@dikolab/kbdb 0.3.0 → 0.3.2
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 +89 -120
- 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/cli.md +9 -0
- package/docs/details/mcp-server.md +5 -3
- package/docs/details/search-and-ranking.md +55 -0
- 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 +171 -167
- 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 +121 -0
- package/docs/release-notes/0.3.2.md +64 -0
- package/docs/release-notes/README.md +3 -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
|
@@ -0,0 +1,220 @@
|
|
|
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
|
+
* Interface for the worker client dependency consumed by the MCP
|
|
12
|
+
* server. Defines the knowledge-base operations the server exposes
|
|
13
|
+
* as MCP tools and resources without coupling to the concrete
|
|
14
|
+
* `WorkerClient` class.
|
|
15
|
+
*/
|
|
16
|
+
export interface McpWorkerClient {
|
|
17
|
+
/**
|
|
18
|
+
* Searches the knowledge base using the given parameters.
|
|
19
|
+
*
|
|
20
|
+
* @param params - query string and optional search options
|
|
21
|
+
* @returns ranked list of matching section summaries
|
|
22
|
+
*/
|
|
23
|
+
search(params: {
|
|
24
|
+
/** Natural language query text. */
|
|
25
|
+
readonly query: string;
|
|
26
|
+
/** Search mode: 'sections', 'documents', or 'stats'. */
|
|
27
|
+
readonly mode?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Search algorithm: `'lexical'`, `'vector'`, or `'hybrid'`.
|
|
30
|
+
* Defaults to `'lexical'` when omitted.
|
|
31
|
+
*/
|
|
32
|
+
readonly algo?: string;
|
|
33
|
+
/** Maximum number of results to return. */
|
|
34
|
+
readonly limit?: number;
|
|
35
|
+
/** Number of results to skip for pagination. */
|
|
36
|
+
readonly offset?: number;
|
|
37
|
+
}): Promise<{
|
|
38
|
+
readonly items: readonly {
|
|
39
|
+
readonly kbid: string;
|
|
40
|
+
readonly heading: string | null;
|
|
41
|
+
readonly type: string;
|
|
42
|
+
readonly docids: readonly string[];
|
|
43
|
+
readonly score: number;
|
|
44
|
+
readonly snippet: string;
|
|
45
|
+
readonly matched_terms: readonly string[];
|
|
46
|
+
/** Fields that contained matches (heading, body, code). */
|
|
47
|
+
readonly matched_fields?: readonly string[];
|
|
48
|
+
/** ISO 8601 creation timestamp of the section. */
|
|
49
|
+
readonly created_at?: string;
|
|
50
|
+
}[];
|
|
51
|
+
readonly total: number;
|
|
52
|
+
readonly offset: number;
|
|
53
|
+
readonly limit: number;
|
|
54
|
+
readonly has_more: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* `true` when results came from an automatic AND-to-OR
|
|
57
|
+
* fallback query relaxation.
|
|
58
|
+
*/
|
|
59
|
+
readonly relaxed?: boolean;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Adds a new section to the knowledge base.
|
|
63
|
+
*
|
|
64
|
+
* @param params - content type, raw content, and optional metadata
|
|
65
|
+
* @returns the assigned knowledge-base identifier
|
|
66
|
+
*/
|
|
67
|
+
addSection(params: {
|
|
68
|
+
/** Semantic type label for the section content. */
|
|
69
|
+
readonly sectionType: string;
|
|
70
|
+
/** Raw text or base64-encoded content for the section. */
|
|
71
|
+
readonly content: string;
|
|
72
|
+
/** Optional section title. Required for image/* types. */
|
|
73
|
+
readonly title?: string;
|
|
74
|
+
/** Optional section description. */
|
|
75
|
+
readonly description?: string;
|
|
76
|
+
/** Optional document ID to group this section under. */
|
|
77
|
+
readonly docid?: string;
|
|
78
|
+
/** Optional tags for scoping and filtering. */
|
|
79
|
+
readonly tags?: string[];
|
|
80
|
+
/**
|
|
81
|
+
* When `true`, replaces an existing section that has the same
|
|
82
|
+
* source key (supersession).
|
|
83
|
+
*/
|
|
84
|
+
readonly replace?: boolean;
|
|
85
|
+
}): Promise<AddSectionResult>;
|
|
86
|
+
/**
|
|
87
|
+
* Removes a section from the knowledge base.
|
|
88
|
+
*
|
|
89
|
+
* @param kbid - knowledge-base identifier of the section to remove
|
|
90
|
+
* @returns removal result with `removed` flag and elapsed time
|
|
91
|
+
*/
|
|
92
|
+
removeSection(kbid: string): Promise<RemoveSectionResult>;
|
|
93
|
+
/**
|
|
94
|
+
* Retrieves one or more sections by their identifiers.
|
|
95
|
+
*
|
|
96
|
+
* @param kbids - list of knowledge-base identifiers to fetch
|
|
97
|
+
* @returns sections in the order their IDs were requested
|
|
98
|
+
*/
|
|
99
|
+
readSections(kbids: string[]): Promise<{
|
|
100
|
+
/** Knowledge-base identifier for this section. */
|
|
101
|
+
kbid: string;
|
|
102
|
+
/** Semantic type label assigned to the section. */
|
|
103
|
+
sectionType: string;
|
|
104
|
+
/** Raw text content of the section. */
|
|
105
|
+
content: string;
|
|
106
|
+
/** Byte size of the stored content. */
|
|
107
|
+
size: number;
|
|
108
|
+
}[]>;
|
|
109
|
+
/**
|
|
110
|
+
* Retrieves a full document record including its ordered sections.
|
|
111
|
+
*
|
|
112
|
+
* @param docid - identifier of the document to retrieve
|
|
113
|
+
* @returns the document record as returned by the daemon
|
|
114
|
+
*/
|
|
115
|
+
retrieveDocument(docid: string): Promise<unknown>;
|
|
116
|
+
/**
|
|
117
|
+
* Composes a rendered Markdown document from one or more kbid
|
|
118
|
+
* or docid identifiers.
|
|
119
|
+
*
|
|
120
|
+
* @param ids - list of kbid or docid identifiers (may be mixed)
|
|
121
|
+
* @returns composed Markdown result with character count
|
|
122
|
+
*/
|
|
123
|
+
content(ids: string[]): Promise<McpContentResult>;
|
|
124
|
+
/**
|
|
125
|
+
* Returns database metadata and status from the daemon.
|
|
126
|
+
*
|
|
127
|
+
* @returns document count, section count, and timing statistics
|
|
128
|
+
*/
|
|
129
|
+
dbStatus(): Promise<{
|
|
130
|
+
/** Whether the daemon has finished loading its WASM modules. */
|
|
131
|
+
initialized: boolean;
|
|
132
|
+
/** Absolute path to the context directory the daemon serves. */
|
|
133
|
+
contextPath: string;
|
|
134
|
+
/** In-memory cache statistics. */
|
|
135
|
+
cacheStats: {
|
|
136
|
+
/** Number of content entries currently cached. */
|
|
137
|
+
contentCount: number;
|
|
138
|
+
/** Number of index entries currently cached. */
|
|
139
|
+
indexCount: number;
|
|
140
|
+
};
|
|
141
|
+
}>;
|
|
142
|
+
/**
|
|
143
|
+
* Runs an integrity check on the knowledge-base database.
|
|
144
|
+
*
|
|
145
|
+
* @returns a report of all issues found; `ok` is `true` when
|
|
146
|
+
* no errors were detected
|
|
147
|
+
*/
|
|
148
|
+
integrityCheck(): Promise<McpIntegrityCheckResult>;
|
|
149
|
+
/**
|
|
150
|
+
* Removes unreferenced sections from the database.
|
|
151
|
+
*
|
|
152
|
+
* @returns a report of sections removed and bytes freed
|
|
153
|
+
*/
|
|
154
|
+
gc(): Promise<McpGcResult>;
|
|
155
|
+
/**
|
|
156
|
+
* Reconstructs all index files from section files and document
|
|
157
|
+
* manifests on disk.
|
|
158
|
+
*
|
|
159
|
+
* @returns a report of sections and terms re-indexed
|
|
160
|
+
*/
|
|
161
|
+
rebuildIndexes(): Promise<McpRebuildResult>;
|
|
162
|
+
/**
|
|
163
|
+
* Retrieves all sections whose type name matches the given string.
|
|
164
|
+
*
|
|
165
|
+
* @param sectionType - the application-level type name to filter by
|
|
166
|
+
* @returns all section records with a matching type name
|
|
167
|
+
*/
|
|
168
|
+
listByType(sectionType: string): Promise<SectionRecord[]>;
|
|
169
|
+
/**
|
|
170
|
+
* Retrieves all documents whose type name matches the given string.
|
|
171
|
+
*
|
|
172
|
+
* @param docType - the application-level document type to filter by
|
|
173
|
+
* @returns all document manifests with a matching type name
|
|
174
|
+
*/
|
|
175
|
+
listDocumentsByType(docType: string): Promise<DocumentManifest[]>;
|
|
176
|
+
/**
|
|
177
|
+
* Groups a set of sections under a named document.
|
|
178
|
+
*
|
|
179
|
+
* @param title - human-readable document title
|
|
180
|
+
* @param kbids - identifiers of the sections to group
|
|
181
|
+
* @returns the assigned document identifier
|
|
182
|
+
*/
|
|
183
|
+
groupSections(title: string, kbids: string[], docType?: string): Promise<string>;
|
|
184
|
+
/**
|
|
185
|
+
* Removes the document grouping for the given document.
|
|
186
|
+
*
|
|
187
|
+
* The sections themselves are not deleted; only the grouping
|
|
188
|
+
* record is removed.
|
|
189
|
+
*
|
|
190
|
+
* @param docid - identifier of the document grouping to remove
|
|
191
|
+
*/
|
|
192
|
+
removeGrouping(docid: string): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Retrieves full content and context for one or more sections by
|
|
195
|
+
* their knowledge-base identifiers.
|
|
196
|
+
*
|
|
197
|
+
* @param params - section identifier(s) and optional expansion depth
|
|
198
|
+
* @returns a single result or array of results depending on input
|
|
199
|
+
*/
|
|
200
|
+
recall(params: {
|
|
201
|
+
/** Single section identifier. */
|
|
202
|
+
readonly kbid?: string;
|
|
203
|
+
/** Batch section identifiers. */
|
|
204
|
+
readonly kbids?: readonly string[];
|
|
205
|
+
/** Expansion depth (0-3, default: 0). */
|
|
206
|
+
readonly depth?: number;
|
|
207
|
+
}): Promise<unknown>;
|
|
208
|
+
/**
|
|
209
|
+
* Exports the database to a target directory as a self-contained
|
|
210
|
+
* snapshot (sections, documents, catalog -- no indexes).
|
|
211
|
+
*
|
|
212
|
+
* @param params - optional export parameters
|
|
213
|
+
* @returns export report with the resolved path and file counts
|
|
214
|
+
*/
|
|
215
|
+
export(params?: {
|
|
216
|
+
readonly path?: string;
|
|
217
|
+
}): Promise<McpExportResult>;
|
|
218
|
+
/** Destroys the IPC socket and clears the connection state. */
|
|
219
|
+
disconnect(): void;
|
|
220
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
* Result returned by any MCP tool call handler, containing one or
|
|
10
|
+
* more content items and an optional error flag.
|
|
11
|
+
*/
|
|
12
|
+
export interface ToolCallResult {
|
|
13
|
+
/** One or more content items describing the result. */
|
|
14
|
+
readonly content: ToolContent[];
|
|
15
|
+
/** Set to `true` when the tool encountered an error. */
|
|
16
|
+
readonly isError?: boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
/** A resolution record pairing an entry with its resolution. */
|
|
5
|
+
interface ResolutionRecord {
|
|
6
|
+
/** The export entry being resolved. */
|
|
7
|
+
readonly entry: ExportEntry;
|
|
8
|
+
/** The resolution applied to the entry. */
|
|
9
|
+
readonly resolution: ConflictResolution;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Builds an import report from resolution results.
|
|
13
|
+
*
|
|
14
|
+
* Counts each resolution type and determines whether
|
|
15
|
+
* a database rebuild is required after the import.
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildImportReport(resolutions: readonly ResolutionRecord[]): ImportReport;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ExportEntry } from '../typings/export-entry.interface.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a serialized export entry.
|
|
4
|
+
*
|
|
5
|
+
* Expects TOML frontmatter delimited by `+++` lines,
|
|
6
|
+
* followed by the body content.
|
|
7
|
+
*
|
|
8
|
+
* @throws {Error} if the frontmatter delimiters are absent
|
|
9
|
+
* or required fields are missing.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseExportEntry(content: string): ExportEntry;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ConflictResolution } from '../typings/conflict-resolution.type.ts';
|
|
2
|
+
import type { ExportEntry } from '../typings/export-entry.interface.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Determines the conflict resolution action for
|
|
5
|
+
* an incoming section.
|
|
6
|
+
*
|
|
7
|
+
* Rules applied in order:
|
|
8
|
+
* 1. Same kbid exists -> skip
|
|
9
|
+
* 2. Same source_key, incoming is newer -> supersede
|
|
10
|
+
* 3. Same source_key, incoming is not newer -> skip
|
|
11
|
+
* 4. No match -> add
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveConflict(incoming: ExportEntry, existingKbids: ReadonlySet<string>, existingBySourceKey: ReadonlyMap<string, ExportEntry>): ConflictResolution;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ExportEntry } from '../typings/export-entry.interface.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Serializes an export entry to a flat file format.
|
|
4
|
+
*
|
|
5
|
+
* Format: TOML frontmatter delimited by `+++` lines,
|
|
6
|
+
* followed by the body content.
|
|
7
|
+
*/
|
|
8
|
+
export declare function serializeExportEntry(entry: ExportEntry): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { resolveConflict } from './functions/resolve-conflict.function.ts';
|
|
2
|
+
export { buildImportReport } from './functions/build-import-report.function.ts';
|
|
3
|
+
export { serializeExportEntry } from './functions/serialize-export-entry.function.ts';
|
|
4
|
+
export { parseExportEntry } from './functions/parse-export-entry.function.ts';
|
|
5
|
+
export type { ExportEntry } from './typings/export-entry.interface.ts';
|
|
6
|
+
export type { ExportOptions } from './typings/export-options.interface.ts';
|
|
7
|
+
export type { ImportOptions } from './typings/import-options.interface.ts';
|
|
8
|
+
export type { ImportReport } from './typings/import-report.interface.ts';
|
|
9
|
+
export type { ConflictResolution } from './typings/conflict-resolution.type.ts';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** A single entry in an export manifest. */
|
|
2
|
+
export interface ExportEntry {
|
|
3
|
+
/** Section kbid. */
|
|
4
|
+
readonly kbid: string;
|
|
5
|
+
/** Source key. */
|
|
6
|
+
readonly sourceKey: string;
|
|
7
|
+
/** Section heading. */
|
|
8
|
+
readonly heading: string;
|
|
9
|
+
/** Content body. */
|
|
10
|
+
readonly body: string;
|
|
11
|
+
/** Created timestamp (ISO). */
|
|
12
|
+
readonly createdAt: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Options for export operation. */
|
|
2
|
+
export interface ExportOptions {
|
|
3
|
+
/** Export format. */
|
|
4
|
+
readonly format: 'git' | 'archive';
|
|
5
|
+
/** Output directory or file path. */
|
|
6
|
+
readonly outputPath: string;
|
|
7
|
+
/** Exclude vector indexes. */
|
|
8
|
+
readonly excludeVectors: boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Report of an import operation. */
|
|
2
|
+
export interface ImportReport {
|
|
3
|
+
/** Sections added. */
|
|
4
|
+
readonly sectionsAdded: number;
|
|
5
|
+
/** Sections skipped (same kbid). */
|
|
6
|
+
readonly sectionsSkipped: number;
|
|
7
|
+
/** Sections superseded (same source_key, newer). */
|
|
8
|
+
readonly sectionsSuperseded: number;
|
|
9
|
+
/** Documents added. */
|
|
10
|
+
readonly documentsAdded: number;
|
|
11
|
+
/** Documents skipped. */
|
|
12
|
+
readonly documentsSkipped: number;
|
|
13
|
+
/** Whether rebuild is required. */
|
|
14
|
+
readonly rebuildRequired: boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DecodeResult } from './decode-string.function.ts';
|
|
2
|
+
import type { RecallResult } from '../../worker-client/typings/recall-result.model.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Decodes a single `RecallResult` record from WASM binary output.
|
|
5
|
+
*
|
|
6
|
+
* Wire format: kbid, heading, section_type, content, docid list,
|
|
7
|
+
* document list, back_references list, siblings list,
|
|
8
|
+
* references list.
|
|
9
|
+
*
|
|
10
|
+
* @param bytes - raw binary buffer
|
|
11
|
+
* @param startOffset - byte position of the record start
|
|
12
|
+
* @returns decoded result and number of bytes consumed
|
|
13
|
+
*/
|
|
14
|
+
export declare function decodeOneRecallResult(bytes: Uint8Array, startOffset: number): DecodeResult<RecallResult>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DecodeResult } from './decode-string.function.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Decodes an `Option<String>` from WASM binary output.
|
|
4
|
+
*
|
|
5
|
+
* Wire format: `u8` tag byte (`0x00` = `None`, any other value =
|
|
6
|
+
* `Some`) followed by a length-prefixed UTF-8 string when present.
|
|
7
|
+
*
|
|
8
|
+
* @param bytes - raw binary buffer
|
|
9
|
+
* @param offset - byte position of the tag byte
|
|
10
|
+
* @returns decoded nullable string and number of bytes consumed
|
|
11
|
+
*/
|
|
12
|
+
export declare function decodeOptionString(bytes: Uint8Array, offset: number): DecodeResult<string | null>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DecodeResult } from './decode-string.function.ts';
|
|
2
|
+
import type { RecallDocument } from '../../worker-client/typings/recall-result.model.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Decodes a single `RecallDocument` record from WASM binary output.
|
|
5
|
+
*
|
|
6
|
+
* Wire format: docid (String), title (String), section_count (u32),
|
|
7
|
+
* then each section as kbid (String), heading (Option<String>),
|
|
8
|
+
* section_type (String).
|
|
9
|
+
*
|
|
10
|
+
* @param bytes - raw binary buffer
|
|
11
|
+
* @param offset - byte position of the record start
|
|
12
|
+
* @returns decoded document and number of bytes consumed
|
|
13
|
+
*/
|
|
14
|
+
export declare function decodeRecallDocument(bytes: Uint8Array, offset: number): DecodeResult<RecallDocument>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DecodeResult } from './decode-string.function.ts';
|
|
2
|
+
import type { RecallReference } from '../../worker-client/typings/recall-result.model.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Decodes a single `RecallReference` record from WASM binary output.
|
|
5
|
+
*
|
|
6
|
+
* Wire format: kbid (String), heading (Option<String>),
|
|
7
|
+
* section_type (String), marker_type (String),
|
|
8
|
+
* context_snippet (String), direction (String).
|
|
9
|
+
*
|
|
10
|
+
* @param bytes - raw binary buffer
|
|
11
|
+
* @param offset - byte position of the record start
|
|
12
|
+
* @returns decoded reference and number of bytes consumed
|
|
13
|
+
*/
|
|
14
|
+
export declare function decodeRecallReference(bytes: Uint8Array, offset: number): DecodeResult<RecallReference>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DecodeResult } from './decode-string.function.ts';
|
|
2
|
+
import type { RecallSibling } from '../../worker-client/typings/recall-result.model.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Decodes a single `RecallSibling` record from WASM binary output.
|
|
5
|
+
*
|
|
6
|
+
* Wire format: kbid (String), heading (Option<String>),
|
|
7
|
+
* section_type (String), content (String).
|
|
8
|
+
*
|
|
9
|
+
* @param bytes - raw binary buffer
|
|
10
|
+
* @param offset - byte position of the record start
|
|
11
|
+
* @returns decoded sibling and number of bytes consumed
|
|
12
|
+
*/
|
|
13
|
+
export declare function decodeRecallSibling(bytes: Uint8Array, offset: number): DecodeResult<RecallSibling>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DecodeResult } from './decode-string.function.ts';
|
|
2
|
+
import type { SectionMatch } from '../typings/section-match.model.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Decodes a single `SectionMatch` item from WASM binary output.
|
|
5
|
+
*
|
|
6
|
+
* Wire format per item: kbid, heading (Option<String>),
|
|
7
|
+
* section_type, docids (u32 count + String[]), score (f32),
|
|
8
|
+
* confidence (f32), snippet, matched_terms (u32 + String[]),
|
|
9
|
+
* matched_fields (u32 + String[]), created_at.
|
|
10
|
+
*
|
|
11
|
+
* @param bytes - raw binary buffer
|
|
12
|
+
* @param startOffset - byte position of the item start
|
|
13
|
+
* @returns decoded match and number of bytes consumed
|
|
14
|
+
*/
|
|
15
|
+
export declare function decodeSectionMatch(bytes: Uint8Array, startOffset: number): DecodeResult<SectionMatch>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SectionRecordTrailing } from '../typings/section-record-trailing.model.ts';
|
|
2
|
+
export type { SectionRecordTrailing };
|
|
3
|
+
/**
|
|
4
|
+
* Decodes the trailing backward-compatible fields of a
|
|
5
|
+
* `SectionRecord` from WASM binary output.
|
|
6
|
+
*
|
|
7
|
+
* Fields present only in newer binary output; each is guarded by a
|
|
8
|
+
* length check. Missing fields default to `null` or `[]`.
|
|
9
|
+
*
|
|
10
|
+
* @param bytes - raw bytes from a WASM section-list export
|
|
11
|
+
* @param startOffset - byte position after the `typeName` field
|
|
12
|
+
* @returns decoded trailing fields and bytes consumed
|
|
13
|
+
*/
|
|
14
|
+
export declare function decodeSectionRecordTrailing(bytes: Uint8Array, startOffset: number): SectionRecordTrailing;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DecodeResult } from './decode-string.function.ts';
|
|
2
|
+
import type { SectionRecord } from '../typings/section-record.model.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Decodes a single `SectionRecord` from WASM binary output.
|
|
5
|
+
*
|
|
6
|
+
* Reads all section fields in the order produced by the Rust
|
|
7
|
+
* `SectionRecord::encode` implementation. Trailing fields added
|
|
8
|
+
* after `typeName` default to `null` / `[]` when absent.
|
|
9
|
+
*
|
|
10
|
+
* @param bytes - raw bytes returned by a WASM section-list export
|
|
11
|
+
* @param startOffset - byte position of the record start
|
|
12
|
+
* @returns decoded record and number of bytes consumed
|
|
13
|
+
*/
|
|
14
|
+
export declare function decodeSectionRecord(bytes: Uint8Array, startOffset: number): DecodeResult<SectionRecord>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SectionTypeResult } from '../typings/section-type-result.model.ts';
|
|
2
|
+
export type { SectionTypeResult };
|
|
3
|
+
/**
|
|
4
|
+
* Decodes a section type discriminant from WASM binary output.
|
|
5
|
+
*
|
|
6
|
+
* Wire format: `u8` tag (`0x00` = text, `0x01` = code,
|
|
7
|
+
* `0x02` = image), followed by a MIME string for code/image.
|
|
8
|
+
*
|
|
9
|
+
* @param bytes - raw binary buffer
|
|
10
|
+
* @param offset - byte position of the tag byte
|
|
11
|
+
* @returns section type, optional MIME type, and bytes consumed
|
|
12
|
+
*/
|
|
13
|
+
export declare function decodeSectionType(bytes: Uint8Array, offset: number): SectionTypeResult;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ItemDecoder } from '../typings/item-decoder.type.ts';
|
|
2
|
+
export type { ItemDecoder };
|
|
3
|
+
/**
|
|
4
|
+
* Decodes a length-prefixed list from WASM binary output.
|
|
5
|
+
*
|
|
6
|
+
* Wire format: u32 item count, then that many items decoded
|
|
7
|
+
* sequentially by `decode`.
|
|
8
|
+
*
|
|
9
|
+
* @param bytes - raw binary buffer
|
|
10
|
+
* @param offset - byte position of the u32 count
|
|
11
|
+
* @param decode - decoder function for each item
|
|
12
|
+
* @returns decoded item array and total bytes consumed
|
|
13
|
+
*/
|
|
14
|
+
export declare function decodeWasmList<T>(bytes: Uint8Array, offset: number, decode: ItemDecoder<T>): {
|
|
15
|
+
items: T[];
|
|
16
|
+
bytesRead: number;
|
|
17
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameters for adding a new section to the knowledge base.
|
|
3
|
+
*
|
|
4
|
+
* Maps to the Rust `AddSectionParams` struct encoded for the
|
|
5
|
+
* `worker_add_section` WASM export.
|
|
6
|
+
*/
|
|
7
|
+
export interface AddSectionInput {
|
|
8
|
+
/** Semantic content category. */
|
|
9
|
+
sectionType: 'text' | 'code' | 'image';
|
|
10
|
+
/** MIME type; required for `code` and `image` section types. */
|
|
11
|
+
mimeType?: string;
|
|
12
|
+
/** Raw section content. */
|
|
13
|
+
content: string;
|
|
14
|
+
/** Optional section heading. */
|
|
15
|
+
title?: string | null;
|
|
16
|
+
/** Optional description summary. */
|
|
17
|
+
description?: string | null;
|
|
18
|
+
/** Optional document identifier to attach the section to. */
|
|
19
|
+
docid?: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Application-level type name for the section (e.g. `'skill'`,
|
|
22
|
+
* `'fact'`). `null` means no custom type.
|
|
23
|
+
*/
|
|
24
|
+
typeName?: string | null;
|
|
25
|
+
/**
|
|
26
|
+
* Absolute path of the source file being learned. `undefined`
|
|
27
|
+
* means stdin input or programmatic API call.
|
|
28
|
+
*/
|
|
29
|
+
sourcePath?: string;
|
|
30
|
+
/**
|
|
31
|
+
* ISO 8601 modified time of the source file. `undefined` means
|
|
32
|
+
* no source file exists.
|
|
33
|
+
*/
|
|
34
|
+
sourceMtime?: string;
|
|
35
|
+
/**
|
|
36
|
+
* User-supplied tags for scoping and filtering. Defaults to
|
|
37
|
+
* an empty list when not provided.
|
|
38
|
+
*/
|
|
39
|
+
tags?: string[];
|
|
40
|
+
/**
|
|
41
|
+
* When `true`, supersede any existing section with the same
|
|
42
|
+
* source key. Defaults to `false`.
|
|
43
|
+
*/
|
|
44
|
+
replace?: boolean;
|
|
45
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { NearDuplicate } from './near-duplicate.model.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Decoded result of a `worker_add_section` WASM call.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors the Rust `AddSectionResult` struct encoded via the
|
|
6
|
+
* `Encode` trait wire format.
|
|
7
|
+
*/
|
|
8
|
+
export interface AddSectionResult {
|
|
9
|
+
/** Knowledge-base identifier assigned to the new section. */
|
|
10
|
+
readonly kbid: string;
|
|
11
|
+
/** Number of unique terms indexed for the section. */
|
|
12
|
+
readonly indexedTermsCount: number;
|
|
13
|
+
/** Wall-clock time the add operation took, in milliseconds. */
|
|
14
|
+
readonly elapsedMs: number;
|
|
15
|
+
/**
|
|
16
|
+
* Knowledge-base identifier of the section that was superseded,
|
|
17
|
+
* or `null` if no supersession occurred.
|
|
18
|
+
*/
|
|
19
|
+
readonly superseded: string | null;
|
|
20
|
+
/** Advisory warnings emitted during indexing. */
|
|
21
|
+
readonly warnings: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Near-duplicate sections detected above the similarity threshold
|
|
24
|
+
* (Jaccard ≥ 0.85).
|
|
25
|
+
*/
|
|
26
|
+
readonly nearDuplicates: NearDuplicate[];
|
|
27
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DocumentSection } from './document-section.model.ts';
|
|
2
|
+
/**
|
|
3
|
+
* A document manifest decoded from WASM binary output.
|
|
4
|
+
*
|
|
5
|
+
* Represents a grouped document record with its ordered list of
|
|
6
|
+
* section references as returned by `worker_retrieve_doc`.
|
|
7
|
+
*/
|
|
8
|
+
export interface DocumentManifest {
|
|
9
|
+
/** Unique document identifier. */
|
|
10
|
+
docid: string;
|
|
11
|
+
/** Human-readable document title. */
|
|
12
|
+
title: string;
|
|
13
|
+
/** Document creation timestamp as a Unix epoch value. */
|
|
14
|
+
createdAt: bigint;
|
|
15
|
+
/** Application-level type name assigned to this document. */
|
|
16
|
+
docType: string;
|
|
17
|
+
/** Ordered list of section references belonging to the document. */
|
|
18
|
+
sections: DocumentSection[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single section reference within a document manifest.
|
|
3
|
+
*
|
|
4
|
+
* Associates a knowledge-base identifier with the section's
|
|
5
|
+
* ordinal position in the document.
|
|
6
|
+
*/
|
|
7
|
+
export interface DocumentSection {
|
|
8
|
+
/** Knowledge-base identifier of the referenced section. */
|
|
9
|
+
kbid: string;
|
|
10
|
+
/** Zero-based position of this section within its document. */
|
|
11
|
+
position: number;
|
|
12
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DecodeResult } from '../functions/decode-string.function.ts';
|
|
2
|
+
/**
|
|
3
|
+
* A function that decodes one item from a binary buffer at the
|
|
4
|
+
* given byte offset, returning the decoded value and bytes consumed.
|
|
5
|
+
*/
|
|
6
|
+
export type ItemDecoder<T> = (bytes: Uint8Array, offset: number) => DecodeResult<T>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A near-duplicate section identified during add-section indexing.
|
|
3
|
+
*/
|
|
4
|
+
export interface NearDuplicate {
|
|
5
|
+
/** Knowledge-base identifier of the near-duplicate section. */
|
|
6
|
+
readonly kbid: string;
|
|
7
|
+
/** Similarity score (0.0–1.0). */
|
|
8
|
+
readonly similarity: number;
|
|
9
|
+
/**
|
|
10
|
+
* Detection method that produced this match.
|
|
11
|
+
*
|
|
12
|
+
* Optional for backward compatibility with WASM-decoded results
|
|
13
|
+
* that do not carry method information.
|
|
14
|
+
*/
|
|
15
|
+
readonly method?: 'jaccard' | 'cosine';
|
|
16
|
+
}
|