@burdenoff/fe-libs 2026.925.4 → 2026.925.6
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/index.d.ts +1 -0
- package/dist/shared/assistant/index.d.ts.map +1 -1
- package/dist/shared/assistant/prewarm.d.ts +139 -0
- package/dist/shared/assistant/prewarm.d.ts.map +1 -0
- package/dist/shared/assistant/prewarm.js +96 -0
- package/dist/shared/assistant/sandboxReadiness.d.ts +45 -6
- package/dist/shared/assistant/sandboxReadiness.d.ts.map +1 -1
- package/dist/shared/assistant/sandboxReadiness.js +25 -11
- package/dist/shared/assistant/transportErrors.d.ts +2 -0
- package/dist/shared/assistant/transportErrors.d.ts.map +1 -1
- package/dist/shared/assistant/transportErrors.js +5 -1
- package/dist/shared/assistant/turnTimeline.d.ts +12 -0
- package/dist/shared/assistant/turnTimeline.d.ts.map +1 -1
- package/dist/shared/assistant/turnTimeline.js +2 -2
- package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantChatArea.js +587 -465
- package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts +6 -0
- package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts.map +1 -1
- package/dist/shared/assistant/ui/composer/AssistantComposer.js +110 -106
- package/dist/shared-assistant.js +67 -66
- package/package.json +1 -1
|
@@ -4,204 +4,318 @@ import "../../../shared-providers-shell.js";
|
|
|
4
4
|
import { useAssistantProduct as n } from "../product.js";
|
|
5
5
|
import { useAssistantTr as r } from "../i18n.js";
|
|
6
6
|
import { isAssistantModeId as i } from "../modeIds.js";
|
|
7
|
-
import { abortAssistantTurn as a, approvePendingWrite as o, createAssistantSandbox as s, createAssistantSession as c, extendAssistantSandboxTTL as
|
|
8
|
-
import { sanitize as
|
|
9
|
-
import { withIncompleteTurnNotice as
|
|
10
|
-
import { isVoiceTurn as
|
|
11
|
-
import { buildContinuedFromVoiceNote as
|
|
12
|
-
import { pollDelayMs as
|
|
13
|
-
import { toCaptionText as
|
|
14
|
-
import { resolveAssistantLanguage as
|
|
15
|
-
import { resolveLanguagePair as
|
|
16
|
-
import { countInlineImageCandidates as
|
|
17
|
-
import { AssistantSendRefusal as
|
|
18
|
-
import { createAdminModeAccessGate as
|
|
19
|
-
import { buildBoundedAttachmentTurn as
|
|
20
|
-
import { isWriteModeAcknowledged as
|
|
21
|
-
import { AUTO_READ_MODE as
|
|
22
|
-
import { resolveActiveModeSandbox as
|
|
23
|
-
import { isTurnInFlight as
|
|
24
|
-
import { getAssistantDisplayContent as
|
|
25
|
-
import { NO_FIRST_TEXT as
|
|
26
|
-
import { parseToolActivity as
|
|
27
|
-
import { countSpokenTurns as
|
|
28
|
-
import { beginTurn as
|
|
29
|
-
import { useVoiceSession as
|
|
30
|
-
import { getOrganizationId as
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
7
|
+
import { abortAssistantTurn as a, approvePendingWrite as o, createAssistantSandbox as s, createAssistantSession as c, extendAssistantSandboxTTL as l, findExistingSandboxWithStatus as ee, getAssistantArtifacts as te, getAssistantMessages as u, getAssistantSession as d, modeRequiresConfirmWrites as f, promptGatewayRequestBytes as ne, releaseSupersededAssistantSandboxes as p, sendAssistantPromptAsync as re, waitForAssistantServiceReady as m, waitForSandboxRunning as ie } from "../api.js";
|
|
8
|
+
import { sanitize as ae } from "../progress.js";
|
|
9
|
+
import { withIncompleteTurnNotice as oe } from "../streamBudget.js";
|
|
10
|
+
import { isVoiceTurn as h, voiceMarker as se, voiceSessionIdOf as g } from "../voice/turnVisibility.js";
|
|
11
|
+
import { buildContinuedFromVoiceNote as ce, buildVoiceTranscriptMarkdown as _, voiceTranscriptFilename as le } from "../voice/voiceTranscript.js";
|
|
12
|
+
import { pollDelayMs as ue } from "../voice/assistantPollSchedule.js";
|
|
13
|
+
import { toCaptionText as de } from "../voice/captionText.js";
|
|
14
|
+
import { resolveAssistantLanguage as v } from "../voice/languages.js";
|
|
15
|
+
import { resolveLanguagePair as fe } from "../voice/languagePair.js";
|
|
16
|
+
import { countInlineImageCandidates as pe, countInlinedImageParts as me, getSendableAttachments as he, largestInlineCharsPerFile as ge, resolveAssistantInlineLimits as _e, toMessageAttachment as ve } from "../attachments.js";
|
|
17
|
+
import { AssistantSendRefusal as ye, classifyTurnFailure as be, turnOutcomeCopy as xe } from "../turnOutcome.js";
|
|
18
|
+
import { createAdminModeAccessGate as y, resolveAssistantSendModeAfterAccess as Se } from "../adminModeSendGate.js";
|
|
19
|
+
import { buildBoundedAttachmentTurn as Ce } from "../attachmentTurn.js";
|
|
20
|
+
import { isWriteModeAcknowledged as we, writeModeSendRefusalReason as Te } from "../writeModeConsent.js";
|
|
21
|
+
import { AUTO_READ_MODE as b, autoCarryOverFor as Ee, autoSuggestions as De, classifyAssistantIntent as Oe, escalationToUndo as ke, isAutoRoutingOffered as Ae, resolveAutoRoute as je } from "../autoRouting.js";
|
|
22
|
+
import { resolveActiveModeSandbox as Me, useAssistantStore as x } from "../store.js";
|
|
23
|
+
import { isTurnInFlight as Ne, planAbandonedTurn as Pe, planTurnAbort as Fe } from "../turnState.js";
|
|
24
|
+
import { getAssistantDisplayContent as Ie } from "../displayContent.js";
|
|
25
|
+
import { NO_FIRST_TEXT as Le, buildAssistantProgress as Re, snapshotReplyFloor as ze, trackFirstText as Be } from "../turnProgress.js";
|
|
26
|
+
import { parseToolActivity as Ve } from "./AssistantToolActivity.js";
|
|
27
|
+
import { countSpokenTurns as He, spokenTurnText as Ue } from "../spokenTurns.js";
|
|
28
|
+
import { beginTurn as We, describeTurn as S, detectTurnDevice as Ge, markTurn as C, restartAttempt as Ke, turnClockMs as qe } from "../turnTimeline.js";
|
|
29
|
+
import { useVoiceSession as Je } from "./useVoiceSession.js";
|
|
30
|
+
import { getOrganizationId as Ye, getWorkspaceId as Xe } from "../context.js";
|
|
31
|
+
import { isMultimodalBodyRejection as Ze, isRecoverableAssistantError as Qe } from "../transportErrors.js";
|
|
32
|
+
import { createReadinessTracker as $e, planAfterTransportFailure as et, planTrustedSandboxFailure as tt } from "../sandboxReadiness.js";
|
|
33
|
+
import { AssistantSpokenTurnsNotice as nt } from "./AssistantSpokenTurnsNotice.js";
|
|
34
|
+
import { VoiceTranscriptDrawer as rt } from "./voice/VoiceTranscriptDrawer.js";
|
|
35
|
+
import { downloadFile as it } from "../exportConversation.js";
|
|
36
|
+
import { AssistantEmptyState as at } from "./AssistantEmptyState.js";
|
|
37
|
+
import { AssistantMessageList as ot } from "./AssistantMessageList.js";
|
|
38
|
+
import { AssistantVoiceSession as st } from "./voice/AssistantVoiceSession.js";
|
|
39
|
+
import { useAssistantApiAccess as ct } from "../useAssistantApiAccess.js";
|
|
40
|
+
import { useConversationTurns as lt } from "../useConversationTurns.js";
|
|
41
|
+
import { WarmCancelled as ut, consumeWarm as dt, prewarmTarget as ft, settleWarmBeforeSend as pt, startWarm as mt, warmState as ht } from "../prewarm.js";
|
|
42
|
+
import { dispatchAssistantQuotaExhausted as gt, notifyAiCreditsUpdated as _t } from "../aiCredits.js";
|
|
43
|
+
import { useAssistantAttachments as vt } from "../useAssistantAttachments.js";
|
|
44
|
+
import { AssistantComposer as yt } from "./composer/AssistantComposer.js";
|
|
45
|
+
import { isProdRuntime as bt } from "../env.js";
|
|
46
|
+
import { AssistantApiCallsConsentDialog as xt } from "./AssistantApiCallsConsentDialog.js";
|
|
47
|
+
import { useCallback as w, useEffect as T, useMemo as E, useRef as D, useState as St } from "react";
|
|
48
|
+
import { jsx as O, jsxs as Ct } from "react/jsx-runtime";
|
|
48
49
|
//#region src/shared/assistant/ui/AssistantChatArea.tsx
|
|
49
|
-
var
|
|
50
|
-
function
|
|
50
|
+
var wt = 600, Tt = 2e4;
|
|
51
|
+
function Et() {
|
|
51
52
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
52
53
|
}
|
|
53
|
-
var
|
|
54
|
-
let
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
]),
|
|
59
|
-
loading:
|
|
60
|
-
canUseAdminModes:
|
|
61
|
-
})).current,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}, [
|
|
65
|
-
|
|
66
|
-
loading:
|
|
67
|
-
canUseAdminModes:
|
|
54
|
+
var Dt = ({ visible: Dt = !0, writeAccess: Ot = "unknown" }) => {
|
|
55
|
+
let k = r(), { product: A, modes: j, gatherPageContext: kt, buildPrompt: At, reportTokenUsage: jt } = n(), { getAccessToken: M, getWorkspaceToken: N, userId: P } = t(), { locale: Mt } = e(), Nt = x((e) => e.assistantLanguage), Pt = x((e) => e.replyLanguage), Ft = E(() => fe(Nt, Pt, Mt), [
|
|
56
|
+
Nt,
|
|
57
|
+
Pt,
|
|
58
|
+
Mt
|
|
59
|
+
]), It = Ft.reply.english, Lt = Ft.replyIsExplicit, Rt = Ft.reply.code, { conversations: zt, activeConversationId: F, mode: I, processingByConversationId: Bt, setMode: L, setConversationMode: Vt, setActiveConversation: Ht, createConversation: R, addMessage: z, updateMessage: Ut, patchMessage: Wt, mergeMessageMetadata: Gt, setConversationProcessing: Kt, clearConversationProcessing: qt, setBackendSessionId: Jt, clearBackendSessionId: Yt, setSandbox: B, clearSandbox: V, acknowledgedWriteModes: Xt, acknowledgeWriteMode: Zt, autoRouting: Qt, setAutoRouting: $t, routeConversation: H } = x(), en = zt.find((e) => e.id === F), tn = lt(en), nn = tn.all, U = F ? Bt[F] : void 0, rn = Ne(U?.status), an = rn ? U?.messageId ?? null : null, on = U?.status === "error" ? U.messageId : null, { canUseApiCalls: W, loading: sn } = ct(Ye()), G = D(y({
|
|
60
|
+
loading: sn,
|
|
61
|
+
canUseAdminModes: W
|
|
62
|
+
})).current, cn = D(j);
|
|
63
|
+
T(() => {
|
|
64
|
+
cn.current = j;
|
|
65
|
+
}, [j]), T(() => {
|
|
66
|
+
G.update({
|
|
67
|
+
loading: sn,
|
|
68
|
+
canUseAdminModes: W
|
|
68
69
|
});
|
|
69
70
|
}, [
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
]),
|
|
74
|
-
|
|
75
|
-
}, [
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}, [
|
|
80
|
-
let
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
|
|
71
|
+
G,
|
|
72
|
+
sn,
|
|
73
|
+
W
|
|
74
|
+
]), T(() => () => {
|
|
75
|
+
G.abandon();
|
|
76
|
+
}, [G]);
|
|
77
|
+
let ln = E(() => j.filter((e) => !e.requiresAdmin || W), [j, W]), un = Ae(ln), dn = Qt && un, fn = D(un);
|
|
78
|
+
T(() => {
|
|
79
|
+
fn.current = un;
|
|
80
|
+
}, [un]);
|
|
81
|
+
let pn = D(null), mn = ge(j), [hn, gn] = St(null), [_n, vn] = St(!1), yn = D({}), K = D($e()), q = D(/* @__PURE__ */ new Set()), bn = D(/* @__PURE__ */ new Set()), J = E(() => j.find((e) => e.id === I), [j, I]), xn = I === "assistant" || J !== void 0 && !J.writeCapable && !f(I);
|
|
82
|
+
T(() => {
|
|
83
|
+
if (I !== "assistant" && J?.writeCapable && !we(Xt, I)) {
|
|
84
|
+
L("assistant");
|
|
84
85
|
return;
|
|
85
86
|
}
|
|
86
|
-
|
|
87
|
+
sn || (!J || J.requiresAdmin && !W) && I !== "assistant" && L("assistant");
|
|
87
88
|
}, [
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
I,
|
|
90
|
+
J,
|
|
91
|
+
W,
|
|
92
|
+
sn,
|
|
93
|
+
L,
|
|
94
|
+
Xt
|
|
94
95
|
]);
|
|
95
|
-
let
|
|
96
|
-
|
|
97
|
-
}, [
|
|
98
|
-
let
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
let Y = w((e, t, n, r) => {
|
|
97
|
+
Kt(e, n, t, null, r);
|
|
98
|
+
}, [Kt]), Sn = w(async (e, t, n, r, a, o = null) => {
|
|
99
|
+
let c = (e, t) => {
|
|
100
|
+
r && Y(r.conversationId, r.assistantMessageId, e, t), o && (o.step = t, o.onStep?.(t));
|
|
101
|
+
}, l = (e) => {
|
|
102
|
+
r && C(r.assistantMessageId, e);
|
|
103
|
+
}, te = () => o !== null && (o.signal.aborted || Xe() !== t), u = () => {
|
|
104
|
+
if (te()) throw new ut("cancelled");
|
|
105
|
+
}, d = x.getState().sandboxesByMode[e]?.sandboxId ?? null, f = !1, ne = !1, re = !1, ae = !1, oe = !1, h = async (r) => {
|
|
106
|
+
if (a && !q.current.has(r) && K.current.isFresh(r)) return f = !0, !0;
|
|
107
|
+
re = !0;
|
|
108
|
+
let i = !1;
|
|
102
109
|
try {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
})
|
|
110
|
+
await ie(r, t, n, 3e5), await m(r, t, e, n, 9e4, () => {
|
|
111
|
+
i = !0;
|
|
112
|
+
});
|
|
106
113
|
} catch {
|
|
107
|
-
|
|
114
|
+
if (te()) throw new ut("cancelled");
|
|
115
|
+
return K.current.invalidate(r), q.current.add(r), o?.dead.push(r), oe = !0, !1;
|
|
108
116
|
}
|
|
117
|
+
return u(), K.current.markVerified(r), i && (ae = !0), !0;
|
|
109
118
|
};
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
let
|
|
113
|
-
|
|
119
|
+
if (d && (B(e, d, "provisioning"), c("provisioning", "reusingEnvironment"), await h(d) || (B(e, null, "provisioning"), d = null)), !d) {
|
|
120
|
+
c("provisioning", "lookingForEnvironment");
|
|
121
|
+
let r = await ee(t, A, e, bt(), n, q.current);
|
|
122
|
+
u();
|
|
123
|
+
let i = r?.id ?? null;
|
|
124
|
+
i && (B(e, i, "provisioning"), c("provisioning", "reusingEnvironment"), await h(i) ? (d = i, (r?.status === "PROVISIONING" || r?.status === "PENDING") && (ae = !0)) : B(e, null, "provisioning"));
|
|
114
125
|
}
|
|
115
|
-
if (!
|
|
116
|
-
if (
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
let
|
|
123
|
-
|
|
126
|
+
if (!d) {
|
|
127
|
+
if (o && !o.mayCreate) throw new ut("no-create");
|
|
128
|
+
if (l("provisionStarted"), e === "api-calls" && !M()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
|
|
129
|
+
c("provisioning", "startingEnvironment"), B(e, null, "provisioning");
|
|
130
|
+
let r = o ? [] : await p(t, A, e, bt(), n, q.current);
|
|
131
|
+
if (r.length > 0) {
|
|
132
|
+
let e = new Set(r);
|
|
133
|
+
for (let e of r) K.current.invalidate(e), q.current.add(e);
|
|
134
|
+
let t = x.getState().sandboxesByMode;
|
|
135
|
+
for (let [n, r] of Object.entries(t)) i(n) && r?.sandboxId && e.has(r.sandboxId) && V(n);
|
|
136
|
+
}
|
|
137
|
+
l("createRequested");
|
|
138
|
+
let a = o?.beginCreate();
|
|
139
|
+
try {
|
|
140
|
+
d = await s(A, e, t, bt(), wt, n);
|
|
141
|
+
} finally {
|
|
142
|
+
a?.();
|
|
124
143
|
}
|
|
125
|
-
|
|
144
|
+
ne = !0, u(), B(e, d, "provisioning"), await ie(d, t, n, 3e5), u(), l("sandboxRunning"), await m(d, t, e, n, 9e4), u(), l("serviceReady"), K.current.markVerified(d);
|
|
126
145
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
146
|
+
return B(e, d, "running"), {
|
|
147
|
+
sandboxId: d,
|
|
148
|
+
sandboxIsNew: ne,
|
|
149
|
+
sandboxProbed: re,
|
|
150
|
+
sandboxAdopted: ae,
|
|
151
|
+
deadSandboxProbe: oe,
|
|
152
|
+
trustedFromCache: f
|
|
153
|
+
};
|
|
154
|
+
}, [
|
|
155
|
+
V,
|
|
156
|
+
M,
|
|
157
|
+
A,
|
|
158
|
+
B,
|
|
159
|
+
Y
|
|
160
|
+
]), Cn = w(async function e(t, n, r, i, a, o = {}) {
|
|
161
|
+
let s = await pt(i, r, (e) => Y(t, n, "provisioning", e));
|
|
162
|
+
for (let e of s.dead) K.current.invalidate(e), q.current.add(e);
|
|
163
|
+
s.verified && !q.current.has(s.verified) && K.current.markVerified(s.verified), s.joined && S(n, { prewarm: s.joined });
|
|
164
|
+
let { sandboxId: l, sandboxIsNew: te, sandboxProbed: u, sandboxAdopted: f, deadSandboxProbe: ne, trustedFromCache: p } = await Sn(r, i, a, {
|
|
165
|
+
conversationId: t,
|
|
166
|
+
assistantMessageId: n
|
|
167
|
+
}, o.trustCache !== !1), re = dt(i, r, l);
|
|
168
|
+
!s.joined && re && S(n, { prewarm: "hit" });
|
|
169
|
+
let m = x.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null, ie = !1;
|
|
170
|
+
if (m) try {
|
|
171
|
+
let e = await d(l, i, m, r, a);
|
|
172
|
+
if (e.mode !== r) throw Error(`Session mode mismatch: expected ${r}, received ${e.mode}`);
|
|
132
173
|
} catch {
|
|
133
|
-
|
|
174
|
+
Yt(t), m = null;
|
|
175
|
+
}
|
|
176
|
+
if (!m) {
|
|
177
|
+
Y(t, n, "connecting", "preparingSession");
|
|
178
|
+
let s;
|
|
179
|
+
try {
|
|
180
|
+
s = await c(l, i, r, a);
|
|
181
|
+
} catch (s) {
|
|
182
|
+
if (p) {
|
|
183
|
+
K.current.invalidate(l);
|
|
184
|
+
let c = tt(s, o.isAbandoned?.() ?? !1), te = c === "check-network";
|
|
185
|
+
if (c === "check-network" && (c = await et(() => ee(i, A, r, bt(), a, q.current))), c !== "rethrow" && o.isAbandoned?.() && (c = "rethrow"), c !== "rethrow") {
|
|
186
|
+
te || S(n, { cacheProofFailed: !0 }), c === "replace" && (q.current.add(l), Yt(t), V(r));
|
|
187
|
+
let s = await e(t, n, r, i, a, {
|
|
188
|
+
...o,
|
|
189
|
+
trustCache: !1
|
|
190
|
+
});
|
|
191
|
+
return te && (s.deadSandboxProbe || s.sandboxId !== l) && S(n, { cacheProofFailed: !0 }), {
|
|
192
|
+
...s,
|
|
193
|
+
sandboxProbed: s.sandboxProbed || u,
|
|
194
|
+
sandboxAdopted: s.sandboxAdopted || f,
|
|
195
|
+
deadSandboxProbe: s.deadSandboxProbe || ne
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
throw s;
|
|
200
|
+
}
|
|
201
|
+
m = s.sessionId, Jt(t, m), ie = !0;
|
|
134
202
|
}
|
|
135
|
-
return
|
|
136
|
-
sandboxId:
|
|
137
|
-
sessionId:
|
|
138
|
-
sessionIsNew:
|
|
139
|
-
sandboxIsNew:
|
|
140
|
-
sandboxProbed:
|
|
141
|
-
sandboxAdopted:
|
|
142
|
-
deadSandboxProbe:
|
|
203
|
+
return {
|
|
204
|
+
sandboxId: l,
|
|
205
|
+
sessionId: m,
|
|
206
|
+
sessionIsNew: ie,
|
|
207
|
+
sandboxIsNew: te,
|
|
208
|
+
sandboxProbed: u,
|
|
209
|
+
sandboxAdopted: f,
|
|
210
|
+
deadSandboxProbe: ne
|
|
143
211
|
};
|
|
144
212
|
}, [
|
|
145
|
-
|
|
146
|
-
|
|
213
|
+
Sn,
|
|
214
|
+
Yt,
|
|
215
|
+
V,
|
|
147
216
|
A,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
]), [gn, _n] = gt(null), Y = T(/* @__PURE__ */ new Set()), vn = T(null), yn = S(() => {
|
|
153
|
-
let e = y.getState(), t = e.activeConversationId;
|
|
217
|
+
Jt,
|
|
218
|
+
Y
|
|
219
|
+
]), wn = w((e) => {
|
|
220
|
+
let t = Xe();
|
|
154
221
|
if (!t) return;
|
|
155
|
-
let n =
|
|
156
|
-
|
|
222
|
+
let n = x.getState(), r = Date.now(), i = ft({
|
|
223
|
+
autoRouting: n.autoRouting,
|
|
224
|
+
autoOffered: fn.current,
|
|
225
|
+
active: n.activeConversationId ? n.conversations.find((e) => e.id === n.activeConversationId) : void 0,
|
|
226
|
+
selectedMode: n.mode,
|
|
227
|
+
autoReadMode: b,
|
|
228
|
+
modes: cn.current,
|
|
229
|
+
acknowledgedWriteModes: n.acknowledgedWriteModes,
|
|
230
|
+
adminAccess: G.read(),
|
|
231
|
+
dictated: e,
|
|
232
|
+
turnInFlight: Object.values(n.processingByConversationId).some((e) => Ne(e?.status)),
|
|
233
|
+
...ht(t),
|
|
234
|
+
now: r
|
|
235
|
+
});
|
|
236
|
+
if (!i) return;
|
|
237
|
+
let a = mt(t, i, r), o = {
|
|
238
|
+
accessToken: M(),
|
|
239
|
+
workspaceToken: N(),
|
|
240
|
+
userId: P,
|
|
241
|
+
organizationId: Ye()
|
|
242
|
+
};
|
|
243
|
+
Sn(i.mode, t, o, null, !0, a).then((e) => a.finish({
|
|
244
|
+
ok: !0,
|
|
245
|
+
sandboxId: e.sandboxId,
|
|
246
|
+
didWork: !e.trustedFromCache && (e.sandboxIsNew || e.sandboxProbed || e.sandboxAdopted),
|
|
247
|
+
dead: a.dead
|
|
248
|
+
}), (e) => {
|
|
249
|
+
if (!(e instanceof ut) && !a.signal.aborted && Xe() === t) {
|
|
250
|
+
let e = x.getState().sandboxesByMode[i.mode]?.sandboxId ?? null;
|
|
251
|
+
e && (K.current.invalidate(e), q.current.add(e), a.dead.push(e), V(i.mode));
|
|
252
|
+
}
|
|
253
|
+
a.finish({
|
|
254
|
+
ok: !1,
|
|
255
|
+
didWork: !1,
|
|
256
|
+
dead: a.dead
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
}, [
|
|
260
|
+
Sn,
|
|
261
|
+
G,
|
|
262
|
+
V,
|
|
263
|
+
M,
|
|
264
|
+
N,
|
|
265
|
+
P
|
|
266
|
+
]), Tn = w(() => wn(!1), [wn]), [En, Dn] = St(null), On = D(/* @__PURE__ */ new Set()), kn = D(null), An = w(() => {
|
|
267
|
+
let e = x.getState(), t = e.activeConversationId;
|
|
268
|
+
if (!t) return;
|
|
269
|
+
let n = e.processingByConversationId[t], r = Ne(n?.status) ? n?.messageId ?? null : null;
|
|
270
|
+
if (!Fe({
|
|
157
271
|
interruptedTurnId: r,
|
|
158
272
|
activeTurnId: r,
|
|
159
|
-
alreadyRequested: r ?
|
|
273
|
+
alreadyRequested: r ? On.current.has(r) : !1
|
|
160
274
|
}).send || !r) return;
|
|
161
|
-
|
|
162
|
-
let i =
|
|
275
|
+
On.current.add(r);
|
|
276
|
+
let i = Me(e), o = Xe(), s = e.conversations.find((e) => e.id === t)?.backendSessionId;
|
|
163
277
|
!i || !o || !s || a(i.sandboxId, o, s, i.mode, {
|
|
164
|
-
accessToken:
|
|
165
|
-
workspaceToken:
|
|
166
|
-
userId:
|
|
167
|
-
organizationId:
|
|
278
|
+
accessToken: M(),
|
|
279
|
+
workspaceToken: N(),
|
|
280
|
+
userId: P,
|
|
281
|
+
organizationId: Ye()
|
|
168
282
|
});
|
|
169
283
|
}, [
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
]),
|
|
174
|
-
let t =
|
|
284
|
+
P,
|
|
285
|
+
M,
|
|
286
|
+
N
|
|
287
|
+
]), jn = w(async (e) => {
|
|
288
|
+
let t = x.getState(), n = Me(t), r = Xe(), i = t.activeConversationId;
|
|
175
289
|
if (!(!n || !r || !i)) {
|
|
176
|
-
|
|
290
|
+
Dn(e);
|
|
177
291
|
try {
|
|
178
292
|
await o(n.sandboxId, r, e, n.mode, {
|
|
179
|
-
accessToken:
|
|
180
|
-
workspaceToken:
|
|
181
|
-
userId:
|
|
182
|
-
organizationId:
|
|
293
|
+
accessToken: M(),
|
|
294
|
+
workspaceToken: N(),
|
|
295
|
+
userId: P,
|
|
296
|
+
organizationId: Ye()
|
|
183
297
|
});
|
|
184
298
|
} catch (e) {
|
|
185
|
-
|
|
186
|
-
id:
|
|
299
|
+
Dn(null), z(i, {
|
|
300
|
+
id: Et(),
|
|
187
301
|
role: "system",
|
|
188
302
|
content: e instanceof Error ? e.message : "The change could not be approved.",
|
|
189
303
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
190
304
|
});
|
|
191
305
|
return;
|
|
192
306
|
}
|
|
193
|
-
|
|
307
|
+
Dn(null), Pn.current(k("pendingWrite.approvedPrompt", "I approved that change — go ahead."));
|
|
194
308
|
}
|
|
195
309
|
}, [
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
]), X =
|
|
200
|
-
let r = n.voiceSessionId !== void 0, i =
|
|
310
|
+
P,
|
|
311
|
+
z,
|
|
312
|
+
k
|
|
313
|
+
]), X = w(async (e, t = [], n = {}) => {
|
|
314
|
+
let r = n.voiceSessionId !== void 0, i = x.getState(), a = i.activeConversationId ?? F;
|
|
201
315
|
if (a) {
|
|
202
|
-
if (
|
|
316
|
+
if (Ne(i.processingByConversationId[a]?.status)) {
|
|
203
317
|
let r = i.processingByConversationId[a]?.messageId ?? null;
|
|
204
|
-
r &&
|
|
318
|
+
r && On.current.has(r) && (kn.current = {
|
|
205
319
|
conversationId: a,
|
|
206
320
|
content: e,
|
|
207
321
|
attachments: t,
|
|
@@ -209,11 +323,11 @@ var xt = ({ visible: xt = !0, writeAccess: St = "unknown" }) => {
|
|
|
209
323
|
});
|
|
210
324
|
return;
|
|
211
325
|
}
|
|
212
|
-
if (
|
|
326
|
+
if (bn.current.has(a)) return;
|
|
213
327
|
}
|
|
214
|
-
if (
|
|
215
|
-
let o = i.activeConversationId ? i.conversations.find((e) => e.id === i.activeConversationId) : void 0, s = i.autoRouting &&
|
|
216
|
-
intent: n.autoIntent ??
|
|
328
|
+
if (pn.current) return;
|
|
329
|
+
let o = i.activeConversationId ? i.conversations.find((e) => e.id === i.activeConversationId) : void 0, s = i.autoRouting && fn.current ? je({
|
|
330
|
+
intent: n.autoIntent ?? Oe(e),
|
|
217
331
|
dictated: r,
|
|
218
332
|
conversation: o ? {
|
|
219
333
|
mode: o.mode,
|
|
@@ -221,250 +335,255 @@ var xt = ({ visible: xt = !0, writeAccess: St = "unknown" }) => {
|
|
|
221
335
|
hasHistory: o.messages.length > 0 || !!o.backendSessionId
|
|
222
336
|
} : null
|
|
223
337
|
}) : null;
|
|
224
|
-
if (s &&
|
|
225
|
-
|
|
338
|
+
if (s && cn.current.find((e) => e.id === s.mode)?.writeCapable && !we(i.acknowledgedWriteModes, s.mode)) {
|
|
339
|
+
pn.current = {
|
|
226
340
|
content: e,
|
|
227
341
|
attachments: t,
|
|
228
342
|
options: n
|
|
229
|
-
},
|
|
343
|
+
}, gn(s.mode);
|
|
230
344
|
return;
|
|
231
345
|
}
|
|
232
|
-
let c = s ? s.mode : i.mode,
|
|
346
|
+
let c = s ? s.mode : i.mode, ee, d, p = F, m = p ? x.getState().conversations.find((e) => e.id === p) : void 0, ie = s?.action === "escalate" && o ? {
|
|
233
347
|
mode: o.mode,
|
|
234
348
|
backendSessionId: o.backendSessionId ?? null
|
|
235
349
|
} : null;
|
|
236
|
-
if (s) s.action === "new" || !o ?
|
|
350
|
+
if (s) s.action === "new" || !o ? p = R(void 0, c, { routedBy: "auto" }) : (p = o.id, H(p, c));
|
|
237
351
|
else {
|
|
238
352
|
let e = i.autoRouting ? { routedBy: "auto" } : void 0;
|
|
239
|
-
|
|
353
|
+
p ? m && m.mode !== c && (m.messages.length > 0 || m.backendSessionId) ? p = R(void 0, c, e) : m && m.mode !== c && (e ? H(p, c) : Vt(p, c)) : p = R(void 0, c, e);
|
|
240
354
|
}
|
|
241
|
-
if (!
|
|
242
|
-
|
|
243
|
-
let
|
|
244
|
-
accessToken:
|
|
245
|
-
workspaceToken:
|
|
246
|
-
userId:
|
|
247
|
-
organizationId:
|
|
248
|
-
},
|
|
249
|
-
id:
|
|
355
|
+
if (!p) return;
|
|
356
|
+
yn.current[p] = t;
|
|
357
|
+
let h = Xe(), g = {
|
|
358
|
+
accessToken: M(),
|
|
359
|
+
workspaceToken: N(),
|
|
360
|
+
userId: P,
|
|
361
|
+
organizationId: Ye()
|
|
362
|
+
}, ce = {
|
|
363
|
+
id: Et(),
|
|
250
364
|
role: "user",
|
|
251
365
|
content: e,
|
|
252
366
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
253
367
|
metadata: {
|
|
254
|
-
...t.length ? { attachments: t.map(
|
|
255
|
-
...
|
|
368
|
+
...t.length ? { attachments: t.map(ve) } : {},
|
|
369
|
+
...se(n.voiceSessionId)
|
|
256
370
|
}
|
|
257
371
|
};
|
|
258
|
-
|
|
259
|
-
let
|
|
260
|
-
|
|
261
|
-
id:
|
|
372
|
+
z(p, ce);
|
|
373
|
+
let _ = Et();
|
|
374
|
+
z(p, {
|
|
375
|
+
id: _,
|
|
262
376
|
role: "assistant",
|
|
263
377
|
content: "",
|
|
264
378
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
265
379
|
metadata: {
|
|
266
|
-
lang:
|
|
267
|
-
...
|
|
380
|
+
lang: Rt,
|
|
381
|
+
...se(n.voiceSessionId)
|
|
268
382
|
}
|
|
269
|
-
}),
|
|
383
|
+
}), We(_, {
|
|
270
384
|
channel: r ? "voice" : "chat",
|
|
271
385
|
mode: c,
|
|
272
|
-
product:
|
|
273
|
-
language:
|
|
274
|
-
device:
|
|
386
|
+
product: A,
|
|
387
|
+
language: Rt,
|
|
388
|
+
device: Ge(),
|
|
275
389
|
routedByAuto: !!s
|
|
276
|
-
}, n.voiceTiming),
|
|
277
|
-
let
|
|
278
|
-
|
|
390
|
+
}, n.voiceTiming), C(_, "accepted"), Kt(p, "provisioning", _, null);
|
|
391
|
+
let le = (e, t, r, i, a = Rt) => {
|
|
392
|
+
Wt(p, _, { content: ae(e) }), Gt(p, _, {
|
|
279
393
|
lang: a,
|
|
280
394
|
...t?.length ? { artifacts: t } : {},
|
|
281
395
|
...t?.length || r || i ? { mode: c } : {},
|
|
282
396
|
...r ? { sessionId: r } : {},
|
|
283
397
|
...i ? { sandboxId: i } : {},
|
|
284
|
-
...
|
|
398
|
+
...se(n.voiceSessionId)
|
|
285
399
|
});
|
|
286
|
-
},
|
|
287
|
-
|
|
288
|
-
let i = !1;
|
|
400
|
+
}, de = async (n = 1) => {
|
|
401
|
+
C(_, "attemptStarted");
|
|
402
|
+
let i = null, a = !1;
|
|
289
403
|
try {
|
|
290
|
-
let { sandboxId: n, sessionId:
|
|
291
|
-
|
|
292
|
-
|
|
404
|
+
let { sandboxId: n, sessionId: o, sessionIsNew: s, sandboxIsNew: f, sandboxProbed: m, sandboxAdopted: ie, deadSandboxProbe: se } = await Cn(p, _, c, h, g, { isAbandoned: () => Pe({
|
|
405
|
+
turnId: _,
|
|
406
|
+
abortRequested: On.current.has(_),
|
|
407
|
+
activeTurnId: x.getState().processingByConversationId[p]?.messageId ?? null
|
|
408
|
+
}).abandon });
|
|
409
|
+
i = n, C(_, "runtimeReady"), S(_, {
|
|
410
|
+
runtime: f ? "cold" : ie ? "adopted" : m ? "probed" : s ? "new-session" : "warm",
|
|
293
411
|
deadSandboxProbe: se
|
|
294
412
|
});
|
|
295
|
-
let
|
|
296
|
-
|
|
297
|
-
let
|
|
298
|
-
content:
|
|
413
|
+
let ce = Ee(x.getState().conversations.find((e) => e.id === p), e, s), de = await ze(() => u(n, h, o, c, g, { limit: 50 }), s);
|
|
414
|
+
Y(p, _, "streaming", "thinking");
|
|
415
|
+
let v = kt?.(), { prompt: fe, parts: he } = Ce({
|
|
416
|
+
content: ce ? `${ce}${e}` : e,
|
|
299
417
|
attachments: t,
|
|
300
|
-
limits:
|
|
301
|
-
wrapPrompt: (e) =>
|
|
302
|
-
requestBytes: (e, t) =>
|
|
418
|
+
limits: _e(ee),
|
|
419
|
+
wrapPrompt: (e) => At?.(c, e, It, Lt, r) ?? e,
|
|
420
|
+
requestBytes: (e, t) => ne({
|
|
303
421
|
sandboxId: n,
|
|
304
|
-
workspaceId:
|
|
305
|
-
sessionId:
|
|
422
|
+
workspaceId: h,
|
|
423
|
+
sessionId: o,
|
|
306
424
|
mode: c,
|
|
307
425
|
prompt: e,
|
|
308
426
|
parts: t,
|
|
309
|
-
pageContext:
|
|
310
|
-
authContext:
|
|
427
|
+
pageContext: v,
|
|
428
|
+
authContext: g
|
|
311
429
|
})
|
|
312
|
-
}), ge = he
|
|
313
|
-
|
|
430
|
+
}), ge = me(he), ve = ge > 0;
|
|
431
|
+
a = pe(t) > ge;
|
|
314
432
|
try {
|
|
315
|
-
await
|
|
433
|
+
await re(n, h, o, fe, c, v, g, he?.length ? { parts: he } : void 0);
|
|
316
434
|
} catch (e) {
|
|
317
|
-
if (!
|
|
318
|
-
await
|
|
435
|
+
if (!he || !Ze(e)) throw e;
|
|
436
|
+
await re(n, h, o, fe, c, v, g, void 0), a ||= ve;
|
|
319
437
|
}
|
|
320
|
-
|
|
321
|
-
let ye = null, be = !1, xe =
|
|
322
|
-
turnId:
|
|
323
|
-
abortRequested:
|
|
324
|
-
activeTurnId:
|
|
438
|
+
C(_, "promptSent");
|
|
439
|
+
let ye = null, be = !1, xe = Le, y = Re([], de), Se = Date.now() + d.streamBudgetMs, we = Date.now(), Te = Date.now(), b = () => Pe({
|
|
440
|
+
turnId: _,
|
|
441
|
+
abortRequested: On.current.has(_),
|
|
442
|
+
activeTurnId: x.getState().processingByConversationId[p]?.messageId ?? null
|
|
325
443
|
});
|
|
326
444
|
for (; Date.now() < Se;) {
|
|
327
|
-
let e =
|
|
445
|
+
let e = b();
|
|
328
446
|
if (e.abandon) {
|
|
329
|
-
e.clearProcessing &&
|
|
447
|
+
e.clearProcessing && qt(p);
|
|
330
448
|
return;
|
|
331
449
|
}
|
|
332
|
-
if (
|
|
450
|
+
if (y = Re(await u(n, h, o, c, g, {
|
|
333
451
|
limit: 50,
|
|
334
|
-
sinceMs:
|
|
335
|
-
}),
|
|
452
|
+
sinceMs: de
|
|
453
|
+
}), de, { accumulateNarration: d.accumulatesNarration }), Wt(p, _, { content: ae(y.content) }), y.hasRenderableOutput ? be || (be = !0, ye !== null && C(_, "lastQuietPoll", ye), C(_, "firstOutput")) : ye = qe(), d.accumulatesNarration) y.hasText && C(_, "firstText");
|
|
336
454
|
else {
|
|
337
|
-
let e =
|
|
338
|
-
xe = e.tracker, e.confirmedAt !== null &&
|
|
455
|
+
let e = Be(xe, y, qe());
|
|
456
|
+
xe = e.tracker, e.confirmedAt !== null && C(_, "firstText", e.confirmedAt);
|
|
339
457
|
}
|
|
340
|
-
if (
|
|
341
|
-
|
|
458
|
+
if (y.pendingWrite && Gt(p, _, { pendingWrite: y.pendingWrite }), y.done) {
|
|
459
|
+
C(_, "answerDone"), K.current.markVerified(n);
|
|
342
460
|
break;
|
|
343
461
|
}
|
|
344
|
-
Date.now() -
|
|
462
|
+
Date.now() - we > 3e4 && (await l(n, h, 600, g).catch(() => void 0), we = Date.now()), await new Promise((e) => setTimeout(e, ue(Date.now() - Te)));
|
|
345
463
|
}
|
|
346
|
-
let De =
|
|
347
|
-
if (
|
|
348
|
-
...
|
|
349
|
-
content:
|
|
350
|
-
}),
|
|
351
|
-
...
|
|
352
|
-
content: `${
|
|
353
|
-
}),
|
|
354
|
-
|
|
464
|
+
let De = d.producesArtifacts ? await te(n, h, o, c, g).then((e) => e).catch(() => []) : void 0;
|
|
465
|
+
if (y.usedTools !== void 0 && S(_, { usedTools: y.usedTools }), y.done || (S(_, { outcome: "timedOut" }), y = {
|
|
466
|
+
...y,
|
|
467
|
+
content: oe(y.content, c, k, ee)
|
|
468
|
+
}), a && (y = {
|
|
469
|
+
...y,
|
|
470
|
+
content: `${y.content}\n\n${k("attachments.imagesNotSent", "_Your photo was too large to include with this message, so the answer above is from the text and the file link only. Try a smaller or more tightly cropped photo._")}`
|
|
471
|
+
}), le(y.content, De, o, n), y.tokens) {
|
|
472
|
+
Wt(p, _, { tokens: y.tokens });
|
|
355
473
|
try {
|
|
356
|
-
await
|
|
357
|
-
workspaceId:
|
|
358
|
-
sessionId:
|
|
359
|
-
messageId:
|
|
360
|
-
model:
|
|
361
|
-
tokens:
|
|
362
|
-
}),
|
|
474
|
+
await jt?.({
|
|
475
|
+
workspaceId: h,
|
|
476
|
+
sessionId: o,
|
|
477
|
+
messageId: y.messageId,
|
|
478
|
+
model: y.model,
|
|
479
|
+
tokens: y.tokens
|
|
480
|
+
}), _t(A);
|
|
363
481
|
} catch {}
|
|
364
482
|
}
|
|
365
|
-
let
|
|
366
|
-
if (
|
|
367
|
-
|
|
483
|
+
let Oe = b();
|
|
484
|
+
if (Oe.abandon) {
|
|
485
|
+
Oe.clearProcessing && qt(p);
|
|
368
486
|
return;
|
|
369
487
|
}
|
|
370
|
-
|
|
488
|
+
C(_, "complete"), S(_, { outcome: "answered" }), Kt(p, "complete", _, null);
|
|
371
489
|
} catch (e) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
490
|
+
K.current.invalidate(i ?? x.getState().sandboxesByMode[c]?.sandboxId ?? null);
|
|
491
|
+
let t = Pe({
|
|
492
|
+
turnId: _,
|
|
493
|
+
abortRequested: On.current.has(_),
|
|
494
|
+
activeTurnId: x.getState().processingByConversationId[p]?.messageId ?? null
|
|
376
495
|
});
|
|
377
496
|
if (t.abandon) {
|
|
378
|
-
t.clearProcessing &&
|
|
497
|
+
t.clearProcessing && qt(p);
|
|
379
498
|
return;
|
|
380
499
|
}
|
|
381
|
-
if (n === 1 &&
|
|
382
|
-
let e =
|
|
383
|
-
return e && (
|
|
500
|
+
if (n === 1 && Qe(e)) {
|
|
501
|
+
let e = i ?? x.getState().sandboxesByMode[c]?.sandboxId ?? null;
|
|
502
|
+
return e && (q.current.add(e), K.current.invalidate(e)), Yt(p), V(c), Ut(p, _, ""), Gt(p, _, { pendingWrite: void 0 }), Ke(_), de(2);
|
|
384
503
|
}
|
|
385
504
|
throw e;
|
|
386
505
|
}
|
|
387
|
-
},
|
|
388
|
-
|
|
506
|
+
}, v = p;
|
|
507
|
+
bn.current.add(v);
|
|
389
508
|
try {
|
|
390
|
-
if (!
|
|
509
|
+
if (!h) throw Object.assign(/* @__PURE__ */ Error("Assistant backend is unavailable without an active workspace context."), { extensions: {
|
|
391
510
|
code: "UNAUTHENTICATED",
|
|
392
511
|
authFailure: "WORKSPACE_CONTEXT_MISSING"
|
|
393
512
|
} });
|
|
394
|
-
let e = await
|
|
395
|
-
|
|
396
|
-
let t =
|
|
513
|
+
let e = await Se(c, () => cn.current.find((e) => e.id === c), G);
|
|
514
|
+
ee = e.config, d = e.capabilities;
|
|
515
|
+
let t = Te(c, ee, x.getState().acknowledgedWriteModes, {
|
|
397
516
|
dictated: r,
|
|
398
|
-
confirmsWrites:
|
|
517
|
+
confirmsWrites: f(c)
|
|
399
518
|
});
|
|
400
|
-
if (t) throw new
|
|
401
|
-
|
|
519
|
+
if (t) throw new ye(t, t === "confirm-write-mode" ? "Write mode not confirmed" : "Voice in a write mode");
|
|
520
|
+
C(_, "cleared"), await de();
|
|
402
521
|
} catch (e) {
|
|
403
|
-
K.current.invalidate(
|
|
404
|
-
let t =
|
|
405
|
-
|
|
406
|
-
let r =
|
|
407
|
-
|
|
408
|
-
lang: r.translated ?
|
|
409
|
-
...
|
|
522
|
+
K.current.invalidate(x.getState().sandboxesByMode[c]?.sandboxId ?? null);
|
|
523
|
+
let t = be(e);
|
|
524
|
+
S(_, { outcome: t.kind === "temporary" ? "failed" : "refused" }), t.offersUpgrade && gt(A, "sandbox");
|
|
525
|
+
let r = xe(t, k);
|
|
526
|
+
Kt(p, "error", _, r.headline), Wt(p, _, { content: r.text }), Gt(p, _, {
|
|
527
|
+
lang: r.translated ? Mt : "en",
|
|
528
|
+
...se(n.voiceSessionId)
|
|
410
529
|
});
|
|
411
530
|
} finally {
|
|
412
|
-
|
|
413
|
-
let e =
|
|
414
|
-
t && (
|
|
415
|
-
let n =
|
|
416
|
-
|
|
531
|
+
bn.current.delete(v), S(_, { outcome: "stopped" }), C(_, "complete");
|
|
532
|
+
let e = x.getState(), t = ke(ie, c, e.conversations.find((e) => e.id === v), (t) => !!e.sandboxesByMode[t]?.sandboxId);
|
|
533
|
+
t && (H(v, t.mode), t.backendSessionId && Jt(v, t.backendSessionId));
|
|
534
|
+
let n = kn.current;
|
|
535
|
+
kn.current = null, n && n.conversationId === v && Pn.current(n.content, n.attachments, n.options);
|
|
417
536
|
}
|
|
418
537
|
}, [
|
|
538
|
+
F,
|
|
539
|
+
z,
|
|
540
|
+
At,
|
|
541
|
+
Yt,
|
|
542
|
+
V,
|
|
543
|
+
zt,
|
|
544
|
+
R,
|
|
545
|
+
Cn,
|
|
546
|
+
kt,
|
|
419
547
|
M,
|
|
420
|
-
|
|
421
|
-
wt,
|
|
422
|
-
Ut,
|
|
548
|
+
N,
|
|
423
549
|
Wt,
|
|
424
|
-
Pt,
|
|
425
|
-
F,
|
|
426
|
-
hn,
|
|
427
|
-
Ct,
|
|
428
550
|
A,
|
|
429
|
-
|
|
430
|
-
zt,
|
|
431
|
-
O,
|
|
432
|
-
U,
|
|
433
|
-
Tt,
|
|
434
|
-
Mt,
|
|
435
|
-
Dt,
|
|
436
|
-
Nt,
|
|
551
|
+
G,
|
|
437
552
|
jt,
|
|
438
|
-
|
|
439
|
-
|
|
553
|
+
Lt,
|
|
554
|
+
Mt,
|
|
555
|
+
Rt,
|
|
440
556
|
It,
|
|
441
|
-
|
|
557
|
+
H,
|
|
558
|
+
Jt,
|
|
442
559
|
Vt,
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
560
|
+
Kt,
|
|
561
|
+
qt,
|
|
562
|
+
k,
|
|
563
|
+
Y,
|
|
564
|
+
Ut,
|
|
565
|
+
P
|
|
566
|
+
]), Mn = w((e, t) => {
|
|
448
567
|
X(e, [], t ? { autoIntent: t } : {});
|
|
449
|
-
}, [X]),
|
|
450
|
-
let e = [...
|
|
568
|
+
}, [X]), Nn = w(() => {
|
|
569
|
+
let e = [...tn.chat].reverse().find((e) => e.role === "user"), t = F ? yn.current[F] ?? [] : [];
|
|
451
570
|
e && X(e.content, t);
|
|
452
571
|
}, [
|
|
453
|
-
|
|
572
|
+
nn,
|
|
454
573
|
X,
|
|
455
|
-
|
|
456
|
-
]),
|
|
457
|
-
|
|
458
|
-
|
|
574
|
+
F
|
|
575
|
+
]), Pn = D(X);
|
|
576
|
+
T(() => {
|
|
577
|
+
Pn.current = X;
|
|
459
578
|
}, [X]);
|
|
460
|
-
let
|
|
461
|
-
if (
|
|
462
|
-
for (let e =
|
|
463
|
-
let t =
|
|
464
|
-
if (t?.role !== "assistant" || !
|
|
465
|
-
let n =
|
|
579
|
+
let Fn = E(() => {
|
|
580
|
+
if (rn) return null;
|
|
581
|
+
for (let e = nn.length - 1; e >= 0; --e) {
|
|
582
|
+
let t = nn[e];
|
|
583
|
+
if (t?.role !== "assistant" || !h(t) || On.current.has(t.id)) continue;
|
|
584
|
+
let n = Ie(t, U, k);
|
|
466
585
|
if (n.kind !== "output") return null;
|
|
467
|
-
let r =
|
|
586
|
+
let r = Ve(n.text).text.trim();
|
|
468
587
|
return r ? {
|
|
469
588
|
id: t.id,
|
|
470
589
|
text: r
|
|
@@ -472,224 +591,227 @@ var xt = ({ visible: xt = !0, writeAccess: St = "unknown" }) => {
|
|
|
472
591
|
}
|
|
473
592
|
return null;
|
|
474
593
|
}, [
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
]),
|
|
594
|
+
nn,
|
|
595
|
+
rn,
|
|
596
|
+
U,
|
|
597
|
+
k
|
|
598
|
+
]), In = E(() => Fn ? de(Fn.text) : null, [Fn]), Ln = tn.chat, Z = E(() => tn.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
|
|
480
599
|
id: e.id,
|
|
481
600
|
role: e.role,
|
|
482
|
-
text:
|
|
483
|
-
sessionId:
|
|
601
|
+
text: Ue(e, U, k),
|
|
602
|
+
sessionId: g(e),
|
|
484
603
|
timestamp: e.timestamp
|
|
485
604
|
})).filter((e) => e.text.length > 0), [
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
]),
|
|
605
|
+
tn.voice,
|
|
606
|
+
U,
|
|
607
|
+
k
|
|
608
|
+
]), Rn = w(() => {
|
|
490
609
|
if (Z.length === 0) return;
|
|
491
610
|
let e = /* @__PURE__ */ new Date();
|
|
492
|
-
|
|
493
|
-
title:
|
|
494
|
-
savedAt:
|
|
495
|
-
session:
|
|
496
|
-
earlier:
|
|
497
|
-
you:
|
|
498
|
-
assistant:
|
|
499
|
-
}, e),
|
|
611
|
+
it(_(Z, {
|
|
612
|
+
title: k("voiceSession.transcript", "Voice conversation"),
|
|
613
|
+
savedAt: k("voiceSession.savedAt", "Saved"),
|
|
614
|
+
session: k("voiceSession.sessionLabel", "Session"),
|
|
615
|
+
earlier: k("voiceSession.earlierLabel", "Earlier"),
|
|
616
|
+
you: k("voiceSession.speakerYou", "You"),
|
|
617
|
+
assistant: k("voiceSession.speakerAssistant", "Assistant")
|
|
618
|
+
}, e), le(A, e), "text/markdown");
|
|
500
619
|
}, [
|
|
501
|
-
|
|
620
|
+
A,
|
|
502
621
|
Z,
|
|
503
|
-
|
|
504
|
-
]), Q =
|
|
505
|
-
|
|
506
|
-
let $ =
|
|
507
|
-
onSubmit:
|
|
622
|
+
k
|
|
623
|
+
]), Q = vt({ perFileChars: mn }), zn = D(Q);
|
|
624
|
+
zn.current = Q;
|
|
625
|
+
let $ = Je({
|
|
626
|
+
onSubmit: w((e, t, n) => {
|
|
508
627
|
let r = () => {
|
|
509
|
-
let r =
|
|
628
|
+
let r = zn.current, i = he(r.attachments), a = {
|
|
510
629
|
...n,
|
|
511
|
-
handedOver:
|
|
630
|
+
handedOver: qe()
|
|
512
631
|
};
|
|
513
|
-
|
|
632
|
+
Pn.current(e, i, {
|
|
514
633
|
voiceSessionId: t,
|
|
515
634
|
voiceTiming: a
|
|
516
635
|
}), r.clear();
|
|
517
636
|
};
|
|
518
|
-
if (!
|
|
637
|
+
if (!zn.current.isBusy) {
|
|
519
638
|
r();
|
|
520
639
|
return;
|
|
521
640
|
}
|
|
522
641
|
let i = Date.now(), a = window.setInterval(() => {
|
|
523
|
-
|
|
642
|
+
zn.current.isBusy && Date.now() - i < Tt || (window.clearInterval(a), r());
|
|
524
643
|
}, 200);
|
|
525
644
|
}, []),
|
|
526
|
-
latestReply:
|
|
527
|
-
language:
|
|
528
|
-
}),
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
645
|
+
latestReply: Fn,
|
|
646
|
+
language: v(Nt, Mt).tag
|
|
647
|
+
}), Bn = $.start, Vn = w(() => {
|
|
648
|
+
wn(!0), Bn();
|
|
649
|
+
}, [wn, Bn]), Hn = E(() => (en?.messages ?? []).reduce((e, t) => Math.max(e, t.metadata?.continuedVoiceTurns ?? 0), 0), [en?.messages]), Un = He(tn.voice, U, k), Wn = Un > Hn, Gn = w(() => {
|
|
650
|
+
let e = x.getState().activeConversationId;
|
|
651
|
+
!e || Z.length === 0 || (z(e, {
|
|
652
|
+
id: Et(),
|
|
532
653
|
role: "system",
|
|
533
|
-
content:
|
|
534
|
-
intro:
|
|
535
|
-
nothing:
|
|
536
|
-
more: (e) =>
|
|
654
|
+
content: ce(Z.slice(Hn), {
|
|
655
|
+
intro: k("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
|
|
656
|
+
nothing: k("voiceSession.continuedNothing", "Continued from a voice conversation."),
|
|
657
|
+
more: (e) => k("voiceSession.continuedMore", "…and {{count}} more", { count: e })
|
|
537
658
|
}),
|
|
538
659
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
539
|
-
metadata: { continuedVoiceTurns:
|
|
540
|
-
}),
|
|
660
|
+
metadata: { continuedVoiceTurns: Un }
|
|
661
|
+
}), vn(!1), $.end());
|
|
541
662
|
}, [
|
|
542
663
|
Z,
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
664
|
+
Un,
|
|
665
|
+
Hn,
|
|
666
|
+
z,
|
|
667
|
+
k,
|
|
547
668
|
$
|
|
548
|
-
]),
|
|
549
|
-
|
|
550
|
-
$.active && (
|
|
669
|
+
]), Kn = D(0);
|
|
670
|
+
T(() => {
|
|
671
|
+
$.active && (Kn.current = Un);
|
|
551
672
|
}, [$.active]);
|
|
552
|
-
let
|
|
553
|
-
let e =
|
|
554
|
-
$.end(), e &&
|
|
555
|
-
}, [
|
|
556
|
-
|
|
557
|
-
(!
|
|
673
|
+
let qn = w(() => {
|
|
674
|
+
let e = Un > Kn.current;
|
|
675
|
+
$.end(), e && vn(!0);
|
|
676
|
+
}, [Un, $]);
|
|
677
|
+
T(() => {
|
|
678
|
+
(!Dt || !xn) && $.active && $.end();
|
|
558
679
|
}, [
|
|
559
|
-
|
|
560
|
-
|
|
680
|
+
Dt,
|
|
681
|
+
xn,
|
|
561
682
|
$
|
|
562
|
-
]),
|
|
563
|
-
$.active || (
|
|
564
|
-
}, [$.active]),
|
|
565
|
-
let e =
|
|
566
|
-
return e &&
|
|
683
|
+
]), T(() => {
|
|
684
|
+
$.active || (zn.current.clear(), kn.current = null);
|
|
685
|
+
}, [$.active]), T(() => {
|
|
686
|
+
let e = x.getState().consumePendingPrompt();
|
|
687
|
+
return e && Pn.current(e), x.subscribe((e, t) => {
|
|
567
688
|
if (e.pendingPrompt && e.pendingPrompt !== t.pendingPrompt) {
|
|
568
|
-
let e =
|
|
569
|
-
e &&
|
|
689
|
+
let e = x.getState().consumePendingPrompt();
|
|
690
|
+
e && Pn.current(e);
|
|
570
691
|
}
|
|
571
692
|
});
|
|
572
693
|
}, []);
|
|
573
|
-
let
|
|
574
|
-
let t =
|
|
694
|
+
let Jn = w((e) => {
|
|
695
|
+
let t = F ? x.getState().conversations.find((e) => e.id === F) : void 0;
|
|
575
696
|
if (t && (t.messages.length > 0 || t.backendSessionId)) {
|
|
576
697
|
if (t.mode !== e) {
|
|
577
|
-
let t =
|
|
578
|
-
t ?
|
|
698
|
+
let t = x.getState().conversations.find((t) => t.mode === e && t.messages.length === 0 && !t.backendSessionId && !x.getState().processingByConversationId[t.id]);
|
|
699
|
+
t ? Ht(t.id) : R(void 0, e);
|
|
579
700
|
}
|
|
580
|
-
} else
|
|
581
|
-
let n =
|
|
582
|
-
n ?
|
|
701
|
+
} else F && Vt(F, e);
|
|
702
|
+
let n = x.getState().activeConversationId;
|
|
703
|
+
n ? Vt(n, e) : $t(!1), L(e);
|
|
583
704
|
}, [
|
|
584
|
-
M,
|
|
585
705
|
F,
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
706
|
+
R,
|
|
707
|
+
Ht,
|
|
708
|
+
$t,
|
|
709
|
+
Vt,
|
|
710
|
+
L
|
|
711
|
+
]), Yn = w(() => {
|
|
712
|
+
let e = x.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0;
|
|
592
713
|
if (!t) {
|
|
593
|
-
|
|
714
|
+
$t(!0), L(b);
|
|
594
715
|
return;
|
|
595
716
|
}
|
|
596
717
|
if (t.routedBy === "auto") {
|
|
597
|
-
|
|
718
|
+
$t(!0);
|
|
598
719
|
return;
|
|
599
720
|
}
|
|
600
721
|
if (t.messages.length === 0 && !t.backendSessionId) {
|
|
601
|
-
|
|
722
|
+
H(t.id, b);
|
|
602
723
|
return;
|
|
603
724
|
}
|
|
604
725
|
let n = e.conversations.find((t) => t.routedBy === "auto" && t.messages.length === 0 && !t.backendSessionId && !e.processingByConversationId[t.id]);
|
|
605
|
-
n ? (
|
|
726
|
+
n ? (Ht(n.id), H(n.id, b)) : R(void 0, b, { routedBy: "auto" });
|
|
606
727
|
}, [
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
]),
|
|
613
|
-
if (
|
|
614
|
-
|
|
728
|
+
R,
|
|
729
|
+
H,
|
|
730
|
+
Ht,
|
|
731
|
+
$t,
|
|
732
|
+
L
|
|
733
|
+
]), Xn = w((e) => {
|
|
734
|
+
if (j.find((t) => t.id === e)?.writeCapable && !we(x.getState().acknowledgedWriteModes, e)) {
|
|
735
|
+
gn(e);
|
|
615
736
|
return;
|
|
616
737
|
}
|
|
617
|
-
|
|
618
|
-
}, [
|
|
619
|
-
let e =
|
|
620
|
-
if (
|
|
621
|
-
let t =
|
|
622
|
-
if (
|
|
623
|
-
|
|
738
|
+
Jn(e);
|
|
739
|
+
}, [Jn, j]), Zn = w(() => {
|
|
740
|
+
let e = hn;
|
|
741
|
+
if (gn(null), !e) return;
|
|
742
|
+
let t = pn.current;
|
|
743
|
+
if (pn.current = null, t) {
|
|
744
|
+
Zt(e), X(t.content, t.attachments, t.options);
|
|
624
745
|
return;
|
|
625
746
|
}
|
|
626
|
-
|
|
747
|
+
Zt(e), Jn(e);
|
|
627
748
|
}, [
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
749
|
+
hn,
|
|
750
|
+
Zt,
|
|
751
|
+
Jn,
|
|
631
752
|
X
|
|
632
|
-
]),
|
|
633
|
-
|
|
634
|
-
let e =
|
|
635
|
-
|
|
753
|
+
]), Qn = hn === null ? void 0 : j.find((e) => e.id === hn) ?? { id: hn }, $n = w(() => {
|
|
754
|
+
gn(null);
|
|
755
|
+
let e = pn.current;
|
|
756
|
+
pn.current = null, e && X(e.content, e.attachments, {
|
|
636
757
|
...e.options,
|
|
637
758
|
autoIntent: "read"
|
|
638
759
|
});
|
|
639
760
|
}, [X]);
|
|
640
|
-
return /* @__PURE__ */
|
|
761
|
+
return /* @__PURE__ */ Ct("div", {
|
|
641
762
|
className: "relative flex flex-1 flex-col overflow-hidden",
|
|
642
763
|
children: [
|
|
643
|
-
/* @__PURE__ */
|
|
764
|
+
/* @__PURE__ */ Ct("div", {
|
|
644
765
|
className: "contents",
|
|
645
766
|
inert: $.active || void 0,
|
|
646
767
|
children: [
|
|
647
|
-
Z.length > 0 && !$.active ? /* @__PURE__ */
|
|
768
|
+
Z.length > 0 && !$.active ? /* @__PURE__ */ O(nt, {
|
|
648
769
|
count: Z.length,
|
|
649
|
-
onOpenTranscript: () =>
|
|
770
|
+
onOpenTranscript: () => vn(!0)
|
|
650
771
|
}) : null,
|
|
651
|
-
|
|
652
|
-
mode:
|
|
653
|
-
onSuggestionClick:
|
|
654
|
-
explainsAuto:
|
|
655
|
-
suggestions:
|
|
656
|
-
}) : /* @__PURE__ */
|
|
772
|
+
Ln.length === 0 ? /* @__PURE__ */ O(at, {
|
|
773
|
+
mode: I,
|
|
774
|
+
onSuggestionClick: Mn,
|
|
775
|
+
explainsAuto: dn,
|
|
776
|
+
suggestions: dn && I === "assistant" ? De(j.find((e) => e.id === "assistant")?.suggestions ?? [], j.find((e) => e.id === "api-calls")?.suggestions ?? []) : void 0
|
|
777
|
+
}) : /* @__PURE__ */ O("div", {
|
|
657
778
|
className: "flex min-h-0 flex-1 flex-col",
|
|
658
|
-
children: /* @__PURE__ */
|
|
659
|
-
onApprovePendingWrite:
|
|
660
|
-
approvingWriteRef:
|
|
661
|
-
messages:
|
|
662
|
-
processing:
|
|
663
|
-
streamingMessageId:
|
|
664
|
-
failedMessageId:
|
|
665
|
-
onRetry:
|
|
779
|
+
children: /* @__PURE__ */ O(ot, {
|
|
780
|
+
onApprovePendingWrite: jn,
|
|
781
|
+
approvingWriteRef: En,
|
|
782
|
+
messages: Ln,
|
|
783
|
+
processing: U ?? null,
|
|
784
|
+
streamingMessageId: an,
|
|
785
|
+
failedMessageId: on,
|
|
786
|
+
onRetry: Nn
|
|
666
787
|
})
|
|
667
788
|
}),
|
|
668
|
-
/* @__PURE__ */
|
|
669
|
-
onStartVoiceSession: $.available &&
|
|
789
|
+
/* @__PURE__ */ O(yt, {
|
|
790
|
+
onStartVoiceSession: $.available && xn ? Vn : void 0,
|
|
670
791
|
onSend: (e, t) => void X(e, t),
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
792
|
+
onDraftStart: Tn,
|
|
793
|
+
disabled: rn,
|
|
794
|
+
placeholder: I === "api-calls" ? k("chatArea.placeholderActions", "What would you like me to do?") : k("chatArea.placeholderGeneral", "Ask me anything…"),
|
|
795
|
+
mode: I,
|
|
796
|
+
writeAccessDenied: Ot === "denied" && !!J?.writeCapable,
|
|
797
|
+
availableModes: ln,
|
|
798
|
+
attachmentCharsPerFile: mn,
|
|
799
|
+
onModeChange: Xn,
|
|
800
|
+
auto: un ? {
|
|
801
|
+
active: dn,
|
|
802
|
+
onSelect: Yn
|
|
681
803
|
} : void 0
|
|
682
804
|
})
|
|
683
805
|
]
|
|
684
806
|
}),
|
|
685
|
-
|
|
807
|
+
_n && !$.active ? /* @__PURE__ */ O(rt, {
|
|
686
808
|
turns: Z,
|
|
687
|
-
onClose: () =>
|
|
688
|
-
onSave:
|
|
689
|
-
onContinueInChat:
|
|
809
|
+
onClose: () => vn(!1),
|
|
810
|
+
onSave: Rn,
|
|
811
|
+
onContinueInChat: Wn ? Gn : void 0,
|
|
690
812
|
closeOnEscape: !0
|
|
691
813
|
}) : null,
|
|
692
|
-
$.active && /* @__PURE__ */
|
|
814
|
+
$.active && /* @__PURE__ */ O(st, {
|
|
693
815
|
session: $.session,
|
|
694
816
|
notice: $.notice,
|
|
695
817
|
capturing: $.capturing,
|
|
@@ -703,24 +825,24 @@ var xt = ({ visible: xt = !0, writeAccess: St = "unknown" }) => {
|
|
|
703
825
|
onRetryAttachment: Q.retry,
|
|
704
826
|
canAttachMore: Q.canAddMore,
|
|
705
827
|
preparingAttachments: Q.preparingCount,
|
|
706
|
-
onSaveTranscript:
|
|
707
|
-
onContinueInChat:
|
|
828
|
+
onSaveTranscript: Rn,
|
|
829
|
+
onContinueInChat: Gn,
|
|
708
830
|
onInterrupt: () => {
|
|
709
|
-
$.interrupt(),
|
|
831
|
+
$.interrupt(), An();
|
|
710
832
|
},
|
|
711
|
-
spoken:
|
|
833
|
+
spoken: In,
|
|
712
834
|
onToggleMute: $.toggleMute,
|
|
713
|
-
onEnd:
|
|
835
|
+
onEnd: qn
|
|
714
836
|
}),
|
|
715
|
-
/* @__PURE__ */
|
|
716
|
-
open:
|
|
717
|
-
mode:
|
|
718
|
-
currentMode:
|
|
719
|
-
onConfirm:
|
|
720
|
-
onCancel:
|
|
837
|
+
/* @__PURE__ */ O(xt, {
|
|
838
|
+
open: hn !== null,
|
|
839
|
+
mode: Qn,
|
|
840
|
+
currentMode: J ?? { id: I },
|
|
841
|
+
onConfirm: Zn,
|
|
842
|
+
onCancel: $n
|
|
721
843
|
})
|
|
722
844
|
]
|
|
723
845
|
});
|
|
724
846
|
};
|
|
725
847
|
//#endregion
|
|
726
|
-
export {
|
|
848
|
+
export { Dt as AssistantChatArea };
|