@dexto/core 1.8.12 → 1.9.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.
Files changed (110) hide show
  1. package/dist/approval/manager.cjs +37 -325
  2. package/dist/approval/manager.d.ts +10 -109
  3. package/dist/approval/manager.d.ts.map +1 -1
  4. package/dist/approval/manager.js +37 -316
  5. package/dist/approval/schemas.cjs +8 -51
  6. package/dist/approval/schemas.d.ts +5 -179
  7. package/dist/approval/schemas.d.ts.map +1 -1
  8. package/dist/approval/schemas.js +8 -47
  9. package/dist/approval/types.cjs +0 -6
  10. package/dist/approval/types.d.ts +2 -27
  11. package/dist/approval/types.d.ts.map +1 -1
  12. package/dist/approval/types.js +0 -6
  13. package/dist/context/content-clone.cjs +12 -8
  14. package/dist/context/content-clone.d.ts.map +1 -1
  15. package/dist/context/content-clone.js +12 -8
  16. package/dist/errors/DextoRuntimeError.cjs +3 -1
  17. package/dist/errors/DextoRuntimeError.d.ts +5 -3
  18. package/dist/errors/DextoRuntimeError.d.ts.map +1 -1
  19. package/dist/errors/DextoRuntimeError.js +3 -1
  20. package/dist/errors/index.d.ts +1 -1
  21. package/dist/errors/index.d.ts.map +1 -1
  22. package/dist/errors/types.d.ts +1 -0
  23. package/dist/errors/types.d.ts.map +1 -1
  24. package/dist/events/index.d.ts +2 -2
  25. package/dist/events/index.d.ts.map +1 -1
  26. package/dist/llm/executor/provider-error.cjs +25 -4
  27. package/dist/llm/executor/provider-error.d.ts.map +1 -1
  28. package/dist/llm/executor/provider-error.js +25 -4
  29. package/dist/llm/executor/stream-processor.cjs +61 -0
  30. package/dist/llm/executor/stream-processor.d.ts.map +1 -1
  31. package/dist/llm/executor/stream-processor.js +61 -0
  32. package/dist/llm/executor/turn-executor.cjs +93 -26
  33. package/dist/llm/executor/turn-executor.d.ts +2 -0
  34. package/dist/llm/executor/turn-executor.d.ts.map +1 -1
  35. package/dist/llm/executor/turn-executor.js +93 -26
  36. package/dist/llm/services/factory.cjs +3 -2
  37. package/dist/llm/services/factory.d.ts.map +1 -1
  38. package/dist/llm/services/factory.js +3 -2
  39. package/dist/llm/services/types.d.ts +8 -0
  40. package/dist/llm/services/types.d.ts.map +1 -1
  41. package/dist/llm/services/vercel.cjs +6 -1
  42. package/dist/llm/services/vercel.d.ts +3 -2
  43. package/dist/llm/services/vercel.d.ts.map +1 -1
  44. package/dist/llm/services/vercel.js +6 -1
  45. package/dist/session/chat-session.cjs +3 -0
  46. package/dist/session/chat-session.d.ts +2 -1
  47. package/dist/session/chat-session.d.ts.map +1 -1
  48. package/dist/session/chat-session.js +3 -0
  49. package/dist/session/message-queue.cjs +48 -75
  50. package/dist/session/message-queue.d.ts +1 -2
  51. package/dist/session/message-queue.d.ts.map +1 -1
  52. package/dist/session/message-queue.js +48 -75
  53. package/dist/session/session-manager.cjs +14 -32
  54. package/dist/session/session-manager.d.ts +5 -2
  55. package/dist/session/session-manager.d.ts.map +1 -1
  56. package/dist/session/session-manager.js +14 -32
  57. package/dist/storage/approvals/types.cjs +2 -9
  58. package/dist/storage/approvals/types.d.ts +4 -16
  59. package/dist/storage/approvals/types.d.ts.map +1 -1
  60. package/dist/storage/approvals/types.js +2 -8
  61. package/dist/storage/database/types.d.ts +5 -0
  62. package/dist/storage/database/types.d.ts.map +1 -1
  63. package/dist/storage/index.cjs +0 -2
  64. package/dist/storage/index.d.ts +2 -2
  65. package/dist/storage/index.d.ts.map +1 -1
  66. package/dist/storage/index.js +1 -2
  67. package/dist/storage/message-queue/types.d.ts +14 -6
  68. package/dist/storage/message-queue/types.d.ts.map +1 -1
  69. package/dist/storage/stores/backend.cjs +68 -32
  70. package/dist/storage/stores/backend.d.ts +17 -8
  71. package/dist/storage/stores/backend.d.ts.map +1 -1
  72. package/dist/storage/stores/backend.js +69 -33
  73. package/dist/storage/stores/in-memory.cjs +26 -11
  74. package/dist/storage/stores/in-memory.d.ts.map +1 -1
  75. package/dist/storage/stores/in-memory.js +27 -12
  76. package/dist/test-utils/in-memory-storage.cjs +11 -0
  77. package/dist/test-utils/in-memory-storage.js +11 -0
  78. package/dist/test-utils/session-state-stores.cjs +25 -9
  79. package/dist/test-utils/session-state-stores.js +26 -10
  80. package/dist/tools/approval/tool-approval-policy.cjs +87 -0
  81. package/dist/tools/approval/tool-approval-policy.d.ts +34 -0
  82. package/dist/tools/approval/tool-approval-policy.d.ts.map +1 -0
  83. package/dist/tools/approval/tool-approval-policy.js +64 -0
  84. package/dist/tools/error-codes.cjs +0 -1
  85. package/dist/tools/error-codes.d.ts +0 -1
  86. package/dist/tools/error-codes.d.ts.map +1 -1
  87. package/dist/tools/error-codes.js +0 -1
  88. package/dist/tools/errors.cjs +0 -15
  89. package/dist/tools/errors.d.ts +0 -9
  90. package/dist/tools/errors.d.ts.map +1 -1
  91. package/dist/tools/errors.js +0 -15
  92. package/dist/tools/index.cjs +2 -0
  93. package/dist/tools/index.d.ts +1 -1
  94. package/dist/tools/index.d.ts.map +1 -1
  95. package/dist/tools/index.js +5 -1
  96. package/dist/tools/tool-manager.cjs +94 -312
  97. package/dist/tools/tool-manager.d.ts +4 -19
  98. package/dist/tools/tool-manager.d.ts.map +1 -1
  99. package/dist/tools/tool-manager.js +95 -316
  100. package/dist/tools/types.d.ts +10 -9
  101. package/dist/tools/types.d.ts.map +1 -1
  102. package/dist/utils/service-initializer.cjs +3 -0
  103. package/dist/utils/service-initializer.d.ts +2 -1
  104. package/dist/utils/service-initializer.d.ts.map +1 -1
  105. package/dist/utils/service-initializer.js +3 -0
  106. package/package.json +2 -2
  107. package/dist/tools/pattern-utils.cjs +0 -33
  108. package/dist/tools/pattern-utils.d.ts +0 -20
  109. package/dist/tools/pattern-utils.d.ts.map +0 -1
  110. package/dist/tools/pattern-utils.js +0 -10
@@ -1,5 +1,5 @@
1
1
  import type { ContextManager } from '../context/index.js';
2
- import type { LanguageModelFactory } from '../llm/services/types.js';
2
+ import type { LLMExecutionControl, LanguageModelFactory } from '../llm/services/types.js';
3
3
  import type { LlmAuthResolver } from '../llm/auth/index.js';
4
4
  import type { SystemPromptManager } from '../systemPrompt/manager.js';
5
5
  import type { ToolManager } from '../tools/tool-manager.js';
@@ -148,6 +148,7 @@ export declare class ChatSession {
148
148
  authResolver?: LlmAuthResolver | null;
149
149
  workspaceManager?: import('../workspace/manager.js').WorkspaceManager;
150
150
  compactionStrategy: CompactionStrategy | null;
151
+ executionControl?: LLMExecutionControl | undefined;
151
152
  }, id: string, logger: Logger);
152
153
  /**
153
154
  * Initialize the session services asynchronously.
@@ -1 +1 @@
1
- {"version":3,"file":"chat-session.d.ts","sourceRoot":"","sources":["../../src/session/chat-session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK1D,OAAO,KAAK,EAA2B,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,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,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACH,eAAe,EACf,aAAa,EAGhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,O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;OAIG;IACU,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhE;;;OAGG;IACU,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAO/C;;;OAGG;IACU,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAOlD;;;OAGG;IACU,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAQjD;;;OAGG;IACI,MAAM,IAAI,OAAO;CAa3B"}
@@ -176,6 +176,9 @@ class ChatSession {
176
176
  const options = {
177
177
  usageScopeId,
178
178
  compactionStrategy: this.services.compactionStrategy,
179
+ ...this.services.executionControl !== void 0 && {
180
+ executionControl: this.services.executionControl
181
+ },
179
182
  ...workspace?.path !== void 0 && { cwd: workspace.path },
180
183
  steerQueue: this.steerQueue,
181
184
  followUpQueue: this.followUpQueue,
@@ -23,18 +23,31 @@ __export(message_queue_exports, {
23
23
  module.exports = __toCommonJS(message_queue_exports);
24
24
  var import_queue_clone = require("./queue-clone.js");
25
25
  class EphemeralMessageQueueStore {
26
- async listSessionIds() {
27
- return [];
28
- }
29
- async load(input) {
26
+ queue = [];
27
+ async list(input) {
30
28
  void input;
31
- return [];
29
+ return (0, import_queue_clone.cloneQueuedMessages)(this.queue);
32
30
  }
33
- async save(input) {
34
- void input;
31
+ async append(input) {
32
+ void input.sessionId;
33
+ this.queue = [...this.queue, (0, import_queue_clone.cloneQueuedMessage)(input.message)];
34
+ return { position: this.queue.length };
35
35
  }
36
- async delete(input) {
37
- void input;
36
+ async takeAll(input) {
37
+ void input.sessionId;
38
+ const messages = (0, import_queue_clone.cloneQueuedMessages)(this.queue);
39
+ this.queue = [];
40
+ return messages;
41
+ }
42
+ async remove(input) {
43
+ void input.sessionId;
44
+ const previousLength = this.queue.length;
45
+ this.queue = this.queue.filter((message) => message.id !== input.id);
46
+ return this.queue.length !== previousLength;
47
+ }
48
+ async clear(input) {
49
+ void input.sessionId;
50
+ this.queue = [];
38
51
  }
39
52
  }
40
53
  function generateId() {
@@ -48,7 +61,7 @@ class MessageQueueService {
48
61
  this.store = store;
49
62
  this.queueKind = queueKind;
50
63
  }
51
- queue = [];
64
+ queueSnapshot = [];
52
65
  mutationLock = Promise.resolve();
53
66
  initialized = false;
54
67
  initializationPromise = null;
@@ -66,10 +79,10 @@ class MessageQueueService {
66
79
  if (this.initialized) {
67
80
  return;
68
81
  }
69
- this.queue = await this.store.load({ sessionId: this.sessionId });
70
- if (this.queue.length > 0) {
82
+ this.queueSnapshot = await this.store.list({ sessionId: this.sessionId });
83
+ if (this.queueSnapshot.length > 0) {
71
84
  this.logger.debug(
72
- `Restored ${this.queue.length} queued message(s) for session ${this.sessionId}`
85
+ `Restored ${this.queueSnapshot.length} queued message(s) for session ${this.sessionId}`
73
86
  );
74
87
  }
75
88
  this.initialized = true;
@@ -79,22 +92,8 @@ class MessageQueueService {
79
92
  });
80
93
  await this.initializationPromise;
81
94
  }
82
- async persistQueue() {
83
- await this.store.save({ sessionId: this.sessionId, queue: this.queue });
84
- }
85
95
  async refreshFromStore() {
86
- const storedQueue = await this.store.load({ sessionId: this.sessionId });
87
- const existingIds = new Set(this.queue.map((message) => message.id));
88
- const externalMessages = storedQueue.filter((message) => !existingIds.has(message.id));
89
- if (externalMessages.length === 0) {
90
- return;
91
- }
92
- this.queue = [...this.queue, ...(0, import_queue_clone.cloneQueuedMessages)(externalMessages)].sort(
93
- (left, right) => left.queuedAt - right.queuedAt
94
- );
95
- this.logger.debug(
96
- `Loaded ${externalMessages.length} externally queued message(s) for session ${this.sessionId}`
97
- );
96
+ this.queueSnapshot = await this.store.list({ sessionId: this.sessionId });
98
97
  }
99
98
  runWithMutationLock(fn) {
100
99
  const currentResult = this.mutationLock.catch(() => {
@@ -124,22 +123,20 @@ class MessageQueueService {
124
123
  ...message.kind !== void 0 && { kind: message.kind }
125
124
  };
126
125
  const copiedQueuedMsg = (0, import_queue_clone.cloneQueuedMessage)(queuedMsg);
127
- this.queue.push(copiedQueuedMsg);
128
- try {
129
- await this.persistQueue();
130
- } catch (error) {
131
- this.queue.pop();
132
- throw error;
133
- }
134
- this.logger.debug(`Message queued: ${queuedMsg.id}, position: ${this.queue.length}`);
126
+ const { position } = await this.store.append({
127
+ sessionId: this.sessionId,
128
+ message: copiedQueuedMsg
129
+ });
130
+ await this.refreshFromStore();
131
+ this.logger.debug(`Message queued: ${queuedMsg.id}, position: ${position}`);
135
132
  this.eventBus.emit("message:queued", {
136
- position: this.queue.length,
133
+ position,
137
134
  id: queuedMsg.id,
138
135
  queue: this.queueKind
139
136
  });
140
137
  return {
141
138
  queued: true,
142
- position: this.queue.length,
139
+ position,
143
140
  id: queuedMsg.id
144
141
  };
145
142
  });
@@ -167,16 +164,9 @@ class MessageQueueService {
167
164
  */
168
165
  async dequeueAll() {
169
166
  return await this.runWithMutationLock(async () => {
170
- await this.refreshFromStore();
171
- if (this.queue.length === 0) return null;
172
- const messages = (0, import_queue_clone.cloneQueuedMessages)(this.queue);
173
- this.queue = [];
174
- try {
175
- await this.persistQueue();
176
- } catch (error) {
177
- this.queue = messages;
178
- throw error;
179
- }
167
+ const messages = await this.store.takeAll({ sessionId: this.sessionId });
168
+ this.queueSnapshot = [];
169
+ if (messages.length === 0) return null;
180
170
  const combined = this.coalesce(messages);
181
171
  this.logger.debug(
182
172
  `Dequeued ${messages.length} message(s): ${messages.map((m) => m.id).join(", ")}`
@@ -272,7 +262,7 @@ ${prefixText}`;
272
262
  * Check if there are pending messages in the queue.
273
263
  */
274
264
  hasPending() {
275
- return this.queue.length > 0;
265
+ return this.queueSnapshot.length > 0;
276
266
  }
277
267
  async refresh() {
278
268
  await this.runWithMutationLock(async () => {
@@ -283,7 +273,7 @@ ${prefixText}`;
283
273
  * Get the number of pending messages.
284
274
  */
285
275
  pendingCount() {
286
- return this.queue.length;
276
+ return this.queueSnapshot.length;
287
277
  }
288
278
  /**
289
279
  * Clear all pending messages without processing.
@@ -291,17 +281,8 @@ ${prefixText}`;
291
281
  */
292
282
  async clear() {
293
283
  await this.runWithMutationLock(async () => {
294
- if (this.queue.length === 0) {
295
- return;
296
- }
297
- const previousQueue = [...this.queue];
298
- this.queue = [];
299
- try {
300
- await this.persistQueue();
301
- } catch (error) {
302
- this.queue = previousQueue;
303
- throw error;
304
- }
284
+ await this.store.clear({ sessionId: this.sessionId });
285
+ this.queueSnapshot = [];
305
286
  });
306
287
  }
307
288
  /**
@@ -309,13 +290,13 @@ ${prefixText}`;
309
290
  * Returns defensive copies to prevent external mutation.
310
291
  */
311
292
  getAll() {
312
- return (0, import_queue_clone.cloneQueuedMessages)(this.queue);
293
+ return (0, import_queue_clone.cloneQueuedMessages)(this.queueSnapshot);
313
294
  }
314
295
  /**
315
296
  * Get a single queued message by ID.
316
297
  */
317
298
  get(id) {
318
- const message = this.queue.find((m) => m.id === id);
299
+ const message = this.queueSnapshot.find((m) => m.id === id);
319
300
  return message ? (0, import_queue_clone.cloneQueuedMessage)(message) : void 0;
320
301
  }
321
302
  /**
@@ -324,21 +305,13 @@ ${prefixText}`;
324
305
  */
325
306
  async remove(id) {
326
307
  return await this.runWithMutationLock(async () => {
327
- const index = this.queue.findIndex((m) => m.id === id);
328
- if (index === -1) {
308
+ const removed = await this.store.remove({ sessionId: this.sessionId, id });
309
+ if (!removed) {
329
310
  this.logger.debug(`Remove failed: message ${id} not found in queue`);
330
311
  return false;
331
312
  }
332
- const [removed] = this.queue.splice(index, 1);
333
- try {
334
- await this.persistQueue();
335
- } catch (error) {
336
- if (removed) {
337
- this.queue.splice(index, 0, removed);
338
- }
339
- throw error;
340
- }
341
- this.logger.debug(`Message removed: ${id}, remaining: ${this.queue.length}`);
313
+ await this.refreshFromStore();
314
+ this.logger.debug(`Message removed: ${id}, remaining: ${this.queueSnapshot.length}`);
342
315
  this.eventBus.emit("message:removed", { id, queue: this.queueKind });
343
316
  return true;
344
317
  });
@@ -51,14 +51,13 @@ export declare class MessageQueueService {
51
51
  private sessionId;
52
52
  private store;
53
53
  private queueKind;
54
- private queue;
54
+ private queueSnapshot;
55
55
  private mutationLock;
56
56
  private initialized;
57
57
  private initializationPromise;
58
58
  static createEphemeral(eventBus: SessionEventBus, logger: Logger, sessionId: string, queueKind?: 'steer' | 'follow-up'): MessageQueueService;
59
59
  constructor(eventBus: SessionEventBus, logger: Logger, sessionId: string, store: MessageQueueBackingStore, queueKind?: 'steer' | 'follow-up');
60
60
  initialize(): Promise<void>;
61
- private persistQueue;
62
61
  private refreshFromStore;
63
62
  private runWithMutationLock;
64
63
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"message-queue.d.ts","sourceRoot":"","sources":["../../src/session/message-queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAElF,KAAK,wBAAwB,GAAG,wBAAwB,CAAC;AA4BzD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC7B,2DAA2D;IAC3D,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,sCAAsC;IACtC,IAAI,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,mBAAmB;IAsBxB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,SAAS;IAzBrB,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,YAAY,CAAoC;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AsBnB,gBAAgB;IAI9B,OAAO,CAAC,mBAAmB;IAS3B;;;;;;OAMG;IACG,OAAO,CACT,OAAO,EAAE,gBAAgB,GAC1B,OAAO,CAAC;QAAE,MAAM,EAAE,IAAI,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAmC1D;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,UAAU,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAyBpD;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAoFhB;;OAEG;IACH,UAAU,IAAI,OAAO;IAIf,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAM9B;;OAEG;IACH,YAAY,IAAI,MAAM;IAItB;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAO5B;;;OAGG;IACH,MAAM,IAAI,aAAa,EAAE;IAIzB;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAK1C;;;OAGG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAe7C"}
@@ -1,18 +1,31 @@
1
1
  import "../chunk-C6A6W6XS.js";
2
2
  import { cloneCoalescedMessage, cloneQueuedMessage, cloneQueuedMessages } from "./queue-clone.js";
3
3
  class EphemeralMessageQueueStore {
4
- async listSessionIds() {
5
- return [];
6
- }
7
- async load(input) {
4
+ queue = [];
5
+ async list(input) {
8
6
  void input;
9
- return [];
7
+ return cloneQueuedMessages(this.queue);
10
8
  }
11
- async save(input) {
12
- void input;
9
+ async append(input) {
10
+ void input.sessionId;
11
+ this.queue = [...this.queue, cloneQueuedMessage(input.message)];
12
+ return { position: this.queue.length };
13
13
  }
14
- async delete(input) {
15
- void input;
14
+ async takeAll(input) {
15
+ void input.sessionId;
16
+ const messages = cloneQueuedMessages(this.queue);
17
+ this.queue = [];
18
+ return messages;
19
+ }
20
+ async remove(input) {
21
+ void input.sessionId;
22
+ const previousLength = this.queue.length;
23
+ this.queue = this.queue.filter((message) => message.id !== input.id);
24
+ return this.queue.length !== previousLength;
25
+ }
26
+ async clear(input) {
27
+ void input.sessionId;
28
+ this.queue = [];
16
29
  }
17
30
  }
18
31
  function generateId() {
@@ -26,7 +39,7 @@ class MessageQueueService {
26
39
  this.store = store;
27
40
  this.queueKind = queueKind;
28
41
  }
29
- queue = [];
42
+ queueSnapshot = [];
30
43
  mutationLock = Promise.resolve();
31
44
  initialized = false;
32
45
  initializationPromise = null;
@@ -44,10 +57,10 @@ class MessageQueueService {
44
57
  if (this.initialized) {
45
58
  return;
46
59
  }
47
- this.queue = await this.store.load({ sessionId: this.sessionId });
48
- if (this.queue.length > 0) {
60
+ this.queueSnapshot = await this.store.list({ sessionId: this.sessionId });
61
+ if (this.queueSnapshot.length > 0) {
49
62
  this.logger.debug(
50
- `Restored ${this.queue.length} queued message(s) for session ${this.sessionId}`
63
+ `Restored ${this.queueSnapshot.length} queued message(s) for session ${this.sessionId}`
51
64
  );
52
65
  }
53
66
  this.initialized = true;
@@ -57,22 +70,8 @@ class MessageQueueService {
57
70
  });
58
71
  await this.initializationPromise;
59
72
  }
60
- async persistQueue() {
61
- await this.store.save({ sessionId: this.sessionId, queue: this.queue });
62
- }
63
73
  async refreshFromStore() {
64
- const storedQueue = await this.store.load({ sessionId: this.sessionId });
65
- const existingIds = new Set(this.queue.map((message) => message.id));
66
- const externalMessages = storedQueue.filter((message) => !existingIds.has(message.id));
67
- if (externalMessages.length === 0) {
68
- return;
69
- }
70
- this.queue = [...this.queue, ...cloneQueuedMessages(externalMessages)].sort(
71
- (left, right) => left.queuedAt - right.queuedAt
72
- );
73
- this.logger.debug(
74
- `Loaded ${externalMessages.length} externally queued message(s) for session ${this.sessionId}`
75
- );
74
+ this.queueSnapshot = await this.store.list({ sessionId: this.sessionId });
76
75
  }
77
76
  runWithMutationLock(fn) {
78
77
  const currentResult = this.mutationLock.catch(() => {
@@ -102,22 +101,20 @@ class MessageQueueService {
102
101
  ...message.kind !== void 0 && { kind: message.kind }
103
102
  };
104
103
  const copiedQueuedMsg = cloneQueuedMessage(queuedMsg);
105
- this.queue.push(copiedQueuedMsg);
106
- try {
107
- await this.persistQueue();
108
- } catch (error) {
109
- this.queue.pop();
110
- throw error;
111
- }
112
- this.logger.debug(`Message queued: ${queuedMsg.id}, position: ${this.queue.length}`);
104
+ const { position } = await this.store.append({
105
+ sessionId: this.sessionId,
106
+ message: copiedQueuedMsg
107
+ });
108
+ await this.refreshFromStore();
109
+ this.logger.debug(`Message queued: ${queuedMsg.id}, position: ${position}`);
113
110
  this.eventBus.emit("message:queued", {
114
- position: this.queue.length,
111
+ position,
115
112
  id: queuedMsg.id,
116
113
  queue: this.queueKind
117
114
  });
118
115
  return {
119
116
  queued: true,
120
- position: this.queue.length,
117
+ position,
121
118
  id: queuedMsg.id
122
119
  };
123
120
  });
@@ -145,16 +142,9 @@ class MessageQueueService {
145
142
  */
146
143
  async dequeueAll() {
147
144
  return await this.runWithMutationLock(async () => {
148
- await this.refreshFromStore();
149
- if (this.queue.length === 0) return null;
150
- const messages = cloneQueuedMessages(this.queue);
151
- this.queue = [];
152
- try {
153
- await this.persistQueue();
154
- } catch (error) {
155
- this.queue = messages;
156
- throw error;
157
- }
145
+ const messages = await this.store.takeAll({ sessionId: this.sessionId });
146
+ this.queueSnapshot = [];
147
+ if (messages.length === 0) return null;
158
148
  const combined = this.coalesce(messages);
159
149
  this.logger.debug(
160
150
  `Dequeued ${messages.length} message(s): ${messages.map((m) => m.id).join(", ")}`
@@ -250,7 +240,7 @@ ${prefixText}`;
250
240
  * Check if there are pending messages in the queue.
251
241
  */
252
242
  hasPending() {
253
- return this.queue.length > 0;
243
+ return this.queueSnapshot.length > 0;
254
244
  }
255
245
  async refresh() {
256
246
  await this.runWithMutationLock(async () => {
@@ -261,7 +251,7 @@ ${prefixText}`;
261
251
  * Get the number of pending messages.
262
252
  */
263
253
  pendingCount() {
264
- return this.queue.length;
254
+ return this.queueSnapshot.length;
265
255
  }
266
256
  /**
267
257
  * Clear all pending messages without processing.
@@ -269,17 +259,8 @@ ${prefixText}`;
269
259
  */
270
260
  async clear() {
271
261
  await this.runWithMutationLock(async () => {
272
- if (this.queue.length === 0) {
273
- return;
274
- }
275
- const previousQueue = [...this.queue];
276
- this.queue = [];
277
- try {
278
- await this.persistQueue();
279
- } catch (error) {
280
- this.queue = previousQueue;
281
- throw error;
282
- }
262
+ await this.store.clear({ sessionId: this.sessionId });
263
+ this.queueSnapshot = [];
283
264
  });
284
265
  }
285
266
  /**
@@ -287,13 +268,13 @@ ${prefixText}`;
287
268
  * Returns defensive copies to prevent external mutation.
288
269
  */
289
270
  getAll() {
290
- return cloneQueuedMessages(this.queue);
271
+ return cloneQueuedMessages(this.queueSnapshot);
291
272
  }
292
273
  /**
293
274
  * Get a single queued message by ID.
294
275
  */
295
276
  get(id) {
296
- const message = this.queue.find((m) => m.id === id);
277
+ const message = this.queueSnapshot.find((m) => m.id === id);
297
278
  return message ? cloneQueuedMessage(message) : void 0;
298
279
  }
299
280
  /**
@@ -302,21 +283,13 @@ ${prefixText}`;
302
283
  */
303
284
  async remove(id) {
304
285
  return await this.runWithMutationLock(async () => {
305
- const index = this.queue.findIndex((m) => m.id === id);
306
- if (index === -1) {
286
+ const removed = await this.store.remove({ sessionId: this.sessionId, id });
287
+ if (!removed) {
307
288
  this.logger.debug(`Remove failed: message ${id} not found in queue`);
308
289
  return false;
309
290
  }
310
- const [removed] = this.queue.splice(index, 1);
311
- try {
312
- await this.persistQueue();
313
- } catch (error) {
314
- if (removed) {
315
- this.queue.splice(index, 0, removed);
316
- }
317
- throw error;
318
- }
319
- this.logger.debug(`Message removed: ${id}, remaining: ${this.queue.length}`);
291
+ await this.refreshFromStore();
292
+ this.logger.debug(`Message removed: ${id}, remaining: ${this.queueSnapshot.length}`);
320
293
  this.eventBus.emit("message:removed", { id, queue: this.queueKind });
321
294
  return true;
322
295
  });
@@ -49,6 +49,7 @@ class SessionManager {
49
49
  this.sessionLoggerFactory = config.sessionLoggerFactory ?? defaultSessionLoggerFactory;
50
50
  this.languageModelFactory = config.languageModelFactory;
51
51
  this.authResolver = config.authResolver ?? null;
52
+ this.executionControl = config.executionControl;
52
53
  this.logger = logger.createChild(import_types.DextoLogComponent.SESSION);
53
54
  }
54
55
  sessions = /* @__PURE__ */ new Map();
@@ -68,6 +69,7 @@ class SessionManager {
68
69
  sessionLoggerFactory;
69
70
  languageModelFactory;
70
71
  authResolver;
72
+ executionControl;
71
73
  getChatSessionServices() {
72
74
  return {
73
75
  ...this.services,
@@ -75,7 +77,10 @@ class SessionManager {
75
77
  ...this.languageModelFactory !== void 0 && {
76
78
  languageModelFactory: this.languageModelFactory
77
79
  },
78
- authResolver: this.authResolver
80
+ authResolver: this.authResolver,
81
+ ...this.executionControl !== void 0 && {
82
+ executionControl: this.executionControl
83
+ }
79
84
  };
80
85
  }
81
86
  /**
@@ -86,7 +91,6 @@ class SessionManager {
86
91
  if (this.initialized) {
87
92
  return;
88
93
  }
89
- await this.clearPersistedQueuedMessages("startup");
90
94
  await this.restoreSessionsFromStorage();
91
95
  const cleanupIntervalMs = Math.min(this.sessionTTL / 4, 15 * 60 * 1e3);
92
96
  this.cleanupInterval = setInterval(
@@ -130,32 +134,6 @@ class SessionManager {
130
134
  );
131
135
  }
132
136
  }
133
- async clearPersistedQueuedMessages(reason) {
134
- try {
135
- const steerSessionIds = await this.services.steerQueueStore.listSessionIds();
136
- const followUpSessionIds = await this.services.followUpQueueStore.listSessionIds();
137
- const sessionIds = Array.from(/* @__PURE__ */ new Set([...steerSessionIds, ...followUpSessionIds]));
138
- if (sessionIds.length === 0) {
139
- return;
140
- }
141
- await Promise.all(
142
- sessionIds.flatMap((sessionId) => [
143
- this.services.steerQueueStore.delete({ sessionId }),
144
- this.services.followUpQueueStore.delete({ sessionId })
145
- ])
146
- );
147
- const message = `${reason === "startup" ? "Cleared stale pending input state from previous agent run" : "Cleared pending input state during agent shutdown"} (${sessionIds.length} session bucket(s))`;
148
- if (reason === "startup") {
149
- this.logger.info(message);
150
- } else {
151
- this.logger.debug(message);
152
- }
153
- } catch (error) {
154
- this.logger.warn(
155
- `Failed to clear persisted queued follow-up state during ${reason}: ${error instanceof Error ? error.message : String(error)}`
156
- );
157
- }
158
- }
159
137
  /**
160
138
  * Ensures the SessionManager is initialized before operations.
161
139
  */
@@ -481,6 +459,7 @@ class SessionManager {
481
459
  }
482
460
  await this.services.sessionStore.deleteSession({ sessionId });
483
461
  await this.deleteSessionInteractionState(sessionId);
462
+ await this.deleteSessionPendingInput(sessionId);
484
463
  await this.services.conversationStore.clearMessages({ sessionId });
485
464
  this.logger.debug(`Deleted session and conversation history: ${sessionId}`);
486
465
  }
@@ -918,9 +897,13 @@ class SessionManager {
918
897
  this.services.stateManager.clearSessionOverride(sessionId);
919
898
  await Promise.all([
920
899
  this.services.toolManager.deleteSessionState(sessionId),
921
- this.services.approvalManager.deleteSessionState(sessionId),
922
- this.services.steerQueueStore.delete({ sessionId }),
923
- this.services.followUpQueueStore.delete({ sessionId })
900
+ this.services.approvalManager.deleteSessionState(sessionId)
901
+ ]);
902
+ }
903
+ async deleteSessionPendingInput(sessionId) {
904
+ await Promise.all([
905
+ this.services.steerQueueStore.clear({ sessionId }),
906
+ this.services.followUpQueueStore.clear({ sessionId })
924
907
  ]);
925
908
  }
926
909
  evictSessionInteractionState(sessionId) {
@@ -989,7 +972,6 @@ class SessionManager {
989
972
  delete this.cleanupInterval;
990
973
  this.logger.debug("Periodic session cleanup stopped");
991
974
  }
992
- await this.clearPersistedQueuedMessages("shutdown");
993
975
  const sessionIds = Array.from(this.sessions.keys());
994
976
  for (const sessionId of sessionIds) {
995
977
  try {
@@ -8,7 +8,7 @@ import type { ValidatedLLMConfig } from '../llm/schemas.js';
8
8
  import type { HookManager } from '../hooks/manager.js';
9
9
  import type { ApprovalManager } from '../approval/manager.js';
10
10
  import type { TokenUsage } from '@dexto/llm';
11
- import type { LanguageModelFactory } from '../llm/services/types.js';
11
+ import type { LLMExecutionControl, LanguageModelFactory } from '../llm/services/types.js';
12
12
  import type { LlmAuthResolver } from '../llm/auth/index.js';
13
13
  import type { CompactionStrategy } from '../context/compaction/types.js';
14
14
  import { type SessionPromptContributor } from '../systemPrompt/schemas.js';
@@ -61,6 +61,8 @@ export interface SessionManagerConfig {
61
61
  languageModelFactory?: LanguageModelFactory;
62
62
  /** Host hook for resolving runtime provider auth from local/cloud profiles */
63
63
  authResolver?: LlmAuthResolver | null;
64
+ /** Host control for queue continuation behavior. CLI defaults preserve core-owned follow-ups. */
65
+ executionControl?: LLMExecutionControl | undefined;
64
66
  }
65
67
  type PersistedLLMConfig = Omit<ValidatedLLMConfig, 'apiKey'>;
66
68
  export interface SessionData {
@@ -112,6 +114,7 @@ export declare class SessionManager {
112
114
  private readonly sessionLoggerFactory;
113
115
  private readonly languageModelFactory;
114
116
  private readonly authResolver;
117
+ private readonly executionControl;
115
118
  constructor(services: {
116
119
  stateManager: AgentStateManager;
117
120
  systemPromptManager: SystemPromptManager;
@@ -139,7 +142,6 @@ export declare class SessionManager {
139
142
  * This allows sessions to survive application restarts.
140
143
  */
141
144
  private restoreSessionsFromStorage;
142
- private clearPersistedQueuedMessages;
143
145
  /**
144
146
  * Ensures the SessionManager is initialized before operations.
145
147
  */
@@ -297,6 +299,7 @@ export declare class SessionManager {
297
299
  private toPersistedLLMConfig;
298
300
  private setPersistedSessionLLMOverride;
299
301
  private deleteSessionInteractionState;
302
+ private deleteSessionPendingInput;
300
303
  private evictSessionInteractionState;
301
304
  private runWithSessionDataLock;
302
305
  private persistSessionData;