MCPcopy Create free account
hub / github.com/anomalyco/opencode / appendExisting

Function appendExisting

packages/llm/src/protocols/utils/tool-stream.ts:146–157  ·  view source on GitHub ↗
(
  route: string,
  tools: State<K>,
  key: K,
  text: string,
  missingToolMessage: string,
)

Source from the content-addressed store, hash-verified

144 * argument delta.
145 */
146export const appendExisting = <K extends StreamKey>(
147 route: string,
148 tools: State<K>,
149 key: K,
150 text: string,
151 missingToolMessage: string,
152): AppendOutcome<K> | LLMError => {
153 const current = tools[key]
154 if (!current) return eventError(route, missingToolMessage)
155 if (text.length === 0) return { tools, tool: current, events: [] }
156 return appendTool(tools, key, { ...current, input: `${current.input}${text}` }, text)
157}
158
159/**
160 * Finalize one pending tool call: parse the accumulated raw JSON, remove it

Callers

nothing calls this directly

Calls 2

eventErrorFunction · 0.90
appendToolFunction · 0.85

Tested by

no test coverage detected