maka-agent 0.2.0-dev.24.20260907 → 0.2.0-dev.25.20260908
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -19
- package/README.zh-CN.md +34 -19
- package/dist/pi-transcript-tools.js +6 -0
- package/dist/pi-tui-layout.js +56 -10
- package/dist/pi-tui-pickers.js +102 -1
- package/dist/pi-tui-runner.js +156 -42
- package/dist/pi-tui-todo.js +221 -0
- package/dist/pi-tui-transcript-viewer.js +134 -7
- package/dist/runtime-host-cli-context.js +70 -13
- package/dist/runtime-host-handoff-surface.js +51 -26
- package/dist/runtime-host-local-handoff.js +11 -1
- package/dist/runtime-host-service-manager.js +0 -3
- package/dist/runtime-host-session-channel.js +13 -0
- package/dist/runtime-host-session-driver.js +42 -1
- package/dist/tui-copy-catalog.js +79 -3
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/agent-run.js +1 -0
- package/node_modules/@maka/core/dist/attachments.js +3 -0
- package/node_modules/@maka/core/dist/canonical-json.js +27 -0
- package/node_modules/@maka/core/dist/capabilities.js +35 -0
- package/node_modules/@maka/core/dist/computer-use.js +0 -1
- package/node_modules/@maka/core/dist/display-redaction.js +18 -0
- package/node_modules/@maka/core/dist/llm-connections.js +13 -0
- package/node_modules/@maka/core/dist/model-call-attempt.js +2 -0
- package/node_modules/@maka/core/dist/model-metadata.js +4 -0
- package/node_modules/@maka/core/dist/redaction.js +35 -0
- package/node_modules/@maka/core/dist/run-composition.js +77 -2
- package/node_modules/@maka/core/dist/session.js +30 -4
- package/node_modules/@maka/core/dist/slash-command-catalog.js +1 -0
- package/node_modules/@maka/core/dist/tool-result-record-schema.js +2 -1
- package/node_modules/@maka/core/package.json +1 -0
- package/node_modules/@maka/eval/dist/experiment-directory.js +4 -13
- package/node_modules/@maka/runtime/dist/agent-run-inspect.js +0 -13
- package/node_modules/@maka/runtime/dist/agent-run.js +80 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +16 -8
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +57 -50
- package/node_modules/@maka/runtime/dist/archive-read-tool.js +2 -2
- package/node_modules/@maka/runtime/dist/context-budget-helpers.js +0 -16
- package/node_modules/@maka/runtime/dist/conversation-copy.js +153 -11
- package/node_modules/@maka/runtime/dist/github-copilot-oauth-enrollment.js +3 -3
- package/node_modules/@maka/runtime/dist/ledger-tool-result-archive-reader.js +69 -1
- package/node_modules/@maka/runtime/dist/mcp-tools.js +7 -2
- package/node_modules/@maka/runtime/dist/model-fetcher.js +42 -2
- package/node_modules/@maka/runtime/dist/model-history.js +0 -112
- package/node_modules/@maka/runtime/dist/plugin-runtime.js +20 -10
- package/node_modules/@maka/runtime/dist/plugin-tool-service.js +205 -0
- package/node_modules/@maka/runtime/dist/provider-request-telemetry.js +8 -1
- package/node_modules/@maka/runtime/dist/request-shape.js +23 -0
- package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +1 -1
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +4 -0
- package/node_modules/@maka/runtime/dist/runtime-kernel.js +7 -0
- package/node_modules/@maka/runtime/dist/stream-graph-coordinator.js +21 -0
- package/node_modules/@maka/runtime/dist/stream-graph-supervisor-tools.js +0 -5
- package/node_modules/@maka/runtime/dist/test-connection.js +0 -1
- package/node_modules/@maka/runtime/dist/tool-activation-identity.js +41 -0
- package/node_modules/@maka/runtime/dist/tool-availability.js +11 -1
- package/node_modules/@maka/runtime/dist/tool-result-archive-resource.js +63 -1
- package/node_modules/@maka/runtime/dist/tool-result-archive-transition.js +42 -12
- package/node_modules/@maka/runtime/dist/tool-result-archive.js +27 -4
- package/node_modules/@maka/runtime/package.json +1 -0
- package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +35 -12
- package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +2 -0
- package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +19 -0
- package/node_modules/@maka/runtime-host/dist/control/endpoint.js +1 -3
- package/node_modules/@maka/runtime-host/dist/node-error.js +22 -0
- package/node_modules/@maka/runtime-host/dist/operator/managed-deployment.js +1 -3
- package/node_modules/@maka/runtime-host/dist/peer-mesh/limits.js +0 -1
- package/node_modules/@maka/runtime-host/dist/peer-mesh/model.js +1 -1
- package/node_modules/@maka/runtime-host/dist/peer-reachability/publisher.js +1 -3
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +5 -1
- package/node_modules/@maka/runtime-host/dist/protocol/plan.js +1 -0
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +27 -5
- package/node_modules/@maka/runtime-host/dist/protocol/project-catalog.js +2 -2
- package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +31 -2
- package/node_modules/@maka/runtime-host/dist/server/agent-graph-coordinator.js +0 -3
- package/node_modules/@maka/runtime-host/dist/server/execution-artifacts.js +32 -32
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +44 -9
- package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +42 -14
- package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +47 -22
- 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 +6 -0
- package/node_modules/@maka/runtime-host/dist/server/session-retirement-coordinator.js +5 -2
- package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +4 -0
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +20 -2
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +13 -3
- package/node_modules/@maka/runtime-host/dist/server/workhub-message-attachments.js +46 -0
- package/node_modules/@maka/storage/dist/claude-code-session-adapter.js +0 -1
- package/node_modules/@maka/storage/dist/codex-session-adapter.js +284 -196
- package/node_modules/@maka/storage/dist/git-exec.js +61 -0
- package/node_modules/@maka/storage/dist/git-worktree-child-executor.js +8 -35
- package/node_modules/@maka/storage/dist/goal-authority.js +2 -2
- package/node_modules/@maka/storage/dist/interaction-store.js +2 -2
- package/node_modules/@maka/storage/dist/project-catalog.js +2 -23
- package/node_modules/@maka/storage/dist/runtime-event-invariants.js +2 -2
- package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +8 -3
- package/node_modules/@maka/storage/dist/scheduled-task-store.js +249 -283
- package/node_modules/@maka/storage/dist/session-bundle-manifest.js +5 -17
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +2 -1
- package/node_modules/@maka/storage/dist/session-copy-cleanup.js +2 -1
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +1 -2
- package/node_modules/@maka/storage/dist/storage-id.js +28 -0
- package/node_modules/@maka/storage/dist/tool-result-archive-evidence.js +31 -4
- package/node_modules/@maka/storage/dist/workspace-identity.js +2 -15
- package/node_modules/@maka/storage/dist/workspace-version-authority-internal.js +1 -8
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ import { isAbsolute, resolve } from 'node:path';
|
|
|
22
22
|
import { MAX_ATTACHMENT_BYTES } from '@maka/core/attachments';
|
|
23
23
|
import { createToolResultArchiveCapability, } from '@maka/runtime/tool-result-archive-capability';
|
|
24
24
|
import { isPathInside } from '@maka/runtime/path-containment';
|
|
25
|
-
import {
|
|
25
|
+
import { createLedgerArchivePreparer, createLedgerArchiveResourceReader, createLedgerToolResultArchiveReader, } from '@maka/runtime/ledger-tool-result-archive-reader';
|
|
26
26
|
export function createHostExecutionArtifactServices(input) {
|
|
27
27
|
const runWrite = async (operation) => {
|
|
28
28
|
try {
|
|
@@ -58,6 +58,30 @@ export function createHostExecutionArtifactServices(input) {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
|
+
const prepareLedger = input.archiveEvidence
|
|
62
|
+
? createLedgerArchivePreparer(input.archiveEvidence)
|
|
63
|
+
: undefined;
|
|
64
|
+
const readLedger = input.archiveEvidence
|
|
65
|
+
? createLedgerToolResultArchiveReader(input.archiveEvidence)
|
|
66
|
+
: undefined;
|
|
67
|
+
const readLedgerResource = input.archiveEvidence
|
|
68
|
+
? createLedgerArchiveResourceReader(input.archiveEvidence)
|
|
69
|
+
: undefined;
|
|
70
|
+
const prepareLedgerForCommit = async (event) => {
|
|
71
|
+
const accepted = { ...event };
|
|
72
|
+
if (!prepareLedger || !(await prepareLedger(accepted)))
|
|
73
|
+
return;
|
|
74
|
+
return {
|
|
75
|
+
ledger: true,
|
|
76
|
+
commitTransition: (transition, persist) => input.sessionAdmission.runOrJoin(accepted.sessionId, async () => {
|
|
77
|
+
if ((await input.sessions.probeSessionRemoval(accepted.sessionId)).kind !== 'present' ||
|
|
78
|
+
!(await prepareLedger(accepted)))
|
|
79
|
+
return false;
|
|
80
|
+
await persist(transition);
|
|
81
|
+
return true;
|
|
82
|
+
}),
|
|
83
|
+
};
|
|
84
|
+
};
|
|
61
85
|
const services = {
|
|
62
86
|
recordToolArtifacts,
|
|
63
87
|
publishChildWorkspacePatch: async ({ sessionId, turnId, binding, patch }) => {
|
|
@@ -77,37 +101,13 @@ export function createHostExecutionArtifactServices(input) {
|
|
|
77
101
|
return artifact;
|
|
78
102
|
},
|
|
79
103
|
toolResultArchive: createToolResultArchiveCapability({
|
|
80
|
-
archiveToolResult:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
bodySha256: event.bodySha256,
|
|
88
|
-
originalBytes: event.originalBytes,
|
|
89
|
-
maxBytes: event.originalBytes,
|
|
90
|
-
});
|
|
91
|
-
if (!read.ok) {
|
|
92
|
-
throw new Error(`Tool result archive identity conflict: ${read.reason}`);
|
|
93
|
-
}
|
|
94
|
-
return { artifactId };
|
|
95
|
-
}
|
|
96
|
-
const artifact = await input.artifacts.create({
|
|
97
|
-
id: artifactId,
|
|
98
|
-
sessionId: event.sessionId,
|
|
99
|
-
turnId: event.turnId,
|
|
100
|
-
name: `archived-${event.toolName}-${event.runtimeEventId}.json`,
|
|
101
|
-
kind: 'file',
|
|
102
|
-
content: event.serializedResult,
|
|
103
|
-
mimeType: 'application/json',
|
|
104
|
-
source: 'tool_result_archive',
|
|
105
|
-
summary: `Archived ${event.toolName} tool result for context budget replay`,
|
|
106
|
-
});
|
|
107
|
-
return { artifactId: artifact.id };
|
|
108
|
-
}),
|
|
109
|
-
readToolResultArchive: (event) => readArchive(input.artifacts, event),
|
|
110
|
-
readArchivedToolResultResource: (event) => readArchive(input.artifacts, event),
|
|
104
|
+
archiveToolResult: prepareLedgerForCommit,
|
|
105
|
+
readToolResultArchive: (event) => event.rewriteVersion === 2
|
|
106
|
+
? (readLedger?.(event) ?? { ok: false, reason: 'read_failed' })
|
|
107
|
+
: readArchive(input.artifacts, event),
|
|
108
|
+
readArchivedToolResultResource: (event) => event.storage === 'ledger'
|
|
109
|
+
? (readLedgerResource?.(event) ?? { ok: false, reason: 'read_failed' })
|
|
110
|
+
: readArchive(input.artifacts, event),
|
|
111
111
|
}),
|
|
112
112
|
};
|
|
113
113
|
return Object.freeze(services);
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
import { copyWorkHubAttachmentsToTarget } from './workhub-message-attachments.js';
|
|
19
20
|
import { createHash, randomUUID } from 'node:crypto';
|
|
20
21
|
import { MAX_READ_IMAGE_BYTES } from '@maka/core/attachments';
|
|
21
22
|
import { messageContentDigest, normalizeMessageContent } from '@maka/core/events';
|
|
@@ -43,6 +44,9 @@ import { renderAgentSwarmSupervisorWake, shouldWakeAgentSwarmSupervisor, } from
|
|
|
43
44
|
import { SessionActivityRegistry } from '@maka/runtime/goal-turn-lifecycle';
|
|
44
45
|
import { ShellRunProcessManager } from '@maka/runtime/shell-run-manager';
|
|
45
46
|
import { resolveShellPlan, resolveTurnShellPlan, validateShellPreference, } from '@maka/runtime/shell-detect';
|
|
47
|
+
import { Context } from '@maka/runtime/plugin-kernel';
|
|
48
|
+
import { MakaCompositionLoader } from '@maka/runtime/plugin-composition-loader';
|
|
49
|
+
import { PluginToolService } from '@maka/runtime/plugin-tool-service';
|
|
46
50
|
import { isHostedExecutionTerminal } from './hosted-execution-authority.js';
|
|
47
51
|
import { createAgentGraphControlStore } from '@maka/storage/agent-graph-control-store';
|
|
48
52
|
import { createArtifactAttachmentResourceReader } from '@maka/storage/artifact-stores';
|
|
@@ -125,6 +129,7 @@ import { WorkHubActionEffectFailure, workHubResumedTurnId, } from './workhub-coo
|
|
|
125
129
|
import { createHostWebSearchService, createHostWebSearchToolFromService, resolveHostTavilyWebSearchReadiness, shouldResolveHostTavilyWebSearchReadiness, } from './web-search-tool.js';
|
|
126
130
|
import { createHostWebFetchService, createHostWebFetchToolFromService } from './web-fetch-tool.js';
|
|
127
131
|
import { createHostExecutionArtifactServices } from './execution-artifacts.js';
|
|
132
|
+
import { openToolResultArchiveEvidenceReader } from '@maka/storage/tool-result-archive-evidence';
|
|
128
133
|
import { createRuntimeHostWorkspaceExecutionComposition, RuntimeHostWorkspaceExecutionError, } from './workspace-execution-composition.js';
|
|
129
134
|
const GIBIBYTE = 1024 * 1024 * 1024;
|
|
130
135
|
const CONTEXT_OFFLOAD_LIMITS = Object.freeze({
|
|
@@ -167,9 +172,16 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
167
172
|
let workspaceExecution;
|
|
168
173
|
let goalExecutions;
|
|
169
174
|
let pluginPlatform;
|
|
175
|
+
let manager;
|
|
170
176
|
let modelMetadataRefresh;
|
|
177
|
+
let archiveEvidence;
|
|
171
178
|
try {
|
|
172
|
-
|
|
179
|
+
const pluginRoot = new Context();
|
|
180
|
+
const pluginTools = new PluginToolService(pluginRoot);
|
|
181
|
+
pluginPlatform = new HostPluginPlatform(context.owner.controlDirectory, {
|
|
182
|
+
composition: new MakaCompositionLoader({ root: pluginRoot }),
|
|
183
|
+
tools: pluginTools,
|
|
184
|
+
});
|
|
173
185
|
const pluginPlatformCoordinator = new HostPluginPlatformCoordinator(pluginPlatform);
|
|
174
186
|
const openedProjectCatalog = storage.projectCatalog;
|
|
175
187
|
const runtimePolicyStores = storage.runtimePolicy;
|
|
@@ -229,7 +241,6 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
229
241
|
const memoryExtractionLane = new MemoryExtractionSessionLane();
|
|
230
242
|
let runtimeResources;
|
|
231
243
|
let continuity;
|
|
232
|
-
let manager;
|
|
233
244
|
let graphCoordinator;
|
|
234
245
|
let graphSupervisorWake;
|
|
235
246
|
const graphWakeActivities = new SessionActivityRegistry();
|
|
@@ -281,7 +292,9 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
281
292
|
resolveShell: async () => resolveShellPlan((await runtimePolicyStores.runtimePolicy.getSnapshot()).policy.shell),
|
|
282
293
|
onProjectionChanged: (update) => requireContinuity(continuity).enqueueRuntimeResourceChanged(update),
|
|
283
294
|
});
|
|
295
|
+
archiveEvidence = await openToolResultArchiveEvidenceReader(context.owner.lease);
|
|
284
296
|
const executionArtifacts = createHostExecutionArtifactServices({
|
|
297
|
+
archiveEvidence,
|
|
285
298
|
artifacts: openedArtifactStore,
|
|
286
299
|
requestDrain: context.requestDrain,
|
|
287
300
|
sessionAdmission,
|
|
@@ -537,6 +550,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
537
550
|
builtinTools,
|
|
538
551
|
hostTools,
|
|
539
552
|
resolveRootTools: (sessionId) => requireGraphCoordinator(graphCoordinator).toolsForSession(sessionId),
|
|
553
|
+
resolvePluginTools: (sessionId, coreTools) => pluginTools.resolveContributions(sessionId, coreTools),
|
|
540
554
|
parentAgentTools: childAgentTools.parentTools,
|
|
541
555
|
childTools: childAgentTools.childTools,
|
|
542
556
|
worktreePatchWriteBackAvailable: true,
|
|
@@ -855,7 +869,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
855
869
|
});
|
|
856
870
|
};
|
|
857
871
|
const registerBackendInvalidation = () => {
|
|
858
|
-
observeBackendInvalidation(manager.refreshIdleBackends());
|
|
872
|
+
observeBackendInvalidation(requireSessionManager(manager).refreshIdleBackends());
|
|
859
873
|
};
|
|
860
874
|
const registerConfigurationMutation = () => {
|
|
861
875
|
hostChanges.publishConfiguration();
|
|
@@ -876,7 +890,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
876
890
|
acquireResidency: () => context.acquireResidency('oauth'),
|
|
877
891
|
invalidateBackends: () => {
|
|
878
892
|
hostChanges.publishConfiguration();
|
|
879
|
-
return manager.refreshIdleBackends();
|
|
893
|
+
return requireSessionManager(manager).refreshIdleBackends();
|
|
880
894
|
},
|
|
881
895
|
onFatal: (error) => {
|
|
882
896
|
if (poisonFailure)
|
|
@@ -1178,7 +1192,17 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1178
1192
|
sessionId: input.targetSessionId,
|
|
1179
1193
|
workspace: input.create.workspace,
|
|
1180
1194
|
name: input.create.title,
|
|
1181
|
-
modelTarget:
|
|
1195
|
+
modelTarget: input.create.defaults?.model
|
|
1196
|
+
? {
|
|
1197
|
+
kind: 'explicit',
|
|
1198
|
+
connectionId: input.create.defaults.model.llmConnectionId,
|
|
1199
|
+
connectionSlug: input.create.defaults.model.llmConnectionSlug,
|
|
1200
|
+
model: input.create.defaults.model.model,
|
|
1201
|
+
}
|
|
1202
|
+
: { kind: 'default' },
|
|
1203
|
+
...(input.create.defaults?.permissionMode
|
|
1204
|
+
? { permissionMode: input.create.defaults.permissionMode }
|
|
1205
|
+
: {}),
|
|
1182
1206
|
collaborationMode: 'agent',
|
|
1183
1207
|
orchestrationMode: 'default',
|
|
1184
1208
|
})
|
|
@@ -1188,7 +1212,13 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1188
1212
|
.digest('hex')
|
|
1189
1213
|
.slice(0, 48);
|
|
1190
1214
|
const messageId = `whm_${suffix}`;
|
|
1191
|
-
const
|
|
1215
|
+
const targetAttachments = !durable && input.attachments?.length
|
|
1216
|
+
? await copyWorkHubAttachmentsToTarget(openedArtifactStore, artifacts, input.targetSessionId, input.attachments)
|
|
1217
|
+
: input.attachments;
|
|
1218
|
+
const content = normalizeMessageContent({
|
|
1219
|
+
text: input.userText,
|
|
1220
|
+
...(targetAttachments ? { attachments: targetAttachments } : {}),
|
|
1221
|
+
});
|
|
1192
1222
|
const persisted = durable ??
|
|
1193
1223
|
(await sessionAdmission.runMany([WORKHUB_COORDINATION_SESSION_ID, input.targetSessionId], async (lease) => {
|
|
1194
1224
|
const rootState = coordinator.readRootState(input.targetSessionId);
|
|
@@ -1239,6 +1269,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1239
1269
|
delegationId,
|
|
1240
1270
|
disposition: input.disposition,
|
|
1241
1271
|
userText: input.userText,
|
|
1272
|
+
...(input.attachments ? { attachments: input.attachments } : {}),
|
|
1242
1273
|
...(steered ? { steered: true } : {}),
|
|
1243
1274
|
...(input.create ? { create: input.create } : {}),
|
|
1244
1275
|
...(input.replacesActionId && input.replacesDelegationId
|
|
@@ -1492,9 +1523,12 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1492
1523
|
() => oauth?.beginDrain(),
|
|
1493
1524
|
],
|
|
1494
1525
|
close: [
|
|
1526
|
+
() => archiveEvidence?.close(),
|
|
1495
1527
|
() => modelMetadataRefresh?.close(),
|
|
1496
1528
|
() => connectionEffects.close(),
|
|
1497
|
-
() =>
|
|
1529
|
+
() => backendInvalidationPoisoned
|
|
1530
|
+
? undefined
|
|
1531
|
+
: requireSessionManager(manager).refreshIdleBackends(),
|
|
1498
1532
|
() => skills.close(),
|
|
1499
1533
|
() => oauth?.close(),
|
|
1500
1534
|
() => {
|
|
@@ -1559,8 +1593,8 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1559
1593
|
executions: async () => {
|
|
1560
1594
|
await coordinator.prepareRecovery();
|
|
1561
1595
|
await interactions.recoverPendingAfterHostRestart();
|
|
1562
|
-
await manager.recoverInterruptedSessionsStrict(stores);
|
|
1563
|
-
await manager.recoverChildWorkspacePatches(recoverySessions.flatMap((session) => session.subagentWorkspace ? [session.id] : []));
|
|
1596
|
+
await requireSessionManager(manager).recoverInterruptedSessionsStrict(stores);
|
|
1597
|
+
await requireSessionManager(manager).recoverChildWorkspacePatches(recoverySessions.flatMap((session) => session.subagentWorkspace ? [session.id] : []));
|
|
1564
1598
|
await coordinator.recover();
|
|
1565
1599
|
await messages.recoverPendingAfterHostRestart(recoverySessions.map((session) => session.id));
|
|
1566
1600
|
await turnAccessRequests?.recover();
|
|
@@ -1746,6 +1780,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1746
1780
|
}
|
|
1747
1781
|
catch (error) {
|
|
1748
1782
|
const errors = [error];
|
|
1783
|
+
archiveEvidence?.close();
|
|
1749
1784
|
try {
|
|
1750
1785
|
await modelMetadataRefresh?.close();
|
|
1751
1786
|
}
|
|
@@ -187,20 +187,42 @@ async function buildHostAiSdkBackend(input, target) {
|
|
|
187
187
|
});
|
|
188
188
|
};
|
|
189
189
|
const recordRunComposition = input.context.recordRunComposition;
|
|
190
|
+
const recordRequestComposition = input.context.recordRequestComposition;
|
|
191
|
+
const resolveModelTools = () => modelComposition.resolveTools?.() ?? modelComposition.tools;
|
|
192
|
+
// RunComposition remains the immutable C0 baseline. Dynamic Tool changes
|
|
193
|
+
// belong exclusively to RequestComposition epochs, so never re-sample them
|
|
194
|
+
// while committing the baseline immediately before provider dispatch.
|
|
195
|
+
const initialModelTools = Object.freeze([...modelComposition.tools]);
|
|
196
|
+
const runCompositionCommits = new Map();
|
|
190
197
|
const commitRunComposition = recordRunComposition
|
|
191
198
|
? async (context) => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
199
|
+
let commit = runCompositionCommits.get(context.runId);
|
|
200
|
+
if (!commit) {
|
|
201
|
+
commit = (async () => {
|
|
202
|
+
const resolved = await resolveRunPrompt(context);
|
|
203
|
+
await recordRunComposition(context.runId, createRunCompositionSnapshot({
|
|
204
|
+
composerId: modelComposition.composerId,
|
|
205
|
+
composerRevision: modelComposition.composerRevision,
|
|
206
|
+
sourceRevisions: resolved.sourceRevisions,
|
|
207
|
+
baseSystemPromptHash: stableHash(resolved.text ?? ''),
|
|
208
|
+
toolCatalogHash: toolCatalogHash(initialModelTools),
|
|
209
|
+
toolAvailabilityHash: toolAvailabilityHash(modelComposition.toolAvailability),
|
|
210
|
+
baseProviderOptionsHash: stableHash(providerOptions),
|
|
211
|
+
toolNames: initialModelTools.map(({ name }) => name),
|
|
212
|
+
contextWindow: contextWindow ?? null,
|
|
213
|
+
}));
|
|
214
|
+
})();
|
|
215
|
+
runCompositionCommits.set(context.runId, commit);
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
await commit;
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
if (runCompositionCommits.get(context.runId) === commit) {
|
|
222
|
+
runCompositionCommits.delete(context.runId);
|
|
223
|
+
}
|
|
224
|
+
throw error;
|
|
225
|
+
}
|
|
204
226
|
}
|
|
205
227
|
: undefined;
|
|
206
228
|
const planProjectionImage = createReadImageSnapshotPlanner(input.artifacts);
|
|
@@ -234,7 +256,8 @@ async function buildHostAiSdkBackend(input, target) {
|
|
|
234
256
|
apiKey,
|
|
235
257
|
modelId: target.model,
|
|
236
258
|
modelFactory,
|
|
237
|
-
tools: [...
|
|
259
|
+
tools: [...resolveModelTools()],
|
|
260
|
+
resolveTools: resolveModelTools,
|
|
238
261
|
toolAvailability: modelComposition.toolAvailability,
|
|
239
262
|
...(modelComposition.planTraceContext
|
|
240
263
|
? { planTraceContext: modelComposition.planTraceContext }
|
|
@@ -293,6 +316,11 @@ async function buildHostAiSdkBackend(input, target) {
|
|
|
293
316
|
beforeRunProviderDispatch: commitRunComposition,
|
|
294
317
|
}
|
|
295
318
|
: {}),
|
|
319
|
+
...(recordRequestComposition
|
|
320
|
+
? {
|
|
321
|
+
recordRequestComposition: (runId, snapshot) => recordRequestComposition(runId, snapshot),
|
|
322
|
+
}
|
|
323
|
+
: {}),
|
|
296
324
|
systemPrompt: async (context) => {
|
|
297
325
|
const resolved = await resolveRunPrompt({
|
|
298
326
|
turnId: context.turnId,
|
|
@@ -300,7 +328,7 @@ async function buildHostAiSdkBackend(input, target) {
|
|
|
300
328
|
? { emitSkillCatalogTrace: context.emitSkillCatalogTrace }
|
|
301
329
|
: {}),
|
|
302
330
|
});
|
|
303
|
-
return resolved.text;
|
|
331
|
+
return { text: resolved.text, sourceRevisions: resolved.sourceRevisions };
|
|
304
332
|
},
|
|
305
333
|
lookupPricing: pricing,
|
|
306
334
|
recordModelCallAttempt,
|
|
@@ -52,31 +52,41 @@ export function createInteractiveRunComposer(input) {
|
|
|
52
52
|
: input.builtinTools;
|
|
53
53
|
const inventorySnapshotFor = createTurnSkillInventorySnapshotResolver(input.skills);
|
|
54
54
|
const inventoryFor = async (context) => (await inventorySnapshotFor(context)).inventory;
|
|
55
|
+
const hasToolCeiling = input.boundTools !== undefined || input.toolProfile !== undefined;
|
|
56
|
+
const activeExecution = input.plan ? activePlanExecution(input.plan.state) : undefined;
|
|
57
|
+
// The base Host binding is immutable for this backend. Only scoped plugin
|
|
58
|
+
// contributions are sampled at logical step boundaries.
|
|
55
59
|
const defaultTools = input.boundTools
|
|
56
60
|
? input.boundTools
|
|
57
|
-
: buildDefaultHostTools(input.sessionTodo, inventoryFor, builtinTools, input.hostTools, input.scheduledTaskTool, input.goalTools, input.parentAgentTools, input.plan, input.deepResearch?.tools);
|
|
58
|
-
const hasToolCeiling = input.boundTools !== undefined || input.toolProfile !== undefined;
|
|
61
|
+
: buildDefaultHostTools(input.sessionTodo, inventoryFor, builtinTools, input.hostTools ?? [], input.scheduledTaskTool, input.goalTools, input.parentAgentTools, input.plan, input.deepResearch?.tools);
|
|
59
62
|
const clientCapabilityTools = hasToolCeiling ? [] : (input.clientCapabilities?.tools ?? []);
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
63
|
+
const resolveTools = () => {
|
|
64
|
+
const stableHostTools = [...defaultTools, ...clientCapabilityTools];
|
|
65
|
+
const additionalTools = hasToolCeiling
|
|
66
|
+
? []
|
|
67
|
+
: (input.resolveAdditionalTools?.(stableHostTools) ?? []);
|
|
68
|
+
const unscopedCandidateTools = [...stableHostTools, ...additionalTools];
|
|
69
|
+
const routedCandidateTools = input.deepResearch
|
|
70
|
+
? unscopedCandidateTools.filter(isDeepResearchToolAllowed)
|
|
71
|
+
: unscopedCandidateTools;
|
|
72
|
+
const candidateTools = projectHostedExecutionTools(routedCandidateTools, input.toolProfile);
|
|
73
|
+
const selectedTools = input.plan
|
|
74
|
+
? selectCollaborationTools({
|
|
75
|
+
mode: input.plan.mode,
|
|
76
|
+
tools: candidateTools,
|
|
77
|
+
hasActiveExecution: activeExecution !== undefined,
|
|
78
|
+
fullAccess: input.plan.permissionMode === 'bypass',
|
|
79
|
+
})
|
|
80
|
+
: candidateTools;
|
|
81
|
+
// A bound tool list is an exact child/local activation ceiling. Dynamic
|
|
82
|
+
// capabilities must be included by the authority that constructs that
|
|
83
|
+
// list. The ceiling is also an exact wire contract: no deferred search
|
|
84
|
+
// groups inside it, so the bound tools stay fully visible.
|
|
85
|
+
const resolved = [...selectedTools];
|
|
86
|
+
assertUniqueToolNames(resolved);
|
|
87
|
+
return Object.freeze(resolved);
|
|
88
|
+
};
|
|
89
|
+
const tools = resolveTools();
|
|
80
90
|
const hostCapabilities = buildHostCapabilitiesFromBinding(tools.map(({ name }) => name));
|
|
81
91
|
const toolAvailability = hasToolCeiling
|
|
82
92
|
? undefined
|
|
@@ -160,6 +170,7 @@ export function createInteractiveRunComposer(input) {
|
|
|
160
170
|
composerId: INTERACTIVE_RUN_COMPOSER_ID,
|
|
161
171
|
composerRevision: INTERACTIVE_RUN_COMPOSER_REVISION,
|
|
162
172
|
tools,
|
|
173
|
+
resolveTools,
|
|
163
174
|
toolAvailability,
|
|
164
175
|
resolveSystemPrompt,
|
|
165
176
|
});
|
|
@@ -248,6 +259,20 @@ export function createInteractiveRunComposerFactory(input) {
|
|
|
248
259
|
...(clientCapabilities ? { clientCapabilities } : {}),
|
|
249
260
|
...(input.builtinTools ? { builtinTools: input.builtinTools } : {}),
|
|
250
261
|
...(hostTools.length > 0 ? { hostTools } : {}),
|
|
262
|
+
...(input.resolvePluginTools && !backendContext.tools
|
|
263
|
+
? {
|
|
264
|
+
resolveAdditionalTools: (hostTools) => {
|
|
265
|
+
return routeInteractiveRunToolSurface({
|
|
266
|
+
runtimePolicy,
|
|
267
|
+
connection,
|
|
268
|
+
modelId,
|
|
269
|
+
hostTools: input.resolvePluginTools(backendContext.sessionId, hostTools).tools,
|
|
270
|
+
worktreePatchWriteBackAvailable: input.worktreePatchWriteBackAvailable,
|
|
271
|
+
tavilyReady,
|
|
272
|
+
}).hostTools;
|
|
273
|
+
},
|
|
274
|
+
}
|
|
275
|
+
: {}),
|
|
251
276
|
...(input.scheduledTaskTool ? { scheduledTaskTool: input.scheduledTaskTool } : {}),
|
|
252
277
|
...(input.goalTools ? { goalTools: input.goalTools } : {}),
|
|
253
278
|
...(parentAgentTools ? { parentAgentTools } : {}),
|
|
@@ -56,6 +56,12 @@ export class HostPluginPlatformCoordinator {
|
|
|
56
56
|
const inspections = flattenInspections(this.platform.inspect(input.rootId));
|
|
57
57
|
return { ok: true, result: boundedPage('entries', inspections, input) };
|
|
58
58
|
}
|
|
59
|
+
if (input.view === 'tools') {
|
|
60
|
+
return {
|
|
61
|
+
ok: true,
|
|
62
|
+
result: boundedPage('tools', this.platform.inspectTools(input.rootId), input),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
59
65
|
if (input.view === 'failures') {
|
|
60
66
|
return { ok: true, result: boundedPage('failures', failures, input) };
|
|
61
67
|
}
|
|
@@ -42,6 +42,7 @@ export class HostPluginPlatform {
|
|
|
42
42
|
#packages;
|
|
43
43
|
#packageLoader;
|
|
44
44
|
#store;
|
|
45
|
+
#tools;
|
|
45
46
|
#authority = emptyCompositionAuthority();
|
|
46
47
|
#desired = emptyCompositionState();
|
|
47
48
|
#mutation = Promise.resolve();
|
|
@@ -62,6 +63,7 @@ export class HostPluginPlatform {
|
|
|
62
63
|
this.#packageLoader =
|
|
63
64
|
options.packageLoader ?? new TrustedPluginPackageLoader(controlDirectory, this.#packages);
|
|
64
65
|
this.#store = options.store ?? new HostPluginCompositionStore(controlDirectory);
|
|
66
|
+
this.#tools = options.tools;
|
|
65
67
|
}
|
|
66
68
|
async recover() {
|
|
67
69
|
if (this.#recoveryStarted ||
|
|
@@ -338,6 +340,10 @@ export class HostPluginPlatform {
|
|
|
338
340
|
this.#assertReadable();
|
|
339
341
|
return this.#composition.inspectTree(rootId);
|
|
340
342
|
}
|
|
343
|
+
inspectTools(rootId) {
|
|
344
|
+
this.#assertReadable();
|
|
345
|
+
return this.#tools?.inspect(rootId) ?? Object.freeze([]);
|
|
346
|
+
}
|
|
341
347
|
async status() {
|
|
342
348
|
this.#assertReadable();
|
|
343
349
|
return Object.freeze({
|
|
@@ -439,8 +439,11 @@ export class HostSessionRetirementCoordinator {
|
|
|
439
439
|
throw new SessionRetirementBusyError(`Session ${sessionId} has a live derived effect`);
|
|
440
440
|
}
|
|
441
441
|
const header = requireFamilyRecord(family, sessionId).header;
|
|
442
|
-
if (!header.subagentParent
|
|
443
|
-
|
|
442
|
+
if (!header.subagentParent) {
|
|
443
|
+
const graph = await this.#graph.readRetirementDisposition(sessionId);
|
|
444
|
+
if (graph.kind === 'busy') {
|
|
445
|
+
throw new SessionRetirementBusyError(`Session ${sessionId} has an Agent Graph that is ${graph.status}`);
|
|
446
|
+
}
|
|
444
447
|
}
|
|
445
448
|
if (!header.subagentParent && this.#graphWake.hasLiveSessionState(sessionId)) {
|
|
446
449
|
throw new SessionRetirementBusyError(`Session ${sessionId} has an active Agent Graph supervisor wake`);
|
|
@@ -642,6 +642,8 @@ function collectArchivedToolResultPlaceholders(events, messages, copyTurnIds, op
|
|
|
642
642
|
return true;
|
|
643
643
|
if (!isArchivedToolResultPlaceholder(value))
|
|
644
644
|
return false;
|
|
645
|
+
if (value.rewriteVersion === 2)
|
|
646
|
+
return true;
|
|
645
647
|
addDescriptor(value);
|
|
646
648
|
return true;
|
|
647
649
|
};
|
|
@@ -684,6 +686,8 @@ function collectArchivedToolResultPlaceholders(events, messages, copyTurnIds, op
|
|
|
684
686
|
continue;
|
|
685
687
|
}
|
|
686
688
|
if (message.content.kind === 'archived_tool_result') {
|
|
689
|
+
if (message.content.rewriteVersion === 2 && message.content.resourceRef)
|
|
690
|
+
continue;
|
|
687
691
|
if (!message.content.artifactId && !message.content.bodySha256)
|
|
688
692
|
continue;
|
|
689
693
|
if (!message.content.artifactId || !message.content.bodySha256)
|
|
@@ -109,7 +109,11 @@ export class WorkHubCoordinationActionGate {
|
|
|
109
109
|
if (proposal.disposition === 'answer_here') {
|
|
110
110
|
const turnId = coordinationTurnId(input.actionId, 'answer');
|
|
111
111
|
await this.#claimAction(input.actionId, 'answer_here', fingerprint, turnId);
|
|
112
|
-
await this.#effects.answer({
|
|
112
|
+
await this.#effects.answer({
|
|
113
|
+
turnId,
|
|
114
|
+
text: input.userText,
|
|
115
|
+
...(input.attachments ? { attachments: input.attachments } : {}),
|
|
116
|
+
}, context);
|
|
113
117
|
return { disposition: 'answer_here', coordinationTurnId: turnId };
|
|
114
118
|
}
|
|
115
119
|
if (proposal.disposition === 'clarify') {
|
|
@@ -384,7 +388,12 @@ export class WorkHubCoordinationActionGate {
|
|
|
384
388
|
targetSessionName: target.title,
|
|
385
389
|
disposition: 'create_new',
|
|
386
390
|
userText: input.userText,
|
|
387
|
-
|
|
391
|
+
...(input.attachments ? { attachments: input.attachments } : {}),
|
|
392
|
+
create: {
|
|
393
|
+
title: target.title,
|
|
394
|
+
workspace: input.create.workspace,
|
|
395
|
+
...(input.newWorkDefaults ? { defaults: input.newWorkDefaults } : {}),
|
|
396
|
+
},
|
|
388
397
|
replacesActionId: replaced.actionId,
|
|
389
398
|
replacesDelegationId: replaced.delegationId,
|
|
390
399
|
replacedTargetSessionId: replaced.targetSessionId,
|
|
@@ -413,6 +422,7 @@ export class WorkHubCoordinationActionGate {
|
|
|
413
422
|
targetSessionName: destination.sessionName,
|
|
414
423
|
disposition: 'delegate_existing',
|
|
415
424
|
userText: input.userText,
|
|
425
|
+
...(input.attachments ? { attachments: input.attachments } : {}),
|
|
416
426
|
replacesActionId: replaced.actionId,
|
|
417
427
|
replacesDelegationId: replaced.delegationId,
|
|
418
428
|
replacedTargetSessionId: replaced.targetSessionId,
|
|
@@ -615,6 +625,7 @@ function delegationAssignment(input, actionFingerprint, targetSessionId, targetS
|
|
|
615
625
|
targetSessionName,
|
|
616
626
|
disposition: input.proposal.disposition,
|
|
617
627
|
userText: input.userText,
|
|
628
|
+
...(input.attachments ? { attachments: input.attachments } : {}),
|
|
618
629
|
};
|
|
619
630
|
if (input.proposal.disposition === 'delegate_existing')
|
|
620
631
|
return base;
|
|
@@ -626,6 +637,7 @@ function delegationAssignment(input, actionFingerprint, targetSessionId, targetS
|
|
|
626
637
|
create: {
|
|
627
638
|
title: input.proposal.title,
|
|
628
639
|
workspace: create.workspace,
|
|
640
|
+
...(input.newWorkDefaults ? { defaults: input.newWorkDefaults } : {}),
|
|
629
641
|
},
|
|
630
642
|
};
|
|
631
643
|
}
|
|
@@ -657,6 +669,8 @@ function digest(value) {
|
|
|
657
669
|
function actionFingerprint(input) {
|
|
658
670
|
return digest({
|
|
659
671
|
userText: input.userText,
|
|
672
|
+
...(input.attachments ? { attachments: input.attachments } : {}),
|
|
673
|
+
...(input.newWorkDefaults ? { newWorkDefaults: input.newWorkDefaults } : {}),
|
|
660
674
|
disposition: input.proposal.disposition,
|
|
661
675
|
...(input.proposal.disposition === 'delegate_existing'
|
|
662
676
|
? { candidateRef: input.proposal.candidateRef }
|
|
@@ -687,6 +701,8 @@ function replacementActionFingerprint(input, targetSessionId) {
|
|
|
687
701
|
}
|
|
688
702
|
return digest({
|
|
689
703
|
userText: input.userText,
|
|
704
|
+
...(input.attachments ? { attachments: input.attachments } : {}),
|
|
705
|
+
...(input.newWorkDefaults ? { newWorkDefaults: input.newWorkDefaults } : {}),
|
|
690
706
|
disposition: input.proposal.disposition,
|
|
691
707
|
replacesActionId: input.proposal.replacesActionId,
|
|
692
708
|
target: {
|
|
@@ -747,6 +763,7 @@ function assignmentInputFromRecord(assignment) {
|
|
|
747
763
|
targetSessionName: assignment.targetSessionName,
|
|
748
764
|
disposition: assignment.disposition,
|
|
749
765
|
userText: assignment.userText,
|
|
766
|
+
...(assignment.attachments ? { attachments: assignment.attachments } : {}),
|
|
750
767
|
...(assignment.create ? { create: assignment.create } : {}),
|
|
751
768
|
...(assignment.replacesActionId && assignment.replacesDelegationId
|
|
752
769
|
? {
|
|
@@ -764,6 +781,7 @@ function assignmentInputFromReplacement(replacement) {
|
|
|
764
781
|
targetSessionName: replacement.targetSessionName,
|
|
765
782
|
disposition: replacement.disposition,
|
|
766
783
|
userText: replacement.userText,
|
|
784
|
+
...(replacement.attachments ? { attachments: replacement.attachments } : {}),
|
|
767
785
|
...(replacement.create ? { create: replacement.create } : {}),
|
|
768
786
|
replacesActionId: replacement.replacesActionId,
|
|
769
787
|
replacesDelegationId: replacement.replacesDelegationId,
|
|
@@ -88,7 +88,7 @@ export class HostWorkHubCoordinationCoordinator {
|
|
|
88
88
|
readStopRequest: (delegationId) => this.#stores.readWorkHubStopRequest(delegationId),
|
|
89
89
|
readStopResolution: (delegationId) => this.#stores.readWorkHubStopResolution(delegationId),
|
|
90
90
|
answer: async (input, context) => {
|
|
91
|
-
const outcome = await this.#answer(
|
|
91
|
+
const outcome = await this.#answer(input, context);
|
|
92
92
|
if (!outcome.ok) {
|
|
93
93
|
throw new WorkHubActionEffectFailure(outcome.error.code, outcome.error.message);
|
|
94
94
|
}
|
|
@@ -136,6 +136,7 @@ export class HostWorkHubCoordinationCoordinator {
|
|
|
136
136
|
targetSessionName: input.targetSessionName,
|
|
137
137
|
disposition: input.disposition,
|
|
138
138
|
userText: input.userText,
|
|
139
|
+
...(input.attachments ? { attachments: input.attachments } : {}),
|
|
139
140
|
replacesActionId: input.replacesActionId,
|
|
140
141
|
replacesDelegationId: input.replacesDelegationId,
|
|
141
142
|
replacedTargetSessionId: input.replacedTargetSessionId,
|
|
@@ -443,7 +444,10 @@ export class HostWorkHubCoordinationCoordinator {
|
|
|
443
444
|
turnId: input.turnId,
|
|
444
445
|
execution: {
|
|
445
446
|
kind: 'workhub_coordination',
|
|
446
|
-
inputDigest: digest({
|
|
447
|
+
inputDigest: digest({
|
|
448
|
+
text: input.text,
|
|
449
|
+
...(input.attachments ? { attachments: input.attachments } : {}),
|
|
450
|
+
}),
|
|
447
451
|
},
|
|
448
452
|
archivedMessage: 'WorkHub Coordination Session is unavailable',
|
|
449
453
|
// A recorded summary owns its Turn identity durably but is admitted
|
|
@@ -462,7 +466,13 @@ export class HostWorkHubCoordinationCoordinator {
|
|
|
462
466
|
}
|
|
463
467
|
return recorded.length > 0
|
|
464
468
|
? { kind: 'rejected', outcome: turnIdentityConflict() }
|
|
465
|
-
: {
|
|
469
|
+
: {
|
|
470
|
+
kind: 'ready',
|
|
471
|
+
content: normalizeMessageContent({
|
|
472
|
+
text: input.text,
|
|
473
|
+
...(input.attachments ? { attachments: input.attachments } : {}),
|
|
474
|
+
}),
|
|
475
|
+
};
|
|
466
476
|
},
|
|
467
477
|
}, context);
|
|
468
478
|
return outcome.ok ? { ok: true, result: { turnId: input.turnId } } : outcome;
|