@dikolab/kbdb 0.3.0 → 0.3.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/README.md +24 -43
- package/dist/bench/constants/corpus-defaults.constant.d.ts +3 -0
- package/dist/bench/functions/format-report.function.d.ts +11 -0
- package/dist/bench/functions/generate-corpus.function.d.ts +12 -0
- package/dist/bench/functions/measure-operation.function.d.ts +14 -0
- package/dist/bench/functions/seeded-rng.function.d.ts +11 -0
- package/dist/bench/functions/zipf-word.function.d.ts +13 -0
- package/dist/bench/index.d.ts +10 -0
- package/dist/bench/typings/bench-result.interface.d.ts +11 -0
- package/dist/bench/typings/bench-suite-result.interface.d.ts +10 -0
- package/dist/bench/typings/corpus-config.interface.d.ts +11 -0
- package/dist/bench/typings/corpus-section.interface.d.ts +9 -0
- package/dist/cli.cjs +63 -9
- package/dist/cli.cjs.map +2 -2
- package/dist/cli.mjs +63 -9
- package/dist/cli.mjs.map +2 -2
- package/dist/src/shared/auto-capture/classes/auto-capture-controller.class.d.ts +33 -0
- package/dist/src/shared/auto-capture/constants/auto-capture-defaults.constant.d.ts +8 -0
- package/dist/src/shared/auto-capture/functions/build-capture-prompt.function.d.ts +11 -0
- package/dist/src/shared/auto-capture/functions/evaluate-trigger.function.d.ts +12 -0
- package/dist/src/shared/auto-capture/index.d.ts +7 -0
- package/dist/src/shared/auto-capture/typings/auto-capture-config.interface.d.ts +13 -0
- package/dist/src/shared/auto-capture/typings/auto-capture-state.interface.d.ts +13 -0
- package/dist/src/shared/auto-capture/typings/auto-capture-trigger.interface.d.ts +7 -0
- package/dist/src/shared/cli/constants/global-help.constant.d.ts +8 -0
- package/dist/src/shared/cli/constants/leaf-help.constant.d.ts +7 -0
- package/dist/src/shared/cli/constants/memory-protocol-body.constant.d.ts +7 -0
- package/dist/src/shared/cli/constants/query-guidance-body.constant.d.ts +7 -0
- package/dist/src/shared/cli/constants/subcommand-help.constant.d.ts +8 -0
- package/dist/src/shared/cli/functions/collect-files.function.d.ts +13 -0
- package/dist/src/shared/cli/functions/compute-section-kbid.function.d.ts +15 -0
- package/dist/src/shared/cli/functions/format-mcp-output.function.d.ts +9 -0
- package/dist/src/shared/cli/functions/format-text-output.function.d.ts +9 -0
- package/dist/src/shared/cli/functions/generate-group-help.function.d.ts +11 -0
- package/dist/src/shared/cli/functions/handle-data-command.function.d.ts +16 -0
- package/dist/src/shared/cli/functions/handle-mcp.function.d.ts +15 -0
- package/dist/src/shared/cli/functions/handle-migrate.function.d.ts +15 -0
- package/dist/src/shared/cli/functions/hydrate-search-previews.function.d.ts +14 -0
- package/dist/src/shared/cli/functions/resolve-skill-names.function.d.ts +16 -0
- package/dist/src/shared/cli/functions/run-search.function.d.ts +1 -0
- package/dist/src/shared/cli/functions/version-gate.function.d.ts +15 -0
- package/dist/src/shared/cli/functions/wrap-command.function.d.ts +15 -0
- package/dist/src/shared/cli/typings/agent-create-client.interface.d.ts +42 -0
- package/dist/src/shared/cli/typings/agent-get-client.interface.d.ts +36 -0
- package/dist/src/shared/cli/typings/check-client.interface.d.ts +58 -0
- package/dist/src/shared/cli/typings/cli-deps.interface.d.ts +48 -0
- package/dist/src/shared/cli/typings/cli-options.interface.d.ts +2 -0
- package/dist/src/shared/cli/typings/disconnectable-client.interface.d.ts +26 -0
- package/dist/src/shared/cli/typings/dispatch-client.type.d.ts +27 -0
- package/dist/src/shared/cli/typings/learn-client.interface.d.ts +52 -0
- package/dist/src/shared/cli/typings/learn-io.interface.d.ts +5 -0
- package/dist/src/shared/cli/typings/search-client.interface.d.ts +71 -0
- package/dist/src/shared/embedding/classes/null-embedding-provider.class.d.ts +20 -0
- package/dist/src/shared/embedding/constants/near-duplicate-thresholds.constant.d.ts +15 -0
- package/dist/src/shared/embedding/functions/build-vector-index.function.d.ts +14 -0
- package/dist/src/shared/embedding/functions/cosine-similarity.function.d.ts +10 -0
- package/dist/src/shared/embedding/functions/detect-near-duplicates.function.d.ts +18 -0
- package/dist/src/shared/embedding/functions/jaccard-coefficient.function.d.ts +9 -0
- package/dist/src/shared/embedding/functions/read-vector-index-meta.function.d.ts +10 -0
- package/dist/src/shared/embedding/functions/rrf-fuse.function.d.ts +14 -0
- package/dist/src/shared/embedding/functions/search-vectors.function.d.ts +14 -0
- package/dist/src/shared/embedding/index.d.ts +16 -0
- package/dist/src/shared/embedding/typings/embedding-config.interface.d.ts +20 -0
- package/dist/src/shared/embedding/typings/embedding-provider.interface.d.ts +23 -0
- package/dist/src/shared/embedding/typings/near-duplicate-candidate.model.d.ts +23 -0
- package/dist/src/shared/embedding/typings/near-duplicate-result.model.d.ts +24 -0
- package/dist/src/shared/embedding/typings/vector-index-entry.model.d.ts +12 -0
- package/dist/src/shared/embedding/typings/vector-index-meta.model.d.ts +11 -0
- package/dist/src/shared/embedding/typings/vector-search-result.model.d.ts +7 -0
- package/dist/src/shared/mcp/constants/tool-agent-create.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-agent-delete.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-agent-get.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-agent-list.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-auto-capture-review.constant.d.ts +8 -0
- package/dist/src/shared/mcp/constants/tool-check.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-content.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-export.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-gc.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-learn.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-rebuild.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-recall.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-retrieve.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-search.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-skill-delete.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-skill-get.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-skill-learn.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-skill-list.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-status.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-unlearn.constant.d.ts +3 -0
- package/dist/src/shared/mcp/functions/as-boolean-or-undefined.function.d.ts +7 -0
- package/dist/src/shared/mcp/functions/as-string-array-or-undefined.function.d.ts +7 -0
- package/dist/src/shared/mcp/functions/as-string-array.function.d.ts +7 -0
- package/dist/src/shared/mcp/functions/as-string.function.d.ts +8 -0
- package/dist/src/shared/mcp/functions/build-skills-text.function.d.ts +18 -0
- package/dist/src/shared/mcp/functions/handle-agent-prompt.function.d.ts +14 -0
- package/dist/src/shared/mcp/functions/handle-mcp-request.function.d.ts +14 -0
- package/dist/src/shared/mcp/functions/handle-prompt-get.function.d.ts +4 -3
- package/dist/src/shared/mcp/functions/handle-skill-prompt.function.d.ts +16 -0
- package/dist/src/shared/mcp/functions/handle-tool-auto-capture-review.function.d.ts +12 -0
- package/dist/src/shared/mcp/functions/handle-tool-check.function.d.ts +11 -0
- package/dist/src/shared/mcp/functions/handle-tool-content.function.d.ts +12 -0
- package/dist/src/shared/mcp/functions/handle-tool-export.function.d.ts +12 -0
- package/dist/src/shared/mcp/functions/handle-tool-gc.function.d.ts +11 -0
- package/dist/src/shared/mcp/functions/handle-tool-learn.function.d.ts +12 -0
- package/dist/src/shared/mcp/functions/handle-tool-rebuild.function.d.ts +11 -0
- package/dist/src/shared/mcp/functions/handle-tool-retrieve.function.d.ts +12 -0
- package/dist/src/shared/mcp/functions/handle-tool-search.function.d.ts +13 -0
- package/dist/src/shared/mcp/functions/handle-tool-skill-delete.function.d.ts +12 -0
- package/dist/src/shared/mcp/functions/handle-tool-skill-get.function.d.ts +13 -0
- package/dist/src/shared/mcp/functions/handle-tool-skill-learn.function.d.ts +13 -0
- package/dist/src/shared/mcp/functions/handle-tool-skill-list.function.d.ts +11 -0
- package/dist/src/shared/mcp/functions/handle-tool-status.function.d.ts +11 -0
- package/dist/src/shared/mcp/functions/handle-tool-unlearn.function.d.ts +12 -0
- package/dist/src/shared/mcp/functions/parse-agent-meta.function.d.ts +14 -0
- package/dist/src/shared/mcp/functions/parse-skill-arguments.function.d.ts +11 -0
- package/dist/src/shared/mcp/functions/read-agent-meta.function.d.ts +17 -0
- package/dist/src/shared/mcp/functions/resolve-skill-refs.function.d.ts +23 -0
- package/dist/src/shared/mcp/functions/run-startup-health-check.function.d.ts +14 -0
- package/dist/src/shared/mcp/typings/mcp-capabilities.interface.d.ts +16 -0
- package/dist/src/shared/mcp/typings/mcp-client.interface.d.ts +2 -0
- package/dist/src/shared/mcp/typings/mcp-completion.interface.d.ts +43 -0
- package/dist/src/shared/mcp/typings/mcp-content-result.model.d.ts +9 -0
- package/dist/src/shared/mcp/typings/mcp-export-result.model.d.ts +11 -0
- package/dist/src/shared/mcp/typings/mcp-gc-result.model.d.ts +15 -0
- package/dist/src/shared/mcp/typings/mcp-integrity-check-result.model.d.ts +16 -0
- package/dist/src/shared/mcp/typings/mcp-integrity-error.model.d.ts +9 -0
- package/dist/src/shared/mcp/typings/mcp-notification.interface.d.ts +9 -0
- package/dist/src/shared/mcp/typings/mcp-rebuild-result.model.d.ts +9 -0
- package/dist/src/shared/mcp/typings/mcp-request.interface.d.ts +11 -0
- package/dist/src/shared/mcp/typings/mcp-resource-result.interface.d.ts +12 -0
- package/dist/src/shared/mcp/typings/mcp-resource-template.interface.d.ts +11 -0
- package/dist/src/shared/mcp/typings/mcp-response.interface.d.ts +18 -0
- package/dist/src/shared/mcp/typings/mcp-server-info.interface.d.ts +7 -0
- package/dist/src/shared/mcp/typings/mcp-server-state.interface.d.ts +16 -0
- package/dist/src/shared/mcp/typings/mcp-tool-annotations.interface.d.ts +32 -0
- package/dist/src/shared/mcp/typings/mcp-tool-definition.interface.d.ts +15 -0
- package/dist/src/shared/mcp/typings/mcp-tool-result.interface.d.ts +19 -0
- package/dist/src/shared/mcp/typings/mcp-worker-client.interface.d.ts +220 -0
- package/dist/src/shared/mcp/typings/tool-call-result.model.d.ts +17 -0
- package/dist/src/shared/sync/functions/build-import-report.function.d.ts +18 -0
- package/dist/src/shared/sync/functions/parse-export-entry.function.d.ts +11 -0
- package/dist/src/shared/sync/functions/resolve-conflict.function.d.ts +13 -0
- package/dist/src/shared/sync/functions/serialize-export-entry.function.d.ts +8 -0
- package/dist/src/shared/sync/index.d.ts +9 -0
- package/dist/src/shared/sync/typings/conflict-resolution.type.d.ts +8 -0
- package/dist/src/shared/sync/typings/export-entry.interface.d.ts +13 -0
- package/dist/src/shared/sync/typings/export-options.interface.d.ts +9 -0
- package/dist/src/shared/sync/typings/import-options.interface.d.ts +7 -0
- package/dist/src/shared/sync/typings/import-report.interface.d.ts +15 -0
- package/dist/src/shared/wasm-codec/functions/decode-one-recall-result.function.d.ts +14 -0
- package/dist/src/shared/wasm-codec/functions/decode-option-string.function.d.ts +12 -0
- package/dist/src/shared/wasm-codec/functions/decode-recall-document.function.d.ts +14 -0
- package/dist/src/shared/wasm-codec/functions/decode-recall-reference.function.d.ts +14 -0
- package/dist/src/shared/wasm-codec/functions/decode-recall-sibling.function.d.ts +13 -0
- package/dist/src/shared/wasm-codec/functions/decode-section-match.function.d.ts +15 -0
- package/dist/src/shared/wasm-codec/functions/decode-section-record-trailing.function.d.ts +14 -0
- package/dist/src/shared/wasm-codec/functions/decode-section-record.function.d.ts +14 -0
- package/dist/src/shared/wasm-codec/functions/decode-section-type.function.d.ts +13 -0
- package/dist/src/shared/wasm-codec/functions/decode-wasm-list.function.d.ts +17 -0
- package/dist/src/shared/wasm-codec/typings/add-section-input.model.d.ts +45 -0
- package/dist/src/shared/wasm-codec/typings/add-section-result.model.d.ts +27 -0
- package/dist/src/shared/wasm-codec/typings/document-manifest.model.d.ts +19 -0
- package/dist/src/shared/wasm-codec/typings/document-section.model.d.ts +12 -0
- package/dist/src/shared/wasm-codec/typings/item-decoder.type.d.ts +6 -0
- package/dist/src/shared/wasm-codec/typings/near-duplicate.model.d.ts +16 -0
- package/dist/src/shared/wasm-codec/typings/paged-search-result.model.d.ts +21 -0
- package/dist/src/shared/wasm-codec/typings/section-match.model.d.ts +31 -0
- package/dist/src/shared/wasm-codec/typings/section-record-trailing.model.d.ts +38 -0
- package/dist/src/shared/wasm-codec/typings/section-record.model.d.ts +66 -0
- package/dist/src/shared/wasm-codec/typings/section-type-result.model.d.ts +12 -0
- package/dist/src/shared/worker-client/functions/handle-ipc-data.function.d.ts +16 -0
- package/dist/src/shared/worker-client/functions/send-ipc-request.function.d.ts +19 -0
- package/dist/src/shared/worker-client/typings/add-section-result.model.d.ts +2 -0
- package/dist/src/shared/worker-client/typings/json-rpc-response.interface.d.ts +16 -0
- package/dist/src/shared/worker-client/typings/pending-call.interface.d.ts +7 -0
- package/dist/src/shared/worker-client/typings/recall-document.model.d.ts +16 -0
- package/dist/src/shared/worker-client/typings/recall-params.model.d.ts +15 -0
- package/dist/src/shared/worker-client/typings/recall-reference.model.d.ts +32 -0
- package/dist/src/shared/worker-client/typings/recall-sibling.model.d.ts +11 -0
- package/dist/src/shared/worker-client/typings/recall-single-result.model.d.ts +40 -0
- package/dist/src/shared/worker-daemon/classes/ipc-error.class.d.ts +17 -0
- package/dist/src/shared/worker-daemon/constants/wasm-method-map.constant.d.ts +16 -0
- package/dist/src/shared/worker-daemon/functions/build-ipc-error-response.function.d.ts +9 -0
- package/dist/src/shared/worker-daemon/functions/check-catalog-version.function.d.ts +9 -0
- package/dist/src/shared/worker-daemon/functions/check-preconditions.function.d.ts +10 -0
- package/dist/src/shared/worker-daemon/functions/detect-stale-pid.function.d.ts +15 -0
- package/dist/src/shared/worker-daemon/functions/dispatch-request.function.d.ts +35 -0
- package/dist/src/shared/worker-daemon/functions/handle-check-version.function.d.ts +23 -0
- package/dist/src/shared/worker-daemon/functions/handle-config-method.function.d.ts +11 -0
- package/dist/src/shared/worker-daemon/functions/handle-read-ops.function.d.ts +52 -0
- package/dist/src/shared/worker-daemon/functions/handle-write-ops.function.d.ts +44 -0
- package/dist/src/shared/worker-daemon/functions/parse-auto-capture-section.function.d.ts +14 -0
- package/dist/src/shared/worker-daemon/functions/parse-catalog-version.function.d.ts +10 -0
- package/dist/src/shared/worker-daemon/functions/parse-embedding-section.function.d.ts +13 -0
- package/dist/src/shared/worker-daemon/functions/parse-worker-toml.function.d.ts +11 -0
- package/dist/src/shared/worker-daemon/functions/run-startup-integrity-check.function.d.ts +18 -0
- package/dist/src/shared/worker-daemon/functions/scan-near-duplicates.function.d.ts +21 -0
- package/dist/src/shared/worker-daemon/functions/wasm-bridge.function.d.ts +51 -0
- package/dist/src/shared/worker-daemon/functions/wasm-memory-helpers.function.d.ts +22 -0
- package/dist/src/shared/worker-daemon/functions/write-lock.function.d.ts +32 -0
- package/dist/src/shared/worker-daemon/typings/allocator-ref.interface.d.ts +16 -0
- package/dist/src/shared/worker-daemon/typings/daemon-config.interface.d.ts +6 -0
- package/dist/src/shared/worker-daemon/typings/fs-adapter.interface.d.ts +22 -0
- package/dist/src/shared/worker-daemon/typings/handler-context.interface.d.ts +18 -0
- package/dist/src/shared/worker-daemon/typings/memory-ref.interface.d.ts +13 -0
- package/dist/src/shared/worker-daemon/typings/wasm-fn.type.d.ts +2 -0
- package/dist/src/shared/worker-daemon/typings/write-lock.interface.d.ts +15 -0
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/docs/details/mcp-server.md +4 -2
- package/docs/goals/auto-capture.md +378 -0
- package/docs/goals/benchmarking.md +296 -0
- package/docs/goals/concurrency.md +259 -0
- package/docs/goals/hybrid-search.md +436 -0
- package/docs/goals/semantic-dedup.md +229 -0
- package/docs/goals/sync.md +217 -0
- package/docs/modules/rust/fs-database/indexes/vectors.md +110 -0
- package/docs/modules/typescript/shared/auto-capture/module.md +73 -0
- package/docs/modules/typescript/shared/embedding/functions.md +94 -0
- package/docs/modules/typescript/shared/embedding/module.md +71 -0
- package/docs/modules/typescript/shared/embedding/typings.md +122 -0
- package/docs/overview.md +148 -166
- package/docs/release-notes/0.2.0.md +3 -3
- package/docs/release-notes/0.3.0.md +89 -0
- package/docs/release-notes/0.3.1.md +111 -0
- package/docs/release-notes/README.md +2 -0
- package/package.json +1 -1
- package/src/shared/auto-capture/classes/auto-capture-controller.class.ts +62 -0
- package/src/shared/auto-capture/constants/auto-capture-defaults.constant.ts +15 -0
- package/src/shared/auto-capture/functions/build-capture-prompt.function.ts +27 -0
- package/src/shared/auto-capture/functions/evaluate-trigger.function.ts +50 -0
- package/src/shared/auto-capture/index.ts +7 -0
- package/src/shared/auto-capture/typings/auto-capture-config.interface.ts +13 -0
- package/src/shared/auto-capture/typings/auto-capture-state.interface.ts +13 -0
- package/src/shared/auto-capture/typings/auto-capture-trigger.interface.ts +7 -0
- package/src/shared/cli/constants/global-help.constant.ts +73 -0
- package/src/shared/cli/constants/leaf-help.constant.ts +219 -0
- package/src/shared/cli/constants/memory-protocol-body.constant.ts +39 -0
- package/src/shared/cli/constants/query-guidance-body.constant.ts +37 -0
- package/src/shared/cli/constants/subcommand-help.constant.ts +195 -0
- package/src/shared/cli/functions/collect-files.function.ts +55 -0
- package/src/shared/cli/functions/compute-section-kbid.function.ts +49 -0
- package/src/shared/cli/functions/format-mcp-output.function.ts +41 -0
- package/src/shared/cli/functions/format-text-output.function.ts +42 -0
- package/src/shared/cli/functions/generate-group-help.function.ts +41 -0
- package/src/shared/cli/functions/handle-data-command.function.ts +67 -0
- package/src/shared/cli/functions/handle-mcp.function.ts +56 -0
- package/src/shared/cli/functions/handle-migrate.function.ts +64 -0
- package/src/shared/cli/functions/hydrate-search-previews.function.ts +29 -0
- package/src/shared/cli/functions/parse-args.function.ts +3 -0
- package/src/shared/cli/functions/resolve-skill-names.function.ts +43 -0
- package/src/shared/cli/functions/run-search.function.ts +2 -0
- package/src/shared/cli/functions/version-gate.function.ts +44 -0
- package/src/shared/cli/functions/wrap-command.function.ts +34 -0
- package/src/shared/cli/typings/agent-create-client.interface.ts +47 -0
- package/src/shared/cli/typings/agent-get-client.interface.ts +39 -0
- package/src/shared/cli/typings/check-client.interface.ts +66 -0
- package/src/shared/cli/typings/cli-deps.interface.ts +54 -0
- package/src/shared/cli/typings/cli-options.interface.ts +2 -0
- package/src/shared/cli/typings/disconnectable-client.interface.ts +29 -0
- package/src/shared/cli/typings/dispatch-client.type.ts +46 -0
- package/src/shared/cli/typings/learn-client.interface.ts +53 -0
- package/src/shared/cli/typings/learn-io.interface.ts +5 -0
- package/src/shared/cli/typings/search-client.interface.ts +73 -0
- package/src/shared/embedding/classes/null-embedding-provider.class.ts +29 -0
- package/src/shared/embedding/constants/near-duplicate-thresholds.constant.ts +17 -0
- package/src/shared/embedding/functions/build-vector-index.function.ts +79 -0
- package/src/shared/embedding/functions/cosine-similarity.function.ts +31 -0
- package/src/shared/embedding/functions/detect-near-duplicates.function.ts +69 -0
- package/src/shared/embedding/functions/jaccard-coefficient.function.ts +26 -0
- package/src/shared/embedding/functions/read-vector-index-meta.function.ts +44 -0
- package/src/shared/embedding/functions/rrf-fuse.function.ts +33 -0
- package/src/shared/embedding/functions/search-vectors.function.ts +59 -0
- package/src/shared/embedding/index.ts +20 -0
- package/src/shared/embedding/typings/embedding-config.interface.ts +23 -0
- package/src/shared/embedding/typings/embedding-provider.interface.ts +25 -0
- package/src/shared/embedding/typings/near-duplicate-candidate.model.ts +25 -0
- package/src/shared/embedding/typings/near-duplicate-result.model.ts +26 -0
- package/src/shared/embedding/typings/vector-index-entry.model.ts +13 -0
- package/src/shared/embedding/typings/vector-index-meta.model.ts +14 -0
- package/src/shared/embedding/typings/vector-search-result.model.ts +8 -0
- package/src/shared/mcp/classes/mcp-server.class.ts +6 -3
- package/src/shared/mcp/constants/tool-agent-create.constant.ts +39 -0
- package/src/shared/mcp/constants/tool-agent-delete.constant.ts +26 -0
- package/src/shared/mcp/constants/tool-agent-get.constant.ts +24 -0
- package/src/shared/mcp/constants/tool-agent-list.constant.ts +18 -0
- package/src/shared/mcp/constants/tool-auto-capture-review.constant.ts +32 -0
- package/src/shared/mcp/constants/tool-check.constant.ts +21 -0
- package/src/shared/mcp/constants/tool-content.constant.ts +29 -0
- package/src/shared/mcp/constants/tool-export.constant.ts +27 -0
- package/src/shared/mcp/constants/tool-gc.constant.ts +21 -0
- package/src/shared/mcp/constants/tool-learn.constant.ts +58 -0
- package/src/shared/mcp/constants/tool-rebuild.constant.ts +21 -0
- package/src/shared/mcp/constants/tool-recall.constant.ts +36 -0
- package/src/shared/mcp/constants/tool-retrieve.constant.ts +31 -0
- package/src/shared/mcp/constants/tool-search.constant.ts +51 -0
- package/src/shared/mcp/constants/tool-skill-delete.constant.ts +24 -0
- package/src/shared/mcp/constants/tool-skill-get.constant.ts +27 -0
- package/src/shared/mcp/constants/tool-skill-learn.constant.ts +37 -0
- package/src/shared/mcp/constants/tool-skill-list.constant.ts +18 -0
- package/src/shared/mcp/constants/tool-status.constant.ts +20 -0
- package/src/shared/mcp/constants/tool-unlearn.constant.ts +25 -0
- package/src/shared/mcp/functions/as-boolean-or-undefined.function.ts +11 -0
- package/src/shared/mcp/functions/as-string-array-or-undefined.function.ts +17 -0
- package/src/shared/mcp/functions/as-string-array.function.ts +15 -0
- package/src/shared/mcp/functions/as-string.function.ts +10 -0
- package/src/shared/mcp/functions/build-skills-text.function.ts +43 -0
- package/src/shared/mcp/functions/create-tool-definitions.function.ts +28 -0
- package/src/shared/mcp/functions/handle-agent-create.function.ts +1 -1
- package/src/shared/mcp/functions/handle-agent-prompt.function.ts +68 -0
- package/src/shared/mcp/functions/handle-mcp-request.function.ts +202 -0
- package/src/shared/mcp/functions/handle-prompt-get.function.ts +18 -12
- package/src/shared/mcp/functions/handle-skill-prompt.function.ts +44 -0
- package/src/shared/mcp/functions/handle-tool-auto-capture-review.function.ts +24 -0
- package/src/shared/mcp/functions/handle-tool-call.function.ts +18 -0
- package/src/shared/mcp/functions/handle-tool-check.function.ts +21 -0
- package/src/shared/mcp/functions/handle-tool-content.function.ts +23 -0
- package/src/shared/mcp/functions/handle-tool-export.function.ts +25 -0
- package/src/shared/mcp/functions/handle-tool-gc.function.ts +21 -0
- package/src/shared/mcp/functions/handle-tool-learn.function.ts +69 -0
- package/src/shared/mcp/functions/handle-tool-rebuild.function.ts +21 -0
- package/src/shared/mcp/functions/handle-tool-retrieve.function.ts +40 -0
- package/src/shared/mcp/functions/handle-tool-search.function.ts +47 -0
- package/src/shared/mcp/functions/handle-tool-skill-delete.function.ts +34 -0
- package/src/shared/mcp/functions/handle-tool-skill-get.function.ts +59 -0
- package/src/shared/mcp/functions/handle-tool-skill-learn.function.ts +61 -0
- package/src/shared/mcp/functions/handle-tool-skill-list.function.ts +39 -0
- package/src/shared/mcp/functions/handle-tool-status.function.ts +21 -0
- package/src/shared/mcp/functions/handle-tool-unlearn.function.ts +24 -0
- package/src/shared/mcp/functions/parse-agent-meta.function.ts +27 -0
- package/src/shared/mcp/functions/parse-skill-arguments.function.ts +36 -0
- package/src/shared/mcp/functions/read-agent-meta.function.ts +41 -0
- package/src/shared/mcp/functions/resolve-skill-refs.function.ts +50 -0
- package/src/shared/mcp/functions/run-startup-health-check.function.ts +34 -0
- package/src/shared/mcp/typings/mcp-capabilities.interface.ts +16 -0
- package/src/shared/mcp/typings/mcp-client.interface.ts +2 -0
- package/src/shared/mcp/typings/mcp-completion.interface.ts +45 -0
- package/src/shared/mcp/typings/mcp-content-result.model.ts +9 -0
- package/src/shared/mcp/typings/mcp-export-result.model.ts +11 -0
- package/src/shared/mcp/typings/mcp-gc-result.model.ts +15 -0
- package/src/shared/mcp/typings/mcp-integrity-check-result.model.ts +17 -0
- package/src/shared/mcp/typings/mcp-integrity-error.model.ts +15 -0
- package/src/shared/mcp/typings/mcp-notification.interface.ts +9 -0
- package/src/shared/mcp/typings/mcp-rebuild-result.model.ts +9 -0
- package/src/shared/mcp/typings/mcp-request.interface.ts +11 -0
- package/src/shared/mcp/typings/mcp-resource-result.interface.ts +12 -0
- package/src/shared/mcp/typings/mcp-resource-template.interface.ts +11 -0
- package/src/shared/mcp/typings/mcp-response.interface.ts +18 -0
- package/src/shared/mcp/typings/mcp-server-info.interface.ts +7 -0
- package/src/shared/mcp/typings/mcp-server-state.interface.ts +17 -0
- package/src/shared/mcp/typings/mcp-tool-annotations.interface.ts +32 -0
- package/src/shared/mcp/typings/mcp-tool-definition.interface.ts +16 -0
- package/src/shared/mcp/typings/mcp-tool-result.interface.ts +19 -0
- package/src/shared/mcp/typings/mcp-worker-client.interface.ts +243 -0
- package/src/shared/mcp/typings/tool-call-result.model.ts +18 -0
- package/src/shared/sync/functions/build-import-report.function.ts +40 -0
- package/src/shared/sync/functions/parse-export-entry.function.ts +45 -0
- package/src/shared/sync/functions/resolve-conflict.function.ts +31 -0
- package/src/shared/sync/functions/serialize-export-entry.function.ts +18 -0
- package/src/shared/sync/index.ts +9 -0
- package/src/shared/sync/typings/conflict-resolution.type.ts +8 -0
- package/src/shared/sync/typings/export-entry.interface.ts +13 -0
- package/src/shared/sync/typings/export-options.interface.ts +9 -0
- package/src/shared/sync/typings/import-options.interface.ts +7 -0
- package/src/shared/sync/typings/import-report.interface.ts +15 -0
- package/src/shared/wasm-codec/functions/decode-one-recall-result.function.ts +86 -0
- package/src/shared/wasm-codec/functions/decode-option-string.function.ts +24 -0
- package/src/shared/wasm-codec/functions/decode-recall-document.function.ts +59 -0
- package/src/shared/wasm-codec/functions/decode-recall-reference.function.ts +52 -0
- package/src/shared/wasm-codec/functions/decode-recall-sibling.function.ts +43 -0
- package/src/shared/wasm-codec/functions/decode-section-match.function.ts +80 -0
- package/src/shared/wasm-codec/functions/decode-section-record-trailing.function.ts +75 -0
- package/src/shared/wasm-codec/functions/decode-section-record.function.ts +85 -0
- package/src/shared/wasm-codec/functions/decode-section-type.function.ts +30 -0
- package/src/shared/wasm-codec/functions/decode-wasm-list.function.ts +31 -0
- package/src/shared/wasm-codec/typings/add-section-input.model.ts +45 -0
- package/src/shared/wasm-codec/typings/add-section-result.model.ts +28 -0
- package/src/shared/wasm-codec/typings/document-manifest.model.ts +20 -0
- package/src/shared/wasm-codec/typings/document-section.model.ts +12 -0
- package/src/shared/wasm-codec/typings/item-decoder.type.ts +10 -0
- package/src/shared/wasm-codec/typings/near-duplicate.model.ts +16 -0
- package/src/shared/wasm-codec/typings/paged-search-result.model.ts +22 -0
- package/src/shared/wasm-codec/typings/section-match.model.ts +31 -0
- package/src/shared/wasm-codec/typings/section-record-trailing.model.ts +38 -0
- package/src/shared/wasm-codec/typings/section-record.model.ts +66 -0
- package/src/shared/wasm-codec/typings/section-type-result.model.ts +12 -0
- package/src/shared/worker-client/functions/handle-ipc-data.function.ts +49 -0
- package/src/shared/worker-client/functions/send-ipc-request.function.ts +39 -0
- package/src/shared/worker-client/typings/add-section-result.model.ts +2 -0
- package/src/shared/worker-client/typings/json-rpc-response.interface.ts +17 -0
- package/src/shared/worker-client/typings/pending-call.interface.ts +7 -0
- package/src/shared/worker-client/typings/recall-document.model.ts +16 -0
- package/src/shared/worker-client/typings/recall-params.model.ts +15 -0
- package/src/shared/worker-client/typings/recall-reference.model.ts +32 -0
- package/src/shared/worker-client/typings/recall-sibling.model.ts +11 -0
- package/src/shared/worker-client/typings/recall-single-result.model.ts +41 -0
- package/src/shared/worker-daemon/classes/ipc-error.class.ts +22 -0
- package/src/shared/worker-daemon/constants/wasm-method-map.constant.ts +69 -0
- package/src/shared/worker-daemon/functions/build-ipc-error-response.function.ts +16 -0
- package/src/shared/worker-daemon/functions/check-catalog-version.function.ts +54 -0
- package/src/shared/worker-daemon/functions/check-preconditions.function.ts +28 -0
- package/src/shared/worker-daemon/functions/detect-stale-pid.function.ts +33 -0
- package/src/shared/worker-daemon/functions/dispatch-request.function.ts +190 -0
- package/src/shared/worker-daemon/functions/handle-check-version.function.ts +74 -0
- package/src/shared/worker-daemon/functions/handle-config-method.function.ts +27 -0
- package/src/shared/worker-daemon/functions/handle-read-ops.function.ts +236 -0
- package/src/shared/worker-daemon/functions/handle-write-ops.function.ts +257 -0
- package/src/shared/worker-daemon/functions/parse-auto-capture-section.function.ts +51 -0
- package/src/shared/worker-daemon/functions/parse-catalog-version.function.ts +20 -0
- package/src/shared/worker-daemon/functions/parse-embedding-section.function.ts +38 -0
- package/src/shared/worker-daemon/functions/parse-worker-toml.function.ts +104 -0
- package/src/shared/worker-daemon/functions/run-startup-integrity-check.function.ts +55 -0
- package/src/shared/worker-daemon/functions/scan-near-duplicates.function.ts +92 -0
- package/src/shared/worker-daemon/functions/wasm-bridge.function.ts +144 -0
- package/src/shared/worker-daemon/functions/wasm-memory-helpers.function.ts +41 -0
- package/src/shared/worker-daemon/functions/write-lock.function.ts +49 -0
- package/src/shared/worker-daemon/typings/allocator-ref.interface.ts +16 -0
- package/src/shared/worker-daemon/typings/daemon-config.interface.ts +7 -0
- package/src/shared/worker-daemon/typings/fs-adapter.interface.ts +22 -0
- package/src/shared/worker-daemon/typings/handler-context.interface.ts +19 -0
- package/src/shared/worker-daemon/typings/memory-ref.interface.ts +13 -0
- package/src/shared/worker-daemon/typings/wasm-fn.type.ts +2 -0
- package/src/shared/worker-daemon/typings/write-lock.interface.ts +13 -0
- package/src/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/src/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
|
@@ -105,6 +105,8 @@ export interface McpWorkerClient {
|
|
|
105
105
|
readonly limit?: number;
|
|
106
106
|
/** Number of results to skip for pagination. */
|
|
107
107
|
readonly offset?: number;
|
|
108
|
+
/** Search algorithm: 'lexical', 'vector', or 'hybrid'. */
|
|
109
|
+
readonly algo?: string;
|
|
108
110
|
}): Promise<{
|
|
109
111
|
readonly items: readonly {
|
|
110
112
|
readonly kbid: string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discriminated reference used in MCP completion requests.
|
|
3
|
+
* Identifies whether the completion target is a prompt or a resource.
|
|
4
|
+
*/
|
|
5
|
+
export interface McpCompletionRef {
|
|
6
|
+
/**
|
|
7
|
+
* The reference type: `'ref/prompt'` for named prompts (skills
|
|
8
|
+
* and agents) or `'ref/resource'` for resource URIs.
|
|
9
|
+
*/
|
|
10
|
+
readonly type: 'ref/prompt' | 'ref/resource';
|
|
11
|
+
/** Prompt name, present when `type` is `'ref/prompt'`. */
|
|
12
|
+
readonly name?: string;
|
|
13
|
+
/** Resource URI, present when `type` is `'ref/resource'`. */
|
|
14
|
+
readonly uri?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Completion argument supplied by the client, describing which
|
|
19
|
+
* argument is being completed and the current partial value.
|
|
20
|
+
*/
|
|
21
|
+
export interface McpCompletionArgument {
|
|
22
|
+
/** The argument name being completed. */
|
|
23
|
+
readonly name: string;
|
|
24
|
+
/** The partial value typed so far; used for prefix filtering. */
|
|
25
|
+
readonly value: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Result returned by `handleCompletion`, containing the list of
|
|
30
|
+
* matching completion values and pagination metadata.
|
|
31
|
+
*/
|
|
32
|
+
export interface McpCompletionResult {
|
|
33
|
+
/** Completion payload. */
|
|
34
|
+
readonly completion: {
|
|
35
|
+
/** Matching completion strings for the given prefix. */
|
|
36
|
+
readonly values: string[];
|
|
37
|
+
/**
|
|
38
|
+
* Whether more results are available beyond what is returned.
|
|
39
|
+
* Always `false` in this implementation.
|
|
40
|
+
*/
|
|
41
|
+
readonly hasMore: boolean;
|
|
42
|
+
/** Total number of values returned. */
|
|
43
|
+
readonly total: number;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Result returned by content composition. */
|
|
2
|
+
export interface McpContentResult {
|
|
3
|
+
/** MIME type of the composed output, always `'text/markdown'`. */
|
|
4
|
+
readonly type: 'text/markdown';
|
|
5
|
+
/** The composed Markdown string. */
|
|
6
|
+
readonly data: string;
|
|
7
|
+
/** Character count of `data` (not byte count). */
|
|
8
|
+
readonly total: number;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Export report returned by the daemon. */
|
|
2
|
+
export interface McpExportResult {
|
|
3
|
+
/** Absolute path to the directory where files were written. */
|
|
4
|
+
readonly path: string;
|
|
5
|
+
/** Number of section files copied to the export directory. */
|
|
6
|
+
readonly sections_exported: number;
|
|
7
|
+
/** Number of document manifest files copied. */
|
|
8
|
+
readonly documents_exported: number;
|
|
9
|
+
/** Time taken to complete the export, in milliseconds. */
|
|
10
|
+
readonly elapsed_ms: number;
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Garbage collection report returned by the daemon. */
|
|
2
|
+
export interface McpGcResult {
|
|
3
|
+
/** Number of unreferenced sections removed. */
|
|
4
|
+
readonly removed_sections: number;
|
|
5
|
+
/** Total bytes freed by removing unreferenced sections. */
|
|
6
|
+
readonly removed_bytes: number;
|
|
7
|
+
/** Time taken to complete garbage collection, in milliseconds. */
|
|
8
|
+
readonly elapsed_ms: number;
|
|
9
|
+
/**
|
|
10
|
+
* Number of sections whose source_path file no longer contains
|
|
11
|
+
* their heading text. Advisory; not auto-removed by gc.
|
|
12
|
+
* Absent on older daemon versions.
|
|
13
|
+
*/
|
|
14
|
+
readonly stale_sources?: number;
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { McpIntegrityError } from './mcp-integrity-error.model.ts';
|
|
2
|
+
|
|
3
|
+
/** Integrity check report returned by the daemon. */
|
|
4
|
+
export interface McpIntegrityCheckResult {
|
|
5
|
+
/** `true` when all checks passed and no errors were found. */
|
|
6
|
+
readonly ok: boolean;
|
|
7
|
+
/** All integrity errors found; empty when `ok` is `true`. */
|
|
8
|
+
readonly errors: McpIntegrityError[];
|
|
9
|
+
/** Total number of sections examined. */
|
|
10
|
+
readonly sections_checked: number;
|
|
11
|
+
/** Total number of documents examined. */
|
|
12
|
+
readonly documents_checked: number;
|
|
13
|
+
/** Total number of marker references checked. */
|
|
14
|
+
readonly references_checked: number;
|
|
15
|
+
/** Time taken to complete the check, in milliseconds. */
|
|
16
|
+
readonly elapsed_ms: number;
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** A single integrity error found during a database check. */
|
|
2
|
+
export interface McpIntegrityError {
|
|
3
|
+
/** The category of integrity violation detected. */
|
|
4
|
+
readonly type:
|
|
5
|
+
| 'checksum_mismatch'
|
|
6
|
+
| 'orphan_section'
|
|
7
|
+
| 'orphan_document'
|
|
8
|
+
| 'broken_reference'
|
|
9
|
+
| 'type_mismatch'
|
|
10
|
+
| 'circular_reference';
|
|
11
|
+
/** Identifier of the entity (kbid or docid) that has the issue. */
|
|
12
|
+
readonly entity: string;
|
|
13
|
+
/** Human-readable description of the specific problem. */
|
|
14
|
+
readonly detail: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A JSON-RPC 2.0 notification with no expected response. */
|
|
2
|
+
export interface McpNotification {
|
|
3
|
+
/** JSON-RPC protocol version. Must always be '2.0'. */
|
|
4
|
+
readonly jsonrpc: '2.0';
|
|
5
|
+
/** Notification method name. */
|
|
6
|
+
readonly method: string;
|
|
7
|
+
/** Optional notification parameters. */
|
|
8
|
+
readonly params?: Record<string, unknown>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Index rebuild report returned by the daemon. */
|
|
2
|
+
export interface McpRebuildResult {
|
|
3
|
+
/** Number of text and code sections that were re-indexed. */
|
|
4
|
+
readonly sections_reindexed: number;
|
|
5
|
+
/** Total number of unique terms written to the rebuilt indexes. */
|
|
6
|
+
readonly terms_indexed: number;
|
|
7
|
+
/** Time taken to complete the rebuild, in milliseconds. */
|
|
8
|
+
readonly elapsed_ms: number;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** A JSON-RPC 2.0 request message sent to the MCP server. */
|
|
2
|
+
export interface McpRequest {
|
|
3
|
+
/** JSON-RPC protocol version. Must always be '2.0'. */
|
|
4
|
+
readonly jsonrpc: '2.0';
|
|
5
|
+
/** Request identifier; absent for notifications. */
|
|
6
|
+
readonly id?: number | string;
|
|
7
|
+
/** RPC method name. */
|
|
8
|
+
readonly method: string;
|
|
9
|
+
/** Optional method parameters. */
|
|
10
|
+
readonly params?: Record<string, unknown>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Result returned by `handleResourceRead`. */
|
|
2
|
+
export interface McpResourceResult {
|
|
3
|
+
/** One or more content items for the requested resource URI. */
|
|
4
|
+
readonly contents: readonly {
|
|
5
|
+
/** The resource URI that was read. */
|
|
6
|
+
readonly uri: string;
|
|
7
|
+
/** MIME type of the content body. */
|
|
8
|
+
readonly mimeType: string;
|
|
9
|
+
/** Text body of the resource. */
|
|
10
|
+
readonly text: string;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** A URI template describing an MCP resource the server serves. */
|
|
2
|
+
export interface McpResourceTemplate {
|
|
3
|
+
/** RFC 6570 URI template for the resource. */
|
|
4
|
+
readonly uriTemplate: string;
|
|
5
|
+
/** Human-readable resource name. */
|
|
6
|
+
readonly name: string;
|
|
7
|
+
/** Human-readable description of the resource. */
|
|
8
|
+
readonly description: string;
|
|
9
|
+
/** Optional MIME type for the resource content. */
|
|
10
|
+
readonly mimeType?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** A JSON-RPC 2.0 response message sent from the MCP server. */
|
|
2
|
+
export interface McpResponse {
|
|
3
|
+
/** JSON-RPC protocol version. Must always be '2.0'. */
|
|
4
|
+
readonly jsonrpc: '2.0';
|
|
5
|
+
/** Echoes the request identifier. */
|
|
6
|
+
readonly id: number | string;
|
|
7
|
+
/** Successful result payload; absent when error is set. */
|
|
8
|
+
readonly result?: unknown;
|
|
9
|
+
/** Error payload; absent when result is set. */
|
|
10
|
+
readonly error?: {
|
|
11
|
+
/** Numeric error code as defined by JSON-RPC or MCP. */
|
|
12
|
+
readonly code: number;
|
|
13
|
+
/** Human-readable error message. */
|
|
14
|
+
readonly message: string;
|
|
15
|
+
/** Optional additional error data. */
|
|
16
|
+
readonly data?: unknown;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { McpLogLevel } from './log-types.interface.ts';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Mutable runtime state shared by `McpServer` and its request
|
|
5
|
+
* handler. Extracted as an interface so the handler can be
|
|
6
|
+
* tested independently of the full server class.
|
|
7
|
+
*/
|
|
8
|
+
export interface McpServerState {
|
|
9
|
+
/** Advertised capabilities received from the MCP host. */
|
|
10
|
+
hostCapabilities: Record<string, unknown> | null;
|
|
11
|
+
/** Currently configured log level, or `null` when unset. */
|
|
12
|
+
logLevel: McpLogLevel | null;
|
|
13
|
+
/** Set of URI strings that the host has subscribed to. */
|
|
14
|
+
readonly subscriptions: Set<string>;
|
|
15
|
+
/** Filesystem path used as the KB context root. */
|
|
16
|
+
readonly contextPath: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional behavioral hints for an MCP tool, used by clients to
|
|
3
|
+
* decide how to present or invoke the tool safely.
|
|
4
|
+
*/
|
|
5
|
+
export interface McpToolAnnotations {
|
|
6
|
+
/**
|
|
7
|
+
* Human-readable title for the tool, suitable for display
|
|
8
|
+
* in client UIs.
|
|
9
|
+
*/
|
|
10
|
+
readonly title?: string;
|
|
11
|
+
/**
|
|
12
|
+
* When `true`, the tool only reads data and does not modify
|
|
13
|
+
* any server-side state.
|
|
14
|
+
*/
|
|
15
|
+
readonly readOnlyHint?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* When `true`, the tool may cause data loss or irreversible
|
|
18
|
+
* changes.
|
|
19
|
+
*/
|
|
20
|
+
readonly destructiveHint?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* When `true`, calling the tool multiple times with the same
|
|
23
|
+
* arguments produces the same result with no additional side
|
|
24
|
+
* effects.
|
|
25
|
+
*/
|
|
26
|
+
readonly idempotentHint?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* When `true`, the tool may interact with systems or data
|
|
29
|
+
* outside the immediate knowledge base context.
|
|
30
|
+
*/
|
|
31
|
+
readonly openWorldHint?: boolean;
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { McpToolAnnotations } from './mcp-tool-annotations.interface.ts';
|
|
2
|
+
|
|
3
|
+
/** Definition of a single MCP tool exposed by the server. */
|
|
4
|
+
export interface McpToolDefinition {
|
|
5
|
+
/** Unique tool name used to invoke it. */
|
|
6
|
+
readonly name: string;
|
|
7
|
+
/** Human-readable description of what the tool does. */
|
|
8
|
+
readonly description: string;
|
|
9
|
+
/** JSON Schema object describing the tool's input parameters. */
|
|
10
|
+
readonly inputSchema: Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Optional behavioral hints that describe how the tool
|
|
13
|
+
* interacts with state.
|
|
14
|
+
*/
|
|
15
|
+
readonly annotations?: McpToolAnnotations;
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result returned by `handleToolCall`. Successful tool responses
|
|
3
|
+
* carry `isError: true` for application-level failures rather than
|
|
4
|
+
* using JSON-RPC error responses.
|
|
5
|
+
*/
|
|
6
|
+
export interface McpToolResult {
|
|
7
|
+
/** One or more text content items describing the result. */
|
|
8
|
+
readonly content: readonly {
|
|
9
|
+
/** Content type identifier, always 'text'. */
|
|
10
|
+
readonly type: string;
|
|
11
|
+
/** Text payload of the content item. */
|
|
12
|
+
readonly text: string;
|
|
13
|
+
}[];
|
|
14
|
+
/**
|
|
15
|
+
* Set to `true` when the tool encountered an application-level
|
|
16
|
+
* error. Absent or `false` on success.
|
|
17
|
+
*/
|
|
18
|
+
readonly isError?: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import type { AddSectionResult } from '../../worker-client/typings/add-section-result.model.ts';
|
|
2
|
+
import type { RemoveSectionResult } from './remove-section-result.model.ts';
|
|
3
|
+
import type { SectionRecord } from '../../wasm-codec/functions/decode-section-records.function.ts';
|
|
4
|
+
import type { DocumentManifest } from '../../wasm-codec/functions/decode-document-manifest.function.ts';
|
|
5
|
+
import type { McpContentResult } from './mcp-content-result.model.ts';
|
|
6
|
+
import type { McpIntegrityCheckResult } from './mcp-integrity-check-result.model.ts';
|
|
7
|
+
import type { McpGcResult } from './mcp-gc-result.model.ts';
|
|
8
|
+
import type { McpRebuildResult } from './mcp-rebuild-result.model.ts';
|
|
9
|
+
import type { McpExportResult } from './mcp-export-result.model.ts';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Interface for the worker client dependency consumed by the MCP
|
|
13
|
+
* server. Defines the knowledge-base operations the server exposes
|
|
14
|
+
* as MCP tools and resources without coupling to the concrete
|
|
15
|
+
* `WorkerClient` class.
|
|
16
|
+
*/
|
|
17
|
+
export interface McpWorkerClient {
|
|
18
|
+
/**
|
|
19
|
+
* Searches the knowledge base using the given parameters.
|
|
20
|
+
*
|
|
21
|
+
* @param params - query string and optional search options
|
|
22
|
+
* @returns ranked list of matching section summaries
|
|
23
|
+
*/
|
|
24
|
+
search(params: {
|
|
25
|
+
/** Natural language query text. */
|
|
26
|
+
readonly query: string;
|
|
27
|
+
/** Search mode: 'sections', 'documents', or 'stats'. */
|
|
28
|
+
readonly mode?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Search algorithm: `'lexical'`, `'vector'`, or `'hybrid'`.
|
|
31
|
+
* Defaults to `'lexical'` when omitted.
|
|
32
|
+
*/
|
|
33
|
+
readonly algo?: string;
|
|
34
|
+
/** Maximum number of results to return. */
|
|
35
|
+
readonly limit?: number;
|
|
36
|
+
/** Number of results to skip for pagination. */
|
|
37
|
+
readonly offset?: number;
|
|
38
|
+
}): Promise<{
|
|
39
|
+
readonly items: readonly {
|
|
40
|
+
readonly kbid: string;
|
|
41
|
+
readonly heading: string | null;
|
|
42
|
+
readonly type: string;
|
|
43
|
+
readonly docids: readonly string[];
|
|
44
|
+
readonly score: number;
|
|
45
|
+
readonly snippet: string;
|
|
46
|
+
readonly matched_terms: readonly string[];
|
|
47
|
+
/** Fields that contained matches (heading, body, code). */
|
|
48
|
+
readonly matched_fields?: readonly string[];
|
|
49
|
+
/** ISO 8601 creation timestamp of the section. */
|
|
50
|
+
readonly created_at?: string;
|
|
51
|
+
}[];
|
|
52
|
+
readonly total: number;
|
|
53
|
+
readonly offset: number;
|
|
54
|
+
readonly limit: number;
|
|
55
|
+
readonly has_more: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* `true` when results came from an automatic AND-to-OR
|
|
58
|
+
* fallback query relaxation.
|
|
59
|
+
*/
|
|
60
|
+
readonly relaxed?: boolean;
|
|
61
|
+
}>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Adds a new section to the knowledge base.
|
|
65
|
+
*
|
|
66
|
+
* @param params - content type, raw content, and optional metadata
|
|
67
|
+
* @returns the assigned knowledge-base identifier
|
|
68
|
+
*/
|
|
69
|
+
addSection(params: {
|
|
70
|
+
/** Semantic type label for the section content. */
|
|
71
|
+
readonly sectionType: string;
|
|
72
|
+
/** Raw text or base64-encoded content for the section. */
|
|
73
|
+
readonly content: string;
|
|
74
|
+
/** Optional section title. Required for image/* types. */
|
|
75
|
+
readonly title?: string;
|
|
76
|
+
/** Optional section description. */
|
|
77
|
+
readonly description?: string;
|
|
78
|
+
/** Optional document ID to group this section under. */
|
|
79
|
+
readonly docid?: string;
|
|
80
|
+
/** Optional tags for scoping and filtering. */
|
|
81
|
+
readonly tags?: string[];
|
|
82
|
+
/**
|
|
83
|
+
* When `true`, replaces an existing section that has the same
|
|
84
|
+
* source key (supersession).
|
|
85
|
+
*/
|
|
86
|
+
readonly replace?: boolean;
|
|
87
|
+
}): Promise<AddSectionResult>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Removes a section from the knowledge base.
|
|
91
|
+
*
|
|
92
|
+
* @param kbid - knowledge-base identifier of the section to remove
|
|
93
|
+
* @returns removal result with `removed` flag and elapsed time
|
|
94
|
+
*/
|
|
95
|
+
removeSection(kbid: string): Promise<RemoveSectionResult>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Retrieves one or more sections by their identifiers.
|
|
99
|
+
*
|
|
100
|
+
* @param kbids - list of knowledge-base identifiers to fetch
|
|
101
|
+
* @returns sections in the order their IDs were requested
|
|
102
|
+
*/
|
|
103
|
+
readSections(kbids: string[]): Promise<
|
|
104
|
+
{
|
|
105
|
+
/** Knowledge-base identifier for this section. */
|
|
106
|
+
kbid: string;
|
|
107
|
+
/** Semantic type label assigned to the section. */
|
|
108
|
+
sectionType: string;
|
|
109
|
+
/** Raw text content of the section. */
|
|
110
|
+
content: string;
|
|
111
|
+
/** Byte size of the stored content. */
|
|
112
|
+
size: number;
|
|
113
|
+
}[]
|
|
114
|
+
>;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Retrieves a full document record including its ordered sections.
|
|
118
|
+
*
|
|
119
|
+
* @param docid - identifier of the document to retrieve
|
|
120
|
+
* @returns the document record as returned by the daemon
|
|
121
|
+
*/
|
|
122
|
+
retrieveDocument(docid: string): Promise<unknown>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Composes a rendered Markdown document from one or more kbid
|
|
126
|
+
* or docid identifiers.
|
|
127
|
+
*
|
|
128
|
+
* @param ids - list of kbid or docid identifiers (may be mixed)
|
|
129
|
+
* @returns composed Markdown result with character count
|
|
130
|
+
*/
|
|
131
|
+
content(ids: string[]): Promise<McpContentResult>;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Returns database metadata and status from the daemon.
|
|
135
|
+
*
|
|
136
|
+
* @returns document count, section count, and timing statistics
|
|
137
|
+
*/
|
|
138
|
+
dbStatus(): Promise<{
|
|
139
|
+
/** Whether the daemon has finished loading its WASM modules. */
|
|
140
|
+
initialized: boolean;
|
|
141
|
+
/** Absolute path to the context directory the daemon serves. */
|
|
142
|
+
contextPath: string;
|
|
143
|
+
/** In-memory cache statistics. */
|
|
144
|
+
cacheStats: {
|
|
145
|
+
/** Number of content entries currently cached. */
|
|
146
|
+
contentCount: number;
|
|
147
|
+
/** Number of index entries currently cached. */
|
|
148
|
+
indexCount: number;
|
|
149
|
+
};
|
|
150
|
+
}>;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Runs an integrity check on the knowledge-base database.
|
|
154
|
+
*
|
|
155
|
+
* @returns a report of all issues found; `ok` is `true` when
|
|
156
|
+
* no errors were detected
|
|
157
|
+
*/
|
|
158
|
+
integrityCheck(): Promise<McpIntegrityCheckResult>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Removes unreferenced sections from the database.
|
|
162
|
+
*
|
|
163
|
+
* @returns a report of sections removed and bytes freed
|
|
164
|
+
*/
|
|
165
|
+
gc(): Promise<McpGcResult>;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Reconstructs all index files from section files and document
|
|
169
|
+
* manifests on disk.
|
|
170
|
+
*
|
|
171
|
+
* @returns a report of sections and terms re-indexed
|
|
172
|
+
*/
|
|
173
|
+
rebuildIndexes(): Promise<McpRebuildResult>;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Retrieves all sections whose type name matches the given string.
|
|
177
|
+
*
|
|
178
|
+
* @param sectionType - the application-level type name to filter by
|
|
179
|
+
* @returns all section records with a matching type name
|
|
180
|
+
*/
|
|
181
|
+
listByType(sectionType: string): Promise<SectionRecord[]>;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Retrieves all documents whose type name matches the given string.
|
|
185
|
+
*
|
|
186
|
+
* @param docType - the application-level document type to filter by
|
|
187
|
+
* @returns all document manifests with a matching type name
|
|
188
|
+
*/
|
|
189
|
+
listDocumentsByType(docType: string): Promise<DocumentManifest[]>;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Groups a set of sections under a named document.
|
|
193
|
+
*
|
|
194
|
+
* @param title - human-readable document title
|
|
195
|
+
* @param kbids - identifiers of the sections to group
|
|
196
|
+
* @returns the assigned document identifier
|
|
197
|
+
*/
|
|
198
|
+
groupSections(
|
|
199
|
+
title: string,
|
|
200
|
+
kbids: string[],
|
|
201
|
+
docType?: string,
|
|
202
|
+
): Promise<string>;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Removes the document grouping for the given document.
|
|
206
|
+
*
|
|
207
|
+
* The sections themselves are not deleted; only the grouping
|
|
208
|
+
* record is removed.
|
|
209
|
+
*
|
|
210
|
+
* @param docid - identifier of the document grouping to remove
|
|
211
|
+
*/
|
|
212
|
+
removeGrouping(docid: string): Promise<void>;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Retrieves full content and context for one or more sections by
|
|
216
|
+
* their knowledge-base identifiers.
|
|
217
|
+
*
|
|
218
|
+
* @param params - section identifier(s) and optional expansion depth
|
|
219
|
+
* @returns a single result or array of results depending on input
|
|
220
|
+
*/
|
|
221
|
+
recall(params: {
|
|
222
|
+
/** Single section identifier. */
|
|
223
|
+
readonly kbid?: string;
|
|
224
|
+
/** Batch section identifiers. */
|
|
225
|
+
readonly kbids?: readonly string[];
|
|
226
|
+
/** Expansion depth (0-3, default: 0). */
|
|
227
|
+
readonly depth?: number;
|
|
228
|
+
}): Promise<unknown>;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Exports the database to a target directory as a self-contained
|
|
232
|
+
* snapshot (sections, documents, catalog -- no indexes).
|
|
233
|
+
*
|
|
234
|
+
* @param params - optional export parameters
|
|
235
|
+
* @returns export report with the resolved path and file counts
|
|
236
|
+
*/
|
|
237
|
+
export(params?: {
|
|
238
|
+
readonly path?: string;
|
|
239
|
+
}): Promise<McpExportResult>;
|
|
240
|
+
|
|
241
|
+
/** Destroys the IPC socket and clears the connection state. */
|
|
242
|
+
disconnect(): void;
|
|
243
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Shape of a content item in an MCP tool call response. */
|
|
2
|
+
export interface ToolContent {
|
|
3
|
+
/** Content type identifier, typically `'text'`. */
|
|
4
|
+
readonly type: string;
|
|
5
|
+
/** The text payload. */
|
|
6
|
+
readonly text: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Result returned by any MCP tool call handler, containing one or
|
|
11
|
+
* more content items and an optional error flag.
|
|
12
|
+
*/
|
|
13
|
+
export interface ToolCallResult {
|
|
14
|
+
/** One or more content items describing the result. */
|
|
15
|
+
readonly content: ToolContent[];
|
|
16
|
+
/** Set to `true` when the tool encountered an error. */
|
|
17
|
+
readonly isError?: boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ConflictResolution } from '../typings/conflict-resolution.type.ts';
|
|
2
|
+
import type { ExportEntry } from '../typings/export-entry.interface.ts';
|
|
3
|
+
import type { ImportReport } from '../typings/import-report.interface.ts';
|
|
4
|
+
|
|
5
|
+
/** A resolution record pairing an entry with its resolution. */
|
|
6
|
+
interface ResolutionRecord {
|
|
7
|
+
/** The export entry being resolved. */
|
|
8
|
+
readonly entry: ExportEntry;
|
|
9
|
+
/** The resolution applied to the entry. */
|
|
10
|
+
readonly resolution: ConflictResolution;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Builds an import report from resolution results.
|
|
15
|
+
*
|
|
16
|
+
* Counts each resolution type and determines whether
|
|
17
|
+
* a database rebuild is required after the import.
|
|
18
|
+
*/
|
|
19
|
+
export function buildImportReport(
|
|
20
|
+
resolutions: readonly ResolutionRecord[],
|
|
21
|
+
): ImportReport {
|
|
22
|
+
let sectionsAdded = 0;
|
|
23
|
+
let sectionsSkipped = 0;
|
|
24
|
+
let sectionsSuperseded = 0;
|
|
25
|
+
|
|
26
|
+
for (const { resolution } of resolutions) {
|
|
27
|
+
if (resolution === 'add') sectionsAdded++;
|
|
28
|
+
else if (resolution === 'skip') sectionsSkipped++;
|
|
29
|
+
else sectionsSuperseded++;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
sectionsAdded,
|
|
34
|
+
sectionsSkipped,
|
|
35
|
+
sectionsSuperseded,
|
|
36
|
+
documentsAdded: sectionsAdded,
|
|
37
|
+
documentsSkipped: sectionsSkipped,
|
|
38
|
+
rebuildRequired: sectionsAdded > 0 || sectionsSuperseded > 0,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ExportEntry } from '../typings/export-entry.interface.ts';
|
|
2
|
+
|
|
3
|
+
/** Extracts a quoted string value for a TOML key. */
|
|
4
|
+
function extractField(lines: string[], key: string): string {
|
|
5
|
+
for (const line of lines) {
|
|
6
|
+
const prefix = `${key} = "`;
|
|
7
|
+
if (line.startsWith(prefix) && line.endsWith('"')) {
|
|
8
|
+
return line.slice(prefix.length, -1);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
throw new Error(`Missing required field: ${key}`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Parses a serialized export entry.
|
|
16
|
+
*
|
|
17
|
+
* Expects TOML frontmatter delimited by `+++` lines,
|
|
18
|
+
* followed by the body content.
|
|
19
|
+
*
|
|
20
|
+
* @throws {Error} if the frontmatter delimiters are absent
|
|
21
|
+
* or required fields are missing.
|
|
22
|
+
*/
|
|
23
|
+
export function parseExportEntry(content: string): ExportEntry {
|
|
24
|
+
const firstDelim = content.indexOf('+++');
|
|
25
|
+
if (firstDelim === -1) {
|
|
26
|
+
throw new Error('Missing opening +++ delimiter');
|
|
27
|
+
}
|
|
28
|
+
const afterFirst = firstDelim + 3;
|
|
29
|
+
const secondDelim = content.indexOf('+++', afterFirst);
|
|
30
|
+
if (secondDelim === -1) {
|
|
31
|
+
throw new Error('Missing closing +++ delimiter');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const frontmatter = content.slice(afterFirst, secondDelim).trim();
|
|
35
|
+
const body = content.slice(secondDelim + 3).replace(/^\n/, '');
|
|
36
|
+
const lines = frontmatter.split('\n');
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
kbid: extractField(lines, 'kbid'),
|
|
40
|
+
sourceKey: extractField(lines, 'sourceKey'),
|
|
41
|
+
heading: extractField(lines, 'heading'),
|
|
42
|
+
createdAt: extractField(lines, 'createdAt'),
|
|
43
|
+
body,
|
|
44
|
+
};
|
|
45
|
+
}
|