@opengeni/react 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/accounts.js +2 -0
- package/dist/accounts.js.map +1 -1
- package/dist/artifacts-document.js +5 -4
- package/dist/artifacts-presentation.js +5 -4
- package/dist/artifacts-spreadsheet.js +4 -3
- package/dist/artifacts.js +14 -13
- package/dist/artifacts.js.map +1 -1
- package/dist/browser-viewer-WGJ43YGI.js +17 -0
- package/dist/chat-interactive-block-ZFHOKTMS.js +12 -0
- package/dist/{chunk-WEHMPOXK.js → chunk-2DDJ6YH6.js} +3 -1
- package/dist/{chunk-WEHMPOXK.js.map → chunk-2DDJ6YH6.js.map} +1 -1
- package/dist/{chunk-C5X5AJXK.js → chunk-2HVLQ26H.js} +5 -4
- package/dist/{chunk-C5X5AJXK.js.map → chunk-2HVLQ26H.js.map} +1 -1
- package/dist/{chunk-A4UJB2MM.js → chunk-32CGLXW2.js} +4 -3
- package/dist/{chunk-A4UJB2MM.js.map → chunk-32CGLXW2.js.map} +1 -1
- package/dist/{chunk-5CVXZA3Y.js → chunk-45NUOSXQ.js} +3 -2
- package/dist/{chunk-5CVXZA3Y.js.map → chunk-45NUOSXQ.js.map} +1 -1
- package/dist/{chunk-WUISZ3WU.js → chunk-53KJBGPZ.js} +5 -4
- package/dist/{chunk-WUISZ3WU.js.map → chunk-53KJBGPZ.js.map} +1 -1
- package/dist/{chunk-MBMPHOMA.js → chunk-55DXD22O.js} +3 -2
- package/dist/{chunk-MBMPHOMA.js.map → chunk-55DXD22O.js.map} +1 -1
- package/dist/{chunk-JT4JW7BC.js → chunk-5I4VRWBB.js} +3 -1
- package/dist/{chunk-JT4JW7BC.js.map → chunk-5I4VRWBB.js.map} +1 -1
- package/dist/{chunk-UK4TINKT.js → chunk-B27E3V37.js} +3 -1
- package/dist/{chunk-UK4TINKT.js.map → chunk-B27E3V37.js.map} +1 -1
- package/dist/{chunk-J6DBS4T3.js → chunk-BNKV5ZLF.js} +5 -4
- package/dist/{chunk-J6DBS4T3.js.map → chunk-BNKV5ZLF.js.map} +1 -1
- package/dist/{chunk-YM2DE7BQ.js → chunk-C5BF4L26.js} +13 -12
- package/dist/{chunk-YM2DE7BQ.js.map → chunk-C5BF4L26.js.map} +1 -1
- package/dist/{chunk-YBXQDQFX.js → chunk-C7CMD56T.js} +6 -5
- package/dist/{chunk-YBXQDQFX.js.map → chunk-C7CMD56T.js.map} +1 -1
- package/dist/{chunk-UGLEYEMP.js → chunk-CM7LVUKC.js} +3 -1
- package/dist/{chunk-UGLEYEMP.js.map → chunk-CM7LVUKC.js.map} +1 -1
- package/dist/{chunk-LJ2UTJJE.js → chunk-CREMJMVN.js} +181 -96
- package/dist/chunk-CREMJMVN.js.map +1 -0
- package/dist/{chunk-JVYQRRC4.js → chunk-CVYCLFMH.js} +3 -1
- package/dist/{chunk-JVYQRRC4.js.map → chunk-CVYCLFMH.js.map} +1 -1
- package/dist/{chunk-Y2PRMYLC.js → chunk-G3U2A6GS.js} +3 -2
- package/dist/{chunk-Y2PRMYLC.js.map → chunk-G3U2A6GS.js.map} +1 -1
- package/dist/{chunk-WZMYFJD3.js → chunk-G6YRCIYJ.js} +16 -7
- package/dist/{chunk-WZMYFJD3.js.map → chunk-G6YRCIYJ.js.map} +1 -1
- package/dist/{chunk-B3V6TG77.js → chunk-GC3PH6N7.js} +3 -1
- package/dist/{chunk-B3V6TG77.js.map → chunk-GC3PH6N7.js.map} +1 -1
- package/dist/{chunk-CJUO7J5Z.js → chunk-HXYOSSQO.js} +3 -2
- package/dist/{chunk-CJUO7J5Z.js.map → chunk-HXYOSSQO.js.map} +1 -1
- package/dist/{chunk-BRM6FVZA.js → chunk-IEE7WCLN.js} +4 -3
- package/dist/{chunk-BRM6FVZA.js.map → chunk-IEE7WCLN.js.map} +1 -1
- package/dist/{chunk-DYWBUX5Q.js → chunk-IMSUVYQB.js} +6 -5
- package/dist/{chunk-DYWBUX5Q.js.map → chunk-IMSUVYQB.js.map} +1 -1
- package/dist/{chunk-LN6TCXD3.js → chunk-IUHHPMAX.js} +184 -48
- package/dist/chunk-IUHHPMAX.js.map +1 -0
- package/dist/{chunk-SGKD2OCN.js → chunk-IYQCWGU5.js} +6 -5
- package/dist/{chunk-SGKD2OCN.js.map → chunk-IYQCWGU5.js.map} +1 -1
- package/dist/{chunk-J2QWVSQY.js → chunk-JH7V627O.js} +8 -7
- package/dist/{chunk-J2QWVSQY.js.map → chunk-JH7V627O.js.map} +1 -1
- package/dist/{chunk-EESD3PY3.js → chunk-JHTIMBOL.js} +6 -5
- package/dist/{chunk-EESD3PY3.js.map → chunk-JHTIMBOL.js.map} +1 -1
- package/dist/{chunk-LNIRAOA3.js → chunk-L2J3PU7A.js} +7 -6
- package/dist/{chunk-LNIRAOA3.js.map → chunk-L2J3PU7A.js.map} +1 -1
- package/dist/{chunk-ZYRGEKWS.js → chunk-LJUMYUBO.js} +3 -1
- package/dist/{chunk-ZYRGEKWS.js.map → chunk-LJUMYUBO.js.map} +1 -1
- package/dist/{chunk-4RVYOY4O.js → chunk-LSW2OJVV.js} +4 -3
- package/dist/{chunk-4RVYOY4O.js.map → chunk-LSW2OJVV.js.map} +1 -1
- package/dist/{chunk-UTRTG6LH.js → chunk-LVS3MH5T.js} +3 -1
- package/dist/{chunk-UTRTG6LH.js.map → chunk-LVS3MH5T.js.map} +1 -1
- package/dist/chunk-M357MHH3.js +2 -0
- package/dist/{chunk-GYVRFZDY.js → chunk-MDIXFKA3.js} +9 -8
- package/dist/{chunk-GYVRFZDY.js.map → chunk-MDIXFKA3.js.map} +1 -1
- package/dist/{chunk-WRHIZYZF.js → chunk-MEQM4LI3.js} +6 -5
- package/dist/{chunk-WRHIZYZF.js.map → chunk-MEQM4LI3.js.map} +1 -1
- package/dist/chunk-NX4ADH73.js +14 -0
- package/dist/chunk-NX4ADH73.js.map +1 -0
- package/dist/{chunk-XCHWDJ22.js → chunk-OGTTUYNT.js} +3 -1
- package/dist/{chunk-XCHWDJ22.js.map → chunk-OGTTUYNT.js.map} +1 -1
- package/dist/{chunk-GIMRELBW.js → chunk-OYQQJL3J.js} +3 -1
- package/dist/{chunk-GIMRELBW.js.map → chunk-OYQQJL3J.js.map} +1 -1
- package/dist/{chunk-RSI7XYXL.js → chunk-PBCZL4JP.js} +6 -5
- package/dist/{chunk-RSI7XYXL.js.map → chunk-PBCZL4JP.js.map} +1 -1
- package/dist/{chunk-I7IWRQLN.js → chunk-PHBFJCEU.js} +17 -11
- package/dist/chunk-PHBFJCEU.js.map +1 -0
- package/dist/{chunk-3CTRFMAK.js → chunk-PKCAYHDC.js} +5 -4
- package/dist/{chunk-3CTRFMAK.js.map → chunk-PKCAYHDC.js.map} +1 -1
- package/dist/{chunk-K3HQAKQX.js → chunk-PMV53IMM.js} +3 -1
- package/dist/{chunk-K3HQAKQX.js.map → chunk-PMV53IMM.js.map} +1 -1
- package/dist/{chunk-YQEAA6LT.js → chunk-QHUE7E4N.js} +3 -2
- package/dist/{chunk-YQEAA6LT.js.map → chunk-QHUE7E4N.js.map} +1 -1
- package/dist/{chunk-OA6HFRQP.js → chunk-QMMCJGFI.js} +4 -3
- package/dist/{chunk-OA6HFRQP.js.map → chunk-QMMCJGFI.js.map} +1 -1
- package/dist/{chunk-YV4L3ILF.js → chunk-QV3DJVRZ.js} +3 -1
- package/dist/{chunk-YV4L3ILF.js.map → chunk-QV3DJVRZ.js.map} +1 -1
- package/dist/{chunk-447JLCBU.js → chunk-S2QH6EZ5.js} +3 -1
- package/dist/{chunk-447JLCBU.js.map → chunk-S2QH6EZ5.js.map} +1 -1
- package/dist/{chunk-PNY3JKBJ.js → chunk-SFH43JT2.js} +5 -4
- package/dist/{chunk-PNY3JKBJ.js.map → chunk-SFH43JT2.js.map} +1 -1
- package/dist/{chunk-AWZLIMKX.js → chunk-T46QZH3E.js} +3 -1
- package/dist/{chunk-AWZLIMKX.js.map → chunk-T46QZH3E.js.map} +1 -1
- package/dist/{chunk-5J4FOW6Q.js → chunk-TNEZNMSN.js} +3 -1
- package/dist/{chunk-5J4FOW6Q.js.map → chunk-TNEZNMSN.js.map} +1 -1
- package/dist/{chunk-22KP6LR5.js → chunk-TXS65BB2.js} +3 -1
- package/dist/{chunk-22KP6LR5.js.map → chunk-TXS65BB2.js.map} +1 -1
- package/dist/{chunk-H5X55XH7.js → chunk-UDPH5SLV.js} +4 -3
- package/dist/{chunk-H5X55XH7.js.map → chunk-UDPH5SLV.js.map} +1 -1
- package/dist/{chunk-HDJWDK7W.js → chunk-VCSERYXH.js} +10 -9
- package/dist/{chunk-HDJWDK7W.js.map → chunk-VCSERYXH.js.map} +1 -1
- package/dist/{chunk-VZTQ73XT.js → chunk-XEA5BCMA.js} +3 -1
- package/dist/{chunk-VZTQ73XT.js.map → chunk-XEA5BCMA.js.map} +1 -1
- package/dist/{chunk-5F4WR7X7.js → chunk-XS67YG5R.js} +3 -1
- package/dist/{chunk-5F4WR7X7.js.map → chunk-XS67YG5R.js.map} +1 -1
- package/dist/{chunk-TKOTKRWY.js → chunk-XTD7TZHW.js} +3 -1
- package/dist/{chunk-TKOTKRWY.js.map → chunk-XTD7TZHW.js.map} +1 -1
- package/dist/{chunk-A2PI6UMY.js → chunk-YSRBFJMQ.js} +3 -1
- package/dist/{chunk-A2PI6UMY.js.map → chunk-YSRBFJMQ.js.map} +1 -1
- package/dist/chunk-YVFRBXST.js +1420 -0
- package/dist/chunk-YVFRBXST.js.map +1 -0
- package/dist/{chunk-SCOTPE2I.js → chunk-YYLBXXTE.js} +3 -1
- package/dist/{chunk-SCOTPE2I.js.map → chunk-YYLBXXTE.js.map} +1 -1
- package/dist/{chunk-RHREZ7BO.js → chunk-ZUWF4NF7.js} +3 -1
- package/dist/{chunk-RHREZ7BO.js.map → chunk-ZUWF4NF7.js.map} +1 -1
- package/dist/clipboard.js +3 -2
- package/dist/components/composer-transcription-control.d.ts +4 -0
- package/dist/components/session-conversation.d.ts +6 -0
- package/dist/composer-voice-events.d.ts +8 -0
- package/dist/composer.js +15 -13
- package/dist/computer-viewer-46UIN7F3.js +20 -0
- package/dist/connect.js +15 -12
- package/dist/connect.js.map +1 -1
- package/dist/desktop.js +6 -5
- package/dist/desktop.js.map +1 -1
- package/dist/diffs.js +2 -1
- package/dist/diffs.js.map +1 -1
- package/dist/editor.js +4 -3
- package/dist/editor.js.map +1 -1
- package/dist/embedded-voice-NIL4RDX3.js +69 -0
- package/dist/embedded-voice-NIL4RDX3.js.map +1 -0
- package/dist/{fleet-decision-row-YZ3ZKWMM.js → fleet-decision-row-SI63O5V4.js} +3 -1
- package/dist/{fleet-decision-row-YZ3ZKWMM.js.map → fleet-decision-row-SI63O5V4.js.map} +1 -1
- package/dist/hooks/use-client-config-flags.d.ts +6 -0
- package/dist/hooks/use-realtime-voice-models.d.ts +9 -0
- package/dist/hooks/use-voice-input.d.ts +8 -1
- package/dist/index.js +47 -45
- package/dist/index.js.map +1 -1
- package/dist/interaction.js +14 -13
- package/dist/interaction.js.map +1 -1
- package/dist/{latest-question-GPYM2JNU.js → latest-question-2POFPYNB.js} +5 -4
- package/dist/{latest-question-GPYM2JNU.js.map → latest-question-2POFPYNB.js.map} +1 -1
- package/dist/machines.js +8 -7
- package/dist/{markdown-table-layout-QXSLK4BY.js → markdown-table-layout-DQ4DRNVT.js} +3 -1
- package/dist/{markdown-table-layout-QXSLK4BY.js.map → markdown-table-layout-DQ4DRNVT.js.map} +1 -1
- package/dist/model-policy-picker-menu-WRNSRFQC.js +15 -0
- package/dist/model-policy.js +2 -1
- package/dist/{noto-sans-arabic-loader-IA2T4X2A.js → noto-sans-arabic-loader-XSH2KYWJ.js} +3 -1
- package/dist/{noto-sans-arabic-loader-IA2T4X2A.js.map → noto-sans-arabic-loader-XSH2KYWJ.js.map} +1 -1
- package/dist/{noto-sans-jp-loader.generated-HFGLYBR3.js → noto-sans-jp-loader.generated-MR5L6V7K.js} +3 -1
- package/dist/{noto-sans-jp-loader.generated-HFGLYBR3.js.map → noto-sans-jp-loader.generated-MR5L6V7K.js.map} +1 -1
- package/dist/{platform-activity-row-627BFZ46.js → platform-activity-row-PJJVATTZ.js} +3 -1
- package/dist/{platform-activity-row-627BFZ46.js.map → platform-activity-row-PJJVATTZ.js.map} +1 -1
- package/dist/{queue-surface-implementation-ZHFI5JBP.js → queue-surface-implementation-67FS7FUI.js} +10 -9
- package/dist/{queue-surface-implementation-ZHFI5JBP.js.map → queue-surface-implementation-67FS7FUI.js.map} +1 -1
- package/dist/realtime/embedded-voice.d.ts +20 -0
- package/dist/realtime.js +22 -1353
- package/dist/realtime.js.map +1 -1
- package/dist/sandbox-files-34CJJNOY.js +21 -0
- package/dist/session-ui.js +32 -30
- package/dist/session-ui.js.map +1 -1
- package/dist/session.js +10 -9
- package/dist/sites.js +2 -1
- package/dist/terminal.js +6 -5
- package/dist/terminal.js.map +1 -1
- package/dist/{timeline-annotation-markers-GNDHTGBD.js → timeline-annotation-markers-U3G66KUD.js} +5 -4
- package/dist/{timeline-annotation-markers-GNDHTGBD.js.map → timeline-annotation-markers-U3G66KUD.js.map} +1 -1
- package/dist/{timeline-annotation-selection-DMLMM2TX.js → timeline-annotation-selection-BI7QTPTZ.js} +4 -3
- package/dist/{timeline-annotation-selection-DMLMM2TX.js.map → timeline-annotation-selection-BI7QTPTZ.js.map} +1 -1
- package/dist/{timeline-annotations-dialog-ELRDBHTS.js → timeline-annotations-dialog-FOMHSDTE.js} +7 -6
- package/dist/{timeline-annotations-dialog-ELRDBHTS.js.map → timeline-annotations-dialog-FOMHSDTE.js.map} +1 -1
- package/dist/usage.js +6 -5
- package/dist/usage.js.map +1 -1
- package/dist/voice-recording-owner.d.ts +7 -0
- package/package.json +3 -3
- package/src/components/composer-transcription-control.tsx +109 -27
- package/src/components/markdown.tsx +7 -2
- package/src/components/message-timeline.tsx +10 -1
- package/src/components/session-conversation.tsx +44 -0
- package/src/components/session-proxy-scope.tsx +26 -5
- package/src/composer-voice-events.ts +12 -0
- package/src/connection-discovery.tsx +4 -1
- package/src/hooks/use-client-config-flags.ts +8 -0
- package/src/hooks/use-goal.ts +12 -1
- package/src/hooks/use-realtime-voice-models.ts +67 -0
- package/src/hooks/use-voice-input.ts +109 -18
- package/src/realtime/embedded-voice.tsx +81 -0
- package/src/realtime/realtime-control.tsx +82 -17
- package/src/voice-recording-owner.ts +22 -0
- package/styles/compiled.css +72 -18
- package/styles/index.css +49 -0
- package/styles/responsive.css +61 -4
- package/styles/session-capability.css +1 -1
- package/dist/browser-viewer-SHYKQRNX.js +0 -16
- package/dist/chat-interactive-block-UGBTNB3L.js +0 -11
- package/dist/chunk-I7IWRQLN.js.map +0 -1
- package/dist/chunk-IWIDV7SB.js +0 -1
- package/dist/chunk-LJ2UTJJE.js.map +0 -1
- package/dist/chunk-LN6TCXD3.js.map +0 -1
- package/dist/computer-viewer-6SRGWRUX.js +0 -19
- package/dist/model-policy-picker-menu-DXHUL73H.js +0 -14
- package/dist/sandbox-files-GORZOUUJ.js +0 -20
- /package/dist/{browser-viewer-SHYKQRNX.js.map → browser-viewer-WGJ43YGI.js.map} +0 -0
- /package/dist/{chat-interactive-block-UGBTNB3L.js.map → chat-interactive-block-ZFHOKTMS.js.map} +0 -0
- /package/dist/{chunk-IWIDV7SB.js.map → chunk-M357MHH3.js.map} +0 -0
- /package/dist/{computer-viewer-6SRGWRUX.js.map → computer-viewer-46UIN7F3.js.map} +0 -0
- /package/dist/{model-policy-picker-menu-DXHUL73H.js.map → model-policy-picker-menu-WRNSRFQC.js.map} +0 -0
- /package/dist/{sandbox-files-GORZOUUJ.js.map → sandbox-files-34CJJNOY.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/use-portal-token-style.ts","../src/lib/composer-responsive-context.ts"],"sourcesContent":["import {\n type CSSProperties,\n type RefCallback,\n type RefObject,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { useComposerResponsiveContext } from \"./composer-responsive-context\";\n\nexport type PortalTokenStyle = Pick<CSSProperties, \"colorScheme\"> &\n Partial<Record<`--${string}`, string>>;\n\nexport const PORTAL_SOURCE_INLINE_SIZE = \"--og-portal-source-inline-size\";\n\n/**\n * A callback ref that publishes the currently mounted source element through\n * React state. Unlike a bare mutable ref, late mounts and replacements cause\n * consumers to render and restart their observers without polling.\n */\nexport function usePortalTokenSource<T extends HTMLElement>(): {\n source: T | null;\n currentRef: RefObject<T | null>;\n ref: RefCallback<T>;\n} {\n const currentRef = useRef<T | null>(null);\n const [source, setSource] = useState<T | null>(null);\n const ref = useCallback<RefCallback<T>>((node) => {\n currentRef.current = node;\n setSource((current) => (current === node ? current : node));\n }, []);\n return { source, currentRef, ref };\n}\n\n/**\n * Copy the effective SDK tokens across a portal boundary. A locally themed or\n * rebranded embed cannot rely on CSS inheritance once a portal mounts under\n * `<body>`. Ancestor theme/class/style mutations and OS color-scheme changes\n * keep the copied values live.\n */\nexport function usePortalTokenStyle(source: HTMLElement | null): PortalTokenStyle {\n const responsiveContext = useComposerResponsiveContext();\n const [style, setStyle] = useState<PortalTokenStyle>({});\n useEffect(() => {\n if (!source || typeof window === \"undefined\") return;\n const layoutSource =\n responsiveContext?.responsiveBasis === \"container\" ? responsiveContext.rootRef.current : null;\n let signature = \"\";\n const sync = () => {\n const computed = getComputedStyle(source);\n const next: PortalTokenStyle = { colorScheme: computed.colorScheme };\n for (let index = 0; index < computed.length; index += 1) {\n const property = computed.item(index);\n if (!property.startsWith(\"--og-\")) continue;\n next[property as `--${string}`] = computed.getPropertyValue(property);\n }\n if (layoutSource) {\n const inlineSize = layoutSource.clientWidth || layoutSource.getBoundingClientRect().width;\n if (inlineSize > 0) {\n next[PORTAL_SOURCE_INLINE_SIZE] = `${Math.round(inlineSize * 1000) / 1000}px`;\n }\n }\n const nextSignature = JSON.stringify(next);\n if (nextSignature !== signature) {\n signature = nextSignature;\n setStyle(next);\n }\n };\n const observers: MutationObserver[] = [];\n if (typeof MutationObserver !== \"undefined\") {\n let ancestor: HTMLElement | null = source;\n while (ancestor) {\n const observer = new MutationObserver(sync);\n observer.observe(ancestor, {\n attributes: true,\n attributeFilter: [\"class\", \"data-og-density\", \"data-og-theme\", \"style\"],\n });\n observers.push(observer);\n ancestor = ancestor.parentElement;\n }\n }\n const resizeObserver =\n layoutSource && typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(sync) : null;\n if (layoutSource) resizeObserver?.observe(layoutSource);\n const colorScheme = window.matchMedia?.(\"(prefers-color-scheme: dark)\");\n colorScheme?.addEventListener?.(\"change\", sync);\n sync();\n return () => {\n for (const observer of observers) observer.disconnect();\n resizeObserver?.disconnect();\n colorScheme?.removeEventListener?.(\"change\", sync);\n };\n }, [responsiveContext?.responsiveBasis, responsiveContext?.rootRef, source]);\n return style;\n}\n","import { createContext, useContext, type RefObject } from \"react\";\n\n/** The measurement surface used by responsive composer chrome. */\nexport type ResponsiveBasis = \"viewport\" | \"container\";\n\nexport type ComposerResponsiveContextValue = {\n responsiveBasis: ResponsiveBasis;\n rootRef: RefObject<HTMLDivElement | null>;\n};\n\nexport const ComposerResponsiveContext = createContext<ComposerResponsiveContextValue | null>(null);\n\nexport function useComposerResponsiveContext(): ComposerResponsiveContextValue | null {\n return useContext(ComposerResponsiveContext);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/lib/use-portal-token-style.ts","../src/lib/composer-responsive-context.ts"],"sourcesContent":["import {\n type CSSProperties,\n type RefCallback,\n type RefObject,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { useComposerResponsiveContext } from \"./composer-responsive-context\";\n\nexport type PortalTokenStyle = Pick<CSSProperties, \"colorScheme\"> &\n Partial<Record<`--${string}`, string>>;\n\nexport const PORTAL_SOURCE_INLINE_SIZE = \"--og-portal-source-inline-size\";\n\n/**\n * A callback ref that publishes the currently mounted source element through\n * React state. Unlike a bare mutable ref, late mounts and replacements cause\n * consumers to render and restart their observers without polling.\n */\nexport function usePortalTokenSource<T extends HTMLElement>(): {\n source: T | null;\n currentRef: RefObject<T | null>;\n ref: RefCallback<T>;\n} {\n const currentRef = useRef<T | null>(null);\n const [source, setSource] = useState<T | null>(null);\n const ref = useCallback<RefCallback<T>>((node) => {\n currentRef.current = node;\n setSource((current) => (current === node ? current : node));\n }, []);\n return { source, currentRef, ref };\n}\n\n/**\n * Copy the effective SDK tokens across a portal boundary. A locally themed or\n * rebranded embed cannot rely on CSS inheritance once a portal mounts under\n * `<body>`. Ancestor theme/class/style mutations and OS color-scheme changes\n * keep the copied values live.\n */\nexport function usePortalTokenStyle(source: HTMLElement | null): PortalTokenStyle {\n const responsiveContext = useComposerResponsiveContext();\n const [style, setStyle] = useState<PortalTokenStyle>({});\n useEffect(() => {\n if (!source || typeof window === \"undefined\") return;\n const layoutSource =\n responsiveContext?.responsiveBasis === \"container\" ? responsiveContext.rootRef.current : null;\n let signature = \"\";\n const sync = () => {\n const computed = getComputedStyle(source);\n const next: PortalTokenStyle = { colorScheme: computed.colorScheme };\n for (let index = 0; index < computed.length; index += 1) {\n const property = computed.item(index);\n if (!property.startsWith(\"--og-\")) continue;\n next[property as `--${string}`] = computed.getPropertyValue(property);\n }\n if (layoutSource) {\n const inlineSize = layoutSource.clientWidth || layoutSource.getBoundingClientRect().width;\n if (inlineSize > 0) {\n next[PORTAL_SOURCE_INLINE_SIZE] = `${Math.round(inlineSize * 1000) / 1000}px`;\n }\n }\n const nextSignature = JSON.stringify(next);\n if (nextSignature !== signature) {\n signature = nextSignature;\n setStyle(next);\n }\n };\n const observers: MutationObserver[] = [];\n if (typeof MutationObserver !== \"undefined\") {\n let ancestor: HTMLElement | null = source;\n while (ancestor) {\n const observer = new MutationObserver(sync);\n observer.observe(ancestor, {\n attributes: true,\n attributeFilter: [\"class\", \"data-og-density\", \"data-og-theme\", \"style\"],\n });\n observers.push(observer);\n ancestor = ancestor.parentElement;\n }\n }\n const resizeObserver =\n layoutSource && typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(sync) : null;\n if (layoutSource) resizeObserver?.observe(layoutSource);\n const colorScheme = window.matchMedia?.(\"(prefers-color-scheme: dark)\");\n colorScheme?.addEventListener?.(\"change\", sync);\n sync();\n return () => {\n for (const observer of observers) observer.disconnect();\n resizeObserver?.disconnect();\n colorScheme?.removeEventListener?.(\"change\", sync);\n };\n }, [responsiveContext?.responsiveBasis, responsiveContext?.rootRef, source]);\n return style;\n}\n","import { createContext, useContext, type RefObject } from \"react\";\n\n/** The measurement surface used by responsive composer chrome. */\nexport type ResponsiveBasis = \"viewport\" | \"container\";\n\nexport type ComposerResponsiveContextValue = {\n responsiveBasis: ResponsiveBasis;\n rootRef: RefObject<HTMLDivElement | null>;\n};\n\nexport const ComposerResponsiveContext = createContext<ComposerResponsiveContextValue | null>(null);\n\nexport function useComposerResponsiveContext(): ComposerResponsiveContextValue | null {\n return useContext(ComposerResponsiveContext);\n}\n"],"mappings":";;;AAAA;AAAA,EAIE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACRP,SAAS,eAAe,kBAAkC;AAUnD,IAAM,4BAA4B,cAAqD,IAAI;AAE3F,SAAS,+BAAsE;AACpF,SAAO,WAAW,yBAAyB;AAC7C;;;ADAO,IAAM,4BAA4B;AAOlC,SAAS,uBAId;AACA,QAAM,aAAa,OAAiB,IAAI;AACxC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAmB,IAAI;AACnD,QAAM,MAAM,YAA4B,CAAC,SAAS;AAChD,eAAW,UAAU;AACrB,cAAU,CAAC,YAAa,YAAY,OAAO,UAAU,IAAK;AAAA,EAC5D,GAAG,CAAC,CAAC;AACL,SAAO,EAAE,QAAQ,YAAY,IAAI;AACnC;AAQO,SAAS,oBAAoB,QAA8C;AAChF,QAAM,oBAAoB,6BAA6B;AACvD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAA2B,CAAC,CAAC;AACvD,YAAU,MAAM;AACd,QAAI,CAAC,UAAU,OAAO,WAAW,YAAa;AAC9C,UAAM,eACJ,mBAAmB,oBAAoB,c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AAC3B,mBAAa,sBAAsB,UAAU,IAAI;AAAA,IACnD;AAAA,EACF,GAAG,CAAC,mBAAmB,iBAAiB,mBAAmB,SAAS,MAAM,CAAC;AAC3E,SAAO;AACT;","names":[]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
// src/model-policy.ts
|
|
2
4
|
import {
|
|
3
5
|
compareModelPickerOrder,
|
|
@@ -297,4 +299,4 @@ export {
|
|
|
297
299
|
modelDisplayName2 as modelDisplayName,
|
|
298
300
|
modelVendor
|
|
299
301
|
};
|
|
300
|
-
//# sourceMappingURL=chunk-
|
|
302
|
+
//# sourceMappingURL=chunk-XS67YG5R.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/model-policy.ts"],"sourcesContent":["import {\n compareModelPickerOrder,\n modelPickerBillingClassFor,\n type ModelPickerBillingClass,\n} from \"@opengeni/sdk/model-picker-order\";\nimport { modelDisplayName } from \"@opengeni/sdk/model-display\";\nimport type { ClientModel, ReasoningEffort, WorkspaceModelCatalogModel } from \"@opengeni/sdk\";\n\nexport type PickerBillingClass = ModelPickerBillingClass;\n\nexport type PickerModelRow<TCatalog extends ClientModel = WorkspaceModelCatalogModel> = {\n id: string;\n label: string;\n /** Catalog-curated compact label for dense UI; fall back to `label` when absent. */\n shortLabel?: string | undefined;\n billingClass: PickerBillingClass;\n billingClassLabel: string;\n selectable: boolean;\n unavailableReason: string | null;\n fundingHint?: string | undefined;\n provider: string;\n providerLabel: string;\n catalog: TCatalog;\n};\n\nexport type LatencyModeId = \"standard\" | \"priority\" | \"fast\";\n\nconst BILLING_CLASS_LABELS: Record<PickerBillingClass, string> = {\n opengeni_credits: \"Models\",\n external: \"External\",\n codex_subscription: \"Codex\",\n supergrok_subscription: \"SuperGrok\",\n claude_subscription: \"Claude subscription\",\n // Who connected the key (organization or workspace) is a settings fact, not\n // a model choice: both scopes share one label and one picker group.\n byok: \"API keys\",\n organization_byok: \"API keys\",\n};\n\n/** Models settings keeps naming who connected the key. */\nconst SCOPED_BILLING_CLASS_LABELS: Record<PickerBillingClass, string> = {\n ...BILLING_CLASS_LABELS,\n byok: \"Workspace providers\",\n organization_byok: \"Organization providers\",\n};\n\nconst AVAILABILITY_REASON_LABELS: Record<string, string> = {\n missing_credential: \"Credentials required\",\n needs_reauth: \"Reconnect required\",\n credential_not_ready: \"Credential not ready\",\n not_entitled: \"Not entitled\",\n provider_unhealthy: \"Provider unavailable\",\n policy_blocked: \"Blocked by workspace policy\",\n unsupported: \"Unsupported\",\n};\n\nexport function billingClassForModel(model: ClientModel): PickerBillingClass {\n if (model.provider === \"organization-gateway\" || model.provider === \"organization-openrouter\") {\n return \"organization_byok\";\n }\n if (\n model.provider?.startsWith(\"workspace-openai-\") ||\n model.provider?.startsWith(\"workspace-azure-openai-\")\n )\n return \"byok\";\n if (model.provider === \"workspace-gateway\" || model.provider === \"workspace-openrouter\") {\n return \"byok\";\n }\n return modelPickerBillingClassFor(model);\n}\n\nexport function billingClassLabel(billingClass: PickerBillingClass): string {\n return BILLING_CLASS_LABELS[billingClass];\n}\n\n/** The group label that names the connection scope, for Models settings only. */\nexport function scopedBillingClassLabel(billingClass: PickerBillingClass): string {\n return SCOPED_BILLING_CLASS_LABELS[billingClass];\n}\n\nexport function availabilityReasonLabel(\n reason: WorkspaceModelCatalogModel[\"availability\"][\"reason\"],\n): string | null {\n if (!reason) {\n return null;\n }\n return AVAILABILITY_REASON_LABELS[reason] ?? \"Unavailable\";\n}\n\nexport function effortOptionsForModel(model: ClientModel): ReasoningEffort[] {\n const efforts = model.capabilities?.reasoning.efforts;\n if (!efforts || efforts.length === 0) {\n return [\"low\"];\n }\n const order: ReasoningEffort[] = [\"none\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"];\n return order.filter((effort) => efforts.includes(effort));\n}\n\nexport function defaultEffortForModel(model: ClientModel): ReasoningEffort {\n const options = effortOptionsForModel(model);\n const configured = model.capabilities?.reasoning.defaultEffort;\n if (configured && options.includes(configured)) {\n return configured;\n }\n return options[0] ?? \"low\";\n}\n\nexport function coerceReasoningEffortForModel(\n model: ClientModel,\n effort: ReasoningEffort,\n): ReasoningEffort {\n const options = effortOptionsForModel(model);\n if (options.includes(effort)) {\n return effort;\n }\n return defaultEffortForModel(model);\n}\n\nexport function runnableLatencyModesForModel(model: ClientModel): LatencyModeId[] {\n const modes = model.capabilities?.latencyModes ?? [];\n return modes.filter((mode) => mode.runnable).map((mode) => mode.id);\n}\n\nexport function labelLatencyMode(mode: LatencyModeId): string {\n if (mode === \"fast\") {\n return \"Fast\";\n }\n if (mode === \"priority\") {\n return \"Priority\";\n }\n return \"Standard\";\n}\n\nexport function labelReasoningEffort(effort: ReasoningEffort): string {\n if (effort === \"xhigh\") {\n return \"Extra high\";\n }\n return effort.slice(0, 1).toUpperCase() + effort.slice(1);\n}\n\n/** Payment prompts must use cost policy, never the presentation group. */\nexport function modelUsesCredits(model: ClientModel | undefined): boolean {\n if (model?.cost !== undefined) return model.cost === \"credits\";\n return model?.billing?.metering === \"opengeni_credits\";\n}\n\nexport function payerSummaryForModel(model: ClientModel): string {\n if (model.cost === \"free\") {\n return \"Free in this deployment\";\n }\n if (model.cost === \"credits\") {\n return \"Opengeni credits\";\n }\n if (model.cost === \"subscription\") {\n return model.credentialSource?.kind === \"connected_subscription\" &&\n model.credentialSource.provider === \"claude\"\n ? \"Claude subscription · external billing\"\n : model.source === \"supergrok\"\n ? \"SuperGrok subscription · external billing\"\n : \"Codex subscription · external billing\";\n }\n if (model.cost === \"workspace\") {\n return workspaceProviderPayerSummary(model);\n }\n if (model.cost === \"organization\") {\n return organizationProviderPayerSummary(model);\n }\n\n // Older client-config payloads do not carry `cost`; preserve their existing\n // settlement-derived label until every deployment has rolled forward.\n const billing = model.billing;\n if (!billing) {\n return \"Route unknown\";\n }\n if (billing.metering === \"opengeni_credits\") {\n return \"Opengeni credits · automatic managed route\";\n }\n if (billing.upstreamPayer === \"connected_subscription\") {\n return model.credentialSource?.kind === \"connected_subscription\" &&\n model.credentialSource.provider === \"claude\"\n ? \"Claude subscription · external billing\"\n : model.source === \"supergrok\"\n ? \"SuperGrok subscription · external billing\"\n : \"Codex subscription · external billing\";\n }\n if (billing.upstreamPayer === \"workspace\") {\n return workspaceProviderPayerSummary(model);\n }\n if (billing.upstreamPayer === \"organization\") {\n return organizationProviderPayerSummary(model);\n }\n return billing.upstreamPayer === \"deployment\"\n ? \"Opengeni · no model credits\"\n : \"External provider · no Opengeni credits\";\n}\n\nexport function advancedSourceSummary(model: ClientModel): string | null {\n const source = model.credentialSource;\n if (!source) {\n return model.billing?.metering === \"external\" && model.billing.upstreamPayer === \"deployment\"\n ? \"Deployment-provided connection\"\n : null;\n }\n if (source.kind === \"connected_subscription\") {\n return source.provider === \"claude\"\n ? \"Connected Claude subscription\"\n : source.provider === \"xai\"\n ? \"Connected SuperGrok subscription\"\n : \"Connected Codex subscription\";\n }\n if (source.kind === \"workspace_connection\") {\n if (model.provider === \"workspace-openrouter\") {\n return \"Workspace OpenRouter connection\";\n }\n if (model.provider === \"workspace-gateway\" || model.source === \"workspace_gateway\") {\n return \"Workspace Vercel AI Gateway\";\n }\n return \"Workspace provider connection\";\n }\n if (source.kind === \"deployment\") {\n return source.mechanism === \"azure_ad_bearer\"\n ? \"Deployment Azure identity\"\n : \"Deployment API key\";\n }\n return null;\n}\n\nfunction workspaceProviderPayerSummary(model: ClientModel): string {\n if (model.provider === \"workspace-anthropic\")\n return \"Billed to the workspace Anthropic API account\";\n if (model.provider === \"workspace-claude-subscription\")\n return \"Uses the workspace Claude subscription · no Opengeni credits\";\n if (model.provider === \"workspace-openrouter\") {\n return \"Billed to the workspace OpenRouter account\";\n }\n if (model.provider === \"workspace-gateway\" || model.source === \"workspace_gateway\") {\n return \"Billed to the workspace Vercel account\";\n }\n return \"Billed to the workspace provider account\";\n}\n\nfunction organizationProviderPayerSummary(model: ClientModel): string {\n if (model.provider === \"organization-anthropic\")\n return \"Billed to the organization Anthropic API account\";\n if (model.provider === \"organization-claude-subscription\")\n return \"Uses the connected Claude subscription · no Opengeni credits\";\n if (model.provider === \"organization-openrouter\") {\n return \"Billed to the organization OpenRouter account\";\n }\n if (model.provider === \"organization-gateway\") {\n return \"Billed to the organization Vercel account\";\n }\n return \"Billed to the organization provider account\";\n}\n\n/**\n * The curated compact label, else the family-free name for Claude models\n * (\"Opus 5.5\"): the maker's mark beside it already says Claude.\n */\nfunction compactLabel(catalog: ClientModel): { shortLabel?: string } {\n if (catalog.shortLabel) return { shortLabel: catalog.shortLabel };\n const name = modelDisplayName(catalog);\n return name.startsWith(\"Claude \") ? { shortLabel: name.slice(\"Claude \".length) } : {};\n}\n\nexport function projectPickerRows(models: WorkspaceModelCatalogModel[]): PickerModelRow[] {\n return models\n .filter((catalog) => catalog.credentialReadiness.status === \"ready\")\n .map((catalog) => {\n const billingClass = billingClassForModel(catalog);\n return {\n id: catalog.id,\n label: modelDisplayName(catalog),\n ...compactLabel(catalog),\n billingClass,\n billingClassLabel: billingClassLabel(billingClass),\n selectable: catalog.availability.selectable,\n fundingHint:\n catalog.creditFunding === \"promotional\"\n ? \"Free credits\"\n : catalog.creditFunding === \"general\"\n ? \"Uses credits\"\n : catalog.creditFunding === \"unavailable\"\n ? \"Needs credits\"\n : undefined,\n unavailableReason: catalog.availability.selectable\n ? null\n : availabilityReasonLabel(catalog.availability.reason),\n provider: catalog.provider,\n providerLabel: catalog.providerLabel,\n catalog,\n };\n });\n}\n\n/** Project the lightweight client-config model list into the same picker contract. */\nexport function projectClientModelRows(models: ClientModel[]): PickerModelRow<ClientModel>[] {\n return models.map((catalog) => {\n const billingClass = billingClassForModel(catalog);\n return {\n id: catalog.id,\n label: modelDisplayName(catalog),\n ...compactLabel(catalog),\n billingClass,\n billingClassLabel: billingClassLabel(billingClass),\n selectable: true,\n unavailableReason: null,\n provider: catalog.provider,\n providerLabel: catalog.providerLabel,\n catalog,\n };\n });\n}\n\nexport function sortPickerRows<TCatalog extends ClientModel>(\n rows: PickerModelRow<TCatalog>[],\n): PickerModelRow<TCatalog>[] {\n return [...rows].sort(compareModelPickerOrder);\n}\n\nexport function findPickerRow<TCatalog extends ClientModel>(\n rows: PickerModelRow<TCatalog>[],\n modelId: string,\n): PickerModelRow<TCatalog> | null {\n return rows.find((row) => row.id === modelId) ?? null;\n}\n\nexport type GroupPickerRowsOptions = {\n codexOnly?: boolean;\n /**\n * Default true: organization- and workspace-connected keys share one group\n * and identical copies show once. Models settings passes false.\n */\n collapseScopes?: boolean | undefined;\n /** Kept visible when it has an identical twin (see below). */\n selectedId?: string | undefined;\n};\n\n/**\n * Organization- and workspace-connected API keys are one choice for the person\n * picking a model, so they share one group.\n */\nfunction displayGroupFor(billingClass: PickerBillingClass): PickerBillingClass {\n return billingClass === \"organization_byok\" ? \"byok\" : billingClass;\n}\n\n/**\n * The same model through the same provider kind, whichever scope connected it:\n * `organization-anthropic/claude-opus-5-5` and `workspace-anthropic/claude-opus-5-5`\n * share a key, while OpenRouter and the Anthropic API never do (different\n * accounts and bills).\n */\nfunction scopeFreeIdentity(row: PickerModelRow<ClientModel>): string | null {\n const provider = row.provider.replace(/^(?:organization|workspace)-/, \"\");\n if (provider === row.provider) return null;\n const upstream =\n row.catalog.deployment?.upstreamModelId ??\n (row.id.startsWith(`${row.provider}/`) ? row.id.slice(row.provider.length + 1) : row.id);\n return `${provider}\\u0000${upstream}`;\n}\n\n/**\n * Two rows that are the same model through the same provider kind, connected\n * by the organization and by the workspace, are one choice: show one. Keep the\n * current selection, else a selectable row, else the first in picker order.\n */\nfunction prefersTwin<TCatalog extends ClientModel>(\n candidate: PickerModelRow<TCatalog>,\n current: PickerModelRow<TCatalog>,\n selectedId: string | undefined,\n): boolean {\n if (selectedId !== undefined && current.id === selectedId) return false;\n if (selectedId !== undefined && candidate.id === selectedId) return true;\n return candidate.selectable && !current.selectable;\n}\n\nexport function groupPickerRowsByBillingClass(\n rows: PickerModelRow[],\n options?: GroupPickerRowsOptions,\n): Array<{ billingClass: PickerBillingClass; label: string; rows: PickerModelRow[] }>;\nexport function groupPickerRowsByBillingClass<TCatalog extends ClientModel>(\n rows: PickerModelRow<TCatalog>[],\n options?: GroupPickerRowsOptions,\n): Array<{\n billingClass: PickerBillingClass;\n label: string;\n rows: PickerModelRow<TCatalog>[];\n}>;\nexport function groupPickerRowsByBillingClass<TCatalog extends ClientModel>(\n rows: PickerModelRow<TCatalog>[],\n options?: GroupPickerRowsOptions,\n): Array<{\n billingClass: PickerBillingClass;\n label: string;\n rows: PickerModelRow<TCatalog>[];\n}> {\n const sorted = sortPickerRows(rows);\n const groups: Array<{\n billingClass: PickerBillingClass;\n label: string;\n rows: PickerModelRow<TCatalog>[];\n }> = [];\n for (const row of sorted) {\n const collapse = options?.collapseScopes !== false;\n const billingClass = collapse ? displayGroupFor(row.billingClass) : row.billingClass;\n const existing = groups.find((group) => group.billingClass === billingClass);\n if (existing) {\n const identity = collapse ? scopeFreeIdentity(row) : null;\n const twin =\n identity === null\n ? -1\n : existing.rows.findIndex((candidate) => scopeFreeIdentity(candidate) === identity);\n if (twin < 0) {\n existing.rows.push(row);\n } else if (prefersTwin(row, existing.rows[twin]!, options?.selectedId)) {\n existing.rows[twin] = row;\n }\n continue;\n }\n groups.push({\n billingClass,\n label:\n billingClass === row.billingClass ? row.billingClassLabel : billingClassLabel(billingClass),\n rows: [row],\n });\n }\n const codexIndex = groups.findIndex((group) => group.billingClass === \"codex_subscription\");\n const codex = groups[codexIndex];\n const selectableOpenGeni = groups\n .find((group) => group.billingClass === \"opengeni_credits\")\n ?.rows.filter((row) => row.selectable);\n // Presentation only: never change the catalog/default model ordering or selection.\n const onlyFreeOpenGeni =\n selectableOpenGeni !== undefined &&\n selectableOpenGeni.length > 0 &&\n selectableOpenGeni.every((row) => row.catalog.cost === \"free\");\n if (\n codex &&\n codex.rows.some((row) => row.selectable) &&\n (options?.codexOnly || onlyFreeOpenGeni)\n ) {\n groups.splice(codexIndex, 1);\n groups.unshift(codex);\n }\n return groups;\n}\nexport { modelDisplayName, modelVendor } from \"@opengeni/sdk/model-display\";\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,wBAAwB;AAybjC,SAAS,oBAAAA,mBAAkB,mBAAmB;AAna9C,IAAM,uBAA2D;AAAA,EAC/D,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,oBAAoB;AAAA,EACpB,wBAAwB;AAAA,EACxB,qBAAqB;AAAA;AAAA;AAAA,EAGrB,MAAM;AAAA,EACN,mBAAmB;AACrB;AAGA,IAAM,8BAAkE;AAAA,EACtE,GAAG;AAAA,EACH,MAAM;AAAA,EACN,mBAAmB;AACrB;AAEA,IAAM,6BAAqD;AAAA,EACzD,oBAAoB;AAAA,EACpB,cAAc;AAAA,EACd,sBAAsB;AAAA,EACtB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,aAAa;AACf;AAEO,SAAS,qBAAqB,OAAwC;AAC3E,MAAI,MAAM,aAAa,0BAA0B,MAAM,aAAa,2BAA2B;AAC7F,WAAO;AAAA,EACT;AACA,MACE,MAAM,UAAU,WAAW,mBAAmB,KAC9C,MAAM,UAAU,WAAW,yBAAyB;AAEpD,WAAO;AACT,MAAI,MAAM,aAAa,uBAAuB,MAAM,aAAa,wBAAwB;AACvF,WAAO;AAAA,EACT;AACA,SAAO,2BAA2B,KAAK;AACzC;AAEO,SAAS,kBAAkB,cAA0C;AAC1E,SAAO,qBAAqB,YAAY;AAC1C;AAGO,SAAS,wBAAwB,cAA0C;AAChF,SAAO,4BAA4B,YAAY;AACjD;AAEO,SAAS,wBACd,QACe;AACf,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AACA,SAAO,2BAA2B,MAAM,KAAK;AAC/C;AAEO,SAAS,sBAAsB,OAAuC;AAC3E,QAAM,UAAU,MAAM,cAAc,UAAU;AAC9C,MAAI,CAAC,WAAW,QAAQ,WAAW,GAAG;AACpC,W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sources":["../src/model-policy.ts"],"sourcesContent":["import {\n compareModelPickerOrder,\n modelPickerBillingClassFor,\n type ModelPickerBillingClass,\n} from \"@opengeni/sdk/model-picker-order\";\nimport { modelDisplayName } from \"@opengeni/sdk/model-display\";\nimport type { ClientModel, ReasoningEffort, WorkspaceModelCatalogModel } from \"@opengeni/sdk\";\n\nexport type PickerBillingClass = ModelPickerBillingClass;\n\nexport type PickerModelRow<TCatalog extends ClientModel = WorkspaceModelCatalogModel> = {\n id: string;\n label: string;\n /** Catalog-curated compact label for dense UI; fall back to `label` when absent. */\n shortLabel?: string | undefined;\n billingClass: PickerBillingClass;\n billingClassLabel: string;\n selectable: boolean;\n unavailableReason: string | null;\n fundingHint?: string | undefined;\n provider: string;\n providerLabel: string;\n catalog: TCatalog;\n};\n\nexport type LatencyModeId = \"standard\" | \"priority\" | \"fast\";\n\nconst BILLING_CLASS_LABELS: Record<PickerBillingClass, string> = {\n opengeni_credits: \"Models\",\n external: \"External\",\n codex_subscription: \"Codex\",\n supergrok_subscription: \"SuperGrok\",\n claude_subscription: \"Claude subscription\",\n // Who connected the key (organization or workspace) is a settings fact, not\n // a model choice: both scopes share one label and one picker group.\n byok: \"API keys\",\n organization_byok: \"API keys\",\n};\n\n/** Models settings keeps naming who connected the key. */\nconst SCOPED_BILLING_CLASS_LABELS: Record<PickerBillingClass, string> = {\n ...BILLING_CLASS_LABELS,\n byok: \"Workspace providers\",\n organization_byok: \"Organization providers\",\n};\n\nconst AVAILABILITY_REASON_LABELS: Record<string, string> = {\n missing_credential: \"Credentials required\",\n needs_reauth: \"Reconnect required\",\n credential_not_ready: \"Credential not ready\",\n not_entitled: \"Not entitled\",\n provider_unhealthy: \"Provider unavailable\",\n policy_blocked: \"Blocked by workspace policy\",\n unsupported: \"Unsupported\",\n};\n\nexport function billingClassForModel(model: ClientModel): PickerBillingClass {\n if (model.provider === \"organization-gateway\" || model.provider === \"organization-openrouter\") {\n return \"organization_byok\";\n }\n if (\n model.provider?.startsWith(\"workspace-openai-\") ||\n model.provider?.startsWith(\"workspace-azure-openai-\")\n )\n return \"byok\";\n if (model.provider === \"workspace-gateway\" || model.provider === \"workspace-openrouter\") {\n return \"byok\";\n }\n return modelPickerBillingClassFor(model);\n}\n\nexport function billingClassLabel(billingClass: PickerBillingClass): string {\n return BILLING_CLASS_LABELS[billingClass];\n}\n\n/** The group label that names the connection scope, for Models settings only. */\nexport function scopedBillingClassLabel(billingClass: PickerBillingClass): string {\n return SCOPED_BILLING_CLASS_LABELS[billingClass];\n}\n\nexport function availabilityReasonLabel(\n reason: WorkspaceModelCatalogModel[\"availability\"][\"reason\"],\n): string | null {\n if (!reason) {\n return null;\n }\n return AVAILABILITY_REASON_LABELS[reason] ?? \"Unavailable\";\n}\n\nexport function effortOptionsForModel(model: ClientModel): ReasoningEffort[] {\n const efforts = model.capabilities?.reasoning.efforts;\n if (!efforts || efforts.length === 0) {\n return [\"low\"];\n }\n const order: ReasoningEffort[] = [\"none\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"];\n return order.filter((effort) => efforts.includes(effort));\n}\n\nexport function defaultEffortForModel(model: ClientModel): ReasoningEffort {\n const options = effortOptionsForModel(model);\n const configured = model.capabilities?.reasoning.defaultEffort;\n if (configured && options.includes(configured)) {\n return configured;\n }\n return options[0] ?? \"low\";\n}\n\nexport function coerceReasoningEffortForModel(\n model: ClientModel,\n effort: ReasoningEffort,\n): ReasoningEffort {\n const options = effortOptionsForModel(model);\n if (options.includes(effort)) {\n return effort;\n }\n return defaultEffortForModel(model);\n}\n\nexport function runnableLatencyModesForModel(model: ClientModel): LatencyModeId[] {\n const modes = model.capabilities?.latencyModes ?? [];\n return modes.filter((mode) => mode.runnable).map((mode) => mode.id);\n}\n\nexport function labelLatencyMode(mode: LatencyModeId): string {\n if (mode === \"fast\") {\n return \"Fast\";\n }\n if (mode === \"priority\") {\n return \"Priority\";\n }\n return \"Standard\";\n}\n\nexport function labelReasoningEffort(effort: ReasoningEffort): string {\n if (effort === \"xhigh\") {\n return \"Extra high\";\n }\n return effort.slice(0, 1).toUpperCase() + effort.slice(1);\n}\n\n/** Payment prompts must use cost policy, never the presentation group. */\nexport function modelUsesCredits(model: ClientModel | undefined): boolean {\n if (model?.cost !== undefined) return model.cost === \"credits\";\n return model?.billing?.metering === \"opengeni_credits\";\n}\n\nexport function payerSummaryForModel(model: ClientModel): string {\n if (model.cost === \"free\") {\n return \"Free in this deployment\";\n }\n if (model.cost === \"credits\") {\n return \"Opengeni credits\";\n }\n if (model.cost === \"subscription\") {\n return model.credentialSource?.kind === \"connected_subscription\" &&\n model.credentialSource.provider === \"claude\"\n ? \"Claude subscription · external billing\"\n : model.source === \"supergrok\"\n ? \"SuperGrok subscription · external billing\"\n : \"Codex subscription · external billing\";\n }\n if (model.cost === \"workspace\") {\n return workspaceProviderPayerSummary(model);\n }\n if (model.cost === \"organization\") {\n return organizationProviderPayerSummary(model);\n }\n\n // Older client-config payloads do not carry `cost`; preserve their existing\n // settlement-derived label until every deployment has rolled forward.\n const billing = model.billing;\n if (!billing) {\n return \"Route unknown\";\n }\n if (billing.metering === \"opengeni_credits\") {\n return \"Opengeni credits · automatic managed route\";\n }\n if (billing.upstreamPayer === \"connected_subscription\") {\n return model.credentialSource?.kind === \"connected_subscription\" &&\n model.credentialSource.provider === \"claude\"\n ? \"Claude subscription · external billing\"\n : model.source === \"supergrok\"\n ? \"SuperGrok subscription · external billing\"\n : \"Codex subscription · external billing\";\n }\n if (billing.upstreamPayer === \"workspace\") {\n return workspaceProviderPayerSummary(model);\n }\n if (billing.upstreamPayer === \"organization\") {\n return organizationProviderPayerSummary(model);\n }\n return billing.upstreamPayer === \"deployment\"\n ? \"Opengeni · no model credits\"\n : \"External provider · no Opengeni credits\";\n}\n\nexport function advancedSourceSummary(model: ClientModel): string | null {\n const source = model.credentialSource;\n if (!source) {\n return model.billing?.metering === \"external\" && model.billing.upstreamPayer === \"deployment\"\n ? \"Deployment-provided connection\"\n : null;\n }\n if (source.kind === \"connected_subscription\") {\n return source.provider === \"claude\"\n ? \"Connected Claude subscription\"\n : source.provider === \"xai\"\n ? \"Connected SuperGrok subscription\"\n : \"Connected Codex subscription\";\n }\n if (source.kind === \"workspace_connection\") {\n if (model.provider === \"workspace-openrouter\") {\n return \"Workspace OpenRouter connection\";\n }\n if (model.provider === \"workspace-gateway\" || model.source === \"workspace_gateway\") {\n return \"Workspace Vercel AI Gateway\";\n }\n return \"Workspace provider connection\";\n }\n if (source.kind === \"deployment\") {\n return source.mechanism === \"azure_ad_bearer\"\n ? \"Deployment Azure identity\"\n : \"Deployment API key\";\n }\n return null;\n}\n\nfunction workspaceProviderPayerSummary(model: ClientModel): string {\n if (model.provider === \"workspace-anthropic\")\n return \"Billed to the workspace Anthropic API account\";\n if (model.provider === \"workspace-claude-subscription\")\n return \"Uses the workspace Claude subscription · no Opengeni credits\";\n if (model.provider === \"workspace-openrouter\") {\n return \"Billed to the workspace OpenRouter account\";\n }\n if (model.provider === \"workspace-gateway\" || model.source === \"workspace_gateway\") {\n return \"Billed to the workspace Vercel account\";\n }\n return \"Billed to the workspace provider account\";\n}\n\nfunction organizationProviderPayerSummary(model: ClientModel): string {\n if (model.provider === \"organization-anthropic\")\n return \"Billed to the organization Anthropic API account\";\n if (model.provider === \"organization-claude-subscription\")\n return \"Uses the connected Claude subscription · no Opengeni credits\";\n if (model.provider === \"organization-openrouter\") {\n return \"Billed to the organization OpenRouter account\";\n }\n if (model.provider === \"organization-gateway\") {\n return \"Billed to the organization Vercel account\";\n }\n return \"Billed to the organization provider account\";\n}\n\n/**\n * The curated compact label, else the family-free name for Claude models\n * (\"Opus 5.5\"): the maker's mark beside it already says Claude.\n */\nfunction compactLabel(catalog: ClientModel): { shortLabel?: string } {\n if (catalog.shortLabel) return { shortLabel: catalog.shortLabel };\n const name = modelDisplayName(catalog);\n return name.startsWith(\"Claude \") ? { shortLabel: name.slice(\"Claude \".length) } : {};\n}\n\nexport function projectPickerRows(models: WorkspaceModelCatalogModel[]): PickerModelRow[] {\n return models\n .filter((catalog) => catalog.credentialReadiness.status === \"ready\")\n .map((catalog) => {\n const billingClass = billingClassForModel(catalog);\n return {\n id: catalog.id,\n label: modelDisplayName(catalog),\n ...compactLabel(catalog),\n billingClass,\n billingClassLabel: billingClassLabel(billingClass),\n selectable: catalog.availability.selectable,\n fundingHint:\n catalog.creditFunding === \"promotional\"\n ? \"Free credits\"\n : catalog.creditFunding === \"general\"\n ? \"Uses credits\"\n : catalog.creditFunding === \"unavailable\"\n ? \"Needs credits\"\n : undefined,\n unavailableReason: catalog.availability.selectable\n ? null\n : availabilityReasonLabel(catalog.availability.reason),\n provider: catalog.provider,\n providerLabel: catalog.providerLabel,\n catalog,\n };\n });\n}\n\n/** Project the lightweight client-config model list into the same picker contract. */\nexport function projectClientModelRows(models: ClientModel[]): PickerModelRow<ClientModel>[] {\n return models.map((catalog) => {\n const billingClass = billingClassForModel(catalog);\n return {\n id: catalog.id,\n label: modelDisplayName(catalog),\n ...compactLabel(catalog),\n billingClass,\n billingClassLabel: billingClassLabel(billingClass),\n selectable: true,\n unavailableReason: null,\n provider: catalog.provider,\n providerLabel: catalog.providerLabel,\n catalog,\n };\n });\n}\n\nexport function sortPickerRows<TCatalog extends ClientModel>(\n rows: PickerModelRow<TCatalog>[],\n): PickerModelRow<TCatalog>[] {\n return [...rows].sort(compareModelPickerOrder);\n}\n\nexport function findPickerRow<TCatalog extends ClientModel>(\n rows: PickerModelRow<TCatalog>[],\n modelId: string,\n): PickerModelRow<TCatalog> | null {\n return rows.find((row) => row.id === modelId) ?? null;\n}\n\nexport type GroupPickerRowsOptions = {\n codexOnly?: boolean;\n /**\n * Default true: organization- and workspace-connected keys share one group\n * and identical copies show once. Models settings passes false.\n */\n collapseScopes?: boolean | undefined;\n /** Kept visible when it has an identical twin (see below). */\n selectedId?: string | undefined;\n};\n\n/**\n * Organization- and workspace-connected API keys are one choice for the person\n * picking a model, so they share one group.\n */\nfunction displayGroupFor(billingClass: PickerBillingClass): PickerBillingClass {\n return billingClass === \"organization_byok\" ? \"byok\" : billingClass;\n}\n\n/**\n * The same model through the same provider kind, whichever scope connected it:\n * `organization-anthropic/claude-opus-5-5` and `workspace-anthropic/claude-opus-5-5`\n * share a key, while OpenRouter and the Anthropic API never do (different\n * accounts and bills).\n */\nfunction scopeFreeIdentity(row: PickerModelRow<ClientModel>): string | null {\n const provider = row.provider.replace(/^(?:organization|workspace)-/, \"\");\n if (provider === row.provider) return null;\n const upstream =\n row.catalog.deployment?.upstreamModelId ??\n (row.id.startsWith(`${row.provider}/`) ? row.id.slice(row.provider.length + 1) : row.id);\n return `${provider}\\u0000${upstream}`;\n}\n\n/**\n * Two rows that are the same model through the same provider kind, connected\n * by the organization and by the workspace, are one choice: show one. Keep the\n * current selection, else a selectable row, else the first in picker order.\n */\nfunction prefersTwin<TCatalog extends ClientModel>(\n candidate: PickerModelRow<TCatalog>,\n current: PickerModelRow<TCatalog>,\n selectedId: string | undefined,\n): boolean {\n if (selectedId !== undefined && current.id === selectedId) return false;\n if (selectedId !== undefined && candidate.id === selectedId) return true;\n return candidate.selectable && !current.selectable;\n}\n\nexport function groupPickerRowsByBillingClass(\n rows: PickerModelRow[],\n options?: GroupPickerRowsOptions,\n): Array<{ billingClass: PickerBillingClass; label: string; rows: PickerModelRow[] }>;\nexport function groupPickerRowsByBillingClass<TCatalog extends ClientModel>(\n rows: PickerModelRow<TCatalog>[],\n options?: GroupPickerRowsOptions,\n): Array<{\n billingClass: PickerBillingClass;\n label: string;\n rows: PickerModelRow<TCatalog>[];\n}>;\nexport function groupPickerRowsByBillingClass<TCatalog extends ClientModel>(\n rows: PickerModelRow<TCatalog>[],\n options?: GroupPickerRowsOptions,\n): Array<{\n billingClass: PickerBillingClass;\n label: string;\n rows: PickerModelRow<TCatalog>[];\n}> {\n const sorted = sortPickerRows(rows);\n const groups: Array<{\n billingClass: PickerBillingClass;\n label: string;\n rows: PickerModelRow<TCatalog>[];\n }> = [];\n for (const row of sorted) {\n const collapse = options?.collapseScopes !== false;\n const billingClass = collapse ? displayGroupFor(row.billingClass) : row.billingClass;\n const existing = groups.find((group) => group.billingClass === billingClass);\n if (existing) {\n const identity = collapse ? scopeFreeIdentity(row) : null;\n const twin =\n identity === null\n ? -1\n : existing.rows.findIndex((candidate) => scopeFreeIdentity(candidate) === identity);\n if (twin < 0) {\n existing.rows.push(row);\n } else if (prefersTwin(row, existing.rows[twin]!, options?.selectedId)) {\n existing.rows[twin] = row;\n }\n continue;\n }\n groups.push({\n billingClass,\n label:\n billingClass === row.billingClass ? row.billingClassLabel : billingClassLabel(billingClass),\n rows: [row],\n });\n }\n const codexIndex = groups.findIndex((group) => group.billingClass === \"codex_subscription\");\n const codex = groups[codexIndex];\n const selectableOpenGeni = groups\n .find((group) => group.billingClass === \"opengeni_credits\")\n ?.rows.filter((row) => row.selectable);\n // Presentation only: never change the catalog/default model ordering or selection.\n const onlyFreeOpenGeni =\n selectableOpenGeni !== undefined &&\n selectableOpenGeni.length > 0 &&\n selectableOpenGeni.every((row) => row.catalog.cost === \"free\");\n if (\n codex &&\n codex.rows.some((row) => row.selectable) &&\n (options?.codexOnly || onlyFreeOpenGeni)\n ) {\n groups.splice(codexIndex, 1);\n groups.unshift(codex);\n }\n return groups;\n}\nexport { modelDisplayName, modelVendor } from \"@opengeni/sdk/model-display\";\n"],"mappings":";;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,wBAAwB;AAybjC,SAAS,oBAAAA,mBAAkB,mBAAmB;AAna9C,IAAM,uBAA2D;AAAA,EAC/D,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,oBAAoB;AAAA,EACpB,wBAAwB;AAAA,EACxB,qBAAqB;AAAA;AAAA;AAAA,EAGrB,MAAM;AAAA,EACN,mBAAmB;AACrB;AAGA,IAAM,8BAAkE;AAAA,EACtE,GAAG;AAAA,EACH,MAAM;AAAA,EACN,mBAAmB;AACrB;AAEA,IAAM,6BAAqD;AAAA,EACzD,oBAAoB;AAAA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SAAS,UAAU,GAAG;AACtE,iBAAS,KAAK,IAAI,IAAI;AAAA,MACxB;AACA;AAAA,IACF;AACA,WAAO,KAAK;AAAA,MACV;AAAA,MACA,OACE,iBAAiB,IAAI,eAAe,IAAI,oBAAoB,kBAAkB,YAAY;AAAA,MAC5F,MAAM,CAAC,GAAG;AAAA,IACZ,CAAC;AAAA,EACH;AACA,QAAM,aAAa,OAAO,UAAU,CAAC,UAAU,MAAM,iBAAiB,oBAAoB;AAC1F,QAAM,QAAQ,OAAO,UAAU;AAC/B,QAAM,qBAAqB,OACxB,KAAK,CAAC,UAAU,MAAM,iBAAiB,kBAAkB,GACxD,KAAK,OAAO,CAAC,QAAQ,IAAI,UAAU;AAEvC,QAAM,mBACJ,uBAAuB,UACvB,mBAAmB,SAAS,KAC5B,mBAAmB,MAAM,CAAC,QAAQ,IAAI,QAAQ,SAAS,MAAM;AAC/D,MACE,SACA,MAAM,KAAK,KAAK,CAAC,QAAQ,IAAI,UAAU,MACtC,SAAS,aAAa,mBACvB;AACA,WAAO,OAAO,YAAY,CAAC;AAC3B,WAAO,QAAQ,KAAK;AAAA,EACtB;AACA,SAAO;AACT;","names":["modelDisplayName"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
// src/session-context.ts
|
|
2
4
|
import { createContext, useContext } from "react";
|
|
3
5
|
var OpenGeniContext = createContext(null);
|
|
@@ -249,4 +251,4 @@ export {
|
|
|
249
251
|
useEmbeddedRealtimeSession,
|
|
250
252
|
useOpenGeniClient
|
|
251
253
|
};
|
|
252
|
-
//# sourceMappingURL=chunk-
|
|
254
|
+
//# sourceMappingURL=chunk-XTD7TZHW.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/session-context.ts"],"sourcesContent":["import type {\n StreamConnectionState,\n WorkspaceControlEvent,\n WorkspaceInteractionRevisionEvent,\n} from \"@opengeni/sdk\";\nimport { createContext, useContext } from \"react\";\nimport type {\n EmbeddedFileAttachmentClientLike,\n EmbeddedGoalClientLike,\n EmbeddedHumanInputSessionClientLike,\n EmbeddedBrowserInteractionClientLike,\n EmbeddedComputerInteractionClientLike,\n EmbeddedInteractionClientLike,\n EmbeddedInterventionClientLike,\n EmbeddedRealtimeSessionClientLike,\n EmbeddedSessionClientLike,\n EmbeddedSessionLineageClientLike,\n EmbeddedSessionMcpApprovalPolicyClientLike,\n EmbeddedSessionReadClientLike,\n SessionClientLike,\n} from \"./client\";\n\nexport type OpenGeniContextValue = {\n client: SessionClientLike;\n workspaceId: string;\n workspaceControlEvent: WorkspaceControlEvent | null;\n workspaceControlConnectionState: StreamConnectionState | \"idle\" | \"error\";\n workspaceInteractionEvent: WorkspaceInteractionRevisionEvent | null;\n workspaceInteractionConnectionState: StreamConnectionState | \"idle\" | \"error\";\n registerSessionReconciler: (\n sessionId: string,\n key: string,\n reconcile: () => Promise<void>,\n ) => () => void;\n reconcileSession: (sessionId: string) => Promise<void>;\n};\n\nexport const OpenGeniContext = createContext<OpenGeniContextValue | null>(null);\n\nconst NOOP_REGISTER_RECONCILER: OpenGeniContextValue[\"registerSessionReconciler\"] = () => () =>\n undefined;\nconst NOOP_RECONCILE_SESSION: OpenGeniContextValue[\"reconcileSession\"] = async () => undefined;\n\nexport type ClientOverride = {\n client?: SessionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedSessionClientOverride = {\n client?: EmbeddedSessionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedHumanInputClientOverride = {\n client?: EmbeddedHumanInputSessionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedSessionMcpApprovalPolicyClientOverride = {\n client?: EmbeddedSessionMcpApprovalPolicyClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedSessionReadClientOverride = {\n client?: EmbeddedSessionReadClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedRealtimeSessionClientOverride = {\n client?: EmbeddedRealtimeSessionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedGoalClientOverride = {\n client?: EmbeddedGoalClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedSessionLineageClientOverride = {\n client?: EmbeddedSessionLineageClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedFileAttachmentClientOverride = {\n client?: EmbeddedFileAttachmentClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedInteractionClientOverride = {\n client?: EmbeddedInteractionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedInterventionClientOverride = {\n client?: EmbeddedInterventionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedBrowserInteractionClientOverride = {\n client?: EmbeddedBrowserInteractionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedComputerInteractionClientOverride = {\n client?: EmbeddedComputerInteractionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedSessionContextValue = Omit<OpenGeniContextValue, \"client\"> & {\n client: EmbeddedSessionClientLike;\n};\n\ntype EmbeddedClientOverride<TClient> = {\n client?: TClient | undefined;\n workspaceId?: string | undefined;\n};\n\ntype EmbeddedClientContextValue<TClient> = Omit<OpenGeniContextValue, \"client\"> & {\n client: TClient;\n};\n\nfunction useEmbeddedClientRefinement<TClient extends object>(\n override: EmbeddedClientOverride<TClient>,\n requiredMethods: readonly string[],\n hookName: string,\n): EmbeddedClientContextValue<TClient> {\n const context = useContext(OpenGeniContext);\n const candidate = override.client ?? context?.client;\n const workspaceId = override.workspaceId ?? context?.workspaceId;\n if (!candidate || !workspaceId) {\n throw new Error(\n \"@opengeni/react: no Opengeni client/workspace available. Wrap the tree in <OpenGeniProvider> or pass { client, workspaceId } to the hook.\",\n );\n }\n const methods = candidate as Record<string, unknown>;\n const missing = requiredMethods.filter((method) => typeof methods[method] !== \"function\");\n if (missing.length > 0) {\n throw new Error(\n `@opengeni/react: ${hookName} requires client method${missing.length === 1 ? \"\" : \"s\"} ${missing.join(\", \")}.`,\n );\n }\n return {\n client: candidate as TClient,\n workspaceId,\n workspaceControlEvent: context?.workspaceControlEvent ?? null,\n workspaceControlConnectionState: context?.workspaceControlConnectionState ?? \"idle\",\n workspaceInteractionEvent: context?.workspaceInteractionEvent ?? null,\n workspaceInteractionConnectionState: context?.workspaceInteractionConnectionState ?? \"idle\",\n registerSessionReconciler: context?.registerSessionReconciler ?? NOOP_REGISTER_RECONCILER,\n reconcileSession: context?.reconcileSession ?? NOOP_RECONCILE_SESSION,\n };\n}\n\nfunction eventClientMethods(override: object, directMethods: readonly string[]): readonly string[] {\n const hasSharedEventFeed =\n \"events\" in override && (override as { events?: unknown }).events !== undefined;\n return hasSharedEventFeed ? directMethods : [\"getSession\", \"streamEvents\", ...directMethods];\n}\n\n/** Resolve client + workspace from explicit overrides or the provider. */\nexport function useOpenGeni(override: ClientOverride = {}): OpenGeniContextValue {\n const context = useContext(OpenGeniContext);\n const client = override.client ?? context?.client;\n const workspaceId = override.workspaceId ?? context?.workspaceId;\n if (!client || !workspaceId) {\n throw new Error(\n \"@opengeni/react: no Opengeni client/workspace available. Wrap the tree in <OpenGeniProvider> or pass { client, workspaceId } to the hook.\",\n );\n }\n return {\n client,\n workspaceId,\n workspaceControlEvent: context?.workspaceControlEvent ?? null,\n workspaceControlConnectionState: context?.workspaceControlConnectionState ?? \"idle\",\n workspaceInteractionEvent: context?.workspaceInteractionEvent ?? null,\n workspaceInteractionConnectionState: context?.workspaceInteractionConnectionState ?? \"idle\",\n registerSessionReconciler: context?.registerSessionReconciler ?? NOOP_REGISTER_RECONCILER,\n reconcileSession: context?.reconcileSession ?? NOOP_RECONCILE_SESSION,\n };\n}\n\nconst BROWSER_INTERACTION_METHODS = [\n \"streamWorkspaceInteractionRevisions\",\n \"listNetworkRoutes\",\n \"getNetworkRoute\",\n \"createNetworkRoute\",\n \"updateNetworkRoute\",\n \"listSiteAuthConnections\",\n \"getSiteAuthConnection\",\n \"createSiteAuthConnection\",\n \"updateSiteAuthConnection\",\n \"listAuthRuns\",\n \"getAuthRun\",\n \"startBrowserAuthRun\",\n \"reportBrowserAuthRun\",\n \"protectedBrowserAuthFill\",\n \"verifyBrowserAuthRun\",\n \"listInteractionInterventions\",\n \"getInteractionIntervention\",\n \"createInteractionIntervention\",\n \"resolveInteractionIntervention\",\n \"listAttachedBrowsers\",\n \"getAttachedBrowser\",\n \"listBrowserIdentities\",\n \"getBrowserIdentity\",\n \"createBrowserIdentity\",\n \"updateBrowserIdentity\",\n \"listBrowserRevisions\",\n \"listBrowserSessions\",\n \"getBrowserSession\",\n \"readBrowserClipboard\",\n \"listBrowserDownloads\",\n \"getBrowserDownload\",\n \"saveBrowserDownload\",\n \"createBrowserSession\",\n \"listBrowserTargets\",\n \"openBrowserTarget\",\n \"selectBrowserTarget\",\n \"closeBrowserTarget\",\n \"observeBrowserTarget\",\n \"actInBrowser\",\n \"getBrowserActionReceipt\",\n \"listBrowserDiagnostics\",\n \"attachBrowserSession\",\n \"heartbeatBrowserSession\",\n \"publishBrowserRevision\",\n \"suspendBrowserSession\",\n \"resumeBrowserSession\",\n \"endBrowserSession\",\n] as const;\n\nconst COMPUTER_INTERACTION_METHODS = [\n \"streamWorkspaceInteractionRevisions\",\n \"listInteractionInterventions\",\n \"getInteractionIntervention\",\n \"createInteractionIntervention\",\n \"resolveInteractionIntervention\",\n \"listComputerSessions\",\n \"getComputerSession\",\n \"readComputerClipboard\",\n \"createComputerSession\",\n \"listComputerTargets\",\n \"observeComputerTarget\",\n \"actInComputer\",\n \"getComputerActionReceipt\",\n \"attachComputerSession\",\n \"heartbeatComputerSession\",\n \"endComputerSession\",\n] as const;\n\nconst INTERVENTION_METHODS = [\n \"streamWorkspaceInteractionRevisions\",\n \"listInteractionInterventions\",\n \"getInteractionIntervention\",\n \"createInteractionIntervention\",\n \"resolveInteractionIntervention\",\n] as const;\n\n/** Resolve only the workspace-wide Browser/Computer intervention surface. */\nexport function useEmbeddedInterventions(\n override: EmbeddedInterventionClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedInterventionClientLike> {\n return useEmbeddedClientRefinement(\n override,\n INTERVENTION_METHODS,\n \"interaction intervention hooks\",\n );\n}\n\n/** Resolve only BrowserSession methods for a standalone Browser embed. */\nexport function useEmbeddedBrowserInteraction(\n override: EmbeddedBrowserInteractionClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedBrowserInteractionClientLike> {\n return useEmbeddedClientRefinement(\n override,\n BROWSER_INTERACTION_METHODS,\n \"browser interaction hooks\",\n );\n}\n\n/** Resolve only ComputerSession methods for a standalone Computer embed. */\nexport function useEmbeddedComputerInteraction(\n override: EmbeddedComputerInteractionClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedComputerInteractionClientLike> {\n return useEmbeddedClientRefinement(\n override,\n COMPUTER_INTERACTION_METHODS,\n \"computer interaction hooks\",\n );\n}\n\n/** Resolve the complete Browser + Computer client surface. */\nexport function useEmbeddedInteraction(\n override: EmbeddedInteractionClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedInteractionClientLike> {\n return useEmbeddedClientRefinement(\n override,\n [...BROWSER_INTERACTION_METHODS, ...COMPUTER_INTERACTION_METHODS],\n \"interaction hooks\",\n );\n}\n\n/**\n * Resolve the narrow client required by the session-only hooks. The full\n * provider client is structurally compatible, while an explicit host proxy\n * only needs to expose session/event/composer/queue/control operations.\n */\nexport function useEmbeddedSession(\n override: EmbeddedSessionClientOverride = {},\n): EmbeddedSessionContextValue {\n return useEmbeddedClientRefinement(\n override,\n [\n \"getSession\",\n \"listEvents\",\n \"streamEvents\",\n \"getComposerDraft\",\n \"saveComposerDraft\",\n \"submitComposerDraft\",\n \"sendMessage\",\n \"steerMessage\",\n \"getQueue\",\n \"moveQueueItem\",\n \"editQueueItem\",\n \"steerQueueItem\",\n \"deleteQueueItem\",\n \"pauseSession\",\n \"resumeSession\",\n \"sendApprovalDecision\",\n ],\n \"session hooks\",\n );\n}\n\n/** Resolve the exact client surface required by `useSession`. */\nexport function useEmbeddedSessionRead(\n override: EmbeddedSessionReadClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedSessionReadClientLike> {\n return useEmbeddedClientRefinement(\n override,\n eventClientMethods(override, [\"getSession\", \"updateSession\"]),\n \"useSession\",\n );\n}\n\n/** Resolve the exact client surface required by `useGoal`. */\nexport function useEmbeddedGoal(\n override: EmbeddedGoalClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedGoalClientLike> {\n return useEmbeddedClientRefinement(\n override,\n eventClientMethods(override, [\"getGoal\", \"updateGoal\", \"deleteGoal\"]),\n \"useGoal\",\n );\n}\n\n/** Resolve the exact client surface required by `useSessionLineage`. */\nexport function useEmbeddedSessionLineage(\n override: EmbeddedSessionLineageClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedSessionLineageClientLike> {\n return useEmbeddedClientRefinement(\n override,\n eventClientMethods(override, [\"getSessionLineage\"]),\n \"useSessionLineage\",\n );\n}\n\n/** Resolve the exact client surface required by `useFileAttachments`. */\nexport function useEmbeddedFileAttachments(\n override: EmbeddedFileAttachmentClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedFileAttachmentClientLike> {\n return useEmbeddedClientRefinement(override, [\"uploadFile\"], \"useFileAttachments\");\n}\n\n/**\n * Resolve the structured-input refinement without widening the baseline\n * session-only proxy contract.\n */\nexport function useEmbeddedHumanInputSession(override: EmbeddedHumanInputClientOverride = {}): Omit<\n EmbeddedSessionContextValue,\n \"client\"\n> & {\n client: EmbeddedHumanInputSessionClientLike;\n} {\n return useEmbeddedClientRefinement(\n override,\n eventClientMethods(override, [\"listHumanInputRequests\", \"submitHumanInputResponse\"]),\n \"useHumanInputRequests\",\n );\n}\n\n/** Resolve the approval-policy refinement without widening session-only hosts. */\nexport function useEmbeddedSessionMcpApprovalPolicy(\n override: EmbeddedSessionMcpApprovalPolicyClientOverride = {},\n): Omit<EmbeddedSessionContextValue, \"client\"> & {\n client: EmbeddedSessionMcpApprovalPolicyClientLike;\n} {\n return useEmbeddedClientRefinement(\n override,\n eventClientMethods(override, [\"getSession\", \"updateSessionMcpApprovalPolicy\"]),\n \"useSessionMcpApprovalPolicy\",\n );\n}\n\n/** Resolve the exact browser/API surface required by `@opengeni/react/realtime`. */\nexport function useEmbeddedRealtimeSession(\n override: EmbeddedRealtimeSessionClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedRealtimeSessionClientLike> {\n // Preserve the existing lazy capability behavior: proxy/test clients may\n // implement only the methods reached by their selected model and lifecycle.\n // The exported structural type remains the complete embedding contract.\n return useEmbeddedClientRefinement(override, [], \"realtime hooks\");\n}\n\n/**\n * Resolve the client only — for hooks that are not workspace-scoped\n * (`useWorkspaces`, `useBillingUsage`).\n */\nexport function useOpenGeniClient(\n override: Pick<ClientOverride, \"client\"> = {},\n): SessionClientLike {\n const context = useContext(OpenGeniContext);\n const client = override.client ?? context?.client;\n if (!client) {\n throw new Error(\n \"@opengeni/react: no Opengeni client available. Wrap the tree in <OpenGeniProvider> or pass { client } to the hook.\",\n );\n }\n return client;\n}\n"],"mappings":";AAKA,SAAS,eAAe,kBAAkB;AAgCnC,IAAM,kBAAkB,cAA2C,IAAI;AAE9E,IAAM,2BAA8E,MAAM,MACxF;AACF,IAAM,yBAAmE,YAAY;AAgFrF,SAAS,4BACP,UACA,iBACA,UACqC;AACrC,QAAM,UAAU,WAAW,eAAe;AAC1C,QAAM,YAAY,SAAS,UAAU,SAAS;AAC9C,QAAM,cAAc,SAAS,eAAe,SAAS;AACrD,MAAI,CAAC,aAAa,CAAC,aAAa;AAC9B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,QAAM,UAAU;AAChB,QAAM,UAAU,gBAAgB,OAAO,CAAC,WAAW,OAAO,QAAQ,MAAM,MAAM,UAAU;AACxF,MAAI,QAAQ,SAAS,GAAG;AACtB,UAAM,IAAI;AAAA,MACR,oBAAoB,QAAQ,0BAA0B,QAA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AA,MACA;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;AAGO,SAAS,uBACd,WAA8C,CAAC,GACY;AAC3D,SAAO;AAAA,IACL;AAAA,IACA,mBAAmB,UAAU,CAAC,cAAc,eAAe,CAAC;AAAA,IAC5D;AAAA,EACF;AACF;AAGO,SAAS,gBACd,WAAuC,CAAC,GACY;AACpD,SAAO;AAAA,IACL;AAAA,IACA,mBAAmB,UAAU,CAAC,WAAW,cAAc,YAAY,CAAC;AAAA,IACpE;AAAA,EACF;AACF;AAGO,SAAS,0BACd,WAAiD,CAAC,GACY;AAC9D,SAAO;AAAA,IACL;AAAA,IACA,mBAAmB,UAAU,CAAC,mBAAmB,CAAC;AAAA,IAClD;AAAA,EACF;AACF;AAGO,SAAS,2BACd,WAAiD,CAAC,GACY;AAC9D,SAAO,4BAA4B,UAAU,CAAC,YAAY,GAAG,oBAAoB;AACnF;AAMO,SAAS,6BAA6B,WAA6C,CAAC,GAKzF;AACA,SAAO;AAAA,IACL;AAAA,IACA,mBAAmB,UAAU,CAAC,0BAA0B,0BAA0B,CAAC;AAAA,IACnF;AAAA,EACF;AACF;AAGO,SAAS,oCACd,WAA2D,CAAC,GAG5D;AACA,SAAO;AAAA,IACL;AAAA,IACA,mBAAmB,UAAU,CAAC,cAAc,gCAAgC,CAAC;AAAA,IAC7E;AAAA,EACF;AACF;AAGO,SAAS,2BACd,WAAkD,CAAC,GACY;AAI/D,SAAO,4BAA4B,UAAU,CAAC,GAAG,gBAAgB;AACnE;AAMO,SAAS,kBACd,WAA2C,CAAC,GACzB;AACnB,QAAM,UAAU,WAAW,eAAe;AAC1C,QAAM,SAAS,SAAS,UAAU,SAAS;AAC3C,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/session-context.ts"],"sourcesContent":["import type {\n StreamConnectionState,\n WorkspaceControlEvent,\n WorkspaceInteractionRevisionEvent,\n} from \"@opengeni/sdk\";\nimport { createContext, useContext } from \"react\";\nimport type {\n EmbeddedFileAttachmentClientLike,\n EmbeddedGoalClientLike,\n EmbeddedHumanInputSessionClientLike,\n EmbeddedBrowserInteractionClientLike,\n EmbeddedComputerInteractionClientLike,\n EmbeddedInteractionClientLike,\n EmbeddedInterventionClientLike,\n EmbeddedRealtimeSessionClientLike,\n EmbeddedSessionClientLike,\n EmbeddedSessionLineageClientLike,\n EmbeddedSessionMcpApprovalPolicyClientLike,\n EmbeddedSessionReadClientLike,\n SessionClientLike,\n} from \"./client\";\n\nexport type OpenGeniContextValue = {\n client: SessionClientLike;\n workspaceId: string;\n workspaceControlEvent: WorkspaceControlEvent | null;\n workspaceControlConnectionState: StreamConnectionState | \"idle\" | \"error\";\n workspaceInteractionEvent: WorkspaceInteractionRevisionEvent | null;\n workspaceInteractionConnectionState: StreamConnectionState | \"idle\" | \"error\";\n registerSessionReconciler: (\n sessionId: string,\n key: string,\n reconcile: () => Promise<void>,\n ) => () => void;\n reconcileSession: (sessionId: string) => Promise<void>;\n};\n\nexport const OpenGeniContext = createContext<OpenGeniContextValue | null>(null);\n\nconst NOOP_REGISTER_RECONCILER: OpenGeniContextValue[\"registerSessionReconciler\"] = () => () =>\n undefined;\nconst NOOP_RECONCILE_SESSION: OpenGeniContextValue[\"reconcileSession\"] = async () => undefined;\n\nexport type ClientOverride = {\n client?: SessionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedSessionClientOverride = {\n client?: EmbeddedSessionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedHumanInputClientOverride = {\n client?: EmbeddedHumanInputSessionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedSessionMcpApprovalPolicyClientOverride = {\n client?: EmbeddedSessionMcpApprovalPolicyClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedSessionReadClientOverride = {\n client?: EmbeddedSessionReadClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedRealtimeSessionClientOverride = {\n client?: EmbeddedRealtimeSessionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedGoalClientOverride = {\n client?: EmbeddedGoalClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedSessionLineageClientOverride = {\n client?: EmbeddedSessionLineageClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedFileAttachmentClientOverride = {\n client?: EmbeddedFileAttachmentClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedInteractionClientOverride = {\n client?: EmbeddedInteractionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedInterventionClientOverride = {\n client?: EmbeddedInterventionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedBrowserInteractionClientOverride = {\n client?: EmbeddedBrowserInteractionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedComputerInteractionClientOverride = {\n client?: EmbeddedComputerInteractionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\nexport type EmbeddedSessionContextValue = Omit<OpenGeniContextValue, \"client\"> & {\n client: EmbeddedSessionClientLike;\n};\n\ntype EmbeddedClientOverride<TClient> = {\n client?: TClient | undefined;\n workspaceId?: string | undefined;\n};\n\ntype EmbeddedClientContextValue<TClient> = Omit<OpenGeniContextValue, \"client\"> & {\n client: TClient;\n};\n\nfunction useEmbeddedClientRefinement<TClient extends object>(\n override: EmbeddedClientOverride<TClient>,\n requiredMethods: readonly string[],\n hookName: string,\n): EmbeddedClientContextValue<TClient> {\n const context = useContext(OpenGeniContext);\n const candidate = override.client ?? context?.client;\n const workspaceId = override.workspaceId ?? context?.workspaceId;\n if (!candidate || !workspaceId) {\n throw new Error(\n \"@opengeni/react: no Opengeni client/workspace available. Wrap the tree in <OpenGeniProvider> or pass { client, workspaceId } to the hook.\",\n );\n }\n const methods = candidate as Record<string, unknown>;\n const missing = requiredMethods.filter((method) => typeof methods[method] !== \"function\");\n if (missing.length > 0) {\n throw new Error(\n `@opengeni/react: ${hookName} requires client method${missing.length === 1 ? \"\" : \"s\"} ${missing.join(\", \")}.`,\n );\n }\n return {\n client: candidate as TClient,\n workspaceId,\n workspaceControlEvent: context?.workspaceControlEvent ?? null,\n workspaceControlConnectionState: context?.workspaceControlConnectionState ?? \"idle\",\n workspaceInteractionEvent: context?.workspaceInteractionEvent ?? null,\n workspaceInteractionConnectionState: context?.workspaceInteractionConnectionState ?? \"idle\",\n registerSessionReconciler: context?.registerSessionReconciler ?? NOOP_REGISTER_RECONCILER,\n reconcileSession: context?.reconcileSession ?? NOOP_RECONCILE_SESSION,\n };\n}\n\nfunction eventClientMethods(override: object, directMethods: readonly string[]): readonly string[] {\n const hasSharedEventFeed =\n \"events\" in override && (override as { events?: unknown }).events !== undefined;\n return hasSharedEventFeed ? directMethods : [\"getSession\", \"streamEvents\", ...directMethods];\n}\n\n/** Resolve client + workspace from explicit overrides or the provider. */\nexport function useOpenGeni(override: ClientOverride = {}): OpenGeniContextValue {\n const context = useContext(OpenGeniContext);\n const client = override.client ?? context?.client;\n const workspaceId = override.workspaceId ?? context?.workspaceId;\n if (!client || !workspaceId) {\n throw new Error(\n \"@opengeni/react: no Opengeni client/workspace available. Wrap the tree in <OpenGeniProvider> or pass { client, workspaceId } to the hook.\",\n );\n }\n return {\n client,\n workspaceId,\n workspaceControlEvent: context?.workspaceControlEvent ?? null,\n workspaceControlConnectionState: context?.workspaceControlConnectionState ?? \"idle\",\n workspaceInteractionEvent: context?.workspaceInteractionEvent ?? null,\n workspaceInteractionConnectionState: context?.workspaceInteractionConnectionState ?? \"idle\",\n registerSessionReconciler: context?.registerSessionReconciler ?? NOOP_REGISTER_RECONCILER,\n reconcileSession: context?.reconcileSession ?? NOOP_RECONCILE_SESSION,\n };\n}\n\nconst BROWSER_INTERACTION_METHODS = [\n \"streamWorkspaceInteractionRevisions\",\n \"listNetworkRoutes\",\n \"getNetworkRoute\",\n \"createNetworkRoute\",\n \"updateNetworkRoute\",\n \"listSiteAuthConnections\",\n \"getSiteAuthConnection\",\n \"createSiteAuthConnection\",\n \"updateSiteAuthConnection\",\n \"listAuthRuns\",\n \"getAuthRun\",\n \"startBrowserAuthRun\",\n \"reportBrowserAuthRun\",\n \"protectedBrowserAuthFill\",\n \"verifyBrowserAuthRun\",\n \"listInteractionInterventions\",\n \"getInteractionIntervention\",\n \"createInteractionIntervention\",\n \"resolveInteractionIntervention\",\n \"listAttachedBrowsers\",\n \"getAttachedBrowser\",\n \"listBrowserIdentities\",\n \"getBrowserIdentity\",\n \"createBrowserIdentity\",\n \"updateBrowserIdentity\",\n \"listBrowserRevisions\",\n \"listBrowserSessions\",\n \"getBrowserSession\",\n \"readBrowserClipboard\",\n \"listBrowserDownloads\",\n \"getBrowserDownload\",\n \"saveBrowserDownload\",\n \"createBrowserSession\",\n \"listBrowserTargets\",\n \"openBrowserTarget\",\n \"selectBrowserTarget\",\n \"closeBrowserTarget\",\n \"observeBrowserTarget\",\n \"actInBrowser\",\n \"getBrowserActionReceipt\",\n \"listBrowserDiagnostics\",\n \"attachBrowserSession\",\n \"heartbeatBrowserSession\",\n \"publishBrowserRevision\",\n \"suspendBrowserSession\",\n \"resumeBrowserSession\",\n \"endBrowserSession\",\n] as const;\n\nconst COMPUTER_INTERACTION_METHODS = [\n \"streamWorkspaceInteractionRevisions\",\n \"listInteractionInterventions\",\n \"getInteractionIntervention\",\n \"createInteractionIntervention\",\n \"resolveInteractionIntervention\",\n \"listComputerSessions\",\n \"getComputerSession\",\n \"readComputerClipboard\",\n \"createComputerSession\",\n \"listComputerTargets\",\n \"observeComputerTarget\",\n \"actInComputer\",\n \"getComputerActionReceipt\",\n \"attachComputerSession\",\n \"heartbeatComputerSession\",\n \"endComputerSession\",\n] as const;\n\nconst INTERVENTION_METHODS = [\n \"streamWorkspaceInteractionRevisions\",\n \"listInteractionInterventions\",\n \"getInteractionIntervention\",\n \"createInteractionIntervention\",\n \"resolveInteractionIntervention\",\n] as const;\n\n/** Resolve only the workspace-wide Browser/Computer intervention surface. */\nexport function useEmbeddedInterventions(\n override: EmbeddedInterventionClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedInterventionClientLike> {\n return useEmbeddedClientRefinement(\n override,\n INTERVENTION_METHODS,\n \"interaction intervention hooks\",\n );\n}\n\n/** Resolve only BrowserSession methods for a standalone Browser embed. */\nexport function useEmbeddedBrowserInteraction(\n override: EmbeddedBrowserInteractionClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedBrowserInteractionClientLike> {\n return useEmbeddedClientRefinement(\n override,\n BROWSER_INTERACTION_METHODS,\n \"browser interaction hooks\",\n );\n}\n\n/** Resolve only ComputerSession methods for a standalone Computer embed. */\nexport function useEmbeddedComputerInteraction(\n override: EmbeddedComputerInteractionClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedComputerInteractionClientLike> {\n return useEmbeddedClientRefinement(\n override,\n COMPUTER_INTERACTION_METHODS,\n \"computer interaction hooks\",\n );\n}\n\n/** Resolve the complete Browser + Computer client surface. */\nexport function useEmbeddedInteraction(\n override: EmbeddedInteractionClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedInteractionClientLike> {\n return useEmbeddedClientRefinement(\n override,\n [...BROWSER_INTERACTION_METHODS, ...COMPUTER_INTERACTION_METHODS],\n \"interaction hooks\",\n );\n}\n\n/**\n * Resolve the narrow client required by the session-only hooks. The full\n * provider client is structurally compatible, while an explicit host proxy\n * only needs to expose session/event/composer/queue/control operations.\n */\nexport function useEmbeddedSession(\n override: EmbeddedSessionClientOverride = {},\n): EmbeddedSessionContextValue {\n return useEmbeddedClientRefinement(\n override,\n [\n \"getSession\",\n \"listEvents\",\n \"streamEvents\",\n \"getComposerDraft\",\n \"saveComposerDraft\",\n \"submitComposerDraft\",\n \"sendMessage\",\n \"steerMessage\",\n \"getQueue\",\n \"moveQueueItem\",\n \"editQueueItem\",\n \"steerQueueItem\",\n \"deleteQueueItem\",\n \"pauseSession\",\n \"resumeSession\",\n \"sendApprovalDecision\",\n ],\n \"session hooks\",\n );\n}\n\n/** Resolve the exact client surface required by `useSession`. */\nexport function useEmbeddedSessionRead(\n override: EmbeddedSessionReadClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedSessionReadClientLike> {\n return useEmbeddedClientRefinement(\n override,\n eventClientMethods(override, [\"getSession\", \"updateSession\"]),\n \"useSession\",\n );\n}\n\n/** Resolve the exact client surface required by `useGoal`. */\nexport function useEmbeddedGoal(\n override: EmbeddedGoalClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedGoalClientLike> {\n return useEmbeddedClientRefinement(\n override,\n eventClientMethods(override, [\"getGoal\", \"updateGoal\", \"deleteGoal\"]),\n \"useGoal\",\n );\n}\n\n/** Resolve the exact client surface required by `useSessionLineage`. */\nexport function useEmbeddedSessionLineage(\n override: EmbeddedSessionLineageClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedSessionLineageClientLike> {\n return useEmbeddedClientRefinement(\n override,\n eventClientMethods(override, [\"getSessionLineage\"]),\n \"useSessionLineage\",\n );\n}\n\n/** Resolve the exact client surface required by `useFileAttachments`. */\nexport function useEmbeddedFileAttachments(\n override: EmbeddedFileAttachmentClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedFileAttachmentClientLike> {\n return useEmbeddedClientRefinement(override, [\"uploadFile\"], \"useFileAttachments\");\n}\n\n/**\n * Resolve the structured-input refinement without widening the baseline\n * session-only proxy contract.\n */\nexport function useEmbeddedHumanInputSession(override: EmbeddedHumanInputClientOverride = {}): Omit<\n EmbeddedSessionContextValue,\n \"client\"\n> & {\n client: EmbeddedHumanInputSessionClientLike;\n} {\n return useEmbeddedClientRefinement(\n override,\n eventClientMethods(override, [\"listHumanInputRequests\", \"submitHumanInputResponse\"]),\n \"useHumanInputRequests\",\n );\n}\n\n/** Resolve the approval-policy refinement without widening session-only hosts. */\nexport function useEmbeddedSessionMcpApprovalPolicy(\n override: EmbeddedSessionMcpApprovalPolicyClientOverride = {},\n): Omit<EmbeddedSessionContextValue, \"client\"> & {\n client: EmbeddedSessionMcpApprovalPolicyClientLike;\n} {\n return useEmbeddedClientRefinement(\n override,\n eventClientMethods(override, [\"getSession\", \"updateSessionMcpApprovalPolicy\"]),\n \"useSessionMcpApprovalPolicy\",\n );\n}\n\n/** Resolve the exact browser/API surface required by `@opengeni/react/realtime`. */\nexport function useEmbeddedRealtimeSession(\n override: EmbeddedRealtimeSessionClientOverride = {},\n): EmbeddedClientContextValue<EmbeddedRealtimeSessionClientLike> {\n // Preserve the existing lazy capability behavior: proxy/test clients may\n // implement only the methods reached by their selected model and lifecycle.\n // The exported structural type remains the complete embedding contract.\n return useEmbeddedClientRefinement(override, [], \"realtime hooks\");\n}\n\n/**\n * Resolve the client only — for hooks that are not workspace-scoped\n * (`useWorkspaces`, `useBillingUsage`).\n */\nexport function useOpenGeniClient(\n override: Pick<ClientOverride, \"client\"> = {},\n): SessionClientLike {\n const context = useContext(OpenGeniContext);\n const client = override.client ?? context?.client;\n if (!client) {\n throw new Error(\n \"@opengeni/react: no Opengeni client available. Wrap the tree in <OpenGeniProvider> or pass { client } to the hook.\",\n );\n }\n return client;\n}\n"],"mappings":";;;AAKA,SAAS,eAAe,kBAAkB;AAgCnC,IAAM,kBAAkB,cAA2C,IAAI;AAE9E,IAAM,2BAA8E,MAAM,MACxF;AACF,IAAM,yBAAmE,YAAY;AAgFrF,SAAS,4BACP,UACA,iBACA,UACqC;AACrC,QAAM,UAAU,WAAW,eAAe;AAC1C,QAAM,YAAY,SAAS,UAAU,SAAS;AAC9C,QAAM,cAAc,SAAS,eAAe,SAAS;AACrD,MAAI,CAAC,aAAa,CAAC,aAAa;AAC9B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,QAAM,UAAU;AAChB,QAAM,UAAU,gBAAgB,OAAO,CAAC,WAAW,OAAO,QAAQ,MAAM,MAAM,UAAU;AACxF,MAAI,QAAQ,SAAS,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|
+
"use client";
|
|
2
|
+
|
|
1
3
|
// src/lib/pierre-diffs-loader.ts
|
|
2
4
|
var loader = null;
|
|
3
5
|
var loaded = null;
|
|
@@ -38,4 +40,4 @@ export {
|
|
|
38
40
|
subscribePierreDiffs,
|
|
39
41
|
loadPierreDiffs
|
|
40
42
|
};
|
|
41
|
-
//# sourceMappingURL=chunk-
|
|
43
|
+
//# sourceMappingURL=chunk-YSRBFJMQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/pierre-diffs-loader.ts"],"sourcesContent":["/**\n * `@pierre/diffs` is an optional heavy peer. The package never names it in an\n * `import()` that the conversation surfaces can reach: bundlers such as\n * Turbopack resolve every reachable dynamic import at build time, so a host\n * without the peer would fail to build. Hosts that install it opt in once with\n * `enablePierreDiffs()` from `@opengeni/react/diffs` (or register their own\n * loader); otherwise diffs and file views use the plain-text renderer.\n */\nexport type PierreDiffsLoader = () => Promise<unknown>;\n\nlet loader: PierreDiffsLoader | null = null;\nlet loaded: Promise<unknown> | null = null;\nlet revision = 0;\nconst listeners = new Set<() => void>();\n\n/**\n * Register (or clear with `null`) the loader for `@pierre/diffs/react`.\n * Views already on screen retry with the new loader, so a host may register\n * lazily (for example from the route that renders diffs).\n */\nexport function registerPierreDiffs(next: PierreDiffsLoader | null): void {\n if (next === loader) return;\n loader = next;\n loaded = null;\n revision += 1;\n for (const listener of listeners) listener();\n}\n\n/** Changes whenever the registered loader changes (for `useSyncExternalStore`). */\nexport function pierreDiffsRevision(): number {\n return revision;\n}\n\nexport function subscribePierreDiffs(listener: () => void): () => void {\n listeners.add(listener);\n return () => listeners.delete(listener);\n}\n\n/** Resolve the registered `@pierre/diffs/react` module; rejects when none is registered. */\nexport function loadPierreDiffs(): Promise<unknown> {\n if (!loader) {\n return Promise.reject(\n new Error(\n \"@pierre/diffs is not enabled; call enablePierreDiffs() from @opengeni/react/diffs\",\n ),\n );\n }\n loaded ??= loader().catch((error: unknown) => {\n loaded = null;\n throw error;\n });\n return loaded;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/lib/pierre-diffs-loader.ts"],"sourcesContent":["/**\n * `@pierre/diffs` is an optional heavy peer. The package never names it in an\n * `import()` that the conversation surfaces can reach: bundlers such as\n * Turbopack resolve every reachable dynamic import at build time, so a host\n * without the peer would fail to build. Hosts that install it opt in once with\n * `enablePierreDiffs()` from `@opengeni/react/diffs` (or register their own\n * loader); otherwise diffs and file views use the plain-text renderer.\n */\nexport type PierreDiffsLoader = () => Promise<unknown>;\n\nlet loader: PierreDiffsLoader | null = null;\nlet loaded: Promise<unknown> | null = null;\nlet revision = 0;\nconst listeners = new Set<() => void>();\n\n/**\n * Register (or clear with `null`) the loader for `@pierre/diffs/react`.\n * Views already on screen retry with the new loader, so a host may register\n * lazily (for example from the route that renders diffs).\n */\nexport function registerPierreDiffs(next: PierreDiffsLoader | null): void {\n if (next === loader) return;\n loader = next;\n loaded = null;\n revision += 1;\n for (const listener of listeners) listener();\n}\n\n/** Changes whenever the registered loader changes (for `useSyncExternalStore`). */\nexport function pierreDiffsRevision(): number {\n return revision;\n}\n\nexport function subscribePierreDiffs(listener: () => void): () => void {\n listeners.add(listener);\n return () => listeners.delete(listener);\n}\n\n/** Resolve the registered `@pierre/diffs/react` module; rejects when none is registered. */\nexport function loadPierreDiffs(): Promise<unknown> {\n if (!loader) {\n return Promise.reject(\n new Error(\n \"@pierre/diffs is not enabled; call enablePierreDiffs() from @opengeni/react/diffs\",\n ),\n );\n }\n loaded ??= loader().catch((error: unknown) => {\n loaded = null;\n throw error;\n });\n return loaded;\n}\n"],"mappings":";;;AAUA,IAAI,SAAmC;AACvC,IAAI,SAAkC;AACtC,IAAI,WAAW;AACf,IAAM,YAAY,oBAAI,IAAgB;AAO/B,SAAS,oBAAoB,MAAsC;AACxE,MAAI,SAAS,OAAQ;AACrB,WAAS;AACT,WAAS;AACT,cAAY;AACZ,aAAW,YAAY,UAAW,UAAS;AAC7C;AAGO,SAAS,sBAA8B;AAC5C,SAAO;AACT;AAEO,SAAS,qBAAqB,UAAkC;AACrE,YAAU,IAAI,QAAQ;AACtB,SAAO,MAAM,UAAU,OAAO,QAAQ;AACxC;AAGO,SAAS,kBAAoC;AAClD,MAAI,CAAC,QAAQ;AACX,WAAO,QAAQ;AAAA,MACb,IAAI;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,aAAW,OAAO,EAAE,MAAM,CAAC,UAAmB;AAC5C,aAAS;AACT,UAAM;AAAA,EACR,CAAC;AACD,SAAO;AACT;","names":[]}
|