@ixo/oracle-runtime 0.0.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/dist/bootstrap/ambient-factory.d.ts +32 -0
- package/dist/bootstrap/ambient-factory.d.ts.map +1 -0
- package/dist/bootstrap/ambient-factory.js +128 -0
- package/dist/bootstrap/create-oracle-app.d.ts +112 -0
- package/dist/bootstrap/create-oracle-app.d.ts.map +1 -0
- package/dist/bootstrap/create-oracle-app.js +530 -0
- package/dist/bootstrap/graceful-shutdown.d.ts +20 -0
- package/dist/bootstrap/graceful-shutdown.d.ts.map +1 -0
- package/dist/bootstrap/graceful-shutdown.js +61 -0
- package/dist/bootstrap/index.d.ts +13 -0
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/bootstrap/index.js +6 -0
- package/dist/bootstrap/inspect.d.ts +74 -0
- package/dist/bootstrap/inspect.d.ts.map +1 -0
- package/dist/bootstrap/inspect.js +111 -0
- package/dist/bootstrap/plugin-loader.d.ts +50 -0
- package/dist/bootstrap/plugin-loader.d.ts.map +1 -0
- package/dist/bootstrap/plugin-loader.js +119 -0
- package/dist/bootstrap/runtime-app-module.d.ts +38 -0
- package/dist/bootstrap/runtime-app-module.d.ts.map +1 -0
- package/dist/bootstrap/runtime-app-module.js +114 -0
- package/dist/bootstrap/schema-composer.d.ts +46 -0
- package/dist/bootstrap/schema-composer.d.ts.map +1 -0
- package/dist/bootstrap/schema-composer.js +65 -0
- package/dist/config/base-env-config.d.ts +31 -0
- package/dist/config/base-env-config.d.ts.map +1 -0
- package/dist/config/base-env-config.js +70 -0
- package/dist/config/base-env-schema.d.ts +77 -0
- package/dist/config/base-env-schema.d.ts.map +1 -0
- package/dist/config/base-env-schema.js +102 -0
- package/dist/events/scoped-emitter.d.ts +33 -0
- package/dist/events/scoped-emitter.d.ts.map +1 -0
- package/dist/events/scoped-emitter.js +32 -0
- package/dist/graph/index.d.ts +8 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +6 -0
- package/dist/graph/main-agent-types.d.ts +88 -0
- package/dist/graph/main-agent-types.d.ts.map +1 -0
- package/dist/graph/main-agent-types.js +20 -0
- package/dist/graph/main-agent.d.ts +16 -0
- package/dist/graph/main-agent.d.ts.map +1 -0
- package/dist/graph/main-agent.js +251 -0
- package/dist/graph/middlewares/capability-gate-middleware.d.ts +35 -0
- package/dist/graph/middlewares/capability-gate-middleware.d.ts.map +1 -0
- package/dist/graph/middlewares/capability-gate-middleware.js +54 -0
- package/dist/graph/middlewares/index.d.ts +7 -0
- package/dist/graph/middlewares/index.d.ts.map +1 -0
- package/dist/graph/middlewares/index.js +6 -0
- package/dist/graph/middlewares/page-context-middleware.d.ts +23 -0
- package/dist/graph/middlewares/page-context-middleware.d.ts.map +1 -0
- package/dist/graph/middlewares/page-context-middleware.js +68 -0
- package/dist/graph/middlewares/safety-guardrail-middleware.d.ts +26 -0
- package/dist/graph/middlewares/safety-guardrail-middleware.d.ts.map +1 -0
- package/dist/graph/middlewares/safety-guardrail-middleware.js +88 -0
- package/dist/graph/middlewares/summarization-middleware.d.ts +17 -0
- package/dist/graph/middlewares/summarization-middleware.d.ts.map +1 -0
- package/dist/graph/middlewares/summarization-middleware.js +62 -0
- package/dist/graph/middlewares/tool-repetition-guard-middleware.d.ts +24 -0
- package/dist/graph/middlewares/tool-repetition-guard-middleware.d.ts.map +1 -0
- package/dist/graph/middlewares/tool-repetition-guard-middleware.js +112 -0
- package/dist/graph/middlewares/tool-validation-middleware.d.ts +24 -0
- package/dist/graph/middlewares/tool-validation-middleware.d.ts.map +1 -0
- package/dist/graph/middlewares/tool-validation-middleware.js +61 -0
- package/dist/graph/prompt-composer.d.ts +69 -0
- package/dist/graph/prompt-composer.d.ts.map +1 -0
- package/dist/graph/prompt-composer.js +315 -0
- package/dist/graph/state.d.ts +65 -0
- package/dist/graph/state.d.ts.map +1 -0
- package/dist/graph/state.js +60 -0
- package/dist/graph/sub-agent-fallback.d.ts +56 -0
- package/dist/graph/sub-agent-fallback.d.ts.map +1 -0
- package/dist/graph/sub-agent-fallback.js +79 -0
- package/dist/graph/subagent-as-tool.d.ts +77 -0
- package/dist/graph/subagent-as-tool.d.ts.map +1 -0
- package/dist/graph/subagent-as-tool.js +197 -0
- package/dist/graph/wrap-plugin-tool.d.ts +28 -0
- package/dist/graph/wrap-plugin-tool.d.ts.map +1 -0
- package/dist/graph/wrap-plugin-tool.js +30 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/llm/index.d.ts +2 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +1 -0
- package/dist/llm/llm-provider.d.ts +41 -0
- package/dist/llm/llm-provider.d.ts.map +1 -0
- package/dist/llm/llm-provider.js +130 -0
- package/dist/manifest/index.d.ts +6 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +3 -0
- package/dist/manifest/schema.d.ts +31 -0
- package/dist/manifest/schema.d.ts.map +1 -0
- package/dist/manifest/schema.js +44 -0
- package/dist/manifest/tier1-renderer.d.ts +31 -0
- package/dist/manifest/tier1-renderer.d.ts.map +1 -0
- package/dist/manifest/tier1-renderer.js +68 -0
- package/dist/manifest/validator.d.ts +34 -0
- package/dist/manifest/validator.d.ts.map +1 -0
- package/dist/manifest/validator.js +111 -0
- package/dist/matrix/checkpointer/matrix-upload-utils.d.ts +66 -0
- package/dist/matrix/checkpointer/matrix-upload-utils.d.ts.map +1 -0
- package/dist/matrix/checkpointer/matrix-upload-utils.js +228 -0
- package/dist/matrix/checkpointer/type.d.ts +4 -0
- package/dist/matrix/checkpointer/type.d.ts.map +1 -0
- package/dist/matrix/checkpointer/type.js +1 -0
- package/dist/matrix/checkpointer/user-matrix-sqlite-sync-service.module.d.ts +3 -0
- package/dist/matrix/checkpointer/user-matrix-sqlite-sync-service.module.d.ts.map +1 -0
- package/dist/matrix/checkpointer/user-matrix-sqlite-sync-service.module.js +22 -0
- package/dist/matrix/checkpointer/user-matrix-sqlite-sync-service.service.d.ts +93 -0
- package/dist/matrix/checkpointer/user-matrix-sqlite-sync-service.service.d.ts.map +1 -0
- package/dist/matrix/checkpointer/user-matrix-sqlite-sync-service.service.js +856 -0
- package/dist/matrix/room-membership.d.ts +11 -0
- package/dist/matrix/room-membership.d.ts.map +1 -0
- package/dist/matrix/room-membership.js +33 -0
- package/dist/meta-tools/index.d.ts +28 -0
- package/dist/meta-tools/index.d.ts.map +1 -0
- package/dist/meta-tools/index.js +24 -0
- package/dist/meta-tools/list-capabilities.d.ts +12 -0
- package/dist/meta-tools/list-capabilities.d.ts.map +1 -0
- package/dist/meta-tools/list-capabilities.js +55 -0
- package/dist/meta-tools/load-capability.d.ts +24 -0
- package/dist/meta-tools/load-capability.d.ts.map +1 -0
- package/dist/meta-tools/load-capability.js +82 -0
- package/dist/modules/auth/auth-header.middleware.d.ts +37 -0
- package/dist/modules/auth/auth-header.middleware.d.ts.map +1 -0
- package/dist/modules/auth/auth-header.middleware.js +115 -0
- package/dist/modules/auth/auth.module.d.ts +9 -0
- package/dist/modules/auth/auth.module.d.ts.map +1 -0
- package/dist/modules/auth/auth.module.js +27 -0
- package/dist/modules/auth/index.d.ts +3 -0
- package/dist/modules/auth/index.d.ts.map +1 -0
- package/dist/modules/auth/index.js +2 -0
- package/dist/modules/auth/validate-ucan-delegation.d.ts +31 -0
- package/dist/modules/auth/validate-ucan-delegation.d.ts.map +1 -0
- package/dist/modules/auth/validate-ucan-delegation.js +36 -0
- package/dist/modules/blob-store/blob-store.module.d.ts +10 -0
- package/dist/modules/blob-store/blob-store.module.d.ts.map +1 -0
- package/dist/modules/blob-store/blob-store.module.js +25 -0
- package/dist/modules/blob-store/blob-store.service.d.ts +66 -0
- package/dist/modules/blob-store/blob-store.service.d.ts.map +1 -0
- package/dist/modules/blob-store/blob-store.service.js +108 -0
- package/dist/modules/blob-store/index.d.ts +3 -0
- package/dist/modules/blob-store/index.d.ts.map +1 -0
- package/dist/modules/blob-store/index.js +2 -0
- package/dist/modules/health/health.controller.d.ts +18 -0
- package/dist/modules/health/health.controller.d.ts.map +1 -0
- package/dist/modules/health/health.controller.js +48 -0
- package/dist/modules/health/health.module.d.ts +8 -0
- package/dist/modules/health/health.module.d.ts.map +1 -0
- package/dist/modules/health/health.module.js +21 -0
- package/dist/modules/index.d.ts +8 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +6 -0
- package/dist/modules/messages/__test-fixtures__/deps.d.ts +41 -0
- package/dist/modules/messages/__test-fixtures__/deps.d.ts.map +1 -0
- package/dist/modules/messages/__test-fixtures__/deps.js +73 -0
- package/dist/modules/messages/__test-fixtures__/fake-agent.d.ts +27 -0
- package/dist/modules/messages/__test-fixtures__/fake-agent.d.ts.map +1 -0
- package/dist/modules/messages/__test-fixtures__/fake-agent.js +41 -0
- package/dist/modules/messages/__test-fixtures__/fake-response.d.ts +29 -0
- package/dist/modules/messages/__test-fixtures__/fake-response.d.ts.map +1 -0
- package/dist/modules/messages/__test-fixtures__/fake-response.js +55 -0
- package/dist/modules/messages/agent-builder.d.ts +64 -0
- package/dist/modules/messages/agent-builder.d.ts.map +1 -0
- package/dist/modules/messages/agent-builder.js +219 -0
- package/dist/modules/messages/batch-invoker.d.ts +36 -0
- package/dist/modules/messages/batch-invoker.d.ts.map +1 -0
- package/dist/modules/messages/batch-invoker.js +58 -0
- package/dist/modules/messages/dto/list-messages.dto.d.ts +4 -0
- package/dist/modules/messages/dto/list-messages.dto.d.ts.map +1 -0
- package/dist/modules/messages/dto/list-messages.dto.js +17 -0
- package/dist/modules/messages/dto/send-message.dto.d.ts +73 -0
- package/dist/modules/messages/dto/send-message.dto.d.ts.map +1 -0
- package/dist/modules/messages/dto/send-message.dto.js +318 -0
- package/dist/modules/messages/file-processing-credit-sink.port.d.ts +20 -0
- package/dist/modules/messages/file-processing-credit-sink.port.d.ts.map +1 -0
- package/dist/modules/messages/file-processing-credit-sink.port.js +1 -0
- package/dist/modules/messages/file-processing.service.d.ts +195 -0
- package/dist/modules/messages/file-processing.service.d.ts.map +1 -0
- package/dist/modules/messages/file-processing.service.js +1278 -0
- package/dist/modules/messages/homeserver-cache.d.ts +11 -0
- package/dist/modules/messages/homeserver-cache.d.ts.map +1 -0
- package/dist/modules/messages/homeserver-cache.js +31 -0
- package/dist/modules/messages/matrix-listener-bridge.d.ts +63 -0
- package/dist/modules/messages/matrix-listener-bridge.d.ts.map +1 -0
- package/dist/modules/messages/matrix-listener-bridge.js +280 -0
- package/dist/modules/messages/messages.controller.d.ts +13 -0
- package/dist/modules/messages/messages.controller.d.ts.map +1 -0
- package/dist/modules/messages/messages.controller.js +95 -0
- package/dist/modules/messages/messages.module.d.ts +3 -0
- package/dist/modules/messages/messages.module.d.ts.map +1 -0
- package/dist/modules/messages/messages.module.js +75 -0
- package/dist/modules/messages/messages.service.d.ts +112 -0
- package/dist/modules/messages/messages.service.d.ts.map +1 -0
- package/dist/modules/messages/messages.service.js +279 -0
- package/dist/modules/messages/oracle-runtime-bundle.d.ts +38 -0
- package/dist/modules/messages/oracle-runtime-bundle.d.ts.map +1 -0
- package/dist/modules/messages/oracle-runtime-bundle.js +40 -0
- package/dist/modules/messages/post-message-syncer.d.ts +30 -0
- package/dist/modules/messages/post-message-syncer.d.ts.map +1 -0
- package/dist/modules/messages/post-message-syncer.js +73 -0
- package/dist/modules/messages/request-preparer.d.ts +53 -0
- package/dist/modules/messages/request-preparer.d.ts.map +1 -0
- package/dist/modules/messages/request-preparer.js +139 -0
- package/dist/modules/messages/sse-stream-runner.d.ts +73 -0
- package/dist/modules/messages/sse-stream-runner.d.ts.map +1 -0
- package/dist/modules/messages/sse-stream-runner.js +352 -0
- package/dist/modules/messages/sse.utils.d.ts +29 -0
- package/dist/modules/messages/sse.utils.d.ts.map +1 -0
- package/dist/modules/messages/sse.utils.js +77 -0
- package/dist/modules/messages/user-context-fetcher.d.ts +41 -0
- package/dist/modules/messages/user-context-fetcher.d.ts.map +1 -0
- package/dist/modules/messages/user-context-fetcher.js +117 -0
- package/dist/modules/secrets/index.d.ts +2 -0
- package/dist/modules/secrets/index.d.ts.map +1 -0
- package/dist/modules/secrets/index.js +1 -0
- package/dist/modules/secrets/secrets.service.d.ts +29 -0
- package/dist/modules/secrets/secrets.service.d.ts.map +1 -0
- package/dist/modules/secrets/secrets.service.js +107 -0
- package/dist/modules/sessions/dto/create-session.dto.d.ts +6 -0
- package/dist/modules/sessions/dto/create-session.dto.d.ts.map +1 -0
- package/dist/modules/sessions/dto/create-session.dto.js +5 -0
- package/dist/modules/sessions/dto/delete-session.dto.d.ts +6 -0
- package/dist/modules/sessions/dto/delete-session.dto.d.ts.map +1 -0
- package/dist/modules/sessions/dto/delete-session.dto.js +5 -0
- package/dist/modules/sessions/dto/list-sessions.dto.d.ts +7 -0
- package/dist/modules/sessions/dto/list-sessions.dto.d.ts.map +1 -0
- package/dist/modules/sessions/dto/list-sessions.dto.js +6 -0
- package/dist/modules/sessions/session-history-processor.service.d.ts +48 -0
- package/dist/modules/sessions/session-history-processor.service.d.ts.map +1 -0
- package/dist/modules/sessions/session-history-processor.service.js +254 -0
- package/dist/modules/sessions/sessions.controller.d.ts +13 -0
- package/dist/modules/sessions/sessions.controller.d.ts.map +1 -0
- package/dist/modules/sessions/sessions.controller.js +113 -0
- package/dist/modules/sessions/sessions.module.d.ts +3 -0
- package/dist/modules/sessions/sessions.module.d.ts.map +1 -0
- package/dist/modules/sessions/sessions.module.js +49 -0
- package/dist/modules/sessions/sessions.service.d.ts +23 -0
- package/dist/modules/sessions/sessions.service.d.ts.map +1 -0
- package/dist/modules/sessions/sessions.service.js +168 -0
- package/dist/modules/subscription/subscription.middleware.d.ts +37 -0
- package/dist/modules/subscription/subscription.middleware.d.ts.map +1 -0
- package/dist/modules/subscription/subscription.middleware.js +141 -0
- package/dist/modules/subscription/subscription.module.d.ts +12 -0
- package/dist/modules/subscription/subscription.module.d.ts.map +1 -0
- package/dist/modules/subscription/subscription.module.js +26 -0
- package/dist/modules/throttler/throttler.module.d.ts +11 -0
- package/dist/modules/throttler/throttler.module.d.ts.map +1 -0
- package/dist/modules/throttler/throttler.module.js +32 -0
- package/dist/modules/ucan/index.d.ts +7 -0
- package/dist/modules/ucan/index.d.ts.map +1 -0
- package/dist/modules/ucan/index.js +6 -0
- package/dist/modules/ucan/ucan.config.d.ts +87 -0
- package/dist/modules/ucan/ucan.config.d.ts.map +1 -0
- package/dist/modules/ucan/ucan.config.js +114 -0
- package/dist/modules/ucan/ucan.module.d.ts +29 -0
- package/dist/modules/ucan/ucan.module.d.ts.map +1 -0
- package/dist/modules/ucan/ucan.module.js +46 -0
- package/dist/modules/ucan/ucan.service.d.ts +129 -0
- package/dist/modules/ucan/ucan.service.d.ts.map +1 -0
- package/dist/modules/ucan/ucan.service.js +582 -0
- package/dist/modules/ws/emitter.d.ts +12 -0
- package/dist/modules/ws/emitter.d.ts.map +1 -0
- package/dist/modules/ws/emitter.js +12 -0
- package/dist/modules/ws/ws.gateway.d.ts +34 -0
- package/dist/modules/ws/ws.gateway.d.ts.map +1 -0
- package/dist/modules/ws/ws.gateway.js +241 -0
- package/dist/modules/ws/ws.module.d.ts +3 -0
- package/dist/modules/ws/ws.module.d.ts.map +1 -0
- package/dist/modules/ws/ws.module.js +21 -0
- package/dist/modules/ws/ws.service.d.ts +25 -0
- package/dist/modules/ws/ws.service.d.ts.map +1 -0
- package/dist/modules/ws/ws.service.js +113 -0
- package/dist/plugin-api/define-plugin.d.ts +19 -0
- package/dist/plugin-api/define-plugin.d.ts.map +1 -0
- package/dist/plugin-api/define-plugin.js +25 -0
- package/dist/plugin-api/oracle-plugin.d.ts +92 -0
- package/dist/plugin-api/oracle-plugin.d.ts.map +1 -0
- package/dist/plugin-api/oracle-plugin.js +15 -0
- package/dist/plugin-api/tool-helper.d.ts +33 -0
- package/dist/plugin-api/tool-helper.d.ts.map +1 -0
- package/dist/plugin-api/tool-helper.js +40 -0
- package/dist/plugin-api/types.d.ts +378 -0
- package/dist/plugin-api/types.d.ts.map +1 -0
- package/dist/plugin-api/types.js +1 -0
- package/dist/plugins/agui/agui-agent.d.ts +10 -0
- package/dist/plugins/agui/agui-agent.d.ts.map +1 -0
- package/dist/plugins/agui/agui-agent.js +110 -0
- package/dist/plugins/agui/agui.plugin.d.ts +16 -0
- package/dist/plugins/agui/agui.plugin.d.ts.map +1 -0
- package/dist/plugins/agui/agui.plugin.js +117 -0
- package/dist/plugins/agui/index.d.ts +3 -0
- package/dist/plugins/agui/index.d.ts.map +1 -0
- package/dist/plugins/agui/index.js +2 -0
- package/dist/plugins/composio/composio-tools.d.ts +59 -0
- package/dist/plugins/composio/composio-tools.d.ts.map +1 -0
- package/dist/plugins/composio/composio-tools.js +88 -0
- package/dist/plugins/composio/composio-ucan.d.ts +14 -0
- package/dist/plugins/composio/composio-ucan.d.ts.map +1 -0
- package/dist/plugins/composio/composio-ucan.js +32 -0
- package/dist/plugins/composio/composio.plugin.d.ts +45 -0
- package/dist/plugins/composio/composio.plugin.d.ts.map +1 -0
- package/dist/plugins/composio/composio.plugin.js +116 -0
- package/dist/plugins/composio/index.d.ts +4 -0
- package/dist/plugins/composio/index.d.ts.map +1 -0
- package/dist/plugins/composio/index.js +3 -0
- package/dist/plugins/credits/claim-processing.module.d.ts +28 -0
- package/dist/plugins/credits/claim-processing.module.d.ts.map +1 -0
- package/dist/plugins/credits/claim-processing.module.js +37 -0
- package/dist/plugins/credits/claim-processing.service.d.ts +92 -0
- package/dist/plugins/credits/claim-processing.service.d.ts.map +1 -0
- package/dist/plugins/credits/claim-processing.service.js +406 -0
- package/dist/plugins/credits/credits-middleware.d.ts +23 -0
- package/dist/plugins/credits/credits-middleware.d.ts.map +1 -0
- package/dist/plugins/credits/credits-middleware.js +154 -0
- package/dist/plugins/credits/credits.plugin.d.ts +55 -0
- package/dist/plugins/credits/credits.plugin.d.ts.map +1 -0
- package/dist/plugins/credits/credits.plugin.js +95 -0
- package/dist/plugins/credits/file-processing-sink.module.d.ts +18 -0
- package/dist/plugins/credits/file-processing-sink.module.d.ts.map +1 -0
- package/dist/plugins/credits/file-processing-sink.module.js +56 -0
- package/dist/plugins/credits/index.d.ts +8 -0
- package/dist/plugins/credits/index.d.ts.map +1 -0
- package/dist/plugins/credits/index.js +7 -0
- package/dist/plugins/credits/subscription-sink.module.d.ts +23 -0
- package/dist/plugins/credits/subscription-sink.module.d.ts.map +1 -0
- package/dist/plugins/credits/subscription-sink.module.js +54 -0
- package/dist/plugins/credits/token-limiter.d.ts +139 -0
- package/dist/plugins/credits/token-limiter.d.ts.map +1 -0
- package/dist/plugins/credits/token-limiter.js +302 -0
- package/dist/plugins/domain-indexer/domain-indexer-agent.d.ts +7 -0
- package/dist/plugins/domain-indexer/domain-indexer-agent.d.ts.map +1 -0
- package/dist/plugins/domain-indexer/domain-indexer-agent.js +48 -0
- package/dist/plugins/domain-indexer/domain-indexer-tools.d.ts +8 -0
- package/dist/plugins/domain-indexer/domain-indexer-tools.d.ts.map +1 -0
- package/dist/plugins/domain-indexer/domain-indexer-tools.js +194 -0
- package/dist/plugins/domain-indexer/domain-indexer.plugin.d.ts +20 -0
- package/dist/plugins/domain-indexer/domain-indexer.plugin.d.ts.map +1 -0
- package/dist/plugins/domain-indexer/domain-indexer.plugin.js +78 -0
- package/dist/plugins/domain-indexer/index.d.ts +2 -0
- package/dist/plugins/domain-indexer/index.d.ts.map +1 -0
- package/dist/plugins/domain-indexer/index.js +1 -0
- package/dist/plugins/editor/apply-sandbox-output.d.ts +33 -0
- package/dist/plugins/editor/apply-sandbox-output.d.ts.map +1 -0
- package/dist/plugins/editor/apply-sandbox-output.js +302 -0
- package/dist/plugins/editor/block-actions.d.ts +84 -0
- package/dist/plugins/editor/block-actions.d.ts.map +1 -0
- package/dist/plugins/editor/block-actions.js +471 -0
- package/dist/plugins/editor/blocknote-helper.d.ts +147 -0
- package/dist/plugins/editor/blocknote-helper.d.ts.map +1 -0
- package/dist/plugins/editor/blocknote-helper.js +542 -0
- package/dist/plugins/editor/blocknote-tools.d.ts +364 -0
- package/dist/plugins/editor/blocknote-tools.d.ts.map +1 -0
- package/dist/plugins/editor/blocknote-tools.js +2123 -0
- package/dist/plugins/editor/editor-agent.d.ts +47 -0
- package/dist/plugins/editor/editor-agent.d.ts.map +1 -0
- package/dist/plugins/editor/editor-agent.js +158 -0
- package/dist/plugins/editor/editor-mx.d.ts +56 -0
- package/dist/plugins/editor/editor-mx.d.ts.map +1 -0
- package/dist/plugins/editor/editor-mx.js +100 -0
- package/dist/plugins/editor/editor.plugin.d.ts +32 -0
- package/dist/plugins/editor/editor.plugin.d.ts.map +1 -0
- package/dist/plugins/editor/editor.plugin.js +189 -0
- package/dist/plugins/editor/index.d.ts +6 -0
- package/dist/plugins/editor/index.d.ts.map +1 -0
- package/dist/plugins/editor/index.js +5 -0
- package/dist/plugins/editor/mint-invocation-tool.d.ts +72 -0
- package/dist/plugins/editor/mint-invocation-tool.d.ts.map +1 -0
- package/dist/plugins/editor/mint-invocation-tool.js +173 -0
- package/dist/plugins/editor/page-functions.d.ts +100 -0
- package/dist/plugins/editor/page-functions.d.ts.map +1 -0
- package/dist/plugins/editor/page-functions.js +317 -0
- package/dist/plugins/editor/page-tools.d.ts +75 -0
- package/dist/plugins/editor/page-tools.d.ts.map +1 -0
- package/dist/plugins/editor/page-tools.js +238 -0
- package/dist/plugins/editor/prompts.d.ts +22 -0
- package/dist/plugins/editor/prompts.d.ts.map +1 -0
- package/dist/plugins/editor/prompts.js +451 -0
- package/dist/plugins/editor/provider.d.ts +101 -0
- package/dist/plugins/editor/provider.d.ts.map +1 -0
- package/dist/plugins/editor/provider.js +249 -0
- package/dist/plugins/editor/standalone-editor-tool.d.ts +17 -0
- package/dist/plugins/editor/standalone-editor-tool.d.ts.map +1 -0
- package/dist/plugins/editor/standalone-editor-tool.js +136 -0
- package/dist/plugins/editor/survey-helpers.d.ts +112 -0
- package/dist/plugins/editor/survey-helpers.d.ts.map +1 -0
- package/dist/plugins/editor/survey-helpers.js +358 -0
- package/dist/plugins/firecrawl/firecrawl-agent.d.ts +7 -0
- package/dist/plugins/firecrawl/firecrawl-agent.d.ts.map +1 -0
- package/dist/plugins/firecrawl/firecrawl-agent.js +84 -0
- package/dist/plugins/firecrawl/firecrawl-tools.d.ts +37 -0
- package/dist/plugins/firecrawl/firecrawl-tools.d.ts.map +1 -0
- package/dist/plugins/firecrawl/firecrawl-tools.js +129 -0
- package/dist/plugins/firecrawl/firecrawl.plugin.d.ts +32 -0
- package/dist/plugins/firecrawl/firecrawl.plugin.d.ts.map +1 -0
- package/dist/plugins/firecrawl/firecrawl.plugin.js +69 -0
- package/dist/plugins/firecrawl/index.d.ts +3 -0
- package/dist/plugins/firecrawl/index.d.ts.map +1 -0
- package/dist/plugins/firecrawl/index.js +2 -0
- package/dist/plugins/index.d.ts +47 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +69 -0
- package/dist/plugins/matrix-group-chats/channel-memory.module.d.ts +7 -0
- package/dist/plugins/matrix-group-chats/channel-memory.module.d.ts.map +1 -0
- package/dist/plugins/matrix-group-chats/channel-memory.module.js +22 -0
- package/dist/plugins/matrix-group-chats/channel-memory.repo.d.ts +62 -0
- package/dist/plugins/matrix-group-chats/channel-memory.repo.d.ts.map +1 -0
- package/dist/plugins/matrix-group-chats/channel-memory.repo.js +311 -0
- package/dist/plugins/matrix-group-chats/channel-memory.service.d.ts +89 -0
- package/dist/plugins/matrix-group-chats/channel-memory.service.d.ts.map +1 -0
- package/dist/plugins/matrix-group-chats/channel-memory.service.js +565 -0
- package/dist/plugins/matrix-group-chats/channel-memory.summarizer.d.ts +18 -0
- package/dist/plugins/matrix-group-chats/channel-memory.summarizer.d.ts.map +1 -0
- package/dist/plugins/matrix-group-chats/channel-memory.summarizer.js +128 -0
- package/dist/plugins/matrix-group-chats/channel-memory.types.d.ts +50 -0
- package/dist/plugins/matrix-group-chats/channel-memory.types.d.ts.map +1 -0
- package/dist/plugins/matrix-group-chats/channel-memory.types.js +2 -0
- package/dist/plugins/matrix-group-chats/guard.d.ts +83 -0
- package/dist/plugins/matrix-group-chats/guard.d.ts.map +1 -0
- package/dist/plugins/matrix-group-chats/guard.js +138 -0
- package/dist/plugins/matrix-group-chats/index.d.ts +59 -0
- package/dist/plugins/matrix-group-chats/index.d.ts.map +1 -0
- package/dist/plugins/matrix-group-chats/index.js +140 -0
- package/dist/plugins/matrix-group-chats/middleware.d.ts +31 -0
- package/dist/plugins/matrix-group-chats/middleware.d.ts.map +1 -0
- package/dist/plugins/matrix-group-chats/middleware.js +186 -0
- package/dist/plugins/matrix-group-chats/power-levels.d.ts +15 -0
- package/dist/plugins/matrix-group-chats/power-levels.d.ts.map +1 -0
- package/dist/plugins/matrix-group-chats/power-levels.js +36 -0
- package/dist/plugins/matrix-group-chats/room-info.d.ts +23 -0
- package/dist/plugins/matrix-group-chats/room-info.d.ts.map +1 -0
- package/dist/plugins/matrix-group-chats/room-info.js +34 -0
- package/dist/plugins/matrix-group-chats/tools.d.ts +8 -0
- package/dist/plugins/matrix-group-chats/tools.d.ts.map +1 -0
- package/dist/plugins/matrix-group-chats/tools.js +154 -0
- package/dist/plugins/memory/index.d.ts +5 -0
- package/dist/plugins/memory/index.d.ts.map +1 -0
- package/dist/plugins/memory/index.js +3 -0
- package/dist/plugins/memory/memory-tools.d.ts +52 -0
- package/dist/plugins/memory/memory-tools.d.ts.map +1 -0
- package/dist/plugins/memory/memory-tools.js +88 -0
- package/dist/plugins/memory/memory-ucan.d.ts +17 -0
- package/dist/plugins/memory/memory-ucan.d.ts.map +1 -0
- package/dist/plugins/memory/memory-ucan.js +43 -0
- package/dist/plugins/memory/memory.plugin.d.ts +51 -0
- package/dist/plugins/memory/memory.plugin.d.ts.map +1 -0
- package/dist/plugins/memory/memory.plugin.js +76 -0
- package/dist/plugins/memory/types.d.ts +75 -0
- package/dist/plugins/memory/types.d.ts.map +1 -0
- package/dist/plugins/memory/types.js +2 -0
- package/dist/plugins/portal/index.d.ts +3 -0
- package/dist/plugins/portal/index.d.ts.map +1 -0
- package/dist/plugins/portal/index.js +2 -0
- package/dist/plugins/portal/portal-agent.d.ts +9 -0
- package/dist/plugins/portal/portal-agent.d.ts.map +1 -0
- package/dist/plugins/portal/portal-agent.js +70 -0
- package/dist/plugins/portal/portal.plugin.d.ts +16 -0
- package/dist/plugins/portal/portal.plugin.d.ts.map +1 -0
- package/dist/plugins/portal/portal.plugin.js +115 -0
- package/dist/plugins/sandbox/index.d.ts +3 -0
- package/dist/plugins/sandbox/index.d.ts.map +1 -0
- package/dist/plugins/sandbox/index.js +2 -0
- package/dist/plugins/sandbox/sandbox-mcp.d.ts +46 -0
- package/dist/plugins/sandbox/sandbox-mcp.d.ts.map +1 -0
- package/dist/plugins/sandbox/sandbox-mcp.js +80 -0
- package/dist/plugins/sandbox/sandbox-write-blob.d.ts +22 -0
- package/dist/plugins/sandbox/sandbox-write-blob.d.ts.map +1 -0
- package/dist/plugins/sandbox/sandbox-write-blob.js +80 -0
- package/dist/plugins/sandbox/sandbox.plugin.d.ts +80 -0
- package/dist/plugins/sandbox/sandbox.plugin.d.ts.map +1 -0
- package/dist/plugins/sandbox/sandbox.plugin.js +204 -0
- package/dist/plugins/skills/index.d.ts +3 -0
- package/dist/plugins/skills/index.d.ts.map +1 -0
- package/dist/plugins/skills/index.js +2 -0
- package/dist/plugins/skills/skills-tools.d.ts +20 -0
- package/dist/plugins/skills/skills-tools.d.ts.map +1 -0
- package/dist/plugins/skills/skills-tools.js +204 -0
- package/dist/plugins/skills/skills-ucan.d.ts +24 -0
- package/dist/plugins/skills/skills-ucan.d.ts.map +1 -0
- package/dist/plugins/skills/skills-ucan.js +28 -0
- package/dist/plugins/skills/skills.plugin.d.ts +37 -0
- package/dist/plugins/skills/skills.plugin.d.ts.map +1 -0
- package/dist/plugins/skills/skills.plugin.js +82 -0
- package/dist/plugins/slack/index.d.ts +4 -0
- package/dist/plugins/slack/index.d.ts.map +1 -0
- package/dist/plugins/slack/index.js +3 -0
- package/dist/plugins/slack/slack.module.d.ts +9 -0
- package/dist/plugins/slack/slack.module.d.ts.map +1 -0
- package/dist/plugins/slack/slack.module.js +27 -0
- package/dist/plugins/slack/slack.plugin.d.ts +30 -0
- package/dist/plugins/slack/slack.plugin.d.ts.map +1 -0
- package/dist/plugins/slack/slack.plugin.js +40 -0
- package/dist/plugins/slack/slack.service.d.ts +32 -0
- package/dist/plugins/slack/slack.service.d.ts.map +1 -0
- package/dist/plugins/slack/slack.service.js +157 -0
- package/dist/plugins/user-preferences/index.d.ts +4 -0
- package/dist/plugins/user-preferences/index.d.ts.map +1 -0
- package/dist/plugins/user-preferences/index.js +3 -0
- package/dist/plugins/user-preferences/service/user-preferences.service.d.ts +61 -0
- package/dist/plugins/user-preferences/service/user-preferences.service.d.ts.map +1 -0
- package/dist/plugins/user-preferences/service/user-preferences.service.js +105 -0
- package/dist/plugins/user-preferences/user-preferences-http.module.d.ts +10 -0
- package/dist/plugins/user-preferences/user-preferences-http.module.d.ts.map +1 -0
- package/dist/plugins/user-preferences/user-preferences-http.module.js +23 -0
- package/dist/plugins/user-preferences/user-preferences-tool.d.ts +22 -0
- package/dist/plugins/user-preferences/user-preferences-tool.d.ts.map +1 -0
- package/dist/plugins/user-preferences/user-preferences-tool.js +103 -0
- package/dist/plugins/user-preferences/user-preferences.controller.d.ts +18 -0
- package/dist/plugins/user-preferences/user-preferences.controller.d.ts.map +1 -0
- package/dist/plugins/user-preferences/user-preferences.controller.js +72 -0
- package/dist/plugins/user-preferences/user-preferences.plugin.d.ts +27 -0
- package/dist/plugins/user-preferences/user-preferences.plugin.d.ts.map +1 -0
- package/dist/plugins/user-preferences/user-preferences.plugin.js +66 -0
- package/dist/registries/config-schema-registry.d.ts +24 -0
- package/dist/registries/config-schema-registry.d.ts.map +1 -0
- package/dist/registries/config-schema-registry.js +27 -0
- package/dist/registries/index.d.ts +13 -0
- package/dist/registries/index.d.ts.map +1 -0
- package/dist/registries/index.js +6 -0
- package/dist/registries/manifest-registry.d.ts +49 -0
- package/dist/registries/manifest-registry.d.ts.map +1 -0
- package/dist/registries/manifest-registry.js +53 -0
- package/dist/registries/middleware-registry.d.ts +41 -0
- package/dist/registries/middleware-registry.d.ts.map +1 -0
- package/dist/registries/middleware-registry.js +52 -0
- package/dist/registries/shared-state-registry.d.ts +41 -0
- package/dist/registries/shared-state-registry.d.ts.map +1 -0
- package/dist/registries/shared-state-registry.js +65 -0
- package/dist/registries/subagent-registry.d.ts +55 -0
- package/dist/registries/subagent-registry.d.ts.map +1 -0
- package/dist/registries/subagent-registry.js +106 -0
- package/dist/registries/test-fixtures.d.ts +47 -0
- package/dist/registries/test-fixtures.d.ts.map +1 -0
- package/dist/registries/test-fixtures.js +168 -0
- package/dist/registries/tool-registry.d.ts +74 -0
- package/dist/registries/tool-registry.d.ts.map +1 -0
- package/dist/registries/tool-registry.js +130 -0
- package/dist/runtime-context/ambient.d.ts +118 -0
- package/dist/runtime-context/ambient.d.ts.map +1 -0
- package/dist/runtime-context/ambient.js +1 -0
- package/dist/runtime-context/build-plugin.d.ts +20 -0
- package/dist/runtime-context/build-plugin.d.ts.map +1 -0
- package/dist/runtime-context/build-plugin.js +16 -0
- package/dist/runtime-context/build-runtime.d.ts +60 -0
- package/dist/runtime-context/build-runtime.d.ts.map +1 -0
- package/dist/runtime-context/build-runtime.js +81 -0
- package/dist/testing/create-test-runtime.d.ts +95 -0
- package/dist/testing/create-test-runtime.d.ts.map +1 -0
- package/dist/testing/create-test-runtime.js +302 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +5 -0
- package/dist/testing/integration/chat-client.d.ts +143 -0
- package/dist/testing/integration/chat-client.d.ts.map +1 -0
- package/dist/testing/integration/chat-client.js +238 -0
- package/dist/testing/integration/harness.d.ts +189 -0
- package/dist/testing/integration/harness.d.ts.map +1 -0
- package/dist/testing/integration/harness.js +461 -0
- package/dist/testing/integration/index.d.ts +14 -0
- package/dist/testing/integration/index.d.ts.map +1 -0
- package/dist/testing/integration/index.js +18 -0
- package/dist/testing/integration/setup.d.ts +2 -0
- package/dist/testing/integration/setup.d.ts.map +1 -0
- package/dist/testing/integration/setup.js +41 -0
- package/dist/testing/integration/sse-parser.d.ts +99 -0
- package/dist/testing/integration/sse-parser.d.ts.map +1 -0
- package/dist/testing/integration/sse-parser.js +125 -0
- package/dist/testing/integration/ucan.d.ts +74 -0
- package/dist/testing/integration/ucan.d.ts.map +1 -0
- package/dist/testing/integration/ucan.js +95 -0
- package/dist/testing/integration/wait-for-matrix-loaded.d.ts +19 -0
- package/dist/testing/integration/wait-for-matrix-loaded.d.ts.map +1 -0
- package/dist/testing/integration/wait-for-matrix-loaded.js +31 -0
- package/dist/testing/mocks.d.ts +64 -0
- package/dist/testing/mocks.d.ts.map +1 -0
- package/dist/testing/mocks.js +141 -0
- package/dist/testing/nest-doubles.d.ts +10 -0
- package/dist/testing/nest-doubles.d.ts.map +1 -0
- package/dist/testing/nest-doubles.js +19 -0
- package/dist/utils/emoji.d.ts +3 -0
- package/dist/utils/emoji.d.ts.map +1 -0
- package/dist/utils/emoji.js +36 -0
- package/package.json +102 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type GetMySubscriptionsResponseDto } from '@ixo/common';
|
|
2
|
+
import { Cache } from '@nestjs/cache-manager';
|
|
3
|
+
import { type NestMiddleware } from '@nestjs/common';
|
|
4
|
+
import { ConfigService } from '@nestjs/config';
|
|
5
|
+
import { type NextFunction, type Request, type Response } from 'express';
|
|
6
|
+
import { UcanService } from '../ucan/ucan.service.js';
|
|
7
|
+
/**
|
|
8
|
+
* Optional credit/token-limiter sink. Subscription syncs the per-DID
|
|
9
|
+
* subscription payload + balance into Redis for the credits plugin to
|
|
10
|
+
* read on the LLM hot path. The sink is provided by the credits plugin
|
|
11
|
+
* when installed. When absent, the middleware still enforces the 402
|
|
12
|
+
* gate purely from the API response — no Redis dependency.
|
|
13
|
+
*/
|
|
14
|
+
export interface SubscriptionCreditSink {
|
|
15
|
+
setSubscriptionPayload(userDid: string, payload: GetMySubscriptionsResponseDto): Promise<void>;
|
|
16
|
+
overrideUserBalance(userDid: string, balance: number): Promise<string>;
|
|
17
|
+
}
|
|
18
|
+
export declare const SUBSCRIPTION_CREDIT_SINK: unique symbol;
|
|
19
|
+
declare global {
|
|
20
|
+
namespace Express {
|
|
21
|
+
interface Request {
|
|
22
|
+
subscriptionData?: GetMySubscriptionsResponseDto;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export declare class SubscriptionMiddleware implements NestMiddleware {
|
|
27
|
+
private readonly configService;
|
|
28
|
+
private cacheManager;
|
|
29
|
+
private readonly ucanService;
|
|
30
|
+
private readonly creditSink?;
|
|
31
|
+
private readonly logger;
|
|
32
|
+
constructor(configService: ConfigService, cacheManager: Cache, ucanService: UcanService, creditSink?: SubscriptionCreditSink | undefined);
|
|
33
|
+
private checkCanContinue;
|
|
34
|
+
use(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
35
|
+
private syncCreditSink;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=subscription.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription.middleware.d.ts","sourceRoot":"","sources":["../../../src/modules/subscription/subscription.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,6BAA6B,EACnC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,EAAiB,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAOL,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,sBAAsB,CACpB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACxE;AAED,eAAO,MAAM,wBAAwB,eAAqC,CAAC;AAmB3E,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,gBAAgB,CAAC,EAAE,6BAA6B,CAAC;SAClD;KACF;CACF;AAID,qBACa,sBAAuB,YAAW,cAAc;IAIzD,OAAO,CAAC,QAAQ,CAAC,aAAa;IACP,OAAO,CAAC,YAAY;IAG3C,OAAO,CAAC,QAAQ,CAAC,WAAW;IAM5B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;IAb9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;gBAG/C,aAAa,EAAE,aAAa,EACd,YAAY,EAAE,KAAK,EAGjC,WAAW,EAAE,WAAW,EAMxB,UAAU,CAAC,EAAE,sBAAsB,YAAA;IAGtD,OAAO,CAAC,gBAAgB;IA4BlB,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;YAqI3D,cAAc;CAa7B"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var SubscriptionMiddleware_1;
|
|
14
|
+
import { getUserSubscription, getSubscriptionUrlByNetwork, } from '@ixo/common';
|
|
15
|
+
import { Cache, CACHE_MANAGER } from '@nestjs/cache-manager';
|
|
16
|
+
import { HttpException, HttpStatus, Inject, Injectable, Logger, Optional, } from '@nestjs/common';
|
|
17
|
+
import { ConfigService } from '@nestjs/config';
|
|
18
|
+
import { minutes } from '@nestjs/throttler';
|
|
19
|
+
import { UcanService } from '../ucan/ucan.service.js';
|
|
20
|
+
export const SUBSCRIPTION_CREDIT_SINK = Symbol('SUBSCRIPTION_CREDIT_SINK');
|
|
21
|
+
const THREE_MINUTES = minutes(3);
|
|
22
|
+
let SubscriptionMiddleware = SubscriptionMiddleware_1 = class SubscriptionMiddleware {
|
|
23
|
+
configService;
|
|
24
|
+
cacheManager;
|
|
25
|
+
ucanService;
|
|
26
|
+
creditSink;
|
|
27
|
+
logger = new Logger(SubscriptionMiddleware_1.name);
|
|
28
|
+
constructor(configService, cacheManager,
|
|
29
|
+
// UCAN is core runtime (global `UcanModule` exports `UcanService`).
|
|
30
|
+
// Direct DI — no port indirection.
|
|
31
|
+
ucanService, creditSink) {
|
|
32
|
+
this.configService = configService;
|
|
33
|
+
this.cacheManager = cacheManager;
|
|
34
|
+
this.ucanService = ucanService;
|
|
35
|
+
this.creditSink = creditSink;
|
|
36
|
+
}
|
|
37
|
+
checkCanContinue(subscription) {
|
|
38
|
+
const disableCredits = this.configService.get('DISABLE_CREDITS', false);
|
|
39
|
+
if (disableCredits) {
|
|
40
|
+
this.logger.debug('Subscription check skipped (DISABLE_CREDITS=true)');
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
if (subscription.status !== 'active' && subscription.status !== 'trial') {
|
|
44
|
+
throw new HttpException('User has inactive subscription, please subscribe to continue', HttpStatus.PAYMENT_REQUIRED);
|
|
45
|
+
}
|
|
46
|
+
if (subscription.totalCredits <= 10) {
|
|
47
|
+
throw new HttpException('User has less than 10 credits, please top up to continue', HttpStatus.PAYMENT_REQUIRED);
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
async use(req, res, next) {
|
|
52
|
+
this.logger.debug(`SubscriptionMiddleware processing request for: ${req.originalUrl}`);
|
|
53
|
+
if (!this.creditSink) {
|
|
54
|
+
this.logger.warn('No SubscriptionCreditSink configured; credits plugin is not active. Enforcing 402 policy directly based on subscription API only.');
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
// Check if authData is available (set upstream by AuthHeaderMiddleware)
|
|
58
|
+
const authData = req.authData;
|
|
59
|
+
if (!authData) {
|
|
60
|
+
this.logger.warn('No auth data available, skipping subscription check');
|
|
61
|
+
req.subscriptionData = undefined;
|
|
62
|
+
return next();
|
|
63
|
+
}
|
|
64
|
+
const { did, ucanDelegation } = authData;
|
|
65
|
+
if (!ucanDelegation) {
|
|
66
|
+
throw new HttpException('Missing UCAN delegation; cannot verify subscription', HttpStatus.UNAUTHORIZED);
|
|
67
|
+
}
|
|
68
|
+
const cachedSubscription = await this.cacheManager.get(`subscription_${did}`);
|
|
69
|
+
if (cachedSubscription) {
|
|
70
|
+
this.logger.debug(`Subscription found in cache for user: ${did}`);
|
|
71
|
+
req.subscriptionData = cachedSubscription;
|
|
72
|
+
this.checkCanContinue(cachedSubscription);
|
|
73
|
+
// Credit sink was already synced on the original cache miss; the
|
|
74
|
+
// subscription cache TTL is the source of truth for "this user's
|
|
75
|
+
// Redis state is fresh enough." Re-syncing on every cached request
|
|
76
|
+
// adds two Redis writes for no gain.
|
|
77
|
+
next();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const network = this.configService.get('NETWORK') ??
|
|
81
|
+
'devnet';
|
|
82
|
+
const subscriptionUrl = this.configService.get('SUBSCRIPTION_URL') ??
|
|
83
|
+
getSubscriptionUrlByNetwork(network);
|
|
84
|
+
if (!this.ucanService.hasSigningKey()) {
|
|
85
|
+
throw new HttpException('UCAN signing key not configured; subscription check unavailable', HttpStatus.UNAUTHORIZED);
|
|
86
|
+
}
|
|
87
|
+
const invocation = await this.ucanService.createServiceInvocation(subscriptionUrl, did, 'ixo:subscriptions');
|
|
88
|
+
if (!invocation) {
|
|
89
|
+
throw new HttpException('Failed to mint UCAN invocation for subscription check', HttpStatus.UNAUTHORIZED);
|
|
90
|
+
}
|
|
91
|
+
this.logger.debug(`[UCAN] Using UCAN invocation for subscription check: ${did}`);
|
|
92
|
+
const subscription = await getUserSubscription({
|
|
93
|
+
bearerToken: invocation,
|
|
94
|
+
network,
|
|
95
|
+
subscriptionUrl,
|
|
96
|
+
authType: 'ucan',
|
|
97
|
+
});
|
|
98
|
+
if (!subscription) {
|
|
99
|
+
this.logger.warn(`No subscription found for user: ${did}. This could mean: 1) API returned non-OK status, 2) API returned null/undefined data, 3) API call failed with error`);
|
|
100
|
+
req.subscriptionData = undefined;
|
|
101
|
+
throw new HttpException('No subscription found, please subscribe to continue', HttpStatus.PAYMENT_REQUIRED);
|
|
102
|
+
}
|
|
103
|
+
req.subscriptionData = subscription;
|
|
104
|
+
this.logger.debug(`Subscription validated for user: ${did}, status: ${subscription.status}`);
|
|
105
|
+
this.checkCanContinue(subscription);
|
|
106
|
+
await this.syncCreditSink(did, subscription);
|
|
107
|
+
await this.cacheManager.set(`subscription_${did}`, subscription, THREE_MINUTES);
|
|
108
|
+
next();
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
112
|
+
const errorStack = error instanceof Error ? error.stack : undefined;
|
|
113
|
+
// Re-throw HttpExceptions (the 402 gates) unchanged so the original
|
|
114
|
+
// status + message reach the client.
|
|
115
|
+
if (error instanceof HttpException) {
|
|
116
|
+
this.logger.error(`Subscription validation failed: ${message}`, errorStack);
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
this.logger.error(`Subscription check failed: ${message}`, errorStack);
|
|
120
|
+
req.subscriptionData = undefined;
|
|
121
|
+
throw new HttpException('Subscription validation failed', HttpStatus.PAYMENT_REQUIRED);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async syncCreditSink(userDid, subscription) {
|
|
125
|
+
if (!this.creditSink) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
await this.creditSink.setSubscriptionPayload(userDid, subscription);
|
|
129
|
+
await this.creditSink.overrideUserBalance(userDid, subscription.totalCredits);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
SubscriptionMiddleware = SubscriptionMiddleware_1 = __decorate([
|
|
133
|
+
Injectable(),
|
|
134
|
+
__param(1, Inject(CACHE_MANAGER)),
|
|
135
|
+
__param(3, Optional()),
|
|
136
|
+
__param(3, Inject(SUBSCRIPTION_CREDIT_SINK)),
|
|
137
|
+
__metadata("design:paramtypes", [ConfigService,
|
|
138
|
+
Cache,
|
|
139
|
+
UcanService, Object])
|
|
140
|
+
], SubscriptionMiddleware);
|
|
141
|
+
export { SubscriptionMiddleware };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps `SubscriptionMiddleware` so `RuntimeAppModule` can pull it in via
|
|
3
|
+
* `MiddlewareConsumer.apply(...)`. The middleware itself is the unit of
|
|
4
|
+
* work — this module just owns the provider registration.
|
|
5
|
+
*
|
|
6
|
+
* `UcanService` flows in via Nest's global UCAN module (always present).
|
|
7
|
+
* `SUBSCRIPTION_CREDIT_SINK` is plugin-supplied (credits plugin's
|
|
8
|
+
* `getNestModules()`); the middleware tolerates it being absent.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SubscriptionModule {
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=subscription.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription.module.d.ts","sourceRoot":"","sources":["../../../src/modules/subscription/subscription.module.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,qBAIa,kBAAkB;CAAG"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Module } from '@nestjs/common';
|
|
8
|
+
import { SubscriptionMiddleware } from './subscription.middleware.js';
|
|
9
|
+
/**
|
|
10
|
+
* Wraps `SubscriptionMiddleware` so `RuntimeAppModule` can pull it in via
|
|
11
|
+
* `MiddlewareConsumer.apply(...)`. The middleware itself is the unit of
|
|
12
|
+
* work — this module just owns the provider registration.
|
|
13
|
+
*
|
|
14
|
+
* `UcanService` flows in via Nest's global UCAN module (always present).
|
|
15
|
+
* `SUBSCRIPTION_CREDIT_SINK` is plugin-supplied (credits plugin's
|
|
16
|
+
* `getNestModules()`); the middleware tolerates it being absent.
|
|
17
|
+
*/
|
|
18
|
+
let SubscriptionModule = class SubscriptionModule {
|
|
19
|
+
};
|
|
20
|
+
SubscriptionModule = __decorate([
|
|
21
|
+
Module({
|
|
22
|
+
providers: [SubscriptionMiddleware],
|
|
23
|
+
exports: [SubscriptionMiddleware],
|
|
24
|
+
})
|
|
25
|
+
], SubscriptionModule);
|
|
26
|
+
export { SubscriptionModule };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports `@nestjs/throttler` configured with the runtime's default
|
|
3
|
+
* rate-limit policy (10 requests per 60 seconds, applied globally via
|
|
4
|
+
* the `ThrottlerGuard` registered by `RuntimeAppModule`).
|
|
5
|
+
*
|
|
6
|
+
* Forks that need a different policy can swap this module in their
|
|
7
|
+
* own AppModule, but most should leave it alone.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ThrottlerModule {
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=throttler.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttler.module.d.ts","sourceRoot":"","sources":["../../../src/modules/throttler/throttler.module.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,qBAWa,eAAe;CAAG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Module } from '@nestjs/common';
|
|
8
|
+
import { ThrottlerModule as NestThrottlerModule } from '@nestjs/throttler';
|
|
9
|
+
/**
|
|
10
|
+
* Re-exports `@nestjs/throttler` configured with the runtime's default
|
|
11
|
+
* rate-limit policy (10 requests per 60 seconds, applied globally via
|
|
12
|
+
* the `ThrottlerGuard` registered by `RuntimeAppModule`).
|
|
13
|
+
*
|
|
14
|
+
* Forks that need a different policy can swap this module in their
|
|
15
|
+
* own AppModule, but most should leave it alone.
|
|
16
|
+
*/
|
|
17
|
+
let ThrottlerModule = class ThrottlerModule {
|
|
18
|
+
};
|
|
19
|
+
ThrottlerModule = __decorate([
|
|
20
|
+
Module({
|
|
21
|
+
imports: [
|
|
22
|
+
NestThrottlerModule.forRoot([
|
|
23
|
+
{
|
|
24
|
+
ttl: 60000,
|
|
25
|
+
limit: 10,
|
|
26
|
+
},
|
|
27
|
+
]),
|
|
28
|
+
],
|
|
29
|
+
exports: [NestThrottlerModule],
|
|
30
|
+
})
|
|
31
|
+
], ThrottlerModule);
|
|
32
|
+
export { ThrottlerModule };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview UCAN module exports for the Oracle runtime
|
|
3
|
+
*/
|
|
4
|
+
export { UcanModule } from './ucan.module.js';
|
|
5
|
+
export { UcanService, type MCPValidationResult } from './ucan.service.js';
|
|
6
|
+
export { createMCPUCANConfig, requiresUCANAuth, buildRequiredCapability, loadUCANConfigFromEnv, } from './ucan.config.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/ucan/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview UCAN module exports for the Oracle runtime
|
|
3
|
+
*/
|
|
4
|
+
export { UcanModule } from './ucan.module.js';
|
|
5
|
+
export { UcanService } from './ucan.service.js';
|
|
6
|
+
export { createMCPUCANConfig, requiresUCANAuth, buildRequiredCapability, loadUCANConfigFromEnv, } from './ucan.config.js';
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview UCAN configuration for Oracle MCP endpoints
|
|
3
|
+
*
|
|
4
|
+
* This module defines the UCAN authorization requirements for MCP tools.
|
|
5
|
+
* Each MCP server/tool can be configured to require UCAN authorization.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* MCP capability actions
|
|
9
|
+
*/
|
|
10
|
+
type MCPAction = 'mcp/call' | 'mcp/*';
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for MCP tool UCAN requirements
|
|
13
|
+
*/
|
|
14
|
+
interface MCPUCANRequirement {
|
|
15
|
+
/** The action required (e.g., 'mcp/call') */
|
|
16
|
+
can: MCPAction;
|
|
17
|
+
/** Pattern for the resource URI */
|
|
18
|
+
withPattern: string;
|
|
19
|
+
/** Whether this MCP server/tool requires UCAN authorization */
|
|
20
|
+
requiresAuth: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Map of MCP server names to their UCAN requirements
|
|
24
|
+
*/
|
|
25
|
+
export interface MCPUCANConfig {
|
|
26
|
+
/** This oracle's DID (will be the audience for invocations) */
|
|
27
|
+
oracleDid: string;
|
|
28
|
+
/** Root DIDs allowed to self-issue capabilities */
|
|
29
|
+
rootIssuers: string[];
|
|
30
|
+
/** Per-MCP-server authorization requirements */
|
|
31
|
+
requirements: Record<string, MCPUCANRequirement>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create the UCAN configuration for this oracle
|
|
35
|
+
*
|
|
36
|
+
* @param oracleDid - The oracle's DID (audience for invocations)
|
|
37
|
+
* @param rootIssuers - DIDs allowed to be root issuers
|
|
38
|
+
* @param protectedServers - Map of MCP server names to whether they require UCAN
|
|
39
|
+
* @returns The complete UCAN configuration
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const config = createMCPUCANConfig(
|
|
44
|
+
* 'did:ixo:oracle123',
|
|
45
|
+
* ['did:ixo:admin'],
|
|
46
|
+
* {
|
|
47
|
+
* postgres: true, // Requires UCAN
|
|
48
|
+
* filesystem: false, // No UCAN required
|
|
49
|
+
* }
|
|
50
|
+
* );
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function createMCPUCANConfig(oracleDid: string, rootIssuers: string[], protectedServers?: Record<string, boolean>): MCPUCANConfig;
|
|
54
|
+
/**
|
|
55
|
+
* Check if an MCP tool requires UCAN authorization
|
|
56
|
+
*
|
|
57
|
+
* @param config - The UCAN configuration
|
|
58
|
+
* @param serverName - The MCP server name
|
|
59
|
+
* @param toolName - The tool name (optional, for tool-level checks)
|
|
60
|
+
* @returns Whether the tool requires UCAN authorization
|
|
61
|
+
*/
|
|
62
|
+
export declare function requiresUCANAuth(config: MCPUCANConfig, serverName: string, _toolName?: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Build the required capability for an MCP tool
|
|
65
|
+
*
|
|
66
|
+
* @param config - The UCAN configuration
|
|
67
|
+
* @param serverName - The MCP server name
|
|
68
|
+
* @param toolName - The tool name
|
|
69
|
+
* @returns The required capability object
|
|
70
|
+
*/
|
|
71
|
+
export declare function buildRequiredCapability(config: MCPUCANConfig, serverName: string, toolName: string): {
|
|
72
|
+
can: string;
|
|
73
|
+
with: string;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Environment-based configuration loader
|
|
77
|
+
*
|
|
78
|
+
* Reads UCAN configuration from environment variables:
|
|
79
|
+
* - ORACLE_ENTITY_DID: The oracle's DID
|
|
80
|
+
* - UCAN_ROOT_ISSUERS: Comma-separated list of root issuer DIDs
|
|
81
|
+
* - UCAN_PROTECTED_MCP_SERVERS: Comma-separated list of MCP server names that require UCAN
|
|
82
|
+
*
|
|
83
|
+
* @returns The UCAN configuration from environment
|
|
84
|
+
*/
|
|
85
|
+
export declare function loadUCANConfigFromEnv(): MCPUCANConfig;
|
|
86
|
+
export {};
|
|
87
|
+
//# sourceMappingURL=ucan.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ucan.config.d.ts","sourceRoot":"","sources":["../../../src/modules/ucan/ucan.config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,KAAK,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC;AAEtC;;GAEG;AACH,UAAU,kBAAkB;IAC1B,6CAA6C;IAC7C,GAAG,EAAE,SAAS,CAAC;IACf,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,+DAA+D;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,gDAAgD;IAChD,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CAClD;AAYD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EAAE,EACrB,gBAAgB,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAC7C,aAAa,CAef;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAQT;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAa/B;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,IAAI,aAAa,CAmBrD"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview UCAN configuration for Oracle MCP endpoints
|
|
3
|
+
*
|
|
4
|
+
* This module defines the UCAN authorization requirements for MCP tools.
|
|
5
|
+
* Each MCP server/tool can be configured to require UCAN authorization.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default UCAN requirement for MCP tools
|
|
9
|
+
* Requires the 'mcp/call' action on the specific tool resource
|
|
10
|
+
*/
|
|
11
|
+
const defaultMCPRequirement = {
|
|
12
|
+
can: 'mcp/call',
|
|
13
|
+
// Pattern: ixo:oracle:{oracleDid}:mcp/{serverName}/{toolName}
|
|
14
|
+
withPattern: 'ixo:oracle:{oracleDid}:mcp/{serverName}/{toolName}',
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Create the UCAN configuration for this oracle
|
|
18
|
+
*
|
|
19
|
+
* @param oracleDid - The oracle's DID (audience for invocations)
|
|
20
|
+
* @param rootIssuers - DIDs allowed to be root issuers
|
|
21
|
+
* @param protectedServers - Map of MCP server names to whether they require UCAN
|
|
22
|
+
* @returns The complete UCAN configuration
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const config = createMCPUCANConfig(
|
|
27
|
+
* 'did:ixo:oracle123',
|
|
28
|
+
* ['did:ixo:admin'],
|
|
29
|
+
* {
|
|
30
|
+
* postgres: true, // Requires UCAN
|
|
31
|
+
* filesystem: false, // No UCAN required
|
|
32
|
+
* }
|
|
33
|
+
* );
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function createMCPUCANConfig(oracleDid, rootIssuers, protectedServers = {}) {
|
|
37
|
+
const requirements = {};
|
|
38
|
+
for (const [serverName, requiresAuth] of Object.entries(protectedServers)) {
|
|
39
|
+
requirements[serverName] = {
|
|
40
|
+
...defaultMCPRequirement,
|
|
41
|
+
requiresAuth,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
oracleDid,
|
|
46
|
+
rootIssuers,
|
|
47
|
+
requirements,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Check if an MCP tool requires UCAN authorization
|
|
52
|
+
*
|
|
53
|
+
* @param config - The UCAN configuration
|
|
54
|
+
* @param serverName - The MCP server name
|
|
55
|
+
* @param toolName - The tool name (optional, for tool-level checks)
|
|
56
|
+
* @returns Whether the tool requires UCAN authorization
|
|
57
|
+
*/
|
|
58
|
+
export function requiresUCANAuth(config, serverName, _toolName) {
|
|
59
|
+
const requirement = config.requirements[serverName];
|
|
60
|
+
if (!requirement) {
|
|
61
|
+
// Default: no UCAN required for unconfigured servers
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
return requirement.requiresAuth;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Build the required capability for an MCP tool
|
|
68
|
+
*
|
|
69
|
+
* @param config - The UCAN configuration
|
|
70
|
+
* @param serverName - The MCP server name
|
|
71
|
+
* @param toolName - The tool name
|
|
72
|
+
* @returns The required capability object
|
|
73
|
+
*/
|
|
74
|
+
export function buildRequiredCapability(config, serverName, toolName) {
|
|
75
|
+
const requirement = config.requirements[serverName] ?? defaultMCPRequirement;
|
|
76
|
+
// Replace placeholders in the pattern
|
|
77
|
+
const withUri = requirement.withPattern
|
|
78
|
+
.replace('{oracleDid}', config.oracleDid)
|
|
79
|
+
.replace('{serverName}', serverName)
|
|
80
|
+
.replace('{toolName}', toolName);
|
|
81
|
+
return {
|
|
82
|
+
can: requirement.can,
|
|
83
|
+
with: withUri,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Environment-based configuration loader
|
|
88
|
+
*
|
|
89
|
+
* Reads UCAN configuration from environment variables:
|
|
90
|
+
* - ORACLE_ENTITY_DID: The oracle's DID
|
|
91
|
+
* - UCAN_ROOT_ISSUERS: Comma-separated list of root issuer DIDs
|
|
92
|
+
* - UCAN_PROTECTED_MCP_SERVERS: Comma-separated list of MCP server names that require UCAN
|
|
93
|
+
*
|
|
94
|
+
* @returns The UCAN configuration from environment
|
|
95
|
+
*/
|
|
96
|
+
export function loadUCANConfigFromEnv() {
|
|
97
|
+
const oracleDid = process.env.ORACLE_ENTITY_DID ?? '';
|
|
98
|
+
const rootIssuers = (process.env.UCAN_ROOT_ISSUERS ?? '')
|
|
99
|
+
.split(',')
|
|
100
|
+
.map((s) => s.trim())
|
|
101
|
+
.filter(Boolean);
|
|
102
|
+
const protectedServerNames = (process.env.UCAN_PROTECTED_MCP_SERVERS ?? '')
|
|
103
|
+
.split(',')
|
|
104
|
+
.map((s) => s.trim())
|
|
105
|
+
.filter(Boolean);
|
|
106
|
+
const protectedServers = {};
|
|
107
|
+
for (const serverName of protectedServerNames) {
|
|
108
|
+
protectedServers[serverName] = true;
|
|
109
|
+
}
|
|
110
|
+
return createMCPUCANConfig(oracleDid, rootIssuers, protectedServers);
|
|
111
|
+
}
|
|
112
|
+
// TODO: Add support for per-tool authorization requirements
|
|
113
|
+
// TODO: Add support for capability caveats (e.g., rate limiting)
|
|
114
|
+
// TODO: Add support for time-based restrictions
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview UCAN module for Oracle
|
|
3
|
+
*
|
|
4
|
+
* This module provides UCAN authorization services for the Oracle application.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* UCAN Module
|
|
8
|
+
*
|
|
9
|
+
* Provides UCAN authorization services for MCP tool invocations.
|
|
10
|
+
* Marked as @Global so the UcanService can be injected anywhere.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // In your app.module.ts
|
|
15
|
+
* @Module({
|
|
16
|
+
* imports: [UcanModule],
|
|
17
|
+
* })
|
|
18
|
+
* export class AppModule {}
|
|
19
|
+
*
|
|
20
|
+
* // Then inject UcanService where needed
|
|
21
|
+
* @Injectable()
|
|
22
|
+
* class MyService {
|
|
23
|
+
* constructor(private readonly ucanService: UcanService) {}
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class UcanModule {
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ucan.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ucan.module.d.ts","sourceRoot":"","sources":["../../../src/modules/ucan/ucan.module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAMa,UAAU;CAAG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview UCAN module for Oracle
|
|
3
|
+
*
|
|
4
|
+
* This module provides UCAN authorization services for the Oracle application.
|
|
5
|
+
*/
|
|
6
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
9
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
import { Global, Module } from '@nestjs/common';
|
|
13
|
+
import { ConfigModule } from '@nestjs/config';
|
|
14
|
+
import { UcanService } from './ucan.service.js';
|
|
15
|
+
/**
|
|
16
|
+
* UCAN Module
|
|
17
|
+
*
|
|
18
|
+
* Provides UCAN authorization services for MCP tool invocations.
|
|
19
|
+
* Marked as @Global so the UcanService can be injected anywhere.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // In your app.module.ts
|
|
24
|
+
* @Module({
|
|
25
|
+
* imports: [UcanModule],
|
|
26
|
+
* })
|
|
27
|
+
* export class AppModule {}
|
|
28
|
+
*
|
|
29
|
+
* // Then inject UcanService where needed
|
|
30
|
+
* @Injectable()
|
|
31
|
+
* class MyService {
|
|
32
|
+
* constructor(private readonly ucanService: UcanService) {}
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
let UcanModule = class UcanModule {
|
|
37
|
+
};
|
|
38
|
+
UcanModule = __decorate([
|
|
39
|
+
Global(),
|
|
40
|
+
Module({
|
|
41
|
+
imports: [ConfigModule],
|
|
42
|
+
providers: [UcanService],
|
|
43
|
+
exports: [UcanService],
|
|
44
|
+
})
|
|
45
|
+
], UcanModule);
|
|
46
|
+
export { UcanModule };
|