Documentation
¶
Index ¶
- Constants
- func ApplySystemCachePoints(system anthropic.SystemPrompt, history []kiroproto.HistoryEntry, ...)
- func ApplyToolCachePoints(tools []anthropic.Tool, entries []kiroproto.ToolEntry) []kiroproto.ToolEntry
- func ConvertTools(tools []anthropic.Tool, nameMap *ToolNameMap) []kiroproto.ToolEntry
- func ExtractImages(content anthropic.MessageContent) []kiroproto.Image
- func ExtractSystemPrompt(system anthropic.SystemPrompt) string
- func ExtractTextContent(content anthropic.MessageContent) string
- func ExtractThinkingToolUses(content anthropic.MessageContent) []kiroproto.HistoryToolUse
- func ExtractToolReferences(messages []anthropic.Message) []string
- func ExtractToolResults(content anthropic.MessageContent) []kiroproto.ToolResult
- func ExtractToolUses(content anthropic.MessageContent) []kiroproto.HistoryToolUse
- func Normalize(msgs []anthropic.Message, hasTools bool) []anthropic.Message
- func ReorderToolResults(results []kiroproto.ToolResult, toolUseIDs []string) []kiroproto.ToolResult
- func SanitizeJSONSchema(schema map[string]any) map[string]any
- func ThinkingToolEntry() kiroproto.ToolEntry
- type BuildOptions
- type ToolNameMap
Constants ¶
const ThinkingToolName = kiroproto.ThinkingToolName
ThinkingToolName is an alias for kiroproto.ThinkingToolName for use in tests within this package.
Variables ¶
This section is empty.
Functions ¶
func ApplySystemCachePoints ¶
func ApplySystemCachePoints(system anthropic.SystemPrompt, history []kiroproto.HistoryEntry, currentMessage *kiroproto.UserInputMessage)
ApplySystemCachePoints is a no-op for now. v2 captures show cachePoint is NOT placed on currentMessage or history entries for system-level cache_control. Only tool-level cachePoints are used.
func ApplyToolCachePoints ¶
func ApplyToolCachePoints(tools []anthropic.Tool, entries []kiroproto.ToolEntry) []kiroproto.ToolEntry
ApplyToolCachePoints inserts cachePoint entries into the tools array after tools that have cache_control set.
func ConvertTools ¶
func ConvertTools(tools []anthropic.Tool, nameMap *ToolNameMap) []kiroproto.ToolEntry
ConvertTools converts Anthropic tool definitions to Kiro tool entries. Names exceeding 64 characters are shortened via nameMap.
func ExtractImages ¶
func ExtractImages(content anthropic.MessageContent) []kiroproto.Image
ExtractImages extracts image blocks from message content and converts to Kiro format. URL-based images are skipped with a warning log.
func ExtractSystemPrompt ¶
func ExtractSystemPrompt(system anthropic.SystemPrompt) string
ExtractSystemPrompt extracts the system prompt text from the SystemPrompt union type. String form returns as-is. Array form joins text blocks with "\n".
func ExtractTextContent ¶
func ExtractTextContent(content anthropic.MessageContent) string
ExtractTextContent extracts plain text from message content. String content is returned as-is. For block arrays: text blocks are joined with space, thinking blocks are ignored, unknown blocks are converted to text like [type: name].
func ExtractThinkingToolUses ¶
func ExtractThinkingToolUses(content anthropic.MessageContent) []kiroproto.HistoryToolUse
ExtractThinkingToolUses extracts thinking content blocks from assistant messages and converts them to Kiro thinking tool_use entries for history. Unlike regular tool_use, thinking tool results are NOT sent back to the upstream.
func ExtractToolReferences ¶ added in v0.0.5
ExtractToolReferences scans conversation history for tool_reference blocks and returns the referenced tool names. These appear in: - tool_search_tool_result content (nested tool_references array via ToolReferences field) - tool_result content with tool_reference blocks - top-level tool_reference blocks
func ExtractToolResults ¶
func ExtractToolResults(content anthropic.MessageContent) []kiroproto.ToolResult
ExtractToolResults extracts tool_result blocks from message content and converts to Kiro format.
func ExtractToolUses ¶
func ExtractToolUses(content anthropic.MessageContent) []kiroproto.HistoryToolUse
ExtractToolUses extracts tool_use blocks from assistant message content and converts to Kiro format.
func ReorderToolResults ¶
func ReorderToolResults(results []kiroproto.ToolResult, toolUseIDs []string) []kiroproto.ToolResult
ReorderToolResults reorders tool results to match the order of tool_use IDs from the preceding assistant message. Results not found in toolUseIDs are appended at the end.
func SanitizeJSONSchema ¶
SanitizeJSONSchema recursively removes fields that Kiro API rejects.
func ThinkingToolEntry ¶
ThinkingToolEntry returns the Kiro thinking tool entry matching the real Kiro client.
Types ¶
type BuildOptions ¶
type BuildOptions struct {
ProfileARN string
ModelID string
ConversationID string
Thinking bool
ThinkingBudget int
ToolSearchCtx *toolsearch.Context
}
BuildOptions controls how an Anthropic request is mapped to a Kiro payload.
type ToolNameMap ¶ added in v0.0.10
type ToolNameMap struct {
// contains filtered or unexported fields
}
ToolNameMap provides bidirectional mapping between original and shortened tool names. All methods are safe to call on a nil receiver (no-op passthrough).
func BuildPayload ¶
func BuildPayload(req *anthropic.Request, options BuildOptions) (*kiroproto.Payload, *ToolNameMap, error)
BuildPayload converts an Anthropic request into a Kiro API payload.
func NewToolNameMap ¶ added in v0.0.10
func NewToolNameMap() *ToolNameMap
NewToolNameMap creates a new ToolNameMap. Maps are lazily allocated on first use.
func (*ToolNameMap) Restore ¶ added in v0.0.10
func (m *ToolNameMap) Restore(name string) string
Restore returns the original name for a shortened name, or name itself if not mapped. Safe to call on nil receiver.
func (*ToolNameMap) ReverseMap ¶ added in v0.0.10
func (m *ToolNameMap) ReverseMap() map[string]string
ReverseMap returns the short→original map for use in the response path. Returns nil if no mappings exist.
func (*ToolNameMap) Shorten ¶ added in v0.0.10
func (m *ToolNameMap) Shorten(name string) string
Shorten returns name as-is if <= 64 chars. Otherwise shortens, registers mapping, and returns the shortened name. Safe to call on nil receiver.