baro-ai 0.23.5 → 0.24.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
@@ -8794,6 +8794,12 @@ var Conductor = class extends Participant {
8794
8794
  spawnQueue = [];
8795
8795
  /** Stories currently in flight in the active level. */
8796
8796
  inFlight = /* @__PURE__ */ new Set();
8797
+ /**
8798
+ * Timer handle when we're deliberately spacing out intra-level
8799
+ * spawns. Re-entering `fillSpawnSlots` while this is set is a
8800
+ * no-op; the timer callback resumes pumping.
8801
+ */
8802
+ pendingNextSpawn = null;
8797
8803
  /** Resolved when the run terminates, exposed for callers that need it. */
8798
8804
  done;
8799
8805
  resolveDone;
@@ -8803,8 +8809,12 @@ var Conductor = class extends Participant {
8803
8809
  parallel: 0,
8804
8810
  timeoutSecs: 600,
8805
8811
  defaultModel: "sonnet",
8812
+ intraLevelDelaySecs: 10,
8806
8813
  ...opts
8807
8814
  };
8815
+ if (this.opts.intraLevelDelaySecs == null) {
8816
+ this.opts.intraLevelDelaySecs = 10;
8817
+ }
8808
8818
  this.done = new Promise((resolve2) => {
8809
8819
  this.resolveDone = resolve2;
8810
8820
  });
@@ -8950,10 +8960,25 @@ var Conductor = class extends Participant {
8950
8960
  }
8951
8961
  async fillSpawnSlots() {
8952
8962
  if (!this.currentLevel) return;
8963
+ if (this.pendingNextSpawn) return;
8953
8964
  const cap = this.opts.parallel > 0 ? this.opts.parallel : Number.MAX_SAFE_INTEGER;
8965
+ const delaySecs = this.opts.intraLevelDelaySecs ?? 0;
8954
8966
  while (this.spawnQueue.length > 0 && this.inFlight.size < cap) {
8955
8967
  const story = this.spawnQueue.shift();
8956
8968
  await this.requestStorySpawn(story);
8969
+ if (this.spawnQueue.length > 0 && this.inFlight.size < cap && delaySecs > 0) {
8970
+ this.pendingNextSpawn = setTimeout(() => {
8971
+ this.pendingNextSpawn = null;
8972
+ if (this.phase === "done") return;
8973
+ this.fillSpawnSlots().catch((err) => {
8974
+ process.stderr.write(
8975
+ `[conductor] fillSpawnSlots resume failed: ${err?.stack ?? String(err)}
8976
+ `
8977
+ );
8978
+ });
8979
+ }, delaySecs * 1e3);
8980
+ return;
8981
+ }
8957
8982
  }
8958
8983
  }
8959
8984
  async requestStorySpawn(story) {
@@ -9785,15 +9810,21 @@ var EXPLORATION_TOOLS = /* @__PURE__ */ new Set([
9785
9810
  "WebFetch",
9786
9811
  "WebSearch"
9787
9812
  ]);
9813
+ var BROADCAST_TOOLS = /* @__PURE__ */ new Set(["Read", "Grep", "Glob", "LSP"]);
9788
9814
  var Librarian = class extends Participant {
9789
9815
  opts;
9790
9816
  pending = /* @__PURE__ */ new Map();
9791
9817
  knowledge = [];
9818
+ // Mid-flight bookkeeping
9819
+ inFlight = /* @__PURE__ */ new Set();
9820
+ storyHints = /* @__PURE__ */ new Map();
9821
+ broadcastBytes = /* @__PURE__ */ new Map();
9792
9822
  constructor(opts = {}) {
9793
9823
  super();
9794
9824
  this.opts = {
9795
9825
  maxContentChars: opts.maxContentChars ?? 4e3,
9796
- maxInjectedChars: opts.maxInjectedChars ?? 8e3
9826
+ maxInjectedChars: opts.maxInjectedChars ?? 2e4,
9827
+ maxBroadcastBytesPerStory: opts.maxBroadcastBytesPerStory ?? 5e4
9797
9828
  };
9798
9829
  }
9799
9830
  /** All indexed knowledge entries, in order discovered. */
@@ -9834,9 +9865,11 @@ var Librarian = class extends Participant {
9834
9865
  }
9835
9866
  if (lines.length === 0) return null;
9836
9867
  return [
9837
- "[librarian] Findings from prior agents in this run that may save",
9838
- "you time. Do not re-fetch what's already here unless you suspect",
9839
- "the file changed.",
9868
+ "## Codebase context (current as of this run)",
9869
+ "",
9870
+ "The following file contents and discovery results are authoritative",
9871
+ "and up-to-date. Do not re-read or re-search unless you have specific",
9872
+ "reason to suspect a file has changed since these were captured.",
9840
9873
  "",
9841
9874
  ...lines
9842
9875
  ].join("\n");
@@ -9850,6 +9883,18 @@ var Librarian = class extends Participant {
9850
9883
  this.completeWithOutput(source, item);
9851
9884
  return;
9852
9885
  }
9886
+ if (item instanceof StorySpawnRequestItem) {
9887
+ this.storyHints.set(item.storyId, tokenizeHints(item.prompt));
9888
+ return;
9889
+ }
9890
+ if (item instanceof StorySpawnedItem) {
9891
+ this.inFlight.add(item.storyId);
9892
+ return;
9893
+ }
9894
+ if (item instanceof StoryResultItem) {
9895
+ this.inFlight.delete(item.storyId);
9896
+ return;
9897
+ }
9853
9898
  }
9854
9899
  recordPending(source, item) {
9855
9900
  if (!EXPLORATION_TOOLS.has(item.name)) return;
@@ -9896,6 +9941,51 @@ var Librarian = class extends Participant {
9896
9941
  )
9897
9942
  );
9898
9943
  }
9944
+ if (BROADCAST_TOOLS.has(entry.tool)) {
9945
+ this.broadcastFinding(entry);
9946
+ }
9947
+ }
9948
+ broadcastFinding(finding) {
9949
+ if (this.inFlight.size === 0) return;
9950
+ const envs = this.getEnvironments();
9951
+ if (envs.length === 0) return;
9952
+ const findingTokens = new Set(
9953
+ [...finding.tags, finding.summary].join(" ").toLowerCase().split(/[^a-z0-9_/.\\-]+/).filter((t) => t.length >= 3)
9954
+ );
9955
+ const block = formatEntry(finding);
9956
+ const text = [
9957
+ "## Just-in-time codebase context",
9958
+ "",
9959
+ `Another agent in this run (${finding.sourceAgentId}) just`,
9960
+ "discovered the following. It is authoritative and current;",
9961
+ "use it directly without re-fetching.",
9962
+ "",
9963
+ block
9964
+ ].join("\n");
9965
+ const bytes = text.length;
9966
+ for (const recipientId of this.inFlight) {
9967
+ if (recipientId === finding.sourceAgentId) continue;
9968
+ const recipientHints = this.storyHints.get(recipientId) ?? [];
9969
+ if (recipientHints.length > 0) {
9970
+ const overlap = recipientHints.some(
9971
+ (h) => findingTokens.has(h.toLowerCase())
9972
+ );
9973
+ if (!overlap) continue;
9974
+ }
9975
+ const already = this.broadcastBytes.get(recipientId) ?? 0;
9976
+ if (already + bytes > this.opts.maxBroadcastBytesPerStory) continue;
9977
+ this.broadcastBytes.set(recipientId, already + bytes);
9978
+ for (const env of envs) {
9979
+ env.deliverContextItem(
9980
+ this,
9981
+ new AgentTargetedMessageItem(recipientId, text, {
9982
+ source: "librarian",
9983
+ finding: finding.summary,
9984
+ from_agent: finding.sourceAgentId
9985
+ })
9986
+ );
9987
+ }
9988
+ }
9899
9989
  }
9900
9990
  };
9901
9991
  function describeCall(tool, args) {
@@ -9948,6 +10038,9 @@ function formatEntry(k) {
9948
10038
  ""
9949
10039
  ].join("\n");
9950
10040
  }
10041
+ function tokenizeHints(prompt) {
10042
+ return prompt.toLowerCase().split(/[^a-z0-9_/.\-]+/).filter((t) => t.length >= 3);
10043
+ }
9951
10044
 
9952
10045
  // ../baro-orchestrator/src/participants/operator.ts
9953
10046
  var Operator = class extends Participant {
@@ -10412,6 +10505,7 @@ async function orchestrate(config) {
10412
10505
  timeoutSecs: config.timeoutSecs ?? 600,
10413
10506
  overrideModel: config.overrideModel ?? void 0,
10414
10507
  defaultModel: config.defaultModel ?? "opus",
10508
+ intraLevelDelaySecs: config.intraLevelDelaySecs,
10415
10509
  onRunStart: useGit ? async (prd) => {
10416
10510
  baseSha = await getHeadSha(config.cwd);
10417
10511
  if (prd.branchName) {
@@ -10750,6 +10844,12 @@ function parseArgs(argv) {
10750
10844
  case "--surgeon-model":
10751
10845
  args.surgeonModel = required(argv, ++i, "--surgeon-model");
10752
10846
  break;
10847
+ case "--intra-level-delay":
10848
+ args.intraLevelDelaySecs = parseInt(
10849
+ required(argv, ++i, "--intra-level-delay"),
10850
+ 10
10851
+ );
10852
+ break;
10753
10853
  default:
10754
10854
  process.stderr.write(`[cli] unknown flag: ${a}
10755
10855
  `);
@@ -10791,6 +10891,7 @@ function printHelp() {
10791
10891
  " --with-surgeon Enable Surgeon (adaptive DAG mutation)",
10792
10892
  " --surgeon-use-llm Use LLM evaluation in Surgeon (default: deterministic)",
10793
10893
  " --surgeon-model <name> Model for Surgeon LLM (default: opus)",
10894
+ " --intra-level-delay <secs> Stagger story spawns within a level (default: 10, 0 disables)",
10794
10895
  " -h, --help Show this message",
10795
10896
  ""
10796
10897
  ].join("\n")
@@ -10825,7 +10926,8 @@ async function main() {
10825
10926
  withSentry: args.noSentry ? false : void 0,
10826
10927
  withSurgeon: args.withSurgeon,
10827
10928
  surgeonUseLlm: args.surgeonUseLlm,
10828
- surgeonModel: args.surgeonModel
10929
+ surgeonModel: args.surgeonModel,
10930
+ intraLevelDelaySecs: args.intraLevelDelaySecs
10829
10931
  };
10830
10932
  process.stderr.write(
10831
10933
  `[cli] starting orchestrator: prd=${prdPath} cwd=${cwd} parallel=${args.parallel} timeout=${args.timeout}s