MCPcopy Create free account
hub / github.com/atripati/ark / parseToolCallLine

Function parseToolCallLine

pkg/runtime/agent.go:1097–1128  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

1095}
1096
1097func parseToolCallLine(s string) parsedResponse {
1098 parenIdx := strings.Index(s, "(")
1099 if parenIdx < 0 {
1100 toolName := strings.TrimSpace(s)
1101 if toolName != "" {
1102 return parsedResponse{
1103 toolCall: &ToolCall{
1104 Name: toolName,
1105 Params: make(map[string]interface{}),
1106 },
1107 }
1108 }
1109 return parsedResponse{text: s}
1110 }
1111
1112 toolName := strings.TrimSpace(s[:parenIdx])
1113
1114 closeIdx := strings.LastIndex(s, ")")
1115 if closeIdx <= parenIdx {
1116 closeIdx = len(s)
1117 }
1118 paramsStr := s[parenIdx+1 : closeIdx]
1119
1120 params := parseParams(paramsStr)
1121
1122 return parsedResponse{
1123 toolCall: &ToolCall{
1124 Name: toolName,
1125 Params: params,
1126 },
1127 }
1128}
1129
1130func parseParams(s string) map[string]interface{} {
1131 s = strings.TrimSpace(s)

Callers 1

parseResponseFunction · 0.85

Calls 1

parseParamsFunction · 0.85

Tested by

no test coverage detected