skybridge 0.0.0-dev.ff23e30 → 0.0.0-dev.ff50fdb
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/LICENSE +21 -0
- package/README.md +143 -0
- package/bin/run.js +5 -0
- package/dist/cli/header.d.ts +4 -0
- package/dist/cli/header.js +6 -0
- package/dist/cli/header.js.map +1 -0
- package/dist/cli/run-command.d.ts +2 -0
- package/dist/cli/run-command.js +43 -0
- package/dist/cli/run-command.js.map +1 -0
- package/dist/cli/telemetry.d.ts +7 -0
- package/dist/cli/telemetry.js +123 -0
- package/dist/cli/telemetry.js.map +1 -0
- package/dist/cli/use-execute-steps.d.ts +10 -0
- package/dist/cli/use-execute-steps.js +31 -0
- package/dist/cli/use-execute-steps.js.map +1 -0
- package/dist/commands/build.d.ts +9 -0
- package/dist/commands/build.js +44 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/dev.d.ts +9 -0
- package/dist/commands/dev.js +32 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/start.d.ts +7 -0
- package/dist/commands/start.js +33 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/telemetry/disable.d.ts +5 -0
- package/dist/commands/telemetry/disable.js +14 -0
- package/dist/commands/telemetry/disable.js.map +1 -0
- package/dist/commands/telemetry/enable.d.ts +5 -0
- package/dist/commands/telemetry/enable.js +14 -0
- package/dist/commands/telemetry/enable.js.map +1 -0
- package/dist/commands/telemetry/status.d.ts +5 -0
- package/dist/commands/telemetry/status.js +14 -0
- package/dist/commands/telemetry/status.js.map +1 -0
- package/dist/{src/server → server}/index.d.ts +0 -1
- package/dist/{src/server → server}/index.js +0 -1
- package/dist/server/index.js.map +1 -0
- package/dist/server/inferUtilityTypes.js.map +1 -0
- package/dist/{src/server → server}/server.d.ts +26 -1
- package/dist/server/server.js +139 -0
- package/dist/server/server.js.map +1 -0
- package/dist/server/templateHelper.js.map +1 -0
- package/dist/server/templates/development.hbs +66 -0
- package/dist/{src/server → server}/widgetsDevServer.d.ts +2 -2
- package/dist/{src/server → server}/widgetsDevServer.js +11 -3
- package/dist/server/widgetsDevServer.js.map +1 -0
- package/dist/test/utils.js.map +1 -0
- package/dist/{src/test → test}/widget.test.js +123 -14
- package/dist/test/widget.test.js.map +1 -0
- package/dist/web/bridges/apps-sdk/adaptor.d.ts +22 -0
- package/dist/web/bridges/apps-sdk/adaptor.js +64 -0
- package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -0
- package/dist/web/bridges/apps-sdk/bridge.d.ts +10 -0
- package/dist/{src/web/bridges/apps-sdk-bridge.js → web/bridges/apps-sdk/bridge.js} +2 -2
- package/dist/web/bridges/apps-sdk/bridge.js.map +1 -0
- package/dist/web/bridges/apps-sdk/index.d.ts +5 -0
- package/dist/web/bridges/apps-sdk/index.js +5 -0
- package/dist/web/bridges/apps-sdk/index.js.map +1 -0
- package/dist/{src/web → web/bridges/apps-sdk}/types.d.ts +22 -56
- package/dist/{src/web → web/bridges/apps-sdk}/types.js +0 -1
- package/dist/web/bridges/apps-sdk/types.js.map +1 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +2 -0
- package/dist/{src/web/bridges/hooks/use-apps-sdk-bridge.js → web/bridges/apps-sdk/use-apps-sdk-context.js} +3 -3
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -0
- package/dist/web/bridges/get-adaptor.d.ts +2 -0
- package/dist/web/bridges/get-adaptor.js +8 -0
- package/dist/web/bridges/get-adaptor.js.map +1 -0
- package/dist/web/bridges/index.d.ts +5 -0
- package/dist/web/bridges/index.js +6 -0
- package/dist/web/bridges/index.js.map +1 -0
- package/dist/web/bridges/mcp-app/adaptor.d.ts +36 -0
- package/dist/web/bridges/mcp-app/adaptor.js +185 -0
- package/dist/web/bridges/mcp-app/adaptor.js.map +1 -0
- package/dist/web/bridges/mcp-app/bridge.d.ts +43 -0
- package/dist/{src/web/bridges/mcp-app-bridge.js → web/bridges/mcp-app/bridge.js} +109 -16
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -0
- package/dist/web/bridges/mcp-app/index.d.ts +4 -0
- package/dist/web/bridges/mcp-app/index.js +4 -0
- package/dist/web/bridges/mcp-app/index.js.map +1 -0
- package/dist/web/bridges/mcp-app/types.d.ts +8 -0
- package/dist/web/bridges/mcp-app/types.js.map +1 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +5 -0
- package/dist/{src/web/bridges/hooks/use-mcp-app-bridge.js → web/bridges/mcp-app/use-mcp-app-context.js} +3 -3
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +66 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -0
- package/dist/web/bridges/types.d.ts +98 -0
- package/dist/web/bridges/types.js +2 -0
- package/dist/{src/web → web}/bridges/types.js.map +1 -1
- package/dist/web/bridges/use-host-context.d.ts +2 -0
- package/dist/web/bridges/use-host-context.js +8 -0
- package/dist/web/bridges/use-host-context.js.map +1 -0
- package/dist/web/components/modal-provider.d.ts +4 -0
- package/dist/web/components/modal-provider.js +47 -0
- package/dist/web/components/modal-provider.js.map +1 -0
- package/dist/{src/web → web}/create-store.js +6 -7
- package/dist/web/create-store.js.map +1 -0
- package/dist/web/create-store.test.js +126 -0
- package/dist/web/create-store.test.js.map +1 -0
- package/dist/{src/web → web}/data-llm.js +5 -3
- package/dist/web/data-llm.js.map +1 -0
- package/dist/web/data-llm.test.js +139 -0
- package/dist/web/data-llm.test.js.map +1 -0
- package/dist/{src/web → web}/generate-helpers.d.ts +3 -2
- package/dist/{src/web → web}/generate-helpers.js +1 -1
- package/dist/web/generate-helpers.js.map +1 -0
- package/dist/web/generate-helpers.test-d.js.map +1 -0
- package/dist/web/generate-helpers.test.js.map +1 -0
- package/dist/{src/web → web}/helpers/state.js +13 -8
- package/dist/web/helpers/state.js.map +1 -0
- package/dist/web/helpers/state.test.js.map +1 -0
- package/dist/{src/web → web}/hooks/index.d.ts +1 -1
- package/dist/{src/web → web}/hooks/index.js +1 -1
- package/dist/web/hooks/index.js.map +1 -0
- package/dist/{src/web → web}/hooks/test/utils.d.ts +8 -2
- package/dist/web/hooks/test/utils.js +60 -0
- package/dist/web/hooks/test/utils.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-call-tool.d.ts +2 -1
- package/dist/{src/web → web}/hooks/use-call-tool.js +2 -2
- package/dist/web/hooks/use-call-tool.js.map +1 -0
- package/dist/web/hooks/use-call-tool.test-d.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-call-tool.test.js +0 -1
- package/dist/web/hooks/use-call-tool.test.js.map +1 -0
- package/dist/web/hooks/use-display-mode.js +9 -0
- package/dist/web/hooks/use-display-mode.js.map +1 -0
- package/dist/web/hooks/use-display-mode.test.js.map +1 -0
- package/dist/web/hooks/use-files.d.ts +6 -0
- package/dist/web/hooks/use-files.js +9 -0
- package/dist/web/hooks/use-files.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-files.test.js +5 -4
- package/dist/web/hooks/use-files.test.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-layout.d.ts +2 -2
- package/dist/{src/web → web}/hooks/use-layout.js +4 -4
- package/dist/web/hooks/use-layout.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-layout.test.js +6 -5
- package/dist/web/hooks/use-layout.test.js.map +1 -0
- package/dist/web/hooks/use-open-external.js +8 -0
- package/dist/web/hooks/use-open-external.js.map +1 -0
- package/dist/web/hooks/use-open-external.test.js +50 -0
- package/dist/web/hooks/use-open-external.test.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-request-modal.d.ts +2 -2
- package/dist/web/hooks/use-request-modal.js +16 -0
- package/dist/web/hooks/use-request-modal.js.map +1 -0
- package/dist/web/hooks/use-request-modal.test.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-send-follow-up-message.js +2 -2
- package/dist/web/hooks/use-send-follow-up-message.js.map +1 -0
- package/dist/web/hooks/use-set-open-in-app-url.d.ts +1 -0
- package/dist/web/hooks/use-set-open-in-app-url.js +8 -0
- package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -0
- package/dist/web/hooks/use-set-open-in-app-url.test.js +49 -0
- package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-tool-info.js +4 -4
- package/dist/web/hooks/use-tool-info.js.map +1 -0
- package/dist/web/hooks/use-tool-info.test-d.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-tool-info.test.js +4 -4
- package/dist/web/hooks/use-tool-info.test.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-user.d.ts +1 -1
- package/dist/{src/web → web}/hooks/use-user.js +3 -3
- package/dist/web/hooks/use-user.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-user.test.js +4 -3
- package/dist/web/hooks/use-user.test.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-widget-state.js +10 -10
- package/dist/web/hooks/use-widget-state.js.map +1 -0
- package/dist/web/hooks/use-widget-state.test.js.map +1 -0
- package/dist/web/index.js.map +1 -0
- package/dist/{src/web → web}/mount-widget.js +9 -1
- package/dist/web/mount-widget.js.map +1 -0
- package/dist/web/plugin/data-llm.test.js.map +1 -0
- package/dist/web/plugin/plugin.js.map +1 -0
- package/dist/web/plugin/transform-data-llm.js.map +1 -0
- package/dist/web/plugin/transform-data-llm.test.d.ts +1 -0
- package/dist/web/plugin/transform-data-llm.test.js.map +1 -0
- package/dist/web/proxy.js.map +1 -0
- package/dist/web/types.d.ts +16 -0
- package/dist/web/types.js +2 -0
- package/dist/web/types.js.map +1 -0
- package/package.json +54 -35
- package/dist/src/server/devtoolsStaticServer.d.ts +0 -15
- package/dist/src/server/devtoolsStaticServer.js +0 -38
- package/dist/src/server/devtoolsStaticServer.js.map +0 -1
- package/dist/src/server/index.js.map +0 -1
- package/dist/src/server/inferUtilityTypes.js.map +0 -1
- package/dist/src/server/server.js +0 -82
- package/dist/src/server/server.js.map +0 -1
- package/dist/src/server/templateHelper.js.map +0 -1
- package/dist/src/server/templates/development.hbs +0 -13
- package/dist/src/server/widgetsDevServer.js.map +0 -1
- package/dist/src/test/utils.js.map +0 -1
- package/dist/src/test/widget.test.js.map +0 -1
- package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.d.ts +0 -12
- package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.js +0 -30
- package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.js.map +0 -1
- package/dist/src/web/bridges/adaptors/mcp-app-adaptor.d.ts +0 -15
- package/dist/src/web/bridges/adaptors/mcp-app-adaptor.js +0 -108
- package/dist/src/web/bridges/adaptors/mcp-app-adaptor.js.map +0 -1
- package/dist/src/web/bridges/apps-sdk-bridge.d.ts +0 -10
- package/dist/src/web/bridges/apps-sdk-bridge.js.map +0 -1
- package/dist/src/web/bridges/hooks/use-adaptor.d.ts +0 -2
- package/dist/src/web/bridges/hooks/use-adaptor.js +0 -8
- package/dist/src/web/bridges/hooks/use-adaptor.js.map +0 -1
- package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.d.ts +0 -2
- package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.js.map +0 -1
- package/dist/src/web/bridges/hooks/use-bridge.d.ts +0 -2
- package/dist/src/web/bridges/hooks/use-bridge.js +0 -8
- package/dist/src/web/bridges/hooks/use-bridge.js.map +0 -1
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.d.ts +0 -5
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js.map +0 -1
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js +0 -41
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js.map +0 -1
- package/dist/src/web/bridges/index.d.ts +0 -4
- package/dist/src/web/bridges/index.js +0 -5
- package/dist/src/web/bridges/index.js.map +0 -1
- package/dist/src/web/bridges/mcp-app-bridge.d.ts +0 -38
- package/dist/src/web/bridges/mcp-app-bridge.js.map +0 -1
- package/dist/src/web/bridges/types.d.ts +0 -56
- package/dist/src/web/create-store.js.map +0 -1
- package/dist/src/web/create-store.test.js +0 -70
- package/dist/src/web/create-store.test.js.map +0 -1
- package/dist/src/web/data-llm.js.map +0 -1
- package/dist/src/web/data-llm.test.js +0 -76
- package/dist/src/web/data-llm.test.js.map +0 -1
- package/dist/src/web/generate-helpers.js.map +0 -1
- package/dist/src/web/generate-helpers.test-d.js.map +0 -1
- package/dist/src/web/generate-helpers.test.js.map +0 -1
- package/dist/src/web/helpers/state.js.map +0 -1
- package/dist/src/web/helpers/state.test.js.map +0 -1
- package/dist/src/web/hooks/index.js.map +0 -1
- package/dist/src/web/hooks/test/utils.js +0 -40
- package/dist/src/web/hooks/test/utils.js.map +0 -1
- package/dist/src/web/hooks/use-call-tool.js.map +0 -1
- package/dist/src/web/hooks/use-call-tool.test-d.js.map +0 -1
- package/dist/src/web/hooks/use-call-tool.test.js.map +0 -1
- package/dist/src/web/hooks/use-display-mode.js +0 -10
- package/dist/src/web/hooks/use-display-mode.js.map +0 -1
- package/dist/src/web/hooks/use-display-mode.test.js.map +0 -1
- package/dist/src/web/hooks/use-files.d.ts +0 -10
- package/dist/src/web/hooks/use-files.js +0 -7
- package/dist/src/web/hooks/use-files.js.map +0 -1
- package/dist/src/web/hooks/use-files.test.js.map +0 -1
- package/dist/src/web/hooks/use-layout.js.map +0 -1
- package/dist/src/web/hooks/use-layout.test.js.map +0 -1
- package/dist/src/web/hooks/use-open-external.js +0 -6
- package/dist/src/web/hooks/use-open-external.js.map +0 -1
- package/dist/src/web/hooks/use-open-external.test.js +0 -24
- package/dist/src/web/hooks/use-open-external.test.js.map +0 -1
- package/dist/src/web/hooks/use-openai-global.d.ts +0 -3
- package/dist/src/web/hooks/use-openai-global.js +0 -6
- package/dist/src/web/hooks/use-openai-global.js.map +0 -1
- package/dist/src/web/hooks/use-request-modal.js +0 -14
- package/dist/src/web/hooks/use-request-modal.js.map +0 -1
- package/dist/src/web/hooks/use-request-modal.test.js.map +0 -1
- package/dist/src/web/hooks/use-send-follow-up-message.js.map +0 -1
- package/dist/src/web/hooks/use-tool-info.js.map +0 -1
- package/dist/src/web/hooks/use-tool-info.test-d.js.map +0 -1
- package/dist/src/web/hooks/use-tool-info.test.js.map +0 -1
- package/dist/src/web/hooks/use-user.js.map +0 -1
- package/dist/src/web/hooks/use-user.test.js.map +0 -1
- package/dist/src/web/hooks/use-widget-state.js.map +0 -1
- package/dist/src/web/hooks/use-widget-state.test.js.map +0 -1
- package/dist/src/web/index.js.map +0 -1
- package/dist/src/web/mount-widget.js.map +0 -1
- package/dist/src/web/plugin/data-llm.test.js.map +0 -1
- package/dist/src/web/plugin/plugin.js.map +0 -1
- package/dist/src/web/plugin/transform-data-llm.js.map +0 -1
- package/dist/src/web/plugin/transform-data-llm.test.js.map +0 -1
- package/dist/src/web/proxy.js.map +0 -1
- package/dist/src/web/types.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -2
- package/dist/vitest.config.js +0 -8
- package/dist/vitest.config.js.map +0 -1
- /package/dist/{src/server → server}/inferUtilityTypes.d.ts +0 -0
- /package/dist/{src/server → server}/inferUtilityTypes.js +0 -0
- /package/dist/{src/server → server}/templateHelper.d.ts +0 -0
- /package/dist/{src/server → server}/templateHelper.js +0 -0
- /package/dist/{src/server → server}/templates/production.hbs +0 -0
- /package/dist/{src/test → test}/utils.d.ts +0 -0
- /package/dist/{src/test → test}/utils.js +0 -0
- /package/dist/{src/test → test}/widget.test.d.ts +0 -0
- /package/dist/{src/web/bridges → web/bridges/mcp-app}/types.js +0 -0
- /package/dist/{src/web/bridges/hooks/use-mcp-app-bridge.test.d.ts → web/bridges/mcp-app/use-mcp-app-context.test.d.ts} +0 -0
- /package/dist/{src/web → web}/create-store.d.ts +0 -0
- /package/dist/{src/web → web}/create-store.test.d.ts +0 -0
- /package/dist/{src/web → web}/data-llm.d.ts +0 -0
- /package/dist/{src/web → web}/data-llm.test.d.ts +0 -0
- /package/dist/{src/web → web}/generate-helpers.test-d.d.ts +0 -0
- /package/dist/{src/web → web}/generate-helpers.test-d.js +0 -0
- /package/dist/{src/web → web}/generate-helpers.test.d.ts +0 -0
- /package/dist/{src/web → web}/generate-helpers.test.js +0 -0
- /package/dist/{src/web → web}/helpers/state.d.ts +0 -0
- /package/dist/{src/web → web}/helpers/state.test.d.ts +0 -0
- /package/dist/{src/web → web}/helpers/state.test.js +0 -0
- /package/dist/{src/web → web}/hooks/use-call-tool.test-d.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-call-tool.test-d.js +0 -0
- /package/dist/{src/web → web}/hooks/use-call-tool.test.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-display-mode.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-display-mode.test.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-display-mode.test.js +0 -0
- /package/dist/{src/web → web}/hooks/use-files.test.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-layout.test.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-open-external.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-open-external.test.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-request-modal.test.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-request-modal.test.js +0 -0
- /package/dist/{src/web → web}/hooks/use-send-follow-up-message.d.ts +0 -0
- /package/dist/{src/web/hooks/use-tool-info.test-d.d.ts → web/hooks/use-set-open-in-app-url.test.d.ts} +0 -0
- /package/dist/{src/web → web}/hooks/use-tool-info.d.ts +0 -0
- /package/dist/{src/web/hooks/use-tool-info.test.d.ts → web/hooks/use-tool-info.test-d.d.ts} +0 -0
- /package/dist/{src/web → web}/hooks/use-tool-info.test-d.js +0 -0
- /package/dist/{src/web/hooks/use-user.test.d.ts → web/hooks/use-tool-info.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-widget-state.test.d.ts → web/hooks/use-user.test.d.ts} +0 -0
- /package/dist/{src/web → web}/hooks/use-widget-state.d.ts +0 -0
- /package/dist/{src/web/plugin/data-llm.test.d.ts → web/hooks/use-widget-state.test.d.ts} +0 -0
- /package/dist/{src/web → web}/hooks/use-widget-state.test.js +0 -0
- /package/dist/{src/web → web}/index.d.ts +0 -0
- /package/dist/{src/web → web}/index.js +0 -0
- /package/dist/{src/web → web}/mount-widget.d.ts +0 -0
- /package/dist/{src/web/plugin/transform-data-llm.test.d.ts → web/plugin/data-llm.test.d.ts} +0 -0
- /package/dist/{src/web → web}/plugin/data-llm.test.js +0 -0
- /package/dist/{src/web → web}/plugin/plugin.d.ts +0 -0
- /package/dist/{src/web → web}/plugin/plugin.js +0 -0
- /package/dist/{src/web → web}/plugin/transform-data-llm.d.ts +0 -0
- /package/dist/{src/web → web}/plugin/transform-data-llm.js +0 -0
- /package/dist/{src/web → web}/plugin/transform-data-llm.test.js +0 -0
- /package/dist/{src/web → web}/proxy.d.ts +0 -0
- /package/dist/{src/web → web}/proxy.js +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Adaptor, CallToolResponse, DisplayMode, HostContext, HostContextStore, RequestModalOptions, SetWidgetStateAction } from "../types.js";
|
|
2
|
+
export declare class AppsSdkAdaptor implements Adaptor {
|
|
3
|
+
private static instance;
|
|
4
|
+
static getInstance(): AppsSdkAdaptor;
|
|
5
|
+
static resetInstance(): void;
|
|
6
|
+
getHostContextStore<K extends keyof HostContext>(key: K): HostContextStore<K>;
|
|
7
|
+
callTool: <ToolArgs extends Record<string, unknown> | null = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
|
|
8
|
+
requestDisplayMode: (mode: DisplayMode) => Promise<{
|
|
9
|
+
mode: DisplayMode;
|
|
10
|
+
}>;
|
|
11
|
+
sendFollowUpMessage: (prompt: string) => Promise<void>;
|
|
12
|
+
openExternal(href: string): void;
|
|
13
|
+
setWidgetState: (stateOrUpdater: SetWidgetStateAction) => Promise<void>;
|
|
14
|
+
uploadFile: (file: File) => Promise<import("../types.js").FileMetadata>;
|
|
15
|
+
getFileDownloadUrl: (file: {
|
|
16
|
+
fileId: string;
|
|
17
|
+
}) => Promise<{
|
|
18
|
+
downloadUrl: string;
|
|
19
|
+
}>;
|
|
20
|
+
openModal(options: RequestModalOptions): Promise<void>;
|
|
21
|
+
setOpenInAppUrl(href: string): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { AppsSdkBridge } from "./bridge.js";
|
|
2
|
+
export class AppsSdkAdaptor {
|
|
3
|
+
static instance = null;
|
|
4
|
+
static getInstance() {
|
|
5
|
+
if (!AppsSdkAdaptor.instance) {
|
|
6
|
+
AppsSdkAdaptor.instance = new AppsSdkAdaptor();
|
|
7
|
+
}
|
|
8
|
+
return AppsSdkAdaptor.instance;
|
|
9
|
+
}
|
|
10
|
+
static resetInstance() {
|
|
11
|
+
AppsSdkAdaptor.instance = null;
|
|
12
|
+
}
|
|
13
|
+
getHostContextStore(key) {
|
|
14
|
+
const bridge = AppsSdkBridge.getInstance();
|
|
15
|
+
return {
|
|
16
|
+
subscribe: bridge.subscribe(key),
|
|
17
|
+
getSnapshot: () => bridge.getSnapshot(key),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
callTool = async (name, args) => {
|
|
21
|
+
return window.openai.callTool(name, args);
|
|
22
|
+
};
|
|
23
|
+
requestDisplayMode = (mode) => {
|
|
24
|
+
return window.openai.requestDisplayMode({ mode });
|
|
25
|
+
};
|
|
26
|
+
sendFollowUpMessage = (prompt) => {
|
|
27
|
+
return window.openai.sendFollowUpMessage({ prompt });
|
|
28
|
+
};
|
|
29
|
+
openExternal(href) {
|
|
30
|
+
window.openai.openExternal({ href });
|
|
31
|
+
}
|
|
32
|
+
setWidgetState = (stateOrUpdater) => {
|
|
33
|
+
const newState = typeof stateOrUpdater === "function"
|
|
34
|
+
? stateOrUpdater(window.openai.widgetState)
|
|
35
|
+
: stateOrUpdater;
|
|
36
|
+
return window.openai.setWidgetState(newState);
|
|
37
|
+
};
|
|
38
|
+
uploadFile = (file) => {
|
|
39
|
+
return window.openai.uploadFile(file);
|
|
40
|
+
};
|
|
41
|
+
getFileDownloadUrl = (file) => {
|
|
42
|
+
return window.openai.getFileDownloadUrl(file);
|
|
43
|
+
};
|
|
44
|
+
openModal(options) {
|
|
45
|
+
return window.openai.requestModal(options);
|
|
46
|
+
}
|
|
47
|
+
setOpenInAppUrl(href) {
|
|
48
|
+
href = href.trim();
|
|
49
|
+
if (!href) {
|
|
50
|
+
throw new Error("The href parameter is required.");
|
|
51
|
+
}
|
|
52
|
+
const serverUrl = window.skybridge.serverUrl;
|
|
53
|
+
if (!serverUrl) {
|
|
54
|
+
throw new Error("The widgetDomain property has not been set on the widget resource meta object.");
|
|
55
|
+
}
|
|
56
|
+
const domainUrl = new URL(serverUrl);
|
|
57
|
+
const hrefUrl = new URL(href, serverUrl);
|
|
58
|
+
if (domainUrl.origin !== hrefUrl.origin) {
|
|
59
|
+
throw new Error("Provided href is not compatible with widget domain: origin differs");
|
|
60
|
+
}
|
|
61
|
+
return window.openai.setOpenInAppUrl({ href });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=adaptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk/adaptor.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,cAAc;IACjB,MAAM,CAAC,QAAQ,GAA0B,IAAI,CAAC;IAE/C,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;YAC7B,cAAc,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;QACjD,CAAC;QACD,OAAO,cAAc,CAAC,QAAQ,CAAC;IACjC,CAAC;IAEM,MAAM,CAAC,aAAa;QACzB,cAAc,CAAC,QAAQ,GAAG,IAAI,CAAC;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GAAG,CAAC,IAAwB,EAAE,EAAE;QACvD,OAAO,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC,CAAC;IAEK,SAAS,CAAC,OAA4B;QAC3C,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;IAEM,eAAe,CAAC,IAAY;QACjC,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAEnB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC;QAC7C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,gFAAgF,CACjF,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;QACrC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAEzC,IAAI,SAAS,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Bridge, Subscribe } from "../types.js";
|
|
2
|
+
import { type AppsSdkContext } from "./types.js";
|
|
3
|
+
export declare class AppsSdkBridge implements Bridge<AppsSdkContext> {
|
|
4
|
+
private static instance;
|
|
5
|
+
static getInstance(): AppsSdkBridge;
|
|
6
|
+
static resetInstance(): void;
|
|
7
|
+
subscribe(key: keyof AppsSdkContext): Subscribe;
|
|
8
|
+
subscribe(keys: readonly (keyof AppsSdkContext)[]): Subscribe;
|
|
9
|
+
getSnapshot: <K extends keyof AppsSdkContext>(key: K) => (import("./types.js").AppsSdkMethods<import("../../types.js").UnknownObject> & AppsSdkContext<Record<never, unknown>, import("../../types.js").UnknownObject, import("../../types.js").UnknownObject, import("../../types.js").UnknownObject>)[K];
|
|
10
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SET_GLOBALS_EVENT_TYPE, } from "
|
|
1
|
+
import { SET_GLOBALS_EVENT_TYPE, } from "./types.js";
|
|
2
2
|
export class AppsSdkBridge {
|
|
3
3
|
static instance = null;
|
|
4
4
|
static getInstance() {
|
|
@@ -43,4 +43,4 @@ export class AppsSdkBridge {
|
|
|
43
43
|
return window.openai[key];
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
//# sourceMappingURL=
|
|
46
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk/bridge.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,sBAAsB,GAEvB,MAAM,YAAY,CAAC;AAEpB,MAAM,OAAO,aAAa;IAChB,MAAM,CAAC,QAAQ,GAAyB,IAAI,CAAC;IAE9C,MAAM,CAAC,WAAW;QACvB,IACE,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,UAAU;YACxC,MAAM,CAAC,MAAM,KAAK,SAAS,EAC3B,CAAC;YACD,MAAM,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAC;QACJ,CAAC;QACD,IAAI,aAAa,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YACpC,aAAa,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;QAC/C,CAAC;QACD,OAAO,aAAa,CAAC,QAAQ,CAAC;IAChC,CAAC;IAEM,MAAM,CAAC,aAAa;QACzB,IAAI,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC3B,aAAa,CAAC,QAAQ,GAAG,IAAI,CAAC;QAChC,CAAC;IACH,CAAC;IAIM,SAAS,CACd,SAAmE;QAEnE,MAAM,IAAI,GAAsC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;YACtE,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAChB,OAAO,CAAC,QAAoB,EAAE,EAAE;YAC9B,MAAM,eAAe,GAAG,CAAC,KAAsB,EAAE,EAAE;gBACjD,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CACjC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,CACjD,CAAC;gBACF,IAAI,CAAC,iBAAiB,EAAE,CAAC;oBACvB,OAAO;gBACT,CAAC;gBACD,QAAQ,EAAE,CAAC;YACb,CAAC,CAAC;YAEF,MAAM,CAAC,gBAAgB,CAAC,sBAAsB,EAAE,eAAe,EAAE;gBAC/D,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;YAEH,OAAO,GAAG,EAAE;gBACV,MAAM,CAAC,mBAAmB,CAAC,sBAAsB,EAAE,eAAe,CAAC,CAAC;YACtE,CAAC,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAEM,WAAW,GAAG,CAAiC,GAAM,EAAE,EAAE;QAC9D,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CACb,+EAA+E,GAAG,8CAA8C,CACjI,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AppsSdkAdaptor } from "./adaptor.js";
|
|
2
|
+
export { AppsSdkBridge } from "./bridge.js";
|
|
3
|
+
export type { AppsSdkContext, AppsSdkMethods, ToolResponseEvent, } from "./types.js";
|
|
4
|
+
export { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent, TOOL_RESPONSE_EVENT_TYPE, } from "./types.js";
|
|
5
|
+
export { useAppsSdkContext } from "./use-apps-sdk-context.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AppsSdkAdaptor } from "./adaptor.js";
|
|
2
|
+
export { AppsSdkBridge } from "./bridge.js";
|
|
3
|
+
export { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent, TOOL_RESPONSE_EVENT_TYPE, } from "./types.js";
|
|
4
|
+
export { useAppsSdkContext } from "./use-apps-sdk-context.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAM5C,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -1,24 +1,7 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
declare module "react" {
|
|
5
|
-
interface HTMLAttributes<T> {
|
|
6
|
-
"data-llm"?: string;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export type UnknownObject = Record<string, unknown>;
|
|
10
|
-
export type Prettify<T> = {
|
|
11
|
-
[K in keyof T]: T[K];
|
|
12
|
-
} & {};
|
|
13
|
-
export type Objectify<T> = T & UnknownObject;
|
|
14
|
-
type RequiredKeys<T> = {
|
|
15
|
-
[K in keyof T]-?: Record<string, never> extends Pick<T, K> ? never : K;
|
|
16
|
-
}[keyof T];
|
|
17
|
-
export type HasRequiredKeys<T> = RequiredKeys<T> extends never ? false : true;
|
|
1
|
+
import type { UnknownObject } from "../../types.js";
|
|
2
|
+
import type { CallToolArgs, CallToolResponse, FileMetadata, RequestModalOptions } from "../types.js";
|
|
3
|
+
type DisplayMode = "pip" | "inline" | "fullscreen" | "modal";
|
|
18
4
|
type WidgetState = UnknownObject;
|
|
19
|
-
type FileMetadata = {
|
|
20
|
-
fileId: string;
|
|
21
|
-
};
|
|
22
5
|
export declare const TOOL_RESPONSE_EVENT_TYPE = "openai:tool_response";
|
|
23
6
|
export declare class ToolResponseEvent extends CustomEvent<{
|
|
24
7
|
tool: {
|
|
@@ -30,21 +13,17 @@ export declare class ToolResponseEvent extends CustomEvent<{
|
|
|
30
13
|
}
|
|
31
14
|
declare global {
|
|
32
15
|
interface Window {
|
|
33
|
-
|
|
34
|
-
openai: OpenAiMethods<WidgetState> & OpenAiProperties;
|
|
16
|
+
openai: AppsSdkMethods<WidgetState> & AppsSdkContext;
|
|
35
17
|
}
|
|
36
18
|
interface WindowEventMap {
|
|
37
19
|
[SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
|
|
38
20
|
}
|
|
39
21
|
}
|
|
40
|
-
export type
|
|
41
|
-
hostType: WidgetHostType;
|
|
42
|
-
};
|
|
43
|
-
export type OpenAiProperties<ToolInput extends UnknownObject = Record<never, unknown>, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
|
|
22
|
+
export type AppsSdkContext<ToolInput extends UnknownObject = Record<never, unknown>, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
|
|
44
23
|
theme: Theme;
|
|
45
24
|
userAgent: UserAgent;
|
|
46
25
|
locale: string;
|
|
47
|
-
maxHeight: number;
|
|
26
|
+
maxHeight: number | undefined;
|
|
48
27
|
displayMode: DisplayMode;
|
|
49
28
|
safeArea: SafeArea;
|
|
50
29
|
view: View;
|
|
@@ -55,25 +34,7 @@ export type OpenAiProperties<ToolInput extends UnknownObject = Record<never, unk
|
|
|
55
34
|
toolResponseMetadata: ToolResponseMetadata | null;
|
|
56
35
|
widgetState: WidgetState | null;
|
|
57
36
|
};
|
|
58
|
-
export type
|
|
59
|
-
export type CallToolResponse = {
|
|
60
|
-
content: CallToolResult["content"];
|
|
61
|
-
structuredContent: Record<string, unknown>;
|
|
62
|
-
isError: boolean;
|
|
63
|
-
result: string;
|
|
64
|
-
meta: Record<string, unknown>;
|
|
65
|
-
};
|
|
66
|
-
export type RequestModalOptions = {
|
|
67
|
-
title?: string;
|
|
68
|
-
params?: Record<string, unknown>;
|
|
69
|
-
anchor?: {
|
|
70
|
-
top?: number;
|
|
71
|
-
left?: number;
|
|
72
|
-
width?: number;
|
|
73
|
-
height?: number;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
export type OpenAiMethods<WidgetState extends UnknownObject = UnknownObject> = {
|
|
37
|
+
export type AppsSdkMethods<WidgetState extends UnknownObject = UnknownObject> = {
|
|
77
38
|
/** Calls a tool on your MCP. Returns the full response. */
|
|
78
39
|
callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
|
|
79
40
|
/** Triggers a followup turn in the ChatGPT conversation */
|
|
@@ -110,34 +71,39 @@ export type OpenAiMethods<WidgetState extends UnknownObject = UnknownObject> = {
|
|
|
110
71
|
* Downloads a file from the host that was previously uploaded.
|
|
111
72
|
* Only files uploaded by the same connector instance can be downloaded.
|
|
112
73
|
*/
|
|
113
|
-
|
|
74
|
+
getFileDownloadUrl: (file: FileMetadata) => Promise<{
|
|
114
75
|
downloadUrl: string;
|
|
115
76
|
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Sets the open in app URL.
|
|
79
|
+
* This URL will be opened in the app when the user clicks on the top right button in fullscreen mode.
|
|
80
|
+
*/
|
|
81
|
+
setOpenInAppUrl: (args: {
|
|
82
|
+
href: string;
|
|
83
|
+
}) => Promise<void>;
|
|
116
84
|
};
|
|
117
85
|
export declare const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
|
|
118
86
|
export declare class SetGlobalsEvent extends CustomEvent<{
|
|
119
|
-
globals: Partial<
|
|
87
|
+
globals: Partial<AppsSdkContext>;
|
|
120
88
|
}> {
|
|
121
89
|
readonly type = "openai:set_globals";
|
|
122
90
|
}
|
|
123
|
-
|
|
124
|
-
export type DisplayMode = "pip" | "inline" | "fullscreen" | "modal";
|
|
125
|
-
export type View = {
|
|
91
|
+
type View = {
|
|
126
92
|
mode: DisplayMode;
|
|
127
93
|
params?: Record<string, unknown>;
|
|
128
94
|
};
|
|
129
|
-
|
|
130
|
-
|
|
95
|
+
type Theme = "light" | "dark";
|
|
96
|
+
type SafeAreaInsets = {
|
|
131
97
|
top: number;
|
|
132
98
|
bottom: number;
|
|
133
99
|
left: number;
|
|
134
100
|
right: number;
|
|
135
101
|
};
|
|
136
|
-
|
|
102
|
+
type SafeArea = {
|
|
137
103
|
insets: SafeAreaInsets;
|
|
138
104
|
};
|
|
139
|
-
|
|
140
|
-
|
|
105
|
+
type DeviceType = "mobile" | "tablet" | "desktop" | "unknown";
|
|
106
|
+
type UserAgent = {
|
|
141
107
|
device: {
|
|
142
108
|
type: DeviceType;
|
|
143
109
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk/types.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,MAAM,OAAO,iBAAkB,SAAQ,WAErC;IACkB,IAAI,GAAG,wBAAwB,CAAC;CACnD;AA2FD,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D,MAAM,OAAO,eAAgB,SAAQ,WAEnC;IACkB,IAAI,GAAG,sBAAsB,CAAC;CACjD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useSyncExternalStore } from "react";
|
|
2
|
-
import { AppsSdkBridge } from "
|
|
3
|
-
export function
|
|
2
|
+
import { AppsSdkBridge } from "./bridge.js";
|
|
3
|
+
export function useAppsSdkContext(key) {
|
|
4
4
|
const bridge = AppsSdkBridge.getInstance();
|
|
5
5
|
return useSyncExternalStore(bridge.subscribe(key), () => bridge.getSnapshot(key));
|
|
6
6
|
}
|
|
7
|
-
//# sourceMappingURL=use-apps-sdk-
|
|
7
|
+
//# sourceMappingURL=use-apps-sdk-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-apps-sdk-context.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk/use-apps-sdk-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,UAAU,iBAAiB,CAC/B,GAAM;IAEN,MAAM,MAAM,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;IAC3C,OAAO,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CACtD,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AppsSdkAdaptor } from "./apps-sdk/adaptor.js";
|
|
2
|
+
import { McpAppAdaptor } from "./mcp-app/adaptor.js";
|
|
3
|
+
export const getAdaptor = () => {
|
|
4
|
+
return window.skybridge.hostType === "apps-sdk"
|
|
5
|
+
? AppsSdkAdaptor.getInstance()
|
|
6
|
+
: McpAppAdaptor.getInstance();
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=get-adaptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-adaptor.js","sourceRoot":"","sources":["../../../src/web/bridges/get-adaptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,MAAM,CAAC,MAAM,UAAU,GAAG,GAAY,EAAE;IACtC,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,UAAU;QAC7C,CAAC,CAAC,cAAc,CAAC,WAAW,EAAE;QAC9B,CAAC,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web/bridges/index.tsx"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { McpUiRequestDisplayModeResult } from "@modelcontextprotocol/ext-apps";
|
|
2
|
+
import type { Adaptor, CallToolResponse, DisplayMode, HostContext, HostContextStore, RequestModalOptions, SetWidgetStateAction } from "../types.js";
|
|
3
|
+
export declare class McpAppAdaptor implements Adaptor {
|
|
4
|
+
private static instance;
|
|
5
|
+
private stores;
|
|
6
|
+
private _widgetState;
|
|
7
|
+
private widgetStateListeners;
|
|
8
|
+
private _viewState;
|
|
9
|
+
private viewListeners;
|
|
10
|
+
private constructor();
|
|
11
|
+
static getInstance(): McpAppAdaptor;
|
|
12
|
+
static resetInstance(): void;
|
|
13
|
+
getHostContextStore<K extends keyof HostContext>(key: K): HostContextStore<K>;
|
|
14
|
+
callTool: <ToolArgs extends Record<string, unknown> | null = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
|
|
15
|
+
requestDisplayMode: (mode: DisplayMode) => Promise<McpUiRequestDisplayModeResult>;
|
|
16
|
+
sendFollowUpMessage: (prompt: string) => Promise<void>;
|
|
17
|
+
openExternal(href: string): void;
|
|
18
|
+
private initializeStores;
|
|
19
|
+
setWidgetState: (stateOrUpdater: SetWidgetStateAction) => Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* @throws File upload is not supported in MCP App.
|
|
22
|
+
*/
|
|
23
|
+
uploadFile(): Promise<{
|
|
24
|
+
fileId: string;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* @throws File download is not supported in MCP App.
|
|
28
|
+
*/
|
|
29
|
+
getFileDownloadUrl(): Promise<{
|
|
30
|
+
downloadUrl: string;
|
|
31
|
+
}>;
|
|
32
|
+
openModal(options: RequestModalOptions): void;
|
|
33
|
+
closeModal(): void;
|
|
34
|
+
setOpenInAppUrl(_href: string): Promise<void>;
|
|
35
|
+
private createHostContextStore;
|
|
36
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { dequal } from "dequal/lite";
|
|
2
|
+
import { McpAppBridge } from "./bridge.js";
|
|
3
|
+
export class McpAppAdaptor {
|
|
4
|
+
static instance = null;
|
|
5
|
+
stores;
|
|
6
|
+
_widgetState = null;
|
|
7
|
+
widgetStateListeners = new Set();
|
|
8
|
+
_viewState = {
|
|
9
|
+
mode: "inline",
|
|
10
|
+
};
|
|
11
|
+
viewListeners = new Set();
|
|
12
|
+
constructor() {
|
|
13
|
+
this.stores = this.initializeStores();
|
|
14
|
+
}
|
|
15
|
+
static getInstance() {
|
|
16
|
+
if (!McpAppAdaptor.instance) {
|
|
17
|
+
McpAppAdaptor.instance = new McpAppAdaptor();
|
|
18
|
+
}
|
|
19
|
+
return McpAppAdaptor.instance;
|
|
20
|
+
}
|
|
21
|
+
static resetInstance() {
|
|
22
|
+
McpAppAdaptor.instance = null;
|
|
23
|
+
}
|
|
24
|
+
getHostContextStore(key) {
|
|
25
|
+
return this.stores[key];
|
|
26
|
+
}
|
|
27
|
+
callTool = async (name, args) => {
|
|
28
|
+
const bridge = McpAppBridge.getInstance();
|
|
29
|
+
const response = await bridge.request({
|
|
30
|
+
method: "tools/call",
|
|
31
|
+
params: {
|
|
32
|
+
name,
|
|
33
|
+
arguments: args ?? undefined,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
const result = response.content
|
|
37
|
+
.filter((content) => content.type === "text")
|
|
38
|
+
.map(({ text }) => text)
|
|
39
|
+
.join("\n");
|
|
40
|
+
return {
|
|
41
|
+
content: response.content,
|
|
42
|
+
structuredContent: response.structuredContent ?? {},
|
|
43
|
+
isError: response.isError ?? false,
|
|
44
|
+
result,
|
|
45
|
+
meta: response._meta ?? {},
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
requestDisplayMode = (mode) => {
|
|
49
|
+
const bridge = McpAppBridge.getInstance();
|
|
50
|
+
if (mode !== "modal") {
|
|
51
|
+
return bridge.request({
|
|
52
|
+
method: "ui/request-display-mode",
|
|
53
|
+
params: { mode },
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
throw new Error("Modal display mode is not accessible in MCP App.");
|
|
57
|
+
};
|
|
58
|
+
sendFollowUpMessage = async (prompt) => {
|
|
59
|
+
const bridge = McpAppBridge.getInstance();
|
|
60
|
+
await bridge.request({
|
|
61
|
+
method: "ui/message",
|
|
62
|
+
params: {
|
|
63
|
+
role: "user",
|
|
64
|
+
content: [
|
|
65
|
+
{
|
|
66
|
+
type: "text",
|
|
67
|
+
text: prompt,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
openExternal(href) {
|
|
74
|
+
const bridge = McpAppBridge.getInstance();
|
|
75
|
+
bridge.request({
|
|
76
|
+
method: "ui/open-link",
|
|
77
|
+
params: { url: href },
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
initializeStores() {
|
|
81
|
+
return {
|
|
82
|
+
theme: this.createHostContextStore(["theme"], ({ theme }) => theme ?? "light"),
|
|
83
|
+
locale: this.createHostContextStore(["locale"], ({ locale }) => locale ?? "en-US"),
|
|
84
|
+
safeArea: this.createHostContextStore(["safeAreaInsets"], ({ safeAreaInsets }) => ({
|
|
85
|
+
insets: safeAreaInsets ?? { top: 0, right: 0, bottom: 0, left: 0 },
|
|
86
|
+
})),
|
|
87
|
+
displayMode: this.createHostContextStore(["displayMode"], ({ displayMode }) => displayMode ?? "inline"),
|
|
88
|
+
maxHeight: this.createHostContextStore(["containerDimensions"], ({ containerDimensions }) => {
|
|
89
|
+
if (containerDimensions && "maxHeight" in containerDimensions) {
|
|
90
|
+
return containerDimensions.maxHeight;
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}),
|
|
94
|
+
userAgent: this.createHostContextStore(["platform", "deviceCapabilities"], ({ platform, deviceCapabilities }) => ({
|
|
95
|
+
device: {
|
|
96
|
+
type: platform === "web" ? "desktop" : (platform ?? "unknown"),
|
|
97
|
+
},
|
|
98
|
+
capabilities: {
|
|
99
|
+
hover: true,
|
|
100
|
+
touch: true,
|
|
101
|
+
...deviceCapabilities,
|
|
102
|
+
},
|
|
103
|
+
})),
|
|
104
|
+
toolInput: this.createHostContextStore(["toolInput"], ({ toolInput }) => toolInput ?? null),
|
|
105
|
+
toolOutput: this.createHostContextStore(["toolResult"], ({ toolResult }) => toolResult?.structuredContent ?? null),
|
|
106
|
+
toolResponseMetadata: this.createHostContextStore(["toolResult"], ({ toolResult }) => toolResult?._meta ?? null),
|
|
107
|
+
view: {
|
|
108
|
+
subscribe: (onChange) => {
|
|
109
|
+
this.viewListeners.add(onChange);
|
|
110
|
+
return () => {
|
|
111
|
+
this.viewListeners.delete(onChange);
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
getSnapshot: () => this._viewState,
|
|
115
|
+
},
|
|
116
|
+
widgetState: {
|
|
117
|
+
subscribe: (onChange) => {
|
|
118
|
+
this.widgetStateListeners.add(onChange);
|
|
119
|
+
return () => {
|
|
120
|
+
this.widgetStateListeners.delete(onChange);
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
getSnapshot: () => this._widgetState,
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
setWidgetState = async (stateOrUpdater) => {
|
|
128
|
+
const newState = typeof stateOrUpdater === "function"
|
|
129
|
+
? stateOrUpdater(this._widgetState)
|
|
130
|
+
: stateOrUpdater;
|
|
131
|
+
const bridge = McpAppBridge.getInstance();
|
|
132
|
+
await bridge.request({
|
|
133
|
+
method: "ui/update-model-context",
|
|
134
|
+
params: { structuredContent: newState },
|
|
135
|
+
});
|
|
136
|
+
this._widgetState = newState;
|
|
137
|
+
this.widgetStateListeners.forEach((listener) => {
|
|
138
|
+
listener();
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* @throws File upload is not supported in MCP App.
|
|
143
|
+
*/
|
|
144
|
+
uploadFile() {
|
|
145
|
+
throw new Error("File upload is not supported in MCP App.");
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* @throws File download is not supported in MCP App.
|
|
149
|
+
*/
|
|
150
|
+
getFileDownloadUrl() {
|
|
151
|
+
throw new Error("File download is not supported in MCP App.");
|
|
152
|
+
}
|
|
153
|
+
openModal(options) {
|
|
154
|
+
this._viewState = { mode: "modal", params: options.params };
|
|
155
|
+
this.viewListeners.forEach((listener) => {
|
|
156
|
+
listener();
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
closeModal() {
|
|
160
|
+
this._viewState = { mode: "inline" };
|
|
161
|
+
this.viewListeners.forEach((listener) => {
|
|
162
|
+
listener();
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
setOpenInAppUrl(_href) {
|
|
166
|
+
throw new Error("setOpenInAppUrl is not implemented in MCP App.");
|
|
167
|
+
}
|
|
168
|
+
createHostContextStore(keys, computeSnapshot) {
|
|
169
|
+
const bridge = McpAppBridge.getInstance();
|
|
170
|
+
let cachedValue;
|
|
171
|
+
return {
|
|
172
|
+
subscribe: bridge.subscribe(keys),
|
|
173
|
+
getSnapshot: () => {
|
|
174
|
+
const context = Object.fromEntries(keys.map((k) => [k, bridge.getSnapshot(k)]));
|
|
175
|
+
const newValue = computeSnapshot(context);
|
|
176
|
+
if (cachedValue !== undefined && dequal(cachedValue, newValue)) {
|
|
177
|
+
return cachedValue;
|
|
178
|
+
}
|
|
179
|
+
cachedValue = newValue;
|
|
180
|
+
return newValue;
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=adaptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app/adaptor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO3C,MAAM,OAAO,aAAa;IAChB,MAAM,CAAC,QAAQ,GAAyB,IAAI,CAAC;IAC7C,MAAM,CAEZ;IACM,YAAY,GAA+B,IAAI,CAAC;IAChD,oBAAoB,GAAG,IAAI,GAAG,EAAc,CAAC;IAE7C,UAAU,GAAwB;QACxC,IAAI,EAAE,QAAQ;KACf,CAAC;IACM,aAAa,GAAG,IAAI,GAAG,EAAc,CAAC;IAE9C;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACxC,CAAC;IAEM,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC5B,aAAa,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;QAC/C,CAAC;QACD,OAAO,aAAa,CAAC,QAAQ,CAAC;IAChC,CAAC;IAEM,MAAM,CAAC,aAAa;QACzB,aAAa,CAAC,QAAQ,GAAG,IAAI,CAAC;IAChC,CAAC;IAEM,mBAAmB,CACxB,GAAM;QAEN,OAAO,IAAI,CAAC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ext-apps";
|
|
2
|
+
import type { Bridge, Subscribe } from "../types.js";
|
|
3
|
+
import type { McpAppContext, McpAppContextKey } from "./types.js";
|
|
4
|
+
type McpAppInitializationOptions = Pick<McpUiInitializeRequest["params"], "appInfo">;
|
|
5
|
+
export declare class McpAppBridge implements Bridge<McpUiHostContext> {
|
|
6
|
+
private static instance;
|
|
7
|
+
context: McpAppContext;
|
|
8
|
+
private listeners;
|
|
9
|
+
private pendingRequests;
|
|
10
|
+
private nextId;
|
|
11
|
+
private initialized;
|
|
12
|
+
private appInitializationOptions;
|
|
13
|
+
private requestTimeout;
|
|
14
|
+
private cleanupSizeObserver;
|
|
15
|
+
constructor(options: McpAppInitializationOptions, requestTimeout?: number);
|
|
16
|
+
static getInstance(options?: Partial<McpAppInitializationOptions>, requestTimeout?: number): McpAppBridge;
|
|
17
|
+
subscribe(key: McpAppContextKey): Subscribe;
|
|
18
|
+
subscribe(keys: readonly McpAppContextKey[]): Subscribe;
|
|
19
|
+
getSnapshot<K extends keyof McpAppContext>(key: K): McpAppContext[K];
|
|
20
|
+
cleanup: () => void;
|
|
21
|
+
static resetInstance(): void;
|
|
22
|
+
request<R extends {
|
|
23
|
+
method: string;
|
|
24
|
+
params?: unknown;
|
|
25
|
+
}, T>({ method, params, }: R): Promise<T>;
|
|
26
|
+
private emit;
|
|
27
|
+
private updateContext;
|
|
28
|
+
private init;
|
|
29
|
+
private handleMessage;
|
|
30
|
+
private handleResponse;
|
|
31
|
+
private handleNotification;
|
|
32
|
+
private handleRequest;
|
|
33
|
+
private connect;
|
|
34
|
+
private notify;
|
|
35
|
+
private sendSizeChanged;
|
|
36
|
+
/**
|
|
37
|
+
* Set up automatic size change notifications using ResizeObserver.
|
|
38
|
+
* Based on @modelcontextprotocol/ext-apps App.setupSizeChangedNotifications
|
|
39
|
+
* @see https://github.com/modelcontextprotocol/ext-apps/blob/main/src/app.ts#L940-L989
|
|
40
|
+
*/
|
|
41
|
+
private setupSizeChangedNotifications;
|
|
42
|
+
}
|
|
43
|
+
export {};
|