@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/cli.mjs
CHANGED
|
@@ -71,6 +71,13 @@ function parseArgs(argv) {
|
|
|
71
71
|
case "-l":
|
|
72
72
|
options.limit = parseInt(argv[++i] ?? "", 10) || DEFAULT_LIMIT;
|
|
73
73
|
break;
|
|
74
|
+
case "--offset":
|
|
75
|
+
case "-o":
|
|
76
|
+
options.offset = Math.max(
|
|
77
|
+
0,
|
|
78
|
+
parseInt(argv[++i] ?? "", 10) || 0
|
|
79
|
+
);
|
|
80
|
+
break;
|
|
74
81
|
case "--title":
|
|
75
82
|
options.title = argv[++i];
|
|
76
83
|
break;
|
|
@@ -111,29 +118,39 @@ function parseArgs(argv) {
|
|
|
111
118
|
}
|
|
112
119
|
|
|
113
120
|
// src/shared/cli/functions/format-output.function.ts
|
|
114
|
-
function formatOutput(
|
|
121
|
+
function formatOutput(paged, format) {
|
|
115
122
|
switch (format) {
|
|
116
123
|
case "json":
|
|
117
|
-
return JSON.stringify(
|
|
124
|
+
return JSON.stringify(paged, null, 2);
|
|
118
125
|
case "text":
|
|
119
|
-
return formatText(
|
|
126
|
+
return formatText(paged);
|
|
120
127
|
case "mcp":
|
|
121
|
-
return formatMcp(
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
function formatText(
|
|
125
|
-
if (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
return formatMcp(paged);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function formatText(paged) {
|
|
132
|
+
if (paged.items.length === 0) return "No results found.";
|
|
133
|
+
const start = paged.offset + 1;
|
|
134
|
+
const end = paged.offset + paged.items.length;
|
|
135
|
+
const lines = paged.items.map((r, i) => {
|
|
136
|
+
const num = paged.offset + i + 1;
|
|
137
|
+
const heading = r.heading ?? "(untitled)";
|
|
138
|
+
const terms = r.matched_terms.join(", ");
|
|
139
|
+
return `${String(num)}. [${r.kbid}] ${heading} (score: ${r.score.toFixed(4)})
|
|
140
|
+
${r.snippet || r.preview || "(no snippet)"}
|
|
141
|
+
type: ${r.type} terms: ${terms}`;
|
|
142
|
+
}).join("\n\n");
|
|
143
|
+
const footer = `
|
|
144
|
+
Showing ${String(start)}-${String(end)} of ${String(paged.total)} results`;
|
|
145
|
+
const hint = paged.has_more ? `
|
|
146
|
+
Use --offset ${String(end)} to see more` : "";
|
|
147
|
+
return lines + footer + hint;
|
|
148
|
+
}
|
|
149
|
+
function formatMcp(paged) {
|
|
133
150
|
return JSON.stringify({
|
|
134
151
|
type: "text",
|
|
135
|
-
text:
|
|
136
|
-
(r) => `[${r.kbid}]
|
|
152
|
+
text: paged.items.map(
|
|
153
|
+
(r) => `[${r.kbid}] ${r.heading ?? "(untitled)"} \u2014 ${r.snippet || r.preview}`
|
|
137
154
|
).join("\n")
|
|
138
155
|
});
|
|
139
156
|
}
|
|
@@ -141,18 +158,37 @@ function formatMcp(results) {
|
|
|
141
158
|
// src/shared/cli/functions/run-search.function.ts
|
|
142
159
|
async function runSearch(client, options) {
|
|
143
160
|
const query = options.args.join(" ").trim();
|
|
144
|
-
if (!query)
|
|
161
|
+
if (!query) {
|
|
162
|
+
return {
|
|
163
|
+
items: [],
|
|
164
|
+
total: 0,
|
|
165
|
+
offset: 0,
|
|
166
|
+
limit: options.limit,
|
|
167
|
+
has_more: false
|
|
168
|
+
};
|
|
169
|
+
}
|
|
145
170
|
const results = await client.search({
|
|
146
171
|
query,
|
|
147
172
|
mode: options.mode,
|
|
148
|
-
limit: options.limit
|
|
173
|
+
limit: options.limit,
|
|
174
|
+
offset: options.offset
|
|
149
175
|
});
|
|
150
|
-
return
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
176
|
+
return {
|
|
177
|
+
items: results.items.map((r) => ({
|
|
178
|
+
kbid: r.kbid,
|
|
179
|
+
heading: r.heading,
|
|
180
|
+
type: r.type,
|
|
181
|
+
docids: r.docids,
|
|
182
|
+
score: r.score,
|
|
183
|
+
snippet: r.snippet,
|
|
184
|
+
matched_terms: r.matched_terms,
|
|
185
|
+
preview: ""
|
|
186
|
+
})),
|
|
187
|
+
total: results.total,
|
|
188
|
+
offset: results.offset,
|
|
189
|
+
limit: results.limit,
|
|
190
|
+
has_more: results.has_more
|
|
191
|
+
};
|
|
156
192
|
}
|
|
157
193
|
|
|
158
194
|
// src/shared/cli/functions/run-learn.function.ts
|
|
@@ -872,9 +908,9 @@ async function handleDbMigrate(client, options) {
|
|
|
872
908
|
};
|
|
873
909
|
}
|
|
874
910
|
}
|
|
875
|
-
async function hydrateSearchPreviews(client,
|
|
911
|
+
async function hydrateSearchPreviews(client, paged) {
|
|
876
912
|
await Promise.all(
|
|
877
|
-
|
|
913
|
+
paged.items.map(async (result) => {
|
|
878
914
|
try {
|
|
879
915
|
const contentResult = await client.content([result.kbid]);
|
|
880
916
|
result.preview = contentResult.data;
|
|
@@ -885,7 +921,7 @@ async function hydrateSearchPreviews(client, results) {
|
|
|
885
921
|
}
|
|
886
922
|
|
|
887
923
|
// src/shared/version/constants/version.constant.ts
|
|
888
|
-
var VERSION = "0.1
|
|
924
|
+
var VERSION = "0.2.1";
|
|
889
925
|
|
|
890
926
|
// src/shared/cli/functions/generate-help.function.ts
|
|
891
927
|
var KNOWN_COMMANDS = /* @__PURE__ */ new Set([
|
|
@@ -1594,11 +1630,22 @@ var WorkerClient = class {
|
|
|
1594
1630
|
* Searches the knowledge base.
|
|
1595
1631
|
*
|
|
1596
1632
|
* @param params - query parameters including the search string
|
|
1597
|
-
* @returns
|
|
1633
|
+
* @returns paginated search results with metadata
|
|
1598
1634
|
*/
|
|
1599
1635
|
async search(params) {
|
|
1600
1636
|
return this.call("search", params);
|
|
1601
1637
|
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Retrieves full content and context for one or more sections by
|
|
1640
|
+
* their knowledge-base identifiers.
|
|
1641
|
+
*
|
|
1642
|
+
* @param params - section identifier(s) and optional expansion depth
|
|
1643
|
+
* @returns a single `RecallResult` when `kbid` is provided without
|
|
1644
|
+
* `kbids`, or a `RecallResult[]` when `kbids` is provided
|
|
1645
|
+
*/
|
|
1646
|
+
async recall(params) {
|
|
1647
|
+
return this.call("recall", params);
|
|
1648
|
+
}
|
|
1602
1649
|
/**
|
|
1603
1650
|
* Adds a new section to the knowledge base.
|
|
1604
1651
|
*
|
|
@@ -2016,7 +2063,7 @@ function createToolDefinitions() {
|
|
|
2016
2063
|
return [
|
|
2017
2064
|
{
|
|
2018
2065
|
name: "search",
|
|
2019
|
-
description: "Search the knowledge base for
|
|
2066
|
+
description: "Search the knowledge base. Returns ranked results with headings and snippets for relevance evaluation. Use `recall` to get full content of specific results.",
|
|
2020
2067
|
inputSchema: {
|
|
2021
2068
|
type: "object",
|
|
2022
2069
|
properties: {
|
|
@@ -2032,6 +2079,10 @@ function createToolDefinitions() {
|
|
|
2032
2079
|
limit: {
|
|
2033
2080
|
type: "number",
|
|
2034
2081
|
description: "Maximum results (default: 20)"
|
|
2082
|
+
},
|
|
2083
|
+
offset: {
|
|
2084
|
+
type: "number",
|
|
2085
|
+
description: "Number of results to skip for pagination (default: 0)"
|
|
2035
2086
|
}
|
|
2036
2087
|
},
|
|
2037
2088
|
required: ["query"]
|
|
@@ -2040,7 +2091,8 @@ function createToolDefinitions() {
|
|
|
2040
2091
|
title: "Search KB",
|
|
2041
2092
|
readOnlyHint: true,
|
|
2042
2093
|
destructiveHint: false,
|
|
2043
|
-
idempotentHint: true
|
|
2094
|
+
idempotentHint: true,
|
|
2095
|
+
openWorldHint: false
|
|
2044
2096
|
}
|
|
2045
2097
|
},
|
|
2046
2098
|
{
|
|
@@ -2076,7 +2128,8 @@ function createToolDefinitions() {
|
|
|
2076
2128
|
title: "Import Content",
|
|
2077
2129
|
readOnlyHint: false,
|
|
2078
2130
|
destructiveHint: false,
|
|
2079
|
-
idempotentHint: true
|
|
2131
|
+
idempotentHint: true,
|
|
2132
|
+
openWorldHint: false
|
|
2080
2133
|
}
|
|
2081
2134
|
},
|
|
2082
2135
|
{
|
|
@@ -2096,12 +2149,13 @@ function createToolDefinitions() {
|
|
|
2096
2149
|
title: "Remove Section",
|
|
2097
2150
|
readOnlyHint: false,
|
|
2098
2151
|
destructiveHint: true,
|
|
2099
|
-
idempotentHint: true
|
|
2152
|
+
idempotentHint: true,
|
|
2153
|
+
openWorldHint: false
|
|
2100
2154
|
}
|
|
2101
2155
|
},
|
|
2102
2156
|
{
|
|
2103
2157
|
name: "retrieve",
|
|
2104
|
-
description: "
|
|
2158
|
+
description: "Low-level fetch of a section or document by identifier. For AI agent workflows, prefer `recall` which includes metadata, context, and back-references.",
|
|
2105
2159
|
inputSchema: {
|
|
2106
2160
|
type: "object",
|
|
2107
2161
|
properties: {
|
|
@@ -2119,7 +2173,37 @@ function createToolDefinitions() {
|
|
|
2119
2173
|
title: "Fetch Content",
|
|
2120
2174
|
readOnlyHint: true,
|
|
2121
2175
|
destructiveHint: false,
|
|
2122
|
-
idempotentHint: true
|
|
2176
|
+
idempotentHint: true,
|
|
2177
|
+
openWorldHint: false
|
|
2178
|
+
}
|
|
2179
|
+
},
|
|
2180
|
+
{
|
|
2181
|
+
name: "recall",
|
|
2182
|
+
description: "Retrieve full content and context for sections by identifier. Use after search to read relevant results. Returns section text, metadata, references, and back-references.",
|
|
2183
|
+
inputSchema: {
|
|
2184
|
+
type: "object",
|
|
2185
|
+
properties: {
|
|
2186
|
+
kbid: {
|
|
2187
|
+
type: "string",
|
|
2188
|
+
description: "Single section identifier"
|
|
2189
|
+
},
|
|
2190
|
+
kbids: {
|
|
2191
|
+
type: "array",
|
|
2192
|
+
items: { type: "string" },
|
|
2193
|
+
description: "Batch section identifiers"
|
|
2194
|
+
},
|
|
2195
|
+
depth: {
|
|
2196
|
+
type: "number",
|
|
2197
|
+
description: "Expansion depth (0-3, default: 0)"
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
},
|
|
2201
|
+
annotations: {
|
|
2202
|
+
title: "Recall Context",
|
|
2203
|
+
readOnlyHint: true,
|
|
2204
|
+
destructiveHint: false,
|
|
2205
|
+
idempotentHint: true,
|
|
2206
|
+
openWorldHint: false
|
|
2123
2207
|
}
|
|
2124
2208
|
},
|
|
2125
2209
|
{
|
|
@@ -2133,7 +2217,8 @@ function createToolDefinitions() {
|
|
|
2133
2217
|
title: "DB Status",
|
|
2134
2218
|
readOnlyHint: true,
|
|
2135
2219
|
destructiveHint: false,
|
|
2136
|
-
idempotentHint: true
|
|
2220
|
+
idempotentHint: true,
|
|
2221
|
+
openWorldHint: false
|
|
2137
2222
|
}
|
|
2138
2223
|
},
|
|
2139
2224
|
{
|
|
@@ -2154,7 +2239,8 @@ function createToolDefinitions() {
|
|
|
2154
2239
|
title: "Compose Content",
|
|
2155
2240
|
readOnlyHint: true,
|
|
2156
2241
|
destructiveHint: false,
|
|
2157
|
-
idempotentHint: true
|
|
2242
|
+
idempotentHint: true,
|
|
2243
|
+
openWorldHint: false
|
|
2158
2244
|
}
|
|
2159
2245
|
},
|
|
2160
2246
|
{
|
|
@@ -2168,7 +2254,8 @@ function createToolDefinitions() {
|
|
|
2168
2254
|
title: "Integrity Check",
|
|
2169
2255
|
readOnlyHint: true,
|
|
2170
2256
|
destructiveHint: false,
|
|
2171
|
-
idempotentHint: true
|
|
2257
|
+
idempotentHint: true,
|
|
2258
|
+
openWorldHint: false
|
|
2172
2259
|
}
|
|
2173
2260
|
},
|
|
2174
2261
|
{
|
|
@@ -2182,7 +2269,8 @@ function createToolDefinitions() {
|
|
|
2182
2269
|
title: "Garbage Collect",
|
|
2183
2270
|
readOnlyHint: false,
|
|
2184
2271
|
destructiveHint: true,
|
|
2185
|
-
idempotentHint: false
|
|
2272
|
+
idempotentHint: false,
|
|
2273
|
+
openWorldHint: false
|
|
2186
2274
|
}
|
|
2187
2275
|
},
|
|
2188
2276
|
{
|
|
@@ -2196,7 +2284,8 @@ function createToolDefinitions() {
|
|
|
2196
2284
|
title: "Rebuild Indexes",
|
|
2197
2285
|
readOnlyHint: false,
|
|
2198
2286
|
destructiveHint: false,
|
|
2199
|
-
idempotentHint: false
|
|
2287
|
+
idempotentHint: false,
|
|
2288
|
+
openWorldHint: false
|
|
2200
2289
|
}
|
|
2201
2290
|
},
|
|
2202
2291
|
{
|
|
@@ -2224,7 +2313,8 @@ function createToolDefinitions() {
|
|
|
2224
2313
|
title: "Create Skill",
|
|
2225
2314
|
readOnlyHint: false,
|
|
2226
2315
|
destructiveHint: false,
|
|
2227
|
-
idempotentHint: true
|
|
2316
|
+
idempotentHint: true,
|
|
2317
|
+
openWorldHint: false
|
|
2228
2318
|
}
|
|
2229
2319
|
},
|
|
2230
2320
|
{
|
|
@@ -2238,7 +2328,8 @@ function createToolDefinitions() {
|
|
|
2238
2328
|
title: "List Skills",
|
|
2239
2329
|
readOnlyHint: true,
|
|
2240
2330
|
destructiveHint: false,
|
|
2241
|
-
idempotentHint: true
|
|
2331
|
+
idempotentHint: true,
|
|
2332
|
+
openWorldHint: false
|
|
2242
2333
|
}
|
|
2243
2334
|
},
|
|
2244
2335
|
{
|
|
@@ -2261,7 +2352,8 @@ function createToolDefinitions() {
|
|
|
2261
2352
|
title: "Get Skill",
|
|
2262
2353
|
readOnlyHint: true,
|
|
2263
2354
|
destructiveHint: false,
|
|
2264
|
-
idempotentHint: true
|
|
2355
|
+
idempotentHint: true,
|
|
2356
|
+
openWorldHint: false
|
|
2265
2357
|
}
|
|
2266
2358
|
},
|
|
2267
2359
|
{
|
|
@@ -2281,7 +2373,8 @@ function createToolDefinitions() {
|
|
|
2281
2373
|
title: "Delete Skill",
|
|
2282
2374
|
readOnlyHint: false,
|
|
2283
2375
|
destructiveHint: true,
|
|
2284
|
-
idempotentHint: true
|
|
2376
|
+
idempotentHint: true,
|
|
2377
|
+
openWorldHint: false
|
|
2285
2378
|
}
|
|
2286
2379
|
},
|
|
2287
2380
|
{
|
|
@@ -2314,7 +2407,8 @@ function createToolDefinitions() {
|
|
|
2314
2407
|
title: "Create Agent",
|
|
2315
2408
|
readOnlyHint: false,
|
|
2316
2409
|
destructiveHint: false,
|
|
2317
|
-
idempotentHint: true
|
|
2410
|
+
idempotentHint: true,
|
|
2411
|
+
openWorldHint: false
|
|
2318
2412
|
}
|
|
2319
2413
|
},
|
|
2320
2414
|
{
|
|
@@ -2328,7 +2422,8 @@ function createToolDefinitions() {
|
|
|
2328
2422
|
title: "List Agents",
|
|
2329
2423
|
readOnlyHint: true,
|
|
2330
2424
|
destructiveHint: false,
|
|
2331
|
-
idempotentHint: true
|
|
2425
|
+
idempotentHint: true,
|
|
2426
|
+
openWorldHint: false
|
|
2332
2427
|
}
|
|
2333
2428
|
},
|
|
2334
2429
|
{
|
|
@@ -2348,7 +2443,8 @@ function createToolDefinitions() {
|
|
|
2348
2443
|
title: "Get Agent",
|
|
2349
2444
|
readOnlyHint: true,
|
|
2350
2445
|
destructiveHint: false,
|
|
2351
|
-
idempotentHint: true
|
|
2446
|
+
idempotentHint: true,
|
|
2447
|
+
openWorldHint: false
|
|
2352
2448
|
}
|
|
2353
2449
|
},
|
|
2354
2450
|
{
|
|
@@ -2368,7 +2464,8 @@ function createToolDefinitions() {
|
|
|
2368
2464
|
title: "Delete Agent",
|
|
2369
2465
|
readOnlyHint: false,
|
|
2370
2466
|
destructiveHint: true,
|
|
2371
|
-
idempotentHint: true
|
|
2467
|
+
idempotentHint: true,
|
|
2468
|
+
openWorldHint: false
|
|
2372
2469
|
}
|
|
2373
2470
|
}
|
|
2374
2471
|
];
|
|
@@ -2569,6 +2666,33 @@ async function handleAgentDelete(client, args) {
|
|
|
2569
2666
|
};
|
|
2570
2667
|
}
|
|
2571
2668
|
|
|
2669
|
+
// src/shared/mcp/functions/handle-recall.function.ts
|
|
2670
|
+
async function handleRecall(client, args) {
|
|
2671
|
+
const kbid = typeof args["kbid"] === "string" ? args["kbid"] : void 0;
|
|
2672
|
+
const kbids = Array.isArray(args["kbids"]) && args["kbids"].every((item) => typeof item === "string") ? args["kbids"] : void 0;
|
|
2673
|
+
if (!kbid && !kbids) {
|
|
2674
|
+
return {
|
|
2675
|
+
content: [
|
|
2676
|
+
{
|
|
2677
|
+
type: "text",
|
|
2678
|
+
text: "Provide kbid or kbids"
|
|
2679
|
+
}
|
|
2680
|
+
],
|
|
2681
|
+
isError: true
|
|
2682
|
+
};
|
|
2683
|
+
}
|
|
2684
|
+
const depth = typeof args["depth"] === "number" ? args["depth"] : 0;
|
|
2685
|
+
const result = await client.recall({ kbid, kbids, depth });
|
|
2686
|
+
return {
|
|
2687
|
+
content: [
|
|
2688
|
+
{
|
|
2689
|
+
type: "text",
|
|
2690
|
+
text: JSON.stringify(result, null, 2)
|
|
2691
|
+
}
|
|
2692
|
+
]
|
|
2693
|
+
};
|
|
2694
|
+
}
|
|
2695
|
+
|
|
2572
2696
|
// src/shared/mcp/functions/handle-tool-call.function.ts
|
|
2573
2697
|
function asString2(value, fallback) {
|
|
2574
2698
|
return typeof value === "string" ? value : fallback;
|
|
@@ -2590,6 +2714,8 @@ async function handleToolCall(client, name, args) {
|
|
|
2590
2714
|
return await handleUnlearn2(client, args);
|
|
2591
2715
|
case "retrieve":
|
|
2592
2716
|
return await handleRetrieve(client, args);
|
|
2717
|
+
case "recall":
|
|
2718
|
+
return await handleRecall(client, args);
|
|
2593
2719
|
case "status":
|
|
2594
2720
|
return await handleStatus2(client);
|
|
2595
2721
|
case "content":
|
|
@@ -2643,13 +2769,18 @@ async function handleSearch2(client, args) {
|
|
|
2643
2769
|
const results = await client.search({
|
|
2644
2770
|
query: asString2(args["query"], ""),
|
|
2645
2771
|
mode: args["mode"],
|
|
2646
|
-
limit: args["limit"]
|
|
2772
|
+
limit: args["limit"],
|
|
2773
|
+
offset: args["offset"]
|
|
2647
2774
|
});
|
|
2775
|
+
const stripped = {
|
|
2776
|
+
...results,
|
|
2777
|
+
items: results.items.map(({ score: _score, ...rest }) => rest)
|
|
2778
|
+
};
|
|
2648
2779
|
return {
|
|
2649
2780
|
content: [
|
|
2650
2781
|
{
|
|
2651
2782
|
type: "text",
|
|
2652
|
-
text: JSON.stringify(
|
|
2783
|
+
text: JSON.stringify(stripped, null, 2)
|
|
2653
2784
|
}
|
|
2654
2785
|
]
|
|
2655
2786
|
};
|