@vm0/cli 9.244.8 → 9.245.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/{agent-QLXX4WY7.js → agent-G4K3H6XM.js} +6 -5
  2. package/{agent-QLXX4WY7.js.map → agent-G4K3H6XM.js.map} +1 -1
  3. package/{banking-WY3J5BTJ.js → banking-EKOZ3Q5H.js} +4 -3
  4. package/{banking-WY3J5BTJ.js.map → banking-EKOZ3Q5H.js.map} +1 -1
  5. package/{chat-L3EFI2XJ.js → chat-LJVPQ6E3.js} +5 -4
  6. package/{chat-L3EFI2XJ.js.map → chat-LJVPQ6E3.js.map} +1 -1
  7. package/{chunk-TTP663DN.js → chunk-35SF4MIM.js} +2 -2
  8. package/{chunk-KMLBXZVR.js → chunk-3AV5UOJI.js} +2 -2
  9. package/{chunk-43PGP5OI.js → chunk-AKRDZBGF.js} +4 -4
  10. package/{chunk-JVIFZRZ7.js → chunk-C2X2AMNB.js} +3 -3
  11. package/{chunk-LHR5Z775.js → chunk-D7RUZAYZ.js} +2 -2
  12. package/{chunk-MX32FFQR.js → chunk-HFZVT4HJ.js} +60 -506
  13. package/chunk-HFZVT4HJ.js.map +1 -0
  14. package/{chunk-65MTNZ44.js → chunk-LNJWRJPF.js} +786 -1217
  15. package/chunk-LNJWRJPF.js.map +1 -0
  16. package/{chunk-WCRXAO2G.js → chunk-QO2ZPLKJ.js} +2 -2
  17. package/chunk-TLZUMBBR.js +678 -0
  18. package/chunk-TLZUMBBR.js.map +1 -0
  19. package/{chunk-MA37R4QS.js → chunk-WEEPG6HO.js} +3 -665
  20. package/chunk-WEEPG6HO.js.map +1 -0
  21. package/{computer-use-7FYLJXZS.js → computer-use-INB6UBIB.js} +4 -3
  22. package/{computer-use-7FYLJXZS.js.map → computer-use-INB6UBIB.js.map} +1 -1
  23. package/{connector-BSBQIFMQ.js → connector-P3EJMWEQ.js} +7 -6
  24. package/{connector-BSBQIFMQ.js.map → connector-P3EJMWEQ.js.map} +1 -1
  25. package/{credit-JBFJY5US.js → credit-4HVDTUJU.js} +5 -4
  26. package/{credit-JBFJY5US.js.map → credit-4HVDTUJU.js.map} +1 -1
  27. package/{developer-support-RUWSZBFP.js → developer-support-H2WWODQP.js} +4 -3
  28. package/{developer-support-RUWSZBFP.js.map → developer-support-H2WWODQP.js.map} +1 -1
  29. package/{doctor-YLD526OE.js → doctor-5J2UDQ7Y.js} +4 -3
  30. package/{doctor-YLD526OE.js.map → doctor-5J2UDQ7Y.js.map} +1 -1
  31. package/{generate-5EMJ3PE6.js → generate-ZQSGF4JD.js} +10 -8
  32. package/{generate-5EMJ3PE6.js.map → generate-ZQSGF4JD.js.map} +1 -1
  33. package/{github-36XCAIUP.js → github-L7OTQLJ3.js} +4 -3
  34. package/{github-36XCAIUP.js.map → github-L7OTQLJ3.js.map} +1 -1
  35. package/{goal-FRXLYRUG.js → goal-OD43U6LO.js} +4 -3
  36. package/{goal-FRXLYRUG.js.map → goal-OD43U6LO.js.map} +1 -1
  37. package/{host-X2KS3WTS.js → host-AHDILSME.js} +28 -7
  38. package/host-AHDILSME.js.map +1 -0
  39. package/index.js +4 -715
  40. package/index.js.map +1 -1
  41. package/{logs-WHQES7BY.js → logs-B5UAWP3H.js} +13 -14
  42. package/logs-B5UAWP3H.js.map +1 -0
  43. package/{mail-LOXCIZZN.js → mail-OLFTOSFS.js} +6 -5
  44. package/{mail-LOXCIZZN.js.map → mail-OLFTOSFS.js.map} +1 -1
  45. package/{maps-KQWCQLHW.js → maps-5275BTHE.js} +4 -3
  46. package/{maps-KQWCQLHW.js.map → maps-5275BTHE.js.map} +1 -1
  47. package/{model-2BBROTMX.js → model-3PJFWIGT.js} +5 -4
  48. package/{model-2BBROTMX.js.map → model-3PJFWIGT.js.map} +1 -1
  49. package/{model-provider-BOMTZ6JA.js → model-provider-MFTEUVUR.js} +5 -4
  50. package/{model-provider-BOMTZ6JA.js.map → model-provider-MFTEUVUR.js.map} +1 -1
  51. package/{org-SO7ELOV6.js → org-FYW5SKNL.js} +4 -3
  52. package/{org-SO7ELOV6.js.map → org-FYW5SKNL.js.map} +1 -1
  53. package/package.json +1 -1
  54. package/{phone-IYUG3RGY.js → phone-GPEGHEYZ.js} +4 -3
  55. package/{phone-IYUG3RGY.js.map → phone-GPEGHEYZ.js.map} +1 -1
  56. package/{preference-TGBWXIP7.js → preference-VZPSASBS.js} +4 -3
  57. package/{preference-TGBWXIP7.js.map → preference-VZPSASBS.js.map} +1 -1
  58. package/{resource-EA5OUVG4.js → resource-U2AKCUW6.js} +4 -3
  59. package/{resource-EA5OUVG4.js.map → resource-U2AKCUW6.js.map} +1 -1
  60. package/{scrape-2S3B33RA.js → scrape-75TPDRWU.js} +4 -3
  61. package/{scrape-2S3B33RA.js.map → scrape-75TPDRWU.js.map} +1 -1
  62. package/{search-LCGK3BJI.js → search-FTR3X5KB.js} +9 -10
  63. package/search-FTR3X5KB.js.map +1 -0
  64. package/{secret-M5C54VAT.js → secret-EDHHGJ74.js} +4 -3
  65. package/{secret-M5C54VAT.js.map → secret-EDHHGJ74.js.map} +1 -1
  66. package/{slack-FJV2NEOT.js → slack-HMY4W3TP.js} +4 -3
  67. package/{slack-FJV2NEOT.js.map → slack-HMY4W3TP.js.map} +1 -1
  68. package/{teams-XBLEN2XV.js → teams-FEBFKEOJ.js} +4 -3
  69. package/{teams-XBLEN2XV.js.map → teams-FEBFKEOJ.js.map} +1 -1
  70. package/{telegram-RE6IO7ZT.js → telegram-JXCTBHDN.js} +4 -3
  71. package/{telegram-RE6IO7ZT.js.map → telegram-JXCTBHDN.js.map} +1 -1
  72. package/{variable-5MVUR6U4.js → variable-X6MW44CV.js} +4 -3
  73. package/{variable-5MVUR6U4.js.map → variable-X6MW44CV.js.map} +1 -1
  74. package/{video-DIVG6CMM.js → video-HKMGD425.js} +6 -4
  75. package/{video-DIVG6CMM.js.map → video-HKMGD425.js.map} +1 -1
  76. package/{web-KVZL6WM4.js → web-PQCJRMF2.js} +7 -5
  77. package/{web-KVZL6WM4.js.map → web-PQCJRMF2.js.map} +1 -1
  78. package/{web-search-XNJH2FXZ.js → web-search-GE3BRO7E.js} +4 -3
  79. package/{web-search-XNJH2FXZ.js.map → web-search-GE3BRO7E.js.map} +1 -1
  80. package/{whoami-NQYYRWEE.js → whoami-FJVWNO4Z.js} +6 -5
  81. package/{whoami-NQYYRWEE.js.map → whoami-FJVWNO4Z.js.map} +1 -1
  82. package/{workflow-5CGPRRAY.js → workflow-CM6JMVRA.js} +4 -3
  83. package/{workflow-5CGPRRAY.js.map → workflow-CM6JMVRA.js.map} +1 -1
  84. package/zero.js +35 -35
  85. package/chunk-65MTNZ44.js.map +0 -1
  86. package/chunk-MA37R4QS.js.map +0 -1
  87. package/chunk-MPSVIFKZ.js +0 -240
  88. package/chunk-MPSVIFKZ.js.map +0 -1
  89. package/chunk-MX32FFQR.js.map +0 -1
  90. package/chunk-ZUSDQG2O.js +0 -50
  91. package/chunk-ZUSDQG2O.js.map +0 -1
  92. package/host-X2KS3WTS.js.map +0 -1
  93. package/logs-WHQES7BY.js.map +0 -1
  94. package/search-LCGK3BJI.js.map +0 -1
  95. /package/{chunk-TTP663DN.js.map → chunk-35SF4MIM.js.map} +0 -0
  96. /package/{chunk-KMLBXZVR.js.map → chunk-3AV5UOJI.js.map} +0 -0
  97. /package/{chunk-43PGP5OI.js.map → chunk-AKRDZBGF.js.map} +0 -0
  98. /package/{chunk-JVIFZRZ7.js.map → chunk-C2X2AMNB.js.map} +0 -0
  99. /package/{chunk-LHR5Z775.js.map → chunk-D7RUZAYZ.js.map} +0 -0
  100. /package/{chunk-WCRXAO2G.js.map → chunk-QO2ZPLKJ.js.map} +0 -0
@@ -16440,7 +16440,7 @@ function createCliClientHeaderInjector(options) {
16440
16440
  };
16441
16441
  }
16442
16442
  var addDefaultCliClientHeaders = createCliClientHeaderInjector({
16443
- clientVersion: "9.244.8"
16443
+ clientVersion: "9.245.1"
16444
16444
  });
16445
16445
  function addCliClientHeaders(headers) {
16446
16446
  addDefaultCliClientHeaders(headers);
@@ -16632,662 +16632,6 @@ function withErrorHandler(fn) {
16632
16632
  };
16633
16633
  }
16634
16634
 
16635
- // src/lib/api/domains/web.ts
16636
- init_esm_shims();
16637
- import { createWriteStream, readFileSync, statSync } from "fs";
16638
- import { basename, extname } from "path";
16639
- import { Readable } from "stream";
16640
- import { pipeline } from "stream/promises";
16641
- import { setTimeout as delay } from "timers/promises";
16642
- import { Realtime } from "ably";
16643
- var BUILT_IN_GENERATION_POLL_INTERVAL_MS = 2e3;
16644
- var BUILT_IN_GENERATION_WAIT_TIMEOUT_MS_BY_TYPE = {
16645
- image: 15 * 60 * 1e3,
16646
- video: 30 * 60 * 1e3,
16647
- presentation: 60 * 60 * 1e3,
16648
- website: 60 * 60 * 1e3
16649
- };
16650
- var ABLY_CONNECT_TIMEOUT_MS = 1e4;
16651
- var MIME_BY_EXTENSION = {
16652
- ".png": "image/png",
16653
- ".jpg": "image/jpeg",
16654
- ".jpeg": "image/jpeg",
16655
- ".gif": "image/gif",
16656
- ".webp": "image/webp",
16657
- ".avif": "image/avif",
16658
- ".svg": "image/svg+xml",
16659
- ".bmp": "image/bmp",
16660
- ".heic": "image/heic",
16661
- ".heif": "image/heif",
16662
- ".tif": "image/tiff",
16663
- ".tiff": "image/tiff",
16664
- ".psd": "image/vnd.adobe.photoshop",
16665
- ".mp4": "video/mp4",
16666
- ".webm": "video/webm",
16667
- ".mov": "video/quicktime",
16668
- ".aac": "audio/aac",
16669
- ".flac": "audio/flac",
16670
- ".m4a": "audio/mp4",
16671
- ".mp3": "audio/mpeg",
16672
- ".mpga": "audio/mpga",
16673
- ".oga": "audio/ogg",
16674
- ".ogg": "audio/ogg",
16675
- ".opus": "audio/opus",
16676
- ".wav": "audio/wav",
16677
- ".wave": "audio/wave",
16678
- ".pdf": "application/pdf",
16679
- ".txt": "text/plain",
16680
- ".csv": "text/csv",
16681
- ".md": "text/markdown",
16682
- ".html": "text/html",
16683
- ".htm": "text/html",
16684
- ".json": "application/json",
16685
- ".xml": "application/xml",
16686
- ".yaml": "application/yaml",
16687
- ".yml": "application/yaml",
16688
- ".tsv": "text/tab-separated-values",
16689
- ".doc": "application/msword",
16690
- ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
16691
- ".docm": "application/vnd.ms-word.document.macroenabled.12",
16692
- ".dotm": "application/vnd.ms-word.template.macroenabled.12",
16693
- ".dotx": "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
16694
- ".odt": "application/vnd.oasis.opendocument.text",
16695
- ".rtf": "application/rtf",
16696
- ".xls": "application/vnd.ms-excel",
16697
- ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
16698
- ".xlsb": "application/vnd.ms-excel.sheet.binary.macroenabled.12",
16699
- ".xlsm": "application/vnd.ms-excel.sheet.macroenabled.12",
16700
- ".xltm": "application/vnd.ms-excel.template.macroenabled.12",
16701
- ".xltx": "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
16702
- ".ods": "application/vnd.oasis.opendocument.spreadsheet",
16703
- ".ppt": "application/vnd.ms-powerpoint",
16704
- ".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
16705
- ".potm": "application/vnd.ms-powerpoint.template.macroenabled.12",
16706
- ".potx": "application/vnd.openxmlformats-officedocument.presentationml.template",
16707
- ".odp": "application/vnd.oasis.opendocument.presentation",
16708
- ".ppsx": "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
16709
- ".ppsm": "application/vnd.ms-powerpoint.slideshow.macroenabled.12",
16710
- ".pptm": "application/vnd.ms-powerpoint.presentation.macroenabled.12",
16711
- ".zip": "application/zip",
16712
- ".rar": "application/vnd.rar",
16713
- ".7z": "application/x-7z-compressed",
16714
- ".tar": "application/x-tar",
16715
- ".gz": "application/gzip",
16716
- ".tgz": "application/gzip",
16717
- ".bz2": "application/x-bzip2",
16718
- ".xz": "application/x-xz",
16719
- ".pages": "application/vnd.apple.pages",
16720
- ".numbers": "application/vnd.apple.numbers",
16721
- ".key": "application/vnd.apple.keynote",
16722
- ".parquet": "application/vnd.apache.parquet",
16723
- ".sqlite": "application/vnd.sqlite3",
16724
- ".sqlite3": "application/vnd.sqlite3",
16725
- ".db": "application/vnd.sqlite3",
16726
- ".epub": "application/epub+zip",
16727
- ".ai": "application/postscript"
16728
- };
16729
- function inferContentType(localPath) {
16730
- const ext = extname(localPath).toLowerCase();
16731
- return MIME_BY_EXTENSION[ext] ?? "application/octet-stream";
16732
- }
16733
- async function downloadWebFile(fileId, outPath) {
16734
- const baseUrl = await getBaseUrl();
16735
- const token = await getActiveToken();
16736
- if (!token) {
16737
- throw new ApiRequestError("Not authenticated", "UNAUTHORIZED", 401);
16738
- }
16739
- const url2 = new URL("/api/zero/web/download-file", baseUrl);
16740
- url2.searchParams.set("file_id", fileId);
16741
- const headers = {
16742
- Authorization: `Bearer ${token}`
16743
- };
16744
- const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
16745
- if (bypassSecret) {
16746
- headers["x-vercel-protection-bypass"] = bypassSecret;
16747
- }
16748
- const response = await fetch(url2, {
16749
- headers: headersWithCliClientHeaders(headers)
16750
- });
16751
- if (!response.ok) {
16752
- let message = `Failed to download web file (HTTP ${response.status})`;
16753
- let code = "UNKNOWN";
16754
- try {
16755
- const body = await response.json();
16756
- if (body.error?.message) message = body.error.message;
16757
- if (body.error?.code) code = body.error.code;
16758
- } catch {
16759
- }
16760
- throw new ApiRequestError(message, code, response.status);
16761
- }
16762
- if (!response.body) {
16763
- throw new ApiRequestError(
16764
- "Web download response has no body",
16765
- "EMPTY_BODY",
16766
- 502
16767
- );
16768
- }
16769
- const mimetype = response.headers.get("x-file-mimetype") ?? response.headers.get("content-type") ?? "application/octet-stream";
16770
- await pipeline(
16771
- Readable.fromWeb(response.body),
16772
- createWriteStream(outPath)
16773
- );
16774
- const contentLengthHeader = response.headers.get("content-length");
16775
- const size = contentLengthHeader ? Number(contentLengthHeader) : 0;
16776
- return { path: outPath, mimetype, size };
16777
- }
16778
- function shouldIncludePayloadValue(value) {
16779
- if (value === void 0) {
16780
- return false;
16781
- }
16782
- return !Array.isArray(value) || value.length > 0;
16783
- }
16784
- function compactPayload(entries) {
16785
- return Object.fromEntries(
16786
- entries.filter(([, value]) => {
16787
- return shouldIncludePayloadValue(value);
16788
- })
16789
- );
16790
- }
16791
- function generateWebVideoPayload(options) {
16792
- return compactPayload([
16793
- ["prompt", options.prompt],
16794
- ["model", options.model],
16795
- ["aspectRatio", options.aspectRatio],
16796
- ["duration", options.duration],
16797
- ["resolution", options.resolution],
16798
- ["generateAudio", options.generateAudio],
16799
- ["negativePrompt", options.negativePrompt],
16800
- ["seed", options.seed],
16801
- ["autoFix", options.autoFix],
16802
- ["safetyTolerance", options.safetyTolerance],
16803
- ["imageUrls", options.imageUrls],
16804
- ["videoUrls", options.videoUrls],
16805
- ["audioUrls", options.audioUrls],
16806
- ["firstFrameImageUrl", options.firstFrameImageUrl],
16807
- ["lastFrameImageUrl", options.lastFrameImageUrl]
16808
- ]);
16809
- }
16810
- async function parseErrorBody(response, fallback) {
16811
- let message = `${fallback} (HTTP ${response.status})`;
16812
- let code = "UNKNOWN";
16813
- try {
16814
- const body = await response.json();
16815
- if (body.error?.message) message = body.error.message;
16816
- if (body.error?.code) code = body.error.code;
16817
- } catch {
16818
- }
16819
- return { message, code };
16820
- }
16821
- function authenticatedJsonHeaders(token) {
16822
- const headers = {
16823
- Authorization: `Bearer ${token}`,
16824
- "Content-Type": "application/json"
16825
- };
16826
- const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
16827
- if (bypassSecret) {
16828
- headers["x-vercel-protection-bypass"] = bypassSecret;
16829
- }
16830
- return headersWithCliClientHeaders(headers);
16831
- }
16832
- function isRecord(value) {
16833
- return typeof value === "object" && value !== null && !Array.isArray(value);
16834
- }
16835
- function isBuiltInGenerationAcceptedResponse(value) {
16836
- if (!isRecord(value)) {
16837
- return false;
16838
- }
16839
- return typeof value.generationId === "string" && value.status === "queued" && (value.type === "image" || value.type === "video" || value.type === "presentation" || value.type === "website") && isRecord(value.realtime);
16840
- }
16841
- function createBuiltInGenerationRealtime(accepted) {
16842
- let nextAuthRequest = accepted.realtime.tokenRequest;
16843
- const authCallback = (_params, callback) => {
16844
- const current = nextAuthRequest;
16845
- nextAuthRequest = accepted.realtime.tokenRequest;
16846
- callback(null, current);
16847
- };
16848
- return new Realtime({
16849
- authCallback,
16850
- autoConnect: true,
16851
- disconnectedRetryTimeout: 5e3,
16852
- suspendedRetryTimeout: 15e3
16853
- });
16854
- }
16855
- function waitForRealtimeConnected(ably, timeoutMs = ABLY_CONNECT_TIMEOUT_MS) {
16856
- if (ably.connection.state === "connected") {
16857
- return Promise.resolve();
16858
- }
16859
- if (ably.connection.state === "failed") {
16860
- return Promise.reject(new Error("Ably connection failed"));
16861
- }
16862
- return new Promise((resolve, reject) => {
16863
- const timer = setTimeout(() => {
16864
- reject(new Error("Timed out connecting to Ably"));
16865
- }, timeoutMs);
16866
- ably.connection.once("connected", () => {
16867
- clearTimeout(timer);
16868
- resolve();
16869
- });
16870
- ably.connection.once("failed", (stateChange) => {
16871
- clearTimeout(timer);
16872
- reject(
16873
- new Error(
16874
- `Ably connection failed: ${stateChange?.reason?.message ?? "unknown"}`
16875
- )
16876
- );
16877
- });
16878
- });
16879
- }
16880
- async function createBuiltInGenerationNotifier(accepted) {
16881
- const ably = createBuiltInGenerationRealtime(accepted);
16882
- try {
16883
- await waitForRealtimeConnected(ably);
16884
- const channel = ably.channels.get(accepted.realtime.channelName);
16885
- let pendingEvent = false;
16886
- let closed = false;
16887
- let wake = null;
16888
- const wakeWaiter = () => {
16889
- const current = wake;
16890
- wake = null;
16891
- current?.();
16892
- };
16893
- const onMessage = (_message) => {
16894
- if (wake) {
16895
- wakeWaiter();
16896
- return;
16897
- }
16898
- pendingEvent = true;
16899
- };
16900
- await channel.subscribe(accepted.realtime.eventName, onMessage);
16901
- return {
16902
- wait(timeoutMs) {
16903
- if (pendingEvent || closed || timeoutMs <= 0) {
16904
- pendingEvent = false;
16905
- return Promise.resolve();
16906
- }
16907
- return new Promise((resolve) => {
16908
- function done() {
16909
- clearTimeout(timer);
16910
- if (wake === done) {
16911
- wake = null;
16912
- }
16913
- resolve();
16914
- }
16915
- const timer = setTimeout(done, timeoutMs);
16916
- wake = done;
16917
- });
16918
- },
16919
- close() {
16920
- if (closed) {
16921
- return;
16922
- }
16923
- closed = true;
16924
- channel.unsubscribe(accepted.realtime.eventName, onMessage);
16925
- wakeWaiter();
16926
- ably.close();
16927
- }
16928
- };
16929
- } catch {
16930
- ably.close();
16931
- return null;
16932
- }
16933
- }
16934
- async function getBuiltInGenerationStatus(baseUrl, token, generationId) {
16935
- const response = await fetch(
16936
- new URL(`/api/zero/built-in-generations/${generationId}`, baseUrl),
16937
- { headers: authenticatedJsonHeaders(token) }
16938
- );
16939
- if (!response.ok) {
16940
- const { message, code } = await parseErrorBody(
16941
- response,
16942
- "Failed to get generation status"
16943
- );
16944
- throw new ApiRequestError(message, code, response.status);
16945
- }
16946
- return await response.json();
16947
- }
16948
- function readBuiltInGenerationResult(status, fallback) {
16949
- if (status.status === "completed") {
16950
- if (!status.result) {
16951
- throw new ApiRequestError(
16952
- `${fallback} returned no result`,
16953
- "EMPTY_RESULT",
16954
- 502
16955
- );
16956
- }
16957
- return status.result;
16958
- }
16959
- if (status.status === "failed") {
16960
- const code = status.error?.code ?? "GENERATION_FAILED";
16961
- throw new ApiRequestError(
16962
- status.error?.message ?? `${fallback} failed`,
16963
- code,
16964
- statusForBuiltInGenerationError(code)
16965
- );
16966
- }
16967
- return void 0;
16968
- }
16969
- function statusForBuiltInGenerationError(code) {
16970
- if (code === "BAD_REQUEST") {
16971
- return 400;
16972
- }
16973
- if (code === "INSUFFICIENT_CREDITS") {
16974
- return 402;
16975
- }
16976
- if (code === "NOT_CONFIGURED") {
16977
- return 503;
16978
- }
16979
- if (code === "GENERATION_TIMEOUT") {
16980
- return 504;
16981
- }
16982
- if (code.startsWith("BYTEPLUS_INVALID_PARAMETER") || code.startsWith("BYTEPLUS_INPUT_")) {
16983
- return 400;
16984
- }
16985
- if (code.startsWith("BYTEPLUS_")) {
16986
- return 502;
16987
- }
16988
- if (code.startsWith("NO_") || code.endsWith("_FAILED")) {
16989
- return 502;
16990
- }
16991
- return 500;
16992
- }
16993
- async function waitForBuiltInGenerationResult(args) {
16994
- let notifier = null;
16995
- let notifierCreated = false;
16996
- const startedAt = Date.now();
16997
- const timeoutMs = BUILT_IN_GENERATION_WAIT_TIMEOUT_MS_BY_TYPE[args.accepted.type];
16998
- try {
16999
- while (Date.now() - startedAt < timeoutMs) {
17000
- const status = await getBuiltInGenerationStatus(
17001
- args.baseUrl,
17002
- args.token,
17003
- args.accepted.generationId
17004
- );
17005
- const result = readBuiltInGenerationResult(status, args.fallback);
17006
- if (result) {
17007
- return result;
17008
- }
17009
- const elapsed = Date.now() - startedAt;
17010
- const remaining = timeoutMs - elapsed;
17011
- const waitMs = Math.min(BUILT_IN_GENERATION_POLL_INTERVAL_MS, remaining);
17012
- if (!notifierCreated) {
17013
- notifier = await createBuiltInGenerationNotifier(args.accepted);
17014
- notifierCreated = true;
17015
- }
17016
- if (notifier) {
17017
- await notifier.wait(waitMs);
17018
- } else {
17019
- await delay(waitMs);
17020
- }
17021
- }
17022
- } finally {
17023
- notifier?.close();
17024
- }
17025
- throw new ApiRequestError(
17026
- `${args.fallback} timed out (generationId: ${args.accepted.generationId})`,
17027
- "GENERATION_TIMEOUT",
17028
- 504
17029
- );
17030
- }
17031
- async function readBuiltInGenerationResponse(args) {
17032
- const body = await args.response.json();
17033
- if (isBuiltInGenerationAcceptedResponse(body)) {
17034
- return waitForBuiltInGenerationResult({
17035
- accepted: body,
17036
- baseUrl: args.baseUrl,
17037
- token: args.token,
17038
- fallback: args.fallback
17039
- });
17040
- }
17041
- if (args.response.status === 202) {
17042
- throw new ApiRequestError(
17043
- `${args.fallback} returned an invalid generation response`,
17044
- "INVALID_GENERATION_RESPONSE",
17045
- 502
17046
- );
17047
- }
17048
- return body;
17049
- }
17050
- async function uploadWebFile(localPath, options) {
17051
- const stats = statSync(localPath);
17052
- if (!stats.isFile()) {
17053
- throw new ApiRequestError(
17054
- `Not a regular file: ${localPath}`,
17055
- "BAD_REQUEST",
17056
- 400
17057
- );
17058
- }
17059
- const baseUrl = await getBaseUrl();
17060
- const token = await getActiveToken();
17061
- if (!token) {
17062
- throw new ApiRequestError("Not authenticated", "UNAUTHORIZED", 401);
17063
- }
17064
- const filename = basename(localPath);
17065
- const contentType = options?.contentType ?? inferContentType(localPath);
17066
- const prepareHeaders = {
17067
- Authorization: `Bearer ${token}`,
17068
- "Content-Type": "application/json"
17069
- };
17070
- const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
17071
- if (bypassSecret) {
17072
- prepareHeaders["x-vercel-protection-bypass"] = bypassSecret;
17073
- }
17074
- const prepareUrl = new URL("/api/zero/uploads/prepare", baseUrl);
17075
- const prepareRes = await fetch(prepareUrl, {
17076
- method: "POST",
17077
- headers: headersWithCliClientHeaders(prepareHeaders),
17078
- body: JSON.stringify({ filename, contentType, size: stats.size })
17079
- });
17080
- if (!prepareRes.ok) {
17081
- const { message, code } = await parseErrorBody(
17082
- prepareRes,
17083
- "Failed to prepare upload"
17084
- );
17085
- throw new ApiRequestError(message, code, prepareRes.status);
17086
- }
17087
- const prepared = await prepareRes.json();
17088
- const bytes = readFileSync(localPath);
17089
- const putRes = await fetch(prepared.uploadUrl, {
17090
- method: "PUT",
17091
- headers: { "Content-Type": prepared.contentType },
17092
- body: new Uint8Array(bytes)
17093
- });
17094
- if (!putRes.ok) {
17095
- throw new ApiRequestError(
17096
- `Failed to upload file to storage (HTTP ${putRes.status})`,
17097
- "UPLOAD_FAILED",
17098
- putRes.status
17099
- );
17100
- }
17101
- const completeUrl = new URL("/api/zero/uploads/complete", baseUrl);
17102
- const completeRes = await fetch(completeUrl, {
17103
- method: "POST",
17104
- headers: headersWithCliClientHeaders(prepareHeaders),
17105
- body: JSON.stringify({
17106
- id: prepared.id,
17107
- contentType: prepared.contentType
17108
- })
17109
- });
17110
- if (!completeRes.ok) {
17111
- const { message, code } = await parseErrorBody(
17112
- completeRes,
17113
- "Failed to complete upload"
17114
- );
17115
- throw new ApiRequestError(message, code, completeRes.status);
17116
- }
17117
- const completed = await completeRes.json();
17118
- return {
17119
- id: completed.id,
17120
- filename: completed.filename,
17121
- contentType: completed.contentType,
17122
- size: completed.size,
17123
- url: completed.url
17124
- };
17125
- }
17126
- async function generateWebVoice(options) {
17127
- const baseUrl = await getBaseUrl();
17128
- const token = await getActiveToken();
17129
- if (!token) {
17130
- throw new ApiRequestError("Not authenticated", "UNAUTHORIZED", 401);
17131
- }
17132
- const headers = {
17133
- Authorization: `Bearer ${token}`,
17134
- "Content-Type": "application/json"
17135
- };
17136
- const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
17137
- if (bypassSecret) {
17138
- headers["x-vercel-protection-bypass"] = bypassSecret;
17139
- }
17140
- const response = await fetch(new URL("/api/zero/voice-io/speech", baseUrl), {
17141
- method: "POST",
17142
- headers: headersWithCliClientHeaders(headers),
17143
- body: JSON.stringify({
17144
- text: options.text,
17145
- ...options.voice ? { voice: options.voice } : {},
17146
- ...options.instructions ? { instructions: options.instructions } : {}
17147
- })
17148
- });
17149
- if (!response.ok) {
17150
- const { message, code } = await parseErrorBody(
17151
- response,
17152
- "Failed to generate voice"
17153
- );
17154
- throw new ApiRequestError(message, code, response.status);
17155
- }
17156
- return await response.json();
17157
- }
17158
- async function generateWebImage(options) {
17159
- const baseUrl = await getBaseUrl();
17160
- const token = await getActiveToken();
17161
- if (!token) {
17162
- throw new ApiRequestError("Not authenticated", "UNAUTHORIZED", 401);
17163
- }
17164
- const headers = {
17165
- Authorization: `Bearer ${token}`,
17166
- "Content-Type": "application/json"
17167
- };
17168
- const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
17169
- if (bypassSecret) {
17170
- headers["x-vercel-protection-bypass"] = bypassSecret;
17171
- }
17172
- const response = await fetch(
17173
- new URL("/api/zero/image-io/generate", baseUrl),
17174
- {
17175
- method: "POST",
17176
- headers: headersWithCliClientHeaders(headers),
17177
- body: JSON.stringify({
17178
- prompt: options.prompt,
17179
- ...options.model ? { model: options.model } : {},
17180
- ...options.size ? { size: options.size } : {},
17181
- ...options.quality ? { quality: options.quality } : {},
17182
- ...options.background ? { background: options.background } : {},
17183
- ...options.outputFormat ? { outputFormat: options.outputFormat } : {},
17184
- ...options.outputCompression !== void 0 ? { outputCompression: options.outputCompression } : {},
17185
- ...options.moderation ? { moderation: options.moderation } : {},
17186
- ...options.seed !== void 0 ? { seed: options.seed } : {},
17187
- ...options.safetyTolerance ? { safetyTolerance: options.safetyTolerance } : {},
17188
- ...options.enhancePrompt !== void 0 ? { enhancePrompt: options.enhancePrompt } : {},
17189
- ...options.imageUrls && options.imageUrls.length > 0 ? { imageUrls: options.imageUrls } : {},
17190
- ...options.maskImageUrl ? { maskImageUrl: options.maskImageUrl } : {},
17191
- ...options.inputFidelity ? { inputFidelity: options.inputFidelity } : {},
17192
- ...options.imagePromptStrength !== void 0 ? { imagePromptStrength: options.imagePromptStrength } : {}
17193
- })
17194
- }
17195
- );
17196
- if (!response.ok) {
17197
- const { message, code } = await parseErrorBody(
17198
- response,
17199
- "Failed to generate image"
17200
- );
17201
- throw new ApiRequestError(message, code, response.status);
17202
- }
17203
- return readBuiltInGenerationResponse({
17204
- response,
17205
- baseUrl,
17206
- token,
17207
- fallback: "Failed to generate image"
17208
- });
17209
- }
17210
- async function generateWebVideo(options) {
17211
- const baseUrl = await getBaseUrl();
17212
- const token = await getActiveToken();
17213
- if (!token) {
17214
- throw new ApiRequestError("Not authenticated", "UNAUTHORIZED", 401);
17215
- }
17216
- const headers = {
17217
- Authorization: `Bearer ${token}`,
17218
- "Content-Type": "application/json"
17219
- };
17220
- const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
17221
- if (bypassSecret) {
17222
- headers["x-vercel-protection-bypass"] = bypassSecret;
17223
- }
17224
- const response = await fetch(
17225
- new URL("/api/zero/video-io/generate", baseUrl),
17226
- {
17227
- method: "POST",
17228
- headers: headersWithCliClientHeaders(headers),
17229
- body: JSON.stringify(generateWebVideoPayload(options))
17230
- }
17231
- );
17232
- if (!response.ok) {
17233
- const { message, code } = await parseErrorBody(
17234
- response,
17235
- "Failed to generate video"
17236
- );
17237
- throw new ApiRequestError(message, code, response.status);
17238
- }
17239
- return readBuiltInGenerationResponse({
17240
- response,
17241
- baseUrl,
17242
- token,
17243
- fallback: "Failed to generate video"
17244
- });
17245
- }
17246
- async function transcribeAudio(audioPath, options = {}) {
17247
- const baseUrl = await getBaseUrl();
17248
- const token = await getActiveToken();
17249
- if (!token) {
17250
- throw new ApiRequestError("Not authenticated", "UNAUTHORIZED", 401);
17251
- }
17252
- const headers = {
17253
- Authorization: `Bearer ${token}`
17254
- };
17255
- const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
17256
- if (bypassSecret) {
17257
- headers["x-vercel-protection-bypass"] = bypassSecret;
17258
- }
17259
- const url2 = new URL("/api/zero/voice-io/stt", baseUrl);
17260
- if (options.verbose) {
17261
- url2.searchParams.set("verbose", "true");
17262
- }
17263
- const audioData = readFileSync(audioPath);
17264
- const filename = basename(audioPath);
17265
- const ext = extname(filename).toLowerCase();
17266
- const mimeMap = {
17267
- ".mp3": "audio/mpeg",
17268
- ".mp4": "audio/mp4",
17269
- ".m4a": "audio/m4a",
17270
- ".wav": "audio/wav",
17271
- ".webm": "audio/webm"
17272
- };
17273
- const mimeType = mimeMap[ext] ?? "audio/mpeg";
17274
- const formData = new FormData();
17275
- formData.append("file", new Blob([audioData], { type: mimeType }), filename);
17276
- const response = await fetch(url2, {
17277
- method: "POST",
17278
- headers: headersWithCliClientHeaders(headers),
17279
- body: formData
17280
- });
17281
- if (!response.ok) {
17282
- const { message, code } = await parseErrorBody(
17283
- response,
17284
- "Transcription failed"
17285
- );
17286
- throw new ApiRequestError(message, code, response.status);
17287
- }
17288
- return await response.json();
17289
- }
17290
-
17291
16635
  export {
17292
16636
  source_default,
17293
16637
  loadConfig,
@@ -17324,12 +16668,6 @@ export {
17324
16668
  getBaseUrl,
17325
16669
  getClientConfig,
17326
16670
  handleError,
17327
- withErrorHandler,
17328
- downloadWebFile,
17329
- uploadWebFile,
17330
- generateWebVoice,
17331
- generateWebImage,
17332
- generateWebVideo,
17333
- transcribeAudio
16671
+ withErrorHandler
17334
16672
  };
17335
- //# sourceMappingURL=chunk-MA37R4QS.js.map
16673
+ //# sourceMappingURL=chunk-WEEPG6HO.js.map