@myagentroam/agent 0.9.62 → 0.9.64
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 +427 -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,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { MarAgentError } from '../error.js';
|
|
2
|
+
export const agentCancelToolDefinition = {
|
|
3
|
+
name: 'agent_cancel',
|
|
4
|
+
parallelSafety: 'serial',
|
|
5
|
+
description: 'Idempotently cancel a child agent using the agentId returned by agent_start. For an exec processId, use exec with action:"cancel" instead. Waits for a running task to reach cancelled and returns its agentId and description.',
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: { agentId: { type: 'string' } },
|
|
9
|
+
required: ['agentId'],
|
|
10
|
+
additionalProperties: false
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export async function executeAgentCancel(arguments_, context) {
|
|
14
|
+
if (!arguments_ || typeof arguments_ !== 'object' || Array.isArray(arguments_))
|
|
15
|
+
return invalid();
|
|
16
|
+
const input = arguments_;
|
|
17
|
+
if (Object.keys(input).some((key) => key !== 'agentId') ||
|
|
18
|
+
typeof input.agentId !== 'string' ||
|
|
19
|
+
input.agentId.trim().length === 0)
|
|
20
|
+
return invalid();
|
|
21
|
+
if (!context.subagents)
|
|
22
|
+
throw new MarAgentError('MAR_AGENT_SUBAGENT_RECURSION_DISABLED', 'Subagents cannot recurse.');
|
|
23
|
+
const task = await context.subagents.cancel(input.agentId);
|
|
24
|
+
return { content: JSON.stringify(task), data: task };
|
|
25
|
+
}
|
|
26
|
+
function invalid() {
|
|
27
|
+
throw new MarAgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Agent cancellation input is invalid.');
|
|
28
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ClientToolDefinition } from '../model/contracts.js';
|
|
2
2
|
import type { ToolRuntimeContext } from './runtime-context.js';
|
|
3
|
-
export declare const
|
|
4
|
-
export declare function
|
|
3
|
+
export declare const agentMessageToolDefinition: ClientToolDefinition;
|
|
4
|
+
export declare function executeAgentMessage(arguments_: unknown, context: ToolRuntimeContext): Promise<{
|
|
5
5
|
content: string;
|
|
6
6
|
data: import("../subagent/scheduler.js").SubagentTaskSnapshot;
|
|
7
7
|
}>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { MarAgentError } from '../error.js';
|
|
2
|
+
import { TOOL_EXECUTION_LIMITS } from './execution-limits.js';
|
|
3
|
+
export const agentMessageToolDefinition = {
|
|
4
|
+
name: 'agent_message',
|
|
5
|
+
parallelSafety: 'serial',
|
|
6
|
+
description: 'Send a real user message to an existing child agent. Default delivery=append inserts guidance into a running child turn at the next safe boundary after the current model response or complete tool batch. Explicit delivery=replace immediately requests cancellation, waits for the old turn to close, then starts a new turn in the same Session. When idle, either mode starts a new turn using persisted history. Returns messageId, turnId and deliveryStatus: accepted means queued in memory; applied means persisted in model context, not that the guidance has been executed. Use agent_wait for the latest receipt and task status. Does not wait for the new task to complete or roll back existing side effects.',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
agentId: { type: 'string' },
|
|
11
|
+
delivery: { type: 'string', enum: ['append', 'replace'], default: 'append' },
|
|
12
|
+
message: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: 'Non-empty follow-up message for the existing child Session.'
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
required: ['agentId', 'message'],
|
|
18
|
+
additionalProperties: false
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export async function executeAgentMessage(arguments_, context) {
|
|
22
|
+
const input = parseAgentMessageInput(arguments_);
|
|
23
|
+
if (!context.subagents)
|
|
24
|
+
throw new MarAgentError('MAR_AGENT_SUBAGENT_RECURSION_DISABLED', 'Subagents cannot recurse.');
|
|
25
|
+
const task = await context.subagents.message(input.agentId, input.message, {
|
|
26
|
+
delivery: input.delivery ?? 'append',
|
|
27
|
+
signal: context.signal
|
|
28
|
+
});
|
|
29
|
+
return { content: JSON.stringify(task), data: task };
|
|
30
|
+
}
|
|
31
|
+
function parseAgentMessageInput(value) {
|
|
32
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
33
|
+
return invalid();
|
|
34
|
+
const input = value;
|
|
35
|
+
if (Object.keys(input).some((key) => !['agentId', 'message', 'delivery'].includes(key)) ||
|
|
36
|
+
(input.delivery !== undefined && input.delivery !== 'append' && input.delivery !== 'replace') ||
|
|
37
|
+
typeof input.agentId !== 'string' ||
|
|
38
|
+
input.agentId.trim().length === 0 ||
|
|
39
|
+
typeof input.message !== 'string' ||
|
|
40
|
+
input.message.trim().length === 0 ||
|
|
41
|
+
Buffer.byteLength(input.message) > TOOL_EXECUTION_LIMITS.subagentMessageMaxBytes)
|
|
42
|
+
return invalid();
|
|
43
|
+
return {
|
|
44
|
+
agentId: input.agentId.trim(),
|
|
45
|
+
message: input.message,
|
|
46
|
+
...(input.delivery === undefined ? {} : { delivery: input.delivery })
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function invalid() {
|
|
50
|
+
throw new MarAgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Agent message input is invalid.');
|
|
51
|
+
}
|
|
@@ -1,2 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { MarAgentError } from '../error.js';
|
|
2
|
+
import { marAgentReasoningEffortSchema } from '../model/configuration.js';
|
|
3
|
+
import { TOOL_EXECUTION_LIMITS } from './execution-limits.js';
|
|
4
|
+
export const agentStartToolDefinition = {
|
|
5
|
+
name: 'agent_start',
|
|
6
|
+
parallelSafety: 'serial',
|
|
7
|
+
description: 'Start one bounded, non-recursive child agent with self-contained context. Use when an independent investigation would consume substantial main-context space or when safe parallel work has real value; keep small or tightly coupled work in the main context. All agents share the filesystem, so avoid conflicting writes. The optional reasoningEffort overrides the parent effort and must be supported by the selected model; omit it to inherit. Returns agentId for agent_wait, agent_message, or agent_cancel, description, queued/running/completed/failed/cancelled status, bounded summary, changedFiles, verification, and read evidence; background returns immediately while foreground waits for a terminal result.',
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
description: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
maxLength: TOOL_EXECUTION_LIMITS.subagentDescriptionMaxCharacters
|
|
14
|
+
},
|
|
15
|
+
prompt: { type: 'string', description: 'Self-contained bounded task prompt.' },
|
|
16
|
+
role: { enum: ['general-purpose', 'explore'] },
|
|
17
|
+
modelId: { type: 'string' },
|
|
18
|
+
reasoningEffort: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
enum: marAgentReasoningEffortSchema.options,
|
|
21
|
+
maxLength: TOOL_EXECUTION_LIMITS.subagentReasoningEffortMaxCharacters,
|
|
22
|
+
description: 'Reasoning effort override for the subagent. Omit to inherit the parent effort.'
|
|
23
|
+
},
|
|
24
|
+
background: { type: 'boolean' }
|
|
25
|
+
},
|
|
26
|
+
required: ['description', 'prompt', 'role'],
|
|
27
|
+
additionalProperties: false
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export async function executeAgentStart(arguments_, context) {
|
|
31
|
+
const value = parseAgentStartInput(arguments_);
|
|
32
|
+
if (!context.subagents)
|
|
33
|
+
throw new MarAgentError('MAR_AGENT_SUBAGENT_RECURSION_DISABLED', 'Subagents cannot recurse.');
|
|
34
|
+
const task = await context.subagents.run(value, {
|
|
35
|
+
signal: context.signal,
|
|
36
|
+
onCreated: async (created) => context.emit({
|
|
37
|
+
type: 'subagent.started',
|
|
38
|
+
agentId: created.agentId,
|
|
39
|
+
description: created.description,
|
|
40
|
+
...(created.modelId === undefined ? {} : { modelId: created.modelId }),
|
|
41
|
+
...(created.modelName === undefined ? {} : { modelName: created.modelName }),
|
|
42
|
+
...(created.reasoningEffort === undefined
|
|
43
|
+
? {}
|
|
44
|
+
: { reasoningEffort: created.reasoningEffort })
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
return { content: JSON.stringify(task), data: task };
|
|
48
|
+
}
|
|
49
|
+
function parseAgentStartInput(value) {
|
|
50
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
51
|
+
return invalidAgentStart();
|
|
52
|
+
const input = value;
|
|
53
|
+
if (Object.keys(input).some((key) => !['description', 'prompt', 'role', 'modelId', 'reasoningEffort', 'background'].includes(key)) ||
|
|
54
|
+
typeof input.description !== 'string' ||
|
|
55
|
+
input.description.trim().length === 0 ||
|
|
56
|
+
input.description.length > TOOL_EXECUTION_LIMITS.subagentDescriptionMaxCharacters ||
|
|
57
|
+
typeof input.prompt !== 'string' ||
|
|
58
|
+
input.prompt.trim().length === 0 ||
|
|
59
|
+
Buffer.byteLength(input.prompt) > TOOL_EXECUTION_LIMITS.subagentPromptMaxBytes ||
|
|
60
|
+
!['general-purpose', 'explore'].includes(String(input.role)) ||
|
|
61
|
+
(input.modelId !== undefined &&
|
|
62
|
+
input.modelId !== null &&
|
|
63
|
+
(typeof input.modelId !== 'string' || input.modelId.trim().length === 0)) ||
|
|
64
|
+
(input.reasoningEffort !== undefined &&
|
|
65
|
+
(typeof input.reasoningEffort !== 'string' ||
|
|
66
|
+
!marAgentReasoningEffortSchema.safeParse(input.reasoningEffort.trim()).success)) ||
|
|
67
|
+
(input.background !== undefined &&
|
|
68
|
+
input.background !== null &&
|
|
69
|
+
typeof input.background !== 'boolean'))
|
|
70
|
+
return invalidAgentStart();
|
|
71
|
+
return {
|
|
72
|
+
description: input.description.trim(),
|
|
73
|
+
prompt: input.prompt,
|
|
74
|
+
role: input.role,
|
|
75
|
+
...(typeof input.modelId === 'string' ? { modelId: input.modelId } : {}),
|
|
76
|
+
...(typeof input.reasoningEffort === 'string'
|
|
77
|
+
? { reasoningEffort: marAgentReasoningEffortSchema.parse(input.reasoningEffort.trim()) }
|
|
78
|
+
: {}),
|
|
79
|
+
...(typeof input.background === 'boolean' ? { background: input.background } : {})
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function invalidAgentStart() {
|
|
83
|
+
throw new MarAgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Agent start input is invalid.');
|
|
84
|
+
}
|
package/dist/tools/agent-wait.js
CHANGED
|
@@ -1,2 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { MarAgentError } from '../error.js';
|
|
2
|
+
import { TOOL_EXECUTION_LIMITS } from './execution-limits.js';
|
|
3
|
+
export const agentWaitToolDefinition = {
|
|
4
|
+
name: 'agent_wait',
|
|
5
|
+
parallelSafety: 'serial',
|
|
6
|
+
description: 'Read or wait a bounded time for a child agent result using the agentId returned by agent_start. For an exec processId, use exec with action:"poll" instead. Omitting waitMs waits up to 30 seconds by default; waitMs=0 returns the current snapshot immediately. Positive waits range up to 5 minutes, and positive values below 10 seconds are raised to 10 seconds. Every result includes agentId and description. A queued or running result is not completion; wait again only when useful, or cancel if no longer needed. Terminal results include bounded summary, changedFiles, verification, and read evidence with path/line ranges; use that evidence to avoid repeating the full exploration, while independently checking consequential edits and claims. Preserve agentId and avoid busy polling.',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
agentId: { type: 'string' },
|
|
11
|
+
waitMs: {
|
|
12
|
+
type: 'integer',
|
|
13
|
+
minimum: TOOL_EXECUTION_LIMITS.agentWaitMinWaitMs,
|
|
14
|
+
maximum: TOOL_EXECUTION_LIMITS.agentWaitMaxWaitMs,
|
|
15
|
+
default: TOOL_EXECUTION_LIMITS.agentWaitDefaultWaitMs,
|
|
16
|
+
description: `Timeout in milliseconds. Defaults to ${TOOL_EXECUTION_LIMITS.agentWaitDefaultWaitMs}, min ${TOOL_EXECUTION_LIMITS.agentWaitMinWaitMs}, max ${TOOL_EXECUTION_LIMITS.agentWaitMaxWaitMs}. Zero returns immediately. Positive values below ${TOOL_EXECUTION_LIMITS.agentWaitWaitFloorMs} are raised to ${TOOL_EXECUTION_LIMITS.agentWaitWaitFloorMs}.`
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
required: ['agentId'],
|
|
20
|
+
additionalProperties: false
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export async function executeAgentWait(arguments_, context) {
|
|
24
|
+
const value = parseAgentWaitInput(arguments_);
|
|
25
|
+
if (!context.subagents)
|
|
26
|
+
throw new MarAgentError('MAR_AGENT_SUBAGENT_RECURSION_DISABLED', 'Subagents cannot recurse.');
|
|
27
|
+
const task = await context.subagents.output(value.agentId, {
|
|
28
|
+
waitMs: value.waitMs ?? TOOL_EXECUTION_LIMITS.agentWaitDefaultWaitMs,
|
|
29
|
+
signal: context.signal
|
|
30
|
+
});
|
|
31
|
+
return { content: JSON.stringify(task), data: task };
|
|
32
|
+
}
|
|
33
|
+
function parseAgentWaitInput(value) {
|
|
34
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
35
|
+
return invalidAgentWait();
|
|
36
|
+
const input = value;
|
|
37
|
+
if (Object.keys(input).some((key) => !['agentId', 'waitMs'].includes(key)) ||
|
|
38
|
+
typeof input.agentId !== 'string' ||
|
|
39
|
+
input.agentId.trim().length === 0 ||
|
|
40
|
+
(input.waitMs !== undefined &&
|
|
41
|
+
input.waitMs !== null &&
|
|
42
|
+
(!Number.isInteger(input.waitMs) ||
|
|
43
|
+
input.waitMs < TOOL_EXECUTION_LIMITS.agentWaitMinWaitMs ||
|
|
44
|
+
input.waitMs > TOOL_EXECUTION_LIMITS.agentWaitMaxWaitMs)))
|
|
45
|
+
return invalidAgentWait();
|
|
46
|
+
return {
|
|
47
|
+
agentId: input.agentId,
|
|
48
|
+
...(typeof input.waitMs === 'number' ? { waitMs: input.waitMs } : {})
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function invalidAgentWait() {
|
|
52
|
+
throw new MarAgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Agent wait input is invalid.');
|
|
53
|
+
}
|