@myagentroam/agent 0.15.19 → 0.15.21
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/host/local-exec-tool.js +15 -12
- package/package.json +1 -1
|
@@ -84,14 +84,14 @@ export class ExecTool {
|
|
|
84
84
|
throw new AgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Completed process cannot accept input.');
|
|
85
85
|
process.child.stdin.write(input.data);
|
|
86
86
|
}
|
|
87
|
-
if (input.action === 'cancel')
|
|
87
|
+
if (input.action === 'cancel') {
|
|
88
|
+
// Mark before awaiting termination so concurrent collection cannot evict another replay.
|
|
89
|
+
process.discardReplay = true;
|
|
88
90
|
await this.#terminate(process, true);
|
|
89
|
-
const result = this.#result(input.processId, process);
|
|
90
|
-
if (process.status !== 'running') {
|
|
91
|
-
this.#retainCompleted(input.processId, process);
|
|
92
|
-
if (input.action === 'cancel')
|
|
93
|
-
this.#removeCompleted(input.processId);
|
|
94
91
|
}
|
|
92
|
+
const result = this.#result(input.processId, process);
|
|
93
|
+
if (process.status !== 'running')
|
|
94
|
+
this.#releaseCollectedProcess(input.processId, process);
|
|
95
95
|
return {
|
|
96
96
|
...result,
|
|
97
97
|
...(input.action === 'poll'
|
|
@@ -119,14 +119,14 @@ export class ExecTool {
|
|
|
119
119
|
}, owner?.sessionId, false);
|
|
120
120
|
if (input.timeoutMs !== undefined) {
|
|
121
121
|
managed.timer = setTimeout(() => {
|
|
122
|
-
void this.#terminate(managed, true).then(() => this.#
|
|
122
|
+
void this.#terminate(managed, true).then(() => this.#releaseCollectedProcess(id, managed));
|
|
123
123
|
}, Math.min(input.timeoutMs, TOOL_EXECUTION_LIMITS.execMaxTimeoutMs));
|
|
124
124
|
managed.timer.unref();
|
|
125
125
|
}
|
|
126
126
|
const outcome = await waitForProcessCompletion('initial', id, managed, input.yieldMs ?? TOOL_EXECUTION_LIMITS.execDefaultYieldMs, signal, waitInterrupt, onOutput);
|
|
127
127
|
const result = this.#result(id, managed);
|
|
128
128
|
if (managed.status !== 'running')
|
|
129
|
-
this.#
|
|
129
|
+
this.#releaseCollectedProcess(id, managed);
|
|
130
130
|
return {
|
|
131
131
|
...result,
|
|
132
132
|
...waitMetadata(result.status !== 'running'
|
|
@@ -186,6 +186,7 @@ export class ExecTool {
|
|
|
186
186
|
...(child.signalCode == null ? {} : { exitSignal: child.signalCode }),
|
|
187
187
|
finalized: false,
|
|
188
188
|
terminalResultReturned: false,
|
|
189
|
+
discardReplay: false,
|
|
189
190
|
waiters: new Set()
|
|
190
191
|
};
|
|
191
192
|
this.#processes.set(id, managed);
|
|
@@ -219,7 +220,7 @@ export class ExecTool {
|
|
|
219
220
|
managed.exitSignal = signal;
|
|
220
221
|
managed.resolveExited();
|
|
221
222
|
if (!native)
|
|
222
|
-
void finalizeAfterOutputGrace(managed, this.maxOutputBytes).then(() => this.#
|
|
223
|
+
void finalizeAfterOutputGrace(managed, this.maxOutputBytes).then(() => this.#releaseCollectedProcess(id, managed));
|
|
223
224
|
});
|
|
224
225
|
child.once('close', (code, signal) => {
|
|
225
226
|
managed.exitObserved = true;
|
|
@@ -229,7 +230,7 @@ export class ExecTool {
|
|
|
229
230
|
if (native)
|
|
230
231
|
this.#processes.delete(id);
|
|
231
232
|
else
|
|
232
|
-
this.#
|
|
233
|
+
this.#releaseCollectedProcess(id, managed);
|
|
233
234
|
});
|
|
234
235
|
child.once('error', (error) => {
|
|
235
236
|
if (managed.finalized)
|
|
@@ -257,7 +258,7 @@ export class ExecTool {
|
|
|
257
258
|
if (native)
|
|
258
259
|
this.#processes.delete(id);
|
|
259
260
|
else
|
|
260
|
-
this.#
|
|
261
|
+
this.#releaseCollectedProcess(id, managed);
|
|
261
262
|
}
|
|
262
263
|
}
|
|
263
264
|
return { id, managed };
|
|
@@ -412,7 +413,7 @@ export class ExecTool {
|
|
|
412
413
|
clearTimeout(completed.timer);
|
|
413
414
|
this.#completed.delete(id);
|
|
414
415
|
}
|
|
415
|
-
#
|
|
416
|
+
#releaseCollectedProcess(id, process) {
|
|
416
417
|
if (process.native ||
|
|
417
418
|
process.status === 'running' ||
|
|
418
419
|
!process.finalized ||
|
|
@@ -420,6 +421,8 @@ export class ExecTool {
|
|
|
420
421
|
this.#processes.get(id) !== process)
|
|
421
422
|
return;
|
|
422
423
|
this.#processes.delete(id);
|
|
424
|
+
if (process.discardReplay)
|
|
425
|
+
return;
|
|
423
426
|
const stdout = consumeOutput(process.stdoutHistory);
|
|
424
427
|
const stderr = consumeOutput(process.stderrHistory);
|
|
425
428
|
const timer = setTimeout(() => this.#removeCompleted(id), TOOL_EXECUTION_LIMITS.execCompletedRetentionMs);
|