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.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // core/generate-object/generate-object.ts
2
2
  import zodToJsonSchema from "zod-to-json-schema";
3
3
 
4
- // ai-model-specification/errors/api-call-error.ts
4
+ // spec/errors/api-call-error.ts
5
5
  var APICallError = class extends Error {
6
6
  constructor({
7
7
  message,
@@ -45,7 +45,7 @@ var APICallError = class extends Error {
45
45
  }
46
46
  };
47
47
 
48
- // ai-model-specification/errors/invalid-argument-error.ts
48
+ // spec/errors/invalid-argument-error.ts
49
49
  var InvalidArgumentError = class extends Error {
50
50
  constructor({
51
51
  parameter,
@@ -71,7 +71,7 @@ var InvalidArgumentError = class extends Error {
71
71
  }
72
72
  };
73
73
 
74
- // ai-model-specification/errors/invalid-data-content-error.ts
74
+ // spec/errors/invalid-data-content-error.ts
75
75
  var InvalidDataContentError = class extends Error {
76
76
  constructor({
77
77
  content,
@@ -94,7 +94,7 @@ var InvalidDataContentError = class extends Error {
94
94
  }
95
95
  };
96
96
 
97
- // ai-model-specification/util/get-error-message.ts
97
+ // spec/util/get-error-message.ts
98
98
  function getErrorMessage(error) {
99
99
  if (error == null) {
100
100
  return "unknown error";
@@ -108,10 +108,10 @@ function getErrorMessage(error) {
108
108
  return JSON.stringify(error);
109
109
  }
110
110
 
111
- // ai-model-specification/util/parse-json.ts
111
+ // spec/util/parse-json.ts
112
112
  import SecureJSON from "secure-json-parse";
113
113
 
114
- // ai-model-specification/errors/json-parse-error.ts
114
+ // spec/errors/json-parse-error.ts
115
115
  var JSONParseError = class extends Error {
116
116
  constructor({ text, cause }) {
117
117
  super(
@@ -136,7 +136,7 @@ Error message: ${getErrorMessage(cause)}`
136
136
  }
137
137
  };
138
138
 
139
- // ai-model-specification/errors/type-validation-error.ts
139
+ // spec/errors/type-validation-error.ts
140
140
  var TypeValidationError = class extends Error {
141
141
  constructor({ value, cause }) {
142
142
  super(
@@ -161,7 +161,7 @@ Error message: ${getErrorMessage(cause)}`
161
161
  }
162
162
  };
163
163
 
164
- // ai-model-specification/util/validate-types.ts
164
+ // spec/util/validate-types.ts
165
165
  function safeValidateTypes({
166
166
  value,
167
167
  schema
@@ -189,7 +189,7 @@ function safeValidateTypes({
189
189
  }
190
190
  }
191
191
 
192
- // ai-model-specification/util/parse-json.ts
192
+ // spec/util/parse-json.ts
193
193
  function safeParseJSON({
194
194
  text,
195
195
  schema
@@ -211,7 +211,7 @@ function safeParseJSON({
211
211
  }
212
212
  }
213
213
 
214
- // ai-model-specification/util/uint8-utils.ts
214
+ // spec/util/uint8-utils.ts
215
215
  function convertBase64ToUint8Array(base64String) {
216
216
  const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
217
217
  const latin1string = globalThis.atob(base64Url);
@@ -225,7 +225,7 @@ function convertUint8ArrayToBase64(array) {
225
225
  return globalThis.btoa(latin1string);
226
226
  }
227
227
 
228
- // ai-model-specification/errors/invalid-tool-arguments-error.ts
228
+ // spec/errors/invalid-tool-arguments-error.ts
229
229
  var InvalidToolArgumentsError = class extends Error {
230
230
  constructor({
231
231
  toolArgs,
@@ -256,7 +256,7 @@ var InvalidToolArgumentsError = class extends Error {
256
256
  }
257
257
  };
258
258
 
259
- // ai-model-specification/errors/no-object-generated-error.ts
259
+ // spec/errors/no-object-generated-error.ts
260
260
  var NoTextGeneratedError = class extends Error {
261
261
  constructor() {
262
262
  super(`No text generated.`);
@@ -275,7 +275,7 @@ var NoTextGeneratedError = class extends Error {
275
275
  }
276
276
  };
277
277
 
278
- // ai-model-specification/errors/no-such-tool-error.ts
278
+ // spec/errors/no-such-tool-error.ts
279
279
  var NoSuchToolError = class extends Error {
280
280
  constructor({ message, toolName }) {
281
281
  super(message);
@@ -295,7 +295,7 @@ var NoSuchToolError = class extends Error {
295
295
  }
296
296
  };
297
297
 
298
- // ai-model-specification/errors/retry-error.ts
298
+ // spec/errors/retry-error.ts
299
299
  var RetryError = class extends Error {
300
300
  constructor({
301
301
  message,
@@ -1633,6 +1633,11 @@ var StreamTextResult = class {
1633
1633
  this.originalStream = stream;
1634
1634
  this.warnings = warnings;
1635
1635
  }
1636
+ /**
1637
+ A text stream that returns only the generated text deltas. You can use it
1638
+ as either an AsyncIterable or a ReadableStream. When an error occurs, the
1639
+ stream will throw the error.
1640
+ */
1636
1641
  get textStream() {
1637
1642
  return createAsyncIterableStream(this.originalStream, {
1638
1643
  transform(chunk, controller) {
@@ -1646,6 +1651,12 @@ var StreamTextResult = class {
1646
1651
  }
1647
1652
  });
1648
1653
  }
1654
+ /**
1655
+ A stream with all events, including text deltas, tool calls, tool results, and
1656
+ errors.
1657
+ You can use it as either an AsyncIterable or a ReadableStream. When an error occurs, the
1658
+ stream will throw the error.
1659
+ */
1649
1660
  get fullStream() {
1650
1661
  return createAsyncIterableStream(this.originalStream, {
1651
1662
  transform(chunk, controller) {
@@ -1659,6 +1670,15 @@ var StreamTextResult = class {
1659
1670
  }
1660
1671
  });
1661
1672
  }
1673
+ /**
1674
+ Converts the result to an `AIStream` object that is compatible with `StreamingTextResponse`.
1675
+ It can be used with the `useChat` and `useCompletion` hooks.
1676
+
1677
+ @param callbacks
1678
+ Stream callbacks that will be called when the stream emits events.
1679
+
1680
+ @returns an `AIStream` object.
1681
+ */
1662
1682
  toAIStream(callbacks) {
1663
1683
  return readableFromAsyncIterable(this.textStream).pipeThrough(createCallbacksTransformer(callbacks)).pipeThrough(
1664
1684
  createStreamDataTransformer(callbacks == null ? void 0 : callbacks.experimental_streamData)