@bivy/bivy 0.16.25-staging.2 → 0.16.25-staging.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.
@@ -193,7 +193,10 @@
193
193
  "certification": "release-tested",
194
194
  "testedVersion": "1.0.0",
195
195
  "headlessFlags": [
196
+ "--always-approve",
196
197
  "-p",
198
+ "--output-format",
199
+ "streaming-json",
197
200
  "--resume"
198
201
  ],
199
202
  "install": {
@@ -370,19 +370,28 @@ export const AGENT_PROFILES = {
370
370
  // UUID (sessions live under ~/.grok/sessions/<cwd>/<id>/). The interactive
371
371
  // TUI uses the same store via `grok --resume <id>`. Model ids match
372
372
  // `grok models` for the official CLI (override with BIVY_GROK_MODELS).
373
- args: ["-p"],
374
- // The current CLI's `--output-format streaming-json` emits newline-delimited
375
- // JSON keyed off `type`: {type:"text",data} for the answer, {type:"thought",
376
- // data} for reasoning, {type:"end"} to close the turn (plus tool frames). The
377
- // shared tolerant generic-stream-json parser understands this shape (and the
378
- // ACP session/update envelope other CLIs use), so Grok gets faithful
379
- // transcripts answer prose, a thinking sidecar, and tool cards — without a
380
- // Grok-specific adapter. Keep the plain args as the explicit
381
- // BIVY_AGENT_STRUCTURED=0 fallback.
382
- jsonArgs: ["--output-format", "streaming-json", "-p"],
373
+ // `--always-approve` auto-approves every tool execution. Without it, Grok's
374
+ // headless `-p` turn emits a tool_call and then waits for the client to
375
+ // approve it over the streaming-json (ACP) channel; Bivy governs effects at
376
+ // the sandbox tier and closes stdin, so the pending call races to a "User
377
+ // cancelled the execution" i.e. Grok could never actually run a tool under
378
+ // Bivy. The flag is the Grok analogue of Cursor's `--force`, Copilot's
379
+ // `--allow-all-tools`, Droid's `--auto`, etc.
380
+ args: ["--always-approve", "-p"],
381
+ // The current CLI's `--output-format streaming-json` emits NDJSON of the
382
+ // agent-native ACP session updates: assistant text, a {type:"thought"}
383
+ // reasoning sidecar, and tool_call/tool_call_update frames. The shared
384
+ // tolerant generic-stream-json parser understands this shape (and the ACP
385
+ // session/update envelope other CLIs use), so Grok gets faithful transcripts
386
+ // — answer prose, a thinking sidecar, and tool cards — without a Grok-specific
387
+ // adapter. Keep the plain args as the explicit BIVY_AGENT_STRUCTURED=0
388
+ // fallback.
389
+ jsonArgs: ["--output-format", "streaming-json", "--always-approve", "-p"],
383
390
  parserId: "generic-stream-json",
391
+ // Resume mirrors the fresh-launch recipe (structured output + auto-approve)
392
+ // so a continued turn streams and runs tools exactly like the first one.
384
393
  resume: {
385
- template: ["--resume", "{id}", "-p"],
394
+ template: ["--output-format", "streaming-json", "--resume", "{id}", "--always-approve", "-p"],
386
395
  historyLoader: "grok",
387
396
  },
388
397
  model: {
@@ -369,8 +369,14 @@ class ProcessSession {
369
369
  this.nativeSessionRef = learnedRef;
370
370
  this.upstreamSessionStarted = true;
371
371
  }
372
- for (const event of events)
373
- this.emit(event);
372
+ // Sync the parser's final transcript into this.messages BEFORE emitting the
373
+ // terminal events (message_end/turn_end/agent_end). The daemon persists a
374
+ // base-transcript snapshot synchronously on message_end/turn_end by reading
375
+ // getMessages() — so if the push happened after the emit loop (as it once
376
+ // did), that snapshot saw an empty turn and the agent's answer + paired
377
+ // tool blocks were never persisted, vanishing on reload for every
378
+ // structured-pipe CLI (Grok, Goose, Gemini, …). Populating first makes
379
+ // getMessages() authoritative the instant message_end fires.
374
380
  if (!messagesPushed && events.some((e) => e.type === "agent_end")) {
375
381
  messagesPushed = true;
376
382
  for (const message of activeParser.messages())
@@ -381,6 +387,8 @@ class ProcessSession {
381
387
  if (usage)
382
388
  this.lastUsage = usage;
383
389
  }
390
+ for (const event of events)
391
+ this.emit(event);
384
392
  };
385
393
  const feedParser = (activeParser, text) => {
386
394
  lineBuf += text;
@@ -31,7 +31,15 @@ function capThinkingForPersistence(text) {
31
31
  function toolEventId(event) {
32
32
  const toolCall = event.toolCall;
33
33
  const input = (event.input || event.toolInput || event.args || toolCall?.input || {});
34
- const explicit = event.toolUseId || event.tool_use_id || event.toolCallId || event.callId || event.id || toolCall?.id;
34
+ // Structured-pipe parsers (Grok/Goose/Gemini/… via the shared TurnAccumulator)
35
+ // emit a `tool_result` whose id lives under `result.toolCallId`, not at the top
36
+ // level. Without reading it here the result overlay was keyed `"<name>:"` and
37
+ // never paired with its `tool_call` overlay — orphaning the output in the
38
+ // transcript. Check the nested result id as a general shape, not a per-agent
39
+ // branch (protocol agents that already set a top-level id are unaffected).
40
+ const result = (event.result || event.toolResult);
41
+ const explicit = event.toolUseId || event.tool_use_id || event.toolCallId || event.callId || event.id || toolCall?.id ||
42
+ result?.toolCallId || result?.tool_use_id || result?.toolUseId || result?.id;
35
43
  if (explicit)
36
44
  return String(explicit);
37
45
  return `${String(event.toolName || event.name || toolCall?.name || "tool")}:${String(input.path || input.file || input.filePath || input.command || input.cmd || input.query || "")}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bivy/bivy",
3
- "version": "0.16.25-staging.2",
3
+ "version": "0.16.25-staging.4",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0-only",
6
6
  "description": "Run coding agents on machines you own. Open-source, self-hostable agent workspace.",