@dikolab/kbdb 0.3.2 → 0.4.0
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 +83 -89
- package/dist/chunk-BJPSPNGX.mjs +223 -0
- package/dist/chunk-BJPSPNGX.mjs.map +7 -0
- package/dist/cli.cjs +956 -319
- package/dist/cli.cjs.map +4 -4
- package/dist/cli.d.ts +9 -0
- package/dist/cli.mjs +840 -321
- package/dist/cli.mjs.map +4 -4
- package/dist/kbdb-worker.cjs +714 -94
- package/dist/kbdb-worker.cjs.map +4 -4
- package/dist/mod.cjs +122 -16
- package/dist/mod.cjs.map +3 -3
- package/dist/mod.d.ts +23 -2
- package/dist/mod.mjs +121 -16
- package/dist/mod.mjs.map +3 -3
- package/dist/src/shared/cli/functions/dispatch-command.function.d.ts +2 -1
- package/dist/src/shared/cli/functions/find-db.function.d.ts +7 -8
- package/dist/src/shared/cli/functions/handle-mcp.function.d.ts +1 -1
- package/dist/src/shared/cli/functions/parse-args.function.d.ts +4 -3
- package/dist/src/shared/cli/functions/resolve-kbid-prefix.function.d.ts +27 -0
- package/dist/src/shared/cli/functions/resolve-raw-db-path.function.d.ts +10 -0
- package/dist/src/shared/cli/functions/run-cli.function.d.ts +3 -1
- package/dist/src/shared/cli/functions/run-content.function.d.ts +8 -3
- package/dist/src/shared/cli/functions/run-import.function.d.ts +27 -0
- package/dist/src/shared/cli/functions/run-recall.function.d.ts +10 -4
- package/dist/src/shared/cli/functions/run-search.function.d.ts +7 -0
- package/dist/src/shared/cli/functions/run-unlearn.function.d.ts +9 -4
- package/dist/src/shared/cli/functions/run-worker-restart.function.d.ts +11 -0
- package/dist/src/shared/cli/functions/run-worker-stop.function.d.ts +11 -0
- package/dist/src/shared/cli/index.d.ts +2 -0
- package/dist/src/shared/cli/typings/cli-deps.interface.d.ts +4 -1
- package/dist/src/shared/cli/typings/cli-options.interface.d.ts +17 -0
- package/dist/src/shared/cli/typings/dispatch-client.type.d.ts +2 -1
- package/dist/src/shared/cli/typings/search-display.model.d.ts +6 -0
- package/dist/src/shared/embedding/classes/api-embedding-provider.class.d.ts +33 -0
- package/dist/src/shared/embedding/classes/onnx-embedding-provider.class.d.ts +33 -0
- package/dist/src/shared/embedding/functions/append-vector-entry.function.d.ts +14 -0
- package/dist/src/shared/embedding/functions/create-embedding-provider.function.d.ts +12 -0
- package/dist/src/shared/embedding/functions/detect-stale-vectors.function.d.ts +16 -0
- package/dist/src/shared/embedding/functions/parse-api-embedding-response.function.d.ts +11 -0
- package/dist/src/shared/embedding/functions/rebuild-vectors.function.d.ts +15 -0
- package/dist/src/shared/embedding/functions/scan-semantic-contradictions.function.d.ts +13 -0
- package/dist/src/shared/embedding/index.d.ts +7 -0
- package/dist/src/shared/embedding/typings/semantic-contradiction.model.d.ts +21 -0
- package/dist/src/shared/embedding/typings/stale-vectors-report.model.d.ts +16 -0
- package/dist/src/shared/mcp/classes/mcp-server.class.d.ts +22 -2
- package/dist/src/shared/mcp/functions/create-mcp-server.function.d.ts +6 -1
- package/dist/src/shared/mcp/functions/has-sampling-capability.function.d.ts +8 -0
- package/dist/src/shared/mcp/functions/run-auto-capture.function.d.ts +26 -0
- package/dist/src/shared/mcp/typings/mcp-client.interface.d.ts +2 -0
- package/dist/src/shared/mcp/typings/mcp-integrity-check-result.model.d.ts +24 -0
- package/dist/src/shared/mcp/typings/mcp-worker-client.interface.d.ts +3 -1
- package/dist/src/shared/version/constants/version.constant.d.ts +1 -1
- package/dist/src/shared/wasm-codec/typings/paged-search-result.model.d.ts +2 -0
- package/dist/src/shared/worker-client/classes/worker-client.class.d.ts +31 -1
- package/dist/src/shared/worker-client/constants/request-timeout.constant.d.ts +2 -0
- package/dist/src/shared/worker-client/constants/retry-defaults.constant.d.ts +2 -0
- package/dist/src/shared/worker-client/functions/get-or-create-client.function.d.ts +20 -0
- package/dist/src/shared/worker-client/functions/retry-on-timeout.function.d.ts +17 -0
- package/dist/src/shared/worker-client/index.d.ts +4 -1
- package/dist/src/shared/worker-client/typings/import-result.model.d.ts +16 -0
- package/dist/src/shared/worker-client/typings/integrity-check-result.model.d.ts +24 -0
- package/dist/src/shared/worker-client/typings/search-params.model.d.ts +4 -0
- package/dist/src/shared/worker-client/typings/search-result.model.d.ts +6 -0
- package/dist/src/shared/worker-client/typings/worker-client-options.interface.d.ts +7 -0
- package/dist/src/shared/worker-daemon/classes/worker-daemon.class.d.ts +5 -0
- package/dist/src/shared/worker-daemon/functions/create-ipc-server.function.d.ts +11 -11
- package/dist/src/shared/worker-daemon/functions/embed-after-learn.function.d.ts +13 -0
- package/dist/src/shared/worker-daemon/functions/handle-hybrid-search.function.d.ts +44 -0
- package/dist/src/shared/worker-daemon/functions/handle-import.function.d.ts +14 -0
- package/dist/src/shared/worker-daemon/functions/handle-read-ops.function.d.ts +7 -1
- package/dist/src/shared/worker-daemon/functions/handle-write-ops.function.d.ts +9 -4
- package/dist/src/shared/worker-daemon/typings/handler-context.interface.d.ts +3 -0
- package/dist/wasm/fs-database/kbdb_fs_database.d.ts +16 -85
- package/dist/wasm/fs-database/kbdb_fs_database.js +16 -85
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/dist/wasm/kb-worker/kbdb_worker.d.ts +20 -115
- package/dist/wasm/kb-worker/kbdb_worker.js +20 -115
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/dist/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
- package/dist/worker.d.ts +8 -0
- package/dist/worker.mjs +606 -102
- package/dist/worker.mjs.map +4 -4
- package/docs/details/README.md +4 -0
- package/docs/details/agent-tooling.md +122 -0
- package/docs/details/cli.md +70 -13
- package/docs/details/knowledge-base.md +173 -0
- package/docs/details/library-api.md +42 -2
- package/docs/details/mcp-server.md +38 -7
- package/docs/details/search-and-ranking.md +11 -10
- package/docs/goals/cli.md +110 -34
- package/docs/goals/mcp.md +22 -19
- package/docs/goals/query-parser.md +8 -0
- package/docs/goals/worker-client.md +62 -1
- package/docs/goals/worker-daemon.md +52 -10
- package/docs/modules/typescript/cli.md +1 -1
- package/docs/modules/typescript/shared/cli/functions.md +116 -13
- package/docs/modules/typescript/shared/cli/module.md +33 -20
- package/docs/modules/typescript/shared/cli/typings.md +4 -0
- package/docs/modules/typescript/shared/embedding/functions.md +104 -25
- package/docs/modules/typescript/shared/mcp/module.md +1 -1
- package/docs/modules/typescript/shared/mcp/typings.md +8 -1
- package/docs/modules/typescript/shared/worker-client/module.md +9 -1
- package/docs/modules/typescript/shared/worker-client/typings.md +3 -0
- package/docs/modules/typescript/shared/worker-daemon/module.md +6 -3
- package/docs/overview.md +1 -2
- package/docs/release-notes/0.4.0.md +80 -0
- package/docs/release-notes/README.md +1 -0
- package/mod.ts +33 -15
- package/package.json +11 -10
- package/dist/chunk-JG2UCKLI.mjs +0 -95
- package/dist/chunk-JG2UCKLI.mjs.map +0 -7
- package/src/cli.ts +0 -71
- package/src/shared/auto-capture/classes/auto-capture-controller.class.ts +0 -62
- package/src/shared/auto-capture/constants/auto-capture-defaults.constant.ts +0 -15
- package/src/shared/auto-capture/functions/build-capture-prompt.function.ts +0 -27
- package/src/shared/auto-capture/functions/evaluate-trigger.function.ts +0 -50
- package/src/shared/auto-capture/index.ts +0 -7
- package/src/shared/auto-capture/typings/auto-capture-config.interface.ts +0 -13
- package/src/shared/auto-capture/typings/auto-capture-state.interface.ts +0 -13
- package/src/shared/auto-capture/typings/auto-capture-trigger.interface.ts +0 -7
- package/src/shared/cli/constants/defaults.constant.ts +0 -19
- package/src/shared/cli/constants/global-help.constant.ts +0 -73
- package/src/shared/cli/constants/help-text.constant.ts +0 -4
- package/src/shared/cli/constants/leaf-help.constant.ts +0 -219
- package/src/shared/cli/constants/memory-protocol-body.constant.ts +0 -39
- package/src/shared/cli/constants/query-guidance-body.constant.ts +0 -37
- package/src/shared/cli/constants/subcommand-help.constant.ts +0 -195
- package/src/shared/cli/functions/collect-files.function.ts +0 -55
- package/src/shared/cli/functions/compute-section-kbid.function.ts +0 -49
- package/src/shared/cli/functions/dispatch-command.function.ts +0 -390
- package/src/shared/cli/functions/ensure-db.function.ts +0 -21
- package/src/shared/cli/functions/error-to-message.function.ts +0 -9
- package/src/shared/cli/functions/find-db.function.ts +0 -20
- package/src/shared/cli/functions/format-mcp-output.function.ts +0 -41
- package/src/shared/cli/functions/format-output.function.ts +0 -95
- package/src/shared/cli/functions/format-text-output.function.ts +0 -42
- package/src/shared/cli/functions/generate-group-help.function.ts +0 -41
- package/src/shared/cli/functions/generate-help.function.ts +0 -654
- package/src/shared/cli/functions/handle-data-command.function.ts +0 -67
- package/src/shared/cli/functions/handle-mcp.function.ts +0 -56
- package/src/shared/cli/functions/handle-migrate.function.ts +0 -64
- package/src/shared/cli/functions/hydrate-search-previews.function.ts +0 -29
- package/src/shared/cli/functions/install-default-skills.function.ts +0 -296
- package/src/shared/cli/functions/is-stdin-tty.function.ts +0 -12
- package/src/shared/cli/functions/parse-args.function.ts +0 -156
- package/src/shared/cli/functions/prompt-user.function.ts +0 -36
- package/src/shared/cli/functions/resolve-skill-names.function.ts +0 -43
- package/src/shared/cli/functions/run-agent-create.function.ts +0 -114
- package/src/shared/cli/functions/run-agent-delete.function.ts +0 -47
- package/src/shared/cli/functions/run-agent-get.function.ts +0 -166
- package/src/shared/cli/functions/run-agent-list.function.ts +0 -58
- package/src/shared/cli/functions/run-check.function.ts +0 -159
- package/src/shared/cli/functions/run-cli.function.ts +0 -299
- package/src/shared/cli/functions/run-content.function.ts +0 -47
- package/src/shared/cli/functions/run-db-init.function.ts +0 -44
- package/src/shared/cli/functions/run-db-migrate.function.ts +0 -40
- package/src/shared/cli/functions/run-export.function.ts +0 -40
- package/src/shared/cli/functions/run-gc.function.ts +0 -51
- package/src/shared/cli/functions/run-init.function.ts +0 -93
- package/src/shared/cli/functions/run-learn.function.ts +0 -223
- package/src/shared/cli/functions/run-migrate.function.ts +0 -85
- package/src/shared/cli/functions/run-rebuild.function.ts +0 -47
- package/src/shared/cli/functions/run-recall.function.ts +0 -66
- package/src/shared/cli/functions/run-search.function.ts +0 -133
- package/src/shared/cli/functions/run-skill-delete.function.ts +0 -47
- package/src/shared/cli/functions/run-skill-get.function.ts +0 -90
- package/src/shared/cli/functions/run-skill-learn.function.ts +0 -70
- package/src/shared/cli/functions/run-skill-list.function.ts +0 -74
- package/src/shared/cli/functions/run-status.function.ts +0 -29
- package/src/shared/cli/functions/run-unlearn.function.ts +0 -58
- package/src/shared/cli/functions/version-gate.function.ts +0 -44
- package/src/shared/cli/functions/wrap-command.function.ts +0 -34
- package/src/shared/cli/index.ts +0 -55
- package/src/shared/cli/typings/agent-create-client.interface.ts +0 -47
- package/src/shared/cli/typings/agent-get-client.interface.ts +0 -39
- package/src/shared/cli/typings/check-client.interface.ts +0 -66
- package/src/shared/cli/typings/cli-deps.interface.ts +0 -54
- package/src/shared/cli/typings/cli-options.interface.ts +0 -72
- package/src/shared/cli/typings/command-result.model.ts +0 -15
- package/src/shared/cli/typings/disconnectable-client.interface.ts +0 -29
- package/src/shared/cli/typings/dispatch-client.type.ts +0 -46
- package/src/shared/cli/typings/learn-client.interface.ts +0 -53
- package/src/shared/cli/typings/learn-io.interface.ts +0 -5
- package/src/shared/cli/typings/learn-result.model.ts +0 -27
- package/src/shared/cli/typings/search-client.interface.ts +0 -73
- package/src/shared/cli/typings/search-display.model.ts +0 -54
- package/src/shared/dir-resolver/functions/join-path.function.ts +0 -13
- package/src/shared/dir-resolver/functions/resolve-base-dir.function.ts +0 -25
- package/src/shared/dir-resolver/functions/resolve-wasm-dir.function.ts +0 -5
- package/src/shared/dir-resolver/functions/resolve-worker-script.function.ts +0 -13
- package/src/shared/dir-resolver/index.ts +0 -11
- package/src/shared/dir-resolver/typings/base-dir.interface.ts +0 -4
- package/src/shared/embedding/classes/null-embedding-provider.class.ts +0 -29
- package/src/shared/embedding/constants/near-duplicate-thresholds.constant.ts +0 -17
- package/src/shared/embedding/functions/build-vector-index.function.ts +0 -79
- package/src/shared/embedding/functions/cosine-similarity.function.ts +0 -31
- package/src/shared/embedding/functions/detect-near-duplicates.function.ts +0 -69
- package/src/shared/embedding/functions/jaccard-coefficient.function.ts +0 -26
- package/src/shared/embedding/functions/read-vector-index-meta.function.ts +0 -44
- package/src/shared/embedding/functions/rrf-fuse.function.ts +0 -33
- package/src/shared/embedding/functions/search-vectors.function.ts +0 -59
- package/src/shared/embedding/index.ts +0 -20
- package/src/shared/embedding/typings/embedding-config.interface.ts +0 -23
- package/src/shared/embedding/typings/embedding-provider.interface.ts +0 -25
- package/src/shared/embedding/typings/near-duplicate-candidate.model.ts +0 -25
- package/src/shared/embedding/typings/near-duplicate-result.model.ts +0 -26
- package/src/shared/embedding/typings/vector-index-entry.model.ts +0 -13
- package/src/shared/embedding/typings/vector-index-meta.model.ts +0 -14
- package/src/shared/embedding/typings/vector-search-result.model.ts +0 -8
- package/src/shared/hash/functions/compute-sha256.ts +0 -17
- package/src/shared/hash/index.ts +0 -1
- package/src/shared/mcp/classes/mcp-server.class.ts +0 -480
- package/src/shared/mcp/constants/mcp-error-codes.constant.ts +0 -30
- package/src/shared/mcp/constants/tool-agent-create.constant.ts +0 -39
- package/src/shared/mcp/constants/tool-agent-delete.constant.ts +0 -26
- package/src/shared/mcp/constants/tool-agent-get.constant.ts +0 -24
- package/src/shared/mcp/constants/tool-agent-list.constant.ts +0 -18
- package/src/shared/mcp/constants/tool-auto-capture-review.constant.ts +0 -32
- package/src/shared/mcp/constants/tool-check.constant.ts +0 -21
- package/src/shared/mcp/constants/tool-content.constant.ts +0 -29
- package/src/shared/mcp/constants/tool-export.constant.ts +0 -27
- package/src/shared/mcp/constants/tool-gc.constant.ts +0 -21
- package/src/shared/mcp/constants/tool-learn.constant.ts +0 -58
- package/src/shared/mcp/constants/tool-rebuild.constant.ts +0 -21
- package/src/shared/mcp/constants/tool-recall.constant.ts +0 -36
- package/src/shared/mcp/constants/tool-retrieve.constant.ts +0 -31
- package/src/shared/mcp/constants/tool-search.constant.ts +0 -51
- package/src/shared/mcp/constants/tool-skill-delete.constant.ts +0 -24
- package/src/shared/mcp/constants/tool-skill-get.constant.ts +0 -27
- package/src/shared/mcp/constants/tool-skill-learn.constant.ts +0 -37
- package/src/shared/mcp/constants/tool-skill-list.constant.ts +0 -18
- package/src/shared/mcp/constants/tool-status.constant.ts +0 -20
- package/src/shared/mcp/constants/tool-unlearn.constant.ts +0 -25
- package/src/shared/mcp/functions/as-boolean-or-undefined.function.ts +0 -11
- package/src/shared/mcp/functions/as-string-array-or-undefined.function.ts +0 -17
- package/src/shared/mcp/functions/as-string-array.function.ts +0 -15
- package/src/shared/mcp/functions/as-string.function.ts +0 -10
- package/src/shared/mcp/functions/build-skills-text.function.ts +0 -43
- package/src/shared/mcp/functions/create-mcp-server.function.ts +0 -14
- package/src/shared/mcp/functions/create-prompt-definitions.function.ts +0 -102
- package/src/shared/mcp/functions/create-resource-templates.function.ts +0 -23
- package/src/shared/mcp/functions/create-tool-definitions.function.ts +0 -530
- package/src/shared/mcp/functions/extract-skill-arguments.function.ts +0 -27
- package/src/shared/mcp/functions/handle-agent-create.function.ts +0 -116
- package/src/shared/mcp/functions/handle-agent-delete.function.ts +0 -50
- package/src/shared/mcp/functions/handle-agent-get.function.ts +0 -160
- package/src/shared/mcp/functions/handle-agent-list.function.ts +0 -50
- package/src/shared/mcp/functions/handle-agent-prompt.function.ts +0 -68
- package/src/shared/mcp/functions/handle-completion.function.ts +0 -114
- package/src/shared/mcp/functions/handle-mcp-request.function.ts +0 -202
- package/src/shared/mcp/functions/handle-prompt-get.function.ts +0 -220
- package/src/shared/mcp/functions/handle-recall.function.ts +0 -66
- package/src/shared/mcp/functions/handle-resource-read.function.ts +0 -56
- package/src/shared/mcp/functions/handle-roots-list.function.ts +0 -29
- package/src/shared/mcp/functions/handle-skill-prompt.function.ts +0 -44
- package/src/shared/mcp/functions/handle-tool-auto-capture-review.function.ts +0 -24
- package/src/shared/mcp/functions/handle-tool-call.function.ts +0 -560
- package/src/shared/mcp/functions/handle-tool-check.function.ts +0 -21
- package/src/shared/mcp/functions/handle-tool-content.function.ts +0 -23
- package/src/shared/mcp/functions/handle-tool-export.function.ts +0 -25
- package/src/shared/mcp/functions/handle-tool-gc.function.ts +0 -21
- package/src/shared/mcp/functions/handle-tool-learn.function.ts +0 -69
- package/src/shared/mcp/functions/handle-tool-rebuild.function.ts +0 -21
- package/src/shared/mcp/functions/handle-tool-retrieve.function.ts +0 -40
- package/src/shared/mcp/functions/handle-tool-search.function.ts +0 -47
- package/src/shared/mcp/functions/handle-tool-skill-delete.function.ts +0 -34
- package/src/shared/mcp/functions/handle-tool-skill-get.function.ts +0 -59
- package/src/shared/mcp/functions/handle-tool-skill-learn.function.ts +0 -61
- package/src/shared/mcp/functions/handle-tool-skill-list.function.ts +0 -39
- package/src/shared/mcp/functions/handle-tool-status.function.ts +0 -21
- package/src/shared/mcp/functions/handle-tool-unlearn.function.ts +0 -24
- package/src/shared/mcp/functions/parse-agent-meta.function.ts +0 -27
- package/src/shared/mcp/functions/parse-skill-arguments.function.ts +0 -36
- package/src/shared/mcp/functions/parse-skill-content.function.ts +0 -38
- package/src/shared/mcp/functions/read-agent-meta.function.ts +0 -41
- package/src/shared/mcp/functions/resolve-skill-refs.function.ts +0 -50
- package/src/shared/mcp/functions/run-startup-health-check.function.ts +0 -34
- package/src/shared/mcp/functions/serialize-skill-content.function.ts +0 -12
- package/src/shared/mcp/functions/should-emit-log.function.ts +0 -38
- package/src/shared/mcp/index.ts +0 -28
- package/src/shared/mcp/typings/agent-types.interface.ts +0 -39
- package/src/shared/mcp/typings/log-types.interface.ts +0 -26
- package/src/shared/mcp/typings/mcp-capabilities.interface.ts +0 -16
- package/src/shared/mcp/typings/mcp-client.interface.ts +0 -317
- package/src/shared/mcp/typings/mcp-completion.interface.ts +0 -45
- package/src/shared/mcp/typings/mcp-content-result.model.ts +0 -9
- package/src/shared/mcp/typings/mcp-export-result.model.ts +0 -11
- package/src/shared/mcp/typings/mcp-gc-result.model.ts +0 -15
- package/src/shared/mcp/typings/mcp-integrity-check-result.model.ts +0 -17
- package/src/shared/mcp/typings/mcp-integrity-error.model.ts +0 -15
- package/src/shared/mcp/typings/mcp-notification.interface.ts +0 -9
- package/src/shared/mcp/typings/mcp-rebuild-result.model.ts +0 -9
- package/src/shared/mcp/typings/mcp-request.interface.ts +0 -11
- package/src/shared/mcp/typings/mcp-resource-result.interface.ts +0 -12
- package/src/shared/mcp/typings/mcp-resource-template.interface.ts +0 -11
- package/src/shared/mcp/typings/mcp-response.interface.ts +0 -18
- package/src/shared/mcp/typings/mcp-server-info.interface.ts +0 -7
- package/src/shared/mcp/typings/mcp-server-state.interface.ts +0 -17
- package/src/shared/mcp/typings/mcp-tool-annotations.interface.ts +0 -32
- package/src/shared/mcp/typings/mcp-tool-definition.interface.ts +0 -16
- package/src/shared/mcp/typings/mcp-tool-result.interface.ts +0 -19
- package/src/shared/mcp/typings/mcp-types.interface.ts +0 -158
- package/src/shared/mcp/typings/mcp-worker-client.interface.ts +0 -243
- package/src/shared/mcp/typings/prompt-types.interface.ts +0 -39
- package/src/shared/mcp/typings/remove-section-result.model.ts +0 -10
- package/src/shared/mcp/typings/sampling-types.interface.ts +0 -48
- package/src/shared/mcp/typings/skill-types.interface.ts +0 -29
- package/src/shared/mcp/typings/tool-call-result.model.ts +0 -18
- package/src/shared/mod.ts +0 -1
- package/src/shared/platform/functions/get-ipc-path.function.ts +0 -19
- package/src/shared/platform/functions/get-tmpdir.function.ts +0 -8
- package/src/shared/platform/functions/is-process-alive.function.ts +0 -17
- package/src/shared/platform/index.ts +0 -3
- package/src/shared/runtime/functions/detect-runtime.ts +0 -14
- package/src/shared/runtime/functions/get-args.ts +0 -16
- package/src/shared/runtime/index.ts +0 -3
- package/src/shared/runtime/typings/runtime.ts +0 -2
- package/src/shared/sync/functions/build-import-report.function.ts +0 -40
- package/src/shared/sync/functions/parse-export-entry.function.ts +0 -45
- package/src/shared/sync/functions/resolve-conflict.function.ts +0 -31
- package/src/shared/sync/functions/serialize-export-entry.function.ts +0 -18
- package/src/shared/sync/index.ts +0 -9
- package/src/shared/sync/typings/conflict-resolution.type.ts +0 -8
- package/src/shared/sync/typings/export-entry.interface.ts +0 -13
- package/src/shared/sync/typings/export-options.interface.ts +0 -9
- package/src/shared/sync/typings/import-options.interface.ts +0 -7
- package/src/shared/sync/typings/import-report.interface.ts +0 -15
- package/src/shared/version/constants/version.constant.ts +0 -2
- package/src/shared/version/index.ts +0 -1
- package/src/shared/wasm-codec/functions/decode-add-section-result.function.ts +0 -112
- package/src/shared/wasm-codec/functions/decode-compose-output.function.ts +0 -16
- package/src/shared/wasm-codec/functions/decode-document-manifest-list.function.ts +0 -70
- package/src/shared/wasm-codec/functions/decode-document-manifest.function.ts +0 -87
- package/src/shared/wasm-codec/functions/decode-f32.function.ts +0 -16
- package/src/shared/wasm-codec/functions/decode-key-value-text.function.ts +0 -15
- package/src/shared/wasm-codec/functions/decode-one-recall-result.function.ts +0 -86
- package/src/shared/wasm-codec/functions/decode-option-string.function.ts +0 -24
- package/src/shared/wasm-codec/functions/decode-recall-document.function.ts +0 -59
- package/src/shared/wasm-codec/functions/decode-recall-reference.function.ts +0 -52
- package/src/shared/wasm-codec/functions/decode-recall-result.function.ts +0 -267
- package/src/shared/wasm-codec/functions/decode-recall-sibling.function.ts +0 -43
- package/src/shared/wasm-codec/functions/decode-remove-flag.function.ts +0 -3
- package/src/shared/wasm-codec/functions/decode-scored-results.function.ts +0 -194
- package/src/shared/wasm-codec/functions/decode-section-match.function.ts +0 -80
- package/src/shared/wasm-codec/functions/decode-section-record-list.function.ts +0 -20
- package/src/shared/wasm-codec/functions/decode-section-record-trailing.function.ts +0 -75
- package/src/shared/wasm-codec/functions/decode-section-record.function.ts +0 -85
- package/src/shared/wasm-codec/functions/decode-section-records.function.ts +0 -249
- package/src/shared/wasm-codec/functions/decode-section-type.function.ts +0 -30
- package/src/shared/wasm-codec/functions/decode-string.function.ts +0 -22
- package/src/shared/wasm-codec/functions/decode-u32.function.ts +0 -16
- package/src/shared/wasm-codec/functions/decode-u64.function.ts +0 -16
- package/src/shared/wasm-codec/functions/decode-wasm-list.function.ts +0 -31
- package/src/shared/wasm-codec/functions/encode-add-section-params.function.ts +0 -102
- package/src/shared/wasm-codec/functions/encode-group-params.function.ts +0 -28
- package/src/shared/wasm-codec/functions/encode-identifier-list.function.ts +0 -17
- package/src/shared/wasm-codec/functions/encode-kbid-list.function.ts +0 -17
- package/src/shared/wasm-codec/functions/encode-option-string.function.ts +0 -14
- package/src/shared/wasm-codec/functions/encode-recall-params.function.ts +0 -68
- package/src/shared/wasm-codec/functions/encode-search-params.function.ts +0 -12
- package/src/shared/wasm-codec/functions/encode-section-type.function.ts +0 -18
- package/src/shared/wasm-codec/functions/encode-string.function.ts +0 -9
- package/src/shared/wasm-codec/functions/encode-type-filter-param.function.ts +0 -13
- package/src/shared/wasm-codec/functions/encode-u32.function.ts +0 -5
- package/src/shared/wasm-codec/functions/encode-update-section-params.function.ts +0 -16
- package/src/shared/wasm-codec/index.ts +0 -49
- package/src/shared/wasm-codec/typings/add-section-input.model.ts +0 -45
- package/src/shared/wasm-codec/typings/add-section-result.model.ts +0 -28
- package/src/shared/wasm-codec/typings/document-manifest.model.ts +0 -20
- package/src/shared/wasm-codec/typings/document-section.model.ts +0 -12
- package/src/shared/wasm-codec/typings/item-decoder.type.ts +0 -10
- package/src/shared/wasm-codec/typings/near-duplicate.model.ts +0 -16
- package/src/shared/wasm-codec/typings/paged-search-result.model.ts +0 -22
- package/src/shared/wasm-codec/typings/section-match.model.ts +0 -31
- package/src/shared/wasm-codec/typings/section-record-trailing.model.ts +0 -38
- package/src/shared/wasm-codec/typings/section-record.model.ts +0 -66
- package/src/shared/wasm-codec/typings/section-type-result.model.ts +0 -12
- package/src/shared/worker-client/classes/worker-client.class.ts +0 -466
- package/src/shared/worker-client/functions/compute-context-id.function.ts +0 -18
- package/src/shared/worker-client/functions/create-worker-client.function.ts +0 -70
- package/src/shared/worker-client/functions/discover-daemon.function.ts +0 -47
- package/src/shared/worker-client/functions/handle-ipc-data.function.ts +0 -49
- package/src/shared/worker-client/functions/resolve-db-path.function.ts +0 -21
- package/src/shared/worker-client/functions/send-ipc-request.function.ts +0 -39
- package/src/shared/worker-client/functions/spawn-daemon.function.ts +0 -35
- package/src/shared/worker-client/functions/wait-for-daemon.function.ts +0 -34
- package/src/shared/worker-client/index.ts +0 -44
- package/src/shared/worker-client/typings/add-section-result.model.ts +0 -39
- package/src/shared/worker-client/typings/content-result.model.ts +0 -12
- package/src/shared/worker-client/typings/daemon-info.model.ts +0 -7
- package/src/shared/worker-client/typings/export-result.model.ts +0 -14
- package/src/shared/worker-client/typings/gc-result.model.ts +0 -18
- package/src/shared/worker-client/typings/integrity-check-result.model.ts +0 -43
- package/src/shared/worker-client/typings/json-rpc-response.interface.ts +0 -17
- package/src/shared/worker-client/typings/migrate-result.model.ts +0 -11
- package/src/shared/worker-client/typings/pending-call.interface.ts +0 -7
- package/src/shared/worker-client/typings/rebuild-result.model.ts +0 -12
- package/src/shared/worker-client/typings/recall-document.model.ts +0 -16
- package/src/shared/worker-client/typings/recall-params.model.ts +0 -15
- package/src/shared/worker-client/typings/recall-reference.model.ts +0 -32
- package/src/shared/worker-client/typings/recall-result.model.ts +0 -98
- package/src/shared/worker-client/typings/recall-sibling.model.ts +0 -11
- package/src/shared/worker-client/typings/recall-single-result.model.ts +0 -41
- package/src/shared/worker-client/typings/remove-section-result.model.ts +0 -7
- package/src/shared/worker-client/typings/search-params.model.ts +0 -14
- package/src/shared/worker-client/typings/search-result.model.ts +0 -43
- package/src/shared/worker-client/typings/section.model.ts +0 -43
- package/src/shared/worker-client/typings/status-result.model.ts +0 -14
- package/src/shared/worker-client/typings/version-status.model.ts +0 -28
- package/src/shared/worker-client/typings/worker-client-error.interface.ts +0 -8
- package/src/shared/worker-client/typings/worker-client-options.interface.ts +0 -30
- package/src/shared/worker-daemon/classes/ipc-error.class.ts +0 -22
- package/src/shared/worker-daemon/classes/worker-daemon.class.ts +0 -1291
- package/src/shared/worker-daemon/constants/daemon-defaults.constant.ts +0 -29
- package/src/shared/worker-daemon/constants/wasm-method-map.constant.ts +0 -69
- package/src/shared/worker-daemon/functions/build-ipc-error-response.function.ts +0 -16
- package/src/shared/worker-daemon/functions/check-catalog-version.function.ts +0 -54
- package/src/shared/worker-daemon/functions/check-preconditions.function.ts +0 -28
- package/src/shared/worker-daemon/functions/create-host-imports.function.ts +0 -328
- package/src/shared/worker-daemon/functions/create-ipc-server.function.ts +0 -87
- package/src/shared/worker-daemon/functions/detect-stale-pid.function.ts +0 -33
- package/src/shared/worker-daemon/functions/dispatch-request.function.ts +0 -190
- package/src/shared/worker-daemon/functions/handle-check-version.function.ts +0 -74
- package/src/shared/worker-daemon/functions/handle-config-method.function.ts +0 -27
- package/src/shared/worker-daemon/functions/handle-read-ops.function.ts +0 -236
- package/src/shared/worker-daemon/functions/handle-write-ops.function.ts +0 -257
- package/src/shared/worker-daemon/functions/load-wasm-modules.function.ts +0 -95
- package/src/shared/worker-daemon/functions/parse-auto-capture-section.function.ts +0 -51
- package/src/shared/worker-daemon/functions/parse-catalog-version.function.ts +0 -20
- package/src/shared/worker-daemon/functions/parse-embedding-section.function.ts +0 -38
- package/src/shared/worker-daemon/functions/parse-worker-toml.function.ts +0 -104
- package/src/shared/worker-daemon/functions/read-config.function.ts +0 -83
- package/src/shared/worker-daemon/functions/run-startup-integrity-check.function.ts +0 -55
- package/src/shared/worker-daemon/functions/run-worker.function.ts +0 -57
- package/src/shared/worker-daemon/functions/scan-near-duplicates.function.ts +0 -92
- package/src/shared/worker-daemon/functions/start-daemon.function.ts +0 -74
- package/src/shared/worker-daemon/functions/wasm-bridge.function.ts +0 -144
- package/src/shared/worker-daemon/functions/wasm-memory-helpers.function.ts +0 -41
- package/src/shared/worker-daemon/functions/write-lock.function.ts +0 -49
- package/src/shared/worker-daemon/index.ts +0 -16
- package/src/shared/worker-daemon/typings/allocator-ref.interface.ts +0 -16
- package/src/shared/worker-daemon/typings/daemon-config.interface.ts +0 -20
- package/src/shared/worker-daemon/typings/fs-adapter.interface.ts +0 -22
- package/src/shared/worker-daemon/typings/handler-context.interface.ts +0 -19
- package/src/shared/worker-daemon/typings/ipc-handler.interface.ts +0 -39
- package/src/shared/worker-daemon/typings/memory-ref.interface.ts +0 -13
- package/src/shared/worker-daemon/typings/wasm-fn.type.ts +0 -2
- package/src/shared/worker-daemon/typings/wasm-modules.interface.ts +0 -7
- package/src/shared/worker-daemon/typings/write-lock.interface.ts +0 -13
- package/src/wasm/fs-database/kbdb_fs_database.d.ts +0 -259
- package/src/wasm/fs-database/kbdb_fs_database.js +0 -515
- package/src/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/src/wasm/fs-database/kbdb_fs_database_bg.wasm.d.ts +0 -35
- package/src/wasm/fs-database/package.json +0 -13
- package/src/wasm/kb-worker/kbdb_worker.d.ts +0 -650
- package/src/wasm/kb-worker/kbdb_worker.js +0 -1181
- package/src/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/src/wasm/kb-worker/kbdb_worker_bg.wasm.d.ts +0 -77
- package/src/wasm/kb-worker/package.json +0 -13
- package/src/wasm/query-parser/kbdb_query_parser.d.ts +0 -195
- package/src/wasm/query-parser/kbdb_query_parser.js +0 -403
- package/src/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
- package/src/wasm/query-parser/kbdb_query_parser_bg.wasm.d.ts +0 -25
- package/src/wasm/query-parser/package.json +0 -13
- package/src/worker.ts +0 -42
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { decodeString } from './decode-string.function.ts';
|
|
2
|
-
import { decodeU32 } from './decode-u32.function.ts';
|
|
3
|
-
import { decodeF32 } from './decode-f32.function.ts';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A single ranked result item from a paged search response.
|
|
7
|
-
*/
|
|
8
|
-
export interface SectionMatch {
|
|
9
|
-
/** Knowledge-base identifier for the matched section. */
|
|
10
|
-
kbid: string;
|
|
11
|
-
/** Section heading, or `null` when untitled. */
|
|
12
|
-
heading: string | null;
|
|
13
|
-
/** MIME type of the section content. */
|
|
14
|
-
type: string;
|
|
15
|
-
/** Document IDs this section belongs to. */
|
|
16
|
-
docids: string[];
|
|
17
|
-
/** Relevance score from the ranking engine. */
|
|
18
|
-
score: number;
|
|
19
|
-
/**
|
|
20
|
-
* Confidence modifier (0.0–1.0) applied after relaxed search.
|
|
21
|
-
* Always 1.0 for strict-mode results.
|
|
22
|
-
*/
|
|
23
|
-
confidence: number;
|
|
24
|
-
/** KWIC snippet (~150 chars around the best match). */
|
|
25
|
-
snippet: string;
|
|
26
|
-
/** Query terms that matched within this section. */
|
|
27
|
-
matched_terms: string[];
|
|
28
|
-
/**
|
|
29
|
-
* Document fields that contained at least one matched term
|
|
30
|
-
* (e.g. `'title'`, `'body'`).
|
|
31
|
-
*/
|
|
32
|
-
matched_fields: string[];
|
|
33
|
-
/** ISO 8601 creation timestamp of the section. */
|
|
34
|
-
created_at: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Paginated search response envelope returned by the WASM engine.
|
|
39
|
-
*/
|
|
40
|
-
export interface PagedSearchResult {
|
|
41
|
-
/** Matching sections for the current page. */
|
|
42
|
-
items: SectionMatch[];
|
|
43
|
-
/** Total number of matches across all pages. */
|
|
44
|
-
total: number;
|
|
45
|
-
/** Number of results skipped (pagination offset). */
|
|
46
|
-
offset: number;
|
|
47
|
-
/** Maximum results per page. */
|
|
48
|
-
limit: number;
|
|
49
|
-
/** Whether more results exist beyond this page. */
|
|
50
|
-
has_more: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Whether the engine fell back to relaxed (OR-mode) search
|
|
53
|
-
* after strict (AND-mode) returned no results.
|
|
54
|
-
*/
|
|
55
|
-
relaxed: boolean;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function decodeOptionString(
|
|
59
|
-
bytes: Uint8Array,
|
|
60
|
-
offset: number,
|
|
61
|
-
): { value: string | null; bytesRead: number } {
|
|
62
|
-
const tag = bytes[offset];
|
|
63
|
-
if (tag === 0x00) {
|
|
64
|
-
return { value: null, bytesRead: 1 };
|
|
65
|
-
}
|
|
66
|
-
const str = decodeString(bytes, offset + 1);
|
|
67
|
-
return { value: str.value, bytesRead: 1 + str.bytesRead };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Decodes the binary `PagedSearchResult` returned by the
|
|
72
|
-
* `worker_get_result` WASM export after a `worker_search` call.
|
|
73
|
-
*
|
|
74
|
-
* Wire format (little-endian):
|
|
75
|
-
* - `total`: `u32`
|
|
76
|
-
* - `offset`: `u32`
|
|
77
|
-
* - `limit`: `u32`
|
|
78
|
-
* - `has_more`: `u8` (0/1)
|
|
79
|
-
* - `relaxed`: `u8` (0/1)
|
|
80
|
-
* - `item_count`: `u32`
|
|
81
|
-
* - Per item:
|
|
82
|
-
* - `kbid`: `String`
|
|
83
|
-
* - `heading`: `Option<String>`
|
|
84
|
-
* - `section_type`: `String`
|
|
85
|
-
* - `docids`: `u32` count + `String[]`
|
|
86
|
-
* - `score`: `f32`
|
|
87
|
-
* - `confidence`: `f32`
|
|
88
|
-
* - `snippet`: `String`
|
|
89
|
-
* - `matched_terms`: `u32` count + `String[]`
|
|
90
|
-
* - `matched_fields`: `u32` count + `String[]`
|
|
91
|
-
* - `created_at`: `String`
|
|
92
|
-
*/
|
|
93
|
-
export function decodePagedSearchResult(
|
|
94
|
-
bytes: Uint8Array,
|
|
95
|
-
): PagedSearchResult {
|
|
96
|
-
let offset = 0;
|
|
97
|
-
|
|
98
|
-
const total = decodeU32(bytes, offset);
|
|
99
|
-
offset += total.bytesRead;
|
|
100
|
-
|
|
101
|
-
const resultOffset = decodeU32(bytes, offset);
|
|
102
|
-
offset += resultOffset.bytesRead;
|
|
103
|
-
|
|
104
|
-
const limit = decodeU32(bytes, offset);
|
|
105
|
-
offset += limit.bytesRead;
|
|
106
|
-
|
|
107
|
-
const hasMore = bytes[offset] === 1;
|
|
108
|
-
offset += 1;
|
|
109
|
-
|
|
110
|
-
// relaxed flag added after has_more
|
|
111
|
-
const relaxed = offset < bytes.length && bytes[offset] === 1;
|
|
112
|
-
if (offset < bytes.length) {
|
|
113
|
-
offset += 1;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const itemCount = decodeU32(bytes, offset);
|
|
117
|
-
offset += itemCount.bytesRead;
|
|
118
|
-
|
|
119
|
-
const items: SectionMatch[] = [];
|
|
120
|
-
for (let i = 0; i < itemCount.value; i++) {
|
|
121
|
-
const kbid = decodeString(bytes, offset);
|
|
122
|
-
offset += kbid.bytesRead;
|
|
123
|
-
|
|
124
|
-
const heading = decodeOptionString(bytes, offset);
|
|
125
|
-
offset += heading.bytesRead;
|
|
126
|
-
|
|
127
|
-
const sectionType = decodeString(bytes, offset);
|
|
128
|
-
offset += sectionType.bytesRead;
|
|
129
|
-
|
|
130
|
-
const docidCount = decodeU32(bytes, offset);
|
|
131
|
-
offset += docidCount.bytesRead;
|
|
132
|
-
const docids: string[] = [];
|
|
133
|
-
for (let j = 0; j < docidCount.value; j++) {
|
|
134
|
-
const docid = decodeString(bytes, offset);
|
|
135
|
-
offset += docid.bytesRead;
|
|
136
|
-
docids.push(docid.value);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const score = decodeF32(bytes, offset);
|
|
140
|
-
offset += score.bytesRead;
|
|
141
|
-
|
|
142
|
-
// confidence added after score
|
|
143
|
-
const confidence = decodeF32(bytes, offset);
|
|
144
|
-
offset += confidence.bytesRead;
|
|
145
|
-
|
|
146
|
-
const snippet = decodeString(bytes, offset);
|
|
147
|
-
offset += snippet.bytesRead;
|
|
148
|
-
|
|
149
|
-
const termCount = decodeU32(bytes, offset);
|
|
150
|
-
offset += termCount.bytesRead;
|
|
151
|
-
const matched_terms: string[] = [];
|
|
152
|
-
for (let j = 0; j < termCount.value; j++) {
|
|
153
|
-
const term = decodeString(bytes, offset);
|
|
154
|
-
offset += term.bytesRead;
|
|
155
|
-
matched_terms.push(term.value);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// matched_fields added after matched_terms
|
|
159
|
-
const fieldCount = decodeU32(bytes, offset);
|
|
160
|
-
offset += fieldCount.bytesRead;
|
|
161
|
-
const matched_fields: string[] = [];
|
|
162
|
-
for (let j = 0; j < fieldCount.value; j++) {
|
|
163
|
-
const field = decodeString(bytes, offset);
|
|
164
|
-
offset += field.bytesRead;
|
|
165
|
-
matched_fields.push(field.value);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// created_at added after matched_fields
|
|
169
|
-
const createdAt = decodeString(bytes, offset);
|
|
170
|
-
offset += createdAt.bytesRead;
|
|
171
|
-
|
|
172
|
-
items.push({
|
|
173
|
-
kbid: kbid.value,
|
|
174
|
-
heading: heading.value,
|
|
175
|
-
type: sectionType.value,
|
|
176
|
-
docids,
|
|
177
|
-
score: score.value,
|
|
178
|
-
confidence: confidence.value,
|
|
179
|
-
snippet: snippet.value,
|
|
180
|
-
matched_terms,
|
|
181
|
-
matched_fields,
|
|
182
|
-
created_at: createdAt.value,
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return {
|
|
187
|
-
items,
|
|
188
|
-
total: total.value,
|
|
189
|
-
offset: resultOffset.value,
|
|
190
|
-
limit: limit.value,
|
|
191
|
-
has_more: hasMore,
|
|
192
|
-
relaxed,
|
|
193
|
-
};
|
|
194
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { decodeString } from './decode-string.function.ts';
|
|
2
|
-
import { decodeU32 } from './decode-u32.function.ts';
|
|
3
|
-
import { decodeF32 } from './decode-f32.function.ts';
|
|
4
|
-
import { decodeOptionString } from './decode-option-string.function.ts';
|
|
5
|
-
import type { DecodeResult } from './decode-string.function.ts';
|
|
6
|
-
import type { SectionMatch } from '../typings/section-match.model.ts';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Decodes a single `SectionMatch` item from WASM binary output.
|
|
10
|
-
*
|
|
11
|
-
* Wire format per item: kbid, heading (Option<String>),
|
|
12
|
-
* section_type, docids (u32 count + String[]), score (f32),
|
|
13
|
-
* confidence (f32), snippet, matched_terms (u32 + String[]),
|
|
14
|
-
* matched_fields (u32 + String[]), created_at.
|
|
15
|
-
*
|
|
16
|
-
* @param bytes - raw binary buffer
|
|
17
|
-
* @param startOffset - byte position of the item start
|
|
18
|
-
* @returns decoded match and number of bytes consumed
|
|
19
|
-
*/
|
|
20
|
-
export function decodeSectionMatch(
|
|
21
|
-
bytes: Uint8Array,
|
|
22
|
-
startOffset: number,
|
|
23
|
-
): DecodeResult<SectionMatch> {
|
|
24
|
-
let pos = startOffset;
|
|
25
|
-
|
|
26
|
-
const kbid = decodeString(bytes, pos);
|
|
27
|
-
pos += kbid.bytesRead;
|
|
28
|
-
const heading = decodeOptionString(bytes, pos);
|
|
29
|
-
pos += heading.bytesRead;
|
|
30
|
-
const sectionType = decodeString(bytes, pos);
|
|
31
|
-
pos += sectionType.bytesRead;
|
|
32
|
-
const docidCount = decodeU32(bytes, pos);
|
|
33
|
-
pos += docidCount.bytesRead;
|
|
34
|
-
const docids: string[] = [];
|
|
35
|
-
for (let j = 0; j < docidCount.value; j++) {
|
|
36
|
-
const docid = decodeString(bytes, pos);
|
|
37
|
-
pos += docid.bytesRead;
|
|
38
|
-
docids.push(docid.value);
|
|
39
|
-
}
|
|
40
|
-
const score = decodeF32(bytes, pos);
|
|
41
|
-
pos += score.bytesRead;
|
|
42
|
-
const confidence = decodeF32(bytes, pos);
|
|
43
|
-
pos += confidence.bytesRead;
|
|
44
|
-
const snippet = decodeString(bytes, pos);
|
|
45
|
-
pos += snippet.bytesRead;
|
|
46
|
-
const termCount = decodeU32(bytes, pos);
|
|
47
|
-
pos += termCount.bytesRead;
|
|
48
|
-
const matched_terms: string[] = [];
|
|
49
|
-
for (let j = 0; j < termCount.value; j++) {
|
|
50
|
-
const term = decodeString(bytes, pos);
|
|
51
|
-
pos += term.bytesRead;
|
|
52
|
-
matched_terms.push(term.value);
|
|
53
|
-
}
|
|
54
|
-
const fieldCount = decodeU32(bytes, pos);
|
|
55
|
-
pos += fieldCount.bytesRead;
|
|
56
|
-
const matched_fields: string[] = [];
|
|
57
|
-
for (let j = 0; j < fieldCount.value; j++) {
|
|
58
|
-
const field = decodeString(bytes, pos);
|
|
59
|
-
pos += field.bytesRead;
|
|
60
|
-
matched_fields.push(field.value);
|
|
61
|
-
}
|
|
62
|
-
const createdAt = decodeString(bytes, pos);
|
|
63
|
-
pos += createdAt.bytesRead;
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
value: {
|
|
67
|
-
kbid: kbid.value,
|
|
68
|
-
heading: heading.value,
|
|
69
|
-
type: sectionType.value,
|
|
70
|
-
docids,
|
|
71
|
-
score: score.value,
|
|
72
|
-
confidence: confidence.value,
|
|
73
|
-
snippet: snippet.value,
|
|
74
|
-
matched_terms,
|
|
75
|
-
matched_fields,
|
|
76
|
-
created_at: createdAt.value,
|
|
77
|
-
},
|
|
78
|
-
bytesRead: pos - startOffset,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { decodeSectionRecords } from './decode-section-records.function.ts';
|
|
2
|
-
import type { SectionRecord } from './decode-section-records.function.ts';
|
|
3
|
-
|
|
4
|
-
export type { SectionRecord };
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Decodes a WASM byte slice into an array of `SectionRecord` values.
|
|
8
|
-
*
|
|
9
|
-
* Thin wrapper around `decodeSectionRecords` provided as the
|
|
10
|
-
* canonical entry point for list-response decoding from WASM exports
|
|
11
|
-
* such as `worker_list_by_type`.
|
|
12
|
-
*
|
|
13
|
-
* @param bytes - raw bytes returned by a WASM section-list export
|
|
14
|
-
* @returns decoded array of section records
|
|
15
|
-
*/
|
|
16
|
-
export function decodeSectionRecordList(
|
|
17
|
-
bytes: Uint8Array,
|
|
18
|
-
): SectionRecord[] {
|
|
19
|
-
return decodeSectionRecords(bytes);
|
|
20
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { decodeString } from './decode-string.function.ts';
|
|
2
|
-
import { decodeU32 } from './decode-u32.function.ts';
|
|
3
|
-
import { decodeOptionString } from './decode-option-string.function.ts';
|
|
4
|
-
import type { SectionRecordTrailing } from '../typings/section-record-trailing.model.ts';
|
|
5
|
-
|
|
6
|
-
export type { SectionRecordTrailing };
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Decodes the trailing backward-compatible fields of a
|
|
10
|
-
* `SectionRecord` from WASM binary output.
|
|
11
|
-
*
|
|
12
|
-
* Fields present only in newer binary output; each is guarded by a
|
|
13
|
-
* length check. Missing fields default to `null` or `[]`.
|
|
14
|
-
*
|
|
15
|
-
* @param bytes - raw bytes from a WASM section-list export
|
|
16
|
-
* @param startOffset - byte position after the `typeName` field
|
|
17
|
-
* @returns decoded trailing fields and bytes consumed
|
|
18
|
-
*/
|
|
19
|
-
export function decodeSectionRecordTrailing(
|
|
20
|
-
bytes: Uint8Array,
|
|
21
|
-
startOffset: number,
|
|
22
|
-
): SectionRecordTrailing {
|
|
23
|
-
let pos = startOffset;
|
|
24
|
-
|
|
25
|
-
let sourceKey: string | null = null;
|
|
26
|
-
if (pos < bytes.length) {
|
|
27
|
-
const v = decodeOptionString(bytes, pos);
|
|
28
|
-
pos += v.bytesRead;
|
|
29
|
-
sourceKey = v.value;
|
|
30
|
-
}
|
|
31
|
-
let sourcePath: string | null = null;
|
|
32
|
-
if (pos < bytes.length) {
|
|
33
|
-
const v = decodeOptionString(bytes, pos);
|
|
34
|
-
pos += v.bytesRead;
|
|
35
|
-
sourcePath = v.value;
|
|
36
|
-
}
|
|
37
|
-
let sourceMtime: string | null = null;
|
|
38
|
-
if (pos < bytes.length) {
|
|
39
|
-
const v = decodeOptionString(bytes, pos);
|
|
40
|
-
pos += v.bytesRead;
|
|
41
|
-
sourceMtime = v.value;
|
|
42
|
-
}
|
|
43
|
-
let updatedAt: string | null = null;
|
|
44
|
-
if (pos < bytes.length) {
|
|
45
|
-
const v = decodeOptionString(bytes, pos);
|
|
46
|
-
pos += v.bytesRead;
|
|
47
|
-
updatedAt = v.value;
|
|
48
|
-
}
|
|
49
|
-
const tags: string[] = [];
|
|
50
|
-
if (pos < bytes.length) {
|
|
51
|
-
const tagCount = decodeU32(bytes, pos);
|
|
52
|
-
pos += tagCount.bytesRead;
|
|
53
|
-
for (let j = 0; j < tagCount.value; j++) {
|
|
54
|
-
const tagStr = decodeString(bytes, pos);
|
|
55
|
-
pos += tagStr.bytesRead;
|
|
56
|
-
tags.push(tagStr.value);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
let supersedes: string | null = null;
|
|
60
|
-
if (pos < bytes.length) {
|
|
61
|
-
const v = decodeOptionString(bytes, pos);
|
|
62
|
-
pos += v.bytesRead;
|
|
63
|
-
supersedes = v.value;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
sourceKey,
|
|
68
|
-
sourcePath,
|
|
69
|
-
sourceMtime,
|
|
70
|
-
updatedAt,
|
|
71
|
-
tags,
|
|
72
|
-
supersedes,
|
|
73
|
-
bytesRead: pos - startOffset,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { decodeString } from './decode-string.function.ts';
|
|
2
|
-
import { decodeU32 } from './decode-u32.function.ts';
|
|
3
|
-
import { decodeU64 } from './decode-u64.function.ts';
|
|
4
|
-
import { decodeOptionString } from './decode-option-string.function.ts';
|
|
5
|
-
import { decodeSectionType } from './decode-section-type.function.ts';
|
|
6
|
-
import { decodeSectionRecordTrailing } from './decode-section-record-trailing.function.ts';
|
|
7
|
-
import type { DecodeResult } from './decode-string.function.ts';
|
|
8
|
-
import type { SectionRecord } from '../typings/section-record.model.ts';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Decodes a single `SectionRecord` from WASM binary output.
|
|
12
|
-
*
|
|
13
|
-
* Reads all section fields in the order produced by the Rust
|
|
14
|
-
* `SectionRecord::encode` implementation. Trailing fields added
|
|
15
|
-
* after `typeName` default to `null` / `[]` when absent.
|
|
16
|
-
*
|
|
17
|
-
* @param bytes - raw bytes returned by a WASM section-list export
|
|
18
|
-
* @param startOffset - byte position of the record start
|
|
19
|
-
* @returns decoded record and number of bytes consumed
|
|
20
|
-
*/
|
|
21
|
-
export function decodeSectionRecord(
|
|
22
|
-
bytes: Uint8Array,
|
|
23
|
-
startOffset: number,
|
|
24
|
-
): DecodeResult<SectionRecord> {
|
|
25
|
-
let pos = startOffset;
|
|
26
|
-
|
|
27
|
-
const kbid = decodeString(bytes, pos);
|
|
28
|
-
pos += kbid.bytesRead;
|
|
29
|
-
const docid = decodeOptionString(bytes, pos);
|
|
30
|
-
pos += docid.bytesRead;
|
|
31
|
-
const st = decodeSectionType(bytes, pos);
|
|
32
|
-
pos += st.bytesRead;
|
|
33
|
-
const title = decodeOptionString(bytes, pos);
|
|
34
|
-
pos += title.bytesRead;
|
|
35
|
-
const description = decodeOptionString(bytes, pos);
|
|
36
|
-
pos += description.bytesRead;
|
|
37
|
-
const content = decodeString(bytes, pos);
|
|
38
|
-
pos += content.bytesRead;
|
|
39
|
-
const size = decodeU32(bytes, pos);
|
|
40
|
-
pos += size.bytesRead;
|
|
41
|
-
const createdAt = decodeU64(bytes, pos);
|
|
42
|
-
pos += createdAt.bytesRead;
|
|
43
|
-
const checksum = decodeString(bytes, pos);
|
|
44
|
-
pos += checksum.bytesRead;
|
|
45
|
-
const tokenCount = decodeU32(bytes, pos);
|
|
46
|
-
pos += tokenCount.bytesRead;
|
|
47
|
-
const headingTokenCount = decodeU32(bytes, pos);
|
|
48
|
-
pos += headingTokenCount.bytesRead;
|
|
49
|
-
const bodyTokenCount = decodeU32(bytes, pos);
|
|
50
|
-
pos += bodyTokenCount.bytesRead;
|
|
51
|
-
const codeTokenCount = decodeU32(bytes, pos);
|
|
52
|
-
pos += codeTokenCount.bytesRead;
|
|
53
|
-
const typeName = decodeString(bytes, pos);
|
|
54
|
-
pos += typeName.bytesRead;
|
|
55
|
-
|
|
56
|
-
const trailing = decodeSectionRecordTrailing(bytes, pos);
|
|
57
|
-
pos += trailing.bytesRead;
|
|
58
|
-
|
|
59
|
-
const record: SectionRecord = {
|
|
60
|
-
kbid: kbid.value,
|
|
61
|
-
docid: docid.value,
|
|
62
|
-
sectionType: st.sectionType,
|
|
63
|
-
title: title.value,
|
|
64
|
-
description: description.value,
|
|
65
|
-
content: content.value,
|
|
66
|
-
size: size.value,
|
|
67
|
-
createdAt: createdAt.value,
|
|
68
|
-
checksum: checksum.value,
|
|
69
|
-
tokenCount: tokenCount.value,
|
|
70
|
-
headingTokenCount: headingTokenCount.value,
|
|
71
|
-
bodyTokenCount: bodyTokenCount.value,
|
|
72
|
-
codeTokenCount: codeTokenCount.value,
|
|
73
|
-
typeName: typeName.value,
|
|
74
|
-
sourceKey: trailing.sourceKey,
|
|
75
|
-
sourcePath: trailing.sourcePath,
|
|
76
|
-
sourceMtime: trailing.sourceMtime,
|
|
77
|
-
updatedAt: trailing.updatedAt,
|
|
78
|
-
tags: trailing.tags,
|
|
79
|
-
supersedes: trailing.supersedes,
|
|
80
|
-
};
|
|
81
|
-
if (st.mimeType !== undefined) {
|
|
82
|
-
record.mimeType = st.mimeType;
|
|
83
|
-
}
|
|
84
|
-
return { value: record, bytesRead: pos - startOffset };
|
|
85
|
-
}
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import { decodeString } from './decode-string.function.ts';
|
|
2
|
-
import { decodeU32 } from './decode-u32.function.ts';
|
|
3
|
-
import { decodeU64 } from './decode-u64.function.ts';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A single section record decoded from WASM binary output.
|
|
7
|
-
*
|
|
8
|
-
* Represents a stored knowledge-base section with all its metadata
|
|
9
|
-
* and token counts as returned by `worker_read_sections` or
|
|
10
|
-
* `worker_list_by_type`.
|
|
11
|
-
*/
|
|
12
|
-
export interface SectionRecord {
|
|
13
|
-
/** Unique knowledge-base identifier for this section. */
|
|
14
|
-
kbid: string;
|
|
15
|
-
/** Document identifier this section belongs to, or `null`. */
|
|
16
|
-
docid: string | null;
|
|
17
|
-
/** Semantic type discriminant: `'text'`, `'code'`, or `'image'`. */
|
|
18
|
-
sectionType: string;
|
|
19
|
-
/** MIME type string, present only for `'code'` and `'image'` types. */
|
|
20
|
-
mimeType?: string;
|
|
21
|
-
/** Human-readable title for the section, or `null`. */
|
|
22
|
-
title: string | null;
|
|
23
|
-
/** Optional description of the section content, or `null`. */
|
|
24
|
-
description: string | null;
|
|
25
|
-
/** Raw text or base64-encoded content of the section. */
|
|
26
|
-
content: string;
|
|
27
|
-
/** Byte size of the stored content. */
|
|
28
|
-
size: number;
|
|
29
|
-
/** Section creation timestamp as a Unix epoch value. */
|
|
30
|
-
createdAt: bigint;
|
|
31
|
-
/** Integrity checksum of the stored content. */
|
|
32
|
-
checksum: string;
|
|
33
|
-
/** Total number of tokens in the section. */
|
|
34
|
-
tokenCount: number;
|
|
35
|
-
/** Number of heading tokens in the section. */
|
|
36
|
-
headingTokenCount: number;
|
|
37
|
-
/** Number of body tokens in the section. */
|
|
38
|
-
bodyTokenCount: number;
|
|
39
|
-
/** Number of code tokens in the section. */
|
|
40
|
-
codeTokenCount: number;
|
|
41
|
-
/** Application-level type name assigned to this section. */
|
|
42
|
-
typeName: string;
|
|
43
|
-
/**
|
|
44
|
-
* Stable logical identity derived from source path and heading.
|
|
45
|
-
* `null` for stdin input or sections without a source path.
|
|
46
|
-
*/
|
|
47
|
-
sourceKey: string | null;
|
|
48
|
-
/**
|
|
49
|
-
* Absolute path of the source file that was learned.
|
|
50
|
-
* `null` for stdin input or programmatic API calls.
|
|
51
|
-
*/
|
|
52
|
-
sourcePath: string | null;
|
|
53
|
-
/**
|
|
54
|
-
* ISO 8601 modified time of the source file at learn time.
|
|
55
|
-
* `null` when no source file exists.
|
|
56
|
-
*/
|
|
57
|
-
sourceMtime: string | null;
|
|
58
|
-
/**
|
|
59
|
-
* ISO 8601 timestamp of the last supersession.
|
|
60
|
-
* `null` on first creation.
|
|
61
|
-
*/
|
|
62
|
-
updatedAt: string | null;
|
|
63
|
-
/** User-supplied tags for scoping and filtering. */
|
|
64
|
-
tags: string[];
|
|
65
|
-
/**
|
|
66
|
-
* The kbid of the section this one replaced via supersession.
|
|
67
|
-
* `null` on first creation or non-superseding additions.
|
|
68
|
-
*/
|
|
69
|
-
supersedes: string | null;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function decodeOptionString(
|
|
73
|
-
bytes: Uint8Array,
|
|
74
|
-
offset: number,
|
|
75
|
-
): { value: string | null; bytesRead: number } {
|
|
76
|
-
const tag = bytes[offset];
|
|
77
|
-
if (tag === 0x00) {
|
|
78
|
-
return { value: null, bytesRead: 1 };
|
|
79
|
-
}
|
|
80
|
-
const str = decodeString(bytes, offset + 1);
|
|
81
|
-
return { value: str.value, bytesRead: 1 + str.bytesRead };
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function decodeSectionType(
|
|
85
|
-
bytes: Uint8Array,
|
|
86
|
-
offset: number,
|
|
87
|
-
): {
|
|
88
|
-
sectionType: string;
|
|
89
|
-
mimeType?: string;
|
|
90
|
-
bytesRead: number;
|
|
91
|
-
} {
|
|
92
|
-
const tag = bytes[offset];
|
|
93
|
-
if (tag === 0x00) {
|
|
94
|
-
return { sectionType: 'text', bytesRead: 1 };
|
|
95
|
-
}
|
|
96
|
-
const mime = decodeString(bytes, offset + 1);
|
|
97
|
-
const kind = tag === 0x01 ? 'code' : 'image';
|
|
98
|
-
return {
|
|
99
|
-
sectionType: kind,
|
|
100
|
-
mimeType: mime.value,
|
|
101
|
-
bytesRead: 1 + mime.bytesRead,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Decodes a list of `SectionRecord` values from WASM binary output.
|
|
107
|
-
*
|
|
108
|
-
* Reads a leading u32 count followed by that many encoded records.
|
|
109
|
-
* Each record is decoded in field order as produced by the Rust
|
|
110
|
-
* `SectionRecord::encode` implementation.
|
|
111
|
-
*
|
|
112
|
-
* Trailing fields (`sourceKey`, `sourcePath`, `sourceMtime`,
|
|
113
|
-
* `updatedAt`, `tags`, `supersedes`) were added after the initial
|
|
114
|
-
* format. When decoding legacy bytes that stop after `typeName`,
|
|
115
|
-
* those fields default to `null` / `[]`. This matches the Rust
|
|
116
|
-
* decoder's backward-compatibility guards.
|
|
117
|
-
*
|
|
118
|
-
* @param bytes - raw bytes returned by a WASM section-list export
|
|
119
|
-
* @returns decoded array of section records, empty when count is zero
|
|
120
|
-
*/
|
|
121
|
-
export function decodeSectionRecords(
|
|
122
|
-
bytes: Uint8Array,
|
|
123
|
-
): SectionRecord[] {
|
|
124
|
-
let offset = 0;
|
|
125
|
-
const count = decodeU32(bytes, offset);
|
|
126
|
-
offset += count.bytesRead;
|
|
127
|
-
|
|
128
|
-
const records: SectionRecord[] = [];
|
|
129
|
-
for (let i = 0; i < count.value; i++) {
|
|
130
|
-
const kbid = decodeString(bytes, offset);
|
|
131
|
-
offset += kbid.bytesRead;
|
|
132
|
-
|
|
133
|
-
const docid = decodeOptionString(bytes, offset);
|
|
134
|
-
offset += docid.bytesRead;
|
|
135
|
-
|
|
136
|
-
const st = decodeSectionType(bytes, offset);
|
|
137
|
-
offset += st.bytesRead;
|
|
138
|
-
|
|
139
|
-
const title = decodeOptionString(bytes, offset);
|
|
140
|
-
offset += title.bytesRead;
|
|
141
|
-
|
|
142
|
-
const description = decodeOptionString(bytes, offset);
|
|
143
|
-
offset += description.bytesRead;
|
|
144
|
-
|
|
145
|
-
const content = decodeString(bytes, offset);
|
|
146
|
-
offset += content.bytesRead;
|
|
147
|
-
|
|
148
|
-
const size = decodeU32(bytes, offset);
|
|
149
|
-
offset += size.bytesRead;
|
|
150
|
-
|
|
151
|
-
const createdAt = decodeU64(bytes, offset);
|
|
152
|
-
offset += createdAt.bytesRead;
|
|
153
|
-
|
|
154
|
-
const checksum = decodeString(bytes, offset);
|
|
155
|
-
offset += checksum.bytesRead;
|
|
156
|
-
|
|
157
|
-
const tokenCount = decodeU32(bytes, offset);
|
|
158
|
-
offset += tokenCount.bytesRead;
|
|
159
|
-
|
|
160
|
-
const headingTokenCount = decodeU32(bytes, offset);
|
|
161
|
-
offset += headingTokenCount.bytesRead;
|
|
162
|
-
|
|
163
|
-
const bodyTokenCount = decodeU32(bytes, offset);
|
|
164
|
-
offset += bodyTokenCount.bytesRead;
|
|
165
|
-
|
|
166
|
-
const codeTokenCount = decodeU32(bytes, offset);
|
|
167
|
-
offset += codeTokenCount.bytesRead;
|
|
168
|
-
|
|
169
|
-
const typeName = decodeString(bytes, offset);
|
|
170
|
-
offset += typeName.bytesRead;
|
|
171
|
-
|
|
172
|
-
// New trailing fields -- use length guards for backward compat.
|
|
173
|
-
let sourceKey: string | null = null;
|
|
174
|
-
if (offset < bytes.length) {
|
|
175
|
-
const v = decodeOptionString(bytes, offset);
|
|
176
|
-
offset += v.bytesRead;
|
|
177
|
-
sourceKey = v.value;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
let sourcePath: string | null = null;
|
|
181
|
-
if (offset < bytes.length) {
|
|
182
|
-
const v = decodeOptionString(bytes, offset);
|
|
183
|
-
offset += v.bytesRead;
|
|
184
|
-
sourcePath = v.value;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
let sourceMtime: string | null = null;
|
|
188
|
-
if (offset < bytes.length) {
|
|
189
|
-
const v = decodeOptionString(bytes, offset);
|
|
190
|
-
offset += v.bytesRead;
|
|
191
|
-
sourceMtime = v.value;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
let updatedAt: string | null = null;
|
|
195
|
-
if (offset < bytes.length) {
|
|
196
|
-
const v = decodeOptionString(bytes, offset);
|
|
197
|
-
offset += v.bytesRead;
|
|
198
|
-
updatedAt = v.value;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
let tags: string[] = [];
|
|
202
|
-
if (offset < bytes.length) {
|
|
203
|
-
const tagCount = decodeU32(bytes, offset);
|
|
204
|
-
offset += tagCount.bytesRead;
|
|
205
|
-
tags = [];
|
|
206
|
-
for (let j = 0; j < tagCount.value; j++) {
|
|
207
|
-
const tag = decodeString(bytes, offset);
|
|
208
|
-
offset += tag.bytesRead;
|
|
209
|
-
tags.push(tag.value);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
let supersedes: string | null = null;
|
|
214
|
-
if (offset < bytes.length) {
|
|
215
|
-
const v = decodeOptionString(bytes, offset);
|
|
216
|
-
offset += v.bytesRead;
|
|
217
|
-
supersedes = v.value;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const record: SectionRecord = {
|
|
221
|
-
kbid: kbid.value,
|
|
222
|
-
docid: docid.value,
|
|
223
|
-
sectionType: st.sectionType,
|
|
224
|
-
title: title.value,
|
|
225
|
-
description: description.value,
|
|
226
|
-
content: content.value,
|
|
227
|
-
size: size.value,
|
|
228
|
-
createdAt: createdAt.value,
|
|
229
|
-
checksum: checksum.value,
|
|
230
|
-
tokenCount: tokenCount.value,
|
|
231
|
-
headingTokenCount: headingTokenCount.value,
|
|
232
|
-
bodyTokenCount: bodyTokenCount.value,
|
|
233
|
-
codeTokenCount: codeTokenCount.value,
|
|
234
|
-
typeName: typeName.value,
|
|
235
|
-
sourceKey,
|
|
236
|
-
sourcePath,
|
|
237
|
-
sourceMtime,
|
|
238
|
-
updatedAt,
|
|
239
|
-
tags,
|
|
240
|
-
supersedes,
|
|
241
|
-
};
|
|
242
|
-
if (st.mimeType !== undefined) {
|
|
243
|
-
record.mimeType = st.mimeType;
|
|
244
|
-
}
|
|
245
|
-
records.push(record);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return records;
|
|
249
|
-
}
|