@parcha/agentrun 0.4.14 → 0.4.16

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 CHANGED
@@ -33,19 +33,43 @@ machine or container stops, and `agentrun stop` stops it (a SIGTERM, then a SIGK
33
33
  after 45 seconds). Either way the installer returns once AgentRun answers, and prints its address. `sh -s -- --no-start`
34
34
  installs only, `--version V` installs another version, `--node-version V` installs that Node.js (at least the floor),
35
35
  and `--service` fails where there is no service manager. Running it again upgrades, or installs an older version, and
36
- first stops the AgentRun it started in the background itself, whatever version that is.
36
+ first stops the AgentRun it started in the background itself, whatever version that is. An older version does not start on
37
+ a store a later one has upgraded: its server says so and exits, and the store is left as it was. Until the owner's
38
+ password is set, it ends by opening the setup page in this machine's browser with the setup code filled in, or, where no browser
39
+ opens (a remote machine), by printing that link.
40
+
41
+ `agentrun open` does the same at any time: the setup page with a code that is still good (it asks the server for a new
42
+ one when the last has run out) until the password is set, the console after. It reads the code from the service's log,
43
+ `~/.agentrun/logs/agentrun.log`.
37
44
 
38
45
  `agentrun service status` prints the console's address and its health. `start`, `stop`, `restart`, `logs [--follow]`,
39
46
  `upgrade [--version V]` (the installer again, then a restart) and `uninstall` (the data stays) do what they say, and
40
- `agentrun service install [--port N] [--data DIR]` installs the service after a `--no-start`. For a local model, such
47
+ `agentrun service install [--port N] [--data DIR] [--public-url URL]` installs the service after a `--no-start`. For a local model, such
41
48
  as Ollama's, `agentrun service install --env AGENT_MODEL_BASE_URL=<its /v1 address> --env AGENT_MODEL_GATEWAY_IDS=bare --env
42
- AGENT_MODEL=<tag> --env AGENT_MODEL_PRICE=0,0,0` writes those variables into the
43
- service and restarts it. They stay through restarts, upgrades and later installs, and `--env KEY=` removes one. `--env`
44
- takes those four names alone: model keys go in the console, never in a service file. On Linux, a user's
49
+ AGENT_MODEL=<tag> --env AGENT_MODEL_PRICE=0,0,0 --env AGENT_MODEL_API_KEY=none` writes those variables into the
50
+ service and restarts it (`none` alone: 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
51
+ you alone use, `--env AGENTRUN_MCP_ALLOW_LOOPBACK=1 --env AGENTRUN_WEBHOOK_PRIVATE_TARGETS=1` turns on the two start-time
52
+ switches the same way (a switch takes `1` alone). `--env` takes the names `agentrun service install --help` lists, and
53
+ no others: model keys go in the console, never in a service file. The service never sees the shell that installed it, so
54
+ `AGENTRUN_TELEMETRY` or `DO_NOT_TRACK` set there is written into it, and under `CI` it gets `AGENTRUN_TELEMETRY=0`
55
+ ([anonymous usage counts](../../docs/telemetry.md)). On Linux, a user's
45
56
  services stop at logout unless lingering is on: `install` and `status` print the one `sudo loginctl enable-linger` line
46
57
  when it is off. To remove AgentRun, run `agentrun service uninstall`, then delete `~/.agentrun/bin`, `~/.agentrun/lib`,
47
58
  `~/.agentrun/node` and the `PATH` line; the rest of `~/.agentrun` is your data.
48
59
 
60
+ When something doesn't work, `agentrun doctor` (or `npx @parcha/agentrun doctor`) checks the whole setup in one go and
61
+ prints, for each problem, what to change and where it is documented: the Node.js it runs on, whether a server answers
62
+ for the data directory (`--data`, default `~/.agentrun`) and its version, the service (installed, running, lingering on
63
+ Linux), whether a browser elsewhere can open the server's address from this session (an SSH tunnel, `tailscale serve`
64
+ on your tailnet, `--public-url` or `--allow-host`), whether the console's password is set (when it is not, the fix
65
+ is `agentrun open`), whether a model and which harnesses are ready, the server's start-time switches, and Docker for the
66
+ boxes. It only reads: it changes no file, starts and stops nothing, and makes only GET requests. It reads the server
67
+ record `DIR/.server.json` as every command does: one that is not a private file of yours, or whose address is not a plain
68
+ http or https URL, is refused, and one whose process has exited is stale; nothing is sent to the address either names. It reads capabilities with the server's own token in
69
+ `DIR/.token`, and prints no token, key or setup code. `--json` prints the checks for an agent (`{exit, server, checks:
70
+ [{id, status, summary, fix, docs}]}`, each `status` `ok`, `warn`, `fail`, `info` or `skip`). Exit 0 when nothing
71
+ failed (warnings allowed), 1 when a check failed, 3 when no server answers.
72
+
49
73
  On a machine you keep on (a Mac mini, a home server, a VPS), `--tailscale` also puts AgentRun on your own
50
74
  [Tailscale](https://tailscale.com) network, at `https://<machine>.<your tailnet's DNS name>/`, which only your devices
51
75
  on that network open:
@@ -66,6 +90,32 @@ Tailscale's operator may change what it serves, it prints the one `sudo tailscal
66
90
  users, unlimited user devices ([pricing](https://tailscale.com/pricing)). The https address needs MagicDNS and HTTPS
67
91
  certificates turned on in your tailnet's [DNS settings](https://login.tailscale.com/admin/dns).
68
92
 
93
+ Behind a proxy of your own instead (your own `tailscale serve`, a reverse proxy with HTTPS), pass the address people
94
+ open with `--public-url`, and keep the port the proxy points at fixed:
95
+
96
+ ```sh
97
+ npx @parcha/agentrun --port 7340 --public-url https://box.tailnet.example/
98
+ agentrun service install --port 7340 --public-url https://box.tailnet.example/
99
+ ```
100
+
101
+ The server takes it as its public address, as it takes `AGENTRUN_PUBLIC_URL`: its links name it, a browser that sends
102
+ that name as `Host` is let in on loopback (any other gets "unexpected Host header"), and its first visit asks for the
103
+ setup code. On loopback (no `--listen`, or a loopback one) it also sets `AGENTRUN_TRUSTED_PROXIES=loopback`, as
104
+ `--tailscale` does, so sign-in limits count each visitor by the address the proxy names rather than everyone as one;
105
+ an `AGENTRUN_TRUSTED_PROXIES` you set stays as it is (an empty one trusts no proxy), and with `--listen` on another address nothing is trusted. The
106
+ service keeps the flag on its command line, so every restart has both, and so does a later `agentrun service install
107
+ --env` or `--no-tailscale` (`--tailscale` replaces it with the tailnet address). A later `--public-url` changes the address
108
+ alone: the data folder and port stay. It must be an `https://` address, or
109
+ `http://` on this machine (`localhost`, `127.0.0.1`), with no path beyond `/` and no user name or password; anything else
110
+ is refused with exit 2 before the server starts. `AGENTRUN_PUBLIC_URL` still works; given with `--public-url`, the two
111
+ must name the same address. `--public-url` and `--tailscale` don't go together: `--tailscale` names its own.
112
+
113
+ Started on loopback with no public address, where `tailscale` is on `PATH` and signed in, the command reads
114
+ `tailscale status --json` (at most 2 seconds, and it changes nothing) and says once, on stderr, the address your tailnet
115
+ could open it at and the two steps to it: `tailscale serve --bg <port>`, which keeps it on your tailnet, then a restart
116
+ with `--port <port> --public-url https://<machine>.<tailnet>/`. It never runs either, never suggests Funnel, says
117
+ nothing when Tailscale is missing, signed out or slow, and says nothing in CI.
118
+
69
119
  On a Linux server you rent (Ubuntu or Debian, as root), `--vps` sets up AgentRun in Docker Compose instead, with a
70
120
  shell for its agents in Docker sandboxes, on your tailnet when Tailscale is logged in and on the server's loopback
71
121
  otherwise:
package/install.sh CHANGED
@@ -479,6 +479,8 @@ start_background() {
479
479
  say "AgentRun is running at $url"
480
480
  say "It runs in the background until this machine or container stops. $(shown_shim) stop stops it; its log is $log."
481
481
  [ -z "$public" ] || tailnet serve 7340 "$public" || exit 1
482
+ # With no owner yet, its setup page in the browser, the code filled in (or the link, where no browser opens).
483
+ "$shim" open --setup-only || true
482
484
  }
483
485
 
484
486
  # tailscale.mjs of the version installed, on its Node: `address PORT`, `serve PORT URL` or `off`.
@@ -535,9 +537,12 @@ vps_install() {
535
537
  vps_docker
536
538
  command -v openssl > /dev/null 2>&1 || vps_apt install openssl
537
539
 
538
- if ! docker image inspect "$image" > /dev/null 2>&1; then
539
- say "Pulling $image ..."
540
- docker pull -q "$image" > /dev/null || fail "could not pull $image"
540
+ # Pulled on every run, so a tag that moves (an --image like :beta) is the registry's now, not what an earlier run left;
541
+ # a tag already current pulls nothing. An image no registry has (built here) is used as it is.
542
+ say "Pulling $image ..."
543
+ if ! docker pull -q "$image" > /dev/null; then
544
+ docker image inspect "$image" > /dev/null 2>&1 || fail "could not pull $image"
545
+ say "Could not pull $image, so the copy already on this server runs."
541
546
  fi
542
547
 
543
548
  # Where it is reached: every address with --public; else the tailnet's https address when Tailscale is logged in, or
@@ -724,7 +729,7 @@ vps_files() {
724
729
  gid=$(stat -c %g /var/run/docker.sock) || fail "this Docker has no /var/run/docker.sock to give AgentRun"
725
730
  {
726
731
  if [ -f "$env_file" ]; then
727
- grep -v -E '^(AGENTRUN_TOKEN|AGENTRUN_SEAL_KEY|AGENTRUN_IMAGE|AGENTRUN_BIND|AGENTRUN_PUBLIC_URL|AGENTRUN_TRUSTED_PROXIES|DOCKER_GID)=' "$env_file" || true
732
+ grep -v -E '^(AGENTRUN_TOKEN|AGENTRUN_SEAL_KEY|AGENTRUN_IMAGE|AGENTRUN_BIND|AGENTRUN_PUBLIC_URL|AGENTRUN_TRUSTED_PROXIES|DOCKER_GID|AGENTRUN_TELEMETRY|DO_NOT_TRACK)=' "$env_file" || true
728
733
  else
729
734
  echo "# AgentRun's settings for Docker Compose. The installer (--vps) keeps AGENTRUN_TOKEN and AGENTRUN_SEAL_KEY, and"
730
735
  echo "# writes the lines after them on every run. Lines of your own (a model key, AGENTRUN_BOX_ALLOW) stay; keep this"
@@ -737,6 +742,21 @@ vps_files() {
737
742
  printf 'AGENTRUN_PUBLIC_URL=%s\n' "$url"
738
743
  printf 'AGENTRUN_TRUSTED_PROXIES=%s\n' "$trusted"
739
744
  printf 'DOCKER_GID=%s\n' "$gid"
745
+ # The usage counts' switches (docs/telemetry.md) set where this runs reach the server, which reads .env alone. One
746
+ # rule, as `service install --env` keeps them: a value set here wins (running again with AGENTRUN_TELEMETRY=0 turns
747
+ # the counts off), and with none the line .env has stays; with neither, under CI it is off. The server trims a value,
748
+ # so this does too.
749
+ for name in AGENTRUN_TELEMETRY DO_NOT_TRACK; do
750
+ eval "value=\${$name:-}"
751
+ value=$(printf '%s' "$value" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
752
+ case $value in *[!A-Za-z0-9]*) value= ;; esac
753
+ if [ -z "$value" ] && [ -f "$env_file" ] && grep -q -E "^$name=" "$env_file"; then
754
+ printf '%s=%s\n' "$name" "$(sed -n "s/^$name=//p" "$env_file" | tail -n 1)"
755
+ continue
756
+ fi
757
+ if [ "$name" = AGENTRUN_TELEMETRY ] && [ -z "$value" ] && [ -n "${CI:-}" ]; then value=0; fi
758
+ if [ -n "$value" ]; then printf '%s=%s\n' "$name" "$value"; fi
759
+ done
740
760
  } > "$work/env"
741
761
  chmod 600 "$work/env"
742
762
  mv -f "$work/env" "$env_file"
package/lib/cli.mjs CHANGED
@@ -5,7 +5,7 @@
5
5
  // validate and template eval, which check and run a package folder on this machine, are template.mjs's, harness install
6
6
  // (the harness its owner installs: goose) is harness.mjs's, and service
7
7
  // (AgentRun as a launchd or systemd user service) and stop (the AgentRun the installer started in the background) are
8
- // service.mjs's.
8
+ // service.mjs's, and doctor (how this AgentRun is set up, read-only) is doctor.mjs's.
9
9
  import { closeSync, constants, fstatSync, openSync, readFileSync } from "node:fs";
10
10
  import { homedir } from "node:os";
11
11
  import { join, resolve } from "node:path";
@@ -13,13 +13,14 @@ import { parseArgs } from "node:util";
13
13
  import { COMMANDS, SECRET_ROUTES } from "./commands.generated.mjs";
14
14
  import { ALL, FLAGS, MAX_PAGES, REQUEST_MS, WAIT, followTimeline, timerMs, waitRun } from "./follow.mjs";
15
15
  import { SECRETS, guarded, refusalExit } from "./login.mjs";
16
- import { SERVICE, STOP } from "./service.mjs";
16
+ import { DOCTOR } from "./doctor.mjs";
17
+ import { OPEN, SERVICE, STOP } from "./service.mjs";
17
18
  import { SKILL_INSTALL } from "./skill.mjs";
18
19
  import { TEMPLATE_EVAL, TEMPLATE_INSTALL, TEMPLATE_VALIDATE } from "./template.mjs";
19
- import { HARNESS_INSTALL } from "./harness.mjs";
20
+ import { HARNESS_CHECK, HARNESS_INSTALL } from "./harness.mjs";
20
21
 
21
22
  /** The hand-written commands that run as they are given (`run`), beside the table's. */
22
- const LOCAL = [...SECRETS, SKILL_INSTALL, TEMPLATE_VALIDATE, TEMPLATE_EVAL, TEMPLATE_INSTALL, HARNESS_INSTALL, ...SERVICE, STOP];
23
+ const LOCAL = [...SECRETS, SKILL_INSTALL, TEMPLATE_VALIDATE, TEMPLATE_EVAL, TEMPLATE_INSTALL, HARNESS_INSTALL, HARNESS_CHECK, ...SERVICE, STOP, OPEN, DOCTOR];
23
24
  export const NOUNS = new Set(["api", "help", ...[...COMMANDS, ...LOCAL].map((entry) => entry.command[0])]);
24
25
  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
25
26
  const START = "start it with `npx @parcha/agentrun`, or pass --base-url (or set AGENTRUN_BASE_URL) to the address the server printed";
@@ -513,8 +514,9 @@ async function local(entry, argv, env, io) {
513
514
  if (values.help) return io.stdout.write(`${helpOf(entry, entry.help)}\n`), 0;
514
515
  const args = positionals.slice(entry.command.length);
515
516
  const count = entry.pathParams.length;
516
- if (args.length !== count) throw usageError(`${helpOf(entry, entry.help)}\n\n${usageOf(entry)} takes ${count || "no"} argument${count === 1 ? "" : "s"}, given ${args.length}.`);
517
- const cli = { fail: (code, message) => new Exit(code, message), baseOf, targetOf, clientOf, request, BAD_HEADER };
517
+ // An entry whose arguments a flag can stand in for (`harness install --recipe FILE`) takes none too; its run checks.
518
+ 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}.`);
519
+ const cli = { fail: (code, message) => new Exit(code, message), baseOf, targetOf, clientOf, request, privateFile, BAD_HEADER };
518
520
  return entry.run({ values, args, env, io, cli });
519
521
  }
520
522
 
@@ -1480,6 +1480,26 @@ export const COMMANDS = [
1480
1480
  "raw": false,
1481
1481
  "summary": "Whether a GitHub App is connected, and if so its id, slug and installations, never a secret"
1482
1482
  },
1483
+ {
1484
+ "command": [
1485
+ "local",
1486
+ "get-model-gateway"
1487
+ ],
1488
+ "operationId": "getModelGateway",
1489
+ "method": "GET",
1490
+ "path": "/settings/model-gateway",
1491
+ "pathParams": [],
1492
+ "multiSegment": [],
1493
+ "query": [],
1494
+ "headers": [],
1495
+ "bodyFlags": [],
1496
+ "hasBody": false,
1497
+ "bodyRequired": false,
1498
+ "bodyTypes": [],
1499
+ "secretBody": false,
1500
+ "raw": false,
1501
+ "summary": "The model gateway in force: the environment's, the one saved here, or none"
1502
+ },
1483
1503
  {
1484
1504
  "command": [
1485
1505
  "local",
@@ -2153,6 +2173,30 @@ export const COMMANDS = [
2153
2173
  "raw": false,
2154
2174
  "summary": "Start a run of an agent another system owns, given inline"
2155
2175
  },
2176
+ {
2177
+ "command": [
2178
+ "runs",
2179
+ "create-run-computer-viewer"
2180
+ ],
2181
+ "operationId": "createRunComputerViewer",
2182
+ "method": "POST",
2183
+ "path": "/runs/{run_id}/computer/viewer",
2184
+ "pathParams": [
2185
+ "run_id"
2186
+ ],
2187
+ "multiSegment": [],
2188
+ "query": [],
2189
+ "headers": [],
2190
+ "bodyFlags": [],
2191
+ "hasBody": true,
2192
+ "bodyRequired": false,
2193
+ "bodyTypes": [
2194
+ "application/json"
2195
+ ],
2196
+ "secretBody": false,
2197
+ "raw": false,
2198
+ "summary": "Mint a link to the run's live view for the backend's user"
2199
+ },
2156
2200
  {
2157
2201
  "command": [
2158
2202
  "runs",
@@ -3006,7 +3050,8 @@ export const COMMANDS = [
3006
3050
  "type": "string",
3007
3051
  "enum": [
3008
3052
  "claude-agent-sdk",
3009
- "codex-sdk"
3053
+ "codex-sdk",
3054
+ "eve"
3010
3055
  ],
3011
3056
  "required": true,
3012
3057
  "description": ""
@@ -3132,6 +3177,88 @@ export const COMMANDS = [
3132
3177
  "raw": false,
3133
3178
  "summary": "This document"
3134
3179
  },
3180
+ {
3181
+ "command": [
3182
+ "slack",
3183
+ "deliveries"
3184
+ ],
3185
+ "operationId": "listSlackDeliveries",
3186
+ "method": "GET",
3187
+ "path": "/settings/slack/deliveries",
3188
+ "pathParams": [],
3189
+ "multiSegment": [],
3190
+ "query": [],
3191
+ "headers": [],
3192
+ "bodyFlags": [],
3193
+ "hasBody": false,
3194
+ "bodyRequired": false,
3195
+ "bodyTypes": [],
3196
+ "secretBody": false,
3197
+ "raw": false,
3198
+ "summary": "Slack's last 50 attempts, newest first"
3199
+ },
3200
+ {
3201
+ "command": [
3202
+ "slack",
3203
+ "get"
3204
+ ],
3205
+ "operationId": "getSlack",
3206
+ "method": "GET",
3207
+ "path": "/settings/slack",
3208
+ "pathParams": [],
3209
+ "multiSegment": [],
3210
+ "query": [],
3211
+ "headers": [],
3212
+ "bodyFlags": [],
3213
+ "hasBody": false,
3214
+ "bodyRequired": false,
3215
+ "bodyTypes": [],
3216
+ "secretBody": false,
3217
+ "raw": false,
3218
+ "summary": "Where this server posts run notices in Slack, if it is set; never the URL"
3219
+ },
3220
+ {
3221
+ "command": [
3222
+ "slack",
3223
+ "redeliver"
3224
+ ],
3225
+ "operationId": "redeliverSlack",
3226
+ "method": "POST",
3227
+ "path": "/settings/slack/deliveries/{webhook_id}/redeliver",
3228
+ "pathParams": [
3229
+ "webhook_id"
3230
+ ],
3231
+ "multiSegment": [],
3232
+ "query": [],
3233
+ "headers": [],
3234
+ "bodyFlags": [],
3235
+ "hasBody": false,
3236
+ "bodyRequired": false,
3237
+ "bodyTypes": [],
3238
+ "secretBody": false,
3239
+ "raw": false,
3240
+ "summary": "Post a message of Slack's log again, once now, under the same id and body"
3241
+ },
3242
+ {
3243
+ "command": [
3244
+ "slack",
3245
+ "test"
3246
+ ],
3247
+ "operationId": "testSlack",
3248
+ "method": "POST",
3249
+ "path": "/settings/slack/test",
3250
+ "pathParams": [],
3251
+ "multiSegment": [],
3252
+ "query": [],
3253
+ "headers": [],
3254
+ "bodyFlags": [],
3255
+ "hasBody": false,
3256
+ "bodyRequired": false,
3257
+ "bodyTypes": [],
3258
+ "secretBody": false,
3259
+ "raw": false,
3260
+ "summary": "Post a test message to Slack now, once, and say how it went"
3261
+ },
3135
3262
  {
3136
3263
  "command": [
3137
3264
  "stats"
@@ -3813,6 +3940,12 @@ export const SECRET_ROUTES = [
3813
3940
  "path": "/triggers/{trigger_id}/secret",
3814
3941
  "publicFields": []
3815
3942
  },
3943
+ {
3944
+ "operationId": "rotateWebhookSecret",
3945
+ "method": "POST",
3946
+ "path": "/settings/webhook/secret",
3947
+ "publicFields": []
3948
+ },
3816
3949
  {
3817
3950
  "operationId": "saveComposioServer",
3818
3951
  "method": "PUT",
@@ -3832,6 +3965,24 @@ export const SECRET_ROUTES = [
3832
3965
  "auth.type"
3833
3966
  ]
3834
3967
  },
3968
+ {
3969
+ "operationId": "saveModelGateway",
3970
+ "method": "PUT",
3971
+ "path": "/settings/model-gateway",
3972
+ "publicFields": [
3973
+ "base_url",
3974
+ "ids",
3975
+ "models.default",
3976
+ "models.fast",
3977
+ "models.strong"
3978
+ ]
3979
+ },
3980
+ {
3981
+ "operationId": "saveSlack",
3982
+ "method": "PUT",
3983
+ "path": "/settings/slack",
3984
+ "publicFields": []
3985
+ },
3835
3986
  {
3836
3987
  "operationId": "saveToolKey",
3837
3988
  "method": "PUT",
@@ -3847,5 +3998,13 @@ export const SECRET_ROUTES = [
3847
3998
  "scopes.[]",
3848
3999
  "client_id"
3849
4000
  ]
4001
+ },
4002
+ {
4003
+ "operationId": "testModelGateway",
4004
+ "method": "POST",
4005
+ "path": "/settings/model-gateway/test",
4006
+ "publicFields": [
4007
+ "base_url"
4008
+ ]
3850
4009
  }
3851
4010
  ];