@myagentroam/node 0.1.4 → 0.1.7
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 +9 -1
- package/dist/capabilities.d.ts +2 -0
- package/dist/capabilities.js +15 -4
- package/dist/claude-agent-sdk.d.ts +3 -1
- package/dist/claude-agent-sdk.js +9 -2
- package/dist/claude-channel.js +0 -1
- package/dist/codex-app-server.d.ts +1 -0
- package/dist/codex-app-server.js +8 -1
- package/dist/config.d.ts +3 -0
- package/dist/config.js +18 -2
- package/dist/connector/node-connector-options.d.ts +3 -0
- package/dist/connector/node-connector-options.js +0 -1
- package/dist/connector/node-operation-router.js +0 -1
- package/dist/connector.d.ts +3 -0
- package/dist/connector.js +109 -7
- package/dist/control-outbound-scheduler.js +0 -1
- package/dist/database.d.ts +4 -0
- package/dist/database.js +14 -9
- package/dist/event-buffer.js +0 -1
- package/dist/fake-runner.js +0 -1
- package/dist/health.js +0 -1
- package/dist/main.js +6 -1
- package/dist/migrations/v001.js +0 -1
- package/dist/migrations/v002.js +0 -1
- package/dist/migrations/v003.d.ts +4 -0
- package/dist/migrations/v003.js +44 -0
- package/dist/native-jsonl-reader.js +0 -1
- package/dist/native-session-history.d.ts +19 -1
- package/dist/native-session-history.js +65 -3
- package/dist/opencode-runtime.d.ts +33 -0
- package/dist/opencode-runtime.js +80 -0
- package/dist/opencode-server.d.ts +47 -0
- package/dist/opencode-server.js +250 -0
- package/dist/operational.js +10 -3
- package/dist/process-tree.js +0 -1
- package/dist/runner/abstract-runner.d.ts +7 -2
- package/dist/runner/abstract-runner.js +17 -2
- package/dist/runner/claude/managed-run-controller.js +20 -1
- package/dist/runner/claude-code-runner.d.ts +3 -1
- package/dist/runner/claude-code-runner.js +26 -8
- package/dist/runner/codex/conversation-parser.d.ts +1 -3
- package/dist/runner/codex/conversation-parser.js +174 -34
- package/dist/runner/codex/managed-run-controller.d.ts +2 -1
- package/dist/runner/codex/managed-run-controller.js +13 -4
- package/dist/runner/codex-runner.d.ts +4 -0
- package/dist/runner/codex-runner.js +27 -4
- package/dist/runner/fake-test-runner.js +0 -1
- package/dist/runner/opencode/conversation-parser.d.ts +27 -0
- package/dist/runner/opencode/conversation-parser.js +217 -0
- package/dist/runner/opencode/managed-run-controller.d.ts +76 -0
- package/dist/runner/opencode/managed-run-controller.js +451 -0
- package/dist/runner/opencode-runner.d.ts +60 -0
- package/dist/runner/opencode-runner.js +330 -0
- package/dist/runner/runner-registry.d.ts +3 -1
- package/dist/runner/runner-registry.js +12 -3
- package/dist/runner-command-engine.js +0 -1
- package/dist/runner-profiles.d.ts +4 -0
- package/dist/runner-profiles.js +76 -3
- package/dist/runner-usage.js +0 -1
- package/dist/runtime-state.js +20 -9
- package/dist/service/attachment-domain-state.js +0 -1
- package/dist/service/conversation-history-service.js +0 -1
- package/dist/service/external-session-resume-service.js +0 -1
- package/dist/service/fake-managed-run-service.js +0 -1
- package/dist/service/managed-runner-session-service.d.ts +3 -1
- package/dist/service/managed-runner-session-service.js +8 -4
- package/dist/service/native-session-projection-service.d.ts +2 -1
- package/dist/service/native-session-projection-service.js +8 -5
- package/dist/service/native-session-watch-service.js +0 -1
- package/dist/service/node-connection-lifecycle-service.js +3 -2
- package/dist/service/node-control-channel.d.ts +1 -1
- package/dist/service/node-control-channel.js +5 -4
- package/dist/service/node-control-message-service.js +0 -1
- package/dist/service/node-request-service.js +0 -1
- package/dist/service/node-run-event-bridge.d.ts +2 -0
- package/dist/service/node-run-event-bridge.js +4 -1
- package/dist/service/node-terminal-channel.js +16 -10
- package/dist/service/node-upgrade-coordinator.d.ts +29 -0
- package/dist/service/node-upgrade-coordinator.js +137 -0
- package/dist/service/node-workspace-coordinator.js +0 -1
- package/dist/service/run-attachment-service.js +0 -1
- package/dist/service/run-domain-state.js +0 -1
- package/dist/service/run-event-service.js +0 -1
- package/dist/service/run-workbench-service.js +0 -1
- package/dist/service/runner-channel-message-service.js +0 -1
- package/dist/service/runner-interaction-service.js +2 -1
- package/dist/service/runner-service.d.ts +5 -4
- package/dist/service/runner-service.js +19 -6
- package/dist/service/session-catalog-service.d.ts +16 -1
- package/dist/service/session-catalog-service.js +82 -3
- package/dist/service/session-command-service.js +0 -1
- package/dist/service/session-context-service.js +0 -1
- package/dist/service/session-domain-state.js +0 -1
- package/dist/service/session-identity-service.js +0 -1
- package/dist/service/session-lifecycle-service.js +13 -7
- package/dist/service/session-message-service.js +0 -1
- package/dist/service/session-presentation-service.js +0 -1
- package/dist/service/session-query-service.js +0 -1
- package/dist/service/terminal-relay-state.js +0 -1
- package/dist/service/terminal-service.js +0 -1
- package/dist/service/workbench-event-service.js +0 -1
- package/dist/service/workbench-manifest-service.d.ts +5 -4
- package/dist/service/workbench-manifest-service.js +3 -2
- package/dist/service/workspace-change-service.js +2 -2
- package/dist/service/workspace-content-search-service.d.ts +14 -0
- package/dist/service/workspace-content-search-service.js +477 -0
- package/dist/service/workspace-domain-state.js +0 -1
- package/dist/service/workspace-file-service.d.ts +3 -0
- package/dist/service/workspace-file-service.js +35 -3
- package/dist/service/workspace-queue-workbench-service.js +0 -1
- package/dist/service/workspace-service.js +23 -10
- package/dist/service/workspace-session-service.js +0 -1
- package/dist/service/workspace-upload-service.js +0 -1
- package/dist/service/workspace-watch-service.js +0 -1
- package/dist/service/workspace-workbench-service.d.ts +9 -0
- package/dist/service/workspace-workbench-service.js +69 -2
- package/dist/service.js +2 -3
- package/dist/storage.js +0 -1
- package/dist/supervisor.d.ts +1 -0
- package/dist/supervisor.js +154 -0
- package/dist/terminal.js +0 -1
- package/dist/util/node-operation-parsers.d.ts +1 -0
- package/dist/util/node-operation-parsers.js +3 -1
- package/dist/util/runner-native-session-parsers.js +117 -73
- package/dist/util/secret-environment.js +0 -1
- package/dist/workspace.d.ts +62 -2
- package/dist/workspace.js +539 -57
- package/package.json +3 -2
- package/dist/capabilities.js.map +0 -1
- package/dist/claude-agent-sdk.js.map +0 -1
- package/dist/claude-channel.js.map +0 -1
- package/dist/codex-app-server.js.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/connector/node-connector-options.js.map +0 -1
- package/dist/connector/node-operation-router.js.map +0 -1
- package/dist/connector.js.map +0 -1
- package/dist/control-outbound-scheduler.js.map +0 -1
- package/dist/database.js.map +0 -1
- package/dist/event-buffer.js.map +0 -1
- package/dist/fake-runner.js.map +0 -1
- package/dist/health.js.map +0 -1
- package/dist/main.js.map +0 -1
- package/dist/migrations/v001.js.map +0 -1
- package/dist/migrations/v002.js.map +0 -1
- package/dist/native-jsonl-reader.js.map +0 -1
- package/dist/native-session-history.js.map +0 -1
- package/dist/operational.js.map +0 -1
- package/dist/process-tree.js.map +0 -1
- package/dist/runner/abstract-runner.js.map +0 -1
- package/dist/runner/claude/managed-run-controller.js.map +0 -1
- package/dist/runner/claude-code-runner.js.map +0 -1
- package/dist/runner/codex/conversation-parser.js.map +0 -1
- package/dist/runner/codex/managed-run-controller.js.map +0 -1
- package/dist/runner/codex-runner.js.map +0 -1
- package/dist/runner/fake-test-runner.js.map +0 -1
- package/dist/runner/runner-registry.js.map +0 -1
- package/dist/runner-command-engine.js.map +0 -1
- package/dist/runner-profiles.js.map +0 -1
- package/dist/runner-usage.js.map +0 -1
- package/dist/runtime-state.js.map +0 -1
- package/dist/service/attachment-domain-state.js.map +0 -1
- package/dist/service/conversation-history-service.js.map +0 -1
- package/dist/service/external-session-resume-service.js.map +0 -1
- package/dist/service/fake-managed-run-service.js.map +0 -1
- package/dist/service/managed-runner-session-service.js.map +0 -1
- package/dist/service/native-session-projection-service.js.map +0 -1
- package/dist/service/native-session-watch-service.js.map +0 -1
- package/dist/service/node-connection-lifecycle-service.js.map +0 -1
- package/dist/service/node-control-channel.js.map +0 -1
- package/dist/service/node-control-message-service.js.map +0 -1
- package/dist/service/node-request-service.js.map +0 -1
- package/dist/service/node-run-event-bridge.js.map +0 -1
- package/dist/service/node-terminal-channel.js.map +0 -1
- package/dist/service/node-workspace-coordinator.js.map +0 -1
- package/dist/service/run-attachment-service.js.map +0 -1
- package/dist/service/run-domain-state.js.map +0 -1
- package/dist/service/run-event-service.js.map +0 -1
- package/dist/service/run-workbench-service.js.map +0 -1
- package/dist/service/runner-channel-message-service.js.map +0 -1
- package/dist/service/runner-interaction-service.js.map +0 -1
- package/dist/service/runner-service.js.map +0 -1
- package/dist/service/session-catalog-service.js.map +0 -1
- package/dist/service/session-command-service.js.map +0 -1
- package/dist/service/session-context-service.js.map +0 -1
- package/dist/service/session-domain-state.js.map +0 -1
- package/dist/service/session-identity-service.js.map +0 -1
- package/dist/service/session-lifecycle-service.js.map +0 -1
- package/dist/service/session-message-service.js.map +0 -1
- package/dist/service/session-presentation-service.js.map +0 -1
- package/dist/service/session-query-service.js.map +0 -1
- package/dist/service/terminal-relay-state.js.map +0 -1
- package/dist/service/terminal-service.js.map +0 -1
- package/dist/service/workbench-event-service.js.map +0 -1
- package/dist/service/workbench-manifest-service.js.map +0 -1
- package/dist/service/workspace-change-service.js.map +0 -1
- package/dist/service/workspace-domain-state.js.map +0 -1
- package/dist/service/workspace-file-service.js.map +0 -1
- package/dist/service/workspace-queue-workbench-service.js.map +0 -1
- package/dist/service/workspace-service.js.map +0 -1
- package/dist/service/workspace-session-service.js.map +0 -1
- package/dist/service/workspace-upload-service.js.map +0 -1
- package/dist/service/workspace-watch-service.js.map +0 -1
- package/dist/service/workspace-workbench-service.js.map +0 -1
- package/dist/service.js.map +0 -1
- package/dist/storage.js.map +0 -1
- package/dist/terminal.js.map +0 -1
- package/dist/util/node-operation-parsers.js.map +0 -1
- package/dist/util/runner-native-session-parsers.js.map +0 -1
- package/dist/util/secret-environment.js.map +0 -1
- package/dist/workspace.js.map +0 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
MyAgentRoam Node runtime CLI for Linux and Windows.
|
|
4
4
|
|
|
5
5
|
For third-party deployment, registration, Runner prerequisites, and automatic startup, see the
|
|
6
|
-
public **Node deployment and connection guide** at `/docs/
|
|
6
|
+
public **Node deployment and connection guide** at `/docs/deployment/node-installation` in your MyAgentRoam
|
|
7
7
|
Server Web Console. The same guide is also linked from **Settings → Node registration**.
|
|
8
8
|
|
|
9
9
|
## Requirements
|
|
@@ -31,4 +31,12 @@ npm install --global @myagentroam/node@latest
|
|
|
31
31
|
mar-node run --config /path/to/mar-node.json
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
Managed deployments should run the stable supervisor entrypoint instead:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
mar-node supervise --config /path/to/mar-node.json
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The supervisor only installs an exact version requested by an authenticated Server operation. It never follows the npm `latest` tag automatically.
|
|
41
|
+
|
|
34
42
|
The package contains only the executable and its runtime dependencies. It never includes Node configuration, credentials, SQLite data, workspaces, or Runner credentials.
|
package/dist/capabilities.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ export declare function unavailableCapabilities(): NodeCapabilities;
|
|
|
3
3
|
export declare function detectCapabilities(commands?: {
|
|
4
4
|
readonly codex?: string;
|
|
5
5
|
readonly claudeCode?: string;
|
|
6
|
+
readonly openCode?: string;
|
|
6
7
|
}): NodeCapabilities;
|
|
7
8
|
export declare function detectCapabilitiesAsync(commands?: {
|
|
8
9
|
readonly codex?: string;
|
|
9
10
|
readonly claudeCode?: string;
|
|
11
|
+
readonly openCode?: string;
|
|
10
12
|
}): Promise<NodeCapabilities>;
|
package/dist/capabilities.js
CHANGED
|
@@ -2,6 +2,7 @@ import { release, version } from 'node:os';
|
|
|
2
2
|
import nodePackage from '../package.json' with { type: 'json' };
|
|
3
3
|
import { probeClaudeCode, probeClaudeCodeAsync } from './claude-agent-sdk.js';
|
|
4
4
|
import { probeCodex, probeCodexAsync } from './codex-app-server.js';
|
|
5
|
+
import { probeOpenCode, probeOpenCodeAsync } from './opencode-runtime.js';
|
|
5
6
|
const nodeAppVersion = typeof nodePackage.version === 'string' ? nodePackage.version : 'unknown';
|
|
6
7
|
function reportedPlatform() {
|
|
7
8
|
return process.platform === 'win32' ? 'windows' : 'linux';
|
|
@@ -20,7 +21,8 @@ export function unavailableCapabilities() {
|
|
|
20
21
|
osVersion: version()
|
|
21
22
|
},
|
|
22
23
|
codex: { available: false },
|
|
23
|
-
claudeCode: { available: false }
|
|
24
|
+
claudeCode: { available: false },
|
|
25
|
+
openCode: { available: false }
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
28
|
export function detectCapabilities(commands = {}) {
|
|
@@ -29,6 +31,7 @@ export function detectCapabilities(commands = {}) {
|
|
|
29
31
|
}
|
|
30
32
|
const codex = probeCodex(commands.codex);
|
|
31
33
|
const claudeCode = probeClaudeCode(commands.claudeCode);
|
|
34
|
+
const openCode = probeOpenCode(commands.openCode);
|
|
32
35
|
return {
|
|
33
36
|
platform: reportedPlatform(),
|
|
34
37
|
architecture: process.arch,
|
|
@@ -45,6 +48,10 @@ export function detectCapabilities(commands = {}) {
|
|
|
45
48
|
claudeCode: {
|
|
46
49
|
available: claudeCode.available && claudeCode.compatible,
|
|
47
50
|
...(claudeCode.version === undefined ? {} : { version: claudeCode.version })
|
|
51
|
+
},
|
|
52
|
+
openCode: {
|
|
53
|
+
available: openCode.available && openCode.compatible,
|
|
54
|
+
...(openCode.version === undefined ? {} : { version: openCode.version })
|
|
48
55
|
}
|
|
49
56
|
};
|
|
50
57
|
}
|
|
@@ -52,9 +59,10 @@ export async function detectCapabilitiesAsync(commands = {}) {
|
|
|
52
59
|
if (process.platform !== 'win32' && process.platform !== 'linux') {
|
|
53
60
|
throw new Error('NODE_PLATFORM_UNSUPPORTED');
|
|
54
61
|
}
|
|
55
|
-
const [codex, claudeCode] = await Promise.all([
|
|
62
|
+
const [codex, claudeCode, openCode] = await Promise.all([
|
|
56
63
|
probeCodexAsync(commands.codex),
|
|
57
|
-
probeClaudeCodeAsync(commands.claudeCode)
|
|
64
|
+
probeClaudeCodeAsync(commands.claudeCode),
|
|
65
|
+
probeOpenCodeAsync(commands.openCode)
|
|
58
66
|
]);
|
|
59
67
|
return {
|
|
60
68
|
platform: reportedPlatform(),
|
|
@@ -72,7 +80,10 @@ export async function detectCapabilitiesAsync(commands = {}) {
|
|
|
72
80
|
claudeCode: {
|
|
73
81
|
available: claudeCode.available && claudeCode.compatible,
|
|
74
82
|
...(claudeCode.version === undefined ? {} : { version: claudeCode.version })
|
|
83
|
+
},
|
|
84
|
+
openCode: {
|
|
85
|
+
available: openCode.available && openCode.compatible,
|
|
86
|
+
...(openCode.version === undefined ? {} : { version: openCode.version })
|
|
75
87
|
}
|
|
76
88
|
};
|
|
77
89
|
}
|
|
78
|
-
//# sourceMappingURL=capabilities.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CanUseTool, type Options, type PermissionResult, type Query, type SDKMessage, type SDKSessionInfo, type SDKUserMessage, type SessionMessage } from '@anthropic-ai/claude-agent-sdk';
|
|
1
|
+
import { forkSession, type CanUseTool, type Options, type PermissionResult, type Query, type SDKMessage, type SDKSessionInfo, type SDKUserMessage, type SessionMessage } from '@anthropic-ai/claude-agent-sdk';
|
|
2
2
|
export interface ClaudeCodeProbe {
|
|
3
3
|
readonly available: boolean;
|
|
4
4
|
readonly compatible: boolean;
|
|
@@ -53,6 +53,7 @@ export interface ClaudeSdkBindings {
|
|
|
53
53
|
readonly getSessionMessages: (sessionId: string, options: {
|
|
54
54
|
readonly dir?: string;
|
|
55
55
|
}) => Promise<SessionMessage[]>;
|
|
56
|
+
readonly forkSession?: typeof forkSession;
|
|
56
57
|
}
|
|
57
58
|
/**
|
|
58
59
|
* Adapter for the supported Agent SDK APIs only. It neither parses nor writes
|
|
@@ -70,6 +71,7 @@ export declare class ClaudeAgentSdkAdapter {
|
|
|
70
71
|
private startWithPrompt;
|
|
71
72
|
listSessions(cwd: string): Promise<SDKSessionInfo[]>;
|
|
72
73
|
readSession(sessionId: string, cwd: string): Promise<SessionMessage[]>;
|
|
74
|
+
forkSession(sessionId: string, cwd: string, upToMessageId: string, title: string): Promise<string>;
|
|
73
75
|
sessionInfo(sessionId: string, cwd: string): Promise<SDKSessionInfo | undefined>;
|
|
74
76
|
/**
|
|
75
77
|
* The SDK publishes the authoritative, session-specific command list in its
|
package/dist/claude-agent-sdk.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { createSdkMcpServer, getSessionInfo, getSessionMessages, listSessions, query } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
+
import { createSdkMcpServer, forkSession, getSessionInfo, getSessionMessages, listSessions, query } from '@anthropic-ai/claude-agent-sdk';
|
|
3
3
|
import { tool } from '@anthropic-ai/claude-agent-sdk';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { minimalRunnerEnvironment, platformCliInvocation, runRunnerProbe } from './operational.js';
|
|
@@ -90,6 +90,14 @@ export class ClaudeAgentSdkAdapter {
|
|
|
90
90
|
readSession(sessionId, cwd) {
|
|
91
91
|
return this.sdk.getSessionMessages(sessionId, { dir: cwd });
|
|
92
92
|
}
|
|
93
|
+
async forkSession(sessionId, cwd, upToMessageId, title) {
|
|
94
|
+
const result = await (this.sdk.forkSession ?? forkSession)(sessionId, {
|
|
95
|
+
dir: cwd,
|
|
96
|
+
upToMessageId,
|
|
97
|
+
title
|
|
98
|
+
});
|
|
99
|
+
return result.sessionId;
|
|
100
|
+
}
|
|
93
101
|
sessionInfo(sessionId, cwd) {
|
|
94
102
|
return this.sdk.getSessionInfo(sessionId, { dir: cwd });
|
|
95
103
|
}
|
|
@@ -304,4 +312,3 @@ export async function probeClaudeCodeAsync(command = 'claude') {
|
|
|
304
312
|
export function denyPermission(message = 'USER_DECISION_REJECTED') {
|
|
305
313
|
return { behavior: 'deny', message };
|
|
306
314
|
}
|
|
307
|
-
//# sourceMappingURL=claude-agent-sdk.js.map
|
package/dist/claude-channel.js
CHANGED
|
@@ -85,6 +85,7 @@ export declare class CodexAppServerClient {
|
|
|
85
85
|
listThreads(): Promise<unknown>;
|
|
86
86
|
listCollaborationModes(): Promise<unknown>;
|
|
87
87
|
readThread(threadId: string, includeTurns?: boolean): Promise<unknown>;
|
|
88
|
+
forkThread(threadId: string, cwd: string, lastTurnId: string, configuration?: CodexRunConfiguration): Promise<unknown>;
|
|
88
89
|
setThreadName(threadId: string, name: string): Promise<unknown>;
|
|
89
90
|
resumeThread(threadId: string, cwd: string, configuration?: CodexRunConfiguration): Promise<unknown>;
|
|
90
91
|
startTurn(threadId: string, text: string, cwd: string, configuration?: CodexRunConfiguration, attachments?: readonly Extract<CodexComposerInput, {
|
package/dist/codex-app-server.js
CHANGED
|
@@ -173,6 +173,14 @@ export class CodexAppServerClient {
|
|
|
173
173
|
readThread(threadId, includeTurns = true) {
|
|
174
174
|
return this.request('thread/read', { threadId, includeTurns });
|
|
175
175
|
}
|
|
176
|
+
forkThread(threadId, cwd, lastTurnId, configuration = {}) {
|
|
177
|
+
return this.request('thread/fork', {
|
|
178
|
+
threadId,
|
|
179
|
+
lastTurnId,
|
|
180
|
+
cwd,
|
|
181
|
+
...codexThreadConfiguration(cwd, configuration)
|
|
182
|
+
});
|
|
183
|
+
}
|
|
176
184
|
setThreadName(threadId, name) {
|
|
177
185
|
return this.request('thread/name/set', { threadId, name });
|
|
178
186
|
}
|
|
@@ -390,4 +398,3 @@ function connectUnix(socketPath, timeoutMs) {
|
|
|
390
398
|
attempt();
|
|
391
399
|
});
|
|
392
400
|
}
|
|
393
|
-
//# sourceMappingURL=codex-app-server.js.map
|
package/dist/config.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export interface NodeConfig {
|
|
|
7
7
|
readonly nodeId?: string;
|
|
8
8
|
readonly credential?: string;
|
|
9
9
|
readonly registrationToken?: string;
|
|
10
|
+
readonly upgrade?: {
|
|
11
|
+
readonly registryUrl?: string;
|
|
12
|
+
};
|
|
10
13
|
}
|
|
11
14
|
export declare function nodeConfigPath(): string;
|
|
12
15
|
export declare function loadNodeConfig(path?: string): Promise<NodeConfig>;
|
package/dist/config.js
CHANGED
|
@@ -21,6 +21,14 @@ export async function loadNodeConfig(path = nodeConfigPath()) {
|
|
|
21
21
|
const credential = optionalString('credential');
|
|
22
22
|
const registrationToken = optionalString('registrationToken');
|
|
23
23
|
const databasePath = optionalString('databasePath');
|
|
24
|
+
const upgradeInput = input['upgrade'];
|
|
25
|
+
if (upgradeInput !== undefined &&
|
|
26
|
+
(upgradeInput === null ||
|
|
27
|
+
typeof upgradeInput !== 'object' ||
|
|
28
|
+
Array.isArray(upgradeInput) ||
|
|
29
|
+
('registryUrl' in upgradeInput &&
|
|
30
|
+
typeof upgradeInput['registryUrl'] !== 'string')))
|
|
31
|
+
throw new Error('NODE_CONFIG_INVALID');
|
|
24
32
|
const allowedRoots = Array.isArray(input['allowedRoots'])
|
|
25
33
|
? input['allowedRoots']
|
|
26
34
|
: defaultAllowedRoots();
|
|
@@ -30,7 +38,16 @@ export async function loadNodeConfig(path = nodeConfigPath()) {
|
|
|
30
38
|
...(nodeId === undefined ? {} : { nodeId }),
|
|
31
39
|
...(credential === undefined ? {} : { credential }),
|
|
32
40
|
...(registrationToken === undefined ? {} : { registrationToken }),
|
|
33
|
-
...(databasePath === undefined ? {} : { databasePath })
|
|
41
|
+
...(databasePath === undefined ? {} : { databasePath }),
|
|
42
|
+
...(upgradeInput === undefined
|
|
43
|
+
? {}
|
|
44
|
+
: {
|
|
45
|
+
upgrade: {
|
|
46
|
+
...(upgradeInput['registryUrl'] === undefined
|
|
47
|
+
? {}
|
|
48
|
+
: { registryUrl: upgradeInput['registryUrl'] })
|
|
49
|
+
}
|
|
50
|
+
})
|
|
34
51
|
};
|
|
35
52
|
}
|
|
36
53
|
/** Uses the Node service account's scope when no Workspace roots are configured. */
|
|
@@ -48,4 +65,3 @@ export async function saveNodeConfig(config, path = nodeConfigPath()) {
|
|
|
48
65
|
await chmod(path, 0o600);
|
|
49
66
|
}
|
|
50
67
|
}
|
|
51
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -6,6 +6,7 @@ import type { NodeDatabase } from '../database.js';
|
|
|
6
6
|
import type { FakeRunner, FakeRunnerStep } from '../fake-runner.js';
|
|
7
7
|
import type { RunnerUsageReader } from '../runner-usage.js';
|
|
8
8
|
import type { TerminalManager } from '../terminal.js';
|
|
9
|
+
import type { OpenCodeServerClient } from '../opencode-server.js';
|
|
9
10
|
export interface NodeConnectorOptions {
|
|
10
11
|
readonly configPath?: string;
|
|
11
12
|
readonly config?: NodeConfig;
|
|
@@ -16,8 +17,10 @@ export interface NodeConnectorOptions {
|
|
|
16
17
|
readonly fakeScript?: (input: unknown, runId: string) => readonly FakeRunnerStep[];
|
|
17
18
|
readonly codexClient?: CodexAppServerClient;
|
|
18
19
|
readonly claudeClient?: ClaudeAgentSdkAdapter;
|
|
20
|
+
readonly openCodeClient?: OpenCodeServerClient;
|
|
19
21
|
readonly database?: NodeDatabase;
|
|
20
22
|
readonly claudeApprovalTimeoutMs?: number;
|
|
21
23
|
readonly terminalManager?: TerminalManager;
|
|
22
24
|
readonly runnerUsageReader?: RunnerUsageReader;
|
|
25
|
+
readonly upgradeReady?: () => void;
|
|
23
26
|
}
|
package/dist/connector.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export declare class NodeConnector {
|
|
|
41
41
|
private readonly codexClient;
|
|
42
42
|
private readonly codexRunController;
|
|
43
43
|
private readonly claudeClient;
|
|
44
|
+
private readonly openCodeClient;
|
|
45
|
+
private readonly openCodeRunController;
|
|
44
46
|
private readonly claudeRunController;
|
|
45
47
|
private readonly runners;
|
|
46
48
|
private readonly sessionContextService;
|
|
@@ -55,6 +57,7 @@ export declare class NodeConnector {
|
|
|
55
57
|
private readonly commandStates;
|
|
56
58
|
private readonly runnerUsageReader;
|
|
57
59
|
private readonly terminalManager;
|
|
60
|
+
private readonly upgradeCoordinator;
|
|
58
61
|
private readonly workspaceState;
|
|
59
62
|
private readonly workspaceWatchService;
|
|
60
63
|
private readonly workspaceSessionService;
|
package/dist/connector.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dirname, resolve } from 'node:path';
|
|
1
2
|
import { createEnvelope } from '@myagentroam/protocol';
|
|
2
3
|
import { loadNodeConfig, nodeDatabasePath } from './config.js';
|
|
3
4
|
import { NodeMetrics, nodeLog } from './operational.js';
|
|
@@ -14,6 +15,8 @@ import { CodexRunner } from './runner/codex-runner.js';
|
|
|
14
15
|
import { CodexManagedRunController } from './runner/codex/managed-run-controller.js';
|
|
15
16
|
import { FakeTestRunner } from './runner/fake-test-runner.js';
|
|
16
17
|
import { RunnerRegistry } from './runner/runner-registry.js';
|
|
18
|
+
import { OpenCodeRunner } from './runner/opencode-runner.js';
|
|
19
|
+
import { OpenCodeManagedRunController } from './runner/opencode/managed-run-controller.js';
|
|
17
20
|
import { NodeOperationRouter } from './connector/node-operation-router.js';
|
|
18
21
|
import { RunnerService } from './service/runner-service.js';
|
|
19
22
|
import { TerminalService } from './service/terminal-service.js';
|
|
@@ -58,6 +61,7 @@ import { FakeManagedRunService } from './service/fake-managed-run-service.js';
|
|
|
58
61
|
import { RunnerChannelMessageService } from './service/runner-channel-message-service.js';
|
|
59
62
|
import { ManagedRunnerSessionService } from './service/managed-runner-session-service.js';
|
|
60
63
|
import { NodeConnectionLifecycleService } from './service/node-connection-lifecycle-service.js';
|
|
64
|
+
import { NodeUpgradeCoordinator, nodeUpgradeRequestPath } from './service/node-upgrade-coordinator.js';
|
|
61
65
|
const HEARTBEAT_MS = 15_000;
|
|
62
66
|
const CAPABILITY_REFRESH_MS = 60_000;
|
|
63
67
|
const RETRY_MIN_MS = 500;
|
|
@@ -66,6 +70,18 @@ const CLAUDE_APPROVAL_TIMEOUT_MS = 10 * 60_000;
|
|
|
66
70
|
export function nextReconnectDelay(attempt) {
|
|
67
71
|
return Math.min(RETRY_MAX_MS, RETRY_MIN_MS * 2 ** Math.min(Math.max(attempt, 0), 16));
|
|
68
72
|
}
|
|
73
|
+
function upgradeMetadata(metadata, status) {
|
|
74
|
+
const next = { ...(metadata ?? {}) };
|
|
75
|
+
if (process.env['MAR_NODE_SUPERVISED'] === '1')
|
|
76
|
+
next.supervisedUpgrade = true;
|
|
77
|
+
else
|
|
78
|
+
delete next.supervisedUpgrade;
|
|
79
|
+
if (status.state === 'IDLE')
|
|
80
|
+
delete next.upgrade;
|
|
81
|
+
else
|
|
82
|
+
next.upgrade = status;
|
|
83
|
+
return next;
|
|
84
|
+
}
|
|
69
85
|
export class NodeConnector {
|
|
70
86
|
controlChannel;
|
|
71
87
|
controlMessages;
|
|
@@ -110,6 +126,8 @@ export class NodeConnector {
|
|
|
110
126
|
codexClient;
|
|
111
127
|
codexRunController;
|
|
112
128
|
claudeClient;
|
|
129
|
+
openCodeClient;
|
|
130
|
+
openCodeRunController;
|
|
113
131
|
claudeRunController;
|
|
114
132
|
runners;
|
|
115
133
|
sessionContextService;
|
|
@@ -124,6 +142,7 @@ export class NodeConnector {
|
|
|
124
142
|
commandStates = new CommandStateStore();
|
|
125
143
|
runnerUsageReader;
|
|
126
144
|
terminalManager;
|
|
145
|
+
upgradeCoordinator;
|
|
127
146
|
workspaceState = new WorkspaceDomainState();
|
|
128
147
|
workspaceWatchService = new WorkspaceWatchService(this.workspaceState, (workspaceId) => this.workspaceSessionService.ensureWatch(workspaceId), (workspaceId) => this.workspaceSessionService.stopWatch(workspaceId));
|
|
129
148
|
workspaceSessionService = new WorkspaceSessionService(this.workspaceState, {
|
|
@@ -156,7 +175,10 @@ export class NodeConnector {
|
|
|
156
175
|
cleanupAttachments: (runId) => this.runAttachmentService.cleanup(runId),
|
|
157
176
|
expireImages: (runId) => this.runAttachmentService.expire(runId),
|
|
158
177
|
scheduleContextRefresh: (sessionId) => this.sessionContextService.schedule(sessionId),
|
|
159
|
-
dispatchQueue: (sessionId) =>
|
|
178
|
+
dispatchQueue: async (sessionId) => {
|
|
179
|
+
if (!this.upgradeCoordinator.pending())
|
|
180
|
+
await this.workspaceQueueWorkbenchService.dispatch(sessionId);
|
|
181
|
+
},
|
|
160
182
|
removeQueuedStart: (runId) => this.workspaceQueueWorkbenchService.remove(runId)
|
|
161
183
|
});
|
|
162
184
|
nativeSessionWatchService = new NativeSessionWatchService({
|
|
@@ -175,7 +197,33 @@ export class NodeConnector {
|
|
|
175
197
|
this.claudeApprovalTimeoutMs = options.claudeApprovalTimeoutMs ?? CLAUDE_APPROVAL_TIMEOUT_MS;
|
|
176
198
|
this.capabilitiesProvided = options.capabilities !== undefined;
|
|
177
199
|
this.capabilities = options.capabilities ?? unavailableCapabilities();
|
|
178
|
-
this.
|
|
200
|
+
this.upgradeCoordinator = new NodeUpgradeCoordinator(() => {
|
|
201
|
+
if (this.config === undefined)
|
|
202
|
+
throw new Error('NODE_CONFIG_UNAVAILABLE');
|
|
203
|
+
return nodeUpgradeRequestPath(nodeDatabasePath(this.config, this.configPath));
|
|
204
|
+
}, () => this.runState.active.size, (status) => {
|
|
205
|
+
this.capabilities = {
|
|
206
|
+
...this.capabilities,
|
|
207
|
+
metadata: upgradeMetadata(this.capabilities.metadata, status)
|
|
208
|
+
};
|
|
209
|
+
this.controlChannel?.send('capabilities', this.capabilities);
|
|
210
|
+
}, options.upgradeReady ??
|
|
211
|
+
(() => {
|
|
212
|
+
this.stop();
|
|
213
|
+
setImmediate(() => process.exit(75));
|
|
214
|
+
}));
|
|
215
|
+
this.capabilities = {
|
|
216
|
+
...this.capabilities,
|
|
217
|
+
metadata: upgradeMetadata(this.capabilities.metadata, this.upgradeCoordinator.snapshot())
|
|
218
|
+
};
|
|
219
|
+
const detect = options.capabilityDetector ?? detectCapabilitiesAsync;
|
|
220
|
+
this.capabilityDetector = async () => {
|
|
221
|
+
const capabilities = await detect();
|
|
222
|
+
return {
|
|
223
|
+
...capabilities,
|
|
224
|
+
metadata: upgradeMetadata(capabilities.metadata, this.upgradeCoordinator.snapshot())
|
|
225
|
+
};
|
|
226
|
+
};
|
|
179
227
|
this.reconnect = options.reconnect ?? true;
|
|
180
228
|
this.fakeRunner =
|
|
181
229
|
options.fakeRunner === undefined ? undefined : new FakeTestRunner(options.fakeRunner);
|
|
@@ -205,6 +253,7 @@ export class NodeConnector {
|
|
|
205
253
|
emitItem: (runId, item) => this.runEventBridge.emitRun(runId, 'conversation.item', item),
|
|
206
254
|
appendImages: (runId, images) => this.runAttachmentService.append(runId, images.filter(isRunnerImageAttachment)),
|
|
207
255
|
captureSnapshot: (runId, cwd) => this.workspaceCoordinator.captureRunSnapshot(runId, cwd),
|
|
256
|
+
syncTitle: (sessionId, nativeSessionId, cwd) => this.managedRunnerSessions.refreshTitle(sessionId, nativeSessionId, cwd),
|
|
208
257
|
commandState: (sessionId, commandId) => this.commandStates.get(sessionId, commandId),
|
|
209
258
|
setCommandState: (sessionId, state) => this.commandStates.set(sessionId, state),
|
|
210
259
|
clearCommandState: (sessionId, commandId) => this.commandStates.clear(sessionId, commandId),
|
|
@@ -217,6 +266,28 @@ export class NodeConnector {
|
|
|
217
266
|
});
|
|
218
267
|
this.codexClient.onNotification((notification) => this.codexRunController.handleNotification(notification));
|
|
219
268
|
this.claudeClient = new ClaudeCodeRunner(options.claudeClient);
|
|
269
|
+
this.openCodeClient = new OpenCodeRunner(options.openCodeClient);
|
|
270
|
+
this.openCodeRunController = new OpenCodeManagedRunController(this.openCodeClient, {
|
|
271
|
+
intercepted: () => this.fakeRunner !== undefined,
|
|
272
|
+
active: this.runState.active,
|
|
273
|
+
parseAttachments: parseRunnerImageAttachments,
|
|
274
|
+
emit: (runId, eventType, payload, status) => this.runEventBridge.emitRun(runId, eventType, payload, status),
|
|
275
|
+
emitItem: (runId, item) => this.runEventBridge.emitRun(runId, 'conversation.item', item),
|
|
276
|
+
adopt: (input) => this.runtime.adoptRun(input),
|
|
277
|
+
promote: (sessionId, nativeSessionId) => this.sessionIdentityService.promote(sessionId, nativeSessionId),
|
|
278
|
+
rememberNative: (nativeSessionId, sessionId) => this.managedRunnerSessions.remember(nativeSessionId, sessionId),
|
|
279
|
+
send: (type, payload) => this.send(type, payload),
|
|
280
|
+
captureSnapshot: (runId, cwd) => this.workspaceCoordinator.captureRunSnapshot(runId, cwd),
|
|
281
|
+
createApproval: (input) => this.runtime.createApproval(input),
|
|
282
|
+
expireApproval: (approvalId) => {
|
|
283
|
+
this.runtime.expireApproval(approvalId);
|
|
284
|
+
},
|
|
285
|
+
publishApproval: (input) => this.runEventBridge.publishApproval(input),
|
|
286
|
+
commandState: (sessionId, commandId) => this.commandStates.get(sessionId, commandId),
|
|
287
|
+
setCommandState: (sessionId, state) => this.commandStates.set(sessionId, state),
|
|
288
|
+
clearCommandState: (sessionId, commandId) => this.commandStates.clear(sessionId, commandId),
|
|
289
|
+
commandStates: (sessionId) => this.commandStates.list(sessionId)
|
|
290
|
+
}, this.claudeApprovalTimeoutMs);
|
|
220
291
|
this.claudeRunController = new ClaudeManagedRunController(this.claudeClient, {
|
|
221
292
|
intercepted: () => this.fakeRunner !== undefined,
|
|
222
293
|
active: this.runState.active,
|
|
@@ -244,9 +315,12 @@ export class NodeConnector {
|
|
|
244
315
|
this.runners = new RunnerRegistry([
|
|
245
316
|
this.codexClient,
|
|
246
317
|
this.claudeClient,
|
|
318
|
+
this.openCodeClient,
|
|
247
319
|
...(this.fakeRunner === undefined ? [] : [this.fakeRunner])
|
|
248
320
|
]);
|
|
249
|
-
this.managedRunnerSessions = new ManagedRunnerSessionService(this.runtime, this.runners)
|
|
321
|
+
this.managedRunnerSessions = new ManagedRunnerSessionService(this.runtime, this.runners, (session) => this.emitWorkbenchEvent('session', {
|
|
322
|
+
session: this.sessionPresentationService.present(session)
|
|
323
|
+
}));
|
|
250
324
|
this.runnerInteractionService = new RunnerInteractionService({
|
|
251
325
|
runtime: this.runtime,
|
|
252
326
|
state: this.runState,
|
|
@@ -278,6 +352,7 @@ export class NodeConnector {
|
|
|
278
352
|
nodeId: () => this.config?.nodeId ?? 'recorded-session',
|
|
279
353
|
runtime: this.runtime,
|
|
280
354
|
runners: this.runners,
|
|
355
|
+
capabilities: () => this.capabilities,
|
|
281
356
|
state: this.sessionState,
|
|
282
357
|
commands: this.commandStates,
|
|
283
358
|
present: (session) => this.sessionPresentationService.present(session)
|
|
@@ -419,6 +494,7 @@ export class NodeConnector {
|
|
|
419
494
|
},
|
|
420
495
|
nodeId: () => this.config?.nodeId ?? 'recorded-session',
|
|
421
496
|
runtime: this.runtime,
|
|
497
|
+
runners: this.runners,
|
|
422
498
|
projection: this.nativeSessionProjectionService,
|
|
423
499
|
resume: this.externalSessionResumeService,
|
|
424
500
|
cachedNative: () => [...this.sessionState.directNative.values()],
|
|
@@ -428,7 +504,11 @@ export class NodeConnector {
|
|
|
428
504
|
nativeIds: (session) => this.nativeSessionProjectionService.nativeIds(session),
|
|
429
505
|
forget: (session, nativeIds) => this.nativeSessionProjectionService.forget(session, nativeIds),
|
|
430
506
|
refreshActivity: (session) => this.conversationHistoryService.refreshExternalActivity(session),
|
|
431
|
-
externalActivity: (sessionId) => this.sessionState.externalActivity.get(sessionId)
|
|
507
|
+
externalActivity: (sessionId) => this.sessionState.externalActivity.get(sessionId),
|
|
508
|
+
history: (session, input) => this.conversationHistoryService.read(session, input),
|
|
509
|
+
emitSession: (session) => this.emitWorkbenchEvent('session', {
|
|
510
|
+
session: this.sessionPresentationService.present(session)
|
|
511
|
+
})
|
|
432
512
|
});
|
|
433
513
|
this.codexClient.bindControl({
|
|
434
514
|
start: (envelope) => this.codexRunController.start(envelope),
|
|
@@ -446,12 +526,21 @@ export class NodeConnector {
|
|
|
446
526
|
cancel: (runId, intent) => this.runnerInteractionService.cancelClaudeRun(runId, intent),
|
|
447
527
|
decideApproval: (input) => this.runnerInteractionService.decideClaudeApproval(input.approvalId, input.decision)
|
|
448
528
|
});
|
|
529
|
+
this.openCodeClient.bindControl({
|
|
530
|
+
start: (envelope) => this.openCodeRunController.start(envelope),
|
|
531
|
+
cancel: (runId, intent) => this.openCodeRunController.cancel(runId, intent),
|
|
532
|
+
decideApproval: (input) => this.openCodeRunController.decideApproval(input),
|
|
533
|
+
respondUserInput: (runId, requestId, answers) => this.openCodeRunController.respondUserInput(runId, requestId, answers)
|
|
534
|
+
});
|
|
449
535
|
this.codexClient.bindCommandControl({
|
|
450
536
|
execute: (session, command, input, context) => this.codexRunController.executeCommand(session, command, input, context)
|
|
451
537
|
});
|
|
452
538
|
this.claudeClient.bindCommandControl({
|
|
453
539
|
execute: (session, command, input, context) => this.claudeRunController.executeCommand(session, command, input, context)
|
|
454
540
|
});
|
|
541
|
+
this.openCodeClient.bindCommandControl({
|
|
542
|
+
execute: (session, command, _input, context) => this.openCodeRunController.executeCommand(session, command, context)
|
|
543
|
+
});
|
|
455
544
|
const fakeRuns = this.fakeRunner === undefined || this.fakeScript === undefined
|
|
456
545
|
? undefined
|
|
457
546
|
: new FakeManagedRunService({
|
|
@@ -500,8 +589,12 @@ export class NodeConnector {
|
|
|
500
589
|
},
|
|
501
590
|
onReconnectScheduled: () => this.metrics.reconnectScheduled(),
|
|
502
591
|
onMessage: (raw) => this.handleMessage(raw),
|
|
503
|
-
onClose: (code) => {
|
|
592
|
+
onClose: (code, reason) => {
|
|
504
593
|
this.terminalChannel.disconnect();
|
|
594
|
+
if (code === 4000 && reason === 'NODE_CONNECTION_REPLACED')
|
|
595
|
+
nodeLog('node.connection.replaced', {
|
|
596
|
+
message: '当前 Node 已被同一身份的新实例接管,请检查是否启动了重复实例。'
|
|
597
|
+
});
|
|
505
598
|
if (code === 4003 || code === 1001)
|
|
506
599
|
void this.terminalManager.shutdown();
|
|
507
600
|
}
|
|
@@ -548,6 +641,7 @@ export class NodeConnector {
|
|
|
548
641
|
queues: this.workspaceQueueWorkbenchService,
|
|
549
642
|
codex: this.codexClient,
|
|
550
643
|
claude: this.claudeClient,
|
|
644
|
+
openCode: this.openCodeClient,
|
|
551
645
|
send: (type, payload, replyTo) => this.send(type, payload, replyTo)
|
|
552
646
|
});
|
|
553
647
|
this.connectionLifecycle = new NodeConnectionLifecycleService({
|
|
@@ -558,7 +652,10 @@ export class NodeConnector {
|
|
|
558
652
|
detectCapabilities: this.capabilityDetector,
|
|
559
653
|
capabilitiesProvided: this.capabilitiesProvided,
|
|
560
654
|
stopped: () => this.stopped,
|
|
561
|
-
setCapabilities: (capabilities) => (this.capabilities =
|
|
655
|
+
setCapabilities: (capabilities) => (this.capabilities = {
|
|
656
|
+
...capabilities,
|
|
657
|
+
metadata: upgradeMetadata(capabilities.metadata, this.upgradeCoordinator.snapshot())
|
|
658
|
+
}),
|
|
562
659
|
control: this.controlChannel,
|
|
563
660
|
terminal: this.terminalChannel,
|
|
564
661
|
events: this.workbenchEventService,
|
|
@@ -618,6 +715,8 @@ export class NodeConnector {
|
|
|
618
715
|
workspaceLeases: this.runtime.activeWorkspaceLeaseCount()
|
|
619
716
|
}
|
|
620
717
|
}));
|
|
718
|
+
this.operationRouter.register('node.upgrade.request', (data) => this.upgradeCoordinator.request(data));
|
|
719
|
+
this.operationRouter.register('node.upgrade.cancel', () => this.upgradeCoordinator.cancel());
|
|
621
720
|
this.operationRouter.register('node.workbench.capabilities', async () => ({
|
|
622
721
|
manifest: await this.workbenchManifestService.read()
|
|
623
722
|
}));
|
|
@@ -625,6 +724,7 @@ export class NodeConnector {
|
|
|
625
724
|
async start() {
|
|
626
725
|
this.stopped = false;
|
|
627
726
|
this.config ??= await loadNodeConfig(this.configPath);
|
|
727
|
+
await this.upgradeCoordinator.loadResult(resolve(dirname(nodeDatabasePath(this.config, this.configPath)), 'upgrade-result.json'));
|
|
628
728
|
await assertLocalSqlitePath(nodeDatabasePath(this.config, this.configPath));
|
|
629
729
|
this.database ??= new NodeDatabase(nodeDatabasePath(this.config, this.configPath), () => this.config?.nodeId ?? 'unregistered');
|
|
630
730
|
this.database.closeRunningTerminalSessions();
|
|
@@ -633,6 +733,7 @@ export class NodeConnector {
|
|
|
633
733
|
}
|
|
634
734
|
stop() {
|
|
635
735
|
this.stopped = true;
|
|
736
|
+
this.upgradeCoordinator.stop();
|
|
636
737
|
this.connectionLifecycle.stop();
|
|
637
738
|
for (const approval of this.claudeClient.execution.approvals.values()) {
|
|
638
739
|
clearTimeout(approval.timer);
|
|
@@ -681,6 +782,8 @@ export class NodeConnector {
|
|
|
681
782
|
async executeNodeOperation(operation, data) {
|
|
682
783
|
if (this.database === undefined)
|
|
683
784
|
throw new Error('NODE_DATABASE_UNAVAILABLE');
|
|
785
|
+
if (this.upgradeCoordinator.blocks(operation))
|
|
786
|
+
throw new Error('NODE_UPGRADE_PENDING');
|
|
684
787
|
nodeLog('node.operation', { nodeId: this.config?.nodeId, operation });
|
|
685
788
|
return this.operationRouter.execute(operation, data);
|
|
686
789
|
}
|
|
@@ -691,4 +794,3 @@ export class NodeConnector {
|
|
|
691
794
|
this.controlChannel.sendEnvelope(envelope);
|
|
692
795
|
}
|
|
693
796
|
}
|
|
694
|
-
//# sourceMappingURL=connector.js.map
|
package/dist/database.d.ts
CHANGED
|
@@ -106,6 +106,10 @@ export interface NodeConversationTurn {
|
|
|
106
106
|
readonly model: string | null;
|
|
107
107
|
readonly effort: string | null;
|
|
108
108
|
readonly access: string | null;
|
|
109
|
+
readonly rewind?: {
|
|
110
|
+
readonly before: string | null;
|
|
111
|
+
readonly after: string;
|
|
112
|
+
};
|
|
109
113
|
readonly items: readonly NodeConversationItem[];
|
|
110
114
|
readonly startedAt: number | null;
|
|
111
115
|
readonly completedAt: number | null;
|
package/dist/database.js
CHANGED
|
@@ -4,8 +4,9 @@ import { dirname } from 'node:path';
|
|
|
4
4
|
import { DatabaseSync } from 'node:sqlite';
|
|
5
5
|
import { runnerDefaultConfigurationSchema } from '@myagentroam/protocol';
|
|
6
6
|
import { assertNodeSchema, NODE_SCHEMA_V1 } from './migrations/v001.js';
|
|
7
|
-
import { assertNodeSchemaV2, migrateNodeSchemaV2
|
|
8
|
-
|
|
7
|
+
import { assertNodeSchemaV2, migrateNodeSchemaV2 } from './migrations/v002.js';
|
|
8
|
+
import { assertNodeSchemaV3, migrateNodeSchemaV3, NODE_SCHEMA_VERSION_V3 } from './migrations/v003.js';
|
|
9
|
+
const NODE_SCHEMA_VERSION = NODE_SCHEMA_VERSION_V3;
|
|
9
10
|
export class NodeDatabase {
|
|
10
11
|
now;
|
|
11
12
|
activeWorkspaceLeaseCount() {
|
|
@@ -1025,6 +1026,8 @@ function migrate(database) {
|
|
|
1025
1026
|
.prepare('INSERT INTO node_schema_migrations (version, applied_at) VALUES (?, ?), (?, ?)')
|
|
1026
1027
|
.run(1, Date.now(), 2, Date.now());
|
|
1027
1028
|
database.exec('COMMIT');
|
|
1029
|
+
migrateNodeSchemaV3(database);
|
|
1030
|
+
assertNodeSchemaV3(database);
|
|
1028
1031
|
return;
|
|
1029
1032
|
}
|
|
1030
1033
|
catch (error) {
|
|
@@ -1061,6 +1064,8 @@ function migrate(database) {
|
|
|
1061
1064
|
}
|
|
1062
1065
|
migrateNodeSchemaV2(database);
|
|
1063
1066
|
assertNodeSchemaV2(database);
|
|
1067
|
+
migrateNodeSchemaV3(database);
|
|
1068
|
+
assertNodeSchemaV3(database);
|
|
1064
1069
|
return;
|
|
1065
1070
|
}
|
|
1066
1071
|
if (current === 0) {
|
|
@@ -1082,12 +1087,12 @@ function migrate(database) {
|
|
|
1082
1087
|
.get();
|
|
1083
1088
|
if (numberValue(afterBaseline, 'version') === 1)
|
|
1084
1089
|
migrateNodeSchemaV2(database);
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1090
|
+
const afterV2 = database
|
|
1091
|
+
.prepare('SELECT MAX(version) AS version FROM node_schema_migrations')
|
|
1092
|
+
.get();
|
|
1093
|
+
if (numberValue(afterV2, 'version') === 2)
|
|
1094
|
+
migrateNodeSchemaV3(database);
|
|
1095
|
+
assertNodeSchemaV3(database);
|
|
1091
1096
|
}
|
|
1092
1097
|
function sessionMetadata(row) {
|
|
1093
1098
|
const raw = JSON.parse(stringValue(row, 'metadata'));
|
|
@@ -1130,6 +1135,7 @@ function initializeEphemeralRuntimeTables(database) {
|
|
|
1130
1135
|
if (match === null || !runtimeTables.has(match[1] ?? ''))
|
|
1131
1136
|
continue;
|
|
1132
1137
|
database.exec(statement
|
|
1138
|
+
.replaceAll("runner IN ('codex', 'claude-code')", "runner IN ('codex', 'claude-code', 'opencode')")
|
|
1133
1139
|
.replace(/^CREATE TABLE IF NOT EXISTS/, 'CREATE TEMP TABLE IF NOT EXISTS')
|
|
1134
1140
|
.replace('CREATE TEMP TABLE IF NOT EXISTS agent_sessions', 'CREATE TEMP TABLE IF NOT EXISTS legacy_agent_sessions')
|
|
1135
1141
|
.replaceAll('REFERENCES agent_sessions', 'REFERENCES legacy_agent_sessions')
|
|
@@ -1389,4 +1395,3 @@ function transitionAllowed(current, next) {
|
|
|
1389
1395
|
(current === 'CANCELLING' &&
|
|
1390
1396
|
(next === 'CANCELLED' || next === 'FAILED' || next === 'INTERRUPTED')));
|
|
1391
1397
|
}
|
|
1392
|
-
//# sourceMappingURL=database.js.map
|
package/dist/event-buffer.js
CHANGED
package/dist/fake-runner.js
CHANGED
package/dist/health.js
CHANGED