@myagentroam/node 0.9.62 → 0.9.65
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/LICENSE +202 -0
- package/NOTICE +4 -0
- package/dist/capabilities.js +110 -2
- package/dist/claude-agent-sdk.js +330 -2
- package/dist/claude-channel.js +44 -2
- package/dist/codex-app-server.js +510 -2
- package/dist/config.js +106 -2
- package/dist/connector/node-connector-options.js +1 -2
- package/dist/connector/node-operation-router.js +22 -2
- package/dist/connector.js +1736 -2
- package/dist/control-outbound-scheduler.js +153 -2
- package/dist/database.js +639 -2
- package/dist/fake-runner.js +129 -2
- package/dist/git-askpass.js +12 -0
- package/dist/git-execution-helper.js +266 -0
- package/dist/health.js +3 -2
- package/dist/main.js +57 -2
- package/dist/mcp-installation-model.js +1 -2
- package/dist/migrations/v004.js +55 -3
- package/dist/migrations/v005.js +13 -3
- package/dist/migrations/v006.js +90 -3
- package/dist/migrations/v007.js +22 -3
- package/dist/migrations/v008.js +18 -3
- package/dist/migrations/v009.js +70 -4
- package/dist/migrations/v010.js +43 -3
- package/dist/migrations/v011.js +20 -3
- package/dist/migrations/v012.js +8 -0
- package/dist/native-jsonl-reader.js +186 -2
- package/dist/native-session-history.js +1143 -2
- package/dist/opencode-runtime.js +80 -2
- package/dist/opencode-server.js +259 -2
- package/dist/operational.js +122 -2
- package/dist/process-tree.js +18 -2
- package/dist/ripgrep-binary.js +31 -2
- package/dist/rotating-log.js +67 -2
- package/dist/runner/abstract-runner.js +260 -2
- package/dist/runner/claude/managed-run-controller.js +355 -2
- package/dist/runner/claude/tool-normalizer.js +120 -2
- package/dist/runner/claude-code-runner.js +303 -2
- package/dist/runner/codex/composer-image-markers.js +8 -2
- package/dist/runner/codex/conversation-parser.js +913 -2
- package/dist/runner/codex/managed-run-controller.js +494 -2
- package/dist/runner/codex/tool-normalizer.js +214 -2
- package/dist/runner/codex-runner.js +585 -2
- package/dist/runner/fake-test-runner.js +47 -2
- package/dist/runner/mar-agent/conversation-normalizer.js +644 -2
- package/dist/runner/mar-agent/executor-stdio-client-transport.js +139 -2
- package/dist/runner/mar-agent/generated-images.js +41 -2
- package/dist/runner/mar-agent/history-projection.js +106 -2
- package/dist/runner/mar-agent/hosted-conversation-runtime.js +446 -2
- package/dist/runner/mar-agent/managed-run-controller.js +785 -2
- package/dist/runner/mar-agent/mcp-client-pool.js +233 -2
- package/dist/runner/mar-agent/runtime-model-factory.js +326 -2
- package/dist/runner/mar-agent-runner.js +458 -2
- package/dist/runner/opencode/conversation-parser.js +221 -2
- package/dist/runner/opencode/managed-run-controller.js +588 -2
- package/dist/runner/opencode/tool-normalizer.js +80 -2
- package/dist/runner/opencode-runner.js +426 -2
- package/dist/runner/runner-registry.js +87 -2
- package/dist/runner-command-engine.js +71 -2
- package/dist/runner-profiles.js +323 -2
- package/dist/runner-usage.js +190 -2
- package/dist/runtime-command-detector.js +73 -2
- package/dist/runtime-model.js +1 -2
- package/dist/runtime-state.js +1509 -2
- package/dist/service/attachment-domain-state.js +7 -2
- package/dist/service/bubblewrap-sandbox-executor.js +543 -2
- package/dist/service/continuous-run-coordinator.js +425 -2
- package/dist/service/conversation-history-service.js +552 -2
- package/dist/service/conversation-hosting-capability-service.js +61 -2
- package/dist/service/conversation-hosting-enablement-service.js +91 -2
- package/dist/service/conversation-hosting-maintenance-service.js +174 -2
- package/dist/service/conversation-segment-service.js +162 -2
- package/dist/service/conversation-template-node-service.js +992 -2
- package/dist/service/external-session-resume-service.js +152 -2
- package/dist/service/fake-managed-run-service.js +60 -2
- package/dist/service/git-execution-service.js +418 -0
- package/dist/service/git-operation-service.js +57 -0
- package/dist/service/hosted-conversation-node-service.js +1982 -2
- package/dist/service/hosted-conversation-store.js +1405 -2
- package/dist/service/managed-runner-session-service.js +35 -2
- package/dist/service/mar-agent-model-transport-test-service.js +88 -2
- package/dist/service/mcp-installation-verifier.js +87 -2
- package/dist/service/mcp-node-operation-service.js +90 -2
- package/dist/service/mission-mcp-server.js +124 -2
- package/dist/service/mission-mcp-stdio.js +40 -2
- package/dist/service/mission-runtime.js +142 -2
- package/dist/service/native-session-projection-service.js +274 -2
- package/dist/service/native-session-watch-service.js +683 -2
- package/dist/service/node-connection-lifecycle-service.js +88 -2
- package/dist/service/node-control-channel.js +85 -2
- package/dist/service/node-control-message-service.js +109 -2
- package/dist/service/node-request-service.js +62 -2
- package/dist/service/node-run-event-bridge.js +88 -2
- package/dist/service/node-terminal-channel.js +202 -2
- package/dist/service/node-upgrade-coordinator.js +137 -2
- package/dist/service/node-workspace-coordinator.js +97 -2
- package/dist/service/recent-run-projection-service.js +99 -2
- package/dist/service/run-attachment-service.js +321 -2
- package/dist/service/run-domain-state.js +4 -2
- package/dist/service/run-event-service.js +246 -2
- package/dist/service/run-ownership-policy.js +22 -2
- package/dist/service/run-workbench-service.js +120 -2
- package/dist/service/runner-channel-message-service.js +20 -2
- package/dist/service/runner-interaction-service.js +243 -2
- package/dist/service/runner-service.js +69 -2
- package/dist/service/runtime-credential-control-service.js +95 -2
- package/dist/service/session-catalog-service.js +404 -2
- package/dist/service/session-command-service.js +125 -2
- package/dist/service/session-context-service.js +128 -2
- package/dist/service/session-domain-state.js +9 -2
- package/dist/service/session-identity-service.js +86 -2
- package/dist/service/session-lifecycle-service.js +248 -2
- package/dist/service/session-message-service.js +270 -2
- package/dist/service/session-presentation-service.js +43 -2
- package/dist/service/session-query-service.js +82 -2
- package/dist/service/session-watch-slot-coordinator.js +21 -2
- package/dist/service/skill-directory-service.js +238 -2
- package/dist/service/skill-install-service.js +434 -2
- package/dist/service/skill-node-operation-service.js +206 -2
- package/dist/service/terminal-relay-state.js +3 -2
- package/dist/service/terminal-service.js +90 -2
- package/dist/service/web-search-error.js +40 -2
- package/dist/service/workbench-event-service.js +21 -2
- package/dist/service/workbench-manifest-service.js +69 -2
- package/dist/service/workspace-change-service.js +290 -2
- package/dist/service/workspace-content-search-service.js +457 -2
- package/dist/service/workspace-domain-state.js +41 -2
- package/dist/service/workspace-file-service.js +150 -2
- package/dist/service/workspace-git-exclude-service.js +119 -2
- package/dist/service/workspace-queue-workbench-service.js +176 -2
- package/dist/service/workspace-service.js +92 -2
- package/dist/service/workspace-session-service.js +154 -2
- package/dist/service/workspace-upload-service.js +262 -2
- package/dist/service/workspace-watch-controller.js +68 -2
- package/dist/service/workspace-watch-service.js +170 -2
- package/dist/service/workspace-watch-snapshot-service.js +218 -2
- package/dist/service/workspace-workbench-service.js +239 -2
- package/dist/service.js +91 -2
- package/dist/storage.js +32 -2
- package/dist/supervisor.js +136 -2
- package/dist/terminal.js +496 -2
- package/dist/util/git-credential-client.js +32 -0
- package/dist/util/node-operation-data.js +9 -2
- package/dist/util/node-operation-parsers.js +382 -2
- package/dist/util/personal-instructions.js +34 -2
- package/dist/util/runner-error.js +70 -2
- package/dist/util/runner-native-session-parsers.js +510 -2
- package/dist/util/safe-error.js +8 -2
- package/dist/util/secret-environment.js +25 -2
- package/dist/workspace.js +1793 -2
- package/package.json +11 -8
- package/vendor/ripgrep/darwin-arm64/rg +0 -0
- package/vendor/ripgrep/darwin-x64/rg +0 -0
- package/vendor/ripgrep/manifest.json +12 -0
- package/README.md +0 -42
- package/dist/event-buffer.js +0 -2
- package/dist/migrations/v001.js +0 -107
- package/dist/migrations/v002.js +0 -2
- package/dist/migrations/v003.js +0 -2
- package/dist/service/mcp-package-installer.js +0 -2
|
@@ -1,2 +1,139 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { PassThrough } from 'node:stream';
|
|
2
|
+
import { ReadBuffer, serializeMessage } from '@modelcontextprotocol/sdk/shared/stdio.js';
|
|
3
|
+
/** MCP stdio transport whose process creation is delegated to the Host executor. */
|
|
4
|
+
export class ExecutorStdioClientTransport {
|
|
5
|
+
options;
|
|
6
|
+
onclose;
|
|
7
|
+
onerror;
|
|
8
|
+
onmessage;
|
|
9
|
+
#readBuffer;
|
|
10
|
+
#stderr = new PassThrough();
|
|
11
|
+
#child;
|
|
12
|
+
#closing;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.options = options;
|
|
15
|
+
this.#readBuffer = new ReadBuffer(options.maxBufferSize === undefined ? {} : { maxBufferSize: options.maxBufferSize });
|
|
16
|
+
}
|
|
17
|
+
get stderr() {
|
|
18
|
+
return this.#stderr;
|
|
19
|
+
}
|
|
20
|
+
get pid() {
|
|
21
|
+
return this.#child?.pid ?? null;
|
|
22
|
+
}
|
|
23
|
+
async start() {
|
|
24
|
+
if (this.#child !== undefined)
|
|
25
|
+
throw new Error('MCP_EXECUTOR_TRANSPORT_ALREADY_STARTED');
|
|
26
|
+
const child = await this.options.processExecutor.spawn({
|
|
27
|
+
command: this.options.command,
|
|
28
|
+
...(this.options.args === undefined ? {} : { args: this.options.args }),
|
|
29
|
+
cwd: this.options.cwd,
|
|
30
|
+
shell: false,
|
|
31
|
+
environment: this.options.environment,
|
|
32
|
+
environmentKeys: this.options.environmentKeys,
|
|
33
|
+
detached: process.platform !== 'win32',
|
|
34
|
+
owner: this.options.owner
|
|
35
|
+
});
|
|
36
|
+
this.#child = child;
|
|
37
|
+
child.once('error', (error) => this.onerror?.(error));
|
|
38
|
+
child.once('close', () => {
|
|
39
|
+
if (this.#child === child)
|
|
40
|
+
this.#child = undefined;
|
|
41
|
+
this.onclose?.();
|
|
42
|
+
});
|
|
43
|
+
child.stdin.on('error', (error) => this.onerror?.(error));
|
|
44
|
+
child.stdout.on('error', (error) => this.onerror?.(error));
|
|
45
|
+
child.stdout.on('data', (chunk) => {
|
|
46
|
+
try {
|
|
47
|
+
this.#readBuffer.append(chunk);
|
|
48
|
+
this.#processReadBuffer();
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
this.onerror?.(asError(error));
|
|
52
|
+
void this.close();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
child.stderr.pipe(this.#stderr);
|
|
56
|
+
}
|
|
57
|
+
async send(message) {
|
|
58
|
+
const child = this.#child;
|
|
59
|
+
if (child === undefined)
|
|
60
|
+
throw new Error('MCP_EXECUTOR_TRANSPORT_NOT_CONNECTED');
|
|
61
|
+
const content = serializeMessage(message);
|
|
62
|
+
if (child.stdin.write(content))
|
|
63
|
+
return;
|
|
64
|
+
await new Promise((resolve, reject) => {
|
|
65
|
+
const error = (value) => {
|
|
66
|
+
child.stdin.off('drain', resolve);
|
|
67
|
+
reject(value);
|
|
68
|
+
};
|
|
69
|
+
child.stdin.once('error', error);
|
|
70
|
+
child.stdin.once('drain', () => {
|
|
71
|
+
child.stdin.off('error', error);
|
|
72
|
+
resolve();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
close() {
|
|
77
|
+
if (this.#closing !== undefined)
|
|
78
|
+
return this.#closing;
|
|
79
|
+
this.#closing = this.#close();
|
|
80
|
+
return this.#closing;
|
|
81
|
+
}
|
|
82
|
+
async #close() {
|
|
83
|
+
const child = this.#child;
|
|
84
|
+
this.#child = undefined;
|
|
85
|
+
this.#readBuffer.clear();
|
|
86
|
+
if (child === undefined)
|
|
87
|
+
return;
|
|
88
|
+
child.stdin.end();
|
|
89
|
+
if (child.exitCode === null)
|
|
90
|
+
await signalProcessTree(child, 'SIGTERM');
|
|
91
|
+
if (!(await waitForClose(child, 2_000)))
|
|
92
|
+
await signalProcessTree(child, 'SIGKILL');
|
|
93
|
+
await waitForClose(child, 2_000);
|
|
94
|
+
}
|
|
95
|
+
#processReadBuffer() {
|
|
96
|
+
while (true) {
|
|
97
|
+
const message = this.#readBuffer.readMessage();
|
|
98
|
+
if (message === null)
|
|
99
|
+
return;
|
|
100
|
+
this.onmessage?.(message);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function signalProcessTree(child, signal) {
|
|
105
|
+
if (child.pid === undefined)
|
|
106
|
+
return;
|
|
107
|
+
if (process.platform !== 'win32') {
|
|
108
|
+
try {
|
|
109
|
+
process.kill(-child.pid, signal);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
if (error.code === 'ESRCH')
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
child.kill(signal);
|
|
118
|
+
}
|
|
119
|
+
async function waitForClose(child, timeoutMs) {
|
|
120
|
+
if (child.exitCode !== null)
|
|
121
|
+
return true;
|
|
122
|
+
let timer;
|
|
123
|
+
try {
|
|
124
|
+
return await Promise.race([
|
|
125
|
+
new Promise((resolve) => child.once('close', () => resolve(true))),
|
|
126
|
+
new Promise((resolve) => {
|
|
127
|
+
timer = setTimeout(() => resolve(false), timeoutMs);
|
|
128
|
+
timer.unref();
|
|
129
|
+
})
|
|
130
|
+
]);
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
if (timer !== undefined)
|
|
134
|
+
clearTimeout(timer);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function asError(value) {
|
|
138
|
+
return value instanceof Error ? value : new Error(String(value));
|
|
139
|
+
}
|
|
@@ -1,2 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
import { posix, resolve } from 'node:path';
|
|
2
|
+
const HOSTED_CONVERSATION_IMAGE_RUN_PREFIX = 'native-history:hosted:';
|
|
3
|
+
const HOSTED_CONVERSATION_SANDBOX_HOME = '/home/mar';
|
|
4
|
+
export function marAgentGeneratedImagesDirectory(homeDirectory, sessionId) {
|
|
5
|
+
if (!safePathSegment(sessionId))
|
|
6
|
+
return undefined;
|
|
7
|
+
return resolve(homeDirectory, '.mar', 'agent', 'sessions', sessionId, 'generated_images');
|
|
8
|
+
}
|
|
9
|
+
export function hostedConversationImageRunId(conversationId) {
|
|
10
|
+
return `${HOSTED_CONVERSATION_IMAGE_RUN_PREFIX}${conversationId}`;
|
|
11
|
+
}
|
|
12
|
+
export function hostedConversationGeneratedImagesDisplayDirectory(sessionId) {
|
|
13
|
+
if (!safePathSegment(sessionId))
|
|
14
|
+
return undefined;
|
|
15
|
+
return posix.join(HOSTED_CONVERSATION_SANDBOX_HOME, '.mar', 'agent', 'sessions', sessionId, 'generated_images');
|
|
16
|
+
}
|
|
17
|
+
export function isHostedConversationImageRunId(runId) {
|
|
18
|
+
return runId.startsWith(HOSTED_CONVERSATION_IMAGE_RUN_PREFIX);
|
|
19
|
+
}
|
|
20
|
+
export function marAgentGeneratedImageSources(homeDirectory, sessionId, artifacts) {
|
|
21
|
+
const directory = marAgentGeneratedImagesDirectory(homeDirectory, sessionId);
|
|
22
|
+
if (directory === undefined)
|
|
23
|
+
return [];
|
|
24
|
+
return artifacts.flatMap((artifact) => safePathSegment(artifact.fileName)
|
|
25
|
+
? [
|
|
26
|
+
{
|
|
27
|
+
name: artifact.name,
|
|
28
|
+
mime: artifact.mime,
|
|
29
|
+
localPath: resolve(directory, artifact.fileName)
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
: []);
|
|
33
|
+
}
|
|
34
|
+
function safePathSegment(value) {
|
|
35
|
+
return (value.length > 0 &&
|
|
36
|
+
value.length <= 255 &&
|
|
37
|
+
value !== '.' &&
|
|
38
|
+
value !== '..' &&
|
|
39
|
+
!value.includes('/') &&
|
|
40
|
+
!value.includes('\\'));
|
|
41
|
+
}
|
|
@@ -1,2 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { MarAgentConversationNormalizer } from './conversation-normalizer.js';
|
|
2
|
+
export function projectMarAgentHistory(session, entries, options = {}) {
|
|
3
|
+
const turns = new Map();
|
|
4
|
+
const normalizer = new MarAgentConversationNormalizer();
|
|
5
|
+
const ensure = (turnId, at) => {
|
|
6
|
+
const existing = turns.get(turnId);
|
|
7
|
+
if (existing)
|
|
8
|
+
return existing;
|
|
9
|
+
const previous = [...turns.values()].at(-1);
|
|
10
|
+
const created = {
|
|
11
|
+
id: turnId,
|
|
12
|
+
sessionId: session.id,
|
|
13
|
+
runId: null,
|
|
14
|
+
userItemId: null,
|
|
15
|
+
status: 'INTERRUPTED',
|
|
16
|
+
model: session.model,
|
|
17
|
+
effort: session.effort,
|
|
18
|
+
access: session.access,
|
|
19
|
+
rewind: { before: previous?.id ?? null, after: turnId },
|
|
20
|
+
items: [],
|
|
21
|
+
startedAt: at,
|
|
22
|
+
completedAt: at
|
|
23
|
+
};
|
|
24
|
+
turns.set(turnId, created);
|
|
25
|
+
return created;
|
|
26
|
+
};
|
|
27
|
+
const replace = (turn, item) => {
|
|
28
|
+
const index = turn.items.findIndex((candidate) => candidate.id === item.id);
|
|
29
|
+
const items = [...turn.items];
|
|
30
|
+
if (index < 0)
|
|
31
|
+
items.push(item);
|
|
32
|
+
else
|
|
33
|
+
items[index] = { ...items[index], ...item, startedAt: items[index].startedAt };
|
|
34
|
+
turns.set(turn.id, { ...turn, items, completedAt: item.completedAt ?? turn.completedAt });
|
|
35
|
+
};
|
|
36
|
+
for (const entry of entries) {
|
|
37
|
+
if (entry.kind === 'user') {
|
|
38
|
+
const at = Date.parse(entry.timestamp);
|
|
39
|
+
const turn = ensure(entry.turnId, at);
|
|
40
|
+
const id = `${entry.turnId}:user`;
|
|
41
|
+
const images = entry.images;
|
|
42
|
+
const registeredImages = images === undefined ? [] : (options.registerInputImages?.(entry) ?? []);
|
|
43
|
+
replace(turn, historyItem(session, turn, id, 'user_message', 'COMPLETED', {
|
|
44
|
+
clientMessageId: entry.clientMessageId ?? null,
|
|
45
|
+
text: entry.text,
|
|
46
|
+
contexts: [],
|
|
47
|
+
delivery: 'ACCEPTED',
|
|
48
|
+
...(images?.length
|
|
49
|
+
? {
|
|
50
|
+
attachments: images.map((image, imageIndex) => registeredImages[imageIndex] ?? {
|
|
51
|
+
name: image.name,
|
|
52
|
+
mime: image.mimeType,
|
|
53
|
+
byteSize: image.byteSize
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
: {})
|
|
57
|
+
}, at));
|
|
58
|
+
turns.set(entry.turnId, { ...turns.get(entry.turnId), userItemId: id });
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const event = entry.event;
|
|
62
|
+
if (event.turnId === undefined)
|
|
63
|
+
continue;
|
|
64
|
+
const at = Date.parse(event.timestamp);
|
|
65
|
+
const turn = ensure(event.turnId, at);
|
|
66
|
+
if (event.type === 'execution.completed' ||
|
|
67
|
+
event.type === 'execution.failed' ||
|
|
68
|
+
event.type === 'execution.cancelled') {
|
|
69
|
+
turns.set(event.turnId, {
|
|
70
|
+
...turn,
|
|
71
|
+
status: event.type === 'execution.completed'
|
|
72
|
+
? 'SUCCEEDED'
|
|
73
|
+
: event.type === 'execution.failed'
|
|
74
|
+
? 'FAILED'
|
|
75
|
+
: 'INTERRUPTED',
|
|
76
|
+
completedAt: at
|
|
77
|
+
});
|
|
78
|
+
if (event.type !== 'execution.failed')
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const projectionTurn = turns.get(event.turnId) ?? turn;
|
|
82
|
+
for (const projected of normalizer.normalize(event)) {
|
|
83
|
+
const attachments = projected.generatedImages === undefined
|
|
84
|
+
? []
|
|
85
|
+
: (options.registerGeneratedImages?.(event.sessionId, projected.generatedImages) ?? []);
|
|
86
|
+
replace(projectionTurn, historyItem(session, projectionTurn, projected.itemId, projected.kind, projected.status, attachments.length === 0 ? projected.payload : { ...projected.payload, attachments }, at));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return [...turns.values()];
|
|
90
|
+
}
|
|
91
|
+
function historyItem(session, turn, id, kind, status, payload, at) {
|
|
92
|
+
return {
|
|
93
|
+
id,
|
|
94
|
+
sessionId: session.id,
|
|
95
|
+
turnId: turn.id,
|
|
96
|
+
runId: turn.runId,
|
|
97
|
+
parentItemId: null,
|
|
98
|
+
sourceSequence: null,
|
|
99
|
+
revision: 0,
|
|
100
|
+
kind,
|
|
101
|
+
status,
|
|
102
|
+
payload,
|
|
103
|
+
startedAt: at,
|
|
104
|
+
completedAt: status === 'IN_PROGRESS' ? null : at
|
|
105
|
+
};
|
|
106
|
+
}
|