@runuai/host 0.8.41 → 0.8.43

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.
@@ -367,6 +367,11 @@ export class OpencodeSession implements AgentSession {
367
367
 
368
368
  let turnUsage: AgentUsage = {};
369
369
  let sawUsage = false;
370
+ // Whether the JSON stream already surfaced an error this turn. `opencode
371
+ // run` reports a provider/gateway failure as a `{type:"error"}` event AND
372
+ // then exits 1 — without this we'd double-report one failure (e.g.
373
+ // "Unexpected server error" followed by a bare "opencode exited 1").
374
+ let sawError = false;
370
375
  let buf = "";
371
376
  const consume = (chunk: string): void => {
372
377
  buf += chunk;
@@ -380,7 +385,10 @@ export class OpencodeSession implements AgentSession {
380
385
  turnUsage = addUsage(turnUsage, usage);
381
386
  sawUsage = true;
382
387
  }
383
- for (const e of events) this.emit(e);
388
+ for (const e of events) {
389
+ if (e.type === "error") sawError = true;
390
+ this.emit(e);
391
+ }
384
392
  }
385
393
  };
386
394
  child.stdout?.on("data", (b: Buffer) => consume(b.toString("utf8")));
@@ -394,7 +402,10 @@ export class OpencodeSession implements AgentSession {
394
402
  this.current = null;
395
403
  if (buf.trim().length > 0) consume("\n"); // flush a trailing line
396
404
  if (!this.closed) {
397
- if (code !== 0) {
405
+ // Only surface the bare exit code when the stream didn't already
406
+ // explain the failure (see sawError) — otherwise it's a redundant
407
+ // second error card for the same turn.
408
+ if (code !== 0 && !sawError) {
398
409
  const tail = stderr.trim().slice(-500);
399
410
  const message = `opencode exited ${code ?? "null"}${tail ? `: ${tail}` : ""}`;
400
411
  this.emit(