@vm0/cli 9.249.0 → 9.249.2
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/{agent-J7UZFWFE.js → agent-TOFXTWYP.js} +11 -10
- package/{agent-J7UZFWFE.js.map → agent-TOFXTWYP.js.map} +1 -1
- package/{banking-TLHPJBS5.js → banking-U7I6EJUO.js} +8 -7
- package/{banking-TLHPJBS5.js.map → banking-U7I6EJUO.js.map} +1 -1
- package/{chat-PWHG42AL.js → chat-77EDGFMS.js} +9 -8
- package/{chat-PWHG42AL.js.map → chat-77EDGFMS.js.map} +1 -1
- package/{chunk-DIRAZ3YX.js → chunk-3VVCUQPB.js} +3 -3
- package/{chunk-DIRAZ3YX.js.map → chunk-3VVCUQPB.js.map} +1 -1
- package/{chunk-LDQPMTQY.js → chunk-4HN7U3JF.js} +103 -625
- package/chunk-4HN7U3JF.js.map +1 -0
- package/{chunk-ZJENFGWZ.js → chunk-5CZNUTFF.js} +3 -3
- package/chunk-A2NKQGRI.js +491 -0
- package/chunk-A2NKQGRI.js.map +1 -0
- package/{chunk-6IFIMWPY.js → chunk-AFNSFKAH.js} +5 -5
- package/{chunk-XE764T2N.js → chunk-BQOOTJNB.js} +27 -672
- package/chunk-BQOOTJNB.js.map +1 -0
- package/{chunk-KLIW3XK7.js → chunk-GPF7NSX7.js} +2 -2
- package/{chunk-HJOW32CJ.js → chunk-HSGQT7LT.js} +3 -3
- package/{chunk-PD3A7MGG.js → chunk-JCLLQRCI.js} +3 -3
- package/{chunk-B3W2RUBP.js → chunk-LD4ZVU4O.js} +2 -2
- package/chunk-N6TDQYGF.js +678 -0
- package/chunk-N6TDQYGF.js.map +1 -0
- package/{chunk-3QXK5RR7.js → chunk-ROB3OE37.js} +17 -113
- package/chunk-ROB3OE37.js.map +1 -0
- package/{chunk-LTDQISD7.js → chunk-SB7EZ2ZO.js} +2 -2
- package/{chunk-RTYT3CSZ.js → chunk-UG5XA6KU.js} +2 -2
- package/{chunk-ZKWCFMDV.js → chunk-UNQJRTJQ.js} +3 -3
- package/chunk-W75R7EZF.js +17 -0
- package/chunk-W75R7EZF.js.map +1 -0
- package/chunk-WDDZJGWL.js +32 -0
- package/chunk-WDDZJGWL.js.map +1 -0
- package/{chunk-JFY6GK7Y.js → chunk-X2545RBX.js} +2 -2
- package/{chunk-ZE2VIESK.js → chunk-X4DBCBU4.js} +2 -2
- package/{computer-use-EE6NPCXS.js → computer-use-BCGPVGWS.js} +7 -6
- package/{computer-use-EE6NPCXS.js.map → computer-use-BCGPVGWS.js.map} +1 -1
- package/{connector-SCLSWTMT.js → connector-CHZSI2LW.js} +14 -13
- package/{connector-SCLSWTMT.js.map → connector-CHZSI2LW.js.map} +1 -1
- package/credit-RWFBPKOS.js +166 -0
- package/credit-RWFBPKOS.js.map +1 -0
- package/{developer-support-V3N3BOYC.js → developer-support-IVR3HIP7.js} +8 -7
- package/{developer-support-V3N3BOYC.js.map → developer-support-IVR3HIP7.js.map} +1 -1
- package/{doctor-AQLFJCC6.js → doctor-KGWTXW2Q.js} +39 -13
- package/doctor-KGWTXW2Q.js.map +1 -0
- package/{esm-PZKPCIYJ.js → esm-GOCEMHJO.js} +3 -3
- package/{feishu-XHOLF32I.js → feishu-PLF4P5OG.js} +8 -7
- package/{feishu-XHOLF32I.js.map → feishu-PLF4P5OG.js.map} +1 -1
- package/{finance-TF5RU7FD.js → finance-LVFG3WWP.js} +8 -7
- package/{finance-TF5RU7FD.js.map → finance-LVFG3WWP.js.map} +1 -1
- package/{generate-GFFAZX7Y.js → generate-4FIBMMJO.js} +77 -22
- package/generate-4FIBMMJO.js.map +1 -0
- package/{getMachineId-bsd-L73QENVB.js → getMachineId-bsd-SB7C44VX.js} +4 -4
- package/{getMachineId-darwin-TCCWKQ2S.js → getMachineId-darwin-R4BWY3CQ.js} +4 -4
- package/{getMachineId-linux-TJYYUZVM.js → getMachineId-linux-BR4HVNPW.js} +3 -3
- package/{getMachineId-unsupported-DPRVLH4Y.js → getMachineId-unsupported-FPGM635L.js} +3 -3
- package/{getMachineId-win-7EE436CJ.js → getMachineId-win-RB4JMF33.js} +4 -4
- package/{github-V4ZW6TI4.js → github-WHNAVVG3.js} +8 -7
- package/{github-V4ZW6TI4.js.map → github-WHNAVVG3.js.map} +1 -1
- package/{goal-TED5FUYM.js → goal-G4J2BQ5Z.js} +8 -7
- package/{goal-TED5FUYM.js.map → goal-G4J2BQ5Z.js.map} +1 -1
- package/{host-HKDD3CHD.js → host-3W6U2ZUP.js} +8 -7
- package/{host-HKDD3CHD.js.map → host-3W6U2ZUP.js.map} +1 -1
- package/{intro-MIVVJG7M.js → intro-PMHOBGDL.js} +3 -3
- package/{logs-SBMQQM46.js → logs-P7JLTGXY.js} +10 -9
- package/{logs-SBMQQM46.js.map → logs-P7JLTGXY.js.map} +1 -1
- package/{mail-SF5JKA2F.js → mail-LIAOXDD4.js} +12 -11
- package/{mail-SF5JKA2F.js.map → mail-LIAOXDD4.js.map} +1 -1
- package/{maps-D5NKFEAD.js → maps-C4NOXSE7.js} +8 -7
- package/{maps-D5NKFEAD.js.map → maps-C4NOXSE7.js.map} +1 -1
- package/{model-S7CMGRIH.js → model-I2MNQ5KC.js} +9 -8
- package/{model-S7CMGRIH.js.map → model-I2MNQ5KC.js.map} +1 -1
- package/{model-provider-ATXIDNKM.js → model-provider-AOCCHEMP.js} +9 -8
- package/{model-provider-ATXIDNKM.js.map → model-provider-AOCCHEMP.js.map} +1 -1
- package/{org-6JBRK5NL.js → org-MVBG3WXZ.js} +9 -8
- package/{org-6JBRK5NL.js.map → org-MVBG3WXZ.js.map} +1 -1
- package/package.json +1 -1
- package/{phone-B3UWRGWF.js → phone-4OZQFYHU.js} +8 -7
- package/{phone-B3UWRGWF.js.map → phone-4OZQFYHU.js.map} +1 -1
- package/{preference-HRRRUEP3.js → preference-H2A3WBGQ.js} +9 -8
- package/{preference-HRRRUEP3.js.map → preference-H2A3WBGQ.js.map} +1 -1
- package/{resource-65P5D2LT.js → resource-CPCQ6V6M.js} +9 -8
- package/{resource-65P5D2LT.js.map → resource-CPCQ6V6M.js.map} +1 -1
- package/{scrape-N3AWNV2R.js → scrape-6RMFDYAT.js} +8 -7
- package/{scrape-N3AWNV2R.js.map → scrape-6RMFDYAT.js.map} +1 -1
- package/{search-T76RE67L.js → search-HSQVSQZY.js} +10 -9
- package/{search-T76RE67L.js.map → search-HSQVSQZY.js.map} +1 -1
- package/{secret-WALMH6S2.js → secret-S4D6CNOX.js} +9 -8
- package/{secret-WALMH6S2.js.map → secret-S4D6CNOX.js.map} +1 -1
- package/{slack-WXDCNAI2.js → slack-E3E2NIDZ.js} +50 -175
- package/slack-E3E2NIDZ.js.map +1 -0
- package/{teams-LAQBLRUR.js → teams-CLEWT2LQ.js} +8 -7
- package/{teams-LAQBLRUR.js.map → teams-CLEWT2LQ.js.map} +1 -1
- package/{telegram-5BASFBEA.js → telegram-35FKKA4K.js} +8 -7
- package/{telegram-5BASFBEA.js.map → telegram-35FKKA4K.js.map} +1 -1
- package/{undici-ZMFN7TNU.js → undici-YXSVPIYI.js} +2 -2
- package/upgrade-DNGUR42E.js +50 -0
- package/upgrade-DNGUR42E.js.map +1 -0
- package/{variable-GBVHKR6I.js → variable-C7RWUPV6.js} +9 -8
- package/{variable-GBVHKR6I.js.map → variable-C7RWUPV6.js.map} +1 -1
- package/{video-3FXQGBYB.js → video-JS5VOA2S.js} +9 -7
- package/{video-3FXQGBYB.js.map → video-JS5VOA2S.js.map} +1 -1
- package/{weather-JNMUODGJ.js → weather-5R2N5OX4.js} +8 -7
- package/{weather-JNMUODGJ.js.map → weather-5R2N5OX4.js.map} +1 -1
- package/{web-DZT26X4I.js → web-FXIIYCZ7.js} +10 -8
- package/{web-DZT26X4I.js.map → web-FXIIYCZ7.js.map} +1 -1
- package/{web-search-36UUSSUX.js → web-search-SZP7J4UM.js} +8 -7
- package/{web-search-36UUSSUX.js.map → web-search-SZP7J4UM.js.map} +1 -1
- package/{whoami-NXYCNII4.js → whoami-J4FRN67A.js} +10 -9
- package/{whoami-NXYCNII4.js.map → whoami-J4FRN67A.js.map} +1 -1
- package/{workflow-WHTBJCEF.js → workflow-HQHZKXB2.js} +9 -8
- package/{workflow-WHTBJCEF.js.map → workflow-HQHZKXB2.js.map} +1 -1
- package/zero.js +88 -61
- package/zero.js.map +1 -1
- package/chunk-3QXK5RR7.js.map +0 -1
- package/chunk-LDQPMTQY.js.map +0 -1
- package/chunk-LRHXR7JT.js +0 -33
- package/chunk-LRHXR7JT.js.map +0 -1
- package/chunk-XE764T2N.js.map +0 -1
- package/credit-2VN2PYRE.js +0 -128
- package/credit-2VN2PYRE.js.map +0 -1
- package/doctor-AQLFJCC6.js.map +0 -1
- package/generate-GFFAZX7Y.js.map +0 -1
- package/slack-WXDCNAI2.js.map +0 -1
- /package/{chunk-ZJENFGWZ.js.map → chunk-5CZNUTFF.js.map} +0 -0
- /package/{chunk-6IFIMWPY.js.map → chunk-AFNSFKAH.js.map} +0 -0
- /package/{chunk-KLIW3XK7.js.map → chunk-GPF7NSX7.js.map} +0 -0
- /package/{chunk-HJOW32CJ.js.map → chunk-HSGQT7LT.js.map} +0 -0
- /package/{chunk-PD3A7MGG.js.map → chunk-JCLLQRCI.js.map} +0 -0
- /package/{chunk-B3W2RUBP.js.map → chunk-LD4ZVU4O.js.map} +0 -0
- /package/{chunk-LTDQISD7.js.map → chunk-SB7EZ2ZO.js.map} +0 -0
- /package/{chunk-RTYT3CSZ.js.map → chunk-UG5XA6KU.js.map} +0 -0
- /package/{chunk-ZKWCFMDV.js.map → chunk-UNQJRTJQ.js.map} +0 -0
- /package/{chunk-JFY6GK7Y.js.map → chunk-X2545RBX.js.map} +0 -0
- /package/{chunk-ZE2VIESK.js.map → chunk-X4DBCBU4.js.map} +0 -0
- /package/{esm-PZKPCIYJ.js.map → esm-GOCEMHJO.js.map} +0 -0
- /package/{getMachineId-bsd-L73QENVB.js.map → getMachineId-bsd-SB7C44VX.js.map} +0 -0
- /package/{getMachineId-darwin-TCCWKQ2S.js.map → getMachineId-darwin-R4BWY3CQ.js.map} +0 -0
- /package/{getMachineId-linux-TJYYUZVM.js.map → getMachineId-linux-BR4HVNPW.js.map} +0 -0
- /package/{getMachineId-unsupported-DPRVLH4Y.js.map → getMachineId-unsupported-FPGM635L.js.map} +0 -0
- /package/{getMachineId-win-7EE436CJ.js.map → getMachineId-win-RB4JMF33.js.map} +0 -0
- /package/{intro-MIVVJG7M.js.map → intro-PMHOBGDL.js.map} +0 -0
- /package/{undici-ZMFN7TNU.js.map → undici-YXSVPIYI.js.map} +0 -0
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from "node:module";
|
|
3
|
+
const require = __createRequire(import.meta.url);
|
|
4
|
+
import {
|
|
5
|
+
ApiRequestError,
|
|
6
|
+
getActiveToken,
|
|
7
|
+
getBaseUrl,
|
|
8
|
+
headersWithCliClientHeaders
|
|
9
|
+
} from "./chunk-BQOOTJNB.js";
|
|
10
|
+
import {
|
|
11
|
+
init_esm_shims
|
|
12
|
+
} from "./chunk-3VVCUQPB.js";
|
|
13
|
+
|
|
14
|
+
// src/lib/api/domains/web.ts
|
|
15
|
+
init_esm_shims();
|
|
16
|
+
import { createWriteStream, readFileSync, statSync } from "fs";
|
|
17
|
+
import { basename, extname } from "path";
|
|
18
|
+
import { Readable } from "stream";
|
|
19
|
+
import { pipeline } from "stream/promises";
|
|
20
|
+
import { setTimeout as delay } from "timers/promises";
|
|
21
|
+
import { Realtime } from "ably";
|
|
22
|
+
var BUILT_IN_GENERATION_POLL_INTERVAL_MS = 2e3;
|
|
23
|
+
var BUILT_IN_GENERATION_WAIT_TIMEOUT_MS_BY_TYPE = {
|
|
24
|
+
image: 15 * 60 * 1e3,
|
|
25
|
+
video: 30 * 60 * 1e3,
|
|
26
|
+
presentation: 60 * 60 * 1e3,
|
|
27
|
+
website: 60 * 60 * 1e3
|
|
28
|
+
};
|
|
29
|
+
var ABLY_CONNECT_TIMEOUT_MS = 1e4;
|
|
30
|
+
var MIME_BY_EXTENSION = {
|
|
31
|
+
".png": "image/png",
|
|
32
|
+
".jpg": "image/jpeg",
|
|
33
|
+
".jpeg": "image/jpeg",
|
|
34
|
+
".gif": "image/gif",
|
|
35
|
+
".webp": "image/webp",
|
|
36
|
+
".avif": "image/avif",
|
|
37
|
+
".svg": "image/svg+xml",
|
|
38
|
+
".bmp": "image/bmp",
|
|
39
|
+
".heic": "image/heic",
|
|
40
|
+
".heif": "image/heif",
|
|
41
|
+
".tif": "image/tiff",
|
|
42
|
+
".tiff": "image/tiff",
|
|
43
|
+
".psd": "image/vnd.adobe.photoshop",
|
|
44
|
+
".mp4": "video/mp4",
|
|
45
|
+
".webm": "video/webm",
|
|
46
|
+
".mov": "video/quicktime",
|
|
47
|
+
".aac": "audio/aac",
|
|
48
|
+
".flac": "audio/flac",
|
|
49
|
+
".m4a": "audio/mp4",
|
|
50
|
+
".mp3": "audio/mpeg",
|
|
51
|
+
".mpga": "audio/mpga",
|
|
52
|
+
".oga": "audio/ogg",
|
|
53
|
+
".ogg": "audio/ogg",
|
|
54
|
+
".opus": "audio/opus",
|
|
55
|
+
".wav": "audio/wav",
|
|
56
|
+
".wave": "audio/wave",
|
|
57
|
+
".pdf": "application/pdf",
|
|
58
|
+
".txt": "text/plain",
|
|
59
|
+
".csv": "text/csv",
|
|
60
|
+
".md": "text/markdown",
|
|
61
|
+
".html": "text/html",
|
|
62
|
+
".htm": "text/html",
|
|
63
|
+
".json": "application/json",
|
|
64
|
+
".xml": "application/xml",
|
|
65
|
+
".yaml": "application/yaml",
|
|
66
|
+
".yml": "application/yaml",
|
|
67
|
+
".tsv": "text/tab-separated-values",
|
|
68
|
+
".doc": "application/msword",
|
|
69
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
70
|
+
".docm": "application/vnd.ms-word.document.macroenabled.12",
|
|
71
|
+
".dotm": "application/vnd.ms-word.template.macroenabled.12",
|
|
72
|
+
".dotx": "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
|
|
73
|
+
".odt": "application/vnd.oasis.opendocument.text",
|
|
74
|
+
".rtf": "application/rtf",
|
|
75
|
+
".xls": "application/vnd.ms-excel",
|
|
76
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
77
|
+
".xlsb": "application/vnd.ms-excel.sheet.binary.macroenabled.12",
|
|
78
|
+
".xlsm": "application/vnd.ms-excel.sheet.macroenabled.12",
|
|
79
|
+
".xltm": "application/vnd.ms-excel.template.macroenabled.12",
|
|
80
|
+
".xltx": "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
|
|
81
|
+
".ods": "application/vnd.oasis.opendocument.spreadsheet",
|
|
82
|
+
".ppt": "application/vnd.ms-powerpoint",
|
|
83
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
84
|
+
".potm": "application/vnd.ms-powerpoint.template.macroenabled.12",
|
|
85
|
+
".potx": "application/vnd.openxmlformats-officedocument.presentationml.template",
|
|
86
|
+
".odp": "application/vnd.oasis.opendocument.presentation",
|
|
87
|
+
".ppsx": "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
|
|
88
|
+
".ppsm": "application/vnd.ms-powerpoint.slideshow.macroenabled.12",
|
|
89
|
+
".pptm": "application/vnd.ms-powerpoint.presentation.macroenabled.12",
|
|
90
|
+
".zip": "application/zip",
|
|
91
|
+
".rar": "application/vnd.rar",
|
|
92
|
+
".7z": "application/x-7z-compressed",
|
|
93
|
+
".tar": "application/x-tar",
|
|
94
|
+
".gz": "application/gzip",
|
|
95
|
+
".tgz": "application/gzip",
|
|
96
|
+
".bz2": "application/x-bzip2",
|
|
97
|
+
".xz": "application/x-xz",
|
|
98
|
+
".pages": "application/vnd.apple.pages",
|
|
99
|
+
".numbers": "application/vnd.apple.numbers",
|
|
100
|
+
".key": "application/vnd.apple.keynote",
|
|
101
|
+
".parquet": "application/vnd.apache.parquet",
|
|
102
|
+
".sqlite": "application/vnd.sqlite3",
|
|
103
|
+
".sqlite3": "application/vnd.sqlite3",
|
|
104
|
+
".db": "application/vnd.sqlite3",
|
|
105
|
+
".epub": "application/epub+zip",
|
|
106
|
+
".ai": "application/postscript"
|
|
107
|
+
};
|
|
108
|
+
function inferContentType(localPath) {
|
|
109
|
+
const ext = extname(localPath).toLowerCase();
|
|
110
|
+
return MIME_BY_EXTENSION[ext] ?? "application/octet-stream";
|
|
111
|
+
}
|
|
112
|
+
async function downloadWebFile(fileId, outPath) {
|
|
113
|
+
const baseUrl = await getBaseUrl();
|
|
114
|
+
const token = await getActiveToken();
|
|
115
|
+
if (!token) {
|
|
116
|
+
throw new ApiRequestError("Not authenticated", "UNAUTHORIZED", 401);
|
|
117
|
+
}
|
|
118
|
+
const url = new URL("/api/zero/web/download-file", baseUrl);
|
|
119
|
+
url.searchParams.set("file_id", fileId);
|
|
120
|
+
const headers = {
|
|
121
|
+
Authorization: `Bearer ${token}`
|
|
122
|
+
};
|
|
123
|
+
const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
|
|
124
|
+
if (bypassSecret) {
|
|
125
|
+
headers["x-vercel-protection-bypass"] = bypassSecret;
|
|
126
|
+
}
|
|
127
|
+
const response = await fetch(url, {
|
|
128
|
+
headers: headersWithCliClientHeaders(headers)
|
|
129
|
+
});
|
|
130
|
+
if (!response.ok) {
|
|
131
|
+
let message = `Failed to download web file (HTTP ${response.status})`;
|
|
132
|
+
let code = "UNKNOWN";
|
|
133
|
+
try {
|
|
134
|
+
const body = await response.json();
|
|
135
|
+
if (body.error?.message) message = body.error.message;
|
|
136
|
+
if (body.error?.code) code = body.error.code;
|
|
137
|
+
} catch {
|
|
138
|
+
}
|
|
139
|
+
throw new ApiRequestError(message, code, response.status);
|
|
140
|
+
}
|
|
141
|
+
if (!response.body) {
|
|
142
|
+
throw new ApiRequestError(
|
|
143
|
+
"Web download response has no body",
|
|
144
|
+
"EMPTY_BODY",
|
|
145
|
+
502
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
const mimetype = response.headers.get("x-file-mimetype") ?? response.headers.get("content-type") ?? "application/octet-stream";
|
|
149
|
+
await pipeline(
|
|
150
|
+
Readable.fromWeb(response.body),
|
|
151
|
+
createWriteStream(outPath)
|
|
152
|
+
);
|
|
153
|
+
const contentLengthHeader = response.headers.get("content-length");
|
|
154
|
+
const size = contentLengthHeader ? Number(contentLengthHeader) : 0;
|
|
155
|
+
return { path: outPath, mimetype, size };
|
|
156
|
+
}
|
|
157
|
+
function shouldIncludePayloadValue(value) {
|
|
158
|
+
if (value === void 0) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return !Array.isArray(value) || value.length > 0;
|
|
162
|
+
}
|
|
163
|
+
function compactPayload(entries) {
|
|
164
|
+
return Object.fromEntries(
|
|
165
|
+
entries.filter(([, value]) => {
|
|
166
|
+
return shouldIncludePayloadValue(value);
|
|
167
|
+
})
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
function generateWebVideoPayload(options) {
|
|
171
|
+
return compactPayload([
|
|
172
|
+
["prompt", options.prompt],
|
|
173
|
+
["model", options.model],
|
|
174
|
+
["aspectRatio", options.aspectRatio],
|
|
175
|
+
["duration", options.duration],
|
|
176
|
+
["resolution", options.resolution],
|
|
177
|
+
["generateAudio", options.generateAudio],
|
|
178
|
+
["negativePrompt", options.negativePrompt],
|
|
179
|
+
["seed", options.seed],
|
|
180
|
+
["autoFix", options.autoFix],
|
|
181
|
+
["safetyTolerance", options.safetyTolerance],
|
|
182
|
+
["imageUrls", options.imageUrls],
|
|
183
|
+
["videoUrls", options.videoUrls],
|
|
184
|
+
["audioUrls", options.audioUrls],
|
|
185
|
+
["firstFrameImageUrl", options.firstFrameImageUrl],
|
|
186
|
+
["lastFrameImageUrl", options.lastFrameImageUrl]
|
|
187
|
+
]);
|
|
188
|
+
}
|
|
189
|
+
async function parseErrorBody(response, fallback) {
|
|
190
|
+
let message = `${fallback} (HTTP ${response.status})`;
|
|
191
|
+
let code = "UNKNOWN";
|
|
192
|
+
try {
|
|
193
|
+
const body = await response.json();
|
|
194
|
+
if (body.error?.message) message = body.error.message;
|
|
195
|
+
if (body.error?.code) code = body.error.code;
|
|
196
|
+
} catch {
|
|
197
|
+
}
|
|
198
|
+
return { message, code };
|
|
199
|
+
}
|
|
200
|
+
function authenticatedJsonHeaders(token) {
|
|
201
|
+
const headers = {
|
|
202
|
+
Authorization: `Bearer ${token}`,
|
|
203
|
+
"Content-Type": "application/json"
|
|
204
|
+
};
|
|
205
|
+
const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
|
|
206
|
+
if (bypassSecret) {
|
|
207
|
+
headers["x-vercel-protection-bypass"] = bypassSecret;
|
|
208
|
+
}
|
|
209
|
+
return headersWithCliClientHeaders(headers);
|
|
210
|
+
}
|
|
211
|
+
function isRecord(value) {
|
|
212
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
213
|
+
}
|
|
214
|
+
function isBuiltInGenerationAcceptedResponse(value) {
|
|
215
|
+
if (!isRecord(value)) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
return typeof value.generationId === "string" && value.status === "queued" && (value.type === "image" || value.type === "video" || value.type === "presentation" || value.type === "website") && isRecord(value.realtime);
|
|
219
|
+
}
|
|
220
|
+
function createBuiltInGenerationRealtime(accepted) {
|
|
221
|
+
let nextAuthRequest = accepted.realtime.tokenRequest;
|
|
222
|
+
const authCallback = (_params, callback) => {
|
|
223
|
+
const current = nextAuthRequest;
|
|
224
|
+
nextAuthRequest = accepted.realtime.tokenRequest;
|
|
225
|
+
callback(null, current);
|
|
226
|
+
};
|
|
227
|
+
return new Realtime({
|
|
228
|
+
authCallback,
|
|
229
|
+
autoConnect: true,
|
|
230
|
+
disconnectedRetryTimeout: 5e3,
|
|
231
|
+
suspendedRetryTimeout: 15e3
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
function waitForRealtimeConnected(ably, timeoutMs = ABLY_CONNECT_TIMEOUT_MS) {
|
|
235
|
+
if (ably.connection.state === "connected") {
|
|
236
|
+
return Promise.resolve();
|
|
237
|
+
}
|
|
238
|
+
if (ably.connection.state === "failed") {
|
|
239
|
+
return Promise.reject(new Error("Ably connection failed"));
|
|
240
|
+
}
|
|
241
|
+
return new Promise((resolve, reject) => {
|
|
242
|
+
const timer = setTimeout(() => {
|
|
243
|
+
reject(new Error("Timed out connecting to Ably"));
|
|
244
|
+
}, timeoutMs);
|
|
245
|
+
ably.connection.once("connected", () => {
|
|
246
|
+
clearTimeout(timer);
|
|
247
|
+
resolve();
|
|
248
|
+
});
|
|
249
|
+
ably.connection.once("failed", (stateChange) => {
|
|
250
|
+
clearTimeout(timer);
|
|
251
|
+
reject(
|
|
252
|
+
new Error(
|
|
253
|
+
`Ably connection failed: ${stateChange?.reason?.message ?? "unknown"}`
|
|
254
|
+
)
|
|
255
|
+
);
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
async function createBuiltInGenerationNotifier(accepted) {
|
|
260
|
+
const ably = createBuiltInGenerationRealtime(accepted);
|
|
261
|
+
try {
|
|
262
|
+
await waitForRealtimeConnected(ably);
|
|
263
|
+
const channel = ably.channels.get(accepted.realtime.channelName);
|
|
264
|
+
let pendingEvent = false;
|
|
265
|
+
let closed = false;
|
|
266
|
+
let wake = null;
|
|
267
|
+
const wakeWaiter = () => {
|
|
268
|
+
const current = wake;
|
|
269
|
+
wake = null;
|
|
270
|
+
current?.();
|
|
271
|
+
};
|
|
272
|
+
const onMessage = (_message) => {
|
|
273
|
+
if (wake) {
|
|
274
|
+
wakeWaiter();
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
pendingEvent = true;
|
|
278
|
+
};
|
|
279
|
+
await channel.subscribe(accepted.realtime.eventName, onMessage);
|
|
280
|
+
return {
|
|
281
|
+
wait(timeoutMs) {
|
|
282
|
+
if (pendingEvent || closed || timeoutMs <= 0) {
|
|
283
|
+
pendingEvent = false;
|
|
284
|
+
return Promise.resolve();
|
|
285
|
+
}
|
|
286
|
+
return new Promise((resolve) => {
|
|
287
|
+
function done() {
|
|
288
|
+
clearTimeout(timer);
|
|
289
|
+
if (wake === done) {
|
|
290
|
+
wake = null;
|
|
291
|
+
}
|
|
292
|
+
resolve();
|
|
293
|
+
}
|
|
294
|
+
const timer = setTimeout(done, timeoutMs);
|
|
295
|
+
wake = done;
|
|
296
|
+
});
|
|
297
|
+
},
|
|
298
|
+
close() {
|
|
299
|
+
if (closed) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
closed = true;
|
|
303
|
+
channel.unsubscribe(accepted.realtime.eventName, onMessage);
|
|
304
|
+
wakeWaiter();
|
|
305
|
+
ably.close();
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
} catch {
|
|
309
|
+
ably.close();
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
async function getBuiltInGenerationStatus(baseUrl, token, generationId) {
|
|
314
|
+
const response = await fetch(
|
|
315
|
+
new URL(`/api/zero/built-in-generations/${generationId}`, baseUrl),
|
|
316
|
+
{ headers: authenticatedJsonHeaders(token) }
|
|
317
|
+
);
|
|
318
|
+
if (!response.ok) {
|
|
319
|
+
const { message, code } = await parseErrorBody(
|
|
320
|
+
response,
|
|
321
|
+
"Failed to get generation status"
|
|
322
|
+
);
|
|
323
|
+
throw new ApiRequestError(message, code, response.status);
|
|
324
|
+
}
|
|
325
|
+
return await response.json();
|
|
326
|
+
}
|
|
327
|
+
function readBuiltInGenerationResult(status, fallback) {
|
|
328
|
+
if (status.status === "completed") {
|
|
329
|
+
if (!status.result) {
|
|
330
|
+
throw new ApiRequestError(
|
|
331
|
+
`${fallback} returned no result`,
|
|
332
|
+
"EMPTY_RESULT",
|
|
333
|
+
502
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
return status.result;
|
|
337
|
+
}
|
|
338
|
+
if (status.status === "failed") {
|
|
339
|
+
const code = status.error?.code ?? "GENERATION_FAILED";
|
|
340
|
+
throw new ApiRequestError(
|
|
341
|
+
status.error?.message ?? `${fallback} failed`,
|
|
342
|
+
code,
|
|
343
|
+
statusForBuiltInGenerationError(code)
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
return void 0;
|
|
347
|
+
}
|
|
348
|
+
function statusForBuiltInGenerationError(code) {
|
|
349
|
+
if (code === "BAD_REQUEST") {
|
|
350
|
+
return 400;
|
|
351
|
+
}
|
|
352
|
+
if (code === "INSUFFICIENT_CREDITS") {
|
|
353
|
+
return 402;
|
|
354
|
+
}
|
|
355
|
+
if (code === "NOT_CONFIGURED") {
|
|
356
|
+
return 503;
|
|
357
|
+
}
|
|
358
|
+
if (code === "GENERATION_TIMEOUT") {
|
|
359
|
+
return 504;
|
|
360
|
+
}
|
|
361
|
+
if (code.startsWith("BYTEPLUS_INVALID_PARAMETER") || code.startsWith("BYTEPLUS_INPUT_")) {
|
|
362
|
+
return 400;
|
|
363
|
+
}
|
|
364
|
+
if (code.startsWith("BYTEPLUS_")) {
|
|
365
|
+
return 502;
|
|
366
|
+
}
|
|
367
|
+
if (code.startsWith("NO_") || code.endsWith("_FAILED")) {
|
|
368
|
+
return 502;
|
|
369
|
+
}
|
|
370
|
+
return 500;
|
|
371
|
+
}
|
|
372
|
+
async function waitForBuiltInGenerationResult(args) {
|
|
373
|
+
let notifier = null;
|
|
374
|
+
let notifierCreated = false;
|
|
375
|
+
const startedAt = Date.now();
|
|
376
|
+
const timeoutMs = BUILT_IN_GENERATION_WAIT_TIMEOUT_MS_BY_TYPE[args.accepted.type];
|
|
377
|
+
try {
|
|
378
|
+
while (Date.now() - startedAt < timeoutMs) {
|
|
379
|
+
const status = await getBuiltInGenerationStatus(
|
|
380
|
+
args.baseUrl,
|
|
381
|
+
args.token,
|
|
382
|
+
args.accepted.generationId
|
|
383
|
+
);
|
|
384
|
+
const result = readBuiltInGenerationResult(status, args.fallback);
|
|
385
|
+
if (result) {
|
|
386
|
+
return result;
|
|
387
|
+
}
|
|
388
|
+
const elapsed = Date.now() - startedAt;
|
|
389
|
+
const remaining = timeoutMs - elapsed;
|
|
390
|
+
const waitMs = Math.min(BUILT_IN_GENERATION_POLL_INTERVAL_MS, remaining);
|
|
391
|
+
if (!notifierCreated) {
|
|
392
|
+
notifier = await createBuiltInGenerationNotifier(args.accepted);
|
|
393
|
+
notifierCreated = true;
|
|
394
|
+
}
|
|
395
|
+
if (notifier) {
|
|
396
|
+
await notifier.wait(waitMs);
|
|
397
|
+
} else {
|
|
398
|
+
await delay(waitMs);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
} finally {
|
|
402
|
+
notifier?.close();
|
|
403
|
+
}
|
|
404
|
+
throw new ApiRequestError(
|
|
405
|
+
`${args.fallback} timed out (generationId: ${args.accepted.generationId})`,
|
|
406
|
+
"GENERATION_TIMEOUT",
|
|
407
|
+
504
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
async function readBuiltInGenerationResponse(args) {
|
|
411
|
+
const body = await args.response.json();
|
|
412
|
+
if (isBuiltInGenerationAcceptedResponse(body)) {
|
|
413
|
+
return waitForBuiltInGenerationResult({
|
|
414
|
+
accepted: body,
|
|
415
|
+
baseUrl: args.baseUrl,
|
|
416
|
+
token: args.token,
|
|
417
|
+
fallback: args.fallback
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
if (args.response.status === 202) {
|
|
421
|
+
throw new ApiRequestError(
|
|
422
|
+
`${args.fallback} returned an invalid generation response`,
|
|
423
|
+
"INVALID_GENERATION_RESPONSE",
|
|
424
|
+
502
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
return body;
|
|
428
|
+
}
|
|
429
|
+
async function uploadWebFile(localPath, options) {
|
|
430
|
+
const stats = statSync(localPath);
|
|
431
|
+
if (!stats.isFile()) {
|
|
432
|
+
throw new ApiRequestError(
|
|
433
|
+
`Not a regular file: ${localPath}`,
|
|
434
|
+
"BAD_REQUEST",
|
|
435
|
+
400
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
const baseUrl = await getBaseUrl();
|
|
439
|
+
const token = await getActiveToken();
|
|
440
|
+
if (!token) {
|
|
441
|
+
throw new ApiRequestError("Not authenticated", "UNAUTHORIZED", 401);
|
|
442
|
+
}
|
|
443
|
+
const filename = basename(localPath);
|
|
444
|
+
const contentType = options?.contentType ?? inferContentType(localPath);
|
|
445
|
+
const prepareHeaders = {
|
|
446
|
+
Authorization: `Bearer ${token}`,
|
|
447
|
+
"Content-Type": "application/json"
|
|
448
|
+
};
|
|
449
|
+
const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
|
|
450
|
+
if (bypassSecret) {
|
|
451
|
+
prepareHeaders["x-vercel-protection-bypass"] = bypassSecret;
|
|
452
|
+
}
|
|
453
|
+
const prepareUrl = new URL("/api/zero/uploads/prepare", baseUrl);
|
|
454
|
+
const prepareRes = await fetch(prepareUrl, {
|
|
455
|
+
method: "POST",
|
|
456
|
+
headers: headersWithCliClientHeaders(prepareHeaders),
|
|
457
|
+
body: JSON.stringify({ filename, contentType, size: stats.size })
|
|
458
|
+
});
|
|
459
|
+
if (!prepareRes.ok) {
|
|
460
|
+
const { message, code } = await parseErrorBody(
|
|
461
|
+
prepareRes,
|
|
462
|
+
"Failed to prepare upload"
|
|
463
|
+
);
|
|
464
|
+
throw new ApiRequestError(message, code, prepareRes.status);
|
|
465
|
+
}
|
|
466
|
+
const prepared = await prepareRes.json();
|
|
467
|
+
const bytes = readFileSync(localPath);
|
|
468
|
+
const putRes = await fetch(prepared.uploadUrl, {
|
|
469
|
+
method: "PUT",
|
|
470
|
+
headers: { "Content-Type": prepared.contentType },
|
|
471
|
+
body: new Uint8Array(bytes)
|
|
472
|
+
});
|
|
473
|
+
if (!putRes.ok) {
|
|
474
|
+
throw new ApiRequestError(
|
|
475
|
+
`Failed to upload file to storage (HTTP ${putRes.status})`,
|
|
476
|
+
"UPLOAD_FAILED",
|
|
477
|
+
putRes.status
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
const completeUrl = new URL("/api/zero/uploads/complete", baseUrl);
|
|
481
|
+
const completeRes = await fetch(completeUrl, {
|
|
482
|
+
method: "POST",
|
|
483
|
+
headers: headersWithCliClientHeaders(prepareHeaders),
|
|
484
|
+
body: JSON.stringify({
|
|
485
|
+
id: prepared.id,
|
|
486
|
+
contentType: prepared.contentType
|
|
487
|
+
})
|
|
488
|
+
});
|
|
489
|
+
if (!completeRes.ok) {
|
|
490
|
+
const { message, code } = await parseErrorBody(
|
|
491
|
+
completeRes,
|
|
492
|
+
"Failed to complete upload"
|
|
493
|
+
);
|
|
494
|
+
throw new ApiRequestError(message, code, completeRes.status);
|
|
495
|
+
}
|
|
496
|
+
const completed = await completeRes.json();
|
|
497
|
+
return {
|
|
498
|
+
id: completed.id,
|
|
499
|
+
filename: completed.filename,
|
|
500
|
+
contentType: completed.contentType,
|
|
501
|
+
size: completed.size,
|
|
502
|
+
url: completed.url
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
async function generateWebVoice(options) {
|
|
506
|
+
const baseUrl = await getBaseUrl();
|
|
507
|
+
const token = await getActiveToken();
|
|
508
|
+
if (!token) {
|
|
509
|
+
throw new ApiRequestError("Not authenticated", "UNAUTHORIZED", 401);
|
|
510
|
+
}
|
|
511
|
+
const headers = {
|
|
512
|
+
Authorization: `Bearer ${token}`,
|
|
513
|
+
"Content-Type": "application/json"
|
|
514
|
+
};
|
|
515
|
+
const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
|
|
516
|
+
if (bypassSecret) {
|
|
517
|
+
headers["x-vercel-protection-bypass"] = bypassSecret;
|
|
518
|
+
}
|
|
519
|
+
const response = await fetch(new URL("/api/zero/voice-io/speech", baseUrl), {
|
|
520
|
+
method: "POST",
|
|
521
|
+
headers: headersWithCliClientHeaders(headers),
|
|
522
|
+
body: JSON.stringify({
|
|
523
|
+
text: options.text,
|
|
524
|
+
...options.voice ? { voice: options.voice } : {},
|
|
525
|
+
...options.instructions ? { instructions: options.instructions } : {}
|
|
526
|
+
})
|
|
527
|
+
});
|
|
528
|
+
if (!response.ok) {
|
|
529
|
+
const { message, code } = await parseErrorBody(
|
|
530
|
+
response,
|
|
531
|
+
"Failed to generate voice"
|
|
532
|
+
);
|
|
533
|
+
throw new ApiRequestError(message, code, response.status);
|
|
534
|
+
}
|
|
535
|
+
return await response.json();
|
|
536
|
+
}
|
|
537
|
+
async function generateWebImage(options) {
|
|
538
|
+
const baseUrl = await getBaseUrl();
|
|
539
|
+
const token = await getActiveToken();
|
|
540
|
+
if (!token) {
|
|
541
|
+
throw new ApiRequestError("Not authenticated", "UNAUTHORIZED", 401);
|
|
542
|
+
}
|
|
543
|
+
const headers = {
|
|
544
|
+
Authorization: `Bearer ${token}`,
|
|
545
|
+
"Content-Type": "application/json"
|
|
546
|
+
};
|
|
547
|
+
const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
|
|
548
|
+
if (bypassSecret) {
|
|
549
|
+
headers["x-vercel-protection-bypass"] = bypassSecret;
|
|
550
|
+
}
|
|
551
|
+
const response = await fetch(
|
|
552
|
+
new URL("/api/zero/image-io/generate", baseUrl),
|
|
553
|
+
{
|
|
554
|
+
method: "POST",
|
|
555
|
+
headers: headersWithCliClientHeaders(headers),
|
|
556
|
+
body: JSON.stringify({
|
|
557
|
+
prompt: options.prompt,
|
|
558
|
+
...options.model ? { model: options.model } : {},
|
|
559
|
+
...options.size ? { size: options.size } : {},
|
|
560
|
+
...options.quality ? { quality: options.quality } : {},
|
|
561
|
+
...options.background ? { background: options.background } : {},
|
|
562
|
+
...options.outputFormat ? { outputFormat: options.outputFormat } : {},
|
|
563
|
+
...options.outputCompression !== void 0 ? { outputCompression: options.outputCompression } : {},
|
|
564
|
+
...options.moderation ? { moderation: options.moderation } : {},
|
|
565
|
+
...options.seed !== void 0 ? { seed: options.seed } : {},
|
|
566
|
+
...options.safetyTolerance ? { safetyTolerance: options.safetyTolerance } : {},
|
|
567
|
+
...options.enhancePrompt !== void 0 ? { enhancePrompt: options.enhancePrompt } : {},
|
|
568
|
+
...options.imageUrls && options.imageUrls.length > 0 ? { imageUrls: options.imageUrls } : {},
|
|
569
|
+
...options.maskImageUrl ? { maskImageUrl: options.maskImageUrl } : {},
|
|
570
|
+
...options.inputFidelity ? { inputFidelity: options.inputFidelity } : {},
|
|
571
|
+
...options.imagePromptStrength !== void 0 ? { imagePromptStrength: options.imagePromptStrength } : {}
|
|
572
|
+
})
|
|
573
|
+
}
|
|
574
|
+
);
|
|
575
|
+
if (!response.ok) {
|
|
576
|
+
const { message, code } = await parseErrorBody(
|
|
577
|
+
response,
|
|
578
|
+
"Failed to generate image"
|
|
579
|
+
);
|
|
580
|
+
throw new ApiRequestError(message, code, response.status);
|
|
581
|
+
}
|
|
582
|
+
return readBuiltInGenerationResponse({
|
|
583
|
+
response,
|
|
584
|
+
baseUrl,
|
|
585
|
+
token,
|
|
586
|
+
fallback: "Failed to generate image"
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
async function generateWebVideo(options) {
|
|
590
|
+
const baseUrl = await getBaseUrl();
|
|
591
|
+
const token = await getActiveToken();
|
|
592
|
+
if (!token) {
|
|
593
|
+
throw new ApiRequestError("Not authenticated", "UNAUTHORIZED", 401);
|
|
594
|
+
}
|
|
595
|
+
const headers = {
|
|
596
|
+
Authorization: `Bearer ${token}`,
|
|
597
|
+
"Content-Type": "application/json"
|
|
598
|
+
};
|
|
599
|
+
const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
|
|
600
|
+
if (bypassSecret) {
|
|
601
|
+
headers["x-vercel-protection-bypass"] = bypassSecret;
|
|
602
|
+
}
|
|
603
|
+
const response = await fetch(
|
|
604
|
+
new URL("/api/zero/video-io/generate", baseUrl),
|
|
605
|
+
{
|
|
606
|
+
method: "POST",
|
|
607
|
+
headers: headersWithCliClientHeaders(headers),
|
|
608
|
+
body: JSON.stringify(generateWebVideoPayload(options))
|
|
609
|
+
}
|
|
610
|
+
);
|
|
611
|
+
if (!response.ok) {
|
|
612
|
+
const { message, code } = await parseErrorBody(
|
|
613
|
+
response,
|
|
614
|
+
"Failed to generate video"
|
|
615
|
+
);
|
|
616
|
+
throw new ApiRequestError(message, code, response.status);
|
|
617
|
+
}
|
|
618
|
+
return readBuiltInGenerationResponse({
|
|
619
|
+
response,
|
|
620
|
+
baseUrl,
|
|
621
|
+
token,
|
|
622
|
+
fallback: "Failed to generate video"
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
async function transcribeAudio(audioPath, options = {}) {
|
|
626
|
+
const baseUrl = await getBaseUrl();
|
|
627
|
+
const token = await getActiveToken();
|
|
628
|
+
if (!token) {
|
|
629
|
+
throw new ApiRequestError("Not authenticated", "UNAUTHORIZED", 401);
|
|
630
|
+
}
|
|
631
|
+
const headers = {
|
|
632
|
+
Authorization: `Bearer ${token}`
|
|
633
|
+
};
|
|
634
|
+
const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
|
|
635
|
+
if (bypassSecret) {
|
|
636
|
+
headers["x-vercel-protection-bypass"] = bypassSecret;
|
|
637
|
+
}
|
|
638
|
+
const url = new URL("/api/zero/voice-io/stt", baseUrl);
|
|
639
|
+
if (options.verbose) {
|
|
640
|
+
url.searchParams.set("verbose", "true");
|
|
641
|
+
}
|
|
642
|
+
const audioData = readFileSync(audioPath);
|
|
643
|
+
const filename = basename(audioPath);
|
|
644
|
+
const ext = extname(filename).toLowerCase();
|
|
645
|
+
const mimeMap = {
|
|
646
|
+
".mp3": "audio/mpeg",
|
|
647
|
+
".mp4": "audio/mp4",
|
|
648
|
+
".m4a": "audio/m4a",
|
|
649
|
+
".wav": "audio/wav",
|
|
650
|
+
".webm": "audio/webm"
|
|
651
|
+
};
|
|
652
|
+
const mimeType = mimeMap[ext] ?? "audio/mpeg";
|
|
653
|
+
const formData = new FormData();
|
|
654
|
+
formData.append("file", new Blob([audioData], { type: mimeType }), filename);
|
|
655
|
+
const response = await fetch(url, {
|
|
656
|
+
method: "POST",
|
|
657
|
+
headers: headersWithCliClientHeaders(headers),
|
|
658
|
+
body: formData
|
|
659
|
+
});
|
|
660
|
+
if (!response.ok) {
|
|
661
|
+
const { message, code } = await parseErrorBody(
|
|
662
|
+
response,
|
|
663
|
+
"Transcription failed"
|
|
664
|
+
);
|
|
665
|
+
throw new ApiRequestError(message, code, response.status);
|
|
666
|
+
}
|
|
667
|
+
return await response.json();
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
export {
|
|
671
|
+
downloadWebFile,
|
|
672
|
+
uploadWebFile,
|
|
673
|
+
generateWebVoice,
|
|
674
|
+
generateWebImage,
|
|
675
|
+
generateWebVideo,
|
|
676
|
+
transcribeAudio
|
|
677
|
+
};
|
|
678
|
+
//# sourceMappingURL=chunk-N6TDQYGF.js.map
|