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