@burdenoff/fe-libs 2026.925.5 → 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/turnTimeline.d.ts +7 -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 +577 -487
- 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 +15 -14
- package/package.json +1 -1
|
@@ -4,231 +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 { isMultimodalBodyRejection as
|
|
32
|
-
import { createReadinessTracker as
|
|
33
|
-
import { AssistantSpokenTurnsNotice as
|
|
34
|
-
import { VoiceTranscriptDrawer as
|
|
35
|
-
import { downloadFile as
|
|
36
|
-
import { AssistantEmptyState as
|
|
37
|
-
import { AssistantMessageList as
|
|
38
|
-
import { AssistantVoiceSession as
|
|
39
|
-
import { useAssistantApiAccess as
|
|
40
|
-
import { useConversationTurns as
|
|
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);
|
|
124
136
|
}
|
|
125
|
-
|
|
137
|
+
l("createRequested");
|
|
138
|
+
let a = o?.beginCreate();
|
|
139
|
+
try {
|
|
140
|
+
d = await s(A, e, t, bt(), wt, n);
|
|
141
|
+
} finally {
|
|
142
|
+
a?.();
|
|
143
|
+
}
|
|
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
|
-
|
|
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);
|
|
131
172
|
if (e.mode !== r) throw Error(`Session mode mismatch: expected ${r}, received ${e.mode}`);
|
|
132
173
|
} catch {
|
|
133
|
-
|
|
174
|
+
Yt(t), m = null;
|
|
134
175
|
}
|
|
135
|
-
if (!
|
|
136
|
-
|
|
137
|
-
let
|
|
176
|
+
if (!m) {
|
|
177
|
+
Y(t, n, "connecting", "preparingSession");
|
|
178
|
+
let s;
|
|
138
179
|
try {
|
|
139
|
-
|
|
140
|
-
} catch (
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
let
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
let
|
|
147
|
-
...
|
|
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,
|
|
148
189
|
trustCache: !1
|
|
149
190
|
});
|
|
150
|
-
return
|
|
151
|
-
...
|
|
152
|
-
sandboxProbed:
|
|
153
|
-
sandboxAdopted:
|
|
154
|
-
deadSandboxProbe:
|
|
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
|
|
155
196
|
};
|
|
156
197
|
}
|
|
157
198
|
}
|
|
158
|
-
throw
|
|
199
|
+
throw s;
|
|
159
200
|
}
|
|
160
|
-
|
|
201
|
+
m = s.sessionId, Jt(t, m), ie = !0;
|
|
161
202
|
}
|
|
162
203
|
return {
|
|
163
204
|
sandboxId: l,
|
|
164
|
-
sessionId:
|
|
165
|
-
sessionIsNew:
|
|
166
|
-
sandboxIsNew:
|
|
167
|
-
sandboxProbed:
|
|
168
|
-
sandboxAdopted:
|
|
169
|
-
deadSandboxProbe:
|
|
205
|
+
sessionId: m,
|
|
206
|
+
sessionIsNew: ie,
|
|
207
|
+
sandboxIsNew: te,
|
|
208
|
+
sandboxProbed: u,
|
|
209
|
+
sandboxAdopted: f,
|
|
210
|
+
deadSandboxProbe: ne
|
|
170
211
|
};
|
|
171
212
|
}, [
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
let e = b.getState(), t = e.activeConversationId;
|
|
213
|
+
Sn,
|
|
214
|
+
Yt,
|
|
215
|
+
V,
|
|
216
|
+
A,
|
|
217
|
+
Jt,
|
|
218
|
+
Y
|
|
219
|
+
]), wn = w((e) => {
|
|
220
|
+
let t = Xe();
|
|
181
221
|
if (!t) return;
|
|
182
|
-
let n =
|
|
183
|
-
|
|
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({
|
|
184
271
|
interruptedTurnId: r,
|
|
185
272
|
activeTurnId: r,
|
|
186
|
-
alreadyRequested: r ?
|
|
273
|
+
alreadyRequested: r ? On.current.has(r) : !1
|
|
187
274
|
}).send || !r) return;
|
|
188
|
-
|
|
189
|
-
let i =
|
|
275
|
+
On.current.add(r);
|
|
276
|
+
let i = Me(e), o = Xe(), s = e.conversations.find((e) => e.id === t)?.backendSessionId;
|
|
190
277
|
!i || !o || !s || a(i.sandboxId, o, s, i.mode, {
|
|
191
|
-
accessToken:
|
|
192
|
-
workspaceToken:
|
|
193
|
-
userId:
|
|
194
|
-
organizationId:
|
|
278
|
+
accessToken: M(),
|
|
279
|
+
workspaceToken: N(),
|
|
280
|
+
userId: P,
|
|
281
|
+
organizationId: Ye()
|
|
195
282
|
});
|
|
196
283
|
}, [
|
|
284
|
+
P,
|
|
197
285
|
M,
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
let t = b.getState(), n = Ne(t), r = Ze(), i = t.activeConversationId;
|
|
286
|
+
N
|
|
287
|
+
]), jn = w(async (e) => {
|
|
288
|
+
let t = x.getState(), n = Me(t), r = Xe(), i = t.activeConversationId;
|
|
202
289
|
if (!(!n || !r || !i)) {
|
|
203
|
-
|
|
290
|
+
Dn(e);
|
|
204
291
|
try {
|
|
205
292
|
await o(n.sandboxId, r, e, n.mode, {
|
|
206
|
-
accessToken:
|
|
207
|
-
workspaceToken:
|
|
208
|
-
userId:
|
|
209
|
-
organizationId:
|
|
293
|
+
accessToken: M(),
|
|
294
|
+
workspaceToken: N(),
|
|
295
|
+
userId: P,
|
|
296
|
+
organizationId: Ye()
|
|
210
297
|
});
|
|
211
298
|
} catch (e) {
|
|
212
|
-
|
|
213
|
-
id:
|
|
299
|
+
Dn(null), z(i, {
|
|
300
|
+
id: Et(),
|
|
214
301
|
role: "system",
|
|
215
302
|
content: e instanceof Error ? e.message : "The change could not be approved.",
|
|
216
303
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
217
304
|
});
|
|
218
305
|
return;
|
|
219
306
|
}
|
|
220
|
-
|
|
307
|
+
Dn(null), Pn.current(k("pendingWrite.approvedPrompt", "I approved that change — go ahead."));
|
|
221
308
|
}
|
|
222
309
|
}, [
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
]), X =
|
|
227
|
-
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;
|
|
228
315
|
if (a) {
|
|
229
|
-
if (
|
|
316
|
+
if (Ne(i.processingByConversationId[a]?.status)) {
|
|
230
317
|
let r = i.processingByConversationId[a]?.messageId ?? null;
|
|
231
|
-
r &&
|
|
318
|
+
r && On.current.has(r) && (kn.current = {
|
|
232
319
|
conversationId: a,
|
|
233
320
|
content: e,
|
|
234
321
|
attachments: t,
|
|
@@ -236,11 +323,11 @@ var St = ({ visible: St = !0, writeAccess: Ct = "unknown" }) => {
|
|
|
236
323
|
});
|
|
237
324
|
return;
|
|
238
325
|
}
|
|
239
|
-
if (
|
|
326
|
+
if (bn.current.has(a)) return;
|
|
240
327
|
}
|
|
241
|
-
if (
|
|
242
|
-
let o = i.activeConversationId ? i.conversations.find((e) => e.id === i.activeConversationId) : void 0, s = i.autoRouting &&
|
|
243
|
-
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),
|
|
244
331
|
dictated: r,
|
|
245
332
|
conversation: o ? {
|
|
246
333
|
mode: o.mode,
|
|
@@ -248,255 +335,255 @@ var St = ({ visible: St = !0, writeAccess: Ct = "unknown" }) => {
|
|
|
248
335
|
hasHistory: o.messages.length > 0 || !!o.backendSessionId
|
|
249
336
|
} : null
|
|
250
337
|
}) : null;
|
|
251
|
-
if (s &&
|
|
252
|
-
|
|
338
|
+
if (s && cn.current.find((e) => e.id === s.mode)?.writeCapable && !we(i.acknowledgedWriteModes, s.mode)) {
|
|
339
|
+
pn.current = {
|
|
253
340
|
content: e,
|
|
254
341
|
attachments: t,
|
|
255
342
|
options: n
|
|
256
|
-
},
|
|
343
|
+
}, gn(s.mode);
|
|
257
344
|
return;
|
|
258
345
|
}
|
|
259
|
-
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 ? {
|
|
260
347
|
mode: o.mode,
|
|
261
348
|
backendSessionId: o.backendSessionId ?? null
|
|
262
349
|
} : null;
|
|
263
|
-
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));
|
|
264
351
|
else {
|
|
265
352
|
let e = i.autoRouting ? { routedBy: "auto" } : void 0;
|
|
266
|
-
|
|
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);
|
|
267
354
|
}
|
|
268
|
-
if (!
|
|
269
|
-
|
|
270
|
-
let
|
|
271
|
-
accessToken:
|
|
272
|
-
workspaceToken:
|
|
273
|
-
userId:
|
|
274
|
-
organizationId:
|
|
275
|
-
},
|
|
276
|
-
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(),
|
|
277
364
|
role: "user",
|
|
278
365
|
content: e,
|
|
279
366
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
280
367
|
metadata: {
|
|
281
|
-
...t.length ? { attachments: t.map(
|
|
282
|
-
...
|
|
368
|
+
...t.length ? { attachments: t.map(ve) } : {},
|
|
369
|
+
...se(n.voiceSessionId)
|
|
283
370
|
}
|
|
284
371
|
};
|
|
285
|
-
|
|
286
|
-
let
|
|
287
|
-
|
|
288
|
-
id:
|
|
372
|
+
z(p, ce);
|
|
373
|
+
let _ = Et();
|
|
374
|
+
z(p, {
|
|
375
|
+
id: _,
|
|
289
376
|
role: "assistant",
|
|
290
377
|
content: "",
|
|
291
378
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
292
379
|
metadata: {
|
|
293
|
-
lang:
|
|
294
|
-
...
|
|
380
|
+
lang: Rt,
|
|
381
|
+
...se(n.voiceSessionId)
|
|
295
382
|
}
|
|
296
|
-
}),
|
|
383
|
+
}), We(_, {
|
|
297
384
|
channel: r ? "voice" : "chat",
|
|
298
385
|
mode: c,
|
|
299
|
-
product:
|
|
300
|
-
language:
|
|
301
|
-
device:
|
|
386
|
+
product: A,
|
|
387
|
+
language: Rt,
|
|
388
|
+
device: Ge(),
|
|
302
389
|
routedByAuto: !!s
|
|
303
|
-
}, n.voiceTiming),
|
|
304
|
-
let
|
|
305
|
-
|
|
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, _, {
|
|
306
393
|
lang: a,
|
|
307
394
|
...t?.length ? { artifacts: t } : {},
|
|
308
395
|
...t?.length || r || i ? { mode: c } : {},
|
|
309
396
|
...r ? { sessionId: r } : {},
|
|
310
397
|
...i ? { sandboxId: i } : {},
|
|
311
|
-
...
|
|
398
|
+
...se(n.voiceSessionId)
|
|
312
399
|
});
|
|
313
|
-
},
|
|
314
|
-
|
|
400
|
+
}, de = async (n = 1) => {
|
|
401
|
+
C(_, "attemptStarted");
|
|
315
402
|
let i = null, a = !1;
|
|
316
403
|
try {
|
|
317
|
-
let { sandboxId: n, sessionId: o, sessionIsNew: s, sandboxIsNew:
|
|
318
|
-
turnId:
|
|
319
|
-
abortRequested:
|
|
320
|
-
activeTurnId:
|
|
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
|
|
321
408
|
}).abandon });
|
|
322
|
-
i = n,
|
|
323
|
-
runtime:
|
|
324
|
-
deadSandboxProbe:
|
|
409
|
+
i = n, C(_, "runtimeReady"), S(_, {
|
|
410
|
+
runtime: f ? "cold" : ie ? "adopted" : m ? "probed" : s ? "new-session" : "warm",
|
|
411
|
+
deadSandboxProbe: se
|
|
325
412
|
});
|
|
326
|
-
let
|
|
327
|
-
|
|
328
|
-
let
|
|
329
|
-
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,
|
|
330
417
|
attachments: t,
|
|
331
|
-
limits:
|
|
332
|
-
wrapPrompt: (e) =>
|
|
333
|
-
requestBytes: (e, t) =>
|
|
418
|
+
limits: _e(ee),
|
|
419
|
+
wrapPrompt: (e) => At?.(c, e, It, Lt, r) ?? e,
|
|
420
|
+
requestBytes: (e, t) => ne({
|
|
334
421
|
sandboxId: n,
|
|
335
|
-
workspaceId:
|
|
422
|
+
workspaceId: h,
|
|
336
423
|
sessionId: o,
|
|
337
424
|
mode: c,
|
|
338
425
|
prompt: e,
|
|
339
426
|
parts: t,
|
|
340
|
-
pageContext:
|
|
341
|
-
authContext:
|
|
427
|
+
pageContext: v,
|
|
428
|
+
authContext: g
|
|
342
429
|
})
|
|
343
|
-
}),
|
|
344
|
-
a =
|
|
430
|
+
}), ge = me(he), ve = ge > 0;
|
|
431
|
+
a = pe(t) > ge;
|
|
345
432
|
try {
|
|
346
|
-
await
|
|
433
|
+
await re(n, h, o, fe, c, v, g, he?.length ? { parts: he } : void 0);
|
|
347
434
|
} catch (e) {
|
|
348
|
-
if (!
|
|
349
|
-
await
|
|
435
|
+
if (!he || !Ze(e)) throw e;
|
|
436
|
+
await re(n, h, o, fe, c, v, g, void 0), a ||= ve;
|
|
350
437
|
}
|
|
351
|
-
|
|
352
|
-
let
|
|
353
|
-
turnId:
|
|
354
|
-
abortRequested:
|
|
355
|
-
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
|
|
356
443
|
});
|
|
357
|
-
for (; Date.now() <
|
|
358
|
-
let e =
|
|
444
|
+
for (; Date.now() < Se;) {
|
|
445
|
+
let e = b();
|
|
359
446
|
if (e.abandon) {
|
|
360
|
-
e.clearProcessing &&
|
|
447
|
+
e.clearProcessing && qt(p);
|
|
361
448
|
return;
|
|
362
449
|
}
|
|
363
|
-
if (
|
|
450
|
+
if (y = Re(await u(n, h, o, c, g, {
|
|
364
451
|
limit: 50,
|
|
365
|
-
sinceMs:
|
|
366
|
-
}),
|
|
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");
|
|
367
454
|
else {
|
|
368
|
-
let e =
|
|
369
|
-
|
|
455
|
+
let e = Be(xe, y, qe());
|
|
456
|
+
xe = e.tracker, e.confirmedAt !== null && C(_, "firstText", e.confirmedAt);
|
|
370
457
|
}
|
|
371
|
-
if (
|
|
372
|
-
|
|
458
|
+
if (y.pendingWrite && Gt(p, _, { pendingWrite: y.pendingWrite }), y.done) {
|
|
459
|
+
C(_, "answerDone"), K.current.markVerified(n);
|
|
373
460
|
break;
|
|
374
461
|
}
|
|
375
|
-
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)));
|
|
376
463
|
}
|
|
377
|
-
let
|
|
378
|
-
if (
|
|
379
|
-
...
|
|
380
|
-
content:
|
|
381
|
-
}), a && (
|
|
382
|
-
...
|
|
383
|
-
content: `${
|
|
384
|
-
}),
|
|
385
|
-
|
|
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 });
|
|
386
473
|
try {
|
|
387
|
-
await
|
|
388
|
-
workspaceId:
|
|
474
|
+
await jt?.({
|
|
475
|
+
workspaceId: h,
|
|
389
476
|
sessionId: o,
|
|
390
|
-
messageId:
|
|
391
|
-
model:
|
|
392
|
-
tokens:
|
|
393
|
-
}),
|
|
477
|
+
messageId: y.messageId,
|
|
478
|
+
model: y.model,
|
|
479
|
+
tokens: y.tokens
|
|
480
|
+
}), _t(A);
|
|
394
481
|
} catch {}
|
|
395
482
|
}
|
|
396
|
-
let
|
|
397
|
-
if (
|
|
398
|
-
|
|
483
|
+
let Oe = b();
|
|
484
|
+
if (Oe.abandon) {
|
|
485
|
+
Oe.clearProcessing && qt(p);
|
|
399
486
|
return;
|
|
400
487
|
}
|
|
401
|
-
|
|
488
|
+
C(_, "complete"), S(_, { outcome: "answered" }), Kt(p, "complete", _, null);
|
|
402
489
|
} catch (e) {
|
|
403
|
-
|
|
404
|
-
let t =
|
|
405
|
-
turnId:
|
|
406
|
-
abortRequested:
|
|
407
|
-
activeTurnId:
|
|
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
|
|
408
495
|
});
|
|
409
496
|
if (t.abandon) {
|
|
410
|
-
t.clearProcessing &&
|
|
497
|
+
t.clearProcessing && qt(p);
|
|
411
498
|
return;
|
|
412
499
|
}
|
|
413
|
-
if (n === 1 &&
|
|
414
|
-
let e = i ??
|
|
415
|
-
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);
|
|
416
503
|
}
|
|
417
504
|
throw e;
|
|
418
505
|
}
|
|
419
|
-
},
|
|
420
|
-
|
|
506
|
+
}, v = p;
|
|
507
|
+
bn.current.add(v);
|
|
421
508
|
try {
|
|
422
|
-
if (!
|
|
509
|
+
if (!h) throw Object.assign(/* @__PURE__ */ Error("Assistant backend is unavailable without an active workspace context."), { extensions: {
|
|
423
510
|
code: "UNAUTHENTICATED",
|
|
424
511
|
authFailure: "WORKSPACE_CONTEXT_MISSING"
|
|
425
512
|
} });
|
|
426
|
-
let e = await
|
|
427
|
-
|
|
428
|
-
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, {
|
|
429
516
|
dictated: r,
|
|
430
|
-
confirmsWrites:
|
|
517
|
+
confirmsWrites: f(c)
|
|
431
518
|
});
|
|
432
|
-
if (t) throw new
|
|
433
|
-
|
|
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();
|
|
434
521
|
} catch (e) {
|
|
435
|
-
|
|
436
|
-
let t =
|
|
437
|
-
|
|
438
|
-
let r =
|
|
439
|
-
|
|
440
|
-
lang: r.translated ?
|
|
441
|
-
...
|
|
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)
|
|
442
529
|
});
|
|
443
530
|
} finally {
|
|
444
|
-
|
|
445
|
-
let e =
|
|
446
|
-
t && (
|
|
447
|
-
let n =
|
|
448
|
-
|
|
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);
|
|
449
536
|
}
|
|
450
537
|
}, [
|
|
538
|
+
F,
|
|
539
|
+
z,
|
|
540
|
+
At,
|
|
541
|
+
Yt,
|
|
542
|
+
V,
|
|
543
|
+
zt,
|
|
544
|
+
R,
|
|
545
|
+
Cn,
|
|
546
|
+
kt,
|
|
547
|
+
M,
|
|
451
548
|
N,
|
|
452
|
-
L,
|
|
453
|
-
Tt,
|
|
454
549
|
Wt,
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
wt,
|
|
460
|
-
j,
|
|
461
|
-
Dt,
|
|
462
|
-
Bt,
|
|
463
|
-
k,
|
|
464
|
-
W,
|
|
465
|
-
Et,
|
|
466
|
-
Nt,
|
|
467
|
-
Ot,
|
|
468
|
-
Pt,
|
|
550
|
+
A,
|
|
551
|
+
G,
|
|
552
|
+
jt,
|
|
553
|
+
Lt,
|
|
469
554
|
Mt,
|
|
470
|
-
|
|
555
|
+
Rt,
|
|
556
|
+
It,
|
|
557
|
+
H,
|
|
558
|
+
Jt,
|
|
559
|
+
Vt,
|
|
560
|
+
Kt,
|
|
561
|
+
qt,
|
|
562
|
+
k,
|
|
563
|
+
Y,
|
|
471
564
|
Ut,
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
Ht,
|
|
475
|
-
O,
|
|
476
|
-
J,
|
|
477
|
-
zt,
|
|
478
|
-
M
|
|
479
|
-
]), Cn = C((e, t) => {
|
|
565
|
+
P
|
|
566
|
+
]), Mn = w((e, t) => {
|
|
480
567
|
X(e, [], t ? { autoIntent: t } : {});
|
|
481
|
-
}, [X]),
|
|
482
|
-
let e = [...
|
|
568
|
+
}, [X]), Nn = w(() => {
|
|
569
|
+
let e = [...tn.chat].reverse().find((e) => e.role === "user"), t = F ? yn.current[F] ?? [] : [];
|
|
483
570
|
e && X(e.content, t);
|
|
484
571
|
}, [
|
|
485
|
-
|
|
572
|
+
nn,
|
|
486
573
|
X,
|
|
487
|
-
|
|
488
|
-
]),
|
|
489
|
-
|
|
490
|
-
|
|
574
|
+
F
|
|
575
|
+
]), Pn = D(X);
|
|
576
|
+
T(() => {
|
|
577
|
+
Pn.current = X;
|
|
491
578
|
}, [X]);
|
|
492
|
-
let
|
|
493
|
-
if (
|
|
494
|
-
for (let e =
|
|
495
|
-
let t =
|
|
496
|
-
if (t?.role !== "assistant" || !
|
|
497
|
-
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);
|
|
498
585
|
if (n.kind !== "output") return null;
|
|
499
|
-
let r =
|
|
586
|
+
let r = Ve(n.text).text.trim();
|
|
500
587
|
return r ? {
|
|
501
588
|
id: t.id,
|
|
502
589
|
text: r
|
|
@@ -504,224 +591,227 @@ var St = ({ visible: St = !0, writeAccess: Ct = "unknown" }) => {
|
|
|
504
591
|
}
|
|
505
592
|
return null;
|
|
506
593
|
}, [
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
]),
|
|
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) => ({
|
|
512
599
|
id: e.id,
|
|
513
600
|
role: e.role,
|
|
514
|
-
text:
|
|
515
|
-
sessionId:
|
|
601
|
+
text: Ue(e, U, k),
|
|
602
|
+
sessionId: g(e),
|
|
516
603
|
timestamp: e.timestamp
|
|
517
604
|
})).filter((e) => e.text.length > 0), [
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
]),
|
|
605
|
+
tn.voice,
|
|
606
|
+
U,
|
|
607
|
+
k
|
|
608
|
+
]), Rn = w(() => {
|
|
522
609
|
if (Z.length === 0) return;
|
|
523
610
|
let e = /* @__PURE__ */ new Date();
|
|
524
|
-
|
|
525
|
-
title:
|
|
526
|
-
savedAt:
|
|
527
|
-
session:
|
|
528
|
-
earlier:
|
|
529
|
-
you:
|
|
530
|
-
assistant:
|
|
531
|
-
}, 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");
|
|
532
619
|
}, [
|
|
533
|
-
|
|
620
|
+
A,
|
|
534
621
|
Z,
|
|
535
|
-
|
|
536
|
-
]), Q =
|
|
537
|
-
|
|
538
|
-
let $ =
|
|
539
|
-
onSubmit:
|
|
622
|
+
k
|
|
623
|
+
]), Q = vt({ perFileChars: mn }), zn = D(Q);
|
|
624
|
+
zn.current = Q;
|
|
625
|
+
let $ = Je({
|
|
626
|
+
onSubmit: w((e, t, n) => {
|
|
540
627
|
let r = () => {
|
|
541
|
-
let r =
|
|
628
|
+
let r = zn.current, i = he(r.attachments), a = {
|
|
542
629
|
...n,
|
|
543
|
-
handedOver:
|
|
630
|
+
handedOver: qe()
|
|
544
631
|
};
|
|
545
|
-
|
|
632
|
+
Pn.current(e, i, {
|
|
546
633
|
voiceSessionId: t,
|
|
547
634
|
voiceTiming: a
|
|
548
635
|
}), r.clear();
|
|
549
636
|
};
|
|
550
|
-
if (!
|
|
637
|
+
if (!zn.current.isBusy) {
|
|
551
638
|
r();
|
|
552
639
|
return;
|
|
553
640
|
}
|
|
554
641
|
let i = Date.now(), a = window.setInterval(() => {
|
|
555
|
-
|
|
642
|
+
zn.current.isBusy && Date.now() - i < Tt || (window.clearInterval(a), r());
|
|
556
643
|
}, 200);
|
|
557
644
|
}, []),
|
|
558
|
-
latestReply:
|
|
559
|
-
language:
|
|
560
|
-
}),
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
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(),
|
|
564
653
|
role: "system",
|
|
565
|
-
content:
|
|
566
|
-
intro:
|
|
567
|
-
nothing:
|
|
568
|
-
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 })
|
|
569
658
|
}),
|
|
570
659
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
571
|
-
metadata: { continuedVoiceTurns:
|
|
572
|
-
}),
|
|
660
|
+
metadata: { continuedVoiceTurns: Un }
|
|
661
|
+
}), vn(!1), $.end());
|
|
573
662
|
}, [
|
|
574
663
|
Z,
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
664
|
+
Un,
|
|
665
|
+
Hn,
|
|
666
|
+
z,
|
|
667
|
+
k,
|
|
579
668
|
$
|
|
580
|
-
]),
|
|
581
|
-
|
|
582
|
-
$.active && (
|
|
669
|
+
]), Kn = D(0);
|
|
670
|
+
T(() => {
|
|
671
|
+
$.active && (Kn.current = Un);
|
|
583
672
|
}, [$.active]);
|
|
584
|
-
let
|
|
585
|
-
let e =
|
|
586
|
-
$.end(), e &&
|
|
587
|
-
}, [
|
|
588
|
-
|
|
589
|
-
(!
|
|
673
|
+
let qn = w(() => {
|
|
674
|
+
let e = Un > Kn.current;
|
|
675
|
+
$.end(), e && vn(!0);
|
|
676
|
+
}, [Un, $]);
|
|
677
|
+
T(() => {
|
|
678
|
+
(!Dt || !xn) && $.active && $.end();
|
|
590
679
|
}, [
|
|
591
|
-
|
|
592
|
-
|
|
680
|
+
Dt,
|
|
681
|
+
xn,
|
|
593
682
|
$
|
|
594
|
-
]),
|
|
595
|
-
$.active || (
|
|
596
|
-
}, [$.active]),
|
|
597
|
-
let e =
|
|
598
|
-
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) => {
|
|
599
688
|
if (e.pendingPrompt && e.pendingPrompt !== t.pendingPrompt) {
|
|
600
|
-
let e =
|
|
601
|
-
e &&
|
|
689
|
+
let e = x.getState().consumePendingPrompt();
|
|
690
|
+
e && Pn.current(e);
|
|
602
691
|
}
|
|
603
692
|
});
|
|
604
693
|
}, []);
|
|
605
|
-
let
|
|
606
|
-
let t =
|
|
694
|
+
let Jn = w((e) => {
|
|
695
|
+
let t = F ? x.getState().conversations.find((e) => e.id === F) : void 0;
|
|
607
696
|
if (t && (t.messages.length > 0 || t.backendSessionId)) {
|
|
608
697
|
if (t.mode !== e) {
|
|
609
|
-
let t =
|
|
610
|
-
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);
|
|
611
700
|
}
|
|
612
|
-
} else
|
|
613
|
-
let n =
|
|
614
|
-
n ?
|
|
701
|
+
} else F && Vt(F, e);
|
|
702
|
+
let n = x.getState().activeConversationId;
|
|
703
|
+
n ? Vt(n, e) : $t(!1), L(e);
|
|
615
704
|
}, [
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
]),
|
|
623
|
-
let e =
|
|
705
|
+
F,
|
|
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;
|
|
624
713
|
if (!t) {
|
|
625
|
-
|
|
714
|
+
$t(!0), L(b);
|
|
626
715
|
return;
|
|
627
716
|
}
|
|
628
717
|
if (t.routedBy === "auto") {
|
|
629
|
-
|
|
718
|
+
$t(!0);
|
|
630
719
|
return;
|
|
631
720
|
}
|
|
632
721
|
if (t.messages.length === 0 && !t.backendSessionId) {
|
|
633
|
-
|
|
722
|
+
H(t.id, b);
|
|
634
723
|
return;
|
|
635
724
|
}
|
|
636
725
|
let n = e.conversations.find((t) => t.routedBy === "auto" && t.messages.length === 0 && !t.backendSessionId && !e.processingByConversationId[t.id]);
|
|
637
|
-
n ? (
|
|
726
|
+
n ? (Ht(n.id), H(n.id, b)) : R(void 0, b, { routedBy: "auto" });
|
|
638
727
|
}, [
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
]),
|
|
645
|
-
if (
|
|
646
|
-
|
|
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);
|
|
647
736
|
return;
|
|
648
737
|
}
|
|
649
|
-
|
|
650
|
-
}, [
|
|
651
|
-
let e =
|
|
652
|
-
if (
|
|
653
|
-
let t =
|
|
654
|
-
if (
|
|
655
|
-
|
|
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);
|
|
656
745
|
return;
|
|
657
746
|
}
|
|
658
|
-
|
|
747
|
+
Zt(e), Jn(e);
|
|
659
748
|
}, [
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
749
|
+
hn,
|
|
750
|
+
Zt,
|
|
751
|
+
Jn,
|
|
663
752
|
X
|
|
664
|
-
]),
|
|
665
|
-
|
|
666
|
-
let e =
|
|
667
|
-
|
|
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, {
|
|
668
757
|
...e.options,
|
|
669
758
|
autoIntent: "read"
|
|
670
759
|
});
|
|
671
760
|
}, [X]);
|
|
672
|
-
return /* @__PURE__ */
|
|
761
|
+
return /* @__PURE__ */ Ct("div", {
|
|
673
762
|
className: "relative flex flex-1 flex-col overflow-hidden",
|
|
674
763
|
children: [
|
|
675
|
-
/* @__PURE__ */
|
|
764
|
+
/* @__PURE__ */ Ct("div", {
|
|
676
765
|
className: "contents",
|
|
677
766
|
inert: $.active || void 0,
|
|
678
767
|
children: [
|
|
679
|
-
Z.length > 0 && !$.active ? /* @__PURE__ */
|
|
768
|
+
Z.length > 0 && !$.active ? /* @__PURE__ */ O(nt, {
|
|
680
769
|
count: Z.length,
|
|
681
|
-
onOpenTranscript: () =>
|
|
770
|
+
onOpenTranscript: () => vn(!0)
|
|
682
771
|
}) : null,
|
|
683
|
-
|
|
684
|
-
mode:
|
|
685
|
-
onSuggestionClick:
|
|
686
|
-
explainsAuto:
|
|
687
|
-
suggestions:
|
|
688
|
-
}) : /* @__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", {
|
|
689
778
|
className: "flex min-h-0 flex-1 flex-col",
|
|
690
|
-
children: /* @__PURE__ */
|
|
691
|
-
onApprovePendingWrite:
|
|
692
|
-
approvingWriteRef:
|
|
693
|
-
messages:
|
|
694
|
-
processing:
|
|
695
|
-
streamingMessageId:
|
|
696
|
-
failedMessageId:
|
|
697
|
-
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
|
|
698
787
|
})
|
|
699
788
|
}),
|
|
700
|
-
/* @__PURE__ */
|
|
701
|
-
onStartVoiceSession: $.available &&
|
|
789
|
+
/* @__PURE__ */ O(yt, {
|
|
790
|
+
onStartVoiceSession: $.available && xn ? Vn : void 0,
|
|
702
791
|
onSend: (e, t) => void X(e, t),
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
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
|
|
713
803
|
} : void 0
|
|
714
804
|
})
|
|
715
805
|
]
|
|
716
806
|
}),
|
|
717
|
-
|
|
807
|
+
_n && !$.active ? /* @__PURE__ */ O(rt, {
|
|
718
808
|
turns: Z,
|
|
719
|
-
onClose: () =>
|
|
720
|
-
onSave:
|
|
721
|
-
onContinueInChat:
|
|
809
|
+
onClose: () => vn(!1),
|
|
810
|
+
onSave: Rn,
|
|
811
|
+
onContinueInChat: Wn ? Gn : void 0,
|
|
722
812
|
closeOnEscape: !0
|
|
723
813
|
}) : null,
|
|
724
|
-
$.active && /* @__PURE__ */
|
|
814
|
+
$.active && /* @__PURE__ */ O(st, {
|
|
725
815
|
session: $.session,
|
|
726
816
|
notice: $.notice,
|
|
727
817
|
capturing: $.capturing,
|
|
@@ -735,24 +825,24 @@ var St = ({ visible: St = !0, writeAccess: Ct = "unknown" }) => {
|
|
|
735
825
|
onRetryAttachment: Q.retry,
|
|
736
826
|
canAttachMore: Q.canAddMore,
|
|
737
827
|
preparingAttachments: Q.preparingCount,
|
|
738
|
-
onSaveTranscript:
|
|
739
|
-
onContinueInChat:
|
|
828
|
+
onSaveTranscript: Rn,
|
|
829
|
+
onContinueInChat: Gn,
|
|
740
830
|
onInterrupt: () => {
|
|
741
|
-
$.interrupt(),
|
|
831
|
+
$.interrupt(), An();
|
|
742
832
|
},
|
|
743
|
-
spoken:
|
|
833
|
+
spoken: In,
|
|
744
834
|
onToggleMute: $.toggleMute,
|
|
745
|
-
onEnd:
|
|
835
|
+
onEnd: qn
|
|
746
836
|
}),
|
|
747
|
-
/* @__PURE__ */
|
|
748
|
-
open:
|
|
749
|
-
mode:
|
|
750
|
-
currentMode:
|
|
751
|
-
onConfirm:
|
|
752
|
-
onCancel:
|
|
837
|
+
/* @__PURE__ */ O(xt, {
|
|
838
|
+
open: hn !== null,
|
|
839
|
+
mode: Qn,
|
|
840
|
+
currentMode: J ?? { id: I },
|
|
841
|
+
onConfirm: Zn,
|
|
842
|
+
onCancel: $n
|
|
753
843
|
})
|
|
754
844
|
]
|
|
755
845
|
});
|
|
756
846
|
};
|
|
757
847
|
//#endregion
|
|
758
|
-
export {
|
|
848
|
+
export { Dt as AssistantChatArea };
|