@dexto/core 1.8.11 → 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.
- package/dist/approval/manager.cjs +37 -325
- package/dist/approval/manager.d.ts +10 -109
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +37 -316
- package/dist/approval/schemas.cjs +8 -51
- package/dist/approval/schemas.d.ts +5 -179
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +8 -47
- package/dist/approval/types.cjs +0 -6
- package/dist/approval/types.d.ts +2 -27
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/approval/types.js +0 -6
- package/dist/context/content-clone.cjs +12 -8
- package/dist/context/content-clone.d.ts.map +1 -1
- package/dist/context/content-clone.js +12 -8
- package/dist/errors/DextoRuntimeError.cjs +3 -1
- package/dist/errors/DextoRuntimeError.d.ts +5 -3
- package/dist/errors/DextoRuntimeError.d.ts.map +1 -1
- package/dist/errors/DextoRuntimeError.js +3 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/types.d.ts +1 -0
- package/dist/errors/types.d.ts.map +1 -1
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.d.ts.map +1 -1
- package/dist/llm/executor/provider-error.cjs +25 -4
- package/dist/llm/executor/provider-error.d.ts.map +1 -1
- package/dist/llm/executor/provider-error.js +25 -4
- package/dist/llm/executor/stream-processor.cjs +61 -0
- package/dist/llm/executor/stream-processor.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.js +61 -0
- package/dist/llm/executor/turn-executor.cjs +93 -26
- package/dist/llm/executor/turn-executor.d.ts +2 -0
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +93 -26
- package/dist/llm/formatters/vercel.cjs +66 -0
- package/dist/llm/formatters/vercel.d.ts.map +1 -1
- package/dist/llm/formatters/vercel.js +66 -0
- package/dist/llm/services/factory.cjs +3 -2
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +3 -2
- package/dist/llm/services/types.d.ts +8 -0
- package/dist/llm/services/types.d.ts.map +1 -1
- package/dist/llm/services/vercel.cjs +6 -1
- package/dist/llm/services/vercel.d.ts +3 -2
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +6 -1
- package/dist/session/chat-session.cjs +3 -0
- package/dist/session/chat-session.d.ts +2 -1
- package/dist/session/chat-session.d.ts.map +1 -1
- package/dist/session/chat-session.js +3 -0
- package/dist/session/message-queue.cjs +48 -75
- package/dist/session/message-queue.d.ts +1 -2
- package/dist/session/message-queue.d.ts.map +1 -1
- package/dist/session/message-queue.js +48 -75
- package/dist/session/session-manager.cjs +14 -32
- package/dist/session/session-manager.d.ts +5 -2
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +14 -32
- package/dist/storage/approvals/types.cjs +2 -9
- package/dist/storage/approvals/types.d.ts +4 -16
- package/dist/storage/approvals/types.d.ts.map +1 -1
- package/dist/storage/approvals/types.js +2 -8
- package/dist/storage/database/types.d.ts +5 -0
- package/dist/storage/database/types.d.ts.map +1 -1
- package/dist/storage/index.cjs +0 -2
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +1 -2
- package/dist/storage/message-queue/types.d.ts +14 -6
- package/dist/storage/message-queue/types.d.ts.map +1 -1
- package/dist/storage/stores/backend.cjs +68 -32
- package/dist/storage/stores/backend.d.ts +17 -8
- package/dist/storage/stores/backend.d.ts.map +1 -1
- package/dist/storage/stores/backend.js +69 -33
- package/dist/storage/stores/in-memory.cjs +26 -11
- package/dist/storage/stores/in-memory.d.ts.map +1 -1
- package/dist/storage/stores/in-memory.js +27 -12
- package/dist/test-utils/in-memory-storage.cjs +11 -0
- package/dist/test-utils/in-memory-storage.js +11 -0
- package/dist/test-utils/session-state-stores.cjs +25 -9
- package/dist/test-utils/session-state-stores.js +26 -10
- package/dist/tools/approval/tool-approval-policy.cjs +87 -0
- package/dist/tools/approval/tool-approval-policy.d.ts +34 -0
- package/dist/tools/approval/tool-approval-policy.d.ts.map +1 -0
- package/dist/tools/approval/tool-approval-policy.js +64 -0
- package/dist/tools/error-codes.cjs +0 -1
- package/dist/tools/error-codes.d.ts +0 -1
- package/dist/tools/error-codes.d.ts.map +1 -1
- package/dist/tools/error-codes.js +0 -1
- package/dist/tools/errors.cjs +0 -15
- package/dist/tools/errors.d.ts +0 -9
- package/dist/tools/errors.d.ts.map +1 -1
- package/dist/tools/errors.js +0 -15
- package/dist/tools/index.cjs +2 -0
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +5 -1
- package/dist/tools/tool-manager.cjs +94 -312
- package/dist/tools/tool-manager.d.ts +4 -19
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +95 -316
- package/dist/tools/types.d.ts +10 -9
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/service-initializer.cjs +3 -0
- package/dist/utils/service-initializer.d.ts +2 -1
- package/dist/utils/service-initializer.d.ts.map +1 -1
- package/dist/utils/service-initializer.js +3 -0
- package/package.json +2 -2
- package/dist/tools/pattern-utils.cjs +0 -33
- package/dist/tools/pattern-utils.d.ts +0 -20
- package/dist/tools/pattern-utils.d.ts.map +0 -1
- package/dist/tools/pattern-utils.js +0 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../../src/storage/stores/backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAE5F,OAAO,KAAK,EAAE,WAAW,EAAE,M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B,WAAW,IAAI,OAAO,CAAC;CAC1B;AAUD,qBAAa,kBAAmB,YAAW,WAAW;IAI9C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAL9B,OAAO,CAAC,SAAS,CAAS;gBAGL,MAAM,EAAE,aAAa,EACrB,SAAS,GAAE,oBAAqC,EAChD,SAAS,SAAY;IAG1C,QAAQ,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;IAIvD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IASxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IASjC,WAAW,IAAI,OAAO;IAItB,YAAY,IAAI,MAAM;CAGzB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../../chunk-C6A6W6XS.js";
|
|
2
2
|
import { ApprovalRequestSchema, ApprovalResponseSchema } from "../../approval/schemas.js";
|
|
3
|
-
import { cloneQueuedMessages } from "../../session/queue-clone.js";
|
|
3
|
+
import { cloneQueuedMessage, cloneQueuedMessages } from "../../session/queue-clone.js";
|
|
4
4
|
import { QueuedMessagesSchema } from "../../session/types.js";
|
|
5
5
|
import {
|
|
6
6
|
SessionToolPreferencesSchema
|
|
@@ -21,6 +21,7 @@ const MEMORY_KEY_PREFIX = "memory:item:";
|
|
|
21
21
|
const CUSTOM_PROMPT_KEY_PREFIX = "prompt:custom:";
|
|
22
22
|
const RUNTIME_EVENTS_KEY = "runtime-events";
|
|
23
23
|
const RUNTIME_EVENTS_LIMIT = 1e4;
|
|
24
|
+
const SESSION_MESSAGE_QUEUE_READ_LIMIT = 1e4;
|
|
24
25
|
const TOOL_EXECUTION_KEY_PREFIX = "tool-execution:";
|
|
25
26
|
const TOOL_STATE_KEY_PREFIX = "tool-state:";
|
|
26
27
|
const WORKSPACE_KEY_PREFIX = "workspace:item:";
|
|
@@ -28,8 +29,7 @@ const WORKSPACE_CURRENT_KEY = "workspace:current";
|
|
|
28
29
|
const SESSION_STEER_QUEUE_KEY_PREFIX = "session-steer-queue";
|
|
29
30
|
const SESSION_FOLLOW_UP_QUEUE_KEY_PREFIX = "session-follow-up-queue";
|
|
30
31
|
const DEFAULT_APPROVAL_STATE = {
|
|
31
|
-
|
|
32
|
-
approvedDirectories: []
|
|
32
|
+
approvedKeys: {}
|
|
33
33
|
};
|
|
34
34
|
const DEFAULT_TOOL_PREFERENCES = {
|
|
35
35
|
userAutoApproveTools: [],
|
|
@@ -407,51 +407,87 @@ class DatabaseBackedToolPreferenceStore {
|
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
409
|
class DatabaseBackedSessionMessageQueueStore {
|
|
410
|
-
constructor(database,
|
|
410
|
+
constructor(database, logger, keyPrefix) {
|
|
411
411
|
this.database = database;
|
|
412
|
-
this.cache = cache;
|
|
413
412
|
this.logger = logger;
|
|
414
413
|
this.keyPrefix = keyPrefix;
|
|
415
414
|
}
|
|
416
|
-
async
|
|
417
|
-
|
|
418
|
-
const keys = await this.database.list(prefix);
|
|
419
|
-
return keys.map((key) => key.replace(prefix, ""));
|
|
415
|
+
async list(input) {
|
|
416
|
+
return await this.loadQueue(input.sessionId);
|
|
420
417
|
}
|
|
421
|
-
async
|
|
418
|
+
async append(input) {
|
|
422
419
|
const key = this.key(input.sessionId);
|
|
423
|
-
const
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
420
|
+
const result = await this.database.updateList(
|
|
421
|
+
key,
|
|
422
|
+
(stored) => {
|
|
423
|
+
const queue = this.parseQueue(key, stored);
|
|
424
|
+
const nextQueue = [...queue, cloneQueuedMessage(input.message)];
|
|
425
|
+
return {
|
|
426
|
+
items: nextQueue,
|
|
427
|
+
result: {
|
|
428
|
+
position: nextQueue.length
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
);
|
|
433
|
+
return result;
|
|
434
|
+
}
|
|
435
|
+
async takeAll(input) {
|
|
436
|
+
const key = this.key(input.sessionId);
|
|
437
|
+
const queue = await this.database.updateList(key, (stored) => ({
|
|
438
|
+
items: [],
|
|
439
|
+
result: this.parseQueue(key, stored)
|
|
440
|
+
}));
|
|
441
|
+
return queue;
|
|
442
|
+
}
|
|
443
|
+
async remove(input) {
|
|
444
|
+
const key = this.key(input.sessionId);
|
|
445
|
+
const removed = await this.database.updateList(key, (stored) => {
|
|
446
|
+
const queue = this.parseQueue(key, stored);
|
|
447
|
+
const updatedQueue = queue.filter((message) => message.id !== input.id);
|
|
448
|
+
return {
|
|
449
|
+
items: updatedQueue,
|
|
450
|
+
result: updatedQueue.length !== queue.length
|
|
451
|
+
};
|
|
452
|
+
});
|
|
453
|
+
return removed;
|
|
454
|
+
}
|
|
455
|
+
async clear(input) {
|
|
456
|
+
const key = this.key(input.sessionId);
|
|
457
|
+
await this.database.updateList(key, () => ({
|
|
458
|
+
items: [],
|
|
459
|
+
result: void 0
|
|
460
|
+
}));
|
|
461
|
+
}
|
|
462
|
+
async loadQueue(sessionId) {
|
|
463
|
+
const key = this.key(sessionId);
|
|
464
|
+
const stored = [];
|
|
465
|
+
let offset = 0;
|
|
466
|
+
while (true) {
|
|
467
|
+
const page = await this.database.getRange(
|
|
468
|
+
key,
|
|
469
|
+
offset,
|
|
470
|
+
SESSION_MESSAGE_QUEUE_READ_LIMIT
|
|
471
|
+
);
|
|
472
|
+
stored.push(...page);
|
|
473
|
+
if (page.length < SESSION_MESSAGE_QUEUE_READ_LIMIT) {
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
offset += SESSION_MESSAGE_QUEUE_READ_LIMIT;
|
|
427
477
|
}
|
|
428
|
-
|
|
478
|
+
return this.parseQueue(key, stored);
|
|
479
|
+
}
|
|
480
|
+
parseQueue(key, stored) {
|
|
429
481
|
const storedQueue = QueuedMessagesSchema.safeParse(stored);
|
|
430
482
|
if (!storedQueue.success) {
|
|
431
|
-
if (stored
|
|
483
|
+
if (stored.length > 0) {
|
|
432
484
|
this.logger.warn("Invalid persisted message queue encountered; ignoring state", {
|
|
433
485
|
key
|
|
434
486
|
});
|
|
435
487
|
}
|
|
436
488
|
return [];
|
|
437
489
|
}
|
|
438
|
-
|
|
439
|
-
await this.cache.set(key, queue, 3600);
|
|
440
|
-
return cloneQueuedMessages(queue);
|
|
441
|
-
}
|
|
442
|
-
async save(input) {
|
|
443
|
-
const key = this.key(input.sessionId);
|
|
444
|
-
if (input.queue.length === 0) {
|
|
445
|
-
await this.delete({ sessionId: input.sessionId });
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
const queue = cloneQueuedMessages(input.queue);
|
|
449
|
-
await this.database.set(key, queue);
|
|
450
|
-
await this.cache.set(key, queue, 3600);
|
|
451
|
-
}
|
|
452
|
-
async delete(input) {
|
|
453
|
-
const key = this.key(input.sessionId);
|
|
454
|
-
await Promise.all([this.database.delete(key), this.cache.delete(key)]);
|
|
490
|
+
return cloneQueuedMessages(storedQueue.data);
|
|
455
491
|
}
|
|
456
492
|
key(sessionId) {
|
|
457
493
|
return `${this.keyPrefix}:${sessionId}`;
|
|
@@ -28,8 +28,7 @@ var import_types = require("../tool-executions/types.js");
|
|
|
28
28
|
var import_errors = require("../errors.js");
|
|
29
29
|
const GLOBAL_SCOPE = "global";
|
|
30
30
|
const DEFAULT_APPROVAL_STATE = {
|
|
31
|
-
|
|
32
|
-
approvedDirectories: []
|
|
31
|
+
approvedKeys: {}
|
|
33
32
|
};
|
|
34
33
|
const DEFAULT_TOOL_PREFERENCES = {
|
|
35
34
|
userAutoApproveTools: [],
|
|
@@ -227,20 +226,36 @@ class InMemoryToolPreferenceStore {
|
|
|
227
226
|
}
|
|
228
227
|
class InMemorySessionMessageQueueStore {
|
|
229
228
|
queues = /* @__PURE__ */ new Map();
|
|
230
|
-
async
|
|
231
|
-
return Array.from(this.queues.keys());
|
|
232
|
-
}
|
|
233
|
-
async load(input) {
|
|
229
|
+
async list(input) {
|
|
234
230
|
return (0, import_queue_clone.cloneQueuedMessages)(this.queues.get(input.sessionId) ?? []);
|
|
235
231
|
}
|
|
236
|
-
async
|
|
237
|
-
|
|
232
|
+
async append(input) {
|
|
233
|
+
const queue = [
|
|
234
|
+
...this.queues.get(input.sessionId) ?? [],
|
|
235
|
+
(0, import_queue_clone.cloneQueuedMessage)(input.message)
|
|
236
|
+
];
|
|
237
|
+
this.queues.set(input.sessionId, queue);
|
|
238
|
+
return { position: queue.length };
|
|
239
|
+
}
|
|
240
|
+
async takeAll(input) {
|
|
241
|
+
const queue = (0, import_queue_clone.cloneQueuedMessages)(this.queues.get(input.sessionId) ?? []);
|
|
242
|
+
this.queues.delete(input.sessionId);
|
|
243
|
+
return queue;
|
|
244
|
+
}
|
|
245
|
+
async remove(input) {
|
|
246
|
+
const queue = this.queues.get(input.sessionId) ?? [];
|
|
247
|
+
const updatedQueue = queue.filter((message) => message.id !== input.id);
|
|
248
|
+
if (updatedQueue.length === queue.length) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
if (updatedQueue.length === 0) {
|
|
238
252
|
this.queues.delete(input.sessionId);
|
|
239
|
-
|
|
253
|
+
} else {
|
|
254
|
+
this.queues.set(input.sessionId, updatedQueue);
|
|
240
255
|
}
|
|
241
|
-
|
|
256
|
+
return true;
|
|
242
257
|
}
|
|
243
|
-
async
|
|
258
|
+
async clear(input) {
|
|
244
259
|
this.queues.delete(input.sessionId);
|
|
245
260
|
}
|
|
246
261
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory.d.ts","sourceRoot":"","sources":["../../../src/storage/stores/in-memory.ts"],"names":[],"mappings":"AA0CA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"in-memory.d.ts","sourceRoot":"","sources":["../../../src/storage/stores/in-memory.ts"],"names":[],"mappings":"AA0CA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA2lB7E,qBAAa,mBAAoB,YAAW,WAAW;IACnD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAcrB;IAEF,QAAQ,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;IAIvD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC,WAAW,IAAI,OAAO;IAItB,YAAY,IAAI,MAAM;CAGzB"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import "../../chunk-C6A6W6XS.js";
|
|
2
2
|
import { createHash, randomUUID } from "crypto";
|
|
3
3
|
import { cloneInternalMessage, cloneInternalMessages } from "../../context/content-clone.js";
|
|
4
|
-
import { cloneQueuedMessages } from "../../session/queue-clone.js";
|
|
4
|
+
import { cloneQueuedMessage, cloneQueuedMessages } from "../../session/queue-clone.js";
|
|
5
5
|
import { splitToolExecutionResult } from "../tool-executions/types.js";
|
|
6
6
|
import { StorageError } from "../errors.js";
|
|
7
7
|
const GLOBAL_SCOPE = "global";
|
|
8
8
|
const DEFAULT_APPROVAL_STATE = {
|
|
9
|
-
|
|
10
|
-
approvedDirectories: []
|
|
9
|
+
approvedKeys: {}
|
|
11
10
|
};
|
|
12
11
|
const DEFAULT_TOOL_PREFERENCES = {
|
|
13
12
|
userAutoApproveTools: [],
|
|
@@ -205,20 +204,36 @@ class InMemoryToolPreferenceStore {
|
|
|
205
204
|
}
|
|
206
205
|
class InMemorySessionMessageQueueStore {
|
|
207
206
|
queues = /* @__PURE__ */ new Map();
|
|
208
|
-
async
|
|
209
|
-
return Array.from(this.queues.keys());
|
|
210
|
-
}
|
|
211
|
-
async load(input) {
|
|
207
|
+
async list(input) {
|
|
212
208
|
return cloneQueuedMessages(this.queues.get(input.sessionId) ?? []);
|
|
213
209
|
}
|
|
214
|
-
async
|
|
215
|
-
|
|
210
|
+
async append(input) {
|
|
211
|
+
const queue = [
|
|
212
|
+
...this.queues.get(input.sessionId) ?? [],
|
|
213
|
+
cloneQueuedMessage(input.message)
|
|
214
|
+
];
|
|
215
|
+
this.queues.set(input.sessionId, queue);
|
|
216
|
+
return { position: queue.length };
|
|
217
|
+
}
|
|
218
|
+
async takeAll(input) {
|
|
219
|
+
const queue = cloneQueuedMessages(this.queues.get(input.sessionId) ?? []);
|
|
220
|
+
this.queues.delete(input.sessionId);
|
|
221
|
+
return queue;
|
|
222
|
+
}
|
|
223
|
+
async remove(input) {
|
|
224
|
+
const queue = this.queues.get(input.sessionId) ?? [];
|
|
225
|
+
const updatedQueue = queue.filter((message) => message.id !== input.id);
|
|
226
|
+
if (updatedQueue.length === queue.length) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
if (updatedQueue.length === 0) {
|
|
216
230
|
this.queues.delete(input.sessionId);
|
|
217
|
-
|
|
231
|
+
} else {
|
|
232
|
+
this.queues.set(input.sessionId, updatedQueue);
|
|
218
233
|
}
|
|
219
|
-
|
|
234
|
+
return true;
|
|
220
235
|
}
|
|
221
|
-
async
|
|
236
|
+
async clear(input) {
|
|
222
237
|
this.queues.delete(input.sessionId);
|
|
223
238
|
}
|
|
224
239
|
}
|
|
@@ -111,6 +111,17 @@ class InMemoryDatabase {
|
|
|
111
111
|
const next = Array.isArray(existing) ? [...existing, item] : [item];
|
|
112
112
|
this.data.set(key, next);
|
|
113
113
|
}
|
|
114
|
+
async updateList(key, updater) {
|
|
115
|
+
const existing = this.data.get(key);
|
|
116
|
+
const current = Array.isArray(existing) ? existing : [];
|
|
117
|
+
const mutation = updater([...current]);
|
|
118
|
+
if (mutation.items.length === 0) {
|
|
119
|
+
this.data.delete(key);
|
|
120
|
+
} else {
|
|
121
|
+
this.data.set(key, [...mutation.items]);
|
|
122
|
+
}
|
|
123
|
+
return mutation.result;
|
|
124
|
+
}
|
|
114
125
|
async getRange(key, start, count) {
|
|
115
126
|
const existing = this.data.get(key);
|
|
116
127
|
if (!Array.isArray(existing)) return [];
|
|
@@ -77,6 +77,17 @@ class InMemoryDatabase {
|
|
|
77
77
|
const next = Array.isArray(existing) ? [...existing, item] : [item];
|
|
78
78
|
this.data.set(key, next);
|
|
79
79
|
}
|
|
80
|
+
async updateList(key, updater) {
|
|
81
|
+
const existing = this.data.get(key);
|
|
82
|
+
const current = Array.isArray(existing) ? existing : [];
|
|
83
|
+
const mutation = updater([...current]);
|
|
84
|
+
if (mutation.items.length === 0) {
|
|
85
|
+
this.data.delete(key);
|
|
86
|
+
} else {
|
|
87
|
+
this.data.set(key, [...mutation.items]);
|
|
88
|
+
}
|
|
89
|
+
return mutation.result;
|
|
90
|
+
}
|
|
80
91
|
async getRange(key, start, count) {
|
|
81
92
|
const existing = this.data.get(key);
|
|
82
93
|
if (!Array.isArray(existing)) return [];
|
|
@@ -39,21 +39,37 @@ function createInMemorySessionToolPreferencesStore(logger) {
|
|
|
39
39
|
function createInMemoryMessageQueueStore() {
|
|
40
40
|
const queues = /* @__PURE__ */ new Map();
|
|
41
41
|
return {
|
|
42
|
-
async
|
|
42
|
+
async list(input) {
|
|
43
43
|
return (0, import_queue_clone.cloneQueuedMessages)(queues.get(input.sessionId) ?? []);
|
|
44
44
|
},
|
|
45
|
-
async
|
|
46
|
-
|
|
45
|
+
async append(input) {
|
|
46
|
+
const queue = [
|
|
47
|
+
...queues.get(input.sessionId) ?? [],
|
|
48
|
+
(0, import_queue_clone.cloneQueuedMessage)(input.message)
|
|
49
|
+
];
|
|
50
|
+
queues.set(input.sessionId, queue);
|
|
51
|
+
return { position: queue.length };
|
|
52
|
+
},
|
|
53
|
+
async takeAll(input) {
|
|
54
|
+
const queue = (0, import_queue_clone.cloneQueuedMessages)(queues.get(input.sessionId) ?? []);
|
|
55
|
+
queues.delete(input.sessionId);
|
|
56
|
+
return queue;
|
|
57
|
+
},
|
|
58
|
+
async remove(input) {
|
|
59
|
+
const queue = queues.get(input.sessionId) ?? [];
|
|
60
|
+
const updatedQueue = queue.filter((message) => message.id !== input.id);
|
|
61
|
+
if (updatedQueue.length === queue.length) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
if (updatedQueue.length === 0) {
|
|
47
65
|
queues.delete(input.sessionId);
|
|
48
|
-
|
|
66
|
+
} else {
|
|
67
|
+
queues.set(input.sessionId, updatedQueue);
|
|
49
68
|
}
|
|
50
|
-
|
|
69
|
+
return true;
|
|
51
70
|
},
|
|
52
|
-
async
|
|
71
|
+
async clear(input) {
|
|
53
72
|
queues.delete(input.sessionId);
|
|
54
|
-
},
|
|
55
|
-
async listSessionIds() {
|
|
56
|
-
return Array.from(queues.keys());
|
|
57
73
|
}
|
|
58
74
|
};
|
|
59
75
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../chunk-C6A6W6XS.js";
|
|
2
|
-
import { cloneQueuedMessages } from "../session/queue-clone.js";
|
|
2
|
+
import { cloneQueuedMessage, cloneQueuedMessages } from "../session/queue-clone.js";
|
|
3
3
|
import { InMemoryDextoStores } from "../storage/stores/in-memory.js";
|
|
4
4
|
import { SessionToolPreferencesStore } from "../tools/session-tool-preferences-store.js";
|
|
5
5
|
function createInMemorySessionApprovalStore(logger) {
|
|
@@ -15,21 +15,37 @@ function createInMemorySessionToolPreferencesStore(logger) {
|
|
|
15
15
|
function createInMemoryMessageQueueStore() {
|
|
16
16
|
const queues = /* @__PURE__ */ new Map();
|
|
17
17
|
return {
|
|
18
|
-
async
|
|
18
|
+
async list(input) {
|
|
19
19
|
return cloneQueuedMessages(queues.get(input.sessionId) ?? []);
|
|
20
20
|
},
|
|
21
|
-
async
|
|
22
|
-
|
|
21
|
+
async append(input) {
|
|
22
|
+
const queue = [
|
|
23
|
+
...queues.get(input.sessionId) ?? [],
|
|
24
|
+
cloneQueuedMessage(input.message)
|
|
25
|
+
];
|
|
26
|
+
queues.set(input.sessionId, queue);
|
|
27
|
+
return { position: queue.length };
|
|
28
|
+
},
|
|
29
|
+
async takeAll(input) {
|
|
30
|
+
const queue = cloneQueuedMessages(queues.get(input.sessionId) ?? []);
|
|
31
|
+
queues.delete(input.sessionId);
|
|
32
|
+
return queue;
|
|
33
|
+
},
|
|
34
|
+
async remove(input) {
|
|
35
|
+
const queue = queues.get(input.sessionId) ?? [];
|
|
36
|
+
const updatedQueue = queue.filter((message) => message.id !== input.id);
|
|
37
|
+
if (updatedQueue.length === queue.length) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (updatedQueue.length === 0) {
|
|
23
41
|
queues.delete(input.sessionId);
|
|
24
|
-
|
|
42
|
+
} else {
|
|
43
|
+
queues.set(input.sessionId, updatedQueue);
|
|
25
44
|
}
|
|
26
|
-
|
|
45
|
+
return true;
|
|
27
46
|
},
|
|
28
|
-
async
|
|
47
|
+
async clear(input) {
|
|
29
48
|
queues.delete(input.sessionId);
|
|
30
|
-
},
|
|
31
|
-
async listSessionIds() {
|
|
32
|
-
return Array.from(queues.keys());
|
|
33
49
|
}
|
|
34
50
|
};
|
|
35
51
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var tool_approval_policy_exports = {};
|
|
20
|
+
__export(tool_approval_policy_exports, {
|
|
21
|
+
ToolApprovalPolicy: () => ToolApprovalPolicy
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(tool_approval_policy_exports);
|
|
24
|
+
var import_errors = require("../errors.js");
|
|
25
|
+
class ToolApprovalPolicy {
|
|
26
|
+
constructor(deps) {
|
|
27
|
+
this.deps = deps;
|
|
28
|
+
}
|
|
29
|
+
async resolve(input) {
|
|
30
|
+
if (await this.deps.isToolExplicitlyAllowed({
|
|
31
|
+
...input.sessionId !== void 0 ? { sessionId: input.sessionId } : {},
|
|
32
|
+
toolName: input.toolName
|
|
33
|
+
})) {
|
|
34
|
+
return { kind: "ready" };
|
|
35
|
+
}
|
|
36
|
+
if (this.deps.getApprovalMode() === "auto-approve") {
|
|
37
|
+
return { kind: "ready" };
|
|
38
|
+
}
|
|
39
|
+
const authored = await this.resolveAuthoredPolicy(input);
|
|
40
|
+
if (authored.kind === "allow") {
|
|
41
|
+
return { kind: "ready" };
|
|
42
|
+
}
|
|
43
|
+
if (authored.kind === "require") {
|
|
44
|
+
if (authored.approvalKey !== void 0 && this.deps.isApprovalKeySessionApproved({
|
|
45
|
+
approvalKey: authored.approvalKey,
|
|
46
|
+
...input.sessionId !== void 0 ? { sessionId: input.sessionId } : {}
|
|
47
|
+
})) {
|
|
48
|
+
return { kind: "ready" };
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
...authored.approvalKey !== void 0 ? { approvalKey: authored.approvalKey } : {},
|
|
52
|
+
kind: "approval-required"
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return { kind: "approval-required" };
|
|
56
|
+
}
|
|
57
|
+
async resolveAuthoredPolicy(input) {
|
|
58
|
+
if (input.source !== "local") {
|
|
59
|
+
return { kind: "none" };
|
|
60
|
+
}
|
|
61
|
+
const needsApproval = this.deps.getLocalTool(input.toolName)?.needsApproval;
|
|
62
|
+
if (needsApproval === void 0) {
|
|
63
|
+
return { kind: "none" };
|
|
64
|
+
}
|
|
65
|
+
const decision = typeof needsApproval === "function" ? await needsApproval(input.args, this.getAuthoredPolicyContext(input)) : needsApproval;
|
|
66
|
+
if (decision === false || decision === null) {
|
|
67
|
+
return { kind: "allow" };
|
|
68
|
+
}
|
|
69
|
+
if (decision === true) {
|
|
70
|
+
return { kind: "require" };
|
|
71
|
+
}
|
|
72
|
+
return decision.length > 0 && decision.trim() === decision ? { approvalKey: decision, kind: "require" } : { kind: "require" };
|
|
73
|
+
}
|
|
74
|
+
getAuthoredPolicyContext(input) {
|
|
75
|
+
const context = input.getContext();
|
|
76
|
+
if (context.sessionId !== input.sessionId) {
|
|
77
|
+
throw import_errors.ToolError.configInvalid(
|
|
78
|
+
`Tool '${input.toolName}' approval context session does not match the approval scope`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return context;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
ToolApprovalPolicy
|
|
87
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Tool, ToolExecutionContext } from '../types.js';
|
|
2
|
+
export type ToolApprovalGate = {
|
|
3
|
+
kind: 'ready';
|
|
4
|
+
} | {
|
|
5
|
+
approvalKey?: string | undefined;
|
|
6
|
+
kind: 'approval-required';
|
|
7
|
+
};
|
|
8
|
+
export type ToolApprovalPolicyInput = {
|
|
9
|
+
args: Record<string, unknown>;
|
|
10
|
+
getContext: () => ToolExecutionContext;
|
|
11
|
+
sessionId?: string | undefined;
|
|
12
|
+
source: 'local' | 'mcp';
|
|
13
|
+
toolName: string;
|
|
14
|
+
};
|
|
15
|
+
export type ToolApprovalPolicyDeps = {
|
|
16
|
+
getApprovalMode(): 'manual' | 'auto-approve';
|
|
17
|
+
getLocalTool(toolName: string): Tool | undefined;
|
|
18
|
+
isApprovalKeySessionApproved(input: {
|
|
19
|
+
approvalKey: string;
|
|
20
|
+
sessionId?: string | undefined;
|
|
21
|
+
}): boolean;
|
|
22
|
+
isToolExplicitlyAllowed(input: {
|
|
23
|
+
sessionId?: string | undefined;
|
|
24
|
+
toolName: string;
|
|
25
|
+
}): Promise<boolean> | boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare class ToolApprovalPolicy {
|
|
28
|
+
private readonly deps;
|
|
29
|
+
constructor(deps: ToolApprovalPolicyDeps);
|
|
30
|
+
resolve(input: ToolApprovalPolicyInput): Promise<ToolApprovalGate>;
|
|
31
|
+
private resolveAuthoredPolicy;
|
|
32
|
+
private getAuthoredPolicyContext;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=tool-approval-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-approval-policy.d.ts","sourceRoot":"","sources":["../../../src/tools/approval/tool-approval-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAwB,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGpF,MAAM,MAAM,gBAAgB,GACtB;IACI,IAAI,EAAE,OAAO,CAAC;CACjB,GACD;IACI,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,mBAAmB,CAAC;CAC7B,CAAC;AAcR,MAAM,MAAM,uBAAuB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,UAAU,EAAE,MAAM,oBAAoB,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,MAAM,EAAE,OAAO,GAAG,KAAK,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACjC,eAAe,IAAI,QAAQ,GAAG,cAAc,CAAC;IAC7C,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjD,4BAA4B,CAAC,KAAK,EAAE;QAChC,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAClC,GAAG,OAAO,CAAC;IACZ,uBAAuB,CAAC,KAAK,EAAE;QAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,QAAQ,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAClC,CAAC;AAEF,qBAAa,kBAAkB;IACf,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,sBAAsB;IAEnD,OAAO,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC;YAyC1D,qBAAqB;IA8BnC,OAAO,CAAC,wBAAwB;CASnC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import "../../chunk-C6A6W6XS.js";
|
|
2
|
+
import { ToolError } from "../errors.js";
|
|
3
|
+
class ToolApprovalPolicy {
|
|
4
|
+
constructor(deps) {
|
|
5
|
+
this.deps = deps;
|
|
6
|
+
}
|
|
7
|
+
async resolve(input) {
|
|
8
|
+
if (await this.deps.isToolExplicitlyAllowed({
|
|
9
|
+
...input.sessionId !== void 0 ? { sessionId: input.sessionId } : {},
|
|
10
|
+
toolName: input.toolName
|
|
11
|
+
})) {
|
|
12
|
+
return { kind: "ready" };
|
|
13
|
+
}
|
|
14
|
+
if (this.deps.getApprovalMode() === "auto-approve") {
|
|
15
|
+
return { kind: "ready" };
|
|
16
|
+
}
|
|
17
|
+
const authored = await this.resolveAuthoredPolicy(input);
|
|
18
|
+
if (authored.kind === "allow") {
|
|
19
|
+
return { kind: "ready" };
|
|
20
|
+
}
|
|
21
|
+
if (authored.kind === "require") {
|
|
22
|
+
if (authored.approvalKey !== void 0 && this.deps.isApprovalKeySessionApproved({
|
|
23
|
+
approvalKey: authored.approvalKey,
|
|
24
|
+
...input.sessionId !== void 0 ? { sessionId: input.sessionId } : {}
|
|
25
|
+
})) {
|
|
26
|
+
return { kind: "ready" };
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
...authored.approvalKey !== void 0 ? { approvalKey: authored.approvalKey } : {},
|
|
30
|
+
kind: "approval-required"
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return { kind: "approval-required" };
|
|
34
|
+
}
|
|
35
|
+
async resolveAuthoredPolicy(input) {
|
|
36
|
+
if (input.source !== "local") {
|
|
37
|
+
return { kind: "none" };
|
|
38
|
+
}
|
|
39
|
+
const needsApproval = this.deps.getLocalTool(input.toolName)?.needsApproval;
|
|
40
|
+
if (needsApproval === void 0) {
|
|
41
|
+
return { kind: "none" };
|
|
42
|
+
}
|
|
43
|
+
const decision = typeof needsApproval === "function" ? await needsApproval(input.args, this.getAuthoredPolicyContext(input)) : needsApproval;
|
|
44
|
+
if (decision === false || decision === null) {
|
|
45
|
+
return { kind: "allow" };
|
|
46
|
+
}
|
|
47
|
+
if (decision === true) {
|
|
48
|
+
return { kind: "require" };
|
|
49
|
+
}
|
|
50
|
+
return decision.length > 0 && decision.trim() === decision ? { approvalKey: decision, kind: "require" } : { kind: "require" };
|
|
51
|
+
}
|
|
52
|
+
getAuthoredPolicyContext(input) {
|
|
53
|
+
const context = input.getContext();
|
|
54
|
+
if (context.sessionId !== input.sessionId) {
|
|
55
|
+
throw ToolError.configInvalid(
|
|
56
|
+
`Tool '${input.toolName}' approval context session does not match the approval scope`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return context;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
ToolApprovalPolicy
|
|
64
|
+
};
|
|
@@ -25,7 +25,6 @@ var ToolErrorCode = /* @__PURE__ */ ((ToolErrorCode2) => {
|
|
|
25
25
|
ToolErrorCode2["EXECUTION_DENIED"] = "tools_execution_denied";
|
|
26
26
|
ToolErrorCode2["EXECUTION_TIMEOUT"] = "tools_execution_timeout";
|
|
27
27
|
ToolErrorCode2["EXECUTION_FAILED"] = "tools_execution_failed";
|
|
28
|
-
ToolErrorCode2["DIRECTORY_ACCESS_DENIED"] = "tools_directory_access_denied";
|
|
29
28
|
ToolErrorCode2["VALIDATION_FAILED"] = "tools_validation_failed";
|
|
30
29
|
ToolErrorCode2["FILE_MODIFIED_SINCE_PREVIEW"] = "tools_file_modified_since_preview";
|
|
31
30
|
ToolErrorCode2["APPROVAL_HANDLER_MISSING"] = "tools_approval_handler_missing";
|
|
@@ -6,7 +6,6 @@ export declare enum ToolErrorCode {
|
|
|
6
6
|
EXECUTION_DENIED = "tools_execution_denied",
|
|
7
7
|
EXECUTION_TIMEOUT = "tools_execution_timeout",
|
|
8
8
|
EXECUTION_FAILED = "tools_execution_failed",
|
|
9
|
-
DIRECTORY_ACCESS_DENIED = "tools_directory_access_denied",
|
|
10
9
|
VALIDATION_FAILED = "tools_validation_failed",
|
|
11
10
|
FILE_MODIFIED_SINCE_PREVIEW = "tools_file_modified_since_preview",
|
|
12
11
|
APPROVAL_HANDLER_MISSING = "tools_approval_handler_missing",
|