@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,530 @@
|
|
|
1
|
+
import { MatrixManager } from '@ixo/matrix';
|
|
2
|
+
import { loadEncryptionKey, setupClaimSigningMnemonics, } from '@ixo/oracles-chain-client';
|
|
3
|
+
import { SqliteSaver } from '@ixo/sqlite-saver';
|
|
4
|
+
import { Logger, ValidationPipe, } from '@nestjs/common';
|
|
5
|
+
import { NestFactory } from '@nestjs/core';
|
|
6
|
+
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
|
7
|
+
import pkg from '../../package.json' with { type: 'json' };
|
|
8
|
+
import { baseEnvSchema, validateLlmProviderKey, } from '../config/base-env-schema.js';
|
|
9
|
+
import { getModelForRole, getProviderConfig } from '../llm/llm-provider.js';
|
|
10
|
+
import { validateManifest } from '../manifest/validator.js';
|
|
11
|
+
import { UserMatrixSqliteSyncService } from '../matrix/checkpointer/user-matrix-sqlite-sync-service.service.js';
|
|
12
|
+
import { setFileProcessingProvider } from '../modules/messages/file-processing.service.js';
|
|
13
|
+
import { OracleRuntimeBundleHolder } from '../modules/messages/oracle-runtime-bundle.js';
|
|
14
|
+
import { SecretsService } from '../modules/secrets/secrets.service.js';
|
|
15
|
+
import { UcanService } from '../modules/ucan/ucan.service.js';
|
|
16
|
+
import { BUNDLED_PLUGINS } from '../plugins/index.js';
|
|
17
|
+
import { buildPluginContext } from '../runtime-context/build-plugin.js';
|
|
18
|
+
import { buildAmbientServices } from './ambient-factory.js';
|
|
19
|
+
import { ConfigSchemaRegistry, ManifestRegistry, MiddlewareRegistry, SharedStateRegistry, SubAgentRegistry, ToolRegistry, } from '../registries/index.js';
|
|
20
|
+
import { registerGracefulShutdown } from './graceful-shutdown.js';
|
|
21
|
+
import { resolvePlugins, } from './plugin-loader.js';
|
|
22
|
+
import { RuntimeAppModule } from './runtime-app-module.js';
|
|
23
|
+
import { composeEnvSchema, validateEnv } from './schema-composer.js';
|
|
24
|
+
function reportBootError(logger, message, hint) {
|
|
25
|
+
const body = hint ? `${message}\n ${hint}` : message;
|
|
26
|
+
logger.error(`[boot-error] ${body}`);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolve plugins, validate env, populate registries, build the dynamic
|
|
30
|
+
* `RuntimeAppModule`, bootstrap NestJS (without listening) and return an
|
|
31
|
+
* `OracleApp` whose `listen()` runs `beforeListen` callbacks then starts
|
|
32
|
+
* the HTTP server.
|
|
33
|
+
*
|
|
34
|
+
* Matrix initialization runs in the background — the returned promise
|
|
35
|
+
* resolves as soon as Nest is built. Status flips via
|
|
36
|
+
* `onPluginStatusChange`.
|
|
37
|
+
*/
|
|
38
|
+
export async function createOracleApp(opts) {
|
|
39
|
+
validateConfig(opts.config);
|
|
40
|
+
const logger = opts.logger ?? new Logger('createOracleApp');
|
|
41
|
+
const env = opts.env ?? process.env;
|
|
42
|
+
const userPlugins = opts.plugins ?? [];
|
|
43
|
+
const bundled = opts.bundledPlugins ?? [...BUNDLED_PLUGINS];
|
|
44
|
+
// 1-3. Plugin resolution + topo + soft-dep logging
|
|
45
|
+
let resolved;
|
|
46
|
+
try {
|
|
47
|
+
resolved = resolvePlugins({
|
|
48
|
+
bundled,
|
|
49
|
+
userPlugins,
|
|
50
|
+
features: opts.features,
|
|
51
|
+
env,
|
|
52
|
+
logger,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
reportBootError(logger, err instanceof Error ? err.message : String(err));
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
// 4. Manifest validation
|
|
60
|
+
const manifestErrors = [];
|
|
61
|
+
for (const plugin of resolved.loaded) {
|
|
62
|
+
const result = validateManifest(plugin.manifest, plugin.name);
|
|
63
|
+
if (!result.valid)
|
|
64
|
+
manifestErrors.push(...result.errors);
|
|
65
|
+
}
|
|
66
|
+
if (manifestErrors.length > 0) {
|
|
67
|
+
for (const err of manifestErrors)
|
|
68
|
+
reportBootError(logger, err);
|
|
69
|
+
throw new Error(`Plugin manifest validation failed (${manifestErrors.length} issues).`);
|
|
70
|
+
}
|
|
71
|
+
// 5. Schema merge + env validation
|
|
72
|
+
const composed = composeEnvSchema(resolved.loaded, baseEnvSchema, logger);
|
|
73
|
+
const validated = validateEnv(composed.schema, env, composed.pluginOwnership);
|
|
74
|
+
if (!validated.valid) {
|
|
75
|
+
for (const issue of validated.errors) {
|
|
76
|
+
reportBootError(logger, `Plugin '${issue.plugin}' env validation failed for '${issue.field}': ${issue.message}`, `Set '${issue.field}' or disable: features: { ${issue.plugin}: false }`);
|
|
77
|
+
}
|
|
78
|
+
throw new Error(`Env validation failed (${validated.errors.length} issues).`);
|
|
79
|
+
}
|
|
80
|
+
// Cross-field check the merged schema cannot express — the selected
|
|
81
|
+
// LLM_PROVIDER must have its API key set. Surfaced here so the message
|
|
82
|
+
// names the missing field exactly (`OPEN_ROUTER_API_KEY` / `NEBIUS_API_KEY`).
|
|
83
|
+
const llmKeyErrors = validateLlmProviderKey(validated.config);
|
|
84
|
+
if (llmKeyErrors.length > 0) {
|
|
85
|
+
for (const issue of llmKeyErrors) {
|
|
86
|
+
reportBootError(logger, `LLM provider env validation failed for '${issue.field}': ${issue.message}`);
|
|
87
|
+
}
|
|
88
|
+
throw new Error(`Env validation failed (${llmKeyErrors.length} issue${llmKeyErrors.length === 1 ? '' : 's'}).`);
|
|
89
|
+
}
|
|
90
|
+
// 5a. Build the internal identity from config + validated env. Defer until
|
|
91
|
+
// here so `ORACLE_ENTITY_DID` has been parsed by the base env schema —
|
|
92
|
+
// a missing/empty value fails validation above with a clear message.
|
|
93
|
+
const entityDid = String(validated.config.ORACLE_ENTITY_DID ?? '');
|
|
94
|
+
if (!entityDid) {
|
|
95
|
+
throw new Error('createOracleApp: ORACLE_ENTITY_DID env is required and was empty after validation.');
|
|
96
|
+
}
|
|
97
|
+
const identity = {
|
|
98
|
+
name: opts.config.name,
|
|
99
|
+
org: opts.config.org ?? '',
|
|
100
|
+
description: opts.config.description ?? '',
|
|
101
|
+
entityDid,
|
|
102
|
+
prompt: opts.config.prompt ?? {},
|
|
103
|
+
};
|
|
104
|
+
// 6. Registry population
|
|
105
|
+
const registries = {
|
|
106
|
+
tools: new ToolRegistry(),
|
|
107
|
+
subAgents: new SubAgentRegistry(),
|
|
108
|
+
middlewares: new MiddlewareRegistry(),
|
|
109
|
+
manifests: new ManifestRegistry(),
|
|
110
|
+
configSchema: new ConfigSchemaRegistry(),
|
|
111
|
+
sharedState: new SharedStateRegistry(),
|
|
112
|
+
};
|
|
113
|
+
for (const plugin of resolved.loaded) {
|
|
114
|
+
registries.tools.register(plugin);
|
|
115
|
+
registries.subAgents.register(plugin);
|
|
116
|
+
registries.middlewares.register(plugin);
|
|
117
|
+
registries.manifests.register(plugin);
|
|
118
|
+
registries.configSchema.register(plugin);
|
|
119
|
+
registries.sharedState.register(plugin);
|
|
120
|
+
}
|
|
121
|
+
// 7. NestJS bootstrap
|
|
122
|
+
const enableSubscription = resolved.loaded.some((p) => p.name === 'credits');
|
|
123
|
+
const loadedPluginNames = new Set(resolved.loaded.map((p) => p.name));
|
|
124
|
+
const pluginNestModules = resolved.loaded.flatMap((p) => {
|
|
125
|
+
const ctx = buildPluginContext({
|
|
126
|
+
config: validated.config,
|
|
127
|
+
identity,
|
|
128
|
+
availablePlugins: loadedPluginNames,
|
|
129
|
+
logger,
|
|
130
|
+
pluginName: p.name,
|
|
131
|
+
});
|
|
132
|
+
return p.getNestModules?.(ctx) ?? [];
|
|
133
|
+
});
|
|
134
|
+
// Merge plugin-declared exclusions with host-declared ones (from opts).
|
|
135
|
+
// Both flow into the same `RuntimeAppModule` configurer so the runtime
|
|
136
|
+
// doesn't care whose route is opted out — only that it is.
|
|
137
|
+
const pluginAuthExclusions = [
|
|
138
|
+
...resolved.loaded.flatMap((p) => p.getAuthExcludedRoutes?.() ?? []),
|
|
139
|
+
...(opts.authExcludedRoutes ?? []),
|
|
140
|
+
];
|
|
141
|
+
const appModule = RuntimeAppModule.register({
|
|
142
|
+
validatedEnv: validated.config,
|
|
143
|
+
userNestModules: opts.nestModules,
|
|
144
|
+
pluginNestModules,
|
|
145
|
+
pluginAuthExclusions,
|
|
146
|
+
enableSubscriptionMiddleware: enableSubscription,
|
|
147
|
+
});
|
|
148
|
+
// Wire the file-processing LLM provider getter BEFORE Nest constructs
|
|
149
|
+
// `FileProcessingService`. The service's module-level getter throws on
|
|
150
|
+
// first call until this runs — has to happen pre-bootstrap.
|
|
151
|
+
// Uses the same OpenRouter / Nebius config + 'vision' role mapping the
|
|
152
|
+
// legacy apps/app wired up.
|
|
153
|
+
setFileProcessingProvider(() => {
|
|
154
|
+
const cfg = getProviderConfig();
|
|
155
|
+
return {
|
|
156
|
+
apiKey: cfg.apiKey,
|
|
157
|
+
baseURL: cfg.baseURL,
|
|
158
|
+
headers: cfg.headers,
|
|
159
|
+
model: getModelForRole('vision'),
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
const nestApp = await NestFactory.create(appModule, {
|
|
163
|
+
bufferLogs: false,
|
|
164
|
+
});
|
|
165
|
+
// Global validation — enforce every controller's `class-validator` DTO
|
|
166
|
+
// decorators. Without this, decorators like `@Matches`, `@ArrayMaxSize`,
|
|
167
|
+
// and `@IsNotEmpty` are inert and arbitrary body fields flow straight into
|
|
168
|
+
// graph state. `whitelist` strips unknown props, `forbidNonWhitelisted`
|
|
169
|
+
// rejects them outright, `transform` instantiates nested `@Type` DTOs so
|
|
170
|
+
// `@ValidateNested` actually runs. Guarded for the same reason as Swagger
|
|
171
|
+
// (lightweight test runtimes stub `NestFactory.create`).
|
|
172
|
+
if (typeof nestApp.useGlobalPipes === 'function') {
|
|
173
|
+
nestApp.useGlobalPipes(new ValidationPipe({
|
|
174
|
+
whitelist: true,
|
|
175
|
+
forbidNonWhitelisted: true,
|
|
176
|
+
transform: true,
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
// CORS — auth flows from the browser need `x-ucan-delegation` allowed.
|
|
180
|
+
// `credentials: true` requires a specific origin (not `*`); when the
|
|
181
|
+
// host configures a wildcard we disable credentials so the browser
|
|
182
|
+
// doesn't reject the preflight. Guarded for the same reason as Swagger
|
|
183
|
+
// (test runtimes stub `NestFactory.create`).
|
|
184
|
+
if (typeof nestApp.enableCors === 'function') {
|
|
185
|
+
const corsOrigin = typeof validated.config.CORS_ORIGIN === 'string' &&
|
|
186
|
+
validated.config.CORS_ORIGIN.length > 0
|
|
187
|
+
? validated.config.CORS_ORIGIN
|
|
188
|
+
: '*';
|
|
189
|
+
const useCredentials = corsOrigin !== '*';
|
|
190
|
+
nestApp.enableCors({
|
|
191
|
+
origin: corsOrigin,
|
|
192
|
+
credentials: useCredentials,
|
|
193
|
+
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
|
|
194
|
+
allowedHeaders: [
|
|
195
|
+
'Content-Type',
|
|
196
|
+
'Authorization',
|
|
197
|
+
'x-ucan-delegation',
|
|
198
|
+
'x-matrix-access-token',
|
|
199
|
+
'x-matrix-homeserver',
|
|
200
|
+
'x-did',
|
|
201
|
+
'x-request-id',
|
|
202
|
+
'x-timezone',
|
|
203
|
+
],
|
|
204
|
+
exposedHeaders: ['X-Request-Id'],
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
// Swagger UI at `/docs`. Auth middleware already excludes `/docs` and
|
|
208
|
+
// `/docs/(.*)`. Forks can replace by registering their own setup in a
|
|
209
|
+
// `beforeListen` hook.
|
|
210
|
+
//
|
|
211
|
+
// Guarded because lightweight test runtimes stub `NestFactory.create`
|
|
212
|
+
// with an object that lacks `getHttpAdapter` — Swagger introspects the
|
|
213
|
+
// adapter to know whether it's express/fastify. In production both are
|
|
214
|
+
// present.
|
|
215
|
+
try {
|
|
216
|
+
const swaggerDoc = SwaggerModule.createDocument(nestApp, new DocumentBuilder()
|
|
217
|
+
.setTitle(identity.name)
|
|
218
|
+
.setDescription(`${identity.description}\n\nQiForge runtime v${pkg.version}.`)
|
|
219
|
+
.setVersion(pkg.version)
|
|
220
|
+
.addApiKey({ type: 'apiKey', name: 'x-ucan-delegation', in: 'header' }, 'ucan')
|
|
221
|
+
.build());
|
|
222
|
+
SwaggerModule.setup('docs', nestApp, swaggerDoc);
|
|
223
|
+
}
|
|
224
|
+
catch (err) {
|
|
225
|
+
logger.warn?.(`[createOracleApp] Swagger setup skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
226
|
+
}
|
|
227
|
+
// 8. AmbientServices — built once Nest's DI container exists. Plugins reach
|
|
228
|
+
// this through `buildRuntimeContext(runConfig, ambient, state)`, wired by
|
|
229
|
+
// the messages controller on a per-request basis.
|
|
230
|
+
const ambient = buildAmbientServices({
|
|
231
|
+
nestApp,
|
|
232
|
+
config: validated.config,
|
|
233
|
+
identity,
|
|
234
|
+
availablePlugins: loadedPluginNames,
|
|
235
|
+
logger,
|
|
236
|
+
});
|
|
237
|
+
// 9. Warm the boot caches inside each registry so the per-request agent
|
|
238
|
+
// build only re-runs the request-time hooks (`getRequestTools`,
|
|
239
|
+
// `getRequestSubAgents`). Boot-time outputs are identical for every
|
|
240
|
+
// request and don't need to be recomputed.
|
|
241
|
+
const warmBuildCtx = buildPluginContext({
|
|
242
|
+
config: validated.config,
|
|
243
|
+
identity,
|
|
244
|
+
availablePlugins: loadedPluginNames,
|
|
245
|
+
logger,
|
|
246
|
+
pluginName: '__runtime__',
|
|
247
|
+
});
|
|
248
|
+
await registries.tools.collectBoot(warmBuildCtx);
|
|
249
|
+
registries.subAgents.collectBoot(warmBuildCtx);
|
|
250
|
+
registries.middlewares.collect(warmBuildCtx);
|
|
251
|
+
// Fail the boot if two plugins contribute the same tool name, sub-agent
|
|
252
|
+
// name, or shared-state key. Without this, a collision is silently
|
|
253
|
+
// resolved last-write-wins: the agent binds duplicate tools and the
|
|
254
|
+
// capability gate mis-attributes one of them, leaving it unreachable.
|
|
255
|
+
// Only the boot-time contributions are checked here — request-time tools
|
|
256
|
+
// (`getRequestTools`) are per-user and dynamic, so a static cross-plugin
|
|
257
|
+
// assertion can't cover them.
|
|
258
|
+
registries.tools.assertNoCollisions();
|
|
259
|
+
registries.subAgents.assertNoCollisions();
|
|
260
|
+
registries.sharedState.assertNoCollisions();
|
|
261
|
+
// 10. Build the merged hooks the agent build will use:
|
|
262
|
+
// - default: per-user SQLite checkpointer backed by
|
|
263
|
+
// `UserMatrixSqliteSyncService` (already DI-managed)
|
|
264
|
+
// - override: anything the host passed in `opts.hooks` wins
|
|
265
|
+
//
|
|
266
|
+
// The merged hooks live inside the bundle so `agent-builder.ts` reads
|
|
267
|
+
// them through `bundle.hooks` without ever rewriting the contract.
|
|
268
|
+
const checkpointSync = nestApp.get(UserMatrixSqliteSyncService, {
|
|
269
|
+
strict: false,
|
|
270
|
+
});
|
|
271
|
+
const defaultHooks = checkpointSync
|
|
272
|
+
? {
|
|
273
|
+
checkpointerForUser: async (userDid) => {
|
|
274
|
+
const db = await checkpointSync.getUserDatabase(userDid);
|
|
275
|
+
// Cross-package interop: SqliteSaver extends BaseCheckpointSaver
|
|
276
|
+
// from `@langchain/langgraph-checkpoint`; the hook return type
|
|
277
|
+
// pulls from `@langchain/langgraph`. pnpm hoists these into
|
|
278
|
+
// separate type identities even at the same version — they are
|
|
279
|
+
// structurally identical at runtime.
|
|
280
|
+
return SqliteSaver.fromDatabase(db);
|
|
281
|
+
},
|
|
282
|
+
}
|
|
283
|
+
: {};
|
|
284
|
+
const mergedHooks = { ...defaultHooks, ...opts.hooks };
|
|
285
|
+
// 11. Populate the OracleRuntimeBundleHolder so MessagesService (and any
|
|
286
|
+
// other Nest-managed consumer) can grab the boot-snapshot per request.
|
|
287
|
+
// `strict: false` so we get `undefined` instead of throwing when the
|
|
288
|
+
// holder isn't registered (lightweight test runtimes that skip
|
|
289
|
+
// MessagesModule). In that case the bundle is just not available.
|
|
290
|
+
const bundleHolder = nestApp.get(OracleRuntimeBundleHolder, {
|
|
291
|
+
strict: false,
|
|
292
|
+
});
|
|
293
|
+
if (bundleHolder) {
|
|
294
|
+
bundleHolder.populate({
|
|
295
|
+
ambient,
|
|
296
|
+
registries,
|
|
297
|
+
identity,
|
|
298
|
+
config: validated.config,
|
|
299
|
+
availablePlugins: loadedPluginNames,
|
|
300
|
+
hooks: mergedHooks,
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
// 12. Background Matrix init — fire-and-forget.
|
|
304
|
+
const beforeListenHooks = [];
|
|
305
|
+
const errorHandlers = [];
|
|
306
|
+
const statusHandlers = [];
|
|
307
|
+
const dispatchError = (err, source) => {
|
|
308
|
+
if (errorHandlers.length === 0) {
|
|
309
|
+
logger.error(`[${source}] ${err.message}`);
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
for (const handler of errorHandlers) {
|
|
313
|
+
try {
|
|
314
|
+
handler(err, source);
|
|
315
|
+
}
|
|
316
|
+
catch (callbackErr) {
|
|
317
|
+
logger.error(`onError handler threw: ${String(callbackErr)}`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
const dispatchStatus = (evt) => {
|
|
322
|
+
for (const handler of statusHandlers) {
|
|
323
|
+
try {
|
|
324
|
+
handler(evt);
|
|
325
|
+
}
|
|
326
|
+
catch (callbackErr) {
|
|
327
|
+
logger.error(`onPluginStatusChange handler threw: ${String(callbackErr)}`);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
if (!opts.skipMatrixInit) {
|
|
332
|
+
const matrixManager = MatrixManager.getInstance();
|
|
333
|
+
// Defer to the next macrotask so callers can attach
|
|
334
|
+
// `onPluginStatusChange` / `onError` handlers before the first event
|
|
335
|
+
// fires. The init itself is still asynchronous and does not block the
|
|
336
|
+
// returned promise.
|
|
337
|
+
setImmediate(() => {
|
|
338
|
+
dispatchStatus({ plugin: 'matrix', from: 'pending', to: 'pending' });
|
|
339
|
+
matrixManager
|
|
340
|
+
.init()
|
|
341
|
+
.then(async () => {
|
|
342
|
+
// Matrix is up. Load the UCAN signing mnemonic + (optional)
|
|
343
|
+
// user-secrets encryption key from the oracle's Matrix account
|
|
344
|
+
// room. Both rely on Matrix state events as the source of truth,
|
|
345
|
+
// so this MUST run after init.
|
|
346
|
+
//
|
|
347
|
+
// The signing mnemonic enables `UcanService.createServiceInvocation`
|
|
348
|
+
// → which the credits/subscription middleware needs on the very
|
|
349
|
+
// first authenticated request. Failing this step silently is the
|
|
350
|
+
// origin of "UCAN signing key not configured" errors mid-flight.
|
|
351
|
+
//
|
|
352
|
+
// Wrapped in try/catch so a key-setup failure (e.g. test env
|
|
353
|
+
// without real Matrix state events) doesn't block the
|
|
354
|
+
// `matrix:loaded` status dispatch — auth-requiring routes will
|
|
355
|
+
// 401 until the operator provisions the keys, but the rest of
|
|
356
|
+
// the app stays usable (health, docs, ws).
|
|
357
|
+
try {
|
|
358
|
+
await wireSigningAndEncryptionKeys({
|
|
359
|
+
nestApp,
|
|
360
|
+
config: validated.config,
|
|
361
|
+
logger,
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
catch (err) {
|
|
365
|
+
logger.error?.(`[boot] key setup failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
366
|
+
}
|
|
367
|
+
dispatchStatus({ plugin: 'matrix', from: 'pending', to: 'loaded' });
|
|
368
|
+
})
|
|
369
|
+
.catch((err) => {
|
|
370
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
371
|
+
dispatchStatus({
|
|
372
|
+
plugin: 'matrix',
|
|
373
|
+
from: 'pending',
|
|
374
|
+
to: 'failed',
|
|
375
|
+
reason: error.message,
|
|
376
|
+
});
|
|
377
|
+
dispatchError(error, 'matrix-init');
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
if (!opts.skipGracefulShutdown) {
|
|
381
|
+
registerGracefulShutdown({ app: nestApp, matrixManager });
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
// Public surface
|
|
385
|
+
const statusReport = () => ({
|
|
386
|
+
loaded: resolved.loaded.map((p) => p.name),
|
|
387
|
+
excluded: resolved.excluded.map((e) => ({
|
|
388
|
+
plugin: e.plugin,
|
|
389
|
+
reason: e.reason,
|
|
390
|
+
})),
|
|
391
|
+
softDepGaps: resolved.softDepGaps.map((s) => ({
|
|
392
|
+
plugin: s.plugin,
|
|
393
|
+
missing: s.missing,
|
|
394
|
+
})),
|
|
395
|
+
});
|
|
396
|
+
let started = false;
|
|
397
|
+
return {
|
|
398
|
+
getNestApp() {
|
|
399
|
+
return nestApp;
|
|
400
|
+
},
|
|
401
|
+
ambient,
|
|
402
|
+
plugins: {
|
|
403
|
+
status: statusReport,
|
|
404
|
+
},
|
|
405
|
+
beforeListen(fn) {
|
|
406
|
+
beforeListenHooks.push(fn);
|
|
407
|
+
},
|
|
408
|
+
onError(handler) {
|
|
409
|
+
errorHandlers.push(handler);
|
|
410
|
+
},
|
|
411
|
+
onPluginStatusChange(handler) {
|
|
412
|
+
statusHandlers.push(handler);
|
|
413
|
+
},
|
|
414
|
+
async listen(port) {
|
|
415
|
+
if (started) {
|
|
416
|
+
throw new Error('OracleApp.listen called twice.');
|
|
417
|
+
}
|
|
418
|
+
started = true;
|
|
419
|
+
for (const hook of beforeListenHooks) {
|
|
420
|
+
await hook(nestApp);
|
|
421
|
+
}
|
|
422
|
+
const portValue = port ??
|
|
423
|
+
coercePort(validated.config.PORT) ??
|
|
424
|
+
coercePort(env.PORT) ??
|
|
425
|
+
5678;
|
|
426
|
+
await nestApp.listen(portValue, '0.0.0.0');
|
|
427
|
+
logger.log(`Oracle '${identity.name}' (runtime v${pkg.version}) listening on :${portValue}`);
|
|
428
|
+
},
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
function validateConfig(config) {
|
|
432
|
+
if (!config) {
|
|
433
|
+
throw new Error("createOracleApp: 'config' is required.");
|
|
434
|
+
}
|
|
435
|
+
if (!config.name) {
|
|
436
|
+
throw new Error("createOracleApp: 'config.name' is required.");
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
function coercePort(value) {
|
|
440
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
441
|
+
return value;
|
|
442
|
+
if (typeof value === 'string' && value.length > 0) {
|
|
443
|
+
const parsed = Number.parseInt(value, 10);
|
|
444
|
+
if (Number.isFinite(parsed))
|
|
445
|
+
return parsed;
|
|
446
|
+
}
|
|
447
|
+
return undefined;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* After Matrix init succeeds, load the oracle's UCAN signing mnemonic and
|
|
451
|
+
* (optional) P-256 secrets encryption key from the oracle's Matrix account
|
|
452
|
+
* room, and seat them on the corresponding services.
|
|
453
|
+
*
|
|
454
|
+
* Without the signing mnemonic the credits/subscription middleware can't
|
|
455
|
+
* mint downstream invocations — every authenticated request would fail at
|
|
456
|
+
* the gate. Without the encryption key, the user-secrets read path skips
|
|
457
|
+
* silently and returns nothing (acceptable degraded mode).
|
|
458
|
+
*/
|
|
459
|
+
async function wireSigningAndEncryptionKeys(args) {
|
|
460
|
+
const { nestApp, config, logger } = args;
|
|
461
|
+
const need = (key) => {
|
|
462
|
+
const value = config[key];
|
|
463
|
+
if (typeof value !== 'string' || value.length === 0) {
|
|
464
|
+
throw new Error(`[boot] missing required env '${key}' for key setup`);
|
|
465
|
+
}
|
|
466
|
+
return value;
|
|
467
|
+
};
|
|
468
|
+
const matrixRoomId = typeof config.MATRIX_ACCOUNT_ROOM_ID === 'string'
|
|
469
|
+
? config.MATRIX_ACCOUNT_ROOM_ID
|
|
470
|
+
: '';
|
|
471
|
+
const matrixAccessToken = need('MATRIX_ORACLE_ADMIN_ACCESS_TOKEN');
|
|
472
|
+
const walletMnemonic = need('SECP_MNEMONIC');
|
|
473
|
+
const pin = need('MATRIX_VALUE_PIN');
|
|
474
|
+
const signerDid = need('ORACLE_DID');
|
|
475
|
+
const network = need('NETWORK');
|
|
476
|
+
try {
|
|
477
|
+
logger.log?.('[boot] Loading UCAN signing mnemonic from Matrix...');
|
|
478
|
+
const signingMnemonic = await setupClaimSigningMnemonics({
|
|
479
|
+
matrixRoomId,
|
|
480
|
+
matrixAccessToken,
|
|
481
|
+
walletMnemonic,
|
|
482
|
+
pin,
|
|
483
|
+
signerDid,
|
|
484
|
+
network: network,
|
|
485
|
+
});
|
|
486
|
+
if (signingMnemonic) {
|
|
487
|
+
const ucan = nestApp.get(UcanService, { strict: false });
|
|
488
|
+
if (ucan) {
|
|
489
|
+
ucan.setSigningMnemonic(signingMnemonic, signerDid);
|
|
490
|
+
logger.log?.('[boot] UCAN signing mnemonic loaded.');
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
logger.warn?.('[boot] UcanService not available — signing mnemonic dropped.');
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
logger.warn?.('[boot] setupClaimSigningMnemonics returned null. ' +
|
|
498
|
+
'UCAN minting will be unavailable until the mnemonic is provisioned ' +
|
|
499
|
+
'(run `oracles-cli setup-claim-signing-mnemonics`).');
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
catch (error) {
|
|
503
|
+
logger.error?.(`[boot] Failed to set up claim signing mnemonics: ${error instanceof Error ? error.message : String(error)}`);
|
|
504
|
+
}
|
|
505
|
+
if (!matrixRoomId) {
|
|
506
|
+
logger.warn?.('[boot] No MATRIX_ACCOUNT_ROOM_ID; skipping encryption-key load. ' +
|
|
507
|
+
'User secrets will be unavailable.');
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
try {
|
|
511
|
+
logger.log?.('[boot] Loading P-256 user-secrets encryption key...');
|
|
512
|
+
const result = await loadEncryptionKey({
|
|
513
|
+
matrixRoomId,
|
|
514
|
+
matrixAccessToken,
|
|
515
|
+
pin,
|
|
516
|
+
signerDid,
|
|
517
|
+
});
|
|
518
|
+
if (result) {
|
|
519
|
+
SecretsService.getInstance().setEncryptionKey(result.privateJwk);
|
|
520
|
+
logger.log?.('[boot] P-256 encryption key loaded.');
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
logger.warn?.('[boot] No P-256 encryption key found. User secrets will be ' +
|
|
524
|
+
'unavailable. Provision one via `oracles-cli setup-encryption-key`.');
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
catch (error) {
|
|
528
|
+
logger.error?.(`[boot] Failed to load P-256 encryption key: ${error instanceof Error ? error.message : String(error)}`);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type INestApplication } from '@nestjs/common';
|
|
2
|
+
import type { MatrixManager } from '@ixo/matrix';
|
|
3
|
+
export interface GracefulShutdownOptions {
|
|
4
|
+
app: INestApplication;
|
|
5
|
+
matrixManager: MatrixManager;
|
|
6
|
+
/** Optional teardown callbacks run after Nest has stopped but before exit. */
|
|
7
|
+
teardown?: Array<() => Promise<void> | void>;
|
|
8
|
+
/** Signals to listen on; defaults to SIGTERM + SIGINT. */
|
|
9
|
+
signals?: NodeJS.Signals[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Drain the running Nest app on SIGTERM/SIGINT: upload checkpoints to Matrix,
|
|
13
|
+
* close the HTTP server, then shut down the Matrix client. Mirrors today's
|
|
14
|
+
* boot flow so existing operators see no behaviour change when migrating.
|
|
15
|
+
*
|
|
16
|
+
* Each step is wrapped individually — an error in one step is logged and the
|
|
17
|
+
* remaining steps still run.
|
|
18
|
+
*/
|
|
19
|
+
export declare function registerGracefulShutdown(opts: GracefulShutdownOptions): () => void;
|
|
20
|
+
//# sourceMappingURL=graceful-shutdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graceful-shutdown.d.ts","sourceRoot":"","sources":["../../src/bootstrap/graceful-shutdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAU,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,gBAAgB,CAAC;IACtB,aAAa,EAAE,aAAa,CAAC;IAC7B,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7C,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;CAC5B;AAID;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,uBAAuB,GAC5B,MAAM,IAAI,CAmDZ"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
import { UserMatrixSqliteSyncService } from '../matrix/checkpointer/user-matrix-sqlite-sync-service.service.js';
|
|
3
|
+
const DEFAULT_SIGNALS = ['SIGTERM', 'SIGINT'];
|
|
4
|
+
/**
|
|
5
|
+
* Drain the running Nest app on SIGTERM/SIGINT: upload checkpoints to Matrix,
|
|
6
|
+
* close the HTTP server, then shut down the Matrix client. Mirrors today's
|
|
7
|
+
* boot flow so existing operators see no behaviour change when migrating.
|
|
8
|
+
*
|
|
9
|
+
* Each step is wrapped individually — an error in one step is logged and the
|
|
10
|
+
* remaining steps still run.
|
|
11
|
+
*/
|
|
12
|
+
export function registerGracefulShutdown(opts) {
|
|
13
|
+
const context = 'GracefulShutdown';
|
|
14
|
+
const signals = opts.signals ?? DEFAULT_SIGNALS;
|
|
15
|
+
const handlers = new Map();
|
|
16
|
+
const shutdown = async (signal) => {
|
|
17
|
+
Logger.log(`${signal} received, starting graceful shutdown...`, context);
|
|
18
|
+
await runStep('Upload checkpoint to Matrix', async () => {
|
|
19
|
+
const syncService = opts.app.get(UserMatrixSqliteSyncService);
|
|
20
|
+
await syncService.uploadCheckpointToMatrixStorageTask();
|
|
21
|
+
});
|
|
22
|
+
await runStep('Stop Nest application', async () => {
|
|
23
|
+
await opts.app.close();
|
|
24
|
+
});
|
|
25
|
+
await runStep('Stop MatrixManager client', async () => {
|
|
26
|
+
await opts.matrixManager.shutdown();
|
|
27
|
+
});
|
|
28
|
+
for (const teardownFn of opts.teardown ?? []) {
|
|
29
|
+
await runStep('Run plugin teardown', () => teardownFn());
|
|
30
|
+
}
|
|
31
|
+
Logger.log('Graceful shutdown complete', context);
|
|
32
|
+
process.exit(0);
|
|
33
|
+
};
|
|
34
|
+
for (const signal of signals) {
|
|
35
|
+
const handler = (received) => {
|
|
36
|
+
shutdown(received).catch((err) => {
|
|
37
|
+
Logger.error('Error during graceful shutdown', err instanceof Error ? err.stack : String(err), context);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
handlers.set(signal, handler);
|
|
42
|
+
process.once(signal, handler);
|
|
43
|
+
}
|
|
44
|
+
// Return a detach function for tests that need to remove the handlers.
|
|
45
|
+
return () => {
|
|
46
|
+
for (const [signal, handler] of handlers) {
|
|
47
|
+
process.off(signal, handler);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
async function runStep(label, step) {
|
|
52
|
+
const context = 'GracefulShutdown';
|
|
53
|
+
Logger.log(`${label}...`, context);
|
|
54
|
+
try {
|
|
55
|
+
await step();
|
|
56
|
+
Logger.log(`${label} complete`, context);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
Logger.warn(`${label} failed (continuing anyway): ${err instanceof Error ? err.message : String(err)}`, context);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { createOracleApp } from './create-oracle-app.js';
|
|
2
|
+
export type { CreateOracleAppOptions, OracleApp, BundledFeatureName, PluginStatusReport, PluginStatusChangeEvent, } from './create-oracle-app.js';
|
|
3
|
+
export { RuntimeAppModule } from './runtime-app-module.js';
|
|
4
|
+
export type { RuntimeAppModuleOptions } from './runtime-app-module.js';
|
|
5
|
+
export { registerGracefulShutdown } from './graceful-shutdown.js';
|
|
6
|
+
export type { GracefulShutdownOptions } from './graceful-shutdown.js';
|
|
7
|
+
export { resolvePlugins, topoSort } from './plugin-loader.js';
|
|
8
|
+
export type { ResolvePluginsInput, ResolvePluginsResult, ExcludedPlugin, SoftDepGap, FeatureToggle, } from './plugin-loader.js';
|
|
9
|
+
export { composeEnvSchema, validateEnv } from './schema-composer.js';
|
|
10
|
+
export type { ComposeEnvSchemaResult, ValidateEnvResult, ValidateEnvError, } from './schema-composer.js';
|
|
11
|
+
export { inspect } from './inspect.js';
|
|
12
|
+
export type { InspectInput, InspectOutput, InspectPluginEntry, CollectedRegistries, } from './inspect.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EACV,sBAAsB,EACtB,SAAS,EACT,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9D,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,UAAU,EACV,aAAa,GACd,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACrE,YAAY,EACV,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createOracleApp } from './create-oracle-app.js';
|
|
2
|
+
export { RuntimeAppModule } from './runtime-app-module.js';
|
|
3
|
+
export { registerGracefulShutdown } from './graceful-shutdown.js';
|
|
4
|
+
export { resolvePlugins, topoSort } from './plugin-loader.js';
|
|
5
|
+
export { composeEnvSchema, validateEnv } from './schema-composer.js';
|
|
6
|
+
export { inspect } from './inspect.js';
|