ai 3.0.14 → 3.0.15

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.
package/dist/index.js CHANGED
@@ -77,7 +77,7 @@ module.exports = __toCommonJS(streams_exports);
77
77
  // core/generate-object/generate-object.ts
78
78
  var import_zod_to_json_schema = __toESM(require("zod-to-json-schema"));
79
79
 
80
- // ai-model-specification/errors/api-call-error.ts
80
+ // spec/errors/api-call-error.ts
81
81
  var APICallError = class extends Error {
82
82
  constructor({
83
83
  message,
@@ -121,7 +121,7 @@ var APICallError = class extends Error {
121
121
  }
122
122
  };
123
123
 
124
- // ai-model-specification/errors/invalid-argument-error.ts
124
+ // spec/errors/invalid-argument-error.ts
125
125
  var InvalidArgumentError = class extends Error {
126
126
  constructor({
127
127
  parameter,
@@ -147,7 +147,7 @@ var InvalidArgumentError = class extends Error {
147
147
  }
148
148
  };
149
149
 
150
- // ai-model-specification/errors/invalid-data-content-error.ts
150
+ // spec/errors/invalid-data-content-error.ts
151
151
  var InvalidDataContentError = class extends Error {
152
152
  constructor({
153
153
  content,
@@ -170,7 +170,7 @@ var InvalidDataContentError = class extends Error {
170
170
  }
171
171
  };
172
172
 
173
- // ai-model-specification/util/get-error-message.ts
173
+ // spec/util/get-error-message.ts
174
174
  function getErrorMessage(error) {
175
175
  if (error == null) {
176
176
  return "unknown error";
@@ -184,10 +184,10 @@ function getErrorMessage(error) {
184
184
  return JSON.stringify(error);
185
185
  }
186
186
 
187
- // ai-model-specification/util/parse-json.ts
187
+ // spec/util/parse-json.ts
188
188
  var import_secure_json_parse = __toESM(require("secure-json-parse"));
189
189
 
190
- // ai-model-specification/errors/json-parse-error.ts
190
+ // spec/errors/json-parse-error.ts
191
191
  var JSONParseError = class extends Error {
192
192
  constructor({ text, cause }) {
193
193
  super(
@@ -212,7 +212,7 @@ Error message: ${getErrorMessage(cause)}`
212
212
  }
213
213
  };
214
214
 
215
- // ai-model-specification/errors/type-validation-error.ts
215
+ // spec/errors/type-validation-error.ts
216
216
  var TypeValidationError = class extends Error {
217
217
  constructor({ value, cause }) {
218
218
  super(
@@ -237,7 +237,7 @@ Error message: ${getErrorMessage(cause)}`
237
237
  }
238
238
  };
239
239
 
240
- // ai-model-specification/util/validate-types.ts
240
+ // spec/util/validate-types.ts
241
241
  function safeValidateTypes({
242
242
  value,
243
243
  schema
@@ -265,7 +265,7 @@ function safeValidateTypes({
265
265
  }
266
266
  }
267
267
 
268
- // ai-model-specification/util/parse-json.ts
268
+ // spec/util/parse-json.ts
269
269
  function safeParseJSON({
270
270
  text,
271
271
  schema
@@ -287,7 +287,7 @@ function safeParseJSON({
287
287
  }
288
288
  }
289
289
 
290
- // ai-model-specification/util/uint8-utils.ts
290
+ // spec/util/uint8-utils.ts
291
291
  function convertBase64ToUint8Array(base64String) {
292
292
  const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
293
293
  const latin1string = globalThis.atob(base64Url);
@@ -301,7 +301,7 @@ function convertUint8ArrayToBase64(array) {
301
301
  return globalThis.btoa(latin1string);
302
302
  }
303
303
 
304
- // ai-model-specification/errors/invalid-tool-arguments-error.ts
304
+ // spec/errors/invalid-tool-arguments-error.ts
305
305
  var InvalidToolArgumentsError = class extends Error {
306
306
  constructor({
307
307
  toolArgs,
@@ -332,7 +332,7 @@ var InvalidToolArgumentsError = class extends Error {
332
332
  }
333
333
  };
334
334
 
335
- // ai-model-specification/errors/no-object-generated-error.ts
335
+ // spec/errors/no-object-generated-error.ts
336
336
  var NoTextGeneratedError = class extends Error {
337
337
  constructor() {
338
338
  super(`No text generated.`);
@@ -351,7 +351,7 @@ var NoTextGeneratedError = class extends Error {
351
351
  }
352
352
  };
353
353
 
354
- // ai-model-specification/errors/no-such-tool-error.ts
354
+ // spec/errors/no-such-tool-error.ts
355
355
  var NoSuchToolError = class extends Error {
356
356
  constructor({ message, toolName }) {
357
357
  super(message);
@@ -371,7 +371,7 @@ var NoSuchToolError = class extends Error {
371
371
  }
372
372
  };
373
373
 
374
- // ai-model-specification/errors/retry-error.ts
374
+ // spec/errors/retry-error.ts
375
375
  var RetryError = class extends Error {
376
376
  constructor({
377
377
  message,
@@ -1709,6 +1709,11 @@ var StreamTextResult = class {
1709
1709
  this.originalStream = stream;
1710
1710
  this.warnings = warnings;
1711
1711
  }
1712
+ /**
1713
+ A text stream that returns only the generated text deltas. You can use it
1714
+ as either an AsyncIterable or a ReadableStream. When an error occurs, the
1715
+ stream will throw the error.
1716
+ */
1712
1717
  get textStream() {
1713
1718
  return createAsyncIterableStream(this.originalStream, {
1714
1719
  transform(chunk, controller) {
@@ -1722,6 +1727,12 @@ var StreamTextResult = class {
1722
1727
  }
1723
1728
  });
1724
1729
  }
1730
+ /**
1731
+ A stream with all events, including text deltas, tool calls, tool results, and
1732
+ errors.
1733
+ You can use it as either an AsyncIterable or a ReadableStream. When an error occurs, the
1734
+ stream will throw the error.
1735
+ */
1725
1736
  get fullStream() {
1726
1737
  return createAsyncIterableStream(this.originalStream, {
1727
1738
  transform(chunk, controller) {
@@ -1735,6 +1746,15 @@ var StreamTextResult = class {
1735
1746
  }
1736
1747
  });
1737
1748
  }
1749
+ /**
1750
+ Converts the result to an `AIStream` object that is compatible with `StreamingTextResponse`.
1751
+ It can be used with the `useChat` and `useCompletion` hooks.
1752
+
1753
+ @param callbacks
1754
+ Stream callbacks that will be called when the stream emits events.
1755
+
1756
+ @returns an `AIStream` object.
1757
+ */
1738
1758
  toAIStream(callbacks) {
1739
1759
  return readableFromAsyncIterable(this.textStream).pipeThrough(createCallbacksTransformer(callbacks)).pipeThrough(
1740
1760
  createStreamDataTransformer(callbacks == null ? void 0 : callbacks.experimental_streamData)