@nhtio/adk 0.1.0-master-445a9ed0 → 1.20260529.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/batteries/llm/openai_chat_completions/adapter.cjs +10 -9
  2. package/batteries/llm/openai_chat_completions/adapter.cjs.map +1 -1
  3. package/batteries/llm/openai_chat_completions/adapter.mjs +8 -8
  4. package/batteries/llm/openai_chat_completions/adapter.mjs.map +1 -1
  5. package/batteries/llm/openai_chat_completions/exceptions.cjs +1 -1
  6. package/batteries/llm/openai_chat_completions/helpers.cjs +16 -16
  7. package/batteries/llm/openai_chat_completions/helpers.cjs.map +1 -1
  8. package/batteries/llm/openai_chat_completions/helpers.d.ts +10 -10
  9. package/batteries/llm/openai_chat_completions/helpers.mjs +16 -16
  10. package/batteries/llm/openai_chat_completions/helpers.mjs.map +1 -1
  11. package/batteries/llm/openai_chat_completions/types.d.ts +6 -26
  12. package/batteries/llm/openai_chat_completions/validation.cjs +1 -3
  13. package/batteries/llm/openai_chat_completions/validation.cjs.map +1 -1
  14. package/batteries/llm/openai_chat_completions/validation.mjs +0 -2
  15. package/batteries/llm/openai_chat_completions/validation.mjs.map +1 -1
  16. package/batteries/llm/webllm_chat_completions/adapter.cjs +10 -9
  17. package/batteries/llm/webllm_chat_completions/adapter.cjs.map +1 -1
  18. package/batteries/llm/webllm_chat_completions/adapter.mjs +8 -8
  19. package/batteries/llm/webllm_chat_completions/adapter.mjs.map +1 -1
  20. package/batteries/llm/webllm_chat_completions/exceptions.cjs +1 -1
  21. package/batteries/llm/webllm_chat_completions/validation.cjs +1 -3
  22. package/batteries/llm/webllm_chat_completions/validation.cjs.map +1 -1
  23. package/batteries/llm/webllm_chat_completions/validation.mjs +0 -2
  24. package/batteries/llm/webllm_chat_completions/validation.mjs.map +1 -1
  25. package/batteries/storage/flydrive/index.d.ts +4 -10
  26. package/batteries/storage/flydrive.cjs +3 -12
  27. package/batteries/storage/flydrive.cjs.map +1 -1
  28. package/batteries/storage/flydrive.mjs +2 -11
  29. package/batteries/storage/flydrive.mjs.map +1 -1
  30. package/batteries/storage/in_memory/index.d.ts +17 -31
  31. package/batteries/storage/in_memory.cjs +30 -89
  32. package/batteries/storage/in_memory.cjs.map +1 -1
  33. package/batteries/storage/in_memory.mjs +30 -89
  34. package/batteries/storage/in_memory.mjs.map +1 -1
  35. package/batteries/storage/opfs/index.d.ts +4 -10
  36. package/batteries/storage/opfs.cjs +5 -55
  37. package/batteries/storage/opfs.cjs.map +1 -1
  38. package/batteries/storage/opfs.mjs +4 -54
  39. package/batteries/storage/opfs.mjs.map +1 -1
  40. package/batteries/tools/color.cjs +3 -3
  41. package/batteries/tools/color.mjs +2 -2
  42. package/batteries/tools/comparison.cjs +4 -3
  43. package/batteries/tools/comparison.cjs.map +1 -1
  44. package/batteries/tools/comparison.mjs +2 -2
  45. package/batteries/tools/data_structure.cjs +4 -3
  46. package/batteries/tools/data_structure.cjs.map +1 -1
  47. package/batteries/tools/data_structure.mjs +2 -2
  48. package/batteries/tools/datetime_extended.cjs +4 -4
  49. package/batteries/tools/datetime_extended.mjs +2 -2
  50. package/batteries/tools/datetime_math.cjs +3 -3
  51. package/batteries/tools/datetime_math.mjs +2 -2
  52. package/batteries/tools/encoding.cjs +4 -3
  53. package/batteries/tools/encoding.cjs.map +1 -1
  54. package/batteries/tools/encoding.mjs +2 -2
  55. package/batteries/tools/formatting.cjs +4 -3
  56. package/batteries/tools/formatting.cjs.map +1 -1
  57. package/batteries/tools/formatting.mjs +2 -2
  58. package/batteries/tools/geo_basics.cjs +3 -3
  59. package/batteries/tools/geo_basics.mjs +2 -2
  60. package/batteries/tools/math.cjs +4 -3
  61. package/batteries/tools/math.cjs.map +1 -1
  62. package/batteries/tools/math.mjs +2 -2
  63. package/batteries/tools/memory.cjs +7 -6
  64. package/batteries/tools/memory.cjs.map +1 -1
  65. package/batteries/tools/memory.mjs +5 -5
  66. package/batteries/tools/parsing.cjs +6 -5
  67. package/batteries/tools/parsing.cjs.map +1 -1
  68. package/batteries/tools/parsing.mjs +3 -3
  69. package/batteries/tools/retrievables.cjs +11 -11
  70. package/batteries/tools/retrievables.cjs.map +1 -1
  71. package/batteries/tools/retrievables.mjs +9 -10
  72. package/batteries/tools/retrievables.mjs.map +1 -1
  73. package/batteries/tools/standing_instructions.cjs +5 -4
  74. package/batteries/tools/standing_instructions.cjs.map +1 -1
  75. package/batteries/tools/standing_instructions.mjs +3 -3
  76. package/batteries/tools/statistics.cjs +5 -4
  77. package/batteries/tools/statistics.cjs.map +1 -1
  78. package/batteries/tools/statistics.mjs +3 -3
  79. package/batteries/tools/string_processing.cjs +4 -3
  80. package/batteries/tools/string_processing.cjs.map +1 -1
  81. package/batteries/tools/string_processing.mjs +2 -2
  82. package/batteries/tools/structured_data.cjs +4 -3
  83. package/batteries/tools/structured_data.cjs.map +1 -1
  84. package/batteries/tools/structured_data.mjs +2 -2
  85. package/batteries/tools/text_analysis.cjs +4 -4
  86. package/batteries/tools/text_analysis.mjs +3 -3
  87. package/batteries/tools/text_comparison.cjs +3 -3
  88. package/batteries/tools/text_comparison.mjs +2 -2
  89. package/batteries/tools/time.cjs +3 -3
  90. package/batteries/tools/time.mjs +2 -2
  91. package/batteries/tools/unit_conversion.cjs +3 -3
  92. package/batteries/tools/unit_conversion.mjs +2 -2
  93. package/batteries/tools.cjs +1 -1
  94. package/batteries/tools.mjs +1 -1
  95. package/batteries.cjs +1 -1
  96. package/batteries.mjs +1 -1
  97. package/chunk-KmRHZBOW.js +35 -0
  98. package/{common-aFmr9Oqs.mjs → common-DeZaonK1.mjs} +10 -76
  99. package/common-DeZaonK1.mjs.map +1 -0
  100. package/{common-BJ6V6dsH.js → common-Od8edUXU.js} +12 -89
  101. package/common-Od8edUXU.js.map +1 -0
  102. package/common.cjs +7 -9
  103. package/common.d.ts +0 -8
  104. package/common.mjs +7 -7
  105. package/{dispatch_runner-OimGCkk7.mjs → dispatch_runner-9j6bXHL3.mjs} +2 -34
  106. package/dispatch_runner-9j6bXHL3.mjs.map +1 -0
  107. package/{dispatch_runner-BWYNxmnp.js → dispatch_runner-CsoH0nld.js} +6 -37
  108. package/dispatch_runner-CsoH0nld.js.map +1 -0
  109. package/dispatch_runner.cjs +1 -1
  110. package/dispatch_runner.mjs +1 -1
  111. package/{exceptions-CSqzbL1N.js → exceptions-D5YrO9Vm.js} +2 -2
  112. package/{exceptions-CSqzbL1N.js.map → exceptions-D5YrO9Vm.js.map} +1 -1
  113. package/exceptions.cjs +2 -2
  114. package/factories.cjs +1 -1
  115. package/forge.cjs +4 -4
  116. package/forge.mjs +3 -3
  117. package/guards.cjs +9 -9
  118. package/guards.mjs +7 -7
  119. package/index.cjs +13 -13
  120. package/index.cjs.map +1 -1
  121. package/index.d.ts +1 -1
  122. package/index.mjs +10 -10
  123. package/index.mjs.map +1 -1
  124. package/lib/classes/retrievable.d.ts +4 -47
  125. package/lib/contracts/dispatch_context.d.ts +0 -44
  126. package/lib/contracts/turn_runner_config.d.ts +1 -5
  127. package/lib/contracts/turn_runner_context.d.ts +0 -25
  128. package/package.json +74 -74
  129. package/{runtime-BUDWyd-R.js → runtime-BJVkrGQe.js} +2 -2
  130. package/{runtime-BUDWyd-R.js.map → runtime-BJVkrGQe.js.map} +1 -1
  131. package/skills/adk-assembly/SKILL.md +2 -2
  132. package/{spooled_artifact-B_tVDDdB.mjs → spooled_artifact-C5ZtGxuJ.mjs} +2 -2
  133. package/{spooled_artifact-B_tVDDdB.mjs.map → spooled_artifact-C5ZtGxuJ.mjs.map} +1 -1
  134. package/{spooled_artifact-CFstzlqX.js → spooled_artifact-Cm9Te22K.js} +6 -5
  135. package/{spooled_artifact-CFstzlqX.js.map → spooled_artifact-Cm9Te22K.js.map} +1 -1
  136. package/spooled_artifact.cjs +2 -2
  137. package/spooled_artifact.mjs +2 -2
  138. package/{spooled_markdown_artifact-DWWak35I.mjs → spooled_markdown_artifact-BpUJol0W.mjs} +2 -2
  139. package/{spooled_markdown_artifact-DWWak35I.mjs.map → spooled_markdown_artifact-BpUJol0W.mjs.map} +1 -1
  140. package/{spooled_markdown_artifact-DK-T8Hy6.js → spooled_markdown_artifact-RRB113sy.js} +7 -6
  141. package/{spooled_markdown_artifact-DK-T8Hy6.js.map → spooled_markdown_artifact-RRB113sy.js.map} +1 -1
  142. package/{thought-DDqjQu3m.mjs → thought-CDb457b4.mjs} +2 -2
  143. package/{thought-DDqjQu3m.mjs.map → thought-CDb457b4.mjs.map} +1 -1
  144. package/{thought-DTsFRGdE.js → thought-DuN2PgdO.js} +6 -5
  145. package/{thought-DTsFRGdE.js.map → thought-DuN2PgdO.js.map} +1 -1
  146. package/{tool-cwJyEHI9.js → tool-COSeH8I6.js} +5 -4
  147. package/{tool-cwJyEHI9.js.map → tool-COSeH8I6.js.map} +1 -1
  148. package/{tool-q4LskG7K.mjs → tool-D2WB1EA1.mjs} +1 -1
  149. package/{tool-q4LskG7K.mjs.map → tool-D2WB1EA1.mjs.map} +1 -1
  150. package/{tool_call-BKIdAAoY.mjs → tool_call-BKyyxGaZ.mjs} +2 -2
  151. package/{tool_call-BKIdAAoY.mjs.map → tool_call-BKyyxGaZ.mjs.map} +1 -1
  152. package/{tool_call-3T0xTXlD.js → tool_call-DFgzcVcU.js} +6 -5
  153. package/{tool_call-3T0xTXlD.js.map → tool_call-DFgzcVcU.js.map} +1 -1
  154. package/{tool_registry-snPjF0zJ.js → tool_registry-Dkfprsck.js} +5 -39
  155. package/{tool_registry-snPjF0zJ.js.map → tool_registry-Dkfprsck.js.map} +1 -1
  156. package/{turn_runner-BScT8OgA.js → turn_runner-CMm2BHdX.js} +7 -10
  157. package/turn_runner-CMm2BHdX.js.map +1 -0
  158. package/{turn_runner-DRBLN2Y_.mjs → turn_runner-y7eyEcJH.mjs} +3 -7
  159. package/turn_runner-y7eyEcJH.mjs.map +1 -0
  160. package/turn_runner.cjs +1 -1
  161. package/turn_runner.mjs +1 -1
  162. package/types.d.ts +2 -2
  163. package/CHANGELOG.md +0 -49
  164. package/common-BJ6V6dsH.js.map +0 -1
  165. package/common-aFmr9Oqs.mjs.map +0 -1
  166. package/dispatch_runner-BWYNxmnp.js.map +0 -1
  167. package/dispatch_runner-OimGCkk7.mjs.map +0 -1
  168. package/lib/contracts/byte_store.d.ts +0 -93
  169. package/turn_runner-BScT8OgA.js.map +0 -1
  170. package/turn_runner-DRBLN2Y_.mjs.map +0 -1
@@ -1,11 +1,11 @@
1
- import { a as validateOrThrow, i as passesSchema } from "./exceptions-NrzIHw_R.mjs";
1
+ import { a as validateOrThrow } from "./exceptions-NrzIHw_R.mjs";
2
2
  import { a as Tokenizable, o as isError, s as isInstanceOf } from "./tool_registry-DqLOyGyG.mjs";
3
3
  import { c as E_INVALID_INITIAL_RETRIEVABLE_VALUE } from "./runtime-CrEPIFgr.mjs";
4
- import "./thought-DDqjQu3m.mjs";
5
- import "./tool-q4LskG7K.mjs";
6
- import { t as SpooledArtifact } from "./spooled_artifact-B_tVDDdB.mjs";
7
- import "./tool_call-BKIdAAoY.mjs";
8
- import "./spooled_markdown_artifact-DWWak35I.mjs";
4
+ import "./thought-CDb457b4.mjs";
5
+ import "./tool_call-BKyyxGaZ.mjs";
6
+ import "./tool-D2WB1EA1.mjs";
7
+ import "./spooled_artifact-C5ZtGxuJ.mjs";
8
+ import "./spooled_markdown_artifact-BpUJol0W.mjs";
9
9
  import { validator } from "@nhtio/validation";
10
10
  //#region src/lib/classes/retrievable.ts
11
11
  /**
@@ -24,13 +24,9 @@ import { validator } from "@nhtio/validation";
24
24
  * Throws {@link @nhtio/adk/exceptions!E_INVALID_INITIAL_RETRIEVABLE_VALUE} (via the {@link Retrievable} constructor)
25
25
  * when validation fails.
26
26
  */
27
- var contentSchema = validator.alternatives(validator.string(), validator.custom((value, helpers) => {
28
- if (Tokenizable.isTokenizable(value) || SpooledArtifact.isSpooledArtifact(value)) return value;
29
- return helpers.error("any.invalid");
30
- }));
31
27
  var rawRetrievableSchema = validator.object({
32
28
  id: validator.string().required(),
33
- content: contentSchema.required(),
29
+ content: Tokenizable.schema.required(),
34
30
  trustTier: validator.string().valid("first-party", "third-party-public", "third-party-private").required(),
35
31
  source: validator.string().optional(),
36
32
  kind: validator.string().optional(),
@@ -84,7 +80,7 @@ var Retrievable = class Retrievable {
84
80
  throw new E_INVALID_INITIAL_RETRIEVABLE_VALUE({ cause: isError(err) ? err : void 0 });
85
81
  }
86
82
  this.#id = resolved.id;
87
- this.#content = Tokenizable.isTokenizable(resolved.content) || SpooledArtifact.isSpooledArtifact(resolved.content) ? resolved.content : new Tokenizable(resolved.content);
83
+ this.#content = Tokenizable.isTokenizable(resolved.content) ? resolved.content : new Tokenizable(resolved.content);
88
84
  this.#trustTier = resolved.trustTier;
89
85
  this.#source = resolved.source;
90
86
  this.#kind = resolved.kind;
@@ -134,68 +130,6 @@ var Retrievable = class Retrievable {
134
130
  }
135
131
  });
136
132
  }
137
- /**
138
- * Estimates the token count of the content under `encoding`.
139
- *
140
- * @remarks
141
- * Delegates to the content's own `estimateTokens`: synchronous for a {@link @nhtio/adk!Tokenizable}
142
- * (returns `number`), asynchronous for a {@link @nhtio/adk!SpooledArtifact} (returns
143
- * `Promise<number>`, reading the bytes from the backing store on demand). Both shapes satisfy the
144
- * adapter's token-budget path, which already awaits estimates.
145
- *
146
- * Note: the `SpooledArtifact` branch materialises the full decoded string transiently to count
147
- * tokens — reader-backing keeps the body off the *permanent* heap, but does not eliminate the
148
- * transient allocation at budgeting time.
149
- *
150
- * @param encoding - The encoding identifier to use for counting.
151
- * @returns The estimated token count.
152
- */
153
- estimateTokens(encoding) {
154
- return this.#content.estimateTokens(encoding);
155
- }
156
- /**
157
- * Returns the content body as a single string.
158
- *
159
- * @remarks
160
- * For a {@link @nhtio/adk!Tokenizable} this is synchronous in effect (resolved immediately); for a
161
- * {@link @nhtio/adk!SpooledArtifact} it reads the full body from the backing store via
162
- * {@link @nhtio/adk!SpooledArtifact.asString}. Always returns a `Promise` so callers have one
163
- * code path; render helpers `await` it at the point the trust-tier envelope is built.
164
- *
165
- * @returns The full content body as a string.
166
- */
167
- async contentString() {
168
- return SpooledArtifact.isSpooledArtifact(this.#content) ? this.#content.asString() : this.#content.toString();
169
- }
170
- };
171
- //#endregion
172
- //#region src/lib/contracts/byte_store.ts
173
- /**
174
- * Validator schema used to validate a {@link ByteStore} value.
175
- *
176
- * @remarks
177
- * Because `ByteStore` is a structural interface with no associated constructor, validation is
178
- * duck-typed: the value must be non-null with `write`, `read`, and `delete` present as callable
179
- * properties. Arity is not enforced — implementations may add optional parameters beyond the
180
- * contract. The reader type `R` cannot be checked structurally here; conformance of the reader is
181
- * the caller's concern at the point of use.
182
- */
183
- var byteStoreSchema = validator.any().custom((value, helpers) => {
184
- if (value !== null && value !== void 0 && typeof value.write === "function" && typeof value.read === "function" && typeof value.delete === "function") return value;
185
- return helpers.error("any.invalid");
186
- });
187
- /**
188
- * Returns `true` if `value` implements the {@link ByteStore} interface.
189
- *
190
- * @remarks
191
- * Duck-typed: checks that `value` is non-null with `write`, `read`, and `delete` as callable
192
- * functions. Does not use `instanceof` — there is no `ByteStore` constructor.
193
- *
194
- * @param value - The value to test.
195
- * @returns `true` when `value` conforms to the {@link ByteStore} interface.
196
- */
197
- var implementsByteStore = (value) => {
198
- return passesSchema(byteStoreSchema, value);
199
133
  };
200
134
  //#endregion
201
135
  //#region src/lib/helpers/media_readers.ts
@@ -269,6 +203,6 @@ var fromWebFile = (file) => {
269
203
  };
270
204
  };
271
205
  //#endregion
272
- export { implementsByteStore as a, byteStoreSchema as i, fromWebFile as n, Retrievable as o, inMemoryMediaReader as r, fromFetch as t };
206
+ export { Retrievable as i, fromWebFile as n, inMemoryMediaReader as r, fromFetch as t };
273
207
 
274
- //# sourceMappingURL=common-aFmr9Oqs.mjs.map
208
+ //# sourceMappingURL=common-DeZaonK1.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common-DeZaonK1.mjs","names":["#id","#content","#trustTier","#source","#kind","#score","#createdAt","#updatedAt"],"sources":["../src/lib/classes/retrievable.ts","../src/lib/helpers/media_readers.ts"],"sourcesContent":["import { Tokenizable } from './tokenizable'\nimport { validator } from '@nhtio/validation'\nimport { validateOrThrow } from '../utils/validation'\nimport { isInstanceOf, isError } from '../utils/guards'\nimport { E_INVALID_INITIAL_RETRIEVABLE_VALUE } from '../exceptions/runtime'\nimport type { DateTime } from 'luxon'\n\n/**\n * Trust-tier discriminator declared by the retrieval middleware at construction time. Drives\n * which envelope the LLM battery wraps the record in.\n *\n * @remarks\n * Vocabulary deliberately mirrors the published security-research taxonomy (\"first-party /\n * third-party\" per *Hidden-in-Plain-Text* WWW '26 and *When AI Meets the Web* IEEE S&P 2026)\n * and explicitly avoids the words \"user\" or \"system\" so the names cannot leak into the model's\n * OpenAI-Model-Spec role-tier authority resolution.\n *\n * - `'first-party'` — deployer-vetted corpora (signed internal docs, policy KBs, curated\n * reference material). Rendered as a `<retrieved_corpus>` parent with per-record nonce-keyed\n * `<retrieved>` children. The label \"first-party\" never appears in the envelope itself.\n * - `'third-party-public'` — open-web scrapes, search results, public APIs. Rendered through\n * the untrusted-content envelope with `kind: 'retrieved-third-party-public'`.\n * - `'third-party-private'` — user uploads, pasted attachments, partner APIs. Rendered through\n * the untrusted-content envelope with `kind: 'retrieved-third-party-private'`.\n */\nexport type RetrievableTrustTier = 'first-party' | 'third-party-public' | 'third-party-private'\n\n/**\n * Plain input object supplied to {@link Retrievable} at construction time.\n *\n * @remarks\n * Validated against `rawRetrievableSchema` before the `Retrievable` instance is created.\n * Temporal fields accept any value that Luxon can parse — ISO strings, Unix timestamps,\n * `Date` objects, or existing `DateTime` instances.\n */\nexport interface RawRetrievable {\n /**\n * Stable unique identifier for this retrieved record. Used as the closing-tag nonce in the\n * rendered envelope, so it must be unguessable from the payload.\n */\n id: string\n /** The retrieved content as a plain string or an existing {@link @nhtio/adk!Tokenizable} instance. */\n content: string | Tokenizable\n /**\n * Trust tier declared by the retrieval middleware at construction time. Required — there is\n * NO default. The decision must be conscious. See {@link RetrievableTrustTier}.\n */\n trustTier: RetrievableTrustTier\n /** Optional provenance string: URL, document path, knowledge-base id, etc. */\n source?: string\n /** Optional semantic label: 'policy' | 'reference' | 'web-page' | 'pdf' | etc. */\n kind?: string\n /** Optional relevance / similarity score in `[0, 1]` from the retrieval middleware. */\n score?: number\n /** When the source record was created (publication date, upload date, etc.). */\n createdAt: string | number | Date | DateTime\n /** When the source record was last modified. */\n updatedAt: string | number | Date | DateTime\n}\n\n/**\n * A fully-resolved {@link RawRetrievable} where all fields have been validated and temporal\n * values normalised to Luxon `DateTime` instances.\n */\ninterface ResolvedRetrievable {\n id: string\n content: Tokenizable\n trustTier: RetrievableTrustTier\n source?: string\n kind?: string\n score?: number\n createdAt: DateTime\n updatedAt: DateTime\n}\n\n/**\n * Validator schema used to validate a {@link RawRetrievable} before constructing a\n * {@link Retrievable}.\n *\n * @remarks\n * - `id` — required non-empty string.\n * - `content` — required {@link @nhtio/adk!Tokenizable.schema}.\n * - `trustTier` — required, one of `'first-party'`, `'third-party-public'`,\n * `'third-party-private'`. Unknown / missing values reject.\n * - `source` / `kind` — optional strings.\n * - `score` — optional number in `[0, 1]`.\n * - `createdAt` / `updatedAt` — required datetime-parseable values.\n *\n * Throws {@link @nhtio/adk/exceptions!E_INVALID_INITIAL_RETRIEVABLE_VALUE} (via the {@link Retrievable} constructor)\n * when validation fails.\n */\nconst rawRetrievableSchema = validator.object<RawRetrievable>({\n id: validator.string().required(),\n content: Tokenizable.schema.required(),\n trustTier: validator\n .string()\n .valid('first-party', 'third-party-public', 'third-party-private')\n .required(),\n source: validator.string().optional(),\n kind: validator.string().optional(),\n score: validator.number().min(0).max(1).optional(),\n createdAt: validator.datetime().required(),\n updatedAt: validator.datetime().required(),\n})\n\n/**\n * An immutable, validated retrieved record (RAG content) held by the agent.\n *\n * @remarks\n * Peer of {@link @nhtio/adk!Memory} / `Message` / `Thought` / `ToolCall`. Carries an explicit `trustTier`\n * that LLM batteries branch on to choose the rendering envelope. The retrieval middleware that\n * produced the record is the only party that knows its provenance — batteries MUST NOT\n * auto-classify or infer the tier from `source`.\n */\nexport class Retrievable {\n /**\n * Validator schema that accepts a {@link RawRetrievable} object.\n *\n * @remarks\n * Reusable fragment for any schema that needs to validate or nest a retrievable record.\n */\n public static schema = rawRetrievableSchema\n\n /**\n * Returns `true` if `value` is a {@link Retrievable} instance.\n *\n * @remarks\n * Uses {@link @nhtio/adk!isInstanceOf} for cross-realm safety.\n */\n public static isRetrievable(value: unknown): value is Retrievable {\n return isInstanceOf(value, 'Retrievable', Retrievable)\n }\n\n /** Stable unique identifier for this retrieved record. */\n declare readonly id: string\n /** The retrieved content as a {@link @nhtio/adk!Tokenizable} for inline token estimation. */\n declare readonly content: Tokenizable\n /** Trust tier declared by the retrieval middleware. */\n declare readonly trustTier: RetrievableTrustTier\n /** Optional provenance string. */\n declare readonly source: string | undefined\n /** Optional semantic label. */\n declare readonly kind: string | undefined\n /** Optional relevance / similarity score in `[0, 1]`. */\n declare readonly score: number | undefined\n /** When the source record was created. */\n declare readonly createdAt: DateTime\n /** When the source record was last modified. */\n declare readonly updatedAt: DateTime\n\n #id: string\n #content: Tokenizable\n #trustTier: RetrievableTrustTier\n #source: string | undefined\n #kind: string | undefined\n #score: number | undefined\n #createdAt: DateTime\n #updatedAt: DateTime\n\n /**\n * @param raw - The raw retrievable input validated against `rawRetrievableSchema`.\n * @throws {@link @nhtio/adk/exceptions!E_INVALID_INITIAL_RETRIEVABLE_VALUE} when `raw` does not satisfy the schema.\n */\n constructor(raw: RawRetrievable) {\n let resolved: ResolvedRetrievable\n try {\n resolved = validateOrThrow<ResolvedRetrievable>(rawRetrievableSchema, raw, true)\n } catch (err) {\n throw new E_INVALID_INITIAL_RETRIEVABLE_VALUE({ cause: isError(err) ? err : undefined })\n }\n this.#id = resolved.id\n this.#content = Tokenizable.isTokenizable(resolved.content)\n ? resolved.content\n : new Tokenizable(resolved.content)\n this.#trustTier = resolved.trustTier\n this.#source = resolved.source\n this.#kind = resolved.kind\n this.#score = resolved.score\n this.#createdAt = resolved.createdAt\n this.#updatedAt = resolved.updatedAt\n\n Object.defineProperties(this, {\n id: {\n get: () => this.#id,\n enumerable: true,\n configurable: false,\n },\n content: {\n get: () => this.#content,\n enumerable: true,\n configurable: false,\n },\n trustTier: {\n get: () => this.#trustTier,\n enumerable: true,\n configurable: false,\n },\n source: {\n get: () => this.#source,\n enumerable: true,\n configurable: false,\n },\n kind: {\n get: () => this.#kind,\n enumerable: true,\n configurable: false,\n },\n score: {\n get: () => this.#score,\n enumerable: true,\n configurable: false,\n },\n createdAt: {\n get: () => this.#createdAt,\n enumerable: true,\n configurable: false,\n },\n updatedAt: {\n get: () => this.#updatedAt,\n enumerable: true,\n configurable: false,\n },\n })\n }\n}\n","import type { MediaReader } from '../contracts/media_reader'\n\n/**\n * Constructs a {@link @nhtio/adk!MediaReader} backed by an in-memory `Uint8Array`.\n *\n * @remarks\n * Each `stream()` call returns a fresh single-chunk `ReadableStream` over the same buffer. The\n * reader is re-openable by construction — call `stream()` as many times as needed.\n *\n * @param bytes - The buffer to serve.\n * @returns A {@link @nhtio/adk!MediaReader} that re-reads `bytes` on every call.\n */\nexport const inMemoryMediaReader = (bytes: Uint8Array): MediaReader => {\n return {\n stream(): ReadableStream<Uint8Array> {\n return new ReadableStream<Uint8Array>({\n start(controller) {\n controller.enqueue(bytes)\n controller.close()\n },\n })\n },\n byteLength(): number {\n return bytes.byteLength\n },\n }\n}\n\n/**\n * Constructs a {@link @nhtio/adk!MediaReader} backed by a fetch call.\n *\n * @remarks\n * Each `stream()` call re-issues the fetch. Tool authors whose underlying source is rate-limited\n * or expensive must cache locally before constructing the reader — the framework cannot make\n * that decision for them.\n *\n * `byteLength()` returns `undefined` because most remote sources do not promise it without an\n * extra HEAD request; consumers that need a byte size should resolve it out-of-band.\n *\n * @param url - The URL to fetch on each call.\n * @param init - Optional `fetch` init forwarded verbatim.\n * @returns A {@link @nhtio/adk!MediaReader} that re-issues `fetch(url, init)` on every call.\n */\nexport const fromFetch = (url: string | URL, init?: RequestInit): MediaReader => {\n return {\n async stream(): Promise<ReadableStream<Uint8Array>> {\n const response = await fetch(url, init)\n if (!response.ok) {\n throw new Error(`fromFetch: fetch failed with status ${response.status}`)\n }\n if (!response.body) {\n throw new Error('fromFetch: response has no body')\n }\n return response.body as ReadableStream<Uint8Array>\n },\n byteLength(): undefined {\n return undefined\n },\n }\n}\n\n/**\n * Constructs a {@link @nhtio/adk!MediaReader} backed by a browser `File` or `Blob`.\n *\n * @remarks\n * Each `stream()` call re-streams the underlying File via `File.stream()`. `byteLength()`\n * resolves from `file.size`.\n *\n * @param file - The browser `File` or `Blob` to stream.\n * @returns A {@link @nhtio/adk!MediaReader} that re-streams `file` on every call.\n */\nexport const fromWebFile = (file: Blob): MediaReader => {\n return {\n stream(): ReadableStream<Uint8Array> {\n return file.stream() as ReadableStream<Uint8Array>\n },\n byteLength(): number {\n return file.size\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,IAAM,uBAAuB,UAAU,OAAuB;CAC5D,IAAI,UAAU,OAAO,EAAE,SAAS;CAChC,SAAS,YAAY,OAAO,SAAS;CACrC,WAAW,UACR,OAAO,EACP,MAAM,eAAe,sBAAsB,qBAAqB,EAChE,SAAS;CACZ,QAAQ,UAAU,OAAO,EAAE,SAAS;CACpC,MAAM,UAAU,OAAO,EAAE,SAAS;CAClC,OAAO,UAAU,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS;CACjD,WAAW,UAAU,SAAS,EAAE,SAAS;CACzC,WAAW,UAAU,SAAS,EAAE,SAAS;AAC3C,CAAC;;;;;;;;;;AAWD,IAAa,cAAb,MAAa,YAAY;;;;;;;CAOvB,OAAc,SAAS;;;;;;;CAQvB,OAAc,cAAc,OAAsC;EAChE,OAAO,aAAa,OAAO,eAAe,WAAW;CACvD;CAmBA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;;;CAMA,YAA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,SAAoC;CAC/E,OAAO;EACL,MAAM,SAA8C;GAClD,MAAM,WAAW,MAAM,MAAM,KAAK,IAAI;GACtC,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MAAM,uCAAuC,SAAS,QAAQ;GAE1E,IAAI,CAAC,SAAS,MACZ,MAAM,IAAI,MAAM,iCAAiC;GAEnD,OAAO,SAAS;EAClB;EACA,aAAwB,CAExB;CACF;AACF;;;;;;;;;;;AAYA,IAAa,eAAe,SAA4B;CACtD,OAAO;EACL,SAAqC;GACnC,OAAO,KAAK,OAAO;EACrB;EACA,aAAqB;GACnB,OAAO,KAAK;EACd;CACF;AACF"}
@@ -1,11 +1,12 @@
1
- const require_tool_registry = require("./tool_registry-snPjF0zJ.js");
2
- const require_exceptions = require("./exceptions-CSqzbL1N.js");
3
- const require_runtime = require("./runtime-BUDWyd-R.js");
4
- require("./thought-DTsFRGdE.js");
5
- require("./tool-cwJyEHI9.js");
6
- const require_spooled_artifact = require("./spooled_artifact-CFstzlqX.js");
7
- require("./tool_call-3T0xTXlD.js");
8
- require("./spooled_markdown_artifact-DK-T8Hy6.js");
1
+ require("./chunk-KmRHZBOW.js");
2
+ const require_exceptions = require("./exceptions-D5YrO9Vm.js");
3
+ const require_tool_registry = require("./tool_registry-Dkfprsck.js");
4
+ const require_runtime = require("./runtime-BJVkrGQe.js");
5
+ require("./thought-DuN2PgdO.js");
6
+ require("./tool_call-DFgzcVcU.js");
7
+ require("./tool-COSeH8I6.js");
8
+ require("./spooled_artifact-Cm9Te22K.js");
9
+ require("./spooled_markdown_artifact-RRB113sy.js");
9
10
  let _nhtio_validation = require("@nhtio/validation");
10
11
  //#region src/lib/classes/retrievable.ts
11
12
  /**
@@ -24,13 +25,9 @@ let _nhtio_validation = require("@nhtio/validation");
24
25
  * Throws {@link @nhtio/adk/exceptions!E_INVALID_INITIAL_RETRIEVABLE_VALUE} (via the {@link Retrievable} constructor)
25
26
  * when validation fails.
26
27
  */
27
- var contentSchema = _nhtio_validation.validator.alternatives(_nhtio_validation.validator.string(), _nhtio_validation.validator.custom((value, helpers) => {
28
- if (require_tool_registry.Tokenizable.isTokenizable(value) || require_spooled_artifact.SpooledArtifact.isSpooledArtifact(value)) return value;
29
- return helpers.error("any.invalid");
30
- }));
31
28
  var rawRetrievableSchema = _nhtio_validation.validator.object({
32
29
  id: _nhtio_validation.validator.string().required(),
33
- content: contentSchema.required(),
30
+ content: require_tool_registry.Tokenizable.schema.required(),
34
31
  trustTier: _nhtio_validation.validator.string().valid("first-party", "third-party-public", "third-party-private").required(),
35
32
  source: _nhtio_validation.validator.string().optional(),
36
33
  kind: _nhtio_validation.validator.string().optional(),
@@ -84,7 +81,7 @@ var Retrievable = class Retrievable {
84
81
  throw new require_runtime.E_INVALID_INITIAL_RETRIEVABLE_VALUE({ cause: require_tool_registry.isError(err) ? err : void 0 });
85
82
  }
86
83
  this.#id = resolved.id;
87
- this.#content = require_tool_registry.Tokenizable.isTokenizable(resolved.content) || require_spooled_artifact.SpooledArtifact.isSpooledArtifact(resolved.content) ? resolved.content : new require_tool_registry.Tokenizable(resolved.content);
84
+ this.#content = require_tool_registry.Tokenizable.isTokenizable(resolved.content) ? resolved.content : new require_tool_registry.Tokenizable(resolved.content);
88
85
  this.#trustTier = resolved.trustTier;
89
86
  this.#source = resolved.source;
90
87
  this.#kind = resolved.kind;
@@ -134,68 +131,6 @@ var Retrievable = class Retrievable {
134
131
  }
135
132
  });
136
133
  }
137
- /**
138
- * Estimates the token count of the content under `encoding`.
139
- *
140
- * @remarks
141
- * Delegates to the content's own `estimateTokens`: synchronous for a {@link @nhtio/adk!Tokenizable}
142
- * (returns `number`), asynchronous for a {@link @nhtio/adk!SpooledArtifact} (returns
143
- * `Promise<number>`, reading the bytes from the backing store on demand). Both shapes satisfy the
144
- * adapter's token-budget path, which already awaits estimates.
145
- *
146
- * Note: the `SpooledArtifact` branch materialises the full decoded string transiently to count
147
- * tokens — reader-backing keeps the body off the *permanent* heap, but does not eliminate the
148
- * transient allocation at budgeting time.
149
- *
150
- * @param encoding - The encoding identifier to use for counting.
151
- * @returns The estimated token count.
152
- */
153
- estimateTokens(encoding) {
154
- return this.#content.estimateTokens(encoding);
155
- }
156
- /**
157
- * Returns the content body as a single string.
158
- *
159
- * @remarks
160
- * For a {@link @nhtio/adk!Tokenizable} this is synchronous in effect (resolved immediately); for a
161
- * {@link @nhtio/adk!SpooledArtifact} it reads the full body from the backing store via
162
- * {@link @nhtio/adk!SpooledArtifact.asString}. Always returns a `Promise` so callers have one
163
- * code path; render helpers `await` it at the point the trust-tier envelope is built.
164
- *
165
- * @returns The full content body as a string.
166
- */
167
- async contentString() {
168
- return require_spooled_artifact.SpooledArtifact.isSpooledArtifact(this.#content) ? this.#content.asString() : this.#content.toString();
169
- }
170
- };
171
- //#endregion
172
- //#region src/lib/contracts/byte_store.ts
173
- /**
174
- * Validator schema used to validate a {@link ByteStore} value.
175
- *
176
- * @remarks
177
- * Because `ByteStore` is a structural interface with no associated constructor, validation is
178
- * duck-typed: the value must be non-null with `write`, `read`, and `delete` present as callable
179
- * properties. Arity is not enforced — implementations may add optional parameters beyond the
180
- * contract. The reader type `R` cannot be checked structurally here; conformance of the reader is
181
- * the caller's concern at the point of use.
182
- */
183
- var byteStoreSchema = _nhtio_validation.validator.any().custom((value, helpers) => {
184
- if (value !== null && value !== void 0 && typeof value.write === "function" && typeof value.read === "function" && typeof value.delete === "function") return value;
185
- return helpers.error("any.invalid");
186
- });
187
- /**
188
- * Returns `true` if `value` implements the {@link ByteStore} interface.
189
- *
190
- * @remarks
191
- * Duck-typed: checks that `value` is non-null with `write`, `read`, and `delete` as callable
192
- * functions. Does not use `instanceof` — there is no `ByteStore` constructor.
193
- *
194
- * @param value - The value to test.
195
- * @returns `true` when `value` conforms to the {@link ByteStore} interface.
196
- */
197
- var implementsByteStore = (value) => {
198
- return require_exceptions.passesSchema(byteStoreSchema, value);
199
134
  };
200
135
  //#endregion
201
136
  //#region src/lib/helpers/media_readers.ts
@@ -275,12 +210,6 @@ Object.defineProperty(exports, "Retrievable", {
275
210
  return Retrievable;
276
211
  }
277
212
  });
278
- Object.defineProperty(exports, "byteStoreSchema", {
279
- enumerable: true,
280
- get: function() {
281
- return byteStoreSchema;
282
- }
283
- });
284
213
  Object.defineProperty(exports, "fromFetch", {
285
214
  enumerable: true,
286
215
  get: function() {
@@ -293,12 +222,6 @@ Object.defineProperty(exports, "fromWebFile", {
293
222
  return fromWebFile;
294
223
  }
295
224
  });
296
- Object.defineProperty(exports, "implementsByteStore", {
297
- enumerable: true,
298
- get: function() {
299
- return implementsByteStore;
300
- }
301
- });
302
225
  Object.defineProperty(exports, "inMemoryMediaReader", {
303
226
  enumerable: true,
304
227
  get: function() {
@@ -306,4 +229,4 @@ Object.defineProperty(exports, "inMemoryMediaReader", {
306
229
  }
307
230
  });
308
231
 
309
- //# sourceMappingURL=common-BJ6V6dsH.js.map
232
+ //# sourceMappingURL=common-Od8edUXU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common-Od8edUXU.js","names":["#id","#content","#trustTier","#source","#kind","#score","#createdAt","#updatedAt"],"sources":["../src/lib/classes/retrievable.ts","../src/lib/helpers/media_readers.ts"],"sourcesContent":["import { Tokenizable } from './tokenizable'\nimport { validator } from '@nhtio/validation'\nimport { validateOrThrow } from '../utils/validation'\nimport { isInstanceOf, isError } from '../utils/guards'\nimport { E_INVALID_INITIAL_RETRIEVABLE_VALUE } from '../exceptions/runtime'\nimport type { DateTime } from 'luxon'\n\n/**\n * Trust-tier discriminator declared by the retrieval middleware at construction time. Drives\n * which envelope the LLM battery wraps the record in.\n *\n * @remarks\n * Vocabulary deliberately mirrors the published security-research taxonomy (\"first-party /\n * third-party\" per *Hidden-in-Plain-Text* WWW '26 and *When AI Meets the Web* IEEE S&P 2026)\n * and explicitly avoids the words \"user\" or \"system\" so the names cannot leak into the model's\n * OpenAI-Model-Spec role-tier authority resolution.\n *\n * - `'first-party'` — deployer-vetted corpora (signed internal docs, policy KBs, curated\n * reference material). Rendered as a `<retrieved_corpus>` parent with per-record nonce-keyed\n * `<retrieved>` children. The label \"first-party\" never appears in the envelope itself.\n * - `'third-party-public'` — open-web scrapes, search results, public APIs. Rendered through\n * the untrusted-content envelope with `kind: 'retrieved-third-party-public'`.\n * - `'third-party-private'` — user uploads, pasted attachments, partner APIs. Rendered through\n * the untrusted-content envelope with `kind: 'retrieved-third-party-private'`.\n */\nexport type RetrievableTrustTier = 'first-party' | 'third-party-public' | 'third-party-private'\n\n/**\n * Plain input object supplied to {@link Retrievable} at construction time.\n *\n * @remarks\n * Validated against `rawRetrievableSchema` before the `Retrievable` instance is created.\n * Temporal fields accept any value that Luxon can parse — ISO strings, Unix timestamps,\n * `Date` objects, or existing `DateTime` instances.\n */\nexport interface RawRetrievable {\n /**\n * Stable unique identifier for this retrieved record. Used as the closing-tag nonce in the\n * rendered envelope, so it must be unguessable from the payload.\n */\n id: string\n /** The retrieved content as a plain string or an existing {@link @nhtio/adk!Tokenizable} instance. */\n content: string | Tokenizable\n /**\n * Trust tier declared by the retrieval middleware at construction time. Required — there is\n * NO default. The decision must be conscious. See {@link RetrievableTrustTier}.\n */\n trustTier: RetrievableTrustTier\n /** Optional provenance string: URL, document path, knowledge-base id, etc. */\n source?: string\n /** Optional semantic label: 'policy' | 'reference' | 'web-page' | 'pdf' | etc. */\n kind?: string\n /** Optional relevance / similarity score in `[0, 1]` from the retrieval middleware. */\n score?: number\n /** When the source record was created (publication date, upload date, etc.). */\n createdAt: string | number | Date | DateTime\n /** When the source record was last modified. */\n updatedAt: string | number | Date | DateTime\n}\n\n/**\n * A fully-resolved {@link RawRetrievable} where all fields have been validated and temporal\n * values normalised to Luxon `DateTime` instances.\n */\ninterface ResolvedRetrievable {\n id: string\n content: Tokenizable\n trustTier: RetrievableTrustTier\n source?: string\n kind?: string\n score?: number\n createdAt: DateTime\n updatedAt: DateTime\n}\n\n/**\n * Validator schema used to validate a {@link RawRetrievable} before constructing a\n * {@link Retrievable}.\n *\n * @remarks\n * - `id` — required non-empty string.\n * - `content` — required {@link @nhtio/adk!Tokenizable.schema}.\n * - `trustTier` — required, one of `'first-party'`, `'third-party-public'`,\n * `'third-party-private'`. Unknown / missing values reject.\n * - `source` / `kind` — optional strings.\n * - `score` — optional number in `[0, 1]`.\n * - `createdAt` / `updatedAt` — required datetime-parseable values.\n *\n * Throws {@link @nhtio/adk/exceptions!E_INVALID_INITIAL_RETRIEVABLE_VALUE} (via the {@link Retrievable} constructor)\n * when validation fails.\n */\nconst rawRetrievableSchema = validator.object<RawRetrievable>({\n id: validator.string().required(),\n content: Tokenizable.schema.required(),\n trustTier: validator\n .string()\n .valid('first-party', 'third-party-public', 'third-party-private')\n .required(),\n source: validator.string().optional(),\n kind: validator.string().optional(),\n score: validator.number().min(0).max(1).optional(),\n createdAt: validator.datetime().required(),\n updatedAt: validator.datetime().required(),\n})\n\n/**\n * An immutable, validated retrieved record (RAG content) held by the agent.\n *\n * @remarks\n * Peer of {@link @nhtio/adk!Memory} / `Message` / `Thought` / `ToolCall`. Carries an explicit `trustTier`\n * that LLM batteries branch on to choose the rendering envelope. The retrieval middleware that\n * produced the record is the only party that knows its provenance — batteries MUST NOT\n * auto-classify or infer the tier from `source`.\n */\nexport class Retrievable {\n /**\n * Validator schema that accepts a {@link RawRetrievable} object.\n *\n * @remarks\n * Reusable fragment for any schema that needs to validate or nest a retrievable record.\n */\n public static schema = rawRetrievableSchema\n\n /**\n * Returns `true` if `value` is a {@link Retrievable} instance.\n *\n * @remarks\n * Uses {@link @nhtio/adk!isInstanceOf} for cross-realm safety.\n */\n public static isRetrievable(value: unknown): value is Retrievable {\n return isInstanceOf(value, 'Retrievable', Retrievable)\n }\n\n /** Stable unique identifier for this retrieved record. */\n declare readonly id: string\n /** The retrieved content as a {@link @nhtio/adk!Tokenizable} for inline token estimation. */\n declare readonly content: Tokenizable\n /** Trust tier declared by the retrieval middleware. */\n declare readonly trustTier: RetrievableTrustTier\n /** Optional provenance string. */\n declare readonly source: string | undefined\n /** Optional semantic label. */\n declare readonly kind: string | undefined\n /** Optional relevance / similarity score in `[0, 1]`. */\n declare readonly score: number | undefined\n /** When the source record was created. */\n declare readonly createdAt: DateTime\n /** When the source record was last modified. */\n declare readonly updatedAt: DateTime\n\n #id: string\n #content: Tokenizable\n #trustTier: RetrievableTrustTier\n #source: string | undefined\n #kind: string | undefined\n #score: number | undefined\n #createdAt: DateTime\n #updatedAt: DateTime\n\n /**\n * @param raw - The raw retrievable input validated against `rawRetrievableSchema`.\n * @throws {@link @nhtio/adk/exceptions!E_INVALID_INITIAL_RETRIEVABLE_VALUE} when `raw` does not satisfy the schema.\n */\n constructor(raw: RawRetrievable) {\n let resolved: ResolvedRetrievable\n try {\n resolved = validateOrThrow<ResolvedRetrievable>(rawRetrievableSchema, raw, true)\n } catch (err) {\n throw new E_INVALID_INITIAL_RETRIEVABLE_VALUE({ cause: isError(err) ? err : undefined })\n }\n this.#id = resolved.id\n this.#content = Tokenizable.isTokenizable(resolved.content)\n ? resolved.content\n : new Tokenizable(resolved.content)\n this.#trustTier = resolved.trustTier\n this.#source = resolved.source\n this.#kind = resolved.kind\n this.#score = resolved.score\n this.#createdAt = resolved.createdAt\n this.#updatedAt = resolved.updatedAt\n\n Object.defineProperties(this, {\n id: {\n get: () => this.#id,\n enumerable: true,\n configurable: false,\n },\n content: {\n get: () => this.#content,\n enumerable: true,\n configurable: false,\n },\n trustTier: {\n get: () => this.#trustTier,\n enumerable: true,\n configurable: false,\n },\n source: {\n get: () => this.#source,\n enumerable: true,\n configurable: false,\n },\n kind: {\n get: () => this.#kind,\n enumerable: true,\n configurable: false,\n },\n score: {\n get: () => this.#score,\n enumerable: true,\n configurable: false,\n },\n createdAt: {\n get: () => this.#createdAt,\n enumerable: true,\n configurable: false,\n },\n updatedAt: {\n get: () => this.#updatedAt,\n enumerable: true,\n configurable: false,\n },\n })\n }\n}\n","import type { MediaReader } from '../contracts/media_reader'\n\n/**\n * Constructs a {@link @nhtio/adk!MediaReader} backed by an in-memory `Uint8Array`.\n *\n * @remarks\n * Each `stream()` call returns a fresh single-chunk `ReadableStream` over the same buffer. The\n * reader is re-openable by construction — call `stream()` as many times as needed.\n *\n * @param bytes - The buffer to serve.\n * @returns A {@link @nhtio/adk!MediaReader} that re-reads `bytes` on every call.\n */\nexport const inMemoryMediaReader = (bytes: Uint8Array): MediaReader => {\n return {\n stream(): ReadableStream<Uint8Array> {\n return new ReadableStream<Uint8Array>({\n start(controller) {\n controller.enqueue(bytes)\n controller.close()\n },\n })\n },\n byteLength(): number {\n return bytes.byteLength\n },\n }\n}\n\n/**\n * Constructs a {@link @nhtio/adk!MediaReader} backed by a fetch call.\n *\n * @remarks\n * Each `stream()` call re-issues the fetch. Tool authors whose underlying source is rate-limited\n * or expensive must cache locally before constructing the reader — the framework cannot make\n * that decision for them.\n *\n * `byteLength()` returns `undefined` because most remote sources do not promise it without an\n * extra HEAD request; consumers that need a byte size should resolve it out-of-band.\n *\n * @param url - The URL to fetch on each call.\n * @param init - Optional `fetch` init forwarded verbatim.\n * @returns A {@link @nhtio/adk!MediaReader} that re-issues `fetch(url, init)` on every call.\n */\nexport const fromFetch = (url: string | URL, init?: RequestInit): MediaReader => {\n return {\n async stream(): Promise<ReadableStream<Uint8Array>> {\n const response = await fetch(url, init)\n if (!response.ok) {\n throw new Error(`fromFetch: fetch failed with status ${response.status}`)\n }\n if (!response.body) {\n throw new Error('fromFetch: response has no body')\n }\n return response.body as ReadableStream<Uint8Array>\n },\n byteLength(): undefined {\n return undefined\n },\n }\n}\n\n/**\n * Constructs a {@link @nhtio/adk!MediaReader} backed by a browser `File` or `Blob`.\n *\n * @remarks\n * Each `stream()` call re-streams the underlying File via `File.stream()`. `byteLength()`\n * resolves from `file.size`.\n *\n * @param file - The browser `File` or `Blob` to stream.\n * @returns A {@link @nhtio/adk!MediaReader} that re-streams `file` on every call.\n */\nexport const fromWebFile = (file: Blob): MediaReader => {\n return {\n stream(): ReadableStream<Uint8Array> {\n return file.stream() as ReadableStream<Uint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Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_tool_registry = require("./tool_registry-snPjF0zJ.js");
3
- const require_thought = require("./thought-DTsFRGdE.js");
4
- const require_tool = require("./tool-cwJyEHI9.js");
5
- const require_spooled_artifact = require("./spooled_artifact-CFstzlqX.js");
6
- const require_common = require("./common-BJ6V6dsH.js");
7
- const require_tool_call = require("./tool_call-3T0xTXlD.js");
8
- const require_spooled_markdown_artifact = require("./spooled_markdown_artifact-DK-T8Hy6.js");
2
+ const require_tool_registry = require("./tool_registry-Dkfprsck.js");
3
+ const require_thought = require("./thought-DuN2PgdO.js");
4
+ const require_common = require("./common-Od8edUXU.js");
5
+ const require_tool_call = require("./tool_call-DFgzcVcU.js");
6
+ const require_tool = require("./tool-COSeH8I6.js");
7
+ const require_spooled_artifact = require("./spooled_artifact-Cm9Te22K.js");
8
+ const require_spooled_markdown_artifact = require("./spooled_markdown_artifact-RRB113sy.js");
9
9
  exports.ArtifactTool = require_spooled_artifact.ArtifactTool;
10
10
  exports.Identity = require_thought.Identity;
11
11
  exports.Media = require_tool_call.Media;
@@ -22,10 +22,8 @@ exports.Tokenizable = require_tool_registry.Tokenizable;
22
22
  exports.Tool = require_tool.Tool;
23
23
  exports.ToolCall = require_tool_call.ToolCall;
24
24
  exports.ToolRegistry = require_tool_registry.ToolRegistry;
25
- exports.byteStoreSchema = require_common.byteStoreSchema;
26
25
  exports.fromFetch = require_common.fromFetch;
27
26
  exports.fromWebFile = require_common.fromWebFile;
28
- exports.implementsByteStore = require_common.implementsByteStore;
29
27
  exports.implementsMediaReader = require_tool_call.implementsMediaReader;
30
28
  exports.implementsSpoolReader = require_spooled_artifact.implementsSpoolReader;
31
29
  exports.inMemoryMediaReader = require_common.inMemoryMediaReader;
package/common.d.ts CHANGED
@@ -82,14 +82,6 @@ export type { RawTurnGate } from "./lib/classes/turn_gate";
82
82
  export { SpooledArtifact } from "./lib/classes/spooled_artifact";
83
83
  export { implementsSpoolReader } from "./lib/contracts/spool_reader";
84
84
  export type { SpoolReader } from "./lib/contracts/spool_reader";
85
- /**
86
- * @primaryExport
87
- */
88
- export { implementsByteStore, byteStoreSchema } from "./lib/contracts/byte_store";
89
- /**
90
- * @primaryExport
91
- */
92
- export type { ByteStore, SpoolStore, MediaStore } from "./lib/contracts/byte_store";
93
85
  /**
94
86
  * @primaryExport
95
87
  */
package/common.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { a as Tokenizable, i as TokenEncoding, r as Registry, t as ToolRegistry } from "./tool_registry-DqLOyGyG.mjs";
2
- import { i as Identity, n as Message, r as Memory, t as Thought } from "./thought-DDqjQu3m.mjs";
3
- import { t as Tool } from "./tool-q4LskG7K.mjs";
4
- import { i as ArtifactTool, r as implementsSpoolReader, t as SpooledArtifact } from "./spooled_artifact-B_tVDDdB.mjs";
5
- import { a as implementsByteStore, i as byteStoreSchema, n as fromWebFile, o as Retrievable, r as inMemoryMediaReader, t as fromFetch } from "./common-aFmr9Oqs.mjs";
6
- import { a as mediaReaderSchema, i as implementsMediaReader, n as Media, r as isMedia, t as ToolCall } from "./tool_call-BKIdAAoY.mjs";
7
- import { n as SpooledJsonArtifact, t as SpooledMarkdownArtifact } from "./spooled_markdown_artifact-DWWak35I.mjs";
8
- export { ArtifactTool, Identity, Media, Memory, Message, Registry, Retrievable, SpooledArtifact, SpooledJsonArtifact, SpooledMarkdownArtifact, Thought, TokenEncoding, Tokenizable, Tool, ToolCall, ToolRegistry, byteStoreSchema, fromFetch, fromWebFile, implementsByteStore, implementsMediaReader, implementsSpoolReader, inMemoryMediaReader, isMedia, mediaReaderSchema };
2
+ import { i as Identity, n as Message, r as Memory, t as Thought } from "./thought-CDb457b4.mjs";
3
+ import { i as Retrievable, n as fromWebFile, r as inMemoryMediaReader, t as fromFetch } from "./common-DeZaonK1.mjs";
4
+ import { a as mediaReaderSchema, i as implementsMediaReader, n as Media, r as isMedia, t as ToolCall } from "./tool_call-BKyyxGaZ.mjs";
5
+ import { t as Tool } from "./tool-D2WB1EA1.mjs";
6
+ import { i as ArtifactTool, r as implementsSpoolReader, t as SpooledArtifact } from "./spooled_artifact-C5ZtGxuJ.mjs";
7
+ import { n as SpooledJsonArtifact, t as SpooledMarkdownArtifact } from "./spooled_markdown_artifact-BpUJol0W.mjs";
8
+ export { ArtifactTool, Identity, Media, Memory, Message, Registry, Retrievable, SpooledArtifact, SpooledJsonArtifact, SpooledMarkdownArtifact, Thought, TokenEncoding, Tokenizable, Tool, ToolCall, ToolRegistry, fromFetch, fromWebFile, implementsMediaReader, implementsSpoolReader, inMemoryMediaReader, isMedia, mediaReaderSchema };
@@ -2,9 +2,9 @@ import { a as validateOrThrow } from "./exceptions-NrzIHw_R.mjs";
2
2
  import { a as Tokenizable, n as canonicalStringify, o as isError, r as Registry, s as isInstanceOf, t as ToolRegistry } from "./tool_registry-DqLOyGyG.mjs";
3
3
  import { T as E_PIPELINE_SHORT_CIRCUITED, b as E_LLM_EXECUTION_EXECUTOR_ERROR, g as E_INVALID_TURN_CONTEXT, m as E_INVALID_LLM_EXECUTION_CONTEXT, p as E_INVALID_LLM_DISPATCH_INPUT, t as E_DISPATCH_PIPELINE_ERROR, x as E_LLM_EXECUTION_GATE_NOT_SUPPORTED, y as E_LLM_EXECUTION_ALREADY_SIGNALLED } from "./runtime-CrEPIFgr.mjs";
4
4
  import { validator } from "@nhtio/validation";
5
+ import { v6 } from "uuid";
5
6
  import { DateTime } from "luxon";
6
7
  import { sha256 } from "js-sha256";
7
- import { v6 } from "uuid";
8
8
  import { Hooks } from "@nhtio/hooks";
9
9
  import { Middleware } from "@nhtio/middleware";
10
10
  //#region src/lib/contracts/turn_runner_context.ts
@@ -298,18 +298,6 @@ var TurnContext = class TurnContext {
298
298
  configurable: false,
299
299
  writable: false
300
300
  },
301
- storeMediaBytes: {
302
- value: (id, bytes) => injected.storeMediaBytes(this, id, bytes),
303
- enumerable: true,
304
- configurable: false,
305
- writable: false
306
- },
307
- storeRetrievableBytes: {
308
- value: (id, bytes) => injected.storeRetrievableBytes(this, id, bytes),
309
- enumerable: true,
310
- configurable: false,
311
- writable: false
312
- },
313
301
  emitMessage: {
314
302
  value: injected.emitMessage,
315
303
  enumerable: true,
@@ -392,8 +380,6 @@ var rawDispatchContextSchema = validator.object({
392
380
  storeToolCall: validator.function().required(),
393
381
  mutateToolCall: validator.function().required(),
394
382
  deleteToolCall: validator.function().required(),
395
- storeMediaBytes: validator.function().required(),
396
- storeRetrievableBytes: validator.function().required(),
397
383
  hooks: validator.object().optional(),
398
384
  waitFor: validator.function().optional()
399
385
  });
@@ -458,8 +444,6 @@ var DispatchContext = class DispatchContext {
458
444
  #storeToolCall;
459
445
  #mutateToolCall;
460
446
  #deleteToolCall;
461
- #storeMediaBytes;
462
- #storeRetrievableBytes;
463
447
  #waitFor;
464
448
  #toolCallChecksums;
465
449
  #signalled;
@@ -518,8 +502,6 @@ var DispatchContext = class DispatchContext {
518
502
  this.#storeToolCall = resolved.storeToolCall;
519
503
  this.#mutateToolCall = resolved.mutateToolCall;
520
504
  this.#deleteToolCall = resolved.deleteToolCall;
521
- this.#storeMediaBytes = resolved.storeMediaBytes;
522
- this.#storeRetrievableBytes = resolved.storeRetrievableBytes;
523
505
  this.#waitFor = resolved.waitFor;
524
506
  this.#signalled = void 0;
525
507
  this.#nackError = void 0;
@@ -776,18 +758,6 @@ var DispatchContext = class DispatchContext {
776
758
  configurable: false,
777
759
  writable: false
778
760
  },
779
- storeMediaBytes: {
780
- value: (id, bytes) => this.#storeMediaBytes(this, id, bytes),
781
- enumerable: true,
782
- configurable: false,
783
- writable: false
784
- },
785
- storeRetrievableBytes: {
786
- value: (id, bytes) => this.#storeRetrievableBytes(this, id, bytes),
787
- enumerable: true,
788
- configurable: false,
789
- writable: false
790
- },
791
761
  emitMessage: {
792
762
  value: (content) => {
793
763
  this.#hooks.runner("message").run(content);
@@ -1216,8 +1186,6 @@ var DispatchRunner = class DispatchRunner {
1216
1186
  storeToolCall: (_c, v) => source.storeToolCall(v),
1217
1187
  mutateToolCall: (_c, v) => source.mutateToolCall(v),
1218
1188
  deleteToolCall: (_c, id) => source.deleteToolCall(id),
1219
- storeMediaBytes: (_c, id, bytes) => source.storeMediaBytes(id, bytes),
1220
- storeRetrievableBytes: (_c, id, bytes) => source.storeRetrievableBytes(id, bytes),
1221
1189
  waitFor: source.waitFor
1222
1190
  });
1223
1191
  }
@@ -1638,4 +1606,4 @@ var DispatchRunner = class DispatchRunner {
1638
1606
  //#endregion
1639
1607
  export { DispatchContext as n, TurnContext as r, DispatchRunner as t };
1640
1608
 
1641
- //# sourceMappingURL=dispatch_runner-OimGCkk7.mjs.map
1609
+ //# sourceMappingURL=dispatch_runner-9j6bXHL3.mjs.map