@myagentroam/agent 0.10.54 → 0.10.56
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/agent-core/runtime/events.d.ts +1 -1
- package/dist/agent-core/sdk/session.js +2 -1
- package/dist/agent-core/subagent/session-controller.d.ts +2 -0
- package/dist/agent-core/subagent/session-controller.js +13 -0
- package/dist/agent-core/tools/agent/sleep.d.ts +12 -0
- package/dist/agent-core/tools/agent/sleep.js +47 -0
- package/dist/agent-core/tools/callers.js +1 -0
- package/dist/agent-core/tools/execution-limits.d.ts +1 -0
- package/dist/agent-core/tools/execution-limits.js +1 -0
- package/dist/agent-core/tools/output-projection.d.ts +2 -1
- package/dist/agent-core/tools/output-projection.js +16 -0
- package/dist/agent-core/tools/registry.js +4 -1
- package/dist/agent-core/tools/runtime-context.d.ts +1 -0
- package/package.json +1 -1
|
@@ -92,7 +92,7 @@ export type MarAgentEvent = MarAgentEventBase & ({
|
|
|
92
92
|
summary: string;
|
|
93
93
|
truncated?: boolean;
|
|
94
94
|
artifacts?: readonly MarAgentToolArtifact[];
|
|
95
|
-
data?: CodeCellEventData | import('../tools/contracts.js').ExecResult | Omit<import('../tools/contracts.js').ExecResult, 'stdout' | 'stderr'> | import('../tools/contracts.js').ApplyPatchResult | import('../tools/contracts.js').ReadEventData | import('../tools/contracts.js').ViewImageResult | import('../subagent/contracts.js').SubagentTaskSnapshot | import('../subagent/contracts.js').SubagentManyOutput;
|
|
95
|
+
data?: CodeCellEventData | import('../tools/contracts.js').ExecResult | Omit<import('../tools/contracts.js').ExecResult, 'stdout' | 'stderr'> | import('../tools/contracts.js').ApplyPatchResult | import('../tools/contracts.js').ReadEventData | import('../tools/contracts.js').ViewImageResult | import('../subagent/contracts.js').SubagentTaskSnapshot | import('../subagent/contracts.js').SubagentManyOutput | import('../tools/agent/sleep.js').SleepResult;
|
|
96
96
|
} | {
|
|
97
97
|
type: 'tool.failed';
|
|
98
98
|
resultExtensions?: readonly import('../tools/result-extensions.js').ToolResultExtension[];
|
|
@@ -1004,7 +1004,8 @@ export function createSessionOpener(services) {
|
|
|
1004
1004
|
...(subagents === undefined || mode === 'compact'
|
|
1005
1005
|
? {}
|
|
1006
1006
|
: {
|
|
1007
|
-
subagents: coreExtensions.bindAgents(subagents.captureExecution(executionId))
|
|
1007
|
+
subagents: coreExtensions.bindAgents(subagents.captureExecution(executionId)),
|
|
1008
|
+
subagentMessages: subagents.modelMessages
|
|
1008
1009
|
}),
|
|
1009
1010
|
mode,
|
|
1010
1011
|
sessionId,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ToolWaitInterrupt } from '../tools/wait.js';
|
|
1
2
|
import type { CoreOperationContext } from '../extensions/operation.js';
|
|
2
3
|
import type { MarAgentReasoningEffort } from '../model/configuration.js';
|
|
3
4
|
import type { ExecutionResult } from '../runtime/contracts.js';
|
|
@@ -89,6 +90,7 @@ export declare class SubagentSessionController implements SubagentController {
|
|
|
89
90
|
maxTasks: number;
|
|
90
91
|
maxConcurrent: number;
|
|
91
92
|
};
|
|
93
|
+
readonly modelMessages: ToolWaitInterrupt;
|
|
92
94
|
private constructor();
|
|
93
95
|
static open(input: {
|
|
94
96
|
readonly parentSessionId: string;
|
|
@@ -13,6 +13,19 @@ export class SubagentSessionController {
|
|
|
13
13
|
#queue = [];
|
|
14
14
|
#completionWaiters = new Set();
|
|
15
15
|
#activityWaiters = new Set();
|
|
16
|
+
modelMessages = {
|
|
17
|
+
pending: () => [...this.#agents.values()].some((state) => state.messageRevision > state.observedMessageRevision),
|
|
18
|
+
subscribe: (listener) => {
|
|
19
|
+
const notify = (activity) => {
|
|
20
|
+
if (activity.kind === 'message')
|
|
21
|
+
listener();
|
|
22
|
+
};
|
|
23
|
+
this.#activityWaiters.add(notify);
|
|
24
|
+
return () => {
|
|
25
|
+
this.#activityWaiters.delete(notify);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
16
29
|
#nativeObservations = new Map();
|
|
17
30
|
#activityRevision = 0;
|
|
18
31
|
#resourceRevision = 0;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ClientToolDefinition } from '../../model/contracts.js';
|
|
2
|
+
import type { ToolRuntimeContext } from '../runtime-context.js';
|
|
3
|
+
export interface SleepResult {
|
|
4
|
+
durationMs: number;
|
|
5
|
+
elapsedMs: number;
|
|
6
|
+
wakeReason: 'elapsed' | 'steer' | 'subagent_message';
|
|
7
|
+
}
|
|
8
|
+
export declare const sleepToolDefinition: ClientToolDefinition;
|
|
9
|
+
export declare function executeSleep(arguments_: unknown, context: ToolRuntimeContext): Promise<{
|
|
10
|
+
content: string;
|
|
11
|
+
data: SleepResult;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { MarAgentError } from '../../error.js';
|
|
2
|
+
import { TOOL_EXECUTION_LIMITS } from '../execution-limits.js';
|
|
3
|
+
import { waitForToolCondition } from '../wait.js';
|
|
4
|
+
export const sleepToolDefinition = {
|
|
5
|
+
name: 'sleep',
|
|
6
|
+
allowedCallers: ['direct'],
|
|
7
|
+
parallelSafety: 'serial',
|
|
8
|
+
description: 'Pause for up to durationMs milliseconds. Returns early when user input or a new public subagent message is available. Returns elapsed time and the wake reason.',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
durationMs: {
|
|
13
|
+
type: 'integer',
|
|
14
|
+
minimum: 1,
|
|
15
|
+
maximum: TOOL_EXECUTION_LIMITS.sleepMaxDurationMs
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
required: ['durationMs'],
|
|
19
|
+
additionalProperties: false
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export async function executeSleep(arguments_, context) {
|
|
23
|
+
const durationMs = arguments_ && typeof arguments_ === 'object' && !Array.isArray(arguments_)
|
|
24
|
+
? arguments_.durationMs
|
|
25
|
+
: undefined;
|
|
26
|
+
if (typeof durationMs !== 'number' ||
|
|
27
|
+
!Number.isInteger(durationMs) ||
|
|
28
|
+
durationMs < 1 ||
|
|
29
|
+
durationMs > TOOL_EXECUTION_LIMITS.sleepMaxDurationMs)
|
|
30
|
+
throw new MarAgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Sleep duration is out of range.');
|
|
31
|
+
const started = performance.now();
|
|
32
|
+
const messages = context.subagentMessages;
|
|
33
|
+
const outcome = await waitForToolCondition({
|
|
34
|
+
ready: () => messages?.pending() ?? false,
|
|
35
|
+
subscribe: (notify) => messages?.subscribe(notify) ?? (() => { }),
|
|
36
|
+
waitMs: durationMs,
|
|
37
|
+
signal: context.signal,
|
|
38
|
+
interrupt: context.waitInterrupt
|
|
39
|
+
});
|
|
40
|
+
context.signal.throwIfAborted();
|
|
41
|
+
const data = {
|
|
42
|
+
durationMs,
|
|
43
|
+
elapsedMs: performance.now() - started,
|
|
44
|
+
wakeReason: outcome === 'ready' ? 'subagent_message' : outcome === 'interrupted' ? 'steer' : 'elapsed'
|
|
45
|
+
};
|
|
46
|
+
return { content: JSON.stringify(data), data };
|
|
47
|
+
}
|
|
@@ -47,6 +47,7 @@ export declare const TOOL_EXECUTION_LIMITS: Readonly<{
|
|
|
47
47
|
agentWaitDefaultWaitMs: 30000;
|
|
48
48
|
agentWaitMaxWaitMs: 300000;
|
|
49
49
|
agentWaitMaxAgents: 8;
|
|
50
|
+
sleepMaxDurationMs: 300000;
|
|
50
51
|
subagentDescriptionMaxCharacters: 80;
|
|
51
52
|
subagentPromptMaxBytes: 131072;
|
|
52
53
|
subagentMessageMaxBytes: 131072;
|
|
@@ -47,6 +47,7 @@ export const TOOL_EXECUTION_LIMITS = Object.freeze({
|
|
|
47
47
|
agentWaitDefaultWaitMs: 30_000,
|
|
48
48
|
agentWaitMaxWaitMs: 300_000,
|
|
49
49
|
agentWaitMaxAgents: 8,
|
|
50
|
+
sleepMaxDurationMs: 300_000,
|
|
50
51
|
subagentDescriptionMaxCharacters: 80,
|
|
51
52
|
subagentPromptMaxBytes: 131_072,
|
|
52
53
|
subagentMessageMaxBytes: 131_072,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SubagentTaskSnapshot, SubagentManyOutput } from '../subagent/contracts.js';
|
|
2
2
|
import type { ApplyPatchResult, ApplyPatchPartialResult, CodeCellEventData, ExecResult, MarAgentToolArtifact, ToolExecutionResult, ReadEventData, ViewImageResult } from './contracts.js';
|
|
3
3
|
import type { ToolRuntimeImage } from './runtime-context.js';
|
|
4
|
+
import type { SleepResult } from './agent/sleep.js';
|
|
4
5
|
export declare function currentExecutionImages(modelInputImages: readonly {
|
|
5
6
|
readonly mimeType: string;
|
|
6
7
|
readonly dataBase64: string;
|
|
@@ -10,7 +11,7 @@ export declare function boundedModelToolOutput(toolName: string, value: string,
|
|
|
10
11
|
truncated: boolean;
|
|
11
12
|
};
|
|
12
13
|
/** Project only known, validated tool result shapes into public structured events. */
|
|
13
|
-
export declare function structuredToolEventData(toolName: string, value: unknown): CodeCellEventData | ExecResult | ApplyPatchResult | ReadEventData | ViewImageResult | SubagentTaskSnapshot | SubagentManyOutput | undefined;
|
|
14
|
+
export declare function structuredToolEventData(toolName: string, value: unknown): CodeCellEventData | ExecResult | ApplyPatchResult | ReadEventData | ViewImageResult | SubagentTaskSnapshot | SubagentManyOutput | SleepResult | undefined;
|
|
14
15
|
/** Partial patch facts are allowlisted; arbitrary error details never become public event data. */
|
|
15
16
|
export declare function structuredToolFailureData(toolName: string, error: unknown): ApplyPatchPartialResult | undefined;
|
|
16
17
|
export declare function structuredToolArtifacts(value: readonly MarAgentToolArtifact[] | undefined): readonly MarAgentToolArtifact[] | undefined;
|
|
@@ -35,6 +35,22 @@ export function boundedModelToolOutput(toolName, value, data) {
|
|
|
35
35
|
export function structuredToolEventData(toolName, value) {
|
|
36
36
|
if (!isRecord(value))
|
|
37
37
|
return undefined;
|
|
38
|
+
if (toolName === 'sleep' &&
|
|
39
|
+
typeof value.durationMs === 'number' &&
|
|
40
|
+
Number.isInteger(value.durationMs) &&
|
|
41
|
+
value.durationMs >= 1 &&
|
|
42
|
+
value.durationMs <= TOOL_EXECUTION_LIMITS.sleepMaxDurationMs &&
|
|
43
|
+
typeof value.elapsedMs === 'number' &&
|
|
44
|
+
Number.isFinite(value.elapsedMs) &&
|
|
45
|
+
value.elapsedMs >= 0 &&
|
|
46
|
+
(value.wakeReason === 'elapsed' ||
|
|
47
|
+
value.wakeReason === 'steer' ||
|
|
48
|
+
value.wakeReason === 'subagent_message'))
|
|
49
|
+
return {
|
|
50
|
+
durationMs: value.durationMs,
|
|
51
|
+
elapsedMs: value.elapsedMs,
|
|
52
|
+
wakeReason: value.wakeReason
|
|
53
|
+
};
|
|
38
54
|
if (toolName === 'agent_wait' &&
|
|
39
55
|
(value.mode === 'any' || value.mode === 'all') &&
|
|
40
56
|
(value.waitFor === 'completion' || value.waitFor === 'message') &&
|
|
@@ -13,6 +13,7 @@ import { executeTodoWrite, todoWriteToolDefinition } from './agent/todo-write.js
|
|
|
13
13
|
import { executeToolSearch, toolSearchToolDefinition } from './mcp/tool-search.js';
|
|
14
14
|
import { viewImageToolDefinition } from './local/view-image.js';
|
|
15
15
|
import { smartCompactToolDefinition, executeSmartCompact } from './agent/smart-compact.js';
|
|
16
|
+
import { executeSleep, sleepToolDefinition } from './agent/sleep.js';
|
|
16
17
|
export const BUILTIN_TOOL_DEFINITIONS = [
|
|
17
18
|
skillToolDefinition,
|
|
18
19
|
toolSearchToolDefinition,
|
|
@@ -30,10 +31,12 @@ export const BUILTIN_TOOL_DEFINITIONS = [
|
|
|
30
31
|
agentWaitToolDefinition,
|
|
31
32
|
agentMessageToolDefinition,
|
|
32
33
|
agentCancelToolDefinition,
|
|
33
|
-
smartCompactToolDefinition
|
|
34
|
+
smartCompactToolDefinition,
|
|
35
|
+
sleepToolDefinition
|
|
34
36
|
];
|
|
35
37
|
export const AGENT_TOOL_HANDLERS = new Map([
|
|
36
38
|
['skill', executeSkill],
|
|
39
|
+
['sleep', executeSleep],
|
|
37
40
|
['smart_compact', executeSmartCompact],
|
|
38
41
|
['tool_search', executeToolSearch],
|
|
39
42
|
['question', executeQuestion],
|
|
@@ -48,6 +48,7 @@ export interface ToolRuntimeContext {
|
|
|
48
48
|
modelId?: string;
|
|
49
49
|
signal: AbortSignal;
|
|
50
50
|
waitInterrupt?: import('./wait.js').ToolWaitInterrupt | undefined;
|
|
51
|
+
subagentMessages?: import('./wait.js').ToolWaitInterrupt;
|
|
51
52
|
permissionPolicy?: import('./permissions.js').ExecutionToolPermissions;
|
|
52
53
|
parentCallId?: string;
|
|
53
54
|
writeToolResultResource?: import('./result-extensions.js').ToolResultResourceWriter;
|