@yu_robotics/remote-cli 1.6.244 → 1.6.251

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.
Files changed (155) hide show
  1. package/dist/client/MessageHandler.d.ts +6 -2
  2. package/dist/client/MessageHandler.d.ts.map +1 -1
  3. package/dist/client/MessageHandler.js +144 -48
  4. package/dist/client/MessageHandler.js.map +1 -1
  5. package/dist/client/WebSocketClient.d.ts +3 -0
  6. package/dist/client/WebSocketClient.d.ts.map +1 -1
  7. package/dist/client/WebSocketClient.js +3 -1
  8. package/dist/client/WebSocketClient.js.map +1 -1
  9. package/dist/commands/start.d.ts +5 -0
  10. package/dist/commands/start.d.ts.map +1 -1
  11. package/dist/commands/start.js +37 -0
  12. package/dist/commands/start.js.map +1 -1
  13. package/dist/executor/AgyExecutor.d.ts +39 -2
  14. package/dist/executor/AgyExecutor.d.ts.map +1 -1
  15. package/dist/executor/AgyExecutor.js +383 -38
  16. package/dist/executor/AgyExecutor.js.map +1 -1
  17. package/dist/executor/ClaudePersistentExecutor.d.ts.map +1 -1
  18. package/dist/executor/ClaudePersistentExecutor.js +29 -16
  19. package/dist/executor/ClaudePersistentExecutor.js.map +1 -1
  20. package/dist/executor/DshExecutor.d.ts +1 -0
  21. package/dist/executor/DshExecutor.d.ts.map +1 -1
  22. package/dist/executor/IExecutor.d.ts +1 -1
  23. package/dist/executor/IExecutor.d.ts.map +1 -1
  24. package/dist/executor/acp/AcpClient.d.ts +5 -0
  25. package/dist/executor/acp/AcpClient.d.ts.map +1 -1
  26. package/dist/executor/acp/AcpClient.js +19 -1
  27. package/dist/executor/acp/AcpClient.js.map +1 -1
  28. package/dist/executor/agy/AgyAcpRuntime.d.ts +82 -0
  29. package/dist/executor/agy/AgyAcpRuntime.d.ts.map +1 -0
  30. package/dist/executor/agy/AgyAcpRuntime.js +390 -0
  31. package/dist/executor/agy/AgyAcpRuntime.js.map +1 -0
  32. package/dist/executor/index.d.ts.map +1 -1
  33. package/dist/executor/index.js +2 -1
  34. package/dist/executor/index.js.map +1 -1
  35. package/dist/files/FileInbox.d.ts +1 -0
  36. package/dist/files/FileInbox.d.ts.map +1 -1
  37. package/dist/files/FileInbox.js +49 -4
  38. package/dist/files/FileInbox.js.map +1 -1
  39. package/dist/index.js +2 -0
  40. package/dist/index.js.map +1 -1
  41. package/dist/maintenance/release-notes.json +1 -1
  42. package/dist/managed/tools.d.ts +2 -2
  43. package/dist/scheduling/ScheduleCapabilities.d.ts +4 -4
  44. package/dist/scheduling/ScheduleCapabilities.d.ts.map +1 -1
  45. package/dist/scheduling/ScheduleCapabilities.js +6 -6
  46. package/dist/scheduling/ScheduleCapabilities.js.map +1 -1
  47. package/dist/scheduling/ScheduleCleanup.js +1 -1
  48. package/dist/scheduling/ScheduleCleanup.js.map +1 -1
  49. package/dist/scheduling/ScheduleCommand.d.ts +1 -0
  50. package/dist/scheduling/ScheduleCommand.d.ts.map +1 -1
  51. package/dist/scheduling/ScheduleCommand.js +9 -3
  52. package/dist/scheduling/ScheduleCommand.js.map +1 -1
  53. package/dist/scheduling/ScheduleService.d.ts +27 -1
  54. package/dist/scheduling/ScheduleService.d.ts.map +1 -1
  55. package/dist/scheduling/ScheduleService.js +235 -51
  56. package/dist/scheduling/ScheduleService.js.map +1 -1
  57. package/dist/scheduling/ScheduleToolScope.d.ts.map +1 -1
  58. package/dist/scheduling/ScheduleToolScope.js +12 -2
  59. package/dist/scheduling/ScheduleToolScope.js.map +1 -1
  60. package/dist/scheduling/agy/AgyCheckpoint.d.ts +35 -0
  61. package/dist/scheduling/agy/AgyCheckpoint.d.ts.map +1 -0
  62. package/dist/scheduling/agy/AgyCheckpoint.js +160 -0
  63. package/dist/scheduling/agy/AgyCheckpoint.js.map +1 -0
  64. package/dist/scheduling/agy/AgyHookRelay.d.ts +33 -0
  65. package/dist/scheduling/agy/AgyHookRelay.d.ts.map +1 -0
  66. package/dist/scheduling/agy/AgyHookRelay.js +274 -0
  67. package/dist/scheduling/agy/AgyHookRelay.js.map +1 -0
  68. package/dist/scheduling/agy/AgyScheduleHost.d.ts +42 -0
  69. package/dist/scheduling/agy/AgyScheduleHost.d.ts.map +1 -0
  70. package/dist/scheduling/agy/AgyScheduleHost.js +121 -0
  71. package/dist/scheduling/agy/AgyScheduleHost.js.map +1 -0
  72. package/dist/scheduling/agy/AgySessionSchedules.d.ts +109 -0
  73. package/dist/scheduling/agy/AgySessionSchedules.d.ts.map +1 -0
  74. package/dist/scheduling/agy/AgySessionSchedules.js +476 -0
  75. package/dist/scheduling/agy/AgySessionSchedules.js.map +1 -0
  76. package/dist/scheduling/agy/hookClient.d.ts +4 -0
  77. package/dist/scheduling/agy/hookClient.d.ts.map +1 -0
  78. package/dist/scheduling/agy/hookClient.js +62 -0
  79. package/dist/scheduling/agy/hookClient.js.map +1 -0
  80. package/dist/scheduling/agy/transcript.d.ts +36 -0
  81. package/dist/scheduling/agy/transcript.d.ts.map +1 -0
  82. package/dist/scheduling/agy/transcript.js +108 -0
  83. package/dist/scheduling/agy/transcript.js.map +1 -0
  84. package/dist/scheduling/claude/ClaudeSessionSchedules.d.ts +7 -0
  85. package/dist/scheduling/claude/ClaudeSessionSchedules.d.ts.map +1 -1
  86. package/dist/scheduling/claude/ClaudeSessionSchedules.js +157 -59
  87. package/dist/scheduling/claude/ClaudeSessionSchedules.js.map +1 -1
  88. package/dist/scheduling/toolContract.d.ts +1 -1
  89. package/dist/scheduling/toolContract.js +1 -1
  90. package/dist/scheduling/toolContract.js.map +1 -1
  91. package/dist/scheduling/types.d.ts +10 -2
  92. package/dist/scheduling/types.d.ts.map +1 -1
  93. package/dist/scheduling/types.js.map +1 -1
  94. package/dist/service/SessionHostSupervisor.d.ts +63 -0
  95. package/dist/service/SessionHostSupervisor.d.ts.map +1 -0
  96. package/dist/service/SessionHostSupervisor.js +323 -0
  97. package/dist/service/SessionHostSupervisor.js.map +1 -0
  98. package/dist/sessionHost/HostClient.d.ts +49 -0
  99. package/dist/sessionHost/HostClient.d.ts.map +1 -0
  100. package/dist/sessionHost/HostClient.js +101 -0
  101. package/dist/sessionHost/HostClient.js.map +1 -0
  102. package/dist/sessionHost/HostProtocol.d.ts +65 -0
  103. package/dist/sessionHost/HostProtocol.d.ts.map +1 -0
  104. package/dist/sessionHost/HostProtocol.js +78 -0
  105. package/dist/sessionHost/HostProtocol.js.map +1 -0
  106. package/dist/sessionHost/HostServer.d.ts +52 -0
  107. package/dist/sessionHost/HostServer.d.ts.map +1 -0
  108. package/dist/sessionHost/HostServer.js +413 -0
  109. package/dist/sessionHost/HostServer.js.map +1 -0
  110. package/dist/sessionHost/HostStore.d.ts +43 -0
  111. package/dist/sessionHost/HostStore.d.ts.map +1 -0
  112. package/dist/sessionHost/HostStore.js +206 -0
  113. package/dist/sessionHost/HostStore.js.map +1 -0
  114. package/dist/sessionHost/RetainedFrontend.d.ts +63 -0
  115. package/dist/sessionHost/RetainedFrontend.d.ts.map +1 -0
  116. package/dist/sessionHost/RetainedFrontend.js +244 -0
  117. package/dist/sessionHost/RetainedFrontend.js.map +1 -0
  118. package/dist/sessionHost/RetainedHostLauncher.d.ts +25 -0
  119. package/dist/sessionHost/RetainedHostLauncher.d.ts.map +1 -0
  120. package/dist/sessionHost/RetainedHostLauncher.js +132 -0
  121. package/dist/sessionHost/RetainedHostLauncher.js.map +1 -0
  122. package/dist/sessionHost/RetainedRuntime.d.ts +62 -0
  123. package/dist/sessionHost/RetainedRuntime.d.ts.map +1 -0
  124. package/dist/sessionHost/RetainedRuntime.js +478 -0
  125. package/dist/sessionHost/RetainedRuntime.js.map +1 -0
  126. package/dist/sessionHost/RuntimeJournal.d.ts +47 -0
  127. package/dist/sessionHost/RuntimeJournal.d.ts.map +1 -0
  128. package/dist/sessionHost/RuntimeJournal.js +103 -0
  129. package/dist/sessionHost/RuntimeJournal.js.map +1 -0
  130. package/dist/sessionHost/entry.d.ts +13 -0
  131. package/dist/sessionHost/entry.d.ts.map +1 -0
  132. package/dist/sessionHost/entry.js +107 -0
  133. package/dist/sessionHost/entry.js.map +1 -0
  134. package/dist/thread/ThreadManager.d.ts.map +1 -1
  135. package/dist/thread/ThreadManager.js +33 -0
  136. package/dist/thread/ThreadManager.js.map +1 -1
  137. package/dist/types/ScheduleCards.d.ts +1 -1
  138. package/dist/types/ScheduleCards.d.ts.map +1 -1
  139. package/dist/update/AutomaticUpdater.d.ts +2 -1
  140. package/dist/update/AutomaticUpdater.d.ts.map +1 -1
  141. package/dist/update/AutomaticUpdater.js +26 -12
  142. package/dist/update/AutomaticUpdater.js.map +1 -1
  143. package/dist/update/PinnedHostBundle.d.ts +49 -0
  144. package/dist/update/PinnedHostBundle.d.ts.map +1 -0
  145. package/dist/update/PinnedHostBundle.js +309 -0
  146. package/dist/update/PinnedHostBundle.js.map +1 -0
  147. package/native/prebuilds/darwin-arm64/managed_native.node +0 -0
  148. package/native/prebuilds/darwin-arm64/manifest.json +1 -1
  149. package/native/prebuilds/darwin-x64/managed_native.node +0 -0
  150. package/native/prebuilds/darwin-x64/manifest.json +1 -1
  151. package/native/prebuilds/win32-arm64/managed_native.node +0 -0
  152. package/native/prebuilds/win32-arm64/manifest.json +1 -1
  153. package/native/prebuilds/win32-x64/managed_native.node +0 -0
  154. package/native/prebuilds/win32-x64/manifest.json +1 -1
  155. package/package.json +1 -1
@@ -39,8 +39,9 @@ export declare class MessageHandler {
39
39
  private readonly abortOperations;
40
40
  private readonly pendingGoalActivations;
41
41
  private automaticUpdateInProgress;
42
+ private readonly automaticUpdateScheduleThreads;
43
+ private automaticUpdateFailed;
42
44
  private automaticUpdateRecovering;
43
- private automaticUpdateRecoveryPending;
44
45
  private approvalCardsSupported;
45
46
  private streamingContextSupported;
46
47
  private delegationProgressSupported;
@@ -87,9 +88,12 @@ export declare class MessageHandler {
87
88
  * Handle message (supports new IncomingMessage format)
88
89
  */
89
90
  handleMessage(message: Message | IncomingMessage): Promise<void>;
91
+ private scheduleContextFenced;
92
+ private releaseSettledUpdateFences;
90
93
  tryBeginAutomaticUpdate(): boolean;
91
94
  prepareAutomaticUpdate(): Promise<void>;
92
- endAutomaticUpdate(): Promise<void>;
95
+ endAutomaticUpdate(failed?: boolean): Promise<void>;
96
+ private restoreAfterAutomaticUpdate;
93
97
  /**
94
98
  * Handle command message — route to the correct thread executor.
95
99
  */
@@ -1 +1 @@
1
- {"version":3,"file":"MessageHandler.d.ts","sourceRoot":"","sources":["../../src/client/MessageHandler.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAQpD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAgK,MAAM,UAAU,CAAC;AACzM,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAOxD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAqIxD;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAsBD,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,mBAAmB,CAA4B;IACvD,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,eAAe,CAA0C;IACjE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAsC;IACnE,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAA+C;IACzF,OAAO,CAAC,QAAQ,CAAC,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O,CAAC,cAAc;IAgBtB,OAAO,CAAC,sBAAsB;IAyB9B,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,oBAAoB;IAe5B,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,SAAS;IAiBjB,OAAO,CAAC,qBAAqB;IAmB7B,OAAO,CAAC,YAAY;IA+DpB,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,iBAAiB;IASzB,uFAAuF;IACjF,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAa7C,0FAA0F;YAC5E,gBAAgB;IAmC9B,OAAO,CAAC,mBAAmB;YA4Gb,eAAe;YASf,4BAA4B;YAgB5B,mBAAmB;IAQjC,OAAO,CAAC,yBAAyB;IAOjC,OAAO,CAAC,uBAAuB;IAc/B,qGAAqG;YACvF,oBAAoB;IAyGlC;sEACkE;YACpD,gBAAgB;IA6D9B;gFAC4E;YAC9D,wBAAwB;YAiExB,qBAAqB;IA8EnC,8EAA8E;YAChE,sBAAsB;IAepC,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,gBAAgB;IAYxB,uFAAuF;YACzE,sBAAsB;IAsBpC,mFAAmF;YACrE,eAAe;YAuDf,mBAAmB;IA2BjC,OAAO,CAAC,YAAY;YAUN,cAAc;YAuBd,oBAAoB;IAgHlC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAoD/B"}
@@ -62,6 +62,7 @@ const ScheduleService_1 = require("../scheduling/ScheduleService");
62
62
  const ScheduleDeliveryClient_1 = require("../scheduling/ScheduleDeliveryClient");
63
63
  const ScheduleCommand_1 = require("../scheduling/ScheduleCommand");
64
64
  const ScheduleCapabilities_1 = require("../scheduling/ScheduleCapabilities");
65
+ const types_2 = require("../scheduling/types");
65
66
  const ClaudeSandbox_1 = require("../executor/claude/ClaudeSandbox");
66
67
  const EFFORT_BACKENDS = new Set(['claude', 'codex', 'agy', 'opencode', 'kimi', 'zcode', 'pi', 'dsh']);
67
68
  const SLASH_SESSION_BACKENDS = new Set(['opencode', 'kimi', 'zcode', 'pi']);
@@ -167,7 +168,7 @@ class MessageHandler {
167
168
  threadName: threadId => this.threadManager.getThread(threadId)?.name,
168
169
  // Queued or pending work counts as busy: a confirmation must never redirect it into another session.
169
170
  isBusy: threadId => this.threadPool.isThreadBusy(threadId) || this.hasThreadQueueState(threadId)
170
- || this.abortOperations.has(threadId) || this.scheduleRecoveryThreads.has(threadId) || this.isDestroyed || this.automaticUpdateInProgress
171
+ || this.abortOperations.has(threadId) || this.scheduleContextFenced(threadId) || this.isDestroyed || this.automaticUpdateInProgress
171
172
  || this.delegation.hasActiveTasks(threadId) || this.settingsAdmission.hasCommand(threadId),
172
173
  setBusy: (threadId, busy) => {
173
174
  if (busy) {
@@ -193,8 +194,11 @@ class MessageHandler {
193
194
  abortOperations = new Map();
194
195
  pendingGoalActivations = new Map();
195
196
  automaticUpdateInProgress = false;
197
+ // Captured before native release starts. A rejected bounded waiter does not
198
+ // retire the underlying host operation or authorize changes to its context.
199
+ automaticUpdateScheduleThreads = new Map();
200
+ automaticUpdateFailed = false;
196
201
  automaticUpdateRecovering = false;
197
- automaticUpdateRecoveryPending = false;
198
202
  approvalCardsSupported = false;
199
203
  streamingContextSupported = false;
200
204
  delegationProgressSupported = false;
@@ -257,12 +261,12 @@ class MessageHandler {
257
261
  cancel: (owner, id) => this.schedules.cancel(owner, id),
258
262
  exclusive: async (owner, body) => {
259
263
  if (!this.schedules || this.isDestroyed || this.automaticUpdateInProgress
260
- || this.scheduleRecoveryThreads.has(owner.threadId) || this.scheduleManagement.has(owner.threadId))
264
+ || this.scheduleContextFenced(owner.threadId) || this.scheduleManagement.has(owner.threadId))
261
265
  throw new Error('Schedule controls are busy.');
262
266
  this.scheduleManagement.add(owner.threadId);
263
267
  try {
264
268
  const executor = this.threadPool.getExecutor(owner.threadId);
265
- if (this.threadPool.getBackendKey(owner.threadId) !== 'claude' || !executor.withNativeScheduleOperation
269
+ if (!['claude', 'agy'].includes(this.threadPool.getBackendKey(owner.threadId)) || !executor.withNativeScheduleOperation
266
270
  || !this.schedules.hasActiveSchedules(owner.threadId))
267
271
  return await body();
268
272
  const epoch = this.imageConnectionEpoch;
@@ -534,12 +538,39 @@ class MessageHandler {
534
538
  });
535
539
  }
536
540
  }
541
+ scheduleContextFenced(threadId) {
542
+ return this.scheduleRecoveryThreads.has(threadId) || this.automaticUpdateScheduleThreads.has(threadId);
543
+ }
544
+ releaseSettledUpdateFences() {
545
+ if (!this.automaticUpdateScheduleThreads.size || !this.schedules
546
+ || this.schedules.hasUnresolvedHandoff() || this.schedules.hasUnresolvedRecovery()
547
+ || this.schedules.hasPendingRecovery() || !this.schedules.canSuspendForRestart())
548
+ return;
549
+ for (const [threadId, generation] of this.automaticUpdateScheduleThreads) {
550
+ const executor = this.threadPool.getExistingExecutor(threadId);
551
+ try {
552
+ if (this.scheduleGeneration(threadId) !== generation || executor?.hasPendingScheduleMutation?.()
553
+ || executor?.hasUncertainShutdown?.())
554
+ return;
555
+ }
556
+ catch {
557
+ return;
558
+ }
559
+ }
560
+ this.automaticUpdateScheduleThreads.clear();
561
+ this.automaticUpdateFailed = false;
562
+ }
537
563
  tryBeginAutomaticUpdate() {
564
+ // Read-only readiness: never replay a release or a recovery just to retry an update.
565
+ this.releaseSettledUpdateFences();
538
566
  this.removeExpiredQueueConfirmations();
539
567
  const hasQueuedCommands = Array.from(this.threadQueues.values()).some((queue) => queue.length > 0);
540
568
  const hasRunningThread = this.threadPool.getSummaries().some((thread) => thread.status === 'running');
541
569
  if (this.automaticUpdateInProgress
542
570
  || this.isDestroyed
571
+ || this.automaticUpdateScheduleThreads.size > 0
572
+ || this.schedules?.hasUnresolvedHandoff() || this.schedules?.hasUnresolvedRecovery()
573
+ || this.schedules?.hasPendingRecovery()
543
574
  || this.scheduleRecoveryPending
544
575
  || this.wsClient.hasPendingTaskResults()
545
576
  || hasRunningThread
@@ -553,22 +584,54 @@ class MessageHandler {
553
584
  return false;
554
585
  }
555
586
  this.automaticUpdateInProgress = true;
587
+ this.automaticUpdateFailed = false;
556
588
  return true;
557
589
  }
558
590
  async prepareAutomaticUpdate() {
559
591
  if (!this.automaticUpdateInProgress || this.isDestroyed)
560
592
  throw new Error('Automatic update admission expired.');
561
- if (this.schedules?.hasActiveSchedules())
593
+ if (this.schedules?.hasActiveSchedules()) {
594
+ for (const thread of this.threadManager.listThreads()) {
595
+ if (this.schedules.hasActiveSchedules(thread.id)) {
596
+ this.automaticUpdateScheduleThreads.set(thread.id, this.scheduleGeneration(thread.id));
597
+ }
598
+ }
562
599
  await this.schedules.suspendForRestart();
600
+ }
563
601
  if (this.wsClient.hasPendingTaskResults())
564
602
  throw new Error('Result delivery remains pending.');
565
603
  }
566
- async endAutomaticUpdate() {
604
+ async endAutomaticUpdate(failed = false) {
605
+ try {
606
+ if (failed)
607
+ this.automaticUpdateFailed = true;
608
+ if (this.automaticUpdateFailed) {
609
+ this.releaseSettledUpdateFences();
610
+ if (this.automaticUpdateScheduleThreads.size || this.schedules?.hasUnresolvedHandoff()
611
+ || this.schedules?.hasUnresolvedRecovery() || this.schedules?.hasPendingRecovery()) {
612
+ throw new Error('Native schedule ownership remains unresolved; affected thread admission is retained.');
613
+ }
614
+ return;
615
+ }
616
+ await this.restoreAfterAutomaticUpdate();
617
+ this.automaticUpdateScheduleThreads.clear();
618
+ }
619
+ catch (error) {
620
+ this.automaticUpdateFailed = true;
621
+ throw error;
622
+ }
623
+ finally {
624
+ // The schedule service and exact affected contexts retain their own leases.
625
+ // Releasing this global lock never cancels or forgets a native operation.
626
+ this.automaticUpdateInProgress = false;
627
+ }
628
+ }
629
+ async restoreAfterAutomaticUpdate() {
567
630
  if (this.schedules?.hasUnresolvedHandoff())
568
- throw new Error('Native restart handoff remains unresolved; update admission is retained.');
631
+ throw new Error('Native restart handoff remains unresolved; affected thread admission is retained.');
569
632
  if (!this.schedules?.hasPendingRecovery()) {
570
633
  if (this.schedules?.hasUnresolvedRecovery())
571
- throw new Error('Native recovery remains blocked; update admission is retained.');
634
+ throw new Error('Native recovery remains blocked; affected thread admission is retained.');
572
635
  // Terminal-only handoffs still own the predecessor's local admission fence.
573
636
  // No job needs recreation, but the shared recovery finalizer must release it.
574
637
  if (this.schedules) {
@@ -580,23 +643,18 @@ class MessageHandler {
580
643
  this.automaticUpdateRecovering = false;
581
644
  }
582
645
  }
583
- this.automaticUpdateInProgress = false;
584
- this.automaticUpdateRecoveryPending = false;
585
646
  return;
586
647
  }
587
648
  if (this.isDestroyed)
588
649
  throw new Error('Shutdown already began; native schedules require startup recovery.');
589
650
  // Only finalization authorizes restoration. Reconnect during installation must
590
651
  // never restart native timing under the still-active installer.
591
- this.automaticUpdateRecoveryPending = true;
592
652
  this.automaticUpdateRecovering = true;
593
653
  try {
594
654
  await this.schedules.recover();
595
655
  if (this.schedules.hasUnresolvedRecovery()) {
596
- throw new Error('Native schedule restoration remains unresolved; update admission is retained.');
656
+ throw new Error('Native schedule restoration remains unresolved; affected thread admission is retained.');
597
657
  }
598
- this.automaticUpdateInProgress = false;
599
- this.automaticUpdateRecoveryPending = false;
600
658
  }
601
659
  finally {
602
660
  this.automaticUpdateRecovering = false;
@@ -608,15 +666,15 @@ class MessageHandler {
608
666
  async handleCommandMessage(message, fileOrder) {
609
667
  const threadId = message.threadId ?? this.threadManager.getDefaultThread().id;
610
668
  const content = message.content?.trim() ?? '';
611
- if (this.automaticUpdateInProgress && content === '/schedule list') {
669
+ if ((this.automaticUpdateInProgress || this.automaticUpdateScheduleThreads.has(threadId)) && content === '/schedule list') {
612
670
  this.messageOpenIds.set(message.messageId, message.openId);
613
671
  await this.handleScheduleCommand(message, threadId);
614
672
  return;
615
673
  }
616
- if (this.scheduleRecoveryThreads.has(threadId)
617
- || this.scheduleRecoveryThreads.size > 0 && /^\/backend\s/.test(content) && !/\s@$/.test(content)) {
674
+ if (this.scheduleContextFenced(threadId)
675
+ || (this.scheduleRecoveryThreads.size > 0 || this.automaticUpdateScheduleThreads.size > 0) && /^\/backend\s/.test(content) && !/\s@$/.test(content)) {
618
676
  this.sendResponse(message.messageId, threadId, { success: false,
619
- error: 'Native schedule recovery is in progress. Retry after reconciliation finishes.' });
677
+ error: 'Native schedule handoff or recovery is unresolved. Use /schedule list for stored status; conflicting operations remain fenced.' });
620
678
  return;
621
679
  }
622
680
  if (this.scheduleRecoveryPending && /^\/(?:clear|new|backend|cd|thread\s+delete)(?:\s|$)/.test(content)) {
@@ -741,9 +799,9 @@ class MessageHandler {
741
799
  return;
742
800
  }
743
801
  const resolvedThreadId = thread.id;
744
- if (this.scheduleRecoveryThreads.has(resolvedThreadId)) {
802
+ if (this.scheduleContextFenced(resolvedThreadId)) {
745
803
  this.sendResponse(messageId, resolvedThreadId, { success: false,
746
- error: 'Native schedule recovery is in progress for this thread. Retry after reconciliation finishes.' });
804
+ error: 'Native schedule handoff or recovery is unresolved for this thread. Use /schedule list for stored status.' });
747
805
  return;
748
806
  }
749
807
  if (this.automaticUpdateInProgress) {
@@ -1225,6 +1283,8 @@ class MessageHandler {
1225
1283
  const thread = this.threadManager.getThread(request.threadId);
1226
1284
  if (!thread)
1227
1285
  throw new Error('This Worker card has expired. Use the latest Worker card.');
1286
+ if (this.scheduleContextFenced(thread.id))
1287
+ throw new Error('Native schedule ownership remains unresolved for this thread.');
1228
1288
  await this.delegation.resetWorkerContext(thread, request.laneId, request.generation);
1229
1289
  }
1230
1290
  catch (cause) {
@@ -1821,7 +1881,7 @@ You can also use natural language commands to control Claude Code CLI.`,
1821
1881
  async startNextQueuedCommand(threadId) {
1822
1882
  if (this.settingsAdmission.isBlocked(threadId))
1823
1883
  return;
1824
- if (this.scheduleRecoveryThreads.has(threadId) || this.threadPool.isThreadBusy(threadId) || this.pausedQueues.has(threadId) || this.abortOperations.has(threadId))
1884
+ if (this.scheduleContextFenced(threadId) || this.threadPool.isThreadBusy(threadId) || this.pausedQueues.has(threadId) || this.abortOperations.has(threadId))
1825
1885
  return;
1826
1886
  const queue = this.threadQueues.get(threadId);
1827
1887
  const command = queue?.shift();
@@ -3485,14 +3545,21 @@ You can also use natural language commands to control Claude Code CLI.`,
3485
3545
  // create a late service/subscription after shutdown has collected its work.
3486
3546
  if (this.isDestroyed || !this.scheduleResultsSupported)
3487
3547
  return;
3548
+ if (this.automaticUpdateFailed && this.automaticUpdateScheduleThreads.size) {
3549
+ // Reconnect can retry durable delivery, but must not restart model-mediated
3550
+ // reconciliation after a failed update merely to reopen unrelated chat.
3551
+ await this.schedules?.retryDeliveries();
3552
+ return;
3553
+ }
3488
3554
  this.scheduleRecoveryPending = true;
3489
3555
  const service = await this.initializeSchedules();
3490
3556
  if (!this.isDestroyed && this.scheduleResultsSupported) {
3491
- if (this.automaticUpdateRecoveryPending && !this.automaticUpdateRecovering) {
3492
- await this.endAutomaticUpdate();
3557
+ if (this.automaticUpdateFailed && this.automaticUpdateScheduleThreads.size) {
3558
+ await service.retryDeliveries();
3559
+ this.scheduleRecoveryPending = false;
3560
+ return;
3493
3561
  }
3494
- else
3495
- await service.recover();
3562
+ await service.recover();
3496
3563
  await service.retryDeliveries();
3497
3564
  this.scheduleRecoveryPending = false;
3498
3565
  }
@@ -3565,24 +3632,32 @@ You can also use natural language commands to control Claude Code CLI.`,
3565
3632
  if (!context.isCurrent())
3566
3633
  throw new Error('Schedule recovery context changed.');
3567
3634
  return capability.reconcile(record, context, event => {
3568
- emit(event);
3635
+ const settled = emit(event);
3569
3636
  if (event.type === 'completed')
3570
3637
  queueMicrotask(() => { void this.startNextQueuedCommand(record.threadId); });
3638
+ return settled;
3571
3639
  });
3572
3640
  } };
3573
3641
  }, create: (input, onEvent, canAdmitOccurrence) => {
3574
3642
  const backend = input.backend === undefined ? 'claude' : input.backend;
3575
- (0, ScheduleCapabilities_1.assertNativeScheduleBackend)(backend);
3576
- if (!input.threadId)
3577
- throw new Error('Native scheduling requires the original thread.');
3578
- if (this.threadPool.getBackendKey(input.threadId) !== backend)
3579
- throw new Error('Foreground scheduling backend changed before native admission.');
3580
- const executor = this.threadPool.getExecutor(input.threadId);
3581
- if (!executor.createNativeSchedule)
3582
- throw new Error('The original executor does not support native session scheduling.');
3583
- const generation = this.scheduleGeneration(input.threadId);
3643
+ let executor;
3644
+ let generation;
3645
+ try {
3646
+ (0, ScheduleCapabilities_1.assertNativeScheduleBackend)(backend);
3647
+ if (!input.threadId)
3648
+ throw new Error('Native scheduling requires the original thread.');
3649
+ if (this.threadPool.getBackendKey(input.threadId) !== backend)
3650
+ throw new Error('Foreground scheduling backend changed before native admission.');
3651
+ executor = this.threadPool.getExecutor(input.threadId);
3652
+ if (!executor.createNativeSchedule)
3653
+ throw new Error('The original executor does not support native session scheduling.');
3654
+ generation = this.scheduleGeneration(input.threadId);
3655
+ }
3656
+ catch (error) {
3657
+ throw new types_2.NativeScheduleNotAdmittedError(error instanceof Error ? error.message : 'Native schedule provider refused admission.');
3658
+ }
3584
3659
  return executor.createNativeSchedule(input, event => {
3585
- onEvent(event);
3660
+ const settled = onEvent(event);
3586
3661
  // A foreground message confirmed into the thread queue while an
3587
3662
  // autonomous native occurrence was running must be retried when
3588
3663
  // that occurrence reaches a terminal state. The executor's own
@@ -3590,6 +3665,7 @@ You can also use natural language commands to control Claude Code CLI.`,
3590
3665
  if (event.type === 'completed' || (event.type === 'stopped' && event.exitConfirmed !== false)) {
3591
3666
  queueMicrotask(() => { void this.startNextQueuedCommand(input.threadId); });
3592
3667
  }
3668
+ return settled;
3593
3669
  }, () => {
3594
3670
  try {
3595
3671
  return !this.isDestroyed && this.scheduleGeneration(input.threadId) === generation
@@ -3656,6 +3732,8 @@ You can also use natural language commands to control Claude Code CLI.`,
3656
3732
  }
3657
3733
  }
3658
3734
  async assertSchedulesIdle(threadId, preserveCleanupContext = true) {
3735
+ if (this.scheduleContextFenced(threadId))
3736
+ throw new Error('Native schedule ownership remains unresolved for this thread.');
3659
3737
  if (preserveCleanupContext)
3660
3738
  await this.assertScheduleCleanupContext(threadId);
3661
3739
  if (this.scheduleManagement.has(threadId) || this.schedules?.hasActiveSchedules(threadId)) {
@@ -3698,7 +3776,7 @@ You can also use natural language commands to control Claude Code CLI.`,
3698
3776
  return false;
3699
3777
  }
3700
3778
  };
3701
- const check = () => { if (!current() || this.automaticUpdateInProgress || this.scheduleRecoveryThreads.has(owner.threadId))
3779
+ const check = () => { if (!current() || this.automaticUpdateInProgress || this.scheduleContextFenced(owner.threadId))
3702
3780
  throw new Error('Scheduling context changed or client is shutting down/updating/recovering.'); };
3703
3781
  check();
3704
3782
  if (command.kind === 'list' && this.threadPool.getExistingExecutor(owner.threadId)?.hasPendingCancellation?.()) {
@@ -3720,10 +3798,10 @@ You can also use natural language commands to control Claude Code CLI.`,
3720
3798
  throw new Error('This native scheduling adapter does not support restricted Claude sandboxes. No schedule was created and sandbox settings were not changed.');
3721
3799
  }
3722
3800
  }
3723
- const nativeCancellation = !nativeBound && backend === 'claude' && command.kind === 'cancel'
3801
+ const nativeCancellation = !nativeBound && (backend === 'claude' || backend === 'agy') && command.kind === 'cancel'
3724
3802
  && (await this.initializeSchedules()).canCancel(owner, command.id);
3725
3803
  check();
3726
- if (!nativeBound && backend === 'claude' && (command.kind === 'create' || nativeCancellation
3804
+ if (!nativeBound && (backend === 'claude' || backend === 'agy') && (command.kind === 'create' || nativeCancellation
3727
3805
  || command.kind !== 'cancel' && this.schedules?.hasActiveSchedules(owner.threadId))) {
3728
3806
  const executor = this.threadPool.getExecutor(owner.threadId);
3729
3807
  if (!executor.withNativeScheduleOperation)
@@ -3801,7 +3879,7 @@ You can also use natural language commands to control Claude Code CLI.`,
3801
3879
  }
3802
3880
  const record = await service.create(owner, { id, threadId: owner.threadId, backend, cwd, rule: command.rule, prompt: command.prompt,
3803
3881
  command: config[backend]?.command,
3804
- model: context ? context.model : thread.models?.[backend] ?? (backend === 'claude' ? thread.model || undefined : config.dsh?.model),
3882
+ model: context ? context.model : thread.models?.[backend] ?? (backend === 'claude' ? thread.model || undefined : config[backend]?.model),
3805
3883
  effort: context ? context.effort : thread.efforts?.[backend] });
3806
3884
  if (!current() && !nativeBound) {
3807
3885
  await service.cancel(owner, record.id);
@@ -3829,7 +3907,7 @@ You can also use natural language commands to control Claude Code CLI.`,
3829
3907
  try {
3830
3908
  return !this.isDestroyed && !this.automaticUpdateInProgress && this.wsClient.isConnected()
3831
3909
  && epoch === this.imageConnectionEpoch && this.scheduleGeneration(owner.threadId) === owner.generation
3832
- && !this.scheduleRecoveryThreads.has(owner.threadId) && !this.abortOperations.has(owner.threadId)
3910
+ && !this.scheduleContextFenced(owner.threadId) && !this.abortOperations.has(owner.threadId)
3833
3911
  && this.threadPool.getBackendKey(owner.threadId) === backend
3834
3912
  && this.threadPool.getExistingExecutor(owner.threadId) === executor
3835
3913
  && capturedSettings === settings() && (!inTurnCurrent || inTurnCurrent());
@@ -3854,11 +3932,14 @@ You can also use natural language commands to control Claude Code CLI.`,
3854
3932
  const run = async () => {
3855
3933
  if (!current())
3856
3934
  throw new Error('Schedule purge context changed before cleanup.');
3857
- const result = await service.purge(owner, { ids }, current);
3935
+ const result = await service.purge(owner, { ids,
3936
+ ...('forgetUnresolved' in selection && selection.forgetUnresolved ? { forgetUnresolved: true } : {}) }, current);
3858
3937
  if (result.removedIds.length)
3859
3938
  this.scheduleCards.invalidate();
3860
3939
  return result;
3861
3940
  };
3941
+ if ('forgetUnresolved' in selection && selection.forgetUnresolved)
3942
+ return await run();
3862
3943
  const records = await service.list(owner);
3863
3944
  const needsVerification = backend === 'claude' && !!executor.withReviewedNativeCleanup && (cleanup.some(item => ids.includes(item.id) && item.backend === 'claude' && !!item.attribution && !!item.nativeId) || records.some(record => ids.includes(record.id)
3864
3945
  && record.backend === 'claude' && !!record.recovery && !!record.nativeId && !record.cleanupConfirmed && !record.creationRefused && !['active', 'running', 'creating'].includes(record.state)));
@@ -3910,7 +3991,7 @@ You can also use natural language commands to control Claude Code CLI.`,
3910
3991
  const config = settings();
3911
3992
  const current = () => {
3912
3993
  try {
3913
- return !this.isDestroyed && !this.automaticUpdateInProgress && !this.scheduleRecoveryThreads.has(threadId)
3994
+ return !this.isDestroyed && !this.automaticUpdateInProgress && !this.scheduleContextFenced(threadId)
3914
3995
  && !this.abortOperations.has(threadId) && this.wsClient.isConnected() && epoch === this.imageConnectionEpoch
3915
3996
  && this.scheduleGeneration(threadId) === owner.generation && this.threadPool.getExistingExecutor(threadId) === executor
3916
3997
  && this.threadPool.getBackendKey(threadId) === 'claude' && config === settings() && (!inTurnCurrent || inTurnCurrent());
@@ -4024,6 +4105,8 @@ You can also use natural language commands to control Claude Code CLI.`,
4024
4105
  const result = await this.runSchedulePurge(owner, command.selection, (0, crypto_1.createHash)('sha256').update(message.messageId ?? (0, uuid_1.v4)()).digest('hex'));
4025
4106
  const lines = [`Removed history: ${result.removedIds.join(', ') || 'none'}.`,
4026
4107
  `Already removed: ${result.alreadyRemovedIds.join(', ') || 'none'}.`,
4108
+ ...(result.forgottenCleanupIds ? [`Forgotten cleanup tracking: ${result.forgottenCleanupIds.join(', ') || 'none'}.`] : []),
4109
+ ...(result.warning ? [result.warning] : []),
4027
4110
  ...result.nativeCleanupUnresolved.map(entry => `Native cleanup unresolved ${entry.id} (${entry.reason}): ${entry.detail}`),
4028
4111
  ...result.pending.map(entry => `Pending ${entry.id}: ${entry.detail}`),
4029
4112
  ...result.errors.map(entry => `Failed ${entry.id}: ${entry.error}`)];
@@ -4034,7 +4117,7 @@ You can also use natural language commands to control Claude Code CLI.`,
4034
4117
  return;
4035
4118
  }
4036
4119
  const storedOnly = command.kind === 'list' && this.threadPool.getExistingExecutor(threadId)?.hasPendingCancellation?.();
4037
- const updateSnapshot = this.automaticUpdateInProgress && command.kind === 'list';
4120
+ const updateSnapshot = (this.automaticUpdateInProgress || this.automaticUpdateScheduleThreads.has(threadId)) && command.kind === 'list';
4038
4121
  const records = updateSnapshot ? await this.schedules?.list(owner) ?? []
4039
4122
  : await this.runScheduleOperation(owner, command.kind === 'list' ? { kind: 'list' } : command);
4040
4123
  const record = records[0];
@@ -4045,9 +4128,10 @@ You can also use natural language commands to control Claude Code CLI.`,
4045
4128
  output = `Schedule ${record.id}: ${record.state}.`;
4046
4129
  else {
4047
4130
  const lifecycle = record.recovery
4048
- ? `Managed jobs recover automatically after a confirmed orderly restart. Dirty shutdowns remain blocked. ${record.recovery.handoffPolicy === 'skip-unadmitted'
4049
- ? 'Fired occurrences not yet admitted to execution may be skipped without replay; admitted work must finish.'
4050
- : 'Queued and executing occurrences must finish before handoff.'}`
4131
+ ? record.backend === 'agy' ? 'AGY recovery requires exact host retirement before every possible first wake and no unknown queued work. Eligible future definitions recover in the original conversation; due work and dirty shutdowns remain blocked.'
4132
+ : `Managed jobs recover automatically after a confirmed orderly restart. Dirty shutdowns remain blocked. ${record.recovery.handoffPolicy === 'skip-unadmitted'
4133
+ ? 'Fired occurrences not yet admitted to execution may be skipped without replay; admitted work must finish.'
4134
+ : 'Queued and executing occurrences must finish before handoff.'}`
4051
4135
  : 'This host does not support automatic schedule recovery after process exit.';
4052
4136
  output = `Schedule ${record.id}: ${record.state}.\n${record.rule.kind === 'once' ? record.rule.at : `${record.rule.expression} (${record.rule.timezone})`}\n\nRuns in this thread's foreground ${ScheduleCapabilities_1.NATIVE_SCHEDULE_CAPABILITIES[record.backend].label} conversation and returns results here. Keep the CLI running; native timing is approximate. ${lifecycle}\nUse /schedule list or /schedule cancel ${record.id}.`;
4053
4137
  }
@@ -4100,7 +4184,7 @@ You can also use natural language commands to control Claude Code CLI.`,
4100
4184
  revision: (0, crypto_1.createHash)('sha256').update(JSON.stringify({ thread: projection(thread), all, config: this.executorConfiguration() })).digest('hex') };
4101
4185
  }
4102
4186
  settingsBusy(threadId, exceptRequest, includeQueue = true, setting) {
4103
- return this.isDestroyed || this.automaticUpdateInProgress || this.scheduleRecoveryThreads.has(threadId) || (setting === 'model' ? this.threadPool.isThreadBusy(threadId, 'model') : this.threadPool.isThreadBusy(threadId))
4187
+ return this.isDestroyed || this.automaticUpdateInProgress || this.scheduleContextFenced(threadId) || (setting === 'model' ? this.threadPool.isThreadBusy(threadId, 'model') : this.threadPool.isThreadBusy(threadId))
4104
4188
  || this.delegation.hasActiveTasks(threadId) || this.abortOperations.has(threadId)
4105
4189
  || this.coordinatorPreparations.has(threadId) || this.settingsAdmission.hasCommand(threadId, exceptRequest) || (includeQueue && this.hasThreadQueueState(threadId));
4106
4190
  }
@@ -4225,6 +4309,8 @@ You can also use natural language commands to control Claude Code CLI.`,
4225
4309
  async applyBackendSetting(threadId, backend, scope, followGlobal = false) {
4226
4310
  try {
4227
4311
  for (const thread of scope === 'all' ? this.threadManager.listThreads() : [{ id: threadId }]) {
4312
+ if (this.scheduleContextFenced(thread.id))
4313
+ throw new Error('Native schedule ownership remains unresolved for an affected thread.');
4228
4314
  this.threadManager.contextResets.assertReady(thread.id);
4229
4315
  }
4230
4316
  if (followGlobal) {
@@ -4410,6 +4496,16 @@ You can also use natural language commands to control Claude Code CLI.`,
4410
4496
  // Native recovery handoff must finish before executor destruction can stop
4411
4497
  // its original host. An uncertain handoff keeps that host owned for retry.
4412
4498
  await this.scheduleInitialization?.then(service => service.requiresShutdownHandoff() ? service.destroy() : undefined, () => undefined);
4499
+ // Uncheckpointed AGY work has no queue-drain contract. Retire its exact owned
4500
+ // group before the catalog asks a handle to stop; never race a management
4501
+ // prompt against host teardown or mistake definition deletion for retirement.
4502
+ // Teardown uses stored backend summaries, not execution admission. A
4503
+ // corrupt reset generation must still block execution, but not host exit.
4504
+ for (const thread of this.threadPool.getSummaries()) {
4505
+ if (thread.backend === 'agy') {
4506
+ await this.threadPool.getExistingExecutor(thread.id)?.destroy();
4507
+ }
4508
+ }
4413
4509
  const results = await Promise.allSettled([
4414
4510
  this.scheduleInitialization?.then(service => service.destroy(), () => undefined),
4415
4511
  this.delegation.destroy(),