@burdenoff/microfe-bigconsole 2026.730.3 → 2026.730.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/bigconsole/assistant/attachmentExtract.js +50 -0
  2. package/dist/bigconsole/assistant/attachmentExtract.js.map +1 -0
  3. package/dist/bigconsole/assistant/createSandboxAssistantTransport.js +174 -173
  4. package/dist/bigconsole/assistant/createSandboxAssistantTransport.js.map +1 -1
  5. package/dist/bigconsole/components/embed/EmbedErrorBoundary.js +25 -0
  6. package/dist/bigconsole/components/embed/EmbedErrorBoundary.js.map +1 -0
  7. package/dist/bigconsole/components/embed/EmbedWidgetRenderer.js +36 -0
  8. package/dist/bigconsole/components/embed/EmbedWidgetRenderer.js.map +1 -0
  9. package/dist/bigconsole/components/embed/ReadOnlyDashboardRenderer.js +62 -0
  10. package/dist/bigconsole/components/embed/ReadOnlyDashboardRenderer.js.map +1 -0
  11. package/dist/bigconsole/components/embed/index.js +7 -0
  12. package/dist/bigconsole/components/embed/renderer-manifest.js +77 -0
  13. package/dist/bigconsole/components/embed/renderer-manifest.js.map +1 -0
  14. package/dist/bigconsole/components/embed/types.js +6 -0
  15. package/dist/bigconsole/components/embed/types.js.map +1 -0
  16. package/dist/bigconsole/components/embed/validate.js +29 -0
  17. package/dist/bigconsole/components/embed/validate.js.map +1 -0
  18. package/dist/bigconsole/components/embed/widgets/KpiComparisonEmbed.js +34 -0
  19. package/dist/bigconsole/components/embed/widgets/KpiComparisonEmbed.js.map +1 -0
  20. package/dist/bigconsole/components/embed/widgets/ListEmbed.js +36 -0
  21. package/dist/bigconsole/components/embed/widgets/ListEmbed.js.map +1 -0
  22. package/dist/bigconsole/components/embed/widgets/MetricCardEmbed.js +20 -0
  23. package/dist/bigconsole/components/embed/widgets/MetricCardEmbed.js.map +1 -0
  24. package/dist/bigconsole/components/embed/widgets/TableEmbed.js +40 -0
  25. package/dist/bigconsole/components/embed/widgets/TableEmbed.js.map +1 -0
  26. package/dist/bigconsole/components/embed/widgets/TextEmbed.js +20 -0
  27. package/dist/bigconsole/components/embed/widgets/TextEmbed.js.map +1 -0
  28. package/dist/bigconsole/components/embed/widgets/shared.js +29 -0
  29. package/dist/bigconsole/components/embed/widgets/shared.js.map +1 -0
  30. package/dist/node_modules/pdfjs-dist/build/pdf.js +12493 -0
  31. package/dist/node_modules/pdfjs-dist/build/pdf.js.map +1 -0
  32. package/dist/node_modules/xlsx/xlsx.js +16412 -0
  33. package/dist/node_modules/xlsx/xlsx.js.map +1 -0
  34. package/package.json +8 -2
@@ -0,0 +1,50 @@
1
+ //#region src/bigconsole/assistant/attachmentExtract.ts
2
+ var e = 1e5, t = 200;
3
+ function n(e) {
4
+ let t = e.name.toLowerCase();
5
+ return t.endsWith(".json") || t.endsWith(".csv") || t.endsWith(".txt") || e.type === "application/json" || e.type === "text/csv" || e.type.startsWith("text/");
6
+ }
7
+ async function r(e) {
8
+ let t = e.name.toLowerCase();
9
+ if (n(e)) return await e.text();
10
+ if (t.endsWith(".xlsx") || t.endsWith(".xls")) {
11
+ let t = await import("../../node_modules/xlsx/xlsx.js"), n = await e.arrayBuffer(), r = t.read(n, { type: "array" }), i = r.SheetNames[0];
12
+ return i ? t.utils.sheet_to_csv(r.Sheets[i]) : "";
13
+ }
14
+ if (t.endsWith(".pdf") || e.type === "application/pdf") {
15
+ let t = await import("../../node_modules/pdfjs-dist/build/pdf.js"), n = await e.arrayBuffer(), r = await t.getDocument({ data: new Uint8Array(n) }).promise, i = [], a = Math.min(r.numPages, 20);
16
+ for (let e = 1; e <= a; e += 1) {
17
+ let t = await (await r.getPage(e)).getTextContent();
18
+ i.push(t.items.map((e) => "str" in e ? e.str : "").join(" "));
19
+ }
20
+ return i.join("\n");
21
+ }
22
+ return await e.text();
23
+ }
24
+ function i(n) {
25
+ let r = n, i = !1, a = r.split(/\r?\n/);
26
+ return a.length > t && (r = a.slice(0, t).join("\n"), i = !0), r.length > e && (r = r.slice(0, e), i = !0), {
27
+ text: r,
28
+ truncated: i
29
+ };
30
+ }
31
+ async function a(n) {
32
+ let a = [];
33
+ for (let o of n) {
34
+ let n;
35
+ try {
36
+ n = await r(o);
37
+ } catch (e) {
38
+ let t = e instanceof Error ? e.message : "unknown error";
39
+ a.push(`--- Attached file "${o.name}" could not be auto-read (${t}). Please paste its rows here instead. ---`);
40
+ continue;
41
+ }
42
+ let { text: s, truncated: c } = i(n.trim()), l = c ? ` (sample — first ${t} rows / ~${Math.round(e / 1e3)}KB)` : "";
43
+ a.push(`--- Attached data source: ${o.name}${l} ---\n${s}\n--- end ${o.name} ---`);
44
+ }
45
+ return a.join("\n\n");
46
+ }
47
+ //#endregion
48
+ export { a as buildAttachmentBlock };
49
+
50
+ //# sourceMappingURL=attachmentExtract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachmentExtract.js","names":[],"sources":["../../../src/bigconsole/assistant/attachmentExtract.ts"],"sourcesContent":["/**\n * Client-side extraction of an uploaded data file into a capped text/rows\n * preview that gets folded into the assistant prompt.\n *\n * Lives in the BigConsole product layer (not fe-libs) because it pulls in the\n * xlsx / pdfjs parsers — fe-libs stays parsing-free and only carries the raw\n * `File`s through `AssistantSendArgs.attachments`. Heavy parsers are loaded via\n * dynamic `import()` so they code-split and only download when a file is\n * actually attached.\n *\n * The agent receives a CAPPED preview — enough to design a DataSink schema from,\n * not the whole file — because the payload rides the `proxySandboxRequest`\n * gateway call (bounded execution budget) and the model has a context limit.\n */\n\nconst MAX_CHARS = 100_000; // ~100 KB of text per file\nconst MAX_ROWS = 200;\n\nfunction isTextLike(file: File): boolean {\n const name = file.name.toLowerCase();\n return (\n name.endsWith('.json') ||\n name.endsWith('.csv') ||\n name.endsWith('.txt') ||\n file.type === 'application/json' ||\n file.type === 'text/csv' ||\n file.type.startsWith('text/')\n );\n}\n\nasync function extractOne(file: File): Promise<string> {\n const name = file.name.toLowerCase();\n\n // JSON / CSV / plain text — native, no deps.\n if (isTextLike(file)) {\n return await file.text();\n }\n\n // Excel — SheetJS, dynamically imported. First sheet → CSV (compact + agent-friendly).\n if (name.endsWith('.xlsx') || name.endsWith('.xls')) {\n const XLSX = await import('xlsx');\n const buf = await file.arrayBuffer();\n const wb = XLSX.read(buf, { type: 'array' });\n const first = wb.SheetNames[0];\n if (!first) return '';\n return XLSX.utils.sheet_to_csv(wb.Sheets[first]);\n }\n\n // PDF — best-effort text-layer extraction via pdfjs (dynamically imported).\n // Unreliable for tabular data and useless for scanned PDFs; the caller shows a\n // graceful note if this throws. NOTE: pdfjs worker setup is Vite-specific and\n // must be verified against a running build.\n if (name.endsWith('.pdf') || file.type === 'application/pdf') {\n const pdfjs = await import('pdfjs-dist');\n const buf = await file.arrayBuffer();\n const doc = await pdfjs.getDocument({ data: new Uint8Array(buf) }).promise;\n const parts: string[] = [];\n const pages = Math.min(doc.numPages, 20);\n for (let page = 1; page <= pages; page += 1) {\n const content = await (await doc.getPage(page)).getTextContent();\n parts.push(content.items.map((item) => ('str' in item ? item.str : '')).join(' '));\n }\n return parts.join('\\n');\n }\n\n // Unknown extension → best-effort text.\n return await file.text();\n}\n\n/** Keep the first MAX_ROWS lines / MAX_CHARS chars so a huge file can't blow the\n * prompt. Returns whether anything was dropped so the agent knows it's a sample. */\nfunction limit(text: string): { text: string; truncated: boolean } {\n let out = text;\n let truncated = false;\n const lines = out.split(/\\r?\\n/);\n if (lines.length > MAX_ROWS) {\n out = lines.slice(0, MAX_ROWS).join('\\n');\n truncated = true;\n }\n if (out.length > MAX_CHARS) {\n out = out.slice(0, MAX_CHARS);\n truncated = true;\n }\n return { text: out, truncated };\n}\n\n/**\n * Extract every attachment and format them as fenced \"Attached data source\"\n * blocks the agent can read and turn into a DataSink. Files that fail to parse\n * (e.g. a scanned PDF) produce a short note rather than aborting the send.\n */\nexport async function buildAttachmentBlock(files: File[]): Promise<string> {\n const blocks: string[] = [];\n for (const file of files) {\n let raw: string;\n try {\n raw = await extractOne(file);\n } catch (err) {\n const reason = err instanceof Error ? err.message : 'unknown error';\n blocks.push(\n `--- Attached file \"${file.name}\" could not be auto-read (${reason}). ` +\n `Please paste its rows here instead. ---`\n );\n continue;\n }\n const { text, truncated } = limit(raw.trim());\n const note = truncated ? ` (sample — first ${MAX_ROWS} rows / ~${Math.round(MAX_CHARS / 1000)}KB)` : '';\n blocks.push(`--- Attached data source: ${file.name}${note} ---\\n${text}\\n--- end ${file.name} ---`);\n }\n return blocks.join('\\n\\n');\n}\n"],"mappings":";AAeA,IAAM,IAAY,KACZ,IAAW;AAEjB,SAAS,EAAW,GAAqB;CACvC,IAAM,IAAO,EAAK,KAAK,aAAa;AACpC,QACE,EAAK,SAAS,QAAQ,IACtB,EAAK,SAAS,OAAO,IACrB,EAAK,SAAS,OAAO,IACrB,EAAK,SAAS,sBACd,EAAK,SAAS,cACd,EAAK,KAAK,WAAW,QAAQ;;AAIjC,eAAe,EAAW,GAA6B;CACrD,IAAM,IAAO,EAAK,KAAK,aAAa;AAGpC,KAAI,EAAW,EAAK,CAClB,QAAO,MAAM,EAAK,MAAM;AAI1B,KAAI,EAAK,SAAS,QAAQ,IAAI,EAAK,SAAS,OAAO,EAAE;EACnD,IAAM,IAAO,MAAM,OAAO,oCACpB,IAAM,MAAM,EAAK,aAAa,EAC9B,IAAK,EAAK,KAAK,GAAK,EAAE,MAAM,SAAS,CAAC,EACtC,IAAQ,EAAG,WAAW;AAE5B,SADK,IACE,EAAK,MAAM,aAAa,EAAG,OAAO,GAAO,GAD7B;;AAQrB,KAAI,EAAK,SAAS,OAAO,IAAI,EAAK,SAAS,mBAAmB;EAC5D,IAAM,IAAQ,MAAM,OAAO,+CACrB,IAAM,MAAM,EAAK,aAAa,EAC9B,IAAM,MAAM,EAAM,YAAY,EAAE,MAAM,IAAI,WAAW,EAAI,EAAE,CAAC,CAAC,SAC7D,IAAkB,EAAE,EACpB,IAAQ,KAAK,IAAI,EAAI,UAAU,GAAG;AACxC,OAAK,IAAI,IAAO,GAAG,KAAQ,GAAO,KAAQ,GAAG;GAC3C,IAAM,IAAU,OAAO,MAAM,EAAI,QAAQ,EAAK,EAAE,gBAAgB;AAChE,KAAM,KAAK,EAAQ,MAAM,KAAK,MAAU,SAAS,IAAO,EAAK,MAAM,GAAI,CAAC,KAAK,IAAI,CAAC;;AAEpF,SAAO,EAAM,KAAK,KAAK;;AAIzB,QAAO,MAAM,EAAK,MAAM;;AAK1B,SAAS,EAAM,GAAoD;CACjE,IAAI,IAAM,GACN,IAAY,IACV,IAAQ,EAAI,MAAM,QAAQ;AAShC,QARI,EAAM,SAAS,MACjB,IAAM,EAAM,MAAM,GAAG,EAAS,CAAC,KAAK,KAAK,EACzC,IAAY,KAEV,EAAI,SAAS,MACf,IAAM,EAAI,MAAM,GAAG,EAAU,EAC7B,IAAY,KAEP;EAAE,MAAM;EAAK;EAAW;;AAQjC,eAAsB,EAAqB,GAAgC;CACzE,IAAM,IAAmB,EAAE;AAC3B,MAAK,IAAM,KAAQ,GAAO;EACxB,IAAI;AACJ,MAAI;AACF,OAAM,MAAM,EAAW,EAAK;WACrB,GAAK;GACZ,IAAM,IAAS,aAAe,QAAQ,EAAI,UAAU;AACpD,KAAO,KACL,sBAAsB,EAAK,KAAK,4BAA4B,EAAO,4CAEpE;AACD;;EAEF,IAAM,EAAE,SAAM,iBAAc,EAAM,EAAI,MAAM,CAAC,EACvC,IAAO,IAAY,oBAAoB,EAAS,WAAW,KAAK,MAAM,IAAY,IAAK,CAAC,OAAO;AACrG,IAAO,KAAK,6BAA6B,EAAK,OAAO,EAAK,QAAQ,EAAK,YAAY,EAAK,KAAK,MAAM;;AAErG,QAAO,EAAO,KAAK,OAAO"}
@@ -1,24 +1,25 @@
1
1
  import { useAssistantRunStore as e } from "./assistantRunStore.js";
2
2
  import { createAssistantSandbox as t, createAssistantSession as n, extendAssistantSandboxTTL as r, findExistingSandbox as i, getAssistantMessages as a, sendAssistantPromptAsync as o, waitForAssistantServiceReady as s, waitForSandboxReady as c } from "./assistantApi.js";
3
- import { deleteAssistantConversation as l, getAssistantConversationMessages as u, listAssistantConversations as d, saveAssistantTurn as ee } from "./conversationHistoryApi.js";
3
+ import { buildAttachmentBlock as l } from "./attachmentExtract.js";
4
+ import { deleteAssistantConversation as u, getAssistantConversationMessages as d, listAssistantConversations as f, saveAssistantTurn as ee } from "./conversationHistoryApi.js";
4
5
  import { gatherPageContext as te } from "./pageContext.js";
5
- import { useCallback as f, useMemo as p, useRef as m } from "react";
6
- import { useAuthToken as h } from "@burdenoff/fe-libs/shared/providers/shell";
6
+ import { useCallback as p, useMemo as m, useRef as h } from "react";
7
+ import { useAuthToken as g } from "@burdenoff/fe-libs/shared/providers/shell";
7
8
  //#region src/bigconsole/assistant/createSandboxAssistantTransport.ts
8
- var g = "api-calls", ne = 42e4, re = 1500, ie = 3e4, _ = 200, v = 25, y = 6e3, b = "bc-assistant-sandbox-id", x = "bc-assistant-session-id", S = "bc-assistant-conversation-id";
9
- function C(e) {
9
+ var _ = "api-calls", ne = 42e4, re = 1500, ie = 3e4, v = 200, y = 25, b = 6e3, x = "bc-assistant-sandbox-id", S = "bc-assistant-session-id", C = "bc-assistant-conversation-id";
10
+ function w(e) {
10
11
  try {
11
12
  return window.sessionStorage.getItem(e);
12
13
  } catch {
13
14
  return null;
14
15
  }
15
16
  }
16
- function w(e, t) {
17
+ function T(e, t) {
17
18
  try {
18
19
  t ? window.sessionStorage.setItem(e, t) : window.sessionStorage.removeItem(e);
19
20
  } catch {}
20
21
  }
21
- function T(e) {
22
+ function E(e) {
22
23
  try {
23
24
  let t = e === "workspaceId" ? "burdenoff-active-context-workspace" : "burdenoff-active-context-organization", n = localStorage.getItem(t);
24
25
  if (n) return n;
@@ -30,16 +31,16 @@ function T(e) {
30
31
  return "";
31
32
  }
32
33
  }
33
- function E(e) {
34
- return new URLSearchParams(window.location.search).get("workspace") ?? T("workspaceId") ?? e ?? "";
34
+ function D(e) {
35
+ return new URLSearchParams(window.location.search).get("workspace") ?? E("workspaceId") ?? e ?? "";
35
36
  }
36
- function D() {
37
- return new URLSearchParams(window.location.search).get("org") ?? T("organizationId");
37
+ function O() {
38
+ return new URLSearchParams(window.location.search).get("org") ?? E("organizationId");
38
39
  }
39
- function O(e) {
40
+ function k(e) {
40
41
  return e.info?.role ?? e.role;
41
42
  }
42
- function k(e) {
43
+ function A(e) {
43
44
  let t = e.info?.time?.created;
44
45
  if (t !== void 0) return t;
45
46
  let n = e.createdAt;
@@ -50,7 +51,7 @@ function k(e) {
50
51
  }
51
52
  return n;
52
53
  }
53
- function A(e) {
54
+ function j(e) {
54
55
  let t = e.info?.time?.completed;
55
56
  if (t !== void 0) return t;
56
57
  let n = e.completedAt;
@@ -62,10 +63,10 @@ function A(e) {
62
63
  return n;
63
64
  }
64
65
  }
65
- function j(e) {
66
+ function M(e) {
66
67
  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() : "");
67
68
  }
68
- var M = {
69
+ var N = {
69
70
  bash: "Running a command",
70
71
  webfetch: "Fetching a page",
71
72
  "file.read": "Reading files",
@@ -76,39 +77,39 @@ var M = {
76
77
  todowrite: "Planning the steps",
77
78
  todoread: "Reviewing the plan"
78
79
  };
79
- function N(e) {
80
+ function P(e) {
80
81
  return typeof e == "object" && e ? e : void 0;
81
82
  }
82
- function P(e) {
83
- let t = e.tool ?? "tool", n = N(e.state?.input), r = n?.description;
83
+ function F(e) {
84
+ let t = e.tool ?? "tool", n = P(e.state?.input), r = n?.description;
84
85
  if (typeof r == "string" && r.trim()) return r.trim();
85
86
  let i = n?.todos;
86
87
  if (Array.isArray(i)) {
87
- let e = N(i.find((e) => N(e)?.status === "in_progress") ?? i[0])?.content;
88
+ let e = P(i.find((e) => P(e)?.status === "in_progress") ?? i[0])?.content;
88
89
  if (typeof e == "string" && e.trim()) return e.trim();
89
90
  }
90
- return M[t] ?? `Running ${t}`;
91
+ return N[t] ?? `Running ${t}`;
91
92
  }
92
- function F(e) {
93
+ function I(e) {
93
94
  return (e.parts ?? []).filter((e) => e.type === "tool" && e.tool).map((e) => {
94
- let t = e.state?.status ?? "running", n = P(e);
95
+ let t = e.state?.status ?? "running", n = F(e);
95
96
  return t === "completed" ? `✓ ${n}` : t === "failed" ? `⚠ ${n}` : `⏳ ${n}…`;
96
97
  });
97
98
  }
98
- function I(e, t, n, r) {
99
- let i = e.filter((e) => O(e) === "assistant" && k(e) >= t).sort((e, t) => k(e) - k(t));
99
+ function L(e, t, n, r) {
100
+ let i = e.filter((e) => k(e) === "assistant" && A(e) >= t).sort((e, t) => A(e) - A(t));
100
101
  i.length === 0 && e.length > 0 && console.log("[BigConsole-Assistant] buildProgress: no relevant messages", {
101
102
  totalMessages: e.length,
102
103
  sinceMs: t,
103
- messageRoles: e.map((e) => O(e)),
104
- messageTimestamps: e.map((e) => k(e))
104
+ messageRoles: e.map((e) => k(e)),
105
+ messageTimestamps: e.map((e) => A(e))
105
106
  });
106
107
  let a, o;
107
108
  if (i.length === 0) a = "", o = n === a && r !== void 0 && Date.now() - r >= 15e3;
108
109
  else {
109
- let e = i[i.length - 1], t = i.map(j).filter(Boolean), s = F(e);
110
+ let e = i[i.length - 1], t = i.map(M).filter(Boolean), s = I(e);
110
111
  a = [...t, ...s].join("\n\n");
111
- let c = !!A(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;
112
+ let c = !!j(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;
112
113
  o = c || u;
113
114
  }
114
115
  return {
@@ -116,7 +117,7 @@ function I(e, t, n, r) {
116
117
  done: o
117
118
  };
118
119
  }
119
- function L(e) {
120
+ function R(e) {
120
121
  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]");
121
122
  }
122
123
  function ae(e) {
@@ -140,241 +141,241 @@ function ae(e) {
140
141
  "unexpected error"
141
142
  ].some((e) => t.includes(e));
142
143
  }
143
- function R() {
144
- let { getAccessToken: T, getWorkspaceToken: A, userId: j, workspaceId: M } = h(), [N, P, F] = p(() => [
145
- C(b),
146
- C(x),
147
- C(S)
148
- ], []), R = m(N), z = m(P), B = m(F), V = m(null), H = f((e) => {
149
- R.current = e, w(b, e);
150
- }, []), U = f((e) => {
151
- z.current = e, w(x, e);
152
- }, []), W = f((e) => {
153
- B.current = e, w(S, e);
154
- }, []), G = f(async (e, r) => {
155
- let a = R.current;
144
+ function z() {
145
+ let { getAccessToken: E, getWorkspaceToken: j, userId: M, workspaceId: N } = g(), [P, F, I] = m(() => [
146
+ w(x),
147
+ w(S),
148
+ w(C)
149
+ ], []), z = h(P), B = h(F), V = h(I), H = h(null), U = p((e) => {
150
+ z.current = e, T(x, e);
151
+ }, []), W = p((e) => {
152
+ B.current = e, T(S, e);
153
+ }, []), G = p((e) => {
154
+ V.current = e, T(C, e);
155
+ }, []), K = p(async (e, r) => {
156
+ let a = z.current;
156
157
  if (console.log("[BigConsole-Assistant] ensureRuntime start", {
157
158
  sandboxId: a,
158
159
  workspaceId: e
159
160
  }), !a) {
160
- if (!T()) throw Error("The assistant requires an authenticated session. Please sign in again.");
161
- if (console.log("[BigConsole-Assistant] findExistingSandbox called"), a = await i(e, g, r), console.log("[BigConsole-Assistant] findExistingSandbox result", { sandboxId: a }), a) try {
162
- console.log("[BigConsole-Assistant] waitForSandboxReady called (reused)", { sandboxId: a }), await c(a, e, r), console.log("[BigConsole-Assistant] waitForSandboxReady done (reused)", { sandboxId: a }), console.log("[BigConsole-Assistant] waitForAssistantServiceReady called (reused)", { sandboxId: a }), await s(a, e, g, r), console.log("[BigConsole-Assistant] waitForAssistantServiceReady done (reused)", { sandboxId: a });
161
+ if (!E()) throw Error("The assistant requires an authenticated session. Please sign in again.");
162
+ if (console.log("[BigConsole-Assistant] findExistingSandbox called"), a = await i(e, _, r), console.log("[BigConsole-Assistant] findExistingSandbox result", { sandboxId: a }), a) try {
163
+ console.log("[BigConsole-Assistant] waitForSandboxReady called (reused)", { sandboxId: a }), await c(a, e, r), console.log("[BigConsole-Assistant] waitForSandboxReady done (reused)", { sandboxId: a }), console.log("[BigConsole-Assistant] waitForAssistantServiceReady called (reused)", { sandboxId: a }), await s(a, e, _, r), console.log("[BigConsole-Assistant] waitForAssistantServiceReady done (reused)", { sandboxId: a });
163
164
  } catch (e) {
164
165
  console.warn("[BigConsole-Assistant] existing sandbox unusable, falling back to fresh sandbox", {
165
166
  sandboxId: a,
166
167
  error: e instanceof Error ? e.message : String(e)
167
168
  }), a = null;
168
169
  }
169
- a || (console.log("[BigConsole-Assistant] createAssistantSandbox called"), a = await t(g, 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, g, r), console.log("[BigConsole-Assistant] waitForAssistantServiceReady done (fresh)", { sandboxId: a })), H(a);
170
+ 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);
170
171
  }
171
- let o = z.current;
172
+ let o = B.current;
172
173
  return console.log("[BigConsole-Assistant] session check", {
173
174
  sessionId: o,
174
175
  sandboxId: a
175
176
  }), o || (console.log("[BigConsole-Assistant] createAssistantSession called", {
176
177
  sandboxId: a,
177
178
  workspaceId: e
178
- }), o = (await n(a, e, g, r)).sessionId, U(o)), {
179
+ }), o = (await n(a, e, _, r)).sessionId, W(o)), {
179
180
  sandboxId: a,
180
181
  sessionId: o
181
182
  };
182
- }, [T]), K = f(async ({ prompt: t, onProgress: n, signal: i }) => {
183
- let s = E(M);
183
+ }, [E]), q = p(async ({ prompt: t, attachments: n, onProgress: i, signal: s }) => {
184
+ let c = D(N);
184
185
  if (console.log("[BigConsole-Assistant] sendPrompt called", {
185
186
  promptLength: t.length,
186
- workspaceId: s,
187
- hasCtxWorkspaceId: !!M,
187
+ workspaceId: c,
188
+ hasCtxWorkspaceId: !!N,
188
189
  authContextKeys: {
189
- hasAccessToken: !!T(),
190
- hasWorkspaceToken: !!A(),
191
- hasUserId: !!j
190
+ hasAccessToken: !!E(),
191
+ hasWorkspaceToken: !!j(),
192
+ hasUserId: !!M
192
193
  },
193
194
  locationSearch: window.location.search
194
- }), !s) throw Error("The assistant needs an active workspace. Open a workspace and try again.");
195
- let c = {
196
- accessToken: T(),
197
- workspaceToken: A(),
198
- userId: j,
199
- organizationId: D()
195
+ }), !c) throw Error("The assistant needs an active workspace. Open a workspace and try again.");
196
+ let u = {
197
+ accessToken: E(),
198
+ workspaceToken: j(),
199
+ userId: M,
200
+ organizationId: O()
200
201
  };
201
202
  console.log("[BigConsole-Assistant] authContext prepared", {
202
- hasAccessToken: !!c.accessToken,
203
- hasWorkspaceToken: !!c.workspaceToken,
204
- hasUserId: !!c.userId,
205
- hasOrgId: !!c.organizationId
203
+ hasAccessToken: !!u.accessToken,
204
+ hasWorkspaceToken: !!u.workspaceToken,
205
+ hasUserId: !!u.userId,
206
+ hasOrgId: !!u.organizationId
206
207
  }), e.getState().startRun(t);
207
- let l = (t) => {
208
- n(t), e.getState().applyProgress(t);
209
- }, u = async (e) => {
208
+ let d = (t) => {
209
+ i(t), e.getState().applyProgress(t);
210
+ }, f = async (e) => {
210
211
  try {
211
212
  console.log("[BigConsole-Assistant] run attempt", e);
212
- let { sandboxId: n, sessionId: u } = await G(s, c);
213
+ let { sandboxId: i, sessionId: f } = await K(c, u);
213
214
  console.log("[BigConsole-Assistant] ensureRuntime resolved", {
214
- sandboxId: n,
215
- sessionId: u
215
+ sandboxId: i,
216
+ sessionId: f
216
217
  });
217
- let d = V.current, f = d ? `${d}\n\n---\n\n${t}` : t, p = Date.now();
218
+ let p = H.current, m = n && n.length > 0 ? await l(n) : "", h = m ? `${t}\n\n${m}` : t, g = p ? `${p}\n\n---\n\n${h}` : h, v = Date.now();
218
219
  console.log("[BigConsole-Assistant] calling sendAssistantPromptAsync", {
219
- sandboxId: n,
220
- workspaceId: s,
221
- sessionId: u,
222
- promptLength: f.length,
223
- replayed: !!d
224
- }), await o(n, s, u, f, g, te(), c);
225
- let m = Date.now() + ne, h = Date.now(), _ = "", v = Date.now(), y = I([], p);
226
- for (; Date.now() < m;) {
227
- if (i.aborted) throw Error("Cancelled");
228
- let e = await a(n, s, u, c, 50);
220
+ sandboxId: i,
221
+ workspaceId: c,
222
+ sessionId: f,
223
+ promptLength: g.length,
224
+ replayed: !!p
225
+ }), await o(i, c, f, g, _, te(), u);
226
+ let y = Date.now() + ne, b = Date.now(), x = "", S = Date.now(), C = L([], v);
227
+ for (; Date.now() < y;) {
228
+ if (s.aborted) throw Error("Cancelled");
229
+ let e = await a(i, c, f, u, 50);
229
230
  if (console.log("[BigConsole-Assistant] poll", {
230
- elapsedMs: Date.now() - p,
231
+ elapsedMs: Date.now() - v,
231
232
  messageCount: e.length,
232
- firstFewRoles: e.slice(0, 3).map((e) => O(e)),
233
- firstFewTimestamps: e.slice(0, 3).map((e) => k(e))
234
- }), y = I(e, p, _, v), console.log("[BigConsole-Assistant] progress", {
235
- contentPreview: y.content.slice(0, 100),
236
- done: y.done,
237
- lastContentChangeAt: Date.now() - v
238
- }), y.content !== _ && (_ = y.content, v = Date.now()), l(L(y.content)), y.done) {
233
+ firstFewRoles: e.slice(0, 3).map((e) => k(e)),
234
+ firstFewTimestamps: e.slice(0, 3).map((e) => A(e))
235
+ }), C = L(e, v, x, S), console.log("[BigConsole-Assistant] progress", {
236
+ contentPreview: C.content.slice(0, 100),
237
+ done: C.done,
238
+ lastContentChangeAt: Date.now() - S
239
+ }), C.content !== x && (x = C.content, S = Date.now()), d(R(C.content)), C.done) {
239
240
  console.log("[BigConsole-Assistant] progress.done=true, breaking poll loop");
240
241
  break;
241
242
  }
242
- Date.now() - h > ie && (await r(n, s, 600, c).catch(() => void 0), h = Date.now()), await new Promise((e) => setTimeout(e, re));
243
+ Date.now() - b > ie && (await r(i, c, 600, u).catch(() => void 0), b = Date.now()), await new Promise((e) => setTimeout(e, re));
243
244
  }
244
- 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.");
245
- let b = L(y.content);
246
- 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.");
247
- V.current = null;
245
+ 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.");
246
+ let w = R(C.content);
247
+ 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.");
248
+ H.current = null;
248
249
  try {
249
- W((await ee({
250
- conversationId: B.current,
250
+ G((await ee({
251
+ conversationId: V.current,
251
252
  prompt: t,
252
- reply: b,
253
- agentSessionId: u
254
- }, s, c)).id);
253
+ reply: w,
254
+ agentSessionId: f
255
+ }, c, u)).id);
255
256
  } catch (e) {
256
257
  console.warn("[BigConsole-Assistant] could not save turn to history", { error: e instanceof Error ? e.message : String(e) });
257
258
  }
258
- return { text: b };
259
+ return { text: w };
259
260
  } catch (t) {
260
261
  if (console.error("[BigConsole-Assistant] run error", {
261
262
  attempt: e,
262
263
  error: t instanceof Error ? t.message : String(t),
263
264
  stack: t instanceof Error ? t.stack : void 0,
264
- sandboxId: R.current,
265
- sessionId: z.current
266
- }), e === 1 && ae(t)) return H(null), U(null), u(2);
265
+ sandboxId: z.current,
266
+ sessionId: B.current
267
+ }), e === 1 && ae(t)) return U(null), W(null), f(2);
267
268
  throw t;
268
269
  }
269
270
  };
270
271
  try {
271
- let t = await u(1);
272
+ let t = await f(1);
272
273
  return e.getState().finishRun(null), t;
273
274
  } catch (t) {
274
275
  throw e.getState().finishRun(t instanceof Error ? t.message : String(t)), t;
275
276
  }
276
277
  }, [
277
- M,
278
- G,
279
- T,
280
- A,
278
+ N,
279
+ K,
280
+ E,
281
281
  j,
282
- H,
282
+ M,
283
283
  U,
284
- W
285
- ]), q = f(() => ({
286
- accessToken: T(),
287
- workspaceToken: A(),
288
- userId: j,
289
- organizationId: D()
284
+ W,
285
+ G
286
+ ]), J = p(() => ({
287
+ accessToken: E(),
288
+ workspaceToken: j(),
289
+ userId: M,
290
+ organizationId: O()
290
291
  }), [
291
- T,
292
- A,
293
- j
294
- ]), J = f((e) => e.length === 0 ? null : [
292
+ E,
293
+ j,
294
+ M
295
+ ]), Y = p((e) => e.length === 0 ? null : [
295
296
  "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.",
296
297
  "--- earlier in this conversation ---",
297
- e.map((e) => `${e.role === "user" ? "User" : "Assistant"}: ${e.content}`).join("\n\n").slice(-y),
298
+ e.map((e) => `${e.role === "user" ? "User" : "Assistant"}: ${e.content}`).join("\n\n").slice(-b),
298
299
  "--- end ---"
299
- ].join("\n\n"), []), Y = f((e) => e.map((e) => ({
300
+ ].join("\n\n"), []), X = p((e) => e.map((e) => ({
300
301
  id: e.id,
301
302
  role: e.role === "ASSISTANT" ? "assistant" : "user",
302
- content: L(e.content)
303
- })), []), X = f(async (e, t, n) => {
304
- let r = Y(await u(e.id, t, n, _));
305
- return W(e.id), e.agentSessionId ? (U(e.agentSessionId), V.current = null) : (U(null), V.current = J(r)), r;
303
+ content: R(e.content)
304
+ })), []), Z = p(async (e, t, n) => {
305
+ let r = X(await d(e.id, t, n, v));
306
+ return G(e.id), e.agentSessionId ? (W(e.agentSessionId), H.current = null) : (W(null), H.current = Y(r)), r;
306
307
  }, [
307
- Y,
308
+ X,
309
+ G,
308
310
  W,
309
- U,
310
- J
311
- ]), Z = f(async () => {
312
- let e = E(M);
313
- if (!e || !T()) return [];
314
- let t = q();
311
+ Y
312
+ ]), Q = p(async () => {
313
+ let e = D(N);
314
+ if (!e || !E()) return [];
315
+ let t = J();
315
316
  try {
316
- let n = await d(e, t, v), r = B.current, i = n.find((e) => e.id === r) ?? n[0];
317
- return i ? await X(i, e, t) : [];
317
+ let n = await f(e, t, y), r = V.current, i = n.find((e) => e.id === r) ?? n[0];
318
+ return i ? await Z(i, e, t) : [];
318
319
  } catch (e) {
319
320
  return console.warn("[BigConsole-Assistant] could not restore history", { error: e instanceof Error ? e.message : String(e) }), [];
320
321
  }
321
322
  }, [
322
- M,
323
- T,
324
- q,
325
- X
326
- ]), Q = f(async () => {
327
- let e = E(M);
328
- if (!e || !T()) return [];
323
+ N,
324
+ E,
325
+ J,
326
+ Z
327
+ ]), $ = p(async () => {
328
+ let e = D(N);
329
+ if (!e || !E()) return [];
329
330
  try {
330
- return (await d(e, q(), v)).map((e) => ({
331
+ return (await f(e, J(), y)).map((e) => ({
331
332
  id: e.id,
332
333
  title: e.title?.trim() || "New chat",
333
334
  updatedAt: Date.parse(e.updatedAt) || void 0,
334
- active: e.id === B.current
335
+ active: e.id === V.current
335
336
  }));
336
337
  } catch {
337
338
  return [];
338
339
  }
339
340
  }, [
340
- M,
341
- T,
342
- q
343
- ]), $ = f(async () => (W(null), U(null), V.current = null, Promise.resolve()), [W, U]), oe = f(async (e) => {
344
- let t = E(M);
345
- t && (await l(e, t, q()), B.current === e && (W(null), U(null), V.current = null));
341
+ N,
342
+ E,
343
+ J
344
+ ]), oe = p(async () => (G(null), W(null), H.current = null, Promise.resolve()), [G, W]), se = p(async (e) => {
345
+ let t = D(N);
346
+ t && (await u(e, t, J()), V.current === e && (G(null), W(null), H.current = null));
346
347
  }, [
347
- M,
348
- q,
349
- W,
350
- U
351
- ]), se = f(async (e) => {
352
- let t = E(M);
348
+ N,
349
+ J,
350
+ G,
351
+ W
352
+ ]), ce = p(async (e) => {
353
+ let t = D(N);
353
354
  if (!t) return [];
354
- let n = q(), r = (await d(t, n, v)).find((t) => t.id === e);
355
- return r ? X(r, t, n) : [];
355
+ let n = J(), r = (await f(t, n, y)).find((t) => t.id === e);
356
+ return r ? Z(r, t, n) : [];
356
357
  }, [
357
- M,
358
- q,
359
- X
358
+ N,
359
+ J,
360
+ Z
360
361
  ]);
361
- return p(() => ({
362
- sendPrompt: K,
363
- loadHistory: Z,
364
- listSessions: Q,
365
- newSession: $,
366
- deleteSession: oe,
367
- selectSession: se
362
+ return m(() => ({
363
+ sendPrompt: q,
364
+ loadHistory: Q,
365
+ listSessions: $,
366
+ newSession: oe,
367
+ deleteSession: se,
368
+ selectSession: ce
368
369
  }), [
369
- K,
370
- Z,
370
+ q,
371
371
  Q,
372
372
  $,
373
373
  oe,
374
- se
374
+ se,
375
+ ce
375
376
  ]);
376
377
  }
377
378
  //#endregion
378
- export { R as useSandboxAssistantTransport };
379
+ export { z as useSandboxAssistantTransport };
379
380
 
380
381
  //# sourceMappingURL=createSandboxAssistantTransport.js.map