@opengeni/react 0.52.1 → 0.57.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 (132) hide show
  1. package/README.md +48 -0
  2. package/dist/artifacts.d.ts +1 -1
  3. package/dist/artifacts.js +43 -14
  4. package/dist/artifacts.js.map +1 -1
  5. package/dist/{chunk-ROIRTM37.js → chunk-5UQPNLIO.js} +6 -6
  6. package/dist/{chunk-JR3QFY6B.js → chunk-6KLX2RH5.js} +49 -2
  7. package/dist/chunk-6KLX2RH5.js.map +1 -0
  8. package/dist/{chunk-FWS3KC3Z.js → chunk-B6WPZSTT.js} +104 -104
  9. package/dist/{chunk-FWS3KC3Z.js.map → chunk-B6WPZSTT.js.map} +1 -1
  10. package/dist/{chunk-HDBG7XGO.js → chunk-C5ZPSSS5.js} +50 -1
  11. package/dist/chunk-C5ZPSSS5.js.map +1 -0
  12. package/dist/{chunk-X4S56Y2H.js → chunk-HA46CYQK.js} +135 -11
  13. package/dist/chunk-HA46CYQK.js.map +1 -0
  14. package/dist/{chunk-724BW4TW.js → chunk-IGC6A2ZI.js} +2 -2
  15. package/dist/chunk-LLOLUHVG.js +5937 -0
  16. package/dist/chunk-LLOLUHVG.js.map +1 -0
  17. package/dist/{chunk-WYA65Y3F.js → chunk-MKPIAGVL.js} +13 -3
  18. package/dist/chunk-MKPIAGVL.js.map +1 -0
  19. package/dist/chunk-R3AZOAB5.js +933 -0
  20. package/dist/chunk-R3AZOAB5.js.map +1 -0
  21. package/dist/{chunk-23EJ676W.js → chunk-XBZWOM2K.js} +9 -4
  22. package/dist/chunk-XBZWOM2K.js.map +1 -0
  23. package/dist/{chunk-JAGDUCZQ.js → chunk-Y7OEDUJ5.js} +17 -13
  24. package/dist/chunk-Y7OEDUJ5.js.map +1 -0
  25. package/dist/client.d.ts +6 -4
  26. package/dist/components/artifacts/index.d.ts +1 -0
  27. package/dist/components/artifacts/published-html-artifact-frame.d.ts +14 -0
  28. package/dist/components/browser-input.d.ts +7 -0
  29. package/dist/components/browser-viewer.d.ts +5 -4
  30. package/dist/components/computer-viewer.d.ts +2 -1
  31. package/dist/components/desktop-viewer.d.ts +26 -2
  32. package/dist/components/interaction-intervention-banner.d.ts +11 -0
  33. package/dist/components/sandbox-terminal.d.ts +4 -1
  34. package/dist/components/sandbox-workspace.d.ts +3 -0
  35. package/dist/composer.js +6 -6
  36. package/dist/hooks/use-auth-runs.d.ts +32 -0
  37. package/dist/hooks/use-browser-downloads.d.ts +25 -0
  38. package/dist/hooks/use-browser-identities.d.ts +5 -1
  39. package/dist/hooks/use-browser-session.d.ts +2 -1
  40. package/dist/hooks/use-browser-sessions.d.ts +1 -1
  41. package/dist/hooks/use-channels.d.ts +26 -0
  42. package/dist/hooks/use-computer-frame-stream.d.ts +1 -1
  43. package/dist/hooks/use-computer-session.d.ts +2 -1
  44. package/dist/hooks/use-computer-sessions.d.ts +1 -1
  45. package/dist/hooks/use-desktop-stream.d.ts +4 -0
  46. package/dist/hooks/use-interaction-interventions.d.ts +27 -0
  47. package/dist/hooks/use-interaction-invalidation.d.ts +19 -0
  48. package/dist/hooks/use-network-routes.d.ts +25 -0
  49. package/dist/hooks/use-site-auth-connections.d.ts +25 -0
  50. package/dist/hooks/use-supergrok-accounts.d.ts +26 -0
  51. package/dist/hooks/use-terminal-stream.d.ts +3 -0
  52. package/dist/index.d.ts +4 -0
  53. package/dist/index.js +1220 -1545
  54. package/dist/index.js.map +1 -1
  55. package/dist/interaction.d.ts +13 -3
  56. package/dist/interaction.js +520 -6
  57. package/dist/interaction.js.map +1 -1
  58. package/dist/interactive-workbench-viewers-TOHBXJEE.js +15 -0
  59. package/dist/lib/host-platform.d.ts +5 -0
  60. package/dist/lib/relay-wire.d.ts +20 -1
  61. package/dist/machines.js +3 -3
  62. package/dist/model-policy.d.ts +1 -1
  63. package/dist/model-policy.js +1 -1
  64. package/dist/provider.d.ts +3 -2
  65. package/dist/realtime/realtime-control.d.ts +2 -2
  66. package/dist/realtime.js +36 -9
  67. package/dist/realtime.js.map +1 -1
  68. package/dist/session-context.d.ts +10 -2
  69. package/dist/session-ui.js +3 -3
  70. package/dist/session.js +11 -11
  71. package/dist/timeline/types.d.ts +5 -0
  72. package/package.json +2 -2
  73. package/src/artifacts.ts +3 -0
  74. package/src/client.ts +73 -3
  75. package/src/components/artifacts/index.ts +5 -0
  76. package/src/components/artifacts/published-html-artifact-frame.tsx +38 -0
  77. package/src/components/browser-input.ts +65 -0
  78. package/src/components/browser-viewer.tsx +1287 -177
  79. package/src/components/computer-viewer.tsx +611 -114
  80. package/src/components/desktop-viewer.tsx +114 -1
  81. package/src/components/interaction-intervention-banner.tsx +99 -0
  82. package/src/components/machines/machine-detail.tsx +1 -1
  83. package/src/components/model-policy-picker.tsx +15 -0
  84. package/src/components/sandbox-terminal.tsx +24 -7
  85. package/src/components/sandbox-workspace.tsx +42 -4
  86. package/src/components/workspace-dock.tsx +59 -5
  87. package/src/hooks/use-attached-browsers.ts +13 -11
  88. package/src/hooks/use-auth-runs.ts +278 -0
  89. package/src/hooks/use-browser-downloads.ts +218 -0
  90. package/src/hooks/use-browser-frame-stream.ts +168 -59
  91. package/src/hooks/use-browser-identities.ts +47 -6
  92. package/src/hooks/use-browser-session.ts +94 -27
  93. package/src/hooks/use-browser-sessions.ts +19 -14
  94. package/src/hooks/use-channels.ts +99 -0
  95. package/src/hooks/use-computer-frame-stream.ts +184 -61
  96. package/src/hooks/use-computer-session.ts +22 -2
  97. package/src/hooks/use-computer-sessions.ts +19 -13
  98. package/src/hooks/use-desktop-stream.ts +39 -7
  99. package/src/hooks/use-interaction-interventions.ts +242 -0
  100. package/src/hooks/use-interaction-invalidation.ts +66 -0
  101. package/src/hooks/use-machine-chip.ts +13 -3
  102. package/src/hooks/use-network-routes.ts +214 -0
  103. package/src/hooks/use-site-auth-connections.ts +226 -0
  104. package/src/hooks/use-supergrok-accounts.ts +81 -0
  105. package/src/hooks/use-terminal-stream.ts +288 -55
  106. package/src/index.ts +8 -0
  107. package/src/interaction.ts +30 -0
  108. package/src/lib/host-platform.ts +10 -0
  109. package/src/lib/relay-wire.ts +43 -4
  110. package/src/lib/terminal-capability.ts +1 -1
  111. package/src/model-policy.ts +19 -4
  112. package/src/provider.tsx +133 -1
  113. package/src/realtime/realtime-control.tsx +34 -6
  114. package/src/session-context.ts +66 -1
  115. package/src/timeline/activity-rail.tsx +6 -0
  116. package/src/timeline/projection.ts +58 -0
  117. package/src/timeline/types.ts +2 -0
  118. package/styles/compiled.css +64 -6
  119. package/dist/chunk-23EJ676W.js.map +0 -1
  120. package/dist/chunk-6BBWWOOU.js +0 -82
  121. package/dist/chunk-6BBWWOOU.js.map +0 -1
  122. package/dist/chunk-7I2KB3OK.js +0 -3895
  123. package/dist/chunk-7I2KB3OK.js.map +0 -1
  124. package/dist/chunk-HDBG7XGO.js.map +0 -1
  125. package/dist/chunk-JAGDUCZQ.js.map +0 -1
  126. package/dist/chunk-JR3QFY6B.js.map +0 -1
  127. package/dist/chunk-WYA65Y3F.js.map +0 -1
  128. package/dist/chunk-X4S56Y2H.js.map +0 -1
  129. package/dist/interactive-workbench-viewers-KHNOHWQE.js +0 -13
  130. /package/dist/{chunk-ROIRTM37.js.map → chunk-5UQPNLIO.js.map} +0 -0
  131. /package/dist/{chunk-724BW4TW.js.map → chunk-IGC6A2ZI.js.map} +0 -0
  132. /package/dist/{interactive-workbench-viewers-KHNOHWQE.js.map → interactive-workbench-viewers-TOHBXJEE.js.map} +0 -0
package/README.md CHANGED
@@ -381,6 +381,49 @@ loading, realtime-first creation, Codex Live, Gateway models, mute, recovery,
381
381
  delegation/context timeline updates, structured questions, and stop/restart
382
382
  through published package APIs only.
383
383
 
384
+ ## Browser and computer surfaces (`@opengeni/react/interaction`)
385
+
386
+ The interaction subpath renders the same browser-native and semantic computer
387
+ surfaces used by the OpenGeni web app. It consumes only the public SDK client:
388
+ workspace discovery, peer switching, tabs/windows, live frames, human input,
389
+ identity versions, interventions, diagnostics, reconnect, and lifecycle state do
390
+ not require app-private controller glue.
391
+
392
+ ```tsx
393
+ import { OpenGeniProvider } from "@opengeni/react";
394
+ import { BrowserViewer, ComputerViewer } from "@opengeni/react/interaction";
395
+
396
+ <OpenGeniProvider client={client} workspaceId={workspaceId}>
397
+ <BrowserViewer
398
+ sessionId={sessionId}
399
+ onOpenComputer={(computerSessionId) => setSelectedComputer(computerSessionId)}
400
+ />
401
+ {selectedComputer ? (
402
+ <ComputerViewer
403
+ sessionId={sessionId}
404
+ requestedComputerSessionId={selectedComputer}
405
+ requestedComputerRequestId={selectedComputer}
406
+ />
407
+ ) : null}
408
+ </OpenGeniProvider>;
409
+ ```
410
+
411
+ `BrowserViewer` follows the current agent until the human pins another workspace
412
+ browser. A headed managed browser can receive `createLinkedComputer`; the
413
+ returned ComputerSession must be the exact placement/window the browser uses.
414
+ `onOpenComputer` then changes the host layout to that resource—it must not open a
415
+ lookalike desktop. Closing either viewer never ends its durable resource.
416
+
417
+ The provider opens one shared workspace interaction-revision stream and every
418
+ catalog refreshes only when its revision advances; hidden or disconnected pages
419
+ fall back to bounded polling and reconcile from the retained cursor. Hosts that
420
+ do not use `OpenGeniProvider` may pass the same structural `client` and
421
+ `workspaceId` directly.
422
+
423
+ Run `bun run demo` and open `browser.html` or `computer.html`. Their `mode=mock`
424
+ paths are deterministic; `mode=live&workspaceId=…&sessionId=…` uses the
425
+ same-origin `/demo-api` proxy and the exact published SDK/React entrypoints.
426
+
384
427
  ## Composer customization (`@opengeni/react/composer`)
385
428
 
386
429
  Use `ChatComposer` for the standard layout and its `controlsStart`, `header`,
@@ -531,6 +574,11 @@ so consumers can render attachment chips. `groupTimeline` clusters consecutive
531
574
  activity for collapsed display. Use them directly if you want custom rendering
532
575
  with the same semantics.
533
576
 
577
+ Failed worker items may also carry `failure: { code, message }`. The projection
578
+ accepts only the bounded structured orchestration envelope retained in MCP
579
+ output; it does not reinterpret arbitrary legacy error strings. `ActivityRail`
580
+ renders the code and message directly beneath the failed worker row.
581
+
534
582
  ### Compatibility
535
583
 
536
584
  The projection is a tolerant reader over `SessionEvent.payload` because the wire
@@ -1,2 +1,2 @@
1
1
  /** Public artifact surfaces. Import from `@opengeni/react/artifacts`. */
2
- export { ArtifactSurface, DocumentArtifactSurface, DocumentEditor, DocumentProjectionArtifactSurface, DocumentProjectionEditor, BrowserEditableArtifactWorkbench, EditableDocumentArtifactSurface, EditableArtifactWorkbench, EditableArtifactWorkbenchHost, EditablePresentationArtifactSurface, EditableSpreadsheetArtifactSurface, EditableSpreadsheetGrid, PresentationArtifactSurface, PresentationEditor, PresentationProjectionArtifactSurface, PresentationProjectionEditor, SpreadsheetArtifactSurface, SpreadsheetGrid, SpreadsheetProjectionGrid, type ArtifactModality, type ArtifactSurfaceProps, type DocumentArtifactSurfaceProps, type DocumentCommit, type DocumentCommitHandler, type DocumentEditorProps, type DocumentEditorProjection, type DocumentLayoutMode, type DocumentProjectionArtifactSurfaceProps, type DocumentProjectionBlock, type DocumentProjectionChange, type DocumentProjectionComment, type DocumentProjectionEditorProps, type DocumentProjectionPageBreak, type DocumentProjectionPageGeometry, type DocumentProjectionParagraph, type DocumentProjectionParagraphStyle, type DocumentProjectionSection, type DocumentProjectionTable, type DocumentProjectionTextRun, type DocumentProjectionTextStyle, type DocumentSelection, type BrowserEditableArtifactWorkbenchOptions, type BrowserEditableArtifactWorkbenchProps, type EditableDocumentArtifactSurfaceProps, type EditableArtifactWorkbenchHostProps, type EditableArtifactWorkbenchProps, type EditablePresentationArtifactSurfaceProps, type EditableSpreadsheetArtifactSurfaceProps, type EditableSpreadsheetGridProps, type PresentationArtifactSurfaceProps, type PresentationCommit, type PresentationCommitHandler, type PresentationEditorProps, type PresentationEditorProjection, type PresentationProjectionArtifactSurfaceProps, type PresentationProjectionChart, type PresentationProjectionChartSeries, type PresentationProjectionConnector, type PresentationProjectionEditorProps, type PresentationProjectionElementMetadata, type PresentationProjectionElement, type PresentationProjectionFill, type PresentationProjectionGroup, type PresentationProjectionImage, type PresentationProjectionLine, type PresentationProjectionPosition, type PresentationProjectionRichText, type PresentationProjectionShape, type PresentationProjectionTable, type PresentationProjectionTableCell, type PresentationProjectionTextParagraph, type PresentationProjectionTextRun, type PresentationProjectionTextStyle, type PresentationSlideProjection, type SpreadsheetArtifactSurfaceProps, type SpreadsheetCommit, type SpreadsheetRangeCommit, type SpreadsheetGridProps, type SpreadsheetGridProjection, type SpreadsheetProjectionCell, type SpreadsheetProjectionGridProps, type SpreadsheetSelection, type SpreadsheetViewport, } from "./components/artifacts/index.js";
2
+ export { ArtifactSurface, DocumentArtifactSurface, DocumentEditor, DocumentProjectionArtifactSurface, DocumentProjectionEditor, BrowserEditableArtifactWorkbench, EditableDocumentArtifactSurface, EditableArtifactWorkbench, EditableArtifactWorkbenchHost, EditablePresentationArtifactSurface, EditableSpreadsheetArtifactSurface, EditableSpreadsheetGrid, PresentationArtifactSurface, PresentationEditor, PresentationProjectionArtifactSurface, PresentationProjectionEditor, PublishedHtmlArtifactFrame, PUBLISHED_HTML_ARTIFACT_IFRAME_SANDBOX, SpreadsheetArtifactSurface, SpreadsheetGrid, SpreadsheetProjectionGrid, type ArtifactModality, type ArtifactSurfaceProps, type DocumentArtifactSurfaceProps, type DocumentCommit, type DocumentCommitHandler, type DocumentEditorProps, type DocumentEditorProjection, type DocumentLayoutMode, type DocumentProjectionArtifactSurfaceProps, type DocumentProjectionBlock, type DocumentProjectionChange, type DocumentProjectionComment, type DocumentProjectionEditorProps, type DocumentProjectionPageBreak, type DocumentProjectionPageGeometry, type DocumentProjectionParagraph, type DocumentProjectionParagraphStyle, type DocumentProjectionSection, type DocumentProjectionTable, type DocumentProjectionTextRun, type DocumentProjectionTextStyle, type DocumentSelection, type BrowserEditableArtifactWorkbenchOptions, type BrowserEditableArtifactWorkbenchProps, type EditableDocumentArtifactSurfaceProps, type EditableArtifactWorkbenchHostProps, type EditableArtifactWorkbenchProps, type EditablePresentationArtifactSurfaceProps, type EditableSpreadsheetArtifactSurfaceProps, type EditableSpreadsheetGridProps, type PresentationArtifactSurfaceProps, type PresentationCommit, type PresentationCommitHandler, type PresentationEditorProps, type PresentationEditorProjection, type PresentationProjectionArtifactSurfaceProps, type PresentationProjectionChart, type PresentationProjectionChartSeries, type PresentationProjectionConnector, type PresentationProjectionEditorProps, type PublishedHtmlArtifactFrameProps, type PresentationProjectionElementMetadata, type PresentationProjectionElement, type PresentationProjectionFill, type PresentationProjectionGroup, type PresentationProjectionImage, type PresentationProjectionLine, type PresentationProjectionPosition, type PresentationProjectionRichText, type PresentationProjectionShape, type PresentationProjectionTable, type PresentationProjectionTableCell, type PresentationProjectionTextParagraph, type PresentationProjectionTextRun, type PresentationProjectionTextStyle, type PresentationSlideProjection, type SpreadsheetArtifactSurfaceProps, type SpreadsheetCommit, type SpreadsheetRangeCommit, type SpreadsheetGridProps, type SpreadsheetGridProjection, type SpreadsheetProjectionCell, type SpreadsheetProjectionGridProps, type SpreadsheetSelection, type SpreadsheetViewport, } from "./components/artifacts/index.js";
package/dist/artifacts.js CHANGED
@@ -1,10 +1,3 @@
1
- import {
2
- DocumentArtifactSurface,
3
- DocumentEditor,
4
- DocumentProjectionArtifactSurface,
5
- DocumentProjectionEditor,
6
- EditableDocumentArtifactSurface
7
- } from "./chunk-HUIKIDM5.js";
8
1
  import {
9
2
  EditablePresentationArtifactSurface,
10
3
  PresentationArtifactSurface,
@@ -19,18 +12,52 @@ import {
19
12
  SpreadsheetGrid,
20
13
  SpreadsheetProjectionGrid
21
14
  } from "./chunk-7WCLAEFV.js";
15
+ import {
16
+ DocumentArtifactSurface,
17
+ DocumentEditor,
18
+ DocumentProjectionArtifactSurface,
19
+ DocumentProjectionEditor,
20
+ EditableDocumentArtifactSurface
21
+ } from "./chunk-HUIKIDM5.js";
22
22
  import {
23
23
  ArtifactSurface,
24
24
  EditableArtifactMessage
25
25
  } from "./chunk-KCGXPP5V.js";
26
26
  import "./chunk-22KP6LR5.js";
27
27
 
28
+ // src/components/artifacts/published-html-artifact-frame.tsx
29
+ import { jsx } from "react/jsx-runtime";
30
+ var PUBLISHED_HTML_ARTIFACT_IFRAME_SANDBOX = [
31
+ "allow-downloads",
32
+ "allow-forms",
33
+ "allow-modals",
34
+ "allow-orientation-lock",
35
+ "allow-pointer-lock",
36
+ "allow-popups",
37
+ "allow-popups-to-escape-sandbox",
38
+ "allow-presentation",
39
+ "allow-scripts"
40
+ ].join(" ");
41
+ function PublishedHtmlArtifactFrame(props) {
42
+ return /* @__PURE__ */ jsx(
43
+ "iframe",
44
+ {
45
+ title: props.title,
46
+ sandbox: PUBLISHED_HTML_ARTIFACT_IFRAME_SANDBOX,
47
+ referrerPolicy: "no-referrer",
48
+ srcDoc: props.html,
49
+ className: props.className,
50
+ style: props.style
51
+ }
52
+ );
53
+ }
54
+
28
55
  // src/components/artifacts/editable-artifact-workbench.tsx
29
56
  import {
30
57
  createBrowserEditableArtifactSession
31
58
  } from "@opengeni/sdk/editable-artifacts";
32
59
  import { useCallback, useEffect, useRef, useState } from "react";
33
- import { jsx } from "react/jsx-runtime";
60
+ import { jsx as jsx2 } from "react/jsx-runtime";
34
61
  function EditableArtifactWorkbench({
35
62
  session,
36
63
  document,
@@ -39,7 +66,7 @@ function EditableArtifactWorkbench({
39
66
  }) {
40
67
  switch (session.modality) {
41
68
  case "document":
42
- return /* @__PURE__ */ jsx(
69
+ return /* @__PURE__ */ jsx2(
43
70
  EditableDocumentArtifactSurface,
44
71
  {
45
72
  ...document,
@@ -48,9 +75,9 @@ function EditableArtifactWorkbench({
48
75
  }
49
76
  );
50
77
  case "spreadsheet":
51
- return /* @__PURE__ */ jsx(EditableSpreadsheetArtifactSurface, { ...spreadsheet, session });
78
+ return /* @__PURE__ */ jsx2(EditableSpreadsheetArtifactSurface, { ...spreadsheet, session });
52
79
  case "presentation":
53
- return /* @__PURE__ */ jsx(EditablePresentationArtifactSurface, { ...presentation, session });
80
+ return /* @__PURE__ */ jsx2(EditablePresentationArtifactSurface, { ...presentation, session });
54
81
  }
55
82
  }
56
83
  function EditableArtifactWorkbenchHost({
@@ -88,7 +115,7 @@ function EditableArtifactWorkbenchHost({
88
115
  const retry = useCallback(() => setRetryEpoch((value) => value + 1), []);
89
116
  const currentError = state.key === sessionKey ? state.error : null;
90
117
  if (state.key === sessionKey && state.session) {
91
- return /* @__PURE__ */ jsx(
118
+ return /* @__PURE__ */ jsx2(
92
119
  EditableArtifactWorkbench,
93
120
  {
94
121
  session: state.session,
@@ -98,7 +125,7 @@ function EditableArtifactWorkbenchHost({
98
125
  }
99
126
  );
100
127
  }
101
- return /* @__PURE__ */ jsx(
128
+ return /* @__PURE__ */ jsx2(
102
129
  EditableArtifactMessage,
103
130
  {
104
131
  title: currentError ? "Could not open this artifact" : "Opening artifact",
@@ -115,7 +142,7 @@ function BrowserEditableArtifactWorkbench({
115
142
  }) {
116
143
  const sessionKey = browserSessionKey(options);
117
144
  const createSession = useCallback(() => createBrowserEditableArtifactSession(options), [options]);
118
- return /* @__PURE__ */ jsx(
145
+ return /* @__PURE__ */ jsx2(
119
146
  EditableArtifactWorkbenchHost,
120
147
  {
121
148
  sessionKey,
@@ -159,10 +186,12 @@ export {
159
186
  EditablePresentationArtifactSurface,
160
187
  EditableSpreadsheetArtifactSurface,
161
188
  EditableSpreadsheetGrid,
189
+ PUBLISHED_HTML_ARTIFACT_IFRAME_SANDBOX,
162
190
  PresentationArtifactSurface,
163
191
  PresentationEditor,
164
192
  PresentationProjectionArtifactSurface,
165
193
  PresentationProjectionEditor,
194
+ PublishedHtmlArtifactFrame,
166
195
  SpreadsheetArtifactSurface,
167
196
  SpreadsheetGrid,
168
197
  SpreadsheetProjectionGrid
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/artifacts/editable-artifact-workbench.tsx"],"sourcesContent":["import {\n createBrowserEditableArtifactSession,\n type CreateBrowserEditableArtifactSessionOptions,\n type EditableArtifactBrowserRuntime,\n type EditableArtifactSession,\n} from \"@opengeni/sdk/editable-artifacts\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { EditableArtifactMessage } from \"./editable-artifact-ui\";\nimport {\n EditableDocumentArtifactSurface,\n type EditableDocumentArtifactSurfaceProps,\n} from \"./editable-document\";\nimport {\n EditablePresentationArtifactSurface,\n type EditablePresentationArtifactSurfaceProps,\n} from \"./editable-presentation\";\nimport {\n EditableSpreadsheetArtifactSurface,\n type EditableSpreadsheetArtifactSurfaceProps,\n} from \"./editable-spreadsheet\";\n\nexport type EditableArtifactWorkbenchProps = Readonly<{\n session: EditableArtifactSession;\n document?: Omit<EditableDocumentArtifactSurfaceProps, \"session\">;\n spreadsheet?: Omit<EditableSpreadsheetArtifactSurfaceProps, \"session\">;\n presentation?: Omit<EditablePresentationArtifactSurfaceProps, \"session\">;\n}>;\n\nexport type EditableArtifactWorkbenchHostProps = Omit<EditableArtifactWorkbenchProps, \"session\"> &\n Readonly<{\n /**\n * Complete identity of the browser session authority. Change this when the\n * artifact, deployment, principal, or authorization epoch changes.\n */\n sessionKey: string;\n /** Called for the active keyed lifecycle and again only after replacement or retry. */\n createSession: () => EditableArtifactSession;\n }>;\n\ntype DefaultBrowserArtifactTransport = Omit<\n NonNullable<CreateBrowserEditableArtifactSessionOptions[\"transport\"]>,\n \"apiKey\" | \"fetch\" | \"headers\" | \"webSocketFactory\"\n> &\n Readonly<{\n /** Static deployment auth headers; rotate authorizationEpoch when they change. */\n headers?: Readonly<Record<string, string>>;\n }>;\n\nexport type BrowserEditableArtifactWorkbenchOptions = Omit<\n CreateBrowserEditableArtifactSessionOptions,\n \"runtime\" | \"storage\" | \"transport\"\n> &\n Readonly<{\n /** Default module Worker only; custom Worker hosts use EditableArtifactWorkbenchHost. */\n runtime: Omit<EditableArtifactBrowserRuntime, \"workerFactory\">;\n /** Default fetch/WebSocket only; static deployment auth headers are supported. */\n transport?: DefaultBrowserArtifactTransport;\n }>;\n\nexport type BrowserEditableArtifactWorkbenchProps = Omit<\n EditableArtifactWorkbenchProps,\n \"session\"\n> &\n Readonly<{ options: BrowserEditableArtifactWorkbenchOptions }>;\n\n/**\n * One modality-neutral SDK workbench. Embedding hosts keep one route/component;\n * each artifact still renders through its complete first-party editor surface.\n */\nexport function EditableArtifactWorkbench({\n session,\n document,\n spreadsheet,\n presentation,\n}: EditableArtifactWorkbenchProps) {\n switch (session.modality) {\n case \"document\":\n return (\n <EditableDocumentArtifactSurface\n {...document}\n session={session}\n title={document?.title ?? \"Document\"}\n />\n );\n case \"spreadsheet\":\n return <EditableSpreadsheetArtifactSurface {...spreadsheet} session={session} />;\n case \"presentation\":\n return <EditablePresentationArtifactSurface {...presentation} session={session} />;\n }\n}\n\n/**\n * Route/embed composition that owns exactly one SDK session. The host supplies\n * the authenticated SDK factory; React guarantees replacement and teardown.\n */\nexport function EditableArtifactWorkbenchHost({\n sessionKey,\n createSession,\n document,\n spreadsheet,\n presentation,\n}: EditableArtifactWorkbenchHostProps) {\n const createSessionRef = useRef(createSession);\n const [retryEpoch, setRetryEpoch] = useState(0);\n const [state, setState] = useState<\n | Readonly<{ key: string; session: EditableArtifactSession; error: null }>\n | Readonly<{ key: string | null; session: null; error: Error | null }>\n >({ key: null, session: null, error: null });\n\n useEffect(() => {\n createSessionRef.current = createSession;\n }, [createSession]);\n\n useEffect(() => {\n let owned: EditableArtifactSession | null = null;\n setState({ key: sessionKey, session: null, error: null });\n try {\n owned = createSessionRef.current();\n setState({ key: sessionKey, session: owned, error: null });\n } catch (cause) {\n setState({\n key: sessionKey,\n session: null,\n error: cause instanceof Error ? cause : new Error(\"Could not create artifact session\"),\n });\n }\n return () => {\n const closing = owned;\n owned = null;\n if (closing) void closing.close().catch(() => undefined);\n };\n }, [retryEpoch, sessionKey]);\n\n const retry = useCallback(() => setRetryEpoch((value) => value + 1), []);\n const currentError = state.key === sessionKey ? state.error : null;\n if (state.key === sessionKey && state.session) {\n return (\n <EditableArtifactWorkbench\n session={state.session}\n {...(document ? { document } : {})}\n {...(spreadsheet ? { spreadsheet } : {})}\n {...(presentation ? { presentation } : {})}\n />\n );\n }\n return (\n <EditableArtifactMessage\n title={currentError ? \"Could not open this artifact\" : \"Opening artifact\"}\n detail={currentError?.message ?? \"Starting the secure editing session…\"}\n retry={currentError ? retry : undefined}\n />\n );\n}\n\n/**\n * Complete default-browser composition for embedders: verified WASM Worker,\n * durable IndexedDB state, authenticated live sync, teardown, and the matching\n * first-party editor. Advanced/custom transports compose the lower-level host.\n */\nexport function BrowserEditableArtifactWorkbench({\n options,\n document,\n spreadsheet,\n presentation,\n}: BrowserEditableArtifactWorkbenchProps) {\n const sessionKey = browserSessionKey(options);\n const createSession = useCallback(() => createBrowserEditableArtifactSession(options), [options]);\n return (\n <EditableArtifactWorkbenchHost\n sessionKey={sessionKey}\n createSession={createSession}\n {...(document ? { document } : {})}\n {...(spreadsheet ? { spreadsheet } : {})}\n {...(presentation ? { presentation } : {})}\n />\n );\n}\n\nfunction browserSessionKey(options: BrowserEditableArtifactWorkbenchOptions): string {\n const transport = options.transport\n ? {\n ...options.transport,\n // Credentials must not be copied into React lifecycle keys. The\n // authorization epoch is the explicit credential/grant rotation fence.\n headers: options.transport.headers\n ? Object.keys(options.transport.headers).sort()\n : undefined,\n }\n : null;\n return JSON.stringify(\n {\n baseUrl: options.baseUrl,\n workspaceId: options.workspaceId,\n artifact: { id: options.artifact.id, modality: options.artifact.modality },\n storageAuthority: options.storageAuthority,\n runtime: options.runtime,\n replicaId: options.replicaId ?? null,\n transport,\n },\n (_key, value: unknown) => (value instanceof URL ? value.href : value),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,OAIK;AACP,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AAyEjD;AATD,SAAS,0BAA0B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAmC;AACjC,UAAQ,QAAQ,UAAU;AAAA,IACxB,KAAK;AACH,aACE;AAAA,QAAC;AAAA;AAAA,UACE,GAAG;AAAA,UACJ;AAAA,UACA,OAAO,UAAU,SAA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UAAoB,iBAAiB,MAAM,MAAM,OAAO;AAAA,EACjE;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/components/artifacts/published-html-artifact-frame.tsx","../src/components/artifacts/editable-artifact-workbench.tsx"],"sourcesContent":["import type { CSSProperties } from \"react\";\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 title: string;\n className?: string;\n style?: CSSProperties;\n};\n\n/**\n * Render exact published HTML in an opaque-origin iframe. Artifact scripts,\n * external resources, forms, popups, and downloads work without granting\n * parent-origin authority, shared cookies/storage, or top-level navigation.\n */\nexport function PublishedHtmlArtifactFrame(props: PublishedHtmlArtifactFrameProps) {\n return (\n <iframe\n title={props.title}\n sandbox={PUBLISHED_HTML_ARTIFACT_IFRAME_SANDBOX}\n referrerPolicy=\"no-referrer\"\n srcDoc={props.html}\n className={props.className}\n style={props.style}\n />\n );\n}\n","import {\n createBrowserEditableArtifactSession,\n type CreateBrowserEditableArtifactSessionOptions,\n type EditableArtifactBrowserRuntime,\n type EditableArtifactSession,\n} from \"@opengeni/sdk/editable-artifacts\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { EditableArtifactMessage } from \"./editable-artifact-ui\";\nimport {\n EditableDocumentArtifactSurface,\n type EditableDocumentArtifactSurfaceProps,\n} from \"./editable-document\";\nimport {\n EditablePresentationArtifactSurface,\n type EditablePresentationArtifactSurfaceProps,\n} from \"./editable-presentation\";\nimport {\n EditableSpreadsheetArtifactSurface,\n type EditableSpreadsheetArtifactSurfaceProps,\n} from \"./editable-spreadsheet\";\n\nexport type EditableArtifactWorkbenchProps = Readonly<{\n session: EditableArtifactSession;\n document?: Omit<EditableDocumentArtifactSurfaceProps, \"session\">;\n spreadsheet?: Omit<EditableSpreadsheetArtifactSurfaceProps, \"session\">;\n presentation?: Omit<EditablePresentationArtifactSurfaceProps, \"session\">;\n}>;\n\nexport type EditableArtifactWorkbenchHostProps = Omit<EditableArtifactWorkbenchProps, \"session\"> &\n Readonly<{\n /**\n * Complete identity of the browser session authority. Change this when the\n * artifact, deployment, principal, or authorization epoch changes.\n */\n sessionKey: string;\n /** Called for the active keyed lifecycle and again only after replacement or retry. */\n createSession: () => EditableArtifactSession;\n }>;\n\ntype DefaultBrowserArtifactTransport = Omit<\n NonNullable<CreateBrowserEditableArtifactSessionOptions[\"transport\"]>,\n \"apiKey\" | \"fetch\" | \"headers\" | \"webSocketFactory\"\n> &\n Readonly<{\n /** Static deployment auth headers; rotate authorizationEpoch when they change. */\n headers?: Readonly<Record<string, string>>;\n }>;\n\nexport type BrowserEditableArtifactWorkbenchOptions = Omit<\n CreateBrowserEditableArtifactSessionOptions,\n \"runtime\" | \"storage\" | \"transport\"\n> &\n Readonly<{\n /** Default module Worker only; custom Worker hosts use EditableArtifactWorkbenchHost. */\n runtime: Omit<EditableArtifactBrowserRuntime, \"workerFactory\">;\n /** Default fetch/WebSocket only; static deployment auth headers are supported. */\n transport?: DefaultBrowserArtifactTransport;\n }>;\n\nexport type BrowserEditableArtifactWorkbenchProps = Omit<\n EditableArtifactWorkbenchProps,\n \"session\"\n> &\n Readonly<{ options: BrowserEditableArtifactWorkbenchOptions }>;\n\n/**\n * One modality-neutral SDK workbench. Embedding hosts keep one route/component;\n * each artifact still renders through its complete first-party editor surface.\n */\nexport function EditableArtifactWorkbench({\n session,\n document,\n spreadsheet,\n presentation,\n}: EditableArtifactWorkbenchProps) {\n switch (session.modality) {\n case \"document\":\n return (\n <EditableDocumentArtifactSurface\n {...document}\n session={session}\n title={document?.title ?? \"Document\"}\n />\n );\n case \"spreadsheet\":\n return <EditableSpreadsheetArtifactSurface {...spreadsheet} session={session} />;\n case \"presentation\":\n return <EditablePresentationArtifactSurface {...presentation} session={session} />;\n }\n}\n\n/**\n * Route/embed composition that owns exactly one SDK session. The host supplies\n * the authenticated SDK factory; React guarantees replacement and teardown.\n */\nexport function EditableArtifactWorkbenchHost({\n sessionKey,\n createSession,\n document,\n spreadsheet,\n presentation,\n}: EditableArtifactWorkbenchHostProps) {\n const createSessionRef = useRef(createSession);\n const [retryEpoch, setRetryEpoch] = useState(0);\n const [state, setState] = useState<\n | Readonly<{ key: string; session: EditableArtifactSession; error: null }>\n | Readonly<{ key: string | null; session: null; error: Error | null }>\n >({ key: null, session: null, error: null });\n\n useEffect(() => {\n createSessionRef.current = createSession;\n }, [createSession]);\n\n useEffect(() => {\n let owned: EditableArtifactSession | null = null;\n setState({ key: sessionKey, session: null, error: null });\n try {\n owned = createSessionRef.current();\n setState({ key: sessionKey, session: owned, error: null });\n } catch (cause) {\n setState({\n key: sessionKey,\n session: null,\n error: cause instanceof Error ? cause : new Error(\"Could not create artifact session\"),\n });\n }\n return () => {\n const closing = owned;\n owned = null;\n if (closing) void closing.close().catch(() => undefined);\n };\n }, [retryEpoch, sessionKey]);\n\n const retry = useCallback(() => setRetryEpoch((value) => value + 1), []);\n const currentError = state.key === sessionKey ? state.error : null;\n if (state.key === sessionKey && state.session) {\n return (\n <EditableArtifactWorkbench\n session={state.session}\n {...(document ? { document } : {})}\n {...(spreadsheet ? { spreadsheet } : {})}\n {...(presentation ? { presentation } : {})}\n />\n );\n }\n return (\n <EditableArtifactMessage\n title={currentError ? \"Could not open this artifact\" : \"Opening artifact\"}\n detail={currentError?.message ?? \"Starting the secure editing session…\"}\n retry={currentError ? retry : undefined}\n />\n );\n}\n\n/**\n * Complete default-browser composition for embedders: verified WASM Worker,\n * durable IndexedDB state, authenticated live sync, teardown, and the matching\n * first-party editor. Advanced/custom transports compose the lower-level host.\n */\nexport function BrowserEditableArtifactWorkbench({\n options,\n document,\n spreadsheet,\n presentation,\n}: BrowserEditableArtifactWorkbenchProps) {\n const sessionKey = browserSessionKey(options);\n const createSession = useCallback(() => createBrowserEditableArtifactSession(options), [options]);\n return (\n <EditableArtifactWorkbenchHost\n sessionKey={sessionKey}\n createSession={createSession}\n {...(document ? { document } : {})}\n {...(spreadsheet ? { spreadsheet } : {})}\n {...(presentation ? { presentation } : {})}\n />\n );\n}\n\nfunction browserSessionKey(options: BrowserEditableArtifactWorkbenchOptions): string {\n const transport = options.transport\n ? {\n ...options.transport,\n // Credentials must not be copied into React lifecycle keys. The\n // authorization epoch is the explicit credential/grant rotation fence.\n headers: options.transport.headers\n ? Object.keys(options.transport.headers).sort()\n : undefined,\n }\n : null;\n return JSON.stringify(\n {\n baseUrl: options.baseUrl,\n workspaceId: options.workspaceId,\n artifact: { id: options.artifact.id, modality: options.artifact.modality },\n storageAuthority: options.storageAuthority,\n runtime: options.runtime,\n replicaId: options.replicaId ?? null,\n transport,\n },\n (_key, value: unknown) => (value instanceof URL ? value.href : value),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BI;AA1BG,IAAM,yCAAyC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK,GAAG;AAcH,SAAS,2BAA2B,OAAwC;AACjF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,MAAM;AAAA,MACb,SAAS;AAAA,MACT,gBAAe;AAAA,MACf,QAAQ,MAAM;AAAA,MACd,WAAW,MAAM;AAAA,MACjB,OAAO,MAAM;AAAA;AAAA,EACf;AAEJ;;;ACrCA;AAAA,EACE;AAAA,OAIK;AACP,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AAyEjD,gBAAAA,YAAA;AATD,SAAS,0BAA0B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAmC;AACjC,UAAQ,QAAQ,UAAU;AAAA,IACxB,KAAK;AACH,aACE,gBAAAA;AAAA,QAAC;AAAA;AAA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,SAAS,QAAQ;AAAA,MACjB,WAAW,QAAQ,aAAa;AAAA,MAChC;AAAA,IACF;AAAA,IACA,CAAC,MAAM,UAAoB,iBAAiB,MAAM,MAAM,OAAO;AAAA,EACjE;AACF;","names":["jsx"]}
@@ -1,6 +1,10 @@
1
+ import {
2
+ shouldSteerOnKey,
3
+ shouldSubmitOnKey
4
+ } from "./chunk-IGC6A2ZI.js";
1
5
  import {
2
6
  groupPickerRowsByBillingClass
3
- } from "./chunk-23EJ676W.js";
7
+ } from "./chunk-XBZWOM2K.js";
4
8
  import {
5
9
  Tooltip,
6
10
  TooltipContent,
@@ -10,10 +14,6 @@ import {
10
14
  import {
11
15
  ComposerResponsiveContext
12
16
  } from "./chunk-VZTQ73XT.js";
13
- import {
14
- shouldSteerOnKey,
15
- shouldSubmitOnKey
16
- } from "./chunk-724BW4TW.js";
17
17
  import {
18
18
  composerSubmissionErrorMessage,
19
19
  formatBytes,
@@ -4531,4 +4531,4 @@ export {
4531
4531
  Status,
4532
4532
  ComposerTranscriptionControl
4533
4533
  };
4534
- //# sourceMappingURL=chunk-ROIRTM37.js.map
4534
+ //# sourceMappingURL=chunk-5UQPNLIO.js.map
@@ -267,6 +267,8 @@ function asRecord(value) {
267
267
  // src/timeline/projection.ts
268
268
  var WORKER_SPAWN_TOOL = "session_create";
269
269
  var WORKER_MESSAGE_TOOL = "session_send_message";
270
+ var WORKER_FAILURE_CODE_MAX_LENGTH = 128;
271
+ var WORKER_FAILURE_MESSAGE_MAX_UTF8_BYTES = 1024;
270
272
  var LANDMARK_ONLY_TOOL_LEAVES = /* @__PURE__ */ new Set(["memory_save", "memory_correct"]);
271
273
  var TIMELINE_ANNOTATION_ANSI_SEQUENCE = new RegExp("\\u001B\\[[0-?]*[ -/]*[@-~]", "g");
272
274
  function safeTimelineAnnotationJson(value) {
@@ -499,6 +501,7 @@ function buildTimeline(events) {
499
501
  action: toolMatchesLeaf(name, WORKER_SPAWN_TOOL) ? "spawn" : "message",
500
502
  prompt: workerPrompt(args),
501
503
  workerSessionId: extractSessionRef(args),
504
+ failure: null,
502
505
  status: "running",
503
506
  occurredAt: event.occurredAt
504
507
  });
@@ -548,6 +551,7 @@ function buildTimeline(events) {
548
551
  if (target.kind === "worker") {
549
552
  target.status = isErrorOutput(payload) ? "failed" : "complete";
550
553
  target.workerSessionId = target.workerSessionId ?? extractSessionRef(payload.output);
554
+ target.failure = target.status === "failed" ? workerFailure(payload.output) : null;
551
555
  break;
552
556
  }
553
557
  const truncation = toolCallTruncation(payload);
@@ -1162,7 +1166,7 @@ function foldSettledTurn(groups, turnEnd) {
1162
1166
  );
1163
1167
  }
1164
1168
  function isTurnBoundary(group) {
1165
- return group?.kind === "turn" || group?.kind === "item" && (group.item.kind === "user-message" || group.item.kind === "context-compaction" || group.item.kind === "notice" && group.item.tone === "input");
1169
+ return group?.kind === "turn" || group?.kind === "item" && (group.item.kind === "user-message" || group.item.kind === "context-compaction" || group.item.kind === "machine-input-batch" && group.item.members.some((member) => member.kind === "media_generation_result") || group.item.kind === "notice" && group.item.tone === "input");
1166
1170
  }
1167
1171
  function belongsToDifferentTurn(group, turnId) {
1168
1172
  if (!group || !turnId) {
@@ -1501,6 +1505,49 @@ function workerPrompt(args) {
1501
1505
  }
1502
1506
  return null;
1503
1507
  }
1508
+ function boundedWorkerFailureMessage(value) {
1509
+ const normalized = value.replace(/[\u0000-\u001f\u007f]+/g, " ").trim();
1510
+ if (!normalized) return null;
1511
+ const encoded = new TextEncoder().encode(normalized);
1512
+ if (encoded.byteLength <= WORKER_FAILURE_MESSAGE_MAX_UTF8_BYTES) return normalized;
1513
+ let end = WORKER_FAILURE_MESSAGE_MAX_UTF8_BYTES;
1514
+ while (end > 0 && (encoded[end] & 192) === 128) end -= 1;
1515
+ return new TextDecoder().decode(encoded.slice(0, end)).trim();
1516
+ }
1517
+ function boundedWorkerFailure(value) {
1518
+ const record = asRecord2(value);
1519
+ const code = typeof record.code === "string" ? record.code.trim() : "";
1520
+ const message = typeof record.message === "string" ? boundedWorkerFailureMessage(record.message) : null;
1521
+ if (!/^[A-Za-z0-9._:-]{1,128}$/.test(code) || !message) return null;
1522
+ return { code: code.slice(0, WORKER_FAILURE_CODE_MAX_LENGTH), message };
1523
+ }
1524
+ function workerFailure(value, depth = 0) {
1525
+ if (depth > 6 || value === null || value === void 0) return null;
1526
+ if (typeof value === "string") {
1527
+ const parsed = tryParseJson(value);
1528
+ return parsed === value ? null : workerFailure(parsed, depth + 1);
1529
+ }
1530
+ if (Array.isArray(value)) {
1531
+ for (const entry of value) {
1532
+ const failure = workerFailure(entry, depth + 1);
1533
+ if (failure) return failure;
1534
+ }
1535
+ return null;
1536
+ }
1537
+ if (typeof value !== "object") return null;
1538
+ const record = value;
1539
+ const direct = boundedWorkerFailure(record.error);
1540
+ if (direct) return direct;
1541
+ for (const key of ["structuredContent", "content", "result", "output"]) {
1542
+ if (!(key in record)) continue;
1543
+ const failure = workerFailure(record[key], depth + 1);
1544
+ if (failure) return failure;
1545
+ }
1546
+ if (record.type === "text" && typeof record.text === "string") {
1547
+ return workerFailure(record.text, depth + 1);
1548
+ }
1549
+ return null;
1550
+ }
1504
1551
  function extractSessionRef(value, depth = 0) {
1505
1552
  if (depth > 6 || value === null || value === void 0) {
1506
1553
  return null;
@@ -1557,4 +1604,4 @@ export {
1557
1604
  groupTimeline,
1558
1605
  extractSessionRef
1559
1606
  };
1560
- //# sourceMappingURL=chunk-JR3QFY6B.js.map
1607
+ //# sourceMappingURL=chunk-6KLX2RH5.js.map