@myagentroam/agent 0.11.39 → 0.11.41
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/dist/cli/catalog-file.d.ts +2 -0
- package/dist/cli/main.js +11 -4
- package/dist/cli/subagent/control.d.ts +56 -0
- package/dist/cli/subagent/control.js +219 -0
- package/dist/cli/subagent/history.d.ts +17 -0
- package/dist/cli/subagent/history.js +85 -0
- package/dist/cli/subagent/index.d.ts +10 -0
- package/dist/cli/subagent/index.js +94 -0
- package/dist/cli/subagent/native.d.ts +91 -0
- package/dist/cli/subagent/native.js +359 -0
- package/dist/cli/subagent/observations.d.ts +57 -0
- package/dist/cli/subagent/observations.js +351 -0
- package/dist/cli/subagent/query.d.ts +4 -0
- package/dist/cli/subagent/query.js +114 -0
- package/dist/cli/subagent/resources.d.ts +3 -0
- package/dist/cli/subagent/resources.js +112 -0
- package/dist/cli/subagent/snapshot.d.ts +77 -0
- package/dist/cli/subagent/snapshot.js +127 -0
- package/dist/cli/subagent/start.d.ts +24 -0
- package/dist/cli/subagent/start.js +201 -0
- package/dist/cli/subagent/wait-output.d.ts +19 -0
- package/dist/cli/subagent/wait-output.js +56 -0
- package/dist/cli/subagent/wait.d.ts +175 -0
- package/dist/cli/subagent/wait.js +453 -0
- package/dist/extensions/contracts.d.ts +2 -5
- package/dist/extensions/manager.d.ts +0 -2
- package/dist/extensions/manager.js +1 -2
- package/dist/extensions/models.d.ts +3 -0
- package/dist/extensions/operation.d.ts +8 -0
- package/dist/extensions/operation.js +3 -0
- package/dist/extensions/services.d.ts +9 -1
- package/dist/extensions/services.js +26 -3
- package/dist/extensions/session-context.d.ts +18 -0
- package/dist/extensions/session-context.js +4 -0
- package/dist/extensions/session-input.d.ts +2 -2
- package/dist/extensions/session-input.js +3 -4
- package/dist/extensions/session-messages.d.ts +1 -1
- package/dist/extensions/session-tools.js +20 -3
- package/dist/extensions/session.d.ts +1 -4
- package/dist/extensions/session.js +2 -16
- package/dist/extensions/tools.js +21 -3
- package/dist/extensions.d.ts +5 -2
- package/dist/extensions.js +2 -1
- package/dist/host/local-agent-host.d.ts +2 -2
- package/dist/host/local-exec-tool.d.ts +1 -1
- package/dist/host/local-exec-tool.js +28 -3
- package/dist/host/local-tool-registry.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/model/configuration.d.ts +3 -1
- package/dist/model/configuration.js +1 -0
- package/dist/model/openai-responses.js +5 -0
- package/dist/model/responses-request.js +9 -0
- package/dist/prompts/index.js +1 -3
- package/dist/prompts/permissions.d.ts +1 -1
- package/dist/prompts/permissions.js +1 -0
- package/dist/prompts/resources.d.ts +1 -5
- package/dist/prompts/resources.js +3 -12
- package/dist/prompts/subagent.d.ts +1 -1
- package/dist/prompts/subagent.js +1 -1
- package/dist/runtime/context/gc-candidates-web.d.ts +6 -0
- package/dist/runtime/context/gc-candidates-web.js +53 -1
- package/dist/runtime/context/gc-candidates.js +1 -9
- package/dist/runtime/context/gc.js +19 -11
- package/dist/runtime/context/projection.js +1 -0
- package/dist/runtime/events.d.ts +4 -3
- package/dist/runtime/execution-handle.d.ts +2 -0
- package/dist/runtime/wait.js +12 -2
- package/dist/sdk/agent.js +94 -5
- package/dist/sdk/execution-context-coordinator.d.ts +2 -3
- package/dist/sdk/execution-context-coordinator.js +3 -3
- package/dist/sdk/execution-input.d.ts +3 -4
- package/dist/sdk/execution-input.js +31 -25
- package/dist/sdk/execution-round-preparation.d.ts +1 -1
- package/dist/sdk/execution-round-preparation.js +4 -4
- package/dist/sdk/execution-tool-catalog.js +2 -10
- package/dist/sdk/execution-tool-scope.d.ts +1 -3
- package/dist/sdk/execution-tool-scope.js +10 -12
- package/dist/sdk/extension-models.js +3 -0
- package/dist/sdk/extension-session-launch.d.ts +3 -2
- package/dist/sdk/extension-session-launch.js +2 -3
- package/dist/sdk/extension-tools.js +0 -2
- package/dist/sdk/native-steer.d.ts +2 -2
- package/dist/sdk/native-steer.js +2 -2
- package/dist/sdk/session-composition.d.ts +2 -17
- package/dist/sdk/session-execution-factory.d.ts +2 -3
- package/dist/sdk/session-execution-factory.js +20 -114
- package/dist/sdk/session-execution.d.ts +13 -7
- package/dist/sdk/session-execution.js +11 -3
- package/dist/sdk/session-extension-messages.d.ts +1 -3
- package/dist/sdk/session-extension-messages.js +14 -9
- package/dist/sdk/session-extension-prompt.js +1 -3
- package/dist/sdk/session-maintenance.d.ts +1 -0
- package/dist/sdk/session-maintenance.js +16 -7
- package/dist/sdk/session-open.d.ts +2 -3
- package/dist/sdk/session-open.js +5 -24
- package/dist/sdk/session-runtime.d.ts +19 -8
- package/dist/sdk/session-runtime.js +36 -30
- package/dist/sdk/session.d.ts +3 -2
- package/dist/sdk/session.js +22 -89
- package/dist/sdk/types.d.ts +36 -0
- package/dist/session/catalog.d.ts +22 -1
- package/dist/session/catalog.js +102 -0
- package/dist/session/context-gc-checkpoint.js +30 -1
- package/dist/session/context-gc-contract.d.ts +7 -0
- package/dist/session/context-gc-replacements.d.ts +3 -0
- package/dist/session/context-gc-replacements.js +26 -0
- package/dist/session/store/contracts.d.ts +2 -2
- package/dist/session/store/jsonl/directory-index.d.ts +1 -1
- package/dist/session/store/jsonl/directory-index.js +18 -17
- package/dist/session/store/jsonl/history.js +1 -1
- package/dist/session/store/jsonl/index-transaction.js +2 -8
- package/dist/session/store/jsonl/jsonl-store.d.ts +1 -1
- package/dist/session/store/jsonl/jsonl-store.js +24 -9
- package/dist/session/store/jsonl/resources.js +5 -1
- package/dist/session/types.d.ts +1 -0
- package/dist/tools/agent/sleep.js +1 -1
- package/dist/tools/callers.js +1 -12
- package/dist/tools/code-mode/dispatch.js +5 -2
- package/dist/tools/code-mode/index.d.ts +1 -1
- package/dist/tools/code-mode/index.js +4 -2
- package/dist/tools/contracts.d.ts +20 -0
- package/dist/tools/execution-limits.d.ts +5 -20
- package/dist/tools/execution-limits.js +0 -2
- package/dist/tools/execution.js +16 -4
- package/dist/tools/local/exec.js +8 -2
- package/dist/tools/output-projection.d.ts +5 -2
- package/dist/tools/output-projection.js +133 -92
- package/dist/tools/permissions.d.ts +0 -1
- package/dist/tools/permissions.js +1 -9
- package/dist/tools/registry.js +1 -13
- package/dist/tools/runtime-context.d.ts +1 -21
- package/package.json +2 -2
- package/dist/extensions/agents.d.ts +0 -100
- package/dist/extensions/agents.js +0 -121
- package/dist/runtime/context/gc-candidates-subagent.d.ts +0 -6
- package/dist/runtime/context/gc-candidates-subagent.js +0 -100
- package/dist/sdk/extension-agent-controller.d.ts +0 -3
- package/dist/sdk/extension-agent-controller.js +0 -69
- package/dist/sdk/extension-agents.d.ts +0 -9
- package/dist/sdk/extension-agents.js +0 -58
- package/dist/sdk/subagent-backend.d.ts +0 -3
- package/dist/sdk/subagent-backend.js +0 -49
- package/dist/subagent/contracts.d.ts +0 -107
- package/dist/subagent/contracts.js +0 -1
- package/dist/subagent/limits.d.ts +0 -17
- package/dist/subagent/limits.js +0 -17
- package/dist/subagent/model-update.d.ts +0 -2
- package/dist/subagent/model-update.js +0 -81
- package/dist/subagent/session-controller.d.ts +0 -87
- package/dist/subagent/session-controller.js +0 -1343
- package/dist/subagent/task.d.ts +0 -134
- package/dist/subagent/task.js +0 -436
- package/dist/subagent/turn-contracts.d.ts +0 -64
- package/dist/subagent/turn-contracts.js +0 -1
- package/dist/subagent/wait-targets.d.ts +0 -10
- package/dist/subagent/wait-targets.js +0 -26
- package/dist/subagent/wait.d.ts +0 -26
- package/dist/subagent/wait.js +0 -73
- package/dist/tools/agent/agent-cancel.d.ts +0 -7
- package/dist/tools/agent/agent-cancel.js +0 -29
- package/dist/tools/agent/agent-message.d.ts +0 -7
- package/dist/tools/agent/agent-message.js +0 -57
- package/dist/tools/agent/agent-start.d.ts +0 -12
- package/dist/tools/agent/agent-start.js +0 -106
- package/dist/tools/agent/agent-wait.d.ts +0 -7
- package/dist/tools/agent/agent-wait.js +0 -91
package/dist/subagent/wait.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { waitForToolCondition, type ToolWaitInterrupt } from '../runtime/wait.js';
|
|
2
|
-
export { parseAgentWaitTargets } from './wait-targets.js';
|
|
3
|
-
export { waitDeadline } from '../runtime/wait.js';
|
|
4
|
-
/** Waiters own notification and aggregation, never child state. */
|
|
5
|
-
export declare class SubagentWaitCoordinator<T, A> {
|
|
6
|
-
#private;
|
|
7
|
-
subscribeActivity(listener: (activity: A) => void): () => void;
|
|
8
|
-
notifyCompletion(value: T): void;
|
|
9
|
-
notifyActivity(value: A): void;
|
|
10
|
-
waitCompletion(accepts: (value: T) => boolean, current: () => T | undefined, waitMs: number, signal?: AbortSignal, interrupt?: ToolWaitInterrupt): Promise<T | undefined>;
|
|
11
|
-
waitActivity(accepts: (value: A) => boolean, current: () => A | undefined, waitMs: number, signal?: AbortSignal, interrupt?: ToolWaitInterrupt): Promise<A | undefined>;
|
|
12
|
-
}
|
|
13
|
-
/** A group owns one listener and one deadline; readiness never consumes observations. */
|
|
14
|
-
export declare function waitForAgentGroup<T>(input: {
|
|
15
|
-
targets: readonly T[];
|
|
16
|
-
mode: 'any' | 'all';
|
|
17
|
-
waitMs: number | undefined;
|
|
18
|
-
signal: AbortSignal | undefined;
|
|
19
|
-
interrupt: Parameters<typeof waitForToolCondition>[0]['interrupt'];
|
|
20
|
-
refresh(): void;
|
|
21
|
-
ready(target: T): boolean;
|
|
22
|
-
subscribe(notify: () => void): () => void;
|
|
23
|
-
}): Promise<{
|
|
24
|
-
snapshot: boolean;
|
|
25
|
-
satisfied: boolean;
|
|
26
|
-
}>;
|
package/dist/subagent/wait.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { waitForToolCondition } from '../runtime/wait.js';
|
|
2
|
-
export { parseAgentWaitTargets } from './wait-targets.js';
|
|
3
|
-
export { waitDeadline } from '../runtime/wait.js';
|
|
4
|
-
/** Waiters own notification and aggregation, never child state. */
|
|
5
|
-
export class SubagentWaitCoordinator {
|
|
6
|
-
#completions = new Set();
|
|
7
|
-
#activities = new Set();
|
|
8
|
-
subscribeActivity(listener) {
|
|
9
|
-
this.#activities.add(listener);
|
|
10
|
-
return () => {
|
|
11
|
-
this.#activities.delete(listener);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
notifyCompletion(value) {
|
|
15
|
-
for (const listener of this.#completions)
|
|
16
|
-
listener(value);
|
|
17
|
-
}
|
|
18
|
-
notifyActivity(value) {
|
|
19
|
-
for (const listener of this.#activities)
|
|
20
|
-
listener(value);
|
|
21
|
-
}
|
|
22
|
-
waitCompletion(accepts, current, waitMs, signal, interrupt) {
|
|
23
|
-
return waitForNotification(this.#completions, accepts, current, waitMs, signal, interrupt);
|
|
24
|
-
}
|
|
25
|
-
waitActivity(accepts, current, waitMs, signal, interrupt) {
|
|
26
|
-
return waitForNotification(this.#activities, accepts, current, waitMs, signal, interrupt);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
async function waitForNotification(waiters, accepts, current, waitMs, signal, interrupt) {
|
|
30
|
-
let value;
|
|
31
|
-
await waitForToolCondition({
|
|
32
|
-
ready: () => {
|
|
33
|
-
value ??= current();
|
|
34
|
-
return value !== undefined;
|
|
35
|
-
},
|
|
36
|
-
subscribe: (notify) => {
|
|
37
|
-
const listener = (next) => {
|
|
38
|
-
if (accepts(next)) {
|
|
39
|
-
value = next;
|
|
40
|
-
notify();
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
waiters.add(listener);
|
|
44
|
-
return () => {
|
|
45
|
-
waiters.delete(listener);
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
waitMs,
|
|
49
|
-
signal,
|
|
50
|
-
interrupt
|
|
51
|
-
});
|
|
52
|
-
return value;
|
|
53
|
-
}
|
|
54
|
-
/** A group owns one listener and one deadline; readiness never consumes observations. */
|
|
55
|
-
export async function waitForAgentGroup(input) {
|
|
56
|
-
const snapshot = input.waitMs === undefined || input.waitMs === 0;
|
|
57
|
-
const satisfied = () => input.mode === 'all' ? input.targets.every(input.ready) : input.targets.some(input.ready);
|
|
58
|
-
if (!snapshot) {
|
|
59
|
-
await waitForToolCondition({
|
|
60
|
-
waitMs: input.waitMs,
|
|
61
|
-
signal: input.signal,
|
|
62
|
-
interrupt: input.interrupt,
|
|
63
|
-
ready: () => {
|
|
64
|
-
input.refresh();
|
|
65
|
-
return satisfied();
|
|
66
|
-
},
|
|
67
|
-
subscribe: input.subscribe
|
|
68
|
-
});
|
|
69
|
-
input.signal?.throwIfAborted();
|
|
70
|
-
}
|
|
71
|
-
input.refresh();
|
|
72
|
-
return { snapshot, satisfied: !snapshot && satisfied() };
|
|
73
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ClientToolDefinition } from '../contracts.js';
|
|
2
|
-
import type { ToolRuntimeContext } from '../runtime-context.js';
|
|
3
|
-
export declare const agentCancelToolDefinition: ClientToolDefinition;
|
|
4
|
-
export declare function executeAgentCancel(arguments_: unknown, context: ToolRuntimeContext): Promise<{
|
|
5
|
-
content: string;
|
|
6
|
-
data: import("../../subagent/contracts.js").SubagentTaskSnapshot;
|
|
7
|
-
}>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { AgentError } from '../../error.js';
|
|
2
|
-
export const agentCancelToolDefinition = {
|
|
3
|
-
name: 'agent_cancel',
|
|
4
|
-
allowedCallers: ['direct'],
|
|
5
|
-
parallelSafety: 'serial',
|
|
6
|
-
description: 'Idempotently cancel a child agent using the agentId returned by agent_start. For an exec processId, use exec_wait with action:"cancel" instead (tools.exec_wait in Code Mode). Waits for a running task to reach cancelled and returns its agentId and description.',
|
|
7
|
-
inputSchema: {
|
|
8
|
-
type: 'object',
|
|
9
|
-
properties: { agentId: { type: 'string' } },
|
|
10
|
-
required: ['agentId'],
|
|
11
|
-
additionalProperties: false
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
export async function executeAgentCancel(arguments_, context) {
|
|
15
|
-
if (!arguments_ || typeof arguments_ !== 'object' || Array.isArray(arguments_))
|
|
16
|
-
return invalid();
|
|
17
|
-
const input = arguments_;
|
|
18
|
-
if (Object.keys(input).some((key) => key !== 'agentId') ||
|
|
19
|
-
typeof input.agentId !== 'string' ||
|
|
20
|
-
input.agentId.trim().length === 0)
|
|
21
|
-
return invalid();
|
|
22
|
-
if (!context.subagents)
|
|
23
|
-
throw new AgentError('MAR_AGENT_SUBAGENT_RECURSION_DISABLED', 'Subagents cannot recurse.');
|
|
24
|
-
const task = await context.subagents.cancel(input.agentId);
|
|
25
|
-
return { content: JSON.stringify(task), data: task };
|
|
26
|
-
}
|
|
27
|
-
function invalid() {
|
|
28
|
-
throw new AgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Agent cancellation input is invalid.');
|
|
29
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ClientToolDefinition } from '../contracts.js';
|
|
2
|
-
import type { ToolRuntimeContext } from '../runtime-context.js';
|
|
3
|
-
export declare const agentMessageToolDefinition: ClientToolDefinition;
|
|
4
|
-
export declare function executeAgentMessage(arguments_: unknown, context: ToolRuntimeContext): Promise<{
|
|
5
|
-
content: string;
|
|
6
|
-
data: import("../../subagent/contracts.js").SubagentTaskSnapshot;
|
|
7
|
-
}>;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { AgentError } from '../../error.js';
|
|
2
|
-
import { TOOL_EXECUTION_LIMITS } from '../execution-limits.js';
|
|
3
|
-
export const agentMessageToolDefinition = {
|
|
4
|
-
name: 'agent_message',
|
|
5
|
-
allowedCallers: ['direct'],
|
|
6
|
-
parallelSafety: 'serial',
|
|
7
|
-
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, deliveryStatus, current status, and model metadata without repeating the child’s previous latestMessage, latestActivity, summary, or verification evidence. accepted means queued in memory; applied means persisted in model context, not that the guidance has been executed. Use agent_wait for subsequent progress or completion. Does not wait for the new task to complete or roll back existing side effects.',
|
|
8
|
-
inputSchema: {
|
|
9
|
-
type: 'object',
|
|
10
|
-
properties: {
|
|
11
|
-
agentId: { type: 'string' },
|
|
12
|
-
delivery: { type: 'string', enum: ['append', 'replace'], default: 'append' },
|
|
13
|
-
message: {
|
|
14
|
-
type: 'string',
|
|
15
|
-
description: 'Non-empty follow-up message for the existing child Session.'
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
required: ['agentId', 'message'],
|
|
19
|
-
additionalProperties: false
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
export async function executeAgentMessage(arguments_, context) {
|
|
23
|
-
const input = parseAgentMessageInput(arguments_);
|
|
24
|
-
if (!context.subagents)
|
|
25
|
-
throw new AgentError('MAR_AGENT_SUBAGENT_RECURSION_DISABLED', 'Subagents cannot recurse.');
|
|
26
|
-
const task = await context.subagents.message(input.agentId, input.message, {
|
|
27
|
-
delivery: input.delivery ?? 'append',
|
|
28
|
-
signal: context.signal
|
|
29
|
-
});
|
|
30
|
-
return { content: JSON.stringify(task), data: task };
|
|
31
|
-
}
|
|
32
|
-
function parseAgentMessageInput(value) {
|
|
33
|
-
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
34
|
-
return invalid();
|
|
35
|
-
const input = value;
|
|
36
|
-
if (Object.keys(input).some((key) => !['agentId', 'message', 'delivery'].includes(key)) ||
|
|
37
|
-
(input.delivery !== undefined &&
|
|
38
|
-
input.delivery !== null &&
|
|
39
|
-
input.delivery !== 'append' &&
|
|
40
|
-
input.delivery !== 'replace') ||
|
|
41
|
-
typeof input.agentId !== 'string' ||
|
|
42
|
-
input.agentId.trim().length === 0 ||
|
|
43
|
-
typeof input.message !== 'string' ||
|
|
44
|
-
input.message.trim().length === 0 ||
|
|
45
|
-
Buffer.byteLength(input.message) > TOOL_EXECUTION_LIMITS.subagentMessageMaxBytes)
|
|
46
|
-
return invalid();
|
|
47
|
-
return {
|
|
48
|
-
agentId: input.agentId.trim(),
|
|
49
|
-
message: input.message,
|
|
50
|
-
...(input.delivery === 'append' || input.delivery === 'replace'
|
|
51
|
-
? { delivery: input.delivery }
|
|
52
|
-
: {})
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function invalid() {
|
|
56
|
-
throw new AgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Agent message input is invalid.');
|
|
57
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ClientToolDefinition } from '../contracts.js';
|
|
2
|
-
import type { ToolRuntimeContext } from '../runtime-context.js';
|
|
3
|
-
export declare const agentStartToolDefinition: ClientToolDefinition;
|
|
4
|
-
export declare function agentStartToolDefinitionWithModels(models: readonly {
|
|
5
|
-
readonly id: string;
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly reasoningEfforts: readonly string[];
|
|
8
|
-
}[]): ClientToolDefinition;
|
|
9
|
-
export declare function executeAgentStart(arguments_: unknown, context: ToolRuntimeContext): Promise<{
|
|
10
|
-
content: string;
|
|
11
|
-
data: import("../../subagent/contracts.js").SubagentRunResult;
|
|
12
|
-
}>;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { AgentError } from '../../error.js';
|
|
2
|
-
import { agentReasoningEffortSchema } from '../../model/configuration.js';
|
|
3
|
-
import { TOOL_EXECUTION_LIMITS } from '../execution-limits.js';
|
|
4
|
-
export const agentStartToolDefinition = {
|
|
5
|
-
name: 'agent_start',
|
|
6
|
-
allowedCallers: ['direct'],
|
|
7
|
-
parallelSafety: 'serial',
|
|
8
|
-
description: 'Start one bounded, non-recursive child agent with self-contained context. Startup does not wait for task completion. Returns agentId for agent_wait, agent_message, or agent_cancel, description, queued/running/completed/failed/cancelled/interrupted status, and effective model metadata, not task results. Use agent_wait to read results and verification evidence. The optional reasoningEffort overrides the parent effort and must be supported by the selected model; omit it to inherit.',
|
|
9
|
-
inputSchema: {
|
|
10
|
-
type: 'object',
|
|
11
|
-
properties: {
|
|
12
|
-
description: {
|
|
13
|
-
type: 'string',
|
|
14
|
-
maxLength: TOOL_EXECUTION_LIMITS.subagentDescriptionMaxCharacters
|
|
15
|
-
},
|
|
16
|
-
prompt: {
|
|
17
|
-
type: 'string',
|
|
18
|
-
description: 'Self-contained bounded objective, necessary facts, relevant paths, read/write scope, constraints, expected output, and verification responsibility. The child does not inherit parent history.'
|
|
19
|
-
},
|
|
20
|
-
role: { enum: ['general-purpose', 'explore'] },
|
|
21
|
-
modelId: { type: 'string' },
|
|
22
|
-
reasoningEffort: {
|
|
23
|
-
type: 'string',
|
|
24
|
-
enum: agentReasoningEffortSchema.options,
|
|
25
|
-
maxLength: TOOL_EXECUTION_LIMITS.subagentReasoningEffortMaxCharacters,
|
|
26
|
-
description: 'Reasoning effort override for the subagent. Omit to inherit the parent effort.'
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
required: ['description', 'prompt', 'role'],
|
|
30
|
-
additionalProperties: false
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
export function agentStartToolDefinitionWithModels(models) {
|
|
34
|
-
if (models.length === 0)
|
|
35
|
-
return agentStartToolDefinition;
|
|
36
|
-
const modelLines = [...models]
|
|
37
|
-
.sort((left, right) => (left.id < right.id ? -1 : left.id > right.id ? 1 : 0))
|
|
38
|
-
.map((model) => {
|
|
39
|
-
const efforts = model.reasoningEfforts.length === 0
|
|
40
|
-
? ''
|
|
41
|
-
: `; reasoning efforts: ${model.reasoningEfforts.join(', ')}`;
|
|
42
|
-
return `- ${JSON.stringify(model.id)} (${JSON.stringify(model.name)}${efforts})`;
|
|
43
|
-
});
|
|
44
|
-
return {
|
|
45
|
-
...agentStartToolDefinition,
|
|
46
|
-
description: [
|
|
47
|
-
agentStartToolDefinition.description,
|
|
48
|
-
'The optional modelId may select an enabled model below. Omit modelId to use the current agent model. Only use a listed reasoning effort for the selected model.',
|
|
49
|
-
'Enabled subagent models:',
|
|
50
|
-
...modelLines
|
|
51
|
-
].join('\n')
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
export async function executeAgentStart(arguments_, context) {
|
|
55
|
-
const value = parseAgentStartInput(arguments_);
|
|
56
|
-
if (!context.subagents)
|
|
57
|
-
throw new AgentError('MAR_AGENT_SUBAGENT_RECURSION_DISABLED', 'Subagents cannot recurse.');
|
|
58
|
-
const task = await context.subagents.run(value, {
|
|
59
|
-
signal: context.signal,
|
|
60
|
-
onCreated: async (created) => context.emit({
|
|
61
|
-
type: 'subagent.started',
|
|
62
|
-
agentId: created.agentId,
|
|
63
|
-
description: created.description,
|
|
64
|
-
...(created.modelId === undefined ? {} : { modelId: created.modelId }),
|
|
65
|
-
...(created.modelName === undefined ? {} : { modelName: created.modelName }),
|
|
66
|
-
...(created.reasoningEffort === undefined
|
|
67
|
-
? {}
|
|
68
|
-
: { reasoningEffort: created.reasoningEffort })
|
|
69
|
-
})
|
|
70
|
-
});
|
|
71
|
-
return { content: JSON.stringify(task), data: task };
|
|
72
|
-
}
|
|
73
|
-
function parseAgentStartInput(value) {
|
|
74
|
-
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
75
|
-
return invalidAgentStart();
|
|
76
|
-
const input = value;
|
|
77
|
-
if (Object.keys(input).some((key) => !['description', 'prompt', 'role', 'modelId', 'reasoningEffort'].includes(key)) ||
|
|
78
|
-
typeof input.description !== 'string' ||
|
|
79
|
-
input.description.trim().length === 0 ||
|
|
80
|
-
input.description.length > TOOL_EXECUTION_LIMITS.subagentDescriptionMaxCharacters ||
|
|
81
|
-
typeof input.prompt !== 'string' ||
|
|
82
|
-
input.prompt.trim().length === 0 ||
|
|
83
|
-
Buffer.byteLength(input.prompt) > TOOL_EXECUTION_LIMITS.subagentPromptMaxBytes ||
|
|
84
|
-
!['general-purpose', 'explore'].includes(String(input.role)) ||
|
|
85
|
-
(input.modelId !== undefined &&
|
|
86
|
-
input.modelId !== null &&
|
|
87
|
-
(typeof input.modelId !== 'string' || input.modelId.trim().length === 0)) ||
|
|
88
|
-
(input.reasoningEffort !== undefined &&
|
|
89
|
-
input.reasoningEffort !== null &&
|
|
90
|
-
(typeof input.reasoningEffort !== 'string' ||
|
|
91
|
-
!agentReasoningEffortSchema.safeParse(input.reasoningEffort.trim()).success)))
|
|
92
|
-
return invalidAgentStart();
|
|
93
|
-
return {
|
|
94
|
-
description: input.description.trim(),
|
|
95
|
-
prompt: input.prompt,
|
|
96
|
-
role: input.role,
|
|
97
|
-
...(typeof input.modelId === 'string' ? { modelId: input.modelId } : {}),
|
|
98
|
-
...(typeof input.reasoningEffort === 'string'
|
|
99
|
-
? { reasoningEffort: agentReasoningEffortSchema.parse(input.reasoningEffort.trim()) }
|
|
100
|
-
: {}),
|
|
101
|
-
background: true
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
function invalidAgentStart() {
|
|
105
|
-
throw new AgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Agent start input is invalid.');
|
|
106
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ClientToolDefinition } from '../contracts.js';
|
|
2
|
-
import type { ToolRuntimeContext } from '../runtime-context.js';
|
|
3
|
-
export declare const agentWaitToolDefinition: ClientToolDefinition;
|
|
4
|
-
export declare function executeAgentWait(arguments_: unknown, context: ToolRuntimeContext): Promise<{
|
|
5
|
-
content: string;
|
|
6
|
-
data: import("../../subagent/contracts.js").SubagentTaskSnapshot | import("../../subagent/contracts.js").SubagentManyOutput;
|
|
7
|
-
}>;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { AgentError } from '../../error.js';
|
|
2
|
-
import { TOOL_EXECUTION_LIMITS } from '../execution-limits.js';
|
|
3
|
-
import { parseAgentWaitTargets } from '../../subagent/wait-targets.js';
|
|
4
|
-
export const agentWaitToolDefinition = {
|
|
5
|
-
name: 'agent_wait',
|
|
6
|
-
allowedCallers: ['direct'],
|
|
7
|
-
parallelSafety: 'serial',
|
|
8
|
-
description: 'Read or wait a bounded time for a child agent result. Unread child messages and terminal results are supplied automatically before the next model request. Wait only when the next local step depends on the child result; otherwise continue useful non-overlapping work. waitFor defaults to "completion"; use "message" only when a fresh public commentary/final message would change the next decision. Omit agentId to wait for whichever live child returns first, matching Codex-style untargeted waiting and avoiding UUID transcription; provide the exact agentId returned by agent_start only when observing a specific child. If no child is live, untargeted waiting reads the most recently created child. For an exec processId, use exec_wait instead (tools.exec_wait in Code Mode). 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. When blocked on a live child result, prefer one 300000 ms completion wait rather than repeated short waits. Use agentIds with mode any (default) or all to wait for an explicit non-empty set of up to 8 distinct child IDs; never combine agentId and agentIds or use mode without agentIds. mode and waitFor are independent. A group uses one deadline and returns mode, waitFor, waitOutcome, agents in input order, and pendingAgentIds. Failed, cancelled and interrupted turns also satisfy completion; terminal state satisfies message waits too. Group waitMs=0 returns only snapshots without consuming messages. Single-target and untargeted results include waitOutcome as snapshot, message, completion, or timeout plus the real agentId and description. A message or timeout with unread progress includes the newly observed public message; first terminal results follow the result projection below. Snapshots and repeated observations omit previously observed message text. latestActivity can still identify a public message or bounded tool started/completed/failed status. A queued or running result is not completion. A message wait consumes only the latest unread public message in the current Session runtime; tool activity does not wake it, and parent cancellation preserves unread progress for a later Execution. waitOutcome distinguishes snapshot, message, completion, and timeout. A foreground steer may return interrupted with reason=steer without cancelling any child. Do not use message waits as heartbeat checks or request progress merely to confirm that a child is still running. First terminal results retain bounded summary and changedFiles, without automatic command or read records. A final latestMessage fully covered by the complete summary is omitted while its turnId is retained. Use public child conclusions and relevant file references to avoid repeating the full exploration, while independently checking consequential edits and claims.',
|
|
9
|
-
inputSchema: {
|
|
10
|
-
type: 'object',
|
|
11
|
-
properties: {
|
|
12
|
-
agentId: { type: 'string' },
|
|
13
|
-
agentIds: {
|
|
14
|
-
type: 'array',
|
|
15
|
-
items: { type: 'string', minLength: 1 },
|
|
16
|
-
minItems: 1,
|
|
17
|
-
maxItems: TOOL_EXECUTION_LIMITS.agentWaitMaxAgents,
|
|
18
|
-
uniqueItems: true,
|
|
19
|
-
description: 'Explicit child-agent set. Mutually exclusive with agentId.'
|
|
20
|
-
},
|
|
21
|
-
mode: {
|
|
22
|
-
type: 'string',
|
|
23
|
-
enum: ['any', 'all'],
|
|
24
|
-
default: 'any',
|
|
25
|
-
description: 'For agentIds only: return when any or all selected children satisfy waitFor.'
|
|
26
|
-
},
|
|
27
|
-
waitFor: {
|
|
28
|
-
type: 'string',
|
|
29
|
-
enum: ['completion', 'message'],
|
|
30
|
-
default: 'completion',
|
|
31
|
-
description: 'Wait for terminal completion or for the latest unread public message. Terminal state ends either wait.'
|
|
32
|
-
},
|
|
33
|
-
waitMs: {
|
|
34
|
-
type: 'integer',
|
|
35
|
-
minimum: TOOL_EXECUTION_LIMITS.agentWaitMinWaitMs,
|
|
36
|
-
maximum: TOOL_EXECUTION_LIMITS.agentWaitMaxWaitMs,
|
|
37
|
-
default: TOOL_EXECUTION_LIMITS.agentWaitDefaultWaitMs,
|
|
38
|
-
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}.`
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
additionalProperties: false
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
export async function executeAgentWait(arguments_, context) {
|
|
45
|
-
const value = parseAgentWaitInput(arguments_);
|
|
46
|
-
const subagents = context.subagents;
|
|
47
|
-
if (!subagents)
|
|
48
|
-
throw new AgentError('MAR_AGENT_SUBAGENT_RECURSION_DISABLED', 'Subagents cannot recurse.');
|
|
49
|
-
const options = {
|
|
50
|
-
waitMs: value.waitMs ?? TOOL_EXECUTION_LIMITS.agentWaitDefaultWaitMs,
|
|
51
|
-
waitFor: value.waitFor ?? 'completion',
|
|
52
|
-
signal: context.signal,
|
|
53
|
-
waitInterrupt: context.waitInterrupt
|
|
54
|
-
};
|
|
55
|
-
const task = value.agentIds !== undefined
|
|
56
|
-
? await subagents.outputMany(value.agentIds, { ...options, mode: value.mode ?? 'any' })
|
|
57
|
-
: value.agentId === undefined
|
|
58
|
-
? await subagents.outputAny(options)
|
|
59
|
-
: await subagents.output(value.agentId, options);
|
|
60
|
-
return { content: JSON.stringify(task), data: task };
|
|
61
|
-
}
|
|
62
|
-
function parseAgentWaitInput(value) {
|
|
63
|
-
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
64
|
-
return invalidAgentWait();
|
|
65
|
-
const input = value;
|
|
66
|
-
if (Object.keys(input).some((key) => !['agentId', 'agentIds', 'mode', 'waitFor', 'waitMs'].includes(key)) ||
|
|
67
|
-
(input.agentId !== undefined &&
|
|
68
|
-
input.agentId !== null &&
|
|
69
|
-
(typeof input.agentId !== 'string' || input.agentId.trim().length === 0)) ||
|
|
70
|
-
(input.waitFor !== undefined &&
|
|
71
|
-
input.waitFor !== null &&
|
|
72
|
-
input.waitFor !== 'completion' &&
|
|
73
|
-
input.waitFor !== 'message') ||
|
|
74
|
-
(input.waitMs !== undefined &&
|
|
75
|
-
input.waitMs !== null &&
|
|
76
|
-
(!Number.isInteger(input.waitMs) ||
|
|
77
|
-
input.waitMs < TOOL_EXECUTION_LIMITS.agentWaitMinWaitMs ||
|
|
78
|
-
input.waitMs > TOOL_EXECUTION_LIMITS.agentWaitMaxWaitMs)))
|
|
79
|
-
return invalidAgentWait();
|
|
80
|
-
return {
|
|
81
|
-
...parseAgentWaitTargets(input, TOOL_EXECUTION_LIMITS.agentWaitMaxAgents),
|
|
82
|
-
...(typeof input.agentId === 'string' ? { agentId: input.agentId.trim() } : {}),
|
|
83
|
-
...(input.waitFor === 'completion' || input.waitFor === 'message'
|
|
84
|
-
? { waitFor: input.waitFor }
|
|
85
|
-
: {}),
|
|
86
|
-
...(typeof input.waitMs === 'number' ? { waitMs: input.waitMs } : {})
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function invalidAgentWait() {
|
|
90
|
-
throw new AgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Agent wait input is invalid.');
|
|
91
|
-
}
|