chatroom-cli 1.54.1 → 1.54.2

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
@@ -30181,6 +30181,14 @@ function formatLogLine(options, kind, payload) {
30181
30181
  const ts = options.now ? options.now() : new Date().toISOString();
30182
30182
  return `[${ts}] role:${options.role} ${kind}]${payload ? ` ${payload}` : ""}`;
30183
30183
  }
30184
+ function isUsageLimitError(error) {
30185
+ if (!error || typeof error !== "object")
30186
+ return false;
30187
+ const e = error;
30188
+ const name = String(e.name ?? e.type ?? "").toLowerCase();
30189
+ const message = String(e.data?.message ?? e.message ?? "").toLowerCase();
30190
+ return name.includes("usagelimit") || message.includes("usage limit") || message.includes("enable usage from your available balance");
30191
+ }
30184
30192
  function eventSessionId(event) {
30185
30193
  const p = event.properties;
30186
30194
  if (!p || typeof p !== "object")
@@ -30323,6 +30331,12 @@ function startSessionEventForwarder(client4, options) {
30323
30331
  }
30324
30332
  errorTarget.write(formatLogLine(options, "error", payload) + `
30325
30333
  `);
30334
+ if (isUsageLimitError(err)) {
30335
+ target.write(formatLogLine(options, "agent_end", "reason: usage_limit_reached") + `
30336
+ `);
30337
+ for (const cb of agentEndCallbacks)
30338
+ cb();
30339
+ }
30326
30340
  break;
30327
30341
  }
30328
30342
  default:
@@ -78748,11 +78762,7 @@ ${content}`);
78748
78762
  lines.push(input.context.content);
78749
78763
  lines.push("</context>");
78750
78764
  if (input.context.triggerMessageContent) {
78751
- lines.push("in response to");
78752
- const senderTag = input.context.triggerMessageSenderRole ?? "unknown";
78753
- lines.push(`<${senderTag}-message>`);
78754
- lines.push(input.context.triggerMessageContent);
78755
- lines.push(`</${senderTag}-message>`);
78765
+ lines.push(`(For the message that triggered this context, run: chatroom context read --chatroom-id="${chatroomId}" --role="${role}")`);
78756
78766
  }
78757
78767
  const hoursAgo = Math.round(input.context.elapsedHours);
78758
78768
  if (hoursAgo >= 4) {
@@ -80354,8 +80364,8 @@ var init_log_observer_sync = __esm(() => {
80354
80364
 
80355
80365
  // src/commands/machine/daemon-start/handlers/process/spawner.ts
80356
80366
  import { spawn as spawn3 } from "node:child_process";
80357
- async function flushTailV2(ctx, tracked) {
80358
- if (!isRunLogObserved(tracked.runId))
80367
+ async function flushTailV2(ctx, tracked, force = false) {
80368
+ if (!force && !isRunLogObserved(tracked.runId))
80359
80369
  return;
80360
80370
  const tail = await tracked.store.getLastNLines(MAX_TAIL_LINES_V2);
80361
80371
  if (tail.content.length === 0)
@@ -80409,7 +80419,7 @@ async function appendFullOutputChunks(ctx, tracked, runId) {
80409
80419
  }
80410
80420
  }
80411
80421
  async function flushFinalChunks(ctx, tracked, runId) {
80412
- await flushTailV2(ctx, tracked);
80422
+ await flushTailV2(ctx, tracked, true);
80413
80423
  if (consumePendingFullSync(tracked.runId)) {
80414
80424
  await appendFullOutputChunks(ctx, tracked, runId);
80415
80425
  }
@@ -88568,4 +88578,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
88568
88578
  });
88569
88579
  program2.parse();
88570
88580
 
88571
- //# debugId=4BE6EFE565A3E11F64756E2164756E21
88581
+ //# debugId=A45EE098A894A8F164756E2164756E21