@yu_robotics/remote-cli 1.6.255 → 1.6.259
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/client/MessageHandler.d.ts +5 -12
- package/dist/client/MessageHandler.d.ts.map +1 -1
- package/dist/client/MessageHandler.js +53 -252
- package/dist/client/MessageHandler.js.map +1 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +0 -3
- package/dist/commands/start.js.map +1 -1
- package/dist/executor/AcpExecutor.d.ts.map +1 -1
- package/dist/executor/AcpExecutor.js.map +1 -1
- package/dist/executor/AgyExecutor.d.ts +4 -11
- package/dist/executor/AgyExecutor.d.ts.map +1 -1
- package/dist/executor/AgyExecutor.js +68 -98
- package/dist/executor/AgyExecutor.js.map +1 -1
- package/dist/executor/ClaudePersistentExecutor.d.ts +3 -7
- package/dist/executor/ClaudePersistentExecutor.d.ts.map +1 -1
- package/dist/executor/ClaudePersistentExecutor.js +14 -224
- package/dist/executor/ClaudePersistentExecutor.js.map +1 -1
- package/dist/executor/DshExecutor.d.ts +7 -14
- package/dist/executor/DshExecutor.d.ts.map +1 -1
- package/dist/executor/DshExecutor.js +48 -50
- package/dist/executor/DshExecutor.js.map +1 -1
- package/dist/executor/IExecutor.d.ts +2 -2
- package/dist/executor/IExecutor.d.ts.map +1 -1
- package/dist/executor/acp/AcpClient.d.ts +15 -1
- package/dist/executor/acp/AcpClient.d.ts.map +1 -1
- package/dist/executor/acp/AcpClient.js +85 -7
- package/dist/executor/acp/AcpClient.js.map +1 -1
- package/dist/executor/agy/AgyAcpDiagnostics.d.ts +8 -0
- package/dist/executor/agy/AgyAcpDiagnostics.d.ts.map +1 -0
- package/dist/executor/agy/AgyAcpDiagnostics.js +45 -0
- package/dist/executor/agy/AgyAcpDiagnostics.js.map +1 -0
- package/dist/executor/agy/AgyAcpRuntime.d.ts +9 -16
- package/dist/executor/agy/AgyAcpRuntime.d.ts.map +1 -1
- package/dist/executor/agy/AgyAcpRuntime.js +67 -151
- package/dist/executor/agy/AgyAcpRuntime.js.map +1 -1
- package/dist/executor/agy/AgySessionSelection.d.ts +7 -0
- package/dist/executor/agy/AgySessionSelection.d.ts.map +1 -0
- package/dist/executor/agy/AgySessionSelection.js +60 -0
- package/dist/executor/agy/AgySessionSelection.js.map +1 -0
- package/dist/executor/agy/AgySessionSettings.d.ts +13 -0
- package/dist/executor/agy/AgySessionSettings.d.ts.map +1 -0
- package/dist/executor/agy/AgySessionSettings.js +60 -0
- package/dist/executor/agy/AgySessionSettings.js.map +1 -0
- package/dist/executor/dsh/DshAcpClient.d.ts +1 -1
- package/dist/executor/dsh/DshAcpClient.d.ts.map +1 -1
- package/dist/executor/dsh/DshAcpClient.js +3 -1
- package/dist/executor/dsh/DshAcpClient.js.map +1 -1
- package/dist/executor/index.d.ts +1 -0
- package/dist/executor/index.d.ts.map +1 -1
- package/dist/executor/index.js +1 -0
- package/dist/executor/index.js.map +1 -1
- package/dist/maintenance/release-notes.json +1 -1
- package/dist/scheduling/ScheduleCapabilities.d.ts +2 -2
- package/dist/scheduling/ScheduleCapabilities.js +4 -4
- package/dist/scheduling/ScheduleCapabilities.js.map +1 -1
- package/dist/scheduling/SchedulePurgeVerification.js +1 -1
- package/dist/scheduling/SchedulePurgeVerification.js.map +1 -1
- package/dist/scheduling/ScheduleService.d.ts +10 -29
- package/dist/scheduling/ScheduleService.d.ts.map +1 -1
- package/dist/scheduling/ScheduleService.js +160 -627
- package/dist/scheduling/ScheduleService.js.map +1 -1
- package/dist/scheduling/agy/AgySessionSchedules.d.ts +5 -5
- package/dist/scheduling/agy/AgySessionSchedules.d.ts.map +1 -1
- package/dist/scheduling/agy/AgySessionSchedules.js +20 -17
- package/dist/scheduling/agy/AgySessionSchedules.js.map +1 -1
- package/dist/scheduling/claude/ClaudeScheduleOwnership.d.ts +2 -6
- package/dist/scheduling/claude/ClaudeScheduleOwnership.d.ts.map +1 -1
- package/dist/scheduling/claude/ClaudeScheduleOwnership.js +12 -67
- package/dist/scheduling/claude/ClaudeScheduleOwnership.js.map +1 -1
- package/dist/scheduling/claude/ClaudeSessionSchedules.d.ts +4 -26
- package/dist/scheduling/claude/ClaudeSessionSchedules.d.ts.map +1 -1
- package/dist/scheduling/claude/ClaudeSessionSchedules.js +22 -145
- package/dist/scheduling/claude/ClaudeSessionSchedules.js.map +1 -1
- package/dist/scheduling/dsh/ScheduledSessionGuard.d.ts +12 -0
- package/dist/scheduling/dsh/ScheduledSessionGuard.d.ts.map +1 -0
- package/dist/scheduling/dsh/ScheduledSessionGuard.js +96 -0
- package/dist/scheduling/dsh/ScheduledSessionGuard.js.map +1 -0
- package/dist/scheduling/dsh/SessionScheduleBridge.d.ts.map +1 -1
- package/dist/scheduling/dsh/SessionScheduleBridge.js +0 -25
- package/dist/scheduling/dsh/SessionScheduleBridge.js.map +1 -1
- package/dist/scheduling/dsh/SessionScheduleClient.d.ts.map +1 -1
- package/dist/scheduling/dsh/SessionScheduleClient.js +0 -8
- package/dist/scheduling/dsh/SessionScheduleClient.js.map +1 -1
- package/dist/scheduling/dsh/sessionLaunch.js +1 -1
- package/dist/scheduling/dsh/sessionLaunch.js.map +1 -1
- package/dist/scheduling/types.d.ts +26 -77
- package/dist/scheduling/types.d.ts.map +1 -1
- package/dist/scheduling/types.js +1 -10
- package/dist/scheduling/types.js.map +1 -1
- package/dist/service/ServiceManager.js +1 -1
- package/dist/thread/ThreadExecutorPool.d.ts +4 -1
- package/dist/thread/ThreadExecutorPool.d.ts.map +1 -1
- package/dist/thread/ThreadExecutorPool.js +6 -3
- package/dist/thread/ThreadExecutorPool.js.map +1 -1
- package/dist/thread/ThreadManager.d.ts.map +1 -1
- package/dist/thread/ThreadManager.js +23 -2
- package/dist/thread/ThreadManager.js.map +1 -1
- package/native/prebuilds/darwin-arm64/managed_native.node +0 -0
- package/native/prebuilds/darwin-arm64/manifest.json +1 -1
- package/native/prebuilds/darwin-x64/managed_native.node +0 -0
- package/native/prebuilds/darwin-x64/manifest.json +1 -1
- package/native/prebuilds/win32-arm64/managed_native.node +0 -0
- package/native/prebuilds/win32-arm64/manifest.json +1 -1
- package/native/prebuilds/win32-x64/managed_native.node +0 -0
- package/native/prebuilds/win32-x64/manifest.json +1 -1
- package/package.json +1 -1
- package/dist/scheduling/agy/AgyCheckpoint.d.ts +0 -35
- package/dist/scheduling/agy/AgyCheckpoint.d.ts.map +0 -1
- package/dist/scheduling/agy/AgyCheckpoint.js +0 -160
- package/dist/scheduling/agy/AgyCheckpoint.js.map +0 -1
|
@@ -318,8 +318,6 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
318
318
|
}
|
|
319
319
|
return data;
|
|
320
320
|
}
|
|
321
|
-
scheduleRestart;
|
|
322
|
-
scheduleRestoring;
|
|
323
321
|
scheduleOwnership;
|
|
324
322
|
scheduleOwnershipSession;
|
|
325
323
|
scheduleHostOwnership() {
|
|
@@ -332,14 +330,13 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
332
330
|
}
|
|
333
331
|
return this.scheduleOwnership;
|
|
334
332
|
}
|
|
335
|
-
get
|
|
333
|
+
get nativeScheduleCleanup() {
|
|
336
334
|
// Advertise the adapter before cold startup; native operations still require
|
|
337
335
|
// the current host's tools, hooks, lifecycle evidence and confirmed receipts.
|
|
338
336
|
if (this.delegationWorker || this.sandbox.isRestricted())
|
|
339
337
|
return undefined;
|
|
340
338
|
return {
|
|
341
|
-
provider: 'claude-session-skip-unadmitted-v1', strategy: 'reconstruct',
|
|
342
|
-
handoffPolicy: 'skip-unadmitted',
|
|
339
|
+
provider: 'claude-session-skip-unadmitted-v1', strategy: 'reconstruct',
|
|
343
340
|
cancelRetained: async (record, context) => {
|
|
344
341
|
const identity = JSON.parse(record.recovery.identity);
|
|
345
342
|
const child = this.claudeProcess, epoch = this.stopEpoch;
|
|
@@ -370,132 +367,9 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
370
367
|
describe: input => JSON.stringify({ marker: (0, crypto_1.randomUUID)(), sessionId: this.sessionId,
|
|
371
368
|
cwd: input.cwd, threadId: this.threadId, model: this.model, effort: this.effort,
|
|
372
369
|
effectiveModel: this.acknowledgedModel || this.reportedModel || this.model }),
|
|
373
|
-
finishRestart: () => this.finishScheduleRestart(),
|
|
374
|
-
releaseRestartAdmission: () => {
|
|
375
|
-
const state = this.scheduleRestart;
|
|
376
|
-
if (state?.exit?.code === 0 && !state.exit.signal && state.endRequested
|
|
377
|
-
&& state.epoch === this.stopEpoch && !this.claudeProcess)
|
|
378
|
-
this.scheduleRestart = undefined;
|
|
379
|
-
},
|
|
380
|
-
reconcile: async (record, context, emit) => {
|
|
381
|
-
let identity;
|
|
382
|
-
let clean;
|
|
383
|
-
// Only this synchronous preflight can certify that no native admission
|
|
384
|
-
// began. Failures after host startup retain the ordinary uncertainty fence.
|
|
385
|
-
try {
|
|
386
|
-
identity = JSON.parse(record.recovery.identity);
|
|
387
|
-
clean = record.recovery?.handoff === 'clean' && record.recovery.nativeDefinitionAbsent;
|
|
388
|
-
if ((!clean && (!record.recovery?.futureOnly || record.rule.kind !== 'cron'))
|
|
389
|
-
|| record.recovery?.handoffPolicy !== 'skip-unadmitted' || !context.isCurrent()
|
|
390
|
-
|| context.signal.aborted || !identity.sessionId || identity.sessionId !== this.sessionId
|
|
391
|
-
|| identity.cwd !== this.currentWorkingDirectory || identity.threadId !== this.threadId
|
|
392
|
-
|| identity.model !== this.model || identity.effort !== this.effort) {
|
|
393
|
-
throw new Error('Original Claude context or recovery evidence changed.');
|
|
394
|
-
}
|
|
395
|
-
if (this.scheduleRestart && !this.scheduleRestart.exit)
|
|
396
|
-
throw new Error('Claude predecessor exit is unconfirmed.');
|
|
397
|
-
this.scheduleRestart = undefined;
|
|
398
|
-
const ownership = this.scheduleHostOwnership();
|
|
399
|
-
ownership.reserve(!!clean, identity.ownerToken);
|
|
400
|
-
if (!clean)
|
|
401
|
-
ownership.assertRebootRecovery();
|
|
402
|
-
}
|
|
403
|
-
catch (error) {
|
|
404
|
-
throw new types_1.NativeScheduleNotAdmittedError(error instanceof Error ? error.message : 'Native recovery preflight refused admission.');
|
|
405
|
-
}
|
|
406
|
-
const restoration = {};
|
|
407
|
-
this.scheduleRestoring = restoration;
|
|
408
|
-
const epoch = this.stopEpoch;
|
|
409
|
-
const current = () => this.scheduleRestoring === restoration && this.stopEpoch === epoch
|
|
410
|
-
&& !this.isDestroyed && context.isCurrent() && !context.signal.aborted && this.sessionId === identity.sessionId;
|
|
411
|
-
const input = { id: record.id, threadId: record.threadId, backend: 'claude',
|
|
412
|
-
cwd: record.cwd, prompt: record.prompt, rule: record.rule, ...record.execution, recovery: record.recovery };
|
|
413
|
-
let handle;
|
|
414
|
-
let adapter;
|
|
415
|
-
const expire = () => adapter?.expireRecovery(`restore-${record.id}`);
|
|
416
|
-
context.signal.addEventListener('abort', expire, { once: true });
|
|
417
|
-
try {
|
|
418
|
-
await this.listModels();
|
|
419
|
-
if (!current())
|
|
420
|
-
throw new Error('Claude recovery owner changed.');
|
|
421
|
-
if (!this.claudeProcess?.pid || this.turnLedger.invalid || this.turnLedger.pid !== this.claudeProcess.pid
|
|
422
|
-
|| this.turnLedger.session && !this.turnLedger.supported(this.claudeProcess.pid)
|
|
423
|
-
|| typeof identity.effectiveModel !== 'string' || !identity.effectiveModel)
|
|
424
|
-
throw new Error('Original Claude model or supported host is unavailable.');
|
|
425
|
-
const child = this.claudeProcess;
|
|
426
|
-
if (this.model !== identity.effectiveModel) {
|
|
427
|
-
const response = await this.nativeControl('set_model', { model: identity.effectiveModel });
|
|
428
|
-
if (!current() || this.claudeProcess !== child)
|
|
429
|
-
throw new Error('Claude recovery model owner changed.');
|
|
430
|
-
if (!response || typeof response !== 'object' || response.model !== identity.effectiveModel) {
|
|
431
|
-
throw new Error('Claude recovery model selection is unconfirmed.');
|
|
432
|
-
}
|
|
433
|
-
this.recordModelSelection(identity.effectiveModel);
|
|
434
|
-
}
|
|
435
|
-
this.scheduleHostOwnership().bindHost(child.pid);
|
|
436
|
-
adapter = this.schedules();
|
|
437
|
-
const timezone = await this.readNativeScheduleTimezone();
|
|
438
|
-
if (!current() || this.claudeProcess !== child)
|
|
439
|
-
throw new Error('Claude recovery host changed.');
|
|
440
|
-
handle = await adapter.inToolOperation(`restore-${record.id}`, current, () => adapter.create(input, emit, context.isOwnerCurrent ?? context.isCurrent, timezone, clean ? 'adopt' : 'adopt-existing', record.nativeId, context.canAdmitOccurrence), false);
|
|
441
|
-
if (!current() || this.claudeProcess !== child || !this.turnLedger.supported(child?.pid))
|
|
442
|
-
throw new types_1.NativeScheduleCleanupError('Claude recovery host or protocol changed.', handle);
|
|
443
|
-
const recovered = this.recoverableScheduleHandle(handle, input, restoration);
|
|
444
|
-
this.scheduleRestoring = undefined;
|
|
445
|
-
return recovered;
|
|
446
|
-
}
|
|
447
|
-
catch (error) {
|
|
448
|
-
if (error instanceof types_1.NativeScheduleAbsentError && this.scheduleRestoring === restoration)
|
|
449
|
-
this.scheduleRestoring = undefined;
|
|
450
|
-
const cleanup = error instanceof types_1.NativeScheduleCleanupError ? error.handle : handle;
|
|
451
|
-
if (cleanup)
|
|
452
|
-
throw new types_1.NativeScheduleCleanupError(error instanceof Error ? error.message : 'Claude recovery failed after native creation.', this.recoverableScheduleHandle(cleanup, input, restoration));
|
|
453
|
-
// No cleanup handle means the adapter never admitted a mutation. Still
|
|
454
|
-
// join its exact management turn before reopening ordinary input.
|
|
455
|
-
const settled = adapter?.settleManagement() ?? Promise.resolve();
|
|
456
|
-
let timer;
|
|
457
|
-
try {
|
|
458
|
-
await Promise.race([settled, new Promise((_, reject) => {
|
|
459
|
-
timer = setTimeout(() => reject(new Error('Native recovery management settlement timed out.')), 60_000);
|
|
460
|
-
})]);
|
|
461
|
-
}
|
|
462
|
-
catch (settlementError) {
|
|
463
|
-
if (this.scheduleRestoring !== restoration || this.stopEpoch !== epoch)
|
|
464
|
-
throw settlementError;
|
|
465
|
-
if (adapter?.hasJobs || adapter?.admittedWork || adapter?.cleanupMutationPending
|
|
466
|
-
|| !this.turnLedger.inventory || this.turnLedger.inventory.size
|
|
467
|
-
|| [...this.turnLedger.tasks.values()].some(task => !task.terminal)) {
|
|
468
|
-
// A sibling or unknown live task forbids recycling the shared host.
|
|
469
|
-
// Keep joining this exact turn so its eventual terminal releases
|
|
470
|
-
// the failed attempt instead of leaving a permanent no-handle fence.
|
|
471
|
-
await settled;
|
|
472
|
-
}
|
|
473
|
-
else {
|
|
474
|
-
// Only an isolated failed management host may be recycled. Session
|
|
475
|
-
// identity/history survive, and close drains all native output first.
|
|
476
|
-
await this.stopProcess();
|
|
477
|
-
if (this.currentScheduleManagement) {
|
|
478
|
-
this.currentCommandReject?.(new Error('Failed native recovery management host closed.'));
|
|
479
|
-
this.resetCurrentCommand();
|
|
480
|
-
this.isProcessing = false;
|
|
481
|
-
}
|
|
482
|
-
await settled;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
finally {
|
|
486
|
-
clearTimeout(timer);
|
|
487
|
-
}
|
|
488
|
-
if (this.scheduleRestoring === restoration)
|
|
489
|
-
this.scheduleRestoring = undefined;
|
|
490
|
-
throw new types_1.NativeScheduleRecoverySettledError(error instanceof Error ? error.message : 'Native recovery failed.');
|
|
491
|
-
}
|
|
492
|
-
finally {
|
|
493
|
-
context.signal.removeEventListener('abort', expire);
|
|
494
|
-
}
|
|
495
|
-
},
|
|
496
370
|
};
|
|
497
371
|
}
|
|
498
|
-
|
|
372
|
+
ownedScheduleHandle(handle, input) {
|
|
499
373
|
if (!input.recovery)
|
|
500
374
|
return handle;
|
|
501
375
|
// describe() runs before creation reserves ownership. Capture the actual
|
|
@@ -505,86 +379,12 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
505
379
|
return { ...handle,
|
|
506
380
|
get nativeId() { return handle.nativeId; },
|
|
507
381
|
get nativeDefinitionAbsent() { return handle.nativeDefinitionAbsent; },
|
|
508
|
-
get
|
|
382
|
+
get cleanupIdentity() {
|
|
509
383
|
return JSON.stringify({ ...identity, sessionId: executor.sessionId,
|
|
510
384
|
model: executor.model, effort: executor.effort,
|
|
511
385
|
effectiveModel: executor.acknowledgedModel || executor.reportedModel || executor.model });
|
|
512
386
|
},
|
|
513
|
-
|
|
514
|
-
...(handle.onceDefinitionAlreadyAbsent && { onceDefinitionAlreadyAbsent: true }) }),
|
|
515
|
-
stop: async () => {
|
|
516
|
-
await handle.stop();
|
|
517
|
-
if (restoration && this.scheduleRestoring === restoration && !this.sessionSchedules?.hasPendingMutation)
|
|
518
|
-
this.scheduleRestoring = undefined;
|
|
519
|
-
}, };
|
|
520
|
-
}
|
|
521
|
-
releaseScheduleDefinitions() {
|
|
522
|
-
if (this.scheduleRestart?.release)
|
|
523
|
-
return this.scheduleRestart.release;
|
|
524
|
-
const child = this.claudeProcess;
|
|
525
|
-
if (!child || !this.turnLedger.supported(child.pid) || !this.scheduleHooksReady || this.modelChange
|
|
526
|
-
|| this.retainedAbort || this.abortOperation || this.hasUncertainShutdown() || this.commandQueue.length
|
|
527
|
-
|| this.isProcessing || this.isStarting || this.scheduleRestoring)
|
|
528
|
-
return Promise.reject(new Error('Claude handoff admission is unavailable.'));
|
|
529
|
-
const adapter = this.schedules();
|
|
530
|
-
const state = this.scheduleRestart ??= { child, epoch: this.stopEpoch, adapter };
|
|
531
|
-
const current = () => !this.isDestroyed && this.claudeProcess === child && this.stopEpoch === state.epoch && !this.abortOperation;
|
|
532
|
-
// Synchronous: after this point, a wake must pass the hook fence or be skipped.
|
|
533
|
-
adapter.beginRestart();
|
|
534
|
-
state.release = (async () => {
|
|
535
|
-
await adapter.removeFutureDefinitionsForRestart({ isCurrent: current });
|
|
536
|
-
await this.turnLedger.wait(() => current() && !adapter.admittedWork && !this.isProcessing
|
|
537
|
-
&& !this.turnLedger.active && !this.pendingApprovals.size && !this.pendingControlRequests.size, 25_000, 'Admitted schedule execution drain');
|
|
538
|
-
if (!current())
|
|
539
|
-
throw new Error('Claude handoff host changed.');
|
|
540
|
-
return { nativeDefinitionAbsent: true, policy: 'skip-unadmitted' };
|
|
541
|
-
})();
|
|
542
|
-
return state.release;
|
|
543
|
-
}
|
|
544
|
-
async finishScheduleRestart() {
|
|
545
|
-
const state = this.scheduleRestart;
|
|
546
|
-
if (!state?.release)
|
|
547
|
-
throw new Error('Claude handoff was not prepared.');
|
|
548
|
-
await state.release;
|
|
549
|
-
if (state.exit) {
|
|
550
|
-
if (state.exit.code === 0 && !state.exit.signal && state.endRequested
|
|
551
|
-
&& this.stopEpoch === state.epoch && !this.claudeProcess) {
|
|
552
|
-
// A timeout or failed receipt publication can precede a confirmed close.
|
|
553
|
-
// Retrying must durably publish that proof before reporting success.
|
|
554
|
-
this.scheduleOwnership?.confirmClean();
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
|
-
throw new Error('Claude handoff exited unsuccessfully.');
|
|
558
|
-
}
|
|
559
|
-
const child = state.child;
|
|
560
|
-
const current = () => this.claudeProcess === child && this.stopEpoch === state.epoch && !this.isDestroyed;
|
|
561
|
-
if (!current())
|
|
562
|
-
throw new Error('Claude handoff host changed.');
|
|
563
|
-
// A new initialize response includes a fresh authoritative native task snapshot.
|
|
564
|
-
this.turnLedger.inventory = undefined;
|
|
565
|
-
await this.nativeControl('initialize', { hooks: ClaudeSessionSchedules_1.SCHEDULE_HOOKS });
|
|
566
|
-
await this.turnLedger.wait(() => current() && this.turnLedger.inventory?.size === 0
|
|
567
|
-
&& [...this.turnLedger.tasks.values()].every(task => task.terminal)
|
|
568
|
-
&& !state.adapter.admittedWork && !this.turnLedger.active && !this.isProcessing
|
|
569
|
-
&& !this.pendingApprovals.size && !this.pendingControlRequests.size, 25_000, 'Native background drain');
|
|
570
|
-
if (!current())
|
|
571
|
-
throw new Error('Claude handoff host changed.');
|
|
572
|
-
// No signals, process-tree stop or timeout escalation: timeout retains the fence.
|
|
573
|
-
const exit = new Promise((resolve, reject) => {
|
|
574
|
-
const closed = (code, signal) => {
|
|
575
|
-
clearTimeout(timer);
|
|
576
|
-
if (code === 0 && !signal && this.stopEpoch === state.epoch)
|
|
577
|
-
resolve();
|
|
578
|
-
else
|
|
579
|
-
reject(new Error('Claude orderly exit was not confirmed.'));
|
|
580
|
-
};
|
|
581
|
-
const timer = setTimeout(() => { child.removeListener('close', closed); reject(new Error('Claude orderly exit remains unconfirmed; ownership retained.')); }, 20_000);
|
|
582
|
-
child.once('close', closed);
|
|
583
|
-
});
|
|
584
|
-
state.endRequested = true;
|
|
585
|
-
child.stdin.end();
|
|
586
|
-
await exit;
|
|
587
|
-
this.scheduleOwnership?.confirmClean();
|
|
387
|
+
};
|
|
588
388
|
}
|
|
589
389
|
sessionSchedules;
|
|
590
390
|
scheduleHooksReady = false;
|
|
@@ -618,7 +418,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
618
418
|
throw new Error('No bound Claude session. Select the original thread/session; cleanup never searches or creates another session.');
|
|
619
419
|
if (!current() || this.reviewedCleanupActive || this.modelChange || this.retainedAbort || this.abortOperation
|
|
620
420
|
|| this.hasUncertainShutdown() || this.delegationWorker || this.isDestroyed || this.isStopping
|
|
621
|
-
|| this.sandbox.isRestricted() ||
|
|
421
|
+
|| this.sandbox.isRestricted() || (!inTurn && this.isBusy())
|
|
622
422
|
|| !this.delegation?.groups?.includes('scheduling'))
|
|
623
423
|
throw new Error('Bound native cleanup is unavailable or busy. Retry when this thread is idle.');
|
|
624
424
|
this.reviewedCleanupActive = true;
|
|
@@ -698,7 +498,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
698
498
|
async createNativeSchedule(input, onEvent, isOwnerCurrent, canAdmitOccurrence) {
|
|
699
499
|
let timezone;
|
|
700
500
|
try {
|
|
701
|
-
if (this.
|
|
501
|
+
if (this.modelChange || this.delegationWorker || this.isDestroyed || this.isStopping || this.sandbox.isRestricted()
|
|
702
502
|
|| input.cwd !== this.currentWorkingDirectory)
|
|
703
503
|
throw new Error('Native schedule context or sandbox is unavailable.');
|
|
704
504
|
if (!this.scheduleHooksReady)
|
|
@@ -707,7 +507,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
707
507
|
if (this.modelChange)
|
|
708
508
|
throw new Error('Native model change is pending or unconfirmed.');
|
|
709
509
|
if (input.recovery && !this.turnLedger.supported(this.claudeProcess?.pid))
|
|
710
|
-
throw new Error('Claude
|
|
510
|
+
throw new Error('Claude schedule ownership protocol is unsupported.');
|
|
711
511
|
if (input.recovery)
|
|
712
512
|
this.scheduleHostOwnership().reserveForNewJob(this.claudeProcess.pid, this.claudeCommand);
|
|
713
513
|
}
|
|
@@ -715,7 +515,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
715
515
|
// No adapter admission or native schedule mutation has started here.
|
|
716
516
|
throw new types_1.NativeScheduleNotAdmittedError(error instanceof Error ? error.message : 'Native schedule preflight refused admission.');
|
|
717
517
|
}
|
|
718
|
-
return this.
|
|
518
|
+
return this.ownedScheduleHandle(await this.schedules().create(input, onEvent, isOwnerCurrent, timezone, canAdmitOccurrence), input);
|
|
719
519
|
}
|
|
720
520
|
/** Inspect only the effective TZ; never log, retain, or expose settings to a model. */
|
|
721
521
|
readNativeScheduleTimezone() {
|
|
@@ -796,8 +596,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
796
596
|
hasUncertainShutdown() { return this.shutdownUncertain || this.isStopping || !!this.stopOperation; }
|
|
797
597
|
isBusy() { return !!this.modelChange || this.isWorkBusy(); }
|
|
798
598
|
isWorkBusy() {
|
|
799
|
-
if (this.reviewedCleanupActive || this.
|
|
800
|
-
|| this.scheduleRestart && this.claudeProcess === this.scheduleRestart.child)
|
|
599
|
+
if (this.reviewedCleanupActive || this.retainedAbort || this.abortOperation || this.hasUncertainShutdown() || this.scheduleCleanupHost)
|
|
801
600
|
return true;
|
|
802
601
|
if (this.sessionSchedules?.busy)
|
|
803
602
|
return true;
|
|
@@ -868,7 +667,8 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
868
667
|
this.scheduleGuardRequired = !this.delegationWorker && (!!this.sessionId || managedScheduling);
|
|
869
668
|
// Non-owning hosts must not start the native scheduler or expose Cron tools.
|
|
870
669
|
// The settings flag does not suppress transcript-restored definitions.
|
|
871
|
-
const disableNativeSchedules = !managedScheduling
|
|
670
|
+
const disableNativeSchedules = !managedScheduling
|
|
671
|
+
|| !!this.sessionId && this.scheduleHostOwnership().exists() && !this.scheduleHostOwnership().ownerToken;
|
|
872
672
|
const mcpServers = {};
|
|
873
673
|
const args = [
|
|
874
674
|
'--input-format=stream-json',
|
|
@@ -1093,13 +893,9 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1093
893
|
// Use 'close' event (fires after all I/O streams are closed, i.e. after all stdout
|
|
1094
894
|
// data events have been processed) instead of 'exit' for command completion logic.
|
|
1095
895
|
child.on('close', (code, signal) => {
|
|
1096
|
-
const restart = this.scheduleRestart;
|
|
1097
|
-
const released = restart?.child === child && restart.endRequested && restart.epoch === this.stopEpoch && code === 0 && !signal;
|
|
1098
896
|
if (this.claudeProcess === child) {
|
|
1099
|
-
if (restart?.child === child)
|
|
1100
|
-
restart.exit = { code, signal };
|
|
1101
897
|
this.scheduleOwnership?.hostClosed();
|
|
1102
|
-
this.sessionSchedules?.processClosed(
|
|
898
|
+
this.sessionSchedules?.processClosed();
|
|
1103
899
|
this.sessionSchedules = undefined;
|
|
1104
900
|
this.scheduleHooksReady = false;
|
|
1105
901
|
}
|
|
@@ -1114,7 +910,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1114
910
|
this.claudeProcess = null;
|
|
1115
911
|
this.turnLedger.retire();
|
|
1116
912
|
// Check if this was an intentional stop (abort/reset)
|
|
1117
|
-
const wasIntentionalStop = this.isStopping
|
|
913
|
+
const wasIntentionalStop = this.isStopping;
|
|
1118
914
|
this.isStopping = false; // Reset the flag
|
|
1119
915
|
// Reject current command if any (only for unexpected exits)
|
|
1120
916
|
if (this.currentCommandReject && !wasIntentionalStop) {
|
|
@@ -2446,8 +2242,6 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
2446
2242
|
async execute(prompt, options = {}) {
|
|
2447
2243
|
if (this.isDestroyed)
|
|
2448
2244
|
return { success: false, error: 'Executor has been destroyed' };
|
|
2449
|
-
if ((this.scheduleRestart || this.scheduleRestoring) && !(options.nativeScheduleManagement && options.nativeScheduleCurrent?.()))
|
|
2450
|
-
return { success: false, error: 'Native schedule handoff or restoration is pending.' };
|
|
2451
2245
|
if (this.modelChange)
|
|
2452
2246
|
return { success: false, error: 'Native model change is pending or unconfirmed. Retry /model after its reply, or use /clear (session-only schedules will be lost).' };
|
|
2453
2247
|
if (((this.abortOperation || this.retainedAbort) && !(this.cleanupAdmission() && options.nativeScheduleManagement && options.nativeScheduleCurrent?.()))
|
|
@@ -2690,8 +2484,6 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
2690
2484
|
await this.stopProcess();
|
|
2691
2485
|
this.retainedAbort = undefined;
|
|
2692
2486
|
this.shutdownUncertain = false;
|
|
2693
|
-
this.scheduleRestart = undefined;
|
|
2694
|
-
this.scheduleRestoring = undefined;
|
|
2695
2487
|
}
|
|
2696
2488
|
/**
|
|
2697
2489
|
* Reset execution context
|
|
@@ -2702,8 +2494,6 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
2702
2494
|
* prompts interrupted during startup are not replayed into the fresh context.
|
|
2703
2495
|
*/
|
|
2704
2496
|
resetContext() {
|
|
2705
|
-
this.scheduleRestart = undefined;
|
|
2706
|
-
this.scheduleRestoring = undefined;
|
|
2707
2497
|
this.cancelInputWaiters();
|
|
2708
2498
|
this.nativeCreationEpoch++;
|
|
2709
2499
|
console.log('[ClaudePersistent] Resetting session context');
|