@portel/photon 1.4.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +326 -1177
- package/dist/auto-ui/beam.d.ts +14 -0
- package/dist/auto-ui/beam.d.ts.map +1 -0
- package/dist/auto-ui/beam.js +3057 -0
- package/dist/auto-ui/beam.js.map +1 -0
- package/dist/auto-ui/bridge/index.d.ts +37 -0
- package/dist/auto-ui/bridge/index.d.ts.map +1 -0
- package/dist/auto-ui/bridge/index.js +555 -0
- package/dist/auto-ui/bridge/index.js.map +1 -0
- package/dist/auto-ui/bridge/openai-shim.d.ts +20 -0
- package/dist/auto-ui/bridge/openai-shim.d.ts.map +1 -0
- package/dist/auto-ui/bridge/openai-shim.js +231 -0
- package/dist/auto-ui/bridge/openai-shim.js.map +1 -0
- package/dist/auto-ui/bridge/photon-app.d.ts +162 -0
- package/dist/auto-ui/bridge/photon-app.d.ts.map +1 -0
- package/dist/auto-ui/bridge/photon-app.js +460 -0
- package/dist/auto-ui/bridge/photon-app.js.map +1 -0
- package/dist/auto-ui/bridge/types.d.ts +128 -0
- package/dist/auto-ui/bridge/types.d.ts.map +1 -0
- package/dist/auto-ui/bridge/types.js +7 -0
- package/dist/auto-ui/bridge/types.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 +23 -0
- package/dist/auto-ui/index.d.ts.map +1 -0
- package/dist/auto-ui/index.js +28 -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 +628 -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 +103 -0
- package/dist/auto-ui/streamable-http-transport.d.ts.map +1 -0
- package/dist/auto-ui/streamable-http-transport.js +1875 -0
- package/dist/auto-ui/streamable-http-transport.js.map +1 -0
- package/dist/auto-ui/types.d.ts +384 -0
- package/dist/auto-ui/types.d.ts.map +1 -0
- package/dist/auto-ui/types.js +92 -0
- package/dist/auto-ui/types.js.map +1 -0
- package/dist/beam.bundle.js +63137 -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 +1166 -1131
- package/dist/cli.js.map +1 -1
- package/dist/daemon/client.d.ts +84 -3
- package/dist/daemon/client.d.ts.map +1 -1
- package/dist/daemon/client.js +561 -11
- package/dist/daemon/client.js.map +1 -1
- package/dist/daemon/manager.d.ts +51 -12
- package/dist/daemon/manager.d.ts.map +1 -1
- package/dist/daemon/manager.js +122 -61
- package/dist/daemon/manager.js.map +1 -1
- package/dist/daemon/protocol.d.ts +62 -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 +743 -133
- 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 +191 -21
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +1186 -319
- 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 +204 -77
- package/dist/photon-cli-runner.js.map +1 -1
- package/dist/photon-doc-extractor.d.ts +89 -0
- package/dist/photon-doc-extractor.d.ts.map +1 -1
- package/dist/photon-doc-extractor.js +560 -32
- 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 +184 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1995 -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 +176 -87
- 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 +10 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +21 -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 +57 -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,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tenant Resolution Middleware
|
|
3
|
+
*
|
|
4
|
+
* Resolves tenant from request (subdomain, path, or custom domain)
|
|
5
|
+
* and attaches to request context
|
|
6
|
+
*/
|
|
7
|
+
import type { Tenant, RequestContext } from '../types/index.js';
|
|
8
|
+
export interface TenantStore {
|
|
9
|
+
/**
|
|
10
|
+
* Find tenant by slug
|
|
11
|
+
*/
|
|
12
|
+
findBySlug(slug: string): Promise<Tenant | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Find tenant by custom domain
|
|
15
|
+
*/
|
|
16
|
+
findByCustomDomain(domain: string): Promise<Tenant | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Find tenant by ID
|
|
19
|
+
*/
|
|
20
|
+
findById(id: string): Promise<Tenant | null>;
|
|
21
|
+
}
|
|
22
|
+
export declare class MemoryTenantStore implements TenantStore {
|
|
23
|
+
private tenants;
|
|
24
|
+
private slugIndex;
|
|
25
|
+
private domainIndex;
|
|
26
|
+
/**
|
|
27
|
+
* Add a tenant to the store
|
|
28
|
+
*/
|
|
29
|
+
add(tenant: Tenant): void;
|
|
30
|
+
findBySlug(slug: string): Promise<Tenant | null>;
|
|
31
|
+
findByCustomDomain(domain: string): Promise<Tenant | null>;
|
|
32
|
+
findById(id: string): Promise<Tenant | null>;
|
|
33
|
+
}
|
|
34
|
+
export interface TenantResolverConfig {
|
|
35
|
+
/** Base domain for subdomain resolution (e.g., 'serv.example.com') */
|
|
36
|
+
baseDomain: string;
|
|
37
|
+
/** Tenant store implementation */
|
|
38
|
+
store: TenantStore;
|
|
39
|
+
/** Path prefix for path-based tenant resolution */
|
|
40
|
+
pathPrefix?: string;
|
|
41
|
+
}
|
|
42
|
+
export declare class TenantResolver {
|
|
43
|
+
private config;
|
|
44
|
+
constructor(config: TenantResolverConfig);
|
|
45
|
+
/**
|
|
46
|
+
* Resolve tenant from HTTP request
|
|
47
|
+
*/
|
|
48
|
+
resolve(request: {
|
|
49
|
+
host?: string;
|
|
50
|
+
url?: string;
|
|
51
|
+
headers?: {
|
|
52
|
+
host?: string;
|
|
53
|
+
};
|
|
54
|
+
}): Promise<Tenant | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Extract subdomain from host
|
|
57
|
+
*/
|
|
58
|
+
private extractSubdomain;
|
|
59
|
+
/**
|
|
60
|
+
* Extract tenant slug from URL path
|
|
61
|
+
*/
|
|
62
|
+
private extractPathSlug;
|
|
63
|
+
}
|
|
64
|
+
export interface ContextBuilderConfig {
|
|
65
|
+
tenantResolver: TenantResolver;
|
|
66
|
+
}
|
|
67
|
+
export declare class RequestContextBuilder {
|
|
68
|
+
private tenantResolver;
|
|
69
|
+
constructor(config: ContextBuilderConfig);
|
|
70
|
+
/**
|
|
71
|
+
* Build request context from HTTP request
|
|
72
|
+
*/
|
|
73
|
+
build(request: {
|
|
74
|
+
host?: string;
|
|
75
|
+
url?: string;
|
|
76
|
+
headers?: {
|
|
77
|
+
host?: string;
|
|
78
|
+
authorization?: string;
|
|
79
|
+
};
|
|
80
|
+
}): Promise<RequestContext | null>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Extract tenant slug from URL for routing
|
|
84
|
+
*/
|
|
85
|
+
export declare function extractTenantSlug(url: string, pathPrefix?: string): string | null;
|
|
86
|
+
/**
|
|
87
|
+
* Build tenant-specific URL
|
|
88
|
+
*/
|
|
89
|
+
export declare function buildTenantUrl(baseUrl: string, tenant: Tenant, path: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* Build resource URI for OAuth audience
|
|
92
|
+
*/
|
|
93
|
+
export declare function buildResourceUri(baseUrl: string, tenant: Tenant): string;
|
|
94
|
+
//# sourceMappingURL=tenant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant.d.ts","sourceRoot":"","sources":["../../../src/serv/middleware/tenant.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAMhE,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAEjD;;OAEG;IACH,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAE3D;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC9C;AAMD,qBAAa,iBAAkB,YAAW,WAAW;IACnD,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,SAAS,CAAkC;IACnD,OAAO,CAAC,WAAW,CAAkC;IAErD;;OAEG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQnB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO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GAAG,EAAE,MAAM,EAAE,UAAU,SAAa,GAAG,MAAM,GAAG,IAAI,CAQrF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAKpF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAExE"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tenant Resolution Middleware
|
|
3
|
+
*
|
|
4
|
+
* Resolves tenant from request (subdomain, path, or custom domain)
|
|
5
|
+
* and attaches to request context
|
|
6
|
+
*/
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// In-Memory Tenant Store (Development)
|
|
9
|
+
// ============================================================================
|
|
10
|
+
export class MemoryTenantStore {
|
|
11
|
+
tenants = new Map();
|
|
12
|
+
slugIndex = new Map();
|
|
13
|
+
domainIndex = new Map();
|
|
14
|
+
/**
|
|
15
|
+
* Add a tenant to the store
|
|
16
|
+
*/
|
|
17
|
+
add(tenant) {
|
|
18
|
+
this.tenants.set(tenant.id, tenant);
|
|
19
|
+
this.slugIndex.set(tenant.slug, tenant.id);
|
|
20
|
+
if (tenant.settings.customDomain) {
|
|
21
|
+
this.domainIndex.set(tenant.settings.customDomain, tenant.id);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async findBySlug(slug) {
|
|
25
|
+
const id = this.slugIndex.get(slug);
|
|
26
|
+
if (!id)
|
|
27
|
+
return null;
|
|
28
|
+
return this.tenants.get(id) ?? null;
|
|
29
|
+
}
|
|
30
|
+
async findByCustomDomain(domain) {
|
|
31
|
+
const id = this.domainIndex.get(domain);
|
|
32
|
+
if (!id)
|
|
33
|
+
return null;
|
|
34
|
+
return this.tenants.get(id) ?? null;
|
|
35
|
+
}
|
|
36
|
+
async findById(id) {
|
|
37
|
+
return this.tenants.get(id) ?? null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export class TenantResolver {
|
|
41
|
+
config;
|
|
42
|
+
constructor(config) {
|
|
43
|
+
this.config = {
|
|
44
|
+
pathPrefix: '/tenant/',
|
|
45
|
+
...config,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolve tenant from HTTP request
|
|
50
|
+
*/
|
|
51
|
+
async resolve(request) {
|
|
52
|
+
const host = request.host ?? request.headers?.host ?? '';
|
|
53
|
+
const url = request.url ?? '';
|
|
54
|
+
// 1. Try subdomain resolution (acme.serv.example.com)
|
|
55
|
+
const subdomain = this.extractSubdomain(host);
|
|
56
|
+
if (subdomain) {
|
|
57
|
+
const tenant = await this.config.store.findBySlug(subdomain);
|
|
58
|
+
if (tenant)
|
|
59
|
+
return tenant;
|
|
60
|
+
}
|
|
61
|
+
// 2. Try path-based resolution (/tenant/acme/...)
|
|
62
|
+
const pathSlug = this.extractPathSlug(url);
|
|
63
|
+
if (pathSlug) {
|
|
64
|
+
const tenant = await this.config.store.findBySlug(pathSlug);
|
|
65
|
+
if (tenant)
|
|
66
|
+
return tenant;
|
|
67
|
+
}
|
|
68
|
+
// 3. Try custom domain resolution
|
|
69
|
+
const tenant = await this.config.store.findByCustomDomain(host);
|
|
70
|
+
if (tenant)
|
|
71
|
+
return tenant;
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Extract subdomain from host
|
|
76
|
+
*/
|
|
77
|
+
extractSubdomain(host) {
|
|
78
|
+
// Remove port if present
|
|
79
|
+
const hostWithoutPort = host.split(':')[0];
|
|
80
|
+
// Check if it's a subdomain of our base domain
|
|
81
|
+
if (!hostWithoutPort.endsWith(`.${this.config.baseDomain}`)) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
// Extract subdomain
|
|
85
|
+
const subdomain = hostWithoutPort.slice(0, hostWithoutPort.length - this.config.baseDomain.length - 1);
|
|
86
|
+
// Validate: must be single-level and not empty
|
|
87
|
+
if (!subdomain || subdomain.includes('.')) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return subdomain;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Extract tenant slug from URL path
|
|
94
|
+
*/
|
|
95
|
+
extractPathSlug(url) {
|
|
96
|
+
const prefix = this.config.pathPrefix;
|
|
97
|
+
const pathStart = url.indexOf(prefix);
|
|
98
|
+
if (pathStart === -1)
|
|
99
|
+
return null;
|
|
100
|
+
const afterPrefix = url.slice(pathStart + prefix.length);
|
|
101
|
+
const slug = afterPrefix.split('/')[0];
|
|
102
|
+
return slug || null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export class RequestContextBuilder {
|
|
106
|
+
tenantResolver;
|
|
107
|
+
constructor(config) {
|
|
108
|
+
this.tenantResolver = config.tenantResolver;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Build request context from HTTP request
|
|
112
|
+
*/
|
|
113
|
+
async build(request) {
|
|
114
|
+
const tenant = await this.tenantResolver.resolve(request);
|
|
115
|
+
if (!tenant)
|
|
116
|
+
return null;
|
|
117
|
+
return {
|
|
118
|
+
tenant,
|
|
119
|
+
// Session and user are added by auth middleware
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// ============================================================================
|
|
124
|
+
// HTTP Middleware Helpers
|
|
125
|
+
// ============================================================================
|
|
126
|
+
/**
|
|
127
|
+
* Extract tenant slug from URL for routing
|
|
128
|
+
*/
|
|
129
|
+
export function extractTenantSlug(url, pathPrefix = '/tenant/') {
|
|
130
|
+
const pathStart = url.indexOf(pathPrefix);
|
|
131
|
+
if (pathStart === -1)
|
|
132
|
+
return null;
|
|
133
|
+
const afterPrefix = url.slice(pathStart + pathPrefix.length);
|
|
134
|
+
const slug = afterPrefix.split('/')[0];
|
|
135
|
+
return slug || null;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Build tenant-specific URL
|
|
139
|
+
*/
|
|
140
|
+
export function buildTenantUrl(baseUrl, tenant, path) {
|
|
141
|
+
if (tenant.settings.customDomain) {
|
|
142
|
+
return `https://${tenant.settings.customDomain}${path}`;
|
|
143
|
+
}
|
|
144
|
+
return `${baseUrl}/tenant/${tenant.slug}${path}`;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Build resource URI for OAuth audience
|
|
148
|
+
*/
|
|
149
|
+
export function buildResourceUri(baseUrl, tenant) {
|
|
150
|
+
return buildTenantUrl(baseUrl, tenant, '/mcp');
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=tenant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant.js","sourceRoot":"","sources":["../../../src/serv/middleware/tenant.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyBH,+EAA+E;AAC/E,uCAAuC;AACvC,+EAA+E;AAE/E,MAAM,OAAO,iBAAiB;IACpB,OAAO,GAAwB,IAAI,GAAG,EAAE,CAAC;IACzC,SAAS,GAAwB,IAAI,GAAG,EAAE,CAAC;IAC3C,WAAW,GAAwB,IAAI,GAAG,EAAE,CAAC;IAErD;;OAEG;IACH,GAAG,CAAC,MAAc;QAChB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;QAC3C,IAAI,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;YACjC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,IAAY;QAC3B,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,G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AAO,WAAW,MAAM,CAAC,QAAQ,CAAC,YAAY,GAAG,IAAI,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO,GAAG,OAAO,WAAW,MAAM,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe,EAAE,MAAc;IAC9D,OAAO,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SERV Photon Executor
|
|
3
|
+
*
|
|
4
|
+
* Executes photons with SERV context (session, OAuth, tenant isolation).
|
|
5
|
+
* Wraps the PhotonLoader with SERV-specific input/output handling.
|
|
6
|
+
*/
|
|
7
|
+
import type { Session, Tenant } from '../types/index.js';
|
|
8
|
+
import type { OAuthFlowHandler } from '../auth/oauth.js';
|
|
9
|
+
import type { TokenVault } from '../vault/token-vault.js';
|
|
10
|
+
import { OAuthContext, OAuthElicitationRequired, type OAuthAsk } from './oauth-context.js';
|
|
11
|
+
export interface ExecutorConfig {
|
|
12
|
+
oauthFlow: OAuthFlowHandler;
|
|
13
|
+
tokenVault: TokenVault;
|
|
14
|
+
}
|
|
15
|
+
export interface ExecutionContext {
|
|
16
|
+
session: Session;
|
|
17
|
+
tenant: Tenant;
|
|
18
|
+
photonId: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ExecutionResult {
|
|
21
|
+
success: boolean;
|
|
22
|
+
result?: unknown;
|
|
23
|
+
error?: {
|
|
24
|
+
code: string;
|
|
25
|
+
message: string;
|
|
26
|
+
data?: unknown;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* SERV Photon Executor
|
|
31
|
+
*
|
|
32
|
+
* Provides a SERV-aware execution environment for photons:
|
|
33
|
+
* - OAuth token management via yields
|
|
34
|
+
* - Session-scoped execution
|
|
35
|
+
* - Tenant isolation
|
|
36
|
+
*/
|
|
37
|
+
export declare class PhotonExecutor {
|
|
38
|
+
private config;
|
|
39
|
+
constructor(config: ExecutorConfig);
|
|
40
|
+
/**
|
|
41
|
+
* Create an OAuth context for a photon execution
|
|
42
|
+
*/
|
|
43
|
+
createOAuthContext(context: ExecutionContext): OAuthContext;
|
|
44
|
+
/**
|
|
45
|
+
* Create an input provider with OAuth support
|
|
46
|
+
*
|
|
47
|
+
* @param context - Execution context
|
|
48
|
+
* @param fallbackProvider - Provider for non-OAuth asks
|
|
49
|
+
*/
|
|
50
|
+
createInputProvider(context: ExecutionContext, fallbackProvider?: (ask: Record<string, unknown>) => Promise<unknown>): (ask: OAuthAsk | Record<string, unknown>) => Promise<unknown>;
|
|
51
|
+
/**
|
|
52
|
+
* Format an error for MCP response
|
|
53
|
+
*/
|
|
54
|
+
formatError(error: unknown): ExecutionResult;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Check if an error is an OAuth elicitation request
|
|
58
|
+
*/
|
|
59
|
+
export declare function isOAuthElicitationError(error: unknown): error is OAuthElicitationRequired;
|
|
60
|
+
/**
|
|
61
|
+
* Format OAuth elicitation error for MCP tool response
|
|
62
|
+
*
|
|
63
|
+
* Returns a structured error that MCP clients can understand
|
|
64
|
+
* and potentially auto-handle (e.g., opening auth URL in browser).
|
|
65
|
+
*/
|
|
66
|
+
export declare function formatElicitationToolResponse(error: OAuthElicitationRequired): {
|
|
67
|
+
content: Array<{
|
|
68
|
+
type: 'text';
|
|
69
|
+
text: string;
|
|
70
|
+
annotations?: {
|
|
71
|
+
mimeType?: string;
|
|
72
|
+
};
|
|
73
|
+
}>;
|
|
74
|
+
isError: boolean;
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/serv/runtime/executor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EA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C,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,wBAAwB,CAEzF;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,wBAAwB,GAAG;IAC9E,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE;YAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KACrC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,CAAC;CAClB,CAwBA"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SERV Photon Executor
|
|
3
|
+
*
|
|
4
|
+
* Executes photons with SERV context (session, OAuth, tenant isolation).
|
|
5
|
+
* Wraps the PhotonLoader with SERV-specific input/output handling.
|
|
6
|
+
*/
|
|
7
|
+
import { OAuthContext, OAuthElicitationRequired, createOAuthInputProvider, } from './oauth-context.js';
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Photon Executor
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* SERV Photon Executor
|
|
13
|
+
*
|
|
14
|
+
* Provides a SERV-aware execution environment for photons:
|
|
15
|
+
* - OAuth token management via yields
|
|
16
|
+
* - Session-scoped execution
|
|
17
|
+
* - Tenant isolation
|
|
18
|
+
*/
|
|
19
|
+
export class PhotonExecutor {
|
|
20
|
+
config;
|
|
21
|
+
constructor(config) {
|
|
22
|
+
this.config = config;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create an OAuth context for a photon execution
|
|
26
|
+
*/
|
|
27
|
+
createOAuthContext(context) {
|
|
28
|
+
return new OAuthContext({
|
|
29
|
+
session: context.session,
|
|
30
|
+
photonId: context.photonId,
|
|
31
|
+
tenantId: context.tenant.id,
|
|
32
|
+
oauthFlow: this.config.oauthFlow,
|
|
33
|
+
tokenVault: this.config.tokenVault,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create an input provider with OAuth support
|
|
38
|
+
*
|
|
39
|
+
* @param context - Execution context
|
|
40
|
+
* @param fallbackProvider - Provider for non-OAuth asks
|
|
41
|
+
*/
|
|
42
|
+
createInputProvider(context, fallbackProvider) {
|
|
43
|
+
const oauthContext = this.createOAuthContext(context);
|
|
44
|
+
return createOAuthInputProvider(oauthContext, fallbackProvider);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Format an error for MCP response
|
|
48
|
+
*/
|
|
49
|
+
formatError(error) {
|
|
50
|
+
if (error instanceof OAuthElicitationRequired) {
|
|
51
|
+
return {
|
|
52
|
+
success: false,
|
|
53
|
+
error: error.toMCPError().error,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
57
|
+
return {
|
|
58
|
+
success: false,
|
|
59
|
+
error: {
|
|
60
|
+
code: 'EXECUTION_ERROR',
|
|
61
|
+
message,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// ============================================================================
|
|
67
|
+
// Helper Functions
|
|
68
|
+
// ============================================================================
|
|
69
|
+
/**
|
|
70
|
+
* Check if an error is an OAuth elicitation request
|
|
71
|
+
*/
|
|
72
|
+
export function isOAuthElicitationError(error) {
|
|
73
|
+
return error instanceof OAuthElicitationRequired;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Format OAuth elicitation error for MCP tool response
|
|
77
|
+
*
|
|
78
|
+
* Returns a structured error that MCP clients can understand
|
|
79
|
+
* and potentially auto-handle (e.g., opening auth URL in browser).
|
|
80
|
+
*/
|
|
81
|
+
export function formatElicitationToolResponse(error) {
|
|
82
|
+
const elicitationInfo = {
|
|
83
|
+
type: 'oauth_elicitation',
|
|
84
|
+
provider: error.provider,
|
|
85
|
+
scopes: error.scopes,
|
|
86
|
+
url: error.elicitationUrl,
|
|
87
|
+
id: error.elicitationId,
|
|
88
|
+
message: error.message,
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
content: [
|
|
92
|
+
{
|
|
93
|
+
type: 'text',
|
|
94
|
+
text: JSON.stringify(elicitationInfo, null, 2),
|
|
95
|
+
annotations: { mimeType: 'application/json' },
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
type: 'text',
|
|
99
|
+
text: `\n\n---\n🔐 **Authorization Required**\n\nThis tool needs access to ${error.provider}.\n\nPlease visit this URL to authorize:\n${error.elicitationUrl}\n\nAfter authorization, retry the tool request.`,
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
isError: true,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/serv/runtime/executor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EACL,YAAY,EACZ,wBAAwB,EACxB,wBAAwB,GAEzB,MAAM,oBAAoB,CAAC;AA2B5B,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IACjB,MAAM,CAAiB;IAE/B,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,kBAAkB,CAAC,OAAyB;QAC1C,OAAO,IAAI,YAAY,CAAC;YACtB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE;YAC3B,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;YAChC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;SACnC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,mBAAmB,CACjB,OAAyB,EACzB,gBAAqE;QAErE,MAAM,Y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,EAAE,MAAM;gBACZ,IAAI,EAAE,uEAAuE,KAAK,CAAC,QAAQ,6CAA6C,KAAK,CAAC,cAAc,kDAAkD;aAC/M;SACF;QACD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SERV Runtime Module
|
|
3
|
+
*
|
|
4
|
+
* Provides execution context for photons running in SERV.
|
|
5
|
+
*/
|
|
6
|
+
export { OAuthContext, OAuthElicitationRequired, createOAuthInputProvider, type OAuthAsk, type OAuthResponse, type OAuthContextConfig, type OAuthInputProvider, } from './oauth-context.js';
|
|
7
|
+
export { PhotonExecutor, isOAuthElicitationError, formatElicitationToolResponse, type ExecutorConfig, type ExecutionContext, type ExecutionResult, } from './executor.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/serv/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,YAAY,EACZ,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,6BAA6B,EAC7B,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SERV Runtime Module
|
|
3
|
+
*
|
|
4
|
+
* Provides execution context for photons running in SERV.
|
|
5
|
+
*/
|
|
6
|
+
// OAuth Context
|
|
7
|
+
export { OAuthContext, OAuthElicitationRequired, createOAuthInputProvider, } from './oauth-context.js';
|
|
8
|
+
// Executor
|
|
9
|
+
export { PhotonExecutor, isOAuthElicitationError, formatElicitationToolResponse, } from './executor.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/serv/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,gBAAgB;AAChB,OAAO,EACL,YAAY,EACZ,wBAAwB,EACxB,wBAAwB,GAKzB,MAAM,oBAAoB,CAAC;AAE5B,WAAW;AACX,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,6BAA6B,GAI9B,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Runtime Context for SERV
|
|
3
|
+
*
|
|
4
|
+
* Provides OAuth token access within photon execution context.
|
|
5
|
+
* Enables photons to request OAuth tokens via yield-based elicitation.
|
|
6
|
+
*/
|
|
7
|
+
import type { Session } from '../types/index.js';
|
|
8
|
+
import type { TokenVault } from '../vault/token-vault.js';
|
|
9
|
+
import type { OAuthFlowHandler } from '../auth/oauth.js';
|
|
10
|
+
/**
|
|
11
|
+
* OAuth token request yield
|
|
12
|
+
* When a photon needs an OAuth token, it yields this
|
|
13
|
+
*/
|
|
14
|
+
export interface OAuthAsk {
|
|
15
|
+
ask: 'oauth';
|
|
16
|
+
/** OAuth provider ID (e.g., 'google', 'github') */
|
|
17
|
+
provider: string;
|
|
18
|
+
/** Required OAuth scopes */
|
|
19
|
+
scopes: string[];
|
|
20
|
+
/** Human-readable message explaining why auth is needed */
|
|
21
|
+
message?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* OAuth ask response - either a token or an elicitation request
|
|
25
|
+
*/
|
|
26
|
+
export interface OAuthResponse {
|
|
27
|
+
/** Whether the token is available */
|
|
28
|
+
success: boolean;
|
|
29
|
+
/** The access token (if available) */
|
|
30
|
+
token?: string;
|
|
31
|
+
/** Elicitation required - redirect user to this URL */
|
|
32
|
+
elicitationUrl?: string;
|
|
33
|
+
/** Elicitation ID for tracking */
|
|
34
|
+
elicitationId?: string;
|
|
35
|
+
/** Error message if something went wrong */
|
|
36
|
+
error?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* MCP Elicitation Error
|
|
40
|
+
*
|
|
41
|
+
* When a photon needs user authorization, this error is returned
|
|
42
|
+
* following the MCP elicitation protocol.
|
|
43
|
+
*/
|
|
44
|
+
export declare class OAuthElicitationRequired extends Error {
|
|
45
|
+
readonly code = "OAUTH_ELICITATION_REQUIRED";
|
|
46
|
+
readonly elicitationUrl: string;
|
|
47
|
+
readonly elicitationId: string;
|
|
48
|
+
readonly provider: string;
|
|
49
|
+
readonly scopes: string[];
|
|
50
|
+
constructor(options: {
|
|
51
|
+
elicitationUrl: string;
|
|
52
|
+
elicitationId: string;
|
|
53
|
+
provider: string;
|
|
54
|
+
scopes: string[];
|
|
55
|
+
message?: string;
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Convert to MCP error response format
|
|
59
|
+
*/
|
|
60
|
+
toMCPError(): {
|
|
61
|
+
error: {
|
|
62
|
+
code: string;
|
|
63
|
+
message: string;
|
|
64
|
+
data: {
|
|
65
|
+
elicitation: {
|
|
66
|
+
type: 'oauth';
|
|
67
|
+
url: string;
|
|
68
|
+
id: string;
|
|
69
|
+
provider: string;
|
|
70
|
+
scopes: string[];
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export interface OAuthContextConfig {
|
|
77
|
+
session: Session;
|
|
78
|
+
photonId: string;
|
|
79
|
+
tenantId: string;
|
|
80
|
+
oauthFlow: OAuthFlowHandler;
|
|
81
|
+
tokenVault: TokenVault;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* OAuth context for photon execution
|
|
85
|
+
*
|
|
86
|
+
* Provides a way for photons to request OAuth tokens during execution.
|
|
87
|
+
* Integrates with SERV's OAuth flow handler to manage grants and elicitations.
|
|
88
|
+
*/
|
|
89
|
+
export declare class OAuthContext {
|
|
90
|
+
private session;
|
|
91
|
+
private photonId;
|
|
92
|
+
private tenantId;
|
|
93
|
+
private oauthFlow;
|
|
94
|
+
private tokenVault;
|
|
95
|
+
constructor(config: OAuthContextConfig);
|
|
96
|
+
/**
|
|
97
|
+
* Request an OAuth token
|
|
98
|
+
*
|
|
99
|
+
* @param provider - OAuth provider ID
|
|
100
|
+
* @param scopes - Required scopes
|
|
101
|
+
* @returns Token if available, or throws OAuthElicitationRequired
|
|
102
|
+
*/
|
|
103
|
+
requestToken(provider: string, scopes: string[]): Promise<string>;
|
|
104
|
+
/**
|
|
105
|
+
* Handle an OAuth ask yield
|
|
106
|
+
*
|
|
107
|
+
* @param ask - The OAuth ask yield from the photon
|
|
108
|
+
* @returns OAuth response
|
|
109
|
+
*/
|
|
110
|
+
handleOAuthAsk(ask: OAuthAsk): Promise<OAuthResponse>;
|
|
111
|
+
}
|
|
112
|
+
export type OAuthInputProvider = (ask: OAuthAsk | Record<string, unknown>) => Promise<unknown>;
|
|
113
|
+
/**
|
|
114
|
+
* Create an input provider that handles OAuth asks
|
|
115
|
+
*
|
|
116
|
+
* Wraps the standard input provider to add OAuth token handling.
|
|
117
|
+
* When an 'oauth' ask is received, it checks for existing grants
|
|
118
|
+
* or initiates an elicitation flow.
|
|
119
|
+
*/
|
|
120
|
+
export declare function createOAuthInputProvider(oauthContext: OAuthContext, fallbackProvider?: (ask: Record<string, unknown>) => Promise<unknown>): OAuthInputProvider;
|
|
121
|
+
//# sourceMappingURL=oauth-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-context.d.ts","sourceRoot":"","sources":["../../../src/serv/runtime/oauth-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EA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