@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,370 @@
1
+ /**
2
+ * Thrown by {@link @nhtio/adk!TurnRunner} when the supplied config object fails schema validation at
3
+ * construction time.
4
+ *
5
+ * @remarks
6
+ * Marked fatal — a misconfigured runner must not be allowed to execute turns.
7
+ *
8
+ * @group Turn Runner Construction
9
+ */
10
+ export declare const E_INVALID_TURN_RUNNER_CONFIG: import("../utils/exceptions").CreatedException<[
11
+ ]>;
12
+ /**
13
+ * Thrown by {@link @nhtio/adk!TurnRunner} when the {@link @nhtio/adk!TurnContext} supplied to `run` fails schema
14
+ * validation.
15
+ *
16
+ * @remarks
17
+ * Marked fatal — an invalid context indicates a programming error in the caller, not a
18
+ * recoverable runtime condition. Thrown synchronously out of `run()` before `turnStart` is
19
+ * emitted.
20
+ *
21
+ * @group Turn Input Validation
22
+ */
23
+ export declare const E_INVALID_TURN_CONTEXT: import("../utils/exceptions").CreatedException<[
24
+ ]>;
25
+ /**
26
+ * Emitted (via the `error` event) when a non-abort error propagates out of the input
27
+ * middleware pipeline during {@link @nhtio/adk!TurnRunner.run}.
28
+ *
29
+ * @remarks
30
+ * Not fatal — the turn runner emits this on the `error` event rather than throwing, so
31
+ * registered listeners can handle or log the failure without crashing the pipeline. Dispatch
32
+ * and output middleware are skipped; `turnEnd` still fires.
33
+ *
34
+ * @group Pipelines
35
+ */
36
+ export declare const E_INPUT_PIPELINE_ERROR: import("../utils/exceptions").CreatedException<[
37
+ ]>;
38
+ /**
39
+ * Emitted (via the `error` event) when a non-abort error propagates out of the output
40
+ * middleware pipeline during {@link @nhtio/adk!TurnRunner.run}.
41
+ *
42
+ * @remarks
43
+ * Not fatal — the turn runner emits this on the `error` event rather than throwing, so
44
+ * registered listeners can handle or log the failure without crashing the pipeline. `turnEnd`
45
+ * still fires.
46
+ *
47
+ * @group Pipelines
48
+ */
49
+ export declare const E_OUTPUT_PIPELINE_ERROR: import("../utils/exceptions").CreatedException<[
50
+ ]>;
51
+ /**
52
+ * Emitted (via the `error` event) when a middleware pipeline resolves without reaching its
53
+ * terminal handler and without the turn being aborted. Indicates that some middleware
54
+ * returned without calling `next` and without signalling a deliberate refusal via the turn's
55
+ * abort controller.
56
+ *
57
+ * @remarks
58
+ * Not fatal — the runner emits this on the `error` event so the failure is observable, then
59
+ * proceeds to short-circuit the remainder of the turn the same way any other pipeline error
60
+ * would. The constructor takes a single positional argument identifying the pipeline that
61
+ * short-circuited: one of `'turn-input'`, `'turn-output'`, `'dispatch-input'`, or `'dispatch-output'`.
62
+ *
63
+ * Deliberate refusals should call `ctx.abort(reason)`, which sets the `'aborted'` outcome
64
+ * instead of emitting this error.
65
+ *
66
+ * @warning
67
+ * This is a **detection condition**, not a thrown exception. The runner constructs and emits
68
+ * the code itself when it detects a missing `next()` on the unwind — nothing in user code
69
+ * throws it. Upstream post-steps still run normally.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * throw new E_PIPELINE_SHORT_CIRCUITED(['turn-input'])
74
+ * ```
75
+ *
76
+ * @group Pipelines
77
+ */
78
+ export declare const E_PIPELINE_SHORT_CIRCUITED: import("../utils/exceptions").CreatedException<[
79
+ string
80
+ ]>;
81
+ /**
82
+ * Thrown when a registry is initialised with a value that is defined but not a plain object.
83
+ *
84
+ * @remarks
85
+ * Registries expect either `undefined` (empty start) or a plain object as their initial value.
86
+ * Passing a primitive, array, class instance, or other non-object signals a programming error
87
+ * in the caller.
88
+ *
89
+ * @group Primitive Validation
90
+ */
91
+ export declare const E_INVALID_INITIAL_REGISTRY_VALUE: import("../utils/exceptions").CreatedException<[
92
+ ]>;
93
+ /**
94
+ * Thrown when a {@link @nhtio/adk!Memory} is initialised with a value that fails schema validation.
95
+ *
96
+ * @remarks
97
+ * `Memory` requires all fields — `id`, `content`, `confidence`, `importance`, `createdAt`,
98
+ * `updatedAt` — to be present and of the correct type. Passing an incomplete or incorrectly
99
+ * typed object signals a programming error in the caller, not a recoverable runtime condition.
100
+ *
101
+ * @group Primitive Validation
102
+ */
103
+ export declare const E_INVALID_INITIAL_MEMORY_VALUE: import("../utils/exceptions").CreatedException<[
104
+ ]>;
105
+ /**
106
+ * Thrown when a {@link @nhtio/adk!Retrievable} is initialised with a value that fails schema validation.
107
+ *
108
+ * @remarks
109
+ * `Retrievable` requires `id`, `content`, `trustTier`, `createdAt`, and `updatedAt` to be present
110
+ * and of the correct type, and `trustTier` must be one of `'first-party'`, `'third-party-public'`,
111
+ * or `'third-party-private'`. The `trustTier` decision must be made consciously by the retrieval
112
+ * middleware at construction time — there is no default. Passing an incomplete or incorrectly
113
+ * typed object signals a programming error in the caller, not a recoverable runtime condition.
114
+ *
115
+ * @group Primitive Validation
116
+ */
117
+ export declare const E_INVALID_INITIAL_RETRIEVABLE_VALUE: import("../utils/exceptions").CreatedException<[
118
+ ]>;
119
+ /**
120
+ * Thrown when a {@link @nhtio/adk!Message} is initialised with a value that fails schema validation.
121
+ *
122
+ * @remarks
123
+ * `Message` requires `id`, `role` (`user` or `assistant`), `content`, `createdAt`, and
124
+ * `updatedAt` to be present and of the correct type. Passing an incomplete or incorrectly
125
+ * typed object signals a programming error in the caller, not a recoverable runtime condition.
126
+ *
127
+ * @group Primitive Validation
128
+ */
129
+ export declare const E_INVALID_INITIAL_MESSAGE_VALUE: import("../utils/exceptions").CreatedException<[
130
+ ]>;
131
+ /**
132
+ * Thrown when an {@link @nhtio/adk!Identity} is initialised with a value that fails schema validation.
133
+ *
134
+ * @remarks
135
+ * `Identity` requires both `identifier` (string or number) and `representation` (string or
136
+ * {@link @nhtio/adk!Tokenizable}) to be present and of the correct type. Passing an incomplete or
137
+ * incorrectly typed object signals a programming error in the caller.
138
+ *
139
+ * @group Primitive Validation
140
+ */
141
+ export declare const E_INVALID_INITIAL_IDENTITY_VALUE: import("../utils/exceptions").CreatedException<[
142
+ ]>;
143
+ /**
144
+ * Thrown when a {@link @nhtio/adk!Thought} is initialised with a value that fails schema validation.
145
+ *
146
+ * @remarks
147
+ * `Thought` requires `id`, `content`, `createdAt`, and `updatedAt` to be present and of the
148
+ * correct type. Passing an incomplete or incorrectly typed object signals a programming error
149
+ * in the caller, not a recoverable runtime condition.
150
+ *
151
+ * @group Primitive Validation
152
+ */
153
+ export declare const E_INVALID_INITIAL_THOUGHT_VALUE: import("../utils/exceptions").CreatedException<[
154
+ ]>;
155
+ /**
156
+ * Thrown when a {@link @nhtio/adk!TurnGate} is constructed with a value that fails schema validation.
157
+ *
158
+ * @remarks
159
+ * Fatal — bad construction arguments indicate a programming error in the caller.
160
+ *
161
+ * @group Gates
162
+ */
163
+ export declare const E_INVALID_INITIAL_TURN_GATE_VALUE: import("../utils/exceptions").CreatedException<[
164
+ ]>;
165
+ /**
166
+ * Thrown synchronously in the caller's context when {@link @nhtio/adk!TurnGate.resolve} is called with a
167
+ * value that fails the gate's schema.
168
+ *
169
+ * @remarks
170
+ * Fatal — passing the wrong type to `resolve()` is a programming error. The internal promise is
171
+ * NOT settled when this is thrown; the gate remains open.
172
+ *
173
+ * @group Gates
174
+ */
175
+ export declare const E_INVALID_TURN_GATE_RESOLUTION: import("../utils/exceptions").CreatedException<[
176
+ ]>;
177
+ /**
178
+ * Thrown (as a rejection reason) when a {@link @nhtio/adk!TurnGate} times out before being resolved.
179
+ *
180
+ * @remarks
181
+ * Not fatal — a timeout is a recoverable runtime condition; the caller may retry or surface it
182
+ * to the user.
183
+ *
184
+ * @warning
185
+ * A timeout does **not** cancel the external event or clear any remote queue. The gate closes
186
+ * locally, but whatever external system was expected to call `gate.resolve()` may still fire
187
+ * later. Orphaned external state must be handled by the caller.
188
+ *
189
+ * @group Gates
190
+ */
191
+ export declare const E_TURN_GATE_TIMEOUT: import("../utils/exceptions").CreatedException<[
192
+ ]>;
193
+ /**
194
+ * Thrown (as a rejection reason) when a {@link @nhtio/adk!TurnGate} is aborted — either because the turn's
195
+ * `AbortSignal` fired or because {@link @nhtio/adk!TurnGate.abort} was called directly.
196
+ *
197
+ * @remarks
198
+ * Not fatal — abort is an intentional cancellation, not an error in the caller.
199
+ *
200
+ * @group Gates
201
+ */
202
+ export declare const E_TURN_GATE_ABORTED: import("../utils/exceptions").CreatedException<[
203
+ ]>;
204
+ /**
205
+ * Thrown when a {@link @nhtio/adk!SpooledArtifact} is constructed with a value that does not implement the
206
+ * {@link @nhtio/adk!SpoolReader} interface.
207
+ *
208
+ * @remarks
209
+ * Validated at construction time via {@link @nhtio/adk!implementsSpoolReader}. Passing anything that lacks
210
+ * `line`, `byteLength`, or `lineCount` as callable functions signals a programming error in the
211
+ * caller.
212
+ *
213
+ * @group Artifacts
214
+ */
215
+ export declare const E_NOT_A_SPOOL_READER: import("../utils/exceptions").CreatedException<[
216
+ ]>;
217
+ /**
218
+ * Thrown when a Media is constructed with a value that does not implement the MediaReader
219
+ * interface.
220
+ *
221
+ * @remarks
222
+ * Validated at construction time. Passing anything that lacks `stream` or `byteLength` as
223
+ * callable functions signals a programming error in the caller.
224
+ *
225
+ * @group Artifacts
226
+ */
227
+ export declare const E_NOT_A_MEDIA_READER: import("../utils/exceptions").CreatedException<[
228
+ ]>;
229
+ /**
230
+ * Thrown when a Media is initialised with a value that fails schema validation.
231
+ *
232
+ * @remarks
233
+ * Fatal — bad construction arguments indicate a programming error in the caller.
234
+ *
235
+ * @group Artifacts
236
+ */
237
+ export declare const E_INVALID_INITIAL_MEDIA_VALUE: import("../utils/exceptions").CreatedException<[
238
+ ]>;
239
+ /**
240
+ * Thrown when a {@link @nhtio/adk!ToolCall} is initialised with a value that fails schema validation.
241
+ *
242
+ * @remarks
243
+ * `ToolCall` requires `id`, `tool`, `args`, `checksum`, `isComplete`, `isError`, `createdAt`,
244
+ * and `updatedAt` to be present and of the correct type. Passing an incomplete or incorrectly
245
+ * typed object signals a programming error in the caller, not a recoverable runtime condition.
246
+ *
247
+ * @group Primitive Validation
248
+ */
249
+ export declare const E_INVALID_INITIAL_TOOL_CALL_VALUE: import("../utils/exceptions").CreatedException<[
250
+ ]>;
251
+ /**
252
+ * Thrown when a {@link @nhtio/adk!Tool} is constructed with a value that fails schema validation.
253
+ *
254
+ * @remarks
255
+ * Fatal — bad construction arguments indicate a programming error in the caller.
256
+ *
257
+ * @group Tools
258
+ */
259
+ export declare const E_INVALID_INITIAL_TOOL_VALUE: import("../utils/exceptions").CreatedException<[
260
+ ]>;
261
+ /**
262
+ * Thrown synchronously when {@link @nhtio/adk!Tool.validate} is called with arguments that fail the tool's
263
+ * input schema.
264
+ *
265
+ * @remarks
266
+ * Not fatal — an arg validation failure in the tool call loop is a caller mistake that can be
267
+ * surfaced as an error response. The tool handler is NOT called when this is thrown.
268
+ *
269
+ * @group Tools
270
+ */
271
+ export declare const E_INVALID_TOOL_ARGS: import("../utils/exceptions").CreatedException<[
272
+ ]>;
273
+ /**
274
+ * Thrown (as a rejection reason) when a {@link @nhtio/adk!Tool}'s handler throws during execution.
275
+ *
276
+ * @remarks
277
+ * Not fatal — a downstream tool failure is a recoverable runtime condition. The tool call loop
278
+ * catches this error specifically to report the failure back to the model rather than crashing
279
+ * the pipeline.
280
+ *
281
+ * @group Tools
282
+ */
283
+ export declare const E_TOOL_DOWNSTREAM_ERROR: import("../utils/exceptions").CreatedException<[
284
+ ]>;
285
+ /**
286
+ * Thrown when {@link @nhtio/adk!ToolRegistry.register} is called for a tool name that is already registered
287
+ * and `overwrite` is not `true`.
288
+ *
289
+ * @remarks
290
+ * Fatal — accidentally overwriting a registered tool indicates a programming error. Pass
291
+ * `overwrite: true` to replace an existing tool intentionally.
292
+ *
293
+ * @group Tools
294
+ */
295
+ export declare const E_TOOL_ALREADY_REGISTERED: import("../utils/exceptions").CreatedException<[
296
+ ]>;
297
+ /**
298
+ * Thrown when {@link @nhtio/adk!DispatchContext} is constructed with a value that fails schema validation.
299
+ *
300
+ * @remarks
301
+ * Fatal — bad construction arguments indicate a programming error in the caller.
302
+ *
303
+ * @group Dispatch
304
+ */
305
+ export declare const E_INVALID_LLM_EXECUTION_CONTEXT: import("../utils/exceptions").CreatedException<[
306
+ ]>;
307
+ /**
308
+ * Thrown (as a rejection reason) when {@link @nhtio/adk!DispatchContext.waitFor} is called on a
309
+ * standalone context that was constructed without a `waitFor` function.
310
+ *
311
+ * @remarks
312
+ * Not fatal — the caller can catch this and handle the case where gate suspension is not
313
+ * supported for this execution context.
314
+ *
315
+ * @group Dispatch
316
+ */
317
+ export declare const E_LLM_EXECUTION_GATE_NOT_SUPPORTED: import("../utils/exceptions").CreatedException<[
318
+ ]>;
319
+ /**
320
+ * Thrown when {@link @nhtio/adk!DispatchContext.ack} or {@link @nhtio/adk!DispatchContext.nack} is called on a
321
+ * context that has already been signalled.
322
+ *
323
+ * @remarks
324
+ * Fatal — signalling twice is a programming error in the caller. The first signal wins; the
325
+ * second call is rejected loudly so callers cannot accidentally race between ack and nack.
326
+ *
327
+ * @danger
328
+ * Signalling is **not** silently idempotent. The first `ack()` or `nack()` wins; the second
329
+ * throws immediately. Guard with `if (!ctx.isSignalled)` when more than one seam may signal.
330
+ *
331
+ * @group Dispatch
332
+ */
333
+ export declare const E_LLM_EXECUTION_ALREADY_SIGNALLED: import("../utils/exceptions").CreatedException<[
334
+ ]>;
335
+ /**
336
+ * Thrown when {@link @nhtio/adk!DispatchRunner.dispatch} receives an input that fails schema validation.
337
+ *
338
+ * @remarks
339
+ * Fatal — invalid dispatch input indicates a programming error in the caller.
340
+ *
341
+ * @group Dispatch
342
+ */
343
+ export declare const E_INVALID_LLM_DISPATCH_INPUT: import("../utils/exceptions").CreatedException<[
344
+ ]>;
345
+ /**
346
+ * Emitted (via the observability `error` hook) and re-thrown when a non-abort error propagates
347
+ * out of the input or output middleware pipeline during {@link @nhtio/adk!DispatchRunner.dispatch}.
348
+ *
349
+ * @remarks
350
+ * Not fatal — pipeline errors are recoverable runtime conditions. `dispatch()` rejects with this
351
+ * exception so callers can handle the failure via try/catch. Both `dispatchInputPipeline` and
352
+ * `dispatchOutputPipeline` share this one code — the runner does not split input vs. output at
353
+ * this layer.
354
+ *
355
+ * @group Pipelines
356
+ */
357
+ export declare const E_DISPATCH_PIPELINE_ERROR: import("../utils/exceptions").CreatedException<[
358
+ ]>;
359
+ /**
360
+ * Emitted (via the observability `error` hook) and re-thrown when the user-supplied executor
361
+ * callback throws during {@link @nhtio/adk!DispatchRunner.dispatch}.
362
+ *
363
+ * @remarks
364
+ * Not fatal — executor errors are recoverable runtime conditions. `dispatch()` rejects with this
365
+ * exception so callers can handle the failure via try/catch.
366
+ *
367
+ * @group Dispatch
368
+ */
369
+ export declare const E_LLM_EXECUTION_EXECUTOR_ERROR: import("../utils/exceptions").CreatedException<[
370
+ ]>;
@@ -0,0 +1,39 @@
1
+ import type { MediaReader } from "../contracts/media_reader";
2
+ /**
3
+ * Constructs a {@link @nhtio/adk!MediaReader} backed by an in-memory `Uint8Array`.
4
+ *
5
+ * @remarks
6
+ * Each `stream()` call returns a fresh single-chunk `ReadableStream` over the same buffer. The
7
+ * reader is re-openable by construction — call `stream()` as many times as needed.
8
+ *
9
+ * @param bytes - The buffer to serve.
10
+ * @returns A {@link @nhtio/adk!MediaReader} that re-reads `bytes` on every call.
11
+ */
12
+ export declare const inMemoryMediaReader: (bytes: Uint8Array) => MediaReader;
13
+ /**
14
+ * Constructs a {@link @nhtio/adk!MediaReader} backed by a fetch call.
15
+ *
16
+ * @remarks
17
+ * Each `stream()` call re-issues the fetch. Tool authors whose underlying source is rate-limited
18
+ * or expensive must cache locally before constructing the reader — the framework cannot make
19
+ * that decision for them.
20
+ *
21
+ * `byteLength()` returns `undefined` because most remote sources do not promise it without an
22
+ * extra HEAD request; consumers that need a byte size should resolve it out-of-band.
23
+ *
24
+ * @param url - The URL to fetch on each call.
25
+ * @param init - Optional `fetch` init forwarded verbatim.
26
+ * @returns A {@link @nhtio/adk!MediaReader} that re-issues `fetch(url, init)` on every call.
27
+ */
28
+ export declare const fromFetch: (url: string | URL, init?: RequestInit) => MediaReader;
29
+ /**
30
+ * Constructs a {@link @nhtio/adk!MediaReader} backed by a browser `File` or `Blob`.
31
+ *
32
+ * @remarks
33
+ * Each `stream()` call re-streams the underlying File via `File.stream()`. `byteLength()`
34
+ * resolves from `file.size`.
35
+ *
36
+ * @param file - The browser `File` or `Blob` to stream.
37
+ * @returns A {@link @nhtio/adk!MediaReader} that re-streams `file` on every call.
38
+ */
39
+ export declare const fromWebFile: (file: Blob) => MediaReader;
@@ -0,0 +1,144 @@
1
+ import { RawTurnContext } from "./contracts/turn_runner_context";
2
+ import type { TurnRunnerConfig } from "./contracts/turn_runner_config";
3
+ import type { TurnEvent, TurnEventListener, TurnObservabilityEvent, TurnObservabilityEventListener } from "./types/turn_runner";
4
+ export type { TurnPipelineMiddlewareFn, TurnStreamableContent, TurnToolCallContent, TurnStartEvent, TurnEndEvent, TurnGateClosedEvent, ToolExecutionStartEvent, ToolExecutionEndEvent, EmitMessageFn, EmitThoughtFn, EmitToolCallFn, EmitToolExecutionStartFn, EmitToolExecutionEndFn, OpenGateFn, TurnEvents, TurnEvent, TurnEventListener, TurnObservabilityEvents, TurnObservabilityEvent, TurnObservabilityEventListener, } from "./types/turn_runner";
5
+ /**
6
+ * Executes a single agent turn through paired input and output middleware pipelines.
7
+ *
8
+ * @remarks
9
+ * Construction validates `config` eagerly and throws {@link @nhtio/adk!E_INVALID_TURN_RUNNER_CONFIG} if it
10
+ * does not satisfy the schema — fail-fast so misconfiguration surfaces before any turn runs.
11
+ *
12
+ * Each call to {@link TurnRunner.run} threads a {@link @nhtio/adk!TurnContext} through the input pipeline,
13
+ * invokes the model, then threads the result through the output pipeline. Middleware on each side
14
+ * can read and mutate the context for pre- and post-processing (e.g. message normalisation, tool
15
+ * call dispatch, response filtering).
16
+ *
17
+ * **Two event buses:**
18
+ * - Functional bus (`on` / `off` / `once`): `message`, `thought`, `toolCall` — pipeline-affecting
19
+ * events that middleware raises throughout turn execution.
20
+ * - Observability bus (`observe` / `unobserve` / `observeOnce`): `turnStart`, `turnEnd`,
21
+ * `turnGateOpen`, `turnGateClosed`, `error` — instrumentation-only events that monitor execution
22
+ * without participating in it.
23
+ *
24
+ * Streaming content is surfaced via `message` and `thought` events; tool call lifecycle via
25
+ * `toolCall`; non-fatal pipeline errors via the observability `error` event; gate lifecycle via
26
+ * `turnGateOpen` and `turnGateClosed` — all throughout execution.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const runner = new TurnRunner({
31
+ * fetchMemoriesCallback: async (ctx) => memoryStore.query(ctx),
32
+ * fetchMessagesCallback: async (ctx) => messageStore.history(ctx),
33
+ * fetchThoughtsCallback: async (ctx) => thoughtStore.history(ctx),
34
+ * fetchToolCallsCallback: async (ctx) => toolCallStore.history(ctx),
35
+ * })
36
+ * // Functional bus — pipeline events
37
+ * runner.on('message', (chunk) => process.stdout.write(chunk.aDelta))
38
+ * // Observability bus — instrumentation
39
+ * runner.observe('error', (err) => console.error(err.toString()))
40
+ * runner.observe('turnStart', ({ turnId }) => console.log('turn started', turnId))
41
+ * runner.observe('turnGateOpen', (gate) => {
42
+ * if (gate.reason === 'tool_approval') {
43
+ * gate.resolve(true) // approve immediately for this example
44
+ * }
45
+ * })
46
+ * await runner.run({
47
+ * turnAbortController: new AbortController(),
48
+ * systemPrompt: 'You are a helpful assistant.',
49
+ * standingInstructions: [],
50
+ * })
51
+ * ```
52
+ */
53
+ export declare class TurnRunner {
54
+ #private;
55
+ /**
56
+ * Returns `true` if `value` is a {@link TurnRunner} instance.
57
+ *
58
+ * @remarks
59
+ * Uses {@link @nhtio/adk!isInstanceOf} for cross-realm safety.
60
+ *
61
+ * @param value - The value to test.
62
+ * @returns `true` when `value` is a {@link TurnRunner} instance.
63
+ */
64
+ static isTurnRunner(value: unknown): value is TurnRunner;
65
+ /**
66
+ * @param config - Construction-time configuration validated against {@link turnRunnerConfigSchema}.
67
+ * @throws {@link @nhtio/adk!E_INVALID_TURN_RUNNER_CONFIG} when `config` does not satisfy the schema.
68
+ */
69
+ constructor(config: TurnRunnerConfig);
70
+ /**
71
+ * Removes a previously registered functional listener for `event`.
72
+ *
73
+ * @param event - The event to stop listening to.
74
+ * @param listener - The listener function to remove.
75
+ * @returns `this` for chaining.
76
+ */
77
+ off<K>(event: TurnEvent<K>, listener: TurnEventListener<K>): this;
78
+ /**
79
+ * Registers a persistent functional listener for `event`.
80
+ *
81
+ * @param event - The event to listen to.
82
+ * @param listener - The function to call on each emission.
83
+ * @returns `this` for chaining.
84
+ */
85
+ on<K>(event: TurnEvent<K>, listener: TurnEventListener<K>): this;
86
+ /**
87
+ * Registers a one-time functional listener for `event` that is automatically removed after the
88
+ * first emission.
89
+ *
90
+ * @param event - The event to listen to.
91
+ * @param listener - The function to call on the next emission.
92
+ * @returns `this` for chaining.
93
+ */
94
+ once<K>(event: TurnEvent<K>, listener: TurnEventListener<K>): this;
95
+ /**
96
+ * Removes a previously registered observability listener for `event`.
97
+ *
98
+ * @param event - The event to stop observing.
99
+ * @param listener - The listener function to remove.
100
+ * @returns `this` for chaining.
101
+ */
102
+ unobserve<K>(event: TurnObservabilityEvent<K>, listener: TurnObservabilityEventListener<K>): this;
103
+ /**
104
+ * Registers a persistent observability listener for `event`.
105
+ *
106
+ * @remarks
107
+ * Use the observability bus (`observe` / `unobserve` / `observeOnce`) for instrumentation:
108
+ * turn lifecycle, gate lifecycle, and non-fatal errors. Use the functional bus (`on` / `off` /
109
+ * `once`) for pipeline-affecting events: `message`, `thought`, `toolCall`.
110
+ *
111
+ * @param event - The event to observe.
112
+ * @param listener - The function to call on each emission.
113
+ * @returns `this` for chaining.
114
+ */
115
+ observe<K>(event: TurnObservabilityEvent<K>, listener: TurnObservabilityEventListener<K>): this;
116
+ /**
117
+ * Registers a one-time observability listener for `event` that is automatically removed after
118
+ * the first emission.
119
+ *
120
+ * @param event - The event to observe once.
121
+ * @param listener - The function to call on the next emission.
122
+ * @returns `this` for chaining.
123
+ */
124
+ observeOnce<K>(event: TurnObservabilityEvent<K>, listener: TurnObservabilityEventListener<K>): this;
125
+ /**
126
+ * Executes a single agent turn against the provided raw context.
127
+ *
128
+ * @remarks
129
+ * Returns `Promise<void>` intentionally — all meaningful output surfaces via events, not return
130
+ * values. Register listeners before calling `run`: observability events (`turnStart`, `turnEnd`)
131
+ * bracket execution; functional events (`message`, `thought`, `toolCall`) fire throughout;
132
+ * observability `error` carries non-fatal pipeline failures; `turnGateOpen` and `turnGateClosed`
133
+ * fire when middleware suspends via `ctx.waitFor()`. Awaiting this method only tells you the
134
+ * pipeline has finished, not what it produced.
135
+ *
136
+ * Constructs a validated {@link @nhtio/adk!TurnContext} from `context` (throwing
137
+ * {@link @nhtio/adk!E_INVALID_TURN_CONTEXT} on failure), then runs the input middleware pipeline.
138
+ * Abort signals are silently swallowed.
139
+ *
140
+ * @param context - Raw input validated and wrapped into a {@link @nhtio/adk!TurnContext} before execution.
141
+ * @throws {@link @nhtio/adk!E_INVALID_TURN_CONTEXT} when `context` does not satisfy the schema.
142
+ */
143
+ run(context: RawTurnContext): Promise<void>;
144
+ }