@culture.dev/agents 0.0.0-stage → 0.15.0

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 (290) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +59 -2
  3. package/dist/contract-schemas/agent.json +128 -0
  4. package/dist/contract-schemas/allowlist.json +25 -0
  5. package/dist/contract-schemas/api.json +501 -0
  6. package/dist/contract-schemas/capabilities.json +208 -0
  7. package/dist/contract-schemas/common.json +123 -0
  8. package/dist/contract-schemas/control-action.json +279 -0
  9. package/dist/contract-schemas/error.json +269 -0
  10. package/dist/contract-schemas/event.json +316 -0
  11. package/dist/contract-schemas/run.json +336 -0
  12. package/dist/contract-schemas/session.json +77 -0
  13. package/dist/contract-schemas/version.json +22 -0
  14. package/dist/src/contract/api.d.ts +41 -0
  15. package/dist/src/contract/api.js +35 -0
  16. package/dist/src/contract/api.js.map +1 -0
  17. package/dist/src/contract/errors.d.ts +21 -0
  18. package/dist/src/contract/errors.js +25 -0
  19. package/dist/src/contract/errors.js.map +1 -0
  20. package/dist/src/contract/generated/agent.d.ts +31 -0
  21. package/dist/src/contract/generated/agent.js +3 -0
  22. package/dist/src/contract/generated/agent.js.map +1 -0
  23. package/dist/src/contract/generated/allowlist.d.ts +10 -0
  24. package/dist/src/contract/generated/allowlist.js +3 -0
  25. package/dist/src/contract/generated/allowlist.js.map +1 -0
  26. package/dist/src/contract/generated/capabilities.d.ts +46 -0
  27. package/dist/src/contract/generated/capabilities.js +3 -0
  28. package/dist/src/contract/generated/capabilities.js.map +1 -0
  29. package/dist/src/contract/generated/common.d.ts +40 -0
  30. package/dist/src/contract/generated/common.js +3 -0
  31. package/dist/src/contract/generated/common.js.map +1 -0
  32. package/dist/src/contract/generated/control-action.d.ts +73 -0
  33. package/dist/src/contract/generated/control-action.js +3 -0
  34. package/dist/src/contract/generated/control-action.js.map +1 -0
  35. package/dist/src/contract/generated/error.d.ts +25 -0
  36. package/dist/src/contract/generated/error.js +3 -0
  37. package/dist/src/contract/generated/error.js.map +1 -0
  38. package/dist/src/contract/generated/event.d.ts +80 -0
  39. package/dist/src/contract/generated/event.js +3 -0
  40. package/dist/src/contract/generated/event.js.map +1 -0
  41. package/dist/src/contract/generated/index.d.ts +81 -0
  42. package/dist/src/contract/generated/index.js +3 -0
  43. package/dist/src/contract/generated/index.js.map +1 -0
  44. package/dist/src/contract/generated/run.d.ts +63 -0
  45. package/dist/src/contract/generated/run.js +3 -0
  46. package/dist/src/contract/generated/run.js.map +1 -0
  47. package/dist/src/contract/generated/session.d.ts +12 -0
  48. package/dist/src/contract/generated/session.js +3 -0
  49. package/dist/src/contract/generated/session.js.map +1 -0
  50. package/dist/src/contract/generated/version.d.ts +9 -0
  51. package/dist/src/contract/generated/version.js +3 -0
  52. package/dist/src/contract/generated/version.js.map +1 -0
  53. package/dist/src/contract/ids.d.ts +36 -0
  54. package/dist/src/contract/ids.js +85 -0
  55. package/dist/src/contract/ids.js.map +1 -0
  56. package/dist/src/contract/index.d.ts +17 -0
  57. package/dist/src/contract/index.js +13 -0
  58. package/dist/src/contract/index.js.map +1 -0
  59. package/dist/src/contract/run-state.d.ts +13 -0
  60. package/dist/src/contract/run-state.js +24 -0
  61. package/dist/src/contract/run-state.js.map +1 -0
  62. package/dist/src/contract/schemas.d.ts +18 -0
  63. package/dist/src/contract/schemas.js +37 -0
  64. package/dist/src/contract/schemas.js.map +1 -0
  65. package/dist/src/contract/validate.d.ts +17 -0
  66. package/dist/src/contract/validate.js +68 -0
  67. package/dist/src/contract/validate.js.map +1 -0
  68. package/dist/src/daemon/allowlist.d.ts +23 -0
  69. package/dist/src/daemon/allowlist.js +57 -0
  70. package/dist/src/daemon/allowlist.js.map +1 -0
  71. package/dist/src/daemon/daemon.d.ts +31 -0
  72. package/dist/src/daemon/daemon.js +141 -0
  73. package/dist/src/daemon/daemon.js.map +1 -0
  74. package/dist/src/daemon/errors.d.ts +14 -0
  75. package/dist/src/daemon/errors.js +26 -0
  76. package/dist/src/daemon/errors.js.map +1 -0
  77. package/dist/src/daemon/harness-catalog.d.ts +11 -0
  78. package/dist/src/daemon/harness-catalog.js +21 -0
  79. package/dist/src/daemon/harness-catalog.js.map +1 -0
  80. package/dist/src/daemon/http.d.ts +15 -0
  81. package/dist/src/daemon/http.js +76 -0
  82. package/dist/src/daemon/http.js.map +1 -0
  83. package/dist/src/daemon/lock.d.ts +47 -0
  84. package/dist/src/daemon/lock.js +167 -0
  85. package/dist/src/daemon/lock.js.map +1 -0
  86. package/dist/src/daemon/main.d.ts +32 -0
  87. package/dist/src/daemon/main.js +204 -0
  88. package/dist/src/daemon/main.js.map +1 -0
  89. package/dist/src/daemon/paths.d.ts +29 -0
  90. package/dist/src/daemon/paths.js +26 -0
  91. package/dist/src/daemon/paths.js.map +1 -0
  92. package/dist/src/daemon/ports.d.ts +58 -0
  93. package/dist/src/daemon/ports.js +2 -0
  94. package/dist/src/daemon/ports.js.map +1 -0
  95. package/dist/src/daemon/routes.d.ts +15 -0
  96. package/dist/src/daemon/routes.js +259 -0
  97. package/dist/src/daemon/routes.js.map +1 -0
  98. package/dist/src/daemon/sse.d.ts +8 -0
  99. package/dist/src/daemon/sse.js +56 -0
  100. package/dist/src/daemon/sse.js.map +1 -0
  101. package/dist/src/harness/availability.d.ts +9 -0
  102. package/dist/src/harness/availability.js +52 -0
  103. package/dist/src/harness/availability.js.map +1 -0
  104. package/dist/src/harness/claude-code/agent.d.ts +4 -0
  105. package/dist/src/harness/claude-code/agent.js +33 -0
  106. package/dist/src/harness/claude-code/agent.js.map +1 -0
  107. package/dist/src/harness/claude-code/backend.d.ts +48 -0
  108. package/dist/src/harness/claude-code/backend.js +83 -0
  109. package/dist/src/harness/claude-code/backend.js.map +1 -0
  110. package/dist/src/harness/claude-code/capabilities.d.ts +7 -0
  111. package/dist/src/harness/claude-code/capabilities.js +11 -0
  112. package/dist/src/harness/claude-code/capabilities.js.map +1 -0
  113. package/dist/src/harness/claude-code/index.d.ts +15 -0
  114. package/dist/src/harness/claude-code/index.js +20 -0
  115. package/dist/src/harness/claude-code/index.js.map +1 -0
  116. package/dist/src/harness/claude-code/map.d.ts +30 -0
  117. package/dist/src/harness/claude-code/map.js +108 -0
  118. package/dist/src/harness/claude-code/map.js.map +1 -0
  119. package/dist/src/harness/common/capabilities.d.ts +34 -0
  120. package/dist/src/harness/common/capabilities.js +60 -0
  121. package/dist/src/harness/common/capabilities.js.map +1 -0
  122. package/dist/src/harness/common/guard.d.ts +18 -0
  123. package/dist/src/harness/common/guard.js +31 -0
  124. package/dist/src/harness/common/guard.js.map +1 -0
  125. package/dist/src/harness/common/processes.d.ts +21 -0
  126. package/dist/src/harness/common/processes.js +46 -0
  127. package/dist/src/harness/common/processes.js.map +1 -0
  128. package/dist/src/harness/common/queue.d.ts +20 -0
  129. package/dist/src/harness/common/queue.js +76 -0
  130. package/dist/src/harness/common/queue.js.map +1 -0
  131. package/dist/src/harness/common/run-driver.d.ts +88 -0
  132. package/dist/src/harness/common/run-driver.js +317 -0
  133. package/dist/src/harness/common/run-driver.js.map +1 -0
  134. package/dist/src/harness/common/sandbox-workspace.d.ts +72 -0
  135. package/dist/src/harness/common/sandbox-workspace.js +155 -0
  136. package/dist/src/harness/common/sandbox-workspace.js.map +1 -0
  137. package/dist/src/harness/common/text.d.ts +9 -0
  138. package/dist/src/harness/common/text.js +49 -0
  139. package/dist/src/harness/common/text.js.map +1 -0
  140. package/dist/src/harness/common/types.d.ts +111 -0
  141. package/dist/src/harness/common/types.js +2 -0
  142. package/dist/src/harness/common/types.js.map +1 -0
  143. package/dist/src/harness/config.d.ts +43 -0
  144. package/dist/src/harness/config.js +200 -0
  145. package/dist/src/harness/config.js.map +1 -0
  146. package/dist/src/harness/index.d.ts +21 -0
  147. package/dist/src/harness/index.js +89 -0
  148. package/dist/src/harness/index.js.map +1 -0
  149. package/dist/src/harness/opencode/backend.d.ts +37 -0
  150. package/dist/src/harness/opencode/backend.js +114 -0
  151. package/dist/src/harness/opencode/backend.js.map +1 -0
  152. package/dist/src/harness/opencode/capabilities.d.ts +8 -0
  153. package/dist/src/harness/opencode/capabilities.js +11 -0
  154. package/dist/src/harness/opencode/capabilities.js.map +1 -0
  155. package/dist/src/harness/opencode/client.d.ts +70 -0
  156. package/dist/src/harness/opencode/client.js +189 -0
  157. package/dist/src/harness/opencode/client.js.map +1 -0
  158. package/dist/src/harness/opencode/index.d.ts +13 -0
  159. package/dist/src/harness/opencode/index.js +19 -0
  160. package/dist/src/harness/opencode/index.js.map +1 -0
  161. package/dist/src/harness/opencode/lines.d.ts +14 -0
  162. package/dist/src/harness/opencode/lines.js +99 -0
  163. package/dist/src/harness/opencode/lines.js.map +1 -0
  164. package/dist/src/harness/opencode/map.d.ts +13 -0
  165. package/dist/src/harness/opencode/map.js +84 -0
  166. package/dist/src/harness/opencode/map.js.map +1 -0
  167. package/dist/src/harness/opencode/turn.d.ts +23 -0
  168. package/dist/src/harness/opencode/turn.js +143 -0
  169. package/dist/src/harness/opencode/turn.js.map +1 -0
  170. package/dist/src/harness/reclaim.d.ts +13 -0
  171. package/dist/src/harness/reclaim.js +18 -0
  172. package/dist/src/harness/reclaim.js.map +1 -0
  173. package/dist/src/harness/stub/backend.d.ts +11 -0
  174. package/dist/src/harness/stub/backend.js +125 -0
  175. package/dist/src/harness/stub/backend.js.map +1 -0
  176. package/dist/src/harness/stub/index.d.ts +18 -0
  177. package/dist/src/harness/stub/index.js +21 -0
  178. package/dist/src/harness/stub/index.js.map +1 -0
  179. package/dist/src/harness/stub/workspace.d.ts +29 -0
  180. package/dist/src/harness/stub/workspace.js +92 -0
  181. package/dist/src/harness/stub/workspace.js.map +1 -0
  182. package/dist/src/index.d.ts +2 -0
  183. package/dist/src/index.js +3 -0
  184. package/dist/src/index.js.map +1 -0
  185. package/dist/src/runs/agents.d.ts +10 -0
  186. package/dist/src/runs/agents.js +49 -0
  187. package/dist/src/runs/agents.js.map +1 -0
  188. package/dist/src/runs/control.d.ts +31 -0
  189. package/dist/src/runs/control.js +105 -0
  190. package/dist/src/runs/control.js.map +1 -0
  191. package/dist/src/runs/index.d.ts +8 -0
  192. package/dist/src/runs/index.js +7 -0
  193. package/dist/src/runs/index.js.map +1 -0
  194. package/dist/src/runs/ports.d.ts +31 -0
  195. package/dist/src/runs/ports.js +5 -0
  196. package/dist/src/runs/ports.js.map +1 -0
  197. package/dist/src/runs/scan.d.ts +38 -0
  198. package/dist/src/runs/scan.js +149 -0
  199. package/dist/src/runs/scan.js.map +1 -0
  200. package/dist/src/runs/service.d.ts +70 -0
  201. package/dist/src/runs/service.js +239 -0
  202. package/dist/src/runs/service.js.map +1 -0
  203. package/dist/src/sandbox/harness-session.d.ts +11 -0
  204. package/dist/src/sandbox/harness-session.js +170 -0
  205. package/dist/src/sandbox/harness-session.js.map +1 -0
  206. package/dist/src/sandbox/host-command.d.ts +19 -0
  207. package/dist/src/sandbox/host-command.js +41 -0
  208. package/dist/src/sandbox/host-command.js.map +1 -0
  209. package/dist/src/sandbox/index.d.ts +11 -0
  210. package/dist/src/sandbox/index.js +15 -0
  211. package/dist/src/sandbox/index.js.map +1 -0
  212. package/dist/src/sandbox/naming.d.ts +49 -0
  213. package/dist/src/sandbox/naming.js +106 -0
  214. package/dist/src/sandbox/naming.js.map +1 -0
  215. package/dist/src/sandbox/openshell-client.d.ts +81 -0
  216. package/dist/src/sandbox/openshell-client.js +49 -0
  217. package/dist/src/sandbox/openshell-client.js.map +1 -0
  218. package/dist/src/sandbox/policy.d.ts +26 -0
  219. package/dist/src/sandbox/policy.js +100 -0
  220. package/dist/src/sandbox/policy.js.map +1 -0
  221. package/dist/src/sandbox/run-sandbox.d.ts +38 -0
  222. package/dist/src/sandbox/run-sandbox.js +247 -0
  223. package/dist/src/sandbox/run-sandbox.js.map +1 -0
  224. package/dist/src/sandbox/run-sandboxes.d.ts +18 -0
  225. package/dist/src/sandbox/run-sandboxes.js +225 -0
  226. package/dist/src/sandbox/run-sandboxes.js.map +1 -0
  227. package/dist/src/sandbox/timeout.d.ts +12 -0
  228. package/dist/src/sandbox/timeout.js +39 -0
  229. package/dist/src/sandbox/timeout.js.map +1 -0
  230. package/dist/src/sandbox/types.d.ts +125 -0
  231. package/dist/src/sandbox/types.js +15 -0
  232. package/dist/src/sandbox/types.js.map +1 -0
  233. package/dist/src/sandbox/worktree.d.ts +72 -0
  234. package/dist/src/sandbox/worktree.js +157 -0
  235. package/dist/src/sandbox/worktree.js.map +1 -0
  236. package/dist/src/store/derive.d.ts +39 -0
  237. package/dist/src/store/derive.js +68 -0
  238. package/dist/src/store/derive.js.map +1 -0
  239. package/dist/src/store/event-log.d.ts +79 -0
  240. package/dist/src/store/event-log.js +202 -0
  241. package/dist/src/store/event-log.js.map +1 -0
  242. package/dist/src/store/files.d.ts +51 -0
  243. package/dist/src/store/files.js +103 -0
  244. package/dist/src/store/files.js.map +1 -0
  245. package/dist/src/store/index.d.ts +15 -0
  246. package/dist/src/store/index.js +11 -0
  247. package/dist/src/store/index.js.map +1 -0
  248. package/dist/src/store/liveness.d.ts +61 -0
  249. package/dist/src/store/liveness.js +150 -0
  250. package/dist/src/store/liveness.js.map +1 -0
  251. package/dist/src/store/run-store.d.ts +67 -0
  252. package/dist/src/store/run-store.js +211 -0
  253. package/dist/src/store/run-store.js.map +1 -0
  254. package/dist/src/util/sequence.d.ts +58 -0
  255. package/dist/src/util/sequence.js +119 -0
  256. package/dist/src/util/sequence.js.map +1 -0
  257. package/dist/src/worker/control.d.ts +60 -0
  258. package/dist/src/worker/control.js +205 -0
  259. package/dist/src/worker/control.js.map +1 -0
  260. package/dist/src/worker/delivery.d.ts +17 -0
  261. package/dist/src/worker/delivery.js +43 -0
  262. package/dist/src/worker/delivery.js.map +1 -0
  263. package/dist/src/worker/driver.d.ts +88 -0
  264. package/dist/src/worker/driver.js +6 -0
  265. package/dist/src/worker/driver.js.map +1 -0
  266. package/dist/src/worker/fake-driver.d.ts +65 -0
  267. package/dist/src/worker/fake-driver.js +123 -0
  268. package/dist/src/worker/fake-driver.js.map +1 -0
  269. package/dist/src/worker/index.d.ts +15 -0
  270. package/dist/src/worker/index.js +11 -0
  271. package/dist/src/worker/index.js.map +1 -0
  272. package/dist/src/worker/main.d.ts +1 -0
  273. package/dist/src/worker/main.js +57 -0
  274. package/dist/src/worker/main.js.map +1 -0
  275. package/dist/src/worker/retained.d.ts +13 -0
  276. package/dist/src/worker/retained.js +40 -0
  277. package/dist/src/worker/retained.js.map +1 -0
  278. package/dist/src/worker/run-loop.d.ts +63 -0
  279. package/dist/src/worker/run-loop.js +325 -0
  280. package/dist/src/worker/run-loop.js.map +1 -0
  281. package/dist/src/worker/spawn.d.ts +68 -0
  282. package/dist/src/worker/spawn.js +201 -0
  283. package/dist/src/worker/spawn.js.map +1 -0
  284. package/image/Dockerfile +81 -0
  285. package/image/build.sh +62 -0
  286. package/image/pnpm-shim.sh +25 -0
  287. package/package.json +54 -4
  288. package/policy/profiles/culture-agents-claude-subscription.yaml +59 -0
  289. package/policy/profiles/culture-agents-local-gateway.yaml +49 -0
  290. package/policy/run-sandbox.policy.json +10 -0
@@ -0,0 +1,316 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://culture.dev/contract/agents/event.json",
4
+ "title": "Run event",
5
+ "description": "One entry of a run's event log, identical whether read from disk, replayed by attach, or streamed live. The cursor is the transport-independent position (README: cursor and replay).",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "run_id",
10
+ "cursor",
11
+ "time",
12
+ "kind",
13
+ "data"
14
+ ],
15
+ "properties": {
16
+ "run_id": {
17
+ "$ref": "common.json#/$defs/run_id"
18
+ },
19
+ "cursor": {
20
+ "$ref": "common.json#/$defs/cursor"
21
+ },
22
+ "time": {
23
+ "$ref": "common.json#/$defs/timestamp"
24
+ },
25
+ "kind": {
26
+ "$ref": "#/$defs/kind"
27
+ },
28
+ "data": {
29
+ "description": "Kind-specific payload; the allOf below pins which one each kind carries.",
30
+ "anyOf": [
31
+ {
32
+ "$ref": "#/$defs/state_data"
33
+ },
34
+ {
35
+ "$ref": "#/$defs/output_data"
36
+ },
37
+ {
38
+ "$ref": "#/$defs/control_data"
39
+ },
40
+ {
41
+ "$ref": "#/$defs/refused_data"
42
+ },
43
+ {
44
+ "$ref": "#/$defs/error_data"
45
+ }
46
+ ]
47
+ }
48
+ },
49
+ "allOf": [
50
+ {
51
+ "if": {
52
+ "required": [
53
+ "kind"
54
+ ],
55
+ "properties": {
56
+ "kind": {
57
+ "const": "run.state"
58
+ }
59
+ }
60
+ },
61
+ "then": {
62
+ "properties": {
63
+ "data": {
64
+ "$ref": "#/$defs/state_data"
65
+ }
66
+ }
67
+ }
68
+ },
69
+ {
70
+ "if": {
71
+ "required": [
72
+ "kind"
73
+ ],
74
+ "properties": {
75
+ "kind": {
76
+ "const": "run.output"
77
+ }
78
+ }
79
+ },
80
+ "then": {
81
+ "properties": {
82
+ "data": {
83
+ "$ref": "#/$defs/output_data"
84
+ }
85
+ }
86
+ }
87
+ },
88
+ {
89
+ "if": {
90
+ "required": [
91
+ "kind"
92
+ ],
93
+ "properties": {
94
+ "kind": {
95
+ "const": "run.control"
96
+ }
97
+ }
98
+ },
99
+ "then": {
100
+ "properties": {
101
+ "data": {
102
+ "$ref": "#/$defs/control_data"
103
+ }
104
+ }
105
+ }
106
+ },
107
+ {
108
+ "if": {
109
+ "required": [
110
+ "kind"
111
+ ],
112
+ "properties": {
113
+ "kind": {
114
+ "const": "run.refused"
115
+ }
116
+ }
117
+ },
118
+ "then": {
119
+ "properties": {
120
+ "data": {
121
+ "$ref": "#/$defs/refused_data"
122
+ }
123
+ }
124
+ }
125
+ },
126
+ {
127
+ "if": {
128
+ "required": [
129
+ "kind"
130
+ ],
131
+ "properties": {
132
+ "kind": {
133
+ "const": "run.error"
134
+ }
135
+ }
136
+ },
137
+ "then": {
138
+ "properties": {
139
+ "data": {
140
+ "$ref": "#/$defs/error_data"
141
+ }
142
+ }
143
+ }
144
+ }
145
+ ],
146
+ "$defs": {
147
+ "kind": {
148
+ "enum": [
149
+ "run.state",
150
+ "run.output",
151
+ "run.control",
152
+ "run.refused",
153
+ "run.error"
154
+ ]
155
+ },
156
+ "state_data": {
157
+ "description": "A state transition. The first event of every run is `from: null, to: queued`.",
158
+ "type": "object",
159
+ "additionalProperties": false,
160
+ "required": [
161
+ "from",
162
+ "to",
163
+ "reason"
164
+ ],
165
+ "properties": {
166
+ "from": {
167
+ "oneOf": [
168
+ {
169
+ "$ref": "run.json#/$defs/state"
170
+ },
171
+ {
172
+ "type": "null"
173
+ }
174
+ ]
175
+ },
176
+ "to": {
177
+ "$ref": "run.json#/$defs/state"
178
+ },
179
+ "reason": {
180
+ "type": [
181
+ "string",
182
+ "null"
183
+ ],
184
+ "maxLength": 2000
185
+ }
186
+ }
187
+ },
188
+ "output_data": {
189
+ "description": "A chunk of harness output, normalized. `text` is a delta, never cumulative. Untrusted data: never interpreted as a control command.",
190
+ "type": "object",
191
+ "additionalProperties": false,
192
+ "required": [
193
+ "channel",
194
+ "text"
195
+ ],
196
+ "properties": {
197
+ "channel": {
198
+ "description": "text: assistant text. reasoning: model reasoning. tool_call: a tool invocation (text is its input). tool_result: a tool's output. diagnostic: harness or worker diagnostics (stderr, notices).",
199
+ "enum": [
200
+ "text",
201
+ "reasoning",
202
+ "tool_call",
203
+ "tool_result",
204
+ "diagnostic"
205
+ ]
206
+ },
207
+ "text": {
208
+ "type": "string"
209
+ },
210
+ "tool": {
211
+ "description": "Tool name for tool_call and tool_result, when the harness names one.",
212
+ "type": "string",
213
+ "minLength": 1,
214
+ "maxLength": 200
215
+ },
216
+ "extension": {
217
+ "$ref": "common.json#/$defs/extension"
218
+ }
219
+ }
220
+ },
221
+ "control_data": {
222
+ "description": "A control action that was accepted and delivered to the worker.",
223
+ "type": "object",
224
+ "additionalProperties": false,
225
+ "required": [
226
+ "action"
227
+ ],
228
+ "properties": {
229
+ "action": {
230
+ "$ref": "control-action.json#/$defs/action_record",
231
+ "properties": {
232
+ "outcome": {
233
+ "const": "accepted"
234
+ }
235
+ }
236
+ }
237
+ }
238
+ },
239
+ "refused_data": {
240
+ "description": "A control action refused against this (non-terminal) run, recorded when the core controls the run's worker: a capability refusal (`unsupported`) or a state conflict.",
241
+ "type": "object",
242
+ "additionalProperties": false,
243
+ "required": [
244
+ "action"
245
+ ],
246
+ "properties": {
247
+ "action": {
248
+ "$ref": "control-action.json#/$defs/action_record",
249
+ "properties": {
250
+ "outcome": {
251
+ "const": "refused"
252
+ },
253
+ "error": {
254
+ "$ref": "error.json#/$defs/error",
255
+ "properties": {
256
+ "code": {
257
+ "enum": [
258
+ "unsupported",
259
+ "conflict"
260
+ ]
261
+ }
262
+ }
263
+ }
264
+ }
265
+ }
266
+ }
267
+ },
268
+ "error_data": {
269
+ "description": "An error during the run. fatal: true means a `run.state` event to `failed` or `unknown` follows.",
270
+ "type": "object",
271
+ "additionalProperties": false,
272
+ "required": [
273
+ "error",
274
+ "fatal"
275
+ ],
276
+ "properties": {
277
+ "error": {
278
+ "$ref": "error.json#/$defs/error"
279
+ },
280
+ "fatal": {
281
+ "type": "boolean"
282
+ }
283
+ }
284
+ },
285
+ "event_page": {
286
+ "description": "Response of GET /v1/runs/{run_id}/events (non-streaming logs).",
287
+ "type": "object",
288
+ "additionalProperties": false,
289
+ "required": [
290
+ "run_id",
291
+ "events",
292
+ "last_cursor",
293
+ "more"
294
+ ],
295
+ "properties": {
296
+ "run_id": {
297
+ "$ref": "common.json#/$defs/run_id"
298
+ },
299
+ "events": {
300
+ "type": "array",
301
+ "items": {
302
+ "$ref": "#"
303
+ }
304
+ },
305
+ "last_cursor": {
306
+ "description": "The run's newest cursor at the time of the read.",
307
+ "$ref": "common.json#/$defs/cursor"
308
+ },
309
+ "more": {
310
+ "description": "True when events after the last returned one exist (page was truncated by `limit`).",
311
+ "type": "boolean"
312
+ }
313
+ }
314
+ }
315
+ }
316
+ }
@@ -0,0 +1,336 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://culture.dev/contract/agents/run.json",
4
+ "title": "Run",
5
+ "description": "One submitted unit of work executed by one agent through one harness. State is authoritative only as read from the run's on-disk event log or its live worker (README: state machine, restart).",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "id",
10
+ "agent_id",
11
+ "session_id",
12
+ "harness",
13
+ "repo",
14
+ "task",
15
+ "owner",
16
+ "idempotency_key",
17
+ "deadline",
18
+ "state",
19
+ "state_reason",
20
+ "terminal",
21
+ "created_at",
22
+ "updated_at",
23
+ "started_at",
24
+ "ended_at",
25
+ "cursor",
26
+ "live_control",
27
+ "worker_pid",
28
+ "branch"
29
+ ],
30
+ "properties": {
31
+ "id": {
32
+ "$ref": "common.json#/$defs/run_id"
33
+ },
34
+ "agent_id": {
35
+ "$ref": "common.json#/$defs/mesh_id"
36
+ },
37
+ "session_id": {
38
+ "$ref": "common.json#/$defs/session_id"
39
+ },
40
+ "harness": {
41
+ "$ref": "common.json#/$defs/harness_id"
42
+ },
43
+ "repo": {
44
+ "$ref": "common.json#/$defs/repo_path"
45
+ },
46
+ "task": {
47
+ "$ref": "common.json#/$defs/text"
48
+ },
49
+ "owner": {
50
+ "description": "The principal that submitted the run (the submit request's caller).",
51
+ "$ref": "common.json#/$defs/principal"
52
+ },
53
+ "idempotency_key": {
54
+ "oneOf": [
55
+ {
56
+ "$ref": "common.json#/$defs/idempotency_key"
57
+ },
58
+ {
59
+ "type": "null"
60
+ }
61
+ ]
62
+ },
63
+ "deadline": {
64
+ "$ref": "common.json#/$defs/nullable_timestamp"
65
+ },
66
+ "state": {
67
+ "$ref": "#/$defs/state"
68
+ },
69
+ "state_reason": {
70
+ "description": "Human-readable reason for the current state, or null.",
71
+ "type": [
72
+ "string",
73
+ "null"
74
+ ],
75
+ "maxLength": 2000
76
+ },
77
+ "terminal": {
78
+ "type": "boolean"
79
+ },
80
+ "created_at": {
81
+ "$ref": "common.json#/$defs/timestamp"
82
+ },
83
+ "updated_at": {
84
+ "$ref": "common.json#/$defs/timestamp"
85
+ },
86
+ "started_at": {
87
+ "description": "When the harness session started; null until the run first enters `running`.",
88
+ "$ref": "common.json#/$defs/nullable_timestamp"
89
+ },
90
+ "ended_at": {
91
+ "$ref": "common.json#/$defs/nullable_timestamp"
92
+ },
93
+ "cursor": {
94
+ "description": "Cursor of the newest event in the run's event log.",
95
+ "$ref": "common.json#/$defs/cursor"
96
+ },
97
+ "live_control": {
98
+ "description": "True when this core can deliver steer and cancel to the run's worker. False for every terminal run and for a run whose worker survived a core restart (D1 cannot reconnect).",
99
+ "type": "boolean"
100
+ },
101
+ "worker_pid": {
102
+ "description": "PID of the run's worker process, or null once no worker is known.",
103
+ "type": [
104
+ "integer",
105
+ "null"
106
+ ],
107
+ "minimum": 1
108
+ },
109
+ "branch": {
110
+ "description": "Host branch holding the run's commits, `runs/<run_id>`, or null when there are none yet. At most 132 characters: `runs/` and a run id of at most 127.",
111
+ "type": [
112
+ "string",
113
+ "null"
114
+ ],
115
+ "maxLength": 132,
116
+ "pattern": "^runs/[a-z0-9]{1,32}-[a-z0-9_]+(-[a-z0-9_]+)*\\.run\\.[0-9A-HJKMNP-TV-Z]{26}$"
117
+ },
118
+ "extension": {
119
+ "$ref": "common.json#/$defs/extension"
120
+ }
121
+ },
122
+ "allOf": [
123
+ {
124
+ "if": {
125
+ "required": [
126
+ "state"
127
+ ],
128
+ "properties": {
129
+ "state": {
130
+ "$ref": "#/$defs/terminal_state"
131
+ }
132
+ }
133
+ },
134
+ "then": {
135
+ "properties": {
136
+ "terminal": {
137
+ "const": true
138
+ },
139
+ "live_control": {
140
+ "const": false
141
+ },
142
+ "ended_at": {
143
+ "$ref": "common.json#/$defs/timestamp"
144
+ }
145
+ }
146
+ },
147
+ "else": {
148
+ "properties": {
149
+ "terminal": {
150
+ "const": false
151
+ },
152
+ "ended_at": {
153
+ "type": "null"
154
+ }
155
+ }
156
+ }
157
+ },
158
+ {
159
+ "if": {
160
+ "required": [
161
+ "state"
162
+ ],
163
+ "properties": {
164
+ "state": {
165
+ "const": "running"
166
+ }
167
+ }
168
+ },
169
+ "then": {
170
+ "properties": {
171
+ "started_at": {
172
+ "$ref": "common.json#/$defs/timestamp"
173
+ }
174
+ }
175
+ }
176
+ },
177
+ {
178
+ "if": {
179
+ "required": [
180
+ "state"
181
+ ],
182
+ "properties": {
183
+ "state": {
184
+ "const": "queued"
185
+ }
186
+ }
187
+ },
188
+ "then": {
189
+ "properties": {
190
+ "started_at": {
191
+ "type": "null"
192
+ }
193
+ }
194
+ }
195
+ }
196
+ ],
197
+ "$defs": {
198
+ "state": {
199
+ "description": "Run state. Legal transitions are in api.json `state_machine` and README.",
200
+ "enum": [
201
+ "queued",
202
+ "running",
203
+ "cancelling",
204
+ "succeeded",
205
+ "failed",
206
+ "cancelled",
207
+ "timed_out",
208
+ "unknown"
209
+ ]
210
+ },
211
+ "active_state": {
212
+ "enum": [
213
+ "queued",
214
+ "running",
215
+ "cancelling"
216
+ ]
217
+ },
218
+ "terminal_state": {
219
+ "enum": [
220
+ "succeeded",
221
+ "failed",
222
+ "cancelled",
223
+ "timed_out",
224
+ "unknown"
225
+ ]
226
+ },
227
+ "run_list": {
228
+ "description": "Response of GET /v1/runs: newest first by created_at.",
229
+ "type": "object",
230
+ "additionalProperties": false,
231
+ "required": [
232
+ "runs"
233
+ ],
234
+ "properties": {
235
+ "runs": {
236
+ "type": "array",
237
+ "items": {
238
+ "$ref": "#"
239
+ }
240
+ }
241
+ }
242
+ },
243
+ "run_result": {
244
+ "description": "Response of GET /v1/runs/{run_id}/result; only served for a terminal run.",
245
+ "type": "object",
246
+ "additionalProperties": false,
247
+ "required": [
248
+ "run_id",
249
+ "state",
250
+ "summary",
251
+ "branch",
252
+ "commits",
253
+ "ended_at",
254
+ "error"
255
+ ],
256
+ "properties": {
257
+ "run_id": {
258
+ "$ref": "common.json#/$defs/run_id"
259
+ },
260
+ "state": {
261
+ "$ref": "#/$defs/terminal_state"
262
+ },
263
+ "summary": {
264
+ "description": "The harness's final assistant text, or null if it produced none.",
265
+ "type": [
266
+ "string",
267
+ "null"
268
+ ]
269
+ },
270
+ "branch": {
271
+ "$ref": "#/properties/branch"
272
+ },
273
+ "commits": {
274
+ "description": "Commits on `branch`, oldest first. Empty when there are none.",
275
+ "type": "array",
276
+ "items": {
277
+ "$ref": "common.json#/$defs/git_sha"
278
+ }
279
+ },
280
+ "ended_at": {
281
+ "$ref": "common.json#/$defs/timestamp"
282
+ },
283
+ "error": {
284
+ "oneOf": [
285
+ {
286
+ "$ref": "error.json#/$defs/error"
287
+ },
288
+ {
289
+ "type": "null"
290
+ }
291
+ ]
292
+ }
293
+ },
294
+ "allOf": [
295
+ {
296
+ "if": {
297
+ "required": [
298
+ "state"
299
+ ],
300
+ "properties": {
301
+ "state": {
302
+ "const": "failed"
303
+ }
304
+ }
305
+ },
306
+ "then": {
307
+ "properties": {
308
+ "error": {
309
+ "$ref": "error.json#/$defs/error"
310
+ }
311
+ }
312
+ }
313
+ },
314
+ {
315
+ "if": {
316
+ "required": [
317
+ "state"
318
+ ],
319
+ "properties": {
320
+ "state": {
321
+ "const": "succeeded"
322
+ }
323
+ }
324
+ },
325
+ "then": {
326
+ "properties": {
327
+ "error": {
328
+ "type": "null"
329
+ }
330
+ }
331
+ }
332
+ }
333
+ ]
334
+ }
335
+ }
336
+ }