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
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { isNonEmptyUnicodeString, isSha256Digest, SESSION_BUNDLE_ARCHIVE_FORMAT, SESSION_BUNDLE_CANONICALIZATION_VERSION, SESSION_BUNDLE_CODEC_NAME, SESSION_BUNDLE_CODEC_VERSION, SESSION_BUNDLE_COMPRESSION_FORMAT, SESSION_BUNDLE_COMPRESSION_LEVEL, SESSION_BUNDLE_SCHEMA_VERSION, SESSION_BUNDLE_STATE_IDENTITY_PATH, SESSION_BUNDLE_STATE_PATH, SESSION_BUNDLE_WORKSPACE_PATH, SessionBundleFileError, } from './session-bundle-contract.js';
|
|
20
|
+
import { stableJsonStringify } from '@maka/core/canonical-json';
|
|
20
21
|
const MANIFEST_KEYS = ['codec', 'envelope', 'payload', 'schemaVersion', 'stateIdentity'];
|
|
21
22
|
const CODEC_KEYS = [
|
|
22
23
|
'archive',
|
|
@@ -167,25 +168,12 @@ function decodePayload(value) {
|
|
|
167
168
|
};
|
|
168
169
|
}
|
|
169
170
|
function canonicalJson(value) {
|
|
170
|
-
|
|
171
|
-
return
|
|
172
|
-
if (typeof value === 'string')
|
|
173
|
-
return JSON.stringify(value);
|
|
174
|
-
if (typeof value === 'number') {
|
|
175
|
-
if (!Number.isFinite(value))
|
|
176
|
-
throw invalidManifest();
|
|
177
|
-
return JSON.stringify(value);
|
|
171
|
+
try {
|
|
172
|
+
return stableJsonStringify(value);
|
|
178
173
|
}
|
|
179
|
-
|
|
180
|
-
return value ? 'true' : 'false';
|
|
181
|
-
if (Array.isArray(value))
|
|
182
|
-
return `[${value.map((item) => canonicalJson(item)).join(',')}]`;
|
|
183
|
-
if (!isRecord(value))
|
|
174
|
+
catch {
|
|
184
175
|
throw invalidManifest();
|
|
185
|
-
|
|
186
|
-
.sort()
|
|
187
|
-
.map((key) => `${JSON.stringify(key)}:${canonicalJson(value[key])}`)
|
|
188
|
-
.join(',')}}`;
|
|
176
|
+
}
|
|
189
177
|
}
|
|
190
178
|
function hasExactKeys(value, expected) {
|
|
191
179
|
const actual = Object.keys(value);
|
|
@@ -22,8 +22,16 @@ import { dirname, isAbsolute, relative, resolve, sep } from 'node:path';
|
|
|
22
22
|
import { DatabaseSync } from 'node:sqlite';
|
|
23
23
|
import { decodeArtifactRecordJsons } from './artifact-metadata-codec.js';
|
|
24
24
|
import { withArtifactWriterLock } from './artifact-writer-lock.js';
|
|
25
|
+
import { withOfflineContextSnapshot, copyContextSnapshot, validateContextSnapshot, planContextSnapshotFiles, } from './context-offload-snapshot.js';
|
|
26
|
+
import { CONTEXT_OFFLOAD_DATABASE_NAME, CONTEXT_OFFLOAD_VALUES_DIRECTORY_NAME, } from './sqlite-context-offload-store.js';
|
|
25
27
|
import { acquireOperationalStateDatabase, OPERATIONAL_STATE_DATABASE_NAME, } from './operational-state-store.js';
|
|
26
|
-
|
|
28
|
+
import { isSafeStorageId } from './storage-id.js';
|
|
29
|
+
export const SESSION_BUNDLE_STATE_ENTRIES = [
|
|
30
|
+
'artifacts',
|
|
31
|
+
OPERATIONAL_STATE_DATABASE_NAME,
|
|
32
|
+
CONTEXT_OFFLOAD_DATABASE_NAME,
|
|
33
|
+
CONTEXT_OFFLOAD_VALUES_DIRECTORY_NAME,
|
|
34
|
+
];
|
|
27
35
|
export const SESSION_BUNDLE_PROTECTED_ENTRIES = [];
|
|
28
36
|
export class SessionBundleExportError extends Error {
|
|
29
37
|
code;
|
|
@@ -85,6 +93,14 @@ export async function planSessionBundleExport(input) {
|
|
|
85
93
|
}
|
|
86
94
|
includedEntries.push('artifacts');
|
|
87
95
|
}
|
|
96
|
+
const contextFiles = await planContextSnapshotFiles(stateRoot, input.sessionId);
|
|
97
|
+
for (const relativePath of contextFiles) {
|
|
98
|
+
entries.push({ relativePath, kind: 'file', source: 'context_snapshot' });
|
|
99
|
+
}
|
|
100
|
+
if (contextFiles.length > 0)
|
|
101
|
+
includedEntries.push(CONTEXT_OFFLOAD_DATABASE_NAME);
|
|
102
|
+
if (contextFiles.length > 1)
|
|
103
|
+
includedEntries.push(CONTEXT_OFFLOAD_VALUES_DIRECTORY_NAME);
|
|
88
104
|
const allowed = new Set([...SESSION_BUNDLE_STATE_ENTRIES]);
|
|
89
105
|
const excludedEntries = (await readdir(stateRoot)).filter((entry) => !allowed.has(entry)).sort();
|
|
90
106
|
return {
|
|
@@ -98,13 +114,15 @@ export async function planSessionBundleExport(input) {
|
|
|
98
114
|
};
|
|
99
115
|
}
|
|
100
116
|
export async function exportSessionBundleState(input) {
|
|
101
|
-
return withArtifactWriterLock(input.stateRoot, async (stateRoot) => {
|
|
117
|
+
return withOfflineContextSnapshot(input.stateRoot, (contextLocked) => withArtifactWriterLock(input.stateRoot, async (stateRoot) => {
|
|
102
118
|
const plan = await planSessionBundleExport({ ...input, stateRoot });
|
|
103
119
|
await assertDestinationMissing(plan.destinationRoot);
|
|
104
120
|
const stagingRoot = `${plan.destinationRoot}.${process.pid}.${randomUUID()}.tmp`;
|
|
105
121
|
try {
|
|
106
|
-
await mkdir(stagingRoot, { recursive: true });
|
|
122
|
+
await mkdir(stagingRoot, { recursive: true, mode: 0o700 });
|
|
107
123
|
for (const entry of plan.entries) {
|
|
124
|
+
if (entry.source === 'context_snapshot')
|
|
125
|
+
continue;
|
|
108
126
|
const destination = resolveInside(stagingRoot, entry.relativePath);
|
|
109
127
|
if (entry.kind === 'directory') {
|
|
110
128
|
await mkdir(destination, { recursive: true });
|
|
@@ -118,6 +136,8 @@ export async function exportSessionBundleState(input) {
|
|
|
118
136
|
await exportFilteredDatabase(plan.stateRoot, destination, plan.sessionId);
|
|
119
137
|
}
|
|
120
138
|
}
|
|
139
|
+
await copyContextSnapshot(stateRoot, stagingRoot, contextLocked, plan.sessionId);
|
|
140
|
+
await validateContextSnapshot(stagingRoot);
|
|
121
141
|
await mkdir(dirname(plan.destinationRoot), { recursive: true });
|
|
122
142
|
await rename(stagingRoot, plan.destinationRoot);
|
|
123
143
|
return plan;
|
|
@@ -126,7 +146,7 @@ export async function exportSessionBundleState(input) {
|
|
|
126
146
|
await rm(stagingRoot, { recursive: true, force: true }).catch(() => { });
|
|
127
147
|
throw error;
|
|
128
148
|
}
|
|
129
|
-
});
|
|
149
|
+
}));
|
|
130
150
|
}
|
|
131
151
|
async function exportFilteredDatabase(stateRoot, destinationPath, sessionId) {
|
|
132
152
|
const lease = acquireOperationalStateDatabase(stateRoot);
|
|
@@ -209,6 +229,7 @@ async function exportFilteredDatabase(stateRoot, destinationPath, sessionId) {
|
|
|
209
229
|
.get(sessionId);
|
|
210
230
|
if (!session)
|
|
211
231
|
throw new Error(`Filtered session is missing: ${sessionId}`);
|
|
232
|
+
database.exec('PRAGMA journal_mode = DELETE');
|
|
212
233
|
}
|
|
213
234
|
catch (error) {
|
|
214
235
|
try {
|
|
@@ -305,7 +326,7 @@ function assertRootsSeparate(left, right, allowSame) {
|
|
|
305
326
|
}
|
|
306
327
|
}
|
|
307
328
|
function assertSafeSessionId(sessionId) {
|
|
308
|
-
if (
|
|
329
|
+
if (!isSafeStorageId(sessionId)) {
|
|
309
330
|
throw new SessionBundleExportError('invalid_root', `Invalid session id: ${sessionId}`);
|
|
310
331
|
}
|
|
311
332
|
}
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
import { randomUUID } from 'node:crypto';
|
|
20
20
|
import { acquireOperationalStateDatabase, } from './operational-state-store.js';
|
|
21
21
|
import { isProcessLifetimeOwnerReference, } from './process-lifetime-owner.js';
|
|
22
|
+
import { isSafeStorageId } from './storage-id.js';
|
|
22
23
|
export function createSessionCopyCleanupAuthority(input) {
|
|
23
24
|
return new SessionCopyCleanupAuthorityImpl(new SqliteSessionCopyCleanupStore(input.workspaceRoot, input.databaseOptions), input.removeSession, input.resumeSessionCopy, input.processId ?? randomUUID(), input.isOwnerProcessActive, input.processLifetimeOwner);
|
|
24
25
|
}
|
|
@@ -392,7 +393,7 @@ function normalizeSessionId(value) {
|
|
|
392
393
|
if (typeof value !== 'string')
|
|
393
394
|
throw new Error('Invalid Session copy id');
|
|
394
395
|
const normalized = value.trim();
|
|
395
|
-
if (
|
|
396
|
+
if (!isSafeStorageId(normalized)) {
|
|
396
397
|
throw new Error('Invalid Session copy id');
|
|
397
398
|
}
|
|
398
399
|
return normalized;
|
|
@@ -74,3 +74,18 @@ function truncatePreview(text, maxLength = 96) {
|
|
|
74
74
|
return text;
|
|
75
75
|
return `${chars.slice(0, maxLength - 1).join('')}…`;
|
|
76
76
|
}
|
|
77
|
+
/** One Turn's summary, folded message by message in transcript order. */
|
|
78
|
+
export function foldTurnContribution(current, turnId, sequence, message) {
|
|
79
|
+
const contribution = current ?? {
|
|
80
|
+
turnId,
|
|
81
|
+
firstSequence: sequence,
|
|
82
|
+
latestState: null,
|
|
83
|
+
userPromptPreview: null,
|
|
84
|
+
};
|
|
85
|
+
const userPrompt = message.type === 'user' ? (message.displayText ?? message.text).trim() : '';
|
|
86
|
+
return {
|
|
87
|
+
...contribution,
|
|
88
|
+
latestState: message.type === 'turn_state' ? { sequence, message } : contribution.latestState,
|
|
89
|
+
userPromptPreview: contribution.userPromptPreview ?? (userPrompt || null),
|
|
90
|
+
};
|
|
91
|
+
}
|