@zeulewan/glueclaw-provider 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/stream.ts +38 -6
package/package.json
CHANGED
package/src/stream.ts
CHANGED
|
@@ -356,14 +356,46 @@ export function createClaudeCliStreamFn(opts: {
|
|
|
356
356
|
continue;
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
-
//
|
|
359
|
+
// Assistant message — may contain tool_use and/or text content blocks
|
|
360
360
|
if (type === "assistant") {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
361
|
+
const content = data.message?.content;
|
|
362
|
+
if (content) {
|
|
363
|
+
// Emit tool call events for any tool_use blocks
|
|
364
|
+
for (const block of content) {
|
|
365
|
+
if (block.type === "tool_use") {
|
|
366
|
+
const b = block as {
|
|
367
|
+
type: string;
|
|
368
|
+
id: string;
|
|
369
|
+
name: string;
|
|
370
|
+
input: Record<string, unknown>;
|
|
371
|
+
};
|
|
372
|
+
startStream();
|
|
373
|
+
const toolCall = {
|
|
374
|
+
type: "toolCall" as const,
|
|
375
|
+
id: b.id,
|
|
376
|
+
name: b.name,
|
|
377
|
+
arguments: (b.input ?? {}) as Record<string, any>,
|
|
378
|
+
};
|
|
379
|
+
stream.push({
|
|
380
|
+
type: "toolcall_start",
|
|
381
|
+
contentIndex: 0,
|
|
382
|
+
toolName: b.name,
|
|
383
|
+
partial: buildMsg(info, text, buildUsage()),
|
|
384
|
+
} as any);
|
|
385
|
+
stream.push({
|
|
386
|
+
type: "toolcall_end",
|
|
387
|
+
contentIndex: 0,
|
|
388
|
+
toolCall,
|
|
389
|
+
partial: buildMsg(info, text, buildUsage()),
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Handle text blocks (only if we haven't streamed via deltas)
|
|
395
|
+
if (!streamed) {
|
|
364
396
|
const textBlocks = content
|
|
365
|
-
.filter((b) => b.type === "text" && b.text)
|
|
366
|
-
.map((b) => b.text ?? "");
|
|
397
|
+
.filter((b: any) => b.type === "text" && b.text)
|
|
398
|
+
.map((b: any) => b.text ?? "");
|
|
367
399
|
if (textBlocks.length > 0) {
|
|
368
400
|
const fullText = textBlocks.join("\n");
|
|
369
401
|
startStream();
|