@vite-hub/workspace 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +190 -17
  2. package/dist/{ai-Bk3LLnit.js → ai-Cztw4eLk.js} +149 -29
  3. package/dist/ai-hFdsvDHC.d.ts +162 -0
  4. package/dist/ai.d.ts +2 -85
  5. package/dist/ai.js +1 -1
  6. package/dist/artifacts-store-BAV9jZpd.js +555 -0
  7. package/dist/asset-registry-CaG9b7tf.js +19 -0
  8. package/dist/cli.d.ts +31 -0
  9. package/dist/cli.js +303 -0
  10. package/dist/cloudflare-env-CKxUs2fa.js +20 -0
  11. package/dist/cloudflare.d.ts +16 -0
  12. package/dist/cloudflare.js +3 -0
  13. package/dist/collections/client.d.ts +39 -0
  14. package/dist/collections/client.js +137 -0
  15. package/dist/collections.d.ts +59 -0
  16. package/dist/collections.js +159 -0
  17. package/dist/config--r5unwPc.js +7811 -0
  18. package/dist/config-Ca5DM8fF.d.ts +28 -0
  19. package/dist/config-DCQ6y30R.js +30 -0
  20. package/dist/file-B2q9NE18.js +24 -0
  21. package/dist/{files-DbsIjBya.js → files-xy0le-_U.js} +6 -5
  22. package/dist/github-lIO6-2sH.js +194 -0
  23. package/dist/glob-DeH0dzZX.js +23 -0
  24. package/dist/host-I-_vDs05.js +370 -0
  25. package/dist/hosted-vercel-blob.d.ts +15 -0
  26. package/dist/hosted-vercel-blob.js +26 -0
  27. package/dist/hosted.d.ts +18 -0
  28. package/dist/hosted.js +30 -0
  29. package/dist/index.d.ts +137 -102
  30. package/dist/index.js +479 -594
  31. package/dist/lifecycle-Lhk3dAMt.js +176 -0
  32. package/dist/loader.d.ts +1 -1
  33. package/dist/loader.js +1 -1
  34. package/dist/nitro.d.ts +2 -31
  35. package/dist/nitro.js +2 -2
  36. package/dist/nuxt.d.ts +26 -0
  37. package/dist/nuxt.js +36 -0
  38. package/dist/path-CNI6wKIU.js +115 -0
  39. package/dist/{provider-BZuKAV4e.js → provider-CeQciesl.js} +142 -37
  40. package/dist/providers/cloudflare/artifacts-store.d.ts +1 -1
  41. package/dist/providers/cloudflare/artifacts-store.js +1 -383
  42. package/dist/providers/github/store.d.ts +6 -0
  43. package/dist/providers/github/store.js +362 -0
  44. package/dist/providers/vercel/blob-store.d.ts +1 -1
  45. package/dist/providers/vercel/blob-store.js +77 -18
  46. package/dist/publish.d.ts +3 -2
  47. package/dist/publish.js +48 -142
  48. package/dist/registry-C7DMdBXN.js +74 -0
  49. package/dist/{registry-D4Qzq26I.d.ts → registry-CoC9JxVt.d.ts} +3 -2
  50. package/dist/request-execution-C8qRcReq.js +80 -0
  51. package/dist/runtime/assets.d.ts +2 -1
  52. package/dist/runtime/assets.js +5 -5
  53. package/dist/runtime/empty-assets-registry.d.ts +1 -1
  54. package/dist/runtime/empty-registry.d.ts +1 -1
  55. package/dist/runtime/state.d.ts +4 -21
  56. package/dist/runtime/state.js +7 -4
  57. package/dist/runtime/workspace.d.ts +2 -0
  58. package/dist/runtime/workspace.js +2 -0
  59. package/dist/runtime.d.ts +38 -0
  60. package/dist/runtime.js +643 -0
  61. package/dist/{search-DtaEyjpO.js → search-C4REyHj9.js} +2 -2
  62. package/dist/server.d.ts +65 -0
  63. package/dist/server.js +355 -0
  64. package/dist/shared-BRycRSbo.js +255 -0
  65. package/dist/source-metadata.d.ts +2 -0
  66. package/dist/source-metadata.js +2 -0
  67. package/dist/state-DSAHEsq6.d.ts +25 -0
  68. package/dist/sync-DO42ypji.js +269 -0
  69. package/dist/target-D4Bqb1eH.js +11 -0
  70. package/dist/test.d.ts +1 -1
  71. package/dist/test.js +1 -1
  72. package/dist/types-DHkae7Cb.d.ts +628 -0
  73. package/dist/use-D16tf8Ph.d.ts +86 -0
  74. package/dist/use-d_PlAdOu.js +353 -0
  75. package/dist/{utils-BtAm_K5P.js → utils-BPdaCyI6.js} +7 -3
  76. package/dist/vite-NWC9mFjI.js +1882 -0
  77. package/dist/vite.d.ts +33 -5
  78. package/dist/vite.js +2 -131
  79. package/dist/workspace-f2DBLmPZ.d.ts +6 -0
  80. package/dist/workspace-n4wBmdaM.js +1476 -0
  81. package/package.json +158 -62
  82. package/dist/asset-registry-CMuQbyvl.js +0 -14
  83. package/dist/cloudflare-env-DL94Uvpz.js +0 -12
  84. package/dist/config-CvS-7sre.js +0 -49
  85. package/dist/errors-BUL8SoFS.js +0 -21
  86. package/dist/lifecycle-uD82JeGh.js +0 -92
  87. package/dist/module-8LZUMEXC.js +0 -922
  88. package/dist/path-BVv9OXhg.js +0 -63
  89. package/dist/registry-Cnr0NoKv.js +0 -932
  90. package/dist/runtime/nitro-plugin.d.ts +0 -6
  91. package/dist/runtime/nitro-plugin.js +0 -14
  92. package/dist/sandbox-DtGXCWRq.js +0 -198
  93. package/dist/types-CwNcWTdt.d.ts +0 -378
  94. /package/dist/{chunk-DrSxFLj_.js → chunk-8H4AJuhK.js} +0 -0
@@ -0,0 +1,628 @@
1
+ import { ExecutionAuthority } from "@vite-hub/runtime";
2
+ import { FileSourceOptions, GitHubSourceOptions, GlobSourceOptions, McpResourcesSourceOptions, Source } from "@vite-hub/source";
3
+
4
+ //#region src/core/types.d.ts
5
+ type WorkspaceContent = string | Uint8Array;
6
+ type WorkspaceContentStream = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>;
7
+ interface ReadFileOptions {
8
+ encoding?: "utf8" | "binary";
9
+ }
10
+ type ReadFileResult<TOptions extends ReadFileOptions | undefined = undefined> = TOptions extends {
11
+ encoding: "binary";
12
+ } ? Uint8Array : string;
13
+ interface WriteFileOptions {
14
+ mediaType?: string;
15
+ metadata?: Record<string, unknown>;
16
+ }
17
+ interface ListOptions {
18
+ recursive?: boolean;
19
+ }
20
+ interface GlobOptions {
21
+ cwd?: string;
22
+ }
23
+ interface WorkspaceSearchQuery {
24
+ pattern: string;
25
+ cwd?: string;
26
+ paths?: string[];
27
+ regex?: boolean;
28
+ caseSensitive?: boolean;
29
+ limit?: number;
30
+ }
31
+ interface WorkspaceSearchHit {
32
+ path: string;
33
+ line: number;
34
+ column: number;
35
+ text: string;
36
+ }
37
+ interface MkdirOptions {
38
+ recursive?: boolean;
39
+ }
40
+ interface RmOptions {
41
+ recursive?: boolean;
42
+ force?: boolean;
43
+ }
44
+ type WorkspaceWriteOperation = "writeFile" | "mkdir" | "rm";
45
+ type WorkspaceWriteMode = boolean | "create" | "update" | "delete";
46
+ interface WorkspaceWriteInput {
47
+ workspace: string;
48
+ operation: WorkspaceWriteOperation;
49
+ path: string;
50
+ content?: WorkspaceContent;
51
+ mediaType?: string;
52
+ metadata?: Record<string, unknown>;
53
+ previous?: WorkspaceStat;
54
+ rule?: ResolvedWorkspaceRule;
55
+ }
56
+ type WorkspaceWriteValidatorResult = boolean | void | WorkspaceWriteInput;
57
+ type WorkspaceWriteValidator = (input: WorkspaceWriteInput) => WorkspaceWriteValidatorResult | Promise<WorkspaceWriteValidatorResult>;
58
+ interface WorkspaceRule {
59
+ commit?: boolean | string;
60
+ read?: boolean;
61
+ write?: WorkspaceWriteMode;
62
+ maxBytes?: number | `${number}kb` | `${number}mb`;
63
+ mediaType?: string | string[];
64
+ validate?: WorkspaceWriteValidator | WorkspaceWriteValidator[];
65
+ }
66
+ type WorkspaceRules = Record<string, WorkspaceRule>;
67
+ interface ResolvedWorkspaceRule extends Omit<WorkspaceRule, "maxBytes" | "validate"> {
68
+ maxBytes?: number;
69
+ pattern: string;
70
+ validate: WorkspaceWriteValidator[];
71
+ }
72
+ interface WorkspaceHookContext extends WorkspaceWriteInput {}
73
+ interface WorkspaceHooks {
74
+ "write:before"?: WorkspaceWriteHook | WorkspaceWriteHook[];
75
+ "write:validate"?: WorkspaceWriteHook | WorkspaceWriteHook[];
76
+ "write:after"?: WorkspaceWriteHook | WorkspaceWriteHook[];
77
+ "write:error"?: WorkspaceWriteErrorHook | WorkspaceWriteErrorHook[];
78
+ }
79
+ type WorkspaceWriteHook = (ctx: WorkspaceHookContext) => void | Promise<void>;
80
+ type WorkspaceWriteErrorHook = (ctx: WorkspaceHookContext & {
81
+ error: unknown;
82
+ }) => void | Promise<void>;
83
+ interface WorkspacePlugin {
84
+ id: string;
85
+ rules?: WorkspaceRules;
86
+ hooks?: WorkspaceHooks;
87
+ }
88
+ interface SnapshotOptions {
89
+ name?: string;
90
+ }
91
+ interface WorkspacePublishOptions {
92
+ name?: string;
93
+ }
94
+ interface DiffOptions {
95
+ from?: WorkspaceSnapshot;
96
+ }
97
+ type WorkspaceSourceSelection = "all" | readonly string[];
98
+ type WorkspaceSyncResultDetails = "counts" | "paths";
99
+ interface WorkspaceSyncSnapshotOptions extends SnapshotOptions {
100
+ message?: string;
101
+ }
102
+ interface WorkspaceSyncOptions {
103
+ details?: WorkspaceSyncResultDetails;
104
+ publish?: boolean;
105
+ publishPartial?: boolean;
106
+ snapshot?: boolean | WorkspaceSyncSnapshotOptions;
107
+ sources: WorkspaceSourceSelection;
108
+ }
109
+ interface WorkspaceSessionOptions {
110
+ attach?: boolean;
111
+ host?: WorkspaceSessionHost;
112
+ paths?: readonly string[];
113
+ target?: string;
114
+ }
115
+ interface WorkspaceSessionHostFileEntry {
116
+ path: string;
117
+ size?: number;
118
+ type: "directory" | "file" | "symlink";
119
+ }
120
+ interface WorkspaceSessionHostFiles {
121
+ exists(path: string): Promise<boolean>;
122
+ list(path: string, options?: {
123
+ recursive?: boolean;
124
+ }): Promise<readonly WorkspaceSessionHostFileEntry[]>;
125
+ mkdir(path: string, options?: {
126
+ recursive?: boolean;
127
+ }): Promise<void>;
128
+ read(path: string): Promise<Uint8Array | null>;
129
+ remove(path: string, options?: {
130
+ recursive?: boolean;
131
+ }): Promise<void>;
132
+ write(path: string, content: Uint8Array): Promise<void>;
133
+ }
134
+ interface WorkspaceSessionHost {
135
+ readonly executionAuthority: ExecutionAuthority;
136
+ files: WorkspaceSessionHostFiles;
137
+ exec(command: string, args?: readonly string[], options?: {
138
+ cwd?: string;
139
+ env?: Readonly<Record<string, string>>;
140
+ signal?: AbortSignal;
141
+ timeout?: number;
142
+ }): Promise<{
143
+ code: number;
144
+ stderr: string;
145
+ stdout: string;
146
+ }>;
147
+ }
148
+ type WorkspaceMountMode = "read-only" | "read-write" | "copy-on-write";
149
+ interface WorkspaceMountOptions {
150
+ mode: WorkspaceMountMode;
151
+ target?: string;
152
+ }
153
+ interface WorkspaceMount {
154
+ workspace: Workspace;
155
+ mode: WorkspaceMountMode;
156
+ target: string;
157
+ diff(): Promise<WorkspaceDiff>;
158
+ commit(options?: {
159
+ message?: string;
160
+ }): Promise<void>;
161
+ export(): Promise<WorkspaceSnapshot>;
162
+ }
163
+ interface ExecOptions {
164
+ abortSignal?: AbortSignal;
165
+ cwd?: string;
166
+ env?: Record<string, string>;
167
+ timeout?: number;
168
+ }
169
+ interface ExecResult {
170
+ command: string;
171
+ args: string[];
172
+ exitCode: number;
173
+ stdout: string;
174
+ stderr: string;
175
+ }
176
+ interface WorkspaceSession {
177
+ readonly executionAuthority: ExecutionAuthority;
178
+ readFile<TOptions extends ReadFileOptions | undefined = undefined>(path: string, options?: TOptions): Promise<ReadFileResult<TOptions>>;
179
+ writeFile(path: string, content: WorkspaceContent, options?: WriteFileOptions): Promise<void>;
180
+ mkdir(path: string, options?: MkdirOptions): Promise<void>;
181
+ rm(path: string, options?: RmOptions): Promise<void>;
182
+ list(path?: string, options?: ListOptions): Promise<WorkspaceEntry[]>;
183
+ glob(pattern: string | string[], options?: GlobOptions): Promise<WorkspaceEntry[]>;
184
+ search(query: WorkspaceSearchQuery): Promise<WorkspaceSearchHit[]>;
185
+ diff(): Promise<WorkspaceDiff>;
186
+ commit(options?: {
187
+ message?: string;
188
+ }): Promise<void>;
189
+ exec(command: string, args?: string[], options?: ExecOptions): Promise<ExecResult>;
190
+ tools?: {
191
+ aiSdk?(): Promise<Record<string, unknown>>;
192
+ };
193
+ close(): Promise<void>;
194
+ }
195
+ declare global {
196
+ interface ViteHubWorkspaceNameMap {}
197
+ interface ViteHubWorkspaceAssetMap {}
198
+ interface ViteHubWorkspaceSourceResolutionContextMap {}
199
+ interface ViteHubWorkspaceScopeNameMap {}
200
+ }
201
+ interface WorkspaceNameMap extends ViteHubWorkspaceNameMap {}
202
+ interface WorkspaceSourceResolutionContextMap extends ViteHubWorkspaceSourceResolutionContextMap {}
203
+ type WorkspaceName = [keyof ViteHubWorkspaceNameMap] extends [never] ? string : Extract<keyof ViteHubWorkspaceNameMap, string>;
204
+ type WorkspaceScopeName = [keyof ViteHubWorkspaceScopeNameMap] extends [never] ? string : Extract<keyof ViteHubWorkspaceScopeNameMap, string>;
205
+ type WorkspaceAssetPath<Name extends WorkspaceName = WorkspaceName> = Name extends keyof ViteHubWorkspaceAssetMap ? Extract<ViteHubWorkspaceAssetMap[Name], string> : string;
206
+ interface WorkspaceAssets<TKey extends string = string> {
207
+ readFile<TOptions extends ReadFileOptions | undefined = undefined>(path: TKey, options?: TOptions): Promise<ReadFileResult<TOptions>>;
208
+ stat(path: TKey): Promise<WorkspaceStat>;
209
+ exists(path: TKey): Promise<boolean>;
210
+ list(path?: TKey | (string & {}) | "", options?: ListOptions): Promise<WorkspaceEntry[]>;
211
+ glob(pattern: TKey | (string & {}) | Array<TKey | (string & {})>, options?: GlobOptions): Promise<WorkspaceEntry[]>;
212
+ search(query: WorkspaceSearchQuery): Promise<WorkspaceSearchHit[]>;
213
+ materializeSources?(options?: WorkspaceMaterializeSourcesOptions): Promise<WorkspaceMaterializeSourcesResult>;
214
+ }
215
+ type WorkspaceAssetsRegistry = Record<string, WorkspaceAssets>;
216
+ interface WorkspaceFile {
217
+ path: string;
218
+ content: WorkspaceContent;
219
+ mediaType?: string;
220
+ metadata?: Record<string, unknown>;
221
+ }
222
+ interface WorkspaceStreamFile {
223
+ path: string;
224
+ content: WorkspaceContentStream;
225
+ mediaType?: string;
226
+ metadata?: Record<string, unknown>;
227
+ }
228
+ interface WorkspaceEntry {
229
+ path: string;
230
+ type: "file" | "directory";
231
+ size?: number;
232
+ mtime?: number;
233
+ mediaType?: string;
234
+ metadata?: Record<string, unknown>;
235
+ digest?: string;
236
+ }
237
+ interface WorkspaceStat extends WorkspaceEntry {
238
+ type: "file" | "directory";
239
+ }
240
+ interface WorkspaceSnapshot {
241
+ id: string;
242
+ name?: string;
243
+ createdAt: string;
244
+ entries: Record<string, {
245
+ type: "file" | "directory";
246
+ digest?: string;
247
+ metadata?: Record<string, unknown>;
248
+ size?: number;
249
+ }>;
250
+ }
251
+ interface WorkspaceDiffEntry {
252
+ path: string;
253
+ type: "added" | "modified" | "removed";
254
+ before?: WorkspaceSnapshot["entries"][string];
255
+ after?: WorkspaceSnapshot["entries"][string];
256
+ }
257
+ interface WorkspaceDiff {
258
+ from?: string;
259
+ to: string;
260
+ entries: WorkspaceDiffEntry[];
261
+ }
262
+ interface WorkspaceAutoCommitPlan {
263
+ message: string;
264
+ paths: string[];
265
+ }
266
+ interface WorkspaceStore {
267
+ readFile(path: string): Promise<WorkspaceFile | undefined>;
268
+ writeFile(path: string, file: WorkspaceFile): Promise<void>;
269
+ writeFileStream?(path: string, file: WorkspaceStreamFile): Promise<WorkspaceStat>;
270
+ list(prefix?: string, options?: ListOptions): Promise<WorkspaceEntry[]>;
271
+ glob(pattern: string | string[], options?: GlobOptions): Promise<WorkspaceEntry[]>;
272
+ stat(path: string): Promise<WorkspaceStat | undefined>;
273
+ mkdir(path: string, options?: MkdirOptions): Promise<void>;
274
+ rm(path: string, options?: RmOptions): Promise<void>;
275
+ snapshot(options?: SnapshotOptions): Promise<WorkspaceSnapshot>;
276
+ diff(options?: DiffOptions): Promise<WorkspaceDiff>;
277
+ getMeta?(key: string): Promise<unknown>;
278
+ setMeta?(key: string, value: unknown): Promise<void>;
279
+ }
280
+ interface SourceContextWorkspaceFiles {
281
+ readFile<TOptions extends ReadFileOptions | undefined = undefined>(path: string, options?: TOptions): Promise<ReadFileResult<TOptions>>;
282
+ stat(path: string): Promise<WorkspaceStat | undefined>;
283
+ exists(path: string): Promise<boolean>;
284
+ }
285
+ interface SourceContext {
286
+ abortSignal?: AbortSignal;
287
+ mountPath?: string;
288
+ rootDir: string;
289
+ selectedWorkspaceScope?: WorkspaceSelectedScope;
290
+ source?: string;
291
+ sourceRootDir?: string;
292
+ workspace: string;
293
+ workspaceFiles?: SourceContextWorkspaceFiles;
294
+ }
295
+ type MaybePromise<T> = T | Promise<T>;
296
+ interface WorkspaceSourceResolutionContextValueReader<TContextMap extends object = WorkspaceSourceResolutionContextMap> {
297
+ entries(): IterableIterator<[string, unknown]>;
298
+ get<K extends Extract<keyof TContextMap, string>>(id: K): TContextMap[K] | undefined;
299
+ get<T = unknown>(id: string): T | undefined;
300
+ has(id: string): boolean;
301
+ toJSON?(): Record<string, unknown>;
302
+ }
303
+ interface WorkspaceSelectedScope<TScopeName extends string = string> {
304
+ all: boolean;
305
+ name: TScopeName;
306
+ paths?: readonly string[];
307
+ role?: string;
308
+ sources?: readonly string[];
309
+ }
310
+ interface WorkspaceSourceResolutionInvocation<TContextMap extends object = WorkspaceSourceResolutionContextMap> {
311
+ context: WorkspaceSourceResolutionContextValueReader<TContextMap>;
312
+ run?: {
313
+ channelId?: string;
314
+ messageId?: string;
315
+ origin?: string;
316
+ runId?: string;
317
+ threadId?: string;
318
+ };
319
+ }
320
+ type WorkspaceSourceResolutionContext<TContextMap extends object = WorkspaceSourceResolutionContextMap, TScopeName extends string = WorkspaceScopeName> = Partial<TContextMap> & {
321
+ invocation: WorkspaceSourceResolutionInvocation<TContextMap>;
322
+ selectedWorkspaceScope?: WorkspaceSelectedScope<TScopeName>;
323
+ source: {
324
+ key: string;
325
+ mountPath: string;
326
+ };
327
+ workspace: Pick<WorkspaceDefinition, "name" | "rootDir" | "sourceRootDir">;
328
+ };
329
+ type WorkspaceSourceResolutionResult = WorkspaceSource | false | null | undefined;
330
+ type WorkspaceSourceResolver<TContextMap extends object = WorkspaceSourceResolutionContextMap, TScopeName extends string = WorkspaceScopeName> = (context: WorkspaceSourceResolutionContext<TContextMap, TScopeName>) => MaybePromise<WorkspaceSourceResolutionResult>;
331
+ type WorkspaceMaterializeMode = "build" | "lazy" | "none";
332
+ type WorkspaceValidateMode = false | "request";
333
+ interface WorkspaceCacheOptions {
334
+ maxAge?: number;
335
+ }
336
+ interface WorkspaceSourceMountOptions {
337
+ path?: string;
338
+ materialize?: WorkspaceMaterializeMode;
339
+ cache?: false | WorkspaceCacheOptions;
340
+ validate?: WorkspaceValidateMode;
341
+ }
342
+ type WorkspaceSourceMount = string | WorkspaceSourceMountOptions;
343
+ interface WorkspaceSourceItem {
344
+ key: string;
345
+ path?: string;
346
+ content?: WorkspaceContent;
347
+ contentStream?: WorkspaceContentStream;
348
+ data?: unknown;
349
+ mediaType?: string;
350
+ metadata?: Record<string, unknown>;
351
+ }
352
+ type WorkspaceInstructionBindingValue = string | number | boolean | null;
353
+ type WorkspaceInstructionBinding = WorkspaceInstructionBindingValue | {
354
+ path: string;
355
+ };
356
+ type WorkspaceSourceRequestMethod = "GET" | "HEAD" | "POST";
357
+ interface WorkspaceSourceRequestDescriptor {
358
+ cache?: false | WorkspaceCacheOptions;
359
+ credentials?: {
360
+ cookies?: string[] | "dynamic";
361
+ headers?: string[] | "dynamic";
362
+ };
363
+ description?: string;
364
+ method: WorkspaceSourceRequestMethod;
365
+ request?: {
366
+ body?: unknown;
367
+ bodySchema?: Record<string, unknown>;
368
+ query?: Record<string, unknown>;
369
+ querySchema?: Record<string, unknown>;
370
+ };
371
+ responseType?: "json" | "text";
372
+ sourceKey?: string;
373
+ url: string;
374
+ workspacePath?: string;
375
+ }
376
+ interface WorkspaceSourceRequestExecutionInput {
377
+ body?: unknown;
378
+ method: WorkspaceSourceRequestMethod;
379
+ url: string;
380
+ }
381
+ interface WorkspaceSourceRequestExecutionResult {
382
+ content: WorkspaceContent;
383
+ mediaType?: string;
384
+ metadata?: Record<string, unknown>;
385
+ status?: number;
386
+ }
387
+ type WorkspaceSourceRequestExecutor = (input: WorkspaceSourceRequestExecutionInput, context: SourceContext) => MaybePromise<WorkspaceSourceRequestExecutionResult>;
388
+ interface WorkspaceSource {
389
+ mount?: WorkspaceSourceMount;
390
+ materialize?: WorkspaceMaterializeMode;
391
+ cache?: false | WorkspaceCacheOptions;
392
+ validate?: WorkspaceValidateMode;
393
+ sync?: WorkspaceSourceSyncConfig;
394
+ probeKeys?: string[];
395
+ fingerprint?: unknown;
396
+ resolve?: WorkspaceSourceResolver;
397
+ prepare?(ctx: SourceContext): Promise<void>;
398
+ getKeys(ctx: SourceContext): Promise<string[]>;
399
+ getItem(key: string, ctx: SourceContext): Promise<WorkspaceSourceItem>;
400
+ getItems?(ctx: SourceContext): Promise<WorkspaceSourceItem[]>;
401
+ getMeta?(key: string, ctx: SourceContext): Promise<Record<string, unknown> | undefined>;
402
+ search?(query: WorkspaceSearchQuery, ctx: SourceContext): Promise<WorkspaceSearchHit[]>;
403
+ watch?: unknown[];
404
+ }
405
+ interface WorkspaceSourceSyncPolicy {
406
+ concurrency?: "skip" | "queue";
407
+ stale?: "keep" | "remove";
408
+ }
409
+ type WorkspaceSourceSyncConfig = boolean | WorkspaceSourceSyncPolicy;
410
+ type WorkspaceSourceDefinition = WorkspaceSource | Source;
411
+ type WorkspaceSourceBindingOptions = Pick<WorkspaceSource, "cache" | "materialize" | "mount" | "probeKeys" | "sync" | "validate">;
412
+ interface WorkspaceSourceBindingInput extends WorkspaceSourceBindingOptions {
413
+ source: WorkspaceSourceInput;
414
+ }
415
+ type WorkspaceCustomSourceInput = WorkspaceSourceDefinition & WorkspaceSourceBindingOptions;
416
+ type WorkspaceFileSourceInput<TKey extends string = string> = TKey | (FileSourceOptions<TKey> & WorkspaceSourceBindingOptions);
417
+ interface WorkspaceFetchSourceRequestOptions {
418
+ body?: unknown;
419
+ headers?: Record<string, string>;
420
+ method?: "GET" | "HEAD" | "POST";
421
+ query?: Record<string, unknown>;
422
+ timeout?: number;
423
+ }
424
+ interface WorkspaceFetchSourceInput<TResponse = unknown, TOutput = TResponse> extends WorkspaceSourceBindingOptions {
425
+ method?: "GET" | "HEAD" | "POST";
426
+ path?: string;
427
+ request?: WorkspaceFetchSourceRequestOptions | (() => WorkspaceFetchSourceRequestOptions | Promise<WorkspaceFetchSourceRequestOptions>);
428
+ responseType?: "json" | "text";
429
+ schema?: unknown;
430
+ transform?: (data: TResponse) => TOutput | Promise<TOutput>;
431
+ url: string | URL;
432
+ }
433
+ type WorkspaceGlobSourceInput = GlobSourceOptions & WorkspaceSourceBindingOptions;
434
+ type WorkspaceGitHubSourceInput = GitHubSourceOptions & WorkspaceSourceBindingOptions;
435
+ type WorkspaceMcpResourcesSourceInput<TKey extends string = string> = Omit<McpResourcesSourceOptions<TKey>, "cache"> & WorkspaceSourceBindingOptions;
436
+ type WorkspaceSourceInput = WorkspaceSourceBindingInput | WorkspaceCustomSourceInput | WorkspaceFileSourceInput | WorkspaceFetchSourceInput | WorkspaceGlobSourceInput | WorkspaceGitHubSourceInput | WorkspaceMcpResourcesSourceInput;
437
+ interface WorkspaceLoaderSource extends WorkspaceSource {
438
+ key: string;
439
+ }
440
+ interface LoaderContext {
441
+ workspace: string;
442
+ rootDir: string;
443
+ sourceRootDir?: string;
444
+ sources: WorkspaceLoaderSource[];
445
+ store: WorkspaceStore;
446
+ parseData(input: {
447
+ id: string;
448
+ data: unknown;
449
+ filePath?: string;
450
+ }): Promise<unknown>;
451
+ generateDigest(input: unknown): string;
452
+ logger: Logger;
453
+ watcher?: unknown;
454
+ }
455
+ interface WorkspaceLoader {
456
+ name: string;
457
+ schema?: unknown;
458
+ load(ctx: LoaderContext): Promise<void>;
459
+ }
460
+ interface PublishContext {
461
+ durable: boolean;
462
+ workspace: WorkspaceDefinition;
463
+ store: WorkspaceStore;
464
+ rootDir: string;
465
+ snapshot?: WorkspaceSnapshot;
466
+ }
467
+ interface WorkspacePublisher {
468
+ name: string;
469
+ clientSafe?: boolean;
470
+ publish(ctx: PublishContext): Promise<void>;
471
+ }
472
+ interface Logger {
473
+ debug(...args: unknown[]): void;
474
+ info(...args: unknown[]): void;
475
+ warn(...args: unknown[]): void;
476
+ error(...args: unknown[]): void;
477
+ }
478
+ interface LocalWorkspaceStoreOptions {
479
+ provider?: "local";
480
+ root?: string;
481
+ }
482
+ interface MemoryWorkspaceStoreOptions {
483
+ provider: "memory";
484
+ }
485
+ interface CloudflareArtifactsWorkspaceStoreOptions {
486
+ provider: "cloudflare-artifacts";
487
+ binding?: string;
488
+ namespace?: string;
489
+ repo?: string;
490
+ repoPrefix?: string;
491
+ branch?: string;
492
+ }
493
+ interface VercelBlobWorkspaceStoreOptions {
494
+ provider: "vercel-blob";
495
+ token?: string;
496
+ prefix?: string;
497
+ access?: "private" | "public";
498
+ }
499
+ type GitHubWorkspaceOption = string | (() => string | undefined);
500
+ interface GitHubWorkspaceStoreOptions {
501
+ provider: "github";
502
+ branch?: GitHubWorkspaceOption;
503
+ repo?: GitHubWorkspaceOption;
504
+ repository?: GitHubWorkspaceOption;
505
+ root?: GitHubWorkspaceOption;
506
+ token?: GitHubWorkspaceOption;
507
+ }
508
+ type WorkspaceStoreOptions = LocalWorkspaceStoreOptions | MemoryWorkspaceStoreOptions | CloudflareArtifactsWorkspaceStoreOptions | VercelBlobWorkspaceStoreOptions | GitHubWorkspaceStoreOptions | WorkspaceStore;
509
+ interface WorkspaceDefinition {
510
+ name: string;
511
+ commit?: boolean | string;
512
+ rootDir?: string;
513
+ sourceRootDir?: string;
514
+ store?: WorkspaceStoreOptions;
515
+ bindings?: Record<string, WorkspaceInstructionBinding>;
516
+ sources?: Record<string, WorkspaceSourceInput>;
517
+ loaders?: WorkspaceLoader[];
518
+ publish?: WorkspacePublisher[];
519
+ plugins?: WorkspacePlugin[];
520
+ rules?: WorkspaceRules;
521
+ hooks?: WorkspaceHooks;
522
+ }
523
+ type WorkspaceDefinitionInput = Omit<WorkspaceDefinition, "name"> & {
524
+ name?: never;
525
+ };
526
+ interface WorkspaceModuleOptions {
527
+ root?: string;
528
+ projectRoot?: string;
529
+ assets?: boolean | string[];
530
+ store?: WorkspaceStoreOptions;
531
+ }
532
+ interface ResolvedWorkspaceModuleOptions {
533
+ root: string;
534
+ assets?: boolean | string[];
535
+ store: Exclude<WorkspaceStoreOptions, WorkspaceStore>;
536
+ }
537
+ interface Workspace {
538
+ name: string;
539
+ sync(options: WorkspaceSyncOptions): Promise<WorkspaceSourceSyncResult>;
540
+ materializeSources?(options?: WorkspaceMaterializeSourcesOptions): Promise<WorkspaceMaterializeSourcesResult>;
541
+ getMeta?(key: string): Promise<unknown>;
542
+ setMeta?(key: string, value: unknown): Promise<void>;
543
+ readFile<TOptions extends ReadFileOptions | undefined = undefined>(path: string, options?: TOptions): Promise<ReadFileResult<TOptions>>;
544
+ writeFile(path: string, content: WorkspaceContent, options?: WriteFileOptions): Promise<void>;
545
+ list(path?: string, options?: ListOptions): Promise<WorkspaceEntry[]>;
546
+ glob(pattern: string | string[], options?: GlobOptions): Promise<WorkspaceEntry[]>;
547
+ search(query: WorkspaceSearchQuery): Promise<WorkspaceSearchHit[]>;
548
+ stat(path: string): Promise<WorkspaceStat>;
549
+ exists(path: string): Promise<boolean>;
550
+ mkdir(path: string, options?: MkdirOptions): Promise<void>;
551
+ rm(path: string, options?: RmOptions): Promise<void>;
552
+ publish(options?: WorkspacePublishOptions): Promise<void>;
553
+ snapshot(options?: SnapshotOptions): Promise<WorkspaceSnapshot>;
554
+ diff(options?: DiffOptions): Promise<WorkspaceDiff>;
555
+ startSession(options?: WorkspaceSessionOptions): Promise<WorkspaceSession>;
556
+ mount(options?: WorkspaceMountOptions): WorkspaceMount;
557
+ }
558
+ interface WorkspaceSourceSyncCounts {
559
+ added: number;
560
+ removed: number;
561
+ unchanged: number;
562
+ updated: number;
563
+ }
564
+ interface WorkspaceSourceSyncPathResult {
565
+ path: string;
566
+ sourcePath: string;
567
+ status: "added" | "removed" | "unchanged" | "updated";
568
+ }
569
+ interface WorkspaceSourceSyncStatus {
570
+ counts: WorkspaceSourceSyncCounts;
571
+ error?: string;
572
+ mountPath: string;
573
+ paths?: WorkspaceSourceSyncPathResult[];
574
+ source: string;
575
+ status: "error" | "ready" | "skipped";
576
+ }
577
+ interface WorkspaceSourceSyncResult {
578
+ durationMs: number;
579
+ published: boolean;
580
+ snapshot?: WorkspaceSnapshot;
581
+ sources: WorkspaceSourceSyncStatus[];
582
+ status: "error" | "partial" | "ready" | "skipped";
583
+ }
584
+ interface WorkspaceSourceMaterializationStatus {
585
+ source: string;
586
+ mountPath: string;
587
+ status: "lazy" | "updating" | "ready" | "error";
588
+ commit?: string;
589
+ materializedAt?: string;
590
+ files?: number;
591
+ bytes?: number;
592
+ error?: string;
593
+ }
594
+ interface WorkspaceMaterializeSourcesProgressEvent {
595
+ bytes?: number;
596
+ directories?: number;
597
+ durationMs?: number;
598
+ error?: string;
599
+ files?: number;
600
+ mountPath: string;
601
+ path: string;
602
+ source: string;
603
+ status: "started" | "updating" | "completed" | "failed";
604
+ }
605
+ interface WorkspaceMaterializeSourcesOptions {
606
+ abortSignal?: AbortSignal;
607
+ onProgress?: (event: WorkspaceMaterializeSourcesProgressEvent) => void | Promise<void>;
608
+ sources?: string[];
609
+ path?: string;
610
+ }
611
+ interface WorkspacePrepareSessionProgressEvent {
612
+ data?: Record<string, unknown>;
613
+ durationMs?: number;
614
+ error?: string;
615
+ id: string;
616
+ label: string;
617
+ status: "started" | "updating" | "completed" | "failed";
618
+ }
619
+ interface WorkspaceMaterializeSourcesResult {
620
+ bytes: number;
621
+ directories: number;
622
+ durationMs: number;
623
+ files: number;
624
+ path: string;
625
+ sources: WorkspaceSourceMaterializationStatus[];
626
+ }
627
+ //#endregion
628
+ export { WorkspaceMaterializeSourcesProgressEvent as $, WorkspaceStreamFile as $t, WorkspaceCacheOptions as A, WorkspaceSourceMount as At, WorkspaceFetchSourceRequestOptions as B, WorkspaceSourceResolutionInvocation as Bt, SourceContextWorkspaceFiles as C, WorkspaceSnapshot as Ct, WorkspaceAssets as D, WorkspaceSourceInput as Dt, WorkspaceAssetPath as E, WorkspaceSourceDefinition as Et, WorkspaceDefinitionInput as F, WorkspaceSourceRequestExecutor as Ft, WorkspaceHookContext as G, WorkspaceSourceSyncCounts as Gt, WorkspaceFileSourceInput as H, WorkspaceSourceResolver as Ht, WorkspaceDiff as I, WorkspaceSourceRequestMethod as It, WorkspaceInstructionBindingValue as J, WorkspaceSourceSyncResult as Jt, WorkspaceHooks as K, WorkspaceSourceSyncPathResult as Kt, WorkspaceDiffEntry as L, WorkspaceSourceResolutionContext as Lt, WorkspaceContentStream as M, WorkspaceSourceRequestDescriptor as Mt, WorkspaceCustomSourceInput as N, WorkspaceSourceRequestExecutionInput as Nt, WorkspaceAssetsRegistry as O, WorkspaceSourceItem as Ot, WorkspaceDefinition as P, WorkspaceSourceRequestExecutionResult as Pt, WorkspaceMaterializeSourcesOptions as Q, WorkspaceStoreOptions as Qt, WorkspaceEntry as R, WorkspaceSourceResolutionContextMap as Rt, SourceContext as S, WorkspaceSessionOptions as St, Workspace as T, WorkspaceSourceBindingInput as Tt, WorkspaceGitHubSourceInput as U, WorkspaceSourceSelection as Ut, WorkspaceFile as V, WorkspaceSourceResolutionResult as Vt, WorkspaceGlobSourceInput as W, WorkspaceSourceSyncConfig as Wt, WorkspaceLoaderSource as X, WorkspaceStat as Xt, WorkspaceLoader as Y, WorkspaceSourceSyncStatus as Yt, WorkspaceMaterializeMode as Z, WorkspaceStore as Zt, ReadFileResult as _, WorkspaceSelectedScope as _t, GitHubWorkspaceOption as a, WorkspaceWriteHook as an, WorkspaceMountOptions as at, RmOptions as b, WorkspaceSessionHostFileEntry as bt, ListOptions as c, WorkspaceWriteOperation as cn, WorkspacePlugin as ct, Logger as d, WriteFileOptions as dn, WorkspacePublisher as dt, WorkspaceSyncOptions as en, WorkspaceMaterializeSourcesResult as et, MaybePromise as f, WorkspaceRule as ft, ReadFileOptions as g, WorkspaceSearchQuery as gt, PublishContext as h, WorkspaceSearchHit as ht, ExecResult as i, WorkspaceWriteErrorHook as in, WorkspaceMountMode as it, WorkspaceContent as j, WorkspaceSourceMountOptions as jt, WorkspaceAutoCommitPlan as k, WorkspaceSourceMaterializationStatus as kt, LoaderContext as l, WorkspaceWriteValidator as ln, WorkspacePrepareSessionProgressEvent as lt, MkdirOptions as m, WorkspaceScopeName as mt, DiffOptions as n, WorkspaceSyncSnapshotOptions as nn, WorkspaceModuleOptions as nt, GitHubWorkspaceStoreOptions as o, WorkspaceWriteInput as on, WorkspaceName as ot, MemoryWorkspaceStoreOptions as p, WorkspaceRules as pt, WorkspaceInstructionBinding as q, WorkspaceSourceSyncPolicy as qt, ExecOptions as r, WorkspaceValidateMode as rn, WorkspaceMount as rt, GlobOptions as s, WorkspaceWriteMode as sn, WorkspaceNameMap as st, CloudflareArtifactsWorkspaceStoreOptions as t, WorkspaceSyncResultDetails as tn, WorkspaceMcpResourcesSourceInput as tt, LocalWorkspaceStoreOptions as u, WorkspaceWriteValidatorResult as un, WorkspacePublishOptions as ut, ResolvedWorkspaceModuleOptions as v, WorkspaceSession as vt, VercelBlobWorkspaceStoreOptions as w, WorkspaceSource as wt, SnapshotOptions as x, WorkspaceSessionHostFiles as xt, ResolvedWorkspaceRule as y, WorkspaceSessionHost as yt, WorkspaceFetchSourceInput as z, WorkspaceSourceResolutionContextValueReader as zt };