fix: satisfy backend lint
This commit is contained in:
@@ -159,7 +159,7 @@ type KiroToolSpecification struct {
|
||||
}
|
||||
|
||||
type KiroInputSchema struct {
|
||||
JSON interface{} `json:"json"`
|
||||
JSON any `json:"json"`
|
||||
}
|
||||
|
||||
type KiroAssistantResponseMessage struct {
|
||||
@@ -168,11 +168,11 @@ type KiroAssistantResponseMessage struct {
|
||||
}
|
||||
|
||||
type KiroToolUse struct {
|
||||
ToolUseID string `json:"toolUseId"`
|
||||
Name string `json:"name"`
|
||||
Input map[string]interface{} `json:"input"`
|
||||
IsTruncated bool `json:"-"`
|
||||
TruncatedRaw string `json:"-"`
|
||||
ToolUseID string `json:"toolUseId"`
|
||||
Name string `json:"name"`
|
||||
Input map[string]any `json:"input"`
|
||||
IsTruncated bool `json:"-"`
|
||||
TruncatedRaw string `json:"-"`
|
||||
}
|
||||
|
||||
type toolUseState struct {
|
||||
@@ -501,7 +501,7 @@ func StreamEventStreamAsAnthropicWithContext(ctx context.Context, body io.Reader
|
||||
},
|
||||
})
|
||||
}
|
||||
processStreamingToolUseEvent := func(event map[string]interface{}) error {
|
||||
processStreamingToolUseEvent := func(event map[string]any) error {
|
||||
tu := nestedEvent(event, "toolUseEvent")
|
||||
toolUseID := getString(tu, "toolUseId")
|
||||
name := getString(tu, "name")
|
||||
@@ -514,7 +514,7 @@ func StreamEventStreamAsAnthropicWithContext(ctx context.Context, body io.Reader
|
||||
if err := emitStreamingToolInput(toolUseID, name, v); err != nil {
|
||||
return err
|
||||
}
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
encoded, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -825,7 +825,7 @@ func StreamEventStreamAsAnthropicWithContext(ctx context.Context, body io.Reader
|
||||
continue
|
||||
}
|
||||
|
||||
var event map[string]interface{}
|
||||
var event map[string]any
|
||||
if err := json.Unmarshal(msg.Payload, &event); err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -988,10 +988,6 @@ func extractSystemPrompt(claudeBody []byte) string {
|
||||
return systemField.String()
|
||||
}
|
||||
|
||||
func isThinkingEnabledWithHeaders(body []byte, headers http.Header) bool {
|
||||
return deriveThinkingDirective(body, headers) != nil
|
||||
}
|
||||
|
||||
func deriveThinkingDirective(body []byte, headers http.Header) *thinkingDirective {
|
||||
if override := thinkingDirectiveFromModel(gjson.GetBytes(body, "model").String()); override != nil {
|
||||
return override
|
||||
@@ -1129,10 +1125,6 @@ func isToolChoiceNone(claudeBody []byte) bool {
|
||||
return strings.EqualFold(strings.TrimSpace(toolChoice.Get("type").String()), "none")
|
||||
}
|
||||
|
||||
func kiroToolNameAlias(name string) string {
|
||||
return mapKiroToolName(name, nil)
|
||||
}
|
||||
|
||||
func prependSystemHistory(history []KiroHistoryMessage, systemPrompt, modelID, origin string) []KiroHistoryMessage {
|
||||
systemPrompt = strings.TrimSpace(systemPrompt)
|
||||
if systemPrompt == "" {
|
||||
@@ -1220,9 +1212,7 @@ func appendChunkedToolDescription(name, description string) string {
|
||||
if suffix == "" {
|
||||
return description
|
||||
}
|
||||
if strings.Contains(description, suffix) {
|
||||
description = strings.Replace(description, suffix, "", 1)
|
||||
}
|
||||
description = strings.Replace(description, suffix, "", 1)
|
||||
if strings.TrimSpace(description) == "" {
|
||||
return suffix
|
||||
}
|
||||
@@ -1311,11 +1301,11 @@ func normalizeKiroJSONSchema(schema any) any {
|
||||
}
|
||||
|
||||
func normalizeKiroJSONSchemaValue(schema any, enforceObjectKeywords bool) any {
|
||||
obj, ok := schema.(map[string]interface{})
|
||||
obj, ok := schema.(map[string]any)
|
||||
if !ok || obj == nil {
|
||||
return defaultKiroJSONSchema()
|
||||
}
|
||||
normalized := make(map[string]interface{}, len(obj)+4)
|
||||
normalized := make(map[string]any, len(obj)+4)
|
||||
for key, value := range obj {
|
||||
normalized[key] = normalizeSchemaChild(key, value)
|
||||
}
|
||||
@@ -1329,9 +1319,9 @@ func normalizeKiroJSONSchemaValue(schema any, enforceObjectKeywords bool) any {
|
||||
hasSchemaKey(normalized, "required") ||
|
||||
hasSchemaKey(normalized, "additionalProperties")
|
||||
if needsObjectKeywords {
|
||||
properties, ok := normalized["properties"].(map[string]interface{})
|
||||
properties, ok := normalized["properties"].(map[string]any)
|
||||
if !ok || properties == nil {
|
||||
normalized["properties"] = map[string]interface{}{}
|
||||
normalized["properties"] = map[string]any{}
|
||||
} else {
|
||||
for key, value := range properties {
|
||||
properties[key] = normalizeKiroJSONSchemaValue(value, false)
|
||||
@@ -1341,7 +1331,7 @@ func normalizeKiroJSONSchemaValue(schema any, enforceObjectKeywords bool) any {
|
||||
normalized["required"] = normalizeSchemaRequired(normalized["required"])
|
||||
switch additional := normalized["additionalProperties"].(type) {
|
||||
case bool:
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
normalized["additionalProperties"] = normalizeKiroJSONSchemaValue(additional, false)
|
||||
default:
|
||||
normalized["additionalProperties"] = true
|
||||
@@ -1350,26 +1340,26 @@ func normalizeKiroJSONSchemaValue(schema any, enforceObjectKeywords bool) any {
|
||||
return normalized
|
||||
}
|
||||
|
||||
func hasSchemaKey(schema map[string]interface{}, key string) bool {
|
||||
func hasSchemaKey(schema map[string]any, key string) bool {
|
||||
_, ok := schema[key]
|
||||
return ok
|
||||
}
|
||||
|
||||
func defaultKiroJSONSchema() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
func defaultKiroJSONSchema() map[string]any {
|
||||
return map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]interface{}{},
|
||||
"required": []interface{}{},
|
||||
"properties": map[string]any{},
|
||||
"required": []any{},
|
||||
"additionalProperties": true,
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeSchemaRequired(value interface{}) []interface{} {
|
||||
arr, ok := value.([]interface{})
|
||||
func normalizeSchemaRequired(value any) []any {
|
||||
arr, ok := value.([]any)
|
||||
if !ok {
|
||||
return []interface{}{}
|
||||
return []any{}
|
||||
}
|
||||
out := make([]interface{}, 0, len(arr))
|
||||
out := make([]any, 0, len(arr))
|
||||
for _, item := range arr {
|
||||
if s, ok := item.(string); ok {
|
||||
out = append(out, s)
|
||||
@@ -1378,22 +1368,22 @@ func normalizeSchemaRequired(value interface{}) []interface{} {
|
||||
return out
|
||||
}
|
||||
|
||||
func normalizeSchemaChild(key string, value interface{}) interface{} {
|
||||
func normalizeSchemaChild(key string, value any) any {
|
||||
switch key {
|
||||
case "items", "not":
|
||||
if obj, ok := value.(map[string]interface{}); ok {
|
||||
if obj, ok := value.(map[string]any); ok {
|
||||
return normalizeKiroJSONSchemaValue(obj, false)
|
||||
}
|
||||
if arr, ok := value.([]interface{}); ok {
|
||||
out := make([]interface{}, 0, len(arr))
|
||||
if arr, ok := value.([]any); ok {
|
||||
out := make([]any, 0, len(arr))
|
||||
for _, item := range arr {
|
||||
out = append(out, normalizeKiroJSONSchemaValue(item, false))
|
||||
}
|
||||
return out
|
||||
}
|
||||
case "oneOf", "anyOf", "allOf":
|
||||
if arr, ok := value.([]interface{}); ok {
|
||||
out := make([]interface{}, 0, len(arr))
|
||||
if arr, ok := value.([]any); ok {
|
||||
out := make([]any, 0, len(arr))
|
||||
for _, item := range arr {
|
||||
out = append(out, normalizeKiroJSONSchemaValue(item, false))
|
||||
}
|
||||
@@ -1658,7 +1648,7 @@ func buildAssistantMessageStruct(msg gjson.Result, requestCtx *KiroRequestContex
|
||||
_, _ = contentBuilder.WriteString(part.Get("text").String())
|
||||
case "tool_use":
|
||||
toolName := mapKiroToolName(part.Get("name").String(), requestCtx)
|
||||
input := map[string]interface{}{}
|
||||
input := map[string]any{}
|
||||
toolInput := part.Get("input")
|
||||
if toolInput.IsObject() {
|
||||
toolInput.ForEach(func(key, value gjson.Result) bool {
|
||||
@@ -1704,7 +1694,7 @@ func mergeAdjacentMessages(messages []gjson.Result) []gjson.Result {
|
||||
merged = append(merged, msg)
|
||||
continue
|
||||
}
|
||||
mergedMsg := map[string]interface{}{
|
||||
mergedMsg := map[string]any{
|
||||
"role": role,
|
||||
"content": json.RawMessage(mergeMessageContent(lastMsg, msg)),
|
||||
}
|
||||
@@ -1715,7 +1705,7 @@ func mergeAdjacentMessages(messages []gjson.Result) []gjson.Result {
|
||||
}
|
||||
|
||||
func mergeMessageContent(msg1, msg2 gjson.Result) string {
|
||||
var blocks1, blocks2 []map[string]interface{}
|
||||
var blocks1, blocks2 []map[string]any
|
||||
content1 := msg1.Get("content")
|
||||
content2 := msg2.Get("content")
|
||||
if content1.IsArray() {
|
||||
@@ -1723,14 +1713,14 @@ func mergeMessageContent(msg1, msg2 gjson.Result) string {
|
||||
blocks1 = append(blocks1, blockToMap(block))
|
||||
}
|
||||
} else if content1.Type == gjson.String {
|
||||
blocks1 = append(blocks1, map[string]interface{}{"type": "text", "text": content1.String()})
|
||||
blocks1 = append(blocks1, map[string]any{"type": "text", "text": content1.String()})
|
||||
}
|
||||
if content2.IsArray() {
|
||||
for _, block := range content2.Array() {
|
||||
blocks2 = append(blocks2, blockToMap(block))
|
||||
}
|
||||
} else if content2.Type == gjson.String {
|
||||
blocks2 = append(blocks2, map[string]interface{}{"type": "text", "text": content2.String()})
|
||||
blocks2 = append(blocks2, map[string]any{"type": "text", "text": content2.String()})
|
||||
}
|
||||
if len(blocks1) > 0 && len(blocks2) > 0 && blocks1[len(blocks1)-1]["type"] == "text" && blocks2[0]["type"] == "text" {
|
||||
leftText, leftOK := blocks1[len(blocks1)-1]["text"].(string)
|
||||
@@ -1745,13 +1735,13 @@ func mergeMessageContent(msg1, msg2 gjson.Result) string {
|
||||
return string(result)
|
||||
}
|
||||
|
||||
func blockToMap(block gjson.Result) map[string]interface{} {
|
||||
result := make(map[string]interface{})
|
||||
func blockToMap(block gjson.Result) map[string]any {
|
||||
result := make(map[string]any)
|
||||
block.ForEach(func(key, value gjson.Result) bool {
|
||||
if value.IsObject() {
|
||||
result[key.String()] = blockToMap(value)
|
||||
} else if value.IsArray() {
|
||||
var arr []interface{}
|
||||
var arr []any
|
||||
for _, item := range value.Array() {
|
||||
if item.IsObject() {
|
||||
arr = append(arr, blockToMap(item))
|
||||
@@ -1789,7 +1779,7 @@ func parseEventStream(body io.Reader) (string, []KiroToolUse, Usage, string, err
|
||||
continue
|
||||
}
|
||||
|
||||
var event map[string]interface{}
|
||||
var event map[string]any
|
||||
if err := json.Unmarshal(msg.Payload, &event); err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -1835,8 +1825,8 @@ func parseEventStream(body io.Reader) (string, []KiroToolUse, Usage, string, err
|
||||
}
|
||||
|
||||
if currentTool != nil && currentTool.ToolUseID != "" && !processedIDs[currentTool.ToolUseID] {
|
||||
completed, _ := processToolUseEvent(map[string]interface{}{
|
||||
"toolUseEvent": map[string]interface{}{
|
||||
completed, _ := processToolUseEvent(map[string]any{
|
||||
"toolUseEvent": map[string]any{
|
||||
"toolUseId": currentTool.ToolUseID,
|
||||
"name": currentTool.Name,
|
||||
"stop": true,
|
||||
@@ -1866,7 +1856,7 @@ func parseEventStream(body io.Reader) (string, []KiroToolUse, Usage, string, err
|
||||
}
|
||||
|
||||
func buildClaudeResponse(content string, toolUses []KiroToolUse, model string, usage Usage, stopReason string, requestCtx KiroRequestContext) []byte {
|
||||
var blocks []map[string]interface{}
|
||||
var blocks []map[string]any
|
||||
blocks = append(blocks, extractThinkingBlocks(content)...)
|
||||
usableTools := 0
|
||||
for _, tool := range toolUses {
|
||||
@@ -1874,7 +1864,7 @@ func buildClaudeResponse(content string, toolUses []KiroToolUse, model string, u
|
||||
continue
|
||||
}
|
||||
usableTools++
|
||||
blocks = append(blocks, map[string]interface{}{
|
||||
blocks = append(blocks, map[string]any{
|
||||
"type": "tool_use",
|
||||
"id": tool.ToolUseID,
|
||||
"name": restoreResponseToolName(tool.Name, requestCtx),
|
||||
@@ -1883,11 +1873,11 @@ func buildClaudeResponse(content string, toolUses []KiroToolUse, model string, u
|
||||
}
|
||||
pureThinking := hasThinkingBlocksOnly(blocks) && usableTools == 0
|
||||
if pureThinking {
|
||||
blocks = append(blocks, map[string]interface{}{"type": "text", "text": ""})
|
||||
blocks = append(blocks, map[string]any{"type": "text", "text": ""})
|
||||
stopReason = "max_tokens"
|
||||
}
|
||||
if len(blocks) == 0 {
|
||||
blocks = append(blocks, map[string]interface{}{"type": "text", "text": ""})
|
||||
blocks = append(blocks, map[string]any{"type": "text", "text": ""})
|
||||
}
|
||||
if stopReason == "" {
|
||||
if usableTools > 0 {
|
||||
@@ -1896,14 +1886,14 @@ func buildClaudeResponse(content string, toolUses []KiroToolUse, model string, u
|
||||
stopReason = "end_turn"
|
||||
}
|
||||
}
|
||||
response := map[string]interface{}{
|
||||
response := map[string]any{
|
||||
"id": "msg_" + uuid.NewString()[:24],
|
||||
"type": "message",
|
||||
"role": "assistant",
|
||||
"model": model,
|
||||
"content": blocks,
|
||||
"stop_reason": stopReason,
|
||||
"usage": map[string]interface{}{
|
||||
"usage": map[string]any{
|
||||
"input_tokens": usage.InputTokens,
|
||||
"output_tokens": usage.OutputTokens,
|
||||
"cache_read_input_tokens": usage.CacheReadInputTokens,
|
||||
@@ -1925,7 +1915,7 @@ func restoreResponseToolName(name string, requestCtx KiroRequestContext) string
|
||||
return name
|
||||
}
|
||||
|
||||
func hasThinkingBlocksOnly(blocks []map[string]interface{}) bool {
|
||||
func hasThinkingBlocksOnly(blocks []map[string]any) bool {
|
||||
if len(blocks) == 0 {
|
||||
return false
|
||||
}
|
||||
@@ -1944,36 +1934,36 @@ func hasThinkingBlocksOnly(blocks []map[string]interface{}) bool {
|
||||
return hasThinking
|
||||
}
|
||||
|
||||
func extractThinkingBlocks(content string) []map[string]interface{} {
|
||||
func extractThinkingBlocks(content string) []map[string]any {
|
||||
if content == "" {
|
||||
return nil
|
||||
}
|
||||
if findRealThinkingStartTag(content, 0) == -1 {
|
||||
return []map[string]interface{}{{"type": "text", "text": content}}
|
||||
return []map[string]any{{"type": "text", "text": content}}
|
||||
}
|
||||
var blocks []map[string]interface{}
|
||||
var blocks []map[string]any
|
||||
pos := 0
|
||||
for pos < len(content) {
|
||||
start := findRealThinkingStartTag(content, pos)
|
||||
if start == -1 {
|
||||
if text := content[pos:]; strings.TrimSpace(text) != "" {
|
||||
blocks = append(blocks, map[string]interface{}{"type": "text", "text": text})
|
||||
blocks = append(blocks, map[string]any{"type": "text", "text": text})
|
||||
}
|
||||
break
|
||||
}
|
||||
end := findRealThinkingEndTag(content, start+len(thinkingStartTag))
|
||||
if end == -1 {
|
||||
if text := content[pos:]; strings.TrimSpace(text) != "" {
|
||||
blocks = append(blocks, map[string]interface{}{"type": "text", "text": text})
|
||||
blocks = append(blocks, map[string]any{"type": "text", "text": text})
|
||||
}
|
||||
break
|
||||
}
|
||||
if text := content[pos:start]; strings.TrimSpace(text) != "" {
|
||||
blocks = append(blocks, map[string]interface{}{"type": "text", "text": text})
|
||||
blocks = append(blocks, map[string]any{"type": "text", "text": text})
|
||||
}
|
||||
thinking := strings.TrimPrefix(content[start+len(thinkingStartTag):end], "\n")
|
||||
if strings.TrimSpace(thinking) != "" {
|
||||
blocks = append(blocks, map[string]interface{}{
|
||||
blocks = append(blocks, map[string]any{
|
||||
"type": "thinking",
|
||||
"thinking": thinking,
|
||||
"signature": thinkingSignature(thinking),
|
||||
@@ -1985,7 +1975,7 @@ func extractThinkingBlocks(content string) []map[string]interface{} {
|
||||
}
|
||||
}
|
||||
if len(blocks) == 0 {
|
||||
blocks = append(blocks, map[string]interface{}{"type": "text", "text": ""})
|
||||
blocks = append(blocks, map[string]any{"type": "text", "text": ""})
|
||||
}
|
||||
return blocks
|
||||
}
|
||||
@@ -2238,19 +2228,19 @@ func skipHeaderValue(headers []byte, offset int, valueType byte) (int, bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func processToolUseEvent(event map[string]interface{}, currentTool *toolUseState, processedIDs map[string]bool) ([]KiroToolUse, *toolUseState) {
|
||||
func processToolUseEvent(event map[string]any, currentTool *toolUseState, processedIDs map[string]bool) ([]KiroToolUse, *toolUseState) {
|
||||
tu := nestedEvent(event, "toolUseEvent")
|
||||
toolUseID := getString(tu, "toolUseId")
|
||||
name := getString(tu, "name")
|
||||
isStop, _ := tu["stop"].(bool)
|
||||
|
||||
var inputFragment string
|
||||
var inputMap map[string]interface{}
|
||||
var inputMap map[string]any
|
||||
if inputRaw, ok := tu["input"]; ok {
|
||||
switch v := inputRaw.(type) {
|
||||
case string:
|
||||
inputFragment = v
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
inputMap = v
|
||||
}
|
||||
}
|
||||
@@ -2283,7 +2273,7 @@ func repairJSON(input string) string {
|
||||
if str == "" {
|
||||
return "{}"
|
||||
}
|
||||
var parsed interface{}
|
||||
var parsed any
|
||||
if err := json.Unmarshal([]byte(str), &parsed); err == nil {
|
||||
return str
|
||||
}
|
||||
@@ -2382,7 +2372,7 @@ func finalizeRawToolUse(toolUseID, name, rawInput string) KiroToolUse {
|
||||
tool := KiroToolUse{
|
||||
ToolUseID: toolUseID,
|
||||
Name: normalizeResponseToolName(name),
|
||||
Input: map[string]interface{}{},
|
||||
Input: map[string]any{},
|
||||
}
|
||||
rawInput = strings.TrimSpace(rawInput)
|
||||
tool.TruncatedRaw = rawInput
|
||||
@@ -2394,9 +2384,9 @@ func finalizeRawToolUse(toolUseID, name, rawInput string) KiroToolUse {
|
||||
return tool
|
||||
}
|
||||
|
||||
func finalizeStructuredToolUse(toolUseID, name string, input map[string]interface{}) KiroToolUse {
|
||||
func finalizeStructuredToolUse(toolUseID, name string, input map[string]any) KiroToolUse {
|
||||
if input == nil {
|
||||
input = map[string]interface{}{}
|
||||
input = map[string]any{}
|
||||
}
|
||||
tool := KiroToolUse{
|
||||
ToolUseID: toolUseID,
|
||||
@@ -2508,14 +2498,14 @@ func parseEmbeddedToolCalls(text string) (string, []KiroToolUse) {
|
||||
for index < len(text) {
|
||||
start := strings.Index(text[index:], embeddedToolCallPrefix)
|
||||
if start == -1 {
|
||||
builder.WriteString(text[index:])
|
||||
_, _ = builder.WriteString(text[index:])
|
||||
break
|
||||
}
|
||||
start += index
|
||||
builder.WriteString(text[index:start])
|
||||
_, _ = builder.WriteString(text[index:start])
|
||||
tool, _, end, ok := parseEmbeddedToolCallAt(text, start)
|
||||
if !ok {
|
||||
builder.WriteString(text[start:])
|
||||
_, _ = builder.WriteString(text[start:])
|
||||
break
|
||||
}
|
||||
toolUses = append(toolUses, tool)
|
||||
@@ -2596,7 +2586,7 @@ func findMatchingJSONBracket(text string, start int) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
func isTruncatedToolUse(name, rawInput string, input map[string]interface{}) bool {
|
||||
func isTruncatedToolUse(name, rawInput string, input map[string]any) bool {
|
||||
rawInput = strings.TrimSpace(rawInput)
|
||||
if rawInput == "" {
|
||||
return hasToolRequirements(name)
|
||||
@@ -2625,7 +2615,7 @@ func hasToolRequirements(name string) bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
func hasMissingRequiredFields(name string, input map[string]interface{}) bool {
|
||||
func hasMissingRequiredFields(name string, input map[string]any) bool {
|
||||
groups, ok := requiredToolFields[strings.ToLower(strings.TrimSpace(name))]
|
||||
if !ok {
|
||||
return false
|
||||
@@ -2645,7 +2635,7 @@ func hasMissingRequiredFields(name string, input map[string]interface{}) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func updateUsageFromEvent(usage *Usage, eventType string, event map[string]interface{}) {
|
||||
func updateUsageFromEvent(usage *Usage, eventType string, event map[string]any) {
|
||||
if usage == nil {
|
||||
return
|
||||
}
|
||||
@@ -2653,7 +2643,7 @@ func updateUsageFromEvent(usage *Usage, eventType string, event map[string]inter
|
||||
if len(meta) == 0 {
|
||||
meta = event
|
||||
}
|
||||
if tokenUsage, ok := meta["tokenUsage"].(map[string]interface{}); ok {
|
||||
if tokenUsage, ok := meta["tokenUsage"].(map[string]any); ok {
|
||||
if value, ok := firstInt(tokenUsage, "uncachedInputTokens", "inputTokens", "inputTokenCount", "promptTokens", "prompt_tokens"); ok {
|
||||
usage.InputTokens = value
|
||||
}
|
||||
@@ -2707,7 +2697,7 @@ func updateUsageFromEvent(usage *Usage, eventType string, event map[string]inter
|
||||
}
|
||||
}
|
||||
|
||||
func firstInt(m map[string]interface{}, keys ...string) (int, bool) {
|
||||
func firstInt(m map[string]any, keys ...string) (int, bool) {
|
||||
for _, key := range keys {
|
||||
if value, ok := toInt(m[key]); ok {
|
||||
return value, true
|
||||
@@ -2716,7 +2706,7 @@ func firstInt(m map[string]interface{}, keys ...string) (int, bool) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func firstFloat(m map[string]interface{}, keys ...string) (float64, bool) {
|
||||
func firstFloat(m map[string]any, keys ...string) (float64, bool) {
|
||||
for _, key := range keys {
|
||||
switch v := m[key].(type) {
|
||||
case float64:
|
||||
@@ -2786,11 +2776,11 @@ func countKiroTextTokens(text string) int {
|
||||
return tokens
|
||||
}
|
||||
|
||||
func readToolUses(primary, fallback map[string]interface{}) []KiroToolUse {
|
||||
var raw []interface{}
|
||||
if value, ok := primary["toolUses"].([]interface{}); ok {
|
||||
func readToolUses(primary, fallback map[string]any) []KiroToolUse {
|
||||
var raw []any
|
||||
if value, ok := primary["toolUses"].([]any); ok {
|
||||
raw = value
|
||||
} else if value, ok := fallback["toolUses"].([]interface{}); ok {
|
||||
} else if value, ok := fallback["toolUses"].([]any); ok {
|
||||
raw = value
|
||||
}
|
||||
if len(raw) == 0 {
|
||||
@@ -2798,12 +2788,12 @@ func readToolUses(primary, fallback map[string]interface{}) []KiroToolUse {
|
||||
}
|
||||
out := make([]KiroToolUse, 0, len(raw))
|
||||
for _, item := range raw {
|
||||
tool, ok := item.(map[string]interface{})
|
||||
tool, ok := item.(map[string]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
input := map[string]interface{}{}
|
||||
if value, ok := tool["input"].(map[string]interface{}); ok {
|
||||
input := map[string]any{}
|
||||
if value, ok := tool["input"].(map[string]any); ok {
|
||||
input = value
|
||||
}
|
||||
out = append(out, finalizeStructuredToolUse(getString(tool, "toolUseId"), getString(tool, "name"), input))
|
||||
@@ -2811,28 +2801,28 @@ func readToolUses(primary, fallback map[string]interface{}) []KiroToolUse {
|
||||
return out
|
||||
}
|
||||
|
||||
func nestedEvent(event map[string]interface{}, key string) map[string]interface{} {
|
||||
if nested, ok := event[key].(map[string]interface{}); ok {
|
||||
func nestedEvent(event map[string]any, key string) map[string]any {
|
||||
if nested, ok := event[key].(map[string]any); ok {
|
||||
return nested
|
||||
}
|
||||
return event
|
||||
}
|
||||
|
||||
func getString(m map[string]interface{}, key string) string {
|
||||
func getString(m map[string]any, key string) string {
|
||||
if value, ok := m[key].(string); ok {
|
||||
return value
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func readStopReason(m map[string]interface{}) string {
|
||||
func readStopReason(m map[string]any) string {
|
||||
if stop := getString(m, "stop_reason"); stop != "" {
|
||||
return stop
|
||||
}
|
||||
return getString(m, "stopReason")
|
||||
}
|
||||
|
||||
func toInt(value interface{}) (int, bool) {
|
||||
func toInt(value any) (int, bool) {
|
||||
switch v := value.(type) {
|
||||
case float64:
|
||||
return int(v), true
|
||||
|
||||
Reference in New Issue
Block a user