@portel/photon 1.4.0 → 1.5.1
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 +287 -1160
- package/dist/auto-ui/beam.d.ts +9 -0
- package/dist/auto-ui/beam.d.ts.map +1 -0
- package/dist/auto-ui/beam.js +2381 -0
- package/dist/auto-ui/beam.js.map +1 -0
- package/dist/auto-ui/components/card.d.ts +13 -0
- package/dist/auto-ui/components/card.d.ts.map +1 -0
- package/dist/auto-ui/components/card.js +64 -0
- package/dist/auto-ui/components/card.js.map +1 -0
- package/dist/auto-ui/components/form.d.ts +15 -0
- package/dist/auto-ui/components/form.d.ts.map +1 -0
- package/dist/auto-ui/components/form.js +72 -0
- package/dist/auto-ui/components/form.js.map +1 -0
- package/dist/auto-ui/components/list.d.ts +13 -0
- package/dist/auto-ui/components/list.d.ts.map +1 -0
- package/dist/auto-ui/components/list.js +58 -0
- package/dist/auto-ui/components/list.js.map +1 -0
- package/dist/auto-ui/components/progress.d.ts +18 -0
- package/dist/auto-ui/components/progress.d.ts.map +1 -0
- package/dist/auto-ui/components/progress.js +125 -0
- package/dist/auto-ui/components/progress.js.map +1 -0
- package/dist/auto-ui/components/table.d.ts +13 -0
- package/dist/auto-ui/components/table.d.ts.map +1 -0
- package/dist/auto-ui/components/table.js +82 -0
- package/dist/auto-ui/components/table.js.map +1 -0
- package/dist/auto-ui/components/tree.d.ts +13 -0
- package/dist/auto-ui/components/tree.d.ts.map +1 -0
- package/dist/auto-ui/components/tree.js +61 -0
- package/dist/auto-ui/components/tree.js.map +1 -0
- package/dist/auto-ui/daemon-tools.d.ts +45 -0
- package/dist/auto-ui/daemon-tools.d.ts.map +1 -0
- package/dist/auto-ui/daemon-tools.js +580 -0
- package/dist/auto-ui/daemon-tools.js.map +1 -0
- package/dist/auto-ui/design-system/index.d.ts +21 -0
- package/dist/auto-ui/design-system/index.d.ts.map +1 -0
- package/dist/auto-ui/design-system/index.js +27 -0
- package/dist/auto-ui/design-system/index.js.map +1 -0
- package/dist/auto-ui/design-system/tokens.d.ts +9 -0
- package/dist/auto-ui/design-system/tokens.d.ts.map +1 -0
- package/dist/auto-ui/design-system/tokens.js +27 -0
- package/dist/auto-ui/design-system/tokens.js.map +1 -0
- package/dist/auto-ui/design-system/transaction-ui.d.ts +70 -0
- package/dist/auto-ui/design-system/transaction-ui.d.ts.map +1 -0
- package/dist/auto-ui/design-system/transaction-ui.js +982 -0
- package/dist/auto-ui/design-system/transaction-ui.js.map +1 -0
- package/dist/auto-ui/frontend/index.html +84 -0
- package/dist/auto-ui/index.d.ts +21 -0
- package/dist/auto-ui/index.d.ts.map +1 -0
- package/dist/auto-ui/index.js +25 -0
- package/dist/auto-ui/index.js.map +1 -0
- package/dist/auto-ui/openapi-generator.d.ts +71 -0
- package/dist/auto-ui/openapi-generator.d.ts.map +1 -0
- package/dist/auto-ui/openapi-generator.js +223 -0
- package/dist/auto-ui/openapi-generator.js.map +1 -0
- package/dist/auto-ui/photon-bridge.d.ts +159 -0
- package/dist/auto-ui/photon-bridge.d.ts.map +1 -0
- package/dist/auto-ui/photon-bridge.js +262 -0
- package/dist/auto-ui/photon-bridge.js.map +1 -0
- package/dist/auto-ui/photon-host.d.ts +113 -0
- package/dist/auto-ui/photon-host.d.ts.map +1 -0
- package/dist/auto-ui/photon-host.js +284 -0
- package/dist/auto-ui/photon-host.js.map +1 -0
- package/dist/auto-ui/platform-compat.d.ts +71 -0
- package/dist/auto-ui/platform-compat.d.ts.map +1 -0
- package/dist/auto-ui/platform-compat.js +574 -0
- package/dist/auto-ui/platform-compat.js.map +1 -0
- package/dist/auto-ui/playground-html.d.ts +15 -0
- package/dist/auto-ui/playground-html.d.ts.map +1 -0
- package/dist/auto-ui/playground-html.js +1113 -0
- package/dist/auto-ui/playground-html.js.map +1 -0
- package/dist/auto-ui/playground-server.d.ts +7 -0
- package/dist/auto-ui/playground-server.d.ts.map +1 -0
- package/dist/auto-ui/playground-server.js +840 -0
- package/dist/auto-ui/playground-server.js.map +1 -0
- package/dist/auto-ui/registry.d.ts +13 -0
- package/dist/auto-ui/registry.d.ts.map +1 -0
- package/dist/auto-ui/registry.js +62 -0
- package/dist/auto-ui/registry.js.map +1 -0
- package/dist/auto-ui/renderer.d.ts +14 -0
- package/dist/auto-ui/renderer.d.ts.map +1 -0
- package/dist/auto-ui/renderer.js +88 -0
- package/dist/auto-ui/renderer.js.map +1 -0
- package/dist/auto-ui/rendering/components.d.ts +29 -0
- package/dist/auto-ui/rendering/components.d.ts.map +1 -0
- package/dist/auto-ui/rendering/components.js +773 -0
- package/dist/auto-ui/rendering/components.js.map +1 -0
- package/dist/auto-ui/rendering/field-analyzer.d.ts +48 -0
- package/dist/auto-ui/rendering/field-analyzer.d.ts.map +1 -0
- package/dist/auto-ui/rendering/field-analyzer.js +270 -0
- package/dist/auto-ui/rendering/field-analyzer.js.map +1 -0
- package/dist/auto-ui/rendering/field-renderers.d.ts +64 -0
- package/dist/auto-ui/rendering/field-renderers.d.ts.map +1 -0
- package/dist/auto-ui/rendering/field-renderers.js +317 -0
- package/dist/auto-ui/rendering/field-renderers.js.map +1 -0
- package/dist/auto-ui/rendering/index.d.ts +28 -0
- package/dist/auto-ui/rendering/index.d.ts.map +1 -0
- package/dist/auto-ui/rendering/index.js +60 -0
- package/dist/auto-ui/rendering/index.js.map +1 -0
- package/dist/auto-ui/rendering/layout-selector.d.ts +48 -0
- package/dist/auto-ui/rendering/layout-selector.d.ts.map +1 -0
- package/dist/auto-ui/rendering/layout-selector.js +352 -0
- package/dist/auto-ui/rendering/layout-selector.js.map +1 -0
- package/dist/auto-ui/rendering/template-engine.d.ts +41 -0
- package/dist/auto-ui/rendering/template-engine.d.ts.map +1 -0
- package/dist/auto-ui/rendering/template-engine.js +238 -0
- package/dist/auto-ui/rendering/template-engine.js.map +1 -0
- package/dist/auto-ui/streamable-http-transport.d.ts +79 -0
- package/dist/auto-ui/streamable-http-transport.d.ts.map +1 -0
- package/dist/auto-ui/streamable-http-transport.js +1314 -0
- package/dist/auto-ui/streamable-http-transport.js.map +1 -0
- package/dist/auto-ui/types.d.ts +310 -0
- package/dist/auto-ui/types.d.ts.map +1 -0
- package/dist/auto-ui/types.js +71 -0
- package/dist/auto-ui/types.js.map +1 -0
- package/dist/beam.bundle.js +13506 -0
- package/dist/beam.bundle.js.map +7 -0
- package/dist/claude-code-plugin.d.ts.map +1 -1
- package/dist/claude-code-plugin.js +30 -30
- package/dist/claude-code-plugin.js.map +1 -1
- package/dist/cli/commands/info.d.ts +11 -0
- package/dist/cli/commands/info.d.ts.map +1 -0
- package/dist/cli/commands/info.js +313 -0
- package/dist/cli/commands/info.js.map +1 -0
- package/dist/cli/commands/marketplace.d.ts +11 -0
- package/dist/cli/commands/marketplace.d.ts.map +1 -0
- package/dist/cli/commands/marketplace.js +198 -0
- package/dist/cli/commands/marketplace.js.map +1 -0
- package/dist/cli/commands/package-app.d.ts +9 -0
- package/dist/cli/commands/package-app.d.ts.map +1 -0
- package/dist/cli/commands/package-app.js +191 -0
- package/dist/cli/commands/package-app.js.map +1 -0
- package/dist/cli/commands/package.d.ts +11 -0
- package/dist/cli/commands/package.d.ts.map +1 -0
- package/dist/cli/commands/package.js +573 -0
- package/dist/cli/commands/package.js.map +1 -0
- package/dist/cli-alias.d.ts.map +1 -1
- package/dist/cli-alias.js +30 -28
- package/dist/cli-alias.js.map +1 -1
- package/dist/cli-formatter.d.ts +8 -24
- package/dist/cli-formatter.d.ts.map +1 -1
- package/dist/cli-formatter.js +8 -325
- package/dist/cli-formatter.js.map +1 -1
- package/dist/cli.d.ts +15 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1157 -1132
- package/dist/cli.js.map +1 -1
- package/dist/daemon/client.d.ts +81 -0
- package/dist/daemon/client.d.ts.map +1 -1
- package/dist/daemon/client.js +583 -13
- package/dist/daemon/client.js.map +1 -1
- package/dist/daemon/manager.d.ts +46 -12
- package/dist/daemon/manager.d.ts.map +1 -1
- package/dist/daemon/manager.js +102 -61
- package/dist/daemon/manager.js.map +1 -1
- package/dist/daemon/protocol.d.ts +74 -6
- package/dist/daemon/protocol.d.ts.map +1 -1
- package/dist/daemon/protocol.js +76 -1
- package/dist/daemon/protocol.js.map +1 -1
- package/dist/daemon/server.d.ts +6 -6
- package/dist/daemon/server.js +778 -117
- package/dist/daemon/server.js.map +1 -1
- package/dist/daemon/session-manager.d.ts +8 -1
- package/dist/daemon/session-manager.d.ts.map +1 -1
- package/dist/daemon/session-manager.js +32 -9
- package/dist/daemon/session-manager.js.map +1 -1
- package/dist/deploy/cloudflare.d.ts +12 -0
- package/dist/deploy/cloudflare.d.ts.map +1 -0
- package/dist/deploy/cloudflare.js +216 -0
- package/dist/deploy/cloudflare.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +172 -15
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +1132 -267
- package/dist/loader.js.map +1 -1
- package/dist/markdown-utils.d.ts +8 -0
- package/dist/markdown-utils.d.ts.map +1 -0
- package/dist/markdown-utils.js +63 -0
- package/dist/markdown-utils.js.map +1 -0
- package/dist/marketplace-manager.d.ts +10 -0
- package/dist/marketplace-manager.d.ts.map +1 -1
- package/dist/marketplace-manager.js +112 -28
- package/dist/marketplace-manager.js.map +1 -1
- package/dist/mcp-client.d.ts +9 -0
- package/dist/mcp-client.d.ts.map +1 -0
- package/dist/mcp-client.js +11 -0
- package/dist/mcp-client.js.map +1 -0
- package/dist/mcp-elicitation.d.ts +32 -0
- package/dist/mcp-elicitation.d.ts.map +1 -0
- package/dist/mcp-elicitation.js +26 -0
- package/dist/mcp-elicitation.js.map +1 -0
- package/dist/path-resolver.d.ts +9 -12
- package/dist/path-resolver.d.ts.map +1 -1
- package/dist/path-resolver.js +13 -43
- package/dist/path-resolver.js.map +1 -1
- package/dist/photon-cli-runner.d.ts.map +1 -1
- package/dist/photon-cli-runner.js +216 -73
- package/dist/photon-cli-runner.js.map +1 -1
- package/dist/photon-doc-extractor.d.ts +88 -0
- package/dist/photon-doc-extractor.d.ts.map +1 -1
- package/dist/photon-doc-extractor.js +536 -27
- package/dist/photon-doc-extractor.js.map +1 -1
- package/dist/photons/maker.photon.d.ts +182 -0
- package/dist/photons/maker.photon.d.ts.map +1 -0
- package/dist/photons/maker.photon.js +504 -0
- package/dist/photons/maker.photon.js.map +1 -0
- package/dist/photons/maker.photon.ts +626 -0
- package/dist/photons/marketplace.photon.d.ts +110 -0
- package/dist/photons/marketplace.photon.d.ts.map +1 -0
- package/dist/photons/marketplace.photon.js +260 -0
- package/dist/photons/marketplace.photon.js.map +1 -0
- package/dist/photons/marketplace.photon.ts +378 -0
- package/dist/photons/tunnel.photon.d.ts +80 -0
- package/dist/photons/tunnel.photon.d.ts.map +1 -0
- package/dist/photons/tunnel.photon.js +269 -0
- package/dist/photons/tunnel.photon.js.map +1 -0
- package/dist/photons/tunnel.photon.ts +345 -0
- package/dist/security-scanner.d.ts.map +1 -1
- package/dist/security-scanner.js +18 -15
- package/dist/security-scanner.js.map +1 -1
- package/dist/serv/auth/jwt.d.ts +89 -0
- package/dist/serv/auth/jwt.d.ts.map +1 -0
- package/dist/serv/auth/jwt.js +239 -0
- package/dist/serv/auth/jwt.js.map +1 -0
- package/dist/serv/auth/oauth.d.ts +117 -0
- package/dist/serv/auth/oauth.d.ts.map +1 -0
- package/dist/serv/auth/oauth.js +395 -0
- package/dist/serv/auth/oauth.js.map +1 -0
- package/dist/serv/auth/well-known.d.ts +60 -0
- package/dist/serv/auth/well-known.d.ts.map +1 -0
- package/dist/serv/auth/well-known.js +154 -0
- package/dist/serv/auth/well-known.js.map +1 -0
- package/dist/serv/db/d1-client.d.ts +65 -0
- package/dist/serv/db/d1-client.d.ts.map +1 -0
- package/dist/serv/db/d1-client.js +137 -0
- package/dist/serv/db/d1-client.js.map +1 -0
- package/dist/serv/db/d1-stores.d.ts +62 -0
- package/dist/serv/db/d1-stores.d.ts.map +1 -0
- package/dist/serv/db/d1-stores.js +307 -0
- package/dist/serv/db/d1-stores.js.map +1 -0
- package/dist/serv/index.d.ts +114 -0
- package/dist/serv/index.d.ts.map +1 -0
- package/dist/serv/index.js +172 -0
- package/dist/serv/index.js.map +1 -0
- package/dist/serv/local.d.ts +118 -0
- package/dist/serv/local.d.ts.map +1 -0
- package/dist/serv/local.js +392 -0
- package/dist/serv/local.js.map +1 -0
- package/dist/serv/middleware/auth.d.ts +66 -0
- package/dist/serv/middleware/auth.d.ts.map +1 -0
- package/dist/serv/middleware/auth.js +178 -0
- package/dist/serv/middleware/auth.js.map +1 -0
- package/dist/serv/middleware/tenant.d.ts +94 -0
- package/dist/serv/middleware/tenant.d.ts.map +1 -0
- package/dist/serv/middleware/tenant.js +152 -0
- package/dist/serv/middleware/tenant.js.map +1 -0
- package/dist/serv/runtime/executor.d.ts +76 -0
- package/dist/serv/runtime/executor.d.ts.map +1 -0
- package/dist/serv/runtime/executor.js +105 -0
- package/dist/serv/runtime/executor.js.map +1 -0
- package/dist/serv/runtime/index.d.ts +8 -0
- package/dist/serv/runtime/index.d.ts.map +1 -0
- package/dist/serv/runtime/index.js +10 -0
- package/dist/serv/runtime/index.js.map +1 -0
- package/dist/serv/runtime/oauth-context.d.ts +121 -0
- package/dist/serv/runtime/oauth-context.d.ts.map +1 -0
- package/dist/serv/runtime/oauth-context.js +153 -0
- package/dist/serv/runtime/oauth-context.js.map +1 -0
- package/dist/serv/session/kv-store.d.ts +54 -0
- package/dist/serv/session/kv-store.d.ts.map +1 -0
- package/dist/serv/session/kv-store.js +149 -0
- package/dist/serv/session/kv-store.js.map +1 -0
- package/dist/serv/session/store.d.ts +113 -0
- package/dist/serv/session/store.d.ts.map +1 -0
- package/dist/serv/session/store.js +284 -0
- package/dist/serv/session/store.js.map +1 -0
- package/dist/serv/types/index.d.ts +147 -0
- package/dist/serv/types/index.d.ts.map +1 -0
- package/dist/serv/types/index.js +8 -0
- package/dist/serv/types/index.js.map +1 -0
- package/dist/serv/vault/token-vault.d.ts +102 -0
- package/dist/serv/vault/token-vault.d.ts.map +1 -0
- package/dist/serv/vault/token-vault.js +177 -0
- package/dist/serv/vault/token-vault.js.map +1 -0
- package/dist/server.d.ts +173 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1622 -86
- package/dist/server.js.map +1 -1
- package/dist/shared/cli-sections.d.ts +6 -0
- package/dist/shared/cli-sections.d.ts.map +1 -0
- package/dist/shared/cli-sections.js +16 -0
- package/dist/shared/cli-sections.js.map +1 -0
- package/dist/shared/cli-utils.d.ts +81 -0
- package/dist/shared/cli-utils.d.ts.map +1 -0
- package/dist/shared/cli-utils.js +174 -0
- package/dist/shared/cli-utils.js.map +1 -0
- package/dist/shared/config-docs.d.ts +6 -0
- package/dist/shared/config-docs.d.ts.map +1 -0
- package/dist/shared/config-docs.js +6 -0
- package/dist/shared/config-docs.js.map +1 -0
- package/dist/shared/error-handler.d.ts +128 -0
- package/dist/shared/error-handler.d.ts.map +1 -0
- package/dist/shared/error-handler.js +342 -0
- package/dist/shared/error-handler.js.map +1 -0
- package/dist/shared/logger.d.ts +42 -0
- package/dist/shared/logger.d.ts.map +1 -0
- package/dist/shared/logger.js +123 -0
- package/dist/shared/logger.js.map +1 -0
- package/dist/shared/performance.d.ts +65 -0
- package/dist/shared/performance.d.ts.map +1 -0
- package/dist/shared/performance.js +136 -0
- package/dist/shared/performance.js.map +1 -0
- package/dist/shared/task-runner.d.ts +2 -0
- package/dist/shared/task-runner.d.ts.map +1 -0
- package/dist/shared/task-runner.js +16 -0
- package/dist/shared/task-runner.js.map +1 -0
- package/dist/shared/validation.d.ts +6 -0
- package/dist/shared/validation.d.ts.map +1 -0
- package/dist/shared/validation.js +6 -0
- package/dist/shared/validation.js.map +1 -0
- package/dist/shared-utils.d.ts +63 -0
- package/dist/shared-utils.d.ts.map +1 -0
- package/dist/shared-utils.js +123 -0
- package/dist/shared-utils.js.map +1 -0
- package/dist/template-manager.d.ts +23 -2
- package/dist/template-manager.d.ts.map +1 -1
- package/dist/template-manager.js +177 -88
- package/dist/template-manager.js.map +1 -1
- package/dist/test-client.d.ts.map +1 -1
- package/dist/test-client.js +10 -8
- package/dist/test-client.js.map +1 -1
- package/dist/test-runner.d.ts +52 -0
- package/dist/test-runner.d.ts.map +1 -0
- package/dist/test-runner.js +785 -0
- package/dist/test-runner.js.map +1 -0
- package/dist/testing.d.ts +103 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +163 -0
- package/dist/testing.js.map +1 -0
- package/dist/version-checker.d.ts.map +1 -1
- package/dist/version-checker.js +2 -2
- package/dist/version-checker.js.map +1 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/dist/watcher.d.ts +6 -3
- package/dist/watcher.d.ts.map +1 -1
- package/dist/watcher.js +49 -10
- package/dist/watcher.js.map +1 -1
- package/package.json +47 -7
- package/templates/cloudflare/worker.ts.template +381 -0
- package/templates/cloudflare/wrangler.toml.template +9 -0
- package/dist/base.d.ts +0 -58
- package/dist/base.d.ts.map +0 -1
- package/dist/base.js +0 -92
- package/dist/base.js.map +0 -1
- package/dist/dependency-manager.d.ts +0 -49
- package/dist/dependency-manager.d.ts.map +0 -1
- package/dist/dependency-manager.js +0 -165
- package/dist/dependency-manager.js.map +0 -1
- package/dist/registry-manager.d.ts +0 -76
- package/dist/registry-manager.d.ts.map +0 -1
- package/dist/registry-manager.js +0 -220
- package/dist/registry-manager.js.map +0 -1
- package/dist/schema-extractor.d.ts +0 -110
- package/dist/schema-extractor.d.ts.map +0 -1
- package/dist/schema-extractor.js +0 -727
- package/dist/schema-extractor.js.map +0 -1
- package/dist/test-marketplace-sources.d.ts +0 -5
- package/dist/test-marketplace-sources.d.ts.map +0 -1
- package/dist/test-marketplace-sources.js +0 -53
- package/dist/test-marketplace-sources.js.map +0 -1
- package/dist/types.d.ts +0 -109
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -12
- package/dist/types.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"photon-host.js","sourceRoot":"","sources":["../../src/auto-ui/photon-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAoBH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EACL,uBAAuB,EACvB,yBAAyB,GAE1B,MAAM,sBAAsB,CAAC;AAgB9B;;;GAGG;AACH,MAAM,OAAO,UAAU;IACb,MAAM,CAAoB;IAC1B,OAAO,CAAgB;IACvB,eAAe,CAAkB;IACjC,SAAS,CAAsB;IAC/B,mBAAmB,GAAG,IAAI,GAAG,EAMlC,CAAC;IACI,OAAO,GAAG,KAAK,CAAC;IAChB,YAAY,CAAgB;IAC5B,YAAY,CAAc;IAC1B,cAAc,CAAuB;IACrC,OAAO,CAAoB;IAEnC,YAAY,MAAyB,EAAE,OAA0B;QAC/D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QAEnC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC;QAEtC,IAAI,CAAC,OAAO,GAAG;YACb,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,KAAK;YACL,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,OAAO;SAClC,CAAC;QAEF,IAAI,CAAC,eAAe,GAAG;YACrB,KAAK;YACL,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,OAAO;YACjC,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,QAAQ;YAC5C,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,QAAQ,EAAE,OAAO,CAAC,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CAAC,KAAK,CAAC,CAAC;gBAC7B,CAAC;gBACD,MAAM;YAER,KAAK,kBAAkB;gBACrB,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;oBAC/B,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACxC,CAAC;gBACD,MAAM;YAER,KAAK,kBAAkB;gBACrB,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;oBAC5B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACvC,CAAC;gBACD,MAAM;QACV,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAgB;IACtD,OAAO,CAAC,UAAe,EAAE,EAAE;QACzB,IAAI,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,MAAM,IAAI,UAAU,EAAE,CAAC;YACzE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAgB;IACtD,OAAO,KAAK,EAAE,GAAQ,EAAgB,EAAE;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Compatibility Layer
|
|
3
|
+
*
|
|
4
|
+
* Provides universal compatibility for custom UIs across:
|
|
5
|
+
* - MCP Apps Extension (SEP-1865) - Standard ui/initialize protocol
|
|
6
|
+
* - ChatGPT Apps SDK - window.openai API
|
|
7
|
+
* - Claude Artifacts - postMessage with theme class
|
|
8
|
+
*
|
|
9
|
+
* BEAM injects all these APIs so apps built for any platform work without modification.
|
|
10
|
+
*
|
|
11
|
+
* @see https://github.com/modelcontextprotocol/modelcontextprotocol/pull/1865
|
|
12
|
+
* @see https://developers.openai.com/apps-sdk/reference/
|
|
13
|
+
* @see https://www.reidbarber.com/blog/reverse-engineering-claude-artifacts
|
|
14
|
+
*/
|
|
15
|
+
import type { PlatformContext } from '@portel/photon-core';
|
|
16
|
+
export { type McpAppsInitialize, type McpAppsToolInput, type McpAppsToolResult, type McpAppsHostContextChanged, type McpAppsResourceTeardown, type McpAppsModelContextUpdate, type PlatformContext, createMcpAppsInitialize, createThemeChangeMessages, } from '@portel/photon-core';
|
|
17
|
+
export interface OpenAiContext {
|
|
18
|
+
theme: 'light' | 'dark';
|
|
19
|
+
displayMode: 'inline' | 'fullscreen' | 'pip';
|
|
20
|
+
locale: string;
|
|
21
|
+
maxHeight: number;
|
|
22
|
+
safeArea: {
|
|
23
|
+
top: number;
|
|
24
|
+
bottom: number;
|
|
25
|
+
left: number;
|
|
26
|
+
right: number;
|
|
27
|
+
};
|
|
28
|
+
view: 'widget' | 'modal';
|
|
29
|
+
userAgent: string;
|
|
30
|
+
toolInput: Record<string, unknown>;
|
|
31
|
+
toolOutput: unknown;
|
|
32
|
+
widgetState: unknown;
|
|
33
|
+
}
|
|
34
|
+
export interface OpenAiApi {
|
|
35
|
+
theme: 'light' | 'dark';
|
|
36
|
+
displayMode: 'inline' | 'fullscreen' | 'pip';
|
|
37
|
+
locale: string;
|
|
38
|
+
maxHeight: number;
|
|
39
|
+
toolInput: Record<string, unknown>;
|
|
40
|
+
toolOutput: unknown;
|
|
41
|
+
widgetState: unknown;
|
|
42
|
+
setWidgetState(state: unknown): void;
|
|
43
|
+
callTool(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
44
|
+
sendFollowUpMessage(options: {
|
|
45
|
+
prompt: string;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
uploadFile(file: File): Promise<{
|
|
48
|
+
fileId: string;
|
|
49
|
+
}>;
|
|
50
|
+
getFileDownloadUrl(options: {
|
|
51
|
+
fileId: string;
|
|
52
|
+
}): Promise<string>;
|
|
53
|
+
requestDisplayMode(mode: 'inline' | 'fullscreen' | 'pip'): Promise<void>;
|
|
54
|
+
requestModal(options: {
|
|
55
|
+
params: unknown;
|
|
56
|
+
template: string;
|
|
57
|
+
}): Promise<void>;
|
|
58
|
+
notifyIntrinsicHeight(height: number): void;
|
|
59
|
+
openExternal(options: {
|
|
60
|
+
href: string;
|
|
61
|
+
}): void;
|
|
62
|
+
setOpenInAppUrl(options: {
|
|
63
|
+
href: string;
|
|
64
|
+
}): void;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Generate the script that injects all platform APIs into an iframe.
|
|
68
|
+
* This enables apps built for ChatGPT, Claude, or MCP Apps to work in BEAM.
|
|
69
|
+
*/
|
|
70
|
+
export declare function generatePlatformBridgeScript(context: PlatformContext): string;
|
|
71
|
+
//# sourceMappingURL=platform-compat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-compat.d.ts","sourceRoot":"","sources":["../../src/auto-ui/platform-compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAC9B,KAAK,eAAe,EACpB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAM7B,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,WAAW,EAAE,QAAQ,GAAG,YAAY,GAAG,KAAK,CAAC;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,C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;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,YAAY,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9C,eAAe,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAClD;AAMD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAkiB7E"}
|
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Compatibility Layer
|
|
3
|
+
*
|
|
4
|
+
* Provides universal compatibility for custom UIs across:
|
|
5
|
+
* - MCP Apps Extension (SEP-1865) - Standard ui/initialize protocol
|
|
6
|
+
* - ChatGPT Apps SDK - window.openai API
|
|
7
|
+
* - Claude Artifacts - postMessage with theme class
|
|
8
|
+
*
|
|
9
|
+
* BEAM injects all these APIs so apps built for any platform work without modification.
|
|
10
|
+
*
|
|
11
|
+
* @see https://github.com/modelcontextprotocol/modelcontextprotocol/pull/1865
|
|
12
|
+
* @see https://developers.openai.com/apps-sdk/reference/
|
|
13
|
+
* @see https://www.reidbarber.com/blog/reverse-engineering-claude-artifacts
|
|
14
|
+
*/
|
|
15
|
+
import { getThemeTokens } from './design-system/tokens.js';
|
|
16
|
+
// Re-export MCP Apps standard types and helpers from core
|
|
17
|
+
export { createMcpAppsInitialize, createThemeChangeMessages, } from '@portel/photon-core';
|
|
18
|
+
// ════════════════════════════════════════════════════════════════════════════════
|
|
19
|
+
// PLATFORM BRIDGE SCRIPT GENERATOR
|
|
20
|
+
// ════════════════════════════════════════════════════════════════════════════════
|
|
21
|
+
/**
|
|
22
|
+
* Generate the script that injects all platform APIs into an iframe.
|
|
23
|
+
* This enables apps built for ChatGPT, Claude, or MCP Apps to work in BEAM.
|
|
24
|
+
*/
|
|
25
|
+
export function generatePlatformBridgeScript(context) {
|
|
26
|
+
const themeTokens = getThemeTokens(context.theme);
|
|
27
|
+
const themeTokensJson = JSON.stringify(themeTokens);
|
|
28
|
+
const contextJson = JSON.stringify(context);
|
|
29
|
+
return `
|
|
30
|
+
<script>
|
|
31
|
+
(function() {
|
|
32
|
+
'use strict';
|
|
33
|
+
|
|
34
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
35
|
+
// SHARED STATE
|
|
36
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
37
|
+
|
|
38
|
+
var ctx = ${contextJson};
|
|
39
|
+
var themeTokens = ${themeTokensJson};
|
|
40
|
+
var toolInput = {};
|
|
41
|
+
var toolOutput = null;
|
|
42
|
+
var widgetState = {};
|
|
43
|
+
var pendingCalls = {};
|
|
44
|
+
var callIdCounter = 0;
|
|
45
|
+
|
|
46
|
+
// Event listeners
|
|
47
|
+
var listeners = {
|
|
48
|
+
progress: [],
|
|
49
|
+
status: [],
|
|
50
|
+
stream: [],
|
|
51
|
+
emit: [],
|
|
52
|
+
toolInputPartial: [],
|
|
53
|
+
toolInput: [],
|
|
54
|
+
result: [],
|
|
55
|
+
error: [],
|
|
56
|
+
themeChange: []
|
|
57
|
+
};
|
|
58
|
+
var elicitationHandler = null;
|
|
59
|
+
var teardownHandler = null;
|
|
60
|
+
|
|
61
|
+
function subscribe(arr, cb) {
|
|
62
|
+
arr.push(cb);
|
|
63
|
+
return function() { var i = arr.indexOf(cb); if (i >= 0) arr.splice(i, 1); };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function postToHost(msg) {
|
|
67
|
+
window.parent.postMessage(msg, '*');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function generateCallId() {
|
|
71
|
+
return 'call_' + (++callIdCounter) + '_' + Math.random().toString(36).slice(2);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
75
|
+
// MESSAGE HANDLER (receives from host)
|
|
76
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
77
|
+
|
|
78
|
+
window.addEventListener('message', function(e) {
|
|
79
|
+
var m = e.data;
|
|
80
|
+
if (!m || typeof m !== 'object') return;
|
|
81
|
+
|
|
82
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
83
|
+
// MCP Apps Extension (JSON-RPC 2.0)
|
|
84
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
85
|
+
if (m.jsonrpc === '2.0') {
|
|
86
|
+
// JSON-RPC response (from tools/call) - has id but no method
|
|
87
|
+
if (m.id && !m.method) {
|
|
88
|
+
var pending = pendingCalls[m.id];
|
|
89
|
+
if (pending) {
|
|
90
|
+
delete pendingCalls[m.id];
|
|
91
|
+
if (m.error) pending.reject(new Error(m.error.message || 'Tool call failed'));
|
|
92
|
+
else pending.resolve(m.result);
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (m.method === 'ui/initialize') {
|
|
97
|
+
// Standard: hostContext.styles.variables; Legacy: params.theme
|
|
98
|
+
var initTokens = (m.params.hostContext && m.params.hostContext.styles && m.params.hostContext.styles.variables) || m.params.theme;
|
|
99
|
+
if (initTokens) themeTokens = initTokens;
|
|
100
|
+
// Extract theme name from hostContext or fall back
|
|
101
|
+
if (m.params.hostContext && m.params.hostContext.theme) ctx.theme = m.params.hostContext.theme;
|
|
102
|
+
applyThemeTokens();
|
|
103
|
+
}
|
|
104
|
+
else if (m.method === 'ui/notifications/tool-input-partial') {
|
|
105
|
+
listeners.toolInputPartial.forEach(function(cb) { cb(m.params); });
|
|
106
|
+
}
|
|
107
|
+
else if (m.method === 'ui/notifications/tool-input') {
|
|
108
|
+
toolInput = m.params.input || {};
|
|
109
|
+
listeners.toolInput.forEach(function(cb) { cb(m.params); });
|
|
110
|
+
}
|
|
111
|
+
else if (m.method === 'ui/notifications/tool-result') {
|
|
112
|
+
toolOutput = m.params.result;
|
|
113
|
+
listeners.result.forEach(function(cb) { cb(m.params.result); });
|
|
114
|
+
}
|
|
115
|
+
else if (m.method === 'ui/resource-teardown' && m.id != null) {
|
|
116
|
+
var teardownResult = teardownHandler ? teardownHandler() : undefined;
|
|
117
|
+
var sendTeardownResponse = function() {
|
|
118
|
+
postToHost({ jsonrpc: '2.0', id: m.id, result: {} });
|
|
119
|
+
};
|
|
120
|
+
if (teardownResult && typeof teardownResult.then === 'function') {
|
|
121
|
+
teardownResult.then(sendTeardownResponse).catch(sendTeardownResponse);
|
|
122
|
+
} else {
|
|
123
|
+
sendTeardownResponse();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else if (m.method === 'ui/notifications/context' || m.method === 'ui/notifications/host-context-changed') {
|
|
127
|
+
// Standard spec: host-context-changed with styles.variables
|
|
128
|
+
var ctxParams = m.params || {};
|
|
129
|
+
if (ctxParams.styles && ctxParams.styles.variables) {
|
|
130
|
+
themeTokens = ctxParams.styles.variables;
|
|
131
|
+
applyThemeTokens();
|
|
132
|
+
}
|
|
133
|
+
if (ctxParams.theme) {
|
|
134
|
+
ctx.theme = ctxParams.theme;
|
|
135
|
+
applyThemeClass();
|
|
136
|
+
listeners.themeChange.forEach(function(cb) { cb(ctx.theme); });
|
|
137
|
+
}
|
|
138
|
+
// Legacy: flat merge
|
|
139
|
+
Object.assign(ctx, ctxParams);
|
|
140
|
+
}
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
145
|
+
// Photon Bridge Protocol (internal)
|
|
146
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
147
|
+
if (typeof m.type === 'string' && m.type.indexOf('photon:') === 0) {
|
|
148
|
+
if (m.type === 'photon:init') {
|
|
149
|
+
toolInput = m.toolInput || {};
|
|
150
|
+
Object.assign(ctx, m.context);
|
|
151
|
+
themeTokens = m.themeTokens || themeTokens;
|
|
152
|
+
applyThemeTokens();
|
|
153
|
+
}
|
|
154
|
+
else if (m.type === 'photon:emit') {
|
|
155
|
+
var ev = m.event;
|
|
156
|
+
listeners.emit.forEach(function(cb) { cb(ev); });
|
|
157
|
+
if (ev.emit === 'progress') listeners.progress.forEach(function(cb) { cb(ev); });
|
|
158
|
+
else if (ev.emit === 'status') listeners.status.forEach(function(cb) { cb(ev); });
|
|
159
|
+
else if (ev.emit === 'stream') listeners.stream.forEach(function(cb) { cb(ev); });
|
|
160
|
+
}
|
|
161
|
+
else if (m.type === 'photon:ask' && elicitationHandler) {
|
|
162
|
+
elicitationHandler(m.event).then(function(v) {
|
|
163
|
+
postToHost({ type: 'photon:ask-response', id: m.id, value: v });
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
else if (m.type === 'photon:result') {
|
|
167
|
+
toolOutput = m.data;
|
|
168
|
+
listeners.result.forEach(function(cb) { cb(m.data); });
|
|
169
|
+
}
|
|
170
|
+
else if (m.type === 'photon:error') {
|
|
171
|
+
listeners.error.forEach(function(cb) { cb(m.error); });
|
|
172
|
+
}
|
|
173
|
+
else if (m.type === 'photon:context') {
|
|
174
|
+
Object.assign(ctx, m.context);
|
|
175
|
+
if (m.themeTokens) {
|
|
176
|
+
themeTokens = m.themeTokens;
|
|
177
|
+
applyThemeTokens();
|
|
178
|
+
}
|
|
179
|
+
if (m.context.theme) {
|
|
180
|
+
listeners.themeChange.forEach(function(cb) { cb(ctx.theme); });
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else if (m.type === 'photon:theme-change') {
|
|
184
|
+
// Theme change from BEAM
|
|
185
|
+
ctx.theme = m.theme || 'dark';
|
|
186
|
+
// Update theme tokens if provided
|
|
187
|
+
if (m.themeTokens) {
|
|
188
|
+
themeTokens = m.themeTokens;
|
|
189
|
+
applyThemeTokens();
|
|
190
|
+
}
|
|
191
|
+
applyThemeClass();
|
|
192
|
+
listeners.themeChange.forEach(function(cb) { cb(ctx.theme); });
|
|
193
|
+
}
|
|
194
|
+
else if (m.type === 'photon:upload-file-response') {
|
|
195
|
+
var pending = pendingCalls[m.callId];
|
|
196
|
+
if (pending) {
|
|
197
|
+
delete pendingCalls[m.callId];
|
|
198
|
+
if (m.error) pending.reject(new Error(m.error));
|
|
199
|
+
else pending.resolve({ fileId: m.fileId });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else if (m.type === 'photon:get-file-url-response') {
|
|
203
|
+
var pending = pendingCalls[m.callId];
|
|
204
|
+
if (pending) {
|
|
205
|
+
delete pendingCalls[m.callId];
|
|
206
|
+
if (m.error) pending.reject(new Error(m.error));
|
|
207
|
+
else pending.resolve(m.url);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else if (m.type === 'photon:request-modal-response') {
|
|
211
|
+
var pending = pendingCalls[m.callId];
|
|
212
|
+
if (pending) {
|
|
213
|
+
delete pendingCalls[m.callId];
|
|
214
|
+
if (m.error) pending.reject(new Error(m.error));
|
|
215
|
+
else pending.resolve(m.result);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
else if (m.type === 'photon:init-state') {
|
|
219
|
+
// Restore persisted widget state from host
|
|
220
|
+
if (m.state !== null && m.state !== undefined) {
|
|
221
|
+
widgetState = m.state;
|
|
222
|
+
// Dispatch event for apps listening to state changes
|
|
223
|
+
window.dispatchEvent(new CustomEvent('photon:state-restored', { detail: m.state }));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
230
|
+
// Claude Artifacts Protocol (simple postMessage)
|
|
231
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
232
|
+
if (m.type === 'theme') {
|
|
233
|
+
ctx.theme = m.theme || 'dark';
|
|
234
|
+
applyThemeClass();
|
|
235
|
+
listeners.themeChange.forEach(function(cb) { cb(ctx.theme); });
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
239
|
+
// OpenAI set_globals event
|
|
240
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
241
|
+
if (m.type === 'openai:set_globals') {
|
|
242
|
+
if (m.theme) ctx.theme = m.theme;
|
|
243
|
+
if (m.toolInput) toolInput = m.toolInput;
|
|
244
|
+
if (m.toolOutput) toolOutput = m.toolOutput;
|
|
245
|
+
if (m.widgetState) widgetState = m.widgetState;
|
|
246
|
+
applyThemeClass();
|
|
247
|
+
listeners.themeChange.forEach(function(cb) { cb(ctx.theme); });
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
252
|
+
// THEME APPLICATION
|
|
253
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
254
|
+
|
|
255
|
+
function applyThemeTokens() {
|
|
256
|
+
var root = document.documentElement;
|
|
257
|
+
for (var key in themeTokens) {
|
|
258
|
+
root.style.setProperty(key, themeTokens[key]);
|
|
259
|
+
}
|
|
260
|
+
// Set safe area inset CSS variables
|
|
261
|
+
var insets = ctx.safeAreaInsets || { top: 0, bottom: 0, left: 0, right: 0 };
|
|
262
|
+
root.style.setProperty('--safe-area-inset-top', insets.top + 'px');
|
|
263
|
+
root.style.setProperty('--safe-area-inset-bottom', insets.bottom + 'px');
|
|
264
|
+
root.style.setProperty('--safe-area-inset-left', insets.left + 'px');
|
|
265
|
+
root.style.setProperty('--safe-area-inset-right', insets.right + 'px');
|
|
266
|
+
applyThemeClass();
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function applyThemeClass() {
|
|
270
|
+
document.documentElement.classList.remove('light', 'dark', 'light-theme');
|
|
271
|
+
document.documentElement.classList.add(ctx.theme);
|
|
272
|
+
|
|
273
|
+
// Define colors for each theme (must match design-system/tokens.ts)
|
|
274
|
+
var lightBg = '#ffffff';
|
|
275
|
+
var lightText = '#1a1a1a';
|
|
276
|
+
var darkBg = '#0d0d0d';
|
|
277
|
+
var darkText = '#e6e6e6';
|
|
278
|
+
|
|
279
|
+
if (ctx.theme === 'light') {
|
|
280
|
+
document.documentElement.classList.add('light-theme');
|
|
281
|
+
document.documentElement.style.colorScheme = 'light';
|
|
282
|
+
document.documentElement.style.backgroundColor = lightBg;
|
|
283
|
+
if (document.body) {
|
|
284
|
+
document.body.style.backgroundColor = lightBg;
|
|
285
|
+
document.body.style.color = lightText;
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
document.documentElement.style.colorScheme = 'dark';
|
|
289
|
+
document.documentElement.style.backgroundColor = darkBg;
|
|
290
|
+
if (document.body) {
|
|
291
|
+
document.body.style.backgroundColor = darkBg;
|
|
292
|
+
document.body.style.color = darkText;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
document.documentElement.setAttribute('data-theme', ctx.theme);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
299
|
+
// CALL TOOL HELPER
|
|
300
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
301
|
+
|
|
302
|
+
function callTool(name, args) {
|
|
303
|
+
var callId = generateCallId();
|
|
304
|
+
return new Promise(function(resolve, reject) {
|
|
305
|
+
pendingCalls[callId] = { resolve: resolve, reject: reject };
|
|
306
|
+
|
|
307
|
+
// MCP Apps standard: JSON-RPC tools/call
|
|
308
|
+
postToHost({
|
|
309
|
+
jsonrpc: '2.0',
|
|
310
|
+
id: callId,
|
|
311
|
+
method: 'tools/call',
|
|
312
|
+
params: { name: name, arguments: args || {} }
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
// Timeout after 30s
|
|
316
|
+
setTimeout(function() {
|
|
317
|
+
if (pendingCalls[callId]) {
|
|
318
|
+
delete pendingCalls[callId];
|
|
319
|
+
reject(new Error('Tool call timeout'));
|
|
320
|
+
}
|
|
321
|
+
}, 30000);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
326
|
+
// 1. WINDOW.PHOTON - Photon Bridge API
|
|
327
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
328
|
+
|
|
329
|
+
window.photon = {
|
|
330
|
+
get toolInput() { return toolInput; },
|
|
331
|
+
get toolOutput() { return toolOutput; },
|
|
332
|
+
get widgetState() { return widgetState; },
|
|
333
|
+
setWidgetState: function(s) {
|
|
334
|
+
widgetState = s;
|
|
335
|
+
postToHost({ type: 'photon:set-state', state: s });
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
onProgress: function(cb) { return subscribe(listeners.progress, cb); },
|
|
339
|
+
onStatus: function(cb) { return subscribe(listeners.status, cb); },
|
|
340
|
+
onStream: function(cb) { return subscribe(listeners.stream, cb); },
|
|
341
|
+
onEmit: function(cb) { return subscribe(listeners.emit, cb); },
|
|
342
|
+
onResult: function(cb) { return subscribe(listeners.result, cb); },
|
|
343
|
+
onError: function(cb) { return subscribe(listeners.error, cb); },
|
|
344
|
+
onThemeChange: function(cb) { return subscribe(listeners.themeChange, cb); },
|
|
345
|
+
onToolInputPartial: function(cb) { return subscribe(listeners.toolInputPartial, cb); },
|
|
346
|
+
onToolInput: function(cb) { return subscribe(listeners.toolInput, cb); },
|
|
347
|
+
onElicitation: function(h) { elicitationHandler = h; return function() { elicitationHandler = null; }; },
|
|
348
|
+
onTeardown: function(h) { teardownHandler = h; return function() { teardownHandler = null; }; },
|
|
349
|
+
|
|
350
|
+
updateModelContext: function(opts) {
|
|
351
|
+
var callId = generateCallId();
|
|
352
|
+
return new Promise(function(resolve, reject) {
|
|
353
|
+
pendingCalls[callId] = { resolve: resolve, reject: reject };
|
|
354
|
+
postToHost({
|
|
355
|
+
jsonrpc: '2.0',
|
|
356
|
+
id: callId,
|
|
357
|
+
method: 'ui/update-model-context',
|
|
358
|
+
params: { content: opts.content, structuredContent: opts.structuredContent }
|
|
359
|
+
});
|
|
360
|
+
setTimeout(function() {
|
|
361
|
+
if (pendingCalls[callId]) {
|
|
362
|
+
delete pendingCalls[callId];
|
|
363
|
+
reject(new Error('Model context update timeout'));
|
|
364
|
+
}
|
|
365
|
+
}, 10000);
|
|
366
|
+
});
|
|
367
|
+
},
|
|
368
|
+
|
|
369
|
+
get safeAreaInsets() {
|
|
370
|
+
return ctx.safeAreaInsets || { top: 0, bottom: 0, left: 0, right: 0 };
|
|
371
|
+
},
|
|
372
|
+
|
|
373
|
+
callTool: callTool,
|
|
374
|
+
invoke: callTool, // Alias for callTool - used by custom UI templates
|
|
375
|
+
sendFollowUpMessage: function(msg) {
|
|
376
|
+
postToHost({ type: 'photon:follow-up', message: msg });
|
|
377
|
+
},
|
|
378
|
+
|
|
379
|
+
get theme() { return ctx.theme; },
|
|
380
|
+
get locale() { return ctx.locale; },
|
|
381
|
+
get photon() { return ctx.photon; },
|
|
382
|
+
get method() { return ctx.method; },
|
|
383
|
+
get isChatGPT() { return typeof window.openai !== 'undefined'; }
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
387
|
+
// 2. WINDOW.OPENAI - ChatGPT Apps SDK Compatibility
|
|
388
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
389
|
+
|
|
390
|
+
window.openai = {
|
|
391
|
+
// Context properties (reactive via openai:set_globals)
|
|
392
|
+
get theme() { return ctx.theme; },
|
|
393
|
+
get displayMode() { return ctx.displayMode === 'fullscreen' ? 'fullscreen' : 'inline'; },
|
|
394
|
+
get locale() { return ctx.locale; },
|
|
395
|
+
get maxHeight() { return 600; },
|
|
396
|
+
get toolInput() { return toolInput; },
|
|
397
|
+
get toolOutput() { return toolOutput; },
|
|
398
|
+
get widgetState() { return widgetState; },
|
|
399
|
+
get toolResponseMetadata() { return {}; },
|
|
400
|
+
|
|
401
|
+
// Methods
|
|
402
|
+
setWidgetState: function(state) {
|
|
403
|
+
widgetState = state;
|
|
404
|
+
postToHost({ type: 'photon:set-state', state: state });
|
|
405
|
+
},
|
|
406
|
+
|
|
407
|
+
callTool: callTool,
|
|
408
|
+
|
|
409
|
+
sendFollowUpMessage: function(opts) {
|
|
410
|
+
postToHost({ type: 'photon:follow-up', message: opts.prompt });
|
|
411
|
+
return Promise.resolve();
|
|
412
|
+
},
|
|
413
|
+
|
|
414
|
+
uploadFile: function(file) {
|
|
415
|
+
var callId = generateCallId();
|
|
416
|
+
return new Promise(function(resolve, reject) {
|
|
417
|
+
pendingCalls[callId] = { resolve: resolve, reject: reject };
|
|
418
|
+
|
|
419
|
+
// Read file as base64
|
|
420
|
+
var reader = new FileReader();
|
|
421
|
+
reader.onload = function() {
|
|
422
|
+
var base64 = reader.result;
|
|
423
|
+
postToHost({
|
|
424
|
+
type: 'photon:upload-file',
|
|
425
|
+
callId: callId,
|
|
426
|
+
fileName: file.name,
|
|
427
|
+
fileType: file.type,
|
|
428
|
+
fileSize: file.size,
|
|
429
|
+
data: base64
|
|
430
|
+
});
|
|
431
|
+
};
|
|
432
|
+
reader.onerror = function() {
|
|
433
|
+
delete pendingCalls[callId];
|
|
434
|
+
reject(new Error('Failed to read file'));
|
|
435
|
+
};
|
|
436
|
+
reader.readAsDataURL(file);
|
|
437
|
+
|
|
438
|
+
// Timeout after 60s
|
|
439
|
+
setTimeout(function() {
|
|
440
|
+
if (pendingCalls[callId]) {
|
|
441
|
+
delete pendingCalls[callId];
|
|
442
|
+
reject(new Error('File upload timeout'));
|
|
443
|
+
}
|
|
444
|
+
}, 60000);
|
|
445
|
+
});
|
|
446
|
+
},
|
|
447
|
+
|
|
448
|
+
getFileDownloadUrl: function(opts) {
|
|
449
|
+
var callId = generateCallId();
|
|
450
|
+
return new Promise(function(resolve, reject) {
|
|
451
|
+
pendingCalls[callId] = { resolve: resolve, reject: reject };
|
|
452
|
+
|
|
453
|
+
postToHost({
|
|
454
|
+
type: 'photon:get-file-url',
|
|
455
|
+
callId: callId,
|
|
456
|
+
fileId: opts.fileId
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
// Timeout after 30s
|
|
460
|
+
setTimeout(function() {
|
|
461
|
+
if (pendingCalls[callId]) {
|
|
462
|
+
delete pendingCalls[callId];
|
|
463
|
+
reject(new Error('Get file URL timeout'));
|
|
464
|
+
}
|
|
465
|
+
}, 30000);
|
|
466
|
+
});
|
|
467
|
+
},
|
|
468
|
+
|
|
469
|
+
requestDisplayMode: function(mode) {
|
|
470
|
+
postToHost({ type: 'photon:request-display-mode', mode: mode });
|
|
471
|
+
return Promise.resolve();
|
|
472
|
+
},
|
|
473
|
+
|
|
474
|
+
requestModal: function(opts) {
|
|
475
|
+
var callId = generateCallId();
|
|
476
|
+
return new Promise(function(resolve, reject) {
|
|
477
|
+
pendingCalls[callId] = { resolve: resolve, reject: reject };
|
|
478
|
+
|
|
479
|
+
postToHost({
|
|
480
|
+
type: 'photon:request-modal',
|
|
481
|
+
callId: callId,
|
|
482
|
+
template: opts.template,
|
|
483
|
+
params: opts.params
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
// Timeout after 5 minutes (modals may take user input)
|
|
487
|
+
setTimeout(function() {
|
|
488
|
+
if (pendingCalls[callId]) {
|
|
489
|
+
delete pendingCalls[callId];
|
|
490
|
+
reject(new Error('Modal request timeout'));
|
|
491
|
+
}
|
|
492
|
+
}, 300000);
|
|
493
|
+
});
|
|
494
|
+
},
|
|
495
|
+
|
|
496
|
+
notifyIntrinsicHeight: function(height) {
|
|
497
|
+
postToHost({ type: 'photon:notify-height', height: height });
|
|
498
|
+
},
|
|
499
|
+
|
|
500
|
+
openExternal: function(opts) {
|
|
501
|
+
window.open(opts.href, '_blank', 'noopener,noreferrer');
|
|
502
|
+
},
|
|
503
|
+
|
|
504
|
+
setOpenInAppUrl: function(opts) {
|
|
505
|
+
postToHost({ type: 'photon:set-open-in-app-url', href: opts.href });
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
510
|
+
// 3. WINDOW.MCP - Generic MCP Bridge (superset)
|
|
511
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
512
|
+
|
|
513
|
+
window.mcp = {
|
|
514
|
+
// Inherits from photon
|
|
515
|
+
...window.photon,
|
|
516
|
+
|
|
517
|
+
// Additional MCP-specific context
|
|
518
|
+
get hostName() { return ctx.hostName; },
|
|
519
|
+
get hostVersion() { return ctx.hostVersion; },
|
|
520
|
+
|
|
521
|
+
// MCP Apps Extension methods
|
|
522
|
+
requestToolCall: callTool,
|
|
523
|
+
|
|
524
|
+
// Read a resource
|
|
525
|
+
readResource: function(uri) {
|
|
526
|
+
return callTool('resources/read', { uri: uri });
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
531
|
+
// 4. OPENAI GLOBAL HOOK - useOpenAiGlobal compatibility
|
|
532
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
533
|
+
|
|
534
|
+
// Dispatch custom event for useOpenAiGlobal hook subscribers
|
|
535
|
+
function dispatchGlobalsEvent() {
|
|
536
|
+
window.dispatchEvent(new CustomEvent('openai:set_globals', {
|
|
537
|
+
detail: {
|
|
538
|
+
theme: ctx.theme,
|
|
539
|
+
displayMode: ctx.displayMode,
|
|
540
|
+
locale: ctx.locale,
|
|
541
|
+
toolInput: toolInput,
|
|
542
|
+
toolOutput: toolOutput,
|
|
543
|
+
widgetState: widgetState
|
|
544
|
+
}
|
|
545
|
+
}));
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
549
|
+
// INITIALIZATION
|
|
550
|
+
// ══════════════════════════════════════════════════════════════════════════
|
|
551
|
+
|
|
552
|
+
// Apply initial theme
|
|
553
|
+
applyThemeTokens();
|
|
554
|
+
|
|
555
|
+
// Notify host that bridge is ready
|
|
556
|
+
postToHost({ type: 'photon:ready' });
|
|
557
|
+
|
|
558
|
+
// Request persisted state from host
|
|
559
|
+
postToHost({ type: 'photon:get-state' });
|
|
560
|
+
|
|
561
|
+
// Also send MCP Apps ready (JSON-RPC style)
|
|
562
|
+
postToHost({
|
|
563
|
+
jsonrpc: '2.0',
|
|
564
|
+
method: 'ui/ready',
|
|
565
|
+
params: {}
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
})();
|
|
569
|
+
</script>`;
|
|
570
|
+
}
|
|
571
|
+
// ════════════════════════════════════════════════════════════════════════════════
|
|
572
|
+
// HOST-SIDE HELPERS
|
|
573
|
+
// ════════════════════════════════════════════════════════════════════════════════
|
|
574
|
+
//# sourceMappingURL=platform-compat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-compat.js","sourceRoot":"","sources":["../../src/auto-ui/platform-compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,cAAc,EAAkB,MAAM,2BAA2B,CAAC;AAG3E,0DAA0D;AAC1D,OAAO,EAQL,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AA0C7B,mFAAmF;AACnF,mCAAmC;AACnC,mFAAmF;AAEnF;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,OAAwB;IACnE,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACpD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAE5C,OAAO;;;;;;;;;cASK,WAAW;sBACH,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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