@debian777/kairos-mcp 3.0.1-beta.6
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/LICENSE +22 -0
- package/README.md +78 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/cli/api-client.d.ts +31 -0
- package/dist/cli/api-client.d.ts.map +1 -0
- package/dist/cli/api-client.js +110 -0
- package/dist/cli/api-client.js.map +1 -0
- package/dist/cli/commands/attest.d.ts +6 -0
- package/dist/cli/commands/attest.d.ts.map +1 -0
- package/dist/cli/commands/attest.js +52 -0
- package/dist/cli/commands/attest.js.map +1 -0
- package/dist/cli/commands/begin.d.ts +6 -0
- package/dist/cli/commands/begin.d.ts.map +1 -0
- package/dist/cli/commands/begin.js +32 -0
- package/dist/cli/commands/begin.js.map +1 -0
- package/dist/cli/commands/delete.d.ts +6 -0
- package/dist/cli/commands/delete.d.ts.map +1 -0
- package/dist/cli/commands/delete.js +32 -0
- package/dist/cli/commands/delete.js.map +1 -0
- package/dist/cli/commands/mint.d.ts +6 -0
- package/dist/cli/commands/mint.d.ts.map +1 -0
- package/dist/cli/commands/mint.js +48 -0
- package/dist/cli/commands/mint.js.map +1 -0
- package/dist/cli/commands/next.d.ts +6 -0
- package/dist/cli/commands/next.d.ts.map +1 -0
- package/dist/cli/commands/next.js +89 -0
- package/dist/cli/commands/next.js.map +1 -0
- package/dist/cli/commands/search.d.ts +6 -0
- package/dist/cli/commands/search.d.ts.map +1 -0
- package/dist/cli/commands/search.js +32 -0
- package/dist/cli/commands/search.js.map +1 -0
- package/dist/cli/commands/update.d.ts +6 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +72 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/config.d.ts +9 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +14 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +40 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/output.d.ts +10 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +20 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/config.d.ts +58 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +161 -0
- package/dist/config.js.map +1 -0
- package/dist/debian777-kairos-mcp-3.0.1-beta.6.tgz +0 -0
- package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002001.md +324 -0
- package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002002.md +48 -0
- package/dist/http/bearer-validate.d.ts +14 -0
- package/dist/http/bearer-validate.d.ts.map +1 -0
- package/dist/http/bearer-validate.js +111 -0
- package/dist/http/bearer-validate.js.map +1 -0
- package/dist/http/http-api-attest.d.ts +7 -0
- package/dist/http/http-api-attest.d.ts.map +1 -0
- package/dist/http/http-api-attest.js +103 -0
- package/dist/http/http-api-attest.js.map +1 -0
- package/dist/http/http-api-begin-step.d.ts +8 -0
- package/dist/http/http-api-begin-step.d.ts.map +1 -0
- package/dist/http/http-api-begin-step.js +108 -0
- package/dist/http/http-api-begin-step.js.map +1 -0
- package/dist/http/http-api-begin.d.ts +8 -0
- package/dist/http/http-api-begin.d.ts.map +1 -0
- package/dist/http/http-api-begin.js +167 -0
- package/dist/http/http-api-begin.js.map +1 -0
- package/dist/http/http-api-delete.d.ts +9 -0
- package/dist/http/http-api-delete.d.ts.map +1 -0
- package/dist/http/http-api-delete.js +67 -0
- package/dist/http/http-api-delete.js.map +1 -0
- package/dist/http/http-api-dump.d.ts +8 -0
- package/dist/http/http-api-dump.d.ts.map +1 -0
- package/dist/http/http-api-dump.js +34 -0
- package/dist/http/http-api-dump.js.map +1 -0
- package/dist/http/http-api-mint.d.ts +9 -0
- package/dist/http/http-api-mint.d.ts.map +1 -0
- package/dist/http/http-api-mint.js +100 -0
- package/dist/http/http-api-mint.js.map +1 -0
- package/dist/http/http-api-next.d.ts +9 -0
- package/dist/http/http-api-next.d.ts.map +1 -0
- package/dist/http/http-api-next.js +193 -0
- package/dist/http/http-api-next.js.map +1 -0
- package/dist/http/http-api-routes.d.ts +13 -0
- package/dist/http/http-api-routes.d.ts.map +1 -0
- package/dist/http/http-api-routes.js +28 -0
- package/dist/http/http-api-routes.js.map +1 -0
- package/dist/http/http-api-snapshot.d.ts +9 -0
- package/dist/http/http-api-snapshot.d.ts.map +1 -0
- package/dist/http/http-api-snapshot.js +38 -0
- package/dist/http/http-api-snapshot.js.map +1 -0
- package/dist/http/http-api-update.d.ts +9 -0
- package/dist/http/http-api-update.d.ts.map +1 -0
- package/dist/http/http-api-update.js +105 -0
- package/dist/http/http-api-update.js.map +1 -0
- package/dist/http/http-auth-callback.d.ts +6 -0
- package/dist/http/http-auth-callback.d.ts.map +1 -0
- package/dist/http/http-auth-callback.js +183 -0
- package/dist/http/http-auth-callback.js.map +1 -0
- package/dist/http/http-auth-middleware.d.ts +30 -0
- package/dist/http/http-auth-middleware.d.ts.map +1 -0
- package/dist/http/http-auth-middleware.js +224 -0
- package/dist/http/http-auth-middleware.js.map +1 -0
- package/dist/http/http-error-handlers.d.ts +7 -0
- package/dist/http/http-error-handlers.d.ts.map +1 -0
- package/dist/http/http-error-handlers.js +35 -0
- package/dist/http/http-error-handlers.js.map +1 -0
- package/dist/http/http-health-routes.d.ts +9 -0
- package/dist/http/http-health-routes.d.ts.map +1 -0
- package/dist/http/http-health-routes.js +117 -0
- package/dist/http/http-health-routes.js.map +1 -0
- package/dist/http/http-mcp-handler.d.ts +8 -0
- package/dist/http/http-mcp-handler.d.ts.map +1 -0
- package/dist/http/http-mcp-handler.js +136 -0
- package/dist/http/http-mcp-handler.js.map +1 -0
- package/dist/http/http-metrics-middleware.d.ts +7 -0
- package/dist/http/http-metrics-middleware.d.ts.map +1 -0
- package/dist/http/http-metrics-middleware.js +56 -0
- package/dist/http/http-metrics-middleware.js.map +1 -0
- package/dist/http/http-server-config.d.ts +11 -0
- package/dist/http/http-server-config.d.ts.map +1 -0
- package/dist/http/http-server-config.js +15 -0
- package/dist/http/http-server-config.js.map +1 -0
- package/dist/http/http-server-startup.d.ts +9 -0
- package/dist/http/http-server-startup.d.ts.map +1 -0
- package/dist/http/http-server-startup.js +26 -0
- package/dist/http/http-server-startup.js.map +1 -0
- package/dist/http/http-server.d.ts +4 -0
- package/dist/http/http-server.d.ts.map +1 -0
- package/dist/http/http-server.js +39 -0
- package/dist/http/http-server.js.map +1 -0
- package/dist/http/http-well-known.d.ts +13 -0
- package/dist/http/http-well-known.d.ts.map +1 -0
- package/dist/http/http-well-known.js +32 -0
- package/dist/http/http-well-known.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +100 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics-server.d.ts +14 -0
- package/dist/metrics-server.d.ts.map +1 -0
- package/dist/metrics-server.js +41 -0
- package/dist/metrics-server.js.map +1 -0
- package/dist/resources/docs-resources.d.ts +2 -0
- package/dist/resources/docs-resources.d.ts.map +1 -0
- package/dist/resources/docs-resources.js +47 -0
- package/dist/resources/docs-resources.js.map +1 -0
- package/dist/resources/embedded-mcp-resources.d.ts +73 -0
- package/dist/resources/embedded-mcp-resources.d.ts.map +1 -0
- package/dist/resources/embedded-mcp-resources.js +132 -0
- package/dist/resources/embedded-mcp-resources.js.map +1 -0
- package/dist/resources/mem-resources-boot.d.ts +10 -0
- package/dist/resources/mem-resources-boot.d.ts.map +1 -0
- package/dist/resources/mem-resources-boot.js +164 -0
- package/dist/resources/mem-resources-boot.js.map +1 -0
- package/dist/resources/prompt-resources.d.ts +5 -0
- package/dist/resources/prompt-resources.d.ts.map +1 -0
- package/dist/resources/prompt-resources.js +42 -0
- package/dist/resources/prompt-resources.js.map +1 -0
- package/dist/resources/resource-bootstrap.d.ts +7 -0
- package/dist/resources/resource-bootstrap.d.ts.map +1 -0
- package/dist/resources/resource-bootstrap.js +33 -0
- package/dist/resources/resource-bootstrap.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +79 -0
- package/dist/server.js.map +1 -0
- package/dist/services/chain-utils.d.ts +22 -0
- package/dist/services/chain-utils.d.ts.map +1 -0
- package/dist/services/chain-utils.js +95 -0
- package/dist/services/chain-utils.js.map +1 -0
- package/dist/services/code-block-processor.d.ts +40 -0
- package/dist/services/code-block-processor.d.ts.map +1 -0
- package/dist/services/code-block-processor.js +169 -0
- package/dist/services/code-block-processor.js.map +1 -0
- package/dist/services/embedding/config.d.ts +5 -0
- package/dist/services/embedding/config.d.ts.map +1 -0
- package/dist/services/embedding/config.js +13 -0
- package/dist/services/embedding/config.js.map +1 -0
- package/dist/services/embedding/providers.d.ts +5 -0
- package/dist/services/embedding/providers.d.ts.map +1 -0
- package/dist/services/embedding/providers.js +141 -0
- package/dist/services/embedding/providers.js.map +1 -0
- package/dist/services/embedding/service.d.ts +39 -0
- package/dist/services/embedding/service.d.ts.map +1 -0
- package/dist/services/embedding/service.js +302 -0
- package/dist/services/embedding/service.js.map +1 -0
- package/dist/services/embedding/types.d.ts +17 -0
- package/dist/services/embedding/types.d.ts.map +1 -0
- package/dist/services/embedding/types.js +2 -0
- package/dist/services/embedding/types.js.map +1 -0
- package/dist/services/id-generator.d.ts +63 -0
- package/dist/services/id-generator.d.ts.map +1 -0
- package/dist/services/id-generator.js +101 -0
- package/dist/services/id-generator.js.map +1 -0
- package/dist/services/key-value-store-factory.d.ts +7 -0
- package/dist/services/key-value-store-factory.d.ts.map +1 -0
- package/dist/services/key-value-store-factory.js +15 -0
- package/dist/services/key-value-store-factory.js.map +1 -0
- package/dist/services/key-value-store.d.ts +24 -0
- package/dist/services/key-value-store.d.ts.map +1 -0
- package/dist/services/key-value-store.js +6 -0
- package/dist/services/key-value-store.js.map +1 -0
- package/dist/services/memory/chain-builder-proof.d.ts +18 -0
- package/dist/services/memory/chain-builder-proof.d.ts.map +1 -0
- package/dist/services/memory/chain-builder-proof.js +70 -0
- package/dist/services/memory/chain-builder-proof.js.map +1 -0
- package/dist/services/memory/chain-builder.d.ts +4 -0
- package/dist/services/memory/chain-builder.d.ts.map +1 -0
- package/dist/services/memory/chain-builder.js +185 -0
- package/dist/services/memory/chain-builder.js.map +1 -0
- package/dist/services/memory/store-chain-default-handler.d.ts +9 -0
- package/dist/services/memory/store-chain-default-handler.d.ts.map +1 -0
- package/dist/services/memory/store-chain-default-handler.js +118 -0
- package/dist/services/memory/store-chain-default-handler.js.map +1 -0
- package/dist/services/memory/store-chain-header-handler.d.ts +8 -0
- package/dist/services/memory/store-chain-header-handler.d.ts.map +1 -0
- package/dist/services/memory/store-chain-header-handler.js +98 -0
- package/dist/services/memory/store-chain-header-handler.js.map +1 -0
- package/dist/services/memory/store-chain-helpers.d.ts +27 -0
- package/dist/services/memory/store-chain-helpers.d.ts.map +1 -0
- package/dist/services/memory/store-chain-helpers.js +102 -0
- package/dist/services/memory/store-chain-helpers.js.map +1 -0
- package/dist/services/memory/store-chain.d.ts +15 -0
- package/dist/services/memory/store-chain.d.ts.map +1 -0
- package/dist/services/memory/store-chain.js +56 -0
- package/dist/services/memory/store-chain.js.map +1 -0
- package/dist/services/memory/store-init.d.ts +3 -0
- package/dist/services/memory/store-init.d.ts.map +1 -0
- package/dist/services/memory/store-init.js +127 -0
- package/dist/services/memory/store-init.js.map +1 -0
- package/dist/services/memory/store-methods.d.ts +35 -0
- package/dist/services/memory/store-methods.d.ts.map +1 -0
- package/dist/services/memory/store-methods.js +308 -0
- package/dist/services/memory/store-methods.js.map +1 -0
- package/dist/services/memory/store.d.ts +36 -0
- package/dist/services/memory/store.d.ts.map +1 -0
- package/dist/services/memory/store.js +119 -0
- package/dist/services/memory/store.js.map +1 -0
- package/dist/services/memory-store.d.ts +33 -0
- package/dist/services/memory-store.d.ts.map +1 -0
- package/dist/services/memory-store.js +158 -0
- package/dist/services/memory-store.js.map +1 -0
- package/dist/services/metrics/agent-metrics.d.ts +12 -0
- package/dist/services/metrics/agent-metrics.d.ts.map +1 -0
- package/dist/services/metrics/agent-metrics.js +34 -0
- package/dist/services/metrics/agent-metrics.js.map +1 -0
- package/dist/services/metrics/embedding-metrics.d.ts +12 -0
- package/dist/services/metrics/embedding-metrics.d.ts.map +1 -0
- package/dist/services/metrics/embedding-metrics.js +41 -0
- package/dist/services/metrics/embedding-metrics.js.map +1 -0
- package/dist/services/metrics/http-metrics.d.ts +12 -0
- package/dist/services/metrics/http-metrics.d.ts.map +1 -0
- package/dist/services/metrics/http-metrics.js +41 -0
- package/dist/services/metrics/http-metrics.js.map +1 -0
- package/dist/services/metrics/mcp-metrics.d.ts +16 -0
- package/dist/services/metrics/mcp-metrics.d.ts.map +1 -0
- package/dist/services/metrics/mcp-metrics.js +55 -0
- package/dist/services/metrics/mcp-metrics.js.map +1 -0
- package/dist/services/metrics/memory-metrics.d.ts +10 -0
- package/dist/services/metrics/memory-metrics.d.ts.map +1 -0
- package/dist/services/metrics/memory-metrics.js +28 -0
- package/dist/services/metrics/memory-metrics.js.map +1 -0
- package/dist/services/metrics/qdrant-metrics.d.ts +11 -0
- package/dist/services/metrics/qdrant-metrics.d.ts.map +1 -0
- package/dist/services/metrics/qdrant-metrics.js +35 -0
- package/dist/services/metrics/qdrant-metrics.js.map +1 -0
- package/dist/services/metrics/registry.d.ts +9 -0
- package/dist/services/metrics/registry.d.ts.map +1 -0
- package/dist/services/metrics/registry.js +19 -0
- package/dist/services/metrics/registry.js.map +1 -0
- package/dist/services/metrics/system-metrics.d.ts +10 -0
- package/dist/services/metrics/system-metrics.d.ts.map +1 -0
- package/dist/services/metrics/system-metrics.js +35 -0
- package/dist/services/metrics/system-metrics.js.map +1 -0
- package/dist/services/proof-of-work-store.d.ts +66 -0
- package/dist/services/proof-of-work-store.d.ts.map +1 -0
- package/dist/services/proof-of-work-store.js +141 -0
- package/dist/services/proof-of-work-store.js.map +1 -0
- package/dist/services/qdrant/connection.d.ts +24 -0
- package/dist/services/qdrant/connection.d.ts.map +1 -0
- package/dist/services/qdrant/connection.js +126 -0
- package/dist/services/qdrant/connection.js.map +1 -0
- package/dist/services/qdrant/index.d.ts +3 -0
- package/dist/services/qdrant/index.d.ts.map +1 -0
- package/dist/services/qdrant/index.js +4 -0
- package/dist/services/qdrant/index.js.map +1 -0
- package/dist/services/qdrant/initialization.d.ts +25 -0
- package/dist/services/qdrant/initialization.d.ts.map +1 -0
- package/dist/services/qdrant/initialization.js +170 -0
- package/dist/services/qdrant/initialization.js.map +1 -0
- package/dist/services/qdrant/listing.d.ts +26 -0
- package/dist/services/qdrant/listing.d.ts.map +1 -0
- package/dist/services/qdrant/listing.js +88 -0
- package/dist/services/qdrant/listing.js.map +1 -0
- package/dist/services/qdrant/memory-retrieval.d.ts +14 -0
- package/dist/services/qdrant/memory-retrieval.d.ts.map +1 -0
- package/dist/services/qdrant/memory-retrieval.js +110 -0
- package/dist/services/qdrant/memory-retrieval.js.map +1 -0
- package/dist/services/qdrant/memory-store.d.ts +16 -0
- package/dist/services/qdrant/memory-store.d.ts.map +1 -0
- package/dist/services/qdrant/memory-store.js +108 -0
- package/dist/services/qdrant/memory-store.js.map +1 -0
- package/dist/services/qdrant/memory-updates.d.ts +8 -0
- package/dist/services/qdrant/memory-updates.d.ts.map +1 -0
- package/dist/services/qdrant/memory-updates.js +206 -0
- package/dist/services/qdrant/memory-updates.js.map +1 -0
- package/dist/services/qdrant/protocol.d.ts +16 -0
- package/dist/services/qdrant/protocol.d.ts.map +1 -0
- package/dist/services/qdrant/protocol.js +48 -0
- package/dist/services/qdrant/protocol.js.map +1 -0
- package/dist/services/qdrant/quality.d.ts +14 -0
- package/dist/services/qdrant/quality.d.ts.map +1 -0
- package/dist/services/qdrant/quality.js +101 -0
- package/dist/services/qdrant/quality.js.map +1 -0
- package/dist/services/qdrant/resources.d.ts +7 -0
- package/dist/services/qdrant/resources.d.ts.map +1 -0
- package/dist/services/qdrant/resources.js +108 -0
- package/dist/services/qdrant/resources.js.map +1 -0
- package/dist/services/qdrant/search.d.ts +22 -0
- package/dist/services/qdrant/search.d.ts.map +1 -0
- package/dist/services/qdrant/search.js +75 -0
- package/dist/services/qdrant/search.js.map +1 -0
- package/dist/services/qdrant/service.d.ts +90 -0
- package/dist/services/qdrant/service.d.ts.map +1 -0
- package/dist/services/qdrant/service.js +95 -0
- package/dist/services/qdrant/service.js.map +1 -0
- package/dist/services/qdrant/snapshots.d.ts +19 -0
- package/dist/services/qdrant/snapshots.d.ts.map +1 -0
- package/dist/services/qdrant/snapshots.js +126 -0
- package/dist/services/qdrant/snapshots.js.map +1 -0
- package/dist/services/qdrant/types.d.ts +39 -0
- package/dist/services/qdrant/types.d.ts.map +1 -0
- package/dist/services/qdrant/types.js +2 -0
- package/dist/services/qdrant/types.js.map +1 -0
- package/dist/services/qdrant/utils.d.ts +20 -0
- package/dist/services/qdrant/utils.d.ts.map +1 -0
- package/dist/services/qdrant/utils.js +121 -0
- package/dist/services/qdrant/utils.js.map +1 -0
- package/dist/services/redis-cache.d.ts +43 -0
- package/dist/services/redis-cache.d.ts.map +1 -0
- package/dist/services/redis-cache.js +214 -0
- package/dist/services/redis-cache.js.map +1 -0
- package/dist/services/redis.d.ts +43 -0
- package/dist/services/redis.d.ts.map +1 -0
- package/dist/services/redis.js +234 -0
- package/dist/services/redis.js.map +1 -0
- package/dist/services/stats/bonuses.d.ts +28 -0
- package/dist/services/stats/bonuses.d.ts.map +1 -0
- package/dist/services/stats/bonuses.js +96 -0
- package/dist/services/stats/bonuses.js.map +1 -0
- package/dist/services/stats/healer.d.ts +6 -0
- package/dist/services/stats/healer.d.ts.map +1 -0
- package/dist/services/stats/healer.js +24 -0
- package/dist/services/stats/healer.js.map +1 -0
- package/dist/services/stats/model-stats.d.ts +53 -0
- package/dist/services/stats/model-stats.d.ts.map +1 -0
- package/dist/services/stats/model-stats.js +238 -0
- package/dist/services/stats/model-stats.js.map +1 -0
- package/dist/services/stats/protocol.d.ts +11 -0
- package/dist/services/stats/protocol.d.ts.map +1 -0
- package/dist/services/stats/protocol.js +55 -0
- package/dist/services/stats/protocol.js.map +1 -0
- package/dist/services/stats/scoring.d.ts +19 -0
- package/dist/services/stats/scoring.d.ts.map +1 -0
- package/dist/services/stats/scoring.js +102 -0
- package/dist/services/stats/scoring.js.map +1 -0
- package/dist/services/stats/types.d.ts +39 -0
- package/dist/services/stats/types.d.ts.map +1 -0
- package/dist/services/stats/types.js +8 -0
- package/dist/services/stats/types.js.map +1 -0
- package/dist/tools/kairos_attest.d.ts +7 -0
- package/dist/tools/kairos_attest.d.ts.map +1 -0
- package/dist/tools/kairos_attest.js +179 -0
- package/dist/tools/kairos_attest.js.map +1 -0
- package/dist/tools/kairos_begin.d.ts +9 -0
- package/dist/tools/kairos_begin.d.ts.map +1 -0
- package/dist/tools/kairos_begin.js +149 -0
- package/dist/tools/kairos_begin.js.map +1 -0
- package/dist/tools/kairos_begin_schema.d.ts +48 -0
- package/dist/tools/kairos_begin_schema.d.ts.map +1 -0
- package/dist/tools/kairos_begin_schema.js +48 -0
- package/dist/tools/kairos_begin_schema.js.map +1 -0
- package/dist/tools/kairos_delete.d.ts +2 -0
- package/dist/tools/kairos_delete.d.ts.map +1 -0
- package/dist/tools/kairos_delete.js +113 -0
- package/dist/tools/kairos_delete.js.map +1 -0
- package/dist/tools/kairos_dump.d.ts +14 -0
- package/dist/tools/kairos_dump.d.ts.map +1 -0
- package/dist/tools/kairos_dump.js +148 -0
- package/dist/tools/kairos_dump.js.map +1 -0
- package/dist/tools/kairos_mint.d.ts +7 -0
- package/dist/tools/kairos_mint.d.ts.map +1 -0
- package/dist/tools/kairos_mint.js +233 -0
- package/dist/tools/kairos_mint.js.map +1 -0
- package/dist/tools/kairos_next-pow-helpers.d.ts +57 -0
- package/dist/tools/kairos_next-pow-helpers.d.ts.map +1 -0
- package/dist/tools/kairos_next-pow-helpers.js +269 -0
- package/dist/tools/kairos_next-pow-helpers.js.map +1 -0
- package/dist/tools/kairos_next-previous-step.d.ts +27 -0
- package/dist/tools/kairos_next-previous-step.d.ts.map +1 -0
- package/dist/tools/kairos_next-previous-step.js +85 -0
- package/dist/tools/kairos_next-previous-step.js.map +1 -0
- package/dist/tools/kairos_next.d.ts +12 -0
- package/dist/tools/kairos_next.d.ts.map +1 -0
- package/dist/tools/kairos_next.js +262 -0
- package/dist/tools/kairos_next.js.map +1 -0
- package/dist/tools/kairos_next_schema.d.ts +80 -0
- package/dist/tools/kairos_next_schema.d.ts.map +1 -0
- package/dist/tools/kairos_next_schema.js +82 -0
- package/dist/tools/kairos_next_schema.js.map +1 -0
- package/dist/tools/kairos_search.d.ts +15 -0
- package/dist/tools/kairos_search.d.ts.map +1 -0
- package/dist/tools/kairos_search.js +262 -0
- package/dist/tools/kairos_search.js.map +1 -0
- package/dist/tools/kairos_spaces.d.ts +10 -0
- package/dist/tools/kairos_spaces.d.ts.map +1 -0
- package/dist/tools/kairos_spaces.js +129 -0
- package/dist/tools/kairos_spaces.js.map +1 -0
- package/dist/tools/kairos_update.d.ts +2 -0
- package/dist/tools/kairos_update.d.ts.map +1 -0
- package/dist/tools/kairos_update.js +158 -0
- package/dist/tools/kairos_update.js.map +1 -0
- package/dist/types/index.d.ts +60 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/memory.d.ts +38 -0
- package/dist/types/memory.d.ts.map +1 -0
- package/dist/types/memory.js +2 -0
- package/dist/types/memory.js.map +1 -0
- package/dist/utils/build-version.d.ts +15 -0
- package/dist/utils/build-version.d.ts.map +1 -0
- package/dist/utils/build-version.js +46 -0
- package/dist/utils/build-version.js.map +1 -0
- package/dist/utils/global-error-handlers.d.ts +7 -0
- package/dist/utils/global-error-handlers.d.ts.map +1 -0
- package/dist/utils/global-error-handlers.js +61 -0
- package/dist/utils/global-error-handlers.js.map +1 -0
- package/dist/utils/log-core.d.ts +11 -0
- package/dist/utils/log-core.d.ts.map +1 -0
- package/dist/utils/log-core.js +78 -0
- package/dist/utils/log-core.js.map +1 -0
- package/dist/utils/logger.d.ts +22 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +63 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/memory-body.d.ts +6 -0
- package/dist/utils/memory-body.d.ts.map +1 -0
- package/dist/utils/memory-body.js +21 -0
- package/dist/utils/memory-body.js.map +1 -0
- package/dist/utils/memory-store-utils.d.ts +14 -0
- package/dist/utils/memory-store-utils.d.ts.map +1 -0
- package/dist/utils/memory-store-utils.js +83 -0
- package/dist/utils/memory-store-utils.js.map +1 -0
- package/dist/utils/qdrant-collection-utils.d.ts +11 -0
- package/dist/utils/qdrant-collection-utils.d.ts.map +1 -0
- package/dist/utils/qdrant-collection-utils.js +62 -0
- package/dist/utils/qdrant-collection-utils.js.map +1 -0
- package/dist/utils/qdrant-query-utils.d.ts +6 -0
- package/dist/utils/qdrant-query-utils.d.ts.map +1 -0
- package/dist/utils/qdrant-query-utils.js +23 -0
- package/dist/utils/qdrant-query-utils.js.map +1 -0
- package/dist/utils/qdrant-utils.d.ts +5 -0
- package/dist/utils/qdrant-utils.d.ts.map +1 -0
- package/dist/utils/qdrant-utils.js +5 -0
- package/dist/utils/qdrant-utils.js.map +1 -0
- package/dist/utils/qdrant-vector-management.d.ts +25 -0
- package/dist/utils/qdrant-vector-management.d.ts.map +1 -0
- package/dist/utils/qdrant-vector-management.js +284 -0
- package/dist/utils/qdrant-vector-management.js.map +1 -0
- package/dist/utils/qdrant-vector-types.d.ts +35 -0
- package/dist/utils/qdrant-vector-types.d.ts.map +1 -0
- package/dist/utils/qdrant-vector-types.js +42 -0
- package/dist/utils/qdrant-vector-types.js.map +1 -0
- package/dist/utils/space-display.d.ts +11 -0
- package/dist/utils/space-display.d.ts.map +1 -0
- package/dist/utils/space-display.js +25 -0
- package/dist/utils/space-display.js.map +1 -0
- package/dist/utils/space-filter.d.ts +15 -0
- package/dist/utils/space-filter.d.ts.map +1 -0
- package/dist/utils/space-filter.js +18 -0
- package/dist/utils/space-filter.js.map +1 -0
- package/dist/utils/structured-logger.d.ts +41 -0
- package/dist/utils/structured-logger.d.ts.map +1 -0
- package/dist/utils/structured-logger.js +133 -0
- package/dist/utils/structured-logger.js.map +1 -0
- package/dist/utils/tenant-context.d.ts +67 -0
- package/dist/utils/tenant-context.d.ts.map +1 -0
- package/dist/utils/tenant-context.js +154 -0
- package/dist/utils/tenant-context.js.map +1 -0
- package/dist/utils/uri-builder.d.ts +37 -0
- package/dist/utils/uri-builder.d.ts.map +1 -0
- package/dist/utils/uri-builder.js +60 -0
- package/dist/utils/uri-builder.js.map +1 -0
- package/package.json +133 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
+
*
|
|
4
|
+
* Generated by: scripts/embed-docs.ts
|
|
5
|
+
* Contains: MCP guide resources dynamically embedded at build time
|
|
6
|
+
* Structure reflects src/embed-docs/ directory structure
|
|
7
|
+
*
|
|
8
|
+
* To update: npm run build (or manually run ts-node scripts/embed-docs.ts)
|
|
9
|
+
*/
|
|
10
|
+
export const mcpResources = {
|
|
11
|
+
"prompts": {
|
|
12
|
+
"contextual-prompt": "You are KAIROS — a deterministic execution engine for protocol chains.\n\nYou turn user intent into a KAIROS protocol run, then execute it exactly.\nProtocols are stored as memory chains. Each step can define a\nchallenge. You advance a protocol by submitting a matching solution.\n\n**Execution policy:** When running KAIROS protocols you MUST follow the tools' next_action and challenge.description exactly. Do not invent work or skip steps. Only respond to the user after the protocol run is complete (after calling kairos_attest when next_action directs you to it).\n\n## Use KAIROS strengths\n\nUse KAIROS to be reliable and fast.\n\n- Deterministic next actions: follow `next_action` instead of improvising.\n- Verifiable work: treat every challenge as something you must prove.\n- Self-healing: when a step is broken, fix the protocol for next time.\n- Reuse: prefer running an existing protocol over inventing a new workflow.\n\n## Non-negotiable rules\n\nThese rules override your default behavior.\n\n- If a tool response includes `must_obey: true`, follow `next_action` exactly.\n Do not respond to the user until the protocol run is complete (when\n you have called kairos_attest if next_action directed you to it).\n- If a tool response includes `must_obey: false`, use judgment. Choose the best\n option described in `next_action`. Prefer repairing the protocol with\n `kairos_update` when safe. Otherwise, ask the user.\n- Do not guess. If you need facts from the codebase, environment, or external\n systems, use tools to get them.\n\n## Execution loop\n\nFollow this loop for any protocol run.\n\n1. If the user intent matches a stored protocol, call `kairos_search`.\n2. Choose a protocol from `choices`, then call `kairos_begin` with its `uri`.\n3. While `next_action` says to call `kairos_next`:\n - Read the `challenge` for the current step.\n - Complete the work in the real world. By challenge.type: shell — Run `challenge.shell.cmd` and report the actual exit_code/stdout/stderr; never fabricate. mcp — Call `challenge.mcp.tool_name` and report the actual result; success must reflect reality. user_input — Show `challenge.user_input.prompt` to the user and use only their reply as `user_input.confirmation`; never invent it. comment — Write a genuine comment about this step that meets `challenge.comment.min_length` and is relevant to the step.\n - Call `kairos_next` with the URI from `next_action` and a `solution` that\n matches `challenge.type`.\n - Echo `challenge.nonce` as `solution.nonce` when present.\n - Echo the correct `proof_hash` as `solution.proof_hash`.\n - For step 1, use `challenge.proof_hash`.\n - For later steps, use the `proof_hash` returned by the previous\n `kairos_next`.\n - Never compute hashes yourself. The server generates all hashes.\n4. When `next_action` directs you to call kairos_attest, call it with the given URI and outcome/message; then the protocol run is done and you may respond to the user.\n\n## Create or edit protocols\n\nWhen you mint or edit a workflow document (H1 chain, H2 steps), add a trailing\n` ```json ` block at the end of each step with `{\"challenge\": {...}}` (same shape as kairos_begin/kairos_next). Choose the challenge type that matches the work: `shell`, `mcp`, `user_input`, or `comment`.\n"
|
|
13
|
+
},
|
|
14
|
+
"resources": {
|
|
15
|
+
"building-kairos-workflows": "# Building KAIROS Workflows with Challenge/Solution\n\n**Status:** Active \n**Purpose:** Primary guide for building KAIROS protocol workflows. **Challenge/Solution** is the core mechanism: each step can define a **challenge** (what must be done) and execution advances by submitting a matching **solution** via `kairos_next`. This doc covers structure, minting with `kairos_mint`, and solution submission.\n\n---\n\n## MISSION\n\nBuild KAIROS protocol workflows where **challenges** (defined per step) are validated by **solutions** (submitted in `kairos_next`). Create documents with `kairos_mint` that define these challenges; maintain exact consistency between markdown structure and memory chain behavior.\n\n---\n\n## STRUCTURE\n\n**Document Organization:**\n- **H1 (# Title)**: Defines a protocol chain (one H1 = one chain)\n- **Steps**: Defined by **PoW (proof-of-work) code** — each ` ```json ` block with `{\"challenge\": {...}}` ends one step. H2 headings are used only for step labels when present in a segment.\n- **Challenge**: A fenced ` ```json ` block with `{\"challenge\": {...}}` (same shape as kairos_begin/kairos_next)\n\n**Memory Mapping:**\n- Each H1 section → One protocol chain\n- Each PoW block (```json with `challenge`) → One memory step (content before that block is that step’s text)\n- Optional content after the last PoW block → Final step (no proof required)\n- H2 in a segment → Used as that step’s label when present\n\n**Processing Flow:**\n```\nMarkdown Document\n ↓\nkairos_mint(markdown_doc, llm_model_id)\n ↓\nMemory Chain (array of Memory objects)\n ↓\nEach Memory has:\n - memory_uuid\n - label (from H2 heading)\n - text (H2 content)\n - proof_of_work (from trailing JSON challenge block)\n```\n\n---\n\n## CONTENT TYPES\n\n### Challenge Definitions\n\nAdd a **trailing** ` ```json ` block at the end of each step with an object that has a `challenge` key. The value is the same shape as the challenge returned by kairos_begin/kairos_next; it round-trips with kairos_dump.\n\n**Shell (`shell`):**\n```json\n{\n \"challenge\": {\n \"type\": \"shell\",\n \"shell\": { \"cmd\": \"echo \\\"test\\\"\", \"timeout_seconds\": 30 },\n \"required\": true\n }\n}\n```\n\n**MCP (`mcp`):**\n```json\n{\n \"challenge\": {\n \"type\": \"mcp\",\n \"mcp\": { \"tool_name\": \"tool_name\", \"expected_result\": null },\n \"required\": true\n }\n}\n```\n\n**User Input (`user_input`):**\n```json\n{\n \"challenge\": {\n \"type\": \"user_input\",\n \"user_input\": { \"prompt\": \"Confirm completion\" },\n \"required\": true\n }\n}\n```\n\n**Comment (`comment`):**\n```json\n{\n \"challenge\": {\n \"type\": \"comment\",\n \"comment\": { \"min_length\": 50 },\n \"required\": true\n }\n}\n```\n\n**Parsing:** Only the **last** fenced code block in a step is read; it must be valid JSON with a `challenge` key. The block is stripped from stored text; the challenge becomes that step's `proof_of_work`.\n\n### Challenge Types (execution)\n\n**Shell:** Run the command; report exit_code/stdout/stderr. Exit code 0 = success.\n\n**MCP:** Call the tool; report result and success.\n\n**User Input:** Show the prompt to the user; use only their reply as `user_input.confirmation`.\n\n**Comment:** Provide text meeting the minimum length; validated for relevance to the step.\n\nFor execution semantics (how agents must perform each challenge type), see the kairos_begin and kairos_next tool descriptions.\n\n---\n\n## MUST ALWAYS\n\n### Document Structure\n- Use H1 (`# Title`) for protocol chain labels\n- Use H2 (`## Step N`) for individual steps\n- Place challenge markers **within** the H2 section they apply to\n- Each H1 creates a separate protocol chain\n\n### Challenge Placement\n- Place the challenge **at the end** of an H2 section as a single trailing ` ```json ` block\n- Only the **last** code block in a step is parsed as the challenge (if multiple blocks exist)\n\n### kairos_mint Usage\n- Always provide `markdown_doc` as a string (can be JSON stringified)\n- Always provide `llm_model_id` (e.g., `\"minimax/minimax-m2:free\"`)\n- Use `force_update: true` to overwrite existing chains with the same label\n\n### Solution Submission\n- Use `kairos_next(uri, solution)` to submit solutions (not `proof_of_work`)\n- Solution structure matches challenge type:\n - `shell`: `{type: 'shell', shell: {exit_code, stdout, stderr, duration_seconds}}`\n - `mcp`: `{type: 'mcp', mcp: {tool_name, arguments, result, success}}`\n - `user_input`: `{type: 'user_input', user_input: {confirmation, timestamp}}`\n - `comment`: `{type: 'comment', comment: {text}}`\n\n---\n\n## MUST NEVER\n\n### Document Structure\n- **NEVER** mix H1 and H2 in unpredictable ways\n- **NEVER** place the challenge JSON block outside an H2 section (it applies to the step it ends)\n- **NEVER** use legacy line-based challenge syntax; use only the trailing JSON block\n\n### Challenge Definitions\n- **NEVER** use the old `proof_of_work` field in API calls (use `solution` instead)\n- **NEVER** skip challenge validation - `kairos_next` requires solutions for steps with challenges\n- **NEVER** submit solutions that don't match the challenge type\n\n### kairos_mint\n- **NEVER** pass markdown as an object - always as a string\n- **NEVER** omit `llm_model_id` - it's required\n- **NEVER** store duplicate chains without `force_update: true`\n\n### Workflow Confusion\n- **NEVER** confuse `challenge` (output from `kairos_next`) with `solution` (input to `kairos_next`)\n- **NEVER** use `proof_of_work` field - it's deprecated, use `solution`\n- **NEVER** assume step 1 requires a solution (only steps 2+ require solutions)\n\n---\n\n## WORKFLOW EXAMPLES\n\n### Example 1: Simple Protocol with Shell Challenges\n\nUse one H1, then one H2 per step. End each step with a fenced ` ```json ` block containing `{\"challenge\": {...}}`. Example for one step:\n\n ## Step 1: Initialize\n Create the project structure.\n\n ```json\n {\"challenge\":{\"type\":\"shell\",\"shell\":{\"cmd\":\"mkdir -p project/src\",\"timeout_seconds\":10},\"required\":true}}\n ```\n\nRepeat for Step 2 and Step 3 with their own `shell` challenge blocks (same shape, different `cmd`).\n\n**Minting:**\n```javascript\nawait kairos_mint({\n markdown_doc: markdownText,\n llm_model_id: 'minimax/minimax-m2:free'\n});\n```\n\n**Execution Flow:**\n1. `kairos_search(\"simple setup\")` -> Returns `must_obey: true` with `next_action` containing URI\n2. `kairos_begin(uri)` -> Returns step 1 with `challenge` and `next_action` with next URI\n3. `kairos_next(step2_uri, solution: {type: 'shell', proof_hash: '...', shell: {...}})` -> Returns step 2\n4. Continue through all steps with solutions (echo `proof_hash` from each response)\n5. Last `kairos_next` returns `next_action` to call kairos_attest; call it to complete the run\n\n### Example 2: Protocol with Comment Challenge\n\nStep 1 ends with a comment challenge block; Step 2 with a user_input block. Example for Step 1:\n\n ## Step 1: Review\n Review the documentation for accuracy.\n\n ```json\n {\"challenge\":{\"type\":\"comment\",\"comment\":{\"min_length\":50},\"required\":true}}\n ```\n\nStep 2: use `{\"challenge\":{\"type\":\"user_input\",\"user_input\":{\"prompt\":\"Type 'approved' to confirm\"},\"required\":true}}` in its trailing JSON block.\n\n**Solution Submission:**\n```javascript\n// For step 1 (comment challenge)\nawait kairos_next(step1_uri, {\n solution: {\n type: 'comment',\n comment: {\n text: 'Reviewed documentation. All sections are accurate and up-to-date. No changes needed.'\n }\n }\n});\n\n// For step 2 (user input challenge)\nawait kairos_next(step2_uri, {\n solution: {\n type: 'user_input',\n user_input: {\n confirmation: 'approved',\n timestamp: new Date().toISOString()\n }\n }\n});\n```\n\n### Example 3: Multi-Chain Document\n\nUse two H1 sections (Protocol A, Protocol B). Each H1 creates a separate chain. Each can have one or more H2 steps; each step ends with a ` ```json ` block with `{\"challenge\": {...}}` as above.\n\n**Result:** Two separate protocol chains are created (one for Protocol A, one for Protocol B).\n\n---\n\n## CHALLENGE vs SOLUTION NOMENCLATURE\n\n**Important Distinction:**\n- **Challenge** = What `kairos_next` **returns** (what the AI must complete)\n- **Solution** = What you **submit** to `kairos_next` (proof you completed it)\n\n**In Markdown:** Use a trailing ` ```json ` block with `{\"challenge\": {...}}` per step. Internal representation is `proof_of_work`; API uses `challenge` (output) and `solution` (input).\n\n---\n\n## VALIDATION RULES\n\n### Challenge Validation\n- Shell challenges: Exit code 0 = success, non-zero = failure\n- MCP challenges: `success: true` required\n- User input: Any non-empty `confirmation` accepted\n- Comment challenges: Minimum length enforced (default: 10 chars)\n\n### Step Progression\n- Step 1 (first H2): **No solution required** - call `kairos_begin` only\n- Steps 2+: **Solution required** - must submit matching `solution` to proceed\n- Include `nonce` and `proof_hash` in solution (echo from challenge/response)\n- Protocol completion: Last `kairos_next` directs to kairos_attest; call attest to finalize\n\n### Error Handling (Two-Phase Retry)\n- Retries 1-3: `must_obey: true` with `error_code` and `next_action` for recovery\n- After 3 retries: `must_obey: false` - AI gets autonomy (fix step, abort, or ask user)\n- Error responses include `error_code` (e.g., `NONCE_MISMATCH`, `TYPE_MISMATCH`) and `retry_count`\n\n---\n\n## MIGRATION FROM OLD WORKFLOW\n\n**Old Way (Deprecated):**\n```javascript\nkairos_next(uri, {proof_of_work: {...}}) // ❌ Deprecated\n```\n\n**New Way (Current):**\n```javascript\nkairos_next(uri, {solution: {...}}) // ✅ Correct\n```\n\n**Field Mapping:**\n- `proof_of_work` → `solution`\n- Structure remains the same (type-specific fields unchanged)\n- Validation logic unchanged\n\n---\n\n## QUICK REFERENCE\n\n| Operation | Tool | Required Fields |\n|-----------|------|----------------|\n| Mint document | `kairos_mint` | `markdown_doc`, `llm_model_id` |\n| Find protocol | `kairos_search` | `query` |\n| Start protocol | `kairos_begin` | `uri` (from `next_action`) |\n| Continue step | `kairos_next` | `uri` (from `next_action`), `solution` with `nonce` + `proof_hash` |\n| Complete protocol | `kairos_attest` | `uri`, `outcome`, `message` |\n\n---\n\n## COMMON PITFALLS\n\n1. **Forgetting solutions for step 2+**: Every step after step 1 requires a solution if it has a challenge\n2. **Wrong solution type**: Solution type must exactly match challenge type\n3. **Skipping validation**: Challenges are enforced - you cannot proceed without valid solutions\n4. **Using old field names**: Always use `solution`, never `proof_of_work` in API calls\n5. **Mixing H1 chains**: Each H1 creates a separate chain - don't mix steps between chains\n\n---\n\n**Last Updated:** 2025-12-08 \n**Related:** `kairos_mint`, `kairos_next`, `kairos_begin`, `kairos_attest`\n"
|
|
16
|
+
},
|
|
17
|
+
"templates": {
|
|
18
|
+
"kairos-memory": "Retrieves a KAIROS memory by UUID"
|
|
19
|
+
},
|
|
20
|
+
"tools": {
|
|
21
|
+
"kairos_attest": "Attest protocol completion or failure. **Final step** of every protocol run. Updates quality metrics for the last step.\n\n**When to call:** When `kairos_next` (or `kairos_begin` for a single-step protocol) returns `next_action` directing you to call `kairos_attest` — i.e. when there are no more steps to solve. Call with the URI from that response, and `outcome` (success or failure) and `message` (short summary).\n\n**Input:** `uri` (last step URI from the completion response), `outcome` (`\"success\"` or `\"failure\"`), `message` (short summary of how the protocol went).\n\n**After attestation:** Protocol is done. You may respond to the user. Do not respond before attestation when `must_obey: true`.\n",
|
|
22
|
+
"kairos_begin": "Start protocol execution. Loads step 1 and returns its challenge. Step 1 never requires a solution.\n\n**When to call:** After `kairos_search` returns a URI in `next_action`. Call with that URI to begin the protocol. If a non-step-1 URI is provided, KAIROS auto-redirects to step 1.\n\n**Response:** `current_step` (content + uri), `challenge` (type, description, nonce, proof_hash), and `next_action` with the exact URI for the next call.\n\n**Execution rules by challenge.type:** You must perform the challenge, not infer it. shell: Run `challenge.shell.cmd` and report the actual exit_code/stdout/stderr; never fabricate. mcp: Call `challenge.mcp.tool_name` and report the actual result; success must reflect reality. user_input: Show `challenge.user_input.prompt` to the user and use only their reply as `user_input.confirmation`; never invent it. comment: Write a genuine, relevant comment that meets `challenge.comment.min_length`.\n\n**AI decision tree:** `must_obey: true` -> follow `next_action`.\n\n- If `next_action` mentions `kairos_next`: Execute the challenge, then call `kairos_next` with the URI from `next_action` and a solution matching the challenge.\n- If `next_action` directs you to call kairos_attest: Single-step (or no further steps). Call kairos_attest with the given URI and outcome/message; then run is done.\n\n**Proof hash:** Echo `challenge.proof_hash` back as `solution.proof_hash` in the next `kairos_next` call. The server generates all hashes; the AI never computes them.\n",
|
|
23
|
+
"kairos_delete": "Delete one or more memories from the KAIROS.\n\n**When to call:** When the user wants to delete, remove, purge, or clean KAIROS content. Resolve the target memory URIs first (e.g. via `kairos_search` and chain navigation).\n\n**Input:** `uris` (non-empty array of kairos://mem/{uuid} URIs to delete).\n",
|
|
24
|
+
"kairos_dump": "Read-only inspection of a memory or full protocol. Returns **markdown_doc** for use with `kairos_update` or `kairos_mint`. No run state, no nonce.\n\n**When to call:** When you have a memory URI and need to read its content before updating or re-minting. For example: after `kairos_mint` returns SIMILAR_MEMORY_FOUND (dump the existing protocol to compare), or before calling `kairos_update` to edit a step.\n\n**Input:** `uri` (kairos://mem/{uuid}), optional `protocol` (default false). When `protocol` is true, returns the full chain as one markdown document; otherwise returns the single step’s content.\n\n**Output:** `markdown_doc` (string). In default mode also optional `uri`, `label`, `position`, `challenge`. In protocol mode also optional `uri` (chain head), `label`, `step_count`.\n\n**Use with update:** Get `markdown_doc` for one step → edit → `kairos_update({ uris: [uri], markdown_doc: [markdown_doc] })`.\n\n**Use with mint:** Get `markdown_doc` with `protocol: true` → compare or edit → `kairos_mint({ markdown_doc, llm_model_id, force_update: true })`.\n\nDo not use dump to bypass execution; use it only for inspection and round-trip edit flows.\n",
|
|
25
|
+
"kairos_mint": "Stores markdown documents as KAIROS memories with automatic header-based organization. Each H1 defines a protocol chain; each H2 defines a step.\n\n**When to call:** When the user wants to create, add, mint, store, or save a protocol or document.\n\n**Challenge:** For each step that can be verified, add a fenced ` ```json ` block at the end with an object that has a `challenge` key. The value is the same shape as the `challenge` returned by kairos_begin/kairos_next; round-trips with kairos_dump.\n\n**Challenge examples (one per type; use a ` ```json ` code block at the end of each step):**\n\n**shell** — run a command:\n\n```json\n{\n \"challenge\": {\n \"type\": \"shell\",\n \"shell\": {\n \"cmd\": \"npm test\",\n \"timeout_seconds\": 60\n },\n \"required\": true\n }\n}\n```\n\n**comment** — verification text (min length):\n\n```json\n{\n \"challenge\": {\n \"type\": \"comment\",\n \"comment\": { \"min_length\": 50 },\n \"required\": true\n }\n}\n```\n\n**user_input** — human confirmation:\n\n```json\n{\n \"challenge\": {\n \"type\": \"user_input\",\n \"user_input\": { \"prompt\": \"Approve deployment?\" },\n \"required\": true\n }\n}\n```\n\n**mcp** — call MCP tool:\n\n```json\n{\n \"challenge\": {\n \"type\": \"mcp\",\n \"mcp\": { \"tool_name\": \"kairos_mint\" },\n \"required\": true\n }\n}\n```\n\nUse a challenge on every step that can be verified: commands → shell; reviews/summaries → comment; approvals → user_input; tool calls → mcp. Mix types in one protocol. See workflow-kairos-mint and the creation protocol (kairos://mem/00000000-0000-0000-0000-000000002001) for full examples.\n\n**Input:** `markdown_doc` (string), `llm_model_id` (required), `force_update` (optional, overwrite existing chain with same label).\n\n**Response:** Chain head URI(s). You can then find the protocol via `kairos_search` with a query matching the content.\n",
|
|
26
|
+
"kairos_next": "Submit solution and get next step. Advance through the protocol by proving each challenge was completed.\n\n**When to call:** After completing a step's challenge. Use the URI from `next_action` of the previous response. Do not use for step 1 — use `kairos_begin` for step 1.\n\n**Input:** `uri` (current step URI from `next_action`), `solution` (proof matching the `challenge.type`).\n\n**Solution shapes by challenge type:**\n\n- `shell`: `{type:'shell', shell:{exit_code, stdout?, stderr?, duration_seconds?}}` — exit_code 0 = success.\n- `mcp`: `{type:'mcp', mcp:{tool_name, arguments?, result, success}}` — success must be true.\n- `user_input`: `{type:'user_input', user_input:{confirmation, timestamp?}}`.\n- `comment`: `{type:'comment', comment:{text}}` — text length must meet challenge's min_length.\n\nInclude in solution when the challenge has them: `nonce` (echo from challenge), `proof_hash` (echo `challenge.proof_hash` for step 1; for step 2+ use `proof_hash` from the previous `kairos_next` response). The server generates all hashes; the AI never computes them.\n\n**Execution rules by challenge.type:** Same as kairos_begin. shell: Run `challenge.shell.cmd` and report the actual exit_code/stdout/stderr; never fabricate. mcp: Call `challenge.mcp.tool_name` and report the actual result; success must reflect reality. user_input: Show `challenge.user_input.prompt` to the user and use only their reply as `user_input.confirmation`; never invent it. comment: Write a genuine, relevant comment that meets `challenge.comment.min_length`.\n\n**Response:** `current_step`, `challenge` (for next step), `next_action` (next tool call with embedded URI), and `proof_hash` (hash of proof just stored — use as `solution.proof_hash` for the next step).\n\n**AI decision tree:**\n- `must_obey: true` -> follow `next_action` (success or recoverable error, retries 1-3).\n- `must_obey: false` -> use judgment (max retries exceeded). Options in `next_action`: fix the step via `kairos_update`, abort via `kairos_attest` with failure, or ask the user.\n\n**Error responses** include `error_code` (e.g., `NONCE_MISMATCH`, `TYPE_MISMATCH`, `MAX_RETRIES_EXCEEDED`) and `retry_count`. A fresh `challenge` with new nonce is provided for self-correction.\n\n**When `next_action` directs you to call kairos_attest:** Call attest with the given URI and outcome/message; then the protocol run is done and you may respond to the user.\n",
|
|
27
|
+
"kairos_search": "Search for protocol chains matching a query. Entry point for KAIROS workflow.\n\n**When to call:** When the user's intent maps to a protocol (coding, docs, Jira, GitLab MR, etc.). Use a search term derived from intent.\n\n**Query tip:** Prefer a concrete query (e.g. 3–8 words, nouns + verbs, domain or tool name if the user implied one). Stay faithful to the user's intent — add clarity, don't substitute your own interpretation. If the user was vague (e.g. slash-command or \"do the thing\"), you can expand to a likely intent; if results are weak, pick the refine choice and run that protocol for step-by-step help.\n\n**Response:** Always `must_obey: true`. Contains `choices` array (each with `uri`, `label`, `chain_label`, `score`, `role`, `tags`, `next_action`), `message`, and a global `next_action` directive.\n\n**AI decision tree:** `must_obey: true` -> pick one choice and follow **that choice's `next_action`**. The global `next_action` says: \"Pick one choice and follow that choice's next_action.\" (or \"Follow the choice's next_action.\" when there is only one choice.)\n\n**Choices roles:**\n- `role: \"match\"` — search results with a `score` (0.0-1.0). Higher = better match. That choice's `next_action` tells you to call `kairos_begin` with its URI.\n- `role: \"refine\"` — get step-by-step help turning the user's request into a better query. That choice's `next_action` tells you to call `kairos_begin` with its URI (refining-help protocol).\n- `role: \"create\"` — system action to create a new protocol (`score: null`). That choice's `next_action` tells you to call `kairos_begin` with the creation protocol URI.\n\n**Ordering:** Match choices first (top N from search), then refine (if present), then create (if present). Refine and create are not part of the search limit.\n\n**After search:** Pick the choice that best fits user intent (use `label`, `chain_label`, `tags`, `score`). Then follow that choice's `next_action` exactly (always `kairos_begin` with that choice's URI).\n",
|
|
28
|
+
"kairos_spaces": "List the agent's available spaces with human-readable names and chain counts. Use when the agent needs to see which spaces exist and how many chains (protocols) each contains.\n\n**When to call:** When the user or agent asks what spaces exist, how many protocols are in each space, or for a summary of stored content per space.\n\n**Input:** `include_chain_titles` (optional, default false). When true, each space includes a list of chains with `chain_id`, `title`, and `step_count`.\n\n**Output:** `spaces` array. Each item has `name` (human-readable: \"Personal\", \"Group: <ref>\", \"Kairos app\"), `chain_count`, and optionally `chains` (array of `{ chain_id, title, step_count }`).\n\nSpaces include the agent's personal space, any group spaces, and the Kairos app space (read-only protocols). Use space names in tool parameters (e.g. `kairos_mint` space param); do not rely on raw space ids.\n",
|
|
29
|
+
"kairos_update": "Update one or more memories in the KAIROS using markdown_doc or updates.\n\n**When to call:** When the user wants to replace, modify, update, edit, or change existing KAIROS content. Resolve the target memory first (e.g. via `kairos_search` and then navigating to the step, or by URI).\n\n**Input:** `uris` (array of kairos://mem/{uuid} URIs), and either `markdown_doc` (array of markdown strings, one per URI) or `updates` (field-level updates).\n"
|
|
30
|
+
},
|
|
31
|
+
"mem": {}
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Get prompts object
|
|
35
|
+
*/
|
|
36
|
+
export function getPrompts() {
|
|
37
|
+
return mcpResources.prompts || {};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get resources object
|
|
41
|
+
*/
|
|
42
|
+
export function getResources() {
|
|
43
|
+
return mcpResources.resources || {};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get templates object
|
|
47
|
+
*/
|
|
48
|
+
export function getTemplates() {
|
|
49
|
+
return mcpResources.templates || {};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get tools object
|
|
53
|
+
*/
|
|
54
|
+
export function getTools() {
|
|
55
|
+
return mcpResources.tools || {};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get mem object
|
|
59
|
+
*/
|
|
60
|
+
export function getMem() {
|
|
61
|
+
return mcpResources.mem || {};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get a prompt by key (e.g. 'contextual-prompt')
|
|
65
|
+
*/
|
|
66
|
+
export function getPrompt(key) {
|
|
67
|
+
const prompts = (mcpResources.prompts || {});
|
|
68
|
+
return prompts[key];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get a resource by key (e.g. 'TEST', 'doc.TEST', 'mem.<uuid>')
|
|
72
|
+
*/
|
|
73
|
+
export function getResource(key) {
|
|
74
|
+
const resources = (mcpResources.resources || {});
|
|
75
|
+
const parts = key.split('.');
|
|
76
|
+
let current = resources;
|
|
77
|
+
for (const part of parts) {
|
|
78
|
+
if (current && typeof current === 'object') {
|
|
79
|
+
current = current[part];
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return current;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get a template by key (e.g. 'kairos-memory')
|
|
89
|
+
*/
|
|
90
|
+
export function getTemplate(key) {
|
|
91
|
+
const templates = (mcpResources.templates || {});
|
|
92
|
+
return templates[key];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get a tool doc by key (e.g. 'kairos_begin')
|
|
96
|
+
*/
|
|
97
|
+
export function getToolDoc(key) {
|
|
98
|
+
const tools = (mcpResources.tools || {});
|
|
99
|
+
return tools[key];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get all available resource categories and names
|
|
103
|
+
*/
|
|
104
|
+
export function listResourceKeys() {
|
|
105
|
+
const prompts = Object.keys((mcpResources.prompts || {}));
|
|
106
|
+
const resources = collectAllKeys((mcpResources.resources || {}));
|
|
107
|
+
const templates = Object.keys((mcpResources.templates || {}));
|
|
108
|
+
const tools = Object.keys((mcpResources.tools || {}));
|
|
109
|
+
const result = { prompts, resources, templates, tools };
|
|
110
|
+
// Add any other top-level categories
|
|
111
|
+
for (const [key, value] of Object.entries(mcpResources)) {
|
|
112
|
+
if (!['prompts', 'resources', 'templates', 'tools'].includes(key)) {
|
|
113
|
+
if (typeof value === 'object' && value !== null) {
|
|
114
|
+
result[key] = Object.keys(value);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
function collectAllKeys(obj, prefix = '', keys = []) {
|
|
121
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
122
|
+
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
123
|
+
if (typeof value === 'string') {
|
|
124
|
+
keys.push(fullKey);
|
|
125
|
+
}
|
|
126
|
+
else if (typeof value === 'object' && value !== null) {
|
|
127
|
+
collectAllKeys(value, fullKey, keys);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return keys;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=embedded-mcp-resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedded-mcp-resources.js","sourceRoot":"","sources":["../../src/resources/embedded-mcp-resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,SAAS,EAAE;QACT,mBAAmB,EAAE,yvGAAyvG;KAC/wG;IACD,WAAW,EAAE;QACX,2BAA2B,EAAE,izVAAizV;KAC/0V;IACD,WAAW,EAAE;QACX,eAAe,EAAE,mCAAmC;KACrD;IACD,OAAO,EAAE;QACP,eAAe,EAAE,ysBAAysB;QAC1tB,cAAc,EAAE,s+CAAs+C;QACt/C,eAAe,EAAE,gTAAgT;QACjU,aAAa,EAAE,gpCAAgpC;QAC/pC,aAAa,EAAE,24DAA24D;QAC15D,aAAa,EAAE,83EAA83E;QAC74E,eAAe,EAAE,09DAA09D;QAC3+D,eAAe,EAAE,q4BAAq4B;QACt5B,eAAe,EAAE,kcAAkc;KACpd;IACD,KAAK,EAAE,EAAE;CACV,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,YAAY,CAAC,OAAO,IAAI,EAAE,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,YAAY,CAAC,SAAS,IAAI,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,YAAY,CAAC,SAAS,IAAI,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,YAAY,CAAC,GAAG,IAAI,EAAE,CAAC;AAChC,CAAC;AAED;;GAEG;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CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MemoryQdrantStore } from '../services/memory/store.js';
|
|
2
|
+
/**
|
|
3
|
+
* Inject mem resources from filesystem into Qdrant at system boot
|
|
4
|
+
* Uses the key (filename) as the UUID and supports force option for override
|
|
5
|
+
* Uses storeChain for processing but updates UUID to match filename
|
|
6
|
+
*/
|
|
7
|
+
export declare function injectMemResourcesAtBoot(memoryStore: MemoryQdrantStore, options?: {
|
|
8
|
+
force?: boolean;
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=mem-resources-boot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mem-resources-boot.d.ts","sourceRoot":"","sources":["../../src/resources/mem-resources-boot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAkEhE;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,WAAW,EAAE,iBAAiB,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA0G/H"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { structuredLogger } from '../utils/structured-logger.js';
|
|
2
|
+
import { qdrantService } from '../services/qdrant/index.js';
|
|
3
|
+
import { runWithSpaceContextAsync } from '../utils/tenant-context.js';
|
|
4
|
+
import { KAIROS_APP_SPACE_ID } from '../config.js';
|
|
5
|
+
import { readdir, readFile } from 'fs/promises';
|
|
6
|
+
import { join, dirname, basename } from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
/**
|
|
9
|
+
* Get the directory containing mem files at runtime
|
|
10
|
+
* Works in both development (src/) and production (dist/)
|
|
11
|
+
*/
|
|
12
|
+
function getMemDir() {
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = dirname(__filename);
|
|
15
|
+
// In dist/, this will be dist/resources/mem-resources-boot.js
|
|
16
|
+
// So we need to go up to dist/ and then to embed-docs/mem/
|
|
17
|
+
// In development (when running from src/), this would be src/resources/mem-resources-boot.ts
|
|
18
|
+
// But in production, files are in dist/embed-docs/mem/
|
|
19
|
+
const baseDir = join(__dirname, '..', 'embed-docs', 'mem');
|
|
20
|
+
return baseDir;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Return the other of src/embed-docs/mem or dist/embed-docs/mem for fallback when primary has 0 files.
|
|
24
|
+
*/
|
|
25
|
+
function getMemDirFallback() {
|
|
26
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
27
|
+
const __dirname = dirname(__filename);
|
|
28
|
+
const parentDir = join(__dirname, '..');
|
|
29
|
+
const otherName = basename(parentDir) === 'src' ? 'dist' : 'src';
|
|
30
|
+
return join(parentDir, '..', otherName, 'embed-docs', 'mem');
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Read mem files from filesystem at runtime
|
|
34
|
+
* Returns a map of filename (without .md) -> content
|
|
35
|
+
* If memDir yields 0 .md files, tries fallback path (other of src/dist).
|
|
36
|
+
*/
|
|
37
|
+
async function readMemFiles(memDir) {
|
|
38
|
+
const dir = memDir ?? getMemDir();
|
|
39
|
+
const memResources = {};
|
|
40
|
+
try {
|
|
41
|
+
const files = await readdir(dir);
|
|
42
|
+
const mdFiles = files.filter(f => f.endsWith('.md'));
|
|
43
|
+
for (const file of mdFiles) {
|
|
44
|
+
const filePath = join(dir, file);
|
|
45
|
+
const key = file.replace(/\.md$/, ''); // Remove .md extension
|
|
46
|
+
const content = await readFile(filePath, 'utf-8');
|
|
47
|
+
memResources[key] = content;
|
|
48
|
+
structuredLogger.debug(`[mem-resources-boot] Loaded mem file: ${file} -> ${key}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
if (err.code === 'ENOENT') {
|
|
53
|
+
structuredLogger.warn(`[mem-resources-boot] Mem directory not found: ${dir} (this is OK if no mem files exist)`);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
structuredLogger.error(`[mem-resources-boot] Failed to read mem directory ${dir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return memResources;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Inject mem resources from filesystem into Qdrant at system boot
|
|
63
|
+
* Uses the key (filename) as the UUID and supports force option for override
|
|
64
|
+
* Uses storeChain for processing but updates UUID to match filename
|
|
65
|
+
*/
|
|
66
|
+
export async function injectMemResourcesAtBoot(memoryStore, options = {}) {
|
|
67
|
+
const primaryDir = getMemDir();
|
|
68
|
+
structuredLogger.info(`[mem-resources-boot] Mem dir: ${primaryDir}`);
|
|
69
|
+
let memResources = await readMemFiles(primaryDir);
|
|
70
|
+
if (Object.keys(memResources).length === 0) {
|
|
71
|
+
const fallbackDir = getMemDirFallback();
|
|
72
|
+
structuredLogger.info(`[mem-resources-boot] No files in primary dir, trying fallback: ${fallbackDir}`);
|
|
73
|
+
memResources = await readMemFiles(fallbackDir);
|
|
74
|
+
}
|
|
75
|
+
const fileCount = Object.keys(memResources).length;
|
|
76
|
+
structuredLogger.info(`[mem-resources-boot] Mem files found: ${fileCount}`);
|
|
77
|
+
if (fileCount === 0) {
|
|
78
|
+
structuredLogger.info('[mem-resources-boot] No mem resources to inject');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const appSpaceContext = {
|
|
82
|
+
userId: '',
|
|
83
|
+
groupIds: [],
|
|
84
|
+
allowedSpaceIds: [KAIROS_APP_SPACE_ID],
|
|
85
|
+
defaultWriteSpaceId: KAIROS_APP_SPACE_ID
|
|
86
|
+
};
|
|
87
|
+
await runWithSpaceContextAsync(appSpaceContext, async () => {
|
|
88
|
+
structuredLogger.info(`[mem-resources-boot] Injecting ${fileCount} mem resources into Qdrant (force: ${options.force || false})`);
|
|
89
|
+
const llmModelId = 'system-boot';
|
|
90
|
+
let injectedCount = 0;
|
|
91
|
+
for (const [key, markdownContent] of Object.entries(memResources)) {
|
|
92
|
+
if (typeof markdownContent !== 'string')
|
|
93
|
+
continue;
|
|
94
|
+
const targetUuid = key; // Use key (filename) as UUID
|
|
95
|
+
try {
|
|
96
|
+
// Use storeChain to handle parsing, embeddings, and force update logic
|
|
97
|
+
// storeChain handles forceUpdate by deleting existing chains, but we need to handle individual UUIDs
|
|
98
|
+
if (options.force) {
|
|
99
|
+
try {
|
|
100
|
+
await qdrantService.deleteMemory(targetUuid);
|
|
101
|
+
structuredLogger.info(`[mem-resources-boot] Deleted existing memory ${targetUuid} (force mode)`);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// Ignore errors if memory doesn't exist
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
try {
|
|
109
|
+
const existing = await qdrantService.getMemoryByUUID(targetUuid);
|
|
110
|
+
if (existing) {
|
|
111
|
+
structuredLogger.info(`[mem-resources-boot] Memory ${targetUuid} already exists, skipping (use --force flag to override)`);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
// Continue if check fails
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const memories = await memoryStore.storeChain([markdownContent], llmModelId, { forceUpdate: options.force || false });
|
|
120
|
+
if (memories.length > 0) {
|
|
121
|
+
// Only the first step is remapped to the file UUID; other steps of the same chain keep server-generated IDs.
|
|
122
|
+
const storedMemory = memories[0];
|
|
123
|
+
if (storedMemory.memory_uuid !== targetUuid) {
|
|
124
|
+
const { client, collection } = memoryStore.getQdrantAccess();
|
|
125
|
+
const storedPoint = await client.retrieve(collection, {
|
|
126
|
+
ids: [storedMemory.memory_uuid],
|
|
127
|
+
with_payload: true,
|
|
128
|
+
with_vector: true
|
|
129
|
+
});
|
|
130
|
+
if (storedPoint && storedPoint.length > 0) {
|
|
131
|
+
const point = storedPoint[0];
|
|
132
|
+
await client.delete(collection, { points: [storedMemory.memory_uuid] });
|
|
133
|
+
const upsertPoint = {
|
|
134
|
+
id: targetUuid,
|
|
135
|
+
payload: point.payload
|
|
136
|
+
};
|
|
137
|
+
if (point.vector) {
|
|
138
|
+
upsertPoint.vector = point.vector;
|
|
139
|
+
}
|
|
140
|
+
await client.upsert(collection, { points: [upsertPoint] });
|
|
141
|
+
const { redisCacheService } = await import('../services/redis-cache.js');
|
|
142
|
+
await redisCacheService.invalidateMemoryCache(storedMemory.memory_uuid);
|
|
143
|
+
await redisCacheService.invalidateMemoryCache(targetUuid);
|
|
144
|
+
await redisCacheService.invalidateSearchCache();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
injectedCount++;
|
|
148
|
+
structuredLogger.info(`[mem-resources-boot] Injected memory ${targetUuid}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
153
|
+
structuredLogger.error(`[mem-resources-boot] Failed to inject memory ${targetUuid}: ${message}`);
|
|
154
|
+
structuredLogger.info(`[mem-resources-boot] Failed memory ${targetUuid}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
structuredLogger.info(`[mem-resources-boot] Successfully injected ${injectedCount} mem resources into Qdrant`);
|
|
158
|
+
const { methods } = memoryStore;
|
|
159
|
+
if (methods && typeof methods.invalidateLocalCache === 'function') {
|
|
160
|
+
methods.invalidateLocalCache();
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=mem-resources-boot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mem-resources-boot.js","sourceRoot":"","sources":["../../src/resources/mem-resources-boot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MA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U,EAAE,CAAC,CAAC;YAC5E,CAAC;QACH,CAAC;QAED,gBAAgB,CAAC,IAAI,CAAC,8CAA8C,aAAa,4BAA4B,CAAC,CAAC;QAE/G,MAAM,EAAE,OAAO,EAAE,GAAI,WAAmB,CAAC;QACzC,IAAI,OAAO,IAAI,OAAO,OAAO,CAAC,oBAAoB,KAAK,UAAU,EAAE,CAAC;YAClE,OAAO,CAAC,oBAAoB,EAAE,CAAC;QACjC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-resources.d.ts","sourceRoot":"","sources":["../../src/resources/prompt-resources.ts"],"names":[],"mappings":"AAkBA;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,GAAG,QAqClD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getPrompts, getPrompt } from './embedded-mcp-resources.js';
|
|
2
|
+
import { logger } from '../utils/logger.js';
|
|
3
|
+
const promptOverrides = {
|
|
4
|
+
'contextual-prompt': {
|
|
5
|
+
title: 'KAIROS Core Execution Engine',
|
|
6
|
+
description: 'Required execution policy for KAIROS protocol runs',
|
|
7
|
+
resultDescription: 'Required execution policy for KAIROS protocol runs'
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Register all prompts from embedded-mcp-resources
|
|
12
|
+
*/
|
|
13
|
+
export function registerPromptResources(server) {
|
|
14
|
+
logger.info('Registering prompts dynamically from embedded resources');
|
|
15
|
+
const prompts = getPrompts();
|
|
16
|
+
for (const [key, text] of Object.entries(prompts)) {
|
|
17
|
+
const override = promptOverrides[key] ?? {};
|
|
18
|
+
const title = override.title || key.replace(/[-_]/g, ' ').replace(/\b\w/g, (l) => l.toUpperCase());
|
|
19
|
+
const description = override.description || `Prompt: ${title}`;
|
|
20
|
+
const resultDescription = override.resultDescription || description;
|
|
21
|
+
server.registerPrompt(key, {
|
|
22
|
+
title,
|
|
23
|
+
description
|
|
24
|
+
}, async () => {
|
|
25
|
+
const promptText = getPrompt(key) || text;
|
|
26
|
+
const result = {
|
|
27
|
+
description: resultDescription,
|
|
28
|
+
messages: [
|
|
29
|
+
{
|
|
30
|
+
role: 'user',
|
|
31
|
+
content: {
|
|
32
|
+
type: 'text',
|
|
33
|
+
text: promptText
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
};
|
|
38
|
+
return result;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=prompt-resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-resources.js","sourceRoot":"","sources":["../../src/resources/prompt-resources.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAQ5C,MAAM,eAAe,GAAmC;IACtD,mBAAmB,EAAE;QACnB,KAAK,EAAE,8BAA8B;QACrC,WAAW,EAAE,oDAAoD;QACjE,iBAAiB,EAAE,oDAAoD;KACxE;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAW;IACjD,MAAM,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;IAEvE,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAE7B,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAClD,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAC5C,MAAM,KAAK,GACT,QAAQ,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QAC/F,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,IAAI,WAAW,KAAK,EAAE,CAAC;QAC/D,MAAM,iBAAiB,GAAG,QAAQ,CAAC,iBAAiB,IAAI,WAAW,CAAC;QAEpE,MAAM,CAAC,cAAc,CACnB,GAAG,EACH;YACE,KAAK;YACL,WAAW;SACZ,EACD,KAAK,IAA8B,EAAE;YACnC,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;YAC1C,MAAM,MAAM,GAAoB;gBAC9B,WAAW,EAAE,iBAAiB;gBAC9B,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE;4BACP,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,UAAU;yBACjB;qBACF;iBACF;aACF,CAAC;YAEF,OAAO,MAAM,CAAC;QAChB,CAAC,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensures the MCP server has resource handlers wired up even when no public
|
|
3
|
+
* resources or templates are registered. Without this bootstrap, the SDK
|
|
4
|
+
* refuses to expose resources/* methods and returns Method not found.
|
|
5
|
+
*/
|
|
6
|
+
export declare function bootstrapEmptyResourceHandlers(server: any): void;
|
|
7
|
+
//# sourceMappingURL=resource-bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-bootstrap.d.ts","sourceRoot":"","sources":["../../src/resources/resource-bootstrap.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,GAAG,QAoCzD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
/**
|
|
3
|
+
* Ensures the MCP server has resource handlers wired up even when no public
|
|
4
|
+
* resources or templates are registered. Without this bootstrap, the SDK
|
|
5
|
+
* refuses to expose resources/* methods and returns Method not found.
|
|
6
|
+
*/
|
|
7
|
+
export function bootstrapEmptyResourceHandlers(server) {
|
|
8
|
+
// Register a throwaway resource to trigger handler installation, then remove it.
|
|
9
|
+
const placeholderUri = 'kairos://__internal__/bootstrap';
|
|
10
|
+
const placeholderResource = server.registerResource('__kairos_internal_bootstrap_resource__', placeholderUri, {
|
|
11
|
+
title: 'bootstrap',
|
|
12
|
+
description: 'internal bootstrap resource',
|
|
13
|
+
mimeType: 'text/plain'
|
|
14
|
+
}, () => ({
|
|
15
|
+
contents: [{ uri: placeholderUri, mimeType: 'text/plain', text: '' }]
|
|
16
|
+
}));
|
|
17
|
+
placeholderResource.remove();
|
|
18
|
+
// Same trick for resource templates so /resources/templates/list stays available.
|
|
19
|
+
const template = new ResourceTemplate('kairos://__internal__/bootstrap/{id}', {
|
|
20
|
+
async list() {
|
|
21
|
+
return { resources: [] };
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const placeholderTemplate = server.registerResource('__kairos_internal_bootstrap_template__', template, {
|
|
25
|
+
title: 'bootstrap template',
|
|
26
|
+
description: 'internal bootstrap template',
|
|
27
|
+
mimeType: 'text/plain'
|
|
28
|
+
}, async () => ({
|
|
29
|
+
contents: []
|
|
30
|
+
}));
|
|
31
|
+
placeholderTemplate.remove();
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=resource-bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-bootstrap.js","sourceRoot":"","sources":["../../src/resources/resource-bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAAC,MAAW;IACxD,iFAAiF;IACjF,MAAM,cAAc,GAAG,iCAAiC,CAAC;IACzD,MAAM,mBAAmB,GAAG,MAAM,CAAC,gBAAgB,CACjD,wCAAwC,EACxC,cAAc,EACd;QACE,KAAK,EAAE,WAAW;QAClB,WAAW,EAAE,6BAA6B;QAC1C,QAAQ,EAAE,YAAY;KACvB,EACD,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;KACtE,CAAC,CACH,CAAC;IACF,mBAAmB,CAAC,MAAM,EAAE,CAAC;IAE7B,kFAAkF;IAClF,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,sCAAsC,EAAE;QAC5E,KAAK,CAAC,IAAI;YACR,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;QAC3B,CAAC;KACF,CAAC,CAAC;IACH,MAAM,mBAAmB,GAAG,MAAM,CAAC,gBAAgB,CACjD,wCAAwC,EACxC,QAAQ,EACR;QACE,KAAK,EAAE,oBAAoB;QAC3B,WAAW,EAAE,6BAA6B;QAC1C,QAAQ,EAAE,YAAY;KACvB,EACD,KAAK,IAAI,EAAE,CAAC,CAAC;QACX,QAAQ,EAAE,EAAE;KACb,CAAC,CACH,CAAC;IACF,mBAAmB,CAAC,MAAM,EAAE,CAAC;AAC/B,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAgB/D,wBAAgB,YAAY,CAAC,WAAW,EAAE,iBAAiB,GAAG,SAAS,CAmEtE"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { structuredLogger } from './utils/structured-logger.js';
|
|
3
|
+
import { registerDocsResources } from './resources/docs-resources.js';
|
|
4
|
+
import { registerPromptResources } from './resources/prompt-resources.js';
|
|
5
|
+
import { bootstrapEmptyResourceHandlers } from './resources/resource-bootstrap.js';
|
|
6
|
+
import { qdrantService } from './services/qdrant/index.js';
|
|
7
|
+
import { getBuildVersion } from './utils/build-version.js';
|
|
8
|
+
import { registerKairosMintTool } from './tools/kairos_mint.js';
|
|
9
|
+
import { LOG_LEVEL, LOG_FORMAT, TRANSPORT_TYPE, getQdrantUrl, getQdrantCollection, QDRANT_API_KEY, QDRANT_RESCORE_STRING, TEI_URL, TEI_MODEL, getEmbeddingDimension, getTeiDimension, KAIROS_SEARCH_OVERFETCH_FACTOR, KAIROS_SEARCH_MAX_FETCH, KAIROS_ENABLE_GROUP_COLLAPSE } from './config.js';
|
|
10
|
+
// removed: debug tools (kb_version, kb_cache_stats)
|
|
11
|
+
import { registerKairosUpdateTool } from './tools/kairos_update.js';
|
|
12
|
+
import { registerKairosDeleteTool } from './tools/kairos_delete.js';
|
|
13
|
+
import { registerSearchTool } from './tools/kairos_search.js';
|
|
14
|
+
import { registerBeginTool } from './tools/kairos_begin.js';
|
|
15
|
+
import { registerKairosNextTool } from './tools/kairos_next.js';
|
|
16
|
+
import { registerKairosAttestTool } from './tools/kairos_attest.js';
|
|
17
|
+
import { registerKairosDumpTool } from './tools/kairos_dump.js';
|
|
18
|
+
import { registerKairosSpacesTool } from './tools/kairos_spaces.js';
|
|
19
|
+
// Create and configure the MCP server
|
|
20
|
+
export function createServer(memoryStore) {
|
|
21
|
+
const server = new McpServer({
|
|
22
|
+
name: 'KAIROS',
|
|
23
|
+
version: getBuildVersion()
|
|
24
|
+
}, {
|
|
25
|
+
capabilities: {
|
|
26
|
+
tools: {},
|
|
27
|
+
resources: {},
|
|
28
|
+
prompts: {}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
// Register kairos tools
|
|
32
|
+
// New protocol workflow: search -> begin (step 1) -> next (steps 2+) -> attest
|
|
33
|
+
registerSearchTool(server, memoryStore, { qdrantService });
|
|
34
|
+
registerBeginTool(server, memoryStore, { qdrantService });
|
|
35
|
+
registerKairosNextTool(server, memoryStore, { qdrantService });
|
|
36
|
+
registerKairosMintTool(server, memoryStore);
|
|
37
|
+
registerKairosAttestTool(server, qdrantService);
|
|
38
|
+
registerKairosUpdateTool(server);
|
|
39
|
+
registerKairosDeleteTool(server);
|
|
40
|
+
registerKairosDumpTool(server, memoryStore, { qdrantService });
|
|
41
|
+
registerKairosSpacesTool(server, memoryStore);
|
|
42
|
+
// Register resources
|
|
43
|
+
bootstrapEmptyResourceHandlers(server);
|
|
44
|
+
// Register docs resources (from embedded-mcp-resources)
|
|
45
|
+
registerDocsResources(server);
|
|
46
|
+
// Register prompts (from embedded-mcp-resources)
|
|
47
|
+
registerPromptResources(server);
|
|
48
|
+
// Log runtime configuration (mask secrets)
|
|
49
|
+
const mask = (v) => (v ? `${v.slice(0, 2)}***${v.slice(-2)}` : undefined);
|
|
50
|
+
const config = {
|
|
51
|
+
log: {
|
|
52
|
+
level: LOG_LEVEL,
|
|
53
|
+
format: LOG_FORMAT,
|
|
54
|
+
},
|
|
55
|
+
transport: {
|
|
56
|
+
type: TRANSPORT_TYPE,
|
|
57
|
+
},
|
|
58
|
+
qdrant: {
|
|
59
|
+
url: getQdrantUrl(),
|
|
60
|
+
collection: getQdrantCollection(),
|
|
61
|
+
apiKey: mask(QDRANT_API_KEY),
|
|
62
|
+
rescore: QDRANT_RESCORE_STRING,
|
|
63
|
+
},
|
|
64
|
+
tei: {
|
|
65
|
+
url: TEI_URL,
|
|
66
|
+
model: TEI_MODEL,
|
|
67
|
+
dim_env: getEmbeddingDimension() || getTeiDimension(),
|
|
68
|
+
},
|
|
69
|
+
search: {
|
|
70
|
+
overfetch: KAIROS_SEARCH_OVERFETCH_FACTOR,
|
|
71
|
+
maxFetch: KAIROS_SEARCH_MAX_FETCH,
|
|
72
|
+
groupCollapse: KAIROS_ENABLE_GROUP_COLLAPSE
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
structuredLogger.debug(`runtime config ${JSON.stringify(config)}`);
|
|
76
|
+
structuredLogger.info('MCP server created and configured');
|
|
77
|
+
return server;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,qBAAqB,EAAE,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,eAAe,EAAE,8BAA8B,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AACjS,oDAAoD;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,s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C,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACnF,MAAM,MAAM,GAAG;QACX,GAAG,EAAE;YACD,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,UAAU;SACrB;QACD,SAAS,EAAE;YACP,IAAI,EAAE,cAAc;SACvB;QACD,MAAM,EAAE;YACJ,GAAG,EAAE,YAAY,EAAE;YACnB,UAAU,EAAE,mBAAmB,EAAE;YACjC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC;YAC5B,OAAO,EAAE,qBAAqB;SACjC;QACD,GAAG,EAAE;YACD,GAAG,EAAE,OAAO;YACZ,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,qBAAqB,EAAE,IAAI,eAAe,EAAE;SACxD;QACD,MAAM,EAAE;YACJ,SAAS,EAAE,8BAA8B;YACzC,QAAQ,EAAE,uBAAuB;YACjC,aAAa,EAAE,4BAA4B;SAC9C;KACJ,CAAC;IACF,gBAAgB,CAAC,KAAK,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAEnE,gBAAgB,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IAC3D,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Memory } from '../types/memory.js';
|
|
2
|
+
export interface ResolvedChainStep {
|
|
3
|
+
uuid: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
step?: number;
|
|
6
|
+
count?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function resolveFirstStep(memory: Memory, qdrantService?: any): Promise<{
|
|
9
|
+
uri: string;
|
|
10
|
+
label: string;
|
|
11
|
+
} | undefined>;
|
|
12
|
+
export declare function resolveChainFirstStep(memory: Memory, qdrantService?: any): Promise<ResolvedChainStep | undefined>;
|
|
13
|
+
export declare function resolveChainNextStep(memory: Memory, qdrantService?: any): Promise<ResolvedChainStep | undefined>;
|
|
14
|
+
export declare function resolveChainPreviousStep(memory: Memory, qdrantService?: any): Promise<ResolvedChainStep | undefined>;
|
|
15
|
+
declare const _default: {
|
|
16
|
+
resolveFirstStep: typeof resolveFirstStep;
|
|
17
|
+
resolveChainFirstStep: typeof resolveChainFirstStep;
|
|
18
|
+
resolveChainNextStep: typeof resolveChainNextStep;
|
|
19
|
+
resolveChainPreviousStep: typeof resolveChainPreviousStep;
|
|
20
|
+
};
|
|
21
|
+
export default _default;
|
|
22
|
+
//# sourceMappingURL=chain-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-utils.d.ts","sourceRoot":"","sources":["../../src/services/chain-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAYD,wBAAsB,gBAAgB,CAClC,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,GAAG,GACpB,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC,CAkBrD;AAED,wBAAsB,qBAAqB,CACvC,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,GAAG,GACpB,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAexC;AAED,wBAAsB,oBAAoB,CACtC,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,GAAG,GACpB,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAexC;AAED,wBAAsB,wBAAwB,CAC1C,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,GAAG,GACpB,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAexC;;;;;;;AAED,wBAKE"}
|