maka-agent 0.2.0-dev.26.20260909 → 0.2.0-dev.27.20260910
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/cli-core.js +21 -0
- package/dist/runtime-host-cli.js +43 -3
- package/dist/runtime-host-handoff-surface.js +10 -8
- package/dist/runtime-host-lifecycle-transaction.js +28 -3
- package/dist/runtime-host-local-source-retirement.js +1 -1
- package/dist/runtime-host-setup-command.js +29 -6
- package/dist/runtime-host-update-command.js +49 -5
- package/dist/session-export-command.js +72 -0
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/usage-stats/types.js +2 -0
- package/node_modules/@maka/core/dist/workhub-routing.js +126 -0
- package/node_modules/@maka/core/package.json +2 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +7 -3
- package/node_modules/@maka/runtime/dist/builtin-tools.js +21 -2
- package/node_modules/@maka/runtime/dist/plugin-agent-service.js +131 -0
- package/node_modules/@maka/runtime/dist/plugin-approval-service.js +33 -0
- package/node_modules/@maka/runtime/dist/plugin-attachment-service.js +53 -0
- package/node_modules/@maka/runtime/dist/plugin-command-service.js +100 -0
- package/node_modules/@maka/runtime/dist/plugin-data-services.js +332 -0
- package/node_modules/@maka/runtime/dist/plugin-fs-service.js +62 -0
- package/node_modules/@maka/runtime/dist/plugin-goal-service.js +61 -0
- package/node_modules/@maka/runtime/dist/plugin-invocation-signal.js +24 -0
- package/node_modules/@maka/runtime/dist/plugin-llm-service.js +85 -0
- package/node_modules/@maka/runtime/dist/plugin-lsp-service.js +94 -0
- package/node_modules/@maka/runtime/dist/plugin-scope-registry.js +91 -0
- package/node_modules/@maka/runtime/dist/plugin-session-query-service.js +71 -0
- package/node_modules/@maka/runtime/dist/plugin-shell-env-service.js +87 -0
- package/node_modules/@maka/runtime/dist/plugin-shell-service.js +74 -0
- package/node_modules/@maka/runtime/dist/plugin-skill-service.js +93 -0
- package/node_modules/@maka/runtime/dist/plugin-system-prompt-service.js +346 -0
- package/node_modules/@maka/runtime/dist/plugin-tool-service.js +18 -52
- package/node_modules/@maka/runtime/dist/plugin-user-question-service.js +43 -0
- package/node_modules/@maka/runtime/dist/plugin-web-service.js +69 -0
- package/node_modules/@maka/runtime/dist/session-export.js +177 -0
- package/node_modules/@maka/runtime/package.json +18 -0
- package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +67 -18
- package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +46 -12
- package/node_modules/@maka/runtime-host/dist/operator/setup-frame.js +31 -21
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +9 -1
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +30 -5
- package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +25 -23
- package/node_modules/@maka/runtime-host/dist/server/client-capability-coordinator.js +62 -4
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +452 -7
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +74 -0
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +2 -2
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +30 -0
- package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +79 -16
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +25 -4
- package/node_modules/@maka/runtime-host/dist/server/plugin-data-runtime.js +234 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-platform-coordinator.js +6 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-platform.js +12 -0
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +189 -92
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +44 -35
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +92 -10
- package/node_modules/@maka/storage/dist/agent-run-store.js +54 -10
- package/node_modules/@maka/storage/dist/context-offload-snapshot.js +13 -6
- package/node_modules/@maka/storage/dist/execution-stores.js +1 -1
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +333 -30
- package/node_modules/@maka/storage/dist/session-store.js +2 -2
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +12 -5
- package/node_modules/@maka/storage/package.json +2 -0
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { createHash } from 'node:crypto';
|
|
20
20
|
import { mkdir } from 'node:fs/promises';
|
|
21
|
-
import { join } from 'node:path';
|
|
21
|
+
import { basename, join } from 'node:path';
|
|
22
22
|
import { isDeepStrictEqual } from 'node:util';
|
|
23
23
|
import { normalizeMessageContent } from '@maka/core/events';
|
|
24
24
|
import { WORKHUB_COORDINATION_SESSION_ID, WORKHUB_COORDINATION_SESSION_ROLE, WORKHUB_COORDINATION_REPLACEMENT_SCHEMA_VERSION, WORKHUB_COORDINATION_STOP_SCHEMA_VERSION, isWorkHubCoordinationSession, isWorkHubCoordinationSessionId, } from '@maka/core/session';
|
|
@@ -39,6 +39,9 @@ const TURN_IDENTITY_CONFLICT_MESSAGE = 'WorkHub Coordination Turn identity belon
|
|
|
39
39
|
const JSON_ESCAPE_MAX_BYTES_PER_INPUT_BYTE = 6;
|
|
40
40
|
const COORDINATION_SUMMARY_READ_MAX_BYTES = JSON_ESCAPE_MAX_BYTES_PER_INPUT_BYTE * (WORKHUB_COORDINATION_TEXT_MAX_BYTES + 8 * 1024) +
|
|
41
41
|
16 * 1024;
|
|
42
|
+
const WORKHUB_ROUTING_TIMEOUT_MS = 15_000;
|
|
43
|
+
export const WORKHUB_ROUTING_HISTORY_MAX_MESSAGES = 32;
|
|
44
|
+
export const WORKHUB_ROUTING_HISTORY_MAX_STORED_BYTES = 64 * 1024;
|
|
42
45
|
/** Resolves the one durable Coordination Session owned by this Runtime Host. */
|
|
43
46
|
export class HostWorkHubCoordinationCoordinator {
|
|
44
47
|
handlers = {
|
|
@@ -59,9 +62,11 @@ export class HostWorkHubCoordinationCoordinator {
|
|
|
59
62
|
#resolveCreateTarget;
|
|
60
63
|
#requestDrain;
|
|
61
64
|
#actionGate;
|
|
65
|
+
#routingModel;
|
|
62
66
|
#readDelegationRetirement;
|
|
63
67
|
constructor(options) {
|
|
64
68
|
this.#configureModel = options.configureModel;
|
|
69
|
+
this.#routingModel = options.routingModel;
|
|
65
70
|
this.#transitionConfiguration = options.transitionConfiguration;
|
|
66
71
|
this.#coordinationCwd = join(options.stateRoot, COORDINATION_CWD_DIRECTORY);
|
|
67
72
|
this.#stores = options.stores;
|
|
@@ -328,9 +333,9 @@ export class HostWorkHubCoordinationCoordinator {
|
|
|
328
333
|
}
|
|
329
334
|
}
|
|
330
335
|
async #actFromTurn(input, context) {
|
|
331
|
-
let
|
|
336
|
+
let request;
|
|
332
337
|
try {
|
|
333
|
-
|
|
338
|
+
request = await this.#executions.readActiveWorkHubRoutingRequest(input.turnId);
|
|
334
339
|
}
|
|
335
340
|
catch {
|
|
336
341
|
return {
|
|
@@ -341,7 +346,7 @@ export class HostWorkHubCoordinationCoordinator {
|
|
|
341
346
|
},
|
|
342
347
|
};
|
|
343
348
|
}
|
|
344
|
-
if (!
|
|
349
|
+
if (!request) {
|
|
345
350
|
return {
|
|
346
351
|
ok: false,
|
|
347
352
|
error: {
|
|
@@ -351,17 +356,25 @@ export class HostWorkHubCoordinationCoordinator {
|
|
|
351
356
|
};
|
|
352
357
|
}
|
|
353
358
|
const { turnId: _turnId, ...action } = input;
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
359
|
+
if (request.decision && !routingDecisionAllowsProposal(request.decision, action)) {
|
|
360
|
+
return {
|
|
361
|
+
ok: false,
|
|
362
|
+
error: {
|
|
363
|
+
code: 'operation_conflict',
|
|
364
|
+
message: 'WorkHub action does not match the routing decision bound to this Turn',
|
|
365
|
+
},
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
const carriesAttachments = 'disposition' in action.proposal ||
|
|
369
|
+
('operation' in action.proposal && action.proposal.operation === 'correct');
|
|
357
370
|
try {
|
|
358
371
|
return {
|
|
359
372
|
ok: true,
|
|
360
373
|
result: await this.#actionGate.act({
|
|
361
374
|
...action,
|
|
362
|
-
userText: content.text,
|
|
363
|
-
...(carriesAttachments && content.attachments
|
|
364
|
-
? { attachments: content.attachments }
|
|
375
|
+
userText: request.content.text,
|
|
376
|
+
...(carriesAttachments && request.content.attachments
|
|
377
|
+
? { attachments: request.content.attachments }
|
|
365
378
|
: {}),
|
|
366
379
|
}, context, input.turnId),
|
|
367
380
|
};
|
|
@@ -520,6 +533,60 @@ export class HostWorkHubCoordinationCoordinator {
|
|
|
520
533
|
}, context);
|
|
521
534
|
return outcome.ok ? { ok: true, result: { turnId: input.turnId } } : outcome;
|
|
522
535
|
}
|
|
536
|
+
async prepareRoutingDecision(input) {
|
|
537
|
+
try {
|
|
538
|
+
if (!this.#routingModel)
|
|
539
|
+
throw new Error('WorkHub routing model is unavailable');
|
|
540
|
+
const page = await this.#stores.readMessagesAfter(WORKHUB_COORDINATION_SESSION_ID, {
|
|
541
|
+
beforeSequence: Number.MAX_SAFE_INTEGER,
|
|
542
|
+
maxMessages: WORKHUB_ROUTING_HISTORY_MAX_MESSAGES,
|
|
543
|
+
maxStoredBytes: WORKHUB_ROUTING_HISTORY_MAX_STORED_BYTES,
|
|
544
|
+
});
|
|
545
|
+
const transcript = [...page.records]
|
|
546
|
+
.reverse()
|
|
547
|
+
.flatMap(({ message }) => message.type === 'user' || message.type === 'assistant'
|
|
548
|
+
? [{ role: message.type, text: message.text }]
|
|
549
|
+
: [])
|
|
550
|
+
.slice(-8);
|
|
551
|
+
return await this.#routingModel.decide({
|
|
552
|
+
turnId: input.turnId,
|
|
553
|
+
header: input.header,
|
|
554
|
+
userText: input.content.text,
|
|
555
|
+
transcript,
|
|
556
|
+
resolveCandidates: async () => {
|
|
557
|
+
const outcome = await this.#candidates();
|
|
558
|
+
if (!outcome.ok)
|
|
559
|
+
throw new Error(outcome.error.message);
|
|
560
|
+
const now = Date.now();
|
|
561
|
+
return {
|
|
562
|
+
candidateSetId: outcome.result.candidateSetId,
|
|
563
|
+
candidates: outcome.result.candidates.map((candidate) => ({
|
|
564
|
+
candidateRef: candidate.candidateRef,
|
|
565
|
+
sessionName: candidate.sessionName,
|
|
566
|
+
workspaceName: basename(candidate.workspace.hostCwd),
|
|
567
|
+
state: candidate.state,
|
|
568
|
+
recency: now - candidate.updatedAt < 24 * 60 * 60 * 1_000
|
|
569
|
+
? 'today'
|
|
570
|
+
: now - candidate.updatedAt < 7 * 24 * 60 * 60 * 1_000
|
|
571
|
+
? 'this_week'
|
|
572
|
+
: 'older',
|
|
573
|
+
})),
|
|
574
|
+
};
|
|
575
|
+
},
|
|
576
|
+
abortSignal: input.inputClosedSignal
|
|
577
|
+
? AbortSignal.any([
|
|
578
|
+
input.inputClosedSignal,
|
|
579
|
+
AbortSignal.timeout(WORKHUB_ROUTING_TIMEOUT_MS),
|
|
580
|
+
])
|
|
581
|
+
: AbortSignal.timeout(WORKHUB_ROUTING_TIMEOUT_MS),
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
catch {
|
|
585
|
+
// Invalid output, unavailable candidates, or provider failure cannot
|
|
586
|
+
// silently become creation or bind an arbitrary existing Session.
|
|
587
|
+
return { kind: 'routing', disposition: 'clarify' };
|
|
588
|
+
}
|
|
589
|
+
}
|
|
523
590
|
/** Reads a historical v1 summary to preserve its durable Turn identity. */
|
|
524
591
|
async #readSummaryMessages(turnId) {
|
|
525
592
|
const throughSequence = await this.#stores.readTranscriptHighWaterSnapshot(WORKHUB_COORDINATION_SESSION_ID);
|
|
@@ -620,6 +687,21 @@ function validCoordinationHeader(header) {
|
|
|
620
687
|
function digest(value) {
|
|
621
688
|
return `sha256:${createHash('sha256').update(JSON.stringify(value)).digest('hex')}`;
|
|
622
689
|
}
|
|
690
|
+
function routingDecisionAllowsProposal(decision, action) {
|
|
691
|
+
if (decision.kind === 'linked') {
|
|
692
|
+
return 'operation' in action.proposal && action.proposal.operation === decision.operation;
|
|
693
|
+
}
|
|
694
|
+
if (decision.disposition === 'delegate_existing') {
|
|
695
|
+
return ('disposition' in action.proposal &&
|
|
696
|
+
action.proposal.disposition === 'delegate_existing' &&
|
|
697
|
+
action.proposal.candidateRef === decision.candidateRef &&
|
|
698
|
+
action.candidateSetId === decision.candidateSetId);
|
|
699
|
+
}
|
|
700
|
+
if (decision.disposition === 'create_new') {
|
|
701
|
+
return 'disposition' in action.proposal && action.proposal.disposition === 'create_new';
|
|
702
|
+
}
|
|
703
|
+
return false;
|
|
704
|
+
}
|
|
623
705
|
function workHubDestructiveClaimIdentitySuffix(delegationId) {
|
|
624
706
|
return createHash('sha256').update(delegationId, 'utf8').digest('hex').slice(0, 48);
|
|
625
707
|
}
|
|
@@ -1183,7 +1183,9 @@ function assertRootTurnAdmissionContract(admission) {
|
|
|
1183
1183
|
const execution = admission.execution;
|
|
1184
1184
|
const providerRetry = execution.kind === 'linked_child_provider_retry';
|
|
1185
1185
|
const inputlessExecution = execution.kind === 'safe_boundary_continuation' || execution.kind === 'context_compact';
|
|
1186
|
-
const
|
|
1186
|
+
const allowsQueueSources = execution.kind === 'external_message' ||
|
|
1187
|
+
(execution.kind === 'workhub_coordination' && execution.operation !== 'action');
|
|
1188
|
+
const sourceBatch = allowsQueueSources && admission.sourceMessages.length > 1;
|
|
1187
1189
|
const messageLessExecution = inputlessExecution || providerRetry || sourceBatch;
|
|
1188
1190
|
if (execution.kind === 'agent_graph_supervisor_wake') {
|
|
1189
1191
|
if (admission.turnOrchestration?.mode !== 'graph' ||
|
|
@@ -1200,7 +1202,7 @@ function assertRootTurnAdmissionContract(admission) {
|
|
|
1200
1202
|
if ((admission.normalizedInput === null) !== inputlessExecution) {
|
|
1201
1203
|
throw new Error('Invalid root turn admission contract: execution has an invalid input requirement');
|
|
1202
1204
|
}
|
|
1203
|
-
if (
|
|
1205
|
+
if (!allowsQueueSources && admission.sourceMessages.length !== 0) {
|
|
1204
1206
|
throw new Error('Invalid root turn admission contract: host-authored execution cannot have source messages');
|
|
1205
1207
|
}
|
|
1206
1208
|
if (admission.skillInvocation && execution.kind !== 'external_message') {
|
|
@@ -1347,14 +1349,18 @@ function normalizeRootExecutionDescriptor(value) {
|
|
|
1347
1349
|
});
|
|
1348
1350
|
}
|
|
1349
1351
|
if (value.kind === 'workhub_coordination') {
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
])
|
|
1352
|
+
const routingDecision = normalizeWorkHubRoutingDecision(value.routingDecision);
|
|
1353
|
+
if (!hasExactKeys(value, [
|
|
1354
|
+
'kind',
|
|
1355
|
+
'inputDigest',
|
|
1356
|
+
...(value.capabilityBinding === undefined ? [] : ['capabilityBinding']),
|
|
1357
|
+
...(value.routingDecision === undefined ? [] : ['routingDecision']),
|
|
1358
|
+
...(value.operation === undefined ? [] : ['operation']),
|
|
1359
|
+
...(value.actionId === undefined ? [] : ['actionId']),
|
|
1360
|
+
]) ||
|
|
1361
|
+
(value.capabilityBinding !== undefined && !isSha256Digest(value.capabilityBinding)) ||
|
|
1362
|
+
(value.actionId !== undefined && value.operation !== 'action') ||
|
|
1363
|
+
(value.operation !== undefined && routingDecision !== undefined) ||
|
|
1358
1364
|
(value.operation !== undefined && value.operation !== 'action') ||
|
|
1359
1365
|
(value.actionId !== undefined &&
|
|
1360
1366
|
(typeof value.actionId !== 'string' || !isSafeId(value.actionId))) ||
|
|
@@ -1365,7 +1371,11 @@ function normalizeRootExecutionDescriptor(value) {
|
|
|
1365
1371
|
kind: 'workhub_coordination',
|
|
1366
1372
|
...(value.operation === 'action' ? { operation: 'action' } : {}),
|
|
1367
1373
|
inputDigest: value.inputDigest,
|
|
1374
|
+
...(isSha256Digest(value.capabilityBinding)
|
|
1375
|
+
? { capabilityBinding: value.capabilityBinding }
|
|
1376
|
+
: {}),
|
|
1368
1377
|
...(typeof value.actionId === 'string' ? { actionId: value.actionId } : {}),
|
|
1378
|
+
...(routingDecision ? { routingDecision } : {}),
|
|
1369
1379
|
});
|
|
1370
1380
|
}
|
|
1371
1381
|
if (value.kind === 'regenerate') {
|
|
@@ -1533,6 +1543,40 @@ function normalizeRootExecutionDescriptor(value) {
|
|
|
1533
1543
|
sourceRunId: value.sourceRunId,
|
|
1534
1544
|
});
|
|
1535
1545
|
}
|
|
1546
|
+
function normalizeWorkHubRoutingDecision(value) {
|
|
1547
|
+
if (value === undefined)
|
|
1548
|
+
return undefined;
|
|
1549
|
+
if (!isPlainRecord(value) || typeof value.kind !== 'string') {
|
|
1550
|
+
throw new Error('Invalid WorkHub routing decision');
|
|
1551
|
+
}
|
|
1552
|
+
if (value.kind === 'routing' &&
|
|
1553
|
+
(value.disposition === 'answer_here' ||
|
|
1554
|
+
value.disposition === 'create_new' ||
|
|
1555
|
+
value.disposition === 'clarify') &&
|
|
1556
|
+
hasExactKeys(value, ['kind', 'disposition'])) {
|
|
1557
|
+
return Object.freeze({ kind: 'routing', disposition: value.disposition });
|
|
1558
|
+
}
|
|
1559
|
+
if (value.kind === 'routing' &&
|
|
1560
|
+
value.disposition === 'delegate_existing' &&
|
|
1561
|
+
typeof value.candidateSetId === 'string' &&
|
|
1562
|
+
/^sha256:[a-f0-9]{64}$/.test(value.candidateSetId) &&
|
|
1563
|
+
typeof value.candidateRef === 'string' &&
|
|
1564
|
+
isSafeId(value.candidateRef) &&
|
|
1565
|
+
hasExactKeys(value, ['kind', 'disposition', 'candidateSetId', 'candidateRef'])) {
|
|
1566
|
+
return Object.freeze({
|
|
1567
|
+
kind: 'routing',
|
|
1568
|
+
disposition: 'delegate_existing',
|
|
1569
|
+
candidateSetId: value.candidateSetId,
|
|
1570
|
+
candidateRef: value.candidateRef,
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
if (value.kind === 'linked' &&
|
|
1574
|
+
(value.operation === 'correct' || value.operation === 'stop' || value.operation === 'resume') &&
|
|
1575
|
+
hasExactKeys(value, ['kind', 'operation'])) {
|
|
1576
|
+
return Object.freeze({ kind: 'linked', operation: value.operation });
|
|
1577
|
+
}
|
|
1578
|
+
throw new Error('Invalid WorkHub routing decision');
|
|
1579
|
+
}
|
|
1536
1580
|
function deepFreezeRootTurnMessageContent(content) {
|
|
1537
1581
|
for (const attachment of content.attachments ?? []) {
|
|
1538
1582
|
Object.freeze(attachment.ref);
|
|
@@ -47,7 +47,7 @@ export async function withOfflineContextSnapshot(root, operation) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
/** Copies under the offline owner and the caller's Artifact lock; never mutates the source DB. */
|
|
50
|
-
export async function copyContextSnapshot(sourceRoot, targetRoot, contextLocked,
|
|
50
|
+
export async function copyContextSnapshot(sourceRoot, targetRoot, contextLocked, sessionIds) {
|
|
51
51
|
const sourcePath = join(sourceRoot, CONTEXT_OFFLOAD_DATABASE_NAME);
|
|
52
52
|
if (!(await exists(sourcePath)))
|
|
53
53
|
return false;
|
|
@@ -68,8 +68,14 @@ export async function copyContextSnapshot(sourceRoot, targetRoot, contextLocked,
|
|
|
68
68
|
target.exec('PRAGMA foreign_keys = ON');
|
|
69
69
|
migrateSqliteContextOffloadDatabase(target);
|
|
70
70
|
target.exec('BEGIN IMMEDIATE');
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
// A subagent child's context refs belong to the export as much as its
|
|
72
|
+
// parent's do: the parent's tool call is why the child ran at all.
|
|
73
|
+
if (sessionIds !== undefined) {
|
|
74
|
+
const keep = sessionIds.map(() => '?').join(', ');
|
|
75
|
+
target
|
|
76
|
+
.prepare(`DELETE FROM context_refs WHERE session_id NOT IN (${keep})`)
|
|
77
|
+
.run(...sessionIds);
|
|
78
|
+
}
|
|
73
79
|
target.exec(`
|
|
74
80
|
DELETE FROM context_gc_candidates;
|
|
75
81
|
DELETE FROM context_file_deletions;
|
|
@@ -110,7 +116,7 @@ export async function copyContextSnapshot(sourceRoot, targetRoot, contextLocked,
|
|
|
110
116
|
await syncDirectoryChain(targetRoot, targetRoot);
|
|
111
117
|
return true;
|
|
112
118
|
}
|
|
113
|
-
export async function planContextSnapshotFiles(root,
|
|
119
|
+
export async function planContextSnapshotFiles(root, sessionIds) {
|
|
114
120
|
const path = join(root, CONTEXT_OFFLOAD_DATABASE_NAME);
|
|
115
121
|
if (!(await exists(path)))
|
|
116
122
|
return [];
|
|
@@ -126,8 +132,9 @@ export async function planContextSnapshotFiles(root, sessionId) {
|
|
|
126
132
|
for (const row of database
|
|
127
133
|
.prepare(`SELECT DISTINCT b.blob_id, b.payload FROM context_refs r
|
|
128
134
|
JOIN context_blobs b ON b.blob_id = r.blob_id
|
|
129
|
-
WHERE r.session_id
|
|
130
|
-
|
|
135
|
+
WHERE r.session_id IN (${sessionIds.map(() => '?').join(', ')})
|
|
136
|
+
AND b.storage_kind = 'managed_file' ORDER BY b.blob_id`)
|
|
137
|
+
.iterate(...sessionIds)) {
|
|
131
138
|
const file = managedPath(row.blob_id, row.payload);
|
|
132
139
|
await assertRegularPath(root, file);
|
|
133
140
|
files.push(file);
|
|
@@ -172,7 +172,7 @@ async function createExecutionStoresForWrite(lease, kind, extension) {
|
|
|
172
172
|
listMessageAdmissions: (sessionId) => run(() => sessionStore.listMessageAdmissions(sessionId)),
|
|
173
173
|
markMessagesHandedOff: (input) => run(() => sessionStore.markMessagesHandedOff(input)),
|
|
174
174
|
updateMessageAdmission: (admission) => run(() => sessionStore.updateMessageAdmission(admission)),
|
|
175
|
-
reorderMessageAdmissions: (sessionId, messageIds) => run(() => sessionStore.reorderMessageAdmissions(sessionId, messageIds)),
|
|
175
|
+
reorderMessageAdmissions: (sessionId, messageIds, disposition) => run(() => sessionStore.reorderMessageAdmissions(sessionId, messageIds, disposition)),
|
|
176
176
|
cancelMessageAdmissions: (sessionId, messageIds) => run(() => sessionStore.cancelMessageAdmissions(sessionId, messageIds)),
|
|
177
177
|
subscribeTranscriptChanges: (listener) => sessionStore.subscribeTranscriptChanges(listener),
|
|
178
178
|
updateHeader: (sessionId, patch) => run(() => sessionStore.updateHeader(sessionId, patch)),
|