baro-ai 0.59.2 → 0.61.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/cli.mjs CHANGED
@@ -43312,7 +43312,15 @@ function extractPath(item) {
43312
43312
  }
43313
43313
 
43314
43314
  // ../baro-orchestrator/src/participants/forwarders/token-usage.ts
43315
+ var PROGRESS_THROTTLE_MS = 1500;
43315
43316
  var TokenUsageForwarder = class extends BaseObserver {
43317
+ // Per-agent live accumulator for Claude streaming. Claude reports
43318
+ // output_tokens cumulatively *within a message*, restarting each turn — so
43319
+ // we carry committed output across turns and add the current message's count.
43320
+ // We track OUTPUT only: per-message input_tokens includes the whole replayed
43321
+ // context, so summing it across turns would wildly over-count. Input comes
43322
+ // from the authoritative token_usage total at the end instead.
43323
+ live = /* @__PURE__ */ new Map();
43316
43324
  async onExternalEvent(_source, event) {
43317
43325
  if (AgentResult.is(event)) {
43318
43326
  this.handleClaudeResult(event.data);
@@ -43322,6 +43330,38 @@ var TokenUsageForwarder = class extends BaseObserver {
43322
43330
  this.handleCodexTurnEvent(event.data);
43323
43331
  return;
43324
43332
  }
43333
+ if (ClaudeStreamChunk.is(event)) {
43334
+ this.handleStreamChunk(event.data);
43335
+ return;
43336
+ }
43337
+ }
43338
+ handleStreamChunk(item) {
43339
+ const inner = item.raw.event ?? item.raw;
43340
+ const type = typeof inner.type === "string" ? inner.type : "";
43341
+ const num = (v) => typeof v === "number" ? v : 0;
43342
+ const st = this.live.get(item.agentId) ?? { committedOut: 0, curOut: 0, lastEmit: 0 };
43343
+ if (type === "message_start") {
43344
+ st.committedOut += st.curOut;
43345
+ const msg = inner.message ?? {};
43346
+ st.curOut = num((msg.usage ?? {}).output_tokens);
43347
+ } else if (type === "message_delta") {
43348
+ const usage = inner.usage ?? {};
43349
+ st.curOut = num(usage.output_tokens) || st.curOut;
43350
+ } else {
43351
+ this.live.set(item.agentId, st);
43352
+ return;
43353
+ }
43354
+ this.live.set(item.agentId, st);
43355
+ const now = Date.now();
43356
+ if (type !== "message_start" && now - st.lastEmit < PROGRESS_THROTTLE_MS) return;
43357
+ st.lastEmit = now;
43358
+ emit({
43359
+ type: "token_progress",
43360
+ id: item.agentId,
43361
+ input_tokens: 0,
43362
+ // input comes from the authoritative total; see above
43363
+ output_tokens: st.committedOut + st.curOut
43364
+ });
43325
43365
  }
43326
43366
  handleClaudeResult(item) {
43327
43367
  const usage = item.usage;
@@ -48403,6 +48443,9 @@ async function orchestrate(config) {
48403
48443
  (lvl) => lvl.storyIds.map((id) => ({ id }))
48404
48444
  );
48405
48445
  emit({ type: "dag", levels: dagLevels });
48446
+ if (prd.decisionDocument && prd.decisionDocument.trim()) {
48447
+ emit({ type: "decision_document", document: prd.decisionDocument });
48448
+ }
48406
48449
  }
48407
48450
  env.deliverSemanticEvent(
48408
48451
  operator,