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,61 @@
|
|
|
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 { execFile } from 'node:child_process';
|
|
20
|
+
import { promisify } from 'node:util';
|
|
21
|
+
const execFileAsync = promisify(execFile);
|
|
22
|
+
const DEFAULT_TIMEOUT_MS = 2 * 60 * 1_000;
|
|
23
|
+
const DEFAULT_TEXT_MAX_BUFFER = 1024 * 1024;
|
|
24
|
+
const DEFAULT_BYTES_MAX_BUFFER = Number.MAX_SAFE_INTEGER;
|
|
25
|
+
/**
|
|
26
|
+
* Runs Git with repository discovery isolated from ambient Git environment
|
|
27
|
+
* variables. Callers may provide a temporary index for patch construction.
|
|
28
|
+
*/
|
|
29
|
+
export async function execGitText(cwd, args, options = {}) {
|
|
30
|
+
const { stdout } = await execFileAsync('git', ['-C', cwd, ...args], {
|
|
31
|
+
env: gitEnvironment(options),
|
|
32
|
+
encoding: 'utf8',
|
|
33
|
+
maxBuffer: options.maxBuffer ?? DEFAULT_TEXT_MAX_BUFFER,
|
|
34
|
+
timeout: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
35
|
+
windowsHide: true,
|
|
36
|
+
});
|
|
37
|
+
return stdout;
|
|
38
|
+
}
|
|
39
|
+
export async function execGitBytes(cwd, args, options = {}) {
|
|
40
|
+
const { stdout } = await execFileAsync('git', ['-C', cwd, ...args], {
|
|
41
|
+
env: gitEnvironment(options),
|
|
42
|
+
encoding: 'buffer',
|
|
43
|
+
maxBuffer: options.maxBuffer ?? DEFAULT_BYTES_MAX_BUFFER,
|
|
44
|
+
timeout: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
45
|
+
windowsHide: true,
|
|
46
|
+
});
|
|
47
|
+
return new Uint8Array(stdout);
|
|
48
|
+
}
|
|
49
|
+
function gitEnvironment(options) {
|
|
50
|
+
const env = { ...process.env, GIT_OPTIONAL_LOCKS: '0' };
|
|
51
|
+
delete env.GIT_DIR;
|
|
52
|
+
delete env.GIT_WORK_TREE;
|
|
53
|
+
delete env.GIT_COMMON_DIR;
|
|
54
|
+
if (options.gitIndexFile === undefined) {
|
|
55
|
+
delete env.GIT_INDEX_FILE;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
env.GIT_INDEX_FILE = options.gitIndexFile;
|
|
59
|
+
}
|
|
60
|
+
return env;
|
|
61
|
+
}
|
|
@@ -16,17 +16,14 @@
|
|
|
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 { copyFile, mkdir, mkdtemp, readdir, realpath, rm, stat } from 'node:fs/promises';
|
|
21
20
|
import { tmpdir } from 'node:os';
|
|
22
21
|
import { isAbsolute, join, normalize, resolve } from 'node:path';
|
|
23
|
-
import { promisify } from 'node:util';
|
|
24
22
|
import { SUBAGENT_WORKSPACE_BINDING_SCHEMA_VERSION, isSubagentWorkspaceBinding, } from '@maka/core/subagent-workspace';
|
|
23
|
+
import { execGitBytes, execGitText } from './git-exec.js';
|
|
25
24
|
import { resolveProjectLocation } from './project-catalog.js';
|
|
26
|
-
const execFileAsync = promisify(execFile);
|
|
27
25
|
const LEASE_PATTERN = /^subagent_worktree_([a-f0-9]{32})$/;
|
|
28
26
|
const WORKTREE_DIRECTORY_PATTERN = /^[a-f0-9]{32}$/;
|
|
29
|
-
const GIT_TIMEOUT_MS = 2 * 60 * 1_000;
|
|
30
27
|
/**
|
|
31
28
|
* Host-owned Git worktree allocator for linked child Sessions.
|
|
32
29
|
*
|
|
@@ -96,8 +93,8 @@ class GitWorktreeChildExecutor {
|
|
|
96
93
|
const currentIndex = (await runGit(binding.worktreePath, ['rev-parse', '--git-path', 'index'])).trim();
|
|
97
94
|
// Preserve staged and committed ignored paths, then overlay all working-tree changes.
|
|
98
95
|
await copyFile(isAbsolute(currentIndex) ? currentIndex : resolve(binding.worktreePath, currentIndex), indexPath);
|
|
99
|
-
const
|
|
100
|
-
await runGit(binding.worktreePath, ['add', '--all', '--'],
|
|
96
|
+
const gitOptions = { gitIndexFile: indexPath };
|
|
97
|
+
await runGit(binding.worktreePath, ['add', '--all', '--'], gitOptions);
|
|
101
98
|
return await runGitBytes(binding.worktreePath, [
|
|
102
99
|
'diff',
|
|
103
100
|
'--cached',
|
|
@@ -108,7 +105,7 @@ class GitWorktreeChildExecutor {
|
|
|
108
105
|
'--no-color',
|
|
109
106
|
binding.baseCommit,
|
|
110
107
|
'--',
|
|
111
|
-
],
|
|
108
|
+
], gitOptions);
|
|
112
109
|
}
|
|
113
110
|
finally {
|
|
114
111
|
await rm(temporary, { recursive: true, force: true });
|
|
@@ -398,35 +395,11 @@ async function gitCurrentBranch(cwd) {
|
|
|
398
395
|
throw error;
|
|
399
396
|
}
|
|
400
397
|
}
|
|
401
|
-
async function runGit(cwd, args,
|
|
402
|
-
|
|
403
|
-
const { stdout } = await execFileAsync('git', ['-C', cwd, ...args], {
|
|
404
|
-
env,
|
|
405
|
-
encoding: 'utf8',
|
|
406
|
-
maxBuffer: 1024 * 1024,
|
|
407
|
-
timeout: GIT_TIMEOUT_MS,
|
|
408
|
-
windowsHide: true,
|
|
409
|
-
});
|
|
410
|
-
return stdout;
|
|
398
|
+
async function runGit(cwd, args, options = {}) {
|
|
399
|
+
return execGitText(cwd, args, options);
|
|
411
400
|
}
|
|
412
|
-
async function runGitBytes(cwd, args,
|
|
413
|
-
|
|
414
|
-
env: gitEnvironment(overrides),
|
|
415
|
-
encoding: 'buffer',
|
|
416
|
-
maxBuffer: Number.MAX_SAFE_INTEGER,
|
|
417
|
-
timeout: GIT_TIMEOUT_MS,
|
|
418
|
-
windowsHide: true,
|
|
419
|
-
});
|
|
420
|
-
return new Uint8Array(stdout);
|
|
421
|
-
}
|
|
422
|
-
function gitEnvironment(overrides) {
|
|
423
|
-
const env = { ...process.env, GIT_OPTIONAL_LOCKS: '0', ...overrides };
|
|
424
|
-
delete env.GIT_DIR;
|
|
425
|
-
delete env.GIT_WORK_TREE;
|
|
426
|
-
delete env.GIT_COMMON_DIR;
|
|
427
|
-
if (overrides.GIT_INDEX_FILE === undefined)
|
|
428
|
-
delete env.GIT_INDEX_FILE;
|
|
429
|
-
return env;
|
|
401
|
+
async function runGitBytes(cwd, args, options = {}) {
|
|
402
|
+
return execGitBytes(cwd, args, options);
|
|
430
403
|
}
|
|
431
404
|
function gitExitCode(error) {
|
|
432
405
|
if (!error || typeof error !== 'object' || !('code' in error))
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
import { decodeGoalAuthorityRecord } from '@maka/core/goal';
|
|
20
20
|
import { acquireOperationalStateDatabase, } from './operational-state-store.js';
|
|
21
21
|
import { assertStorageRootLease, runWithStorageRootLease, StorageRootAuthorityError, } from './root-authority.js';
|
|
22
|
+
import { assertSafeStorageId } from './storage-id.js';
|
|
22
23
|
const writerBrand = Symbol('InteractiveGoalAuthorityWriter');
|
|
23
24
|
const writers = new WeakSet();
|
|
24
25
|
const writerByLease = new WeakMap();
|
|
@@ -217,6 +218,5 @@ function cloneSnapshot(snapshot) {
|
|
|
217
218
|
});
|
|
218
219
|
}
|
|
219
220
|
function requireId(value, label) {
|
|
220
|
-
|
|
221
|
-
throw new TypeError(`${label} identity is invalid`);
|
|
221
|
+
assertSafeStorageId(value, `${label} identity is invalid`);
|
|
222
222
|
}
|
|
@@ -22,7 +22,7 @@ import { clientCapabilityScopeIdentity, decodeClientCapabilitySessionGrant, deco
|
|
|
22
22
|
import { decodeInteractionCanonicalOutcome, decodeInteractionRequest, interactionCanonicalOutcomesEquivalent, isInteractionCanonicalOutcomeValidForRequest, projectInteractionFormRequest, projectInteractionQuestionRequest, } from '@maka/core/interaction';
|
|
23
23
|
import { assertStorageRootLease, runWithStorageRootLease, StorageRootAuthorityError, } from './root-authority.js';
|
|
24
24
|
import { acquireOperationalStateDatabase, } from './operational-state-store.js';
|
|
25
|
-
|
|
25
|
+
import { isSafeStorageId } from './storage-id.js';
|
|
26
26
|
const REMEMBER_SCOPE_ID = /^[0-9a-f]{64}$/;
|
|
27
27
|
export const STORED_INTERACTION_REQUEST_MAX_BYTES = 20 * 1024;
|
|
28
28
|
export const STORED_INTERACTION_OUTCOME_MAX_BYTES = 12 * 1024;
|
|
@@ -512,7 +512,7 @@ function identity(value) {
|
|
|
512
512
|
};
|
|
513
513
|
}
|
|
514
514
|
function assertId(value, source = 'input', message = 'Invalid Interaction identity') {
|
|
515
|
-
if (
|
|
515
|
+
if (!isSafeStorageId(value))
|
|
516
516
|
decodeFailure(source, message);
|
|
517
517
|
return value;
|
|
518
518
|
}
|
|
@@ -222,7 +222,6 @@ export function convertTranscript(sessionId, messages, parts) {
|
|
|
222
222
|
ts: turn.lastTs,
|
|
223
223
|
status: 'failed',
|
|
224
224
|
errorClass: 'opencode_error',
|
|
225
|
-
partialOutputRetained: true,
|
|
226
225
|
});
|
|
227
226
|
}
|
|
228
227
|
else if (turn.aborted) {
|
|
@@ -234,7 +233,6 @@ export function convertTranscript(sessionId, messages, parts) {
|
|
|
234
233
|
status: 'aborted',
|
|
235
234
|
abortedAt: turn.lastTs,
|
|
236
235
|
abortSource: EXTERNAL_SNAPSHOT_ABORT_SOURCE,
|
|
237
|
-
partialOutputRetained: true,
|
|
238
236
|
});
|
|
239
237
|
}
|
|
240
238
|
else if (turn.closed) {
|
|
@@ -244,7 +242,6 @@ export function convertTranscript(sessionId, messages, parts) {
|
|
|
244
242
|
turnId: turn.turnId,
|
|
245
243
|
ts: turn.lastTs,
|
|
246
244
|
status: 'completed',
|
|
247
|
-
partialOutputRetained: true,
|
|
248
245
|
});
|
|
249
246
|
}
|
|
250
247
|
else {
|
|
@@ -259,7 +256,6 @@ export function convertTranscript(sessionId, messages, parts) {
|
|
|
259
256
|
status: 'aborted',
|
|
260
257
|
abortedAt: turn.lastTs,
|
|
261
258
|
abortSource: EXTERNAL_SNAPSHOT_ABORT_SOURCE,
|
|
262
|
-
partialOutputRetained: true,
|
|
263
259
|
});
|
|
264
260
|
}
|
|
265
261
|
turn = undefined;
|
|
@@ -23,13 +23,14 @@ import { dirname, relative, resolve } from 'node:path';
|
|
|
23
23
|
import { DatabaseSync } from 'node:sqlite';
|
|
24
24
|
import { decodeArtifactRecordJsons } from './artifact-metadata-codec.js';
|
|
25
25
|
import { withArtifactWriterLock } from './artifact-writer-lock.js';
|
|
26
|
+
import { withOfflineContextSnapshot, copyContextSnapshot, validateContextSnapshot, } from './context-offload-snapshot.js';
|
|
26
27
|
import { decodeStoredMessage } from './execution-record-codec.js';
|
|
27
28
|
import { acquireOperationalStateDatabase, inspectOperationalStateSchema, OPERATIONAL_STATE_DATABASE_NAME, } from './operational-state-store.js';
|
|
28
29
|
import { assertCurrentOperationalTargetSchema } from './operational-target-schema.js';
|
|
29
30
|
import { SQLITE_SESSION_MESSAGE_CHUNK_BYTES, SQLITE_SESSION_MESSAGE_CHUNK_MARKER, } from './sqlite-session-metadata-schema.js';
|
|
30
31
|
import { syncDirectory, syncDirectoryChain, syncFile } from './stable-storage.js';
|
|
31
32
|
export const OPERATIONAL_BACKUP_FORMAT = 'maka-operational-backup';
|
|
32
|
-
export const OPERATIONAL_BACKUP_SCHEMA_VERSION =
|
|
33
|
+
export const OPERATIONAL_BACKUP_SCHEMA_VERSION = 4;
|
|
33
34
|
export const OPERATIONAL_BACKUP_MANIFEST_FILE = 'operational-backup.json';
|
|
34
35
|
export class OperationalBackupError extends Error {
|
|
35
36
|
code;
|
|
@@ -44,7 +45,7 @@ export async function createOperationalStateBackup(input) {
|
|
|
44
45
|
const destinationRoot = resolve(input.destinationRoot);
|
|
45
46
|
assertSeparateRoots(stateRoot, destinationRoot);
|
|
46
47
|
await assertMissing(destinationRoot, 'backup destination');
|
|
47
|
-
return withArtifactWriterLock(stateRoot, async (canonicalStateRoot) => {
|
|
48
|
+
return withOfflineContextSnapshot(stateRoot, (contextLocked) => withArtifactWriterLock(stateRoot, async (canonicalStateRoot) => {
|
|
48
49
|
assertSeparateRoots(canonicalStateRoot, destinationRoot);
|
|
49
50
|
const stagingRoot = `${destinationRoot}.${process.pid}.${randomUUID()}.tmp`;
|
|
50
51
|
try {
|
|
@@ -64,6 +65,7 @@ export async function createOperationalStateBackup(input) {
|
|
|
64
65
|
if (await pathExists(artifactRoot)) {
|
|
65
66
|
await copyRegularTree(artifactRoot, resolve(stagingRoot, 'artifacts'), artifactRoot, stagingRoot);
|
|
66
67
|
}
|
|
68
|
+
await copyContextSnapshot(canonicalStateRoot, stagingRoot, contextLocked);
|
|
67
69
|
const createdAt = (input.now ?? Date.now)();
|
|
68
70
|
if (!Number.isSafeInteger(createdAt) || createdAt < 0) {
|
|
69
71
|
throw new OperationalBackupError('corrupt_backup', 'Backup creation time is invalid');
|
|
@@ -92,7 +94,7 @@ export async function createOperationalStateBackup(input) {
|
|
|
92
94
|
await rm(stagingRoot, { recursive: true, force: true }).catch(() => { });
|
|
93
95
|
throw error;
|
|
94
96
|
}
|
|
95
|
-
});
|
|
97
|
+
}));
|
|
96
98
|
}
|
|
97
99
|
export async function validateOperationalStateBackup(backupRoot) {
|
|
98
100
|
const root = resolve(backupRoot);
|
|
@@ -111,6 +113,7 @@ export async function validateOperationalStateBackup(backupRoot) {
|
|
|
111
113
|
throw new OperationalBackupError('corrupt_backup', 'Backup file inventory does not match');
|
|
112
114
|
}
|
|
113
115
|
validateSqlite(resolve(root, OPERATIONAL_STATE_DATABASE_NAME), manifest.files);
|
|
116
|
+
await validateContextSnapshot(root);
|
|
114
117
|
return manifest;
|
|
115
118
|
}
|
|
116
119
|
export async function restoreOperationalStateBackup(input) {
|
|
@@ -136,6 +139,7 @@ export async function restoreOperationalStateBackup(input) {
|
|
|
136
139
|
throw new OperationalBackupError('corrupt_backup', 'Restored file inventory does not match');
|
|
137
140
|
}
|
|
138
141
|
validateSqlite(resolve(stagingRoot, OPERATIONAL_STATE_DATABASE_NAME), manifest.files);
|
|
142
|
+
await validateContextSnapshot(stagingRoot);
|
|
139
143
|
await syncDirectoryChain(stagingRoot, stagingRoot);
|
|
140
144
|
await mkdir(dirname(destinationRoot), { recursive: true });
|
|
141
145
|
await rename(stagingRoot, destinationRoot);
|
|
@@ -155,7 +159,7 @@ function decodeManifest(value) {
|
|
|
155
159
|
if (record.format !== OPERATIONAL_BACKUP_FORMAT) {
|
|
156
160
|
throw new OperationalBackupError('corrupt_backup', 'Backup format is invalid');
|
|
157
161
|
}
|
|
158
|
-
if (record.schemaVersion !== OPERATIONAL_BACKUP_SCHEMA_VERSION) {
|
|
162
|
+
if (record.schemaVersion !== 3 && record.schemaVersion !== OPERATIONAL_BACKUP_SCHEMA_VERSION) {
|
|
159
163
|
throw new OperationalBackupError('unsupported_schema', 'Backup schema is unsupported');
|
|
160
164
|
}
|
|
161
165
|
if (!Number.isSafeInteger(record.createdAt) ||
|
|
@@ -184,7 +188,7 @@ function decodeManifest(value) {
|
|
|
184
188
|
}
|
|
185
189
|
return {
|
|
186
190
|
format: OPERATIONAL_BACKUP_FORMAT,
|
|
187
|
-
schemaVersion:
|
|
191
|
+
schemaVersion: record.schemaVersion,
|
|
188
192
|
createdAt: record.createdAt,
|
|
189
193
|
files,
|
|
190
194
|
};
|
|
@@ -16,16 +16,14 @@
|
|
|
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 { realpath, stat } from 'node:fs/promises';
|
|
22
21
|
import { basename, dirname, isAbsolute, join, normalize, relative, resolve, sep } from 'node:path';
|
|
23
|
-
import { promisify } from 'node:util';
|
|
24
22
|
import { markPersisted } from '@maka/core/persisted-value';
|
|
23
|
+
import { execGitText } from './git-exec.js';
|
|
25
24
|
import { hasEnclosingGitEntry } from './git-entry.js';
|
|
26
25
|
import { acquireOperationalStateDatabase, } from './operational-state-store.js';
|
|
27
26
|
import { decodePersistedSessionHeader, normalizeSessionHeader } from './session-store.js';
|
|
28
|
-
const execFileAsync = promisify(execFile);
|
|
29
27
|
export class ProjectPathMismatchError extends Error {
|
|
30
28
|
projectId;
|
|
31
29
|
path;
|
|
@@ -690,26 +688,7 @@ function isPathWithin(root, candidate) {
|
|
|
690
688
|
return path === '' || (!isAbsolute(path) && path !== '..' && !path.startsWith(`..${sep}`));
|
|
691
689
|
}
|
|
692
690
|
async function resolveGitLocation(canonicalPath) {
|
|
693
|
-
const
|
|
694
|
-
delete env.GIT_DIR;
|
|
695
|
-
delete env.GIT_WORK_TREE;
|
|
696
|
-
delete env.GIT_INDEX_FILE;
|
|
697
|
-
delete env.GIT_COMMON_DIR;
|
|
698
|
-
const { stdout: locationOutput } = await execFileAsync('git', [
|
|
699
|
-
'-C',
|
|
700
|
-
canonicalPath,
|
|
701
|
-
'rev-parse',
|
|
702
|
-
'--path-format=absolute',
|
|
703
|
-
'--show-toplevel',
|
|
704
|
-
'--git-dir',
|
|
705
|
-
'--git-common-dir',
|
|
706
|
-
], {
|
|
707
|
-
env,
|
|
708
|
-
encoding: 'utf8',
|
|
709
|
-
maxBuffer: 64 * 1024,
|
|
710
|
-
timeout: 3_000,
|
|
711
|
-
windowsHide: true,
|
|
712
|
-
});
|
|
691
|
+
const locationOutput = await execGitText(canonicalPath, ['rev-parse', '--path-format=absolute', '--show-toplevel', '--git-dir', '--git-common-dir'], { maxBuffer: 64 * 1024, timeoutMs: 3_000 });
|
|
713
692
|
const [worktreeRootRaw, gitDirRaw, commonDirRaw] = locationOutput.trim().split(/\r?\n/);
|
|
714
693
|
if (!worktreeRootRaw || !gitDirRaw || !commonDirRaw) {
|
|
715
694
|
throw new Error(`Git returned an incomplete project location for: ${canonicalPath}`);
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
import { isSafeStorageId } from './storage-id.js';
|
|
20
20
|
export function isRuntimeStorageSafeId(value) {
|
|
21
|
-
return
|
|
21
|
+
return isSafeStorageId(value);
|
|
22
22
|
}
|
|
23
23
|
export function immutableSteeringMessageId(event) {
|
|
24
24
|
const messageId = event.refs?.providerEventId;
|
|
@@ -48,6 +48,7 @@ export async function openRuntimeEventReadPersistence(input) {
|
|
|
48
48
|
readRuntimeEventsBounded: (sessionId, runId, budget) => store.readRuntimeEventsBounded(sessionId, runId, budget),
|
|
49
49
|
readImmutableRuntimeEvents: (sessionId, runId) => store.readImmutableRuntimeEvents(sessionId, runId),
|
|
50
50
|
readSessionRuntimeEvents: (sessionId) => store.readSessionRuntimeEvents(sessionId),
|
|
51
|
+
readSessionRuntimeEventEntries: (sessionId) => store.readSessionRuntimeEventEntries(sessionId),
|
|
51
52
|
}),
|
|
52
53
|
close: () => store.close(),
|
|
53
54
|
};
|
|
@@ -20,7 +20,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
20
20
|
import { isDeepStrictEqual } from 'node:util';
|
|
21
21
|
import { CONNECTION_CATALOG_MAX_CONNECTIONS, decodeCanonicalConnectionCatalogEntry, decodeConnectionName, decodeConnectionSlug, decodeConnectionTarget, decodeConnectionTestSummary, decodeProviderType, decodeRuntimePolicyEntityId, normalizeConnectionCatalogEntryUpdateForProvider, normalizeConnectionModelDiscoveryResult, normalizeCreateCatalogConnectionInput, normalizeRemoveCatalogConnectionInput, normalizeSetDefaultConnectionTargetInput, normalizeUpdateCatalogConnectionInput, } from '@maka/core/runtime-policy';
|
|
22
22
|
import { PROVIDER_REGISTRY, reconcileConnectionAfterModelFetch } from '@maka/core/llm-connections';
|
|
23
|
-
import { modelIdAliasesForProvider } from '@maka/core/model-metadata';
|
|
23
|
+
import { modelIdAliasesForProvider, providerReportsCompleteModelCatalog, } from '@maka/core/model-metadata';
|
|
24
24
|
import { isRetiredProvider } from '@maka/core/provider-registry';
|
|
25
25
|
import { pruneRelayModelProfiles } from '@maka/core/model-thinking';
|
|
26
26
|
import { deepFreeze, nextRevision, record, revision, unique } from './codec.js';
|
|
@@ -325,14 +325,19 @@ export class ConnectionCatalogDocumentOwner {
|
|
|
325
325
|
hasModelInventory: previous.models.length > 0,
|
|
326
326
|
}, result.models, {
|
|
327
327
|
aliases: modelIdAliasesForProvider(previous.providerType),
|
|
328
|
+
authoritative: providerReportsCompleteModelCatalog(previous.providerType),
|
|
328
329
|
});
|
|
329
330
|
// Discovery MOVES a target: a provider's model rename carries the default
|
|
330
331
|
// across by alias. A default outside the selection the reconciler just
|
|
331
332
|
// decided is its own bug — fail closed where it is still attributable.
|
|
332
333
|
const defaultTarget = currentDefaultTarget
|
|
333
|
-
?
|
|
334
|
+
? reconciled.defaultModel
|
|
335
|
+
? { connectionId: previous.connectionId, modelId: reconciled.defaultModel }
|
|
336
|
+
: null
|
|
334
337
|
: current.defaultTarget;
|
|
335
|
-
if (currentDefaultTarget &&
|
|
338
|
+
if (currentDefaultTarget &&
|
|
339
|
+
reconciled.defaultModel &&
|
|
340
|
+
!reconciled.enabledModelIds.includes(reconciled.defaultModel)) {
|
|
336
341
|
throw codecError('invalid_document', 'Model discovery reconciled a default outside its own selection');
|
|
337
342
|
}
|
|
338
343
|
// A refresh only ever migrates a renamed id now, but that rename still
|