baro-ai 0.52.0 → 0.54.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
@@ -47302,19 +47302,74 @@ function raceWithTimeout4(p, ms, label) {
47302
47302
  ]);
47303
47303
  }
47304
47304
 
47305
+ // ../baro-orchestrator/src/participants/story-executor.ts
47306
+ var LocalStoryExecutor = class {
47307
+ start(req, route, cwd, env, opts) {
47308
+ const agent = route.backend === "pi" ? new PiStoryAgent({
47309
+ id: req.storyId,
47310
+ prompt: req.prompt,
47311
+ cwd,
47312
+ model: route.model,
47313
+ retries: req.retries,
47314
+ timeoutSecs: req.timeoutSecs
47315
+ }) : route.backend === "opencode" ? new OpenCodeStoryAgent({
47316
+ id: req.storyId,
47317
+ prompt: req.prompt,
47318
+ cwd,
47319
+ model: route.model,
47320
+ retries: req.retries,
47321
+ timeoutSecs: req.timeoutSecs
47322
+ }) : route.backend === "codex" ? new CodexStoryAgent({
47323
+ id: req.storyId,
47324
+ prompt: req.prompt,
47325
+ cwd,
47326
+ // undefined → let Codex pick its account default.
47327
+ model: route.model,
47328
+ retries: req.retries,
47329
+ timeoutSecs: req.timeoutSecs
47330
+ }) : route.backend === "openai" ? new OpenAIStoryAgent(
47331
+ {
47332
+ id: req.storyId,
47333
+ prompt: req.prompt,
47334
+ cwd,
47335
+ model: route.model,
47336
+ retries: req.retries,
47337
+ timeoutSecs: req.timeoutSecs
47338
+ },
47339
+ {
47340
+ model: route.model ?? opts.openaiModel,
47341
+ baseUrl: route.baseUrl,
47342
+ apiKey: route.apiKey
47343
+ }
47344
+ ) : new StoryAgent({
47345
+ id: req.storyId,
47346
+ prompt: req.prompt,
47347
+ cwd,
47348
+ // undefined → StoryAgent applies its own default.
47349
+ model: route.model,
47350
+ effort: opts.effort,
47351
+ retries: req.retries,
47352
+ timeoutSecs: req.timeoutSecs
47353
+ });
47354
+ agent.join(env);
47355
+ void agent.run(env);
47356
+ return { dispose: (e2) => agent.leave(e2) };
47357
+ }
47358
+ };
47359
+
47305
47360
  // ../baro-orchestrator/src/participants/story-factory.ts
47306
47361
  var StoryFactory = class extends BaseObserver {
47307
47362
  constructor(opts) {
47308
47363
  super();
47309
47364
  this.opts = opts;
47365
+ this.executor = opts.executor ?? new LocalStoryExecutor();
47310
47366
  }
47311
- // Typed as BaroEnvironment because StoryAgent.run() / join() still
47312
- // expect the old environment type. Once StoryAgent migrates, this
47313
- // narrows to vanilla AgenticEnvironment.
47367
+ /** The bus environment, wired in before any spawn; passed to the executor. */
47314
47368
  envRef = null;
47315
47369
  active = /* @__PURE__ */ new Map();
47316
47370
  /** Story ids whose spawn is in progress (closes the await-create window). */
47317
47371
  spawning = /* @__PURE__ */ new Set();
47372
+ executor;
47318
47373
  setEnvironment(env) {
47319
47374
  this.envRef = env;
47320
47375
  }
@@ -47324,9 +47379,9 @@ var StoryFactory = class extends BaseObserver {
47324
47379
  return;
47325
47380
  }
47326
47381
  if (StoryResult.is(event)) {
47327
- const agent = this.active.get(event.data.storyId);
47328
- if (agent && this.envRef) {
47329
- agent.leave(this.envRef);
47382
+ const exec3 = this.active.get(event.data.storyId);
47383
+ if (exec3 && this.envRef) {
47384
+ exec3.dispose(this.envRef);
47330
47385
  this.active.delete(event.data.storyId);
47331
47386
  }
47332
47387
  }
@@ -47355,55 +47410,11 @@ var StoryFactory = class extends BaseObserver {
47355
47410
  `[story-factory] ${req.storyId} \u2192 ${formatRoute(route)}` + (req.model ? ` (model="${req.model}")` : "") + "\n"
47356
47411
  );
47357
47412
  const storyCwd = this.opts.worktrees ? await this.opts.worktrees.create(req.storyId) ?? this.opts.cwd : this.opts.cwd;
47358
- const agent = route.backend === "pi" ? new PiStoryAgent({
47359
- id: req.storyId,
47360
- prompt: req.prompt,
47361
- cwd: storyCwd,
47362
- model: route.model,
47363
- retries: req.retries,
47364
- timeoutSecs: req.timeoutSecs
47365
- }) : route.backend === "opencode" ? new OpenCodeStoryAgent({
47366
- id: req.storyId,
47367
- prompt: req.prompt,
47368
- cwd: storyCwd,
47369
- model: route.model,
47370
- retries: req.retries,
47371
- timeoutSecs: req.timeoutSecs
47372
- }) : route.backend === "codex" ? new CodexStoryAgent({
47373
- id: req.storyId,
47374
- prompt: req.prompt,
47375
- cwd: storyCwd,
47376
- // undefined → let Codex pick its account default.
47377
- model: route.model,
47378
- retries: req.retries,
47379
- timeoutSecs: req.timeoutSecs
47380
- }) : route.backend === "openai" ? new OpenAIStoryAgent(
47381
- {
47382
- id: req.storyId,
47383
- prompt: req.prompt,
47384
- cwd: storyCwd,
47385
- model: route.model,
47386
- retries: req.retries,
47387
- timeoutSecs: req.timeoutSecs
47388
- },
47389
- {
47390
- model: route.model ?? this.opts.openaiModel,
47391
- baseUrl: route.baseUrl,
47392
- apiKey: route.apiKey
47393
- }
47394
- ) : new StoryAgent({
47395
- id: req.storyId,
47396
- prompt: req.prompt,
47397
- cwd: storyCwd,
47398
- // undefined → StoryAgent applies its own default.
47399
- model: route.model,
47400
- effort: this.opts.effort,
47401
- retries: req.retries,
47402
- timeoutSecs: req.timeoutSecs
47413
+ const exec3 = this.executor.start(req, route, storyCwd, this.envRef, {
47414
+ openaiModel: this.opts.openaiModel,
47415
+ effort: this.opts.effort
47403
47416
  });
47404
- agent.join(this.envRef);
47405
- this.active.set(req.storyId, agent);
47406
- void agent.run(this.envRef);
47417
+ this.active.set(req.storyId, exec3);
47407
47418
  this.envRef.deliverSemanticEvent(
47408
47419
  this,
47409
47420
  StorySpawned.create({ storyId: req.storyId })
@@ -48294,7 +48305,8 @@ async function orchestrate(config) {
48294
48305
  effort: config.effort,
48295
48306
  tierMap: config.tierMap,
48296
48307
  endpoints: config.openaiEndpoints,
48297
- defaultApiKey: process.env.OPENAI_API_KEY
48308
+ defaultApiKey: process.env.OPENAI_API_KEY,
48309
+ executor: config.executor
48298
48310
  });
48299
48311
  storyFactory.setEnvironment(env);
48300
48312
  storyFactory.join(env);