@dreamtree-org/harness-device 0.9.4 → 0.10.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/CHANGELOG.md +7 -0
- package/README.md +13 -3
- package/package.json +1 -1
- package/src/capabilities.js +7 -12
- package/src/cli.js +15 -2
- package/src/config.js +1 -1
- package/src/device.js +1 -1
- package/src/dokploy.js +192 -0
- package/src/mcp/interact.js +33 -4
- package/src/mcp/server.js +42 -0
- package/src/pool/sync.js +3 -3
- package/src/providers/claude.js +1 -1
- package/src/serve/scopes.js +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
- **Dokploy secrets reach the device without passing through the agent.** `dokploy_project_list` (ids and names), `dokploy_env_keys` (names only) and `dokploy_secret_import`, which copies one env var from a Dokploy application or compose service straight into `secrets.env` after you approve it. The import refuses reserved names and the device's own credentials, and won't replace an existing secret unless `overwrite`. CLI: `harness-device dokploy list | keys | import`. Scopes: the list tools are `device:read`, the import is `device:operate`.
|
|
6
|
+
- **Set the Dokploy and ngrok credentials from a session.** `credential_set` (`kind: dokploy` or `ngrok`) asks for the secret in a private form, so it stays out of the chat. Clients without forms say so and take a `value` argument only if you agree. A confirmation token never covers or repeats the value. The Dokploy key is checked against the API. `credential_status` shows what is set, never values. `credential_set` needs `device:admin` through `serve` and the pool.
|
|
7
|
+
- **`app_remove` / `app rm`** removes a managed app safely (stops it, archives its workspaces, deletes its folder), refusing while it holds work found nowhere else.
|
|
8
|
+
- **macOS: `ngrok_up` works again after a device stop**, and failed tunnels are reported. Public previews return the ngrok login as `public_login`.
|
|
9
|
+
|
|
3
10
|
## 0.9.0
|
|
4
11
|
|
|
5
12
|
Ties the device into the Dreamtree agent standard 3, as described in ai-builder's `standard sdlc/environment` and `sdlc/evidence`.
|
package/README.md
CHANGED
|
@@ -125,6 +125,16 @@ harness-device doctor # "Dokploy API accepts the key"
|
|
|
125
125
|
|
|
126
126
|
Secrets in Dokploy's API responses (env vars, passwords, tokens) are redacted before they reach the agent (`DOKPLOY_REDACT_ENV=true`). To load fewer Dokploy tools, add any of these to `config.env` and run `install` again: `DOKPLOY_TOOL_PRESET`, `DOKPLOY_ENABLED_TAGS=project,application,postgres`, `DOKPLOY_DISABLED_TAGS`. If you already have your own `dokploy` MCP server, install leaves it as it is and the device's is not registered.
|
|
127
127
|
|
|
128
|
+
From a remote session (you approve each step), without anyone at the machine:
|
|
129
|
+
|
|
130
|
+
| Tool | |
|
|
131
|
+
| --- | --- |
|
|
132
|
+
| `credential_status` | Which Dokploy and ngrok credentials are set (never their values) and whether Dokploy accepts the key |
|
|
133
|
+
| `credential_set` | `kind: dokploy` (URL + API key) or `kind: ngrok` (authtoken). You type the secret into a private form, so it never enters the chat. Clients that can't show forms (Remote Control, the HTTP server, the pool) say so and only take it as a `value` argument if you agree, knowing it is then visible in the conversation. The Dokploy key is checked against the API. Needs `device:admin` through `serve` and the pool |
|
|
134
|
+
| `dokploy_project_list` | Projects with their environments, applications and compose services: ids and names only |
|
|
135
|
+
| `dokploy_env_keys` | Env var names of one application or compose service. Never the values |
|
|
136
|
+
| `dokploy_secret_import` | Copies one env var from Dokploy straight into the device secrets (asks first). The value never passes through the agent; use it by name afterwards (`env_manage` `from_secret`, `exec` `env_refs`). It refuses to replace an existing secret unless `overwrite`, and refuses the device's own credentials and reserved names. CLI: `harness-device dokploy list | keys <id> | import <id> KEY [--as NAME] [--overwrite]` (`compose:<id>` for compose services) |
|
|
137
|
+
|
|
128
138
|
### Stop, start, restart
|
|
129
139
|
|
|
130
140
|
Run these on the machine (a terminal or SSH), not from a session: stopping ends every session.
|
|
@@ -303,7 +313,7 @@ Pick them with `init --with`/`--without`, or edit `CAPABILITIES=` in `config.env
|
|
|
303
313
|
| `playwright` | | | Playwright MCP attached to that browser; `hd-pw-live` headed runs and UI mode |
|
|
304
314
|
| `sqlite` | apt `sqlite3` | built in | `sqlite3` |
|
|
305
315
|
| `docker` | Docker Engine (`get.docker.com`) | Docker Desktop, else colima | `docker`, `docker compose` |
|
|
306
|
-
| `dokploy` | API only | API only | Dokploy MCP against your deployment (`DOKPLOY_URL` + `secrets set DOKPLOY_API_KEY`); nothing is installed |
|
|
316
|
+
| `dokploy` | API only | API only | Dokploy MCP against your deployment (`DOKPLOY_URL` + `secrets set DOKPLOY_API_KEY`, or `credential_set`), plus the `dokploy_*` device tools; nothing is installed |
|
|
307
317
|
| `graphify` | | | `@dreamtree-org/graphify` CLI; `graphify .` wires a project's graph MCP and hooks |
|
|
308
318
|
| `ngrok` | apt repo | Homebrew (Intel: ngrok's official release, into `~/.local/bin`) | Tunnels you open; the agent may only read them |
|
|
309
319
|
| `pool` | systemd unit | launchd agent | Member of a HarnessPro pool: outbound link, calls routed here within `POOL_SCOPES` |
|
|
@@ -319,9 +329,9 @@ Remote sessions run commands without anyone at the keyboard, so `install` merges
|
|
|
319
329
|
- **Pre-approved:** git, npm/npx/node, tmux, curl, docker, sqlite3, graphify, `hd-pw-live`, read-only system commands, the read-only `harness-device` subcommands (`status`, `logs`, `proc list`, `session list`/`new`…), the Playwright and graphify MCP tools, and the harness-device MCP tools that only read (status, sessions, logs, viewers, screenshot…) or restart the browser.
|
|
320
330
|
- **Denied:** `sudo`, `su`, shutdown/reboot, `mkfs`, `dd`, `rm -rf` of `/` or home, `tmux kill-server`/`kill-session`, reading `secrets.env`, the ngrok config and `~/.ssh`, **editing anything in `~/.harness-device`**, and `harness-device init`/`install`/`uninstall`/`secrets`.
|
|
321
331
|
- **Never from inside a session:** restarting tmux (it holds every live session); the MCP tool refuses it, and the CLI asks for `--force`.
|
|
322
|
-
- **Everything else asks you**, including Dokploy deploys, registering or removing processes (`proc_add`/`proc_remove`), opening public URLs (`ngrok_up`/`ngrok_down`), changing settings (`config_set`) and `session reset`.
|
|
332
|
+
- **Everything else asks you**, including Dokploy deploys, registering or removing processes (`proc_add`/`proc_remove`), opening public URLs (`ngrok_up`/`ngrok_down`), changing settings (`config_set`), credentials (`credential_set`), importing a secret from Dokploy (`dokploy_secret_import`) and `session reset`.
|
|
323
333
|
|
|
324
|
-
**Remote first.** You approve those prompts in the session itself, on your phone or claude.ai, so nothing a session does needs you at the machine. A session changes the device only through these tools, never by editing its files, and never asks you to type commands on the machine. Only three things need the machine (locally or over SSH): entering secrets, `init`/`install` (capabilities, projects, upgrades) and the first `claude` login.
|
|
334
|
+
**Remote first.** You approve those prompts in the session itself, on your phone or claude.ai, so nothing a session does needs you at the machine. A session changes the device only through these tools, never by editing its files, and never asks you to type commands on the machine. Only three things need the machine (locally or over SSH): entering secrets other than the Dokploy and ngrok credentials (those go in with `credential_set`, through a private form) or ones Dokploy already holds (`dokploy_secret_import`), `init`/`install` (capabilities, projects, upgrades) and the first `claude` login.
|
|
325
335
|
|
|
326
336
|
**Interactive questions.** When the agent needs a decision it asks with the provider's interactive prompt (in Claude, `AskUserQuestion`: tappable options plus "Other"), not a question in prose. The device's own tools show forms for missing details and confirmations (MCP elicitation: pick a tunnel, enter a port, confirm closing URLs). Neither ever asks for a secret.
|
|
327
337
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreamtree-org/harness-device",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Turn a Linux server into a reboot-proof Claude Code harness: Remote Control per project in tmux, a persistent Chromium + Playwright MCP on a virtual display, live viewers (noVNC, ttyd, Playwright UI), self-healing systemd services, plus Docker, Dokploy, ngrok and AI-provider tooling.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Partha Preetham Krishna",
|
package/src/capabilities.js
CHANGED
|
@@ -12,6 +12,7 @@ import fs from 'node:fs';
|
|
|
12
12
|
import path from 'node:path';
|
|
13
13
|
import { ok, httpOk, httpJson, which } from './util.js';
|
|
14
14
|
import { listSessions, listProcs } from './state.js';
|
|
15
|
+
import { probe as dokployApi } from './dokploy.js';
|
|
15
16
|
|
|
16
17
|
export const PLAYWRIGHT_MCP = '@playwright/mcp@0.0.86';
|
|
17
18
|
export const DOKPLOY_MCP = '@dokploy/mcp@0.30.7';
|
|
@@ -20,15 +21,6 @@ export const DOKPLOY_OPTIONS = ['DOKPLOY_TOOL_PRESET', 'DOKPLOY_ENABLED_TAGS', '
|
|
|
20
21
|
|
|
21
22
|
const isMac = (plat) => plat && plat.id === 'darwin';
|
|
22
23
|
|
|
23
|
-
async function dokployApi(url, key) {
|
|
24
|
-
try {
|
|
25
|
-
const res = await fetch(`${url.replace(/\/+$/, '')}/api/project.all`, { headers: { 'x-api-key': key }, signal: AbortSignal.timeout(8000) });
|
|
26
|
-
return res.status;
|
|
27
|
-
} catch {
|
|
28
|
-
return 0;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
24
|
/** @type {Record<string, any>} */
|
|
33
25
|
export const CAPABILITIES = {
|
|
34
26
|
shell: {
|
|
@@ -95,7 +87,8 @@ The device guards its resources. Before heavy work (builds, test runs, container
|
|
|
95
87
|
### Upgrades
|
|
96
88
|
harness-device upgrades itself from npm (AUTO_UPGRADE, default minor) without stopping sessions or unchanged services. \`upgrade\` with check=true shows what is available; a newer version applies to this session's device tools when the session next restarts.
|
|
97
89
|
- To upgrade the device, call \`upgrade\` (\`check: true\` first to see what's available): npm installs go to the newest version, source-folder installs apply the folder's current code; by default the device then restarts gracefully so every session loads the new tools. To restart the whole device without upgrading (when things are wedged), call \`device_restart\`. Either way, tell the user first that this session ends and resumes in about a minute. Stopping the device (\`harness-device stop\`/\`start\`) is done at the machine.
|
|
98
|
-
-
|
|
90
|
+
- Credentials: \`credential_status\` shows what is set; \`credential_set\` sets the Dokploy URL + key or the ngrok authtoken. Call it without \`value\` so the user types the secret into a private form; only if the tool says no form can be shown, and the user agrees, pass it as \`value\`. Never ask for a secret in plain chat yourself, never make one up, and never repeat one.
|
|
91
|
+
- Only three things need the machine itself (local or SSH): other secrets (\`harness-device secrets set\`), \`harness-device init/install\` (capabilities, projects, upgrades) and the first \`claude\` login. Those commands are denied to you.`,
|
|
99
92
|
},
|
|
100
93
|
|
|
101
94
|
system: {
|
|
@@ -115,7 +108,7 @@ Apps are repositories this device runs, in \`${cfg.APPS_DIR || '~/apps'}\`; unli
|
|
|
115
108
|
- Per-ticket work: \`workspace_create {"app":"web","ticket":"HARNESS-5"}\` gives a git worktree on branch ticket/HARNESS-5 from a pinned base, with its own port, as the app \`web--harness-5\` (use it with exec, file_*, project_start…). \`workspace_status\` shows uncommitted files and commits ahead; \`workspace_archive\` keeps the branch and refuses to lose uncommitted work unless the user agrees.
|
|
116
109
|
- Previews: \`preview_start {"app":"web--harness-5"}\` starts the dev server if needed, health-checks it and returns an expiring link through an authenticating proxy (127.0.0.1; give the user the url and the ssh_tunnel command). Only with \`public: true\` (asks the user) does it get a public ngrok URL. \`preview_screenshot\` is evidence; \`preview_stop\` revokes the link.
|
|
117
110
|
- \`shell_exec\` runs one shell command in an app folder; through the pool it needs device:admin.
|
|
118
|
-
- Private GitHub repos use the device secret GITHUB_TOKEN; if it is missing, ask the user to set it (on the machine,
|
|
111
|
+
- Private GitHub repos use the device secret GITHUB_TOKEN; if it is missing, ask the user to set it (on the machine, as a pool secret, or with \`dokploy_secret_import\` when Dokploy has it), never for the token itself.
|
|
119
112
|
|
|
120
113
|
## Device, disk and services
|
|
121
114
|
- Overview: \`harness-device status\` (or the \`device_status\` / \`disk_usage\` MCP tools).
|
|
@@ -211,7 +204,9 @@ You can use \`docker\` and \`docker compose\` directly${isMac(plat) ? ' (the eng
|
|
|
211
204
|
return out;
|
|
212
205
|
},
|
|
213
206
|
docs: (cfg) => `## Dokploy
|
|
214
|
-
Deployments go through the user's Dokploy at ${cfg.DOKPLOY_URL || '(DOKPLOY_URL not set yet)'}; nothing of Dokploy runs on this device. Use the \`dokploy\` MCP tools to inspect and deploy projects, applications, databases and compose stacks. Deploys, redeploys, deletes and env changes need the user's approval: say what you will change first
|
|
207
|
+
Deployments go through the user's Dokploy at ${cfg.DOKPLOY_URL || '(DOKPLOY_URL not set yet)'}; nothing of Dokploy runs on this device. Use the \`dokploy\` MCP tools to inspect and deploy projects, applications, databases and compose stacks. Deploys, redeploys, deletes and env changes need the user's approval: say what you will change first.
|
|
208
|
+
- To bring a value from Dokploy onto this device (a database URL, an API key): \`dokploy_project_list\` → \`dokploy_env_keys\` (names only) → \`dokploy_secret_import\`. The value goes straight into the device secrets without you seeing it; use it by name afterwards (\`env_manage\` from_secret, \`exec\` env_refs). Never ask the user to paste such a value instead.
|
|
209
|
+
- Dokploy not configured, or the key refused: \`credential_status\`, then \`credential_set\` with kind=dokploy.`,
|
|
215
210
|
},
|
|
216
211
|
|
|
217
212
|
graphify: {
|
package/src/cli.js
CHANGED
|
@@ -59,6 +59,8 @@ ${color.bold('Device')}
|
|
|
59
59
|
pool [status] pool hub, link state, POOL_SCOPES; \`pool link\` is the service
|
|
60
60
|
app list | clone <url> [--name N] [--branch B] | pull|setup|start|stop|deploy <app> | exec <app> -- <cmd> | rm <app> [--force]
|
|
61
61
|
managed apps in APPS_DIR (~/apps): clone, install, run, update (jobs run in the background)
|
|
62
|
+
dokploy list [project] | keys <app-id|compose:<id>> | import <app-id|compose:<id>> KEY [--as NAME] [--overwrite]
|
|
63
|
+
Dokploy projects, env var names (never values), and copying one value into the device secrets
|
|
62
64
|
job list | job <id> | job run <id> background jobs (clone, setup, deploy) and their logs
|
|
63
65
|
limits [--enforce] [--json] safe maximums (RAM reserve, per process, browser, sessions) and current use; --enforce runs one watchdog pass
|
|
64
66
|
cleanup [--apply] [item...] [--json] what could be freed safely (caches, build cache, old reports/logs); --apply removes it
|
|
@@ -80,8 +82,8 @@ ${color.bold('Fleet')} (from any machine with ssh access to the devices)
|
|
|
80
82
|
Capabilities: ${ORDER.map((id) => (CAPABILITIES[id].required ? `${id}*` : id)).join(', ')} (* always on)
|
|
81
83
|
`;
|
|
82
84
|
|
|
83
|
-
const BOOL_FLAGS = ['dryRun', 'skipSystem', 'skipPkg', 'graceful', 'json', 'purge', 'force', 'follow', 'help', 'version', 'check', 'auto', 'detach', 'hook', 'now', 'apply', 'restart', 'enforce', 'quiet', 'systemSteps', 'session'];
|
|
84
|
-
const VALUE_FLAGS = ['enroll', 'name', 'branch', 'command', 'tokenSecret', 'device', 'project', 'with', 'without', 'capabilities', 'serveMode', 'provider', 'dokployUrl', 'port', 'to', 'wait', 'timeout', 'except'];
|
|
85
|
+
const BOOL_FLAGS = ['dryRun', 'skipSystem', 'skipPkg', 'graceful', 'json', 'purge', 'force', 'follow', 'help', 'version', 'check', 'auto', 'detach', 'hook', 'now', 'apply', 'restart', 'enforce', 'quiet', 'systemSteps', 'session', 'overwrite'];
|
|
86
|
+
const VALUE_FLAGS = ['enroll', 'name', 'branch', 'command', 'tokenSecret', 'device', 'project', 'with', 'without', 'capabilities', 'serveMode', 'provider', 'dokployUrl', 'port', 'to', 'wait', 'timeout', 'except', 'as'];
|
|
85
87
|
|
|
86
88
|
// Commands whose tail is someone else's command line, kept verbatim:
|
|
87
89
|
// `proc add <name> <dir> <command...>` and `fleet run <device> <args...>`.
|
|
@@ -340,6 +342,17 @@ export async function main(argv) {
|
|
|
340
342
|
throw new Error('usage: harness-device app list|clone|pull|setup|start|stop|deploy|exec|rm <app> [--force]');
|
|
341
343
|
}
|
|
342
344
|
|
|
345
|
+
case 'dokploy': {
|
|
346
|
+
const ctx = loadContext(env);
|
|
347
|
+
const dk = await import('./dokploy.js');
|
|
348
|
+
const out = (v) => console.log(JSON.stringify(v, null, 2));
|
|
349
|
+
const src = (id = '') => (id.startsWith('compose:') ? { compose_id: id.slice(8) } : { application_id: id });
|
|
350
|
+
if (!sub || sub === 'list') return out(await dk.projects(ctx, rest[0]));
|
|
351
|
+
if (sub === 'keys') return out(await dk.envKeys(ctx, src(rest[0])));
|
|
352
|
+
if (sub === 'import') return out(await dk.importSecret(ctx, { ...src(rest[0]), key: rest[1], as: f.as, overwrite: !!f.overwrite }));
|
|
353
|
+
throw new Error('usage: harness-device dokploy list [project] | keys <app-id|compose:<id>> | import <app-id|compose:<id>> KEY [--as NAME] [--overwrite]');
|
|
354
|
+
}
|
|
355
|
+
|
|
343
356
|
case 'preview': {
|
|
344
357
|
const ctx = loadContext(env);
|
|
345
358
|
const preview = await import('./preview.js');
|
package/src/config.js
CHANGED
|
@@ -363,7 +363,7 @@ const NEEDS_INSTALL = /^(DOKPLOY_|TRANSCRIPT_DAYS|AUTO_UPGRADE|RESOURCE_GUARD|RE
|
|
|
363
363
|
/** Validate and save one settable key; returns { key, value, needsInstall }. */
|
|
364
364
|
export function setConfigValue(key, value, env = process.env) {
|
|
365
365
|
if (!Object.prototype.hasOwnProperty.call(SETTABLE_KEYS, key)) {
|
|
366
|
-
const hint = /KEY|TOKEN|SECRET|PASS/i.test(key) ? 'secrets
|
|
366
|
+
const hint = /KEY|TOKEN|SECRET|PASS/i.test(key) ? 'secrets go in with credential_set (Dokploy, ngrok), dokploy_secret_import, or harness-device secrets set KEY on the machine'
|
|
367
367
|
: 'capabilities, projects and ports change with harness-device init + install on the machine';
|
|
368
368
|
throw new Error(`${key} can't be changed from a session (${hint}). Settable: ${Object.keys(SETTABLE_KEYS).join(', ')}`);
|
|
369
369
|
}
|
package/src/device.js
CHANGED
|
@@ -160,7 +160,7 @@ export async function ngrokStatus() {
|
|
|
160
160
|
export async function ngrokUp(ctx, { tunnels = [], ports = [] } = {}) {
|
|
161
161
|
const p = ctx.paths;
|
|
162
162
|
if (!ctx.caps.some((c) => c.id === 'ngrok')) throw new Error('The ngrok capability is off on this device (turn it on with harness-device init --with ngrok + install, on the machine).');
|
|
163
|
-
if (!fs.existsSync(p.ngrokToken)) throw new Error('No ngrok authtoken on this device yet (harness-device ngrok token
|
|
163
|
+
if (!fs.existsSync(p.ngrokToken)) throw new Error('No ngrok authtoken on this device yet: set it with credential_set kind=ngrok (or harness-device ngrok token on the machine).');
|
|
164
164
|
let { cfg } = loadConfig(ctx.env);
|
|
165
165
|
const file = fs.existsSync(p.config) ? fs.readFileSync(p.config, 'utf8') : '';
|
|
166
166
|
let dirty = !/^NGROK_VIEWER_PASS=/m.test(file); // a generated password must be saved, or the next run makes another
|
package/src/dokploy.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
// The device's own window on the user's Dokploy, through its API: list
|
|
2
|
+
// projects and apps, list an app's env var names, and copy one env value into
|
|
3
|
+
// the device's secrets without it ever passing through the agent. Also sets
|
|
4
|
+
// the Dokploy and ngrok credentials themselves.
|
|
5
|
+
//
|
|
6
|
+
// Values never leave this module: every function returns names only, and no
|
|
7
|
+
// error message quotes a value, the API key or a response body.
|
|
8
|
+
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import { parseEnv, loadConfig, saveConfig, validateConfig, setSecret } from './config.js';
|
|
11
|
+
import { readSecrets } from './context.js';
|
|
12
|
+
import { DENY, NAME, VALUE } from './pool/sync.js';
|
|
13
|
+
|
|
14
|
+
/** Secrets that are credentials of the device itself: never overwritten by an import. */
|
|
15
|
+
const CREDENTIALS = /^(DOKPLOY_API_KEY|RUNLOOM_CREDENTIAL)$/;
|
|
16
|
+
const NGROK_TOKEN = /^[A-Za-z0-9_-]{20,200}$/;
|
|
17
|
+
const ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
18
|
+
|
|
19
|
+
const base = (url) => String(url || '').trim().replace(/\/+$/, '');
|
|
20
|
+
|
|
21
|
+
/** GET /api/<path> with the device's API key. Throws short messages that carry no secrets. */
|
|
22
|
+
export async function api(ctx, apiPath, query = {}, { url = ctx.cfg.DOKPLOY_URL, key = ctx.secrets.DOKPLOY_API_KEY } = {}) {
|
|
23
|
+
if (!url || !key) throw new Error('Dokploy is not configured on this device yet: set it with credential_set kind=dokploy (or harness-device init --dokploy-url + secrets set DOKPLOY_API_KEY on the machine).');
|
|
24
|
+
const qs = new URLSearchParams(query).toString();
|
|
25
|
+
let res;
|
|
26
|
+
try {
|
|
27
|
+
res = await fetch(`${base(url)}/api/${apiPath}${qs ? `?${qs}` : ''}`, { headers: { 'x-api-key': key, accept: 'application/json' }, signal: AbortSignal.timeout(8000) });
|
|
28
|
+
} catch (e) {
|
|
29
|
+
throw new Error(`Dokploy at ${base(url)} is unreachable (${e && e.name === 'TimeoutError' ? 'timed out' : 'connection failed'}).`);
|
|
30
|
+
}
|
|
31
|
+
if (res.status === 401 || res.status === 403) throw new Error(`Dokploy refused the API key (HTTP ${res.status}): set a new one with credential_set kind=dokploy.`);
|
|
32
|
+
if (res.status === 404) throw new Error(`Dokploy has no ${apiPath}${query && Object.keys(query).length ? ` for ${Object.values(query).join(', ')}` : ''} (HTTP 404).`);
|
|
33
|
+
if (!res.ok) throw new Error(`Dokploy ${apiPath} failed (HTTP ${res.status}).`);
|
|
34
|
+
try { return await res.json(); } catch { throw new Error(`Dokploy ${apiPath} did not return JSON.`); }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** HTTP status of project.all for a url + key (0 = unreachable); for checks. */
|
|
38
|
+
export async function probe(url, key) {
|
|
39
|
+
try {
|
|
40
|
+
const res = await fetch(`${base(url)}/api/project.all`, { headers: { 'x-api-key': key }, signal: AbortSignal.timeout(8000) });
|
|
41
|
+
return res.status;
|
|
42
|
+
} catch {
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const app = (a) => ({ applicationId: a.applicationId, name: a.name, appName: a.appName });
|
|
48
|
+
const comp = (c) => ({ composeId: c.composeId, name: c.name, appName: c.appName });
|
|
49
|
+
|
|
50
|
+
/** Projects with their applications and compose services: ids and names only, never env. */
|
|
51
|
+
export async function projects(ctx, filter) {
|
|
52
|
+
const all = await api(ctx, 'project.all');
|
|
53
|
+
const want = filter ? String(filter).toLowerCase() : '';
|
|
54
|
+
return (Array.isArray(all) ? all : [])
|
|
55
|
+
.filter((p) => !want || String(p.name || '').toLowerCase().includes(want))
|
|
56
|
+
.map((p) => {
|
|
57
|
+
// Newer Dokploy nests services in environments; older puts them on the project.
|
|
58
|
+
const envs = Array.isArray(p.environments) && p.environments.length ? p.environments : [{ name: 'production', applications: p.applications, compose: p.compose }];
|
|
59
|
+
return {
|
|
60
|
+
projectId: p.projectId,
|
|
61
|
+
name: p.name,
|
|
62
|
+
environments: envs.map((e) => ({
|
|
63
|
+
...(e.environmentId ? { environmentId: e.environmentId } : {}),
|
|
64
|
+
name: e.name,
|
|
65
|
+
applications: (e.applications || []).map(app),
|
|
66
|
+
compose: (e.compose || []).map(comp),
|
|
67
|
+
})),
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Which service: { kind, id, label } from { application_id } or { compose_id }. */
|
|
73
|
+
export function source(a = {}) {
|
|
74
|
+
const has = [a.application_id, a.compose_id].filter((x) => x !== undefined && x !== '');
|
|
75
|
+
if (has.length !== 1) throw new Error('Give exactly one of application_id or compose_id (ids from dokploy_project_list).');
|
|
76
|
+
const kind = a.application_id ? 'application' : 'compose';
|
|
77
|
+
const id = String(a.application_id || a.compose_id);
|
|
78
|
+
if (!ID.test(id)) throw new Error(`Not a Dokploy ${kind} id: ${id.slice(0, 64)}`);
|
|
79
|
+
return { kind, id, label: `${kind} ${id}` };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The service's env as an object. Internal: callers must never return its values. */
|
|
83
|
+
async function envOf(ctx, src) {
|
|
84
|
+
const one = await api(ctx, `${src.kind}.one`, { [`${src.kind}Id`]: src.id });
|
|
85
|
+
return { name: one && (one.name || one.appName), env: parseEnv(String((one && one.env) || '')) };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Env var names of an application or compose service. */
|
|
89
|
+
export async function envKeys(ctx, a) {
|
|
90
|
+
const src = source(a);
|
|
91
|
+
const { name, env } = await envOf(ctx, src);
|
|
92
|
+
return { [`${src.kind}Id`]: src.id, name, keys: Object.keys(env) };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Why `as` can't be the target name, or '' when it can. */
|
|
96
|
+
export function targetProblem(as) {
|
|
97
|
+
if (!NAME.test(as || '')) return `${as} is not a secret name (UPPER_SNAKE_CASE, at most 64 characters)`;
|
|
98
|
+
if (DENY.test(as)) return `${as} is reserved on this device (it would break Remote Control, the server login or the pool link)`;
|
|
99
|
+
if (CREDENTIALS.test(as)) return `${as} is one of the device's own credentials; set it with credential_set or on the machine`;
|
|
100
|
+
return '';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** What an import would do, without fetching anything: for the confirmation message. */
|
|
104
|
+
export function importPlan(ctx, a) {
|
|
105
|
+
const src = source(a);
|
|
106
|
+
const key = String(a.key || '');
|
|
107
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]{0,99}$/.test(key)) throw new Error(`Not an env var name: ${key.slice(0, 100)}`);
|
|
108
|
+
const as = String(a.as || key);
|
|
109
|
+
const bad = targetProblem(as);
|
|
110
|
+
if (bad) throw new Error(`Not imported: ${bad}.`);
|
|
111
|
+
const exists = as in readSecrets(ctx.paths.secrets);
|
|
112
|
+
if (exists && !a.overwrite) throw new Error(`Not imported: the device secret ${as} already exists. Call again with overwrite=true if the user agrees to replace it, or choose another name with as.`);
|
|
113
|
+
return { src, key, as, replaces: exists };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Copy one env value from Dokploy into secrets.env. Returns names only. */
|
|
117
|
+
export async function importSecret(ctx, a) {
|
|
118
|
+
const plan = importPlan(ctx, a);
|
|
119
|
+
const { name, env } = await envOf(ctx, plan.src);
|
|
120
|
+
if (!(plan.key in env)) throw new Error(`${plan.src.label}${name ? ` (${name})` : ''} has no env var ${plan.key}. Its names: ${Object.keys(env).join(', ') || '(none)'}.`);
|
|
121
|
+
const v = env[plan.key];
|
|
122
|
+
if (!v) throw new Error(`${plan.key} is empty in ${plan.src.label}; nothing was imported.`);
|
|
123
|
+
if (!VALUE.test(v)) throw new Error(`${plan.key} can't be stored as a device secret (it contains a single quote or a newline, or is over 4096 characters); nothing was imported.`);
|
|
124
|
+
setSecret(ctx.paths.secrets, plan.as, v);
|
|
125
|
+
return {
|
|
126
|
+
imported: plan.as,
|
|
127
|
+
from: { [`${plan.src.kind}Id`]: plan.src.id, name, key: plan.key },
|
|
128
|
+
replaced: plan.replaces,
|
|
129
|
+
next: `Use it by name: env_manage from_secret, exec env_refs, or MCP servers started from now on. The value was not shown to you.`,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** What is set, never the values. With verify, asks Dokploy whether the key works. */
|
|
134
|
+
export async function credentialStatus(ctx, { verify = true } = {}) {
|
|
135
|
+
const url = ctx.cfg.DOKPLOY_URL || '';
|
|
136
|
+
const keySet = !!ctx.secrets.DOKPLOY_API_KEY;
|
|
137
|
+
let verified;
|
|
138
|
+
if (verify && url && keySet) {
|
|
139
|
+
const st = await probe(url, ctx.secrets.DOKPLOY_API_KEY);
|
|
140
|
+
verified = st === 200 ? true : `no (${st ? `HTTP ${st}` : 'unreachable'})`;
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
dokploy: { url: url || null, keySet, ...(verified === undefined ? {} : { verified }) },
|
|
144
|
+
ngrok: { tokenSet: fs.existsSync(ctx.paths.ngrokToken) && !!fs.readFileSync(ctx.paths.ngrokToken, 'utf8').trim() },
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Problems with a credential before anything is asked or saved; throws. Returns the normalized url. */
|
|
149
|
+
export function checkCredential(ctx, { kind, url }) {
|
|
150
|
+
if (kind === 'ngrok') return undefined;
|
|
151
|
+
if (kind !== 'dokploy') throw new Error('kind must be dokploy or ngrok');
|
|
152
|
+
const u = base(url || ctx.cfg.DOKPLOY_URL);
|
|
153
|
+
if (!u) throw new Error('No Dokploy URL yet: give url (e.g. https://dokploy.example.com).');
|
|
154
|
+
if (!/^https?:\/\/[^\s'"]+$/.test(u)) throw new Error('url must be an http(s) URL.');
|
|
155
|
+
return u;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Save a credential. dokploy: url (optional when already set) + API key, checked
|
|
160
|
+
* against project.all first; ngrok: the authtoken. Returns names only.
|
|
161
|
+
*/
|
|
162
|
+
export async function setCredential(ctx, { kind, url, value }) {
|
|
163
|
+
const v = String(value ?? '').trim();
|
|
164
|
+
if (kind === 'ngrok') {
|
|
165
|
+
if (!NGROK_TOKEN.test(v)) throw new Error('That does not look like an ngrok authtoken (dashboard.ngrok.com → Your Authtoken); nothing was saved.');
|
|
166
|
+
const had = fs.existsSync(ctx.paths.ngrokToken);
|
|
167
|
+
fs.mkdirSync(ctx.paths.home, { recursive: true });
|
|
168
|
+
fs.writeFileSync(ctx.paths.ngrokToken, v + '\n', { mode: 0o600 });
|
|
169
|
+
fs.chmodSync(ctx.paths.ngrokToken, 0o600);
|
|
170
|
+
return { set: ['ngrok authtoken'], replaced: had, next: 'Applies at the next ngrok_up; tunnels already open keep the old token until then.' };
|
|
171
|
+
}
|
|
172
|
+
const u = checkCredential(ctx, { kind, url });
|
|
173
|
+
if (!VALUE.test(v)) throw new Error('That API key is empty, too long, or contains a quote or newline; nothing was saved.');
|
|
174
|
+
const st = await probe(u, v);
|
|
175
|
+
const { cfg } = loadConfig(ctx.env);
|
|
176
|
+
const urlChanged = cfg.DOKPLOY_URL !== u;
|
|
177
|
+
if (urlChanged) {
|
|
178
|
+
const next = { ...cfg, DOKPLOY_URL: u };
|
|
179
|
+
const errs = validateConfig(next, ctx.env);
|
|
180
|
+
if (errs.length) throw new Error(errs.join(' '));
|
|
181
|
+
saveConfig(next, ctx.env);
|
|
182
|
+
}
|
|
183
|
+
const replaced = !!ctx.secrets.DOKPLOY_API_KEY;
|
|
184
|
+
setSecret(ctx.paths.secrets, 'DOKPLOY_API_KEY', v);
|
|
185
|
+
return {
|
|
186
|
+
set: [...(urlChanged ? ['DOKPLOY_URL'] : []), 'DOKPLOY_API_KEY'],
|
|
187
|
+
url: u,
|
|
188
|
+
replaced,
|
|
189
|
+
verified: st === 200 ? true : `no (${st ? `HTTP ${st}${st === 401 || st === 403 ? ': Dokploy refused this key' : ''}` : `${u} unreachable from this device`}); saved anyway`,
|
|
190
|
+
next: `The dokploy_* tools use it now. The Dokploy MCP gets it in new sessions or after device_restart${urlChanged ? '; the new URL reaches it after harness-device install' : ''}.`,
|
|
191
|
+
};
|
|
192
|
+
}
|
package/src/mcp/interact.js
CHANGED
|
@@ -25,9 +25,21 @@ const SECRET = crypto.randomBytes(32);
|
|
|
25
25
|
const TTL_MS = 10 * 60 * 1000;
|
|
26
26
|
const used = new Map(); // token -> expiry, so each "yes" works once
|
|
27
27
|
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Arguments that carry a secret. They are left out of the token (the user
|
|
30
|
+
* approves the action, not the value) and never written back in a reply.
|
|
31
|
+
*/
|
|
32
|
+
export const SECRET_ARGS = new Set(['value']);
|
|
33
|
+
const HIDDEN = '<the same value>';
|
|
34
|
+
|
|
35
|
+
/** The arguments as they may appear in a reply: secret ones masked. */
|
|
36
|
+
export function shown(args) {
|
|
37
|
+
return Object.fromEntries(Object.entries(args || {}).map(([k, v]) => [k, SECRET_ARGS.has(k) && v !== undefined ? HIDDEN : v]));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Stable JSON of the arguments that define the action (the token and secret values excluded). */
|
|
29
41
|
function canonical(args) {
|
|
30
|
-
const keys = Object.keys(args || {}).filter((k) => k !== 'confirm_token' && args[k] !== undefined).sort();
|
|
42
|
+
const keys = Object.keys(args || {}).filter((k) => k !== 'confirm_token' && !SECRET_ARGS.has(k) && args[k] !== undefined).sort();
|
|
31
43
|
return JSON.stringify(keys.map((k) => [k, args[k]]));
|
|
32
44
|
}
|
|
33
45
|
|
|
@@ -102,7 +114,7 @@ export function interaction(server, opts = {}) {
|
|
|
102
114
|
throw new NeedsUser([
|
|
103
115
|
`Nothing was done yet. ${message}: ask the user with AskUserQuestion (offer likely values as options; they can type their own), then call ${tool} again with these arguments added:`,
|
|
104
116
|
...Object.entries(properties).map(([k, p]) => describeField(k, p)),
|
|
105
|
-
`Keep the arguments already given: ${JSON.stringify(args)}.`,
|
|
117
|
+
`Keep the arguments already given: ${JSON.stringify(shown(args))}.`,
|
|
106
118
|
].join('\n'));
|
|
107
119
|
},
|
|
108
120
|
|
|
@@ -122,9 +134,26 @@ export function interaction(server, opts = {}) {
|
|
|
122
134
|
throw new NeedsUser([
|
|
123
135
|
`${args.confirm_token !== undefined ? 'That confirm_token is expired, already used, or for different arguments. ' : ''}Nothing was done yet. This needs the user's OK first.`,
|
|
124
136
|
`Ask the user with AskUserQuestion: "${message}" with the options "Go ahead" and "Cancel".`,
|
|
125
|
-
`If they choose Go ahead, call ${tool} again with exactly these arguments: ${JSON.stringify({ ...rest, confirm_token: token })}`,
|
|
137
|
+
`If they choose Go ahead, call ${tool} again with exactly these arguments: ${JSON.stringify(shown({ ...rest, confirm_token: token }))}${Object.keys(rest).some((k) => SECRET_ARGS.has(k)) ? ` (where it says ${HIDDEN}, pass the value you passed before)` : ''}`,
|
|
126
138
|
'If they cancel, do not call it. The token works once, for these arguments only, for 10 minutes.',
|
|
127
139
|
].join('\n'));
|
|
128
140
|
},
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* A secret value, typed by the user into a form so it never enters the
|
|
144
|
+
* chat. Without a form (remote sessions, the HTTP server) the tool can't
|
|
145
|
+
* get it privately: NeedsUser says how to pass it as `value` instead.
|
|
146
|
+
*/
|
|
147
|
+
async secret(ctx, tool, args, message, title) {
|
|
148
|
+
if (askMode(ctx, server, opts) === 'elicit') {
|
|
149
|
+
const got = await elicit(ctx, server, message, { value: { type: 'string', title, minLength: 1, maxLength: 4096 } }, ['value']);
|
|
150
|
+
if (got && typeof got.value === 'string' && got.value) return got.value;
|
|
151
|
+
}
|
|
152
|
+
throw new NeedsUser([
|
|
153
|
+
`Nothing was done yet. ${message}: this client can't show the private form, so the value has to be passed as the \`value\` argument, and it will then be visible in this conversation (and in the hub's logs when the call goes through HarnessPro).`,
|
|
154
|
+
'Tell the user that and ask with AskUserQuestion whether they want to paste it here or set it on the machine instead (harness-device secrets set / ngrok token). Never invent or reuse a value yourself.',
|
|
155
|
+
`If they paste it, call ${tool} again with these arguments plus "value": ${JSON.stringify(shown((({ confirm_token: _, ...r }) => r)(args)))}`,
|
|
156
|
+
].join('\n'));
|
|
157
|
+
},
|
|
129
158
|
};
|
|
130
159
|
}
|
package/src/mcp/server.js
CHANGED
|
@@ -23,6 +23,7 @@ import * as ws from '../workspace.js';
|
|
|
23
23
|
import * as preview from '../preview.js';
|
|
24
24
|
import { getApp } from '../apps.js';
|
|
25
25
|
import * as removal from '../remove.js';
|
|
26
|
+
import * as dokploy from '../dokploy.js';
|
|
26
27
|
import { Cancelled, NeedsUser, interaction } from './interact.js';
|
|
27
28
|
|
|
28
29
|
const text = (v) => ({ content: [{ type: 'text', text: typeof v === 'string' ? v : JSON.stringify(v, null, 2) }] });
|
|
@@ -65,6 +66,7 @@ export function buildServer(env = process.env, opts = {}) {
|
|
|
65
66
|
return await fn(c, a, {
|
|
66
67
|
ask: (message, properties, required) => io.ask(c, name, a, message, properties, required),
|
|
67
68
|
confirm: (message) => io.confirm(c, name, a, message),
|
|
69
|
+
secret: (message, title) => io.secret(c, name, a, message, title),
|
|
68
70
|
});
|
|
69
71
|
} catch (e) {
|
|
70
72
|
if (e instanceof resources.ResourceDenied) return fail(`${e.message}\n${resources.summary(e.sample)}`);
|
|
@@ -420,6 +422,46 @@ export function buildServer(env = process.env, opts = {}) {
|
|
|
420
422
|
});
|
|
421
423
|
}
|
|
422
424
|
|
|
425
|
+
// ---- Dokploy (src/dokploy.js): names only; values go straight into secrets.env ----------
|
|
426
|
+
if (has(base, 'dokploy')) {
|
|
427
|
+
const SRC = {
|
|
428
|
+
application_id: z.string().regex(/^[A-Za-z0-9_-]{1,64}$/).optional().describe('applicationId from dokploy_project_list'),
|
|
429
|
+
compose_id: z.string().regex(/^[A-Za-z0-9_-]{1,64}$/).optional().describe('composeId from dokploy_project_list (instead of application_id)'),
|
|
430
|
+
};
|
|
431
|
+
tool('dokploy_project_list', 'Projects in the user\'s Dokploy with their environments, applications and compose services: ids and names only (no env values). Use the ids with dokploy_env_keys and dokploy_secret_import.',
|
|
432
|
+
{ project: z.string().max(100).optional().describe('only projects whose name contains this') },
|
|
433
|
+
async (c, a) => text(await dokploy.projects(c, a.project)));
|
|
434
|
+
tool('dokploy_env_keys', 'Names of the environment variables of one Dokploy application or compose service. Values are never returned.',
|
|
435
|
+
{ ...SRC },
|
|
436
|
+
async (c, a) => text(await dokploy.envKeys(c, a)));
|
|
437
|
+
tool('dokploy_secret_import', 'Copy one environment variable of a Dokploy application or compose service into this device\'s secrets (asks the user first). The value goes from Dokploy straight into secrets.env and is never shown to you; use it afterwards by name (env_manage from_secret, exec env_refs). as: the device secret name (default: the same name). Refuses to replace an existing secret unless overwrite=true, and never touches the device\'s own credentials.',
|
|
438
|
+
{ ...SRC, key: z.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,99}$/).describe('env var name in Dokploy (dokploy_env_keys)'), as: z.string().regex(/^[A-Z][A-Z0-9_]{0,63}$/).optional(), overwrite: z.boolean().optional(), ...CONFIRM },
|
|
439
|
+
async (c, a, u) => {
|
|
440
|
+
const p = dokploy.importPlan(c, a);
|
|
441
|
+
await u.confirm(`Copy ${p.key} from Dokploy ${p.src.label} into the device secret ${p.as}${p.replaces ? ' (replacing the existing one)' : ''}? The value goes straight into secrets.env and is not shown in the chat.`);
|
|
442
|
+
return text(await dokploy.importSecret(c, a));
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// ---- Credentials of the device itself: values typed into a form, never echoed ---------------
|
|
447
|
+
tool('credential_status', 'Which Dokploy and ngrok credentials this device has (never their values), and whether Dokploy accepts the key.', {},
|
|
448
|
+
async (c) => text(await dokploy.credentialStatus(c)));
|
|
449
|
+
tool('credential_set', 'Set the Dokploy URL + API key (kind=dokploy) or the ngrok authtoken (kind=ngrok) on this device (asks the user first). Call it WITHOUT value: the user types the secret into a private form, so it never enters the chat. Only when the tool says the form can\'t be shown, and the user agrees, pass it as value. Never make one up. The Dokploy key is checked against the API and saved either way.',
|
|
450
|
+
{ kind: z.enum(['dokploy', 'ngrok']), url: z.string().max(300).optional().describe('Dokploy URL, e.g. https://dokploy.example.com (kind=dokploy; kept when omitted)'), value: z.string().max(4096).optional().describe('the secret itself; only after the tool asks for it this way'), ...CONFIRM },
|
|
451
|
+
async (c, a, u) => {
|
|
452
|
+
if (a.kind === 'dokploy' && !a.url && !c.cfg.DOKPLOY_URL) {
|
|
453
|
+
const got = await u.ask('Which Dokploy should this device use?', { url: { type: 'string', title: 'Dokploy URL', description: 'e.g. https://dokploy.example.com' } });
|
|
454
|
+
a = { ...a, url: got.url };
|
|
455
|
+
}
|
|
456
|
+
const url = dokploy.checkCredential(c, a);
|
|
457
|
+
const what = a.kind === 'dokploy' ? `the Dokploy API key for ${url}` : 'the ngrok authtoken';
|
|
458
|
+
const value = a.value ?? await u.secret(`Enter ${what}`, a.kind === 'dokploy' ? 'Dokploy API key (Settings → Profile → API/CLI)' : 'ngrok authtoken (dashboard.ngrok.com → Your Authtoken)');
|
|
459
|
+
const st = await dokploy.credentialStatus(c, { verify: false });
|
|
460
|
+
const replacing = a.kind === 'dokploy' ? st.dokploy.keySet : st.ngrok.tokenSet;
|
|
461
|
+
await u.confirm(`Save ${what} on device ${c.cfg.DEVICE}${replacing ? ', replacing the current one' : ''}?`);
|
|
462
|
+
return text(await dokploy.setCredential(c, { kind: a.kind, url, value }));
|
|
463
|
+
});
|
|
464
|
+
|
|
423
465
|
tool('disk_cleanup', 'Free disk space safely. Without apply it only lists what could go (Docker build cache, dangling images, old stopped containers not managed by Dokploy/compose, npm/pnpm/pip caches, the user journal, Playwright reports, harness logs) with sizes. apply=true removes the chosen items (all when items is empty) after the user confirms. Never removes volumes, databases or anything Dokploy runs.',
|
|
424
466
|
{ apply: z.boolean().optional(), items: z.array(z.string().regex(/^[a-z0-9-]+$/)).max(20).optional().describe('ids from the listing; empty = all cleanable'), ...CONFIRM },
|
|
425
467
|
async (c, a, u) => {
|
package/src/pool/sync.js
CHANGED
|
@@ -9,9 +9,9 @@ import { readSecrets } from '../context.js';
|
|
|
9
9
|
import { setSecret, setConfigValue, SETTABLE_KEYS, defaults } from '../config.js';
|
|
10
10
|
|
|
11
11
|
/** Names the pool may never set: they would break Remote Control, the server login, or the link itself. */
|
|
12
|
-
const DENY = /^(ANTHROPIC_|CLAUDE_CODE_USE_|SERVE_OWNER_PASSWORD$|POOL_|PATH$|HOME$|LD_|NODE_OPTIONS$|HARNESS_DEVICE_HOME$|HD_)/;
|
|
13
|
-
const NAME = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
14
|
-
const VALUE = /^[^'\n\r]{1,4096}$/;
|
|
12
|
+
export const DENY = /^(ANTHROPIC_|CLAUDE_CODE_USE_|SERVE_OWNER_PASSWORD$|POOL_|PATH$|HOME$|LD_|NODE_OPTIONS$|HARNESS_DEVICE_HOME$|HD_)/;
|
|
13
|
+
export const NAME = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
14
|
+
export const VALUE = /^[^'\n\r]{1,4096}$/;
|
|
15
15
|
|
|
16
16
|
/** Settings the pool may manage (all of them also settable from a session, so validated the same way). */
|
|
17
17
|
export const POOL_CONFIG = /^(RES_[A-Z_]+|MAX_SESSIONS|MAX_PROCS|ASK_MODE|ELICIT_TIMEOUT_SECONDS)$/;
|
package/src/providers/claude.js
CHANGED
|
@@ -168,7 +168,7 @@ export function userMcpServers(env) {
|
|
|
168
168
|
// proc_remove, restart_service and playwright_ui still ask: they start or stop things.
|
|
169
169
|
export const HARNESS_TOOLS_ALLOWED = ['device_status', 'sessions', 'proc_list', 'viewers', 'disk_usage', 'logs',
|
|
170
170
|
'browser_restart', 'screenshot', 'run_tests_live', 'docker_summary', 'ngrok_status', 'config_get', 'resources',
|
|
171
|
-
'app_list', 'file_read', 'job_status'].map((t) => `mcp__harness-device__${t}`);
|
|
171
|
+
'app_list', 'file_read', 'job_status', 'dokploy_project_list', 'dokploy_env_keys', 'credential_status'].map((t) => `mcp__harness-device__${t}`);
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
174
|
* A Read() rule for an absolute path. In Claude Code rules `/x` is relative to
|
package/src/serve/scopes.js
CHANGED
|
@@ -13,11 +13,12 @@ const ORDER = ['device:read', 'device:operate', 'device:admin'];
|
|
|
13
13
|
const TOOLS = {
|
|
14
14
|
'device:read': ['device_status', 'sessions', 'proc_list', 'viewers', 'disk_usage', 'logs', 'resources', 'screenshot', 'docker_summary', 'ngrok_status', 'config_get',
|
|
15
15
|
'app_list', 'file_read', 'job_status', 'workspace_list', 'workspace_status', 'preview_list', 'preview_screenshot',
|
|
16
|
-
'graph_status', 'graph_query', 'graph_summary'],
|
|
16
|
+
'graph_status', 'graph_query', 'graph_summary', 'dokploy_project_list', 'dokploy_env_keys', 'credential_status'],
|
|
17
17
|
'device:operate': ['proc_add', 'proc_remove', 'session_new', 'restart_service', 'browser_restart', 'run_tests_live', 'playwright_ui', 'ngrok_up', 'ngrok_down', 'disk_cleanup', 'docker_limit',
|
|
18
18
|
'git_clone', 'app_remove', 'git_pull', 'project_setup', 'project_start', 'project_stop', 'project_deploy', 'file_write', 'env_manage',
|
|
19
|
-
'exec', 'job_submit', 'job_cancel', 'graph_index', 'workspace_create', 'workspace_archive', 'preview_start', 'preview_stop'
|
|
20
|
-
|
|
19
|
+
'exec', 'job_submit', 'job_cancel', 'graph_index', 'workspace_create', 'workspace_archive', 'preview_start', 'preview_stop',
|
|
20
|
+
'dokploy_secret_import'],
|
|
21
|
+
// shell_exec and credential_set are not listed: they need device:admin (unknown tools do).
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
/** Granted scopes with everything they include. */
|