@burdenoff/fe-libs 2026.1118.1 → 2026.1118.3
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.
- package/dist/shared/assistant/api.d.ts +10 -0
- package/dist/shared/assistant/api.js +5 -3
- package/dist/shared/assistant/createSandboxAssistantTransport.js +4 -1
- package/dist/shared/assistant/index.d.ts +1 -0
- package/dist/shared/assistant/turnOutcome.js +46 -38
- package/dist/shared/assistant/turnOutcomeCopy.d.ts +8 -0
- package/dist/shared/assistant/turnOutcomeCopy.js +8 -0
- package/dist/shared/assistant/turnProgress.d.ts +23 -0
- package/dist/shared/assistant/turnProgress.js +17 -7
- package/dist/shared/assistant/turnStall.d.ts +39 -0
- package/dist/shared/assistant/turnStall.js +16 -0
- package/dist/shared/assistant/types.d.ts +17 -0
- package/dist/shared/assistant/ui/AssistantChatArea.js +1348 -1332
- package/dist/shared/hooks/index.d.ts +1 -0
- package/dist/shared/hooks/useInfiniteScroll.d.ts +40 -0
- package/dist/shared/hooks/useInfiniteScroll.js +41 -0
- package/dist/shared-assistant.js +334 -333
- package/dist/shared-hooks.js +24 -23
- package/dist/shared.js +37 -36
- package/package.json +1 -1
|
@@ -464,6 +464,12 @@ export declare function buildPromptRequestBody(args: {
|
|
|
464
464
|
uiCatalogue?: AssistantUiCatalogue | null;
|
|
465
465
|
/** ★ BOFF-9786: the page's browser tools. Absent unless the sandbox runs them and the page registers some. */
|
|
466
466
|
clientTools?: readonly ClientToolManifestEntry[] | null;
|
|
467
|
+
/**
|
|
468
|
+
* ★ BOFF-13499 (BOFF-7503): how long this panel polls the turn, so the agent
|
|
469
|
+
* budgets the run to match instead of guessing from the mode. Absent from
|
|
470
|
+
* callers that do not know it; the agent then uses its per-mode table.
|
|
471
|
+
*/
|
|
472
|
+
turnBudgetMs?: number | null;
|
|
467
473
|
}): Record<string, unknown>;
|
|
468
474
|
export interface AssistantPromptGatewayRequest {
|
|
469
475
|
sandboxId: string;
|
|
@@ -482,6 +488,8 @@ export interface AssistantPromptGatewayRequest {
|
|
|
482
488
|
uiCatalogue?: AssistantUiCatalogue | null;
|
|
483
489
|
/** The page's browser tools (BOFF-9786). */
|
|
484
490
|
clientTools?: readonly ClientToolManifestEntry[] | null;
|
|
491
|
+
/** How long the panel polls this turn (BOFF-13499). */
|
|
492
|
+
turnBudgetMs?: number | null;
|
|
485
493
|
}
|
|
486
494
|
/** The actual unbatched GraphQL body, including context and forwarded-token overhead. */
|
|
487
495
|
export declare function buildPromptGatewayRequest(args: AssistantPromptGatewayRequest): {
|
|
@@ -501,6 +509,8 @@ options?: {
|
|
|
501
509
|
writeReply?: AssistantPromptWriteReply | null;
|
|
502
510
|
uiCatalogue?: AssistantUiCatalogue | null;
|
|
503
511
|
clientTools?: readonly ClientToolManifestEntry[] | null;
|
|
512
|
+
/** How long the panel polls this turn (BOFF-13499). */
|
|
513
|
+
turnBudgetMs?: number | null;
|
|
504
514
|
}): Promise<{
|
|
505
515
|
messageID?: string;
|
|
506
516
|
}>;
|
|
@@ -489,7 +489,7 @@ function Q(e) {
|
|
|
489
489
|
};
|
|
490
490
|
r && r.length > 0 && (i.parts = r), typeof e.conversationId == "string" && ze.test(e.conversationId) && (i.conversationId = e.conversationId);
|
|
491
491
|
let a = Ue(e.writeReply);
|
|
492
|
-
return a && (i.writeReply = a), e.uiCatalogue && (i.uiCatalogue = e.uiCatalogue), e.clientTools && e.clientTools.length > 0 && (i.clientTools = e.clientTools), i;
|
|
492
|
+
return a && (i.writeReply = a), e.uiCatalogue && (i.uiCatalogue = e.uiCatalogue), e.clientTools && e.clientTools.length > 0 && (i.clientTools = e.clientTools), typeof e.turnBudgetMs == "number" && Number.isFinite(e.turnBudgetMs) && e.turnBudgetMs > 0 && (i.turnBudgetMs = Math.floor(e.turnBudgetMs)), i;
|
|
493
493
|
}
|
|
494
494
|
function We(e) {
|
|
495
495
|
return O(e.sandboxId, e.workspaceId, j(e.sessionId, "/prompt-async"), "POST", Q(e), e.mode, e.authContext);
|
|
@@ -510,7 +510,8 @@ async function Ke(e, t, n, r, i, a, o, s) {
|
|
|
510
510
|
conversationId: s?.conversationId,
|
|
511
511
|
writeReply: s?.writeReply,
|
|
512
512
|
uiCatalogue: s?.uiCatalogue,
|
|
513
|
-
clientTools: s?.clientTools
|
|
513
|
+
clientTools: s?.clientTools,
|
|
514
|
+
turnBudgetMs: s?.turnBudgetMs
|
|
514
515
|
}) > 262144) throw Object.assign(Error(he), { assistantPromptNotDispatched: !0 });
|
|
515
516
|
let c = await M(e, t, j(n, "/prompt-async"), "POST", Q({
|
|
516
517
|
mode: i,
|
|
@@ -520,7 +521,8 @@ async function Ke(e, t, n, r, i, a, o, s) {
|
|
|
520
521
|
conversationId: s?.conversationId,
|
|
521
522
|
writeReply: s?.writeReply,
|
|
522
523
|
uiCatalogue: s?.uiCatalogue,
|
|
523
|
-
clientTools: s?.clientTools
|
|
524
|
+
clientTools: s?.clientTools,
|
|
525
|
+
turnBudgetMs: s?.turnBudgetMs
|
|
524
526
|
}), i, o, "never");
|
|
525
527
|
return { messageID: typeof c.messageID == "string" ? c.messageID : void 0 };
|
|
526
528
|
}
|
|
@@ -52,7 +52,10 @@ function F(F, I) {
|
|
|
52
52
|
prompt: e.prompt,
|
|
53
53
|
isAbandoned: b,
|
|
54
54
|
readMessages: (e) => t(o, r, s, L, a, { sinceMs: e }),
|
|
55
|
-
send: () => i(o, r, s, e.prompt, L, K(), a, e.parts?.length ? {
|
|
55
|
+
send: () => i(o, r, s, e.prompt, L, K(), a, e.parts?.length ? {
|
|
56
|
+
parts: e.parts,
|
|
57
|
+
turnBudgetMs: R
|
|
58
|
+
} : { turnBudgetMs: R })
|
|
56
59
|
}), b()) throw Error("Cancelled");
|
|
57
60
|
let d = null, f = null, x = await n(o, r, s, L, a).catch(() => null);
|
|
58
61
|
if (x && typeof EventSource < "u") try {
|
|
@@ -280,6 +280,7 @@ export * from './sandboxBusy';
|
|
|
280
280
|
export * from './permissionError';
|
|
281
281
|
export * from './autoRouting';
|
|
282
282
|
export * from './turnOutcome';
|
|
283
|
+
export * from './turnStall';
|
|
283
284
|
export * from './turnTimeline';
|
|
284
285
|
export * from './turnStream';
|
|
285
286
|
export * from './liveDeltas';
|
|
@@ -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
|
|
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
|
-
},
|
|
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
|
|
42
|
+
function l(e) {
|
|
42
43
|
return e === null ? null : Number.isFinite(Date.parse(e)) ? e : null;
|
|
43
44
|
}
|
|
44
|
-
function
|
|
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
|
|
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
|
|
60
|
+
function f({ mode: e, capabilities: t }) {
|
|
60
61
|
return e === "assistant" || t?.proposals === !0 && t.writeApprovalMode === "proposal-v1";
|
|
61
62
|
}
|
|
62
|
-
function
|
|
63
|
-
let
|
|
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
|
-
|
|
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
|
|
71
|
-
if (
|
|
72
|
-
let e =
|
|
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:
|
|
83
|
+
copy: u(p.quotaName, e !== null),
|
|
76
84
|
offersUpgrade: !1,
|
|
77
|
-
quotaName:
|
|
78
|
-
traceId:
|
|
85
|
+
quotaName: p.quotaName,
|
|
86
|
+
traceId: p.traceId ?? f,
|
|
79
87
|
...e === null ? {} : { resetsAt: e }
|
|
80
88
|
};
|
|
81
89
|
}
|
|
82
|
-
if (
|
|
90
|
+
if (p) return {
|
|
83
91
|
kind: "usage",
|
|
84
|
-
copy:
|
|
85
|
-
offersUpgrade:
|
|
86
|
-
quotaName:
|
|
87
|
-
traceId:
|
|
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
|
|
90
|
-
if (
|
|
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:
|
|
103
|
+
traceId: f
|
|
96
104
|
};
|
|
97
|
-
let
|
|
98
|
-
return
|
|
105
|
+
let h = m === null ? e(r) : null;
|
|
106
|
+
return h ? {
|
|
99
107
|
kind: "permission",
|
|
100
|
-
copy: t(
|
|
108
|
+
copy: t(h.refusal),
|
|
101
109
|
offersUpgrade: !1,
|
|
102
110
|
quotaName: null,
|
|
103
|
-
traceId:
|
|
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:
|
|
117
|
+
traceId: f
|
|
110
118
|
};
|
|
111
119
|
}
|
|
112
|
-
var
|
|
120
|
+
var m = {
|
|
113
121
|
hour: "numeric",
|
|
114
122
|
minute: "2-digit",
|
|
115
123
|
timeZoneName: "short"
|
|
116
124
|
};
|
|
117
|
-
function
|
|
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,
|
|
129
|
+
return new Intl.DateTimeFormat(t, m).format(n);
|
|
122
130
|
} catch {
|
|
123
|
-
return new Intl.DateTimeFormat("en",
|
|
131
|
+
return new Intl.DateTimeFormat("en", m).format(n);
|
|
124
132
|
}
|
|
125
133
|
}
|
|
126
|
-
function
|
|
134
|
+
function g(e) {
|
|
127
135
|
return e && /^en(?:-|$)/i.test(e) ? e : "en";
|
|
128
136
|
}
|
|
129
|
-
function
|
|
137
|
+
function _(e, t) {
|
|
130
138
|
return t ? e.replace(/\{\{(\w+)\}\}/g, (e, n) => t[n] ?? e) : e;
|
|
131
139
|
}
|
|
132
|
-
function
|
|
133
|
-
let r = e.resetsAt ?
|
|
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 {
|
|
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 ?? [],
|
|
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" && (
|
|
17
|
+
e.type === "tool" && (S = t), e.type === "text" && typeof e.text == "string" && e.text.trim() !== "" && (x = t);
|
|
18
18
|
});
|
|
19
|
-
let S = b
|
|
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 &&
|
|
24
|
-
usedTools:
|
|
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
|
-
|
|
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;
|