baro-ai 0.70.15 → 0.72.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
@@ -40683,8 +40683,10 @@ var RunStarted = defineSemanticEvent("run_started");
40683
40683
  var LevelComputeRequest = defineSemanticEvent("level_compute_request");
40684
40684
  var LevelStarted = defineSemanticEvent("level_started");
40685
40685
  var LevelCompleted = defineSemanticEvent("level_completed");
40686
+ var RecoveryStarted = defineSemanticEvent("recovery_started");
40686
40687
  var StorySpawnRequest = defineSemanticEvent("story_spawn_request");
40687
40688
  var StorySpawned = defineSemanticEvent("story_spawned");
40689
+ var StoryRouted = defineSemanticEvent("story_routed");
40688
40690
  var FinalizeStarted = defineSemanticEvent("finalize_started");
40689
40691
  var PrCreated = defineSemanticEvent("pr_created");
40690
40692
  var RunCompleted = defineSemanticEvent("run_completed");
@@ -40942,6 +40944,8 @@ var Conductor = class extends BaseObserver {
40942
40944
  */
40943
40945
  recoveryAttempts = /* @__PURE__ */ new Map();
40944
40946
  maxRecoveryAttemptsPerStory = 1;
40947
+ /** Recovery levels started in this run (1-based `attempt` for RecoveryStarted). */
40948
+ recoveryLevelsStarted = 0;
40945
40949
  totalAttempts = 0;
40946
40950
  appliedReplans = 0;
40947
40951
  currentLevel = null;
@@ -41412,6 +41416,13 @@ ${prompt}`;
41412
41416
  failed: [],
41413
41417
  perStoryAttempts: /* @__PURE__ */ new Map()
41414
41418
  };
41419
+ this.recoveryLevelsStarted += 1;
41420
+ this.emit(
41421
+ RecoveryStarted.create({
41422
+ attempt: this.recoveryLevelsStarted,
41423
+ storyIds: this.currentLevel.storyIds
41424
+ })
41425
+ );
41415
41426
  this.emit(
41416
41427
  LevelStarted.create({
41417
41428
  ordinal,
@@ -43201,10 +43212,35 @@ function matchCommit(story, commits) {
43201
43212
  }
43202
43213
 
43203
43214
  // ../baro-orchestrator/src/tui-protocol.ts
43215
+ import { stdin } from "process";
43216
+ import { createInterface } from "readline";
43204
43217
  function emit(event) {
43205
43218
  const line = JSON.stringify(event) + "\n";
43206
43219
  process.stdout.write(line);
43207
43220
  }
43221
+ function subscribeCommands(handler) {
43222
+ const rl = createInterface({ input: stdin });
43223
+ rl.on("line", (line) => {
43224
+ const trimmed = line.trim();
43225
+ if (!trimmed) return;
43226
+ let cmd;
43227
+ try {
43228
+ cmd = JSON.parse(trimmed);
43229
+ } catch {
43230
+ return;
43231
+ }
43232
+ if (!cmd || typeof cmd !== "object" || typeof cmd.type !== "string") {
43233
+ return;
43234
+ }
43235
+ Promise.resolve(handler(cmd)).catch((err) => {
43236
+ process.stderr.write(
43237
+ `[tui-protocol] command handler error: ${err?.message ?? String(err)}
43238
+ `
43239
+ );
43240
+ });
43241
+ });
43242
+ return () => rl.close();
43243
+ }
43208
43244
 
43209
43245
  // ../baro-orchestrator/src/participants/git-coordinator.ts
43210
43246
  var GitCoordinator = class extends BaseObserver {
@@ -43423,6 +43459,13 @@ var CoordinationForwarder = class extends BaseObserver {
43423
43459
  }
43424
43460
  }
43425
43461
  handleIntervention(item) {
43462
+ emit({
43463
+ type: "intervention",
43464
+ id: item.storyId,
43465
+ source: item.source,
43466
+ action: item.action,
43467
+ reason: item.reason
43468
+ });
43426
43469
  emit({
43427
43470
  type: "story_log",
43428
43471
  id: item.storyId,
@@ -43443,6 +43486,13 @@ var CoordinationForwarder = class extends BaseObserver {
43443
43486
  });
43444
43487
  }
43445
43488
  handleCritique(item) {
43489
+ emit({
43490
+ type: "critique",
43491
+ id: item.agentId,
43492
+ verdict: item.verdict,
43493
+ reasoning: item.reasoning,
43494
+ violated: [...item.violatedCriteria]
43495
+ });
43446
43496
  emit({
43447
43497
  type: "story_log",
43448
43498
  id: item.agentId,
@@ -43451,6 +43501,67 @@ var CoordinationForwarder = class extends BaseObserver {
43451
43501
  }
43452
43502
  };
43453
43503
 
43504
+ // ../baro-orchestrator/src/participants/forwarders/dag.ts
43505
+ var DagForwarder = class extends BaseObserver {
43506
+ async onExternalEvent(_source, event) {
43507
+ if (Replan.is(event)) {
43508
+ this.handleReplan(event.data);
43509
+ return;
43510
+ }
43511
+ if (LevelStarted.is(event)) {
43512
+ this.handleLevelStarted(event.data);
43513
+ return;
43514
+ }
43515
+ if (LevelCompleted.is(event)) {
43516
+ this.handleLevelCompleted(event.data);
43517
+ return;
43518
+ }
43519
+ if (RecoveryStarted.is(event)) {
43520
+ this.handleRecoveryStarted(event.data);
43521
+ return;
43522
+ }
43523
+ }
43524
+ handleReplan(item) {
43525
+ emit({
43526
+ type: "replan",
43527
+ source: item.source,
43528
+ reason: item.reason,
43529
+ added: item.addedStories.map((s2) => ({
43530
+ id: s2.id,
43531
+ title: s2.title,
43532
+ depends_on: [...s2.dependsOn]
43533
+ })),
43534
+ removed: [...item.removedStoryIds],
43535
+ rewired: Object.entries(item.modifiedDeps).map(([id, deps]) => ({
43536
+ id,
43537
+ depends_on: [...deps]
43538
+ }))
43539
+ });
43540
+ }
43541
+ handleLevelStarted(item) {
43542
+ emit({
43543
+ type: "level_started",
43544
+ ordinal: item.ordinal,
43545
+ story_ids: [...item.storyIds]
43546
+ });
43547
+ }
43548
+ handleLevelCompleted(item) {
43549
+ emit({
43550
+ type: "level_completed",
43551
+ ordinal: item.ordinal,
43552
+ passed: [...item.passed],
43553
+ failed: [...item.failed]
43554
+ });
43555
+ }
43556
+ handleRecoveryStarted(item) {
43557
+ emit({
43558
+ type: "recovery_started",
43559
+ attempt: item.attempt,
43560
+ story_ids: [...item.storyIds]
43561
+ });
43562
+ }
43563
+ };
43564
+
43454
43565
  // ../baro-orchestrator/src/participants/forwarders/finalization.ts
43455
43566
  var FinalizationForwarder = class extends BaseObserver {
43456
43567
  async onExternalEvent(_source, event) {
@@ -43550,6 +43661,31 @@ var StoryLifecycleForwarder = class extends BaseObserver {
43550
43661
  this.handleStoryResult(event.data);
43551
43662
  return;
43552
43663
  }
43664
+ if (StoryRouted.is(event)) {
43665
+ emit({
43666
+ type: "routed",
43667
+ id: event.data.storyId,
43668
+ backend: event.data.backend,
43669
+ model: event.data.model
43670
+ });
43671
+ return;
43672
+ }
43673
+ if (StoryMerged.is(event)) {
43674
+ emit({
43675
+ type: "story_merged",
43676
+ id: event.data.storyId,
43677
+ mode: event.data.mode
43678
+ });
43679
+ return;
43680
+ }
43681
+ if (StoryMergeFailed.is(event)) {
43682
+ emit({
43683
+ type: "merge_failed",
43684
+ id: event.data.storyId,
43685
+ error: event.data.error
43686
+ });
43687
+ return;
43688
+ }
43553
43689
  }
43554
43690
  // Same signal the Sentry uses: a write/edit tool call from a story
43555
43691
  // agent. We attribute the touched path to that agent's story and
@@ -43721,6 +43857,7 @@ function joinBaroEventForwarders(env) {
43721
43857
  new TokenUsageForwarder(),
43722
43858
  new ProgressForwarder(),
43723
43859
  new CoordinationForwarder(),
43860
+ new DagForwarder(),
43724
43861
  new FinalizationForwarder()
43725
43862
  ];
43726
43863
  for (const f3 of forwarders) f3.join(env);
@@ -44241,7 +44378,7 @@ var Operator = class extends BaseObserver {
44241
44378
  AgentTargetedMessage.create({
44242
44379
  recipientId: cmd.storyId,
44243
44380
  text: cmd.message,
44244
- metadata: { source: "operator" }
44381
+ metadata: { source: cmd.source ?? "operator" }
44245
44382
  })
44246
44383
  );
44247
44384
  return;
@@ -47739,6 +47876,14 @@ var StoryFactory = class extends BaseObserver {
47739
47876
  process.stderr.write(
47740
47877
  `[story-factory] ${req.storyId} \u2192 ${formatRoute(route)}` + (req.model ? ` (model="${req.model}")` : "") + "\n"
47741
47878
  );
47879
+ this.envRef.deliverSemanticEvent(
47880
+ this,
47881
+ StoryRouted.create({
47882
+ storyId: req.storyId,
47883
+ backend: route.backend,
47884
+ model: route.model ?? "default"
47885
+ })
47886
+ );
47742
47887
  const storyCwd = this.opts.worktrees ? await this.opts.worktrees.create(req.storyId) ?? this.opts.cwd : this.opts.cwd;
47743
47888
  const exec3 = this.executor.start(req, route, storyCwd, this.envRef, {
47744
47889
  openaiModel: this.opts.openaiModel,
@@ -48594,6 +48739,7 @@ async function orchestrate(config) {
48594
48739
  const operator = new Operator(config.operatorHooks ?? {});
48595
48740
  operator.setEnvironment(env);
48596
48741
  operator.join(env);
48742
+ config.onOperatorReady?.(operator);
48597
48743
  const useGit = config.withGit ?? await isInsideGitRepo(config.cwd);
48598
48744
  const gitGate = new GitGate();
48599
48745
  let baseSha = null;
@@ -48910,6 +49056,17 @@ function tokenizeForHints(text) {
48910
49056
  return out;
48911
49057
  }
48912
49058
 
49059
+ // ../baro-orchestrator/src/stdin-commands.ts
49060
+ function handleStdinCommand(cmd, ctx) {
49061
+ if (cmd.type !== "agent_message") return;
49062
+ const { id, text } = cmd;
49063
+ if (typeof id !== "string" || !id || typeof text !== "string" || !text.trim()) return;
49064
+ const operator = ctx.getOperator();
49065
+ if (!operator) return;
49066
+ operator.dispatch({ kind: "redirect", storyId: id, message: text, source: "user" });
49067
+ (ctx.emitEvent ?? emit)({ type: "story_log", id, line: `[you \u2192 ${id}] ${text}` });
49068
+ }
49069
+
48913
49070
  // ../baro-orchestrator/scripts/cli.ts
48914
49071
  function parseArgs2(argv) {
48915
49072
  const args = {
@@ -49167,9 +49324,16 @@ async function main() {
49167
49324
  `);
49168
49325
  process.exit(2);
49169
49326
  }
49327
+ let operatorRef = null;
49328
+ subscribeCommands((cmd) => {
49329
+ handleStdinCommand(cmd, { getOperator: () => operatorRef });
49330
+ });
49170
49331
  const config = {
49171
49332
  prdPath,
49172
49333
  cwd,
49334
+ onOperatorReady: (operator) => {
49335
+ operatorRef = operator;
49336
+ },
49173
49337
  parallel: args.parallel,
49174
49338
  timeoutSecs: args.timeout,
49175
49339
  overrideModel: args.model ?? null,