chatroom-cli 1.77.5 → 1.78.1
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/index.js +67 -45
- package/dist/index.js.map +8 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -99284,6 +99284,30 @@ var init_assigned_task_snapshot_store = __esm(() => {
|
|
|
99284
99284
|
rows = [];
|
|
99285
99285
|
});
|
|
99286
99286
|
|
|
99287
|
+
// src/commands/machine/daemon-start/restart-orchestrator-in-flight.ts
|
|
99288
|
+
function roleKey2(chatroomId, role) {
|
|
99289
|
+
return `${chatroomId}:${role.toLowerCase()}`;
|
|
99290
|
+
}
|
|
99291
|
+
function markRestartOrchestratorInFlight(chatroomId, role, correlationId) {
|
|
99292
|
+
inFlight.set(roleKey2(chatroomId, role), correlationId);
|
|
99293
|
+
}
|
|
99294
|
+
function clearRestartOrchestratorInFlight(chatroomId, role, correlationId) {
|
|
99295
|
+
const key = roleKey2(chatroomId, role);
|
|
99296
|
+
if (correlationId !== undefined && inFlight.get(key) !== correlationId)
|
|
99297
|
+
return;
|
|
99298
|
+
inFlight.delete(key);
|
|
99299
|
+
}
|
|
99300
|
+
function isRestartOrchestratorInFlight(chatroomId, role) {
|
|
99301
|
+
return inFlight.has(roleKey2(chatroomId, role));
|
|
99302
|
+
}
|
|
99303
|
+
function filterSnapshotsExcludingRestartInFlight(snapshots) {
|
|
99304
|
+
return snapshots.filter((row) => !isRestartOrchestratorInFlight(row.chatroomId, row.agentConfig.role));
|
|
99305
|
+
}
|
|
99306
|
+
var inFlight;
|
|
99307
|
+
var init_restart_orchestrator_in_flight = __esm(() => {
|
|
99308
|
+
inFlight = new Map;
|
|
99309
|
+
});
|
|
99310
|
+
|
|
99287
99311
|
// src/commands/machine/daemon-start/native-task-delivery-coordinator.ts
|
|
99288
99312
|
class NativeTaskDeliveryCoordinator {
|
|
99289
99313
|
onSessionLost(params) {
|
|
@@ -99296,6 +99320,8 @@ class NativeTaskDeliveryCoordinator {
|
|
|
99296
99320
|
getRoleDeliveryState().resetDeliveryState(chatroomId, role);
|
|
99297
99321
|
}
|
|
99298
99322
|
tryInjectNextForRole(chatroomId, role) {
|
|
99323
|
+
if (isRestartOrchestratorInFlight(chatroomId, role))
|
|
99324
|
+
return;
|
|
99299
99325
|
const session2 = getNativeDeliverySession();
|
|
99300
99326
|
if (!session2)
|
|
99301
99327
|
return;
|
|
@@ -99315,7 +99341,10 @@ class NativeTaskDeliveryCoordinator {
|
|
|
99315
99341
|
});
|
|
99316
99342
|
}
|
|
99317
99343
|
reconcileAssignedTasks(params) {
|
|
99318
|
-
const
|
|
99344
|
+
const tasks = filterSnapshotsExcludingRestartInFlight(params.tasks);
|
|
99345
|
+
if (tasks.length === 0)
|
|
99346
|
+
return;
|
|
99347
|
+
const { runtime: runtime4, effectContext: effectContext2, agentMgr, sessionDeps, machineId } = params;
|
|
99319
99348
|
const deliveryState = getRoleDeliveryState();
|
|
99320
99349
|
const ledger = getNativeDeliveryLedger();
|
|
99321
99350
|
const pendingFirst = [...tasks].sort((a, b) => {
|
|
@@ -99404,6 +99433,8 @@ function resetRoleDeliveryState(chatroomId, role) {
|
|
|
99404
99433
|
getRoleDeliveryState().resetDeliveryState(chatroomId, role);
|
|
99405
99434
|
}
|
|
99406
99435
|
function notifyNativeTurnIdle(params) {
|
|
99436
|
+
if (isRestartOrchestratorInFlight(params.chatroomId, params.role))
|
|
99437
|
+
return;
|
|
99407
99438
|
logNativeDeliveryPrimary(params.role, params.chatroomId);
|
|
99408
99439
|
getNativeTaskDeliveryCoordinator().tryInjectNextForRole(params.chatroomId, params.role);
|
|
99409
99440
|
}
|
|
@@ -99416,6 +99447,7 @@ var init_native_task_delivery_coordinator = __esm(() => {
|
|
|
99416
99447
|
init_api3();
|
|
99417
99448
|
init_assigned_task_snapshot_store();
|
|
99418
99449
|
init_convex_error();
|
|
99450
|
+
init_restart_orchestrator_in_flight();
|
|
99419
99451
|
});
|
|
99420
99452
|
|
|
99421
99453
|
// src/commands/machine/daemon-start/restart-orchestrator.ts
|
|
@@ -99438,14 +99470,6 @@ async function waitForHarnessSessionId(deps, event, pid) {
|
|
|
99438
99470
|
if (initial?.harnessSessionId) {
|
|
99439
99471
|
return initial.harnessSessionId;
|
|
99440
99472
|
}
|
|
99441
|
-
await deps.session.backend.mutation(api.machines.emitHarnessSessionAwaiting, {
|
|
99442
|
-
sessionId: deps.session.sessionId,
|
|
99443
|
-
machineId: deps.session.machineId,
|
|
99444
|
-
chatroomId: event.chatroomId,
|
|
99445
|
-
role: event.role,
|
|
99446
|
-
pid,
|
|
99447
|
-
timeoutMs: HARNESS_SESSION_READY_TIMEOUT_MS
|
|
99448
|
-
});
|
|
99449
99473
|
const deadline = Date.now() + HARNESS_SESSION_READY_TIMEOUT_MS;
|
|
99450
99474
|
while (Date.now() < deadline) {
|
|
99451
99475
|
const slot = deps.agentMgr.getSlot(event.chatroomId, event.role);
|
|
@@ -99454,14 +99478,6 @@ async function waitForHarnessSessionId(deps, event, pid) {
|
|
|
99454
99478
|
}
|
|
99455
99479
|
await sleep5(100);
|
|
99456
99480
|
}
|
|
99457
|
-
await deps.session.backend.mutation(api.machines.emitHarnessSessionTimeout, {
|
|
99458
|
-
sessionId: deps.session.sessionId,
|
|
99459
|
-
machineId: deps.session.machineId,
|
|
99460
|
-
chatroomId: event.chatroomId,
|
|
99461
|
-
role: event.role,
|
|
99462
|
-
pid,
|
|
99463
|
-
timeoutMs: HARNESS_SESSION_READY_TIMEOUT_MS
|
|
99464
|
-
});
|
|
99465
99481
|
await deps.agentMgr.stop({
|
|
99466
99482
|
chatroomId: event.chatroomId,
|
|
99467
99483
|
role: event.role,
|
|
@@ -99556,15 +99572,14 @@ async function deliverPendingTasks(deps, event) {
|
|
|
99556
99572
|
}
|
|
99557
99573
|
async function runRestartOrchestrator(deps, event) {
|
|
99558
99574
|
const { chatroomId, role } = event;
|
|
99575
|
+
markRestartOrchestratorInFlight(chatroomId, role, event.correlationId);
|
|
99559
99576
|
try {
|
|
99560
|
-
await emitPhase(deps, event, "reset");
|
|
99561
99577
|
resetRoleDeliveryState(chatroomId, role);
|
|
99562
99578
|
await deps.agentMgr.stop({
|
|
99563
99579
|
chatroomId,
|
|
99564
99580
|
role,
|
|
99565
99581
|
reason: "user.restart"
|
|
99566
99582
|
});
|
|
99567
|
-
await emitPhase(deps, event, "spawn");
|
|
99568
99583
|
const spawnResult = await exports_Effect.runPromise(deps.agentMgr.ensureRunning({
|
|
99569
99584
|
chatroomId,
|
|
99570
99585
|
role,
|
|
@@ -99578,23 +99593,12 @@ async function runRestartOrchestrator(deps, event) {
|
|
|
99578
99593
|
await emitPhase(deps, event, "failed", spawnResult.error ?? "spawn failed");
|
|
99579
99594
|
return;
|
|
99580
99595
|
}
|
|
99581
|
-
await emitPhase(deps, event, "await_session");
|
|
99582
99596
|
const harnessSessionId = await waitForHarnessSessionId(deps, event, spawnResult.pid);
|
|
99583
99597
|
if (!harnessSessionId) {
|
|
99584
99598
|
await emitPhase(deps, event, "failed", "harnessSessionId timeout");
|
|
99585
99599
|
return;
|
|
99586
99600
|
}
|
|
99587
|
-
await deps.session.backend.mutation(api.machines.emitHarnessSessionReady, {
|
|
99588
|
-
sessionId: deps.session.sessionId,
|
|
99589
|
-
machineId: deps.session.machineId,
|
|
99590
|
-
chatroomId,
|
|
99591
|
-
role,
|
|
99592
|
-
harnessSessionId,
|
|
99593
|
-
pid: spawnResult.pid
|
|
99594
|
-
});
|
|
99595
99601
|
await forceNativeWaiting(deps, event);
|
|
99596
|
-
await emitPhase(deps, event, "ready");
|
|
99597
|
-
await emitPhase(deps, event, "deliver");
|
|
99598
99602
|
const deliveredTaskIds = await deliverPendingTasks(deps, event);
|
|
99599
99603
|
await deps.session.backend.mutation(api.machines.emitRestartCompleted, {
|
|
99600
99604
|
sessionId: deps.session.sessionId,
|
|
@@ -99604,10 +99608,11 @@ async function runRestartOrchestrator(deps, event) {
|
|
|
99604
99608
|
correlationId: event.correlationId,
|
|
99605
99609
|
deliveredTaskIds
|
|
99606
99610
|
});
|
|
99607
|
-
await emitPhase(deps, event, "completed");
|
|
99608
99611
|
} catch (err) {
|
|
99609
99612
|
console.warn(`[RestartOrchestrator] failed for ${role}@${chatroomId}: ${getErrorMessage(err)}`);
|
|
99610
99613
|
await emitPhase(deps, event, "failed", getErrorMessage(err));
|
|
99614
|
+
} finally {
|
|
99615
|
+
clearRestartOrchestratorInFlight(chatroomId, role, event.correlationId);
|
|
99611
99616
|
}
|
|
99612
99617
|
}
|
|
99613
99618
|
var init_restart_orchestrator = __esm(() => {
|
|
@@ -99621,6 +99626,7 @@ var init_restart_orchestrator = __esm(() => {
|
|
|
99621
99626
|
init_native_task_injector();
|
|
99622
99627
|
init_api3();
|
|
99623
99628
|
init_convex_error();
|
|
99629
|
+
init_restart_orchestrator_in_flight();
|
|
99624
99630
|
});
|
|
99625
99631
|
|
|
99626
99632
|
// src/events/daemon/agent/on-request-restart-agent.ts
|
|
@@ -100742,6 +100748,17 @@ async function openFinder(workingDir) {
|
|
|
100742
100748
|
execFireAndForget(`${cmd} ${escapeShellArg(workingDir)}`, "open-finder");
|
|
100743
100749
|
return { success: true };
|
|
100744
100750
|
}
|
|
100751
|
+
async function openCursor(workingDir) {
|
|
100752
|
+
const available = await isCliAvailable("cursor");
|
|
100753
|
+
if (!available) {
|
|
100754
|
+
return {
|
|
100755
|
+
success: false,
|
|
100756
|
+
error: "Cursor CLI (cursor) not found. Install via: Cursor → Cmd+Shift+P → 'Shell Command: Install cursor in PATH'"
|
|
100757
|
+
};
|
|
100758
|
+
}
|
|
100759
|
+
execFireAndForget(`cursor ${escapeShellArg(workingDir)}`, "open-cursor");
|
|
100760
|
+
return { success: true };
|
|
100761
|
+
}
|
|
100745
100762
|
async function openGithubDesktop(workingDir) {
|
|
100746
100763
|
const available = await isCliAvailable("github");
|
|
100747
100764
|
if (!available) {
|
|
@@ -100816,6 +100833,7 @@ var init_execute_local_action = __esm(() => {
|
|
|
100816
100833
|
actionHandlers = {
|
|
100817
100834
|
"open-vscode": openVscode,
|
|
100818
100835
|
"open-finder": openFinder,
|
|
100836
|
+
"open-cursor": openCursor,
|
|
100819
100837
|
"open-github-desktop": openGithubDesktop,
|
|
100820
100838
|
"git-discard-file": gitDiscardFileAction,
|
|
100821
100839
|
"git-discard-all": gitDiscardAllAction,
|
|
@@ -103236,7 +103254,7 @@ var init_open_pending_session = __esm(() => {
|
|
|
103236
103254
|
|
|
103237
103255
|
// src/commands/machine/daemon-start/direct-harness/session-subscriber.ts
|
|
103238
103256
|
function startSessionSubscriber(daemonSession, wsClient2, deps) {
|
|
103239
|
-
const
|
|
103257
|
+
const inFlight2 = new Set;
|
|
103240
103258
|
const unsub = wsClient2.onUpdate(api.daemon.directHarness.sessions.listPendingSessionsForMachine, {
|
|
103241
103259
|
sessionId: daemonSession.sessionId,
|
|
103242
103260
|
machineId: daemonSession.machineId
|
|
@@ -103245,9 +103263,9 @@ function startSessionSubscriber(daemonSession, wsClient2, deps) {
|
|
|
103245
103263
|
return;
|
|
103246
103264
|
for (const session2 of pendingSessions) {
|
|
103247
103265
|
const rowId = session2._id;
|
|
103248
|
-
if (
|
|
103266
|
+
if (inFlight2.has(rowId))
|
|
103249
103267
|
continue;
|
|
103250
|
-
|
|
103268
|
+
inFlight2.add(rowId);
|
|
103251
103269
|
(async () => {
|
|
103252
103270
|
const harnessName = session2.opencode?.harnessName ?? "opencode-sdk";
|
|
103253
103271
|
const agent = session2.opencode?.lastUsedConfig?.agent ?? "build";
|
|
@@ -103258,7 +103276,7 @@ function startSessionSubscriber(daemonSession, wsClient2, deps) {
|
|
|
103258
103276
|
harnessName,
|
|
103259
103277
|
lastUsedConfig: { agent, ...model ? { model } : {} }
|
|
103260
103278
|
}, { logPrefix: "[direct-harness]", handleProviderIdEvents: true });
|
|
103261
|
-
})().finally(() =>
|
|
103279
|
+
})().finally(() => inFlight2.delete(rowId));
|
|
103262
103280
|
}
|
|
103263
103281
|
}, (err) => {
|
|
103264
103282
|
console.warn("[direct-harness] Session subscription error:", err instanceof Error ? err.message : String(err));
|
|
@@ -103793,21 +103811,21 @@ var init_prompt_subscriber2 = __esm(() => {
|
|
|
103793
103811
|
|
|
103794
103812
|
// src/commands/machine/daemon-start/agentic-query/session-subscriber.ts
|
|
103795
103813
|
function startSessionSubscriber2(daemonSession, wsClient2, deps) {
|
|
103796
|
-
const
|
|
103814
|
+
const inFlight2 = new Set;
|
|
103797
103815
|
const unsub = wsClient2.onUpdate(api.daemon.agenticQuery.runs.pendingForMachine, { sessionId: daemonSession.sessionId, machineId: daemonSession.machineId }, (pendingSessions) => {
|
|
103798
103816
|
if (!pendingSessions || pendingSessions.length === 0)
|
|
103799
103817
|
return;
|
|
103800
103818
|
for (const session2 of pendingSessions) {
|
|
103801
103819
|
const rowId = session2.runId;
|
|
103802
|
-
if (
|
|
103820
|
+
if (inFlight2.has(rowId))
|
|
103803
103821
|
continue;
|
|
103804
|
-
|
|
103822
|
+
inFlight2.add(rowId);
|
|
103805
103823
|
openPendingHarnessSession(daemonSession, deps, {
|
|
103806
103824
|
rowId: session2.runId,
|
|
103807
103825
|
workspaceId: session2.workspaceId,
|
|
103808
103826
|
harnessName: session2.harnessName,
|
|
103809
103827
|
lastUsedConfig: session2.lastUsedConfig
|
|
103810
|
-
}, { logPrefix: "[agentic-query]", handleProviderIdEvents: false }).finally(() =>
|
|
103828
|
+
}, { logPrefix: "[agentic-query]", handleProviderIdEvents: false }).finally(() => inFlight2.delete(rowId));
|
|
103811
103829
|
}
|
|
103812
103830
|
}, (err) => {
|
|
103813
103831
|
console.warn("[agentic-query] Session subscription error:", err instanceof Error ? err.message : String(err));
|
|
@@ -104100,12 +104118,12 @@ var init_wait_for_enhancer_job = __esm(() => {
|
|
|
104100
104118
|
|
|
104101
104119
|
// src/commands/machine/daemon-start/enhancer/job-subscriber.ts
|
|
104102
104120
|
function startEnhancerJobSubscriber(sessionId, machineId, convexUrl, backend2, wsClient2, agentServices) {
|
|
104103
|
-
const
|
|
104121
|
+
const inFlight2 = new Set;
|
|
104104
104122
|
const unsub = wsClient2.onUpdate(api.daemon.enhancer.index.pendingForMachine, { sessionId, machineId }, (jobs) => {
|
|
104105
104123
|
for (const job of jobs ?? []) {
|
|
104106
|
-
if (
|
|
104124
|
+
if (inFlight2.has(job.jobId))
|
|
104107
104125
|
continue;
|
|
104108
|
-
|
|
104126
|
+
inFlight2.add(job.jobId);
|
|
104109
104127
|
(async () => {
|
|
104110
104128
|
let claimed = false;
|
|
104111
104129
|
let chatroomId = job.chatroomId;
|
|
@@ -104193,7 +104211,7 @@ function startEnhancerJobSubscriber(sessionId, machineId, convexUrl, backend2, w
|
|
|
104193
104211
|
});
|
|
104194
104212
|
}
|
|
104195
104213
|
} finally {
|
|
104196
|
-
|
|
104214
|
+
inFlight2.delete(job.jobId);
|
|
104197
104215
|
if (spawnResult && service3) {
|
|
104198
104216
|
try {
|
|
104199
104217
|
await service3.stop(spawnResult.pid);
|
|
@@ -114513,6 +114531,8 @@ async function nudgeStuckTasks(tasks, now, cooldown, runtime4, effectContext2, a
|
|
|
114513
114531
|
}
|
|
114514
114532
|
async function reviveNativeTasks(tasks, localHealth, now, cooldown, runtime4, effectContext2, agentMgr, sessionDeps, machineId) {
|
|
114515
114533
|
for (const row of listNativeTasksNeedingRevive(tasks, localHealth, now, cooldown)) {
|
|
114534
|
+
if (isRestartOrchestratorInFlight(row.chatroomId, row.agentConfig.role))
|
|
114535
|
+
continue;
|
|
114516
114536
|
await clearStuckStoppingSlotIfNeeded(agentMgr, row.chatroomId, row.agentConfig.role);
|
|
114517
114537
|
const full = await fetchTaskForAction(sessionDeps, machineId, row);
|
|
114518
114538
|
if (!full)
|
|
@@ -114521,6 +114541,7 @@ async function reviveNativeTasks(tasks, localHealth, now, cooldown, runtime4, ef
|
|
|
114521
114541
|
}
|
|
114522
114542
|
}
|
|
114523
114543
|
async function processTasksUpdate(tasks, runtime4, effectContext2, cooldown, agentMgr, sessionDeps, machineId, _pass) {
|
|
114544
|
+
tasks = filterSnapshotsExcludingRestartInFlight(tasks);
|
|
114524
114545
|
if (tasks.length === 0)
|
|
114525
114546
|
return;
|
|
114526
114547
|
const now = Date.now();
|
|
@@ -114557,7 +114578,7 @@ function runLocalStoreReconcilePass(params) {
|
|
|
114557
114578
|
const { stopped, monitorPassInFlight, agentMgr, runtime: runtime4, effectContext: effectContext2, sessionDeps, machineId } = params;
|
|
114558
114579
|
if (stopped || monitorPassInFlight)
|
|
114559
114580
|
return;
|
|
114560
|
-
const deliverable = listDeliverablePendingFromStore(agentMgr);
|
|
114581
|
+
const deliverable = filterSnapshotsExcludingRestartInFlight(listDeliverablePendingFromStore(agentMgr));
|
|
114561
114582
|
if (deliverable.length === 0)
|
|
114562
114583
|
return;
|
|
114563
114584
|
const first = deliverable[0];
|
|
@@ -114700,6 +114721,7 @@ var init_task_monitor = __esm(() => {
|
|
|
114700
114721
|
init_esm();
|
|
114701
114722
|
init_daemon_services();
|
|
114702
114723
|
init_native_ready_invariant();
|
|
114724
|
+
init_restart_orchestrator_in_flight();
|
|
114703
114725
|
init_native_task_delivery_coordinator();
|
|
114704
114726
|
init_native_task_injector_logic();
|
|
114705
114727
|
init_task_monitor_logic();
|
|
@@ -116359,4 +116381,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
116359
116381
|
});
|
|
116360
116382
|
program2.parse();
|
|
116361
116383
|
|
|
116362
|
-
//# debugId=
|
|
116384
|
+
//# debugId=F542CAE8E215492E64756E2164756E21
|