@vite-hub/workspace 0.1.0 → 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 +164 -107
- package/dist/abort-BCwpdrN0.js +32 -0
- package/dist/blob-database.d.ts +70 -117
- package/dist/blob-database.js +48 -41
- package/dist/checkout.d.ts +128 -0
- package/dist/checkout.js +849 -0
- package/dist/cloudflare.d.ts +2 -2
- package/dist/cloudflare.js +1 -1
- package/dist/config-B-863EgC.js +15 -0
- package/dist/{config-B7dmzDX3.js → config-BAgL2dtB.js} +48 -84
- package/dist/{config-DLKdaFWN.d.ts → config-BQKcPawI.d.ts} +1 -1
- 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-C7Px8uaC.js → files-BOo4SbwE.js} +2 -2
- package/dist/files.d.ts +38 -0
- package/dist/files.js +6 -0
- package/dist/{github-CPxHtFB7.js → github-CrYp4v8k.js} +32 -5
- package/dist/{glob--XcLlcml.js → glob-B8YGvTrZ.js} +4 -5
- package/dist/{glob--kNYDbfU.js → glob-Cjxms1t7.js} +1 -1
- package/dist/{host-CFnrTXTK.js → host-BFBpXn0N.js} +58 -47
- package/dist/{hosted-acMA5XyL.js → hosted-KcUR_jPv.js} +216 -93
- package/dist/hosted-vercel-blob-B3-wRdUm.js +410 -0
- package/dist/hosted-vercel-blob.d.ts +2 -2
- package/dist/hosted-vercel-blob.js +1 -1
- package/dist/hosted.d.ts +5 -3
- package/dist/hosted.js +2 -2
- package/dist/index.d.ts +9 -51
- package/dist/index.js +21 -91
- package/dist/{lifecycle-BwZ7c9hb.js → lifecycle-B-enk_4A.js} +8 -8
- package/dist/lineage.d.ts +26 -0
- package/dist/lineage.js +76 -0
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js +2 -2
- package/dist/{mcp-resources-BREFCmtn.js → mcp-resources-DF0F5rcL.js} +2 -2
- package/dist/{memory-BbwOqDXl.js → memory-BOexthyW.js} +3 -4
- package/dist/{metadata-target-DZEZQGHA.js → metadata-target-CWz6KHKq.js} +17 -16
- 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 +41 -4
- package/dist/operations.js +3 -2
- package/dist/{path-CNAwN7pw.js → path--wrT_Azm.js} +2 -3
- package/dist/path-AxMho1wo.d.ts +7 -0
- package/dist/{plugins-DqQ8b4T5.d.ts → plugins-C8C0auoW.d.ts} +1 -1
- package/dist/{provider-kXjfli9u.js → provider-9s4Ufkm5.js} +104 -82
- package/dist/providers/github/store.d.ts +1 -1
- package/dist/providers/github/store.js +1 -1
- package/dist/registry-B3BBm4Ts.d.ts +19 -0
- package/dist/{registry-Bp-8UUfG.js → registry-CNphafBx.js} +55 -20
- 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/{rolldown-runtime-B4iAMlE-.js → rolldown-runtime-rQ84J-ij.js} +2 -3
- package/dist/runtime/assets.d.ts +1 -1
- package/dist/runtime/assets.js +3 -3
- package/dist/runtime/empty-assets-registry.d.ts +1 -1
- package/dist/runtime/empty-registry.d.ts +2 -1
- 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 +9 -8
- package/dist/runtime.js +23 -26
- package/dist/{search-CrTmXj5h.js → search-C_RfoM2j.js} +2 -2
- package/dist/{server-BNQ-Nbjj.js → server-8tGltlGz.js} +53 -40
- package/dist/server.d.ts +17 -8
- package/dist/server.js +1 -1
- package/dist/shared-B3_EUk89.js +848 -0
- package/dist/source-metadata.d.ts +6 -2
- package/dist/source-metadata.js +8 -8
- package/dist/state-BISnUf1s.d.ts +35 -0
- package/dist/{ai-BZyLwULx.js → state-DbrW-njQ.js} +96 -54
- package/dist/{store-CXgmu-uw.js → store-ybhyD38Z.js} +250 -106
- package/dist/{sync-CN6ec-5M.js → sync-CCD_VYC8.js} +4 -4
- package/dist/target-jWhTdIuF.js +89 -0
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/{types-DeK9GIxy.d.ts → types-BbtwmBZ5.d.ts} +68 -14
- package/dist/use-C6lV3-wC.d.ts +321 -0
- package/dist/{use-BQj7nSz6.js → use-CSpT5W87.js} +75 -82
- package/dist/{utils-Blrh4N2n.js → utils-CgMZCHsX.js} +112 -41
- package/dist/vite.d.ts +585 -2
- package/dist/vite.js +21368 -1
- package/dist/{workspace-BWJQBK1u.d.ts → workspace-CYB2xZ1T.d.ts} +1 -1
- package/dist/{workspace-6pxkOuxr.js → workspace-sPWn2Jxj.js} +125 -40
- package/package.json +46 -55
- package/dist/ai-BW2ZhizI.d.ts +0 -177
- package/dist/ai.d.ts +0 -3
- package/dist/ai.js +0 -2
- package/dist/association-Cm0dUTDU-CDDhJnIh-Cv3bWnVb.js +0 -19
- package/dist/error-diagnostics-A_8Kp-48.js +0 -116
- package/dist/error-diagnostics-DY5GP47p.js +0 -96
- package/dist/events-7EBoeIPd-A2RUkJi5-BxrICQ17.js +0 -354
- package/dist/events-CRaLy7U3-3PNNp5WZ-Gv9nd0cH.js +0 -214
- package/dist/events-CeChclTf-CX-gD8oy-4aL2j6V-.js +0 -527
- package/dist/feed-DsC7Vws1-M_de2nSK-tKc0Pwo8.js +0 -248
- package/dist/feed-Dyf730Ys-D0HgBba6-BUnCa5gS.js +0 -179
- package/dist/file-C0_aPWSS.js +0 -26
- package/dist/file-metadata-CxDy-E2H.js +0 -58
- package/dist/forgejo-BN8ItCfl-Bbn4vhDd.js +0 -2278
- package/dist/github-DtncTfmv-Du2S8lGF.js +0 -4159
- package/dist/gitlab-BoDm8-BC-xzZsW9eW.js +0 -2530
- package/dist/graphql-DG5aJBT3-DceyFYdM-C4saqX37.js +0 -489
- package/dist/hosted-vercel-blob-DKntsHaf.js +0 -12603
- package/dist/inspect-BoObD2cJ.js +0 -167
- package/dist/mountx.d.ts +0 -8
- package/dist/mountx.js +0 -145
- package/dist/nitro.d.ts +0 -2
- package/dist/nitro.js +0 -2
- package/dist/nuxt.d.ts +0 -27
- package/dist/nuxt.js +0 -38
- package/dist/operations-BcpWr41m.js +0 -159
- package/dist/operations-CGqY1XeG.js +0 -965
- package/dist/operations-DnOwKsJT.d.ts +0 -136
- package/dist/registry-Cg1TJVVZ.d.ts +0 -10
- package/dist/request-execution-Dk9rY-Yh.js +0 -84
- package/dist/shared-DalXdP0i.js +0 -2158
- package/dist/state-B8zbLi5t.d.ts +0 -26
- package/dist/target-D4Bqb1eH.js +0 -11
- package/dist/templates-Bn8a-pd2-D9DhJEVD-CBfXNRzz.js +0 -125
- package/dist/token-CO62GglH.js +0 -61
- package/dist/use-DhwhbAVV.d.ts +0 -108
- package/dist/vite-BEvgU2GY.js +0 -20909
- package/dist/vite-CcZmMQ7S.d.ts +0 -476
- package/dist/webhooks-DgHwxxYz-D1V2LOr1-azofFOiP.js +0 -1565
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as workspaceSourceGrantPaths, n as normalizeWorkspaceSourceMetadata, r as normalizeWorkspaceSourcesMetadata, t as WorkspaceSourceMetadata } from "./config-
|
|
1
|
+
import { $t as WorkspaceSourceMaterializationStatus, B as WorkspaceEntry, Pt as WorkspaceRules } from "./types-BbtwmBZ5.js";
|
|
2
|
+
import { i as workspaceSourceGrantPaths, n as normalizeWorkspaceSourceMetadata, r as normalizeWorkspaceSourcesMetadata, t as WorkspaceSourceMetadata } from "./config-BQKcPawI.js";
|
|
3
|
+
//#region src/core/rule-keys.d.ts
|
|
4
|
+
/** Rejects rule keys that ViteHub does not enforce, such as `read`, so that a rule never looks like a protection it is not. */
|
|
5
|
+
export declare function assertWorkspaceRules(rules: WorkspaceRules | undefined): void;
|
|
6
|
+
//#endregion
|
|
3
7
|
//#region src/source-metadata.d.ts
|
|
4
8
|
export declare function listMaterializedWorkspaceEntries(workspace: unknown): Promise<WorkspaceEntry[] | undefined>;
|
|
5
9
|
export declare function listMaterializedWorkspaceSourceEntries(workspace: unknown, source: WorkspaceSourceMetadata): Promise<WorkspaceEntry[] | undefined>;
|
package/dist/source-metadata.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { i as assertWorkspaceRules } from "./target-jWhTdIuF.js";
|
|
2
|
+
import { i as normalizeWorkspaceSourceMetadata, l as workspaceSourceGrantPaths, o as normalizeWorkspaceSourcesMetadata } from "./config-BAgL2dtB.js";
|
|
3
|
+
import { m as readCurrentSourceSnapshot, o as resolveWorkspaceMetadataTarget } from "./metadata-target-CWz6KHKq.js";
|
|
4
4
|
//#region src/source-metadata.ts
|
|
5
5
|
async function listMaterializedWorkspaceEntries(workspace) {
|
|
6
6
|
return await (await resolveWorkspaceMetadataTarget(workspace))?.list?.("", { recursive: true });
|
|
@@ -20,15 +20,15 @@ async function readWorkspaceSourceMaterializationStatus(workspace, source) {
|
|
|
20
20
|
const metadata = await resolveWorkspaceMetadataTarget(workspace);
|
|
21
21
|
if (metadata?.workspaceName === void 0) return;
|
|
22
22
|
const snapshot = await readCurrentSourceSnapshot(metadata, metadata.workspaceName, source);
|
|
23
|
-
if (
|
|
23
|
+
if (typeof snapshot !== "object" || snapshot === null) return;
|
|
24
24
|
const status = snapshot.status;
|
|
25
25
|
if (status !== "lazy" && status !== "updating" && status !== "ready" && status !== "error") return;
|
|
26
26
|
return {
|
|
27
|
-
materializedAt:
|
|
28
|
-
mountPath:
|
|
29
|
-
source:
|
|
27
|
+
materializedAt: typeof snapshot.materializedAt === "string" ? snapshot.materializedAt : void 0,
|
|
28
|
+
mountPath: typeof snapshot.mountPath === "string" ? snapshot.mountPath : "",
|
|
29
|
+
source: typeof snapshot.source === "string" ? snapshot.source : source.key,
|
|
30
30
|
status
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
//#endregion
|
|
34
|
-
export { listMaterializedWorkspaceEntries, listMaterializedWorkspaceSourceEntries, normalizeWorkspaceSourceMetadata, normalizeWorkspaceSourcesMetadata, readWorkspaceSourceMaterializationStatus, workspaceSourceGrantPaths };
|
|
34
|
+
export { assertWorkspaceRules, listMaterializedWorkspaceEntries, listMaterializedWorkspaceSourceEntries, normalizeWorkspaceSourceMetadata, normalizeWorkspaceSourcesMetadata, readWorkspaceSourceMaterializationStatus, workspaceSourceGrantPaths };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { O as WorkspaceAssetsRegistry, St as WorkspaceName, s as GitHubWorkspaceStoreOptions, t as CloudflareArtifactsWorkspaceStoreOptions, w as VercelBlobWorkspaceStoreOptions, xn as WorkspaceStore } from "./types-BbtwmBZ5.js";
|
|
2
|
+
import { h as WritableWorkspaceFacade, i as ReadonlyWorkspaceFacade, s as UseWorkspaceOptions } from "./use-C6lV3-wC.js";
|
|
3
|
+
import { t as WorkspaceRegistry } from "./registry-B3BBm4Ts.js";
|
|
4
|
+
import "./registry-CYNN623b.js";
|
|
5
|
+
//#region ../internal/src/runtime/cloudflare-env-lookup.d.ts
|
|
6
|
+
type CloudflareWorkerEnv = Record<string, unknown>;
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region ../internal/src/runtime/cloudflare-env.d.ts
|
|
9
|
+
declare function setActiveCloudflareEnv(env: CloudflareWorkerEnv | undefined): void;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/core/use-tools.d.ts
|
|
12
|
+
declare function useWorkspace<Name extends WorkspaceName>(name: Name): ReadonlyWorkspaceFacade<Name>;
|
|
13
|
+
declare function useWorkspace<Name extends WorkspaceName>(name: Name, options: UseWorkspaceOptions & {
|
|
14
|
+
mode?: "read";
|
|
15
|
+
}): ReadonlyWorkspaceFacade<Name>;
|
|
16
|
+
declare function useWorkspace<Name extends WorkspaceName>(name: Name, options: UseWorkspaceOptions & {
|
|
17
|
+
mode: "write";
|
|
18
|
+
}): WritableWorkspaceFacade<Name>;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/core/workspace-cache.d.ts
|
|
21
|
+
declare function resetWorkspaceStoreCache(): void;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/runtime/hosted-store-loader.d.ts
|
|
24
|
+
type HostedWorkspaceStoreOptions = CloudflareArtifactsWorkspaceStoreOptions | GitHubWorkspaceStoreOptions | VercelBlobWorkspaceStoreOptions;
|
|
25
|
+
/** Returns `undefined` when no installed hosted store handles `options.provider`. */
|
|
26
|
+
type WorkspaceHostedStoreLoader = (options: HostedWorkspaceStoreOptions, workspaceName: string) => WorkspaceStore | undefined;
|
|
27
|
+
declare function setWorkspaceHostedStoreLoader(loader: WorkspaceHostedStoreLoader | undefined): void;
|
|
28
|
+
declare function getWorkspaceHostedStoreLoader(): WorkspaceHostedStoreLoader | undefined;
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/runtime/state.d.ts
|
|
31
|
+
declare function invalidateWorkspaceStore(name: string): Promise<void>;
|
|
32
|
+
declare function setWorkspaceRuntimeRegistry(registry: WorkspaceRegistry): void;
|
|
33
|
+
declare function setWorkspaceRuntimeAssetsRegistry(registry: WorkspaceAssetsRegistry): void;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { WorkspaceHostedStoreLoader as a, resetWorkspaceStoreCache as c, HostedWorkspaceStoreOptions as i, useWorkspace as l, setWorkspaceRuntimeAssetsRegistry as n, getWorkspaceHostedStoreLoader as o, setWorkspaceRuntimeRegistry as r, setWorkspaceHostedStoreLoader as s, invalidateWorkspaceStore as t, setActiveCloudflareEnv as u };
|
|
@@ -1,49 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { r as
|
|
5
|
-
import {
|
|
1
|
+
import { s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
|
|
2
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CtKjGtGb.js";
|
|
3
|
+
import { g as getWorkspaceSourceRequestExecution, n as invalidateCachedWorkspaceStore } from "./workspace-sPWn2Jxj.js";
|
|
4
|
+
import { i as setWorkspaceRegistry, r as resolveRegisteredWorkspaceDefinition } from "./registry-CNphafBx.js";
|
|
5
|
+
import { t as setWorkspaceAssetsRegistry } from "./asset-registry-DfBV5kmw.js";
|
|
6
|
+
import { a as copyWorkspacePath, i as appendWorkspaceFile, n as createWorkspaceFileRuntime, t as createReadonlyFs } from "./use-CSpT5W87.js";
|
|
6
7
|
import { executionBudgetCharged, executionBudgetOverride, markExecutionBudgetHandled } from "@vite-hub/runtime/internal/execution-budget";
|
|
7
|
-
//#region src/fs-ops.ts
|
|
8
|
-
async function ensureMissingOrReplaceable(workspace, path, overwrite = false) {
|
|
9
|
-
if (!await workspace.exists(path)) return;
|
|
10
|
-
if (!overwrite) throw workspaceError(`[vitehub] Workspace path already exists: ${path}.`);
|
|
11
|
-
await workspace.rm(path, {
|
|
12
|
-
recursive: true,
|
|
13
|
-
force: true
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
async function copyWorkspacePath(workspace, from, to, overwrite = false) {
|
|
17
|
-
if (from === to) throw workspaceError("[vitehub] Source and destination must be different.");
|
|
18
|
-
const source = await workspace.stat(from);
|
|
19
|
-
if (source.type === "directory" && to.startsWith(`${from}/`)) throw workspaceError("[vitehub] Destination cannot be nested inside the source directory.");
|
|
20
|
-
if (from.startsWith(`${to}/`)) throw workspaceError("[vitehub] Destination cannot contain the source.");
|
|
21
|
-
if (overwrite && await (await resolveWorkspaceStoreTarget(workspace))?.containsPath?.(to, from)) throw workspaceError("[vitehub] Destination cannot contain the source.");
|
|
22
|
-
await ensureMissingOrReplaceable(workspace, to, overwrite);
|
|
23
|
-
if (source.type === "file") {
|
|
24
|
-
const content = await workspace.readFile(from, { encoding: "binary" });
|
|
25
|
-
await workspace.writeFile(to, content, { mediaType: source.mediaType });
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const entries = await workspace.list(from, { recursive: true });
|
|
29
|
-
await workspace.mkdir(to, { recursive: true });
|
|
30
|
-
const directories = entries.filter((entry) => entry.type === "directory").sort((left, right) => left.path.length - right.path.length);
|
|
31
|
-
for (const entry of directories) await workspace.mkdir(posix.join(to, posix.relative(from, entry.path)), { recursive: true });
|
|
32
|
-
await Promise.all(entries.filter((entry) => entry.type === "file").map(async (entry) => {
|
|
33
|
-
const content = await workspace.readFile(entry.path, { encoding: "binary" });
|
|
34
|
-
await workspace.writeFile(posix.join(to, posix.relative(from, entry.path)), content, { mediaType: entry.mediaType });
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
async function appendWorkspaceFile(workspace, path, content) {
|
|
38
|
-
let current = "";
|
|
39
|
-
try {
|
|
40
|
-
current = String(await workspace.readFile(path));
|
|
41
|
-
} catch (error) {
|
|
42
|
-
if (!isWorkspaceError(error)) throw error;
|
|
43
|
-
}
|
|
44
|
-
await workspace.writeFile(path, `${current}${content}`);
|
|
45
|
-
}
|
|
46
|
-
//#endregion
|
|
47
8
|
//#region src/runtime/dependency-loaders.ts
|
|
48
9
|
const shellWorkspaceSpecifier = "@vite-hub/shell/workspace";
|
|
49
10
|
const defaultWorkspaceDependencyRuntimeLoaders = { shellWorkspace: () => import(
|
|
@@ -123,7 +84,7 @@ function getWorkspaceSessionStarter(input) {
|
|
|
123
84
|
function hasOwnMethod(value, key) {
|
|
124
85
|
return Object.hasOwn(value, key) && typeof Reflect.get(value, key) === "function";
|
|
125
86
|
}
|
|
126
|
-
function
|
|
87
|
+
function createWorkspaceSessionShellDriver(starter) {
|
|
127
88
|
return {
|
|
128
89
|
boundary: {
|
|
129
90
|
cwd: true,
|
|
@@ -150,7 +111,7 @@ function createWorkspaceSessionShellProvider(starter) {
|
|
|
150
111
|
});
|
|
151
112
|
let observation;
|
|
152
113
|
try {
|
|
153
|
-
const result = await session.exec("sh", ["-
|
|
114
|
+
const result = await session.exec("sh", ["-c", command], {
|
|
154
115
|
cwd: execOptions.cwd || workspaceMountPoint,
|
|
155
116
|
env: execOptions.env,
|
|
156
117
|
...execOptions.signal ? { abortSignal: execOptions.signal } : {},
|
|
@@ -181,8 +142,8 @@ function createWorkspaceSessionShellProvider(starter) {
|
|
|
181
142
|
}
|
|
182
143
|
};
|
|
183
144
|
}
|
|
184
|
-
async function
|
|
185
|
-
return typeof
|
|
145
|
+
async function resolveShellDriver(driver) {
|
|
146
|
+
return typeof driver === "function" ? await driver() : driver;
|
|
186
147
|
}
|
|
187
148
|
function isUnavailableWorkspaceSession(error) {
|
|
188
149
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -278,17 +239,17 @@ async function runShellCommand(input, command, options) {
|
|
|
278
239
|
if (starter) try {
|
|
279
240
|
const result = await runWorkspaceInspectionCommand(input, command, {
|
|
280
241
|
...inspectionOptions,
|
|
281
|
-
|
|
242
|
+
driver: createWorkspaceSessionShellDriver(starter)
|
|
282
243
|
});
|
|
283
244
|
if (options.budget?.signal.aborted) throw options.budget.signal.reason;
|
|
284
245
|
return result;
|
|
285
246
|
} catch (error) {
|
|
286
247
|
if (!isUnavailableWorkspaceSession(error)) throw error;
|
|
287
248
|
}
|
|
288
|
-
const
|
|
249
|
+
const driver = await resolveShellDriver(options.shellDriver);
|
|
289
250
|
const result = await runWorkspaceInspectionCommand(input, command, {
|
|
290
251
|
...inspectionOptions,
|
|
291
|
-
...
|
|
252
|
+
...driver ? { driver } : {}
|
|
292
253
|
});
|
|
293
254
|
if (options.budget?.signal.aborted) throw options.budget.signal.reason;
|
|
294
255
|
return result;
|
|
@@ -466,7 +427,7 @@ function createWorkspaceTools(input, options = {}) {
|
|
|
466
427
|
broadSearchPaths: options.broadSearchPaths || [],
|
|
467
428
|
commands: shellCommandsFor(resolveReadOperations(options.operations)),
|
|
468
429
|
cwd: options.cwd || workspaceMountPoint,
|
|
469
|
-
|
|
430
|
+
shellDriver: options.shellDriver,
|
|
470
431
|
budget: options.executionBudget,
|
|
471
432
|
materialize: resolveReadOperations(options.operations).materialize,
|
|
472
433
|
maxShellCalls: options.maxShellCalls,
|
|
@@ -561,4 +522,85 @@ function createWorkspaceTools(input, options = {}) {
|
|
|
561
522
|
return result;
|
|
562
523
|
}
|
|
563
524
|
//#endregion
|
|
564
|
-
|
|
525
|
+
//#region src/core/use-tools.ts
|
|
526
|
+
function toReadOperations(options) {
|
|
527
|
+
return {
|
|
528
|
+
list: options?.list,
|
|
529
|
+
materialize: options?.materialize ?? true,
|
|
530
|
+
read: options?.read,
|
|
531
|
+
search: options?.search
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
function toWriteOperations(options) {
|
|
535
|
+
return {
|
|
536
|
+
...toReadOperations(options),
|
|
537
|
+
write: {
|
|
538
|
+
appendFile: options?.appendFile !== false,
|
|
539
|
+
copyPath: options?.copyPath !== false,
|
|
540
|
+
deletePath: options?.deletePath !== false,
|
|
541
|
+
makeDir: options?.makeDir !== false,
|
|
542
|
+
movePath: options?.movePath !== false,
|
|
543
|
+
writeFile: options?.writeFile !== false
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
function createDefaultToolSet(createTools) {
|
|
548
|
+
return createTools();
|
|
549
|
+
}
|
|
550
|
+
function emptyTools() {
|
|
551
|
+
return {};
|
|
552
|
+
}
|
|
553
|
+
function useWorkspace(name, options) {
|
|
554
|
+
const runtime = createWorkspaceFileRuntime(name, options);
|
|
555
|
+
if (runtime.mode === "write") {
|
|
556
|
+
const createTools = (opts) => createWorkspaceTools(runtime.workspace, {
|
|
557
|
+
broadSearchPaths: opts?.broadSearchPaths,
|
|
558
|
+
cwd: opts?.cwd,
|
|
559
|
+
maxShellCalls: opts?.maxShellCalls,
|
|
560
|
+
maxOutputLength: opts?.maxOutputLength,
|
|
561
|
+
operations: toWriteOperations(opts),
|
|
562
|
+
sourceRequests: opts?.sourceRequests,
|
|
563
|
+
timeout: opts?.timeout
|
|
564
|
+
});
|
|
565
|
+
const createReadTools = (opts) => createWorkspaceTools(createReadonlyFs(name, runtime.workspace), {
|
|
566
|
+
broadSearchPaths: opts?.broadSearchPaths,
|
|
567
|
+
cwd: opts?.cwd,
|
|
568
|
+
maxShellCalls: opts?.maxShellCalls,
|
|
569
|
+
maxOutputLength: opts?.maxOutputLength,
|
|
570
|
+
operations: toReadOperations(opts),
|
|
571
|
+
sourceRequests: opts?.sourceRequests,
|
|
572
|
+
timeout: opts?.timeout
|
|
573
|
+
});
|
|
574
|
+
const tools = createDefaultToolSet(createTools);
|
|
575
|
+
tools.inspect = createReadTools;
|
|
576
|
+
tools.write = createTools;
|
|
577
|
+
tools.none = emptyTools;
|
|
578
|
+
return Object.assign(runtime.facade, { tools });
|
|
579
|
+
}
|
|
580
|
+
const createTools = (opts) => createWorkspaceTools(runtime.facade.fs, {
|
|
581
|
+
broadSearchPaths: opts?.broadSearchPaths,
|
|
582
|
+
cwd: opts?.cwd,
|
|
583
|
+
maxShellCalls: opts?.maxShellCalls,
|
|
584
|
+
maxOutputLength: opts?.maxOutputLength,
|
|
585
|
+
operations: toReadOperations(opts),
|
|
586
|
+
sourceRequests: opts?.sourceRequests,
|
|
587
|
+
timeout: opts?.timeout
|
|
588
|
+
});
|
|
589
|
+
const tools = createDefaultToolSet(createTools);
|
|
590
|
+
tools.inspect = createTools;
|
|
591
|
+
tools.none = emptyTools;
|
|
592
|
+
return Object.assign(runtime.facade, { tools });
|
|
593
|
+
}
|
|
594
|
+
//#endregion
|
|
595
|
+
//#region src/runtime/state.ts
|
|
596
|
+
async function invalidateWorkspaceStore(name) {
|
|
597
|
+
invalidateCachedWorkspaceStore(await resolveRegisteredWorkspaceDefinition(name));
|
|
598
|
+
}
|
|
599
|
+
function setWorkspaceRuntimeRegistry(registry) {
|
|
600
|
+
setWorkspaceRegistry(registry);
|
|
601
|
+
}
|
|
602
|
+
function setWorkspaceRuntimeAssetsRegistry(registry) {
|
|
603
|
+
setWorkspaceAssetsRegistry(registry);
|
|
604
|
+
}
|
|
605
|
+
//#endregion
|
|
606
|
+
export { createWorkspaceTools as a, useWorkspace as i, setWorkspaceRuntimeAssetsRegistry as n, getWorkspaceDependencyRuntimeLoaders as o, setWorkspaceRuntimeRegistry as r, setWorkspaceDependencyRuntimeLoaders as s, invalidateWorkspaceStore as t };
|