MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / processAiSdkStreamPart

Function processAiSdkStreamPart

src/api/transform/ai-sdk.ts:196–282  ·  view source on GitHub ↗
(part: ExtendedStreamPart)

Source from the content-addressed store, hash-verified

194 * @yields ApiStreamChunk objects corresponding to the stream part
195 */
196export function* processAiSdkStreamPart(part: ExtendedStreamPart): Generator<ApiStreamChunk> {
197 switch (part.type) {
198 case "text":
199 case "text-delta":
200 yield { type: "text", text: (part as { text: string }).text }
201 break
202
203 case "reasoning":
204 case "reasoning-delta":
205 yield { type: "reasoning", text: (part as { text: string }).text }
206 break
207
208 case "tool-input-start":
209 yield {
210 type: "tool_call_start",
211 id: part.id,
212 name: part.toolName,
213 }
214 break
215
216 case "tool-input-delta":
217 yield {
218 type: "tool_call_delta",
219 id: part.id,
220 delta: part.delta,
221 }
222 break
223
224 case "tool-input-end":
225 yield {
226 type: "tool_call_end",
227 id: part.id,
228 }
229 break
230
231 case "tool-call":
232 // Complete tool call - emit for compatibility
233 yield {
234 type: "tool_call",
235 id: part.toolCallId,
236 name: part.toolName,
237 arguments: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
238 }
239 break
240
241 case "source":
242 // Handle both URL and document source types
243 if ("url" in part) {
244 yield {
245 type: "grounding",
246 sources: [
247 {
248 title: part.title || "Source",
249 url: part.url,
250 snippet: undefined,
251 },
252 ],
253 }

Callers 3

createMessageFunction · 0.90
createMessageMethod · 0.90
ai-sdk.spec.tsFile · 0.90

Calls 1

StringInterface · 0.50

Tested by

no test coverage detected