@dikolab/kbdb 0.6.4 → 0.6.5
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/dist/cli.cjs +452 -144
- package/dist/cli.cjs.map +4 -4
- package/dist/cli.mjs +452 -144
- package/dist/cli.mjs.map +4 -4
- package/dist/kbdb-worker.cjs +49 -7
- package/dist/kbdb-worker.cjs.map +4 -4
- package/dist/mod.cjs +1 -1
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.mjs +1 -1
- package/dist/mod.mjs.map +1 -1
- package/dist/src/shared/cli/constants/defaults.constant.d.ts +1 -1
- package/dist/src/shared/cli/functions/learn-structured-document.function.d.ts +10 -0
- package/dist/src/shared/cli/functions/learn-target-content.function.d.ts +5 -17
- package/dist/src/shared/cli/functions/split-markdown-sections.function.d.ts +4 -0
- package/dist/src/shared/cli/typings/learn-client.interface.d.ts +2 -0
- package/dist/src/shared/cli/typings/learn-result.model.d.ts +2 -0
- package/dist/src/shared/content-splitter/classes/heading-parent-tracker.class.d.ts +20 -0
- package/dist/src/shared/content-splitter/constants/content-type-maps.constant.d.ts +5 -0
- package/dist/src/shared/content-splitter/constants/split-strategy-map.constant.d.ts +4 -0
- package/dist/src/shared/content-splitter/functions/detect-content-type.function.d.ts +13 -0
- package/dist/src/shared/content-splitter/functions/flush-markdown-draft.function.d.ts +14 -0
- package/dist/src/shared/content-splitter/functions/flush-toml-draft.function.d.ts +15 -0
- package/dist/src/shared/content-splitter/functions/push-content-section.function.d.ts +16 -0
- package/dist/src/shared/content-splitter/functions/resolve-parent-ids.function.d.ts +14 -0
- package/dist/src/shared/content-splitter/functions/split-content.function.d.ts +11 -0
- package/dist/src/shared/content-splitter/functions/split-html.function.d.ts +12 -0
- package/dist/src/shared/content-splitter/functions/split-markdown.function.d.ts +13 -0
- package/dist/src/shared/content-splitter/functions/split-plain-text.function.d.ts +8 -0
- package/dist/src/shared/content-splitter/functions/split-toml.function.d.ts +12 -0
- package/dist/src/shared/content-splitter/index.d.ts +11 -0
- package/dist/src/shared/content-splitter/typings/content-format.type.d.ts +2 -0
- package/dist/src/shared/content-splitter/typings/content-section.interface.d.ts +17 -0
- package/dist/src/shared/content-splitter/typings/markdown-draft.interface.d.ts +12 -0
- package/dist/src/shared/content-splitter/typings/split-result.interface.d.ts +8 -0
- package/dist/src/shared/content-splitter/typings/split-strategy.interface.d.ts +3 -0
- package/dist/src/shared/content-splitter/typings/toml-draft.interface.d.ts +15 -0
- package/dist/src/shared/mcp/functions/build-learn-payload.function.d.ts +24 -0
- package/dist/src/shared/mcp/functions/determine-learn-split.function.d.ts +18 -0
- package/dist/src/shared/mcp/functions/handle-tool-learn.function.d.ts +3 -1
- package/dist/src/shared/mcp/functions/learn-with-splitting.function.d.ts +22 -0
- package/dist/src/shared/mcp/functions/parse-learn-args.function.d.ts +24 -0
- package/dist/src/shared/mcp/functions/store-split-learn-sections.function.d.ts +16 -0
- package/dist/src/shared/mcp/functions/unwrap-json-content.function.d.ts +9 -0
- package/dist/src/shared/mcp/typings/learn-section-params.interface.d.ts +20 -0
- package/dist/src/shared/mcp/typings/mcp-client.interface.d.ts +4 -0
- package/dist/src/shared/mcp/typings/mcp-worker-client.interface.d.ts +4 -0
- package/dist/src/shared/version/constants/version.constant.d.ts +1 -1
- package/dist/src/shared/wasm-codec/functions/decode-one-recall-result.function.d.ts +2 -1
- package/dist/src/shared/wasm-codec/functions/decode-recall-document.function.d.ts +2 -1
- package/dist/src/shared/wasm-codec/functions/decode-recall-result.function.d.ts +2 -0
- package/dist/src/shared/wasm-codec/functions/decode-recall-sibling.function.d.ts +2 -1
- package/dist/src/shared/wasm-codec/functions/decode-scored-results.function.d.ts +6 -0
- package/dist/src/shared/wasm-codec/functions/decode-section-match.function.d.ts +2 -1
- package/dist/src/shared/wasm-codec/functions/decode-section-records.function.d.ts +4 -0
- package/dist/src/shared/wasm-codec/functions/encode-add-section-params.function.d.ts +1 -0
- package/dist/src/shared/wasm-codec/typings/add-section-input.model.d.ts +2 -0
- package/dist/src/shared/wasm-codec/typings/section-match.model.d.ts +4 -0
- package/dist/src/shared/wasm-codec/typings/section-record-trailing.model.d.ts +2 -0
- package/dist/src/shared/wasm-codec/typings/section-record.model.d.ts +2 -0
- package/dist/src/shared/worker-client/typings/recall-result.model.d.ts +12 -0
- package/dist/src/shared/worker-client/typings/search-result.model.d.ts +4 -0
- package/dist/src/shared/worker-client/typings/section.model.d.ts +2 -0
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/dist/worker.mjs +49 -7
- package/dist/worker.mjs.map +4 -4
- package/package.json +1 -1
|
@@ -27,6 +27,10 @@ export interface RecallDocument {
|
|
|
27
27
|
readonly heading: string | null;
|
|
28
28
|
/** Semantic type label for the section. */
|
|
29
29
|
readonly type: string;
|
|
30
|
+
/** Heading level (1-6), or `null`. */
|
|
31
|
+
readonly level?: number | null;
|
|
32
|
+
/** Kbid of the parent section, or `null`. */
|
|
33
|
+
readonly parent?: string | null;
|
|
30
34
|
}[];
|
|
31
35
|
}
|
|
32
36
|
/** A sibling section adjacent to the recalled section. */
|
|
@@ -39,6 +43,10 @@ export interface RecallSibling {
|
|
|
39
43
|
readonly type: string;
|
|
40
44
|
/** Full text content of the sibling section. */
|
|
41
45
|
readonly content: string;
|
|
46
|
+
/** Heading level (1-6), or `null`. */
|
|
47
|
+
readonly level?: number | null;
|
|
48
|
+
/** Kbid of the parent section, or `null`. */
|
|
49
|
+
readonly parent?: string | null;
|
|
42
50
|
}
|
|
43
51
|
/** A section that references or is referenced by the recalled section. */
|
|
44
52
|
export interface RecallReference {
|
|
@@ -65,6 +73,10 @@ export interface RecallResult {
|
|
|
65
73
|
readonly type: string;
|
|
66
74
|
/** Full text content of the section. */
|
|
67
75
|
readonly content: string;
|
|
76
|
+
/** Heading level (1-6), or `null`. */
|
|
77
|
+
readonly level?: number | null;
|
|
78
|
+
/** Kbid of the parent section, or `null`. */
|
|
79
|
+
readonly parent?: string | null;
|
|
68
80
|
/** Identifiers of documents that contain this section. */
|
|
69
81
|
readonly docids: readonly string[];
|
|
70
82
|
/**
|
|
@@ -26,6 +26,10 @@ export interface SearchResult {
|
|
|
26
26
|
readonly confidence?: number;
|
|
27
27
|
/** ISO 8601 creation timestamp of the section. */
|
|
28
28
|
readonly created_at?: string;
|
|
29
|
+
/** Heading level (1-6), or `null` when unset. */
|
|
30
|
+
readonly level?: number | null;
|
|
31
|
+
/** Kbid of the parent section, or `null`. */
|
|
32
|
+
readonly parent?: string | null;
|
|
29
33
|
}
|
|
30
34
|
/** Paginated search result envelope. */
|
|
31
35
|
export interface PagedSearchResult {
|
|
Binary file
|
|
Binary file
|
package/dist/worker.mjs
CHANGED
|
@@ -1006,6 +1006,7 @@ function encodeAddSectionParams(params) {
|
|
|
1006
1006
|
params.replace === true ? 1 : 0
|
|
1007
1007
|
]);
|
|
1008
1008
|
const levelBytes = params.level != null ? new Uint8Array([1, params.level]) : new Uint8Array([0]);
|
|
1009
|
+
const parentBytes = encodeOptionString(params.parent);
|
|
1009
1010
|
const parts = [
|
|
1010
1011
|
encodeSectionType(params.sectionType, params.mimeType),
|
|
1011
1012
|
encodeString(params.content),
|
|
@@ -1018,7 +1019,8 @@ function encodeAddSectionParams(params) {
|
|
|
1018
1019
|
tagsCountBytes,
|
|
1019
1020
|
...tagParts,
|
|
1020
1021
|
replaceByte,
|
|
1021
|
-
levelBytes
|
|
1022
|
+
levelBytes,
|
|
1023
|
+
parentBytes
|
|
1022
1024
|
];
|
|
1023
1025
|
const totalLen = parts.reduce((sum, p) => sum + p.length, 0);
|
|
1024
1026
|
const result = new Uint8Array(totalLen);
|
|
@@ -1156,6 +1158,15 @@ function decodeU64(bytes, offset) {
|
|
|
1156
1158
|
};
|
|
1157
1159
|
}
|
|
1158
1160
|
|
|
1161
|
+
// src/shared/wasm-codec/functions/decode-option-u8.function.ts
|
|
1162
|
+
function decodeOptionU8(bytes, offset) {
|
|
1163
|
+
const tag = bytes[offset];
|
|
1164
|
+
if (tag === 1) {
|
|
1165
|
+
return { value: bytes[offset + 1], bytesRead: 2 };
|
|
1166
|
+
}
|
|
1167
|
+
return { value: null, bytesRead: 1 };
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1159
1170
|
// src/shared/wasm-codec/functions/decode-scored-results.function.ts
|
|
1160
1171
|
function decodeOptionString(bytes, offset) {
|
|
1161
1172
|
const tag = bytes[offset];
|
|
@@ -1221,6 +1232,10 @@ function decodePagedSearchResult(bytes) {
|
|
|
1221
1232
|
}
|
|
1222
1233
|
const createdAt = decodeString(bytes, offset);
|
|
1223
1234
|
offset += createdAt.bytesRead;
|
|
1235
|
+
const optLevel = decodeOptionU8(bytes, offset);
|
|
1236
|
+
offset += optLevel.bytesRead;
|
|
1237
|
+
const optParent = decodeOptionString(bytes, offset);
|
|
1238
|
+
offset += optParent.bytesRead;
|
|
1224
1239
|
items.push({
|
|
1225
1240
|
kbid: kbid.value,
|
|
1226
1241
|
heading: heading.value,
|
|
@@ -1231,7 +1246,9 @@ function decodePagedSearchResult(bytes) {
|
|
|
1231
1246
|
snippet: snippet.value,
|
|
1232
1247
|
matched_terms,
|
|
1233
1248
|
matched_fields,
|
|
1234
|
-
created_at: createdAt.value
|
|
1249
|
+
created_at: createdAt.value,
|
|
1250
|
+
level: optLevel.value,
|
|
1251
|
+
parent: optParent.value
|
|
1235
1252
|
});
|
|
1236
1253
|
}
|
|
1237
1254
|
return {
|
|
@@ -1245,7 +1262,7 @@ function decodePagedSearchResult(bytes) {
|
|
|
1245
1262
|
}
|
|
1246
1263
|
|
|
1247
1264
|
// src/shared/wasm-codec/functions/decode-section-records.function.ts
|
|
1248
|
-
function
|
|
1265
|
+
function decodeOptionU82(bytes, offset) {
|
|
1249
1266
|
const tag = bytes[offset];
|
|
1250
1267
|
if (tag === 1) {
|
|
1251
1268
|
return { value: bytes[offset + 1], bytesRead: 2 };
|
|
@@ -1350,10 +1367,16 @@ function decodeSectionRecords(bytes) {
|
|
|
1350
1367
|
}
|
|
1351
1368
|
let level = null;
|
|
1352
1369
|
if (offset < bytes.length) {
|
|
1353
|
-
const v =
|
|
1370
|
+
const v = decodeOptionU82(bytes, offset);
|
|
1354
1371
|
offset += v.bytesRead;
|
|
1355
1372
|
level = v.value;
|
|
1356
1373
|
}
|
|
1374
|
+
let parent = null;
|
|
1375
|
+
if (offset < bytes.length) {
|
|
1376
|
+
const v = decodeOptionString2(bytes, offset);
|
|
1377
|
+
offset += v.bytesRead;
|
|
1378
|
+
parent = v.value;
|
|
1379
|
+
}
|
|
1357
1380
|
const record = {
|
|
1358
1381
|
kbid: kbid.value,
|
|
1359
1382
|
docid: docid.value,
|
|
@@ -1375,7 +1398,8 @@ function decodeSectionRecords(bytes) {
|
|
|
1375
1398
|
updatedAt,
|
|
1376
1399
|
tags,
|
|
1377
1400
|
supersedes,
|
|
1378
|
-
level
|
|
1401
|
+
level,
|
|
1402
|
+
parent
|
|
1379
1403
|
};
|
|
1380
1404
|
if (st.mimeType !== void 0) {
|
|
1381
1405
|
record.mimeType = st.mimeType;
|
|
@@ -1588,12 +1612,18 @@ function decodeSibling(bytes, offset) {
|
|
|
1588
1612
|
pos += sectionType.bytesRead;
|
|
1589
1613
|
const content = decodeString(bytes, pos);
|
|
1590
1614
|
pos += content.bytesRead;
|
|
1615
|
+
const optLevel = decodeOptionU8(bytes, pos);
|
|
1616
|
+
pos += optLevel.bytesRead;
|
|
1617
|
+
const optParent = decodeOptionString3(bytes, pos);
|
|
1618
|
+
pos += optParent.bytesRead;
|
|
1591
1619
|
return {
|
|
1592
1620
|
value: {
|
|
1593
1621
|
kbid: kbid.value,
|
|
1594
1622
|
heading: heading.value,
|
|
1595
1623
|
type: sectionType.value,
|
|
1596
|
-
content: content.value
|
|
1624
|
+
content: content.value,
|
|
1625
|
+
level: optLevel.value,
|
|
1626
|
+
parent: optParent.value
|
|
1597
1627
|
},
|
|
1598
1628
|
bytesRead: pos - offset
|
|
1599
1629
|
};
|
|
@@ -1614,10 +1644,16 @@ function decodeDocument(bytes, offset) {
|
|
|
1614
1644
|
pos += secHeading.bytesRead;
|
|
1615
1645
|
const secType = decodeString(bytes, pos);
|
|
1616
1646
|
pos += secType.bytesRead;
|
|
1647
|
+
const secLevel = decodeOptionU8(bytes, pos);
|
|
1648
|
+
pos += secLevel.bytesRead;
|
|
1649
|
+
const secParent = decodeOptionString3(bytes, pos);
|
|
1650
|
+
pos += secParent.bytesRead;
|
|
1617
1651
|
sections.push({
|
|
1618
1652
|
kbid: secKbid.value,
|
|
1619
1653
|
heading: secHeading.value,
|
|
1620
|
-
type: secType.value
|
|
1654
|
+
type: secType.value,
|
|
1655
|
+
level: secLevel.value,
|
|
1656
|
+
parent: secParent.value
|
|
1621
1657
|
});
|
|
1622
1658
|
}
|
|
1623
1659
|
return {
|
|
@@ -1639,6 +1675,10 @@ function decodeOneResult(bytes, startOffset) {
|
|
|
1639
1675
|
pos += sectionType.bytesRead;
|
|
1640
1676
|
const content = decodeString(bytes, pos);
|
|
1641
1677
|
pos += content.bytesRead;
|
|
1678
|
+
const optLevel = decodeOptionU8(bytes, pos);
|
|
1679
|
+
pos += optLevel.bytesRead;
|
|
1680
|
+
const optParent = decodeOptionString3(bytes, pos);
|
|
1681
|
+
pos += optParent.bytesRead;
|
|
1642
1682
|
const docidCount = decodeU32(bytes, pos);
|
|
1643
1683
|
pos += docidCount.bytesRead;
|
|
1644
1684
|
const docids = [];
|
|
@@ -1685,6 +1725,8 @@ function decodeOneResult(bytes, startOffset) {
|
|
|
1685
1725
|
heading: heading.value,
|
|
1686
1726
|
type: sectionType.value,
|
|
1687
1727
|
content: content.value,
|
|
1728
|
+
level: optLevel.value,
|
|
1729
|
+
parent: optParent.value,
|
|
1688
1730
|
docids,
|
|
1689
1731
|
documents,
|
|
1690
1732
|
back_references,
|