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