chatroom-cli 1.107.0 → 1.107.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 +217 -73
- package/dist/index.js.map +11 -10
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -80716,6 +80716,7 @@ ${getHandoffNotApplicableSectionComment("List tradeoffs")}
|
|
|
80716
80716
|
|
|
80717
80717
|
## System Design
|
|
80718
80718
|
${getHandoffNotApplicableSectionComment("Include a mermaid diagram when the change has non-trivial structure")}
|
|
80719
|
+
<!-- Mermaid formatting: wrap the diagram in a fenced code block that begins with \`\`\`mermaid and ends with \`\`\`. Never write a bare "mermaid" line — it will not render. -->
|
|
80719
80720
|
|
|
80720
80721
|
\`\`\`mermaid
|
|
80721
80722
|
flowchart TD
|
|
@@ -106082,6 +106083,7 @@ var init_model_catalog = __esm(() => {
|
|
|
106082
106083
|
init_model_provider();
|
|
106083
106084
|
init_model_variant();
|
|
106084
106085
|
CODEX_MODEL_IDS = [
|
|
106086
|
+
"gpt-6-astra",
|
|
106085
106087
|
"gpt-5.6-terra",
|
|
106086
106088
|
"gpt-5.6-luna",
|
|
106087
106089
|
"gpt-5.6-sol",
|
|
@@ -118155,6 +118157,30 @@ var init_task_inbox_delivery = __esm(() => {
|
|
|
118155
118157
|
init_enrich_snapshot_with_operational();
|
|
118156
118158
|
});
|
|
118157
118159
|
|
|
118160
|
+
// src/daemon/infrastructure/inbox/task-signal-contract.ts
|
|
118161
|
+
function asChatroomId2(chatroomId) {
|
|
118162
|
+
return chatroomId;
|
|
118163
|
+
}
|
|
118164
|
+
function buildSubscribeTaskStatusSignalsSinceArgs(input) {
|
|
118165
|
+
return {
|
|
118166
|
+
sessionId: input.sessionId,
|
|
118167
|
+
machineId: input.machineId,
|
|
118168
|
+
chatroomId: asChatroomId2(input.chatroomId),
|
|
118169
|
+
afterKey: input.afterKey,
|
|
118170
|
+
...input.limit === undefined ? {} : { limit: input.limit }
|
|
118171
|
+
};
|
|
118172
|
+
}
|
|
118173
|
+
function buildListTasksForMachineSignalRangeArgs(input) {
|
|
118174
|
+
return {
|
|
118175
|
+
sessionId: input.sessionId,
|
|
118176
|
+
machineId: input.machineId,
|
|
118177
|
+
chatroomId: asChatroomId2(input.chatroomId),
|
|
118178
|
+
afterSignalKey: input.afterSignalKey,
|
|
118179
|
+
throughSignalKey: input.throughSignalKey,
|
|
118180
|
+
...input.limit === undefined ? {} : { limit: input.limit }
|
|
118181
|
+
};
|
|
118182
|
+
}
|
|
118183
|
+
|
|
118158
118184
|
// src/daemon/infrastructure/inbox/task.ts
|
|
118159
118185
|
function taskSignalCursorAt(timestamp) {
|
|
118160
118186
|
return `${String(Math.max(0, Math.floor(timestamp))).padStart(16, "0")}:`;
|
|
@@ -118194,12 +118220,13 @@ function waitForTaskSignalPage(options, afterSignalKey) {
|
|
|
118194
118220
|
settle2(() => reject(error51));
|
|
118195
118221
|
return;
|
|
118196
118222
|
}
|
|
118197
|
-
unsubscribe = options.client.onUpdate(api.messageList.subscribeTaskStatusSignalsSince, {
|
|
118223
|
+
unsubscribe = options.client.onUpdate(api.messageList.subscribeTaskStatusSignalsSince, buildSubscribeTaskStatusSignalsSinceArgs({
|
|
118198
118224
|
sessionId: options.sessionId,
|
|
118199
118225
|
machineId: options.machineId,
|
|
118226
|
+
chatroomId: options.chatroomId,
|
|
118200
118227
|
afterKey: afterSignalKey,
|
|
118201
118228
|
limit: options.signalPageLimit ?? DEFAULT_SIGNAL_PAGE_LIMIT2
|
|
118202
|
-
}, (result) => {
|
|
118229
|
+
}), (result) => {
|
|
118203
118230
|
if (!result || typeof result !== "object")
|
|
118204
118231
|
return;
|
|
118205
118232
|
const page = result;
|
|
@@ -118230,13 +118257,14 @@ async function fetchSnapshotsForSignalPage(options, page) {
|
|
|
118230
118257
|
let afterSignalKey = page.afterSignalKey;
|
|
118231
118258
|
while (true) {
|
|
118232
118259
|
throwIfAborted2(options.signal);
|
|
118233
|
-
const result = await options.client.query(api.tasks.listTasksForMachineSignalRange, {
|
|
118260
|
+
const result = await options.client.query(api.tasks.listTasksForMachineSignalRange, buildListTasksForMachineSignalRangeArgs({
|
|
118234
118261
|
sessionId: options.sessionId,
|
|
118235
118262
|
machineId: options.machineId,
|
|
118263
|
+
chatroomId: options.chatroomId,
|
|
118236
118264
|
afterSignalKey,
|
|
118237
118265
|
throughSignalKey: page.highSignalKey,
|
|
118238
118266
|
limit: options.taskPageLimit ?? DEFAULT_TASK_PAGE_LIMIT
|
|
118239
|
-
});
|
|
118267
|
+
}));
|
|
118240
118268
|
snapshots.push(...result.snapshots);
|
|
118241
118269
|
if (!result.hasMore || !result.nextSignalKey)
|
|
118242
118270
|
break;
|
|
@@ -118283,7 +118311,7 @@ async function bootstrapMachineAssignedTaskSnapshots(deps) {
|
|
|
118283
118311
|
function isAbortError2(error51) {
|
|
118284
118312
|
return error51 instanceof Error && error51.name === "AbortError";
|
|
118285
118313
|
}
|
|
118286
|
-
function
|
|
118314
|
+
function roomScopeKey(machineId, chatroomId) {
|
|
118287
118315
|
return JSON.stringify([machineId, chatroomId]);
|
|
118288
118316
|
}
|
|
118289
118317
|
async function runInboxLoopWithRestart(options, onUpdate, isStopped) {
|
|
@@ -118337,10 +118365,6 @@ var NATIVE_DELIVERY_RECONCILE_MS = 1e4, INBOX_RESTART_INITIAL_MS = 1000, INBOX_R
|
|
|
118337
118365
|
};
|
|
118338
118366
|
console.log(`[${formatTimestamp()}] \uD83D\uDCEC Starting task-inbox (chatroom-scoped operational signals)`);
|
|
118339
118367
|
const inboxStore = createInboxStateStore(resolveInboxDbPath(session2.machineId));
|
|
118340
|
-
const persisted = inboxStore.get({
|
|
118341
|
-
inboxType: "task",
|
|
118342
|
-
scopeKey: session2.machineId
|
|
118343
|
-
});
|
|
118344
118368
|
const serviceStartedAt = Date.now();
|
|
118345
118369
|
const abort = new AbortController;
|
|
118346
118370
|
let stopped = false;
|
|
@@ -118361,14 +118385,6 @@ var NATIVE_DELIVERY_RECONCILE_MS = 1e4, INBOX_RESTART_INITIAL_MS = 1000, INBOX_R
|
|
|
118361
118385
|
const cooldown = new RecoveryCooldown;
|
|
118362
118386
|
let inboxUpdatesInFlight = 0;
|
|
118363
118387
|
let reconcileInFlight = false;
|
|
118364
|
-
const inboxOptions = {
|
|
118365
|
-
client: wsClient2,
|
|
118366
|
-
sessionId: session2.sessionId,
|
|
118367
|
-
machineId: session2.machineId,
|
|
118368
|
-
serviceStartedAt,
|
|
118369
|
-
initialAfterSignalKey: persisted?.state.afterSignalKey,
|
|
118370
|
-
signal: abort.signal
|
|
118371
|
-
};
|
|
118372
118388
|
const bootstrapSucceeded = yield* exports_Effect.tryPromise(async () => {
|
|
118373
118389
|
const rows = await fetchMachineAgentOperationalStatus(sessionDeps, session2.machineId);
|
|
118374
118390
|
agentOperationalReadModel.replace(rows);
|
|
@@ -118390,7 +118406,7 @@ var NATIVE_DELIVERY_RECONCILE_MS = 1e4, INBOX_RESTART_INITIAL_MS = 1000, INBOX_R
|
|
|
118390
118406
|
}
|
|
118391
118407
|
inboxStore.save({
|
|
118392
118408
|
inboxType: "operational",
|
|
118393
|
-
scopeKey:
|
|
118409
|
+
scopeKey: roomScopeKey(session2.machineId, chatroomId)
|
|
118394
118410
|
}, { afterSignalKey: update6.throughSignalKey });
|
|
118395
118411
|
try {
|
|
118396
118412
|
await ackMachineOperationalSignals(sessionDeps, session2.machineId, chatroomId, update6.throughSignalKey);
|
|
@@ -118401,7 +118417,7 @@ var NATIVE_DELIVERY_RECONCILE_MS = 1e4, INBOX_RESTART_INITIAL_MS = 1000, INBOX_R
|
|
|
118401
118417
|
inboxUpdatesInFlight -= 1;
|
|
118402
118418
|
}
|
|
118403
118419
|
};
|
|
118404
|
-
const
|
|
118420
|
+
const ensureRoomInboxes = (chatroomId) => {
|
|
118405
118421
|
const existing = roomWatchers.get(chatroomId);
|
|
118406
118422
|
if (existing)
|
|
118407
118423
|
return existing.startPromise;
|
|
@@ -118422,25 +118438,25 @@ var NATIVE_DELIVERY_RECONCILE_MS = 1e4, INBOX_RESTART_INITIAL_MS = 1000, INBOX_R
|
|
|
118422
118438
|
console.warn(`[OperationalInbox room=${chatroomId}] operational hydration failed:`, error51);
|
|
118423
118439
|
}
|
|
118424
118440
|
}
|
|
118425
|
-
const
|
|
118441
|
+
const operationalRoomKey = {
|
|
118426
118442
|
inboxType: "operational",
|
|
118427
|
-
scopeKey:
|
|
118443
|
+
scopeKey: roomScopeKey(session2.machineId, chatroomId)
|
|
118428
118444
|
};
|
|
118429
|
-
const
|
|
118430
|
-
let
|
|
118431
|
-
if (
|
|
118432
|
-
|
|
118433
|
-
ackMachineOperationalSignals(sessionDeps, session2.machineId, chatroomId,
|
|
118445
|
+
const persistedOperationalRoom = inboxStore.get(operationalRoomKey);
|
|
118446
|
+
let operationalCursor;
|
|
118447
|
+
if (persistedOperationalRoom) {
|
|
118448
|
+
operationalCursor = persistedOperationalRoom.state.afterSignalKey;
|
|
118449
|
+
ackMachineOperationalSignals(sessionDeps, session2.machineId, chatroomId, operationalCursor).catch((error51) => console.warn(`[OperationalInbox room=${chatroomId}] startup signal cleanup failed:`, error51));
|
|
118434
118450
|
} else if (bootstrapSucceeded) {
|
|
118435
|
-
|
|
118451
|
+
operationalCursor = operationalSignalCursorAt(serviceStartedAt);
|
|
118436
118452
|
try {
|
|
118437
|
-
inboxStore.save(
|
|
118438
|
-
ackMachineOperationalSignals(sessionDeps, session2.machineId, chatroomId,
|
|
118453
|
+
inboxStore.save(operationalRoomKey, { afterSignalKey: operationalCursor });
|
|
118454
|
+
ackMachineOperationalSignals(sessionDeps, session2.machineId, chatroomId, operationalCursor).catch((error51) => console.warn(`[OperationalInbox room=${chatroomId}] startup signal cleanup failed:`, error51));
|
|
118439
118455
|
} catch (error51) {
|
|
118440
118456
|
console.warn(`[OperationalInbox room=${chatroomId}] failed to persist bootstrap baseline:`, error51);
|
|
118441
118457
|
}
|
|
118442
118458
|
} else {
|
|
118443
|
-
|
|
118459
|
+
operationalCursor = operationalSignalCursorAt(serviceStartedAt);
|
|
118444
118460
|
}
|
|
118445
118461
|
runOperationalInboxLoopWithRestart({
|
|
118446
118462
|
client: wsClient2,
|
|
@@ -118448,13 +118464,57 @@ var NATIVE_DELIVERY_RECONCILE_MS = 1e4, INBOX_RESTART_INITIAL_MS = 1000, INBOX_R
|
|
|
118448
118464
|
machineId: session2.machineId,
|
|
118449
118465
|
chatroomId,
|
|
118450
118466
|
serviceStartedAt,
|
|
118451
|
-
initialAfterSignalKey:
|
|
118467
|
+
initialAfterSignalKey: operationalCursor,
|
|
118452
118468
|
signal: controller.signal
|
|
118453
118469
|
}, operationalHandler, () => stopped);
|
|
118470
|
+
const taskRoomKey = {
|
|
118471
|
+
inboxType: "task",
|
|
118472
|
+
scopeKey: roomScopeKey(session2.machineId, chatroomId)
|
|
118473
|
+
};
|
|
118474
|
+
const persistedTaskRoom = inboxStore.get(taskRoomKey);
|
|
118475
|
+
let taskCursor;
|
|
118476
|
+
if (persistedTaskRoom) {
|
|
118477
|
+
taskCursor = persistedTaskRoom.state.afterSignalKey;
|
|
118478
|
+
} else if (bootstrapSucceeded) {
|
|
118479
|
+
taskCursor = taskSignalCursorAt(serviceStartedAt);
|
|
118480
|
+
try {
|
|
118481
|
+
inboxStore.save(taskRoomKey, { afterSignalKey: taskCursor });
|
|
118482
|
+
} catch (error51) {
|
|
118483
|
+
console.warn(`[TaskInbox room=${chatroomId}] failed to persist bootstrap baseline:`, error51);
|
|
118484
|
+
}
|
|
118485
|
+
} else {
|
|
118486
|
+
taskCursor = taskSignalCursorAt(serviceStartedAt);
|
|
118487
|
+
}
|
|
118488
|
+
const taskHandlerForRoom = async (update6) => {
|
|
118489
|
+
inboxUpdatesInFlight += 1;
|
|
118490
|
+
try {
|
|
118491
|
+
await handleTaskInboxUpdate(update6, {
|
|
118492
|
+
runtime: runtime4,
|
|
118493
|
+
effectContext: effectContext2,
|
|
118494
|
+
cooldown,
|
|
118495
|
+
agentMgr,
|
|
118496
|
+
sessionDeps,
|
|
118497
|
+
machineId: session2.machineId,
|
|
118498
|
+
taskSnapshotState
|
|
118499
|
+
});
|
|
118500
|
+
inboxStore.save(taskRoomKey, { afterSignalKey: update6.throughSignalKey });
|
|
118501
|
+
} finally {
|
|
118502
|
+
inboxUpdatesInFlight -= 1;
|
|
118503
|
+
}
|
|
118504
|
+
};
|
|
118505
|
+
runInboxLoopWithRestart({
|
|
118506
|
+
client: wsClient2,
|
|
118507
|
+
sessionId: session2.sessionId,
|
|
118508
|
+
machineId: session2.machineId,
|
|
118509
|
+
chatroomId,
|
|
118510
|
+
serviceStartedAt,
|
|
118511
|
+
initialAfterSignalKey: taskCursor,
|
|
118512
|
+
signal: controller.signal
|
|
118513
|
+
}, taskHandlerForRoom, () => stopped);
|
|
118454
118514
|
})();
|
|
118455
118515
|
return entry.startPromise;
|
|
118456
118516
|
};
|
|
118457
|
-
yield* exports_Effect.tryPromise(() => Promise.all([...knownRoomIds].map((chatroomId) =>
|
|
118517
|
+
yield* exports_Effect.tryPromise(() => Promise.all([...knownRoomIds].map((chatroomId) => ensureRoomInboxes(chatroomId)))).pipe(exports_Effect.catchAll((error51) => {
|
|
118458
118518
|
console.warn("[OperationalInbox] initial watcher start failed:", error51);
|
|
118459
118519
|
return exports_Effect.void;
|
|
118460
118520
|
}));
|
|
@@ -118467,49 +118527,33 @@ var NATIVE_DELIVERY_RECONCILE_MS = 1e4, INBOX_RESTART_INITIAL_MS = 1000, INBOX_R
|
|
|
118467
118527
|
machineId: session2.machineId,
|
|
118468
118528
|
taskSnapshotState,
|
|
118469
118529
|
onDiscoveredChatrooms: async (chatroomIds) => {
|
|
118470
|
-
await Promise.all(chatroomIds.map((chatroomId) =>
|
|
118530
|
+
await Promise.all(chatroomIds.map((chatroomId) => ensureRoomInboxes(chatroomId)));
|
|
118471
118531
|
}
|
|
118472
118532
|
})).pipe(exports_Effect.catchAll((error51) => {
|
|
118473
118533
|
console.warn("[TaskInbox] bootstrap failed:", error51);
|
|
118474
118534
|
return exports_Effect.void;
|
|
118475
118535
|
}));
|
|
118476
|
-
const inboxHandler = async (update6) => {
|
|
118477
|
-
inboxUpdatesInFlight += 1;
|
|
118478
|
-
try {
|
|
118479
|
-
const chatroomIds = [
|
|
118480
|
-
...new Set([
|
|
118481
|
-
...update6.snapshots.map((snapshot) => snapshot.chatroomId),
|
|
118482
|
-
...update6.signals.map((signal) => signal.chatroomId)
|
|
118483
|
-
])
|
|
118484
|
-
];
|
|
118485
|
-
if (chatroomIds.length > 0) {
|
|
118486
|
-
await Promise.all(chatroomIds.map((chatroomId) => ensureOperationalInbox(chatroomId)));
|
|
118487
|
-
}
|
|
118488
|
-
await handleTaskInboxUpdate(update6, {
|
|
118489
|
-
runtime: runtime4,
|
|
118490
|
-
effectContext: effectContext2,
|
|
118491
|
-
cooldown,
|
|
118492
|
-
agentMgr,
|
|
118493
|
-
sessionDeps,
|
|
118494
|
-
machineId: session2.machineId,
|
|
118495
|
-
taskSnapshotState
|
|
118496
|
-
});
|
|
118497
|
-
inboxStore.save({ inboxType: "task", scopeKey: session2.machineId }, { afterSignalKey: update6.throughSignalKey });
|
|
118498
|
-
} finally {
|
|
118499
|
-
inboxUpdatesInFlight -= 1;
|
|
118500
|
-
}
|
|
118501
|
-
};
|
|
118502
118536
|
const reconcileTimer = setInterval(() => {
|
|
118503
118537
|
if (stopped || inboxUpdatesInFlight > 0 || reconcileInFlight)
|
|
118504
118538
|
return;
|
|
118505
118539
|
reconcileInFlight = true;
|
|
118540
|
+
(async () => {
|
|
118541
|
+
try {
|
|
118542
|
+
const current = await fetchMachineAgentOperationalStatus(sessionDeps, session2.machineId);
|
|
118543
|
+
agentOperationalReadModel.replace(current);
|
|
118544
|
+
for (const row of current)
|
|
118545
|
+
knownRoomIds.add(row.chatroomId);
|
|
118546
|
+
await Promise.all([...new Set(current.map((row) => row.chatroomId))].map((chatroomId) => ensureRoomInboxes(chatroomId)));
|
|
118547
|
+
} catch (error51) {
|
|
118548
|
+
console.warn("[TaskInbox] room membership refresh failed:", error51);
|
|
118549
|
+
}
|
|
118550
|
+
})();
|
|
118506
118551
|
processTasksUpdate(runtime4, effectContext2, cooldown, agentMgr, sessionDeps, session2.machineId, "periodic-reconcile", { snapshots: enrichSnapshotsWithOperational(taskSnapshotState.listAll()) }).catch((error51) => {
|
|
118507
118552
|
console.warn("[TaskInbox] local delivery reconciliation failed:", error51);
|
|
118508
118553
|
}).finally(() => {
|
|
118509
118554
|
reconcileInFlight = false;
|
|
118510
118555
|
});
|
|
118511
118556
|
}, NATIVE_DELIVERY_RECONCILE_MS);
|
|
118512
|
-
runInboxLoopWithRestart(inboxOptions, inboxHandler, () => stopped);
|
|
118513
118557
|
return {
|
|
118514
118558
|
stop() {
|
|
118515
118559
|
stopped = true;
|
|
@@ -119684,7 +119728,10 @@ var init_command_run = __esm(() => {
|
|
|
119684
119728
|
// src/daemon/infrastructure/convex/subscribers/enhancer-job.ts
|
|
119685
119729
|
function startEnhancerJobSubscriber2(deps, onEvent) {
|
|
119686
119730
|
const seen = new Set;
|
|
119687
|
-
const
|
|
119731
|
+
const watchers = new Map;
|
|
119732
|
+
let stopped = false;
|
|
119733
|
+
let refreshInFlight = false;
|
|
119734
|
+
const onPendingJobs = (jobs) => {
|
|
119688
119735
|
if (!jobs?.length)
|
|
119689
119736
|
return;
|
|
119690
119737
|
for (const job of jobs) {
|
|
@@ -119695,13 +119742,57 @@ function startEnhancerJobSubscriber2(deps, onEvent) {
|
|
|
119695
119742
|
seen.add(job.jobId);
|
|
119696
119743
|
onEvent({ type: "enhancer.job-assigned", jobId: job.jobId });
|
|
119697
119744
|
}
|
|
119698
|
-
}
|
|
119745
|
+
};
|
|
119746
|
+
const onError3 = (err) => {
|
|
119699
119747
|
console.warn(`[daemon] enhancer-job subscriber error: ${err instanceof Error ? err.message : String(err)}`);
|
|
119700
|
-
}
|
|
119748
|
+
};
|
|
119749
|
+
const watchChatroom = (chatroomId) => {
|
|
119750
|
+
if (watchers.has(chatroomId) || stopped)
|
|
119751
|
+
return;
|
|
119752
|
+
const unsub = deps.wsClient.onUpdate(api.daemon.enhancer.index.pendingForChatroom, {
|
|
119753
|
+
sessionId: deps.sessionId,
|
|
119754
|
+
machineId: deps.machineId,
|
|
119755
|
+
chatroomId
|
|
119756
|
+
}, onPendingJobs, onError3);
|
|
119757
|
+
watchers.set(chatroomId, unsub);
|
|
119758
|
+
};
|
|
119759
|
+
const refreshChatrooms = async () => {
|
|
119760
|
+
if (refreshInFlight)
|
|
119761
|
+
return;
|
|
119762
|
+
refreshInFlight = true;
|
|
119763
|
+
try {
|
|
119764
|
+
const workspaces = await deps.wsClient.query(api.workspaces.listWorkspacesForMachine, {
|
|
119765
|
+
sessionId: deps.sessionId,
|
|
119766
|
+
machineId: deps.machineId
|
|
119767
|
+
});
|
|
119768
|
+
if (stopped)
|
|
119769
|
+
return;
|
|
119770
|
+
const roomIds = [
|
|
119771
|
+
...new Set((workspaces ?? []).map((ws) => ws.chatroomId))
|
|
119772
|
+
];
|
|
119773
|
+
for (const [roomId, unsub] of watchers) {
|
|
119774
|
+
if (!roomIds.includes(roomId)) {
|
|
119775
|
+
unsub();
|
|
119776
|
+
watchers.delete(roomId);
|
|
119777
|
+
}
|
|
119778
|
+
}
|
|
119779
|
+
for (const roomId of roomIds)
|
|
119780
|
+
watchChatroom(roomId);
|
|
119781
|
+
} catch (error51) {
|
|
119782
|
+
console.warn(`[daemon] enhancer-job room refresh failed: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
119783
|
+
} finally {
|
|
119784
|
+
refreshInFlight = false;
|
|
119785
|
+
}
|
|
119786
|
+
};
|
|
119787
|
+
refreshChatrooms();
|
|
119701
119788
|
return {
|
|
119702
119789
|
async stop() {
|
|
119703
|
-
|
|
119704
|
-
|
|
119790
|
+
stopped = true;
|
|
119791
|
+
for (const unsub of watchers.values())
|
|
119792
|
+
unsub();
|
|
119793
|
+
watchers.clear();
|
|
119794
|
+
},
|
|
119795
|
+
refreshChatrooms
|
|
119705
119796
|
};
|
|
119706
119797
|
}
|
|
119707
119798
|
var init_enhancer_job = __esm(() => {
|
|
@@ -119859,7 +119950,11 @@ function requestId2(req) {
|
|
|
119859
119950
|
}
|
|
119860
119951
|
function startGitRequestSubscriber(deps, onEvent) {
|
|
119861
119952
|
const seen = new Set;
|
|
119862
|
-
const
|
|
119953
|
+
const watchers = new Map;
|
|
119954
|
+
let stopped = false;
|
|
119955
|
+
let refreshInFlight = false;
|
|
119956
|
+
let queued = false;
|
|
119957
|
+
const onPendingRequests = (requests) => {
|
|
119863
119958
|
if (!requests?.length)
|
|
119864
119959
|
return;
|
|
119865
119960
|
for (const req of requests) {
|
|
@@ -119871,13 +119966,58 @@ function startGitRequestSubscriber(deps, onEvent) {
|
|
|
119871
119966
|
seen.add(id3);
|
|
119872
119967
|
onEvent({ type: "git.request", requestId: id3 });
|
|
119873
119968
|
}
|
|
119874
|
-
}
|
|
119969
|
+
};
|
|
119970
|
+
const onError3 = (err) => {
|
|
119875
119971
|
console.warn(`[daemon] git-request subscriber error: ${err instanceof Error ? err.message : String(err)}`);
|
|
119876
|
-
}
|
|
119972
|
+
};
|
|
119973
|
+
const watchWorkspace = (workingDir) => {
|
|
119974
|
+
if (watchers.has(workingDir) || stopped)
|
|
119975
|
+
return;
|
|
119976
|
+
const unsub = deps.wsClient.onUpdate(api.workspaces.getPendingRequestsForWorkspace, { sessionId: deps.sessionId, machineId: deps.machineId, workingDir }, onPendingRequests, onError3);
|
|
119977
|
+
watchers.set(workingDir, unsub);
|
|
119978
|
+
};
|
|
119979
|
+
const refreshWorkspaces = async () => {
|
|
119980
|
+
if (refreshInFlight) {
|
|
119981
|
+
queued = true;
|
|
119982
|
+
return;
|
|
119983
|
+
}
|
|
119984
|
+
refreshInFlight = true;
|
|
119985
|
+
try {
|
|
119986
|
+
do {
|
|
119987
|
+
queued = false;
|
|
119988
|
+
const workspaces = await deps.wsClient.query(api.workspaces.listWorkspacesForMachine, {
|
|
119989
|
+
sessionId: deps.sessionId,
|
|
119990
|
+
machineId: deps.machineId
|
|
119991
|
+
});
|
|
119992
|
+
if (stopped)
|
|
119993
|
+
return;
|
|
119994
|
+
const workingDirs = [
|
|
119995
|
+
...new Set((workspaces ?? []).map((ws) => ws.workingDir))
|
|
119996
|
+
];
|
|
119997
|
+
for (const [workingDir, unsub] of watchers) {
|
|
119998
|
+
if (!workingDirs.includes(workingDir)) {
|
|
119999
|
+
unsub();
|
|
120000
|
+
watchers.delete(workingDir);
|
|
120001
|
+
}
|
|
120002
|
+
}
|
|
120003
|
+
for (const workingDir of workingDirs)
|
|
120004
|
+
watchWorkspace(workingDir);
|
|
120005
|
+
} while (queued && !stopped);
|
|
120006
|
+
} catch (error51) {
|
|
120007
|
+
console.warn(`[daemon] git-request workspace refresh failed: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
120008
|
+
} finally {
|
|
120009
|
+
refreshInFlight = false;
|
|
120010
|
+
}
|
|
120011
|
+
};
|
|
120012
|
+
refreshWorkspaces();
|
|
119877
120013
|
return {
|
|
119878
120014
|
async stop() {
|
|
119879
|
-
|
|
119880
|
-
|
|
120015
|
+
stopped = true;
|
|
120016
|
+
for (const unsub of watchers.values())
|
|
120017
|
+
unsub();
|
|
120018
|
+
watchers.clear();
|
|
120019
|
+
},
|
|
120020
|
+
refreshWorkspaces
|
|
119881
120021
|
};
|
|
119882
120022
|
}
|
|
119883
120023
|
var init_git_request = __esm(() => {
|
|
@@ -119928,7 +120068,13 @@ function startAllSubscribers(deps) {
|
|
|
119928
120068
|
const onEvent = (event) => {
|
|
119929
120069
|
routeInboundEvent(deps.router, event);
|
|
119930
120070
|
};
|
|
120071
|
+
const enhancerJob = startEnhancerJobSubscriber2(deps, onEvent);
|
|
120072
|
+
const gitRequest = startGitRequestSubscriber(deps, onEvent);
|
|
119931
120073
|
const machineCommands = startMachineCommandInboxSubscriber(deps, async (claimed) => {
|
|
120074
|
+
if (claimed.type === "daemon.workspaceListChanged") {
|
|
120075
|
+
enhancerJob.refreshChatrooms();
|
|
120076
|
+
gitRequest.refreshWorkspaces();
|
|
120077
|
+
}
|
|
119932
120078
|
await dispatchCommandInboundEvent({
|
|
119933
120079
|
type: "command.received",
|
|
119934
120080
|
commandId: claimed.commandId,
|
|
@@ -119936,14 +120082,12 @@ function startAllSubscribers(deps) {
|
|
|
119936
120082
|
});
|
|
119937
120083
|
});
|
|
119938
120084
|
const commandRun = startCommandRunSubscriber(deps, onEvent);
|
|
119939
|
-
const gitRequest = startGitRequestSubscriber(deps, onEvent);
|
|
119940
120085
|
const fileTree = startFileTreeRequestSubscriber(deps, onEvent);
|
|
119941
120086
|
const fileTreeRelease = startFileTreeReleaseRequestSubscriber(deps, onEvent);
|
|
119942
120087
|
const fileContent = startFileContentRequestSubscriber(deps, onEvent);
|
|
119943
120088
|
const fileWrite = startFileWriteRequestSubscriber(deps, onEvent);
|
|
119944
120089
|
const agenticQuerySession = startAgenticQuerySessionSubscriber(deps, onEvent);
|
|
119945
120090
|
const agenticQueryPrompt = startAgenticQueryPromptSubscriber(deps, onEvent);
|
|
119946
|
-
const enhancerJob = startEnhancerJobSubscriber2(deps, onEvent);
|
|
119947
120091
|
return {
|
|
119948
120092
|
async stopAll() {
|
|
119949
120093
|
await Promise.all([
|
|
@@ -135734,4 +135878,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
135734
135878
|
});
|
|
135735
135879
|
program2.parse();
|
|
135736
135880
|
|
|
135737
|
-
//# debugId=
|
|
135881
|
+
//# debugId=3C68FDC314358C7A64756E2164756E21
|