maka-agent 0.2.0-dev.23.20260906 → 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/acp/maka-acp-agent.js +2 -1
- package/dist/acp/session-configuration.js +143 -0
- package/dist/acp/session-registry.js +90 -4
- package/dist/cli-core.js +2 -0
- package/dist/pi-transcript-tools.js +6 -0
- package/dist/pi-transcript.js +5 -12
- package/dist/pi-tui-layout.js +56 -10
- package/dist/pi-tui-pickers.js +102 -1
- package/dist/pi-tui-runner.js +230 -46
- package/dist/pi-tui-todo.js +221 -0
- package/dist/pi-tui-transcript-viewer.js +134 -7
- package/dist/runtime-host-cli-context.js +224 -78
- package/dist/runtime-host-cli-installation.js +8 -2
- package/dist/runtime-host-cli.js +31 -1
- package/dist/runtime-host-handoff-surface.js +106 -0
- package/dist/runtime-host-installed-update-bootstrap.js +13 -0
- package/dist/runtime-host-installed-update-coordinator.js +33 -0
- package/dist/runtime-host-lifecycle-transaction.js +9 -1
- package/dist/runtime-host-local-handoff.js +48 -5
- package/dist/runtime-host-local-managed-activation.js +84 -0
- package/dist/runtime-host-local-source-retirement.js +18 -2
- package/dist/runtime-host-managed-lifecycle-manager.js +1 -0
- package/dist/runtime-host-operator-retirement.js +50 -0
- package/dist/runtime-host-service-manager.js +3 -3
- package/dist/runtime-host-session-channel.js +13 -0
- package/dist/runtime-host-session-driver.js +46 -26
- package/dist/runtime-host-session-update.js +62 -0
- package/dist/runtime-host-tui-command.js +38 -73
- package/dist/runtime-host-tui-context.js +1 -0
- package/dist/runtime-host-tui-owner.js +226 -0
- package/dist/tui-copy-catalog.js +219 -6
- package/dist/tui-host-owner-copy.js +24 -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/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/canonical-runtime-event.js +3 -1
- 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-failure.js +40 -0
- package/node_modules/@maka/core/dist/model-metadata.generated.js +4 -4
- package/node_modules/@maka/core/dist/model-metadata.js +7 -3
- package/node_modules/@maka/core/dist/model-web-search.js +5 -4
- package/node_modules/@maka/core/dist/provider-registry.js +45 -4
- package/node_modules/@maka/core/dist/record-schema.js +9 -2
- 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/runtime-boundary.js +31 -11
- package/node_modules/@maka/core/dist/runtime-event.js +37 -6
- package/node_modules/@maka/core/dist/runtime-handoff.js +98 -0
- package/node_modules/@maka/core/dist/runtime-invocation.js +1 -1
- package/node_modules/@maka/core/dist/runtime-logical-execution.js +112 -0
- package/node_modules/@maka/core/dist/session.js +84 -56
- package/node_modules/@maka/core/dist/slash-command-catalog.js +3 -0
- package/node_modules/@maka/core/dist/tool-result-archive-evidence.js +20 -0
- package/node_modules/@maka/core/dist/tool-result-record-schema.js +2 -1
- package/node_modules/@maka/core/dist/usage-record-schema.js +26 -35
- package/node_modules/@maka/core/package.json +5 -0
- package/node_modules/@maka/eval/dist/experiment-directory.js +4 -13
- package/node_modules/@maka/mcp/dist/index.js +131 -1
- package/node_modules/@maka/runtime/dist/agent-run-inspect.js +0 -13
- package/node_modules/@maka/runtime/dist/agent-run.js +351 -105
- package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +29 -13
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +109 -34
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +184 -183
- 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/context-budget.js +14 -9
- package/node_modules/@maka/runtime/dist/conversation-copy.js +158 -15
- package/node_modules/@maka/runtime/dist/github-copilot-oauth-enrollment.js +3 -3
- package/node_modules/@maka/runtime/dist/goal-continuation.js +36 -4
- package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +18 -9
- package/node_modules/@maka/runtime/dist/history-compact-summarizer.js +30 -22
- package/node_modules/@maka/runtime/dist/history-compaction.js +29 -4
- package/node_modules/@maka/runtime/dist/ledger-tool-result-archive-reader.js +174 -0
- package/node_modules/@maka/runtime/dist/mcp-tools.js +7 -2
- package/node_modules/@maka/runtime/dist/message-authority.js +9 -0
- package/node_modules/@maka/runtime/dist/model-adapter.js +19 -98
- package/node_modules/@maka/runtime/dist/model-factory.js +19 -81
- package/node_modules/@maka/runtime/dist/model-fetcher.js +49 -2
- package/node_modules/@maka/runtime/dist/model-history.js +0 -112
- package/node_modules/@maka/runtime/dist/model-runtime.js +85 -111
- package/node_modules/@maka/runtime/dist/native-web-search-tool.js +2 -1
- package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +2 -2
- package/node_modules/@maka/runtime/dist/opencode-session-header.js +4 -2
- 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-error-classification.js +84 -123
- package/node_modules/@maka/runtime/dist/provider-request-telemetry.js +76 -109
- package/node_modules/@maka/runtime/dist/request-shape.js +23 -0
- package/node_modules/@maka/runtime/dist/run-handoff-gate.js +97 -0
- package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +83 -55
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +121 -159
- package/node_modules/@maka/runtime/dist/runtime-kernel.js +157 -112
- package/node_modules/@maka/runtime/dist/runtime-ledger-repair.js +160 -79
- package/node_modules/@maka/runtime/dist/runtime-read-model.js +30 -89
- package/node_modules/@maka/runtime/dist/runtime-resume.js +80 -4
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +5 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +171 -288
- package/node_modules/@maka/runtime/dist/session-projection-helpers.js +0 -27
- 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/subscription-model-fetch.js +3 -4
- package/node_modules/@maka/runtime/dist/test-connection.js +16 -17
- 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-encoding.js +38 -0
- 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/dist/tool-runtime.js +3 -61
- package/node_modules/@maka/runtime/package.json +2 -0
- package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +35 -0
- package/node_modules/@maka/runtime-host/dist/client/connect-or-spawn.js +9 -1
- package/node_modules/@maka/runtime-host/dist/client/connection.js +3 -0
- package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +179 -0
- package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +275 -0
- package/node_modules/@maka/runtime-host/dist/client/host-retirement.js +26 -5
- package/node_modules/@maka/runtime-host/dist/client/index.js +2 -0
- package/node_modules/@maka/runtime-host/dist/client/launcher.js +3 -0
- package/node_modules/@maka/runtime-host/dist/client/remote-compatibility-error.js +2 -0
- package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +46 -5
- 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/index.js +2 -1
- package/node_modules/@maka/runtime-host/dist/operator/managed-deployment.js +1 -3
- package/node_modules/@maka/runtime-host/dist/operator/retirement-cancellation.js +20 -0
- 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/host-status.js +21 -12
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +29 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +1 -0
- 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/session-continuity.js +40 -20
- package/node_modules/@maka/runtime-host/dist/protocol/session-transcript.js +0 -5
- package/node_modules/@maka/runtime-host/dist/protocol/session-turns.js +29 -58
- package/node_modules/@maka/runtime-host/dist/protocol/turn.js +11 -1
- package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +31 -2
- package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +1 -0
- package/node_modules/@maka/runtime-host/dist/server/agent-graph-coordinator.js +0 -3
- package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +19 -4
- package/node_modules/@maka/runtime-host/dist/server/connection-session.js +7 -6
- package/node_modules/@maka/runtime-host/dist/server/execution-artifacts.js +32 -32
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +144 -33
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +5 -5
- package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +45 -16
- package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +40 -1
- package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +96 -17
- package/node_modules/@maka/runtime-host/dist/server/host-residency-registry.js +13 -7
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-admission-registry.js +3 -1
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +124 -62
- package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +47 -22
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +76 -6
- 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/root-turn-coordinator.js +325 -73
- package/node_modules/@maka/runtime-host/dist/server/scheduled-task-coordinator.js +37 -2
- package/node_modules/@maka/runtime-host/dist/server/serial-outbound-writer.js +45 -3
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +50 -7
- package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +87 -25
- 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 +12 -55
- package/node_modules/@maka/runtime-host/dist/server/session-sidecar-purge.js +1 -16
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-pager.js +0 -1
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +460 -70
- package/node_modules/@maka/runtime-host/dist/server/shared-session-transcript.js +1 -1
- package/node_modules/@maka/runtime-host/dist/server/storage-maintenance.js +109 -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 -4
- package/node_modules/@maka/runtime-host/dist/server/workhub-message-attachments.js +46 -0
- package/node_modules/@maka/storage/dist/artifact-store.js +21 -10
- package/node_modules/@maka/storage/dist/artifact-stores.js +1 -1
- package/node_modules/@maka/storage/dist/claude-code-session-adapter.js +0 -5
- package/node_modules/@maka/storage/dist/codex-session-adapter.js +284 -198
- package/node_modules/@maka/storage/dist/context-offload-snapshot.js +325 -0
- package/node_modules/@maka/storage/dist/execution-stores.js +9 -7
- package/node_modules/@maka/storage/dist/file-session-repository.js +1012 -0
- 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/opencode-session-adapter.js +0 -4
- package/node_modules/@maka/storage/dist/operational-state-backup.js +9 -5
- 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-event-persistence.js +1 -0
- package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +8 -3
- package/node_modules/@maka/storage/dist/runtime-transcript-query.js +308 -0
- 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 +26 -5
- package/node_modules/@maka/storage/dist/session-copy-cleanup.js +2 -1
- package/node_modules/@maka/storage/dist/session-message-projection.js +15 -0
- package/node_modules/@maka/storage/dist/session-repository.js +767 -0
- package/node_modules/@maka/storage/dist/session-store.js +25 -99
- package/node_modules/@maka/storage/dist/sqlite-artifact-metadata.js +10 -3
- package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +24 -8
- package/node_modules/@maka/storage/dist/sqlite-core-execution-schema.js +7 -1
- package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +44 -1
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +130 -27
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +109 -892
- package/node_modules/@maka/storage/dist/storage-id.js +28 -0
- package/node_modules/@maka/storage/dist/tool-result-archive-evidence.js +138 -0
- 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/node_modules/@maka/storage/package.json +2 -0
- package/package.json +1 -1
|
@@ -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 } : {}),
|
|
@@ -246,11 +246,16 @@ export class HostMessageCoordinator {
|
|
|
246
246
|
}
|
|
247
247
|
bindRun(identity) {
|
|
248
248
|
const state = this.#state(identity.sessionId);
|
|
249
|
-
const exactPreStartStop = state.stopFence !== undefined &&
|
|
249
|
+
const exactPreStartStop = state.stopFence !== undefined &&
|
|
250
|
+
state.reservedRoot !== undefined &&
|
|
251
|
+
sameRun(state.stopFence.identity, state.reservedRoot);
|
|
250
252
|
if (state.phase !== 'open' && !exactPreStartStop) {
|
|
251
253
|
throw new RuntimeMessageAuthorityInvariantError('Message Run bound while admission was closed');
|
|
252
254
|
}
|
|
253
|
-
if (!state.reservedRoot ||
|
|
255
|
+
if (!state.reservedRoot ||
|
|
256
|
+
state.reservedRoot.turnId !== identity.turnId ||
|
|
257
|
+
state.reservedRoot.expectedRunId !== identity.runId ||
|
|
258
|
+
state.run) {
|
|
254
259
|
throw new RuntimeMessageAuthorityInvariantError(`Message Run ${identity.runId} was not the exact reserved root identity`);
|
|
255
260
|
}
|
|
256
261
|
const run = { ...identity, generation: state.generation, released: false };
|
|
@@ -273,9 +278,66 @@ export class HostMessageCoordinator {
|
|
|
273
278
|
if (state.run || state.transition) {
|
|
274
279
|
throw new RuntimeMessageAuthorityInvariantError('Cannot reserve a root Turn during live ownership');
|
|
275
280
|
}
|
|
276
|
-
state.reservedRoot = { ...identity };
|
|
281
|
+
state.reservedRoot = { ...identity, expectedRunId: identity.runId };
|
|
277
282
|
state.phase = 'open';
|
|
278
283
|
}
|
|
284
|
+
/** Change physical ownership, not the logical queue generation or Stop identity. */
|
|
285
|
+
async advanceHandoffRun(identity, successorRunId, admission) {
|
|
286
|
+
await this.#sessionAdmission.runAdmitted(identity.sessionId, admission, async () => {
|
|
287
|
+
const logical = await this.#durableProof.readLogicalExecution(identity);
|
|
288
|
+
const state = this.#requireState(identity.sessionId);
|
|
289
|
+
if (!logical?.pendingHandoff ||
|
|
290
|
+
logical.pendingHandoff.successorRunId !== successorRunId ||
|
|
291
|
+
!state.reservedRoot ||
|
|
292
|
+
!sameRun(state.reservedRoot, identity) ||
|
|
293
|
+
state.transition ||
|
|
294
|
+
(state.phase !== 'open' && !state.stopFence) ||
|
|
295
|
+
state.inFlight.size !== 0 ||
|
|
296
|
+
(state.run
|
|
297
|
+
? !state.run.released || state.run.runId !== logical.tip.runId
|
|
298
|
+
: state.reservedRoot.expectedRunId !== identity.runId)) {
|
|
299
|
+
throw new RuntimeMessageAuthorityInvariantError('Physical handoff lacks a sealed released root owner');
|
|
300
|
+
}
|
|
301
|
+
state.run = undefined;
|
|
302
|
+
state.reservedRoot.expectedRunId = successorRunId;
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
async #readDetachableHandoff(identity) {
|
|
306
|
+
const logical = await this.#durableProof.readLogicalExecution(identity);
|
|
307
|
+
const state = this.#requireState(identity.sessionId);
|
|
308
|
+
if (state.stopFence || state.pendingInterrupts.size !== 0)
|
|
309
|
+
return undefined;
|
|
310
|
+
if (!logical?.pendingHandoff ||
|
|
311
|
+
!state.reservedRoot ||
|
|
312
|
+
!sameRun(state.reservedRoot, identity) ||
|
|
313
|
+
!state.run?.released ||
|
|
314
|
+
state.run.runId !== logical.tip.runId ||
|
|
315
|
+
state.inFlight.size !== 0 ||
|
|
316
|
+
state.transition) {
|
|
317
|
+
throw new RuntimeMessageAuthorityInvariantError('Handoff cannot detach unsettled Message ownership');
|
|
318
|
+
}
|
|
319
|
+
return state;
|
|
320
|
+
}
|
|
321
|
+
async handoffResidencies(identity, admission) {
|
|
322
|
+
return this.#sessionAdmission.runAdmitted(identity.sessionId, admission, async () => {
|
|
323
|
+
const state = await this.#readDetachableHandoff(identity);
|
|
324
|
+
return state && allLiveEntries(state).map((entry) => entry.residency);
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
async detachHandoffRoot(identity, admission) {
|
|
328
|
+
await this.#sessionAdmission.runAdmitted(identity.sessionId, admission, async () => {
|
|
329
|
+
const state = await this.#readDetachableHandoff(identity);
|
|
330
|
+
if (!state)
|
|
331
|
+
throw new RuntimeMessageAuthorityInvariantError('Stop took ownership before handoff detach');
|
|
332
|
+
// Confirmed admissions remain durable for the next Host. Only local leases
|
|
333
|
+
// and handles retire; do not write cancellation receipts or a queue fence.
|
|
334
|
+
this.#retractQueued(state);
|
|
335
|
+
state.run = undefined;
|
|
336
|
+
state.reservedRoot = undefined;
|
|
337
|
+
state.phase = 'closed';
|
|
338
|
+
this.#maybeReclaim(identity.sessionId, state);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
279
341
|
abandonRootReservation(identity) {
|
|
280
342
|
const state = this.#requireState(identity.sessionId);
|
|
281
343
|
if (!state.reservedRoot || !sameRun(state.reservedRoot, identity) || state.run) {
|
|
@@ -296,7 +358,8 @@ export class HostMessageCoordinator {
|
|
|
296
358
|
if (!state.reservedRoot ||
|
|
297
359
|
!sameRun(state.reservedRoot, identity) ||
|
|
298
360
|
!run ||
|
|
299
|
-
|
|
361
|
+
run.turnId !== identity.turnId ||
|
|
362
|
+
run.runId !== state.reservedRoot.expectedRunId ||
|
|
300
363
|
!run.released) {
|
|
301
364
|
throw new RuntimeMessageAuthorityInvariantError('Terminal transition requires a released exact root owner');
|
|
302
365
|
}
|
|
@@ -344,7 +407,7 @@ export class HostMessageCoordinator {
|
|
|
344
407
|
state.generation += 1;
|
|
345
408
|
for (const entry of allLiveEntries(state))
|
|
346
409
|
entry.generation = state.generation;
|
|
347
|
-
state.reservedRoot = { ...identity };
|
|
410
|
+
state.reservedRoot = { ...identity, expectedRunId: identity.runId };
|
|
348
411
|
state.phase = 'open';
|
|
349
412
|
this.#mutated(state);
|
|
350
413
|
}
|
|
@@ -387,6 +450,7 @@ export class HostMessageCoordinator {
|
|
|
387
450
|
const provenRootMessages = [];
|
|
388
451
|
const provenSteeringMessages = [];
|
|
389
452
|
const admissions = await this.#admissions.listMessageAdmissions(input.sessionId);
|
|
453
|
+
let logicalRunIds;
|
|
390
454
|
for (const messageId of new Set(input.messageIds)) {
|
|
391
455
|
messageIds.add(messageId);
|
|
392
456
|
provenRootMessages.push(await this.#readProvenRootMessage(input, messageId));
|
|
@@ -396,7 +460,13 @@ export class HostMessageCoordinator {
|
|
|
396
460
|
continue;
|
|
397
461
|
}
|
|
398
462
|
const proof = await this.#durableProof.readImmutableSteeringMessageProof(input.sessionId, admission.messageId);
|
|
399
|
-
if (proof?.event.turnId === input.turnId &&
|
|
463
|
+
if (proof?.event.turnId === input.turnId &&
|
|
464
|
+
proof.event.runId !== input.runId &&
|
|
465
|
+
!logicalRunIds) {
|
|
466
|
+
logicalRunIds = (await this.#durableProof.readLogicalExecution(input))?.runIds ?? [];
|
|
467
|
+
}
|
|
468
|
+
if (proof?.event.turnId === input.turnId &&
|
|
469
|
+
(proof.event.runId === input.runId || logicalRunIds?.includes(proof.event.runId))) {
|
|
400
470
|
messageIds.add(admission.messageId);
|
|
401
471
|
provenSteeringMessages.push({
|
|
402
472
|
messageId: admission.messageId,
|
|
@@ -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({
|