@opengeni/sdk 3.3.2 → 3.7.0-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 (76) hide show
  1. package/README.md +80 -6
  2. package/dist/artifact-client.d.ts +4 -2
  3. package/dist/artifacts.d.ts +1 -1
  4. package/dist/artifacts.js +6 -6
  5. package/dist/browser.d.ts +5 -2
  6. package/dist/browser.js +14 -4
  7. package/dist/{chunk-YXQX7RQT.js → chunk-2E2BFEEN.js} +2 -2
  8. package/dist/{chunk-JUS2UYRP.js → chunk-3QDQTYOE.js} +3 -1
  9. package/dist/chunk-3QDQTYOE.js.map +1 -0
  10. package/dist/{chunk-C2H7HBNP.js → chunk-7S2MZ65L.js} +6 -6
  11. package/dist/chunk-FMLDFJ2Q.js +246 -0
  12. package/dist/chunk-FMLDFJ2Q.js.map +1 -0
  13. package/dist/{chunk-TRNI7KEO.js → chunk-IQTEPOI3.js} +228 -26
  14. package/dist/chunk-IQTEPOI3.js.map +1 -0
  15. package/dist/chunk-IRAEPLXG.js +350 -0
  16. package/dist/chunk-IRAEPLXG.js.map +1 -0
  17. package/dist/{chunk-QT3KFVDP.js → chunk-MPGVC7EO.js} +10 -2
  18. package/dist/chunk-MPGVC7EO.js.map +1 -0
  19. package/dist/{chunk-C4DJPZRU.js → chunk-OO5LPTO7.js} +14 -1
  20. package/dist/chunk-OO5LPTO7.js.map +1 -0
  21. package/dist/{chunk-KKRO2VCP.js → chunk-QTBAMHEF.js} +2 -2
  22. package/dist/client.d.ts +51 -11
  23. package/dist/codex-realtime-controller.js +2 -2
  24. package/dist/core.d.ts +5 -2
  25. package/dist/core.js +17 -7
  26. package/dist/document-authority.js +5 -5
  27. package/dist/editable-artifacts.js +4 -4
  28. package/dist/errors.d.ts +12 -0
  29. package/dist/github-repositories.d.ts +10 -0
  30. package/dist/github-repositories.js +36 -0
  31. package/dist/github-repositories.js.map +1 -0
  32. package/dist/index.d.ts +13 -6
  33. package/dist/index.js +99 -52
  34. package/dist/index.js.map +1 -1
  35. package/dist/interaction.js +2 -2
  36. package/dist/model-context.d.ts +49 -0
  37. package/dist/model-picker-order.d.ts +1 -0
  38. package/dist/model-picker-order.js +10 -0
  39. package/dist/model-picker-order.js.map +1 -0
  40. package/dist/proxy.d.ts +7 -5
  41. package/dist/realtime.js +2 -2
  42. package/dist/session-titles.d.ts +2 -28
  43. package/dist/site.d.ts +93 -0
  44. package/dist/site.js +35 -0
  45. package/dist/site.js.map +1 -0
  46. package/dist/stream.d.ts +2 -0
  47. package/dist/tools-FSTY4FAY.js +12 -0
  48. package/dist/tools-FSTY4FAY.js.map +1 -0
  49. package/dist/tools.d.ts +61 -0
  50. package/dist/types.d.ts +231 -9
  51. package/dist/workspace-artifacts.d.ts +26 -1
  52. package/package.json +14 -2
  53. package/src/artifact-client.ts +16 -1
  54. package/src/artifacts.ts +1 -0
  55. package/src/browser.ts +16 -0
  56. package/src/client.ts +332 -22
  57. package/src/core.ts +16 -0
  58. package/src/errors.ts +23 -0
  59. package/src/github-repositories.ts +60 -0
  60. package/src/index.ts +94 -1
  61. package/src/model-context.ts +69 -0
  62. package/src/model-picker-order.ts +6 -0
  63. package/src/proxy.ts +17 -6
  64. package/src/session-titles.ts +8 -82
  65. package/src/site.ts +544 -0
  66. package/src/stream.ts +29 -8
  67. package/src/tools.ts +396 -0
  68. package/src/types.ts +287 -10
  69. package/src/workspace-artifacts.ts +33 -2
  70. package/dist/chunk-C4DJPZRU.js.map +0 -1
  71. package/dist/chunk-JUS2UYRP.js.map +0 -1
  72. package/dist/chunk-QT3KFVDP.js.map +0 -1
  73. package/dist/chunk-TRNI7KEO.js.map +0 -1
  74. /package/dist/{chunk-YXQX7RQT.js.map → chunk-2E2BFEEN.js.map} +0 -0
  75. /package/dist/{chunk-C2H7HBNP.js.map → chunk-7S2MZ65L.js.map} +0 -0
  76. /package/dist/{chunk-KKRO2VCP.js.map → chunk-QTBAMHEF.js.map} +0 -0
@@ -0,0 +1,350 @@
1
+ import {
2
+ OpenGeniToolsClient
3
+ } from "./chunk-FMLDFJ2Q.js";
4
+
5
+ // src/site.ts
6
+ var OPENGENI_SITE_BRIDGE_VERSION = 2;
7
+ var OPENGENI_SITE_BRIDGE_CONNECT = "opengeni.site.connect";
8
+ var OPENGENI_SITE_BRIDGE_READY = "opengeni.site.ready";
9
+ var OPENGENI_SITE_BRIDGE_REQUEST = "opengeni.site.request";
10
+ var OPENGENI_SITE_BRIDGE_RESPONSE = "opengeni.site.response";
11
+ var OPENGENI_SITE_BRIDGE_CANCEL = "opengeni.site.cancel";
12
+ var OPENGENI_SITE_BRIDGE_BOOTSTRAP_GLOBAL = "__opengeniSiteBridgeBootstrapV2";
13
+ var OPENGENI_SITE_LOCAL_CODEMODE_PATH = "/__opengeni/site-tools";
14
+ var OpenGeniSiteBridgeError = class extends Error {
15
+ constructor(code, message, retryable = false, outcomeUnknown = false) {
16
+ super(message);
17
+ this.code = code;
18
+ this.retryable = retryable;
19
+ this.outcomeUnknown = outcomeUnknown;
20
+ this.name = "OpenGeniSiteBridgeError";
21
+ }
22
+ };
23
+ function createOpenGeniSiteClient(options = {}) {
24
+ const transport = shouldUseLocalCodemode(options) ? new OpenGeniSiteLocalCodemodeTransport(options) : new OpenGeniSiteBridgeTransport(options);
25
+ return {
26
+ tools: new OpenGeniToolsClient(transport).forWorkspace("site-host"),
27
+ close: () => transport.close()
28
+ };
29
+ }
30
+ var OpenGeniSiteLocalCodemodeTransport = class {
31
+ fetchImpl;
32
+ basePath;
33
+ constructor(options) {
34
+ this.fetchImpl = options.fetch ?? globalThis.fetch.bind(globalThis);
35
+ const configured = options.localCodemodePath;
36
+ this.basePath = (typeof configured === "string" ? configured : OPENGENI_SITE_LOCAL_CODEMODE_PATH).replace(/\/+$/u, "");
37
+ }
38
+ close() {
39
+ }
40
+ async requestJson(method, path, body, _query, options = {}) {
41
+ const suffix = localCodemodeSuffix(method, path);
42
+ const response = await this.fetchImpl(`${this.basePath}${suffix}`, {
43
+ method,
44
+ ...options.signal ? { signal: options.signal } : {},
45
+ ...body === void 0 ? {} : {
46
+ headers: { "content-type": "application/json" },
47
+ body: JSON.stringify(body)
48
+ }
49
+ });
50
+ const value = await response.json();
51
+ if (response.ok) return value;
52
+ const envelope = isRecord(value) && isRecord(value.error) ? value.error : {};
53
+ throw new OpenGeniSiteBridgeError(
54
+ typeof envelope.code === "string" ? envelope.code : "local_codemode_error",
55
+ typeof envelope.message === "string" ? envelope.message : `Local Site tool request failed with HTTP ${response.status}`,
56
+ envelope.retryable === true,
57
+ envelope.outcomeUnknown === true
58
+ );
59
+ }
60
+ };
61
+ function shouldUseLocalCodemode(options) {
62
+ if (options.localCodemodePath === false || options.bootstrapPort) return false;
63
+ if (typeof options.localCodemodePath === "string") return true;
64
+ const siteWindow = options.siteWindow ?? globalThis.window;
65
+ return Boolean(siteWindow && siteWindow.parent === siteWindow);
66
+ }
67
+ function localCodemodeSuffix(method, path) {
68
+ if (method === "GET" && path.endsWith("/tools/catalog")) return "/catalog";
69
+ if (method === "GET" && path.endsWith("/tools/declarations")) return "/declarations";
70
+ if (method === "POST" && path.endsWith("/tools/calls")) return "/calls";
71
+ throw new OpenGeniSiteBridgeError("unsupported_request", "Unsupported Site tool request");
72
+ }
73
+ function isOpenGeniSiteBridgeConnectMessage(value) {
74
+ return isRecord(value) && value.type === OPENGENI_SITE_BRIDGE_CONNECT && value.version === OPENGENI_SITE_BRIDGE_VERSION;
75
+ }
76
+ function isOpenGeniSiteBridgeRequestMessage(value) {
77
+ if (!isRecord(value) || value.type !== OPENGENI_SITE_BRIDGE_REQUEST || value.version !== OPENGENI_SITE_BRIDGE_VERSION || typeof value.requestId !== "string" || !value.requestId) {
78
+ return false;
79
+ }
80
+ if (value.method === "catalog" || value.method === "declarations") return true;
81
+ return value.method === "call" && isRecord(value.payload);
82
+ }
83
+ function isOpenGeniSiteBridgeCancelMessage(value) {
84
+ return isRecord(value) && value.type === OPENGENI_SITE_BRIDGE_CANCEL && value.version === OPENGENI_SITE_BRIDGE_VERSION && typeof value.requestId === "string" && Boolean(value.requestId);
85
+ }
86
+ function sanitizeOpenGeniSiteToolCallRequest(value) {
87
+ return {
88
+ ...value.operationId === void 0 ? {} : { operationId: value.operationId },
89
+ catalogDigest: value.catalogDigest,
90
+ identity: value.identity,
91
+ arguments: value.arguments
92
+ };
93
+ }
94
+ var OpenGeniSiteBridgeTransport = class {
95
+ options;
96
+ bootstrap;
97
+ port = null;
98
+ connecting = null;
99
+ closed = false;
100
+ constructor(options) {
101
+ this.options = options;
102
+ this.bootstrap = createSiteBridgeBootstrap(options);
103
+ }
104
+ async requestJson(method, path, body, _query, requestOptions = {}) {
105
+ if (method === "GET" && path.endsWith("/tools/catalog")) {
106
+ return await this.request({ method: "catalog" }, requestOptions);
107
+ }
108
+ if (method === "GET" && path.endsWith("/tools/declarations")) {
109
+ return await this.request({ method: "declarations" }, requestOptions);
110
+ }
111
+ if (method === "POST" && path.endsWith("/tools/calls")) {
112
+ if (!isRecord(body)) throw new TypeError("Site tool call payload is required");
113
+ return await this.request(
114
+ {
115
+ method: "call",
116
+ payload: sanitizeOpenGeniSiteToolCallRequest(body)
117
+ },
118
+ requestOptions
119
+ );
120
+ }
121
+ throw new OpenGeniSiteBridgeError("unsupported_request", "Unsupported Site bridge request");
122
+ }
123
+ close() {
124
+ if (this.closed) return;
125
+ this.closed = true;
126
+ this.bootstrap.close();
127
+ this.port?.close();
128
+ this.port = null;
129
+ }
130
+ async request(request, options) {
131
+ const port = await this.connect();
132
+ const requestId = crypto.randomUUID();
133
+ const timeoutMs = positiveTimeout(
134
+ options.timeoutMs ?? this.options.requestTimeoutMs ?? 12e4,
135
+ "requestTimeoutMs"
136
+ );
137
+ return await new Promise((resolve, reject) => {
138
+ const timeout = setTimeout(() => {
139
+ cleanup();
140
+ cancel(port, requestId);
141
+ reject(
142
+ request.method === "call" ? new OpenGeniSiteBridgeError(
143
+ "timeout",
144
+ "Site tool request timed out after execution may have started",
145
+ false,
146
+ true
147
+ ) : new OpenGeniSiteBridgeError("timeout", "Site tool request timed out", true)
148
+ );
149
+ }, timeoutMs);
150
+ const abort = () => {
151
+ cleanup();
152
+ cancel(port, requestId);
153
+ reject(options.signal?.reason ?? new DOMException("Request aborted", "AbortError"));
154
+ };
155
+ const onMessage = (event) => {
156
+ const response = event.data;
157
+ if (!isRecord(response) || response.type !== OPENGENI_SITE_BRIDGE_RESPONSE || response.version !== OPENGENI_SITE_BRIDGE_VERSION || response.requestId !== requestId || typeof response.ok !== "boolean") {
158
+ return;
159
+ }
160
+ cleanup();
161
+ if (response.ok) {
162
+ resolve(response.value);
163
+ return;
164
+ }
165
+ const error = isRecord(response.error) ? response.error : {};
166
+ reject(
167
+ new OpenGeniSiteBridgeError(
168
+ typeof error.code === "string" ? error.code : "bridge_error",
169
+ typeof error.message === "string" ? error.message : "Site tool request failed",
170
+ error.retryable === true,
171
+ error.outcomeUnknown === true
172
+ )
173
+ );
174
+ };
175
+ const cleanup = () => {
176
+ clearTimeout(timeout);
177
+ options.signal?.removeEventListener("abort", abort);
178
+ port.removeEventListener("message", onMessage);
179
+ };
180
+ if (options.signal?.aborted) {
181
+ abort();
182
+ return;
183
+ }
184
+ options.signal?.addEventListener("abort", abort, { once: true });
185
+ port.addEventListener("message", onMessage);
186
+ port.postMessage({
187
+ type: OPENGENI_SITE_BRIDGE_REQUEST,
188
+ version: OPENGENI_SITE_BRIDGE_VERSION,
189
+ requestId,
190
+ ...request
191
+ });
192
+ });
193
+ }
194
+ async connect() {
195
+ if (this.closed) throw new OpenGeniSiteBridgeError("closed", "Site bridge is closed");
196
+ if (this.port) return this.port;
197
+ if (this.connecting) return await this.connecting;
198
+ const channel = (this.options.createMessageChannel ?? (() => new MessageChannel()))();
199
+ const timeoutMs = positiveTimeout(this.options.connectTimeoutMs ?? 1e4, "connectTimeoutMs");
200
+ this.connecting = new Promise((resolve, reject) => {
201
+ let active = true;
202
+ const timeout = setTimeout(() => {
203
+ cleanup();
204
+ channel.port1.close();
205
+ reject(new OpenGeniSiteBridgeError("host_timeout", "OpenGeni Site host did not respond"));
206
+ }, timeoutMs);
207
+ const onMessage = (event) => {
208
+ const message = event.data;
209
+ if (!isRecord(message) || message.type !== OPENGENI_SITE_BRIDGE_READY || message.version !== OPENGENI_SITE_BRIDGE_VERSION) {
210
+ return;
211
+ }
212
+ cleanup();
213
+ this.port = channel.port1;
214
+ resolve(channel.port1);
215
+ };
216
+ const cleanup = () => {
217
+ active = false;
218
+ clearTimeout(timeout);
219
+ channel.port1.removeEventListener("message", onMessage);
220
+ };
221
+ channel.port1.addEventListener("message", onMessage);
222
+ channel.port1.start();
223
+ void this.bootstrap.port().then((bootstrapPort) => {
224
+ if (!active) return;
225
+ if (this.closed) throw new OpenGeniSiteBridgeError("closed", "Site bridge is closed");
226
+ bootstrapPort.postMessage(
227
+ {
228
+ type: OPENGENI_SITE_BRIDGE_CONNECT,
229
+ version: OPENGENI_SITE_BRIDGE_VERSION
230
+ },
231
+ [channel.port2]
232
+ );
233
+ }).catch((error) => {
234
+ cleanup();
235
+ channel.port1.close();
236
+ reject(error);
237
+ });
238
+ }).finally(() => {
239
+ this.connecting = null;
240
+ });
241
+ return await this.connecting;
242
+ }
243
+ };
244
+ function createSiteBridgeBootstrap(options) {
245
+ if (options.bootstrapPort) {
246
+ return {
247
+ port: async () => options.bootstrapPort,
248
+ close: () => options.bootstrapPort?.close()
249
+ };
250
+ }
251
+ const siteWindow = options.siteWindow ?? globalThis.window;
252
+ const parentWindow = options.parentWindow ?? siteWindow?.parent;
253
+ if (!siteWindow || !parentWindow || parentWindow === siteWindow) {
254
+ return {
255
+ port: async () => {
256
+ throw new OpenGeniSiteBridgeError(
257
+ "host_unavailable",
258
+ "OpenGeni Site client must run inside a hosted iframe"
259
+ );
260
+ },
261
+ close: () => void 0
262
+ };
263
+ }
264
+ const retainedPort = retainedSiteBridgeBootstrapPort(siteWindow);
265
+ if (retainedPort) {
266
+ return {
267
+ port: async () => retainedPort,
268
+ close: () => void 0
269
+ };
270
+ }
271
+ let settledPort = null;
272
+ let rejectBootstrap = null;
273
+ const onMessage = (event) => {
274
+ if (event.source !== parentWindow || !isOpenGeniSiteBridgeReadyMessage(event.data) || event.ports.length !== 1) {
275
+ return;
276
+ }
277
+ cleanup();
278
+ settledPort = event.ports[0];
279
+ settledPort.start();
280
+ retainSiteBridgeBootstrapPort(siteWindow, settledPort);
281
+ resolveBootstrap?.(settledPort);
282
+ };
283
+ let resolveBootstrap = null;
284
+ const cleanup = () => siteWindow.removeEventListener("message", onMessage);
285
+ const port = new Promise((resolve, reject) => {
286
+ resolveBootstrap = resolve;
287
+ rejectBootstrap = reject;
288
+ siteWindow.addEventListener("message", onMessage);
289
+ });
290
+ void port.catch(() => void 0);
291
+ return {
292
+ port: async () => await port,
293
+ close: () => {
294
+ cleanup();
295
+ rejectBootstrap?.(new OpenGeniSiteBridgeError("closed", "Site bridge is closed"));
296
+ resolveBootstrap = null;
297
+ rejectBootstrap = null;
298
+ }
299
+ };
300
+ }
301
+ function retainedSiteBridgeBootstrapPort(siteWindow) {
302
+ const state = siteWindow[OPENGENI_SITE_BRIDGE_BOOTSTRAP_GLOBAL];
303
+ if (!isRecord(state)) return null;
304
+ const candidate = state.port;
305
+ return candidate && typeof candidate.postMessage === "function" && typeof candidate.addEventListener === "function" && typeof candidate.start === "function" ? candidate : null;
306
+ }
307
+ function retainSiteBridgeBootstrapPort(siteWindow, port) {
308
+ try {
309
+ Object.defineProperty(siteWindow, OPENGENI_SITE_BRIDGE_BOOTSTRAP_GLOBAL, {
310
+ configurable: true,
311
+ value: { port }
312
+ });
313
+ } catch {
314
+ }
315
+ }
316
+ function isOpenGeniSiteBridgeReadyMessage(value) {
317
+ return isRecord(value) && value.type === OPENGENI_SITE_BRIDGE_READY && value.version === OPENGENI_SITE_BRIDGE_VERSION;
318
+ }
319
+ function cancel(port, requestId) {
320
+ port.postMessage({
321
+ type: OPENGENI_SITE_BRIDGE_CANCEL,
322
+ version: OPENGENI_SITE_BRIDGE_VERSION,
323
+ requestId
324
+ });
325
+ }
326
+ function positiveTimeout(value, label) {
327
+ if (!Number.isFinite(value) || value <= 0) throw new RangeError(`${label} must be positive`);
328
+ return value;
329
+ }
330
+ function isRecord(value) {
331
+ return typeof value === "object" && value !== null && !Array.isArray(value);
332
+ }
333
+
334
+ export {
335
+ OPENGENI_SITE_BRIDGE_VERSION,
336
+ OPENGENI_SITE_BRIDGE_CONNECT,
337
+ OPENGENI_SITE_BRIDGE_READY,
338
+ OPENGENI_SITE_BRIDGE_REQUEST,
339
+ OPENGENI_SITE_BRIDGE_RESPONSE,
340
+ OPENGENI_SITE_BRIDGE_CANCEL,
341
+ OPENGENI_SITE_BRIDGE_BOOTSTRAP_GLOBAL,
342
+ OPENGENI_SITE_LOCAL_CODEMODE_PATH,
343
+ OpenGeniSiteBridgeError,
344
+ createOpenGeniSiteClient,
345
+ isOpenGeniSiteBridgeConnectMessage,
346
+ isOpenGeniSiteBridgeRequestMessage,
347
+ isOpenGeniSiteBridgeCancelMessage,
348
+ sanitizeOpenGeniSiteToolCallRequest
349
+ };
350
+ //# sourceMappingURL=chunk-IRAEPLXG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/site.ts"],"sourcesContent":["import {\n OpenGeniToolsClient,\n type OpenGeniToolTransport,\n type OpenGeniWorkspaceTools,\n} from \"./tools\";\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 /** 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 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 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 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":";;;;;AAYO,IAAM,+BAA+B;AACrC,IAAM,+BAA+B;AACrC,IAAM,6BAA6B;AACnC,IAAM,+BAA+B;AACrC,IAAM,gCAAgC;AACtC,IAAM,8BAA8B;AACpC,IAAM,wCAAwC;AAC9C,IAAM,oCAAoC;AAiF1C,IAAM,0BAAN,cAAsC,MAAM;AAAA,EACjD,YACW,MACT,SACS,YAAY,OACZ,iBAAi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uthorityClient
3
- } from "./chunk-YXQX7RQT.js";
3
+ } from "./chunk-2E2BFEEN.js";
4
4
 
5
5
  // src/artifact-client.ts
6
6
  var OpenGeniClient = class extends OpenGeniDocumentAuthorityClient {
@@ -80,6 +80,7 @@ var OpenGeniClient = class extends OpenGeniDocumentAuthorityClient {
80
80
  const query = new URLSearchParams();
81
81
  if (options.limit !== void 0) query.set("limit", String(options.limit));
82
82
  if (options.cursor) query.set("cursor", options.cursor);
83
+ if (options.status) query.set("status", options.status);
83
84
  const suffix = query.size > 0 ? `?${query.toString()}` : "";
84
85
  return await this.requestJson(
85
86
  "GET",
@@ -120,9 +121,16 @@ var OpenGeniClient = class extends OpenGeniDocumentAuthorityClient {
120
121
  request
121
122
  );
122
123
  }
124
+ async setWorkspaceArtifactStatus(workspaceId, artifactId, request) {
125
+ return await this.requestJson(
126
+ "PATCH",
127
+ `/v1/workspaces/${workspaceId}/published-artifacts/${encodeURIComponent(artifactId)}/status`,
128
+ request
129
+ );
130
+ }
123
131
  };
124
132
 
125
133
  export {
126
134
  OpenGeniClient
127
135
  };
128
- //# sourceMappingURL=chunk-QT3KFVDP.js.map
136
+ //# sourceMappingURL=chunk-MPGVC7EO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/artifact-client.ts"],"sourcesContent":["import { OpenGeniDocumentAuthorityClient } from \"./document-authority-client\";\nimport type { FetchResponse } from \"./client\";\nimport type {\n CreateEditableArtifactMaterializationRequest,\n CreateEditableArtifactResourceRequest,\n EditableArtifactListResource,\n EditableArtifactMaterializationJobResource,\n EditableArtifactPinnedVersionResource,\n EditableArtifactResource,\n ImportEditableArtifactResourceRequest,\n ListSessionEditableArtifactResourcesOptions,\n PinEditableArtifactVersionRequest,\n ReadEditableArtifactMaterializationOptions,\n ReadEditableArtifactResourceOptions,\n} from \"./editable-artifact-resources\";\nimport type {\n CreateWorkspaceArtifactRequest,\n PublishWorkspaceArtifactVersionRequest,\n RollbackWorkspaceArtifactRequest,\n SetWorkspaceArtifactStatusRequest,\n WorkspaceArtifactContentResponse,\n WorkspaceArtifactDetailResponse,\n WorkspaceArtifactListOptions,\n WorkspaceArtifactListResponse,\n WorkspaceArtifactMutationResponse,\n} from \"./workspace-artifacts\";\n\n/** Public SDK client. Optional operator and artifact operations stay out of the console core. */\nexport class OpenGeniClient extends OpenGeniDocumentAuthorityClient {\n async createEditableArtifact(\n workspaceId: string,\n request: CreateEditableArtifactResourceRequest,\n options: Readonly<{ signal?: AbortSignal | undefined }> = {},\n ): Promise<EditableArtifactResource> {\n return await this.requestJson<EditableArtifactResource>(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/editable-artifacts`,\n request,\n {},\n options,\n );\n }\n\n async importEditableArtifact(\n workspaceId: string,\n request: ImportEditableArtifactResourceRequest,\n options: Readonly<{ signal?: AbortSignal | undefined }> = {},\n ): Promise<EditableArtifactResource> {\n return await this.requestJson<EditableArtifactResource>(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/editable-artifacts/imports`,\n request,\n {},\n options,\n );\n }\n\n async getEditableArtifact(\n workspaceId: string,\n artifactId: string,\n options: ReadEditableArtifactResourceOptions,\n ): Promise<EditableArtifactResource> {\n return await this.requestJson<EditableArtifactResource>(\n \"GET\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/editable-artifacts/${encodeURIComponent(artifactId)}`,\n undefined,\n { replicaId: options.replicaId },\n options,\n );\n }\n\n async listSessionEditableArtifacts(\n workspaceId: string,\n sourceSessionId: string,\n options: ListSessionEditableArtifactResourcesOptions,\n ): Promise<EditableArtifactListResource> {\n return await this.requestJson<EditableArtifactListResource>(\n \"GET\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/editable-artifacts`,\n undefined,\n { sourceSessionId, replicaId: options.replicaId },\n options,\n );\n }\n\n async pinEditableArtifactVersion(\n workspaceId: string,\n artifactId: string,\n request: PinEditableArtifactVersionRequest,\n options: Readonly<{ signal?: AbortSignal | undefined }> = {},\n ): Promise<EditableArtifactPinnedVersionResource> {\n return await this.requestJson<EditableArtifactPinnedVersionResource>(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/editable-artifacts/${encodeURIComponent(artifactId)}/versions`,\n request,\n {},\n options,\n );\n }\n\n async createEditableArtifactMaterialization(\n workspaceId: string,\n artifactId: string,\n request: CreateEditableArtifactMaterializationRequest,\n options: Readonly<{ signal?: AbortSignal | undefined }> = {},\n ): Promise<EditableArtifactMaterializationJobResource> {\n return await this.requestJson<EditableArtifactMaterializationJobResource>(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/editable-artifacts/${encodeURIComponent(artifactId)}/materializations`,\n request,\n {},\n options,\n );\n }\n\n async getEditableArtifactMaterialization(\n workspaceId: string,\n artifactId: string,\n jobId: string,\n options: ReadEditableArtifactMaterializationOptions,\n ): Promise<EditableArtifactMaterializationJobResource> {\n return await this.requestJson<EditableArtifactMaterializationJobResource>(\n \"GET\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/editable-artifacts/${encodeURIComponent(artifactId)}/materializations/${encodeURIComponent(jobId)}`,\n undefined,\n { replicaId: options.replicaId },\n options,\n );\n }\n\n /** The caller owns the returned bounded response stream. */\n async downloadEditableArtifactMaterialization(\n workspaceId: string,\n artifactId: string,\n jobId: string,\n options: ReadEditableArtifactMaterializationOptions,\n ): Promise<FetchResponse> {\n return await this.requestResponse(\n \"GET\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/editable-artifacts/${encodeURIComponent(artifactId)}/materializations/${encodeURIComponent(jobId)}/download`,\n { replicaId: options.replicaId },\n options,\n );\n }\n\n async listWorkspaceArtifacts(\n workspaceId: string,\n options: WorkspaceArtifactListOptions = {},\n ): Promise<WorkspaceArtifactListResponse> {\n const query = new URLSearchParams();\n if (options.limit !== undefined) query.set(\"limit\", String(options.limit));\n if (options.cursor) query.set(\"cursor\", options.cursor);\n if (options.status) query.set(\"status\", options.status);\n const suffix = query.size > 0 ? `?${query.toString()}` : \"\";\n return await this.requestJson<WorkspaceArtifactListResponse>(\n \"GET\",\n `/v1/workspaces/${workspaceId}/published-artifacts${suffix}`,\n );\n }\n\n async getWorkspaceArtifact(\n workspaceId: string,\n artifactId: string,\n ): Promise<WorkspaceArtifactDetailResponse> {\n return await this.requestJson<WorkspaceArtifactDetailResponse>(\n \"GET\",\n `/v1/workspaces/${workspaceId}/published-artifacts/${encodeURIComponent(artifactId)}`,\n );\n }\n\n async getWorkspaceArtifactContent(\n workspaceId: string,\n artifactId: string,\n versionId?: string,\n ): Promise<WorkspaceArtifactContentResponse> {\n const query = versionId ? `?versionId=${encodeURIComponent(versionId)}` : \"\";\n return await this.requestJson<WorkspaceArtifactContentResponse>(\n \"GET\",\n `/v1/workspaces/${workspaceId}/published-artifacts/${encodeURIComponent(artifactId)}/content${query}`,\n );\n }\n\n async createWorkspaceArtifact(\n workspaceId: string,\n request: CreateWorkspaceArtifactRequest,\n ): Promise<WorkspaceArtifactMutationResponse> {\n return await this.requestJson<WorkspaceArtifactMutationResponse>(\n \"POST\",\n `/v1/workspaces/${workspaceId}/published-artifacts`,\n request,\n );\n }\n\n async publishWorkspaceArtifactVersion(\n workspaceId: string,\n artifactId: string,\n request: PublishWorkspaceArtifactVersionRequest,\n ): Promise<WorkspaceArtifactMutationResponse> {\n return await this.requestJson<WorkspaceArtifactMutationResponse>(\n \"POST\",\n `/v1/workspaces/${workspaceId}/published-artifacts/${encodeURIComponent(artifactId)}/versions`,\n request,\n );\n }\n\n async rollbackWorkspaceArtifact(\n workspaceId: string,\n artifactId: string,\n request: RollbackWorkspaceArtifactRequest,\n ): Promise<WorkspaceArtifactMutationResponse> {\n return await this.requestJson<WorkspaceArtifactMutationResponse>(\n \"POST\",\n `/v1/workspaces/${workspaceId}/published-artifacts/${encodeURIComponent(artifactId)}/rollback`,\n request,\n );\n }\n\n async setWorkspaceArtifactStatus(\n workspaceId: string,\n artifactId: string,\n request: SetWorkspaceArtifactStatusRequest,\n ): Promise<WorkspaceArtifactMutationResponse> {\n return await this.requestJson<WorkspaceArtifactMutationResponse>(\n \"PATCH\",\n `/v1/workspaces/${workspaceId}/published-artifacts/${encodeURIComponent(artifactId)}/status`,\n request,\n );\n }\n}\n"],"mappings":";;;;;AA4BO,IAAM,iBAAN,cAA6B,gCAAgC;AAAA,EAClE,MAAM,uBACJ,aACA,SACA,UAA0D,CAAC,GACxB;AACnC,WAAO,MAAM,KAAK;AAAA,MAChB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC;AAAA,MACjD;AAAA,MACA,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,uBACJ,aACA,SACA,UAA0D,CAAC,GACxB;AACnC,WAAO,MAAM,KAAK;AAAA,MAChB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC;AAAA,MACjD;AAAA,MACA,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,oBACJ,aACA,YACA,SACmC;AACnC,WAAO,MAAM,KAAK;AAAA,MAChB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC,uBAAuB,mBAAmB,UAAU,CAAC;AAAA,MACtG;AAAA,MACA,EAAE,WAAW,QAAQ,UAAU;AAAA,MAC/B;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,6BACJ,aACA,iBACA,SACuC;AACvC,WAAO,MAAM,KAAK;AAAA,MAChB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC;AAAA,MACjD;AAAA,MACA,EAAE,iBAAiB,WAAW,QAAQ,UAAU;AAAA,MAChD;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,2BACJ,aACA,YACA,SACA,UAA0D,CAAC,GACX;AAChD,WAAO,MAAM,KAAK;AAAA,MAChB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC,uBAAuB,mBAAmB,UAAU,CAAC;AAAA,MACtG;AAAA,MACA,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EAC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AAO,MAAM,KAAK;AAAA,MAChB;AAAA,MACA,kBAAkB,WAAW,wBAAwB,mBAAmB,UAAU,CAAC;AAAA,IACrF;AAAA,EACF;AAAA,EAEA,MAAM,4BACJ,aACA,YACA,WAC2C;AAC3C,UAAM,QAAQ,YAAY,cAAc,mBAAmB,SAAS,CAAC,KAAK;AAC1E,WAAO,MAAM,KAAK;AAAA,MAChB;AAAA,MACA,kBAAkB,WAAW,wBAAwB,mBAAmB,UAAU,CAAC,WAAW,KAAK;AAAA,IACrG;AAAA,EACF;AAAA,EAEA,MAAM,wBACJ,aACA,SAC4C;AAC5C,WAAO,MAAM,KAAK;AAAA,MAChB;AAAA,MACA,kBAAkB,WAAW;AAAA,MAC7B;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,gCACJ,aACA,YACA,SAC4C;AAC5C,WAAO,MAAM,KAAK;AAAA,MAChB;AAAA,MACA,kBAAkB,WAAW,wBAAwB,mBAAmB,UAAU,CAAC;AAAA,MACnF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,0BACJ,aACA,YACA,SAC4C;AAC5C,WAAO,MAAM,KAAK;AAAA,MAChB;AAAA,MACA,kBAAkB,WAAW,wBAAwB,mBAAmB,UAAU,CAAC;AAAA,MACnF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,2BACJ,aACA,YACA,SAC4C;AAC5C,WAAO,MAAM,KAAK;AAAA,MAChB;AAAA,MACA,kBAAkB,WAAW,wBAAwB,mBAAmB,UAAU,CAAC;AAAA,MACnF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -26,6 +26,18 @@ var OpenGeniApiError = class extends Error {
26
26
  this.details = decoded?.details;
27
27
  }
28
28
  };
29
+ var OpenGeniSecureContextRequiredError = class extends Error {
30
+ code = "secure_context_required";
31
+ retryable = false;
32
+ reason;
33
+ constructor(reason) {
34
+ super(
35
+ reason === "insecure_context" ? "Couldn\u2019t attach this file because OpenGeni is open over HTTP. Attachments require a secure HTTPS connection. Open the secure site or configure HTTPS for this deployment." : "Couldn\u2019t attach this file because secure browser cryptography is unavailable. Attachments require HTTPS and Web Crypto support. Open a secure site in a supported browser or configure HTTPS for this deployment."
36
+ );
37
+ this.name = "OpenGeniSecureContextRequiredError";
38
+ this.reason = reason;
39
+ }
40
+ };
29
41
  function decodeApiErrorBody(body) {
30
42
  if (!body) return null;
31
43
  try {
@@ -110,10 +122,11 @@ function isRetryableStreamError(error) {
110
122
 
111
123
  export {
112
124
  OpenGeniApiError,
125
+ OpenGeniSecureContextRequiredError,
113
126
  OpenGeniSessionListCursorError,
114
127
  OpenGeniApiContractMismatchError,
115
128
  OpenGeniStreamError,
116
129
  isAbortError,
117
130
  isRetryableStreamError
118
131
  };
119
- //# sourceMappingURL=chunk-C4DJPZRU.js.map
132
+ //# sourceMappingURL=chunk-OO5LPTO7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"sourcesContent":["/** Error for a non-2xx OpenGeni API response. */\nexport class OpenGeniApiError extends Error {\n readonly status: number;\n readonly code: string | undefined;\n readonly retryable: boolean;\n readonly correlationId: string | undefined;\n /** True only when an uncontrolled transport failed after a mutation may have been accepted. */\n readonly outcomeUnknown: boolean;\n readonly body: string;\n readonly details: Record<string, unknown> | undefined;\n\n constructor(\n status: number,\n body: string,\n options: {\n code?: string | undefined;\n retryable?: boolean | undefined;\n correlationId?: string | undefined;\n outcomeUnknown?: boolean | undefined;\n displayMessage?: string | undefined;\n mutation?: boolean | undefined;\n } = {},\n ) {\n const decoded = decodeApiErrorBody(body);\n const correlationId = decoded?.requestId ?? boundedCorrelationId(options.correlationId);\n const gatewayFailure = status >= 502 && status <= 504;\n const fromResponse = options.mutation !== undefined;\n const message = decoded?.message ?? (fromResponse ? \"Request failed.\" : body || \"(empty body)\");\n const displayMessage =\n options.displayMessage ??\n (gatewayFailure && fromResponse\n ? (decoded?.message ?? \"OpenGeni is temporarily unavailable — retry.\")\n : `OpenGeni API ${status}: ${message}`);\n super(correlationId ? `${displayMessage} Reference: ${correlationId}.` : displayMessage);\n this.name = \"OpenGeniApiError\";\n this.status = status;\n this.code =\n options.code ??\n decoded?.code ??\n (gatewayFailure && fromResponse ? \"upstream_unavailable\" : undefined);\n this.retryable = options.retryable ?? decoded?.retryable ?? retryableApiStatus(status);\n this.correlationId = correlationId;\n this.outcomeUnknown =\n options.outcomeUnknown ??\n decoded?.outcomeUnknown ??\n (gatewayFailure && !!options.mutation && !decoded);\n this.body = !fromResponse || decoded ? body : \"\";\n this.details = decoded?.details;\n }\n}\n\nexport type OpenGeniSecureContextRequiredReason = \"insecure_context\" | \"web_crypto_unavailable\";\n\n/**\n * A browser operation requires secure-context-only platform capabilities.\n * Callers may key UI behavior on the stable `secure_context_required` code;\n * `reason` exists only to keep the human guidance truthful.\n */\nexport class OpenGeniSecureContextRequiredError extends Error {\n readonly code = \"secure_context_required\" as const;\n readonly retryable = false;\n readonly reason: OpenGeniSecureContextRequiredReason;\n\n constructor(reason: OpenGeniSecureContextRequiredReason) {\n super(\n reason === \"insecure_context\"\n ? \"Couldn’t attach this file because OpenGeni is open over HTTP. Attachments require a secure HTTPS connection. Open the secure site or configure HTTPS for this deployment.\"\n : \"Couldn’t attach this file because secure browser cryptography is unavailable. Attachments require HTTPS and Web Crypto support. Open a secure site in a supported browser or configure HTTPS for this deployment.\",\n );\n this.name = \"OpenGeniSecureContextRequiredError\";\n this.reason = reason;\n }\n}\n\nfunction decodeApiErrorBody(body: string): {\n code: string | undefined;\n message: string | undefined;\n requestId: string | undefined;\n retryable: boolean | undefined;\n outcomeUnknown: boolean | undefined;\n details: Record<string, unknown> | undefined;\n} | null {\n if (!body) return null;\n try {\n const decoded: unknown = JSON.parse(body);\n if (!decoded || typeof decoded !== \"object\" || Array.isArray(decoded)) return null;\n const record = decoded as Record<string, unknown>;\n const nested =\n record.error && typeof record.error === \"object\" && !Array.isArray(record.error)\n ? (record.error as Record<string, unknown>)\n : record;\n const code = boundedApiField(nested.code);\n const message = boundedApiField(nested.message);\n const requestId = boundedCorrelationId(nested.requestId);\n const retryable = typeof nested.retryable === \"boolean\" ? nested.retryable : undefined;\n const outcomeUnknown =\n typeof nested.outcomeUnknown === \"boolean\" ? nested.outcomeUnknown : undefined;\n const details = boundedApiDetails(nested.details);\n if (\n !code &&\n !message &&\n !requestId &&\n retryable === undefined &&\n outcomeUnknown === undefined &&\n !details\n )\n return null;\n return {\n code,\n message,\n requestId,\n retryable,\n outcomeUnknown,\n details,\n };\n } catch {\n return null;\n }\n}\n\nfunction boundedApiDetails(value: unknown): Record<string, unknown> | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return;\n const entries = Object.entries(value as Record<string, unknown>).slice(0, 16);\n const details: Record<string, unknown> = {};\n for (const [key, entry] of entries) {\n if (!/^[a-zA-Z][\\w.-]{0,63}$/.test(key)) continue;\n if (typeof entry === \"string\") {\n const bounded = boundedApiField(entry);\n if (bounded !== undefined) details[key] = bounded;\n } else if (typeof entry === \"number\" || typeof entry === \"boolean\" || entry === null) {\n details[key] = entry;\n }\n }\n return Object.keys(details).length > 0 ? details : undefined;\n}\n\nfunction boundedApiField(value: unknown): string | undefined {\n if (typeof value !== \"string\") return;\n const bytes = new TextEncoder().encode(value);\n return bytes.byteLength <= 512 ? value : new TextDecoder().decode(bytes.slice(0, 512));\n}\n\nfunction retryableApiStatus(status: number): boolean {\n return status === 408 || status === 409 || status === 425 || status === 429 || status >= 500;\n}\n\nfunction boundedCorrelationId(value: unknown): string | undefined {\n if (typeof value !== \"string\" || value.length > 128 || !/^[\\w.:-]+$/.test(value)) {\n return;\n }\n return value;\n}\n\n/** A legacy short-lived session-list snapshot cursor can no longer be continued. */\nexport class OpenGeniSessionListCursorError extends OpenGeniApiError {}\n\n/** The browser bundle and API disagree about their state-changing wire contract. */\nexport class OpenGeniApiContractMismatchError extends Error {\n readonly expected: string;\n readonly actual: string;\n\n constructor(expected: string, actual: string) {\n super(`OpenGeni API contract mismatch: client expects ${expected}, API serves ${actual}`);\n this.name = \"OpenGeniApiContractMismatchError\";\n this.expected = expected;\n this.actual = actual;\n }\n}\n\n/** Error for an unrecoverable event-stream condition (not a transient drop). */\nexport class OpenGeniStreamError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"OpenGeniStreamError\";\n }\n}\n\nexport function isAbortError(error: unknown): boolean {\n return (\n (error instanceof DOMException && error.name === \"AbortError\") ||\n (error instanceof Error && error.name === \"AbortError\")\n );\n}\n\n/**\n * Transient conditions worth a reconnect: network-level failures (`fetch`\n * rejects with `TypeError`) and HTTP statuses that signal a temporary server\n * or contention condition. Auth/validation failures (401/403/404/...) are\n * permanent and surface to the caller instead.\n */\nexport function isRetryableStreamError(error: unknown): boolean {\n if (error instanceof OpenGeniApiError) return error.retryable;\n return error instanceof TypeError;\n}\n"],"mappings":";AACO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YACE,QACA,MACA,UAOI,CAAC,GACL;AACA,UAAM,UAAU,mBAAmB,IAAI;AACvC,UAAM,gBAAgB,SAAS,aAAa,qBAAqB,QAAQ,aAAa;AACtF,UAAM,iBAAiB,UAAU,OAAO,UAAU;AAClD,UAAM,eAAe,QAAQ,aAAa;AAC1C,UAAM,UAAU,SAAS,YAAY,eAAe,oBAAoB,QAAQ;AAChF,UAAM,iBACJ,QAAQ,mBACP,kBAAkB,eACd,SAAS,WAAW,sDACrB,gBAAgB,MAAM,KAAK,OAAO;AACxC,UAAM,gBAAgB,GAAG,cAAc,eAAe,aAAa,MAAM,cAAc;AACvF,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OACH,QAAQ,QACR,SAAS,SACR,kBAAkB,eAAe,yBAAyB;AAC7D,SAAK,YAAY,QAAQ,aAAa,SAAS,aAAa,mBAAmB,MAAM;AACrF,SAAK,gBAAgB;AACrB,SAAK,iBACH,QAAQ,kBACR,SAAS,mBAC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AAA,EACd;AACF;AAEO,SAAS,aAAa,OAAyB;AACpD,SACG,iBAAiB,gBAAgB,MAAM,SAAS,gBAChD,iBAAiB,SAAS,MAAM,SAAS;AAE9C;AAQO,SAAS,uBAAuB,OAAyB;AAC9D,MAAI,iBAAiB,iBAAkB,QAAO,MAAM;AACpD,SAAO,iBAAiB;AAC1B;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  OpenGeniApiError
3
- } from "./chunk-C4DJPZRU.js";
3
+ } from "./chunk-OO5LPTO7.js";
4
4
 
5
5
  // src/interaction.ts
6
6
  var INTERACTION_PROTOCOL_VERSION = 1;
@@ -1060,4 +1060,4 @@ export {
1060
1060
  parseComputerFrameMetadata,
1061
1061
  decodeComputerFrameMetadataHeader
1062
1062
  };
1063
- //# sourceMappingURL=chunk-KKRO2VCP.js.map
1063
+ //# sourceMappingURL=chunk-QTBAMHEF.js.map