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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
const ACTIVE_DELAY_MS = 100;
|
|
20
|
+
const IDLE_DELAY_MS = 60_000;
|
|
21
|
+
const MAX_BATCH_ITEMS = 64;
|
|
22
|
+
const MAX_BATCH_BYTES = 16 * 1024 * 1024;
|
|
23
|
+
/** Physical cleanup is optional work, admitted only after the Host publishes Ready. */
|
|
24
|
+
export class HostStorageMaintenance {
|
|
25
|
+
#lanes;
|
|
26
|
+
#onError;
|
|
27
|
+
#started = false;
|
|
28
|
+
#draining = false;
|
|
29
|
+
constructor(input) {
|
|
30
|
+
this.#onError = input.onError;
|
|
31
|
+
let after;
|
|
32
|
+
this.#lanes = [
|
|
33
|
+
{
|
|
34
|
+
name: 'artifact upgrade cleanup',
|
|
35
|
+
failures: 0,
|
|
36
|
+
run: async () => {
|
|
37
|
+
const result = await input.artifacts.reclaimUpgradeResidue({
|
|
38
|
+
after,
|
|
39
|
+
maxPaths: MAX_BATCH_ITEMS,
|
|
40
|
+
});
|
|
41
|
+
after = result.nextAfter ?? undefined;
|
|
42
|
+
if (result.failedPaths > 0) {
|
|
43
|
+
this.#report('artifact upgrade cleanup', new Error(`${result.failedPaths} paths remain pending`));
|
|
44
|
+
}
|
|
45
|
+
return result.nextAfter !== null;
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
const context = input.contextOffload;
|
|
50
|
+
if (context)
|
|
51
|
+
this.#lanes.push({
|
|
52
|
+
name: 'context garbage collection',
|
|
53
|
+
failures: 0,
|
|
54
|
+
run: async () => (await context.collectGarbage({
|
|
55
|
+
olderThan: Date.now(),
|
|
56
|
+
maxBlobs: MAX_BATCH_ITEMS,
|
|
57
|
+
maxBytes: MAX_BATCH_BYTES,
|
|
58
|
+
})).hasMore,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
start() {
|
|
62
|
+
if (this.#started || this.#draining)
|
|
63
|
+
return;
|
|
64
|
+
this.#started = true;
|
|
65
|
+
for (const lane of this.#lanes)
|
|
66
|
+
this.#schedule(lane, ACTIVE_DELAY_MS);
|
|
67
|
+
}
|
|
68
|
+
beginDrain() {
|
|
69
|
+
this.#draining = true;
|
|
70
|
+
for (const lane of this.#lanes)
|
|
71
|
+
clearTimeout(lane.timer);
|
|
72
|
+
}
|
|
73
|
+
async close() {
|
|
74
|
+
this.beginDrain();
|
|
75
|
+
await Promise.all(this.#lanes.map((lane) => lane.pending));
|
|
76
|
+
}
|
|
77
|
+
#schedule(lane, delay) {
|
|
78
|
+
if (this.#draining)
|
|
79
|
+
return;
|
|
80
|
+
lane.timer = setTimeout(() => {
|
|
81
|
+
lane.pending = this.#run(lane);
|
|
82
|
+
}, delay);
|
|
83
|
+
lane.timer.unref();
|
|
84
|
+
}
|
|
85
|
+
async #run(lane) {
|
|
86
|
+
if (this.#draining)
|
|
87
|
+
return;
|
|
88
|
+
let delay;
|
|
89
|
+
try {
|
|
90
|
+
const more = await lane.run();
|
|
91
|
+
lane.failures = 0;
|
|
92
|
+
delay = more ? ACTIVE_DELAY_MS : IDLE_DELAY_MS;
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
lane.failures = Math.min(lane.failures + 1, 7);
|
|
96
|
+
delay = Math.min(IDLE_DELAY_MS, 1000 * 2 ** (lane.failures - 1));
|
|
97
|
+
this.#report(lane.name, error);
|
|
98
|
+
}
|
|
99
|
+
this.#schedule(lane, delay);
|
|
100
|
+
}
|
|
101
|
+
#report(name, error) {
|
|
102
|
+
try {
|
|
103
|
+
this.#onError(name, error);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// Diagnostics must not terminate a maintenance lane or poison Host readiness.
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -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;
|
|
@@ -619,7 +629,6 @@ function coordinationSummaryMessages(input) {
|
|
|
619
629
|
turnId: input.turnId,
|
|
620
630
|
ts: ts + 2,
|
|
621
631
|
status: 'completed',
|
|
622
|
-
partialOutputRetained: false,
|
|
623
632
|
},
|
|
624
633
|
];
|
|
625
634
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { WORKHUB_COORDINATION_SESSION_ID } from '@maka/core/session';
|
|
20
|
+
import { WorkHubActionEffectFailure } from './workhub-coordination-action-gate.js';
|
|
21
|
+
/** Preserve canonical ownership when a Coordination message is delegated. */
|
|
22
|
+
export async function copyWorkHubAttachmentsToTarget(store, artifacts, targetSessionId, attachments) {
|
|
23
|
+
const invalid = await artifacts.validateTurnAttachments(WORKHUB_COORDINATION_SESSION_ID, attachments);
|
|
24
|
+
if (invalid)
|
|
25
|
+
throw new WorkHubActionEffectFailure('operation_conflict', invalid);
|
|
26
|
+
const ids = attachments.map((attachment) => {
|
|
27
|
+
if (attachment.ref.kind !== 'session_file')
|
|
28
|
+
throw new Error('Invalid WorkHub attachment');
|
|
29
|
+
return attachment.ref.relativePath;
|
|
30
|
+
});
|
|
31
|
+
const copied = await store.copyConversationArtifacts({
|
|
32
|
+
sourceSessionId: WORKHUB_COORDINATION_SESSION_ID,
|
|
33
|
+
targetSessionId,
|
|
34
|
+
turnIds: [],
|
|
35
|
+
includeArtifactIds: ids,
|
|
36
|
+
});
|
|
37
|
+
return attachments.map((attachment, index) => {
|
|
38
|
+
const relativePath = copied.artifactIds.get(ids[index]);
|
|
39
|
+
if (!relativePath)
|
|
40
|
+
throw new WorkHubActionEffectFailure('operation_conflict', 'WorkHub attachment was not copied');
|
|
41
|
+
return {
|
|
42
|
+
...attachment,
|
|
43
|
+
ref: { kind: 'session_file', sessionId: targetSessionId, relativePath },
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
@@ -240,18 +240,22 @@ class SqliteArtifactStore {
|
|
|
240
240
|
* once its file is gone, and a file that will not go keeps only its own note
|
|
241
241
|
* rather than holding up the ones behind it.
|
|
242
242
|
*/
|
|
243
|
-
async reclaimUpgradeResidue() {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
243
|
+
async reclaimUpgradeResidue(input) {
|
|
244
|
+
if (!Number.isSafeInteger(input.maxPaths) || input.maxPaths < 1 || input.maxPaths > 1024) {
|
|
245
|
+
throw new TypeError('Artifact cleanup path limit must be between 1 and 1024');
|
|
246
|
+
}
|
|
247
|
+
const after = input.after ?? '';
|
|
248
|
+
const maxPaths = input.maxPaths;
|
|
249
|
+
return this.enqueueMutation(async () => {
|
|
250
|
+
const recorded = this.metadataRepository.readUpgradeOrphanPaths(after, maxPaths + 1);
|
|
251
|
+
const selected = recorded.slice(0, maxPaths);
|
|
250
252
|
const directories = new Set();
|
|
251
253
|
const discharged = [];
|
|
254
|
+
let failedPaths = 0;
|
|
252
255
|
try {
|
|
253
|
-
for (const relativePath of
|
|
254
|
-
if (
|
|
256
|
+
for (const relativePath of selected) {
|
|
257
|
+
if (this.metadataRepository.hasRelativePath(relativePath) ||
|
|
258
|
+
!isSafeRelativeArtifactPath(relativePath)) {
|
|
255
259
|
discharged.push(relativePath);
|
|
256
260
|
continue;
|
|
257
261
|
}
|
|
@@ -261,8 +265,10 @@ class SqliteArtifactStore {
|
|
|
261
265
|
directories.add(dirname(target));
|
|
262
266
|
}
|
|
263
267
|
catch (error) {
|
|
264
|
-
if (!isNotFound(error))
|
|
268
|
+
if (!isNotFound(error)) {
|
|
269
|
+
failedPaths += 1;
|
|
265
270
|
continue;
|
|
271
|
+
}
|
|
266
272
|
}
|
|
267
273
|
discharged.push(relativePath);
|
|
268
274
|
}
|
|
@@ -273,6 +279,11 @@ class SqliteArtifactStore {
|
|
|
273
279
|
}
|
|
274
280
|
if (discharged.length > 0)
|
|
275
281
|
this.metadataRepository.forgetUpgradeOrphanPaths(discharged);
|
|
282
|
+
return {
|
|
283
|
+
nextAfter: recorded.length > selected.length ? selected.at(-1) : null,
|
|
284
|
+
processedPaths: selected.length,
|
|
285
|
+
failedPaths,
|
|
286
|
+
};
|
|
276
287
|
});
|
|
277
288
|
}
|
|
278
289
|
async replayExistingArtifactUnlocked(existing, input, canonical) {
|
|
@@ -103,7 +103,7 @@ function createWriterFacade(lease, authority) {
|
|
|
103
103
|
return run(() => store.copyConversationArtifacts(acceptedInput));
|
|
104
104
|
},
|
|
105
105
|
purgeSessionArtifacts: (sessionId) => run(() => store.purgeSessionArtifacts(sessionId)),
|
|
106
|
-
reclaimUpgradeResidue: () => run(() => store.reclaimUpgradeResidue()),
|
|
106
|
+
reclaimUpgradeResidue: (input) => run(() => store.reclaimUpgradeResidue(input)),
|
|
107
107
|
deleteUserArtifactInSession: (sessionId, artifactId) => run(() => store.deleteUserArtifactInSession(sessionId, artifactId)),
|
|
108
108
|
close: () => {
|
|
109
109
|
if (writerByLease.get(lease) === facade)
|
|
@@ -306,7 +306,6 @@ function timestampMs(record) {
|
|
|
306
306
|
}
|
|
307
307
|
return undefined;
|
|
308
308
|
}
|
|
309
|
-
export default ClaudeCodeSessionAdapter;
|
|
310
309
|
/* ------------------------------------------------------------------ *
|
|
311
310
|
* Transcript -> StoredMessage[]
|
|
312
311
|
* ------------------------------------------------------------------ */
|
|
@@ -393,7 +392,6 @@ export function convertTranscript(sessionId, rawRecords) {
|
|
|
393
392
|
status: 'aborted',
|
|
394
393
|
abortedAt: turn.lastTs,
|
|
395
394
|
abortSource: 'claude-code.interrupt',
|
|
396
|
-
partialOutputRetained: true,
|
|
397
395
|
});
|
|
398
396
|
}
|
|
399
397
|
else if (turn.failed) {
|
|
@@ -404,7 +402,6 @@ export function convertTranscript(sessionId, rawRecords) {
|
|
|
404
402
|
ts: turn.lastTs,
|
|
405
403
|
status: 'failed',
|
|
406
404
|
errorClass: 'claude_code_api_error',
|
|
407
|
-
partialOutputRetained: true,
|
|
408
405
|
});
|
|
409
406
|
}
|
|
410
407
|
else if (turn.terminalStop) {
|
|
@@ -414,7 +411,6 @@ export function convertTranscript(sessionId, rawRecords) {
|
|
|
414
411
|
turnId: turn.turnId,
|
|
415
412
|
ts: turn.lastTs,
|
|
416
413
|
status: 'completed',
|
|
417
|
-
partialOutputRetained: true,
|
|
418
414
|
});
|
|
419
415
|
}
|
|
420
416
|
else {
|
|
@@ -426,7 +422,6 @@ export function convertTranscript(sessionId, rawRecords) {
|
|
|
426
422
|
status: 'aborted',
|
|
427
423
|
abortedAt: turn.lastTs,
|
|
428
424
|
abortSource: EXTERNAL_SNAPSHOT_ABORT_SOURCE,
|
|
429
|
-
partialOutputRetained: true,
|
|
430
425
|
});
|
|
431
426
|
}
|
|
432
427
|
turn = undefined;
|