chatroom-cli 1.54.0 → 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,17 +78762,11 @@ ${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
- const msgsSince = input.context.messagesSinceContext;
78759
- const isStale = hoursAgo >= 24 || msgsSince >= 50;
78760
- if (isStale) {
78761
- const ageLabel = hoursAgo >= 48 ? `${Math.round(hoursAgo / 24)}d old` : hoursAgo >= 24 ? `${hoursAgo}h old` : `${msgsSince} messages old`;
78768
+ if (hoursAgo >= 4) {
78769
+ const ageLabel = hoursAgo >= 48 ? `${Math.round(hoursAgo / 24)}d old` : hoursAgo >= 24 ? `${hoursAgo}h old` : `${hoursAgo}h old`;
78762
78770
  lines.push(`<system-notice>`);
78763
78771
  lines.push(`⚠️ Context is ${ageLabel}.`);
78764
78772
  lines.push(` Entry point role will update when needed.`);
@@ -79317,9 +79325,6 @@ async function listContexts(chatroomId, options, deps) {
79317
79325
  \uD83D\uDD39 Context ID: ${context4._id}`);
79318
79326
  console.log(` Created by: ${context4.createdBy}`);
79319
79327
  console.log(` Created at: ${timestamp}`);
79320
- if (context4.messageCountAtCreation !== undefined) {
79321
- console.log(` Messages at creation: ${context4.messageCountAtCreation}`);
79322
- }
79323
79328
  console.log(` Content:`);
79324
79329
  const safeContent = sanitizeForTerminal(context4.content);
79325
79330
  const truncatedContent = safeContent.length > 200 ? safeContent.slice(0, 200) + "..." : safeContent;
@@ -79370,17 +79375,15 @@ async function inspectContext(chatroomId, options, deps) {
79370
79375
  console.log(` Created at: ${new Date(context4.createdAt).toLocaleString()}`);
79371
79376
  console.log(`
79372
79377
  \uD83D\uDCCA Staleness:`);
79373
- console.log(` Messages since context: ${context4.messagesSinceContext}`);
79374
79378
  console.log(` Time elapsed: ${context4.elapsedHours.toFixed(1)} hours`);
79375
- if (context4.messagesSinceContext >= 10) {
79376
- console.log(`
79377
- ⚠️ Many messages since this context was created.`);
79378
- console.log(` Consider creating a new context with an updated summary.`);
79379
- }
79380
79379
  if (context4.elapsedHours >= 24) {
79381
79380
  console.log(`
79382
79381
  ⚠️ This context is over 24 hours old.`);
79383
79382
  console.log(` Consider creating a new context with an updated summary.`);
79383
+ } else if (context4.elapsedHours >= 4) {
79384
+ console.log(`
79385
+ ⚠️ This context is over 4 hours old.`);
79386
+ console.log(` Consider refreshing if the focus has shifted.`);
79384
79387
  }
79385
79388
  console.log(`
79386
79389
  \uD83D\uDCDD Content:`);
@@ -80361,8 +80364,8 @@ var init_log_observer_sync = __esm(() => {
80361
80364
 
80362
80365
  // src/commands/machine/daemon-start/handlers/process/spawner.ts
80363
80366
  import { spawn as spawn3 } from "node:child_process";
80364
- async function flushTailV2(ctx, tracked) {
80365
- if (!isRunLogObserved(tracked.runId))
80367
+ async function flushTailV2(ctx, tracked, force = false) {
80368
+ if (!force && !isRunLogObserved(tracked.runId))
80366
80369
  return;
80367
80370
  const tail = await tracked.store.getLastNLines(MAX_TAIL_LINES_V2);
80368
80371
  if (tail.content.length === 0)
@@ -80416,7 +80419,7 @@ async function appendFullOutputChunks(ctx, tracked, runId) {
80416
80419
  }
80417
80420
  }
80418
80421
  async function flushFinalChunks(ctx, tracked, runId) {
80419
- await flushTailV2(ctx, tracked);
80422
+ await flushTailV2(ctx, tracked, true);
80420
80423
  if (consumePendingFullSync(tracked.runId)) {
80421
80424
  await appendFullOutputChunks(ctx, tracked, runId);
80422
80425
  }
@@ -88575,4 +88578,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
88575
88578
  });
88576
88579
  program2.parse();
88577
88580
 
88578
- //# debugId=CA89B8C579092E0C64756E2164756E21
88581
+ //# debugId=A45EE098A894A8F164756E2164756E21