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,28 @@
|
|
|
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 SAFE_STORAGE_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
|
|
20
|
+
/** Returns whether a value can safely be used as a persisted storage identity. */
|
|
21
|
+
export function isSafeStorageId(value) {
|
|
22
|
+
return typeof value === 'string' && SAFE_STORAGE_ID_PATTERN.test(value);
|
|
23
|
+
}
|
|
24
|
+
/** Throws a TypeError unless the value is a safe persisted storage identity. */
|
|
25
|
+
export function assertSafeStorageId(value, message = 'Storage identity is invalid') {
|
|
26
|
+
if (!isSafeStorageId(value))
|
|
27
|
+
throw new TypeError(message);
|
|
28
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
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 { TOOL_RESULT_ARCHIVE_EVIDENCE_MAX_BYTES as MAX_BYTES, TOOL_RESULT_ARCHIVE_EVIDENCE_MAX_TRANSITIONS as MAX_TRANSITIONS, } from '@maka/core/tool-result-archive-evidence';
|
|
20
|
+
import { assertStorageRootLease, runWithStorageRootLease, } from './root-authority.js';
|
|
21
|
+
import { decodeRuntimeEvent } from '@maka/core/runtime-event';
|
|
22
|
+
import { decodeAgentRunEvent } from '@maka/core/agent-run';
|
|
23
|
+
import { MODEL_PROJECTION_TARGET_SQL as TARGET } from './sqlite-core-execution-schema.js';
|
|
24
|
+
const TRANSITIONS = 'core_agent_run_events INDEXED BY core_model_projection_target';
|
|
25
|
+
const KIND = "event_type = 'model_projection_transition_recorded'";
|
|
26
|
+
// SQLite may parse the containing JSON, but only these reconstruction fields
|
|
27
|
+
// cross into JS or count toward the evidence budget. Raw tool bytes never do.
|
|
28
|
+
const EVENT_EVIDENCE = `CASE WHEN json_valid(payload_json) THEN json_extract(payload_json,
|
|
29
|
+
'$.id', '$.sessionId', '$.runId', '$.invocationId', '$.turnId', '$.ts', '$.partial',
|
|
30
|
+
'$.author', '$.role', '$.content.kind', '$.content.id', '$.content.name',
|
|
31
|
+
'$.content.modelProjection', '$.content.providerExecuted') END`;
|
|
32
|
+
/** Reader-first foundation; no archive writer or fallback is activated by opening it. */
|
|
33
|
+
export async function openToolResultArchiveEvidenceReader(lease) {
|
|
34
|
+
await assertStorageRootLease(lease, 'interactive', lease.access);
|
|
35
|
+
const { acquireOperationalStateDatabase } = await import('./operational-state-store.js');
|
|
36
|
+
await assertStorageRootLease(lease, 'interactive', lease.access);
|
|
37
|
+
const database = acquireOperationalStateDatabase(lease.canonicalPath, {
|
|
38
|
+
schemaMigration: lease.access === 'read' ? 'require_current' : 'migrate',
|
|
39
|
+
});
|
|
40
|
+
let closed = false;
|
|
41
|
+
return {
|
|
42
|
+
close() {
|
|
43
|
+
if (!closed) {
|
|
44
|
+
closed = true;
|
|
45
|
+
database.close();
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
async read(input) {
|
|
49
|
+
const accepted = { ...input };
|
|
50
|
+
if (closed)
|
|
51
|
+
return { ok: false, reason: 'unavailable' };
|
|
52
|
+
try {
|
|
53
|
+
return await runWithStorageRootLease(lease, 'interactive', lease.access, async () => {
|
|
54
|
+
if (closed)
|
|
55
|
+
return { ok: false, reason: 'unavailable' };
|
|
56
|
+
return database.transaction('read', () => {
|
|
57
|
+
const db = database.database;
|
|
58
|
+
const { sessionId, runtimeEventId } = accepted;
|
|
59
|
+
const eventSize = db
|
|
60
|
+
.prepare(`SELECT length(CAST(${EVENT_EVIDENCE} AS BLOB)) AS bytes FROM runtime_events WHERE event_id = ? AND session_id = ?`)
|
|
61
|
+
.get(runtimeEventId, sessionId);
|
|
62
|
+
if (!eventSize)
|
|
63
|
+
return { ok: false, reason: 'not_found' };
|
|
64
|
+
if (eventSize.bytes === null)
|
|
65
|
+
return { ok: false, reason: 'corrupt' };
|
|
66
|
+
// An unscoped unreadable transition prevents proving completeness.
|
|
67
|
+
if (db
|
|
68
|
+
.prepare(`SELECT 1 FROM ${TRANSITIONS} WHERE ${KIND} AND session_id = ? AND ${TARGET} IS NULL LIMIT 1`)
|
|
69
|
+
.get(sessionId))
|
|
70
|
+
return { ok: false, reason: 'corrupt' };
|
|
71
|
+
const sizes = db
|
|
72
|
+
.prepare(`SELECT run_id, sequence, length(CAST(record_json AS BLOB)) AS bytes FROM ${TRANSITIONS}
|
|
73
|
+
WHERE ${KIND} AND session_id = ? AND ${TARGET} = ? LIMIT ?`)
|
|
74
|
+
.all(sessionId, runtimeEventId, MAX_TRANSITIONS + 1);
|
|
75
|
+
if (sizes.length > MAX_TRANSITIONS)
|
|
76
|
+
return { ok: false, reason: 'too_large' };
|
|
77
|
+
let bytes = Number(eventSize.bytes);
|
|
78
|
+
for (const row of sizes)
|
|
79
|
+
bytes += Number(row.bytes);
|
|
80
|
+
if (!Number.isSafeInteger(bytes) || bytes < 0 || bytes > MAX_BYTES)
|
|
81
|
+
return { ok: false, reason: 'too_large' };
|
|
82
|
+
const raw = db
|
|
83
|
+
.prepare(`SELECT ${EVENT_EVIDENCE} AS evidence_json FROM runtime_events WHERE event_id = ? AND session_id = ?`)
|
|
84
|
+
.get(runtimeEventId, sessionId);
|
|
85
|
+
let event;
|
|
86
|
+
try {
|
|
87
|
+
const [id, sessionId, runId, invocationId, turnId, ts, partial, author, role, kind, callId, name, modelProjection, providerExecuted,] = JSON.parse(String(raw?.evidence_json));
|
|
88
|
+
event = decodeRuntimeEvent({
|
|
89
|
+
id,
|
|
90
|
+
sessionId,
|
|
91
|
+
runId,
|
|
92
|
+
invocationId,
|
|
93
|
+
turnId,
|
|
94
|
+
ts,
|
|
95
|
+
partial,
|
|
96
|
+
author,
|
|
97
|
+
role,
|
|
98
|
+
content: {
|
|
99
|
+
kind,
|
|
100
|
+
id: callId,
|
|
101
|
+
name,
|
|
102
|
+
result: null,
|
|
103
|
+
...(modelProjection === null ? {} : { modelProjection }),
|
|
104
|
+
...(providerExecuted === null ? {} : { providerExecuted }),
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return { ok: false, reason: 'corrupt' };
|
|
110
|
+
}
|
|
111
|
+
if (event.sessionId !== sessionId || event.id !== runtimeEventId)
|
|
112
|
+
return { ok: false, reason: 'corrupt' };
|
|
113
|
+
const read = db.prepare('SELECT record_json FROM core_agent_run_events WHERE session_id = ? AND run_id = ? AND sequence = ?');
|
|
114
|
+
const transitions = [];
|
|
115
|
+
for (const row of sizes) {
|
|
116
|
+
const stored = read.get(sessionId, row.run_id, row.sequence);
|
|
117
|
+
let transition;
|
|
118
|
+
try {
|
|
119
|
+
transition = decodeAgentRunEvent(JSON.parse(String(stored?.record_json)));
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return { ok: false, reason: 'corrupt' };
|
|
123
|
+
}
|
|
124
|
+
if (transition.sessionId !== sessionId)
|
|
125
|
+
return { ok: false, reason: 'corrupt' };
|
|
126
|
+
transitions.push(transition);
|
|
127
|
+
}
|
|
128
|
+
return { ok: true, event, transitions, storedBytes: bytes };
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// Failure to acquire/read the store is not evidence that its records are invalid.
|
|
134
|
+
return { ok: false, reason: 'unavailable' };
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
@@ -16,12 +16,11 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
-
import { execFile } from 'node:child_process';
|
|
20
19
|
import { randomUUID } from 'node:crypto';
|
|
21
20
|
import { constants as fsConstants } from 'node:fs';
|
|
22
21
|
import { lstat, open, realpath, stat } from 'node:fs/promises';
|
|
23
22
|
import { isAbsolute, join, normalize, parse, resolve } from 'node:path';
|
|
24
|
-
import {
|
|
23
|
+
import { execGitText } from './git-exec.js';
|
|
25
24
|
import { hasEnclosingGitEntry } from './git-entry.js';
|
|
26
25
|
import { publishMarkerFile, readBoundedMarkerFile } from './marker-file.js';
|
|
27
26
|
export const WORKSPACE_MARKER_FILE = '.maka-workspace.json';
|
|
@@ -29,7 +28,6 @@ export const WORKSPACE_MARKER_SCHEMA_VERSION = 1;
|
|
|
29
28
|
export const WORKSPACE_IDENTITY_PREFIX = 'workspace:v1:';
|
|
30
29
|
const MAX_WORKSPACE_MARKER_BYTES = 4_096;
|
|
31
30
|
const MAX_GIT_EXCLUDE_BYTES = 1024 * 1024;
|
|
32
|
-
const execFileAsync = promisify(execFile);
|
|
33
31
|
export class WorkspaceIdentityError extends Error {
|
|
34
32
|
code;
|
|
35
33
|
constructor(code, message, options) {
|
|
@@ -101,18 +99,7 @@ async function createWorkspaceMarker(snapshot, workspaceId) {
|
|
|
101
99
|
async function ensureWorkspaceMarkerIgnored(workspacePath) {
|
|
102
100
|
if (!(await hasEnclosingGitEntry(workspacePath)))
|
|
103
101
|
return;
|
|
104
|
-
const
|
|
105
|
-
delete env.GIT_DIR;
|
|
106
|
-
delete env.GIT_WORK_TREE;
|
|
107
|
-
delete env.GIT_INDEX_FILE;
|
|
108
|
-
delete env.GIT_COMMON_DIR;
|
|
109
|
-
const { stdout } = await execFileAsync('git', ['-C', workspacePath, 'rev-parse', '--path-format=absolute', '--git-path', 'info/exclude'], {
|
|
110
|
-
env,
|
|
111
|
-
encoding: 'utf8',
|
|
112
|
-
maxBuffer: 64 * 1024,
|
|
113
|
-
timeout: 3_000,
|
|
114
|
-
windowsHide: true,
|
|
115
|
-
});
|
|
102
|
+
const stdout = await execGitText(workspacePath, ['rev-parse', '--path-format=absolute', '--git-path', 'info/exclude'], { maxBuffer: 64 * 1024, timeoutMs: 3_000 });
|
|
116
103
|
const excludePath = stdout.trim();
|
|
117
104
|
if (!isAbsolute(excludePath)) {
|
|
118
105
|
throw new Error(`Git returned a non-absolute exclude path: ${excludePath}`);
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
const workspaceBaselineAuthorityWriters = new WeakMap();
|
|
20
|
-
export function registerWorkspaceBaselineAuthorityWriterInternal(store, writer, successorWriter, terminalWriter, bindStorageRoot,
|
|
20
|
+
export function registerWorkspaceBaselineAuthorityWriterInternal(store, writer, successorWriter, terminalWriter, bindStorageRoot, readActiveManagedMutation) {
|
|
21
21
|
if (workspaceBaselineAuthorityWriters.has(store)) {
|
|
22
22
|
throw new Error('Workspace baseline authority writer is already registered');
|
|
23
23
|
}
|
|
@@ -25,7 +25,6 @@ export function registerWorkspaceBaselineAuthorityWriterInternal(store, writer,
|
|
|
25
25
|
writer,
|
|
26
26
|
successorWriter,
|
|
27
27
|
terminalWriter,
|
|
28
|
-
readHead,
|
|
29
28
|
readActiveManagedMutation,
|
|
30
29
|
bindStorageRoot,
|
|
31
30
|
});
|
|
@@ -36,12 +35,6 @@ export function readActiveManagedMutationInternal(store, workspaceInstanceId) {
|
|
|
36
35
|
throw new Error('Managed mutation reservation reader is unavailable');
|
|
37
36
|
return registration.readActiveManagedMutation(workspaceInstanceId);
|
|
38
37
|
}
|
|
39
|
-
export function readWorkspaceHeadInternal(store, workspaceId, workspaceEpochId) {
|
|
40
|
-
const registration = workspaceBaselineAuthorityWriters.get(store);
|
|
41
|
-
if (!registration)
|
|
42
|
-
throw new Error('Workspace baseline authority reader is unavailable');
|
|
43
|
-
return registration.readHead(workspaceId, workspaceEpochId);
|
|
44
|
-
}
|
|
45
38
|
/**
|
|
46
39
|
* Storage-internal authority seam. This module is deliberately absent from the
|
|
47
40
|
* @maka/storage package exports. The schema-9 reader, migration, and projection
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"./artifact-stores": "./dist/artifact-stores.js",
|
|
11
11
|
"./config-transfer": "./dist/config-transfer.js",
|
|
12
12
|
"./context-offload-store": "./dist/context-offload-store.js",
|
|
13
|
+
"./tool-result-archive-evidence": "./dist/tool-result-archive-evidence.js",
|
|
13
14
|
"./credential-store": "./dist/credential-store.js",
|
|
14
15
|
"./daily-review-authority": "./dist/daily-review-authority.js",
|
|
15
16
|
"./deep-research-authority": "./dist/deep-research-authority.js",
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
"./session-bundle-policy": "./dist/session-bundle-policy.js",
|
|
46
47
|
"./session-copy-cleanup": "./dist/session-copy-cleanup.js",
|
|
47
48
|
"./session-todo-authority": "./dist/session-todo-authority.js",
|
|
49
|
+
"./session-message-projection": "./dist/session-message-projection.js",
|
|
48
50
|
"./session-store": "./dist/session-store.js",
|
|
49
51
|
"./settings-store": "./dist/settings-store.js",
|
|
50
52
|
"./shell-run-authority": "./dist/shell-run-authority.js",
|