@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/worker.mjs
CHANGED
|
@@ -515,10 +515,13 @@ function encodeIdentifierList(ids) {
|
|
|
515
515
|
|
|
516
516
|
// src/shared/wasm-codec/functions/encode-search-params.function.ts
|
|
517
517
|
var encoder2 = new TextEncoder();
|
|
518
|
-
function encodeSearchParams(query, mode = "and", limit = 20) {
|
|
519
|
-
return encoder2.encode(
|
|
518
|
+
function encodeSearchParams(query, mode = "and", limit = 20, offset = 0) {
|
|
519
|
+
return encoder2.encode(
|
|
520
|
+
`${query}
|
|
520
521
|
${mode}
|
|
521
|
-
${String(limit)}
|
|
522
|
+
${String(limit)}
|
|
523
|
+
${String(offset)}`
|
|
524
|
+
);
|
|
522
525
|
}
|
|
523
526
|
|
|
524
527
|
// src/shared/wasm-codec/functions/encode-type-filter-param.function.ts
|
|
@@ -581,40 +584,75 @@ function decodeU64(bytes, offset) {
|
|
|
581
584
|
}
|
|
582
585
|
|
|
583
586
|
// src/shared/wasm-codec/functions/decode-scored-results.function.ts
|
|
584
|
-
function
|
|
587
|
+
function decodeOptionString(bytes, offset) {
|
|
588
|
+
const tag = bytes[offset];
|
|
589
|
+
if (tag === 0) {
|
|
590
|
+
return { value: null, bytesRead: 1 };
|
|
591
|
+
}
|
|
592
|
+
const str = decodeString(bytes, offset + 1);
|
|
593
|
+
return { value: str.value, bytesRead: 1 + str.bytesRead };
|
|
594
|
+
}
|
|
595
|
+
function decodePagedSearchResult(bytes) {
|
|
585
596
|
let offset = 0;
|
|
586
|
-
const
|
|
587
|
-
offset +=
|
|
588
|
-
const
|
|
589
|
-
|
|
597
|
+
const total = decodeU32(bytes, offset);
|
|
598
|
+
offset += total.bytesRead;
|
|
599
|
+
const resultOffset = decodeU32(bytes, offset);
|
|
600
|
+
offset += resultOffset.bytesRead;
|
|
601
|
+
const limit = decodeU32(bytes, offset);
|
|
602
|
+
offset += limit.bytesRead;
|
|
603
|
+
const hasMore = bytes[offset] === 1;
|
|
604
|
+
offset += 1;
|
|
605
|
+
const itemCount = decodeU32(bytes, offset);
|
|
606
|
+
offset += itemCount.bytesRead;
|
|
607
|
+
const items = [];
|
|
608
|
+
for (let i = 0; i < itemCount.value; i++) {
|
|
590
609
|
const kbid = decodeString(bytes, offset);
|
|
591
610
|
offset += kbid.bytesRead;
|
|
611
|
+
const heading = decodeOptionString(bytes, offset);
|
|
612
|
+
offset += heading.bytesRead;
|
|
613
|
+
const sectionType = decodeString(bytes, offset);
|
|
614
|
+
offset += sectionType.bytesRead;
|
|
615
|
+
const docidCount = decodeU32(bytes, offset);
|
|
616
|
+
offset += docidCount.bytesRead;
|
|
617
|
+
const docids = [];
|
|
618
|
+
for (let j = 0; j < docidCount.value; j++) {
|
|
619
|
+
const docid = decodeString(bytes, offset);
|
|
620
|
+
offset += docid.bytesRead;
|
|
621
|
+
docids.push(docid.value);
|
|
622
|
+
}
|
|
592
623
|
const score = decodeF32(bytes, offset);
|
|
593
624
|
offset += score.bytesRead;
|
|
594
|
-
const
|
|
595
|
-
offset +=
|
|
596
|
-
const
|
|
597
|
-
|
|
625
|
+
const snippet = decodeString(bytes, offset);
|
|
626
|
+
offset += snippet.bytesRead;
|
|
627
|
+
const termCount = decodeU32(bytes, offset);
|
|
628
|
+
offset += termCount.bytesRead;
|
|
629
|
+
const matched_terms = [];
|
|
630
|
+
for (let j = 0; j < termCount.value; j++) {
|
|
598
631
|
const term = decodeString(bytes, offset);
|
|
599
632
|
offset += term.bytesRead;
|
|
600
|
-
|
|
601
|
-
offset += freq.bytesRead;
|
|
602
|
-
matches.push({
|
|
603
|
-
term: term.value,
|
|
604
|
-
frequency: freq.value
|
|
605
|
-
});
|
|
633
|
+
matched_terms.push(term.value);
|
|
606
634
|
}
|
|
607
|
-
|
|
635
|
+
items.push({
|
|
608
636
|
kbid: kbid.value,
|
|
637
|
+
heading: heading.value,
|
|
638
|
+
type: sectionType.value,
|
|
639
|
+
docids,
|
|
609
640
|
score: score.value,
|
|
610
|
-
|
|
641
|
+
snippet: snippet.value,
|
|
642
|
+
matched_terms
|
|
611
643
|
});
|
|
612
644
|
}
|
|
613
|
-
return
|
|
645
|
+
return {
|
|
646
|
+
items,
|
|
647
|
+
total: total.value,
|
|
648
|
+
offset: resultOffset.value,
|
|
649
|
+
limit: limit.value,
|
|
650
|
+
has_more: hasMore
|
|
651
|
+
};
|
|
614
652
|
}
|
|
615
653
|
|
|
616
654
|
// src/shared/wasm-codec/functions/decode-section-records.function.ts
|
|
617
|
-
function
|
|
655
|
+
function decodeOptionString2(bytes, offset) {
|
|
618
656
|
const tag = bytes[offset];
|
|
619
657
|
if (tag === 0) {
|
|
620
658
|
return { value: null, bytesRead: 1 };
|
|
@@ -643,13 +681,13 @@ function decodeSectionRecords(bytes) {
|
|
|
643
681
|
for (let i = 0; i < count.value; i++) {
|
|
644
682
|
const kbid = decodeString(bytes, offset);
|
|
645
683
|
offset += kbid.bytesRead;
|
|
646
|
-
const docid =
|
|
684
|
+
const docid = decodeOptionString2(bytes, offset);
|
|
647
685
|
offset += docid.bytesRead;
|
|
648
686
|
const st = decodeSectionType(bytes, offset);
|
|
649
687
|
offset += st.bytesRead;
|
|
650
|
-
const title =
|
|
688
|
+
const title = decodeOptionString2(bytes, offset);
|
|
651
689
|
offset += title.bytesRead;
|
|
652
|
-
const description =
|
|
690
|
+
const description = decodeOptionString2(bytes, offset);
|
|
653
691
|
offset += description.bytesRead;
|
|
654
692
|
const content = decodeString(bytes, offset);
|
|
655
693
|
offset += content.bytesRead;
|
|
@@ -800,6 +838,209 @@ function decodeRemoveFlag(bytes) {
|
|
|
800
838
|
return bytes.length > 0 && bytes[0] === 1;
|
|
801
839
|
}
|
|
802
840
|
|
|
841
|
+
// src/shared/wasm-codec/functions/encode-recall-params.function.ts
|
|
842
|
+
function encodeRecallParams(params) {
|
|
843
|
+
const depth = params.depth ?? 0;
|
|
844
|
+
const depthBytes = encodeU32(depth);
|
|
845
|
+
if (params.kbids !== void 0) {
|
|
846
|
+
const allKbids = params.kbid !== void 0 ? [...params.kbids, params.kbid] : [...params.kbids];
|
|
847
|
+
const countBytes = encodeU32(allKbids.length);
|
|
848
|
+
const encodedKbids = allKbids.map(encodeString);
|
|
849
|
+
const totalLen2 = 1 + // tag
|
|
850
|
+
countBytes.length + encodedKbids.reduce((sum, b) => sum + b.length, 0) + depthBytes.length;
|
|
851
|
+
const result2 = new Uint8Array(totalLen2);
|
|
852
|
+
let offset2 = 0;
|
|
853
|
+
result2[offset2++] = 1;
|
|
854
|
+
result2.set(countBytes, offset2);
|
|
855
|
+
offset2 += countBytes.length;
|
|
856
|
+
for (const kbidBytes2 of encodedKbids) {
|
|
857
|
+
result2.set(kbidBytes2, offset2);
|
|
858
|
+
offset2 += kbidBytes2.length;
|
|
859
|
+
}
|
|
860
|
+
result2.set(depthBytes, offset2);
|
|
861
|
+
return result2;
|
|
862
|
+
}
|
|
863
|
+
const kbid = params.kbid ?? "";
|
|
864
|
+
const kbidBytes = encodeString(kbid);
|
|
865
|
+
const totalLen = 1 + kbidBytes.length + depthBytes.length;
|
|
866
|
+
const result = new Uint8Array(totalLen);
|
|
867
|
+
let offset = 0;
|
|
868
|
+
result[offset++] = 0;
|
|
869
|
+
result.set(kbidBytes, offset);
|
|
870
|
+
offset += kbidBytes.length;
|
|
871
|
+
result.set(depthBytes, offset);
|
|
872
|
+
return result;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
// src/shared/wasm-codec/functions/decode-recall-result.function.ts
|
|
876
|
+
function decodeRecallResult(bytes) {
|
|
877
|
+
const tag = bytes[0];
|
|
878
|
+
let offset = 1;
|
|
879
|
+
if (tag === 1) {
|
|
880
|
+
const countResult = decodeU32(bytes, offset);
|
|
881
|
+
offset += countResult.bytesRead;
|
|
882
|
+
const items = [];
|
|
883
|
+
for (let i = 0; i < countResult.value; i++) {
|
|
884
|
+
const { item: item2, bytesRead } = decodeOneResult(bytes, offset);
|
|
885
|
+
offset += bytesRead;
|
|
886
|
+
items.push(item2);
|
|
887
|
+
}
|
|
888
|
+
return items;
|
|
889
|
+
}
|
|
890
|
+
const { item } = decodeOneResult(bytes, offset);
|
|
891
|
+
return item;
|
|
892
|
+
}
|
|
893
|
+
function decodeOptionString3(bytes, offset) {
|
|
894
|
+
const tag = bytes[offset];
|
|
895
|
+
if (tag === 0) {
|
|
896
|
+
return { value: null, bytesRead: 1 };
|
|
897
|
+
}
|
|
898
|
+
const str = decodeString(bytes, offset + 1);
|
|
899
|
+
return { value: str.value, bytesRead: 1 + str.bytesRead };
|
|
900
|
+
}
|
|
901
|
+
function decodeReference(bytes, offset) {
|
|
902
|
+
let pos = offset;
|
|
903
|
+
const kbid = decodeString(bytes, pos);
|
|
904
|
+
pos += kbid.bytesRead;
|
|
905
|
+
const heading = decodeOptionString3(bytes, pos);
|
|
906
|
+
pos += heading.bytesRead;
|
|
907
|
+
const sectionType = decodeString(bytes, pos);
|
|
908
|
+
pos += sectionType.bytesRead;
|
|
909
|
+
const markerType = decodeString(bytes, pos);
|
|
910
|
+
pos += markerType.bytesRead;
|
|
911
|
+
const contextSnippet = decodeString(bytes, pos);
|
|
912
|
+
pos += contextSnippet.bytesRead;
|
|
913
|
+
const direction = decodeString(bytes, pos);
|
|
914
|
+
pos += direction.bytesRead;
|
|
915
|
+
return {
|
|
916
|
+
value: {
|
|
917
|
+
kbid: kbid.value,
|
|
918
|
+
heading: heading.value,
|
|
919
|
+
type: sectionType.value,
|
|
920
|
+
marker_type: markerType.value,
|
|
921
|
+
context_snippet: contextSnippet.value,
|
|
922
|
+
direction: direction.value
|
|
923
|
+
},
|
|
924
|
+
bytesRead: pos - offset
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
function decodeSibling(bytes, offset) {
|
|
928
|
+
let pos = offset;
|
|
929
|
+
const kbid = decodeString(bytes, pos);
|
|
930
|
+
pos += kbid.bytesRead;
|
|
931
|
+
const heading = decodeOptionString3(bytes, pos);
|
|
932
|
+
pos += heading.bytesRead;
|
|
933
|
+
const sectionType = decodeString(bytes, pos);
|
|
934
|
+
pos += sectionType.bytesRead;
|
|
935
|
+
const content = decodeString(bytes, pos);
|
|
936
|
+
pos += content.bytesRead;
|
|
937
|
+
return {
|
|
938
|
+
value: {
|
|
939
|
+
kbid: kbid.value,
|
|
940
|
+
heading: heading.value,
|
|
941
|
+
type: sectionType.value,
|
|
942
|
+
content: content.value
|
|
943
|
+
},
|
|
944
|
+
bytesRead: pos - offset
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
function decodeDocument(bytes, offset) {
|
|
948
|
+
let pos = offset;
|
|
949
|
+
const docid = decodeString(bytes, pos);
|
|
950
|
+
pos += docid.bytesRead;
|
|
951
|
+
const title = decodeString(bytes, pos);
|
|
952
|
+
pos += title.bytesRead;
|
|
953
|
+
const sectionCount = decodeU32(bytes, pos);
|
|
954
|
+
pos += sectionCount.bytesRead;
|
|
955
|
+
const sections = [];
|
|
956
|
+
for (let i = 0; i < sectionCount.value; i++) {
|
|
957
|
+
const secKbid = decodeString(bytes, pos);
|
|
958
|
+
pos += secKbid.bytesRead;
|
|
959
|
+
const secHeading = decodeOptionString3(bytes, pos);
|
|
960
|
+
pos += secHeading.bytesRead;
|
|
961
|
+
const secType = decodeString(bytes, pos);
|
|
962
|
+
pos += secType.bytesRead;
|
|
963
|
+
sections.push({
|
|
964
|
+
kbid: secKbid.value,
|
|
965
|
+
heading: secHeading.value,
|
|
966
|
+
type: secType.value
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
return {
|
|
970
|
+
value: {
|
|
971
|
+
docid: docid.value,
|
|
972
|
+
title: title.value,
|
|
973
|
+
sections
|
|
974
|
+
},
|
|
975
|
+
bytesRead: pos - offset
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
function decodeOneResult(bytes, startOffset) {
|
|
979
|
+
let pos = startOffset;
|
|
980
|
+
const kbid = decodeString(bytes, pos);
|
|
981
|
+
pos += kbid.bytesRead;
|
|
982
|
+
const heading = decodeOptionString3(bytes, pos);
|
|
983
|
+
pos += heading.bytesRead;
|
|
984
|
+
const sectionType = decodeString(bytes, pos);
|
|
985
|
+
pos += sectionType.bytesRead;
|
|
986
|
+
const content = decodeString(bytes, pos);
|
|
987
|
+
pos += content.bytesRead;
|
|
988
|
+
const docidCount = decodeU32(bytes, pos);
|
|
989
|
+
pos += docidCount.bytesRead;
|
|
990
|
+
const docids = [];
|
|
991
|
+
for (let i = 0; i < docidCount.value; i++) {
|
|
992
|
+
const docid = decodeString(bytes, pos);
|
|
993
|
+
pos += docid.bytesRead;
|
|
994
|
+
docids.push(docid.value);
|
|
995
|
+
}
|
|
996
|
+
const docCount = decodeU32(bytes, pos);
|
|
997
|
+
pos += docCount.bytesRead;
|
|
998
|
+
const documents = [];
|
|
999
|
+
for (let i = 0; i < docCount.value; i++) {
|
|
1000
|
+
const doc = decodeDocument(bytes, pos);
|
|
1001
|
+
pos += doc.bytesRead;
|
|
1002
|
+
documents.push(doc.value);
|
|
1003
|
+
}
|
|
1004
|
+
const backRefCount = decodeU32(bytes, pos);
|
|
1005
|
+
pos += backRefCount.bytesRead;
|
|
1006
|
+
const back_references = [];
|
|
1007
|
+
for (let i = 0; i < backRefCount.value; i++) {
|
|
1008
|
+
const ref = decodeReference(bytes, pos);
|
|
1009
|
+
pos += ref.bytesRead;
|
|
1010
|
+
back_references.push(ref.value);
|
|
1011
|
+
}
|
|
1012
|
+
const sibCount = decodeU32(bytes, pos);
|
|
1013
|
+
pos += sibCount.bytesRead;
|
|
1014
|
+
const siblings = [];
|
|
1015
|
+
for (let i = 0; i < sibCount.value; i++) {
|
|
1016
|
+
const sib = decodeSibling(bytes, pos);
|
|
1017
|
+
pos += sib.bytesRead;
|
|
1018
|
+
siblings.push(sib.value);
|
|
1019
|
+
}
|
|
1020
|
+
const refCount = decodeU32(bytes, pos);
|
|
1021
|
+
pos += refCount.bytesRead;
|
|
1022
|
+
const references = [];
|
|
1023
|
+
for (let i = 0; i < refCount.value; i++) {
|
|
1024
|
+
const ref = decodeReference(bytes, pos);
|
|
1025
|
+
pos += ref.bytesRead;
|
|
1026
|
+
references.push(ref.value);
|
|
1027
|
+
}
|
|
1028
|
+
return {
|
|
1029
|
+
item: {
|
|
1030
|
+
kbid: kbid.value,
|
|
1031
|
+
heading: heading.value,
|
|
1032
|
+
type: sectionType.value,
|
|
1033
|
+
content: content.value,
|
|
1034
|
+
docids,
|
|
1035
|
+
documents,
|
|
1036
|
+
back_references,
|
|
1037
|
+
siblings,
|
|
1038
|
+
references
|
|
1039
|
+
},
|
|
1040
|
+
bytesRead: pos - startOffset
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
|
|
803
1044
|
// src/shared/worker-daemon/classes/worker-daemon.class.ts
|
|
804
1045
|
var WASM_METHOD_MAP = {
|
|
805
1046
|
search: "worker_search",
|
|
@@ -838,7 +1079,8 @@ var WASM_METHOD_MAP = {
|
|
|
838
1079
|
listByType: "worker_list_by_type",
|
|
839
1080
|
list_by_type: "worker_list_by_type",
|
|
840
1081
|
listDocumentsByType: "worker_list_docs_by_type",
|
|
841
|
-
list_docs_by_type: "worker_list_docs_by_type"
|
|
1082
|
+
list_docs_by_type: "worker_list_docs_by_type",
|
|
1083
|
+
recall: "worker_recall"
|
|
842
1084
|
};
|
|
843
1085
|
var CONFIG_PREFIX = "config_";
|
|
844
1086
|
var CONFIG_KEY_MAP = {
|
|
@@ -1206,6 +1448,9 @@ var WorkerDaemon = class {
|
|
|
1206
1448
|
if (method === "listDocumentsByType" || method === "list_docs_by_type") {
|
|
1207
1449
|
return this.handleListDocsByType(params);
|
|
1208
1450
|
}
|
|
1451
|
+
if (method === "recall") {
|
|
1452
|
+
return this.handleRecall(params);
|
|
1453
|
+
}
|
|
1209
1454
|
return this.invokeWasmRaw(wasmExport, new Uint8Array(0));
|
|
1210
1455
|
}
|
|
1211
1456
|
// -- Search/query (token-based async) --
|
|
@@ -1213,7 +1458,8 @@ var WorkerDaemon = class {
|
|
|
1213
1458
|
const query = params["query"] ?? "";
|
|
1214
1459
|
const mode = params["mode"] ?? "and";
|
|
1215
1460
|
const limit = Number(params["limit"] ?? 20);
|
|
1216
|
-
const
|
|
1461
|
+
const offset = Number(params["offset"] ?? 0);
|
|
1462
|
+
const encoded = encodeSearchParams(query, mode, limit, offset);
|
|
1217
1463
|
const searchFn = this.getExport("worker_search");
|
|
1218
1464
|
const ptr = this.wasmAlloc(encoded.length);
|
|
1219
1465
|
this.wasmWrite(ptr, encoded);
|
|
@@ -1235,7 +1481,7 @@ var WorkerDaemon = class {
|
|
|
1235
1481
|
throw new IpcError(-32e3, new TextDecoder().decode(errBytes));
|
|
1236
1482
|
}
|
|
1237
1483
|
const resultBytes = this.readReturnSlot();
|
|
1238
|
-
return
|
|
1484
|
+
return decodePagedSearchResult(resultBytes);
|
|
1239
1485
|
}
|
|
1240
1486
|
// -- Token status/result (u32 direct params) --
|
|
1241
1487
|
handleResultStatus(params) {
|
|
@@ -1253,7 +1499,7 @@ var WorkerDaemon = class {
|
|
|
1253
1499
|
throw new IpcError(-32e3, new TextDecoder().decode(errBytes));
|
|
1254
1500
|
}
|
|
1255
1501
|
const bytes = this.readReturnSlot();
|
|
1256
|
-
return
|
|
1502
|
+
return decodePagedSearchResult(bytes);
|
|
1257
1503
|
}
|
|
1258
1504
|
// -- Binary-encoded input methods --
|
|
1259
1505
|
handleAddSection(params) {
|
|
@@ -1364,6 +1610,14 @@ var WorkerDaemon = class {
|
|
|
1364
1610
|
);
|
|
1365
1611
|
return decodeDocumentManifestList(bytes);
|
|
1366
1612
|
}
|
|
1613
|
+
handleRecall(params) {
|
|
1614
|
+
const kbid = typeof params["kbid"] === "string" ? params["kbid"] : void 0;
|
|
1615
|
+
const kbids = Array.isArray(params["kbids"]) ? params["kbids"] : void 0;
|
|
1616
|
+
const depth = Number(params["depth"] ?? 0);
|
|
1617
|
+
const encoded = encodeRecallParams({ kbid, kbids, depth });
|
|
1618
|
+
const bytes = this.callWasmSync("worker_recall", encoded);
|
|
1619
|
+
return decodeRecallResult(bytes);
|
|
1620
|
+
}
|
|
1367
1621
|
// -- Zero-arg methods --
|
|
1368
1622
|
handleInvalidateAll() {
|
|
1369
1623
|
this.callWasmZeroArg("worker_invalidate_all");
|