@burdenoff/fe-libs 2026.725.1 → 2026.725.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared/assistant/api.d.ts +24 -2
- package/dist/shared/assistant/api.d.ts.map +1 -1
- package/dist/shared/assistant/api.js +24 -15
- package/dist/shared/assistant/createSandboxAssistantTransport.d.ts.map +1 -1
- package/dist/shared/assistant/createSandboxAssistantTransport.js +1 -1
- package/dist/shared/assistant/index.d.ts +3 -3
- package/dist/shared/assistant/index.d.ts.map +1 -1
- package/dist/shared/assistant/progress.d.ts +14 -0
- package/dist/shared/assistant/progress.d.ts.map +1 -1
- package/dist/shared/assistant/progress.js +42 -17
- package/dist/shared/assistant/types.d.ts +48 -0
- package/dist/shared/assistant/types.d.ts.map +1 -1
- package/dist/shared/providers/shell/ActiveContextProvider.d.ts +34 -0
- package/dist/shared/providers/shell/ActiveContextProvider.d.ts.map +1 -1
- package/dist/shared/providers/shell/ActiveContextProvider.js +127 -113
- package/dist/shared/providers/shell/ActiveContextStorage.d.ts +25 -0
- package/dist/shared/providers/shell/ActiveContextStorage.d.ts.map +1 -1
- package/dist/shared/providers/shell/ActiveContextStorage.js +43 -2
- package/dist/shared-assistant.js +6 -6
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssistantMode, AssistantRawMessage, AssistantSandboxAuthContext, AssistantArtifact, AssistantSessionInfo, DownloadedAssistantArtifact, StreamAccess } from './types';
|
|
1
|
+
import { AssistantMode, AssistantPromptPart, AssistantRawMessage, AssistantSandboxAuthContext, AssistantArtifact, AssistantSessionInfo, DownloadedAssistantArtifact, StreamAccess } from './types';
|
|
2
2
|
export declare function findExistingSandbox(workspaceId: string, mode: AssistantMode, isProd: boolean, authContext: AssistantSandboxAuthContext): Promise<string | null>;
|
|
3
3
|
export declare function createAssistantSandbox(product: string, mode: AssistantMode, workspaceId: string, isProd: boolean, ttlSeconds: number, authContext: AssistantSandboxAuthContext): Promise<string>;
|
|
4
4
|
/**
|
|
@@ -11,7 +11,29 @@ export declare function waitForAssistantServiceReady(sandboxId: string, workspac
|
|
|
11
11
|
export declare function createAssistantSession(sandboxId: string, workspaceId: string, mode: AssistantMode, authContext: AssistantSandboxAuthContext): Promise<{
|
|
12
12
|
sessionId: string;
|
|
13
13
|
}>;
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Assemble the `/sessions/:id/prompt-async` request body. Pure + exported so the
|
|
16
|
+
* backward-compatibility contract is unit-testable without touching the network.
|
|
17
|
+
*
|
|
18
|
+
* The contract, deliberately additive:
|
|
19
|
+
* - `prompt` is ALWAYS present. A bridge that predates multimodal ignores the
|
|
20
|
+
* unknown `parts` key and answers from `prompt` — degradation, not failure.
|
|
21
|
+
* - `parts` appears ONLY when there is at least one. A text-only turn therefore
|
|
22
|
+
* produces a byte-identical body to the pre-multimodal client.
|
|
23
|
+
* - When a bridge does understand `parts`, `parts` wins and `prompt` is the
|
|
24
|
+
* text-only fallback.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildPromptRequestBody(args: {
|
|
27
|
+
mode: AssistantMode;
|
|
28
|
+
prompt: string;
|
|
29
|
+
pageContext: Record<string, unknown> | undefined;
|
|
30
|
+
parts?: AssistantPromptPart[];
|
|
31
|
+
}): Record<string, unknown>;
|
|
32
|
+
export declare function sendAssistantPromptAsync(sandboxId: string, workspaceId: string, sessionId: string, prompt: string, mode: AssistantMode, pageContext: Record<string, unknown> | undefined, authContext: AssistantSandboxAuthContext,
|
|
33
|
+
/** Multimodal extras. Optional + trailing, so every existing call site is unaffected. */
|
|
34
|
+
options?: {
|
|
35
|
+
parts?: AssistantPromptPart[];
|
|
36
|
+
}): Promise<{
|
|
15
37
|
messageID?: string;
|
|
16
38
|
}>;
|
|
17
39
|
export declare function getAssistantMessages(sandboxId: string, workspaceId: string, sessionId: string, authContext: AssistantSandboxAuthContext, opts?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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) {
|
|
156
156
|
return { sessionId: (await y(e, t, "/sessions", "POST", { mode: n }, r)).session.id };
|
|
157
157
|
}
|
|
158
|
-
|
|
159
|
-
let
|
|
158
|
+
function D(e) {
|
|
159
|
+
let { mode: t, prompt: n, pageContext: r, parts: i } = e, a = {
|
|
160
|
+
mode: t,
|
|
161
|
+
prompt: n,
|
|
162
|
+
pageContext: r
|
|
163
|
+
};
|
|
164
|
+
return i && i.length > 0 && (a.parts = i), a;
|
|
165
|
+
}
|
|
166
|
+
async function O(e, t, n, r, i, a, o, s) {
|
|
167
|
+
let c = await y(e, t, `/sessions/${n}/prompt-async`, "POST", D({
|
|
160
168
|
mode: i,
|
|
161
169
|
prompt: r,
|
|
162
|
-
pageContext: a
|
|
163
|
-
|
|
164
|
-
|
|
170
|
+
pageContext: a,
|
|
171
|
+
parts: s?.parts
|
|
172
|
+
}), o);
|
|
173
|
+
return { messageID: typeof c.messageID == "string" ? c.messageID : void 0 };
|
|
165
174
|
}
|
|
166
|
-
async function
|
|
175
|
+
async function k(e, t, n, r, i) {
|
|
167
176
|
let a = `/sessions/${n}/messages?limit=${i?.limit ?? 50}`;
|
|
168
177
|
i?.sinceMs && h("sinceParam") !== "unsupported" && (a += `&since=${i.sinceMs}`);
|
|
169
178
|
let o = await y(e, t, a, "GET", void 0, r);
|
|
170
179
|
return typeof o.now == "number" && _("sinceParam"), o.messages ?? [];
|
|
171
180
|
}
|
|
172
|
-
async function
|
|
181
|
+
async function A(e, t, n, r) {
|
|
173
182
|
if (h("sse") === "unsupported") return null;
|
|
174
183
|
try {
|
|
175
184
|
let i = await y(e, t, `/sessions/${n}/stream-url`, "GET", void 0, r);
|
|
@@ -181,7 +190,7 @@ async function k(e, t, n, r) {
|
|
|
181
190
|
return v("sse"), null;
|
|
182
191
|
}
|
|
183
192
|
}
|
|
184
|
-
async function
|
|
193
|
+
async function j(n, r, a, o) {
|
|
185
194
|
await t({
|
|
186
195
|
query: i,
|
|
187
196
|
operationName: "ExtendSandboxTtl",
|
|
@@ -194,20 +203,20 @@ async function A(n, r, a, o) {
|
|
|
194
203
|
authContext: o
|
|
195
204
|
});
|
|
196
205
|
}
|
|
197
|
-
async function
|
|
206
|
+
async function M(e, t, n, r) {
|
|
198
207
|
await y(e, t, `/sessions/${n}/heartbeat`, "POST", void 0, r).catch(() => void 0);
|
|
199
208
|
}
|
|
200
|
-
async function
|
|
209
|
+
async function N(e, t, n, r) {
|
|
201
210
|
return ((await y(e, t, `/sessions/${n}/artifacts`, "GET", void 0, r)).artifacts ?? []).filter((e) => !e.name.startsWith("."));
|
|
202
211
|
}
|
|
203
|
-
async function
|
|
212
|
+
async function P(e, t, n, r) {
|
|
204
213
|
let i = await y(e, t, `/sessions/${n}`, "GET", void 0, r);
|
|
205
214
|
return {
|
|
206
215
|
id: i.session?.id ?? n,
|
|
207
216
|
mode: i.mode ?? "unknown"
|
|
208
217
|
};
|
|
209
218
|
}
|
|
210
|
-
async function
|
|
219
|
+
async function F(e, t, n, r, i) {
|
|
211
220
|
let a = (await y(e, t, `/sessions/${n}/artifacts/download?path=${encodeURIComponent(r)}`, "GET", void 0, i)).artifact;
|
|
212
221
|
if (!a) throw Error("Artifact download returned an empty response");
|
|
213
222
|
return {
|
|
@@ -216,7 +225,7 @@ async function P(e, t, n, r, i) {
|
|
|
216
225
|
contentBase64: a.contentBase64
|
|
217
226
|
};
|
|
218
227
|
}
|
|
219
|
-
async function
|
|
228
|
+
async function I(e, r) {
|
|
220
229
|
return (await t({
|
|
221
230
|
query: n,
|
|
222
231
|
operationName: "CheckAiCredits",
|
|
@@ -225,7 +234,7 @@ async function F(e, r) {
|
|
|
225
234
|
authContext: r
|
|
226
235
|
})).checkAiCredits;
|
|
227
236
|
}
|
|
228
|
-
async function
|
|
237
|
+
async function L(e, n, r, i, a, o) {
|
|
229
238
|
let s = Math.max(0, Math.round(a.input ?? 0)), l = Math.max(0, Math.round(a.output ?? 0));
|
|
230
239
|
s + l === 0 || !i || await t({
|
|
231
240
|
query: c,
|
|
@@ -242,4 +251,4 @@ async function I(e, n, r, i, a, o) {
|
|
|
242
251
|
});
|
|
243
252
|
}
|
|
244
253
|
//#endregion
|
|
245
|
-
export {
|
|
254
|
+
export { D as buildPromptRequestBody, I as checkAssistantAiCredits, x as createAssistantSandbox, E as createAssistantSession, F as downloadAssistantArtifact, j as extendAssistantSandboxTTL, b as findExistingSandbox, N as getAssistantArtifacts, k as getAssistantMessages, P as getAssistantSession, A as getAssistantStreamAccess, L as reportAssistantAiTokenUsage, O as sendAssistantPromptAsync, M as sendHeartbeat, T as waitForAssistantServiceReady, w as waitForSandboxRunning };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSandboxAssistantTransport.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/createSandboxAssistantTransport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,OAAO,KAAK,EAGV,2BAA2B,EAE3B,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAOjB,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,MAAM,2BAA2B,CAAC;IAClD,cAAc,EAAE,MAAM,MAAM,CAAC;CAC9B;AAYD,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,sBAAsB,EAC9B,IAAI,EAAE,aAAa,GAClB,yBAAyB,
|
|
1
|
+
{"version":3,"file":"createSandboxAssistantTransport.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/createSandboxAssistantTransport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,OAAO,KAAK,EAGV,2BAA2B,EAE3B,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAOjB,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,MAAM,2BAA2B,CAAC;IAClD,cAAc,EAAE,MAAM,MAAM,CAAC;CAC9B;AAYD,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,sBAAsB,EAC9B,IAAI,EAAE,aAAa,GAClB,yBAAyB,CAgL3B"}
|
|
@@ -25,7 +25,7 @@ function g(g, _) {
|
|
|
25
25
|
let { sandboxId: c, sessionId: d } = await C.ensureRuntime();
|
|
26
26
|
C.startKeepWarm();
|
|
27
27
|
let h = Date.now();
|
|
28
|
-
await a(c, t, d, e.prompt, v, w(), o);
|
|
28
|
+
await a(c, t, d, e.prompt, v, w(), o, e.parts?.length ? { parts: e.parts } : void 0);
|
|
29
29
|
let _ = null, b = null, x = await r(c, t, d, o).catch(() => null);
|
|
30
30
|
if (x && typeof EventSource < "u") try {
|
|
31
31
|
b = new EventSource(x.url);
|
|
@@ -9,7 +9,7 @@ export { useSandboxAssistantTransport } from './useSandboxAssistantTransport';
|
|
|
9
9
|
export { createSandboxAssistantTransport } from './createSandboxAssistantTransport';
|
|
10
10
|
export { AssistantRuntimeManager } from './runtime';
|
|
11
11
|
export { isQuotaExhaustedError } from './gatewayClient';
|
|
12
|
-
export { buildProgress, sanitize, isRecoverable, mergeMessagesById, mapSessionToHistory, } from './progress';
|
|
13
|
-
export { findExistingSandbox, createAssistantSandbox, waitForSandboxRunning, waitForAssistantServiceReady, createAssistantSession, getAssistantSession, sendAssistantPromptAsync, getAssistantMessages, getAssistantStreamAccess, extendAssistantSandboxTTL, sendHeartbeat, getAssistantArtifacts, downloadAssistantArtifact, checkAssistantAiCredits, reportAssistantAiTokenUsage, } from './api';
|
|
14
|
-
export type { AssistantMode, PageContext, SandboxAssistantConfig, SandboxAssistantTransport, AssistantSendArgs, PrewarmLevel, AssistantRawMessage, AssistantRawMessagePart, AssistantWidgetMessage, AssistantArtifact, AssistantSandboxAuthContext, AssistantSessionInfo, DownloadedAssistantArtifact, StreamAccess, } from './types';
|
|
12
|
+
export { buildProgress, getAssistantMedia, sanitize, isRecoverable, mergeMessagesById, mapSessionToHistory, } from './progress';
|
|
13
|
+
export { buildPromptRequestBody, findExistingSandbox, createAssistantSandbox, waitForSandboxRunning, waitForAssistantServiceReady, createAssistantSession, getAssistantSession, sendAssistantPromptAsync, getAssistantMessages, getAssistantStreamAccess, extendAssistantSandboxTTL, sendHeartbeat, getAssistantArtifacts, downloadAssistantArtifact, checkAssistantAiCredits, reportAssistantAiTokenUsage, } from './api';
|
|
14
|
+
export type { AssistantMode, AssistantPromptPart, PageContext, SandboxAssistantConfig, SandboxAssistantTransport, AssistantSendArgs, PrewarmLevel, AssistantRawMessage, AssistantRawMessagePart, AssistantWidgetMessage, AssistantArtifact, AssistantSandboxAuthContext, AssistantSessionInfo, DownloadedAssistantArtifact, StreamAccess, } from './types';
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EACL,aAAa,EACb,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAKpB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,4BAA4B,EAC5B,sBAAsB,EACtB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,aAAa,EACb,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,OAAO,CAAC;AAEf,YAAY,EACV,aAAa,EACb,WAAW,EACX,sBAAsB,EACtB,yBAAyB,EACzB,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,2BAA2B,EAC3B,oBAAoB,EACpB,2BAA2B,EAC3B,YAAY,GACb,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAKpB,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,4BAA4B,EAC5B,sBAAsB,EACtB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,aAAa,EACb,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,OAAO,CAAC;AAEf,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,sBAAsB,EACtB,yBAAyB,EACzB,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,2BAA2B,EAC3B,oBAAoB,EACpB,2BAA2B,EAC3B,YAAY,GACb,MAAM,SAAS,CAAC"}
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { AssistantRawMessage, AssistantWidgetMessage } from './types';
|
|
2
2
|
export declare function getRawMessageCreatedAt(message: AssistantRawMessage): number;
|
|
3
3
|
export declare function getAssistantText(parts: AssistantRawMessage['parts']): string;
|
|
4
|
+
/**
|
|
5
|
+
* Render inbound non-text parts (an image or file the agent returned) as
|
|
6
|
+
* markdown, so any renderer already handling the text channel displays them with
|
|
7
|
+
* no extra plumbing: images become ``, files become `[name](src)`.
|
|
8
|
+
*
|
|
9
|
+
* Bytes may arrive by reference (`url`) or inline (`data`, bare base64); inline
|
|
10
|
+
* image bytes become a `data:` URL. Today's agent emits `text | tool` only, so
|
|
11
|
+
* this returns `[]` and nothing downstream changes.
|
|
12
|
+
*
|
|
13
|
+
* Everything interpolated here is UNTRUSTED — it reaches us from a model that
|
|
14
|
+
* has read tool output, web pages and user uploads — so the label is escaped and
|
|
15
|
+
* the source is protocol-checked. A part we cannot render safely is DROPPED.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getAssistantMedia(parts: AssistantRawMessage['parts']): string[];
|
|
4
18
|
export declare function getToolProgress(parts: AssistantRawMessage['parts']): string[];
|
|
5
19
|
/**
|
|
6
20
|
* Reduce the assistant messages created at/after `sinceMs` into display content +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/progress.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAA2B,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEpG,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAE3E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,GAAG,MAAM,CAM5E;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,GAAG,MAAM,EAAE,CAU7E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,mBAAmB,EAAE,EAC/B,OAAO,EAAE,MAAM,GACd;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/progress.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAA2B,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEpG,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAE3E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,GAAG,MAAM,CAM5E;AAmCD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,GAAG,MAAM,EAAE,CAkB/E;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,GAAG,MAAM,EAAE,CAU7E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,mBAAmB,EAAE,EAC/B,OAAO,EAAE,MAAM,GACd;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAuBpC;AAED,iEAAiE;AACjE,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED,2FAA2F;AAC3F,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAyBrD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,mBAAmB,EAAE,EAClC,QAAQ,EAAE,mBAAmB,EAAE,GAC9B,mBAAmB,EAAE,CAavB;AAED,2FAA2F;AAC3F,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,mBAAmB,EAAE,GAAG,sBAAsB,EAAE,CAyB7F"}
|
|
@@ -6,27 +6,52 @@ function t(e) {
|
|
|
6
6
|
return (e ?? []).filter((e) => e.type === "text" && typeof e.text == "string").map((e) => e.text?.trim() ?? "").filter(Boolean).join("\n");
|
|
7
7
|
}
|
|
8
8
|
function n(e) {
|
|
9
|
+
return e.replace(/[\\[\]]/g, "\\$&").replace(/[\r\n]+/g, " ").trim();
|
|
10
|
+
}
|
|
11
|
+
function r(e, t) {
|
|
12
|
+
let n = e.trim();
|
|
13
|
+
return /^https?:\/\//i.test(n) ? n.replace(/[()\s<>]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0")}`) : t && /^data:image\/[a-z0-9.+-]+;base64,[a-z0-9+/=]*$/i.test(n) ? n : null;
|
|
14
|
+
}
|
|
15
|
+
function i(e) {
|
|
16
|
+
let t = [];
|
|
17
|
+
for (let i of e ?? []) {
|
|
18
|
+
let e = i.type === "image";
|
|
19
|
+
if (!e && i.type !== "file") continue;
|
|
20
|
+
let a = i.url ?? (i.data && i.mimeType ? `data:${i.mimeType};base64,${i.data}` : void 0);
|
|
21
|
+
if (!a) continue;
|
|
22
|
+
let o = r(a, e);
|
|
23
|
+
if (!o) continue;
|
|
24
|
+
let s = n(i.filename ?? (e ? "image" : "file")) || "file";
|
|
25
|
+
t.push(e ? `` : `[${s}](${o})`);
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
function a(e) {
|
|
9
30
|
return (e ?? []).filter((e) => e.type === "tool" && e.tool).map((e) => {
|
|
10
31
|
let t = e.state?.status ?? "running", n = e.tool ?? "tool";
|
|
11
32
|
return t === "completed" ? `Completed: ${n}` : t === "failed" ? `Failed: ${n}` : `Running: ${n}`;
|
|
12
33
|
});
|
|
13
34
|
}
|
|
14
|
-
function
|
|
15
|
-
let
|
|
16
|
-
if (
|
|
35
|
+
function o(n, r) {
|
|
36
|
+
let o = n.filter((t) => t.info?.role === "assistant" && e(t) >= r).sort((t, n) => e(t) - e(n));
|
|
37
|
+
if (o.length === 0) return {
|
|
17
38
|
content: "Thinking…",
|
|
18
39
|
done: !1
|
|
19
40
|
};
|
|
20
|
-
let
|
|
41
|
+
let s = o[o.length - 1], c = t(s.parts), l = i(s.parts), u = a(s.parts);
|
|
21
42
|
return {
|
|
22
|
-
content: [
|
|
23
|
-
|
|
43
|
+
content: [
|
|
44
|
+
c,
|
|
45
|
+
...l,
|
|
46
|
+
...u
|
|
47
|
+
].filter(Boolean).join("\n\n") || "Thinking…",
|
|
48
|
+
done: !!s.info?.time?.completed && (!!c || l.length > 0 || u.length > 0)
|
|
24
49
|
};
|
|
25
50
|
}
|
|
26
|
-
function
|
|
51
|
+
function s(e) {
|
|
27
52
|
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]");
|
|
28
53
|
}
|
|
29
|
-
function
|
|
54
|
+
function c(e) {
|
|
30
55
|
let t = e instanceof Error ? e.message.toLowerCase() : String(e).toLowerCase();
|
|
31
56
|
return t.includes("rate limit exceeded") || t.includes("unauthorized") || t.includes("k8s api error 401") ? !1 : [
|
|
32
57
|
"sandbox not found",
|
|
@@ -44,7 +69,7 @@ function a(e) {
|
|
|
44
69
|
"proxy error: 503"
|
|
45
70
|
].some((e) => t.includes(e));
|
|
46
71
|
}
|
|
47
|
-
function
|
|
72
|
+
function l(t, n) {
|
|
48
73
|
let r = /* @__PURE__ */ new Map();
|
|
49
74
|
for (let e of t) {
|
|
50
75
|
let t = e.info?.id;
|
|
@@ -56,19 +81,19 @@ function o(t, n) {
|
|
|
56
81
|
}
|
|
57
82
|
return Array.from(r.values()).sort((t, n) => e(t) - e(n));
|
|
58
83
|
}
|
|
59
|
-
function
|
|
84
|
+
function u(n) {
|
|
60
85
|
let r = [];
|
|
61
|
-
for (let
|
|
62
|
-
let n =
|
|
86
|
+
for (let a of n) {
|
|
87
|
+
let n = a.info?.role;
|
|
63
88
|
if (n !== "user" && n !== "assistant") continue;
|
|
64
|
-
let a = t(i.
|
|
65
|
-
|
|
66
|
-
id:
|
|
89
|
+
let o = a.parts, s = t(o), c = [s, ...i(o)].filter(Boolean).join("\n\n");
|
|
90
|
+
c && (n === "user" && (s.startsWith("[Context file:") || s.startsWith("User's current context:")) || r.push({
|
|
91
|
+
id: a.info?.id ?? `${n}-${e(a)}`,
|
|
67
92
|
role: n,
|
|
68
|
-
content:
|
|
93
|
+
content: c
|
|
69
94
|
}));
|
|
70
95
|
}
|
|
71
96
|
return r;
|
|
72
97
|
}
|
|
73
98
|
//#endregion
|
|
74
|
-
export {
|
|
99
|
+
export { o as buildProgress, i as getAssistantMedia, c as isRecoverable, u as mapSessionToHistory, l as mergeMessagesById, s as sanitize };
|
|
@@ -34,7 +34,44 @@ export interface AssistantRawMessagePart {
|
|
|
34
34
|
output?: unknown;
|
|
35
35
|
raw?: unknown;
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Inbound media (an image or file the agent produced). Present only once the
|
|
39
|
+
* `ai-assistant-*` bridge emits non-text parts; today's agent returns
|
|
40
|
+
* `text | tool` only, so these stay undefined and every reader degrades to the
|
|
41
|
+
* text path. Typed here so consumers can render media without a fe-libs bump
|
|
42
|
+
* on the day the bridge starts sending it.
|
|
43
|
+
*/
|
|
44
|
+
mimeType?: string;
|
|
45
|
+
url?: string;
|
|
46
|
+
/** Inline bytes as bare base64 (no `data:` prefix) — mirrors the outbound shape. */
|
|
47
|
+
data?: string;
|
|
48
|
+
filename?: string;
|
|
37
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* One piece of a multimodal prompt (outbound). The external `ai-assistant-*`
|
|
52
|
+
* bridge translates these into native `opencode` message parts.
|
|
53
|
+
*
|
|
54
|
+
* Carry the bytes either by reference (`url`) or inline (`data`, bare base64 with
|
|
55
|
+
* no `data:` prefix). Inline is the reliable option for images: a browser-issued
|
|
56
|
+
* storage URL is frequently cookie- or CF-gated and therefore unreachable from
|
|
57
|
+
* inside the sandbox container, whereas inline bytes need no egress at all.
|
|
58
|
+
*/
|
|
59
|
+
export type AssistantPromptPart = {
|
|
60
|
+
type: 'text';
|
|
61
|
+
text: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: 'image';
|
|
64
|
+
mimeType: string;
|
|
65
|
+
url?: string;
|
|
66
|
+
data?: string;
|
|
67
|
+
name?: string;
|
|
68
|
+
} | {
|
|
69
|
+
type: 'file';
|
|
70
|
+
mimeType: string;
|
|
71
|
+
url?: string;
|
|
72
|
+
data?: string;
|
|
73
|
+
name?: string;
|
|
74
|
+
};
|
|
38
75
|
export interface AssistantRawMessage {
|
|
39
76
|
info?: {
|
|
40
77
|
id?: string;
|
|
@@ -92,7 +129,18 @@ export interface SandboxAssistantConfig {
|
|
|
92
129
|
onCreditsUpdated?: () => void;
|
|
93
130
|
}
|
|
94
131
|
export interface AssistantSendArgs {
|
|
132
|
+
/**
|
|
133
|
+
* The turn as plain text. ALWAYS sent, even alongside `parts` — an
|
|
134
|
+
* un-upgraded bridge ignores what it does not understand and still answers
|
|
135
|
+
* from this, so a multimodal client degrades to text instead of failing.
|
|
136
|
+
*/
|
|
95
137
|
prompt: string;
|
|
138
|
+
/**
|
|
139
|
+
* Optional multimodal turn. When present it is AUTHORITATIVE for a bridge
|
|
140
|
+
* that understands it, and `prompt` is the text-only fallback. Omit entirely
|
|
141
|
+
* for text-only turns — the wire body then looks exactly as it always has.
|
|
142
|
+
*/
|
|
143
|
+
parts?: AssistantPromptPart[];
|
|
96
144
|
onProgress: (partialText: string) => void;
|
|
97
145
|
signal: AbortSignal;
|
|
98
146
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,cAAc,GAAG,WAAW,CAAC;AAEnF,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAA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AC7E,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC;IAC9B,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,KAAK,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC9B,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,CAAC;AAE5C,sEAAsE;AACtE,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnE,kFAAkF;IAClF,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,iEAAiE;IACjE,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { ActiveContextUrlParams, AuthStoreContextSnapshot } from './ActiveContextStorage';
|
|
2
3
|
/**
|
|
3
4
|
* Context value interface for organization/workspace/project selection
|
|
4
5
|
*/
|
|
@@ -71,6 +72,39 @@ export declare function createContextFieldThrashState(initial: string | null): C
|
|
|
71
72
|
* value — the ping-pong signature described above.
|
|
72
73
|
*/
|
|
73
74
|
export declare function shouldApplyContextFieldWrite(fieldName: string, state: ContextFieldThrashState, nextValue: string | null, now: number): boolean;
|
|
75
|
+
export interface ActiveContextBootstrapFields {
|
|
76
|
+
organizationId: string | null;
|
|
77
|
+
workspaceId: string | null;
|
|
78
|
+
projectId: string | null;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Fill-only merge of the persisted auth-store context into the values already
|
|
82
|
+
* resolved from the URL / ActiveContext's own storage.
|
|
83
|
+
*
|
|
84
|
+
* Fill rules (mirroring microfe-auth's `useActiveContextBootstrapMirror`):
|
|
85
|
+
* - a value already resolved from the URL or own storage always wins;
|
|
86
|
+
* - a child axis is filled from the store only when its parent axis provably
|
|
87
|
+
* matches the parent the stored child belongs to — the workspace only when
|
|
88
|
+
* the resolved organization IS the store's organization, the project only
|
|
89
|
+
* when the resolved workspace IS the store's workspace. Without that guard a
|
|
90
|
+
* stale `?org=` deep link would be paired with a workspace from a different
|
|
91
|
+
* organization, which is worse than no workspace at all.
|
|
92
|
+
* - a child is never filled under an empty parent, for the same reason.
|
|
93
|
+
*
|
|
94
|
+
* Exported so this can be unit-tested directly: it is pure, while the provider
|
|
95
|
+
* around it needs a DOM.
|
|
96
|
+
*/
|
|
97
|
+
export declare function applyAuthStoreContextFallback(resolved: ActiveContextBootstrapFields, authStore: AuthStoreContextSnapshot): ActiveContextBootstrapFields;
|
|
98
|
+
/**
|
|
99
|
+
* Resolve the organization / workspace / project the provider should start
|
|
100
|
+
* from: URL (when synced) > ActiveContext's own storage > persisted auth store.
|
|
101
|
+
* Defaults are applied by the caller, after this.
|
|
102
|
+
*/
|
|
103
|
+
export declare function resolveInitialActiveContext(options: {
|
|
104
|
+
storageKey: string;
|
|
105
|
+
syncToUrl: boolean;
|
|
106
|
+
urlParams: ActiveContextUrlParams;
|
|
107
|
+
}): ActiveContextBootstrapFields;
|
|
74
108
|
/**
|
|
75
109
|
* ActiveContextProvider
|
|
76
110
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActiveContextProvider.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/ActiveContextProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ActiveContextProvider.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/ActiveContextProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAMf,OAAO,EASL,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC9B,MAAM,wBAAwB,CAAC;AAGhC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,yCAAyC;IACzC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,sCAAsC;IACtC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,oCAAoC;IACpC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,mCAAmC;IACnC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAExB,kCAAkC;IAClC,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAChD,+BAA+B;IAC/B,YAAY,EAAE,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACnD,6BAA6B;IAC7B,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC/C,4BAA4B;IAC5B,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAE7C,qCAAqC;IACrC,UAAU,EAAE,CACV,OAAO,EAAE,OAAO,CAAC;QACf,cAAc,EAAE,MAAM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,GAAG,IAAI,GAAG,uBAAuB,CAE7F;AAgBD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,uBAAuB,EAC9B,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,GAAG,EAAE,MAAM,GACV,OAAO,CAsCT;AAsBD,MAAM,WAAW,4BAA4B;IAC3C,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,4BAA4B,EACtC,SAAS,EAAE,wBAAwB,GAClC,4BAA4B,CAY9B;AAgBD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,sBAAsB,CAAC;CACnC,GAAG,4BAA4B,CAsC/B;AAiCD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,qBAA4B,EAC5B,kBAAyB,EACzB,gBAAuB,EACvB,eAAsB,EACtB,UAAuC,EACvC,SAAiB,EACjB,SAA6C,GAC9C,EAAE,0BAA0B,2CAgX5B;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,uBAM/B"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getProfileContext as e, resolveActiveProfileId as t, setProfileContext as n } from "./ProfileStorageManager.js";
|
|
2
|
-
import { ACTIVE_CONTEXT_STORAGE_KEY as r, DEFAULT_ACTIVE_CONTEXT_URL_PARAMS as i, clearActiveContextStorage as a, getUrlParam as o, readActiveContextStorageValue as s,
|
|
3
|
-
import { isSsoNavigationPending as
|
|
4
|
-
import { createContext as
|
|
5
|
-
import { jsx as
|
|
2
|
+
import { ACTIVE_CONTEXT_STORAGE_KEY as r, DEFAULT_ACTIVE_CONTEXT_URL_PARAMS as i, clearActiveContextStorage as a, getUrlParam as o, readActiveContextStorageValue as s, readAuthStoreContext as c, writeActiveContextFallback as l, writeActiveContextStorageValue as u } from "./ActiveContextStorage.js";
|
|
3
|
+
import { isSsoNavigationPending as d } from "../../utils/ssoDeposit.js";
|
|
4
|
+
import { createContext as f, use as p, useCallback as m, useEffect as h, useMemo as g, useRef as _, useState as v } from "react";
|
|
5
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
6
6
|
//#region src/shared/providers/shell/ActiveContextProvider.tsx
|
|
7
|
-
var
|
|
8
|
-
function
|
|
7
|
+
var b = f(null);
|
|
8
|
+
function x(e) {
|
|
9
9
|
return {
|
|
10
10
|
current: e,
|
|
11
11
|
previous: null,
|
|
@@ -14,7 +14,7 @@ function b(e) {
|
|
|
14
14
|
suppressUntil: 0
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function S() {
|
|
18
18
|
try {
|
|
19
19
|
return !!{
|
|
20
20
|
BASE_URL: "/",
|
|
@@ -27,34 +27,55 @@ function x() {
|
|
|
27
27
|
return !1;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function C(e, t, n, r) {
|
|
31
31
|
if (t.current === n) return !1;
|
|
32
|
-
if (r < t.suppressUntil) return
|
|
32
|
+
if (r < t.suppressUntil) return S() && console.warn(`[ActiveContext] Suppressing rapid ${e} change to avoid a render loop (BOFF-5395): holding at ${JSON.stringify(t.current)}, refused ${JSON.stringify(n)}.`), !1;
|
|
33
33
|
let i = n === t.previous, a = r - t.windowStart < 500;
|
|
34
|
-
return i && a ? t.flips += 1 : (t.flips = 1, t.windowStart = r), t.flips >= 3 ? (t.suppressUntil = r + 500, t.flips = 0,
|
|
34
|
+
return i && a ? t.flips += 1 : (t.flips = 1, t.windowStart = r), t.flips >= 3 ? (t.suppressUntil = r + 500, t.flips = 0, S() && console.warn(`[ActiveContext] Detected ${e} ping-pong between ${JSON.stringify(t.current)} and ${JSON.stringify(n)} (BOFF-5395) — holding at the current value instead of looping.`), !1) : (t.previous = t.current, t.current = n, !0);
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
36
|
+
function w(e, t) {
|
|
37
|
+
let n = e.organizationId ?? t.organizationId, r = n !== null && n === t.organizationId, i = e.workspaceId ?? (r ? t.workspaceId : null), a = i !== null && i === t.workspaceId;
|
|
38
|
+
return {
|
|
39
|
+
organizationId: n,
|
|
40
|
+
workspaceId: i,
|
|
41
|
+
projectId: e.projectId ?? (a ? t.projectId : null)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function T(e, t, n, r) {
|
|
45
|
+
if (n) {
|
|
46
|
+
let e = o(t);
|
|
47
|
+
if (e) return e;
|
|
48
|
+
}
|
|
49
|
+
return s(e, r) || null;
|
|
50
|
+
}
|
|
51
|
+
function E(e) {
|
|
52
|
+
if (typeof window > "u") return {
|
|
53
|
+
organizationId: null,
|
|
54
|
+
workspaceId: null,
|
|
55
|
+
projectId: null
|
|
56
|
+
};
|
|
57
|
+
let { storageKey: t, syncToUrl: n, urlParams: r } = e, a = {
|
|
58
|
+
organizationId: T("organization", r.organization ?? i.organization, n, t),
|
|
59
|
+
workspaceId: T("workspace", r.workspace ?? i.workspace, n, t),
|
|
60
|
+
projectId: T("project", r.project ?? i.project, n, t)
|
|
61
|
+
};
|
|
62
|
+
return a.organizationId !== null && a.workspaceId !== null && a.projectId !== null ? a : w(a, c());
|
|
63
|
+
}
|
|
64
|
+
function D(e) {
|
|
65
|
+
if (typeof window > "u" || d() || window.location.pathname.startsWith("/auth/")) return;
|
|
38
66
|
let t = new URL(window.location.href);
|
|
39
67
|
Object.entries(e).forEach(([e, n]) => {
|
|
40
68
|
n ? t.searchParams.set(e, n) : t.searchParams.delete(e);
|
|
41
69
|
}), window.history.replaceState({}, "", t.toString());
|
|
42
70
|
}
|
|
43
|
-
function
|
|
44
|
-
let [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
return s("organization", T) || d;
|
|
51
|
-
}), [A, j] = _(() => {
|
|
71
|
+
function O({ children: c, defaultOrganizationId: d = null, defaultWorkspaceId: f = null, defaultProjectId: p = null, defaultTenantId: S = null, storageKey: w = r, syncToUrl: T = !1, urlParams: O = i }) {
|
|
72
|
+
let [k] = v(() => E({
|
|
73
|
+
storageKey: w,
|
|
74
|
+
syncToUrl: T,
|
|
75
|
+
urlParams: O
|
|
76
|
+
})), [A, j] = v(() => typeof window > "u" ? d : k.organizationId ?? d), [M, N] = v(() => {
|
|
52
77
|
if (typeof window > "u") return f;
|
|
53
|
-
|
|
54
|
-
let e = o(D.workspace);
|
|
55
|
-
if (e) return e;
|
|
56
|
-
}
|
|
57
|
-
let r = s("workspace", T) || f;
|
|
78
|
+
let r = k.workspaceId ?? f;
|
|
58
79
|
if (r) {
|
|
59
80
|
let i = t();
|
|
60
81
|
if (i) {
|
|
@@ -66,152 +87,145 @@ function w({ children: u, defaultOrganizationId: d = null, defaultWorkspaceId: f
|
|
|
66
87
|
}
|
|
67
88
|
}
|
|
68
89
|
return r;
|
|
69
|
-
}), [
|
|
70
|
-
if (typeof window > "u") return
|
|
71
|
-
if (
|
|
72
|
-
let e = o(
|
|
90
|
+
}), [P, F] = v(() => typeof window > "u" ? p : k.projectId ?? p), [I, L] = v(() => {
|
|
91
|
+
if (typeof window > "u") return S;
|
|
92
|
+
if (T) {
|
|
93
|
+
let e = o(O.tenant);
|
|
73
94
|
if (e) return e;
|
|
74
95
|
}
|
|
75
|
-
return s("
|
|
76
|
-
}),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
let L = g(null);
|
|
86
|
-
L.current === null && (L.current = b(A));
|
|
87
|
-
let R = g(null);
|
|
88
|
-
R.current === null && (R.current = b(M));
|
|
89
|
-
let z = g(null);
|
|
90
|
-
z.current === null && (z.current = b(P)), m(() => {
|
|
91
|
-
l("organization", O, T), l("workspace", A, T), l("project", M, T), l("tenant", P, T);
|
|
96
|
+
return s("tenant", w) || S;
|
|
97
|
+
}), R = _(null);
|
|
98
|
+
R.current === null && (R.current = x(A));
|
|
99
|
+
let z = _(null);
|
|
100
|
+
z.current === null && (z.current = x(M));
|
|
101
|
+
let B = _(null);
|
|
102
|
+
B.current === null && (B.current = x(P));
|
|
103
|
+
let V = _(null);
|
|
104
|
+
V.current === null && (V.current = x(I)), h(() => {
|
|
105
|
+
u("organization", A, w), u("workspace", M, w), u("project", P, w), u("tenant", I, w);
|
|
92
106
|
}, [
|
|
93
|
-
O,
|
|
94
107
|
A,
|
|
95
108
|
M,
|
|
96
109
|
P,
|
|
97
|
-
|
|
98
|
-
|
|
110
|
+
I,
|
|
111
|
+
w
|
|
112
|
+
]), h(() => {
|
|
99
113
|
let r = t();
|
|
100
114
|
if (!r) return;
|
|
101
115
|
let i = e(r), a = {
|
|
102
116
|
...i,
|
|
103
|
-
organizationId:
|
|
104
|
-
workspaceId:
|
|
105
|
-
projectId:
|
|
106
|
-
tenantId:
|
|
117
|
+
organizationId: A,
|
|
118
|
+
workspaceId: M,
|
|
119
|
+
projectId: P,
|
|
120
|
+
tenantId: I
|
|
107
121
|
};
|
|
108
122
|
i?.organizationId === a.organizationId && i?.workspaceId === a.workspaceId && i?.projectId === a.projectId && i?.tenantId === a.tenantId || n(r, a);
|
|
109
123
|
}, [
|
|
110
|
-
O,
|
|
111
124
|
A,
|
|
112
125
|
M,
|
|
113
|
-
P
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
[
|
|
118
|
-
[
|
|
119
|
-
[
|
|
126
|
+
P,
|
|
127
|
+
I
|
|
128
|
+
]), h(() => {
|
|
129
|
+
T && D({
|
|
130
|
+
[O.organization]: A,
|
|
131
|
+
[O.workspace]: M,
|
|
132
|
+
[O.project]: P,
|
|
133
|
+
[O.tenant]: I
|
|
120
134
|
});
|
|
121
135
|
}, [
|
|
122
|
-
O,
|
|
123
136
|
A,
|
|
124
137
|
M,
|
|
125
138
|
P,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
139
|
+
I,
|
|
140
|
+
T,
|
|
141
|
+
O
|
|
142
|
+
]), h(() => {
|
|
143
|
+
if (!T) return;
|
|
130
144
|
let e = () => {
|
|
131
|
-
let e = o(
|
|
132
|
-
e !==
|
|
145
|
+
let e = o(O.organization), t = o(O.workspace), n = o(O.project), r = o(O.tenant);
|
|
146
|
+
e !== A && (j(e), R.current.previous = R.current.current, R.current.current = e), t !== M && (N(t), z.current.previous = z.current.current, z.current.current = t), n !== P && (F(n), B.current.previous = B.current.current, B.current.current = n), r !== I && (L(r), V.current.previous = V.current.current, V.current.current = r);
|
|
133
147
|
};
|
|
134
148
|
return window.addEventListener("popstate", e), () => window.removeEventListener("popstate", e);
|
|
135
149
|
}, [
|
|
136
|
-
|
|
137
|
-
D,
|
|
150
|
+
T,
|
|
138
151
|
O,
|
|
139
152
|
A,
|
|
140
153
|
M,
|
|
141
|
-
P
|
|
154
|
+
P,
|
|
155
|
+
I
|
|
142
156
|
]);
|
|
143
|
-
let
|
|
144
|
-
if (!
|
|
145
|
-
|
|
157
|
+
let H = m((r) => {
|
|
158
|
+
if (!C("organizationId", R.current, r, Date.now())) return;
|
|
159
|
+
j(r);
|
|
146
160
|
let i = t();
|
|
147
161
|
i && n(i, {
|
|
148
162
|
...e(i),
|
|
149
163
|
organizationId: r
|
|
150
164
|
}), typeof window < "u" && window.dispatchEvent(new CustomEvent("burdenoff:organization-changed", { detail: { organizationId: r } }));
|
|
151
|
-
}, []),
|
|
165
|
+
}, []), U = m((r, i) => {
|
|
152
166
|
let a = {
|
|
153
167
|
organization: "organizationId",
|
|
154
168
|
workspace: "workspaceId",
|
|
155
169
|
project: "projectId",
|
|
156
170
|
tenant: "tenantId"
|
|
157
171
|
};
|
|
158
|
-
|
|
172
|
+
u(r, i, w);
|
|
159
173
|
let o = t();
|
|
160
174
|
o ? n(o, {
|
|
161
175
|
...e(o),
|
|
162
176
|
[a[r]]: i
|
|
163
|
-
}) : typeof window < "u" &&
|
|
164
|
-
}, [
|
|
165
|
-
|
|
166
|
-
}, [
|
|
167
|
-
|
|
168
|
-
}, [
|
|
169
|
-
|
|
170
|
-
}, [
|
|
171
|
-
e.organizationId !== void 0 &&
|
|
177
|
+
}) : typeof window < "u" && l(r, i, w);
|
|
178
|
+
}, [w]), W = m((e) => {
|
|
179
|
+
C("workspaceId", z.current, e, Date.now()) && (N(e), U("workspace", e), typeof window < "u" && window.dispatchEvent(new CustomEvent("burdenoff:workspace-changed", { detail: { workspaceId: e } })));
|
|
180
|
+
}, [U]), G = m((e) => {
|
|
181
|
+
C("projectId", B.current, e, Date.now()) && (F(e), U("project", e), typeof window < "u" && window.dispatchEvent(new CustomEvent("burdenoff:project-changed", { detail: { projectId: e } })));
|
|
182
|
+
}, [U]), K = m((e) => {
|
|
183
|
+
C("tenantId", V.current, e, Date.now()) && (L(e), U("tenant", e));
|
|
184
|
+
}, [U]), q = m((e) => {
|
|
185
|
+
e.organizationId !== void 0 && H(e.organizationId), e.workspaceId !== void 0 && W(e.workspaceId), e.projectId !== void 0 && G(e.projectId), e.tenantId !== void 0 && K(e.tenantId);
|
|
172
186
|
}, [
|
|
173
|
-
B,
|
|
174
187
|
H,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
188
|
+
W,
|
|
189
|
+
G,
|
|
190
|
+
K
|
|
191
|
+
]), J = m(() => {
|
|
192
|
+
j(null), N(null), F(null), L(null), R.current = x(null), z.current = x(null), B.current = x(null), V.current = x(null), a(w);
|
|
179
193
|
let e = t();
|
|
180
194
|
e && n(e, {});
|
|
181
|
-
}, [
|
|
182
|
-
organizationId:
|
|
183
|
-
workspaceId:
|
|
184
|
-
projectId:
|
|
185
|
-
tenantId:
|
|
186
|
-
setOrganization:
|
|
187
|
-
setWorkspace:
|
|
188
|
-
setProject:
|
|
189
|
-
setTenant:
|
|
190
|
-
setContext:
|
|
191
|
-
clearContext:
|
|
192
|
-
urlSyncEnabled:
|
|
195
|
+
}, [w]), Y = g(() => ({
|
|
196
|
+
organizationId: A,
|
|
197
|
+
workspaceId: M,
|
|
198
|
+
projectId: P,
|
|
199
|
+
tenantId: I,
|
|
200
|
+
setOrganization: H,
|
|
201
|
+
setWorkspace: W,
|
|
202
|
+
setProject: G,
|
|
203
|
+
setTenant: K,
|
|
204
|
+
setContext: q,
|
|
205
|
+
clearContext: J,
|
|
206
|
+
urlSyncEnabled: T
|
|
193
207
|
}), [
|
|
194
|
-
O,
|
|
195
208
|
A,
|
|
196
209
|
M,
|
|
197
210
|
P,
|
|
198
|
-
|
|
211
|
+
I,
|
|
199
212
|
H,
|
|
200
|
-
U,
|
|
201
213
|
W,
|
|
202
214
|
G,
|
|
203
215
|
K,
|
|
204
|
-
|
|
216
|
+
q,
|
|
217
|
+
J,
|
|
218
|
+
T
|
|
205
219
|
]);
|
|
206
|
-
return /* @__PURE__ */
|
|
207
|
-
value:
|
|
208
|
-
children:
|
|
220
|
+
return /* @__PURE__ */ y(b.Provider, {
|
|
221
|
+
value: Y,
|
|
222
|
+
children: c
|
|
209
223
|
});
|
|
210
224
|
}
|
|
211
|
-
function
|
|
212
|
-
let e =
|
|
225
|
+
function k() {
|
|
226
|
+
let e = p(b);
|
|
213
227
|
if (!e) throw Error("useActiveContext must be used within an ActiveContextProvider");
|
|
214
228
|
return e;
|
|
215
229
|
}
|
|
216
230
|
//#endregion
|
|
217
|
-
export {
|
|
231
|
+
export { O as ActiveContextProvider, k as useActiveContext };
|
|
@@ -37,6 +37,31 @@ export declare function writeActiveContextStorageValue(field: ActiveContextStora
|
|
|
37
37
|
*/
|
|
38
38
|
export declare function writeActiveContextFallback(field: ActiveContextStorageField, value: string | null, storageKey?: string): void;
|
|
39
39
|
export declare function clearActiveContextStorage(storageKey?: string): void;
|
|
40
|
+
/** zustand `persist` name used by the microfe-auth store. */
|
|
41
|
+
export declare const AUTH_STORE_PERSIST_NAME = "auth-storage";
|
|
42
|
+
/** The subset of the persisted auth store usable as an ActiveContext fallback. */
|
|
43
|
+
export interface AuthStoreContextSnapshot {
|
|
44
|
+
organizationId: string | null;
|
|
45
|
+
workspaceId: string | null;
|
|
46
|
+
projectId: string | null;
|
|
47
|
+
}
|
|
48
|
+
/** localStorage key the microfe-auth store persists to for a given profile. */
|
|
49
|
+
export declare function getAuthStoreStorageKey(profileId: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Tolerantly parse a persisted auth-store payload. Any shape this does not
|
|
52
|
+
* recognise yields an all-null snapshot ("no fallback available"); it never
|
|
53
|
+
* throws.
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseAuthStoreContext(raw: string | null): AuthStoreContextSnapshot;
|
|
56
|
+
/**
|
|
57
|
+
* Read the persisted auth-store context for the active profile.
|
|
58
|
+
*
|
|
59
|
+
* Purely a read: unlike `readActiveContextStorageValue`, this never seeds
|
|
60
|
+
* sessionStorage or the profile context with what it finds. Profile
|
|
61
|
+
* resolution uses `resolveActiveProfileId()` — the same scheme the rest of
|
|
62
|
+
* this module uses — so the fallback can never come from another account.
|
|
63
|
+
*/
|
|
64
|
+
export declare function readAuthStoreContext(): AuthStoreContextSnapshot;
|
|
40
65
|
export declare function readActiveContextValueWithUrlPrecedence(field: ActiveContextStorageField, options?: {
|
|
41
66
|
storageKey?: string;
|
|
42
67
|
urlParam?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActiveContextStorage.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/ActiveContextStorage.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,6BAA6B,CAAC;AAErE,MAAM,MAAM,yBAAyB,GAAG,cAAc,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AA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|
|
1
|
+
{"version":3,"file":"ActiveContextStorage.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/ActiveContextStorage.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,6BAA6B,CAAC;AAErE,MAAM,MAAM,yBAAyB,GAAG,cAAc,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE5F,MAAM,WAAW,sBAAsB;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,sBAAsB,CAK9E,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AA6BD,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO5D;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,yBAAyB,EAChC,UAAU,SAA6B,GACtC,MAAM,GAAG,IAAI,CAyBf;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,yBAAyB,EAChC,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,UAAU,SAA6B,GACtC,IAAI,CAaN;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,yBAAyB,EAChC,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,UAAU,SAA6B,GACtC,IAAI,CAWN;AAED,wBAAgB,yBAAyB,CAAC,UAAU,SAA6B,GAAG,IAAI,CAUvF;AAsBD,6DAA6D;AAC7D,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAItD,kFAAkF;AAClF,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAeD,+EAA+E;AAC/E,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,wBAAwB,CAqBlF;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,wBAAwB,CAe/D;AAED,wBAAgB,uCAAuC,CACrD,KAAK,EAAE,yBAAyB,EAChC,OAAO,CAAC,EAAE;IACR,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GACA,MAAM,GAAG,IAAI,CAOf;AAED,wBAAgB,yBAAyB,CACvC,UAAU,SAA6B,EACvC,SAAS,GAAE,sBAA0D,GACpE,qBAAqB,CAmBvB"}
|
|
@@ -54,8 +54,49 @@ function u(e = n) {
|
|
|
54
54
|
sessionStorage.removeItem(n), localStorage.removeItem(n);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
var d = "auth-storage", f = "bf-p";
|
|
58
|
+
function p() {
|
|
59
|
+
return {
|
|
60
|
+
organizationId: null,
|
|
61
|
+
workspaceId: null,
|
|
62
|
+
projectId: null
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function m(e) {
|
|
66
|
+
return typeof e == "object" && !!e;
|
|
67
|
+
}
|
|
68
|
+
function h(e, t) {
|
|
69
|
+
let n = e[t];
|
|
70
|
+
return typeof n == "string" && n.length > 0 ? n : null;
|
|
71
|
+
}
|
|
72
|
+
function g(e) {
|
|
73
|
+
return `${f}-${e}-${d}`;
|
|
74
|
+
}
|
|
75
|
+
function _(e) {
|
|
76
|
+
if (!e) return p();
|
|
77
|
+
let t;
|
|
78
|
+
try {
|
|
79
|
+
t = JSON.parse(e);
|
|
80
|
+
} catch {
|
|
81
|
+
return p();
|
|
82
|
+
}
|
|
83
|
+
return !m(t) || !m(t.state) ? p() : {
|
|
84
|
+
organizationId: h(t.state, "currentOrganizationId"),
|
|
85
|
+
workspaceId: h(t.state, "currentWorkspaceId"),
|
|
86
|
+
projectId: h(t.state, "currentProjectId")
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function v() {
|
|
90
|
+
if (typeof window > "u") return p();
|
|
91
|
+
try {
|
|
92
|
+
let e = t();
|
|
93
|
+
return e ? _(localStorage.getItem(g(e))) : p();
|
|
94
|
+
} catch {
|
|
95
|
+
return p();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function y(e, t) {
|
|
58
99
|
return o(t?.urlParam ?? r[e]) || s(e, t?.storageKey ?? "burdenoff-active-context");
|
|
59
100
|
}
|
|
60
101
|
//#endregion
|
|
61
|
-
export { n as ACTIVE_CONTEXT_STORAGE_KEY, r as DEFAULT_ACTIVE_CONTEXT_URL_PARAMS, u as clearActiveContextStorage, o as getUrlParam, s as readActiveContextStorageValue,
|
|
102
|
+
export { n as ACTIVE_CONTEXT_STORAGE_KEY, r as DEFAULT_ACTIVE_CONTEXT_URL_PARAMS, u as clearActiveContextStorage, o as getUrlParam, s as readActiveContextStorageValue, y as readActiveContextValueWithUrlPrecedence, v as readAuthStoreContext, l as writeActiveContextFallback, c as writeActiveContextStorageValue };
|
package/dist/shared-assistant.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isQuotaExhaustedError as e } from "./shared/assistant/gatewayClient.js";
|
|
2
|
-
import {
|
|
3
|
-
import { AssistantRuntimeManager as
|
|
4
|
-
import { buildProgress as
|
|
5
|
-
import { createSandboxAssistantTransport as
|
|
6
|
-
import { useSandboxAssistantTransport as
|
|
7
|
-
export {
|
|
2
|
+
import { buildPromptRequestBody as t, checkAssistantAiCredits as n, createAssistantSandbox as r, createAssistantSession as i, downloadAssistantArtifact as a, extendAssistantSandboxTTL as o, findExistingSandbox as s, getAssistantArtifacts as c, getAssistantMessages as l, getAssistantSession as u, getAssistantStreamAccess as d, reportAssistantAiTokenUsage as f, sendAssistantPromptAsync as p, sendHeartbeat as m, waitForAssistantServiceReady as h, waitForSandboxRunning as g } from "./shared/assistant/api.js";
|
|
3
|
+
import { AssistantRuntimeManager as _ } from "./shared/assistant/runtime.js";
|
|
4
|
+
import { buildProgress as v, getAssistantMedia as y, isRecoverable as b, mapSessionToHistory as x, mergeMessagesById as S, sanitize as C } from "./shared/assistant/progress.js";
|
|
5
|
+
import { createSandboxAssistantTransport as w } from "./shared/assistant/createSandboxAssistantTransport.js";
|
|
6
|
+
import { useSandboxAssistantTransport as T } from "./shared/assistant/useSandboxAssistantTransport.js";
|
|
7
|
+
export { _ as AssistantRuntimeManager, v as buildProgress, t as buildPromptRequestBody, n as checkAssistantAiCredits, r as createAssistantSandbox, i as createAssistantSession, w as createSandboxAssistantTransport, a as downloadAssistantArtifact, o as extendAssistantSandboxTTL, s as findExistingSandbox, c as getAssistantArtifacts, y as getAssistantMedia, l as getAssistantMessages, u as getAssistantSession, d as getAssistantStreamAccess, e as isQuotaExhaustedError, b as isRecoverable, x as mapSessionToHistory, S as mergeMessagesById, f as reportAssistantAiTokenUsage, C as sanitize, p as sendAssistantPromptAsync, m as sendHeartbeat, T as useSandboxAssistantTransport, h as waitForAssistantServiceReady, g as waitForSandboxRunning };
|