@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,302 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/** Insufficient-balance error raised by `limit()`. */
|
|
4
|
+
export class TokenLimiterError extends Error {
|
|
5
|
+
type;
|
|
6
|
+
limit;
|
|
7
|
+
currentBalance;
|
|
8
|
+
reset;
|
|
9
|
+
constructor(message, type, limit, reset, currentBalance) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.type = type;
|
|
12
|
+
this.limit = limit;
|
|
13
|
+
this.reset = reset;
|
|
14
|
+
this.currentBalance = currentBalance;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const NOOP_LOGGER = {
|
|
18
|
+
log: () => undefined,
|
|
19
|
+
warn: () => undefined,
|
|
20
|
+
error: () => undefined,
|
|
21
|
+
};
|
|
22
|
+
const KEY_PREFIX = 'token_limit:';
|
|
23
|
+
const KEY_BALANCE = 'balance';
|
|
24
|
+
const KEY_HELD_AMOUNTS = 'held_amounts';
|
|
25
|
+
const KEY_SUBSCRIPTION_PAYLOAD = 'subscription_payload';
|
|
26
|
+
const KEY_PENDING_CLAIM = 'pending_claim';
|
|
27
|
+
// Atomic balance decrement + held-amount increment, with rollback on overdraft.
|
|
28
|
+
const LIMIT_TOKENS_SCRIPT = `
|
|
29
|
+
local balanceKey = KEYS[1]
|
|
30
|
+
local heldAmountsKey = KEYS[2]
|
|
31
|
+
local userDid = ARGV[1]
|
|
32
|
+
local tokenCount = tonumber(ARGV[2])
|
|
33
|
+
|
|
34
|
+
local newBalance = tonumber(redis.call('INCRBYFLOAT', balanceKey, -tokenCount))
|
|
35
|
+
|
|
36
|
+
if newBalance < 0 then
|
|
37
|
+
redis.call('INCRBYFLOAT', balanceKey, tokenCount)
|
|
38
|
+
return {0, newBalance + tokenCount, 'INSUFFICIENT_BALANCE'}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
redis.call('ZINCRBY', heldAmountsKey, tokenCount, userDid)
|
|
42
|
+
|
|
43
|
+
return {1, newBalance, 'SUCCESS'}
|
|
44
|
+
`;
|
|
45
|
+
/**
|
|
46
|
+
* Per-user credit budget enforced against Redis. The runtime instantiates
|
|
47
|
+
* one `TokenLimiter` per oracle and shares it between the middleware (live
|
|
48
|
+
* deduction on the LLM hot path) and the subscription middleware (which
|
|
49
|
+
* mirrors the chain-side balance into Redis on every authenticated request).
|
|
50
|
+
*
|
|
51
|
+
* Costs are computed in three priority tiers:
|
|
52
|
+
* 1. provider-supplied USD cost (e.g. OpenRouter `usage.cost`)
|
|
53
|
+
* 2. cached per-model pricing × tokens
|
|
54
|
+
* 3. flat-rate `$0.75 / 1M tokens` fallback
|
|
55
|
+
*/
|
|
56
|
+
export class TokenLimiter {
|
|
57
|
+
redis;
|
|
58
|
+
network;
|
|
59
|
+
disableCredits;
|
|
60
|
+
lookupModelPricing;
|
|
61
|
+
logger;
|
|
62
|
+
static getSubscriptionPayloadKey(userDid) {
|
|
63
|
+
return `${KEY_PREFIX}${userDid}:${KEY_SUBSCRIPTION_PAYLOAD}`;
|
|
64
|
+
}
|
|
65
|
+
static getUserBalanceKey(userDid) {
|
|
66
|
+
return `${KEY_PREFIX}${userDid}:${KEY_BALANCE}`;
|
|
67
|
+
}
|
|
68
|
+
static getPendingClaimKey(userDid) {
|
|
69
|
+
return `${KEY_PREFIX}${userDid}:${KEY_PENDING_CLAIM}`;
|
|
70
|
+
}
|
|
71
|
+
static getHeldAmountsKey() {
|
|
72
|
+
return KEY_HELD_AMOUNTS;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Deterministic claim ID derived from `userDid + batchStartTime`. Retries
|
|
76
|
+
* for the same batch resolve to the same ID, preventing duplicate claims.
|
|
77
|
+
*/
|
|
78
|
+
static generateClaimId(userDid, batchStartTime) {
|
|
79
|
+
const hash = crypto
|
|
80
|
+
.createHash('sha256')
|
|
81
|
+
.update(`${userDid}:${batchStartTime}`)
|
|
82
|
+
.digest('hex');
|
|
83
|
+
return `claim_${hash.slice(0, 32)}`;
|
|
84
|
+
}
|
|
85
|
+
constructor(options) {
|
|
86
|
+
this.redis = options.redis;
|
|
87
|
+
this.network = options.network;
|
|
88
|
+
this.disableCredits = options.disableCredits ?? false;
|
|
89
|
+
this.lookupModelPricing =
|
|
90
|
+
options.modelPricingLookup ?? (() => null);
|
|
91
|
+
this.logger = options.logger ?? NOOP_LOGGER;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Convert raw USD cost (e.g. OpenRouter `response_metadata.usage.cost`)
|
|
95
|
+
* into credits. On mainnet 1 USD = 1000 credits; devnet uses a 10x
|
|
96
|
+
* multiplier so micro-costs are visible during testing.
|
|
97
|
+
*/
|
|
98
|
+
usdCostToCredits(usdCost) {
|
|
99
|
+
const isMainnet = this.network === 'mainnet';
|
|
100
|
+
const creditsPerUsd = isMainnet ? 1000 : 10_000;
|
|
101
|
+
const markup = isMainnet ? 1.6 : 4;
|
|
102
|
+
return Math.round(usdCost * creditsPerUsd * markup);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Cost in USD (post-markup) using the same 3-priority fallback as
|
|
106
|
+
* `creditsForUsage`. Exposed for callers that bill outside the agent
|
|
107
|
+
* graph (e.g. file-processing pre-flight charges).
|
|
108
|
+
*/
|
|
109
|
+
calculateCostUsdWithMarkup(params) {
|
|
110
|
+
const markup = this.network === 'mainnet' ? 1.6 : 5;
|
|
111
|
+
if (params.providerCost != null && params.providerCost > 0) {
|
|
112
|
+
return params.providerCost * markup;
|
|
113
|
+
}
|
|
114
|
+
const pricing = params.model ? this.lookupModelPricing(params.model) : null;
|
|
115
|
+
if (pricing) {
|
|
116
|
+
const inputCost = (params.inputTokens / 1_000_000) * pricing.inputPricePerMillionTokens;
|
|
117
|
+
const outputCost = (params.outputTokens / 1_000_000) * pricing.outputPricePerMillionTokens;
|
|
118
|
+
return (inputCost + outputCost) * markup;
|
|
119
|
+
}
|
|
120
|
+
return (params.totalTokens / 1_000_000) * 0.75 * markup;
|
|
121
|
+
}
|
|
122
|
+
/** Flat-rate fallback: $0.75 per 1M tokens × network markup. */
|
|
123
|
+
llmTokenToCredits(tokenCount) {
|
|
124
|
+
const markup = this.network === 'mainnet' ? 1.6 : 5;
|
|
125
|
+
const costPerMillionTokens = 0.75 * markup;
|
|
126
|
+
const tokensPerMillion = this.network === 'mainnet' ? 1_000_000 : 1000;
|
|
127
|
+
return Math.round((tokenCount / tokensPerMillion) * costPerMillionTokens);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Credits using per-model pricing (separate input/output rates). Falls
|
|
131
|
+
* through to the flat-rate fallback when pricing is `null`.
|
|
132
|
+
*/
|
|
133
|
+
llmTokenToCreditsWithPricing(inputTokens, outputTokens, pricing) {
|
|
134
|
+
if (!pricing) {
|
|
135
|
+
this.logger.log('[TokenLimiter] No pricing found, falling back to flat rate');
|
|
136
|
+
return this.llmTokenToCredits(inputTokens + outputTokens);
|
|
137
|
+
}
|
|
138
|
+
const markup = this.network === 'mainnet' ? 1.6 : 5;
|
|
139
|
+
const divisor = this.network === 'mainnet' ? 1_000_000 : 1000;
|
|
140
|
+
const inputCost = (inputTokens / divisor) * pricing.inputPricePerMillionTokens;
|
|
141
|
+
const outputCost = (outputTokens / divisor) * pricing.outputPricePerMillionTokens;
|
|
142
|
+
return Math.round((inputCost + outputCost) * markup);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Compute credit cost for a single completion using the standard 3-priority
|
|
146
|
+
* fallback. The middleware's `afterModel` hook calls this on every LLM
|
|
147
|
+
* response.
|
|
148
|
+
*/
|
|
149
|
+
creditsForUsage(params) {
|
|
150
|
+
if (params.providerCost != null && params.providerCost > 0) {
|
|
151
|
+
const credits = this.usdCostToCredits(params.providerCost);
|
|
152
|
+
this.logger.log(`[TokenLimiter] Using provider cost: $${params.providerCost} → ${credits} credits`);
|
|
153
|
+
return credits;
|
|
154
|
+
}
|
|
155
|
+
const pricing = params.model ? this.lookupModelPricing(params.model) : null;
|
|
156
|
+
if (pricing) {
|
|
157
|
+
const credits = this.llmTokenToCreditsWithPricing(params.inputTokens, params.outputTokens, pricing);
|
|
158
|
+
this.logger.log(`[TokenLimiter] Using cached pricing for model=${params.model ?? 'unknown'} → ${credits} credits`);
|
|
159
|
+
return credits;
|
|
160
|
+
}
|
|
161
|
+
const credits = this.llmTokenToCredits(params.totalTokens);
|
|
162
|
+
this.logger.log(`[TokenLimiter] Using flat-rate fallback (model=${params.model ?? 'unknown'}) → ${credits} credits`);
|
|
163
|
+
return credits;
|
|
164
|
+
}
|
|
165
|
+
async setSubscriptionPayload(userDid, payload) {
|
|
166
|
+
await this.redis.set(TokenLimiter.getSubscriptionPayloadKey(userDid), JSON.stringify({
|
|
167
|
+
adminAddress: payload.adminAddress,
|
|
168
|
+
claimCollections: payload.claimCollections,
|
|
169
|
+
totalCredits: payload.totalCredits,
|
|
170
|
+
}));
|
|
171
|
+
}
|
|
172
|
+
async getSubscriptionPayload(userDid) {
|
|
173
|
+
const payload = await this.redis.get(TokenLimiter.getSubscriptionPayloadKey(userDid));
|
|
174
|
+
return payload
|
|
175
|
+
? JSON.parse(payload)
|
|
176
|
+
: null;
|
|
177
|
+
}
|
|
178
|
+
async getUserHeldAmount(userDid) {
|
|
179
|
+
const result = await this.redis.zscore(KEY_HELD_AMOUNTS, userDid);
|
|
180
|
+
return result ? parseFloat(result) : 0;
|
|
181
|
+
}
|
|
182
|
+
async incrementUserHeldAmount(userDid, amount) {
|
|
183
|
+
await this.redis.zincrby(KEY_HELD_AMOUNTS, amount, userDid);
|
|
184
|
+
}
|
|
185
|
+
async deleteUserHeldAmount(userDid) {
|
|
186
|
+
await this.redis.zrem(KEY_HELD_AMOUNTS, userDid);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* List users whose held amount is at or above `amount`. Result rows are
|
|
190
|
+
* `[did, heldAmount]` tuples.
|
|
191
|
+
*/
|
|
192
|
+
async listUsersWithHeldAmount(amount) {
|
|
193
|
+
const raw = await this.redis.zrangebyscore(KEY_HELD_AMOUNTS, amount, '+inf', 'WITHSCORES');
|
|
194
|
+
const result = [];
|
|
195
|
+
for (let i = 0; i < raw.length; i += 2) {
|
|
196
|
+
result.push([raw[i], parseFloat(raw[i + 1])]);
|
|
197
|
+
}
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Reconcile the Redis balance with the chain-side subscription balance.
|
|
202
|
+
* Subtracts any pending held amount to surface the user's actual usable
|
|
203
|
+
* balance. Throws when the held amount exceeds the chain balance (a
|
|
204
|
+
* sync error) unless credits are disabled.
|
|
205
|
+
*/
|
|
206
|
+
async overrideUserBalance(userDid, balance) {
|
|
207
|
+
z.number().parse(balance);
|
|
208
|
+
const heldAmount = await this.getUserHeldAmount(userDid);
|
|
209
|
+
const newBalance = balance - heldAmount;
|
|
210
|
+
if (newBalance < 0) {
|
|
211
|
+
this.logger.error(`CRITICAL: Held amount (${heldAmount}) exceeds chain balance (${balance}) for user ${userDid}.`);
|
|
212
|
+
await this.redis.set(TokenLimiter.getUserBalanceKey(userDid), '0');
|
|
213
|
+
if (this.disableCredits) {
|
|
214
|
+
return '0';
|
|
215
|
+
}
|
|
216
|
+
throw new TokenLimiterError(`It looks like you have some usage pending that's higher than your current balance (${balance / 1000}). Please add more credits to your account to continue. If you think this is a mistake, please contact support. (Held: ${heldAmount / 1000})`, 'token', undefined, undefined, balance);
|
|
217
|
+
}
|
|
218
|
+
await this.redis.set(TokenLimiter.getUserBalanceKey(userDid), newBalance.toString());
|
|
219
|
+
this.logger.debug?.(`Overriding balance for user ${userDid} to current balance: ${newBalance}, held amount: ${heldAmount}, subscription balance: ${balance}`);
|
|
220
|
+
return newBalance.toString();
|
|
221
|
+
}
|
|
222
|
+
async getUserBalance(userDid) {
|
|
223
|
+
const balance = await this.redis.get(TokenLimiter.getUserBalanceKey(userDid));
|
|
224
|
+
return balance ? parseFloat(balance) : 0;
|
|
225
|
+
}
|
|
226
|
+
async getRemaining(userDid) {
|
|
227
|
+
return this.getUserBalance(userDid);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Decrement the user's balance by `credits` and add the same amount to
|
|
231
|
+
* their held-amount sorted-set entry, atomically via a Lua script.
|
|
232
|
+
* Throws `TokenLimiterError` when the balance would go negative.
|
|
233
|
+
*/
|
|
234
|
+
async limit(userDid, credits) {
|
|
235
|
+
const balanceKey = TokenLimiter.getUserBalanceKey(userDid);
|
|
236
|
+
const heldAmountsKey = KEY_HELD_AMOUNTS;
|
|
237
|
+
try {
|
|
238
|
+
const result = (await this.redis.eval(LIMIT_TOKENS_SCRIPT, 2, balanceKey, heldAmountsKey, userDid, credits.toString()));
|
|
239
|
+
const [success, balance] = result;
|
|
240
|
+
if (success === 0) {
|
|
241
|
+
throw new TokenLimiterError(`Insufficient balance. Current balance: ${balance}`, 'token', credits, undefined, balance);
|
|
242
|
+
}
|
|
243
|
+
this.logger.debug?.(`Limited ${credits} credits for user ${userDid}, remaining: ${balance}`);
|
|
244
|
+
return { success: true, remaining: balance };
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
if (error instanceof TokenLimiterError) {
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
250
|
+
this.logger.error(`Failed to limit tokens for user ${userDid}: ${error instanceof Error ? error.message : String(error)}`);
|
|
251
|
+
throw new TokenLimiterError('Failed to process token limit', 'token', credits);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
async setPendingClaim(userDid, claimId, amount, batchStartTime) {
|
|
255
|
+
const now = Date.now();
|
|
256
|
+
const payload = {
|
|
257
|
+
claimId,
|
|
258
|
+
amount,
|
|
259
|
+
timestamp: now,
|
|
260
|
+
batchStartTime: batchStartTime ?? now,
|
|
261
|
+
};
|
|
262
|
+
await this.redis.set(TokenLimiter.getPendingClaimKey(userDid), JSON.stringify(payload), 'EX', 60 * 60);
|
|
263
|
+
}
|
|
264
|
+
async getPendingClaim(userDid) {
|
|
265
|
+
const data = await this.redis.get(TokenLimiter.getPendingClaimKey(userDid));
|
|
266
|
+
return data
|
|
267
|
+
? JSON.parse(data)
|
|
268
|
+
: null;
|
|
269
|
+
}
|
|
270
|
+
async clearPendingClaim(userDid) {
|
|
271
|
+
await this.redis.del(TokenLimiter.getPendingClaimKey(userDid));
|
|
272
|
+
}
|
|
273
|
+
async updatePendingClaimAmount(userDid, newAmount) {
|
|
274
|
+
const pending = await this.getPendingClaim(userDid);
|
|
275
|
+
if (!pending) {
|
|
276
|
+
this.logger.warn(`Attempted to update pending claim amount for ${userDid}, but no pending claim exists`);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
await this.setPendingClaim(userDid, pending.claimId, newAmount, pending.batchStartTime);
|
|
280
|
+
this.logger.debug?.(`Updated pending claim ${pending.claimId} amount from ${pending.amount} to ${newAmount} for user ${userDid}`);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Return the existing pending-claim ID for `userDid`, refreshing the
|
|
284
|
+
* amount if the held amount changed; otherwise create a new claim entry
|
|
285
|
+
* with a deterministic ID.
|
|
286
|
+
*/
|
|
287
|
+
async getOrCreatePendingClaim(userDid, currentHeldAmount) {
|
|
288
|
+
const pending = await this.getPendingClaim(userDid);
|
|
289
|
+
if (pending) {
|
|
290
|
+
if (pending.amount !== currentHeldAmount) {
|
|
291
|
+
this.logger.debug?.(`Held amount changed from ${pending.amount} to ${currentHeldAmount} for user ${userDid}. Updating pending claim.`);
|
|
292
|
+
await this.updatePendingClaimAmount(userDid, currentHeldAmount);
|
|
293
|
+
}
|
|
294
|
+
return pending.claimId;
|
|
295
|
+
}
|
|
296
|
+
const batchStartTime = Date.now();
|
|
297
|
+
const claimId = TokenLimiter.generateClaimId(userDid, batchStartTime);
|
|
298
|
+
await this.setPendingClaim(userDid, claimId, currentHeldAmount, batchStartTime);
|
|
299
|
+
this.logger.debug?.(`Created new pending claim ${claimId} for user ${userDid} with amount ${currentHeldAmount}`);
|
|
300
|
+
return claimId;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PluginSubAgent, PluginTool } from '../../plugin-api/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Build the Domain Indexer sub-agent definition. Tools are supplied by the
|
|
4
|
+
* plugin and closed over `DOMAIN_INDEXER_URL` from the merged config.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createDomainIndexerSubAgent(tools: PluginTool[]): PluginSubAgent;
|
|
7
|
+
//# sourceMappingURL=domain-indexer-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-indexer-agent.d.ts","sourceRoot":"","sources":["../../../src/plugins/domain-indexer/domain-indexer-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAyC5E;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,UAAU,EAAE,GAClB,cAAc,CAShB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const formatToolDocs = (tools) => tools
|
|
2
|
+
.map((t) => {
|
|
3
|
+
const description = t.description?.trim() ?? 'No description provided.';
|
|
4
|
+
return `- \`${t.name}\`: ${description}`;
|
|
5
|
+
})
|
|
6
|
+
.join('\n');
|
|
7
|
+
const buildSystemPrompt = (tools) => `
|
|
8
|
+
You are the Domain Indexer Agent. You are the specialist for searching the IXO Domain Indexer—treat it like Google for IXO entities (organizations, projects, DAOs, agents, compositions, events).
|
|
9
|
+
|
|
10
|
+
Core expectations:
|
|
11
|
+
- Always clarify the user’s goal and translate it into a concrete search query or DID lookup.
|
|
12
|
+
- Never call tools with empty parameters; \`domain_indexer_search\` always needs a query, \`get_domain_card\` always needs a DID.
|
|
13
|
+
- Explain what you are searching for, summarize the results, and cite relevant DIDs or entity names.
|
|
14
|
+
- When multiple results appear, compare them briefly and suggest next steps.
|
|
15
|
+
|
|
16
|
+
Task discipline:
|
|
17
|
+
- You are a sub-agent invoked by the main agent. You receive a single task message — that is ALL the context you have.
|
|
18
|
+
- If the task is unclear, ambiguous, or missing critical details (IDs, names, scope, what to do), do NOT guess. Instead, STOP immediately and return a clear message explaining what information you need. The main agent will ask the user and re-invoke you with a complete task.
|
|
19
|
+
- Never loop or retry the same failing approach. If something fails twice, return the error and stop.
|
|
20
|
+
- Complete the requested task and STOP. Do not do additional unrequested work.
|
|
21
|
+
|
|
22
|
+
### Available Domain Indexer Tools
|
|
23
|
+
${formatToolDocs(tools)}
|
|
24
|
+
|
|
25
|
+
Workflow:
|
|
26
|
+
1. Decide if you need search (find relevant entities) or a card lookup (get summary/overview/FAQ for a known DID).
|
|
27
|
+
2. Provide detailed, structured tool inputs (query text, limits, filters, or DID).
|
|
28
|
+
3. Parse the response—highlight summary, overview, FAQ, URLs, and keywords.
|
|
29
|
+
4. Surface gaps or follow-ups — if more context is needed (from memory, portal, etc.), say so and the main agent will use the appropriate tools.
|
|
30
|
+
`.trim();
|
|
31
|
+
const buildDescription = (tools) => {
|
|
32
|
+
const names = tools.map((t) => t.name).join(', ');
|
|
33
|
+
return `Domain Indexer specialist using (${names}) to discover IXO entities, summaries, overviews, and FAQs.`;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Build the Domain Indexer sub-agent definition. Tools are supplied by the
|
|
37
|
+
* plugin and closed over `DOMAIN_INDEXER_URL` from the merged config.
|
|
38
|
+
*/
|
|
39
|
+
export function createDomainIndexerSubAgent(tools) {
|
|
40
|
+
return {
|
|
41
|
+
name: 'Domain Indexer Agent',
|
|
42
|
+
description: buildDescription(tools),
|
|
43
|
+
systemPrompt: buildSystemPrompt(tools),
|
|
44
|
+
tools,
|
|
45
|
+
model: 'subagent',
|
|
46
|
+
middlewares: [],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PluginTool } from '../../plugin-api/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Construct the two domain-indexer tools, closing over the configured base
|
|
4
|
+
* URL. Tools are pure HTTP wrappers — they don't need a `RuntimeContext`,
|
|
5
|
+
* so the handler ignores the second argument.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createDomainIndexerTools(baseUrl: string): PluginTool[];
|
|
8
|
+
//# sourceMappingURL=domain-indexer-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-indexer-tools.d.ts","sourceRoot":"","sources":["../../../src/plugins/domain-indexer/domain-indexer-tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAiL5D;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,EAAE,CAgDtE"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { tool } from '../../plugin-api/tool-helper.js';
|
|
3
|
+
const searchSchema = z.object({
|
|
4
|
+
query: z
|
|
5
|
+
.string()
|
|
6
|
+
.min(1, '❌ ERROR: Query is required and cannot be empty - this tool works like Google search, you MUST provide a search query')
|
|
7
|
+
.describe('🚨 MANDATORY PARAMETER - ALWAYS REQUIRED\n' +
|
|
8
|
+
'This tool works like Google search - you MUST provide a search query to find entities.\n' +
|
|
9
|
+
'The search query string. Cannot be empty or omitted. This is like typing into Google search.\n' +
|
|
10
|
+
'Examples:\n' +
|
|
11
|
+
'- User asks "What is IXO?" → Use query: "IXO"\n' +
|
|
12
|
+
'- User asks "Tell me about blockchain projects" → Use query: "blockchain projects"\n' +
|
|
13
|
+
'- User asks "What are carbon credits?" → Use query: "carbon credits"\n' +
|
|
14
|
+
"Extract the main search term from the user's question and use it as the query.\n" +
|
|
15
|
+
'This parameter is mandatory - you cannot search without a query, just like you cannot Google search without typing something.'),
|
|
16
|
+
limit: z
|
|
17
|
+
.number()
|
|
18
|
+
.min(1)
|
|
19
|
+
.max(10)
|
|
20
|
+
.optional()
|
|
21
|
+
.describe('Optional: Maximum number of results to return (1-10, default: 10)'),
|
|
22
|
+
scopes: z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('Optional: Comma-separated list of scopes to search: domain_cards (default), agents, compositions, events. Use "domain_cards" to find organizations/projects/DAOs with summaries and FAQs.'),
|
|
26
|
+
filters: z.record(z.string(), z.string()).optional()
|
|
27
|
+
.describe(`Optional filters as key-value pairs. Examples:
|
|
28
|
+
- {"dc.categories": "dao,project"} - Filter by categories
|
|
29
|
+
- {"dc.entity_type": "dao"} - Filter by entity type
|
|
30
|
+
- {"dc.has_url": "true"} - Only entities with URLs
|
|
31
|
+
- {"dc.keywords": "blockchain,web3"} - Filter by keywords
|
|
32
|
+
- {"agent.domain_card_id": "did:ixo:entity:ixoworld"} - Agents for specific entity
|
|
33
|
+
For multiple values, use comma-separated strings. For booleans, use "true" or "false". For dates, use ISO format.`),
|
|
34
|
+
});
|
|
35
|
+
const cardSchema = z.object({
|
|
36
|
+
did: z
|
|
37
|
+
.string()
|
|
38
|
+
.min(1, '❌ ERROR: DID is required and cannot be empty')
|
|
39
|
+
.describe('REQUIRED: Domain card DID (Decentralized Identifier). Must be a non-empty string. Get this from search results (record.id) or user input. Example: "did:ixo:entity:ixoworld". This parameter is mandatory and cannot be omitted.'),
|
|
40
|
+
});
|
|
41
|
+
const SEARCH_DESCRIPTION = `🔍 This is like Google Search for entities and domains in the IXO ecosystem. You search using a query and you will find relevant entities.
|
|
42
|
+
|
|
43
|
+
Think of this tool exactly like Google Search:
|
|
44
|
+
- Google Search: You type a query → You get search results
|
|
45
|
+
- Domain Indexer: You provide a query → You get entity results
|
|
46
|
+
|
|
47
|
+
🚨 CRITICAL REQUIREMENT: You MUST provide the 'query' parameter. This tool works like Google search - you CANNOT search without a query. NEVER call this tool with empty arguments {}.
|
|
48
|
+
|
|
49
|
+
✅ CORRECT EXAMPLES (like Google search):
|
|
50
|
+
{"query": "IXO"}
|
|
51
|
+
{"query": "blockchain impact"}
|
|
52
|
+
{"query": "carbon credits", "limit": 5}
|
|
53
|
+
{"query": "What is IXO?", "scopes": "domain_cards"}
|
|
54
|
+
|
|
55
|
+
❌ WRONG (WILL FAIL - like trying to Google search with no query):
|
|
56
|
+
{}
|
|
57
|
+
{"limit": 5}
|
|
58
|
+
{"scopes": "domain_cards"}
|
|
59
|
+
|
|
60
|
+
The 'query' parameter is MANDATORY in every call - just like you can't Google search without typing something.
|
|
61
|
+
|
|
62
|
+
WHAT IT DOES:
|
|
63
|
+
- Searches the IXO domain indexer to find entities (organizations, projects, DAOs, agents, compositions, events)
|
|
64
|
+
- Returns summaries, overviews, and FAQs for matching entities
|
|
65
|
+
- Works like Google search: you provide a search query and get relevant results
|
|
66
|
+
|
|
67
|
+
PRIMARY USE CASES:
|
|
68
|
+
- When users ask "What is X?" or "Tell me about X" → Use query: "X" to find the entity
|
|
69
|
+
- When users ask "What are the FAQs for X?" → Use query: "X" to find the entity and access its FAQ section
|
|
70
|
+
- When users need information about an organization/project → Use query with the entity name or topic
|
|
71
|
+
- When users ask about entities in the IXO ecosystem → Use query with relevant keywords
|
|
72
|
+
|
|
73
|
+
WHAT IT RETURNS:
|
|
74
|
+
- Entity records containing: name, description, summary, overview, FAQs, keywords, URLs, logos, contact info, location, and metadata
|
|
75
|
+
- Search results include domain cards (organizations/projects/DAOs), agents, compositions (documents/resources), and events
|
|
76
|
+
- Each result has a 'record' field with the entity data - look for 'summary', 'overview', and 'faq' fields in the record
|
|
77
|
+
- Results are ranked by relevance using hybrid search (text + semantic similarity)
|
|
78
|
+
|
|
79
|
+
WORKFLOW:
|
|
80
|
+
1. User asks about something → Extract the search query (entity name, topic, or keywords)
|
|
81
|
+
2. Call this tool with the query: {"query": "extracted search term"}
|
|
82
|
+
3. Review the search results - each item has a 'record' field with entity data
|
|
83
|
+
4. Check the 'record' for 'summary', 'overview', and 'faq' fields
|
|
84
|
+
5. If you need more complete information, use get_domain_card with the entity's DID (found in record.id)
|
|
85
|
+
|
|
86
|
+
FILTERS (optional):
|
|
87
|
+
- Domain cards: dc.categories (comma-separated), dc.entity_type, dc.keywords, dc.issuer, dc.has_url (true/false), dc.has_logo (true/false), dc.valid_from_gte (ISO date), dc.valid_from_lte (ISO date), dc.bbox (minLng,minLat,maxLng,maxLat), dc.near (lng,lat), dc.radius (meters)
|
|
88
|
+
- Agents: agent.domain_card_id, agent.has_url (true/false)
|
|
89
|
+
- Compositions: comp.domain_card_id, comp.creator, comp.has_url (true/false)
|
|
90
|
+
- Events: event.domain_card_id, event.from (ISO date), event.to (ISO date), event.location
|
|
91
|
+
|
|
92
|
+
IMPORTANT: Always check the 'record' field in results for summary, overview, and faq data. These fields contain the curated information about the entity.`;
|
|
93
|
+
const CARD_DESCRIPTION = `Get essential domain card details by DID (Decentralized Identifier) including summary, overview, FAQs, and key information. Returns only essential fields to optimize context usage.
|
|
94
|
+
|
|
95
|
+
🚨 CRITICAL REQUIREMENT: You MUST provide the 'did' parameter. NEVER call this tool with empty arguments {}.
|
|
96
|
+
|
|
97
|
+
✅ CORRECT EXAMPLES:
|
|
98
|
+
{"did": "did:ixo:entity:ixoworld"}
|
|
99
|
+
|
|
100
|
+
❌ WRONG (WILL FAIL):
|
|
101
|
+
{}
|
|
102
|
+
{"query": "IXO"}
|
|
103
|
+
|
|
104
|
+
⚠️ REQUIRED PARAMETERS:
|
|
105
|
+
- did (REQUIRED): The domain card DID (Decentralized Identifier) - MUST always be provided. Cannot be empty.
|
|
106
|
+
|
|
107
|
+
PRIMARY USE CASES:
|
|
108
|
+
- After using domain_indexer_search, use this to get the essential entity information including summary, overview, and FAQs
|
|
109
|
+
- When you have a specific entity DID and need its summary, overview, or FAQs
|
|
110
|
+
- When search results show partial information and you need the curated summary/overview/FAQ fields
|
|
111
|
+
- When users specifically ask for FAQs, summaries, or overviews of a known entity
|
|
112
|
+
|
|
113
|
+
WHAT IT RETURNS (filtered to essential fields only):
|
|
114
|
+
- id: Entity DID
|
|
115
|
+
- name: Entity name
|
|
116
|
+
- description: Full description
|
|
117
|
+
- summary: Brief summary of the entity (if available)
|
|
118
|
+
- overview: Detailed overview/description (if available)
|
|
119
|
+
- faq: Array of FAQ objects with question and answer fields
|
|
120
|
+
- url: Entity website URL
|
|
121
|
+
- keywords: Array of keywords
|
|
122
|
+
- entity_type: Array of entity types
|
|
123
|
+
|
|
124
|
+
WORKFLOW:
|
|
125
|
+
1. First use domain_indexer_search to find entities
|
|
126
|
+
2. Extract the DID from search results (record.id field)
|
|
127
|
+
3. Use this tool with the DID to get essential information including summary, overview, and FAQs
|
|
128
|
+
4. The response directly contains summary, overview, and faq fields at the top level
|
|
129
|
+
|
|
130
|
+
IMPORTANT: This tool returns a filtered response with only essential fields (summary, overview, FAQ, and basic info) to avoid context overload. All fields are at the top level - no need to navigate nested objects.`;
|
|
131
|
+
function isRecord(value) {
|
|
132
|
+
return typeof value === 'object' && value !== null;
|
|
133
|
+
}
|
|
134
|
+
function projectDomainCard(card) {
|
|
135
|
+
const c = isRecord(card) ? card : {};
|
|
136
|
+
return {
|
|
137
|
+
id: c.id,
|
|
138
|
+
name: c.name,
|
|
139
|
+
description: c.description,
|
|
140
|
+
summary: c.summary,
|
|
141
|
+
overview: c.overview,
|
|
142
|
+
faq: c.faq ?? [],
|
|
143
|
+
url: c.url,
|
|
144
|
+
keywords: c.keywords ?? [],
|
|
145
|
+
entity_type: c.entity_type ?? [],
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Construct the two domain-indexer tools, closing over the configured base
|
|
150
|
+
* URL. Tools are pure HTTP wrappers — they don't need a `RuntimeContext`,
|
|
151
|
+
* so the handler ignores the second argument.
|
|
152
|
+
*/
|
|
153
|
+
export function createDomainIndexerTools(baseUrl) {
|
|
154
|
+
const search = tool(async (rawArgs) => {
|
|
155
|
+
const params = searchSchema.parse(rawArgs);
|
|
156
|
+
const url = new URL('/search', baseUrl);
|
|
157
|
+
url.searchParams.set('q', params.query);
|
|
158
|
+
if (params.limit !== undefined) {
|
|
159
|
+
url.searchParams.set('limit', String(params.limit));
|
|
160
|
+
}
|
|
161
|
+
if (params.scopes)
|
|
162
|
+
url.searchParams.set('scopes', params.scopes);
|
|
163
|
+
for (const [k, v] of Object.entries(params.filters ?? {})) {
|
|
164
|
+
url.searchParams.set(k, v);
|
|
165
|
+
}
|
|
166
|
+
const response = await fetch(url.toString());
|
|
167
|
+
if (!response.ok) {
|
|
168
|
+
throw new Error(`Search failed: ${response.statusText}`);
|
|
169
|
+
}
|
|
170
|
+
return response.json();
|
|
171
|
+
}, {
|
|
172
|
+
name: 'domain_indexer_search',
|
|
173
|
+
description: SEARCH_DESCRIPTION,
|
|
174
|
+
schema: searchSchema,
|
|
175
|
+
});
|
|
176
|
+
const card = tool(async (rawArgs) => {
|
|
177
|
+
const { did } = cardSchema.parse(rawArgs);
|
|
178
|
+
const url = new URL(`/domain-cards/${did}`, baseUrl);
|
|
179
|
+
const response = await fetch(url.toString());
|
|
180
|
+
if (!response.ok) {
|
|
181
|
+
if (response.status === 404) {
|
|
182
|
+
return { error: 'Domain card not found' };
|
|
183
|
+
}
|
|
184
|
+
throw new Error(`Failed to fetch domain card: ${response.statusText}`);
|
|
185
|
+
}
|
|
186
|
+
const fullCard = await response.json();
|
|
187
|
+
return projectDomainCard(fullCard);
|
|
188
|
+
}, {
|
|
189
|
+
name: 'get_domain_card',
|
|
190
|
+
description: CARD_DESCRIPTION,
|
|
191
|
+
schema: cardSchema,
|
|
192
|
+
});
|
|
193
|
+
return [search, card];
|
|
194
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OraclePlugin } from '../../plugin-api/oracle-plugin.js';
|
|
3
|
+
import type { PluginContext, PluginManifest, PluginSubAgent } from '../../plugin-api/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Domain Indexer plugin. Exposes a sub-agent (`call_domain_indexer_agent`)
|
|
6
|
+
* that searches the IXO Domain Indexer and resolves entities by DID.
|
|
7
|
+
*
|
|
8
|
+
* The base URL is derived from `NETWORK` by default and can be overridden
|
|
9
|
+
* with `DOMAIN_INDEXER_URL` (e.g. for a local mirror or staging build).
|
|
10
|
+
*/
|
|
11
|
+
export declare class DomainIndexerPlugin extends OraclePlugin {
|
|
12
|
+
readonly name = "domain-indexer";
|
|
13
|
+
readonly version = "1.0.0";
|
|
14
|
+
readonly manifest: PluginManifest;
|
|
15
|
+
readonly configSchema: z.ZodObject<{
|
|
16
|
+
DOMAIN_INDEXER_URL: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
getSubAgents(ctx: PluginContext): PluginSubAgent[];
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=domain-indexer.plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-indexer.plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/domain-indexer/domain-indexer.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EAEV,aAAa,EACb,cAAc,EACd,cAAc,EACf,MAAM,2BAA2B,CAAC;AAsEnC;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;IACnD,QAAQ,CAAC,IAAI,oBAAoB;IACjC,QAAQ,CAAC,OAAO,WAAW;IAC3B,QAAQ,CAAC,QAAQ,iBAAY;IAC7B,SAAkB,YAAY;;sBAAgB;IAErC,YAAY,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,EAAE;CAK5D"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OraclePlugin } from '../../plugin-api/oracle-plugin.js';
|
|
3
|
+
import { createDomainIndexerSubAgent } from './domain-indexer-agent.js';
|
|
4
|
+
import { createDomainIndexerTools } from './domain-indexer-tools.js';
|
|
5
|
+
/**
|
|
6
|
+
* Default Domain Indexer endpoints per IXO network. Selected at boot from
|
|
7
|
+
* the core `NETWORK` env var. Operators can override with the optional
|
|
8
|
+
* `DOMAIN_INDEXER_URL` env var (useful for local/staging deployments).
|
|
9
|
+
*/
|
|
10
|
+
const DOMAIN_INDEXER_URLS = {
|
|
11
|
+
mainnet: 'https://domain-indexer.ixo.earth',
|
|
12
|
+
testnet: 'https://domain-indexer.testnet.ixo.earth',
|
|
13
|
+
devnet: 'https://domain-indexer.devnet.ixo.earth',
|
|
14
|
+
};
|
|
15
|
+
const configSchema = z.object({
|
|
16
|
+
DOMAIN_INDEXER_URL: z.string().url().optional(),
|
|
17
|
+
});
|
|
18
|
+
const networkSchema = z.enum(['mainnet', 'testnet', 'devnet']);
|
|
19
|
+
function resolveDomainIndexerUrl(config) {
|
|
20
|
+
const override = configSchema.safeParse(config);
|
|
21
|
+
if (override.success && override.data.DOMAIN_INDEXER_URL) {
|
|
22
|
+
return override.data.DOMAIN_INDEXER_URL;
|
|
23
|
+
}
|
|
24
|
+
const network = networkSchema.safeParse(config.NETWORK);
|
|
25
|
+
if (network.success) {
|
|
26
|
+
return DOMAIN_INDEXER_URLS[network.data];
|
|
27
|
+
}
|
|
28
|
+
throw new Error('domain-indexer: could not resolve base URL. Set DOMAIN_INDEXER_URL or ensure NETWORK is one of mainnet|testnet|devnet.');
|
|
29
|
+
}
|
|
30
|
+
const manifest = {
|
|
31
|
+
title: 'Domain Indexer',
|
|
32
|
+
summary: 'Domain analysis and entity lookup across the IXO ecosystem — organizations, projects, DAOs, DIDs.',
|
|
33
|
+
whenToUse: [
|
|
34
|
+
'User asks "what is X?" or "tell me about X" for an organization, project, DAO, or DID.',
|
|
35
|
+
'User needs the summary, overview, or FAQ of an IXO entity.',
|
|
36
|
+
'Looking up a domain card by its DID.',
|
|
37
|
+
'Discovering entities by topic, category, or keyword.',
|
|
38
|
+
],
|
|
39
|
+
whenNotToUse: [
|
|
40
|
+
'General web search unrelated to IXO entities (use Firecrawl).',
|
|
41
|
+
'Personal memory or past-conversation recall (use Memory).',
|
|
42
|
+
'Page editing or workspace pages (use Editor) — pages are NOT entities.',
|
|
43
|
+
],
|
|
44
|
+
examples: [
|
|
45
|
+
{
|
|
46
|
+
user: 'Tell me about did:ixo:entity:abc123.',
|
|
47
|
+
thought: 'IXO DID lookup — delegate to call_domain_indexer_agent.',
|
|
48
|
+
tool: 'call_domain_indexer_agent',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
user: 'Find DAOs working on climate.',
|
|
52
|
+
thought: 'Discovery by topic across IXO entities.',
|
|
53
|
+
tool: 'call_domain_indexer_agent',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
tags: ['ixo', 'entities', 'search', 'dids'],
|
|
57
|
+
category: 'data',
|
|
58
|
+
visibility: 'always',
|
|
59
|
+
stability: 'stable',
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Domain Indexer plugin. Exposes a sub-agent (`call_domain_indexer_agent`)
|
|
63
|
+
* that searches the IXO Domain Indexer and resolves entities by DID.
|
|
64
|
+
*
|
|
65
|
+
* The base URL is derived from `NETWORK` by default and can be overridden
|
|
66
|
+
* with `DOMAIN_INDEXER_URL` (e.g. for a local mirror or staging build).
|
|
67
|
+
*/
|
|
68
|
+
export class DomainIndexerPlugin extends OraclePlugin {
|
|
69
|
+
name = 'domain-indexer';
|
|
70
|
+
version = '1.0.0';
|
|
71
|
+
manifest = manifest;
|
|
72
|
+
configSchema = configSchema;
|
|
73
|
+
getSubAgents(ctx) {
|
|
74
|
+
const baseUrl = resolveDomainIndexerUrl(ctx.config);
|
|
75
|
+
const tools = createDomainIndexerTools(baseUrl);
|
|
76
|
+
return [createDomainIndexerSubAgent(tools)];
|
|
77
|
+
}
|
|
78
|
+
}
|