assistant-stream 0.3.15 → 0.3.17

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 (234) hide show
  1. package/README.md +6 -4
  2. package/dist/core/AssistantStream.d.ts +35 -31
  3. package/dist/core/AssistantStream.d.ts.map +1 -1
  4. package/dist/core/AssistantStream.js +39 -37
  5. package/dist/core/AssistantStream.js.map +1 -1
  6. package/dist/core/AssistantStreamChunk.d.ts +71 -78
  7. package/dist/core/AssistantStreamChunk.d.ts.map +1 -1
  8. package/dist/core/AssistantStreamChunk.js +0 -2
  9. package/dist/core/accumulators/AssistantMessageStream.d.ts +15 -11
  10. package/dist/core/accumulators/AssistantMessageStream.d.ts.map +1 -1
  11. package/dist/core/accumulators/AssistantMessageStream.js +52 -48
  12. package/dist/core/accumulators/AssistantMessageStream.js.map +1 -1
  13. package/dist/core/accumulators/TimingTracker.d.ts +15 -11
  14. package/dist/core/accumulators/TimingTracker.d.ts.map +1 -1
  15. package/dist/core/accumulators/TimingTracker.js +36 -43
  16. package/dist/core/accumulators/TimingTracker.js.map +1 -1
  17. package/dist/core/accumulators/assistant-message-accumulator.d.ts +21 -11
  18. package/dist/core/accumulators/assistant-message-accumulator.d.ts.map +1 -1
  19. package/dist/core/accumulators/assistant-message-accumulator.js +349 -390
  20. package/dist/core/accumulators/assistant-message-accumulator.js.map +1 -1
  21. package/dist/core/converters/toGenericMessages.d.ts +49 -47
  22. package/dist/core/converters/toGenericMessages.d.ts.map +1 -1
  23. package/dist/core/converters/toGenericMessages.js +122 -136
  24. package/dist/core/converters/toGenericMessages.js.map +1 -1
  25. package/dist/core/modules/assistant-stream.d.ts +62 -66
  26. package/dist/core/modules/assistant-stream.d.ts.map +1 -1
  27. package/dist/core/modules/assistant-stream.js +176 -182
  28. package/dist/core/modules/assistant-stream.js.map +1 -1
  29. package/dist/core/modules/text.d.ts +11 -7
  30. package/dist/core/modules/text.d.ts.map +1 -1
  31. package/dist/core/modules/text.js +45 -45
  32. package/dist/core/modules/text.js.map +1 -1
  33. package/dist/core/modules/tool-call.d.ts +15 -11
  34. package/dist/core/modules/tool-call.d.ts.map +1 -1
  35. package/dist/core/modules/tool-call.js +81 -96
  36. package/dist/core/modules/tool-call.js.map +1 -1
  37. package/dist/core/object/ObjectStreamAccumulator.d.ts +13 -9
  38. package/dist/core/object/ObjectStreamAccumulator.d.ts.map +1 -1
  39. package/dist/core/object/ObjectStreamAccumulator.js +44 -52
  40. package/dist/core/object/ObjectStreamAccumulator.js.map +1 -1
  41. package/dist/core/object/ObjectStreamResponse.d.ts +12 -8
  42. package/dist/core/object/ObjectStreamResponse.d.ts.map +1 -1
  43. package/dist/core/object/ObjectStreamResponse.js +52 -71
  44. package/dist/core/object/ObjectStreamResponse.js.map +1 -1
  45. package/dist/core/object/createObjectStream.d.ts +14 -8
  46. package/dist/core/object/createObjectStream.d.ts.map +1 -1
  47. package/dist/core/object/createObjectStream.js +50 -47
  48. package/dist/core/object/createObjectStream.js.map +1 -1
  49. package/dist/core/object/types.d.ts +14 -11
  50. package/dist/core/object/types.d.ts.map +1 -1
  51. package/dist/core/object/types.js +0 -2
  52. package/dist/core/serialization/PlainText.d.ts +11 -7
  53. package/dist/core/serialization/PlainText.d.ts.map +1 -1
  54. package/dist/core/serialization/PlainText.js +40 -48
  55. package/dist/core/serialization/PlainText.js.map +1 -1
  56. package/dist/core/serialization/assistant-transport/AssistantTransport.d.ts +11 -7
  57. package/dist/core/serialization/assistant-transport/AssistantTransport.d.ts.map +1 -1
  58. package/dist/core/serialization/assistant-transport/AssistantTransport.js +102 -117
  59. package/dist/core/serialization/assistant-transport/AssistantTransport.js.map +1 -1
  60. package/dist/core/serialization/data-stream/DataStream.d.ts +11 -7
  61. package/dist/core/serialization/data-stream/DataStream.d.ts.map +1 -1
  62. package/dist/core/serialization/data-stream/DataStream.js +320 -371
  63. package/dist/core/serialization/data-stream/DataStream.js.map +1 -1
  64. package/dist/core/serialization/data-stream/chunk-types.d.ts +101 -100
  65. package/dist/core/serialization/data-stream/chunk-types.d.ts.map +1 -1
  66. package/dist/core/serialization/data-stream/chunk-types.js +27 -23
  67. package/dist/core/serialization/data-stream/chunk-types.js.map +1 -1
  68. package/dist/core/serialization/data-stream/serialization.d.ts +9 -5
  69. package/dist/core/serialization/data-stream/serialization.d.ts.map +1 -1
  70. package/dist/core/serialization/data-stream/serialization.js +23 -24
  71. package/dist/core/serialization/data-stream/serialization.js.map +1 -1
  72. package/dist/core/serialization/ui-message-stream/UIMessageStream.d.ts +15 -12
  73. package/dist/core/serialization/ui-message-stream/UIMessageStream.d.ts.map +1 -1
  74. package/dist/core/serialization/ui-message-stream/UIMessageStream.js +205 -228
  75. package/dist/core/serialization/ui-message-stream/UIMessageStream.js.map +1 -1
  76. package/dist/core/serialization/ui-message-stream/chunk-types.d.ts +68 -65
  77. package/dist/core/serialization/ui-message-stream/chunk-types.d.ts.map +1 -1
  78. package/dist/core/serialization/ui-message-stream/chunk-types.js +0 -2
  79. package/dist/core/tool/ToolCallReader.d.ts +34 -30
  80. package/dist/core/tool/ToolCallReader.d.ts.map +1 -1
  81. package/dist/core/tool/ToolCallReader.js +264 -317
  82. package/dist/core/tool/ToolCallReader.js.map +1 -1
  83. package/dist/core/tool/ToolExecutionStream.d.ts +20 -17
  84. package/dist/core/tool/ToolExecutionStream.d.ts.map +1 -1
  85. package/dist/core/tool/ToolExecutionStream.js +123 -146
  86. package/dist/core/tool/ToolExecutionStream.js.map +1 -1
  87. package/dist/core/tool/ToolResponse.d.ts +41 -41
  88. package/dist/core/tool/ToolResponse.d.ts.map +1 -1
  89. package/dist/core/tool/ToolResponse.js +50 -56
  90. package/dist/core/tool/ToolResponse.js.map +1 -1
  91. package/dist/core/tool/schema-utils.d.ts +19 -15
  92. package/dist/core/tool/schema-utils.d.ts.map +1 -1
  93. package/dist/core/tool/schema-utils.js +50 -84
  94. package/dist/core/tool/schema-utils.js.map +1 -1
  95. package/dist/core/tool/tool-types.d.ts +103 -122
  96. package/dist/core/tool/tool-types.d.ts.map +1 -1
  97. package/dist/core/tool/tool-types.js +0 -2
  98. package/dist/core/tool/toolResultStream.d.ts +11 -9
  99. package/dist/core/tool/toolResultStream.d.ts.map +1 -1
  100. package/dist/core/tool/toolResultStream.js +127 -157
  101. package/dist/core/tool/toolResultStream.js.map +1 -1
  102. package/dist/core/tool/type-path-utils.d.ts +8 -19
  103. package/dist/core/tool/type-path-utils.d.ts.map +1 -1
  104. package/dist/core/tool/type-path-utils.js +0 -2
  105. package/dist/core/utils/Counter.d.ts +6 -3
  106. package/dist/core/utils/Counter.d.ts.map +1 -1
  107. package/dist/core/utils/Counter.js +10 -6
  108. package/dist/core/utils/Counter.js.map +1 -1
  109. package/dist/core/utils/generateId.d.ts +4 -1
  110. package/dist/core/utils/generateId.d.ts.map +1 -1
  111. package/dist/core/utils/generateId.js +5 -1
  112. package/dist/core/utils/generateId.js.map +1 -1
  113. package/dist/core/utils/stream/AssistantMetaTransformStream.d.ts +15 -11
  114. package/dist/core/utils/stream/AssistantMetaTransformStream.d.ts.map +1 -1
  115. package/dist/core/utils/stream/AssistantMetaTransformStream.js +38 -42
  116. package/dist/core/utils/stream/AssistantMetaTransformStream.js.map +1 -1
  117. package/dist/core/utils/stream/AssistantTransformStream.d.ts +11 -8
  118. package/dist/core/utils/stream/AssistantTransformStream.d.ts.map +1 -1
  119. package/dist/core/utils/stream/AssistantTransformStream.js +37 -35
  120. package/dist/core/utils/stream/AssistantTransformStream.js.map +1 -1
  121. package/dist/core/utils/stream/LineDecoderStream.d.ts +6 -3
  122. package/dist/core/utils/stream/LineDecoderStream.d.ts.map +1 -1
  123. package/dist/core/utils/stream/LineDecoderStream.js +23 -26
  124. package/dist/core/utils/stream/LineDecoderStream.js.map +1 -1
  125. package/dist/core/utils/stream/PipeableTransformStream.d.ts +5 -2
  126. package/dist/core/utils/stream/PipeableTransformStream.d.ts.map +1 -1
  127. package/dist/core/utils/stream/PipeableTransformStream.js +14 -10
  128. package/dist/core/utils/stream/PipeableTransformStream.js.map +1 -1
  129. package/dist/core/utils/stream/SSE.d.ts +10 -6
  130. package/dist/core/utils/stream/SSE.d.ts.map +1 -1
  131. package/dist/core/utils/stream/SSE.js +79 -91
  132. package/dist/core/utils/stream/SSE.js.map +1 -1
  133. package/dist/core/utils/stream/UnderlyingReadable.d.ts +7 -4
  134. package/dist/core/utils/stream/UnderlyingReadable.d.ts.map +1 -1
  135. package/dist/core/utils/stream/UnderlyingReadable.js +0 -2
  136. package/dist/core/utils/stream/merge.d.ts +11 -7
  137. package/dist/core/utils/stream/merge.d.ts.map +1 -1
  138. package/dist/core/utils/stream/merge.js +68 -170
  139. package/dist/core/utils/stream/merge.js.map +1 -1
  140. package/dist/core/utils/stream/path-utils.d.ts +11 -7
  141. package/dist/core/utils/stream/path-utils.d.ts.map +1 -1
  142. package/dist/core/utils/stream/path-utils.js +46 -52
  143. package/dist/core/utils/stream/path-utils.js.map +1 -1
  144. package/dist/core/utils/types.d.ts +109 -113
  145. package/dist/core/utils/types.d.ts.map +1 -1
  146. package/dist/core/utils/types.js +0 -2
  147. package/dist/core/utils/withPromiseOrValue.d.ts +4 -1
  148. package/dist/core/utils/withPromiseOrValue.d.ts.map +1 -1
  149. package/dist/core/utils/withPromiseOrValue.js +12 -15
  150. package/dist/core/utils/withPromiseOrValue.js.map +1 -1
  151. package/dist/index.d.ts +23 -24
  152. package/dist/index.js +16 -16
  153. package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts +141 -0
  154. package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts.map +1 -0
  155. package/dist/resumable/ResumableStreamContext.d.ts +28 -24
  156. package/dist/resumable/ResumableStreamContext.d.ts.map +1 -1
  157. package/dist/resumable/ResumableStreamContext.js +99 -114
  158. package/dist/resumable/ResumableStreamContext.js.map +1 -1
  159. package/dist/resumable/constants.d.ts +4 -1
  160. package/dist/resumable/constants.d.ts.map +1 -1
  161. package/dist/resumable/constants.js +5 -1
  162. package/dist/resumable/constants.js.map +1 -1
  163. package/dist/resumable/createResumableAssistantStreamResponse.d.ts +22 -21
  164. package/dist/resumable/createResumableAssistantStreamResponse.d.ts.map +1 -1
  165. package/dist/resumable/createResumableAssistantStreamResponse.js +25 -32
  166. package/dist/resumable/createResumableAssistantStreamResponse.js.map +1 -1
  167. package/dist/resumable/errors.d.ts +8 -5
  168. package/dist/resumable/errors.d.ts.map +1 -1
  169. package/dist/resumable/errors.js +14 -12
  170. package/dist/resumable/errors.js.map +1 -1
  171. package/dist/resumable/index.d.ts +7 -7
  172. package/dist/resumable/index.js +5 -5
  173. package/dist/resumable/stores/InMemoryResumableStreamStore.d.ts +14 -10
  174. package/dist/resumable/stores/InMemoryResumableStreamStore.d.ts.map +1 -1
  175. package/dist/resumable/stores/InMemoryResumableStreamStore.js +159 -193
  176. package/dist/resumable/stores/InMemoryResumableStreamStore.js.map +1 -1
  177. package/dist/resumable/stores/ioredis.d.ts +9 -5
  178. package/dist/resumable/stores/ioredis.d.ts.map +1 -1
  179. package/dist/resumable/stores/ioredis.js +70 -82
  180. package/dist/resumable/stores/ioredis.js.map +1 -1
  181. package/dist/resumable/stores/redis-impl.d.ts +51 -48
  182. package/dist/resumable/stores/redis-impl.d.ts.map +1 -1
  183. package/dist/resumable/stores/redis-impl.js +176 -176
  184. package/dist/resumable/stores/redis-impl.js.map +1 -1
  185. package/dist/resumable/stores/redis.d.ts +31 -28
  186. package/dist/resumable/stores/redis.d.ts.map +1 -1
  187. package/dist/resumable/stores/redis.js +87 -95
  188. package/dist/resumable/stores/redis.js.map +1 -1
  189. package/dist/resumable/types.d.ts +29 -26
  190. package/dist/resumable/types.d.ts.map +1 -1
  191. package/dist/resumable/types.js +0 -2
  192. package/dist/utils/AsyncIterableStream.d.ts +5 -2
  193. package/dist/utils/AsyncIterableStream.d.ts.map +1 -1
  194. package/dist/utils/AsyncIterableStream.js +17 -16
  195. package/dist/utils/AsyncIterableStream.js.map +1 -1
  196. package/dist/utils/json/fix-json.d.ts +4 -1
  197. package/dist/utils/json/fix-json.d.ts.map +1 -1
  198. package/dist/utils/json/fix-json.js +286 -380
  199. package/dist/utils/json/fix-json.js.map +1 -1
  200. package/dist/utils/json/is-json.d.ts +8 -4
  201. package/dist/utils/json/is-json.d.ts.map +1 -1
  202. package/dist/utils/json/is-json.js +13 -21
  203. package/dist/utils/json/is-json.js.map +1 -1
  204. package/dist/utils/json/json-value.d.ts +7 -4
  205. package/dist/utils/json/json-value.d.ts.map +1 -1
  206. package/dist/utils/json/json-value.js +0 -2
  207. package/dist/utils/json/parse-partial-json-object.d.ts +11 -8
  208. package/dist/utils/json/parse-partial-json-object.d.ts.map +1 -1
  209. package/dist/utils/json/parse-partial-json-object.js +50 -62
  210. package/dist/utils/json/parse-partial-json-object.js.map +1 -1
  211. package/dist/utils/promiseWithResolvers.d.ts +7 -4
  212. package/dist/utils/promiseWithResolvers.d.ts.map +1 -1
  213. package/dist/utils/promiseWithResolvers.js +17 -10
  214. package/dist/utils/promiseWithResolvers.js.map +1 -1
  215. package/dist/utils.d.ts +6 -6
  216. package/dist/utils.js +5 -5
  217. package/package.json +3 -3
  218. package/src/core/modules/assistant-stream.test.ts +104 -0
  219. package/src/core/modules/assistant-stream.ts +13 -4
  220. package/dist/core/AssistantStreamChunk.js.map +0 -1
  221. package/dist/core/object/types.js.map +0 -1
  222. package/dist/core/serialization/ui-message-stream/chunk-types.js.map +0 -1
  223. package/dist/core/tool/tool-types.js.map +0 -1
  224. package/dist/core/tool/type-path-utils.js.map +0 -1
  225. package/dist/core/utils/stream/UnderlyingReadable.js.map +0 -1
  226. package/dist/core/utils/types.js.map +0 -1
  227. package/dist/index.d.ts.map +0 -1
  228. package/dist/index.js.map +0 -1
  229. package/dist/resumable/index.d.ts.map +0 -1
  230. package/dist/resumable/index.js.map +0 -1
  231. package/dist/resumable/types.js.map +0 -1
  232. package/dist/utils/json/json-value.js.map +0 -1
  233. package/dist/utils.d.ts.map +0 -1
  234. package/dist/utils.js.map +0 -1
@@ -1,25 +1,22 @@
1
- import type { JSONSchema7 } from "json-schema";
2
- import type { DeepPartial, TypeAtPath, TypePath } from "./type-path-utils.js";
3
- import type { AsyncIterableStream } from "../../utils.js";
4
- import type { StandardSchemaV1 } from "@standard-schema/spec";
5
- import type { ToolResponse } from "./ToolResponse.js";
6
- export type ToolModelContentPart = {
7
- /** A text content part returned to the model after a tool call. */
8
- readonly type: "text";
9
- /** Text that should be included in the model-visible tool result. */
10
- readonly text: string;
1
+ import { AsyncIterableStream } from "../../utils/AsyncIterableStream.js";
2
+ import { JSONSchema7 } from "../../node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.js";
3
+ import { DeepPartial, TypeAtPath, TypePath } from "./type-path-utils.js";
4
+ import { ToolResponse } from "./ToolResponse.js";
5
+ import { StandardSchemaV1 } from "@standard-schema/spec";
6
+
7
+ //#region src/core/tool/tool-types.d.ts
8
+ type ToolModelContentPart = {
9
+ /** A text content part returned to the model after a tool call. */readonly type: "text"; /** Text that should be included in the model-visible tool result. */
10
+ readonly text: string;
11
11
  } | {
12
- /** A file content part returned to the model after a tool call. */
13
- readonly type: "file";
14
- /**
15
- * File payload encoded as a provider-compatible string, commonly base64
16
- * for binary data.
17
- */
18
- readonly data: string;
19
- /** MIME type for the file payload. */
20
- readonly mediaType: string;
21
- /** Optional display filename for the file payload. */
22
- readonly filename?: string;
12
+ /** A file content part returned to the model after a tool call. */readonly type: "file";
13
+ /**
14
+ * File payload encoded as a provider-compatible string, commonly base64
15
+ * for binary data.
16
+ */
17
+ readonly data: string; /** MIME type for the file payload. */
18
+ readonly mediaType: string; /** Optional display filename for the file payload. */
19
+ readonly filename?: string;
23
20
  };
24
21
  /**
25
22
  * Converts a tool's runtime result into content that is sent back to the
@@ -46,13 +43,10 @@ export type ToolModelContentPart = {
46
43
  * ];
47
44
  * ```
48
45
  */
49
- export type ToolModelOutputFunction<TArgs, TResult> = (options: {
50
- /** Stable identifier for the tool call being converted. */
51
- toolCallId: string;
52
- /** Arguments supplied by the model for this tool call. */
53
- input: TArgs;
54
- /** Value returned by the tool's {@link ToolExecuteFunction}. */
55
- output: TResult;
46
+ type ToolModelOutputFunction<TArgs, TResult> = (options: {
47
+ /** Stable identifier for the tool call being converted. */toolCallId: string; /** Arguments supplied by the model for this tool call. */
48
+ input: TArgs; /** Value returned by the tool's {@link ToolExecuteFunction}. */
49
+ output: TResult;
56
50
  }) => readonly ToolModelContentPart[] | Promise<readonly ToolModelContentPart[]>;
57
51
  /**
58
52
  * Interface for reading tool call arguments from a stream, which are
@@ -62,111 +56,97 @@ export type ToolModelOutputFunction<TArgs, TResult> = (options: {
62
56
  *
63
57
  * @template TArgs The type of arguments being read.
64
58
  */
65
- export interface ToolCallArgsReader<TArgs extends Record<string, unknown>> {
66
- /**
67
- * Returns a promise that will resolve to the value at the given path,
68
- * as soon as that path is generated by the LLM.
69
- *
70
- * @param fieldPath An array of object keys or array indices.
71
- */
72
- get<PathT extends TypePath<TArgs>>(...fieldPath: PathT): Promise<TypeAtPath<TArgs, PathT>>;
73
- /**
74
- * Returns a stream that will emit partial values at the given path,
75
- * as they are generated by the LLM.
76
- *
77
- * @param fieldPath An array of object keys or array indices.
78
- */
79
- streamValues<PathT extends TypePath<TArgs>>(...fieldPath: PathT): AsyncIterableStream<DeepPartial<TypeAtPath<TArgs, PathT>>>;
80
- /**
81
- * Returns a stream that will emit partial text at the given path,
82
- * as they are generated by the LLM.
83
- *
84
- * @param fieldPath An array of object keys or array indices.
85
- */
86
- streamText<PathT extends TypePath<TArgs>>(...fieldPath: PathT): TypeAtPath<TArgs, PathT> extends string & infer U ? AsyncIterableStream<U> : never;
87
- /**
88
- * Returns a stream that will emit complete items in the array
89
- * at the given path, as they are generated by the LLM.
90
- *
91
- * @param fieldPath An array of object keys or array indices.
92
- */
93
- forEach<PathT extends TypePath<TArgs>>(...fieldPath: PathT): TypeAtPath<TArgs, PathT> extends Array<infer U> ? AsyncIterableStream<U> : never;
59
+ interface ToolCallArgsReader<TArgs extends Record<string, unknown>> {
60
+ /**
61
+ * Returns a promise that will resolve to the value at the given path,
62
+ * as soon as that path is generated by the LLM.
63
+ *
64
+ * @param fieldPath An array of object keys or array indices.
65
+ */
66
+ get<PathT extends TypePath<TArgs>>(...fieldPath: PathT): Promise<TypeAtPath<TArgs, PathT>>;
67
+ /**
68
+ * Returns a stream that will emit partial values at the given path,
69
+ * as they are generated by the LLM.
70
+ *
71
+ * @param fieldPath An array of object keys or array indices.
72
+ */
73
+ streamValues<PathT extends TypePath<TArgs>>(...fieldPath: PathT): AsyncIterableStream<DeepPartial<TypeAtPath<TArgs, PathT>>>;
74
+ /**
75
+ * Returns a stream that will emit partial text at the given path,
76
+ * as they are generated by the LLM.
77
+ *
78
+ * @param fieldPath An array of object keys or array indices.
79
+ */
80
+ streamText<PathT extends TypePath<TArgs>>(...fieldPath: PathT): TypeAtPath<TArgs, PathT> extends string & infer U ? AsyncIterableStream<U> : never;
81
+ /**
82
+ * Returns a stream that will emit complete items in the array
83
+ * at the given path, as they are generated by the LLM.
84
+ *
85
+ * @param fieldPath An array of object keys or array indices.
86
+ */
87
+ forEach<PathT extends TypePath<TArgs>>(...fieldPath: PathT): TypeAtPath<TArgs, PathT> extends Array<infer U> ? AsyncIterableStream<U> : never;
94
88
  }
95
- export interface ToolCallResponseReader<TResult> {
96
- get: () => Promise<ToolResponse<TResult>>;
89
+ interface ToolCallResponseReader<TResult> {
90
+ get: () => Promise<ToolResponse<TResult>>;
97
91
  }
98
- export interface ToolCallReader<TArgs extends Record<string, unknown> = Record<string, unknown>, TResult = unknown> {
99
- args: ToolCallArgsReader<TArgs>;
100
- response: ToolCallResponseReader<TResult>;
101
- /**
102
- * @deprecated Use {@link ToolCallReader.response} and read
103
- * `response.get().result` instead.
104
- */
105
- result: {
106
- get: () => Promise<TResult>;
107
- };
92
+ interface ToolCallReader<TArgs extends Record<string, unknown> = Record<string, unknown>, TResult = unknown> {
93
+ args: ToolCallArgsReader<TArgs>;
94
+ response: ToolCallResponseReader<TResult>;
95
+ /**
96
+ * @deprecated Use {@link ToolCallReader.response} and read
97
+ * `response.get().result` instead.
98
+ */
99
+ result: {
100
+ get: () => Promise<TResult>;
101
+ };
108
102
  }
109
- export type ToolExecutionContext = {
110
- /** Stable identifier for the tool call being executed. */
111
- toolCallId: string;
112
- /** Signal that is aborted when the current run is cancelled. */
113
- abortSignal: AbortSignal;
114
- /**
115
- * From inside a frontend tool's execute function, request human input from
116
- * the UI. Resolves with the payload the UI supplies.
117
- */
118
- human: (payload: unknown) => Promise<unknown>;
103
+ type ToolExecutionContext = {
104
+ /** Stable identifier for the tool call being executed. */toolCallId: string; /** Signal that is aborted when the current run is cancelled. */
105
+ abortSignal: AbortSignal;
106
+ /**
107
+ * From inside a frontend tool's execute function, request human input from
108
+ * the UI. Resolves with the payload the UI supplies.
109
+ */
110
+ human: (payload: unknown) => Promise<unknown>;
119
111
  };
120
112
  /**
121
113
  * Function called when assistant-ui executes a frontend tool.
122
114
  */
123
- export type ToolExecuteFunction<TArgs, TResult> = (args: TArgs, context: ToolExecutionContext) => TResult | Promise<TResult>;
124
- export type ToolStreamCallFunction<TArgs extends Record<string, unknown> = Record<string, unknown>, TResult = unknown> = (reader: ToolCallReader<TArgs, TResult>, context: ToolExecutionContext) => void;
115
+ type ToolExecuteFunction<TArgs, TResult> = (args: TArgs, context: ToolExecutionContext) => TResult | Promise<TResult>;
116
+ type ToolStreamCallFunction<TArgs extends Record<string, unknown> = Record<string, unknown>, TResult = unknown> = (reader: ToolCallReader<TArgs, TResult>, context: ToolExecutionContext) => void;
125
117
  type OnSchemaValidationErrorFunction<TResult> = ToolExecuteFunction<unknown, TResult>;
126
118
  type ToolBase<TArgs extends Record<string, unknown> = Record<string, unknown>, TResult = unknown> = {
127
- /**
128
- * @deprecated Experimental, API may change.
129
- */
130
- streamCall?: ToolStreamCallFunction<TArgs, TResult>;
119
+ /**
120
+ * @deprecated Experimental, API may change.
121
+ */
122
+ streamCall?: ToolStreamCallFunction<TArgs, TResult>;
131
123
  };
132
124
  type BackendTool<TArgs extends Record<string, unknown> = Record<string, unknown>, TResult = unknown> = ToolBase<TArgs, TResult> & {
133
- /** Tool that is executed by the backend rather than in the browser. */
134
- type: "backend";
135
- description?: undefined;
136
- parameters?: undefined;
137
- disabled?: undefined;
138
- execute?: undefined;
139
- toModelOutput?: undefined;
140
- experimental_onSchemaValidationError?: undefined;
125
+ /** Tool that is executed by the backend rather than in the browser. */type: "backend";
126
+ description?: undefined;
127
+ parameters?: undefined;
128
+ disabled?: undefined;
129
+ execute?: undefined;
130
+ toModelOutput?: undefined;
131
+ experimental_onSchemaValidationError?: undefined;
141
132
  };
142
133
  type FrontendTool<TArgs extends Record<string, unknown> = Record<string, unknown>, TResult = unknown> = ToolBase<TArgs, TResult> & {
143
- /** Tool that is executed in the frontend runtime. */
144
- type: "frontend";
145
- /** Natural-language description shown to the model when selecting tools. */
146
- description?: string | undefined;
147
- /** Schema for the arguments the model must provide when calling the tool. */
148
- parameters: StandardSchemaV1<TArgs> | JSONSchema7;
149
- /** Prevents the tool from being exposed to the model while true. */
150
- disabled?: boolean;
151
- /** Executes the tool after the model provides valid arguments. */
152
- execute: ToolExecuteFunction<TArgs, TResult>;
153
- /** Converts the execution result into model-visible output. */
154
- toModelOutput?: ToolModelOutputFunction<TArgs, TResult>;
155
- /** Handles invalid tool arguments when schema validation fails. */
156
- experimental_onSchemaValidationError?: OnSchemaValidationErrorFunction<TResult>;
134
+ /** Tool that is executed in the frontend runtime. */type: "frontend"; /** Natural-language description shown to the model when selecting tools. */
135
+ description?: string | undefined; /** Schema for the arguments the model must provide when calling the tool. */
136
+ parameters: StandardSchemaV1<TArgs> | JSONSchema7; /** Prevents the tool from being exposed to the model while true. */
137
+ disabled?: boolean; /** Executes the tool after the model provides valid arguments. */
138
+ execute: ToolExecuteFunction<TArgs, TResult>; /** Converts the execution result into model-visible output. */
139
+ toModelOutput?: ToolModelOutputFunction<TArgs, TResult>; /** Handles invalid tool arguments when schema validation fails. */
140
+ experimental_onSchemaValidationError?: OnSchemaValidationErrorFunction<TResult>;
157
141
  };
158
142
  type HumanTool<TArgs extends Record<string, unknown> = Record<string, unknown>, TResult = unknown> = ToolBase<TArgs, TResult> & {
159
- /** Tool that pauses the run until a user or UI supplies a result. */
160
- type: "human";
161
- /** Natural-language description shown to the model when selecting tools. */
162
- description?: string | undefined;
163
- /** Schema for the arguments the model must provide when requesting input. */
164
- parameters: StandardSchemaV1<TArgs> | JSONSchema7;
165
- /** Prevents the tool from being exposed to the model while true. */
166
- disabled?: boolean;
167
- execute?: undefined;
168
- toModelOutput?: undefined;
169
- experimental_onSchemaValidationError?: undefined;
143
+ /** Tool that pauses the run until a user or UI supplies a result. */type: "human"; /** Natural-language description shown to the model when selecting tools. */
144
+ description?: string | undefined; /** Schema for the arguments the model must provide when requesting input. */
145
+ parameters: StandardSchemaV1<TArgs> | JSONSchema7; /** Prevents the tool from being exposed to the model while true. */
146
+ disabled?: boolean;
147
+ execute?: undefined;
148
+ toModelOutput?: undefined;
149
+ experimental_onSchemaValidationError?: undefined;
170
150
  };
171
151
  /**
172
152
  * Definition for a tool that can be exposed to the assistant model.
@@ -209,12 +189,13 @@ type HumanTool<TArgs extends Record<string, unknown> = Record<string, unknown>,
209
189
  * };
210
190
  * ```
211
191
  */
212
- export type Tool<TArgs extends Record<string, unknown> = Record<string, unknown>, TResult = unknown> = FrontendTool<TArgs, TResult> | BackendTool<TArgs, TResult> | HumanTool<TArgs, TResult> | ToolWithoutType<TArgs, TResult>;
192
+ type Tool<TArgs extends Record<string, unknown> = Record<string, unknown>, TResult = unknown> = FrontendTool<TArgs, TResult> | BackendTool<TArgs, TResult> | HumanTool<TArgs, TResult> | ToolWithoutType<TArgs, TResult>;
213
193
  /**
214
194
  * @deprecated Use {@link Tool} with an explicit `type` field instead.
215
195
  */
216
- export type ToolWithoutType<TArgs extends Record<string, unknown> = Record<string, unknown>, TResult = unknown> = (Omit<FrontendTool<TArgs, TResult>, "type"> | Omit<BackendTool<TArgs, TResult>, "type"> | Omit<HumanTool<TArgs, TResult>, "type">) & {
217
- type?: undefined;
196
+ type ToolWithoutType<TArgs extends Record<string, unknown> = Record<string, unknown>, TResult = unknown> = (Omit<FrontendTool<TArgs, TResult>, "type"> | Omit<BackendTool<TArgs, TResult>, "type"> | Omit<HumanTool<TArgs, TResult>, "type">) & {
197
+ type?: undefined;
218
198
  };
219
- export {};
199
+ //#endregion
200
+ export { Tool, ToolCallArgsReader, ToolCallReader, ToolCallResponseReader, ToolExecuteFunction, ToolExecutionContext, ToolModelContentPart, ToolModelOutputFunction, ToolStreamCallFunction, ToolWithoutType };
220
201
  //# sourceMappingURL=tool-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-types.d.ts","sourceRoot":"","sources":["../../../src/core/tool/tool-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,6BAA0B;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAoB;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,0BAAuB;AAEnD,MAAM,MAAM,oBAAoB,GAC5B;IACE,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,GACD;IACE,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC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CAAiB,KAAA,IAAS,WAAA,EApFT;EAsF7B,QAAA,YArFwC;EAuFxC,OAAA,EAAS,mBAAA,CAAoB,KAAA,EAAO,OAAA,GApF9B;EAsFN,aAAA,GAAgB,uBAAA,CAAwB,KAAA,EAAO,OAAA,GArFrC;EAuFV,oCAAA,GAAuC,+BAAA,CAAgC,OAAA;AAAA;AAAA,KAGpE,SAAA,eACW,MAAA,oBAA0B,MAAA,wCAEtC,QAAA,CAAS,KAAA,EAAO,OAAA;EAtFE,qEAwFpB,IAAA,WAnGc;EAsGd,WAAA,uBArGA;EAuGA,UAAA,EAAY,gBAAA,CAAiB,KAAA,IAAS,WAAA,EArGhC;EAuGN,QAAA;EACA,OAAA;EACA,aAAA;EACA,oCAAA;AAAA;;;;;AAlG4B;AAI9B;;;;;;;;;;;AASsC;AAMtC;;;;;;;;;;;;;;;;;;;;AAG8B;AAE9B;;;KAsHY,IAAA,eACI,MAAA,oBAA0B,MAAA,wCAGtC,YAAA,CAAa,KAAA,EAAO,OAAA,IACpB,WAAA,CAAY,KAAA,EAAO,OAAA,IACnB,SAAA,CAAU,KAAA,EAAO,OAAA,IACjB,eAAA,CAAgB,KAAA,EAAO,OAAA;;;;KAKf,eAAA,eACI,MAAA,oBAA0B,MAAA,yCAGtC,IAAA,CAAK,YAAA,CAAa,KAAA,EAAO,OAAA,aACzB,IAAA,CAAK,WAAA,CAAY,KAAA,EAAO,OAAA,aACxB,IAAA,CAAK,SAAA,CAAU,KAAA,EAAO,OAAA;EACpB,IAAA;AAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=tool-types.js.map
@@ -1,12 +1,12 @@
1
- import type { Tool } from "./tool-types.js";
1
+ import { Tool } from "./tool-types.js";
2
+ import { AssistantMessage } from "../utils/types.js";
2
3
  import { ToolExecutionStream } from "./ToolExecutionStream.js";
3
- import type { AssistantMessage } from "../utils/types.js";
4
- export declare function unstable_runPendingTools(message: AssistantMessage, tools: Record<string, Tool> | undefined, abortSignal: AbortSignal, human: (toolCallId: string, payload: unknown) => Promise<unknown>): Promise<AssistantMessage>;
5
- export type ToolResultStreamOptions = {
6
- /** Called immediately before a frontend tool's `execute` function runs. */
7
- onExecutionStart?: (toolCallId: string, toolName: string) => void;
8
- /** Called after frontend tool execution finishes or fails. */
9
- onExecutionEnd?: (toolCallId: string, toolName: string) => void;
4
+
5
+ //#region src/core/tool/toolResultStream.d.ts
6
+ declare function unstable_runPendingTools(message: AssistantMessage, tools: Record<string, Tool> | undefined, abortSignal: AbortSignal, human: (toolCallId: string, payload: unknown) => Promise<unknown>): Promise<AssistantMessage>;
7
+ type ToolResultStreamOptions = {
8
+ /** Called immediately before a frontend tool's `execute` function runs. */onExecutionStart?: (toolCallId: string, toolName: string) => void; /** Called after frontend tool execution finishes or fails. */
9
+ onExecutionEnd?: (toolCallId: string, toolName: string) => void;
10
10
  };
11
11
  /**
12
12
  * Transform stream that executes frontend tools and appends tool results.
@@ -21,5 +21,7 @@ export type ToolResultStreamOptions = {
21
21
  * @param human Callback used to resolve human-tool requests from UI input.
22
22
  * @param options Optional execution lifecycle callbacks.
23
23
  */
24
- export declare function toolResultStream(tools: Record<string, Tool> | (() => Record<string, Tool> | undefined) | undefined, abortSignal: AbortSignal | (() => AbortSignal), human: (toolCallId: string, payload: unknown) => Promise<unknown>, options?: ToolResultStreamOptions): ToolExecutionStream;
24
+ declare function toolResultStream(tools: Record<string, Tool> | (() => Record<string, Tool> | undefined) | undefined, abortSignal: AbortSignal | (() => AbortSignal), human: (toolCallId: string, payload: unknown) => Promise<unknown>, options?: ToolResultStreamOptions): ToolExecutionStream;
25
+ //#endregion
26
+ export { ToolResultStreamOptions, toolResultStream, unstable_runPendingTools };
25
27
  //# sourceMappingURL=toolResultStream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toolResultStream.d.ts","sourceRoot":"","sources":["../../../src/core/tool/toolResultStream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAuC,wBAAq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