ai 3.1.0-canary.4 → 3.1.1

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 (69) hide show
  1. package/dist/index.d.mts +982 -24
  2. package/dist/index.d.ts +982 -24
  3. package/dist/index.js +1748 -175
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +1723 -174
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +11 -28
  8. package/prompts/dist/index.d.mts +13 -1
  9. package/prompts/dist/index.d.ts +13 -1
  10. package/prompts/dist/index.js +13 -0
  11. package/prompts/dist/index.js.map +1 -1
  12. package/prompts/dist/index.mjs +12 -0
  13. package/prompts/dist/index.mjs.map +1 -1
  14. package/react/dist/index.d.mts +23 -6
  15. package/react/dist/index.d.ts +27 -8
  16. package/react/dist/index.js +154 -141
  17. package/react/dist/index.js.map +1 -1
  18. package/react/dist/index.mjs +153 -141
  19. package/react/dist/index.mjs.map +1 -1
  20. package/react/dist/index.server.d.mts +4 -2
  21. package/react/dist/index.server.d.ts +4 -2
  22. package/react/dist/index.server.js.map +1 -1
  23. package/react/dist/index.server.mjs.map +1 -1
  24. package/rsc/dist/index.d.ts +388 -21
  25. package/rsc/dist/rsc-client.d.mts +1 -1
  26. package/rsc/dist/rsc-client.mjs +2 -0
  27. package/rsc/dist/rsc-client.mjs.map +1 -1
  28. package/rsc/dist/rsc-server.d.mts +370 -21
  29. package/rsc/dist/rsc-server.mjs +677 -36
  30. package/rsc/dist/rsc-server.mjs.map +1 -1
  31. package/rsc/dist/rsc-shared.d.mts +24 -9
  32. package/rsc/dist/rsc-shared.mjs +98 -4
  33. package/rsc/dist/rsc-shared.mjs.map +1 -1
  34. package/solid/dist/index.d.mts +7 -3
  35. package/solid/dist/index.d.ts +7 -3
  36. package/solid/dist/index.js +106 -107
  37. package/solid/dist/index.js.map +1 -1
  38. package/solid/dist/index.mjs +106 -107
  39. package/solid/dist/index.mjs.map +1 -1
  40. package/svelte/dist/index.d.mts +7 -3
  41. package/svelte/dist/index.d.ts +7 -3
  42. package/svelte/dist/index.js +109 -109
  43. package/svelte/dist/index.js.map +1 -1
  44. package/svelte/dist/index.mjs +109 -109
  45. package/svelte/dist/index.mjs.map +1 -1
  46. package/vue/dist/index.d.mts +7 -3
  47. package/vue/dist/index.d.ts +7 -3
  48. package/vue/dist/index.js +106 -107
  49. package/vue/dist/index.js.map +1 -1
  50. package/vue/dist/index.mjs +106 -107
  51. package/vue/dist/index.mjs.map +1 -1
  52. package/ai-model-specification/dist/index.d.mts +0 -665
  53. package/ai-model-specification/dist/index.d.ts +0 -665
  54. package/ai-model-specification/dist/index.js +0 -716
  55. package/ai-model-specification/dist/index.js.map +0 -1
  56. package/ai-model-specification/dist/index.mjs +0 -656
  57. package/ai-model-specification/dist/index.mjs.map +0 -1
  58. package/core/dist/index.d.mts +0 -626
  59. package/core/dist/index.d.ts +0 -626
  60. package/core/dist/index.js +0 -1918
  61. package/core/dist/index.js.map +0 -1
  62. package/core/dist/index.mjs +0 -1873
  63. package/core/dist/index.mjs.map +0 -1
  64. package/openai/dist/index.d.mts +0 -429
  65. package/openai/dist/index.d.ts +0 -429
  66. package/openai/dist/index.js +0 -1231
  67. package/openai/dist/index.js.map +0 -1
  68. package/openai/dist/index.mjs +0 -1195
  69. package/openai/dist/index.mjs.map +0 -1
@@ -1,716 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // ai-model-specification/index.ts
31
- var ai_model_specification_exports = {};
32
- __export(ai_model_specification_exports, {
33
- APICallError: () => APICallError,
34
- InvalidArgumentError: () => InvalidArgumentError,
35
- InvalidPromptError: () => InvalidPromptError,
36
- InvalidToolArgumentsError: () => InvalidToolArgumentsError,
37
- JSONParseError: () => JSONParseError,
38
- LoadAPIKeyError: () => LoadAPIKeyError,
39
- NoSuchToolError: () => NoSuchToolError,
40
- NoTextGeneratedError: () => NoTextGeneratedError,
41
- RetryError: () => RetryError,
42
- TypeValidationError: () => TypeValidationError,
43
- UnsupportedFunctionalityError: () => UnsupportedFunctionalityError,
44
- convertBase64ToUint8Array: () => convertBase64ToUint8Array,
45
- convertUint8ArrayToBase64: () => convertUint8ArrayToBase64,
46
- createEventSourceResponseHandler: () => createEventSourceResponseHandler,
47
- createJsonErrorResponseHandler: () => createJsonErrorResponseHandler,
48
- createJsonResponseHandler: () => createJsonResponseHandler,
49
- getErrorMessage: () => getErrorMessage,
50
- isParseableJson: () => isParseableJson,
51
- loadApiKey: () => loadApiKey,
52
- parseJSON: () => parseJSON,
53
- postJsonToApi: () => postJsonToApi,
54
- postToApi: () => postToApi,
55
- safeParseJSON: () => safeParseJSON,
56
- safeValidateTypes: () => safeValidateTypes,
57
- scale: () => scale,
58
- validateTypes: () => validateTypes
59
- });
60
- module.exports = __toCommonJS(ai_model_specification_exports);
61
-
62
- // ai-model-specification/errors/api-call-error.ts
63
- var APICallError = class extends Error {
64
- constructor({
65
- message,
66
- url,
67
- requestBodyValues,
68
- statusCode,
69
- responseBody,
70
- cause,
71
- isRetryable = statusCode != null && (statusCode === 408 || // request timeout
72
- statusCode === 409 || // conflict
73
- statusCode === 429 || // too many requests
74
- statusCode >= 500),
75
- // server error
76
- data
77
- }) {
78
- super(message);
79
- this.name = "AI_APICallError";
80
- this.url = url;
81
- this.requestBodyValues = requestBodyValues;
82
- this.statusCode = statusCode;
83
- this.responseBody = responseBody;
84
- this.cause = cause;
85
- this.isRetryable = isRetryable;
86
- this.data = data;
87
- }
88
- static isAPICallError(error) {
89
- return error instanceof Error && error.name === "AI_APICallError" && typeof error.url === "string" && typeof error.requestBodyValues === "object" && (error.statusCode == null || typeof error.statusCode === "number") && (error.responseBody == null || typeof error.responseBody === "string") && (error.cause == null || typeof error.cause === "object") && typeof error.isRetryable === "boolean" && (error.data == null || typeof error.data === "object");
90
- }
91
- toJSON() {
92
- return {
93
- name: this.name,
94
- message: this.message,
95
- url: this.url,
96
- requestBodyValues: this.requestBodyValues,
97
- statusCode: this.statusCode,
98
- responseBody: this.responseBody,
99
- cause: this.cause,
100
- isRetryable: this.isRetryable,
101
- data: this.data
102
- };
103
- }
104
- };
105
-
106
- // ai-model-specification/errors/invalid-argument-error.ts
107
- var InvalidArgumentError = class extends Error {
108
- constructor({
109
- parameter,
110
- value,
111
- message
112
- }) {
113
- super(`Invalid argument for parameter ${parameter}: ${message}`);
114
- this.name = "AI_InvalidArgumentError";
115
- this.parameter = parameter;
116
- this.value = value;
117
- }
118
- static isInvalidArgumentError(error) {
119
- return error instanceof Error && error.name === "AI_InvalidArgumentError" && typeof error.parameter === "string" && typeof error.value === "string";
120
- }
121
- toJSON() {
122
- return {
123
- name: this.name,
124
- message: this.message,
125
- stack: this.stack,
126
- parameter: this.parameter,
127
- value: this.value
128
- };
129
- }
130
- };
131
-
132
- // ai-model-specification/errors/invalid-prompt-error.ts
133
- var InvalidPromptError = class extends Error {
134
- constructor({ prompt: prompt2, message }) {
135
- super(`Invalid prompt: ${message}`);
136
- this.name = "AI_InvalidPromptError";
137
- this.prompt = prompt2;
138
- }
139
- static isInvalidPromptError(error) {
140
- return error instanceof Error && error.name === "AI_InvalidPromptError" && prompt != null;
141
- }
142
- toJSON() {
143
- return {
144
- name: this.name,
145
- message: this.message,
146
- stack: this.stack,
147
- prompt: this.prompt
148
- };
149
- }
150
- };
151
-
152
- // ai-model-specification/util/get-error-message.ts
153
- function getErrorMessage(error) {
154
- if (error == null) {
155
- return "unknown error";
156
- }
157
- if (typeof error === "string") {
158
- return error;
159
- }
160
- if (error instanceof Error) {
161
- return error.message;
162
- }
163
- return JSON.stringify(error);
164
- }
165
-
166
- // ai-model-specification/errors/load-api-key-error.ts
167
- var LoadAPIKeyError = class extends Error {
168
- constructor({ message }) {
169
- super(message);
170
- this.name = "AI_LoadAPIKeyError";
171
- }
172
- static isLoadAPIKeyError(error) {
173
- return error instanceof Error && error.name === "AI_LoadAPIKeyError";
174
- }
175
- toJSON() {
176
- return {
177
- name: this.name,
178
- message: this.message
179
- };
180
- }
181
- };
182
-
183
- // ai-model-specification/util/load-api-key.ts
184
- function loadApiKey({
185
- apiKey,
186
- environmentVariableName,
187
- apiKeyParameterName = "apiKey",
188
- description
189
- }) {
190
- if (apiKey != null) {
191
- return apiKey;
192
- }
193
- if (typeof process === "undefined") {
194
- throw new LoadAPIKeyError({
195
- message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables is not supported in this environment.`
196
- });
197
- }
198
- apiKey = process.env[environmentVariableName];
199
- if (apiKey == null) {
200
- throw new LoadAPIKeyError({
201
- message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter or the ${environmentVariableName} environment variable.`
202
- });
203
- }
204
- return apiKey;
205
- }
206
-
207
- // ai-model-specification/util/parse-json.ts
208
- var import_secure_json_parse = __toESM(require("secure-json-parse"));
209
-
210
- // ai-model-specification/errors/json-parse-error.ts
211
- var JSONParseError = class extends Error {
212
- constructor({ text, cause }) {
213
- super(
214
- `JSON parsing failed: Text: ${text}.
215
- Error message: ${getErrorMessage(cause)}`
216
- );
217
- this.name = "AI_JSONParseError";
218
- this.cause = cause;
219
- this.text = text;
220
- }
221
- static isJSONParseError(error) {
222
- return error instanceof Error && error.name === "AI_JSONParseError" && typeof error.text === "string" && typeof error.cause === "string";
223
- }
224
- toJSON() {
225
- return {
226
- name: this.name,
227
- message: this.message,
228
- cause: this.cause,
229
- stack: this.stack,
230
- valueText: this.text
231
- };
232
- }
233
- };
234
-
235
- // ai-model-specification/errors/type-validation-error.ts
236
- var TypeValidationError = class extends Error {
237
- constructor({ value, cause }) {
238
- super(
239
- `Type validation failed: Value: ${JSON.stringify(value)}.
240
- Error message: ${getErrorMessage(cause)}`
241
- );
242
- this.name = "AI_TypeValidationError";
243
- this.cause = cause;
244
- this.value = value;
245
- }
246
- static isTypeValidationError(error) {
247
- return error instanceof Error && error.name === "AI_TypeValidationError" && typeof error.value === "string" && typeof error.cause === "string";
248
- }
249
- toJSON() {
250
- return {
251
- name: this.name,
252
- message: this.message,
253
- cause: this.cause,
254
- stack: this.stack,
255
- value: this.value
256
- };
257
- }
258
- };
259
-
260
- // ai-model-specification/util/validate-types.ts
261
- function validateTypes({
262
- value,
263
- schema
264
- }) {
265
- try {
266
- return schema.parse(value);
267
- } catch (error) {
268
- throw new TypeValidationError({ value, cause: error });
269
- }
270
- }
271
- function safeValidateTypes({
272
- value,
273
- schema
274
- }) {
275
- try {
276
- const validationResult = schema.safeParse(value);
277
- if (validationResult.success) {
278
- return {
279
- success: true,
280
- value: validationResult.data
281
- };
282
- }
283
- return {
284
- success: false,
285
- error: new TypeValidationError({
286
- value,
287
- cause: validationResult.error
288
- })
289
- };
290
- } catch (error) {
291
- return {
292
- success: false,
293
- error: TypeValidationError.isTypeValidationError(error) ? error : new TypeValidationError({ value, cause: error })
294
- };
295
- }
296
- }
297
-
298
- // ai-model-specification/util/parse-json.ts
299
- function parseJSON({
300
- text,
301
- schema
302
- }) {
303
- try {
304
- const value = import_secure_json_parse.default.parse(text);
305
- if (schema == null) {
306
- return value;
307
- }
308
- return validateTypes({ value, schema });
309
- } catch (error) {
310
- if (JSONParseError.isJSONParseError(error) || TypeValidationError.isTypeValidationError(error)) {
311
- throw error;
312
- }
313
- throw new JSONParseError({ text, cause: error });
314
- }
315
- }
316
- function safeParseJSON({
317
- text,
318
- schema
319
- }) {
320
- try {
321
- const value = import_secure_json_parse.default.parse(text);
322
- if (schema == null) {
323
- return {
324
- success: true,
325
- value
326
- };
327
- }
328
- return safeValidateTypes({ value, schema });
329
- } catch (error) {
330
- return {
331
- success: false,
332
- error: JSONParseError.isJSONParseError(error) ? error : new JSONParseError({ text, cause: error })
333
- };
334
- }
335
- }
336
- function isParseableJson(input) {
337
- try {
338
- import_secure_json_parse.default.parse(input);
339
- return true;
340
- } catch (e) {
341
- return false;
342
- }
343
- }
344
-
345
- // ai-model-specification/util/post-to-api.ts
346
- var postJsonToApi = async ({
347
- url,
348
- headers,
349
- body,
350
- failedResponseHandler,
351
- successfulResponseHandler,
352
- abortSignal
353
- }) => postToApi({
354
- url,
355
- headers: {
356
- ...headers,
357
- "Content-Type": "application/json"
358
- },
359
- body: {
360
- content: JSON.stringify(body),
361
- values: body
362
- },
363
- failedResponseHandler,
364
- successfulResponseHandler,
365
- abortSignal
366
- });
367
- var postToApi = async ({
368
- url,
369
- headers = {},
370
- body,
371
- successfulResponseHandler,
372
- failedResponseHandler,
373
- abortSignal
374
- }) => {
375
- try {
376
- const definedHeaders = Object.fromEntries(
377
- Object.entries(headers).filter(([_key, value]) => value != null)
378
- );
379
- const response = await fetch(url, {
380
- method: "POST",
381
- headers: definedHeaders,
382
- body: body.content,
383
- signal: abortSignal
384
- });
385
- if (!response.ok) {
386
- try {
387
- throw await failedResponseHandler({
388
- response,
389
- url,
390
- requestBodyValues: body.values
391
- });
392
- } catch (error) {
393
- if (error instanceof Error) {
394
- if (error.name === "AbortError" || APICallError.isAPICallError(error)) {
395
- throw error;
396
- }
397
- }
398
- throw new APICallError({
399
- message: "Failed to process error response",
400
- cause: error,
401
- statusCode: response.status,
402
- url,
403
- requestBodyValues: body.values
404
- });
405
- }
406
- }
407
- try {
408
- return await successfulResponseHandler({
409
- response,
410
- url,
411
- requestBodyValues: body.values
412
- });
413
- } catch (error) {
414
- if (error instanceof Error) {
415
- if (error.name === "AbortError" || APICallError.isAPICallError(error)) {
416
- throw error;
417
- }
418
- }
419
- throw new APICallError({
420
- message: "Failed to process successful response",
421
- cause: error,
422
- statusCode: response.status,
423
- url,
424
- requestBodyValues: body.values
425
- });
426
- }
427
- } catch (error) {
428
- if (error instanceof Error) {
429
- if (error.name === "AbortError") {
430
- throw error;
431
- }
432
- }
433
- if (error instanceof TypeError && error.message === "fetch failed") {
434
- const cause = error.cause;
435
- if (cause != null) {
436
- throw new APICallError({
437
- message: `Cannot connect to API: ${cause.message}`,
438
- cause,
439
- url,
440
- requestBodyValues: body.values,
441
- isRetryable: true
442
- // retry when network error
443
- });
444
- }
445
- }
446
- throw error;
447
- }
448
- };
449
-
450
- // ai-model-specification/util/response-handler.ts
451
- var import_stream = require("eventsource-parser/stream");
452
- var createJsonErrorResponseHandler = ({
453
- errorSchema,
454
- errorToMessage,
455
- isRetryable
456
- }) => async ({ response, url, requestBodyValues }) => {
457
- const responseBody = await response.text();
458
- if (responseBody.trim() === "") {
459
- return new APICallError({
460
- message: response.statusText,
461
- url,
462
- requestBodyValues,
463
- statusCode: response.status,
464
- responseBody,
465
- isRetryable: isRetryable == null ? void 0 : isRetryable(response)
466
- });
467
- }
468
- try {
469
- const parsedError = parseJSON({
470
- text: responseBody,
471
- schema: errorSchema
472
- });
473
- return new APICallError({
474
- message: errorToMessage(parsedError),
475
- url,
476
- requestBodyValues,
477
- statusCode: response.status,
478
- responseBody,
479
- data: parsedError,
480
- isRetryable: isRetryable == null ? void 0 : isRetryable(response, parsedError)
481
- });
482
- } catch (parseError) {
483
- return new APICallError({
484
- message: response.statusText,
485
- url,
486
- requestBodyValues,
487
- statusCode: response.status,
488
- responseBody,
489
- isRetryable: isRetryable == null ? void 0 : isRetryable(response)
490
- });
491
- }
492
- };
493
- var createEventSourceResponseHandler = (chunkSchema) => async ({ response }) => {
494
- if (response.body == null) {
495
- throw new Error("No response body");
496
- }
497
- return response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new import_stream.EventSourceParserStream()).pipeThrough(
498
- new TransformStream({
499
- transform({ data }, controller) {
500
- if (data === "[DONE]") {
501
- return;
502
- }
503
- const parseResult = safeParseJSON({
504
- text: data,
505
- schema: chunkSchema
506
- });
507
- controller.enqueue(
508
- parseResult.success ? { type: "value", value: parseResult.value } : { type: "error", error: parseResult.error }
509
- );
510
- }
511
- })
512
- );
513
- };
514
- var createJsonResponseHandler = (responseSchema) => async ({ response, url, requestBodyValues }) => {
515
- const responseBody = await response.text();
516
- const parsedResult = safeParseJSON({
517
- text: responseBody,
518
- schema: responseSchema
519
- });
520
- if (!parsedResult.success) {
521
- throw new APICallError({
522
- message: "Invalid JSON response",
523
- cause: parsedResult.error,
524
- statusCode: response.status,
525
- responseBody,
526
- url,
527
- requestBodyValues
528
- });
529
- }
530
- return parsedResult.value;
531
- };
532
-
533
- // ai-model-specification/util/scale.ts
534
- function scale({
535
- inputMin = 0,
536
- inputMax = 1,
537
- outputMin,
538
- outputMax,
539
- value
540
- }) {
541
- if (value === void 0) {
542
- return void 0;
543
- }
544
- const inputRange = inputMax - inputMin;
545
- const outputRange = outputMax - outputMin;
546
- return (value - inputMin) * outputRange / inputRange + outputMin;
547
- }
548
-
549
- // ai-model-specification/util/uint8-utils.ts
550
- function convertBase64ToUint8Array(base64String) {
551
- const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
552
- const latin1string = globalThis.atob(base64Url);
553
- return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
554
- }
555
- function convertUint8ArrayToBase64(array) {
556
- let latin1string = "";
557
- for (const value of array) {
558
- latin1string += String.fromCodePoint(value);
559
- }
560
- return globalThis.btoa(latin1string);
561
- }
562
-
563
- // ai-model-specification/errors/invalid-tool-arguments-error.ts
564
- var InvalidToolArgumentsError = class extends Error {
565
- constructor({
566
- toolArgs,
567
- toolName,
568
- cause,
569
- message = `Invalid arguments for tool ${toolName}: ${getErrorMessage(
570
- cause
571
- )}`
572
- }) {
573
- super(message);
574
- this.name = "AI_InvalidToolArgumentsError";
575
- this.toolArgs = toolArgs;
576
- this.toolName = toolName;
577
- this.cause = cause;
578
- }
579
- static isInvalidToolArgumentsError(error) {
580
- return error instanceof Error && error.name === "AI_InvalidToolArgumentsError" && typeof error.toolName === "string" && typeof error.toolArgs === "string";
581
- }
582
- toJSON() {
583
- return {
584
- name: this.name,
585
- message: this.message,
586
- cause: this.cause,
587
- stack: this.stack,
588
- toolName: this.toolName,
589
- toolArgs: this.toolArgs
590
- };
591
- }
592
- };
593
-
594
- // ai-model-specification/errors/no-object-generated-error.ts
595
- var NoTextGeneratedError = class extends Error {
596
- constructor() {
597
- super(`No text generated.`);
598
- this.name = "AI_NoTextGeneratedError";
599
- }
600
- static isNoTextGeneratedError(error) {
601
- return error instanceof Error && error.name === "AI_NoTextGeneratedError";
602
- }
603
- toJSON() {
604
- return {
605
- name: this.name,
606
- cause: this.cause,
607
- message: this.message,
608
- stack: this.stack
609
- };
610
- }
611
- };
612
-
613
- // ai-model-specification/errors/no-such-tool-error.ts
614
- var NoSuchToolError = class extends Error {
615
- constructor({ message, toolName }) {
616
- super(message);
617
- this.name = "AI_NoSuchToolError";
618
- this.toolName = toolName;
619
- }
620
- static isNoSuchToolError(error) {
621
- return error instanceof Error && error.name === "AI_NoSuchToolError" && typeof error.toolName === "string";
622
- }
623
- toJSON() {
624
- return {
625
- name: this.name,
626
- message: this.message,
627
- stack: this.stack,
628
- toolName: this.toolName
629
- };
630
- }
631
- };
632
-
633
- // ai-model-specification/errors/retry-error.ts
634
- var RetryError = class extends Error {
635
- constructor({
636
- message,
637
- reason,
638
- errors
639
- }) {
640
- super(message);
641
- this.name = "AI_RetryError";
642
- this.reason = reason;
643
- this.errors = errors;
644
- this.lastError = errors[errors.length - 1];
645
- }
646
- static isRetryError(error) {
647
- return error instanceof Error && error.name === "AI_RetryError" && typeof error.reason === "string" && Array.isArray(error.errors);
648
- }
649
- toJSON() {
650
- return {
651
- name: this.name,
652
- message: this.message,
653
- reason: this.reason,
654
- lastError: this.lastError,
655
- errors: this.errors
656
- };
657
- }
658
- };
659
-
660
- // ai-model-specification/errors/unsupported-functionality-error.ts
661
- var UnsupportedFunctionalityError = class extends Error {
662
- constructor({
663
- provider,
664
- functionality
665
- }) {
666
- super(
667
- `Functionality not supported by the provider. Provider: ${provider}.
668
- Functionality: ${functionality}`
669
- );
670
- this.name = "AI_UnsupportedFunctionalityError";
671
- this.provider = provider;
672
- this.functionality = functionality;
673
- }
674
- static isUnsupportedFunctionalityError(error) {
675
- return error instanceof Error && error.name === "AI_UnsupportedFunctionalityError" && typeof error.provider === "string" && typeof error.functionality === "string";
676
- }
677
- toJSON() {
678
- return {
679
- name: this.name,
680
- message: this.message,
681
- stack: this.stack,
682
- provider: this.provider,
683
- functionality: this.functionality
684
- };
685
- }
686
- };
687
- // Annotate the CommonJS export names for ESM import in node:
688
- 0 && (module.exports = {
689
- APICallError,
690
- InvalidArgumentError,
691
- InvalidPromptError,
692
- InvalidToolArgumentsError,
693
- JSONParseError,
694
- LoadAPIKeyError,
695
- NoSuchToolError,
696
- NoTextGeneratedError,
697
- RetryError,
698
- TypeValidationError,
699
- UnsupportedFunctionalityError,
700
- convertBase64ToUint8Array,
701
- convertUint8ArrayToBase64,
702
- createEventSourceResponseHandler,
703
- createJsonErrorResponseHandler,
704
- createJsonResponseHandler,
705
- getErrorMessage,
706
- isParseableJson,
707
- loadApiKey,
708
- parseJSON,
709
- postJsonToApi,
710
- postToApi,
711
- safeParseJSON,
712
- safeValidateTypes,
713
- scale,
714
- validateTypes
715
- });
716
- //# sourceMappingURL=index.js.map