@yu_robotics/remote-cli 1.6.183 → 1.6.187
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/README.md +35 -0
- package/dist/client/MessageHandler.d.ts.map +1 -1
- package/dist/client/MessageHandler.js +10 -0
- package/dist/client/MessageHandler.js.map +1 -1
- package/dist/executor/CodexAppServerExecutor.d.ts +3 -0
- package/dist/executor/CodexAppServerExecutor.d.ts.map +1 -1
- package/dist/executor/CodexAppServerExecutor.js +65 -11
- package/dist/executor/CodexAppServerExecutor.js.map +1 -1
- package/dist/executor/IExecutor.d.ts +3 -1
- package/dist/executor/IExecutor.d.ts.map +1 -1
- package/dist/executor/PiExecutor.d.ts +24 -0
- package/dist/executor/PiExecutor.d.ts.map +1 -1
- package/dist/executor/PiExecutor.js +179 -36
- package/dist/executor/PiExecutor.js.map +1 -1
- package/dist/executor/acp/AcpClient.d.ts.map +1 -1
- package/dist/executor/acp/AcpClient.js +22 -14
- package/dist/executor/acp/AcpClient.js.map +1 -1
- package/dist/maintenance/release-notes.json +1 -1
- package/dist/thread/ThreadExecutorPool.js +2 -2
- package/dist/thread/ThreadExecutorPool.js.map +1 -1
- package/package.json +1 -1
|
@@ -106,8 +106,10 @@ export interface IExecutor {
|
|
|
106
106
|
execute(prompt: string, options: ExecuteOptions): Promise<ExecuteResult>;
|
|
107
107
|
getCurrentWorkingDirectory(): string;
|
|
108
108
|
setWorkingDirectory(targetPath: string): Promise<void>;
|
|
109
|
-
/** Native
|
|
109
|
+
/** Native activity, checked before destructive session changes. */
|
|
110
110
|
isBusy?(): boolean;
|
|
111
|
+
/** A failed transport stop requires an explicit successful abort retry before admission. */
|
|
112
|
+
hasUncertainShutdown?(): boolean;
|
|
111
113
|
resetContext(): void;
|
|
112
114
|
abort(): Promise<boolean>;
|
|
113
115
|
destroy(): Promise<void> | void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IExecutor.d.ts","sourceRoot":"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AAe,CAAC,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,GAAG,oBAAoB,GAAG,IAAI,CAAC;IACvF,uFAAuF;IACvF,eAAe,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IAE3D;;;;OAIG;IACH,gBAAgB,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnD;;OAEG;IACH,sBAAsB,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC;;;;OAIG;IACH,kBAAkB,CAAC,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC/E,wFAAwF;IACxF,mBAAmB,CAAC,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACtD;AAED,uFAAuF;AACvF,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GAAG;IACpD,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC"}
|
|
@@ -13,6 +13,8 @@ export interface PiExecutorOptions {
|
|
|
13
13
|
delegationWorker?: boolean;
|
|
14
14
|
sessionBaseDir?: string;
|
|
15
15
|
clientFactory?: (launch: PiLaunchOptions) => PiTransport;
|
|
16
|
+
/** Native inactivity limit in milliseconds; `0` disables the watchdog. */
|
|
17
|
+
inactivityTimeoutMs?: number;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Persistent Pi executor backed by `pi --mode rpc`.
|
|
@@ -28,6 +30,7 @@ export declare class PiExecutor implements IExecutor {
|
|
|
28
30
|
private readonly provider?;
|
|
29
31
|
private readonly autoApprove;
|
|
30
32
|
private readonly threadId?;
|
|
33
|
+
private readonly inactivityTimeoutMs;
|
|
31
34
|
private readonly sessionFilePath;
|
|
32
35
|
private readonly sessionStoreDir;
|
|
33
36
|
private readonly piCommand?;
|
|
@@ -49,6 +52,8 @@ export declare class PiExecutor implements IExecutor {
|
|
|
49
52
|
private activeTurn;
|
|
50
53
|
private readonly activityTracker;
|
|
51
54
|
private pendingUi;
|
|
55
|
+
/** Pi's own dialog timeout (it sends no event when it resolves the dialog). */
|
|
56
|
+
private pendingUiExpiry;
|
|
52
57
|
private destroyed;
|
|
53
58
|
private delegation?;
|
|
54
59
|
private readonly delegationWorker;
|
|
@@ -107,6 +112,12 @@ export declare class PiExecutor implements IExecutor {
|
|
|
107
112
|
private buildLaunch;
|
|
108
113
|
private handleEvent;
|
|
109
114
|
private handleUiRequest;
|
|
115
|
+
/**
|
|
116
|
+
* Pi resolves a dialog that carries its own timeout and sends no event for it.
|
|
117
|
+
* Without this the watchdog would stay suspended for the rest of the turn.
|
|
118
|
+
*/
|
|
119
|
+
private schedulePendingUiExpiry;
|
|
120
|
+
private clearPendingUiExpiry;
|
|
110
121
|
private resolveModel;
|
|
111
122
|
private isSessionStreaming;
|
|
112
123
|
private lastAssistantText;
|
|
@@ -115,6 +126,19 @@ export declare class PiExecutor implements IExecutor {
|
|
|
115
126
|
private savePointer;
|
|
116
127
|
private clearPointer;
|
|
117
128
|
private completeActive;
|
|
129
|
+
/** Arm the one-shot hard deadline and the re-armable inactivity watchdog. */
|
|
130
|
+
private armTurnDeadlines;
|
|
131
|
+
/** Claim the turn once; the in-flight cleanup stays observable to /abort. */
|
|
132
|
+
private startFailure;
|
|
133
|
+
/** Clear both deadlines; the turn either settled or already claimed a failure. */
|
|
134
|
+
private clearTurnTimers;
|
|
135
|
+
/** Clear only the inactivity watchdog; a hard deadline keeps running. */
|
|
136
|
+
private clearInactivityTimer;
|
|
137
|
+
/**
|
|
138
|
+
* Arm or re-arm the inactivity watchdog. `inactivityTimeout: 0` disables it
|
|
139
|
+
* (used by delegated workers, whose manager owns liveness).
|
|
140
|
+
*/
|
|
141
|
+
private armInactivityTimer;
|
|
118
142
|
private failActive;
|
|
119
143
|
private cancelPendingUi;
|
|
120
144
|
private toImages;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PiExecutor.d.ts","sourceRoot":"","sources":["../../src/executor/PiExecutor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGnF,OAAO,EAKL,KAAK,eAAe,EAEpB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"PiExecutor.d.ts","sourceRoot":"","sources":["../../src/executor/PiExecutor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,o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YAOb,iBAAiB;IAM/B,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,WAAW;IA0BnB,OAAO,CAAC,WAAW;YA8IL,eAAe;IA+C7B;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAW/B,OAAO,CAAC,oBAAoB;YAKd,YAAY;YAcZ,kBAAkB;YASlB,iBAAiB;YASjB,qBAAqB;IAmBnC,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,cAAc;IAiBtB,6EAA6E;IAC7E,OAAO,CAAC,gBAAgB;IAYxB,6EAA6E;IAC7E,OAAO,CAAC,YAAY;IAMpB,kFAAkF;IAClF,OAAO,CAAC,eAAe;IAQvB,yEAAyE;IACzE,OAAO,CAAC,oBAAoB;IAK5B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;YAkBZ,UAAU;IAyBxB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,aAAa;CAUtB;AAMD,YAAY,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -54,7 +54,11 @@ function sameFilePath(left, right) {
|
|
|
54
54
|
} };
|
|
55
55
|
return canonical(left) === canonical(right);
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Default inactivity window: any Pi event re-arms it, so total duration alone
|
|
59
|
+
* never fails a turn. Matches the Agy and Codex backends.
|
|
60
|
+
*/
|
|
61
|
+
const DEFAULT_INACTIVITY_TIMEOUT_MS = 10 * 60 * 1000;
|
|
58
62
|
const COMPACT_TIMEOUT_MS = 10 * 60 * 1000;
|
|
59
63
|
/** Grace period to distinguish immediate slash/extension commands from a real agent turn. */
|
|
60
64
|
const IMMEDIATE_SETTLE_MS = 750;
|
|
@@ -178,6 +182,7 @@ class PiExecutor {
|
|
|
178
182
|
provider;
|
|
179
183
|
autoApprove;
|
|
180
184
|
threadId;
|
|
185
|
+
inactivityTimeoutMs;
|
|
181
186
|
sessionFilePath;
|
|
182
187
|
sessionStoreDir;
|
|
183
188
|
piCommand;
|
|
@@ -199,6 +204,8 @@ class PiExecutor {
|
|
|
199
204
|
activeTurn = null;
|
|
200
205
|
activityTracker = new Activity_1.ActivityTracker();
|
|
201
206
|
pendingUi = null;
|
|
207
|
+
/** Pi's own dialog timeout (it sends no event when it resolves the dialog). */
|
|
208
|
+
pendingUiExpiry = null;
|
|
202
209
|
destroyed = false;
|
|
203
210
|
delegation;
|
|
204
211
|
delegationWorker;
|
|
@@ -217,6 +224,7 @@ class PiExecutor {
|
|
|
217
224
|
this.provider = options.provider;
|
|
218
225
|
this.autoApprove = options.autoApprove ?? true;
|
|
219
226
|
this.threadId = options.threadId;
|
|
227
|
+
this.inactivityTimeoutMs = options.inactivityTimeoutMs ?? DEFAULT_INACTIVITY_TIMEOUT_MS;
|
|
220
228
|
this.delegationWorker = options.delegationWorker ?? false;
|
|
221
229
|
this.piCommand = options.piCommand;
|
|
222
230
|
if (options.initialWorkingDirectory) {
|
|
@@ -292,17 +300,8 @@ class PiExecutor {
|
|
|
292
300
|
pendingToolFallbackIds: [],
|
|
293
301
|
nextToolFallbackId: 0,
|
|
294
302
|
};
|
|
295
|
-
if (options.timeout !== 0 && options.timeout && options.timeout > 0) {
|
|
296
|
-
active.timeoutTimer = setTimeout(() => {
|
|
297
|
-
void this.failActive(active, `Command timed out after ${options.timeout}ms`);
|
|
298
|
-
}, options.timeout);
|
|
299
|
-
}
|
|
300
|
-
else if (options.timeout !== 0) {
|
|
301
|
-
active.timeoutTimer = setTimeout(() => {
|
|
302
|
-
void this.failActive(active, `Command timed out after ${DEFAULT_TURN_TIMEOUT_MS}ms`);
|
|
303
|
-
}, DEFAULT_TURN_TIMEOUT_MS);
|
|
304
|
-
}
|
|
305
303
|
this.activeTurn = active;
|
|
304
|
+
this.armTurnDeadlines(active);
|
|
306
305
|
this.activityTracker.setCallback(options.onActivity);
|
|
307
306
|
this.activityTracker.reset();
|
|
308
307
|
const settled = new Promise((settle) => {
|
|
@@ -411,29 +410,62 @@ class PiExecutor {
|
|
|
411
410
|
if (!this.client.isRunning())
|
|
412
411
|
return false;
|
|
413
412
|
const active = this.activeTurn;
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
413
|
+
// A deadline that already claimed this turn owns its abort, so a second
|
|
414
|
+
// abort RPC (or a concurrent /abort) must not be sent for the same turn.
|
|
415
|
+
const alreadyClaimed = active?.programError !== undefined;
|
|
416
|
+
if (active)
|
|
417
|
+
this.clearTurnTimers(active);
|
|
418
|
+
if (alreadyClaimed) {
|
|
419
|
+
// Wait for the in-flight failure instead of releasing the turn: Pi is still
|
|
420
|
+
// stopping, and its late aborted events would land on the next turn.
|
|
421
|
+
if (active?.failing)
|
|
422
|
+
await active.failing;
|
|
423
|
+
return true;
|
|
419
424
|
}
|
|
425
|
+
// Pi settles its own aborted turn before answering the abort RPC, so claim
|
|
426
|
+
// remote-cli's reason first.
|
|
427
|
+
if (active)
|
|
428
|
+
active.programError = 'Aborted';
|
|
420
429
|
let cleanupError;
|
|
421
|
-
|
|
422
|
-
await this.client.request({ type: 'abort' });
|
|
423
|
-
}
|
|
424
|
-
catch {
|
|
430
|
+
const cleanup = (async () => {
|
|
425
431
|
try {
|
|
426
|
-
await this.
|
|
432
|
+
await this.client.request({ type: 'clear_queue' });
|
|
433
|
+
}
|
|
434
|
+
catch {
|
|
435
|
+
// Queue may already be empty.
|
|
436
|
+
}
|
|
437
|
+
// A successor turn may own the session by now (this turn can settle while
|
|
438
|
+
// the queue request is pending); its abort belongs to that turn.
|
|
439
|
+
if (this.activeTurn !== active)
|
|
440
|
+
return;
|
|
441
|
+
try {
|
|
442
|
+
await this.client.request({ type: 'abort' });
|
|
427
443
|
}
|
|
428
444
|
catch (error) {
|
|
429
|
-
|
|
445
|
+
// Only a turn that still owns the session may recycle its transport; a
|
|
446
|
+
// late failure must not stop the client of a turn starting or started
|
|
447
|
+
// meanwhile, including one still in preparation.
|
|
448
|
+
if (this.activeTurn === active || (!this.activeTurn && !this.preparingTurn)) {
|
|
449
|
+
try {
|
|
450
|
+
await this.recycleClient();
|
|
451
|
+
}
|
|
452
|
+
catch (failure) {
|
|
453
|
+
cleanupError = failure;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
430
456
|
}
|
|
431
|
-
}
|
|
457
|
+
})();
|
|
458
|
+
// A concurrent /abort waits for this cleanup instead of starting its own.
|
|
459
|
+
if (active)
|
|
460
|
+
active.failing = cleanup;
|
|
461
|
+
await cleanup;
|
|
432
462
|
if (active && this.activeTurn === active) {
|
|
433
|
-
|
|
434
|
-
|
|
463
|
+
const claimed = active.programError ?? 'Aborted';
|
|
464
|
+
active.programError = cleanupError ? `${claimed}; ${this.friendlyError(cleanupError)}` : claimed;
|
|
465
|
+
this.completeActive({ success: false, error: active.programError, sessionAbbr: this.sessionAbbr() });
|
|
435
466
|
}
|
|
436
|
-
this.
|
|
467
|
+
if ((!this.activeTurn && !this.preparingTurn) || this.activeTurn === active)
|
|
468
|
+
this.cancelPendingUi(true);
|
|
437
469
|
if (cleanupError)
|
|
438
470
|
throw cleanupError;
|
|
439
471
|
return true;
|
|
@@ -496,6 +528,11 @@ class PiExecutor {
|
|
|
496
528
|
if (!trimmed)
|
|
497
529
|
return false;
|
|
498
530
|
this.pendingUi = null;
|
|
531
|
+
this.clearPendingUiExpiry();
|
|
532
|
+
// The reply restarts the wait for Pi, so it re-arms the watchdog rather
|
|
533
|
+
// than inheriting the little time left from before the prompt.
|
|
534
|
+
if (this.activeTurn)
|
|
535
|
+
this.armInactivityTimer(this.activeTurn);
|
|
499
536
|
if (pending.method === 'confirm') {
|
|
500
537
|
if (/^(n|no|cancel|false)$/i.test(trimmed)) {
|
|
501
538
|
this.client.send({ type: 'extension_ui_response', id: pending.id, cancelled: true });
|
|
@@ -1030,6 +1067,9 @@ class PiExecutor {
|
|
|
1030
1067
|
const active = this.activeTurn;
|
|
1031
1068
|
if (!active)
|
|
1032
1069
|
return;
|
|
1070
|
+
// Pi is still working: re-arm the watchdog so many short tool calls cannot
|
|
1071
|
+
// exhaust it by cumulative duration.
|
|
1072
|
+
this.armInactivityTimer(active);
|
|
1033
1073
|
if (event.type === 'agent_start') {
|
|
1034
1074
|
active.sawAgentStart = true;
|
|
1035
1075
|
return;
|
|
@@ -1153,6 +1193,8 @@ class PiExecutor {
|
|
|
1153
1193
|
return;
|
|
1154
1194
|
const fireAndForget = ['notify', 'setStatus', 'setWidget', 'setTitle', 'set_editor_text'];
|
|
1155
1195
|
if (fireAndForget.includes(method)) {
|
|
1196
|
+
if (this.activeTurn)
|
|
1197
|
+
this.armInactivityTimer(this.activeTurn);
|
|
1156
1198
|
if (method === 'notify' && event.message) {
|
|
1157
1199
|
this.activeTurn?.options.onStream?.(`\n${event.message}\n`);
|
|
1158
1200
|
}
|
|
@@ -1184,6 +1226,34 @@ class PiExecutor {
|
|
|
1184
1226
|
}
|
|
1185
1227
|
this.activeTurn?.options.onStream?.(lines.join('\n'));
|
|
1186
1228
|
this.pendingUi = { id, method, title, options };
|
|
1229
|
+
// The turn now waits for a human, not for Pi; suspend the watchdog until the
|
|
1230
|
+
// reply re-arms it, so a slow answer is never reported as Pi inactivity. The
|
|
1231
|
+
// hard limit stays armed because it bounds the whole turn.
|
|
1232
|
+
if (this.activeTurn)
|
|
1233
|
+
this.clearInactivityTimer(this.activeTurn);
|
|
1234
|
+
this.schedulePendingUiExpiry(id, event.timeout);
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Pi resolves a dialog that carries its own timeout and sends no event for it.
|
|
1238
|
+
* Without this the watchdog would stay suspended for the rest of the turn.
|
|
1239
|
+
*/
|
|
1240
|
+
schedulePendingUiExpiry(id, timeoutMs) {
|
|
1241
|
+
this.clearPendingUiExpiry();
|
|
1242
|
+
if (typeof timeoutMs !== 'number' || !Number.isFinite(timeoutMs) || timeoutMs <= 0)
|
|
1243
|
+
return;
|
|
1244
|
+
this.pendingUiExpiry = setTimeout(() => {
|
|
1245
|
+
this.pendingUiExpiry = null;
|
|
1246
|
+
if (this.pendingUi?.id !== id)
|
|
1247
|
+
return;
|
|
1248
|
+
this.pendingUi = null;
|
|
1249
|
+
if (this.activeTurn)
|
|
1250
|
+
this.armInactivityTimer(this.activeTurn);
|
|
1251
|
+
}, timeoutMs);
|
|
1252
|
+
}
|
|
1253
|
+
clearPendingUiExpiry() {
|
|
1254
|
+
if (this.pendingUiExpiry)
|
|
1255
|
+
clearTimeout(this.pendingUiExpiry);
|
|
1256
|
+
this.pendingUiExpiry = null;
|
|
1187
1257
|
}
|
|
1188
1258
|
async resolveModel(value) {
|
|
1189
1259
|
const parsed = (0, PiTypes_1.parsePiModelRef)(value);
|
|
@@ -1300,34 +1370,107 @@ class PiExecutor {
|
|
|
1300
1370
|
this.activityTracker.setCallback(undefined);
|
|
1301
1371
|
if (active.timeoutTimer)
|
|
1302
1372
|
clearTimeout(active.timeoutTimer);
|
|
1373
|
+
if (active.inactivityTimer)
|
|
1374
|
+
clearTimeout(active.inactivityTimer);
|
|
1303
1375
|
active.settle?.();
|
|
1304
1376
|
this.cancelPendingUi(true);
|
|
1305
|
-
|
|
1377
|
+
// A claimed failure wins over any later result: Pi's own aborted turn would
|
|
1378
|
+
// otherwise report a successful turn that merely raced the deadline.
|
|
1379
|
+
active.resolve(active.programError
|
|
1380
|
+
? { ...result, success: false, error: active.programError }
|
|
1381
|
+
: result);
|
|
1382
|
+
}
|
|
1383
|
+
/** Arm the one-shot hard deadline and the re-armable inactivity watchdog. */
|
|
1384
|
+
armTurnDeadlines(active) {
|
|
1385
|
+
const requested = active.options.timeout;
|
|
1386
|
+
// A non-finite or non-positive limit has no meaningful deadline; Node would
|
|
1387
|
+
// otherwise clamp Infinity to an immediate timer.
|
|
1388
|
+
if (typeof requested === 'number' && Number.isFinite(requested) && requested > 0) {
|
|
1389
|
+
active.timeoutTimer = setTimeout(() => {
|
|
1390
|
+
this.startFailure(active, `Pi turn timed out after ${requested}ms (hard time limit)`);
|
|
1391
|
+
}, requested);
|
|
1392
|
+
}
|
|
1393
|
+
this.armInactivityTimer(active);
|
|
1394
|
+
}
|
|
1395
|
+
/** Claim the turn once; the in-flight cleanup stays observable to /abort. */
|
|
1396
|
+
startFailure(active, error) {
|
|
1397
|
+
const failing = this.failActive(active, error);
|
|
1398
|
+
active.failing = failing;
|
|
1399
|
+
void failing;
|
|
1400
|
+
}
|
|
1401
|
+
/** Clear both deadlines; the turn either settled or already claimed a failure. */
|
|
1402
|
+
clearTurnTimers(active) {
|
|
1403
|
+
if (active.timeoutTimer) {
|
|
1404
|
+
clearTimeout(active.timeoutTimer);
|
|
1405
|
+
active.timeoutTimer = undefined;
|
|
1406
|
+
}
|
|
1407
|
+
this.clearInactivityTimer(active);
|
|
1408
|
+
}
|
|
1409
|
+
/** Clear only the inactivity watchdog; a hard deadline keeps running. */
|
|
1410
|
+
clearInactivityTimer(active) {
|
|
1411
|
+
if (active.inactivityTimer)
|
|
1412
|
+
clearTimeout(active.inactivityTimer);
|
|
1413
|
+
active.inactivityTimer = undefined;
|
|
1414
|
+
}
|
|
1415
|
+
/**
|
|
1416
|
+
* Arm or re-arm the inactivity watchdog. `inactivityTimeout: 0` disables it
|
|
1417
|
+
* (used by delegated workers, whose manager owns liveness).
|
|
1418
|
+
*/
|
|
1419
|
+
armInactivityTimer(active) {
|
|
1420
|
+
// A claimed failure is already aborting this turn; do not re-arm behind it.
|
|
1421
|
+
if (active.programError)
|
|
1422
|
+
return;
|
|
1423
|
+
if (this.pendingUi) {
|
|
1424
|
+
// A turn blocked on a user answer is not idle; the reply re-arms it. Only
|
|
1425
|
+
// the watchdog pauses: a caller-supplied hard limit still runs.
|
|
1426
|
+
this.clearInactivityTimer(active);
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1429
|
+
const requested = active.options.inactivityTimeout ?? this.inactivityTimeoutMs;
|
|
1430
|
+
if (active.inactivityTimer)
|
|
1431
|
+
clearTimeout(active.inactivityTimer);
|
|
1432
|
+
active.inactivityTimer = undefined;
|
|
1433
|
+
if (!Number.isFinite(requested) || requested <= 0)
|
|
1434
|
+
return;
|
|
1435
|
+
active.inactivityTimer = setTimeout(() => {
|
|
1436
|
+
this.startFailure(active, `Pi turn timed out after ${requested}ms of inactivity (no output or tool events)`);
|
|
1437
|
+
}, requested);
|
|
1306
1438
|
}
|
|
1307
1439
|
async failActive(active, error) {
|
|
1308
|
-
|
|
1440
|
+
// Claim the turn once: an event arriving while the abort RPC is in flight
|
|
1441
|
+
// must not start a second failure or a duplicate abort.
|
|
1442
|
+
if (this.activeTurn !== active || active.programError)
|
|
1309
1443
|
return;
|
|
1444
|
+
// Claim the reason before the RPC: Pi answers `abort` only after it persists
|
|
1445
|
+
// its own aborted turn, and that event settles this turn first.
|
|
1446
|
+
active.programError = error;
|
|
1447
|
+
this.clearTurnTimers(active);
|
|
1310
1448
|
let cleanupError;
|
|
1311
1449
|
try {
|
|
1312
1450
|
await this.client.request({ type: 'abort' });
|
|
1313
1451
|
}
|
|
1314
1452
|
catch {
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1453
|
+
// Only the turn that still owns the session may recycle its transport; a
|
|
1454
|
+
// late failure from a settled turn must not stop the next turn's client.
|
|
1455
|
+
if (this.activeTurn === active) {
|
|
1456
|
+
try {
|
|
1457
|
+
await this.recycleClient();
|
|
1458
|
+
}
|
|
1459
|
+
catch (failure) {
|
|
1460
|
+
cleanupError = failure;
|
|
1461
|
+
}
|
|
1320
1462
|
}
|
|
1321
1463
|
}
|
|
1322
1464
|
if (this.activeTurn === active) {
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1465
|
+
if (cleanupError)
|
|
1466
|
+
active.programError = `${active.programError}; ${this.friendlyError(cleanupError)}`;
|
|
1467
|
+
this.completeActive({ success: false, error: active.programError, sessionAbbr: this.sessionAbbr() });
|
|
1326
1468
|
}
|
|
1327
1469
|
}
|
|
1328
1470
|
cancelPendingUi(cancel = false) {
|
|
1329
1471
|
const pending = this.pendingUi;
|
|
1330
1472
|
this.pendingUi = null;
|
|
1473
|
+
this.clearPendingUiExpiry();
|
|
1331
1474
|
if (pending && cancel) {
|
|
1332
1475
|
try {
|
|
1333
1476
|
this.client.send({ type: 'extension_ui_response', id: pending.id, cancelled: true });
|