@dexto/core 1.6.22 → 1.6.25
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/dist/agent/DextoAgent.cjs +25 -3
- package/dist/agent/DextoAgent.d.ts +4 -0
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +25 -3
- package/dist/agent/state-manager.cjs +6 -0
- package/dist/agent/state-manager.d.ts +4 -0
- package/dist/agent/state-manager.d.ts.map +1 -1
- package/dist/agent/state-manager.js +6 -0
- package/dist/context/manager.cjs +3 -0
- package/dist/context/manager.d.ts +2 -0
- package/dist/context/manager.d.ts.map +1 -1
- package/dist/context/manager.js +3 -0
- package/dist/context/types.d.ts +3 -0
- package/dist/context/types.d.ts.map +1 -1
- package/dist/events/index.d.ts +14 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.cjs +61 -20
- package/dist/llm/executor/stream-processor.d.ts +7 -0
- package/dist/llm/executor/stream-processor.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.js +61 -20
- package/dist/llm/executor/turn-executor.cjs +3 -0
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +3 -0
- package/dist/llm/providers/local/schemas.d.ts +2 -2
- package/dist/llm/registry/index.cjs +1 -1
- package/dist/llm/registry/index.js +1 -1
- package/dist/llm/schemas.d.ts +50 -50
- package/dist/llm/services/factory.cjs +19 -1
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +19 -1
- package/dist/llm/usage-metadata.cjs +4 -2
- package/dist/llm/usage-metadata.d.ts +2 -0
- package/dist/llm/usage-metadata.d.ts.map +1 -1
- package/dist/llm/usage-metadata.js +8 -3
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/tool-call-metadata.cjs +1 -1
- package/dist/tools/tool-call-metadata.d.ts +1 -1
- package/dist/tools/tool-call-metadata.d.ts.map +1 -1
- package/dist/tools/tool-call-metadata.js +1 -1
- package/dist/tools/tool-manager.cjs +3 -0
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +7 -1
- package/dist/tools/types.d.ts +2 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -208,6 +208,9 @@ class StreamProcessor {
|
|
|
208
208
|
...metadata?.presentationSnapshot !== void 0 && {
|
|
209
209
|
presentationSnapshot: metadata.presentationSnapshot
|
|
210
210
|
},
|
|
211
|
+
...metadata?.meta !== void 0 && {
|
|
212
|
+
meta: metadata.meta
|
|
213
|
+
},
|
|
211
214
|
callId: event.toolCallId,
|
|
212
215
|
success: true,
|
|
213
216
|
sanitized: truncated,
|
|
@@ -318,6 +321,7 @@ class StreamProcessor {
|
|
|
318
321
|
error: event.error
|
|
319
322
|
});
|
|
320
323
|
const errorMessage = event.error instanceof Error ? event.error.message : String(event.error);
|
|
324
|
+
const metadata = this.toolCallMetadata?.get(event.toolCallId);
|
|
321
325
|
const errorResult = {
|
|
322
326
|
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
323
327
|
meta: {
|
|
@@ -330,14 +334,25 @@ class StreamProcessor {
|
|
|
330
334
|
event.toolCallId,
|
|
331
335
|
event.toolName,
|
|
332
336
|
errorResult,
|
|
333
|
-
|
|
334
|
-
// No approval metadata for errors
|
|
337
|
+
metadata
|
|
335
338
|
);
|
|
336
339
|
this.eventBus.emit("llm:tool-result", {
|
|
337
340
|
toolName: event.toolName,
|
|
341
|
+
...metadata?.presentationSnapshot !== void 0 && {
|
|
342
|
+
presentationSnapshot: metadata.presentationSnapshot
|
|
343
|
+
},
|
|
344
|
+
...metadata?.meta !== void 0 && {
|
|
345
|
+
meta: metadata.meta
|
|
346
|
+
},
|
|
338
347
|
callId: event.toolCallId,
|
|
339
348
|
success: false,
|
|
340
|
-
error: errorMessage
|
|
349
|
+
error: errorMessage,
|
|
350
|
+
...metadata?.requireApproval !== void 0 && {
|
|
351
|
+
requireApproval: metadata.requireApproval
|
|
352
|
+
},
|
|
353
|
+
...metadata?.approvalStatus !== void 0 && {
|
|
354
|
+
approvalStatus: metadata.approvalStatus
|
|
355
|
+
}
|
|
341
356
|
});
|
|
342
357
|
this.eventBus.emit("llm:error", {
|
|
343
358
|
error: event.error instanceof Error ? event.error : new Error(String(event.error)),
|
|
@@ -346,17 +361,15 @@ class StreamProcessor {
|
|
|
346
361
|
recoverable: true
|
|
347
362
|
// Tool errors are typically recoverable
|
|
348
363
|
});
|
|
364
|
+
this.toolCallMetadata?.delete(event.toolCallId);
|
|
349
365
|
this.pendingToolCalls.delete(event.toolCallId);
|
|
350
366
|
this.partialToolCalls.delete(event.toolCallId);
|
|
351
367
|
break;
|
|
352
368
|
}
|
|
353
369
|
case "error": {
|
|
354
370
|
const err = event.error instanceof Error ? event.error : new Error(String(event.error));
|
|
355
|
-
this.
|
|
356
|
-
|
|
357
|
-
error: err
|
|
358
|
-
});
|
|
359
|
-
break;
|
|
371
|
+
await this.persistFailedToolResults(err.message);
|
|
372
|
+
throw err;
|
|
360
373
|
}
|
|
361
374
|
case "abort": {
|
|
362
375
|
this.logger.debug("Stream aborted, emitting partial response");
|
|
@@ -411,11 +424,6 @@ class StreamProcessor {
|
|
|
411
424
|
};
|
|
412
425
|
}
|
|
413
426
|
this.logger.error("Stream processing failed", { error });
|
|
414
|
-
this.eventBus.emit("llm:error", {
|
|
415
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
416
|
-
context: "StreamProcessor",
|
|
417
|
-
recoverable: false
|
|
418
|
-
});
|
|
419
427
|
throw error;
|
|
420
428
|
}
|
|
421
429
|
return {
|
|
@@ -482,6 +490,9 @@ class StreamProcessor {
|
|
|
482
490
|
...config.estimatedCost !== void 0 && {
|
|
483
491
|
estimatedCost: config.estimatedCost
|
|
484
492
|
},
|
|
493
|
+
...config.costBreakdown && {
|
|
494
|
+
costBreakdown: config.costBreakdown
|
|
495
|
+
},
|
|
485
496
|
...config.pricingStatus && { pricingStatus: config.pricingStatus },
|
|
486
497
|
...this.config.estimatedInputTokens !== void 0 && {
|
|
487
498
|
estimatedInputTokens: this.config.estimatedInputTokens
|
|
@@ -548,13 +559,31 @@ class StreamProcessor {
|
|
|
548
559
|
* Called on abort/cancel to prevent "tool_use ids were found without tool_result" errors.
|
|
549
560
|
*/
|
|
550
561
|
async persistCancelledToolResults() {
|
|
562
|
+
await this.persistPendingToolResults({
|
|
563
|
+
logLabel: "cancelled",
|
|
564
|
+
resultText: "Cancelled by user",
|
|
565
|
+
errorMessage: "Cancelled by user"
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Persist synthetic failed results for pending tool calls before surfacing a fatal stream error.
|
|
570
|
+
*/
|
|
571
|
+
async persistFailedToolResults(errorMessage) {
|
|
572
|
+
await this.persistPendingToolResults({
|
|
573
|
+
logLabel: "failed",
|
|
574
|
+
resultText: `Error: ${errorMessage}`,
|
|
575
|
+
errorMessage
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
async persistPendingToolResults(options) {
|
|
551
579
|
if (this.pendingToolCalls.size === 0) return;
|
|
552
580
|
this.logger.debug(
|
|
553
|
-
`Persisting
|
|
581
|
+
`Persisting ${options.logLabel} results for ${this.pendingToolCalls.size} pending tool call(s)`
|
|
554
582
|
);
|
|
555
583
|
for (const [toolCallId, { toolName }] of this.pendingToolCalls) {
|
|
556
|
-
const
|
|
557
|
-
|
|
584
|
+
const metadata = this.toolCallMetadata?.get(toolCallId);
|
|
585
|
+
const syntheticResult = {
|
|
586
|
+
content: [{ type: "text", text: options.resultText }],
|
|
558
587
|
meta: {
|
|
559
588
|
toolName,
|
|
560
589
|
toolCallId,
|
|
@@ -564,16 +593,28 @@ class StreamProcessor {
|
|
|
564
593
|
await this.contextManager.addToolResult(
|
|
565
594
|
toolCallId,
|
|
566
595
|
toolName,
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
// No approval metadata for cancelled tools
|
|
596
|
+
syntheticResult,
|
|
597
|
+
metadata
|
|
570
598
|
);
|
|
571
599
|
this.eventBus.emit("llm:tool-result", {
|
|
572
600
|
toolName,
|
|
601
|
+
...metadata?.presentationSnapshot !== void 0 && {
|
|
602
|
+
presentationSnapshot: metadata.presentationSnapshot
|
|
603
|
+
},
|
|
604
|
+
...metadata?.meta !== void 0 && {
|
|
605
|
+
meta: metadata.meta
|
|
606
|
+
},
|
|
573
607
|
callId: toolCallId,
|
|
574
608
|
success: false,
|
|
575
|
-
error:
|
|
609
|
+
error: options.errorMessage,
|
|
610
|
+
...metadata?.requireApproval !== void 0 && {
|
|
611
|
+
requireApproval: metadata.requireApproval
|
|
612
|
+
},
|
|
613
|
+
...metadata?.approvalStatus !== void 0 && {
|
|
614
|
+
approvalStatus: metadata.approvalStatus
|
|
615
|
+
}
|
|
576
616
|
});
|
|
617
|
+
this.toolCallMetadata?.delete(toolCallId);
|
|
577
618
|
}
|
|
578
619
|
this.pendingToolCalls.clear();
|
|
579
620
|
}
|
|
@@ -5,6 +5,7 @@ import { ResourceManager } from '../../resources/index.js';
|
|
|
5
5
|
import { StreamProcessorResult } from './types.js';
|
|
6
6
|
import type { Logger } from '../../logger/v2/types.js';
|
|
7
7
|
import type { ToolPresentationSnapshotV1 } from '../../tools/types.js';
|
|
8
|
+
import type { ToolCallMetadata } from '../../tools/tool-call-metadata.js';
|
|
8
9
|
import type { LLMProvider, ReasoningVariant } from '../types.js';
|
|
9
10
|
export interface StreamProcessorConfig {
|
|
10
11
|
provider: LLMProvider;
|
|
@@ -52,6 +53,7 @@ export declare class StreamProcessor {
|
|
|
52
53
|
*/
|
|
53
54
|
constructor(contextManager: ContextManager, eventBus: SessionEventBus, resourceManager: ResourceManager, abortSignal: AbortSignal, config: StreamProcessorConfig, logger: Logger, streaming?: boolean, toolCallMetadata?: Map<string, {
|
|
54
55
|
presentationSnapshot?: ToolPresentationSnapshotV1;
|
|
56
|
+
meta?: ToolCallMetadata;
|
|
55
57
|
requireApproval?: boolean;
|
|
56
58
|
approvalStatus?: "approved" | "rejected";
|
|
57
59
|
}> | undefined);
|
|
@@ -71,5 +73,10 @@ export declare class StreamProcessor {
|
|
|
71
73
|
* Called on abort/cancel to prevent "tool_use ids were found without tool_result" errors.
|
|
72
74
|
*/
|
|
73
75
|
private persistCancelledToolResults;
|
|
76
|
+
/**
|
|
77
|
+
* Persist synthetic failed results for pending tool calls before surfacing a fatal stream error.
|
|
78
|
+
*/
|
|
79
|
+
private persistFailedToolResults;
|
|
80
|
+
private persistPendingToolResults;
|
|
74
81
|
}
|
|
75
82
|
//# sourceMappingURL=stream-processor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-processor.d.ts","sourceRoot":"","sources":["../../../src/llm/executor/stream-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,IAAI,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAmB,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"stream-processor.d.ts","sourceRoot":"","sources":["../../../src/llm/executor/stream-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,IAAI,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAmB,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAG1E,OAAO,KAAK,EAAE,WAAW,EAAoB,gBAAgB,EAAc,MAAM,aAAa,CAAC;AA4C/F,MAAM,WAAW,qBAAqB;IAClC,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yEAAyE;IACzE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,gFAAgF;IAChF,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,qBAAa,eAAe;IA4BpB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,MAAM;IAEd,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,gBAAgB,CAAC;IAlC7B,OAAO,CAAC,kBAAkB,CAAuB;IACjD,OAAO,CAAC,YAAY,CAAmE;IACvF,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,iBAAiB,CAAsC;IAC/D,OAAO,CAAC,eAAe,CAAc;IACrC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqB;IAClD;;;OAGG;IACH,OAAO,CAAC,gBAAgB,CAAgD;IACxE,OAAO,CAAC,gBAAgB,CAAkE;IAE1F;;;;;;;;;OASG;gBAES,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,eAAe,EACzB,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,qBAAqB,EACrC,MAAM,EAAE,MAAM,EACN,SAAS,GAAE,OAAc,EACzB,gBAAgB,CAAC,EAAE,GAAG,CAC1B,MAAM,EACN;QACI,oBAAoB,CAAC,EAAE,0BAA0B,CAAC;QAClD,IAAI,CAAC,EAAE,gBAAgB,CAAC;QACxB,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,cAAc,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;KAC5C,CACJ,YAAA;IAMC,OAAO,CACT,QAAQ,EAAE,MAAM,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,GACzD,OAAO,CAAC,qBAAqB,CAAC;IA+fjC,OAAO,CAAC,kCAAkC;IAoB1C,OAAO,CAAC,cAAc;IA0CtB,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,0BAA0B;IAclC,OAAO,CAAC,eAAe;YA8BT,gCAAgC;IA0B9C,OAAO,CAAC,sBAAsB;YAwChB,sBAAsB;YAKtB,gBAAgB;IAO9B;;;;OAIG;YACW,2BAA2B;IAQzC;;OAEG;YACW,wBAAwB;YAQxB,yBAAyB;CAqD1C"}
|
|
@@ -186,6 +186,9 @@ class StreamProcessor {
|
|
|
186
186
|
...metadata?.presentationSnapshot !== void 0 && {
|
|
187
187
|
presentationSnapshot: metadata.presentationSnapshot
|
|
188
188
|
},
|
|
189
|
+
...metadata?.meta !== void 0 && {
|
|
190
|
+
meta: metadata.meta
|
|
191
|
+
},
|
|
189
192
|
callId: event.toolCallId,
|
|
190
193
|
success: true,
|
|
191
194
|
sanitized: truncated,
|
|
@@ -296,6 +299,7 @@ class StreamProcessor {
|
|
|
296
299
|
error: event.error
|
|
297
300
|
});
|
|
298
301
|
const errorMessage = event.error instanceof Error ? event.error.message : String(event.error);
|
|
302
|
+
const metadata = this.toolCallMetadata?.get(event.toolCallId);
|
|
299
303
|
const errorResult = {
|
|
300
304
|
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
301
305
|
meta: {
|
|
@@ -308,14 +312,25 @@ class StreamProcessor {
|
|
|
308
312
|
event.toolCallId,
|
|
309
313
|
event.toolName,
|
|
310
314
|
errorResult,
|
|
311
|
-
|
|
312
|
-
// No approval metadata for errors
|
|
315
|
+
metadata
|
|
313
316
|
);
|
|
314
317
|
this.eventBus.emit("llm:tool-result", {
|
|
315
318
|
toolName: event.toolName,
|
|
319
|
+
...metadata?.presentationSnapshot !== void 0 && {
|
|
320
|
+
presentationSnapshot: metadata.presentationSnapshot
|
|
321
|
+
},
|
|
322
|
+
...metadata?.meta !== void 0 && {
|
|
323
|
+
meta: metadata.meta
|
|
324
|
+
},
|
|
316
325
|
callId: event.toolCallId,
|
|
317
326
|
success: false,
|
|
318
|
-
error: errorMessage
|
|
327
|
+
error: errorMessage,
|
|
328
|
+
...metadata?.requireApproval !== void 0 && {
|
|
329
|
+
requireApproval: metadata.requireApproval
|
|
330
|
+
},
|
|
331
|
+
...metadata?.approvalStatus !== void 0 && {
|
|
332
|
+
approvalStatus: metadata.approvalStatus
|
|
333
|
+
}
|
|
319
334
|
});
|
|
320
335
|
this.eventBus.emit("llm:error", {
|
|
321
336
|
error: event.error instanceof Error ? event.error : new Error(String(event.error)),
|
|
@@ -324,17 +339,15 @@ class StreamProcessor {
|
|
|
324
339
|
recoverable: true
|
|
325
340
|
// Tool errors are typically recoverable
|
|
326
341
|
});
|
|
342
|
+
this.toolCallMetadata?.delete(event.toolCallId);
|
|
327
343
|
this.pendingToolCalls.delete(event.toolCallId);
|
|
328
344
|
this.partialToolCalls.delete(event.toolCallId);
|
|
329
345
|
break;
|
|
330
346
|
}
|
|
331
347
|
case "error": {
|
|
332
348
|
const err = event.error instanceof Error ? event.error : new Error(String(event.error));
|
|
333
|
-
this.
|
|
334
|
-
|
|
335
|
-
error: err
|
|
336
|
-
});
|
|
337
|
-
break;
|
|
349
|
+
await this.persistFailedToolResults(err.message);
|
|
350
|
+
throw err;
|
|
338
351
|
}
|
|
339
352
|
case "abort": {
|
|
340
353
|
this.logger.debug("Stream aborted, emitting partial response");
|
|
@@ -389,11 +402,6 @@ class StreamProcessor {
|
|
|
389
402
|
};
|
|
390
403
|
}
|
|
391
404
|
this.logger.error("Stream processing failed", { error });
|
|
392
|
-
this.eventBus.emit("llm:error", {
|
|
393
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
394
|
-
context: "StreamProcessor",
|
|
395
|
-
recoverable: false
|
|
396
|
-
});
|
|
397
405
|
throw error;
|
|
398
406
|
}
|
|
399
407
|
return {
|
|
@@ -460,6 +468,9 @@ class StreamProcessor {
|
|
|
460
468
|
...config.estimatedCost !== void 0 && {
|
|
461
469
|
estimatedCost: config.estimatedCost
|
|
462
470
|
},
|
|
471
|
+
...config.costBreakdown && {
|
|
472
|
+
costBreakdown: config.costBreakdown
|
|
473
|
+
},
|
|
463
474
|
...config.pricingStatus && { pricingStatus: config.pricingStatus },
|
|
464
475
|
...this.config.estimatedInputTokens !== void 0 && {
|
|
465
476
|
estimatedInputTokens: this.config.estimatedInputTokens
|
|
@@ -526,13 +537,31 @@ class StreamProcessor {
|
|
|
526
537
|
* Called on abort/cancel to prevent "tool_use ids were found without tool_result" errors.
|
|
527
538
|
*/
|
|
528
539
|
async persistCancelledToolResults() {
|
|
540
|
+
await this.persistPendingToolResults({
|
|
541
|
+
logLabel: "cancelled",
|
|
542
|
+
resultText: "Cancelled by user",
|
|
543
|
+
errorMessage: "Cancelled by user"
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Persist synthetic failed results for pending tool calls before surfacing a fatal stream error.
|
|
548
|
+
*/
|
|
549
|
+
async persistFailedToolResults(errorMessage) {
|
|
550
|
+
await this.persistPendingToolResults({
|
|
551
|
+
logLabel: "failed",
|
|
552
|
+
resultText: `Error: ${errorMessage}`,
|
|
553
|
+
errorMessage
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
async persistPendingToolResults(options) {
|
|
529
557
|
if (this.pendingToolCalls.size === 0) return;
|
|
530
558
|
this.logger.debug(
|
|
531
|
-
`Persisting
|
|
559
|
+
`Persisting ${options.logLabel} results for ${this.pendingToolCalls.size} pending tool call(s)`
|
|
532
560
|
);
|
|
533
561
|
for (const [toolCallId, { toolName }] of this.pendingToolCalls) {
|
|
534
|
-
const
|
|
535
|
-
|
|
562
|
+
const metadata = this.toolCallMetadata?.get(toolCallId);
|
|
563
|
+
const syntheticResult = {
|
|
564
|
+
content: [{ type: "text", text: options.resultText }],
|
|
536
565
|
meta: {
|
|
537
566
|
toolName,
|
|
538
567
|
toolCallId,
|
|
@@ -542,16 +571,28 @@ class StreamProcessor {
|
|
|
542
571
|
await this.contextManager.addToolResult(
|
|
543
572
|
toolCallId,
|
|
544
573
|
toolName,
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
// No approval metadata for cancelled tools
|
|
574
|
+
syntheticResult,
|
|
575
|
+
metadata
|
|
548
576
|
);
|
|
549
577
|
this.eventBus.emit("llm:tool-result", {
|
|
550
578
|
toolName,
|
|
579
|
+
...metadata?.presentationSnapshot !== void 0 && {
|
|
580
|
+
presentationSnapshot: metadata.presentationSnapshot
|
|
581
|
+
},
|
|
582
|
+
...metadata?.meta !== void 0 && {
|
|
583
|
+
meta: metadata.meta
|
|
584
|
+
},
|
|
551
585
|
callId: toolCallId,
|
|
552
586
|
success: false,
|
|
553
|
-
error:
|
|
587
|
+
error: options.errorMessage,
|
|
588
|
+
...metadata?.requireApproval !== void 0 && {
|
|
589
|
+
requireApproval: metadata.requireApproval
|
|
590
|
+
},
|
|
591
|
+
...metadata?.approvalStatus !== void 0 && {
|
|
592
|
+
approvalStatus: metadata.approvalStatus
|
|
593
|
+
}
|
|
554
594
|
});
|
|
595
|
+
this.toolCallMetadata?.delete(toolCallId);
|
|
555
596
|
}
|
|
556
597
|
this.pendingToolCalls.clear();
|
|
557
598
|
}
|
|
@@ -539,6 +539,9 @@ class TurnExecutor {
|
|
|
539
539
|
if (executionResult.presentationSnapshot !== void 0) {
|
|
540
540
|
meta.presentationSnapshot = executionResult.presentationSnapshot;
|
|
541
541
|
}
|
|
542
|
+
if (executionResult.meta !== void 0) {
|
|
543
|
+
meta.meta = executionResult.meta;
|
|
544
|
+
}
|
|
542
545
|
if (executionResult.requireApproval !== void 0) {
|
|
543
546
|
meta.requireApproval = executionResult.requireApproval;
|
|
544
547
|
if (executionResult.approvalStatus !== void 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn-executor.d.ts","sourceRoot":"","sources":["../../../src/llm/executor/turn-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EAMb,KAAK,YAAY,EAEpB,MAAM,IAAI,CAAC;AAEZ,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAQ1D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"turn-executor.d.ts","sourceRoot":"","sources":["../../../src/llm/executor/turn-executor.ts"],"names":[],"mappings":"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"}
|
|
@@ -471,6 +471,9 @@ class TurnExecutor {
|
|
|
471
471
|
if (executionResult.presentationSnapshot !== void 0) {
|
|
472
472
|
meta.presentationSnapshot = executionResult.presentationSnapshot;
|
|
473
473
|
}
|
|
474
|
+
if (executionResult.meta !== void 0) {
|
|
475
|
+
meta.meta = executionResult.meta;
|
|
476
|
+
}
|
|
474
477
|
if (executionResult.requireApproval !== void 0) {
|
|
475
478
|
meta.requireApproval = executionResult.requireApproval;
|
|
476
479
|
if (executionResult.approvalStatus !== void 0) {
|
|
@@ -51,7 +51,7 @@ export declare const LocalModelInfoSchema: z.ZodObject<{
|
|
|
51
51
|
quantization: "Q2_K" | "Q3_K_S" | "Q3_K_M" | "Q3_K_L" | "Q4_0" | "Q4_K_S" | "Q4_K_M" | "Q5_0" | "Q5_K_S" | "Q5_K_M" | "Q6_K" | "Q8_0" | "F16" | "F32";
|
|
52
52
|
sizeBytes: number;
|
|
53
53
|
contextLength: number;
|
|
54
|
-
categories: ("
|
|
54
|
+
categories: ("reasoning" | "small" | "general" | "coding" | "vision")[];
|
|
55
55
|
license?: string | undefined;
|
|
56
56
|
supportsVision?: boolean | undefined;
|
|
57
57
|
supportsTools?: boolean | undefined;
|
|
@@ -68,7 +68,7 @@ export declare const LocalModelInfoSchema: z.ZodObject<{
|
|
|
68
68
|
quantization: "Q2_K" | "Q3_K_S" | "Q3_K_M" | "Q3_K_L" | "Q4_0" | "Q4_K_S" | "Q4_K_M" | "Q5_0" | "Q5_K_S" | "Q5_K_M" | "Q6_K" | "Q8_0" | "F16" | "F32";
|
|
69
69
|
sizeBytes: number;
|
|
70
70
|
contextLength: number;
|
|
71
|
-
categories: ("
|
|
71
|
+
categories: ("reasoning" | "small" | "general" | "coding" | "vision")[];
|
|
72
72
|
license?: string | undefined;
|
|
73
73
|
supportsVision?: boolean | undefined;
|
|
74
74
|
supportsTools?: boolean | undefined;
|
package/dist/llm/schemas.d.ts
CHANGED
|
@@ -24,30 +24,30 @@ export declare const LLMConfigBaseSchema: z.ZodObject<{
|
|
|
24
24
|
model: string;
|
|
25
25
|
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova";
|
|
26
26
|
apiKey?: string | undefined;
|
|
27
|
+
maxIterations?: number | undefined;
|
|
28
|
+
baseURL?: string | undefined;
|
|
27
29
|
maxInputTokens?: number | undefined;
|
|
30
|
+
maxOutputTokens?: number | undefined;
|
|
31
|
+
temperature?: number | undefined;
|
|
32
|
+
allowedMediaTypes?: string[] | undefined;
|
|
28
33
|
reasoning?: {
|
|
29
34
|
variant: string;
|
|
30
35
|
budgetTokens?: number | undefined;
|
|
31
36
|
} | undefined;
|
|
32
|
-
temperature?: number | undefined;
|
|
33
|
-
maxIterations?: number | undefined;
|
|
34
|
-
baseURL?: string | undefined;
|
|
35
|
-
maxOutputTokens?: number | undefined;
|
|
36
|
-
allowedMediaTypes?: string[] | undefined;
|
|
37
37
|
}, {
|
|
38
38
|
model: string;
|
|
39
39
|
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova";
|
|
40
40
|
apiKey?: string | undefined;
|
|
41
|
+
maxIterations?: number | undefined;
|
|
42
|
+
baseURL?: string | undefined;
|
|
41
43
|
maxInputTokens?: number | undefined;
|
|
44
|
+
maxOutputTokens?: number | undefined;
|
|
45
|
+
temperature?: number | undefined;
|
|
46
|
+
allowedMediaTypes?: string[] | undefined;
|
|
42
47
|
reasoning?: {
|
|
43
48
|
variant: string;
|
|
44
49
|
budgetTokens?: number | undefined;
|
|
45
50
|
} | undefined;
|
|
46
|
-
temperature?: number | undefined;
|
|
47
|
-
maxIterations?: number | undefined;
|
|
48
|
-
baseURL?: string | undefined;
|
|
49
|
-
maxOutputTokens?: number | undefined;
|
|
50
|
-
allowedMediaTypes?: string[] | undefined;
|
|
51
51
|
}>;
|
|
52
52
|
/**
|
|
53
53
|
* LLM config schema.
|
|
@@ -80,58 +80,58 @@ export declare const LLMConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
80
80
|
model: string;
|
|
81
81
|
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova";
|
|
82
82
|
apiKey?: string | undefined;
|
|
83
|
+
maxIterations?: number | undefined;
|
|
84
|
+
baseURL?: string | undefined;
|
|
83
85
|
maxInputTokens?: number | undefined;
|
|
86
|
+
maxOutputTokens?: number | undefined;
|
|
87
|
+
temperature?: number | undefined;
|
|
88
|
+
allowedMediaTypes?: string[] | undefined;
|
|
84
89
|
reasoning?: {
|
|
85
90
|
variant: string;
|
|
86
91
|
budgetTokens?: number | undefined;
|
|
87
92
|
} | undefined;
|
|
88
|
-
temperature?: number | undefined;
|
|
89
|
-
maxIterations?: number | undefined;
|
|
90
|
-
baseURL?: string | undefined;
|
|
91
|
-
maxOutputTokens?: number | undefined;
|
|
92
|
-
allowedMediaTypes?: string[] | undefined;
|
|
93
93
|
}, {
|
|
94
94
|
model: string;
|
|
95
95
|
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova";
|
|
96
96
|
apiKey?: string | undefined;
|
|
97
|
+
maxIterations?: number | undefined;
|
|
98
|
+
baseURL?: string | undefined;
|
|
97
99
|
maxInputTokens?: number | undefined;
|
|
100
|
+
maxOutputTokens?: number | undefined;
|
|
101
|
+
temperature?: number | undefined;
|
|
102
|
+
allowedMediaTypes?: string[] | undefined;
|
|
98
103
|
reasoning?: {
|
|
99
104
|
variant: string;
|
|
100
105
|
budgetTokens?: number | undefined;
|
|
101
106
|
} | undefined;
|
|
102
|
-
temperature?: number | undefined;
|
|
103
|
-
maxIterations?: number | undefined;
|
|
104
|
-
baseURL?: string | undefined;
|
|
105
|
-
maxOutputTokens?: number | undefined;
|
|
106
|
-
allowedMediaTypes?: string[] | undefined;
|
|
107
107
|
}>, {
|
|
108
108
|
model: string;
|
|
109
109
|
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova";
|
|
110
110
|
apiKey?: string | undefined;
|
|
111
|
+
maxIterations?: number | undefined;
|
|
112
|
+
baseURL?: string | undefined;
|
|
111
113
|
maxInputTokens?: number | undefined;
|
|
114
|
+
maxOutputTokens?: number | undefined;
|
|
115
|
+
temperature?: number | undefined;
|
|
116
|
+
allowedMediaTypes?: string[] | undefined;
|
|
112
117
|
reasoning?: {
|
|
113
118
|
variant: string;
|
|
114
119
|
budgetTokens?: number | undefined;
|
|
115
120
|
} | undefined;
|
|
116
|
-
temperature?: number | undefined;
|
|
117
|
-
maxIterations?: number | undefined;
|
|
118
|
-
baseURL?: string | undefined;
|
|
119
|
-
maxOutputTokens?: number | undefined;
|
|
120
|
-
allowedMediaTypes?: string[] | undefined;
|
|
121
121
|
}, {
|
|
122
122
|
model: string;
|
|
123
123
|
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova";
|
|
124
124
|
apiKey?: string | undefined;
|
|
125
|
+
maxIterations?: number | undefined;
|
|
126
|
+
baseURL?: string | undefined;
|
|
125
127
|
maxInputTokens?: number | undefined;
|
|
128
|
+
maxOutputTokens?: number | undefined;
|
|
129
|
+
temperature?: number | undefined;
|
|
130
|
+
allowedMediaTypes?: string[] | undefined;
|
|
126
131
|
reasoning?: {
|
|
127
132
|
variant: string;
|
|
128
133
|
budgetTokens?: number | undefined;
|
|
129
134
|
} | undefined;
|
|
130
|
-
temperature?: number | undefined;
|
|
131
|
-
maxIterations?: number | undefined;
|
|
132
|
-
baseURL?: string | undefined;
|
|
133
|
-
maxOutputTokens?: number | undefined;
|
|
134
|
-
allowedMediaTypes?: string[] | undefined;
|
|
135
135
|
}>;
|
|
136
136
|
export type LLMConfig = z.input<typeof LLMConfigSchema>;
|
|
137
137
|
export type ValidatedLLMConfig = z.output<typeof LLMConfigSchema>;
|
|
@@ -159,58 +159,58 @@ export declare const LLMUpdatesSchema: z.ZodEffects<z.ZodObject<{
|
|
|
159
159
|
apiKey?: string | undefined;
|
|
160
160
|
model?: string | undefined;
|
|
161
161
|
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova" | undefined;
|
|
162
|
+
maxIterations?: number | undefined;
|
|
163
|
+
baseURL?: string | undefined;
|
|
162
164
|
maxInputTokens?: number | undefined;
|
|
165
|
+
maxOutputTokens?: number | undefined;
|
|
166
|
+
temperature?: number | undefined;
|
|
167
|
+
allowedMediaTypes?: string[] | undefined;
|
|
163
168
|
reasoning?: {
|
|
164
169
|
variant: string;
|
|
165
170
|
budgetTokens?: number | undefined;
|
|
166
171
|
} | null | undefined;
|
|
167
|
-
temperature?: number | undefined;
|
|
168
|
-
maxIterations?: number | undefined;
|
|
169
|
-
baseURL?: string | undefined;
|
|
170
|
-
maxOutputTokens?: number | undefined;
|
|
171
|
-
allowedMediaTypes?: string[] | undefined;
|
|
172
172
|
}, {
|
|
173
173
|
apiKey?: string | undefined;
|
|
174
174
|
model?: string | undefined;
|
|
175
175
|
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova" | undefined;
|
|
176
|
+
maxIterations?: number | undefined;
|
|
177
|
+
baseURL?: string | undefined;
|
|
176
178
|
maxInputTokens?: number | undefined;
|
|
179
|
+
maxOutputTokens?: number | undefined;
|
|
180
|
+
temperature?: number | undefined;
|
|
181
|
+
allowedMediaTypes?: string[] | undefined;
|
|
177
182
|
reasoning?: {
|
|
178
183
|
variant: string;
|
|
179
184
|
budgetTokens?: number | undefined;
|
|
180
185
|
} | null | undefined;
|
|
181
|
-
temperature?: number | undefined;
|
|
182
|
-
maxIterations?: number | undefined;
|
|
183
|
-
baseURL?: string | undefined;
|
|
184
|
-
maxOutputTokens?: number | undefined;
|
|
185
|
-
allowedMediaTypes?: string[] | undefined;
|
|
186
186
|
}>, {
|
|
187
187
|
apiKey?: string | undefined;
|
|
188
188
|
model?: string | undefined;
|
|
189
189
|
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova" | undefined;
|
|
190
|
+
maxIterations?: number | undefined;
|
|
191
|
+
baseURL?: string | undefined;
|
|
190
192
|
maxInputTokens?: number | undefined;
|
|
193
|
+
maxOutputTokens?: number | undefined;
|
|
194
|
+
temperature?: number | undefined;
|
|
195
|
+
allowedMediaTypes?: string[] | undefined;
|
|
191
196
|
reasoning?: {
|
|
192
197
|
variant: string;
|
|
193
198
|
budgetTokens?: number | undefined;
|
|
194
199
|
} | null | undefined;
|
|
195
|
-
temperature?: number | undefined;
|
|
196
|
-
maxIterations?: number | undefined;
|
|
197
|
-
baseURL?: string | undefined;
|
|
198
|
-
maxOutputTokens?: number | undefined;
|
|
199
|
-
allowedMediaTypes?: string[] | undefined;
|
|
200
200
|
}, {
|
|
201
201
|
apiKey?: string | undefined;
|
|
202
202
|
model?: string | undefined;
|
|
203
203
|
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova" | undefined;
|
|
204
|
+
maxIterations?: number | undefined;
|
|
205
|
+
baseURL?: string | undefined;
|
|
204
206
|
maxInputTokens?: number | undefined;
|
|
207
|
+
maxOutputTokens?: number | undefined;
|
|
208
|
+
temperature?: number | undefined;
|
|
209
|
+
allowedMediaTypes?: string[] | undefined;
|
|
205
210
|
reasoning?: {
|
|
206
211
|
variant: string;
|
|
207
212
|
budgetTokens?: number | undefined;
|
|
208
213
|
} | null | undefined;
|
|
209
|
-
temperature?: number | undefined;
|
|
210
|
-
maxIterations?: number | undefined;
|
|
211
|
-
baseURL?: string | undefined;
|
|
212
|
-
maxOutputTokens?: number | undefined;
|
|
213
|
-
allowedMediaTypes?: string[] | undefined;
|
|
214
214
|
}>;
|
|
215
215
|
export type LLMUpdates = z.input<typeof LLMUpdatesSchema>;
|
|
216
216
|
export type { LLMUpdateContext } from '../llm/types.js';
|
|
@@ -48,6 +48,24 @@ function isLanguageModel(value) {
|
|
|
48
48
|
const candidate = value;
|
|
49
49
|
return typeof candidate["modelId"] === "string" && (typeof candidate["doGenerate"] === "function" || typeof candidate["doStream"] === "function");
|
|
50
50
|
}
|
|
51
|
+
const DEFAULT_DEXTO_GATEWAY_BASE_URL = "https://api.dexto.ai/v1";
|
|
52
|
+
function trimTrailingSlash(value) {
|
|
53
|
+
return value.trim().replace(/\/$/, "");
|
|
54
|
+
}
|
|
55
|
+
function resolveDextoGatewayBaseURL(baseURL) {
|
|
56
|
+
if (baseURL?.trim()) {
|
|
57
|
+
return trimTrailingSlash(baseURL);
|
|
58
|
+
}
|
|
59
|
+
const envBaseURL = process.env.DEXTO_API_URL?.trim();
|
|
60
|
+
if (!envBaseURL) {
|
|
61
|
+
return DEFAULT_DEXTO_GATEWAY_BASE_URL;
|
|
62
|
+
}
|
|
63
|
+
const normalizedEnvBaseURL = trimTrailingSlash(envBaseURL);
|
|
64
|
+
if (normalizedEnvBaseURL.endsWith("/v1")) {
|
|
65
|
+
return normalizedEnvBaseURL;
|
|
66
|
+
}
|
|
67
|
+
return `${normalizedEnvBaseURL}/v1`;
|
|
68
|
+
}
|
|
51
69
|
const DEXTO_GATEWAY_HEADERS = {
|
|
52
70
|
SESSION_ID: "X-Dexto-Session-ID",
|
|
53
71
|
CLIENT_SOURCE: "X-Dexto-Source",
|
|
@@ -126,7 +144,7 @@ function createVercelModel(llmConfig, context) {
|
|
|
126
144
|
return (0, import_openai.createOpenAI)({ apiKey: apiKey ?? "", baseURL: glamaBaseURL }).chat(model);
|
|
127
145
|
}
|
|
128
146
|
case "dexto-nova": {
|
|
129
|
-
const dextoBaseURL =
|
|
147
|
+
const dextoBaseURL = resolveDextoGatewayBaseURL(baseURL);
|
|
130
148
|
const headers = {
|
|
131
149
|
[DEXTO_GATEWAY_HEADERS.CLIENT_SOURCE]: context?.clientSource ?? "cli"
|
|
132
150
|
};
|