@culture.dev/agents 0.15.3 → 0.16.1

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 (222) hide show
  1. package/README.md +22 -0
  2. package/dist/contract-schemas/api.json +73 -15
  3. package/dist/contract-schemas/branches.json +163 -0
  4. package/dist/contract-schemas/capabilities.json +133 -6
  5. package/dist/contract-schemas/common.json +9 -3
  6. package/dist/contract-schemas/control-action.json +91 -14
  7. package/dist/contract-schemas/error.json +189 -48
  8. package/dist/contract-schemas/event.json +185 -2
  9. package/dist/contract-schemas/run.json +111 -4
  10. package/dist/contract-schemas/version.json +2 -2
  11. package/dist/src/contract/generated/branches.d.ts +34 -0
  12. package/dist/src/contract/generated/branches.js +3 -0
  13. package/dist/src/contract/generated/branches.js.map +1 -0
  14. package/dist/src/contract/generated/capabilities.d.ts +39 -7
  15. package/dist/src/contract/generated/common.d.ts +5 -3
  16. package/dist/src/contract/generated/control-action.d.ts +30 -11
  17. package/dist/src/contract/generated/error.d.ts +31 -7
  18. package/dist/src/contract/generated/event.d.ts +57 -8
  19. package/dist/src/contract/generated/index.d.ts +37 -12
  20. package/dist/src/contract/generated/run.d.ts +23 -5
  21. package/dist/src/contract/generated/version.d.ts +2 -2
  22. package/dist/src/contract/ids.d.ts +6 -3
  23. package/dist/src/contract/ids.js +5 -2
  24. package/dist/src/contract/ids.js.map +1 -1
  25. package/dist/src/contract/index.d.ts +1 -1
  26. package/dist/src/contract/index.js +1 -1
  27. package/dist/src/contract/index.js.map +1 -1
  28. package/dist/src/daemon/branch-routes.d.ts +13 -0
  29. package/dist/src/daemon/branch-routes.js +41 -0
  30. package/dist/src/daemon/branch-routes.js.map +1 -0
  31. package/dist/src/daemon/daemon.js +10 -2
  32. package/dist/src/daemon/daemon.js.map +1 -1
  33. package/dist/src/daemon/harness-catalog.d.ts +6 -0
  34. package/dist/src/daemon/harness-catalog.js +20 -0
  35. package/dist/src/daemon/harness-catalog.js.map +1 -1
  36. package/dist/src/daemon/limits.d.ts +31 -0
  37. package/dist/src/daemon/limits.js +61 -0
  38. package/dist/src/daemon/limits.js.map +1 -0
  39. package/dist/src/daemon/main.d.ts +10 -0
  40. package/dist/src/daemon/main.js +161 -41
  41. package/dist/src/daemon/main.js.map +1 -1
  42. package/dist/src/daemon/ports.d.ts +21 -11
  43. package/dist/src/daemon/routes.d.ts +3 -0
  44. package/dist/src/daemon/routes.js +26 -5
  45. package/dist/src/daemon/routes.js.map +1 -1
  46. package/dist/src/daemon/secrets.d.ts +24 -0
  47. package/dist/src/daemon/secrets.js +52 -0
  48. package/dist/src/daemon/secrets.js.map +1 -0
  49. package/dist/src/daemon/submitter.d.ts +9 -0
  50. package/dist/src/daemon/submitter.js +23 -0
  51. package/dist/src/daemon/submitter.js.map +1 -0
  52. package/dist/src/harness/claude-code/index.js +1 -1
  53. package/dist/src/harness/claude-code/index.js.map +1 -1
  54. package/dist/src/harness/common/capabilities.d.ts +26 -2
  55. package/dist/src/harness/common/capabilities.js +31 -6
  56. package/dist/src/harness/common/capabilities.js.map +1 -1
  57. package/dist/src/harness/common/guard.d.ts +2 -1
  58. package/dist/src/harness/common/guard.js +6 -0
  59. package/dist/src/harness/common/guard.js.map +1 -1
  60. package/dist/src/harness/common/run-driver.d.ts +6 -1
  61. package/dist/src/harness/common/run-driver.js +20 -3
  62. package/dist/src/harness/common/run-driver.js.map +1 -1
  63. package/dist/src/harness/common/sandbox-workspace.d.ts +5 -1
  64. package/dist/src/harness/common/sandbox-workspace.js +12 -3
  65. package/dist/src/harness/common/sandbox-workspace.js.map +1 -1
  66. package/dist/src/harness/common/types.d.ts +8 -0
  67. package/dist/src/harness/config.d.ts +5 -0
  68. package/dist/src/harness/config.js +7 -3
  69. package/dist/src/harness/config.js.map +1 -1
  70. package/dist/src/harness/index.js +2 -2
  71. package/dist/src/harness/index.js.map +1 -1
  72. package/dist/src/harness/opencode/index.js +1 -1
  73. package/dist/src/harness/opencode/index.js.map +1 -1
  74. package/dist/src/harness/stub/backend.d.ts +3 -0
  75. package/dist/src/harness/stub/backend.js +50 -1
  76. package/dist/src/harness/stub/backend.js.map +1 -1
  77. package/dist/src/harness/stub/index.d.ts +7 -1
  78. package/dist/src/harness/stub/index.js +10 -2
  79. package/dist/src/harness/stub/index.js.map +1 -1
  80. package/dist/src/index.d.ts +1 -1
  81. package/dist/src/index.js +1 -1
  82. package/dist/src/publish/config.d.ts +25 -0
  83. package/dist/src/publish/config.js +47 -0
  84. package/dist/src/publish/config.js.map +1 -0
  85. package/dist/src/publish/envelope.d.ts +61 -0
  86. package/dist/src/publish/envelope.js +109 -0
  87. package/dist/src/publish/envelope.js.map +1 -0
  88. package/dist/src/publish/index.d.ts +22 -0
  89. package/dist/src/publish/index.js +35 -0
  90. package/dist/src/publish/index.js.map +1 -0
  91. package/dist/src/publish/log-tail.d.ts +31 -0
  92. package/dist/src/publish/log-tail.js +172 -0
  93. package/dist/src/publish/log-tail.js.map +1 -0
  94. package/dist/src/publish/publisher.d.ts +34 -0
  95. package/dist/src/publish/publisher.js +207 -0
  96. package/dist/src/publish/publisher.js.map +1 -0
  97. package/dist/src/publish/transport.d.ts +14 -0
  98. package/dist/src/publish/transport.js +69 -0
  99. package/dist/src/publish/transport.js.map +1 -0
  100. package/dist/src/runs/admission.d.ts +27 -0
  101. package/dist/src/runs/admission.js +97 -0
  102. package/dist/src/runs/admission.js.map +1 -0
  103. package/dist/src/runs/answer.d.ts +24 -0
  104. package/dist/src/runs/answer.js +99 -0
  105. package/dist/src/runs/answer.js.map +1 -0
  106. package/dist/src/runs/base-commit.d.ts +6 -0
  107. package/dist/src/runs/base-commit.js +23 -0
  108. package/dist/src/runs/base-commit.js.map +1 -0
  109. package/dist/src/runs/branches.d.ts +23 -0
  110. package/dist/src/runs/branches.js +115 -0
  111. package/dist/src/runs/branches.js.map +1 -0
  112. package/dist/src/runs/control.d.ts +12 -4
  113. package/dist/src/runs/control.js +14 -6
  114. package/dist/src/runs/control.js.map +1 -1
  115. package/dist/src/runs/gateway.d.ts +25 -0
  116. package/dist/src/runs/gateway.js +122 -0
  117. package/dist/src/runs/gateway.js.map +1 -0
  118. package/dist/src/runs/keys.d.ts +21 -0
  119. package/dist/src/runs/keys.js +50 -0
  120. package/dist/src/runs/keys.js.map +1 -0
  121. package/dist/src/runs/limits.d.ts +15 -0
  122. package/dist/src/runs/limits.js +37 -0
  123. package/dist/src/runs/limits.js.map +1 -0
  124. package/dist/src/runs/ports.d.ts +3 -0
  125. package/dist/src/runs/ports.js.map +1 -1
  126. package/dist/src/runs/reattach.d.ts +37 -0
  127. package/dist/src/runs/reattach.js +70 -0
  128. package/dist/src/runs/reattach.js.map +1 -0
  129. package/dist/src/runs/scan.d.ts +11 -6
  130. package/dist/src/runs/scan.js +12 -15
  131. package/dist/src/runs/scan.js.map +1 -1
  132. package/dist/src/runs/service.d.ts +57 -7
  133. package/dist/src/runs/service.js +160 -95
  134. package/dist/src/runs/service.js.map +1 -1
  135. package/dist/src/runs/submit.d.ts +34 -0
  136. package/dist/src/runs/submit.js +92 -0
  137. package/dist/src/runs/submit.js.map +1 -0
  138. package/dist/src/sandbox/host-command.js +5 -1
  139. package/dist/src/sandbox/host-command.js.map +1 -1
  140. package/dist/src/sandbox/run-sandbox.d.ts +8 -2
  141. package/dist/src/sandbox/run-sandbox.js +10 -3
  142. package/dist/src/sandbox/run-sandbox.js.map +1 -1
  143. package/dist/src/store/derive.js +3 -0
  144. package/dist/src/store/derive.js.map +1 -1
  145. package/dist/src/store/entries.d.ts +29 -0
  146. package/dist/src/store/entries.js +41 -0
  147. package/dist/src/store/entries.js.map +1 -0
  148. package/dist/src/store/event-log.d.ts +3 -3
  149. package/dist/src/store/event-log.js +2 -2
  150. package/dist/src/store/event-log.js.map +1 -1
  151. package/dist/src/store/files.d.ts +4 -0
  152. package/dist/src/store/files.js +4 -0
  153. package/dist/src/store/files.js.map +1 -1
  154. package/dist/src/store/idempotency.d.ts +79 -0
  155. package/dist/src/store/idempotency.js +281 -0
  156. package/dist/src/store/idempotency.js.map +1 -0
  157. package/dist/src/store/index.d.ts +8 -0
  158. package/dist/src/store/index.js +5 -0
  159. package/dist/src/store/index.js.map +1 -1
  160. package/dist/src/store/questions.d.ts +40 -0
  161. package/dist/src/store/questions.js +90 -0
  162. package/dist/src/store/questions.js.map +1 -0
  163. package/dist/src/store/retention.d.ts +13 -0
  164. package/dist/src/store/retention.js +74 -0
  165. package/dist/src/store/retention.js.map +1 -0
  166. package/dist/src/store/run-store.d.ts +4 -0
  167. package/dist/src/store/run-store.js +20 -4
  168. package/dist/src/store/run-store.js.map +1 -1
  169. package/dist/src/store/startup.d.ts +9 -0
  170. package/dist/src/store/startup.js +92 -0
  171. package/dist/src/store/startup.js.map +1 -0
  172. package/dist/src/store/summary.d.ts +7 -0
  173. package/dist/src/store/summary.js +126 -0
  174. package/dist/src/store/summary.js.map +1 -0
  175. package/dist/src/store/version.d.ts +10 -0
  176. package/dist/src/store/version.js +46 -0
  177. package/dist/src/store/version.js.map +1 -0
  178. package/dist/src/trace/config.d.ts +31 -0
  179. package/dist/src/trace/config.js +69 -0
  180. package/dist/src/trace/config.js.map +1 -0
  181. package/dist/src/trace/follower.d.ts +20 -0
  182. package/dist/src/trace/follower.js +196 -0
  183. package/dist/src/trace/follower.js.map +1 -0
  184. package/dist/src/trace/index.d.ts +21 -0
  185. package/dist/src/trace/index.js +42 -0
  186. package/dist/src/trace/index.js.map +1 -0
  187. package/dist/src/trace/otlp.d.ts +11 -0
  188. package/dist/src/trace/otlp.js +52 -0
  189. package/dist/src/trace/otlp.js.map +1 -0
  190. package/dist/src/trace/spans.d.ts +28 -0
  191. package/dist/src/trace/spans.js +120 -0
  192. package/dist/src/trace/spans.js.map +1 -0
  193. package/dist/src/worker/answer.d.ts +29 -0
  194. package/dist/src/worker/answer.js +53 -0
  195. package/dist/src/worker/answer.js.map +1 -0
  196. package/dist/src/worker/asking.d.ts +22 -0
  197. package/dist/src/worker/asking.js +21 -0
  198. package/dist/src/worker/asking.js.map +1 -0
  199. package/dist/src/worker/control.d.ts +7 -1
  200. package/dist/src/worker/control.js +22 -10
  201. package/dist/src/worker/control.js.map +1 -1
  202. package/dist/src/worker/delivery.d.ts +2 -2
  203. package/dist/src/worker/delivery.js +1 -1
  204. package/dist/src/worker/delivery.js.map +1 -1
  205. package/dist/src/worker/driver.d.ts +46 -1
  206. package/dist/src/worker/fake-driver.d.ts +35 -1
  207. package/dist/src/worker/fake-driver.js +45 -0
  208. package/dist/src/worker/fake-driver.js.map +1 -1
  209. package/dist/src/worker/main.js +4 -1
  210. package/dist/src/worker/main.js.map +1 -1
  211. package/dist/src/worker/questions.d.ts +67 -0
  212. package/dist/src/worker/questions.js +152 -0
  213. package/dist/src/worker/questions.js.map +1 -0
  214. package/dist/src/worker/run-loop.d.ts +19 -1
  215. package/dist/src/worker/run-loop.js +91 -25
  216. package/dist/src/worker/run-loop.js.map +1 -1
  217. package/dist/src/worker/spawn.d.ts +9 -1
  218. package/dist/src/worker/spawn.js +12 -3
  219. package/dist/src/worker/spawn.js.map +1 -1
  220. package/package.json +3 -2
  221. package/policy/profiles/culture-agents-claude-subscription.yaml +1 -1
  222. package/policy/profiles/culture-agents-local-gateway.yaml +1 -1
package/README.md CHANGED
@@ -43,6 +43,15 @@ The daemon listens on `$CULTURE_AGENTS_SOCKET`, else
43
43
  is `${XDG_CONFIG_HOME:-$HOME/.config}/culture-agents/allowlist.json` and ships
44
44
  empty.
45
45
 
46
+ Run events can also go to the workspace's events broker (events-cli: Mosquitto
47
+ on loopback). Publishing is off unless `CULTURE_AGENTS_BROKER_URL` names a
48
+ loopback broker, for example `mqtt://127.0.0.1:1883`. Each event is published
49
+ after it is appended to the run's log, under a type `agents.run.<what>` and
50
+ with the id `<run id>:<cursor>`. A message holds the run id, the event kind,
51
+ the run's state, the cursor and the time, never the run's content. A broker
52
+ that is down never blocks or fails a run: the events stay in the log and are
53
+ published when the broker is back.
54
+
46
55
  Then, with the Python client:
47
56
 
48
57
  ```bash
@@ -55,6 +64,19 @@ The contract (JSON Schemas, routes, error table, state machine) is in the
55
64
  repository's [`contract/`](https://github.com/agentculture/culture-agents/tree/main/contract)
56
65
  directory and ships in this package under `dist/contract-schemas/`.
57
66
 
67
+ ## Injected secrets
68
+
69
+ The core is started with credentials in its environment. It reads each one once at start, keeps it in
70
+ memory and deletes it from `process.env` before any worker, host command (`git`, `openshell`) or
71
+ sandbox exists, so none of them inherits it. That is all it does: the kernel keeps the core's initial
72
+ environment in `/proc/<pid>/environ`, which any process of the same user can read, so the secrets
73
+ stay readable there for the life of the core. The way to avoid that is to give the core its secrets
74
+ by file or descriptor instead of the environment (planned, not built). The list is declared in one place,
75
+ `INJECTED_SECRETS` in `src/daemon/secrets.ts`: `GH_TOKEN`, `GITHUB_TOKEN`, `SSH_AUTH_SOCK`,
76
+ `CLAUDE_CODE_OAUTH_TOKEN`, `ANTHROPIC_API_KEY` and `LOBES_GATEWAY_KEY`. The worker spawner, the host
77
+ command runner and the sandbox environment filter also drop these names from any environment they
78
+ are given.
79
+
58
80
  ## License
59
81
 
60
82
  Apache-2.0
@@ -1,5 +1,5 @@
1
1
  {
2
- "api_version": "2.0",
2
+ "api_version": "3.0",
3
3
  "schema_base": "https://culture.dev/contract/agents/",
4
4
  "description": "Index of the culture-agents control-plane API. Semantics live in contract/README.md; payload shapes in the schema files named here, resolved against schema_base.",
5
5
  "transport": {
@@ -23,7 +23,8 @@
23
23
  "failed",
24
24
  "cancelled",
25
25
  "timed_out",
26
- "unknown"
26
+ "unknown",
27
+ "unanswered"
27
28
  ],
28
29
  "transitions": {
29
30
  "queued": [
@@ -41,6 +42,7 @@
41
42
  "cancelling": [
42
43
  "cancelled",
43
44
  "timed_out",
45
+ "unanswered",
44
46
  "succeeded",
45
47
  "failed",
46
48
  "unknown"
@@ -49,7 +51,8 @@
49
51
  "failed": [],
50
52
  "cancelled": [],
51
53
  "timed_out": [],
52
- "unknown": []
54
+ "unknown": [],
55
+ "unanswered": []
53
56
  }
54
57
  },
55
58
  "errors": {
@@ -68,15 +71,20 @@
68
71
  "exit_code": 1,
69
72
  "retryable": false
70
73
  },
71
- "busy": {
74
+ "conflict": {
72
75
  "http_status": 409,
73
76
  "exit_code": 1,
77
+ "retryable": null
78
+ },
79
+ "limit_reached": {
80
+ "http_status": 429,
81
+ "exit_code": 1,
74
82
  "retryable": true
75
83
  },
76
- "conflict": {
77
- "http_status": 409,
84
+ "admission_held": {
85
+ "http_status": 429,
78
86
  "exit_code": 1,
79
- "retryable": null
87
+ "retryable": true
80
88
  },
81
89
  "unsupported": {
82
90
  "http_status": 422,
@@ -208,7 +216,7 @@
208
216
  "id": "runs.submit",
209
217
  "method": "POST",
210
218
  "path": "/v1/runs",
211
- "summary": "Create a run; returns once the worker's PID, event log and cursor are on disk.",
219
+ "summary": "Create a run; returns once the worker's PID, event log and cursor are on disk. A repeat of an idempotency key returns the first run.",
212
220
  "cli": "agents runs submit",
213
221
  "d1": "supported",
214
222
  "request": "control-action.json#/$defs/submit_request",
@@ -225,8 +233,10 @@
225
233
  "denied",
226
234
  "not_found",
227
235
  "unsupported",
228
- "busy",
229
- "unavailable"
236
+ "unavailable",
237
+ "conflict",
238
+ "limit_reached",
239
+ "admission_held"
230
240
  ]
231
241
  },
232
242
  {
@@ -430,7 +440,7 @@
430
440
  "method": "POST",
431
441
  "path": "/v1/runs/{run_id}/pause",
432
442
  "summary": "Deferred: always refused with unsupported, capability pause, after validation and not_found checks.",
433
- "cli": "(none in D1)",
443
+ "cli": "(none)",
434
444
  "d1": "unsupported",
435
445
  "request": "control-action.json#/$defs/pause_request",
436
446
  "response": "control-action.json#/$defs/accepted_response",
@@ -454,7 +464,7 @@
454
464
  "method": "POST",
455
465
  "path": "/v1/runs/{run_id}/resume",
456
466
  "summary": "Deferred: always refused with unsupported, capability resume, after validation and not_found checks.",
457
- "cli": "(none in D1)",
467
+ "cli": "(none)",
458
468
  "d1": "unsupported",
459
469
  "request": "control-action.json#/$defs/resume_request",
460
470
  "response": "control-action.json#/$defs/accepted_response",
@@ -477,8 +487,8 @@
477
487
  "id": "runs.answer",
478
488
  "method": "POST",
479
489
  "path": "/v1/runs/{run_id}/answer",
480
- "summary": "Deferred: always refused with unsupported, capability answer, after validation and not_found checks.",
481
- "cli": "(none in D1)",
490
+ "summary": "Answer one pending question of a run. Refused with unsupported, capability answer, when the run's harness cannot ask.",
491
+ "cli": "agents runs answer",
482
492
  "d1": "unsupported",
483
493
  "request": "control-action.json#/$defs/answer_request",
484
494
  "response": "control-action.json#/$defs/accepted_response",
@@ -494,7 +504,55 @@
494
504
  "incompatible_version",
495
505
  "internal",
496
506
  "not_found",
497
- "unsupported"
507
+ "unsupported",
508
+ "conflict",
509
+ "unavailable"
510
+ ]
511
+ },
512
+ {
513
+ "id": "branches.list",
514
+ "method": "GET",
515
+ "path": "/v1/branches",
516
+ "summary": "Every runs branch of one repository with its run's state and the git evidence of whether its commits are reachable from another ref.",
517
+ "cli": "agents branches list",
518
+ "d1": "supported",
519
+ "request": null,
520
+ "response": "branches.json",
521
+ "status": 200,
522
+ "stream": false,
523
+ "content_type": "application/json",
524
+ "params": {},
525
+ "query": {
526
+ "repo": {
527
+ "$ref": "common.json#/$defs/repo_path"
528
+ }
529
+ },
530
+ "errors": [
531
+ "invalid",
532
+ "incompatible_version",
533
+ "internal",
534
+ "denied"
535
+ ]
536
+ },
537
+ {
538
+ "id": "branches.remove",
539
+ "method": "POST",
540
+ "path": "/v1/branches/remove",
541
+ "summary": "Delete the finished runs branches of one repository that git shows reachable from another ref, with git branch -d only; skip and report the rest.",
542
+ "cli": "agents branches remove",
543
+ "d1": "supported",
544
+ "request": "branches.json#/$defs/remove_request",
545
+ "response": "branches.json#/$defs/remove_response",
546
+ "status": 200,
547
+ "stream": false,
548
+ "content_type": "application/json",
549
+ "params": {},
550
+ "query": {},
551
+ "errors": [
552
+ "invalid",
553
+ "incompatible_version",
554
+ "internal",
555
+ "denied"
498
556
  ]
499
557
  }
500
558
  ]
@@ -0,0 +1,163 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://culture.dev/contract/agents/branches.json",
4
+ "title": "BranchList",
5
+ "description": "Response of GET /v1/branches: every `runs/<run_id>` branch of one repository, with the state of its run and the git evidence about whether its commits are reachable from another ref (a local branch other than a runs branch, or a remote-tracking branch).",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "repo",
10
+ "branches"
11
+ ],
12
+ "properties": {
13
+ "repo": {
14
+ "$ref": "common.json#/$defs/repo_path"
15
+ },
16
+ "branches": {
17
+ "type": "array",
18
+ "maxItems": 10000,
19
+ "items": {
20
+ "$ref": "#/$defs/branch"
21
+ }
22
+ }
23
+ },
24
+ "$defs": {
25
+ "branch": {
26
+ "description": "One runs branch. `state` is the run's state as the core reads it now, or null when no run can be read for the branch; `state_note` then says why (no such run, or the run cannot be read). `merged_into` names the first other ref git shows to contain the branch tip (`git merge-base --is-ancestor`), or is null.",
27
+ "type": "object",
28
+ "additionalProperties": false,
29
+ "required": [
30
+ "branch",
31
+ "run_id",
32
+ "state",
33
+ "state_note",
34
+ "tip",
35
+ "merged_into"
36
+ ],
37
+ "properties": {
38
+ "branch": {
39
+ "type": "string",
40
+ "minLength": 6,
41
+ "maxLength": 132,
42
+ "pattern": "^runs/.+$"
43
+ },
44
+ "run_id": {
45
+ "$ref": "common.json#/$defs/run_id"
46
+ },
47
+ "state": {
48
+ "oneOf": [
49
+ {
50
+ "$ref": "run.json#/$defs/state"
51
+ },
52
+ {
53
+ "type": "null"
54
+ }
55
+ ]
56
+ },
57
+ "state_note": {
58
+ "type": [
59
+ "string",
60
+ "null"
61
+ ],
62
+ "maxLength": 1000
63
+ },
64
+ "tip": {
65
+ "$ref": "common.json#/$defs/git_sha"
66
+ },
67
+ "merged_into": {
68
+ "type": [
69
+ "string",
70
+ "null"
71
+ ],
72
+ "maxLength": 512
73
+ }
74
+ }
75
+ },
76
+ "remove_request": {
77
+ "description": "Body of POST /v1/branches/remove. The repository must be one the allow-list names. With `dry_run` true nothing is deleted and `removed` lists what would be.",
78
+ "type": "object",
79
+ "additionalProperties": false,
80
+ "required": [
81
+ "repo"
82
+ ],
83
+ "properties": {
84
+ "repo": {
85
+ "$ref": "common.json#/$defs/repo_path"
86
+ },
87
+ "dry_run": {
88
+ "type": "boolean",
89
+ "default": false
90
+ }
91
+ }
92
+ },
93
+ "remove_response": {
94
+ "description": "Outcome of a removal: the branches deleted with `git branch -d` (never `-D`), and the branches skipped with the reason for each. A branch is skipped when its run is active, unknown or unreadable, when git shows no other ref containing it, or when git itself refuses the delete.",
95
+ "type": "object",
96
+ "additionalProperties": false,
97
+ "required": [
98
+ "repo",
99
+ "dry_run",
100
+ "removed",
101
+ "skipped"
102
+ ],
103
+ "properties": {
104
+ "repo": {
105
+ "$ref": "common.json#/$defs/repo_path"
106
+ },
107
+ "dry_run": {
108
+ "type": "boolean"
109
+ },
110
+ "removed": {
111
+ "type": "array",
112
+ "maxItems": 10000,
113
+ "items": {
114
+ "$ref": "#/$defs/branch"
115
+ }
116
+ },
117
+ "skipped": {
118
+ "type": "array",
119
+ "maxItems": 10000,
120
+ "items": {
121
+ "$ref": "#/$defs/skipped"
122
+ }
123
+ }
124
+ }
125
+ },
126
+ "skipped": {
127
+ "type": "object",
128
+ "additionalProperties": false,
129
+ "required": [
130
+ "branch",
131
+ "run_id",
132
+ "state",
133
+ "reason"
134
+ ],
135
+ "properties": {
136
+ "branch": {
137
+ "type": "string",
138
+ "minLength": 6,
139
+ "maxLength": 132,
140
+ "pattern": "^runs/.+$"
141
+ },
142
+ "run_id": {
143
+ "$ref": "common.json#/$defs/run_id"
144
+ },
145
+ "state": {
146
+ "oneOf": [
147
+ {
148
+ "$ref": "run.json#/$defs/state"
149
+ },
150
+ {
151
+ "type": "null"
152
+ }
153
+ ]
154
+ },
155
+ "reason": {
156
+ "type": "string",
157
+ "minLength": 1,
158
+ "maxLength": 1000
159
+ }
160
+ }
161
+ }
162
+ }
163
+ }
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://culture.dev/contract/agents/capabilities.json",
4
4
  "title": "Harness capability document",
5
- "description": "What one harness can do through this core, stated honestly. Every capability name is always present. A control action whose capability is not supported is refused with an `unsupported` error naming it, never dropped or simulated.",
5
+ "description": "What one harness can do through this core, stated honestly, and what this core's host can take right now. Every capability name is always present. A control action whose capability is not supported is refused with an `unsupported` error naming it, never dropped or simulated. `limits`, `active_runs` and `admission` describe this core's own host and never another one.",
6
6
  "type": "object",
7
7
  "additionalProperties": false,
8
8
  "required": [
@@ -37,6 +37,19 @@
37
37
  "capabilities": {
38
38
  "$ref": "#/$defs/capability_set"
39
39
  },
40
+ "limits": {
41
+ "description": "The limits the operator configured on this core. Absent when the core does not report them.",
42
+ "$ref": "#/$defs/limits"
43
+ },
44
+ "active_runs": {
45
+ "description": "How many runs are active on this core's host right now, across every harness and repository. Absent when the core does not report it.",
46
+ "type": "integer",
47
+ "minimum": 0
48
+ },
49
+ "admission": {
50
+ "description": "What each admission signal says for this harness on this host right now. Absent when the core does not report it.",
51
+ "$ref": "#/$defs/admission"
52
+ },
40
53
  "extension": {
41
54
  "$ref": "common.json#/$defs/extension"
42
55
  }
@@ -109,7 +122,7 @@
109
122
  }
110
123
  },
111
124
  "deferred": {
112
- "description": "A capability no harness supports in this API version. Changing it to supportable is a schema change (README: versioning).",
125
+ "description": "A capability no harness supports in this API version: pause, resume, continue_session and delegate. Changing one to supportable is a schema change (README: versioning).",
113
126
  "type": "object",
114
127
  "additionalProperties": false,
115
128
  "required": [
@@ -169,7 +182,7 @@
169
182
  "$ref": "#/$defs/deferred"
170
183
  },
171
184
  "answer": {
172
- "$ref": "#/$defs/deferred"
185
+ "$ref": "#/$defs/capability"
173
186
  },
174
187
  "continue_session": {
175
188
  "$ref": "#/$defs/deferred"
@@ -178,13 +191,127 @@
178
191
  "$ref": "#/$defs/deferred"
179
192
  },
180
193
  "placement": {
181
- "$ref": "#/$defs/deferred"
194
+ "$ref": "#/$defs/capability"
182
195
  },
183
196
  "reconnect": {
184
- "$ref": "#/$defs/deferred"
197
+ "$ref": "#/$defs/capability"
185
198
  },
186
199
  "worktree_isolation": {
187
- "$ref": "#/$defs/deferred"
200
+ "$ref": "#/$defs/capability"
201
+ }
202
+ }
203
+ },
204
+ "limit_name": {
205
+ "description": "A limit an operator can configure. runs_per_repository: active runs in one repository. runs_per_host: active runs on the core's host.",
206
+ "enum": [
207
+ "runs_per_repository",
208
+ "runs_per_host"
209
+ ]
210
+ },
211
+ "limits": {
212
+ "description": "Every limit by name. null means the operator configured none, and then no submit is refused for it. No limit applies unless one is configured.",
213
+ "type": "object",
214
+ "additionalProperties": false,
215
+ "required": [
216
+ "runs_per_repository",
217
+ "runs_per_host"
218
+ ],
219
+ "properties": {
220
+ "runs_per_repository": {
221
+ "type": [
222
+ "integer",
223
+ "null"
224
+ ],
225
+ "minimum": 1
226
+ },
227
+ "runs_per_host": {
228
+ "type": [
229
+ "integer",
230
+ "null"
231
+ ],
232
+ "minimum": 1
233
+ }
234
+ }
235
+ },
236
+ "signal_name": {
237
+ "description": "An admission signal. heat: the host's heat state. gateway: the model gateway's admit state, for harnesses that use the gateway.",
238
+ "enum": [
239
+ "heat",
240
+ "gateway"
241
+ ]
242
+ },
243
+ "signal_state": {
244
+ "description": "admit: the signal allows new work. hold: it says not to start new work. unknown: it is missing or stale; it is never read as admit or as a failure of the control plane.",
245
+ "enum": [
246
+ "admit",
247
+ "hold",
248
+ "unknown"
249
+ ]
250
+ },
251
+ "signal": {
252
+ "description": "One admission signal as this core read it.",
253
+ "type": "object",
254
+ "additionalProperties": false,
255
+ "required": [
256
+ "state",
257
+ "consulted",
258
+ "reason",
259
+ "observed_at"
260
+ ],
261
+ "properties": {
262
+ "state": {
263
+ "$ref": "#/$defs/signal_state"
264
+ },
265
+ "consulted": {
266
+ "description": "Whether admission reads this signal for this harness. When false the state does not affect admission and `reason` says why it is not read.",
267
+ "type": "boolean"
268
+ },
269
+ "reason": {
270
+ "description": "Why the state is hold or unknown, or why the signal is not consulted. null only for a plain admit.",
271
+ "type": [
272
+ "string",
273
+ "null"
274
+ ],
275
+ "maxLength": 500
276
+ },
277
+ "observed_at": {
278
+ "description": "The time the signal's publisher stamped on the reading, or null when there is no reading.",
279
+ "$ref": "common.json#/$defs/nullable_timestamp"
280
+ }
281
+ },
282
+ "if": {
283
+ "required": [
284
+ "state"
285
+ ],
286
+ "properties": {
287
+ "state": {
288
+ "const": "admit"
289
+ }
290
+ }
291
+ },
292
+ "else": {
293
+ "properties": {
294
+ "reason": {
295
+ "type": "string",
296
+ "minLength": 1
297
+ }
298
+ }
299
+ }
300
+ },
301
+ "admission": {
302
+ "description": "Every admission signal by name.",
303
+ "type": "object",
304
+ "additionalProperties": false,
305
+ "required": [
306
+ "heat",
307
+ "gateway"
308
+ ],
309
+ "properties": {
310
+ "heat": {
311
+ "$ref": "#/$defs/signal"
312
+ },
313
+ "gateway": {
314
+ "$ref": "#/$defs/signal"
188
315
  }
189
316
  }
190
317
  },
@@ -45,6 +45,12 @@
45
45
  "maxLength": 127,
46
46
  "pattern": "^[a-z0-9]{1,32}-[a-z0-9_]+(-[a-z0-9_]+)*\\.act\\.[0-9A-HJKMNP-TV-Z]{26}$"
47
47
  },
48
+ "question_id": {
49
+ "description": "Stable id of a question a run asks its operator: `<node>-<agent>.qst.<ULID>`, using the run's agent. Assigned by the run's worker when it records the question, never by a harness or a client. At most 127 characters: a mesh id of at most 96, then the 31 of `.qst.<ULID>`.",
50
+ "type": "string",
51
+ "maxLength": 127,
52
+ "pattern": "^[a-z0-9]{1,32}-[a-z0-9_]+(-[a-z0-9_]+)*\\.qst\\.[0-9A-HJKMNP-TV-Z]{26}$"
53
+ },
48
54
  "harness_id": {
49
55
  "description": "Harness identifier, a free lowercase string (for example `claude-code`, `opencode`). Deliberately not an enum.",
50
56
  "type": "string",
@@ -71,7 +77,7 @@
71
77
  "pattern": "^(?![\\s\\S]*[\\u0000-\\u001f])(?!.*/\\.\\.?(/|$))(/[^/]+)+$"
72
78
  },
73
79
  "idempotency_key": {
74
- "description": "Caller-chosen key, recorded and returned. D1 does not deduplicate on it (see README).",
80
+ "description": "Caller-chosen key, recorded and returned. A repeat of the same key with the same request takes effect once, and the same key with a different request is a `conflict` (see README: idempotency keys).",
75
81
  "type": "string",
76
82
  "pattern": "^[A-Za-z0-9._:-]{1,128}$"
77
83
  },
@@ -86,7 +92,7 @@
86
92
  "pattern": "^[0-9]+\\.[0-9]+$"
87
93
  },
88
94
  "text": {
89
- "description": "Free text from a caller (task, steer message). Untrusted data, never a control command.",
95
+ "description": "Free text from a caller or a harness (task, steer message, question, answer). Untrusted data, never a control command.",
90
96
  "type": "string",
91
97
  "minLength": 1,
92
98
  "maxLength": 100000
@@ -96,7 +102,7 @@
96
102
  "pattern": "^[0-9a-f]{40}$"
97
103
  },
98
104
  "principal": {
99
- "description": "Who asked: an operator or an agent, by mesh id. In D1 the core records it as supplied; authority comes from the owner-only socket and the allow-list, not from this field.",
105
+ "description": "Who asked, as the request says: an operator or an agent, by mesh id. The core records it as supplied and does not authenticate it; authority comes from the owner-only socket and the allow-list, not from this field. What the core itself established about the caller is the run's `submitter`.",
100
106
  "type": "object",
101
107
  "additionalProperties": false,
102
108
  "required": [