@myagentroam/agent 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/cli/codex-auth-file.js +268 -3
- package/dist/cli/main.js +431 -2
- package/dist/error.js +66 -2
- package/dist/host/contracts.js +20 -2
- package/dist/host/local-agent-host.js +146 -2
- package/dist/host/local-process-executor.js +39 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -2
- package/dist/model/anthropic-messages.js +474 -2
- package/dist/model/anthropic-thinking.js +33 -2
- package/dist/model/catalog-file.js +88 -2
- package/dist/model/configuration.js +137 -2
- package/dist/model/contracts.d.ts +2 -0
- package/dist/model/contracts.js +1 -2
- package/dist/model/http.js +529 -2
- package/dist/model/openai-responses.d.ts +2 -0
- package/dist/model/openai-responses.js +1602 -2
- package/dist/model/runtime-credential.js +35 -2
- package/dist/model/sse.js +199 -2
- package/dist/prompts/compact.js +25 -2
- package/dist/prompts/core.js +37 -2
- package/dist/prompts/execution-budget.js +10 -2
- package/dist/prompts/index.d.ts +3 -2
- package/dist/prompts/index.js +47 -2
- package/dist/prompts/modes.js +25 -2
- package/dist/prompts/output.js +1 -2
- package/dist/prompts/resources.d.ts +1 -1
- package/dist/prompts/resources.js +31 -2
- package/dist/prompts/subagent.d.ts +6 -0
- package/dist/prompts/subagent.js +29 -2
- package/dist/prompts/title.js +9 -2
- package/dist/prompts/workflow.js +32 -2
- package/dist/runtime/async-queue.js +62 -2
- package/dist/runtime/builtin-skills.js +19 -2
- package/dist/runtime/byted-ark-imagegen-skill.js +18 -2
- package/dist/runtime/codex-imagegen-skill.js +35 -2
- package/dist/runtime/compact.js +225 -2
- package/dist/runtime/context-gc-runtime.d.ts +35 -0
- package/dist/runtime/context-gc-runtime.js +163 -0
- package/dist/runtime/context-gc-tokens.d.ts +24 -0
- package/dist/runtime/context-gc-tokens.js +83 -0
- package/dist/runtime/context-gc.d.ts +66 -0
- package/dist/runtime/context-gc.js +909 -0
- package/dist/runtime/context-projection.d.ts +23 -0
- package/dist/runtime/context-projection.js +203 -0
- package/dist/runtime/environment-context.js +41 -2
- package/dist/runtime/execution-policy.js +13 -2
- package/dist/runtime/instructions.js +298 -2
- package/dist/runtime/normalize.js +40 -2
- package/dist/runtime/plan-output.js +95 -2
- package/dist/runtime/rollout-budget.d.ts +2 -0
- package/dist/runtime/rollout-budget.js +92 -2
- package/dist/runtime/token-budget.d.ts +2 -0
- package/dist/runtime/token-budget.js +44 -2
- package/dist/sdk/agent.js +1804 -2
- package/dist/sdk/types.d.ts +15 -5
- package/dist/sdk/types.js +1 -2
- package/dist/session/catalog.d.ts +5 -4
- package/dist/session/catalog.js +133 -2
- package/dist/session/context-gc-checkpoint.d.ts +148 -0
- package/dist/session/context-gc-checkpoint.js +665 -0
- package/dist/session/context-gc-replacements.d.ts +52 -0
- package/dist/session/context-gc-replacements.js +226 -0
- package/dist/session/context-gc-subagent.d.ts +43 -0
- package/dist/session/context-gc-subagent.js +267 -0
- package/dist/session/jsonl-store.d.ts +42 -4
- package/dist/session/jsonl-store.js +1657 -2
- package/dist/subagent/scheduler.d.ts +35 -2
- package/dist/subagent/scheduler.js +249 -2
- package/dist/subagent/session-controller.d.ts +94 -0
- package/dist/subagent/session-controller.js +675 -0
- package/dist/tools/agent-cancel.js +28 -2
- package/dist/tools/{task.d.ts → agent-message.d.ts} +2 -2
- package/dist/tools/agent-message.js +51 -0
- package/dist/tools/agent-start.js +84 -2
- package/dist/tools/agent-wait.js +53 -2
- package/dist/tools/apply-patch.js +478 -2
- package/dist/tools/code-mode.js +370 -2
- package/dist/tools/codex-image-gen.js +312 -2
- package/dist/tools/exec.js +455 -2
- package/dist/tools/execution-limits.d.ts +1 -0
- package/dist/tools/execution-limits.js +44 -2
- package/dist/tools/local-registry.js +233 -2
- package/dist/tools/local-workspace-tools.js +28 -2
- package/dist/tools/question.js +124 -2
- package/dist/tools/read-context.d.ts +16 -0
- package/dist/tools/read-context.js +85 -0
- package/dist/tools/read.d.ts +13 -0
- package/dist/tools/read.js +294 -2
- package/dist/tools/registry.js +76 -2
- package/dist/tools/runtime-context.d.ts +9 -2
- package/dist/tools/runtime-context.js +1 -2
- package/dist/tools/runtime.js +21 -2
- package/dist/tools/scheduler.js +41 -2
- package/dist/tools/shared/path-resolver.js +133 -2
- package/dist/tools/skill.js +37 -2
- package/dist/tools/todo-read.js +10 -2
- package/dist/tools/todo-write.js +65 -2
- package/dist/tools/todo.js +67 -2
- package/dist/tools/view-image.js +81 -2
- package/dist/tools/web-fetch.js +11 -2
- package/dist/tools/web-search.js +14 -2
- package/package.json +9 -7
- package/README.md +0 -3
- package/dist/runtime/prompt.d.ts +0 -9
- package/dist/runtime/prompt.js +0 -2
- package/dist/tools/shared/secret-redaction.d.ts +0 -4
- package/dist/tools/shared/secret-redaction.js +0 -2
- package/dist/tools/task-cancel.d.ts +0 -7
- package/dist/tools/task-cancel.js +0 -2
- package/dist/tools/task-output.d.ts +0 -7
- package/dist/tools/task-output.js +0 -2
- package/dist/tools/task-tools.d.ts +0 -36
- package/dist/tools/task-tools.js +0 -2
- package/dist/tools/task.js +0 -2
- package/dist/tools/todo-tools.d.ts +0 -25
- package/dist/tools/todo-tools.js +0 -2
|
@@ -1,2 +1,146 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { mkdir } from 'node:fs/promises';
|
|
3
|
+
import { basename, delimiter, isAbsolute, join, resolve, win32 } from 'node:path';
|
|
4
|
+
import { MAR_AGENT_HOST_API_VERSION } from './contracts.js';
|
|
5
|
+
import { MarAgentError } from '../error.js';
|
|
6
|
+
import { LocalToolRegistry } from '../tools/local-registry.js';
|
|
7
|
+
import { TOOL_EXECUTION_LIMITS } from '../tools/execution-limits.js';
|
|
8
|
+
export class LocalAgentHost {
|
|
9
|
+
#home;
|
|
10
|
+
#workspace;
|
|
11
|
+
#tools;
|
|
12
|
+
#approve;
|
|
13
|
+
#question;
|
|
14
|
+
#mcpTools;
|
|
15
|
+
#callMcp;
|
|
16
|
+
events = [];
|
|
17
|
+
#mode;
|
|
18
|
+
#environment;
|
|
19
|
+
#guaranteedCommands;
|
|
20
|
+
#shell;
|
|
21
|
+
#hasWebSearch;
|
|
22
|
+
#hasWebFetch;
|
|
23
|
+
#resourceIdleTtlMs;
|
|
24
|
+
constructor(input) {
|
|
25
|
+
this.#home = resolve(input.homeDirectory);
|
|
26
|
+
this.#workspace = resolve(input.workspace);
|
|
27
|
+
this.#environment = input.environment ?? process.env;
|
|
28
|
+
this.#guaranteedCommands = input.guaranteedCommands ?? {};
|
|
29
|
+
this.#shell = selectExecutionShell(this.#environment);
|
|
30
|
+
this.#hasWebSearch = input.webSearch !== undefined;
|
|
31
|
+
this.#hasWebFetch = input.webFetch !== false;
|
|
32
|
+
this.#resourceIdleTtlMs = input.resourceIdleTtlMs;
|
|
33
|
+
this.#tools = new LocalToolRegistry(this.#workspace, this.#environment, this.#shell.path, {
|
|
34
|
+
...(input.webSearch ? { webSearch: input.webSearch } : {}),
|
|
35
|
+
webFetch: this.#hasWebFetch,
|
|
36
|
+
allowUntrustedTls: input.allowUntrustedTls ??
|
|
37
|
+
this.#environment['MAR_AGENT_WEB_FETCH_ALLOW_UNTRUSTED_TLS'] === '1',
|
|
38
|
+
...(input.processExecutor === undefined ? {} : { processExecutor: input.processExecutor }),
|
|
39
|
+
...(input.restrictPaths === undefined ? {} : { restrictPaths: input.restrictPaths }),
|
|
40
|
+
...(input.workspaceWritable === undefined
|
|
41
|
+
? {}
|
|
42
|
+
: { workspaceWritable: input.workspaceWritable }),
|
|
43
|
+
...(input.pathMounts === undefined ? {} : { pathMounts: input.pathMounts })
|
|
44
|
+
});
|
|
45
|
+
this.#approve = input.approve;
|
|
46
|
+
this.#mode = input.mode ?? 'normal';
|
|
47
|
+
this.#question = input.question;
|
|
48
|
+
this.#mcpTools = input.mcpTools ?? [];
|
|
49
|
+
this.#callMcp = input.callMcp;
|
|
50
|
+
}
|
|
51
|
+
async describe() {
|
|
52
|
+
await mkdir(this.#home, { recursive: true });
|
|
53
|
+
await mkdir(this.#workspace, { recursive: true });
|
|
54
|
+
return {
|
|
55
|
+
apiVersion: MAR_AGENT_HOST_API_VERSION,
|
|
56
|
+
mode: this.#mode,
|
|
57
|
+
homeDirectory: this.#home,
|
|
58
|
+
platform: process.platform,
|
|
59
|
+
architecture: process.arch,
|
|
60
|
+
shell: this.#shell,
|
|
61
|
+
guaranteedCommands: this.#guaranteedCommands,
|
|
62
|
+
capabilities: [
|
|
63
|
+
'workspace.read',
|
|
64
|
+
'workspace.patch',
|
|
65
|
+
'process.manage',
|
|
66
|
+
'code.execute',
|
|
67
|
+
'approval.request',
|
|
68
|
+
'user-input.request',
|
|
69
|
+
'event.publish',
|
|
70
|
+
'session.store',
|
|
71
|
+
...(this.#hasWebFetch ? ['web.fetch'] : []),
|
|
72
|
+
...(this.#hasWebSearch ? ['web.search'] : [])
|
|
73
|
+
],
|
|
74
|
+
limits: {
|
|
75
|
+
maxProcesses: TOOL_EXECUTION_LIMITS.maxProcesses,
|
|
76
|
+
maxOutputBytes: TOOL_EXECUTION_LIMITS.execDefaultMaxOutputBytes,
|
|
77
|
+
maxExecutionMs: TOOL_EXECUTION_LIMITS.execMaxTimeoutMs
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async executeTool(call, context) {
|
|
82
|
+
const needsApproval = call.name === 'apply_patch' || call.name === 'exec' || call.name === 'code_mode';
|
|
83
|
+
if (context.access === 'on-request' &&
|
|
84
|
+
needsApproval &&
|
|
85
|
+
(await this.#approve?.(call, context.signal)) !== 'approved')
|
|
86
|
+
throw new MarAgentError('MAR_AGENT_TOOL_APPROVAL_DENIED', 'Tool approval was denied or unavailable.');
|
|
87
|
+
return this.#tools.execute(call, context);
|
|
88
|
+
}
|
|
89
|
+
emit(event) {
|
|
90
|
+
this.events.push(event);
|
|
91
|
+
}
|
|
92
|
+
async requestUserInput(input, signal) {
|
|
93
|
+
if (!this.#question)
|
|
94
|
+
throw new MarAgentError('MAR_AGENT_USER_INPUT_UNAVAILABLE', 'User input is unavailable.');
|
|
95
|
+
return this.#question(input, signal);
|
|
96
|
+
}
|
|
97
|
+
listMcpTools() {
|
|
98
|
+
return Promise.resolve(this.#mcpTools);
|
|
99
|
+
}
|
|
100
|
+
async callMcpTool(call, signal) {
|
|
101
|
+
if (!this.#callMcp)
|
|
102
|
+
throw new MarAgentError('MAR_AGENT_MCP_FAILED', 'MCP tool execution is unavailable.');
|
|
103
|
+
return this.#callMcp(call, signal);
|
|
104
|
+
}
|
|
105
|
+
listSessionResources(sessionId) {
|
|
106
|
+
return Promise.resolve({
|
|
107
|
+
...(this.#resourceIdleTtlMs === undefined ? {} : { idleTtlMs: this.#resourceIdleTtlMs }),
|
|
108
|
+
processes: this.#tools.listSessionResources(sessionId)
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
disposeSessionResources(sessionId) {
|
|
112
|
+
return this.#tools.disposeSessionResources(sessionId);
|
|
113
|
+
}
|
|
114
|
+
async dispose() {
|
|
115
|
+
await this.#tools.dispose();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export function selectExecutionShell(environment = process.env, platform = process.platform, available = existsSync) {
|
|
119
|
+
const candidates = platform === 'win32'
|
|
120
|
+
? [
|
|
121
|
+
resolveCommand('pwsh.exe', environment, platform, available),
|
|
122
|
+
resolveCommand('powershell.exe', environment, platform, available),
|
|
123
|
+
environment['ComSpec'],
|
|
124
|
+
environment['COMSPEC'],
|
|
125
|
+
'cmd.exe'
|
|
126
|
+
]
|
|
127
|
+
: ['/bin/bash', resolveCommand('bash', environment, platform, available), '/bin/sh'];
|
|
128
|
+
const path = candidates.find((candidate) => candidate && available(candidate)) ?? candidates.at(-1);
|
|
129
|
+
const name = (platform === 'win32' ? win32.basename(path) : basename(path)).replace(/\.exe$/iu, '');
|
|
130
|
+
return { name, path };
|
|
131
|
+
}
|
|
132
|
+
function resolveCommand(name, environment, platform, available) {
|
|
133
|
+
if (isAbsolute(name))
|
|
134
|
+
return available(name) ? name : undefined;
|
|
135
|
+
const pathValue = environment[platform === 'win32' ? 'Path' : 'PATH'] ?? environment['PATH'];
|
|
136
|
+
if (!pathValue)
|
|
137
|
+
return undefined;
|
|
138
|
+
const separator = platform === 'win32' ? win32.delimiter : delimiter;
|
|
139
|
+
const combine = platform === 'win32' ? win32.join : join;
|
|
140
|
+
for (const directory of pathValue.split(separator).filter(Boolean)) {
|
|
141
|
+
const candidate = combine(directory, name);
|
|
142
|
+
if (available(candidate))
|
|
143
|
+
return candidate;
|
|
144
|
+
}
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
@@ -1,2 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
/** Preserves the direct local execution behavior used by the CLI and normal Node Workbench. */
|
|
3
|
+
export const directLocalProcessExecutor = {
|
|
4
|
+
async spawn(request) {
|
|
5
|
+
return spawn(request.command, [...(request.args ?? [])], {
|
|
6
|
+
cwd: request.cwd,
|
|
7
|
+
shell: request.shell ?? false,
|
|
8
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
9
|
+
windowsHide: true,
|
|
10
|
+
detached: request.detached,
|
|
11
|
+
env: request.environment
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export async function signalProcessTree(child, signal) {
|
|
16
|
+
if (!child.pid)
|
|
17
|
+
return;
|
|
18
|
+
if (process.platform !== 'win32') {
|
|
19
|
+
try {
|
|
20
|
+
process.kill(-child.pid, signal);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (error.code !== 'ESRCH')
|
|
24
|
+
child.kill(signal);
|
|
25
|
+
}
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
await new Promise((resolve) => {
|
|
29
|
+
const killer = spawn('taskkill', ['/pid', String(child.pid), '/T', '/F'], {
|
|
30
|
+
stdio: 'ignore',
|
|
31
|
+
windowsHide: true
|
|
32
|
+
});
|
|
33
|
+
killer.once('error', () => {
|
|
34
|
+
child.kill();
|
|
35
|
+
resolve();
|
|
36
|
+
});
|
|
37
|
+
killer.once('exit', () => resolve());
|
|
38
|
+
});
|
|
39
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,5 +13,5 @@ export type { WorkspacePathMount } from './tools/shared/path-resolver.js';
|
|
|
13
13
|
export { createMarAgent } from './sdk/agent.js';
|
|
14
14
|
export { MAR_AGENT_PROMPT_VERSION, buildSystemPrompt } from './prompts/index.js';
|
|
15
15
|
export { TodoStore, type TodoItem } from './tools/todo.js';
|
|
16
|
-
export { SubagentScheduler, type SubagentOutputOptions, type SubagentRunOptions, type SubagentTaskInput, type SubagentTaskResult, type SubagentTaskSnapshot } from './subagent/scheduler.js';
|
|
16
|
+
export { SubagentScheduler, type SubagentOutputOptions, type SubagentMessageOptions, type SubagentRunOptions, type SubagentTaskInput, type SubagentTaskResult, type SubagentTaskSnapshot } from './subagent/scheduler.js';
|
|
17
17
|
export type { AccessMode, CreateMarAgentOptions, CreateSessionInput, ExecutionHandle, ExecutionMode, ExecutionResult, HostSessionResourceSnapshot, MarAgent, MarAgentEvent, MarAgentHost, MarAgentImageMetadata, MarAgentSession, MarAgentToolArtifact, MarAgentToolImageArtifact, RolloutBudgetOptions, RunInput, RunInputImage, ToolCall, ToolExecutionContext, ToolExecutionResult } from './sdk/types.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { MarAgentError } from './error.js';
|
|
2
|
+
export { SecretValue, marAgentReasoningEffortSchema, parseModelCatalog, resolveModelDefaultReasoningEffort } from './model/configuration.js';
|
|
3
|
+
export { MAR_AGENT_HOST_API_VERSION, negotiateHost } from './host/contracts.js';
|
|
4
|
+
export { OpenAiResponsesAdapter } from './model/openai-responses.js';
|
|
5
|
+
export { AnthropicMessagesAdapter } from './model/anthropic-messages.js';
|
|
6
|
+
export { LocalWorkspaceTools } from './tools/local-workspace-tools.js';
|
|
7
|
+
export { openMarAgentSessionCatalog } from './session/catalog.js';
|
|
8
|
+
export { LocalAgentHost, selectExecutionShell } from './host/local-agent-host.js';
|
|
9
|
+
export { createMarAgent } from './sdk/agent.js';
|
|
10
|
+
export { MAR_AGENT_PROMPT_VERSION, buildSystemPrompt } from './prompts/index.js';
|
|
11
|
+
export { TodoStore } from './tools/todo.js';
|
|
12
|
+
export { SubagentScheduler } from './subagent/scheduler.js';
|