@bunny-agent/runner-cli 0.10.0-beta.1 → 0.10.0-beta.4

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 +132 -5
  2. package/package.json +5 -5
package/dist/bundle.mjs CHANGED
@@ -39586,6 +39586,123 @@ function createOpenCodeRunner(options = {}) {
39586
39586
  });
39587
39587
  }
39588
39588
 
39589
+ // ../../packages/runner-pi/dist/live-control.js
39590
+ import { AsyncLocalStorage } from "node:async_hooks";
39591
+ import { randomBytes as randomBytes2 } from "node:crypto";
39592
+ function createPiLiveController(session, onFirstStreamInvocation) {
39593
+ const originalSteeringMode = session.agent.steeringMode;
39594
+ session.agent.steeringMode = "one-at-a-time";
39595
+ const controllerNonce = randomBytes2(16).toString("hex");
39596
+ const dispatchContext = new AsyncLocalStorage();
39597
+ const dispatches = /* @__PURE__ */ new Map();
39598
+ let consumedCallback;
39599
+ let disposed = false;
39600
+ let firstStreamInvocationReported = false;
39601
+ const reportIfConfirmed = (dispatch) => {
39602
+ if (!disposed && dispatch.outcome === "queued" && dispatch.captured.length === 1 && dispatch.observed && !dispatch.reported) {
39603
+ dispatch.reported = true;
39604
+ consumedCallback?.(dispatch.id);
39605
+ }
39606
+ };
39607
+ const originalAgentSteer = session.agent.steer;
39608
+ const installedAgentSteer = (message) => {
39609
+ const dispatch = dispatchContext.getStore();
39610
+ if (dispatch && message.role === "user") {
39611
+ dispatch.captured.push(message);
39612
+ message.__bunnyLiveControl = {
39613
+ controllerNonce,
39614
+ stableId: dispatch.id
39615
+ };
39616
+ }
39617
+ originalAgentSteer.call(session.agent, message);
39618
+ };
39619
+ session.agent.steer = installedAgentSteer;
39620
+ const originalStreamFunction = session.agent.streamFunction;
39621
+ const wrappedStreamFunction = (model, context, streamOptions) => {
39622
+ const observed = /* @__PURE__ */ new Set();
39623
+ const sanitizedMessages = context.messages.map((candidate) => {
39624
+ if (!Object.getOwnPropertyDescriptor(candidate, "__bunnyLiveControl"))
39625
+ return candidate;
39626
+ const { __bunnyLiveControl: marker, ...rest } = candidate;
39627
+ if (marker && marker.controllerNonce === controllerNonce && candidate.role === "user") {
39628
+ const dispatch = dispatches.get(marker.stableId);
39629
+ if (dispatch)
39630
+ observed.add(dispatch);
39631
+ }
39632
+ return rest;
39633
+ });
39634
+ const providerContext = {
39635
+ ...context,
39636
+ messages: sanitizedMessages
39637
+ };
39638
+ const result = originalStreamFunction.call(session.agent, model, providerContext, streamOptions);
39639
+ return Promise.resolve(result).then((stream) => {
39640
+ if (!disposed && !firstStreamInvocationReported) {
39641
+ firstStreamInvocationReported = true;
39642
+ onFirstStreamInvocation?.();
39643
+ }
39644
+ for (const dispatch of observed) {
39645
+ dispatch.observed = true;
39646
+ reportIfConfirmed(dispatch);
39647
+ }
39648
+ return stream;
39649
+ });
39650
+ };
39651
+ session.agent.streamFunction = wrappedStreamFunction;
39652
+ return {
39653
+ async steer(message) {
39654
+ if (disposed)
39655
+ return { disposition: "rejected", reason: "controller disposed" };
39656
+ if (dispatches.has(message.id)) {
39657
+ return {
39658
+ disposition: "rejected",
39659
+ reason: "message id already dispatched"
39660
+ };
39661
+ }
39662
+ const dispatch = {
39663
+ id: message.id,
39664
+ captured: [],
39665
+ observed: false,
39666
+ reported: false
39667
+ };
39668
+ dispatches.set(message.id, dispatch);
39669
+ const images = message.images?.map((image) => ({
39670
+ type: "image",
39671
+ data: image.data,
39672
+ mimeType: image.mimeType
39673
+ }));
39674
+ try {
39675
+ dispatch.outcome = await dispatchContext.run(dispatch, () => session.steer(message.text, images?.length ? images : void 0));
39676
+ } catch (error109) {
39677
+ if (dispatch.captured.length > 0)
39678
+ throw error109;
39679
+ return {
39680
+ disposition: "rejected",
39681
+ reason: error109 instanceof Error ? error109.message : String(error109)
39682
+ };
39683
+ }
39684
+ if (dispatch.outcome === "handled")
39685
+ return { disposition: "handled" };
39686
+ reportIfConfirmed(dispatch);
39687
+ return { disposition: "queued" };
39688
+ },
39689
+ onConsumed(callback) {
39690
+ consumedCallback = callback;
39691
+ },
39692
+ dispose() {
39693
+ if (disposed)
39694
+ return;
39695
+ disposed = true;
39696
+ if (session.agent.steer === installedAgentSteer)
39697
+ session.agent.steer = originalAgentSteer;
39698
+ if (session.agent.streamFunction === wrappedStreamFunction)
39699
+ session.agent.streamFunction = originalStreamFunction;
39700
+ session.agent.steeringMode = originalSteeringMode;
39701
+ dispatches.clear();
39702
+ }
39703
+ };
39704
+ }
39705
+
39589
39706
  // ../../packages/runner-pi/dist/mcp-config.js
39590
39707
  import { createJiti } from "jiti";
39591
39708
  var MAX_SERVERS = 50;
@@ -40245,7 +40362,7 @@ var SourceRegistry = class {
40245
40362
  }
40246
40363
  }
40247
40364
  register(source, toolCallIds = [], save = true, restoredReferences) {
40248
- if (toolCallIds.some((id) => typeof id !== "string" || id.trim().length === 0 || id.length > 1024)) {
40365
+ if (toolCallIds.some((id) => typeof id !== "string" || id.trim().length === 0)) {
40249
40366
  this.diagnose("invalid_version", "Rejected malformed source provenance.");
40250
40367
  return void 0;
40251
40368
  }
@@ -40339,7 +40456,7 @@ function isRegisteredSource(value) {
40339
40456
  if (!isWebSearchSource(value))
40340
40457
  return false;
40341
40458
  const entry = value;
40342
- return deriveSourceId(entry.url) === entry.source_id && (entry.references === void 0 || typeof entry.references === "object" && entry.references !== null && Object.keys(entry.references).length <= 50 && Object.entries(entry.references).every(([ref, call]) => ref.length <= 64 && /^turn\d+url\d+$/.test(ref) && Number.isSafeInteger(Number(/^turn(\d+)/.exec(ref)?.[1])) && Number.isSafeInteger(Number(/url(\d+)$/.exec(ref)?.[1])) && typeof call === "string" && Array.isArray(entry.tool_call_ids) && entry.tool_call_ids.includes(call))) && Array.isArray(entry.tool_call_ids) && entry.tool_call_ids.length <= 50 && entry.tool_call_ids.every((id) => typeof id === "string" && id.trim().length > 0 && id.length <= 1024);
40459
+ return deriveSourceId(entry.url) === entry.source_id && (entry.references === void 0 || typeof entry.references === "object" && entry.references !== null && Object.keys(entry.references).length <= 50 && Object.entries(entry.references).every(([ref, call]) => ref.length <= 64 && /^turn\d+url\d+$/.test(ref) && Number.isSafeInteger(Number(/^turn(\d+)/.exec(ref)?.[1])) && Number.isSafeInteger(Number(/url(\d+)$/.exec(ref)?.[1])) && typeof call === "string" && Array.isArray(entry.tool_call_ids) && entry.tool_call_ids.includes(call))) && Array.isArray(entry.tool_call_ids) && entry.tool_call_ids.length <= 50 && entry.tool_call_ids.every((id) => typeof id === "string" && id.trim().length > 0);
40343
40460
  }
40344
40461
 
40345
40462
  // ../../packages/runner-pi/dist/citation-session-cache.js
@@ -40357,7 +40474,7 @@ function sourcesFromEntry(value) {
40357
40474
  const record3 = entry.message?.details?.web_search;
40358
40475
  if (entry.type === "message" && entry.message?.role === "toolResult" && !entry.message.isError && isValidWebSearchCallRecord(record3) && record3.status === "completed") {
40359
40476
  const callId = entry.message.toolCallId;
40360
- if (typeof callId !== "string" || callId.trim().length === 0 || callId.length > 1024)
40477
+ if (typeof callId !== "string" || callId.trim().length === 0)
40361
40478
  return [];
40362
40479
  return record3.action.sources.map((source) => ({
40363
40480
  ...source,
@@ -40469,7 +40586,7 @@ function createCitationSessionRegistry(store, enabled) {
40469
40586
  const entry = value;
40470
40587
  if (entry.type === "custom" && entry.customType === CITATION_CACHE_TYPE && entry.data?.schema_version === 1 && Array.isArray(entry.data.calls)) {
40471
40588
  for (const call of entry.data.calls.slice(0, 50)) {
40472
- if (call && typeof call.id === "string" && call.id.trim().length > 0 && call.id.length <= 1024 && Number.isSafeInteger(call.turn) && call.turn >= 0)
40589
+ if (call && typeof call.id === "string" && call.id.trim().length > 0 && Number.isSafeInteger(call.turn) && call.turn >= 0)
40473
40590
  registry3.reserveSearch(call.id, call.turn);
40474
40591
  }
40475
40592
  }
@@ -45818,6 +45935,14 @@ function createPiRunner(options = {}) {
45818
45935
  wakeConsumer?.();
45819
45936
  wakeConsumer = null;
45820
45937
  };
45938
+ let liveControlRegistered = false;
45939
+ const registerLiveControl = options.liveControl;
45940
+ const liveController = registerLiveControl ? createPiLiveController(session, () => {
45941
+ if (liveControlRegistered)
45942
+ return;
45943
+ liveControlRegistered = true;
45944
+ registerLiveControl(liveController);
45945
+ }) : void 0;
45821
45946
  const unsubscribe = session.subscribe((e) => {
45822
45947
  eventQueue.push(e);
45823
45948
  notify();
@@ -45915,6 +46040,7 @@ function createPiRunner(options = {}) {
45915
46040
  if (abortSignal) {
45916
46041
  abortSignal.removeEventListener("abort", abortHandler);
45917
46042
  }
46043
+ liveController?.dispose();
45918
46044
  unsubscribe();
45919
46045
  await disposePiSession(session);
45920
46046
  }
@@ -46119,7 +46245,8 @@ function dispatchRunner(runner, base, cwd, options, input2) {
46119
46245
  mcpConfig: options.mcpConfig,
46120
46246
  effort: options.effort,
46121
46247
  systemEnv: options.systemEnv,
46122
- searchContractVersion: options.searchContractVersion
46248
+ searchContractVersion: options.searchContractVersion,
46249
+ liveControl: options.liveControl
46123
46250
  }).run(hasStructuredInput ? input2 : compiled.text);
46124
46251
  }
46125
46252
  case "opencode":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunny-agent/runner-cli",
3
- "version": "0.10.0-beta.1",
3
+ "version": "0.10.0-beta.4",
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": {
@@ -59,16 +59,16 @@
59
59
  "esbuild": "^0.27.2",
60
60
  "typescript": "^5.3.0",
61
61
  "vitest": "^1.6.1",
62
+ "@bunny-agent/apply-patch": "0.1.0",
62
63
  "@bunny-agent/runner-claude": "0.6.2",
63
- "@bunny-agent/runner-codex": "0.6.2",
64
64
  "@bunny-agent/runner-copilot": "0.1.0",
65
- "@bunny-agent/manager": "0.10.0-beta.1",
66
65
  "@bunny-agent/runner-gemini": "0.6.2",
67
- "@bunny-agent/apply-patch": "0.1.0",
68
66
  "@bunny-agent/runner-harness": "0.1.1-beta.0",
67
+ "@bunny-agent/runner-opencode": "0.6.2",
69
68
  "@bunny-agent/runner-pi": "0.6.4-beta.0",
70
69
  "@bunny-agent/server-acp": "0.1.0",
71
- "@bunny-agent/runner-opencode": "0.6.2"
70
+ "@bunny-agent/manager": "0.10.0-beta.4",
71
+ "@bunny-agent/runner-codex": "0.6.2"
72
72
  },
73
73
  "scripts": {
74
74
  "build": "tsc && pnpm bundle",