aancloud 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +120 -2
- package/aan.mjs +420 -0
- package/package.json +12 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AAN Software LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,121 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center"><a href="https://aancloud.com"><img src="https://aancloud.com/static/brand/aan-cloud-logo-120.png" width="96" height="96" alt="Aan Cloud"></a></p>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# Aan Cloud CLI
|
|
4
|
+
|
|
5
|
+
Deploy and share websites and apps on [Aan Cloud](https://aancloud.com) from your terminal, or let your AI agent do it through MCP.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g aancloud
|
|
9
|
+
aan login --token <your-token>
|
|
10
|
+
aan deploy ./dist --name my-site
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Your app is live at `https://my-site.aan.run` a few seconds later. It starts private: only you can open it until you share it.
|
|
14
|
+
|
|
15
|
+
Requires Node.js 18 or later. The CLI has no dependencies.
|
|
16
|
+
|
|
17
|
+
## Sign in
|
|
18
|
+
|
|
19
|
+
1. Sign in at [aancloud.com](https://aancloud.com) and open **Developers & agents**.
|
|
20
|
+
2. Click **Create token** and copy the command it shows.
|
|
21
|
+
3. Run it:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
aan login --token aan_xxxxxxxx
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Credentials are saved in `~/.aan/config.json`. `aan whoami` shows the signed-in account.
|
|
28
|
+
|
|
29
|
+
## Deploy
|
|
30
|
+
|
|
31
|
+
Deploy the folder that contains `index.html`, usually your build output:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
aan deploy ./dist --name my-site --title "My Site"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Deploying again to the same name publishes a new version; earlier versions stay available for rollback in the portal. Files starting with a dot (such as `.env`) and `node_modules` are never uploaded.
|
|
38
|
+
|
|
39
|
+
Add an `aan.json` to the project so a plain `aan deploy` is enough:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{ "name": "my-site", "title": "My Site", "dir": "dist", "workspace": "acme" }
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Share
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
aan share my-site --with colleague@company.com # can use the app
|
|
49
|
+
aan share my-site --with colleague@company.com --editor # can also deploy and share
|
|
50
|
+
aan share my-site --org # every member of its workspace
|
|
51
|
+
aan share my-site --public # anyone with the link, no sign-in
|
|
52
|
+
aan unshare my-site --with colleague@company.com
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Workspaces
|
|
56
|
+
|
|
57
|
+
Every app belongs to a workspace: your company, a client, or just you. New apps go into your first workspace unless you choose one:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
aan workspaces
|
|
61
|
+
aan deploy ./dist --name my-site --workspace acme
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Connect a backend you already run
|
|
65
|
+
|
|
66
|
+
Send some paths of your app to a server you host elsewhere. Requests arrive only after Aan Cloud has signed the user in, with `x-aan-user-email`, `x-aan-role` and `x-aan-proxy-secret` headers:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
aan backend my-site https://api.example.com --paths /api,/hubs
|
|
70
|
+
aan backend my-site --off
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Use it from your AI agent (MCP)
|
|
74
|
+
|
|
75
|
+
`aan mcp` runs Aan Cloud as an MCP server, so agents such as Claude Code, Cursor, Windsurf and VS Code can build, deploy and share apps for you. Sign in with `aan login` first.
|
|
76
|
+
|
|
77
|
+
**Claude Code**
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
claude mcp add aan --scope user -- aan mcp
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Cursor, Windsurf, VS Code and other MCP clients**
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{ "mcpServers": { "aan": { "command": "aan", "args": ["mcp"] } } }
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
On Windows, start it through `cmd`: `claude mcp add aan --scope user -- cmd /c aan mcp`, or `"command": "cmd", "args": ["/c", "aan", "mcp"]`.
|
|
90
|
+
|
|
91
|
+
## All commands
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
aan login --token <token> [--host <url>] Save credentials
|
|
95
|
+
aan whoami Show the signed-in account
|
|
96
|
+
aan deploy [folder] [--name n] [--title t] [--workspace w]
|
|
97
|
+
Upload a folder (needs index.html) and print its URL
|
|
98
|
+
aan apps List apps you can open
|
|
99
|
+
aan workspaces List your workspaces
|
|
100
|
+
aan share <name> --with <email> [--editor] Give a person access
|
|
101
|
+
aan share <name> --org | --private | --public
|
|
102
|
+
aan unshare <name> --with <email> Remove a person's access
|
|
103
|
+
aan backend <name> <url> [--paths /api,/hubs]
|
|
104
|
+
aan backend <name> --off
|
|
105
|
+
aan delete <name> --yes Delete an app and all its data
|
|
106
|
+
aan mcp Run as an MCP server for AI agents
|
|
107
|
+
aan --version Show the CLI version
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Environment variables `AAN_TOKEN` and `AAN_HOST` override the saved credentials, for example in CI.
|
|
111
|
+
|
|
112
|
+
**Windows PowerShell:** if `aan` is blocked by the script execution policy, run `aan.cmd` instead.
|
|
113
|
+
|
|
114
|
+
## Links
|
|
115
|
+
|
|
116
|
+
- [Developer guide](https://aancloud.com/docs)
|
|
117
|
+
- [User guide](https://aancloud.com/guide)
|
|
118
|
+
- [Privacy policy](https://aancloud.com/privacy)
|
|
119
|
+
- Support: support@aan0.com
|
|
120
|
+
|
|
121
|
+
© 2026 AAN Software LLC. Released under the MIT License.
|
package/aan.mjs
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// aan: deploy and share websites and tools on Aan Cloud. No dependencies; needs Node 18+.
|
|
3
|
+
import { mkdir, readFile, readdir, stat, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { basename, join, relative, resolve, sep } from 'node:path';
|
|
6
|
+
|
|
7
|
+
const CONFIG_PATH = join(homedir(), '.aan', 'config.json');
|
|
8
|
+
const VERSION = JSON.parse(await readFile(new URL('./package.json', import.meta.url), 'utf8')).version;
|
|
9
|
+
// Customers sign in to the hosted service; --host or AAN_HOST points the CLI at another instance (e.g. local dev).
|
|
10
|
+
const DEFAULT_HOST = 'https://aancloud.com';
|
|
11
|
+
const SKIP_DIRS = new Set(['node_modules']);
|
|
12
|
+
const BATCH_FILES = 200;
|
|
13
|
+
const BATCH_BYTES = 40 * 1024 * 1024;
|
|
14
|
+
|
|
15
|
+
const HELP = `aan: deploy and share websites and tools on Aan Cloud
|
|
16
|
+
|
|
17
|
+
aan login --token <token> [--host <url>] Save credentials (create a token at https://aancloud.com/developer)
|
|
18
|
+
aan whoami Show the signed-in account
|
|
19
|
+
aan deploy [folder] [--name n] [--title t] [--workspace w] [--worker file.js]
|
|
20
|
+
Upload a folder (needs index.html) and print its URL
|
|
21
|
+
aan apps List apps you can open
|
|
22
|
+
aan workspaces List your workspaces (new apps go into --workspace, or your first one)
|
|
23
|
+
aan share <name> --with <email> [--editor] Give a person access
|
|
24
|
+
aan share <name> --org | --private | --public Set who can open the app (--org: the whole workspace)
|
|
25
|
+
aan unshare <name> --with <email> Remove a person's access
|
|
26
|
+
aan backend <name> <url> [--paths /api,/hubs] Forward those paths to a backend you run elsewhere
|
|
27
|
+
aan backend <name> --off Stop forwarding to the backend
|
|
28
|
+
aan delete <name> --yes Delete an app and all its data
|
|
29
|
+
aan mcp Run as an MCP server so AI agents can deploy and share
|
|
30
|
+
aan --version Show the CLI version
|
|
31
|
+
|
|
32
|
+
A folder may contain aan.json:
|
|
33
|
+
{ "name": "my-tool", "title": "My Tool", "dir": "dist", "workspace": "acme", "worker": "worker.js",
|
|
34
|
+
"backend": "https://api.example.com", "backendPaths": ["/api", "/hubs"] }
|
|
35
|
+
Environment overrides: AAN_HOST, AAN_TOKEN`;
|
|
36
|
+
|
|
37
|
+
function parseArgs(argv) {
|
|
38
|
+
const args = { _: [] };
|
|
39
|
+
for (let i = 0; i < argv.length; i++) {
|
|
40
|
+
const a = argv[i];
|
|
41
|
+
if (!a.startsWith('--')) args._.push(a);
|
|
42
|
+
else if (i + 1 < argv.length && !argv[i + 1].startsWith('--')) args[a.slice(2)] = argv[++i];
|
|
43
|
+
else args[a.slice(2)] = true;
|
|
44
|
+
}
|
|
45
|
+
return args;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function readJson(path) {
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(await readFile(path, 'utf8'));
|
|
51
|
+
} catch (e) {
|
|
52
|
+
if (e.code === 'ENOENT') return null;
|
|
53
|
+
throw new Error(`Could not read ${path}: ${e.message}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function config() {
|
|
58
|
+
const saved = (await readJson(CONFIG_PATH)) ?? {};
|
|
59
|
+
const host = process.env.AAN_HOST ?? saved.host ?? DEFAULT_HOST;
|
|
60
|
+
const token = process.env.AAN_TOKEN ?? saved.token;
|
|
61
|
+
if (!token) throw new Error(`Not logged in. Create a token at ${host}/developer, then run: aan login --token <token>`);
|
|
62
|
+
return { host: host.replace(/\/+$/, ''), token };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function api(method, path, body) {
|
|
66
|
+
const { host, token } = await config();
|
|
67
|
+
const headers = { authorization: `Bearer ${token}` };
|
|
68
|
+
if (body !== undefined && !(body instanceof FormData)) headers['content-type'] = 'application/json';
|
|
69
|
+
const res = await fetch(host + path, { method, headers, body: body instanceof FormData || body === undefined ? body : JSON.stringify(body) });
|
|
70
|
+
const data = await res.json().catch(() => ({ error: `${res.status} ${res.statusText}` }));
|
|
71
|
+
if (!res.ok) throw new Error(data.error ?? `${res.status} ${res.statusText}`);
|
|
72
|
+
return data;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Every file under dir, skipping dotfiles (.env, .git ...) and node_modules so secrets don't get published.
|
|
76
|
+
async function walk(dir, skip) {
|
|
77
|
+
const out = [];
|
|
78
|
+
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
79
|
+
if (entry.name.startsWith('.') || SKIP_DIRS.has(entry.name)) continue;
|
|
80
|
+
const full = join(dir, entry.name);
|
|
81
|
+
if (entry.isDirectory()) out.push(...(await walk(full, skip)));
|
|
82
|
+
else if (entry.isFile() && !skip.has(full) && entry.name !== 'aan.json') out.push(full);
|
|
83
|
+
}
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const slugify = (s) =>
|
|
88
|
+
s
|
|
89
|
+
.toLowerCase()
|
|
90
|
+
.replace(/[^a-z0-9-]+/g, '-')
|
|
91
|
+
.replace(/^-+|-+$/g, '')
|
|
92
|
+
.slice(0, 40);
|
|
93
|
+
|
|
94
|
+
/** Uploads a folder; shared by `aan deploy` and the MCP aan_deploy tool. Options override aan.json. */
|
|
95
|
+
async function deployFolder(folder, opts = {}) {
|
|
96
|
+
const root = resolve(folder ?? '.');
|
|
97
|
+
const cfg = (await readJson(join(root, 'aan.json'))) ?? {};
|
|
98
|
+
const dir = resolve(root, cfg.dir ?? '.');
|
|
99
|
+
const name = slugify(String(opts.name ?? cfg.name ?? basename(root)));
|
|
100
|
+
const workerArg = opts.worker ?? cfg.worker;
|
|
101
|
+
const worker = workerArg ? resolve(root, String(workerArg)) : null;
|
|
102
|
+
const title = opts.title ?? cfg.title;
|
|
103
|
+
const backend = opts.backend ?? cfg.backend;
|
|
104
|
+
const backendPaths = opts.backendPaths ?? cfg.backendPaths;
|
|
105
|
+
const workspace = opts.workspace ?? cfg.workspace;
|
|
106
|
+
|
|
107
|
+
const files = await walk(dir, new Set(worker ? [worker] : [])).catch((e) => {
|
|
108
|
+
throw e.code === 'ENOENT' ? new Error(`Folder not found: ${dir}`) : e;
|
|
109
|
+
});
|
|
110
|
+
if (!files.some((f) => relative(dir, f) === 'index.html') && !worker) {
|
|
111
|
+
throw new Error(`No index.html in ${dir}. Deploy the built folder (e.g. ./dist), not the project root.`);
|
|
112
|
+
}
|
|
113
|
+
// Upload in batches (Cloudflare caps a request at 100 MB); the site switches over only at finalize.
|
|
114
|
+
const { deployId } = await api('POST', `/api/apps/${name}/deploys${workspace ? `?workspace=${encodeURIComponent(workspace)}` : ''}`);
|
|
115
|
+
const sizes = await Promise.all(files.map(async (f) => (await stat(f)).size));
|
|
116
|
+
const total = sizes.reduce((a, b) => a + b, 0);
|
|
117
|
+
let i = 0;
|
|
118
|
+
let sent = 0;
|
|
119
|
+
while (i < files.length) {
|
|
120
|
+
const batch = new FormData();
|
|
121
|
+
let size = 0;
|
|
122
|
+
let count = 0;
|
|
123
|
+
while (i < files.length && count < BATCH_FILES && (count === 0 || size + sizes[i] <= BATCH_BYTES)) {
|
|
124
|
+
batch.append(relative(dir, files[i]).split(sep).join('/'), new Blob([await readFile(files[i])]), basename(files[i]));
|
|
125
|
+
size += sizes[i];
|
|
126
|
+
count++;
|
|
127
|
+
i++;
|
|
128
|
+
}
|
|
129
|
+
await api('POST', `/api/apps/${name}/deploys/${deployId}/files`, batch);
|
|
130
|
+
sent += size;
|
|
131
|
+
opts.onProgress?.(i, files.length, sent, total);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const fin = new FormData();
|
|
135
|
+
if (worker) fin.append('__worker', new Blob([await readFile(worker)]), 'worker.js');
|
|
136
|
+
if (title) fin.append('title', String(title));
|
|
137
|
+
if (backend) fin.append('backend', String(backend));
|
|
138
|
+
if (backendPaths) fin.append('backendPaths', [backendPaths].flat().join(','));
|
|
139
|
+
const r = await api('POST', `/api/apps/${name}/deploys/${deployId}/finalize`, fin);
|
|
140
|
+
return { ...r, name, fileCount: files.length, bytes: total, worker: !!worker, backend, backendPaths: backend ? [backendPaths ?? '/api'].flat().join(', ') : null };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function deploy(args) {
|
|
144
|
+
const progress = (done, count, sent, total) =>
|
|
145
|
+
process.stderr.write(`\rUploading ${done}/${count} files (${Math.round((sent / Math.max(total, 1)) * 100)}%) ${done === count ? '\n' : ''}`);
|
|
146
|
+
const r = await deployFolder(args._[1], {
|
|
147
|
+
name: args.name,
|
|
148
|
+
title: args.title,
|
|
149
|
+
worker: args.worker,
|
|
150
|
+
backend: args.backend,
|
|
151
|
+
backendPaths: args['backend-paths'],
|
|
152
|
+
workspace: typeof args.workspace === 'string' ? args.workspace : undefined,
|
|
153
|
+
onProgress: progress,
|
|
154
|
+
});
|
|
155
|
+
console.log(
|
|
156
|
+
`Deployed ${r.fileCount} file${r.fileCount === 1 ? '' : 's'} (${(r.bytes / 1048576).toFixed(1)} MB)${r.worker ? ' + server code' : ''} as "${r.name}" in the workspace "${r.workspace}".`,
|
|
157
|
+
);
|
|
158
|
+
console.log(`\n Live at: ${r.url}\n Manage: ${r.manage}\n`);
|
|
159
|
+
if (r.backend) console.log(`Requests to ${r.backendPaths} go to ${r.backend}.`);
|
|
160
|
+
if (r.created) console.log(`The app is private. Share it with: aan share ${r.name} --org or aan share ${r.name} --with someone@company.com`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async function share(args, remove) {
|
|
164
|
+
const name = args._[1];
|
|
165
|
+
if (!name) throw new Error('Usage: aan share <name> --with <email> | --org | --private | --public');
|
|
166
|
+
if (typeof args.with === 'string') {
|
|
167
|
+
if (remove) await api('DELETE', `/api/apps/${name}/members/${encodeURIComponent(args.with)}`);
|
|
168
|
+
else await api('POST', `/api/apps/${name}/members`, { email: args.with, role: args.editor ? 'editor' : 'viewer' });
|
|
169
|
+
console.log(remove ? `Removed ${args.with} from ${name}.` : `Shared ${name} with ${args.with}${args.editor ? ' (can edit)' : ''}.`);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const visibility = args.org ? 'org' : args.private ? 'private' : args.public ? 'public' : null;
|
|
173
|
+
if (!visibility || remove) throw new Error('Pass --with <email>, --org, --private or --public.');
|
|
174
|
+
await api('PATCH', `/api/apps/${name}`, { visibility });
|
|
175
|
+
console.log(`${name} is now ${{ org: 'open to the whole workspace', private: 'private', public: 'public' }[visibility]}.`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ---------------------------------------------------------------- MCP server (stdio)
|
|
179
|
+
// Lets any MCP-capable agent (Claude Code, Cursor, ...) deploy and share. Uses the same login as the CLI.
|
|
180
|
+
// Deleting apps is deliberately not exposed to agents.
|
|
181
|
+
|
|
182
|
+
const MCP_INSTRUCTIONS = `Aan Cloud hosts websites and tools: public sites anyone can open, and private apps behind sign-in.
|
|
183
|
+
Before building an app for Aan Cloud, call aan_guide once: it explains the app format, the built-in data store and user identity.
|
|
184
|
+
Build the app, then call aan_deploy with the folder that contains index.html (the build output, e.g. dist).
|
|
185
|
+
New apps are private and go into the user's first workspace unless you pass "workspace" (aan_whoami lists them).
|
|
186
|
+
Share only as the user asked: ask before opening an app to the whole workspace (visibility "org") or making it public.`;
|
|
187
|
+
|
|
188
|
+
const str = (description) => ({ type: 'string', description });
|
|
189
|
+
|
|
190
|
+
const MCP_TOOLS = [
|
|
191
|
+
{
|
|
192
|
+
name: 'aan_guide',
|
|
193
|
+
description: 'Read first. How to build an app for Aan Cloud: folder layout, the aan.db() data store, signed-in user info, backends and limits.',
|
|
194
|
+
inputSchema: { type: 'object', properties: {} },
|
|
195
|
+
run: async () => {
|
|
196
|
+
const { host } = await config();
|
|
197
|
+
const res = await fetch(`${host}/docs/building-apps.md`);
|
|
198
|
+
if (!res.ok) throw new Error(`Could not load the guide (${res.status}).`);
|
|
199
|
+
return res.text();
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: 'aan_whoami',
|
|
204
|
+
description: 'Show which Aan Cloud account and instance the agent is deploying to.',
|
|
205
|
+
inputSchema: { type: 'object', properties: {} },
|
|
206
|
+
run: async () => {
|
|
207
|
+
const { host } = await config();
|
|
208
|
+
const me = await api('GET', '/api/me');
|
|
209
|
+
const ws = (me.workspaces ?? []).map((w) => `${w.slug} (${w.name}, ${w.role})`).join(', ');
|
|
210
|
+
return `Signed in to ${host} as ${me.email}.${ws ? ` Workspaces: ${ws}. New apps go into the first one unless you pass "workspace".` : ''}`;
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: 'aan_list_apps',
|
|
215
|
+
description: 'List the Aan Cloud apps the user can open or manage, with their URLs and who can open them.',
|
|
216
|
+
inputSchema: { type: 'object', properties: {} },
|
|
217
|
+
run: async () => {
|
|
218
|
+
const { apps } = await api('GET', '/api/apps');
|
|
219
|
+
if (!apps.length) return 'No apps yet.';
|
|
220
|
+
return apps.map((a) => `${a.name} (${a.title ?? a.name}): ${a.url}, workspace ${a.workspace}, visibility ${a.visibility}, your role ${a.role}`).join('\n');
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: 'aan_deploy',
|
|
225
|
+
description:
|
|
226
|
+
'Deploy a folder to Aan Cloud and return its URL. The folder must contain index.html at its root (use the build output such as dist/). Deploying to an existing name you own publishes a new version.',
|
|
227
|
+
inputSchema: {
|
|
228
|
+
type: 'object',
|
|
229
|
+
properties: {
|
|
230
|
+
folder: str('Path to the folder with index.html (absolute, or relative to the current project).'),
|
|
231
|
+
name: str('Web address name: lowercase letters, numbers and dashes, e.g. "leave-tracker".'),
|
|
232
|
+
title: str('Human-readable app name, e.g. "Leave Tracker".'),
|
|
233
|
+
workspace: str('Optional: the workspace short name for a new app (see aan_whoami). Existing apps stay in their workspace.'),
|
|
234
|
+
backend: str('Optional: https URL of an existing backend that should receive the backendPaths requests.'),
|
|
235
|
+
backendPaths: { type: 'array', items: { type: 'string' }, description: 'Path prefixes sent to the backend, e.g. ["/api", "/hubs"]. Default ["/api"].' },
|
|
236
|
+
},
|
|
237
|
+
required: ['folder', 'name'],
|
|
238
|
+
},
|
|
239
|
+
run: async (a) => {
|
|
240
|
+
const r = await deployFolder(a.folder, { name: a.name, title: a.title, workspace: a.workspace, backend: a.backend, backendPaths: a.backendPaths });
|
|
241
|
+
return [
|
|
242
|
+
`Deployed ${r.fileCount} files to ${r.url} (workspace ${r.workspace})`,
|
|
243
|
+
`Manage it at ${r.manage}`,
|
|
244
|
+
r.backend ? `Requests to ${r.backendPaths} go to ${r.backend}.` : null,
|
|
245
|
+
r.created ? 'The app is private: only the user can open it. Use aan_share if the user asked to share it.' : null,
|
|
246
|
+
]
|
|
247
|
+
.filter(Boolean)
|
|
248
|
+
.join('\n');
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: 'aan_share',
|
|
253
|
+
description:
|
|
254
|
+
'Share an app. Give "email" (with optional "role") to add a person, or "visibility" to change who can open it: private, org (every member of its workspace) or public. Only widen access as far as the user asked.',
|
|
255
|
+
inputSchema: {
|
|
256
|
+
type: 'object',
|
|
257
|
+
properties: {
|
|
258
|
+
name: str('App name.'),
|
|
259
|
+
email: str('Person to add.'),
|
|
260
|
+
role: { type: 'string', enum: ['viewer', 'editor'], description: 'viewer can use the app; editor can also redeploy and share. Default viewer.' },
|
|
261
|
+
visibility: { type: 'string', enum: ['private', 'org', 'public'], description: 'Who can open the app.' },
|
|
262
|
+
},
|
|
263
|
+
required: ['name'],
|
|
264
|
+
},
|
|
265
|
+
run: async (a) => {
|
|
266
|
+
const done = [];
|
|
267
|
+
if (a.email) {
|
|
268
|
+
await api('POST', `/api/apps/${a.name}/members`, { email: a.email, role: a.role ?? 'viewer' });
|
|
269
|
+
done.push(`shared with ${a.email} as ${a.role ?? 'viewer'}`);
|
|
270
|
+
}
|
|
271
|
+
if (a.visibility) {
|
|
272
|
+
await api('PATCH', `/api/apps/${a.name}`, { visibility: a.visibility });
|
|
273
|
+
done.push(`visibility set to ${a.visibility}`);
|
|
274
|
+
}
|
|
275
|
+
if (!done.length) throw new Error('Pass "email" or "visibility".');
|
|
276
|
+
return `${a.name}: ${done.join(', ')}.`;
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
name: 'aan_unshare',
|
|
281
|
+
description: "Remove a person's access to an app.",
|
|
282
|
+
inputSchema: { type: 'object', properties: { name: str('App name.'), email: str('Person to remove.') }, required: ['name', 'email'] },
|
|
283
|
+
run: async (a) => {
|
|
284
|
+
await api('DELETE', `/api/apps/${a.name}/members/${encodeURIComponent(a.email)}`);
|
|
285
|
+
return `Removed ${a.email} from ${a.name}.`;
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
name: 'aan_set_backend',
|
|
290
|
+
description: 'Forward some paths of an app (default /api) to a backend running elsewhere, WebSockets included. Pass an empty url to remove the backend.',
|
|
291
|
+
inputSchema: {
|
|
292
|
+
type: 'object',
|
|
293
|
+
properties: {
|
|
294
|
+
name: str('App name.'),
|
|
295
|
+
url: str('https URL of the backend, or "" to remove it.'),
|
|
296
|
+
paths: { type: 'array', items: { type: 'string' }, description: 'Path prefixes, e.g. ["/api", "/hubs"].' },
|
|
297
|
+
},
|
|
298
|
+
required: ['name', 'url'],
|
|
299
|
+
},
|
|
300
|
+
run: async (a) => {
|
|
301
|
+
await api('PATCH', `/api/apps/${a.name}`, { backend: a.url || null, backendPaths: (a.paths ?? []).join(',') });
|
|
302
|
+
return a.url
|
|
303
|
+
? `${a.name}: ${(a.paths ?? ['/api']).join(', ')} now go to ${a.url}. The backend should check the x-aan-proxy-secret header; the secret is on the app's Backend tab in the portal.`
|
|
304
|
+
: `${a.name} no longer forwards to a backend.`;
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
];
|
|
308
|
+
|
|
309
|
+
async function mcp() {
|
|
310
|
+
const { createInterface } = await import('node:readline');
|
|
311
|
+
const send = (msg) => process.stdout.write(`${JSON.stringify(msg)}\n`);
|
|
312
|
+
const reply = (id, result) => send({ jsonrpc: '2.0', id, result });
|
|
313
|
+
const fail = (id, code, message) => send({ jsonrpc: '2.0', id, error: { code, message } });
|
|
314
|
+
|
|
315
|
+
async function handle(msg) {
|
|
316
|
+
if (msg.id === undefined || msg.id === null) return; // notifications need no answer
|
|
317
|
+
switch (msg.method) {
|
|
318
|
+
case 'initialize':
|
|
319
|
+
return reply(msg.id, {
|
|
320
|
+
protocolVersion: msg.params?.protocolVersion ?? '2025-06-18',
|
|
321
|
+
capabilities: { tools: {} },
|
|
322
|
+
serverInfo: { name: 'aan-cloud', version: VERSION },
|
|
323
|
+
instructions: MCP_INSTRUCTIONS,
|
|
324
|
+
});
|
|
325
|
+
case 'ping':
|
|
326
|
+
return reply(msg.id, {});
|
|
327
|
+
case 'tools/list':
|
|
328
|
+
return reply(msg.id, { tools: MCP_TOOLS.map(({ run, ...tool }) => tool) });
|
|
329
|
+
case 'tools/call': {
|
|
330
|
+
const tool = MCP_TOOLS.find((t) => t.name === msg.params?.name);
|
|
331
|
+
if (!tool) return fail(msg.id, -32602, `Unknown tool: ${msg.params?.name}`);
|
|
332
|
+
try {
|
|
333
|
+
return reply(msg.id, { content: [{ type: 'text', text: await tool.run(msg.params.arguments ?? {}) }] });
|
|
334
|
+
} catch (e) {
|
|
335
|
+
return reply(msg.id, { content: [{ type: 'text', text: e.message }], isError: true });
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
default:
|
|
339
|
+
return fail(msg.id, -32601, `Method not found: ${msg.method}`);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// stdout carries protocol messages only; anything else would corrupt the stream.
|
|
344
|
+
console.log = console.error;
|
|
345
|
+
process.stdout.on('error', () => process.exit(0)); // the client went away
|
|
346
|
+
for await (const line of createInterface({ input: process.stdin })) {
|
|
347
|
+
if (!line.trim()) continue;
|
|
348
|
+
let msg;
|
|
349
|
+
try {
|
|
350
|
+
msg = JSON.parse(line);
|
|
351
|
+
} catch {
|
|
352
|
+
fail(null, -32700, 'Parse error');
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
handle(msg).catch((e) => fail(msg.id ?? null, -32603, e.message));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
async function main() {
|
|
360
|
+
const args = parseArgs(process.argv.slice(2));
|
|
361
|
+
const cmd = args._[0];
|
|
362
|
+
if (args.version || cmd === 'version') return console.log(VERSION);
|
|
363
|
+
switch (cmd) {
|
|
364
|
+
case 'login': {
|
|
365
|
+
if (typeof args.token !== 'string') throw new Error('Usage: aan login --token <token> [--host <url>] (create a token at https://aancloud.com/developer)');
|
|
366
|
+
const host = (typeof args.host === 'string' ? args.host : DEFAULT_HOST).replace(/\/+$/, '');
|
|
367
|
+
if (!/^https?:\/\//.test(host)) throw new Error(`--host must be a URL such as ${DEFAULT_HOST}`);
|
|
368
|
+
// Check the token before saving it, so a typo never replaces working credentials.
|
|
369
|
+
process.env.AAN_HOST = host;
|
|
370
|
+
process.env.AAN_TOKEN = args.token;
|
|
371
|
+
const me = await api('GET', '/api/me').catch((e) => {
|
|
372
|
+
throw new Error(/token/i.test(e.message) ? `That token isn't valid for ${host}. Create a new one at ${host}/developer.` : e.message);
|
|
373
|
+
});
|
|
374
|
+
await mkdir(join(homedir(), '.aan'), { recursive: true });
|
|
375
|
+
await writeFile(CONFIG_PATH, JSON.stringify({ host, token: args.token }, null, 2), { mode: 0o600 });
|
|
376
|
+
return console.log(`Logged in to ${host} as ${me.email}.`);
|
|
377
|
+
}
|
|
378
|
+
case 'whoami':
|
|
379
|
+
return console.log((await api('GET', '/api/me')).email);
|
|
380
|
+
case 'deploy':
|
|
381
|
+
return deploy(args);
|
|
382
|
+
case 'apps': {
|
|
383
|
+
const { apps } = await api('GET', '/api/apps');
|
|
384
|
+
if (!apps.length) return console.log('No apps yet.');
|
|
385
|
+
for (const a of apps) console.log(`${a.name.padEnd(28)} ${String(a.workspace).padEnd(20)} ${a.visibility.padEnd(8)} ${a.role.padEnd(7)} ${a.url}`);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
case 'workspaces': {
|
|
389
|
+
const { workspaces } = await api('GET', '/api/workspaces');
|
|
390
|
+
if (!workspaces.length) return console.log('No workspaces yet. One is created for you on your first deploy.');
|
|
391
|
+
for (const w of workspaces) console.log(`${w.slug.padEnd(28)} ${w.roleLabel.padEnd(8)} ${w.name}`);
|
|
392
|
+
return console.log('\nNew apps go into the first workspace above. Pick another with: aan deploy --workspace <name>');
|
|
393
|
+
}
|
|
394
|
+
case 'share':
|
|
395
|
+
return share(args, false);
|
|
396
|
+
case 'unshare':
|
|
397
|
+
return share(args, true);
|
|
398
|
+
case 'backend': {
|
|
399
|
+
const [, name, url] = args._;
|
|
400
|
+
if (!name || (!url && !args.off)) throw new Error('Usage: aan backend <name> <url> [--paths /api,/hubs] or aan backend <name> --off');
|
|
401
|
+
await api('PATCH', `/api/apps/${name}`, { backend: args.off ? null : url, backendPaths: typeof args.paths === 'string' ? args.paths : '' });
|
|
402
|
+
if (args.off) return console.log(`${name} no longer forwards to a backend.`);
|
|
403
|
+
return console.log(`${name}: requests to ${typeof args.paths === 'string' ? args.paths : '/api'} now go to ${url}.\nThe proxy secret for your backend is on ${name}'s page in the dashboard.`);
|
|
404
|
+
}
|
|
405
|
+
case 'mcp':
|
|
406
|
+
return mcp();
|
|
407
|
+
case 'delete': {
|
|
408
|
+
if (!args._[1] || !args.yes) throw new Error('Usage: aan delete <name> --yes (deletes the app and all its data)');
|
|
409
|
+
await api('DELETE', `/api/apps/${args._[1]}`);
|
|
410
|
+
return console.log(`Deleted ${args._[1]}.`);
|
|
411
|
+
}
|
|
412
|
+
default:
|
|
413
|
+
console.log(HELP);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
main().catch((e) => {
|
|
418
|
+
console.error(`aan: ${e.message}`);
|
|
419
|
+
process.exit(1);
|
|
420
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aancloud",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Deploy and share websites and apps on Aan Cloud from your terminal or your AI agent (MCP).",
|
|
5
|
+
"keywords": ["aan cloud", "aancloud", "hosting", "deploy", "static site", "mcp", "ai agent", "cli"],
|
|
6
|
+
"homepage": "https://aancloud.com/docs",
|
|
7
|
+
"bugs": { "email": "support@aan0.com" },
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"author": "AAN Software LLC <hello@aan0.com> (https://aancloud.com)",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"bin": { "aan": "aan.mjs" },
|
|
12
|
+
"files": ["aan.mjs", "README.md", "LICENSE"],
|
|
13
|
+
"engines": { "node": ">=18" }
|
|
14
|
+
}
|