@dexto/core 1.2.6 → 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/README.md +47 -13
- package/dist/agent/DextoAgent.cjs +92 -34
- package/dist/agent/DextoAgent.d.ts +3 -3
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +93 -36
- package/dist/agent/schemas.cjs +1 -1
- package/dist/agent/schemas.js +1 -1
- package/dist/agent/types.d.ts +0 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/approval/schemas.cjs +2 -1
- package/dist/approval/schemas.d.ts +21 -20
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +2 -1
- package/dist/context/manager.cjs +7 -0
- package/dist/context/manager.d.ts.map +1 -1
- package/dist/context/manager.js +7 -0
- package/dist/context/types.d.ts +6 -2
- package/dist/context/types.d.ts.map +1 -1
- package/dist/errors/types.cjs +1 -0
- package/dist/errors/types.d.ts +4 -2
- package/dist/errors/types.d.ts.map +1 -1
- package/dist/errors/types.js +1 -0
- package/dist/events/index.cjs +4 -1
- package/dist/events/index.d.ts +23 -52
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +4 -1
- package/dist/llm/formatters/openai.cjs +8 -1
- package/dist/llm/formatters/openai.d.ts.map +1 -1
- package/dist/llm/formatters/openai.js +8 -1
- package/dist/llm/tokenizer/openai.d.ts +8 -0
- package/dist/llm/tokenizer/openai.d.ts.map +1 -1
- package/dist/logger/v2/schemas.cjs +1 -1
- package/dist/logger/v2/schemas.js +1 -1
- package/dist/plugins/error-codes.cjs +1 -0
- package/dist/plugins/error-codes.d.ts +3 -1
- package/dist/plugins/error-codes.d.ts.map +1 -1
- package/dist/plugins/error-codes.js +1 -0
- package/dist/plugins/loader.cjs +25 -5
- package/dist/plugins/loader.d.ts.map +1 -1
- package/dist/plugins/loader.js +25 -5
- package/dist/prompts/providers/custom-prompt-provider.cjs +2 -2
- package/dist/prompts/providers/custom-prompt-provider.d.ts +1 -1
- package/dist/prompts/providers/custom-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/providers/custom-prompt-provider.js +2 -2
- package/dist/storage/cache/factory.cjs +6 -2
- package/dist/storage/cache/factory.d.ts +2 -1
- package/dist/storage/cache/factory.d.ts.map +1 -1
- package/dist/storage/cache/factory.js +6 -2
- package/dist/storage/database/factory.cjs +11 -17
- package/dist/storage/database/factory.d.ts +2 -1
- package/dist/storage/database/factory.d.ts.map +1 -1
- package/dist/storage/database/factory.js +11 -17
- package/dist/storage/database/sqlite-store.cjs +8 -0
- package/dist/storage/database/sqlite-store.d.ts.map +1 -1
- package/dist/storage/database/sqlite-store.js +8 -0
- package/dist/storage/error-codes.cjs +1 -0
- package/dist/storage/error-codes.d.ts +1 -0
- package/dist/storage/error-codes.d.ts.map +1 -1
- package/dist/storage/error-codes.js +1 -0
- package/dist/storage/errors.cjs +17 -0
- package/dist/storage/errors.d.ts +9 -0
- package/dist/storage/errors.d.ts.map +1 -1
- package/dist/storage/errors.js +17 -0
- package/dist/telemetry/error-codes.cjs +36 -0
- package/dist/telemetry/error-codes.d.ts +13 -0
- package/dist/telemetry/error-codes.d.ts.map +1 -0
- package/dist/telemetry/error-codes.js +13 -0
- package/dist/telemetry/errors.cjs +105 -0
- package/dist/telemetry/errors.d.ts +28 -0
- package/dist/telemetry/errors.d.ts.map +1 -0
- package/dist/telemetry/errors.js +82 -0
- package/dist/telemetry/telemetry.cjs +92 -26
- package/dist/telemetry/telemetry.d.ts +1 -1
- package/dist/telemetry/telemetry.d.ts.map +1 -1
- package/dist/telemetry/telemetry.js +74 -18
- package/dist/tools/schemas.cjs +1 -1
- package/dist/tools/schemas.js +1 -1
- package/dist/tools/types.d.ts +0 -11
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/schema.d.ts +6 -0
- package/dist/utils/schema.d.ts.map +1 -1
- package/package.json +52 -14
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @dexto/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Dexto Agent SDK for building agentic applications programmatically. This package powers the Dexto CLI and lets you embed the same agent runtime in your own apps.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,6 +8,32 @@ TypeScript SDK for building agentic applications programmatically. This package
|
|
|
8
8
|
npm install @dexto/core
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
### Optional Dependencies
|
|
12
|
+
|
|
13
|
+
Some features require additional packages. Install only what you need:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Telemetry (OpenTelemetry distributed tracing)
|
|
17
|
+
npm install @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node \
|
|
18
|
+
@opentelemetry/resources @opentelemetry/semantic-conventions \
|
|
19
|
+
@opentelemetry/sdk-trace-base @opentelemetry/exporter-trace-otlp-http
|
|
20
|
+
|
|
21
|
+
# For gRPC telemetry export protocol
|
|
22
|
+
npm install @opentelemetry/exporter-trace-otlp-grpc
|
|
23
|
+
|
|
24
|
+
# Storage backends
|
|
25
|
+
npm install better-sqlite3 # SQLite database
|
|
26
|
+
npm install pg # PostgreSQL database
|
|
27
|
+
npm install ioredis # Redis cache
|
|
28
|
+
|
|
29
|
+
# TypeScript plugin support
|
|
30
|
+
npm install tsx
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If you configure a feature without its dependencies, you'll get a helpful error message with the exact install command.
|
|
34
|
+
|
|
35
|
+
> **Note:** The `dexto` CLI package includes all optional dependencies. These are only needed when using `@dexto/core` directly as a library.
|
|
36
|
+
|
|
11
37
|
## Quick Start
|
|
12
38
|
|
|
13
39
|
```ts
|
|
@@ -23,19 +49,24 @@ const agent = new DextoAgent({
|
|
|
23
49
|
});
|
|
24
50
|
await agent.start();
|
|
25
51
|
|
|
26
|
-
//
|
|
27
|
-
const
|
|
28
|
-
console.log(response);
|
|
52
|
+
// Create a session for the conversation
|
|
53
|
+
const session = await agent.createSession();
|
|
29
54
|
|
|
30
|
-
//
|
|
31
|
-
await agent.
|
|
32
|
-
|
|
55
|
+
// Use generate() for simple request/response
|
|
56
|
+
const response = await agent.generate('What is TypeScript?', {
|
|
57
|
+
sessionId: session.id
|
|
58
|
+
});
|
|
59
|
+
console.log(response.content);
|
|
60
|
+
|
|
61
|
+
// Conversations maintain context within a session
|
|
62
|
+
await agent.generate('Write a haiku about it', { sessionId: session.id });
|
|
63
|
+
await agent.generate('Make it funnier', { sessionId: session.id });
|
|
33
64
|
|
|
34
65
|
await agent.stop();
|
|
35
66
|
```
|
|
36
67
|
|
|
37
|
-
See the
|
|
38
|
-
https://docs.dexto.ai/api/category/
|
|
68
|
+
See the Dexto Agent SDK docs for full examples with MCP tools, sessions, and advanced features:
|
|
69
|
+
https://docs.dexto.ai/api/category/dexto-sdk/
|
|
39
70
|
|
|
40
71
|
---
|
|
41
72
|
|
|
@@ -49,7 +80,7 @@ await agent.start();
|
|
|
49
80
|
|
|
50
81
|
// Create and manage sessions
|
|
51
82
|
const session = await agent.createSession('user-123');
|
|
52
|
-
await agent.
|
|
83
|
+
await agent.generate('Hello, how can you help me?', { sessionId: session.id });
|
|
53
84
|
|
|
54
85
|
// List and manage sessions
|
|
55
86
|
const sessions = await agent.listSessions();
|
|
@@ -115,15 +146,18 @@ Delegate tasks to other A2A-compliant agents using the built-in `delegate_to_url
|
|
|
115
146
|
```typescript
|
|
116
147
|
const agent = new DextoAgent({
|
|
117
148
|
llm: { /* ... */ },
|
|
118
|
-
internalTools: ['delegate_to_url'] // Enable delegation tool
|
|
149
|
+
internalTools: ['delegate_to_url'], // Enable delegation tool
|
|
150
|
+
toolConfirmation: { mode: 'auto-approve' }
|
|
119
151
|
});
|
|
120
152
|
await agent.start();
|
|
121
153
|
|
|
154
|
+
const session = await agent.createSession();
|
|
155
|
+
|
|
122
156
|
// Delegate via natural language
|
|
123
|
-
await agent.
|
|
157
|
+
await agent.generate(`
|
|
124
158
|
Please delegate this task to the PDF analyzer agent at http://localhost:3001:
|
|
125
159
|
"Extract all tables from the Q4 sales report"
|
|
126
|
-
|
|
160
|
+
`, { sessionId: session.id });
|
|
127
161
|
|
|
128
162
|
// Or call the tool directly
|
|
129
163
|
const tools = await agent.getAllTools();
|
|
@@ -519,7 +519,7 @@ Either:
|
|
|
519
519
|
events.push(event);
|
|
520
520
|
}
|
|
521
521
|
const errorEvent = events.find(
|
|
522
|
-
(e) => e.
|
|
522
|
+
(e) => e.name === "llm:error"
|
|
523
523
|
);
|
|
524
524
|
if (errorEvent) {
|
|
525
525
|
if (errorEvent.error instanceof import_DextoRuntimeError.DextoRuntimeError) {
|
|
@@ -532,8 +532,8 @@ Either:
|
|
|
532
532
|
llmConfig.model
|
|
533
533
|
);
|
|
534
534
|
}
|
|
535
|
-
const responseEvent = events.find((e) => e.
|
|
536
|
-
if (!responseEvent || responseEvent.
|
|
535
|
+
const responseEvent = events.find((e) => e.name === "llm:response");
|
|
536
|
+
if (!responseEvent || responseEvent.name !== "llm:response") {
|
|
537
537
|
const llmConfig = this.stateManager.getLLMConfig(options.sessionId);
|
|
538
538
|
throw import_errors.LLMError.generationFailed(
|
|
539
539
|
"Stream did not complete successfully - no response received",
|
|
@@ -542,10 +542,10 @@ Either:
|
|
|
542
542
|
);
|
|
543
543
|
}
|
|
544
544
|
const toolCallEvents = events.filter(
|
|
545
|
-
(e) => e.
|
|
545
|
+
(e) => e.name === "llm:tool-call"
|
|
546
546
|
);
|
|
547
547
|
const toolResultEvents = events.filter(
|
|
548
|
-
(e) => e.
|
|
548
|
+
(e) => e.name === "llm:tool-result"
|
|
549
549
|
);
|
|
550
550
|
const toolCalls = toolCallEvents.map((tc) => {
|
|
551
551
|
const toolResult = toolResultEvents.find((tr) => tr.callId === tc.callId);
|
|
@@ -559,7 +559,6 @@ Either:
|
|
|
559
559
|
} : void 0
|
|
560
560
|
};
|
|
561
561
|
});
|
|
562
|
-
const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
563
562
|
const defaultUsage = {
|
|
564
563
|
inputTokens: 0,
|
|
565
564
|
outputTokens: 0,
|
|
@@ -571,8 +570,7 @@ Either:
|
|
|
571
570
|
reasoning: responseEvent.reasoning,
|
|
572
571
|
usage,
|
|
573
572
|
toolCalls,
|
|
574
|
-
sessionId: options.sessionId
|
|
575
|
-
messageId
|
|
573
|
+
sessionId: options.sessionId
|
|
576
574
|
};
|
|
577
575
|
}
|
|
578
576
|
/**
|
|
@@ -588,15 +586,15 @@ Either:
|
|
|
588
586
|
*
|
|
589
587
|
* @param message The user's message
|
|
590
588
|
* @param options Configuration options (sessionId is required, imageData, fileData, signal are optional)
|
|
591
|
-
* @returns AsyncIterator that yields StreamingEvent objects (core events with
|
|
589
|
+
* @returns AsyncIterator that yields StreamingEvent objects (core events with name property)
|
|
592
590
|
*
|
|
593
591
|
* @example
|
|
594
592
|
* ```typescript
|
|
595
593
|
* for await (const event of await agent.stream("Write a poem", { sessionId: "default" })) {
|
|
596
|
-
* if (event.
|
|
594
|
+
* if (event.name === 'llm:chunk') {
|
|
597
595
|
* process.stdout.write(event.content);
|
|
598
596
|
* }
|
|
599
|
-
* if (event.
|
|
597
|
+
* if (event.name === 'llm:tool-call') {
|
|
600
598
|
* console.log(`\n[Using ${event.toolName}]\n`);
|
|
601
599
|
* }
|
|
602
600
|
* }
|
|
@@ -622,7 +620,10 @@ Either:
|
|
|
622
620
|
return;
|
|
623
621
|
}
|
|
624
622
|
for (const { event, listener } of listeners) {
|
|
625
|
-
this.agentEventBus.off(
|
|
623
|
+
this.agentEventBus.off(
|
|
624
|
+
event,
|
|
625
|
+
listener
|
|
626
|
+
);
|
|
626
627
|
}
|
|
627
628
|
listeners.length = 0;
|
|
628
629
|
};
|
|
@@ -633,21 +634,78 @@ Either:
|
|
|
633
634
|
};
|
|
634
635
|
signal.addEventListener("abort", abortHandler, { once: true });
|
|
635
636
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
637
|
+
const thinkingListener = (data) => {
|
|
638
|
+
if (data.sessionId !== sessionId) return;
|
|
639
|
+
eventQueue.push({ name: "llm:thinking", ...data });
|
|
640
|
+
};
|
|
641
|
+
this.agentEventBus.on("llm:thinking", thinkingListener, { signal: cleanupSignal });
|
|
642
|
+
listeners.push({ event: "llm:thinking", listener: thinkingListener });
|
|
643
|
+
const chunkListener = (data) => {
|
|
644
|
+
if (data.sessionId !== sessionId) return;
|
|
645
|
+
eventQueue.push({ name: "llm:chunk", ...data });
|
|
646
|
+
};
|
|
647
|
+
this.agentEventBus.on("llm:chunk", chunkListener, { signal: cleanupSignal });
|
|
648
|
+
listeners.push({ event: "llm:chunk", listener: chunkListener });
|
|
649
|
+
const responseListener = (data) => {
|
|
650
|
+
if (data.sessionId !== sessionId) return;
|
|
651
|
+
eventQueue.push({ name: "llm:response", ...data });
|
|
652
|
+
completed = true;
|
|
653
|
+
};
|
|
654
|
+
this.agentEventBus.on("llm:response", responseListener, { signal: cleanupSignal });
|
|
655
|
+
listeners.push({ event: "llm:response", listener: responseListener });
|
|
656
|
+
const toolCallListener = (data) => {
|
|
657
|
+
if (data.sessionId !== sessionId) return;
|
|
658
|
+
eventQueue.push({ name: "llm:tool-call", ...data });
|
|
659
|
+
};
|
|
660
|
+
this.agentEventBus.on("llm:tool-call", toolCallListener, { signal: cleanupSignal });
|
|
661
|
+
listeners.push({ event: "llm:tool-call", listener: toolCallListener });
|
|
662
|
+
const toolResultListener = (data) => {
|
|
663
|
+
if (data.sessionId !== sessionId) return;
|
|
664
|
+
eventQueue.push({ name: "llm:tool-result", ...data });
|
|
665
|
+
};
|
|
666
|
+
this.agentEventBus.on("llm:tool-result", toolResultListener, { signal: cleanupSignal });
|
|
667
|
+
listeners.push({ event: "llm:tool-result", listener: toolResultListener });
|
|
668
|
+
const errorListener = (data) => {
|
|
669
|
+
if (data.sessionId !== sessionId) return;
|
|
670
|
+
eventQueue.push({ name: "llm:error", ...data });
|
|
671
|
+
if (!data.recoverable) {
|
|
672
|
+
completed = true;
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
this.agentEventBus.on("llm:error", errorListener, { signal: cleanupSignal });
|
|
676
|
+
listeners.push({ event: "llm:error", listener: errorListener });
|
|
677
|
+
const unsupportedInputListener = (data) => {
|
|
678
|
+
if (data.sessionId !== sessionId) return;
|
|
679
|
+
eventQueue.push({ name: "llm:unsupported-input", ...data });
|
|
680
|
+
};
|
|
681
|
+
this.agentEventBus.on("llm:unsupported-input", unsupportedInputListener, {
|
|
682
|
+
signal: cleanupSignal
|
|
683
|
+
});
|
|
684
|
+
listeners.push({ event: "llm:unsupported-input", listener: unsupportedInputListener });
|
|
685
|
+
const titleUpdatedListener = (data) => {
|
|
686
|
+
if (data.sessionId !== sessionId) return;
|
|
687
|
+
eventQueue.push({ name: "session:title-updated", ...data });
|
|
688
|
+
};
|
|
689
|
+
this.agentEventBus.on("session:title-updated", titleUpdatedListener, {
|
|
690
|
+
signal: cleanupSignal
|
|
691
|
+
});
|
|
692
|
+
listeners.push({ event: "session:title-updated", listener: titleUpdatedListener });
|
|
693
|
+
const approvalRequestListener = (data) => {
|
|
694
|
+
if (data.sessionId !== sessionId) return;
|
|
695
|
+
eventQueue.push({ name: "approval:request", ...data });
|
|
696
|
+
};
|
|
697
|
+
this.agentEventBus.on("approval:request", approvalRequestListener, {
|
|
698
|
+
signal: cleanupSignal
|
|
699
|
+
});
|
|
700
|
+
listeners.push({ event: "approval:request", listener: approvalRequestListener });
|
|
701
|
+
const approvalResponseListener = (data) => {
|
|
702
|
+
if (data.sessionId !== sessionId) return;
|
|
703
|
+
eventQueue.push({ name: "approval:response", ...data });
|
|
704
|
+
};
|
|
705
|
+
this.agentEventBus.on("approval:response", approvalResponseListener, {
|
|
706
|
+
signal: cleanupSignal
|
|
707
|
+
});
|
|
708
|
+
listeners.push({ event: "approval:response", listener: approvalResponseListener });
|
|
651
709
|
const imageDataForRun = imageData ? {
|
|
652
710
|
image: typeof imageData.image === "string" ? imageData.image : imageData.image.toString(),
|
|
653
711
|
mimeType: imageData.mimeType || "image/png"
|
|
@@ -657,19 +715,19 @@ Either:
|
|
|
657
715
|
mimeType: fileData.mimeType,
|
|
658
716
|
...fileData.filename && { filename: fileData.filename }
|
|
659
717
|
} : void 0;
|
|
660
|
-
this.run(message, imageDataForRun, fileDataForRun, sessionId, true).catch((
|
|
718
|
+
this.run(message, imageDataForRun, fileDataForRun, sessionId, true).catch((err) => {
|
|
719
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
661
720
|
_streamError = error;
|
|
662
721
|
completed = true;
|
|
663
|
-
this.logger.error(
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
eventQueue.push({
|
|
667
|
-
type: "llm:error",
|
|
722
|
+
this.logger.error(`Error in DextoAgent.stream: ${error.message}`);
|
|
723
|
+
const errorEvent = {
|
|
724
|
+
name: "llm:error",
|
|
668
725
|
error,
|
|
669
726
|
recoverable: false,
|
|
670
727
|
context: "run_failed",
|
|
671
728
|
sessionId
|
|
672
|
-
}
|
|
729
|
+
};
|
|
730
|
+
eventQueue.push(errorEvent);
|
|
673
731
|
});
|
|
674
732
|
const iterator = {
|
|
675
733
|
async next() {
|
|
@@ -203,15 +203,15 @@ export declare class DextoAgent {
|
|
|
203
203
|
*
|
|
204
204
|
* @param message The user's message
|
|
205
205
|
* @param options Configuration options (sessionId is required, imageData, fileData, signal are optional)
|
|
206
|
-
* @returns AsyncIterator that yields StreamingEvent objects (core events with
|
|
206
|
+
* @returns AsyncIterator that yields StreamingEvent objects (core events with name property)
|
|
207
207
|
*
|
|
208
208
|
* @example
|
|
209
209
|
* ```typescript
|
|
210
210
|
* for await (const event of await agent.stream("Write a poem", { sessionId: "default" })) {
|
|
211
|
-
* if (event.
|
|
211
|
+
* if (event.name === 'llm:chunk') {
|
|
212
212
|
* process.stdout.write(event.content);
|
|
213
213
|
* }
|
|
214
|
-
* if (event.
|
|
214
|
+
* if (event.name === 'llm:tool-call') {
|
|
215
215
|
* console.log(`\n[Using ${event.toolName}]\n`);
|
|
216
216
|
* }
|
|
217
217
|
* }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DextoAgent.d.ts","sourceRoot":"","sources":["../../src/agent/DextoAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,eAAe,EAA2B,MAAM,uBAAuB,CAAC;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAgB,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAK1D,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAoB,MAAM,sBAAsB,CAAC;AAUxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAKH,SAAS,EACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EACH,aAAa,EAEb,KAAK,cAAc,EAEtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,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,SAAS,EAAE,oBAAoB,EAC/B,SAAS,EAAE,oBAAoB,GAChC,MAAM,EAAE;IAkDX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACI,kBAAkB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAYzD;;;;OAIG;IACI,oBAAoB,IAAI,IAAI;CAgCtC"}
|
package/dist/agent/DextoAgent.js
CHANGED
|
@@ -31,8 +31,7 @@ import {
|
|
|
31
31
|
import { createAgentServices } from "../utils/service-initializer.js";
|
|
32
32
|
import { AgentConfigSchema } from "./schemas.js";
|
|
33
33
|
import {
|
|
34
|
-
AgentEventBus
|
|
35
|
-
STREAMING_EVENTS
|
|
34
|
+
AgentEventBus
|
|
36
35
|
} from "../events/index.js";
|
|
37
36
|
import { safeStringify } from "../utils/safe-stringify.js";
|
|
38
37
|
import { deriveHeuristicTitle, generateSessionTitle } from "../session/title-generator.js";
|
|
@@ -464,7 +463,7 @@ Either:
|
|
|
464
463
|
events.push(event);
|
|
465
464
|
}
|
|
466
465
|
const errorEvent = events.find(
|
|
467
|
-
(e) => e.
|
|
466
|
+
(e) => e.name === "llm:error"
|
|
468
467
|
);
|
|
469
468
|
if (errorEvent) {
|
|
470
469
|
if (errorEvent.error instanceof DextoRuntimeError) {
|
|
@@ -477,8 +476,8 @@ Either:
|
|
|
477
476
|
llmConfig.model
|
|
478
477
|
);
|
|
479
478
|
}
|
|
480
|
-
const responseEvent = events.find((e) => e.
|
|
481
|
-
if (!responseEvent || responseEvent.
|
|
479
|
+
const responseEvent = events.find((e) => e.name === "llm:response");
|
|
480
|
+
if (!responseEvent || responseEvent.name !== "llm:response") {
|
|
482
481
|
const llmConfig = this.stateManager.getLLMConfig(options.sessionId);
|
|
483
482
|
throw LLMError.generationFailed(
|
|
484
483
|
"Stream did not complete successfully - no response received",
|
|
@@ -487,10 +486,10 @@ Either:
|
|
|
487
486
|
);
|
|
488
487
|
}
|
|
489
488
|
const toolCallEvents = events.filter(
|
|
490
|
-
(e) => e.
|
|
489
|
+
(e) => e.name === "llm:tool-call"
|
|
491
490
|
);
|
|
492
491
|
const toolResultEvents = events.filter(
|
|
493
|
-
(e) => e.
|
|
492
|
+
(e) => e.name === "llm:tool-result"
|
|
494
493
|
);
|
|
495
494
|
const toolCalls = toolCallEvents.map((tc) => {
|
|
496
495
|
const toolResult = toolResultEvents.find((tr) => tr.callId === tc.callId);
|
|
@@ -504,7 +503,6 @@ Either:
|
|
|
504
503
|
} : void 0
|
|
505
504
|
};
|
|
506
505
|
});
|
|
507
|
-
const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
508
506
|
const defaultUsage = {
|
|
509
507
|
inputTokens: 0,
|
|
510
508
|
outputTokens: 0,
|
|
@@ -516,8 +514,7 @@ Either:
|
|
|
516
514
|
reasoning: responseEvent.reasoning,
|
|
517
515
|
usage,
|
|
518
516
|
toolCalls,
|
|
519
|
-
sessionId: options.sessionId
|
|
520
|
-
messageId
|
|
517
|
+
sessionId: options.sessionId
|
|
521
518
|
};
|
|
522
519
|
}
|
|
523
520
|
/**
|
|
@@ -533,15 +530,15 @@ Either:
|
|
|
533
530
|
*
|
|
534
531
|
* @param message The user's message
|
|
535
532
|
* @param options Configuration options (sessionId is required, imageData, fileData, signal are optional)
|
|
536
|
-
* @returns AsyncIterator that yields StreamingEvent objects (core events with
|
|
533
|
+
* @returns AsyncIterator that yields StreamingEvent objects (core events with name property)
|
|
537
534
|
*
|
|
538
535
|
* @example
|
|
539
536
|
* ```typescript
|
|
540
537
|
* for await (const event of await agent.stream("Write a poem", { sessionId: "default" })) {
|
|
541
|
-
* if (event.
|
|
538
|
+
* if (event.name === 'llm:chunk') {
|
|
542
539
|
* process.stdout.write(event.content);
|
|
543
540
|
* }
|
|
544
|
-
* if (event.
|
|
541
|
+
* if (event.name === 'llm:tool-call') {
|
|
545
542
|
* console.log(`\n[Using ${event.toolName}]\n`);
|
|
546
543
|
* }
|
|
547
544
|
* }
|
|
@@ -567,7 +564,10 @@ Either:
|
|
|
567
564
|
return;
|
|
568
565
|
}
|
|
569
566
|
for (const { event, listener } of listeners) {
|
|
570
|
-
this.agentEventBus.off(
|
|
567
|
+
this.agentEventBus.off(
|
|
568
|
+
event,
|
|
569
|
+
listener
|
|
570
|
+
);
|
|
571
571
|
}
|
|
572
572
|
listeners.length = 0;
|
|
573
573
|
};
|
|
@@ -578,21 +578,78 @@ Either:
|
|
|
578
578
|
};
|
|
579
579
|
signal.addEventListener("abort", abortHandler, { once: true });
|
|
580
580
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
581
|
+
const thinkingListener = (data) => {
|
|
582
|
+
if (data.sessionId !== sessionId) return;
|
|
583
|
+
eventQueue.push({ name: "llm:thinking", ...data });
|
|
584
|
+
};
|
|
585
|
+
this.agentEventBus.on("llm:thinking", thinkingListener, { signal: cleanupSignal });
|
|
586
|
+
listeners.push({ event: "llm:thinking", listener: thinkingListener });
|
|
587
|
+
const chunkListener = (data) => {
|
|
588
|
+
if (data.sessionId !== sessionId) return;
|
|
589
|
+
eventQueue.push({ name: "llm:chunk", ...data });
|
|
590
|
+
};
|
|
591
|
+
this.agentEventBus.on("llm:chunk", chunkListener, { signal: cleanupSignal });
|
|
592
|
+
listeners.push({ event: "llm:chunk", listener: chunkListener });
|
|
593
|
+
const responseListener = (data) => {
|
|
594
|
+
if (data.sessionId !== sessionId) return;
|
|
595
|
+
eventQueue.push({ name: "llm:response", ...data });
|
|
596
|
+
completed = true;
|
|
597
|
+
};
|
|
598
|
+
this.agentEventBus.on("llm:response", responseListener, { signal: cleanupSignal });
|
|
599
|
+
listeners.push({ event: "llm:response", listener: responseListener });
|
|
600
|
+
const toolCallListener = (data) => {
|
|
601
|
+
if (data.sessionId !== sessionId) return;
|
|
602
|
+
eventQueue.push({ name: "llm:tool-call", ...data });
|
|
603
|
+
};
|
|
604
|
+
this.agentEventBus.on("llm:tool-call", toolCallListener, { signal: cleanupSignal });
|
|
605
|
+
listeners.push({ event: "llm:tool-call", listener: toolCallListener });
|
|
606
|
+
const toolResultListener = (data) => {
|
|
607
|
+
if (data.sessionId !== sessionId) return;
|
|
608
|
+
eventQueue.push({ name: "llm:tool-result", ...data });
|
|
609
|
+
};
|
|
610
|
+
this.agentEventBus.on("llm:tool-result", toolResultListener, { signal: cleanupSignal });
|
|
611
|
+
listeners.push({ event: "llm:tool-result", listener: toolResultListener });
|
|
612
|
+
const errorListener = (data) => {
|
|
613
|
+
if (data.sessionId !== sessionId) return;
|
|
614
|
+
eventQueue.push({ name: "llm:error", ...data });
|
|
615
|
+
if (!data.recoverable) {
|
|
616
|
+
completed = true;
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
this.agentEventBus.on("llm:error", errorListener, { signal: cleanupSignal });
|
|
620
|
+
listeners.push({ event: "llm:error", listener: errorListener });
|
|
621
|
+
const unsupportedInputListener = (data) => {
|
|
622
|
+
if (data.sessionId !== sessionId) return;
|
|
623
|
+
eventQueue.push({ name: "llm:unsupported-input", ...data });
|
|
624
|
+
};
|
|
625
|
+
this.agentEventBus.on("llm:unsupported-input", unsupportedInputListener, {
|
|
626
|
+
signal: cleanupSignal
|
|
627
|
+
});
|
|
628
|
+
listeners.push({ event: "llm:unsupported-input", listener: unsupportedInputListener });
|
|
629
|
+
const titleUpdatedListener = (data) => {
|
|
630
|
+
if (data.sessionId !== sessionId) return;
|
|
631
|
+
eventQueue.push({ name: "session:title-updated", ...data });
|
|
632
|
+
};
|
|
633
|
+
this.agentEventBus.on("session:title-updated", titleUpdatedListener, {
|
|
634
|
+
signal: cleanupSignal
|
|
635
|
+
});
|
|
636
|
+
listeners.push({ event: "session:title-updated", listener: titleUpdatedListener });
|
|
637
|
+
const approvalRequestListener = (data) => {
|
|
638
|
+
if (data.sessionId !== sessionId) return;
|
|
639
|
+
eventQueue.push({ name: "approval:request", ...data });
|
|
640
|
+
};
|
|
641
|
+
this.agentEventBus.on("approval:request", approvalRequestListener, {
|
|
642
|
+
signal: cleanupSignal
|
|
643
|
+
});
|
|
644
|
+
listeners.push({ event: "approval:request", listener: approvalRequestListener });
|
|
645
|
+
const approvalResponseListener = (data) => {
|
|
646
|
+
if (data.sessionId !== sessionId) return;
|
|
647
|
+
eventQueue.push({ name: "approval:response", ...data });
|
|
648
|
+
};
|
|
649
|
+
this.agentEventBus.on("approval:response", approvalResponseListener, {
|
|
650
|
+
signal: cleanupSignal
|
|
651
|
+
});
|
|
652
|
+
listeners.push({ event: "approval:response", listener: approvalResponseListener });
|
|
596
653
|
const imageDataForRun = imageData ? {
|
|
597
654
|
image: typeof imageData.image === "string" ? imageData.image : imageData.image.toString(),
|
|
598
655
|
mimeType: imageData.mimeType || "image/png"
|
|
@@ -602,19 +659,19 @@ Either:
|
|
|
602
659
|
mimeType: fileData.mimeType,
|
|
603
660
|
...fileData.filename && { filename: fileData.filename }
|
|
604
661
|
} : void 0;
|
|
605
|
-
this.run(message, imageDataForRun, fileDataForRun, sessionId, true).catch((
|
|
662
|
+
this.run(message, imageDataForRun, fileDataForRun, sessionId, true).catch((err) => {
|
|
663
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
606
664
|
_streamError = error;
|
|
607
665
|
completed = true;
|
|
608
|
-
this.logger.error(
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
eventQueue.push({
|
|
612
|
-
type: "llm:error",
|
|
666
|
+
this.logger.error(`Error in DextoAgent.stream: ${error.message}`);
|
|
667
|
+
const errorEvent = {
|
|
668
|
+
name: "llm:error",
|
|
613
669
|
error,
|
|
614
670
|
recoverable: false,
|
|
615
671
|
context: "run_failed",
|
|
616
672
|
sessionId
|
|
617
|
-
}
|
|
673
|
+
};
|
|
674
|
+
eventQueue.push(errorEvent);
|
|
618
675
|
});
|
|
619
676
|
const iterator = {
|
|
620
677
|
async next() {
|
package/dist/agent/schemas.cjs
CHANGED
|
@@ -201,7 +201,7 @@ const AgentConfigSchema = import_zod.z.object({
|
|
|
201
201
|
logger: import_logger.LoggerConfigSchema.describe(
|
|
202
202
|
"Logger configuration with multi-transport support (file, console, remote) - CLI enrichment adds per-agent file transport"
|
|
203
203
|
).default({
|
|
204
|
-
level: "
|
|
204
|
+
level: "error",
|
|
205
205
|
transports: [{ type: "console", colorize: true }]
|
|
206
206
|
}),
|
|
207
207
|
storage: import_schemas5.StorageSchema.describe(
|
package/dist/agent/schemas.js
CHANGED
|
@@ -181,7 +181,7 @@ const AgentConfigSchema = z.object({
|
|
|
181
181
|
logger: LoggerConfigSchema.describe(
|
|
182
182
|
"Logger configuration with multi-transport support (file, console, remote) - CLI enrichment adds per-agent file transport"
|
|
183
183
|
).default({
|
|
184
|
-
level: "
|
|
184
|
+
level: "error",
|
|
185
185
|
transports: [{ type: "console", colorize: true }]
|
|
186
186
|
}),
|
|
187
187
|
storage: StorageSchema.describe(
|
package/dist/agent/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agent/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D;;GAEG;AACH,YAAY,EAAE,SAAS,IAAI,UAAU,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1F,YAAY,EAAE,aAAa,IAAI,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE5E;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf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AC5B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAc,SAAQ,eAAe;CAErD"}
|
|
@@ -46,6 +46,7 @@ __export(schemas_exports, {
|
|
|
46
46
|
module.exports = __toCommonJS(schemas_exports);
|
|
47
47
|
var import_zod = require("zod");
|
|
48
48
|
var import_types = require("./types.js");
|
|
49
|
+
const JsonSchema7Schema = import_zod.z.record(import_zod.z.unknown());
|
|
49
50
|
const ApprovalTypeSchema = import_zod.z.nativeEnum(import_types.ApprovalType);
|
|
50
51
|
const ApprovalStatusSchema = import_zod.z.nativeEnum(import_types.ApprovalStatus);
|
|
51
52
|
const DenialReasonSchema = import_zod.z.nativeEnum(import_types.DenialReason);
|
|
@@ -60,7 +61,7 @@ const CommandConfirmationMetadataSchema = import_zod.z.object({
|
|
|
60
61
|
originalCommand: import_zod.z.string().optional().describe("The original command before normalization")
|
|
61
62
|
}).strict().describe("Command confirmation metadata");
|
|
62
63
|
const ElicitationMetadataSchema = import_zod.z.object({
|
|
63
|
-
schema:
|
|
64
|
+
schema: JsonSchema7Schema.describe("JSON Schema for the form"),
|
|
64
65
|
prompt: import_zod.z.string().describe("Prompt to show the user"),
|
|
65
66
|
serverName: import_zod.z.string().describe("MCP server requesting input"),
|
|
66
67
|
context: import_zod.z.record(import_zod.z.unknown()).optional().describe("Additional context")
|