@yu_robotics/remote-cli 1.6.232 → 1.6.235
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 +325 -75
- 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 +14 -1
- package/dist/executor/AcpExecutor.d.ts.map +1 -1
- package/dist/executor/AcpExecutor.js +28 -6
- 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 +15 -0
- package/dist/executor/ClaudePersistentExecutor.d.ts.map +1 -1
- package/dist/executor/ClaudePersistentExecutor.js +191 -11
- 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/DshExecutor.d.ts +1 -0
- package/dist/executor/DshExecutor.d.ts.map +1 -1
- package/dist/executor/DshExecutor.js +14 -0
- package/dist/executor/DshExecutor.js.map +1 -1
- package/dist/executor/IExecutor.d.ts +7 -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/acp/AcpClient.d.ts +4 -3
- package/dist/executor/acp/AcpClient.d.ts.map +1 -1
- package/dist/executor/acp/AcpClient.js.map +1 -1
- package/dist/executor/dsh/DshAcpClient.d.ts +9 -0
- package/dist/executor/dsh/DshAcpClient.d.ts.map +1 -1
- package/dist/executor/dsh/DshAcpClient.js +72 -2
- package/dist/executor/dsh/DshAcpClient.js.map +1 -1
- package/dist/executor/dsh/DshPrivacy.d.ts +1 -1
- package/dist/executor/dsh/DshPrivacy.d.ts.map +1 -1
- package/dist/executor/dsh/DshPrivacy.js +3 -3
- package/dist/executor/dsh/DshPrivacy.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/ScheduleCapabilities.d.ts +5 -7
- package/dist/scheduling/ScheduleCapabilities.d.ts.map +1 -1
- package/dist/scheduling/ScheduleCapabilities.js +6 -7
- package/dist/scheduling/ScheduleCapabilities.js.map +1 -1
- 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/ScheduleCommand.js +1 -1
- package/dist/scheduling/ScheduleCommand.js.map +1 -1
- package/dist/scheduling/ScheduleService.d.ts +2 -0
- package/dist/scheduling/ScheduleService.d.ts.map +1 -1
- package/dist/scheduling/ScheduleService.js +47 -16
- package/dist/scheduling/ScheduleService.js.map +1 -1
- package/dist/scheduling/ScheduleToolScope.d.ts +56 -0
- package/dist/scheduling/ScheduleToolScope.d.ts.map +1 -0
- package/dist/scheduling/ScheduleToolScope.js +184 -0
- package/dist/scheduling/ScheduleToolScope.js.map +1 -0
- package/dist/scheduling/claude/ClaudeSessionSchedules.d.ts +82 -0
- package/dist/scheduling/claude/ClaudeSessionSchedules.d.ts.map +1 -0
- package/dist/scheduling/claude/ClaudeSessionSchedules.js +457 -0
- package/dist/scheduling/claude/ClaudeSessionSchedules.js.map +1 -0
- package/dist/scheduling/dsh/SessionScheduleBridge.d.ts +35 -0
- package/dist/scheduling/dsh/SessionScheduleBridge.d.ts.map +1 -0
- package/dist/scheduling/dsh/SessionScheduleBridge.js +300 -0
- package/dist/scheduling/dsh/SessionScheduleBridge.js.map +1 -0
- package/dist/scheduling/dsh/SessionScheduleClient.d.ts +15 -0
- package/dist/scheduling/dsh/SessionScheduleClient.d.ts.map +1 -0
- package/dist/scheduling/dsh/SessionScheduleClient.js +182 -0
- package/dist/scheduling/dsh/SessionScheduleClient.js.map +1 -0
- package/dist/scheduling/dsh/SessionScheduleStorage.d.ts +8 -0
- package/dist/scheduling/dsh/SessionScheduleStorage.d.ts.map +1 -0
- package/dist/scheduling/dsh/SessionScheduleStorage.js +34 -0
- package/dist/scheduling/dsh/SessionScheduleStorage.js.map +1 -0
- package/dist/scheduling/dsh/sessionLaunch.d.ts +3 -0
- package/dist/scheduling/dsh/sessionLaunch.d.ts.map +1 -0
- package/dist/scheduling/dsh/sessionLaunch.js +22 -0
- package/dist/scheduling/dsh/sessionLaunch.js.map +1 -0
- package/dist/scheduling/dsh/sessionProtocol.d.ts +4 -0
- package/dist/scheduling/dsh/sessionProtocol.d.ts.map +1 -0
- package/dist/scheduling/dsh/sessionProtocol.js +7 -0
- package/dist/scheduling/dsh/sessionProtocol.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/scheduling/types.d.ts +11 -2
- package/dist/scheduling/types.d.ts.map +1 -1
- package/dist/scheduling/types.js.map +1 -1
- 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,CAA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N,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");
|
|
@@ -52,8 +55,6 @@ const adapters_1 = require("../session/adapters");
|
|
|
52
55
|
const PiSessionCatalog_1 = require("../session/adapters/PiSessionCatalog");
|
|
53
56
|
const SessionControl_1 = require("../session/SessionControl");
|
|
54
57
|
const ScheduleService_1 = require("../scheduling/ScheduleService");
|
|
55
|
-
const ClaudeNativeScheduleProvider_1 = require("../scheduling/ClaudeNativeScheduleProvider");
|
|
56
|
-
const DshNativeScheduleProvider_1 = require("../scheduling/DshNativeScheduleProvider");
|
|
57
58
|
const ScheduleDeliveryClient_1 = require("../scheduling/ScheduleDeliveryClient");
|
|
58
59
|
const ScheduleCommand_1 = require("../scheduling/ScheduleCommand");
|
|
59
60
|
const ScheduleCapabilities_1 = require("../scheduling/ScheduleCapabilities");
|
|
@@ -214,6 +215,11 @@ class MessageHandler {
|
|
|
214
215
|
pendingOutputFiles = new PendingOutputFiles_1.PendingOutputFiles();
|
|
215
216
|
imageConnectionEpoch = 0;
|
|
216
217
|
scheduleResultsSupported = false;
|
|
218
|
+
scheduleCardsSupported = false;
|
|
219
|
+
scheduleToolCardsSupported = false;
|
|
220
|
+
scheduleToolOperations = new ScheduleToolScope_1.ScheduleToolOperations();
|
|
221
|
+
scheduleCardReceipts = new Map();
|
|
222
|
+
scheduleCards;
|
|
217
223
|
schedules;
|
|
218
224
|
scheduleInitialization;
|
|
219
225
|
scheduleDelivery;
|
|
@@ -225,9 +231,53 @@ class MessageHandler {
|
|
|
225
231
|
this.threadManager = threadManager;
|
|
226
232
|
this.directoryGuard = directoryGuard;
|
|
227
233
|
this.config = config;
|
|
234
|
+
this.scheduleCards = new ScheduleCardService_1.ScheduleCardService({
|
|
235
|
+
current: owner => {
|
|
236
|
+
try {
|
|
237
|
+
return !this.isDestroyed && this.scheduleGeneration(owner.threadId) === owner.generation;
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
threadName: id => this.threadManager.getThread(id)?.name ?? id,
|
|
244
|
+
records: owner => this.schedules.list(owner),
|
|
245
|
+
canCancel: (owner, id) => this.schedules.canCancel(owner, id),
|
|
246
|
+
refresh: owner => this.schedules.refresh(owner),
|
|
247
|
+
cancel: (owner, id) => this.schedules.cancel(owner, id),
|
|
248
|
+
exclusive: async (owner, body) => {
|
|
249
|
+
if (!this.schedules || this.isDestroyed || this.automaticUpdateInProgress
|
|
250
|
+
|| this.scheduleManagement.has(owner.threadId))
|
|
251
|
+
throw new Error('Schedule controls are busy.');
|
|
252
|
+
this.scheduleManagement.add(owner.threadId);
|
|
253
|
+
try {
|
|
254
|
+
const executor = this.threadPool.getExecutor(owner.threadId);
|
|
255
|
+
if (this.threadPool.getBackendKey(owner.threadId) !== 'claude' || !executor.withNativeScheduleOperation
|
|
256
|
+
|| !this.schedules.hasActiveSchedules(owner.threadId))
|
|
257
|
+
return await body();
|
|
258
|
+
const epoch = this.imageConnectionEpoch;
|
|
259
|
+
return await executor.withNativeScheduleOperation((0, uuid_1.v4)(), () => {
|
|
260
|
+
try {
|
|
261
|
+
return !this.isDestroyed && this.wsClient.isConnected() && epoch === this.imageConnectionEpoch
|
|
262
|
+
&& this.scheduleGeneration(owner.threadId) === owner.generation;
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
}, body, false);
|
|
268
|
+
}
|
|
269
|
+
finally {
|
|
270
|
+
this.scheduleManagement.delete(owner.threadId);
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
});
|
|
228
274
|
this.wsClient.onClose?.(() => {
|
|
229
275
|
this.imageConnectionEpoch++;
|
|
230
276
|
this.scheduleResultsSupported = false;
|
|
277
|
+
this.scheduleCardsSupported = false;
|
|
278
|
+
this.scheduleToolCardsSupported = false;
|
|
279
|
+
this.clearScheduleCardReceipts();
|
|
280
|
+
this.scheduleCards.invalidate();
|
|
231
281
|
this.routerVersion = undefined;
|
|
232
282
|
this.fileInbox?.disconnect();
|
|
233
283
|
this.outputFiles?.disconnect();
|
|
@@ -330,6 +380,26 @@ class MessageHandler {
|
|
|
330
380
|
case 'command':
|
|
331
381
|
await this.handleCommandMessage(message, this.fileInbox?.mark());
|
|
332
382
|
return;
|
|
383
|
+
case 'schedule_tool_card_ack': {
|
|
384
|
+
if (!this.scheduleToolCardsSupported || typeof message.messageId !== 'string')
|
|
385
|
+
return;
|
|
386
|
+
const pending = this.scheduleCardReceipts.get(message.messageId);
|
|
387
|
+
if (pending && typeof message.success === 'boolean') {
|
|
388
|
+
clearTimeout(pending.timer);
|
|
389
|
+
this.scheduleCardReceipts.delete(message.messageId);
|
|
390
|
+
pending.resolve(message.success ? 'Management card delivered.' : 'Management card unavailable. Use /schedule list; do not recreate the task.');
|
|
391
|
+
}
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
case 'schedule_action': {
|
|
395
|
+
if (!this.scheduleCardsSupported || !this.schedules)
|
|
396
|
+
return;
|
|
397
|
+
const epoch = this.imageConnectionEpoch;
|
|
398
|
+
const result = await this.scheduleCards.action(message);
|
|
399
|
+
if (!this.isDestroyed && this.scheduleCardsSupported && epoch === this.imageConnectionEpoch)
|
|
400
|
+
this.wsClient.send(result);
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
333
403
|
case 'settings_action':
|
|
334
404
|
if (this.settingsCardsSupported) {
|
|
335
405
|
const request = message;
|
|
@@ -374,6 +444,8 @@ class MessageHandler {
|
|
|
374
444
|
this.pendingOutputSupported = data.capabilities?.pendingOutputFilesV1 === true;
|
|
375
445
|
this.routerVersion = typeof data.routerVersion === 'string' ? data.routerVersion : undefined;
|
|
376
446
|
this.scheduleResultsSupported = data.capabilities?.scheduleResultsV1 === true;
|
|
447
|
+
this.scheduleCardsSupported = this.scheduleResultsSupported && data.capabilities?.scheduleCardsV1 === true;
|
|
448
|
+
this.scheduleToolCardsSupported = this.scheduleCardsSupported && data.capabilities?.scheduleToolCardsV1 === true;
|
|
377
449
|
if (this.scheduleResultsSupported) {
|
|
378
450
|
void this.recoverSchedules().catch(() => {
|
|
379
451
|
if (this.isDestroyed || !this.scheduleResultsSupported)
|
|
@@ -2348,6 +2420,8 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2348
2420
|
throw new Error('Conversation request was cancelled'); };
|
|
2349
2421
|
this.sendStreamContext(messageId, threadId, executor);
|
|
2350
2422
|
let delegationScope;
|
|
2423
|
+
let scheduleScope;
|
|
2424
|
+
let clearScheduleModelOverride;
|
|
2351
2425
|
let delegationBridge;
|
|
2352
2426
|
let executionMetadata;
|
|
2353
2427
|
let requestFinished = false;
|
|
@@ -2414,6 +2488,12 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2414
2488
|
}
|
|
2415
2489
|
const responseError = fromQueue && !success
|
|
2416
2490
|
? this.pauseQueueAfterFailure(threadId, error || 'Queued command failed') : error;
|
|
2491
|
+
const scheduleFailures = scheduleScope?.unreportedFailures() ?? [];
|
|
2492
|
+
if (scheduleFailures.length) {
|
|
2493
|
+
const details = scheduleFailures.slice(0, 5).map(result => `${result.requestId}: ${result.error ?? 'Operation failed.'}${result.scheduleId ? `\nTask reference: ${result.scheduleId}` : ''}`).join('\n\n');
|
|
2494
|
+
const fence = '`'.repeat(Math.max(3, ...Array.from(details.matchAll(/`+/g), match => match[0].length + 1)));
|
|
2495
|
+
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`);
|
|
2496
|
+
}
|
|
2417
2497
|
this.sendResponse(messageId, threadId, { success, error: responseError, threads: this.threadPool.getSummaries(), executionMetadata, attachmentHints: outputAttachmentHints });
|
|
2418
2498
|
if (fromQueue)
|
|
2419
2499
|
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 +2515,11 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2435
2515
|
}
|
|
2436
2516
|
await this.delegation.assertExecutionSafe(executor.getCurrentWorkingDirectory(), threadId);
|
|
2437
2517
|
assertCurrent();
|
|
2518
|
+
if ((goalRequest || !openId) && executor.configureManagedTools && this.delegationBridges.has(threadId)) {
|
|
2519
|
+
await executor.configureManagedTools(undefined);
|
|
2520
|
+
assertCurrent();
|
|
2521
|
+
this.detachDelegationBridge(threadId);
|
|
2522
|
+
}
|
|
2438
2523
|
if (thread && (0, DelegationSettings_1.isDelegationEnabled)(thread) && executor.configureDelegation) {
|
|
2439
2524
|
const backend = this.threadPool.getBackendKey(threadId);
|
|
2440
2525
|
if (!thread.delegationBackends?.includes(backend)) {
|
|
@@ -2482,18 +2567,70 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2482
2567
|
}), });
|
|
2483
2568
|
delegationBridge = this.delegationBridges.get(threadId) ?? new DelegationBridge_1.DelegationBridge();
|
|
2484
2569
|
this.delegationBridges.set(threadId, delegationBridge);
|
|
2485
|
-
const connection = await delegationBridge.start();
|
|
2570
|
+
const connection = await delegationBridge.start(executor.configureManagedTools && openId && !goalRequest ? ['delegation', 'scheduling'] : undefined);
|
|
2486
2571
|
assertCurrent();
|
|
2487
|
-
await executor.configureDelegation(connection);
|
|
2572
|
+
await (executor.configureManagedTools ?? executor.configureDelegation).call(executor, connection);
|
|
2488
2573
|
assertCurrent();
|
|
2489
2574
|
if (delegationScope.isClosed() || this.isDestroyed || this.abortOperations.has(threadId)) {
|
|
2490
2575
|
throw new Error('Delegation was cancelled before the coordinator started');
|
|
2491
2576
|
}
|
|
2492
2577
|
content = `${contract_1.DELEGATION_INSTRUCTIONS}\n\nUser request:\n${content}`;
|
|
2493
2578
|
}
|
|
2494
|
-
else if (
|
|
2579
|
+
else if ((!executor.configureManagedTools || goalRequest || !openId)
|
|
2580
|
+
&& thread?.delegationBackends?.includes(this.threadPool.getBackendKey(threadId)) && executor.configureDelegation) {
|
|
2495
2581
|
await executor.configureDelegation(undefined);
|
|
2496
2582
|
}
|
|
2583
|
+
if (thread && openId && !goalRequest && executor.configureManagedTools) {
|
|
2584
|
+
const owner = { threadId, openId, generation: this.scheduleGeneration(threadId) };
|
|
2585
|
+
const epoch = this.imageConnectionEpoch;
|
|
2586
|
+
const backend = this.threadPool.getBackendKey(threadId);
|
|
2587
|
+
const config = structuredClone(this.executorConfiguration());
|
|
2588
|
+
let settings = JSON.stringify({ config, models: thread.models, model: thread.model, efforts: thread.efforts });
|
|
2589
|
+
const context = { backend, config, cwd: thread.workingDirectory,
|
|
2590
|
+
model: thread.models?.[backend] ?? (backend === 'claude' ? thread.model || undefined : config[backend]?.model),
|
|
2591
|
+
effort: thread.efforts?.[backend],
|
|
2592
|
+
current: () => {
|
|
2593
|
+
try {
|
|
2594
|
+
const latest = this.threadManager.getThread(threadId);
|
|
2595
|
+
return isCurrent() && !this.abortOperations.has(threadId) && !this.automaticUpdateInProgress && this.wsClient.isConnected()
|
|
2596
|
+
&& epoch === this.imageConnectionEpoch && this.scheduleGeneration(threadId) === owner.generation
|
|
2597
|
+
&& this.threadPool.getBackendKey(threadId) === backend && !!latest
|
|
2598
|
+
&& JSON.stringify({ config: this.executorConfiguration(), models: latest.models, model: latest.model, efforts: latest.efforts }) === settings;
|
|
2599
|
+
}
|
|
2600
|
+
catch {
|
|
2601
|
+
return false;
|
|
2602
|
+
}
|
|
2603
|
+
} };
|
|
2604
|
+
clearScheduleModelOverride = () => {
|
|
2605
|
+
// Match only the authorized recovery mutation. Other concurrent policy
|
|
2606
|
+
// or model changes still fail the captured-context comparison.
|
|
2607
|
+
const captured = JSON.parse(settings);
|
|
2608
|
+
if (captured.models)
|
|
2609
|
+
delete captured.models.codex;
|
|
2610
|
+
settings = JSON.stringify(captured);
|
|
2611
|
+
context.model = config.codex?.model;
|
|
2612
|
+
};
|
|
2613
|
+
if (!delegationBridge) {
|
|
2614
|
+
delegationBridge = this.delegationBridges.get(threadId) ?? new DelegationBridge_1.DelegationBridge();
|
|
2615
|
+
this.delegationBridges.set(threadId, delegationBridge);
|
|
2616
|
+
const connection = await delegationBridge.start(['scheduling']);
|
|
2617
|
+
assertCurrent();
|
|
2618
|
+
await executor.configureManagedTools(connection);
|
|
2619
|
+
assertCurrent();
|
|
2620
|
+
}
|
|
2621
|
+
scheduleScope = this.scheduleToolOperations.scope({ owner, messageId, backend, current: context.current,
|
|
2622
|
+
nativeAction: id => executor.nativeScheduleAction?.(id),
|
|
2623
|
+
run: (command, id) => this.runScheduleOperation(owner, command, id, context),
|
|
2624
|
+
present: async (records, operationId) => {
|
|
2625
|
+
if (!context.current() || !this.scheduleToolCardsSupported)
|
|
2626
|
+
return 'Management card unavailable. Use /schedule list; do not recreate the task.';
|
|
2627
|
+
const menu = this.scheduleCards.open(owner, records);
|
|
2628
|
+
return this.deliverScheduleToolCard({ type: 'schedule_tool_card', messageId: `schedule-card-${operationId}`,
|
|
2629
|
+
parentMessageId: messageId, openId, threadId, menu, timestamp: Date.now() });
|
|
2630
|
+
},
|
|
2631
|
+
});
|
|
2632
|
+
content = `${(0, toolContract_1.scheduleGuidance)()}\n\nUser request:\n${content}`;
|
|
2633
|
+
}
|
|
2497
2634
|
// Retain the callback so native completion tracking consumes late items
|
|
2498
2635
|
// and deduplicates them without adding background output to another turn.
|
|
2499
2636
|
const onTaskNotification = (_notification) => { };
|
|
@@ -2616,11 +2753,13 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2616
2753
|
showState('Working');
|
|
2617
2754
|
scope?.beginExecution(continuationResults.map(task => task.taskId));
|
|
2618
2755
|
const launchRevision = scope?.getLaunchRevision();
|
|
2619
|
-
if (scope)
|
|
2620
|
-
delegationBridge?.activate((
|
|
2621
|
-
if (!active)
|
|
2756
|
+
if (scope || scheduleScope)
|
|
2757
|
+
delegationBridge?.activate((name, args, callId) => {
|
|
2758
|
+
if (!active || !isCurrent())
|
|
2622
2759
|
return Promise.reject(new Error('The coordinator execution has ended'));
|
|
2623
|
-
|
|
2760
|
+
if (name.startsWith('remote_cli_schedule_') && scheduleScope)
|
|
2761
|
+
return scheduleScope.invoke(name, args);
|
|
2762
|
+
return scope ? scope.invoke(name, args, callId) : Promise.reject(new Error('Delegation is disabled for this turn.'));
|
|
2624
2763
|
});
|
|
2625
2764
|
const canPublish = () => isCurrent() && active && (!scope || (!scope.isClosed() && !scope.hasPendingResults()));
|
|
2626
2765
|
const guardedOptions = {
|
|
@@ -2746,7 +2885,8 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2746
2885
|
if (!finished)
|
|
2747
2886
|
scope?.finishExecution(false);
|
|
2748
2887
|
// Goal activation mutates durable native state; never replay it as a model retry.
|
|
2749
|
-
|
|
2888
|
+
await scheduleScope?.drain();
|
|
2889
|
+
mayRetry = !goalRequest && !scheduleScope?.hasSideEffects && (!scope || scope.getLaunchRevision() === launchRevision);
|
|
2750
2890
|
}
|
|
2751
2891
|
};
|
|
2752
2892
|
finishPreparation();
|
|
@@ -2764,6 +2904,7 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2764
2904
|
return this.clearInvalidCodexModel(threadId, executor, result.error);
|
|
2765
2905
|
})) {
|
|
2766
2906
|
assertCoordinatorActive();
|
|
2907
|
+
clearScheduleModelOverride?.();
|
|
2767
2908
|
this.sendStreamChunk(messageId, threadId, '⚠️ The saved Codex model is unavailable for this account. Cleared it and retrying with the backend default...\n');
|
|
2768
2909
|
// Retain the ordinary path's existing image-flush timing on model retry.
|
|
2769
2910
|
result = await executeOnce(prompt, options, !!delegationScope);
|
|
@@ -2838,6 +2979,8 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2838
2979
|
}
|
|
2839
2980
|
finally {
|
|
2840
2981
|
finishPreparation();
|
|
2982
|
+
await scheduleScope?.close();
|
|
2983
|
+
delegationBridge?.activate(undefined);
|
|
2841
2984
|
if (delegationBridge && this.delegationBridges.get(threadId) !== delegationBridge) {
|
|
2842
2985
|
void delegationBridge.close().catch(() => undefined);
|
|
2843
2986
|
}
|
|
@@ -3144,6 +3287,7 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
3144
3287
|
threads: result.threads,
|
|
3145
3288
|
queueConfirmation: result.queueConfirmation,
|
|
3146
3289
|
...(result.executionMetadata ? { executionMetadata: result.executionMetadata } : {}),
|
|
3290
|
+
...(this.scheduleCardsSupported && result.scheduleMenu ? { scheduleMenu: result.scheduleMenu } : {}),
|
|
3147
3291
|
...(this.attachmentHintsSupported && result.attachmentHints ? { attachmentHints: result.attachmentHints } : {}),
|
|
3148
3292
|
...(this.settingsCardsSupported && result.settingsMenu
|
|
3149
3293
|
&& (result.settingsMenu.kind !== 'delegation' || this.delegationCardsSupported)
|
|
@@ -3181,7 +3325,7 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
3181
3325
|
})).digest('hex');
|
|
3182
3326
|
return path_1.default.join(directory, 'schedules', namespace);
|
|
3183
3327
|
}
|
|
3184
|
-
/** Binding recovery only reads existing storage;
|
|
3328
|
+
/** Binding recovery only reads existing storage; explicit command/tool use initializes it. */
|
|
3185
3329
|
async recoverSchedules() {
|
|
3186
3330
|
if (this.isDestroyed || !this.scheduleResultsSupported)
|
|
3187
3331
|
return;
|
|
@@ -3215,13 +3359,37 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
3215
3359
|
const directory = this.scheduleDirectory();
|
|
3216
3360
|
if (!directory)
|
|
3217
3361
|
throw new Error('Local schedule storage is unavailable.');
|
|
3218
|
-
const providers = { claude: new ClaudeNativeScheduleProvider_1.ClaudeNativeScheduleProvider(), dsh: new DshNativeScheduleProvider_1.DshNativeScheduleProvider() };
|
|
3219
3362
|
const service = new ScheduleService_1.ScheduleService({
|
|
3220
3363
|
directory,
|
|
3221
3364
|
provider: { create: (input, onEvent) => {
|
|
3222
3365
|
const backend = input.backend === undefined ? 'claude' : input.backend;
|
|
3223
3366
|
(0, ScheduleCapabilities_1.assertNativeScheduleBackend)(backend);
|
|
3224
|
-
|
|
3367
|
+
if (!input.threadId)
|
|
3368
|
+
throw new Error('Native scheduling requires the original thread.');
|
|
3369
|
+
if (this.threadPool.getBackendKey(input.threadId) !== backend)
|
|
3370
|
+
throw new Error('Foreground scheduling backend changed before native admission.');
|
|
3371
|
+
const executor = this.threadPool.getExecutor(input.threadId);
|
|
3372
|
+
if (!executor.createNativeSchedule)
|
|
3373
|
+
throw new Error('The original executor does not support native session scheduling.');
|
|
3374
|
+
const generation = this.scheduleGeneration(input.threadId);
|
|
3375
|
+
return executor.createNativeSchedule(input, event => {
|
|
3376
|
+
onEvent(event);
|
|
3377
|
+
// A foreground message confirmed into the thread queue while an
|
|
3378
|
+
// autonomous native occurrence was running must be retried when
|
|
3379
|
+
// that occurrence reaches a terminal state. The executor's own
|
|
3380
|
+
// queue wake does not know about MessageHandler's queue.
|
|
3381
|
+
if (event.type === 'completed' || (event.type === 'stopped' && event.exitConfirmed !== false)) {
|
|
3382
|
+
queueMicrotask(() => { void this.startNextQueuedCommand(input.threadId); });
|
|
3383
|
+
}
|
|
3384
|
+
}, () => {
|
|
3385
|
+
try {
|
|
3386
|
+
return !this.isDestroyed && this.scheduleGeneration(input.threadId) === generation
|
|
3387
|
+
&& this.threadPool.getBackendKey(input.threadId) === backend;
|
|
3388
|
+
}
|
|
3389
|
+
catch {
|
|
3390
|
+
return false;
|
|
3391
|
+
}
|
|
3392
|
+
});
|
|
3225
3393
|
} },
|
|
3226
3394
|
isOwnerCurrent: owner => {
|
|
3227
3395
|
// Shutdown blocks delivery separately; it does not invalidate persisted ownership.
|
|
@@ -3264,9 +3432,139 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
3264
3432
|
throw new Error('Cancel this thread\'s schedules with /schedule cancel <id> before resetting context, changing directory, or deleting the thread.');
|
|
3265
3433
|
}
|
|
3266
3434
|
}
|
|
3435
|
+
clearScheduleCardReceipts() {
|
|
3436
|
+
for (const pending of this.scheduleCardReceipts.values()) {
|
|
3437
|
+
clearTimeout(pending.timer);
|
|
3438
|
+
pending.resolve('Management card delivery is unknown. Use /schedule list; do not recreate the task.');
|
|
3439
|
+
}
|
|
3440
|
+
this.scheduleCardReceipts.clear();
|
|
3441
|
+
}
|
|
3442
|
+
deliverScheduleToolCard(message) {
|
|
3443
|
+
if (this.scheduleCardReceipts.size >= 5)
|
|
3444
|
+
return Promise.resolve('Management card limit reached. Use /schedule list.');
|
|
3445
|
+
return new Promise(resolve => {
|
|
3446
|
+
const timer = setTimeout(() => {
|
|
3447
|
+
this.scheduleCardReceipts.delete(message.messageId);
|
|
3448
|
+
resolve('Management card delivery is unknown. Use /schedule list; do not recreate the task.');
|
|
3449
|
+
}, 8000);
|
|
3450
|
+
this.scheduleCardReceipts.set(message.messageId, { resolve, timer });
|
|
3451
|
+
try {
|
|
3452
|
+
if (this.wsClient.send(message))
|
|
3453
|
+
return;
|
|
3454
|
+
}
|
|
3455
|
+
catch { /* The native operation already succeeded. */ }
|
|
3456
|
+
clearTimeout(timer);
|
|
3457
|
+
this.scheduleCardReceipts.delete(message.messageId);
|
|
3458
|
+
resolve('Management card unavailable. Use /schedule list; do not recreate the task.');
|
|
3459
|
+
});
|
|
3460
|
+
}
|
|
3461
|
+
/** Shared admission for slash commands and scoped model tools. Native providers alone own timing. */
|
|
3462
|
+
async runScheduleOperation(owner, command, id = (0, uuid_1.v4)(), context, nativeBound = false) {
|
|
3463
|
+
const current = () => {
|
|
3464
|
+
try {
|
|
3465
|
+
return !this.isDestroyed && this.scheduleGeneration(owner.threadId) === owner.generation && (!context || context.current());
|
|
3466
|
+
}
|
|
3467
|
+
catch {
|
|
3468
|
+
return false;
|
|
3469
|
+
}
|
|
3470
|
+
};
|
|
3471
|
+
const check = () => { if (!current() || this.automaticUpdateInProgress)
|
|
3472
|
+
throw new Error('Scheduling context changed or client is shutting down/updating.'); };
|
|
3473
|
+
check();
|
|
3474
|
+
if (!nativeBound && this.scheduleManagement.has(owner.threadId))
|
|
3475
|
+
throw new Error('A schedule operation is already in progress for this thread.');
|
|
3476
|
+
this.scheduleManagement.add(owner.threadId);
|
|
3477
|
+
try {
|
|
3478
|
+
const backend = context?.backend ?? this.threadPool.getBackendKey(owner.threadId);
|
|
3479
|
+
const config = context?.config ?? this.executorConfiguration();
|
|
3480
|
+
if (command.kind === 'create') {
|
|
3481
|
+
(0, ScheduleCapabilities_1.assertNativeScheduleBackend)(backend);
|
|
3482
|
+
if (!this.scheduleResultsSupported || !this.wsClient.isConnected())
|
|
3483
|
+
throw new Error('Schedule creation requires a connected Router with scheduleResultsV1 support.');
|
|
3484
|
+
if (backend === 'claude' && new ClaudeSandbox_1.ClaudeSandbox(this.directoryGuard, config.claude?.sandbox, owner.threadId).isRestricted()) {
|
|
3485
|
+
throw new Error('This native scheduling adapter does not support restricted Claude sandboxes. No schedule was created and sandbox settings were not changed.');
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
if (!nativeBound && backend === 'claude' && (command.kind === 'create' || this.schedules?.hasActiveSchedules(owner.threadId))) {
|
|
3489
|
+
const executor = this.threadPool.getExecutor(owner.threadId);
|
|
3490
|
+
if (!executor.withNativeScheduleOperation)
|
|
3491
|
+
throw new Error('Shared native session scheduling is unavailable.');
|
|
3492
|
+
if (!context && command.kind === 'create' && executor.configureManagedTools) {
|
|
3493
|
+
// Install the same bridge the next ordinary turn will use before a
|
|
3494
|
+
// slash-created native job exists. That turn must not recycle its host.
|
|
3495
|
+
const bridge = this.delegationBridges.get(owner.threadId) ?? new DelegationBridge_1.DelegationBridge();
|
|
3496
|
+
this.delegationBridges.set(owner.threadId, bridge);
|
|
3497
|
+
const thread = this.threadManager.getThread(owner.threadId);
|
|
3498
|
+
const connection = await bridge.start(thread && (0, DelegationSettings_1.isDelegationEnabled)(thread) ? ['delegation', 'scheduling'] : ['scheduling']);
|
|
3499
|
+
check();
|
|
3500
|
+
await executor.configureManagedTools(connection);
|
|
3501
|
+
check();
|
|
3502
|
+
}
|
|
3503
|
+
return await executor.withNativeScheduleOperation(id, current, () => this.runScheduleOperation(owner, command, id, context, true), !!context);
|
|
3504
|
+
}
|
|
3505
|
+
const service = await this.initializeSchedules();
|
|
3506
|
+
check();
|
|
3507
|
+
if (command.kind === 'list') {
|
|
3508
|
+
await service.refresh(owner);
|
|
3509
|
+
check();
|
|
3510
|
+
void service.retryDeliveries().catch(() => { });
|
|
3511
|
+
return service.list(owner);
|
|
3512
|
+
}
|
|
3513
|
+
if (command.kind === 'cancel')
|
|
3514
|
+
return [await service.cancel(owner, command.id)];
|
|
3515
|
+
(0, ScheduleCapabilities_1.assertNativeScheduleBackend)(backend);
|
|
3516
|
+
// A durable record fences retries after lost in-memory receipts or a process restart.
|
|
3517
|
+
if ((await service.list(owner)).some(record => record.id === id))
|
|
3518
|
+
throw new Error(`Schedule ${id} already has a durable record. Use /schedule list; it was not recreated.`);
|
|
3519
|
+
check();
|
|
3520
|
+
const thread = this.threadManager.getThread(owner.threadId);
|
|
3521
|
+
const cwd = this.directoryGuard.resolveWorkingDirectory(context?.cwd ?? thread.workingDirectory);
|
|
3522
|
+
(0, WorkingDirectory_1.assertWorkingDirectoryExists)(cwd);
|
|
3523
|
+
const existingOwner = this.scheduleOwners.get(owner.threadId);
|
|
3524
|
+
if (existingOwner && existingOwner.openId !== owner.openId && (await this.activeSchedules(owner.threadId)).length)
|
|
3525
|
+
throw new Error('This thread has schedules belonging to a different owner.');
|
|
3526
|
+
check();
|
|
3527
|
+
this.scheduleOwners.set(owner.threadId, owner);
|
|
3528
|
+
if (!context && backend !== 'claude') {
|
|
3529
|
+
const executor = this.threadPool.getExecutor(owner.threadId);
|
|
3530
|
+
if (executor.configureManagedTools) {
|
|
3531
|
+
const bridge = this.delegationBridges.get(owner.threadId) ?? new DelegationBridge_1.DelegationBridge();
|
|
3532
|
+
this.delegationBridges.set(owner.threadId, bridge);
|
|
3533
|
+
const connection = await bridge.start((0, DelegationSettings_1.isDelegationEnabled)(thread) ? ['delegation', 'scheduling'] : ['scheduling']);
|
|
3534
|
+
check();
|
|
3535
|
+
await executor.configureManagedTools(connection);
|
|
3536
|
+
check();
|
|
3537
|
+
}
|
|
3538
|
+
}
|
|
3539
|
+
const record = await service.create(owner, { id, threadId: owner.threadId, backend, cwd, rule: command.rule, prompt: command.prompt,
|
|
3540
|
+
command: config[backend]?.command,
|
|
3541
|
+
model: context ? context.model : thread.models?.[backend] ?? (backend === 'claude' ? thread.model || undefined : config.dsh?.model),
|
|
3542
|
+
effort: context ? context.effort : thread.efforts?.[backend] });
|
|
3543
|
+
if (!current()) {
|
|
3544
|
+
await service.cancel(owner, record.id);
|
|
3545
|
+
throw new Error('Scheduling context retired during creation; the native task was cancelled.');
|
|
3546
|
+
}
|
|
3547
|
+
return [record];
|
|
3548
|
+
}
|
|
3549
|
+
finally {
|
|
3550
|
+
if (!nativeBound) {
|
|
3551
|
+
this.scheduleManagement.delete(owner.threadId);
|
|
3552
|
+
await this.activeSchedules(owner.threadId).catch(() => undefined);
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3267
3556
|
async handleScheduleCommand(message, threadId) {
|
|
3268
3557
|
const respond = (result) => this.sendResponse(message.messageId, threadId, result, true);
|
|
3269
|
-
|
|
3558
|
+
const menuFor = (owner, records) => {
|
|
3559
|
+
if (!this.scheduleCardsSupported)
|
|
3560
|
+
return undefined;
|
|
3561
|
+
try {
|
|
3562
|
+
return this.scheduleCards.open(owner, records);
|
|
3563
|
+
}
|
|
3564
|
+
catch {
|
|
3565
|
+
return undefined;
|
|
3566
|
+
} // A presentation failure must not turn successful native work into a failed command.
|
|
3567
|
+
};
|
|
3270
3568
|
try {
|
|
3271
3569
|
const command = (0, ScheduleCommand_1.parseScheduleCommand)(message.content ?? '');
|
|
3272
3570
|
if (!command || command.kind === 'help') {
|
|
@@ -3287,74 +3585,24 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
3287
3585
|
throw new Error('Use /cd first and include a self-contained text prompt. Schedule commands do not accept attachments or directory overrides.');
|
|
3288
3586
|
}
|
|
3289
3587
|
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'
|
|
3588
|
+
const records = await this.runScheduleOperation(owner, command.kind === 'list' ? { kind: 'list' } : command);
|
|
3589
|
+
const record = records[0];
|
|
3590
|
+
let output;
|
|
3591
|
+
if (command.kind === 'list')
|
|
3592
|
+
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.';
|
|
3593
|
+
else if (command.kind === 'cancel')
|
|
3594
|
+
output = `Schedule ${record.id}: ${record.state}.`;
|
|
3595
|
+
else {
|
|
3596
|
+
const lifecycle = record.backend === 'claude'
|
|
3339
3597
|
? 'Schedules are lost when the native process exits; recurring tasks expire after seven days.'
|
|
3340
3598
|
: '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);
|
|
3599
|
+
output = `Schedule ${record.id}: ${record.state}.\n${record.rule.kind === 'once' ? record.rule.at : `${record.rule.expression} (${record.rule.timezone})`}\n\nRuns in this thread's foreground ${ScheduleCapabilities_1.NATIVE_SCHEDULE_CAPABILITIES[record.backend].label} conversation and returns results here. Keep the CLI running; native timing is approximate. ${lifecycle}\nUse /schedule list or /schedule cancel ${record.id}.`;
|
|
3347
3600
|
}
|
|
3601
|
+
respond({ success: true, scheduleMenu: menuFor(owner, records), output });
|
|
3348
3602
|
}
|
|
3349
3603
|
catch (error) {
|
|
3350
3604
|
respond({ success: false, error: error instanceof Error ? error.message : 'Schedule operation failed.' });
|
|
3351
3605
|
}
|
|
3352
|
-
finally {
|
|
3353
|
-
if (reserved) {
|
|
3354
|
-
this.scheduleManagement.delete(threadId);
|
|
3355
|
-
await this.activeSchedules(threadId).catch(() => undefined);
|
|
3356
|
-
}
|
|
3357
|
-
}
|
|
3358
3606
|
}
|
|
3359
3607
|
/** Shared card/text Apply path. Callers hold exclusive settings admission. */
|
|
3360
3608
|
async changeWorkingDirectory(threadId, targetDir) {
|
|
@@ -3673,6 +3921,8 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
3673
3921
|
async destroy() {
|
|
3674
3922
|
this.directoryBrowser.destroy();
|
|
3675
3923
|
this.settingsService.destroy();
|
|
3924
|
+
this.scheduleCards.destroy();
|
|
3925
|
+
this.clearScheduleCardReceipts();
|
|
3676
3926
|
this.isDestroyed = true;
|
|
3677
3927
|
this.scheduleDelivery?.destroy();
|
|
3678
3928
|
this.pendingOutputFiles.clear();
|