@parcha/agentrun 0.4.11 → 0.4.13

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.
@@ -0,0 +1,175 @@
1
+ // `--tailscale` (install.sh, `agentrun service install`): AgentRun on the person's own tailnet, over HTTPS at this
2
+ // machine's MagicDNS name, through `tailscale serve` in front of the server on loopback. Never Funnel: a serve entry with
3
+ // Funnel on is refused by name and left as it is. Tailscale itself is never installed, logged in or given sudo here;
4
+ // what it lacks is said as steps, and AgentRun runs on this machine meanwhile. The entry added is recorded in
5
+ // ~/.agentrun/tailscale.json, so `off` removes that entry and no other serve setting.
6
+ //
7
+ // Run as a script, it is the installer's step where AgentRun runs in the background (no service manager), and its --vps
8
+ // step, run in the server's image with this machine's tailscale and its socket mounted:
9
+ // node tailscale.mjs address PORT AGAIN prints the https address to start the server with, or nothing
10
+ // node tailscale.mjs serve PORT AGAIN URL [LOG] serves the loopback PORT at URL, the address printed, and says where;
11
+ // LOG is where the setup code's line is (default ~/.agentrun's log)
12
+ // node tailscale.mjs off removes the entry it added
13
+ import { spawnSync } from "node:child_process";
14
+ import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
15
+ import { homedir } from "node:os";
16
+ import { join } from "node:path";
17
+
18
+ /** The port AgentRun is served on when --tailscale names none: fixed, so the serve entry and the server agree after a
19
+ * restart, where "the first free port" could land on another of this machine's services. */
20
+ export const TAILNET_PORT = "7340";
21
+ export const PRICE = "Tailscale's Personal plan is free: up to 6 users, unlimited user devices (https://tailscale.com/pricing).";
22
+ const MAC_APP = "/Applications/Tailscale.app/Contents/MacOS/Tailscale";
23
+ const DENIED = /Access denied/i;
24
+
25
+ /** The proxy target of the server on `port`. */
26
+ const LOOPBACK = "127.0.0.1"; // key-gate: loopback-rule serve proxies to the server on this machine
27
+ export const targetOf = (port) => `http://${LOOPBACK}:${port}`;
28
+
29
+ /** Tailscale on this machine, driven through `exec` (spawnSync's shape); `again` is the command that runs this step again;
30
+ * `log`, where the server's setup code line is. */
31
+ export function tailnetOf({ platform = process.platform, root = join(homedir(), ".agentrun"), uid = process.getuid?.(), exec, say, fail, again, log = join(root, "logs", "agentrun.log") }) {
32
+ // The Mac app's CLI is in the app, and on PATH only when someone put it there.
33
+ let bin;
34
+ const run = (args, options) => {
35
+ bin ??= platform === "darwin" && exec("tailscale", ["version"]).error?.code === "ENOENT" && existsSync(MAC_APP) ? MAC_APP : "tailscale";
36
+ return exec(bin, args, options);
37
+ };
38
+ const state = join(root, "tailscale.json");
39
+ const json = (result) => {
40
+ try {
41
+ return JSON.parse(result.stdout?.trim() || "{}");
42
+ } catch {
43
+ return undefined;
44
+ }
45
+ };
46
+ const errorOf = (result) => `${result.error?.message ?? ""}${result.stderr ?? ""}`.trim().split("\n")[0];
47
+ const up = platform === "darwin" ? "open the Tailscale app and log in" : uid === 0 ? "tailscale up" : "sudo tailscale up --operator=$USER";
48
+ const steps = (why, ...todo) => {
49
+ say(`${why}, so AgentRun is on this machine only for now. To open it from your phone and laptop, on your tailnet only:`);
50
+ todo.forEach((step, i) => say(` ${i + 1}. ${step}`));
51
+ say(`Then run again: ${again}`);
52
+ say(PRICE);
53
+ };
54
+ const operator = (retry = again) => {
55
+ say("Tailscale on Linux lets only root or its operator change what it serves. Run once:");
56
+ say(" sudo tailscale set --operator=$USER");
57
+ say(`Then run again: ${retry}`);
58
+ };
59
+ const serveConfig = () => {
60
+ const result = run(["serve", "status", "--json"]);
61
+ if (result.status !== 0) return { denied: DENIED.test(result.stderr ?? ""), missing: result.error?.code === "ENOENT", error: errorOf(result) };
62
+ return { config: json(result) ?? {} };
63
+ };
64
+ const recorded = () => {
65
+ try {
66
+ return JSON.parse(readFileSync(state, "utf8"));
67
+ } catch {
68
+ return undefined;
69
+ }
70
+ };
71
+ const handlerOf = (config, host) => config.Web?.[`${host}:443`]?.Handlers?.["/"];
72
+
73
+ return {
74
+ state,
75
+ recorded,
76
+ /** The https address to serve AgentRun at, its server to be `target`: `{ host, url }`, or undefined once what Tailscale
77
+ * lacks is said. Throws, changing nothing, when Funnel is on there or another service has it. */
78
+ address(target) {
79
+ const status = run(["status", "--json"]);
80
+ if (status.error?.code === "ENOENT") {
81
+ const link = platform === "darwin" ? "https://tailscale.com/download/mac" : "https://tailscale.com/download/linux";
82
+ return steps("Tailscale is not installed here", `Install Tailscale: ${link}`, `Connect this machine to your tailnet: ${up}`);
83
+ }
84
+ const st = status.status === 0 ? json(status) : undefined;
85
+ if (st === undefined) {
86
+ const start = platform === "darwin" ? "open the Tailscale app" : "sudo systemctl enable --now tailscaled";
87
+ return steps(`Tailscale is installed but not running (${errorOf(status) || "no status"})`, `Start it: ${start}`, `Connect this machine to your tailnet: ${up}`);
88
+ }
89
+ if (st.BackendState !== "Running") return steps(`Tailscale is installed but this machine is not on a tailnet (${st.BackendState ?? "no state"})`, `Connect it: ${up}`);
90
+ const host = (st.Self?.DNSName ?? "").replace(/\.$/, "");
91
+ if (!host || !(st.CertDomains ?? []).includes(host)) {
92
+ return steps(`tailscale serve needs an HTTPS certificate, and your tailnet gives none to this machine${host ? ` (${host})` : ""}`, "Turn on MagicDNS and HTTPS Certificates: https://login.tailscale.com/admin/dns");
93
+ }
94
+ const { config, denied, error } = serveConfig();
95
+ if (denied) return operator();
96
+ if (config === undefined) throw fail(1, `tailscale serve status failed: ${error}.`);
97
+ if (config.AllowFunnel?.[`${host}:443`]) {
98
+ throw fail(1, `Tailscale Funnel is on for https://${host}/ (tailscale funnel status), which puts it on the public internet. AgentRun is served on your tailnet only, so nothing was changed. Turn that Funnel off, then run again: ${again}`);
99
+ }
100
+ const handler = handlerOf(config, host);
101
+ const tcp = config.TCP?.["443"];
102
+ const ours = [target, recorded()?.proxy].filter(Boolean);
103
+ if ((handler && !ours.includes(handler.Proxy)) || (tcp && !tcp.HTTPS)) {
104
+ const what = handler ? handler.Proxy ?? handler.Path ?? "text" : tcp.TCPForward;
105
+ throw fail(1, `https://${host}/ already serves ${what} on your tailnet (tailscale serve status), so AgentRun left it as it is and changed nothing. Free it, then run again: ${again}`);
106
+ }
107
+ return { host, url: `https://${host}/` };
108
+ },
109
+ /** Serves the server on `port` at `host`'s https address; false once what stops it is said (operator rights). */
110
+ serve(port, host) {
111
+ const target = targetOf(port);
112
+ // Tailscale's own words (a link to turn something on, say) go to the terminal as it writes them.
113
+ const result = run(["serve", "--bg", "--https=443", target], { stdio: ["ignore", "inherit", "pipe"] });
114
+ if (result.status !== 0) {
115
+ if (DENIED.test(result.stderr ?? "")) return operator(), false;
116
+ throw fail(1, `tailscale serve --bg --https=443 ${target} failed: ${errorOf(result)}.`);
117
+ }
118
+ const { config } = serveConfig();
119
+ if (handlerOf(config ?? {}, host)?.Proxy !== target) throw fail(1, `tailscale serve did not serve ${target} at https://${host}/ (tailscale serve status shows what it serves).`);
120
+ writeFileSync(state, `${JSON.stringify({ url: `https://${host}/`, proxy: target })}\n`, { mode: 0o600 });
121
+ say(`AgentRun is on your tailnet at https://${host}/ (tailscale serve): only your devices on your tailnet open it; nothing is on the public internet.`);
122
+ say(`It asks for a setup code on the first visit: the newest "Set up this server" line in ${log} has the link.`);
123
+ say(PRICE);
124
+ return true;
125
+ },
126
+ /** Removes the serve entry this added, when it is still the one there; never another. The record stays while
127
+ * Tailscale's settings can't be read or change, so running it again finishes the job. */
128
+ off(retry = again) {
129
+ const had = recorded();
130
+ if (!had) return;
131
+ const host = URL.canParse(had.url) ? new URL(had.url).hostname : "";
132
+ const { config, denied, missing, error } = serveConfig();
133
+ if (denied) return operator(retry);
134
+ if (config === undefined && !missing) {
135
+ // The entry may still be in Tailscale's settings (tailscaled stopped keeps them), so the record stays for the next run.
136
+ say(`AgentRun's entry at https://${host}/ may still be in Tailscale's serve settings, and they can't be read now (${error || "no answer"}). Start Tailscale, then run again: ${retry}`);
137
+ return;
138
+ }
139
+ // With Tailscale gone, what it served went with it.
140
+ if (config !== undefined && handlerOf(config, host)?.Proxy === had.proxy) {
141
+ const result = run(["serve", "--https=443", "off"]);
142
+ if (result.status !== 0) {
143
+ if (DENIED.test(result.stderr ?? "")) return operator(retry);
144
+ throw fail(1, `tailscale serve --https=443 off failed: ${errorOf(result)}.`);
145
+ }
146
+ say(`Removed AgentRun from your tailnet (tailscale serve --https=443 off): https://${host}/ serves nothing now.`);
147
+ }
148
+ rmSync(state, { force: true });
149
+ },
150
+ };
151
+ }
152
+
153
+ /** The installer's step for an AgentRun in the background or under --vps. Exit 1 on a refusal, said on stderr. */
154
+ function script([verb, port, again, url, log]) {
155
+ const fail = (code, message) => Object.assign(new Error(message), { code });
156
+ // `address` prints the address alone on stdout, for the installer to read; what it says goes to stderr.
157
+ const say = (line) => (verb === "address" ? process.stderr : process.stdout).write(`${line}\n`);
158
+ const exec = (command, args, options = {}) => spawnSync(command, args, { encoding: "utf8", ...options });
159
+ const tailnet = tailnetOf({ exec, say, fail, again, ...(log ? { log } : {}) });
160
+ try {
161
+ if (verb === "address") {
162
+ const at = tailnet.address(targetOf(port));
163
+ if (at) process.stdout.write(`${at.url}\n`);
164
+ } else if (verb === "serve") tailnet.serve(port, new URL(url).hostname);
165
+ else if (verb === "off") tailnet.off();
166
+ else throw fail(2, `tailscale.mjs takes address, serve or off, not ${verb}`);
167
+ return 0;
168
+ } catch (error) {
169
+ process.stderr.write(`agentrun: ${error.message}\n`);
170
+ return error.code ?? 1;
171
+ }
172
+ }
173
+
174
+ // The installer runs this on the Node it installed, inside the engines floor, where import.meta.main is set.
175
+ if (import.meta.main) process.exitCode = script(process.argv.slice(2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun",
3
- "version": "0.4.11",
3
+ "version": "0.4.13",
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",
@@ -11,12 +11,13 @@
11
11
  "bin",
12
12
  "lib",
13
13
  "skills",
14
+ "install.sh",
14
15
  "README.md",
15
16
  "LICENSE",
16
17
  "NOTICE"
17
18
  ],
18
19
  "dependencies": {
19
- "@parcha/agentrun-serve": "0.1.0-beta.43"
20
+ "@parcha/agentrun-serve": "0.1.0-beta.45"
20
21
  },
21
22
  "scripts": {
22
23
  "test": "node --test 'test/*.test.mjs'"
@@ -36,9 +36,9 @@ First clarify whether the user wants a live connection, historical import, or bo
36
36
 
37
37
  On the machine with the existing Claude Code or Codex setup, use `npx @parcha/agentrun native discover --project /absolute/project` to inspect supported project defaults, named Claude agents and Codex profiles without a model call. Then run `npx @parcha/agentrun native connect --project /absolute/project --runtime claude-code` (or `codex`), adding `--agent NAME` or `--profile NAME` for a discovered selector. The local server uses `--data DIR`; `--url http://127.0.0.1:PORT` selects its loopback address. For another machine, use the existing Python connector's `remote` command from the same reviewed build, with the matching `agentrun-serve remote-bridge` runtime. The released observation-only connector is not a remote execution worker. Pair using the console's one-use code entered into the secure CLI prompt; never send a broad server token or put the code in a command argument. Source configuration and sign-in stay on that machine. For completed project history, preview with the matching Python connector’s `remote history-preview --project /absolute/project --runtime claude-code` (or `codex`). Select History only or Both when creating the owner’s code; the source must also explicitly pass `--history-only` or `--history` to `remote connect`. History-only starts no worker or learning and needs no native sign-in. History flags reject named-agent/profile selectors because native logs cannot attribute sessions to them reliably. Re-import the approved target with `remote import-history --state-dir /private/connector`; duplicates are skipped. Historical records never become live jobs or automatic learning. Local-store imports still use the separate maintenance-window flow in the server skill.
38
38
 
39
- For an authorized live connection, open the connected agent, verify its native sign-in, and turn Self-improving On only when requested to use the existing checked/graded learning pipeline. Native projects keep their original instructions, tools, hooks, permissions and login. AgentRun adds notes and skills without rewriting those files. Native dollar caps, interactive approvals, learned workflows and attachment to an already-running desktop conversation are unavailable; never bypass native permissions to make a run work. Off supplies and creates no AgentRun learning on subsequent runs. Reflection and grading make additional model calls using native sign-in unless the server has an explicit grading model route.
39
+ For an authorized live connection, open the connected agent, verify its native sign-in, and turn Self-improving On only when requested to use the existing checked learning pipeline. Native projects keep their original instructions, tools, hooks, permissions and login. AgentRun adds the owner's corrections (corrections.md) to the run's context without rewriting those files. Native dollar caps, interactive approvals, learned workflows and attachment to an already-running desktop conversation are unavailable; never bypass native permissions to make a run work. Off supplies and creates no AgentRun learning on subsequent runs. The end-of-run step makes additional model calls using native sign-in.
40
40
 
41
- For the remote development build, install the Python connector from `./connector` in the same reviewed checkout after building its Node runtime (Python 3.12+ and Node 24.22.3+). A checkout build does not put `agentrun-serve` on PATH: pass `--bridge /absolute/path/to/checkout/packages/serve/dist/native/remote-worker-bridge.js` to discovery and connection. The Python connector and Node management CLI share the name `agentrun`; verify the executable, or use `python -m agentrun_cli` inside the installed connector environment. Keep its source worker online for live jobs. Inspect accepted notes and skills in Learning Dojo, then verify a fresh run uses them; imported history never supplies that learning automatically.
41
+ For the remote development build, install the Python connector from `./connector` in the same reviewed checkout after building its Node runtime (Python 3.12+ and Node 24.22.3+). A checkout build does not put `agentrun-serve` on PATH: pass `--bridge /absolute/path/to/checkout/packages/serve/dist/native/remote-worker-bridge.js` to discovery and connection. The Python connector and Node management CLI share the name `agentrun`; verify the executable, or use `python -m agentrun_cli` inside the installed connector environment. Keep its source worker online for live jobs. Inspect the corrections in Learning Dojo, then verify a fresh run uses them; imported history never supplies that learning automatically.
42
42
 
43
43
  ## Recipes
44
44
 
@@ -131,22 +131,25 @@ Two clients call the same API from code, with the same server and token. `@parch
131
131
 
132
132
  ## Commands
133
133
 
134
- - `agentrun agents`: archive, connect-native, create, delete-agent-archil, disconnect-native, discover-native, forget-sign-in, get, get-agent-archil, get-learning-loop, get-native, list, list-learning-audits, list-learning-promotions, runs, unarchive, update, verify-native
134
+ - `agentrun agents`: archive, connect-native, create, delete-agent, delete-agent-archil, disconnect-native, discover-native, forget-sign-in, get, get-agent-archil, get-learning-loop, get-native, list, list-learning-audits, list-learning-promotions, runs, unarchive, update, verify-native
135
135
  - `agentrun connectors`: complete-remote-command, enroll-remote-connector, import-remote-history, import-remote-target, list-remote-connectors, poll-remote-connector, register-remote-connector, remote-command-events, revoke-remote-connector
136
136
  - `agentrun files`: create, delete, get, list, upload
137
+ - `agentrun harness`: install
137
138
  - `agentrun home`: delete, list, read, write
138
- - `agentrun learning`: batch, batch-cancel, batch-start, batches, cost, evals, get, log, notes, read, record-eval, replay, retire, workflow-revisions, write
139
+ - `agentrun learning`: corrections, cost, get, log, read, replay, retire, workflow-revisions, write-corrections
139
140
  - `agentrun local`: create-pairing, delete-composio-subscription, delete-computer, delete-workspace-archil, disconnect-git-hub, get-git-hub-connection, get-workspace-archil, list-composio-events, list-composio-triggers, list-computer-choices, list-computers, receive-hook-composio, rotate-composio-secret, test-computer, test-workspace-archil
140
141
  - `agentrun login`: Check a server's token, read from stdin, and keep it with the server's address in the config file
141
142
  - `agentrun logout`: Remove the config file login wrote, its address and token
142
143
  - `agentrun mcp-servers`: delete, get, list, oauth-client, private-hosts, refresh
143
144
  - `agentrun Observations`: get-observations
144
145
  - `agentrun revisions`: list, set-current
145
- - `agentrun runs`: archive, cancel, computer-call, computer-release, create-inline-run, 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, unarchive, wait
146
+ - `agentrun runs`: archive, cancel, computer-call, computer-release, create-inline-run, 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, wait
146
147
  - `agentrun sdk-runs`: complete, events, get, start
147
148
  - `agentrun server`: capabilities, health, mcp, openapi
149
+ - `agentrun service`: install, logs, restart, start, status, stop, uninstall, upgrade
148
150
  - `agentrun skill`: install
149
151
  - `agentrun stats`: Counts and cost over every agent and run
152
+ - `agentrun stop`: Stop the AgentRun the installer started in the background, where there is no service manager (exit 0 stopped, 3 none running)
150
153
  - `agentrun template`: apply, delete, eval, import, install, list, validate
151
154
  - `agentrun tool-keys`: list
152
155
  - `agentrun tool-settings`: get, save
@@ -29,11 +29,17 @@ Create an agent home.
29
29
 
30
30
  Route: `POST /agents`.
31
31
 
32
- - `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first
32
+ - `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first answer with `Idempotent-Replayed: true`; another body is `409 idempotency_mismatch`; a retry while the first is in flight is `409 idempotency_in_progress`. Keys are scoped to the credential's account and the route.
33
33
  - `--note STRING` (string): What the revision changes, kept with it (GET /agents/{agent_id}/revisions).
34
34
  - `--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.
35
35
  - `--body-type TYPE` (string): The body's type, one of application/json; any other than JSON is sent as given.
36
36
 
37
+ ### `agentrun agents delete-agent AGENT_ID`
38
+
39
+ Delete an agent another system owns.
40
+
41
+ Route: `DELETE /agents/{agent_id}`.
42
+
37
43
  ### `agentrun agents delete-agent-archil AGENT_ID`
38
44
 
39
45
  Remove an agent's own Archil disk, and everything on it.
@@ -244,10 +250,10 @@ Route: `POST /files`.
244
250
  - `--path STRING` (string): With the file's bytes as the body: the file's path (FilePathString). Its presence makes the body the file.
245
251
  - `--content-type STRING` (string): With `path`: the file's type. Absent, the request's own type when it names one (not application/octet-stream, not application/x-www-form-urlencoded), else the path's extension's, else application/octet-stream.
246
252
  - `--sha256 STRING` (string): With `path`: the hash the bytes must have (`422 input_invalid` at sha256 when they do not).
247
- - `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first
253
+ - `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first answer with `Idempotent-Replayed: true`; another body is `409 idempotency_mismatch`; a retry while the first is in flight is `409 idempotency_in_progress`. Keys are scoped to the credential's account and the route.
248
254
  - `--size-bytes INTEGER` (integer, required): At most `limits.max_upload_bytes`.
249
- - `--body JSON|@FILE|-` (application/json, application/octet-stream, */*, required): The whole body: inline, from a file or from stdin. The flags above win over a JSON body's fields.
250
- - `--body-type TYPE` (string): The body's type, one of application/json, application/octet-stream, */*; any other than JSON is sent as given.
255
+ - `--body JSON|@FILE|-` (application/json, application/octet-stream, `*/*`, required): The whole body: inline, from a file or from stdin. The flags above win over a JSON body's fields.
256
+ - `--body-type TYPE` (string): The body's type, one of application/json, application/octet-stream, `*/*`; any other than JSON is sent as given.
251
257
 
252
258
  ### `agentrun files delete FILE_ID`
253
259
 
@@ -280,6 +286,16 @@ Route: `PUT /files/{file_id}`.
280
286
  - `--body JSON|@FILE|-` (application/octet-stream, required): The whole body: inline, from a file or from stdin. The flags above win over a JSON body's fields.
281
287
  - `--body-type TYPE` (string): The body's type, one of application/octet-stream; any other than JSON is sent as given.
282
288
 
289
+ ## harness
290
+
291
+ ### `agentrun harness install HARNESS`
292
+
293
+ Install a harness AgentRun runs only once its owner installs it (goose), then restart AgentRun.
294
+
295
+ Route: none, it runs on this machine.
296
+
297
+ - `--data DIR` (string, this CLI's own): the data directory of the AgentRun it is for (default ~/.agentrun, where npx @parcha/agentrun keeps it)
298
+
283
299
  ## home
284
300
 
285
301
  ### `agentrun home delete AGENT_ID PATH`
@@ -308,41 +324,16 @@ Write one file of the agent's home.
308
324
 
309
325
  Route: `PUT /agents/{agent_id}/home/files/{path}`. PATH keeps its slashes.
310
326
 
311
- - `--body JSON|@FILE|-` (application/octet-stream, */*, required): The whole body: inline, from a file or from stdin. The flags above win over a JSON body's fields.
312
- - `--body-type TYPE` (string): The body's type, one of application/octet-stream, */*; any other than JSON is sent as given.
327
+ - `--body JSON|@FILE|-` (application/octet-stream, `*/*`, required): The whole body: inline, from a file or from stdin. The flags above win over a JSON body's fields.
328
+ - `--body-type TYPE` (string): The body's type, one of application/octet-stream, `*/*`; any other than JSON is sent as given.
313
329
 
314
330
  ## learning
315
331
 
316
- ### `agentrun learning batch AGENT_ID BATCH_ID`
317
-
318
- A learning batch's progress: rows done, right or wrong, lessons, workflow revisions, cost, the path each run took.
319
-
320
- Route: `GET /agents/{agent_id}/learning/batches/{batch_id}`.
321
-
322
- ### `agentrun learning batch-cancel AGENT_ID BATCH_ID`
323
-
324
- Cancel a running learning batch.
325
-
326
- Route: `POST /agents/{agent_id}/learning/batches/{batch_id}/cancel`.
327
-
328
- ### `agentrun learning batch-start AGENT_ID`
329
-
330
- Learn from rows: run the agent on each in order, with learning on, and tell it the reference answer after each.
331
-
332
- Route: `POST /agents/{agent_id}/learning/batches`.
333
-
334
- - `--answer STRING` (string, required): The column holding the reference answer.
335
- - `--max-cost-usd NUMBER` (number, required): Caps what the batch's runs spend (job, look-back, review turn); grades are booked and shown, uncapped.
336
- - `--answer-field STRING` (string): A dotted path into a JSON answer to compare, such as result.code; absent: the whole answer.
337
- - `--effort STRING` (string): The runs' effort, as a run's.
338
- - `--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.
339
- - `--body-type TYPE` (string): The body's type, one of application/json; any other than JSON is sent as given.
340
-
341
- ### `agentrun learning batches AGENT_ID`
332
+ ### `agentrun learning corrections AGENT_ID`
342
333
 
343
- The agent's learning batches, latest first.
334
+ The agent's corrections.md on main, with its ETag.
344
335
 
345
- Route: `GET /agents/{agent_id}/learning/batches`.
336
+ Route: `GET /agents/{agent_id}/learning/corrections`.
346
337
 
347
338
  ### `agentrun learning cost AGENT_ID`
348
339
 
@@ -351,17 +342,11 @@ The agent's cost per run, run after run: its own cost, what learning added and t
351
342
  Route: `GET /agents/{agent_id}/learning/cost`.
352
343
 
353
344
  - `--limit INTEGER` (integer): The latest runs to answer, each keeping its number. At most 10000.
354
- - `--format json|csv` (string, one of these): `csv`: the runs as CSV, columns n, run_id, started_at, path, workflow, learned_revision, cost_usd, cost_upper_bound, learning_usd, total_usd.
355
-
356
- ### `agentrun learning evals AGENT_ID`
357
-
358
- The agent's eval records: the latest, and every one kept, newest first.
359
-
360
- Route: `GET /agents/{agent_id}/learning/evals`.
345
+ - `--format json|csv` (string, one of these): `csv`: the runs as CSV, columns n, run_id, started_at, path, workflow, digest, audited, cost_usd, cost_upper_bound, learning_usd, total_usd.
361
346
 
362
347
  ### `agentrun learning get AGENT_ID`
363
348
 
364
- What the agent has learned: its index, notes, log of changes and counts.
349
+ What the agent has learned: its corrections, workflow drafts, log of changes and counts.
365
350
 
366
351
  Route: `GET /agents/{agent_id}/learning`.
367
352
 
@@ -375,40 +360,12 @@ Route: `GET /agents/{agent_id}/learning/log`.
375
360
  - `--limit INTEGER` (integer): At most 200.
376
361
  - `--all` (boolean, this CLI's own): every page: follows next_cursor and prints one list, its next_cursor null; stops past 1000 pages, exit 1
377
362
 
378
- ### `agentrun learning notes AGENT_ID`
379
-
380
- A page of the agent's notes.
381
-
382
- Route: `GET /agents/{agent_id}/learning/notes`.
383
-
384
- - `--cursor STRING` (string): `next_cursor` from the previous page: opaque, read at the commit the first page was.
385
- - `--limit INTEGER` (integer): At most 200.
386
- - `--status active|superseded|retired|pending` (string, one of these): Only notes with this status.
387
- - `--all` (boolean, this CLI's own): every page: follows next_cursor and prints one list, its next_cursor null; stops past 1000 pages, exit 1
388
-
389
363
  ### `agentrun learning read AGENT_ID FILE`
390
364
 
391
- One note (or MEMORY.md, a skill's SKILL.md or a draft's file) on main, as text, with its ETag.
365
+ One file of a learned workflow on main (its workflow.json or README.md), as text, with its ETag.
392
366
 
393
367
  Route: `GET /agents/{agent_id}/learning/files/{file}`.
394
368
 
395
- ### `agentrun learning record-eval AGENT_ID`
396
-
397
- Record a held-out test of the agent: its counts and the cost a task, with learning and by hand.
398
-
399
- Route: `POST /agents/{agent_id}/learning/evals`.
400
-
401
- - `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first
402
- - `--name STRING` (string, required): What ran the test, one line: a bench's name and set, a script's.
403
- - `--n INTEGER` (integer, required): The held-out jobs the test counted: jobs the agent never learned from.
404
- - `--correct INTEGER` (integer, required): How many of the `n` jobs the agent with what it learned got right: 0 to `n`.
405
- - `--label-source STRING` (string): Where the right answers came from, one line; null (or absent) when not said.
406
- - `--cost-per-task-usd NUMBER` (number): The agent with what it learned: its mean cost a task, in USD; null (or absent) when not counted.
407
- - `--baseline-cost-per-task-usd NUMBER` (number): The agent by hand (learning off): its mean cost a task, in USD; null (or absent) when not counted.
408
- - `--learned-revision STRING` (string): The learning folder's commit the test ran from; null (or absent) when not said.
409
- - `--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.
410
- - `--body-type TYPE` (string): The body's type, one of application/json; any other than JSON is sent as given.
411
-
412
369
  ### `agentrun learning replay AGENT_ID NAME DIGEST REPLAY_ID`
413
370
 
414
371
  Read a replay's result: running, done or failed, its counts and its score (start one from the console's Learning tab).
@@ -417,11 +374,11 @@ Route: `GET /agents/{agent_id}/learning/workflows/{name}/revisions/{digest}/repl
417
374
 
418
375
  ### `agentrun learning retire AGENT_ID FILE`
419
376
 
420
- Retire a note, a skill or a workflow draft: out of every later run, kept in history.
377
+ Retire a workflow draft: out of every later run, kept in history.
421
378
 
422
379
  Route: `POST /agents/{agent_id}/learning/files/{file}/retire`. It prints the answer's bytes as they are.
423
380
 
424
- - `--if-match STRING` (string): The note's ETag, as a GET answered it: an edit or a retire lands only on that version, else 412.
381
+ - `--if-match STRING` (string): The file's ETag, as a GET answered it: the write lands only on that version, else 412.
425
382
 
426
383
  ### `agentrun learning workflow-revisions AGENT_ID NAME`
427
384
 
@@ -431,15 +388,14 @@ Route: `GET /agents/{agent_id}/learning/workflows/{name}/revisions`.
431
388
 
432
389
  - `--limit INTEGER` (integer): The latest revisions to answer. At most 50.
433
390
 
434
- ### `agentrun learning write AGENT_ID FILE`
391
+ ### `agentrun learning write-corrections AGENT_ID`
435
392
 
436
- Edit a note (If-Match) or create one (If-None-Match: *).
393
+ Replace the agent's corrections.md (If-Match).
437
394
 
438
- Route: `PUT /agents/{agent_id}/learning/files/{file}`. It prints the answer's bytes as they are.
395
+ Route: `PUT /agents/{agent_id}/learning/corrections`.
439
396
 
440
- - `--if-match STRING` (string): The note's ETag, as a GET answered it: an edit or a retire lands only on that version, else 412.
441
- - `--if-none-match STRING` (string): `*`: create the note, only if the name is not taken, else 412.
442
- - `--text STRING` (string, required): The note's whole text, front matter included.
397
+ - `--if-match STRING` (string, required): The file's ETag, as a GET answered it: the write lands only on that version, else 412.
398
+ - `--text STRING` (string, required): corrections.md's whole text.
443
399
  - `--body JSON|@FILE|-` (text/markdown, text/plain, application/json, required): The whole body: inline, from a file or from stdin. The flags above win over a JSON body's fields.
444
400
  - `--body-type TYPE` (string): The body's type, one of text/markdown, text/plain, application/json; any other than JSON is sent as given.
445
401
 
@@ -517,8 +473,8 @@ Fire a Composio trigger: a request it checks, no token.
517
473
 
518
474
  Route: `POST /hooks/composio/{hook}`.
519
475
 
520
- - `--body JSON|@FILE|-` (*/*, required): The whole body: inline, from a file or from stdin. The flags above win over a JSON body's fields.
521
- - `--body-type TYPE` (string): The body's type, one of */*; any other than JSON is sent as given.
476
+ - `--body JSON|@FILE|-` (`*/*`, required): The whole body: inline, from a file or from stdin. The flags above win over a JSON body's fields.
477
+ - `--body-type TYPE` (string): The body's type, one of `*/*`; any other than JSON is sent as given.
522
478
 
523
479
  ### `agentrun local rotate-composio-secret NAME`
524
480
 
@@ -666,13 +622,14 @@ Start a run of an agent another system owns, given inline.
666
622
 
667
623
  Route: `POST /runs`.
668
624
 
669
- - `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first
625
+ - `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first answer with `Idempotent-Replayed: true`; another body is `409 idempotency_mismatch`; a retry while the first is in flight is `409 idempotency_in_progress`. Keys are scoped to the credential's account and the route.
670
626
  - `--note STRING` (string): What the version changes, kept with its revision by the version's first run (GET /agents/{agent_id}/revisions); not part of its definition.
671
627
  - `--effort low|medium|high` (string, one of these): How hard a run works. It sets the model's thinking level, and adds a short note on how to work right after the agent's instructions, on every harness: low answers directly, medium plans briefly and checks once, high plans each part, fills the gaps and reviews. A run started with none thinks at its agent revision's own thinking level, else the host's default, and gets no note.
672
628
  - `--max-cost-usd NUMBER` (number): This run's cap, for every turn of it. Default the definition's `max_cost_usd`, else the effort default.
673
629
  - `--quote-id STRING` (string): Run at a quote's terms. A different `effort` or `max_cost_usd` than the quote's is `409 quote_invalid`.
630
+ - `--model-key STRING` (string): The run's own model key: a key for the model gateway at AGENT_MODEL_BASE_URL, such as a LiteLLM virtual key minted for this run, which every model request tied to the run carries in place of the server's own key (its turns, its subagents, its learned workflows' nodes, a workflow's model nodes, its end-of-run compile turn). AgentRun never mints, lists or revokes it. Sealed into the run's launch bound to the gateway's origin, read at each claim (a reclaim after a crash among them), erased by the write that ends the run's turn; never in its saved body, its timeline, its view, a log or an Idempotency-Key's fingerprint (a retry with a new key answers the first request's run, its first key kept). The harness, its tools and its sandbox never see it. 422 at `model_key` when the run's model never goes to that gateway (no AGENT_MODEL_BASE_URL here, a native run, or a model routed elsewhere). Absent, the run spends on the server's key for its route; where the server holds none (no AGENT_MODEL_API_KEY, none saved in Settings), a start without it is 422 `model_key_required`, never a failure at its first model call.
674
631
  - `--workflow-first` (boolean): Whether a run of an agent that learns may start on one of its learned workflows. On (absent or true), a run whose input fits exactly one active learned workflow (its input schema has a required field, and the run's input passes it) runs that workflow first, with no turn of the agent's model: its answer is the run's answer, and if it hands the job back (it escalates, a step fails), the same run goes on with the agent, given what the workflow found. The run keeps which path it took: `workflow`, `handed_back` or `agent`. false: the agent takes the run from its first turn.
675
- - `--learning use` (string, one of these): `use`: the run starts from what its agent learned (its notes, learned skills and learned workflows, as a run that learns is given them), whatever its agent's `learning` says, and keeps nothing: no end-of-run turn, no proposal, no grade and no merge, at its end or after a follow-up. Its `learning` reads `seeded` while it runs, then `dropped` with reason `use`. So many runs of one agent read one learned state, frozen (a held-out evaluation). On a server whose learning is off it is given nothing, as every run there. Absent: the agent's own (`learning: true` learns). 422 not_an_option for anything else.
632
+ - `--learning use` (string, one of these): `use`: the run starts from what its agent learned (its corrections and learned workflows, as a run that learns is given them), whatever its agent's `learning` says, and keeps nothing: no compile turn, no correction and no merge, at its end or after a follow-up. Its `learning` reads `seeded` while it runs, then `dropped` with reason `use`. So many runs of one agent read one learned state, frozen (a held-out evaluation). On a server whose learning is off it is given nothing, as every run there. Absent: the agent's own (`learning: true` learns). 422 not_an_option for anything else.
676
633
  - `--repo STRING` (string): The GitHub repository (`owner/name`) this run reaches: the one its GitHub App token is made for, so its github MCP calls are scoped to it. It must be one the agent is bound to (a repository its GitHub triggers' `accept` names on `/repository/full_name`); another is 422 at `repo` in words naming the repositories it is bound to. Absent: the agent's repository when it is bound to exactly one and the first message names none; otherwise the repository a `https://github.com/<owner>/<repo>` URL in the first message names. A run a trigger starts takes its repository from its event, and `repo` there is 422.
677
634
  - `--hold` (boolean): true: the run claims its computer and holds it for its owner. Its agent waits until POST /runs/{run_id}/start; meanwhile POST /runs/{run_id}/computer/call sends the computer protocol calls, to set a task up. After the agent's end the run keeps the computer, for the owner's calls (to check what the agent left), until POST /runs/{run_id}/computer/release; then it ends as its agent did. A stop (POST /runs/{run_id}/stop) ends the agent and keeps the computer the same way, and the run ends stopped at the release; a cancel ends the run at once and lets the computer go. Each wait lets the computer go after `hold_minutes` with no call from the owner: before the start, the run then ends cancelled. The run read's `computer.held` says where the hold is. Only for an agent whose computer is a sandbox, a desktop or a phone, never a workflow (422 `hold` not_an_option otherwise). A run that loses its runner, or whose harness restarts after a fault, loses the computer it held: it fails, and `computer.held.why` is `lost`.
678
635
  - `--hold-minutes INTEGER` (integer): With `hold: true`: how long the held computer waits with no call from its owner, before the start and after the agent's end. Absent: 30. Above 120, or without hold, is 422.
@@ -752,8 +709,9 @@ Send the run a message.
752
709
 
753
710
  Route: `POST /runs/{run_id}/messages`.
754
711
 
755
- - `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first
712
+ - `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first answer with `Idempotent-Replayed: true`; another body is `409 idempotency_mismatch`; a retry while the first is in flight is `409 idempotency_in_progress`. Keys are scoped to the credential's account and the route.
756
713
  - `--content STRING` (string, required): At most `limits.max_message_chars`. Not only whitespace.
714
+ - `--model-key STRING` (string): The run's own model key: a key for the model gateway at AGENT_MODEL_BASE_URL, such as a LiteLLM virtual key minted for this run, which every model request tied to the run carries in place of the server's own key (its turns, its subagents, its learned workflows' nodes, a workflow's model nodes, its end-of-run compile turn). AgentRun never mints, lists or revokes it. Sealed into the run's launch bound to the gateway's origin, read at each claim (a reclaim after a crash among them), erased by the write that ends the run's turn; never in its saved body, its timeline, its view, a log or an Idempotency-Key's fingerprint (a retry with a new key answers the first request's run, its first key kept). The harness, its tools and its sandbox never see it. 422 at `model_key` when the run's model never goes to that gateway (no AGENT_MODEL_BASE_URL here, a native run, or a model routed elsewhere). Absent, the run spends on the server's key for its route; where the server holds none (no AGENT_MODEL_API_KEY, none saved in Settings), a start without it is 422 `model_key_required`, never a failure at its first model call. On a message it replaces the run's key from the run's next model request on, a turn still going included, and it is the first key of a run that started on the server's (mint one per turn); a message without one keeps the key the run holds, which is none once its last turn ended: then, where the server holds no key for the run's model, the message is 422 `model_key_required` and nothing is written.
757
715
  - `--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.
758
716
  - `--body-type TYPE` (string): The body's type, one of application/json; any other than JSON is sent as given.
759
717
 
@@ -794,12 +752,13 @@ Start a run.
794
752
 
795
753
  Route: `POST /agents/{agent_id}/runs`.
796
754
 
797
- - `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first
755
+ - `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first answer with `Idempotent-Replayed: true`; another body is `409 idempotency_mismatch`; a retry while the first is in flight is `409 idempotency_in_progress`. Keys are scoped to the credential's account and the route.
798
756
  - `--effort low|medium|high` (string, one of these): How hard a run works. It sets the model's thinking level, and adds a short note on how to work right after the agent's instructions, on every harness: low answers directly, medium plans briefly and checks once, high plans each part, fills the gaps and reviews. A run started with none thinks at its agent revision's own thinking level, else the host's default, and gets no note.
799
757
  - `--max-cost-usd NUMBER` (number): This run's cap, for every turn of it. Default the definition's `max_cost_usd`, else the effort default.
800
758
  - `--quote-id STRING` (string): Run at a quote's terms. A different `effort` or `max_cost_usd` than the quote's is `409 quote_invalid`.
759
+ - `--model-key STRING` (string): The run's own model key: a key for the model gateway at AGENT_MODEL_BASE_URL, such as a LiteLLM virtual key minted for this run, which every model request tied to the run carries in place of the server's own key (its turns, its subagents, its learned workflows' nodes, a workflow's model nodes, its end-of-run compile turn). AgentRun never mints, lists or revokes it. Sealed into the run's launch bound to the gateway's origin, read at each claim (a reclaim after a crash among them), erased by the write that ends the run's turn; never in its saved body, its timeline, its view, a log or an Idempotency-Key's fingerprint (a retry with a new key answers the first request's run, its first key kept). The harness, its tools and its sandbox never see it. 422 at `model_key` when the run's model never goes to that gateway (no AGENT_MODEL_BASE_URL here, a native run, or a model routed elsewhere). Absent, the run spends on the server's key for its route; where the server holds none (no AGENT_MODEL_API_KEY, none saved in Settings), a start without it is 422 `model_key_required`, never a failure at its first model call.
801
760
  - `--workflow-first` (boolean): Whether a run of an agent that learns may start on one of its learned workflows. On (absent or true), a run whose input fits exactly one active learned workflow (its input schema has a required field, and the run's input passes it) runs that workflow first, with no turn of the agent's model: its answer is the run's answer, and if it hands the job back (it escalates, a step fails), the same run goes on with the agent, given what the workflow found. The run keeps which path it took: `workflow`, `handed_back` or `agent`. false: the agent takes the run from its first turn.
802
- - `--learning use` (string, one of these): `use`: the run starts from what its agent learned (its notes, learned skills and learned workflows, as a run that learns is given them), whatever its agent's `learning` says, and keeps nothing: no end-of-run turn, no proposal, no grade and no merge, at its end or after a follow-up. Its `learning` reads `seeded` while it runs, then `dropped` with reason `use`. So many runs of one agent read one learned state, frozen (a held-out evaluation). On a server whose learning is off it is given nothing, as every run there. Absent: the agent's own (`learning: true` learns). 422 not_an_option for anything else.
761
+ - `--learning use` (string, one of these): `use`: the run starts from what its agent learned (its corrections and learned workflows, as a run that learns is given them), whatever its agent's `learning` says, and keeps nothing: no compile turn, no correction and no merge, at its end or after a follow-up. Its `learning` reads `seeded` while it runs, then `dropped` with reason `use`. So many runs of one agent read one learned state, frozen (a held-out evaluation). On a server whose learning is off it is given nothing, as every run there. Absent: the agent's own (`learning: true` learns). 422 not_an_option for anything else.
803
762
  - `--repo STRING` (string): The GitHub repository (`owner/name`) this run reaches: the one its GitHub App token is made for, so its github MCP calls are scoped to it. It must be one the agent is bound to (a repository its GitHub triggers' `accept` names on `/repository/full_name`); another is 422 at `repo` in words naming the repositories it is bound to. Absent: the agent's repository when it is bound to exactly one and the first message names none; otherwise the repository a `https://github.com/<owner>/<repo>` URL in the first message names. A run a trigger starts takes its repository from its event, and `repo` there is 422.
804
763
  - `--hold` (boolean): true: the run claims its computer and holds it for its owner. Its agent waits until POST /runs/{run_id}/start; meanwhile POST /runs/{run_id}/computer/call sends the computer protocol calls, to set a task up. After the agent's end the run keeps the computer, for the owner's calls (to check what the agent left), until POST /runs/{run_id}/computer/release; then it ends as its agent did. A stop (POST /runs/{run_id}/stop) ends the agent and keeps the computer the same way, and the run ends stopped at the release; a cancel ends the run at once and lets the computer go. Each wait lets the computer go after `hold_minutes` with no call from the owner: before the start, the run then ends cancelled. The run read's `computer.held` says where the hold is. Only for an agent whose computer is a sandbox, a desktop or a phone, never a workflow (422 `hold` not_an_option otherwise). A run that loses its runner, or whose harness restarts after a fault, loses the computer it held: it fails, and `computer.held.why` is `lost`.
805
764
  - `--hold-minutes INTEGER` (integer): With `hold: true`: how long the held computer waits with no call from its owner, before the start and after the agent's end. Absent: 30. Above 120, or without hold, is 422.
@@ -845,6 +804,12 @@ Route: `GET /runs/{run_id}/timeline`.
845
804
  - `--last-event-id STRING` (string): SSE reconnect. Same meaning as `after`, and wins over it.
846
805
  - `--follow` (boolean, this CLI's own): the timeline as it changes, one page per line (NDJSON), until the run ends; resumes a dropped connection
847
806
 
807
+ ### `agentrun runs trace RUN_ID`
808
+
809
+ A run's trace: each model request and tool call, with its time, tokens and cost.
810
+
811
+ Route: `GET /runs/{run_id}/trace`.
812
+
848
813
  ### `agentrun runs unarchive RUN_ID`
849
814
 
850
815
  Show the archived run in the lists again.
@@ -940,6 +905,66 @@ This document.
940
905
 
941
906
  Route: `GET /openapi.json`.
942
907
 
908
+ ## service
909
+
910
+ ### `agentrun service install`
911
+
912
+ Install AgentRun as a service of this user and start it: it keeps running after the terminal closes and starts again at login.
913
+
914
+ Route: none, it runs on this machine.
915
+
916
+ - `--port N` (string, this CLI's own): the port to listen on (default: the first free from 7340; 7340 with --tailscale)
917
+ - `--data DIR` (string, this CLI's own): the data directory (default ~/.agentrun)
918
+ - `--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
919
+ - `--env KEY=VALUE` (string, this CLI's own): a local model's variable for the server (AGENT_MODEL_BASE_URL, AGENT_MODEL_GATEWAY_IDS, AGENT_MODEL, AGENT_MODEL_PRICE), kept until KEY= removes it; repeatable
920
+
921
+ ### `agentrun service logs`
922
+
923
+ Print the service's log, ~/.agentrun/logs/agentrun.log.
924
+
925
+ Route: none, it runs on this machine.
926
+
927
+ - `--lines N` (string, this CLI's own): how many of its last lines (default 50)
928
+ - `--follow` (boolean, this CLI's own): and keep printing what comes (-f)
929
+
930
+ ### `agentrun service restart`
931
+
932
+ Restart the service and wait until it answers.
933
+
934
+ Route: none, it runs on this machine.
935
+
936
+ ### `agentrun service start`
937
+
938
+ Start the service and wait until it answers.
939
+
940
+ Route: none, it runs on this machine.
941
+
942
+ ### `agentrun service status`
943
+
944
+ Say whether the service is installed and running, the console's address and its health (exit 0 healthy, 1 not, 3 not installed).
945
+
946
+ Route: none, it runs on this machine.
947
+
948
+ ### `agentrun service stop`
949
+
950
+ Stop the service (it starts again at the next login).
951
+
952
+ Route: none, it runs on this machine.
953
+
954
+ ### `agentrun service uninstall`
955
+
956
+ Stop the service and remove it, and the tailscale serve entry --tailscale added; the data directory stays.
957
+
958
+ Route: none, it runs on this machine.
959
+
960
+ ### `agentrun service upgrade`
961
+
962
+ Install another version with the installer, then restart the service on it.
963
+
964
+ Route: none, it runs on this machine.
965
+
966
+ - `--version V` (string, this CLI's own): the version or npm tag (default: latest)
967
+
943
968
  ## skill
944
969
 
945
970
  ### `agentrun skill install`
@@ -964,6 +989,14 @@ Route: `GET /stats`.
964
989
  - `--to STRING` (string): Runs started before this RFC 3339 date-time, to the millisecond (a finer fraction is a 400). Default no bound.
965
990
  - `--agent STRING` (string): One agent's runs.
966
991
 
992
+ ## stop
993
+
994
+ ### `agentrun stop`
995
+
996
+ Stop the AgentRun the installer started in the background, where there is no service manager (exit 0 stopped, 3 none running).
997
+
998
+ Route: none, it runs on this machine.
999
+
967
1000
  ## template
968
1001
 
969
1002
  ### `agentrun template apply TEMPLATE`
@@ -972,7 +1005,8 @@ Apply a template package: make its agent, with its skills, then its triggers.
972
1005
 
973
1006
  Route: `POST /templates/{template}/apply`.
974
1007
 
975
- - `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first
1008
+ - `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first answer with `Idempotent-Replayed: true`; another body is `409 idempotency_mismatch`; a retry while the first is in flight is `409 idempotency_in_progress`. Keys are scoped to the credential's account and the route.
1009
+ - `--agent-id STRING` (string): An agent this package made here (GET /agents `template.id` is the package's id): the apply writes a new revision of it in place of making another, answered 200 with the same id. Its runs and its learning (corrections and workflows) stay. The parameters and grants are checked as a fresh apply checks them. Its triggers are reconciled by name: one of a name it has is changed in place (its id, a feed trigger's seen items, a webhook trigger's secret and whether it is on are kept; a `catchup_window_s` or `max_active_runs` the package leaves out goes back to its default, as a fresh apply makes it; a source the package leaves as it was is not rewritten, so a schedule keeps its next time, and an `every_s` one with no `start_at` the grid its first apply set), a new name is made, and one this package's apply made or kept that the package no longer lists is removed (a feed trigger whose feeds are left empty is not listed). Which triggers are the package's is kept on each trigger, never in an API body: one the owner made, one moved to the agent from another (or away and back), and one made before this was kept are never removed. A Composio trigger it removes (the package dropped it, or makes it again) goes at Composio first: one whose instance Composio does not delete is kept here as it was (on or off, the package's, its config sealed), and the next apply removes it; a dropped one is said in `warnings` under `triggers`, naming it and what is left at Composio. Such an unmarked trigger with a package trigger's name is adopted only when it can be changed in place (the same kind, and for a Composio trigger the same server, event and config), and is the package's from then on; one that would have to be made again, or one another package made, is 409 name_taken under `triggers.<i>.name` before anything is written: rename or delete it, then apply again. A trigger moved to another agent while the update runs is neither changed nor removed; its name is made anew. A Composio trigger it keeps keeps its sealed config when the package sends the same values; one whose server, event or config the package changes (another key too) is made again, as one whose source kind changed is: the old trigger and its Composio instance are removed first, and the new one is off where the owner turned the old one off. When Composio does not delete the old instance, the new one is not made, and the apply is 424 upstream_failed with the new revision standing and the old trigger kept as it was (remove the instance at Composio, or wait, and apply again: the old trigger's off carries to the new one). What the package owns and its new version leaves out (an input or answer schema, a checkout, a default cap, learning) is gone from the agent; what the host set (its harness, computer, sdk and native references) is kept. Updates of one agent run one after the other on a server, and each writes only onto the revision it read: one whose read went stale meanwhile (an edit, or an update elsewhere) is 412 precondition_failed, with nothing changed. An agent made otherwise, or from another package, is 422 under `agent_id`, saying which; an unknown id is 404; an archived agent is 409 agent_archived.
976
1010
  - `--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.
977
1011
  - `--body-type TYPE` (string): The body's type, one of application/json; any other than JSON is sent as given.
978
1012
 
@@ -1061,7 +1095,7 @@ Make a trigger: a schedule or a signed webhook that starts a capped run of an ag
1061
1095
 
1062
1096
  Route: `POST /triggers`.
1063
1097
 
1064
- - `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first
1098
+ - `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first answer with `Idempotent-Replayed: true`; another body is `409 idempotency_mismatch`; a retry while the first is in flight is `409 idempotency_in_progress`. Keys are scoped to the credential's account and the route.
1065
1099
  - `--name STRING` (string): Default the trigger's id.
1066
1100
  - `--enabled` (boolean): Off, it fires nothing; on again, it goes on from now: the time it was off is skipped, never caught up.
1067
1101
  - `--catchup-window-s INTEGER` (integer)