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