@yu_robotics/remote-cli 1.6.232 → 1.6.234
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/MessageHandler.d.ts +10 -1
- package/dist/client/MessageHandler.d.ts.map +1 -1
- package/dist/client/MessageHandler.js +255 -71
- package/dist/client/MessageHandler.js.map +1 -1
- package/dist/client/WebSocketClient.d.ts.map +1 -1
- package/dist/client/WebSocketClient.js +2 -0
- package/dist/client/WebSocketClient.js.map +1 -1
- package/dist/delegation/DelegationBridge.d.ts +2 -13
- package/dist/delegation/DelegationBridge.d.ts.map +1 -1
- package/dist/delegation/DelegationBridge.js +3 -126
- package/dist/delegation/DelegationBridge.js.map +1 -1
- package/dist/delegation/contract.d.ts +3 -4
- package/dist/delegation/contract.d.ts.map +1 -1
- package/dist/delegation/contract.js +3 -2
- package/dist/delegation/contract.js.map +1 -1
- package/dist/delegation/mcpServer.js +3 -2
- package/dist/delegation/mcpServer.js.map +1 -1
- package/dist/delegation/piExtension.d.ts +3 -3
- package/dist/delegation/piExtension.d.ts.map +1 -1
- package/dist/delegation/piExtension.js +4 -4
- package/dist/delegation/piExtension.js.map +1 -1
- package/dist/executor/AcpExecutor.d.ts +1 -0
- package/dist/executor/AcpExecutor.d.ts.map +1 -1
- package/dist/executor/AcpExecutor.js +10 -4
- package/dist/executor/AcpExecutor.js.map +1 -1
- package/dist/executor/AgyExecutor.d.ts +1 -0
- package/dist/executor/AgyExecutor.d.ts.map +1 -1
- package/dist/executor/AgyExecutor.js +5 -0
- package/dist/executor/AgyExecutor.js.map +1 -1
- package/dist/executor/ClaudePersistentExecutor.d.ts +1 -0
- package/dist/executor/ClaudePersistentExecutor.d.ts.map +1 -1
- package/dist/executor/ClaudePersistentExecutor.js +7 -1
- package/dist/executor/ClaudePersistentExecutor.js.map +1 -1
- package/dist/executor/CodexAppServerExecutor.d.ts +1 -0
- package/dist/executor/CodexAppServerExecutor.d.ts.map +1 -1
- package/dist/executor/CodexAppServerExecutor.js +15 -8
- package/dist/executor/CodexAppServerExecutor.js.map +1 -1
- package/dist/executor/IExecutor.d.ts +2 -0
- package/dist/executor/IExecutor.d.ts.map +1 -1
- package/dist/executor/PiExecutor.d.ts +1 -0
- package/dist/executor/PiExecutor.d.ts.map +1 -1
- package/dist/executor/PiExecutor.js +5 -0
- package/dist/executor/PiExecutor.js.map +1 -1
- package/dist/executor/pi/PiClient.d.ts.map +1 -1
- package/dist/executor/pi/PiClient.js +1 -0
- package/dist/executor/pi/PiClient.js.map +1 -1
- package/dist/maintenance/release-notes.json +1 -1
- package/dist/managed/ManagedToolBridge.d.ts +14 -0
- package/dist/managed/ManagedToolBridge.d.ts.map +1 -0
- package/dist/managed/ManagedToolBridge.js +132 -0
- package/dist/managed/ManagedToolBridge.js.map +1 -0
- package/dist/managed/contract.d.ts +9 -0
- package/dist/managed/contract.d.ts.map +1 -0
- package/dist/managed/contract.js +7 -0
- package/dist/managed/contract.js.map +1 -0
- package/dist/managed/tools.d.ts +230 -0
- package/dist/managed/tools.d.ts.map +1 -0
- package/dist/managed/tools.js +23 -0
- package/dist/managed/tools.js.map +1 -0
- package/dist/scheduling/ScheduleCardService.d.ts +26 -0
- package/dist/scheduling/ScheduleCardService.d.ts.map +1 -0
- package/dist/scheduling/ScheduleCardService.js +109 -0
- package/dist/scheduling/ScheduleCardService.js.map +1 -0
- package/dist/scheduling/ScheduleService.d.ts +2 -0
- package/dist/scheduling/ScheduleService.d.ts.map +1 -1
- package/dist/scheduling/ScheduleService.js +7 -0
- package/dist/scheduling/ScheduleService.js.map +1 -1
- package/dist/scheduling/ScheduleToolScope.d.ts +55 -0
- package/dist/scheduling/ScheduleToolScope.d.ts.map +1 -0
- package/dist/scheduling/ScheduleToolScope.js +182 -0
- package/dist/scheduling/ScheduleToolScope.js.map +1 -0
- package/dist/scheduling/toolContract.d.ts +48 -0
- package/dist/scheduling/toolContract.d.ts.map +1 -0
- package/dist/scheduling/toolContract.js +24 -0
- package/dist/scheduling/toolContract.js.map +1 -0
- package/dist/types/ScheduleCards.d.ts +56 -0
- package/dist/types/ScheduleCards.d.ts.map +1 -0
- package/dist/types/ScheduleCards.js +3 -0
- package/dist/types/ScheduleCards.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/native/prebuilds/darwin-arm64/managed_native.node +0 -0
- package/native/prebuilds/darwin-arm64/manifest.json +1 -1
- package/native/prebuilds/darwin-x64/managed_native.node +0 -0
- package/native/prebuilds/darwin-x64/manifest.json +1 -1
- package/native/prebuilds/win32-arm64/managed_native.node +0 -0
- package/native/prebuilds/win32-arm64/manifest.json +1 -1
- package/native/prebuilds/win32-x64/managed_native.node +0 -0
- package/native/prebuilds/win32-x64/manifest.json +1 -1
- package/package.json +1 -1
|
@@ -65,6 +65,11 @@ export declare class MessageHandler {
|
|
|
65
65
|
private readonly pendingOutputFiles;
|
|
66
66
|
private imageConnectionEpoch;
|
|
67
67
|
private scheduleResultsSupported;
|
|
68
|
+
private scheduleCardsSupported;
|
|
69
|
+
private scheduleToolCardsSupported;
|
|
70
|
+
private readonly scheduleToolOperations;
|
|
71
|
+
private readonly scheduleCardReceipts;
|
|
72
|
+
private readonly scheduleCards;
|
|
68
73
|
private schedules?;
|
|
69
74
|
private scheduleInitialization?;
|
|
70
75
|
private scheduleDelivery?;
|
|
@@ -212,11 +217,15 @@ export declare class MessageHandler {
|
|
|
212
217
|
private executorConfiguration;
|
|
213
218
|
private scheduleGeneration;
|
|
214
219
|
private scheduleDirectory;
|
|
215
|
-
/** Binding recovery only reads existing storage;
|
|
220
|
+
/** Binding recovery only reads existing storage; explicit command/tool use initializes it. */
|
|
216
221
|
private recoverSchedules;
|
|
217
222
|
private initializeSchedules;
|
|
218
223
|
private activeSchedules;
|
|
219
224
|
private assertSchedulesIdle;
|
|
225
|
+
private clearScheduleCardReceipts;
|
|
226
|
+
private deliverScheduleToolCard;
|
|
227
|
+
/** Shared admission for slash commands and scoped model tools. Native providers alone own timing. */
|
|
228
|
+
private runScheduleOperation;
|
|
220
229
|
private handleScheduleCommand;
|
|
221
230
|
/** Shared card/text Apply path. Callers hold exclusive settings admission. */
|
|
222
231
|
private changeWorkingDirectory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageHandler.d.ts","sourceRoot":"","sources":["../../src/client/MessageHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MessageHandler.d.ts","sourceRoot":"","sources":["../../src/client/MessageHandler.ts"],"names":[],"mappings":"AAWA,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,C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;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,8FAA8F;YAChF,gBAAgB;IAmB9B,OAAO,CAAC,mBAAmB;YAkCb,eAAe;YASf,mBAAmB;IAMjC,OAAO,CAAC,yBAAyB;IAOjC,OAAO,CAAC,uBAAuB;IAc/B,qGAAqG;YACvF,oBAAoB;YAqDpB,qBAAqB;IAoCnC,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;IA0BjC,OAAO,CAAC,YAAY;YAUN,cAAc;YAuBd,oBAAoB;IAgHlC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAiC/B"}
|
|
@@ -4,6 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.MessageHandler = void 0;
|
|
7
|
+
const ScheduleToolScope_1 = require("../scheduling/ScheduleToolScope");
|
|
8
|
+
const toolContract_1 = require("../scheduling/toolContract");
|
|
9
|
+
const ScheduleCardService_1 = require("../scheduling/ScheduleCardService");
|
|
7
10
|
const PendingOutputFiles_1 = require("../output/PendingOutputFiles");
|
|
8
11
|
const OutputFiles_1 = require("../output/OutputFiles");
|
|
9
12
|
const OutputSnapshots_1 = require("../output/OutputSnapshots");
|
|
@@ -214,6 +217,11 @@ class MessageHandler {
|
|
|
214
217
|
pendingOutputFiles = new PendingOutputFiles_1.PendingOutputFiles();
|
|
215
218
|
imageConnectionEpoch = 0;
|
|
216
219
|
scheduleResultsSupported = false;
|
|
220
|
+
scheduleCardsSupported = false;
|
|
221
|
+
scheduleToolCardsSupported = false;
|
|
222
|
+
scheduleToolOperations = new ScheduleToolScope_1.ScheduleToolOperations();
|
|
223
|
+
scheduleCardReceipts = new Map();
|
|
224
|
+
scheduleCards;
|
|
217
225
|
schedules;
|
|
218
226
|
scheduleInitialization;
|
|
219
227
|
scheduleDelivery;
|
|
@@ -225,9 +233,40 @@ class MessageHandler {
|
|
|
225
233
|
this.threadManager = threadManager;
|
|
226
234
|
this.directoryGuard = directoryGuard;
|
|
227
235
|
this.config = config;
|
|
236
|
+
this.scheduleCards = new ScheduleCardService_1.ScheduleCardService({
|
|
237
|
+
current: owner => {
|
|
238
|
+
try {
|
|
239
|
+
return !this.isDestroyed && this.scheduleGeneration(owner.threadId) === owner.generation;
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
threadName: id => this.threadManager.getThread(id)?.name ?? id,
|
|
246
|
+
records: owner => this.schedules.list(owner),
|
|
247
|
+
canCancel: (owner, id) => this.schedules.canCancel(owner, id),
|
|
248
|
+
refresh: owner => this.schedules.refresh(owner),
|
|
249
|
+
cancel: (owner, id) => this.schedules.cancel(owner, id),
|
|
250
|
+
exclusive: async (owner, body) => {
|
|
251
|
+
if (!this.schedules || this.isDestroyed || this.automaticUpdateInProgress
|
|
252
|
+
|| this.scheduleManagement.has(owner.threadId))
|
|
253
|
+
throw new Error('Schedule controls are busy.');
|
|
254
|
+
this.scheduleManagement.add(owner.threadId);
|
|
255
|
+
try {
|
|
256
|
+
return await body();
|
|
257
|
+
}
|
|
258
|
+
finally {
|
|
259
|
+
this.scheduleManagement.delete(owner.threadId);
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
});
|
|
228
263
|
this.wsClient.onClose?.(() => {
|
|
229
264
|
this.imageConnectionEpoch++;
|
|
230
265
|
this.scheduleResultsSupported = false;
|
|
266
|
+
this.scheduleCardsSupported = false;
|
|
267
|
+
this.scheduleToolCardsSupported = false;
|
|
268
|
+
this.clearScheduleCardReceipts();
|
|
269
|
+
this.scheduleCards.invalidate();
|
|
231
270
|
this.routerVersion = undefined;
|
|
232
271
|
this.fileInbox?.disconnect();
|
|
233
272
|
this.outputFiles?.disconnect();
|
|
@@ -330,6 +369,26 @@ class MessageHandler {
|
|
|
330
369
|
case 'command':
|
|
331
370
|
await this.handleCommandMessage(message, this.fileInbox?.mark());
|
|
332
371
|
return;
|
|
372
|
+
case 'schedule_tool_card_ack': {
|
|
373
|
+
if (!this.scheduleToolCardsSupported || typeof message.messageId !== 'string')
|
|
374
|
+
return;
|
|
375
|
+
const pending = this.scheduleCardReceipts.get(message.messageId);
|
|
376
|
+
if (pending && typeof message.success === 'boolean') {
|
|
377
|
+
clearTimeout(pending.timer);
|
|
378
|
+
this.scheduleCardReceipts.delete(message.messageId);
|
|
379
|
+
pending.resolve(message.success ? 'Management card delivered.' : 'Management card unavailable. Use /schedule list; do not recreate the task.');
|
|
380
|
+
}
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
case 'schedule_action': {
|
|
384
|
+
if (!this.scheduleCardsSupported || !this.schedules)
|
|
385
|
+
return;
|
|
386
|
+
const epoch = this.imageConnectionEpoch;
|
|
387
|
+
const result = await this.scheduleCards.action(message);
|
|
388
|
+
if (!this.isDestroyed && this.scheduleCardsSupported && epoch === this.imageConnectionEpoch)
|
|
389
|
+
this.wsClient.send(result);
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
333
392
|
case 'settings_action':
|
|
334
393
|
if (this.settingsCardsSupported) {
|
|
335
394
|
const request = message;
|
|
@@ -374,6 +433,8 @@ class MessageHandler {
|
|
|
374
433
|
this.pendingOutputSupported = data.capabilities?.pendingOutputFilesV1 === true;
|
|
375
434
|
this.routerVersion = typeof data.routerVersion === 'string' ? data.routerVersion : undefined;
|
|
376
435
|
this.scheduleResultsSupported = data.capabilities?.scheduleResultsV1 === true;
|
|
436
|
+
this.scheduleCardsSupported = this.scheduleResultsSupported && data.capabilities?.scheduleCardsV1 === true;
|
|
437
|
+
this.scheduleToolCardsSupported = this.scheduleCardsSupported && data.capabilities?.scheduleToolCardsV1 === true;
|
|
377
438
|
if (this.scheduleResultsSupported) {
|
|
378
439
|
void this.recoverSchedules().catch(() => {
|
|
379
440
|
if (this.isDestroyed || !this.scheduleResultsSupported)
|
|
@@ -2348,6 +2409,8 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2348
2409
|
throw new Error('Conversation request was cancelled'); };
|
|
2349
2410
|
this.sendStreamContext(messageId, threadId, executor);
|
|
2350
2411
|
let delegationScope;
|
|
2412
|
+
let scheduleScope;
|
|
2413
|
+
let clearScheduleModelOverride;
|
|
2351
2414
|
let delegationBridge;
|
|
2352
2415
|
let executionMetadata;
|
|
2353
2416
|
let requestFinished = false;
|
|
@@ -2414,6 +2477,12 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2414
2477
|
}
|
|
2415
2478
|
const responseError = fromQueue && !success
|
|
2416
2479
|
? this.pauseQueueAfterFailure(threadId, error || 'Queued command failed') : error;
|
|
2480
|
+
const scheduleFailures = scheduleScope?.unreportedFailures() ?? [];
|
|
2481
|
+
if (scheduleFailures.length) {
|
|
2482
|
+
const details = scheduleFailures.slice(0, 5).map(result => `${result.requestId}: ${result.error ?? 'Operation failed.'}${result.scheduleId ? `\nTask reference: ${result.scheduleId}` : ''}`).join('\n\n');
|
|
2483
|
+
const fence = '`'.repeat(Math.max(3, ...Array.from(details.matchAll(/`+/g), match => match[0].length + 1)));
|
|
2484
|
+
this.sendStreamChunk(messageId, threadId, `\nScheduled operation failed after its pending receipt:\n${fence}text\n${details}\n${fence}\nUse /schedule list to inspect the final task state before retrying.\n`);
|
|
2485
|
+
}
|
|
2417
2486
|
this.sendResponse(messageId, threadId, { success, error: responseError, threads: this.threadPool.getSummaries(), executionMetadata, attachmentHints: outputAttachmentHints });
|
|
2418
2487
|
if (fromQueue)
|
|
2419
2488
|
console.log(`[MessageHandler] Finished queued message ${messageId} in thread ${threadId}: success=${success}, remaining=${this.threadQueues.get(threadId)?.length ?? 0}, paused=${this.pausedQueues.has(threadId)}`);
|
|
@@ -2435,6 +2504,11 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2435
2504
|
}
|
|
2436
2505
|
await this.delegation.assertExecutionSafe(executor.getCurrentWorkingDirectory(), threadId);
|
|
2437
2506
|
assertCurrent();
|
|
2507
|
+
if ((goalRequest || !openId) && executor.configureManagedTools && this.delegationBridges.has(threadId)) {
|
|
2508
|
+
await executor.configureManagedTools(undefined);
|
|
2509
|
+
assertCurrent();
|
|
2510
|
+
this.detachDelegationBridge(threadId);
|
|
2511
|
+
}
|
|
2438
2512
|
if (thread && (0, DelegationSettings_1.isDelegationEnabled)(thread) && executor.configureDelegation) {
|
|
2439
2513
|
const backend = this.threadPool.getBackendKey(threadId);
|
|
2440
2514
|
if (!thread.delegationBackends?.includes(backend)) {
|
|
@@ -2482,18 +2556,69 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2482
2556
|
}), });
|
|
2483
2557
|
delegationBridge = this.delegationBridges.get(threadId) ?? new DelegationBridge_1.DelegationBridge();
|
|
2484
2558
|
this.delegationBridges.set(threadId, delegationBridge);
|
|
2485
|
-
const connection = await delegationBridge.start();
|
|
2559
|
+
const connection = await delegationBridge.start(executor.configureManagedTools && openId && !goalRequest ? ['delegation', 'scheduling'] : undefined);
|
|
2486
2560
|
assertCurrent();
|
|
2487
|
-
await executor.configureDelegation(connection);
|
|
2561
|
+
await (executor.configureManagedTools ?? executor.configureDelegation).call(executor, connection);
|
|
2488
2562
|
assertCurrent();
|
|
2489
2563
|
if (delegationScope.isClosed() || this.isDestroyed || this.abortOperations.has(threadId)) {
|
|
2490
2564
|
throw new Error('Delegation was cancelled before the coordinator started');
|
|
2491
2565
|
}
|
|
2492
2566
|
content = `${contract_1.DELEGATION_INSTRUCTIONS}\n\nUser request:\n${content}`;
|
|
2493
2567
|
}
|
|
2494
|
-
else if (
|
|
2568
|
+
else if ((!executor.configureManagedTools || goalRequest || !openId)
|
|
2569
|
+
&& thread?.delegationBackends?.includes(this.threadPool.getBackendKey(threadId)) && executor.configureDelegation) {
|
|
2495
2570
|
await executor.configureDelegation(undefined);
|
|
2496
2571
|
}
|
|
2572
|
+
if (thread && openId && !goalRequest && executor.configureManagedTools) {
|
|
2573
|
+
const owner = { threadId, openId, generation: this.scheduleGeneration(threadId) };
|
|
2574
|
+
const epoch = this.imageConnectionEpoch;
|
|
2575
|
+
const backend = this.threadPool.getBackendKey(threadId);
|
|
2576
|
+
const config = structuredClone(this.executorConfiguration());
|
|
2577
|
+
let settings = JSON.stringify({ config, models: thread.models, model: thread.model, efforts: thread.efforts });
|
|
2578
|
+
const context = { backend, config, cwd: thread.workingDirectory,
|
|
2579
|
+
model: thread.models?.[backend] ?? (backend === 'claude' ? thread.model || undefined : config[backend]?.model),
|
|
2580
|
+
effort: thread.efforts?.[backend],
|
|
2581
|
+
current: () => {
|
|
2582
|
+
try {
|
|
2583
|
+
const latest = this.threadManager.getThread(threadId);
|
|
2584
|
+
return isCurrent() && !this.abortOperations.has(threadId) && !this.automaticUpdateInProgress && this.wsClient.isConnected()
|
|
2585
|
+
&& epoch === this.imageConnectionEpoch && this.scheduleGeneration(threadId) === owner.generation
|
|
2586
|
+
&& this.threadPool.getBackendKey(threadId) === backend && !!latest
|
|
2587
|
+
&& JSON.stringify({ config: this.executorConfiguration(), models: latest.models, model: latest.model, efforts: latest.efforts }) === settings;
|
|
2588
|
+
}
|
|
2589
|
+
catch {
|
|
2590
|
+
return false;
|
|
2591
|
+
}
|
|
2592
|
+
} };
|
|
2593
|
+
clearScheduleModelOverride = () => {
|
|
2594
|
+
// Match only the authorized recovery mutation. Other concurrent policy
|
|
2595
|
+
// or model changes still fail the captured-context comparison.
|
|
2596
|
+
const captured = JSON.parse(settings);
|
|
2597
|
+
if (captured.models)
|
|
2598
|
+
delete captured.models.codex;
|
|
2599
|
+
settings = JSON.stringify(captured);
|
|
2600
|
+
context.model = config.codex?.model;
|
|
2601
|
+
};
|
|
2602
|
+
if (!delegationBridge) {
|
|
2603
|
+
delegationBridge = this.delegationBridges.get(threadId) ?? new DelegationBridge_1.DelegationBridge();
|
|
2604
|
+
this.delegationBridges.set(threadId, delegationBridge);
|
|
2605
|
+
const connection = await delegationBridge.start(['scheduling']);
|
|
2606
|
+
assertCurrent();
|
|
2607
|
+
await executor.configureManagedTools(connection);
|
|
2608
|
+
assertCurrent();
|
|
2609
|
+
}
|
|
2610
|
+
scheduleScope = this.scheduleToolOperations.scope({ owner, messageId, backend, current: context.current,
|
|
2611
|
+
run: (command, id) => this.runScheduleOperation(owner, command, id, context),
|
|
2612
|
+
present: async (records, operationId) => {
|
|
2613
|
+
if (!context.current() || !this.scheduleToolCardsSupported)
|
|
2614
|
+
return 'Management card unavailable. Use /schedule list; do not recreate the task.';
|
|
2615
|
+
const menu = this.scheduleCards.open(owner, records);
|
|
2616
|
+
return this.deliverScheduleToolCard({ type: 'schedule_tool_card', messageId: `schedule-card-${operationId}`,
|
|
2617
|
+
parentMessageId: messageId, openId, threadId, menu, timestamp: Date.now() });
|
|
2618
|
+
},
|
|
2619
|
+
});
|
|
2620
|
+
content = `${(0, toolContract_1.scheduleGuidance)()}\n\nUser request:\n${content}`;
|
|
2621
|
+
}
|
|
2497
2622
|
// Retain the callback so native completion tracking consumes late items
|
|
2498
2623
|
// and deduplicates them without adding background output to another turn.
|
|
2499
2624
|
const onTaskNotification = (_notification) => { };
|
|
@@ -2616,11 +2741,13 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2616
2741
|
showState('Working');
|
|
2617
2742
|
scope?.beginExecution(continuationResults.map(task => task.taskId));
|
|
2618
2743
|
const launchRevision = scope?.getLaunchRevision();
|
|
2619
|
-
if (scope)
|
|
2620
|
-
delegationBridge?.activate((
|
|
2621
|
-
if (!active)
|
|
2744
|
+
if (scope || scheduleScope)
|
|
2745
|
+
delegationBridge?.activate((name, args, callId) => {
|
|
2746
|
+
if (!active || !isCurrent())
|
|
2622
2747
|
return Promise.reject(new Error('The coordinator execution has ended'));
|
|
2623
|
-
|
|
2748
|
+
if (name.startsWith('remote_cli_schedule_') && scheduleScope)
|
|
2749
|
+
return scheduleScope.invoke(name, args);
|
|
2750
|
+
return scope ? scope.invoke(name, args, callId) : Promise.reject(new Error('Delegation is disabled for this turn.'));
|
|
2624
2751
|
});
|
|
2625
2752
|
const canPublish = () => isCurrent() && active && (!scope || (!scope.isClosed() && !scope.hasPendingResults()));
|
|
2626
2753
|
const guardedOptions = {
|
|
@@ -2746,7 +2873,8 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2746
2873
|
if (!finished)
|
|
2747
2874
|
scope?.finishExecution(false);
|
|
2748
2875
|
// Goal activation mutates durable native state; never replay it as a model retry.
|
|
2749
|
-
|
|
2876
|
+
await scheduleScope?.drain();
|
|
2877
|
+
mayRetry = !goalRequest && !scheduleScope?.hasSideEffects && (!scope || scope.getLaunchRevision() === launchRevision);
|
|
2750
2878
|
}
|
|
2751
2879
|
};
|
|
2752
2880
|
finishPreparation();
|
|
@@ -2764,6 +2892,7 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2764
2892
|
return this.clearInvalidCodexModel(threadId, executor, result.error);
|
|
2765
2893
|
})) {
|
|
2766
2894
|
assertCoordinatorActive();
|
|
2895
|
+
clearScheduleModelOverride?.();
|
|
2767
2896
|
this.sendStreamChunk(messageId, threadId, '⚠️ The saved Codex model is unavailable for this account. Cleared it and retrying with the backend default...\n');
|
|
2768
2897
|
// Retain the ordinary path's existing image-flush timing on model retry.
|
|
2769
2898
|
result = await executeOnce(prompt, options, !!delegationScope);
|
|
@@ -2838,6 +2967,8 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2838
2967
|
}
|
|
2839
2968
|
finally {
|
|
2840
2969
|
finishPreparation();
|
|
2970
|
+
await scheduleScope?.close();
|
|
2971
|
+
delegationBridge?.activate(undefined);
|
|
2841
2972
|
if (delegationBridge && this.delegationBridges.get(threadId) !== delegationBridge) {
|
|
2842
2973
|
void delegationBridge.close().catch(() => undefined);
|
|
2843
2974
|
}
|
|
@@ -3144,6 +3275,7 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
3144
3275
|
threads: result.threads,
|
|
3145
3276
|
queueConfirmation: result.queueConfirmation,
|
|
3146
3277
|
...(result.executionMetadata ? { executionMetadata: result.executionMetadata } : {}),
|
|
3278
|
+
...(this.scheduleCardsSupported && result.scheduleMenu ? { scheduleMenu: result.scheduleMenu } : {}),
|
|
3147
3279
|
...(this.attachmentHintsSupported && result.attachmentHints ? { attachmentHints: result.attachmentHints } : {}),
|
|
3148
3280
|
...(this.settingsCardsSupported && result.settingsMenu
|
|
3149
3281
|
&& (result.settingsMenu.kind !== 'delegation' || this.delegationCardsSupported)
|
|
@@ -3181,7 +3313,7 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
3181
3313
|
})).digest('hex');
|
|
3182
3314
|
return path_1.default.join(directory, 'schedules', namespace);
|
|
3183
3315
|
}
|
|
3184
|
-
/** Binding recovery only reads existing storage;
|
|
3316
|
+
/** Binding recovery only reads existing storage; explicit command/tool use initializes it. */
|
|
3185
3317
|
async recoverSchedules() {
|
|
3186
3318
|
if (this.isDestroyed || !this.scheduleResultsSupported)
|
|
3187
3319
|
return;
|
|
@@ -3264,9 +3396,109 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
3264
3396
|
throw new Error('Cancel this thread\'s schedules with /schedule cancel <id> before resetting context, changing directory, or deleting the thread.');
|
|
3265
3397
|
}
|
|
3266
3398
|
}
|
|
3399
|
+
clearScheduleCardReceipts() {
|
|
3400
|
+
for (const pending of this.scheduleCardReceipts.values()) {
|
|
3401
|
+
clearTimeout(pending.timer);
|
|
3402
|
+
pending.resolve('Management card delivery is unknown. Use /schedule list; do not recreate the task.');
|
|
3403
|
+
}
|
|
3404
|
+
this.scheduleCardReceipts.clear();
|
|
3405
|
+
}
|
|
3406
|
+
deliverScheduleToolCard(message) {
|
|
3407
|
+
if (this.scheduleCardReceipts.size >= 5)
|
|
3408
|
+
return Promise.resolve('Management card limit reached. Use /schedule list.');
|
|
3409
|
+
return new Promise(resolve => {
|
|
3410
|
+
const timer = setTimeout(() => {
|
|
3411
|
+
this.scheduleCardReceipts.delete(message.messageId);
|
|
3412
|
+
resolve('Management card delivery is unknown. Use /schedule list; do not recreate the task.');
|
|
3413
|
+
}, 8000);
|
|
3414
|
+
this.scheduleCardReceipts.set(message.messageId, { resolve, timer });
|
|
3415
|
+
try {
|
|
3416
|
+
if (this.wsClient.send(message))
|
|
3417
|
+
return;
|
|
3418
|
+
}
|
|
3419
|
+
catch { /* The native operation already succeeded. */ }
|
|
3420
|
+
clearTimeout(timer);
|
|
3421
|
+
this.scheduleCardReceipts.delete(message.messageId);
|
|
3422
|
+
resolve('Management card unavailable. Use /schedule list; do not recreate the task.');
|
|
3423
|
+
});
|
|
3424
|
+
}
|
|
3425
|
+
/** Shared admission for slash commands and scoped model tools. Native providers alone own timing. */
|
|
3426
|
+
async runScheduleOperation(owner, command, id = (0, uuid_1.v4)(), context) {
|
|
3427
|
+
const current = () => {
|
|
3428
|
+
try {
|
|
3429
|
+
return !this.isDestroyed && this.scheduleGeneration(owner.threadId) === owner.generation && (!context || context.current());
|
|
3430
|
+
}
|
|
3431
|
+
catch {
|
|
3432
|
+
return false;
|
|
3433
|
+
}
|
|
3434
|
+
};
|
|
3435
|
+
const check = () => { if (!current() || this.automaticUpdateInProgress)
|
|
3436
|
+
throw new Error('Scheduling context changed or client is shutting down/updating.'); };
|
|
3437
|
+
check();
|
|
3438
|
+
if (this.scheduleManagement.has(owner.threadId))
|
|
3439
|
+
throw new Error('A schedule operation is already in progress for this thread.');
|
|
3440
|
+
this.scheduleManagement.add(owner.threadId);
|
|
3441
|
+
try {
|
|
3442
|
+
const backend = context?.backend ?? this.threadPool.getBackendKey(owner.threadId);
|
|
3443
|
+
const config = context?.config ?? this.executorConfiguration();
|
|
3444
|
+
if (command.kind === 'create') {
|
|
3445
|
+
(0, ScheduleCapabilities_1.assertNativeScheduleBackend)(backend);
|
|
3446
|
+
if (!this.scheduleResultsSupported || !this.wsClient.isConnected())
|
|
3447
|
+
throw new Error('Schedule creation requires a connected Router with scheduleResultsV1 support.');
|
|
3448
|
+
if (backend === 'claude' && new ClaudeSandbox_1.ClaudeSandbox(this.directoryGuard, config.claude?.sandbox, owner.threadId).isRestricted()) {
|
|
3449
|
+
throw new Error('This native scheduling adapter does not support restricted Claude sandboxes. No schedule was created and sandbox settings were not changed.');
|
|
3450
|
+
}
|
|
3451
|
+
}
|
|
3452
|
+
const service = await this.initializeSchedules();
|
|
3453
|
+
check();
|
|
3454
|
+
if (command.kind === 'list') {
|
|
3455
|
+
await service.refresh(owner);
|
|
3456
|
+
check();
|
|
3457
|
+
void service.retryDeliveries().catch(() => { });
|
|
3458
|
+
return service.list(owner);
|
|
3459
|
+
}
|
|
3460
|
+
if (command.kind === 'cancel')
|
|
3461
|
+
return [await service.cancel(owner, command.id)];
|
|
3462
|
+
(0, ScheduleCapabilities_1.assertNativeScheduleBackend)(backend);
|
|
3463
|
+
// A durable record fences retries after lost in-memory receipts or a process restart.
|
|
3464
|
+
if ((await service.list(owner)).some(record => record.id === id))
|
|
3465
|
+
throw new Error(`Schedule ${id} already has a durable record. Use /schedule list; it was not recreated.`);
|
|
3466
|
+
check();
|
|
3467
|
+
const thread = this.threadManager.getThread(owner.threadId);
|
|
3468
|
+
const cwd = this.directoryGuard.resolveWorkingDirectory(context?.cwd ?? thread.workingDirectory);
|
|
3469
|
+
(0, WorkingDirectory_1.assertWorkingDirectoryExists)(cwd);
|
|
3470
|
+
const existingOwner = this.scheduleOwners.get(owner.threadId);
|
|
3471
|
+
if (existingOwner && existingOwner.openId !== owner.openId && (await this.activeSchedules(owner.threadId)).length)
|
|
3472
|
+
throw new Error('This thread has schedules belonging to a different owner.');
|
|
3473
|
+
check();
|
|
3474
|
+
this.scheduleOwners.set(owner.threadId, owner);
|
|
3475
|
+
const record = await service.create(owner, { id, backend, cwd, rule: command.rule, prompt: command.prompt,
|
|
3476
|
+
command: config[backend]?.command,
|
|
3477
|
+
model: context ? context.model : thread.models?.[backend] ?? (backend === 'claude' ? thread.model || undefined : config.dsh?.model),
|
|
3478
|
+
effort: context ? context.effort : thread.efforts?.[backend] });
|
|
3479
|
+
if (!current()) {
|
|
3480
|
+
await service.cancel(owner, record.id);
|
|
3481
|
+
throw new Error('Scheduling context retired during creation; the native task was cancelled.');
|
|
3482
|
+
}
|
|
3483
|
+
return [record];
|
|
3484
|
+
}
|
|
3485
|
+
finally {
|
|
3486
|
+
this.scheduleManagement.delete(owner.threadId);
|
|
3487
|
+
await this.activeSchedules(owner.threadId).catch(() => undefined);
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3267
3490
|
async handleScheduleCommand(message, threadId) {
|
|
3268
3491
|
const respond = (result) => this.sendResponse(message.messageId, threadId, result, true);
|
|
3269
|
-
|
|
3492
|
+
const menuFor = (owner, records) => {
|
|
3493
|
+
if (!this.scheduleCardsSupported)
|
|
3494
|
+
return undefined;
|
|
3495
|
+
try {
|
|
3496
|
+
return this.scheduleCards.open(owner, records);
|
|
3497
|
+
}
|
|
3498
|
+
catch {
|
|
3499
|
+
return undefined;
|
|
3500
|
+
} // A presentation failure must not turn successful native work into a failed command.
|
|
3501
|
+
};
|
|
3270
3502
|
try {
|
|
3271
3503
|
const command = (0, ScheduleCommand_1.parseScheduleCommand)(message.content ?? '');
|
|
3272
3504
|
if (!command || command.kind === 'help') {
|
|
@@ -3287,74 +3519,24 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
3287
3519
|
throw new Error('Use /cd first and include a self-contained text prompt. Schedule commands do not accept attachments or directory overrides.');
|
|
3288
3520
|
}
|
|
3289
3521
|
const owner = { threadId, openId: message.openId, generation: this.scheduleGeneration(threadId) };
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
const records = await service.list(owner);
|
|
3300
|
-
void service.retryDeliveries().catch(() => { });
|
|
3301
|
-
await this.activeSchedules(threadId);
|
|
3302
|
-
respond({ success: true, output: records.length ? records.map(record => `${record.id} — ${record.state}\n${record.rule.kind === 'once' ? record.rule.at : `${record.rule.expression} (${record.rule.timezone})`}\n${record.prompt.slice(0, 240)}${record.error ? `\n${record.error}` : ''}`).join('\n\n') : 'No schedules in this thread. Use /schedule for examples.' });
|
|
3303
|
-
return;
|
|
3304
|
-
}
|
|
3305
|
-
try {
|
|
3306
|
-
if (command.kind === 'cancel') {
|
|
3307
|
-
const record = await service.cancel(owner, command.id);
|
|
3308
|
-
respond({ success: true, output: `Schedule ${record.id}: ${record.state}.` });
|
|
3309
|
-
return;
|
|
3310
|
-
}
|
|
3311
|
-
if (command.kind !== 'create')
|
|
3312
|
-
throw new Error('Unknown schedule operation.');
|
|
3313
|
-
if (this.isDestroyed || this.automaticUpdateInProgress)
|
|
3314
|
-
throw new Error('The client is updating or shutting down. No schedule was created.');
|
|
3315
|
-
if (!this.scheduleResultsSupported || !this.wsClient.isConnected()) {
|
|
3316
|
-
throw new Error('Schedule creation requires a connected Router with scheduleResultsV1 support. Update both CLI and Router.');
|
|
3317
|
-
}
|
|
3318
|
-
const backend = this.threadPool.getBackendKey(threadId);
|
|
3319
|
-
(0, ScheduleCapabilities_1.assertNativeScheduleBackend)(backend);
|
|
3320
|
-
const config = this.executorConfiguration();
|
|
3321
|
-
if (backend === 'claude' && new ClaudeSandbox_1.ClaudeSandbox(this.directoryGuard, config.claude?.sandbox, threadId).isRestricted()) {
|
|
3322
|
-
throw new Error('This native scheduling adapter does not support restricted Claude sandboxes. No schedule was created and sandbox settings were not changed.');
|
|
3323
|
-
}
|
|
3324
|
-
const thread = this.threadManager.getThread(threadId);
|
|
3325
|
-
const cwd = this.directoryGuard.resolveWorkingDirectory(thread.workingDirectory);
|
|
3326
|
-
(0, WorkingDirectory_1.assertWorkingDirectoryExists)(cwd);
|
|
3327
|
-
const existingOwner = this.scheduleOwners.get(threadId);
|
|
3328
|
-
if (existingOwner && existingOwner.openId !== owner.openId && (await this.activeSchedules(threadId)).length) {
|
|
3329
|
-
throw new Error('This thread has schedules belonging to a different owner.');
|
|
3330
|
-
}
|
|
3331
|
-
this.scheduleOwners.set(threadId, owner);
|
|
3332
|
-
const record = await service.create(owner, {
|
|
3333
|
-
id: (0, uuid_1.v4)(), backend, cwd, rule: command.rule, prompt: command.prompt,
|
|
3334
|
-
command: config[backend]?.command,
|
|
3335
|
-
model: thread.models?.[backend] ?? (backend === 'claude' ? thread.model || undefined : config.dsh?.model),
|
|
3336
|
-
effort: thread.efforts?.[backend],
|
|
3337
|
-
});
|
|
3338
|
-
const lifecycle = backend === 'claude'
|
|
3522
|
+
const records = await this.runScheduleOperation(owner, command.kind === 'list' ? { kind: 'list' } : command);
|
|
3523
|
+
const record = records[0];
|
|
3524
|
+
let output;
|
|
3525
|
+
if (command.kind === 'list')
|
|
3526
|
+
output = records.length ? records.map(item => `${item.id} — ${item.state}\n${item.rule.kind === 'once' ? item.rule.at : `${item.rule.expression} (${item.rule.timezone})`}\n${item.prompt.slice(0, 240)}${item.error ? `\n${item.error}` : ''}`).join('\n\n') : 'No schedules in this thread. Use /schedule for examples.';
|
|
3527
|
+
else if (command.kind === 'cancel')
|
|
3528
|
+
output = `Schedule ${record.id}: ${record.state}.`;
|
|
3529
|
+
else {
|
|
3530
|
+
const lifecycle = record.backend === 'claude'
|
|
3339
3531
|
? 'Schedules are lost when the native process exits; recurring tasks expire after seven days.'
|
|
3340
3532
|
: 'Native job storage is isolated and is never automatically reopened after process exit.';
|
|
3341
|
-
|
|
3342
|
-
}
|
|
3343
|
-
finally {
|
|
3344
|
-
this.scheduleManagement.delete(threadId);
|
|
3345
|
-
reserved = false;
|
|
3346
|
-
await this.activeSchedules(threadId).catch(() => undefined);
|
|
3533
|
+
output = `Schedule ${record.id}: ${record.state}.\n${record.rule.kind === 'once' ? record.rule.at : `${record.rule.expression} (${record.rule.timezone})`}\n\nRuns in its own ${ScheduleCapabilities_1.NATIVE_SCHEDULE_CAPABILITIES[record.backend].label} session and returns results to this thread. Keep the CLI running; native timing is approximate. ${lifecycle}\nUse /schedule list or /schedule cancel ${record.id}.`;
|
|
3347
3534
|
}
|
|
3535
|
+
respond({ success: true, scheduleMenu: menuFor(owner, records), output });
|
|
3348
3536
|
}
|
|
3349
3537
|
catch (error) {
|
|
3350
3538
|
respond({ success: false, error: error instanceof Error ? error.message : 'Schedule operation failed.' });
|
|
3351
3539
|
}
|
|
3352
|
-
finally {
|
|
3353
|
-
if (reserved) {
|
|
3354
|
-
this.scheduleManagement.delete(threadId);
|
|
3355
|
-
await this.activeSchedules(threadId).catch(() => undefined);
|
|
3356
|
-
}
|
|
3357
|
-
}
|
|
3358
3540
|
}
|
|
3359
3541
|
/** Shared card/text Apply path. Callers hold exclusive settings admission. */
|
|
3360
3542
|
async changeWorkingDirectory(threadId, targetDir) {
|
|
@@ -3673,6 +3855,8 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
3673
3855
|
async destroy() {
|
|
3674
3856
|
this.directoryBrowser.destroy();
|
|
3675
3857
|
this.settingsService.destroy();
|
|
3858
|
+
this.scheduleCards.destroy();
|
|
3859
|
+
this.clearScheduleCardReceipts();
|
|
3676
3860
|
this.isDestroyed = true;
|
|
3677
3861
|
this.scheduleDelivery?.destroy();
|
|
3678
3862
|
this.pendingOutputFiles.clear();
|