@vite-hub/workspace 0.1.0 → 0.3.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 (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
@@ -0,0 +1,89 @@
1
+ import { s as workspaceError } from "./path-DrSIenjj.js";
2
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CtKjGtGb.js";
3
+ //#region src/core/file-metadata.ts
4
+ function invalidMetadata(path) {
5
+ return workspaceError(`[vitehub] Invalid Workspace metadata for ${path}. Metadata must contain only JSON-safe plain objects, dense arrays, strings, booleans, null, and finite numbers other than negative zero.`);
6
+ }
7
+ function copyJsonValue(path, value, ancestors, normalizeOptional = false) {
8
+ if (value === null || typeof value === "string" || typeof value === "boolean") return value;
9
+ if (typeof value === "number" && Number.isFinite(value) && !Object.is(value, -0)) return value;
10
+ if (typeof value !== "object" || ancestors.has(value)) throw invalidMetadata(path);
11
+ const array = Array.isArray(value);
12
+ const prototype = Object.getPrototypeOf(value);
13
+ if (!array && prototype !== Object.prototype && prototype !== null) throw invalidMetadata(path);
14
+ ancestors.add(value);
15
+ try {
16
+ const descriptors = Object.getOwnPropertyDescriptors(value);
17
+ const keys = Reflect.ownKeys(descriptors).filter((key) => !array || key !== "length");
18
+ if (array && !normalizeOptional && keys.length !== descriptors.length?.value) throw invalidMetadata(path);
19
+ const copy = array ? [] : {};
20
+ for (const [index, key] of keys.entries()) {
21
+ if (typeof key !== "string" || array && (normalizeOptional ? !/^(0|[1-9]\d*)$/.test(key) || Number(key) >= descriptors.length?.value : key !== String(index))) throw invalidMetadata(path);
22
+ const descriptor = descriptors[key];
23
+ if (!descriptor.enumerable || !("value" in descriptor)) throw invalidMetadata(path);
24
+ if (normalizeOptional && descriptor.value === void 0 && !array) continue;
25
+ Object.defineProperty(copy, key, {
26
+ value: normalizeOptional && descriptor.value === void 0 ? null : copyJsonValue(path, descriptor.value, ancestors, normalizeOptional),
27
+ enumerable: true,
28
+ writable: true,
29
+ configurable: true
30
+ });
31
+ }
32
+ if (array && normalizeOptional) {
33
+ for (let index = 0; index < descriptors.length?.value; index++) if (!Object.hasOwn(copy, index)) Object.defineProperty(copy, index, {
34
+ value: null,
35
+ enumerable: true,
36
+ writable: true,
37
+ configurable: true
38
+ });
39
+ }
40
+ return copy;
41
+ } finally {
42
+ ancestors.delete(value);
43
+ }
44
+ }
45
+ function copyJsonWorkspaceMetadata(path, metadata, normalizeOptional = false) {
46
+ if (metadata === void 0) return;
47
+ let copy;
48
+ try {
49
+ if (typeof metadata === "object" && metadata !== null && !Array.isArray(metadata)) copy = copyJsonValue(path, metadata, /* @__PURE__ */ new Set(), normalizeOptional);
50
+ } catch {}
51
+ if (!copy) throw invalidMetadata(path);
52
+ return copy;
53
+ }
54
+ function copyJsonFileMetadata(path, metadata, normalizeOptional = false) {
55
+ const copy = copyJsonWorkspaceMetadata(path, metadata, normalizeOptional);
56
+ if (!copy) return;
57
+ const source = Object.getOwnPropertyDescriptor(copy, "source");
58
+ if (source && typeof source.value !== "string") throw workspaceError(`[vitehub] Invalid Workspace metadata for ${path}. metadata.source must be a string when provided.`);
59
+ return copy;
60
+ }
61
+ //#endregion
62
+ //#region src/core/rule-keys.ts
63
+ /** The rule fields that a more specific rule replaces only when it sets them. */
64
+ const cascadingRuleKeys = [
65
+ "commit",
66
+ "maxBytes",
67
+ "mediaType",
68
+ "write"
69
+ ];
70
+ const workspaceRuleKeys = /* @__PURE__ */ new Set([...cascadingRuleKeys, "validate"]);
71
+ /** Rejects rule keys that ViteHub does not enforce, such as `read`, so that a rule never looks like a protection it is not. */
72
+ function assertWorkspaceRules(rules) {
73
+ for (const [pattern, rule] of Object.entries(rules ?? {})) for (const key of Object.keys(rule ?? {})) {
74
+ if (key === "read") throw workspaceErrorDiagnostics.WORKSPACE_R0075({ message: `[vitehub] Workspace rule "${pattern}" sets read. Workspace rules do not limit reads.` });
75
+ if (!workspaceRuleKeys.has(key)) throw workspaceErrorDiagnostics.WORKSPACE_R0076({ message: `[vitehub] Workspace rule "${pattern}" does not support option "${key}".` });
76
+ }
77
+ }
78
+ //#endregion
79
+ //#region src/storage/target.ts
80
+ const workspaceStoreTarget = Symbol.for("vitehub.workspace.storeTarget");
81
+ function forwardWorkspaceStoreTarget(source, target) {
82
+ const resolveTarget = source[workspaceStoreTarget];
83
+ if (resolveTarget) target[workspaceStoreTarget] = resolveTarget.bind(source);
84
+ }
85
+ async function resolveWorkspaceStoreTarget(source) {
86
+ return await source[workspaceStoreTarget]?.();
87
+ }
88
+ //#endregion
89
+ export { cascadingRuleKeys as a, assertWorkspaceRules as i, resolveWorkspaceStoreTarget as n, copyJsonFileMetadata as o, workspaceStoreTarget as r, copyJsonWorkspaceMetadata as s, forwardWorkspaceStoreTarget as t };
package/dist/test.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as registerWorkspace } from "./registry-Cg1TJVVZ.js";
1
+ import { t as registerWorkspace } from "./registry-CYNN623b.js";
2
2
  export { registerWorkspace };
package/dist/test.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as registerWorkspace } from "./registry-Bp-8UUfG.js";
1
+ import { n as registerWorkspace } from "./registry-CNphafBx.js";
2
2
  export { registerWorkspace };
@@ -1,8 +1,5 @@
1
1
  import { ExecutionAuthority } from "@vite-hub/runtime";
2
- import { Source, SourceContext, SourceRevision } from "@vite-hub/source";
3
- import { FileSourceOptions } from "@vite-hub/source/file";
4
- import { GitHubSourceOptions } from "@vite-hub/source/github";
5
- import { GlobSourceOptions } from "@vite-hub/source/glob";
2
+ import { FileSourceOptions, GitHubSourceOptions, GlobSourceOptions, Source, SourceContext, SourceRevision } from "@vite-hub/source";
6
3
  import { McpResourcesSourceOptions } from "@vite-hub/source/mcp";
7
4
  //#region src/core/types.d.ts
8
5
  type WorkspaceContent = string | Uint8Array;
@@ -65,12 +62,29 @@ interface WorkspaceWriteInput {
65
62
  metadata?: Record<string, unknown>;
66
63
  previous?: WorkspaceStat;
67
64
  rule?: ResolvedWorkspaceRule;
65
+ /** The history commit that the write is part of. Undefined for writes to the working tree. */
66
+ commit?: WorkspaceWriteCommit;
67
+ }
68
+ /** What a hook knows of the history commit that a write is part of. It is read-only. */
69
+ interface WorkspaceWriteCommit {
70
+ readonly message?: string;
71
+ /**
72
+ * The revision metadata that the caller passed to `history.commit()`. A plugin can read the intent of the caller from
73
+ * it. For example, `vitehub push --override-lease` records `lease: "override"`.
74
+ */
75
+ readonly metadata: Readonly<Record<string, unknown>>;
76
+ /** Every path that the commit adds, changes, or deletes, in sorted order. A hook can check all of them and name every problem in one error. */
77
+ readonly paths: readonly string[];
68
78
  }
69
79
  type WorkspaceWriteValidatorResult = boolean | void | WorkspaceWriteInput;
70
80
  type WorkspaceWriteValidator = (input: WorkspaceWriteInput) => WorkspaceWriteValidatorResult | Promise<WorkspaceWriteValidatorResult>;
81
+ /**
82
+ * Limits writes to the paths that match the rule pattern. Every matching rule applies, from the least to the most
83
+ * specific. A more specific rule replaces a field only when it sets that field, and the validators of every matching
84
+ * rule run. Rules do not limit reads.
85
+ */
71
86
  interface WorkspaceRule {
72
87
  commit?: boolean | string;
73
- read?: boolean;
74
88
  write?: WorkspaceWriteMode;
75
89
  maxBytes?: number | `${number}kb` | `${number}mb`;
76
90
  mediaType?: string | string[];
@@ -98,8 +112,18 @@ interface WorkspacePlugin {
98
112
  rules?: WorkspaceRules;
99
113
  hooks?: WorkspaceHooks;
100
114
  }
115
+ /** The person that a snapshot or a history commit records as its author. */
116
+ interface WorkspaceAuthor {
117
+ name: string;
118
+ email: string;
119
+ }
101
120
  interface SnapshotOptions {
102
121
  name?: string;
122
+ /**
123
+ * Who made the change, such as the signed-in user. The GitHub and Cloudflare Artifacts Stores write it as the Git
124
+ * commit author. Stores with retained history keep it as `metadata.author` of the revision.
125
+ */
126
+ author?: WorkspaceAuthor;
103
127
  }
104
128
  interface DiffOptions {
105
129
  from?: WorkspaceSnapshot;
@@ -196,6 +220,8 @@ interface ExecResult {
196
220
  }
197
221
  interface WorkspaceSession {
198
222
  readonly executionAuthority: ExecutionAuthority;
223
+ /** Retained revision used to materialize this Session, when the Store provides one. */
224
+ readonly revision?: string;
199
225
  readFile<TOptions extends ReadFileOptions | undefined = undefined>(path: string, options?: TOptions): Promise<ReadFileResult<TOptions>>;
200
226
  writeFile(path: string, content: WorkspaceContent, options?: WorkspaceSessionWriteFileOptions): Promise<void>;
201
227
  mkdir(path: string, options?: MkdirOptions): Promise<void>;
@@ -286,8 +312,12 @@ interface WorkspaceRevision {
286
312
  createdAt: string;
287
313
  message?: string;
288
314
  metadata?: Record<string, unknown>;
289
- files: number;
290
- bytes: number;
315
+ /**
316
+ * How many files the revision has, and their total size. The GitHub Store leaves both out of `list()` and `head()`,
317
+ * because counting needs one more request per commit. `open(id)` reports them.
318
+ */
319
+ files?: number;
320
+ bytes?: number;
291
321
  }
292
322
  interface WorkspaceHistoryRefOptions {
293
323
  /** Named history line inside the Workspace. Defaults to `main`. */
@@ -361,6 +391,11 @@ interface WorkspaceRevisionView {
361
391
  list(path?: string, options?: ListOptions): Promise<WorkspaceEntry[]>;
362
392
  stat(path: string): Promise<WorkspaceStat>;
363
393
  readFile<TOptions extends ReadFileOptions | undefined = undefined>(path: string, options?: TOptions): Promise<ReadFileResult<TOptions>>;
394
+ /**
395
+ * Read many files of the revision at once, so that `readFile()` of each path needs no request. The GitHub Store reads
396
+ * them from one archive of the commit. Stores without it read each file on its own.
397
+ */
398
+ preload?(paths: readonly string[]): Promise<void>;
364
399
  }
365
400
  /** An open pull request on a forge, for a Store whose refs are branches. */
366
401
  interface WorkspacePullRequest {
@@ -622,8 +657,15 @@ interface WorkspaceSourceRequestExecutionResult {
622
657
  }
623
658
  type WorkspaceSourceRequestExecutor = (input: WorkspaceSourceRequestExecutionInput, context: SourceContext$1) => MaybePromise<WorkspaceSourceRequestExecutionResult>;
624
659
  interface WorkspaceSource {
660
+ /** `false` keeps the Skills in this Source out of a Provider Agent's skill roots. */
661
+ skills?: false;
625
662
  /** Stable provider name used for inspection and diagnostics. */
626
663
  name?: string;
664
+ /**
665
+ * The key of the one item of a file Source. Without a mount path, the Workspace places that item at this path.
666
+ * Other Sources mount under their binding key.
667
+ */
668
+ key?: string;
627
669
  mount?: WorkspaceSourceMount;
628
670
  materialize?: WorkspaceMaterializeMode;
629
671
  cache?: false | WorkspaceCacheOptions;
@@ -634,10 +676,20 @@ interface WorkspaceSource {
634
676
  resolve?: WorkspaceSourceResolver;
635
677
  resolveRevision?(ctx: SourceContext$1): Promise<SourceRevision | undefined>;
636
678
  prepare?(ctx: SourceContext$1): Promise<void>;
679
+ /**
680
+ * The build calls it for a `lazy` or `startup` Source, which the app reads after deploy. It throws when the Source
681
+ * cannot reach its data with the credentials of the build, so a revoked token fails the build and not the first read.
682
+ */
683
+ checkAccess?(ctx: SourceContext$1): Promise<void>;
637
684
  getKeys(ctx: SourceContext$1): Promise<string[]>;
638
685
  getItem(key: string, ctx: SourceContext$1): Promise<WorkspaceSourceItem>;
639
686
  getItems?(ctx: SourceContext$1): Promise<WorkspaceSourceItem[]>;
640
687
  getMeta?(key: string, ctx: SourceContext$1): Promise<Record<string, unknown> | undefined>;
688
+ /**
689
+ * Returns a Source that holds only the items that match `include`, inside the items this Source holds.
690
+ * GitHub Sources fetch only the matching paths.
691
+ */
692
+ subset?(include: readonly string[]): WorkspaceSource;
641
693
  }
642
694
  interface WorkspaceSourceSyncPolicy {
643
695
  concurrency?: "skip" | "queue";
@@ -648,6 +700,8 @@ type WorkspaceSourceDefinition = WorkspaceSource | Source;
648
700
  type WorkspaceSourceBindingOptions = Pick<WorkspaceSource, "cache" | "materialize" | "mount" | "probeKeys" | "sync" | "validate">;
649
701
  interface WorkspaceSourceBindingInput extends WorkspaceSourceBindingOptions {
650
702
  source: WorkspaceSourceInput;
703
+ /** `false` keeps the Skills in this Source out of a Provider Agent's skill roots. */
704
+ skills?: false;
651
705
  }
652
706
  type WorkspaceCustomSourceInput = WorkspaceSourceDefinition & WorkspaceSourceBindingOptions;
653
707
  type WorkspaceFileSourceInput<TKey extends string = string> = TKey | (FileSourceOptions<TKey> & WorkspaceSourceBindingOptions);
@@ -717,14 +771,14 @@ interface LocalWorkspaceStoreOptions {
717
771
  * write locks in memory. Use it only when one process owns the root.
718
772
  */
719
773
  locks?: "filesystem" | "process";
720
- provider?: "local";
774
+ driver?: "local";
721
775
  root?: string;
722
776
  }
723
777
  interface MemoryWorkspaceStoreOptions {
724
- provider: "memory";
778
+ driver: "memory";
725
779
  }
726
780
  interface CloudflareArtifactsWorkspaceStoreOptions {
727
- provider: "cloudflare-artifacts";
781
+ driver: "cloudflare";
728
782
  binding?: string;
729
783
  namespace?: string;
730
784
  repo?: string;
@@ -732,7 +786,7 @@ interface CloudflareArtifactsWorkspaceStoreOptions {
732
786
  branch?: string;
733
787
  }
734
788
  interface VercelBlobWorkspaceStoreOptions {
735
- provider: "vercel-blob";
789
+ driver: "vercel";
736
790
  token?: string;
737
791
  /**
738
792
  * A namespace under `_vitehub/workspaces/`. For example, `handbook`
@@ -751,7 +805,7 @@ interface GitHubWorkspaceRefs {
751
805
  draft?: string;
752
806
  }
753
807
  interface GitHubWorkspaceStoreOptions {
754
- provider: "github";
808
+ driver: "github";
755
809
  branch?: GitHubWorkspaceOption;
756
810
  /**
757
811
  * An opaque value that the store target carries for consumers that keep their own rows next to the Workspace, such as a
@@ -782,7 +836,7 @@ interface WorkspaceDefinition {
782
836
  type WorkspaceDefinitionInput = Omit<WorkspaceDefinition, "name"> & {
783
837
  name?: never;
784
838
  };
785
- interface WorkspaceModuleOptions {
839
+ interface WorkspaceOptions {
786
840
  root?: string;
787
841
  projectRoot?: string;
788
842
  assets?: boolean | string[];
@@ -908,4 +962,4 @@ interface WorkspaceMaterializeSourcesResult {
908
962
  sources: WorkspaceSourceMaterializationStatus[];
909
963
  }
910
964
  //#endregion
911
- export { WorkspaceHistoryFilesCommitOptions as $, WorkspaceSourceMount as $t, WorkspaceCacheOptions as A, WorkspaceWriteHook as An, WorkspaceRevision as At, WorkspaceFetchSourceInput as B, WorkspaceSessionHostFileEntry as Bt, SourceContextWorkspaceFiles as C, WorkspaceStoreOptions as Cn, WorkspaceNameMap as Ct, WorkspaceAssets as D, WorkspaceSyncSnapshotOptions as Dn, WorkspacePullRequest as Dt, WorkspaceAssetPath as E, WorkspaceSyncResultDetails as En, WorkspacePrepareSessionProgressEvent as Et, WorkspaceDefinition as F, WorkspaceWriteValidatorResult as Fn, WorkspaceSearchHit as Ft, WorkspaceGlobSourceInput as G, WorkspaceSource as Gt, WorkspaceFile as H, WorkspaceSessionOptions as Ht, WorkspaceDefinitionInput as I, WriteFileOptions as In, WorkspaceSearchQuery as It, WorkspaceHistoryCommitBase as J, WorkspaceSourceInput as Jt, WorkspaceHistoryChanges as K, WorkspaceSourceBindingInput as Kt, WorkspaceDiff as L, WorkspaceSelectedScope as Lt, WorkspaceContent as M, WorkspaceWriteMode as Mn, WorkspaceRule as Mt, WorkspaceContentStream as N, WorkspaceWriteOperation as Nn, WorkspaceRules as Nt, WorkspaceAssetsRegistry as O, WorkspaceValidateMode as On, WorkspaceRebaseOptions as Ot, WorkspaceCustomSourceInput as P, WorkspaceWriteValidator as Pn, WorkspaceScopeName as Pt, WorkspaceHistoryFileInput as Q, WorkspaceSourceMaterializationStatus as Qt, WorkspaceDiffEntry as R, WorkspaceSession as Rt, SourceContext$1 as S, WorkspaceStoreHistoryCommitOptions as Sn, WorkspaceName as St, Workspace as T, WorkspaceSyncOptions as Tn, WorkspacePlugin as Tt, WorkspaceFileSourceInput as U, WorkspaceSessionWriteFileOptions as Ut, WorkspaceFetchSourceRequestOptions as V, WorkspaceSessionHostFiles as Vt, WorkspaceGitHubSourceInput as W, WorkspaceSnapshot as Wt, WorkspaceHistoryExtensions as X, WorkspaceSourceMaterializationCounts as Xt, WorkspaceHistoryCommitOptions as Y, WorkspaceSourceItem as Yt, WorkspaceHistoryFile as Z, WorkspaceSourceMaterializationPathResult as Zt, ReadFileResult as _, WorkspaceSourceSyncResult as _n, WorkspaceMergeConflict as _t, GitHubWorkspaceOption as a, WorkspaceSourceRequestMethod as an, WorkspaceHookContext as at, RmOptions as b, WorkspaceStore as bn, WorkspaceMergeResolution as bt, GlobOptions as c, WorkspaceSourceResolutionContextValueReader as cn, WorkspaceInstructionBindingValue as ct, LocalWorkspaceStoreOptions as d, WorkspaceSourceResolver as dn, WorkspaceMaterializeMode as dt, WorkspaceSourceMountOptions as en, WorkspaceHistoryListOptions as et, Logger as f, WorkspaceSourceSelection as fn, WorkspaceMaterializeSourcesOptions as ft, ReadFileOptions as g, WorkspaceSourceSyncPolicy as gn, WorkspaceMergeCommit as gt, MkdirOptions as h, WorkspaceSourceSyncPathResult as hn, WorkspaceMcpResourcesSourceInput as ht, ExecResult as i, WorkspaceSourceRequestExecutor as in, WorkspaceHistoryRefOptions as it, WorkspaceCapabilities as j, WorkspaceWriteInput as jn, WorkspaceRevisionView as jt, WorkspaceAutoCommitPlan as k, WorkspaceWriteErrorHook as kn, WorkspaceRetainedHistory as kt, ListOptions as l, WorkspaceSourceResolutionInvocation as ln, WorkspaceLoader as lt, MemoryWorkspaceStoreOptions as m, WorkspaceSourceSyncCounts as mn, WorkspaceMaterializeSourcesResult as mt, DiffOptions as n, WorkspaceSourceRequestExecutionInput as nn, WorkspaceHistoryReader as nt, GitHubWorkspaceRefs as o, WorkspaceSourceResolutionContext as on, WorkspaceHooks as ot, MaybePromise as p, WorkspaceSourceSyncConfig as pn, WorkspaceMaterializeSourcesProgressEvent as pt, WorkspaceHistoryChangesCommitOptions as q, WorkspaceSourceDefinition as qt, ExecOptions as r, WorkspaceSourceRequestExecutionResult as rn, WorkspaceHistoryRef as rt, GitHubWorkspaceStoreOptions as s, WorkspaceSourceResolutionContextMap as sn, WorkspaceInstructionBinding as st, CloudflareArtifactsWorkspaceStoreOptions as t, WorkspaceSourceRequestDescriptor as tn, WorkspaceHistoryListResult as tt, LoaderContext as u, WorkspaceSourceResolutionResult as un, WorkspaceLoaderSource as ut, ResolvedWorkspaceModuleOptions as v, WorkspaceSourceSyncStatus as vn, WorkspaceMergeConflictContext as vt, VercelBlobWorkspaceStoreOptions as w, WorkspaceStreamFile as wn, WorkspaceOpenPullRequestOptions as wt, SnapshotOptions as x, WorkspaceStoreHistory as xn, WorkspaceModuleOptions as xt, ResolvedWorkspaceRule as y, WorkspaceStat as yn, WorkspaceMergeOptions as yt, WorkspaceEntry as z, WorkspaceSessionHost as zt };
965
+ export { WorkspaceHistoryFileInput as $, WorkspaceSourceMaterializationStatus as $t, WorkspaceAutoCommitPlan as A, WorkspaceWriteCommit as An, WorkspaceRetainedHistory as At, WorkspaceEntry as B, WorkspaceSessionHost as Bt, SourceContextWorkspaceFiles as C, WorkspaceStoreHistoryCommitOptions as Cn, WorkspaceNameMap as Ct, WorkspaceAssets as D, WorkspaceSyncResultDetails as Dn, WorkspacePrepareSessionProgressEvent as Dt, WorkspaceAssetPath as E, WorkspaceSyncOptions as En, WorkspacePlugin as Et, WorkspaceCustomSourceInput as F, WorkspaceWriteOperation as Fn, WorkspaceScopeName as Ft, WorkspaceGitHubSourceInput as G, WorkspaceSnapshot as Gt, WorkspaceFetchSourceRequestOptions as H, WorkspaceSessionHostFiles as Ht, WorkspaceDefinition as I, WorkspaceWriteValidator as In, WorkspaceSearchHit as It, WorkspaceHistoryChangesCommitOptions as J, WorkspaceSourceDefinition as Jt, WorkspaceGlobSourceInput as K, WorkspaceSource as Kt, WorkspaceDefinitionInput as L, WorkspaceWriteValidatorResult as Ln, WorkspaceSearchQuery as Lt, WorkspaceCapabilities as M, WorkspaceWriteHook as Mn, WorkspaceRevisionView as Mt, WorkspaceContent as N, WorkspaceWriteInput as Nn, WorkspaceRule as Nt, WorkspaceAssetsRegistry as O, WorkspaceSyncSnapshotOptions as On, WorkspacePullRequest as Ot, WorkspaceContentStream as P, WorkspaceWriteMode as Pn, WorkspaceRules as Pt, WorkspaceHistoryFile as Q, WorkspaceSourceMaterializationPathResult as Qt, WorkspaceDiff as R, WriteFileOptions as Rn, WorkspaceSelectedScope as Rt, SourceContext$1 as S, WorkspaceStoreHistory as Sn, WorkspaceName as St, Workspace as T, WorkspaceStreamFile as Tn, WorkspaceOptions as Tt, WorkspaceFile as U, WorkspaceSessionOptions as Ut, WorkspaceFetchSourceInput as V, WorkspaceSessionHostFileEntry as Vt, WorkspaceFileSourceInput as W, WorkspaceSessionWriteFileOptions as Wt, WorkspaceHistoryCommitOptions as X, WorkspaceSourceItem as Xt, WorkspaceHistoryCommitBase as Y, WorkspaceSourceInput as Yt, WorkspaceHistoryExtensions as Z, WorkspaceSourceMaterializationCounts as Zt, ReadFileResult as _, WorkspaceSourceSyncPolicy as _n, WorkspaceMergeCommit as _t, GitHubWorkspaceOption as a, WorkspaceSourceRequestExecutor as an, WorkspaceHistoryRefOptions as at, RmOptions as b, WorkspaceStat as bn, WorkspaceMergeOptions as bt, GlobOptions as c, WorkspaceSourceResolutionContextMap as cn, WorkspaceInstructionBinding as ct, LocalWorkspaceStoreOptions as d, WorkspaceSourceResolutionResult as dn, WorkspaceLoaderSource as dt, WorkspaceSourceMount as en, WorkspaceHistoryFilesCommitOptions as et, Logger as f, WorkspaceSourceResolver as fn, WorkspaceMaterializeMode as ft, ReadFileOptions as g, WorkspaceSourceSyncPathResult as gn, WorkspaceMcpResourcesSourceInput as gt, MkdirOptions as h, WorkspaceSourceSyncCounts as hn, WorkspaceMaterializeSourcesResult as ht, ExecResult as i, WorkspaceSourceRequestExecutionResult as in, WorkspaceHistoryRef as it, WorkspaceCacheOptions as j, WorkspaceWriteErrorHook as jn, WorkspaceRevision as jt, WorkspaceAuthor as k, WorkspaceValidateMode as kn, WorkspaceRebaseOptions as kt, ListOptions as l, WorkspaceSourceResolutionContextValueReader as ln, WorkspaceInstructionBindingValue as lt, MemoryWorkspaceStoreOptions as m, WorkspaceSourceSyncConfig as mn, WorkspaceMaterializeSourcesProgressEvent as mt, DiffOptions as n, WorkspaceSourceRequestDescriptor as nn, WorkspaceHistoryListResult as nt, GitHubWorkspaceRefs as o, WorkspaceSourceRequestMethod as on, WorkspaceHookContext as ot, MaybePromise as p, WorkspaceSourceSelection as pn, WorkspaceMaterializeSourcesOptions as pt, WorkspaceHistoryChanges as q, WorkspaceSourceBindingInput as qt, ExecOptions as r, WorkspaceSourceRequestExecutionInput as rn, WorkspaceHistoryReader as rt, GitHubWorkspaceStoreOptions as s, WorkspaceSourceResolutionContext as sn, WorkspaceHooks as st, CloudflareArtifactsWorkspaceStoreOptions as t, WorkspaceSourceMountOptions as tn, WorkspaceHistoryListOptions as tt, LoaderContext as u, WorkspaceSourceResolutionInvocation as un, WorkspaceLoader as ut, ResolvedWorkspaceModuleOptions as v, WorkspaceSourceSyncResult as vn, WorkspaceMergeConflict as vt, VercelBlobWorkspaceStoreOptions as w, WorkspaceStoreOptions as wn, WorkspaceOpenPullRequestOptions as wt, SnapshotOptions as x, WorkspaceStore as xn, WorkspaceMergeResolution as xt, ResolvedWorkspaceRule as y, WorkspaceSourceSyncStatus as yn, WorkspaceMergeConflictContext as yt, WorkspaceDiffEntry as z, WorkspaceSession as zt };
@@ -0,0 +1,321 @@
1
+ import { At as WorkspaceRetainedHistory, B as WorkspaceEntry, D as WorkspaceAssets, E as WorkspaceAssetPath, En as WorkspaceSyncOptions, Gt as WorkspaceSnapshot, I as WorkspaceDefinition, It as WorkspaceSearchHit, Lt as WorkspaceSearchQuery, M as WorkspaceCapabilities, Mt as WorkspaceRevisionView, N as WorkspaceContent, R as WorkspaceDiff, Rn as WriteFileOptions, St as WorkspaceName, T as Workspace, Ut as WorkspaceSessionOptions, _ as ReadFileResult, at as WorkspaceHistoryRefOptions, b as RmOptions, bn as WorkspaceStat, c as GlobOptions, g as ReadFileOptions, h as MkdirOptions, ht as WorkspaceMaterializeSourcesResult, it as WorkspaceHistoryRef, jt as WorkspaceRevision, k as WorkspaceAuthor, kt as WorkspaceRebaseOptions, l as ListOptions, n as DiffOptions, nt as WorkspaceHistoryListResult, pt as WorkspaceMaterializeSourcesOptions, rt as WorkspaceHistoryReader, tt as WorkspaceHistoryListOptions, vn as WorkspaceSourceSyncResult, x as SnapshotOptions, zt as WorkspaceSession } from "./types-BbtwmBZ5.js";
2
+ import { ExecutionBudget } from "@vite-hub/runtime";
3
+ import { Tool, ToolSet } from "ai";
4
+ //#region src/ai.d.ts
5
+ type ShellObservationEvent = "command_finished" | "command_timed_out" | "policy_denied" | "session_disposed";
6
+ interface ShellRuntimeExecOptions {
7
+ budget?: ExecutionBudget;
8
+ cwd?: string;
9
+ env?: Record<string, string>;
10
+ maxOutputLength?: number;
11
+ onStderr?: (chunk: string) => void;
12
+ onStdout?: (chunk: string) => void;
13
+ signal?: AbortSignal;
14
+ stdin?: string;
15
+ timeout?: number;
16
+ workspacePaths?: string[];
17
+ }
18
+ interface ShellObservation {
19
+ command?: string;
20
+ cwd?: string;
21
+ durationMs?: number;
22
+ event: ShellObservationEvent;
23
+ exitCode: number | null;
24
+ maxOutputLength?: number;
25
+ outputTruncated?: boolean;
26
+ stderr: string;
27
+ stdout: string;
28
+ timedOut?: boolean;
29
+ workspaceGuardrail?: {
30
+ kind: "broad_search" | "missing_path" | "no_match" | "timeout";
31
+ path?: string;
32
+ };
33
+ }
34
+ interface ShellAnalyzeOptions {
35
+ maxInputBytes?: number;
36
+ timeoutMs?: number;
37
+ }
38
+ interface ShellAnalyzeResult {
39
+ commands?: string[];
40
+ error?: string;
41
+ hasCommandSubstitution?: boolean;
42
+ hasHeredocs?: boolean;
43
+ hasPipelines?: boolean;
44
+ hasRedirects?: boolean;
45
+ ok: boolean;
46
+ parser: "sh-syntax";
47
+ }
48
+ interface ShellProcess {
49
+ id: string;
50
+ command: string;
51
+ cwd?: string;
52
+ stop(): Promise<ShellObservation>;
53
+ }
54
+ interface ShellBoundary {
55
+ cwd: boolean;
56
+ env: boolean;
57
+ filesystem: {
58
+ mountPoint?: string;
59
+ writable: boolean;
60
+ };
61
+ network: boolean | "unknown";
62
+ processes: {
63
+ background: boolean;
64
+ interactive: boolean;
65
+ };
66
+ streaming: boolean;
67
+ timeout: {
68
+ enforcedBy: "provider" | "runtime" | "unsupported";
69
+ supported: boolean;
70
+ };
71
+ execution?: {
72
+ isolation: "in_process" | "process" | "provider_managed" | "unknown";
73
+ model: "virtual" | "host" | "unknown";
74
+ };
75
+ resources?: {
76
+ output: {
77
+ enforcedBy: "provider" | "runtime" | "unsupported";
78
+ unit: "characters";
79
+ };
80
+ };
81
+ }
82
+ interface ShellDriver {
83
+ analyze?: (command: string, options?: ShellAnalyzeOptions) => Promise<ShellAnalyzeResult>;
84
+ boundary: ShellBoundary;
85
+ exec(command: string, options?: ShellRuntimeExecOptions): Promise<ShellObservation>;
86
+ startProcess?: (command: string, options?: ShellRuntimeExecOptions) => Promise<ShellProcess>;
87
+ }
88
+ interface ShellSessionPolicy {
89
+ maxOutputLength?: number;
90
+ maxShellCalls?: number;
91
+ timeout?: number;
92
+ }
93
+ type WorkspaceShellResult = ShellObservation;
94
+ interface WorkspacePathResult {
95
+ path: string;
96
+ }
97
+ interface WorkspaceMoveResult {
98
+ from: string;
99
+ to: string;
100
+ }
101
+ interface WorkspaceReadOperations {
102
+ list?: boolean;
103
+ materialize?: boolean;
104
+ read?: boolean;
105
+ search?: boolean;
106
+ }
107
+ interface WorkspaceWriteOperations {
108
+ appendFile?: boolean;
109
+ copyPath?: boolean;
110
+ deletePath?: boolean;
111
+ makeDir?: boolean;
112
+ movePath?: boolean;
113
+ writeFile?: boolean;
114
+ }
115
+ type WorkspaceToolOperations = WorkspaceReadOperations & {
116
+ write?: true | WorkspaceWriteOperations;
117
+ };
118
+ interface WorkspaceToolOptions<Operations extends WorkspaceToolOperations | undefined = undefined, SourceRequests extends boolean = boolean> extends Pick<ShellSessionPolicy, "maxOutputLength" | "maxShellCalls" | "timeout"> {
119
+ broadSearchPaths?: string[];
120
+ cwd?: string;
121
+ executionBudget?: ExecutionBudget;
122
+ shellDriver?: ShellDriver | (() => MaybePromise<ShellDriver | undefined>);
123
+ operations?: Operations;
124
+ sourceRequests?: SourceRequests;
125
+ }
126
+ type EnabledReadCapability<Operations, Key extends keyof WorkspaceReadOperations> = Operations extends Record<Key, infer Value> ? Value extends false ? false : true : true;
127
+ type ShellEnabled<Operations, SourceRequests extends boolean = false> = true extends SourceRequests | EnabledReadCapability<Operations, "list"> | EnabledReadCapability<Operations, "read"> | EnabledReadCapability<Operations, "search"> ? true : false;
128
+ type ResolvedWriteOperations<Operations> = Operations extends {
129
+ write: infer Write;
130
+ } ? Write : false;
131
+ type WorkspaceWriteToolMap = {
132
+ appendFile: Tool<{
133
+ content: string;
134
+ path: string;
135
+ }, WorkspacePathResult>;
136
+ copyPath: Tool<{
137
+ from: string;
138
+ overwrite?: boolean;
139
+ to: string;
140
+ }, WorkspaceMoveResult>;
141
+ deletePath: Tool<{
142
+ force?: boolean;
143
+ path: string;
144
+ recursive?: boolean;
145
+ }, WorkspacePathResult>;
146
+ makeDir: Tool<{
147
+ path: string;
148
+ recursive?: boolean;
149
+ }, WorkspacePathResult>;
150
+ movePath: Tool<{
151
+ from: string;
152
+ overwrite?: boolean;
153
+ to: string;
154
+ }, WorkspaceMoveResult>;
155
+ writeFile: Tool<{
156
+ content: string;
157
+ mediaType?: string;
158
+ path: string;
159
+ }, WorkspacePathResult>;
160
+ };
161
+ type EnabledWriteTools<Selection> = Selection extends true ? WorkspaceWriteToolMap : Selection extends WorkspaceWriteOperations ? { [Key in keyof WorkspaceWriteToolMap as Key extends keyof Selection ? Selection[Key] extends true ? Key : never : never]: WorkspaceWriteToolMap[Key]; } : {};
162
+ type WorkspaceTools<Operations = undefined, SourceRequests extends boolean = false> = ((ShellEnabled<Operations, SourceRequests> extends true ? {
163
+ shell: Tool<{
164
+ command: string;
165
+ }, WorkspaceShellResult>;
166
+ } : {}) & EnabledWriteTools<ResolvedWriteOperations<Operations>> & (Operations extends {
167
+ materialize: true;
168
+ } ? {
169
+ materialize_sources: Tool<{
170
+ path?: string;
171
+ sources?: string[];
172
+ }, WorkspaceMaterializeSourcesResult>;
173
+ } : {})) & ToolSet;
174
+ type MaybePromise<T> = T | Promise<T>;
175
+ declare function createWorkspaceTools<Operations extends WorkspaceToolOperations | undefined = undefined, SourceRequests extends boolean = false>(input: Workspace | WorkspaceAssets, options?: WorkspaceToolOptions<Operations, SourceRequests>): WorkspaceTools<Operations, SourceRequests>;
176
+ //#endregion
177
+ //#region src/storage/target.d.ts
178
+ declare const workspaceStoreTarget: unique symbol;
179
+ interface WorkspaceStoreTarget {
180
+ provider: string;
181
+ containsPath?(ancestor: string, path: string): Promise<boolean>;
182
+ }
183
+ type WorkspaceStoreTargetCarrier = {
184
+ [workspaceStoreTarget]?: () => Promise<WorkspaceStoreTarget | undefined> | WorkspaceStoreTarget | undefined;
185
+ };
186
+ declare function resolveWorkspaceStoreTarget(source: unknown): Promise<WorkspaceStoreTarget | undefined>;
187
+ //#endregion
188
+ //#region src/core/use.d.ts
189
+ type WorkspaceWritablePath<Name extends WorkspaceName> = WorkspaceAssetPath<Name> | (string & {});
190
+ interface UseWorkspaceOptions {
191
+ definition?: WorkspaceDefinition;
192
+ mode?: "read" | "write";
193
+ refresh?: boolean;
194
+ }
195
+ interface WorkspaceFacadeToolOptions extends WorkspaceReadOperations {
196
+ broadSearchPaths?: string[];
197
+ cwd?: string;
198
+ executionBudget?: ExecutionBudget;
199
+ maxShellCalls?: number;
200
+ maxOutputLength?: number;
201
+ sourceRequests?: boolean;
202
+ timeout?: number;
203
+ }
204
+ interface WritableWorkspaceFacadeToolOptions extends WorkspaceFacadeToolOptions, WorkspaceWriteOperations {}
205
+ type EnabledWriteCapability<Options, Key extends keyof WorkspaceWriteOperations> = Options extends Record<Key, infer Value> ? Value extends false ? false : true : true;
206
+ type WorkspaceReadTools<Options = undefined> = ((ShellEnabled<Options, Options extends {
207
+ sourceRequests: true;
208
+ } ? true : false> extends true ? {
209
+ shell: Tool<{
210
+ command: string;
211
+ }, WorkspaceShellResult>;
212
+ } : {}) & (Options extends {
213
+ materialize: true;
214
+ } ? {
215
+ materialize_sources: Tool<{
216
+ path?: string;
217
+ sources?: string[];
218
+ }, WorkspaceMaterializeSourcesResult>;
219
+ } : {}) & ToolSet);
220
+ type WorkspaceWriteTools<Options = undefined> = WorkspaceReadTools<Options> & { [Key in keyof WorkspaceWriteToolMap as EnabledWriteCapability<Options, Key> extends true ? Key : never]: WorkspaceWriteToolMap[Key]; } & ToolSet;
221
+ type WorkspaceReadToolSet = WorkspaceReadTools & {
222
+ inspect: <Options extends WorkspaceFacadeToolOptions | undefined = undefined>(options?: Options) => WorkspaceReadTools<Options>;
223
+ none: () => ToolSet;
224
+ };
225
+ type WorkspaceWriteToolSet = WorkspaceWriteTools & {
226
+ inspect: <Options extends WorkspaceFacadeToolOptions | undefined = undefined>(options?: Options) => WorkspaceReadTools<Options>;
227
+ none: () => ToolSet;
228
+ write: <Options extends WritableWorkspaceFacadeToolOptions | undefined = undefined>(options?: Options) => WorkspaceWriteTools<Options>;
229
+ };
230
+ type ReadonlyWorkspaceFs<Name extends WorkspaceName = WorkspaceName> = WorkspaceAssets<WorkspaceAssetPath<Name>>;
231
+ interface HistoryCheckpoint {
232
+ createdAt: string;
233
+ id: string;
234
+ name?: string;
235
+ }
236
+ interface HistoryCheckpointOptions {
237
+ message?: string;
238
+ /** Who made the change. See `SnapshotOptions.author`. */
239
+ author?: WorkspaceAuthor;
240
+ }
241
+ interface History<TCheckpoint extends HistoryCheckpoint = HistoryCheckpoint> {
242
+ checkpoint(options?: HistoryCheckpointOptions): Promise<TCheckpoint>;
243
+ }
244
+ interface WritableWorkspaceFs<Name extends WorkspaceName = WorkspaceName> {
245
+ readFile<TOptions extends ReadFileOptions | undefined = undefined>(path: WorkspaceWritablePath<Name>, options?: TOptions): Promise<ReadFileResult<TOptions>>;
246
+ writeFile(path: WorkspaceWritablePath<Name>, content: WorkspaceContent, options?: WriteFileOptions): Promise<string>;
247
+ appendFile(path: WorkspaceWritablePath<Name>, content: string): Promise<void>;
248
+ stat(path: WorkspaceWritablePath<Name>): Promise<WorkspaceStat>;
249
+ exists(path: WorkspaceWritablePath<Name>): Promise<boolean>;
250
+ list(path?: WorkspaceWritablePath<Name> | "", options?: ListOptions): Promise<WorkspaceEntry[]>;
251
+ glob(pattern: WorkspaceWritablePath<Name> | Array<WorkspaceWritablePath<Name>>, options?: GlobOptions): Promise<WorkspaceEntry[]>;
252
+ search(query: WorkspaceSearchQuery): Promise<WorkspaceSearchHit[]>;
253
+ mkdir(path: WorkspaceWritablePath<Name>, options?: MkdirOptions): Promise<void>;
254
+ rm(path: WorkspaceWritablePath<Name>, options?: RmOptions): Promise<void>;
255
+ movePath(from: WorkspaceWritablePath<Name>, to: WorkspaceWritablePath<Name>, options?: {
256
+ overwrite?: boolean;
257
+ }): Promise<void>;
258
+ copyPath(from: WorkspaceWritablePath<Name>, to: WorkspaceWritablePath<Name>, options?: {
259
+ overwrite?: boolean;
260
+ }): Promise<void>;
261
+ }
262
+ interface ReadonlyWorkspaceFiles<Name extends WorkspaceName = WorkspaceName> {
263
+ fs: ReadonlyWorkspaceFs<Name>;
264
+ history: WorkspaceHistoryReader;
265
+ getMeta?(key: string): Promise<unknown>;
266
+ }
267
+ interface ReadonlyWorkspaceFacade<Name extends WorkspaceName = WorkspaceName> extends ReadonlyWorkspaceFiles<Name> {
268
+ tools: WorkspaceReadToolSet;
269
+ }
270
+ interface WorkspaceHistory extends History<WorkspaceSnapshot>, WorkspaceRetainedHistory {
271
+ rebase(options?: WorkspaceRebaseOptions): Promise<void>;
272
+ }
273
+ interface WritableWorkspaceFiles<Name extends WorkspaceName = WorkspaceName> {
274
+ capabilities(): Promise<WorkspaceCapabilities>;
275
+ diff(options?: DiffOptions): Promise<WorkspaceDiff>;
276
+ fs: WritableWorkspaceFs<Name>;
277
+ history: WorkspaceHistory;
278
+ getMeta?(key: string): Promise<unknown>;
279
+ materializeSources(options?: WorkspaceMaterializeSourcesOptions): Promise<WorkspaceMaterializeSourcesResult>;
280
+ setMeta?(key: string, value: unknown, capability?: symbol): Promise<void>;
281
+ snapshot(options?: SnapshotOptions): Promise<WorkspaceSnapshot>;
282
+ startSession(options?: WorkspaceSessionOptions): Promise<WorkspaceSession>;
283
+ sync(options: WorkspaceSyncOptions): Promise<WorkspaceSourceSyncResult>;
284
+ }
285
+ interface WritableWorkspaceFacade<Name extends WorkspaceName = WorkspaceName> extends WritableWorkspaceFiles<Name> {
286
+ tools: WorkspaceWriteToolSet;
287
+ }
288
+ type WorkspaceFacade<Name extends WorkspaceName = WorkspaceName, Mode extends UseWorkspaceOptions["mode"] = "read"> = Mode extends "write" ? WritableWorkspaceFacade<Name> : ReadonlyWorkspaceFacade<Name>;
289
+ declare function createReadonlyFs<Name extends WorkspaceName>(name: Name, workspace: Workspace): ReadonlyWorkspaceFs<Name>;
290
+ declare function createWorkspaceFileRuntime<Name extends WorkspaceName>(name: Name, options?: UseWorkspaceOptions): {
291
+ mode: "write";
292
+ workspace: Workspace;
293
+ facade: WritableWorkspaceFiles<Name> & WorkspaceStoreTargetCarrier;
294
+ } | {
295
+ mode: "read";
296
+ workspace: Workspace;
297
+ facade: {
298
+ fs: ReadonlyWorkspaceFs<Name>;
299
+ history: {
300
+ head: (options?: WorkspaceHistoryRefOptions) => Promise<WorkspaceRevision | null>;
301
+ list: (options?: WorkspaceHistoryListOptions) => Promise<WorkspaceHistoryListResult>;
302
+ refs: () => Promise<WorkspaceHistoryRef[]>;
303
+ open: (id: string) => Promise<WorkspaceRevisionView>;
304
+ usage: () => Promise<{
305
+ bytes: number;
306
+ objects: number;
307
+ }>;
308
+ };
309
+ getMeta: (key: string) => Promise<unknown>;
310
+ };
311
+ };
312
+ /** File and history access without constructing Agent tools or bundling a shell. */
313
+ declare function useWorkspaceFiles<Name extends WorkspaceName>(name: Name): ReadonlyWorkspaceFiles<Name>;
314
+ declare function useWorkspaceFiles<Name extends WorkspaceName>(name: Name, options: UseWorkspaceOptions & {
315
+ mode?: "read";
316
+ }): ReadonlyWorkspaceFiles<Name>;
317
+ declare function useWorkspaceFiles<Name extends WorkspaceName>(name: Name, options: UseWorkspaceOptions & {
318
+ mode: "write";
319
+ }): WritableWorkspaceFiles<Name>;
320
+ //#endregion
321
+ export { WorkspaceToolOperations as A, resolveWorkspaceStoreTarget as C, WorkspacePathResult as D, WorkspaceMoveResult as E, createWorkspaceTools as F, WorkspaceTools as M, WorkspaceWriteOperations as N, WorkspaceReadOperations as O, WorkspaceWriteToolMap as P, WorkspaceStoreTarget as S, ShellEnabled as T, WritableWorkspaceFiles as _, ReadonlyWorkspaceFiles as a, createWorkspaceFileRuntime as b, WorkspaceFacade as c, WorkspaceReadToolSet as d, WorkspaceReadTools as f, WritableWorkspaceFacadeToolOptions as g, WritableWorkspaceFacade as h, ReadonlyWorkspaceFacade as i, WorkspaceToolOptions as j, WorkspaceShellResult as k, WorkspaceFacadeToolOptions as l, WorkspaceWriteTools as m, HistoryCheckpoint as n, ReadonlyWorkspaceFs as o, WorkspaceWriteToolSet as p, HistoryCheckpointOptions as r, UseWorkspaceOptions as s, History as t, WorkspaceHistory as u, WritableWorkspaceFs as v, EnabledReadCapability as w, useWorkspaceFiles as x, createReadonlyFs as y };