@mastra/server 0.0.0-vector-sources-20250516175436 → 0.0.0-vector-extension-schema-20250922130418
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/CHANGELOG.md +3745 -0
- package/LICENSE.md +11 -42
- package/README.md +0 -5
- package/dist/{chunk-H5PTF3Y4.js → chunk-4QCXUEAT.js} +11 -2
- package/dist/chunk-4QCXUEAT.js.map +1 -0
- package/dist/chunk-4RRMWXQ2.js +3522 -0
- package/dist/chunk-4RRMWXQ2.js.map +1 -0
- package/dist/chunk-57HWW2TY.cjs +587 -0
- package/dist/chunk-57HWW2TY.cjs.map +1 -0
- package/dist/chunk-5DP5XZH6.cjs +928 -0
- package/dist/chunk-5DP5XZH6.cjs.map +1 -0
- package/dist/chunk-66YYHFGF.js +761 -0
- package/dist/chunk-66YYHFGF.js.map +1 -0
- package/dist/chunk-6GMFZ5LK.js +2774 -0
- package/dist/chunk-6GMFZ5LK.js.map +1 -0
- package/dist/chunk-743UIDHI.cjs +2013 -0
- package/dist/chunk-743UIDHI.cjs.map +1 -0
- package/dist/chunk-7JYXPDM4.js +15712 -0
- package/dist/chunk-7JYXPDM4.js.map +1 -0
- package/dist/{chunk-OCWPVYNI.cjs → chunk-7NADHFD2.cjs} +3 -0
- package/dist/chunk-7NADHFD2.cjs.map +1 -0
- package/dist/chunk-7QEJ5QG5.js +151 -0
- package/dist/chunk-7QEJ5QG5.js.map +1 -0
- package/dist/chunk-A3AL7EWJ.js +83 -0
- package/dist/chunk-A3AL7EWJ.js.map +1 -0
- package/dist/chunk-AK2FXLLB.cjs +849 -0
- package/dist/chunk-AK2FXLLB.cjs.map +1 -0
- package/dist/{chunk-5SN4U5AC.cjs → chunk-AVEPEUN4.cjs} +115 -138
- package/dist/chunk-AVEPEUN4.cjs.map +1 -0
- package/dist/chunk-CNU4A2XU.js +129 -0
- package/dist/chunk-CNU4A2XU.js.map +1 -0
- package/dist/chunk-CY4TP3FK.js +16 -0
- package/dist/chunk-CY4TP3FK.js.map +1 -0
- package/dist/chunk-EMMSS5I5.cjs +37 -0
- package/dist/chunk-EMMSS5I5.cjs.map +1 -0
- package/dist/chunk-EMNGA4R4.js +845 -0
- package/dist/chunk-EMNGA4R4.js.map +1 -0
- package/dist/chunk-FALVL2VV.cjs +3525 -0
- package/dist/chunk-FALVL2VV.cjs.map +1 -0
- package/dist/chunk-FQNT7PI4.js +937 -0
- package/dist/chunk-FQNT7PI4.js.map +1 -0
- package/dist/chunk-G3PMV62Z.js +33 -0
- package/dist/chunk-G3PMV62Z.js.map +1 -0
- package/dist/chunk-G4PUALCE.cjs +28 -0
- package/dist/chunk-G4PUALCE.cjs.map +1 -0
- package/dist/chunk-G662L2YZ.js +568 -0
- package/dist/chunk-G662L2YZ.js.map +1 -0
- package/dist/chunk-GDWMF6SB.cjs +133 -0
- package/dist/chunk-GDWMF6SB.cjs.map +1 -0
- package/dist/chunk-GU4EWMZB.cjs +769 -0
- package/dist/chunk-GU4EWMZB.cjs.map +1 -0
- package/dist/chunk-GUI3CROV.cjs +159 -0
- package/dist/chunk-GUI3CROV.cjs.map +1 -0
- package/dist/chunk-HJQKWRKQ.cjs +764 -0
- package/dist/chunk-HJQKWRKQ.cjs.map +1 -0
- package/dist/{chunk-YWLUOY3D.cjs → chunk-HVBBFCDH.cjs} +1110 -793
- package/dist/chunk-HVBBFCDH.cjs.map +1 -0
- package/dist/chunk-HZJRQ5L3.cjs +1411 -0
- package/dist/chunk-HZJRQ5L3.cjs.map +1 -0
- package/dist/chunk-IGFMAZZ5.cjs +1150 -0
- package/dist/chunk-IGFMAZZ5.cjs.map +1 -0
- package/dist/chunk-ILESGJ6N.js +524 -0
- package/dist/chunk-ILESGJ6N.js.map +1 -0
- package/dist/chunk-IOQGI4ML.js +931 -0
- package/dist/chunk-IOQGI4ML.js.map +1 -0
- package/dist/chunk-J7BPKKOG.cjs +163 -0
- package/dist/chunk-J7BPKKOG.cjs.map +1 -0
- package/dist/{chunk-HFWCEP5S.js → chunk-JRDEOHAJ.js} +47 -14
- package/dist/chunk-JRDEOHAJ.js.map +1 -0
- package/dist/chunk-KNGXRN26.cjs +335 -0
- package/dist/chunk-KNGXRN26.cjs.map +1 -0
- package/dist/{chunk-OR3CIE2H.js → chunk-KV6VHX4V.js} +29 -7
- package/dist/chunk-KV6VHX4V.js.map +1 -0
- package/dist/chunk-L265APUD.cjs +69 -0
- package/dist/chunk-L265APUD.cjs.map +1 -0
- package/dist/chunk-LF2ZLOFP.js +767 -0
- package/dist/chunk-LF2ZLOFP.js.map +1 -0
- package/dist/chunk-LYPU75T6.js +1147 -0
- package/dist/chunk-LYPU75T6.js.map +1 -0
- package/dist/{chunk-NYN7KFXL.js → chunk-MMROOK5J.js} +3 -0
- package/dist/chunk-MMROOK5J.js.map +1 -0
- package/dist/chunk-N35YCWQ5.cjs +540 -0
- package/dist/chunk-N35YCWQ5.cjs.map +1 -0
- package/dist/{chunk-LIVAK2DM.js → chunk-N7F33WAD.js} +1083 -794
- package/dist/chunk-N7F33WAD.js.map +1 -0
- package/dist/chunk-NG5IVLEZ.js +1012 -0
- package/dist/chunk-NG5IVLEZ.js.map +1 -0
- package/dist/chunk-NLWACBE7.cjs +128 -0
- package/dist/chunk-NLWACBE7.cjs.map +1 -0
- package/dist/chunk-OGW6HHVI.js +1408 -0
- package/dist/chunk-OGW6HHVI.js.map +1 -0
- package/dist/chunk-OJQOYXHU.cjs +15748 -0
- package/dist/chunk-OJQOYXHU.cjs.map +1 -0
- package/dist/chunk-OZLRIVC4.cjs +588 -0
- package/dist/chunk-OZLRIVC4.cjs.map +1 -0
- package/dist/chunk-P7CIEIJ3.js +925 -0
- package/dist/chunk-P7CIEIJ3.js.map +1 -0
- package/dist/chunk-P7RBMCBE.cjs +934 -0
- package/dist/chunk-P7RBMCBE.cjs.map +1 -0
- package/dist/chunk-PPYGWINI.cjs +2777 -0
- package/dist/chunk-PPYGWINI.cjs.map +1 -0
- package/dist/{chunk-P6SCPDYW.js → chunk-PUYSH3IL.js} +114 -137
- package/dist/chunk-PUYSH3IL.js.map +1 -0
- package/dist/{chunk-MHKNLNAN.cjs → chunk-PWTXZZTR.cjs} +33 -10
- package/dist/chunk-PWTXZZTR.cjs.map +1 -0
- package/dist/chunk-R7NOGUZG.js +65 -0
- package/dist/chunk-R7NOGUZG.js.map +1 -0
- package/dist/chunk-RCHEPTZZ.js +2006 -0
- package/dist/chunk-RCHEPTZZ.js.map +1 -0
- package/dist/chunk-RE4RPXT2.cjs +18 -0
- package/dist/chunk-RE4RPXT2.cjs.map +1 -0
- package/dist/chunk-SIGXR3JT.cjs +1043 -0
- package/dist/chunk-SIGXR3JT.cjs.map +1 -0
- package/dist/chunk-SPLSYTYW.cjs +88 -0
- package/dist/chunk-SPLSYTYW.cjs.map +1 -0
- package/dist/chunk-SQY4T6EJ.js +571 -0
- package/dist/chunk-SQY4T6EJ.js.map +1 -0
- package/dist/{chunk-TJKLBTFB.js → chunk-SYRRSBGL.js} +51 -27
- package/dist/chunk-SYRRSBGL.js.map +1 -0
- package/dist/{chunk-BNEY4P4P.cjs → chunk-T3TIA3O6.cjs} +20 -18
- package/dist/chunk-T3TIA3O6.cjs.map +1 -0
- package/dist/{chunk-EJO45KYT.js → chunk-TTHEEIZ3.js} +53 -50
- package/dist/chunk-TTHEEIZ3.js.map +1 -0
- package/dist/chunk-TVSIG4JE.cjs +940 -0
- package/dist/chunk-TVSIG4JE.cjs.map +1 -0
- package/dist/{chunk-55DOQLP6.js → chunk-WHN4VX55.js} +5 -3
- package/dist/chunk-WHN4VX55.js.map +1 -0
- package/dist/dist-26HWEQY6.js +3 -0
- package/dist/dist-26HWEQY6.js.map +1 -0
- package/dist/dist-3A5DXB37.cjs +20 -0
- package/dist/dist-3A5DXB37.cjs.map +1 -0
- package/dist/dist-3SJKQJGY.cjs +16 -0
- package/dist/dist-3SJKQJGY.cjs.map +1 -0
- package/dist/dist-4ZQSPE5K.js +3 -0
- package/dist/dist-4ZQSPE5K.js.map +1 -0
- package/dist/dist-5W5QNRTD.js +3 -0
- package/dist/dist-5W5QNRTD.js.map +1 -0
- package/dist/dist-653SRMPL.js +3 -0
- package/dist/dist-653SRMPL.js.map +1 -0
- package/dist/dist-6U6EFC5C.cjs +16 -0
- package/dist/dist-6U6EFC5C.cjs.map +1 -0
- package/dist/dist-7IHNNYMF.cjs +16 -0
- package/dist/dist-7IHNNYMF.cjs.map +1 -0
- package/dist/dist-B5IPRF6W.js +3 -0
- package/dist/dist-B5IPRF6W.js.map +1 -0
- package/dist/dist-EOMYFT4Y.cjs +16 -0
- package/dist/dist-EOMYFT4Y.cjs.map +1 -0
- package/dist/dist-EZZMMMNT.cjs +16 -0
- package/dist/dist-EZZMMMNT.cjs.map +1 -0
- package/dist/dist-F2ET4MNO.cjs +16 -0
- package/dist/dist-F2ET4MNO.cjs.map +1 -0
- package/dist/dist-H64VX6DE.js +3 -0
- package/dist/dist-H64VX6DE.js.map +1 -0
- package/dist/dist-HY7RMLJQ.cjs +16 -0
- package/dist/dist-HY7RMLJQ.cjs.map +1 -0
- package/dist/dist-M6S4P3FJ.js +3 -0
- package/dist/dist-M6S4P3FJ.js.map +1 -0
- package/dist/dist-NR7QSCQT.js +3 -0
- package/dist/dist-NR7QSCQT.js.map +1 -0
- package/dist/dist-QLFMCMCX.js +3 -0
- package/dist/dist-QLFMCMCX.js.map +1 -0
- package/dist/dist-UY46BFRP.js +3 -0
- package/dist/dist-UY46BFRP.js.map +1 -0
- package/dist/dist-WCQDRTIV.cjs +16 -0
- package/dist/dist-WCQDRTIV.cjs.map +1 -0
- package/dist/dist-WKYB3LTJ.cjs +16 -0
- package/dist/dist-WKYB3LTJ.cjs.map +1 -0
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/server/a2a/protocol.d.ts +8 -0
- package/dist/server/a2a/protocol.d.ts.map +1 -0
- package/dist/server/a2a/store.cjs +25 -0
- package/dist/server/a2a/store.cjs.map +1 -0
- package/dist/server/a2a/store.d.ts +14 -0
- package/dist/server/a2a/store.d.ts.map +1 -0
- package/dist/server/a2a/store.js +23 -0
- package/dist/server/a2a/store.js.map +1 -0
- package/dist/server/a2a/tasks.d.ts +20 -0
- package/dist/server/a2a/tasks.d.ts.map +1 -0
- package/dist/server/handlers/a2a.cjs +13 -11
- package/dist/server/handlers/a2a.cjs.map +1 -0
- package/dist/server/handlers/a2a.d.ts +68 -6
- package/dist/server/handlers/a2a.d.ts.map +1 -0
- package/dist/server/handlers/a2a.js +3 -1
- package/dist/server/handlers/a2a.js.map +1 -0
- package/dist/server/handlers/agent-builder.cjs +68 -0
- package/dist/server/handlers/agent-builder.cjs.map +1 -0
- package/dist/server/handlers/agent-builder.d.ts +88 -0
- package/dist/server/handlers/agent-builder.d.ts.map +1 -0
- package/dist/server/handlers/agent-builder.js +3 -0
- package/dist/server/handlers/agent-builder.js.map +1 -0
- package/dist/server/handlers/agents.cjs +41 -7
- package/dist/server/handlers/agents.cjs.map +1 -0
- package/dist/server/handlers/agents.d.ts +139 -6
- package/dist/server/handlers/agents.d.ts.map +1 -0
- package/dist/server/handlers/agents.js +3 -1
- package/dist/server/handlers/agents.js.map +1 -0
- package/dist/server/handlers/error.cjs +4 -2
- package/dist/server/handlers/error.cjs.map +1 -0
- package/dist/server/handlers/error.d.ts +2 -1
- package/dist/server/handlers/error.d.ts.map +1 -0
- package/dist/server/handlers/error.js +3 -1
- package/dist/server/handlers/error.js.map +1 -0
- package/dist/server/handlers/legacyWorkflows.cjs +48 -0
- package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
- package/dist/server/handlers/legacyWorkflows.d.ts +59 -0
- package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
- package/dist/server/handlers/legacyWorkflows.js +3 -0
- package/dist/server/handlers/legacyWorkflows.js.map +1 -0
- package/dist/server/handlers/logs.cjs +6 -4
- package/dist/server/handlers/logs.cjs.map +1 -0
- package/dist/server/handlers/logs.d.ts +34 -3
- package/dist/server/handlers/logs.d.ts.map +1 -0
- package/dist/server/handlers/logs.js +3 -1
- package/dist/server/handlers/logs.js.map +1 -0
- package/dist/server/handlers/memory.cjs +39 -9
- package/dist/server/handlers/memory.cjs.map +1 -0
- package/dist/server/handlers/memory.d.ts +118 -8
- package/dist/server/handlers/memory.d.ts.map +1 -0
- package/dist/server/handlers/memory.js +3 -1
- package/dist/server/handlers/memory.js.map +1 -0
- package/dist/server/handlers/observability.cjs +16 -0
- package/dist/server/handlers/observability.cjs.map +1 -0
- package/dist/server/handlers/observability.d.ts +23 -0
- package/dist/server/handlers/observability.d.ts.map +1 -0
- package/dist/server/handlers/observability.js +3 -0
- package/dist/server/handlers/observability.js.map +1 -0
- package/dist/server/handlers/scores.cjs +32 -0
- package/dist/server/handlers/scores.cjs.map +1 -0
- package/dist/server/handlers/scores.d.ts +49 -0
- package/dist/server/handlers/scores.d.ts.map +1 -0
- package/dist/server/handlers/scores.js +3 -0
- package/dist/server/handlers/scores.js.map +1 -0
- package/dist/server/handlers/telemetry.cjs +9 -3
- package/dist/server/handlers/telemetry.cjs.map +1 -0
- package/dist/server/handlers/telemetry.d.ts +33 -2
- package/dist/server/handlers/telemetry.d.ts.map +1 -0
- package/dist/server/handlers/telemetry.js +3 -1
- package/dist/server/handlers/telemetry.js.map +1 -0
- package/dist/server/handlers/tools.cjs +11 -5
- package/dist/server/handlers/tools.cjs.map +1 -0
- package/dist/server/handlers/tools.d.ts +25 -4
- package/dist/server/handlers/tools.d.ts.map +1 -0
- package/dist/server/handlers/tools.js +3 -1
- package/dist/server/handlers/tools.js.map +1 -0
- package/dist/server/handlers/utils.cjs +8 -2
- package/dist/server/handlers/utils.cjs.map +1 -0
- package/dist/server/handlers/utils.d.ts +8 -1
- package/dist/server/handlers/utils.d.ts.map +1 -0
- package/dist/server/handlers/utils.js +3 -1
- package/dist/server/handlers/utils.js.map +1 -0
- package/dist/server/handlers/vNextNetwork.cjs +220 -0
- package/dist/server/handlers/vNextNetwork.cjs.map +1 -0
- package/dist/server/handlers/vNextNetwork.d.ts +246 -0
- package/dist/server/handlers/vNextNetwork.d.ts.map +1 -0
- package/dist/server/handlers/vNextNetwork.js +213 -0
- package/dist/server/handlers/vNextNetwork.js.map +1 -0
- package/dist/server/handlers/vector.cjs +9 -7
- package/dist/server/handlers/vector.cjs.map +1 -0
- package/dist/server/handlers/vector.d.ts +51 -6
- package/dist/server/handlers/vector.d.ts.map +1 -0
- package/dist/server/handlers/vector.js +3 -1
- package/dist/server/handlers/vector.js.map +1 -0
- package/dist/server/handlers/voice.cjs +10 -4
- package/dist/server/handlers/voice.cjs.map +1 -0
- package/dist/server/handlers/voice.d.ts +41 -3
- package/dist/server/handlers/voice.d.ts.map +1 -0
- package/dist/server/handlers/voice.js +3 -1
- package/dist/server/handlers/voice.js.map +1 -0
- package/dist/server/handlers/workflows.cjs +43 -13
- package/dist/server/handlers/workflows.cjs.map +1 -0
- package/dist/server/handlers/workflows.d.ts +82 -10
- package/dist/server/handlers/workflows.d.ts.map +1 -0
- package/dist/server/handlers/workflows.js +3 -1
- package/dist/server/handlers/workflows.js.map +1 -0
- package/dist/server/handlers.cjs +44 -32
- package/dist/server/handlers.cjs.map +1 -0
- package/dist/server/handlers.d.ts +14 -11
- package/dist/server/handlers.d.ts.map +1 -0
- package/dist/server/handlers.js +15 -11
- package/dist/server/handlers.js.map +1 -0
- package/dist/server/http-exception.d.ts +87 -0
- package/dist/server/http-exception.d.ts.map +1 -0
- package/dist/server/types.d.ts +10 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/utils.d.ts +44 -0
- package/dist/server/utils.d.ts.map +1 -0
- package/package.json +51 -21
- package/dist/_tsup-dts-rollup.d.cts +0 -816
- package/dist/_tsup-dts-rollup.d.ts +0 -816
- package/dist/chunk-57CJTIPW.cjs +0 -18
- package/dist/chunk-64U3UDTH.cjs +0 -13
- package/dist/chunk-75ZPJI57.cjs +0 -9
- package/dist/chunk-C7564HUT.js +0 -142
- package/dist/chunk-D4IRYCUI.cjs +0 -235
- package/dist/chunk-DJJIUEL2.js +0 -211
- package/dist/chunk-HWZVAG3H.js +0 -49
- package/dist/chunk-I2B73Y4I.cjs +0 -332
- package/dist/chunk-M5ABIP7D.js +0 -11
- package/dist/chunk-MIQYDLLM.js +0 -329
- package/dist/chunk-MLKGABMK.js +0 -7
- package/dist/chunk-OGCNNUHF.cjs +0 -54
- package/dist/chunk-UCTEMO2Q.cjs +0 -341
- package/dist/chunk-VPNDC2DI.cjs +0 -148
- package/dist/chunk-WUC6LSTW.js +0 -227
- package/dist/chunk-Y7UWRW5X.cjs +0 -221
- package/dist/chunk-YBVOQN4M.cjs +0 -94
- package/dist/chunk-ZE5AAC4I.cjs +0 -138
- package/dist/index.d.cts +0 -1
- package/dist/server/handlers/a2a.d.cts +0 -6
- package/dist/server/handlers/agents.d.cts +0 -6
- package/dist/server/handlers/error.d.cts +0 -1
- package/dist/server/handlers/logs.d.cts +0 -3
- package/dist/server/handlers/memory.d.cts +0 -8
- package/dist/server/handlers/network.cjs +0 -22
- package/dist/server/handlers/network.d.cts +0 -4
- package/dist/server/handlers/network.d.ts +0 -4
- package/dist/server/handlers/network.js +0 -1
- package/dist/server/handlers/telemetry.d.cts +0 -2
- package/dist/server/handlers/tools.d.cts +0 -4
- package/dist/server/handlers/utils.d.cts +0 -1
- package/dist/server/handlers/vNextWorkflows.cjs +0 -46
- package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
- package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
- package/dist/server/handlers/vNextWorkflows.js +0 -1
- package/dist/server/handlers/vector.d.cts +0 -6
- package/dist/server/handlers/voice.d.cts +0 -3
- package/dist/server/handlers/workflows.d.cts +0 -10
- package/dist/server/handlers.d.cts +0 -11
|
@@ -2,771 +2,423 @@
|
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
|
|
5
|
-
// ../../node_modules/.pnpm
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
// ../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
6
|
+
var marker = "vercel.ai.error";
|
|
7
|
+
var symbol = Symbol.for(marker);
|
|
8
|
+
var _a;
|
|
9
|
+
var _AISDKError = class _AISDKError2 extends Error {
|
|
10
|
+
/**
|
|
11
|
+
* Creates an AI SDK Error.
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} params - The parameters for creating the error.
|
|
14
|
+
* @param {string} params.name - The name of the error.
|
|
15
|
+
* @param {string} params.message - The error message.
|
|
16
|
+
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
17
|
+
*/
|
|
18
|
+
constructor({
|
|
19
|
+
name: name14,
|
|
20
|
+
message,
|
|
21
|
+
cause
|
|
22
|
+
}) {
|
|
23
|
+
super(message);
|
|
24
|
+
this[_a] = true;
|
|
25
|
+
this.name = name14;
|
|
26
|
+
this.cause = cause;
|
|
17
27
|
}
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Checks if the given error is an AI SDK Error.
|
|
30
|
+
* @param {unknown} error - The error to check.
|
|
31
|
+
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
32
|
+
*/
|
|
33
|
+
static isInstance(error) {
|
|
34
|
+
return _AISDKError2.hasMarker(error, marker);
|
|
20
35
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
36
|
+
static hasMarker(error, marker15) {
|
|
37
|
+
const markerSymbol = Symbol.for(marker15);
|
|
38
|
+
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
24
39
|
}
|
|
25
40
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
_a = symbol;
|
|
42
|
+
var AISDKError = _AISDKError;
|
|
43
|
+
var name = "AI_APICallError";
|
|
44
|
+
var marker2 = `vercel.ai.error.${name}`;
|
|
45
|
+
var symbol2 = Symbol.for(marker2);
|
|
46
|
+
var _a2;
|
|
47
|
+
var APICallError = class extends AISDKError {
|
|
48
|
+
constructor({
|
|
49
|
+
message,
|
|
50
|
+
url,
|
|
51
|
+
requestBodyValues,
|
|
52
|
+
statusCode,
|
|
53
|
+
responseHeaders,
|
|
54
|
+
responseBody,
|
|
55
|
+
cause,
|
|
56
|
+
isRetryable = statusCode != null && (statusCode === 408 || // request timeout
|
|
57
|
+
statusCode === 409 || // conflict
|
|
58
|
+
statusCode === 429 || // too many requests
|
|
59
|
+
statusCode >= 500),
|
|
60
|
+
// server error
|
|
61
|
+
data
|
|
62
|
+
}) {
|
|
63
|
+
super({ name, message, cause });
|
|
64
|
+
this[_a2] = true;
|
|
65
|
+
this.url = url;
|
|
66
|
+
this.requestBodyValues = requestBodyValues;
|
|
67
|
+
this.statusCode = statusCode;
|
|
68
|
+
this.responseHeaders = responseHeaders;
|
|
69
|
+
this.responseBody = responseBody;
|
|
70
|
+
this.isRetryable = isRetryable;
|
|
71
|
+
this.data = data;
|
|
72
|
+
}
|
|
73
|
+
static isInstance(error) {
|
|
74
|
+
return AISDKError.hasMarker(error, marker2);
|
|
50
75
|
}
|
|
51
76
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
} else {
|
|
66
|
-
super.register(value, options);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
getAllowedProps(value) {
|
|
70
|
-
return this.classToAllowedProps.get(value);
|
|
77
|
+
_a2 = symbol2;
|
|
78
|
+
var name2 = "AI_EmptyResponseBodyError";
|
|
79
|
+
var marker3 = `vercel.ai.error.${name2}`;
|
|
80
|
+
var symbol3 = Symbol.for(marker3);
|
|
81
|
+
var _a3;
|
|
82
|
+
var EmptyResponseBodyError = class extends AISDKError {
|
|
83
|
+
// used in isInstance
|
|
84
|
+
constructor({ message = "Empty response body" } = {}) {
|
|
85
|
+
super({ name: name2, message });
|
|
86
|
+
this[_a3] = true;
|
|
87
|
+
}
|
|
88
|
+
static isInstance(error) {
|
|
89
|
+
return AISDKError.hasMarker(error, marker3);
|
|
71
90
|
}
|
|
72
91
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return Object.values(record);
|
|
78
|
-
}
|
|
79
|
-
const values = [];
|
|
80
|
-
for (const key in record) {
|
|
81
|
-
if (record.hasOwnProperty(key)) {
|
|
82
|
-
values.push(record[key]);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return values;
|
|
86
|
-
}
|
|
87
|
-
function find(record, predicate) {
|
|
88
|
-
const values = valuesOfObj(record);
|
|
89
|
-
if ("find" in values) {
|
|
90
|
-
return values.find(predicate);
|
|
92
|
+
_a3 = symbol3;
|
|
93
|
+
function getErrorMessage(error) {
|
|
94
|
+
if (error == null) {
|
|
95
|
+
return "unknown error";
|
|
91
96
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const value = valuesNotNever[i];
|
|
95
|
-
if (predicate(value)) {
|
|
96
|
-
return value;
|
|
97
|
-
}
|
|
97
|
+
if (typeof error === "string") {
|
|
98
|
+
return error;
|
|
98
99
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
function forEach(record, run) {
|
|
102
|
-
Object.entries(record).forEach(([key, value]) => run(value, key));
|
|
103
|
-
}
|
|
104
|
-
function includes(arr, value) {
|
|
105
|
-
return arr.indexOf(value) !== -1;
|
|
106
|
-
}
|
|
107
|
-
function findArr(record, predicate) {
|
|
108
|
-
for (let i = 0; i < record.length; i++) {
|
|
109
|
-
const value = record[i];
|
|
110
|
-
if (predicate(value)) {
|
|
111
|
-
return value;
|
|
112
|
-
}
|
|
100
|
+
if (error instanceof Error) {
|
|
101
|
+
return error.message;
|
|
113
102
|
}
|
|
114
|
-
return
|
|
103
|
+
return JSON.stringify(error);
|
|
115
104
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
var
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
105
|
+
var name3 = "AI_InvalidArgumentError";
|
|
106
|
+
var marker4 = `vercel.ai.error.${name3}`;
|
|
107
|
+
var symbol4 = Symbol.for(marker4);
|
|
108
|
+
var _a4;
|
|
109
|
+
var InvalidArgumentError = class extends AISDKError {
|
|
110
|
+
constructor({
|
|
111
|
+
message,
|
|
112
|
+
cause,
|
|
113
|
+
argument
|
|
114
|
+
}) {
|
|
115
|
+
super({ name: name3, message, cause });
|
|
116
|
+
this[_a4] = true;
|
|
117
|
+
this.argument = argument;
|
|
118
|
+
}
|
|
119
|
+
static isInstance(error) {
|
|
120
|
+
return AISDKError.hasMarker(error, marker4);
|
|
130
121
|
}
|
|
131
122
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
var
|
|
135
|
-
var
|
|
136
|
-
var
|
|
137
|
-
var
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
123
|
+
_a4 = symbol4;
|
|
124
|
+
var name4 = "AI_InvalidPromptError";
|
|
125
|
+
var marker5 = `vercel.ai.error.${name4}`;
|
|
126
|
+
var symbol5 = Symbol.for(marker5);
|
|
127
|
+
var _a5;
|
|
128
|
+
var InvalidPromptError = class extends AISDKError {
|
|
129
|
+
constructor({
|
|
130
|
+
prompt,
|
|
131
|
+
message,
|
|
132
|
+
cause
|
|
133
|
+
}) {
|
|
134
|
+
super({ name: name4, message: `Invalid prompt: ${message}`, cause });
|
|
135
|
+
this[_a5] = true;
|
|
136
|
+
this.prompt = prompt;
|
|
137
|
+
}
|
|
138
|
+
static isInstance(error) {
|
|
139
|
+
return AISDKError.hasMarker(error, marker5);
|
|
140
|
+
}
|
|
145
141
|
};
|
|
146
|
-
|
|
147
|
-
var
|
|
148
|
-
var
|
|
149
|
-
var
|
|
150
|
-
var
|
|
151
|
-
var
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
var isURL = (payload) => payload instanceof URL;
|
|
163
|
-
|
|
164
|
-
// ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/pathstringifier.js
|
|
165
|
-
var escapeKey = (key) => key.replace(/\./g, "\\.");
|
|
166
|
-
var stringifyPath = (path) => path.map(String).map(escapeKey).join(".");
|
|
167
|
-
var parsePath = (string) => {
|
|
168
|
-
const result = [];
|
|
169
|
-
let segment = "";
|
|
170
|
-
for (let i = 0; i < string.length; i++) {
|
|
171
|
-
let char = string.charAt(i);
|
|
172
|
-
const isEscapedDot = char === "\\" && string.charAt(i + 1) === ".";
|
|
173
|
-
if (isEscapedDot) {
|
|
174
|
-
segment += ".";
|
|
175
|
-
i++;
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
const isEndOfSegment = char === ".";
|
|
179
|
-
if (isEndOfSegment) {
|
|
180
|
-
result.push(segment);
|
|
181
|
-
segment = "";
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
segment += char;
|
|
142
|
+
_a5 = symbol5;
|
|
143
|
+
var name5 = "AI_InvalidResponseDataError";
|
|
144
|
+
var marker6 = `vercel.ai.error.${name5}`;
|
|
145
|
+
var symbol6 = Symbol.for(marker6);
|
|
146
|
+
var _a6;
|
|
147
|
+
var InvalidResponseDataError = class extends AISDKError {
|
|
148
|
+
constructor({
|
|
149
|
+
data,
|
|
150
|
+
message = `Invalid response data: ${JSON.stringify(data)}.`
|
|
151
|
+
}) {
|
|
152
|
+
super({ name: name5, message });
|
|
153
|
+
this[_a6] = true;
|
|
154
|
+
this.data = data;
|
|
155
|
+
}
|
|
156
|
+
static isInstance(error) {
|
|
157
|
+
return AISDKError.hasMarker(error, marker6);
|
|
185
158
|
}
|
|
186
|
-
const lastSegment = segment;
|
|
187
|
-
result.push(lastSegment);
|
|
188
|
-
return result;
|
|
189
159
|
};
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
simpleTransformation(isBigint, "bigint", (v) => v.toString(), (v) => {
|
|
203
|
-
if (typeof BigInt !== "undefined") {
|
|
204
|
-
return BigInt(v);
|
|
205
|
-
}
|
|
206
|
-
console.error("Please add a BigInt polyfill.");
|
|
207
|
-
return v;
|
|
208
|
-
}),
|
|
209
|
-
simpleTransformation(isDate, "Date", (v) => v.toISOString(), (v) => new Date(v)),
|
|
210
|
-
simpleTransformation(isError, "Error", (v, superJson) => {
|
|
211
|
-
const baseError = {
|
|
212
|
-
name: v.name,
|
|
213
|
-
message: v.message
|
|
214
|
-
};
|
|
215
|
-
superJson.allowedErrorProps.forEach((prop) => {
|
|
216
|
-
baseError[prop] = v[prop];
|
|
217
|
-
});
|
|
218
|
-
return baseError;
|
|
219
|
-
}, (v, superJson) => {
|
|
220
|
-
const e = new Error(v.message);
|
|
221
|
-
e.name = v.name;
|
|
222
|
-
e.stack = v.stack;
|
|
223
|
-
superJson.allowedErrorProps.forEach((prop) => {
|
|
224
|
-
e[prop] = v[prop];
|
|
160
|
+
_a6 = symbol6;
|
|
161
|
+
var name6 = "AI_JSONParseError";
|
|
162
|
+
var marker7 = `vercel.ai.error.${name6}`;
|
|
163
|
+
var symbol7 = Symbol.for(marker7);
|
|
164
|
+
var _a7;
|
|
165
|
+
var JSONParseError = class extends AISDKError {
|
|
166
|
+
constructor({ text, cause }) {
|
|
167
|
+
super({
|
|
168
|
+
name: name6,
|
|
169
|
+
message: `JSON parsing failed: Text: ${text}.
|
|
170
|
+
Error message: ${getErrorMessage(cause)}`,
|
|
171
|
+
cause
|
|
225
172
|
});
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
simpleTransformation(isRegExp, "regexp", (v) => "" + v, (regex) => {
|
|
229
|
-
const body = regex.slice(1, regex.lastIndexOf("/"));
|
|
230
|
-
const flags = regex.slice(regex.lastIndexOf("/") + 1);
|
|
231
|
-
return new RegExp(body, flags);
|
|
232
|
-
}),
|
|
233
|
-
simpleTransformation(
|
|
234
|
-
isSet,
|
|
235
|
-
"set",
|
|
236
|
-
// (sets only exist in es6+)
|
|
237
|
-
// eslint-disable-next-line es5/no-es6-methods
|
|
238
|
-
(v) => [...v.values()],
|
|
239
|
-
(v) => new Set(v)
|
|
240
|
-
),
|
|
241
|
-
simpleTransformation(isMap, "map", (v) => [...v.entries()], (v) => new Map(v)),
|
|
242
|
-
simpleTransformation((v) => isNaNValue(v) || isInfinite(v), "number", (v) => {
|
|
243
|
-
if (isNaNValue(v)) {
|
|
244
|
-
return "NaN";
|
|
245
|
-
}
|
|
246
|
-
if (v > 0) {
|
|
247
|
-
return "Infinity";
|
|
248
|
-
} else {
|
|
249
|
-
return "-Infinity";
|
|
250
|
-
}
|
|
251
|
-
}, Number),
|
|
252
|
-
simpleTransformation((v) => v === 0 && 1 / v === -Infinity, "number", () => {
|
|
253
|
-
return "-0";
|
|
254
|
-
}, Number),
|
|
255
|
-
simpleTransformation(isURL, "URL", (v) => v.toString(), (v) => new URL(v))
|
|
256
|
-
];
|
|
257
|
-
function compositeTransformation(isApplicable, annotation, transform, untransform) {
|
|
258
|
-
return {
|
|
259
|
-
isApplicable,
|
|
260
|
-
annotation,
|
|
261
|
-
transform,
|
|
262
|
-
untransform
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
var symbolRule = compositeTransformation((s, superJson) => {
|
|
266
|
-
if (isSymbol(s)) {
|
|
267
|
-
const isRegistered = !!superJson.symbolRegistry.getIdentifier(s);
|
|
268
|
-
return isRegistered;
|
|
269
|
-
}
|
|
270
|
-
return false;
|
|
271
|
-
}, (s, superJson) => {
|
|
272
|
-
const identifier = superJson.symbolRegistry.getIdentifier(s);
|
|
273
|
-
return ["symbol", identifier];
|
|
274
|
-
}, (v) => v.description, (_, a, superJson) => {
|
|
275
|
-
const value = superJson.symbolRegistry.getValue(a[1]);
|
|
276
|
-
if (!value) {
|
|
277
|
-
throw new Error("Trying to deserialize unknown symbol");
|
|
278
|
-
}
|
|
279
|
-
return value;
|
|
280
|
-
});
|
|
281
|
-
var constructorToName = [
|
|
282
|
-
Int8Array,
|
|
283
|
-
Uint8Array,
|
|
284
|
-
Int16Array,
|
|
285
|
-
Uint16Array,
|
|
286
|
-
Int32Array,
|
|
287
|
-
Uint32Array,
|
|
288
|
-
Float32Array,
|
|
289
|
-
Float64Array,
|
|
290
|
-
Uint8ClampedArray
|
|
291
|
-
].reduce((obj, ctor) => {
|
|
292
|
-
obj[ctor.name] = ctor;
|
|
293
|
-
return obj;
|
|
294
|
-
}, {});
|
|
295
|
-
var typedArrayRule = compositeTransformation(isTypedArray, (v) => ["typed-array", v.constructor.name], (v) => [...v], (v, a) => {
|
|
296
|
-
const ctor = constructorToName[a[1]];
|
|
297
|
-
if (!ctor) {
|
|
298
|
-
throw new Error("Trying to deserialize unknown typed array");
|
|
299
|
-
}
|
|
300
|
-
return new ctor(v);
|
|
301
|
-
});
|
|
302
|
-
function isInstanceOfRegisteredClass(potentialClass, superJson) {
|
|
303
|
-
if (potentialClass?.constructor) {
|
|
304
|
-
const isRegistered = !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
|
|
305
|
-
return isRegistered;
|
|
306
|
-
}
|
|
307
|
-
return false;
|
|
308
|
-
}
|
|
309
|
-
var classRule = compositeTransformation(isInstanceOfRegisteredClass, (clazz, superJson) => {
|
|
310
|
-
const identifier = superJson.classRegistry.getIdentifier(clazz.constructor);
|
|
311
|
-
return ["class", identifier];
|
|
312
|
-
}, (clazz, superJson) => {
|
|
313
|
-
const allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
|
|
314
|
-
if (!allowedProps) {
|
|
315
|
-
return { ...clazz };
|
|
316
|
-
}
|
|
317
|
-
const result = {};
|
|
318
|
-
allowedProps.forEach((prop) => {
|
|
319
|
-
result[prop] = clazz[prop];
|
|
320
|
-
});
|
|
321
|
-
return result;
|
|
322
|
-
}, (v, a, superJson) => {
|
|
323
|
-
const clazz = superJson.classRegistry.getValue(a[1]);
|
|
324
|
-
if (!clazz) {
|
|
325
|
-
throw new Error(`Trying to deserialize unknown class '${a[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
|
|
326
|
-
}
|
|
327
|
-
return Object.assign(Object.create(clazz.prototype), v);
|
|
328
|
-
});
|
|
329
|
-
var customRule = compositeTransformation((value, superJson) => {
|
|
330
|
-
return !!superJson.customTransformerRegistry.findApplicable(value);
|
|
331
|
-
}, (value, superJson) => {
|
|
332
|
-
const transformer = superJson.customTransformerRegistry.findApplicable(value);
|
|
333
|
-
return ["custom", transformer.name];
|
|
334
|
-
}, (value, superJson) => {
|
|
335
|
-
const transformer = superJson.customTransformerRegistry.findApplicable(value);
|
|
336
|
-
return transformer.serialize(value);
|
|
337
|
-
}, (v, a, superJson) => {
|
|
338
|
-
const transformer = superJson.customTransformerRegistry.findByName(a[1]);
|
|
339
|
-
if (!transformer) {
|
|
340
|
-
throw new Error("Trying to deserialize unknown custom value");
|
|
341
|
-
}
|
|
342
|
-
return transformer.deserialize(v);
|
|
343
|
-
});
|
|
344
|
-
var compositeRules = [classRule, symbolRule, customRule, typedArrayRule];
|
|
345
|
-
var transformValue = (value, superJson) => {
|
|
346
|
-
const applicableCompositeRule = findArr(compositeRules, (rule) => rule.isApplicable(value, superJson));
|
|
347
|
-
if (applicableCompositeRule) {
|
|
348
|
-
return {
|
|
349
|
-
value: applicableCompositeRule.transform(value, superJson),
|
|
350
|
-
type: applicableCompositeRule.annotation(value, superJson)
|
|
351
|
-
};
|
|
173
|
+
this[_a7] = true;
|
|
174
|
+
this.text = text;
|
|
352
175
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
return {
|
|
356
|
-
value: applicableSimpleRule.transform(value, superJson),
|
|
357
|
-
type: applicableSimpleRule.annotation
|
|
358
|
-
};
|
|
176
|
+
static isInstance(error) {
|
|
177
|
+
return AISDKError.hasMarker(error, marker7);
|
|
359
178
|
}
|
|
360
|
-
return void 0;
|
|
361
179
|
};
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
var
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
case "typed-array":
|
|
376
|
-
return typedArrayRule.untransform(json, type, superJson);
|
|
377
|
-
default:
|
|
378
|
-
throw new Error("Unknown transformation: " + type);
|
|
379
|
-
}
|
|
380
|
-
} else {
|
|
381
|
-
const transformation = simpleRulesByAnnotation[type];
|
|
382
|
-
if (!transformation) {
|
|
383
|
-
throw new Error("Unknown transformation: " + type);
|
|
384
|
-
}
|
|
385
|
-
return transformation.untransform(json, superJson);
|
|
180
|
+
_a7 = symbol7;
|
|
181
|
+
var name7 = "AI_LoadAPIKeyError";
|
|
182
|
+
var marker8 = `vercel.ai.error.${name7}`;
|
|
183
|
+
var symbol8 = Symbol.for(marker8);
|
|
184
|
+
var _a8;
|
|
185
|
+
var LoadAPIKeyError = class extends AISDKError {
|
|
186
|
+
// used in isInstance
|
|
187
|
+
constructor({ message }) {
|
|
188
|
+
super({ name: name7, message });
|
|
189
|
+
this[_a8] = true;
|
|
190
|
+
}
|
|
191
|
+
static isInstance(error) {
|
|
192
|
+
return AISDKError.hasMarker(error, marker8);
|
|
386
193
|
}
|
|
387
194
|
};
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
var
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
if (includes(path, "constructor")) {
|
|
408
|
-
throw new Error("constructor is not allowed as a property");
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
var getDeep = (object, path) => {
|
|
412
|
-
validatePath(path);
|
|
413
|
-
for (let i = 0; i < path.length; i++) {
|
|
414
|
-
const key = path[i];
|
|
415
|
-
if (isSet(object)) {
|
|
416
|
-
object = getNthKey(object, +key);
|
|
417
|
-
} else if (isMap(object)) {
|
|
418
|
-
const row = +key;
|
|
419
|
-
const type = +path[++i] === 0 ? "key" : "value";
|
|
420
|
-
const keyOfRow = getNthKey(object, row);
|
|
421
|
-
switch (type) {
|
|
422
|
-
case "key":
|
|
423
|
-
object = keyOfRow;
|
|
424
|
-
break;
|
|
425
|
-
case "value":
|
|
426
|
-
object = object.get(keyOfRow);
|
|
427
|
-
break;
|
|
428
|
-
}
|
|
429
|
-
} else {
|
|
430
|
-
object = object[key];
|
|
431
|
-
}
|
|
195
|
+
_a8 = symbol8;
|
|
196
|
+
var name10 = "AI_NoSuchModelError";
|
|
197
|
+
var marker11 = `vercel.ai.error.${name10}`;
|
|
198
|
+
var symbol11 = Symbol.for(marker11);
|
|
199
|
+
var _a11;
|
|
200
|
+
var NoSuchModelError = class extends AISDKError {
|
|
201
|
+
constructor({
|
|
202
|
+
errorName = name10,
|
|
203
|
+
modelId,
|
|
204
|
+
modelType,
|
|
205
|
+
message = `No such ${modelType}: ${modelId}`
|
|
206
|
+
}) {
|
|
207
|
+
super({ name: errorName, message });
|
|
208
|
+
this[_a11] = true;
|
|
209
|
+
this.modelId = modelId;
|
|
210
|
+
this.modelType = modelType;
|
|
211
|
+
}
|
|
212
|
+
static isInstance(error) {
|
|
213
|
+
return AISDKError.hasMarker(error, marker11);
|
|
432
214
|
}
|
|
433
|
-
return object;
|
|
434
215
|
};
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
} else if (isMap(parent)) {
|
|
452
|
-
const isEnd = i === path.length - 2;
|
|
453
|
-
if (isEnd) {
|
|
454
|
-
break;
|
|
455
|
-
}
|
|
456
|
-
const row = +key;
|
|
457
|
-
const type = +path[++i] === 0 ? "key" : "value";
|
|
458
|
-
const keyOfRow = getNthKey(parent, row);
|
|
459
|
-
switch (type) {
|
|
460
|
-
case "key":
|
|
461
|
-
parent = keyOfRow;
|
|
462
|
-
break;
|
|
463
|
-
case "value":
|
|
464
|
-
parent = parent.get(keyOfRow);
|
|
465
|
-
break;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
const lastKey = path[path.length - 1];
|
|
470
|
-
if (isArray(parent)) {
|
|
471
|
-
parent[+lastKey] = mapper(parent[+lastKey]);
|
|
472
|
-
} else if (isPlainObject(parent)) {
|
|
473
|
-
parent[lastKey] = mapper(parent[lastKey]);
|
|
474
|
-
}
|
|
475
|
-
if (isSet(parent)) {
|
|
476
|
-
const oldValue = getNthKey(parent, +lastKey);
|
|
477
|
-
const newValue = mapper(oldValue);
|
|
478
|
-
if (oldValue !== newValue) {
|
|
479
|
-
parent.delete(oldValue);
|
|
480
|
-
parent.add(newValue);
|
|
481
|
-
}
|
|
216
|
+
_a11 = symbol11;
|
|
217
|
+
var name11 = "AI_TooManyEmbeddingValuesForCallError";
|
|
218
|
+
var marker12 = `vercel.ai.error.${name11}`;
|
|
219
|
+
var symbol12 = Symbol.for(marker12);
|
|
220
|
+
var _a12;
|
|
221
|
+
var TooManyEmbeddingValuesForCallError = class extends AISDKError {
|
|
222
|
+
constructor(options) {
|
|
223
|
+
super({
|
|
224
|
+
name: name11,
|
|
225
|
+
message: `Too many values for a single embedding call. The ${options.provider} model "${options.modelId}" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`
|
|
226
|
+
});
|
|
227
|
+
this[_a12] = true;
|
|
228
|
+
this.provider = options.provider;
|
|
229
|
+
this.modelId = options.modelId;
|
|
230
|
+
this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
|
|
231
|
+
this.values = options.values;
|
|
482
232
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
const keyToRow = getNthKey(parent, row);
|
|
486
|
-
const type = +lastKey === 0 ? "key" : "value";
|
|
487
|
-
switch (type) {
|
|
488
|
-
case "key": {
|
|
489
|
-
const newKey = mapper(keyToRow);
|
|
490
|
-
parent.set(newKey, parent.get(keyToRow));
|
|
491
|
-
if (newKey !== keyToRow) {
|
|
492
|
-
parent.delete(keyToRow);
|
|
493
|
-
}
|
|
494
|
-
break;
|
|
495
|
-
}
|
|
496
|
-
case "value": {
|
|
497
|
-
parent.set(keyToRow, mapper(parent.get(keyToRow)));
|
|
498
|
-
break;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
233
|
+
static isInstance(error) {
|
|
234
|
+
return AISDKError.hasMarker(error, marker12);
|
|
501
235
|
}
|
|
502
|
-
return object;
|
|
503
236
|
};
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
forEach(children, (child, key) => {
|
|
517
|
-
traverse(child, walker2, [...origin, ...parsePath(key)]);
|
|
237
|
+
_a12 = symbol12;
|
|
238
|
+
var name12 = "AI_TypeValidationError";
|
|
239
|
+
var marker13 = `vercel.ai.error.${name12}`;
|
|
240
|
+
var symbol13 = Symbol.for(marker13);
|
|
241
|
+
var _a13;
|
|
242
|
+
var _TypeValidationError = class _TypeValidationError2 extends AISDKError {
|
|
243
|
+
constructor({ value, cause }) {
|
|
244
|
+
super({
|
|
245
|
+
name: name12,
|
|
246
|
+
message: `Type validation failed: Value: ${JSON.stringify(value)}.
|
|
247
|
+
Error message: ${getErrorMessage(cause)}`,
|
|
248
|
+
cause
|
|
518
249
|
});
|
|
250
|
+
this[_a13] = true;
|
|
251
|
+
this.value = value;
|
|
519
252
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
function applyValueAnnotations(plain, annotations, superJson) {
|
|
523
|
-
traverse(annotations, (type, path) => {
|
|
524
|
-
plain = setDeep(plain, path, (v) => untransformValue(v, type, superJson));
|
|
525
|
-
});
|
|
526
|
-
return plain;
|
|
527
|
-
}
|
|
528
|
-
function applyReferentialEqualityAnnotations(plain, annotations) {
|
|
529
|
-
function apply(identicalPaths, path) {
|
|
530
|
-
const object = getDeep(plain, parsePath(path));
|
|
531
|
-
identicalPaths.map(parsePath).forEach((identicalObjectPath) => {
|
|
532
|
-
plain = setDeep(plain, identicalObjectPath, () => object);
|
|
533
|
-
});
|
|
253
|
+
static isInstance(error) {
|
|
254
|
+
return AISDKError.hasMarker(error, marker13);
|
|
534
255
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Wraps an error into a TypeValidationError.
|
|
258
|
+
* If the cause is already a TypeValidationError with the same value, it returns the cause.
|
|
259
|
+
* Otherwise, it creates a new TypeValidationError.
|
|
260
|
+
*
|
|
261
|
+
* @param {Object} params - The parameters for wrapping the error.
|
|
262
|
+
* @param {unknown} params.value - The value that failed validation.
|
|
263
|
+
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
264
|
+
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
265
|
+
*/
|
|
266
|
+
static wrap({
|
|
267
|
+
value,
|
|
268
|
+
cause
|
|
269
|
+
}) {
|
|
270
|
+
return _TypeValidationError2.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError2({ value, cause });
|
|
545
271
|
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
var
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
272
|
+
};
|
|
273
|
+
_a13 = symbol13;
|
|
274
|
+
var TypeValidationError = _TypeValidationError;
|
|
275
|
+
var name13 = "AI_UnsupportedFunctionalityError";
|
|
276
|
+
var marker14 = `vercel.ai.error.${name13}`;
|
|
277
|
+
var symbol14 = Symbol.for(marker14);
|
|
278
|
+
var _a14;
|
|
279
|
+
var UnsupportedFunctionalityError = class extends AISDKError {
|
|
280
|
+
constructor({
|
|
281
|
+
functionality,
|
|
282
|
+
message = `'${functionality}' functionality not supported.`
|
|
283
|
+
}) {
|
|
284
|
+
super({ name: name13, message });
|
|
285
|
+
this[_a14] = true;
|
|
286
|
+
this.functionality = functionality;
|
|
287
|
+
}
|
|
288
|
+
static isInstance(error) {
|
|
289
|
+
return AISDKError.hasMarker(error, marker14);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
_a14 = symbol14;
|
|
293
|
+
|
|
294
|
+
// ../../node_modules/.pnpm/eventsource-parser@3.0.6/node_modules/eventsource-parser/dist/index.js
|
|
295
|
+
var ParseError = class extends Error {
|
|
296
|
+
constructor(message, options) {
|
|
297
|
+
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
555
298
|
}
|
|
299
|
+
};
|
|
300
|
+
function noop(_arg) {
|
|
556
301
|
}
|
|
557
|
-
function
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
302
|
+
function createParser(callbacks) {
|
|
303
|
+
if (typeof callbacks == "function")
|
|
304
|
+
throw new TypeError(
|
|
305
|
+
"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
|
|
306
|
+
);
|
|
307
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
|
|
308
|
+
let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = "";
|
|
309
|
+
function feed(newChunk) {
|
|
310
|
+
const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`);
|
|
311
|
+
for (const line of complete)
|
|
312
|
+
parseLine(line);
|
|
313
|
+
incompleteLine = incomplete, isFirstChunk = false;
|
|
314
|
+
}
|
|
315
|
+
function parseLine(line) {
|
|
316
|
+
if (line === "") {
|
|
317
|
+
dispatchEvent();
|
|
562
318
|
return;
|
|
563
319
|
}
|
|
564
|
-
if (
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
const [representativePath, ...identicalPaths] = paths;
|
|
568
|
-
if (representativePath.length === 0) {
|
|
569
|
-
rootEqualityPaths = identicalPaths.map(stringifyPath);
|
|
570
|
-
} else {
|
|
571
|
-
result[stringifyPath(representativePath)] = identicalPaths.map(stringifyPath);
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
if (rootEqualityPaths) {
|
|
575
|
-
if (isEmptyObject(result)) {
|
|
576
|
-
return [rootEqualityPaths];
|
|
577
|
-
} else {
|
|
578
|
-
return [rootEqualityPaths, result];
|
|
320
|
+
if (line.startsWith(":")) {
|
|
321
|
+
onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
|
|
322
|
+
return;
|
|
579
323
|
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
const primitive = isPrimitive(object);
|
|
586
|
-
if (!primitive) {
|
|
587
|
-
addIdentity(object, path, identities);
|
|
588
|
-
const seen = seenObjects.get(object);
|
|
589
|
-
if (seen) {
|
|
590
|
-
return dedupe ? {
|
|
591
|
-
transformedValue: null
|
|
592
|
-
} : seen;
|
|
324
|
+
const fieldSeparatorIndex = line.indexOf(":");
|
|
325
|
+
if (fieldSeparatorIndex !== -1) {
|
|
326
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
327
|
+
processField(field, value, line);
|
|
328
|
+
return;
|
|
593
329
|
}
|
|
330
|
+
processField(line, "", line);
|
|
594
331
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
332
|
+
function processField(field, value, line) {
|
|
333
|
+
switch (field) {
|
|
334
|
+
case "event":
|
|
335
|
+
eventType = value;
|
|
336
|
+
break;
|
|
337
|
+
case "data":
|
|
338
|
+
data = `${data}${value}
|
|
339
|
+
`;
|
|
340
|
+
break;
|
|
341
|
+
case "id":
|
|
342
|
+
id = value.includes("\0") ? void 0 : value;
|
|
343
|
+
break;
|
|
344
|
+
case "retry":
|
|
345
|
+
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
|
|
346
|
+
new ParseError(`Invalid \`retry\` value: "${value}"`, {
|
|
347
|
+
type: "invalid-retry",
|
|
348
|
+
value,
|
|
349
|
+
line
|
|
350
|
+
})
|
|
351
|
+
);
|
|
352
|
+
break;
|
|
353
|
+
default:
|
|
354
|
+
onError(
|
|
355
|
+
new ParseError(
|
|
356
|
+
`Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
|
|
357
|
+
{ type: "unknown-field", field, value, line }
|
|
358
|
+
)
|
|
359
|
+
);
|
|
360
|
+
break;
|
|
605
361
|
}
|
|
606
|
-
return result2;
|
|
607
362
|
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
forEach(transformed, (value, index) => {
|
|
618
|
-
if (index === "__proto__" || index === "constructor" || index === "prototype") {
|
|
619
|
-
throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
|
|
620
|
-
}
|
|
621
|
-
const recursiveResult = walker(value, identities, superJson, dedupe, [...path, index], [...objectsInThisPath, object], seenObjects);
|
|
622
|
-
transformedValue[index] = recursiveResult.transformedValue;
|
|
623
|
-
if (isArray(recursiveResult.annotations)) {
|
|
624
|
-
innerAnnotations[index] = recursiveResult.annotations;
|
|
625
|
-
} else if (isPlainObject(recursiveResult.annotations)) {
|
|
626
|
-
forEach(recursiveResult.annotations, (tree, key) => {
|
|
627
|
-
innerAnnotations[escapeKey(index) + "." + key] = tree;
|
|
628
|
-
});
|
|
629
|
-
}
|
|
630
|
-
});
|
|
631
|
-
const result = isEmptyObject(innerAnnotations) ? {
|
|
632
|
-
transformedValue,
|
|
633
|
-
annotations: !!transformationResult ? [transformationResult.type] : void 0
|
|
634
|
-
} : {
|
|
635
|
-
transformedValue,
|
|
636
|
-
annotations: !!transformationResult ? [transformationResult.type, innerAnnotations] : innerAnnotations
|
|
637
|
-
};
|
|
638
|
-
if (!primitive) {
|
|
639
|
-
seenObjects.set(object, result);
|
|
363
|
+
function dispatchEvent() {
|
|
364
|
+
data.length > 0 && onEvent({
|
|
365
|
+
id,
|
|
366
|
+
event: eventType || void 0,
|
|
367
|
+
// If the data buffer's last character is a U+000A LINE FEED (LF) character,
|
|
368
|
+
// then remove the last character from the data buffer.
|
|
369
|
+
data: data.endsWith(`
|
|
370
|
+
`) ? data.slice(0, -1) : data
|
|
371
|
+
}), id = void 0, data = "", eventType = "";
|
|
640
372
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
// ../../node_modules/.pnpm/is-what@4.1.16/node_modules/is-what/dist/index.js
|
|
645
|
-
function getType2(payload) {
|
|
646
|
-
return Object.prototype.toString.call(payload).slice(8, -1);
|
|
647
|
-
}
|
|
648
|
-
function isArray2(payload) {
|
|
649
|
-
return getType2(payload) === "Array";
|
|
650
|
-
}
|
|
651
|
-
function isPlainObject2(payload) {
|
|
652
|
-
if (getType2(payload) !== "Object")
|
|
653
|
-
return false;
|
|
654
|
-
const prototype = Object.getPrototypeOf(payload);
|
|
655
|
-
return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
// ../../node_modules/.pnpm/copy-anything@3.0.5/node_modules/copy-anything/dist/index.js
|
|
659
|
-
function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
|
|
660
|
-
const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
|
|
661
|
-
if (propType === "enumerable")
|
|
662
|
-
carry[key] = newVal;
|
|
663
|
-
if (includeNonenumerable && propType === "nonenumerable") {
|
|
664
|
-
Object.defineProperty(carry, key, {
|
|
665
|
-
value: newVal,
|
|
666
|
-
enumerable: false,
|
|
667
|
-
writable: true,
|
|
668
|
-
configurable: true
|
|
669
|
-
});
|
|
373
|
+
function reset(options = {}) {
|
|
374
|
+
incompleteLine && options.consume && parseLine(incompleteLine), isFirstChunk = true, id = void 0, data = "", eventType = "", incompleteLine = "";
|
|
670
375
|
}
|
|
376
|
+
return { feed, reset };
|
|
671
377
|
}
|
|
672
|
-
function
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
378
|
+
function splitLines(chunk) {
|
|
379
|
+
const lines = [];
|
|
380
|
+
let incompleteLine = "", searchIndex = 0;
|
|
381
|
+
for (; searchIndex < chunk.length; ) {
|
|
382
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
383
|
+
`, searchIndex);
|
|
384
|
+
let lineEnd = -1;
|
|
385
|
+
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
|
|
386
|
+
incompleteLine = chunk.slice(searchIndex);
|
|
387
|
+
break;
|
|
388
|
+
} else {
|
|
389
|
+
const line = chunk.slice(searchIndex, lineEnd);
|
|
390
|
+
lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
|
|
391
|
+
` && searchIndex++;
|
|
684
392
|
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
assignProp(carry, key, newVal, target, options.nonenumerable);
|
|
688
|
-
return carry;
|
|
689
|
-
}, {});
|
|
393
|
+
}
|
|
394
|
+
return [lines, incompleteLine];
|
|
690
395
|
}
|
|
691
396
|
|
|
692
|
-
// ../../node_modules/.pnpm/
|
|
693
|
-
var
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
...res.meta,
|
|
713
|
-
values: output.annotations
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
const equalityAnnotations = generateReferentialEqualityAnnotations(identities, this.dedupe);
|
|
717
|
-
if (equalityAnnotations) {
|
|
718
|
-
res.meta = {
|
|
719
|
-
...res.meta,
|
|
720
|
-
referentialEqualities: equalityAnnotations
|
|
721
|
-
};
|
|
722
|
-
}
|
|
723
|
-
return res;
|
|
724
|
-
}
|
|
725
|
-
deserialize(payload) {
|
|
726
|
-
const { json, meta } = payload;
|
|
727
|
-
let result = copy(json);
|
|
728
|
-
if (meta?.values) {
|
|
729
|
-
result = applyValueAnnotations(result, meta.values, this);
|
|
730
|
-
}
|
|
731
|
-
if (meta?.referentialEqualities) {
|
|
732
|
-
result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities);
|
|
733
|
-
}
|
|
734
|
-
return result;
|
|
735
|
-
}
|
|
736
|
-
stringify(object) {
|
|
737
|
-
return JSON.stringify(this.serialize(object));
|
|
738
|
-
}
|
|
739
|
-
parse(string) {
|
|
740
|
-
return this.deserialize(JSON.parse(string));
|
|
741
|
-
}
|
|
742
|
-
registerClass(v, options) {
|
|
743
|
-
this.classRegistry.register(v, options);
|
|
744
|
-
}
|
|
745
|
-
registerSymbol(v, identifier) {
|
|
746
|
-
this.symbolRegistry.register(v, identifier);
|
|
747
|
-
}
|
|
748
|
-
registerCustom(transformer, name) {
|
|
749
|
-
this.customTransformerRegistry.register({
|
|
750
|
-
name,
|
|
751
|
-
...transformer
|
|
397
|
+
// ../../node_modules/.pnpm/eventsource-parser@3.0.6/node_modules/eventsource-parser/dist/stream.js
|
|
398
|
+
var EventSourceParserStream = class extends TransformStream {
|
|
399
|
+
constructor({ onError, onRetry, onComment } = {}) {
|
|
400
|
+
let parser;
|
|
401
|
+
super({
|
|
402
|
+
start(controller) {
|
|
403
|
+
parser = createParser({
|
|
404
|
+
onEvent: (event) => {
|
|
405
|
+
controller.enqueue(event);
|
|
406
|
+
},
|
|
407
|
+
onError(error) {
|
|
408
|
+
onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error);
|
|
409
|
+
},
|
|
410
|
+
onRetry,
|
|
411
|
+
onComment
|
|
412
|
+
});
|
|
413
|
+
},
|
|
414
|
+
transform(chunk) {
|
|
415
|
+
parser.feed(chunk);
|
|
416
|
+
}
|
|
752
417
|
});
|
|
753
418
|
}
|
|
754
|
-
allowErrorProps(...props) {
|
|
755
|
-
this.allowedErrorProps.push(...props);
|
|
756
|
-
}
|
|
757
419
|
};
|
|
758
|
-
SuperJSON.defaultInstance = new SuperJSON();
|
|
759
|
-
SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
|
|
760
|
-
SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
|
|
761
|
-
SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
|
|
762
|
-
SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
|
|
763
|
-
SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
|
|
764
|
-
SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
|
|
765
|
-
SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
|
|
766
|
-
SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
|
|
767
|
-
var stringify = SuperJSON.stringify;
|
|
768
420
|
|
|
769
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
421
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
770
422
|
var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
771
423
|
var defaultOptions = {
|
|
772
424
|
name: void 0,
|
|
@@ -789,7 +441,8 @@ var defaultOptions = {
|
|
|
789
441
|
applyRegexFlags: false,
|
|
790
442
|
emailStrategy: "format:email",
|
|
791
443
|
base64Strategy: "contentEncoding:base64",
|
|
792
|
-
nameStrategy: "ref"
|
|
444
|
+
nameStrategy: "ref",
|
|
445
|
+
openAiAnyTypeName: "OpenAiAnyType"
|
|
793
446
|
};
|
|
794
447
|
var getDefaultOptions = (options) => typeof options === "string" ? {
|
|
795
448
|
...defaultOptions,
|
|
@@ -799,19 +452,20 @@ var getDefaultOptions = (options) => typeof options === "string" ? {
|
|
|
799
452
|
...options
|
|
800
453
|
};
|
|
801
454
|
|
|
802
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
455
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Refs.js
|
|
803
456
|
var getRefs = (options) => {
|
|
804
457
|
const _options = getDefaultOptions(options);
|
|
805
458
|
const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
806
459
|
return {
|
|
807
460
|
..._options,
|
|
461
|
+
flags: { hasReferencedOpenAiAnyType: false },
|
|
808
462
|
currentPath,
|
|
809
463
|
propertyPath: void 0,
|
|
810
|
-
seen: new Map(Object.entries(_options.definitions).map(([
|
|
464
|
+
seen: new Map(Object.entries(_options.definitions).map(([name14, def]) => [
|
|
811
465
|
def._def,
|
|
812
466
|
{
|
|
813
467
|
def: def._def,
|
|
814
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
468
|
+
path: [..._options.basePath, _options.definitionPath, name14],
|
|
815
469
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
816
470
|
jsonSchema: void 0
|
|
817
471
|
}
|
|
@@ -819,7 +473,7 @@ var getRefs = (options) => {
|
|
|
819
473
|
};
|
|
820
474
|
};
|
|
821
475
|
|
|
822
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
476
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
|
|
823
477
|
function addErrorMessage(res, key, errorMessage, refs) {
|
|
824
478
|
if (!refs?.errorMessages)
|
|
825
479
|
return;
|
|
@@ -835,9 +489,30 @@ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
|
835
489
|
addErrorMessage(res, key, errorMessage, refs);
|
|
836
490
|
}
|
|
837
491
|
|
|
838
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
839
|
-
|
|
840
|
-
|
|
492
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
|
|
493
|
+
var getRelativePath = (pathA, pathB) => {
|
|
494
|
+
let i = 0;
|
|
495
|
+
for (; i < pathA.length && i < pathB.length; i++) {
|
|
496
|
+
if (pathA[i] !== pathB[i])
|
|
497
|
+
break;
|
|
498
|
+
}
|
|
499
|
+
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/any.js
|
|
503
|
+
function parseAnyDef(refs) {
|
|
504
|
+
if (refs.target !== "openAi") {
|
|
505
|
+
return {};
|
|
506
|
+
}
|
|
507
|
+
const anyDefinitionPath = [
|
|
508
|
+
...refs.basePath,
|
|
509
|
+
refs.definitionPath,
|
|
510
|
+
refs.openAiAnyTypeName
|
|
511
|
+
];
|
|
512
|
+
refs.flags.hasReferencedOpenAiAnyType = true;
|
|
513
|
+
return {
|
|
514
|
+
$ref: refs.$refStrategy === "relative" ? getRelativePath(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join("/")
|
|
515
|
+
};
|
|
841
516
|
}
|
|
842
517
|
function parseArrayDef(def, refs) {
|
|
843
518
|
const res = {
|
|
@@ -862,7 +537,7 @@ function parseArrayDef(def, refs) {
|
|
|
862
537
|
return res;
|
|
863
538
|
}
|
|
864
539
|
|
|
865
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
540
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
|
|
866
541
|
function parseBigintDef(def, refs) {
|
|
867
542
|
const res = {
|
|
868
543
|
type: "integer",
|
|
@@ -908,24 +583,24 @@ function parseBigintDef(def, refs) {
|
|
|
908
583
|
return res;
|
|
909
584
|
}
|
|
910
585
|
|
|
911
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
586
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
|
|
912
587
|
function parseBooleanDef() {
|
|
913
588
|
return {
|
|
914
589
|
type: "boolean"
|
|
915
590
|
};
|
|
916
591
|
}
|
|
917
592
|
|
|
918
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
593
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
|
|
919
594
|
function parseBrandedDef(_def, refs) {
|
|
920
595
|
return parseDef(_def.type._def, refs);
|
|
921
596
|
}
|
|
922
597
|
|
|
923
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
598
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
|
|
924
599
|
var parseCatchDef = (def, refs) => {
|
|
925
600
|
return parseDef(def.innerType._def, refs);
|
|
926
601
|
};
|
|
927
602
|
|
|
928
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
603
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
|
|
929
604
|
function parseDateDef(def, refs, overrideDateStrategy) {
|
|
930
605
|
const strategy = overrideDateStrategy ?? refs.dateStrategy;
|
|
931
606
|
if (Array.isArray(strategy)) {
|
|
@@ -984,7 +659,7 @@ var integerDateParser = (def, refs) => {
|
|
|
984
659
|
return res;
|
|
985
660
|
};
|
|
986
661
|
|
|
987
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
662
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/default.js
|
|
988
663
|
function parseDefaultDef(_def, refs) {
|
|
989
664
|
return {
|
|
990
665
|
...parseDef(_def.innerType._def, refs),
|
|
@@ -992,12 +667,12 @@ function parseDefaultDef(_def, refs) {
|
|
|
992
667
|
};
|
|
993
668
|
}
|
|
994
669
|
|
|
995
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
670
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
|
|
996
671
|
function parseEffectsDef(_def, refs) {
|
|
997
|
-
return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) :
|
|
672
|
+
return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
|
|
998
673
|
}
|
|
999
674
|
|
|
1000
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
675
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
|
|
1001
676
|
function parseEnumDef(def) {
|
|
1002
677
|
return {
|
|
1003
678
|
type: "string",
|
|
@@ -1005,7 +680,7 @@ function parseEnumDef(def) {
|
|
|
1005
680
|
};
|
|
1006
681
|
}
|
|
1007
682
|
|
|
1008
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
683
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
|
|
1009
684
|
var isJsonSchema7AllOfType = (type) => {
|
|
1010
685
|
if ("type" in type && type.type === "string")
|
|
1011
686
|
return false;
|
|
@@ -1047,7 +722,7 @@ function parseIntersectionDef(def, refs) {
|
|
|
1047
722
|
} : void 0;
|
|
1048
723
|
}
|
|
1049
724
|
|
|
1050
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
725
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
|
|
1051
726
|
function parseLiteralDef(def, refs) {
|
|
1052
727
|
const parsedType = typeof def.value;
|
|
1053
728
|
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
|
|
@@ -1067,7 +742,7 @@ function parseLiteralDef(def, refs) {
|
|
|
1067
742
|
};
|
|
1068
743
|
}
|
|
1069
744
|
|
|
1070
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
745
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
1071
746
|
var emojiRegex = void 0;
|
|
1072
747
|
var zodPatterns = {
|
|
1073
748
|
/**
|
|
@@ -1379,7 +1054,7 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
1379
1054
|
return pattern;
|
|
1380
1055
|
}
|
|
1381
1056
|
|
|
1382
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1057
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
1383
1058
|
function parseRecordDef(def, refs) {
|
|
1384
1059
|
if (refs.target === "openAi") {
|
|
1385
1060
|
console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
|
@@ -1393,7 +1068,7 @@ function parseRecordDef(def, refs) {
|
|
|
1393
1068
|
[key]: parseDef(def.valueType._def, {
|
|
1394
1069
|
...refs,
|
|
1395
1070
|
currentPath: [...refs.currentPath, "properties", key]
|
|
1396
|
-
}) ??
|
|
1071
|
+
}) ?? parseAnyDef(refs)
|
|
1397
1072
|
}), {}),
|
|
1398
1073
|
additionalProperties: refs.rejectedAdditionalProperties
|
|
1399
1074
|
};
|
|
@@ -1431,7 +1106,7 @@ function parseRecordDef(def, refs) {
|
|
|
1431
1106
|
return schema;
|
|
1432
1107
|
}
|
|
1433
1108
|
|
|
1434
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1109
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
|
|
1435
1110
|
function parseMapDef(def, refs) {
|
|
1436
1111
|
if (refs.mapStrategy === "record") {
|
|
1437
1112
|
return parseRecordDef(def, refs);
|
|
@@ -1439,11 +1114,11 @@ function parseMapDef(def, refs) {
|
|
|
1439
1114
|
const keys = parseDef(def.keyType._def, {
|
|
1440
1115
|
...refs,
|
|
1441
1116
|
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
1442
|
-
}) ||
|
|
1117
|
+
}) || parseAnyDef(refs);
|
|
1443
1118
|
const values = parseDef(def.valueType._def, {
|
|
1444
1119
|
...refs,
|
|
1445
1120
|
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
1446
|
-
}) ||
|
|
1121
|
+
}) || parseAnyDef(refs);
|
|
1447
1122
|
return {
|
|
1448
1123
|
type: "array",
|
|
1449
1124
|
maxItems: 125,
|
|
@@ -1456,7 +1131,7 @@ function parseMapDef(def, refs) {
|
|
|
1456
1131
|
};
|
|
1457
1132
|
}
|
|
1458
1133
|
|
|
1459
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1134
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
1460
1135
|
function parseNativeEnumDef(def) {
|
|
1461
1136
|
const object = def.values;
|
|
1462
1137
|
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
@@ -1470,14 +1145,17 @@ function parseNativeEnumDef(def) {
|
|
|
1470
1145
|
};
|
|
1471
1146
|
}
|
|
1472
1147
|
|
|
1473
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1474
|
-
function parseNeverDef() {
|
|
1475
|
-
return {
|
|
1476
|
-
not: {
|
|
1148
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
|
|
1149
|
+
function parseNeverDef(refs) {
|
|
1150
|
+
return refs.target === "openAi" ? void 0 : {
|
|
1151
|
+
not: parseAnyDef({
|
|
1152
|
+
...refs,
|
|
1153
|
+
currentPath: [...refs.currentPath, "not"]
|
|
1154
|
+
})
|
|
1477
1155
|
};
|
|
1478
1156
|
}
|
|
1479
1157
|
|
|
1480
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1158
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/null.js
|
|
1481
1159
|
function parseNullDef(refs) {
|
|
1482
1160
|
return refs.target === "openApi3" ? {
|
|
1483
1161
|
enum: ["null"],
|
|
@@ -1487,7 +1165,7 @@ function parseNullDef(refs) {
|
|
|
1487
1165
|
};
|
|
1488
1166
|
}
|
|
1489
1167
|
|
|
1490
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1168
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/union.js
|
|
1491
1169
|
var primitiveMappings = {
|
|
1492
1170
|
ZodString: "string",
|
|
1493
1171
|
ZodNumber: "number",
|
|
@@ -1555,7 +1233,7 @@ var asAnyOf = (def, refs) => {
|
|
|
1555
1233
|
return anyOf.length ? { anyOf } : void 0;
|
|
1556
1234
|
};
|
|
1557
1235
|
|
|
1558
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1236
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
|
|
1559
1237
|
function parseNullableDef(def, refs) {
|
|
1560
1238
|
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
1561
1239
|
if (refs.target === "openApi3") {
|
|
@@ -1587,7 +1265,7 @@ function parseNullableDef(def, refs) {
|
|
|
1587
1265
|
return base && { anyOf: [base, { type: "null" }] };
|
|
1588
1266
|
}
|
|
1589
1267
|
|
|
1590
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1268
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
|
|
1591
1269
|
function parseNumberDef(def, refs) {
|
|
1592
1270
|
const res = {
|
|
1593
1271
|
type: "number"
|
|
@@ -1635,6 +1313,8 @@ function parseNumberDef(def, refs) {
|
|
|
1635
1313
|
}
|
|
1636
1314
|
return res;
|
|
1637
1315
|
}
|
|
1316
|
+
|
|
1317
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
|
|
1638
1318
|
function parseObjectDef(def, refs) {
|
|
1639
1319
|
const forceOptionalIntoNullable = refs.target === "openAi";
|
|
1640
1320
|
const result = {
|
|
@@ -1650,7 +1330,7 @@ function parseObjectDef(def, refs) {
|
|
|
1650
1330
|
}
|
|
1651
1331
|
let propOptional = safeIsOptional(propDef);
|
|
1652
1332
|
if (propOptional && forceOptionalIntoNullable) {
|
|
1653
|
-
if (propDef
|
|
1333
|
+
if (propDef._def.typeName === "ZodOptional") {
|
|
1654
1334
|
propDef = propDef._def.innerType;
|
|
1655
1335
|
}
|
|
1656
1336
|
if (!propDef.isNullable()) {
|
|
@@ -1704,7 +1384,7 @@ function safeIsOptional(schema) {
|
|
|
1704
1384
|
}
|
|
1705
1385
|
}
|
|
1706
1386
|
|
|
1707
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1387
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
|
|
1708
1388
|
var parseOptionalDef = (def, refs) => {
|
|
1709
1389
|
if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
|
|
1710
1390
|
return parseDef(def.innerType._def, refs);
|
|
@@ -1716,14 +1396,14 @@ var parseOptionalDef = (def, refs) => {
|
|
|
1716
1396
|
return innerSchema ? {
|
|
1717
1397
|
anyOf: [
|
|
1718
1398
|
{
|
|
1719
|
-
not:
|
|
1399
|
+
not: parseAnyDef(refs)
|
|
1720
1400
|
},
|
|
1721
1401
|
innerSchema
|
|
1722
1402
|
]
|
|
1723
|
-
} :
|
|
1403
|
+
} : parseAnyDef(refs);
|
|
1724
1404
|
};
|
|
1725
1405
|
|
|
1726
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1406
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
|
|
1727
1407
|
var parsePipelineDef = (def, refs) => {
|
|
1728
1408
|
if (refs.pipeStrategy === "input") {
|
|
1729
1409
|
return parseDef(def.in._def, refs);
|
|
@@ -1743,12 +1423,12 @@ var parsePipelineDef = (def, refs) => {
|
|
|
1743
1423
|
};
|
|
1744
1424
|
};
|
|
1745
1425
|
|
|
1746
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1426
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
|
|
1747
1427
|
function parsePromiseDef(def, refs) {
|
|
1748
1428
|
return parseDef(def.type._def, refs);
|
|
1749
1429
|
}
|
|
1750
1430
|
|
|
1751
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1431
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/set.js
|
|
1752
1432
|
function parseSetDef(def, refs) {
|
|
1753
1433
|
const items = parseDef(def.valueType._def, {
|
|
1754
1434
|
...refs,
|
|
@@ -1768,7 +1448,7 @@ function parseSetDef(def, refs) {
|
|
|
1768
1448
|
return schema;
|
|
1769
1449
|
}
|
|
1770
1450
|
|
|
1771
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1451
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
|
|
1772
1452
|
function parseTupleDef(def, refs) {
|
|
1773
1453
|
if (def.rest) {
|
|
1774
1454
|
return {
|
|
@@ -1796,24 +1476,24 @@ function parseTupleDef(def, refs) {
|
|
|
1796
1476
|
}
|
|
1797
1477
|
}
|
|
1798
1478
|
|
|
1799
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1800
|
-
function parseUndefinedDef() {
|
|
1479
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
|
|
1480
|
+
function parseUndefinedDef(refs) {
|
|
1801
1481
|
return {
|
|
1802
|
-
not:
|
|
1482
|
+
not: parseAnyDef(refs)
|
|
1803
1483
|
};
|
|
1804
1484
|
}
|
|
1805
1485
|
|
|
1806
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1807
|
-
function parseUnknownDef() {
|
|
1808
|
-
return
|
|
1486
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
|
|
1487
|
+
function parseUnknownDef(refs) {
|
|
1488
|
+
return parseAnyDef(refs);
|
|
1809
1489
|
}
|
|
1810
1490
|
|
|
1811
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1491
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
|
|
1812
1492
|
var parseReadonlyDef = (def, refs) => {
|
|
1813
1493
|
return parseDef(def.innerType._def, refs);
|
|
1814
1494
|
};
|
|
1815
1495
|
|
|
1816
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1496
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/selectParser.js
|
|
1817
1497
|
var selectParser = (def, typeName, refs) => {
|
|
1818
1498
|
switch (typeName) {
|
|
1819
1499
|
case zod.ZodFirstPartyTypeKind.ZodString:
|
|
@@ -1829,7 +1509,7 @@ var selectParser = (def, typeName, refs) => {
|
|
|
1829
1509
|
case zod.ZodFirstPartyTypeKind.ZodDate:
|
|
1830
1510
|
return parseDateDef(def, refs);
|
|
1831
1511
|
case zod.ZodFirstPartyTypeKind.ZodUndefined:
|
|
1832
|
-
return parseUndefinedDef();
|
|
1512
|
+
return parseUndefinedDef(refs);
|
|
1833
1513
|
case zod.ZodFirstPartyTypeKind.ZodNull:
|
|
1834
1514
|
return parseNullDef(refs);
|
|
1835
1515
|
case zod.ZodFirstPartyTypeKind.ZodArray:
|
|
@@ -1863,13 +1543,13 @@ var selectParser = (def, typeName, refs) => {
|
|
|
1863
1543
|
return parsePromiseDef(def, refs);
|
|
1864
1544
|
case zod.ZodFirstPartyTypeKind.ZodNaN:
|
|
1865
1545
|
case zod.ZodFirstPartyTypeKind.ZodNever:
|
|
1866
|
-
return parseNeverDef();
|
|
1546
|
+
return parseNeverDef(refs);
|
|
1867
1547
|
case zod.ZodFirstPartyTypeKind.ZodEffects:
|
|
1868
1548
|
return parseEffectsDef(def, refs);
|
|
1869
1549
|
case zod.ZodFirstPartyTypeKind.ZodAny:
|
|
1870
|
-
return parseAnyDef();
|
|
1550
|
+
return parseAnyDef(refs);
|
|
1871
1551
|
case zod.ZodFirstPartyTypeKind.ZodUnknown:
|
|
1872
|
-
return parseUnknownDef();
|
|
1552
|
+
return parseUnknownDef(refs);
|
|
1873
1553
|
case zod.ZodFirstPartyTypeKind.ZodDefault:
|
|
1874
1554
|
return parseDefaultDef(def, refs);
|
|
1875
1555
|
case zod.ZodFirstPartyTypeKind.ZodBranded:
|
|
@@ -1889,7 +1569,7 @@ var selectParser = (def, typeName, refs) => {
|
|
|
1889
1569
|
}
|
|
1890
1570
|
};
|
|
1891
1571
|
|
|
1892
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1572
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parseDef.js
|
|
1893
1573
|
function parseDef(def, refs, forceResolution = false) {
|
|
1894
1574
|
const seenItem = refs.seen.get(def);
|
|
1895
1575
|
if (refs.override) {
|
|
@@ -1929,20 +1609,12 @@ var get$ref = (item, refs) => {
|
|
|
1929
1609
|
case "seen": {
|
|
1930
1610
|
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
1931
1611
|
console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
|
|
1932
|
-
return
|
|
1612
|
+
return parseAnyDef(refs);
|
|
1933
1613
|
}
|
|
1934
|
-
return refs.$refStrategy === "seen" ?
|
|
1614
|
+
return refs.$refStrategy === "seen" ? parseAnyDef(refs) : void 0;
|
|
1935
1615
|
}
|
|
1936
1616
|
}
|
|
1937
1617
|
};
|
|
1938
|
-
var getRelativePath = (pathA, pathB) => {
|
|
1939
|
-
let i = 0;
|
|
1940
|
-
for (; i < pathA.length && i < pathB.length; i++) {
|
|
1941
|
-
if (pathA[i] !== pathB[i])
|
|
1942
|
-
break;
|
|
1943
|
-
}
|
|
1944
|
-
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
1945
|
-
};
|
|
1946
1618
|
var addMeta = (def, refs, jsonSchema) => {
|
|
1947
1619
|
if (def.description) {
|
|
1948
1620
|
jsonSchema.description = def.description;
|
|
@@ -1953,37 +1625,55 @@ var addMeta = (def, refs, jsonSchema) => {
|
|
|
1953
1625
|
return jsonSchema;
|
|
1954
1626
|
};
|
|
1955
1627
|
|
|
1956
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1628
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
|
|
1957
1629
|
var zodToJsonSchema = (schema, options) => {
|
|
1958
1630
|
const refs = getRefs(options);
|
|
1959
|
-
|
|
1631
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name15, schema2]) => ({
|
|
1960
1632
|
...acc,
|
|
1961
|
-
[
|
|
1633
|
+
[name15]: parseDef(schema2._def, {
|
|
1962
1634
|
...refs,
|
|
1963
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
1964
|
-
}, true) ??
|
|
1635
|
+
currentPath: [...refs.basePath, refs.definitionPath, name15]
|
|
1636
|
+
}, true) ?? parseAnyDef(refs)
|
|
1965
1637
|
}), {}) : void 0;
|
|
1966
|
-
const
|
|
1967
|
-
const main = parseDef(schema._def,
|
|
1638
|
+
const name14 = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
|
|
1639
|
+
const main = parseDef(schema._def, name14 === void 0 ? refs : {
|
|
1968
1640
|
...refs,
|
|
1969
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
1970
|
-
}, false) ??
|
|
1641
|
+
currentPath: [...refs.basePath, refs.definitionPath, name14]
|
|
1642
|
+
}, false) ?? parseAnyDef(refs);
|
|
1971
1643
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
1972
1644
|
if (title !== void 0) {
|
|
1973
1645
|
main.title = title;
|
|
1974
1646
|
}
|
|
1975
|
-
|
|
1647
|
+
if (refs.flags.hasReferencedOpenAiAnyType) {
|
|
1648
|
+
if (!definitions) {
|
|
1649
|
+
definitions = {};
|
|
1650
|
+
}
|
|
1651
|
+
if (!definitions[refs.openAiAnyTypeName]) {
|
|
1652
|
+
definitions[refs.openAiAnyTypeName] = {
|
|
1653
|
+
// Skipping "object" as no properties can be defined and additionalProperties must be "false"
|
|
1654
|
+
type: ["string", "number", "integer", "boolean", "array", "null"],
|
|
1655
|
+
items: {
|
|
1656
|
+
$ref: refs.$refStrategy === "relative" ? "1" : [
|
|
1657
|
+
...refs.basePath,
|
|
1658
|
+
refs.definitionPath,
|
|
1659
|
+
refs.openAiAnyTypeName
|
|
1660
|
+
].join("/")
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
const combined = name14 === void 0 ? definitions ? {
|
|
1976
1666
|
...main,
|
|
1977
1667
|
[refs.definitionPath]: definitions
|
|
1978
1668
|
} : main : {
|
|
1979
1669
|
$ref: [
|
|
1980
1670
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
1981
1671
|
refs.definitionPath,
|
|
1982
|
-
|
|
1672
|
+
name14
|
|
1983
1673
|
].join("/"),
|
|
1984
1674
|
[refs.definitionPath]: {
|
|
1985
1675
|
...definitions,
|
|
1986
|
-
[
|
|
1676
|
+
[name14]: main
|
|
1987
1677
|
}
|
|
1988
1678
|
};
|
|
1989
1679
|
if (refs.target === "jsonSchema7") {
|
|
@@ -1997,8 +1687,635 @@ var zodToJsonSchema = (schema, options) => {
|
|
|
1997
1687
|
return combined;
|
|
1998
1688
|
};
|
|
1999
1689
|
|
|
2000
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
1690
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/index.js
|
|
2001
1691
|
var esm_default = zodToJsonSchema;
|
|
2002
1692
|
|
|
1693
|
+
// ../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.3_zod@3.25.76/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
1694
|
+
function combineHeaders(...headers) {
|
|
1695
|
+
return headers.reduce(
|
|
1696
|
+
(combinedHeaders, currentHeaders) => ({
|
|
1697
|
+
...combinedHeaders,
|
|
1698
|
+
...currentHeaders != null ? currentHeaders : {}
|
|
1699
|
+
}),
|
|
1700
|
+
{}
|
|
1701
|
+
);
|
|
1702
|
+
}
|
|
1703
|
+
function extractResponseHeaders(response) {
|
|
1704
|
+
return Object.fromEntries([...response.headers]);
|
|
1705
|
+
}
|
|
1706
|
+
var createIdGenerator = ({
|
|
1707
|
+
prefix,
|
|
1708
|
+
size = 16,
|
|
1709
|
+
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
1710
|
+
separator = "-"
|
|
1711
|
+
} = {}) => {
|
|
1712
|
+
const generator = () => {
|
|
1713
|
+
const alphabetLength = alphabet.length;
|
|
1714
|
+
const chars = new Array(size);
|
|
1715
|
+
for (let i = 0; i < size; i++) {
|
|
1716
|
+
chars[i] = alphabet[Math.random() * alphabetLength | 0];
|
|
1717
|
+
}
|
|
1718
|
+
return chars.join("");
|
|
1719
|
+
};
|
|
1720
|
+
if (prefix == null) {
|
|
1721
|
+
return generator;
|
|
1722
|
+
}
|
|
1723
|
+
if (alphabet.includes(separator)) {
|
|
1724
|
+
throw new InvalidArgumentError({
|
|
1725
|
+
argument: "separator",
|
|
1726
|
+
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
1727
|
+
});
|
|
1728
|
+
}
|
|
1729
|
+
return () => `${prefix}${separator}${generator()}`;
|
|
1730
|
+
};
|
|
1731
|
+
var generateId = createIdGenerator();
|
|
1732
|
+
function isAbortError(error) {
|
|
1733
|
+
return (error instanceof Error || error instanceof DOMException) && (error.name === "AbortError" || error.name === "ResponseAborted" || // Next.js
|
|
1734
|
+
error.name === "TimeoutError");
|
|
1735
|
+
}
|
|
1736
|
+
var FETCH_FAILED_ERROR_MESSAGES = ["fetch failed", "failed to fetch"];
|
|
1737
|
+
function handleFetchError({
|
|
1738
|
+
error,
|
|
1739
|
+
url,
|
|
1740
|
+
requestBodyValues
|
|
1741
|
+
}) {
|
|
1742
|
+
if (isAbortError(error)) {
|
|
1743
|
+
return error;
|
|
1744
|
+
}
|
|
1745
|
+
if (error instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error.message.toLowerCase())) {
|
|
1746
|
+
const cause = error.cause;
|
|
1747
|
+
if (cause != null) {
|
|
1748
|
+
return new APICallError({
|
|
1749
|
+
message: `Cannot connect to API: ${cause.message}`,
|
|
1750
|
+
cause,
|
|
1751
|
+
url,
|
|
1752
|
+
requestBodyValues,
|
|
1753
|
+
isRetryable: true
|
|
1754
|
+
// retry when network error
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
return error;
|
|
1759
|
+
}
|
|
1760
|
+
function removeUndefinedEntries(record) {
|
|
1761
|
+
return Object.fromEntries(
|
|
1762
|
+
Object.entries(record).filter(([_key, value]) => value != null)
|
|
1763
|
+
);
|
|
1764
|
+
}
|
|
1765
|
+
function loadApiKey({
|
|
1766
|
+
apiKey,
|
|
1767
|
+
environmentVariableName,
|
|
1768
|
+
apiKeyParameterName = "apiKey",
|
|
1769
|
+
description
|
|
1770
|
+
}) {
|
|
1771
|
+
if (typeof apiKey === "string") {
|
|
1772
|
+
return apiKey;
|
|
1773
|
+
}
|
|
1774
|
+
if (apiKey != null) {
|
|
1775
|
+
throw new LoadAPIKeyError({
|
|
1776
|
+
message: `${description} API key must be a string.`
|
|
1777
|
+
});
|
|
1778
|
+
}
|
|
1779
|
+
if (typeof process === "undefined") {
|
|
1780
|
+
throw new LoadAPIKeyError({
|
|
1781
|
+
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables is not supported in this environment.`
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1784
|
+
apiKey = process.env[environmentVariableName];
|
|
1785
|
+
if (apiKey == null) {
|
|
1786
|
+
throw new LoadAPIKeyError({
|
|
1787
|
+
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter or the ${environmentVariableName} environment variable.`
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
if (typeof apiKey !== "string") {
|
|
1791
|
+
throw new LoadAPIKeyError({
|
|
1792
|
+
message: `${description} API key must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
|
|
1793
|
+
});
|
|
1794
|
+
}
|
|
1795
|
+
return apiKey;
|
|
1796
|
+
}
|
|
1797
|
+
var suspectProtoRx = /"__proto__"\s*:/;
|
|
1798
|
+
var suspectConstructorRx = /"constructor"\s*:/;
|
|
1799
|
+
function _parse(text) {
|
|
1800
|
+
const obj = JSON.parse(text);
|
|
1801
|
+
if (obj === null || typeof obj !== "object") {
|
|
1802
|
+
return obj;
|
|
1803
|
+
}
|
|
1804
|
+
if (suspectProtoRx.test(text) === false && suspectConstructorRx.test(text) === false) {
|
|
1805
|
+
return obj;
|
|
1806
|
+
}
|
|
1807
|
+
return filter(obj);
|
|
1808
|
+
}
|
|
1809
|
+
function filter(obj) {
|
|
1810
|
+
let next = [obj];
|
|
1811
|
+
while (next.length) {
|
|
1812
|
+
const nodes = next;
|
|
1813
|
+
next = [];
|
|
1814
|
+
for (const node of nodes) {
|
|
1815
|
+
if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
1816
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
|
1817
|
+
}
|
|
1818
|
+
if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
1819
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
|
1820
|
+
}
|
|
1821
|
+
for (const key in node) {
|
|
1822
|
+
const value = node[key];
|
|
1823
|
+
if (value && typeof value === "object") {
|
|
1824
|
+
next.push(value);
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
return obj;
|
|
1830
|
+
}
|
|
1831
|
+
function secureJsonParse(text) {
|
|
1832
|
+
const { stackTraceLimit } = Error;
|
|
1833
|
+
Error.stackTraceLimit = 0;
|
|
1834
|
+
try {
|
|
1835
|
+
return _parse(text);
|
|
1836
|
+
} finally {
|
|
1837
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
var validatorSymbol = Symbol.for("vercel.ai.validator");
|
|
1841
|
+
function validator(validate) {
|
|
1842
|
+
return { [validatorSymbol]: true, validate };
|
|
1843
|
+
}
|
|
1844
|
+
function isValidator(value) {
|
|
1845
|
+
return typeof value === "object" && value !== null && validatorSymbol in value && value[validatorSymbol] === true && "validate" in value;
|
|
1846
|
+
}
|
|
1847
|
+
function asValidator(value) {
|
|
1848
|
+
return isValidator(value) ? value : standardSchemaValidator(value);
|
|
1849
|
+
}
|
|
1850
|
+
function standardSchemaValidator(standardSchema) {
|
|
1851
|
+
return validator(async (value) => {
|
|
1852
|
+
const result = await standardSchema["~standard"].validate(value);
|
|
1853
|
+
return result.issues == null ? { success: true, value: result.value } : {
|
|
1854
|
+
success: false,
|
|
1855
|
+
error: new TypeValidationError({
|
|
1856
|
+
value,
|
|
1857
|
+
cause: result.issues
|
|
1858
|
+
})
|
|
1859
|
+
};
|
|
1860
|
+
});
|
|
1861
|
+
}
|
|
1862
|
+
async function validateTypes({
|
|
1863
|
+
value,
|
|
1864
|
+
schema
|
|
1865
|
+
}) {
|
|
1866
|
+
const result = await safeValidateTypes({ value, schema });
|
|
1867
|
+
if (!result.success) {
|
|
1868
|
+
throw TypeValidationError.wrap({ value, cause: result.error });
|
|
1869
|
+
}
|
|
1870
|
+
return result.value;
|
|
1871
|
+
}
|
|
1872
|
+
async function safeValidateTypes({
|
|
1873
|
+
value,
|
|
1874
|
+
schema
|
|
1875
|
+
}) {
|
|
1876
|
+
const validator2 = asValidator(schema);
|
|
1877
|
+
try {
|
|
1878
|
+
if (validator2.validate == null) {
|
|
1879
|
+
return { success: true, value, rawValue: value };
|
|
1880
|
+
}
|
|
1881
|
+
const result = await validator2.validate(value);
|
|
1882
|
+
if (result.success) {
|
|
1883
|
+
return { success: true, value: result.value, rawValue: value };
|
|
1884
|
+
}
|
|
1885
|
+
return {
|
|
1886
|
+
success: false,
|
|
1887
|
+
error: TypeValidationError.wrap({ value, cause: result.error }),
|
|
1888
|
+
rawValue: value
|
|
1889
|
+
};
|
|
1890
|
+
} catch (error) {
|
|
1891
|
+
return {
|
|
1892
|
+
success: false,
|
|
1893
|
+
error: TypeValidationError.wrap({ value, cause: error }),
|
|
1894
|
+
rawValue: value
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
async function parseJSON({
|
|
1899
|
+
text,
|
|
1900
|
+
schema
|
|
1901
|
+
}) {
|
|
1902
|
+
try {
|
|
1903
|
+
const value = secureJsonParse(text);
|
|
1904
|
+
if (schema == null) {
|
|
1905
|
+
return value;
|
|
1906
|
+
}
|
|
1907
|
+
return validateTypes({ value, schema });
|
|
1908
|
+
} catch (error) {
|
|
1909
|
+
if (JSONParseError.isInstance(error) || TypeValidationError.isInstance(error)) {
|
|
1910
|
+
throw error;
|
|
1911
|
+
}
|
|
1912
|
+
throw new JSONParseError({ text, cause: error });
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
async function safeParseJSON({
|
|
1916
|
+
text,
|
|
1917
|
+
schema
|
|
1918
|
+
}) {
|
|
1919
|
+
try {
|
|
1920
|
+
const value = secureJsonParse(text);
|
|
1921
|
+
if (schema == null) {
|
|
1922
|
+
return { success: true, value, rawValue: value };
|
|
1923
|
+
}
|
|
1924
|
+
return await safeValidateTypes({ value, schema });
|
|
1925
|
+
} catch (error) {
|
|
1926
|
+
return {
|
|
1927
|
+
success: false,
|
|
1928
|
+
error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text, cause: error }),
|
|
1929
|
+
rawValue: void 0
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
function isParsableJson(input) {
|
|
1934
|
+
try {
|
|
1935
|
+
secureJsonParse(input);
|
|
1936
|
+
return true;
|
|
1937
|
+
} catch (e) {
|
|
1938
|
+
return false;
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
function parseJsonEventStream({
|
|
1942
|
+
stream,
|
|
1943
|
+
schema
|
|
1944
|
+
}) {
|
|
1945
|
+
return stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream()).pipeThrough(
|
|
1946
|
+
new TransformStream({
|
|
1947
|
+
async transform({ data }, controller) {
|
|
1948
|
+
if (data === "[DONE]") {
|
|
1949
|
+
return;
|
|
1950
|
+
}
|
|
1951
|
+
controller.enqueue(await safeParseJSON({ text: data, schema }));
|
|
1952
|
+
}
|
|
1953
|
+
})
|
|
1954
|
+
);
|
|
1955
|
+
}
|
|
1956
|
+
async function parseProviderOptions({
|
|
1957
|
+
provider,
|
|
1958
|
+
providerOptions,
|
|
1959
|
+
schema
|
|
1960
|
+
}) {
|
|
1961
|
+
if ((providerOptions == null ? void 0 : providerOptions[provider]) == null) {
|
|
1962
|
+
return void 0;
|
|
1963
|
+
}
|
|
1964
|
+
const parsedProviderOptions = await safeValidateTypes({
|
|
1965
|
+
value: providerOptions[provider],
|
|
1966
|
+
schema
|
|
1967
|
+
});
|
|
1968
|
+
if (!parsedProviderOptions.success) {
|
|
1969
|
+
throw new InvalidArgumentError({
|
|
1970
|
+
argument: "providerOptions",
|
|
1971
|
+
message: `invalid ${provider} provider options`,
|
|
1972
|
+
cause: parsedProviderOptions.error
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1975
|
+
return parsedProviderOptions.value;
|
|
1976
|
+
}
|
|
1977
|
+
var getOriginalFetch2 = () => globalThis.fetch;
|
|
1978
|
+
var postJsonToApi = async ({
|
|
1979
|
+
url,
|
|
1980
|
+
headers,
|
|
1981
|
+
body,
|
|
1982
|
+
failedResponseHandler,
|
|
1983
|
+
successfulResponseHandler,
|
|
1984
|
+
abortSignal,
|
|
1985
|
+
fetch
|
|
1986
|
+
}) => postToApi({
|
|
1987
|
+
url,
|
|
1988
|
+
headers: {
|
|
1989
|
+
"Content-Type": "application/json",
|
|
1990
|
+
...headers
|
|
1991
|
+
},
|
|
1992
|
+
body: {
|
|
1993
|
+
content: JSON.stringify(body),
|
|
1994
|
+
values: body
|
|
1995
|
+
},
|
|
1996
|
+
failedResponseHandler,
|
|
1997
|
+
successfulResponseHandler,
|
|
1998
|
+
abortSignal,
|
|
1999
|
+
fetch
|
|
2000
|
+
});
|
|
2001
|
+
var postFormDataToApi = async ({
|
|
2002
|
+
url,
|
|
2003
|
+
headers,
|
|
2004
|
+
formData,
|
|
2005
|
+
failedResponseHandler,
|
|
2006
|
+
successfulResponseHandler,
|
|
2007
|
+
abortSignal,
|
|
2008
|
+
fetch
|
|
2009
|
+
}) => postToApi({
|
|
2010
|
+
url,
|
|
2011
|
+
headers,
|
|
2012
|
+
body: {
|
|
2013
|
+
content: formData,
|
|
2014
|
+
values: Object.fromEntries(formData.entries())
|
|
2015
|
+
},
|
|
2016
|
+
failedResponseHandler,
|
|
2017
|
+
successfulResponseHandler,
|
|
2018
|
+
abortSignal,
|
|
2019
|
+
fetch
|
|
2020
|
+
});
|
|
2021
|
+
var postToApi = async ({
|
|
2022
|
+
url,
|
|
2023
|
+
headers = {},
|
|
2024
|
+
body,
|
|
2025
|
+
successfulResponseHandler,
|
|
2026
|
+
failedResponseHandler,
|
|
2027
|
+
abortSignal,
|
|
2028
|
+
fetch = getOriginalFetch2()
|
|
2029
|
+
}) => {
|
|
2030
|
+
try {
|
|
2031
|
+
const response = await fetch(url, {
|
|
2032
|
+
method: "POST",
|
|
2033
|
+
headers: removeUndefinedEntries(headers),
|
|
2034
|
+
body: body.content,
|
|
2035
|
+
signal: abortSignal
|
|
2036
|
+
});
|
|
2037
|
+
const responseHeaders = extractResponseHeaders(response);
|
|
2038
|
+
if (!response.ok) {
|
|
2039
|
+
let errorInformation;
|
|
2040
|
+
try {
|
|
2041
|
+
errorInformation = await failedResponseHandler({
|
|
2042
|
+
response,
|
|
2043
|
+
url,
|
|
2044
|
+
requestBodyValues: body.values
|
|
2045
|
+
});
|
|
2046
|
+
} catch (error) {
|
|
2047
|
+
if (isAbortError(error) || APICallError.isInstance(error)) {
|
|
2048
|
+
throw error;
|
|
2049
|
+
}
|
|
2050
|
+
throw new APICallError({
|
|
2051
|
+
message: "Failed to process error response",
|
|
2052
|
+
cause: error,
|
|
2053
|
+
statusCode: response.status,
|
|
2054
|
+
url,
|
|
2055
|
+
responseHeaders,
|
|
2056
|
+
requestBodyValues: body.values
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
throw errorInformation.value;
|
|
2060
|
+
}
|
|
2061
|
+
try {
|
|
2062
|
+
return await successfulResponseHandler({
|
|
2063
|
+
response,
|
|
2064
|
+
url,
|
|
2065
|
+
requestBodyValues: body.values
|
|
2066
|
+
});
|
|
2067
|
+
} catch (error) {
|
|
2068
|
+
if (error instanceof Error) {
|
|
2069
|
+
if (isAbortError(error) || APICallError.isInstance(error)) {
|
|
2070
|
+
throw error;
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
throw new APICallError({
|
|
2074
|
+
message: "Failed to process successful response",
|
|
2075
|
+
cause: error,
|
|
2076
|
+
statusCode: response.status,
|
|
2077
|
+
url,
|
|
2078
|
+
responseHeaders,
|
|
2079
|
+
requestBodyValues: body.values
|
|
2080
|
+
});
|
|
2081
|
+
}
|
|
2082
|
+
} catch (error) {
|
|
2083
|
+
throw handleFetchError({ error, url, requestBodyValues: body.values });
|
|
2084
|
+
}
|
|
2085
|
+
};
|
|
2086
|
+
function tool(tool2) {
|
|
2087
|
+
return tool2;
|
|
2088
|
+
}
|
|
2089
|
+
function createProviderDefinedToolFactory({
|
|
2090
|
+
id,
|
|
2091
|
+
name: name14,
|
|
2092
|
+
inputSchema
|
|
2093
|
+
}) {
|
|
2094
|
+
return ({
|
|
2095
|
+
execute,
|
|
2096
|
+
outputSchema,
|
|
2097
|
+
toModelOutput,
|
|
2098
|
+
onInputStart,
|
|
2099
|
+
onInputDelta,
|
|
2100
|
+
onInputAvailable,
|
|
2101
|
+
...args
|
|
2102
|
+
}) => tool({
|
|
2103
|
+
type: "provider-defined",
|
|
2104
|
+
id,
|
|
2105
|
+
name: name14,
|
|
2106
|
+
args,
|
|
2107
|
+
inputSchema,
|
|
2108
|
+
outputSchema,
|
|
2109
|
+
execute,
|
|
2110
|
+
toModelOutput,
|
|
2111
|
+
onInputStart,
|
|
2112
|
+
onInputDelta,
|
|
2113
|
+
onInputAvailable
|
|
2114
|
+
});
|
|
2115
|
+
}
|
|
2116
|
+
function createProviderDefinedToolFactoryWithOutputSchema({
|
|
2117
|
+
id,
|
|
2118
|
+
name: name14,
|
|
2119
|
+
inputSchema,
|
|
2120
|
+
outputSchema
|
|
2121
|
+
}) {
|
|
2122
|
+
return ({
|
|
2123
|
+
execute,
|
|
2124
|
+
toModelOutput,
|
|
2125
|
+
onInputStart,
|
|
2126
|
+
onInputDelta,
|
|
2127
|
+
onInputAvailable,
|
|
2128
|
+
...args
|
|
2129
|
+
}) => tool({
|
|
2130
|
+
type: "provider-defined",
|
|
2131
|
+
id,
|
|
2132
|
+
name: name14,
|
|
2133
|
+
args,
|
|
2134
|
+
inputSchema,
|
|
2135
|
+
outputSchema,
|
|
2136
|
+
execute,
|
|
2137
|
+
toModelOutput,
|
|
2138
|
+
onInputStart,
|
|
2139
|
+
onInputDelta,
|
|
2140
|
+
onInputAvailable
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
async function resolve(value) {
|
|
2144
|
+
if (typeof value === "function") {
|
|
2145
|
+
value = value();
|
|
2146
|
+
}
|
|
2147
|
+
return Promise.resolve(value);
|
|
2148
|
+
}
|
|
2149
|
+
var createJsonErrorResponseHandler = ({
|
|
2150
|
+
errorSchema,
|
|
2151
|
+
errorToMessage,
|
|
2152
|
+
isRetryable
|
|
2153
|
+
}) => async ({ response, url, requestBodyValues }) => {
|
|
2154
|
+
const responseBody = await response.text();
|
|
2155
|
+
const responseHeaders = extractResponseHeaders(response);
|
|
2156
|
+
if (responseBody.trim() === "") {
|
|
2157
|
+
return {
|
|
2158
|
+
responseHeaders,
|
|
2159
|
+
value: new APICallError({
|
|
2160
|
+
message: response.statusText,
|
|
2161
|
+
url,
|
|
2162
|
+
requestBodyValues,
|
|
2163
|
+
statusCode: response.status,
|
|
2164
|
+
responseHeaders,
|
|
2165
|
+
responseBody,
|
|
2166
|
+
isRetryable: isRetryable == null ? void 0 : isRetryable(response)
|
|
2167
|
+
})
|
|
2168
|
+
};
|
|
2169
|
+
}
|
|
2170
|
+
try {
|
|
2171
|
+
const parsedError = await parseJSON({
|
|
2172
|
+
text: responseBody,
|
|
2173
|
+
schema: errorSchema
|
|
2174
|
+
});
|
|
2175
|
+
return {
|
|
2176
|
+
responseHeaders,
|
|
2177
|
+
value: new APICallError({
|
|
2178
|
+
message: errorToMessage(parsedError),
|
|
2179
|
+
url,
|
|
2180
|
+
requestBodyValues,
|
|
2181
|
+
statusCode: response.status,
|
|
2182
|
+
responseHeaders,
|
|
2183
|
+
responseBody,
|
|
2184
|
+
data: parsedError,
|
|
2185
|
+
isRetryable: isRetryable == null ? void 0 : isRetryable(response, parsedError)
|
|
2186
|
+
})
|
|
2187
|
+
};
|
|
2188
|
+
} catch (parseError) {
|
|
2189
|
+
return {
|
|
2190
|
+
responseHeaders,
|
|
2191
|
+
value: new APICallError({
|
|
2192
|
+
message: response.statusText,
|
|
2193
|
+
url,
|
|
2194
|
+
requestBodyValues,
|
|
2195
|
+
statusCode: response.status,
|
|
2196
|
+
responseHeaders,
|
|
2197
|
+
responseBody,
|
|
2198
|
+
isRetryable: isRetryable == null ? void 0 : isRetryable(response)
|
|
2199
|
+
})
|
|
2200
|
+
};
|
|
2201
|
+
}
|
|
2202
|
+
};
|
|
2203
|
+
var createEventSourceResponseHandler = (chunkSchema) => async ({ response }) => {
|
|
2204
|
+
const responseHeaders = extractResponseHeaders(response);
|
|
2205
|
+
if (response.body == null) {
|
|
2206
|
+
throw new EmptyResponseBodyError({});
|
|
2207
|
+
}
|
|
2208
|
+
return {
|
|
2209
|
+
responseHeaders,
|
|
2210
|
+
value: parseJsonEventStream({
|
|
2211
|
+
stream: response.body,
|
|
2212
|
+
schema: chunkSchema
|
|
2213
|
+
})
|
|
2214
|
+
};
|
|
2215
|
+
};
|
|
2216
|
+
var createJsonResponseHandler = (responseSchema) => async ({ response, url, requestBodyValues }) => {
|
|
2217
|
+
const responseBody = await response.text();
|
|
2218
|
+
const parsedResult = await safeParseJSON({
|
|
2219
|
+
text: responseBody,
|
|
2220
|
+
schema: responseSchema
|
|
2221
|
+
});
|
|
2222
|
+
const responseHeaders = extractResponseHeaders(response);
|
|
2223
|
+
if (!parsedResult.success) {
|
|
2224
|
+
throw new APICallError({
|
|
2225
|
+
message: "Invalid JSON response",
|
|
2226
|
+
cause: parsedResult.error,
|
|
2227
|
+
statusCode: response.status,
|
|
2228
|
+
responseHeaders,
|
|
2229
|
+
responseBody,
|
|
2230
|
+
url,
|
|
2231
|
+
requestBodyValues
|
|
2232
|
+
});
|
|
2233
|
+
}
|
|
2234
|
+
return {
|
|
2235
|
+
responseHeaders,
|
|
2236
|
+
value: parsedResult.value,
|
|
2237
|
+
rawValue: parsedResult.rawValue
|
|
2238
|
+
};
|
|
2239
|
+
};
|
|
2240
|
+
var createBinaryResponseHandler = () => async ({ response, url, requestBodyValues }) => {
|
|
2241
|
+
const responseHeaders = extractResponseHeaders(response);
|
|
2242
|
+
if (!response.body) {
|
|
2243
|
+
throw new APICallError({
|
|
2244
|
+
message: "Response body is empty",
|
|
2245
|
+
url,
|
|
2246
|
+
requestBodyValues,
|
|
2247
|
+
statusCode: response.status,
|
|
2248
|
+
responseHeaders,
|
|
2249
|
+
responseBody: void 0
|
|
2250
|
+
});
|
|
2251
|
+
}
|
|
2252
|
+
try {
|
|
2253
|
+
const buffer = await response.arrayBuffer();
|
|
2254
|
+
return {
|
|
2255
|
+
responseHeaders,
|
|
2256
|
+
value: new Uint8Array(buffer)
|
|
2257
|
+
};
|
|
2258
|
+
} catch (error) {
|
|
2259
|
+
throw new APICallError({
|
|
2260
|
+
message: "Failed to read response as array buffer",
|
|
2261
|
+
url,
|
|
2262
|
+
requestBodyValues,
|
|
2263
|
+
statusCode: response.status,
|
|
2264
|
+
responseHeaders,
|
|
2265
|
+
responseBody: void 0,
|
|
2266
|
+
cause: error
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
};
|
|
2270
|
+
var { btoa, atob } = globalThis;
|
|
2271
|
+
function convertBase64ToUint8Array(base64String) {
|
|
2272
|
+
const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
2273
|
+
const latin1string = atob(base64Url);
|
|
2274
|
+
return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
|
|
2275
|
+
}
|
|
2276
|
+
function convertUint8ArrayToBase64(array) {
|
|
2277
|
+
let latin1string = "";
|
|
2278
|
+
for (let i = 0; i < array.length; i++) {
|
|
2279
|
+
latin1string += String.fromCodePoint(array[i]);
|
|
2280
|
+
}
|
|
2281
|
+
return btoa(latin1string);
|
|
2282
|
+
}
|
|
2283
|
+
function convertToBase64(value) {
|
|
2284
|
+
return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
|
|
2285
|
+
}
|
|
2286
|
+
function withoutTrailingSlash(url) {
|
|
2287
|
+
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
exports.AISDKError = AISDKError;
|
|
2291
|
+
exports.APICallError = APICallError;
|
|
2292
|
+
exports.EmptyResponseBodyError = EmptyResponseBodyError;
|
|
2293
|
+
exports.EventSourceParserStream = EventSourceParserStream;
|
|
2294
|
+
exports.InvalidArgumentError = InvalidArgumentError;
|
|
2295
|
+
exports.InvalidPromptError = InvalidPromptError;
|
|
2296
|
+
exports.InvalidResponseDataError = InvalidResponseDataError;
|
|
2297
|
+
exports.JSONParseError = JSONParseError;
|
|
2298
|
+
exports.NoSuchModelError = NoSuchModelError;
|
|
2299
|
+
exports.TooManyEmbeddingValuesForCallError = TooManyEmbeddingValuesForCallError;
|
|
2300
|
+
exports.TypeValidationError = TypeValidationError;
|
|
2301
|
+
exports.UnsupportedFunctionalityError = UnsupportedFunctionalityError;
|
|
2302
|
+
exports.combineHeaders = combineHeaders;
|
|
2303
|
+
exports.convertBase64ToUint8Array = convertBase64ToUint8Array;
|
|
2304
|
+
exports.convertToBase64 = convertToBase64;
|
|
2305
|
+
exports.createBinaryResponseHandler = createBinaryResponseHandler;
|
|
2306
|
+
exports.createEventSourceResponseHandler = createEventSourceResponseHandler;
|
|
2307
|
+
exports.createJsonErrorResponseHandler = createJsonErrorResponseHandler;
|
|
2308
|
+
exports.createJsonResponseHandler = createJsonResponseHandler;
|
|
2309
|
+
exports.createProviderDefinedToolFactory = createProviderDefinedToolFactory;
|
|
2310
|
+
exports.createProviderDefinedToolFactoryWithOutputSchema = createProviderDefinedToolFactoryWithOutputSchema;
|
|
2003
2311
|
exports.esm_default = esm_default;
|
|
2004
|
-
exports.
|
|
2312
|
+
exports.generateId = generateId;
|
|
2313
|
+
exports.isParsableJson = isParsableJson;
|
|
2314
|
+
exports.loadApiKey = loadApiKey;
|
|
2315
|
+
exports.parseProviderOptions = parseProviderOptions;
|
|
2316
|
+
exports.postFormDataToApi = postFormDataToApi;
|
|
2317
|
+
exports.postJsonToApi = postJsonToApi;
|
|
2318
|
+
exports.resolve = resolve;
|
|
2319
|
+
exports.withoutTrailingSlash = withoutTrailingSlash;
|
|
2320
|
+
//# sourceMappingURL=chunk-HVBBFCDH.cjs.map
|
|
2321
|
+
//# sourceMappingURL=chunk-HVBBFCDH.cjs.map
|