@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../../src/scheduling/agy/transcript.ts"],"names":[],"mappings":"AAAA;yEACyE;AACzE,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;CAC1C;AACD,eAAO,MAAM,cAAc,QAAkB,CAAC;AAC9C,eAAO,MAAM,WAAW,QAAS,CAAC;AAClC,eA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= exports.MAX_RECORDS = exports.MAX_TRANSCRIPT = void 0;
4
+ exports.parseTranscript = parseTranscript;
5
+ exports.receiptText = receiptText;
6
+ exports.creationReceipt = creationReceipt;
7
+ exports.creationDescription = creationDescription;
8
+ exports.inventoryReceipt = inventoryReceipt;
9
+ exports.deletionReceipt = deletionReceipt;
10
+ exports.nativeWake = nativeWake;
11
+ exports.matchesWake = matchesWake;
12
+ exports.nativeRestartNotice = nativeRestartNotice;
13
+ exports.MAX_TRANSCRIPT = 8 * 1024 * 1024;
14
+ exports.MAX_RECORDS = 20_000;
15
+ exports.NOTIFICATION_PREFIX = 'The following is a <SYSTEM_MESSAGE> not actually sent by the user. '
16
+ + 'It is provided by the system as important information to pay attention to.\n\n<SYSTEM_MESSAGE>\n';
17
+ const PREFIX_LINE = /^(?:Created At|Completed At): [^\r\n]+\r?\n/;
18
+ function parseTranscript(text) {
19
+ if (Buffer.byteLength(text) > exports.MAX_TRANSCRIPT)
20
+ throw new Error('AGY transcript exceeds the observation limit.');
21
+ const records = [];
22
+ const seen = new Set();
23
+ for (const line of text.split('\n')) {
24
+ if (!line.trim())
25
+ continue;
26
+ const row = JSON.parse(line);
27
+ if (!row || !Number.isSafeInteger(row.step_index) || row.step_index < 0 || seen.has(row.step_index)
28
+ || typeof row.source !== 'string' || typeof row.type !== 'string' || typeof row.status !== 'string'
29
+ || row.content !== undefined && typeof row.content !== 'string'
30
+ || row.tool_calls !== undefined && !Array.isArray(row.tool_calls))
31
+ throw new Error('Unsupported AGY transcript schema.');
32
+ seen.add(row.step_index);
33
+ records.push(row);
34
+ if (records.length > exports.MAX_RECORDS)
35
+ throw new Error('AGY transcript record limit reached.');
36
+ }
37
+ return records.sort((a, b) => a.step_index - b.step_index);
38
+ }
39
+ function receiptText(record) {
40
+ if (!record || record.source !== 'MODEL' || record.type !== 'GENERIC' || typeof record.content !== 'string')
41
+ return;
42
+ let text = record.content;
43
+ while (PREFIX_LINE.test(text))
44
+ text = text.replace(PREFIX_LINE, '');
45
+ return text;
46
+ }
47
+ function creationReceipt(record, session, step) {
48
+ const text = receiptText(record);
49
+ if (!text || !['RUNNING', 'DONE'].includes(record.status))
50
+ return;
51
+ const match = /^Tool is running as a background task with task id: ([^\s]+)\nTask Description: [\s\S]+\nTask logs are available at: file:\/\/[^\r\n]+\s*$/.exec(text);
52
+ const id = `${session}/task-${step}`;
53
+ return match?.[1] === id ? id : undefined;
54
+ }
55
+ function creationDescription(record) {
56
+ return /\nTask Description: ([\s\S]+)\nTask logs are available at: file:\/\//.exec(receiptText(record) ?? '')?.[1];
57
+ }
58
+ function inventoryReceipt(record) {
59
+ const text = receiptText(record);
60
+ if (record?.status !== 'DONE' || text === undefined)
61
+ return;
62
+ if (text === 'No background tasks are currently running.')
63
+ return [];
64
+ const match = /^You have (\d+) background task\(s\) currently running:\n([\s\S]+)$/.exec(text);
65
+ if (!match)
66
+ return;
67
+ const rows = JSON.parse(match[2]);
68
+ if (!Array.isArray(rows) || rows.length !== Number(match[1]) || rows.length > 1000)
69
+ throw new Error('Invalid native AGY inventory.');
70
+ const ids = new Set();
71
+ for (const row of rows) {
72
+ if (!row || typeof row.taskId !== 'string' || row.taskId.length > 256 || ids.has(row.taskId)
73
+ || typeof row.toolName !== 'string' || typeof row.description !== 'string'
74
+ || row.isDaemon !== undefined && typeof row.isDaemon !== 'boolean')
75
+ throw new Error('Invalid native AGY task.');
76
+ ids.add(row.taskId);
77
+ }
78
+ return rows;
79
+ }
80
+ function deletionReceipt(record, id) {
81
+ return record?.status === 'DONE' && receiptText(record) === `Task "${id}" cancelled.`;
82
+ }
83
+ function nativeWake(record) {
84
+ if (record.source !== 'SYSTEM' || record.type !== 'SYSTEM_MESSAGE' || record.status !== 'DONE'
85
+ || !record.content?.startsWith(exports.NOTIFICATION_PREFIX))
86
+ return;
87
+ const match = /^\[Message\] timestamp=(\S+) sender=([^\s]+\/task-\d+) priority=MESSAGE_PRIORITY_HIGH content=([\s\S]*)\n<\/SYSTEM_MESSAGE>$/.exec(record.content.slice(exports.NOTIFICATION_PREFIX.length));
88
+ if (!match || !Number.isFinite(Date.parse(match[1])))
89
+ return;
90
+ return { sender: match[2], timestamp: match[1], prompt: match[3] };
91
+ }
92
+ function matchesWake(prompt, actual, recurring) {
93
+ if (!recurring)
94
+ return prompt === actual;
95
+ if (!actual.startsWith(prompt))
96
+ return false;
97
+ return /^ \(iteration [1-9]\d*\)$/.test(actual.slice(prompt.length));
98
+ }
99
+ /** Native load emits this informational notice even for a proven empty session.
100
+ * It is not a task wake or queue-absence proof. Keep its source and full payload
101
+ * exact; an arbitrary SYSTEM sender or MODEL echo does not qualify. */
102
+ function nativeRestartNotice(record) {
103
+ if (record.source !== 'SYSTEM' || record.type !== 'SYSTEM_MESSAGE' || record.status !== 'DONE'
104
+ || !record.content?.startsWith(exports.NOTIFICATION_PREFIX))
105
+ return false;
106
+ return /^\[Message\] timestamp=\S+ sender=system priority=MESSAGE_PRIORITY_LOW content=\[Notice\] All your subagents and background tasks have been stopped due to server restart\. If you want a subagent to continue working, it needs to be revived by sending it a new message\. If resuming work, please check on status and restart as needed\.\n<\/SYSTEM_MESSAGE>$/.test(record.content.slice(exports.NOTIFICATION_PREFIX.length));
107
+ }
108
+ //# sourceMappingURL=transcript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transcript.js","sourceRoot":"","sources":["../../../src/scheduling/agy/transcript.ts"],"names":[],"mappings":";;;AAYA,0CAeC;AAED,kCAKC;AAED,0CAMC;AAED,kDAEC;AAGD,4CAgBC;AAED,0CAEC;AAED,gCAMC;AAED,kCAIC;AAKD,kDAIC;AAtFY,QAAA,cAAc,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACjC,QAAA,WAAW,GAAG,MAAM,CAAC;AACrB,QAAA,mBAAmB,GAAG,qEAAqE;MACpG,kGAAkG,CAAC;AACvG,MAAM,WAAW,GAAG,6CAA6C,CAAC;AAElE,SAAgB,eAAe,CAAC,IAAY;IAC1C,IAAI,MAAM,CAAC,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M,CAAC,OAAO,CAAC,KAAK,CAAC,2BAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;AACra,CAAC"}
@@ -62,6 +62,7 @@ export declare class ClaudeSessionSchedules {
62
62
  private seen;
63
63
  private resultIds;
64
64
  private foregroundId?;
65
+ private foregroundTurn?;
65
66
  private foregroundStarted;
66
67
  private definitionRemoval?;
67
68
  foregroundDispatched(id: string, management?: boolean): void;
@@ -96,6 +97,10 @@ export declare class ClaudeSessionSchedules {
96
97
  isCurrent(): boolean;
97
98
  }): Promise<ClaudeDefinitionRemovalReceipt>;
98
99
  inToolOperation<T>(id: string, current: () => boolean, run: () => Promise<T>, inTurn?: boolean): Promise<T>;
100
+ private invocation;
101
+ /** Capture once, before asynchronous caller preparation; never adopt a later turn. */
102
+ invocationLease(): () => boolean;
103
+ private endInvocation;
99
104
  /** Capture existing mutation ownership before revoking foreground authority. Never creates jobs. */
100
105
  captureCancellation(): (current: () => boolean) => Promise<void>;
101
106
  action(id: string): NativeScheduleAction | undefined;
@@ -111,12 +116,14 @@ export declare class ClaudeSessionSchedules {
111
116
  private inventory;
112
117
  private structuredInventory;
113
118
  private request;
119
+ private watchPending;
114
120
  private receiptTimeout;
115
121
  private failPending;
116
122
  /** Called before an ordinary command resolves so its unexecuted reservations cannot deadlock drain(). */
117
123
  foregroundEnded(): void;
118
124
  /** Consume only schedule-owned frames. Ordinary user output continues through the existing executor. */
119
125
  accept(frame: Frame): boolean;
126
+ private acceptReceipts;
120
127
  private receipt;
121
128
  private hook;
122
129
  private matchPrompts;
@@ -1 +1 @@
1
- {"version":3,"file":"ClaudeSessionSchedules.d.ts","sourceRoot":"","sources":["../../../src/scheduling/claude/ClaudeSessionSchedules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAG1F,OAAO,EAAyD,KAAK,mBAAmB,EAAE,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAC;A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,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,kBAAkB;IAK1B,OAAO,CAAC,IAAI;IAMZ,OAAO,CAAC,kBAAkB;IAoB1B,OAAO,CAAC,MAAM;IAId,kEAAkE;IAClE,aAAa,CAAC,QAAQ,UAAQ,GAAG,IAAI;CAOtC"}
@@ -28,9 +28,14 @@ class ClaudeSessionSchedules {
28
28
  seen = new Set();
29
29
  resultIds = new Set();
30
30
  foregroundId;
31
+ foregroundTurn;
31
32
  foregroundStarted = false;
32
33
  definitionRemoval;
33
34
  foregroundDispatched(id, management = false) {
35
+ this.endInvocation(this.foregroundTurn);
36
+ if (this.batch)
37
+ this.endInvocation(this.batch);
38
+ this.foregroundTurn = {};
34
39
  this.foregroundId = id;
35
40
  this.foregroundStarted = false;
36
41
  this.managementTurn = management;
@@ -116,8 +121,12 @@ class ClaudeSessionSchedules {
116
121
  async inToolOperation(id, current, run, inTurn = true) {
117
122
  if (this.scope)
118
123
  throw new Error('A native schedule operation is already active.');
124
+ const turn = inTurn ? this.invocation() : undefined;
125
+ if (inTurn && !turn)
126
+ throw new Error('No unambiguous native invocation owns this scheduling operation.');
119
127
  let finish;
120
- const scope = { id, current, inTurn, mutations: new Set(), done: new Promise(resolve => { finish = resolve; }) };
128
+ const scope = { id, current: () => current() && (!inTurn || this.invocation() === turn), inTurn, turn,
129
+ mutations: new Set(), done: new Promise(resolve => { finish = resolve; }) };
121
130
  this.scope = scope;
122
131
  try {
123
132
  return await run();
@@ -128,6 +137,31 @@ class ClaudeSessionSchedules {
128
137
  finish();
129
138
  }
130
139
  }
140
+ invocation() {
141
+ if (this.closed)
142
+ return undefined;
143
+ if (this.batch)
144
+ return !this.foregroundId && !this.batch.ended && this.batch.occurrences.some(item => item.job) ? this.batch : undefined;
145
+ return this.foregroundId && !this.foregroundTurn?.ended ? this.foregroundTurn : undefined;
146
+ }
147
+ /** Capture once, before asynchronous caller preparation; never adopt a later turn. */
148
+ invocationLease() {
149
+ const turn = this.invocation();
150
+ if (!turn)
151
+ throw new Error('No unambiguous native invocation owns this scheduling operation.');
152
+ return () => this.invocation() === turn;
153
+ }
154
+ endInvocation(turn) {
155
+ if (!turn)
156
+ return;
157
+ turn.ended = true;
158
+ const scope = this.scope;
159
+ if (!scope?.inTurn || scope.turn !== turn)
160
+ return;
161
+ scope.ended = true;
162
+ if (this.pending?.scope === scope)
163
+ this.failPending('Native invocation scheduling authorization ended without the authorized tool receipt.');
164
+ }
131
165
  /** Capture existing mutation ownership before revoking foreground authority. Never creates jobs. */
132
166
  captureCancellation() {
133
167
  const scope = this.scope;
@@ -135,6 +169,13 @@ class ClaudeSessionSchedules {
135
169
  for (const job of this.jobs.values())
136
170
  if (job.uncertain)
137
171
  ids.add(job.id);
172
+ // Abort revokes this turn before its terminal frame may arrive. Unwind the
173
+ // reservation now so cleanup cannot wait forever for scope.done.
174
+ if (scope)
175
+ scope.ended = true;
176
+ if (this.pending && (scope && this.pending.scope === scope || this.pending.managementId === this.foregroundId)) {
177
+ this.failPending('The native turn was aborted without the authorized schedule tool receipt.');
178
+ }
138
179
  return async (current) => {
139
180
  await scope?.done;
140
181
  for (const id of ids) {
@@ -155,7 +196,7 @@ class ClaudeSessionSchedules {
155
196
  };
156
197
  }
157
198
  action(id) {
158
- return this.pending?.scope?.inTurn && this.pending.scope.id === id && this.pending.scope.current() && !this.pending.toolId
199
+ return this.pending?.scope?.inTurn && !this.pending.scope.ended && this.pending.scope.id === id && this.pending.scope.current() && !this.pending.toolId
159
200
  ? structuredClone(this.pending.action) : undefined;
160
201
  }
161
202
  /** Explicit review authority is independent of historical managed job ownership. */
@@ -243,33 +284,48 @@ class ClaudeSessionSchedules {
243
284
  job.retired = true;
244
285
  }
245
286
  async create(input, emit, current = () => true, timezone = this.options.timezone ?? Intl.DateTimeFormat().resolvedOptions().timeZone, restore = false, expectedNativeId, canAdmitOccurrence) {
246
- if (this.closed || this.definitionRemoval || this.jobs.has(input.id) || this.jobs.size >= 100 || [...this.jobs.values()].filter(j => !j.retired).length >= 5) {
287
+ // An existing identity can still own native work from an earlier attempt.
288
+ if (this.jobs.has(input.id)) {
247
289
  throw new Error('Native session schedule identity or capacity is unavailable.');
248
290
  }
249
- const rule = (0, rules_1.nativeRule)(input.rule, Date.now());
250
- let cron = rule.cron;
251
- if (rule.at) {
252
- const formatter = new Intl.DateTimeFormat('en-US', { timeZone: timezone, year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', hourCycle: 'h23' });
253
- const parts = formatter.formatToParts(rule.at);
254
- // During a daylight-saving rollback cron could select an earlier instance
255
- // of the same wall minute. Refuse that ambiguity rather than fire early.
256
- for (let minutes = 1; minutes <= 180; minutes++) {
257
- const earlier = rule.at - minutes * 60_000;
258
- if (earlier > Date.now() && formatter.format(earlier) === formatter.format(rule.at)) {
259
- throw new Error('This one-shot time is ambiguous in the native session timezone. Choose a time outside the clock rollback.');
291
+ let rule;
292
+ let cron;
293
+ let marker;
294
+ try {
295
+ if (this.closed || this.definitionRemoval || this.jobs.size >= 100 || [...this.jobs.values()].filter(j => !j.retired).length >= 5) {
296
+ throw new Error('Native session schedule identity or capacity is unavailable.');
297
+ }
298
+ rule = (0, rules_1.nativeRule)(input.rule, Date.now());
299
+ cron = rule.cron;
300
+ if (rule.at) {
301
+ const formatter = new Intl.DateTimeFormat('en-US', { timeZone: timezone, year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', hourCycle: 'h23' });
302
+ const parts = formatter.formatToParts(rule.at);
303
+ // During a daylight-saving rollback cron could select an earlier instance
304
+ // of the same wall minute. Refuse that ambiguity rather than fire early.
305
+ for (let minutes = 1; minutes <= 180; minutes++) {
306
+ const earlier = rule.at - minutes * 60_000;
307
+ if (earlier > Date.now() && formatter.format(earlier) === formatter.format(rule.at)) {
308
+ throw new Error('This one-shot time is ambiguous in the native session timezone. Choose a time outside the clock rollback.');
309
+ }
260
310
  }
311
+ const part = (name) => Number(parts.find(p => p.type === name).value);
312
+ cron = `${part('minute')} ${part('hour')} ${part('day')} ${part('month')} *`;
261
313
  }
262
- const part = (name) => Number(parts.find(p => p.type === name).value);
263
- cron = `${part('minute')} ${part('hour')} ${part('day')} ${part('month')} *`;
314
+ else if (new Intl.DateTimeFormat('en', { timeZone: rule.timezone }).resolvedOptions().timeZone
315
+ !== new Intl.DateTimeFormat('en', { timeZone: timezone }).resolvedOptions().timeZone) {
316
+ throw new Error(`Shared Claude schedules use the native session timezone (${timezone}); choose that timezone. The conversation timezone was not changed.`);
317
+ }
318
+ const stable = input.recovery ? JSON.parse(input.recovery.identity).marker : undefined;
319
+ if (input.recovery && (typeof stable !== 'string' || !/^[a-f0-9-]{36}$/.test(stable)))
320
+ throw new Error('Invalid durable native schedule marker.');
321
+ marker = `[remote-cli:${stable ?? (0, crypto_1.randomUUID)()}]`;
264
322
  }
265
- else if (new Intl.DateTimeFormat('en', { timeZone: rule.timezone }).resolvedOptions().timeZone
266
- !== new Intl.DateTimeFormat('en', { timeZone: timezone }).resolvedOptions().timeZone) {
267
- throw new Error(`Shared Claude schedules use the native session timezone (${timezone}); choose that timezone. The conversation timezone was not changed.`);
323
+ catch (error) {
324
+ // Restored definitions may predate this attempt; validation proves no absence.
325
+ if (restore || expectedNativeId)
326
+ throw error;
327
+ throw new types_1.NativeScheduleNotAdmittedError(error instanceof Error ? error.message : 'Native schedule validation refused admission.');
268
328
  }
269
- const stable = input.recovery ? JSON.parse(input.recovery.identity).marker : undefined;
270
- if (input.recovery && (typeof stable !== 'string' || !/^[a-f0-9-]{36}$/.test(stable)))
271
- throw new Error('Invalid durable native schedule marker.');
272
- const marker = `[remote-cli:${stable ?? (0, crypto_1.randomUUID)()}]`;
273
329
  const job = { id: input.id, marker, prompt: `${marker}\n${input.prompt}`, recurring: rule.recurring,
274
330
  deadline: rule.at, current, canAdmitOccurrence, recovering: !!restore, adopt: typeof restore === 'string', cron, expectedNativeId, uncertain: false, retired: false, cancelled: false, emit };
275
331
  this.jobs.set(job.id, job);
@@ -438,11 +494,8 @@ class ClaudeSessionSchedules {
438
494
  if (action.tool !== 'CronList')
439
495
  scope?.mutations.add(job.id);
440
496
  const result = new Promise((resolve, reject) => {
441
- const timer = setTimeout(() => {
442
- if (this.pending)
443
- this.failPending(this.receiptTimeout(this.pending));
444
- }, this.options.timeoutMs ?? 60_000);
445
- this.pending = { action, job, scope, resolve, reject, timer, preserveOccurrences };
497
+ this.pending = { action, job, scope, resolve, reject, preserveOccurrences };
498
+ this.watchPending(this.pending);
446
499
  });
447
500
  // A managed MCP call returns the action to its caller. Never execute a second
448
501
  // model turn while that caller is waiting for this MCP response.
@@ -455,6 +508,32 @@ class ClaudeSessionSchedules {
455
508
  }
456
509
  return result;
457
510
  }
511
+ watchPending(pending) {
512
+ clearTimeout(pending.timer);
513
+ const awaitingCurrentTurn = pending.scope?.inTurn && !pending.toolId;
514
+ const timeout = this.options.timeoutMs ?? 60_000;
515
+ // Current-turn tool discovery and model reasoning have no separate deadline.
516
+ // Poll only scope liveness, so a disconnected owner cannot strand drain().
517
+ // Management invocation and authorized receipts each retain a full deadline.
518
+ pending.timer = setTimeout(() => {
519
+ if (this.pending !== pending)
520
+ return;
521
+ let current = true;
522
+ try {
523
+ current = !pending.scope || !pending.scope.ended && pending.scope.current();
524
+ }
525
+ catch {
526
+ current = false;
527
+ }
528
+ if (!current) {
529
+ this.failPending('Scheduling owner or native turn is no longer current.');
530
+ }
531
+ else if (awaitingCurrentTurn)
532
+ this.watchPending(pending);
533
+ else
534
+ this.failPending(this.receiptTimeout(pending));
535
+ }, awaitingCurrentTurn ? Math.min(timeout, 1000) : timeout);
536
+ }
458
537
  receiptTimeout(pending) {
459
538
  const stage = pending.toolId ? 'authorized tool result missing'
460
539
  : pending.scope?.inTurn ? 'awaiting matching tool invocation in the current turn'
@@ -480,13 +559,13 @@ class ClaudeSessionSchedules {
480
559
  }
481
560
  /** Called before an ordinary command resolves so its unexecuted reservations cannot deadlock drain(). */
482
561
  foregroundEnded() {
483
- if (this.scope?.inTurn)
484
- this.scope.ended = true;
485
- if (this.pending && (this.pending.scope?.inTurn || this.pending.managementId === this.foregroundId)) {
486
- this.failPending('The native turn ended without the authorized schedule tool receipt.');
562
+ this.endInvocation(this.foregroundTurn);
563
+ if (this.pending && this.pending.managementId !== undefined && this.pending.managementId === this.foregroundId) {
564
+ this.failPending('Foreground scheduling authorization ended without the native tool receipt.');
487
565
  }
488
566
  this.managementTurn = false;
489
567
  this.foregroundId = undefined;
568
+ this.foregroundTurn = undefined;
490
569
  this.foregroundStarted = false;
491
570
  }
492
571
  /** Consume only schedule-owned frames. Ordinary user output continues through the existing executor. */
@@ -524,6 +603,8 @@ class ClaudeSessionSchedules {
524
603
  if (frame.state === 'started' && frame.wakeup_source === 'schedule_wakeup') {
525
604
  if (typeof frame.command_uuid !== 'string' || !idPattern.test(frame.command_uuid) || this.seen.has(frame.command_uuid))
526
605
  return true;
606
+ if (!this.batch)
607
+ this.endInvocation(this.foregroundTurn);
527
608
  const batch = this.batch ??= { occurrences: [] };
528
609
  if (batch.occurrences.some(occurrence => occurrence.id === frame.command_uuid))
529
610
  return true;
@@ -546,15 +627,25 @@ class ClaudeSessionSchedules {
546
627
  // Keep failed terminals sticky even if a conflicting late receipt arrives.
547
628
  if (!occurrence.terminal || frame.state !== 'completed')
548
629
  occurrence.terminal = frame.state;
630
+ if (this.batch.occurrences.every(item => item.terminal))
631
+ this.endInvocation(this.batch);
549
632
  this.completeOccurrence();
550
633
  return true;
551
634
  }
635
+ if (frame.command_uuid === this.foregroundId && ['completed', 'cancelled', 'discarded', 'refused'].includes(frame.state)) {
636
+ this.endInvocation(this.foregroundTurn);
637
+ this.foregroundTurn = undefined;
638
+ }
552
639
  if (this.submitted && !this.batch && ['cancelled', 'discarded', 'refused'].includes(frame.state)) {
553
640
  this.submitted = undefined;
554
641
  this.options.wake();
555
642
  }
556
643
  return false;
557
644
  }
645
+ // Tool receipts belong to exact authorized tool IDs even after their turn
646
+ // ended, including a late mutation receipt while another batch is active.
647
+ if (frame.type === 'user' && !frame.parent_tool_use_id)
648
+ this.acceptReceipts(frame);
558
649
  if (this.batch) {
559
650
  if (frame.type === 'result' && !frame.parent_tool_use_id) {
560
651
  if (frame.user_message_uuid || frame.user_message_uuids?.length) {
@@ -563,6 +654,7 @@ class ClaudeSessionSchedules {
563
654
  }
564
655
  else
565
656
  this.batch.result = frame;
657
+ this.endInvocation(this.batch);
566
658
  this.completeOccurrence();
567
659
  return true;
568
660
  }
@@ -580,34 +672,38 @@ class ClaudeSessionSchedules {
580
672
  }
581
673
  }
582
674
  }
583
- if (frame.type === 'user' && !frame.parent_tool_use_id) {
584
- for (const block of frame.message?.content ?? []) {
585
- if (block.type !== 'tool_result' || typeof block.tool_use_id !== 'string')
586
- continue;
587
- const auth = this.authorized.get(block.tool_use_id);
588
- if (!auth)
589
- continue;
590
- this.authorized.delete(block.tool_use_id);
591
- const pending = this.pending?.toolId === block.tool_use_id ? this.pending : undefined;
592
- try {
593
- if (block.is_error || typeof block.content !== 'string')
594
- throw new Error('Native schedule tool failed or returned an invalid receipt.');
595
- if (auth.action.tool === 'CronList' && auth.job.adopt)
596
- this.structuredInventory(auth.job, frame.tool_use_result);
597
- this.receipt(auth.job, auth.action, block.content, auth.preserveOccurrences);
598
- if (pending) {
599
- this.pending = undefined;
600
- clearTimeout(pending.timer);
601
- pending.resolve(block.content);
602
- }
603
- }
604
- catch (error) {
605
- if (pending)
606
- this.failPending(error instanceof Error ? error.message : 'Invalid native receipt.');
675
+ return false;
676
+ }
677
+ acceptReceipts(frame) {
678
+ for (const block of frame.message?.content ?? []) {
679
+ if (block.type !== 'tool_result' || typeof block.tool_use_id !== 'string')
680
+ continue;
681
+ const auth = this.authorized.get(block.tool_use_id);
682
+ if (!auth)
683
+ continue;
684
+ this.authorized.delete(block.tool_use_id);
685
+ const pending = this.pending?.toolId === block.tool_use_id ? this.pending : undefined;
686
+ if (pending?.action.tool === 'CronList' && pending.scope && (pending.scope.ended || !pending.scope.current())) {
687
+ this.failPending('Scheduling owner or native turn is no longer current.');
688
+ continue;
689
+ }
690
+ try {
691
+ if (block.is_error || typeof block.content !== 'string')
692
+ throw new Error('Native schedule tool failed or returned an invalid receipt.');
693
+ if (auth.action.tool === 'CronList' && auth.job.adopt)
694
+ this.structuredInventory(auth.job, frame.tool_use_result);
695
+ this.receipt(auth.job, auth.action, block.content, auth.preserveOccurrences);
696
+ if (pending) {
697
+ this.pending = undefined;
698
+ clearTimeout(pending.timer);
699
+ pending.resolve(block.content);
607
700
  }
608
701
  }
702
+ catch (error) {
703
+ if (pending)
704
+ this.failPending(error instanceof Error ? error.message : 'Invalid native receipt.');
705
+ }
609
706
  }
610
- return false;
611
707
  }
612
708
  receipt(job, action, text, preserveOccurrences) {
613
709
  if (action.tool === 'CronCreate') {
@@ -649,16 +745,17 @@ class ClaudeSessionSchedules {
649
745
  const p = this.pending;
650
746
  const toolId = frame.request.tool_use_id ?? input.tool_use_id;
651
747
  const allow = !!p && (p.scope?.inTurn || this.managementTurn && p.managementId === this.foregroundId)
652
- && this.capable && !this.closed && !p.toolId && !this.busy
748
+ && this.capable && !this.closed && !p.toolId && (!this.busy || !!this.batch && p.scope?.turn === this.batch && !this.batch.ended)
653
749
  && input.agent_id === undefined && !frame.parent_tool_use_id
654
750
  && (!p.scope || !p.scope.ended && p.scope.current()) && (p.action.tool !== 'CronCreate' || p.job.current()) && (p.action.tool !== 'CronCreate' || !p.job.deadline || p.job.deadline > Date.now())
655
- && this.authorized.size < 100 && typeof toolId === 'string' && idPattern.test(toolId) && input.tool_name === p.action.tool
751
+ && this.authorized.size < 100 && typeof toolId === 'string' && idPattern.test(toolId) && !this.authorized.has(toolId) && input.tool_name === p.action.tool
656
752
  && canonical(input.tool_input) === canonical(p.action.input);
657
753
  if (allow) {
658
754
  p.toolId = toolId;
659
755
  if (p.action.tool === 'CronCreate')
660
756
  p.job.uncertain = true;
661
757
  this.authorized.set(toolId, { action: p.action, job: p.job, preserveOccurrences: p.preserveOccurrences });
758
+ this.watchPending(p);
662
759
  }
663
760
  else
664
761
  response = { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'deny', permissionDecisionReason: 'No matching current managed schedule authorization.' } };
@@ -726,6 +823,7 @@ class ClaudeSessionSchedules {
726
823
  const batch = this.batch;
727
824
  if (!batch?.result || !batch.occurrences.every(occurrence => occurrence.terminal))
728
825
  return;
826
+ this.endInvocation(batch);
729
827
  this.batch = undefined;
730
828
  for (const occurrence of batch.occurrences) {
731
829
  this.seen.add(occurrence.id);