@vm0/cli 9.125.7 → 9.126.0

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.
@@ -73642,7 +73642,7 @@ if (DSN) {
73642
73642
  init2({
73643
73643
  dsn: DSN,
73644
73644
  environment: process.env.SENTRY_ENVIRONMENT ?? "production",
73645
- release: "9.125.7",
73645
+ release: "9.126.0",
73646
73646
  sendDefaultPii: false,
73647
73647
  tracesSampleRate: 0,
73648
73648
  shutdownTimeout: 500,
@@ -73661,7 +73661,7 @@ if (DSN) {
73661
73661
  }
73662
73662
  });
73663
73663
  setContext("cli", {
73664
- version: "9.125.7",
73664
+ version: "9.126.0",
73665
73665
  command: process.argv.slice(2).join(" ")
73666
73666
  });
73667
73667
  setContext("runtime", {
@@ -115929,29 +115929,35 @@ var zeroPhoneSetupContract = c55.router({
115929
115929
  // ../../packages/core/src/contracts/zero-uploads.ts
115930
115930
  init_esm_shims();
115931
115931
  var c56 = initContract();
115932
- var uploadResponseSchema = external_exports.object({
115932
+ var prepareRequestSchema = external_exports.object({
115933
+ filename: external_exports.string().min(1).max(255),
115934
+ contentType: external_exports.string().min(1).max(200),
115935
+ size: external_exports.number().int().nonnegative()
115936
+ });
115937
+ var prepareResponseSchema = external_exports.object({
115933
115938
  id: external_exports.string(),
115934
115939
  filename: external_exports.string(),
115935
115940
  contentType: external_exports.string(),
115936
115941
  size: external_exports.number(),
115942
+ /** Presigned PUT URL — browser uploads the file body here directly. */
115943
+ uploadUrl: external_exports.string().url(),
115944
+ /** Presigned GET URL returned to the app after upload succeeds. */
115937
115945
  url: external_exports.string().url()
115938
115946
  });
115939
115947
  var zeroUploadsContract = c56.router({
115940
- upload: {
115948
+ prepare: {
115941
115949
  method: "POST",
115942
- path: "/api/zero/uploads",
115950
+ path: "/api/zero/uploads/prepare",
115943
115951
  headers: authHeadersSchema,
115944
- contentType: "multipart/form-data",
115945
- body: c56.type(),
115952
+ body: prepareRequestSchema,
115946
115953
  responses: {
115947
- 200: uploadResponseSchema,
115954
+ 200: prepareResponseSchema,
115948
115955
  400: apiErrorSchema,
115949
115956
  401: apiErrorSchema,
115950
115957
  403: apiErrorSchema,
115951
- 413: apiErrorSchema,
115952
115958
  500: apiErrorSchema
115953
115959
  },
115954
- summary: "Upload a file"
115960
+ summary: "Prepare a direct-to-R2 upload"
115955
115961
  }
115956
115962
  });
115957
115963
 
@@ -116388,12 +116394,6 @@ var FEATURE_SWITCHES = {
116388
116394
  enabled: true,
116389
116395
  enabledOrgIdHashes: STAFF_ORG_ID_HASHES
116390
116396
  },
116391
- ["redeemCode" /* RedeemCode */]: {
116392
- maintainer: "yuma@vm0.ai",
116393
- description: "Show redeem-code gift icon and dialog in the agent chat page header",
116394
- enabled: false,
116395
- enabledOrgIdHashes: STAFF_ORG_ID_HASHES
116396
- },
116397
116397
  ["nanoBananaConnector" /* NanoBananaConnector */]: {
116398
116398
  maintainer: "liangyou@vm0.ai",
116399
116399
  description: "Show the Nano Banana (Google Gemini image generation) platform-managed connector",
@@ -117787,6 +117787,17 @@ async function downloadWebFile(fileId, outPath) {
117787
117787
  const size = contentLengthHeader ? Number(contentLengthHeader) : 0;
117788
117788
  return { path: outPath, mimetype, size };
117789
117789
  }
117790
+ async function parseErrorBody(response, fallback) {
117791
+ let message = `${fallback} (HTTP ${response.status})`;
117792
+ let code = "UNKNOWN";
117793
+ try {
117794
+ const body = await response.json();
117795
+ if (body.error?.message) message = body.error.message;
117796
+ if (body.error?.code) code = body.error.code;
117797
+ } catch {
117798
+ }
117799
+ return { message, code };
117800
+ }
117790
117801
  async function uploadWebFile(localPath, options) {
117791
117802
  const stats = statSync(localPath);
117792
117803
  if (!stats.isFile()) {
@@ -117803,35 +117814,48 @@ async function uploadWebFile(localPath, options) {
117803
117814
  }
117804
117815
  const filename = basename2(localPath);
117805
117816
  const contentType = options?.contentType ?? inferContentType(localPath);
117806
- const bytes = readFileSync3(localPath);
117807
- const blob = new Blob([new Uint8Array(bytes)], { type: contentType });
117808
- const formData = new FormData();
117809
- formData.append("file", blob, filename);
117810
- const url2 = new URL("/api/zero/uploads", baseUrl);
117811
- const headers = {
117812
- Authorization: `Bearer ${token}`
117817
+ const prepareHeaders = {
117818
+ Authorization: `Bearer ${token}`,
117819
+ "Content-Type": "application/json"
117813
117820
  };
117814
117821
  const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
117815
117822
  if (bypassSecret) {
117816
- headers["x-vercel-protection-bypass"] = bypassSecret;
117823
+ prepareHeaders["x-vercel-protection-bypass"] = bypassSecret;
117817
117824
  }
117818
- const response = await fetch(url2, {
117825
+ const prepareUrl = new URL("/api/zero/uploads/prepare", baseUrl);
117826
+ const prepareRes = await fetch(prepareUrl, {
117819
117827
  method: "POST",
117820
- headers,
117821
- body: formData
117828
+ headers: prepareHeaders,
117829
+ body: JSON.stringify({ filename, contentType, size: stats.size })
117822
117830
  });
117823
- if (!response.ok) {
117824
- let message = `Failed to upload file (HTTP ${response.status})`;
117825
- let code = "UNKNOWN";
117826
- try {
117827
- const body = await response.json();
117828
- if (body.error?.message) message = body.error.message;
117829
- if (body.error?.code) code = body.error.code;
117830
- } catch {
117831
- }
117832
- throw new ApiRequestError(message, code, response.status);
117831
+ if (!prepareRes.ok) {
117832
+ const { message, code } = await parseErrorBody(
117833
+ prepareRes,
117834
+ "Failed to prepare upload"
117835
+ );
117836
+ throw new ApiRequestError(message, code, prepareRes.status);
117833
117837
  }
117834
- return await response.json();
117838
+ const prepared = await prepareRes.json();
117839
+ const bytes = readFileSync3(localPath);
117840
+ const putRes = await fetch(prepared.uploadUrl, {
117841
+ method: "PUT",
117842
+ headers: { "Content-Type": contentType },
117843
+ body: new Uint8Array(bytes)
117844
+ });
117845
+ if (!putRes.ok) {
117846
+ throw new ApiRequestError(
117847
+ `Failed to upload file to storage (HTTP ${putRes.status})`,
117848
+ "UPLOAD_FAILED",
117849
+ putRes.status
117850
+ );
117851
+ }
117852
+ return {
117853
+ id: prepared.id,
117854
+ filename: prepared.filename,
117855
+ contentType: prepared.contentType,
117856
+ size: prepared.size,
117857
+ url: prepared.url
117858
+ };
117835
117859
  }
117836
117860
 
117837
117861
  // src/lib/utils/prompt-utils.ts
@@ -119006,4 +119030,4 @@ undici/lib/web/fetch/body.js:
119006
119030
  undici/lib/web/websocket/frame.js:
119007
119031
  (*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> *)
119008
119032
  */
119009
- //# sourceMappingURL=chunk-JJFBKM2R.js.map
119033
+ //# sourceMappingURL=chunk-XRL42LXP.js.map