@vite-hub/workspace 0.1.0 → 0.3.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.
Files changed (134) hide show
  1. package/README.md +164 -107
  2. package/dist/abort-BCwpdrN0.js +32 -0
  3. package/dist/blob-database.d.ts +70 -117
  4. package/dist/blob-database.js +48 -41
  5. package/dist/checkout.d.ts +128 -0
  6. package/dist/checkout.js +849 -0
  7. package/dist/cloudflare.d.ts +2 -2
  8. package/dist/cloudflare.js +1 -1
  9. package/dist/config-B-863EgC.js +15 -0
  10. package/dist/{config-B7dmzDX3.js → config-BAgL2dtB.js} +48 -84
  11. package/dist/{config-DLKdaFWN.d.ts → config-BQKcPawI.d.ts} +1 -1
  12. package/dist/discard-CNNtCozM.js +8 -0
  13. package/dist/durability.d.ts +22 -0
  14. package/dist/durability.js +70 -0
  15. package/dist/error-diagnostics-CtKjGtGb.js +188 -0
  16. package/dist/error-diagnostics-DSkCJC_L.js +266 -0
  17. package/dist/file-2pFYNtsU.js +22 -0
  18. package/dist/{files-C7Px8uaC.js → files-BOo4SbwE.js} +2 -2
  19. package/dist/files.d.ts +38 -0
  20. package/dist/files.js +6 -0
  21. package/dist/{github-CPxHtFB7.js → github-CrYp4v8k.js} +32 -5
  22. package/dist/{glob--XcLlcml.js → glob-B8YGvTrZ.js} +4 -5
  23. package/dist/{glob--kNYDbfU.js → glob-Cjxms1t7.js} +1 -1
  24. package/dist/{host-CFnrTXTK.js → host-BFBpXn0N.js} +58 -47
  25. package/dist/{hosted-acMA5XyL.js → hosted-KcUR_jPv.js} +216 -93
  26. package/dist/hosted-vercel-blob-B3-wRdUm.js +410 -0
  27. package/dist/hosted-vercel-blob.d.ts +2 -2
  28. package/dist/hosted-vercel-blob.js +1 -1
  29. package/dist/hosted.d.ts +5 -3
  30. package/dist/hosted.js +2 -2
  31. package/dist/index.d.ts +9 -51
  32. package/dist/index.js +21 -91
  33. package/dist/{lifecycle-BwZ7c9hb.js → lifecycle-B-enk_4A.js} +8 -8
  34. package/dist/lineage.d.ts +26 -0
  35. package/dist/lineage.js +76 -0
  36. package/dist/loader.d.ts +1 -1
  37. package/dist/loader.js +2 -2
  38. package/dist/{mcp-resources-BREFCmtn.js → mcp-resources-DF0F5rcL.js} +2 -2
  39. package/dist/{memory-BbwOqDXl.js → memory-BOexthyW.js} +3 -4
  40. package/dist/{metadata-target-DZEZQGHA.js → metadata-target-CWz6KHKq.js} +17 -16
  41. package/dist/object-Da1zyPCR.js +11 -0
  42. package/dist/operation-definition-8gOe-ubD.d.ts +234 -0
  43. package/dist/operations-C6FpR8Rr.js +389 -0
  44. package/dist/operations-CE2drFih.js +1234 -0
  45. package/dist/operations.d.ts +41 -4
  46. package/dist/operations.js +3 -2
  47. package/dist/{path-CNAwN7pw.js → path--wrT_Azm.js} +2 -3
  48. package/dist/path-AxMho1wo.d.ts +7 -0
  49. package/dist/{plugins-DqQ8b4T5.d.ts → plugins-C8C0auoW.d.ts} +1 -1
  50. package/dist/{provider-kXjfli9u.js → provider-9s4Ufkm5.js} +104 -82
  51. package/dist/providers/github/store.d.ts +1 -1
  52. package/dist/providers/github/store.js +1 -1
  53. package/dist/registry-B3BBm4Ts.d.ts +19 -0
  54. package/dist/{registry-Bp-8UUfG.js → registry-CNphafBx.js} +55 -20
  55. package/dist/registry-CYNN623b.d.ts +9 -0
  56. package/dist/request-scope-Dw5n8bMC.js +83 -0
  57. package/dist/results-DgkZUmTL.js +8 -0
  58. package/dist/{rolldown-runtime-B4iAMlE-.js → rolldown-runtime-rQ84J-ij.js} +2 -3
  59. package/dist/runtime/assets.d.ts +1 -1
  60. package/dist/runtime/assets.js +3 -3
  61. package/dist/runtime/empty-assets-registry.d.ts +1 -1
  62. package/dist/runtime/empty-registry.d.ts +2 -1
  63. package/dist/runtime/registry.d.ts +2 -0
  64. package/dist/runtime/registry.js +23 -0
  65. package/dist/runtime/request.d.ts +4 -0
  66. package/dist/runtime/request.js +8 -0
  67. package/dist/runtime/state.d.ts +5 -4
  68. package/dist/runtime/state.js +8 -18
  69. package/dist/runtime/workspace.d.ts +1 -1
  70. package/dist/runtime/workspace.js +1 -1
  71. package/dist/runtime.d.ts +9 -8
  72. package/dist/runtime.js +23 -26
  73. package/dist/{search-CrTmXj5h.js → search-C_RfoM2j.js} +2 -2
  74. package/dist/{server-BNQ-Nbjj.js → server-8tGltlGz.js} +53 -40
  75. package/dist/server.d.ts +17 -8
  76. package/dist/server.js +1 -1
  77. package/dist/shared-B3_EUk89.js +848 -0
  78. package/dist/source-metadata.d.ts +6 -2
  79. package/dist/source-metadata.js +8 -8
  80. package/dist/state-BISnUf1s.d.ts +35 -0
  81. package/dist/{ai-BZyLwULx.js → state-DbrW-njQ.js} +96 -54
  82. package/dist/{store-CXgmu-uw.js → store-ybhyD38Z.js} +250 -106
  83. package/dist/{sync-CN6ec-5M.js → sync-CCD_VYC8.js} +4 -4
  84. package/dist/target-jWhTdIuF.js +89 -0
  85. package/dist/test.d.ts +1 -1
  86. package/dist/test.js +1 -1
  87. package/dist/{types-DeK9GIxy.d.ts → types-BbtwmBZ5.d.ts} +68 -14
  88. package/dist/use-C6lV3-wC.d.ts +321 -0
  89. package/dist/{use-BQj7nSz6.js → use-CSpT5W87.js} +75 -82
  90. package/dist/{utils-Blrh4N2n.js → utils-CgMZCHsX.js} +112 -41
  91. package/dist/vite.d.ts +585 -2
  92. package/dist/vite.js +21368 -1
  93. package/dist/{workspace-BWJQBK1u.d.ts → workspace-CYB2xZ1T.d.ts} +1 -1
  94. package/dist/{workspace-6pxkOuxr.js → workspace-sPWn2Jxj.js} +125 -40
  95. package/package.json +46 -55
  96. package/dist/ai-BW2ZhizI.d.ts +0 -177
  97. package/dist/ai.d.ts +0 -3
  98. package/dist/ai.js +0 -2
  99. package/dist/association-Cm0dUTDU-CDDhJnIh-Cv3bWnVb.js +0 -19
  100. package/dist/error-diagnostics-A_8Kp-48.js +0 -116
  101. package/dist/error-diagnostics-DY5GP47p.js +0 -96
  102. package/dist/events-7EBoeIPd-A2RUkJi5-BxrICQ17.js +0 -354
  103. package/dist/events-CRaLy7U3-3PNNp5WZ-Gv9nd0cH.js +0 -214
  104. package/dist/events-CeChclTf-CX-gD8oy-4aL2j6V-.js +0 -527
  105. package/dist/feed-DsC7Vws1-M_de2nSK-tKc0Pwo8.js +0 -248
  106. package/dist/feed-Dyf730Ys-D0HgBba6-BUnCa5gS.js +0 -179
  107. package/dist/file-C0_aPWSS.js +0 -26
  108. package/dist/file-metadata-CxDy-E2H.js +0 -58
  109. package/dist/forgejo-BN8ItCfl-Bbn4vhDd.js +0 -2278
  110. package/dist/github-DtncTfmv-Du2S8lGF.js +0 -4159
  111. package/dist/gitlab-BoDm8-BC-xzZsW9eW.js +0 -2530
  112. package/dist/graphql-DG5aJBT3-DceyFYdM-C4saqX37.js +0 -489
  113. package/dist/hosted-vercel-blob-DKntsHaf.js +0 -12603
  114. package/dist/inspect-BoObD2cJ.js +0 -167
  115. package/dist/mountx.d.ts +0 -8
  116. package/dist/mountx.js +0 -145
  117. package/dist/nitro.d.ts +0 -2
  118. package/dist/nitro.js +0 -2
  119. package/dist/nuxt.d.ts +0 -27
  120. package/dist/nuxt.js +0 -38
  121. package/dist/operations-BcpWr41m.js +0 -159
  122. package/dist/operations-CGqY1XeG.js +0 -965
  123. package/dist/operations-DnOwKsJT.d.ts +0 -136
  124. package/dist/registry-Cg1TJVVZ.d.ts +0 -10
  125. package/dist/request-execution-Dk9rY-Yh.js +0 -84
  126. package/dist/shared-DalXdP0i.js +0 -2158
  127. package/dist/state-B8zbLi5t.d.ts +0 -26
  128. package/dist/target-D4Bqb1eH.js +0 -11
  129. package/dist/templates-Bn8a-pd2-D9DhJEVD-CBfXNRzz.js +0 -125
  130. package/dist/token-CO62GglH.js +0 -61
  131. package/dist/use-DhwhbAVV.d.ts +0 -108
  132. package/dist/vite-BEvgU2GY.js +0 -20909
  133. package/dist/vite-CcZmMQ7S.d.ts +0 -476
  134. package/dist/webhooks-DgHwxxYz-D1V2LOr1-azofFOiP.js +0 -1565
@@ -1,6 +1,12 @@
1
- import { At as WorkspaceRevision } from "./types-DeK9GIxy.js";
2
- import { t as AnyOperation } from "./operations-DnOwKsJT.js";
1
+ import { jt as WorkspaceRevision } from "./types-BbtwmBZ5.js";
2
+ import { WorkspaceStaleFile } from "./lineage.js";
3
+ import { t as AnyOperation } from "./operation-definition-8gOe-ubD.js";
3
4
  //#region src/results.d.ts
5
+ /**
6
+ * The largest `workspace.commit` request body: 4 MiB of JSON, with base64 for binary files. Vercel Functions accept
7
+ * request bodies up to 4.5 MB and Cloudflare Workers up to 100 MB, so one push works on every host.
8
+ */
9
+ export declare const workspaceCommitRequestBytes: number;
4
10
  /** A retained revision as `workspace.history`, `workspace.refs`, and `workspace.show` report it. */
5
11
  interface WorkspaceHistoryRevision extends WorkspaceRevision {
6
12
  /** The `author` string from the revision metadata, when it has one. */
@@ -45,9 +51,40 @@ interface WorkspaceHistoryDetails {
45
51
  /** The file at `path`. */
46
52
  file?: WorkspaceHistoryContent;
47
53
  }
54
+ /** A file that differs between two revisions of a ref, as `workspace.changes` reports it. */
55
+ interface WorkspaceChangedFile {
56
+ path: string;
57
+ /** True when the head no longer has the file. */
58
+ deleted?: true;
59
+ /** The file at the head. Missing when it was deleted, or when the call asked for no content. */
60
+ head?: Pick<WorkspaceHistoryContent, "content" | "encoding">;
61
+ /** The file at the base revision, for a three-way merge. Missing when the file is new. */
62
+ base?: Pick<WorkspaceHistoryContent, "content" | "encoding">;
63
+ }
64
+ interface WorkspaceChanges {
65
+ workspace: string;
66
+ ref: string;
67
+ /** The head of the ref, or null when the ref has no revision yet. */
68
+ head: WorkspaceHistoryRevision | null;
69
+ /** Files that changed since the base revision, sorted by path. Every file of the head without a base. */
70
+ files: WorkspaceChangedFile[];
71
+ }
72
+ interface WorkspaceStaleList {
73
+ workspace: string;
74
+ ref: string;
75
+ /** The head that the list reads, or null when the ref has no revision yet. */
76
+ head: string | null;
77
+ stale: WorkspaceStaleFile[];
78
+ }
79
+ interface WorkspaceCommitResult {
80
+ workspace: string;
81
+ revision: WorkspaceHistoryRevision;
82
+ /** Committed bytes of puts whose content changed during write validation or hooks, keyed by request path. */
83
+ normalized?: Record<string, Pick<WorkspaceHistoryContent, "content" | "encoding">>;
84
+ }
48
85
  //#endregion
49
86
  //#region src/operations.d.ts
50
- /** The `workspace.*` operations: history, refs, and show. The Console, `vitehub workspace`, and agents run them. */
87
+ /** The `workspace.*` operations: history, refs, show, changes, commit, and stale. The Console, `vitehub workspace`, and agents run them. */
51
88
  export declare const workspaceOperations: readonly AnyOperation[];
52
89
  //#endregion
53
- export type { WorkspaceHistoryContent, WorkspaceHistoryDetails, WorkspaceHistoryFile, WorkspaceHistoryList, WorkspaceHistoryRefs, WorkspaceHistoryRevision };
90
+ export type { WorkspaceChangedFile, WorkspaceChanges, WorkspaceCommitResult, WorkspaceHistoryContent, WorkspaceHistoryDetails, WorkspaceHistoryFile, WorkspaceHistoryList, WorkspaceHistoryRefs, WorkspaceHistoryRevision, WorkspaceStaleFile, WorkspaceStaleList };
@@ -1,2 +1,3 @@
1
- import { t as workspaceOperations } from "./operations-CGqY1XeG.js";
2
- export { workspaceOperations };
1
+ import { t as workspaceCommitRequestBytes } from "./results-DgkZUmTL.js";
2
+ import { t as workspaceOperations } from "./operations-CE2drFih.js";
3
+ export { workspaceCommitRequestBytes, workspaceOperations };
@@ -1,9 +1,8 @@
1
- import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.js";
1
+ import { n as __exportAll } from "./rolldown-runtime-rQ84J-ij.js";
2
2
  import { l as workspacePathError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
3
3
  import { isAbsolute, relative, resolve, sep } from "node:path";
4
4
  import { createHash } from "node:crypto";
5
5
  import { minimatch } from "minimatch";
6
- import { hasRuntimeType } from "@vite-hub/runtime/internal/runtime-type";
7
6
  //#region src/core/path.ts
8
7
  var path_exports = /* @__PURE__ */ __exportAll({
9
8
  contentStreamChunks: () => contentStreamChunks,
@@ -107,7 +106,7 @@ function decodeFile(content, options) {
107
106
  return typeof content === "string" ? content : new TextDecoder().decode(content);
108
107
  }
109
108
  async function sha256(input) {
110
- const bytes = contentToBytes(hasRuntimeType(input, "string") || isWorkspaceBytes(input) ? input : JSON.stringify(input));
109
+ const bytes = contentToBytes(typeof input === "string" || isWorkspaceBytes(input) ? input : JSON.stringify(input));
111
110
  return createHash("sha256").update(bytes).digest("hex");
112
111
  }
113
112
  //#endregion
@@ -0,0 +1,7 @@
1
+ import "./types-BbtwmBZ5.js";
2
+ import { ViteHubError } from "@vite-hub/runtime";
3
+ //#region src/core/errors.d.ts
4
+ type WorkspaceErrorCode = "WORKSPACE_CONFLICT" | "WORKSPACE_FAILED" | "WORKSPACE_NOT_FOUND" | "WORKSPACE_PATH_INVALID";
5
+ declare function isWorkspaceConflict(value: unknown): boolean;
6
+ //#endregion
7
+ export { isWorkspaceConflict as n, WorkspaceErrorCode as t };
@@ -1,4 +1,4 @@
1
- import { Tt as WorkspacePlugin } from "./types-DeK9GIxy.js";
1
+ import { Et as WorkspacePlugin } from "./types-BbtwmBZ5.js";
2
2
  //#region src/core/plugins.d.ts
3
3
  /**
4
4
  * Add a plugin's rules and hooks to a Workspace by name, including discovered Workspaces the caller does not define.
@@ -1,18 +1,18 @@
1
+ import { r as vitehubOwnedPrefix, t as createMemoryWorkspaceStore } from "./memory-BOexthyW.js";
1
2
  import { n as assertWorkspaceDigest, o as workspaceConflictError, s as workspaceError } from "./path-DrSIenjj.js";
2
- import { a as isExcludedWorkspacePath, d as resolveInside, f as sha256, l as normalizeWorkspacePath, r as contentToBytes, t as contentStreamChunks } from "./path-CNAwN7pw.js";
3
- import { r as workspaceStoreTarget } from "./target-D4Bqb1eH.js";
4
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-DY5GP47p.js";
5
- import { r as vitehubOwnedPrefix, t as createMemoryWorkspaceStore } from "./memory-BbwOqDXl.js";
6
- import { t as copyJsonFileMetadata } from "./file-metadata-CxDy-E2H.js";
7
- import { t as createWorkspaceGlobMatcher } from "./glob--kNYDbfU.js";
8
- import { C as forgeEnv, w as readForgeEnv } from "./shared-DalXdP0i.js";
9
- import { t as createGitHubWorkspaceStore } from "./store-CXgmu-uw.js";
3
+ import { o as copyJsonFileMetadata, r as workspaceStoreTarget } from "./target-jWhTdIuF.js";
4
+ import { a as isExcludedWorkspacePath, d as resolveInside, f as sha256, l as normalizeWorkspacePath, r as contentToBytes, t as contentStreamChunks } from "./path--wrT_Azm.js";
5
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CtKjGtGb.js";
6
+ import { t as createWorkspaceGlobMatcher } from "./glob-Cjxms1t7.js";
7
+ import { D as forgeEnv, O as readForgeEnv } from "./shared-B3_EUk89.js";
8
+ import { t as createGitHubWorkspaceStore } from "./store-ybhyD38Z.js";
9
+ import { t as getWorkspaceRuntimeConfig } from "./config-B-863EgC.js";
10
10
  import { dirname, join, relative, resolve, sep } from "node:path";
11
11
  import { createHash, randomUUID } from "node:crypto";
12
- import { defu } from "defu";
13
- import { check, fallback, literal, object, optional, pipe, record, safeParse, string, unknown } from "valibot";
14
12
  import { constants, createReadStream, createWriteStream } from "node:fs";
15
13
  import { chmod, chown, copyFile, link, lstat, mkdir, open, readFile, readdir, rename, rm, rmdir, stat, utimes, writeFile } from "node:fs/promises";
14
+ import { defu } from "defu";
15
+ import { check, fallback, literal, object, optional, pipe, record, safeParse, string, unknown } from "valibot";
16
16
  import { Readable, Transform } from "node:stream";
17
17
  import { pipeline } from "node:stream/promises";
18
18
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
@@ -27,20 +27,6 @@ function readEnv(env, ...names) {
27
27
  }
28
28
  }
29
29
  //#endregion
30
- //#region src/runtime/config.ts
31
- const workspaceRuntimeConfigKey = Symbol.for("vitehub.workspace.runtimeConfig");
32
- function workspaceRuntimeConfigGlobal() {
33
- const scope = globalThis;
34
- scope[workspaceRuntimeConfigKey] ??= false;
35
- return scope;
36
- }
37
- function setWorkspaceRuntimeConfig(config) {
38
- workspaceRuntimeConfigGlobal()[workspaceRuntimeConfigKey] = config;
39
- }
40
- function getWorkspaceRuntimeConfig() {
41
- return workspaceRuntimeConfigGlobal()[workspaceRuntimeConfigKey] ?? false;
42
- }
43
- //#endregion
44
30
  //#region src/runtime/hosted-store-loader.ts
45
31
  const workspaceHostedStoreLoaderKey = Symbol.for("vitehub.workspace.hostedStoreLoader");
46
32
  function workspaceHostedStoreLoaderGlobal() {
@@ -953,28 +939,38 @@ var LocalWorkspaceStore = class {
953
939
  try {
954
940
  await writeFile(temp, bytes);
955
941
  const hadExisting = existing?.type === "file";
956
- const foreignUid = hadExisting ? await backupFile(absolute, backup) : void 0;
957
- await rename(temp, absolute).catch(async (error) => {
958
- await rm(backup, { force: true });
959
- throw error;
942
+ await this.#publishFile({
943
+ absolute,
944
+ normalized,
945
+ temp,
946
+ backup,
947
+ hadExisting,
948
+ file
960
949
  });
961
- try {
962
- await this.#writeFileMetadata(normalized, {
963
- mediaType: file.mediaType,
964
- metadata: file.metadata
965
- });
966
- } catch (error) {
967
- if (hadExisting) await restoreBackup(backup, absolute, foreignUid, error);
968
- else await rm(absolute, { force: true });
969
- throw error;
970
- }
971
- await reclaimBackup(backup);
972
950
  return;
973
951
  } catch (error) {
974
952
  await rm(temp, { force: true }).catch(() => void 0);
975
953
  throw error;
976
954
  }
977
955
  }
956
+ async #publishFile({ absolute, normalized, temp, backup, hadExisting, file }) {
957
+ const foreignUid = hadExisting ? await backupFile(absolute, backup) : void 0;
958
+ await rename(temp, absolute).catch(async (error) => {
959
+ await rm(backup, { force: true });
960
+ throw error;
961
+ });
962
+ try {
963
+ await this.#writeFileMetadata(normalized, {
964
+ mediaType: file.mediaType,
965
+ metadata: file.metadata
966
+ });
967
+ } catch (error) {
968
+ if (hadExisting) await restoreBackup(backup, absolute, foreignUid, error);
969
+ else await rm(absolute, { force: true });
970
+ throw error;
971
+ }
972
+ await reclaimBackup(backup);
973
+ }
978
974
  async #assertPathComponents(path, includeTarget = true) {
979
975
  const root = resolve(this.root);
980
976
  const parts = relative(root, resolveInside(root, path)).split(sep).filter(Boolean);
@@ -1034,22 +1030,14 @@ var LocalWorkspaceStore = class {
1034
1030
  };
1035
1031
  }
1036
1032
  const hadExisting = existing?.type === "file";
1037
- const foreignUid = hadExisting ? await backupFile(absolute, backup) : void 0;
1038
- await rename(temp, absolute).catch(async (error) => {
1039
- await rm(backup, { force: true });
1040
- throw error;
1033
+ await this.#publishFile({
1034
+ absolute,
1035
+ normalized,
1036
+ temp,
1037
+ backup,
1038
+ hadExisting,
1039
+ file
1041
1040
  });
1042
- try {
1043
- await this.#writeFileMetadata(normalized, {
1044
- mediaType: file.mediaType,
1045
- metadata: file.metadata
1046
- });
1047
- } catch (error) {
1048
- if (hadExisting) await restoreBackup(backup, absolute, foreignUid, error);
1049
- else await rm(absolute, { force: true });
1050
- throw error;
1051
- }
1052
- await reclaimBackup(backup);
1053
1041
  return {
1054
1042
  path: normalized,
1055
1043
  type: "file",
@@ -1374,7 +1362,7 @@ function resolveCloudflareArtifactsStore(config = {}, env = process.env) {
1374
1362
  }, {
1375
1363
  binding: "WORKSPACE_ARTIFACTS",
1376
1364
  namespace: "vitehub",
1377
- provider: "cloudflare-artifacts"
1365
+ driver: "cloudflare"
1378
1366
  });
1379
1367
  }
1380
1368
  function resolveVercelBlobWorkspaceStore(config = {}, env = process.env) {
@@ -1383,7 +1371,7 @@ function resolveVercelBlobWorkspaceStore(config = {}, env = process.env) {
1383
1371
  return {
1384
1372
  access: config.access ?? "private",
1385
1373
  ...prefix === void 0 ? {} : { prefix },
1386
- provider: "vercel-blob",
1374
+ driver: "vercel",
1387
1375
  token: MASKED_WORKSPACE_RUNTIME_VALUE
1388
1376
  };
1389
1377
  }
@@ -1393,7 +1381,7 @@ function resolveGitHubWorkspaceStore(config = {}, env = process.env, input = {})
1393
1381
  return {
1394
1382
  branch: branch ?? (input.runtime ? void 0 : "main"),
1395
1383
  ...config.database === void 0 ? {} : { database: config.database },
1396
- provider: "github",
1384
+ driver: "github",
1397
1385
  ...config.refs ? { refs: { ...config.refs } } : {},
1398
1386
  repository: gitHubWorkspaceOption(config.repository) ?? gitHubWorkspaceOption(config.repo) ?? readEnv(env, "VITEHUB_WORKSPACE_GITHUB_REPOSITORY"),
1399
1387
  root: root ?? (input.runtime ? void 0 : ".vitehub/workspaces/<workspace>"),
@@ -1401,41 +1389,69 @@ function resolveGitHubWorkspaceStore(config = {}, env = process.env, input = {})
1401
1389
  };
1402
1390
  }
1403
1391
  function hasVercelWorkspaceBlobEnv(env) {
1404
- return Boolean(readEnv(env, "BLOB_READ_WRITE_TOKEN"));
1392
+ return Boolean(readEnv(env, "BLOB_STORE_ID", "BLOB_READ_WRITE_TOKEN"));
1405
1393
  }
1394
+ const workspaceStoreDrivers = /* @__PURE__ */ new Set([
1395
+ "cloudflare",
1396
+ "github",
1397
+ "local",
1398
+ "memory",
1399
+ "vercel"
1400
+ ]);
1401
+ /** Driver names that ViteHub renamed to the host name. `npx @vite-hub/codemods driver-key` moves them. */
1402
+ const renamedWorkspaceStoreDrivers = /* @__PURE__ */ new Map([["cloudflare-artifacts", "cloudflare"], ["vercel-blob", "vercel"]]);
1406
1403
  function normalizeWorkspaceStoreOptions(store, input = {}) {
1407
1404
  if (isWorkspaceStore(store)) return;
1408
- if (input.dev && !store) return { provider: "local" };
1405
+ if (input.dev && !store) return { driver: "local" };
1409
1406
  const env = input.env || process.env;
1410
1407
  const hosting = input.hosting || "";
1411
- if (store?.provider === "cloudflare-artifacts") return resolveCloudflareArtifactsStore(store, env);
1412
- if (store?.provider === "github") return resolveGitHubWorkspaceStore(store, env, input);
1413
- if (store?.provider === "memory") return store;
1414
- if (store?.provider === "vercel-blob") return resolveVercelBlobWorkspaceStore(store, env);
1415
- if (store?.provider === "local" || store?.root) return defu(store, { provider: "local" });
1416
- if (store && "provider" in store) throw workspaceError(`[vitehub] Unsupported workspace store provider: ${String(store.provider)}.`);
1417
- if (hosting.includes("cloudflare")) return { provider: "memory" };
1408
+ if (store && Object.hasOwn(store, "provider") && store.driver === void 0) {
1409
+ const provider = store.provider;
1410
+ const driver = renamedWorkspaceStoreDrivers.get(String(provider)) ?? provider;
1411
+ throw workspaceErrorDiagnostics.WORKSPACE_RENAMED_STORE_PROVIDER_KEY({
1412
+ driver: JSON.stringify(driver) ?? String(driver),
1413
+ provider: JSON.stringify(provider) ?? String(provider)
1414
+ });
1415
+ }
1416
+ if (store?.driver !== void 0 && !workspaceStoreDrivers.has(store.driver)) throw workspaceErrorDiagnostics.WORKSPACE_UNKNOWN_STORE_DRIVER({
1417
+ driver: JSON.stringify(store.driver),
1418
+ renamed: renamedWorkspaceStoreDrivers.get(String(store.driver))
1419
+ });
1420
+ if (store?.driver === "cloudflare") return resolveCloudflareArtifactsStore(store, env);
1421
+ if (store?.driver === "github") return resolveGitHubWorkspaceStore(store, env, input);
1422
+ if (store?.driver === "memory") return store;
1423
+ if (store?.driver === "vercel") return resolveVercelBlobWorkspaceStore(store, env);
1424
+ if (store?.driver === "local" || store?.root) return defu(store, { driver: "local" });
1425
+ if (store && "driver" in store) throw workspaceError(`[vitehub] Unsupported workspace store driver: ${String(store.driver)}.`);
1426
+ if (hosting.includes("cloudflare")) return { driver: "memory" };
1418
1427
  if (hasVercelWorkspaceBlobEnv(env)) return resolveVercelBlobWorkspaceStore({}, env);
1419
- if (hosting.includes("vercel")) return { provider: "memory" };
1420
- return { provider: "local" };
1428
+ if (hosting.includes("vercel")) return { driver: "memory" };
1429
+ return { driver: "local" };
1421
1430
  }
1422
- function createWorkspaceStoreFromProvider(definition) {
1431
+ /** Resolve the effective store once for the runtime and its durability report. */
1432
+ function resolveWorkspaceDefinitionStore(definition, runtimeConfig = getWorkspaceRuntimeConfig(), input = {}) {
1423
1433
  if (isWorkspaceStore(definition.store)) return definition.store;
1424
1434
  const rootDir = definition.rootDir || process.cwd();
1425
- const runtimeConfig = getWorkspaceRuntimeConfig();
1426
1435
  const runtimeStore = runtimeConfig ? runtimeConfig.store : void 0;
1427
- const store = normalizeWorkspaceStoreOptions(definition.store || runtimeStore, {
1436
+ return normalizeWorkspaceStoreOptions(definition.store || runtimeStore, {
1428
1437
  env: typeof process !== "undefined" ? process.env : {},
1429
- hosting: typeof process !== "undefined" ? process.env.VITEHUB_HOSTING : void 0,
1438
+ hosting: typeof process !== "undefined" ? process.env.VITEHUB_HOST : void 0,
1430
1439
  rootDir,
1431
- runtime: true
1440
+ runtime: true,
1441
+ ...input
1432
1442
  });
1433
- if (store?.provider === "memory") return createMemoryWorkspaceStore();
1434
- if (store?.provider === "cloudflare-artifacts" || store?.provider === "github" || store?.provider === "vercel-blob") {
1435
- const loader = getWorkspaceHostedStoreLoader();
1436
- if (!loader && store.provider === "github") return createGitHubWorkspaceStore(store, definition.name);
1437
- if (!loader) throw workspaceError(`[vitehub] Hosted workspace store "${store.provider}" is not available in this runtime.`);
1438
- return loader(store, definition.name);
1443
+ }
1444
+ function createWorkspaceStoreFromProvider(definition) {
1445
+ const runtimeConfig = getWorkspaceRuntimeConfig();
1446
+ const store = resolveWorkspaceDefinitionStore(definition, runtimeConfig);
1447
+ if (isWorkspaceStore(store)) return store;
1448
+ const rootDir = definition.rootDir || process.cwd();
1449
+ if (store?.driver === "memory") return createMemoryWorkspaceStore();
1450
+ if (store?.driver === "cloudflare" || store?.driver === "github" || store?.driver === "vercel") {
1451
+ const hostedStore = getWorkspaceHostedStoreLoader()?.(store, definition.name);
1452
+ if (hostedStore) return hostedStore;
1453
+ if (store.driver === "github") return createGitHubWorkspaceStore(store, definition.name);
1454
+ throw workspaceError(`[vitehub] Hosted workspace store "${store.driver}" is not available in this runtime.`);
1439
1455
  }
1440
1456
  return createLocalWorkspaceStore(store?.root ? resolve(rootDir, store.root) : runtimeConfig ? resolve(runtimeConfig.root, definition.name) : resolve(rootDir, ".vitehub/workspaces", definition.name), {
1441
1457
  ignore: store?.ignore,
@@ -1445,13 +1461,19 @@ function createWorkspaceStoreFromProvider(definition) {
1445
1461
  function isMaskedWorkspaceRuntimeValue(value) {
1446
1462
  return !value || value === "********";
1447
1463
  }
1464
+ /**
1465
+ * Uses OIDC when the project has `BLOB_STORE_ID`, like `@vite-hub/blob`. The store then has no
1466
+ * token, so `@vercel/blob` reads the OIDC token itself and falls back to `BLOB_READ_WRITE_TOKEN`.
1467
+ */
1448
1468
  function resolveRuntimeVercelBlobWorkspaceStore(config, env) {
1469
+ const { token: _maskedToken, ...store } = config;
1470
+ if (readEnv(env, "BLOB_STORE_ID")) return store;
1449
1471
  const token = readEnv(env, "BLOB_READ_WRITE_TOKEN");
1450
- if (isMaskedWorkspaceRuntimeValue(token)) throw workspaceErrorDiagnostics.WORKSPACE_R0066({ message: "Missing runtime environment variable `BLOB_READ_WRITE_TOKEN` for Vercel workspace Blob storage." });
1472
+ if (isMaskedWorkspaceRuntimeValue(token)) throw workspaceErrorDiagnostics.WORKSPACE_R0066({ message: "Missing Vercel Blob credentials for Workspace storage. Connect a Blob store to the Vercel project so it gets `BLOB_STORE_ID`, or set `BLOB_READ_WRITE_TOKEN` off Vercel." });
1451
1473
  return {
1452
- ...config,
1474
+ ...store,
1453
1475
  token
1454
1476
  };
1455
1477
  }
1456
1478
  //#endregion
1457
- export { resolveGitHubWorkspaceStore as a, ownedBlobPrefix as c, getWorkspaceRuntimeConfig as d, setWorkspaceRuntimeConfig as f, resolveCloudflareArtifactsStore as i, getWorkspaceHostedStoreLoader as l, isWorkspaceStore as n, resolveRuntimeVercelBlobWorkspaceStore as o, normalizeWorkspaceStoreOptions as r, resolveVercelBlobWorkspaceStore as s, createWorkspaceStoreFromProvider as t, setWorkspaceHostedStoreLoader as u };
1479
+ export { resolveGitHubWorkspaceStore as a, resolveWorkspaceDefinitionStore as c, setWorkspaceHostedStoreLoader as d, resolveCloudflareArtifactsStore as i, ownedBlobPrefix as l, isWorkspaceStore as n, resolveRuntimeVercelBlobWorkspaceStore as o, normalizeWorkspaceStoreOptions as r, resolveVercelBlobWorkspaceStore as s, createWorkspaceStoreFromProvider as t, getWorkspaceHostedStoreLoader as u };
@@ -1,4 +1,4 @@
1
- import { bn as WorkspaceStore, s as GitHubWorkspaceStoreOptions } from "../../types-DeK9GIxy.js";
1
+ import { s as GitHubWorkspaceStoreOptions, xn as WorkspaceStore } from "../../types-BbtwmBZ5.js";
2
2
  //#region src/providers/github/store.d.ts
3
3
  export declare function createGitHubWorkspaceStore(options: GitHubWorkspaceStoreOptions, workspaceName: string): WorkspaceStore;
4
4
  //#endregion
@@ -1,2 +1,2 @@
1
- import { t as createGitHubWorkspaceStore } from "../../store-CXgmu-uw.js";
1
+ import { t as createGitHubWorkspaceStore } from "../../store-ybhyD38Z.js";
2
2
  export { createGitHubWorkspaceStore };
@@ -0,0 +1,19 @@
1
+ import { L as WorkspaceDefinitionInput, v as ResolvedWorkspaceModuleOptions } from "./types-BbtwmBZ5.js";
2
+ //#region src/runtime/config.d.ts
3
+ declare function setWorkspaceRuntimeConfig(config: false | ResolvedWorkspaceModuleOptions): void;
4
+ declare function getWorkspaceRuntimeConfig(): false | ResolvedWorkspaceModuleOptions;
5
+ //#endregion
6
+ //#region src/runtime/registry.d.ts
7
+ type WorkspaceRegistryModule = {
8
+ default?: WorkspaceDefinitionInput;
9
+ };
10
+ type WorkspaceRegistry = Record<string, () => Promise<WorkspaceRegistryModule>>;
11
+ interface WorkspaceRuntimeRegistryState {
12
+ loaders: WorkspaceRegistry;
13
+ version: number;
14
+ }
15
+ declare function workspaceRuntimeRegistryState(): Readonly<WorkspaceRuntimeRegistryState>;
16
+ declare function setWorkspaceRuntimeRegistry(registry: WorkspaceRegistry): void;
17
+ declare function resetWorkspaceRuntimeRegistry(): void;
18
+ //#endregion
19
+ export { workspaceRuntimeRegistryState as a, setWorkspaceRuntimeRegistry as i, WorkspaceRegistryModule as n, getWorkspaceRuntimeConfig as o, resetWorkspaceRuntimeRegistry as r, setWorkspaceRuntimeConfig as s, WorkspaceRegistry as t };
@@ -1,8 +1,8 @@
1
1
  import { c as workspaceNotFoundError } from "./path-DrSIenjj.js";
2
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-DY5GP47p.js";
3
- import { t as createWorkspace } from "./workspace-6pxkOuxr.js";
4
- import { hasRuntimeType } from "@vite-hub/runtime/internal/runtime-type";
5
- import runtimeRegistry from "#vitehub-workspace-registry";
2
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CtKjGtGb.js";
3
+ import { t as createWorkspace } from "./workspace-sPWn2Jxj.js";
4
+ import { setWorkspaceRuntimeRegistry, workspaceRuntimeRegistryState } from "./runtime/registry.js";
5
+ import { getViteHubErrorShape, isRuntimeDiagnostic } from "@vite-hub/runtime";
6
6
  //#region src/core/registry.ts
7
7
  const workspaceRegistryStateKey = Symbol.for("vitehub.workspace.registryState");
8
8
  function workspaceRegistryState() {
@@ -11,23 +11,45 @@ function workspaceRegistryState() {
11
11
  loadingDefinitions: /* @__PURE__ */ new Map(),
12
12
  loadGenerations: /* @__PURE__ */ new Map(),
13
13
  loadedDefinitions: /* @__PURE__ */ new Map(),
14
- loaders: runtimeRegistry,
15
- registeredDefinitions: /* @__PURE__ */ new Map()
14
+ registeredDefinitions: /* @__PURE__ */ new Map(),
15
+ registryVersion: workspaceRuntimeRegistryState().version,
16
+ scopedDefinitions: /* @__PURE__ */ new Map()
16
17
  };
17
- scope[workspaceRegistryStateKey].loadingDefinitions ??= /* @__PURE__ */ new Map();
18
- scope[workspaceRegistryStateKey].loadGenerations ??= /* @__PURE__ */ new Map();
19
- return scope[workspaceRegistryStateKey];
18
+ const state = scope[workspaceRegistryStateKey];
19
+ state.loadingDefinitions ??= /* @__PURE__ */ new Map();
20
+ state.loadGenerations ??= /* @__PURE__ */ new Map();
21
+ state.scopedDefinitions ??= /* @__PURE__ */ new Map();
22
+ const { version } = workspaceRuntimeRegistryState();
23
+ if (state.registryVersion !== version) {
24
+ invalidateWorkspaceLoads(state);
25
+ state.loadedDefinitions.clear();
26
+ state.registryVersion = version;
27
+ }
28
+ return state;
20
29
  }
21
30
  function pickWorkspaceFields(definition) {
22
31
  const { __vitehubWorkspaceAgent: _agent, __vitehubWorkspaceAgentOptions: _agentOptions, description: _description, fallback: _fallback, instructions: _instructions, model: _model, name: _agentName, resolve: _resolve, run: _run, stepLimit: _stepLimit, workspace: _workspace, ...workspace } = definition;
23
32
  return workspace;
24
33
  }
34
+ /**
35
+ * The error for a failed loader of the generated Workspace registry. The registry runs plain source text without the
36
+ * Workspace catalog, so its own failures and the errors of the Definition module get a code here. A coded error passes.
37
+ */
38
+ function workspaceRegistryLoadError(workspace, error) {
39
+ if (isRuntimeDiagnostic(error) || getViteHubErrorShape(error)) return error;
40
+ const reason = error instanceof Error ? error.message : String(error);
41
+ return workspaceErrorDiagnostics.WORKSPACE_REGISTRY_LOAD_FAILED({
42
+ reason,
43
+ workspace,
44
+ cause: error
45
+ });
46
+ }
25
47
  function normalizeWorkspaceDefinition(name, definition) {
26
48
  if (!definition) throw workspaceNotFoundError(name);
27
49
  const workspaceAgentOptions = definition.__vitehubWorkspaceAgentOptions;
28
50
  if (workspaceAgentOptions?.workspace) {
29
51
  const injectedWorkspace = pickWorkspaceFields(definition);
30
- const configuredWorkspace = hasRuntimeType(workspaceAgentOptions.workspace, "string") ? {} : workspaceAgentOptions.workspace;
52
+ const configuredWorkspace = typeof workspaceAgentOptions.workspace === "string" ? {} : workspaceAgentOptions.workspace;
31
53
  const sources = mergeWorkspaceSources(injectedWorkspace.sources, configuredWorkspace.sources);
32
54
  const normalizedWorkspace = {
33
55
  ...injectedWorkspace,
@@ -53,16 +75,21 @@ function mergeWorkspaceSources(injected, configured) {
53
75
  };
54
76
  }
55
77
  function registerWorkspace(name, definition) {
56
- if (!name || !hasRuntimeType(name, "string")) throw workspaceErrorDiagnostics.WORKSPACE_R0022({ message: "[vitehub] registerWorkspace requires a string name." });
78
+ if (!name || typeof name !== "string") throw workspaceErrorDiagnostics.WORKSPACE_R0022({ message: "[vitehub] registerWorkspace requires a string name." });
57
79
  const registered = normalizeWorkspaceDefinition(name, definition);
58
80
  workspaceRegistryState().registeredDefinitions.set(name, registered);
59
81
  return registered;
60
82
  }
61
- function setWorkspaceRegistry(registry) {
83
+ /** Replace one generated catalog's definitions without replacing application registrations. */
84
+ function setWorkspaceRuntimeDefinitions(scope, definitions) {
85
+ const normalized = new Map(Object.entries(definitions).map(([name, definition]) => [name, normalizeWorkspaceDefinition(name, definition)]));
62
86
  const state = workspaceRegistryState();
63
- invalidateWorkspaceLoads(state);
64
- state.loaders = registry;
65
- state.loadedDefinitions.clear();
87
+ if (normalized.size) state.scopedDefinitions.set(scope, normalized);
88
+ else state.scopedDefinitions.delete(scope);
89
+ }
90
+ function setWorkspaceRegistry(registry) {
91
+ setWorkspaceRuntimeRegistry(registry);
92
+ workspaceRegistryState();
66
93
  }
67
94
  function invalidateWorkspaceLoads(state) {
68
95
  for (const [name, loading] of state.loadingDefinitions) if (state.loadGenerations.get(name) === loading.generation) state.loadGenerations.set(name, loading.generation + 1);
@@ -70,17 +97,25 @@ function invalidateWorkspaceLoads(state) {
70
97
  }
71
98
  async function resolveWorkspaceDefinition(name, abortSignal) {
72
99
  const state = workspaceRegistryState();
73
- const existing = state.registeredDefinitions.get(name) || state.loadedDefinitions.get(name);
100
+ const registered = state.registeredDefinitions.get(name);
101
+ if (registered) return registered;
102
+ for (const definitions of state.scopedDefinitions.values()) {
103
+ const definition = definitions.get(name);
104
+ if (definition) return definition;
105
+ }
106
+ const existing = state.loadedDefinitions.get(name);
74
107
  if (existing) return existing;
75
- const load = state.loaders[name];
108
+ const load = workspaceRuntimeRegistryState().loaders[name];
76
109
  if (!load) throw workspaceNotFoundError(name);
77
110
  let loading = state.loadingDefinitions.get(name);
78
111
  if (!loading || loading.load !== load) {
79
112
  const generation = (state.loadGenerations.get(name) ?? 0) + 1;
80
113
  state.loadGenerations.set(name, generation);
81
- const promise = load().then((mod) => {
114
+ const promise = (async () => load())().catch((error) => {
115
+ throw workspaceRegistryLoadError(name, error);
116
+ }).then((mod) => {
82
117
  const definition = normalizeWorkspaceDefinition(name, mod.default);
83
- if (state.loadGenerations.get(name) === generation && state.loaders[name] === load) state.loadedDefinitions.set(name, definition);
118
+ if (state.loadGenerations.get(name) === generation && workspaceRuntimeRegistryState().loaders[name] === load) state.loadedDefinitions.set(name, definition);
84
119
  return definition;
85
120
  });
86
121
  loading = {
@@ -126,4 +161,4 @@ async function useRegisteredWorkspace(name, options = {}) {
126
161
  return createWorkspace(definition, options);
127
162
  }
128
163
  //#endregion
129
- export { useRegisteredWorkspace as a, setWorkspaceRegistry as i, registerWorkspace as n, resolveRegisteredWorkspaceDefinition as r, normalizeWorkspaceDefinition as t };
164
+ export { setWorkspaceRuntimeDefinitions as a, setWorkspaceRegistry as i, registerWorkspace as n, useRegisteredWorkspace as o, resolveRegisteredWorkspaceDefinition as r, workspaceRegistryLoadError as s, normalizeWorkspaceDefinition as t };
@@ -0,0 +1,9 @@
1
+ import { I as WorkspaceDefinition, L as WorkspaceDefinitionInput } from "./types-BbtwmBZ5.js";
2
+ import "./registry-B3BBm4Ts.js";
3
+ //#region src/core/registry.d.ts
4
+ declare function registerWorkspace(name: string, definition: WorkspaceDefinitionInput): WorkspaceDefinition;
5
+ /** Replace one generated catalog's definitions without replacing application registrations. */
6
+ declare function setWorkspaceRuntimeDefinitions(scope: string, definitions: Record<string, WorkspaceDefinitionInput>): void;
7
+ declare function resolveRegisteredWorkspaceDefinition(name: string, abortSignal?: AbortSignal): Promise<WorkspaceDefinition>;
8
+ //#endregion
9
+ export { resolveRegisteredWorkspaceDefinition as n, setWorkspaceRuntimeDefinitions as r, registerWorkspace as t };
@@ -0,0 +1,83 @@
1
+ import { t as workspaceStoreDiscard } from "./discard-CNNtCozM.js";
2
+ import { registerRunScope } from "@vite-hub/runtime/internal/run-scope";
3
+ //#region src/core/request-scope.ts
4
+ const runtimeGlobal = globalThis;
5
+ const storageKey = Symbol.for("vitehub.workspace.request");
6
+ const writersKey = Symbol.for("vitehub.workspace.writers");
7
+ /** Writes made outside a request and a run, such as at startup, which no request may drop. */
8
+ const outsideRequest = { staged: /* @__PURE__ */ new Set() };
9
+ function requestStorage() {
10
+ const existing = runtimeGlobal[storageKey];
11
+ if (existing) return existing;
12
+ const Storage = globalThis.process?.getBuiltinModule?.("node:async_hooks")?.AsyncLocalStorage;
13
+ if (!Storage) return;
14
+ const storage = new Storage();
15
+ runtimeGlobal[storageKey] = storage;
16
+ return storage;
17
+ }
18
+ /** The requests that staged writes in each Store since its last snapshot. */
19
+ function writers() {
20
+ return runtimeGlobal[writersKey] ??= /* @__PURE__ */ new WeakMap();
21
+ }
22
+ function isDiscardable(store) {
23
+ return typeof store[workspaceStoreDiscard] === "function";
24
+ }
25
+ const stagingMethods = [
26
+ "mkdir",
27
+ "rebase",
28
+ "removeEmptyDirectory",
29
+ "rm",
30
+ "setMeta",
31
+ "writeFile",
32
+ "writeFileConditional",
33
+ "writeFileStream"
34
+ ];
35
+ /**
36
+ * Records which request stages writes in a Store that keeps them until `snapshot()`, for every caller of the Store:
37
+ * Workspace methods, Source materialization, and sync. Other Stores write through and are returned as they are.
38
+ */
39
+ function trackStagedWrites(store) {
40
+ if (!isDiscardable(store)) return store;
41
+ for (const name of stagingMethods) {
42
+ const method = store[name];
43
+ if (typeof method !== "function") continue;
44
+ Reflect.set(store, name, (...args) => {
45
+ const request = requestStorage()?.getStore() ?? outsideRequest;
46
+ if (request !== outsideRequest) request.staged.add(store);
47
+ const staged = writers().get(store);
48
+ if (staged) staged.add(request);
49
+ else writers().set(store, /* @__PURE__ */ new Set([request]));
50
+ return Reflect.apply(method, store, args);
51
+ });
52
+ }
53
+ const snapshot = store.snapshot;
54
+ store.snapshot = async (options) => {
55
+ const result = await Reflect.apply(snapshot, store, [options]);
56
+ writers().delete(store);
57
+ return result;
58
+ };
59
+ return store;
60
+ }
61
+ /**
62
+ * Runs one request. When it throws, each Store that only this request staged writes in since its last snapshot drops
63
+ * them, so a later snapshot cannot commit them. Facades that hold the Store see the same branch as a new request.
64
+ */
65
+ async function runWorkspaceRequest(next) {
66
+ const storage = requestStorage();
67
+ if (!storage) return await next();
68
+ const request = { staged: /* @__PURE__ */ new Set() };
69
+ try {
70
+ return await storage.run(request, next);
71
+ } catch (error) {
72
+ for (const store of request.staged) {
73
+ const staged = writers().get(store);
74
+ if (staged?.size !== 1 || !staged.has(request) || !isDiscardable(store)) continue;
75
+ writers().delete(store);
76
+ await store[workspaceStoreDiscard]();
77
+ }
78
+ throw error;
79
+ }
80
+ }
81
+ registerRunScope(runWorkspaceRequest);
82
+ //#endregion
83
+ export { trackStagedWrites as n, runWorkspaceRequest as t };
@@ -0,0 +1,8 @@
1
+ //#region src/results.ts
2
+ /**
3
+ * The largest `workspace.commit` request body: 4 MiB of JSON, with base64 for binary files. Vercel Functions accept
4
+ * request bodies up to 4.5 MB and Cloudflare Workers up to 100 MB, so one push works on every host.
5
+ */
6
+ const workspaceCommitRequestBytes = 4194304;
7
+ //#endregion
8
+ export { workspaceCommitRequestBytes as t };