@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,346 @@
1
+ import { t as createException } from "./exceptions-NrzIHw_R.mjs";
2
+ //#region src/lib/exceptions/runtime.ts
3
+ /**
4
+ * Thrown by {@link @nhtio/adk!TurnRunner} when the supplied config object fails schema validation at
5
+ * construction time.
6
+ *
7
+ * @remarks
8
+ * Marked fatal — a misconfigured runner must not be allowed to execute turns.
9
+ *
10
+ * @group Turn Runner Construction
11
+ */
12
+ var E_INVALID_TURN_RUNNER_CONFIG = createException("E_INVALID_TURN_RUNNER_CONFIG", "The turn runner cannot be instantiated with the provided configuration.", "E_INVALID_TURN_RUNNER_CONFIG", 529, true);
13
+ /**
14
+ * Thrown by {@link @nhtio/adk!TurnRunner} when the {@link @nhtio/adk!TurnContext} supplied to `run` fails schema
15
+ * validation.
16
+ *
17
+ * @remarks
18
+ * Marked fatal — an invalid context indicates a programming error in the caller, not a
19
+ * recoverable runtime condition. Thrown synchronously out of `run()` before `turnStart` is
20
+ * emitted.
21
+ *
22
+ * @group Turn Input Validation
23
+ */
24
+ var E_INVALID_TURN_CONTEXT = createException("E_INVALID_TURN_CONTEXT", "The turn runner received an invalid context object.", "E_INVALID_TURN_CONTEXT", 529, true);
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
+ var E_INPUT_PIPELINE_ERROR = createException("E_INPUT_PIPELINE_ERROR", "An error occurred in the input pipeline.", "E_INPUT_PIPELINE_ERROR", 500, false);
37
+ /**
38
+ * Emitted (via the `error` event) when a non-abort error propagates out of the output
39
+ * middleware pipeline during {@link @nhtio/adk!TurnRunner.run}.
40
+ *
41
+ * @remarks
42
+ * Not fatal — the turn runner emits this on the `error` event rather than throwing, so
43
+ * registered listeners can handle or log the failure without crashing the pipeline. `turnEnd`
44
+ * still fires.
45
+ *
46
+ * @group Pipelines
47
+ */
48
+ var E_OUTPUT_PIPELINE_ERROR = createException("E_OUTPUT_PIPELINE_ERROR", "An error occurred in the output pipeline.", "E_OUTPUT_PIPELINE_ERROR", 500, false);
49
+ /**
50
+ * Emitted (via the `error` event) when a middleware pipeline resolves without reaching its
51
+ * terminal handler and without the turn being aborted. Indicates that some middleware
52
+ * returned without calling `next` and without signalling a deliberate refusal via the turn's
53
+ * abort controller.
54
+ *
55
+ * @remarks
56
+ * Not fatal — the runner emits this on the `error` event so the failure is observable, then
57
+ * proceeds to short-circuit the remainder of the turn the same way any other pipeline error
58
+ * would. The constructor takes a single positional argument identifying the pipeline that
59
+ * short-circuited: one of `'turn-input'`, `'turn-output'`, `'dispatch-input'`, or `'dispatch-output'`.
60
+ *
61
+ * Deliberate refusals should call `ctx.abort(reason)`, which sets the `'aborted'` outcome
62
+ * instead of emitting this error.
63
+ *
64
+ * @warning
65
+ * This is a **detection condition**, not a thrown exception. The runner constructs and emits
66
+ * the code itself when it detects a missing `next()` on the unwind — nothing in user code
67
+ * throws it. Upstream post-steps still run normally.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * throw new E_PIPELINE_SHORT_CIRCUITED(['turn-input'])
72
+ * ```
73
+ *
74
+ * @group Pipelines
75
+ */
76
+ var E_PIPELINE_SHORT_CIRCUITED = createException("E_PIPELINE_SHORT_CIRCUITED", "The '%s' middleware pipeline short-circuited without calling next or aborting the turn.", "E_PIPELINE_SHORT_CIRCUITED", 500, false);
77
+ /**
78
+ * Thrown when a registry is initialised with a value that is defined but not a plain object.
79
+ *
80
+ * @remarks
81
+ * Registries expect either `undefined` (empty start) or a plain object as their initial value.
82
+ * Passing a primitive, array, class instance, or other non-object signals a programming error
83
+ * in the caller.
84
+ *
85
+ * @group Primitive Validation
86
+ */
87
+ var E_INVALID_INITIAL_REGISTRY_VALUE = createException("E_INVALID_INITIAL_REGISTRY_VALUE", "Attempted to initialize a registry with a defined non-object value.", "E_INVALID_INITIAL_REGISTRY_VALUE", 500, true);
88
+ /**
89
+ * Thrown when a {@link @nhtio/adk!Memory} is initialised with a value that fails schema validation.
90
+ *
91
+ * @remarks
92
+ * `Memory` requires all fields — `id`, `content`, `confidence`, `importance`, `createdAt`,
93
+ * `updatedAt` — to be present and of the correct type. Passing an incomplete or incorrectly
94
+ * typed object signals a programming error in the caller, not a recoverable runtime condition.
95
+ *
96
+ * @group Primitive Validation
97
+ */
98
+ var E_INVALID_INITIAL_MEMORY_VALUE = createException("E_INVALID_INITIAL_MEMORY_VALUE", "Attempted to initialize a memory with an invalid value.", "E_INVALID_INITIAL_MEMORY_VALUE", 500, true);
99
+ /**
100
+ * Thrown when a {@link @nhtio/adk!Retrievable} is initialised with a value that fails schema validation.
101
+ *
102
+ * @remarks
103
+ * `Retrievable` requires `id`, `content`, `trustTier`, `createdAt`, and `updatedAt` to be present
104
+ * and of the correct type, and `trustTier` must be one of `'first-party'`, `'third-party-public'`,
105
+ * or `'third-party-private'`. The `trustTier` decision must be made consciously by the retrieval
106
+ * middleware at construction time — there is no default. Passing an incomplete or incorrectly
107
+ * typed object signals a programming error in the caller, not a recoverable runtime condition.
108
+ *
109
+ * @group Primitive Validation
110
+ */
111
+ var E_INVALID_INITIAL_RETRIEVABLE_VALUE = createException("E_INVALID_INITIAL_RETRIEVABLE_VALUE", "Invalid initial value supplied to Retrievable constructor.", "E_INVALID_INITIAL_RETRIEVABLE_VALUE", 500, true);
112
+ /**
113
+ * Thrown when a {@link @nhtio/adk!Message} is initialised with a value that fails schema validation.
114
+ *
115
+ * @remarks
116
+ * `Message` requires `id`, `role` (`user` or `assistant`), `content`, `createdAt`, and
117
+ * `updatedAt` to be present and of the correct type. Passing an incomplete or incorrectly
118
+ * typed object signals a programming error in the caller, not a recoverable runtime condition.
119
+ *
120
+ * @group Primitive Validation
121
+ */
122
+ var E_INVALID_INITIAL_MESSAGE_VALUE = createException("E_INVALID_INITIAL_MESSAGE_VALUE", "Attempted to initialize a message with an invalid value.", "E_INVALID_INITIAL_MESSAGE_VALUE", 500, true);
123
+ /**
124
+ * Thrown when an {@link @nhtio/adk!Identity} is initialised with a value that fails schema validation.
125
+ *
126
+ * @remarks
127
+ * `Identity` requires both `identifier` (string or number) and `representation` (string or
128
+ * {@link @nhtio/adk!Tokenizable}) to be present and of the correct type. Passing an incomplete or
129
+ * incorrectly typed object signals a programming error in the caller.
130
+ *
131
+ * @group Primitive Validation
132
+ */
133
+ var E_INVALID_INITIAL_IDENTITY_VALUE = createException("E_INVALID_INITIAL_IDENTITY_VALUE", "Attempted to initialize an identity with an invalid value.", "E_INVALID_INITIAL_IDENTITY_VALUE", 500, true);
134
+ /**
135
+ * Thrown when a {@link @nhtio/adk!Thought} is initialised with a value that fails schema validation.
136
+ *
137
+ * @remarks
138
+ * `Thought` requires `id`, `content`, `createdAt`, and `updatedAt` to be present and of the
139
+ * correct type. Passing an incomplete or incorrectly typed object signals a programming error
140
+ * in the caller, not a recoverable runtime condition.
141
+ *
142
+ * @group Primitive Validation
143
+ */
144
+ var E_INVALID_INITIAL_THOUGHT_VALUE = createException("E_INVALID_INITIAL_THOUGHT_VALUE", "Attempted to initialize a thought with an invalid value.", "E_INVALID_INITIAL_THOUGHT_VALUE", 500, true);
145
+ /**
146
+ * Thrown when a {@link @nhtio/adk!TurnGate} is constructed with a value that fails schema validation.
147
+ *
148
+ * @remarks
149
+ * Fatal — bad construction arguments indicate a programming error in the caller.
150
+ *
151
+ * @group Gates
152
+ */
153
+ var E_INVALID_INITIAL_TURN_GATE_VALUE = createException("E_INVALID_INITIAL_TURN_GATE_VALUE", "Attempted to initialize a turn gate with an invalid value.", "E_INVALID_INITIAL_TURN_GATE_VALUE", 500, true);
154
+ /**
155
+ * Thrown synchronously in the caller's context when {@link @nhtio/adk!TurnGate.resolve} is called with a
156
+ * value that fails the gate's schema.
157
+ *
158
+ * @remarks
159
+ * Fatal — passing the wrong type to `resolve()` is a programming error. The internal promise is
160
+ * NOT settled when this is thrown; the gate remains open.
161
+ *
162
+ * @group Gates
163
+ */
164
+ var E_INVALID_TURN_GATE_RESOLUTION = createException("E_INVALID_TURN_GATE_RESOLUTION", "The value supplied to TurnGate.resolve() failed schema validation.", "E_INVALID_TURN_GATE_RESOLUTION", 500, true);
165
+ /**
166
+ * Thrown (as a rejection reason) when a {@link @nhtio/adk!TurnGate} times out before being resolved.
167
+ *
168
+ * @remarks
169
+ * Not fatal — a timeout is a recoverable runtime condition; the caller may retry or surface it
170
+ * to the user.
171
+ *
172
+ * @warning
173
+ * A timeout does **not** cancel the external event or clear any remote queue. The gate closes
174
+ * locally, but whatever external system was expected to call `gate.resolve()` may still fire
175
+ * later. Orphaned external state must be handled by the caller.
176
+ *
177
+ * @group Gates
178
+ */
179
+ var E_TURN_GATE_TIMEOUT = createException("E_TURN_GATE_TIMEOUT", "The turn gate timed out before being resolved.", "E_TURN_GATE_TIMEOUT", 408, false);
180
+ /**
181
+ * Thrown (as a rejection reason) when a {@link @nhtio/adk!TurnGate} is aborted — either because the turn's
182
+ * `AbortSignal` fired or because {@link @nhtio/adk!TurnGate.abort} was called directly.
183
+ *
184
+ * @remarks
185
+ * Not fatal — abort is an intentional cancellation, not an error in the caller.
186
+ *
187
+ * @group Gates
188
+ */
189
+ var E_TURN_GATE_ABORTED = createException("E_TURN_GATE_ABORTED", "The turn gate was aborted before being resolved.", "E_TURN_GATE_ABORTED", 499, false);
190
+ /**
191
+ * Thrown when a {@link @nhtio/adk!SpooledArtifact} is constructed with a value that does not implement the
192
+ * {@link @nhtio/adk!SpoolReader} interface.
193
+ *
194
+ * @remarks
195
+ * Validated at construction time via {@link @nhtio/adk!implementsSpoolReader}. Passing anything that lacks
196
+ * `line`, `byteLength`, or `lineCount` as callable functions signals a programming error in the
197
+ * caller.
198
+ *
199
+ * @group Artifacts
200
+ */
201
+ var E_NOT_A_SPOOL_READER = createException("E_NOT_A_SPOOL_READER", "The provided value does not implement the SpoolReader interface.", "E_NOT_A_SPOOL_READER", 500, true);
202
+ /**
203
+ * Thrown when a Media is constructed with a value that does not implement the MediaReader
204
+ * interface.
205
+ *
206
+ * @remarks
207
+ * Validated at construction time. Passing anything that lacks `stream` or `byteLength` as
208
+ * callable functions signals a programming error in the caller.
209
+ *
210
+ * @group Artifacts
211
+ */
212
+ var E_NOT_A_MEDIA_READER = createException("E_NOT_A_MEDIA_READER", "The provided value does not implement the MediaReader interface.", "E_NOT_A_MEDIA_READER", 500, true);
213
+ /**
214
+ * Thrown when a Media is initialised with a value that fails schema validation.
215
+ *
216
+ * @remarks
217
+ * Fatal — bad construction arguments indicate a programming error in the caller.
218
+ *
219
+ * @group Artifacts
220
+ */
221
+ var E_INVALID_INITIAL_MEDIA_VALUE = createException("E_INVALID_INITIAL_MEDIA_VALUE", "Attempted to initialize a media with an invalid value.", "E_INVALID_INITIAL_MEDIA_VALUE", 500, true);
222
+ /**
223
+ * Thrown when a {@link @nhtio/adk!ToolCall} is initialised with a value that fails schema validation.
224
+ *
225
+ * @remarks
226
+ * `ToolCall` requires `id`, `tool`, `args`, `checksum`, `isComplete`, `isError`, `createdAt`,
227
+ * and `updatedAt` to be present and of the correct type. Passing an incomplete or incorrectly
228
+ * typed object signals a programming error in the caller, not a recoverable runtime condition.
229
+ *
230
+ * @group Primitive Validation
231
+ */
232
+ var E_INVALID_INITIAL_TOOL_CALL_VALUE = createException("E_INVALID_INITIAL_TOOL_CALL_VALUE", "Attempted to initialize a tool call with an invalid value.", "E_INVALID_INITIAL_TOOL_CALL_VALUE", 500, true);
233
+ /**
234
+ * Thrown when a {@link @nhtio/adk!Tool} is constructed with a value that fails schema validation.
235
+ *
236
+ * @remarks
237
+ * Fatal — bad construction arguments indicate a programming error in the caller.
238
+ *
239
+ * @group Tools
240
+ */
241
+ var E_INVALID_INITIAL_TOOL_VALUE = createException("E_INVALID_INITIAL_TOOL_VALUE", "Attempted to initialize a tool with an invalid value.", "E_INVALID_INITIAL_TOOL_VALUE", 500, true);
242
+ /**
243
+ * Thrown synchronously when {@link @nhtio/adk!Tool.validate} is called with arguments that fail the tool's
244
+ * input schema.
245
+ *
246
+ * @remarks
247
+ * Not fatal — an arg validation failure in the tool call loop is a caller mistake that can be
248
+ * surfaced as an error response. The tool handler is NOT called when this is thrown.
249
+ *
250
+ * @group Tools
251
+ */
252
+ var E_INVALID_TOOL_ARGS = createException("E_INVALID_TOOL_ARGS", "The arguments supplied to the tool failed input schema validation.", "E_INVALID_TOOL_ARGS", 422, false);
253
+ /**
254
+ * Thrown (as a rejection reason) when a {@link @nhtio/adk!Tool}'s handler throws during execution.
255
+ *
256
+ * @remarks
257
+ * Not fatal — a downstream tool failure is a recoverable runtime condition. The tool call loop
258
+ * catches this error specifically to report the failure back to the model rather than crashing
259
+ * the pipeline.
260
+ *
261
+ * @group Tools
262
+ */
263
+ var E_TOOL_DOWNSTREAM_ERROR = createException("E_TOOL_DOWNSTREAM_ERROR", "The tool handler threw an error during execution.", "E_TOOL_DOWNSTREAM_ERROR", 500, false);
264
+ /**
265
+ * Thrown when {@link @nhtio/adk!ToolRegistry.register} is called for a tool name that is already registered
266
+ * and `overwrite` is not `true`.
267
+ *
268
+ * @remarks
269
+ * Fatal — accidentally overwriting a registered tool indicates a programming error. Pass
270
+ * `overwrite: true` to replace an existing tool intentionally.
271
+ *
272
+ * @group Tools
273
+ */
274
+ var E_TOOL_ALREADY_REGISTERED = createException("E_TOOL_ALREADY_REGISTERED", "A tool with this name is already registered. Pass overwrite: true to replace it.", "E_TOOL_ALREADY_REGISTERED", 409, true);
275
+ /**
276
+ * Thrown when {@link @nhtio/adk!DispatchContext} is constructed with a value that fails schema validation.
277
+ *
278
+ * @remarks
279
+ * Fatal — bad construction arguments indicate a programming error in the caller.
280
+ *
281
+ * @group Dispatch
282
+ */
283
+ var E_INVALID_LLM_EXECUTION_CONTEXT = createException("E_INVALID_LLM_EXECUTION_CONTEXT", "The LLM execution context cannot be instantiated with the provided value.", "E_INVALID_LLM_EXECUTION_CONTEXT", 529, true);
284
+ /**
285
+ * Thrown (as a rejection reason) when {@link @nhtio/adk!DispatchContext.waitFor} is called on a
286
+ * standalone context that was constructed without a `waitFor` function.
287
+ *
288
+ * @remarks
289
+ * Not fatal — the caller can catch this and handle the case where gate suspension is not
290
+ * supported for this execution context.
291
+ *
292
+ * @group Dispatch
293
+ */
294
+ var E_LLM_EXECUTION_GATE_NOT_SUPPORTED = createException("E_LLM_EXECUTION_GATE_NOT_SUPPORTED", "waitFor was called on a standalone DispatchContext with no gate function provided.", "E_LLM_EXECUTION_GATE_NOT_SUPPORTED", 501, false);
295
+ /**
296
+ * Thrown when {@link @nhtio/adk!DispatchContext.ack} or {@link @nhtio/adk!DispatchContext.nack} is called on a
297
+ * context that has already been signalled.
298
+ *
299
+ * @remarks
300
+ * Fatal — signalling twice is a programming error in the caller. The first signal wins; the
301
+ * second call is rejected loudly so callers cannot accidentally race between ack and nack.
302
+ *
303
+ * @danger
304
+ * Signalling is **not** silently idempotent. The first `ack()` or `nack()` wins; the second
305
+ * throws immediately. Guard with `if (!ctx.isSignalled)` when more than one seam may signal.
306
+ *
307
+ * @group Dispatch
308
+ */
309
+ var E_LLM_EXECUTION_ALREADY_SIGNALLED = createException("E_LLM_EXECUTION_ALREADY_SIGNALLED", "ack() or nack() was called on an DispatchContext that has already been signalled.", "E_LLM_EXECUTION_ALREADY_SIGNALLED", 500, true);
310
+ /**
311
+ * Thrown when {@link @nhtio/adk!DispatchRunner.dispatch} receives an input that fails schema validation.
312
+ *
313
+ * @remarks
314
+ * Fatal — invalid dispatch input indicates a programming error in the caller.
315
+ *
316
+ * @group Dispatch
317
+ */
318
+ var E_INVALID_LLM_DISPATCH_INPUT = createException("E_INVALID_LLM_DISPATCH_INPUT", "The LLM execution runner received an invalid dispatch input.", "E_INVALID_LLM_DISPATCH_INPUT", 529, true);
319
+ /**
320
+ * Emitted (via the observability `error` hook) and re-thrown when a non-abort error propagates
321
+ * out of the input or output middleware pipeline during {@link @nhtio/adk!DispatchRunner.dispatch}.
322
+ *
323
+ * @remarks
324
+ * Not fatal — pipeline errors are recoverable runtime conditions. `dispatch()` rejects with this
325
+ * exception so callers can handle the failure via try/catch. Both `dispatchInputPipeline` and
326
+ * `dispatchOutputPipeline` share this one code — the runner does not split input vs. output at
327
+ * this layer.
328
+ *
329
+ * @group Pipelines
330
+ */
331
+ var E_DISPATCH_PIPELINE_ERROR = createException("E_DISPATCH_PIPELINE_ERROR", "An error occurred in an LLM execution pipeline.", "E_DISPATCH_PIPELINE_ERROR", 500, false);
332
+ /**
333
+ * Emitted (via the observability `error` hook) and re-thrown when the user-supplied executor
334
+ * callback throws during {@link @nhtio/adk!DispatchRunner.dispatch}.
335
+ *
336
+ * @remarks
337
+ * Not fatal — executor errors are recoverable runtime conditions. `dispatch()` rejects with this
338
+ * exception so callers can handle the failure via try/catch.
339
+ *
340
+ * @group Dispatch
341
+ */
342
+ var E_LLM_EXECUTION_EXECUTOR_ERROR = createException("E_LLM_EXECUTION_EXECUTOR_ERROR", "The LLM execution executor callback threw an error.", "E_LLM_EXECUTION_EXECUTOR_ERROR", 500, false);
343
+ //#endregion
344
+ export { E_NOT_A_SPOOL_READER as C, E_TOOL_DOWNSTREAM_ERROR as D, E_TOOL_ALREADY_REGISTERED as E, E_TURN_GATE_ABORTED as O, E_NOT_A_MEDIA_READER as S, E_PIPELINE_SHORT_CIRCUITED as T, E_INVALID_TURN_GATE_RESOLUTION as _, E_INVALID_INITIAL_MEMORY_VALUE as a, E_LLM_EXECUTION_EXECUTOR_ERROR as b, E_INVALID_INITIAL_RETRIEVABLE_VALUE as c, E_INVALID_INITIAL_TOOL_VALUE as d, E_INVALID_INITIAL_TURN_GATE_VALUE as f, E_INVALID_TURN_CONTEXT as g, E_INVALID_TOOL_ARGS as h, E_INVALID_INITIAL_MEDIA_VALUE as i, E_TURN_GATE_TIMEOUT as k, E_INVALID_INITIAL_THOUGHT_VALUE as l, E_INVALID_LLM_EXECUTION_CONTEXT as m, E_INPUT_PIPELINE_ERROR as n, E_INVALID_INITIAL_MESSAGE_VALUE as o, E_INVALID_LLM_DISPATCH_INPUT as p, E_INVALID_INITIAL_IDENTITY_VALUE as r, E_INVALID_INITIAL_REGISTRY_VALUE as s, E_DISPATCH_PIPELINE_ERROR as t, E_INVALID_INITIAL_TOOL_CALL_VALUE as u, E_INVALID_TURN_RUNNER_CONFIG as v, E_OUTPUT_PIPELINE_ERROR as w, E_LLM_EXECUTION_GATE_NOT_SUPPORTED as x, E_LLM_EXECUTION_ALREADY_SIGNALLED as y };
345
+
346
+ //# sourceMappingURL=runtime-CrEPIFgr.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-CrEPIFgr.mjs","names":[],"sources":["../src/lib/exceptions/runtime.ts"],"sourcesContent":["import { createException } from '../utils/exceptions'\n\n/**\n * Thrown by {@link @nhtio/adk!TurnRunner} when the supplied config object fails schema validation at\n * construction time.\n *\n * @remarks\n * Marked fatal — a misconfigured runner must not be allowed to execute turns.\n *\n * @group Turn Runner Construction\n */\nexport const E_INVALID_TURN_RUNNER_CONFIG = createException(\n 'E_INVALID_TURN_RUNNER_CONFIG',\n 'The turn runner cannot be instantiated with the provided configuration.',\n 'E_INVALID_TURN_RUNNER_CONFIG',\n 529,\n true\n)\n\n/**\n * Thrown by {@link @nhtio/adk!TurnRunner} when the {@link @nhtio/adk!TurnContext} supplied to `run` fails schema\n * validation.\n *\n * @remarks\n * Marked fatal — an invalid context indicates a programming error in the caller, not a\n * recoverable runtime condition. Thrown synchronously out of `run()` before `turnStart` is\n * emitted.\n *\n * @group Turn Input Validation\n */\nexport const E_INVALID_TURN_CONTEXT = createException(\n 'E_INVALID_TURN_CONTEXT',\n 'The turn runner received an invalid context object.',\n 'E_INVALID_TURN_CONTEXT',\n 529,\n true\n)\n\n/**\n * Emitted (via the `error` event) when a non-abort error propagates out of the input\n * middleware pipeline during {@link @nhtio/adk!TurnRunner.run}.\n *\n * @remarks\n * Not fatal — the turn runner emits this on the `error` event rather than throwing, so\n * registered listeners can handle or log the failure without crashing the pipeline. Dispatch\n * and output middleware are skipped; `turnEnd` still fires.\n *\n * @group Pipelines\n */\nexport const E_INPUT_PIPELINE_ERROR = createException(\n 'E_INPUT_PIPELINE_ERROR',\n 'An error occurred in the input pipeline.',\n 'E_INPUT_PIPELINE_ERROR',\n 500,\n false\n)\n\n/**\n * Emitted (via the `error` event) when a non-abort error propagates out of the output\n * middleware pipeline during {@link @nhtio/adk!TurnRunner.run}.\n *\n * @remarks\n * Not fatal — the turn runner emits this on the `error` event rather than throwing, so\n * registered listeners can handle or log the failure without crashing the pipeline. `turnEnd`\n * still fires.\n *\n * @group Pipelines\n */\nexport const E_OUTPUT_PIPELINE_ERROR = createException(\n 'E_OUTPUT_PIPELINE_ERROR',\n 'An error occurred in the output pipeline.',\n 'E_OUTPUT_PIPELINE_ERROR',\n 500,\n false\n)\n\n/**\n * Emitted (via the `error` event) when a middleware pipeline resolves without reaching its\n * terminal handler and without the turn being aborted. Indicates that some middleware\n * returned without calling `next` and without signalling a deliberate refusal via the turn's\n * abort controller.\n *\n * @remarks\n * Not fatal — the runner emits this on the `error` event so the failure is observable, then\n * proceeds to short-circuit the remainder of the turn the same way any other pipeline error\n * would. The constructor takes a single positional argument identifying the pipeline that\n * short-circuited: one of `'turn-input'`, `'turn-output'`, `'dispatch-input'`, or `'dispatch-output'`.\n *\n * Deliberate refusals should call `ctx.abort(reason)`, which sets the `'aborted'` outcome\n * instead of emitting this error.\n *\n * @warning\n * This is a **detection condition**, not a thrown exception. The runner constructs and emits\n * the code itself when it detects a missing `next()` on the unwind — nothing in user code\n * throws it. Upstream post-steps still run normally.\n *\n * @example\n * ```ts\n * throw new E_PIPELINE_SHORT_CIRCUITED(['turn-input'])\n * ```\n *\n * @group Pipelines\n */\nexport const E_PIPELINE_SHORT_CIRCUITED = createException<[string]>(\n 'E_PIPELINE_SHORT_CIRCUITED',\n \"The '%s' middleware pipeline short-circuited without calling next or aborting the turn.\",\n 'E_PIPELINE_SHORT_CIRCUITED',\n 500,\n false\n)\n\n/**\n * Thrown when a registry is initialised with a value that is defined but not a plain object.\n *\n * @remarks\n * Registries expect either `undefined` (empty start) or a plain object as their initial value.\n * Passing a primitive, array, class instance, or other non-object signals a programming error\n * in the caller.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_REGISTRY_VALUE = createException(\n 'E_INVALID_INITIAL_REGISTRY_VALUE',\n 'Attempted to initialize a registry with a defined non-object value.',\n 'E_INVALID_INITIAL_REGISTRY_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Memory} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Memory` requires all fields — `id`, `content`, `confidence`, `importance`, `createdAt`,\n * `updatedAt` — to be present and of the correct type. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_MEMORY_VALUE = createException(\n 'E_INVALID_INITIAL_MEMORY_VALUE',\n 'Attempted to initialize a memory with an invalid value.',\n 'E_INVALID_INITIAL_MEMORY_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Retrievable} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Retrievable` requires `id`, `content`, `trustTier`, `createdAt`, and `updatedAt` to be present\n * and of the correct type, and `trustTier` must be one of `'first-party'`, `'third-party-public'`,\n * or `'third-party-private'`. The `trustTier` decision must be made consciously by the retrieval\n * middleware at construction time — there is no default. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_RETRIEVABLE_VALUE = createException(\n 'E_INVALID_INITIAL_RETRIEVABLE_VALUE',\n 'Invalid initial value supplied to Retrievable constructor.',\n 'E_INVALID_INITIAL_RETRIEVABLE_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Message} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Message` requires `id`, `role` (`user` or `assistant`), `content`, `createdAt`, and\n * `updatedAt` to be present and of the correct type. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_MESSAGE_VALUE = createException(\n 'E_INVALID_INITIAL_MESSAGE_VALUE',\n 'Attempted to initialize a message with an invalid value.',\n 'E_INVALID_INITIAL_MESSAGE_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when an {@link @nhtio/adk!Identity} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Identity` requires both `identifier` (string or number) and `representation` (string or\n * {@link @nhtio/adk!Tokenizable}) to be present and of the correct type. Passing an incomplete or\n * incorrectly typed object signals a programming error in the caller.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_IDENTITY_VALUE = createException(\n 'E_INVALID_INITIAL_IDENTITY_VALUE',\n 'Attempted to initialize an identity with an invalid value.',\n 'E_INVALID_INITIAL_IDENTITY_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Thought} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Thought` requires `id`, `content`, `createdAt`, and `updatedAt` to be present and of the\n * correct type. Passing an incomplete or incorrectly typed object signals a programming error\n * in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_THOUGHT_VALUE = createException(\n 'E_INVALID_INITIAL_THOUGHT_VALUE',\n 'Attempted to initialize a thought with an invalid value.',\n 'E_INVALID_INITIAL_THOUGHT_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!TurnGate} is constructed with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Gates\n */\nexport const E_INVALID_INITIAL_TURN_GATE_VALUE = createException(\n 'E_INVALID_INITIAL_TURN_GATE_VALUE',\n 'Attempted to initialize a turn gate with an invalid value.',\n 'E_INVALID_INITIAL_TURN_GATE_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown synchronously in the caller's context when {@link @nhtio/adk!TurnGate.resolve} is called with a\n * value that fails the gate's schema.\n *\n * @remarks\n * Fatal — passing the wrong type to `resolve()` is a programming error. The internal promise is\n * NOT settled when this is thrown; the gate remains open.\n *\n * @group Gates\n */\nexport const E_INVALID_TURN_GATE_RESOLUTION = createException(\n 'E_INVALID_TURN_GATE_RESOLUTION',\n 'The value supplied to TurnGate.resolve() failed schema validation.',\n 'E_INVALID_TURN_GATE_RESOLUTION',\n 500,\n true\n)\n\n/**\n * Thrown (as a rejection reason) when a {@link @nhtio/adk!TurnGate} times out before being resolved.\n *\n * @remarks\n * Not fatal — a timeout is a recoverable runtime condition; the caller may retry or surface it\n * to the user.\n *\n * @warning\n * A timeout does **not** cancel the external event or clear any remote queue. The gate closes\n * locally, but whatever external system was expected to call `gate.resolve()` may still fire\n * later. Orphaned external state must be handled by the caller.\n *\n * @group Gates\n */\nexport const E_TURN_GATE_TIMEOUT = createException(\n 'E_TURN_GATE_TIMEOUT',\n 'The turn gate timed out before being resolved.',\n 'E_TURN_GATE_TIMEOUT',\n 408,\n false\n)\n\n/**\n * Thrown (as a rejection reason) when a {@link @nhtio/adk!TurnGate} is aborted — either because the turn's\n * `AbortSignal` fired or because {@link @nhtio/adk!TurnGate.abort} was called directly.\n *\n * @remarks\n * Not fatal — abort is an intentional cancellation, not an error in the caller.\n *\n * @group Gates\n */\nexport const E_TURN_GATE_ABORTED = createException(\n 'E_TURN_GATE_ABORTED',\n 'The turn gate was aborted before being resolved.',\n 'E_TURN_GATE_ABORTED',\n 499,\n false\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!SpooledArtifact} is constructed with a value that does not implement the\n * {@link @nhtio/adk!SpoolReader} interface.\n *\n * @remarks\n * Validated at construction time via {@link @nhtio/adk!implementsSpoolReader}. Passing anything that lacks\n * `line`, `byteLength`, or `lineCount` as callable functions signals a programming error in the\n * caller.\n *\n * @group Artifacts\n */\nexport const E_NOT_A_SPOOL_READER = createException(\n 'E_NOT_A_SPOOL_READER',\n 'The provided value does not implement the SpoolReader interface.',\n 'E_NOT_A_SPOOL_READER',\n 500,\n true\n)\n\n/**\n * Thrown when a Media is constructed with a value that does not implement the MediaReader\n * interface.\n *\n * @remarks\n * Validated at construction time. Passing anything that lacks `stream` or `byteLength` as\n * callable functions signals a programming error in the caller.\n *\n * @group Artifacts\n */\nexport const E_NOT_A_MEDIA_READER = createException(\n 'E_NOT_A_MEDIA_READER',\n 'The provided value does not implement the MediaReader interface.',\n 'E_NOT_A_MEDIA_READER',\n 500,\n true\n)\n\n/**\n * Thrown when a Media is initialised with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Artifacts\n */\nexport const E_INVALID_INITIAL_MEDIA_VALUE = createException(\n 'E_INVALID_INITIAL_MEDIA_VALUE',\n 'Attempted to initialize a media with an invalid value.',\n 'E_INVALID_INITIAL_MEDIA_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!ToolCall} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `ToolCall` requires `id`, `tool`, `args`, `checksum`, `isComplete`, `isError`, `createdAt`,\n * and `updatedAt` to be present and of the correct type. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_TOOL_CALL_VALUE = createException(\n 'E_INVALID_INITIAL_TOOL_CALL_VALUE',\n 'Attempted to initialize a tool call with an invalid value.',\n 'E_INVALID_INITIAL_TOOL_CALL_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Tool} is constructed with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Tools\n */\nexport const E_INVALID_INITIAL_TOOL_VALUE = createException(\n 'E_INVALID_INITIAL_TOOL_VALUE',\n 'Attempted to initialize a tool with an invalid value.',\n 'E_INVALID_INITIAL_TOOL_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown synchronously when {@link @nhtio/adk!Tool.validate} is called with arguments that fail the tool's\n * input schema.\n *\n * @remarks\n * Not fatal — an arg validation failure in the tool call loop is a caller mistake that can be\n * surfaced as an error response. The tool handler is NOT called when this is thrown.\n *\n * @group Tools\n */\nexport const E_INVALID_TOOL_ARGS = createException(\n 'E_INVALID_TOOL_ARGS',\n 'The arguments supplied to the tool failed input schema validation.',\n 'E_INVALID_TOOL_ARGS',\n 422,\n false\n)\n\n/**\n * Thrown (as a rejection reason) when a {@link @nhtio/adk!Tool}'s handler throws during execution.\n *\n * @remarks\n * Not fatal — a downstream tool failure is a recoverable runtime condition. The tool call loop\n * catches this error specifically to report the failure back to the model rather than crashing\n * the pipeline.\n *\n * @group Tools\n */\nexport const E_TOOL_DOWNSTREAM_ERROR = createException(\n 'E_TOOL_DOWNSTREAM_ERROR',\n 'The tool handler threw an error during execution.',\n 'E_TOOL_DOWNSTREAM_ERROR',\n 500,\n false\n)\n\n/**\n * Thrown when {@link @nhtio/adk!ToolRegistry.register} is called for a tool name that is already registered\n * and `overwrite` is not `true`.\n *\n * @remarks\n * Fatal — accidentally overwriting a registered tool indicates a programming error. Pass\n * `overwrite: true` to replace an existing tool intentionally.\n *\n * @group Tools\n */\nexport const E_TOOL_ALREADY_REGISTERED = createException(\n 'E_TOOL_ALREADY_REGISTERED',\n 'A tool with this name is already registered. Pass overwrite: true to replace it.',\n 'E_TOOL_ALREADY_REGISTERED',\n 409,\n true\n)\n\n/**\n * Thrown when {@link @nhtio/adk!DispatchContext} is constructed with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Dispatch\n */\nexport const E_INVALID_LLM_EXECUTION_CONTEXT = createException(\n 'E_INVALID_LLM_EXECUTION_CONTEXT',\n 'The LLM execution context cannot be instantiated with the provided value.',\n 'E_INVALID_LLM_EXECUTION_CONTEXT',\n 529,\n true\n)\n\n/**\n * Thrown (as a rejection reason) when {@link @nhtio/adk!DispatchContext.waitFor} is called on a\n * standalone context that was constructed without a `waitFor` function.\n *\n * @remarks\n * Not fatal — the caller can catch this and handle the case where gate suspension is not\n * supported for this execution context.\n *\n * @group Dispatch\n */\nexport const E_LLM_EXECUTION_GATE_NOT_SUPPORTED = createException(\n 'E_LLM_EXECUTION_GATE_NOT_SUPPORTED',\n 'waitFor was called on a standalone DispatchContext with no gate function provided.',\n 'E_LLM_EXECUTION_GATE_NOT_SUPPORTED',\n 501,\n false\n)\n\n/**\n * Thrown when {@link @nhtio/adk!DispatchContext.ack} or {@link @nhtio/adk!DispatchContext.nack} is called on a\n * context that has already been signalled.\n *\n * @remarks\n * Fatal — signalling twice is a programming error in the caller. The first signal wins; the\n * second call is rejected loudly so callers cannot accidentally race between ack and nack.\n *\n * @danger\n * Signalling is **not** silently idempotent. The first `ack()` or `nack()` wins; the second\n * throws immediately. Guard with `if (!ctx.isSignalled)` when more than one seam may signal.\n *\n * @group Dispatch\n */\nexport const E_LLM_EXECUTION_ALREADY_SIGNALLED = createException(\n 'E_LLM_EXECUTION_ALREADY_SIGNALLED',\n 'ack() or nack() was called on an DispatchContext that has already been signalled.',\n 'E_LLM_EXECUTION_ALREADY_SIGNALLED',\n 500,\n true\n)\n\n/**\n * Thrown when {@link @nhtio/adk!DispatchRunner.dispatch} receives an input that fails schema validation.\n *\n * @remarks\n * Fatal — invalid dispatch input indicates a programming error in the caller.\n *\n * @group Dispatch\n */\nexport const E_INVALID_LLM_DISPATCH_INPUT = createException(\n 'E_INVALID_LLM_DISPATCH_INPUT',\n 'The LLM execution runner received an invalid dispatch input.',\n 'E_INVALID_LLM_DISPATCH_INPUT',\n 529,\n true\n)\n\n/**\n * Emitted (via the observability `error` hook) and re-thrown when a non-abort error propagates\n * out of the input or output middleware pipeline during {@link @nhtio/adk!DispatchRunner.dispatch}.\n *\n * @remarks\n * Not fatal — pipeline errors are recoverable runtime conditions. `dispatch()` rejects with this\n * exception so callers can handle the failure via try/catch. Both `dispatchInputPipeline` and\n * `dispatchOutputPipeline` share this one code — the runner does not split input vs. output at\n * this layer.\n *\n * @group Pipelines\n */\nexport const E_DISPATCH_PIPELINE_ERROR = createException(\n 'E_DISPATCH_PIPELINE_ERROR',\n 'An error occurred in an LLM execution pipeline.',\n 'E_DISPATCH_PIPELINE_ERROR',\n 500,\n false\n)\n\n/**\n * Emitted (via the observability `error` hook) and re-thrown when the user-supplied executor\n * callback throws during {@link @nhtio/adk!DispatchRunner.dispatch}.\n *\n * @remarks\n * Not fatal — executor errors are recoverable runtime conditions. `dispatch()` rejects with this\n * exception so callers can handle the failure via try/catch.\n *\n * @group Dispatch\n */\nexport const E_LLM_EXECUTION_EXECUTOR_ERROR = createException(\n 'E_LLM_EXECUTION_EXECUTOR_ERROR',\n 'The LLM execution executor callback threw an error.',\n 'E_LLM_EXECUTION_EXECUTOR_ERROR',\n 500,\n false\n)\n"],"mappings":";;;;;;;;;;;AAWA,IAAa,+BAA+B,gBAC1C,gCACA,2EACA,gCACA,KACA,IACF;;;;;;;;;;;;AAaA,IAAa,yBAAyB,gBACpC,0BACA,uDACA,0BACA,KACA,IACF;;;;;;;;;;;;AAaA,IAAa,yBAAyB,gBACpC,0BACA,4CACA,0BACA,KACA,KACF;;;;;;;;;;;;AAaA,IAAa,0BAA0B,gBACrC,2BACA,6CACA,2BACA,KACA,KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAa,6BAA6B,gBACxC,8BACA,2FACA,8BACA,KACA,KACF;;;;;;;;;;;AAYA,IAAa,mCAAmC,gBAC9C,oCACA,uEACA,oCACA,KACA,IACF;;;;;;;;;;;AAYA,IAAa,iCAAiC,gBAC5C,kCACA,2DACA,kCACA,KACA,IACF;;;;;;;;;;;;;AAcA,IAAa,sCAAsC,gBACjD,uCACA,8DACA,uCACA,KACA,IACF;;;;;;;;;;;AAYA,IAAa,kCAAkC,gBAC7C,mCACA,4DACA,mCACA,KACA,IACF;;;;;;;;;;;AAYA,IAAa,mCAAmC,gBAC9C,oCACA,8DACA,oCACA,KACA,IACF;;;;;;;;;;;AAYA,IAAa,kCAAkC,gBAC7C,mCACA,4DACA,mCACA,KACA,IACF;;;;;;;;;AAUA,IAAa,oCAAoC,gBAC/C,qCACA,8DACA,qCACA,KACA,IACF;;;;;;;;;;;AAYA,IAAa,iCAAiC,gBAC5C,kCACA,sEACA,kCACA,KACA,IACF;;;;;;;;;;;;;;;AAgBA,IAAa,sBAAsB,gBACjC,uBACA,kDACA,uBACA,KACA,KACF;;;;;;;;;;AAWA,IAAa,sBAAsB,gBACjC,uBACA,oDACA,uBACA,KACA,KACF;;;;;;;;;;;;AAaA,IAAa,uBAAuB,gBAClC,wBACA,oEACA,wBACA,KACA,IACF;;;;;;;;;;;AAYA,IAAa,uBAAuB,gBAClC,wBACA,oEACA,wBACA,KACA,IACF;;;;;;;;;AAUA,IAAa,gCAAgC,gBAC3C,iCACA,0DACA,iCACA,KACA,IACF;;;;;;;;;;;AAYA,IAAa,oCAAoC,gBAC/C,qCACA,8DACA,qCACA,KACA,IACF;;;;;;;;;AAUA,IAAa,+BAA+B,gBAC1C,gCACA,yDACA,gCACA,KACA,IACF;;;;;;;;;;;AAYA,IAAa,sBAAsB,gBACjC,uBACA,sEACA,uBACA,KACA,KACF;;;;;;;;;;;AAYA,IAAa,0BAA0B,gBACrC,2BACA,qDACA,2BACA,KACA,KACF;;;;;;;;;;;AAYA,IAAa,4BAA4B,gBACvC,6BACA,oFACA,6BACA,KACA,IACF;;;;;;;;;AAUA,IAAa,kCAAkC,gBAC7C,mCACA,6EACA,mCACA,KACA,IACF;;;;;;;;;;;AAYA,IAAa,qCAAqC,gBAChD,sCACA,sFACA,sCACA,KACA,KACF;;;;;;;;;;;;;;;AAgBA,IAAa,oCAAoC,gBAC/C,qCACA,qFACA,qCACA,KACA,IACF;;;;;;;;;AAUA,IAAa,+BAA+B,gBAC1C,gCACA,gEACA,gCACA,KACA,IACF;;;;;;;;;;;;;AAcA,IAAa,4BAA4B,gBACvC,6BACA,mDACA,6BACA,KACA,KACF;;;;;;;;;;;AAYA,IAAa,iCAAiC,gBAC5C,kCACA,uDACA,kCACA,KACA,KACF"}
@@ -0,0 +1,109 @@
1
+ ---
2
+ name: adk-assembly
3
+ description: "Use when assembling, configuring, or reviewing an @nhtio/adk agent: TurnRunner wiring, executorCallback, LLM batteries, 25 storage callbacks, context hydration, tools, retrieval, memory, pipelines, events, RawTurnContext, ack/nack, or batteries vs BYO choices."
4
+ license: MIT
5
+ compatibility: "Requires TypeScript/JavaScript project using @nhtio/adk; examples assume Node 20+ or compatible browser/runtime."
6
+ metadata:
7
+ package: "@nhtio/adk"
8
+ version: "0.1.0-master-f0aa531d"
9
+ author: "Jak Giveon <jak@nht.io>"
10
+ copyright: "© 2025-present New Horizon Technology LTD"
11
+ ---
12
+
13
+ # ADK Assembly
14
+
15
+ Use this skill to help users build or review an `@nhtio/adk` assembly: the application-owned wiring around the ADK execution chassis.
16
+
17
+ ## Package Metadata
18
+
19
+ - Package: `@nhtio/adk`
20
+ - Version: `0.1.0-master-f0aa531d`
21
+ - License: MIT
22
+ - Author: Jak Giveon <jak@nht.io>
23
+ - Copyright: © 2025-present New Horizon Technology LTD
24
+ - Compatibility: Requires TypeScript/JavaScript project using `@nhtio/adk`; examples assume Node 20+ or compatible browser/runtime.
25
+
26
+ ADK does not ship a hidden default agent. Treat every assembly as explicit wiring of:
27
+
28
+ 1. Storage/context callbacks
29
+ 2. An executor callback or LLM battery
30
+ 3. Optional tools, retrieval, memory, and pipelines
31
+ 4. Functional and observability event listeners
32
+ 5. A `RawTurnContext` passed to `runner.run()`
33
+
34
+ ## First Integration Workflow
35
+
36
+ When the user asks to add ADK to a project or create their first agent, load [First integration workflow](./references/first-integration.md) before proposing files.
37
+
38
+ Prefer this order:
39
+
40
+ 1. Detect package manager, TypeScript setup, runtime, and existing `@nhtio/adk` dependency.
41
+ 2. Choose one executor path: mock executor for no-key local smoke test, OpenAI battery for a real Node/server model, WebLLM battery for browser-local execution, or BYO executor for custom providers.
42
+ 3. Scaffold the smallest explicit assembly: `noop-storage.ts`, `hydrate-messages.ts`, and an `agent.ts` or project-local equivalent.
43
+ 4. Run or provide the narrowest smoke command that proves a `message` event is observed and `turnEnd` fires.
44
+ 5. Upgrade one capability at a time: real persistence, tools, retrieval, memory, iteration guards, then telemetry.
45
+
46
+ Do not start with retrieval, memory, tools, production persistence, and a real model all at once unless the user explicitly asks for a full integration.
47
+
48
+ ## Assembly Procedure
49
+
50
+ 1. Identify the target runtime: Node, browser, worker, CLI, server, or test harness.
51
+ 2. Identify the executor path: first-party LLM battery or custom `DispatchExecutorFn`.
52
+ 3. Establish the storage baseline before anything else: all 25 callbacks must exist with correct arity.
53
+ 4. Add context hydration in `turnInputPipeline`; ADK does not auto-fetch messages, memories, tool calls, tools, retrievables, or standing instructions.
54
+ 5. Register tools intentionally: baseline tools in `tools`, dynamic tools by explicitly calling `ctx.fetchTools()` and registering them.
55
+ 6. Put retrieval and memory loading in `turnInputPipeline`; put memory extraction or analytics in `turnOutputPipeline` only when success-only behavior is acceptable.
56
+ 7. Add dispatch safeguards such as iteration caps in `dispatchInputPipeline`.
57
+ 8. Register functional listeners before `runner.run()` so streamed output is not missed.
58
+ 9. Keep observability listeners behavior-free; telemetry must not change agent results.
59
+ 10. Validate by typechecking or running the narrowest relevant tests/examples.
60
+
61
+ ## Decision Rules
62
+
63
+ - Use `OpenAIChatCompletionsAdapter` or `WebLLMChatCompletionsAdapter` when the user wants a ready executor.
64
+ - Write a custom `executorCallback` only when provider protocol, prompt rendering, retry policy, tool loop, or lifecycle behavior must differ from batteries.
65
+ - Use no-op storage callbacks only for prototypes/tests; never omit callbacks.
66
+ - Implement real `Message` and `ToolCall` persistence for conversational or tool-using agents.
67
+ - Use storage batteries only for `SpooledArtifact` bytes; they do not satisfy the 25 callback contract.
68
+ - Use `ctx.stash.get()` and `ctx.stash.set()`; do not treat `ctx.stash` as a plain object.
69
+ - Use public imports from `@nhtio/adk` and documented battery entrypoints; do not deep-import from internal `src` or `lib` paths.
70
+
71
+ ## Required References
72
+
73
+ Load the focused reference that matches the user's task:
74
+
75
+ - [First integration workflow](./references/first-integration.md) for adding ADK to a project, scaffolding a first runnable turn, or upgrading from mock executor to a real model.
76
+ - [Assembly contract](./references/assembly-contract.md) for the chassis model, minimal runner shape, and batteries-vs-BYO decisions.
77
+ - [Storage and context](./references/storage-and-context.md) for the 25 callbacks, callback arity, context hydration, memory, and retrieval.
78
+ - [Executors, tools, pipelines, and events](./references/executors-tools-pipelines-events.md) for `ack()`/`nack()`, tool execution, middleware placement, and event buses.
79
+
80
+ Use the canonical docs when the user needs complete examples, API-adjacent prose, or source-of-truth wording. `https://adk-c04022.gitlab.io` is a build-time placeholder and must be left unchanged in source:
81
+
82
+ - `https://adk-c04022.gitlab.io/llms.txt` — LLM-friendly documentation index.
83
+ - `https://adk-c04022.gitlab.io/llms-full.txt` — Full LLM-friendly documentation corpus.
84
+ - `https://adk-c04022.gitlab.io/api/index.md` — Generated API documentation index.
85
+ - `https://adk-c04022.gitlab.io/quickstart.md` — No-key three-file first turn with a mock executor.
86
+ - `https://adk-c04022.gitlab.io/assembly/` — Assembly overview.
87
+ - `https://adk-c04022.gitlab.io/assembly/minimal-assembly.md` — Minimal runnable assembly.
88
+ - `https://adk-c04022.gitlab.io/assembly/batteries-llm.md` — LLM batteries.
89
+ - `https://adk-c04022.gitlab.io/assembly/batteries-storage.md` — Storage batteries.
90
+ - `https://adk-c04022.gitlab.io/assembly/batteries-tools.md` — Tool batteries.
91
+ - `https://adk-c04022.gitlab.io/assembly/byo-llm.md` — Custom executor guidance.
92
+ - `https://adk-c04022.gitlab.io/assembly/byo-storage.md` — 25 callback storage contract.
93
+ - `https://adk-c04022.gitlab.io/assembly/byo-tools.md` — Custom tool definitions and registries.
94
+ - `https://adk-c04022.gitlab.io/assembly/byo-retrieval.md` — Retrieval and trust-tier guidance.
95
+ - `https://adk-c04022.gitlab.io/assembly/byo-memory.md` — Memory lifecycle guidance.
96
+ - `https://adk-c04022.gitlab.io/assembly/pipelines.md` — Pipeline placement rules.
97
+ - `https://adk-c04022.gitlab.io/assembly/events.md` — Functional and observability event buses.
98
+
99
+ ## Common Failure Checks
100
+
101
+ - Missing one of the 25 callbacks or using `async () => []` where ADK requires `(ctx) => []`.
102
+ - Forgetting that every executor invocation must call exactly one terminal signal: `ctx.ack()` on success or `ctx.nack(error)` on failure.
103
+ - Expecting `runner.run()` to return the assistant text; it returns `Promise<void>` and output comes through events.
104
+ - Forgetting `autoAck: true` when directly wiring an LLM battery for a simple one-shot turn.
105
+ - Putting primary model reasoning in middleware or event listeners instead of the executor.
106
+ - Loading no messages because `turnInputPipeline` never calls `ctx.fetchMessages()` and `.add()`s results into `ctx.turnMessages`.
107
+ - Doing turn-scoped work such as history, retrieval, memory, or standing-instruction hydration in dispatch pipelines; dispatch middleware runs once per executor iteration.
108
+ - Treating first-party, public third-party, and private/user-supplied retrievables as equivalent trust sources.
109
+ - Relying on `turnOutputPipeline` for cleanup that must run after failures.
@@ -0,0 +1,66 @@
1
+ # Assembly Contract
2
+
3
+ ADK is an execution chassis, not a pre-assembled agent. The library owns runners, loop mechanics, primitive validation, event buses, and callback contracts. The application owns model execution, persistence, prompt policy, retrieval, memory policy, tools, deployment, and observability.
4
+
5
+ ## Minimum Working Shape
6
+
7
+ A runnable turn needs:
8
+
9
+ 1. A `TurnRunner` configuration with all required storage/context callbacks.
10
+ 2. An `executorCallback` implementing `DispatchExecutorFn`, or a battery executor.
11
+ 3. Optional `tools`, `turnInputPipeline`, `turnOutputPipeline`, `dispatchInputPipeline`, and `dispatchOutputPipeline` arrays.
12
+ 4. Functional listeners registered before `runner.run()` if output should be streamed.
13
+ 5. A `RawTurnContext` with `turnAbortController`, `systemPrompt`, and `standingInstructions`.
14
+
15
+ `runner.run(rawCtx)` resolves to `Promise<void>`. It does not return assistant output.
16
+
17
+ ## Ownership Boundary
18
+
19
+ | Area | ADK owns | Application owns |
20
+ | --------- | --------------------------------------------- | ------------------------------------------------------- |
21
+ | Execution | `TurnRunner`, `DispatchRunner`, dispatch loop | `executorCallback`, model/provider calls, retry policy |
22
+ | State | primitive validation, context APIs | 25 callbacks, database writes, fetch policy |
23
+ | Logic | middleware structure, callback invocation | tools, retrieval, memory lifecycle, business rules |
24
+ | Context | typed primitive containers | prompt construction, history selection, context budgets |
25
+ | Events | functional and observability buses | UI streaming, telemetry sinks, tracing |
26
+
27
+ ## Batteries vs. Bring Your Own
28
+
29
+ Use batteries when the default behavior matches the product:
30
+
31
+ - `@nhtio/adk/batteries/llm/openai_chat_completions` for OpenAI-compatible Chat Completions endpoints.
32
+ - `@nhtio/adk/batteries/llm/webllm_chat_completions` for browser-local WebLLM execution.
33
+ - `@nhtio/adk/batteries` and category paths for prebuilt tool instances.
34
+ - `@nhtio/adk/batteries/storage/*` only for `SpooledArtifact` byte storage.
35
+
36
+ Bring your own implementation when you need different provider protocol, custom rendering, custom persistence, custom retrieval, custom memory policy, or product-specific tool behavior.
37
+
38
+ ## Minimal Assembly Checklist
39
+
40
+ - Import public API from `@nhtio/adk` and documented battery paths.
41
+ - Create or import a 25-callback storage adapter.
42
+ - Seed user messages through `fetchMessagesCallback`, not `RawTurnContext`.
43
+ - Add message hydration middleware to `turnInputPipeline`.
44
+ - Choose an executor and ensure it terminates with `ack()`/`nack()` or battery `autoAck`.
45
+ - Register `runner.on('message', ...)` before `runner.run()`.
46
+ - Pass `standingInstructions: []` explicitly when there are no standing instructions.
47
+
48
+ ## RawTurnContext Rules
49
+
50
+ `RawTurnContext` contains turn metadata, not conversation history:
51
+
52
+ - `turnAbortController`: required `AbortController`.
53
+ - `systemPrompt`: required string or tokenizable system behavior.
54
+ - `standingInstructions`: required by TypeScript; pass `[]` if empty.
55
+ - `stash`: optional turn-scoped metadata registry source.
56
+
57
+ Messages, memories, retrievables, thoughts, tool calls, and dynamic tools are loaded by callbacks that your own middleware or executor explicitly invokes.
58
+
59
+ ## Validation Strategy
60
+
61
+ Prefer the narrowest validation that exercises the changed assembly:
62
+
63
+ 1. Typecheck the files that import ADK APIs.
64
+ 2. Run relevant unit or smoke tests if present.
65
+ 3. For examples/docs, run only the relevant example unless the user asks for broader validation.
66
+ 4. Do not run docs builds while a VitePress docs dev server is active unless the user explicitly approves.