@vite-hub/workspace 0.0.1 → 0.0.3

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