graphlit-client 1.0.20250716002 → 1.0.20250716003
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.
@@ -31,6 +31,8 @@ export declare class UIEventAdapter {
|
|
31
31
|
private reasoningSignature?;
|
32
32
|
private isInReasoning;
|
33
33
|
private usageData?;
|
34
|
+
private hasToolCallsInProgress;
|
35
|
+
private hadToolCallsBeforeResume;
|
34
36
|
constructor(onEvent: (event: AgentStreamEvent) => void, conversationId: string, options?: {
|
35
37
|
smoothingEnabled?: boolean;
|
36
38
|
chunkingStrategy?: ChunkingStrategy;
|
@@ -30,6 +30,8 @@ export class UIEventAdapter {
|
|
30
30
|
reasoningSignature;
|
31
31
|
isInReasoning = false;
|
32
32
|
usageData;
|
33
|
+
hasToolCallsInProgress = false;
|
34
|
+
hadToolCallsBeforeResume = false;
|
33
35
|
constructor(onEvent, conversationId, options = {}) {
|
34
36
|
this.onEvent = onEvent;
|
35
37
|
this.conversationId = conversationId;
|
@@ -99,6 +101,9 @@ export class UIEventAdapter {
|
|
99
101
|
this.lastTokenTime = 0;
|
100
102
|
this.tokenCount = 0;
|
101
103
|
this.tokenDelays = [];
|
104
|
+
// Reset tool call tracking flags
|
105
|
+
this.hasToolCallsInProgress = false;
|
106
|
+
this.hadToolCallsBeforeResume = false;
|
102
107
|
// Note: We only clear tool calls here if this is truly a new conversation start
|
103
108
|
// For multi-round tool calling, handleStart is only called once at the beginning
|
104
109
|
if (this.activeToolCalls.size > 0) {
|
@@ -124,6 +129,19 @@ export class UIEventAdapter {
|
|
124
129
|
}
|
125
130
|
this.lastTokenTime = now;
|
126
131
|
this.tokenCount++;
|
132
|
+
// Check if we're resuming after tool calls and need to add newlines
|
133
|
+
if (this.hadToolCallsBeforeResume && this.hasToolCallsInProgress === false) {
|
134
|
+
// We had tool calls before and now we're receiving content again
|
135
|
+
// Add double newline to separate the content from tool results
|
136
|
+
if (this.currentMessage.length > 0 && !this.currentMessage.endsWith('\n\n')) {
|
137
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
138
|
+
console.log(`📝 [UIEventAdapter] Adding newlines after tool calls before resuming content`);
|
139
|
+
}
|
140
|
+
this.currentMessage += '\n\n';
|
141
|
+
}
|
142
|
+
// Reset the flag now that we've added the newlines
|
143
|
+
this.hadToolCallsBeforeResume = false;
|
144
|
+
}
|
127
145
|
if (this.chunkBuffer) {
|
128
146
|
const chunks = this.chunkBuffer.addToken(token);
|
129
147
|
// Add chunks to queue for all chunking modes (character, word, sentence)
|
@@ -155,6 +173,9 @@ export class UIEventAdapter {
|
|
155
173
|
toolCall: conversationToolCall,
|
156
174
|
status: "preparing",
|
157
175
|
});
|
176
|
+
// Mark that we have tool calls in progress
|
177
|
+
this.hasToolCallsInProgress = true;
|
178
|
+
this.hadToolCallsBeforeResume = true;
|
158
179
|
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
159
180
|
console.log(`🔧 [UIEventAdapter] Active tool calls after: ${this.activeToolCalls.size}`);
|
160
181
|
}
|
@@ -219,6 +240,9 @@ export class UIEventAdapter {
|
|
219
240
|
toolCall: conversationToolCall,
|
220
241
|
status: "ready",
|
221
242
|
});
|
243
|
+
// Mark that we have tool calls
|
244
|
+
this.hasToolCallsInProgress = true;
|
245
|
+
this.hadToolCallsBeforeResume = true;
|
222
246
|
this.emitUIEvent({
|
223
247
|
type: "tool_update",
|
224
248
|
toolCall: conversationToolCall,
|
@@ -246,6 +270,21 @@ export class UIEventAdapter {
|
|
246
270
|
else {
|
247
271
|
console.warn(`🔧 [UIEventAdapter] Tool call complete for unknown tool ID: ${toolCall.id}`);
|
248
272
|
}
|
273
|
+
// Check if all tool calls are complete
|
274
|
+
let allComplete = true;
|
275
|
+
for (const [, data] of this.activeToolCalls) {
|
276
|
+
if (data.status !== "completed" && data.status !== "failed") {
|
277
|
+
allComplete = false;
|
278
|
+
break;
|
279
|
+
}
|
280
|
+
}
|
281
|
+
if (allComplete && this.activeToolCalls.size > 0) {
|
282
|
+
// All tool calls are complete, mark that we're no longer processing tools
|
283
|
+
this.hasToolCallsInProgress = false;
|
284
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
285
|
+
console.log(`🔧 [UIEventAdapter] All tool calls complete, ready to resume content streaming`);
|
286
|
+
}
|
287
|
+
}
|
249
288
|
}
|
250
289
|
handleComplete(tokens) {
|
251
290
|
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "graphlit-client",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.20250716003",
|
4
4
|
"description": "Graphlit API Client for TypeScript",
|
5
5
|
"type": "module",
|
6
6
|
"main": "./dist/client.js",
|
@@ -28,11 +28,7 @@
|
|
28
28
|
"format": "prettier --write .",
|
29
29
|
"build": "tsc -p tsconfig.json",
|
30
30
|
"prepublishOnly": "npm run build",
|
31
|
-
"test": "vitest"
|
32
|
-
"test:watch": "vitest --watch",
|
33
|
-
"test:coverage": "vitest --coverage",
|
34
|
-
"test:ui": "vitest --ui",
|
35
|
-
"test:streaming": "vitest --run src/tests/streaming"
|
31
|
+
"test": "vitest"
|
36
32
|
},
|
37
33
|
"keywords": [
|
38
34
|
"Graphlit",
|