@dexto/core 1.6.25 → 1.6.26
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 +27 -14
- package/dist/agent/DextoAgent.d.ts +7 -6
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +27 -14
- package/dist/approval/manager.cjs +328 -178
- package/dist/approval/manager.d.ts +39 -31
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +328 -178
- package/dist/approval/session-approval-store.cjs +91 -0
- package/dist/approval/session-approval-store.d.ts +55 -0
- package/dist/approval/session-approval-store.d.ts.map +1 -0
- package/dist/approval/session-approval-store.js +68 -0
- package/dist/llm/executor/turn-executor.cjs +7 -3
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +7 -3
- package/dist/llm/services/factory.cjs +10 -4
- package/dist/llm/services/factory.d.ts +2 -21
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +11 -7
- package/dist/llm/services/types.d.ts +33 -2
- package/dist/llm/services/types.d.ts.map +1 -1
- package/dist/llm/services/vercel.cjs +4 -5
- package/dist/llm/services/vercel.d.ts +3 -3
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +2 -3
- package/dist/logger/default-logger-factory.d.ts +12 -12
- package/dist/logger/v2/schemas.d.ts +6 -6
- package/dist/mcp/schemas.d.ts +10 -10
- package/dist/session/chat-session.cjs +39 -41
- package/dist/session/chat-session.d.ts +22 -12
- package/dist/session/chat-session.d.ts.map +1 -1
- package/dist/session/chat-session.js +39 -41
- package/dist/session/message-queue-store.cjs +75 -0
- package/dist/session/message-queue-store.d.ts +16 -0
- package/dist/session/message-queue-store.d.ts.map +1 -0
- package/dist/session/message-queue-store.js +52 -0
- package/dist/session/message-queue.cjs +140 -46
- package/dist/session/message-queue.d.ts +18 -6
- package/dist/session/message-queue.d.ts.map +1 -1
- package/dist/session/message-queue.js +140 -46
- package/dist/session/session-manager.cjs +130 -25
- package/dist/session/session-manager.d.ts +18 -1
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +130 -25
- package/dist/session/title-generator.cjs +9 -2
- package/dist/session/title-generator.d.ts +2 -0
- package/dist/session/title-generator.d.ts.map +1 -1
- package/dist/session/title-generator.js +9 -2
- package/dist/telemetry/errors.cjs +2 -2
- package/dist/telemetry/errors.js +2 -2
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +3 -1
- package/dist/telemetry/telemetry.cjs +62 -21
- package/dist/telemetry/telemetry.d.ts +14 -0
- package/dist/telemetry/telemetry.d.ts.map +1 -1
- package/dist/telemetry/telemetry.js +62 -21
- package/dist/test-utils/session-state-stores.cjs +68 -0
- package/dist/test-utils/session-state-stores.js +42 -0
- package/dist/tools/session-tool-preferences-store.cjs +86 -0
- package/dist/tools/session-tool-preferences-store.d.ts +29 -0
- package/dist/tools/session-tool-preferences-store.d.ts.map +1 -0
- package/dist/tools/session-tool-preferences-store.js +63 -0
- package/dist/tools/tool-manager.cjs +131 -32
- package/dist/tools/tool-manager.d.ts +17 -6
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +131 -32
- package/dist/utils/service-initializer.cjs +38 -5
- package/dist/utils/service-initializer.d.ts +11 -1
- package/dist/utils/service-initializer.d.ts.map +1 -1
- package/dist/utils/service-initializer.js +36 -4
- package/package.json +1 -1
|
@@ -27,13 +27,13 @@ export declare const DefaultLoggerFactoryConfigSchema: z.ZodObject<{
|
|
|
27
27
|
}, "strict", z.ZodTypeAny, {
|
|
28
28
|
path: string;
|
|
29
29
|
type: "file";
|
|
30
|
-
maxFiles: number;
|
|
31
30
|
maxSize: number;
|
|
31
|
+
maxFiles: number;
|
|
32
32
|
}, {
|
|
33
33
|
path: string;
|
|
34
34
|
type: "file";
|
|
35
|
-
maxFiles?: number | undefined;
|
|
36
35
|
maxSize?: number | undefined;
|
|
36
|
+
maxFiles?: number | undefined;
|
|
37
37
|
}>, z.ZodObject<{
|
|
38
38
|
type: z.ZodLiteral<"upstash">;
|
|
39
39
|
url: z.ZodString;
|
|
@@ -66,8 +66,8 @@ export declare const DefaultLoggerFactoryConfigSchema: z.ZodObject<{
|
|
|
66
66
|
} | {
|
|
67
67
|
path: string;
|
|
68
68
|
type: "file";
|
|
69
|
-
maxFiles: number;
|
|
70
69
|
maxSize: number;
|
|
70
|
+
maxFiles: number;
|
|
71
71
|
} | {
|
|
72
72
|
token: string;
|
|
73
73
|
type: "upstash";
|
|
@@ -86,8 +86,8 @@ export declare const DefaultLoggerFactoryConfigSchema: z.ZodObject<{
|
|
|
86
86
|
} | {
|
|
87
87
|
path: string;
|
|
88
88
|
type: "file";
|
|
89
|
-
maxFiles?: number | undefined;
|
|
90
89
|
maxSize?: number | undefined;
|
|
90
|
+
maxFiles?: number | undefined;
|
|
91
91
|
} | {
|
|
92
92
|
token: string;
|
|
93
93
|
type: "upstash";
|
|
@@ -108,8 +108,8 @@ export declare const DefaultLoggerFactoryConfigSchema: z.ZodObject<{
|
|
|
108
108
|
} | {
|
|
109
109
|
path: string;
|
|
110
110
|
type: "file";
|
|
111
|
-
maxFiles: number;
|
|
112
111
|
maxSize: number;
|
|
112
|
+
maxFiles: number;
|
|
113
113
|
} | {
|
|
114
114
|
token: string;
|
|
115
115
|
type: "upstash";
|
|
@@ -131,8 +131,8 @@ export declare const DefaultLoggerFactoryConfigSchema: z.ZodObject<{
|
|
|
131
131
|
} | {
|
|
132
132
|
path: string;
|
|
133
133
|
type: "file";
|
|
134
|
-
maxFiles?: number | undefined;
|
|
135
134
|
maxSize?: number | undefined;
|
|
135
|
+
maxFiles?: number | undefined;
|
|
136
136
|
} | {
|
|
137
137
|
token: string;
|
|
138
138
|
type: "upstash";
|
|
@@ -179,13 +179,13 @@ export declare const defaultLoggerFactory: {
|
|
|
179
179
|
}, "strict", z.ZodTypeAny, {
|
|
180
180
|
path: string;
|
|
181
181
|
type: "file";
|
|
182
|
-
maxFiles: number;
|
|
183
182
|
maxSize: number;
|
|
183
|
+
maxFiles: number;
|
|
184
184
|
}, {
|
|
185
185
|
path: string;
|
|
186
186
|
type: "file";
|
|
187
|
-
maxFiles?: number | undefined;
|
|
188
187
|
maxSize?: number | undefined;
|
|
188
|
+
maxFiles?: number | undefined;
|
|
189
189
|
}>, z.ZodObject<{
|
|
190
190
|
type: z.ZodLiteral<"upstash">;
|
|
191
191
|
url: z.ZodString;
|
|
@@ -218,8 +218,8 @@ export declare const defaultLoggerFactory: {
|
|
|
218
218
|
} | {
|
|
219
219
|
path: string;
|
|
220
220
|
type: "file";
|
|
221
|
-
maxFiles: number;
|
|
222
221
|
maxSize: number;
|
|
222
|
+
maxFiles: number;
|
|
223
223
|
} | {
|
|
224
224
|
token: string;
|
|
225
225
|
type: "upstash";
|
|
@@ -238,8 +238,8 @@ export declare const defaultLoggerFactory: {
|
|
|
238
238
|
} | {
|
|
239
239
|
path: string;
|
|
240
240
|
type: "file";
|
|
241
|
-
maxFiles?: number | undefined;
|
|
242
241
|
maxSize?: number | undefined;
|
|
242
|
+
maxFiles?: number | undefined;
|
|
243
243
|
} | {
|
|
244
244
|
token: string;
|
|
245
245
|
type: "upstash";
|
|
@@ -260,8 +260,8 @@ export declare const defaultLoggerFactory: {
|
|
|
260
260
|
} | {
|
|
261
261
|
path: string;
|
|
262
262
|
type: "file";
|
|
263
|
-
maxFiles: number;
|
|
264
263
|
maxSize: number;
|
|
264
|
+
maxFiles: number;
|
|
265
265
|
} | {
|
|
266
266
|
token: string;
|
|
267
267
|
type: "upstash";
|
|
@@ -283,8 +283,8 @@ export declare const defaultLoggerFactory: {
|
|
|
283
283
|
} | {
|
|
284
284
|
path: string;
|
|
285
285
|
type: "file";
|
|
286
|
-
maxFiles?: number | undefined;
|
|
287
286
|
maxSize?: number | undefined;
|
|
287
|
+
maxFiles?: number | undefined;
|
|
288
288
|
} | {
|
|
289
289
|
token: string;
|
|
290
290
|
type: "upstash";
|
|
@@ -31,13 +31,13 @@ export declare const LoggerTransportSchema: z.ZodDiscriminatedUnion<"type", [z.Z
|
|
|
31
31
|
}, "strict", z.ZodTypeAny, {
|
|
32
32
|
path: string;
|
|
33
33
|
type: "file";
|
|
34
|
-
maxFiles: number;
|
|
35
34
|
maxSize: number;
|
|
35
|
+
maxFiles: number;
|
|
36
36
|
}, {
|
|
37
37
|
path: string;
|
|
38
38
|
type: "file";
|
|
39
|
-
maxFiles?: number | undefined;
|
|
40
39
|
maxSize?: number | undefined;
|
|
40
|
+
maxFiles?: number | undefined;
|
|
41
41
|
}>, z.ZodObject<{
|
|
42
42
|
type: z.ZodLiteral<"upstash">;
|
|
43
43
|
url: z.ZodString;
|
|
@@ -89,13 +89,13 @@ export declare const LoggerConfigSchema: z.ZodObject<{
|
|
|
89
89
|
}, "strict", z.ZodTypeAny, {
|
|
90
90
|
path: string;
|
|
91
91
|
type: "file";
|
|
92
|
-
maxFiles: number;
|
|
93
92
|
maxSize: number;
|
|
93
|
+
maxFiles: number;
|
|
94
94
|
}, {
|
|
95
95
|
path: string;
|
|
96
96
|
type: "file";
|
|
97
|
-
maxFiles?: number | undefined;
|
|
98
97
|
maxSize?: number | undefined;
|
|
98
|
+
maxFiles?: number | undefined;
|
|
99
99
|
}>, z.ZodObject<{
|
|
100
100
|
type: z.ZodLiteral<"upstash">;
|
|
101
101
|
url: z.ZodString;
|
|
@@ -128,8 +128,8 @@ export declare const LoggerConfigSchema: z.ZodObject<{
|
|
|
128
128
|
} | {
|
|
129
129
|
path: string;
|
|
130
130
|
type: "file";
|
|
131
|
-
maxFiles: number;
|
|
132
131
|
maxSize: number;
|
|
132
|
+
maxFiles: number;
|
|
133
133
|
} | {
|
|
134
134
|
token: string;
|
|
135
135
|
type: "upstash";
|
|
@@ -148,8 +148,8 @@ export declare const LoggerConfigSchema: z.ZodObject<{
|
|
|
148
148
|
} | {
|
|
149
149
|
path: string;
|
|
150
150
|
type: "file";
|
|
151
|
-
maxFiles?: number | undefined;
|
|
152
151
|
maxSize?: number | undefined;
|
|
152
|
+
maxFiles?: number | undefined;
|
|
153
153
|
} | {
|
|
154
154
|
token: string;
|
|
155
155
|
type: "upstash";
|
package/dist/mcp/schemas.d.ts
CHANGED
|
@@ -55,8 +55,8 @@ export declare const SseServerConfigSchema: z.ZodObject<{
|
|
|
55
55
|
timeout: number;
|
|
56
56
|
type: "sse";
|
|
57
57
|
enabled: boolean;
|
|
58
|
-
connectionMode: "strict" | "lenient";
|
|
59
58
|
url: string;
|
|
59
|
+
connectionMode: "strict" | "lenient";
|
|
60
60
|
headers: Record<string, string>;
|
|
61
61
|
}, {
|
|
62
62
|
type: "sse";
|
|
@@ -79,8 +79,8 @@ export declare const HttpServerConfigSchema: z.ZodObject<{
|
|
|
79
79
|
timeout: number;
|
|
80
80
|
type: "http";
|
|
81
81
|
enabled: boolean;
|
|
82
|
-
connectionMode: "strict" | "lenient";
|
|
83
82
|
url: string;
|
|
83
|
+
connectionMode: "strict" | "lenient";
|
|
84
84
|
headers: Record<string, string>;
|
|
85
85
|
}, {
|
|
86
86
|
type: "http";
|
|
@@ -127,8 +127,8 @@ export declare const McpServerConfigSchema: z.ZodBranded<z.ZodEffects<z.ZodDiscr
|
|
|
127
127
|
timeout: number;
|
|
128
128
|
type: "sse";
|
|
129
129
|
enabled: boolean;
|
|
130
|
-
connectionMode: "strict" | "lenient";
|
|
131
130
|
url: string;
|
|
131
|
+
connectionMode: "strict" | "lenient";
|
|
132
132
|
headers: Record<string, string>;
|
|
133
133
|
}, {
|
|
134
134
|
type: "sse";
|
|
@@ -148,8 +148,8 @@ export declare const McpServerConfigSchema: z.ZodBranded<z.ZodEffects<z.ZodDiscr
|
|
|
148
148
|
timeout: number;
|
|
149
149
|
type: "http";
|
|
150
150
|
enabled: boolean;
|
|
151
|
-
connectionMode: "strict" | "lenient";
|
|
152
151
|
url: string;
|
|
152
|
+
connectionMode: "strict" | "lenient";
|
|
153
153
|
headers: Record<string, string>;
|
|
154
154
|
}, {
|
|
155
155
|
type: "http";
|
|
@@ -170,15 +170,15 @@ export declare const McpServerConfigSchema: z.ZodBranded<z.ZodEffects<z.ZodDiscr
|
|
|
170
170
|
timeout: number;
|
|
171
171
|
type: "sse";
|
|
172
172
|
enabled: boolean;
|
|
173
|
-
connectionMode: "strict" | "lenient";
|
|
174
173
|
url: string;
|
|
174
|
+
connectionMode: "strict" | "lenient";
|
|
175
175
|
headers: Record<string, string>;
|
|
176
176
|
} | {
|
|
177
177
|
timeout: number;
|
|
178
178
|
type: "http";
|
|
179
179
|
enabled: boolean;
|
|
180
|
-
connectionMode: "strict" | "lenient";
|
|
181
180
|
url: string;
|
|
181
|
+
connectionMode: "strict" | "lenient";
|
|
182
182
|
headers: Record<string, string>;
|
|
183
183
|
}, {
|
|
184
184
|
type: "stdio";
|
|
@@ -240,8 +240,8 @@ export declare const ServersConfigSchema: z.ZodBranded<z.ZodRecord<z.ZodString,
|
|
|
240
240
|
timeout: number;
|
|
241
241
|
type: "sse";
|
|
242
242
|
enabled: boolean;
|
|
243
|
-
connectionMode: "strict" | "lenient";
|
|
244
243
|
url: string;
|
|
244
|
+
connectionMode: "strict" | "lenient";
|
|
245
245
|
headers: Record<string, string>;
|
|
246
246
|
}, {
|
|
247
247
|
type: "sse";
|
|
@@ -261,8 +261,8 @@ export declare const ServersConfigSchema: z.ZodBranded<z.ZodRecord<z.ZodString,
|
|
|
261
261
|
timeout: number;
|
|
262
262
|
type: "http";
|
|
263
263
|
enabled: boolean;
|
|
264
|
-
connectionMode: "strict" | "lenient";
|
|
265
264
|
url: string;
|
|
265
|
+
connectionMode: "strict" | "lenient";
|
|
266
266
|
headers: Record<string, string>;
|
|
267
267
|
}, {
|
|
268
268
|
type: "http";
|
|
@@ -283,15 +283,15 @@ export declare const ServersConfigSchema: z.ZodBranded<z.ZodRecord<z.ZodString,
|
|
|
283
283
|
timeout: number;
|
|
284
284
|
type: "sse";
|
|
285
285
|
enabled: boolean;
|
|
286
|
-
connectionMode: "strict" | "lenient";
|
|
287
286
|
url: string;
|
|
287
|
+
connectionMode: "strict" | "lenient";
|
|
288
288
|
headers: Record<string, string>;
|
|
289
289
|
} | {
|
|
290
290
|
timeout: number;
|
|
291
291
|
type: "http";
|
|
292
292
|
enabled: boolean;
|
|
293
|
-
connectionMode: "strict" | "lenient";
|
|
294
293
|
url: string;
|
|
294
|
+
connectionMode: "strict" | "lenient";
|
|
295
295
|
headers: Record<string, string>;
|
|
296
296
|
}, {
|
|
297
297
|
type: "stdio";
|
|
@@ -28,6 +28,7 @@ var import_events = require("../events/index.js");
|
|
|
28
28
|
var import_types = require("../logger/v2/types.js");
|
|
29
29
|
var import_errors = require("../errors/index.js");
|
|
30
30
|
var import_error_codes = require("../hooks/error-codes.js");
|
|
31
|
+
var import_message_queue = require("./message-queue.js");
|
|
31
32
|
var import_usage_metadata = require("../llm/usage-metadata.js");
|
|
32
33
|
var import_codex_base_url = require("../llm/providers/codex-base-url.js");
|
|
33
34
|
class ChatSession {
|
|
@@ -36,7 +37,7 @@ class ChatSession {
|
|
|
36
37
|
*
|
|
37
38
|
* Each session creates its own isolated services:
|
|
38
39
|
* - ConversationHistoryProvider (with session-specific storage, shared across LLM switches)
|
|
39
|
-
* -
|
|
40
|
+
* - LLM service (creates its own properly-typed ContextManager internally)
|
|
40
41
|
* - SessionEventBus (session-local event handling with forwarding)
|
|
41
42
|
*
|
|
42
43
|
* @param services - The shared services from the agent (state manager, prompt, client managers, etc.)
|
|
@@ -48,6 +49,12 @@ class ChatSession {
|
|
|
48
49
|
this.id = id;
|
|
49
50
|
this.logger = logger.createChild(import_types.DextoLogComponent.SESSION);
|
|
50
51
|
this.eventBus = new import_events.SessionEventBus();
|
|
52
|
+
this.messageQueue = new import_message_queue.MessageQueueService(
|
|
53
|
+
this.eventBus,
|
|
54
|
+
this.logger,
|
|
55
|
+
this.id,
|
|
56
|
+
this.services.messageQueueStore
|
|
57
|
+
);
|
|
51
58
|
this.setupEventForwarding();
|
|
52
59
|
this.logger.debug(`ChatSession ${this.id}: Created, awaiting initialization`);
|
|
53
60
|
}
|
|
@@ -71,10 +78,15 @@ class ChatSession {
|
|
|
71
78
|
/**
|
|
72
79
|
* Handles AI model interactions, tool execution, and response generation for this session.
|
|
73
80
|
*
|
|
74
|
-
* Each session has its own
|
|
81
|
+
* Each session has its own LLM runtime instance that uses the session's
|
|
75
82
|
* ContextManager and event bus.
|
|
76
83
|
*/
|
|
77
84
|
llmService;
|
|
85
|
+
/**
|
|
86
|
+
* Durable queued follow-up messages for this session.
|
|
87
|
+
* Reused across LLM switches so mid-task follow-ups survive service recreation.
|
|
88
|
+
*/
|
|
89
|
+
messageQueue;
|
|
78
90
|
/**
|
|
79
91
|
* Map of event forwarder functions for cleanup.
|
|
80
92
|
* Stores the bound functions so they can be removed from the event bus.
|
|
@@ -166,33 +178,35 @@ class ChatSession {
|
|
|
166
178
|
async initializeServices() {
|
|
167
179
|
const runtimeConfig = this.services.stateManager.getRuntimeConfig(this.id);
|
|
168
180
|
const llmConfig = runtimeConfig.llm;
|
|
169
|
-
|
|
181
|
+
await this.messageQueue.initialize();
|
|
170
182
|
this.historyProvider = (0, import_factory.createDatabaseHistoryProvider)(
|
|
171
183
|
this.services.storageManager.getDatabase(),
|
|
172
184
|
this.id,
|
|
173
185
|
this.logger
|
|
174
186
|
);
|
|
175
|
-
|
|
176
|
-
this.
|
|
187
|
+
this.llmService = await this.createSessionLLMService(llmConfig, runtimeConfig.usageScopeId);
|
|
188
|
+
this.logger.debug(`ChatSession ${this.id}: Services initialized with storage`);
|
|
189
|
+
}
|
|
190
|
+
async createSessionLLMService(llmConfig, usageScopeId) {
|
|
191
|
+
const workspace = await this.services.workspaceManager?.getWorkspace();
|
|
192
|
+
const options = {
|
|
193
|
+
usageScopeId,
|
|
194
|
+
compactionStrategy: this.services.compactionStrategy,
|
|
195
|
+
...workspace?.path !== void 0 && { cwd: workspace.path },
|
|
196
|
+
messageQueue: this.messageQueue
|
|
197
|
+
};
|
|
198
|
+
return (0, import_factory2.createLLMService)(
|
|
177
199
|
llmConfig,
|
|
178
200
|
this.services.toolManager,
|
|
179
201
|
this.services.systemPromptManager,
|
|
180
202
|
this.historyProvider,
|
|
181
|
-
// Pass history provider for service to use
|
|
182
203
|
this.eventBus,
|
|
183
|
-
// Use session event bus
|
|
184
204
|
this.id,
|
|
185
205
|
this.services.resourceManager,
|
|
186
|
-
// Pass ResourceManager for blob storage
|
|
187
206
|
this.logger,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
usageScopeId: runtimeConfig.usageScopeId,
|
|
191
|
-
compactionStrategy,
|
|
192
|
-
cwd: workspace?.path
|
|
193
|
-
}
|
|
207
|
+
options,
|
|
208
|
+
this.services.languageModelFactory
|
|
194
209
|
);
|
|
195
|
-
this.logger.debug(`ChatSession ${this.id}: Services initialized with storage`);
|
|
196
210
|
}
|
|
197
211
|
/**
|
|
198
212
|
* Saves a blocked interaction to history when a plugin blocks execution.
|
|
@@ -448,9 +462,9 @@ class ChatSession {
|
|
|
448
462
|
return this.llmService.getContextManager();
|
|
449
463
|
}
|
|
450
464
|
/**
|
|
451
|
-
* Gets the session's
|
|
465
|
+
* Gets the session's LLM service instance.
|
|
452
466
|
*
|
|
453
|
-
* @returns The
|
|
467
|
+
* @returns The session LLM service for this session
|
|
454
468
|
*/
|
|
455
469
|
getLLMService() {
|
|
456
470
|
return this.llmService;
|
|
@@ -477,26 +491,10 @@ class ChatSession {
|
|
|
477
491
|
async switchLLM(newLLMConfig) {
|
|
478
492
|
try {
|
|
479
493
|
const runtimeConfig = this.services.stateManager.getRuntimeConfig(this.id);
|
|
480
|
-
|
|
481
|
-
const compactionStrategy = this.services.compactionStrategy;
|
|
482
|
-
const newLLMService = (0, import_factory2.createLLMService)(
|
|
494
|
+
this.llmService = await this.createSessionLLMService(
|
|
483
495
|
newLLMConfig,
|
|
484
|
-
|
|
485
|
-
this.services.systemPromptManager,
|
|
486
|
-
this.historyProvider,
|
|
487
|
-
// Pass the SAME history provider - preserves conversation!
|
|
488
|
-
this.eventBus,
|
|
489
|
-
// Use session event bus
|
|
490
|
-
this.id,
|
|
491
|
-
this.services.resourceManager,
|
|
492
|
-
this.logger,
|
|
493
|
-
{
|
|
494
|
-
usageScopeId: runtimeConfig.usageScopeId,
|
|
495
|
-
compactionStrategy,
|
|
496
|
-
cwd: workspace?.path
|
|
497
|
-
}
|
|
496
|
+
runtimeConfig.usageScopeId
|
|
498
497
|
);
|
|
499
|
-
this.llmService = newLLMService;
|
|
500
498
|
this.logger.info(
|
|
501
499
|
`ChatSession ${this.id}: LLM switched to ${newLLMConfig.provider}/${newLLMConfig.model}`
|
|
502
500
|
);
|
|
@@ -562,8 +560,8 @@ class ChatSession {
|
|
|
562
560
|
* @param message The user message to queue
|
|
563
561
|
* @returns Queue position and message ID
|
|
564
562
|
*/
|
|
565
|
-
queueMessage(message) {
|
|
566
|
-
return this.llmService.getMessageQueue().enqueue(message);
|
|
563
|
+
async queueMessage(message) {
|
|
564
|
+
return await this.llmService.getMessageQueue().enqueue(message);
|
|
567
565
|
}
|
|
568
566
|
/**
|
|
569
567
|
* Get all messages currently in the queue.
|
|
@@ -577,17 +575,17 @@ class ChatSession {
|
|
|
577
575
|
* @param id Message ID to remove
|
|
578
576
|
* @returns true if message was found and removed; false otherwise
|
|
579
577
|
*/
|
|
580
|
-
removeQueuedMessage(id) {
|
|
581
|
-
return this.llmService.getMessageQueue().remove(id);
|
|
578
|
+
async removeQueuedMessage(id) {
|
|
579
|
+
return await this.llmService.getMessageQueue().remove(id);
|
|
582
580
|
}
|
|
583
581
|
/**
|
|
584
582
|
* Clear all queued messages.
|
|
585
583
|
* @returns Number of messages that were cleared
|
|
586
584
|
*/
|
|
587
|
-
clearMessageQueue() {
|
|
585
|
+
async clearMessageQueue() {
|
|
588
586
|
const queue = this.llmService.getMessageQueue();
|
|
589
587
|
const count = queue.pendingCount();
|
|
590
|
-
queue.clear();
|
|
588
|
+
await queue.clear();
|
|
591
589
|
return count;
|
|
592
590
|
}
|
|
593
591
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContextManager } from '../context/index.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LanguageModelFactory } from '../llm/services/types.js';
|
|
3
3
|
import type { SystemPromptManager } from '../systemPrompt/manager.js';
|
|
4
4
|
import type { ToolManager } from '../tools/tool-manager.js';
|
|
5
5
|
import type { ValidatedLLMConfig } from '../llm/schemas.js';
|
|
@@ -10,9 +10,11 @@ import type { MCPManager } from '../mcp/manager.js';
|
|
|
10
10
|
import { SessionEventBus, AgentEventBus } from '../events/index.js';
|
|
11
11
|
import type { Logger } from '../logger/v2/types.js';
|
|
12
12
|
import type { InternalMessage } from '../context/types.js';
|
|
13
|
-
import type
|
|
13
|
+
import { type UserMessageInput } from './message-queue.js';
|
|
14
|
+
import type { MessageQueueStore } from './message-queue-store.js';
|
|
14
15
|
import type { ContentInput } from '../agent/types.js';
|
|
15
16
|
import type { CompactionStrategy } from '../context/compaction/types.js';
|
|
17
|
+
import type { VercelLLMService } from '../llm/services/vercel.js';
|
|
16
18
|
/**
|
|
17
19
|
* Represents an isolated conversation session within a Dexto agent.
|
|
18
20
|
*
|
|
@@ -25,7 +27,7 @@ import type { CompactionStrategy } from '../context/compaction/types.js';
|
|
|
25
27
|
* The ChatSession acts as a lightweight wrapper around core Dexto services, providing
|
|
26
28
|
* session-specific instances of:
|
|
27
29
|
* - **ContextManager**: Handles conversation history and message formatting
|
|
28
|
-
* - **
|
|
30
|
+
* - **VercelLLMService**: Manages AI model interactions and tool execution
|
|
29
31
|
* - **TypedEventEmitter**: Provides session-scoped event handling
|
|
30
32
|
*
|
|
31
33
|
* ## Event Handling
|
|
@@ -55,7 +57,7 @@ import type { CompactionStrategy } from '../context/compaction/types.js';
|
|
|
55
57
|
*
|
|
56
58
|
* @see {@link SessionManager} for session lifecycle management
|
|
57
59
|
* @see {@link ContextManager} for conversation history management
|
|
58
|
-
* @see {@link
|
|
60
|
+
* @see {@link createLLMService} for the default AI model integration path
|
|
59
61
|
*/
|
|
60
62
|
export declare class ChatSession {
|
|
61
63
|
private services;
|
|
@@ -80,10 +82,15 @@ export declare class ChatSession {
|
|
|
80
82
|
/**
|
|
81
83
|
* Handles AI model interactions, tool execution, and response generation for this session.
|
|
82
84
|
*
|
|
83
|
-
* Each session has its own
|
|
85
|
+
* Each session has its own LLM runtime instance that uses the session's
|
|
84
86
|
* ContextManager and event bus.
|
|
85
87
|
*/
|
|
86
88
|
private llmService;
|
|
89
|
+
/**
|
|
90
|
+
* Durable queued follow-up messages for this session.
|
|
91
|
+
* Reused across LLM switches so mid-task follow-ups survive service recreation.
|
|
92
|
+
*/
|
|
93
|
+
private messageQueue;
|
|
87
94
|
/**
|
|
88
95
|
* Map of event forwarder functions for cleanup.
|
|
89
96
|
* Stores the bound functions so they can be removed from the event bus.
|
|
@@ -104,7 +111,7 @@ export declare class ChatSession {
|
|
|
104
111
|
*
|
|
105
112
|
* Each session creates its own isolated services:
|
|
106
113
|
* - ConversationHistoryProvider (with session-specific storage, shared across LLM switches)
|
|
107
|
-
* -
|
|
114
|
+
* - LLM service (creates its own properly-typed ContextManager internally)
|
|
108
115
|
* - SessionEventBus (session-local event handling with forwarding)
|
|
109
116
|
*
|
|
110
117
|
* @param services - The shared services from the agent (state manager, prompt, client managers, etc.)
|
|
@@ -121,6 +128,8 @@ export declare class ChatSession {
|
|
|
121
128
|
hookManager: HookManager;
|
|
122
129
|
mcpManager: MCPManager;
|
|
123
130
|
sessionManager: import('./session-manager.js').SessionManager;
|
|
131
|
+
messageQueueStore: Pick<MessageQueueStore, 'load' | 'save' | 'delete'>;
|
|
132
|
+
languageModelFactory?: LanguageModelFactory;
|
|
124
133
|
workspaceManager?: import('../workspace/manager.js').WorkspaceManager;
|
|
125
134
|
compactionStrategy: CompactionStrategy | null;
|
|
126
135
|
}, id: string, logger: Logger);
|
|
@@ -147,6 +156,7 @@ export declare class ChatSession {
|
|
|
147
156
|
* Initializes session-specific services.
|
|
148
157
|
*/
|
|
149
158
|
private initializeServices;
|
|
159
|
+
private createSessionLLMService;
|
|
150
160
|
/**
|
|
151
161
|
* Saves a blocked interaction to history when a plugin blocks execution.
|
|
152
162
|
* This ensures that even when a plugin blocks execution (e.g., due to abusive language),
|
|
@@ -240,9 +250,9 @@ export declare class ChatSession {
|
|
|
240
250
|
*/
|
|
241
251
|
getContextManager(): ContextManager<unknown>;
|
|
242
252
|
/**
|
|
243
|
-
* Gets the session's
|
|
253
|
+
* Gets the session's LLM service instance.
|
|
244
254
|
*
|
|
245
|
-
* @returns The
|
|
255
|
+
* @returns The session LLM service for this session
|
|
246
256
|
*/
|
|
247
257
|
getLLMService(): VercelLLMService;
|
|
248
258
|
/**
|
|
@@ -291,11 +301,11 @@ export declare class ChatSession {
|
|
|
291
301
|
* @param message The user message to queue
|
|
292
302
|
* @returns Queue position and message ID
|
|
293
303
|
*/
|
|
294
|
-
queueMessage(message: UserMessageInput): {
|
|
304
|
+
queueMessage(message: UserMessageInput): Promise<{
|
|
295
305
|
queued: true;
|
|
296
306
|
position: number;
|
|
297
307
|
id: string;
|
|
298
|
-
}
|
|
308
|
+
}>;
|
|
299
309
|
/**
|
|
300
310
|
* Get all messages currently in the queue.
|
|
301
311
|
* @returns Array of queued messages
|
|
@@ -306,12 +316,12 @@ export declare class ChatSession {
|
|
|
306
316
|
* @param id Message ID to remove
|
|
307
317
|
* @returns true if message was found and removed; false otherwise
|
|
308
318
|
*/
|
|
309
|
-
removeQueuedMessage(id: string): boolean
|
|
319
|
+
removeQueuedMessage(id: string): Promise<boolean>;
|
|
310
320
|
/**
|
|
311
321
|
* Clear all queued messages.
|
|
312
322
|
* @returns Number of messages that were cleared
|
|
313
323
|
*/
|
|
314
|
-
clearMessageQueue(): number
|
|
324
|
+
clearMessageQueue(): Promise<number>;
|
|
315
325
|
/**
|
|
316
326
|
* Cancel the currently running turn for this session, if any.
|
|
317
327
|
* Returns true if a run was in progress and was signaled to abort.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-session.d.ts","sourceRoot":"","sources":["../../src/session/chat-session.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"chat-session.d.ts","sourceRoot":"","sources":["../../src/session/chat-session.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAA2B,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACH,eAAe,EACf,aAAa,EAIhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAA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