@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,128 @@
|
|
|
1
|
+
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
2
|
+
import { Logger } from '@nestjs/common';
|
|
3
|
+
import { getProviderChatModel } from '../../llm/llm-provider.js';
|
|
4
|
+
const logger = new Logger('ChannelMemorySummarizer');
|
|
5
|
+
const SYSTEM_PROMPT = `You compact a chunk of group-chat messages into a durable, dense summary used as long-term memory for an AI assistant.
|
|
6
|
+
|
|
7
|
+
KEEP:
|
|
8
|
+
- Decisions, agreements, commitments
|
|
9
|
+
- Concrete facts (names, dates, numbers, URLs)
|
|
10
|
+
- Topics discussed and any unresolved questions
|
|
11
|
+
- Member dynamics and stated preferences
|
|
12
|
+
- Action items and ownership
|
|
13
|
+
|
|
14
|
+
DROP:
|
|
15
|
+
- Pleasantries, fillers, redundancy
|
|
16
|
+
- Transient state (typing, reactions)
|
|
17
|
+
- Information that has been explicitly superseded
|
|
18
|
+
|
|
19
|
+
OUTPUT RULES:
|
|
20
|
+
- Output ONLY the summary text. No preamble, no headings, no markdown lists unless they aid clarity.
|
|
21
|
+
- Aim for 200-400 tokens.
|
|
22
|
+
- Refer to people by their display name.
|
|
23
|
+
- Be concrete. Quote short fragments verbatim when wording matters.
|
|
24
|
+
- If the messages are mostly chitchat, produce a one-sentence summary noting that.`;
|
|
25
|
+
const TIER_ROLLUP_PROMPT = `You are consolidating several already-summarized chunks of group-chat history into a single higher-tier summary.
|
|
26
|
+
|
|
27
|
+
KEEP:
|
|
28
|
+
- Persistent facts, decisions, ownership, deadlines that still matter
|
|
29
|
+
- Names, project context, recurring topics
|
|
30
|
+
- Unresolved threads that were never closed
|
|
31
|
+
|
|
32
|
+
DROP:
|
|
33
|
+
- Day-to-day chatter that is no longer relevant
|
|
34
|
+
- Anything explicitly superseded by a later chunk
|
|
35
|
+
|
|
36
|
+
OUTPUT:
|
|
37
|
+
- A single dense paragraph (or short paragraphs) — no headings.
|
|
38
|
+
- 200-400 tokens. Refer to people by display name.
|
|
39
|
+
- Be concrete; quote fragments when wording matters.`;
|
|
40
|
+
const formatMessagesForPrompt = (messages) => messages
|
|
41
|
+
.map((m) => {
|
|
42
|
+
const ts = new Date(m.timestamp).toISOString();
|
|
43
|
+
const thread = m.threadId ? ` thread=${m.threadId.slice(0, 10)}` : '';
|
|
44
|
+
return `[${m.senderDisplayName} @ ${ts}${thread}]: ${m.body}`;
|
|
45
|
+
})
|
|
46
|
+
.join('\n');
|
|
47
|
+
export class ChannelMemorySummarizer {
|
|
48
|
+
/**
|
|
49
|
+
* Compact a batch of observed messages into a summary string.
|
|
50
|
+
* Returns null if the LLM call fails — caller should keep the buffer.
|
|
51
|
+
*/
|
|
52
|
+
async summarize(messages) {
|
|
53
|
+
if (messages.length === 0)
|
|
54
|
+
return null;
|
|
55
|
+
try {
|
|
56
|
+
const llm = getProviderChatModel('session-title', {
|
|
57
|
+
temperature: 0.2,
|
|
58
|
+
maxTokens: 800,
|
|
59
|
+
});
|
|
60
|
+
const prompt = formatMessagesForPrompt(messages);
|
|
61
|
+
const response = await llm.invoke([
|
|
62
|
+
new SystemMessage(SYSTEM_PROMPT),
|
|
63
|
+
new HumanMessage(prompt),
|
|
64
|
+
]);
|
|
65
|
+
const text = extractText(response.content).trim();
|
|
66
|
+
if (!text) {
|
|
67
|
+
logger.warn(`[Summarizer] Empty summary returned for ${messages.length} messages`);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return text.length > 6000 ? text.slice(0, 6000) : text;
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
logger.warn(`[Summarizer] Compaction failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Consolidate multiple tier-N summaries into a single tier-(N+1) summary.
|
|
79
|
+
* Used by the tier scheduler for week/month rollups.
|
|
80
|
+
*/
|
|
81
|
+
async rollup(summaries) {
|
|
82
|
+
if (summaries.length === 0)
|
|
83
|
+
return null;
|
|
84
|
+
if (summaries.length === 1)
|
|
85
|
+
return summaries[0] ?? null;
|
|
86
|
+
try {
|
|
87
|
+
const llm = getProviderChatModel('session-title', {
|
|
88
|
+
temperature: 0.2,
|
|
89
|
+
maxTokens: 800,
|
|
90
|
+
});
|
|
91
|
+
const body = summaries
|
|
92
|
+
.map((s, i) => `--- chunk ${i + 1} ---\n${s}`)
|
|
93
|
+
.join('\n\n');
|
|
94
|
+
const response = await llm.invoke([
|
|
95
|
+
new SystemMessage(TIER_ROLLUP_PROMPT),
|
|
96
|
+
new HumanMessage(body),
|
|
97
|
+
]);
|
|
98
|
+
const text = extractText(response.content).trim();
|
|
99
|
+
if (!text) {
|
|
100
|
+
logger.warn(`[Summarizer] Empty rollup returned for ${summaries.length} chunks`);
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
return text.length > 6000 ? text.slice(0, 6000) : text;
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
logger.warn(`[Summarizer] Rollup failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function extractText(content) {
|
|
112
|
+
if (typeof content === 'string')
|
|
113
|
+
return content;
|
|
114
|
+
if (Array.isArray(content)) {
|
|
115
|
+
return content
|
|
116
|
+
.map((part) => {
|
|
117
|
+
if (typeof part === 'string')
|
|
118
|
+
return part;
|
|
119
|
+
if (part && typeof part === 'object' && 'text' in part) {
|
|
120
|
+
const t = part.text;
|
|
121
|
+
return typeof t === 'string' ? t : '';
|
|
122
|
+
}
|
|
123
|
+
return '';
|
|
124
|
+
})
|
|
125
|
+
.join('');
|
|
126
|
+
}
|
|
127
|
+
return '';
|
|
128
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Channel memory — distilled long-term memory of group rooms.
|
|
3
|
+
*
|
|
4
|
+
* Each `ChannelMemoryChunk` is an LLM-compacted summary of a batch of recent
|
|
5
|
+
* room messages. Chunks accumulate immutably. They are NEVER overwritten.
|
|
6
|
+
*
|
|
7
|
+
* `tier` drives age-based consolidation:
|
|
8
|
+
* - tier=1 — recent, granular (default)
|
|
9
|
+
* - tier=2 — older, weekly rollup
|
|
10
|
+
* - tier=3 — ancient, monthly rollup
|
|
11
|
+
*/
|
|
12
|
+
export interface ChannelMemoryChunk {
|
|
13
|
+
id: string;
|
|
14
|
+
roomId: string;
|
|
15
|
+
summary: string;
|
|
16
|
+
fromEventId: string;
|
|
17
|
+
toEventId: string;
|
|
18
|
+
fromTimestamp: number;
|
|
19
|
+
toTimestamp: number;
|
|
20
|
+
messageCount: number;
|
|
21
|
+
participants: string[];
|
|
22
|
+
threadIds: string[];
|
|
23
|
+
tier: number;
|
|
24
|
+
createdAt: number;
|
|
25
|
+
}
|
|
26
|
+
export interface PinnedFact {
|
|
27
|
+
id: string;
|
|
28
|
+
roomId: string;
|
|
29
|
+
fact: string;
|
|
30
|
+
pinnedByDid: string;
|
|
31
|
+
sourceEventId?: string;
|
|
32
|
+
createdAt: number;
|
|
33
|
+
}
|
|
34
|
+
export interface ChannelMember {
|
|
35
|
+
matrixUserId: string;
|
|
36
|
+
displayName: string;
|
|
37
|
+
did?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface ObservedMessage {
|
|
40
|
+
eventId: string;
|
|
41
|
+
threadId: string;
|
|
42
|
+
senderDid: string;
|
|
43
|
+
senderMatrixUserId: string;
|
|
44
|
+
senderDisplayName: string;
|
|
45
|
+
body: string;
|
|
46
|
+
timestamp: number;
|
|
47
|
+
}
|
|
48
|
+
/** Shared-state key under which the service exposes itself. */
|
|
49
|
+
export declare const CHANNEL_MEMORY_SHARED_KEY: "channelMemory";
|
|
50
|
+
//# sourceMappingURL=channel-memory.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-memory.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/matrix-group-chats/channel-memory.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,EAAG,eAAwB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type MatrixManager } from '@ixo/matrix';
|
|
2
|
+
import { type BaseMessage } from '@langchain/core/messages';
|
|
3
|
+
/**
|
|
4
|
+
* Group-chat utilities — pure, self-contained.
|
|
5
|
+
*
|
|
6
|
+
* Decides whether the agent should respond to an incoming Matrix event in a
|
|
7
|
+
* group room. DMs are unaffected (always respond). Even when the agent stays
|
|
8
|
+
* silent, the caller is expected to still capture the message into channel
|
|
9
|
+
* memory so summaries stay accurate.
|
|
10
|
+
*/
|
|
11
|
+
export interface RoomTypeInfo {
|
|
12
|
+
isDirect: boolean;
|
|
13
|
+
memberCount: number;
|
|
14
|
+
}
|
|
15
|
+
/** Minimal structural type for the incoming Matrix event. */
|
|
16
|
+
export interface GuardEvent {
|
|
17
|
+
eventId: string;
|
|
18
|
+
content?: Record<string, unknown> | undefined;
|
|
19
|
+
}
|
|
20
|
+
export interface ShouldRespondInput {
|
|
21
|
+
event: GuardEvent;
|
|
22
|
+
roomId: string;
|
|
23
|
+
threadId: string;
|
|
24
|
+
matrixManager: MatrixManager;
|
|
25
|
+
/** Bot's Matrix user ID, e.g. `@oracle:matrix.example.org`. */
|
|
26
|
+
botMatrixUserId: string;
|
|
27
|
+
/** Resolved room type. Caller is responsible for caching. */
|
|
28
|
+
roomInfo: RoomTypeInfo;
|
|
29
|
+
/** Active-thread map shared with the middleware. */
|
|
30
|
+
activeBotThreads: Map<string, number>;
|
|
31
|
+
/** TTL to use when re-warming an active-thread entry found via history. */
|
|
32
|
+
activeBotThreadTtlMs: number;
|
|
33
|
+
}
|
|
34
|
+
export type ShouldRespondReason = 'dm' | 'mentioned' | 'reply-to-bot' | 'active-thread' | 'ignored';
|
|
35
|
+
export interface ShouldRespondResult {
|
|
36
|
+
respond: boolean;
|
|
37
|
+
reason: ShouldRespondReason;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* True when the event's `m.mentions.user_ids` array includes the bot.
|
|
41
|
+
* Tolerant of older clients that omit `m.mentions` — returns false.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isBotMentioned(content: Record<string, unknown> | undefined, botMatrixUserId: string): boolean;
|
|
44
|
+
/** Extract the in-reply-to event id from message content, if present. */
|
|
45
|
+
export declare function getInReplyToEventId(content: Record<string, unknown> | undefined): string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Check whether an incoming message is a direct reply to a bot-authored event.
|
|
48
|
+
* One Matrix API lookup; failures degrade to `false`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isReplyToBotMessage(event: GuardEvent, roomId: string, matrixManager: MatrixManager, botMatrixUserId: string): Promise<boolean>;
|
|
51
|
+
/** Mark a thread as actively engaged with the bot. */
|
|
52
|
+
export declare function markBotThreadActive(activeBotThreads: Map<string, number>, roomId: string, threadId: string, ttlMs: number): void;
|
|
53
|
+
/**
|
|
54
|
+
* True when (room, thread) is in the active-bot-thread map and not expired.
|
|
55
|
+
* Lazily evicts expired entries.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isActiveBotThread(activeBotThreads: Map<string, number>, roomId: string, threadId: string): boolean;
|
|
58
|
+
/** Periodic eviction of expired entries. Called opportunistically. */
|
|
59
|
+
export declare function sweepExpiredBotThreads(activeBotThreads: Map<string, number>): void;
|
|
60
|
+
/**
|
|
61
|
+
* Resolve whether the agent should respond to this Matrix event.
|
|
62
|
+
*
|
|
63
|
+
* Order of precedence:
|
|
64
|
+
* 1. DM → respond
|
|
65
|
+
* 2. Bot @mentioned → respond
|
|
66
|
+
* 3. Direct reply to a bot message → respond
|
|
67
|
+
* 4. Thread already in active-bot-thread map → respond
|
|
68
|
+
* 5. Cache cold: check Matrix history for prior bot participation → respond
|
|
69
|
+
* 6. Otherwise → ignore (still capture passively elsewhere)
|
|
70
|
+
*/
|
|
71
|
+
export declare function shouldAgentRespond(input: ShouldRespondInput): Promise<ShouldRespondResult>;
|
|
72
|
+
/**
|
|
73
|
+
* Speaker context derived from the most recent HumanMessage in graph state.
|
|
74
|
+
* In group rooms every HumanMessage carries `additional_kwargs.senderDid`
|
|
75
|
+
* (and friends). In DMs, fall back to the session-owner DID.
|
|
76
|
+
*/
|
|
77
|
+
export interface SpeakerContext {
|
|
78
|
+
did: string;
|
|
79
|
+
matrixUserId?: string;
|
|
80
|
+
displayName?: string;
|
|
81
|
+
}
|
|
82
|
+
export declare function getCurrentSpeaker(messages: ReadonlyArray<BaseMessage> | undefined, fallbackDid: string): SpeakerContext;
|
|
83
|
+
//# sourceMappingURL=guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../../src/plugins/matrix-group-chats/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;GAOG;AAEH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,6DAA6D;AAC7D,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC/C;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,aAAa,CAAC;IAC7B,+DAA+D;IAC/D,eAAe,EAAE,MAAM,CAAC;IACxB,6DAA6D;IAC7D,QAAQ,EAAE,YAAY,CAAC;IACvB,oDAAoD;IACpD,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,2EAA2E;IAC3E,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,MAAM,mBAAmB,GAC3B,IAAI,GACJ,WAAW,GACX,cAAc,GACd,eAAe,GACf,SAAS,CAAC;AAEd,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAOD;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC5C,eAAe,EAAE,MAAM,GACtB,OAAO,CAMT;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC3C,MAAM,GAAG,SAAS,CAOpB;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,OAAO,CAAC,CAYlB;AAED,sDAAsD;AACtD,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,IAAI,CAEN;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAST;AAED,sEAAsE;AACtE,wBAAgB,sBAAsB,CACpC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,IAAI,CAKN;AAoCD;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CA6C9B;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,SAAS,EAChD,WAAW,EAAE,MAAM,GAClB,cAAc,CAoBhB"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
const ACTIVE_THREAD_KEY = (roomId, threadId) => `${roomId}:${threadId}`;
|
|
3
|
+
const logger = new Logger('GroupChatGuard');
|
|
4
|
+
/**
|
|
5
|
+
* True when the event's `m.mentions.user_ids` array includes the bot.
|
|
6
|
+
* Tolerant of older clients that omit `m.mentions` — returns false.
|
|
7
|
+
*/
|
|
8
|
+
export function isBotMentioned(content, botMatrixUserId) {
|
|
9
|
+
if (!content)
|
|
10
|
+
return false;
|
|
11
|
+
const mentions = content['m.mentions'];
|
|
12
|
+
const userIds = mentions?.user_ids;
|
|
13
|
+
if (!Array.isArray(userIds))
|
|
14
|
+
return false;
|
|
15
|
+
return userIds.some((id) => typeof id === 'string' && id === botMatrixUserId);
|
|
16
|
+
}
|
|
17
|
+
/** Extract the in-reply-to event id from message content, if present. */
|
|
18
|
+
export function getInReplyToEventId(content) {
|
|
19
|
+
if (!content)
|
|
20
|
+
return undefined;
|
|
21
|
+
const relates = content['m.relates_to'];
|
|
22
|
+
const eventId = relates?.['m.in_reply_to']?.event_id;
|
|
23
|
+
return typeof eventId === 'string' ? eventId : undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Check whether an incoming message is a direct reply to a bot-authored event.
|
|
27
|
+
* One Matrix API lookup; failures degrade to `false`.
|
|
28
|
+
*/
|
|
29
|
+
export async function isReplyToBotMessage(event, roomId, matrixManager, botMatrixUserId) {
|
|
30
|
+
const inReplyTo = getInReplyToEventId(event.content);
|
|
31
|
+
if (!inReplyTo)
|
|
32
|
+
return false;
|
|
33
|
+
try {
|
|
34
|
+
const target = await matrixManager.getEventById(roomId, inReplyTo);
|
|
35
|
+
return target?.sender === botMatrixUserId;
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
logger.warn(`Failed to fetch reply target ${inReplyTo} in ${roomId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Mark a thread as actively engaged with the bot. */
|
|
43
|
+
export function markBotThreadActive(activeBotThreads, roomId, threadId, ttlMs) {
|
|
44
|
+
activeBotThreads.set(ACTIVE_THREAD_KEY(roomId, threadId), Date.now() + ttlMs);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* True when (room, thread) is in the active-bot-thread map and not expired.
|
|
48
|
+
* Lazily evicts expired entries.
|
|
49
|
+
*/
|
|
50
|
+
export function isActiveBotThread(activeBotThreads, roomId, threadId) {
|
|
51
|
+
const key = ACTIVE_THREAD_KEY(roomId, threadId);
|
|
52
|
+
const expiresAt = activeBotThreads.get(key);
|
|
53
|
+
if (!expiresAt)
|
|
54
|
+
return false;
|
|
55
|
+
if (expiresAt <= Date.now()) {
|
|
56
|
+
activeBotThreads.delete(key);
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
/** Periodic eviction of expired entries. Called opportunistically. */
|
|
62
|
+
export function sweepExpiredBotThreads(activeBotThreads) {
|
|
63
|
+
const now = Date.now();
|
|
64
|
+
for (const [key, expiresAt] of activeBotThreads.entries()) {
|
|
65
|
+
if (expiresAt <= now)
|
|
66
|
+
activeBotThreads.delete(key);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Fallback when the in-memory active-thread cache is cold (restart / TTL
|
|
71
|
+
* expiry): scan recent Matrix history for prior bot participation in this
|
|
72
|
+
* thread. Re-warms the cache on hit.
|
|
73
|
+
*/
|
|
74
|
+
async function hasBotSpokenInThread(roomId, threadId, matrixManager, botMatrixUserId, activeBotThreads, activeBotThreadTtlMs) {
|
|
75
|
+
try {
|
|
76
|
+
const { messages } = await matrixManager.getRecentRoomMessages(roomId, {
|
|
77
|
+
limit: 100,
|
|
78
|
+
});
|
|
79
|
+
const botWasActive = messages.some((m) => m.sender === botMatrixUserId && m.threadId === threadId);
|
|
80
|
+
if (botWasActive) {
|
|
81
|
+
markBotThreadActive(activeBotThreads, roomId, threadId, activeBotThreadTtlMs);
|
|
82
|
+
}
|
|
83
|
+
return botWasActive;
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Resolve whether the agent should respond to this Matrix event.
|
|
91
|
+
*
|
|
92
|
+
* Order of precedence:
|
|
93
|
+
* 1. DM → respond
|
|
94
|
+
* 2. Bot @mentioned → respond
|
|
95
|
+
* 3. Direct reply to a bot message → respond
|
|
96
|
+
* 4. Thread already in active-bot-thread map → respond
|
|
97
|
+
* 5. Cache cold: check Matrix history for prior bot participation → respond
|
|
98
|
+
* 6. Otherwise → ignore (still capture passively elsewhere)
|
|
99
|
+
*/
|
|
100
|
+
export async function shouldAgentRespond(input) {
|
|
101
|
+
const { event, roomId, threadId, matrixManager, botMatrixUserId, roomInfo, activeBotThreads, activeBotThreadTtlMs, } = input;
|
|
102
|
+
if (roomInfo.isDirect) {
|
|
103
|
+
return { respond: true, reason: 'dm' };
|
|
104
|
+
}
|
|
105
|
+
if (isBotMentioned(event.content, botMatrixUserId)) {
|
|
106
|
+
return { respond: true, reason: 'mentioned' };
|
|
107
|
+
}
|
|
108
|
+
if (await isReplyToBotMessage(event, roomId, matrixManager, botMatrixUserId)) {
|
|
109
|
+
return { respond: true, reason: 'reply-to-bot' };
|
|
110
|
+
}
|
|
111
|
+
if (isActiveBotThread(activeBotThreads, roomId, threadId)) {
|
|
112
|
+
return { respond: true, reason: 'active-thread' };
|
|
113
|
+
}
|
|
114
|
+
if (threadId !== event.eventId &&
|
|
115
|
+
(await hasBotSpokenInThread(roomId, threadId, matrixManager, botMatrixUserId, activeBotThreads, activeBotThreadTtlMs))) {
|
|
116
|
+
return { respond: true, reason: 'active-thread' };
|
|
117
|
+
}
|
|
118
|
+
return { respond: false, reason: 'ignored' };
|
|
119
|
+
}
|
|
120
|
+
export function getCurrentSpeaker(messages, fallbackDid) {
|
|
121
|
+
if (!messages || messages.length === 0)
|
|
122
|
+
return { did: fallbackDid };
|
|
123
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
124
|
+
const m = messages[i];
|
|
125
|
+
if (m && typeof m._getType === 'function' && m._getType() === 'human') {
|
|
126
|
+
const kwargs = (m.additional_kwargs ?? {});
|
|
127
|
+
const did = typeof kwargs.senderDid === 'string' ? kwargs.senderDid : fallbackDid;
|
|
128
|
+
const matrixUserId = typeof kwargs.senderMatrixUserId === 'string'
|
|
129
|
+
? kwargs.senderMatrixUserId
|
|
130
|
+
: undefined;
|
|
131
|
+
const displayName = typeof kwargs.senderDisplayName === 'string'
|
|
132
|
+
? kwargs.senderDisplayName
|
|
133
|
+
: undefined;
|
|
134
|
+
return { did, matrixUserId, displayName };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return { did: fallbackDid };
|
|
138
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { MatrixManager } from '@ixo/matrix';
|
|
2
|
+
import type { DynamicModule, Type } from '@nestjs/common';
|
|
3
|
+
import { type AgentMiddleware } from 'langchain';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { OraclePlugin } from '../../plugin-api/oracle-plugin.js';
|
|
6
|
+
import type { PluginContext, PluginManifest, PluginTool, RuntimeContext } from '../../plugin-api/types.js';
|
|
7
|
+
/**
|
|
8
|
+
* `matrix-group-chats` — one plugin that owns the per-room memory pipeline
|
|
9
|
+
* AND the per-turn gating middleware for Matrix group rooms.
|
|
10
|
+
*
|
|
11
|
+
* Activation:
|
|
12
|
+
* - **Boot:** on by default. Developers opt out with
|
|
13
|
+
* `features: { 'matrix-group-chats': false }`.
|
|
14
|
+
* - **Per request:** the middleware short-circuits when the session is not
|
|
15
|
+
* a Matrix room with >2 members, and `getRequestTools` returns the four
|
|
16
|
+
* channel-memory tools only for group rooms, so DM oracles never see
|
|
17
|
+
* them in the prompt.
|
|
18
|
+
*
|
|
19
|
+
* Tools (per-tool visibility=`always`, bypassing the capability gate):
|
|
20
|
+
* - `recall_channel_memory` — recent chunks + pinned facts + members
|
|
21
|
+
* - `search_channel_memory` — FTS5 keyword search over compacted chunks
|
|
22
|
+
* - `pin_room_fact` / `unpin_room_fact` — manage durable per-room facts
|
|
23
|
+
*/
|
|
24
|
+
export declare class MatrixGroupChatsPlugin extends OraclePlugin {
|
|
25
|
+
static readonly NAME = "matrix-group-chats";
|
|
26
|
+
readonly name = "matrix-group-chats";
|
|
27
|
+
readonly version = "1.0.0";
|
|
28
|
+
readonly manifest: PluginManifest;
|
|
29
|
+
readonly configSchema: z.ZodObject<{
|
|
30
|
+
CHANNEL_MEMORY_SYNC_INTERVAL_MS: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
31
|
+
GROUP_CHAT_ACTIVE_THREAD_TTL_MS: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
32
|
+
GROUP_CHAT_REQUIRE_POWER_LEVEL: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
33
|
+
GROUP_CHAT_ROOM_INFO_TTL_MS: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
/** Shared between `getRequestTools` (membership check) and the middleware. */
|
|
36
|
+
private readonly roomInfoCache;
|
|
37
|
+
getNestModules(): Array<Type | DynamicModule>;
|
|
38
|
+
getMiddlewares(ctx: PluginContext): AgentMiddleware[];
|
|
39
|
+
/**
|
|
40
|
+
* Per-request: only expose the four channel-memory tools when the current
|
|
41
|
+
* session is in a Matrix group room (memberCount > 2). DM / portal /
|
|
42
|
+
* slack sessions get an empty list so the agent never sees them.
|
|
43
|
+
*/
|
|
44
|
+
getRequestTools(rtCtx: RuntimeContext): Promise<PluginTool[]>;
|
|
45
|
+
getSharedState(): Record<string, (state: unknown, runCtx: RuntimeContext) => unknown>;
|
|
46
|
+
}
|
|
47
|
+
export { ChannelMemoryModule } from './channel-memory.module.js';
|
|
48
|
+
export { ChannelMemoryService } from './channel-memory.service.js';
|
|
49
|
+
export { CHANNEL_MEMORY_SHARED_KEY, type ChannelMember, type ChannelMemoryChunk, type ObservedMessage, type PinnedFact, } from './channel-memory.types.js';
|
|
50
|
+
export { isBotMentioned, isReplyToBotMessage, isActiveBotThread, markBotThreadActive, sweepExpiredBotThreads, shouldAgentRespond, getCurrentSpeaker, type GuardEvent, type RoomTypeInfo, type ShouldRespondInput, type ShouldRespondReason, type ShouldRespondResult, type SpeakerContext, } from './guard.js';
|
|
51
|
+
export { getBotPowerLevel, type BotPowerLevel } from './power-levels.js';
|
|
52
|
+
export { RoomInfoCache } from './room-info.js';
|
|
53
|
+
/**
|
|
54
|
+
* Tiny export so tests can assert the plugin behaves identically against
|
|
55
|
+
* the real MatrixManager singleton. Exposed for symmetry — production
|
|
56
|
+
* callers should use `MatrixGroupChatsPlugin` directly.
|
|
57
|
+
*/
|
|
58
|
+
export { MatrixManager };
|
|
59
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/matrix-group-chats/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,cAAc,EACf,MAAM,2BAA2B,CAAC;AA8EnC;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,sBAAuB,SAAQ,YAAY;IACtD,MAAM,CAAC,QAAQ,CAAC,IAAI,wBAAwB;IAE5C,QAAQ,CAAC,IAAI,wBAA+B;IAE5C,QAAQ,CAAC,OAAO,WAAW;IAE3B,QAAQ,CAAC,QAAQ,iBAAY;IAE7B,SAAkB,YAAY;;;;;sBAAgB;IAE9C,8EAA8E;IAC9E,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA+C;IAEpE,cAAc,IAAI,KAAK,CAAC,IAAI,GAAG,aAAa,CAAC;IAI7C,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,eAAe,EAAE;IAI9D;;;;OAIG;IACY,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAkBnE,cAAc,IAAI,MAAM,CAC/B,MAAM,EACN,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,KAAK,OAAO,CACpD;CAKF;AAED,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EACL,yBAAyB,EACzB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,UAAU,GAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { MatrixManager } from '@ixo/matrix';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { OraclePlugin } from '../../plugin-api/oracle-plugin.js';
|
|
4
|
+
import { ChannelMemoryModule } from './channel-memory.module.js';
|
|
5
|
+
import { ChannelMemoryService } from './channel-memory.service.js';
|
|
6
|
+
import { CHANNEL_MEMORY_SHARED_KEY } from './channel-memory.types.js';
|
|
7
|
+
import { buildGroupChatMiddleware } from './middleware.js';
|
|
8
|
+
import { RoomInfoCache } from './room-info.js';
|
|
9
|
+
import { buildChannelMemoryTools } from './tools.js';
|
|
10
|
+
const DEFAULT_ROOM_INFO_TTL_MS = 30 * 60 * 1000;
|
|
11
|
+
const configSchema = z.object({
|
|
12
|
+
CHANNEL_MEMORY_SYNC_INTERVAL_MS: z.coerce
|
|
13
|
+
.number()
|
|
14
|
+
.int()
|
|
15
|
+
.min(1000)
|
|
16
|
+
.default(60_000)
|
|
17
|
+
.describe('Debounce window between a write and the Matrix snapshot upload.'),
|
|
18
|
+
// Group-chat gating
|
|
19
|
+
GROUP_CHAT_ACTIVE_THREAD_TTL_MS: z.coerce
|
|
20
|
+
.number()
|
|
21
|
+
.int()
|
|
22
|
+
.min(60_000)
|
|
23
|
+
.default(30 * 60 * 1000)
|
|
24
|
+
.describe('How long a thread stays "active with the bot" after a reply.'),
|
|
25
|
+
GROUP_CHAT_REQUIRE_POWER_LEVEL: z.coerce
|
|
26
|
+
.number()
|
|
27
|
+
.int()
|
|
28
|
+
.min(0)
|
|
29
|
+
.default(0)
|
|
30
|
+
.describe('Extra minimum power level the bot must have before posting (0 = use the room default).'),
|
|
31
|
+
GROUP_CHAT_ROOM_INFO_TTL_MS: z.coerce
|
|
32
|
+
.number()
|
|
33
|
+
.int()
|
|
34
|
+
.min(60_000)
|
|
35
|
+
.default(DEFAULT_ROOM_INFO_TTL_MS)
|
|
36
|
+
.describe('How long roomInfo (membership, DM flag) stays cached.'),
|
|
37
|
+
});
|
|
38
|
+
const manifest = {
|
|
39
|
+
title: 'Matrix Group Chats',
|
|
40
|
+
summary: 'Lets the oracle participate cleanly in Matrix group rooms: it only replies when mentioned, replied to, or already in an active thread, and keeps an FTS5-searchable compacted memory of every room it sits in.',
|
|
41
|
+
whenToUse: [
|
|
42
|
+
'A user asks what was said or decided earlier in this Matrix group room.',
|
|
43
|
+
'A user asks who is in the room or what their role is.',
|
|
44
|
+
'A durable fact should survive across threads (deadline, decision, project context) — pin it.',
|
|
45
|
+
'You need to recall the gist of prior conversation before answering a multi-step group request.',
|
|
46
|
+
],
|
|
47
|
+
whenNotToUse: [
|
|
48
|
+
'Single-user DMs — the plugin only acts in rooms with more than 2 members.',
|
|
49
|
+
'Long-term personal memory about a specific user — use the Memory plugin.',
|
|
50
|
+
'Verbatim text of a specific Matrix event — use Matrix history directly.',
|
|
51
|
+
],
|
|
52
|
+
examples: [
|
|
53
|
+
{
|
|
54
|
+
user: 'What did we agree about the launch date?',
|
|
55
|
+
thought: 'Search channel memory for "launch date" before answering — the decision may be in an older chunk.',
|
|
56
|
+
tool: 'search_channel_memory',
|
|
57
|
+
args: { query: 'launch date' },
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
user: 'Remember that Alice owns the redesign.',
|
|
61
|
+
thought: 'Persist that as a pinned fact for the group room.',
|
|
62
|
+
tool: 'pin_room_fact',
|
|
63
|
+
args: { fact: 'Alice owns the redesign.' },
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
tags: ['matrix', 'group-chat', 'memory'],
|
|
67
|
+
category: 'communication',
|
|
68
|
+
visibility: 'on-demand',
|
|
69
|
+
stability: 'beta',
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* `matrix-group-chats` — one plugin that owns the per-room memory pipeline
|
|
73
|
+
* AND the per-turn gating middleware for Matrix group rooms.
|
|
74
|
+
*
|
|
75
|
+
* Activation:
|
|
76
|
+
* - **Boot:** on by default. Developers opt out with
|
|
77
|
+
* `features: { 'matrix-group-chats': false }`.
|
|
78
|
+
* - **Per request:** the middleware short-circuits when the session is not
|
|
79
|
+
* a Matrix room with >2 members, and `getRequestTools` returns the four
|
|
80
|
+
* channel-memory tools only for group rooms, so DM oracles never see
|
|
81
|
+
* them in the prompt.
|
|
82
|
+
*
|
|
83
|
+
* Tools (per-tool visibility=`always`, bypassing the capability gate):
|
|
84
|
+
* - `recall_channel_memory` — recent chunks + pinned facts + members
|
|
85
|
+
* - `search_channel_memory` — FTS5 keyword search over compacted chunks
|
|
86
|
+
* - `pin_room_fact` / `unpin_room_fact` — manage durable per-room facts
|
|
87
|
+
*/
|
|
88
|
+
export class MatrixGroupChatsPlugin extends OraclePlugin {
|
|
89
|
+
static NAME = 'matrix-group-chats';
|
|
90
|
+
name = MatrixGroupChatsPlugin.NAME;
|
|
91
|
+
version = '1.0.0';
|
|
92
|
+
manifest = manifest;
|
|
93
|
+
configSchema = configSchema;
|
|
94
|
+
/** Shared between `getRequestTools` (membership check) and the middleware. */
|
|
95
|
+
roomInfoCache = new RoomInfoCache(DEFAULT_ROOM_INFO_TTL_MS);
|
|
96
|
+
getNestModules() {
|
|
97
|
+
return [ChannelMemoryModule];
|
|
98
|
+
}
|
|
99
|
+
getMiddlewares(ctx) {
|
|
100
|
+
return [buildGroupChatMiddleware(ctx)];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Per-request: only expose the four channel-memory tools when the current
|
|
104
|
+
* session is in a Matrix group room (memberCount > 2). DM / portal /
|
|
105
|
+
* slack sessions get an empty list so the agent never sees them.
|
|
106
|
+
*/
|
|
107
|
+
async getRequestTools(rtCtx) {
|
|
108
|
+
if (rtCtx.session.client !== 'matrix' || !rtCtx.session.roomId) {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
const info = await this.roomInfoCache.get(rtCtx.session.roomId);
|
|
113
|
+
if (info.isDirect || info.memberCount <= 2) {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
rtCtx.logger.warn?.(`[matrix-group-chats] getRoomInfo failed for ${rtCtx.session.roomId}: ${err instanceof Error ? err.message : String(err)} — skipping tools`);
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
return buildChannelMemoryTools();
|
|
122
|
+
}
|
|
123
|
+
getSharedState() {
|
|
124
|
+
return {
|
|
125
|
+
[CHANNEL_MEMORY_SHARED_KEY]: () => ChannelMemoryService.getInstance(),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export { ChannelMemoryModule } from './channel-memory.module.js';
|
|
130
|
+
export { ChannelMemoryService } from './channel-memory.service.js';
|
|
131
|
+
export { CHANNEL_MEMORY_SHARED_KEY, } from './channel-memory.types.js';
|
|
132
|
+
export { isBotMentioned, isReplyToBotMessage, isActiveBotThread, markBotThreadActive, sweepExpiredBotThreads, shouldAgentRespond, getCurrentSpeaker, } from './guard.js';
|
|
133
|
+
export { getBotPowerLevel } from './power-levels.js';
|
|
134
|
+
export { RoomInfoCache } from './room-info.js';
|
|
135
|
+
/**
|
|
136
|
+
* Tiny export so tests can assert the plugin behaves identically against
|
|
137
|
+
* the real MatrixManager singleton. Exposed for symmetry — production
|
|
138
|
+
* callers should use `MatrixGroupChatsPlugin` directly.
|
|
139
|
+
*/
|
|
140
|
+
export { MatrixManager };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type AgentMiddleware } from 'langchain';
|
|
2
|
+
import type { Logger, PluginContext } from '../../plugin-api/types.js';
|
|
3
|
+
export interface GroupChatMiddlewareOptions {
|
|
4
|
+
activeThreadTtlMs: number;
|
|
5
|
+
requirePowerLevel: number;
|
|
6
|
+
roomInfoTtlMs: number;
|
|
7
|
+
logger?: Logger;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Per-turn gate for Matrix group rooms. Runs as `beforeAgent`:
|
|
11
|
+
*
|
|
12
|
+
* - Non-Matrix transports → pass through.
|
|
13
|
+
* - DMs / rooms with ≤2 members → pass through.
|
|
14
|
+
* - Group rooms (>2 members):
|
|
15
|
+
* - Capture the latest HumanMessage into channel memory (side effect).
|
|
16
|
+
* - Run `shouldAgentRespond` (mention / reply-to-bot / active-thread).
|
|
17
|
+
* - If the bot shouldn't respond → short-circuit with `jumpTo: 'end'`.
|
|
18
|
+
* - If it should → check `m.room.power_levels`; short-circuit when the
|
|
19
|
+
* bot lacks send permission.
|
|
20
|
+
*
|
|
21
|
+
* Does NOT declare a `stateSchema` and NEVER returns state updates.
|
|
22
|
+
* Re-declaring the agent's built-in `messages` channel clobbers its
|
|
23
|
+
* `addMessages` reducer and resets the conversation per turn — that's why
|
|
24
|
+
* earlier versions of this middleware caused "every message is a new
|
|
25
|
+
* thread" behaviour. Side effects only.
|
|
26
|
+
*/
|
|
27
|
+
export declare const createGroupChatMiddleware: (options: GroupChatMiddlewareOptions) => AgentMiddleware;
|
|
28
|
+
/** Build the middleware from `PluginContext` config. */
|
|
29
|
+
export declare function buildGroupChatMiddleware(ctx: PluginContext): AgentMiddleware;
|
|
30
|
+
export { RoomInfoCache } from './room-info.js';
|
|
31
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/plugins/matrix-group-chats/middleware.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAEnE,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAkBvE,MAAM,WAAW,0BAA0B;IACzC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,yBAAyB,GACpC,SAAS,0BAA0B,KAClC,eAiJF,CAAC;AAmCF,wDAAwD;AACxD,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,aAAa,GAAG,eAAe,CAY5E;AAED,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|