@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
|
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ClaudePersistentExecutor = void 0;
|
|
7
|
+
const ClaudeSessionSchedules_1 = require("../scheduling/claude/ClaudeSessionSchedules");
|
|
8
|
+
const tools_1 = require("../managed/tools");
|
|
7
9
|
const ManagedSpawn_1 = require("./ManagedSpawn");
|
|
8
10
|
const OwnershipRuntime_1 = require("../delegation/OwnershipRuntime");
|
|
9
11
|
const NativeHistoryFiles_1 = require("../delegation/NativeHistoryFiles");
|
|
@@ -270,7 +272,104 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
270
272
|
}
|
|
271
273
|
return data;
|
|
272
274
|
}
|
|
275
|
+
sessionSchedules;
|
|
276
|
+
scheduleHooksReady = false;
|
|
277
|
+
currentScheduleManagement = false;
|
|
278
|
+
nativeScheduleTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
279
|
+
schedules() {
|
|
280
|
+
return this.sessionSchedules ??= new ClaudeSessionSchedules_1.ClaudeSessionSchedules({
|
|
281
|
+
send: frame => {
|
|
282
|
+
if (!this.claudeProcess?.stdin?.writable)
|
|
283
|
+
throw new Error('Native conversation is unavailable.');
|
|
284
|
+
this.claudeProcess.stdin.write(JSON.stringify(frame) + '\n');
|
|
285
|
+
},
|
|
286
|
+
manage: async (prompt, current) => {
|
|
287
|
+
await this.listModels();
|
|
288
|
+
return this.execute(prompt, { nativeScheduleManagement: true, nativeScheduleCurrent: current });
|
|
289
|
+
},
|
|
290
|
+
wake: () => { void this.processQueue(); },
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
async withNativeScheduleOperation(id, current, run, inTurn) {
|
|
294
|
+
if (this.delegationWorker || this.isDestroyed || this.isStopping || this.sandbox.isRestricted())
|
|
295
|
+
throw new Error('Native schedule owner or sandbox is unavailable.');
|
|
296
|
+
if (!inTurn)
|
|
297
|
+
await this.listModels();
|
|
298
|
+
if (!this.scheduleHooksReady)
|
|
299
|
+
throw new Error('Native scheduling hooks are not initialized.');
|
|
300
|
+
return this.schedules().inToolOperation(id, current, run, inTurn);
|
|
301
|
+
}
|
|
302
|
+
nativeScheduleAction(id) { return this.sessionSchedules?.action(id); }
|
|
303
|
+
async createNativeSchedule(input, onEvent, isOwnerCurrent) {
|
|
304
|
+
if (this.delegationWorker || this.isDestroyed || this.isStopping || this.sandbox.isRestricted()
|
|
305
|
+
|| input.cwd !== this.currentWorkingDirectory)
|
|
306
|
+
throw new Error('Native schedule context or sandbox is unavailable.');
|
|
307
|
+
if (!this.scheduleHooksReady)
|
|
308
|
+
throw new Error('Native scheduling hooks are not initialized.');
|
|
309
|
+
const timezone = await this.readNativeScheduleTimezone();
|
|
310
|
+
return this.schedules().create(input, onEvent, isOwnerCurrent, timezone);
|
|
311
|
+
}
|
|
312
|
+
/** Inspect only the effective TZ; never log, retain, or expose settings to a model. */
|
|
313
|
+
readNativeScheduleTimezone() {
|
|
314
|
+
const child = this.claudeProcess;
|
|
315
|
+
if (!child?.stdin?.writable)
|
|
316
|
+
return Promise.reject(new Error('Native conversation is unavailable.'));
|
|
317
|
+
const stdin = child.stdin;
|
|
318
|
+
const requestId = `schedule-timezone-${(0, crypto_1.randomUUID)()}`;
|
|
319
|
+
return new Promise((resolve, reject) => {
|
|
320
|
+
const failure = () => {
|
|
321
|
+
this.pendingControlRequests.delete(requestId);
|
|
322
|
+
clearTimeout(timer);
|
|
323
|
+
reject(new Error('Native session timezone could not be verified. No schedule was created.'));
|
|
324
|
+
};
|
|
325
|
+
const timer = setTimeout(failure, 10_000);
|
|
326
|
+
this.pendingControlRequests.set(requestId, {
|
|
327
|
+
timer, reject: failure,
|
|
328
|
+
resolve: value => {
|
|
329
|
+
clearTimeout(timer);
|
|
330
|
+
this.pendingControlRequests.delete(requestId);
|
|
331
|
+
if (this.claudeProcess !== child || this.isDestroyed || this.isStopping) {
|
|
332
|
+
failure();
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
try {
|
|
336
|
+
const response = value;
|
|
337
|
+
if (!response?.effective || typeof response.effective !== 'object') {
|
|
338
|
+
failure();
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (response.effective.disableAllHooks || response.effective.allowManagedHooksOnly) {
|
|
342
|
+
reject(new Error('Native scheduling requires active SDK callback hooks. Native hook policy was not changed.'));
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
const timezone = response.effective.env?.TZ ?? this.nativeScheduleTimezone;
|
|
346
|
+
if (typeof timezone !== 'string' || !timezone || timezone.length > 128) {
|
|
347
|
+
failure();
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
resolve(new Intl.DateTimeFormat('en', { timeZone: timezone }).resolvedOptions().timeZone);
|
|
351
|
+
}
|
|
352
|
+
catch {
|
|
353
|
+
failure();
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
});
|
|
357
|
+
try {
|
|
358
|
+
stdin.write(JSON.stringify({ type: 'control_request', request_id: requestId,
|
|
359
|
+
request: { subtype: 'get_settings' } }) + '\n', error => { if (error)
|
|
360
|
+
failure(); });
|
|
361
|
+
}
|
|
362
|
+
catch {
|
|
363
|
+
failure();
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
}
|
|
273
367
|
delegation;
|
|
368
|
+
async configureManagedTools(connection) {
|
|
369
|
+
if (this.delegationWorker && connection)
|
|
370
|
+
throw new Error('Managed child workers cannot register control tools.');
|
|
371
|
+
await this.configureDelegation(connection);
|
|
372
|
+
}
|
|
274
373
|
async configureDelegation(connection) {
|
|
275
374
|
if ((0, contract_1.sameConnection)(this.delegation, connection))
|
|
276
375
|
return;
|
|
@@ -287,6 +386,8 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
287
386
|
* directories that may have their own .claude-session files.
|
|
288
387
|
*/
|
|
289
388
|
isBusy() {
|
|
389
|
+
if (this.sessionSchedules?.busy)
|
|
390
|
+
return true;
|
|
290
391
|
return this.isProcessing || this.isStarting || this.commandQueue.length > 0;
|
|
291
392
|
}
|
|
292
393
|
async setWorkingDirectory(targetPath) {
|
|
@@ -335,6 +436,14 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
335
436
|
// Build arguments
|
|
336
437
|
// Note: --output-format=stream-json requires --verbose
|
|
337
438
|
const restricted = this.sandbox.isRestricted();
|
|
439
|
+
// Claude restores session-only cron jobs from the resumed transcript, even
|
|
440
|
+
// when the original CronCreate used durable:false. A resumed process that
|
|
441
|
+
// cannot install our ownership hooks must therefore disable native task
|
|
442
|
+
// execution at launch; otherwise a remote-cli job can run unowned after a
|
|
443
|
+
// restart or in a restricted/worker process.
|
|
444
|
+
const managedScheduling = !this.delegationWorker && !restricted
|
|
445
|
+
&& this.delegation?.groups?.includes('scheduling') === true;
|
|
446
|
+
const disableResumedSchedules = !!this.sessionId && !managedScheduling;
|
|
338
447
|
const mcpServers = {};
|
|
339
448
|
const args = [
|
|
340
449
|
'--input-format=stream-json',
|
|
@@ -360,12 +469,14 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
360
469
|
fileHookCommand = [process.execPath, ClaudePersistentExecutor.FILE_POLICY_SCRIPT, socketPath, this.filePolicyToken]
|
|
361
470
|
.map(quote).join(' ') + ' || exit 2';
|
|
362
471
|
}
|
|
363
|
-
|
|
472
|
+
let settings = this.sandbox.spawnSettings(this.currentWorkingDirectory, fileHookCommand);
|
|
364
473
|
if (settings && this.delegation) {
|
|
365
474
|
const permissions = settings.permissions;
|
|
366
475
|
permissions.allow = [...(permissions.allow ?? []),
|
|
367
|
-
...
|
|
476
|
+
...(0, tools_1.managedTools)(this.delegation).map(tool => `mcp__remote-cli-delegation__${tool.name}`)];
|
|
368
477
|
}
|
|
478
|
+
if (disableResumedSchedules)
|
|
479
|
+
settings = { ...(settings ?? {}), scheduledTasksEnabled: false };
|
|
369
480
|
if (settings)
|
|
370
481
|
args.push('--settings', JSON.stringify(settings));
|
|
371
482
|
mcpServers['remote-cli-approval'] = {
|
|
@@ -378,6 +489,8 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
378
489
|
}
|
|
379
490
|
else {
|
|
380
491
|
args.push('--dangerously-skip-permissions');
|
|
492
|
+
if (disableResumedSchedules)
|
|
493
|
+
args.push('--settings', JSON.stringify({ scheduledTasksEnabled: false }));
|
|
381
494
|
}
|
|
382
495
|
if (this.delegation) {
|
|
383
496
|
mcpServers['remote-cli-delegation'] = (0, contract_1.delegationMcpConfig)(this.delegation);
|
|
@@ -462,6 +575,9 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
462
575
|
},
|
|
463
576
|
});
|
|
464
577
|
this.claudeProcess = child;
|
|
578
|
+
this.nativeScheduleTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
579
|
+
if (this.delegation?.groups?.includes('scheduling') && !this.delegationWorker && !restricted)
|
|
580
|
+
this.schedules();
|
|
465
581
|
if (this.delegationWorker)
|
|
466
582
|
this.workerGroups.track(child);
|
|
467
583
|
// Buffer for collecting stderr on startup (for error reporting)
|
|
@@ -484,6 +600,10 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
484
600
|
const forwardStderr = (text) => {
|
|
485
601
|
if (!text)
|
|
486
602
|
return;
|
|
603
|
+
// Stderr has no native turn ID; it cannot be attributed to a foreground
|
|
604
|
+
// request queued behind an autonomous scheduled turn.
|
|
605
|
+
if (this.sessionSchedules?.busy)
|
|
606
|
+
return;
|
|
487
607
|
// Collect stderr during startup for error reporting
|
|
488
608
|
if (isStartupPhase) {
|
|
489
609
|
stderrBuffer.push(text);
|
|
@@ -529,6 +649,11 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
529
649
|
// Use 'close' event (fires after all I/O streams are closed, i.e. after all stdout
|
|
530
650
|
// data events have been processed) instead of 'exit' for command completion logic.
|
|
531
651
|
child.on('close', (code, signal) => {
|
|
652
|
+
if (this.claudeProcess === child) {
|
|
653
|
+
this.sessionSchedules?.processClosed();
|
|
654
|
+
this.sessionSchedules = undefined;
|
|
655
|
+
this.scheduleHooksReady = false;
|
|
656
|
+
}
|
|
532
657
|
if (this.claudeProcess !== child)
|
|
533
658
|
return;
|
|
534
659
|
flushStderr();
|
|
@@ -618,7 +743,12 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
618
743
|
child.on('error', (error) => {
|
|
619
744
|
console.error('[ClaudePersistent] Process error:', error);
|
|
620
745
|
this.clearApprovals('Claude process failed');
|
|
621
|
-
|
|
746
|
+
// An error is not exit evidence for a session that owns native jobs.
|
|
747
|
+
// Retain the process until close (or an explicit bounded stop) confirms it.
|
|
748
|
+
if (this.sessionSchedules?.hasJobs)
|
|
749
|
+
this.isStopping = true;
|
|
750
|
+
else
|
|
751
|
+
this.claudeProcess = null;
|
|
622
752
|
this.isStarting = false;
|
|
623
753
|
if (this.currentCommandReject) {
|
|
624
754
|
if (error.message.includes('ENOENT')) {
|
|
@@ -1076,6 +1206,10 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1076
1206
|
const parsedMessage = JSON.parse(line);
|
|
1077
1207
|
// Handle native Claude Control response packets (models catalog, etc.).
|
|
1078
1208
|
// These bypass raw stdout logging to prevent any potential account/credential leakage.
|
|
1209
|
+
if (this.sessionSchedules?.accept(parsedMessage))
|
|
1210
|
+
return;
|
|
1211
|
+
if (parsedMessage.type === 'result' && !parsedMessage.parent_tool_use_id)
|
|
1212
|
+
this.sessionSchedules?.foregroundEnded();
|
|
1079
1213
|
if (parsedMessage.type === 'control_response' || parsedMessage.type === 'control_request') {
|
|
1080
1214
|
this.handleControlMessage(parsedMessage);
|
|
1081
1215
|
return;
|
|
@@ -1346,7 +1480,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1346
1480
|
// which are converted to Feishu Card 2.0 elements by the router.
|
|
1347
1481
|
// Emit hook for tool execution completion (this is the ACTUAL execution result)
|
|
1348
1482
|
// Note: We don't have the original tool name here, but we have the tool_use_id
|
|
1349
|
-
if (this.lifecycleHooks)
|
|
1483
|
+
if (this.lifecycleHooks && !this.currentScheduleManagement)
|
|
1350
1484
|
ClaudeCodeHooks_1.claudeCodeHooks.notifyToolExecuted({
|
|
1351
1485
|
toolName: toolUseId || 'unknown', // Use tool_use_id as identifier
|
|
1352
1486
|
params: {}, // Original params not available in tool_result
|
|
@@ -1444,7 +1578,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1444
1578
|
console.log('[ClaudePersistent] Requesting interactive input:', prompt);
|
|
1445
1579
|
this.isWaitingForInput = true;
|
|
1446
1580
|
// Emit hook to notify user (fire and forget)
|
|
1447
|
-
if (this.lifecycleHooks)
|
|
1581
|
+
if (this.lifecycleHooks && !this.currentScheduleManagement)
|
|
1448
1582
|
ClaudeCodeHooks_1.claudeCodeHooks.requestUserInput({
|
|
1449
1583
|
prompt,
|
|
1450
1584
|
type: 'text',
|
|
@@ -1494,6 +1628,8 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1494
1628
|
content: input,
|
|
1495
1629
|
},
|
|
1496
1630
|
};
|
|
1631
|
+
inputMessage.uuid = (0, crypto_1.randomUUID)();
|
|
1632
|
+
this.sessionSchedules?.foregroundDispatched(inputMessage.uuid);
|
|
1497
1633
|
const inputLine = JSON.stringify(inputMessage);
|
|
1498
1634
|
console.log(`[ClaudePersistent] Sending user input: ${input}`);
|
|
1499
1635
|
this.claudeProcess.stdin?.write(inputLine + '\n');
|
|
@@ -1527,7 +1663,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1527
1663
|
const output = this.currentOutputBuffer.join('');
|
|
1528
1664
|
console.log(`[ClaudePersistent] Completing command, success=${success}, output length=${output.length}, output preview: ${output.substring(0, 100)}...`);
|
|
1529
1665
|
// Emit task completion hooks
|
|
1530
|
-
if (this.lifecycleHooks && this.currentTaskId) {
|
|
1666
|
+
if (this.lifecycleHooks && !this.currentScheduleManagement && this.currentTaskId) {
|
|
1531
1667
|
const endTime = Date.now();
|
|
1532
1668
|
const duration = endTime - this.currentTaskStartTime;
|
|
1533
1669
|
if (success) {
|
|
@@ -1575,6 +1711,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1575
1711
|
* Reset current command state
|
|
1576
1712
|
*/
|
|
1577
1713
|
resetCurrentCommand() {
|
|
1714
|
+
this.currentScheduleManagement = false;
|
|
1578
1715
|
this.clearApprovals('Task is no longer active');
|
|
1579
1716
|
this.currentOutputBuffer = [];
|
|
1580
1717
|
this.currentObjectiveDispatched = false;
|
|
@@ -1606,7 +1743,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1606
1743
|
* Process the command queue
|
|
1607
1744
|
*/
|
|
1608
1745
|
async processQueue() {
|
|
1609
|
-
if (this.isProcessing || this.isStarting || this.commandQueue.length === 0) {
|
|
1746
|
+
if (this.isProcessing || this.isStarting || this.sessionSchedules?.busy || this.commandQueue.length === 0) {
|
|
1610
1747
|
return;
|
|
1611
1748
|
}
|
|
1612
1749
|
// Ensure process is running
|
|
@@ -1633,11 +1770,38 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1633
1770
|
}
|
|
1634
1771
|
return;
|
|
1635
1772
|
}
|
|
1773
|
+
if (this.delegation?.groups?.includes('scheduling') && !this.scheduleHooksReady && !this.delegationWorker && !this.sandbox.isRestricted()) {
|
|
1774
|
+
// Initialize callback hooks once per native process before its first model turn.
|
|
1775
|
+
this.isStarting = true;
|
|
1776
|
+
try {
|
|
1777
|
+
await this.listModels();
|
|
1778
|
+
}
|
|
1779
|
+
catch {
|
|
1780
|
+
const failed = this.commandQueue.shift();
|
|
1781
|
+
// A resumed native scheduler can fire before a later command. If hook
|
|
1782
|
+
// registration or policy validation failed, retire that process before
|
|
1783
|
+
// returning an error so no restored job can run without ownership.
|
|
1784
|
+
await this.stopProcess().catch(() => { });
|
|
1785
|
+
failed?.resolve({ success: false, error: 'Native managed-tool initialization failed.' });
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
finally {
|
|
1789
|
+
this.isStarting = false;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
if (this.sessionSchedules?.busy)
|
|
1793
|
+
return;
|
|
1636
1794
|
const command = this.commandQueue.shift();
|
|
1637
1795
|
if (!command) {
|
|
1638
1796
|
return;
|
|
1639
1797
|
}
|
|
1798
|
+
if (command.options.nativeScheduleCurrent && !command.options.nativeScheduleCurrent()) {
|
|
1799
|
+
command.resolve({ success: false, error: 'Native schedule management authorization expired before dispatch.' });
|
|
1800
|
+
void this.processQueue();
|
|
1801
|
+
return;
|
|
1802
|
+
}
|
|
1640
1803
|
this.isProcessing = true;
|
|
1804
|
+
this.currentScheduleManagement = command.options.nativeScheduleManagement === true;
|
|
1641
1805
|
this.currentStreamCallback = command.options.onStream;
|
|
1642
1806
|
this.currentAssistantTextSeen = false;
|
|
1643
1807
|
this.currentDisplayTextCallback = text => {
|
|
@@ -1672,7 +1836,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1672
1836
|
this.currentTaskId = `task_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
1673
1837
|
this.currentTaskStartTime = Date.now();
|
|
1674
1838
|
// Emit task started hook
|
|
1675
|
-
if (this.lifecycleHooks)
|
|
1839
|
+
if (this.lifecycleHooks && !this.currentScheduleManagement)
|
|
1676
1840
|
ClaudeCodeHooks_1.claudeCodeHooks.notifyTaskStarted({
|
|
1677
1841
|
taskId: this.currentTaskId,
|
|
1678
1842
|
description: command.prompt,
|
|
@@ -1725,6 +1889,8 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1725
1889
|
},
|
|
1726
1890
|
...(command.isSlashCommand ? { isSlashCommand: true } : {}),
|
|
1727
1891
|
};
|
|
1892
|
+
inputMessage.uuid = (0, crypto_1.randomUUID)();
|
|
1893
|
+
this.sessionSchedules?.foregroundDispatched(inputMessage.uuid, command.options.nativeScheduleManagement);
|
|
1728
1894
|
const inputLine = JSON.stringify(inputMessage);
|
|
1729
1895
|
console.log(`[ClaudePersistent] Sending command${command.isSlashCommand ? ' (slash)' : ''}: ${command.prompt.substring(0, 100)}...`);
|
|
1730
1896
|
this.currentObjectiveDispatched = true;
|
|
@@ -1779,7 +1945,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1779
1945
|
console.log('[ClaudePersistent] Aborting current command...');
|
|
1780
1946
|
this.denyAllPendingApprovals('Task aborted by user');
|
|
1781
1947
|
// Emit task aborted hook before stopping
|
|
1782
|
-
if (this.lifecycleHooks && this.currentTaskId) {
|
|
1948
|
+
if (this.lifecycleHooks && !this.currentScheduleManagement && this.currentTaskId) {
|
|
1783
1949
|
ClaudeCodeHooks_1.claudeCodeHooks.notifyTaskAborted({
|
|
1784
1950
|
taskId: this.currentTaskId,
|
|
1785
1951
|
description: '',
|
|
@@ -1911,6 +2077,12 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1911
2077
|
if (!child || !child.stdin || child.killed) {
|
|
1912
2078
|
throw new Error('Claude process is not available for control initialization');
|
|
1913
2079
|
}
|
|
2080
|
+
// Install the lifecycle guard even in restricted mode so a native schedule
|
|
2081
|
+
// restored from an earlier unrestricted session cannot run unowned after the
|
|
2082
|
+
// execution policy changes. Creation and management remain rejected below.
|
|
2083
|
+
const scheduleHooks = !this.delegationWorker;
|
|
2084
|
+
if (scheduleHooks)
|
|
2085
|
+
this.schedules();
|
|
1914
2086
|
const stdin = child.stdin;
|
|
1915
2087
|
const requestId = `catalog-${(0, crypto_1.randomUUID)()}`;
|
|
1916
2088
|
const requestPacket = {
|
|
@@ -1918,6 +2090,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1918
2090
|
request_id: requestId,
|
|
1919
2091
|
request: {
|
|
1920
2092
|
subtype: 'initialize',
|
|
2093
|
+
...(scheduleHooks ? { hooks: ClaudeSessionSchedules_1.SCHEDULE_HOOKS } : {}),
|
|
1921
2094
|
},
|
|
1922
2095
|
};
|
|
1923
2096
|
return new Promise((resolve, reject) => {
|
|
@@ -1932,7 +2105,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1932
2105
|
reject(new Error('Claude control initialization timed out after 10000ms'));
|
|
1933
2106
|
}, 10_000);
|
|
1934
2107
|
this.pendingControlRequests.set(requestId, {
|
|
1935
|
-
resolve: (response) => {
|
|
2108
|
+
resolve: async (response) => {
|
|
1936
2109
|
cleanup();
|
|
1937
2110
|
if (this.claudeProcess !== child || this.isDestroyed || this.isStopping) {
|
|
1938
2111
|
reject(new Error('Claude catalog process is no longer active'));
|
|
@@ -1941,6 +2114,13 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
1941
2114
|
try {
|
|
1942
2115
|
const rawResponse = response || {};
|
|
1943
2116
|
const { models, rawEntries } = (0, ClaudeSettings_1.parseClaudeModelsCatalog)(rawResponse.models, this.reportedModel || this.model);
|
|
2117
|
+
if (scheduleHooks && this.sessionId && this.delegation?.groups?.includes('scheduling')) {
|
|
2118
|
+
await this.readNativeScheduleTimezone();
|
|
2119
|
+
}
|
|
2120
|
+
if (scheduleHooks) {
|
|
2121
|
+
this.schedules();
|
|
2122
|
+
this.scheduleHooksReady = true;
|
|
2123
|
+
}
|
|
1944
2124
|
this.cachedRawEntries = rawEntries;
|
|
1945
2125
|
this.cachedModelCatalog = models;
|
|
1946
2126
|
resolve(models);
|
|
@@ -2115,7 +2295,7 @@ class ClaudePersistentExecutor extends events_1.EventEmitter {
|
|
|
2115
2295
|
await this.stopProcess();
|
|
2116
2296
|
// Step 2: Run compact as a one-shot process outside the full context
|
|
2117
2297
|
const compactResult = await new Promise((resolve) => {
|
|
2118
|
-
const child = (0, OwnershipRuntime_1.ownedSpawn)(this.claudeCommand, ['--resume', sessionIdBeforeCompact, '--print', '/compact'], {
|
|
2298
|
+
const child = (0, OwnershipRuntime_1.ownedSpawn)(this.claudeCommand, ['--resume', sessionIdBeforeCompact, '--settings', JSON.stringify({ scheduledTasksEnabled: false }), '--print', '/compact'], {
|
|
2119
2299
|
cwd: this.currentWorkingDirectory,
|
|
2120
2300
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
2121
2301
|
env: { ...process.env, FORCE_COLOR: '0', CLAUDECODE: '', CLAUDE_CODE: '' },
|