@dikolab/kbdb 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/README.md +30 -9
  2. package/dist/cli.cjs +181 -50
  3. package/dist/cli.cjs.map +3 -3
  4. package/dist/cli.mjs +181 -50
  5. package/dist/cli.mjs.map +3 -3
  6. package/dist/kbdb-worker.cjs +283 -29
  7. package/dist/kbdb-worker.cjs.map +4 -4
  8. package/dist/mod.cjs +13 -2
  9. package/dist/mod.cjs.map +2 -2
  10. package/dist/mod.mjs +13 -2
  11. package/dist/mod.mjs.map +2 -2
  12. package/dist/src/shared/cli/functions/format-output.function.d.ts +7 -7
  13. package/dist/src/shared/cli/functions/run-search.function.d.ts +25 -16
  14. package/dist/src/shared/cli/index.d.ts +1 -1
  15. package/dist/src/shared/cli/typings/cli-options.interface.d.ts +2 -0
  16. package/dist/src/shared/cli/typings/search-display.model.d.ts +25 -7
  17. package/dist/src/shared/mcp/functions/handle-recall.function.d.ts +29 -0
  18. package/dist/src/shared/mcp/typings/mcp-client.interface.d.ts +30 -11
  19. package/dist/src/shared/version/constants/version.constant.d.ts +1 -1
  20. package/dist/src/shared/wasm-codec/functions/decode-recall-result.function.d.ts +28 -0
  21. package/dist/src/shared/wasm-codec/functions/decode-scored-results.function.d.ts +14 -7
  22. package/dist/src/shared/wasm-codec/functions/encode-recall-params.function.d.ts +21 -0
  23. package/dist/src/shared/wasm-codec/functions/encode-search-params.function.d.ts +1 -1
  24. package/dist/src/shared/wasm-codec/index.d.ts +5 -2
  25. package/dist/src/shared/worker-client/classes/worker-client.class.d.ts +13 -3
  26. package/dist/src/shared/worker-client/index.d.ts +2 -1
  27. package/dist/src/shared/worker-client/typings/recall-result.model.d.ts +94 -0
  28. package/dist/src/shared/worker-client/typings/search-params.model.d.ts +2 -0
  29. package/dist/src/shared/worker-client/typings/search-result.model.d.ts +23 -7
  30. package/dist/src/shared/worker-daemon/classes/worker-daemon.class.d.ts +1 -0
  31. package/dist/wasm/fs-database/kbdb_fs_database.d.ts +18 -0
  32. package/dist/wasm/fs-database/kbdb_fs_database.js +30 -0
  33. package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
  34. package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm.d.ts +2 -0
  35. package/dist/wasm/kb-worker/kbdb_worker.d.ts +38 -0
  36. package/dist/wasm/kb-worker/kbdb_worker.js +56 -0
  37. package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
  38. package/dist/wasm/kb-worker/kbdb_worker_bg.wasm.d.ts +3 -0
  39. package/dist/worker.mjs +283 -29
  40. package/dist/worker.mjs.map +4 -4
  41. package/docs/details/README.md +26 -0
  42. package/docs/details/cli.md +608 -0
  43. package/docs/details/library-api.md +406 -0
  44. package/docs/details/mcp-server.md +430 -0
  45. package/docs/details/search-and-ranking.md +457 -0
  46. package/docs/details/storage.md +529 -0
  47. package/docs/goals/agents.md +751 -0
  48. package/docs/goals/architecture.svg +198 -0
  49. package/docs/goals/cli.md +2308 -0
  50. package/docs/goals/content-composer.md +609 -0
  51. package/docs/goals/content-parser.md +279 -0
  52. package/docs/goals/database.md +1452 -0
  53. package/docs/goals/document.md +368 -0
  54. package/docs/goals/mcp.md +1467 -0
  55. package/docs/goals/overview.md +124 -0
  56. package/docs/goals/query-parser.md +271 -0
  57. package/docs/goals/query-result.md +693 -0
  58. package/docs/goals/skills.md +738 -0
  59. package/docs/goals/worker-client.md +944 -0
  60. package/docs/goals/worker-daemon.md +1447 -0
  61. package/docs/modules/overview.md +298 -0
  62. package/docs/modules/rust/fs-database/functions/document.md +48 -0
  63. package/docs/modules/rust/fs-database/functions/integrity.md +68 -0
  64. package/docs/modules/rust/fs-database/functions/io.md +87 -0
  65. package/docs/modules/rust/fs-database/functions/module.md +22 -0
  66. package/docs/modules/rust/fs-database/functions/query-exec.md +44 -0
  67. package/docs/modules/rust/fs-database/functions/section.md +59 -0
  68. package/docs/modules/rust/fs-database/indexes/btree.md +35 -0
  69. package/docs/modules/rust/fs-database/indexes/corpus.md +61 -0
  70. package/docs/modules/rust/fs-database/indexes/inverted.md +60 -0
  71. package/docs/modules/rust/fs-database/indexes/module.md +64 -0
  72. package/docs/modules/rust/fs-database/indexes/positional.md +39 -0
  73. package/docs/modules/rust/fs-database/module.md +149 -0
  74. package/docs/modules/rust/fs-database/types/catalog.md +53 -0
  75. package/docs/modules/rust/fs-database/types/module.md +12 -0
  76. package/docs/modules/rust/fs-database/types/section.md +101 -0
  77. package/docs/modules/rust/kb-worker/functions/compose.md +57 -0
  78. package/docs/modules/rust/kb-worker/functions/module.md +20 -0
  79. package/docs/modules/rust/kb-worker/functions/retrieve.md +194 -0
  80. package/docs/modules/rust/kb-worker/functions/search.md +173 -0
  81. package/docs/modules/rust/kb-worker/functions/write.md +172 -0
  82. package/docs/modules/rust/kb-worker/module.md +171 -0
  83. package/docs/modules/rust/kb-worker/types/cache.md +90 -0
  84. package/docs/modules/rust/kb-worker/types/context.md +26 -0
  85. package/docs/modules/rust/kb-worker/types/module.md +16 -0
  86. package/docs/modules/rust/kb-worker/types/status.md +29 -0
  87. package/docs/modules/rust/kb-worker/types/token.md +50 -0
  88. package/docs/modules/rust/overview.md +495 -0
  89. package/docs/modules/rust/query-parser/functions/extract.md +56 -0
  90. package/docs/modules/rust/query-parser/functions/module.md +16 -0
  91. package/docs/modules/rust/query-parser/functions/parse.md +33 -0
  92. package/docs/modules/rust/query-parser/functions/pipeline.md +103 -0
  93. package/docs/modules/rust/query-parser/functions/rank.md +85 -0
  94. package/docs/modules/rust/query-parser/module.md +136 -0
  95. package/docs/modules/rust/query-parser/types/cache.md +39 -0
  96. package/docs/modules/rust/query-parser/types/keyphrase.md +60 -0
  97. package/docs/modules/rust/query-parser/types/module.md +17 -0
  98. package/docs/modules/rust/query-parser/types/token.md +42 -0
  99. package/docs/modules/rust/shared/content-composer/functions.md +114 -0
  100. package/docs/modules/rust/shared/content-composer/module.md +147 -0
  101. package/docs/modules/rust/shared/content-composer/types.md +93 -0
  102. package/docs/modules/rust/shared/content-parser/functions.md +72 -0
  103. package/docs/modules/rust/shared/content-parser/module.md +99 -0
  104. package/docs/modules/rust/shared/content-parser/types.md +71 -0
  105. package/docs/modules/rust/shared/corpus/module.md +24 -0
  106. package/docs/modules/rust/shared/corpus/types.md +141 -0
  107. package/docs/modules/rust/shared/document/module.md +25 -0
  108. package/docs/modules/rust/shared/document/types.md +154 -0
  109. package/docs/modules/rust/shared/encode/module.md +22 -0
  110. package/docs/modules/rust/shared/encode/traits.md +304 -0
  111. package/docs/modules/rust/shared/error/module.md +28 -0
  112. package/docs/modules/rust/shared/error/types.md +302 -0
  113. package/docs/modules/rust/shared/kbid/module.md +24 -0
  114. package/docs/modules/rust/shared/kbid/types.md +147 -0
  115. package/docs/modules/rust/shared/memory/functions.md +209 -0
  116. package/docs/modules/rust/shared/memory/module.md +24 -0
  117. package/docs/modules/rust/shared/module.md +168 -0
  118. package/docs/modules/rust/shared/query/module.md +27 -0
  119. package/docs/modules/rust/shared/query/types.md +236 -0
  120. package/docs/modules/rust/shared/section/module.md +25 -0
  121. package/docs/modules/rust/shared/section/types.md +294 -0
  122. package/docs/modules/rust/shared/term/module.md +25 -0
  123. package/docs/modules/rust/shared/term/types.md +139 -0
  124. package/docs/modules/typescript/cli.md +129 -0
  125. package/docs/modules/typescript/kbdb-worker.md +135 -0
  126. package/docs/modules/typescript/overview.md +378 -0
  127. package/docs/modules/typescript/shared/cli/constants.md +23 -0
  128. package/docs/modules/typescript/shared/cli/functions.md +630 -0
  129. package/docs/modules/typescript/shared/cli/module.md +125 -0
  130. package/docs/modules/typescript/shared/cli/typings.md +172 -0
  131. package/docs/modules/typescript/shared/hash/functions.md +20 -0
  132. package/docs/modules/typescript/shared/hash/module.md +21 -0
  133. package/docs/modules/typescript/shared/mcp/classes.md +179 -0
  134. package/docs/modules/typescript/shared/mcp/functions.md +386 -0
  135. package/docs/modules/typescript/shared/mcp/module.md +160 -0
  136. package/docs/modules/typescript/shared/mcp/typings.md +522 -0
  137. package/docs/modules/typescript/shared/module.md +94 -0
  138. package/docs/modules/typescript/shared/platform/functions.md +42 -0
  139. package/docs/modules/typescript/shared/platform/module.md +25 -0
  140. package/docs/modules/typescript/shared/runtime/functions.md +26 -0
  141. package/docs/modules/typescript/shared/runtime/module.md +27 -0
  142. package/docs/modules/typescript/shared/runtime/typings.md +13 -0
  143. package/docs/modules/typescript/shared/version/module.md +27 -0
  144. package/docs/modules/typescript/shared/wasm-codec/functions.md +391 -0
  145. package/docs/modules/typescript/shared/wasm-codec/module.md +98 -0
  146. package/docs/modules/typescript/shared/worker-client/classes.md +264 -0
  147. package/docs/modules/typescript/shared/worker-client/functions.md +175 -0
  148. package/docs/modules/typescript/shared/worker-client/module.md +84 -0
  149. package/docs/modules/typescript/shared/worker-client/typings.md +508 -0
  150. package/docs/modules/typescript/shared/worker-daemon/classes.md +239 -0
  151. package/docs/modules/typescript/shared/worker-daemon/constants.md +37 -0
  152. package/docs/modules/typescript/shared/worker-daemon/functions.md +221 -0
  153. package/docs/modules/typescript/shared/worker-daemon/module.md +112 -0
  154. package/docs/modules/typescript/shared/worker-daemon/typings.md +126 -0
  155. package/docs/overview.md +188 -0
  156. package/docs/release-notes/0.1.0.md +189 -0
  157. package/docs/release-notes/0.1.1.md +46 -0
  158. package/docs/release-notes/0.1.2.md +38 -0
  159. package/docs/release-notes/0.1.3.md +42 -0
  160. package/docs/release-notes/0.2.0.md +147 -0
  161. package/docs/release-notes/README.md +9 -0
  162. package/package.json +8 -2
  163. package/src/shared/cli/functions/dispatch-command.function.ts +3 -3
  164. package/src/shared/cli/functions/format-output.function.ts +41 -34
  165. package/src/shared/cli/functions/parse-args.function.ts +7 -0
  166. package/src/shared/cli/functions/run-search.function.ts +53 -27
  167. package/src/shared/cli/index.ts +4 -1
  168. package/src/shared/cli/typings/cli-options.interface.ts +2 -0
  169. package/src/shared/cli/typings/search-display.model.ts +26 -7
  170. package/src/shared/mcp/functions/create-tool-definitions.function.ts +64 -4
  171. package/src/shared/mcp/functions/handle-recall.function.ts +66 -0
  172. package/src/shared/mcp/functions/handle-tool-call.function.ts +11 -1
  173. package/src/shared/mcp/typings/mcp-client.interface.ts +33 -15
  174. package/src/shared/version/constants/version.constant.ts +1 -1
  175. package/src/shared/wasm-codec/functions/decode-recall-result.function.ts +267 -0
  176. package/src/shared/wasm-codec/functions/decode-scored-results.function.ts +81 -27
  177. package/src/shared/wasm-codec/functions/encode-recall-params.function.ts +68 -0
  178. package/src/shared/wasm-codec/functions/encode-search-params.function.ts +4 -1
  179. package/src/shared/wasm-codec/index.ts +11 -3
  180. package/src/shared/worker-client/classes/worker-client.class.ts +24 -4
  181. package/src/shared/worker-client/index.ts +11 -1
  182. package/src/shared/worker-client/typings/recall-result.model.ts +98 -0
  183. package/src/shared/worker-client/typings/search-params.model.ts +2 -0
  184. package/src/shared/worker-client/typings/search-result.model.ts +24 -7
  185. package/src/shared/worker-daemon/classes/worker-daemon.class.ts +25 -4
  186. package/src/wasm/fs-database/kbdb_fs_database.d.ts +18 -0
  187. package/src/wasm/fs-database/kbdb_fs_database.js +30 -0
  188. package/src/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
  189. package/src/wasm/fs-database/kbdb_fs_database_bg.wasm.d.ts +2 -0
  190. package/src/wasm/kb-worker/kbdb_worker.d.ts +38 -0
  191. package/src/wasm/kb-worker/kbdb_worker.js +56 -0
  192. package/src/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
  193. package/src/wasm/kb-worker/kbdb_worker_bg.wasm.d.ts +3 -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(results, format) {
121
+ function formatOutput(paged, format) {
115
122
  switch (format) {
116
123
  case "json":
117
- return JSON.stringify(results, null, 2);
124
+ return JSON.stringify(paged, null, 2);
118
125
  case "text":
119
- return formatText(results);
126
+ return formatText(paged);
120
127
  case "mcp":
121
- return formatMcp(results);
122
- }
123
- }
124
- function formatText(results) {
125
- if (results.length === 0) return "No results found.";
126
- return results.map(
127
- (r, i) => `${String(i + 1)}. [${r.kbid}] (score: ${r.score.toFixed(4)})
128
- ${r.preview}
129
- matches: ${r.matches.map((m) => m.term).join(", ")}`
130
- ).join("\n\n");
131
- }
132
- function formatMcp(results) {
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: results.map(
136
- (r) => `[${r.kbid}] score=${r.score.toFixed(4)} \u2014 ${r.preview}`
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) return [];
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 results.map((r) => ({
151
- kbid: r.kbid,
152
- score: r.score,
153
- preview: "",
154
- matches: r.matches
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, results) {
911
+ async function hydrateSearchPreviews(client, paged) {
876
912
  await Promise.all(
877
- results.map(async (result) => {
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.6";
924
+ var VERSION = "0.2.0";
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 ranked list of matching sections
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 relevant sections using natural language queries.",
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: "Retrieve a section or document by ID. Provide kbid or docid.",
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(results, null, 2)
2783
+ text: JSON.stringify(stripped, null, 2)
2653
2784
  }
2654
2785
  ]
2655
2786
  };