@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,72 @@
1
+ import { Tokenizable } from "./tokenizable";
2
+ import type { DateTime } from 'luxon';
3
+ /**
4
+ * Plain input object supplied to {@link Memory} at construction time.
5
+ *
6
+ * @remarks
7
+ * Validated against `rawMemorySchema` before the `Memory` instance is created.
8
+ * Temporal fields accept any value that Luxon can parse — ISO strings, Unix timestamps,
9
+ * `Date` objects, or existing `DateTime` instances.
10
+ */
11
+ export interface RawMemory {
12
+ /** Stable unique identifier for this memory entry. */
13
+ id: string;
14
+ /** The memory content as a plain string or an existing {@link @nhtio/adk!Tokenizable} instance. */
15
+ content: string | Tokenizable;
16
+ /** Confidence score in the range `[0, 1]` — how certain the agent is that this memory is accurate. */
17
+ confidence: number;
18
+ /** Importance score in the range `[0, 1]` — how much weight this memory should carry during retrieval. */
19
+ importance: number;
20
+ /** When this memory was first recorded. */
21
+ createdAt: string | number | Date | DateTime;
22
+ /** When this memory was last modified. */
23
+ updatedAt: string | number | Date | DateTime;
24
+ }
25
+ /**
26
+ * An immutable, validated memory entry held by the agent.
27
+ *
28
+ * @remarks
29
+ * Constructed from a {@link RawMemory} via `rawMemorySchema`. All temporal fields are
30
+ * normalised to Luxon `DateTime` instances at construction time. The `content` field is
31
+ * always a {@link @nhtio/adk!Tokenizable} so callers can estimate token cost without an additional
32
+ * wrapping step.
33
+ */
34
+ export declare class Memory {
35
+ #private;
36
+ /**
37
+ * Validator schema that accepts a {@link RawMemory} object.
38
+ *
39
+ * @remarks
40
+ * Reusable fragment for any schema that needs to validate or nest a memory entry — for
41
+ * example, a collection schema that holds an array of memories.
42
+ */
43
+ static schema: import("@nhtio/validation").ObjectSchema<RawMemory>;
44
+ /**
45
+ * Returns `true` if `value` is a {@link Memory} instance.
46
+ *
47
+ * @remarks
48
+ * Uses {@link @nhtio/adk!isInstanceOf} for cross-realm safety — `instanceof` would fail for instances
49
+ * created in a different module copy or VM context.
50
+ *
51
+ * @param value - The value to test.
52
+ * @returns `true` when `value` is a {@link Memory} instance.
53
+ */
54
+ static isMemory(value: unknown): value is Memory;
55
+ /** Stable unique identifier for this memory entry. */
56
+ readonly id: string;
57
+ /** The memory content as a {@link @nhtio/adk!Tokenizable} for inline token estimation. */
58
+ readonly content: Tokenizable;
59
+ /** Confidence score in the range `[0, 1]`. */
60
+ readonly confidence: number;
61
+ /** Importance score in the range `[0, 1]`. */
62
+ readonly importance: number;
63
+ /** When this memory was first recorded. */
64
+ readonly createdAt: DateTime;
65
+ /** When this memory was last modified. */
66
+ readonly updatedAt: DateTime;
67
+ /**
68
+ * @param raw - The raw memory input validated against `rawMemorySchema`.
69
+ * @throws {@link @nhtio/adk!E_INVALID_INITIAL_MEMORY_VALUE} when `raw` does not satisfy the schema.
70
+ */
71
+ constructor(raw: RawMemory);
72
+ }
@@ -0,0 +1,137 @@
1
+ import { Media } from "./media";
2
+ import { Identity } from "./identity";
3
+ import { Tokenizable } from "./tokenizable";
4
+ import type { DateTime } from 'luxon';
5
+ import type { RawIdentity } from "./identity";
6
+ /**
7
+ * The roles a {@link Message} author can hold.
8
+ *
9
+ * @remarks
10
+ * Restricted to `user` and `assistant` — system instructions, developer directives, and
11
+ * tool results are handled separately and never appear in the persisted message history.
12
+ */
13
+ export type MessageRole = 'user' | 'assistant';
14
+ /**
15
+ * Plain input object supplied to {@link Message} at construction time.
16
+ *
17
+ * @remarks
18
+ * Validated against `rawMessageSchema` before the `Message` instance is created.
19
+ * Temporal fields accept any value that Luxon can parse — ISO strings, Unix timestamps,
20
+ * `Date` objects, or existing `DateTime` instances.
21
+ *
22
+ * At least one of `content` or `attachments` (non-empty) must be present — a message with
23
+ * neither throws {@link @nhtio/adk!E_INVALID_INITIAL_MESSAGE_VALUE}.
24
+ */
25
+ export interface RawMessage {
26
+ /** Stable unique identifier for this message. */
27
+ id: string;
28
+ /** Whether this message is from the human participant or the model. */
29
+ role: MessageRole;
30
+ /**
31
+ * The message content as a plain string or an existing {@link @nhtio/adk!Tokenizable} instance.
32
+ *
33
+ * @remarks
34
+ * Optional — but required when `attachments` is absent or empty. The cross-field rule on
35
+ * `rawMessageSchema` enforces that at least one of `content` or `attachments` is present.
36
+ */
37
+ content?: string | Tokenizable;
38
+ /**
39
+ * Media attachments carried by this message — images, audio, video, documents.
40
+ *
41
+ * @remarks
42
+ * Optional and symmetric across roles: both `user` and `assistant` messages may carry
43
+ * attachments. Each attachment carries its own `trustTier` and `modalityHazard`, which the
44
+ * renderer uses to wrap the asset in its own trust envelope independent of the message
45
+ * envelope. How a renderer orders text vs attachments in the on-the-wire content array is
46
+ * a renderer-policy concern, not a contract of {@link Message}.
47
+ */
48
+ attachments?: Media[];
49
+ /**
50
+ * The identity of the participant who authored this message.
51
+ *
52
+ * @remarks
53
+ * Optional. When omitted, the `role` value is used as both the system-facing `identifier`
54
+ * and the model-facing `representation`. Three accepted forms when provided:
55
+ * - A plain `string` — used as both `identifier` and `representation`.
56
+ * - A {@link @nhtio/adk!RawIdentity} object — validated and wrapped into an {@link @nhtio/adk!Identity}.
57
+ * - An existing {@link @nhtio/adk!Identity} instance — passed through unchanged.
58
+ */
59
+ identity?: string | RawIdentity | Identity;
60
+ /** When this message was created. */
61
+ createdAt: string | number | Date | DateTime;
62
+ /** When this message was last modified. */
63
+ updatedAt: string | number | Date | DateTime;
64
+ }
65
+ /**
66
+ * An immutable, validated conversation message from a human participant or the model.
67
+ *
68
+ * @remarks
69
+ * Covers only `user` and `assistant` roles — system instructions, developer directives, and
70
+ * tool results are not represented here. Constructed from a {@link RawMessage} via
71
+ * `rawMessageSchema`. Temporal fields are normalised to Luxon `DateTime` instances at
72
+ * construction time. Both `content` and `identity.representation` are {@link @nhtio/adk!Tokenizable} so
73
+ * token cost can be estimated inline.
74
+ *
75
+ * A message may carry `content` (text), `attachments` (media), or both. The cross-field rule
76
+ * on `rawMessageSchema` enforces that at least one is present. Downstream code that reaches
77
+ * for `message.content` must handle the attachments-only case where `content` is `undefined`.
78
+ */
79
+ export declare class Message {
80
+ #private;
81
+ /**
82
+ * Validator schema that accepts a {@link RawMessage} object.
83
+ *
84
+ * @remarks
85
+ * Reusable fragment for any schema that needs to validate or nest a message entry — for
86
+ * example, a collection schema that holds an array of messages.
87
+ */
88
+ static schema: import("@nhtio/validation").ObjectSchema<RawMessage>;
89
+ /**
90
+ * Returns `true` if `value` is a {@link Message} instance.
91
+ *
92
+ * @remarks
93
+ * Uses {@link @nhtio/adk!isInstanceOf} for cross-realm safety — `instanceof` would fail for instances
94
+ * created in a different module copy or VM context.
95
+ *
96
+ * @param value - The value to test.
97
+ * @returns `true` when `value` is a {@link Message} instance.
98
+ */
99
+ static isMessage(value: unknown): value is Message;
100
+ /** Stable unique identifier for this message. */
101
+ readonly id: string;
102
+ /** Whether this message is from the human participant or the model. */
103
+ readonly role: MessageRole;
104
+ /**
105
+ * The message content as a {@link @nhtio/adk!Tokenizable} for inline token estimation, or `undefined`
106
+ * for attachments-only messages.
107
+ *
108
+ * @remarks
109
+ * `undefined` when the message was constructed with only `attachments`. Render code that
110
+ * needs the text portion must guard for the missing case rather than blindly calling
111
+ * `message.content.toString()`.
112
+ */
113
+ readonly content: Tokenizable | undefined;
114
+ /**
115
+ * Media attachments carried by this message.
116
+ *
117
+ * @remarks
118
+ * Always defined as a frozen array — empty when the message has no attachments. Both
119
+ * `user` and `assistant` messages may carry attachments. Each entry carries its own
120
+ * `trustTier` and `modalityHazard`; the renderer wraps each in its own trust envelope
121
+ * independent of the message envelope.
122
+ */
123
+ readonly attachments: ReadonlyArray<Media>;
124
+ /** The identity of the participant who authored this message. */
125
+ readonly identity: Identity;
126
+ /** When this message was created. */
127
+ readonly createdAt: DateTime;
128
+ /** When this message was last modified. */
129
+ readonly updatedAt: DateTime;
130
+ /**
131
+ * @param raw - The raw message input validated against `rawMessageSchema`.
132
+ * @throws {@link @nhtio/adk!E_INVALID_INITIAL_MESSAGE_VALUE} when `raw` does not satisfy the schema —
133
+ * including the cross-field rule that at least one of `content` or `attachments` must be
134
+ * present and non-empty.
135
+ */
136
+ constructor(raw: RawMessage);
137
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * A controlled-mutation key-value store with dot-path access and deep-clone isolation.
3
+ *
4
+ * @remarks
5
+ * The registry enforces a safe read/write contract: callers never hold a live reference into
6
+ * the internal store. Every value that enters (`set`) or leaves (`get`, `all`) is deep-cloned
7
+ * via `klona`, so mutations to a retrieved value cannot affect stored state and vice versa.
8
+ *
9
+ * Keys are dot-delimited paths (e.g. `"user.profile.name"`), resolved via `dlv` for reads and
10
+ * `dset` for writes; intermediate objects are created automatically on write.
11
+ */
12
+ export declare class Registry {
13
+ #private;
14
+ /**
15
+ * @param initial - Optional plain object to seed the registry. Deep-cloned on construction.
16
+ * @throws {@link @nhtio/adk!E_INVALID_INITIAL_REGISTRY_VALUE} when `initial` is defined but not a plain object.
17
+ */
18
+ constructor(initial?: Record<string, unknown>);
19
+ /**
20
+ * Returns `true` if `value` is a {@link Registry} instance.
21
+ *
22
+ * @remarks
23
+ * Uses {@link @nhtio/adk!isInstanceOf} for cross-realm safety.
24
+ *
25
+ * @param value - The value to test.
26
+ * @returns `true` when `value` is a {@link Registry} instance.
27
+ */
28
+ static isRegistry(value: unknown): value is Registry;
29
+ /**
30
+ * Retrieves the value at `key`, returning `defaultValue` if the path is absent.
31
+ *
32
+ * @remarks
33
+ * The returned value is a deep clone — mutating it will not affect the stored state.
34
+ *
35
+ * @typeParam T - Expected type of the value at `key`.
36
+ * @param key - Dot-delimited path into the store (e.g. `"user.name"`).
37
+ * @param defaultValue - Fallback returned when the path resolves to `undefined`.
38
+ * @returns A deep clone of the stored value cast to `T`, or `defaultValue` when the path is absent.
39
+ */
40
+ get<T = unknown>(key: string, defaultValue?: T): T;
41
+ /**
42
+ * Sets the value at `key`, creating intermediate objects as needed.
43
+ *
44
+ * @remarks
45
+ * The stored value is isolated from the caller — mutating `value` after this call will not
46
+ * affect what is held in the registry.
47
+ *
48
+ * @param key - Dot-delimited path into the store (e.g. `"user.name"`).
49
+ * @param value - Value to store at the path.
50
+ */
51
+ set(key: string, value: unknown): void;
52
+ /**
53
+ * Returns `true` if the registry has a value at `key`, `false` otherwise.
54
+ *
55
+ * @remarks
56
+ * A key resolving to `undefined` is treated as absent — same convention as {@link Registry.get}'s
57
+ * `defaultValue` fallback. No clone is performed; this is a pure existence check.
58
+ *
59
+ * @param key - Dot-delimited path into the store (e.g. `"user.name"`).
60
+ * @returns `true` when the path resolves to a value other than `undefined`.
61
+ */
62
+ has(key: string): boolean;
63
+ /**
64
+ * Returns all leaf dot-paths present in the registry.
65
+ *
66
+ * @remarks
67
+ * The store is deep-cloned before traversal. Plain objects are walked recursively with path
68
+ * segments joined by dots; arrays, primitives, `null`, and class instances are treated as leaves.
69
+ *
70
+ * @returns A string array of dot-delimited paths to leaf values in the store.
71
+ */
72
+ keys(): string[];
73
+ /**
74
+ * Returns a deep clone of the entire store contents.
75
+ *
76
+ * @returns A plain object snapshot of all stored key-value pairs.
77
+ */
78
+ all(): Record<string, unknown>;
79
+ }
@@ -0,0 +1,100 @@
1
+ import { Tokenizable } from "./tokenizable";
2
+ import type { DateTime } from 'luxon';
3
+ /**
4
+ * Trust-tier discriminator declared by the retrieval middleware at construction time. Drives
5
+ * which envelope the LLM battery wraps the record in.
6
+ *
7
+ * @remarks
8
+ * Vocabulary deliberately mirrors the published security-research taxonomy ("first-party /
9
+ * third-party" per *Hidden-in-Plain-Text* WWW '26 and *When AI Meets the Web* IEEE S&P 2026)
10
+ * and explicitly avoids the words "user" or "system" so the names cannot leak into the model's
11
+ * OpenAI-Model-Spec role-tier authority resolution.
12
+ *
13
+ * - `'first-party'` — deployer-vetted corpora (signed internal docs, policy KBs, curated
14
+ * reference material). Rendered as a `<retrieved_corpus>` parent with per-record nonce-keyed
15
+ * `<retrieved>` children. The label "first-party" never appears in the envelope itself.
16
+ * - `'third-party-public'` — open-web scrapes, search results, public APIs. Rendered through
17
+ * the untrusted-content envelope with `kind: 'retrieved-third-party-public'`.
18
+ * - `'third-party-private'` — user uploads, pasted attachments, partner APIs. Rendered through
19
+ * the untrusted-content envelope with `kind: 'retrieved-third-party-private'`.
20
+ */
21
+ export type RetrievableTrustTier = 'first-party' | 'third-party-public' | 'third-party-private';
22
+ /**
23
+ * Plain input object supplied to {@link Retrievable} at construction time.
24
+ *
25
+ * @remarks
26
+ * Validated against `rawRetrievableSchema` before the `Retrievable` instance is created.
27
+ * Temporal fields accept any value that Luxon can parse — ISO strings, Unix timestamps,
28
+ * `Date` objects, or existing `DateTime` instances.
29
+ */
30
+ export interface RawRetrievable {
31
+ /**
32
+ * Stable unique identifier for this retrieved record. Used as the closing-tag nonce in the
33
+ * rendered envelope, so it must be unguessable from the payload.
34
+ */
35
+ id: string;
36
+ /** The retrieved content as a plain string or an existing {@link @nhtio/adk!Tokenizable} instance. */
37
+ content: string | Tokenizable;
38
+ /**
39
+ * Trust tier declared by the retrieval middleware at construction time. Required — there is
40
+ * NO default. The decision must be conscious. See {@link RetrievableTrustTier}.
41
+ */
42
+ trustTier: RetrievableTrustTier;
43
+ /** Optional provenance string: URL, document path, knowledge-base id, etc. */
44
+ source?: string;
45
+ /** Optional semantic label: 'policy' | 'reference' | 'web-page' | 'pdf' | etc. */
46
+ kind?: string;
47
+ /** Optional relevance / similarity score in `[0, 1]` from the retrieval middleware. */
48
+ score?: number;
49
+ /** When the source record was created (publication date, upload date, etc.). */
50
+ createdAt: string | number | Date | DateTime;
51
+ /** When the source record was last modified. */
52
+ updatedAt: string | number | Date | DateTime;
53
+ }
54
+ /**
55
+ * An immutable, validated retrieved record (RAG content) held by the agent.
56
+ *
57
+ * @remarks
58
+ * Peer of {@link @nhtio/adk!Memory} / `Message` / `Thought` / `ToolCall`. Carries an explicit `trustTier`
59
+ * that LLM batteries branch on to choose the rendering envelope. The retrieval middleware that
60
+ * produced the record is the only party that knows its provenance — batteries MUST NOT
61
+ * auto-classify or infer the tier from `source`.
62
+ */
63
+ export declare class Retrievable {
64
+ #private;
65
+ /**
66
+ * Validator schema that accepts a {@link RawRetrievable} object.
67
+ *
68
+ * @remarks
69
+ * Reusable fragment for any schema that needs to validate or nest a retrievable record.
70
+ */
71
+ static schema: import("@nhtio/validation").ObjectSchema<RawRetrievable>;
72
+ /**
73
+ * Returns `true` if `value` is a {@link Retrievable} instance.
74
+ *
75
+ * @remarks
76
+ * Uses {@link @nhtio/adk!isInstanceOf} for cross-realm safety.
77
+ */
78
+ static isRetrievable(value: unknown): value is Retrievable;
79
+ /** Stable unique identifier for this retrieved record. */
80
+ readonly id: string;
81
+ /** The retrieved content as a {@link @nhtio/adk!Tokenizable} for inline token estimation. */
82
+ readonly content: Tokenizable;
83
+ /** Trust tier declared by the retrieval middleware. */
84
+ readonly trustTier: RetrievableTrustTier;
85
+ /** Optional provenance string. */
86
+ readonly source: string | undefined;
87
+ /** Optional semantic label. */
88
+ readonly kind: string | undefined;
89
+ /** Optional relevance / similarity score in `[0, 1]`. */
90
+ readonly score: number | undefined;
91
+ /** When the source record was created. */
92
+ readonly createdAt: DateTime;
93
+ /** When the source record was last modified. */
94
+ readonly updatedAt: DateTime;
95
+ /**
96
+ * @param raw - The raw retrievable input validated against `rawRetrievableSchema`.
97
+ * @throws {@link @nhtio/adk/exceptions!E_INVALID_INITIAL_RETRIEVABLE_VALUE} when `raw` does not satisfy the schema.
98
+ */
99
+ constructor(raw: RawRetrievable);
100
+ }