@burdenoff/microfe-bigconsole 2026.912.4 → 2026.916.1
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/bigconsole/assistant/assistantApi.js +62 -55
- package/dist/bigconsole/assistant/assistantApi.js.map +1 -1
- package/dist/bigconsole/assistant/assistantRuntime.js +45 -0
- package/dist/bigconsole/assistant/assistantRuntime.js.map +1 -0
- package/dist/bigconsole/assistant/createSandboxAssistantTransport.js +197 -194
- package/dist/bigconsole/assistant/createSandboxAssistantTransport.js.map +1 -1
- package/dist/bigconsole/components/preview/AiPreviewContent.js +129 -67
- package/dist/bigconsole/components/preview/AiPreviewContent.js.map +1 -1
- package/dist/bigconsole/hooks/useWidgetOperations.js +1 -1
- package/dist/bigconsole/hooks/useWidgetOperations.js.map +1 -1
- package/dist/generated/wspace-operations.js +48 -37
- package/dist/generated/wspace-operations.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import { useAssistantRunStore as e } from "./assistantRunStore.js";
|
|
2
|
-
import { createAssistantSandbox as t, createAssistantSession as n, extendAssistantSandboxTTL as r, findExistingSandbox as i, getAssistantMessages as a,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { createAssistantSandbox as t, createAssistantSession as n, extendAssistantSandboxTTL as r, findExistingSandbox as i, getAssistantMessages as a, isCachedAssistantSandboxReusable as o, sendAssistantPromptAsync as s, waitForAssistantServiceReady as c, waitForSandboxReady as l } from "./assistantApi.js";
|
|
3
|
+
import { ASSISTANT_SANDBOX_ID_KEY as u, ASSISTANT_SESSION_ID_KEY as d, LEGACY_ASSISTANT_RUNTIME_KEYS as f, resolveAssistantRuntime as p } from "./assistantRuntime.js";
|
|
4
|
+
import { buildAttachmentBlock as m } from "./attachmentExtract.js";
|
|
5
|
+
import { deleteAssistantConversation as h, getAssistantConversationMessages as g, listAssistantConversations as _, saveAssistantTurn as ee } from "./conversationHistoryApi.js";
|
|
5
6
|
import { gatherPageContext as te } from "./pageContext.js";
|
|
6
|
-
import { useCallback as
|
|
7
|
-
import { useAuthToken as
|
|
7
|
+
import { useCallback as v, useMemo as y, useRef as b } from "react";
|
|
8
|
+
import { useAuthToken as x } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
8
9
|
//#region src/bigconsole/assistant/createSandboxAssistantTransport.ts
|
|
9
|
-
var
|
|
10
|
-
|
|
10
|
+
var S = "api-calls", ne = 42e4, re = 1500, ie = 3e4, C = 200, w = 25, ae = 6e3, T = "bc-assistant-conversation-id", oe = {
|
|
11
|
+
isCachedAssistantSandboxReusable: o,
|
|
12
|
+
findExistingSandbox: i,
|
|
13
|
+
createAssistantSandbox: t,
|
|
14
|
+
waitForSandboxReady: l,
|
|
15
|
+
waitForAssistantServiceReady: c,
|
|
16
|
+
createAssistantSession: n
|
|
17
|
+
};
|
|
18
|
+
function E(e) {
|
|
11
19
|
try {
|
|
12
20
|
return window.sessionStorage.getItem(e);
|
|
13
21
|
} catch {
|
|
14
22
|
return null;
|
|
15
23
|
}
|
|
16
24
|
}
|
|
17
|
-
function
|
|
25
|
+
function D(e, t) {
|
|
18
26
|
try {
|
|
19
27
|
t ? window.sessionStorage.setItem(e, t) : window.sessionStorage.removeItem(e);
|
|
20
28
|
} catch {}
|
|
21
29
|
}
|
|
22
|
-
function
|
|
30
|
+
function O(e) {
|
|
23
31
|
try {
|
|
24
32
|
let t = e === "workspaceId" ? "burdenoff-active-context-workspace" : "burdenoff-active-context-organization", n = localStorage.getItem(t);
|
|
25
33
|
if (n) return n;
|
|
@@ -31,16 +39,16 @@ function E(e) {
|
|
|
31
39
|
return "";
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
|
-
function
|
|
35
|
-
return new URLSearchParams(window.location.search).get("workspace") ??
|
|
42
|
+
function k(e) {
|
|
43
|
+
return new URLSearchParams(window.location.search).get("workspace") ?? O("workspaceId") ?? e ?? "";
|
|
36
44
|
}
|
|
37
|
-
function
|
|
38
|
-
return new URLSearchParams(window.location.search).get("org") ??
|
|
45
|
+
function A() {
|
|
46
|
+
return new URLSearchParams(window.location.search).get("org") ?? O("organizationId");
|
|
39
47
|
}
|
|
40
|
-
function
|
|
48
|
+
function j(e) {
|
|
41
49
|
return e.info?.role ?? e.role;
|
|
42
50
|
}
|
|
43
|
-
function
|
|
51
|
+
function M(e) {
|
|
44
52
|
let t = e.info?.time?.created;
|
|
45
53
|
if (t !== void 0) return t;
|
|
46
54
|
let n = e.createdAt;
|
|
@@ -51,7 +59,7 @@ function A(e) {
|
|
|
51
59
|
}
|
|
52
60
|
return n;
|
|
53
61
|
}
|
|
54
|
-
function
|
|
62
|
+
function N(e) {
|
|
55
63
|
let t = e.info?.time?.completed;
|
|
56
64
|
if (t !== void 0) return t;
|
|
57
65
|
let n = e.completedAt;
|
|
@@ -63,10 +71,10 @@ function j(e) {
|
|
|
63
71
|
return n;
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
|
-
function
|
|
74
|
+
function P(e) {
|
|
67
75
|
return (e.parts ?? [] ?? []).filter((e) => e.type === "text" && typeof e.text == "string").map((e) => e.text?.trim() ?? "").filter(Boolean).join("\n") || (typeof e.content == "string" ? e.content.trim() : "");
|
|
68
76
|
}
|
|
69
|
-
var
|
|
77
|
+
var F = {
|
|
70
78
|
bash: "Running a command",
|
|
71
79
|
webfetch: "Fetching a page",
|
|
72
80
|
"file.read": "Reading files",
|
|
@@ -77,42 +85,42 @@ var N = {
|
|
|
77
85
|
todowrite: "Planning the steps",
|
|
78
86
|
todoread: "Reviewing the plan"
|
|
79
87
|
};
|
|
80
|
-
function
|
|
88
|
+
function I(e) {
|
|
81
89
|
return typeof e == "object" && e ? e : void 0;
|
|
82
90
|
}
|
|
83
|
-
function
|
|
84
|
-
let t = e.tool ?? "tool", n =
|
|
91
|
+
function L(e) {
|
|
92
|
+
let t = e.tool ?? "tool", n = I(e.state?.input), r = n?.description;
|
|
85
93
|
if (typeof r == "string" && r.trim()) return r.trim();
|
|
86
94
|
let i = n?.todos;
|
|
87
95
|
if (Array.isArray(i)) {
|
|
88
|
-
let e =
|
|
96
|
+
let e = I(i.find((e) => I(e)?.status === "in_progress") ?? i[0])?.content;
|
|
89
97
|
if (typeof e == "string" && e.trim()) return e.trim();
|
|
90
98
|
}
|
|
91
|
-
return
|
|
99
|
+
return F[t] ?? `Running ${t}`;
|
|
92
100
|
}
|
|
93
|
-
function
|
|
101
|
+
function R(e) {
|
|
94
102
|
return (e.parts ?? []).filter((e) => e.type === "tool" && e.tool).map((e) => {
|
|
95
|
-
let t = e.state?.status ?? "running", n =
|
|
103
|
+
let t = e.state?.status ?? "running", n = L(e);
|
|
96
104
|
return t === "completed" ? `✓ ${n}` : t === "failed" ? `⚠ ${n}` : `⏳ ${n}…`;
|
|
97
105
|
});
|
|
98
106
|
}
|
|
99
|
-
function
|
|
100
|
-
let i = e.filter((e) =>
|
|
107
|
+
function z(e, t, n, r) {
|
|
108
|
+
let i = e.filter((e) => j(e) === "assistant" && M(e) >= t).sort((e, t) => M(e) - M(t));
|
|
101
109
|
i.length === 0 && e.length > 0 && console.log("[BigConsole-Assistant] buildProgress: no relevant messages", {
|
|
102
110
|
totalMessages: e.length,
|
|
103
111
|
sinceMs: t,
|
|
104
|
-
messageRoles: e.map((e) =>
|
|
105
|
-
messageTimestamps: e.map((e) =>
|
|
112
|
+
messageRoles: e.map((e) => j(e)),
|
|
113
|
+
messageTimestamps: e.map((e) => M(e))
|
|
106
114
|
});
|
|
107
115
|
let a, o;
|
|
108
116
|
if (i.length === 0) {
|
|
109
117
|
a = "";
|
|
110
|
-
let t = e.some((e) =>
|
|
118
|
+
let t = e.some((e) => j(e) === "assistant"), i = n === a && r !== void 0 ? Date.now() - r : 0;
|
|
111
119
|
o = t ? i >= 9e4 : i >= 15e4;
|
|
112
120
|
} else {
|
|
113
|
-
let e = i[i.length - 1], t = i.map(
|
|
121
|
+
let e = i[i.length - 1], t = i.map(P).filter(Boolean), s = R(e);
|
|
114
122
|
a = [...t, ...s].join("\n\n");
|
|
115
|
-
let c = !!
|
|
123
|
+
let c = !!N(e) && a.length > 0, l = (e.parts ?? []).some((e) => e.type === "tool" && e.state?.status !== "completed" && e.state?.status !== "failed"), u = !c && !l && n === a && r !== void 0 && Date.now() - r >= 45e3;
|
|
116
124
|
o = c || u;
|
|
117
125
|
}
|
|
118
126
|
return {
|
|
@@ -120,10 +128,10 @@ function L(e, t, n, r) {
|
|
|
120
128
|
done: o
|
|
121
129
|
};
|
|
122
130
|
}
|
|
123
|
-
function
|
|
131
|
+
function B(e) {
|
|
124
132
|
return e.replace(/(Authorization\s*:\s*Bearer\s+)[^\s\n]+/gi, "$1[REDACTED]").replace(/(X-Workspace-Authorization\s*:\s*Bearer\s+)[^\s\n]+/gi, "$1[REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+\b/g, "[REDACTED_JWT]").replace(/\bsk-ant-[A-Za-z0-9-]+\b/g, "[REDACTED_API_KEY]");
|
|
125
133
|
}
|
|
126
|
-
function
|
|
134
|
+
function se(e) {
|
|
127
135
|
let t = e instanceof Error ? e.message.toLowerCase() : String(e).toLowerCase();
|
|
128
136
|
return t.includes("rate limit exceeded") || t.includes("unauthorized") || t.includes("k8s api error 401") ? !1 : [
|
|
129
137
|
"sandbox not found",
|
|
@@ -145,118 +153,113 @@ function ae(e) {
|
|
|
145
153
|
"the assistant runtime did not respond"
|
|
146
154
|
].some((e) => t.includes(e));
|
|
147
155
|
}
|
|
148
|
-
function
|
|
149
|
-
let { getAccessToken:
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
156
|
+
function V() {
|
|
157
|
+
let { getAccessToken: t, getWorkspaceToken: n, userId: i, workspaceId: o } = x(), [c, l, O] = y(() => {
|
|
158
|
+
for (let e of f) D(e, null);
|
|
159
|
+
return [
|
|
160
|
+
E(u),
|
|
161
|
+
E(d),
|
|
162
|
+
E(T)
|
|
163
|
+
];
|
|
164
|
+
}, []), N = b(c), P = b(l), F = b(O), I = b(null), L = b(null), R = v((e) => {
|
|
165
|
+
N.current = e, D(u, e);
|
|
166
|
+
}, []), V = v((e) => {
|
|
167
|
+
P.current = e, D(d, e);
|
|
168
|
+
}, []), H = v((e) => {
|
|
169
|
+
F.current = e, D(T, e);
|
|
170
|
+
}, []), U = v(async (e, n) => p({
|
|
171
|
+
workspaceId: e,
|
|
172
|
+
mode: S,
|
|
173
|
+
authContext: n,
|
|
174
|
+
api: oe,
|
|
175
|
+
hasAccessToken: () => !!t(),
|
|
176
|
+
store: {
|
|
177
|
+
getSandboxId: () => N.current,
|
|
178
|
+
setSandboxId: R,
|
|
179
|
+
getSessionId: () => P.current,
|
|
180
|
+
setSessionId: V,
|
|
181
|
+
getVerifiedSandboxKey: () => I.current,
|
|
182
|
+
setVerifiedSandboxKey: (e) => {
|
|
183
|
+
I.current = e;
|
|
173
184
|
}
|
|
174
|
-
a || (console.log("[BigConsole-Assistant] createAssistantSandbox called"), a = await t(_, e, r), console.log("[BigConsole-Assistant] createAssistantSandbox result", { sandboxId: a }), console.log("[BigConsole-Assistant] waitForSandboxReady called (fresh)", { sandboxId: a }), await c(a, e, r), console.log("[BigConsole-Assistant] waitForSandboxReady done (fresh)", { sandboxId: a }), console.log("[BigConsole-Assistant] waitForAssistantServiceReady called (fresh)", { sandboxId: a }), await s(a, e, _, r), console.log("[BigConsole-Assistant] waitForAssistantServiceReady done (fresh)", { sandboxId: a })), U(a);
|
|
175
185
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
workspaceId: e
|
|
183
|
-
}), o = (await n(a, e, _, r)).sessionId, W(o)), {
|
|
184
|
-
sandboxId: a,
|
|
185
|
-
sessionId: o
|
|
186
|
-
};
|
|
187
|
-
}, [E]), q = p(async ({ prompt: t, attachments: n, onProgress: i, signal: s }) => {
|
|
188
|
-
let c = D(N);
|
|
186
|
+
}), [
|
|
187
|
+
t,
|
|
188
|
+
R,
|
|
189
|
+
V
|
|
190
|
+
]), W = v(async ({ prompt: c, attachments: l, onProgress: u, signal: d }) => {
|
|
191
|
+
let f = k(o);
|
|
189
192
|
if (console.log("[BigConsole-Assistant] sendPrompt called", {
|
|
190
|
-
promptLength:
|
|
191
|
-
workspaceId:
|
|
192
|
-
hasCtxWorkspaceId: !!
|
|
193
|
+
promptLength: c.length,
|
|
194
|
+
workspaceId: f,
|
|
195
|
+
hasCtxWorkspaceId: !!o,
|
|
193
196
|
authContextKeys: {
|
|
194
|
-
hasAccessToken: !!
|
|
195
|
-
hasWorkspaceToken: !!
|
|
196
|
-
hasUserId: !!
|
|
197
|
+
hasAccessToken: !!t(),
|
|
198
|
+
hasWorkspaceToken: !!n(),
|
|
199
|
+
hasUserId: !!i
|
|
197
200
|
},
|
|
198
201
|
locationSearch: window.location.search
|
|
199
|
-
}), !
|
|
200
|
-
let
|
|
201
|
-
accessToken:
|
|
202
|
-
workspaceToken:
|
|
203
|
-
userId:
|
|
204
|
-
organizationId:
|
|
202
|
+
}), !f) throw Error("The assistant needs an active workspace. Open a workspace and try again.");
|
|
203
|
+
let p = {
|
|
204
|
+
accessToken: t(),
|
|
205
|
+
workspaceToken: n(),
|
|
206
|
+
userId: i,
|
|
207
|
+
organizationId: A()
|
|
205
208
|
};
|
|
206
209
|
console.log("[BigConsole-Assistant] authContext prepared", {
|
|
207
|
-
hasAccessToken: !!
|
|
208
|
-
hasWorkspaceToken: !!
|
|
209
|
-
hasUserId: !!
|
|
210
|
-
hasOrgId: !!
|
|
211
|
-
}), e.getState().startRun(
|
|
212
|
-
let
|
|
213
|
-
|
|
214
|
-
},
|
|
210
|
+
hasAccessToken: !!p.accessToken,
|
|
211
|
+
hasWorkspaceToken: !!p.workspaceToken,
|
|
212
|
+
hasUserId: !!p.userId,
|
|
213
|
+
hasOrgId: !!p.organizationId
|
|
214
|
+
}), e.getState().startRun(c);
|
|
215
|
+
let h = (t) => {
|
|
216
|
+
u(t), e.getState().applyProgress(t);
|
|
217
|
+
}, g = async (e) => {
|
|
215
218
|
try {
|
|
216
219
|
console.log("[BigConsole-Assistant] run attempt", e);
|
|
217
|
-
let { sandboxId:
|
|
220
|
+
let { sandboxId: t, sessionId: n } = await U(f, p);
|
|
218
221
|
console.log("[BigConsole-Assistant] ensureRuntime resolved", {
|
|
219
|
-
sandboxId:
|
|
220
|
-
sessionId:
|
|
222
|
+
sandboxId: t,
|
|
223
|
+
sessionId: n
|
|
221
224
|
});
|
|
222
|
-
let
|
|
225
|
+
let i = L.current, o = l && l.length > 0 ? await m(l) : "", u = o ? `${c}\n\n${o}` : c, g = i ? `${i}\n\n---\n\n${u}` : u, _ = Date.now();
|
|
223
226
|
console.log("[BigConsole-Assistant] calling sendAssistantPromptAsync", {
|
|
224
|
-
sandboxId:
|
|
225
|
-
workspaceId:
|
|
226
|
-
sessionId:
|
|
227
|
+
sandboxId: t,
|
|
228
|
+
workspaceId: f,
|
|
229
|
+
sessionId: n,
|
|
227
230
|
promptLength: g.length,
|
|
228
|
-
replayed: !!
|
|
229
|
-
}), await
|
|
230
|
-
let
|
|
231
|
-
for (; Date.now() <
|
|
232
|
-
if (
|
|
233
|
-
let e = await a(
|
|
231
|
+
replayed: !!i
|
|
232
|
+
}), await s(t, f, n, g, S, te(), p);
|
|
233
|
+
let v = Date.now() + ne, y = Date.now(), b = "", x = Date.now(), C = z([], _);
|
|
234
|
+
for (; Date.now() < v;) {
|
|
235
|
+
if (d.aborted) throw Error("Cancelled");
|
|
236
|
+
let e = await a(t, f, n, p, 50);
|
|
234
237
|
if (console.log("[BigConsole-Assistant] poll", {
|
|
235
|
-
elapsedMs: Date.now() -
|
|
238
|
+
elapsedMs: Date.now() - _,
|
|
236
239
|
messageCount: e.length,
|
|
237
|
-
firstFewRoles: e.slice(0, 3).map((e) =>
|
|
238
|
-
firstFewTimestamps: e.slice(0, 3).map((e) =>
|
|
239
|
-
}), C =
|
|
240
|
+
firstFewRoles: e.slice(0, 3).map((e) => j(e)),
|
|
241
|
+
firstFewTimestamps: e.slice(0, 3).map((e) => M(e))
|
|
242
|
+
}), C = z(e, _, b, x), console.log("[BigConsole-Assistant] progress", {
|
|
240
243
|
contentPreview: C.content.slice(0, 100),
|
|
241
244
|
done: C.done,
|
|
242
|
-
lastContentChangeAt: Date.now() -
|
|
243
|
-
}), C.content !==
|
|
245
|
+
lastContentChangeAt: Date.now() - x
|
|
246
|
+
}), C.content !== b && (b = C.content, x = Date.now()), h(B(C.content)), C.done) {
|
|
244
247
|
console.log("[BigConsole-Assistant] progress.done=true, breaking poll loop");
|
|
245
248
|
break;
|
|
246
249
|
}
|
|
247
|
-
Date.now() -
|
|
250
|
+
Date.now() - y > ie && (await r(t, f, 600, p).catch(() => void 0), y = Date.now()), await new Promise((e) => setTimeout(e, re));
|
|
248
251
|
}
|
|
249
252
|
if (!C.done) throw Error("I stopped waiting for a reply, but I may still be working — anything I already created will be there. Check your dashboards and data sinks before asking again, so you do not end up with duplicates.");
|
|
250
|
-
let w =
|
|
253
|
+
let w = B(C.content);
|
|
251
254
|
if (!w.trim()) throw Error("I could not produce a reply — the assistant runtime did not respond. It may be out of capacity right now. Nothing was changed; please try again shortly.");
|
|
252
|
-
|
|
255
|
+
L.current = null;
|
|
253
256
|
try {
|
|
254
|
-
|
|
255
|
-
conversationId:
|
|
256
|
-
prompt:
|
|
257
|
+
H((await ee({
|
|
258
|
+
conversationId: F.current,
|
|
259
|
+
prompt: c,
|
|
257
260
|
reply: w,
|
|
258
|
-
agentSessionId:
|
|
259
|
-
},
|
|
261
|
+
agentSessionId: n
|
|
262
|
+
}, f, p)).id);
|
|
260
263
|
} catch (e) {
|
|
261
264
|
console.warn("[BigConsole-Assistant] could not save turn to history", { error: e instanceof Error ? e.message : String(e) });
|
|
262
265
|
}
|
|
@@ -266,120 +269,120 @@ function z() {
|
|
|
266
269
|
attempt: e,
|
|
267
270
|
error: t instanceof Error ? t.message : String(t),
|
|
268
271
|
stack: t instanceof Error ? t.stack : void 0,
|
|
269
|
-
sandboxId:
|
|
270
|
-
sessionId:
|
|
271
|
-
}), e === 1 &&
|
|
272
|
+
sandboxId: N.current,
|
|
273
|
+
sessionId: P.current
|
|
274
|
+
}), e === 1 && se(t)) return R(null), V(null), g(2);
|
|
272
275
|
throw t;
|
|
273
276
|
}
|
|
274
277
|
};
|
|
275
278
|
try {
|
|
276
|
-
let t = await
|
|
279
|
+
let t = await g(1);
|
|
277
280
|
return e.getState().finishRun(null), t;
|
|
278
281
|
} catch (t) {
|
|
279
282
|
throw e.getState().finishRun(t instanceof Error ? t.message : String(t)), t;
|
|
280
283
|
}
|
|
281
284
|
}, [
|
|
282
|
-
|
|
283
|
-
K,
|
|
284
|
-
E,
|
|
285
|
-
j,
|
|
286
|
-
M,
|
|
285
|
+
o,
|
|
287
286
|
U,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
287
|
+
t,
|
|
288
|
+
n,
|
|
289
|
+
i,
|
|
290
|
+
R,
|
|
291
|
+
V,
|
|
292
|
+
H
|
|
293
|
+
]), G = v(() => ({
|
|
294
|
+
accessToken: t(),
|
|
295
|
+
workspaceToken: n(),
|
|
296
|
+
userId: i,
|
|
297
|
+
organizationId: A()
|
|
295
298
|
}), [
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
]),
|
|
299
|
+
t,
|
|
300
|
+
n,
|
|
301
|
+
i
|
|
302
|
+
]), K = v((e) => e.length === 0 ? null : [
|
|
300
303
|
"You are resuming an earlier conversation. What follows is what was said in it — treat it as your own memory and continue seamlessly. Do not mention this replay, and do not redo work that was already completed.",
|
|
301
304
|
"--- earlier in this conversation ---",
|
|
302
|
-
e.map((e) => `${e.role === "user" ? "User" : "Assistant"}: ${e.content}`).join("\n\n").slice(-
|
|
305
|
+
e.map((e) => `${e.role === "user" ? "User" : "Assistant"}: ${e.content}`).join("\n\n").slice(-ae),
|
|
303
306
|
"--- end ---"
|
|
304
|
-
].join("\n\n"), []),
|
|
307
|
+
].join("\n\n"), []), q = v((e) => e.map((e) => ({
|
|
305
308
|
id: e.id,
|
|
306
309
|
role: e.role === "ASSISTANT" ? "assistant" : "user",
|
|
307
|
-
content:
|
|
308
|
-
})), []),
|
|
309
|
-
let r =
|
|
310
|
-
return
|
|
310
|
+
content: B(e.content)
|
|
311
|
+
})), []), J = v(async (e, t, n) => {
|
|
312
|
+
let r = q(await g(e.id, t, n, C));
|
|
313
|
+
return H(e.id), V(null), L.current = K(r), r;
|
|
311
314
|
}, [
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
]),
|
|
317
|
-
let e =
|
|
318
|
-
if (!e || !
|
|
319
|
-
let
|
|
315
|
+
q,
|
|
316
|
+
H,
|
|
317
|
+
V,
|
|
318
|
+
K
|
|
319
|
+
]), Y = v(async () => {
|
|
320
|
+
let e = k(o);
|
|
321
|
+
if (!e || !t()) return [];
|
|
322
|
+
let n = G();
|
|
320
323
|
try {
|
|
321
|
-
let
|
|
322
|
-
return i ? await
|
|
324
|
+
let t = await _(e, n, w), r = F.current, i = t.find((e) => e.id === r) ?? t[0];
|
|
325
|
+
return i ? await J(i, e, n) : [];
|
|
323
326
|
} catch (e) {
|
|
324
327
|
return console.warn("[BigConsole-Assistant] could not restore history", { error: e instanceof Error ? e.message : String(e) }), [];
|
|
325
328
|
}
|
|
326
329
|
}, [
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
]),
|
|
332
|
-
let e =
|
|
333
|
-
if (!e || !
|
|
330
|
+
o,
|
|
331
|
+
t,
|
|
332
|
+
G,
|
|
333
|
+
J
|
|
334
|
+
]), X = v(async () => {
|
|
335
|
+
let e = k(o);
|
|
336
|
+
if (!e || !t()) return [];
|
|
334
337
|
try {
|
|
335
|
-
return (await
|
|
338
|
+
return (await _(e, G(), w)).map((e) => ({
|
|
336
339
|
id: e.id,
|
|
337
340
|
title: e.title?.trim() || "New chat",
|
|
338
341
|
updatedAt: Date.parse(e.updatedAt) || void 0,
|
|
339
|
-
active: e.id ===
|
|
342
|
+
active: e.id === F.current
|
|
340
343
|
}));
|
|
341
344
|
} catch {
|
|
342
345
|
return [];
|
|
343
346
|
}
|
|
344
347
|
}, [
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
]),
|
|
349
|
-
let t =
|
|
350
|
-
t && (await
|
|
348
|
+
o,
|
|
349
|
+
t,
|
|
350
|
+
G
|
|
351
|
+
]), Z = v(async () => (H(null), V(null), L.current = null, Promise.resolve()), [H, V]), Q = v(async (e) => {
|
|
352
|
+
let t = k(o);
|
|
353
|
+
t && (await h(e, t, G()), F.current === e && (H(null), V(null), L.current = null));
|
|
351
354
|
}, [
|
|
352
|
-
|
|
353
|
-
J,
|
|
355
|
+
o,
|
|
354
356
|
G,
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
357
|
+
H,
|
|
358
|
+
V
|
|
359
|
+
]), $ = v(async (e) => {
|
|
360
|
+
let t = k(o);
|
|
358
361
|
if (!t) return [];
|
|
359
|
-
let n =
|
|
360
|
-
return r ?
|
|
362
|
+
let n = G(), r = (await _(t, n, w)).find((t) => t.id === e);
|
|
363
|
+
return r ? J(r, t, n) : [];
|
|
361
364
|
}, [
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
+
o,
|
|
366
|
+
G,
|
|
367
|
+
J
|
|
365
368
|
]);
|
|
366
|
-
return
|
|
367
|
-
sendPrompt:
|
|
368
|
-
loadHistory:
|
|
369
|
-
listSessions:
|
|
370
|
-
newSession:
|
|
371
|
-
deleteSession:
|
|
372
|
-
selectSession:
|
|
369
|
+
return y(() => ({
|
|
370
|
+
sendPrompt: W,
|
|
371
|
+
loadHistory: Y,
|
|
372
|
+
listSessions: X,
|
|
373
|
+
newSession: Z,
|
|
374
|
+
deleteSession: Q,
|
|
375
|
+
selectSession: $
|
|
373
376
|
}), [
|
|
374
|
-
|
|
377
|
+
W,
|
|
378
|
+
Y,
|
|
379
|
+
X,
|
|
380
|
+
Z,
|
|
375
381
|
Q,
|
|
376
|
-
|
|
377
|
-
oe,
|
|
378
|
-
se,
|
|
379
|
-
ce
|
|
382
|
+
$
|
|
380
383
|
]);
|
|
381
384
|
}
|
|
382
385
|
//#endregion
|
|
383
|
-
export {
|
|
386
|
+
export { V as useSandboxAssistantTransport };
|
|
384
387
|
|
|
385
388
|
//# sourceMappingURL=createSandboxAssistantTransport.js.map
|