@burdenoff/fe-libs 2026.1117.8 → 2026.1118.2

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.
@@ -2,13 +2,14 @@ import { describePermissionError as e, permissionRefusalCopyId as t } from "./pe
2
2
  import { describeQuotaError as n, extensionObjectsIn as r } from "./quota.js";
3
3
  import { assistantLlmTerminalCodeOf as i } from "./sandboxProxyError.js";
4
4
  import { TURN_OUTCOME_COPY as a } from "./turnOutcomeCopy.js";
5
+ import { AssistantTurnStalled as o } from "./turnStall.js";
5
6
  // src/shared/assistant/turnOutcome.ts
6
- var o = class extends Error {
7
+ var s = class extends Error {
7
8
  reason;
8
9
  constructor(e, t) {
9
10
  super(t), this.name = "AssistantSendRefusal", this.reason = e;
10
11
  }
11
- }, s = {
12
+ }, c = {
12
13
  "confirm-write-mode": {
13
14
  kind: "confirmation",
14
15
  copy: "confirmWriteMode"
@@ -38,10 +39,10 @@ var o = class extends Error {
38
39
  copy: "usageNotRecorded"
39
40
  }
40
41
  };
41
- function c(e) {
42
+ function l(e) {
42
43
  return e === null ? null : Number.isFinite(Date.parse(e)) ? e : null;
43
44
  }
44
- function l(e, t) {
45
+ function u(e, t) {
45
46
  if (!t) return "usageDailyLimitReachedUnknownTime";
46
47
  switch (e) {
47
48
  case "assistant.llm.actor_daily": return "usageDailyLimitReached";
@@ -49,92 +50,99 @@ function l(e, t) {
49
50
  default: return "usageDailyLimitReachedPlatform";
50
51
  }
51
52
  }
52
- function u(e, t) {
53
+ function d(e, t) {
53
54
  for (let n of r(e)) {
54
55
  let e = n[t];
55
56
  if (typeof e == "string" && e.length > 0) return e;
56
57
  }
57
58
  return null;
58
59
  }
59
- function d({ mode: e, capabilities: t }) {
60
+ function f({ mode: e, capabilities: t }) {
60
61
  return e === "assistant" || t?.proposals === !0 && t.writeApprovalMode === "proposal-v1";
61
62
  }
62
- function f(r, a = {}) {
63
- let d = u(r, "traceId");
63
+ function p(r, a = {}) {
64
+ let f = d(r, "traceId");
65
+ if (r instanceof s) return {
66
+ ...c[r.reason],
67
+ offersUpgrade: !1,
68
+ quotaName: null,
69
+ traceId: null
70
+ };
64
71
  if (r instanceof o) return {
65
- ...s[r.reason],
72
+ kind: "temporary",
73
+ copy: r.reason === "noOutput" ? "noOutputInTime" : "modelUnavailable",
66
74
  offersUpgrade: !1,
67
75
  quotaName: null,
68
76
  traceId: null
69
77
  };
70
- let f = n(r);
71
- if (f?.refusal === "daily-limit") {
72
- let e = c(f.resetsAt);
78
+ let p = n(r);
79
+ if (p?.refusal === "daily-limit") {
80
+ let e = l(p.resetsAt);
73
81
  return {
74
82
  kind: "usage",
75
- copy: l(f.quotaName, e !== null),
83
+ copy: u(p.quotaName, e !== null),
76
84
  offersUpgrade: !1,
77
- quotaName: f.quotaName,
78
- traceId: f.traceId ?? d,
85
+ quotaName: p.quotaName,
86
+ traceId: p.traceId ?? f,
79
87
  ...e === null ? {} : { resetsAt: e }
80
88
  };
81
89
  }
82
- if (f) return {
90
+ if (p) return {
83
91
  kind: "usage",
84
- copy: f.refusal === "exhausted" ? "usageAllowanceReached" : "usageNotProvisioned",
85
- offersUpgrade: f.refusal === "exhausted",
86
- quotaName: f.quotaName,
87
- traceId: f.traceId ?? d
92
+ copy: p.refusal === "exhausted" ? "usageAllowanceReached" : "usageNotProvisioned",
93
+ offersUpgrade: p.refusal === "exhausted",
94
+ quotaName: p.quotaName,
95
+ traceId: p.traceId ?? f
88
96
  };
89
- let p = i(r);
90
- if (p === "ASSISTANT_CONVERSATION_TOO_LONG") return {
97
+ let m = i(r);
98
+ if (m === "ASSISTANT_CONVERSATION_TOO_LONG") return {
91
99
  kind: "temporary",
92
100
  copy: "conversationTooLong",
93
101
  offersUpgrade: !1,
94
102
  quotaName: null,
95
- traceId: d
103
+ traceId: f
96
104
  };
97
- let m = p === null ? e(r) : null;
98
- return m ? {
105
+ let h = m === null ? e(r) : null;
106
+ return h ? {
99
107
  kind: "permission",
100
- copy: t(m.refusal),
108
+ copy: t(h.refusal),
101
109
  offersUpgrade: !1,
102
110
  quotaName: null,
103
- traceId: d
111
+ traceId: f
104
112
  } : {
105
113
  kind: "temporary",
106
114
  copy: a.confirmsNoAction === !0 ? "temporaryNotConfirmed" : "temporary",
107
115
  offersUpgrade: !1,
108
116
  quotaName: null,
109
- traceId: d
117
+ traceId: f
110
118
  };
111
119
  }
112
- var p = {
120
+ var m = {
113
121
  hour: "numeric",
114
122
  minute: "2-digit",
115
123
  timeZoneName: "short"
116
124
  };
117
- function m(e, t) {
125
+ function h(e, t) {
118
126
  let n = Date.parse(e);
119
127
  if (!Number.isFinite(n)) return null;
120
128
  try {
121
- return new Intl.DateTimeFormat(t, p).format(n);
129
+ return new Intl.DateTimeFormat(t, m).format(n);
122
130
  } catch {
123
- return new Intl.DateTimeFormat("en", p).format(n);
131
+ return new Intl.DateTimeFormat("en", m).format(n);
124
132
  }
125
133
  }
126
- function h(e) {
134
+ function g(e) {
127
135
  return e && /^en(?:-|$)/i.test(e) ? e : "en";
128
136
  }
129
- function g(e, t) {
137
+ function _(e, t) {
130
138
  return t ? e.replace(/\{\{(\w+)\}\}/g, (e, n) => t[n] ?? e) : e;
131
139
  }
132
- function _(e, t, n = {}) {
133
- let r = e.resetsAt ? m(e.resetsAt, n.locale) : null, i = e.resetsAt ? m(e.resetsAt, h(n.locale)) : null, o = r === null && a[e.copy].fallback.includes("{{time}}") ? "usageDailyLimitReachedUnknownTime" : e.copy, s = a[o], c = r === null ? void 0 : { time: r }, l = t(s.key, s.fallback, c), u = g(s.fallback, i === null ? void 0 : { time: i }), d = a.reference, f = e.traceId ? d.fallback.replace("{{id}}", e.traceId) : null, p = e.traceId ? t(d.key, d.fallback, { id: e.traceId }) : null, _ = l !== g(s.fallback, c) && (p === null || p !== f), v = _ ? l : u, y = _ ? p : f;
140
+ function v(e, t, n = {}) {
141
+ let r = e.resetsAt ? h(e.resetsAt, n.locale) : null, i = e.resetsAt ? h(e.resetsAt, g(n.locale)) : null, o = r === null && a[e.copy].fallback.includes("{{time}}") ? "usageDailyLimitReachedUnknownTime" : e.copy, s = a[o], c = r === null ? void 0 : { time: r }, l = t(s.key, s.fallback, c), u = _(s.fallback, i === null ? void 0 : { time: i }), d = a.reference, f = e.traceId ? d.fallback.replace("{{id}}", e.traceId) : null, p = e.traceId ? t(d.key, d.fallback, { id: e.traceId }) : null, m = l !== _(s.fallback, c) && (p === null || p !== f), v = m ? l : u, y = m ? p : f;
134
142
  return {
135
143
  text: y ? `${v}\n\n${y}` : v,
136
144
  headline: v,
137
- translated: _
145
+ translated: m
138
146
  };
139
147
  }
140
- export { o as AssistantSendRefusal, f as classifyTurnFailure, m as formatDailyLimitResetTime, d as turnConfirmsNoAction, _ as turnOutcomeCopy };
148
+ export { s as AssistantSendRefusal, p as classifyTurnFailure, h as formatDailyLimitResetTime, f as turnConfirmsNoAction, v as turnOutcomeCopy };
@@ -95,6 +95,14 @@ export declare const TURN_OUTCOME_COPY: {
95
95
  readonly key: "outcome.temporaryNotConfirmed";
96
96
  readonly fallback: "The assistant couldn't finish this just now, and no action was confirmed. It's a temporary problem on our side — not your plan or your access. Try again in a moment.";
97
97
  };
98
+ readonly modelUnavailable: {
99
+ readonly key: "outcome.modelUnavailable";
100
+ readonly fallback: "The assistant's AI model couldn't answer just now. It's a temporary problem on our side — not your plan or your access. Try again in a moment.";
101
+ };
102
+ readonly noOutputInTime: {
103
+ readonly key: "outcome.noOutputInTime";
104
+ readonly fallback: "The assistant didn't start answering within a minute, so it stopped waiting. It's a temporary problem on our side — not your plan or your access. Try again in a moment.";
105
+ };
98
106
  readonly conversationTooLong: {
99
107
  readonly key: "outcome.conversationTooLong";
100
108
  readonly fallback: "This conversation is too long for the assistant. Start a new conversation to continue.";
@@ -72,6 +72,14 @@ var e = {
72
72
  key: "outcome.temporaryNotConfirmed",
73
73
  fallback: "The assistant couldn't finish this just now, and no action was confirmed. It's a temporary problem on our side — not your plan or your access. Try again in a moment."
74
74
  },
75
+ modelUnavailable: {
76
+ key: "outcome.modelUnavailable",
77
+ fallback: "The assistant's AI model couldn't answer just now. It's a temporary problem on our side — not your plan or your access. Try again in a moment."
78
+ },
79
+ noOutputInTime: {
80
+ key: "outcome.noOutputInTime",
81
+ fallback: "The assistant didn't start answering within a minute, so it stopped waiting. It's a temporary problem on our side — not your plan or your access. Try again in a moment."
82
+ },
75
83
  conversationTooLong: {
76
84
  key: "outcome.conversationTooLong",
77
85
  fallback: "This conversation is too long for the assistant. Start a new conversation to continue."
@@ -47,6 +47,24 @@ export interface AssistantTurnProgress {
47
47
  model?: string;
48
48
  /** A write the sandbox refused pending approval, if this turn produced one. */
49
49
  pendingWrite?: PendingWrite;
50
+ /**
51
+ * ★ BOFF-13499: the run ENDED on an error and produced nothing to show — the
52
+ * model's step completed with `info.error` (a provider outage, an overload
53
+ * past opencode's retries, a refused key, an interrupted step). Without this
54
+ * the turn was neither done (nothing renderable) nor failing, so the panel
55
+ * polled the finished, empty turn until its whole budget ran out: 180 s, or
56
+ * 420 s for BigConsole Build, with nothing on screen. The poll ends the turn
57
+ * on it once the sandbox no longer reports the session busy (a failover may
58
+ * still be resuming the run on another model).
59
+ */
60
+ failure?: AssistantTurnFailure;
61
+ }
62
+ /** Why the run ended without an answer (`AssistantTurnProgress.failure`). */
63
+ export interface AssistantTurnFailure {
64
+ /** The bridge's error name (`APIError`, `MessageAbortedError`, …); `UnknownError` when unnamed. */
65
+ name: string;
66
+ /** The provider's HTTP status, when the error carries one. */
67
+ statusCode?: number;
50
68
  }
51
69
  /**
52
70
  * Reduce one poll's session messages to this turn's progress.
@@ -171,3 +189,8 @@ export declare function trackFirstText(tracker: FirstTextTracker, progress: Pick
171
189
  tracker: FirstTextTracker;
172
190
  confirmedAt: number | null;
173
191
  };
192
+ /**
193
+ * The failure an ended step carries, or undefined when it carries none. Pure.
194
+ * Exported for the poll and its tests.
195
+ */
196
+ export declare function assistantTurnFailureOf(message: AssistantRawMessage): AssistantTurnFailure | undefined;
@@ -12,21 +12,22 @@ function o(o, s, c) {
12
12
  d,
13
13
  ...f,
14
14
  ...p
15
- ].filter(Boolean).join("\n\n"), _ = u.info?.providerID, v = u.info?.modelID, y = u.parts ?? [], b = -1, x = -1;
15
+ ].filter(Boolean).join("\n\n"), _ = u.info?.providerID, v = u.info?.modelID, y = u.parts ?? [], x = -1, S = -1;
16
16
  y.forEach((e, t) => {
17
- e.type === "tool" && (x = t), e.type === "text" && typeof e.text == "string" && e.text.trim() !== "" && (b = t);
17
+ e.type === "tool" && (S = t), e.type === "text" && typeof e.text == "string" && e.text.trim() !== "" && (x = t);
18
18
  });
19
- let S = b > x, C = l.some((e) => (e.parts ?? []).some((e) => e.type === "tool"));
19
+ let C = x > S, w = !h && a(u) ? b(u) : void 0, T = l.some((e) => (e.parts ?? []).some((e) => e.type === "tool"));
20
20
  return {
21
21
  content: g,
22
22
  hasRenderableOutput: h,
23
- hasText: c?.accumulateNarration ? !!d : !!d && S,
24
- usedTools: C,
23
+ hasText: c?.accumulateNarration ? !!d : !!d && C,
24
+ usedTools: T,
25
25
  done: a(u) && h,
26
26
  tokens: u.info?.tokens,
27
27
  messageId: u.info?.id,
28
28
  ..._ && v ? { model: `${_}/${v}` } : {},
29
- ...m ? { pendingWrite: m } : {}
29
+ ...m ? { pendingWrite: m } : {},
30
+ ...w ? { failure: w } : {}
30
31
  };
31
32
  }
32
33
  async function s(e, t, n = null) {
@@ -97,4 +98,13 @@ function y(e, t, n) {
97
98
  confirmedAt: a
98
99
  };
99
100
  }
100
- export { v as NO_FIRST_TEXT, u as REMEMBERED_FLOOR_MAX_AGE_MS, o as buildAssistantProgress, g as hasRememberedSessionFloor, l as readAheadFor, m as rememberSessionFloor, _ as resetRememberedSessionFloorsForTest, s as snapshotReplyFloor, c as startSessionReadAhead, h as takeRememberedSessionFloor, y as trackFirstText };
101
+ function b(e) {
102
+ let t = e.info?.error;
103
+ if (!t || typeof t != "object") return;
104
+ let n = typeof t.name == "string" && t.name.trim() ? t.name : "UnknownError", r = t.data?.statusCode;
105
+ return {
106
+ name: n,
107
+ ...typeof r == "number" && Number.isFinite(r) ? { statusCode: r } : {}
108
+ };
109
+ }
110
+ export { v as NO_FIRST_TEXT, u as REMEMBERED_FLOOR_MAX_AGE_MS, b as assistantTurnFailureOf, o as buildAssistantProgress, g as hasRememberedSessionFloor, l as readAheadFor, m as rememberSessionFloor, _ as resetRememberedSessionFloorsForTest, s as snapshotReplyFloor, c as startSessionReadAhead, h as takeRememberedSessionFloor, y as trackFirstText };
@@ -0,0 +1,39 @@
1
+ import { SandboxBusyGate } from './sandboxBusy';
2
+ import { AssistantTurnFailure } from './turnProgress';
3
+ /** How long a turn may show nothing at all after its prompt was accepted. */
4
+ export declare const NO_OUTPUT_LIMIT_MS = 60000;
5
+ export type AssistantTurnStallReason = 'modelError' | 'noOutput';
6
+ /**
7
+ * Thrown by the poll when a turn is ended for one of the reasons above. The
8
+ * turn's catch reports it as a failed turn and shows the copy
9
+ * `classifyTurnFailure` picks for it (`modelUnavailable` / `noOutputInTime`).
10
+ * Never retried on a fresh sandbox: the sandbox is healthy, and a re-send
11
+ * would ask the model the same question twice.
12
+ */
13
+ export declare class AssistantTurnStalled extends Error {
14
+ readonly reason: AssistantTurnStallReason;
15
+ /** The step's error, for `modelError`. */
16
+ readonly failure?: AssistantTurnFailure;
17
+ constructor(reason: AssistantTurnStallReason, failure?: AssistantTurnFailure);
18
+ }
19
+ /**
20
+ * Should this poll end the turn on the run's error?
21
+ *
22
+ * Only once the sandbox stops reporting the session busy — or, from a sandbox
23
+ * whose busy flag never clears, after the same grace the done gate allows
24
+ * (`SANDBOX_BUSY_GRACE_MS`). Pass a gate of its own, not the done gate.
25
+ */
26
+ export declare function turnFailureEndsTurn(gate: SandboxBusyGate, failure: AssistantTurnFailure | undefined, busy: boolean | undefined, now: number): boolean;
27
+ /**
28
+ * Has this turn shown nothing for longer than it may?
29
+ *
30
+ * `promptSentAt` is when the prompt was accepted (local clock); `sawOutput` is
31
+ * whether the poll or the live stream has put anything on screen.
32
+ */
33
+ export declare function turnHasStalledWithoutOutput(args: {
34
+ promptSentAt: number;
35
+ now: number;
36
+ sawOutput: boolean;
37
+ continuesInBackground: boolean;
38
+ limitMs?: number;
39
+ }): boolean;
@@ -0,0 +1,16 @@
1
+ import { gateDoneOnSandboxBusy as e } from "./sandboxBusy.js";
2
+ // src/shared/assistant/turnStall.ts
3
+ var t = 6e4, n = class extends Error {
4
+ reason;
5
+ failure;
6
+ constructor(e, n) {
7
+ super(e === "noOutput" ? `assistant turn produced no output within ${t / 1e3}s` : `assistant run ended on ${n?.name ?? "an error"}${n?.statusCode === void 0 ? "" : ` (${n.statusCode})`} with no output`), this.name = "AssistantTurnStalled", this.reason = e, n && (this.failure = n);
8
+ }
9
+ };
10
+ function r(t, n, r, i) {
11
+ return e(t, n !== void 0, r, i);
12
+ }
13
+ function i(e) {
14
+ return e.sawOutput || e.continuesInBackground ? !1 : e.now - e.promptSentAt >= (e.limitMs ?? 6e4);
15
+ }
16
+ export { n as AssistantTurnStalled, t as NO_OUTPUT_LIMIT_MS, r as turnFailureEndsTurn, i as turnHasStalledWithoutOutput };
@@ -138,9 +138,26 @@ export interface AssistantRawMessage {
138
138
  * bridges. Read by `isFinalAssistantMessage` (BOFF-9806).
139
139
  */
140
140
  finish?: string;
141
+ /**
142
+ * Why the step failed, when it did (opencode's v1 named error, passed
143
+ * through by the bridge): `APIError` (with the provider's `statusCode`),
144
+ * `ProviderAuthError`, `MessageAbortedError` or `UnknownError`. Read by
145
+ * `buildAssistantProgress` to end a turn the model could not answer
146
+ * (BOFF-13499). `null` on the bridges that write it for every message.
147
+ */
148
+ error?: AssistantMessageError | null;
141
149
  };
142
150
  parts?: AssistantRawMessagePart[];
143
151
  }
152
+ /** A failed step's error, as the bridge reports it (opencode's v1 named errors). */
153
+ export interface AssistantMessageError {
154
+ name?: string;
155
+ data?: {
156
+ message?: string;
157
+ statusCode?: number;
158
+ isRetryable?: boolean;
159
+ };
160
+ }
144
161
  export interface AssistantArtifact {
145
162
  name: string;
146
163
  path: string;