@parcha/agentrun 0.4.24 → 0.4.25
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 +15 -20
- package/lib/commands.generated.mjs +90 -2
- package/lib/deploy.mjs +86 -23
- package/lib/doctor.mjs +2 -2
- 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 +2 -38
- package/skills/agentrun-cli/references/commands.md +31 -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,25 +155,15 @@ 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
|
-
try {
|
|
171
|
-
return baseOf(url, ""), true;
|
|
172
|
-
} catch {
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
};
|
|
166
|
+
const isBase = (url) => checkedBase(url) !== undefined;
|
|
176
167
|
|
|
177
168
|
/** Where the request goes and the token it carries. A token goes only with the address it came with: the local
|
|
178
169
|
* server's own token is never sent to another server. The local token is DIR/.token, whatever the record says. */
|
|
@@ -201,8 +192,12 @@ function targetOf(values, env) {
|
|
|
201
192
|
const isLocal = base === local;
|
|
202
193
|
if (isLocal && record && !alive(record.pid)) throw new Exit(3, stale);
|
|
203
194
|
if (!token && isLocal) {
|
|
204
|
-
|
|
205
|
-
|
|
195
|
+
// A server started with its token in AGENTRUN_TOKEN (no .token file): the variable is that server's token, and only
|
|
196
|
+
// here, on its own address, is it sent; another address takes AGENTRUN_API_KEY or the token kept for it.
|
|
197
|
+
if (record && !record.token_file) {
|
|
198
|
+
token = env.AGENTRUN_TOKEN;
|
|
199
|
+
if (!token) throw new Exit(4, `The server recorded in ${recordFile} was started with its token in AGENTRUN_TOKEN; set AGENTRUN_API_KEY (or AGENTRUN_TOKEN) to it.`);
|
|
200
|
+
} else token = privateFile(join(data, ".token"))?.trim();
|
|
206
201
|
}
|
|
207
202
|
if (!token) {
|
|
208
203
|
throw new Exit(4, isLocal
|
|
@@ -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,
|
|
@@ -3526,7 +3576,7 @@ export const COMMANDS = [
|
|
|
3526
3576
|
"run"
|
|
3527
3577
|
],
|
|
3528
3578
|
"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
|
|
3579
|
+
"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
3580
|
}
|
|
3531
3581
|
],
|
|
3532
3582
|
"headers": [
|
|
@@ -4693,6 +4743,38 @@ export const COMMANDS = [
|
|
|
4693
4743
|
"raw": false,
|
|
4694
4744
|
"summary": "The triggers: schedules and signed webhooks that start an agent's capped runs or message a run"
|
|
4695
4745
|
},
|
|
4746
|
+
{
|
|
4747
|
+
"command": [
|
|
4748
|
+
"triggers",
|
|
4749
|
+
"release-firing"
|
|
4750
|
+
],
|
|
4751
|
+
"operationId": "releaseTriggerFiring",
|
|
4752
|
+
"method": "POST",
|
|
4753
|
+
"path": "/triggers/{trigger_id}/firings/{firing_id}/release",
|
|
4754
|
+
"pathParams": [
|
|
4755
|
+
"trigger_id",
|
|
4756
|
+
"firing_id"
|
|
4757
|
+
],
|
|
4758
|
+
"multiSegment": [],
|
|
4759
|
+
"query": [],
|
|
4760
|
+
"headers": [],
|
|
4761
|
+
"bodyFlags": [
|
|
4762
|
+
{
|
|
4763
|
+
"name": "error",
|
|
4764
|
+
"type": "string",
|
|
4765
|
+
"required": true,
|
|
4766
|
+
"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."
|
|
4767
|
+
}
|
|
4768
|
+
],
|
|
4769
|
+
"hasBody": true,
|
|
4770
|
+
"bodyRequired": true,
|
|
4771
|
+
"bodyTypes": [
|
|
4772
|
+
"application/json"
|
|
4773
|
+
],
|
|
4774
|
+
"secretBody": false,
|
|
4775
|
+
"raw": false,
|
|
4776
|
+
"summary": "The launch hook's host releases a firing it took and will start no run for"
|
|
4777
|
+
},
|
|
4696
4778
|
{
|
|
4697
4779
|
"command": [
|
|
4698
4780
|
"triggers",
|
|
@@ -4971,6 +5053,12 @@ export const COMMANDS = [
|
|
|
4971
5053
|
// Every route whose body carries a secret, a command's or one with no command (omitted): a raw `api` call to one never
|
|
4972
5054
|
// takes its body from the command line, and what it prints has the body's values cut, its public fields kept.
|
|
4973
5055
|
export const SECRET_ROUTES = [
|
|
5056
|
+
{
|
|
5057
|
+
"operationId": "listComposioToolkits",
|
|
5058
|
+
"method": "POST",
|
|
5059
|
+
"path": "/settings/mcp-servers/composio/toolkits",
|
|
5060
|
+
"publicFields": []
|
|
5061
|
+
},
|
|
4974
5062
|
{
|
|
4975
5063
|
"operationId": "listComposioTools",
|
|
4976
5064
|
"method": "POST",
|
package/lib/deploy.mjs
CHANGED
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
// the target, not confirmed), 3 not runnable yet (keys or MCP servers the target lacks: nothing is made, the setup page
|
|
12
12
|
// printed when the target gives one), 1 the target refused otherwise or could not be reached, 4 no token for it, 5 an
|
|
13
13
|
// operation the target does not offer.
|
|
14
|
+
import { spawnSync } from "node:child_process";
|
|
14
15
|
import { createHash } from "node:crypto";
|
|
15
16
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, rmdirSync, statSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { createRequire } from "node:module";
|
|
16
18
|
import { homedir, hostname } from "node:os";
|
|
17
19
|
import { dirname, join, resolve } from "node:path";
|
|
18
20
|
import { createInterface } from "node:readline/promises";
|
|
@@ -22,6 +24,7 @@ import { toUrl } from "./target.mjs";
|
|
|
22
24
|
* and the answer's schema file the manifest names at the folder's root. */
|
|
23
25
|
const MANIFEST = "agent.md";
|
|
24
26
|
const TREES = ["skills", "rules", "evals"];
|
|
27
|
+
const LOCK_DIR = ".agentrun";
|
|
25
28
|
/** What an upload takes (the server's import limits): refused here before anything is read past them. */
|
|
26
29
|
const MAX_FILES = 256;
|
|
27
30
|
const MAX_BYTES = 8 * 1024 * 1024;
|
|
@@ -55,20 +58,47 @@ async function serverManifest(fail) {
|
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
|
|
61
|
+
/** The package checked as the target's import checks it, before anything is sent: the server installed beside this
|
|
62
|
+
* command runs the import's own check (its `check-upload` command, template-import.ts checkUpload) on the body this
|
|
63
|
+
* deploy is about to send. A package the target would refuse (a category it has not, an answer's schema it would not
|
|
64
|
+
* read, a file over its limits) exits 2 here, in the target's words, with no request made. The check runs in a process
|
|
65
|
+
* of its own, started as this node on the server's cli.js, never through its shell launcher, which runs nowhere without
|
|
66
|
+
* a POSIX shell: loading the server here would take every key out of this command's environment (secrets.ts), the
|
|
67
|
+
* target's token among them. */
|
|
68
|
+
async function checkedHere(files, fail) {
|
|
69
|
+
// Loaded here: start.mjs loads cli.mjs, which loads this module.
|
|
70
|
+
const { SERVE_PACKAGE } = await import("./start.mjs");
|
|
71
|
+
let cli;
|
|
72
|
+
try {
|
|
73
|
+
cli = join(dirname(createRequire(import.meta.url).resolve(`${SERVE_PACKAGE}/package.json`)), "dist", "cli.js");
|
|
74
|
+
} catch {
|
|
75
|
+
throw fail(2, `AgentRun's server (${SERVE_PACKAGE}) is not installed beside this command, and it is the server's import that checks a package: nothing was sent.`);
|
|
76
|
+
}
|
|
77
|
+
const checked = spawnSync(process.execPath, [cli, "check-upload"], { input: JSON.stringify({ files: filesBody(files) }), encoding: "utf8", maxBuffer: 4 * MAX_BYTES, windowsHide: true });
|
|
78
|
+
if (checked.status === 0) return;
|
|
79
|
+
const reasons = (checked.stderr ?? "").trim().split("\n").filter(Boolean);
|
|
80
|
+
if (checked.status === 1 && reasons.length) throw fail(2, `The package does not check, so nothing was sent: ${reasons.join("; ")}`);
|
|
81
|
+
throw fail(2, `The server beside this command could not check the package (${checked.error?.code ?? `exit ${checked.status ?? checked.signal}`}): nothing was sent.`);
|
|
82
|
+
}
|
|
83
|
+
|
|
58
84
|
/** The answer's schema file agent.md names (`output: {schema}`) when it is a file at the package's root other than
|
|
59
85
|
* agent.md. One under skills/, rules/ or evals/ goes with its tree, and the target takes no other folder. None when
|
|
60
86
|
* the manifest names none or does not parse: the target refuses it then, in its own words. */
|
|
61
87
|
function rootSchemaOf(manifest, manifestOf) {
|
|
62
88
|
const schema = manifestOf(manifest.toString("utf8"))?.output?.schema;
|
|
63
|
-
|
|
89
|
+
// A hidden name (".", "..", ".answer.json") is none: the target reads no hidden file, as templates.ts holds it.
|
|
90
|
+
return typeof schema === "string" && /^[^/\\]+$/.test(schema) && !schema.startsWith(".") && schema !== MANIFEST ? schema : undefined;
|
|
64
91
|
}
|
|
65
92
|
|
|
66
93
|
/** A folder's package by path, each file its bytes: agent.md, the skills/, rules/ and evals/ trees, and the answer's
|
|
67
94
|
* 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
|
-
|
|
95
|
+
* folder), nor a hidden file or folder inside the trees. Each hidden path left out, at the top or in a tree, is said by
|
|
96
|
+
* name before anything is sent (a hidden folder once, never what it holds; this CLI's own .agentrun/ is not said). No
|
|
97
|
+
* agent.md, a symbolic link, or anything that is neither a file nor a folder refuses the deploy with nothing sent. */
|
|
98
|
+
async function readFolder(dir, fail, io) {
|
|
71
99
|
const files = new Map();
|
|
100
|
+
const hidden = [];
|
|
101
|
+
const leftOut = (rel, entry) => hidden.push(`${rel}${entry.isDirectory() ? "/" : ""}`);
|
|
72
102
|
let bytes = 0;
|
|
73
103
|
const entryOf = (rel) => {
|
|
74
104
|
try {
|
|
@@ -82,7 +112,10 @@ async function readFolder(dir, fail) {
|
|
|
82
112
|
if (entry.isSymbolicLink()) throw fail(2, `${rel} is a symbolic link: a package holds files and folders alone, so nothing was sent.`);
|
|
83
113
|
if (entry.isDirectory()) {
|
|
84
114
|
// 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 }))
|
|
115
|
+
for (const one of readdirSync(join(dir, rel), { withFileTypes: true })) {
|
|
116
|
+
if (one.name.startsWith(".")) leftOut(`${rel}/${one.name}`, one);
|
|
117
|
+
else take(`${rel}/${one.name}`, one);
|
|
118
|
+
}
|
|
86
119
|
return;
|
|
87
120
|
}
|
|
88
121
|
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,6 +135,8 @@ async function readFolder(dir, fail) {
|
|
|
102
135
|
const schema = rootSchemaOf(files.get(MANIFEST), await serverManifest(fail));
|
|
103
136
|
const entry = schema === undefined ? undefined : entryOf(schema);
|
|
104
137
|
if (entry && !entry.isDirectory()) take(schema, entry);
|
|
138
|
+
for (const one of readdirSync(dir, { withFileTypes: true })) if (one.name.startsWith(".") && one.name !== LOCK_DIR) leftOut(one.name, one);
|
|
139
|
+
if (hidden.length) say(io, `Left out, hidden: ${hidden.sort().join(", ")}`);
|
|
105
140
|
return files;
|
|
106
141
|
}
|
|
107
142
|
|
|
@@ -114,9 +149,13 @@ const filesBody = (files) => [...files].sort(([a], [b]) => (a < b ? -1 : a > b ?
|
|
|
114
149
|
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
150
|
});
|
|
116
151
|
|
|
152
|
+
/** The package folder `dir` as a deploy uploads it (POST /templates/import's `files`); `fail(code, message)` makes the
|
|
153
|
+
* refusal a folder that is no package throws. */
|
|
154
|
+
export const packageFiles = async (dir, fail) => filesBody(await readFolder(dir, fail));
|
|
155
|
+
|
|
117
156
|
/** 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
157
|
* file. */
|
|
119
|
-
function lockOf(text, file, fail) {
|
|
158
|
+
export function lockOf(text, file, fail) {
|
|
120
159
|
if (text === undefined) return undefined;
|
|
121
160
|
let value;
|
|
122
161
|
try {
|
|
@@ -324,7 +363,8 @@ function remote(cli, values, env, io, base) {
|
|
|
324
363
|
const ask = async (method, path, body) => {
|
|
325
364
|
const { response, value, unreached } = await send(method, path, body);
|
|
326
365
|
if (unreached !== undefined) return { why: `not reached: ${unreached}` };
|
|
327
|
-
|
|
366
|
+
// A 2xx with no JSON is no answer to read: an empty list read off it would be a guess.
|
|
367
|
+
if (response.ok) return value === undefined && response.status !== 204 ? { why: `${response.status} with no JSON` } : { value };
|
|
328
368
|
return { why: `${response.status}${typeof value?.error?.message === "string" ? `: ${value.error.message}` : ""}` };
|
|
329
369
|
};
|
|
330
370
|
const call = async (method, path, body, allow = []) => {
|
|
@@ -384,7 +424,7 @@ async function sourceOf({ values, args, env, io, cli, releases }, fail) {
|
|
|
384
424
|
const lock = folderLock(dir, cli);
|
|
385
425
|
releases.push(lock.hold());
|
|
386
426
|
const write = (written) => (lock.write(written), cliFiles(env, cli).learn(written.target));
|
|
387
|
-
return { kind: "folder", dir, lock: { ...lock, write }, files: () => readFolder(dir, fail) };
|
|
427
|
+
return { kind: "folder", dir, lock: { ...lock, write }, files: () => readFolder(dir, fail, io) };
|
|
388
428
|
}
|
|
389
429
|
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
430
|
// The install the agent is on: --base-url, else as every command finds it; never with AGENTRUN_API_KEY, which is the
|
|
@@ -417,20 +457,36 @@ async function sourceOf({ values, args, env, io, cli, releases }, fail) {
|
|
|
417
457
|
}
|
|
418
458
|
|
|
419
459
|
/** 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
|
|
460
|
+
* is done by now, so an install that refuses its trigger routes (a front door without them), is not reached, or answers
|
|
461
|
+
* 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
|
|
462
|
+
* paused. Its exit code: 1 when --pause-source left any schedule unread or unpaused, said after the deploy; else 0. */
|
|
422
463
|
async function sourceSchedules(io, from, values) {
|
|
423
464
|
const pause = values["pause-source"];
|
|
424
465
|
const where = from.source.base;
|
|
466
|
+
const unpaused = () => {
|
|
467
|
+
if (!pause) return 0;
|
|
468
|
+
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.`);
|
|
469
|
+
return 1;
|
|
470
|
+
};
|
|
425
471
|
const listed = await from.source.ask("GET", "/triggers");
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
472
|
+
const why = listed.why ?? (Array.isArray(listed.value?.triggers) ? undefined : "200 with no list of triggers");
|
|
473
|
+
if (why) {
|
|
474
|
+
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.`);
|
|
475
|
+
return unpaused();
|
|
476
|
+
}
|
|
477
|
+
const live = listed.value.triggers.filter((one) => (one.agent_id ?? one.target?.agent_id) === from.agentId && one.source?.kind === "schedule" && one.enabled);
|
|
478
|
+
if (!live.length) return 0;
|
|
479
|
+
if (!pause) {
|
|
480
|
+
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.`);
|
|
481
|
+
return 0;
|
|
482
|
+
}
|
|
483
|
+
let left = 0;
|
|
430
484
|
for (const one of live) {
|
|
431
485
|
const paused = await from.source.ask("PATCH", `/triggers/${enc(one.id ?? one.trigger_id)}`, { enabled: false });
|
|
486
|
+
if (paused.why) left += 1;
|
|
432
487
|
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
488
|
}
|
|
489
|
+
return left ? unpaused() : 0;
|
|
434
490
|
}
|
|
435
491
|
|
|
436
492
|
async function deploy(ctx) {
|
|
@@ -438,6 +494,7 @@ async function deploy(ctx) {
|
|
|
438
494
|
const fail = cli.fail;
|
|
439
495
|
const from = await sourceOf(ctx, fail);
|
|
440
496
|
const files = await from.files();
|
|
497
|
+
await checkedHere(files, fail);
|
|
441
498
|
const sha = packageSha256(files);
|
|
442
499
|
let parameters;
|
|
443
500
|
if (values.params !== undefined) {
|
|
@@ -451,14 +508,20 @@ async function deploy(ctx) {
|
|
|
451
508
|
const prior = from.lock.read();
|
|
452
509
|
const base = targetFor(ctx, from, prior, fail);
|
|
453
510
|
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
|
-
|
|
511
|
+
let lock = prior && prior.target === base ? prior : undefined;
|
|
455
512
|
// --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
|
|
513
|
+
// 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
|
|
514
|
+
// own. A lock whose agent is gone from the target is no lock for this: --agent picks the agent, as with none.
|
|
457
515
|
const picked = values.agent;
|
|
458
516
|
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
517
|
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
518
|
const to = remote(cli, values, env, io, base);
|
|
519
|
+
if (picked !== undefined && lock && picked !== lock.agent_id) {
|
|
520
|
+
const { status } = await to.call("GET", `/agents/${enc(lock.agent_id)}`, undefined, [404, 410]);
|
|
521
|
+
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.`);
|
|
522
|
+
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.`);
|
|
523
|
+
lock = undefined;
|
|
524
|
+
}
|
|
462
525
|
|
|
463
526
|
// The lock's agent as the target has it now: gone (deployed anew), edited since (refused unless --force), or the same
|
|
464
527
|
// revision with the same package (up to date: nothing sent that writes, unless --params asks for parameters the lock
|
|
@@ -476,9 +539,9 @@ async function deploy(ctx) {
|
|
|
476
539
|
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
540
|
if (agent.revision === lock.revision_id && lock.package_sha256 === sha && parameters === undefined) {
|
|
478
541
|
say(io, `This package is up to date on ${to.base}: the agent ${lock.agent_id}, revision ${lock.revision_id}. Nothing was sent.`);
|
|
479
|
-
|
|
542
|
+
const code = from.kind === "agent" ? await sourceSchedules(io, from, values) : 0;
|
|
480
543
|
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
|
|
544
|
+
return code;
|
|
482
545
|
}
|
|
483
546
|
// Onto the revision read here: one written after this read (an edit, another deploy) makes the apply 412.
|
|
484
547
|
onto = { agent_id: lock.agent_id, revision: agent.revision };
|
|
@@ -523,9 +586,9 @@ async function deploy(ctx) {
|
|
|
523
586
|
for (const warning of applied.warnings ?? []) say(io, `Warning (${warning.field}): ${warning.message}`);
|
|
524
587
|
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
588
|
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
|
-
|
|
589
|
+
const code = from.kind === "agent" ? await sourceSchedules(io, from, values) : 0;
|
|
527
590
|
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
|
|
591
|
+
return code;
|
|
529
592
|
}
|
|
530
593
|
|
|
531
594
|
/** The lock a rollback or delete acts on, and the target it names (--to wins). */
|
|
@@ -632,8 +695,8 @@ export const DEPLOY = {
|
|
|
632
695
|
["--yes", "apply without asking (needed off a terminal)"],
|
|
633
696
|
["--force", "replace an agent edited on the target since the last deploy"],
|
|
634
697
|
["--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"],
|
|
698
|
+
["--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"],
|
|
699
|
+
["--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
700
|
["", TOKEN],
|
|
638
701
|
["", "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."],
|
|
639
702
|
],
|
package/lib/doctor.mjs
CHANGED
|
@@ -168,7 +168,7 @@ export async function doctorOf({
|
|
|
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${record?.token_file ? "" : " (the server was started with AGENTRUN_TOKEN; set AGENTRUN_API_KEY to it)"}`;
|
|
171
|
+
} else capsWhy ??= `no token to read the server's capabilities with: ${join(data, ".token")} is not there${record?.token_file ? "" : " (the server was started with AGENTRUN_TOKEN; set AGENTRUN_API_KEY or AGENTRUN_TOKEN to it)"}`;
|
|
172
172
|
}
|
|
173
173
|
const version = caps?.server?.version;
|
|
174
174
|
|
|
@@ -371,7 +371,7 @@ export const DOCTOR = {
|
|
|
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
373
|
const readToken = ({ data, record, env: vars }) => {
|
|
374
|
-
if (record && !record.token_file) return vars.AGENTRUN_API_KEY || undefined;
|
|
374
|
+
if (record && !record.token_file) return vars.AGENTRUN_API_KEY || vars.AGENTRUN_TOKEN || undefined;
|
|
375
375
|
return cli.privateFile(join(data, ".token"))?.trim() || undefined;
|
|
376
376
|
};
|
|
377
377
|
const report = await doctorOf({ data: values.data, env, readRecord: cli.privateFile, readToken });
|
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", "check-upload", "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.25",
|
|
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.57"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "node --test 'test/*.test.mjs'"
|
|
@@ -127,44 +127,8 @@ A tool call waiting for approval (`pending.kind` `approval`) is answered by the
|
|
|
127
127
|
|
|
128
128
|
## From a program
|
|
129
129
|
|
|
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
|
|
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 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
131
|
|
|
132
132
|
## Commands
|
|
133
133
|
|
|
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
|
|
134
|
+
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.
|
|
@@ -1119,7 +1135,7 @@ One file's raw bytes.
|
|
|
1119
1135
|
Route: `GET /runs/{run_id}/files/{path}`. It prints the answer's bytes as they are. PATH keeps its slashes.
|
|
1120
1136
|
|
|
1121
1137
|
- `--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
|
|
1138
|
+
- `--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
1139
|
- `--range STRING` (string): One byte range, `bytes=<start>-<end>`.
|
|
1124
1140
|
|
|
1125
1141
|
### `agentrun runs resume RUN_ID`
|
|
@@ -1307,7 +1323,7 @@ Route: none, it runs on this machine.
|
|
|
1307
1323
|
- `--port N` (string, this CLI's own): the port to listen on (default: the first free from 7340; 7340 with --tailscale)
|
|
1308
1324
|
- `--data DIR` (string, this CLI's own): the data directory (default ~/.agentrun)
|
|
1309
1325
|
- `--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
|
|
1326
|
+
- `--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
1327
|
- `--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
1328
|
|
|
1313
1329
|
### `agentrun service logs`
|
|
@@ -1562,6 +1578,16 @@ The triggers: schedules and signed webhooks that start an agent's capped runs or
|
|
|
1562
1578
|
|
|
1563
1579
|
Route: `GET /triggers`.
|
|
1564
1580
|
|
|
1581
|
+
### `agentrun triggers release-firing TRIGGER_ID FIRING_ID`
|
|
1582
|
+
|
|
1583
|
+
The launch hook's host releases a firing it took and will start no run for.
|
|
1584
|
+
|
|
1585
|
+
Route: `POST /triggers/{trigger_id}/firings/{firing_id}/release`.
|
|
1586
|
+
|
|
1587
|
+
- `--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.
|
|
1588
|
+
- `--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.
|
|
1589
|
+
- `--body-type TYPE` (string): The body's type, one of application/json; any other than JSON is sent as given.
|
|
1590
|
+
|
|
1565
1591
|
### `agentrun triggers update TRIGGER_ID`
|
|
1566
1592
|
|
|
1567
1593
|
Change a trigger, or turn it off and on.
|