@parcha/agentrun 0.4.24 → 0.4.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/install.sh +63 -8
- package/lib/cli.mjs +26 -23
- package/lib/commands.generated.mjs +96 -2
- package/lib/deploy.mjs +67 -26
- package/lib/doctor.mjs +3 -7
- package/lib/export.mjs +16 -7
- package/lib/login.mjs +4 -1
- package/lib/service.mjs +7 -2
- package/lib/start.mjs +36 -4
- package/lib/target.mjs +11 -2
- package/package.json +2 -2
- package/skills/agentrun-cli/SKILL.md +4 -38
- package/skills/agentrun-cli/references/commands.md +32 -5
package/README.md
CHANGED
|
@@ -26,10 +26,12 @@ It downloads a Node.js from nodejs.org: the newest release on the major line of
|
|
|
26
26
|
later security releases come with the next install. It checks the download against that release's `SHASUMS256.txt`
|
|
27
27
|
and installs it and AgentRun under `~/.agentrun` (`node/`, `lib/`, `bin/agentrun`). Any other Node, nvm or Homebrew is
|
|
28
28
|
left alone, and nothing needs sudo. When no line in your shell's startup file puts `~/.agentrun/bin` on `PATH`, it adds
|
|
29
|
-
one and says so. Then it starts AgentRun
|
|
30
|
-
Linux, which starts again at login and after a crash and logs to
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
one and says so. Then it starts AgentRun. On a terminal it first asks whether to make it a service of your user, a
|
|
30
|
+
LaunchAgent on macOS or a systemd user unit on Linux, which starts again at login and after a crash and logs to
|
|
31
|
+
`~/.agentrun/logs/agentrun.log`. The answer is No unless you say yes, and then AgentRun runs in the background, logging
|
|
32
|
+
to the same file. With no terminal to ask on, or its output captured (CI, a script, an agent's shell), it installs the
|
|
33
|
+
service without asking; `--service` and `--no-service` choose without the question. Where there is no service manager (a
|
|
34
|
+
container, say), it starts AgentRun in the background. In the background it runs until the machine or container stops, and `agentrun stop` stops it (a SIGTERM, then a SIGKILL to the launcher and its server
|
|
33
35
|
after 45 seconds). Either way the installer returns once AgentRun answers, and prints its address. `sh -s -- --no-start`
|
|
34
36
|
installs only, `--version V` installs another version, `--node-version V` installs that Node.js (at least the floor),
|
|
35
37
|
and `--service` fails where there is no service manager. Running it again upgrades, or installs an older version, and
|
|
@@ -46,7 +48,7 @@ one when the last has run out) until the password is set, the console after. It
|
|
|
46
48
|
`upgrade [--version V]` (the installer again, then a restart) and `uninstall` (the data stays) do what they say, and
|
|
47
49
|
`agentrun service install [--port N] [--data DIR] [--public-url URL]` installs the service after a `--no-start`. The
|
|
48
50
|
Ollama on this machine needs nothing here: the server lists its models itself. For an Ollama off its default address,
|
|
49
|
-
`agentrun service install --env OLLAMA_HOST=<host:port>` writes it into the service and restarts it. For a local model
|
|
51
|
+
`agentrun service install --env OLLAMA_HOST=<host:port>` writes it into the service and restarts it. `--env OLLAMA_CONTEXT_LENGTH=<tokens>` does the same for a lower context than 65,536. For a local model
|
|
50
52
|
behind a gateway, `agentrun service install --env AGENT_MODEL_BASE_URL=<its /v1 address> --env AGENT_MODEL_GATEWAY_IDS=bare
|
|
51
53
|
--env AGENT_MODEL=<tag> --env AGENT_MODEL_PRICE=0,0,0 --env AGENT_MODEL_API_KEY=none` does the same (`none` alone:
|
|
52
54
|
without a key the server refuses each run, `model_key_required`). They stay through restarts, upgrades and later installs, and `--env KEY=` removes one. On a machine
|
package/install.sh
CHANGED
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
# installer keeps to bin, lib, node, logs and agentrun.pid, names the server never uses. No sudo. Running it again
|
|
14
14
|
# installs the version asked for (the latest by default) and removes the others, except one a running server still uses.
|
|
15
15
|
#
|
|
16
|
-
# Then it starts AgentRun as a service of this user (`agentrun service install`: launchd on macOS, systemd --user on
|
|
17
|
-
# Linux), so it keeps running after the terminal closes and starts again at login
|
|
18
|
-
#
|
|
16
|
+
# Then it starts AgentRun: as a service of this user (`agentrun service install`: launchd on macOS, systemd --user on
|
|
17
|
+
# Linux), so it keeps running after the terminal closes and starts again at login, when the person says so in the
|
|
18
|
+
# terminal (want_service; with no terminal to ask in, as before); else, and where this user has no service manager (a
|
|
19
|
+
# container, say), in the background until the machine stops (`agentrun stop` stops it).
|
|
19
20
|
# Either way it returns once AgentRun answers, and prints its address. With --tailscale it is also served over HTTPS on
|
|
20
21
|
# the person's own tailnet (lib/tailscale.mjs), on port 7340. Options: --help.
|
|
21
22
|
#
|
|
@@ -38,6 +39,7 @@ main() {
|
|
|
38
39
|
tarball=
|
|
39
40
|
node_version=
|
|
40
41
|
start=default
|
|
42
|
+
no_service=
|
|
41
43
|
ts_flag=
|
|
42
44
|
vps=
|
|
43
45
|
vps_public=
|
|
@@ -54,6 +56,7 @@ main() {
|
|
|
54
56
|
--node-version=*) node_version=${1#--node-version=}; node_version=${node_version#v}; this_computer=--node-version ;;
|
|
55
57
|
--no-start) start=none; this_computer=$1 ;;
|
|
56
58
|
--service) start=service; this_computer=$1 ;;
|
|
59
|
+
--no-service) no_service=1; this_computer=$1 ;;
|
|
57
60
|
--tailscale | --no-tailscale) ts_flag=$1; this_computer=$1 ;;
|
|
58
61
|
--vps) vps=1 ;;
|
|
59
62
|
--public) vps_public=1 ;;
|
|
@@ -70,6 +73,7 @@ main() {
|
|
|
70
73
|
return 0
|
|
71
74
|
fi
|
|
72
75
|
[ -z "$vps_public$image" ] || fail "--public and --image go with --vps (see --help)"
|
|
76
|
+
[ -z "$no_service" ] || [ "$start" != service ] || fail "--service and --no-service ask for opposite things; give one of them (see --help)"
|
|
73
77
|
if [ -n "$node_version" ] && ! printf '%s\n' "$node_version" | grep -qx '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*'; then
|
|
74
78
|
fail "--node-version $node_version is not a Node.js version (X.Y.Z)"
|
|
75
79
|
fi
|
|
@@ -82,6 +86,9 @@ main() {
|
|
|
82
86
|
need tar
|
|
83
87
|
need gzip
|
|
84
88
|
root=$HOME/.agentrun
|
|
89
|
+
# Before anything is downloaded, so a refusal changes nothing.
|
|
90
|
+
shim=$root/bin/agentrun
|
|
91
|
+
[ ! -x "$shim" ] || no_service_over_service
|
|
85
92
|
|
|
86
93
|
# The launcher's version and its Node floor: from the tarball given, or from the registry's document for that version.
|
|
87
94
|
if [ -n "$tarball" ]; then
|
|
@@ -177,13 +184,22 @@ EOF
|
|
|
177
184
|
default)
|
|
178
185
|
# A service already installed restarts on this version, or installs again to go on or off the tailnet; status
|
|
179
186
|
# exits 3 when there is none.
|
|
187
|
+
no_service_over_service
|
|
180
188
|
code=0
|
|
181
189
|
"$shim" service status > /dev/null 2>&1 || code=$?
|
|
182
190
|
if { [ "$code" = 0 ] || [ "$code" = 1 ]; } && [ -z "$ts_flag" ]; then
|
|
183
191
|
"$shim" service restart
|
|
184
|
-
elif [ "$code" = 0 ] || [ "$code" = 1 ]
|
|
192
|
+
elif [ "$code" = 0 ] || [ "$code" = 1 ]; then
|
|
193
|
+
stop_background
|
|
194
|
+
"$shim" service install ${ts_flag:+"$ts_flag"}
|
|
195
|
+
elif [ "$code" = 3 ] && service_manager && want_service /dev/tty; then
|
|
185
196
|
stop_background
|
|
186
197
|
"$shim" service install ${ts_flag:+"$ts_flag"}
|
|
198
|
+
elif [ "$code" = 3 ] && service_manager; then
|
|
199
|
+
# Asked, and not wanted (or --no-service): it runs now, in the background, until this machine stops.
|
|
200
|
+
say "Starting AgentRun in the background, without a service: it stops when this machine does."
|
|
201
|
+
say "To keep it running after a restart: $(shown_shim) service install"
|
|
202
|
+
start_background
|
|
187
203
|
else
|
|
188
204
|
[ "$code" = 3 ] || why="AgentRun $version has no service command"
|
|
189
205
|
say "AgentRun can't run as a service here ($why), so it runs in the background."
|
|
@@ -203,9 +219,12 @@ AgentRun's installer, for macOS and Linux (x64, arm64):
|
|
|
203
219
|
curl -fsSL https://agentrun.ai/install | sh
|
|
204
220
|
curl -fsSL https://agentrun.ai/install | sh -s -- [options]
|
|
205
221
|
|
|
206
|
-
It installs AgentRun, with a Node.js of its own, in ~/.agentrun, and starts it
|
|
207
|
-
macOS, systemd --user on Linux), which keeps running after the terminal
|
|
208
|
-
|
|
222
|
+
It installs AgentRun, with a Node.js of its own, in ~/.agentrun, and starts it. In a terminal it asks first whether to
|
|
223
|
+
make it a service of this user (launchd on macOS, systemd --user on Linux), which keeps running after the terminal
|
|
224
|
+
closes and starts again at login; the answer is No unless you say yes, and then AgentRun runs in the background until
|
|
225
|
+
the machine stops (`agentrun stop` stops it). With no terminal to ask in, or its output going to a pipe or a file, it
|
|
226
|
+
installs the service, as --service does; --no-service says no there. Where there is no service manager, it runs in the
|
|
227
|
+
background. It returns once AgentRun answers.
|
|
209
228
|
|
|
210
229
|
AgentRun counts itself anonymously (a random id, version and platform; never prompts, files or keys). To turn that
|
|
211
230
|
off, put AGENTRUN_TELEMETRY=0 before sh: https://github.com/Parcha-ai/agentrun/blob/main/docs/telemetry.md
|
|
@@ -216,7 +235,9 @@ Options:
|
|
|
216
235
|
--node-version V the Node.js version to install, at least the launcher's floor (default: the newest release on the
|
|
217
236
|
floor's major line, from nodejs.org/dist/index.json)
|
|
218
237
|
--no-start install only
|
|
219
|
-
--service install the service, and fail if this machine can't run one
|
|
238
|
+
--service install the service without asking, and fail if this machine can't run one
|
|
239
|
+
--no-service never install the service: run AgentRun in the background until the machine stops. Where it is a
|
|
240
|
+
service already, it stops before changing anything (`agentrun service uninstall` first)
|
|
220
241
|
--tailscale also serve it over HTTPS on your own tailnet only, at this machine's name there
|
|
221
242
|
(tailscale serve, never Funnel; Tailscale must be installed and logged in, and it says how when
|
|
222
243
|
not); --no-tailscale takes it off
|
|
@@ -363,6 +384,40 @@ in_use() {
|
|
|
363
384
|
return 1
|
|
364
385
|
}
|
|
365
386
|
|
|
387
|
+
# --no-service where AgentRun is a service of this user already (`service status` exits 0 or 1; 3 for none, and an
|
|
388
|
+
# AgentRun with no service command something else). A background start would run without what the service was installed
|
|
389
|
+
# with (--data, --port, --tailscale, --env, --public-url), and `service uninstall` takes its tailnet address off, so the
|
|
390
|
+
# installer stops and leaves the service as it is.
|
|
391
|
+
no_service_over_service() {
|
|
392
|
+
[ -n "$no_service" ] || return 0
|
|
393
|
+
code=0
|
|
394
|
+
"$shim" service status > /dev/null 2>&1 || code=$?
|
|
395
|
+
case $code in 0 | 1) ;; *) return 0 ;; esac
|
|
396
|
+
fail "--no-service, but AgentRun is a service of this user already. Running it in the background instead would drop what the service runs with (--data, --port, --tailscale, --env, --public-url), so the service is left as it is.
|
|
397
|
+
To run AgentRun without a service: $(shown_shim) service uninstall (the data directory stays), then this installer with --no-service.
|
|
398
|
+
To update the service: this installer without --no-service."
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
# Whether to make AgentRun a service of this user (GRE-4837: a service nobody asked for surprised the person who ran
|
|
402
|
+
# the installer). Asked on the terminal $1 (/dev/tty: `curl | sh` reads this script from its stdin, so the answer comes
|
|
403
|
+
# from the terminal), No unless they say yes. With no terminal to ask in (CI, a script), yes, as before; --no-service
|
|
404
|
+
# says no there.
|
|
405
|
+
want_service() {
|
|
406
|
+
[ -z "$no_service" ] || return 1
|
|
407
|
+
# Output to a pipe or a file (an agent's or a program's shell that captures it, `| tee`): nobody reads the question,
|
|
408
|
+
# though a terminal may still be attached, and the read would wait on it for good. Not asked, as with no terminal. A
|
|
409
|
+
# file standing in for the terminal is asked.
|
|
410
|
+
[ -t 1 ] || [ -t 2 ] || [ ! -c "$1" ] || return 0
|
|
411
|
+
# No terminal to open: nobody to ask. Appended (a terminal takes either; a file standing in for one keeps its answer).
|
|
412
|
+
{ printf 'Keep AgentRun running as a service of this user (it starts again at login)? [y/N] ' >> "$1"; } 2> /dev/null || return 0
|
|
413
|
+
answer=
|
|
414
|
+
read -r answer < "$1" 2> /dev/null || return 1
|
|
415
|
+
case $answer in
|
|
416
|
+
[yY] | [yY][eE][sS]) return 0 ;;
|
|
417
|
+
*) return 1 ;;
|
|
418
|
+
esac
|
|
419
|
+
}
|
|
420
|
+
|
|
366
421
|
# Whether this user has a service manager AgentRun can be a service of; $why says why not.
|
|
367
422
|
service_manager() {
|
|
368
423
|
why=
|
package/lib/cli.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import { COMMANDS, SECRET_ROUTES } from "./commands.generated.mjs";
|
|
|
17
17
|
import { ALL, FLAGS, MAX_PAGES, REQUEST_MS, WAIT, followTimeline, timerMs, waitRun } from "./follow.mjs";
|
|
18
18
|
import { guarded, refusalExit } from "./login.mjs";
|
|
19
19
|
import { LOCAL } from "./local.mjs";
|
|
20
|
-
import { apiBase } from "./target.mjs";
|
|
20
|
+
import { apiBase, checkedBase } from "./target.mjs";
|
|
21
21
|
|
|
22
22
|
export const NOUNS = new Set(["api", "help", ...[...COMMANDS, ...LOCAL].map((entry) => entry.command[0])]);
|
|
23
23
|
const DEFAULT_BASE_URL = "http://127.0.0.1:7340/v2"; // key-gate: loopback-rule the default address of the server started on this machine
|
|
@@ -70,7 +70,8 @@ const HELP = () => {
|
|
|
70
70
|
"The server: --base-url, else AGENTRUN_BASE_URL, else base_url in $XDG_CONFIG_HOME/agentrun/config.json, else the",
|
|
71
71
|
"server started on this machine with the data directory (--data, default ~/.agentrun); /v2 is added to an address",
|
|
72
72
|
"whose path holds none, its path prefix kept. The token: AGENTRUN_API_KEY, else api_key in the config file (for",
|
|
73
|
-
"the same address, with or without /v2), else that server's own
|
|
73
|
+
"the same address, with or without /v2), else that server's own (its .token file, or AGENTRUN_TOKEN for one started",
|
|
74
|
+
"with its token there; AGENTRUN_TOKEN goes to no other address); it is never a flag and never printed. agentrun login",
|
|
74
75
|
"--base-url URL checks a token read from stdin and writes the config file (0600), or on a terminal signs in with a",
|
|
75
76
|
"device code when the server offers one; agentrun login --to URL (or cloud) signs in with a device code when the",
|
|
76
77
|
"server offers one, else reads the token from stdin; agentrun logout removes it.",
|
|
@@ -154,28 +155,31 @@ const alive = (pid) => {
|
|
|
154
155
|
}
|
|
155
156
|
};
|
|
156
157
|
|
|
157
|
-
/** A base URL as every command takes it
|
|
158
|
-
*
|
|
159
|
-
* path holds no v2 segment, the origin unchanged). `where` names it in the refusal; the URL itself is never echoed, as
|
|
160
|
-
* it may hold a password. */
|
|
158
|
+
/** A base URL as every command takes it (target.mjs checkedBase): its API base, or a refusal `where` names; the URL
|
|
159
|
+
* itself is never echoed, as it may hold a password. */
|
|
161
160
|
function baseOf(given, where) {
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
return apiBase(given);
|
|
161
|
+
const base = checkedBase(given);
|
|
162
|
+
if (base === undefined) throw usageError(`${where} must be an http or https URL with no query, fragment, user or password: the server's address, or its API's base ending /v2.`);
|
|
163
|
+
return base;
|
|
167
164
|
}
|
|
168
165
|
|
|
169
|
-
const isBase = (url) =>
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
166
|
+
const isBase = (url) => checkedBase(url) !== undefined;
|
|
167
|
+
|
|
168
|
+
/** The token of the server on this machine whose data directory is `data` and whose record is `record`: one started with
|
|
169
|
+
* its token in AGENTRUN_TOKEN (its record names no token file) takes AGENTRUN_API_KEY, else AGENTRUN_TOKEN, and is
|
|
170
|
+
* refused (exit 4) when neither is set; else the directory's private .token. Undefined when that file is not there.
|
|
171
|
+
* Every command (targetOf) and the doctor read it so. */
|
|
172
|
+
function localToken({ data, record, env }) {
|
|
173
|
+
if (record && !record.token_file) {
|
|
174
|
+
const token = env.AGENTRUN_API_KEY || env.AGENTRUN_TOKEN;
|
|
175
|
+
if (!token) throw new Exit(4, `The server recorded in ${join(data, ".server.json")} was started with its token in AGENTRUN_TOKEN; set AGENTRUN_API_KEY (or AGENTRUN_TOKEN) to it.`);
|
|
176
|
+
return token;
|
|
174
177
|
}
|
|
175
|
-
|
|
178
|
+
return privateFile(join(data, ".token"))?.trim() || undefined;
|
|
179
|
+
}
|
|
176
180
|
|
|
177
181
|
/** Where the request goes and the token it carries. A token goes only with the address it came with: the local
|
|
178
|
-
* server's own token is never sent to another server. The local token is
|
|
182
|
+
* server's own token is never sent to another server. The local token is localToken's. */
|
|
179
183
|
function targetOf(values, env) {
|
|
180
184
|
const data = resolve(values.data ?? join(homedir(), ".agentrun"));
|
|
181
185
|
const configFile = join(env.XDG_CONFIG_HOME || join(homedir(), ".config"), "agentrun", "config.json");
|
|
@@ -200,10 +204,9 @@ function targetOf(values, env) {
|
|
|
200
204
|
let token = env.AGENTRUN_API_KEY || (config.base_url && base === apiBase(config.base_url) ? config.api_key : undefined);
|
|
201
205
|
const isLocal = base === local;
|
|
202
206
|
if (isLocal && record && !alive(record.pid)) throw new Exit(3, stale);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
+
// Only here, on the local server's own address, is AGENTRUN_TOKEN sent; another address takes AGENTRUN_API_KEY or the
|
|
208
|
+
// token kept for it.
|
|
209
|
+
if (!token && isLocal) token = localToken({ data, record, env });
|
|
207
210
|
if (!token) {
|
|
208
211
|
throw new Exit(4, isLocal
|
|
209
212
|
? `No token: AGENTRUN_API_KEY is not set and ${join(data, ".token")} does not exist; ${START}.`
|
|
@@ -526,7 +529,7 @@ async function local(entry, argv, env, io) {
|
|
|
526
529
|
const count = entry.pathParams.length;
|
|
527
530
|
// An entry whose arguments a flag can stand in for (`harness install --recipe FILE`) takes none too; its run checks.
|
|
528
531
|
if (args.length !== count && !(entry.argsOptional && args.length === 0)) throw usageError(`${helpOf(entry, entry.help)}\n\n${usageOf(entry)} takes ${count || "no"} argument${count === 1 ? "" : "s"}, given ${args.length}.`);
|
|
529
|
-
const cli = { fail: (code, message) => new Exit(code, message), baseOf, targetOf, clientOf, request, privateFile, alive, BAD_HEADER };
|
|
532
|
+
const cli = { fail: (code, message) => new Exit(code, message), baseOf, targetOf, localToken, clientOf, request, privateFile, alive, BAD_HEADER };
|
|
530
533
|
return entry.run({ values, args, env, io, cli });
|
|
531
534
|
}
|
|
532
535
|
|
|
@@ -735,6 +735,26 @@ export const COMMANDS = [
|
|
|
735
735
|
"raw": false,
|
|
736
736
|
"summary": "Check native CLI and sign-in without a paid model call"
|
|
737
737
|
},
|
|
738
|
+
{
|
|
739
|
+
"command": [
|
|
740
|
+
"api-keys",
|
|
741
|
+
"list"
|
|
742
|
+
],
|
|
743
|
+
"operationId": "listApiKeys",
|
|
744
|
+
"method": "GET",
|
|
745
|
+
"path": "/settings/api-keys",
|
|
746
|
+
"pathParams": [],
|
|
747
|
+
"multiSegment": [],
|
|
748
|
+
"query": [],
|
|
749
|
+
"headers": [],
|
|
750
|
+
"bodyFlags": [],
|
|
751
|
+
"hasBody": false,
|
|
752
|
+
"bodyRequired": false,
|
|
753
|
+
"bodyTypes": [],
|
|
754
|
+
"secretBody": false,
|
|
755
|
+
"raw": false,
|
|
756
|
+
"summary": "The API keys made for this server's apps; never a key"
|
|
757
|
+
},
|
|
738
758
|
{
|
|
739
759
|
"command": [
|
|
740
760
|
"capabilities",
|
|
@@ -2393,6 +2413,26 @@ export const COMMANDS = [
|
|
|
2393
2413
|
"raw": false,
|
|
2394
2414
|
"summary": "The repositories this server's GitHub App is installed on"
|
|
2395
2415
|
},
|
|
2416
|
+
{
|
|
2417
|
+
"command": [
|
|
2418
|
+
"local",
|
|
2419
|
+
"list-marketplace-templates"
|
|
2420
|
+
],
|
|
2421
|
+
"operationId": "listMarketplaceTemplates",
|
|
2422
|
+
"method": "GET",
|
|
2423
|
+
"path": "/marketplace/templates",
|
|
2424
|
+
"pathParams": [],
|
|
2425
|
+
"multiSegment": [],
|
|
2426
|
+
"query": [],
|
|
2427
|
+
"headers": [],
|
|
2428
|
+
"bodyFlags": [],
|
|
2429
|
+
"hasBody": false,
|
|
2430
|
+
"bodyRequired": false,
|
|
2431
|
+
"bodyTypes": [],
|
|
2432
|
+
"secretBody": false,
|
|
2433
|
+
"raw": false,
|
|
2434
|
+
"summary": "The marketplace's templates: every package on marketplace.agentrun.ai, each with the package here that it is"
|
|
2435
|
+
},
|
|
2396
2436
|
{
|
|
2397
2437
|
"command": [
|
|
2398
2438
|
"local",
|
|
@@ -3148,7 +3188,17 @@ export const COMMANDS = [
|
|
|
3148
3188
|
"run_id"
|
|
3149
3189
|
],
|
|
3150
3190
|
"multiSegment": [],
|
|
3151
|
-
"query": [
|
|
3191
|
+
"query": [
|
|
3192
|
+
{
|
|
3193
|
+
"name": "cut",
|
|
3194
|
+
"type": "string",
|
|
3195
|
+
"enum": [
|
|
3196
|
+
"run"
|
|
3197
|
+
],
|
|
3198
|
+
"required": false,
|
|
3199
|
+
"description": "`run`: each file also has its `name`, its path under the run's own cut (each value the cut holds and each secret shape replaced by `[redacted]` in place, as a cut read cuts a file's text), whatever its type. A run whose end erased what its caller handed it lists no `name`. A run whose cut can't be read is `403 forbidden`, as without `cut`. A server that doesn't know `cut` lists no `name`."
|
|
3200
|
+
}
|
|
3201
|
+
],
|
|
3152
3202
|
"headers": [],
|
|
3153
3203
|
"bodyFlags": [],
|
|
3154
3204
|
"hasBody": false,
|
|
@@ -3389,6 +3439,12 @@ export const COMMANDS = [
|
|
|
3389
3439
|
"type": "string",
|
|
3390
3440
|
"required": false,
|
|
3391
3441
|
"description": "Only runs holding this label: `<key>:<value>`, split at the first `:` (a key holds none). Once per request; a second `label`, or one that does not read as a label, is 400."
|
|
3442
|
+
},
|
|
3443
|
+
{
|
|
3444
|
+
"name": "source",
|
|
3445
|
+
"type": "string",
|
|
3446
|
+
"required": false,
|
|
3447
|
+
"description": "Only runs imported from this source, a source's name as the run's `imported_from.source` holds it (`claude-code`, `codex`, ...), or `live` for the runs made here, not imported. A name no run holds lists none. Once per request; a second `source`, or one that does not read as a name, is 400."
|
|
3392
3448
|
}
|
|
3393
3449
|
],
|
|
3394
3450
|
"headers": [],
|
|
@@ -3526,7 +3582,7 @@ export const COMMANDS = [
|
|
|
3526
3582
|
"run"
|
|
3527
3583
|
],
|
|
3528
3584
|
"required": false,
|
|
3529
|
-
"description": "`run`: the file's text cut of every value the run's own cut holds (the server's keys, the keys a person saved, its secret stores' values, the sign-in refs the run was handed), each one and each secret shape replaced by `[redacted]` in place, as the run's timeline cuts its calls; the text is `[redacted]` whole when a value still shows in a form not cut in place. The
|
|
3585
|
+
"description": "`run`: the file's text cut of every value the run's own cut holds (the server's keys, the keys a person saved, its secret stores' values, the sign-in refs the run was handed, and what its caller handed it: its own model key, tool keys and MCP servers' credentials), each one and each secret shape replaced by `[redacted]` in place, as the run's timeline cuts its calls; the text is `[redacted]` whole when a value still shows in a form not cut in place. The run's end erases what its caller handed it and counts where those values sat in each of its text files, never the values; from then a file is cut where that count says, while its bytes are the ones counted. A file the count cut in more than 256 places reads `[redacted]` whole. A file not counted as it is now (written or changed since the end, past the count's limits of 2,000 files, 64 MiB read and 512 KiB of count, or a run whose end made no count) is `403 forbidden`. That holds for good: once a run handed secrets has ended a turn, a file a later turn writes or changes is withheld from cut reads, whether or not that turn was handed secrets of its own (read it raw). A secret of no known shape passes as written. Answered `text/plain; charset=utf-8` with `x-agentrun-cut: run` (a server that doesn't know `cut` answers the raw bytes, without it), the whole file (`Range` is not read). A file whose type is not text (text/*, JSON, NDJSON, or an extension the server doesn't type), or whose bytes are not UTF-8 or hold a NUL, is `415 unsupported_media_type`; one over 262144 bytes is `413 payload_too_large`; a run whose cut can't be read (the sign-in it was handed, or what its caller handed it, doesn't open here) is `403 forbidden`. Without `cut`, the file's bytes as written."
|
|
3530
3586
|
}
|
|
3531
3587
|
],
|
|
3532
3588
|
"headers": [
|
|
@@ -4693,6 +4749,38 @@ export const COMMANDS = [
|
|
|
4693
4749
|
"raw": false,
|
|
4694
4750
|
"summary": "The triggers: schedules and signed webhooks that start an agent's capped runs or message a run"
|
|
4695
4751
|
},
|
|
4752
|
+
{
|
|
4753
|
+
"command": [
|
|
4754
|
+
"triggers",
|
|
4755
|
+
"release-firing"
|
|
4756
|
+
],
|
|
4757
|
+
"operationId": "releaseTriggerFiring",
|
|
4758
|
+
"method": "POST",
|
|
4759
|
+
"path": "/triggers/{trigger_id}/firings/{firing_id}/release",
|
|
4760
|
+
"pathParams": [
|
|
4761
|
+
"trigger_id",
|
|
4762
|
+
"firing_id"
|
|
4763
|
+
],
|
|
4764
|
+
"multiSegment": [],
|
|
4765
|
+
"query": [],
|
|
4766
|
+
"headers": [],
|
|
4767
|
+
"bodyFlags": [
|
|
4768
|
+
{
|
|
4769
|
+
"name": "error",
|
|
4770
|
+
"type": "string",
|
|
4771
|
+
"required": true,
|
|
4772
|
+
"description": "Why the host starts no run for the firing, in plain words: a failure's code or reason, never a person's data or a key."
|
|
4773
|
+
}
|
|
4774
|
+
],
|
|
4775
|
+
"hasBody": true,
|
|
4776
|
+
"bodyRequired": true,
|
|
4777
|
+
"bodyTypes": [
|
|
4778
|
+
"application/json"
|
|
4779
|
+
],
|
|
4780
|
+
"secretBody": false,
|
|
4781
|
+
"raw": false,
|
|
4782
|
+
"summary": "The launch hook's host releases a firing it took and will start no run for"
|
|
4783
|
+
},
|
|
4696
4784
|
{
|
|
4697
4785
|
"command": [
|
|
4698
4786
|
"triggers",
|
|
@@ -4971,6 +5059,12 @@ export const COMMANDS = [
|
|
|
4971
5059
|
// Every route whose body carries a secret, a command's or one with no command (omitted): a raw `api` call to one never
|
|
4972
5060
|
// takes its body from the command line, and what it prints has the body's values cut, its public fields kept.
|
|
4973
5061
|
export const SECRET_ROUTES = [
|
|
5062
|
+
{
|
|
5063
|
+
"operationId": "listComposioToolkits",
|
|
5064
|
+
"method": "POST",
|
|
5065
|
+
"path": "/settings/mcp-servers/composio/toolkits",
|
|
5066
|
+
"publicFields": []
|
|
5067
|
+
},
|
|
4974
5068
|
{
|
|
4975
5069
|
"operationId": "listComposioTools",
|
|
4976
5070
|
"method": "POST",
|
package/lib/deploy.mjs
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
// refused unless --force. `deploy rollback` makes the agent's previous revision current; `deploy delete` deletes the
|
|
10
10
|
// agent there and the lock here. Exit codes: 0 done or up to date, 2 refused (bad input, a link in the folder, edited on
|
|
11
11
|
// the target, not confirmed), 3 not runnable yet (keys or MCP servers the target lacks: nothing is made, the setup page
|
|
12
|
-
// printed when the target gives one), 1 the target refused otherwise or could not be reached,
|
|
13
|
-
// operation the target does not offer.
|
|
12
|
+
// printed when the target gives one), 1 the target refused otherwise or could not be reached, or deployed but
|
|
13
|
+
// --pause-source left a schedule on, 4 no token for it, 5 an operation the target does not offer.
|
|
14
14
|
import { createHash } from "node:crypto";
|
|
15
15
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, rmdirSync, statSync, writeFileSync } from "node:fs";
|
|
16
16
|
import { homedir, hostname } from "node:os";
|
|
@@ -22,6 +22,7 @@ import { toUrl } from "./target.mjs";
|
|
|
22
22
|
* and the answer's schema file the manifest names at the folder's root. */
|
|
23
23
|
const MANIFEST = "agent.md";
|
|
24
24
|
const TREES = ["skills", "rules", "evals"];
|
|
25
|
+
const LOCK_DIR = ".agentrun";
|
|
25
26
|
/** What an upload takes (the server's import limits): refused here before anything is read past them. */
|
|
26
27
|
const MAX_FILES = 256;
|
|
27
28
|
const MAX_BYTES = 8 * 1024 * 1024;
|
|
@@ -60,15 +61,19 @@ async function serverManifest(fail) {
|
|
|
60
61
|
* the manifest names none or does not parse: the target refuses it then, in its own words. */
|
|
61
62
|
function rootSchemaOf(manifest, manifestOf) {
|
|
62
63
|
const schema = manifestOf(manifest.toString("utf8"))?.output?.schema;
|
|
63
|
-
|
|
64
|
+
// A hidden name (".", "..", ".answer.json") is none: the target reads no hidden file, as templates.ts holds it.
|
|
65
|
+
return typeof schema === "string" && /^[^/\\]+$/.test(schema) && !schema.startsWith(".") && schema !== MANIFEST ? schema : undefined;
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
/** A folder's package by path, each file its bytes: agent.md, the skills/, rules/ and evals/ trees, and the answer's
|
|
67
69
|
* schema file the manifest names at the root. Nothing else of the folder is sent (a .env, a key, a README, another
|
|
68
|
-
* folder), nor a hidden file or folder inside the trees
|
|
69
|
-
*
|
|
70
|
+
* folder), nor a hidden file or folder inside the trees: `hidden` names each one left out, at the top or in a tree (a
|
|
71
|
+
* hidden folder once, never what it holds; this CLI's own .agentrun/ is not named). No agent.md, a symbolic link, or
|
|
72
|
+
* anything that is neither a file nor a folder refuses the deploy with nothing sent. */
|
|
70
73
|
async function readFolder(dir, fail) {
|
|
71
74
|
const files = new Map();
|
|
75
|
+
const hidden = [];
|
|
76
|
+
const leftOut = (rel, entry) => hidden.push(`${rel}${entry.isDirectory() ? "/" : ""}`);
|
|
72
77
|
let bytes = 0;
|
|
73
78
|
const entryOf = (rel) => {
|
|
74
79
|
try {
|
|
@@ -82,7 +87,10 @@ async function readFolder(dir, fail) {
|
|
|
82
87
|
if (entry.isSymbolicLink()) throw fail(2, `${rel} is a symbolic link: a package holds files and folders alone, so nothing was sent.`);
|
|
83
88
|
if (entry.isDirectory()) {
|
|
84
89
|
// A hidden file or folder (.env, .DS_Store) is never part of a package: the target leaves it out too.
|
|
85
|
-
for (const one of readdirSync(join(dir, rel), { withFileTypes: true }))
|
|
90
|
+
for (const one of readdirSync(join(dir, rel), { withFileTypes: true })) {
|
|
91
|
+
if (one.name.startsWith(".")) leftOut(`${rel}/${one.name}`, one);
|
|
92
|
+
else take(`${rel}/${one.name}`, one);
|
|
93
|
+
}
|
|
86
94
|
return;
|
|
87
95
|
}
|
|
88
96
|
if (!entry.isFile()) throw fail(2, `${rel} is neither a file nor a folder: a package holds files and folders alone, so nothing was sent.`);
|
|
@@ -102,7 +110,8 @@ async function readFolder(dir, fail) {
|
|
|
102
110
|
const schema = rootSchemaOf(files.get(MANIFEST), await serverManifest(fail));
|
|
103
111
|
const entry = schema === undefined ? undefined : entryOf(schema);
|
|
104
112
|
if (entry && !entry.isDirectory()) take(schema, entry);
|
|
105
|
-
|
|
113
|
+
for (const one of readdirSync(dir, { withFileTypes: true })) if (one.name.startsWith(".") && one.name !== LOCK_DIR) leftOut(one.name, one);
|
|
114
|
+
return { files, hidden: hidden.sort() };
|
|
106
115
|
}
|
|
107
116
|
|
|
108
117
|
/** The files as an upload sends them: text as it is, unless JSON's escapes make it longer than base64 would (a file of
|
|
@@ -114,9 +123,13 @@ const filesBody = (files) => [...files].sort(([a], [b]) => (a < b ? -1 : a > b ?
|
|
|
114
123
|
return Buffer.from(text, "utf8").equals(data) && Buffer.byteLength(JSON.stringify(text)) <= base64.length + 2 ? { path, encoding: "utf8", content: text } : { path, encoding: "base64", content: base64 };
|
|
115
124
|
});
|
|
116
125
|
|
|
126
|
+
/** The package folder `dir` as a deploy uploads it (POST /templates/import's `files`); `fail(code, message)` makes the
|
|
127
|
+
* refusal a folder that is no package throws. */
|
|
128
|
+
export const packageFiles = async (dir, fail) => filesBody((await readFolder(dir, fail)).files);
|
|
129
|
+
|
|
117
130
|
/** A lock read back from its file's text (none when there is no file): its fields as written, or a refusal naming the
|
|
118
131
|
* file. */
|
|
119
|
-
function lockOf(text, file, fail) {
|
|
132
|
+
export function lockOf(text, file, fail) {
|
|
120
133
|
if (text === undefined) return undefined;
|
|
121
134
|
let value;
|
|
122
135
|
try {
|
|
@@ -324,7 +337,8 @@ function remote(cli, values, env, io, base) {
|
|
|
324
337
|
const ask = async (method, path, body) => {
|
|
325
338
|
const { response, value, unreached } = await send(method, path, body);
|
|
326
339
|
if (unreached !== undefined) return { why: `not reached: ${unreached}` };
|
|
327
|
-
|
|
340
|
+
// A 2xx with no JSON is no answer to read: an empty list read off it would be a guess.
|
|
341
|
+
if (response.ok) return value === undefined && response.status !== 204 ? { why: `${response.status} with no JSON` } : { value };
|
|
328
342
|
return { why: `${response.status}${typeof value?.error?.message === "string" ? `: ${value.error.message}` : ""}` };
|
|
329
343
|
};
|
|
330
344
|
const call = async (method, path, body, allow = []) => {
|
|
@@ -384,7 +398,12 @@ async function sourceOf({ values, args, env, io, cli, releases }, fail) {
|
|
|
384
398
|
const lock = folderLock(dir, cli);
|
|
385
399
|
releases.push(lock.hold());
|
|
386
400
|
const write = (written) => (lock.write(written), cliFiles(env, cli).learn(written.target));
|
|
387
|
-
|
|
401
|
+
const files = async () => {
|
|
402
|
+
const { files, hidden } = await readFolder(dir, fail);
|
|
403
|
+
if (hidden.length) say(io, `Left out, hidden: ${hidden.join(", ")}`);
|
|
404
|
+
return files;
|
|
405
|
+
};
|
|
406
|
+
return { kind: "folder", dir, lock: { ...lock, write }, files };
|
|
388
407
|
}
|
|
389
408
|
if (/[\\/]/.test(given) || given.startsWith(".")) throw fail(2, `${given} is not a folder: deploy takes a package folder or an agent id of this install.`);
|
|
390
409
|
// The install the agent is on: --base-url, else as every command finds it; never with AGENTRUN_API_KEY, which is the
|
|
@@ -417,20 +436,36 @@ async function sourceOf({ values, args, env, io, cli, releases }, fail) {
|
|
|
417
436
|
}
|
|
418
437
|
|
|
419
438
|
/** The schedules of the install agent that still fire there: turned off with --pause-source, else warned of. The deploy
|
|
420
|
-
* is done by now, so an install that refuses its trigger routes (a front door without them)
|
|
421
|
-
* and the
|
|
439
|
+
* is done by now, so an install that refuses its trigger routes (a front door without them), is not reached, or answers
|
|
440
|
+
* with no list of triggers is said and the deploy stands: a schedule it could not read or turn off is never said to be
|
|
441
|
+
* paused. Its exit code: 1 when --pause-source left any schedule unread or unpaused, said after the deploy; else 0. */
|
|
422
442
|
async function sourceSchedules(io, from, values) {
|
|
423
443
|
const pause = values["pause-source"];
|
|
424
444
|
const where = from.source.base;
|
|
445
|
+
const unpaused = () => {
|
|
446
|
+
if (!pause) return 0;
|
|
447
|
+
say(io, `--pause-source did not pause every schedule of the agent on ${where}: the deploy stands, and each schedule not said paused above still fires there.`);
|
|
448
|
+
return 1;
|
|
449
|
+
};
|
|
425
450
|
const listed = await from.source.ask("GET", "/triggers");
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
451
|
+
const why = listed.why ?? (Array.isArray(listed.value?.triggers) ? undefined : "200 with no list of triggers");
|
|
452
|
+
if (why) {
|
|
453
|
+
say(io, `Warning: the agent's schedules on ${where} could not be read ${pause ? "or paused " : ""}(${why}): any it has still run there, so each fires in both places.`);
|
|
454
|
+
return unpaused();
|
|
455
|
+
}
|
|
456
|
+
const live = listed.value.triggers.filter((one) => (one.agent_id ?? one.target?.agent_id) === from.agentId && one.source?.kind === "schedule" && one.enabled);
|
|
457
|
+
if (!live.length) return 0;
|
|
458
|
+
if (!pause) {
|
|
459
|
+
say(io, `Warning: the agent's schedules (${live.map((one) => one.name).join(", ")}) still run on ${where}, so each fires in both places. --pause-source turns them off there.`);
|
|
460
|
+
return 0;
|
|
461
|
+
}
|
|
462
|
+
let left = 0;
|
|
430
463
|
for (const one of live) {
|
|
431
464
|
const paused = await from.source.ask("PATCH", `/triggers/${enc(one.id ?? one.trigger_id)}`, { enabled: false });
|
|
465
|
+
if (paused.why) left += 1;
|
|
432
466
|
say(io, paused.why ? `Warning: ${one.name} could not be paused on ${where} (${paused.why}): it still runs there, so it fires in both places.` : `Paused ${one.name} on ${where}.`);
|
|
433
467
|
}
|
|
468
|
+
return left ? unpaused() : 0;
|
|
434
469
|
}
|
|
435
470
|
|
|
436
471
|
async function deploy(ctx) {
|
|
@@ -451,14 +486,20 @@ async function deploy(ctx) {
|
|
|
451
486
|
const prior = from.lock.read();
|
|
452
487
|
const base = targetFor(ctx, from, prior, fail);
|
|
453
488
|
if (base === undefined) throw fail(2, `Where to? Pass --to URL (cloud, or an AgentRun's address); a deploy after the first reads it from ${from.lock.file}.`);
|
|
454
|
-
|
|
489
|
+
let lock = prior && prior.target === base ? prior : undefined;
|
|
455
490
|
// --agent: the target's agent this deploy is for where no lock here names one there, by its id, or `new` for another.
|
|
456
|
-
// With a lock it may name only the lock's agent: a deploy never moves to another agent on its
|
|
491
|
+
// With a lock it may name only the lock's agent while that agent is there: a deploy never moves to another agent on its
|
|
492
|
+
// own. A lock whose agent is gone from the target is no lock for this: --agent picks the agent, as with none.
|
|
457
493
|
const picked = values.agent;
|
|
458
494
|
if (picked !== undefined && !picked.trim()) throw fail(2, "--agent takes the id of an agent on the target, or new.");
|
|
459
|
-
if (picked !== undefined && lock && picked !== lock.agent_id) throw fail(2, `${from.lock.file} names the agent ${lock.agent_id} on ${base}: --agent ${picked} names another. Nothing was sent: leave --agent out to deploy onto ${lock.agent_id}, or remove the lock to deploy to another agent there.`);
|
|
460
495
|
if (prior && !lock) say(io, `The lock names ${prior.target}; this deploy is to ${base}, so it makes the agent there and the lock names it after.`);
|
|
461
496
|
const to = remote(cli, values, env, io, base);
|
|
497
|
+
if (picked !== undefined && lock && picked !== lock.agent_id) {
|
|
498
|
+
const { status } = await to.call("GET", `/agents/${enc(lock.agent_id)}`, undefined, [404, 410]);
|
|
499
|
+
if (status === 200) throw fail(2, `${from.lock.file} names the agent ${lock.agent_id} on ${base}: --agent ${picked} names another. Nothing was written: leave --agent out to deploy onto ${lock.agent_id}, or remove the lock to deploy to another agent there.`);
|
|
500
|
+
say(io, `The agent ${lock.agent_id} the lock names is gone from ${to.base}: --agent ${picked} picks the agent this deploy is for, and the lock names it after.`);
|
|
501
|
+
lock = undefined;
|
|
502
|
+
}
|
|
462
503
|
|
|
463
504
|
// The lock's agent as the target has it now: gone (deployed anew), edited since (refused unless --force), or the same
|
|
464
505
|
// revision with the same package (up to date: nothing sent that writes, unless --params asks for parameters the lock
|
|
@@ -476,9 +517,9 @@ async function deploy(ctx) {
|
|
|
476
517
|
if (agent.revision !== lock.revision_id && !values.force) throw fail(2, `The agent ${lock.agent_id} was edited on ${to.base} since this lock was written; --force to replace it with this package (its current revision is not the one ${from.lock.file} names).`);
|
|
477
518
|
if (agent.revision === lock.revision_id && lock.package_sha256 === sha && parameters === undefined) {
|
|
478
519
|
say(io, `This package is up to date on ${to.base}: the agent ${lock.agent_id}, revision ${lock.revision_id}. Nothing was sent.`);
|
|
479
|
-
|
|
520
|
+
const code = from.kind === "agent" ? await sourceSchedules(io, from, values) : 0;
|
|
480
521
|
ctx.io.stdout.write(`${JSON.stringify({ status: "up_to_date", target: to.base, agent_id: lock.agent_id, revision_id: lock.revision_id, package_sha256: sha })}\n`);
|
|
481
|
-
return
|
|
522
|
+
return code;
|
|
482
523
|
}
|
|
483
524
|
// Onto the revision read here: one written after this read (an edit, another deploy) makes the apply 412.
|
|
484
525
|
onto = { agent_id: lock.agent_id, revision: agent.revision };
|
|
@@ -523,9 +564,9 @@ async function deploy(ctx) {
|
|
|
523
564
|
for (const warning of applied.warnings ?? []) say(io, `Warning (${warning.field}): ${warning.message}`);
|
|
524
565
|
if (unmade.length) say(io, `Not made on ${to.base} yet: ${unmade.join(", ")}. Until they are, the lock names no package, so the next deploy applies again (keeping the revision when nothing else changed).`);
|
|
525
566
|
say(io, `Deployed ${template.name} to ${to.base}: the agent ${applied.agent_id}, revision ${applied.revision_version} (${applied.agent_change}). Lock: ${from.lock.file}.`);
|
|
526
|
-
|
|
567
|
+
const code = from.kind === "agent" ? await sourceSchedules(io, from, values) : 0;
|
|
527
568
|
io.stdout.write(`${JSON.stringify({ status: "deployed", ...written, revision_version: applied.revision_version, agent_change: applied.agent_change, template: template.id, warnings: applied.warnings ?? [] })}\n`);
|
|
528
|
-
return
|
|
569
|
+
return code;
|
|
529
570
|
}
|
|
530
571
|
|
|
531
572
|
/** The lock a rollback or delete acts on, and the target it names (--to wins). */
|
|
@@ -632,10 +673,10 @@ export const DEPLOY = {
|
|
|
632
673
|
["--yes", "apply without asking (needed off a terminal)"],
|
|
633
674
|
["--force", "replace an agent edited on the target since the last deploy"],
|
|
634
675
|
["--params FILE", "the package's parameters, a JSON object"],
|
|
635
|
-
["--pause-source", "an install agent: turn its schedules off on this install once deployed (else they fire in both places)"],
|
|
636
|
-
["--agent ID|new", "with no lock for the target: deploy onto its agent ID, or make another agent (new), where it has one this package made with these parameters; with a lock, only the lock's agent"],
|
|
676
|
+
["--pause-source", "an install agent: turn its schedules off on this install once deployed (else they fire in both places); exits 1, once deployed, when it could not turn every one off"],
|
|
677
|
+
["--agent ID|new", "with no lock for the target: deploy onto its agent ID, or make another agent (new), where it has one this package made with these parameters; with a lock, only the lock's agent while it is there (one gone from the target, any)"],
|
|
637
678
|
["", TOKEN],
|
|
638
|
-
["", "Exit codes: 0 deployed or up to date, 2 refused (bad input, edited on the target, an agent there this package made that no lock names, not confirmed), 3 not runnable yet there (nothing made), 1 the target refused or was not reached."],
|
|
679
|
+
["", "Exit codes: 0 deployed or up to date, 2 refused (bad input, edited on the target, an agent there this package made that no lock names, not confirmed), 3 not runnable yet there (nothing made), 1 the target refused or was not reached, or deployed but --pause-source left a schedule on."],
|
|
639
680
|
],
|
|
640
681
|
options: { to: { type: "string" }, yes: { type: "boolean" }, force: { type: "boolean" }, params: { type: "string" }, "pause-source": { type: "boolean" }, agent: { type: "string" } },
|
|
641
682
|
run: ending(deploy),
|
package/lib/doctor.mjs
CHANGED
|
@@ -162,13 +162,13 @@ export async function doctorOf({
|
|
|
162
162
|
try {
|
|
163
163
|
token = readToken({ data, record, env });
|
|
164
164
|
} catch (error) {
|
|
165
|
-
capsWhy = error.message;
|
|
165
|
+
capsWhy = error.message.replace(/\.$/, "");
|
|
166
166
|
}
|
|
167
167
|
if (token) {
|
|
168
168
|
const answer = await getJson(`${base}/capabilities`, { authorization: `Bearer ${token}` });
|
|
169
169
|
if (answer.status === 200 && answer.body && typeof answer.body === "object") caps = answer.body;
|
|
170
170
|
else capsWhy = `GET /v2/capabilities answered ${answer.status || answer.error}`;
|
|
171
|
-
} else capsWhy ??= `no token to read the server's capabilities with: ${join(data, ".token")} is not there
|
|
171
|
+
} else capsWhy ??= `no token to read the server's capabilities with: ${join(data, ".token")} is not there`;
|
|
172
172
|
}
|
|
173
173
|
const version = caps?.server?.version;
|
|
174
174
|
|
|
@@ -370,11 +370,7 @@ export const DOCTOR = {
|
|
|
370
370
|
options: { json: { type: "boolean" } },
|
|
371
371
|
async run({ values, io, env, cli }) {
|
|
372
372
|
if (values["base-url"] !== undefined) throw cli.fail(2, "agentrun doctor checks the AgentRun on this machine, the server of --data (default ~/.agentrun); it takes no --base-url.");
|
|
373
|
-
const
|
|
374
|
-
if (record && !record.token_file) return vars.AGENTRUN_API_KEY || undefined;
|
|
375
|
-
return cli.privateFile(join(data, ".token"))?.trim() || undefined;
|
|
376
|
-
};
|
|
377
|
-
const report = await doctorOf({ data: values.data, env, readRecord: cli.privateFile, readToken });
|
|
373
|
+
const report = await doctorOf({ data: values.data, env, readRecord: cli.privateFile, readToken: cli.localToken });
|
|
378
374
|
io.stdout.write(values.json ? `${JSON.stringify(report, null, 2)}\n` : textOf(report));
|
|
379
375
|
return report.exit;
|
|
380
376
|
},
|
package/lib/export.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// `agentrun export AGENT --out DIR`: the agent's current revision written as a template package folder (GET
|
|
2
2
|
// /agents/{agent_id}/package), which `agentrun template validate` reads and any AgentRun applies. The server's report is
|
|
3
3
|
// printed whole: what kept the package from working elsewhere (`blocked`) and what the target sets up again (`remade`).
|
|
4
|
-
// With anything blocked,
|
|
4
|
+
// With anything blocked, an agent the server does not export, or a folder not named as the package, nothing is written
|
|
5
|
+
// and the exit is 2.
|
|
5
6
|
import { mkdirSync, readdirSync, writeFileSync } from "node:fs";
|
|
6
|
-
import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
7
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
7
8
|
|
|
8
|
-
/** Exits: 0 written; 2 refused (blocked, an agent the server does not export, an unknown one, a folder that holds files
|
|
9
|
+
/** Exits: 0 written; 2 refused (blocked, an agent the server does not export, an unknown one, a folder that holds files, a
|
|
10
|
+
* folder not named as the package). */
|
|
9
11
|
const REFUSED = 2;
|
|
10
12
|
|
|
11
13
|
export const EXPORT = {
|
|
@@ -15,7 +17,7 @@ export const EXPORT = {
|
|
|
15
17
|
route: "GET /agents/{agent_id}/package",
|
|
16
18
|
help: [
|
|
17
19
|
["AGENT", "the agent's id"],
|
|
18
|
-
["--out DIR", "the folder to write: a new one, or an empty one"],
|
|
20
|
+
["--out DIR", "the folder to write: a new one, or an empty one, named as the package is (another name is refused, naming the folder to use)"],
|
|
19
21
|
],
|
|
20
22
|
options: { out: { type: "string" } },
|
|
21
23
|
async run({ values, args, env, io, cli }) {
|
|
@@ -40,15 +42,22 @@ export const EXPORT = {
|
|
|
40
42
|
} catch {
|
|
41
43
|
throw cli.fail(1, `The server's answer (${response.status}) is not JSON.`);
|
|
42
44
|
}
|
|
43
|
-
const { name, sha256, files = [], report = {} } = answer;
|
|
45
|
+
const { name, sha256, files = [], report = {} } = answer ?? {};
|
|
46
|
+
if (typeof name !== "string") throw cli.fail(1, `The server's answer (${response.status}) names no package.`);
|
|
44
47
|
const blocked = report.blocked ?? [];
|
|
45
48
|
const remade = report.remade ?? [];
|
|
46
49
|
for (const [label, list] of [["Blocked", blocked], ["Set up again on the target", remade]]) {
|
|
47
50
|
if (list.length) io.stderr.write(`${label}:\n${list.map((note) => ` ${note.kind} ${note.name}: ${note.reason}`).join("\n")}\n`);
|
|
48
51
|
}
|
|
49
|
-
|
|
52
|
+
// A package's folder is named as the package is (agent.md's name, which template validate checks), so a folder of
|
|
53
|
+
// another name would hold a package that fails it. Neither name is changed here: renaming the package would deploy
|
|
54
|
+
// another agent's name, and writing into a folder under --out would move where scripts find it.
|
|
55
|
+
const stops = [];
|
|
56
|
+
if (blocked.length) stops.push("the package would not work elsewhere until what is blocked is fixed on this agent");
|
|
57
|
+
if (basename(out) !== name) stops.push(`a package's folder is named as the package is, ${name}, so ${out} would not pass agentrun template validate. Export to ${join(dirname(out), name)}`);
|
|
58
|
+
if (stops.length) {
|
|
50
59
|
client.print({ name, sha256, blocked, remade, folder: null });
|
|
51
|
-
io.stderr.write(
|
|
60
|
+
io.stderr.write(`Nothing was written: ${stops.join("; and ")}.\n`);
|
|
52
61
|
return REFUSED;
|
|
53
62
|
}
|
|
54
63
|
// Every path checked before the first write: one that leaves the folder writes nothing.
|
package/lib/login.mjs
CHANGED
|
@@ -99,7 +99,10 @@ function secretClient(clientOf, target, io, secrets) {
|
|
|
99
99
|
}
|
|
100
100
|
const named = typeof code === "string" && /^[a-z_]+$/.test(code) ? ` ${code}` : "";
|
|
101
101
|
const what = response.status === 501 ? "The server does not offer it here" : "The server refused it";
|
|
102
|
-
|
|
102
|
+
// A 403 is the token refused a secret write (the server's secret-writes.ts): say where one is made, in this CLI's
|
|
103
|
+
// own words, since the server's are not shown.
|
|
104
|
+
const where = response.status === 403 ? " A secret is saved, replaced or removed only from the owner's signed-in session in the console; the API token can't write one." : "";
|
|
105
|
+
client.io.stderr.write(`${what}: ${response.status}${named}. Its answer is not shown, since it could quote the secret sent.${where}\n`);
|
|
103
106
|
return refusalExit(response.status);
|
|
104
107
|
},
|
|
105
108
|
};
|
package/lib/service.mjs
CHANGED
|
@@ -117,9 +117,12 @@ export const unitEnv = (text) =>
|
|
|
117
117
|
* - A local model's (AGENT_MODEL_BASE_URL in front of a gateway such as Ollama's), and its key at `none`: a server that
|
|
118
118
|
* holds no key for its gateway refuses each run that brings none (run-model-key.ts, model_key_required).
|
|
119
119
|
* - Where Ollama listens (OLLAMA_HOST, read as the ollama CLI reads it), for an Ollama off its default address: the
|
|
120
|
-
* server lists its models itself (serve's ollama-provider.ts).
|
|
120
|
+
* server lists its models itself (serve's ollama-provider.ts). OLLAMA_CONTEXT_LENGTH, Ollama's own too: a person's
|
|
121
|
+
* lower context, which caps each request's num_ctx below 65,536 as it caps Ollama's.
|
|
121
122
|
* - The start-time switches (the server's start-switches.ts), on at `1` alone, for a machine its owner alone uses. A
|
|
122
123
|
* server reads them at its start, so the service restarts.
|
|
124
|
+
* - The marketplace the server reads (AGENTRUN_MARKETPLACE, serve's marketplace.ts): `off`, or another site's address in
|
|
125
|
+
* place of marketplace.agentrun.ai. The server checks the value at its start and refuses one that is neither.
|
|
123
126
|
* - The usage counts' switches (docs/telemetry.md). A service never sees the shell that installed it, so install writes
|
|
124
127
|
* these into it as that shell set them, and AGENTRUN_TELEMETRY=0 under CI. */
|
|
125
128
|
export const SERVICE_ENV = {
|
|
@@ -129,8 +132,10 @@ export const SERVICE_ENV = {
|
|
|
129
132
|
AGENT_MODEL_PRICE: null,
|
|
130
133
|
AGENT_MODEL_API_KEY: ["none"],
|
|
131
134
|
OLLAMA_HOST: null,
|
|
135
|
+
OLLAMA_CONTEXT_LENGTH: null,
|
|
132
136
|
AGENTRUN_MCP_ALLOW_LOOPBACK: ["1"],
|
|
133
137
|
AGENTRUN_WEBHOOK_PRIVATE_TARGETS: ["1"],
|
|
138
|
+
AGENTRUN_MARKETPLACE: null,
|
|
134
139
|
AGENTRUN_TELEMETRY: null,
|
|
135
140
|
DO_NOT_TRACK: null,
|
|
136
141
|
};
|
|
@@ -639,7 +644,7 @@ export function serviceOf({ platform = process.platform, home = homedir(), uid =
|
|
|
639
644
|
}
|
|
640
645
|
|
|
641
646
|
const VERBS = [
|
|
642
|
-
["install", "Install AgentRun as a service of this user and start it: it keeps running after the terminal closes and starts again at login", [["--port N", "the port to listen on (default: the first free from 7340; 7340 with --tailscale)"], ["--data DIR", "the data directory (default ~/.agentrun)"], ["--tailscale", "also serve it over HTTPS on your own tailnet only (tailscale serve, never Funnel); --no-tailscale takes it off"], ["--env KEY=VALUE", `a local model's variable for the server or where Ollama listens, a start-time switch or the usage counts' switch: ${Object.entries(SERVICE_ENV).map(([name, takes]) => (takes ? `${name} (${takes.join(" or ")})` : name)).join(", ")}; kept until KEY= removes it; repeatable`], ["--public-url URL", "the https address people open it at, through a proxy you run in front of it (your own tailscale serve, a reverse proxy); kept for every restart"]], { port: { type: "string" }, tailscale: { type: "boolean" }, env: { type: "string", multiple: true }, "public-url": { type: "string" } }],
|
|
647
|
+
["install", "Install AgentRun as a service of this user and start it: it keeps running after the terminal closes and starts again at login", [["--port N", "the port to listen on (default: the first free from 7340; 7340 with --tailscale)"], ["--data DIR", "the data directory (default ~/.agentrun)"], ["--tailscale", "also serve it over HTTPS on your own tailnet only (tailscale serve, never Funnel); --no-tailscale takes it off"], ["--env KEY=VALUE", `a local model's variable for the server or where Ollama listens, a start-time switch, the marketplace the server reads or the usage counts' switch: ${Object.entries(SERVICE_ENV).map(([name, takes]) => (takes ? `${name} (${takes.join(" or ")})` : name)).join(", ")}; kept until KEY= removes it; repeatable`], ["--public-url URL", "the https address people open it at, through a proxy you run in front of it (your own tailscale serve, a reverse proxy); kept for every restart"]], { port: { type: "string" }, tailscale: { type: "boolean" }, env: { type: "string", multiple: true }, "public-url": { type: "string" } }],
|
|
643
648
|
["status", "Say whether the service is installed and running, the console's address and its health (exit 0 healthy, 1 not, 3 not installed)", [], {}],
|
|
644
649
|
["start", "Start the service and wait until it answers", [], {}],
|
|
645
650
|
["stop", "Stop the service (it starts again at the next login)", [], {}],
|
package/lib/start.mjs
CHANGED
|
@@ -266,7 +266,7 @@ const inCi = (env) => Boolean(env.CI) && env.CI !== "false" && env.CI !== "0";
|
|
|
266
266
|
|
|
267
267
|
/** The server's own commands (its CLI's first word), which this command runs on its store: every other first word is
|
|
268
268
|
* the CLI's, which names a command it has or says it has none. */
|
|
269
|
-
export const SERVER_COMMANDS = ["check-harness", "eval-template", "import", "install-harness", "learning", "native", "remote-bridge", "reset-password", "runner", "sign-in-harness", "store-schema", "validate-template"];
|
|
269
|
+
export const SERVER_COMMANDS = ["check-harness", "eval-template", "import", "install-harness", "learning", "native", "remote-bridge", "reset-password", "runner", "scrub", "sign-in-harness", "store-schema", "validate-template"];
|
|
270
270
|
|
|
271
271
|
/** How many of the server's refusals and ignored deliveries a start says, each route and reason once, before one line
|
|
272
272
|
* that says the rest are not: under this command the server's log goes nowhere else (its stdout is read here and dropped). */
|
|
@@ -288,6 +288,31 @@ function fieldsOf(line) {
|
|
|
288
288
|
return fields;
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
+
/** The error codes the authorize step can send: OAuth's (RFC 6749 4.1.2.1), OpenID Connect's (Core 3.1.2.6), and OpenAI's
|
|
292
|
+
* own for a workspace whose admin turned the plan off. */
|
|
293
|
+
const AUTHORIZE_CODES = new Set([
|
|
294
|
+
"invalid_request", "unauthorized_client", "access_denied", "unsupported_response_type", "invalid_scope", "server_error", "temporarily_unavailable",
|
|
295
|
+
"interaction_required", "login_required", "account_selection_required", "consent_required", "invalid_request_uri", "invalid_request_object",
|
|
296
|
+
"request_not_supported", "request_uri_not_supported", "registration_not_supported",
|
|
297
|
+
"3p_delegated_access_policy_denied",
|
|
298
|
+
]);
|
|
299
|
+
|
|
300
|
+
/** A failed sign-in's reason as the terminal says it. An `authorize_<code>` reason comes from the loopback callback's
|
|
301
|
+
* `?error=`, which any process on the machine can send while a sign-in waits: a code that is not one the authorize step
|
|
302
|
+
* sends is said as `authorize_other`. The server's line, its tagged code whole, is kept in the start log (signInFailed);
|
|
303
|
+
* `agentrun-serve` run on its own logs it. */
|
|
304
|
+
function signInReason(reason) {
|
|
305
|
+
if (reason === undefined) return "no reason given";
|
|
306
|
+
const authorize = /^authorize_(.+)$/.exec(reason);
|
|
307
|
+
return authorize && !AUTHORIZE_CODES.has(authorize[1]) ? "authorize_other" : reason;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** Whether `line` is the server's log line of a ChatGPT sign-in that did not finish. */
|
|
311
|
+
const signInFailed = (line) => {
|
|
312
|
+
const fields = fieldsOf(line);
|
|
313
|
+
return fields.event === "chatgpt" && fields.chatgpt === "sign_in_failed";
|
|
314
|
+
};
|
|
315
|
+
|
|
291
316
|
/** A teller for one start: given a line of the server's output, what to say of it to the person, or undefined. A refused
|
|
292
317
|
* request (auth_failed) and a verified webhook delivery its trigger does not take (hook_ignored) are said in words, with
|
|
293
318
|
* their route and reason and never what was sent, each route and reason once, at most TOLD_MAX. A ChatGPT sign-in that
|
|
@@ -299,7 +324,7 @@ export function tellerOf() {
|
|
|
299
324
|
let full = false;
|
|
300
325
|
return (line) => {
|
|
301
326
|
const fields = fieldsOf(line);
|
|
302
|
-
if (fields.event === "chatgpt" && fields.chatgpt === "sign_in_failed") return `AgentRun's ChatGPT sign-in did not finish (${fields.reason
|
|
327
|
+
if (fields.event === "chatgpt" && fields.chatgpt === "sign_in_failed") return `AgentRun's ChatGPT sign-in did not finish (${signInReason(fields.reason)}): Settings → API Keys says why; start it again there.`;
|
|
303
328
|
if (fields.event === "chatgpt" && fields.chatgpt === "changed_failed") return `AgentRun saved the ChatGPT sign-in but has not taken it into what it offers yet (${fields.reason ?? "no reason given"}): it tries again as Settings reads it; if codex and pi still ask for a key, restart AgentRun.`;
|
|
304
329
|
let words;
|
|
305
330
|
let key;
|
|
@@ -409,7 +434,8 @@ export async function main(argv, env = process.env) {
|
|
|
409
434
|
// server's own "Open " line; the lines SAID names go to stderr after it, for the person, so stdout stays that one line.
|
|
410
435
|
// What it prints on stderr comes through as it is, as it prints it, at the pace this command's stderr is read (forward).
|
|
411
436
|
// Until the server prints the address, all it writes on either goes to the start log too, and the last lines of each are
|
|
412
|
-
// kept: a start that fails says them, with the step, how the server ended and the log (failureText).
|
|
437
|
+
// kept: a start that fails says them, with the step, how the server ended and the log (failureText). After it, the log
|
|
438
|
+
// keeps only a ChatGPT sign-in's failure (tell).
|
|
413
439
|
const log = openStartLog(dataDir);
|
|
414
440
|
const logPath = log.fd === undefined ? undefined : join(dataDir, START_LOG);
|
|
415
441
|
// The first write to the log that failed (a full disk, a quota): the start goes on, the log keeps what it holds, and a
|
|
@@ -486,6 +512,10 @@ export async function main(argv, env = process.env) {
|
|
|
486
512
|
const tell = (line) => {
|
|
487
513
|
const said = SAID.test(line) ? line : teller(line);
|
|
488
514
|
if (said !== undefined) told ? console.error(said) : held.push(said);
|
|
515
|
+
// Started, the start log keeps the server's line of a ChatGPT sign-in that did not finish: its reason whole, a code
|
|
516
|
+
// the terminal says only as authorize_other included, which nothing else under this command keeps. (Before the start,
|
|
517
|
+
// every line goes there already.)
|
|
518
|
+
if (started && signInFailed(line)) toLog(`${line}\n`);
|
|
489
519
|
};
|
|
490
520
|
// A SAID line can come before the "Open " line too (the setup link is printed as the server attaches its owner, before
|
|
491
521
|
// its banner): it is held and said first, in order.
|
|
@@ -539,7 +569,9 @@ export async function main(argv, env = process.env) {
|
|
|
539
569
|
return ended?.code || 1;
|
|
540
570
|
}
|
|
541
571
|
started = true;
|
|
542
|
-
|
|
572
|
+
// Kept open for a sign-in's failure (tell) until the server's output has all been read: its exit can come before the
|
|
573
|
+
// last lines in the pipe.
|
|
574
|
+
void closed.then(closeLog);
|
|
543
575
|
console.log(`AgentRun is running at ${url}`);
|
|
544
576
|
// For the person at the terminal (stderr, so stdout stays the one line a script reads): how to stop it, and where its
|
|
545
577
|
// data is kept, which the next start opens again.
|
package/lib/target.mjs
CHANGED
|
@@ -9,15 +9,24 @@ export const CLOUD_CONSOLE = "https://console.agentrun.ai";
|
|
|
9
9
|
/** The API base of a server's address, the one rule every command takes it by: the address without its trailing
|
|
10
10
|
* slashes, with /v2 added when its path holds no v2 segment, so `https://host/prefix` is `https://host/prefix/v2` and
|
|
11
11
|
* `https://host/v2/` is `https://host/v2`. Only the path's end changes: the string is never re-serialized, so the
|
|
12
|
-
* origin is the given one, byte for byte. The caller checks the address first (
|
|
12
|
+
* origin is the given one, byte for byte. The caller checks the address first (checkedBase). */
|
|
13
13
|
export function apiBase(given) {
|
|
14
14
|
const url = given.replace(/\/+$/, "");
|
|
15
15
|
const path = URL.canParse(url) ? new URL(url).pathname : "";
|
|
16
16
|
return path.split("/").includes("v2") ? url : `${url}/v2`;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/** The API base (apiBase) of an address a token may be sent to: http or https, with no query, fragment, user or
|
|
20
|
+
* password, which would carry the token elsewhere or swallow the path appended to it. Undefined for any other; the
|
|
21
|
+
* caller refuses it without echoing it, as it may hold a password. */
|
|
22
|
+
export function checkedBase(given) {
|
|
23
|
+
const url = typeof given === "string" && URL.canParse(given) ? new URL(given) : undefined;
|
|
24
|
+
if (!url || !/^https?:$/.test(url.protocol) || /[?#]/.test(given) || url.username || url.password) return undefined;
|
|
25
|
+
return apiBase(given);
|
|
26
|
+
}
|
|
27
|
+
|
|
19
28
|
/** The API base a `--to` names: `cloud` is AGENTRUN_CLOUD_URL, else CLOUD_URL; any other address is taken as every
|
|
20
|
-
* command takes one (apiBase). The caller checks the result as every base URL is checked (
|
|
29
|
+
* command takes one (apiBase). The caller checks the result as every base URL is checked (checkedBase), so a query,
|
|
21
30
|
* fragment, user or password is refused there. */
|
|
22
31
|
export function toUrl(given, env) {
|
|
23
32
|
return apiBase(given === "cloud" ? env.AGENTRUN_CLOUD_URL || CLOUD_URL : given);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.26",
|
|
4
4
|
"description": "AgentRun, the open-source platform that supercharges your agents (self-improvement, durable execution and a control plane on top of your favorite agent harness), on this machine with one command: npx @parcha/agentrun",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"NOTICE"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@parcha/agentrun-serve": "0.1.0-beta.
|
|
20
|
+
"@parcha/agentrun-serve": "0.1.0-beta.58"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "node --test 'test/*.test.mjs'"
|
|
@@ -115,6 +115,8 @@ agentrun runs wait "$run" > out.json
|
|
|
115
115
|
|
|
116
116
|
A tool call waiting for approval (`pending.kind` `approval`) is answered by the person in the console (the run's `console_url`): the server takes that answer only from their own session there, never from a token, so the CLI has no command for it. Tell them, then `agentrun runs wait "$run"` once they have.
|
|
117
117
|
|
|
118
|
+
A year of the person's own coding-agent work (tokens, cost, models, harnesses, when they work) is `agentrun wrapped --year 2025`: numbers and names only, read from the session files on the machine the server runs on, and answered only by a server on loopback with no public URL (any other is 403). The console shows it at `#/wrapped`.
|
|
119
|
+
|
|
118
120
|
## Exit codes
|
|
119
121
|
|
|
120
122
|
- 0: done; for `runs wait` and `runs start --wait`, the run completed.
|
|
@@ -127,44 +129,8 @@ A tool call waiting for approval (`pending.kind` `approval`) is answered by the
|
|
|
127
129
|
|
|
128
130
|
## From a program
|
|
129
131
|
|
|
130
|
-
Two clients call the same API from code, with the same server and token. `@parcha/agentrun-client` is the TypeScript one, `new AgentRun({ baseUrl, apiKey })`; `npm install @parcha/agentrun-client` installs it. `parcha-agentrun` (python/) is the Python one, `AgentRun(base_url=..., api_key=...)` from the `agentrun` module; `pip install parcha-agentrun` installs it. Both default to `AGENTRUN_BASE_URL` and `AGENTRUN_API_KEY` and read no config file. Each command
|
|
132
|
+
Two clients call the same API from code, with the same server and token. `@parcha/agentrun-client` is the TypeScript one, `new AgentRun({ baseUrl, apiKey })`; `npm install @parcha/agentrun-client` installs it. `parcha-agentrun` (python/) is the Python one, `AgentRun(base_url=..., api_key=...)` from the `agentrun` module; `pip install parcha-agentrun` installs it. Both default to `AGENTRUN_BASE_URL` and `AGENTRUN_API_KEY` and read no config file. Each command is a method, grouped the same way: `agentrun runs start` is `client.runs.start`, and `client.runs.wait` and `client.runs.follow` do what `--wait` and `--follow` do.
|
|
131
133
|
|
|
132
134
|
## Commands
|
|
133
135
|
|
|
134
|
-
|
|
135
|
-
- `agentrun capabilities`: get-capacity
|
|
136
|
-
- `agentrun cli-learning`: complete, enroll, events, get, list, revoke, start
|
|
137
|
-
- `agentrun connectors`: complete-remote-command, enroll-remote-connector, grant-source-sync, import-remote-history, import-remote-target, list-remote-connectors, poll-remote-connector, publish-source-sync, register-remote-connector, remote-command-events, revoke-remote-connector, source-sync-failure
|
|
138
|
-
- `agentrun deploy SOURCE`: Deploy an agent's package to another AgentRun: upload, plan, apply, lock (deploy rollback, deploy delete)
|
|
139
|
-
- `agentrun doctor`: Check how this AgentRun is set up (Node, the server, its service, address, password, models, switches, Docker) and print what to change; read-only (exit 0 ok or warnings, 1 a check failed, 3 no server answering)
|
|
140
|
-
- `agentrun export AGENT`: Write an agent's current revision as a template package folder, and say what the target sets up again
|
|
141
|
-
- `agentrun files`: create, delete, get, list, upload
|
|
142
|
-
- `agentrun harness`: install, keys, sign-in
|
|
143
|
-
- `agentrun harness-check`: Run a recipe's installed agent for real and check it (tools off, env allowlist, pins, limits, no side requests, resume, a denied call, an MCP tool): a JSON report and three facts. Real models cost money
|
|
144
|
-
- `agentrun harness-keys`: list
|
|
145
|
-
- `agentrun home`: delete, list, read, write
|
|
146
|
-
- `agentrun learning`: corrections, cost, get, log, read, replay, reset, retire, workflow-revisions, write-corrections
|
|
147
|
-
- `agentrun local`: create-pairing, create-suggested-agent, delete-composio-subscription, delete-computer, delete-workspace-archil, discard-suggestion, disconnect-git-hub, get-git-hub-connection, get-model-gateway, get-suggestion, get-workspace-archil, list-composio-events, list-composio-triggers, list-computer-choices, list-computers, list-git-hub-repositories, list-mcp-server-names, list-running-computers, list-suggestions, receive-hook-composio, restore-suggestion, rotate-composio-secret, scan-for-suggestions, test-computer, test-workspace-archil
|
|
148
|
-
- `agentrun login`: Sign in to a server, with a device code when it offers one, else a token read from stdin, and keep the token with the server's address in the config file
|
|
149
|
-
- `agentrun logout`: Remove the config file login wrote, its address and token
|
|
150
|
-
- `agentrun mcp-servers`: delete, get, list, oauth-client, private-hosts, refresh
|
|
151
|
-
- `agentrun Observations`: get-observations
|
|
152
|
-
- `agentrun open`: Open AgentRun in this machine's browser: the setup page, its code filled in, until the owner's password is set; the console after (where no browser opens, it prints the link)
|
|
153
|
-
- `agentrun revisions`: list, set-current
|
|
154
|
-
- `agentrun runs`: archive, cancel, computer-call, computer-release, create-inline-run, create-run-computer-viewer, delete, files, get, grade-run, graph, hand-back-run-computer, learning, learning-diff, list, message, pause, raise-cap, read-file, resume, start, start-held, stop, take-over-run-computer, timeline, trace, unarchive, usage, wait
|
|
155
|
-
- `agentrun sdk-runs`: complete, events, get, start
|
|
156
|
-
- `agentrun server`: capabilities, health, mcp, openapi
|
|
157
|
-
- `agentrun service`: install, logs, restart, start, status, stop, uninstall, upgrade
|
|
158
|
-
- `agentrun skill`: install
|
|
159
|
-
- `agentrun slack`: deliveries, get, redeliver, test
|
|
160
|
-
- `agentrun stats`: Counts and cost over every agent and run
|
|
161
|
-
- `agentrun stop`: Stop the AgentRun the installer started in the background, where there is no service manager (exit 0 stopped, 3 none running)
|
|
162
|
-
- `agentrun template`: apply, delete, eval, get, import, install, list, validate
|
|
163
|
-
- `agentrun tool-keys`: list
|
|
164
|
-
- `agentrun tool-settings`: get, save
|
|
165
|
-
- `agentrun triggers`: create, delete, fire, firings, get, list, update
|
|
166
|
-
- `agentrun usage`: Usage by meter over a period
|
|
167
|
-
- `agentrun webhook`: delete, deliveries, get, redeliver, save, test
|
|
168
|
-
- `agentrun workflows`: validate
|
|
169
|
-
- `agentrun wrapped`: A year of the work under this machine's session files
|
|
170
|
-
- `agentrun api METHOD PATH [--body JSON|@FILE|-]`: any route, PATH under the base URL
|
|
136
|
+
Every command, by group with its flags and route, is in [references/commands.md](references/commands.md); `agentrun api METHOD PATH [--body JSON|@FILE|-]` calls any route, PATH under the base URL.
|
|
@@ -212,6 +212,14 @@ Check native CLI and sign-in without a paid model call.
|
|
|
212
212
|
|
|
213
213
|
Route: `POST /agents/{agent_id}/native/verify`.
|
|
214
214
|
|
|
215
|
+
## api-keys
|
|
216
|
+
|
|
217
|
+
### `agentrun api-keys list`
|
|
218
|
+
|
|
219
|
+
The API keys made for this server's apps; never a key.
|
|
220
|
+
|
|
221
|
+
Route: `GET /settings/api-keys`.
|
|
222
|
+
|
|
215
223
|
## capabilities
|
|
216
224
|
|
|
217
225
|
### `agentrun capabilities get-capacity`
|
|
@@ -433,8 +441,8 @@ Route: `POST /templates/import`, `POST /templates/{template}/apply`.
|
|
|
433
441
|
- `--yes` (boolean, this CLI's own): apply without asking (needed off a terminal)
|
|
434
442
|
- `--force` (boolean, this CLI's own): replace an agent edited on the target since the last deploy
|
|
435
443
|
- `--params FILE` (string, this CLI's own): the package's parameters, a JSON object
|
|
436
|
-
- `--pause-source` (boolean, this CLI's own): an install agent: turn its schedules off on this install once deployed (else they fire in both places)
|
|
437
|
-
- `--agent ID|new` (string, this CLI's own): with no lock for the target: deploy onto its agent ID, or make another agent (new), where it has one this package made with these parameters; with a lock, only the lock's agent
|
|
444
|
+
- `--pause-source` (boolean, this CLI's own): an install agent: turn its schedules off on this install once deployed (else they fire in both places); exits 1, once deployed, when it could not turn every one off
|
|
445
|
+
- `--agent ID|new` (string, this CLI's own): with no lock for the target: deploy onto its agent ID, or make another agent (new), where it has one this package made with these parameters; with a lock, only the lock's agent while it is there (one gone from the target, any)
|
|
438
446
|
|
|
439
447
|
### `agentrun deploy delete SOURCE`
|
|
440
448
|
|
|
@@ -472,7 +480,7 @@ Write an agent's current revision as a template package folder, and say what the
|
|
|
472
480
|
|
|
473
481
|
Route: `GET /agents/{agent_id}/package`.
|
|
474
482
|
|
|
475
|
-
- `--out DIR` (string, this CLI's own): the folder to write: a new one, or an empty one
|
|
483
|
+
- `--out DIR` (string, this CLI's own): the folder to write: a new one, or an empty one, named as the package is (another name is refused, naming the folder to use)
|
|
476
484
|
|
|
477
485
|
## files
|
|
478
486
|
|
|
@@ -784,6 +792,12 @@ The repositories this server's GitHub App is installed on.
|
|
|
784
792
|
|
|
785
793
|
Route: `GET /integrations/github/repositories`.
|
|
786
794
|
|
|
795
|
+
### `agentrun local list-marketplace-templates`
|
|
796
|
+
|
|
797
|
+
The marketplace's templates: every package on marketplace.agentrun.ai, each with the package here that it is.
|
|
798
|
+
|
|
799
|
+
Route: `GET /marketplace/templates`.
|
|
800
|
+
|
|
787
801
|
### `agentrun local list-mcp-server-names`
|
|
788
802
|
|
|
789
803
|
The names of the MCP servers saved here, and nothing else of them.
|
|
@@ -1023,6 +1037,8 @@ The files the run wrote.
|
|
|
1023
1037
|
|
|
1024
1038
|
Route: `GET /runs/{run_id}/files`.
|
|
1025
1039
|
|
|
1040
|
+
- `--cut run` (string, one of these): `run`: each file also has its `name`, its path under the run's own cut (each value the cut holds and each secret shape replaced by `[redacted]` in place, as a cut read cuts a file's text), whatever its type. A run whose end erased what its caller handed it lists no `name`. A run whose cut can't be read is `403 forbidden`, as without `cut`. A server that doesn't know `cut` lists no `name`.
|
|
1041
|
+
|
|
1026
1042
|
### `agentrun runs get RUN_ID`
|
|
1027
1043
|
|
|
1028
1044
|
One run.
|
|
@@ -1082,6 +1098,7 @@ Route: `GET /runs`.
|
|
|
1082
1098
|
- `--status queued|working|paused|input_required|completed|failed|cancelled` (string, one of these): Only runs with this status.
|
|
1083
1099
|
- `--archived` (boolean): true lists only archived runs; false, the default, the others.
|
|
1084
1100
|
- `--label STRING` (string): Only runs holding this label: `<key>:<value>`, split at the first `:` (a key holds none). Once per request; a second `label`, or one that does not read as a label, is 400.
|
|
1101
|
+
- `--source STRING` (string): Only runs imported from this source, a source's name as the run's `imported_from.source` holds it (`claude-code`, `codex`, ...), or `live` for the runs made here, not imported. A name no run holds lists none. Once per request; a second `source`, or one that does not read as a name, is 400.
|
|
1085
1102
|
- `--all` (boolean, this CLI's own): every page: follows next_cursor and prints one list, its next_cursor null; stops past 1000 pages, exit 1
|
|
1086
1103
|
|
|
1087
1104
|
### `agentrun runs message RUN_ID`
|
|
@@ -1119,7 +1136,7 @@ One file's raw bytes.
|
|
|
1119
1136
|
Route: `GET /runs/{run_id}/files/{path}`. It prints the answer's bytes as they are. PATH keeps its slashes.
|
|
1120
1137
|
|
|
1121
1138
|
- `--download INTEGER` (integer): `1` forces a download.
|
|
1122
|
-
- `--cut run` (string, one of these): `run`: the file's text cut of every value the run's own cut holds (the server's keys, the keys a person saved, its secret stores' values, the sign-in refs the run was handed), each one and each secret shape replaced by `[redacted]` in place, as the run's timeline cuts its calls; the text is `[redacted]` whole when a value still shows in a form not cut in place. The
|
|
1139
|
+
- `--cut run` (string, one of these): `run`: the file's text cut of every value the run's own cut holds (the server's keys, the keys a person saved, its secret stores' values, the sign-in refs the run was handed, and what its caller handed it: its own model key, tool keys and MCP servers' credentials), each one and each secret shape replaced by `[redacted]` in place, as the run's timeline cuts its calls; the text is `[redacted]` whole when a value still shows in a form not cut in place. The run's end erases what its caller handed it and counts where those values sat in each of its text files, never the values; from then a file is cut where that count says, while its bytes are the ones counted. A file the count cut in more than 256 places reads `[redacted]` whole. A file not counted as it is now (written or changed since the end, past the count's limits of 2,000 files, 64 MiB read and 512 KiB of count, or a run whose end made no count) is `403 forbidden`. That holds for good: once a run handed secrets has ended a turn, a file a later turn writes or changes is withheld from cut reads, whether or not that turn was handed secrets of its own (read it raw). A secret of no known shape passes as written. Answered `text/plain; charset=utf-8` with `x-agentrun-cut: run` (a server that doesn't know `cut` answers the raw bytes, without it), the whole file (`Range` is not read). A file whose type is not text (text/*, JSON, NDJSON, or an extension the server doesn't type), or whose bytes are not UTF-8 or hold a NUL, is `415 unsupported_media_type`; one over 262144 bytes is `413 payload_too_large`; a run whose cut can't be read (the sign-in it was handed, or what its caller handed it, doesn't open here) is `403 forbidden`. Without `cut`, the file's bytes as written.
|
|
1123
1140
|
- `--range STRING` (string): One byte range, `bytes=<start>-<end>`.
|
|
1124
1141
|
|
|
1125
1142
|
### `agentrun runs resume RUN_ID`
|
|
@@ -1307,7 +1324,7 @@ Route: none, it runs on this machine.
|
|
|
1307
1324
|
- `--port N` (string, this CLI's own): the port to listen on (default: the first free from 7340; 7340 with --tailscale)
|
|
1308
1325
|
- `--data DIR` (string, this CLI's own): the data directory (default ~/.agentrun)
|
|
1309
1326
|
- `--tailscale` (boolean, this CLI's own): also serve it over HTTPS on your own tailnet only (tailscale serve, never Funnel); --no-tailscale takes it off
|
|
1310
|
-
- `--env KEY=VALUE` (string, this CLI's own): a local model's variable for the server or where Ollama listens, a start-time switch or the usage counts' switch: AGENT_MODEL_BASE_URL, AGENT_MODEL_GATEWAY_IDS, AGENT_MODEL, AGENT_MODEL_PRICE, AGENT_MODEL_API_KEY (none), OLLAMA_HOST, AGENTRUN_MCP_ALLOW_LOOPBACK (1), AGENTRUN_WEBHOOK_PRIVATE_TARGETS (1), AGENTRUN_TELEMETRY, DO_NOT_TRACK; kept until KEY= removes it; repeatable
|
|
1327
|
+
- `--env KEY=VALUE` (string, this CLI's own): a local model's variable for the server or where Ollama listens, a start-time switch, the marketplace the server reads or the usage counts' switch: AGENT_MODEL_BASE_URL, AGENT_MODEL_GATEWAY_IDS, AGENT_MODEL, AGENT_MODEL_PRICE, AGENT_MODEL_API_KEY (none), OLLAMA_HOST, OLLAMA_CONTEXT_LENGTH, AGENTRUN_MCP_ALLOW_LOOPBACK (1), AGENTRUN_WEBHOOK_PRIVATE_TARGETS (1), AGENTRUN_MARKETPLACE, AGENTRUN_TELEMETRY, DO_NOT_TRACK; kept until KEY= removes it; repeatable
|
|
1311
1328
|
- `--public-url URL` (string, this CLI's own): the https address people open it at, through a proxy you run in front of it (your own tailscale serve, a reverse proxy); kept for every restart
|
|
1312
1329
|
|
|
1313
1330
|
### `agentrun service logs`
|
|
@@ -1562,6 +1579,16 @@ The triggers: schedules and signed webhooks that start an agent's capped runs or
|
|
|
1562
1579
|
|
|
1563
1580
|
Route: `GET /triggers`.
|
|
1564
1581
|
|
|
1582
|
+
### `agentrun triggers release-firing TRIGGER_ID FIRING_ID`
|
|
1583
|
+
|
|
1584
|
+
The launch hook's host releases a firing it took and will start no run for.
|
|
1585
|
+
|
|
1586
|
+
Route: `POST /triggers/{trigger_id}/firings/{firing_id}/release`.
|
|
1587
|
+
|
|
1588
|
+
- `--error STRING` (string, required): Why the host starts no run for the firing, in plain words: a failure's code or reason, never a person's data or a key.
|
|
1589
|
+
- `--body JSON|@FILE|-` (application/json, required): The whole body: inline, from a file or from stdin. The flags above win over a JSON body's fields.
|
|
1590
|
+
- `--body-type TYPE` (string): The body's type, one of application/json; any other than JSON is sent as given.
|
|
1591
|
+
|
|
1565
1592
|
### `agentrun triggers update TRIGGER_ID`
|
|
1566
1593
|
|
|
1567
1594
|
Change a trigger, or turn it off and on.
|