@parcha/agentrun-serve 0.1.0-beta.59 → 0.1.0-beta.60

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.
Files changed (194) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +188 -106
  3. package/dist/agent-delete.d.ts +6 -9
  4. package/dist/agent-delete.js +5 -3
  5. package/dist/agent-package.js +11 -1
  6. package/dist/api-only.d.ts +2 -2
  7. package/dist/api-only.js +3 -3
  8. package/dist/archil-routes.d.ts +4 -1
  9. package/dist/archil-routes.js +15 -12
  10. package/dist/archil-settings.d.ts +18 -8
  11. package/dist/archil-settings.js +35 -17
  12. package/dist/chatgpt-plan.d.ts +4 -2
  13. package/dist/chatgpt-plan.js +13 -3
  14. package/dist/claude-login-token.d.ts +5 -0
  15. package/dist/claude-login-token.js +8 -0
  16. package/dist/claude-login.d.ts +49 -3
  17. package/dist/claude-login.js +140 -10
  18. package/dist/cli-learning/connections.js +1 -1
  19. package/dist/console/assets/{backend-BztxEAvb.js → backend-QnwGVBeU.js} +1 -1
  20. package/dist/console/assets/index-DZi-muIj.js +629 -0
  21. package/dist/console/assets/{share-L84tlUDW.js → share-pz61zIn9.js} +2 -2
  22. package/dist/console/assets/{styles-CaRKlHke.js → styles-CcceGcu2.js} +31 -31
  23. package/dist/console/assets/styles-fjQBFfMv.css +1 -0
  24. package/dist/console/index.html +3 -3
  25. package/dist/console/share.html +3 -3
  26. package/dist/decisions.d.ts +1 -1
  27. package/dist/decisions.js +2 -2
  28. package/dist/factory-activity.d.ts +68 -0
  29. package/dist/factory-activity.js +153 -0
  30. package/dist/factory-runs.d.ts +11 -0
  31. package/dist/factory-runs.js +52 -0
  32. package/dist/filed-tool.d.ts +32 -0
  33. package/dist/filed-tool.js +122 -0
  34. package/dist/harness-keys.d.ts +1 -2
  35. package/dist/harness-keys.js +1 -2
  36. package/dist/harness-table.d.ts +4 -0
  37. package/dist/harness-table.js +4 -0
  38. package/dist/harness.js +6 -2
  39. package/dist/import-worker.js +2 -2
  40. package/dist/import.d.ts +9 -0
  41. package/dist/import.js +11 -1
  42. package/dist/key-refusal.d.ts +5 -0
  43. package/dist/key-refusal.js +25 -15
  44. package/dist/learn/audit.d.ts +20 -22
  45. package/dist/learn/audit.js +72 -55
  46. package/dist/learn/check.js +1 -1
  47. package/dist/learn/commit.d.ts +35 -43
  48. package/dist/learn/commit.js +62 -270
  49. package/dist/learn/compile.d.ts +4 -4
  50. package/dist/learn/compile.js +6 -7
  51. package/dist/learn/corrections.js +1 -1
  52. package/dist/learn/delete.d.ts +5 -12
  53. package/dist/learn/delete.js +17 -30
  54. package/dist/learn/forget-run.d.ts +16 -0
  55. package/dist/learn/forget-run.js +53 -0
  56. package/dist/learn/index.js +1 -1
  57. package/dist/learn/learning-of.d.ts +0 -4
  58. package/dist/learn/learning-of.js +0 -5
  59. package/dist/learn/{folder.d.ts → legacy/folder.d.ts} +2 -1
  60. package/dist/learn/{folder.js → legacy/folder.js} +4 -7
  61. package/dist/learn/legacy/place.d.ts +16 -0
  62. package/dist/{workspace/learning-workspace.js → learn/legacy/place.js} +12 -42
  63. package/dist/learn/legacy/scrub.d.ts +28 -0
  64. package/dist/learn/legacy/scrub.js +258 -0
  65. package/dist/learn/promote.d.ts +40 -66
  66. package/dist/learn/promote.js +69 -207
  67. package/dist/learn/reset-ledger.d.ts +18 -0
  68. package/dist/learn/reset-ledger.js +14 -0
  69. package/dist/learn/rows.d.ts +186 -0
  70. package/dist/learn/rows.js +376 -0
  71. package/dist/learn/workflow-draft.d.ts +4 -1
  72. package/dist/learn/workflow-draft.js +12 -2
  73. package/dist/learning-reset.d.ts +1 -1
  74. package/dist/learning-reset.js +9 -11
  75. package/dist/learning-routes.d.ts +60 -81
  76. package/dist/learning-routes.js +187 -360
  77. package/dist/learning-words.d.ts +2 -0
  78. package/dist/learning-words.js +2 -0
  79. package/dist/learning.d.ts +18 -24
  80. package/dist/learning.js +35 -66
  81. package/dist/mcp-gateway.d.ts +6 -0
  82. package/dist/mcp-gateway.js +44 -8
  83. package/dist/mcp-resources.d.ts +1 -1
  84. package/dist/native/discovery.d.ts +6 -0
  85. package/dist/native/discovery.js +14 -1
  86. package/dist/native/remote.d.ts +5 -0
  87. package/dist/native/remote.js +16 -0
  88. package/dist/native/runtime.js +3 -2
  89. package/dist/observation/observer.d.ts +6 -6
  90. package/dist/openapi.js +89 -29
  91. package/dist/place-offers.d.ts +3 -0
  92. package/dist/place-offers.js +3 -0
  93. package/dist/place.d.ts +33 -11
  94. package/dist/place.js +61 -26
  95. package/dist/purged-workflow.d.ts +0 -33
  96. package/dist/purged-workflow.js +3 -71
  97. package/dist/redact/match.d.ts +19 -4
  98. package/dist/redact/match.js +123 -30
  99. package/dist/run-launch.d.ts +3 -3
  100. package/dist/run-learning-served.d.ts +3 -3
  101. package/dist/run-learning-served.js +1 -1
  102. package/dist/run-listing.d.ts +1 -1
  103. package/dist/run-timeline-served.d.ts +1 -1
  104. package/dist/run-timeline-served.js +6 -5
  105. package/dist/runnable.js +25 -8
  106. package/dist/runner/adapter-run-spec.js +11 -20
  107. package/dist/runner/audit.d.ts +2 -4
  108. package/dist/runner/audit.js +28 -51
  109. package/dist/runner/cli-run-spec.js +8 -14
  110. package/dist/runner/compare-end.d.ts +0 -2
  111. package/dist/runner/compare-end.js +6 -2
  112. package/dist/runner/disk-free.d.ts +15 -4
  113. package/dist/runner/disk-free.js +25 -7
  114. package/dist/runner/feedback-round.d.ts +1 -1
  115. package/dist/runner/feedback-round.js +2 -2
  116. package/dist/runner/harness-loops.js +2 -3
  117. package/dist/runner/held.d.ts +0 -10
  118. package/dist/runner/held.js +0 -25
  119. package/dist/runner/journal-kinds.d.ts +4 -1
  120. package/dist/runner/journal-kinds.js +1 -1
  121. package/dist/runner/learned-first.d.ts +0 -2
  122. package/dist/runner/learned-first.js +3 -3
  123. package/dist/runner/learning-end.d.ts +12 -16
  124. package/dist/runner/learning-end.js +41 -75
  125. package/dist/runner/learning-seed.d.ts +13 -16
  126. package/dist/runner/learning-seed.js +13 -23
  127. package/dist/runner/main.js +1 -1
  128. package/dist/runner/mcp-run.d.ts +4 -0
  129. package/dist/runner/mcp-run.js +2 -0
  130. package/dist/runner/native-loop.js +2 -3
  131. package/dist/runner/promotion.d.ts +19 -28
  132. package/dist/runner/promotion.js +50 -69
  133. package/dist/runner/reflect-hook.d.ts +2 -2
  134. package/dist/runner/reflect-hook.js +4 -1
  135. package/dist/runner/run-child-host.d.ts +1 -9
  136. package/dist/runner/run-child-host.js +11 -67
  137. package/dist/runner/runner.d.ts +1 -1
  138. package/dist/runner/sdk-loop.js +2 -4
  139. package/dist/sdk/check.d.ts +1 -4
  140. package/dist/sdk/check.js +2 -3
  141. package/dist/sdk/runs.d.ts +20 -7
  142. package/dist/sdk/runs.js +105 -68
  143. package/dist/secrets.d.ts +4 -0
  144. package/dist/secrets.js +44 -10
  145. package/dist/server-fs.d.ts +1 -1
  146. package/dist/server-fs.js +1 -1
  147. package/dist/server-keys.d.ts +6 -0
  148. package/dist/server-keys.js +12 -0
  149. package/dist/server.d.ts +15 -15
  150. package/dist/server.js +214 -164
  151. package/dist/source-sync/auxiliary.js +2 -2
  152. package/dist/store/index.d.ts +1 -1
  153. package/dist/store/index.js +1 -1
  154. package/dist/store/postgres/migrations/0032_learning_rows.sql +65 -0
  155. package/dist/store/schema.d.ts +28 -2
  156. package/dist/store/schema.js +81 -5
  157. package/dist/store/sqlite/learning-rows.d.ts +23 -0
  158. package/dist/store/sqlite/learning-rows.js +559 -0
  159. package/dist/store/sqlite/store.d.ts +7 -1
  160. package/dist/store/sqlite/store.js +84 -18
  161. package/dist/store/store.d.ts +219 -6
  162. package/dist/store/store.js +13 -0
  163. package/dist/store-reads/journal.d.ts +33 -3
  164. package/dist/store-reads/journal.js +99 -4
  165. package/dist/store-reads/learning.d.ts +18 -22
  166. package/dist/store-reads/learning.js +35 -26
  167. package/dist/store-reads/loop.js +1 -1
  168. package/dist/store-view.d.ts +24 -2
  169. package/dist/store-view.js +40 -11
  170. package/dist/templates.d.ts +10 -2
  171. package/dist/templates.js +31 -4
  172. package/dist/tool-plane.d.ts +4 -2
  173. package/dist/tool-plane.js +9 -2
  174. package/dist/web-holds.d.ts +2 -0
  175. package/dist/web-holds.js +5 -2
  176. package/dist/web-run.js +2 -1
  177. package/dist/workspace/archil-exec.js +1 -1
  178. package/dist/workspace/archil.d.ts +1 -1
  179. package/dist/workspace/archil.js +1 -1
  180. package/dist/workspace/computer-deps.js +5 -3
  181. package/dist/workspace/computer-providers.d.ts +11 -1
  182. package/dist/workspace/computer-providers.js +29 -2
  183. package/dist/workspace/index.d.ts +1 -2
  184. package/dist/workspace/index.js +1 -2
  185. package/dist/workspace/paths.d.ts +0 -4
  186. package/dist/workspace/paths.js +0 -6
  187. package/dist/workspace/workspace.d.ts +1 -1
  188. package/dist/workspace/workspace.js +1 -1
  189. package/package.json +13 -13
  190. package/templates/TOOLS.md +46 -0
  191. package/dist/console/assets/index-LwNL4L9q.js +0 -619
  192. package/dist/console/assets/styles-DQo8rzY-.css +0 -1
  193. package/dist/workspace/learning-workspace.d.ts +0 -24
  194. /package/dist/learn/{learning.sh → legacy/learning.sh} +0 -0
package/dist/openapi.js CHANGED
@@ -74,10 +74,12 @@ import { LABEL_KEY, MAX_LABEL_VALUE, MAX_LABELS } from "./run-labels.js";
74
74
  import { COST_BASES } from "./runner/metrics.js";
75
75
  import { FIRST_REASONS, PAST_RUNS } from "./runner/workflow-first.js";
76
76
  import { BASH_POLICIES } from "./bash-read-only.js";
77
+ import { MAX_SHOW_PATHS, MAX_SHOW_SEGMENTS, SHOWN_CHARS } from "./filed-tool.js";
77
78
  // The modules that own the computer and Archil key writes: loading the document loads their secret-write predicates
78
79
  // (secret-writes.ts registerSecretWrite), so every operation the document marks has its predicate wherever it is read.
79
80
  import "./computers.js";
80
81
  import { ARCHIL_KEY_NAMES } from "./archil-routes.js";
82
+ import { ARCHIL_S3_URLS } from "./archil-settings.js";
81
83
  import { RUN_FILE_CUT_MAX } from "./run-files.js";
82
84
  import { ATTACH_HEARTBEAT_MS, ATTACH_IDLE_MS, ATTACH_SUBPROTOCOL, MAX_LINE_BYTES, PAIRING_CODE_PATTERN, PAIRING_CODE_TTL_MS, PROTOCOL_VERSION } from "@parcha/agentrun-computer";
83
85
  import { DAEMON_FETCHES_PER_MINUTE, PAIR_TRIES_PER_MINUTE, PAIRED_NAME_MAX } from "./computer-attach.js";
@@ -826,10 +828,20 @@ const EMAIL_SCOPE = {
826
828
  description: "An agent's own setting on email_read, email_search and email_file only, never the server's. thread (the default): on a run an email trigger started, the tool sees (and email_file files) the thread of the message that started it alone (that message, and every message whose References or In-Reply-To links it, in any mailbox), and a message outside it is answered \"outside this run's thread\" and never fetched; mailbox: the whole account. A run no email started sees the whole account either way.",
827
829
  "x-agentrun-serve": "email/1",
828
830
  };
829
- /** An agent's own tool settings (definition.tool_settings): the map, with bash's policy and the email read tools' scope. */
831
+ /** filed-results/1: an MCP tool's file setting (filed-tool.ts), in an agent's own tool settings and a package's mcp need. */
832
+ const FILE_SETTING = {
833
+ type: "object", additionalProperties: false, required: ["folder", "show"],
834
+ properties: {
835
+ folder: { type: "string", pattern: "^[A-Za-z0-9_][A-Za-z0-9_.-]{0,63}(/[A-Za-z0-9_][A-Za-z0-9_.-]{0,63}){0,2}$", description: "The folder of the run's files each answer is filed in: 1 to 3 segments, none starting with a dot." },
836
+ show: { type: "array", maxItems: MAX_SHOW_PATHS, uniqueItems: true, items: { type: "string", pattern: "^(?:[A-Za-z_$][A-Za-z0-9_$-]{0,63}|0|[1-9][0-9]{0,8}|-1)(?:\\.(?:[A-Za-z_$][A-Za-z0-9_$-]{0,63}|0|[1-9][0-9]{0,8}|-1)){0,5}$" }, description: `The paths of each answer the tool's result shows, at most ${MAX_SHOW_PATHS}, each 1 to ${MAX_SHOW_SEGMENTS} segments joined by .: a key, an index, or -1 (the last item). A path that reaches no scalar shows null; a string is cut at ${SHOWN_CHARS} characters. A path that names a free-text field shows that text, and defeats the setting.` },
837
+ },
838
+ description: `An agent's own setting on an MCP tool's own key (mcp:<server>/<tool>) only, never a server's wildcard and never the server's settings: each answer of the tool, an error answer too, is written whole (its credentials scrubbed) at <folder>/<tool>-<time>-<id>.json in the run's files before the model is answered, for the skill's code. The answer is not returned as the tool's result, and goes through neither the clip nor evidence/mcp/: the result is a summary of the answer's bytes, the file's path, the value at each show path, and the answer's shape (keys that read as short names and types to depth 2, each array's length, never a value), and it is an error when the answer is. The model's own file tools (read, grep, ls, and bash on a computer) can still open the folder, so a template that must keep the model off the answer grants none of them, or runs its skill's code where the model can't read the output. A write that fails answers an error with none of the answer. A stored setting that no longer reads refuses every call of the tool, sending nothing. Removing the setting gives the tool's answers to the model again. A template's apply writes it from the package's mcp[].file.`,
839
+ "x-agentrun-serve": "filed-results/1",
840
+ };
841
+ /** An agent's own tool settings (definition.tool_settings): the map, with bash's policy, the email read tools' scope and an MCP tool's file setting. */
830
842
  const AGENT_TOOL_SETTINGS = {
831
843
  ...TOOL_SETTINGS,
832
- additionalProperties: { type: "object", additionalProperties: false, properties: { permission: PERMISSION, pin: PIN, pin_broken: PIN_BROKEN } },
844
+ additionalProperties: { type: "object", additionalProperties: false, properties: { permission: PERMISSION, pin: PIN, pin_broken: PIN_BROKEN, file: FILE_SETTING } },
833
845
  properties: {
834
846
  ...TOOL_SETTINGS.properties,
835
847
  bash: { ...TOOL_SETTINGS.properties.bash, properties: { ...TOOL_SETTINGS.properties.bash.properties, policy: BASH_POLICY } },
@@ -968,12 +980,13 @@ const LEARNING_REASON = {
968
980
  enum: [...LEARNING_REASONS, null],
969
981
  description: [
970
982
  "Set only when `state` is `dropped`, from a closed list; a new reason is announced before it ships.",
971
- "`seed_failed`: the agent's learning folder could not be read or made, so the run started with nothing learned.",
983
+ "`seed_failed`: the agent's learning could not be read, so the run started with nothing learned.",
972
984
  "`no_budget`: the run's cap left no room for the compile turn, or refused its request. `unknown_cost`: a capped run whose spend is unknown.",
973
985
  "`cancelled`: a person cancelled the run. `crashed`: the run's process went. `reflect_failed`: the compile turn ended on an error.",
974
986
  "`empty`: the compile turn kept no workflow and the owner gave no correction, or the run was not asked its compile turn because its only tool work was its learned workflows, each answering, with nothing said after its first message (its `detail` says so). `checker`: the checks (or the workflow's dry run) refused it, or the owner's correction would pass corrections.md's cap, and nothing was written to git.",
975
987
  "`use`: the run was started with `learning: \"use\"`: it started from what its agent learned and keeps nothing, so it was never asked its end-of-run turn.",
976
988
  "`reset`: the run read what its agent learned before a reset of the agent's learning (DELETE /v2/agents/{agent_id}/learning), so nothing it learned is kept and it was never asked its end-of-run turn.",
989
+ "`purged_since_seed`: another run of its agent was purged (DELETE /v2/runs/{run_id}) after this run read what its agent learned, so nothing this run learned is kept: the purge rewrote what it started from, and what it gives back can't be told apart from the purged run's text.",
977
990
  ].join(" "),
978
991
  };
979
992
  // ---- learning/1: what a person sees and controls of an agent's learning (learning-routes.ts) ---------------------------
@@ -1042,7 +1055,7 @@ const LEARNING_MODEL = closed({
1042
1055
  const AGENT_LEARNING = closed({
1043
1056
  learning_model: LEARNING_MODEL,
1044
1057
  agent: { type: "string" },
1045
- main: { ...NULL_STRING, description: "Main's head commit; null while the agent has no learning folder (its learning was never on), when every page is empty." },
1058
+ main: { ...NULL_STRING, description: "The agent's newest learning save; null while the agent has none (its learning was never on), when every page is empty." },
1046
1059
  corrections: { type: "string", description: "corrections.md on main, cut of the host's secrets: what the agent's next run is given whole under # Learned, one line per correction its owner gave. Empty when there is none. GET .../learning/corrections reads it with its ETag; PUT writes it.", "x-agentrun-serve": "learning/4" },
1047
1060
  workflows: { type: "array", items: LEARNED_WORKFLOW, description: "Every workflow draft on main, `workflows/<name>/workflow.json` with its README.md, by name. Empty when there is none.", "x-agentrun-serve": "learning/3" },
1048
1061
  log: PAGE(LEARNING_CHANGE, "The first 20 changes on main, newest first. GET .../learning/log for more."),
@@ -1301,14 +1314,17 @@ const RUNNING_COMPUTERS = closed({
1301
1314
  description: "The runs still going whose agent has a computer, newest first, each as GET /runs/{run_id} answers it, so each carries its `computer`. A run with no computer, and one that has ended, is not here.",
1302
1315
  },
1303
1316
  });
1304
- /** archil/1: GET, PUT and DELETE /workspace/archil's answer (archil-routes.ts view). */
1317
+ /** archil/1: GET, PUT and DELETE /workspace/archil's answer (archil-routes.ts view). archil/2: `regions` and `s3UrlFrom`,
1318
+ * which a client that validates against archil/1 refuses, so they are a mark of their own. */
1305
1319
  const ARCHIL_VIEW = closedWith({
1306
1320
  on: { type: "boolean", description: "Whether Mode 2 is on: run folders on Archil disks, each agent's own (made on its first run that needs one) unless a run's launch names another. Off, they are on this server's own disk (Mode 1)." },
1321
+ regions: { type: "object", additionalProperties: { type: "string", format: "uri" }, description: `Each Archil region this server knows, with its S3 endpoint (its control plane's host with \`control.\` made \`s3.\`, as Archil's SDK derives it): ${Object.keys(ARCHIL_S3_URLS).join(", ")}. A PUT naming one of them may leave \`s3Url\` out.`, "x-agentrun-serve": "archil/2" },
1307
1322
  secret: { ...SECRET_ITEM("\"workspace:archil\": the Archil account key, which PUT /workspace/archil takes as keys.ARCHIL_API_KEY and the environment variable ARCHIL_API_KEY sets."), description: "The account key as its SecretMeta: never a value." },
1308
1323
  }, {
1309
1324
  source: { enum: ["env", "console"], description: "While on, where the settings come from: `env`, the server's environment (AGENTRUN_ARCHIL_REGION, AGENTRUN_ARCHIL_S3_URL and AGENTRUN_ARCHIL_IMAGE), which wins over saved ones and is changed where the server is started; `console`, saved with PUT /workspace/archil." },
1310
1325
  region: { type: "string", description: "The account key's region: every disk is made, read and minted on its control plane." },
1311
- s3Url: { type: "string", format: "uri", description: "The region's S3 endpoint (the disks' file API)." },
1326
+ s3Url: { type: "string", format: "uri", description: "The S3 endpoint in force (the disks' file API): the one given, else the region's (`regions`)." },
1327
+ s3UrlFrom: { enum: ["region", "given"], description: "While on, where `s3Url` comes from: `region`, the region's own (`regions`), as saved when the PUT, or the environment, gave none; `given`, another one given.", "x-agentrun-serve": "archil/2" },
1312
1328
  image: { type: "string", description: "The exec image, pinned by digest (`<name>@sha256:<64 hex>`); absent, serve's default (`buildpack-deps:trixie-scm` pinned by digest, git 2.47)." },
1313
1329
  });
1314
1330
  /** archil/1: GET and DELETE /agents/{agent_id}/archil's answer (archil-routes.ts agentView). */
@@ -1588,7 +1604,7 @@ const TEMPLATE = closed({
1588
1604
  toolkit: { type: "string", description: "The toolkit its tools are: the package names them `mcp:<toolkit>/<tool>`, and apply maps it to a saved MCP server whose `source` and `toolkit` match, rewriting the name to `mcp:<server>/<tool>` in the agent it makes." },
1589
1605
  required: { type: "boolean" },
1590
1606
  reason: { type: ["string", "null"], description: "Why the agent needs these tools, one line, for the apply screen." },
1591
- tools: { type: "array", items: closedWith({ name: { type: "string" }, tool: { type: "string", description: "Its name in the package, `mcp:<toolkit>/<tool>`: what apply's `grants` name." }, asks: { enum: ["allow", "ask"], description: "Every listed tool is one the package uses and asks the owner to grant (a consent screen shows each): only the owner's `grants` at apply grant it, with no permission written; one left out is not granted. `asks` says only how its calls run once granted: `allow`, a tool the package's manifest lists under `allow`, expected to run without asking (a read); `ask`, each call waits for the owner's OK (a write) unless the owner allowed it in tool settings or chose approvals `never`." } }, { pin: { type: "object", additionalProperties: { anyOf: [{ type: ["string", "number", "boolean", "null"] }, { type: "array", items: { type: ["string", "number", "boolean", "null"] } }, PIN_KEYS] }, description: "The arguments (each a value, a list one of which, or {keys: [...]}, the keys an object argument may hold) each call of the tool must carry, `${parameters.<name>}` unfilled: apply writes them, filled, as the tool's pin in the agent's tool_settings, so the tool gate refuses a call with any other (a send goes only to the destination the owner sets), and a call carrying an argument the tool's listing does not declare (an alias of a pinned one). A pin whose parameter apply is not given sets the tool to deny instead, with a `pins.<tool>` warning.", "x-agentrun-serve": "pins/1" } }) },
1607
+ tools: { type: "array", items: closedWith({ name: { type: "string" }, tool: { type: "string", description: "Its name in the package, `mcp:<toolkit>/<tool>`: what apply's `grants` name." }, asks: { enum: ["allow", "ask"], description: "Every listed tool is one the package uses and asks the owner to grant (a consent screen shows each): only the owner's `grants` at apply grant it, with no permission written; one left out is not granted. `asks` says only how its calls run once granted: `allow`, a tool the package's manifest lists under `allow`, expected to run without asking (a read); `ask`, each call waits for the owner's OK (a write) unless the owner allowed it in tool settings or chose approvals `never`." } }, { pin: { type: "object", additionalProperties: { anyOf: [{ type: ["string", "number", "boolean", "null"] }, { type: "array", items: { type: ["string", "number", "boolean", "null"] } }, PIN_KEYS] }, description: "The arguments (each a value, a list one of which, or {keys: [...]}, the keys an object argument may hold) each call of the tool must carry, `${parameters.<name>}` unfilled: apply writes them, filled, as the tool's pin in the agent's tool_settings, so the tool gate refuses a call with any other (a send goes only to the destination the owner sets), and a call carrying an argument the tool's listing does not declare (an alias of a pinned one). A pin whose parameter apply is not given sets the tool to deny instead, with a `pins.<tool>` warning.", "x-agentrun-serve": "pins/1" }, file: { ...FILE_SETTING, description: "Where each answer of the tool is filed whole in the run's files, and the paths of it the tool's result shows (the package's mcp[].file): apply writes it as the tool's file setting in the agent's tool_settings, ticked or not, so the tool's result is a summary of each answer, never the answer. Absent when the package files none." } }) },
1592
1608
  }),
1593
1609
  description: "The MCP servers it uses, by source and toolkit, and the tools of each it may be granted: apply maps each to a saved server whose `source` and `toolkit` match (`servers` picks when several do) and grants there only those the apply's `grants` name, with no permission written (each call follows this server's tool settings: under approvals ask a write asks unless the owner allowed it there, and a read runs unasked only where the server's Allow reads is on); a tool left out of `grants` is not the agent's at all, whatever its approvals, and the owner can grant it later in the agent's tools. One no saved server matches is skipped with an `mcp.<toolkit>` warning saying how to set it up, or, `required`, refuses the apply (409, nothing made).",
1594
1610
  },
@@ -1758,7 +1774,7 @@ const LEARNING_DIFF = closed({
1758
1774
  },
1759
1775
  }, "What the run merged: its merge commit against its parent; a run that merged nothing, no file, against its seed.");
1760
1776
  const AGENT_ID = ref("parameters/AgentId");
1761
- const FILE_PARAM = { name: "file", in: "path", required: true, description: "A file of the agent's learning folder, its slashes percent-encoded (`workflows%2F<name>%2FREADME.md`): on a read, a draft's `workflows/<name>/workflow.json` or `README.md`; on an approval, a retire or a restore, a draft's README.md. Any other name is 400, corrections.md included: it is read and written on `/agents/{agent_id}/learning/corrections`; a path with a bare `/` is no route (404).", schema: { type: "string" } };
1777
+ const FILE_PARAM = { name: "file", in: "path", required: true, description: "A file of the agent's learning, its slashes percent-encoded (`workflows%2F<name>%2FREADME.md`): on a read, a draft's `workflows/<name>/workflow.json` or `README.md`; on an approval, a retire or a restore, a draft's README.md. Any other name is 400, corrections.md included: it is read and written on `/agents/{agent_id}/learning/corrections`; a path with a bare `/` is no route (404).", schema: { type: "string" } };
1762
1778
  const ETAG = { ETag: { description: "The file's version on main: its git blob id, quoted. If-Match on a write takes it.", schema: { type: "string" } }, "X-Content-Type-Options": ref("headers/NoSniff") };
1763
1779
  const FILE_TEXT = (description, json = false) => ({ description, headers: ETAG, content: { "text/markdown": { schema: { type: "string" } }, ...(json ? { "application/json": { schema: {}, description: "A draft's workflow.json, as it is on main." } } : {}) } });
1764
1780
  const PRECONDITION_REQUIRED = { description: "`precondition_required`: the write names no version it read: If-Match with the file's ETag. If-Match: * is not one.", content: { "application/json": { schema: ref("schemas/Error") } } };
@@ -1954,7 +1970,7 @@ const PROMOTION = closedWith({
1954
1970
  runs: { type: "array", items: { type: "string" }, description: "Its replay runs (path `replay`)." },
1955
1971
  inputs: { type: "array", items: { type: "string" }, description: "On a replaying record: the graded run each of `runs` replays, in the same order. Its runs are reserved before they are created; one not created a few minutes on is created by the next claim." },
1956
1972
  replay_id: { type: "string", description: "The replay's id, on its replaying record and the one that decided it: GET .../revisions/{digest}/replays/{replay_id} reads it, whether a run's claim or its owner started it." },
1957
- commit: { type: "string", description: "The learning commit whose workflow.json is this revision's text: what it serves from as the champion while a newer revision replays." },
1973
+ commit: { type: "string", description: "The learning save whose workflow.json is this revision's text: what it serves from as the champion while a newer revision replays." },
1958
1974
  via: { const: "sdk", description: "A connected (SDK) agent's check, on each reservation and on the record that decides it: its one run (`runs`) is the agent's own native turn reserved now, checked by the caller's shadow, not a replay run. A `replaying` one with no `runs` waits for the next native turn the draft takes. It collects its checked turns (`check.turns`) until it holds `check.compile_after` of them, then decides once on all of them, as a server replay decides once on its inputs. A turn the backend never completes within an hour is one failed input. Left out for a server replay." },
1959
1975
  audit: closedWith({
1960
1976
  window: { type: "integer", minimum: 1, description: "The definition's `learning.hold_window` when it was held." },
@@ -1989,7 +2005,7 @@ const SERVING = closed({
1989
2005
  not_auditable: { ...COUNT, description: "Of the serving revision's newest `learning.stop_window` served runs, those a trigger started: never audited (a shadow run gets none of a trigger's context, and could answer where it answers). 0 when none serves." },
1990
2006
  champion: { anyOf: [closed({
1991
2007
  digest: { type: "string", description: "The champion's revision: `digest` above." },
1992
- commit: { ...NULL_STRING, description: "The learning commit its text was read at: the newest its promotion records name that holds it, else the folder's main. Read by its recorded digest, never by paging the workflow's history. Null when no commit read holds it." },
2008
+ commit: { ...NULL_STRING, description: "The learning save its text was read at: the newest version of the workflow at its recorded digest. Null when no version holds it." },
1993
2009
  nodes: { anyOf: [{ type: "array", items: closed({
1994
2010
  path: { type: "string", description: "Where the node is in its parent: a chain's step by its index (`0`, `1`), any other child by its field (`2.body`); `root` for a root that is no chain." },
1995
2011
  kind: { type: "string", description: "Its node kind (`extract`, `decide`, `call`, `loop`, `escalate`, ...)." },
@@ -2062,7 +2078,7 @@ const LEARNING_EXTENSIONS = {
2062
2078
  "/agents/{agent_id}/learning/audits": {
2063
2079
  get: {
2064
2080
  operationId: "listLearningAudits", tags: ["agents"], summary: "The audit ledger of the agent's serving learned workflows",
2065
- description: "One row per finished audit, oldest first, as the agent's learning folder keeps them (audits.jsonl): a run a promoted learned workflow answered alone (path `workflow`; a run it handed back is never drawn) is audited at 1 in `learning.audit_every` (drawn from its id): its shadow run, the same agent on the same input with learning off, answers it again, and the row says whether the two answers say the same and what each run cost (the shadow's is the agent's learning cost; the shadow is no row of the run list, and GET /runs/{id} reads it with `audit_of`). A capped run's shadow starts at its end, capped at what its cap left, so the two never spend past it: with less than a run's smallest cap left, none starts (`skipped`). A shadow never waits on a person: one that would (an approval, a question, a raise of its cap) ends there at once with no answer (`parked`); neither is counted. Each row compares the served run's answer at the audit's start (`turn`), never a follow-up's. An owner's grade of a run the workflow answered alone is a row too. The hold rule reads them (`learning.hold_window`, `learning.hold_disagree`).",
2081
+ description: "One row per finished audit, oldest first, as the agent's learning keeps them: a run a promoted learned workflow answered alone (path `workflow`; a run it handed back is never drawn) is audited at 1 in `learning.audit_every` (drawn from its id): its shadow run, the same agent on the same input with learning off, answers it again, and the row says whether the two answers say the same and what each run cost (the shadow's is the agent's learning cost; the shadow is no row of the run list, and GET /runs/{id} reads it with `audit_of`). A capped run's shadow starts at its end, capped at what its cap left, so the two never spend past it: with less than a run's smallest cap left, none starts (`skipped`). A shadow never waits on a person: one that would (an approval, a question, a raise of its cap) ends there at once with no answer (`parked`); neither is counted. Each row compares the served run's answer at the audit's start (`turn`), never a follow-up's. An owner's grade of a run the workflow answered alone is a row too. The hold rule reads them (`learning.hold_window`, `learning.hold_disagree`).",
2066
2082
  parameters: [AGENT_ID],
2067
2083
  responses: { "200": json(closed({ agent: { type: "string" }, audits: { type: "array", items: AUDIT_ROW } }), "The agent's audit rows."), ...errors(401, 403, 404, 429, 500) },
2068
2084
  "x-agentrun-serve": "promotion/1",
@@ -2076,7 +2092,7 @@ const LEARNING_EXTENSIONS = {
2076
2092
  },
2077
2093
  delete: {
2078
2094
  operationId: "deleteAgentLearning", tags: ["agents"], summary: "Reset the agent's learning: everything it learned deleted, the agent and its runs kept",
2079
- description: "Deletes what the agent learned: its learning folder whole (`corrections.md`, its learned workflows, their history and the audit ledger), on this server and on every Archil disk its runs used (its own disk, and a disk a run's launch named, where Archil mode keeps it; nothing else on those disks), then its promotion records and grades. The agent, its definition, its runs and everything kept of them (their files, timelines, costs and each one's learning) stay, so the run list, `GET /stats` and `GET /usage` read the same after; a served run's cost keeps its share of its workflow revision's compile and check (the revision's name, digest and `compile_after` are kept for it, nothing else of its records). A run's learning diff (`GET /runs/{run_id}/learning/diff`, the text it merged) is the folder's and goes with it: 404 after. From then on no run is given a correction or a learned workflow of before, and the agent's next run takes the agent path; learning starts again from the agent's runs, as for a new agent. Its learning work in flight is stopped first: a run that exists only for learning (a check's or an owner's replay, an audit's shadow run) is cancelled and waited for. A run of the agent's own still going (queued, running or parked) carries its learning with it (what it was started with, its compile turn and look-back at its end) and is never cancelled for this: while one is, or a learning run this server cannot end (an SDK run) or one not ended in time, it is `409 learning_busy`, each named in `details.runs`, and nothing of the agent's learning is deleted. `204` when done; idempotent: an agent that never learned, or one reset already, is `204` too. An agent being deleted is `409 agent_not_runnable`. While an Archil disk that holds its learning can't be reached (Archil off on this server, no key, or Archil refusing) it is `503 unavailable`, retryable, with its learning here and its records kept; the next call finishes it. A reset that failed on the way (anything but `409`) may have removed part of the agent's learning, so from then on learning reads no run from before it, as after a reset done. Resetting takes the owner's session (the password sign-in, or the console on a server bound to loopback) or the API token, as deleting an agent does: any other console session is `403 forbidden`. Served in the API-only profile (`AGENTRUN_API_ONLY=1`) too, with the token, as the other learning writes take it.",
2095
+ description: "Deletes what the agent learned: every save of its learning (`corrections.md`, its learned workflows, their history), its audit ledger, its promotion records and grades. The agent, its definition, its runs and everything kept of them (their files, timelines, costs and each one's learning) stay, so the run list, `GET /stats` and `GET /usage` read the same after; a served run's cost keeps its share of its workflow revision's compile and check (the revision's name, digest and `compile_after` are kept for it, nothing else of its records). A run's learning diff (`GET /runs/{run_id}/learning/diff`, the text it merged) is read from its save and goes with it: 404 after. From then on no run is given a correction or a learned workflow of before, and the agent's next run takes the agent path; learning starts again from the agent's runs, as for a new agent. Its learning work in flight is stopped first: a run that exists only for learning (a check's or an owner's replay, an audit's shadow run) is cancelled and waited for. A run of the agent's own still going (queued, running or parked) carries its learning with it (what it was started with, its compile turn and look-back at its end) and is never cancelled for this: while one is, or a learning run this server cannot end (an SDK run) or one not ended in time, it is `409 learning_busy`, each named in `details.runs`, and nothing of the agent's learning is deleted. `204` when done; idempotent: an agent that never learned, or one reset already, is `204` too. An agent being deleted is `409 agent_not_runnable`. While an Archil disk that holds its learning can't be reached (Archil off on this server, no key, or Archil refusing) it is `503 unavailable`, retryable, with its learning here and its records kept; the next call finishes it. A reset that failed on the way (anything but `409`) may have removed part of the agent's learning, so from then on learning reads no run from before it, as after a reset done. Resetting takes the owner's session (the password sign-in, or the console on a server bound to loopback) or the API token, as deleting an agent does: any other console session is `403 forbidden`. Served in the API-only profile (`AGENTRUN_API_ONLY=1`) too, with the token, as the other learning writes take it.",
2080
2096
  parameters: [AGENT_ID],
2081
2097
  responses: { "204": { description: "The agent's learning is reset." }, ...errors(401, 403, 404, 409, 429, 500, 503) },
2082
2098
  "x-agentrun-serve": "learningreset/1",
@@ -2180,7 +2196,7 @@ const LEARNING_EXTENSIONS = {
2180
2196
  "/agents/{agent_id}/learning/workflows/{name}/revisions/{digest}/replays": {
2181
2197
  post: {
2182
2198
  operationId: "startLearnedWorkflowReplay", tags: ["agents"], summary: "Re-check a learned workflow's revision on the agent's own runs: a held revision, or an edited one",
2183
- description: `Starts the one check a run's claim starts for a new revision (GET /agents/{agent_id}/learning/promotions explains it): one replay run of the agent per input, each the workflow alone at workflow cost, its reads live and its writes answered only from the agent's own run's recording, never sent, scored against the known answers (a grade's expected answer, else the agent's own recorded one). \`inputs\`: \`held\` (the default), the runs the revision's last check ran on, or, with none, the agent's last \`compile_after\` completed runs; a number from 1 to ${COMPILE_AFTER_MAX}, that many of the agent's newest completed runs. Each is a completed run of the agent's own (path \`agent\` or \`handed_back\`), with no uploaded file, whose input the revision takes. Its record is a check's (\`replaying\` then promoted or held, with its numbers, as a claim-started one is), decided once every replay run ended: at a run's claim that lays the revision, or at its read (GET .../replays/{replay_id}). Its replay runs are handed no per-run MCP credentials. The revision is \`digest\`, the first 16 hex of its workflow.json's sha256: one a promotion record names (read at its commit), or the one on the learning folder's main. 404 for an unknown agent, workflow or revision. 409 \`replay_conflict\` when it is replaying already, another revision of the workflow replays (one at a time, and a running check finishes), it is promoted (it serves already), none of the inputs asked for fits it (nothing is reserved and no run starts), or the agent's runs take no learned workflow here. 409 \`agent_not_runnable\` for an archived agent, as a run's start is: nothing is reserved. 400 for any other \`inputs\`. Only the owner, signed in with their password, starts one: the console's password session alone, from this server's own origin with a JSON body; every token is 403 \`forbidden\`.`,
2199
+ description: `Starts the one check a run's claim starts for a new revision (GET /agents/{agent_id}/learning/promotions explains it): one replay run of the agent per input, each the workflow alone at workflow cost, its reads live and its writes answered only from the agent's own run's recording, never sent, scored against the known answers (a grade's expected answer, else the agent's own recorded one). \`inputs\`: \`held\` (the default), the runs the revision's last check ran on, or, with none, the agent's last \`compile_after\` completed runs; a number from 1 to ${COMPILE_AFTER_MAX}, that many of the agent's newest completed runs. Each is a completed run of the agent's own (path \`agent\` or \`handed_back\`), with no uploaded file, whose input the revision takes. Its record is a check's (\`replaying\` then promoted or held, with its numbers, as a claim-started one is), decided once every replay run ended: at a run's claim that lays the revision, or at its read (GET .../replays/{replay_id}). Its replay runs are handed no per-run MCP credentials. The revision is \`digest\`, the first 16 hex of its workflow.json's sha256: one a promotion record names, or the agent's newest. 404 for an unknown agent, workflow or revision. 409 \`replay_conflict\` when it is replaying already, another revision of the workflow replays (one at a time, and a running check finishes), it is promoted (it serves already), none of the inputs asked for fits it (nothing is reserved and no run starts), or the agent's runs take no learned workflow here. 409 \`agent_not_runnable\` for an archived agent, as a run's start is: nothing is reserved. 400 for any other \`inputs\`. Only the owner, signed in with their password, starts one: the console's password session alone, from this server's own origin with a JSON body; every token is 403 \`forbidden\`.`,
2184
2200
  security: [{ ownerSession: [] }],
2185
2201
  parameters: [AGENT_ID, { name: "name", in: "path", required: true, description: "The learned workflow's folder name, `workflows/<name>/`.", schema: { type: "string" } }, { name: "digest", in: "path", required: true, description: "The revision: the first 16 hex of its workflow.json's sha256.", schema: { type: "string" } }],
2186
2202
  requestBody: { required: true, content: { "application/json": { schema: { type: "object", additionalProperties: false, properties: { inputs: { oneOf: [{ const: "held" }, { type: "integer", minimum: 1, maximum: COMPILE_AFTER_MAX }], default: "held", description: "`held`: the runs it was last checked on; a number: the agent's newest that many completed runs." } } } } } },
@@ -2297,7 +2313,7 @@ const EXTENSIONS = {
2297
2313
  delete: {
2298
2314
  operationId: "deleteAgent", tags: ["agents"], summary: "Delete an agent another system owns, or purge an archived agent made here",
2299
2315
  description: "An agent made here, once archived (`POST /agents/{agent_id}/archive`), is purged by the rule `DELETE /runs/{run_id}` purges a run by: its revisions' content (instructions, skills, notes), its name and description, its learning, its triggers, its saved sign-ins, its own computer, disk and folders go, and each of its runs is purged (a tombstone, its cost kept). An uploaded package (`upload:<name>`, `POST /templates/import` with `files`) it was applied from goes in the same write when no other agent here, archived or not, was applied from it; a package imported from GitHub stays. The agent's row stays as its tombstone: every route of it answers `410 purged` with `details` {agent_id, archived_at, purged_at}, and no list shows it. What its runs cost stays in `/usage` and `/stats`. `204` when it is purged; a second `DELETE` is `204` too. An agent made here that is not archived is `409 agent_not_archived`, nothing purged; `409 run_not_final` while a run of it is live (`details.runs`), nothing purged; `503 unavailable` as below, the next `DELETE` finishing it. Purging one agent touches no other. Deleting or purging takes the owner's session (the password sign-in, or the console on a server bound to loopback) or the API token: any other console session is `403 forbidden`.\n\n" +
2300
- "An agent made by an inline run (`POST /runs` with `external`) is deleted whole, archived or not: its runs and everything kept of them (journals, launch records, messages, files), its triggers, its learning, its saved sign-ins, its own computer and disk, its revisions and the agent. A run whose launch named an Archil disk (`archil_disk`, the caller's) has its own folder there deleted; the disk and everything else on it are kept, and a disk Archil says is gone has nothing left to delete. Shared things (MCP servers, keys, computers) are kept. In order: the agent refuses new runs (a mark in the store that outlives a restart: a run, an inline run, a trigger's firing, an SDK run or a message that would open one of its runs again is `409 agent_not_runnable`, as is a new trigger of it, off too, a trigger moved to it or turned on, and a write to its home or learning), and its runs still going are cancelled and waited for; then its learning (its learning folder, and its promotions and grades); then the rest. `204` when it is gone; a second `DELETE` is `404`. `409 runs_in_flight` (a run did not end in time, or only its application ends it) and `409 learning_busy` (learning work in flight; each names what in `details.runs`) leave the agent refusing runs, as does `503 unavailable` while something it owns elsewhere is not deleted there yet: a trigger's registration upstream (Composio), a saved sign-in at its vendor, its own computer at its provider, its Archil disk (Archil failing or not reached, a run of another agent on it, or Archil off on this server), or a run's folder on a disk its launch named (Archil failing, a computer still holding the folder, or Archil off), or a trigger that reached the agent after its triggers were removed. Each is deleted there before the record here that names it, so none is left behind: send the `DELETE` again, which also finishes a delete that stopped part way.",
2316
+ "An agent made by an inline run (`POST /runs` with `external`) is deleted whole, archived or not: its runs and everything kept of them (journals, launch records, messages, files), its triggers, its learning, its saved sign-ins, its own computer and disk, its revisions and the agent. A run whose launch named an Archil disk (`archil_disk`, the caller's) has its own folder there deleted; the disk and everything else on it are kept, and a disk Archil says is gone has nothing left to delete. Shared things (MCP servers, keys, computers) are kept. In order: the agent refuses new runs (a mark in the store that outlives a restart: a run, an inline run, a trigger's firing, an SDK run or a message that would open one of its runs again is `409 agent_not_runnable`, as is a new trigger of it, off too, a trigger moved to it or turned on, and a write to its home or learning), and its runs still going are cancelled and waited for; then its learning (its saves, its promotions, grades and audits); then the rest. `204` when it is gone; a second `DELETE` is `404`. `409 runs_in_flight` (a run did not end in time, or only its application ends it) and `409 learning_busy` (learning work in flight; each names what in `details.runs`) leave the agent refusing runs, as does `503 unavailable` while something it owns elsewhere is not deleted there yet: a trigger's registration upstream (Composio), a saved sign-in at its vendor, its own computer at its provider, its Archil disk (Archil failing or not reached, a run of another agent on it, or Archil off on this server), or a run's folder on a disk its launch named (Archil failing, a computer still holding the folder, or Archil off), or a trigger that reached the agent after its triggers were removed. Each is deleted there before the record here that names it, so none is left behind: send the `DELETE` again, which also finishes a delete that stopped part way.",
2301
2317
  parameters: [AGENT_ID],
2302
2318
  responses: { "204": { description: "Deleted, or purged." }, ...errors(401, 403, 404, 409, 429, 500, 503) },
2303
2319
  "x-agentrun-serve": "agentdelete/1",
@@ -2369,6 +2385,7 @@ const EXTENSIONS = {
2369
2385
  { name: "agent", in: "query", required: false, description: "Only this agent's runs.", schema: ref("schemas/Id") },
2370
2386
  { name: "revision", in: "query", required: false, description: "Only runs of this revision.", schema: { type: "string" } },
2371
2387
  { name: "status", in: "query", required: false, description: "Only runs with this status.", schema: ref("schemas/RunStatus") },
2388
+ { name: "scope", in: "query", required: false, description: "Factory scope: active includes every nonterminal execution and continuable stopped turn, including archived runs; review selects unarchived terminal escalations and failures separately. Both exclude imported history and use keyset cursors bound to scope, agent and revision. Cannot combine with status or archived. Page limit defaults to 50 (maximum 100). No scope preserves the ordinary history listing.", schema: { enum: ["active", "review"] } },
2372
2389
  { name: "archived", in: "query", required: false, description: "true lists only archived runs; false, the default, the others.", schema: { type: "boolean" } },
2373
2390
  LABEL_PARAMETER,
2374
2391
  SOURCE_PARAMETER,
@@ -2654,7 +2671,7 @@ const EXTENSIONS = {
2654
2671
  "/runs/{run_id}": {
2655
2672
  delete: {
2656
2673
  operationId: "deleteRun", tags: ["runs"], summary: "Purge a run's content and keep its cost",
2657
- description: "Purges a run that is not live: what it was given and what it did go, what it cost stays. Gone: its launch record (its input and prompt), its journal and timeline, its messages and commands, its outputs and files, the answers kept under its idempotency keys, its folders (on this machine, and its own folder on an Archil disk, its agent's or one its launch named; the disk and everything else on it are kept), its settings, the grades its agent keeps of it, and its kept learning's content (its learning's end, merged or dropped, stays, as `/stats` counts it). Its row stays as its tombstone: every route of it answers `410 purged` with `details` {run_id, agent_id, state, started_at, ended_at, cost_usd, cost_upper_bound, tools_usd, purged_at}, and no run list shows it. `/usage`, `/stats` and the spend a cap reads sum it as before: no total moves. The runs made from it are purged with it, each the same way: its audit's shadow run, the replay runs of its input and a learning run its kept learning names. Once it is purged, no replay or shadow run of it is started. Its agent, the agent's other runs and what its agent learned are kept: a promotion record keeps its decision, numbers and run ids (the run's among them), and what it copied from the run (a disagreement's input and answers, the grader's words, and the words a hold's reason quoted from them) is blanked. A run's purge removes its diff files and its feedback lines from the folder's current files and puts each learned workflow whose workflow.json it changed last back to the version before it, the newest no purged run wrote (off main when it wrote it new), and the folder's history no longer serves its merge; the bytes stay in the folder's .git until a learning reset (DELETE /v2/agents/{id}/learning) or the agent's purge, which delete the folder whole. `204` when it is purged; a second `DELETE` is `204` too, and takes off what is left of its text in the learning folder; a run this server never had is `404`. Live (queued, working, waiting on a person or an approval, or held by a runner): `409 run_not_final` (`details.runs`, the run or each run made from it that is live, or a replay or shadow run of it a check or an audit started while the `DELETE` ran, which the next `DELETE` purges first), nothing purged; cancel it first (`POST /runs/{run_id}/cancel`). A run that ended and takes a follow-up (`idle`), or that a person stopped, is not live; one that reads so before its runner has written it ended is waited for (up to 30 seconds), then purged. `503 unavailable` while its folder on an Archil disk is not deleted there yet (Archil failing or off, a computer still holding the folder), or while its agent's learning folder can't be written: the run is not purged (or, purged before, keeps its text in that folder), and the `DELETE` sent again finishes it, as it finishes a purge that stopped part way. Takes the owner's session (the password sign-in, or the console on a server bound to loopback) or the API token: any other console session is `403 forbidden`.",
2674
+ description: "Purges a run that is not live: what it was given and what it did go, what it cost stays. Gone: its launch record (its input and prompt), its journal and timeline, its messages and commands, its outputs and files, the answers kept under its idempotency keys, its folders (on this machine, and its own folder on an Archil disk, its agent's or one its launch named; the disk and everything else on it are kept), its settings, the grades its agent keeps of it, and its kept learning's content (its learning's end, merged or dropped, stays, as `/stats` counts it). Its row stays as its tombstone: every route of it answers `410 purged` with `details` {run_id, agent_id, state, started_at, ended_at, cost_usd, cost_upper_bound, tools_usd, purged_at}, and no run list shows it. `/usage`, `/stats` and the spend a cap reads sum it as before: no total moves. The runs made from it are purged with it, each the same way: its audit's shadow run, the replay runs of its input and a learning run its kept learning names. Once it is purged, no replay or shadow run of it is started. Its agent, the agent's other runs and what its agent learned are kept: a promotion record keeps its decision, numbers and run ids (the run's among them), and what it copied from the run (a disagreement's input and answers, the grader's words, and the words a hold's reason quoted from them) is blanked. A run's purge deletes its learning rows in the same transaction: each note and workflow version it wrote (each workflow then reads as the version before it, the newest no purged run wrote, or none when it wrote it new), its grades and audits, and the promotion and audit records of each revision only it wrote; its saves stay as facts with no words, and its learning diff goes (a purged run's routes answer `410 purged`). `204` when it is purged; a second `DELETE` is `204` too; a run this server never had is `404`. Live (queued, working, waiting on a person or an approval, or held by a runner): `409 run_not_final` (`details.runs`, the run or each run made from it that is live, or a replay or shadow run of it a check or an audit started while the `DELETE` ran, which the next `DELETE` purges first), nothing purged; cancel it first (`POST /runs/{run_id}/cancel`). A run that ended and takes a follow-up (`idle`), or that a person stopped, is not live; one that reads so before its runner has written it ended is waited for (up to 30 seconds), then purged. `503 unavailable` while its folder on an Archil disk is not deleted there yet (Archil failing or off, a computer still holding the folder): the run is not purged, and the `DELETE` sent again finishes it, as it finishes a purge that stopped part way. Takes the owner's session (the password sign-in, or the console on a server bound to loopback) or the API token: any other console session is `403 forbidden`.",
2658
2675
  parameters: [ref("parameters/RunId")],
2659
2676
  responses: { "204": { description: "Purged, now or before. A run's purge removes its diff files and its feedback lines from the folder's current files and puts each learned workflow whose workflow.json it changed last back to the version before it, the newest no purged run wrote (off main when it wrote it new), and the folder's history no longer serves its merge; the bytes stay in the folder's .git until a learning reset (DELETE /v2/agents/{id}/learning) or the agent's purge, which delete the folder whole." }, ...errors(401, 403, 404, 409, 429, 500, 503) },
2660
2677
  "x-agentrun-serve": "purge/1",
@@ -2788,10 +2805,11 @@ const EXTENSIONS = {
2788
2805
  },
2789
2806
  put: {
2790
2807
  operationId: "putWorkspaceArchil", tags: ["local"], summary: "Turn Mode 2 on: run folders on Archil disks, one per agent",
2791
- description: "Replaces the Archil settings (the account key's region and its S3 URL, and an exec image pinned by digest when given) and seals the account key (ARCHIL_API_KEY) under the server's seal key when given; null removes it, and a key not given is kept. There is no server-wide disk: each agent gets its own, made in this region on its first run that uses it (`agentrun-<server id>-i-<agent id>`), and a run may name another (`archil_disk` on its start), so `diskId` is refused. No disk token is kept: a computer's mount credential is minted per run from the account key, so ARCHIL_DISK_TOKEN is refused like any field Archil does not take. Any PUT here is a secret write, whatever its body: it takes the owner's signed-in session, and the API token is 403, since the region and S3 URL say where every run's files go. A field that is not right, or an image not pinned by digest, is 422 input_invalid with its fields, and nothing is saved. While the server's environment sets the settings (GET's `source` is `env`), it is 409 key_set_by_server naming its variables, and nothing is saved. The answer never holds a key.",
2808
+ description: "Replaces the Archil settings (the account key's region; its S3 URL, which for a region this server knows (GET's `regions`) may be left out and is then that region's, and a region it doesn't know needs; and an exec image pinned by digest when given) and seals the account key (ARCHIL_API_KEY) under the server's seal key when given; null removes it, and a key not given is kept. There is no server-wide disk: each agent gets its own, made in this region on its first run that uses it (`agentrun-<server id>-i-<agent id>`), and a run may name another (`archil_disk` on its start), so `diskId` is refused. No disk token is kept: a computer's mount credential is minted per run from the account key, so ARCHIL_DISK_TOKEN is refused like any field Archil does not take. Any PUT here is a secret write, whatever its body: it takes the owner's signed-in session, and the API token is 403, since the region and S3 URL say where every run's files go. A field that is not right, or an image not pinned by digest, is 422 input_invalid with its fields, and nothing is saved. While the server's environment sets the settings (GET's `source` is `env`), it is 409 key_set_by_server naming its variables, and nothing is saved. The answer never holds a key.",
2792
2809
  requestBody: {
2793
2810
  required: true,
2794
- content: { "application/json": { schema: closedWith({ region: { type: "string", minLength: 1 }, s3Url: { type: "string", format: "uri", pattern: "^https://" } }, {
2811
+ content: { "application/json": { schema: closedWith({ region: { type: "string", minLength: 1 } }, {
2812
+ s3Url: { type: "string", format: "uri", pattern: "^https://", description: "The region's S3 endpoint. Left out for a region this server knows (GET's `regions`), that region's." },
2795
2813
  image: { type: "string", pattern: "^[^\\s@]+@sha256:[0-9a-f]{64}$" },
2796
2814
  keys: { type: "object", additionalProperties: false, properties: Object.fromEntries(ARCHIL_KEY_NAMES.map((name) => [name, { type: ["string", "null"], minLength: 1, "x-agentrun-secret": true }])) },
2797
2815
  }) } },
@@ -3022,7 +3040,7 @@ const EXTENSIONS = {
3022
3040
  },
3023
3041
  put: {
3024
3042
  operationId: "turnOnClaudeLogin", tags: ["local"], summary: "Turn on Claude Code's login on this machine for claude-agent's runs",
3025
- description: "Runs claude-agent on the login at `place` (default `agentrun`), on this machine's runner only. 403 forbidden in one line where more than one person can start runs (more than one API token, the API-only profile); 422 input_invalid without `only_me` true. A model a revision names on a gateway or OpenRouter still runs on its key. 404 not_found, naming the operation, when AGENTRUN_CLAUDE_CODE_LOGIN is `off`. A secret write: the owner's signed-in session alone (ownerSession).",
3043
+ description: "Runs claude-agent on the login at `place` (default `agentrun`), on this machine's runner only. 403 forbidden in one line where more than one person can start runs (more than one API token, the API-only profile); 422 input_invalid without `only_me` true. 403 forbidden, too, at `agentrun` when AgentRun's own login folder (`<data>/claude-login`) is a link, in words naming it and where it leads: the login a sign-out removes is always a folder of AgentRun's own. A model a revision names on a gateway or OpenRouter still runs on its key. 404 not_found, naming the operation, when AGENTRUN_CLAUDE_CODE_LOGIN is `off`. A secret write: the owner's signed-in session alone (ownerSession).",
3026
3044
  "x-agentrun-secret": true,
3027
3045
  security: [{ ownerSession: [] }],
3028
3046
  requestBody: { required: true, content: { "application/json": { schema: { type: "object", additionalProperties: false, required: ["only_me"], properties: { place: { enum: ["agentrun", "machine"], description: "Where the login is (see the answer's `place`)." }, only_me: { const: true, description: "The owner's word that they alone run agents on this server, since its runs would use their Claude plan." } } } } } },
@@ -3048,6 +3066,19 @@ const EXTENSIONS = {
3048
3066
  "x-agentrun-serve": "claudelogin/1",
3049
3067
  },
3050
3068
  },
3069
+ "/settings/claude-login/sign-out": {
3070
+ post: {
3071
+ operationId: "signOutClaudeLogin", tags: ["local"], summary: "Sign out of Claude Code's login on this machine: AgentRun's own login removed, the mode off",
3072
+ description: "For a person to sign in fresh, or as another account: a turn-off leaves the login as the CLI keeps it, so the next turn-on reads it again. Ends a sign-in that waits, turns the mode off, runs the pinned CLI's own `claude auth logout` on AgentRun's own login folder (`<data>/claude-login`), which removes its credentials file and, on macOS, its Keychain item for that folder, then removes the folder (credentials, account, profiles, refresh locks), the login's signed-in note and the runner's token reader, whatever the CLI said. The next turn-on finds no login (`signed_out`) and the sign-in starts as before. Runs already going on the login are left as a turn-off leaves them: each keeps the token its CLI holds, and fails saying the login is signed out at its next read of it. `confirmed` false: signed out here and the mode off, and `message` says what may remain: the CLI didn't confirm its own sign-out, or its step failed, named (on macOS its Keychain item may remain); a removal failed, each named with its path (the others still happen); or the folder had become a link, which alone is removed, with no CLI run through it and nothing it leads to touched. 403 forbidden, with nothing touched, when the login is this machine's own (`place` `machine`: the person's `~/.claude` or CLAUDE_CONFIG_DIR): AgentRun never signs it out, and the words say to run `claude auth logout` in a terminal there. 404 not_found, naming the operation, when AGENTRUN_CLAUDE_CODE_LOGIN is `off`. A secret write: the owner's signed-in session alone (ownerSession).",
3073
+ "x-agentrun-secret": true,
3074
+ security: [{ ownerSession: [] }],
3075
+ responses: {
3076
+ "200": json({ type: "object", additionalProperties: false, required: ["confirmed", "login"], properties: { confirmed: { type: "boolean", description: "Whether all of the login is gone: the CLI confirmed its own sign-out and every removal landed. The CLI's sign-out runs where the folder is already gone too, so a retry after an unconfirmed sign-out is true only where the CLI confirms." }, message: { type: "string", description: "With `confirmed` false: what may remain, in words (the CLI's step unconfirmed or failed, a removal that failed, a link left in place of the folder)." }, login: CLAUDE_LOGIN } }, "Signed out here."),
3077
+ ...errors(401, 403, 404, 429, 500),
3078
+ },
3079
+ "x-agentrun-serve": "claudelogin/1",
3080
+ },
3081
+ },
3051
3082
  "/settings/model-gateway": {
3052
3083
  get: {
3053
3084
  operationId: "getModelGateway", tags: ["local"], summary: "The model gateway in force: the environment's, the one saved here, or none",
@@ -3822,7 +3853,27 @@ export const DEFINITION_INPUT_OPTIONAL = ["instructions", "version", "skills", "
3822
3853
  /** Definition's own: only instructions ever misses from an answer (a workflow revision keeps none); version, skills
3823
3854
  * and tools are always sent (agents-store.ts definitionOf), so they stay required there. */
3824
3855
  export const DEFINITION_OPTIONAL = ["instructions"];
3856
+ const FACTORY_ACTIVITY = {
3857
+ ...closed({
3858
+ lifecycle_version: { type: "string", pattern: "^[0-9]+$", description: "Committed lifecycle watermark captured in the same store snapshot as this run's projection. The projection is built once per change of the run and kept until the next, so a run that has not changed keeps its watermark from one read to the next. Compare as an integer when reconciling scoped pages; a later watermark supersedes an earlier projection of the same run." },
3859
+ source: { enum: ["managed", "native", "sdk", "cli"], description: "What runs the session: `managed` and `native`, AgentRun's own runner (a native run through the harness on its machine); `sdk`, a backend's SDK wrapper; `cli`, an existing CLI session connected for learning. An `sdk` or `cli` session is run by its own application, which reports it here." }, runtime: { type: "string", description: "The runtime the session recorded (`codex-sdk`, `codex-cli`, `claude-code-cli`, a native harness), else the run's harness." }, control: { enum: ["managed", "observed"], description: "`observed` for an `sdk` or `cli` session: AgentRun refuses to stop or cancel it, so every one of its `controls` is false." },
3860
+ controls: closed({ stop: { type: "boolean" }, cancel: { type: "boolean" }, approve: { type: "boolean" } }),
3861
+ observation: closed({
3862
+ basis: { enum: ["runner", "connector", "unreported"] }, status: { enum: ["current", "offline", "revoked", "unreported"] },
3863
+ last_seen_at: { type: ["string", "null"], format: "date-time" },
3864
+ }),
3865
+ last_activity_at: { type: ["string", "null"], format: "date-time" },
3866
+ github: { oneOf: [{ type: "null" }, closed({
3867
+ repository: { type: "string" }, issue: { type: ["integer", "null"], minimum: 1 }, pull_request: { type: ["integer", "null"], minimum: 1 },
3868
+ head_sha: { type: ["string", "null"], pattern: "^[0-9a-f]{40}$" }, provenance: { enum: ["launch", "github_trigger"] },
3869
+ })] },
3870
+ children: { type: "array", items: closed({ id: { type: "string" }, conversation_id: { type: "integer", minimum: 0 }, parent_call_id: { type: "string" }, status: { enum: ["active", "completed"] }, label: { type: ["string", "null"], maxLength: 160 } }) },
3871
+ }),
3872
+ description: "Present on scoped factory lists. Source reporting and supported controls, not an execution authorization. Connector health does not prove session liveness; an SDK's or a connected CLI session's heartbeat is unreported. GitHub links come only from explicit launch binding or a trusted GitHub trigger, never prose. Children are active durable subagent conversations with recorded ownership, not standalone runs; an empty list makes no claim about unreported native/SDK children.",
3873
+ "x-agentrun-serve": "factory/1",
3874
+ };
3825
3875
  const RUN_FIELDS = {
3876
+ factory: FACTORY_ACTIVITY,
3826
3877
  console_url: CONSOLE_URL("run"),
3827
3878
  revision: { type: "string", description: "The id of the agent revision the run runs.", "x-agentrun-serve": "serve/1" },
3828
3879
  kind: { enum: ["agentic", "workflow"], description: "The revision's kind: an agentic run, or a workflow run.", "x-agentrun-serve": "serve/1" },
@@ -3982,6 +4033,10 @@ const RUN_TOOL_KEYS = {
3982
4033
  "x-agentrun-serve": "runkeys/1",
3983
4034
  };
3984
4035
  const FIELD_EXTENSIONS = {
4036
+ RunList: {
4037
+ scope: { enum: ["active", "review"], description: "Present only for a scoped factory list.", "x-agentrun-serve": "factory/1" },
4038
+ observed_at: { type: "string", format: "date-time", description: "When this scoped read began. Each run is a consistent snapshot; pages are not one frozen snapshot. Re-read from the first page to discover newer admissions.", "x-agentrun-serve": "factory/1" },
4039
+ },
3985
4040
  Limits: {
3986
4041
  free_model_requests: { type: "integer", minimum: 1, description: "The most requests on free models a run makes: a free model's catalog price is all zeros, so a dollar cap cannot stop it. AGENTRUN_FREE_MODEL_REQUESTS, else 60. The request after that many is not sent, and the run ends `failed`, its error `spend_cap_reached`: \"Not sent: this run reached its 60-request limit for free models.\" (the number is this one). Every free model's request counts, the run's own, its subagents', its side calls and any cut by a crash, capped or not; a paid request, a paid tool call and a workflow decision never do. ChatGPT-plan requests don't count.", "x-agentrun-serve": "freerequests/1" },
3987
4042
  },
@@ -4015,7 +4070,6 @@ const FIELD_EXTENSIONS = {
4015
4070
  followup_usd: { type: ["number", "null"], minimum: 0, description: "On the run read alone, a part of `learning_usd`: what the run's learning spent after its job answered besides its compile turns (a follow-up round's turns, feedback the run was given). 0 for none; null while the run is at work or unknown.", "x-agentrun-serve": "ledger/1" },
4016
4071
  shadow_usd: { type: ["number", "null"], minimum: 0, description: "On the run read alone, a part of `learning_usd`: its audit shadow's cost (0 when none ran). Null while the shadow is queued or running, or its cost is unknown: never $0.", "x-agentrun-serve": "ledger/1" },
4017
4072
  share_usd: { type: ["number", "null"], minimum: 0, description: "On the run read alone, a part of `learning_usd`: its share of the learning spend of the workflow revision that served it (that revision's compile turns and check replays, spread over the first `compile_after` runs it serves, the cost route's `bill.revisions`). 0 for a run no revision served; null while unknown. `followup_usd`, `shadow_usd` and this add up to `learning_usd`.", "x-agentrun-serve": "ledger/1" },
4018
- degraded: { type: "boolean", const: true, description: "On the run read alone, set only when this read could not ask the purge gate (a store read of a purged run's writer failed): `learning_usd` and `all_in_usd` were then counted over the agent's workflow revisions with no purged one left out, so they may count a revision a purged run wrote as the one serving. Figures only: no text is read. Absent on every read that asked the gate.", "x-agentrun-serve": "purge/1" },
4019
4073
  plan: {
4020
4074
  type: "object", additionalProperties: false, required: ["requests", "tokens", "on"],
4021
4075
  properties: {
@@ -4148,6 +4202,7 @@ const FIELD_EXTENSIONS = {
4148
4202
  example: { description: "A value the field accepts, said in `message` too: the operation's documented request body's value there, else the schema's example, const or option, else one made from its type; each is suggested only once the route's own check of the body takes it in place (else the schema, for a value the document gives), so this server never suggests a value it refuses. Absent when there is none. For a field the body does not keep that an object inside it does, the body with the field where it belongs, as `fix` shows it: `{\"definition\": {\"name\": \"Due diligence\"}}`.", "x-agentrun-serve": "explain/1" },
4149
4203
  },
4150
4204
  RunSummary: {
4205
+ computer: RUN_COMPUTER,
4151
4206
  sdk: SDK_RUN,
4152
4207
  cli_learning: CLI_LEARNING_RUN,
4153
4208
  native: NATIVE_RUN,
@@ -4349,7 +4404,7 @@ const FIELD_EXTENSIONS = {
4349
4404
  type: "object", additionalProperties: false, required: ["pending"],
4350
4405
  description: "For an agent that learns (its current revision `learning: true`, on a server whose learning is on): what waits on it. Absent for any other agent.",
4351
4406
  properties: {
4352
- pending: { type: "integer", minimum: 0, description: "How many of its learned workflow drafts wait for its owner's OK: held with `status: pending` on its learning folder's main (approve them on GET /agents/{agent_id}/learning)." },
4407
+ pending: { type: "integer", minimum: 0, description: "How many of its learned workflow drafts wait for its owner's OK: held with `status: pending` on its newest learning save (approve them on GET /agents/{agent_id}/learning)." },
4353
4408
  },
4354
4409
  "x-agentrun-serve": "serve/1",
4355
4410
  },
@@ -4525,15 +4580,18 @@ const FIELD_EXTENSIONS = {
4525
4580
  // widening is a mark of its own. decisions/3: a provider takes `route` (parallel's, on Parallel's API or OpenRouter), which a
4526
4581
  // client that validates against decisions/2 refuses.
4527
4582
  "Capabilities/places": {
4583
+ // place/5: default_place took null (no default: name a box), which a client that validates against place/4 refuses,
4584
+ // and default_reason is there exactly when it is null.
4528
4585
  default_place: {
4529
4586
  oneOf: [
4530
4587
  { type: "object", additionalProperties: false, required: ["mode"], properties: { mode: { const: "runner" } } },
4531
4588
  { type: "object", additionalProperties: false, required: ["mode", "box"], properties: { mode: { const: "sandbox" }, box: { enum: [...BOX_IDS] } } },
4589
+ { type: "null" },
4532
4590
  ],
4533
- description: "The place a NEW agentic agent that names none and has a shell is saved with, written on its revision at its create: the Docker box (`{\"mode\": \"sandbox\", \"box\": \"docker\"}`) where this server has docker, with tools [\"bash\", \"bash_background\", \"bash_output\", \"bash_input\", \"bash_signal\", \"bash_list\"] when the definition names no tools; else the runner, with `default_reason`. One whose named tools need no shell is saved with no place and runs on the runner. It is also where an agentic revision saved with no place and a shell tool runs, resolved at each run: a workflow, a revision whose tools need no shell, and a revision that names a tool a box refuses, run on the runner. (It replaces `places.default`, which said `runner`.)",
4534
- "x-agentrun-serve": "place/4",
4591
+ description: "The place a NEW agentic agent that names none and has a shell is saved with, written on its revision at its create, and where an agentic revision saved with no place and a shell tool runs, resolved at each run. The Docker box (`{\"mode\": \"sandbox\", \"box\": \"docker\"}`) where this server has docker, with tools [\"bash\", \"bash_background\", \"bash_output\", \"bash_input\", \"bash_signal\", \"bash_list\"] when the definition names no tools. Where it has no docker: in Mode 2, where the runner's shell is Archil's serverless exec, the runner (`{\"mode\": \"runner\"}`), and such a create saves with no place; in Mode 1, where the runner has no shell, null, meaning no default: a new agent names a box or the runner, `default_reason` gives the words, and a create that names no place and no tools, or a tool that runs only in a box, is refused `422 input_invalid` at field `definition.place`, reason `missing`, in those words, no other box picked for it. A client tells the cases apart by `default_place` being null, never by reading `default_reason`. One whose named tools need no shell is saved with no place and runs on the runner, as do a workflow and a revision that names a tool a box refuses. (It replaces `places.default`, which said `runner`.)",
4592
+ "x-agentrun-serve": "place/5",
4535
4593
  },
4536
- default_reason: { type: "string", description: "Why a new agent is not given a box here, when `default_place` is the runner, in docker's own words: `new agents run on the runner, because the docker box is unavailable here: <docker's reason>`, such as `Docker isn't running on this machine (no docker command on PATH): install or start Docker, then restart AgentRun`, or, with AGENTRUN_BOXES set to a list without docker, empty or `none`, the setting that turns it on.", "x-agentrun-serve": "place/3" },
4594
+ default_reason: { type: "string", description: "There exactly when `default_place` is null (Mode 1 with no Docker box): the words a create that names no place and would get the box is refused in, `name a box: this server has no Docker box for a new agent. Set place to {mode: sandbox, box: <one of: …>}, or to {mode: runner} to run without a shell.`, listing the boxes this server has, or `<none is set up>`. Docker's own reason is on its entry in `boxes`.", "x-agentrun-serve": "place/5" },
4537
4595
  allow: { type: "array", items: { type: "string" }, description: "The hosts a box whose `network` is `allowlist` may reach: AGENTRUN_BOX_ALLOW's, else the package registries and GitHub; empty when it is `none`.", "x-agentrun-serve": "place/2" },
4538
4596
  },
4539
4597
  "Capabilities/workflows": {
@@ -4591,9 +4649,9 @@ const FIELD_EXTENSIONS = {
4591
4649
  "x-agentrun-serve": "toolkeys/1",
4592
4650
  },
4593
4651
  harness_keys: {
4594
- type: "object", additionalProperties: false, required: ["routes", "at_rest", "harnesses", "kept"],
4595
- properties: { routes: { type: "boolean" }, at_rest: { const: "sealed" }, harnesses: { type: "array", items: { type: "string", pattern: HARNESS_ID_PATTERN }, description: "The plan-billed harness recipes this server is started with (--harness-recipe), whose keys GET /settings/harness-keys lists. Empty when it names none." }, kept: { type: "array", items: { type: "string", pattern: HARNESS_ID_PATTERN }, description: "Each harness id with keys saved whose recipe this server is no longer started with: kept sealed, run by nothing, listed by GET /settings/harness-keys until a DELETE removes them. Empty to a caller with neither the owner's session nor a token." } },
4596
- description: "GET /settings/harness-keys and PUT/DELETE /settings/harness-keys/{harness_id}/{key}: the keys a plan-billed harness recipe runs on, each kept `sealed` for that harness alone, opened at the claim of a run on it and never handed to another harness or to any run's tools.",
4652
+ type: "object", additionalProperties: false, required: ["routes", "at_rest", "harnesses"],
4653
+ properties: { routes: { type: "boolean" }, at_rest: { const: "sealed" }, harnesses: { type: "array", items: { type: "string", pattern: HARNESS_ID_PATTERN }, description: "The plan-billed harness recipes this server is started with (--harness-recipe), whose keys GET /settings/harness-keys lists. Empty when it names none." } },
4654
+ description: "GET /settings/harness-keys and PUT/DELETE /settings/harness-keys/{harness_id}/{key}: the keys a plan-billed harness recipe runs on, each kept `sealed` for that harness alone, opened at the claim of a run on it and never handed to another harness or to any run's tools. The same to every caller: the GET (the owner's session) also lists each id with keys kept whose recipe this server no longer names, so a console offers the page on `routes`.",
4597
4655
  "x-agentrun-serve": "harnesskeys/1",
4598
4656
  },
4599
4657
  mcp_client: {
@@ -4850,6 +4908,8 @@ export function openapiDocument(capabilityOf, adapters = TRIGGER_ADAPTERS) {
4850
4908
  const capabilities = schemas.Capabilities;
4851
4909
  capabilities.required = [...capabilities.required, ...CAPABILITIES_SENT];
4852
4910
  capabilities.properties.places.required = [...capabilities.properties.places.required, "default_place"];
4911
+ // default_reason is there exactly when default_place is null (place.ts placesOf).
4912
+ Object.assign(capabilities.properties.places, { if: { required: ["default_place"], properties: { default_place: { type: "null" } } }, then: { required: ["default_reason"] }, else: { not: { required: ["default_reason"] } } });
4853
4913
  // The contract's definition fields this server refuses (validate.ts), each marked with the reason its 422 gives.
4854
4914
  const definition = schemas.DefinitionInput;
4855
4915
  const refused = [];
@@ -4921,10 +4981,10 @@ export function openapiDocument(capabilityOf, adapters = TRIGGER_ADAPTERS) {
4921
4981
  listAgents.parameters = [...listAgents.parameters, { name: "archived", in: "query", required: false, description: "true lists only archived agents; false, the default, the others.", schema: { type: "boolean" } }];
4922
4982
  listAgents["x-agentrun-serve-changed"] = { archived: "archivedparam/1" };
4923
4983
  changed.push("GET /agents");
4924
- // GET /agents/{agent_id}/runs takes GET /runs' `label` filter too (server.ts runsPage, shared by both routes).
4984
+ // GET /agents/{agent_id}/runs takes GET /runs' `scope` and `label` filters too (server.ts runsPage, shared by both routes).
4925
4985
  const listAgentRuns = doc.paths["/agents/{agent_id}/runs"].get;
4926
- listAgentRuns.parameters = [...listAgentRuns.parameters, LABEL_PARAMETER];
4927
- listAgentRuns["x-agentrun-serve-changed"] = { ...listAgentRuns["x-agentrun-serve-changed"], label: "runlabels/1" };
4986
+ listAgentRuns.parameters = [...listAgentRuns.parameters, { name: "scope", in: "query", required: false, description: "Factory active executions (including archived) or unarchived terminal escalations and failures for this agent, excluding imports. Uses keyset cursors bound to filters; incompatible with status and archived. Default scoped page size 50, maximum 100.", schema: { enum: ["active", "review"] } }, LABEL_PARAMETER];
4987
+ listAgentRuns["x-agentrun-serve-changed"] = { ...listAgentRuns["x-agentrun-serve-changed"], scope: "factory/1", label: "runlabels/1" };
4928
4988
  changed.push("GET /agents/{agent_id}/runs");
4929
4989
  // GET /agents/{agent_id} always sends the agent's `tools` (server.ts getAgent; [] before it has a revision), which the
4930
4990
  // agent in a list, a create or a save does not: its 200 is the contract's Agent with `tools` required.
@@ -21,6 +21,9 @@ export declare const BOX_IDS: readonly string[];
21
21
  * version` (probeDocker), its computers mount this server's paths (box-paths.ts) and keep out the Docker host's own
22
22
  * addresses (docker-host-addresses.ts). */
23
23
  export declare const LOCAL_BOXES: readonly string[];
24
+ /** The box a new agent that names no place and needs a shell is given (its descriptor's `defaultBox`: Docker's), by
25
+ * that fact, never by a name; undefined where no box's descriptor sets it. */
26
+ export declare const DEFAULT_BOX: string | undefined;
24
27
  /** A box as capabilities show it: whether this server has it, and why when not (or how it was checked); `state`, which
25
28
  * capabilities derive from it (place.ts stated). `network`: what an available box reaches (BOX_NETWORKS), with
26
29
  * `network_reason` when it is available and has none for a cause of its own (a daemon elsewhere). `host_addresses`: for Docker from a container (compose.yaml), the Docker host's own addresses
@@ -45,6 +45,9 @@ const boxEntry = (id) => PROVIDERS.find((entry) => entry.id === id);
45
45
  * version` (probeDocker), its computers mount this server's paths (box-paths.ts) and keep out the Docker host's own
46
46
  * addresses (docker-host-addresses.ts). */
47
47
  export const LOCAL_BOXES = BOX_IDS.filter((id) => boxEntry(id).local === true);
48
+ /** The box a new agent that names no place and needs a shell is given (its descriptor's `defaultBox`: Docker's), by
49
+ * that fact, never by a name; undefined where no box's descriptor sets it. */
50
+ export const DEFAULT_BOX = BOX_IDS.find((id) => boxEntry(id).defaultBox === true);
48
51
  /** What an available box reaches: the hosts of `places.allow` (`allowlist`), or nothing (`none`). */
49
52
  export const BOX_NETWORKS = ["allowlist", "none"];
50
53
  /** A box's state in capabilities: ready (available) or unavailable. */
package/dist/place.d.ts CHANGED
@@ -10,9 +10,15 @@ export type Place = {
10
10
  };
11
11
  /** Every box, from what this server found at its start (place-offers.ts): one it did not find is not set up. */
12
12
  export declare function boxAvailability(registry: readonly BoxOffer[]): BoxOffer[];
13
- /** The place a new agentic definition that names none is saved with: the local box (Docker's) where this server has it;
14
- * else none, so the agent runs on the runner as it did before, with `reason` saying why, in its probe's own words. A
15
- * workflow is never given one. */
13
+ /** What a new agent that would get Docker's box sets where this server does not have it: a box, listing the boxes this
14
+ * server has (never picking one), or the runner. */
15
+ export declare function placeToName(registry: readonly BoxOffer[]): string;
16
+ /** Why such an agent is refused: it names a box (placeToName); and why Docker's box is not here, in the words its offer
17
+ * gave (its probe's, with their fix: start Docker, join its group), where it gave some. */
18
+ export declare const nameABox: (registry: readonly BoxOffer[]) => string;
19
+ /** The place a new agentic definition that names none is saved with: Docker's box where this server has it; else none,
20
+ * with `reason`, the words such a definition is refused in (nameABox), and `why` Docker's box is not here, in its probe's
21
+ * own words. A workflow is never given one. */
16
22
  export declare function newAgentPlace(registry: readonly BoxOffer[]): {
17
23
  place: Place;
18
24
  } | {
@@ -24,10 +30,20 @@ export declare function newAgentPlace(registry: readonly BoxOffer[]): {
24
30
  * background tools); the runner for a workflow, which is never given a box, for one whose tools need no shell (none, or
25
31
  * only read and write: a container would only hold up its start), and for one that names a tool the box refuses (the
26
32
  * browser, runner-only for now). */
27
- export declare function defaultPlaceOf(kind: "agentic" | "workflow", tools: readonly unknown[], registry: readonly BoxOffer[], flags: (tool: string) => {
33
+ export declare function defaultPlaceOf(kind: "agentic" | "workflow", tools: readonly unknown[], registry: readonly BoxOffer[], flags: ToolFlags): Place;
34
+ type ToolFlags = (tool: string) => {
28
35
  readonly sandboxOnly?: true;
29
36
  readonly runnerOnly?: true;
30
- } | undefined): Place;
37
+ } | undefined;
38
+ /** The refusal of an agentic definition that names no place (noPlaceIssue), at its create or at an edit that would
39
+ * save it, where it would be given the default box (it names no tools, `tools` undefined, so it would get a shell, or a
40
+ * tool that runs only in a box) and this server does not have Docker's box, and where the runner has no shell
41
+ * (`runnerShell` false: Mode 1). On Mode 2 the runner's exec is a shell, and such a definition saves for the runner as
42
+ * it always did, its tools checked there (runnable.ts). Undefined for one that saves. */
43
+ export declare function noBoxRefusal(tools: readonly unknown[] | undefined, registry: readonly BoxOffer[], flags: ToolFlags, runnerShell: boolean): InputIssue | undefined;
44
+ /** The refusal of a revision that names no place where Docker's box is not here, at definition.place: its words, and
45
+ * what to set as its fix, so no example of a place is picked for it. */
46
+ export declare const noPlaceIssue: (registry: readonly BoxOffer[]) => InputIssue;
31
47
  /** The tools a new agent in the default box is given when its definition names none: a shell, and the background tools
32
48
  * that start, read, feed, signal and list commands that outlive one call (background.ts SHELL_TOOLS, which a test holds
33
49
  * this list to; written out here, since background.ts reads this module). A definition that names its tools, an empty
@@ -39,20 +55,25 @@ export declare function noBoxReason(registry: readonly BoxOffer[], listed: Reado
39
55
  /** The start banner's words on the boxes: which are ready for a sandbox agent's tools, then why each box is not that
40
56
  * AGENTRUN_BOXES lists (`listed`), and, when none is ready, the boxes it does not list, with what to do.
41
57
  * `byDefault`, with AGENTRUN_BOXES not set at all: short, the local box alone, said to be on by default, or why it is
42
- * not. */
43
- export declare function boxesLine(registry: readonly BoxOffer[], listed: ReadonlySet<string>, allow?: readonly string[] | "none", byDefault?: boolean): string;
58
+ * not, and where a new agent with no place goes then: it names its place, or, where the runner has a shell
59
+ * (`runnerShell`: Mode 2), it runs on the runner (placesOf). */
60
+ export declare function boxesLine(registry: readonly BoxOffer[], listed: ReadonlySet<string>, allow?: readonly string[] | "none", byDefault?: boolean, runnerShell?: boolean): string;
44
61
  /** `places` in capabilities: the modes a revision may name, the place a new agent is saved with and a revision that
45
- * names none runs in (`default_place`, with `default_reason` when it is the runner), each box, and the hosts a box whose
46
- * `network` is `allowlist` reaches (`allow`, box-settings.ts boxAllowOf; empty for `none`). */
47
- export declare const placesOf: (registry: readonly BoxOffer[], allow?: readonly string[] | "none") => {
62
+ * names none runs in (`default_place`), each box, and the hosts a box whose `network` is `allowlist` reaches (`allow`,
63
+ * box-settings.ts boxAllowOf; empty for `none`). `default_place` is Docker's box where this server has it; else, where
64
+ * the runner has a shell (`runnerShell`: Mode 2's Archil exec), the runner; else null, no default: a new agent names its
65
+ * place, and `default_reason` is the words a no-place create is refused in (noBoxRefusal). `default_reason` is there
66
+ * exactly when `default_place` is null. */
67
+ export declare const placesOf: (registry: readonly BoxOffer[], allow?: readonly string[] | "none", runnerShell?: boolean) => {
48
68
  boxes: BoxOffer[];
49
69
  allow: string[];
50
70
  default_place: Place;
71
+ default_reason?: undefined;
51
72
  modes: ("runner" | "sandbox")[];
52
73
  } | {
53
74
  boxes: BoxOffer[];
54
75
  allow: string[];
55
- default_place: Place;
76
+ default_place: null;
56
77
  default_reason: string;
57
78
  modes: ("runner" | "sandbox")[];
58
79
  };
@@ -65,3 +86,4 @@ export declare const placeFix: (place: Place) => string;
65
86
  /** What is wrong with `place` as a definition gives it, as issues at `field`. Each names its fix: the field to remove,
66
87
  * or the place to copy, the one it most likely meant. */
67
88
  export declare function placeIssues(place: unknown, field: string): InputIssue[];
89
+ export {};