@yu_robotics/remote-cli 1.6.230 → 1.6.232
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 +16 -0
- package/dist/client/MessageHandler.d.ts.map +1 -1
- package/dist/client/MessageHandler.js +255 -2
- package/dist/client/MessageHandler.js.map +1 -1
- package/dist/client/WebSocketClient.d.ts +4 -1
- package/dist/client/WebSocketClient.d.ts.map +1 -1
- package/dist/client/WebSocketClient.js +43 -3
- package/dist/client/WebSocketClient.js.map +1 -1
- package/dist/maintenance/release-notes.json +1 -1
- package/dist/output/OutputFiles.d.ts +7 -0
- package/dist/output/OutputFiles.d.ts.map +1 -1
- package/dist/output/OutputFiles.js +16 -3
- package/dist/output/OutputFiles.js.map +1 -1
- package/dist/output/OutputSnapshots.d.ts +3 -1
- package/dist/output/OutputSnapshots.d.ts.map +1 -1
- package/dist/output/OutputSnapshots.js +14 -4
- package/dist/output/OutputSnapshots.js.map +1 -1
- package/dist/output/PendingOutputFiles.d.ts +13 -0
- package/dist/output/PendingOutputFiles.d.ts.map +1 -0
- package/dist/output/PendingOutputFiles.js +67 -0
- package/dist/output/PendingOutputFiles.js.map +1 -0
- package/dist/scheduling/ClaudeNativeScheduleProvider.d.ts +19 -0
- package/dist/scheduling/ClaudeNativeScheduleProvider.d.ts.map +1 -0
- package/dist/scheduling/ClaudeNativeScheduleProvider.js +570 -0
- package/dist/scheduling/ClaudeNativeScheduleProvider.js.map +1 -0
- package/dist/scheduling/DshNativeScheduleProvider.d.ts +19 -0
- package/dist/scheduling/DshNativeScheduleProvider.d.ts.map +1 -0
- package/dist/scheduling/DshNativeScheduleProvider.js +470 -0
- package/dist/scheduling/DshNativeScheduleProvider.js.map +1 -0
- package/dist/scheduling/ScheduleCapabilities.d.ts +53 -0
- package/dist/scheduling/ScheduleCapabilities.d.ts.map +1 -0
- package/dist/scheduling/ScheduleCapabilities.js +65 -0
- package/dist/scheduling/ScheduleCapabilities.js.map +1 -0
- package/dist/scheduling/ScheduleCommand.d.ts +27 -0
- package/dist/scheduling/ScheduleCommand.d.ts.map +1 -0
- package/dist/scheduling/ScheduleCommand.js +173 -0
- package/dist/scheduling/ScheduleCommand.js.map +1 -0
- package/dist/scheduling/ScheduleDeliveryClient.d.ts +17 -0
- package/dist/scheduling/ScheduleDeliveryClient.d.ts.map +1 -0
- package/dist/scheduling/ScheduleDeliveryClient.js +109 -0
- package/dist/scheduling/ScheduleDeliveryClient.js.map +1 -0
- package/dist/scheduling/ScheduleService.d.ts +73 -0
- package/dist/scheduling/ScheduleService.d.ts.map +1 -0
- package/dist/scheduling/ScheduleService.js +742 -0
- package/dist/scheduling/ScheduleService.js.map +1 -0
- package/dist/scheduling/claude/rules.d.ts +8 -0
- package/dist/scheduling/claude/rules.d.ts.map +1 -0
- package/dist/scheduling/claude/rules.js +46 -0
- package/dist/scheduling/claude/rules.js.map +1 -0
- package/dist/scheduling/dsh/HostBridge.d.ts +96 -0
- package/dist/scheduling/dsh/HostBridge.d.ts.map +1 -0
- package/dist/scheduling/dsh/HostBridge.js +364 -0
- package/dist/scheduling/dsh/HostBridge.js.map +1 -0
- package/dist/scheduling/dsh/ScopePlugin.d.ts +9 -0
- package/dist/scheduling/dsh/ScopePlugin.d.ts.map +1 -0
- package/dist/scheduling/dsh/ScopePlugin.js +13 -0
- package/dist/scheduling/dsh/ScopePlugin.js.map +1 -0
- package/dist/scheduling/dsh/launch.d.ts +13 -0
- package/dist/scheduling/dsh/launch.d.ts.map +1 -0
- package/dist/scheduling/dsh/launch.js +58 -0
- package/dist/scheduling/dsh/launch.js.map +1 -0
- package/dist/scheduling/dsh/protocol.d.ts +28 -0
- package/dist/scheduling/dsh/protocol.d.ts.map +1 -0
- package/dist/scheduling/dsh/protocol.js +142 -0
- package/dist/scheduling/dsh/protocol.js.map +1 -0
- package/dist/scheduling/types.d.ts +79 -0
- package/dist/scheduling/types.d.ts.map +1 -0
- package/dist/scheduling/types.js +13 -0
- package/dist/scheduling/types.js.map +1 -0
- package/dist/types/index.d.ts +4 -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
|
@@ -61,7 +61,15 @@ export declare class MessageHandler {
|
|
|
61
61
|
private outputFiles?;
|
|
62
62
|
private readonly imageDeliveries;
|
|
63
63
|
private attachmentHintsSupported;
|
|
64
|
+
private pendingOutputSupported;
|
|
65
|
+
private readonly pendingOutputFiles;
|
|
64
66
|
private imageConnectionEpoch;
|
|
67
|
+
private scheduleResultsSupported;
|
|
68
|
+
private schedules?;
|
|
69
|
+
private scheduleInitialization?;
|
|
70
|
+
private scheduleDelivery?;
|
|
71
|
+
private readonly scheduleOwners;
|
|
72
|
+
private readonly scheduleManagement;
|
|
65
73
|
constructor(wsClient: WebSocketClient, threadPool: ThreadExecutorPool, threadManager: ThreadManager, directoryGuard: DirectoryGuard, config: ConfigManager);
|
|
66
74
|
reconcilePendingDelegatedWorkers(): Promise<void>;
|
|
67
75
|
/**
|
|
@@ -202,6 +210,14 @@ export declare class MessageHandler {
|
|
|
202
210
|
private sendStructuredContent;
|
|
203
211
|
private sendResponse;
|
|
204
212
|
private executorConfiguration;
|
|
213
|
+
private scheduleGeneration;
|
|
214
|
+
private scheduleDirectory;
|
|
215
|
+
/** Binding recovery only reads existing storage; first use belongs to /schedule. */
|
|
216
|
+
private recoverSchedules;
|
|
217
|
+
private initializeSchedules;
|
|
218
|
+
private activeSchedules;
|
|
219
|
+
private assertSchedulesIdle;
|
|
220
|
+
private handleScheduleCommand;
|
|
205
221
|
/** Shared card/text Apply path. Callers hold exclusive settings admission. */
|
|
206
222
|
private changeWorkingDirectory;
|
|
207
223
|
private settingsState;
|
|
@@ -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":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAQpD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAgK,MAAM,UAAU,CAAC;AACzM,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAOxD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAqIxD;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAsBD,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,mBAAmB,CAA4B;IACvD,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,eAAe,CAA0C;IACjE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAsC;IACnE,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAA+C;IACzF,OAAO,CAAC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oF;YACtE,gBAAgB;IAmB9B,OAAO,CAAC,mBAAmB;YAkCb,eAAe;YASf,mBAAmB;YAMnB,qBAAqB;IA+EnC,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;CA+B/B"}
|
|
@@ -4,6 +4,7 @@ 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 PendingOutputFiles_1 = require("../output/PendingOutputFiles");
|
|
7
8
|
const OutputFiles_1 = require("../output/OutputFiles");
|
|
8
9
|
const OutputSnapshots_1 = require("../output/OutputSnapshots");
|
|
9
10
|
const OutputLinks_1 = require("../output/OutputLinks");
|
|
@@ -50,6 +51,13 @@ const SessionResumeService_1 = require("../session/SessionResumeService");
|
|
|
50
51
|
const adapters_1 = require("../session/adapters");
|
|
51
52
|
const PiSessionCatalog_1 = require("../session/adapters/PiSessionCatalog");
|
|
52
53
|
const SessionControl_1 = require("../session/SessionControl");
|
|
54
|
+
const ScheduleService_1 = require("../scheduling/ScheduleService");
|
|
55
|
+
const ClaudeNativeScheduleProvider_1 = require("../scheduling/ClaudeNativeScheduleProvider");
|
|
56
|
+
const DshNativeScheduleProvider_1 = require("../scheduling/DshNativeScheduleProvider");
|
|
57
|
+
const ScheduleDeliveryClient_1 = require("../scheduling/ScheduleDeliveryClient");
|
|
58
|
+
const ScheduleCommand_1 = require("../scheduling/ScheduleCommand");
|
|
59
|
+
const ScheduleCapabilities_1 = require("../scheduling/ScheduleCapabilities");
|
|
60
|
+
const ClaudeSandbox_1 = require("../executor/claude/ClaudeSandbox");
|
|
53
61
|
const EFFORT_BACKENDS = new Set(['claude', 'codex', 'agy', 'opencode', 'kimi', 'zcode', 'pi', 'dsh']);
|
|
54
62
|
const SLASH_SESSION_BACKENDS = new Set(['opencode', 'kimi', 'zcode', 'pi']);
|
|
55
63
|
const NATIVE_SKILLS_BACKENDS = new Set(['claude', 'agy', 'opencode', 'kimi', 'zcode', 'pi']);
|
|
@@ -202,7 +210,15 @@ class MessageHandler {
|
|
|
202
210
|
outputFiles;
|
|
203
211
|
imageDeliveries = new Map();
|
|
204
212
|
attachmentHintsSupported = false;
|
|
213
|
+
pendingOutputSupported = false;
|
|
214
|
+
pendingOutputFiles = new PendingOutputFiles_1.PendingOutputFiles();
|
|
205
215
|
imageConnectionEpoch = 0;
|
|
216
|
+
scheduleResultsSupported = false;
|
|
217
|
+
schedules;
|
|
218
|
+
scheduleInitialization;
|
|
219
|
+
scheduleDelivery;
|
|
220
|
+
scheduleOwners = new Map();
|
|
221
|
+
scheduleManagement = new Set();
|
|
206
222
|
constructor(wsClient, threadPool, threadManager, directoryGuard, config) {
|
|
207
223
|
this.wsClient = wsClient;
|
|
208
224
|
this.threadPool = threadPool;
|
|
@@ -211,6 +227,7 @@ class MessageHandler {
|
|
|
211
227
|
this.config = config;
|
|
212
228
|
this.wsClient.onClose?.(() => {
|
|
213
229
|
this.imageConnectionEpoch++;
|
|
230
|
+
this.scheduleResultsSupported = false;
|
|
214
231
|
this.routerVersion = undefined;
|
|
215
232
|
this.fileInbox?.disconnect();
|
|
216
233
|
this.outputFiles?.disconnect();
|
|
@@ -324,6 +341,12 @@ class MessageHandler {
|
|
|
324
341
|
this.wsClient.send(result);
|
|
325
342
|
}
|
|
326
343
|
return;
|
|
344
|
+
case 'prepare_pending_output': {
|
|
345
|
+
if (this.pendingOutputSupported && this.outputFiles?.isEnabled()) {
|
|
346
|
+
await this.pendingOutputFiles.prepare(message, this.outputFiles);
|
|
347
|
+
}
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
327
350
|
case 'output_registered':
|
|
328
351
|
case 'output_grant':
|
|
329
352
|
this.outputFiles?.handle(message);
|
|
@@ -348,7 +371,16 @@ class MessageHandler {
|
|
|
348
371
|
if (data?.success !== true)
|
|
349
372
|
return;
|
|
350
373
|
this.attachmentHintsSupported = data.capabilities?.outputAttachmentHintsV1 === true;
|
|
374
|
+
this.pendingOutputSupported = data.capabilities?.pendingOutputFilesV1 === true;
|
|
351
375
|
this.routerVersion = typeof data.routerVersion === 'string' ? data.routerVersion : undefined;
|
|
376
|
+
this.scheduleResultsSupported = data.capabilities?.scheduleResultsV1 === true;
|
|
377
|
+
if (this.scheduleResultsSupported) {
|
|
378
|
+
void this.recoverSchedules().catch(() => {
|
|
379
|
+
if (this.isDestroyed || !this.scheduleResultsSupported)
|
|
380
|
+
return;
|
|
381
|
+
console.warn('[Schedules] Local schedule recovery is unavailable. Use /schedule list for details.');
|
|
382
|
+
});
|
|
383
|
+
}
|
|
352
384
|
if (data.capabilities?.outputFilesV1 === true) {
|
|
353
385
|
try {
|
|
354
386
|
if (!this.outputFiles) {
|
|
@@ -358,6 +390,8 @@ class MessageHandler {
|
|
|
358
390
|
await this.outputFiles.initialize();
|
|
359
391
|
}
|
|
360
392
|
this.outputFiles.connect();
|
|
393
|
+
if (this.pendingOutputSupported)
|
|
394
|
+
this.wsClient.send({ type: 'pending_outputs_ready' });
|
|
361
395
|
}
|
|
362
396
|
catch {
|
|
363
397
|
await this.outputFiles?.destroy();
|
|
@@ -430,6 +464,7 @@ class MessageHandler {
|
|
|
430
464
|
|| this.pendingReplaces.size > 0
|
|
431
465
|
|| this.activeThreadOperations.size > 0
|
|
432
466
|
|| this.abortOperations.size > 0
|
|
467
|
+
|| this.scheduleManagement.size > 0 || this.schedules?.hasActiveSchedules()
|
|
433
468
|
|| this.threadManager.listThreads().some(thread => this.settingsAdmission.isBlocked(thread.id))) {
|
|
434
469
|
return false;
|
|
435
470
|
}
|
|
@@ -567,6 +602,10 @@ class MessageHandler {
|
|
|
567
602
|
return;
|
|
568
603
|
}
|
|
569
604
|
const settingsCommand = content?.trim() ?? '';
|
|
605
|
+
if (/^\/schedule(?:\s|$)/.test(settingsCommand)) {
|
|
606
|
+
await this.handleScheduleCommand(message, resolvedThreadId);
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
570
609
|
if (settingsCommand === '/clear' || settingsCommand === '/new') {
|
|
571
610
|
await this.clearThreadConversation(messageId, resolvedThreadId);
|
|
572
611
|
return;
|
|
@@ -1039,6 +1078,7 @@ class MessageHandler {
|
|
|
1039
1078
|
void bridge.close().catch(() => undefined);
|
|
1040
1079
|
}
|
|
1041
1080
|
async clearThreadConversation(messageId, threadId) {
|
|
1081
|
+
await this.assertSchedulesIdle(threadId);
|
|
1042
1082
|
this.conversationRevisions.set(threadId, (this.conversationRevisions.get(threadId) ?? 0) + 1);
|
|
1043
1083
|
this.settingsService.invalidate(threadId);
|
|
1044
1084
|
this.directoryBrowser.invalidate(threadId);
|
|
@@ -1178,6 +1218,8 @@ class MessageHandler {
|
|
|
1178
1218
|
}
|
|
1179
1219
|
}
|
|
1180
1220
|
if (trimmed === '/sandbox' || trimmed.startsWith('/sandbox ')) {
|
|
1221
|
+
if (trimmed !== '/sandbox')
|
|
1222
|
+
await this.assertSchedulesIdle(threadId);
|
|
1181
1223
|
if (!('getSandboxStatus' in executor) || !('configureSandbox' in executor)) {
|
|
1182
1224
|
this.sendResponse(messageId, threadId, { success: false, error: '/sandbox is currently supported by the Codex and Claude Code backends.' });
|
|
1183
1225
|
return true;
|
|
@@ -1293,6 +1335,7 @@ Use /compact to reduce conversation context or /clear to start a fresh context.`
|
|
|
1293
1335
|
- /effort [auto|level] - Open effort settings, or set a native supported level with a text argument
|
|
1294
1336
|
- /goal [objective|pause|resume|clear] - Manage a native Codex goal; optional --budget <tokens> on start or resume
|
|
1295
1337
|
- /sandbox [on|off|read-only|default|allow <directory>|remove <directory>|network on|off] - Configure this thread's sandbox (Codex, Claude Code)
|
|
1338
|
+
- /schedule [capabilities|list|cancel <id>|after|at|cron] - Manage native scheduled tasks; /schedule shows examples
|
|
1296
1339
|
- /delegation [on|off|reset [backend]] - Delegate tasks between installed agent backends; reset saved worker context when needed
|
|
1297
1340
|
- /backend - Open backend settings (Current thread by default; Confirm applies)
|
|
1298
1341
|
- /backend <index> - Switch all threads and clear per-thread backend overrides
|
|
@@ -1823,6 +1866,7 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
1823
1866
|
return;
|
|
1824
1867
|
}
|
|
1825
1868
|
try {
|
|
1869
|
+
await this.assertSchedulesIdle(target.id);
|
|
1826
1870
|
await this.delegation.cancelThread(target.id);
|
|
1827
1871
|
await this.delegationBridges.get(target.id)?.close();
|
|
1828
1872
|
this.delegationBridges.delete(target.id);
|
|
@@ -2287,6 +2331,7 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2287
2331
|
}
|
|
2288
2332
|
if (executor.hasUncertainShutdown?.())
|
|
2289
2333
|
throw new Error('Direct backend shutdown is unconfirmed. Retry /abort or /clear before sending more work.');
|
|
2334
|
+
this.pendingOutputFiles.invalidateThread(threadId);
|
|
2290
2335
|
const conversationRevision = this.conversationRevisions.get(threadId) ?? 0;
|
|
2291
2336
|
const operationToken = this.activeThreadOperations.get(threadId)?.token;
|
|
2292
2337
|
const isCurrent = () => !this.isDestroyed && (!operationToken ||
|
|
@@ -2673,9 +2718,18 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
2673
2718
|
if (names.length)
|
|
2674
2719
|
outputAttachmentHints = { generation: outputGeneration, names: [...new Set([...(outputAttachmentHints?.names ?? []), ...names])].slice(0, 16) };
|
|
2675
2720
|
}
|
|
2721
|
+
const outputContext = { messageId, threadId, taskId: messageId, owner: openId,
|
|
2722
|
+
generation: outputGeneration, cwd: imageCwd, source: 'workspace', exports: [...outputExports.values()] };
|
|
2676
2723
|
if (this.outputFiles?.isEnabled()) {
|
|
2677
|
-
await this.outputFiles.capture(outputLinks,
|
|
2678
|
-
|
|
2724
|
+
await this.outputFiles.capture(outputLinks, outputContext);
|
|
2725
|
+
}
|
|
2726
|
+
else if (this.pendingOutputSupported) {
|
|
2727
|
+
this.pendingOutputFiles.remember(outputLinks, outputContext, () => {
|
|
2728
|
+
const current = this.threadManager.getThread(threadId);
|
|
2729
|
+
return !this.isDestroyed && !!current && current.workingDirectory === imageCwd
|
|
2730
|
+
&& (current.delegationWorkspaceGeneration ?? 0) === outputGeneration
|
|
2731
|
+
&& (this.conversationRevisions.get(threadId) ?? 0) === conversationRevision;
|
|
2732
|
+
});
|
|
2679
2733
|
}
|
|
2680
2734
|
await imageDelivery?.drain();
|
|
2681
2735
|
}
|
|
@@ -3107,8 +3161,204 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
3107
3161
|
executorConfiguration() {
|
|
3108
3162
|
return this.config.get('executor') ?? { type: 'auto' };
|
|
3109
3163
|
}
|
|
3164
|
+
scheduleGeneration(threadId) {
|
|
3165
|
+
const thread = this.threadManager.getThread(threadId);
|
|
3166
|
+
if (!thread)
|
|
3167
|
+
throw new Error('This thread no longer exists.');
|
|
3168
|
+
this.threadManager.contextResets.assertReady(threadId);
|
|
3169
|
+
return (0, crypto_1.createHash)('sha256').update(JSON.stringify({
|
|
3170
|
+
server: this.config.get('serverUrl'), device: this.config.get('deviceId'),
|
|
3171
|
+
thread: threadId, cwd: thread.workingDirectory,
|
|
3172
|
+
generation: this.threadManager.contextResets.generation(threadId, thread.delegationWorkspaceGeneration ?? 0),
|
|
3173
|
+
})).digest('hex');
|
|
3174
|
+
}
|
|
3175
|
+
scheduleDirectory() {
|
|
3176
|
+
const directory = this.config.getConfigDir?.();
|
|
3177
|
+
if (typeof directory !== 'string' || !directory)
|
|
3178
|
+
return undefined;
|
|
3179
|
+
const namespace = (0, crypto_1.createHash)('sha256').update(JSON.stringify({
|
|
3180
|
+
server: this.config.get('serverUrl'), device: this.config.get('deviceId'),
|
|
3181
|
+
})).digest('hex');
|
|
3182
|
+
return path_1.default.join(directory, 'schedules', namespace);
|
|
3183
|
+
}
|
|
3184
|
+
/** Binding recovery only reads existing storage; first use belongs to /schedule. */
|
|
3185
|
+
async recoverSchedules() {
|
|
3186
|
+
if (this.isDestroyed || !this.scheduleResultsSupported)
|
|
3187
|
+
return;
|
|
3188
|
+
if (!this.scheduleInitialization) {
|
|
3189
|
+
const directory = this.scheduleDirectory();
|
|
3190
|
+
if (!directory)
|
|
3191
|
+
return;
|
|
3192
|
+
try {
|
|
3193
|
+
await fs_1.default.promises.lstat(path_1.default.join(directory, ScheduleService_1.SCHEDULE_CATALOG_FILE));
|
|
3194
|
+
}
|
|
3195
|
+
catch (error) {
|
|
3196
|
+
if (['ENOENT', 'ENOTDIR'].includes(error.code ?? ''))
|
|
3197
|
+
return;
|
|
3198
|
+
throw error;
|
|
3199
|
+
}
|
|
3200
|
+
}
|
|
3201
|
+
// A disconnect or shutdown can happen while storage is being checked. Never
|
|
3202
|
+
// create a late service/subscription after shutdown has collected its work.
|
|
3203
|
+
if (this.isDestroyed || !this.scheduleResultsSupported)
|
|
3204
|
+
return;
|
|
3205
|
+
const service = await this.initializeSchedules();
|
|
3206
|
+
if (!this.isDestroyed && this.scheduleResultsSupported)
|
|
3207
|
+
await service.retryDeliveries();
|
|
3208
|
+
}
|
|
3209
|
+
initializeSchedules() {
|
|
3210
|
+
if (this.scheduleInitialization)
|
|
3211
|
+
return this.scheduleInitialization;
|
|
3212
|
+
this.scheduleInitialization = (async () => {
|
|
3213
|
+
if (this.isDestroyed)
|
|
3214
|
+
throw new Error('The client is shutting down.');
|
|
3215
|
+
const directory = this.scheduleDirectory();
|
|
3216
|
+
if (!directory)
|
|
3217
|
+
throw new Error('Local schedule storage is unavailable.');
|
|
3218
|
+
const providers = { claude: new ClaudeNativeScheduleProvider_1.ClaudeNativeScheduleProvider(), dsh: new DshNativeScheduleProvider_1.DshNativeScheduleProvider() };
|
|
3219
|
+
const service = new ScheduleService_1.ScheduleService({
|
|
3220
|
+
directory,
|
|
3221
|
+
provider: { create: (input, onEvent) => {
|
|
3222
|
+
const backend = input.backend === undefined ? 'claude' : input.backend;
|
|
3223
|
+
(0, ScheduleCapabilities_1.assertNativeScheduleBackend)(backend);
|
|
3224
|
+
return providers[backend].create(input, onEvent);
|
|
3225
|
+
} },
|
|
3226
|
+
isOwnerCurrent: owner => {
|
|
3227
|
+
// Shutdown blocks delivery separately; it does not invalidate persisted ownership.
|
|
3228
|
+
try {
|
|
3229
|
+
return this.scheduleGeneration(owner.threadId) === owner.generation;
|
|
3230
|
+
}
|
|
3231
|
+
catch {
|
|
3232
|
+
return false;
|
|
3233
|
+
}
|
|
3234
|
+
},
|
|
3235
|
+
deliver: async (delivery) => {
|
|
3236
|
+
if (!this.scheduleResultsSupported || this.isDestroyed)
|
|
3237
|
+
throw new Error('Scheduled result delivery is unavailable.');
|
|
3238
|
+
const thread = this.threadManager.getThread(delivery.schedule.threadId);
|
|
3239
|
+
if (!thread)
|
|
3240
|
+
throw new Error('The original thread no longer exists.');
|
|
3241
|
+
await this.scheduleDelivery.deliver(delivery, thread.name);
|
|
3242
|
+
},
|
|
3243
|
+
});
|
|
3244
|
+
await service.initialize();
|
|
3245
|
+
if (!this.isDestroyed)
|
|
3246
|
+
this.scheduleDelivery = new ScheduleDeliveryClient_1.ScheduleDeliveryClient(this.wsClient);
|
|
3247
|
+
this.schedules = service;
|
|
3248
|
+
return service;
|
|
3249
|
+
})();
|
|
3250
|
+
return this.scheduleInitialization;
|
|
3251
|
+
}
|
|
3252
|
+
async activeSchedules(threadId) {
|
|
3253
|
+
const owner = this.scheduleOwners.get(threadId);
|
|
3254
|
+
if (!owner || !this.schedules)
|
|
3255
|
+
return [];
|
|
3256
|
+
const records = await this.schedules.list(owner);
|
|
3257
|
+
const active = records.filter(record => ['creating', 'active', 'running'].includes(record.state));
|
|
3258
|
+
if (!active.length && !this.scheduleManagement.has(threadId))
|
|
3259
|
+
this.scheduleOwners.delete(threadId);
|
|
3260
|
+
return active;
|
|
3261
|
+
}
|
|
3262
|
+
async assertSchedulesIdle(threadId) {
|
|
3263
|
+
if (this.scheduleManagement.has(threadId) || this.schedules?.hasActiveSchedules(threadId)) {
|
|
3264
|
+
throw new Error('Cancel this thread\'s schedules with /schedule cancel <id> before resetting context, changing directory, or deleting the thread.');
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
async handleScheduleCommand(message, threadId) {
|
|
3268
|
+
const respond = (result) => this.sendResponse(message.messageId, threadId, result, true);
|
|
3269
|
+
let reserved = false;
|
|
3270
|
+
try {
|
|
3271
|
+
const command = (0, ScheduleCommand_1.parseScheduleCommand)(message.content ?? '');
|
|
3272
|
+
if (!command || command.kind === 'help') {
|
|
3273
|
+
respond({ success: true, output: ScheduleCommand_1.SCHEDULE_USAGE });
|
|
3274
|
+
return;
|
|
3275
|
+
}
|
|
3276
|
+
if (command.kind === 'invalid') {
|
|
3277
|
+
respond({ success: false, error: command.message });
|
|
3278
|
+
return;
|
|
3279
|
+
}
|
|
3280
|
+
if (command.kind === 'capabilities') {
|
|
3281
|
+
respond({ success: true, output: ScheduleCapabilities_1.SCHEDULE_CAPABILITIES });
|
|
3282
|
+
return;
|
|
3283
|
+
}
|
|
3284
|
+
if (!message.openId)
|
|
3285
|
+
throw new Error('Scheduled tasks require an authenticated thread owner.');
|
|
3286
|
+
if (message.attachments?.length || message.fileIds?.length || message.workingDirectory) {
|
|
3287
|
+
throw new Error('Use /cd first and include a self-contained text prompt. Schedule commands do not accept attachments or directory overrides.');
|
|
3288
|
+
}
|
|
3289
|
+
const owner = { threadId, openId: message.openId, generation: this.scheduleGeneration(threadId) };
|
|
3290
|
+
if (command.kind === 'create' || command.kind === 'cancel') {
|
|
3291
|
+
if (this.scheduleManagement.has(threadId))
|
|
3292
|
+
throw new Error('A schedule operation is already in progress for this thread.');
|
|
3293
|
+
this.scheduleManagement.add(threadId);
|
|
3294
|
+
reserved = true;
|
|
3295
|
+
}
|
|
3296
|
+
const service = await this.initializeSchedules();
|
|
3297
|
+
if (command.kind === 'list') {
|
|
3298
|
+
await service.refresh(owner);
|
|
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'
|
|
3339
|
+
? 'Schedules are lost when the native process exits; recurring tasks expire after seven days.'
|
|
3340
|
+
: 'Native job storage is isolated and is never automatically reopened after process exit.';
|
|
3341
|
+
respond({ success: true, 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[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}.` });
|
|
3342
|
+
}
|
|
3343
|
+
finally {
|
|
3344
|
+
this.scheduleManagement.delete(threadId);
|
|
3345
|
+
reserved = false;
|
|
3346
|
+
await this.activeSchedules(threadId).catch(() => undefined);
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3349
|
+
catch (error) {
|
|
3350
|
+
respond({ success: false, error: error instanceof Error ? error.message : 'Schedule operation failed.' });
|
|
3351
|
+
}
|
|
3352
|
+
finally {
|
|
3353
|
+
if (reserved) {
|
|
3354
|
+
this.scheduleManagement.delete(threadId);
|
|
3355
|
+
await this.activeSchedules(threadId).catch(() => undefined);
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3110
3359
|
/** Shared card/text Apply path. Callers hold exclusive settings admission. */
|
|
3111
3360
|
async changeWorkingDirectory(threadId, targetDir) {
|
|
3361
|
+
await this.assertSchedulesIdle(threadId);
|
|
3112
3362
|
if (this.isDestroyed || this.automaticUpdateInProgress || this.abortOperations.has(threadId)
|
|
3113
3363
|
|| this.threadPool.isThreadBusy(threadId) || this.coordinatorPreparations.has(threadId) || this.hasThreadQueueState(threadId)) {
|
|
3114
3364
|
throw new Error('Cannot change working directory while the thread has active or queued work. Retry when it is idle.');
|
|
@@ -3424,6 +3674,8 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
3424
3674
|
this.directoryBrowser.destroy();
|
|
3425
3675
|
this.settingsService.destroy();
|
|
3426
3676
|
this.isDestroyed = true;
|
|
3677
|
+
this.scheduleDelivery?.destroy();
|
|
3678
|
+
this.pendingOutputFiles.clear();
|
|
3427
3679
|
for (const threadId of this.activeThreadOperations.keys()) {
|
|
3428
3680
|
this.settingsAdmission.cancelRecoverable(threadId);
|
|
3429
3681
|
this.cancelThreadOperation(threadId, 'Request cancelled because the CLI is shutting down.');
|
|
@@ -3436,6 +3688,7 @@ You can also use natural language commands to control Claude Code CLI.`,
|
|
|
3436
3688
|
this.notificationAdapter.unregister();
|
|
3437
3689
|
try {
|
|
3438
3690
|
const results = await Promise.allSettled([
|
|
3691
|
+
this.scheduleInitialization?.then(service => service.destroy(), () => undefined),
|
|
3439
3692
|
this.delegation.destroy(),
|
|
3440
3693
|
...[...this.delegationBridges.values()].map(bridge => bridge.close()),
|
|
3441
3694
|
this.threadPool.destroyAll({ deleteData: false, shutdown: true }),
|