@vite-hub/workspace 0.0.4 → 0.1.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 +225 -58
- package/dist/{ai-CjxvGqM0.d.ts → ai-BW2ZhizI.d.ts} +22 -7
- package/dist/{ai-BqCC8BpY.js → ai-BZyLwULx.js} +147 -66
- package/dist/ai.d.ts +2 -2
- package/dist/ai.js +1 -1
- package/dist/{asset-registry-8QI3ML3K.js → asset-registry-DfBV5kmw.js} +3 -2
- package/dist/association-Cm0dUTDU-CDDhJnIh-Cv3bWnVb.js +19 -0
- package/dist/blob-database.d.ts +521 -0
- package/dist/blob-database.js +601 -0
- package/dist/cloudflare.d.ts +5 -6
- package/dist/cloudflare.js +1 -1
- package/dist/config-B7dmzDX3.js +1112 -0
- package/dist/{config-DE9xlaIw.d.ts → config-DLKdaFWN.d.ts} +1 -2
- package/dist/error-diagnostics-A_8Kp-48.js +116 -0
- package/dist/error-diagnostics-DY5GP47p.js +96 -0
- package/dist/events-7EBoeIPd-A2RUkJi5-BxrICQ17.js +354 -0
- package/dist/events-CRaLy7U3-3PNNp5WZ-Gv9nd0cH.js +214 -0
- package/dist/events-CeChclTf-CX-gD8oy-4aL2j6V-.js +527 -0
- package/dist/feed-DsC7Vws1-M_de2nSK-tKc0Pwo8.js +248 -0
- package/dist/feed-Dyf730Ys-D0HgBba6-BUnCa5gS.js +179 -0
- package/dist/file-C0_aPWSS.js +26 -0
- package/dist/file-metadata-CxDy-E2H.js +58 -0
- package/dist/{files-Q6xZjDHA.js → files-C7Px8uaC.js} +3 -3
- package/dist/forgejo-BN8ItCfl-Bbn4vhDd.js +2278 -0
- package/dist/{github-DHnjxQIX.js → github-CPxHtFB7.js} +16 -23
- package/dist/github-DtncTfmv-Du2S8lGF.js +4159 -0
- package/dist/gitlab-BoDm8-BC-xzZsW9eW.js +2530 -0
- package/dist/glob--XcLlcml.js +22 -0
- package/dist/glob--kNYDbfU.js +30 -0
- package/dist/graphql-DG5aJBT3-DceyFYdM-C4saqX37.js +489 -0
- package/dist/{host-DJH8cuoU.js → host-CFnrTXTK.js} +97 -41
- package/dist/{hosted-RPeJOCFz.js → hosted-acMA5XyL.js} +102 -19
- package/dist/hosted-vercel-blob-DKntsHaf.js +12603 -0
- package/dist/hosted-vercel-blob.d.ts +5 -6
- package/dist/hosted-vercel-blob.js +1 -1
- package/dist/hosted.d.ts +6 -7
- package/dist/hosted.js +1 -1
- package/dist/index.d.ts +57 -36
- package/dist/index.js +56 -56
- package/dist/inspect-BoObD2cJ.js +167 -0
- package/dist/internal/path.d.ts +2 -0
- package/dist/internal/path.js +2 -0
- package/dist/lifecycle-BwZ7c9hb.js +596 -0
- package/dist/loader.d.ts +5 -6
- package/dist/loader.js +3 -2
- package/dist/mcp-resources-BREFCmtn.js +39 -0
- package/dist/memory-BbwOqDXl.js +248 -0
- package/dist/metadata-target-DZEZQGHA.js +1588 -0
- package/dist/mountx.d.ts +4 -6
- package/dist/mountx.js +10 -8
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +1 -1
- package/dist/nuxt.d.ts +13 -12
- package/dist/nuxt.js +4 -8
- package/dist/operations-BcpWr41m.js +159 -0
- package/dist/operations-CGqY1XeG.js +965 -0
- package/dist/operations-DnOwKsJT.d.ts +136 -0
- package/dist/operations.d.ts +53 -0
- package/dist/operations.js +2 -0
- package/dist/path-CNAwN7pw.js +114 -0
- package/dist/path-DrSIenjj.js +59 -0
- package/dist/path-zHxQUbqa.d.ts +9 -0
- package/dist/plugins-DqQ8b4T5.d.ts +10 -0
- package/dist/provider-kXjfli9u.js +1457 -0
- package/dist/providers/github/store.d.ts +3 -5
- package/dist/providers/github/store.js +1 -1
- package/dist/{registry-D3yzt8HQ.js → registry-Bp-8UUfG.js} +9 -7
- package/dist/{registry-Uj6IVxes.d.ts → registry-Cg1TJVVZ.d.ts} +1 -2
- package/dist/{request-execution-B-dSFlGB.js → request-execution-Dk9rY-Yh.js} +19 -19
- package/dist/{chunk-2rV9d50f.js → rolldown-runtime-B4iAMlE-.js} +2 -2
- 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 +1 -2
- package/dist/runtime/state.d.ts +3 -3
- package/dist/runtime/state.js +6 -6
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -1
- package/dist/runtime.d.ts +51 -17
- package/dist/runtime.js +320 -60
- package/dist/{search-BpiCF2Tw.js → search-CrTmXj5h.js} +10 -9
- package/dist/server-BNQ-Nbjj.js +290 -0
- package/dist/server.d.ts +22 -34
- package/dist/server.js +2 -328
- package/dist/shared-DalXdP0i.js +2158 -0
- package/dist/source-metadata.d.ts +6 -7
- package/dist/source-metadata.js +7 -7
- package/dist/{state-tYcRWEh2.d.ts → state-B8zbLi5t.d.ts} +3 -3
- package/dist/store-CXgmu-uw.js +1729 -0
- package/dist/{sync-DnTQwt8r.js → sync-CN6ec-5M.js} +61 -41
- package/dist/templates-Bn8a-pd2-D9DhJEVD-CBfXNRzz.js +125 -0
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/{token-CVzURBxC.js → token-CO62GglH.js} +3 -3
- package/dist/{types-CYuwjJ4V.d.ts → types-DeK9GIxy.d.ts} +256 -24
- package/dist/{use-BTNDR5Rd.js → use-BQj7nSz6.js} +82 -41
- package/dist/{use-BiHzt0xA.d.ts → use-DhwhbAVV.d.ts} +16 -11
- package/dist/utils-Blrh4N2n.js +545 -0
- package/dist/vite-BEvgU2GY.js +20909 -0
- package/dist/vite-CcZmMQ7S.d.ts +476 -0
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +2 -2
- package/dist/webhooks-DgHwxxYz-D1V2LOr1-azofFOiP.js +1565 -0
- package/dist/{workspace-Dq08Yn72.js → workspace-6pxkOuxr.js} +361 -230
- package/dist/{workspace-Xddf4G1B.d.ts → workspace-BWJQBK1u.d.ts} +4 -3
- package/package.json +89 -55
- 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/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/runtime-options-BsPSv5O7.js +0 -13
- package/dist/runtime-type-iEE6BjQJ.js +0 -34
- package/dist/shared-DTR1Hhma.js +0 -331
- package/dist/store-Dt_Jyys3.js +0 -608
- package/dist/vite-BptCrpv2.js +0 -4526
- package/dist/vite-CtA9guIM.d.ts +0 -66
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { r as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { t as
|
|
1
|
+
import { s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
|
|
2
|
+
import { c as normalizeSafeWorkspacePattern, f as sha256 } from "./path-CNAwN7pw.js";
|
|
3
|
+
import { r as workspaceStoreTarget, t as forwardWorkspaceStoreTarget } from "./target-D4Bqb1eH.js";
|
|
4
|
+
import { a as copyWorkspacePath, i as appendWorkspaceFile, t as createWorkspaceTools } from "./ai-BZyLwULx.js";
|
|
5
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-DY5GP47p.js";
|
|
6
|
+
import { r as getWorkspaceSourceRequestExecution, t as attachWorkspaceSourceRequestExecution } from "./request-execution-Dk9rY-Yh.js";
|
|
7
|
+
import { d as normalizeHistoryRef, f as requireWorkspaceHistory, l as historyConflict, p as validateHistoryMessage } from "./utils-Blrh4N2n.js";
|
|
8
|
+
import { i as assertPublicWorkspaceMetaKey, t as createWorkspace } from "./workspace-6pxkOuxr.js";
|
|
9
|
+
import { c as workspaceInternalMetadataCapability, o as resolveWorkspaceMetadataTarget, r as forwardWorkspaceMetadataTarget, t as attachWorkspaceMetadataTarget } from "./metadata-target-DZEZQGHA.js";
|
|
10
|
+
import { n as useWorkspaceAssets } from "./asset-registry-DfBV5kmw.js";
|
|
11
|
+
import { a as useRegisteredWorkspace } from "./registry-Bp-8UUfG.js";
|
|
12
|
+
import { t as createHostedWorkspaceSession } from "./host-CFnrTXTK.js";
|
|
10
13
|
import { getViteHubErrorShape } from "@vite-hub/runtime";
|
|
11
14
|
//#region src/core/use.ts
|
|
12
15
|
const workspaceDefinitionSyncStates = /* @__PURE__ */ new WeakMap();
|
|
13
16
|
async function workspaceDefinitionSyncState(workspace) {
|
|
14
|
-
const owner = await workspace
|
|
17
|
+
const owner = await resolveWorkspaceMetadataTarget(workspace) ?? workspace;
|
|
15
18
|
const key = workspace.__workspaceDefinitionSyncKey ?? workspace;
|
|
16
19
|
let states = workspaceDefinitionSyncStates.get(owner);
|
|
17
20
|
if (!states) {
|
|
@@ -69,10 +72,10 @@ async function materializeWorkspaceSources(workspace, options) {
|
|
|
69
72
|
if (!workspace.materializeSources) throw workspaceError("[vitehub] Workspace source materialization is unavailable.");
|
|
70
73
|
return await workspace.materializeSources(options);
|
|
71
74
|
}
|
|
72
|
-
function createLazyWorkspace(name, definition) {
|
|
75
|
+
function createLazyWorkspace(name, definition, options = {}) {
|
|
73
76
|
let workspacePromise;
|
|
74
77
|
async function resolveWorkspace() {
|
|
75
|
-
workspacePromise ||= definition ? Promise.resolve(createWorkspace(definition)) : useRegisteredWorkspace(name);
|
|
78
|
+
workspacePromise ||= definition ? Promise.resolve(createWorkspace(definition, options)) : useRegisteredWorkspace(name, options);
|
|
76
79
|
return await workspacePromise;
|
|
77
80
|
}
|
|
78
81
|
async function resolveSyncedWorkspace(abortSignal) {
|
|
@@ -114,17 +117,39 @@ function createLazyWorkspace(name, definition) {
|
|
|
114
117
|
}
|
|
115
118
|
}
|
|
116
119
|
}
|
|
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
|
-
},
|
|
120
|
+
const workspace = {
|
|
127
121
|
name,
|
|
122
|
+
history: {
|
|
123
|
+
digest: async (bytes) => {
|
|
124
|
+
const history = (await resolveWorkspace()).history;
|
|
125
|
+
return history?.digest ? await history.digest(bytes) : await sha256(bytes);
|
|
126
|
+
},
|
|
127
|
+
forksFrom: async (ref) => await (await resolveWorkspace()).history?.forksFrom?.(ref),
|
|
128
|
+
pullRequests: async (options) => await (await resolveWorkspace()).history?.pullRequests?.(options) ?? [],
|
|
129
|
+
merge: async (options) => {
|
|
130
|
+
const history = (await resolveWorkspace()).history;
|
|
131
|
+
if (!history?.merge) throw workspaceError("[vitehub] This Workspace Store cannot merge refs.");
|
|
132
|
+
return await history.merge(options);
|
|
133
|
+
},
|
|
134
|
+
openPullRequest: async (options) => {
|
|
135
|
+
const history = (await resolveWorkspace()).history;
|
|
136
|
+
if (!history?.openPullRequest) throw workspaceError("[vitehub] This Workspace Store cannot open pull requests.");
|
|
137
|
+
return await history.openPullRequest(options);
|
|
138
|
+
},
|
|
139
|
+
head: async (options) => await requireWorkspaceHistory(await resolveWorkspace()).head(options),
|
|
140
|
+
list: async (options) => await requireWorkspaceHistory(await resolveWorkspace()).list(options),
|
|
141
|
+
refs: async () => await requireWorkspaceHistory(await resolveWorkspace()).refs(),
|
|
142
|
+
open: async (id) => await requireWorkspaceHistory(await resolveWorkspace()).open(id),
|
|
143
|
+
usage: async () => await requireWorkspaceHistory(await resolveWorkspace()).usage(),
|
|
144
|
+
commit: async (options) => {
|
|
145
|
+
const history = requireWorkspaceHistory(await resolveWorkspace());
|
|
146
|
+
validateHistoryMessage(options.message);
|
|
147
|
+
const ref = normalizeHistoryRef(options.ref);
|
|
148
|
+
const head = await history.head({ ref });
|
|
149
|
+
if ((head?.id ?? null) !== options.ifHead) throw historyConflict(ref, options.ifHead, head?.id ?? null);
|
|
150
|
+
return await requireWorkspaceHistory(await resolveSyncedWorkspace()).commit(options);
|
|
151
|
+
}
|
|
152
|
+
},
|
|
128
153
|
async capabilities() {
|
|
129
154
|
return await (await resolveWorkspace()).capabilities?.() ?? { conditionalWrites: false };
|
|
130
155
|
},
|
|
@@ -176,9 +201,6 @@ function createLazyWorkspace(name, definition) {
|
|
|
176
201
|
async materializeSources(options) {
|
|
177
202
|
return await materializeWorkspaceSources(await resolveSyncedWorkspace(options?.abortSignal), options);
|
|
178
203
|
},
|
|
179
|
-
async publish(options) {
|
|
180
|
-
await (await resolvePublishWorkspace()).publish(options);
|
|
181
|
-
},
|
|
182
204
|
async snapshot(options) {
|
|
183
205
|
return await (await resolveSyncedWorkspace()).snapshot(options);
|
|
184
206
|
},
|
|
@@ -194,15 +216,18 @@ function createLazyWorkspace(name, definition) {
|
|
|
194
216
|
async getMeta(key) {
|
|
195
217
|
return await (await resolveWorkspace()).getMeta?.(key);
|
|
196
218
|
},
|
|
197
|
-
async setMeta(key, value) {
|
|
198
|
-
await (await resolveWorkspace()).setMeta?.(key, value);
|
|
219
|
+
async setMeta(key, value, capability) {
|
|
220
|
+
await (await resolveWorkspace()).setMeta?.(capability === workspaceInternalMetadataCapability ? key : assertPublicWorkspaceMetaKey(key), value, capability);
|
|
199
221
|
},
|
|
200
222
|
async startSession(options) {
|
|
201
223
|
return await (await resolveSyncedWorkspace()).startSession(options);
|
|
202
224
|
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
225
|
+
};
|
|
226
|
+
attachWorkspaceMetadataTarget(workspace, async () => await resolveWorkspaceMetadataTarget(await resolveWorkspace()));
|
|
227
|
+
return attachWorkspaceSourceRequestExecution(workspace, { async executeSourceRequest(input) {
|
|
228
|
+
const resolved = await resolveSyncedWorkspace();
|
|
229
|
+
const executor = getWorkspaceSourceRequestExecution(resolved);
|
|
230
|
+
if (!executor) throw workspaceErrorDiagnostics.WORKSPACE_R0025({ message: "[vitehub] No API-backed Source request executor is available for this workspace." });
|
|
206
231
|
return await executor.executeSourceRequest(input);
|
|
207
232
|
} });
|
|
208
233
|
}
|
|
@@ -327,31 +352,34 @@ function createReadonlyFs(name, workspace) {
|
|
|
327
352
|
},
|
|
328
353
|
startSession: async (options) => {
|
|
329
354
|
if (!assets || !options?.host) return await workspace.startSession(options);
|
|
330
|
-
|
|
355
|
+
const overlay = Object.assign(Object.create(workspace), {
|
|
331
356
|
exists: readonlyFs.exists,
|
|
332
357
|
glob: readonlyFs.glob,
|
|
333
358
|
list: readonlyFs.list,
|
|
334
359
|
readFile: readonlyFs.readFile,
|
|
335
360
|
search: readonlyFs.search,
|
|
336
361
|
stat: readonlyFs.stat
|
|
337
|
-
})
|
|
362
|
+
});
|
|
363
|
+
return await createHostedWorkspaceSession(overlay, {
|
|
338
364
|
...options,
|
|
339
365
|
host: options.host
|
|
340
366
|
});
|
|
341
367
|
}
|
|
342
368
|
}, getWorkspaceSourceRequestExecution(workspace));
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
const metadata = await ignoreMissingWorkspace(async () => await resolveMetadata.call(workspace));
|
|
369
|
+
attachWorkspaceMetadataTarget(readonlyFs, async () => {
|
|
370
|
+
const metadata = await ignoreMissingWorkspace(async () => await resolveWorkspaceMetadataTarget(workspace));
|
|
346
371
|
if (!metadata && !assets) return;
|
|
347
|
-
|
|
372
|
+
const target = {
|
|
373
|
+
workspaceName: metadata?.workspaceName,
|
|
348
374
|
getMeta: metadata?.getMeta?.bind(metadata),
|
|
349
375
|
list: async (path, options) => {
|
|
350
376
|
const assetPath = path;
|
|
351
377
|
return mergeEntries(assets ? await assets.list(assetPath, options) : [], await metadata?.list?.(path, options) ?? []);
|
|
352
378
|
}
|
|
353
379
|
};
|
|
354
|
-
|
|
380
|
+
if (metadata) forwardWorkspaceStoreTarget(metadata, target);
|
|
381
|
+
return target;
|
|
382
|
+
});
|
|
355
383
|
return readonlyFs;
|
|
356
384
|
}
|
|
357
385
|
function toReadOperations(options) {
|
|
@@ -390,6 +418,7 @@ function useWorkspace(name, options) {
|
|
|
390
418
|
maxShellCalls: opts?.maxShellCalls,
|
|
391
419
|
maxOutputLength: opts?.maxOutputLength,
|
|
392
420
|
operations: toWriteOperations(opts),
|
|
421
|
+
sourceRequests: opts?.sourceRequests,
|
|
393
422
|
timeout: opts?.timeout
|
|
394
423
|
});
|
|
395
424
|
const createReadTools = (opts) => createWorkspaceTools(createReadonlyFs(name, workspace), {
|
|
@@ -398,13 +427,14 @@ function useWorkspace(name, options) {
|
|
|
398
427
|
maxShellCalls: opts?.maxShellCalls,
|
|
399
428
|
maxOutputLength: opts?.maxOutputLength,
|
|
400
429
|
operations: toReadOperations(opts),
|
|
430
|
+
sourceRequests: opts?.sourceRequests,
|
|
401
431
|
timeout: opts?.timeout
|
|
402
432
|
});
|
|
403
433
|
const tools = createDefaultToolSet(createTools);
|
|
404
434
|
tools.inspect = createReadTools;
|
|
405
435
|
tools.write = createTools;
|
|
406
436
|
tools.none = emptyTools;
|
|
407
|
-
|
|
437
|
+
const facade = {
|
|
408
438
|
[workspaceStoreTarget]: async () => {
|
|
409
439
|
return await workspace[workspaceStoreTarget]?.();
|
|
410
440
|
},
|
|
@@ -412,20 +442,22 @@ function useWorkspace(name, options) {
|
|
|
412
442
|
diff: async (options) => await workspace.diff(options),
|
|
413
443
|
fs: createWritableFs(name, workspace),
|
|
414
444
|
history: {
|
|
445
|
+
...workspace.history,
|
|
415
446
|
checkpoint: async (options) => await workspace.snapshot({ name: options?.message }),
|
|
416
447
|
rebase: async (options) => await workspace.rebase(options)
|
|
417
448
|
},
|
|
418
449
|
getMeta: async (key) => await workspace.getMeta?.(key),
|
|
419
450
|
materializeSources: async (options) => await materializeWorkspaceSources(workspace, options),
|
|
420
|
-
|
|
421
|
-
setMeta: async (key, value) => await workspace.setMeta?.(key, value),
|
|
451
|
+
setMeta: async (key, value, capability) => await workspace.setMeta?.(key, value, capability),
|
|
422
452
|
snapshot: async (options) => await workspace.snapshot(options),
|
|
423
453
|
startSession: async (options) => await workspace.startSession(options),
|
|
424
454
|
sync: async (options) => await workspace.sync(options),
|
|
425
455
|
tools
|
|
426
456
|
};
|
|
457
|
+
forwardWorkspaceMetadataTarget(workspace, facade);
|
|
458
|
+
return facade;
|
|
427
459
|
}
|
|
428
|
-
const workspace = createLazyWorkspace(name, options?.definition);
|
|
460
|
+
const workspace = createLazyWorkspace(name, options?.definition, { reuseStartupSnapshots: options?.refresh === false });
|
|
429
461
|
const fs = createReadonlyFs(name, workspace);
|
|
430
462
|
const createTools = (opts) => createWorkspaceTools(fs, {
|
|
431
463
|
broadSearchPaths: opts?.broadSearchPaths,
|
|
@@ -433,6 +465,7 @@ function useWorkspace(name, options) {
|
|
|
433
465
|
maxShellCalls: opts?.maxShellCalls,
|
|
434
466
|
maxOutputLength: opts?.maxOutputLength,
|
|
435
467
|
operations: toReadOperations(opts),
|
|
468
|
+
sourceRequests: opts?.sourceRequests,
|
|
436
469
|
timeout: opts?.timeout
|
|
437
470
|
});
|
|
438
471
|
const tools = createDefaultToolSet(createTools);
|
|
@@ -440,10 +473,18 @@ function useWorkspace(name, options) {
|
|
|
440
473
|
tools.none = emptyTools;
|
|
441
474
|
const facade = {
|
|
442
475
|
fs,
|
|
476
|
+
history: {
|
|
477
|
+
head: (options) => requireWorkspaceHistory(workspace).head(options),
|
|
478
|
+
list: (options) => requireWorkspaceHistory(workspace).list(options),
|
|
479
|
+
refs: () => requireWorkspaceHistory(workspace).refs(),
|
|
480
|
+
open: (id) => requireWorkspaceHistory(workspace).open(id),
|
|
481
|
+
usage: () => requireWorkspaceHistory(workspace).usage()
|
|
482
|
+
},
|
|
443
483
|
getMeta: async (key) => await workspace.getMeta?.(key),
|
|
444
484
|
tools
|
|
445
485
|
};
|
|
446
486
|
forwardWorkspaceMetadataTarget(fs, facade);
|
|
487
|
+
forwardWorkspaceStoreTarget(workspace, facade);
|
|
447
488
|
return facade;
|
|
448
489
|
}
|
|
449
490
|
//#endregion
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as WorkspaceReadOperations, d as WorkspaceWriteToolMap, n as ShellEnabled, o as WorkspaceShellResult, u as WorkspaceWriteOperations } from "./ai-
|
|
1
|
+
import { D as WorkspaceAssets, E as WorkspaceAssetPath, F as WorkspaceDefinition, Ft as WorkspaceSearchHit, Ht as WorkspaceSessionOptions, In as WriteFileOptions, It as WorkspaceSearchQuery, L as WorkspaceDiff, M as WorkspaceContent, Ot as WorkspaceRebaseOptions, Rt as WorkspaceSession, St as WorkspaceName, Tn as WorkspaceSyncOptions, Wt as WorkspaceSnapshot, _ as ReadFileResult, _n as WorkspaceSourceSyncResult, b as RmOptions, c as GlobOptions, ft as WorkspaceMaterializeSourcesOptions, g as ReadFileOptions, h as MkdirOptions, j as WorkspaceCapabilities, kt as WorkspaceRetainedHistory, l as ListOptions, mt as WorkspaceMaterializeSourcesResult, n as DiffOptions, nt as WorkspaceHistoryReader, x as SnapshotOptions, yn as WorkspaceStat, z as WorkspaceEntry } from "./types-DeK9GIxy.js";
|
|
2
|
+
import { a as WorkspaceReadOperations, d as WorkspaceWriteToolMap, n as ShellEnabled, o as WorkspaceShellResult, u as WorkspaceWriteOperations } from "./ai-BW2ZhizI.js";
|
|
3
|
+
import { ExecutionBudget } from "@vite-hub/runtime";
|
|
3
4
|
import { Tool, ToolSet } from "ai";
|
|
4
|
-
|
|
5
5
|
//#region src/core/use.d.ts
|
|
6
6
|
type WorkspaceWritablePath<Name extends WorkspaceName> = WorkspaceAssetPath<Name> | (string & {});
|
|
7
7
|
interface UseWorkspaceOptions {
|
|
8
8
|
definition?: WorkspaceDefinition;
|
|
9
9
|
mode?: "read" | "write";
|
|
10
|
+
refresh?: boolean;
|
|
10
11
|
}
|
|
11
12
|
interface WorkspaceFacadeToolOptions extends WorkspaceReadOperations {
|
|
12
13
|
broadSearchPaths?: string[];
|
|
13
14
|
cwd?: string;
|
|
15
|
+
executionBudget?: ExecutionBudget;
|
|
14
16
|
maxShellCalls?: number;
|
|
15
17
|
maxOutputLength?: number;
|
|
18
|
+
sourceRequests?: boolean;
|
|
16
19
|
timeout?: number;
|
|
17
20
|
}
|
|
18
21
|
interface WritableWorkspaceFacadeToolOptions extends WorkspaceFacadeToolOptions, WorkspaceWriteOperations {}
|
|
19
22
|
type EnabledWriteCapability<Options, Key extends keyof WorkspaceWriteOperations> = Options extends Record<Key, infer Value> ? Value extends false ? false : true : true;
|
|
20
|
-
type WorkspaceReadTools<Options = undefined> = ((ShellEnabled<Options
|
|
23
|
+
type WorkspaceReadTools<Options = undefined> = ((ShellEnabled<Options, Options extends {
|
|
24
|
+
sourceRequests: true;
|
|
25
|
+
} ? true : false> extends true ? {
|
|
21
26
|
shell: Tool<{
|
|
22
27
|
command: string;
|
|
23
28
|
}, WorkspaceShellResult>;
|
|
@@ -29,7 +34,7 @@ type WorkspaceReadTools<Options = undefined> = ((ShellEnabled<Options> extends t
|
|
|
29
34
|
sources?: string[];
|
|
30
35
|
}, WorkspaceMaterializeSourcesResult>;
|
|
31
36
|
} : {}) & ToolSet);
|
|
32
|
-
type WorkspaceWriteTools<Options = undefined> = WorkspaceReadTools<Options> & { [Key in keyof WorkspaceWriteToolMap as EnabledWriteCapability<Options, Key> extends true ? Key : never]: WorkspaceWriteToolMap[Key] } & ToolSet;
|
|
37
|
+
type WorkspaceWriteTools<Options = undefined> = WorkspaceReadTools<Options> & { [Key in keyof WorkspaceWriteToolMap as EnabledWriteCapability<Options, Key> extends true ? Key : never]: WorkspaceWriteToolMap[Key]; } & ToolSet;
|
|
33
38
|
type WorkspaceReadToolSet = WorkspaceReadTools & {
|
|
34
39
|
inspect: <Options extends WorkspaceFacadeToolOptions | undefined = undefined>(options?: Options) => WorkspaceReadTools<Options>;
|
|
35
40
|
none: () => ToolSet;
|
|
@@ -71,10 +76,11 @@ interface WritableWorkspaceFs<Name extends WorkspaceName = WorkspaceName> {
|
|
|
71
76
|
}
|
|
72
77
|
interface ReadonlyWorkspaceFacade<Name extends WorkspaceName = WorkspaceName> {
|
|
73
78
|
fs: ReadonlyWorkspaceFs<Name>;
|
|
79
|
+
history: WorkspaceHistoryReader;
|
|
74
80
|
getMeta?(key: string): Promise<unknown>;
|
|
75
81
|
tools: WorkspaceReadToolSet;
|
|
76
82
|
}
|
|
77
|
-
interface WorkspaceHistory extends History<WorkspaceSnapshot
|
|
83
|
+
interface WorkspaceHistory extends History<WorkspaceSnapshot>, WorkspaceRetainedHistory {
|
|
78
84
|
rebase(options?: WorkspaceRebaseOptions): Promise<void>;
|
|
79
85
|
}
|
|
80
86
|
interface WritableWorkspaceFacade<Name extends WorkspaceName = WorkspaceName> {
|
|
@@ -84,8 +90,7 @@ interface WritableWorkspaceFacade<Name extends WorkspaceName = WorkspaceName> {
|
|
|
84
90
|
history: WorkspaceHistory;
|
|
85
91
|
getMeta?(key: string): Promise<unknown>;
|
|
86
92
|
materializeSources(options?: WorkspaceMaterializeSourcesOptions): Promise<WorkspaceMaterializeSourcesResult>;
|
|
87
|
-
|
|
88
|
-
setMeta?(key: string, value: unknown): Promise<void>;
|
|
93
|
+
setMeta?(key: string, value: unknown, capability?: symbol): Promise<void>;
|
|
89
94
|
snapshot(options?: SnapshotOptions): Promise<WorkspaceSnapshot>;
|
|
90
95
|
startSession(options?: WorkspaceSessionOptions): Promise<WorkspaceSession>;
|
|
91
96
|
sync(options: WorkspaceSyncOptions): Promise<WorkspaceSourceSyncResult>;
|
|
@@ -93,10 +98,10 @@ interface WritableWorkspaceFacade<Name extends WorkspaceName = WorkspaceName> {
|
|
|
93
98
|
}
|
|
94
99
|
type WorkspaceFacade<Name extends WorkspaceName = WorkspaceName, Mode extends UseWorkspaceOptions["mode"] = "read"> = Mode extends "write" ? WritableWorkspaceFacade<Name> : ReadonlyWorkspaceFacade<Name>;
|
|
95
100
|
declare function useWorkspace<Name extends WorkspaceName>(name: Name): ReadonlyWorkspaceFacade<Name>;
|
|
96
|
-
declare function useWorkspace<Name extends WorkspaceName>(name: Name, options: {
|
|
97
|
-
mode
|
|
101
|
+
declare function useWorkspace<Name extends WorkspaceName>(name: Name, options: UseWorkspaceOptions & {
|
|
102
|
+
mode?: "read";
|
|
98
103
|
}): ReadonlyWorkspaceFacade<Name>;
|
|
99
|
-
declare function useWorkspace<Name extends WorkspaceName>(name: Name, options: {
|
|
104
|
+
declare function useWorkspace<Name extends WorkspaceName>(name: Name, options: UseWorkspaceOptions & {
|
|
100
105
|
mode: "write";
|
|
101
106
|
}): WritableWorkspaceFacade<Name>;
|
|
102
107
|
//#endregion
|