@vite-hub/workspace 0.0.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +339 -115
- package/dist/abort-BCwpdrN0.js +32 -0
- package/dist/{asset-registry-8QI3ML3K.js → asset-registry-DfBV5kmw.js} +3 -2
- package/dist/blob-database.d.ts +474 -0
- package/dist/blob-database.js +608 -0
- package/dist/checkout.d.ts +128 -0
- package/dist/checkout.js +849 -0
- package/dist/cloudflare.d.ts +6 -7
- package/dist/cloudflare.js +1 -1
- package/dist/config-B-863EgC.js +15 -0
- package/dist/config-BAgL2dtB.js +1076 -0
- package/dist/{config-DE9xlaIw.d.ts → config-BQKcPawI.d.ts} +1 -2
- package/dist/discard-CNNtCozM.js +8 -0
- package/dist/durability.d.ts +22 -0
- package/dist/durability.js +70 -0
- package/dist/error-diagnostics-CtKjGtGb.js +188 -0
- package/dist/error-diagnostics-DSkCJC_L.js +266 -0
- package/dist/file-2pFYNtsU.js +22 -0
- package/dist/{files-Q6xZjDHA.js → files-BOo4SbwE.js} +3 -3
- package/dist/files.d.ts +38 -0
- package/dist/files.js +6 -0
- package/dist/{github-DHnjxQIX.js → github-CrYp4v8k.js} +44 -24
- package/dist/glob-B8YGvTrZ.js +21 -0
- package/dist/glob-Cjxms1t7.js +30 -0
- package/dist/{host-DJH8cuoU.js → host-BFBpXn0N.js} +144 -77
- package/dist/{hosted-RPeJOCFz.js → hosted-KcUR_jPv.js} +303 -97
- package/dist/hosted-vercel-blob-B3-wRdUm.js +410 -0
- package/dist/hosted-vercel-blob.d.ts +6 -7
- package/dist/hosted-vercel-blob.js +1 -1
- package/dist/hosted.d.ts +10 -9
- package/dist/hosted.js +2 -2
- package/dist/index.d.ts +26 -47
- package/dist/index.js +30 -100
- package/dist/internal/path.d.ts +2 -0
- package/dist/internal/path.js +2 -0
- package/dist/lifecycle-B-enk_4A.js +596 -0
- package/dist/lineage.d.ts +26 -0
- package/dist/lineage.js +76 -0
- package/dist/loader.d.ts +5 -6
- package/dist/loader.js +3 -2
- package/dist/mcp-resources-DF0F5rcL.js +39 -0
- package/dist/memory-BOexthyW.js +247 -0
- package/dist/metadata-target-CWz6KHKq.js +1589 -0
- package/dist/object-Da1zyPCR.js +11 -0
- package/dist/operation-definition-8gOe-ubD.d.ts +234 -0
- package/dist/operations-C6FpR8Rr.js +389 -0
- package/dist/operations-CE2drFih.js +1234 -0
- package/dist/operations.d.ts +90 -0
- package/dist/operations.js +3 -0
- package/dist/path--wrT_Azm.js +113 -0
- package/dist/path-AxMho1wo.d.ts +7 -0
- package/dist/path-DrSIenjj.js +59 -0
- package/dist/path-zHxQUbqa.d.ts +9 -0
- package/dist/plugins-C8C0auoW.d.ts +10 -0
- package/dist/provider-9s4Ufkm5.js +1479 -0
- package/dist/providers/github/store.d.ts +3 -5
- package/dist/providers/github/store.js +1 -1
- package/dist/registry-B3BBm4Ts.d.ts +19 -0
- package/dist/{registry-D3yzt8HQ.js → registry-CNphafBx.js} +60 -23
- package/dist/registry-CYNN623b.d.ts +9 -0
- package/dist/request-scope-Dw5n8bMC.js +83 -0
- package/dist/results-DgkZUmTL.js +8 -0
- package/dist/{chunk-2rV9d50f.js → rolldown-runtime-rQ84J-ij.js} +3 -4
- package/dist/runtime/assets.d.ts +3 -5
- package/dist/runtime/assets.js +7 -6
- package/dist/runtime/empty-assets-registry.d.ts +1 -2
- package/dist/runtime/empty-registry.d.ts +2 -2
- package/dist/runtime/registry.d.ts +2 -0
- package/dist/runtime/registry.js +23 -0
- package/dist/runtime/request.d.ts +4 -0
- package/dist/runtime/request.js +8 -0
- package/dist/runtime/state.d.ts +5 -4
- package/dist/runtime/state.js +8 -18
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -1
- package/dist/runtime.d.ts +52 -17
- package/dist/runtime.js +324 -67
- package/dist/{search-BpiCF2Tw.js → search-C_RfoM2j.js} +10 -9
- package/dist/server-8tGltlGz.js +303 -0
- package/dist/server.d.ts +36 -39
- package/dist/server.js +2 -328
- package/dist/shared-B3_EUk89.js +848 -0
- package/dist/source-metadata.d.ts +10 -7
- package/dist/source-metadata.js +12 -12
- package/dist/state-BISnUf1s.d.ts +35 -0
- package/dist/{ai-BqCC8BpY.js → state-DbrW-njQ.js} +237 -114
- package/dist/store-ybhyD38Z.js +1873 -0
- package/dist/{sync-DnTQwt8r.js → sync-CCD_VYC8.js} +61 -41
- package/dist/target-jWhTdIuF.js +89 -0
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/{types-CYuwjJ4V.d.ts → types-BbtwmBZ5.d.ts} +321 -35
- package/dist/use-C6lV3-wC.d.ts +321 -0
- package/dist/{use-BTNDR5Rd.js → use-CSpT5W87.js} +141 -107
- package/dist/utils-CgMZCHsX.js +616 -0
- package/dist/vite.d.ts +585 -2
- package/dist/vite.js +21369 -2
- package/dist/workspace-CYB2xZ1T.d.ts +7 -0
- package/dist/{workspace-Dq08Yn72.js → workspace-sPWn2Jxj.js} +441 -225
- package/package.json +97 -72
- package/dist/ai-CjxvGqM0.d.ts +0 -162
- package/dist/ai.d.ts +0 -3
- package/dist/ai.js +0 -2
- package/dist/collections/client.d.ts +0 -39
- package/dist/collections/client.js +0 -137
- package/dist/collections.d.ts +0 -59
- package/dist/collections.js +0 -159
- package/dist/config-Bc3c4Su1.js +0 -7904
- package/dist/config-CHLLWklZ.js +0 -36
- package/dist/file-Bc1X7pco.js +0 -23
- package/dist/glob-CEZKeZFC.js +0 -18
- package/dist/hosted-vercel-blob-d6C8ND5j.js +0 -23580
- package/dist/lifecycle-LrL3sA4n.js +0 -316
- package/dist/metadata-target-B0tOmVW7.js +0 -717
- package/dist/mountx.d.ts +0 -10
- package/dist/mountx.js +0 -143
- package/dist/nitro.d.ts +0 -2
- package/dist/nitro.js +0 -2
- package/dist/nuxt.d.ts +0 -26
- package/dist/nuxt.js +0 -42
- package/dist/path-Cp59koVz.js +0 -139
- package/dist/provider-B1yLjCJJ.js +0 -746
- package/dist/publish.d.ts +0 -35
- package/dist/publish.js +0 -112
- package/dist/registry-Uj6IVxes.d.ts +0 -11
- package/dist/request-execution-B-dSFlGB.js +0 -84
- package/dist/runtime-options-BsPSv5O7.js +0 -13
- package/dist/runtime-type-iEE6BjQJ.js +0 -34
- package/dist/shared-DTR1Hhma.js +0 -331
- package/dist/state-tYcRWEh2.d.ts +0 -26
- package/dist/store-Dt_Jyys3.js +0 -608
- package/dist/target-D4Bqb1eH.js +0 -11
- package/dist/token-CVzURBxC.js +0 -61
- package/dist/use-BiHzt0xA.d.ts +0 -103
- package/dist/vite-BptCrpv2.js +0 -4526
- package/dist/vite-CtA9guIM.d.ts +0 -66
- package/dist/workspace-Xddf4G1B.d.ts +0 -6
|
@@ -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 };
|
|
@@ -1,17 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as createWorkspace } from "./workspace-
|
|
7
|
-
import { r as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { i as isWorkspaceError, s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
|
|
2
|
+
import { n as resolveWorkspaceStoreTarget, r as workspaceStoreTarget, t as forwardWorkspaceStoreTarget } from "./target-jWhTdIuF.js";
|
|
3
|
+
import { c as normalizeSafeWorkspacePattern, f as sha256 } from "./path--wrT_Azm.js";
|
|
4
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CtKjGtGb.js";
|
|
5
|
+
import { d as normalizeHistoryRef, f as requireWorkspaceHistory, l as historyConflict, p as validateHistoryMessage } from "./utils-CgMZCHsX.js";
|
|
6
|
+
import { g as getWorkspaceSourceRequestExecution, i as assertPublicWorkspaceMetaKey, m as attachWorkspaceSourceRequestExecution, t as createWorkspace } from "./workspace-sPWn2Jxj.js";
|
|
7
|
+
import { c as workspaceInternalMetadataCapability, o as resolveWorkspaceMetadataTarget, r as forwardWorkspaceMetadataTarget, t as attachWorkspaceMetadataTarget } from "./metadata-target-CWz6KHKq.js";
|
|
8
|
+
import { o as useRegisteredWorkspace } from "./registry-CNphafBx.js";
|
|
9
|
+
import { n as useWorkspaceAssets } from "./asset-registry-DfBV5kmw.js";
|
|
10
|
+
import { t as createHostedWorkspaceSession } from "./host-BFBpXn0N.js";
|
|
10
11
|
import { getViteHubErrorShape } from "@vite-hub/runtime";
|
|
12
|
+
import { posix } from "node:path";
|
|
13
|
+
//#region src/fs-ops.ts
|
|
14
|
+
async function ensureMissingOrReplaceable(workspace, path, overwrite = false) {
|
|
15
|
+
if (!await workspace.exists(path)) return;
|
|
16
|
+
if (!overwrite) throw workspaceError(`[vitehub] Workspace path already exists: ${path}.`);
|
|
17
|
+
await workspace.rm(path, {
|
|
18
|
+
recursive: true,
|
|
19
|
+
force: true
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async function copyWorkspacePath(workspace, from, to, overwrite = false) {
|
|
23
|
+
if (from === to) throw workspaceError("[vitehub] Source and destination must be different.");
|
|
24
|
+
const source = await workspace.stat(from);
|
|
25
|
+
if (source.type === "directory" && to.startsWith(`${from}/`)) throw workspaceError("[vitehub] Destination cannot be nested inside the source directory.");
|
|
26
|
+
if (from.startsWith(`${to}/`)) throw workspaceError("[vitehub] Destination cannot contain the source.");
|
|
27
|
+
if (overwrite && await (await resolveWorkspaceStoreTarget(workspace))?.containsPath?.(to, from)) throw workspaceError("[vitehub] Destination cannot contain the source.");
|
|
28
|
+
await ensureMissingOrReplaceable(workspace, to, overwrite);
|
|
29
|
+
if (source.type === "file") {
|
|
30
|
+
const content = await workspace.readFile(from, { encoding: "binary" });
|
|
31
|
+
await workspace.writeFile(to, content, { mediaType: source.mediaType });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const entries = await workspace.list(from, { recursive: true });
|
|
35
|
+
await workspace.mkdir(to, { recursive: true });
|
|
36
|
+
const directories = entries.filter((entry) => entry.type === "directory").sort((left, right) => left.path.length - right.path.length);
|
|
37
|
+
for (const entry of directories) await workspace.mkdir(posix.join(to, posix.relative(from, entry.path)), { recursive: true });
|
|
38
|
+
await Promise.all(entries.filter((entry) => entry.type === "file").map(async (entry) => {
|
|
39
|
+
const content = await workspace.readFile(entry.path, { encoding: "binary" });
|
|
40
|
+
await workspace.writeFile(posix.join(to, posix.relative(from, entry.path)), content, { mediaType: entry.mediaType });
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
async function appendWorkspaceFile(workspace, path, content) {
|
|
44
|
+
let current = "";
|
|
45
|
+
try {
|
|
46
|
+
current = String(await workspace.readFile(path));
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (!isWorkspaceError(error)) throw error;
|
|
49
|
+
}
|
|
50
|
+
await workspace.writeFile(path, `${current}${content}`);
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
11
53
|
//#region src/core/use.ts
|
|
12
54
|
const workspaceDefinitionSyncStates = /* @__PURE__ */ new WeakMap();
|
|
13
55
|
async function workspaceDefinitionSyncState(workspace) {
|
|
14
|
-
const owner = await workspace
|
|
56
|
+
const owner = await resolveWorkspaceMetadataTarget(workspace) ?? workspace;
|
|
15
57
|
const key = workspace.__workspaceDefinitionSyncKey ?? workspace;
|
|
16
58
|
let states = workspaceDefinitionSyncStates.get(owner);
|
|
17
59
|
if (!states) {
|
|
@@ -69,10 +111,13 @@ async function materializeWorkspaceSources(workspace, options) {
|
|
|
69
111
|
if (!workspace.materializeSources) throw workspaceError("[vitehub] Workspace source materialization is unavailable.");
|
|
70
112
|
return await workspace.materializeSources(options);
|
|
71
113
|
}
|
|
72
|
-
function createLazyWorkspace(name, definition) {
|
|
114
|
+
function createLazyWorkspace(name, definition, options = {}) {
|
|
73
115
|
let workspacePromise;
|
|
74
116
|
async function resolveWorkspace() {
|
|
75
|
-
workspacePromise ||= definition ? Promise.resolve(createWorkspace(definition)) : useRegisteredWorkspace(name)
|
|
117
|
+
workspacePromise ||= (definition ? Promise.resolve(createWorkspace(definition, options)) : useRegisteredWorkspace(name, options)).catch((error) => {
|
|
118
|
+
workspacePromise = void 0;
|
|
119
|
+
throw error;
|
|
120
|
+
});
|
|
76
121
|
return await workspacePromise;
|
|
77
122
|
}
|
|
78
123
|
async function resolveSyncedWorkspace(abortSignal) {
|
|
@@ -114,17 +159,39 @@ function createLazyWorkspace(name, definition) {
|
|
|
114
159
|
}
|
|
115
160
|
}
|
|
116
161
|
}
|
|
117
|
-
|
|
118
|
-
const workspace = await resolveWorkspace();
|
|
119
|
-
const sync = await workspaceDefinitionSyncState(workspace);
|
|
120
|
-
if (sync.explicitPromise) await waitForWorkspaceSync(sync.explicitPromise);
|
|
121
|
-
return sync.promise ? await resolveSyncedWorkspace() : workspace;
|
|
122
|
-
}
|
|
123
|
-
return attachWorkspaceSourceRequestExecution({
|
|
124
|
-
async [workspaceMetadataTarget]() {
|
|
125
|
-
return (await resolveWorkspace())[workspaceMetadataTarget]?.();
|
|
126
|
-
},
|
|
162
|
+
const workspace = {
|
|
127
163
|
name,
|
|
164
|
+
history: {
|
|
165
|
+
digest: async (bytes) => {
|
|
166
|
+
const history = (await resolveWorkspace()).history;
|
|
167
|
+
return history?.digest ? await history.digest(bytes) : await sha256(bytes);
|
|
168
|
+
},
|
|
169
|
+
forksFrom: async (ref) => await (await resolveWorkspace()).history?.forksFrom?.(ref),
|
|
170
|
+
pullRequests: async (options) => await (await resolveWorkspace()).history?.pullRequests?.(options) ?? [],
|
|
171
|
+
merge: async (options) => {
|
|
172
|
+
const history = (await resolveWorkspace()).history;
|
|
173
|
+
if (!history?.merge) throw workspaceError("[vitehub] This Workspace Store cannot merge refs.");
|
|
174
|
+
return await history.merge(options);
|
|
175
|
+
},
|
|
176
|
+
openPullRequest: async (options) => {
|
|
177
|
+
const history = (await resolveWorkspace()).history;
|
|
178
|
+
if (!history?.openPullRequest) throw workspaceError("[vitehub] This Workspace Store cannot open pull requests.");
|
|
179
|
+
return await history.openPullRequest(options);
|
|
180
|
+
},
|
|
181
|
+
head: async (options) => await requireWorkspaceHistory(await resolveWorkspace()).head(options),
|
|
182
|
+
list: async (options) => await requireWorkspaceHistory(await resolveWorkspace()).list(options),
|
|
183
|
+
refs: async () => await requireWorkspaceHistory(await resolveWorkspace()).refs(),
|
|
184
|
+
open: async (id) => await requireWorkspaceHistory(await resolveWorkspace()).open(id),
|
|
185
|
+
usage: async () => await requireWorkspaceHistory(await resolveWorkspace()).usage(),
|
|
186
|
+
commit: async (options) => {
|
|
187
|
+
const history = requireWorkspaceHistory(await resolveWorkspace());
|
|
188
|
+
validateHistoryMessage(options.message);
|
|
189
|
+
const ref = normalizeHistoryRef(options.ref);
|
|
190
|
+
const head = await history.head({ ref });
|
|
191
|
+
if ((head?.id ?? null) !== options.ifHead) throw historyConflict(ref, options.ifHead, head?.id ?? null);
|
|
192
|
+
return await requireWorkspaceHistory(await resolveSyncedWorkspace()).commit(options);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
128
195
|
async capabilities() {
|
|
129
196
|
return await (await resolveWorkspace()).capabilities?.() ?? { conditionalWrites: false };
|
|
130
197
|
},
|
|
@@ -176,9 +243,6 @@ function createLazyWorkspace(name, definition) {
|
|
|
176
243
|
async materializeSources(options) {
|
|
177
244
|
return await materializeWorkspaceSources(await resolveSyncedWorkspace(options?.abortSignal), options);
|
|
178
245
|
},
|
|
179
|
-
async publish(options) {
|
|
180
|
-
await (await resolvePublishWorkspace()).publish(options);
|
|
181
|
-
},
|
|
182
246
|
async snapshot(options) {
|
|
183
247
|
return await (await resolveSyncedWorkspace()).snapshot(options);
|
|
184
248
|
},
|
|
@@ -194,15 +258,18 @@ function createLazyWorkspace(name, definition) {
|
|
|
194
258
|
async getMeta(key) {
|
|
195
259
|
return await (await resolveWorkspace()).getMeta?.(key);
|
|
196
260
|
},
|
|
197
|
-
async setMeta(key, value) {
|
|
198
|
-
await (await resolveWorkspace()).setMeta?.(key, value);
|
|
261
|
+
async setMeta(key, value, capability) {
|
|
262
|
+
await (await resolveWorkspace()).setMeta?.(capability === workspaceInternalMetadataCapability ? key : assertPublicWorkspaceMetaKey(key), value, capability);
|
|
199
263
|
},
|
|
200
264
|
async startSession(options) {
|
|
201
265
|
return await (await resolveSyncedWorkspace()).startSession(options);
|
|
202
266
|
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
267
|
+
};
|
|
268
|
+
attachWorkspaceMetadataTarget(workspace, async () => await resolveWorkspaceMetadataTarget(await resolveWorkspace()));
|
|
269
|
+
return attachWorkspaceSourceRequestExecution(workspace, { async executeSourceRequest(input) {
|
|
270
|
+
const resolved = await resolveSyncedWorkspace();
|
|
271
|
+
const executor = getWorkspaceSourceRequestExecution(resolved);
|
|
272
|
+
if (!executor) throw workspaceErrorDiagnostics.WORKSPACE_R0025({ message: "[vitehub] No API-backed Source request executor is available for this workspace." });
|
|
206
273
|
return await executor.executeSourceRequest(input);
|
|
207
274
|
} });
|
|
208
275
|
}
|
|
@@ -327,84 +394,40 @@ function createReadonlyFs(name, workspace) {
|
|
|
327
394
|
},
|
|
328
395
|
startSession: async (options) => {
|
|
329
396
|
if (!assets || !options?.host) return await workspace.startSession(options);
|
|
330
|
-
|
|
397
|
+
const overlay = Object.assign(Object.create(workspace), {
|
|
331
398
|
exists: readonlyFs.exists,
|
|
332
399
|
glob: readonlyFs.glob,
|
|
333
400
|
list: readonlyFs.list,
|
|
334
401
|
readFile: readonlyFs.readFile,
|
|
335
402
|
search: readonlyFs.search,
|
|
336
403
|
stat: readonlyFs.stat
|
|
337
|
-
})
|
|
404
|
+
});
|
|
405
|
+
return await createHostedWorkspaceSession(overlay, {
|
|
338
406
|
...options,
|
|
339
407
|
host: options.host
|
|
340
408
|
});
|
|
341
409
|
}
|
|
342
410
|
}, getWorkspaceSourceRequestExecution(workspace));
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
const metadata = await ignoreMissingWorkspace(async () => await resolveMetadata.call(workspace));
|
|
411
|
+
attachWorkspaceMetadataTarget(readonlyFs, async () => {
|
|
412
|
+
const metadata = await ignoreMissingWorkspace(async () => await resolveWorkspaceMetadataTarget(workspace));
|
|
346
413
|
if (!metadata && !assets) return;
|
|
347
|
-
|
|
414
|
+
const target = {
|
|
415
|
+
workspaceName: metadata?.workspaceName,
|
|
348
416
|
getMeta: metadata?.getMeta?.bind(metadata),
|
|
349
417
|
list: async (path, options) => {
|
|
350
418
|
const assetPath = path;
|
|
351
419
|
return mergeEntries(assets ? await assets.list(assetPath, options) : [], await metadata?.list?.(path, options) ?? []);
|
|
352
420
|
}
|
|
353
421
|
};
|
|
354
|
-
|
|
422
|
+
if (metadata) forwardWorkspaceStoreTarget(metadata, target);
|
|
423
|
+
return target;
|
|
424
|
+
});
|
|
355
425
|
return readonlyFs;
|
|
356
426
|
}
|
|
357
|
-
function
|
|
358
|
-
return {
|
|
359
|
-
list: options?.list,
|
|
360
|
-
materialize: options?.materialize ?? true,
|
|
361
|
-
read: options?.read,
|
|
362
|
-
search: options?.search
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
function toWriteOperations(options) {
|
|
366
|
-
return {
|
|
367
|
-
...toReadOperations(options),
|
|
368
|
-
write: {
|
|
369
|
-
appendFile: options?.appendFile !== false,
|
|
370
|
-
copyPath: options?.copyPath !== false,
|
|
371
|
-
deletePath: options?.deletePath !== false,
|
|
372
|
-
makeDir: options?.makeDir !== false,
|
|
373
|
-
movePath: options?.movePath !== false,
|
|
374
|
-
writeFile: options?.writeFile !== false
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
function createDefaultToolSet(createTools) {
|
|
379
|
-
return createTools();
|
|
380
|
-
}
|
|
381
|
-
function emptyTools() {
|
|
382
|
-
return {};
|
|
383
|
-
}
|
|
384
|
-
function useWorkspace(name, options) {
|
|
427
|
+
function createWorkspaceFileRuntime(name, options) {
|
|
385
428
|
if (options?.mode === "write") {
|
|
386
429
|
const workspace = createLazyWorkspace(name, options.definition);
|
|
387
|
-
const
|
|
388
|
-
broadSearchPaths: opts?.broadSearchPaths,
|
|
389
|
-
cwd: opts?.cwd,
|
|
390
|
-
maxShellCalls: opts?.maxShellCalls,
|
|
391
|
-
maxOutputLength: opts?.maxOutputLength,
|
|
392
|
-
operations: toWriteOperations(opts),
|
|
393
|
-
timeout: opts?.timeout
|
|
394
|
-
});
|
|
395
|
-
const createReadTools = (opts) => createWorkspaceTools(createReadonlyFs(name, workspace), {
|
|
396
|
-
broadSearchPaths: opts?.broadSearchPaths,
|
|
397
|
-
cwd: opts?.cwd,
|
|
398
|
-
maxShellCalls: opts?.maxShellCalls,
|
|
399
|
-
maxOutputLength: opts?.maxOutputLength,
|
|
400
|
-
operations: toReadOperations(opts),
|
|
401
|
-
timeout: opts?.timeout
|
|
402
|
-
});
|
|
403
|
-
const tools = createDefaultToolSet(createTools);
|
|
404
|
-
tools.inspect = createReadTools;
|
|
405
|
-
tools.write = createTools;
|
|
406
|
-
tools.none = emptyTools;
|
|
407
|
-
return {
|
|
430
|
+
const facade = {
|
|
408
431
|
[workspaceStoreTarget]: async () => {
|
|
409
432
|
return await workspace[workspaceStoreTarget]?.();
|
|
410
433
|
},
|
|
@@ -412,39 +435,50 @@ function useWorkspace(name, options) {
|
|
|
412
435
|
diff: async (options) => await workspace.diff(options),
|
|
413
436
|
fs: createWritableFs(name, workspace),
|
|
414
437
|
history: {
|
|
415
|
-
|
|
438
|
+
...workspace.history,
|
|
439
|
+
checkpoint: async (options) => await workspace.snapshot({
|
|
440
|
+
name: options?.message,
|
|
441
|
+
...options?.author ? { author: options.author } : {}
|
|
442
|
+
}),
|
|
416
443
|
rebase: async (options) => await workspace.rebase(options)
|
|
417
444
|
},
|
|
418
445
|
getMeta: async (key) => await workspace.getMeta?.(key),
|
|
419
446
|
materializeSources: async (options) => await materializeWorkspaceSources(workspace, options),
|
|
420
|
-
|
|
421
|
-
setMeta: async (key, value) => await workspace.setMeta?.(key, value),
|
|
447
|
+
setMeta: async (key, value, capability) => await workspace.setMeta?.(key, value, capability),
|
|
422
448
|
snapshot: async (options) => await workspace.snapshot(options),
|
|
423
449
|
startSession: async (options) => await workspace.startSession(options),
|
|
424
|
-
sync: async (options) => await workspace.sync(options)
|
|
425
|
-
|
|
450
|
+
sync: async (options) => await workspace.sync(options)
|
|
451
|
+
};
|
|
452
|
+
forwardWorkspaceMetadataTarget(workspace, facade);
|
|
453
|
+
return {
|
|
454
|
+
mode: "write",
|
|
455
|
+
workspace,
|
|
456
|
+
facade
|
|
426
457
|
};
|
|
427
458
|
}
|
|
428
|
-
const workspace = createLazyWorkspace(name, options?.definition);
|
|
459
|
+
const workspace = createLazyWorkspace(name, options?.definition, { reuseStartupSnapshots: options?.refresh === false });
|
|
429
460
|
const fs = createReadonlyFs(name, workspace);
|
|
430
|
-
const createTools = (opts) => createWorkspaceTools(fs, {
|
|
431
|
-
broadSearchPaths: opts?.broadSearchPaths,
|
|
432
|
-
cwd: opts?.cwd,
|
|
433
|
-
maxShellCalls: opts?.maxShellCalls,
|
|
434
|
-
maxOutputLength: opts?.maxOutputLength,
|
|
435
|
-
operations: toReadOperations(opts),
|
|
436
|
-
timeout: opts?.timeout
|
|
437
|
-
});
|
|
438
|
-
const tools = createDefaultToolSet(createTools);
|
|
439
|
-
tools.inspect = createTools;
|
|
440
|
-
tools.none = emptyTools;
|
|
441
461
|
const facade = {
|
|
442
462
|
fs,
|
|
443
|
-
|
|
444
|
-
|
|
463
|
+
history: {
|
|
464
|
+
head: (options) => requireWorkspaceHistory(workspace).head(options),
|
|
465
|
+
list: (options) => requireWorkspaceHistory(workspace).list(options),
|
|
466
|
+
refs: () => requireWorkspaceHistory(workspace).refs(),
|
|
467
|
+
open: (id) => requireWorkspaceHistory(workspace).open(id),
|
|
468
|
+
usage: () => requireWorkspaceHistory(workspace).usage()
|
|
469
|
+
},
|
|
470
|
+
getMeta: async (key) => await workspace.getMeta?.(key)
|
|
445
471
|
};
|
|
446
472
|
forwardWorkspaceMetadataTarget(fs, facade);
|
|
447
|
-
|
|
473
|
+
forwardWorkspaceStoreTarget(workspace, facade);
|
|
474
|
+
return {
|
|
475
|
+
mode: "read",
|
|
476
|
+
workspace,
|
|
477
|
+
facade
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
function useWorkspaceFiles(name, options) {
|
|
481
|
+
return createWorkspaceFileRuntime(name, options).facade;
|
|
448
482
|
}
|
|
449
483
|
//#endregion
|
|
450
|
-
export {
|
|
484
|
+
export { copyWorkspacePath as a, appendWorkspaceFile as i, createWorkspaceFileRuntime as n, useWorkspaceFiles as r, createReadonlyFs as t };
|