@opengeni/sdk 4.0.2 → 5.0.3-canary.0

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 (48) hide show
  1. package/README.md +58 -9
  2. package/dist/artifact-client.d.ts +18 -8
  3. package/dist/artifacts.js +4 -4
  4. package/dist/browser.js +2 -2
  5. package/dist/chat/ids.d.ts +3 -3
  6. package/dist/chat/index.js +38 -51
  7. package/dist/chat/index.js.map +1 -1
  8. package/dist/chat/opengeni.d.ts +10 -12
  9. package/dist/chat/types.d.ts +7 -3
  10. package/dist/{chunk-O23OOWJK.js → chunk-4YAL54F3.js} +2 -2
  11. package/dist/{chunk-UW22XVCT.js → chunk-ARGX7UY4.js} +97 -2
  12. package/dist/chunk-ARGX7UY4.js.map +1 -0
  13. package/dist/chunk-J5USCWPE.js +195 -0
  14. package/dist/chunk-J5USCWPE.js.map +1 -0
  15. package/dist/{chunk-WNEGCYCE.js → chunk-TARU5CD2.js} +1 -1
  16. package/dist/chunk-TARU5CD2.js.map +1 -0
  17. package/dist/{chunk-3IZMCD2K.js → chunk-TOB3B4ZJ.js} +28 -41
  18. package/dist/chunk-TOB3B4ZJ.js.map +1 -0
  19. package/dist/{chunk-2H7P45YQ.js → chunk-UQGHX4DI.js} +173 -7
  20. package/dist/chunk-UQGHX4DI.js.map +1 -0
  21. package/dist/client.d.ts +39 -4
  22. package/dist/core.js +3 -3
  23. package/dist/document-authority.js +3 -3
  24. package/dist/editable-artifacts.js +1 -1
  25. package/dist/embedding-client.d.ts +72 -0
  26. package/dist/index.d.ts +4 -1
  27. package/dist/index.js +13 -8
  28. package/dist/index.js.map +1 -1
  29. package/dist/site-tool-bridge.d.ts +39 -0
  30. package/dist/site.d.ts +2 -0
  31. package/dist/site.js +7 -3
  32. package/dist/types.d.ts +23 -12
  33. package/package.json +3 -2
  34. package/src/artifact-client.ts +38 -63
  35. package/src/chat/ids.ts +3 -3
  36. package/src/chat/opengeni.ts +41 -57
  37. package/src/chat/types.ts +7 -3
  38. package/src/client.ts +253 -12
  39. package/src/embedding-client.ts +308 -0
  40. package/src/index.ts +16 -1
  41. package/src/site-tool-bridge.ts +141 -0
  42. package/src/site.ts +7 -0
  43. package/src/types.ts +18 -6
  44. package/dist/chunk-2H7P45YQ.js.map +0 -1
  45. package/dist/chunk-3IZMCD2K.js.map +0 -1
  46. package/dist/chunk-UW22XVCT.js.map +0 -1
  47. package/dist/chunk-WNEGCYCE.js.map +0 -1
  48. /package/dist/{chunk-O23OOWJK.js.map → chunk-4YAL54F3.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import { OpenGeniClient } from "../client.js";
1
+ import { OpenGeniEmbeddingClient as OpenGeniClient } from "../embedding-client.js";
2
2
  import type { CreateSessionRequest, Session } from "../types.js";
3
3
  import { type ChatChunk, type ChatImportedMessage, type ChatMessage, type ChatOptions, type ChatReply, type ChatRespondInput, type ChatSendOptions, type ChatSessionListOptions, type ChatSnapshot, type ChatTarget, type OpenGeniOptions } from "./types.js";
4
4
  export declare const DEFAULT_OPENGENI_BASE_URL = "https://app.opengeni.ai";
@@ -23,7 +23,7 @@ export declare class OpenGeni {
23
23
  readonly organizationId: string;
24
24
  readonly source: string;
25
25
  readonly sessions: {
26
- /** Sessions of one tenant workspace, optionally filtered to one end user. */
26
+ /** Sessions visible to the selected canonical user, or explicit service caller. */
27
27
  list: (options: ChatSessionListOptions) => Promise<Session[]>;
28
28
  };
29
29
  private readonly workspaceName;
@@ -36,17 +36,15 @@ export declare class OpenGeni {
36
36
  }): Promise<string>;
37
37
  /**
38
38
  * Address one conversation; the session is created lazily on the first send.
39
- * With a `user`, the conversation id is namespaced to that user (a different
40
- * user with the same conversation id reaches a different session).
39
+ * Identity selects authority, not the conversation address. Workspace
40
+ * membership must be provisioned by the host's explicit onboarding flow.
41
+ * Legacy user-namespaced conversations remain accessible by their session ID.
41
42
  */
42
43
  chat(options: ChatOptions): Promise<Chat>;
43
44
  /**
44
- * Address an existing session by id (for example decoded from a response id).
45
- * `user` is the end user the caller authenticated: the session must carry
46
- * exactly that end-user label (`{ source, id }`) or the call throws
47
- * `conversation_not_authorized`. Pass `null` only from trusted server code
48
- * that vouches for the session itself; a session reached with `null` is not
49
- * checked against any user.
45
+ * Address an existing session with native API authorization. The same shared
46
+ * session can be opened by different authorized users. Pass null only for an
47
+ * explicitly service-owned operation; the API still enforces service access.
50
48
  */
51
49
  chatBySessionId(target: {
52
50
  workspaceId: string;
@@ -58,7 +56,7 @@ export declare class OpenGeni {
58
56
  }
59
57
  /** One conversation bound to one deterministic session. */
60
58
  export declare class Chat {
61
- private readonly og;
59
+ private readonly client;
62
60
  readonly workspaceId: string;
63
61
  readonly sessionId: string;
64
62
  /** The conversation id this chat was opened with; null when addressed by session id. */
@@ -66,7 +64,7 @@ export declare class Chat {
66
64
  private session;
67
65
  private readonly buildCreate;
68
66
  private pendingTurnId;
69
- constructor(og: OpenGeni, init: ChatInit);
67
+ constructor(client: OpenGeniClient, init: ChatInit);
70
68
  /** True once the session exists on the server. */
71
69
  get created(): boolean;
72
70
  /** Send a message and wait for the agent's reply text. */
@@ -4,9 +4,10 @@ import type { CreateSessionRequest, HumanInputAnswer, SessionEvent, Session, Ses
4
4
  export type ChatAgentAccess = "session" | "user" | "workspace";
5
5
  /**
6
6
  * Memory scope for the session: which memories the agent reads and where it
7
- * saves. `false` disables Memory tools. Omitted follows `agentAccess`.
7
+ * saves. `false` disables Memory tools. Omitted follows user/workspace agent
8
+ * reach; session-only reach defaults to false. Task notes cover task-local data.
8
9
  */
9
- export type ChatMemory = "session" | "user" | "workspace" | false;
10
+ export type ChatMemory = "user" | "workspace" | false;
10
11
  export type OpenGeniOptions = {
11
12
  /** Organization API key. Keep it on the server. */
12
13
  apiKey: string;
@@ -31,10 +32,13 @@ export type ChatTarget = {
31
32
  tenant?: undefined;
32
33
  };
33
34
  export type ChatOptions = ChatTarget & {
34
- /** Opaque end-user label inside the tenant. Required for `memory: "user"`. */
35
+ /** Host-authenticated external user; resolved through server-side asUser(). */
35
36
  user?: string | undefined;
36
37
  /** Stable conversation id; the session id is derived from it deterministically. */
37
38
  conversation: string;
39
+ /** Prefer the actual OpenGeni session ID for shared or existing conversations.
40
+ * The acting user is independent of the conversation's identity. */
41
+ sessionId?: string | undefined;
38
42
  /** Defaults to `"session"`: the agent sees only this conversation. */
39
43
  agentAccess?: ChatAgentAccess | undefined;
40
44
  memory?: ChatMemory | undefined;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  OpenGeniClient
3
- } from "./chunk-2H7P45YQ.js";
3
+ } from "./chunk-UQGHX4DI.js";
4
4
 
5
5
  // src/document-authority-client.ts
6
6
  var OpenGeniDocumentAuthorityClient = class extends OpenGeniClient {
@@ -76,4 +76,4 @@ var OpenGeniDocumentAuthorityClient = class extends OpenGeniClient {
76
76
  export {
77
77
  OpenGeniDocumentAuthorityClient
78
78
  };
79
- //# sourceMappingURL=chunk-O23OOWJK.js.map
79
+ //# sourceMappingURL=chunk-4YAL54F3.js.map
@@ -3,7 +3,10 @@ import {
3
3
  } from "./chunk-FMLDFJ2Q.js";
4
4
  import {
5
5
  OpenGeniClient
6
- } from "./chunk-2H7P45YQ.js";
6
+ } from "./chunk-UQGHX4DI.js";
7
+ import {
8
+ OpenGeniApiError
9
+ } from "./chunk-OO5LPTO7.js";
7
10
 
8
11
  // ../contracts/src/site-session-http.ts
9
12
  var SITE_WORKSPACE_PREFIX = "/v1/workspaces/site-host";
@@ -163,6 +166,96 @@ async function sitePortFetch(port, input, init) {
163
166
  });
164
167
  }
165
168
 
169
+ // src/site-tool-bridge.ts
170
+ function createSiteToolBridge(input) {
171
+ const allowed = new Set(input.requestedTools.map(identityKey));
172
+ let projectedCatalog = null;
173
+ const loadCatalog = async ({
174
+ signal,
175
+ refresh = false
176
+ }) => {
177
+ signal.throwIfAborted();
178
+ if (projectedCatalog && !refresh) return projectedCatalog;
179
+ const current = await input.workspaceTools.$catalog({
180
+ signal,
181
+ ...refresh ? { refresh } : {}
182
+ });
183
+ signal.throwIfAborted();
184
+ if (current.workspaceId !== input.workspaceId)
185
+ throw new Error("Site catalog workspace mismatch");
186
+ projectedCatalog = {
187
+ version: current.version,
188
+ generation: current.generation,
189
+ digest: current.digest,
190
+ createdAt: current.createdAt,
191
+ entries: current.entries.filter((entry) => allowed.has(identityKey(entry.identity)))
192
+ };
193
+ return projectedCatalog;
194
+ };
195
+ return {
196
+ ...input.fetchResponse ? {
197
+ fetch: async (message, signal) => {
198
+ const path = siteSessionPath(
199
+ message.path,
200
+ input.workspaceId,
201
+ message.method,
202
+ input.artifactId
203
+ );
204
+ const headers = new Headers();
205
+ headers.set("x-opengeni-site-id", input.artifactId);
206
+ headers.set("x-opengeni-site-version", input.siteVersionId);
207
+ for (const [name, value] of message.headers) {
208
+ if (["content-type", "accept", "last-event-id"].includes(name.toLowerCase()))
209
+ headers.set(name, value);
210
+ }
211
+ return input.fetchResponse(path, {
212
+ method: message.method,
213
+ signal,
214
+ headers: Object.fromEntries(headers),
215
+ ...message.body === void 0 ? {} : { body: message.body }
216
+ });
217
+ }
218
+ } : {},
219
+ catalog: loadCatalog,
220
+ call: async (request, { signal }) => {
221
+ if (!allowed.has(identityKey(request.identity)))
222
+ throw new Error("This tool is not available to the Site");
223
+ const call = async (refresh = false) => {
224
+ const catalog = await loadCatalog({ signal, refresh });
225
+ if (!catalog.entries.some(
226
+ (entry) => identityKey(entry.identity) === identityKey(request.identity)
227
+ ))
228
+ throw new Error("This requested tool is not enabled in the workspace");
229
+ return input.callTool({
230
+ workspaceId: input.workspaceId,
231
+ signal,
232
+ request: {
233
+ ...request.operationId ? { operationId: request.operationId } : {},
234
+ catalogDigest: catalog.digest,
235
+ identity: request.identity,
236
+ arguments: request.arguments,
237
+ siteArtifactId: input.artifactId,
238
+ siteVersionId: input.siteVersionId
239
+ }
240
+ });
241
+ };
242
+ try {
243
+ return await call();
244
+ } catch (error) {
245
+ if (!(input.isCatalogStale ?? isSiteCatalogStaleError)(error)) throw error;
246
+ projectedCatalog = null;
247
+ return await call(true);
248
+ }
249
+ }
250
+ };
251
+ }
252
+ function isSiteCatalogStaleError(error) {
253
+ return error instanceof OpenGeniApiError && error.status === 409 && error.details?.code === "catalog_stale";
254
+ }
255
+ function identityKey(identity) {
256
+ return `${identity.serverId}\0${identity.toolName}`;
257
+ }
258
+
166
259
  // src/site.ts
167
260
  var OPENGENI_SITE_BRIDGE_VERSION = 2;
168
261
  var OPENGENI_SITE_BRIDGE_CONNECT = "opengeni.site.connect";
@@ -516,6 +609,8 @@ export {
516
609
  siteSessionPath,
517
610
  isSiteHttpRequest,
518
611
  serveSiteHttp,
612
+ createSiteToolBridge,
613
+ isSiteCatalogStaleError,
519
614
  OPENGENI_SITE_BRIDGE_VERSION,
520
615
  OPENGENI_SITE_BRIDGE_CONNECT,
521
616
  OPENGENI_SITE_BRIDGE_READY,
@@ -531,4 +626,4 @@ export {
531
626
  isOpenGeniSiteBridgeCancelMessage,
532
627
  sanitizeOpenGeniSiteToolCallRequest
533
628
  };
534
- //# sourceMappingURL=chunk-UW22XVCT.js.map
629
+ //# sourceMappingURL=chunk-ARGX7UY4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../contracts/src/site-session-http.ts","../src/site-http.ts","../src/site-tool-bridge.ts","../src/site.ts"],"sourcesContent":["const SITE_WORKSPACE_PREFIX = \"/v1/workspaces/site-host\";\n\n/** A Site/Codemode SDK request named a route outside the proxied surface. */\nexport class SiteSessionPathError extends Error {\n readonly code = \"site_session_path_unsupported\";\n\n constructor() {\n super(\"Unsupported Site session API path\");\n this.name = \"SiteSessionPathError\";\n }\n}\n\n/** Route browser/preview SDK requests to the host workspace. This is a URL\n * boundary, not an endpoint or HTTP-method allowlist. Ordinary API handlers\n * authorize every operation with the viewer or agent's existing authority. */\nexport function siteSessionPath(\n path: string,\n workspaceId: string,\n _method = \"GET\",\n siteId?: string,\n): string {\n const pathname = path.split(\"?\")[0]!;\n const workspace =\n pathname === SITE_WORKSPACE_PREFIX || pathname.startsWith(`${SITE_WORKSPACE_PREFIX}/`);\n const context = pathname === \"/v1/config/client\";\n if (\n (!workspace && !context) ||\n /[%\\\\#\\u0000-\\u0020\\u007f]/u.test(pathname) ||\n pathname.split(\"/\").some((p) => p === \".\" || p === \"..\")\n ) {\n throw new SiteSessionPathError();\n }\n const rewritten = path.replace(\n \"/workspaces/site-host\",\n `/workspaces/${encodeURIComponent(workspaceId)}`,\n );\n // Preview has no published Site identity. Never widen a Site-only list to the workspace.\n const url = new URL(rewritten, \"http://site.invalid\");\n if (url.searchParams.get(\"originSiteId\") === \"current\" && workspaceId !== \"site-host\") {\n url.searchParams.set(\"originSiteId\", siteId ?? \"00000000-0000-0000-0000-000000000000\");\n return url.pathname + url.search;\n }\n return rewritten;\n}\n","/** HTTP transport for the ordinary SDK. One response port per request keeps\n * event streams incremental and cancellation independent of other requests. */\nexport const SITE_HTTP = \"opengeni.site.http\";\nexport const SITE_WORKSPACE = \"site-host\";\nexport type SiteHttpRequest = {\n type: typeof SITE_HTTP;\n requestId: string;\n path: string;\n method: string;\n headers: [string, string][];\n body?: string;\n};\n\nimport { siteSessionPath } from \"@opengeni/contracts/site-session-http\";\nexport { siteSessionPath } from \"@opengeni/contracts/site-session-http\";\n\nexport function isSiteHttpRequest(value: unknown): value is SiteHttpRequest {\n if (!value || typeof value !== \"object\") return false;\n const v = value as SiteHttpRequest;\n return (\n v.type === SITE_HTTP &&\n typeof v.requestId === \"string\" &&\n typeof v.path === \"string\" &&\n typeof v.method === \"string\" &&\n /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/u.test(v.method) &&\n (v.body === undefined || typeof v.body === \"string\") &&\n Array.isArray(v.headers) &&\n v.headers.every(\n (h) => Array.isArray(h) && h.length === 2 && h.every((x) => typeof x === \"string\"),\n )\n );\n}\n\nexport async function serveSiteHttp(\n message: SiteHttpRequest,\n port: MessagePort,\n fetchResponse: (request: SiteHttpRequest, signal: AbortSignal) => Promise<Response>,\n signal: AbortSignal,\n): Promise<void> {\n let reader: ReadableStreamDefaultReader<Uint8Array> | undefined;\n let wake: (() => void) | undefined;\n let pulling = false;\n const onMessage = (event: MessageEvent) => {\n if (event.data === \"pull\") {\n pulling = true;\n wake?.();\n }\n };\n const abort = () => {\n void reader?.cancel(signal.reason).catch(() => {});\n wake?.();\n };\n port.addEventListener(\"message\", onMessage);\n signal.addEventListener(\"abort\", abort, { once: true });\n port.start();\n try {\n if (signal.aborted) throw signal.reason;\n const response = await fetchResponse(message, signal);\n reader = response.body?.getReader();\n port.postMessage({ status: response.status, headers: [...response.headers], body: !!reader });\n if (reader)\n while (!signal.aborted) {\n if (!pulling)\n await new Promise<void>((resolve) => {\n wake = resolve;\n });\n wake = undefined;\n if (signal.aborted) break;\n pulling = false;\n const part = await reader.read();\n if (part.done) {\n port.postMessage({ done: true });\n break;\n }\n port.postMessage({ chunk: part.value });\n }\n if (signal.aborted) throw signal.reason;\n } catch (error) {\n port.postMessage({ error: error instanceof Error ? error.message : \"Site request failed\" });\n } finally {\n signal.removeEventListener(\"abort\", abort);\n port.removeEventListener(\"message\", onMessage);\n await reader?.cancel().catch(() => {});\n port.close();\n }\n}\n\nexport async function sitePortFetch(\n port: MessagePort,\n input: RequestInfo | URL,\n init?: RequestInit,\n): Promise<Response> {\n const request = new Request(input, init);\n const url = new URL(request.url);\n const path = `${url.pathname}${url.search}`;\n siteSessionPath(path, SITE_WORKSPACE, request.method);\n const channel = new MessageChannel();\n const requestId = crypto.randomUUID();\n const body = request.body ? await request.text() : undefined;\n return await new Promise<Response>((resolve, reject) => {\n let controller: ReadableStreamDefaultController<Uint8Array> | undefined;\n let finished = false;\n const cleanup = () => {\n finished = true;\n request.signal.removeEventListener(\"abort\", abort);\n channel.port1.close();\n };\n const abort = () => {\n if (finished) return;\n port.postMessage({ type: \"opengeni.site.cancel\", version: 2, requestId });\n const error = request.signal.reason ?? new DOMException(\"Cancelled\", \"AbortError\");\n controller?.error(error);\n reject(error);\n cleanup();\n };\n channel.port1.onmessage = (event) => {\n const data = event.data;\n if (data.error) {\n const error = new Error(data.error);\n controller?.error(error);\n reject(error);\n cleanup();\n } else if (data.status) {\n const stream = data.body\n ? new ReadableStream<Uint8Array>({\n start(c) {\n controller = c;\n },\n pull() {\n channel.port1.postMessage(\"pull\");\n },\n cancel() {\n controller = undefined;\n abort();\n },\n })\n : null;\n resolve(new Response(stream, { status: data.status, headers: data.headers }));\n if (!data.body) cleanup();\n } else if (data.done) {\n controller?.close();\n cleanup();\n } else if (data.chunk) controller?.enqueue(data.chunk);\n };\n if (request.signal.aborted) {\n abort();\n return;\n }\n request.signal.addEventListener(\"abort\", abort, { once: true });\n port.postMessage(\n {\n type: SITE_HTTP,\n requestId,\n path,\n method: request.method,\n headers: [...request.headers],\n ...(body === undefined ? {} : { body }),\n } satisfies SiteHttpRequest,\n [channel.port2],\n );\n });\n}\n","import { OpenGeniApiError } from \"./errors\";\nimport { siteSessionPath, type SiteHttpRequest } from \"./site-http\";\nimport type { OpenGeniSiteToolCatalog } from \"./site\";\nimport type { OpenGeniWorkspaceTools } from \"./tools\";\nimport type { ToolGatewayCallRequest, ToolGatewayCallResponse, ToolGatewayIdentity } from \"./types\";\n\nexport type SiteToolCallRequest = ToolGatewayCallRequest & {\n siteArtifactId: string;\n siteVersionId: string;\n};\nexport type SiteToolCaller = (input: {\n workspaceId: string;\n request: SiteToolCallRequest;\n signal: AbortSignal;\n}) => Promise<ToolGatewayCallResponse>;\nexport type SiteToolBridge = {\n fetch?: (request: SiteHttpRequest, signal: AbortSignal) => Promise<Response>;\n catalog: (options: { signal: AbortSignal }) => Promise<OpenGeniSiteToolCatalog>;\n call: (\n request: ToolGatewayCallRequest,\n options: { signal: AbortSignal },\n ) => Promise<ToolGatewayCallResponse>;\n};\nexport type CreateSiteToolBridgeOptions = {\n workspaceTools: Pick<OpenGeniWorkspaceTools, \"$catalog\">;\n workspaceId: string;\n artifactId: string;\n siteVersionId: string;\n requestedTools: readonly ToolGatewayIdentity[];\n callTool: SiteToolCaller;\n isCatalogStale?: (error: unknown) => boolean;\n /** Optional authenticated host transport for the host-bound workspace API.\n * Omit to expose tools only. Site-provided authorization headers are never forwarded. */\n fetchResponse?: (path: string, init: RequestInit) => Promise<Response>;\n};\n\n/** Host-side bridge for the opaque Site frame. Supply an authenticated transport;\n * the server independently checks live viewer access and the exact Site version.\n * Recreate on actor/version change. Never take these pinned fields from HTML. */\nexport function createSiteToolBridge(input: CreateSiteToolBridgeOptions): SiteToolBridge {\n const allowed = new Set(input.requestedTools.map(identityKey));\n let projectedCatalog: OpenGeniSiteToolCatalog | null = null;\n const loadCatalog = async ({\n signal,\n refresh = false,\n }: {\n signal: AbortSignal;\n refresh?: boolean;\n }): Promise<OpenGeniSiteToolCatalog> => {\n signal.throwIfAborted();\n if (projectedCatalog && !refresh) return projectedCatalog;\n const current = await input.workspaceTools.$catalog({\n signal,\n ...(refresh ? { refresh } : {}),\n });\n signal.throwIfAborted();\n if (current.workspaceId !== input.workspaceId)\n throw new Error(\"Site catalog workspace mismatch\");\n projectedCatalog = {\n version: current.version,\n generation: current.generation,\n digest: current.digest,\n createdAt: current.createdAt,\n entries: current.entries.filter((entry) => allowed.has(identityKey(entry.identity))),\n };\n return projectedCatalog;\n };\n return {\n ...(input.fetchResponse\n ? {\n fetch: async (message: SiteHttpRequest, signal: AbortSignal) => {\n const path = siteSessionPath(\n message.path,\n input.workspaceId,\n message.method,\n input.artifactId,\n );\n const headers = new Headers();\n headers.set(\"x-opengeni-site-id\", input.artifactId);\n headers.set(\"x-opengeni-site-version\", input.siteVersionId);\n for (const [name, value] of message.headers) {\n if ([\"content-type\", \"accept\", \"last-event-id\"].includes(name.toLowerCase()))\n headers.set(name, value);\n }\n return input.fetchResponse!(path, {\n method: message.method,\n signal,\n headers: Object.fromEntries(headers),\n ...(message.body === undefined ? {} : { body: message.body }),\n });\n },\n }\n : {}),\n catalog: loadCatalog,\n call: async (request, { signal }) => {\n if (!allowed.has(identityKey(request.identity)))\n throw new Error(\"This tool is not available to the Site\");\n const call = async (refresh = false) => {\n const catalog = await loadCatalog({ signal, refresh });\n if (\n !catalog.entries.some(\n (entry) => identityKey(entry.identity) === identityKey(request.identity),\n )\n )\n throw new Error(\"This requested tool is not enabled in the workspace\");\n return input.callTool({\n workspaceId: input.workspaceId,\n signal,\n request: {\n ...(request.operationId ? { operationId: request.operationId } : {}),\n catalogDigest: catalog.digest,\n identity: request.identity,\n arguments: request.arguments,\n siteArtifactId: input.artifactId,\n siteVersionId: input.siteVersionId,\n },\n });\n };\n try {\n return await call();\n } catch (error) {\n // Only pre-execution catalog rejection permits one retry. Never retry\n // transport failures, expired credentials or uncertain tool effects.\n if (!(input.isCatalogStale ?? isSiteCatalogStaleError)(error)) throw error;\n projectedCatalog = null;\n return await call(true);\n }\n },\n };\n}\n\nexport function isSiteCatalogStaleError(error: unknown): boolean {\n return (\n error instanceof OpenGeniApiError &&\n error.status === 409 &&\n error.details?.code === \"catalog_stale\"\n );\n}\nfunction identityKey(identity: ToolGatewayIdentity): string {\n return `${identity.serverId}\\u0000${identity.toolName}`;\n}\n","export { createSiteToolBridge, isSiteCatalogStaleError } from \"./site-tool-bridge\";\nexport type {\n SiteToolBridge,\n SiteToolCaller,\n SiteToolCallRequest,\n CreateSiteToolBridgeOptions,\n} from \"./site-tool-bridge\";\nimport {\n OpenGeniToolsClient,\n type OpenGeniToolTransport,\n type OpenGeniWorkspaceTools,\n} from \"./tools\";\nimport { OpenGeniClient } from \"./client\";\nimport { sitePortFetch, siteSessionPath, SITE_WORKSPACE } from \"./site-http\";\nexport {\n isSiteHttpRequest,\n serveSiteHttp,\n siteSessionPath,\n type SiteHttpRequest,\n} from \"./site-http\";\nimport type {\n ToolGatewayCallRequest,\n ToolGatewayCallResponse,\n ToolGatewayCatalog,\n ToolGatewayDeclarationsResponse,\n} from \"./types\";\n\nexport const OPENGENI_SITE_BRIDGE_VERSION = 2 as const;\nexport const OPENGENI_SITE_BRIDGE_CONNECT = \"opengeni.site.connect\" as const;\nexport const OPENGENI_SITE_BRIDGE_READY = \"opengeni.site.ready\" as const;\nexport const OPENGENI_SITE_BRIDGE_REQUEST = \"opengeni.site.request\" as const;\nexport const OPENGENI_SITE_BRIDGE_RESPONSE = \"opengeni.site.response\" as const;\nexport const OPENGENI_SITE_BRIDGE_CANCEL = \"opengeni.site.cancel\" as const;\nexport const OPENGENI_SITE_BRIDGE_BOOTSTRAP_GLOBAL = \"__opengeniSiteBridgeBootstrapV2\" as const;\nexport const OPENGENI_SITE_LOCAL_CODEMODE_PATH = \"/__opengeni/site-tools\" as const;\n\nexport type OpenGeniSiteBridgeConnectMessage = {\n type: typeof OPENGENI_SITE_BRIDGE_CONNECT;\n version: typeof OPENGENI_SITE_BRIDGE_VERSION;\n};\n\nexport type OpenGeniSiteBridgeReadyMessage = {\n type: typeof OPENGENI_SITE_BRIDGE_READY;\n version: typeof OPENGENI_SITE_BRIDGE_VERSION;\n};\n\n/** Site-originated calls cannot carry host-only approval tokens or Site-version authority. */\nexport type OpenGeniSiteToolCallRequest = Omit<\n ToolGatewayCallRequest,\n \"approvalToken\" | \"siteArtifactId\" | \"siteVersionId\"\n>;\n\n/** Host-filtered catalog projection. Tenant routing context never enters Site code. */\nexport type OpenGeniSiteToolCatalog = Omit<ToolGatewayCatalog, \"accountId\" | \"workspaceId\">;\n\nexport type OpenGeniSiteWorkspaceTools = OpenGeniWorkspaceTools<OpenGeniSiteToolCatalog>;\n\nexport type OpenGeniSiteBridgeRequestMessage = {\n type: typeof OPENGENI_SITE_BRIDGE_REQUEST;\n version: typeof OPENGENI_SITE_BRIDGE_VERSION;\n requestId: string;\n} & (\n | { method: \"catalog\" }\n | { method: \"call\"; payload: OpenGeniSiteToolCallRequest }\n | { method: \"declarations\" }\n);\n\nexport type OpenGeniSiteBridgeCancelMessage = {\n type: typeof OPENGENI_SITE_BRIDGE_CANCEL;\n version: typeof OPENGENI_SITE_BRIDGE_VERSION;\n requestId: string;\n};\n\nexport type OpenGeniSiteBridgeResponseMessage = {\n type: typeof OPENGENI_SITE_BRIDGE_RESPONSE;\n version: typeof OPENGENI_SITE_BRIDGE_VERSION;\n requestId: string;\n} & (\n | {\n ok: true;\n value: OpenGeniSiteToolCatalog | ToolGatewayCallResponse | ToolGatewayDeclarationsResponse;\n }\n | {\n ok: false;\n error: {\n code: string;\n message: string;\n retryable: boolean;\n outcomeUnknown?: boolean;\n };\n }\n);\n\nexport type OpenGeniSiteClient = {\n /** Ordinary SDK, including React session/composer methods and SSE streams. */\n readonly client: OpenGeniClient;\n /** Host-bound routing alias, not a credential or a caller-selected tenant. */\n readonly workspaceId: string;\n /** Workspace-bound typed facade. The parent host owns workspace identity and credentials. */\n readonly tools: OpenGeniSiteWorkspaceTools;\n close(): void;\n};\n\nexport type OpenGeniSiteClientOptions = {\n /** Advanced embedding seam; ordinary Sites accept bootstrap only from their exact parent. */\n parentWindow?: MessageEventSource;\n /** Advanced embedding seam for listening to the host's document-bound bootstrap message. */\n siteWindow?: Pick<Window, \"parent\" | \"addEventListener\" | \"removeEventListener\">;\n /** Test/embedding seam for an already document-bound host bootstrap port. */\n bootstrapPort?: MessagePort;\n connectTimeoutMs?: number;\n requestTimeoutMs?: number;\n createMessageChannel?: () => MessageChannel;\n /** Local-preview seam. Top-level pages use this same-origin Codemode proxy automatically. */\n localCodemodePath?: string | false;\n /** Test/embedding seam for local-preview requests. */\n fetch?: typeof globalThis.fetch;\n};\n\nexport class OpenGeniSiteBridgeError extends Error {\n constructor(\n readonly code: string,\n message: string,\n readonly retryable = false,\n readonly outcomeUnknown = false,\n ) {\n super(message);\n this.name = \"OpenGeniSiteBridgeError\";\n }\n}\n\n/**\n * Create the browser client used by a Site. Published iframes use the parent\n * MessagePort; top-level sandbox previews use the same-origin Codemode adapter.\n * Credentials remain in the selected host and never enter Site code.\n */\nexport function createOpenGeniSiteClient(\n options: OpenGeniSiteClientOptions = {},\n): OpenGeniSiteClient {\n const transport = shouldUseLocalCodemode(options)\n ? new OpenGeniSiteLocalCodemodeTransport(options)\n : new OpenGeniSiteBridgeTransport(options);\n return {\n client: new OpenGeniClient({\n baseUrl: \"https://site.opengeni.invalid\",\n fetch: (input, init) => transport.fetch(input, init),\n }),\n workspaceId: SITE_WORKSPACE,\n tools: new OpenGeniToolsClient(transport).forWorkspace(\"site-host\"),\n close: () => transport.close(),\n };\n}\n\nclass OpenGeniSiteLocalCodemodeTransport implements OpenGeniToolTransport {\n private readonly fetchImpl: typeof globalThis.fetch;\n private readonly basePath: string;\n\n constructor(options: OpenGeniSiteClientOptions) {\n this.fetchImpl = options.fetch ?? globalThis.fetch.bind(globalThis);\n const configured = options.localCodemodePath;\n this.basePath = (\n typeof configured === \"string\" ? configured : OPENGENI_SITE_LOCAL_CODEMODE_PATH\n ).replace(/\\/+$/u, \"\");\n }\n\n close(): void {}\n\n async fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {\n const request = new Request(input, init);\n const url = new URL(request.url);\n const path = `${url.pathname}${url.search}`;\n siteSessionPath(path, SITE_WORKSPACE, request.method);\n return this.fetchImpl(`${this.basePath}/sdk${path}`, {\n method: request.method,\n headers: request.headers,\n signal: request.signal,\n ...(request.body ? { body: await request.text() } : {}),\n });\n }\n\n async requestJson<T>(\n method: string,\n path: string,\n body?: unknown,\n _query?: Record<string, string>,\n options: { signal?: AbortSignal } = {},\n ): Promise<T> {\n const suffix = localCodemodeSuffix(method, path);\n const response = await this.fetchImpl(`${this.basePath}${suffix}`, {\n method,\n ...(options.signal ? { signal: options.signal } : {}),\n ...(body === undefined\n ? {}\n : {\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(body),\n }),\n });\n const value = (await response.json()) as unknown;\n if (response.ok) return value as T;\n const envelope = isRecord(value) && isRecord(value.error) ? value.error : {};\n throw new OpenGeniSiteBridgeError(\n typeof envelope.code === \"string\" ? envelope.code : \"local_codemode_error\",\n typeof envelope.message === \"string\"\n ? envelope.message\n : `Local Site tool request failed with HTTP ${response.status}`,\n envelope.retryable === true,\n envelope.outcomeUnknown === true,\n );\n }\n}\n\nfunction shouldUseLocalCodemode(options: OpenGeniSiteClientOptions): boolean {\n if (options.localCodemodePath === false || options.bootstrapPort) return false;\n if (typeof options.localCodemodePath === \"string\") return true;\n const siteWindow = options.siteWindow ?? globalThis.window;\n return Boolean(siteWindow && siteWindow.parent === siteWindow);\n}\n\nfunction localCodemodeSuffix(method: string, path: string): string {\n if (method === \"GET\" && path.endsWith(\"/tools/catalog\")) return \"/catalog\";\n if (method === \"GET\" && path.endsWith(\"/tools/declarations\")) return \"/declarations\";\n if (method === \"POST\" && path.endsWith(\"/tools/calls\")) return \"/calls\";\n throw new OpenGeniSiteBridgeError(\"unsupported_request\", \"Unsupported Site tool request\");\n}\n\nexport function isOpenGeniSiteBridgeConnectMessage(\n value: unknown,\n): value is OpenGeniSiteBridgeConnectMessage {\n return (\n isRecord(value) &&\n value.type === OPENGENI_SITE_BRIDGE_CONNECT &&\n value.version === OPENGENI_SITE_BRIDGE_VERSION\n );\n}\n\nexport function isOpenGeniSiteBridgeRequestMessage(\n value: unknown,\n): value is OpenGeniSiteBridgeRequestMessage {\n if (\n !isRecord(value) ||\n value.type !== OPENGENI_SITE_BRIDGE_REQUEST ||\n value.version !== OPENGENI_SITE_BRIDGE_VERSION ||\n typeof value.requestId !== \"string\" ||\n !value.requestId\n ) {\n return false;\n }\n if (value.method === \"catalog\" || value.method === \"declarations\") return true;\n return value.method === \"call\" && isRecord(value.payload);\n}\n\nexport function isOpenGeniSiteBridgeCancelMessage(\n value: unknown,\n): value is OpenGeniSiteBridgeCancelMessage {\n return (\n isRecord(value) &&\n value.type === OPENGENI_SITE_BRIDGE_CANCEL &&\n value.version === OPENGENI_SITE_BRIDGE_VERSION &&\n typeof value.requestId === \"string\" &&\n Boolean(value.requestId)\n );\n}\n\n/** Strip every host-only field before a call crosses the Site boundary. */\nexport function sanitizeOpenGeniSiteToolCallRequest(\n value: ToolGatewayCallRequest,\n): OpenGeniSiteToolCallRequest {\n return {\n ...(value.operationId === undefined ? {} : { operationId: value.operationId }),\n catalogDigest: value.catalogDigest,\n identity: value.identity,\n arguments: value.arguments,\n };\n}\n\nclass OpenGeniSiteBridgeTransport implements OpenGeniToolTransport {\n private readonly options: OpenGeniSiteClientOptions;\n private readonly bootstrap: SiteBridgeBootstrap;\n private port: MessagePort | null = null;\n private connecting: Promise<MessagePort> | null = null;\n private closed = false;\n\n constructor(options: OpenGeniSiteClientOptions) {\n this.options = options;\n this.bootstrap = createSiteBridgeBootstrap(options);\n }\n\n async fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {\n return sitePortFetch(await this.connect(), input, init);\n }\n\n async requestJson<T>(\n method: string,\n path: string,\n body?: unknown,\n _query?: Record<string, string>,\n requestOptions: { signal?: AbortSignal; timeoutMs?: number } = {},\n ): Promise<T> {\n if (method === \"GET\" && path.endsWith(\"/tools/catalog\")) {\n return (await this.request({ method: \"catalog\" }, requestOptions)) as T;\n }\n if (method === \"GET\" && path.endsWith(\"/tools/declarations\")) {\n return (await this.request({ method: \"declarations\" }, requestOptions)) as T;\n }\n if (method === \"POST\" && path.endsWith(\"/tools/calls\")) {\n if (!isRecord(body)) throw new TypeError(\"Site tool call payload is required\");\n return (await this.request(\n {\n method: \"call\",\n payload: sanitizeOpenGeniSiteToolCallRequest(body as ToolGatewayCallRequest),\n },\n requestOptions,\n )) as T;\n }\n throw new OpenGeniSiteBridgeError(\"unsupported_request\", \"Unsupported Site bridge request\");\n }\n\n close(): void {\n if (this.closed) return;\n this.closed = true;\n this.bootstrap.close();\n this.port?.close();\n this.port = null;\n }\n\n private async request(\n request:\n | { method: \"catalog\" }\n | { method: \"call\"; payload: OpenGeniSiteToolCallRequest }\n | { method: \"declarations\" },\n options: { signal?: AbortSignal; timeoutMs?: number },\n ): Promise<unknown> {\n const port = await this.connect();\n const requestId = crypto.randomUUID();\n const timeoutMs = positiveTimeout(\n options.timeoutMs ?? this.options.requestTimeoutMs ?? 120_000,\n \"requestTimeoutMs\",\n );\n return await new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n cleanup();\n cancel(port, requestId);\n reject(\n request.method === \"call\"\n ? new OpenGeniSiteBridgeError(\n \"timeout\",\n \"Site tool request timed out after execution may have started\",\n false,\n true,\n )\n : new OpenGeniSiteBridgeError(\"timeout\", \"Site tool request timed out\", true),\n );\n }, timeoutMs);\n const abort = () => {\n cleanup();\n cancel(port, requestId);\n reject(options.signal?.reason ?? new DOMException(\"Request aborted\", \"AbortError\"));\n };\n const onMessage = (event: MessageEvent<unknown>) => {\n const response = event.data;\n if (\n !isRecord(response) ||\n response.type !== OPENGENI_SITE_BRIDGE_RESPONSE ||\n response.version !== OPENGENI_SITE_BRIDGE_VERSION ||\n response.requestId !== requestId ||\n typeof response.ok !== \"boolean\"\n ) {\n return;\n }\n cleanup();\n if (response.ok) {\n resolve(response.value);\n return;\n }\n const error = isRecord(response.error) ? response.error : {};\n reject(\n new OpenGeniSiteBridgeError(\n typeof error.code === \"string\" ? error.code : \"bridge_error\",\n typeof error.message === \"string\" ? error.message : \"Site tool request failed\",\n error.retryable === true,\n error.outcomeUnknown === true,\n ),\n );\n };\n const cleanup = () => {\n clearTimeout(timeout);\n options.signal?.removeEventListener(\"abort\", abort);\n port.removeEventListener(\"message\", onMessage);\n };\n if (options.signal?.aborted) {\n abort();\n return;\n }\n options.signal?.addEventListener(\"abort\", abort, { once: true });\n port.addEventListener(\"message\", onMessage);\n port.postMessage({\n type: OPENGENI_SITE_BRIDGE_REQUEST,\n version: OPENGENI_SITE_BRIDGE_VERSION,\n requestId,\n ...request,\n } satisfies OpenGeniSiteBridgeRequestMessage);\n });\n }\n\n private async connect(): Promise<MessagePort> {\n if (this.closed) throw new OpenGeniSiteBridgeError(\"closed\", \"Site bridge is closed\");\n if (this.port) return this.port;\n if (this.connecting) return await this.connecting;\n const channel = (this.options.createMessageChannel ?? (() => new MessageChannel()))();\n const timeoutMs = positiveTimeout(this.options.connectTimeoutMs ?? 10_000, \"connectTimeoutMs\");\n this.connecting = new Promise<MessagePort>((resolve, reject) => {\n let active = true;\n const timeout = setTimeout(() => {\n cleanup();\n channel.port1.close();\n reject(new OpenGeniSiteBridgeError(\"host_timeout\", \"OpenGeni Site host did not respond\"));\n }, timeoutMs);\n const onMessage = (event: MessageEvent<unknown>) => {\n const message = event.data;\n if (\n !isRecord(message) ||\n message.type !== OPENGENI_SITE_BRIDGE_READY ||\n message.version !== OPENGENI_SITE_BRIDGE_VERSION\n ) {\n return;\n }\n cleanup();\n this.port = channel.port1;\n resolve(channel.port1);\n };\n const cleanup = () => {\n active = false;\n clearTimeout(timeout);\n channel.port1.removeEventListener(\"message\", onMessage);\n };\n channel.port1.addEventListener(\"message\", onMessage);\n channel.port1.start();\n void this.bootstrap\n .port()\n .then((bootstrapPort) => {\n if (!active) return;\n if (this.closed) throw new OpenGeniSiteBridgeError(\"closed\", \"Site bridge is closed\");\n bootstrapPort.postMessage(\n {\n type: OPENGENI_SITE_BRIDGE_CONNECT,\n version: OPENGENI_SITE_BRIDGE_VERSION,\n } satisfies OpenGeniSiteBridgeConnectMessage,\n [channel.port2],\n );\n })\n .catch((error) => {\n cleanup();\n channel.port1.close();\n reject(error);\n });\n }).finally(() => {\n this.connecting = null;\n });\n return await this.connecting;\n }\n}\n\ntype SiteBridgeBootstrap = {\n port: () => Promise<MessagePort>;\n close: () => void;\n};\n\nfunction createSiteBridgeBootstrap(options: OpenGeniSiteClientOptions): SiteBridgeBootstrap {\n if (options.bootstrapPort) {\n return {\n port: async () => options.bootstrapPort!,\n close: () => options.bootstrapPort?.close(),\n };\n }\n const siteWindow = options.siteWindow ?? globalThis.window;\n const parentWindow = options.parentWindow ?? siteWindow?.parent;\n if (!siteWindow || !parentWindow || parentWindow === siteWindow) {\n return {\n port: async () => {\n throw new OpenGeniSiteBridgeError(\n \"host_unavailable\",\n \"OpenGeni Site client must run inside a hosted iframe\",\n );\n },\n close: () => undefined,\n };\n }\n const retainedPort = retainedSiteBridgeBootstrapPort(siteWindow);\n if (retainedPort) {\n return {\n port: async () => retainedPort,\n close: () => undefined,\n };\n }\n let settledPort: MessagePort | null = null;\n let rejectBootstrap: ((reason?: unknown) => void) | null = null;\n const onMessage = (event: MessageEvent<unknown>) => {\n if (\n event.source !== parentWindow ||\n !isOpenGeniSiteBridgeReadyMessage(event.data) ||\n event.ports.length !== 1\n ) {\n return;\n }\n cleanup();\n settledPort = event.ports[0]!;\n settledPort.start();\n retainSiteBridgeBootstrapPort(siteWindow, settledPort);\n resolveBootstrap?.(settledPort);\n };\n let resolveBootstrap: ((port: MessagePort) => void) | null = null;\n const cleanup = () => siteWindow.removeEventListener(\"message\", onMessage as EventListener);\n const port = new Promise<MessagePort>((resolve, reject) => {\n resolveBootstrap = resolve;\n rejectBootstrap = reject;\n siteWindow.addEventListener(\"message\", onMessage as EventListener);\n });\n void port.catch(() => undefined);\n return {\n port: async () => await port,\n close: () => {\n cleanup();\n rejectBootstrap?.(new OpenGeniSiteBridgeError(\"closed\", \"Site bridge is closed\"));\n resolveBootstrap = null;\n rejectBootstrap = null;\n },\n };\n}\n\nfunction retainedSiteBridgeBootstrapPort(\n siteWindow: OpenGeniSiteClientOptions[\"siteWindow\"],\n): MessagePort | null {\n const state = (siteWindow as unknown as Record<string, unknown>)[\n OPENGENI_SITE_BRIDGE_BOOTSTRAP_GLOBAL\n ];\n if (!isRecord(state)) return null;\n const candidate = state.port as Partial<MessagePort> | undefined;\n return candidate &&\n typeof candidate.postMessage === \"function\" &&\n typeof candidate.addEventListener === \"function\" &&\n typeof candidate.start === \"function\"\n ? (candidate as MessagePort)\n : null;\n}\n\nfunction retainSiteBridgeBootstrapPort(\n siteWindow: OpenGeniSiteClientOptions[\"siteWindow\"],\n port: MessagePort,\n): void {\n try {\n Object.defineProperty(siteWindow, OPENGENI_SITE_BRIDGE_BOOTSTRAP_GLOBAL, {\n configurable: true,\n value: { port },\n });\n } catch {\n // The bootstrap event still serves the current client when the embedding\n // window refuses extension; only late construction loses this fallback.\n }\n}\n\nfunction isOpenGeniSiteBridgeReadyMessage(value: unknown): value is OpenGeniSiteBridgeReadyMessage {\n return (\n isRecord(value) &&\n value.type === OPENGENI_SITE_BRIDGE_READY &&\n value.version === OPENGENI_SITE_BRIDGE_VERSION\n );\n}\n\nfunction cancel(port: MessagePort, requestId: string): void {\n port.postMessage({\n type: OPENGENI_SITE_BRIDGE_CANCEL,\n version: OPENGENI_SITE_BRIDGE_VERSION,\n requestId,\n } satisfies OpenGeniSiteBridgeCancelMessage);\n}\n\nfunction positiveTimeout(value: number, label: string): number {\n if (!Number.isFinite(value) || value <= 0) throw new RangeError(`${label} must be positive`);\n return value;\n}\n\nfunction isRecord(value: unknown): value is Record<string, any> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAM,wBAAwB;AAGvB,IAAM,uBAAN,cAAmC,MAAM;AAAA,EACrC,OAAO;AAAA,EAEhB,cAAc;AACZ,UAAM,mCAAmC;AACzC,SAAK,OAAO;AAAA,EACd;AACF;AAKO,SAAS,gBACd,MACA,aACA,UAAU,OACV,QACQ;AACR,QAAM,WAAW,KAAK,MAAM,GAAG,EAAE,CAAC;AAClC,QAAM,YACJ,aAAa,yBAAyB,SAAS,WAAW,GAAG,qBAAqB,GAAG;AACvF,QAAM,UAAU,aAAa;AAC7B,MACG,CAAC,aAAa,CAAC,WAChB,6BAA6B,KAAK,QAAQ,KAC1C,SAAS,MAAM,GAAG,EAAE,KAAK,CAAC,MAAM,MAAM,OAAO,MAAM,IAAI,GACvD;AACA,UAAM,IAAI,qBAAqB;AAAA,EACjC;AACA,QAAM,YAAY,KAAK;AAAA,IACrB;AAAA,IACA,eAAe,mBAAmB,WAAW,CAAC;AAAA,EAChD;AAEA,QAAM,MAAM,IAAI,IAAI,WAAW,qBAAqB;AACpD,MAAI,IAAI,aAAa,IAAI,cAAc,MAAM,aAAa,gBAAgB,aAAa;AACrF,QAAI,aAAa,IAAI,gBAAgB,UAAU,sCAAsC;AACrF,WAAO,IAAI,WA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wBAAkB;AAAA,IACpB;AAAA,EACF;AACF;AAEA,SAAS,gCACP,YACoB;AACpB,QAAM,QAAS,WACb,qCACF;AACA,MAAI,CAAC,SAAS,KAAK,EAAG,QAAO;AAC7B,QAAM,YAAY,MAAM;AACxB,SAAO,aACL,OAAO,UAAU,gBAAgB,cACjC,OAAO,UAAU,qBAAqB,cACtC,OAAO,UAAU,UAAU,aACxB,YACD;AACN;AAEA,SAAS,8BACP,YACA,MACM;AACN,MAAI;AACF,WAAO,eAAe,YAAY,uCAAuC;AAAA,MACvE,cAAc;AAAA,MACd,OAAO,EAAE,KAAK;AAAA,IAChB,CAAC;AAAA,EACH,QAAQ;AAAA,EAGR;AACF;AAEA,SAAS,iCAAiC,OAAyD;AACjG,SACE,SAAS,KAAK,KACd,MAAM,SAAS,8BACf,MAAM,YAAY;AAEtB;AAEA,SAAS,OAAO,MAAmB,WAAyB;AAC1D,OAAK,YAAY;AAAA,IACf,MAAM;AAAA,IACN,SAAS;AAAA,IACT;AAAA,EACF,CAA2C;AAC7C;AAEA,SAAS,gBAAgB,OAAe,OAAuB;AAC7D,MAAI,CAAC,OAAO,SAAS,KAAK,KAAK,SAAS,EAAG,OAAM,IAAI,WAAW,GAAG,KAAK,mBAAmB;AAC3F,SAAO;AACT;AAEA,SAAS,SAAS,OAA8C;AAC9D,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;","names":[]}
@@ -0,0 +1,195 @@
1
+ import {
2
+ OpenGeniClient
3
+ } from "./chunk-TOB3B4ZJ.js";
4
+
5
+ // src/embedding-client.ts
6
+ var OpenGeniEmbeddingClient = class extends OpenGeniClient {
7
+ /** Server-side organization-key client scoped to one host-authenticated user.
8
+ * Does not mutate this client, provision workspace membership, or link native
9
+ * identities. The API verifies key and membership authority on each request. */
10
+ asUser(externalId, options = {}) {
11
+ if (typeof window !== "undefined")
12
+ throw new Error("asUser is a server-side API; keep organization keys on your backend");
13
+ const source = options.source ?? "default";
14
+ const validOpaqueText = (value, maxBytes) => typeof value === "string" && value.length > 0 && value.length <= maxBytes && !value.includes("\0") && !/[\uD800-\uDFFF]/u.test(value) && new TextEncoder().encode(value).byteLength <= maxBytes;
15
+ if (!validOpaqueText(externalId, 1024) || !validOpaqueText(source, 200)) {
16
+ throw new Error("Invalid external identity reference");
17
+ }
18
+ const Client = this.constructor;
19
+ const client = new Client({ ...this.options });
20
+ client.externalActorHeader = encodeURIComponent(
21
+ JSON.stringify({ mode: "external", identity: { externalId, source } })
22
+ );
23
+ return client;
24
+ }
25
+ /** Explicitly use a confirmed native delegation. Unlike asUser, new resources
26
+ * belong to the native user. Existing external resources are never reassigned.
27
+ * A stale, expired or revoked link is rejected by the server on every request. */
28
+ asLinkedUser(externalId, options) {
29
+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(options.linkId) || !Number.isSafeInteger(options.expectedLinkRevision) || options.expectedLinkRevision < 1)
30
+ throw new Error("A confirmed identity link and its exact revision are required");
31
+ const client = this.asUser(
32
+ externalId,
33
+ options.source === void 0 ? {} : { source: options.source }
34
+ );
35
+ const identity = JSON.parse(decodeURIComponent(client.externalActorHeader)).identity;
36
+ client.externalActorHeader = encodeURIComponent(
37
+ JSON.stringify({
38
+ mode: "linked_native",
39
+ identity,
40
+ linkId: options.linkId,
41
+ expectedLinkRevision: options.expectedLinkRevision
42
+ })
43
+ );
44
+ return client;
45
+ }
46
+ /** Optional native-account delegation. Invoke on a server-side asUser client.
47
+ * Pass the one-time challenge to the native consent screen, never a URL query
48
+ * or analytics event. Ordinary external embedding needs none of this. */
49
+ async beginIdentityLink(workspaceId, input) {
50
+ return this.requestJson(
51
+ "POST",
52
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links`,
53
+ input
54
+ );
55
+ }
56
+ async getIdentityLink(workspaceId, linkId) {
57
+ return this.requestJson(
58
+ "GET",
59
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links/${encodeURIComponent(linkId)}`
60
+ );
61
+ }
62
+ /** Only links belonging to the effective participant; no organization-wide directory. */
63
+ async listIdentityLinks(workspaceId, cursor) {
64
+ return this.requestJson(
65
+ "GET",
66
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links${cursor ? `?cursor=${encodeURIComponent(cursor)}` : ""}`
67
+ );
68
+ }
69
+ /** Requires a canonical native browser session, not an organization API key. */
70
+ async previewIdentityLink(workspaceId, linkId, challenge) {
71
+ return this.requestJson(
72
+ "POST",
73
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links/${encodeURIComponent(linkId)}/preview`,
74
+ { challenge }
75
+ );
76
+ }
77
+ async confirmIdentityLink(workspaceId, linkId, input) {
78
+ return this.requestJson(
79
+ "POST",
80
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links/${encodeURIComponent(linkId)}/confirm`,
81
+ input
82
+ );
83
+ }
84
+ async revokeIdentityLink(workspaceId, linkId, expectedRevision) {
85
+ return this.requestJson(
86
+ "POST",
87
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links/${encodeURIComponent(linkId)}/revoke`,
88
+ { expectedRevision }
89
+ );
90
+ }
91
+ /** Service-only lifecycle for an external actor's organization membership.
92
+ * A successful reactivation does not restore revoked workspace grants. */
93
+ async updateExternalIdentityMembership(organizationId, membershipId, request, options = {}) {
94
+ return this.requestJson(
95
+ "PATCH",
96
+ `/v1/organizations/${encodeURIComponent(organizationId)}/external-members/${encodeURIComponent(membershipId)}`,
97
+ request,
98
+ void 0,
99
+ options
100
+ );
101
+ }
102
+ async listConnectProviders(workspaceId) {
103
+ return this.requestJson("GET", `/v1/workspaces/${workspaceId}/connect/catalog`);
104
+ }
105
+ /** Register credential-free, external-owner host authority. Does not itself
106
+ * authorize an execution or install MCP tools. */
107
+ async createHostMcpBinding(workspaceId, request, options = {}) {
108
+ return this.requestJson(
109
+ "POST",
110
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-bindings`,
111
+ request,
112
+ {},
113
+ options
114
+ );
115
+ }
116
+ async getHostMcpBinding(workspaceId, bindingId, options = {}) {
117
+ return this.requestJson(
118
+ "GET",
119
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-bindings/${encodeURIComponent(bindingId)}`,
120
+ void 0,
121
+ {},
122
+ options
123
+ );
124
+ }
125
+ async revokeHostMcpBinding(workspaceId, bindingId, request, options = {}) {
126
+ return this.requestJson(
127
+ "POST",
128
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-bindings/${encodeURIComponent(bindingId)}/revoke`,
129
+ request,
130
+ {},
131
+ options
132
+ );
133
+ }
134
+ /** Issue owner-scoped grant metadata; accepted execution must separately admit it. */
135
+ async issueHostMcpDelegation(workspaceId, request, options = {}) {
136
+ return this.requestJson(
137
+ "POST",
138
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-delegations`,
139
+ request,
140
+ {},
141
+ options
142
+ );
143
+ }
144
+ async getHostMcpDelegation(workspaceId, delegationId, options = {}) {
145
+ return this.requestJson(
146
+ "GET",
147
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-delegations/${encodeURIComponent(delegationId)}`,
148
+ void 0,
149
+ {},
150
+ options
151
+ );
152
+ }
153
+ async revokeHostMcpDelegation(workspaceId, delegationId, request, options = {}) {
154
+ return this.requestJson(
155
+ "POST",
156
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-delegations/${encodeURIComponent(delegationId)}/revoke`,
157
+ request,
158
+ {},
159
+ options
160
+ );
161
+ }
162
+ async listConnectAccounts(workspaceId) {
163
+ return this.requestJson("GET", `/v1/workspaces/${workspaceId}/connect/accounts`);
164
+ }
165
+ async getConnectAttempt(workspaceId, attemptId) {
166
+ return this.requestJson("GET", `/v1/workspaces/${workspaceId}/connect/attempts/${attemptId}`);
167
+ }
168
+ async listPendingConnectAttempts(workspaceId) {
169
+ return this.requestJson("GET", `/v1/workspaces/${workspaceId}/connect/attempts`);
170
+ }
171
+ async advanceConnectAttempt(workspaceId, attemptId, request) {
172
+ return this.requestJson(
173
+ "POST",
174
+ `/v1/workspaces/${workspaceId}/connect/attempts/${attemptId}/advance`,
175
+ request
176
+ );
177
+ }
178
+ /** Stops setup; does not revoke already committed provider credentials. */
179
+ async cancelConnectAttempt(workspaceId, attemptId, request) {
180
+ return this.requestJson(
181
+ "POST",
182
+ `/v1/workspaces/${workspaceId}/connect/attempts/${attemptId}/cancel`,
183
+ request
184
+ );
185
+ }
186
+ /** Explicit organization-service-key onboarding; asUser never grants membership. */
187
+ async addExternalWorkspaceMember(workspaceId, request) {
188
+ return this.requestJson("POST", `/v1/workspaces/${workspaceId}/external-members`, request);
189
+ }
190
+ };
191
+
192
+ export {
193
+ OpenGeniEmbeddingClient
194
+ };
195
+ //# sourceMappingURL=chunk-J5USCWPE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/embedding-client.ts"],"sourcesContent":["import { OpenGeniClient as OpenGeniArtifactClient } from \"./artifact-client\";\nimport type { OpenGeniClientOptions, OpenGeniRequestOptions } from \"./client\";\nimport type { AddWorkspaceMemberRequest } from \"./types\";\nimport type {\n ExternalIdentityLink,\n BeginExternalIdentityLinkRequest,\n BeginExternalIdentityLinkResponse,\n ConfirmExternalIdentityLinkRequest,\n ExternalIdentityLinkPreview,\n ExternalIdentityLinkPage,\n} from \"@opengeni/contracts/external-identities\";\n\n/** Public product embedding administration, kept out of the native browser client. */\nexport class OpenGeniEmbeddingClient extends OpenGeniArtifactClient {\n /** Server-side organization-key client scoped to one host-authenticated user.\n * Does not mutate this client, provision workspace membership, or link native\n * identities. The API verifies key and membership authority on each request. */\n asUser(externalId: string, options: { source?: string } = {}): this {\n if (typeof window !== \"undefined\")\n throw new Error(\"asUser is a server-side API; keep organization keys on your backend\");\n const source = options.source ?? \"default\";\n const validOpaqueText = (value: unknown, maxBytes: number): value is string =>\n typeof value === \"string\" &&\n value.length > 0 &&\n value.length <= maxBytes &&\n !value.includes(\"\\0\") &&\n !/[\\uD800-\\uDFFF]/u.test(value) &&\n new TextEncoder().encode(value).byteLength <= maxBytes;\n if (!validOpaqueText(externalId, 1024) || !validOpaqueText(source, 200)) {\n throw new Error(\"Invalid external identity reference\");\n }\n const Client = this.constructor as new (options: OpenGeniClientOptions) => this;\n const client = new Client({ ...this.options });\n client.externalActorHeader = encodeURIComponent(\n JSON.stringify({ mode: \"external\", identity: { externalId, source } }),\n );\n return client;\n }\n\n /** Explicitly use a confirmed native delegation. Unlike asUser, new resources\n * belong to the native user. Existing external resources are never reassigned.\n * A stale, expired or revoked link is rejected by the server on every request. */\n asLinkedUser(\n externalId: string,\n options: { source?: string; linkId: string; expectedLinkRevision: number },\n ): this {\n if (\n !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(options.linkId) ||\n !Number.isSafeInteger(options.expectedLinkRevision) ||\n options.expectedLinkRevision < 1\n )\n throw new Error(\"A confirmed identity link and its exact revision are required\");\n const client = this.asUser(\n externalId,\n options.source === undefined ? {} : { source: options.source },\n );\n const identity = JSON.parse(decodeURIComponent(client.externalActorHeader!)).identity;\n client.externalActorHeader = encodeURIComponent(\n JSON.stringify({\n mode: \"linked_native\",\n identity,\n linkId: options.linkId,\n expectedLinkRevision: options.expectedLinkRevision,\n }),\n );\n return client;\n }\n\n /** Optional native-account delegation. Invoke on a server-side asUser client.\n * Pass the one-time challenge to the native consent screen, never a URL query\n * or analytics event. Ordinary external embedding needs none of this. */\n async beginIdentityLink(\n workspaceId: string,\n input: BeginExternalIdentityLinkRequest,\n ): Promise<BeginExternalIdentityLinkResponse> {\n return this.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links`,\n input,\n );\n }\n\n async getIdentityLink(workspaceId: string, linkId: string): Promise<ExternalIdentityLink> {\n return this.requestJson(\n \"GET\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links/${encodeURIComponent(linkId)}`,\n );\n }\n\n /** Only links belonging to the effective participant; no organization-wide directory. */\n async listIdentityLinks(workspaceId: string, cursor?: string): Promise<ExternalIdentityLinkPage> {\n return this.requestJson(\n \"GET\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links${cursor ? `?cursor=${encodeURIComponent(cursor)}` : \"\"}`,\n );\n }\n\n /** Requires a canonical native browser session, not an organization API key. */\n async previewIdentityLink(\n workspaceId: string,\n linkId: string,\n challenge: string,\n ): Promise<ExternalIdentityLinkPreview> {\n return this.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links/${encodeURIComponent(linkId)}/preview`,\n { challenge },\n );\n }\n\n async confirmIdentityLink(\n workspaceId: string,\n linkId: string,\n input: ConfirmExternalIdentityLinkRequest,\n ): Promise<ExternalIdentityLink> {\n return this.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links/${encodeURIComponent(linkId)}/confirm`,\n input,\n );\n }\n\n async revokeIdentityLink(\n workspaceId: string,\n linkId: string,\n expectedRevision: number,\n ): Promise<ExternalIdentityLink> {\n return this.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links/${encodeURIComponent(linkId)}/revoke`,\n { expectedRevision },\n );\n }\n\n /** Service-only lifecycle for an external actor's organization membership.\n * A successful reactivation does not restore revoked workspace grants. */\n async updateExternalIdentityMembership(\n organizationId: string,\n membershipId: string,\n request: import(\"@opengeni/contracts/external-identities\").UpdateExternalIdentityMembershipRequest,\n options: { signal?: AbortSignal } = {},\n ): Promise<import(\"@opengeni/contracts\").OrganizationMember> {\n return this.requestJson(\n \"PATCH\",\n `/v1/organizations/${encodeURIComponent(organizationId)}/external-members/${encodeURIComponent(membershipId)}`,\n request,\n undefined,\n options,\n );\n }\n\n async listConnectProviders(\n workspaceId: string,\n ): Promise<import(\"@opengeni/contracts/connect\").ConnectProvider[]> {\n return this.requestJson(\"GET\", `/v1/workspaces/${workspaceId}/connect/catalog`);\n }\n\n /** Register credential-free, external-owner host authority. Does not itself\n * authorize an execution or install MCP tools. */\n async createHostMcpBinding(\n workspaceId: string,\n request: import(\"@opengeni/contracts/host-mcp-bindings\").CreateHostMcpBindingRequest,\n options: OpenGeniRequestOptions = {},\n ): Promise<import(\"@opengeni/contracts/host-mcp-bindings\").HostMcpBinding> {\n return this.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-bindings`,\n request,\n {},\n options,\n );\n }\n\n async getHostMcpBinding(\n workspaceId: string,\n bindingId: string,\n options: OpenGeniRequestOptions = {},\n ): Promise<import(\"@opengeni/contracts/host-mcp-bindings\").HostMcpBinding> {\n return this.requestJson(\n \"GET\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-bindings/${encodeURIComponent(bindingId)}`,\n undefined,\n {},\n options,\n );\n }\n\n async revokeHostMcpBinding(\n workspaceId: string,\n bindingId: string,\n request: { expectedGeneration: number },\n options: OpenGeniRequestOptions = {},\n ): Promise<import(\"@opengeni/contracts/host-mcp-bindings\").HostMcpBinding> {\n return this.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-bindings/${encodeURIComponent(bindingId)}/revoke`,\n request,\n {},\n options,\n );\n }\n\n /** Issue owner-scoped grant metadata; accepted execution must separately admit it. */\n async issueHostMcpDelegation(\n workspaceId: string,\n request: import(\"@opengeni/contracts/host-mcp-bindings\").IssueHostMcpDelegationRequest,\n options: OpenGeniRequestOptions = {},\n ): Promise<import(\"@opengeni/contracts/host-mcp-bindings\").HostMcpDelegation> {\n return this.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-delegations`,\n request,\n {},\n options,\n );\n }\n\n async getHostMcpDelegation(\n workspaceId: string,\n delegationId: string,\n options: OpenGeniRequestOptions = {},\n ): Promise<import(\"@opengeni/contracts/host-mcp-bindings\").HostMcpDelegation> {\n return this.requestJson(\n \"GET\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-delegations/${encodeURIComponent(delegationId)}`,\n undefined,\n {},\n options,\n );\n }\n\n async revokeHostMcpDelegation(\n workspaceId: string,\n delegationId: string,\n request: { expectedGeneration: number },\n options: OpenGeniRequestOptions = {},\n ): Promise<import(\"@opengeni/contracts/host-mcp-bindings\").HostMcpDelegation> {\n return this.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-delegations/${encodeURIComponent(delegationId)}/revoke`,\n request,\n {},\n options,\n );\n }\n\n async listConnectAccounts(\n workspaceId: string,\n ): Promise<import(\"@opengeni/contracts/connect\").ConnectAccount[]> {\n return this.requestJson(\"GET\", `/v1/workspaces/${workspaceId}/connect/accounts`);\n }\n\n async getConnectAttempt(\n workspaceId: string,\n attemptId: string,\n ): Promise<import(\"@opengeni/contracts/connect\").ConnectAttempt> {\n return this.requestJson(\"GET\", `/v1/workspaces/${workspaceId}/connect/attempts/${attemptId}`);\n }\n\n async listPendingConnectAttempts(\n workspaceId: string,\n ): Promise<import(\"@opengeni/contracts/connect\").ConnectAttempt[]> {\n return this.requestJson(\"GET\", `/v1/workspaces/${workspaceId}/connect/attempts`);\n }\n\n async advanceConnectAttempt(\n workspaceId: string,\n attemptId: string,\n request: {\n expectedRevision: number;\n idempotencyKey: string;\n action: import(\"@opengeni/contracts/connect\").ConnectAdvance;\n },\n ): Promise<import(\"@opengeni/contracts/connect\").ConnectAttempt> {\n return this.requestJson(\n \"POST\",\n `/v1/workspaces/${workspaceId}/connect/attempts/${attemptId}/advance`,\n request,\n );\n }\n\n /** Stops setup; does not revoke already committed provider credentials. */\n async cancelConnectAttempt(\n workspaceId: string,\n attemptId: string,\n request: {\n expectedRevision: number;\n idempotencyKey: string;\n },\n ): Promise<import(\"@opengeni/contracts/connect\").ConnectAttempt> {\n return this.requestJson(\n \"POST\",\n `/v1/workspaces/${workspaceId}/connect/attempts/${attemptId}/cancel`,\n request,\n );\n }\n\n /** Explicit organization-service-key onboarding; asUser never grants membership. */\n async addExternalWorkspaceMember(\n workspaceId: string,\n request: {\n identity: { externalId: string; source?: string };\n permissions: AddWorkspaceMemberRequest[\"permissions\"];\n },\n ): Promise<import(\"@opengeni/contracts/external-identities\").ExternalIdentity> {\n return this.requestJson(\"POST\", `/v1/workspaces/${workspaceId}/external-members`, request);\n }\n}\n"],"mappings":";;;;;AAaO,IAAM,0BAAN,cAAsC,eAAuB;AAAA;AAAA;AAAA;AAAA,EAIlE,OAAO,YAAoB,UAA+B,CAAC,GAAS;AAClE,QAAI,OAAO,WAAW;AACpB,YAAM,IAAI,MAAM,qEAAqE;AACvF,UAAM,SAAS,QAAQ,UAAU;AACjC,UAAM,kBAAkB,CAAC,OAAgB,aACvC,OAAO,UAAU,YACjB,MAAM,SAAS,KACf,MAAM,UAAU,YAChB,CAAC,MAAM,SAAS,IAAI,KACpB,CAAC,mBAAmB,KAAK,KAAK,KAC9B,IAAI,YAAY,EAAE,OAAO,KAAK,EAAE,cAAc;AAChD,QAAI,CAAC,gBAAgB,YAAY,IAAI,KAAK,CAAC,gBAAgB,QAAQ,GAAG,GAAG;AACvE,YAAM,IAAI,MAAM,qCAAqC;AAAA,IACvD;AACA,UAAM,SAAS,KAAK;AACpB,UAAM,SAAS,IAAI,OAAO,EAAE,GAAG,KAAK,QAAQ,CAAC;AAC7C,WAAO,sBAAsB;AAAA,MAC3B,KAAK,UAAU,EAAE,MAAM,YAAY,UAAU,EAAE,YAAY,OAAO,EAAE,CAAC;AAAA,IACvE;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,aACE,YACA,SACM;AACN,QACE,CAAC,kEAAkE,KAAK,QAAQ,MAAM,KACtF,CAAC,OAAO,cAAc,QAAQ,oBAAoB,KAClD,QAAQ,uBAAuB;AAE/B,YAAM,IAAI,MAAM,+DAA+D;AACjF,UAAM,SAAS,KAAK;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AO;AAAA,EAC3F;AACF;","names":[]}
@@ -239,4 +239,4 @@ export {
239
239
  GENERATED_VIDEO_MAX_BYTES,
240
240
  KNOWN_USAGE_EVENT_TYPES
241
241
  };
242
- //# sourceMappingURL=chunk-WNEGCYCE.js.map
242
+ //# sourceMappingURL=chunk-TARU5CD2.js.map