@opengeni/react 7.4.0-canary.36844267522001 → 7.4.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 (113) hide show
  1. package/README.md +0 -10
  2. package/dist/artifacts-document.js +2 -3
  3. package/dist/artifacts-presentation.js +2 -3
  4. package/dist/artifacts-spreadsheet.js +2 -2
  5. package/dist/artifacts.d.ts +0 -1
  6. package/dist/artifacts.js +1402 -505
  7. package/dist/artifacts.js.map +1 -1
  8. package/dist/{browser-viewer-AJO7LMVE.js → browser-viewer-2E6R2Y4W.js} +2 -2
  9. package/dist/{chunk-WUISZ3WU.js → chunk-3E2AITTZ.js} +28 -32
  10. package/dist/{chunk-WUISZ3WU.js.map → chunk-3E2AITTZ.js.map} +1 -1
  11. package/dist/{chunk-Y2PRMYLC.js → chunk-DUEBTL3N.js} +3 -4
  12. package/dist/{chunk-Y2PRMYLC.js.map → chunk-DUEBTL3N.js.map} +1 -1
  13. package/dist/{chunk-7UAMYXJY.js → chunk-KNDIXZN6.js} +18 -25
  14. package/dist/{chunk-7UAMYXJY.js.map → chunk-KNDIXZN6.js.map} +1 -1
  15. package/dist/{chunk-XVYRQ4PK.js → chunk-L4OSXQ6H.js} +116 -277
  16. package/dist/chunk-L4OSXQ6H.js.map +1 -0
  17. package/dist/{chunk-7B44WVGH.js → chunk-S5JQ4R22.js} +12 -31
  18. package/dist/chunk-S5JQ4R22.js.map +1 -0
  19. package/dist/{chunk-A4UJB2MM.js → chunk-SEEVCT36.js} +2 -2
  20. package/dist/chunk-UGMKPUEM.js +299 -0
  21. package/dist/chunk-UGMKPUEM.js.map +1 -0
  22. package/dist/{chunk-OQVBTOBJ.js → chunk-USXVQACU.js} +3 -3
  23. package/dist/{chunk-ASCSKOWU.js → chunk-V2ABIVYJ.js} +3 -50
  24. package/dist/chunk-V2ABIVYJ.js.map +1 -0
  25. package/dist/{chunk-UQUR5WG5.js → chunk-X4HIN6TV.js} +157 -66
  26. package/dist/chunk-X4HIN6TV.js.map +1 -0
  27. package/dist/{chunk-QLG6W33X.js → chunk-XEJEOAOV.js} +35 -46
  28. package/dist/chunk-XEJEOAOV.js.map +1 -0
  29. package/dist/components/artifacts/editable-artifact-ui.d.ts +1 -2
  30. package/dist/components/artifacts/index.d.ts +0 -7
  31. package/dist/components/message-timeline.d.ts +1 -7
  32. package/dist/components/open-geni-links.d.ts +0 -16
  33. package/dist/components/session-conversation.d.ts +1 -13
  34. package/dist/{computer-viewer-NB6O6BTV.js → computer-viewer-WMJE6OA3.js} +2 -2
  35. package/dist/connect.js +1 -2
  36. package/dist/connect.js.map +1 -1
  37. package/dist/hooks/latest-question.d.ts +1 -1
  38. package/dist/index.d.ts +2 -3
  39. package/dist/index.js +12 -22
  40. package/dist/index.js.map +1 -1
  41. package/dist/interaction.js +2 -2
  42. package/dist/{latest-question-3HGQUI2E.js → latest-question-QB4EUCW5.js} +2 -2
  43. package/dist/{markdown-table-layout-QXSLK4BY.js → markdown-table-layout-PFUEZ2U4.js} +5 -37
  44. package/dist/markdown-table-layout-PFUEZ2U4.js.map +1 -0
  45. package/dist/session-ui.d.ts +2 -3
  46. package/dist/session-ui.js +9 -18
  47. package/dist/session-ui.js.map +1 -1
  48. package/dist/session.js +2 -2
  49. package/dist/sites.js +289 -4
  50. package/dist/sites.js.map +1 -1
  51. package/package.json +3 -3
  52. package/src/artifacts.ts +0 -37
  53. package/src/components/artifacts/editable-artifact-ui.tsx +1 -3
  54. package/src/components/artifacts/editable-artifact-workbench.tsx +2 -5
  55. package/src/components/artifacts/editable-document.tsx +36 -34
  56. package/src/components/artifacts/editable-presentation.tsx +16 -21
  57. package/src/components/artifacts/index.ts +0 -41
  58. package/src/components/browser-viewer.tsx +20 -59
  59. package/src/components/computer-viewer.tsx +23 -51
  60. package/src/components/markdown-table-layout.ts +5 -49
  61. package/src/components/markdown.tsx +2 -5
  62. package/src/components/message-timeline.tsx +7 -59
  63. package/src/components/open-geni-links.tsx +0 -24
  64. package/src/components/session-conversation.tsx +20 -120
  65. package/src/index.ts +0 -7
  66. package/src/session-ui.ts +0 -7
  67. package/src/timeline/projection.ts +4 -54
  68. package/styles/compiled.css +0 -220
  69. package/dist/chat-interactive-block-VAGABN7J.js +0 -11
  70. package/dist/chunk-5CVXZA3Y.js +0 -292
  71. package/dist/chunk-5CVXZA3Y.js.map +0 -1
  72. package/dist/chunk-7B44WVGH.js.map +0 -1
  73. package/dist/chunk-ASCSKOWU.js.map +0 -1
  74. package/dist/chunk-QLG6W33X.js.map +0 -1
  75. package/dist/chunk-RAIQYITC.js +0 -1772
  76. package/dist/chunk-RAIQYITC.js.map +0 -1
  77. package/dist/chunk-SCOTPE2I.js +0 -589
  78. package/dist/chunk-SCOTPE2I.js.map +0 -1
  79. package/dist/chunk-UQUR5WG5.js.map +0 -1
  80. package/dist/chunk-WEHMPOXK.js +0 -39
  81. package/dist/chunk-WEHMPOXK.js.map +0 -1
  82. package/dist/chunk-XCHWDJ22.js +0 -107
  83. package/dist/chunk-XCHWDJ22.js.map +0 -1
  84. package/dist/chunk-XVYRQ4PK.js.map +0 -1
  85. package/dist/components/artifacts/artifact-chrome.d.ts +0 -120
  86. package/dist/components/artifacts/artifact-sandbox.d.ts +0 -27
  87. package/dist/components/artifacts/chat-interactive-block.d.ts +0 -29
  88. package/dist/components/artifacts/deferred-chat-media.d.ts +0 -15
  89. package/dist/components/artifacts/editable-artifact-view.d.ts +0 -46
  90. package/dist/components/artifacts/latest-task-runner.d.ts +0 -15
  91. package/dist/components/artifacts/session-artifact-viewer.d.ts +0 -39
  92. package/dist/components/artifacts/site-view.d.ts +0 -23
  93. package/dist/components/timeline-pill-geometry.d.ts +0 -6
  94. package/dist/components/timeline-pill-placement.d.ts +0 -18
  95. package/dist/computer-viewer-NB6O6BTV.js.map +0 -1
  96. package/dist/markdown-table-layout-QXSLK4BY.js.map +0 -1
  97. package/dist/timeline-pill-geometry-2G6EK47V.js +0 -73
  98. package/dist/timeline-pill-geometry-2G6EK47V.js.map +0 -1
  99. package/src/components/artifacts/artifact-chrome.tsx +0 -413
  100. package/src/components/artifacts/artifact-sandbox.tsx +0 -185
  101. package/src/components/artifacts/chat-interactive-block.tsx +0 -260
  102. package/src/components/artifacts/deferred-chat-media.tsx +0 -67
  103. package/src/components/artifacts/editable-artifact-view.tsx +0 -187
  104. package/src/components/artifacts/latest-task-runner.ts +0 -49
  105. package/src/components/artifacts/session-artifact-viewer.tsx +0 -376
  106. package/src/components/artifacts/site-view.tsx +0 -116
  107. package/src/components/timeline-pill-geometry.ts +0 -112
  108. package/src/components/timeline-pill-placement.ts +0 -81
  109. /package/dist/{browser-viewer-AJO7LMVE.js.map → browser-viewer-2E6R2Y4W.js.map} +0 -0
  110. /package/dist/{chunk-A4UJB2MM.js.map → chunk-SEEVCT36.js.map} +0 -0
  111. /package/dist/{chunk-OQVBTOBJ.js.map → chunk-USXVQACU.js.map} +0 -0
  112. /package/dist/{chat-interactive-block-VAGABN7J.js.map → computer-viewer-WMJE6OA3.js.map} +0 -0
  113. /package/dist/{latest-question-3HGQUI2E.js.map → latest-question-QB4EUCW5.js.map} +0 -0
@@ -4,7 +4,7 @@ import {
4
4
  editableArtifactAccessRevoked,
5
5
  editableArtifactStatusLabel,
6
6
  useEditableArtifactView
7
- } from "./chunk-Y2PRMYLC.js";
7
+ } from "./chunk-DUEBTL3N.js";
8
8
  import {
9
9
  cn
10
10
  } from "./chunk-22KP6LR5.js";
@@ -2835,4 +2835,4 @@ export {
2835
2835
  EditableSpreadsheetGrid,
2836
2836
  EditableSpreadsheetArtifactSurface
2837
2837
  };
2838
- //# sourceMappingURL=chunk-A4UJB2MM.js.map
2838
+ //# sourceMappingURL=chunk-SEEVCT36.js.map
@@ -0,0 +1,299 @@
1
+ // src/components/artifacts/published-html-artifact-frame.tsx
2
+ import {
3
+ OPENGENI_SITE_BRIDGE_BOOTSTRAP_GLOBAL,
4
+ OPENGENI_SITE_BRIDGE_READY,
5
+ OPENGENI_SITE_BRIDGE_RESPONSE,
6
+ OPENGENI_SITE_BRIDGE_VERSION,
7
+ isOpenGeniSiteBridgeCancelMessage,
8
+ isOpenGeniSiteBridgeConnectMessage,
9
+ isOpenGeniSiteBridgeRequestMessage,
10
+ sanitizeOpenGeniSiteToolCallRequest,
11
+ isSiteHttpRequest,
12
+ serveSiteHttp
13
+ } from "@opengeni/sdk/site";
14
+ import { useEffect, useRef, useState } from "react";
15
+ import { resolveSiteClientScript } from "@opengeni/sdk/site-document";
16
+ import { jsx } from "react/jsx-runtime";
17
+ var PUBLISHED_HTML_ARTIFACT_IFRAME_SANDBOX = [
18
+ "allow-downloads",
19
+ "allow-forms",
20
+ "allow-modals",
21
+ "allow-orientation-lock",
22
+ "allow-pointer-lock",
23
+ "allow-popups",
24
+ "allow-popups-to-escape-sandbox",
25
+ "allow-presentation",
26
+ "allow-scripts"
27
+ ].join(" ");
28
+ var SITE_BRIDGE_BOOTSTRAP_SCRIPT = `<script>(()=>{const key=${JSON.stringify(
29
+ OPENGENI_SITE_BRIDGE_BOOTSTRAP_GLOBAL
30
+ )};const parentWindow=window.parent;if(parentWindow===window)return;window.addEventListener("message",event=>{const data=event.data;if(event.source!==parentWindow||!data||data.type!==${JSON.stringify(
31
+ OPENGENI_SITE_BRIDGE_READY
32
+ )}||data.version!==${OPENGENI_SITE_BRIDGE_VERSION}||event.ports.length!==1)return;const port=event.ports[0];const previous=window[key]?.port;if(previous&&previous!==port)previous.close();Object.defineProperty(window,key,{configurable:true,value:{port}});port.start();});})();</script>`;
33
+ function publishedHtmlArtifactDocument(html, toolBridgeEnabled) {
34
+ if (!toolBridgeEnabled) return html;
35
+ html = resolveSiteClientScript(html);
36
+ const doctypeEnd = leadingDoctypeEnd(html);
37
+ if (doctypeEnd >= 0) {
38
+ return `${html.slice(0, doctypeEnd + 1)}${SITE_BRIDGE_BOOTSTRAP_SCRIPT}${html.slice(doctypeEnd + 1)}`;
39
+ }
40
+ return `${SITE_BRIDGE_BOOTSTRAP_SCRIPT}${html}`;
41
+ }
42
+ function leadingDoctypeEnd(html) {
43
+ const lower = html.toLowerCase();
44
+ let cursor = html.charCodeAt(0) === 65279 ? 1 : 0;
45
+ while (cursor < html.length) {
46
+ while (/\s/.test(html[cursor] ?? "")) cursor += 1;
47
+ if (!html.startsWith("<!--", cursor)) break;
48
+ const commentEnd = html.indexOf("-->", cursor + 4);
49
+ if (commentEnd < 0) return -1;
50
+ cursor = commentEnd + 3;
51
+ }
52
+ if (!lower.startsWith("<!doctype", cursor)) return -1;
53
+ return html.indexOf(">", cursor + 9);
54
+ }
55
+ function PublishedHtmlArtifactFrame(props) {
56
+ const frameRef = useRef(null);
57
+ const [height, setHeight] = useState();
58
+ useEffect(() => {
59
+ if (!props.autoHeight) return;
60
+ const receive = (event) => {
61
+ if (event.source !== frameRef.current?.contentWindow || event.data?.type !== "opengeni.preview.height")
62
+ return;
63
+ const value = event.data.height;
64
+ if (typeof value === "number" && Number.isFinite(value))
65
+ setHeight(Math.min(1200, Math.max(80, value)));
66
+ };
67
+ window.addEventListener("message", receive);
68
+ return () => window.removeEventListener("message", receive);
69
+ }, [props.autoHeight]);
70
+ useEffect(() => {
71
+ frameRef.current?.contentWindow?.postMessage(
72
+ { type: "opengeni.preview.theme", theme: props.theme },
73
+ "*"
74
+ );
75
+ }, [props.theme]);
76
+ const bridgeRef = useRef(props.toolBridge);
77
+ const onFrameLoadRef = useRef(() => void 0);
78
+ const frameLoadPendingRef = useRef(false);
79
+ const toolBridgeEnabled = props.toolBridge !== void 0;
80
+ useEffect(() => {
81
+ bridgeRef.current = props.toolBridge;
82
+ }, [props.toolBridge]);
83
+ useEffect(() => {
84
+ if (!toolBridgeEnabled || typeof window === "undefined") return;
85
+ const requests = new SiteBridgeRequestRegistry();
86
+ const attachToolPort = (data, ports) => {
87
+ const port = openGeniSiteBridgePortFromBootstrap(data, ports);
88
+ if (!port) return;
89
+ requests.addPort(port);
90
+ port.addEventListener("message", (portEvent) => {
91
+ const message = portEvent.data;
92
+ if (isOpenGeniSiteBridgeCancelMessage(message)) {
93
+ requests.cancel(port, message.requestId);
94
+ return;
95
+ }
96
+ if (isSiteHttpRequest(message) && portEvent.ports.length === 1) {
97
+ const controller2 = requests.start(port, message.requestId);
98
+ if (!controller2) {
99
+ portEvent.ports[0].close();
100
+ return;
101
+ }
102
+ void serveSiteHttp(
103
+ message,
104
+ portEvent.ports[0],
105
+ async (request, signal) => {
106
+ const fetch = bridgeRef.current?.fetch;
107
+ if (!fetch) throw new Error("This Site host does not support the session SDK");
108
+ return fetch(request, signal);
109
+ },
110
+ controller2.signal
111
+ ).finally(() => requests.complete(port, message.requestId, controller2));
112
+ return;
113
+ }
114
+ if (!isOpenGeniSiteBridgeRequestMessage(message)) return;
115
+ const controller = requests.start(port, message.requestId);
116
+ if (!controller) {
117
+ port.postMessage({
118
+ type: OPENGENI_SITE_BRIDGE_RESPONSE,
119
+ version: OPENGENI_SITE_BRIDGE_VERSION,
120
+ requestId: message.requestId,
121
+ ok: false,
122
+ error: {
123
+ code: "duplicate_request_id",
124
+ message: "A Site tool request with this id is already running",
125
+ retryable: false
126
+ }
127
+ });
128
+ return;
129
+ }
130
+ void handleSiteBridgeRequest(bridgeRef.current, message, controller.signal).then((value) => {
131
+ if (!controller.signal.aborted) {
132
+ port.postMessage({
133
+ type: OPENGENI_SITE_BRIDGE_RESPONSE,
134
+ version: OPENGENI_SITE_BRIDGE_VERSION,
135
+ requestId: message.requestId,
136
+ ok: true,
137
+ value
138
+ });
139
+ }
140
+ }).catch((error) => {
141
+ if (!controller.signal.aborted) {
142
+ port.postMessage({
143
+ type: OPENGENI_SITE_BRIDGE_RESPONSE,
144
+ version: OPENGENI_SITE_BRIDGE_VERSION,
145
+ requestId: message.requestId,
146
+ ok: false,
147
+ error: siteBridgeError(error)
148
+ });
149
+ }
150
+ }).finally(() => requests.complete(port, message.requestId, controller));
151
+ });
152
+ port.addEventListener("messageerror", () => requests.closePort(port));
153
+ port.start();
154
+ port.postMessage({
155
+ type: OPENGENI_SITE_BRIDGE_READY,
156
+ version: OPENGENI_SITE_BRIDGE_VERSION
157
+ });
158
+ };
159
+ const documentLease = new SiteBridgeDocumentLease(attachToolPort, () => requests.closeAll());
160
+ const onFrameLoad = () => {
161
+ frameLoadPendingRef.current = false;
162
+ const frameWindow = frameRef.current?.contentWindow ?? null;
163
+ if (!frameWindow) return;
164
+ documentLease.load(frameWindow);
165
+ };
166
+ onFrameLoadRef.current = onFrameLoad;
167
+ if (frameLoadPendingRef.current) {
168
+ frameLoadPendingRef.current = false;
169
+ onFrameLoad();
170
+ }
171
+ return () => {
172
+ onFrameLoadRef.current = () => void 0;
173
+ documentLease.close();
174
+ };
175
+ }, [props.html, toolBridgeEnabled]);
176
+ return /* @__PURE__ */ jsx(
177
+ "iframe",
178
+ {
179
+ ref: frameRef,
180
+ title: props.title,
181
+ sandbox: PUBLISHED_HTML_ARTIFACT_IFRAME_SANDBOX,
182
+ referrerPolicy: "no-referrer",
183
+ srcDoc: publishedHtmlArtifactDocument(props.html, toolBridgeEnabled),
184
+ onLoad: () => {
185
+ frameRef.current?.contentWindow?.postMessage(
186
+ { type: "opengeni.preview.theme", theme: props.theme },
187
+ "*"
188
+ );
189
+ frameLoadPendingRef.current = true;
190
+ onFrameLoadRef.current();
191
+ },
192
+ className: props.className,
193
+ style: { ...props.style, ...props.autoHeight && height ? { height } : {} }
194
+ }
195
+ );
196
+ }
197
+ var SiteBridgeRequestRegistry = class {
198
+ controllersByPort = /* @__PURE__ */ new Map();
199
+ addPort(port) {
200
+ if (!this.controllersByPort.has(port)) this.controllersByPort.set(port, /* @__PURE__ */ new Map());
201
+ }
202
+ start(port, requestId) {
203
+ const controllers = this.controllersByPort.get(port);
204
+ if (!controllers || controllers.has(requestId)) return null;
205
+ const controller = new AbortController();
206
+ controllers.set(requestId, controller);
207
+ return controller;
208
+ }
209
+ cancel(port, requestId) {
210
+ const controllers = this.controllersByPort.get(port);
211
+ const controller = controllers?.get(requestId);
212
+ if (!controller) return;
213
+ controller.abort(new Error("Site tool request cancelled"));
214
+ controllers.delete(requestId);
215
+ }
216
+ complete(port, requestId, controller) {
217
+ const controllers = this.controllersByPort.get(port);
218
+ if (controllers?.get(requestId) === controller) controllers.delete(requestId);
219
+ }
220
+ closePort(port) {
221
+ const controllers = this.controllersByPort.get(port);
222
+ if (!controllers) return;
223
+ for (const controller of controllers.values()) {
224
+ controller.abort(new Error("Site tool bridge port closed"));
225
+ }
226
+ controllers.clear();
227
+ this.controllersByPort.delete(port);
228
+ port.close();
229
+ }
230
+ closeAll() {
231
+ for (const port of [...this.controllersByPort.keys()]) this.closePort(port);
232
+ }
233
+ };
234
+ var SiteBridgeDocumentLease = class {
235
+ constructor(attachToolPort, closeActivePorts, createMessageChannel = () => new MessageChannel()) {
236
+ this.attachToolPort = attachToolPort;
237
+ this.closeActivePorts = closeActivePorts;
238
+ this.createMessageChannel = createMessageChannel;
239
+ }
240
+ loaded = false;
241
+ bootstrapPort = null;
242
+ load(frameWindow) {
243
+ if (this.loaded) {
244
+ this.close();
245
+ return false;
246
+ }
247
+ this.loaded = true;
248
+ const channel = this.createMessageChannel();
249
+ this.bootstrapPort = channel.port1;
250
+ channel.port1.addEventListener("message", (event) => {
251
+ this.attachToolPort(event.data, event.ports);
252
+ });
253
+ channel.port1.start();
254
+ frameWindow.postMessage(
255
+ {
256
+ type: OPENGENI_SITE_BRIDGE_READY,
257
+ version: OPENGENI_SITE_BRIDGE_VERSION
258
+ },
259
+ "*",
260
+ [channel.port2]
261
+ );
262
+ return true;
263
+ }
264
+ close() {
265
+ this.bootstrapPort?.close();
266
+ this.bootstrapPort = null;
267
+ this.closeActivePorts();
268
+ }
269
+ };
270
+ function openGeniSiteBridgePortFromBootstrap(data, ports) {
271
+ if (!isOpenGeniSiteBridgeConnectMessage(data)) return null;
272
+ return ports.length === 1 ? ports[0] : null;
273
+ }
274
+ async function handleSiteBridgeRequest(bridge, message, signal) {
275
+ if (!bridge) throw new Error("Site tool bridge is unavailable");
276
+ if (message.method === "catalog") return await bridge.catalog({ signal });
277
+ if (message.method === "declarations") {
278
+ if (!bridge.declarations) throw new Error("Site tool declarations are unavailable");
279
+ return await bridge.declarations({ signal });
280
+ }
281
+ return await bridge.call(sanitizeOpenGeniSiteToolCallRequest(message.payload), { signal });
282
+ }
283
+ function siteBridgeError(error) {
284
+ const candidate = error;
285
+ return {
286
+ code: typeof candidate?.code === "string" ? candidate.code : "site_tool_call_failed",
287
+ message: typeof candidate?.message === "string" ? candidate.message : "Site tool request failed",
288
+ retryable: candidate?.retryable === true,
289
+ outcomeUnknown: candidate?.outcomeUnknown === true
290
+ };
291
+ }
292
+
293
+ export {
294
+ PUBLISHED_HTML_ARTIFACT_IFRAME_SANDBOX,
295
+ publishedHtmlArtifactDocument,
296
+ PublishedHtmlArtifactFrame,
297
+ openGeniSiteBridgePortFromBootstrap
298
+ };
299
+ //# sourceMappingURL=chunk-UGMKPUEM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/artifacts/published-html-artifact-frame.tsx"],"sourcesContent":["import {\n OPENGENI_SITE_BRIDGE_BOOTSTRAP_GLOBAL,\n OPENGENI_SITE_BRIDGE_READY,\n OPENGENI_SITE_BRIDGE_RESPONSE,\n OPENGENI_SITE_BRIDGE_VERSION,\n isOpenGeniSiteBridgeCancelMessage,\n isOpenGeniSiteBridgeConnectMessage,\n isOpenGeniSiteBridgeRequestMessage,\n sanitizeOpenGeniSiteToolCallRequest,\n isSiteHttpRequest,\n serveSiteHttp,\n type SiteHttpRequest,\n type OpenGeniSiteBridgeResponseMessage,\n type OpenGeniSiteToolCatalog,\n} from \"@opengeni/sdk/site\";\nimport type {\n ToolGatewayCallRequest,\n ToolGatewayCallResponse,\n ToolGatewayDeclarationsResponse,\n} from \"@opengeni/sdk\";\nimport { useEffect, useRef, useState, type CSSProperties } from \"react\";\nimport { resolveSiteClientScript } from \"@opengeni/sdk/site-document\";\n\nexport const PUBLISHED_HTML_ARTIFACT_IFRAME_SANDBOX = [\n \"allow-downloads\",\n \"allow-forms\",\n \"allow-modals\",\n \"allow-orientation-lock\",\n \"allow-pointer-lock\",\n \"allow-popups\",\n \"allow-popups-to-escape-sandbox\",\n \"allow-presentation\",\n \"allow-scripts\",\n].join(\" \");\n\nexport type PublishedHtmlArtifactFrameProps = {\n html: string;\n autoHeight?: boolean;\n theme?: \"light\" | \"dark\";\n title: string;\n className?: string;\n style?: CSSProperties;\n toolBridge?: PublishedHtmlArtifactToolBridge;\n};\n\nexport type PublishedHtmlArtifactToolBridge = {\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 declarations?: (options: { signal: AbortSignal }) => Promise<ToolGatewayDeclarationsResponse>;\n};\n\nconst SITE_BRIDGE_BOOTSTRAP_SCRIPT = `<script>(()=>{const key=${JSON.stringify(\n OPENGENI_SITE_BRIDGE_BOOTSTRAP_GLOBAL,\n)};const parentWindow=window.parent;if(parentWindow===window)return;window.addEventListener(\"message\",event=>{const data=event.data;if(event.source!==parentWindow||!data||data.type!==${JSON.stringify(\n OPENGENI_SITE_BRIDGE_READY,\n)}||data.version!==${OPENGENI_SITE_BRIDGE_VERSION}||event.ports.length!==1)return;const port=event.ports[0];const previous=window[key]?.port;if(previous&&previous!==port)previous.close();Object.defineProperty(window,key,{configurable:true,value:{port}});port.start();});})();</script>`;\n\nexport function publishedHtmlArtifactDocument(html: string, toolBridgeEnabled: boolean): string {\n if (!toolBridgeEnabled) return html;\n html = resolveSiteClientScript(html);\n const doctypeEnd = leadingDoctypeEnd(html);\n if (doctypeEnd >= 0) {\n return `${html.slice(0, doctypeEnd + 1)}${SITE_BRIDGE_BOOTSTRAP_SCRIPT}${html.slice(doctypeEnd + 1)}`;\n }\n return `${SITE_BRIDGE_BOOTSTRAP_SCRIPT}${html}`;\n}\n\nfunction leadingDoctypeEnd(html: string): number {\n const lower = html.toLowerCase();\n let cursor = html.charCodeAt(0) === 0xfeff ? 1 : 0;\n while (cursor < html.length) {\n while (/\\s/.test(html[cursor] ?? \"\")) cursor += 1;\n if (!html.startsWith(\"<!--\", cursor)) break;\n const commentEnd = html.indexOf(\"-->\", cursor + 4);\n if (commentEnd < 0) return -1;\n cursor = commentEnd + 3;\n }\n if (!lower.startsWith(\"<!doctype\", cursor)) return -1;\n return html.indexOf(\">\", cursor + 9);\n}\n\n/**\n * Render exact published HTML in an opaque-origin iframe. Artifact scripts,\n * external resources, forms, popups, downloads, and the host-filtered tool\n * bridge work without granting parent-origin authority, shared cookies/storage,\n * or top-level navigation.\n */\nexport function PublishedHtmlArtifactFrame(props: PublishedHtmlArtifactFrameProps) {\n const frameRef = useRef<HTMLIFrameElement | null>(null);\n const [height, setHeight] = useState<number>();\n useEffect(() => {\n if (!props.autoHeight) return;\n const receive = (event: MessageEvent) => {\n if (\n event.source !== frameRef.current?.contentWindow ||\n event.data?.type !== \"opengeni.preview.height\"\n )\n return;\n const value = event.data.height;\n if (typeof value === \"number\" && Number.isFinite(value))\n setHeight(Math.min(1200, Math.max(80, value)));\n };\n window.addEventListener(\"message\", receive);\n return () => window.removeEventListener(\"message\", receive);\n }, [props.autoHeight]);\n useEffect(() => {\n frameRef.current?.contentWindow?.postMessage(\n { type: \"opengeni.preview.theme\", theme: props.theme },\n \"*\",\n );\n }, [props.theme]);\n const bridgeRef = useRef(props.toolBridge);\n const onFrameLoadRef = useRef<() => void>(() => undefined);\n const frameLoadPendingRef = useRef(false);\n const toolBridgeEnabled = props.toolBridge !== undefined;\n useEffect(() => {\n bridgeRef.current = props.toolBridge;\n }, [props.toolBridge]);\n useEffect(() => {\n if (!toolBridgeEnabled || typeof window === \"undefined\") return;\n const requests = new SiteBridgeRequestRegistry();\n const attachToolPort = (data: unknown, ports: readonly MessagePort[]) => {\n const port = openGeniSiteBridgePortFromBootstrap(data, ports);\n if (!port) return;\n requests.addPort(port);\n port.addEventListener(\"message\", (portEvent: MessageEvent<unknown>) => {\n const message = portEvent.data;\n if (isOpenGeniSiteBridgeCancelMessage(message)) {\n requests.cancel(port, message.requestId);\n return;\n }\n if (isSiteHttpRequest(message) && portEvent.ports.length === 1) {\n const controller = requests.start(port, message.requestId);\n if (!controller) {\n portEvent.ports[0]!.close();\n return;\n }\n void serveSiteHttp(\n message,\n portEvent.ports[0]!,\n async (request, signal) => {\n const fetch = bridgeRef.current?.fetch;\n if (!fetch) throw new Error(\"This Site host does not support the session SDK\");\n return fetch(request, signal);\n },\n controller.signal,\n ).finally(() => requests.complete(port, message.requestId, controller));\n return;\n }\n if (!isOpenGeniSiteBridgeRequestMessage(message)) return;\n const controller = requests.start(port, message.requestId);\n if (!controller) {\n port.postMessage({\n type: OPENGENI_SITE_BRIDGE_RESPONSE,\n version: OPENGENI_SITE_BRIDGE_VERSION,\n requestId: message.requestId,\n ok: false,\n error: {\n code: \"duplicate_request_id\",\n message: \"A Site tool request with this id is already running\",\n retryable: false,\n },\n } satisfies OpenGeniSiteBridgeResponseMessage);\n return;\n }\n void handleSiteBridgeRequest(bridgeRef.current, message, controller.signal)\n .then((value) => {\n if (!controller.signal.aborted) {\n port.postMessage({\n type: OPENGENI_SITE_BRIDGE_RESPONSE,\n version: OPENGENI_SITE_BRIDGE_VERSION,\n requestId: message.requestId,\n ok: true,\n value,\n } satisfies OpenGeniSiteBridgeResponseMessage);\n }\n })\n .catch((error) => {\n if (!controller.signal.aborted) {\n port.postMessage({\n type: OPENGENI_SITE_BRIDGE_RESPONSE,\n version: OPENGENI_SITE_BRIDGE_VERSION,\n requestId: message.requestId,\n ok: false,\n error: siteBridgeError(error),\n } satisfies OpenGeniSiteBridgeResponseMessage);\n }\n })\n .finally(() => requests.complete(port, message.requestId, controller));\n });\n port.addEventListener(\"messageerror\", () => requests.closePort(port));\n port.start();\n port.postMessage({\n type: OPENGENI_SITE_BRIDGE_READY,\n version: OPENGENI_SITE_BRIDGE_VERSION,\n });\n };\n const documentLease = new SiteBridgeDocumentLease(attachToolPort, () => requests.closeAll());\n const onFrameLoad = () => {\n frameLoadPendingRef.current = false;\n const frameWindow = frameRef.current?.contentWindow ?? null;\n if (!frameWindow) return;\n documentLease.load(frameWindow);\n };\n onFrameLoadRef.current = onFrameLoad;\n if (frameLoadPendingRef.current) {\n frameLoadPendingRef.current = false;\n onFrameLoad();\n }\n return () => {\n onFrameLoadRef.current = () => undefined;\n documentLease.close();\n };\n }, [props.html, toolBridgeEnabled]);\n return (\n <iframe\n ref={frameRef}\n title={props.title}\n sandbox={PUBLISHED_HTML_ARTIFACT_IFRAME_SANDBOX}\n referrerPolicy=\"no-referrer\"\n srcDoc={publishedHtmlArtifactDocument(props.html, toolBridgeEnabled)}\n onLoad={() => {\n frameRef.current?.contentWindow?.postMessage(\n { type: \"opengeni.preview.theme\", theme: props.theme },\n \"*\",\n );\n frameLoadPendingRef.current = true;\n onFrameLoadRef.current();\n }}\n className={props.className}\n style={{ ...props.style, ...(props.autoHeight && height ? { height } : {}) }}\n />\n );\n}\n\nexport class SiteBridgeRequestRegistry {\n private readonly controllersByPort = new Map<MessagePort, Map<string, AbortController>>();\n\n addPort(port: MessagePort): void {\n // Several SDK clients may share one document bootstrap. Document teardown,\n // not another client connecting, revokes all of that document's ports.\n if (!this.controllersByPort.has(port)) this.controllersByPort.set(port, new Map());\n }\n\n start(port: MessagePort, requestId: string): AbortController | null {\n const controllers = this.controllersByPort.get(port);\n if (!controllers || controllers.has(requestId)) return null;\n const controller = new AbortController();\n controllers.set(requestId, controller);\n return controller;\n }\n\n cancel(port: MessagePort, requestId: string): void {\n const controllers = this.controllersByPort.get(port);\n const controller = controllers?.get(requestId);\n if (!controller) return;\n controller.abort(new Error(\"Site tool request cancelled\"));\n controllers!.delete(requestId);\n }\n\n complete(port: MessagePort, requestId: string, controller: AbortController): void {\n const controllers = this.controllersByPort.get(port);\n if (controllers?.get(requestId) === controller) controllers.delete(requestId);\n }\n\n closePort(port: MessagePort): void {\n const controllers = this.controllersByPort.get(port);\n if (!controllers) return;\n for (const controller of controllers.values()) {\n controller.abort(new Error(\"Site tool bridge port closed\"));\n }\n controllers.clear();\n this.controllersByPort.delete(port);\n port.close();\n }\n\n closeAll(): void {\n for (const port of [...this.controllersByPort.keys()]) this.closePort(port);\n }\n}\n\nexport class SiteBridgeDocumentLease {\n private loaded = false;\n private bootstrapPort: MessagePort | null = null;\n\n constructor(\n private readonly attachToolPort: (data: unknown, ports: readonly MessagePort[]) => void,\n private readonly closeActivePorts: () => void,\n private readonly createMessageChannel: () => MessageChannel = () => new MessageChannel(),\n ) {}\n\n load(frameWindow: Pick<Window, \"postMessage\">): boolean {\n if (this.loaded) {\n this.close();\n return false;\n }\n this.loaded = true;\n const channel = this.createMessageChannel();\n this.bootstrapPort = channel.port1;\n channel.port1.addEventListener(\"message\", (event: MessageEvent<unknown>) => {\n this.attachToolPort(event.data, event.ports);\n });\n channel.port1.start();\n frameWindow.postMessage(\n {\n type: OPENGENI_SITE_BRIDGE_READY,\n version: OPENGENI_SITE_BRIDGE_VERSION,\n },\n \"*\",\n [channel.port2],\n );\n return true;\n }\n\n close(): void {\n this.bootstrapPort?.close();\n this.bootstrapPort = null;\n this.closeActivePorts();\n }\n}\n\nexport function openGeniSiteBridgePortFromBootstrap(\n data: unknown,\n ports: readonly MessagePort[],\n): MessagePort | null {\n if (!isOpenGeniSiteBridgeConnectMessage(data)) return null;\n return ports.length === 1 ? ports[0]! : null;\n}\n\nasync function handleSiteBridgeRequest(\n bridge: PublishedHtmlArtifactToolBridge | undefined,\n message: Parameters<typeof isOpenGeniSiteBridgeRequestMessage>[0] & {\n method: \"catalog\" | \"call\" | \"declarations\";\n requestId: string;\n payload?: ToolGatewayCallRequest;\n },\n signal: AbortSignal,\n): Promise<OpenGeniSiteToolCatalog | ToolGatewayCallResponse | ToolGatewayDeclarationsResponse> {\n if (!bridge) throw new Error(\"Site tool bridge is unavailable\");\n if (message.method === \"catalog\") return await bridge.catalog({ signal });\n if (message.method === \"declarations\") {\n if (!bridge.declarations) throw new Error(\"Site tool declarations are unavailable\");\n return await bridge.declarations({ signal });\n }\n return await bridge.call(sanitizeOpenGeniSiteToolCallRequest(message.payload!), { signal });\n}\n\nexport function siteBridgeError(error: unknown): {\n code: string;\n message: string;\n retryable: boolean;\n outcomeUnknown: boolean;\n} {\n const candidate = error as {\n code?: unknown;\n message?: unknown;\n retryable?: unknown;\n outcomeUnknown?: unknown;\n };\n return {\n code: typeof candidate?.code === \"string\" ? candidate.code : \"site_tool_call_failed\",\n message:\n typeof candidate?.message === \"string\" ? candidate.message : \"Site tool request failed\",\n retryable: candidate?.retryable === true,\n outcomeUnknown: candidate?.outcomeUnknown === true,\n };\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAMP,SAAS,WAAW,QAAQ,gBAAoC;AAChE,SAAS,+BAA+B;AAsMpC;AApMG,IAAM,yCAAyC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK,GAAG;AAsBV,IAAM,+BAA+B,2BAA2B,KAAK;AAAA,EACnE;AACF,CAAC,wLAAwL,KAAK;AAAA,EAC5L;AACF,CAAC,oBAAoB,4BAA4B;AAE1C,SAAS,8BAA8B,MAAc,mBAAoC;AAC9F,MAAI,CAAC,kBAAmB,QAAO;AAC/B,SAAO,wBAAwB,IAAI;AACnC,QAAM,aAAa,kBAAkB,IAAI;AACzC,MAAI,cAAc,GAAG;AACnB,WAAO,GAAG,KAAK,MAAM,GAAG,aAAa,CAAC,CAAC,GAAG,4BAA4B,GAAG,KAAK,MAAM,aAAa,CAAC,CAAC;AAAA,EACrG;AACA,SAAO,GAAG,4BAA4B,GAAG,IAAI;AAC/C;AAEA,S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AG,QAAO;AACtD,SAAO,MAAM,WAAW,IAAI,MAAM,CAAC,IAAK;AAC1C;AAEA,eAAe,wBACb,QACA,SAKA,QAC8F;AAC9F,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,iCAAiC;AAC9D,MAAI,QAAQ,WAAW,UAAW,QAAO,MAAM,OAAO,QAAQ,EAAE,OAAO,CAAC;AACxE,MAAI,QAAQ,WAAW,gBAAgB;AACrC,QAAI,CAAC,OAAO,aAAc,OAAM,IAAI,MAAM,wCAAwC;AAClF,WAAO,MAAM,OAAO,aAAa,EAAE,OAAO,CAAC;AAAA,EAC7C;AACA,SAAO,MAAM,OAAO,KAAK,oCAAoC,QAAQ,OAAQ,GAAG,EAAE,OAAO,CAAC;AAC5F;AAEO,SAAS,gBAAgB,OAK9B;AACA,QAAM,YAAY;AAMlB,SAAO;AAAA,IACL,MAAM,OAAO,WAAW,SAAS,WAAW,UAAU,OAAO;AAAA,IAC7D,SACE,OAAO,WAAW,YAAY,WAAW,UAAU,UAAU;AAAA,IAC/D,WAAW,WAAW,cAAc;AAAA,IACpC,gBAAgB,WAAW,mBAAmB;AAAA,EAChD;AACF;","names":["controller"]}
@@ -2,7 +2,7 @@ import {
2
2
  buildTimeline,
3
3
  groupTimeline,
4
4
  sessionStatusFromEvents
5
- } from "./chunk-ASCSKOWU.js";
5
+ } from "./chunk-V2ABIVYJ.js";
6
6
  import {
7
7
  useDebouncedCallback,
8
8
  useMutationRunner,
@@ -830,7 +830,7 @@ function useSessionEvents(sessionId, options = {}) {
830
830
  let generation = navigationGenerationRef.current;
831
831
  const current = () => ownsNavigation() && generation === navigationGenerationRef.current;
832
832
  try {
833
- const { resolveLatestQuestion } = await import("./latest-question-3HGQUI2E.js");
833
+ const { resolveLatestQuestion } = await import("./latest-question-QB4EUCW5.js");
834
834
  if (!current()) return null;
835
835
  const destination = await resolveLatestQuestion({
836
836
  client,
@@ -2308,4 +2308,4 @@ export {
2308
2308
  projectPendingApprovals,
2309
2309
  conversationTimeline
2310
2310
  };
2311
- //# sourceMappingURL=chunk-OQVBTOBJ.js.map
2311
+ //# sourceMappingURL=chunk-USXVQACU.js.map
@@ -255,10 +255,6 @@ function asRecord(value) {
255
255
  }
256
256
 
257
257
  // src/timeline/projection.ts
258
- import {
259
- allowanceExhaustedMessage,
260
- parseAllowanceExhaustedRefusal
261
- } from "@opengeni/sdk/allowance-refusal";
262
258
  function isTimelineUserQuestion(event) {
263
259
  return event.type === "user.message" && workerCompletionPayload(asRecord2(event.payload).childCompletion) === null;
264
260
  }
@@ -305,31 +301,6 @@ function timelineAnnotationToolOutputText(output) {
305
301
  }
306
302
  function buildTimeline(events, options = {}) {
307
303
  const items = [];
308
- const allowanceNotices = /* @__PURE__ */ new Set();
309
- const allowanceNotice = (event, turnId) => {
310
- const refusal = parseAllowanceExhaustedRefusal(event.payload);
311
- if (!refusal) return null;
312
- const text = allowanceExhaustedMessage(refusal);
313
- const key = JSON.stringify([
314
- turnId,
315
- event.turnAttemptId,
316
- startupRecoveryRevisionByTurn.get(turnId ?? "") ?? 0,
317
- refusal.scope,
318
- refusal.subjectId,
319
- refusal.resetsAt
320
- ]);
321
- if (!allowanceNotices.has(key)) {
322
- allowanceNotices.add(key);
323
- items.push({
324
- kind: "notice",
325
- id: `${event.id}-allowance`,
326
- tone: "failed",
327
- text,
328
- occurredAt: event.occurredAt
329
- });
330
- }
331
- return text;
332
- };
333
304
  const prescan = prescanTurnAnchors(events);
334
305
  const ordered = orderTimelineEvents(events, prescan);
335
306
  let completeHistoryPrefix = options.partialStart !== true;
@@ -1078,10 +1049,6 @@ ${message}` : message;
1078
1049
  });
1079
1050
  break;
1080
1051
  }
1081
- case "usage.exhausted": {
1082
- allowanceNotice(event, turnId);
1083
- break;
1084
- }
1085
1052
  case "turn.completed": {
1086
1053
  if (payload.maintenance === "context_compaction") {
1087
1054
  finalizeOpen(turnId, "complete", event.occurredAt);
@@ -1089,16 +1056,6 @@ ${message}` : message;
1089
1056
  takePendingWaitOutcome(turnId);
1090
1057
  break;
1091
1058
  }
1092
- const allowance = parseAllowanceExhaustedRefusal(payload);
1093
- if (allowance) {
1094
- finalizeOpen(turnId, "complete", event.occurredAt);
1095
- takeAgentResponse(turnId);
1096
- takePendingWaitOutcome(turnId);
1097
- const text = allowanceExhaustedMessage(allowance);
1098
- items.push(turnEndItem(event, "failed", text));
1099
- allowanceNotice(event, turnId);
1100
- break;
1101
- }
1102
1059
  if (isCreditExhaustionPayload(payload)) {
1103
1060
  finalizeOpen(turnId, "complete", event.occurredAt);
1104
1061
  takeAgentResponse(turnId);
@@ -1172,13 +1129,10 @@ ${message}` : message;
1172
1129
  takeAgentResponse(turnId);
1173
1130
  takePendingWaitOutcome(turnId);
1174
1131
  const hadActivity = hasTurnActivity(items, turnId);
1175
- const allowance = parseAllowanceExhaustedRefusal(payload);
1176
- const failureText = allowance ? allowanceExhaustedMessage(allowance) : isCreditExhaustionPayload(payload) ? CREDIT_EXHAUSTION_MESSAGE : failureMessage(payload);
1132
+ const failureText = isCreditExhaustionPayload(payload) ? CREDIT_EXHAUSTION_MESSAGE : failureMessage(payload);
1177
1133
  finalizeOpen(turnId, "cancelled", event.occurredAt);
1178
1134
  items.push(turnEndItem(event, "failed", failureText));
1179
- if (allowance) {
1180
- allowanceNotice(event, turnId);
1181
- } else if (!hadActivity) {
1135
+ if (!hadActivity) {
1182
1136
  items.push({
1183
1137
  kind: "notice",
1184
1138
  id: event.id,
@@ -1446,7 +1400,6 @@ function stripOpaqueCitationTokens(text) {
1446
1400
  return text.replace(/\s*cite(?:[^]+)+/gu, "");
1447
1401
  }
1448
1402
  function isCreditExhaustionPayload(payload) {
1449
- if (payload.code === "allowance_exhausted") return false;
1450
1403
  return isCreditExhaustion({
1451
1404
  error: typeof payload.error === "string" ? payload.error : null,
1452
1405
  detail: typeof payload.detail === "string" ? payload.detail : null,
@@ -2555,4 +2508,4 @@ export {
2555
2508
  isTurnExecutionEvidence,
2556
2509
  extractSessionRef
2557
2510
  };
2558
- //# sourceMappingURL=chunk-ASCSKOWU.js.map
2511
+ //# sourceMappingURL=chunk-V2ABIVYJ.js.map