@yu_robotics/remote-cli 1.6.264 → 1.6.266

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 (133) hide show
  1. package/README.md +41 -0
  2. package/dist/client/MessageHandler.d.ts +13 -2
  3. package/dist/client/MessageHandler.d.ts.map +1 -1
  4. package/dist/client/MessageHandler.js +393 -172
  5. package/dist/client/MessageHandler.js.map +1 -1
  6. package/dist/client/WebSocketClient.d.ts.map +1 -1
  7. package/dist/client/WebSocketClient.js +1 -0
  8. package/dist/client/WebSocketClient.js.map +1 -1
  9. package/dist/delegation/piExtension.js +1 -1
  10. package/dist/delegation/piExtension.js.map +1 -1
  11. package/dist/executor/AcpExecutor.d.ts +11 -4
  12. package/dist/executor/AcpExecutor.d.ts.map +1 -1
  13. package/dist/executor/AcpExecutor.js +64 -11
  14. package/dist/executor/AcpExecutor.js.map +1 -1
  15. package/dist/executor/AgyExecutor.d.ts +6 -0
  16. package/dist/executor/AgyExecutor.d.ts.map +1 -1
  17. package/dist/executor/AgyExecutor.js +126 -9
  18. package/dist/executor/AgyExecutor.js.map +1 -1
  19. package/dist/executor/ClaudePersistentExecutor.d.ts +5 -1
  20. package/dist/executor/ClaudePersistentExecutor.d.ts.map +1 -1
  21. package/dist/executor/ClaudePersistentExecutor.js +81 -17
  22. package/dist/executor/ClaudePersistentExecutor.js.map +1 -1
  23. package/dist/executor/CodexAppServerClient.d.ts +1 -1
  24. package/dist/executor/CodexAppServerClient.d.ts.map +1 -1
  25. package/dist/executor/CodexAppServerClient.js +8 -2
  26. package/dist/executor/CodexAppServerClient.js.map +1 -1
  27. package/dist/executor/CodexAppServerExecutor.d.ts +3 -1
  28. package/dist/executor/CodexAppServerExecutor.d.ts.map +1 -1
  29. package/dist/executor/CodexAppServerExecutor.js +67 -22
  30. package/dist/executor/CodexAppServerExecutor.js.map +1 -1
  31. package/dist/executor/DshExecutor.d.ts +2 -0
  32. package/dist/executor/DshExecutor.d.ts.map +1 -1
  33. package/dist/executor/DshExecutor.js +26 -6
  34. package/dist/executor/DshExecutor.js.map +1 -1
  35. package/dist/executor/IExecutor.d.ts +4 -0
  36. package/dist/executor/IExecutor.d.ts.map +1 -1
  37. package/dist/executor/PiExecutor.d.ts +2 -0
  38. package/dist/executor/PiExecutor.d.ts.map +1 -1
  39. package/dist/executor/PiExecutor.js +96 -23
  40. package/dist/executor/PiExecutor.js.map +1 -1
  41. package/dist/executor/acp/AcpClient.d.ts +4 -3
  42. package/dist/executor/acp/AcpClient.d.ts.map +1 -1
  43. package/dist/executor/acp/AcpClient.js +18 -2
  44. package/dist/executor/acp/AcpClient.js.map +1 -1
  45. package/dist/executor/agy/AgyAcpRuntime.d.ts +8 -1
  46. package/dist/executor/agy/AgyAcpRuntime.d.ts.map +1 -1
  47. package/dist/executor/agy/AgyAcpRuntime.js +47 -3
  48. package/dist/executor/agy/AgyAcpRuntime.js.map +1 -1
  49. package/dist/executor/agy/AgySessionSelection.d.ts +3 -0
  50. package/dist/executor/agy/AgySessionSelection.d.ts.map +1 -1
  51. package/dist/executor/agy/AgySessionSelection.js +24 -0
  52. package/dist/executor/agy/AgySessionSelection.js.map +1 -1
  53. package/dist/executor/dsh/DshAcpClient.d.ts +1 -1
  54. package/dist/executor/dsh/DshAcpClient.d.ts.map +1 -1
  55. package/dist/executor/dsh/DshAcpClient.js +2 -2
  56. package/dist/executor/dsh/DshAcpClient.js.map +1 -1
  57. package/dist/executor/pi/PiClient.d.ts +3 -1
  58. package/dist/executor/pi/PiClient.d.ts.map +1 -1
  59. package/dist/executor/pi/PiClient.js +15 -1
  60. package/dist/executor/pi/PiClient.js.map +1 -1
  61. package/dist/executor/pi/PiTypes.d.ts +3 -1
  62. package/dist/executor/pi/PiTypes.d.ts.map +1 -1
  63. package/dist/executor/pi/PiTypes.js.map +1 -1
  64. package/dist/executor/zcode/ZCodeClient.d.ts +2 -2
  65. package/dist/executor/zcode/ZCodeClient.d.ts.map +1 -1
  66. package/dist/executor/zcode/ZCodeClient.js +26 -7
  67. package/dist/executor/zcode/ZCodeClient.js.map +1 -1
  68. package/dist/maintenance/release-notes.json +1 -1
  69. package/dist/managed/tools.d.ts +6 -6
  70. package/dist/scheduling/ScheduleCapabilities.d.ts +59 -14
  71. package/dist/scheduling/ScheduleCapabilities.d.ts.map +1 -1
  72. package/dist/scheduling/ScheduleCapabilities.js +33 -29
  73. package/dist/scheduling/ScheduleCapabilities.js.map +1 -1
  74. package/dist/scheduling/ScheduleCardService.d.ts.map +1 -1
  75. package/dist/scheduling/ScheduleCardService.js +3 -1
  76. package/dist/scheduling/ScheduleCardService.js.map +1 -1
  77. package/dist/scheduling/ScheduleCleanup.d.ts +3 -2
  78. package/dist/scheduling/ScheduleCleanup.d.ts.map +1 -1
  79. package/dist/scheduling/ScheduleCleanup.js +3 -0
  80. package/dist/scheduling/ScheduleCleanup.js.map +1 -1
  81. package/dist/scheduling/ScheduleCommand.d.ts +1 -3
  82. package/dist/scheduling/ScheduleCommand.d.ts.map +1 -1
  83. package/dist/scheduling/ScheduleCommand.js +10 -62
  84. package/dist/scheduling/ScheduleCommand.js.map +1 -1
  85. package/dist/scheduling/ScheduleDeliveryClient.d.ts +2 -1
  86. package/dist/scheduling/ScheduleDeliveryClient.d.ts.map +1 -1
  87. package/dist/scheduling/ScheduleDeliveryClient.js +20 -8
  88. package/dist/scheduling/ScheduleDeliveryClient.js.map +1 -1
  89. package/dist/scheduling/ScheduleService.d.ts +48 -4
  90. package/dist/scheduling/ScheduleService.d.ts.map +1 -1
  91. package/dist/scheduling/ScheduleService.js +582 -73
  92. package/dist/scheduling/ScheduleService.js.map +1 -1
  93. package/dist/scheduling/ScheduleToolScope.d.ts +4 -1
  94. package/dist/scheduling/ScheduleToolScope.d.ts.map +1 -1
  95. package/dist/scheduling/ScheduleToolScope.js +14 -13
  96. package/dist/scheduling/ScheduleToolScope.js.map +1 -1
  97. package/dist/scheduling/agy/AgyHookRelay.d.ts +3 -0
  98. package/dist/scheduling/agy/AgyHookRelay.d.ts.map +1 -1
  99. package/dist/scheduling/agy/AgyHookRelay.js +15 -1
  100. package/dist/scheduling/agy/AgyHookRelay.js.map +1 -1
  101. package/dist/scheduling/claude/ClaudeScheduleOwnership.d.ts +2 -0
  102. package/dist/scheduling/claude/ClaudeScheduleOwnership.d.ts.map +1 -1
  103. package/dist/scheduling/claude/ClaudeScheduleOwnership.js +11 -0
  104. package/dist/scheduling/claude/ClaudeScheduleOwnership.js.map +1 -1
  105. package/dist/scheduling/claude/ClaudeSessionSchedules.d.ts +3 -2
  106. package/dist/scheduling/claude/ClaudeSessionSchedules.d.ts.map +1 -1
  107. package/dist/scheduling/claude/ClaudeSessionSchedules.js +12 -4
  108. package/dist/scheduling/claude/ClaudeSessionSchedules.js.map +1 -1
  109. package/dist/scheduling/dsh/ScheduledSessionGuard.js +1 -1
  110. package/dist/scheduling/dsh/ScheduledSessionGuard.js.map +1 -1
  111. package/dist/scheduling/host/HostScheduleRule.d.ts +6 -0
  112. package/dist/scheduling/host/HostScheduleRule.d.ts.map +1 -0
  113. package/dist/scheduling/host/HostScheduleRule.js +144 -0
  114. package/dist/scheduling/host/HostScheduleRule.js.map +1 -0
  115. package/dist/scheduling/toolContract.d.ts +3 -3
  116. package/dist/scheduling/toolContract.js +4 -4
  117. package/dist/scheduling/toolContract.js.map +1 -1
  118. package/dist/scheduling/types.d.ts +20 -2
  119. package/dist/scheduling/types.d.ts.map +1 -1
  120. package/dist/scheduling/types.js.map +1 -1
  121. package/dist/types/ScheduleCards.d.ts +2 -1
  122. package/dist/types/ScheduleCards.d.ts.map +1 -1
  123. package/dist/types/index.d.ts +2 -0
  124. package/dist/types/index.d.ts.map +1 -1
  125. package/native/prebuilds/darwin-arm64/managed_native.node +0 -0
  126. package/native/prebuilds/darwin-arm64/manifest.json +1 -1
  127. package/native/prebuilds/darwin-x64/managed_native.node +0 -0
  128. package/native/prebuilds/darwin-x64/manifest.json +1 -1
  129. package/native/prebuilds/win32-arm64/managed_native.node +0 -0
  130. package/native/prebuilds/win32-arm64/manifest.json +1 -1
  131. package/native/prebuilds/win32-x64/managed_native.node +0 -0
  132. package/native/prebuilds/win32-x64/manifest.json +1 -1
  133. package/package.json +1 -1
@@ -102,11 +102,25 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
102
102
  }
103
103
  abortStatusMessage() { return this.lastAbortMessage; }
104
104
  hasPendingScheduleMutation() { return this.sessionSchedules?.cleanupMutationPending ?? false; }
105
+ checkHostScheduleSession(id) {
106
+ if (!id || this.sessionId !== id || this.delegationWorker || this.isDestroyed || this.isStopping
107
+ || this.abortOperation || this.retainedAbort || this.modelChange || this.hasUncertainShutdown()
108
+ || this.scheduleCleanupHost || this.reviewedCleanupActive || this.currentScheduleManagement
109
+ || this.sessionSchedules?.hasJobs || this.sessionSchedules?.hasPendingMutation || this.sessionSchedules?.busy
110
+ || this.claudeProcess && (this.turnLedger.invalid || this.turnLedger.session && this.turnLedger.session !== id)
111
+ || this.scheduleHostOwnership().exists()) {
112
+ throw new Error('The original Claude conversation is unavailable or has unresolved native work.');
113
+ }
114
+ if (JSON.parse(fs_1.default.readFileSync(this.sessionFilePath, 'utf8')).id !== id) {
115
+ throw new Error('The saved Claude conversation changed.');
116
+ }
117
+ }
105
118
  hasPendingCancellation() { return !!this.retainedAbort; }
106
119
  isStopping = false; // Flag to indicate intentional process stop
107
120
  isSessionError = false; // Flag to suppress auto-restart on session-not-found errors
108
121
  sessionResumeFailure = false;
109
122
  currentObjectiveDispatched = false;
123
+ currentHostScheduleSession;
110
124
  lastStderrOutput = ''; // Last process stderr, available in 'close' handler
111
125
  commandQueue = [];
112
126
  isProcessing = false;
@@ -356,13 +370,15 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
356
370
  const timezone = await this.readNativeScheduleTimezone();
357
371
  if (!current())
358
372
  throw new Error('Native cancellation host changed.');
359
- await this.schedules().cancelRetained({ id: record.id, threadId: record.threadId, backend: 'claude',
373
+ const inventoryEmpty = await this.schedules().cancelRetained({ id: record.id, threadId: record.threadId, backend: 'claude',
360
374
  cwd: record.cwd, prompt: record.prompt, rule: record.rule, recovery: record.recovery }, record.nativeId, current, timezone);
361
375
  if (!current())
362
376
  throw new Error('Native cancellation host changed after deletion.');
363
377
  if (!predecessorConfirmed || !ownership.cancellationProof(identity.ownerToken)) {
364
378
  throw new Error('Owned future definition is absent on the current host, but predecessor work remains unconfirmed in this boot. Cancellation intent is retained; do not recreate the job. Review predecessor ownership before claiming complete cleanup.');
365
379
  }
380
+ if (inventoryEmpty)
381
+ ownership.retireAfterReboot();
366
382
  },
367
383
  describe: input => JSON.stringify({ marker: (0, crypto_1.randomUUID)(), sessionId: this.sessionId,
368
384
  cwd: input.cwd, threadId: this.threadId, model: this.model, effort: this.effort,
@@ -518,8 +534,18 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
518
534
  }
519
535
  return this.ownedScheduleHandle(await this.schedules().create(input, onEvent, isOwnerCurrent, timezone, canAdmitOccurrence), input);
520
536
  }
521
- /** Inspect only the effective TZ; never log, retain, or expose settings to a model. */
522
- readNativeScheduleTimezone() {
537
+ async readNativeScheduleTimezone() {
538
+ const timezone = await this.readScheduleHookPolicy() ?? this.nativeScheduleTimezone;
539
+ if (typeof timezone === 'string' && timezone.length <= 128 && timezone) {
540
+ try {
541
+ return new Intl.DateTimeFormat('en', { timeZone: timezone }).resolvedOptions().timeZone;
542
+ }
543
+ catch { /* Native Cron needs a valid timezone. */ }
544
+ }
545
+ throw new types_1.NativeScheduleNotAdmittedError('Native session timezone could not be verified. No schedule was created.');
546
+ }
547
+ /** Only native Cron callers need the optional timezone from this control reply. */
548
+ readScheduleHookPolicy() {
523
549
  const child = this.claudeProcess;
524
550
  if (!child?.stdin?.writable)
525
551
  return Promise.reject(new types_1.NativeScheduleNotAdmittedError('Native conversation is unavailable.'));
@@ -543,7 +569,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
543
569
  }
544
570
  try {
545
571
  const response = value;
546
- if (!response?.effective || typeof response.effective !== 'object') {
572
+ if (!response?.effective || typeof response.effective !== 'object' || Array.isArray(response.effective)) {
547
573
  failure();
548
574
  return;
549
575
  }
@@ -551,12 +577,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
551
577
  reject(new types_1.NativeScheduleNotAdmittedError('Native scheduling requires active SDK callback hooks. Native hook policy was not changed.'));
552
578
  return;
553
579
  }
554
- const timezone = response.effective.env?.TZ ?? this.nativeScheduleTimezone;
555
- if (typeof timezone !== 'string' || !timezone || timezone.length > 128) {
556
- failure();
557
- return;
558
- }
559
- resolve(new Intl.DateTimeFormat('en', { timeZone: timezone }).resolvedOptions().timeZone);
580
+ resolve(response.effective.env?.TZ);
560
581
  }
561
582
  catch {
562
583
  failure();
@@ -663,9 +684,9 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
663
684
  // when the original CronCreate used durable:false. Scheduling hosts need
664
685
  // bootstrap admission hooks; every other launch disables the native Cron
665
686
  // feature itself rather than relying on a scheduler preference setting.
666
- const managedScheduling = !this.delegationWorker && !restricted
667
- && this.delegation?.groups?.includes('scheduling') === true;
668
- this.scheduleGuardRequired = !this.delegationWorker && (!!this.sessionId || managedScheduling);
687
+ const scheduleTools = this.delegation?.groups?.includes('scheduling') === true;
688
+ const managedScheduling = !this.delegationWorker && !restricted && scheduleTools;
689
+ this.scheduleGuardRequired = !this.delegationWorker && (!!this.sessionId || scheduleTools);
669
690
  // Managed resumes install admission hooks in the initial handshake. Keep
670
691
  // Cron available for reviewed deletion without adopting predecessor jobs.
671
692
  const disableNativeSchedules = !managedScheduling;
@@ -1495,6 +1516,20 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
1495
1516
  try {
1496
1517
  // Parse message first to check type
1497
1518
  const parsedMessage = JSON.parse(line);
1519
+ const pinned = this.currentHostScheduleSession ?? (!this.isProcessing ? this.commandQueue[0]?.options.hostScheduleSessionId : undefined);
1520
+ if (parsedMessage.type === 'system' && parsedMessage.subtype === 'init' && parsedMessage.session_id
1521
+ && (this.isStopping || pinned !== undefined && parsedMessage.session_id !== pinned)) {
1522
+ if (!this.isStopping) {
1523
+ // The native host diverged before or during dispatch. Preserve the original pointer.
1524
+ const error = 'Claude initialized a different conversation; scheduled dispatch was refused.';
1525
+ void this.stopProcess().then(() => this.processQueue(), () => { this.shutdownUncertain = true; });
1526
+ if (this.currentHostScheduleSession)
1527
+ this.completeCurrentCommand(false, error);
1528
+ else
1529
+ this.commandQueue.shift()?.resolve({ success: false, error });
1530
+ }
1531
+ return;
1532
+ }
1498
1533
  this.turnLedger.observe(parsedMessage);
1499
1534
  const cancellation = this.retainedAbort;
1500
1535
  if (cancellation?.requestId && parsedMessage.type === 'control_response'
@@ -2046,6 +2081,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
2046
2081
  this.clearApprovals('Task is no longer active');
2047
2082
  this.currentOutputBuffer = [];
2048
2083
  this.currentObjectiveDispatched = false;
2084
+ this.currentHostScheduleSession = undefined;
2049
2085
  this.textStreams.clear();
2050
2086
  this.currentStreamCallback = undefined;
2051
2087
  this.currentDisplayTextCallback = undefined;
@@ -2088,6 +2124,17 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
2088
2124
  }
2089
2125
  if (!this.commandQueue.length)
2090
2126
  return;
2127
+ const pinned = this.commandQueue[0].options.hostScheduleSessionId;
2128
+ if (pinned !== undefined) {
2129
+ try {
2130
+ this.checkHostScheduleSession(pinned);
2131
+ }
2132
+ catch (error) {
2133
+ this.commandQueue.shift().resolve({ success: false, error: error.message });
2134
+ void this.processQueue();
2135
+ return;
2136
+ }
2137
+ }
2091
2138
  // Ensure process is running
2092
2139
  if (!this.claudeProcess) {
2093
2140
  try {
@@ -2114,11 +2161,18 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
2114
2161
  }
2115
2162
  return;
2116
2163
  }
2117
- if (this.scheduleGuardRequired && !this.scheduleHooksReady && !this.delegationWorker) {
2164
+ const verifyOrdinaryHost = pinned !== undefined && !this.scheduleGuardRequired;
2165
+ if (!this.delegationWorker && (verifyOrdinaryHost || this.scheduleGuardRequired && !this.scheduleHooksReady)) {
2118
2166
  // Initialize callback hooks once per native process before its first model turn.
2119
2167
  this.isStarting = true;
2120
2168
  try {
2121
2169
  await this.listModels();
2170
+ if (!this.scheduleHooksReady)
2171
+ throw new Error('Native scheduling hooks are not initialized.');
2172
+ if (verifyOrdinaryHost) {
2173
+ await this.readScheduleHookPolicy();
2174
+ this.scheduleGuardRequired = true;
2175
+ }
2122
2176
  }
2123
2177
  catch {
2124
2178
  if (epoch !== this.commandEpoch)
@@ -2146,7 +2200,18 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
2146
2200
  void this.processQueue();
2147
2201
  return;
2148
2202
  }
2203
+ try {
2204
+ if (command.options.hostScheduleSessionId !== undefined)
2205
+ this.checkHostScheduleSession(command.options.hostScheduleSessionId);
2206
+ command.prompt = command.options.resolvePrompt?.(this.sessionId) ?? command.prompt;
2207
+ }
2208
+ catch (error) {
2209
+ command.resolve({ success: false, error: error.message });
2210
+ void this.processQueue();
2211
+ return;
2212
+ }
2149
2213
  this.isProcessing = true;
2214
+ this.currentHostScheduleSession = command.options.hostScheduleSessionId;
2150
2215
  this.currentScheduleManagement = command.options.nativeScheduleManagement === true;
2151
2216
  this.currentStreamCallback = command.options.onStream;
2152
2217
  this.currentAssistantTextSeen = false;
@@ -2200,7 +2265,6 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
2200
2265
  this.completeCurrentCommand(false, 'Execution timeout exceeded');
2201
2266
  }, command.options.timeout);
2202
2267
  }
2203
- command.prompt = command.options.resolvePrompt?.(this.sessionId) ?? command.prompt;
2204
2268
  let content = command.prompt;
2205
2269
  if (command.options.attachments && command.options.attachments.length > 0) {
2206
2270
  const blocks = [];
@@ -2237,7 +2301,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
2237
2301
  };
2238
2302
  inputMessage.uuid = (0, crypto_1.randomUUID)();
2239
2303
  this.turnLedger.dispatched(inputMessage.uuid);
2240
- this.sessionSchedules?.foregroundDispatched(inputMessage.uuid, command.options.nativeScheduleManagement, typeof content === 'string' && !command.isSlashCommand ? content : undefined);
2304
+ this.sessionSchedules?.foregroundDispatched(inputMessage.uuid, command.options.nativeScheduleManagement, typeof content === 'string' && !command.isSlashCommand ? content : undefined, command.options.hostScheduleSessionId);
2241
2305
  const inputLine = JSON.stringify(inputMessage);
2242
2306
  console.log(`[ClaudePersistent] Sending command${command.isSlashCommand ? ' (slash)' : ''}: ${command.prompt.substring(0, 100)}...`);
2243
2307
  this.currentObjectiveDispatched = true;
@@ -2728,7 +2792,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
2728
2792
  this.turnLedger.pid = typeof rawResponse.pid === 'number' ? rawResponse.pid : undefined;
2729
2793
  const { models, rawEntries } = (0, ClaudeSettings_1.parseClaudeModelsCatalog)(rawResponse.models, this.reportedModel || this.acknowledgedModel || this.model);
2730
2794
  if (scheduleHooks && this.scheduleGuardRequired) {
2731
- await this.readNativeScheduleTimezone();
2795
+ await this.readScheduleHookPolicy();
2732
2796
  }
2733
2797
  if (scheduleHooks) {
2734
2798
  this.schedules();