@nhtio/adk 0.1.0-master-f0aa531d

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 (297) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +3 -0
  3. package/batteries/index.d.ts +28 -0
  4. package/batteries/llm/index.d.ts +11 -0
  5. package/batteries/llm/openai_chat_completions/adapter.cjs +916 -0
  6. package/batteries/llm/openai_chat_completions/adapter.cjs.map +1 -0
  7. package/batteries/llm/openai_chat_completions/adapter.d.ts +101 -0
  8. package/batteries/llm/openai_chat_completions/adapter.mjs +914 -0
  9. package/batteries/llm/openai_chat_completions/adapter.mjs.map +1 -0
  10. package/batteries/llm/openai_chat_completions/exceptions.cjs +89 -0
  11. package/batteries/llm/openai_chat_completions/exceptions.cjs.map +1 -0
  12. package/batteries/llm/openai_chat_completions/exceptions.d.ts +97 -0
  13. package/batteries/llm/openai_chat_completions/exceptions.mjs +81 -0
  14. package/batteries/llm/openai_chat_completions/exceptions.mjs.map +1 -0
  15. package/batteries/llm/openai_chat_completions/helpers.cjs +819 -0
  16. package/batteries/llm/openai_chat_completions/helpers.cjs.map +1 -0
  17. package/batteries/llm/openai_chat_completions/helpers.d.ts +233 -0
  18. package/batteries/llm/openai_chat_completions/helpers.mjs +783 -0
  19. package/batteries/llm/openai_chat_completions/helpers.mjs.map +1 -0
  20. package/batteries/llm/openai_chat_completions/index.d.ts +27 -0
  21. package/batteries/llm/openai_chat_completions/types.cjs +1 -0
  22. package/batteries/llm/openai_chat_completions/types.d.ts +524 -0
  23. package/batteries/llm/openai_chat_completions/types.mjs +0 -0
  24. package/batteries/llm/openai_chat_completions/validation.cjs +190 -0
  25. package/batteries/llm/openai_chat_completions/validation.cjs.map +1 -0
  26. package/batteries/llm/openai_chat_completions/validation.d.ts +31 -0
  27. package/batteries/llm/openai_chat_completions/validation.mjs +187 -0
  28. package/batteries/llm/openai_chat_completions/validation.mjs.map +1 -0
  29. package/batteries/llm/openai_chat_completions.cjs +51 -0
  30. package/batteries/llm/openai_chat_completions.mjs +5 -0
  31. package/batteries/llm/webllm_chat_completions/adapter.cjs +658 -0
  32. package/batteries/llm/webllm_chat_completions/adapter.cjs.map +1 -0
  33. package/batteries/llm/webllm_chat_completions/adapter.d.ts +103 -0
  34. package/batteries/llm/webllm_chat_completions/adapter.mjs +656 -0
  35. package/batteries/llm/webllm_chat_completions/adapter.mjs.map +1 -0
  36. package/batteries/llm/webllm_chat_completions/exceptions.cjs +70 -0
  37. package/batteries/llm/webllm_chat_completions/exceptions.cjs.map +1 -0
  38. package/batteries/llm/webllm_chat_completions/exceptions.d.ts +74 -0
  39. package/batteries/llm/webllm_chat_completions/exceptions.mjs +65 -0
  40. package/batteries/llm/webllm_chat_completions/exceptions.mjs.map +1 -0
  41. package/batteries/llm/webllm_chat_completions/helpers.cjs +38 -0
  42. package/batteries/llm/webllm_chat_completions/helpers.d.ts +6 -0
  43. package/batteries/llm/webllm_chat_completions/helpers.mjs +2 -0
  44. package/batteries/llm/webllm_chat_completions/index.d.ts +25 -0
  45. package/batteries/llm/webllm_chat_completions/types.d.ts +31 -0
  46. package/batteries/llm/webllm_chat_completions/validation.cjs +115 -0
  47. package/batteries/llm/webllm_chat_completions/validation.cjs.map +1 -0
  48. package/batteries/llm/webllm_chat_completions/validation.d.ts +8 -0
  49. package/batteries/llm/webllm_chat_completions/validation.mjs +112 -0
  50. package/batteries/llm/webllm_chat_completions/validation.mjs.map +1 -0
  51. package/batteries/llm/webllm_chat_completions.cjs +50 -0
  52. package/batteries/llm/webllm_chat_completions.mjs +6 -0
  53. package/batteries/llm.cjs +63 -0
  54. package/batteries/llm.mjs +10 -0
  55. package/batteries/storage/flydrive/index.d.ts +167 -0
  56. package/batteries/storage/flydrive.cjs +249 -0
  57. package/batteries/storage/flydrive.cjs.map +1 -0
  58. package/batteries/storage/flydrive.mjs +249 -0
  59. package/batteries/storage/flydrive.mjs.map +1 -0
  60. package/batteries/storage/in_memory/index.d.ts +106 -0
  61. package/batteries/storage/in_memory.cjs +121 -0
  62. package/batteries/storage/in_memory.cjs.map +1 -0
  63. package/batteries/storage/in_memory.mjs +119 -0
  64. package/batteries/storage/in_memory.mjs.map +1 -0
  65. package/batteries/storage/index.d.ts +18 -0
  66. package/batteries/storage/opfs/index.d.ts +299 -0
  67. package/batteries/storage/opfs.cjs +368 -0
  68. package/batteries/storage/opfs.cjs.map +1 -0
  69. package/batteries/storage/opfs.mjs +366 -0
  70. package/batteries/storage/opfs.mjs.map +1 -0
  71. package/batteries/storage.cjs +4 -0
  72. package/batteries/storage.mjs +2 -0
  73. package/batteries/tools/color/index.d.ts +37 -0
  74. package/batteries/tools/color.cjs +659 -0
  75. package/batteries/tools/color.cjs.map +1 -0
  76. package/batteries/tools/color.mjs +655 -0
  77. package/batteries/tools/color.mjs.map +1 -0
  78. package/batteries/tools/comparison/index.d.ts +29 -0
  79. package/batteries/tools/comparison.cjs +171 -0
  80. package/batteries/tools/comparison.cjs.map +1 -0
  81. package/batteries/tools/comparison.mjs +168 -0
  82. package/batteries/tools/comparison.mjs.map +1 -0
  83. package/batteries/tools/data_structure/index.d.ts +30 -0
  84. package/batteries/tools/data_structure.cjs +270 -0
  85. package/batteries/tools/data_structure.cjs.map +1 -0
  86. package/batteries/tools/data_structure.mjs +267 -0
  87. package/batteries/tools/data_structure.mjs.map +1 -0
  88. package/batteries/tools/datetime_extended/index.d.ts +51 -0
  89. package/batteries/tools/datetime_extended.cjs +309 -0
  90. package/batteries/tools/datetime_extended.cjs.map +1 -0
  91. package/batteries/tools/datetime_extended.mjs +302 -0
  92. package/batteries/tools/datetime_extended.mjs.map +1 -0
  93. package/batteries/tools/datetime_math/index.d.ts +36 -0
  94. package/batteries/tools/datetime_math.cjs +175 -0
  95. package/batteries/tools/datetime_math.cjs.map +1 -0
  96. package/batteries/tools/datetime_math.mjs +171 -0
  97. package/batteries/tools/datetime_math.mjs.map +1 -0
  98. package/batteries/tools/encoding/index.d.ts +36 -0
  99. package/batteries/tools/encoding.cjs +156 -0
  100. package/batteries/tools/encoding.cjs.map +1 -0
  101. package/batteries/tools/encoding.mjs +152 -0
  102. package/batteries/tools/encoding.mjs.map +1 -0
  103. package/batteries/tools/formatting/index.d.ts +28 -0
  104. package/batteries/tools/formatting.cjs +120 -0
  105. package/batteries/tools/formatting.cjs.map +1 -0
  106. package/batteries/tools/formatting.mjs +117 -0
  107. package/batteries/tools/formatting.mjs.map +1 -0
  108. package/batteries/tools/geo_basics/index.d.ts +33 -0
  109. package/batteries/tools/geo_basics.cjs +136 -0
  110. package/batteries/tools/geo_basics.cjs.map +1 -0
  111. package/batteries/tools/geo_basics.mjs +132 -0
  112. package/batteries/tools/geo_basics.mjs.map +1 -0
  113. package/batteries/tools/index.d.ts +32 -0
  114. package/batteries/tools/math/index.d.ts +37 -0
  115. package/batteries/tools/math.cjs +136 -0
  116. package/batteries/tools/math.cjs.map +1 -0
  117. package/batteries/tools/math.mjs +133 -0
  118. package/batteries/tools/math.mjs.map +1 -0
  119. package/batteries/tools/memory/index.d.ts +73 -0
  120. package/batteries/tools/memory.cjs +193 -0
  121. package/batteries/tools/memory.cjs.map +1 -0
  122. package/batteries/tools/memory.mjs +187 -0
  123. package/batteries/tools/memory.mjs.map +1 -0
  124. package/batteries/tools/parsing/index.d.ts +47 -0
  125. package/batteries/tools/parsing.cjs +191 -0
  126. package/batteries/tools/parsing.cjs.map +1 -0
  127. package/batteries/tools/parsing.mjs +185 -0
  128. package/batteries/tools/parsing.mjs.map +1 -0
  129. package/batteries/tools/retrievables/index.d.ts +81 -0
  130. package/batteries/tools/retrievables.cjs +215 -0
  131. package/batteries/tools/retrievables.cjs.map +1 -0
  132. package/batteries/tools/retrievables.mjs +209 -0
  133. package/batteries/tools/retrievables.mjs.map +1 -0
  134. package/batteries/tools/standing_instructions/index.d.ts +64 -0
  135. package/batteries/tools/standing_instructions.cjs +126 -0
  136. package/batteries/tools/standing_instructions.cjs.map +1 -0
  137. package/batteries/tools/standing_instructions.mjs +121 -0
  138. package/batteries/tools/standing_instructions.mjs.map +1 -0
  139. package/batteries/tools/statistics/index.d.ts +46 -0
  140. package/batteries/tools/statistics.cjs +253 -0
  141. package/batteries/tools/statistics.cjs.map +1 -0
  142. package/batteries/tools/statistics.mjs +248 -0
  143. package/batteries/tools/statistics.mjs.map +1 -0
  144. package/batteries/tools/string_processing/index.d.ts +29 -0
  145. package/batteries/tools/string_processing.cjs +154 -0
  146. package/batteries/tools/string_processing.cjs.map +1 -0
  147. package/batteries/tools/string_processing.mjs +151 -0
  148. package/batteries/tools/string_processing.mjs.map +1 -0
  149. package/batteries/tools/structured_data/index.d.ts +34 -0
  150. package/batteries/tools/structured_data.cjs +189 -0
  151. package/batteries/tools/structured_data.cjs.map +1 -0
  152. package/batteries/tools/structured_data.mjs +185 -0
  153. package/batteries/tools/structured_data.mjs.map +1 -0
  154. package/batteries/tools/text_analysis/index.d.ts +31 -0
  155. package/batteries/tools/text_analysis.cjs +120 -0
  156. package/batteries/tools/text_analysis.cjs.map +1 -0
  157. package/batteries/tools/text_analysis.mjs +117 -0
  158. package/batteries/tools/text_analysis.mjs.map +1 -0
  159. package/batteries/tools/text_comparison/index.d.ts +28 -0
  160. package/batteries/tools/text_comparison.cjs +96 -0
  161. package/batteries/tools/text_comparison.cjs.map +1 -0
  162. package/batteries/tools/text_comparison.mjs +93 -0
  163. package/batteries/tools/text_comparison.mjs.map +1 -0
  164. package/batteries/tools/time/index.d.ts +27 -0
  165. package/batteries/tools/time.cjs +63 -0
  166. package/batteries/tools/time.cjs.map +1 -0
  167. package/batteries/tools/time.mjs +60 -0
  168. package/batteries/tools/time.mjs.map +1 -0
  169. package/batteries/tools/unit_conversion/index.d.ts +19 -0
  170. package/batteries/tools/unit_conversion.cjs +452 -0
  171. package/batteries/tools/unit_conversion.cjs.map +1 -0
  172. package/batteries/tools/unit_conversion.mjs +450 -0
  173. package/batteries/tools/unit_conversion.mjs.map +1 -0
  174. package/batteries/tools.cjs +80 -0
  175. package/batteries/tools.mjs +21 -0
  176. package/batteries.cjs +142 -0
  177. package/batteries.mjs +30 -0
  178. package/chunk-KmRHZBOW.js +35 -0
  179. package/common-DeZaonK1.mjs +208 -0
  180. package/common-DeZaonK1.mjs.map +1 -0
  181. package/common-Od8edUXU.js +232 -0
  182. package/common-Od8edUXU.js.map +1 -0
  183. package/common.cjs +31 -0
  184. package/common.d.ts +108 -0
  185. package/common.mjs +8 -0
  186. package/dispatch_runner-9j6bXHL3.mjs +1609 -0
  187. package/dispatch_runner-9j6bXHL3.mjs.map +1 -0
  188. package/dispatch_runner-CsoH0nld.js +1627 -0
  189. package/dispatch_runner-CsoH0nld.js.map +1 -0
  190. package/dispatch_runner.cjs +3 -0
  191. package/dispatch_runner.d.ts +17 -0
  192. package/dispatch_runner.mjs +2 -0
  193. package/exceptions-D5YrO9Vm.js +280 -0
  194. package/exceptions-D5YrO9Vm.js.map +1 -0
  195. package/exceptions-NrzIHw_R.mjs +244 -0
  196. package/exceptions-NrzIHw_R.mjs.map +1 -0
  197. package/exceptions.cjs +33 -0
  198. package/exceptions.d.ts +52 -0
  199. package/exceptions.mjs +3 -0
  200. package/factories.cjs +4 -0
  201. package/factories.d.ts +39 -0
  202. package/factories.mjs +2 -0
  203. package/forge.cjs +9 -0
  204. package/forge.d.ts +49 -0
  205. package/forge.mjs +5 -0
  206. package/guards.cjs +96 -0
  207. package/guards.cjs.map +1 -0
  208. package/guards.d.ts +83 -0
  209. package/guards.mjs +72 -0
  210. package/guards.mjs.map +1 -0
  211. package/index.cjs +107 -0
  212. package/index.cjs.map +1 -0
  213. package/index.d.ts +18 -0
  214. package/index.mjs +31 -0
  215. package/index.mjs.map +1 -0
  216. package/lib/classes/artifact_tool.d.ts +129 -0
  217. package/lib/classes/base_exception.d.ts +83 -0
  218. package/lib/classes/identity.d.ts +71 -0
  219. package/lib/classes/media.d.ts +326 -0
  220. package/lib/classes/memory.d.ts +72 -0
  221. package/lib/classes/message.d.ts +137 -0
  222. package/lib/classes/registry.d.ts +79 -0
  223. package/lib/classes/retrievable.d.ts +100 -0
  224. package/lib/classes/spooled_artifact.d.ts +296 -0
  225. package/lib/classes/spooled_json_artifact.d.ts +158 -0
  226. package/lib/classes/spooled_markdown_artifact.d.ts +202 -0
  227. package/lib/classes/thought.d.ts +142 -0
  228. package/lib/classes/tokenizable.d.ts +124 -0
  229. package/lib/classes/tool.d.ts +228 -0
  230. package/lib/classes/tool_call.d.ts +190 -0
  231. package/lib/classes/tool_registry.d.ts +159 -0
  232. package/lib/classes/turn_gate.d.ts +109 -0
  233. package/lib/contracts/dispatch_context.d.ts +345 -0
  234. package/lib/contracts/media_reader.d.ts +60 -0
  235. package/lib/contracts/spool_reader.d.ts +80 -0
  236. package/lib/contracts/spooled_artifact_constructor.d.ts +38 -0
  237. package/lib/contracts/turn_runner_config.d.ts +101 -0
  238. package/lib/contracts/turn_runner_context.d.ts +267 -0
  239. package/lib/dispatch_runner.d.ts +98 -0
  240. package/lib/exceptions/runtime.d.ts +370 -0
  241. package/lib/helpers/media_readers.d.ts +39 -0
  242. package/lib/turn_runner.d.ts +144 -0
  243. package/lib/types/dispatch_context.d.ts +233 -0
  244. package/lib/types/dispatch_runner.d.ts +387 -0
  245. package/lib/types/turn_runner.d.ts +322 -0
  246. package/lib/utils/canonical_json.d.ts +18 -0
  247. package/lib/utils/exceptions.d.ts +78 -0
  248. package/lib/utils/guards.d.ts +32 -0
  249. package/lib/utils/validation.d.ts +77 -0
  250. package/package.json +334 -0
  251. package/runtime-BJVkrGQe.js +519 -0
  252. package/runtime-BJVkrGQe.js.map +1 -0
  253. package/runtime-CrEPIFgr.mjs +346 -0
  254. package/runtime-CrEPIFgr.mjs.map +1 -0
  255. package/skills/adk-assembly/SKILL.md +109 -0
  256. package/skills/adk-assembly/references/assembly-contract.md +66 -0
  257. package/skills/adk-assembly/references/executors-tools-pipelines-events.md +113 -0
  258. package/skills/adk-assembly/references/first-integration.md +93 -0
  259. package/skills/adk-assembly/references/storage-and-context.md +102 -0
  260. package/spooled_artifact-C5ZtGxuJ.mjs +544 -0
  261. package/spooled_artifact-C5ZtGxuJ.mjs.map +1 -0
  262. package/spooled_artifact-Cm9Te22K.js +568 -0
  263. package/spooled_artifact-Cm9Te22K.js.map +1 -0
  264. package/spooled_artifact.cjs +7 -0
  265. package/spooled_artifact.d.ts +40 -0
  266. package/spooled_artifact.mjs +3 -0
  267. package/spooled_markdown_artifact-BpUJol0W.mjs +771 -0
  268. package/spooled_markdown_artifact-BpUJol0W.mjs.map +1 -0
  269. package/spooled_markdown_artifact-RRB113sy.js +786 -0
  270. package/spooled_markdown_artifact-RRB113sy.js.map +1 -0
  271. package/thought-CDb457b4.mjs +470 -0
  272. package/thought-CDb457b4.mjs.map +1 -0
  273. package/thought-DuN2PgdO.js +494 -0
  274. package/thought-DuN2PgdO.js.map +1 -0
  275. package/tool-COSeH8I6.js +302 -0
  276. package/tool-COSeH8I6.js.map +1 -0
  277. package/tool-D2WB1EA1.mjs +296 -0
  278. package/tool-D2WB1EA1.mjs.map +1 -0
  279. package/tool_call-BKyyxGaZ.mjs +578 -0
  280. package/tool_call-BKyyxGaZ.mjs.map +1 -0
  281. package/tool_call-DFgzcVcU.js +608 -0
  282. package/tool_call-DFgzcVcU.js.map +1 -0
  283. package/tool_registry-Dkfprsck.js +641 -0
  284. package/tool_registry-Dkfprsck.js.map +1 -0
  285. package/tool_registry-DqLOyGyG.mjs +592 -0
  286. package/tool_registry-DqLOyGyG.mjs.map +1 -0
  287. package/turn_runner-CMm2BHdX.js +615 -0
  288. package/turn_runner-CMm2BHdX.js.map +1 -0
  289. package/turn_runner-y7eyEcJH.mjs +603 -0
  290. package/turn_runner-y7eyEcJH.mjs.map +1 -0
  291. package/turn_runner.cjs +3 -0
  292. package/turn_runner.d.ts +21 -0
  293. package/turn_runner.mjs +2 -0
  294. package/types.cjs +1 -0
  295. package/types.d.ts +56 -0
  296. package/types.mjs +0 -0
  297. package/vite-env.d.ts +23 -0
@@ -0,0 +1,185 @@
1
+ import { o as isError } from "../../tool_registry-DqLOyGyG.mjs";
2
+ import "../../common-DeZaonK1.mjs";
3
+ import { t as Tool } from "../../tool-D2WB1EA1.mjs";
4
+ import { n as SpooledJsonArtifact } from "../../spooled_markdown_artifact-BpUJol0W.mjs";
5
+ import "../../guards.mjs";
6
+ import { validator } from "@nhtio/validation";
7
+ import { load } from "js-yaml";
8
+ import Papa from "papaparse";
9
+ //#region src/batteries/tools/parsing/index.ts
10
+ /**
11
+ * Pre-constructed tools for parsing CSV, TSV, JSON, YAML, and other structured text formats.
12
+ *
13
+ * @module @nhtio/adk/batteries/tools/parsing
14
+ *
15
+ * @remarks
16
+ * Pre-constructed bundled tools for the `parsing` category. Import individually, the whole
17
+ * category, or import every tool via `@nhtio/adk/batteries`.
18
+ */
19
+ /**
20
+ * Parse a CSV or TSV string into a JSON array.
21
+ *
22
+ * @remarks
23
+ * With `has_header: true` (default), each row becomes an object keyed by column name. Without a
24
+ * header, rows are returned as positional arrays. `delimiter` auto-detects when omitted; pass
25
+ * `"\t"` for TSV. Rows are clipped to `limit` (default 1000, max 10000). Parse warnings are
26
+ * prepended to the output.
27
+ */
28
+ var parseCsvTool = new Tool({
29
+ name: "parse_csv",
30
+ description: "Parse a CSV or TSV string into a JSON array. With a header row, returns objects keyed by column name. Without, returns arrays of values.",
31
+ inputSchema: validator.object({
32
+ text: validator.string().required().description("CSV or TSV text to parse"),
33
+ has_header: validator.boolean().default(true).description("First row is a header row (default: true)"),
34
+ delimiter: validator.string().default("").allow("").description("Field delimiter — auto-detected if omitted. Use \"\\t\" for TSV."),
35
+ limit: validator.number().default(1e3).description("Maximum rows to return (default: 1000)")
36
+ }),
37
+ artifactConstructor: () => SpooledJsonArtifact,
38
+ handler: async (args) => {
39
+ const { text, has_header: hasHeader, delimiter, limit: rawLimit } = args;
40
+ const limit = Math.min(1e4, Math.max(1, Math.floor(rawLimit)));
41
+ try {
42
+ const result = Papa.parse(text.trim(), {
43
+ header: hasHeader,
44
+ delimiter: delimiter || void 0,
45
+ skipEmptyLines: true,
46
+ dynamicTyping: true
47
+ });
48
+ const rows = result.data.slice(0, limit);
49
+ const warnings = result.errors.length > 0 ? `Parse warnings: ${result.errors.slice(0, 3).map((e) => e.message).join("; ")}\n\n` : "";
50
+ const truncated = result.data.length > limit ? `\n\n(Showing ${limit} of ${result.data.length} rows)` : "";
51
+ return warnings + JSON.stringify(rows, null, 2) + truncated;
52
+ } catch (err) {
53
+ return `Error: ${isError(err) ? err.message : String(err)}`;
54
+ }
55
+ }
56
+ });
57
+ /**
58
+ * Parse a YAML string into JSON.
59
+ *
60
+ * @remarks
61
+ * Returns a pretty-printed JSON representation of the parsed YAML document. Invalid YAML
62
+ * returns an error string.
63
+ */
64
+ var parseYamlTool = new Tool({
65
+ name: "parse_yaml",
66
+ description: "Parse a YAML string and return the equivalent JSON.",
67
+ inputSchema: validator.object({ text: validator.string().required().description("YAML text to parse") }),
68
+ artifactConstructor: () => SpooledJsonArtifact,
69
+ handler: async (args) => {
70
+ const { text } = args;
71
+ try {
72
+ const parsed = load(text);
73
+ return JSON.stringify(parsed, null, 2);
74
+ } catch (err) {
75
+ return `Error: Invalid YAML — ${isError(err) ? err.message : String(err)}`;
76
+ }
77
+ }
78
+ });
79
+ /**
80
+ * Extract key-value pairs from text.
81
+ *
82
+ * @remarks
83
+ * Handles `.env` files, config files, and query strings. `kv_delimiter` chooses the
84
+ * key→value separator (`=`, `:`, or `auto`); `pair_delimiter` selects how pairs are separated
85
+ * (`newline`, `comma`, `semicolon`, `ampersand`). Surrounding single or double quotes around
86
+ * values are stripped. Comment lines starting with `#` are skipped by default.
87
+ */
88
+ var parseKvTool = new Tool({
89
+ name: "parse_kv",
90
+ description: "Extract key-value pairs from text (e.g. .env files, config files, query strings). Returns a JSON object.",
91
+ inputSchema: validator.object({
92
+ text: validator.string().required().description("Text containing key-value pairs"),
93
+ kv_delimiter: validator.string().valid("=", ":", "auto").default("auto").description("Separator between key and value (default: auto-detect)"),
94
+ pair_delimiter: validator.string().valid("newline", "comma", "semicolon", "ampersand").default("newline").description("Separator between pairs (default: newline)"),
95
+ skip_comments: validator.boolean().default(true).description("Skip lines starting with # (default: true)")
96
+ }),
97
+ artifactConstructor: () => SpooledJsonArtifact,
98
+ handler: async (args) => {
99
+ const { text, kv_delimiter: kvDelim, pair_delimiter: pairDelimKey, skip_comments: skipComments } = args;
100
+ const pairDelim = {
101
+ newline: "\n",
102
+ comma: ",",
103
+ semicolon: ";",
104
+ ampersand: "&"
105
+ }[pairDelimKey] ?? "\n";
106
+ const result = {};
107
+ for (const raw of text.split(pairDelim)) {
108
+ const line = raw.trim();
109
+ if (line === "") continue;
110
+ if (skipComments && line.startsWith("#")) continue;
111
+ const delim = kvDelim === "auto" ? line.includes("=") ? "=" : line.includes(":") ? ":" : null : kvDelim;
112
+ if (!delim) continue;
113
+ const sepIdx = line.indexOf(delim);
114
+ if (sepIdx === -1) continue;
115
+ const key = line.slice(0, sepIdx).trim();
116
+ let value = line.slice(sepIdx + delim.length).trim();
117
+ if (value.startsWith("\"") && value.endsWith("\"") || value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
118
+ if (key) result[key] = value;
119
+ }
120
+ return JSON.stringify(result, null, 2);
121
+ }
122
+ });
123
+ /**
124
+ * Detect the most likely field delimiter in a CSV-like text sample.
125
+ *
126
+ * @remarks
127
+ * Tries comma, tab, semicolon, pipe, and colon. Scores each by mean field count divided by
128
+ * variance (so consistent row widths beat noisy splits). Looks at up to the first 20 lines of
129
+ * the first 5000 characters.
130
+ */
131
+ var detectDelimiterTool = new Tool({
132
+ name: "detect_delimiter",
133
+ description: "Detect the most likely field delimiter in a CSV-like text sample.",
134
+ inputSchema: validator.object({ text: validator.string().required().description("Sample of the delimited text to analyze") }),
135
+ handler: async (args) => {
136
+ const { text } = args;
137
+ const lines = text.slice(0, 5e3).split("\n").map((l) => l.trim()).filter((l) => l.length > 0).slice(0, 20);
138
+ if (lines.length === 0) return "Error: No lines to analyze.";
139
+ const candidates = [
140
+ {
141
+ delim: ",",
142
+ name: "comma"
143
+ },
144
+ {
145
+ delim: " ",
146
+ name: "tab"
147
+ },
148
+ {
149
+ delim: ";",
150
+ name: "semicolon"
151
+ },
152
+ {
153
+ delim: "|",
154
+ name: "pipe"
155
+ },
156
+ {
157
+ delim: ":",
158
+ name: "colon"
159
+ }
160
+ ];
161
+ let best = {
162
+ name: "comma",
163
+ delim: ",",
164
+ score: -1,
165
+ avgFields: 0
166
+ };
167
+ for (const { delim, name } of candidates) {
168
+ const counts = lines.map((l) => l.split(delim).length - 1);
169
+ const avg = counts.reduce((a, b) => a + b, 0) / counts.length;
170
+ if (avg === 0) continue;
171
+ const score = avg / (1 + counts.reduce((a, b) => a + (b - avg) ** 2, 0) / counts.length);
172
+ if (score > best.score) best = {
173
+ name,
174
+ delim,
175
+ score,
176
+ avgFields: Number.parseFloat((avg + 1).toFixed(1))
177
+ };
178
+ }
179
+ return `Detected delimiter: ${best.name} ("${best.delim === " " ? "\\t" : best.delim}") — ~${best.avgFields} fields per row`;
180
+ }
181
+ });
182
+ //#endregion
183
+ export { detectDelimiterTool, parseCsvTool, parseKvTool, parseYamlTool };
184
+
185
+ //# sourceMappingURL=parsing.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parsing.mjs","names":[],"sources":["../../../src/batteries/tools/parsing/index.ts"],"sourcesContent":["/**\n * Pre-constructed tools for parsing CSV, TSV, JSON, YAML, and other structured text formats.\n *\n * @module @nhtio/adk/batteries/tools/parsing\n *\n * @remarks\n * Pre-constructed bundled tools for the `parsing` category. Import individually, the whole\n * category, or import every tool via `@nhtio/adk/batteries`.\n */\n\nimport { load as parseYaml } from 'js-yaml'\nimport { default as Papa } from 'papaparse'\nimport { isError } from '@nhtio/adk/guards'\nimport { validator } from '@nhtio/validation'\nimport { Tool, SpooledJsonArtifact } from '@nhtio/adk/common'\n\n/**\n * Parse a CSV or TSV string into a JSON array.\n *\n * @remarks\n * With `has_header: true` (default), each row becomes an object keyed by column name. Without a\n * header, rows are returned as positional arrays. `delimiter` auto-detects when omitted; pass\n * `\"\\t\"` for TSV. Rows are clipped to `limit` (default 1000, max 10000). Parse warnings are\n * prepended to the output.\n */\nexport const parseCsvTool = new Tool({\n name: 'parse_csv',\n description:\n 'Parse a CSV or TSV string into a JSON array. With a header row, returns objects keyed by column name. Without, returns arrays of values.',\n inputSchema: validator.object({\n text: validator.string().required().description('CSV or TSV text to parse'),\n has_header: validator\n .boolean()\n .default(true)\n .description('First row is a header row (default: true)'),\n delimiter: validator\n .string()\n .default('')\n .allow('')\n .description('Field delimiter — auto-detected if omitted. Use \"\\\\t\" for TSV.'),\n limit: validator.number().default(1000).description('Maximum rows to return (default: 1000)'),\n }),\n artifactConstructor: () => SpooledJsonArtifact,\n handler: async (args) => {\n const {\n text,\n has_header: hasHeader,\n delimiter,\n limit: rawLimit,\n } = args as {\n text: string\n has_header: boolean\n delimiter: string\n limit: number\n }\n const limit = Math.min(10_000, Math.max(1, Math.floor(rawLimit)))\n\n try {\n const result = Papa.parse<unknown>(text.trim(), {\n header: hasHeader,\n delimiter: delimiter || undefined,\n skipEmptyLines: true,\n dynamicTyping: true,\n })\n\n const rows = (result.data as unknown[]).slice(0, limit)\n const warnings =\n result.errors.length > 0\n ? `Parse warnings: ${result.errors\n .slice(0, 3)\n .map((e) => e.message)\n .join('; ')}\\n\\n`\n : ''\n const truncated =\n result.data.length > limit ? `\\n\\n(Showing ${limit} of ${result.data.length} rows)` : ''\n\n return warnings + JSON.stringify(rows, null, 2) + truncated\n } catch (err) {\n return `Error: ${isError(err) ? err.message : String(err)}`\n }\n },\n})\n\n/**\n * Parse a YAML string into JSON.\n *\n * @remarks\n * Returns a pretty-printed JSON representation of the parsed YAML document. Invalid YAML\n * returns an error string.\n */\nexport const parseYamlTool = new Tool({\n name: 'parse_yaml',\n description: 'Parse a YAML string and return the equivalent JSON.',\n inputSchema: validator.object({\n text: validator.string().required().description('YAML text to parse'),\n }),\n artifactConstructor: () => SpooledJsonArtifact,\n handler: async (args) => {\n const { text } = args as { text: string }\n try {\n const parsed = parseYaml(text)\n return JSON.stringify(parsed, null, 2)\n } catch (err) {\n return `Error: Invalid YAML — ${isError(err) ? err.message : String(err)}`\n }\n },\n})\n\n/**\n * Extract key-value pairs from text.\n *\n * @remarks\n * Handles `.env` files, config files, and query strings. `kv_delimiter` chooses the\n * key→value separator (`=`, `:`, or `auto`); `pair_delimiter` selects how pairs are separated\n * (`newline`, `comma`, `semicolon`, `ampersand`). Surrounding single or double quotes around\n * values are stripped. Comment lines starting with `#` are skipped by default.\n */\nexport const parseKvTool = new Tool({\n name: 'parse_kv',\n description:\n 'Extract key-value pairs from text (e.g. .env files, config files, query strings). Returns a JSON object.',\n inputSchema: validator.object({\n text: validator.string().required().description('Text containing key-value pairs'),\n kv_delimiter: validator\n .string()\n .valid('=', ':', 'auto')\n .default('auto')\n .description('Separator between key and value (default: auto-detect)'),\n pair_delimiter: validator\n .string()\n .valid('newline', 'comma', 'semicolon', 'ampersand')\n .default('newline')\n .description('Separator between pairs (default: newline)'),\n skip_comments: validator\n .boolean()\n .default(true)\n .description('Skip lines starting with # (default: true)'),\n }),\n artifactConstructor: () => SpooledJsonArtifact,\n handler: async (args) => {\n const {\n text,\n kv_delimiter: kvDelim,\n pair_delimiter: pairDelimKey,\n skip_comments: skipComments,\n } = args as {\n text: string\n kv_delimiter: string\n pair_delimiter: string\n skip_comments: boolean\n }\n\n const pairDelimMap: Record<string, string> = {\n newline: '\\n',\n comma: ',',\n semicolon: ';',\n ampersand: '&',\n }\n const pairDelim = pairDelimMap[pairDelimKey] ?? '\\n'\n\n const result: Record<string, string> = {}\n\n for (const raw of text.split(pairDelim)) {\n const line = raw.trim()\n if (line === '') continue\n if (skipComments && line.startsWith('#')) continue\n\n const delim =\n kvDelim === 'auto' ? (line.includes('=') ? '=' : line.includes(':') ? ':' : null) : kvDelim\n if (!delim) continue\n\n const sepIdx = line.indexOf(delim)\n if (sepIdx === -1) continue\n\n const key = line.slice(0, sepIdx).trim()\n let value = line.slice(sepIdx + delim.length).trim()\n\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1)\n }\n\n if (key) result[key] = value\n }\n\n return JSON.stringify(result, null, 2)\n },\n})\n\n/**\n * Detect the most likely field delimiter in a CSV-like text sample.\n *\n * @remarks\n * Tries comma, tab, semicolon, pipe, and colon. Scores each by mean field count divided by\n * variance (so consistent row widths beat noisy splits). Looks at up to the first 20 lines of\n * the first 5000 characters.\n */\nexport const detectDelimiterTool = new Tool({\n name: 'detect_delimiter',\n description: 'Detect the most likely field delimiter in a CSV-like text sample.',\n inputSchema: validator.object({\n text: validator.string().required().description('Sample of the delimited text to analyze'),\n }),\n handler: async (args) => {\n const { text } = args as { text: string }\n const sample = text.slice(0, 5000)\n const lines = sample\n .split('\\n')\n .map((l) => l.trim())\n .filter((l) => l.length > 0)\n .slice(0, 20)\n\n if (lines.length === 0) return 'Error: No lines to analyze.'\n\n const candidates: Array<{ delim: string; name: string }> = [\n { delim: ',', name: 'comma' },\n { delim: '\\t', name: 'tab' },\n { delim: ';', name: 'semicolon' },\n { delim: '|', name: 'pipe' },\n { delim: ':', name: 'colon' },\n ]\n\n let best = { name: 'comma', delim: ',', score: -1, avgFields: 0 }\n\n for (const { delim, name } of candidates) {\n const counts = lines.map((l) => l.split(delim).length - 1)\n const avg = counts.reduce((a, b) => a + b, 0) / counts.length\n if (avg === 0) continue\n const fieldVariance = counts.reduce((a, b) => a + (b - avg) ** 2, 0) / counts.length\n const score = avg / (1 + fieldVariance)\n if (score > best.score) {\n best = { name, delim, score, avgFields: Number.parseFloat((avg + 1).toFixed(1)) }\n }\n }\n\n return `Detected delimiter: ${best.name} (\"${best.delim === '\\t' ? '\\\\t' : best.delim}\") — ~${best.avgFields} fields per row`\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,eAAe,IAAI,KA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,QAAQ,OAAO,IADC,OAAO,QAAQ,GAAG,MAAM,KAAK,IAAI,QAAQ,GAAG,CAAC,IAAI,OAAO;GAE9E,IAAI,QAAQ,KAAK,OACf,OAAO;IAAE;IAAM;IAAO;IAAO,WAAW,OAAO,YAAY,MAAM,GAAG,QAAQ,CAAC,CAAC;GAAE;EAEpF;EAEA,OAAO,uBAAuB,KAAK,KAAK,KAAK,KAAK,UAAU,MAAO,QAAQ,KAAK,MAAM,QAAQ,KAAK,UAAU;CAC/G;AACF,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Pre-constructed CRUD tools for model-visible retrievable and RAG-record management.
3
+ *
4
+ * @module @nhtio/adk/batteries/tools/retrievables
5
+ *
6
+ * @remarks
7
+ * Pre-constructed CRUD tools that expose the ADK's {@link @nhtio/adk!Retrievable} surface to the
8
+ * model. Each tool delegates to the corresponding callback on the active
9
+ * {@link @nhtio/adk!DispatchContext} (`fetchRetrievables`, `storeRetrievable`, `mutateRetrievable`,
10
+ * `deleteRetrievable`) — the persistence layer is whatever the consumer wired into the
11
+ * runner.
12
+ *
13
+ * Retrievables are RAG records and carry an explicit `trustTier` that drives the LLM
14
+ * battery's rendering envelope. Exposing these CRUD tools to the model is a deliberate
15
+ * deployer decision; the trust tier the model declares when creating or updating a record
16
+ * is honoured verbatim by the persistence layer. The deployer is responsible for choosing
17
+ * whether to register all four tools, only the read-only `list_retrievables`, or any subset
18
+ * thereof — that registration choice is exactly the trust boundary documented in the
19
+ * Retrievable battery contract.
20
+ *
21
+ * Output is JSON for every tool so consumers can parse the result without re-tokenising —
22
+ * the artifact constructor is set to {@link @nhtio/adk!SpooledJsonArtifact}.
23
+ *
24
+ * Tools:
25
+ * - {@link listRetrievablesTool} — read-only list of every retrievable currently held by
26
+ * the context.
27
+ * - {@link storeRetrievableTool} — create a new retrievable record (auto-generates `id` /
28
+ * `createdAt` / `updatedAt` unless explicit values are supplied).
29
+ * - {@link updateRetrievableTool} — replace an existing retrievable by `id`. Bumps
30
+ * `updatedAt`.
31
+ * - {@link deleteRetrievableTool} — remove a retrievable by `id`.
32
+ */
33
+ import { SpooledJsonArtifact, Tool } from "../../../common";
34
+ /**
35
+ * List every retrievable record currently held by the active execution context.
36
+ *
37
+ * @remarks
38
+ * Delegates to `ctx.fetchRetrievables()`. Returns a JSON-encoded array of retrievable records
39
+ * (id, content, trustTier, source, kind, score, createdAt, updatedAt).
40
+ */
41
+ export declare const listRetrievablesTool: Tool<SpooledJsonArtifact<unknown>>;
42
+ /**
43
+ * Create a new {@link @nhtio/adk!Retrievable} record and persist it via the context's `storeRetrievable`
44
+ * callback.
45
+ *
46
+ * @remarks
47
+ * When `id` is omitted, a UUID v6 is generated. When `createdAt` / `updatedAt` are omitted,
48
+ * the current time is used. The model must declare `trustTier` explicitly — there is no
49
+ * default; the choice is consciously the model's, exposed by the deployer's decision to
50
+ * register this tool.
51
+ */
52
+ export declare const storeRetrievableTool: Tool<SpooledJsonArtifact<unknown>>;
53
+ /**
54
+ * Replace an existing {@link @nhtio/adk!Retrievable} by `id`.
55
+ *
56
+ * @remarks
57
+ * The model supplies `id` plus any subset of `content` / `trustTier` / `source` / `kind` /
58
+ * `score`; omitted fields retain their prior values. `updatedAt` is always bumped;
59
+ * `createdAt` is preserved. Returns an error when no retrievable with the supplied `id` is
60
+ * found.
61
+ */
62
+ export declare const updateRetrievableTool: Tool<SpooledJsonArtifact<unknown>>;
63
+ /**
64
+ * Remove an existing {@link @nhtio/adk!Retrievable} by `id`.
65
+ *
66
+ * @remarks
67
+ * Delegates to `ctx.deleteRetrievable(id)`. Returns `{ ok: true, id }` on success regardless
68
+ * of whether a retrievable was actually present — `deleteRetrievable` is idempotent at the
69
+ * ADK level.
70
+ */
71
+ export declare const deleteRetrievableTool: Tool<SpooledJsonArtifact<unknown>>;
72
+ /**
73
+ * Convenience tuple of every retrievable CRUD tool. Spread into a {@link @nhtio/adk!ToolRegistry} to
74
+ * register the entire category at once.
75
+ */
76
+ export declare const retrievableTools: readonly [
77
+ Tool<SpooledJsonArtifact<unknown>>,
78
+ Tool<SpooledJsonArtifact<unknown>>,
79
+ Tool<SpooledJsonArtifact<unknown>>,
80
+ Tool<SpooledJsonArtifact<unknown>>
81
+ ];
@@ -0,0 +1,215 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../../chunk-KmRHZBOW.js");
3
+ const require_tool_registry = require("../../tool_registry-Dkfprsck.js");
4
+ const require_common = require("../../common-Od8edUXU.js");
5
+ const require_tool = require("../../tool-COSeH8I6.js");
6
+ const require_spooled_markdown_artifact = require("../../spooled_markdown_artifact-RRB113sy.js");
7
+ require("../../guards.cjs");
8
+ let _nhtio_validation = require("@nhtio/validation");
9
+ let uuid = require("uuid");
10
+ let luxon = require("luxon");
11
+ //#region src/batteries/tools/retrievables/index.ts
12
+ /**
13
+ * Pre-constructed CRUD tools for model-visible retrievable and RAG-record management.
14
+ *
15
+ * @module @nhtio/adk/batteries/tools/retrievables
16
+ *
17
+ * @remarks
18
+ * Pre-constructed CRUD tools that expose the ADK's {@link @nhtio/adk!Retrievable} surface to the
19
+ * model. Each tool delegates to the corresponding callback on the active
20
+ * {@link @nhtio/adk!DispatchContext} (`fetchRetrievables`, `storeRetrievable`, `mutateRetrievable`,
21
+ * `deleteRetrievable`) — the persistence layer is whatever the consumer wired into the
22
+ * runner.
23
+ *
24
+ * Retrievables are RAG records and carry an explicit `trustTier` that drives the LLM
25
+ * battery's rendering envelope. Exposing these CRUD tools to the model is a deliberate
26
+ * deployer decision; the trust tier the model declares when creating or updating a record
27
+ * is honoured verbatim by the persistence layer. The deployer is responsible for choosing
28
+ * whether to register all four tools, only the read-only `list_retrievables`, or any subset
29
+ * thereof — that registration choice is exactly the trust boundary documented in the
30
+ * Retrievable battery contract.
31
+ *
32
+ * Output is JSON for every tool so consumers can parse the result without re-tokenising —
33
+ * the artifact constructor is set to {@link @nhtio/adk!SpooledJsonArtifact}.
34
+ *
35
+ * Tools:
36
+ * - {@link listRetrievablesTool} — read-only list of every retrievable currently held by
37
+ * the context.
38
+ * - {@link storeRetrievableTool} — create a new retrievable record (auto-generates `id` /
39
+ * `createdAt` / `updatedAt` unless explicit values are supplied).
40
+ * - {@link updateRetrievableTool} — replace an existing retrievable by `id`. Bumps
41
+ * `updatedAt`.
42
+ * - {@link deleteRetrievableTool} — remove a retrievable by `id`.
43
+ */
44
+ var TRUST_TIERS = [
45
+ "first-party",
46
+ "third-party-public",
47
+ "third-party-private"
48
+ ];
49
+ var serialiseRetrievable = (r) => ({
50
+ id: r.id,
51
+ content: r.content.toString(),
52
+ trustTier: r.trustTier,
53
+ source: r.source,
54
+ kind: r.kind,
55
+ score: r.score,
56
+ createdAt: r.createdAt.toISO(),
57
+ updatedAt: r.updatedAt.toISO()
58
+ });
59
+ /**
60
+ * List every retrievable record currently held by the active execution context.
61
+ *
62
+ * @remarks
63
+ * Delegates to `ctx.fetchRetrievables()`. Returns a JSON-encoded array of retrievable records
64
+ * (id, content, trustTier, source, kind, score, createdAt, updatedAt).
65
+ */
66
+ var listRetrievablesTool = new require_tool.Tool({
67
+ name: "list_retrievables",
68
+ description: "List every retrievable record currently available to the agent. Returns a JSON array of records with id, content, trustTier, source, kind, score, createdAt, and updatedAt.",
69
+ inputSchema: _nhtio_validation.validator.object({}),
70
+ artifactConstructor: () => require_spooled_markdown_artifact.SpooledJsonArtifact,
71
+ handler: async (_args, ctx) => {
72
+ try {
73
+ const retrievables = await ctx.fetchRetrievables();
74
+ return JSON.stringify(retrievables.map(serialiseRetrievable), null, 2);
75
+ } catch (err) {
76
+ return `Error: ${require_tool_registry.isError(err) ? err.message : String(err)}`;
77
+ }
78
+ }
79
+ });
80
+ /**
81
+ * Create a new {@link @nhtio/adk!Retrievable} record and persist it via the context's `storeRetrievable`
82
+ * callback.
83
+ *
84
+ * @remarks
85
+ * When `id` is omitted, a UUID v6 is generated. When `createdAt` / `updatedAt` are omitted,
86
+ * the current time is used. The model must declare `trustTier` explicitly — there is no
87
+ * default; the choice is consciously the model's, exposed by the deployer's decision to
88
+ * register this tool.
89
+ */
90
+ var storeRetrievableTool = new require_tool.Tool({
91
+ name: "store_retrievable",
92
+ description: "Store a new retrievable (RAG) record. The trustTier MUST be one of 'first-party' (deployer-vetted), 'third-party-public' (open-web), or 'third-party-private' (user uploads). id and timestamps are auto-generated if omitted.",
93
+ inputSchema: _nhtio_validation.validator.object({
94
+ content: _nhtio_validation.validator.string().required().description("The retrievable content as a plain string."),
95
+ trustTier: _nhtio_validation.validator.string().valid(...TRUST_TIERS).required().description("Trust tier: 'first-party' for deployer-vetted material, 'third-party-public' for open-web or public APIs, 'third-party-private' for user uploads or partner APIs."),
96
+ source: _nhtio_validation.validator.string().optional().description("Optional provenance string: URL, document path, KB id, etc."),
97
+ kind: _nhtio_validation.validator.string().optional().description("Optional semantic label: 'policy', 'reference', 'web-page', 'pdf', etc."),
98
+ score: _nhtio_validation.validator.number().min(0).max(1).optional().description("Optional relevance / similarity score in [0, 1]."),
99
+ id: _nhtio_validation.validator.string().optional().description("Optional stable id. Auto-generated when absent.")
100
+ }),
101
+ artifactConstructor: () => require_spooled_markdown_artifact.SpooledJsonArtifact,
102
+ handler: async (args, ctx) => {
103
+ const { content, trustTier, source, kind, score, id } = args;
104
+ try {
105
+ const now = luxon.DateTime.now();
106
+ const retrievable = new require_common.Retrievable({
107
+ id: id ?? (0, uuid.v6)(),
108
+ content,
109
+ trustTier,
110
+ source,
111
+ kind,
112
+ score,
113
+ createdAt: now,
114
+ updatedAt: now
115
+ });
116
+ await ctx.storeRetrievable(retrievable);
117
+ return JSON.stringify({
118
+ ok: true,
119
+ retrievable: serialiseRetrievable(retrievable)
120
+ }, null, 2);
121
+ } catch (err) {
122
+ return `Error: ${require_tool_registry.isError(err) ? err.message : String(err)}`;
123
+ }
124
+ }
125
+ });
126
+ /**
127
+ * Replace an existing {@link @nhtio/adk!Retrievable} by `id`.
128
+ *
129
+ * @remarks
130
+ * The model supplies `id` plus any subset of `content` / `trustTier` / `source` / `kind` /
131
+ * `score`; omitted fields retain their prior values. `updatedAt` is always bumped;
132
+ * `createdAt` is preserved. Returns an error when no retrievable with the supplied `id` is
133
+ * found.
134
+ */
135
+ var updateRetrievableTool = new require_tool.Tool({
136
+ name: "update_retrievable",
137
+ description: "Update an existing retrievable by id. Supply any subset of content / trustTier / source / kind / score — omitted fields retain their prior values. updatedAt is always refreshed.",
138
+ inputSchema: _nhtio_validation.validator.object({
139
+ id: _nhtio_validation.validator.string().required().description("Id of the retrievable to update."),
140
+ content: _nhtio_validation.validator.string().optional().description("Replacement content."),
141
+ trustTier: _nhtio_validation.validator.string().valid(...TRUST_TIERS).optional().description("Replacement trust tier."),
142
+ source: _nhtio_validation.validator.string().optional().description("Replacement provenance string."),
143
+ kind: _nhtio_validation.validator.string().optional().description("Replacement semantic label."),
144
+ score: _nhtio_validation.validator.number().min(0).max(1).optional().description("Replacement score in [0, 1].")
145
+ }),
146
+ artifactConstructor: () => require_spooled_markdown_artifact.SpooledJsonArtifact,
147
+ handler: async (args, ctx) => {
148
+ const { id, content, trustTier, source, kind, score } = args;
149
+ try {
150
+ const existing = (await ctx.fetchRetrievables()).find((r) => r.id === id);
151
+ if (!existing) return `Error: No retrievable found with id "${id}".`;
152
+ const updated = new require_common.Retrievable({
153
+ id: existing.id,
154
+ content: content ?? existing.content,
155
+ trustTier: trustTier ?? existing.trustTier,
156
+ source: source ?? existing.source,
157
+ kind: kind ?? existing.kind,
158
+ score: score ?? existing.score,
159
+ createdAt: existing.createdAt,
160
+ updatedAt: luxon.DateTime.now()
161
+ });
162
+ await ctx.mutateRetrievable(updated);
163
+ return JSON.stringify({
164
+ ok: true,
165
+ retrievable: serialiseRetrievable(updated)
166
+ }, null, 2);
167
+ } catch (err) {
168
+ return `Error: ${require_tool_registry.isError(err) ? err.message : String(err)}`;
169
+ }
170
+ }
171
+ });
172
+ /**
173
+ * Remove an existing {@link @nhtio/adk!Retrievable} by `id`.
174
+ *
175
+ * @remarks
176
+ * Delegates to `ctx.deleteRetrievable(id)`. Returns `{ ok: true, id }` on success regardless
177
+ * of whether a retrievable was actually present — `deleteRetrievable` is idempotent at the
178
+ * ADK level.
179
+ */
180
+ var deleteRetrievableTool = new require_tool.Tool({
181
+ name: "delete_retrievable",
182
+ description: "Delete a retrievable by id.",
183
+ inputSchema: _nhtio_validation.validator.object({ id: _nhtio_validation.validator.string().required().description("Id of the retrievable to delete.") }),
184
+ artifactConstructor: () => require_spooled_markdown_artifact.SpooledJsonArtifact,
185
+ handler: async (args, ctx) => {
186
+ const { id } = args;
187
+ try {
188
+ await ctx.deleteRetrievable(id);
189
+ return JSON.stringify({
190
+ ok: true,
191
+ id
192
+ }, null, 2);
193
+ } catch (err) {
194
+ return `Error: ${require_tool_registry.isError(err) ? err.message : String(err)}`;
195
+ }
196
+ }
197
+ });
198
+ /**
199
+ * Convenience tuple of every retrievable CRUD tool. Spread into a {@link @nhtio/adk!ToolRegistry} to
200
+ * register the entire category at once.
201
+ */
202
+ var retrievableTools = [
203
+ listRetrievablesTool,
204
+ storeRetrievableTool,
205
+ updateRetrievableTool,
206
+ deleteRetrievableTool
207
+ ];
208
+ //#endregion
209
+ exports.deleteRetrievableTool = deleteRetrievableTool;
210
+ exports.listRetrievablesTool = listRetrievablesTool;
211
+ exports.retrievableTools = retrievableTools;
212
+ exports.storeRetrievableTool = storeRetrievableTool;
213
+ exports.updateRetrievableTool = updateRetrievableTool;
214
+
215
+ //# sourceMappingURL=retrievables.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retrievables.cjs","names":[],"sources":["../../../src/batteries/tools/retrievables/index.ts"],"sourcesContent":["/**\n * Pre-constructed CRUD tools for model-visible retrievable and RAG-record management.\n *\n * @module @nhtio/adk/batteries/tools/retrievables\n *\n * @remarks\n * Pre-constructed CRUD tools that expose the ADK's {@link @nhtio/adk!Retrievable} surface to the\n * model. Each tool delegates to the corresponding callback on the active\n * {@link @nhtio/adk!DispatchContext} (`fetchRetrievables`, `storeRetrievable`, `mutateRetrievable`,\n * `deleteRetrievable`) — the persistence layer is whatever the consumer wired into the\n * runner.\n *\n * Retrievables are RAG records and carry an explicit `trustTier` that drives the LLM\n * battery's rendering envelope. Exposing these CRUD tools to the model is a deliberate\n * deployer decision; the trust tier the model declares when creating or updating a record\n * is honoured verbatim by the persistence layer. The deployer is responsible for choosing\n * whether to register all four tools, only the read-only `list_retrievables`, or any subset\n * thereof — that registration choice is exactly the trust boundary documented in the\n * Retrievable battery contract.\n *\n * Output is JSON for every tool so consumers can parse the result without re-tokenising —\n * the artifact constructor is set to {@link @nhtio/adk!SpooledJsonArtifact}.\n *\n * Tools:\n * - {@link listRetrievablesTool} — read-only list of every retrievable currently held by\n * the context.\n * - {@link storeRetrievableTool} — create a new retrievable record (auto-generates `id` /\n * `createdAt` / `updatedAt` unless explicit values are supplied).\n * - {@link updateRetrievableTool} — replace an existing retrievable by `id`. Bumps\n * `updatedAt`.\n * - {@link deleteRetrievableTool} — remove a retrievable by `id`.\n */\n\nimport { DateTime } from 'luxon'\nimport { v6 as uuidv6 } from 'uuid'\nimport { isError } from '@nhtio/adk/guards'\nimport { validator } from '@nhtio/validation'\nimport { Retrievable, SpooledJsonArtifact, Tool } from '@nhtio/adk/common'\n\nconst TRUST_TIERS = ['first-party', 'third-party-public', 'third-party-private'] as const\ntype TrustTier = (typeof TRUST_TIERS)[number]\n\nconst serialiseRetrievable = (r: Retrievable): Record<string, unknown> => ({\n id: r.id,\n content: r.content.toString(),\n trustTier: r.trustTier,\n source: r.source,\n kind: r.kind,\n score: r.score,\n createdAt: r.createdAt.toISO(),\n updatedAt: r.updatedAt.toISO(),\n})\n\n/**\n * List every retrievable record currently held by the active execution context.\n *\n * @remarks\n * Delegates to `ctx.fetchRetrievables()`. Returns a JSON-encoded array of retrievable records\n * (id, content, trustTier, source, kind, score, createdAt, updatedAt).\n */\nexport const listRetrievablesTool = new Tool({\n name: 'list_retrievables',\n description:\n 'List every retrievable record currently available to the agent. Returns a JSON array of records with id, content, trustTier, source, kind, score, createdAt, and updatedAt.',\n inputSchema: validator.object({}),\n artifactConstructor: () => SpooledJsonArtifact,\n handler: async (_args, ctx) => {\n try {\n const retrievables = await ctx.fetchRetrievables()\n return JSON.stringify(retrievables.map(serialiseRetrievable), null, 2)\n } catch (err) {\n return `Error: ${isError(err) ? err.message : String(err)}`\n }\n },\n})\n\n/**\n * Create a new {@link @nhtio/adk!Retrievable} record and persist it via the context's `storeRetrievable`\n * callback.\n *\n * @remarks\n * When `id` is omitted, a UUID v6 is generated. When `createdAt` / `updatedAt` are omitted,\n * the current time is used. The model must declare `trustTier` explicitly — there is no\n * default; the choice is consciously the model's, exposed by the deployer's decision to\n * register this tool.\n */\nexport const storeRetrievableTool = new Tool({\n name: 'store_retrievable',\n description:\n \"Store a new retrievable (RAG) record. The trustTier MUST be one of 'first-party' (deployer-vetted), 'third-party-public' (open-web), or 'third-party-private' (user uploads). id and timestamps are auto-generated if omitted.\",\n inputSchema: validator.object({\n content: validator\n .string()\n .required()\n .description('The retrievable content as a plain string.'),\n trustTier: validator\n .string()\n .valid(...TRUST_TIERS)\n .required()\n .description(\n \"Trust tier: 'first-party' for deployer-vetted material, 'third-party-public' for open-web or public APIs, 'third-party-private' for user uploads or partner APIs.\"\n ),\n source: validator\n .string()\n .optional()\n .description('Optional provenance string: URL, document path, KB id, etc.'),\n kind: validator\n .string()\n .optional()\n .description(\"Optional semantic label: 'policy', 'reference', 'web-page', 'pdf', etc.\"),\n score: validator\n .number()\n .min(0)\n .max(1)\n .optional()\n .description('Optional relevance / similarity score in [0, 1].'),\n id: validator\n .string()\n .optional()\n .description('Optional stable id. Auto-generated when absent.'),\n }),\n artifactConstructor: () => SpooledJsonArtifact,\n handler: async (args, ctx) => {\n const { content, trustTier, source, kind, score, id } = args as {\n content: string\n trustTier: TrustTier\n source?: string\n kind?: string\n score?: number\n id?: string\n }\n try {\n const now = DateTime.now()\n const retrievable = new Retrievable({\n id: id ?? uuidv6(),\n content,\n trustTier,\n source,\n kind,\n score,\n createdAt: now,\n updatedAt: now,\n })\n await ctx.storeRetrievable(retrievable)\n return JSON.stringify({ ok: true, retrievable: serialiseRetrievable(retrievable) }, null, 2)\n } catch (err) {\n return `Error: ${isError(err) ? err.message : String(err)}`\n }\n },\n})\n\n/**\n * Replace an existing {@link @nhtio/adk!Retrievable} by `id`.\n *\n * @remarks\n * The model supplies `id` plus any subset of `content` / `trustTier` / `source` / `kind` /\n * `score`; omitted fields retain their prior values. `updatedAt` is always bumped;\n * `createdAt` is preserved. Returns an error when no retrievable with the supplied `id` is\n * found.\n */\nexport const updateRetrievableTool = new Tool({\n name: 'update_retrievable',\n description:\n 'Update an existing retrievable by id. Supply any subset of content / trustTier / source / kind / score — omitted fields retain their prior values. updatedAt is always refreshed.',\n inputSchema: validator.object({\n id: validator.string().required().description('Id of the retrievable to update.'),\n content: validator.string().optional().description('Replacement content.'),\n trustTier: validator\n .string()\n .valid(...TRUST_TIERS)\n .optional()\n .description('Replacement trust tier.'),\n source: validator.string().optional().description('Replacement provenance string.'),\n kind: validator.string().optional().description('Replacement semantic label.'),\n score: validator.number().min(0).max(1).optional().description('Replacement score in [0, 1].'),\n }),\n artifactConstructor: () => SpooledJsonArtifact,\n handler: async (args, ctx) => {\n const { id, content, trustTier, source, kind, score } = args as {\n id: string\n content?: string\n trustTier?: TrustTier\n source?: string\n kind?: string\n score?: number\n }\n try {\n const retrievables = await ctx.fetchRetrievables()\n const existing = retrievables.find((r) => r.id === id)\n if (!existing) {\n return `Error: No retrievable found with id \"${id}\".`\n }\n const updated = new Retrievable({\n id: existing.id,\n content: content ?? existing.content,\n trustTier: trustTier ?? existing.trustTier,\n source: source ?? existing.source,\n kind: kind ?? existing.kind,\n score: score ?? existing.score,\n createdAt: existing.createdAt,\n updatedAt: DateTime.now(),\n })\n await ctx.mutateRetrievable(updated)\n return JSON.stringify({ ok: true, retrievable: serialiseRetrievable(updated) }, null, 2)\n } catch (err) {\n return `Error: ${isError(err) ? err.message : String(err)}`\n }\n },\n})\n\n/**\n * Remove an existing {@link @nhtio/adk!Retrievable} by `id`.\n *\n * @remarks\n * Delegates to `ctx.deleteRetrievable(id)`. Returns `{ ok: true, id }` on success regardless\n * of whether a retrievable was actually present — `deleteRetrievable` is idempotent at the\n * ADK level.\n */\nexport const deleteRetrievableTool = new Tool({\n name: 'delete_retrievable',\n description: 'Delete a retrievable by id.',\n inputSchema: validator.object({\n id: validator.string().required().description('Id of the retrievable to delete.'),\n }),\n artifactConstructor: () => SpooledJsonArtifact,\n handler: async (args, ctx) => {\n const { id } = args as { id: string }\n try {\n await ctx.deleteRetrievable(id)\n return JSON.stringify({ ok: true, id }, null, 2)\n } catch (err) {\n return `Error: ${isError(err) ? err.message : String(err)}`\n }\n },\n})\n\n/**\n * Convenience tuple of every retrievable CRUD tool. Spread into a {@link @nhtio/adk!ToolRegistry} to\n * register the entire category at once.\n */\nexport const retrievableTools = [\n listRetrievablesTool,\n storeRetrievableTool,\n updateRetrievableTool,\n deleteRetrievableTool,\n] as const\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAM,cAAc;CAAC;CAAe;CAAsB;AAAqB;AAG/E,IAAM,wBAAwB,OAA6C;CACzE,IAAI,EAAE;CACN,SAAS,EAAE,QAAQ,SAAS;CAC5B,WAAW,EAAE;CACb,QAAQ,EAAE;CACV,MAAM,EAAE;CACR,OAAO,EAAE;CACT,WAAW,EAAE,UAAU,MAAM;CAC7B,WAAW,EAAE,UAAU,MAAM;AAC/B;;;;;;;;AASA,IAAa,uBAAuB,IAAI,aAAA,KAAK;CAC3C,MAAM;CACN,aACE;CACF,aAAa,kBAAA,UAAU,OAAO,CAAC,CAAC;CAChC,2BAA2B,kCAAA;CAC3B,SAAS,OAAO,OAAO,QAAQ;EAC7B,IAAI;GACF,MAAM,eAAe,MAAM,IAAI,kBAAkB;GACjD,OAAO,KAAK,UAAU,aAAa,IAAI,oBAAoB,GAAG,MAAM,CAAC;EACvE,S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