@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.
package/lib/cli.mjs CHANGED
@@ -2,7 +2,10 @@
2
2
  // OpenAPI document, read from the generated table (commands.generated.mjs); nothing here is written per command. Waiting for
3
3
  // a run and following it live (runs start --wait, runs wait, runs timeline --follow) are follow.mjs's; the commands that
4
4
  // read a secret from stdin (login, logout) are login.mjs's, skill install is skill.mjs's, and template
5
- // validate and template eval, which check and run a package folder on this machine, are template.mjs's.
5
+ // validate and template eval, which check and run a package folder on this machine, are template.mjs's, harness install
6
+ // (the harness its owner installs: goose) is harness.mjs's, and service
7
+ // (AgentRun as a launchd or systemd user service) and stop (the AgentRun the installer started in the background) are
8
+ // service.mjs's.
6
9
  import { closeSync, constants, fstatSync, openSync, readFileSync } from "node:fs";
7
10
  import { homedir } from "node:os";
8
11
  import { join, resolve } from "node:path";
@@ -10,11 +13,13 @@ import { parseArgs } from "node:util";
10
13
  import { COMMANDS, SECRET_ROUTES } from "./commands.generated.mjs";
11
14
  import { ALL, FLAGS, MAX_PAGES, REQUEST_MS, WAIT, followTimeline, timerMs, waitRun } from "./follow.mjs";
12
15
  import { SECRETS, guarded, refusalExit } from "./login.mjs";
16
+ import { SERVICE, STOP } from "./service.mjs";
13
17
  import { SKILL_INSTALL } from "./skill.mjs";
14
18
  import { TEMPLATE_EVAL, TEMPLATE_INSTALL, TEMPLATE_VALIDATE } from "./template.mjs";
19
+ import { HARNESS_INSTALL } from "./harness.mjs";
15
20
 
16
21
  /** The hand-written commands that run as they are given (`run`), beside the table's. */
17
- const LOCAL = [...SECRETS, SKILL_INSTALL, TEMPLATE_VALIDATE, TEMPLATE_EVAL, TEMPLATE_INSTALL];
22
+ const LOCAL = [...SECRETS, SKILL_INSTALL, TEMPLATE_VALIDATE, TEMPLATE_EVAL, TEMPLATE_INSTALL, HARNESS_INSTALL, ...SERVICE, STOP];
18
23
  export const NOUNS = new Set(["api", "help", ...[...COMMANDS, ...LOCAL].map((entry) => entry.command[0])]);
19
24
  const DEFAULT_BASE_URL = "http://127.0.0.1:7340/v2"; // key-gate: loopback-rule the default address of the server started on this machine
20
25
  const START = "start it with `npx @parcha/agentrun`, or pass --base-url (or set AGENTRUN_BASE_URL) to the address the server printed";
@@ -77,7 +77,7 @@ export const COMMANDS = [
77
77
  "name": "Idempotency-Key",
78
78
  "type": "string",
79
79
  "required": false,
80
- "description": "Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first"
80
+ "description": "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."
81
81
  }
82
82
  ],
83
83
  "bodyFlags": [
@@ -108,6 +108,28 @@ export const COMMANDS = [
108
108
  "raw": false,
109
109
  "summary": "Create an agent home"
110
110
  },
111
+ {
112
+ "command": [
113
+ "agents",
114
+ "delete-agent"
115
+ ],
116
+ "operationId": "deleteAgent",
117
+ "method": "DELETE",
118
+ "path": "/agents/{agent_id}",
119
+ "pathParams": [
120
+ "agent_id"
121
+ ],
122
+ "multiSegment": [],
123
+ "query": [],
124
+ "headers": [],
125
+ "bodyFlags": [],
126
+ "hasBody": false,
127
+ "bodyRequired": false,
128
+ "bodyTypes": [],
129
+ "secretBody": false,
130
+ "raw": false,
131
+ "summary": "Delete an agent another system owns"
132
+ },
111
133
  {
112
134
  "command": [
113
135
  "agents",
@@ -838,7 +860,7 @@ export const COMMANDS = [
838
860
  "name": "Idempotency-Key",
839
861
  "type": "string",
840
862
  "required": false,
841
- "description": "Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first"
863
+ "description": "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."
842
864
  }
843
865
  ],
844
866
  "bodyFlags": [
@@ -1071,106 +1093,11 @@ export const COMMANDS = [
1071
1093
  {
1072
1094
  "command": [
1073
1095
  "learning",
1074
- "batch"
1096
+ "corrections"
1075
1097
  ],
1076
- "operationId": "getLearningBatch",
1098
+ "operationId": "getLearningCorrections",
1077
1099
  "method": "GET",
1078
- "path": "/agents/{agent_id}/learning/batches/{batch_id}",
1079
- "pathParams": [
1080
- "agent_id",
1081
- "batch_id"
1082
- ],
1083
- "multiSegment": [],
1084
- "query": [],
1085
- "headers": [],
1086
- "bodyFlags": [],
1087
- "hasBody": false,
1088
- "bodyRequired": false,
1089
- "bodyTypes": [],
1090
- "secretBody": false,
1091
- "raw": false,
1092
- "summary": "A learning batch's progress: rows done, right or wrong, lessons, workflow revisions, cost, the path each run took"
1093
- },
1094
- {
1095
- "command": [
1096
- "learning",
1097
- "batch-cancel"
1098
- ],
1099
- "operationId": "cancelLearningBatch",
1100
- "method": "POST",
1101
- "path": "/agents/{agent_id}/learning/batches/{batch_id}/cancel",
1102
- "pathParams": [
1103
- "agent_id",
1104
- "batch_id"
1105
- ],
1106
- "multiSegment": [],
1107
- "query": [],
1108
- "headers": [],
1109
- "bodyFlags": [],
1110
- "hasBody": false,
1111
- "bodyRequired": false,
1112
- "bodyTypes": [],
1113
- "secretBody": false,
1114
- "raw": false,
1115
- "summary": "Cancel a running learning batch"
1116
- },
1117
- {
1118
- "command": [
1119
- "learning",
1120
- "batch-start"
1121
- ],
1122
- "operationId": "createLearningBatch",
1123
- "method": "POST",
1124
- "path": "/agents/{agent_id}/learning/batches",
1125
- "pathParams": [
1126
- "agent_id"
1127
- ],
1128
- "multiSegment": [],
1129
- "query": [],
1130
- "headers": [],
1131
- "bodyFlags": [
1132
- {
1133
- "name": "answer",
1134
- "type": "string",
1135
- "required": true,
1136
- "description": "The column holding the reference answer."
1137
- },
1138
- {
1139
- "name": "max_cost_usd",
1140
- "type": "number",
1141
- "required": true,
1142
- "description": "Caps what the batch's runs spend (job, look-back, review turn); grades are booked and shown, uncapped."
1143
- },
1144
- {
1145
- "name": "answer_field",
1146
- "type": "string",
1147
- "required": false,
1148
- "description": "A dotted path into a JSON answer to compare, such as result.code; absent: the whole answer."
1149
- },
1150
- {
1151
- "name": "effort",
1152
- "type": "string",
1153
- "required": false,
1154
- "description": "The runs' effort, as a run's."
1155
- }
1156
- ],
1157
- "hasBody": true,
1158
- "bodyRequired": true,
1159
- "bodyTypes": [
1160
- "application/json"
1161
- ],
1162
- "secretBody": false,
1163
- "raw": false,
1164
- "summary": "Learn from rows: run the agent on each in order, with learning on, and tell it the reference answer after each"
1165
- },
1166
- {
1167
- "command": [
1168
- "learning",
1169
- "batches"
1170
- ],
1171
- "operationId": "listLearningBatches",
1172
- "method": "GET",
1173
- "path": "/agents/{agent_id}/learning/batches",
1100
+ "path": "/agents/{agent_id}/learning/corrections",
1174
1101
  "pathParams": [
1175
1102
  "agent_id"
1176
1103
  ],
@@ -1183,7 +1110,7 @@ export const COMMANDS = [
1183
1110
  "bodyTypes": [],
1184
1111
  "secretBody": false,
1185
1112
  "raw": false,
1186
- "summary": "The agent's learning batches, latest first"
1113
+ "summary": "The agent's corrections.md on main, with its ETag"
1187
1114
  },
1188
1115
  {
1189
1116
  "command": [
@@ -1212,7 +1139,7 @@ export const COMMANDS = [
1212
1139
  "csv"
1213
1140
  ],
1214
1141
  "required": false,
1215
- "description": "`csv`: the runs as CSV, columns n, run_id, started_at, path, workflow, learned_revision, cost_usd, cost_upper_bound, learning_usd, total_usd."
1142
+ "description": "`csv`: the runs as CSV, columns n, run_id, started_at, path, workflow, digest, audited, cost_usd, cost_upper_bound, learning_usd, total_usd."
1216
1143
  }
1217
1144
  ],
1218
1145
  "headers": [],
@@ -1224,28 +1151,6 @@ export const COMMANDS = [
1224
1151
  "raw": false,
1225
1152
  "summary": "The agent's cost per run, run after run: its own cost, what learning added and the path it took"
1226
1153
  },
1227
- {
1228
- "command": [
1229
- "learning",
1230
- "evals"
1231
- ],
1232
- "operationId": "listLearningEvals",
1233
- "method": "GET",
1234
- "path": "/agents/{agent_id}/learning/evals",
1235
- "pathParams": [
1236
- "agent_id"
1237
- ],
1238
- "multiSegment": [],
1239
- "query": [],
1240
- "headers": [],
1241
- "bodyFlags": [],
1242
- "hasBody": false,
1243
- "bodyRequired": false,
1244
- "bodyTypes": [],
1245
- "secretBody": false,
1246
- "raw": false,
1247
- "summary": "The agent's eval records: the latest, and every one kept, newest first"
1248
- },
1249
1154
  {
1250
1155
  "command": [
1251
1156
  "learning",
@@ -1266,7 +1171,7 @@ export const COMMANDS = [
1266
1171
  "bodyTypes": [],
1267
1172
  "secretBody": false,
1268
1173
  "raw": false,
1269
- "summary": "What the agent has learned: its index, notes, log of changes and counts"
1174
+ "summary": "What the agent has learned: its corrections, workflow drafts, log of changes and counts"
1270
1175
  },
1271
1176
  {
1272
1177
  "command": [
@@ -1303,53 +1208,6 @@ export const COMMANDS = [
1303
1208
  "raw": false,
1304
1209
  "summary": "A page of the changes on the agent's main, newest first"
1305
1210
  },
1306
- {
1307
- "command": [
1308
- "learning",
1309
- "notes"
1310
- ],
1311
- "operationId": "listLearningNotes",
1312
- "method": "GET",
1313
- "path": "/agents/{agent_id}/learning/notes",
1314
- "pathParams": [
1315
- "agent_id"
1316
- ],
1317
- "multiSegment": [],
1318
- "query": [
1319
- {
1320
- "name": "cursor",
1321
- "type": "string",
1322
- "required": false,
1323
- "description": "`next_cursor` from the previous page: opaque, read at the commit the first page was."
1324
- },
1325
- {
1326
- "name": "limit",
1327
- "type": "integer",
1328
- "required": false,
1329
- "description": "At most 200."
1330
- },
1331
- {
1332
- "name": "status",
1333
- "type": "string",
1334
- "enum": [
1335
- "active",
1336
- "superseded",
1337
- "retired",
1338
- "pending"
1339
- ],
1340
- "required": false,
1341
- "description": "Only notes with this status."
1342
- }
1343
- ],
1344
- "headers": [],
1345
- "bodyFlags": [],
1346
- "hasBody": false,
1347
- "bodyRequired": false,
1348
- "bodyTypes": [],
1349
- "secretBody": false,
1350
- "raw": false,
1351
- "summary": "A page of the agent's notes"
1352
- },
1353
1211
  {
1354
1212
  "command": [
1355
1213
  "learning",
@@ -1371,81 +1229,7 @@ export const COMMANDS = [
1371
1229
  "bodyTypes": [],
1372
1230
  "secretBody": false,
1373
1231
  "raw": false,
1374
- "summary": "One note (or MEMORY.md, a skill's SKILL.md or a draft's file) on main, as text, with its ETag"
1375
- },
1376
- {
1377
- "command": [
1378
- "learning",
1379
- "record-eval"
1380
- ],
1381
- "operationId": "recordLearningEval",
1382
- "method": "POST",
1383
- "path": "/agents/{agent_id}/learning/evals",
1384
- "pathParams": [
1385
- "agent_id"
1386
- ],
1387
- "multiSegment": [],
1388
- "query": [],
1389
- "headers": [
1390
- {
1391
- "name": "Idempotency-Key",
1392
- "type": "string",
1393
- "required": false,
1394
- "description": "Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first"
1395
- }
1396
- ],
1397
- "bodyFlags": [
1398
- {
1399
- "name": "name",
1400
- "type": "string",
1401
- "required": true,
1402
- "description": "What ran the test, one line: a bench's name and set, a script's."
1403
- },
1404
- {
1405
- "name": "n",
1406
- "type": "integer",
1407
- "required": true,
1408
- "description": "The held-out jobs the test counted: jobs the agent never learned from."
1409
- },
1410
- {
1411
- "name": "correct",
1412
- "type": "integer",
1413
- "required": true,
1414
- "description": "How many of the `n` jobs the agent with what it learned got right: 0 to `n`."
1415
- },
1416
- {
1417
- "name": "label_source",
1418
- "type": "string",
1419
- "required": false,
1420
- "description": "Where the right answers came from, one line; null (or absent) when not said."
1421
- },
1422
- {
1423
- "name": "cost_per_task_usd",
1424
- "type": "number",
1425
- "required": false,
1426
- "description": "The agent with what it learned: its mean cost a task, in USD; null (or absent) when not counted."
1427
- },
1428
- {
1429
- "name": "baseline_cost_per_task_usd",
1430
- "type": "number",
1431
- "required": false,
1432
- "description": "The agent by hand (learning off): its mean cost a task, in USD; null (or absent) when not counted."
1433
- },
1434
- {
1435
- "name": "learned_revision",
1436
- "type": "string",
1437
- "required": false,
1438
- "description": "The learning folder's commit the test ran from; null (or absent) when not said."
1439
- }
1440
- ],
1441
- "hasBody": true,
1442
- "bodyRequired": true,
1443
- "bodyTypes": [
1444
- "application/json"
1445
- ],
1446
- "secretBody": false,
1447
- "raw": false,
1448
- "summary": "Record a held-out test of the agent: its counts and the cost a task, with learning and by hand"
1232
+ "summary": "One file of a learned workflow on main (its workflow.json or README.md), as text, with its ETag"
1449
1233
  },
1450
1234
  {
1451
1235
  "command": [
@@ -1491,7 +1275,7 @@ export const COMMANDS = [
1491
1275
  "name": "If-Match",
1492
1276
  "type": "string",
1493
1277
  "required": false,
1494
- "description": "The note's ETag, as a GET answered it: an edit or a retire lands only on that version, else 412."
1278
+ "description": "The file's ETag, as a GET answered it: the write lands only on that version, else 412."
1495
1279
  }
1496
1280
  ],
1497
1281
  "bodyFlags": [],
@@ -1500,7 +1284,7 @@ export const COMMANDS = [
1500
1284
  "bodyTypes": [],
1501
1285
  "secretBody": false,
1502
1286
  "raw": true,
1503
- "summary": "Retire a note, a skill or a workflow draft: out of every later run, kept in history"
1287
+ "summary": "Retire a workflow draft: out of every later run, kept in history"
1504
1288
  },
1505
1289
  {
1506
1290
  "command": [
@@ -1535,14 +1319,13 @@ export const COMMANDS = [
1535
1319
  {
1536
1320
  "command": [
1537
1321
  "learning",
1538
- "write"
1322
+ "write-corrections"
1539
1323
  ],
1540
- "operationId": "writeLearningFile",
1324
+ "operationId": "putLearningCorrections",
1541
1325
  "method": "PUT",
1542
- "path": "/agents/{agent_id}/learning/files/{file}",
1326
+ "path": "/agents/{agent_id}/learning/corrections",
1543
1327
  "pathParams": [
1544
- "agent_id",
1545
- "file"
1328
+ "agent_id"
1546
1329
  ],
1547
1330
  "multiSegment": [],
1548
1331
  "query": [],
@@ -1550,14 +1333,8 @@ export const COMMANDS = [
1550
1333
  {
1551
1334
  "name": "If-Match",
1552
1335
  "type": "string",
1553
- "required": false,
1554
- "description": "The note's ETag, as a GET answered it: an edit or a retire lands only on that version, else 412."
1555
- },
1556
- {
1557
- "name": "If-None-Match",
1558
- "type": "string",
1559
- "required": false,
1560
- "description": "`*`: create the note, only if the name is not taken, else 412."
1336
+ "required": true,
1337
+ "description": "The file's ETag, as a GET answered it: the write lands only on that version, else 412."
1561
1338
  }
1562
1339
  ],
1563
1340
  "bodyFlags": [
@@ -1565,7 +1342,7 @@ export const COMMANDS = [
1565
1342
  "name": "text",
1566
1343
  "type": "string",
1567
1344
  "required": true,
1568
- "description": "The note's whole text, front matter included."
1345
+ "description": "corrections.md's whole text."
1569
1346
  }
1570
1347
  ],
1571
1348
  "hasBody": true,
@@ -1576,8 +1353,8 @@ export const COMMANDS = [
1576
1353
  "application/json"
1577
1354
  ],
1578
1355
  "secretBody": false,
1579
- "raw": true,
1580
- "summary": "Edit a note (If-Match) or create one (If-None-Match: *)"
1356
+ "raw": false,
1357
+ "summary": "Replace the agent's corrections.md (If-Match)"
1581
1358
  },
1582
1359
  {
1583
1360
  "command": [
@@ -2274,7 +2051,7 @@ export const COMMANDS = [
2274
2051
  "name": "Idempotency-Key",
2275
2052
  "type": "string",
2276
2053
  "required": false,
2277
- "description": "Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first"
2054
+ "description": "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."
2278
2055
  }
2279
2056
  ],
2280
2057
  "bodyFlags": [
@@ -2307,6 +2084,12 @@ export const COMMANDS = [
2307
2084
  "required": false,
2308
2085
  "description": "Run at a quote's terms. A different `effort` or `max_cost_usd` than the quote's is `409 quote_invalid`."
2309
2086
  },
2087
+ {
2088
+ "name": "model_key",
2089
+ "type": "string",
2090
+ "required": false,
2091
+ "description": "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."
2092
+ },
2310
2093
  {
2311
2094
  "name": "workflow_first",
2312
2095
  "type": "boolean",
@@ -2320,7 +2103,7 @@ export const COMMANDS = [
2320
2103
  "use"
2321
2104
  ],
2322
2105
  "required": false,
2323
- "description": "`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."
2106
+ "description": "`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."
2324
2107
  },
2325
2108
  {
2326
2109
  "name": "repo",
@@ -2652,7 +2435,7 @@ export const COMMANDS = [
2652
2435
  "name": "Idempotency-Key",
2653
2436
  "type": "string",
2654
2437
  "required": false,
2655
- "description": "Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first"
2438
+ "description": "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."
2656
2439
  }
2657
2440
  ],
2658
2441
  "bodyFlags": [
@@ -2661,6 +2444,12 @@ export const COMMANDS = [
2661
2444
  "type": "string",
2662
2445
  "required": true,
2663
2446
  "description": "At most `limits.max_message_chars`. Not only whitespace."
2447
+ },
2448
+ {
2449
+ "name": "model_key",
2450
+ "type": "string",
2451
+ "required": false,
2452
+ "description": "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."
2664
2453
  }
2665
2454
  ],
2666
2455
  "hasBody": true,
@@ -2804,7 +2593,7 @@ export const COMMANDS = [
2804
2593
  "name": "Idempotency-Key",
2805
2594
  "type": "string",
2806
2595
  "required": false,
2807
- "description": "Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first"
2596
+ "description": "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."
2808
2597
  }
2809
2598
  ],
2810
2599
  "bodyFlags": [
@@ -2831,6 +2620,12 @@ export const COMMANDS = [
2831
2620
  "required": false,
2832
2621
  "description": "Run at a quote's terms. A different `effort` or `max_cost_usd` than the quote's is `409 quote_invalid`."
2833
2622
  },
2623
+ {
2624
+ "name": "model_key",
2625
+ "type": "string",
2626
+ "required": false,
2627
+ "description": "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."
2628
+ },
2834
2629
  {
2835
2630
  "name": "workflow_first",
2836
2631
  "type": "boolean",
@@ -2844,7 +2639,7 @@ export const COMMANDS = [
2844
2639
  "use"
2845
2640
  ],
2846
2641
  "required": false,
2847
- "description": "`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."
2642
+ "description": "`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."
2848
2643
  },
2849
2644
  {
2850
2645
  "name": "repo",
@@ -3007,6 +2802,28 @@ export const COMMANDS = [
3007
2802
  "raw": false,
3008
2803
  "summary": "The run's timeline, as a page or a stream"
3009
2804
  },
2805
+ {
2806
+ "command": [
2807
+ "runs",
2808
+ "trace"
2809
+ ],
2810
+ "operationId": "getRunTrace",
2811
+ "method": "GET",
2812
+ "path": "/runs/{run_id}/trace",
2813
+ "pathParams": [
2814
+ "run_id"
2815
+ ],
2816
+ "multiSegment": [],
2817
+ "query": [],
2818
+ "headers": [],
2819
+ "bodyFlags": [],
2820
+ "hasBody": false,
2821
+ "bodyRequired": false,
2822
+ "bodyTypes": [],
2823
+ "secretBody": false,
2824
+ "raw": false,
2825
+ "summary": "A run's trace: each model request and tool call, with its time, tokens and cost"
2826
+ },
3010
2827
  {
3011
2828
  "command": [
3012
2829
  "runs",
@@ -3371,10 +3188,17 @@ export const COMMANDS = [
3371
3188
  "name": "Idempotency-Key",
3372
3189
  "type": "string",
3373
3190
  "required": false,
3374
- "description": "Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first"
3191
+ "description": "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."
3192
+ }
3193
+ ],
3194
+ "bodyFlags": [
3195
+ {
3196
+ "name": "agent_id",
3197
+ "type": "string",
3198
+ "required": false,
3199
+ "description": "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."
3375
3200
  }
3376
3201
  ],
3377
- "bodyFlags": [],
3378
3202
  "hasBody": true,
3379
3203
  "bodyRequired": true,
3380
3204
  "bodyTypes": [
@@ -3545,7 +3369,7 @@ export const COMMANDS = [
3545
3369
  "name": "Idempotency-Key",
3546
3370
  "type": "string",
3547
3371
  "required": false,
3548
- "description": "Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first"
3372
+ "description": "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."
3549
3373
  }
3550
3374
  ],
3551
3375
  "bodyFlags": [
@@ -0,0 +1,37 @@
1
+ // `agentrun harness install goose`: the harness its owner installs, never a run (Goose, the one there is). The server
2
+ // installed with this command does it (agentrun-serve install-harness), as it runs validate-template: the pinned archive
3
+ // downloaded, its sha256 checked, unpacked into DATA/harnesses/goose, the binary's sha256 checked, then put in place
4
+ // read-only. DATA is this command's (~/.agentrun unless --data names one), the store `npx @parcha/agentrun` starts the
5
+ // server on. Run again with the pinned binary in place, it downloads nothing. No provider key goes near it.
6
+ import { spawnSync } from "node:child_process";
7
+ import { homedir } from "node:os";
8
+ import { join, resolve } from "node:path";
9
+
10
+ /** The harnesses this command installs. */
11
+ const INSTALLABLE = ["goose"];
12
+
13
+ /** A variable named like a credential (a KEY, TOKEN, SECRET, PASSWORD or CREDENTIAL(S) segment). */
14
+ const KEY_NAMED = /(?:^|_)(?:KEY|TOKEN|TOKENS|SECRET|PASSWORD|CREDENTIALS?)(?:_|$)/i;
15
+
16
+ export const HARNESS_INSTALL = {
17
+ command: ["harness", "install"],
18
+ pathParams: ["harness"],
19
+ summary: "Install a harness AgentRun runs only once its owner installs it (goose), then restart AgentRun",
20
+ help: [
21
+ ["HARNESS", `the harness: ${INSTALLABLE.join(", ")}. Its pinned release is downloaded and checked by sha256 into DATA/harnesses/HARNESS; run again, it downloads nothing`],
22
+ ["--data DIR", "the data directory of the AgentRun it is for (default ~/.agentrun, where npx @parcha/agentrun keeps it)"],
23
+ ],
24
+ options: {},
25
+ async run({ values, args, env, cli }) {
26
+ const [name] = args;
27
+ if (!INSTALLABLE.includes(name)) throw cli.fail(2, `agentrun harness install installs ${INSTALLABLE.join(", ")}, not ${name}: claude-agent and codex install on first use, and pi and opencode come with AgentRun.`);
28
+ // Loaded here: start.mjs loads cli.mjs, which loads this module.
29
+ const { installedServer } = await import("./start.mjs");
30
+ const launcher = installedServer();
31
+ if (launcher === undefined) throw cli.fail(2, "AgentRun's server is not installed beside this command, and it is the server that installs a harness.");
32
+ const data = resolve(values.data ?? join(env.HOME || homedir(), ".agentrun"));
33
+ // No key reaches the install: every variable named like one is left out of its environment.
34
+ const keyless = Object.fromEntries(Object.entries(env).filter(([key]) => !KEY_NAMED.test(key)));
35
+ return spawnSync(launcher, ["install-harness", name, "--data", data], { stdio: "inherit", env: keyless }).status ?? 1;
36
+ },
37
+ };