@aigne/afs-cli 1.11.0-beta.6 → 1.11.0-beta.7
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/dist/cli.cjs +27 -353
- package/dist/cli.d.cts +2 -1
- package/dist/cli.d.mts +2 -1
- package/dist/cli.mjs +28 -353
- package/dist/cli.mjs.map +1 -1
- package/dist/config/afs-loader.cjs +123 -0
- package/dist/config/afs-loader.d.cts +14 -0
- package/dist/config/afs-loader.d.cts.map +1 -0
- package/dist/config/afs-loader.d.mts +14 -0
- package/dist/config/afs-loader.d.mts.map +1 -0
- package/dist/config/afs-loader.mjs +122 -0
- package/dist/config/afs-loader.mjs.map +1 -0
- package/dist/config/loader.cjs +2 -2
- package/dist/config/loader.mjs +2 -2
- package/dist/{commands/mount.cjs → config/mount-commands.cjs} +13 -49
- package/dist/config/mount-commands.d.cts +20 -0
- package/dist/config/mount-commands.d.cts.map +1 -0
- package/dist/config/mount-commands.d.mts +20 -0
- package/dist/config/mount-commands.d.mts.map +1 -0
- package/dist/{commands/mount.mjs → config/mount-commands.mjs} +14 -49
- package/dist/config/mount-commands.mjs.map +1 -0
- package/dist/config/schema.cjs +9 -1
- package/dist/config/schema.mjs +9 -1
- package/dist/config/schema.mjs.map +1 -1
- package/dist/core/commands/delete.cjs +41 -0
- package/dist/core/commands/delete.d.cts +18 -0
- package/dist/core/commands/delete.d.cts.map +1 -0
- package/dist/core/commands/delete.d.mts +18 -0
- package/dist/core/commands/delete.d.mts.map +1 -0
- package/dist/core/commands/delete.mjs +42 -0
- package/dist/core/commands/delete.mjs.map +1 -0
- package/dist/core/commands/exec.cjs +95 -0
- package/dist/core/commands/exec.d.cts +26 -0
- package/dist/core/commands/exec.d.cts.map +1 -0
- package/dist/core/commands/exec.d.mts +26 -0
- package/dist/core/commands/exec.d.mts.map +1 -0
- package/dist/core/commands/exec.mjs +96 -0
- package/dist/core/commands/exec.mjs.map +1 -0
- package/dist/core/commands/explain.cjs +254 -0
- package/dist/core/commands/explain.d.cts +25 -0
- package/dist/core/commands/explain.d.cts.map +1 -0
- package/dist/core/commands/explain.d.mts +25 -0
- package/dist/core/commands/explain.d.mts.map +1 -0
- package/dist/core/commands/explain.mjs +255 -0
- package/dist/core/commands/explain.mjs.map +1 -0
- package/dist/core/commands/explore.cjs +30 -0
- package/dist/core/commands/explore.d.mts +2 -0
- package/dist/core/commands/explore.mjs +31 -0
- package/dist/core/commands/explore.mjs.map +1 -0
- package/dist/core/commands/index.cjs +36 -0
- package/dist/core/commands/index.d.cts +21 -0
- package/dist/core/commands/index.d.cts.map +1 -0
- package/dist/core/commands/index.d.mts +24 -0
- package/dist/core/commands/index.d.mts.map +1 -0
- package/dist/core/commands/index.mjs +37 -0
- package/dist/core/commands/index.mjs.map +1 -0
- package/dist/core/commands/ls.cjs +57 -0
- package/dist/core/commands/ls.d.cts +21 -0
- package/dist/core/commands/ls.d.cts.map +1 -0
- package/dist/core/commands/ls.d.mts +21 -0
- package/dist/core/commands/ls.d.mts.map +1 -0
- package/dist/core/commands/ls.mjs +58 -0
- package/dist/core/commands/ls.mjs.map +1 -0
- package/dist/core/commands/mount.cjs +139 -0
- package/dist/core/commands/mount.d.cts +33 -0
- package/dist/core/commands/mount.d.cts.map +1 -0
- package/dist/core/commands/mount.d.mts +33 -0
- package/dist/core/commands/mount.d.mts.map +1 -0
- package/dist/core/commands/mount.mjs +140 -0
- package/dist/core/commands/mount.mjs.map +1 -0
- package/dist/core/commands/read.cjs +48 -0
- package/dist/core/commands/read.d.cts +17 -0
- package/dist/core/commands/read.d.cts.map +1 -0
- package/dist/core/commands/read.d.mts +17 -0
- package/dist/core/commands/read.d.mts.map +1 -0
- package/dist/core/commands/read.mjs +49 -0
- package/dist/core/commands/read.mjs.map +1 -0
- package/dist/core/commands/search.cjs +40 -0
- package/dist/core/commands/search.d.mts +2 -0
- package/dist/core/commands/search.mjs +41 -0
- package/dist/core/commands/search.mjs.map +1 -0
- package/dist/core/commands/serve.cjs +242 -0
- package/dist/core/commands/serve.d.mts +2 -0
- package/dist/core/commands/serve.mjs +242 -0
- package/dist/core/commands/serve.mjs.map +1 -0
- package/dist/core/commands/stat.cjs +53 -0
- package/dist/core/commands/stat.d.cts +17 -0
- package/dist/core/commands/stat.d.cts.map +1 -0
- package/dist/core/commands/stat.d.mts +17 -0
- package/dist/core/commands/stat.d.mts.map +1 -0
- package/dist/core/commands/stat.mjs +54 -0
- package/dist/core/commands/stat.mjs.map +1 -0
- package/dist/core/commands/types.cjs +13 -0
- package/dist/core/commands/types.d.cts +54 -0
- package/dist/core/commands/types.d.cts.map +1 -0
- package/dist/core/commands/types.d.mts +54 -0
- package/dist/core/commands/types.d.mts.map +1 -0
- package/dist/core/commands/types.mjs +14 -0
- package/dist/core/commands/types.mjs.map +1 -0
- package/dist/core/commands/write.cjs +70 -0
- package/dist/core/commands/write.d.cts +20 -0
- package/dist/core/commands/write.d.cts.map +1 -0
- package/dist/core/commands/write.d.mts +20 -0
- package/dist/core/commands/write.d.mts.map +1 -0
- package/dist/core/commands/write.mjs +71 -0
- package/dist/core/commands/write.mjs.map +1 -0
- package/dist/core/executor/index.cjs +196 -0
- package/dist/core/executor/index.d.cts +77 -0
- package/dist/core/executor/index.d.cts.map +1 -0
- package/dist/core/executor/index.d.mts +77 -0
- package/dist/core/executor/index.d.mts.map +1 -0
- package/dist/core/executor/index.mjs +195 -0
- package/dist/core/executor/index.mjs.map +1 -0
- package/dist/core/formatters/delete.cjs +37 -0
- package/dist/core/formatters/delete.d.cts +18 -0
- package/dist/core/formatters/delete.d.cts.map +1 -0
- package/dist/core/formatters/delete.d.mts +18 -0
- package/dist/core/formatters/delete.d.mts.map +1 -0
- package/dist/core/formatters/delete.mjs +37 -0
- package/dist/core/formatters/delete.mjs.map +1 -0
- package/dist/core/formatters/exec.cjs +60 -0
- package/dist/core/formatters/exec.d.cts +18 -0
- package/dist/core/formatters/exec.d.cts.map +1 -0
- package/dist/core/formatters/exec.d.mts +18 -0
- package/dist/core/formatters/exec.d.mts.map +1 -0
- package/dist/core/formatters/exec.mjs +60 -0
- package/dist/core/formatters/exec.mjs.map +1 -0
- package/dist/core/formatters/explain.cjs +97 -0
- package/dist/core/formatters/explain.d.cts +11 -0
- package/dist/core/formatters/explain.d.cts.map +1 -0
- package/dist/core/formatters/explain.d.mts +11 -0
- package/dist/core/formatters/explain.d.mts.map +1 -0
- package/dist/core/formatters/explain.mjs +96 -0
- package/dist/core/formatters/explain.mjs.map +1 -0
- package/dist/core/formatters/index.d.mts +9 -0
- package/dist/core/formatters/ls.cjs +179 -0
- package/dist/core/formatters/ls.d.cts +20 -0
- package/dist/core/formatters/ls.d.cts.map +1 -0
- package/dist/core/formatters/ls.d.mts +20 -0
- package/dist/core/formatters/ls.d.mts.map +1 -0
- package/dist/core/formatters/ls.mjs +179 -0
- package/dist/core/formatters/ls.mjs.map +1 -0
- package/dist/core/formatters/mount.cjs +55 -0
- package/dist/core/formatters/mount.d.cts +15 -0
- package/dist/core/formatters/mount.d.cts.map +1 -0
- package/dist/core/formatters/mount.d.mts +15 -0
- package/dist/core/formatters/mount.d.mts.map +1 -0
- package/dist/core/formatters/mount.mjs +55 -0
- package/dist/core/formatters/mount.mjs.map +1 -0
- package/dist/core/formatters/read.cjs +100 -0
- package/dist/core/formatters/read.d.cts +22 -0
- package/dist/core/formatters/read.d.cts.map +1 -0
- package/dist/core/formatters/read.d.mts +22 -0
- package/dist/core/formatters/read.d.mts.map +1 -0
- package/dist/core/formatters/read.mjs +100 -0
- package/dist/core/formatters/read.mjs.map +1 -0
- package/dist/core/formatters/search.cjs +44 -0
- package/dist/core/formatters/search.d.mts +1 -0
- package/dist/core/formatters/search.mjs +44 -0
- package/dist/core/formatters/search.mjs.map +1 -0
- package/dist/core/formatters/stat.cjs +155 -0
- package/dist/core/formatters/stat.d.cts +15 -0
- package/dist/core/formatters/stat.d.cts.map +1 -0
- package/dist/core/formatters/stat.d.mts +15 -0
- package/dist/core/formatters/stat.d.mts.map +1 -0
- package/dist/core/formatters/stat.mjs +155 -0
- package/dist/core/formatters/stat.mjs.map +1 -0
- package/dist/core/formatters/write.cjs +51 -0
- package/dist/core/formatters/write.d.cts +22 -0
- package/dist/core/formatters/write.d.cts.map +1 -0
- package/dist/core/formatters/write.d.mts +22 -0
- package/dist/core/formatters/write.d.mts.map +1 -0
- package/dist/core/formatters/write.mjs +51 -0
- package/dist/core/formatters/write.mjs.map +1 -0
- package/dist/core/helpers/exec-args.cjs +142 -0
- package/dist/core/helpers/exec-args.d.cts +46 -0
- package/dist/core/helpers/exec-args.d.cts.map +1 -0
- package/dist/core/helpers/exec-args.d.mts +46 -0
- package/dist/core/helpers/exec-args.d.mts.map +1 -0
- package/dist/core/helpers/exec-args.mjs +139 -0
- package/dist/core/helpers/exec-args.mjs.map +1 -0
- package/dist/core/helpers/stdin.cjs +41 -0
- package/dist/core/helpers/stdin.d.cts +15 -0
- package/dist/core/helpers/stdin.d.cts.map +1 -0
- package/dist/core/helpers/stdin.d.mts +15 -0
- package/dist/core/helpers/stdin.d.mts.map +1 -0
- package/dist/core/helpers/stdin.mjs +41 -0
- package/dist/core/helpers/stdin.mjs.map +1 -0
- package/dist/core/index.cjs +49 -0
- package/dist/core/index.d.cts +24 -0
- package/dist/core/index.d.mts +25 -0
- package/dist/core/index.mjs +24 -0
- package/dist/core/path-utils.cjs +1 -0
- package/dist/core/path-utils.mjs +3 -0
- package/dist/core/types.d.cts +24 -0
- package/dist/core/types.d.cts.map +1 -0
- package/dist/core/types.d.mts +24 -0
- package/dist/core/types.d.mts.map +1 -0
- package/dist/errors.cjs +0 -11
- package/dist/errors.mjs +1 -11
- package/dist/errors.mjs.map +1 -1
- package/dist/explorer/actions.cjs +67 -32
- package/dist/explorer/actions.mjs +66 -32
- package/dist/explorer/actions.mjs.map +1 -1
- package/dist/explorer/components/dialog.cjs +170 -46
- package/dist/explorer/components/dialog.mjs +170 -46
- package/dist/explorer/components/dialog.mjs.map +1 -1
- package/dist/explorer/components/metadata-panel.cjs +86 -3
- package/dist/explorer/components/metadata-panel.mjs +86 -3
- package/dist/explorer/components/metadata-panel.mjs.map +1 -1
- package/dist/explorer/screen.cjs +63 -27
- package/dist/explorer/screen.d.cts +23 -0
- package/dist/explorer/screen.d.cts.map +1 -0
- package/dist/explorer/screen.d.mts +23 -0
- package/dist/explorer/screen.d.mts.map +1 -0
- package/dist/explorer/screen.mjs +63 -27
- package/dist/explorer/screen.mjs.map +1 -1
- package/dist/explorer/theme.cjs +1 -1
- package/dist/explorer/theme.mjs +1 -1
- package/dist/explorer/theme.mjs.map +1 -1
- package/dist/index.cjs +7 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +4 -1
- package/dist/mcp/http-transport.cjs +68 -0
- package/dist/mcp/http-transport.mjs +68 -0
- package/dist/mcp/http-transport.mjs.map +1 -0
- package/dist/mcp/prompts.cjs +48 -0
- package/dist/mcp/prompts.mjs +48 -0
- package/dist/mcp/prompts.mjs.map +1 -0
- package/dist/mcp/resources.cjs +25 -0
- package/dist/mcp/resources.mjs +25 -0
- package/dist/mcp/resources.mjs.map +1 -0
- package/dist/mcp/server.cjs +30 -0
- package/dist/mcp/server.mjs +30 -0
- package/dist/mcp/server.mjs.map +1 -0
- package/dist/mcp/tools.cjs +196 -0
- package/dist/mcp/tools.mjs +196 -0
- package/dist/mcp/tools.mjs.map +1 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.cts +10 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.mts +10 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.mts.map +1 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.cts +46 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.mts +46 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.mts.map +1 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/urlpattern.cjs +902 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/urlpattern.mjs +902 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/urlpattern.mjs.map +1 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/index.cjs +6 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/index.mjs +8 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/index.mjs.map +1 -0
- package/dist/path-utils.d.cts +50 -0
- package/dist/path-utils.d.cts.map +1 -0
- package/dist/path-utils.d.mts +50 -0
- package/dist/path-utils.d.mts.map +1 -0
- package/dist/repl.cjs +485 -0
- package/dist/repl.d.cts +15 -0
- package/dist/repl.d.cts.map +1 -0
- package/dist/repl.d.mts +16 -0
- package/dist/repl.d.mts.map +1 -0
- package/dist/repl.mjs +485 -0
- package/dist/repl.mjs.map +1 -0
- package/dist/serve.cjs +146 -0
- package/dist/serve.d.cts +41 -0
- package/dist/serve.d.cts.map +1 -0
- package/dist/serve.d.mts +41 -0
- package/dist/serve.d.mts.map +1 -0
- package/dist/serve.mjs +146 -0
- package/dist/serve.mjs.map +1 -0
- package/dist/ui/header.cjs +1 -40
- package/dist/ui/header.mjs +1 -39
- package/dist/ui/header.mjs.map +1 -1
- package/dist/ui/index.cjs +2 -9
- package/dist/ui/index.mjs +2 -7
- package/dist/ui/index.mjs.map +1 -1
- package/dist/ui/terminal.cjs +1 -10
- package/dist/ui/terminal.mjs +1 -8
- package/dist/ui/terminal.mjs.map +1 -1
- package/package.json +29 -16
- package/dist/commands/exec.cjs +0 -164
- package/dist/commands/exec.mjs +0 -160
- package/dist/commands/exec.mjs.map +0 -1
- package/dist/commands/explain.cjs +0 -244
- package/dist/commands/explain.mjs +0 -242
- package/dist/commands/explain.mjs.map +0 -1
- package/dist/commands/index.cjs +0 -8
- package/dist/commands/index.mjs +0 -10
- package/dist/commands/ls.cjs +0 -242
- package/dist/commands/ls.mjs +0 -242
- package/dist/commands/ls.mjs.map +0 -1
- package/dist/commands/mount.mjs.map +0 -1
- package/dist/commands/read.cjs +0 -264
- package/dist/commands/read.mjs +0 -263
- package/dist/commands/read.mjs.map +0 -1
- package/dist/commands/serve.cjs +0 -144
- package/dist/commands/serve.mjs +0 -143
- package/dist/commands/serve.mjs.map +0 -1
- package/dist/commands/stat.cjs +0 -195
- package/dist/commands/stat.mjs +0 -195
- package/dist/commands/stat.mjs.map +0 -1
- package/dist/commands/write.cjs +0 -85
- package/dist/commands/write.mjs +0 -85
- package/dist/commands/write.mjs.map +0 -1
- package/dist/config/provider-factory.cjs +0 -400
- package/dist/config/provider-factory.mjs +0 -401
- package/dist/config/provider-factory.mjs.map +0 -1
- package/dist/config/uri-parser.cjs +0 -285
- package/dist/config/uri-parser.mjs +0 -285
- package/dist/config/uri-parser.mjs.map +0 -1
- package/dist/runtime.cjs +0 -120
- package/dist/runtime.mjs +0 -120
- package/dist/runtime.mjs.map +0 -1
- package/dist/utils/meta.cjs +0 -51
- package/dist/utils/meta.mjs +0 -49
- package/dist/utils/meta.mjs.map +0 -1
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
const require_uri_parser = require('./uri-parser.cjs');
|
|
2
|
-
|
|
3
|
-
//#region src/config/provider-factory.ts
|
|
4
|
-
/**
|
|
5
|
-
* Create an AFS provider from a mount configuration
|
|
6
|
-
*
|
|
7
|
-
* @param mount - Mount configuration with URI and options
|
|
8
|
-
* @returns Provider instance
|
|
9
|
-
* @throws Error if scheme is unknown or not implemented
|
|
10
|
-
*/
|
|
11
|
-
async function createProvider(mount) {
|
|
12
|
-
const parsed = require_uri_parser.parseURI(mount.uri);
|
|
13
|
-
switch (parsed.scheme) {
|
|
14
|
-
case "fs": return createAFSFSProvider(mount, parsed.path);
|
|
15
|
-
case "git": return createGitProvider(mount, parsed.path, parsed.params, parsed.host);
|
|
16
|
-
case "sqlite": return createSQLiteProvider(mount, parsed.path);
|
|
17
|
-
case "json": return createJSONProvider(mount, parsed.path);
|
|
18
|
-
case "toml": return createTOMLProvider(mount, parsed.path);
|
|
19
|
-
case "s3": return createS3Provider(mount, parsed.path, parsed.params);
|
|
20
|
-
case "gs": return createGCSProvider(mount, parsed.path, parsed.params);
|
|
21
|
-
case "ec2": return createEC2Provider(mount, parsed.path, parsed.params);
|
|
22
|
-
case "gce": return createGCEProvider(mount, parsed.path, parsed.params);
|
|
23
|
-
case "dns": return createDNSProvider(mount, parsed.path, parsed.params);
|
|
24
|
-
case "github": return createGitHubProvider(mount, parsed.path, parsed.params);
|
|
25
|
-
case "sandbox": return createSandboxProvider(mount);
|
|
26
|
-
case "http":
|
|
27
|
-
case "https": return createHttpProvider(mount);
|
|
28
|
-
case "mcp":
|
|
29
|
-
case "mcp+stdio":
|
|
30
|
-
case "mcp+http":
|
|
31
|
-
case "mcp+sse": return createMCPProvider(mount, parsed);
|
|
32
|
-
default: throw new Error(`Unknown URI scheme: ${parsed.scheme}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
async function createAFSFSProvider(mount, localPath) {
|
|
36
|
-
const { AFSFS } = await import("@aigne/afs-fs");
|
|
37
|
-
return new AFSFS({
|
|
38
|
-
localPath,
|
|
39
|
-
name: mount.path.slice(1).replace(/\//g, "-") || "fs",
|
|
40
|
-
description: mount.description,
|
|
41
|
-
accessMode: mount.access_mode,
|
|
42
|
-
...mount.options
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
async function createGitProvider(mount, repoPath, params, host) {
|
|
46
|
-
const { AFSGit } = await import("@aigne/afs-git");
|
|
47
|
-
let provider;
|
|
48
|
-
if (host) provider = new AFSGit({
|
|
49
|
-
remoteUrl: `git@${host}:${repoPath}`,
|
|
50
|
-
name: mount.path.slice(1).replace(/\//g, "-") || "git",
|
|
51
|
-
description: mount.description,
|
|
52
|
-
accessMode: mount.access_mode ?? "readonly",
|
|
53
|
-
branches: params.branch ? [params.branch] : void 0,
|
|
54
|
-
...mount.options
|
|
55
|
-
});
|
|
56
|
-
else if (repoPath.startsWith("https://") || repoPath.startsWith("http://")) provider = new AFSGit({
|
|
57
|
-
remoteUrl: repoPath,
|
|
58
|
-
name: mount.path.slice(1).replace(/\//g, "-") || "git",
|
|
59
|
-
description: mount.description,
|
|
60
|
-
accessMode: mount.access_mode ?? "readonly",
|
|
61
|
-
branches: params.branch ? [params.branch] : void 0,
|
|
62
|
-
...mount.options
|
|
63
|
-
});
|
|
64
|
-
else provider = new AFSGit({
|
|
65
|
-
repoPath,
|
|
66
|
-
name: mount.path.slice(1).replace(/\//g, "-") || "git",
|
|
67
|
-
description: mount.description,
|
|
68
|
-
accessMode: mount.access_mode ?? "readonly",
|
|
69
|
-
branches: params.branch ? [params.branch] : void 0,
|
|
70
|
-
...mount.options
|
|
71
|
-
});
|
|
72
|
-
await provider.ready();
|
|
73
|
-
return provider;
|
|
74
|
-
}
|
|
75
|
-
async function createSQLiteProvider(mount, dbPath) {
|
|
76
|
-
const { SQLiteAFS } = await import("@aigne/afs-sqlite");
|
|
77
|
-
return new SQLiteAFS({
|
|
78
|
-
url: `file:${dbPath}`,
|
|
79
|
-
name: mount.path.slice(1).replace(/\//g, "-") || "sqlite",
|
|
80
|
-
description: mount.description,
|
|
81
|
-
accessMode: mount.access_mode,
|
|
82
|
-
...mount.options
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
async function createJSONProvider(mount, jsonPath) {
|
|
86
|
-
const { AFSJSON } = await import("@aigne/afs-json");
|
|
87
|
-
return new AFSJSON({
|
|
88
|
-
jsonPath,
|
|
89
|
-
name: mount.path.slice(1).replace(/\//g, "-") || "json",
|
|
90
|
-
description: mount.description,
|
|
91
|
-
accessMode: mount.access_mode,
|
|
92
|
-
...mount.options
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
async function createTOMLProvider(mount, tomlPath) {
|
|
96
|
-
const { AFSTOML } = await import("@aigne/afs-toml");
|
|
97
|
-
return new AFSTOML({
|
|
98
|
-
tomlPath,
|
|
99
|
-
name: mount.path.slice(1).replace(/\//g, "-") || "toml",
|
|
100
|
-
description: mount.description,
|
|
101
|
-
accessMode: mount.access_mode,
|
|
102
|
-
...mount.options
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Create an S3 provider from mount configuration
|
|
107
|
-
*
|
|
108
|
-
* Supported URI formats:
|
|
109
|
-
* - s3://bucket (bucket only)
|
|
110
|
-
* - s3://bucket/prefix (bucket with prefix)
|
|
111
|
-
*
|
|
112
|
-
* Options:
|
|
113
|
-
* - endpoint: S3-compatible endpoint URL (for MinIO, R2, B2, etc.)
|
|
114
|
-
* - forcePathStyle: Use path-style URLs instead of virtual-hosted style
|
|
115
|
-
* - region: AWS region
|
|
116
|
-
* - profile: AWS profile name
|
|
117
|
-
*/
|
|
118
|
-
async function createS3Provider(mount, path, params) {
|
|
119
|
-
const { AFSS3 } = await import("@aigne/afs-s3");
|
|
120
|
-
const parts = path.split("/");
|
|
121
|
-
const bucket = parts[0] || "";
|
|
122
|
-
const prefix = parts.slice(1).join("/") || void 0;
|
|
123
|
-
if (!bucket) throw new Error("S3 URI requires a bucket name: s3://bucket/prefix");
|
|
124
|
-
return new AFSS3({
|
|
125
|
-
bucket,
|
|
126
|
-
prefix,
|
|
127
|
-
name: mount.path.slice(1).replace(/\//g, "-") || bucket,
|
|
128
|
-
description: mount.description,
|
|
129
|
-
accessMode: mount.access_mode,
|
|
130
|
-
region: params.region ?? mount.options?.region,
|
|
131
|
-
endpoint: params.endpoint ?? mount.options?.endpoint,
|
|
132
|
-
forcePathStyle: params.forcePathStyle === "true" || mount.options?.forcePathStyle,
|
|
133
|
-
profile: params.profile ?? mount.options?.profile,
|
|
134
|
-
...mount.options
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Create a GCS provider from mount configuration
|
|
139
|
-
*
|
|
140
|
-
* Supported URI formats:
|
|
141
|
-
* - gs://bucket (bucket only)
|
|
142
|
-
* - gs://bucket/prefix (bucket with prefix)
|
|
143
|
-
*
|
|
144
|
-
* Options:
|
|
145
|
-
* - projectId: Google Cloud project ID
|
|
146
|
-
* - keyFilename: Path to service account key file
|
|
147
|
-
* - apiEndpoint: Custom API endpoint (for emulators)
|
|
148
|
-
*/
|
|
149
|
-
async function createGCSProvider(mount, path, params) {
|
|
150
|
-
const { AFSGCS } = await import("@aigne/afs-gcs");
|
|
151
|
-
const parts = path.split("/");
|
|
152
|
-
const bucket = parts[0] || "";
|
|
153
|
-
const prefix = parts.slice(1).join("/") || void 0;
|
|
154
|
-
if (!bucket) throw new Error("GCS URI requires a bucket name: gs://bucket/prefix");
|
|
155
|
-
return new AFSGCS({
|
|
156
|
-
bucket,
|
|
157
|
-
prefix,
|
|
158
|
-
name: mount.path.slice(1).replace(/\//g, "-") || bucket,
|
|
159
|
-
description: mount.description,
|
|
160
|
-
accessMode: mount.access_mode,
|
|
161
|
-
projectId: params.projectId ?? mount.options?.projectId,
|
|
162
|
-
keyFilename: params.keyFilename ?? mount.options?.keyFilename,
|
|
163
|
-
endpoint: params.endpoint ?? mount.options?.endpoint,
|
|
164
|
-
...mount.options
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Create a GitHub provider from mount configuration
|
|
169
|
-
*
|
|
170
|
-
* Supported URI formats:
|
|
171
|
-
* - github://owner/repo (single-repo mode)
|
|
172
|
-
* - github://owner (org mode - list all repos in organization)
|
|
173
|
-
* - github:// (multi-repo mode, requires options.mode = "multi-repo")
|
|
174
|
-
*
|
|
175
|
-
* Options:
|
|
176
|
-
* - mode: "single-repo" | "multi-repo" | "org" (default: auto-detected from URI)
|
|
177
|
-
* - baseUrl: GitHub API base URL (for GitHub Enterprise)
|
|
178
|
-
* - cache: { enabled: boolean; ttl: number }
|
|
179
|
-
* - rateLimit: { autoRetry: boolean; maxRetries: number }
|
|
180
|
-
*/
|
|
181
|
-
async function createGitHubProvider(mount, repoPath, params) {
|
|
182
|
-
const { AFSGitHub } = await import("@aigne/afs-github");
|
|
183
|
-
const parts = repoPath.split("/").filter(Boolean);
|
|
184
|
-
const owner = parts[0];
|
|
185
|
-
const repo = parts[1];
|
|
186
|
-
let mode = params.mode ?? mount.options?.mode;
|
|
187
|
-
if (!mode) if (owner && repo) mode = "single-repo";
|
|
188
|
-
else if (owner && !repo) mode = "org";
|
|
189
|
-
else mode = "multi-repo";
|
|
190
|
-
if (mode === "single-repo" && (!owner || !repo)) throw new Error("GitHub single-repo mode requires owner/repo in URI: github://owner/repo");
|
|
191
|
-
if (mode === "org" && !owner) throw new Error("GitHub org mode requires owner in URI: github://owner");
|
|
192
|
-
const authToken = mount.auth ?? mount.token;
|
|
193
|
-
const ownerType = mount.options?.owner_type ?? mount.options?.ownerType;
|
|
194
|
-
return new AFSGitHub({
|
|
195
|
-
name: mount.path.slice(1).replace(/\//g, "-") || "github",
|
|
196
|
-
description: mount.description,
|
|
197
|
-
owner,
|
|
198
|
-
repo,
|
|
199
|
-
auth: authToken ? { token: authToken } : void 0,
|
|
200
|
-
mode,
|
|
201
|
-
ownerType,
|
|
202
|
-
accessMode: mount.access_mode ?? "readonly",
|
|
203
|
-
...mount.options
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
async function createSandboxProvider(mount) {
|
|
207
|
-
const { AFSSandbox } = await import("@aigne/afs-sandbox");
|
|
208
|
-
return new AFSSandbox({
|
|
209
|
-
name: mount.path.slice(1).replace(/\//g, "-") || "sandbox",
|
|
210
|
-
description: mount.description,
|
|
211
|
-
accessMode: mount.access_mode,
|
|
212
|
-
...mount.options
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
async function createHttpProvider(mount) {
|
|
216
|
-
const { AFSHttpClient } = await import("@aigne/afs-http");
|
|
217
|
-
return new AFSHttpClient({
|
|
218
|
-
url: mount.uri,
|
|
219
|
-
name: mount.path.slice(1).replace(/\//g, "-") || "http",
|
|
220
|
-
description: mount.description,
|
|
221
|
-
accessMode: mount.access_mode,
|
|
222
|
-
token: mount.token,
|
|
223
|
-
...mount.options
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Create an MCP provider from mount configuration
|
|
228
|
-
*
|
|
229
|
-
* Supported URI formats:
|
|
230
|
-
* - mcp://name (requires options.transport, options.command/url)
|
|
231
|
-
* - mcp+stdio://command/args... (e.g., mcp+stdio://npx/-y/@modelcontextprotocol/server-sqlite/test.db)
|
|
232
|
-
* - mcp+http://host/path (e.g., mcp+http://mcp.notion.com/mcp)
|
|
233
|
-
* - mcp+sse://host/path (e.g., mcp+sse://api.example.com/sse)
|
|
234
|
-
*
|
|
235
|
-
* Options:
|
|
236
|
-
* - transport: "stdio" | "http" | "sse" (required for mcp:// scheme)
|
|
237
|
-
* - command: string (for stdio transport)
|
|
238
|
-
* - args: string[] (for stdio transport)
|
|
239
|
-
* - env: Record<string, string> (for stdio transport)
|
|
240
|
-
* - url: string (for http/sse transport)
|
|
241
|
-
* - headers: Record<string, string> (for http/sse transport)
|
|
242
|
-
*/
|
|
243
|
-
async function createMCPProvider(mount, parsed) {
|
|
244
|
-
const { AFSMCP } = await import("@aigne/afs-mcp");
|
|
245
|
-
const name = mount.path.slice(1).replace(/\//g, "-") || "mcp";
|
|
246
|
-
const options = mount.options || {};
|
|
247
|
-
let transport;
|
|
248
|
-
let command;
|
|
249
|
-
let args;
|
|
250
|
-
let url;
|
|
251
|
-
if (parsed.scheme === "mcp+stdio") {
|
|
252
|
-
transport = "stdio";
|
|
253
|
-
const parts = parsed.path.split("/").filter(Boolean).map(decodeURIComponent);
|
|
254
|
-
command = parts[0];
|
|
255
|
-
args = parts.slice(1);
|
|
256
|
-
} else if (parsed.scheme === "mcp+http") {
|
|
257
|
-
transport = "http";
|
|
258
|
-
url = `https://${parsed.host || ""}${parsed.path}`;
|
|
259
|
-
} else if (parsed.scheme === "mcp+sse") {
|
|
260
|
-
transport = "sse";
|
|
261
|
-
url = `https://${parsed.host || ""}${parsed.path}`;
|
|
262
|
-
} else {
|
|
263
|
-
transport = options.transport || "stdio";
|
|
264
|
-
command = options.command;
|
|
265
|
-
args = options.args;
|
|
266
|
-
url = options.url;
|
|
267
|
-
}
|
|
268
|
-
const mcpOptions = {
|
|
269
|
-
name,
|
|
270
|
-
description: mount.description,
|
|
271
|
-
transport
|
|
272
|
-
};
|
|
273
|
-
if (transport === "stdio") {
|
|
274
|
-
if (!command) throw new Error("MCP stdio transport requires 'command' option");
|
|
275
|
-
mcpOptions.command = command;
|
|
276
|
-
mcpOptions.args = args || [];
|
|
277
|
-
if (options.env) mcpOptions.env = options.env;
|
|
278
|
-
} else {
|
|
279
|
-
if (!url) throw new Error(`MCP ${transport} transport requires 'url' option`);
|
|
280
|
-
mcpOptions.url = url;
|
|
281
|
-
if (options.headers) mcpOptions.headers = options.headers;
|
|
282
|
-
}
|
|
283
|
-
if (options.timeout) mcpOptions.timeout = options.timeout;
|
|
284
|
-
if (options.maxReconnects) mcpOptions.maxReconnects = options.maxReconnects;
|
|
285
|
-
return new AFSMCP(mcpOptions);
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Create an EC2 provider from mount configuration
|
|
289
|
-
*
|
|
290
|
-
* Supported URI formats:
|
|
291
|
-
* - ec2://us-east-1 (single region)
|
|
292
|
-
* - ec2://us-east-1,us-west-2 (multi-region)
|
|
293
|
-
* - ec2://?profile=myprofile (use default region from profile)
|
|
294
|
-
*
|
|
295
|
-
* Options:
|
|
296
|
-
* - endpoint: Custom endpoint URL (for LocalStack, etc.)
|
|
297
|
-
* - profile: AWS profile name
|
|
298
|
-
* - filters: Array of { name, values } filters
|
|
299
|
-
* - cache: { ttl: number, instanceTtl: number, staticTtl: number }
|
|
300
|
-
*/
|
|
301
|
-
async function createEC2Provider(mount, path, params) {
|
|
302
|
-
const { AFSEC2 } = await import("@aigne/afs-ec2");
|
|
303
|
-
const regions = path.split(",").map((r) => r.trim()).filter(Boolean);
|
|
304
|
-
const config = {
|
|
305
|
-
name: mount.path.slice(1).replace(/\//g, "-") || "ec2",
|
|
306
|
-
description: mount.description,
|
|
307
|
-
accessMode: mount.access_mode ?? "readonly"
|
|
308
|
-
};
|
|
309
|
-
if (regions.length === 1) config.region = regions[0];
|
|
310
|
-
else if (regions.length > 1) config.regions = regions;
|
|
311
|
-
const endpoint = params.endpoint ?? mount.options?.endpoint;
|
|
312
|
-
if (endpoint) config.endpoint = endpoint;
|
|
313
|
-
const profile = params.profile ?? mount.options?.profile;
|
|
314
|
-
if (profile) config.profile = profile;
|
|
315
|
-
if (mount.options?.credentials) config.credentials = mount.options.credentials;
|
|
316
|
-
if (mount.options?.filters) config.filters = mount.options.filters;
|
|
317
|
-
if (mount.options?.cache) config.cache = mount.options.cache;
|
|
318
|
-
return new AFSEC2(config);
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Create a GCE provider from mount configuration
|
|
322
|
-
*
|
|
323
|
-
* Supported URI formats:
|
|
324
|
-
* - gce://project-id/zone (project and zone)
|
|
325
|
-
* - gce://project-id (project only, zone from options)
|
|
326
|
-
*
|
|
327
|
-
* Options:
|
|
328
|
-
* - zone: GCE zone
|
|
329
|
-
* - keyFilename: Path to service account key file
|
|
330
|
-
* - credentials: Service account credentials object
|
|
331
|
-
* - cache: { ttl: number, instanceTtl: number, staticTtl: number }
|
|
332
|
-
*/
|
|
333
|
-
async function createGCEProvider(mount, path, params) {
|
|
334
|
-
const { AFSGCE } = await import("@aigne/afs-gce");
|
|
335
|
-
const parts = path.split("/").filter(Boolean);
|
|
336
|
-
const projectId = parts[0] || "";
|
|
337
|
-
const zoneFromPath = parts[1];
|
|
338
|
-
if (!projectId) throw new Error("GCE URI requires a project ID: gce://project-id/zone");
|
|
339
|
-
const zone = zoneFromPath ?? params.zone ?? mount.options?.zone;
|
|
340
|
-
if (!zone) throw new Error("GCE requires a zone: gce://project-id/zone or use ?zone= parameter");
|
|
341
|
-
const config = {
|
|
342
|
-
name: mount.path.slice(1).replace(/\//g, "-") || "gce",
|
|
343
|
-
description: mount.description,
|
|
344
|
-
projectId,
|
|
345
|
-
zone,
|
|
346
|
-
accessMode: mount.access_mode ?? "readonly"
|
|
347
|
-
};
|
|
348
|
-
const keyFilename = params.keyFilename ?? mount.options?.keyFilename;
|
|
349
|
-
if (keyFilename) config.keyFilename = keyFilename;
|
|
350
|
-
if (mount.options?.credentials) config.credentials = mount.options.credentials;
|
|
351
|
-
if (mount.options?.cache) config.cache = mount.options.cache;
|
|
352
|
-
return new AFSGCE(config);
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Create a DNS provider from mount configuration
|
|
356
|
-
*
|
|
357
|
-
* Supported URI formats:
|
|
358
|
-
* - dns://zone.domain.com (single zone)
|
|
359
|
-
*
|
|
360
|
-
* Options:
|
|
361
|
-
* - provider: DNS provider type ("route53" | "clouddns")
|
|
362
|
-
* - endpoint: Custom endpoint URL (for LocalStack, etc.)
|
|
363
|
-
* - region: AWS region (for Route53)
|
|
364
|
-
* - credentials: { accessKeyId, secretAccessKey } (for Route53)
|
|
365
|
-
* - projectId: Google Cloud project ID (for Cloud DNS)
|
|
366
|
-
* - keyFilename: Path to service account key file (for Cloud DNS)
|
|
367
|
-
* - permissions: { preset, dangerous }
|
|
368
|
-
*/
|
|
369
|
-
async function createDNSProvider(mount, zoneDomain, params) {
|
|
370
|
-
const { DNSProvider, Route53Adapter, CloudDNSAdapter } = await import("@aigne/afs-dns");
|
|
371
|
-
const providerType = params.provider ?? mount.options?.provider ?? "route53";
|
|
372
|
-
let adapter;
|
|
373
|
-
if (providerType === "route53") {
|
|
374
|
-
const adapterConfig = {};
|
|
375
|
-
const region = params.region ?? mount.options?.region;
|
|
376
|
-
if (region) adapterConfig.region = region;
|
|
377
|
-
const endpoint = params.endpoint ?? mount.options?.endpoint;
|
|
378
|
-
if (endpoint) adapterConfig.endpoint = endpoint;
|
|
379
|
-
if (mount.options?.credentials) adapterConfig.credentials = mount.options.credentials;
|
|
380
|
-
adapter = new Route53Adapter(adapterConfig);
|
|
381
|
-
} else if (providerType === "clouddns") {
|
|
382
|
-
const adapterConfig = {};
|
|
383
|
-
const projectId = params.projectId ?? mount.options?.projectId;
|
|
384
|
-
if (projectId) adapterConfig.projectId = projectId;
|
|
385
|
-
const keyFilename = params.keyFilename ?? mount.options?.keyFilename;
|
|
386
|
-
if (keyFilename) adapterConfig.keyFilename = keyFilename;
|
|
387
|
-
adapter = new CloudDNSAdapter(adapterConfig);
|
|
388
|
-
} else throw new Error(`Unsupported DNS provider: ${providerType}. Supported providers: 'route53', 'clouddns'.`);
|
|
389
|
-
return new DNSProvider({
|
|
390
|
-
zone: zoneDomain,
|
|
391
|
-
adapter,
|
|
392
|
-
accessMode: mount.access_mode ?? "readonly",
|
|
393
|
-
permissions: mount.options?.permissions,
|
|
394
|
-
auditLog: mount.options?.auditLog,
|
|
395
|
-
rateLimiting: mount.options?.rateLimiting
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
//#endregion
|
|
400
|
-
exports.createProvider = createProvider;
|