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