@dikolab/kbdb 0.1.6 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -9
- package/dist/cli.cjs +181 -50
- package/dist/cli.cjs.map +3 -3
- package/dist/cli.mjs +181 -50
- package/dist/cli.mjs.map +3 -3
- package/dist/kbdb-worker.cjs +283 -29
- package/dist/kbdb-worker.cjs.map +4 -4
- package/dist/mod.cjs +13 -2
- package/dist/mod.cjs.map +2 -2
- package/dist/mod.d.ts +25 -0
- package/dist/mod.mjs +13 -2
- package/dist/mod.mjs.map +2 -2
- package/dist/src/cli.d.ts +8 -0
- package/dist/src/shared/cli/functions/format-output.function.d.ts +7 -7
- package/dist/src/shared/cli/functions/run-search.function.d.ts +25 -16
- package/dist/src/shared/cli/index.d.ts +1 -1
- package/dist/src/shared/cli/typings/cli-options.interface.d.ts +2 -0
- package/dist/src/shared/cli/typings/search-display.model.d.ts +25 -7
- package/dist/src/shared/mcp/functions/handle-recall.function.d.ts +29 -0
- package/dist/src/shared/mcp/typings/mcp-client.interface.d.ts +30 -11
- package/dist/src/shared/version/constants/version.constant.d.ts +1 -1
- package/dist/src/shared/wasm-codec/functions/decode-recall-result.function.d.ts +28 -0
- package/dist/src/shared/wasm-codec/functions/decode-scored-results.function.d.ts +14 -7
- package/dist/src/shared/wasm-codec/functions/encode-recall-params.function.d.ts +21 -0
- package/dist/src/shared/wasm-codec/functions/encode-search-params.function.d.ts +1 -1
- package/dist/src/shared/wasm-codec/index.d.ts +5 -2
- package/dist/src/shared/worker-client/classes/worker-client.class.d.ts +13 -3
- package/dist/src/shared/worker-client/index.d.ts +2 -1
- package/dist/src/shared/worker-client/typings/recall-result.model.d.ts +94 -0
- package/dist/src/shared/worker-client/typings/search-params.model.d.ts +2 -0
- package/dist/src/shared/worker-client/typings/search-result.model.d.ts +23 -7
- package/dist/src/shared/worker-daemon/classes/worker-daemon.class.d.ts +1 -0
- package/dist/src/worker.d.ts +7 -0
- package/dist/wasm/fs-database/kbdb_fs_database.d.ts +18 -0
- package/dist/wasm/fs-database/kbdb_fs_database.js +30 -0
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm.d.ts +2 -0
- package/dist/wasm/kb-worker/kbdb_worker.d.ts +38 -0
- package/dist/wasm/kb-worker/kbdb_worker.js +56 -0
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm.d.ts +3 -0
- package/dist/worker.mjs +283 -29
- package/dist/worker.mjs.map +4 -4
- package/docs/details/README.md +26 -0
- package/docs/details/cli.md +608 -0
- package/docs/details/library-api.md +406 -0
- package/docs/details/mcp-server.md +430 -0
- package/docs/details/search-and-ranking.md +457 -0
- package/docs/details/storage.md +529 -0
- package/docs/goals/agents.md +751 -0
- package/docs/goals/architecture.svg +198 -0
- package/docs/goals/cli.md +2308 -0
- package/docs/goals/content-composer.md +609 -0
- package/docs/goals/content-parser.md +279 -0
- package/docs/goals/database.md +1452 -0
- package/docs/goals/document.md +368 -0
- package/docs/goals/mcp.md +1467 -0
- package/docs/goals/overview.md +124 -0
- package/docs/goals/query-parser.md +271 -0
- package/docs/goals/query-result.md +693 -0
- package/docs/goals/skills.md +738 -0
- package/docs/goals/worker-client.md +944 -0
- package/docs/goals/worker-daemon.md +1447 -0
- package/docs/modules/overview.md +298 -0
- package/docs/modules/rust/fs-database/functions/document.md +48 -0
- package/docs/modules/rust/fs-database/functions/integrity.md +68 -0
- package/docs/modules/rust/fs-database/functions/io.md +87 -0
- package/docs/modules/rust/fs-database/functions/module.md +22 -0
- package/docs/modules/rust/fs-database/functions/query-exec.md +44 -0
- package/docs/modules/rust/fs-database/functions/section.md +59 -0
- package/docs/modules/rust/fs-database/indexes/btree.md +35 -0
- package/docs/modules/rust/fs-database/indexes/corpus.md +61 -0
- package/docs/modules/rust/fs-database/indexes/inverted.md +60 -0
- package/docs/modules/rust/fs-database/indexes/module.md +64 -0
- package/docs/modules/rust/fs-database/indexes/positional.md +39 -0
- package/docs/modules/rust/fs-database/module.md +149 -0
- package/docs/modules/rust/fs-database/types/catalog.md +53 -0
- package/docs/modules/rust/fs-database/types/module.md +12 -0
- package/docs/modules/rust/fs-database/types/section.md +101 -0
- package/docs/modules/rust/kb-worker/functions/compose.md +57 -0
- package/docs/modules/rust/kb-worker/functions/module.md +20 -0
- package/docs/modules/rust/kb-worker/functions/retrieve.md +194 -0
- package/docs/modules/rust/kb-worker/functions/search.md +173 -0
- package/docs/modules/rust/kb-worker/functions/write.md +172 -0
- package/docs/modules/rust/kb-worker/module.md +171 -0
- package/docs/modules/rust/kb-worker/types/cache.md +90 -0
- package/docs/modules/rust/kb-worker/types/context.md +26 -0
- package/docs/modules/rust/kb-worker/types/module.md +16 -0
- package/docs/modules/rust/kb-worker/types/status.md +29 -0
- package/docs/modules/rust/kb-worker/types/token.md +50 -0
- package/docs/modules/rust/overview.md +495 -0
- package/docs/modules/rust/query-parser/functions/extract.md +56 -0
- package/docs/modules/rust/query-parser/functions/module.md +16 -0
- package/docs/modules/rust/query-parser/functions/parse.md +33 -0
- package/docs/modules/rust/query-parser/functions/pipeline.md +103 -0
- package/docs/modules/rust/query-parser/functions/rank.md +85 -0
- package/docs/modules/rust/query-parser/module.md +136 -0
- package/docs/modules/rust/query-parser/types/cache.md +39 -0
- package/docs/modules/rust/query-parser/types/keyphrase.md +60 -0
- package/docs/modules/rust/query-parser/types/module.md +17 -0
- package/docs/modules/rust/query-parser/types/token.md +42 -0
- package/docs/modules/rust/shared/content-composer/functions.md +114 -0
- package/docs/modules/rust/shared/content-composer/module.md +147 -0
- package/docs/modules/rust/shared/content-composer/types.md +93 -0
- package/docs/modules/rust/shared/content-parser/functions.md +72 -0
- package/docs/modules/rust/shared/content-parser/module.md +99 -0
- package/docs/modules/rust/shared/content-parser/types.md +71 -0
- package/docs/modules/rust/shared/corpus/module.md +24 -0
- package/docs/modules/rust/shared/corpus/types.md +141 -0
- package/docs/modules/rust/shared/document/module.md +25 -0
- package/docs/modules/rust/shared/document/types.md +154 -0
- package/docs/modules/rust/shared/encode/module.md +22 -0
- package/docs/modules/rust/shared/encode/traits.md +304 -0
- package/docs/modules/rust/shared/error/module.md +28 -0
- package/docs/modules/rust/shared/error/types.md +302 -0
- package/docs/modules/rust/shared/kbid/module.md +24 -0
- package/docs/modules/rust/shared/kbid/types.md +147 -0
- package/docs/modules/rust/shared/memory/functions.md +209 -0
- package/docs/modules/rust/shared/memory/module.md +24 -0
- package/docs/modules/rust/shared/module.md +168 -0
- package/docs/modules/rust/shared/query/module.md +27 -0
- package/docs/modules/rust/shared/query/types.md +236 -0
- package/docs/modules/rust/shared/section/module.md +25 -0
- package/docs/modules/rust/shared/section/types.md +294 -0
- package/docs/modules/rust/shared/term/module.md +25 -0
- package/docs/modules/rust/shared/term/types.md +139 -0
- package/docs/modules/typescript/cli.md +129 -0
- package/docs/modules/typescript/kbdb-worker.md +135 -0
- package/docs/modules/typescript/overview.md +378 -0
- package/docs/modules/typescript/shared/cli/constants.md +23 -0
- package/docs/modules/typescript/shared/cli/functions.md +630 -0
- package/docs/modules/typescript/shared/cli/module.md +125 -0
- package/docs/modules/typescript/shared/cli/typings.md +172 -0
- package/docs/modules/typescript/shared/hash/functions.md +20 -0
- package/docs/modules/typescript/shared/hash/module.md +21 -0
- package/docs/modules/typescript/shared/mcp/classes.md +179 -0
- package/docs/modules/typescript/shared/mcp/functions.md +386 -0
- package/docs/modules/typescript/shared/mcp/module.md +160 -0
- package/docs/modules/typescript/shared/mcp/typings.md +522 -0
- package/docs/modules/typescript/shared/module.md +94 -0
- package/docs/modules/typescript/shared/platform/functions.md +42 -0
- package/docs/modules/typescript/shared/platform/module.md +25 -0
- package/docs/modules/typescript/shared/runtime/functions.md +26 -0
- package/docs/modules/typescript/shared/runtime/module.md +27 -0
- package/docs/modules/typescript/shared/runtime/typings.md +13 -0
- package/docs/modules/typescript/shared/version/module.md +27 -0
- package/docs/modules/typescript/shared/wasm-codec/functions.md +391 -0
- package/docs/modules/typescript/shared/wasm-codec/module.md +98 -0
- package/docs/modules/typescript/shared/worker-client/classes.md +264 -0
- package/docs/modules/typescript/shared/worker-client/functions.md +175 -0
- package/docs/modules/typescript/shared/worker-client/module.md +84 -0
- package/docs/modules/typescript/shared/worker-client/typings.md +508 -0
- package/docs/modules/typescript/shared/worker-daemon/classes.md +239 -0
- package/docs/modules/typescript/shared/worker-daemon/constants.md +37 -0
- package/docs/modules/typescript/shared/worker-daemon/functions.md +221 -0
- package/docs/modules/typescript/shared/worker-daemon/module.md +112 -0
- package/docs/modules/typescript/shared/worker-daemon/typings.md +126 -0
- package/docs/overview.md +188 -0
- package/docs/release-notes/0.1.0.md +189 -0
- package/docs/release-notes/0.1.1.md +46 -0
- package/docs/release-notes/0.1.2.md +38 -0
- package/docs/release-notes/0.1.3.md +42 -0
- package/docs/release-notes/0.2.0.md +147 -0
- package/docs/release-notes/README.md +9 -0
- package/mod.ts +26 -0
- package/package.json +8 -2
- package/src/cli.ts +9 -0
- package/src/shared/cli/functions/dispatch-command.function.ts +3 -3
- package/src/shared/cli/functions/format-output.function.ts +41 -34
- package/src/shared/cli/functions/parse-args.function.ts +7 -0
- package/src/shared/cli/functions/run-search.function.ts +53 -27
- package/src/shared/cli/index.ts +4 -1
- package/src/shared/cli/typings/cli-options.interface.ts +2 -0
- package/src/shared/cli/typings/search-display.model.ts +26 -7
- package/src/shared/mcp/functions/create-tool-definitions.function.ts +64 -4
- package/src/shared/mcp/functions/handle-recall.function.ts +66 -0
- package/src/shared/mcp/functions/handle-tool-call.function.ts +11 -1
- package/src/shared/mcp/typings/mcp-client.interface.ts +33 -15
- package/src/shared/version/constants/version.constant.ts +1 -1
- package/src/shared/wasm-codec/functions/decode-recall-result.function.ts +267 -0
- package/src/shared/wasm-codec/functions/decode-scored-results.function.ts +81 -27
- package/src/shared/wasm-codec/functions/encode-recall-params.function.ts +68 -0
- package/src/shared/wasm-codec/functions/encode-search-params.function.ts +4 -1
- package/src/shared/wasm-codec/index.ts +11 -3
- package/src/shared/worker-client/classes/worker-client.class.ts +24 -4
- package/src/shared/worker-client/index.ts +11 -1
- package/src/shared/worker-client/typings/recall-result.model.ts +98 -0
- package/src/shared/worker-client/typings/search-params.model.ts +2 -0
- package/src/shared/worker-client/typings/search-result.model.ts +24 -7
- package/src/shared/worker-daemon/classes/worker-daemon.class.ts +25 -4
- package/src/wasm/fs-database/kbdb_fs_database.d.ts +18 -0
- package/src/wasm/fs-database/kbdb_fs_database.js +30 -0
- package/src/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/src/wasm/fs-database/kbdb_fs_database_bg.wasm.d.ts +2 -0
- package/src/wasm/kb-worker/kbdb_worker.d.ts +38 -0
- package/src/wasm/kb-worker/kbdb_worker.js +56 -0
- package/src/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/src/wasm/kb-worker/kbdb_worker_bg.wasm.d.ts +3 -0
- package/src/worker.ts +8 -0
package/dist/kbdb-worker.cjs
CHANGED
|
@@ -568,10 +568,13 @@ function encodeIdentifierList(ids) {
|
|
|
568
568
|
|
|
569
569
|
// src/shared/wasm-codec/functions/encode-search-params.function.ts
|
|
570
570
|
var encoder2 = new TextEncoder();
|
|
571
|
-
function encodeSearchParams(query, mode = "and", limit = 20) {
|
|
572
|
-
return encoder2.encode(
|
|
571
|
+
function encodeSearchParams(query, mode = "and", limit = 20, offset = 0) {
|
|
572
|
+
return encoder2.encode(
|
|
573
|
+
`${query}
|
|
573
574
|
${mode}
|
|
574
|
-
${String(limit)}
|
|
575
|
+
${String(limit)}
|
|
576
|
+
${String(offset)}`
|
|
577
|
+
);
|
|
575
578
|
}
|
|
576
579
|
|
|
577
580
|
// src/shared/wasm-codec/functions/encode-type-filter-param.function.ts
|
|
@@ -634,40 +637,75 @@ function decodeU64(bytes, offset) {
|
|
|
634
637
|
}
|
|
635
638
|
|
|
636
639
|
// src/shared/wasm-codec/functions/decode-scored-results.function.ts
|
|
637
|
-
function
|
|
640
|
+
function decodeOptionString(bytes, offset) {
|
|
641
|
+
const tag = bytes[offset];
|
|
642
|
+
if (tag === 0) {
|
|
643
|
+
return { value: null, bytesRead: 1 };
|
|
644
|
+
}
|
|
645
|
+
const str = decodeString(bytes, offset + 1);
|
|
646
|
+
return { value: str.value, bytesRead: 1 + str.bytesRead };
|
|
647
|
+
}
|
|
648
|
+
function decodePagedSearchResult(bytes) {
|
|
638
649
|
let offset = 0;
|
|
639
|
-
const
|
|
640
|
-
offset +=
|
|
641
|
-
const
|
|
642
|
-
|
|
650
|
+
const total = decodeU32(bytes, offset);
|
|
651
|
+
offset += total.bytesRead;
|
|
652
|
+
const resultOffset = decodeU32(bytes, offset);
|
|
653
|
+
offset += resultOffset.bytesRead;
|
|
654
|
+
const limit = decodeU32(bytes, offset);
|
|
655
|
+
offset += limit.bytesRead;
|
|
656
|
+
const hasMore = bytes[offset] === 1;
|
|
657
|
+
offset += 1;
|
|
658
|
+
const itemCount = decodeU32(bytes, offset);
|
|
659
|
+
offset += itemCount.bytesRead;
|
|
660
|
+
const items = [];
|
|
661
|
+
for (let i = 0; i < itemCount.value; i++) {
|
|
643
662
|
const kbid = decodeString(bytes, offset);
|
|
644
663
|
offset += kbid.bytesRead;
|
|
664
|
+
const heading = decodeOptionString(bytes, offset);
|
|
665
|
+
offset += heading.bytesRead;
|
|
666
|
+
const sectionType = decodeString(bytes, offset);
|
|
667
|
+
offset += sectionType.bytesRead;
|
|
668
|
+
const docidCount = decodeU32(bytes, offset);
|
|
669
|
+
offset += docidCount.bytesRead;
|
|
670
|
+
const docids = [];
|
|
671
|
+
for (let j = 0; j < docidCount.value; j++) {
|
|
672
|
+
const docid = decodeString(bytes, offset);
|
|
673
|
+
offset += docid.bytesRead;
|
|
674
|
+
docids.push(docid.value);
|
|
675
|
+
}
|
|
645
676
|
const score = decodeF32(bytes, offset);
|
|
646
677
|
offset += score.bytesRead;
|
|
647
|
-
const
|
|
648
|
-
offset +=
|
|
649
|
-
const
|
|
650
|
-
|
|
678
|
+
const snippet = decodeString(bytes, offset);
|
|
679
|
+
offset += snippet.bytesRead;
|
|
680
|
+
const termCount = decodeU32(bytes, offset);
|
|
681
|
+
offset += termCount.bytesRead;
|
|
682
|
+
const matched_terms = [];
|
|
683
|
+
for (let j = 0; j < termCount.value; j++) {
|
|
651
684
|
const term = decodeString(bytes, offset);
|
|
652
685
|
offset += term.bytesRead;
|
|
653
|
-
|
|
654
|
-
offset += freq.bytesRead;
|
|
655
|
-
matches.push({
|
|
656
|
-
term: term.value,
|
|
657
|
-
frequency: freq.value
|
|
658
|
-
});
|
|
686
|
+
matched_terms.push(term.value);
|
|
659
687
|
}
|
|
660
|
-
|
|
688
|
+
items.push({
|
|
661
689
|
kbid: kbid.value,
|
|
690
|
+
heading: heading.value,
|
|
691
|
+
type: sectionType.value,
|
|
692
|
+
docids,
|
|
662
693
|
score: score.value,
|
|
663
|
-
|
|
694
|
+
snippet: snippet.value,
|
|
695
|
+
matched_terms
|
|
664
696
|
});
|
|
665
697
|
}
|
|
666
|
-
return
|
|
698
|
+
return {
|
|
699
|
+
items,
|
|
700
|
+
total: total.value,
|
|
701
|
+
offset: resultOffset.value,
|
|
702
|
+
limit: limit.value,
|
|
703
|
+
has_more: hasMore
|
|
704
|
+
};
|
|
667
705
|
}
|
|
668
706
|
|
|
669
707
|
// src/shared/wasm-codec/functions/decode-section-records.function.ts
|
|
670
|
-
function
|
|
708
|
+
function decodeOptionString2(bytes, offset) {
|
|
671
709
|
const tag = bytes[offset];
|
|
672
710
|
if (tag === 0) {
|
|
673
711
|
return { value: null, bytesRead: 1 };
|
|
@@ -696,13 +734,13 @@ function decodeSectionRecords(bytes) {
|
|
|
696
734
|
for (let i = 0; i < count.value; i++) {
|
|
697
735
|
const kbid = decodeString(bytes, offset);
|
|
698
736
|
offset += kbid.bytesRead;
|
|
699
|
-
const docid =
|
|
737
|
+
const docid = decodeOptionString2(bytes, offset);
|
|
700
738
|
offset += docid.bytesRead;
|
|
701
739
|
const st = decodeSectionType(bytes, offset);
|
|
702
740
|
offset += st.bytesRead;
|
|
703
|
-
const title =
|
|
741
|
+
const title = decodeOptionString2(bytes, offset);
|
|
704
742
|
offset += title.bytesRead;
|
|
705
|
-
const description =
|
|
743
|
+
const description = decodeOptionString2(bytes, offset);
|
|
706
744
|
offset += description.bytesRead;
|
|
707
745
|
const content = decodeString(bytes, offset);
|
|
708
746
|
offset += content.bytesRead;
|
|
@@ -853,6 +891,209 @@ function decodeRemoveFlag(bytes) {
|
|
|
853
891
|
return bytes.length > 0 && bytes[0] === 1;
|
|
854
892
|
}
|
|
855
893
|
|
|
894
|
+
// src/shared/wasm-codec/functions/encode-recall-params.function.ts
|
|
895
|
+
function encodeRecallParams(params) {
|
|
896
|
+
const depth = params.depth ?? 0;
|
|
897
|
+
const depthBytes = encodeU32(depth);
|
|
898
|
+
if (params.kbids !== void 0) {
|
|
899
|
+
const allKbids = params.kbid !== void 0 ? [...params.kbids, params.kbid] : [...params.kbids];
|
|
900
|
+
const countBytes = encodeU32(allKbids.length);
|
|
901
|
+
const encodedKbids = allKbids.map(encodeString);
|
|
902
|
+
const totalLen2 = 1 + // tag
|
|
903
|
+
countBytes.length + encodedKbids.reduce((sum, b) => sum + b.length, 0) + depthBytes.length;
|
|
904
|
+
const result2 = new Uint8Array(totalLen2);
|
|
905
|
+
let offset2 = 0;
|
|
906
|
+
result2[offset2++] = 1;
|
|
907
|
+
result2.set(countBytes, offset2);
|
|
908
|
+
offset2 += countBytes.length;
|
|
909
|
+
for (const kbidBytes2 of encodedKbids) {
|
|
910
|
+
result2.set(kbidBytes2, offset2);
|
|
911
|
+
offset2 += kbidBytes2.length;
|
|
912
|
+
}
|
|
913
|
+
result2.set(depthBytes, offset2);
|
|
914
|
+
return result2;
|
|
915
|
+
}
|
|
916
|
+
const kbid = params.kbid ?? "";
|
|
917
|
+
const kbidBytes = encodeString(kbid);
|
|
918
|
+
const totalLen = 1 + kbidBytes.length + depthBytes.length;
|
|
919
|
+
const result = new Uint8Array(totalLen);
|
|
920
|
+
let offset = 0;
|
|
921
|
+
result[offset++] = 0;
|
|
922
|
+
result.set(kbidBytes, offset);
|
|
923
|
+
offset += kbidBytes.length;
|
|
924
|
+
result.set(depthBytes, offset);
|
|
925
|
+
return result;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
// src/shared/wasm-codec/functions/decode-recall-result.function.ts
|
|
929
|
+
function decodeRecallResult(bytes) {
|
|
930
|
+
const tag = bytes[0];
|
|
931
|
+
let offset = 1;
|
|
932
|
+
if (tag === 1) {
|
|
933
|
+
const countResult = decodeU32(bytes, offset);
|
|
934
|
+
offset += countResult.bytesRead;
|
|
935
|
+
const items = [];
|
|
936
|
+
for (let i = 0; i < countResult.value; i++) {
|
|
937
|
+
const { item: item2, bytesRead } = decodeOneResult(bytes, offset);
|
|
938
|
+
offset += bytesRead;
|
|
939
|
+
items.push(item2);
|
|
940
|
+
}
|
|
941
|
+
return items;
|
|
942
|
+
}
|
|
943
|
+
const { item } = decodeOneResult(bytes, offset);
|
|
944
|
+
return item;
|
|
945
|
+
}
|
|
946
|
+
function decodeOptionString3(bytes, offset) {
|
|
947
|
+
const tag = bytes[offset];
|
|
948
|
+
if (tag === 0) {
|
|
949
|
+
return { value: null, bytesRead: 1 };
|
|
950
|
+
}
|
|
951
|
+
const str = decodeString(bytes, offset + 1);
|
|
952
|
+
return { value: str.value, bytesRead: 1 + str.bytesRead };
|
|
953
|
+
}
|
|
954
|
+
function decodeReference(bytes, offset) {
|
|
955
|
+
let pos = offset;
|
|
956
|
+
const kbid = decodeString(bytes, pos);
|
|
957
|
+
pos += kbid.bytesRead;
|
|
958
|
+
const heading = decodeOptionString3(bytes, pos);
|
|
959
|
+
pos += heading.bytesRead;
|
|
960
|
+
const sectionType = decodeString(bytes, pos);
|
|
961
|
+
pos += sectionType.bytesRead;
|
|
962
|
+
const markerType = decodeString(bytes, pos);
|
|
963
|
+
pos += markerType.bytesRead;
|
|
964
|
+
const contextSnippet = decodeString(bytes, pos);
|
|
965
|
+
pos += contextSnippet.bytesRead;
|
|
966
|
+
const direction = decodeString(bytes, pos);
|
|
967
|
+
pos += direction.bytesRead;
|
|
968
|
+
return {
|
|
969
|
+
value: {
|
|
970
|
+
kbid: kbid.value,
|
|
971
|
+
heading: heading.value,
|
|
972
|
+
type: sectionType.value,
|
|
973
|
+
marker_type: markerType.value,
|
|
974
|
+
context_snippet: contextSnippet.value,
|
|
975
|
+
direction: direction.value
|
|
976
|
+
},
|
|
977
|
+
bytesRead: pos - offset
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
function decodeSibling(bytes, offset) {
|
|
981
|
+
let pos = offset;
|
|
982
|
+
const kbid = decodeString(bytes, pos);
|
|
983
|
+
pos += kbid.bytesRead;
|
|
984
|
+
const heading = decodeOptionString3(bytes, pos);
|
|
985
|
+
pos += heading.bytesRead;
|
|
986
|
+
const sectionType = decodeString(bytes, pos);
|
|
987
|
+
pos += sectionType.bytesRead;
|
|
988
|
+
const content = decodeString(bytes, pos);
|
|
989
|
+
pos += content.bytesRead;
|
|
990
|
+
return {
|
|
991
|
+
value: {
|
|
992
|
+
kbid: kbid.value,
|
|
993
|
+
heading: heading.value,
|
|
994
|
+
type: sectionType.value,
|
|
995
|
+
content: content.value
|
|
996
|
+
},
|
|
997
|
+
bytesRead: pos - offset
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
function decodeDocument(bytes, offset) {
|
|
1001
|
+
let pos = offset;
|
|
1002
|
+
const docid = decodeString(bytes, pos);
|
|
1003
|
+
pos += docid.bytesRead;
|
|
1004
|
+
const title = decodeString(bytes, pos);
|
|
1005
|
+
pos += title.bytesRead;
|
|
1006
|
+
const sectionCount = decodeU32(bytes, pos);
|
|
1007
|
+
pos += sectionCount.bytesRead;
|
|
1008
|
+
const sections = [];
|
|
1009
|
+
for (let i = 0; i < sectionCount.value; i++) {
|
|
1010
|
+
const secKbid = decodeString(bytes, pos);
|
|
1011
|
+
pos += secKbid.bytesRead;
|
|
1012
|
+
const secHeading = decodeOptionString3(bytes, pos);
|
|
1013
|
+
pos += secHeading.bytesRead;
|
|
1014
|
+
const secType = decodeString(bytes, pos);
|
|
1015
|
+
pos += secType.bytesRead;
|
|
1016
|
+
sections.push({
|
|
1017
|
+
kbid: secKbid.value,
|
|
1018
|
+
heading: secHeading.value,
|
|
1019
|
+
type: secType.value
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
return {
|
|
1023
|
+
value: {
|
|
1024
|
+
docid: docid.value,
|
|
1025
|
+
title: title.value,
|
|
1026
|
+
sections
|
|
1027
|
+
},
|
|
1028
|
+
bytesRead: pos - offset
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
function decodeOneResult(bytes, startOffset) {
|
|
1032
|
+
let pos = startOffset;
|
|
1033
|
+
const kbid = decodeString(bytes, pos);
|
|
1034
|
+
pos += kbid.bytesRead;
|
|
1035
|
+
const heading = decodeOptionString3(bytes, pos);
|
|
1036
|
+
pos += heading.bytesRead;
|
|
1037
|
+
const sectionType = decodeString(bytes, pos);
|
|
1038
|
+
pos += sectionType.bytesRead;
|
|
1039
|
+
const content = decodeString(bytes, pos);
|
|
1040
|
+
pos += content.bytesRead;
|
|
1041
|
+
const docidCount = decodeU32(bytes, pos);
|
|
1042
|
+
pos += docidCount.bytesRead;
|
|
1043
|
+
const docids = [];
|
|
1044
|
+
for (let i = 0; i < docidCount.value; i++) {
|
|
1045
|
+
const docid = decodeString(bytes, pos);
|
|
1046
|
+
pos += docid.bytesRead;
|
|
1047
|
+
docids.push(docid.value);
|
|
1048
|
+
}
|
|
1049
|
+
const docCount = decodeU32(bytes, pos);
|
|
1050
|
+
pos += docCount.bytesRead;
|
|
1051
|
+
const documents = [];
|
|
1052
|
+
for (let i = 0; i < docCount.value; i++) {
|
|
1053
|
+
const doc = decodeDocument(bytes, pos);
|
|
1054
|
+
pos += doc.bytesRead;
|
|
1055
|
+
documents.push(doc.value);
|
|
1056
|
+
}
|
|
1057
|
+
const backRefCount = decodeU32(bytes, pos);
|
|
1058
|
+
pos += backRefCount.bytesRead;
|
|
1059
|
+
const back_references = [];
|
|
1060
|
+
for (let i = 0; i < backRefCount.value; i++) {
|
|
1061
|
+
const ref = decodeReference(bytes, pos);
|
|
1062
|
+
pos += ref.bytesRead;
|
|
1063
|
+
back_references.push(ref.value);
|
|
1064
|
+
}
|
|
1065
|
+
const sibCount = decodeU32(bytes, pos);
|
|
1066
|
+
pos += sibCount.bytesRead;
|
|
1067
|
+
const siblings = [];
|
|
1068
|
+
for (let i = 0; i < sibCount.value; i++) {
|
|
1069
|
+
const sib = decodeSibling(bytes, pos);
|
|
1070
|
+
pos += sib.bytesRead;
|
|
1071
|
+
siblings.push(sib.value);
|
|
1072
|
+
}
|
|
1073
|
+
const refCount = decodeU32(bytes, pos);
|
|
1074
|
+
pos += refCount.bytesRead;
|
|
1075
|
+
const references = [];
|
|
1076
|
+
for (let i = 0; i < refCount.value; i++) {
|
|
1077
|
+
const ref = decodeReference(bytes, pos);
|
|
1078
|
+
pos += ref.bytesRead;
|
|
1079
|
+
references.push(ref.value);
|
|
1080
|
+
}
|
|
1081
|
+
return {
|
|
1082
|
+
item: {
|
|
1083
|
+
kbid: kbid.value,
|
|
1084
|
+
heading: heading.value,
|
|
1085
|
+
type: sectionType.value,
|
|
1086
|
+
content: content.value,
|
|
1087
|
+
docids,
|
|
1088
|
+
documents,
|
|
1089
|
+
back_references,
|
|
1090
|
+
siblings,
|
|
1091
|
+
references
|
|
1092
|
+
},
|
|
1093
|
+
bytesRead: pos - startOffset
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
|
|
856
1097
|
// src/shared/worker-daemon/classes/worker-daemon.class.ts
|
|
857
1098
|
var WASM_METHOD_MAP = {
|
|
858
1099
|
search: "worker_search",
|
|
@@ -891,7 +1132,8 @@ var WASM_METHOD_MAP = {
|
|
|
891
1132
|
listByType: "worker_list_by_type",
|
|
892
1133
|
list_by_type: "worker_list_by_type",
|
|
893
1134
|
listDocumentsByType: "worker_list_docs_by_type",
|
|
894
|
-
list_docs_by_type: "worker_list_docs_by_type"
|
|
1135
|
+
list_docs_by_type: "worker_list_docs_by_type",
|
|
1136
|
+
recall: "worker_recall"
|
|
895
1137
|
};
|
|
896
1138
|
var CONFIG_PREFIX = "config_";
|
|
897
1139
|
var CONFIG_KEY_MAP = {
|
|
@@ -1259,6 +1501,9 @@ var WorkerDaemon = class {
|
|
|
1259
1501
|
if (method === "listDocumentsByType" || method === "list_docs_by_type") {
|
|
1260
1502
|
return this.handleListDocsByType(params);
|
|
1261
1503
|
}
|
|
1504
|
+
if (method === "recall") {
|
|
1505
|
+
return this.handleRecall(params);
|
|
1506
|
+
}
|
|
1262
1507
|
return this.invokeWasmRaw(wasmExport, new Uint8Array(0));
|
|
1263
1508
|
}
|
|
1264
1509
|
// -- Search/query (token-based async) --
|
|
@@ -1266,7 +1511,8 @@ var WorkerDaemon = class {
|
|
|
1266
1511
|
const query = params["query"] ?? "";
|
|
1267
1512
|
const mode = params["mode"] ?? "and";
|
|
1268
1513
|
const limit = Number(params["limit"] ?? 20);
|
|
1269
|
-
const
|
|
1514
|
+
const offset = Number(params["offset"] ?? 0);
|
|
1515
|
+
const encoded = encodeSearchParams(query, mode, limit, offset);
|
|
1270
1516
|
const searchFn = this.getExport("worker_search");
|
|
1271
1517
|
const ptr = this.wasmAlloc(encoded.length);
|
|
1272
1518
|
this.wasmWrite(ptr, encoded);
|
|
@@ -1288,7 +1534,7 @@ var WorkerDaemon = class {
|
|
|
1288
1534
|
throw new IpcError(-32e3, new TextDecoder().decode(errBytes));
|
|
1289
1535
|
}
|
|
1290
1536
|
const resultBytes = this.readReturnSlot();
|
|
1291
|
-
return
|
|
1537
|
+
return decodePagedSearchResult(resultBytes);
|
|
1292
1538
|
}
|
|
1293
1539
|
// -- Token status/result (u32 direct params) --
|
|
1294
1540
|
handleResultStatus(params) {
|
|
@@ -1306,7 +1552,7 @@ var WorkerDaemon = class {
|
|
|
1306
1552
|
throw new IpcError(-32e3, new TextDecoder().decode(errBytes));
|
|
1307
1553
|
}
|
|
1308
1554
|
const bytes = this.readReturnSlot();
|
|
1309
|
-
return
|
|
1555
|
+
return decodePagedSearchResult(bytes);
|
|
1310
1556
|
}
|
|
1311
1557
|
// -- Binary-encoded input methods --
|
|
1312
1558
|
handleAddSection(params) {
|
|
@@ -1417,6 +1663,14 @@ var WorkerDaemon = class {
|
|
|
1417
1663
|
);
|
|
1418
1664
|
return decodeDocumentManifestList(bytes);
|
|
1419
1665
|
}
|
|
1666
|
+
handleRecall(params) {
|
|
1667
|
+
const kbid = typeof params["kbid"] === "string" ? params["kbid"] : void 0;
|
|
1668
|
+
const kbids = Array.isArray(params["kbids"]) ? params["kbids"] : void 0;
|
|
1669
|
+
const depth = Number(params["depth"] ?? 0);
|
|
1670
|
+
const encoded = encodeRecallParams({ kbid, kbids, depth });
|
|
1671
|
+
const bytes = this.callWasmSync("worker_recall", encoded);
|
|
1672
|
+
return decodeRecallResult(bytes);
|
|
1673
|
+
}
|
|
1420
1674
|
// -- Zero-arg methods --
|
|
1421
1675
|
handleInvalidateAll() {
|
|
1422
1676
|
this.callWasmZeroArg("worker_invalidate_all");
|