chatroom-cli 1.111.0 → 1.112.0

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 CHANGED
@@ -31875,7 +31875,7 @@ function decideNextDelivery(tasks, context5) {
31875
31875
  return { kind: "wait", taskId: task.taskId, reason: "slot_stopping" };
31876
31876
  }
31877
31877
  const coldSession = context5.snapshotRequestsNativeColdSession(task);
31878
- const startAllowed = blockReason.startsWith("slot_missing") || blockReason.startsWith("slot_not_running");
31878
+ const startAllowed = blockReason.startsWith("slot_missing") || blockReason.startsWith("slot_not_running") || blockReason.startsWith("spawned_pid_missing");
31879
31879
  if (startAllowed && !coldSession && task.status === "pending" && isSlotIdle(context5.slot?.state ?? "idle") && task.agentConfig.workingDir) {
31880
31880
  return { kind: "start-agent", taskId: task.taskId };
31881
31881
  }
@@ -118005,56 +118005,112 @@ async function refreshTaskInboxRoomMembership() {
118005
118005
  }
118006
118006
  var refreshRoomMembership = null;
118007
118007
 
118008
- // src/daemon/infrastructure/agent-operational/operational-signal-contract.ts
118009
- function asChatroomId2(chatroomId) {
118010
- return chatroomId;
118008
+ // src/daemon/infrastructure/agent-operational/operational-signal-feeds.ts
118009
+ function chatroomId(value) {
118010
+ return value;
118011
+ }
118012
+ function signalPage(result) {
118013
+ if (!result || typeof result !== "object")
118014
+ return null;
118015
+ const page = result;
118016
+ if (!page.items?.length || !page.highKey)
118017
+ return null;
118018
+ return {
118019
+ items: page.items,
118020
+ afterSignalKey: "",
118021
+ highSignalKey: page.highKey
118022
+ };
118011
118023
  }
118012
- function buildSubscribeMachineOperationalSignalsSinceArgs(input) {
118024
+ function createFeed(input) {
118025
+ return input;
118026
+ }
118027
+ function subscribeArgs(input) {
118013
118028
  return {
118014
118029
  sessionId: input.sessionId,
118015
118030
  machineId: input.machineId,
118016
- chatroomId: asChatroomId2(input.chatroomId),
118031
+ chatroomId: chatroomId(input.chatroomId),
118017
118032
  afterKey: input.afterKey,
118018
- ...input.limit === undefined ? {} : { limit: input.limit }
118033
+ limit: input.limit
118019
118034
  };
118020
118035
  }
118021
- function buildListOperationalStatusForMachineSignalRangeArgs(input) {
118036
+ function rangeArgs(input) {
118022
118037
  return {
118023
118038
  sessionId: input.sessionId,
118024
118039
  machineId: input.machineId,
118025
- chatroomId: asChatroomId2(input.chatroomId),
118040
+ chatroomId: chatroomId(input.chatroomId),
118026
118041
  afterSignalKey: input.afterSignalKey,
118027
118042
  throughSignalKey: input.throughSignalKey,
118028
- ...input.limit === undefined ? {} : { limit: input.limit }
118043
+ limit: input.limit
118029
118044
  };
118030
118045
  }
118031
- function buildAckMachineOperationalSignalsArgs(input) {
118046
+ function ackArgs(input) {
118032
118047
  return {
118033
118048
  sessionId: input.sessionId,
118034
118049
  machineId: input.machineId,
118035
- chatroomId: asChatroomId2(input.chatroomId),
118050
+ chatroomId: chatroomId(input.chatroomId),
118036
118051
  throughSignalKey: input.throughSignalKey
118037
118052
  };
118038
118053
  }
118054
+ var createMachineFeed = (config4) => createFeed({
118055
+ kind: config4.kind,
118056
+ subscribe: (client4, input, onResult, onError3) => client4.onUpdate(config4.subscribe, subscribeArgs(input), (result) => {
118057
+ const page = signalPage(result);
118058
+ onResult(page ? { ...page, afterSignalKey: input.afterKey } : result);
118059
+ }, onError3),
118060
+ hydrate: async (client4, input) => await client4.query(config4.hydrate, rangeArgs(input)),
118061
+ acknowledge: async (sessionDeps, input) => await sessionDeps.backend.mutation(config4.acknowledge, ackArgs({
118062
+ ...input,
118063
+ sessionId: sessionDeps.sessionId
118064
+ }))
118065
+ }), operationalSignalFeeds;
118066
+ var init_operational_signal_feeds = __esm(() => {
118067
+ init_api3();
118068
+ operationalSignalFeeds = {
118069
+ "agent-operational": createMachineFeed({
118070
+ kind: "agent-operational",
118071
+ subscribe: api.machines.subscribeMachineAgentOperationalSignalsSince,
118072
+ hydrate: api.machines.listMachineAgentOperationalStatusForSignalRange,
118073
+ acknowledge: api.machines.ackMachineAgentOperationalSignals
118074
+ }),
118075
+ connectivity: createMachineFeed({
118076
+ kind: "connectivity",
118077
+ subscribe: api.machines.subscribeMachineConnectivitySignalsSince,
118078
+ hydrate: api.machines.listMachineConnectivityStatusForSignalRange,
118079
+ acknowledge: api.machines.ackMachineConnectivitySignals
118080
+ }),
118081
+ "agent-stop": createMachineFeed({
118082
+ kind: "agent-stop",
118083
+ subscribe: api.machines.subscribeMachineAgentStopSignalsSince,
118084
+ hydrate: api.machines.listMachineAgentStopStatusForSignalRange,
118085
+ acknowledge: api.machines.ackMachineAgentStopSignals
118086
+ }),
118087
+ "agent-removal": createMachineFeed({
118088
+ kind: "agent-removal",
118089
+ subscribe: api.machines.subscribeMachineAgentRemovalSignalsSince,
118090
+ hydrate: api.machines.listMachineAgentRemovalStatusForSignalRange,
118091
+ acknowledge: api.machines.ackMachineAgentRemovalSignals
118092
+ })
118093
+ };
118094
+ });
118039
118095
 
118040
118096
  // src/daemon/infrastructure/agent-operational/ack-machine-operational-signals.ts
118041
- async function ackMachineOperationalSignals(sessionDeps, machineId, chatroomId, throughSignalKey) {
118097
+ async function ackMachineSignal(sessionDeps, machineId, chatroomId2, throughSignalKey, kind) {
118098
+ const feed = operationalSignalFeeds[kind];
118042
118099
  while (true) {
118043
- const result = await sessionDeps.backend.mutation(api.machines.ackMachineOperationalSignals, buildAckMachineOperationalSignalsArgs({
118044
- sessionId: sessionDeps.sessionId,
118100
+ const result = await feed.acknowledge(sessionDeps, {
118045
118101
  machineId,
118046
- chatroomId,
118102
+ chatroomId: chatroomId2,
118047
118103
  throughSignalKey
118048
- }));
118104
+ });
118049
118105
  if (!result.hasMore)
118050
118106
  return;
118051
118107
  if (result.deletedCount === 0) {
118052
- throw new Error("Operational signal ack reported more work without progress");
118108
+ throw new Error(`${kind} signal ack reported more work without progress`);
118053
118109
  }
118054
118110
  }
118055
118111
  }
118056
118112
  var init_ack_machine_operational_signals = __esm(() => {
118057
- init_api3();
118113
+ init_operational_signal_feeds();
118058
118114
  });
118059
118115
 
118060
118116
  // src/daemon/infrastructure/agent-operational/agent-operational-read-model.ts
@@ -118097,11 +118153,11 @@ class AgentOperationalReadModel {
118097
118153
  }
118098
118154
  return changed;
118099
118155
  }
118100
- get(chatroomId, role) {
118101
- return this.rows.get(roleKey3(chatroomId, role));
118156
+ get(chatroomId2, role) {
118157
+ return this.rows.get(roleKey3(chatroomId2, role));
118102
118158
  }
118103
118159
  }
118104
- var roleKey3 = (chatroomId, role) => `${chatroomId}:${role.toLowerCase()}`;
118160
+ var roleKey3 = (chatroomId2, role) => `${chatroomId2}:${role.toLowerCase()}`;
118105
118161
 
118106
118162
  // src/daemon/infrastructure/agent-operational/fetch-machine-agent-operational-status.ts
118107
118163
  async function fetchMachineAgentOperationalStatus(sessionDeps, machineId) {
@@ -118128,6 +118184,9 @@ function throwIfAborted2(signal) {
118128
118184
  if (signal?.aborted)
118129
118185
  throw abortError2();
118130
118186
  }
118187
+ function feedFor(options) {
118188
+ return options.feed ?? operationalSignalFeeds["agent-operational"];
118189
+ }
118131
118190
  function waitForOperationalSignalPage(options, afterSignalKey) {
118132
118191
  return new Promise((resolve8, reject) => {
118133
118192
  let unsubscribe;
@@ -118154,25 +118213,17 @@ function waitForOperationalSignalPage(options, afterSignalKey) {
118154
118213
  settle2(() => reject(error51));
118155
118214
  return;
118156
118215
  }
118157
- unsubscribe = options.client.onUpdate(api.machines.subscribeMachineOperationalSignalsSince, buildSubscribeMachineOperationalSignalsSinceArgs({
118216
+ unsubscribe = feedFor(options).subscribe(options.client, {
118158
118217
  sessionId: options.sessionId,
118159
118218
  machineId: options.machineId,
118160
118219
  chatroomId: options.chatroomId,
118161
118220
  afterKey: afterSignalKey,
118162
118221
  limit: options.signalPageLimit ?? DEFAULT_SIGNAL_PAGE_LIMIT2
118163
- }), (result) => {
118164
- if (!result || typeof result !== "object")
118165
- return;
118222
+ }, (result) => {
118166
118223
  const page = result;
118167
- const items = page.items;
118168
- const highKey = page.highKey;
118169
- if (!items?.length || !highKey)
118224
+ if (!page)
118170
118225
  return;
118171
- settle2(() => resolve8({
118172
- items,
118173
- afterSignalKey,
118174
- highSignalKey: highKey
118175
- }));
118226
+ settle2(() => resolve8(page));
118176
118227
  }, (error51) => {
118177
118228
  settle2(() => reject(error51));
118178
118229
  });
@@ -118192,14 +118243,14 @@ async function fetchRowsForSignalPage(options, page) {
118192
118243
  let afterSignalKey = page.afterSignalKey;
118193
118244
  while (true) {
118194
118245
  throwIfAborted2(options.signal);
118195
- const result = await options.client.query(api.machines.listOperationalStatusForMachineSignalRange, buildListOperationalStatusForMachineSignalRangeArgs({
118246
+ const result = await feedFor(options).hydrate(options.client, {
118196
118247
  sessionId: options.sessionId,
118197
118248
  machineId: options.machineId,
118198
118249
  chatroomId: options.chatroomId,
118199
118250
  afterSignalKey,
118200
118251
  throughSignalKey: page.highSignalKey,
118201
118252
  limit: options.operationalPageLimit ?? DEFAULT_OPERATIONAL_PAGE_LIMIT
118202
- }));
118253
+ });
118203
118254
  rows.push(...result.rows);
118204
118255
  removed.push(...result.removed);
118205
118256
  if (!result.hasMore || !result.nextSignalKey)
@@ -118223,15 +118274,15 @@ async function runOperationalInbox(options, onUpdate) {
118223
118274
  }
118224
118275
  var DEFAULT_SIGNAL_PAGE_LIMIT2 = 100, DEFAULT_OPERATIONAL_PAGE_LIMIT = 500;
118225
118276
  var init_operational_inbox = __esm(() => {
118226
- init_api3();
118277
+ init_operational_signal_feeds();
118227
118278
  });
118228
118279
 
118229
118280
  // src/daemon/entry/task-inbox-runtime.ts
118230
118281
  function isAbortError2(error51) {
118231
118282
  return error51 instanceof Error && error51.name === "AbortError";
118232
118283
  }
118233
- function roomScopeKey(machineId, chatroomId) {
118234
- return JSON.stringify([machineId, chatroomId]);
118284
+ function roomScopeKey(machineId, chatroomId2) {
118285
+ return JSON.stringify([machineId, chatroomId2]);
118235
118286
  }
118236
118287
  async function runOperationalInboxLoopWithRestart(options, onUpdate, isStopped) {
118237
118288
  let backoffMs = INBOX_RESTART_INITIAL_MS;
@@ -118302,8 +118353,8 @@ var INBOX_RESTART_INITIAL_MS = 1000, INBOX_RESTART_MAX_MS = 30000, startTaskInbo
118302
118353
  console.warn("[OperationalInbox] bootstrap failed:", error51);
118303
118354
  return exports_Effect.succeed(false);
118304
118355
  }));
118305
- const operationalHandler = async (update6) => {
118306
- const chatroomId = update6.chatroomId;
118356
+ const operationalHandler = async (kind, update6) => {
118357
+ const chatroomId2 = update6.chatroomId;
118307
118358
  const changed = agentOperationalReadModel.applySignalPage(update6.rows, update6.removed);
118308
118359
  await Promise.all(changed.map(({ chatroomId: roomId, role }) => nativeDelivery.requestReconcile({
118309
118360
  chatroomId: roomId,
@@ -118311,17 +118362,17 @@ var INBOX_RESTART_INITIAL_MS = 1000, INBOX_RESTART_MAX_MS = 30000, startTaskInbo
118311
118362
  source: "operational-signal"
118312
118363
  })));
118313
118364
  inboxStore.save({
118314
- inboxType: "operational",
118315
- scopeKey: roomScopeKey(session2.machineId, chatroomId)
118365
+ inboxType: `operational:${kind}`,
118366
+ scopeKey: roomScopeKey(session2.machineId, chatroomId2)
118316
118367
  }, { afterSignalKey: update6.throughSignalKey });
118317
118368
  try {
118318
- await ackMachineOperationalSignals(sessionDeps, session2.machineId, chatroomId, update6.throughSignalKey);
118369
+ await ackMachineSignal(sessionDeps, session2.machineId, chatroomId2, update6.throughSignalKey, kind);
118319
118370
  } catch (error51) {
118320
- console.warn(`[OperationalInbox room=${chatroomId}] signal cleanup failed:`, error51);
118371
+ console.warn(`[OperationalInbox kind=${kind} room=${chatroomId2}] signal cleanup failed:`, error51);
118321
118372
  }
118322
118373
  };
118323
- const ensureRoomInboxes = (chatroomId) => {
118324
- const existing = roomWatchers.get(chatroomId);
118374
+ const ensureRoomInboxes = (chatroomId2) => {
118375
+ const existing = roomWatchers.get(chatroomId2);
118325
118376
  if (existing)
118326
118377
  return existing.startPromise;
118327
118378
  const controller = new AbortController;
@@ -118329,48 +118380,48 @@ var INBOX_RESTART_INITIAL_MS = 1000, INBOX_RESTART_MAX_MS = 30000, startTaskInbo
118329
118380
  controller,
118330
118381
  startPromise: Promise.resolve()
118331
118382
  };
118332
- roomWatchers.set(chatroomId, entry);
118383
+ roomWatchers.set(chatroomId2, entry);
118333
118384
  entry.startPromise = (async () => {
118334
- if (!knownRoomIds.has(chatroomId)) {
118385
+ if (!knownRoomIds.has(chatroomId2)) {
118335
118386
  try {
118336
118387
  const current = await fetchMachineAgentOperationalStatus(sessionDeps, session2.machineId);
118337
118388
  agentOperationalReadModel.replace(current);
118338
118389
  for (const row of current)
118339
118390
  knownRoomIds.add(row.chatroomId);
118340
118391
  } catch (error51) {
118341
- console.warn(`[OperationalInbox room=${chatroomId}] operational hydration failed:`, error51);
118392
+ console.warn(`[OperationalInbox room=${chatroomId2}] operational hydration failed:`, error51);
118342
118393
  }
118343
118394
  }
118344
- const operationalRoomKey = {
118345
- inboxType: "operational",
118346
- scopeKey: roomScopeKey(session2.machineId, chatroomId)
118347
- };
118348
- const persistedOperationalRoom = inboxStore.get(operationalRoomKey);
118349
- let operationalCursor;
118350
- if (persistedOperationalRoom) {
118351
- operationalCursor = persistedOperationalRoom.state.afterSignalKey;
118352
- ackMachineOperationalSignals(sessionDeps, session2.machineId, chatroomId, operationalCursor).catch((error51) => console.warn(`[OperationalInbox room=${chatroomId}] startup signal cleanup failed:`, error51));
118353
- } else if (bootstrapSucceeded) {
118354
- operationalCursor = operationalSignalCursorAt(serviceStartedAt);
118355
- try {
118356
- inboxStore.save(operationalRoomKey, { afterSignalKey: operationalCursor });
118357
- ackMachineOperationalSignals(sessionDeps, session2.machineId, chatroomId, operationalCursor).catch((error51) => console.warn(`[OperationalInbox room=${chatroomId}] startup signal cleanup failed:`, error51));
118358
- } catch (error51) {
118359
- console.warn(`[OperationalInbox room=${chatroomId}] failed to persist bootstrap baseline:`, error51);
118395
+ await Promise.all(["agent-operational", "connectivity", "agent-stop", "agent-removal"].map(async (kind) => {
118396
+ const operationalRoomKey = {
118397
+ inboxType: `operational:${kind}`,
118398
+ scopeKey: roomScopeKey(session2.machineId, chatroomId2)
118399
+ };
118400
+ const persistedRoom = inboxStore.get(operationalRoomKey);
118401
+ let cursor = persistedRoom?.state.afterSignalKey;
118402
+ if (!cursor) {
118403
+ cursor = operationalSignalCursorAt(serviceStartedAt);
118404
+ try {
118405
+ inboxStore.save(operationalRoomKey, { afterSignalKey: cursor });
118406
+ } catch (error51) {
118407
+ console.warn(`[OperationalInbox kind=${kind} room=${chatroomId2}] failed to persist bootstrap baseline:`, error51);
118408
+ }
118360
118409
  }
118361
- } else {
118362
- operationalCursor = operationalSignalCursorAt(serviceStartedAt);
118363
- }
118364
- runOperationalInboxLoopWithRestart({
118365
- client: wsClient2,
118366
- sessionId: session2.sessionId,
118367
- machineId: session2.machineId,
118368
- chatroomId,
118369
- serviceStartedAt,
118370
- initialAfterSignalKey: operationalCursor,
118371
- signal: controller.signal
118372
- }, operationalHandler, () => stopped);
118373
- await session2.taskService.registerTaskChatroom(chatroomId);
118410
+ if (persistedRoom || bootstrapSucceeded) {
118411
+ ackMachineSignal(sessionDeps, session2.machineId, chatroomId2, cursor, kind).catch((error51) => console.warn(`[OperationalInbox kind=${kind} room=${chatroomId2}] startup signal cleanup failed:`, error51));
118412
+ }
118413
+ runOperationalInboxLoopWithRestart({
118414
+ client: wsClient2,
118415
+ sessionId: session2.sessionId,
118416
+ machineId: session2.machineId,
118417
+ chatroomId: chatroomId2,
118418
+ feed: operationalSignalFeeds[kind],
118419
+ serviceStartedAt,
118420
+ initialAfterSignalKey: cursor,
118421
+ signal: controller.signal
118422
+ }, (update6) => operationalHandler(kind, update6), () => stopped);
118423
+ }));
118424
+ await session2.taskService.registerTaskChatroom(chatroomId2);
118374
118425
  })();
118375
118426
  return entry.startPromise;
118376
118427
  };
@@ -118386,22 +118437,22 @@ var INBOX_RESTART_INITIAL_MS = 1000, INBOX_RESTART_MAX_MS = 30000, startTaskInbo
118386
118437
  ...new Set((workspaces ?? []).map((workspace) => workspace.chatroomId))
118387
118438
  ];
118388
118439
  const activeChatroomIds = new Set(chatroomIds);
118389
- for (const [chatroomId, watcher] of roomWatchers) {
118390
- if (activeChatroomIds.has(chatroomId))
118440
+ for (const [chatroomId2, watcher] of roomWatchers) {
118441
+ if (activeChatroomIds.has(chatroomId2))
118391
118442
  continue;
118392
118443
  watcher.controller.abort();
118393
- session2.taskService.unregisterTaskChatroom(chatroomId);
118394
- roomWatchers.delete(chatroomId);
118395
- knownRoomIds.delete(chatroomId);
118444
+ session2.taskService.unregisterTaskChatroom(chatroomId2);
118445
+ roomWatchers.delete(chatroomId2);
118446
+ knownRoomIds.delete(chatroomId2);
118396
118447
  }
118397
- await Promise.all(chatroomIds.map((chatroomId) => ensureRoomInboxes(chatroomId)));
118448
+ await Promise.all(chatroomIds.map((chatroomId2) => ensureRoomInboxes(chatroomId2)));
118398
118449
  } catch (error51) {
118399
118450
  console.warn("[TaskInbox] room membership refresh failed:", error51);
118400
118451
  }
118401
118452
  };
118402
118453
  registerTaskInboxRoomMembershipRefresh(refreshRoomMembership2);
118403
118454
  yield* exports_Effect.promise(refreshRoomMembership2);
118404
- yield* exports_Effect.tryPromise(() => Promise.all([...knownRoomIds].map((chatroomId) => ensureRoomInboxes(chatroomId)))).pipe(exports_Effect.catchAll((error51) => {
118455
+ yield* exports_Effect.tryPromise(() => Promise.all([...knownRoomIds].map((chatroomId2) => ensureRoomInboxes(chatroomId2)))).pipe(exports_Effect.catchAll((error51) => {
118405
118456
  console.warn("[OperationalInbox] initial watcher start failed:", error51);
118406
118457
  return exports_Effect.void;
118407
118458
  }));
@@ -118428,6 +118479,7 @@ var init_task_inbox_runtime = __esm(() => {
118428
118479
  init_ack_machine_operational_signals();
118429
118480
  init_fetch_machine_agent_operational_status();
118430
118481
  init_operational_inbox();
118482
+ init_operational_signal_feeds();
118431
118483
  init_inbox();
118432
118484
  init_service_interfaces();
118433
118485
  });
@@ -118773,11 +118825,11 @@ var init_on_daemon_shutdown = __esm(() => {
118773
118825
  console.log(`[${formatTimestamp()}] Stopping ${activeAgents.length} agent(s) locally...`);
118774
118826
  let totalStopped = 0;
118775
118827
  let totalFailed = 0;
118776
- yield* exports_Effect.all(activeAgents.map(({ chatroomId, role }) => exports_Effect.promise(() => agentPm.stopAgent({ chatroomId, role, reason: "daemon.shutdown" })).pipe(exports_Effect.tap(() => exports_Effect.sync(() => {
118828
+ yield* exports_Effect.all(activeAgents.map(({ chatroomId: chatroomId2, role }) => exports_Effect.promise(() => agentPm.stopAgent({ chatroomId: chatroomId2, role, reason: "daemon.shutdown" })).pipe(exports_Effect.tap(() => exports_Effect.sync(() => {
118777
118829
  totalStopped += 1;
118778
118830
  })), exports_Effect.catchAll((e) => exports_Effect.sync(() => {
118779
118831
  totalFailed += 1;
118780
- console.log(` ⚠️ Failed to stop ${role}@${chatroomId}: ${e.message}`);
118832
+ console.log(` ⚠️ Failed to stop ${role}@${chatroomId2}: ${e.message}`);
118781
118833
  })))), { concurrency: "unbounded" });
118782
118834
  if (totalFailed > 0) {
118783
118835
  console.log(`[${formatTimestamp()}] Shutdown stops: ${totalStopped} stopped, ${totalFailed} failed`);
@@ -119599,15 +119651,15 @@ function startEnhancerJobSubscriber2(deps, onEvent) {
119599
119651
  const onError3 = (err) => {
119600
119652
  console.warn(`[daemon] enhancer-job subscriber error: ${err instanceof Error ? err.message : String(err)}`);
119601
119653
  };
119602
- const watchChatroom = (chatroomId) => {
119603
- if (watchers.has(chatroomId) || stopped)
119654
+ const watchChatroom = (chatroomId2) => {
119655
+ if (watchers.has(chatroomId2) || stopped)
119604
119656
  return;
119605
119657
  const unsub = deps.wsClient.onUpdate(api.daemon.enhancer.index.pendingForChatroom, {
119606
119658
  sessionId: deps.sessionId,
119607
119659
  machineId: deps.machineId,
119608
- chatroomId
119660
+ chatroomId: chatroomId2
119609
119661
  }, onPendingJobs, onError3);
119610
- watchers.set(chatroomId, unsub);
119662
+ watchers.set(chatroomId2, unsub);
119611
119663
  };
119612
119664
  const refreshChatrooms = async () => {
119613
119665
  if (refreshInFlight)
@@ -120092,10 +120144,10 @@ function queryEventStream(db, input) {
120092
120144
  payload: JSON.parse(row.payload_json)
120093
120145
  }));
120094
120146
  }
120095
- function queryAfterId(db, afterId = 0, limit = 100, source, chatroomId, role, harness, fromTimestamp, toTimestamp) {
120147
+ function queryAfterId(db, afterId = 0, limit = 100, source, chatroomId2, role, harness, fromTimestamp, toTimestamp) {
120096
120148
  const filters = [
120097
120149
  source ? "AND source = ?" : "",
120098
- chatroomId ? "AND json_extract(metadata_json, '$.chatroomId') = ?" : "",
120150
+ chatroomId2 ? "AND json_extract(metadata_json, '$.chatroomId') = ?" : "",
120099
120151
  role ? "AND json_extract(metadata_json, '$.role') = ?" : "",
120100
120152
  harness ? "AND (json_extract(metadata_json, '$.harness') = ? OR source = ?)" : "",
120101
120153
  fromTimestamp !== undefined ? "AND timestamp >= ?" : "",
@@ -120104,7 +120156,7 @@ function queryAfterId(db, afterId = 0, limit = 100, source, chatroomId, role, ha
120104
120156
  const values3 = [
120105
120157
  afterId,
120106
120158
  ...source ? [source] : [],
120107
- ...chatroomId ? [chatroomId] : [],
120159
+ ...chatroomId2 ? [chatroomId2] : [],
120108
120160
  ...role ? [role] : [],
120109
120161
  ...harness ? [harness, `harness:${harness}`] : [],
120110
120162
  ...fromTimestamp !== undefined ? [fromTimestamp] : [],
@@ -120114,11 +120166,11 @@ function queryAfterId(db, afterId = 0, limit = 100, source, chatroomId, role, ha
120114
120166
  const rows = db.prepare(`SELECT * FROM log_entries WHERE id > ? ${filters} ORDER BY id ASC LIMIT ?`).all(...values3);
120115
120167
  return rows.map(map19);
120116
120168
  }
120117
- function queryHistory(db, beforeId, limit = 100, source, chatroomId, role, harness, fromTimestamp, toTimestamp) {
120169
+ function queryHistory(db, beforeId, limit = 100, source, chatroomId2, role, harness, fromTimestamp, toTimestamp) {
120118
120170
  const filters = [
120119
120171
  beforeId ? "AND id < ?" : "",
120120
120172
  source ? "AND source = ?" : "",
120121
- chatroomId ? "AND json_extract(metadata_json, '$.chatroomId') = ?" : "",
120173
+ chatroomId2 ? "AND json_extract(metadata_json, '$.chatroomId') = ?" : "",
120122
120174
  role ? "AND json_extract(metadata_json, '$.role') = ?" : "",
120123
120175
  harness ? "AND (json_extract(metadata_json, '$.harness') = ? OR source = ?)" : "",
120124
120176
  fromTimestamp !== undefined ? "AND timestamp >= ?" : "",
@@ -120127,7 +120179,7 @@ function queryHistory(db, beforeId, limit = 100, source, chatroomId, role, harne
120127
120179
  const values3 = [
120128
120180
  ...beforeId ? [beforeId] : [],
120129
120181
  ...source ? [source] : [],
120130
- ...chatroomId ? [chatroomId] : [],
120182
+ ...chatroomId2 ? [chatroomId2] : [],
120131
120183
  ...role ? [role] : [],
120132
120184
  ...harness ? [harness, `harness:${harness}`] : [],
120133
120185
  ...fromTimestamp !== undefined ? [fromTimestamp] : [],
@@ -120137,9 +120189,9 @@ function queryHistory(db, beforeId, limit = 100, source, chatroomId, role, harne
120137
120189
  const rows = db.prepare(`SELECT * FROM log_entries WHERE 1=1 ${filters} ORDER BY id DESC LIMIT ?`).all(...values3);
120138
120190
  return rows.map(map19).reverse();
120139
120191
  }
120140
- function listLogDimensions(db, chatroomId, limit = 100) {
120192
+ function listLogDimensions(db, chatroomId2, limit = 100) {
120141
120193
  const clamped = clamp4(limit);
120142
- const values3 = (sql) => db.prepare(sql).all(chatroomId, clamped).map((r) => r.v);
120194
+ const values3 = (sql) => db.prepare(sql).all(chatroomId2, clamped).map((r) => r.v);
120143
120195
  const roles = values3("SELECT DISTINCT json_extract(metadata_json, '$.role') AS v FROM log_entries WHERE json_extract(metadata_json, '$.chatroomId') = ? AND json_extract(metadata_json, '$.role') IS NOT NULL ORDER BY v LIMIT ?");
120144
120196
  const meta3 = values3("SELECT DISTINCT json_extract(metadata_json, '$.harness') AS v FROM log_entries WHERE json_extract(metadata_json, '$.chatroomId') = ? AND json_extract(metadata_json, '$.harness') IS NOT NULL ORDER BY v LIMIT ?");
120145
120197
  const source = values3("SELECT DISTINCT substr(source, 9) AS v FROM log_entries WHERE json_extract(metadata_json, '$.chatroomId') = ? AND source LIKE 'harness:%' ORDER BY v LIMIT ?");
@@ -120323,17 +120375,17 @@ var init_persistence = __esm(() => {
120323
120375
  // src/daemon/infrastructure/repository/log-repository.ts
120324
120376
  function createLogRepository(db) {
120325
120377
  return {
120326
- queryAfterId(afterId = 0, limit = 100, source, chatroomId, role, harness, fromTimestamp, toTimestamp) {
120327
- return queryAfterId(db, afterId, limit, source, chatroomId, role, harness, fromTimestamp, toTimestamp);
120378
+ queryAfterId(afterId = 0, limit = 100, source, chatroomId2, role, harness, fromTimestamp, toTimestamp) {
120379
+ return queryAfterId(db, afterId, limit, source, chatroomId2, role, harness, fromTimestamp, toTimestamp);
120328
120380
  },
120329
- queryHistory(beforeId, limit = 100, source, chatroomId, role, harness, fromTimestamp, toTimestamp) {
120330
- return queryHistory(db, beforeId, limit, source, chatroomId, role, harness, fromTimestamp, toTimestamp);
120381
+ queryHistory(beforeId, limit = 100, source, chatroomId2, role, harness, fromTimestamp, toTimestamp) {
120382
+ return queryHistory(db, beforeId, limit, source, chatroomId2, role, harness, fromTimestamp, toTimestamp);
120331
120383
  },
120332
120384
  listSources(limit = 100) {
120333
120385
  return listDistinctSources(db, limit);
120334
120386
  },
120335
- listDimensions(chatroomId, limit = 100) {
120336
- return listLogDimensions(db, chatroomId, limit);
120387
+ listDimensions(chatroomId2, limit = 100) {
120388
+ return listLogDimensions(db, chatroomId2, limit);
120337
120389
  },
120338
120390
  writeChatroomEvent(event) {
120339
120391
  return appendChatroomEvent(db, event);
@@ -134145,8 +134197,8 @@ function listLogHistory(reader, input) {
134145
134197
  const entries2 = input.afterId !== undefined ? reader.queryAfterId(input.afterId, limit, input.source, input.chatroomId, input.role, input.harness, input.fromTimestamp, input.toTimestamp) : reader.queryHistory(input.beforeId, limit, input.source, input.chatroomId, input.role, input.harness, input.fromTimestamp, input.toTimestamp);
134146
134198
  return { entries: entries2 };
134147
134199
  }
134148
- function listLogDimensions2(reader, chatroomId, limit = 100) {
134149
- return reader.listDimensions ? reader.listDimensions(chatroomId, limit) : { roles: [], harnesses: [] };
134200
+ function listLogDimensions2(reader, chatroomId2, limit = 100) {
134201
+ return reader.listDimensions ? reader.listDimensions(chatroomId2, limit) : { roles: [], harnesses: [] };
134150
134202
  }
134151
134203
  function listLogSources(reader, limit = 100) {
134152
134204
  return { sources: reader.listSources(limit) };
@@ -135364,7 +135416,7 @@ handoffCommandGroup.option("--chatroom-id <id>", "Chatroom identifier").option("
135364
135416
  console.error(`error: required option '${flag} <...>' not specified`);
135365
135417
  process.exit(1);
135366
135418
  }
135367
- const { chatroomId, role, nextRole } = options;
135419
+ const { chatroomId: chatroomId2, role, nextRole } = options;
135368
135420
  await maybeRequireAuth();
135369
135421
  const { decode: decode6 } = await Promise.resolve().then(() => exports_decode);
135370
135422
  const stdinContent = await readStdin();
@@ -135383,7 +135435,7 @@ handoffCommandGroup.option("--chatroom-id <id>", "Chatroom identifier").option("
135383
135435
  process.exit(1);
135384
135436
  }
135385
135437
  const { handoff: handoff2 } = await Promise.resolve().then(() => (init_handoff(), exports_handoff));
135386
- await handoff2(chatroomId, {
135438
+ await handoff2(chatroomId2, {
135387
135439
  role,
135388
135440
  message,
135389
135441
  nextRole
@@ -135707,18 +135759,18 @@ registerChatroomRoleCommand(program2, {
135707
135759
  name: "get-system-prompt",
135708
135760
  description: "Fetch the system prompt for your role in a chatroom",
135709
135761
  maybeRequireAuth,
135710
- run: async (chatroomId, { role }) => {
135762
+ run: async (chatroomId2, { role }) => {
135711
135763
  const { getSystemPrompt: getSystemPrompt2 } = await Promise.resolve().then(() => (init_get_system_prompt(), exports_get_system_prompt));
135712
- await getSystemPrompt2(chatroomId, { role });
135764
+ await getSystemPrompt2(chatroomId2, { role });
135713
135765
  }
135714
135766
  });
135715
135767
  registerChatroomRoleCommand(program2, {
135716
135768
  name: "get-role-guidance",
135717
135769
  description: "Fetch role-specific operating-model guidance for your role in a chatroom",
135718
135770
  maybeRequireAuth,
135719
- run: async (chatroomId, { role }) => {
135771
+ run: async (chatroomId2, { role }) => {
135720
135772
  const { getRoleGuidance: getRoleGuidance2 } = await Promise.resolve().then(() => (init_get_role_guidance(), exports_get_role_guidance));
135721
- await getRoleGuidance2(chatroomId, { role });
135773
+ await getRoleGuidance2(chatroomId2, { role });
135722
135774
  }
135723
135775
  });
135724
135776
  var telegramCommand = program2.command("telegram").description("Telegram integration commands");
@@ -135753,9 +135805,9 @@ opencodeCommand.command("install").description("Install chatroom as an OpenCode
135753
135805
  });
135754
135806
  program2.hook("preAction", async (_thisCommand, actionCommand) => {
135755
135807
  const opts = actionCommand.opts();
135756
- const chatroomId = opts["chatroomId"];
135808
+ const chatroomId2 = opts["chatroomId"];
135757
135809
  const role = opts["role"];
135758
- if (!chatroomId || !role)
135810
+ if (!chatroomId2 || !role)
135759
135811
  return;
135760
135812
  const { getSessionId: getSessionId2 } = await Promise.resolve().then(() => (init_storage(), exports_storage));
135761
135813
  const { getConvexClient: getConvexClient2 } = await Promise.resolve().then(() => (init_client2(), exports_client));
@@ -135764,8 +135816,8 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
135764
135816
  if (!sessionId)
135765
135817
  return;
135766
135818
  const client4 = await getConvexClient2();
135767
- sendLifecycleHeartbeat2(client4, { sessionId, chatroomId, role });
135819
+ sendLifecycleHeartbeat2(client4, { sessionId, chatroomId: chatroomId2, role });
135768
135820
  });
135769
135821
  program2.parse();
135770
135822
 
135771
- //# debugId=F48EA5F0861EF1C964756E2164756E21
135823
+ //# debugId=B512277D42B2480364756E2164756E21