@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,254 @@
|
|
|
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 SessionHistoryProcessor_1;
|
|
14
|
+
// VALUE imports required for Nest DI — `design:paramtypes` metadata needs
|
|
15
|
+
// the runtime constructor, not a stripped `type`-only reference.
|
|
16
|
+
import { MemoryEngineService, SessionManagerService } from '@ixo/common';
|
|
17
|
+
import { MatrixManager } from '@ixo/matrix';
|
|
18
|
+
import { getMatrixHomeServerCroppedForDid } from '@ixo/oracles-chain-client';
|
|
19
|
+
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
|
20
|
+
import { Inject, Injectable, Logger, Optional } from '@nestjs/common';
|
|
21
|
+
import { ConfigService } from '@nestjs/config';
|
|
22
|
+
import { UserPreferencesService } from '../../plugins/user-preferences/service/user-preferences.service.js';
|
|
23
|
+
import { MessagesService } from '../messages/messages.service.js';
|
|
24
|
+
import { UcanService } from '../ucan/ucan.service.js';
|
|
25
|
+
let SessionHistoryProcessor = SessionHistoryProcessor_1 = class SessionHistoryProcessor {
|
|
26
|
+
messagesService;
|
|
27
|
+
memoryEngineService;
|
|
28
|
+
sessionManagerService;
|
|
29
|
+
configService;
|
|
30
|
+
cacheManager;
|
|
31
|
+
ucanService;
|
|
32
|
+
logger = new Logger(SessionHistoryProcessor_1.name);
|
|
33
|
+
constructor(messagesService, memoryEngineService, sessionManagerService, configService, cacheManager, ucanService) {
|
|
34
|
+
this.messagesService = messagesService;
|
|
35
|
+
this.memoryEngineService = memoryEngineService;
|
|
36
|
+
this.sessionManagerService = sessionManagerService;
|
|
37
|
+
this.configService = configService;
|
|
38
|
+
this.cacheManager = cacheManager;
|
|
39
|
+
this.ucanService = ucanService;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Process session history by sending messages to memory engine.
|
|
43
|
+
* Uses cache locking to prevent concurrent processing for the same session.
|
|
44
|
+
*/
|
|
45
|
+
async processSessionHistory(params) {
|
|
46
|
+
const cacheKey = `processing:session:${params.sessionId}`;
|
|
47
|
+
const lockTtl = 5 * 60 * 1000;
|
|
48
|
+
const maxRetries = 3;
|
|
49
|
+
const retryDelay = 10 * 1000;
|
|
50
|
+
const existingLock = await this.cacheManager.get(cacheKey);
|
|
51
|
+
if (existingLock) {
|
|
52
|
+
this.logger.debug(`Session ${params.sessionId} is already being processed, skipping`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
await this.cacheManager.set(cacheKey, true, lockTtl);
|
|
56
|
+
try {
|
|
57
|
+
await this.processSessionHistoryWithRetry(params, maxRetries, retryDelay);
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
await this.cacheManager.del(cacheKey);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async processSessionHistoryWithRetry(params, maxRetries, retryDelay) {
|
|
64
|
+
const { sessionId } = params;
|
|
65
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
66
|
+
try {
|
|
67
|
+
await this.processSessionHistoryInternal(params);
|
|
68
|
+
this.logger.log(`Successfully processed session history for session ${sessionId}`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
this.logger.warn(`Attempt ${attempt}/${maxRetries} failed for session ${sessionId}:`, error);
|
|
73
|
+
if (attempt === maxRetries) {
|
|
74
|
+
this.logger.error(`Failed to process session history for session ${sessionId} after ${maxRetries} attempts`, error);
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async processSessionHistoryInternal({ sessionId, did, oracleEntityDid, homeServer, }) {
|
|
82
|
+
this.logger.debug(`Processing session history for session ${sessionId}`);
|
|
83
|
+
const session = await this.sessionManagerService.getSession(sessionId, did, false);
|
|
84
|
+
if (!session) {
|
|
85
|
+
this.logger.warn(`Session ${sessionId} not found, skipping processing`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const userHomeServer = homeServer || (await getMatrixHomeServerCroppedForDid(did));
|
|
89
|
+
const { roomId } = await this.sessionManagerService.matrixManger.getOracleRoomIdWithHomeServer({
|
|
90
|
+
userDid: did,
|
|
91
|
+
oracleEntityDid,
|
|
92
|
+
userHomeServer,
|
|
93
|
+
});
|
|
94
|
+
if (!roomId) {
|
|
95
|
+
this.logger.warn(`Room not found for session ${sessionId}, skipping processing`);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const messagesResponse = await this.messagesService.listMessages({
|
|
99
|
+
sessionId,
|
|
100
|
+
did,
|
|
101
|
+
homeServer,
|
|
102
|
+
});
|
|
103
|
+
if (!messagesResponse.messages || messagesResponse.messages.length === 0) {
|
|
104
|
+
this.logger.debug(`No messages found for session ${sessionId}`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const lastProcessedCount = session.lastProcessedCount || 0;
|
|
108
|
+
const newMessages = messagesResponse.messages.slice(lastProcessedCount);
|
|
109
|
+
if (newMessages.length === 0) {
|
|
110
|
+
this.logger.debug(`No new messages to process for session ${sessionId} (lastProcessedCount: ${lastProcessedCount})`);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// Speaker identities for graphiti's extractor. Without these, every
|
|
114
|
+
// message's episode body starts with the literal string "user" or
|
|
115
|
+
// "assistant" — graphiti's extraction prompt then creates entity nodes
|
|
116
|
+
// with those generic names and pins all extracted facts to them,
|
|
117
|
+
// polluting the graph. Real identities make the graph person-centric.
|
|
118
|
+
// Graphiti partitions memories per (user, oracle) via group_id, so a
|
|
119
|
+
// simple "Me"/"Oracle" fallback is collision-safe within a user's graph.
|
|
120
|
+
const prefs = await UserPreferencesService.getInstance()
|
|
121
|
+
.get(roomId)
|
|
122
|
+
.catch(() => undefined);
|
|
123
|
+
const userSpeakerLabel = await this.resolveUserDisplayName(did, prefs?.userName, userHomeServer);
|
|
124
|
+
const oracleSpeakerLabel = prefs?.agentName?.trim() ||
|
|
125
|
+
this.configService.get('ORACLE_NAME')?.trim() ||
|
|
126
|
+
'Oracle';
|
|
127
|
+
const transformedMessages = this.transformMessagesToMemoryEngineFormat(newMessages, session.title ?? '', userSpeakerLabel, oracleSpeakerLabel);
|
|
128
|
+
if (!this.ucanService?.hasSigningKey()) {
|
|
129
|
+
this.logger.warn(`No UCAN signing key for session ${sessionId}, skipping memory engine processing`);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const oracleMatrixBaseUrl = this.configService
|
|
133
|
+
.getOrThrow('MATRIX_BASE_URL')
|
|
134
|
+
.replace(/\/$/, '');
|
|
135
|
+
const oracleHomeServer = oracleMatrixBaseUrl.replace(/^https?:\/\//, '');
|
|
136
|
+
let memoryUcanInvocation;
|
|
137
|
+
try {
|
|
138
|
+
const invocation = await this.ucanService.createServiceInvocation(this.configService.getOrThrow('MEMORY_ENGINE_URL'), did, 'ixo:memory');
|
|
139
|
+
if (invocation) {
|
|
140
|
+
memoryUcanInvocation = invocation;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
this.logger.warn(`[UCAN] Failed to create memory engine invocation: ${err instanceof Error ? err.message : String(err)}`);
|
|
145
|
+
}
|
|
146
|
+
if (!memoryUcanInvocation) {
|
|
147
|
+
this.logger.warn(`Could not mint UCAN invocation for memory engine; skipping memory engine processing for session ${sessionId}`);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const result = await this.memoryEngineService.processConversationHistory({
|
|
151
|
+
messages: transformedMessages,
|
|
152
|
+
roomId,
|
|
153
|
+
oracleHomeServer,
|
|
154
|
+
userHomeServer,
|
|
155
|
+
ucanInvocation: memoryUcanInvocation,
|
|
156
|
+
});
|
|
157
|
+
if (!result.success) {
|
|
158
|
+
throw new Error('Failed to send messages to memory engine');
|
|
159
|
+
}
|
|
160
|
+
const newLastProcessedCount = lastProcessedCount + newMessages.length;
|
|
161
|
+
await this.sessionManagerService.updateLastProcessedCount({
|
|
162
|
+
sessionId,
|
|
163
|
+
did,
|
|
164
|
+
lastProcessedCount: newLastProcessedCount,
|
|
165
|
+
});
|
|
166
|
+
this.logger.log(`Processed ${newMessages.length} new messages for session ${sessionId}, updated lastProcessedCount to ${newLastProcessedCount}`);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Transform LangChain messages into the role/content shape the
|
|
170
|
+
* memory engine expects. `userSpeakerLabel` and `oracleSpeakerLabel` become
|
|
171
|
+
* the `name` (and `role`) the memory engine sees for each message — these
|
|
172
|
+
* are what graphiti's extractor will use as the speaker entity in the graph,
|
|
173
|
+
* so they MUST be meaningful identities (not the literal strings
|
|
174
|
+
* "user"/"assistant"), otherwise every fact gets pinned to a generic
|
|
175
|
+
* placeholder node.
|
|
176
|
+
*/
|
|
177
|
+
transformMessagesToMemoryEngineFormat(messages, sessionTitle, userSpeakerLabel, oracleSpeakerLabel) {
|
|
178
|
+
return messages.map((message) => {
|
|
179
|
+
let role_type;
|
|
180
|
+
let role;
|
|
181
|
+
let name;
|
|
182
|
+
switch (message.type) {
|
|
183
|
+
case 'human':
|
|
184
|
+
role_type = 'user';
|
|
185
|
+
role = userSpeakerLabel;
|
|
186
|
+
name = userSpeakerLabel;
|
|
187
|
+
break;
|
|
188
|
+
case 'ai':
|
|
189
|
+
role_type = 'assistant';
|
|
190
|
+
role = oracleSpeakerLabel;
|
|
191
|
+
name = oracleSpeakerLabel;
|
|
192
|
+
break;
|
|
193
|
+
case 'system':
|
|
194
|
+
role_type = 'system';
|
|
195
|
+
role = 'System';
|
|
196
|
+
name = 'System';
|
|
197
|
+
break;
|
|
198
|
+
case 'tool':
|
|
199
|
+
// Memory engine has no tool role — fold tool replies into assistant.
|
|
200
|
+
// Tool responses are framed as the oracle reporting back, so they
|
|
201
|
+
// share the oracle speaker label.
|
|
202
|
+
role_type = 'assistant';
|
|
203
|
+
role = oracleSpeakerLabel;
|
|
204
|
+
name = oracleSpeakerLabel;
|
|
205
|
+
break;
|
|
206
|
+
default:
|
|
207
|
+
role_type = 'user';
|
|
208
|
+
role = userSpeakerLabel;
|
|
209
|
+
name = userSpeakerLabel;
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
content: message.content,
|
|
213
|
+
role_type,
|
|
214
|
+
role,
|
|
215
|
+
name,
|
|
216
|
+
source_description: `Chat Session: ${sessionTitle}`,
|
|
217
|
+
};
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Resolve the user's display name for graphiti's speaker label. Cascade:
|
|
222
|
+
* 1. `userName` from preferences (caller passes it in — fetched once
|
|
223
|
+
* alongside agentName)
|
|
224
|
+
* 2. Matrix profile displayname (looked up via @did-…:homeServer)
|
|
225
|
+
* 3. "Me" — safe fallback because each user has their own group_id
|
|
226
|
+
* partition in graphiti, so a generic label can't collide cross-user.
|
|
227
|
+
*/
|
|
228
|
+
async resolveUserDisplayName(did, prefsUserName, userHomeServer) {
|
|
229
|
+
const fromPrefs = prefsUserName?.trim();
|
|
230
|
+
if (fromPrefs)
|
|
231
|
+
return fromPrefs;
|
|
232
|
+
try {
|
|
233
|
+
const matrixUserId = `@did-${did.replace(/:/g, '-')}:${userHomeServer}`;
|
|
234
|
+
const displayName = await MatrixManager.getInstance().getDisplayName(matrixUserId);
|
|
235
|
+
const trimmed = displayName?.trim();
|
|
236
|
+
if (trimmed)
|
|
237
|
+
return trimmed;
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
this.logger.warn(`[resolveUserDisplayName] matrix lookup failed for ${did}: ${error instanceof Error ? error.message : String(error)}`);
|
|
241
|
+
}
|
|
242
|
+
return 'Me';
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
SessionHistoryProcessor = SessionHistoryProcessor_1 = __decorate([
|
|
246
|
+
Injectable(),
|
|
247
|
+
__param(4, Inject(CACHE_MANAGER)),
|
|
248
|
+
__param(5, Optional()),
|
|
249
|
+
__metadata("design:paramtypes", [MessagesService,
|
|
250
|
+
MemoryEngineService,
|
|
251
|
+
SessionManagerService,
|
|
252
|
+
ConfigService, Object, UcanService])
|
|
253
|
+
], SessionHistoryProcessor);
|
|
254
|
+
export { SessionHistoryProcessor };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type CreateChatSessionResponseDto, type ListChatSessionsResponseDto } from '@ixo/common';
|
|
2
|
+
import type { Request } from 'express';
|
|
3
|
+
import { SessionsService } from './sessions.service.js';
|
|
4
|
+
export declare class SessionsController {
|
|
5
|
+
private readonly sessionsService;
|
|
6
|
+
constructor(sessionsService: SessionsService);
|
|
7
|
+
createSession(req: Request): Promise<CreateChatSessionResponseDto>;
|
|
8
|
+
listSessions(req: Request, limit?: number, offset?: number): Promise<ListChatSessionsResponseDto>;
|
|
9
|
+
deleteSession(req: Request, sessionId: string): Promise<{
|
|
10
|
+
message: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=sessions.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessions.controller.d.ts","sourceRoot":"","sources":["../../../src/modules/sessions/sessions.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EACjC,MAAM,aAAa,CAAC;AAmBrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,qBAEa,kBAAkB;IACjB,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAAf,eAAe,EAAE,eAAe;IAWvD,aAAa,CACV,GAAG,EAAE,OAAO,GAClB,OAAO,CAAC,4BAA4B,CAAC;IA2BlC,YAAY,CACT,GAAG,EAAE,OAAO,EACH,KAAK,CAAC,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,GAC/B,OAAO,CAAC,2BAA2B,CAAC;IA2BjC,aAAa,CACV,GAAG,EAAE,OAAO,EACC,SAAS,EAAE,MAAM,GACpC,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAOhC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
import { Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Query, Req, } from '@nestjs/common';
|
|
14
|
+
import { ApiOperation, ApiParam, ApiQuery, ApiResponse, ApiTags, } from '@nestjs/swagger';
|
|
15
|
+
import { SessionsService } from './sessions.service.js';
|
|
16
|
+
let SessionsController = class SessionsController {
|
|
17
|
+
sessionsService;
|
|
18
|
+
constructor(sessionsService) {
|
|
19
|
+
this.sessionsService = sessionsService;
|
|
20
|
+
}
|
|
21
|
+
async createSession(req) {
|
|
22
|
+
const { did } = req.authData;
|
|
23
|
+
return this.sessionsService.createSession({
|
|
24
|
+
did,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async listSessions(req, limit, offset) {
|
|
28
|
+
const { did } = req.authData;
|
|
29
|
+
return this.sessionsService.listSessions({
|
|
30
|
+
did,
|
|
31
|
+
limit: limit ? Number(limit) : undefined,
|
|
32
|
+
offset: offset ? Number(offset) : undefined,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async deleteSession(req, sessionId) {
|
|
36
|
+
const { did } = req.authData;
|
|
37
|
+
return this.sessionsService.deleteSession({
|
|
38
|
+
did,
|
|
39
|
+
sessionId,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
__decorate([
|
|
44
|
+
Post(),
|
|
45
|
+
HttpCode(HttpStatus.CREATED),
|
|
46
|
+
ApiOperation({ summary: 'Create a new session' }),
|
|
47
|
+
ApiResponse({ status: 201, description: 'Session created successfully.' }),
|
|
48
|
+
ApiResponse({
|
|
49
|
+
status: 400,
|
|
50
|
+
description: 'Bad Request (e.g., missing/invalid headers by middleware, or session creation failed).',
|
|
51
|
+
}),
|
|
52
|
+
__param(0, Req()),
|
|
53
|
+
__metadata("design:type", Function),
|
|
54
|
+
__metadata("design:paramtypes", [Object]),
|
|
55
|
+
__metadata("design:returntype", Promise)
|
|
56
|
+
], SessionsController.prototype, "createSession", null);
|
|
57
|
+
__decorate([
|
|
58
|
+
Get(),
|
|
59
|
+
ApiOperation({ summary: 'List all sessions for a user' }),
|
|
60
|
+
ApiQuery({
|
|
61
|
+
name: 'limit',
|
|
62
|
+
required: false,
|
|
63
|
+
type: Number,
|
|
64
|
+
description: 'Number of sessions to return (default: 20)',
|
|
65
|
+
}),
|
|
66
|
+
ApiQuery({
|
|
67
|
+
name: 'offset',
|
|
68
|
+
required: false,
|
|
69
|
+
type: Number,
|
|
70
|
+
description: 'Number of sessions to skip (default: 0)',
|
|
71
|
+
}),
|
|
72
|
+
ApiResponse({ status: 200, description: 'List of sessions retrieved.' }),
|
|
73
|
+
ApiResponse({
|
|
74
|
+
status: 400,
|
|
75
|
+
description: 'Bad Request (e.g., missing/invalid headers by middleware, or failed to list sessions).',
|
|
76
|
+
}),
|
|
77
|
+
__param(0, Req()),
|
|
78
|
+
__param(1, Query('limit')),
|
|
79
|
+
__param(2, Query('offset')),
|
|
80
|
+
__metadata("design:type", Function),
|
|
81
|
+
__metadata("design:paramtypes", [Object, Number, Number]),
|
|
82
|
+
__metadata("design:returntype", Promise)
|
|
83
|
+
], SessionsController.prototype, "listSessions", null);
|
|
84
|
+
__decorate([
|
|
85
|
+
Delete(':sessionId'),
|
|
86
|
+
HttpCode(HttpStatus.OK),
|
|
87
|
+
ApiOperation({ summary: 'Delete a specific session' }),
|
|
88
|
+
ApiParam({
|
|
89
|
+
name: 'sessionId',
|
|
90
|
+
required: true,
|
|
91
|
+
description: 'ID of the session to delete',
|
|
92
|
+
}),
|
|
93
|
+
ApiResponse({ status: 200, description: 'Session deleted successfully.' }),
|
|
94
|
+
ApiResponse({
|
|
95
|
+
status: 400,
|
|
96
|
+
description: 'Bad Request (e.g., missing/invalid headers by middleware, or failed to delete session).',
|
|
97
|
+
}),
|
|
98
|
+
ApiResponse({
|
|
99
|
+
status: 404,
|
|
100
|
+
description: 'Session not found for the given ID.',
|
|
101
|
+
}),
|
|
102
|
+
__param(0, Req()),
|
|
103
|
+
__param(1, Param('sessionId')),
|
|
104
|
+
__metadata("design:type", Function),
|
|
105
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
106
|
+
__metadata("design:returntype", Promise)
|
|
107
|
+
], SessionsController.prototype, "deleteSession", null);
|
|
108
|
+
SessionsController = __decorate([
|
|
109
|
+
ApiTags('sessions'),
|
|
110
|
+
Controller('sessions'),
|
|
111
|
+
__metadata("design:paramtypes", [SessionsService])
|
|
112
|
+
], SessionsController);
|
|
113
|
+
export { SessionsController };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessions.module.d.ts","sourceRoot":"","sources":["../../../src/modules/sessions/sessions.module.ts"],"names":[],"mappings":"AAYA,qBA8Ba,cAAc;CAAG"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 { MemoryEngineService, SessionManagerService } from '@ixo/common';
|
|
8
|
+
import { MatrixManager } from '@ixo/matrix';
|
|
9
|
+
import { Module } from '@nestjs/common';
|
|
10
|
+
import { ConfigService } from '@nestjs/config';
|
|
11
|
+
import { MessagesModule } from '../messages/messages.module.js';
|
|
12
|
+
import { UcanModule } from '../ucan/ucan.module.js';
|
|
13
|
+
import { CheckpointStorageSyncModule } from '../../matrix/checkpointer/user-matrix-sqlite-sync-service.module.js';
|
|
14
|
+
import { UserMatrixSqliteSyncService } from '../../matrix/checkpointer/user-matrix-sqlite-sync-service.service.js';
|
|
15
|
+
import { SessionHistoryProcessor } from './session-history-processor.service.js';
|
|
16
|
+
import { SessionsController } from './sessions.controller.js';
|
|
17
|
+
import { SessionsService } from './sessions.service.js';
|
|
18
|
+
let SessionsModule = class SessionsModule {
|
|
19
|
+
};
|
|
20
|
+
SessionsModule = __decorate([
|
|
21
|
+
Module({
|
|
22
|
+
imports: [MessagesModule, CheckpointStorageSyncModule, UcanModule],
|
|
23
|
+
controllers: [SessionsController],
|
|
24
|
+
providers: [
|
|
25
|
+
SessionsService,
|
|
26
|
+
SessionHistoryProcessor,
|
|
27
|
+
{
|
|
28
|
+
// MEMORY_ENGINE_URL is optional — see comment in messages.module.ts.
|
|
29
|
+
provide: MemoryEngineService,
|
|
30
|
+
useFactory: (configService) => {
|
|
31
|
+
const memoryEngineUrl = configService.get('MEMORY_ENGINE_URL');
|
|
32
|
+
return memoryEngineUrl
|
|
33
|
+
? new MemoryEngineService(memoryEngineUrl)
|
|
34
|
+
: null;
|
|
35
|
+
},
|
|
36
|
+
inject: [ConfigService],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
provide: SessionManagerService,
|
|
40
|
+
useFactory: (syncService) => {
|
|
41
|
+
return new SessionManagerService(syncService, MatrixManager.getInstance());
|
|
42
|
+
},
|
|
43
|
+
inject: [UserMatrixSqliteSyncService],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
exports: [SessionsService, SessionHistoryProcessor],
|
|
47
|
+
})
|
|
48
|
+
], SessionsModule);
|
|
49
|
+
export { SessionsModule };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type CreateChatSessionResponseDto, type ListChatSessionsResponseDto, SessionManagerService } from '@ixo/common';
|
|
2
|
+
import { ConfigService } from '@nestjs/config';
|
|
3
|
+
import { UcanService } from '../ucan/ucan.service.js';
|
|
4
|
+
import { UserMatrixSqliteSyncService } from '../../matrix/checkpointer/user-matrix-sqlite-sync-service.service.js';
|
|
5
|
+
import { type CreateSessionDto } from './dto/create-session.dto.js';
|
|
6
|
+
import { type DeleteSessionDto } from './dto/delete-session.dto.js';
|
|
7
|
+
import { type ListSessionsDto } from './dto/list-sessions.dto.js';
|
|
8
|
+
import { SessionHistoryProcessor } from './session-history-processor.service.js';
|
|
9
|
+
export declare class SessionsService {
|
|
10
|
+
private readonly sessionManager;
|
|
11
|
+
private readonly configService;
|
|
12
|
+
private readonly sessionHistoryProcessor;
|
|
13
|
+
private readonly syncService;
|
|
14
|
+
private readonly ucanService?;
|
|
15
|
+
constructor(sessionManager: SessionManagerService, configService: ConfigService, sessionHistoryProcessor: SessionHistoryProcessor, syncService: UserMatrixSqliteSyncService, ucanService?: UcanService | undefined);
|
|
16
|
+
processPreviousSessionHistory(data: CreateSessionDto): Promise<void>;
|
|
17
|
+
createSession(data: CreateSessionDto): Promise<CreateChatSessionResponseDto>;
|
|
18
|
+
listSessions(data: ListSessionsDto): Promise<ListChatSessionsResponseDto>;
|
|
19
|
+
deleteSession(data: DeleteSessionDto): Promise<{
|
|
20
|
+
message: string;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=sessions.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessions.service.d.ts","sourceRoot":"","sources":["../../../src/modules/sessions/sessions.service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAQrB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,sEAAsE,CAAC;AACnH,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,qBACa,eAAe;IAExB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW;IAChB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;gBAJxB,cAAc,EAAE,qBAAqB,EACrC,aAAa,EAAE,aAAa,EAC5B,uBAAuB,EAAE,uBAAuB,EAChD,WAAW,EAAE,2BAA2B,EAC5B,WAAW,CAAC,EAAE,WAAW,YAAA;IAGlD,6BAA6B,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgCpE,aAAa,CACjB,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,4BAA4B,CAAC;IA0ClC,YAAY,CAChB,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,2BAA2B,CAAC;IAwCjC,aAAa,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CA4C1E"}
|
|
@@ -0,0 +1,168 @@
|
|
|
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
|
+
import { SessionManagerService, } from '@ixo/common';
|
|
14
|
+
import { getMatrixHomeServerCroppedForDid } from '@ixo/oracles-chain-client';
|
|
15
|
+
import { BadRequestException, Injectable, Logger, Optional, } from '@nestjs/common';
|
|
16
|
+
import { ConfigService } from '@nestjs/config';
|
|
17
|
+
import { UcanService } from '../ucan/ucan.service.js';
|
|
18
|
+
import { UserMatrixSqliteSyncService } from '../../matrix/checkpointer/user-matrix-sqlite-sync-service.service.js';
|
|
19
|
+
import { SessionHistoryProcessor } from './session-history-processor.service.js';
|
|
20
|
+
let SessionsService = class SessionsService {
|
|
21
|
+
sessionManager;
|
|
22
|
+
configService;
|
|
23
|
+
sessionHistoryProcessor;
|
|
24
|
+
syncService;
|
|
25
|
+
ucanService;
|
|
26
|
+
constructor(sessionManager, configService, sessionHistoryProcessor, syncService, ucanService) {
|
|
27
|
+
this.sessionManager = sessionManager;
|
|
28
|
+
this.configService = configService;
|
|
29
|
+
this.sessionHistoryProcessor = sessionHistoryProcessor;
|
|
30
|
+
this.syncService = syncService;
|
|
31
|
+
this.ucanService = ucanService;
|
|
32
|
+
}
|
|
33
|
+
async processPreviousSessionHistory(data) {
|
|
34
|
+
const oracleEntityDid = this.configService.getOrThrow('ORACLE_ENTITY_DID');
|
|
35
|
+
const { sessions } = await this.listSessions({
|
|
36
|
+
did: data.did,
|
|
37
|
+
});
|
|
38
|
+
const previousSession = sessions[0]; // most recent
|
|
39
|
+
if (previousSession) {
|
|
40
|
+
// Guard the inner fire-and-forget separately — the outer guard on
|
|
41
|
+
// processPreviousSessionHistory drops when this method resolves,
|
|
42
|
+
// but processSessionHistory continues running in the background.
|
|
43
|
+
this.syncService.markUserActive(data.did);
|
|
44
|
+
this.sessionHistoryProcessor
|
|
45
|
+
.processSessionHistory({
|
|
46
|
+
sessionId: previousSession.sessionId,
|
|
47
|
+
did: data.did,
|
|
48
|
+
oracleEntityDid,
|
|
49
|
+
homeServer: data.homeServer,
|
|
50
|
+
})
|
|
51
|
+
.catch((err) => Logger.error(`Failed to process previous session ${previousSession.sessionId}:`, err))
|
|
52
|
+
.finally(() => {
|
|
53
|
+
this.syncService.markUserInactive(data.did);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async createSession(data) {
|
|
58
|
+
this.syncService.markUserActive(data.did);
|
|
59
|
+
try {
|
|
60
|
+
const oracleEntityDid = this.configService.getOrThrow('ORACLE_ENTITY_DID');
|
|
61
|
+
// Increment ref count BEFORE firing the background task so the outer
|
|
62
|
+
// finally's markUserInactive doesn't drop to 0 while the task runs.
|
|
63
|
+
this.syncService.markUserActive(data.did);
|
|
64
|
+
this.processPreviousSessionHistory(data)
|
|
65
|
+
.catch((err) => Logger.error(`Failed to process previous session history for DID ${data.did}:`, err))
|
|
66
|
+
.finally(() => {
|
|
67
|
+
this.syncService.markUserInactive(data.did);
|
|
68
|
+
});
|
|
69
|
+
const session = await this.sessionManager.createSession({
|
|
70
|
+
did: data.did,
|
|
71
|
+
homeServer: data.homeServer,
|
|
72
|
+
oracleName: this.configService.getOrThrow('ORACLE_NAME'),
|
|
73
|
+
oracleEntityDid,
|
|
74
|
+
oracleDid: this.configService.getOrThrow('ORACLE_DID'),
|
|
75
|
+
slackThreadTs: data.slackThreadTs,
|
|
76
|
+
});
|
|
77
|
+
return session;
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
81
|
+
const stack = error instanceof Error ? error.stack : undefined;
|
|
82
|
+
Logger.error(`Failed to create session for DID ${data.did}: ${message}`, stack);
|
|
83
|
+
throw new BadRequestException(`Session creation failed: ${message}`);
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
this.syncService.markUserInactive(data.did);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async listSessions(data) {
|
|
90
|
+
this.syncService.markUserActive(data.did);
|
|
91
|
+
try {
|
|
92
|
+
// Resolve the user's main room so we only return main-room sessions.
|
|
93
|
+
// Task-room sessions (created via Matrix in dedicated task channels)
|
|
94
|
+
// are filtered out — the portal only shows main conversations.
|
|
95
|
+
const userHomeServer = data.homeServer || (await getMatrixHomeServerCroppedForDid(data.did));
|
|
96
|
+
const { roomId: mainRoomId } = await this.sessionManager.matrixManger.getOracleRoomIdWithHomeServer({
|
|
97
|
+
userDid: data.did,
|
|
98
|
+
oracleEntityDid: this.configService.getOrThrow('ORACLE_ENTITY_DID'),
|
|
99
|
+
userHomeServer,
|
|
100
|
+
});
|
|
101
|
+
const sessionsResult = await this.sessionManager.listSessions({
|
|
102
|
+
did: data.did,
|
|
103
|
+
oracleEntityDid: this.configService.getOrThrow('ORACLE_ENTITY_DID'),
|
|
104
|
+
limit: data.limit ?? 20,
|
|
105
|
+
offset: data.offset ?? 0,
|
|
106
|
+
roomId: mainRoomId ?? undefined,
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
sessions: sessionsResult.sessions,
|
|
110
|
+
total: sessionsResult.total,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
115
|
+
const stack = error instanceof Error ? error.stack : undefined;
|
|
116
|
+
Logger.error(`Failed to list sessions for DID ${data.did}: ${message}`, stack);
|
|
117
|
+
throw new BadRequestException(`Failed to list sessions: ${message}`);
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
this.syncService.markUserInactive(data.did);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async deleteSession(data) {
|
|
124
|
+
this.syncService.markUserActive(data.did);
|
|
125
|
+
try {
|
|
126
|
+
const oracleEntityDid = this.configService.getOrThrow('ORACLE_ENTITY_DID');
|
|
127
|
+
// Increment ref count BEFORE firing the background task so the outer
|
|
128
|
+
// finally's markUserInactive doesn't drop to 0 while the task runs.
|
|
129
|
+
this.syncService.markUserActive(data.did);
|
|
130
|
+
this.sessionHistoryProcessor
|
|
131
|
+
.processSessionHistory({
|
|
132
|
+
sessionId: data.sessionId,
|
|
133
|
+
did: data.did,
|
|
134
|
+
oracleEntityDid,
|
|
135
|
+
homeServer: data.homeServer,
|
|
136
|
+
})
|
|
137
|
+
.catch((err) => Logger.error(`Failed to process deleted session ${data.sessionId}:`, err))
|
|
138
|
+
.finally(() => {
|
|
139
|
+
this.syncService.markUserInactive(data.did);
|
|
140
|
+
});
|
|
141
|
+
await this.sessionManager.deleteSession({
|
|
142
|
+
did: data.did,
|
|
143
|
+
sessionId: data.sessionId,
|
|
144
|
+
oracleEntityDid,
|
|
145
|
+
});
|
|
146
|
+
return { message: 'Session deleted successfully' };
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
150
|
+
const stack = error instanceof Error ? error.stack : undefined;
|
|
151
|
+
Logger.error(`Failed to delete session ${data.sessionId} for DID ${data.did}: ${message}`, stack);
|
|
152
|
+
throw new BadRequestException(`Failed to delete session: ${message}`);
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
this.syncService.markUserInactive(data.did);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
SessionsService = __decorate([
|
|
160
|
+
Injectable(),
|
|
161
|
+
__param(4, Optional()),
|
|
162
|
+
__metadata("design:paramtypes", [SessionManagerService,
|
|
163
|
+
ConfigService,
|
|
164
|
+
SessionHistoryProcessor,
|
|
165
|
+
UserMatrixSqliteSyncService,
|
|
166
|
+
UcanService])
|
|
167
|
+
], SessionsService);
|
|
168
|
+
export { SessionsService };
|