@myagentroam/agent 0.14.3 → 0.14.5
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.
|
@@ -55,9 +55,7 @@ export class ExecTool {
|
|
|
55
55
|
return {
|
|
56
56
|
...completed.result,
|
|
57
57
|
cached: true,
|
|
58
|
-
...(input.action === 'poll'
|
|
59
|
-
? waitMetadata(input.yieldMs === 0 ? 'snapshot' : 'completion')
|
|
60
|
-
: {})
|
|
58
|
+
...(input.action === 'poll' ? waitMetadata('completion') : {})
|
|
61
59
|
};
|
|
62
60
|
}
|
|
63
61
|
if (!process ||
|
|
@@ -69,8 +67,8 @@ export class ExecTool {
|
|
|
69
67
|
if (signal?.aborted)
|
|
70
68
|
throw executionAbortReason(signal);
|
|
71
69
|
let outcome;
|
|
72
|
-
if (input.action === 'poll'
|
|
73
|
-
outcome = await waitForProcessCompletion(input.processId, process,
|
|
70
|
+
if (input.action === 'poll')
|
|
71
|
+
outcome = await waitForProcessCompletion(input.processId, process, input.yieldMs, signal, waitInterrupt, onOutput);
|
|
74
72
|
if (input.action === 'write') {
|
|
75
73
|
if (process.status !== 'running')
|
|
76
74
|
throw new AgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Completed process cannot accept input.');
|
|
@@ -87,13 +85,11 @@ export class ExecTool {
|
|
|
87
85
|
return {
|
|
88
86
|
...result,
|
|
89
87
|
...(input.action === 'poll'
|
|
90
|
-
? waitMetadata(
|
|
91
|
-
? '
|
|
92
|
-
:
|
|
93
|
-
? '
|
|
94
|
-
:
|
|
95
|
-
? 'interrupted'
|
|
96
|
-
: 'timeout')
|
|
88
|
+
? waitMetadata(result.status !== 'running'
|
|
89
|
+
? 'completion'
|
|
90
|
+
: outcome === 'interrupted'
|
|
91
|
+
? 'interrupted'
|
|
92
|
+
: 'timeout')
|
|
97
93
|
: {})
|
|
98
94
|
};
|
|
99
95
|
}
|
|
@@ -117,22 +113,17 @@ export class ExecTool {
|
|
|
117
113
|
}, Math.min(input.timeoutMs, TOOL_EXECUTION_LIMITS.execMaxTimeoutMs));
|
|
118
114
|
managed.timer.unref();
|
|
119
115
|
}
|
|
120
|
-
const
|
|
121
|
-
const outcome = yieldMs === 0
|
|
122
|
-
? undefined
|
|
123
|
-
: await waitForProcessCompletion(id, managed, yieldMs, signal, waitInterrupt, onOutput);
|
|
116
|
+
const outcome = await waitForProcessCompletion(id, managed, input.yieldMs ?? TOOL_EXECUTION_LIMITS.execDefaultYieldMs, signal, waitInterrupt, onOutput);
|
|
124
117
|
const result = this.#result(id, managed);
|
|
125
118
|
if (managed.status !== 'running')
|
|
126
119
|
this.#retainCompleted(id, managed);
|
|
127
120
|
return {
|
|
128
121
|
...result,
|
|
129
|
-
...waitMetadata(
|
|
130
|
-
? '
|
|
131
|
-
:
|
|
132
|
-
? '
|
|
133
|
-
:
|
|
134
|
-
? 'interrupted'
|
|
135
|
-
: 'timeout')
|
|
122
|
+
...waitMetadata(result.status !== 'running'
|
|
123
|
+
? 'completion'
|
|
124
|
+
: outcome === 'interrupted'
|
|
125
|
+
? 'interrupted'
|
|
126
|
+
: 'timeout')
|
|
136
127
|
};
|
|
137
128
|
}
|
|
138
129
|
async #startManaged(request, ownerSessionId, native) {
|
|
@@ -10,9 +10,9 @@ export declare const TOOL_EXECUTION_LIMITS: Readonly<{
|
|
|
10
10
|
viewImageMaxPixels: 16777216;
|
|
11
11
|
execMaxTimeoutMs: 3600000;
|
|
12
12
|
execDefaultYieldMs: 10000;
|
|
13
|
-
|
|
13
|
+
execMinYieldMs: 10000;
|
|
14
|
+
execMaxYieldMs: 300000;
|
|
14
15
|
execDefaultPollYieldMs: 60000;
|
|
15
|
-
execMaxPollYieldMs: 300000;
|
|
16
16
|
execTerminationGraceMs: 1000;
|
|
17
17
|
execDefaultMaxOutputBytes: 1000000;
|
|
18
18
|
execProgressMaxOutputBytes: 8192;
|
|
@@ -12,9 +12,9 @@ export const TOOL_EXECUTION_LIMITS = Object.freeze({
|
|
|
12
12
|
viewImageMaxPixels: 16_777_216,
|
|
13
13
|
execMaxTimeoutMs: 3_600_000,
|
|
14
14
|
execDefaultYieldMs: 10_000,
|
|
15
|
-
|
|
15
|
+
execMinYieldMs: 10_000,
|
|
16
|
+
execMaxYieldMs: 300_000,
|
|
16
17
|
execDefaultPollYieldMs: 60_000,
|
|
17
|
-
execMaxPollYieldMs: 300_000,
|
|
18
18
|
execTerminationGraceMs: 1_000,
|
|
19
19
|
execDefaultMaxOutputBytes: 1_000_000,
|
|
20
20
|
execProgressMaxOutputBytes: 8_192,
|
|
@@ -21,8 +21,15 @@ export type ExecInput = {
|
|
|
21
21
|
action: 'cancel';
|
|
22
22
|
processId: string;
|
|
23
23
|
};
|
|
24
|
+
type ParsedExecInput = Exclude<ExecInput, {
|
|
25
|
+
action: 'poll';
|
|
26
|
+
}> | {
|
|
27
|
+
action: 'poll';
|
|
28
|
+
processId: string;
|
|
29
|
+
yieldMs: number;
|
|
30
|
+
};
|
|
24
31
|
export declare const execToolDefinition: ClientToolDefinition;
|
|
25
32
|
export declare const execWaitToolDefinition: ClientToolDefinition;
|
|
26
33
|
/** Validate the public entry points before delegating to the single process manager. */
|
|
27
|
-
export declare function execToolInput(name: 'exec' | 'exec_wait', value: unknown):
|
|
28
|
-
export declare function parseExecInput(value: unknown):
|
|
34
|
+
export declare function execToolInput(name: 'exec' | 'exec_wait', value: unknown): ParsedExecInput;
|
|
35
|
+
export declare function parseExecInput(value: unknown): ParsedExecInput;
|
package/dist/tools/local/exec.js
CHANGED
|
@@ -33,7 +33,7 @@ export const execToolDefinition = {
|
|
|
33
33
|
name: 'exec',
|
|
34
34
|
allowedCallers: ['direct', 'programmatic'],
|
|
35
35
|
parallelSafety: 'safe',
|
|
36
|
-
description: 'Start a platform-native command, script, or program in workspace/default cwd. Returns a stable processId (p_ plus 12 lowercase hex characters), status, bounded stdout/stderr, cumulative byte counts, dropped-byte counts, exitCode and truncated. A completed status does not imply exitCode 0; inspect stderr/exitCode. For subsequent waiting, stdin writes or cancellation, use exec_wait with processId, not exec. Truncation does not stop the process. Cancelling the initial wait does not terminate the process. waitOutcome distinguishes
|
|
36
|
+
description: 'Start a platform-native command, script, or program in workspace/default cwd. Returns a stable processId (p_ plus 12 lowercase hex characters), status, bounded stdout/stderr, cumulative byte counts, dropped-byte counts, exitCode and truncated. A completed status does not imply exitCode 0; inspect stderr/exitCode. For subsequent waiting, stdin writes or cancellation, use exec_wait with processId, not exec. Truncation does not stop the process. Cancelling the initial wait does not terminate the process. waitOutcome distinguishes completion from a wait timeout. A direct foreground call may return interrupted with reason=steer. Inside a cell, steer interrupts only the outer foreground wait, not the inner exec wait. In either case the process keeps running.',
|
|
37
37
|
outputSchema: {
|
|
38
38
|
type: 'object',
|
|
39
39
|
required: ['content', 'data'],
|
|
@@ -96,7 +96,7 @@ export const execToolDefinition = {
|
|
|
96
96
|
minimum: 0,
|
|
97
97
|
maximum: TOOL_EXECUTION_LIMITS.execMaxYieldMs,
|
|
98
98
|
default: TOOL_EXECUTION_LIMITS.execDefaultYieldMs,
|
|
99
|
-
description: `
|
|
99
|
+
description: `Initial wait window in milliseconds (default: ${TOOL_EXECUTION_LIMITS.execDefaultYieldMs}; floor: ${TOOL_EXECUTION_LIMITS.execMinYieldMs}).`
|
|
100
100
|
}
|
|
101
101
|
},
|
|
102
102
|
required: ['command'],
|
|
@@ -122,9 +122,9 @@ export const execWaitToolDefinition = {
|
|
|
122
122
|
yieldMs: {
|
|
123
123
|
type: 'integer',
|
|
124
124
|
minimum: 0,
|
|
125
|
-
maximum: TOOL_EXECUTION_LIMITS.
|
|
125
|
+
maximum: TOOL_EXECUTION_LIMITS.execMaxYieldMs,
|
|
126
126
|
default: TOOL_EXECUTION_LIMITS.execDefaultPollYieldMs,
|
|
127
|
-
description: `Poll wait window in milliseconds
|
|
127
|
+
description: `Poll wait window in milliseconds (floor: ${TOOL_EXECUTION_LIMITS.execMinYieldMs}). Use the ${TOOL_EXECUTION_LIMITS.execDefaultPollYieldMs} ms default when just waiting for completion.`
|
|
128
128
|
},
|
|
129
129
|
data: { type: 'string', description: 'Required stdin data for write.' }
|
|
130
130
|
},
|
|
@@ -156,9 +156,10 @@ export function parseExecInput(value) {
|
|
|
156
156
|
const action = input.action ?? 'start';
|
|
157
157
|
if (typeof action !== 'string' || !['start', 'poll', 'write', 'cancel'].includes(action))
|
|
158
158
|
return invalidExecInput("Field 'action' must be one of: start, poll, write, cancel.");
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
const requestedYieldMs = optionalBoundedInteger('yieldMs', input.yieldMs, 0, TOOL_EXECUTION_LIMITS.execMaxYieldMs);
|
|
160
|
+
const yieldMs = requestedYieldMs === undefined
|
|
161
|
+
? undefined
|
|
162
|
+
: Math.max(requestedYieldMs, TOOL_EXECUTION_LIMITS.execMinYieldMs);
|
|
162
163
|
if (action === 'start') {
|
|
163
164
|
if (typeof input.command !== 'string' || input.command.trim() === '')
|
|
164
165
|
return invalidExecInput("Field 'command' must be a nonblank string.");
|