@parcha/agentrun 0.4.12 → 0.4.14

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/lib/service.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // unit on Linux; never a system service, never sudo. The service runs the installer's command (~/.agentrun/bin/agentrun,
4
4
  // install.sh), which brings its own Node, with --no-open and the interactive launcher's rules for the data directory and
5
5
  // port, and writes to ~/.agentrun/logs/agentrun.log. With --tailscale it is also served on the person's tailnet
6
- // (tailscale.mjs). `agentrun stop` stops the AgentRun the installer starts in the
6
+ // (tailscale.mjs); with --env, on a local model (MODEL_ENV). `agentrun stop` stops the AgentRun the installer starts in the
7
7
  // background where there is no service manager (a container): its pid is in ~/.agentrun/agentrun.pid.
8
8
  import { spawnSync } from "node:child_process";
9
9
  import { closeSync, existsSync, fstatSync, mkdirSync, openSync, readFileSync, readSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
@@ -63,6 +63,10 @@ ${vars}
63
63
  /** The command and arguments a plist made by plistText runs. */
64
64
  export const plistArgs = (text) => [...(/<key>ProgramArguments<\/key>\s*<array>([\s\S]*?)<\/array>/.exec(text)?.[1] ?? "").matchAll(/<string>([^<]*)<\/string>/g)].map((match) => unxml(match[1]));
65
65
 
66
+ /** The variables a plist made by plistText sets. */
67
+ export const plistEnv = (text) =>
68
+ Object.fromEntries([...(/<key>EnvironmentVariables<\/key>\s*<dict>([\s\S]*?)<\/dict>/.exec(text)?.[1] ?? "").matchAll(/<key>([^<]*)<\/key>\s*<string>([^<]*)<\/string>/g)].map((match) => [unxml(match[1]), unxml(match[2])]));
69
+
66
70
  /** One word of a systemd command line or setting: quoted when it needs to be, its specifiers (%) and variables ($)
67
71
  * escaped, as systemd.syntax(7) reads them. */
68
72
  export const systemdWord = (word) => {
@@ -102,6 +106,14 @@ WantedBy=default.target
102
106
  /** The command and arguments a unit made by unitText runs. */
103
107
  export const unitArgs = (text) => systemdWords(/^ExecStart=(.*)$/m.exec(text)?.[1] ?? "");
104
108
 
109
+ /** The variables a unit made by unitText sets. */
110
+ export const unitEnv = (text) =>
111
+ Object.fromEntries([...text.matchAll(/^Environment=(.*)$/gm)].map((match) => systemdWords(match[1])[0] ?? "").map((pair) => [pair.slice(0, pair.indexOf("=")), pair.slice(pair.indexOf("=") + 1)]));
112
+
113
+ /** The variables `service install --env` sets: a local model's (AGENT_MODEL_BASE_URL in front of a gateway such as
114
+ * Ollama's). Never a key: a unit file is plain text, and keys are sealed in the console. */
115
+ export const MODEL_ENV = ["AGENT_MODEL_BASE_URL", "AGENT_MODEL_GATEWAY_IDS", "AGENT_MODEL", "AGENT_MODEL_PRICE"];
116
+
105
117
  const sleep = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
106
118
 
107
119
  /** The service manager of this platform, driven through `exec` (spawnSync's shape). */
@@ -133,6 +145,7 @@ export function managerOf({ platform, home, uid, user, env, exec, fail }) {
133
145
  name: `launchd ${target}`,
134
146
  text: plistText,
135
147
  args: plistArgs,
148
+ env: plistEnv,
136
149
  available: () => (run("launchctl", ["print", domain], { ok: true }).status === 0 ? undefined : `this user has no launchd session (${domain}): a login over ssh has none; log in at the Mac`),
137
150
  install() {
138
151
  if (loaded()) run("launchctl", ["bootout", target], { ok: true });
@@ -160,6 +173,7 @@ export function managerOf({ platform, home, uid, user, env, exec, fail }) {
160
173
  name: `systemd --user ${UNIT}`,
161
174
  text: unitText,
162
175
  args: unitArgs,
176
+ env: unitEnv,
163
177
  available() {
164
178
  const result = run("systemctl", ["--user", "show-environment"], { ok: true });
165
179
  if (result.error?.code === "ENOENT") return "this machine has no systemd";
@@ -292,15 +306,29 @@ export function serviceOf({ platform = process.platform, home = homedir(), uid =
292
306
  }
293
307
 
294
308
  return {
295
- async install({ data, port, tailscale }) {
309
+ async install({ data, port, tailscale, env: sets = [] }) {
296
310
  if (port !== undefined && !/^\d+$/.test(port)) throw fail(2, `--port takes a port number, not ${port}.`);
311
+ const changes = sets.map((pair) => {
312
+ const at = pair.indexOf("=");
313
+ if (at < 1) throw fail(2, `--env takes KEY=VALUE, not ${pair}.`);
314
+ const key = pair.slice(0, at);
315
+ if (!MODEL_ENV.includes(key)) throw fail(2, `--env takes ${MODEL_ENV.slice(0, -1).join(", ")} or ${MODEL_ENV.at(-1)}, not ${key}: a key goes in the console (Settings → Model keys), never in a service file.`);
316
+ if (/[\0-\x1f]/.test(pair)) throw fail(2, `${key}'s value has a line break or another control character.`);
317
+ return [key, pair.slice(at + 1)];
318
+ });
297
319
  need();
298
320
  if (!existsSync(program)) throw fail(1, `AgentRun's service runs the installed command, ${program}, and it is not there. Install it first: ${INSTALL_COMMAND}`);
299
321
  const why = manager.available();
300
322
  if (why !== undefined) throw fail(1, `AgentRun can't run as a service here: ${why}. Start it in a terminal with ${program}.`);
301
- // --tailscale or --no-tailscale on an installed service changes its sharing only: its data folder and port stay
323
+ // An installed service keeps its local model's variables; --env KEY=VALUE sets one, KEY= removes it.
324
+ const model = installed() ? Object.fromEntries(Object.entries(manager.env(readFileSync(manager.file, "utf8"))).filter(([key]) => MODEL_ENV.includes(key))) : {};
325
+ for (const [key, value] of changes) {
326
+ if (value === "") delete model[key];
327
+ else model[key] = value;
328
+ }
329
+ // --tailscale, --no-tailscale or --env on an installed service changes that only: its data folder and port stay
302
330
  // unless named (the installer passes the flag alone).
303
- if (tailscale !== undefined && installed()) {
331
+ if ((tailscale !== undefined || changes.length > 0) && installed()) {
304
332
  const now = argsNow();
305
333
  const option = (name) => (now.includes(name) ? now[now.indexOf(name) + 1] : undefined);
306
334
  data ??= option("--data");
@@ -317,7 +345,7 @@ export function serviceOf({ platform = process.platform, home = homedir(), uid =
317
345
  // The server knows the address people open: its host check takes the name, and its setup takes the printed code.
318
346
  const at = share ? tailnet.address(targetOf(served)) : undefined;
319
347
  const args = ["--no-open", ...(data !== undefined ? ["--data", resolve(data)] : []), ...(served !== undefined ? ["--port", served] : [])];
320
- const vars = at ? { AGENTRUN_PUBLIC_URL: at.url, AGENTRUN_TRUSTED_PROXIES: "loopback" } : {};
348
+ const vars = { ...model, ...(at ? { AGENTRUN_PUBLIC_URL: at.url, AGENTRUN_TRUSTED_PROXIES: "loopback" } : {}) };
321
349
  mkdirSync(join(root, "logs"), { recursive: true, mode: 0o700 });
322
350
  mkdirSync(join(manager.file, ".."), { recursive: true });
323
351
  writeFileSync(manager.file, manager.text({ program, args, path: env.PATH ?? "/usr/bin:/bin", log, env: vars }));
@@ -461,7 +489,7 @@ export function serviceOf({ platform = process.platform, home = homedir(), uid =
461
489
  }
462
490
 
463
491
  const VERBS = [
464
- ["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"]], { port: { type: "string" }, tailscale: { type: "boolean" } }],
492
+ ["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 (${MODEL_ENV.join(", ")}), kept until KEY= removes it; repeatable`]], { port: { type: "string" }, tailscale: { type: "boolean" }, env: { type: "string", multiple: true } }],
465
493
  ["status", "Say whether the service is installed and running, the console's address and its health (exit 0 healthy, 1 not, 3 not installed)", [], {}],
466
494
  ["start", "Start the service and wait until it answers", [], {}],
467
495
  ["stop", "Stop the service (it starts again at the next login)", [], {}],
package/lib/start.mjs CHANGED
@@ -248,7 +248,7 @@ export const serverArgs = (argv) => (argv.includes("--no-open") ? argv.filter((a
248
248
 
249
249
  /** The server's own commands (its CLI's first word), which this command runs on its store: every other first word is
250
250
  * the CLI's, which names a command it has or says it has none. */
251
- export const SERVER_COMMANDS = ["eval-template", "import", "native", "remote-bridge", "reset-password", "runner", "validate-template"];
251
+ export const SERVER_COMMANDS = ["eval-template", "import", "install-harness", "native", "remote-bridge", "reset-password", "runner", "validate-template"];
252
252
 
253
253
  /** How many of the server's refusals and ignored deliveries a start says, each route and reason once, before one line
254
254
  * that says the rest are not: under this command the server's log goes nowhere else (its stdout is read here and dropped). */
package/lib/tailscale.mjs CHANGED
@@ -4,10 +4,12 @@
4
4
  // what it lacks is said as steps, and AgentRun runs on this machine meanwhile. The entry added is recorded in
5
5
  // ~/.agentrun/tailscale.json, so `off` removes that entry and no other serve setting.
6
6
  //
7
- // Run as a script, it is the installer's step where AgentRun runs in the background (no service manager):
8
- // node tailscale.mjs address PORT AGAIN prints the https address to start the server with, or nothing
9
- // node tailscale.mjs serve PORT AGAIN URL serves the loopback PORT at URL, the address printed, and says where
10
- // node tailscale.mjs off removes the entry it added
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
11
13
  import { spawnSync } from "node:child_process";
12
14
  import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
13
15
  import { homedir } from "node:os";
@@ -24,8 +26,9 @@ const DENIED = /Access denied/i;
24
26
  const LOOPBACK = "127.0.0.1"; // key-gate: loopback-rule serve proxies to the server on this machine
25
27
  export const targetOf = (port) => `http://${LOOPBACK}:${port}`;
26
28
 
27
- /** Tailscale on this machine, driven through `exec` (spawnSync's shape); `again` is the command that runs this step again. */
28
- export function tailnetOf({ platform = process.platform, root = join(homedir(), ".agentrun"), uid = process.getuid?.(), exec, say, fail, again }) {
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") }) {
29
32
  // The Mac app's CLI is in the app, and on PATH only when someone put it there.
30
33
  let bin;
31
34
  const run = (args, options) => {
@@ -116,7 +119,7 @@ export function tailnetOf({ platform = process.platform, root = join(homedir(),
116
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).`);
117
120
  writeFileSync(state, `${JSON.stringify({ url: `https://${host}/`, proxy: target })}\n`, { mode: 0o600 });
118
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.`);
119
- say(`It asks for a setup code on the first visit: the newest "Set up this server" line in ${join(root, "logs", "agentrun.log")} has the link.`);
122
+ say(`It asks for a setup code on the first visit: the newest "Set up this server" line in ${log} has the link.`);
120
123
  say(PRICE);
121
124
  return true;
122
125
  },
@@ -147,13 +150,13 @@ export function tailnetOf({ platform = process.platform, root = join(homedir(),
147
150
  };
148
151
  }
149
152
 
150
- /** The installer's step for an AgentRun in the background. Exit 1 on a refusal, said on stderr. */
151
- function script([verb, port, again, url]) {
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]) {
152
155
  const fail = (code, message) => Object.assign(new Error(message), { code });
153
156
  // `address` prints the address alone on stdout, for the installer to read; what it says goes to stderr.
154
157
  const say = (line) => (verb === "address" ? process.stderr : process.stdout).write(`${line}\n`);
155
158
  const exec = (command, args, options = {}) => spawnSync(command, args, { encoding: "utf8", ...options });
156
- const tailnet = tailnetOf({ exec, say, fail, again });
159
+ const tailnet = tailnetOf({ exec, say, fail, again, ...(log ? { log } : {}) });
157
160
  try {
158
161
  if (verb === "address") {
159
162
  const at = tailnet.address(targetOf(port));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun",
3
- "version": "0.4.12",
3
+ "version": "0.4.14",
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.44"
20
+ "@parcha/agentrun-serve": "0.1.0-beta.46"
21
21
  },
22
22
  "scripts": {
23
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,18 +131,19 @@ 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
148
149
  - `agentrun service`: install, logs, restart, start, status, stop, uninstall, upgrade
@@ -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.
332
+ ### `agentrun learning corrections AGENT_ID`
340
333
 
341
- ### `agentrun learning batches AGENT_ID`
334
+ The agent's corrections.md on main, with its ETag.
342
335
 
343
- The agent's learning batches, latest first.
344
-
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,14 +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`.
674
- - `--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 look-back). 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.
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.
675
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.
676
- - `--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.
677
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.
678
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`.
679
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.
@@ -753,9 +709,9 @@ Send the run a message.
753
709
 
754
710
  Route: `POST /runs/{run_id}/messages`.
755
711
 
756
- - `--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.
757
713
  - `--content STRING` (string, required): At most `limits.max_message_chars`. Not only whitespace.
758
- - `--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 look-back). 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.
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.
759
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.
760
716
  - `--body-type TYPE` (string): The body's type, one of application/json; any other than JSON is sent as given.
761
717
 
@@ -796,13 +752,13 @@ Start a run.
796
752
 
797
753
  Route: `POST /agents/{agent_id}/runs`.
798
754
 
799
- - `--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.
800
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.
801
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.
802
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`.
803
- - `--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 look-back). 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.
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.
804
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.
805
- - `--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.
806
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.
807
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`.
808
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.
@@ -848,6 +804,12 @@ Route: `GET /runs/{run_id}/timeline`.
848
804
  - `--last-event-id STRING` (string): SSE reconnect. Same meaning as `after`, and wins over it.
849
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
850
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
+
851
813
  ### `agentrun runs unarchive RUN_ID`
852
814
 
853
815
  Show the archived run in the lists again.
@@ -954,6 +916,7 @@ Route: none, it runs on this machine.
954
916
  - `--port N` (string, this CLI's own): the port to listen on (default: the first free from 7340; 7340 with --tailscale)
955
917
  - `--data DIR` (string, this CLI's own): the data directory (default ~/.agentrun)
956
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
957
920
 
958
921
  ### `agentrun service logs`
959
922
 
@@ -1042,7 +1005,8 @@ Apply a template package: make its agent, with its skills, then its triggers.
1042
1005
 
1043
1006
  Route: `POST /templates/{template}/apply`.
1044
1007
 
1045
- - `--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.
1046
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.
1047
1011
  - `--body-type TYPE` (string): The body's type, one of application/json; any other than JSON is sent as given.
1048
1012
 
@@ -1131,7 +1095,7 @@ Make a trigger: a schedule or a signed webhook that starts a capped run of an ag
1131
1095
 
1132
1096
  Route: `POST /triggers`.
1133
1097
 
1134
- - `--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.
1135
1099
  - `--name STRING` (string): Default the trigger's id.
1136
1100
  - `--enabled` (boolean): Off, it fires nothing; on again, it goes on from now: the time it was off is skipped, never caught up.
1137
1101
  - `--catchup-window-s INTEGER` (integer)