MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / toolCallIdToName

Function toolCallIdToName

packages/kosong/src/providers/google-genai.ts:146–158  ·  view source on GitHub ↗
(toolCallId: string, toolNameById: Map<string, string>)

Source from the content-addressed store, hash-verified

144}
145
146function toolCallIdToName(toolCallId: string, toolNameById: Map<string, string>): string {
147 const name = toolNameById.get(toolCallId);
148 if (name !== undefined) return name;
149 // Fallback: ids produced by this provider follow the format
150 // "{tool_name}_{id_suffix}" where `tool_name` may itself contain
151 // underscores (e.g. `fetch_image`) and `id_suffix` is a single trailing
152 // token without underscores (e.g. a random hex / UUID fragment). We strip
153 // the last "_<suffix>" segment by matching it explicitly — splitting on
154 // the first underscore would truncate multi-word tool names like
155 // `fetch_image_<id>` to just `fetch`.
156 const match = /^(.+)_[^_]+$/.exec(toolCallId);
157 return match?.[1] ?? toolCallId;
158}
159
160/**
161 * Convert a data URL or HTTP URL to a Google GenAI inline/file data part.

Callers 1

Calls 2

getMethod · 0.65
execMethod · 0.65

Tested by

no test coverage detected