@bunny-agent/runner-cli 0.9.50-release.1 → 0.9.51-beta.1

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.
Files changed (2) hide show
  1. package/dist/bundle.mjs +32 -17
  2. package/package.json +2 -2
package/dist/bundle.mjs CHANGED
@@ -5605,7 +5605,9 @@ function createPiRunner(options = {}) {
5605
5605
  ]
5606
5606
  });
5607
5607
  const eventQueue = [];
5608
- let isComplete = false;
5608
+ let promptSettled = false;
5609
+ let promptError;
5610
+ let finalAgentEnd = void 0;
5609
5611
  let aborted = false;
5610
5612
  let wakeConsumer = null;
5611
5613
  const notify = () => {
@@ -5614,15 +5616,11 @@ function createPiRunner(options = {}) {
5614
5616
  };
5615
5617
  const unsubscribe = session.subscribe((e) => {
5616
5618
  eventQueue.push(e);
5617
- if (e.type === "agent_end") {
5618
- isComplete = true;
5619
- }
5620
5619
  notify();
5621
5620
  });
5622
5621
  const abortSignal = options.abortController?.signal;
5623
5622
  const abortHandler = () => {
5624
5623
  aborted = true;
5625
- isComplete = true;
5626
5624
  void session.abort();
5627
5625
  notify();
5628
5626
  };
@@ -5636,6 +5634,14 @@ function createPiRunner(options = {}) {
5636
5634
  traceRawMessage(cwd, null, true, options.env);
5637
5635
  const promptText = userInput;
5638
5636
  const promptPromise = session.prompt(promptText);
5637
+ void promptPromise.then(() => {
5638
+ promptSettled = true;
5639
+ notify();
5640
+ }, (error) => {
5641
+ promptError = error;
5642
+ promptSettled = true;
5643
+ notify();
5644
+ });
5639
5645
  const streamConverter = new PiAISDKStreamConverter({
5640
5646
  sessionId: session.sessionId,
5641
5647
  model,
@@ -5643,10 +5649,14 @@ function createPiRunner(options = {}) {
5643
5649
  getUsageFromAgentEndMessages,
5644
5650
  getErrorFromAgentEndMessages
5645
5651
  });
5646
- while (!isComplete || eventQueue.length > 0) {
5652
+ while (!promptSettled && !aborted || eventQueue.length > 0) {
5647
5653
  while (eventQueue.length > 0) {
5648
5654
  const event = eventQueue.shift();
5649
5655
  traceRawMessage(cwd, event, false, options.env);
5656
+ if (event.type === "agent_end") {
5657
+ finalAgentEnd = event;
5658
+ continue;
5659
+ }
5650
5660
  const chunks = streamConverter.handleEvent(event, aborted);
5651
5661
  for (const chunk of chunks) {
5652
5662
  yield chunk;
@@ -5658,30 +5668,35 @@ function createPiRunner(options = {}) {
5658
5668
  }
5659
5669
  break;
5660
5670
  }
5661
- if (!isComplete && eventQueue.length === 0) {
5671
+ if (!promptSettled && !aborted && eventQueue.length === 0) {
5662
5672
  await new Promise((resolve4) => {
5663
5673
  wakeConsumer = resolve4;
5664
5674
  });
5665
5675
  }
5666
5676
  }
5667
- if (streamConverter.finished) {
5677
+ if (aborted) {
5668
5678
  return;
5669
5679
  }
5670
- try {
5671
- await promptPromise;
5672
- } catch (error) {
5673
- if (!streamConverter.finished) {
5674
- const message = error instanceof Error ? error.message : "Pi agent run failed.";
5675
- for (const chunk of streamConverter.forceError(message)) {
5676
- yield chunk;
5677
- }
5680
+ if (promptError !== void 0) {
5681
+ const message = promptError instanceof Error ? promptError.message : "Pi agent run failed.";
5682
+ for (const chunk of streamConverter.forceError(message)) {
5683
+ yield chunk;
5678
5684
  }
5679
5685
  return;
5680
5686
  }
5681
- if (!streamConverter.finished && session.agent.state.errorMessage) {
5687
+ if (finalAgentEnd) {
5688
+ const chunks = streamConverter.handleEvent(finalAgentEnd, false);
5689
+ for (const chunk of chunks) {
5690
+ yield chunk;
5691
+ }
5692
+ } else if (session.agent.state.errorMessage) {
5682
5693
  for (const chunk of streamConverter.forceError(session.agent.state.errorMessage)) {
5683
5694
  yield chunk;
5684
5695
  }
5696
+ } else {
5697
+ for (const chunk of streamConverter.forceError("Pi agent run completed without an agent_end event.")) {
5698
+ yield chunk;
5699
+ }
5685
5700
  }
5686
5701
  } finally {
5687
5702
  if (abortSignal) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunny-agent/runner-cli",
3
- "version": "0.9.50-release.1",
3
+ "version": "0.9.51-beta.1",
4
4
  "description": "BunnyAgent Runner CLI - Like gemini-cli or claude-code, runs in your local terminal with AI SDK UI streaming",
5
5
  "type": "module",
6
6
  "bin": {
@@ -53,8 +53,8 @@
53
53
  "esbuild": "^0.27.2",
54
54
  "typescript": "^5.3.0",
55
55
  "vitest": "^1.6.1",
56
- "@bunny-agent/runner-harness": "0.1.1-beta.0",
57
56
  "@bunny-agent/runner-claude": "0.6.2",
57
+ "@bunny-agent/runner-harness": "0.1.1-beta.0",
58
58
  "@bunny-agent/runner-codex": "0.6.2",
59
59
  "@bunny-agent/runner-gemini": "0.6.2",
60
60
  "@bunny-agent/runner-opencode": "0.6.2",