@culture.dev/agents 0.0.0-stage → 0.15.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 (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,77 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://culture.dev/contract/agents/session.json",
4
+ "title": "Session",
5
+ "description": "A harness conversation that one or more runs execute in. In D1 every submit opens a new session holding exactly that run, and the session closes when the run reaches a terminal state; continuing a session is the deferred capability `continue_session`.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "id",
10
+ "agent_id",
11
+ "harness",
12
+ "run_ids",
13
+ "state",
14
+ "created_at",
15
+ "closed_at"
16
+ ],
17
+ "properties": {
18
+ "id": {
19
+ "$ref": "common.json#/$defs/session_id"
20
+ },
21
+ "agent_id": {
22
+ "$ref": "common.json#/$defs/mesh_id"
23
+ },
24
+ "harness": {
25
+ "$ref": "common.json#/$defs/harness_id"
26
+ },
27
+ "run_ids": {
28
+ "description": "Runs in this session, oldest first.",
29
+ "type": "array",
30
+ "minItems": 1,
31
+ "uniqueItems": true,
32
+ "items": {
33
+ "$ref": "common.json#/$defs/run_id"
34
+ }
35
+ },
36
+ "state": {
37
+ "enum": [
38
+ "open",
39
+ "closed"
40
+ ]
41
+ },
42
+ "created_at": {
43
+ "$ref": "common.json#/$defs/timestamp"
44
+ },
45
+ "closed_at": {
46
+ "$ref": "common.json#/$defs/nullable_timestamp"
47
+ }
48
+ },
49
+ "allOf": [
50
+ {
51
+ "if": {
52
+ "required": [
53
+ "state"
54
+ ],
55
+ "properties": {
56
+ "state": {
57
+ "const": "closed"
58
+ }
59
+ }
60
+ },
61
+ "then": {
62
+ "properties": {
63
+ "closed_at": {
64
+ "$ref": "common.json#/$defs/timestamp"
65
+ }
66
+ }
67
+ },
68
+ "else": {
69
+ "properties": {
70
+ "closed_at": {
71
+ "type": "null"
72
+ }
73
+ }
74
+ }
75
+ }
76
+ ]
77
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://culture.dev/contract/agents/version.json",
4
+ "title": "Version",
5
+ "description": "Response of GET /v1/version, the first call a client makes on connect (README: versioning).",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["api_version", "core_version", "node"],
9
+ "properties": {
10
+ "api_version": { "$ref": "common.json#/$defs/api_version" },
11
+ "core_version": {
12
+ "description": "The core package's own release version (semver); informational, never used for compatibility.",
13
+ "type": "string",
14
+ "minLength": 1,
15
+ "maxLength": 64
16
+ },
17
+ "node": {
18
+ "description": "The node this core runs on; the `<node>` of every agent it can execute in D1.",
19
+ "$ref": "common.json#/$defs/node"
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,41 @@
1
+ import type { ErrorCode, RunState } from "./generated/index.js";
2
+ /** The parts of `api.json` that this module reads. */
3
+ interface ApiIndex {
4
+ api_version: string;
5
+ errors: Record<ErrorCode, {
6
+ http_status: number;
7
+ exit_code: number;
8
+ retryable: boolean | null;
9
+ }>;
10
+ state_machine: {
11
+ initial: RunState;
12
+ active: RunState[];
13
+ terminal: RunState[];
14
+ transitions: Record<RunState, RunState[]>;
15
+ };
16
+ }
17
+ export declare const api: ApiIndex;
18
+ /** The contract version this build speaks, from `api.json` (`MAJOR.MINOR`). */
19
+ export declare const apiVersion: string;
20
+ /** HTTP header every request carries (api.json `transport.version_header`). */
21
+ export declare const API_VERSION_HEADER = "Agents-Api-Version";
22
+ export interface ApiVersion {
23
+ major: number;
24
+ minor: number;
25
+ }
26
+ /** Parse `MAJOR.MINOR`; returns null for anything else. */
27
+ export declare function parseApiVersion(text: string): ApiVersion | null;
28
+ /**
29
+ * Compatibility rule: a client at `C.x` and a core at `S.y` are compatible exactly when
30
+ * `C == S` and `y >= x`. An unparseable version is never compatible.
31
+ */
32
+ export declare function isCompatible(clientVersion: string, serverVersion: string): boolean;
33
+ /** HTTP status for an error code (api.json `errors`). */
34
+ export declare function httpStatusFor(code: ErrorCode): number;
35
+ /** CLI exit code for an error code: 1 for a user error, 2 for an environment error. */
36
+ export declare function exitCodeFor(code: ErrorCode): number;
37
+ /** Fixed `retryable` for a code; null when it varies (`conflict`). */
38
+ export declare function retryableFor(code: ErrorCode): boolean | null;
39
+ /** Every error code in api.json. */
40
+ export declare const errorCodes: ErrorCode[];
41
+ export {};
@@ -0,0 +1,35 @@
1
+ import { loadJson } from "./schemas.js";
2
+ export const api = loadJson("api.json");
3
+ /** The contract version this build speaks, from `api.json` (`MAJOR.MINOR`). */
4
+ export const apiVersion = api.api_version;
5
+ /** HTTP header every request carries (api.json `transport.version_header`). */
6
+ export const API_VERSION_HEADER = "Agents-Api-Version";
7
+ /** Parse `MAJOR.MINOR`; returns null for anything else. */
8
+ export function parseApiVersion(text) {
9
+ const m = /^(\d+)\.(\d+)$/.exec(text);
10
+ return m ? { major: Number(m[1]), minor: Number(m[2]) } : null;
11
+ }
12
+ /**
13
+ * Compatibility rule: a client at `C.x` and a core at `S.y` are compatible exactly when
14
+ * `C == S` and `y >= x`. An unparseable version is never compatible.
15
+ */
16
+ export function isCompatible(clientVersion, serverVersion) {
17
+ const c = parseApiVersion(clientVersion);
18
+ const s = parseApiVersion(serverVersion);
19
+ return c !== null && s !== null && c.major === s.major && s.minor >= c.minor;
20
+ }
21
+ /** HTTP status for an error code (api.json `errors`). */
22
+ export function httpStatusFor(code) {
23
+ return api.errors[code].http_status;
24
+ }
25
+ /** CLI exit code for an error code: 1 for a user error, 2 for an environment error. */
26
+ export function exitCodeFor(code) {
27
+ return api.errors[code].exit_code;
28
+ }
29
+ /** Fixed `retryable` for a code; null when it varies (`conflict`). */
30
+ export function retryableFor(code) {
31
+ return api.errors[code].retryable;
32
+ }
33
+ /** Every error code in api.json. */
34
+ export const errorCodes = Object.keys(api.errors);
35
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/contract/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAcxC,MAAM,CAAC,MAAM,GAAG,GAAG,QAAQ,CAAC,UAAU,CAAa,CAAC;AAEpD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,UAAU,GAAW,GAAG,CAAC,WAAW,CAAC;AAElD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAOvD,2DAA2D;AAC3D,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACjE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,aAAqB,EAAE,aAAqB;IACvE,MAAM,CAAC,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC;IACzC,MAAM,CAAC,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC;IACzC,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC;AAC/E,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,aAAa,CAAC,IAAe;IAC3C,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;AACtC,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,WAAW,CAAC,IAAe;IACzC,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC;AACpC,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,YAAY,CAAC,IAAe;IAC1C,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC;AACpC,CAAC;AAED,oCAAoC;AACpC,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAgB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { ErrorBody } from "./generated/index.js";
2
+ /** One schema violation, flattened from the validator's output. */
3
+ export interface ValidationIssue {
4
+ /** JSON Pointer to the offending value ("" is the document root). A missing required property is reported at that property. */
5
+ path: string;
6
+ /** The JSON Schema keyword that failed (`required`, `pattern`, `additionalProperties`, ...). */
7
+ keyword: string;
8
+ message: string;
9
+ }
10
+ /**
11
+ * Thrown by `assertValid`. Carries the contract error code `invalid` and the failing
12
+ * path, so a daemon can answer with `toBody()` as-is.
13
+ */
14
+ export declare class ContractValidationError extends Error {
15
+ readonly code: "invalid";
16
+ readonly path: string;
17
+ readonly issues: readonly ValidationIssue[];
18
+ constructor(schemaName: string, issues: readonly ValidationIssue[]);
19
+ /** The `error.json` body for this failure (`field` is omitted for a root-level failure). */
20
+ toBody(): ErrorBody;
21
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Thrown by `assertValid`. Carries the contract error code `invalid` and the failing
3
+ * path, so a daemon can answer with `toBody()` as-is.
4
+ */
5
+ export class ContractValidationError extends Error {
6
+ code = "invalid";
7
+ path;
8
+ issues;
9
+ constructor(schemaName, issues) {
10
+ const first = issues[0];
11
+ const path = first?.path ?? "";
12
+ super(`${schemaName} is invalid at ${path === "" ? "(root)" : path}: ${first?.message ?? "unknown"}`);
13
+ this.name = "ContractValidationError";
14
+ this.path = path;
15
+ this.issues = issues;
16
+ }
17
+ /** The `error.json` body for this failure (`field` is omitted for a root-level failure). */
18
+ toBody() {
19
+ const body = { code: "invalid", message: this.message.slice(0, 2000), retryable: false };
20
+ if (this.path !== "")
21
+ body.field = this.path.slice(0, 200);
22
+ return body;
23
+ }
24
+ }
25
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/contract/errors.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACvC,IAAI,GAAG,SAAkB,CAAC;IAC1B,IAAI,CAAS;IACb,MAAM,CAA6B;IAE5C,YAAY,UAAkB,EAAE,MAAkC;QAChE,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,MAAM,IAAI,GAAG,KAAK,EAAE,IAAI,IAAI,EAAE,CAAC;QAC/B,KAAK,CAAC,GAAG,UAAU,kBAAkB,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,EAAE,OAAO,IAAI,SAAS,EAAE,CAAC,CAAC;QACtG,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,4FAA4F;IAC5F,MAAM;QACJ,MAAM,IAAI,GAAc,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QACpG,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE;YAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,31 @@
1
+ import type { Capabilities } from "./capabilities.js";
2
+ import type { HarnessId, MeshId, MeshNode, RepoPath, RunId, Suffix } from "./common.js";
3
+ /** An agent known to the core. In D1 an agent is known exactly when at least one allow-list entry names it; `harnesses` and `repos` are the union of its allow-list entries. */
4
+ export type Agent = {
5
+ /** Mesh id; always equals `<node>-<suffix>`. */
6
+ id: MeshId;
7
+ node: MeshNode;
8
+ suffix: Suffix;
9
+ harnesses: HarnessId[];
10
+ repos: RepoPath[];
11
+ /** idle: no active run. running: at least one active run. unavailable: none of its harnesses is available on this core. */
12
+ state: "idle" | "running" | "unavailable";
13
+ /** Runs of this agent in an active state (queued, running, cancelling). */
14
+ active_run_ids: RunId[];
15
+ } & (({
16
+ state: "idle";
17
+ } & {
18
+ active_run_ids: unknown;
19
+ }) | ({
20
+ state: "running";
21
+ } & {
22
+ active_run_ids: unknown;
23
+ }) | ({
24
+ state: Exclude<"idle" | "running" | "unavailable", "idle" | "running">;
25
+ }));
26
+ /** Response of GET /v1/agents: the core's node, every known agent, and every harness capability document, so one call serves `agents agents list --json`. */
27
+ export type AgentList = {
28
+ node: MeshNode;
29
+ agents: Agent[];
30
+ harnesses: Capabilities[];
31
+ };
@@ -0,0 +1,3 @@
1
+ // GENERATED by core/scripts/gen-contract-types.mjs from contract/agent.json. Do not edit.
2
+ export {};
3
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../../src/contract/generated/agent.ts"],"names":[],"mappings":"AAAA,0FAA0F"}
@@ -0,0 +1,10 @@
1
+ import type { HarnessId, MeshId, RepoPath } from "./common.js";
2
+ /** The core's local dispatch allow-list file (README: authorization). Not an API payload: no route reads or writes it. It ships empty, and a submit is allowed only when one entry matches its agent, harness and repo exactly. */
3
+ export type Allowlist = {
4
+ version: 1;
5
+ entries: {
6
+ agent_id: MeshId;
7
+ harness: HarnessId;
8
+ repo: RepoPath;
9
+ }[];
10
+ };
@@ -0,0 +1,3 @@
1
+ // GENERATED by core/scripts/gen-contract-types.mjs from contract/allowlist.json. Do not edit.
2
+ export {};
3
+ //# sourceMappingURL=allowlist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allowlist.js","sourceRoot":"","sources":["../../../../src/contract/generated/allowlist.ts"],"names":[],"mappings":"AAAA,8FAA8F"}
@@ -0,0 +1,46 @@
1
+ import type { Extension, HarnessId } from "./common.js";
2
+ /** 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. */
3
+ export type Capabilities = {
4
+ harness: HarnessId;
5
+ /** Whether the core can start this harness right now (binary, credentials and sandbox present). */
6
+ available: boolean;
7
+ /** The harness's own version string as detected, or null if unknown. */
8
+ version: string | null;
9
+ /** Neutral one-line description of how the core drives the harness (for example `interactive session over a local bridge`). Informational only. */
10
+ transport: string;
11
+ capabilities: CapabilitySet;
12
+ extension?: Extension;
13
+ };
14
+ /** Every capability the contract can name in a capability document or an `unsupported` error. */
15
+ export type CapabilityName = "submit" | "stream" | "steer" | "cancel" | "pause" | "resume" | "answer" | "continue_session" | "delegate" | "placement" | "reconnect" | "worktree_isolation";
16
+ export type Capability = {
17
+ supported: boolean;
18
+ /** Why it is unsupported (required then), or null when supported. */
19
+ reason: string | null;
20
+ /** Known limits of a supported capability, for example that cancel can leave a harness child process running until the sandbox is deleted. */
21
+ caveats: string[];
22
+ };
23
+ /** A capability no harness supports in this API version. Changing it to supportable is a schema change (README: versioning). */
24
+ export type Deferred = {
25
+ supported: false;
26
+ reason: string;
27
+ caveats: unknown[];
28
+ };
29
+ export type CapabilitySet = {
30
+ submit: Capability;
31
+ stream: Capability;
32
+ steer: Capability;
33
+ cancel: Capability;
34
+ pause: Deferred;
35
+ resume: Deferred;
36
+ answer: Deferred;
37
+ continue_session: Deferred;
38
+ delegate: Deferred;
39
+ placement: Deferred;
40
+ reconnect: Deferred;
41
+ worktree_isolation: Deferred;
42
+ };
43
+ /** Response of GET /v1/harnesses. */
44
+ export type CapabilitiesList = {
45
+ harnesses: Capabilities[];
46
+ };
@@ -0,0 +1,3 @@
1
+ // GENERATED by core/scripts/gen-contract-types.mjs from contract/capabilities.json. Do not edit.
2
+ export {};
3
+ //# sourceMappingURL=capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../../../src/contract/generated/capabilities.ts"],"names":[],"mappings":"AAAA,iGAAiG"}
@@ -0,0 +1,40 @@
1
+ /** Identifiers, timestamps and small value types shared by every contract schema. See contract/README.md for semantics. */
2
+ export type Common = unknown;
3
+ /** Mesh node name, the `<node>` part of a `<node>-<agent>` identity. No hyphen, so the first hyphen of a mesh id always ends the node. */
4
+ export type MeshNode = string;
5
+ /** Agent suffix, the `<agent>` part of a `<node>-<agent>` identity (culture.yaml `suffix`). */
6
+ export type Suffix = string;
7
+ /** A mesh identity in `<node>-<agent>` form, used for agents and for principals (operators and agents). The node is 1 to 32 characters and the whole id at most 96. */
8
+ export type MeshId = string;
9
+ /** A ULID: 26 Crockford base32 characters, uppercase. */
10
+ export type Ulid = string;
11
+ /** Stable run id: `<node>-<agent>.run.<ULID>`, where `<node>-<agent>` is the executing agent's mesh id. At most 127 characters: a mesh id of at most 96, then the 31 of `.run.<ULID>`. */
12
+ export type RunId = string;
13
+ /** Stable session id: `<node>-<agent>.ses.<ULID>`. At most 127 characters: a mesh id of at most 96, then the 31 of `.ses.<ULID>`. */
14
+ export type SessionId = string;
15
+ /** Stable control-action id: `<node>-<agent>.act.<ULID>`, using the target run's agent. At most 127 characters: a mesh id of at most 96, then the 31 of `.act.<ULID>`. */
16
+ export type ActionId = string;
17
+ /** Harness identifier, a free lowercase string (for example `claude-code`, `opencode`). Deliberately not an enum. */
18
+ export type HarnessId = string;
19
+ /** RFC 3339 timestamp in UTC with a `Z` suffix and optional fractional seconds. */
20
+ export type Timestamp = string;
21
+ /** A timestamp (same pattern as `timestamp`) or null. */
22
+ export type NullableTimestamp = string | null;
23
+ /** Absolute POSIX path of a repository on the core's host, with no `.` or `..` segments, no trailing slash and no control characters (a newline would hide a `..` segment from the pattern). */
24
+ export type RepoPath = string;
25
+ /** Caller-chosen key, recorded and returned. D1 does not deduplicate on it (see README). */
26
+ export type IdempotencyKey = string;
27
+ /** Per-run event cursor: the first event is 1 and each next event is exactly 1 higher. */
28
+ export type Cursor = number;
29
+ /** API version `MAJOR.MINOR`. */
30
+ export type ApiVersion = string;
31
+ /** Free text from a caller (task, steer message). Untrusted data, never a control command. */
32
+ export type CallerText = string;
33
+ export type GitSha = string;
34
+ /** 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. */
35
+ export type Principal = {
36
+ kind: "operator" | "agent";
37
+ id: MeshId;
38
+ };
39
+ /** The single opaque field for harness-specific data. Consumers must not depend on its contents, must not branch control flow on it, and must treat it as untrusted. Its shape is outside the contract and is not versioned. */
40
+ export type Extension = Record<string, unknown>;
@@ -0,0 +1,3 @@
1
+ // GENERATED by core/scripts/gen-contract-types.mjs from contract/common.json. Do not edit.
2
+ export {};
3
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../src/contract/generated/common.ts"],"names":[],"mappings":"AAAA,2FAA2F"}
@@ -0,0 +1,73 @@
1
+ import type { ActionId, CallerText, HarnessId, IdempotencyKey, MeshId, Principal, RepoPath, RunId, SessionId, Timestamp } from "./common.js";
2
+ import type { ErrorBody } from "./error.js";
3
+ import type { Run } from "./run.js";
4
+ /** Requests that create or control a run, their responses, and the record of a control action against an existing run. The root schema is that record. */
5
+ export type ControlAction = ActionRecord;
6
+ /** Control actions against an existing run. pause, resume and answer are deferred: always refused with `unsupported` in this API version. */
7
+ export type ActionKind = "steer" | "cancel" | "pause" | "resume" | "answer";
8
+ /** One control action against a run, as recorded in the run's event log and returned by an accepting route. */
9
+ export type ActionRecord = {
10
+ id: ActionId;
11
+ run_id: RunId;
12
+ kind: ActionKind;
13
+ caller: Principal;
14
+ requested_at: Timestamp;
15
+ idempotency_key: IdempotencyKey | null;
16
+ /** accepted: delivered to the run's worker. It does not promise any effect on the harness's behaviour. refused: not delivered; `error` says why. */
17
+ outcome: "accepted" | "refused";
18
+ error: ErrorBody | null;
19
+ };
20
+ /** Body of POST /v1/runs. Optional fields are omitted, never null. Setting `session_id` asks for `continue_session` and setting `parent_run_id` asks for `delegate`; both are refused with `unsupported` in this API version, as is an `agent_id` whose node is not the core's node (`placement`). */
21
+ export type SubmitRequest = {
22
+ agent_id: MeshId;
23
+ harness: HarnessId;
24
+ repo: RepoPath;
25
+ task: CallerText;
26
+ caller: Principal;
27
+ idempotency_key?: IdempotencyKey;
28
+ /** Absolute UTC time by which the run must be terminal; must be later than the core's clock at submit. */
29
+ deadline?: Timestamp;
30
+ session_id?: SessionId;
31
+ parent_run_id?: RunId;
32
+ };
33
+ /** 201 response of POST /v1/runs. The run is in state `queued` and its worker's PID, event log and cursor are on disk. */
34
+ export type SubmitResponse = {
35
+ run: Run & {
36
+ state?: "queued";
37
+ };
38
+ };
39
+ /** Body of POST /v1/runs/{run_id}/steer: a mid-run instruction delivered to the harness as user input. */
40
+ export type SteerRequest = {
41
+ caller: Principal;
42
+ message: CallerText;
43
+ idempotency_key?: IdempotencyKey;
44
+ };
45
+ /** Body of POST /v1/runs/{run_id}/cancel. */
46
+ export type CancelRequest = {
47
+ caller: Principal;
48
+ reason?: string;
49
+ idempotency_key?: IdempotencyKey;
50
+ };
51
+ /** Body of POST /v1/runs/{run_id}/pause (deferred; always refused with `unsupported`, capability `pause`). */
52
+ export type PauseRequest = {
53
+ caller: Principal;
54
+ idempotency_key?: IdempotencyKey;
55
+ };
56
+ /** Body of POST /v1/runs/{run_id}/resume (deferred; always refused with `unsupported`, capability `resume`). */
57
+ export type ResumeRequest = {
58
+ caller: Principal;
59
+ idempotency_key?: IdempotencyKey;
60
+ };
61
+ /** Body of POST /v1/runs/{run_id}/answer (deferred; always refused with `unsupported`, capability `answer`). */
62
+ export type AnswerRequest = {
63
+ caller: Principal;
64
+ question_id: string;
65
+ answer: CallerText;
66
+ idempotency_key?: IdempotencyKey;
67
+ };
68
+ /** 202 response of steer and cancel: the recorded, accepted action. */
69
+ export type AcceptedResponse = {
70
+ action: ActionRecord & {
71
+ outcome?: "accepted";
72
+ };
73
+ };
@@ -0,0 +1,3 @@
1
+ // GENERATED by core/scripts/gen-contract-types.mjs from contract/control-action.json. Do not edit.
2
+ export {};
3
+ //# sourceMappingURL=control-action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control-action.js","sourceRoot":"","sources":["../../../../src/contract/generated/control-action.ts"],"names":[],"mappings":"AAAA,mGAAmG"}
@@ -0,0 +1,25 @@
1
+ import type { CapabilityName } from "./capabilities.js";
2
+ import type { ApiVersion, RepoPath, RunId } from "./common.js";
3
+ /** Body of every non-2xx response. HTTP status, CLI exit code and retryability per code are fixed in api.json `errors` and README. */
4
+ export type ErrorResponse = {
5
+ error: ErrorBody;
6
+ };
7
+ export type ErrorCode = "invalid" | "denied" | "not_found" | "busy" | "conflict" | "unsupported" | "incompatible_version" | "unavailable" | "internal";
8
+ export type ErrorBody = {
9
+ code: ErrorCode;
10
+ /** One human-readable sentence; for environment errors it includes a remediation hint. */
11
+ message: string;
12
+ retryable: boolean;
13
+ /** unsupported only: the capability that was refused. */
14
+ capability?: CapabilityName;
15
+ /** invalid only (optional): JSON Pointer to the offending request field, or a query/path parameter name. */
16
+ field?: string;
17
+ /** The run the error concerns, when there is one. Required for conflict. */
18
+ run_id?: RunId;
19
+ /** busy only: the active run holding the repository. */
20
+ active_run_id?: RunId;
21
+ /** busy only: the canonical repository path that is busy. */
22
+ repo?: RepoPath;
23
+ client_api_version?: ApiVersion;
24
+ server_api_version?: ApiVersion;
25
+ };
@@ -0,0 +1,3 @@
1
+ // GENERATED by core/scripts/gen-contract-types.mjs from contract/error.json. Do not edit.
2
+ export {};
3
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../src/contract/generated/error.ts"],"names":[],"mappings":"AAAA,0FAA0F"}
@@ -0,0 +1,80 @@
1
+ import type { Cursor, Extension, RunId, Timestamp } from "./common.js";
2
+ import type { ActionRecord } from "./control-action.js";
3
+ import type { ErrorBody } from "./error.js";
4
+ import type { RunState } from "./run.js";
5
+ /** 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
+ export type RunEvent = {
7
+ run_id: RunId;
8
+ cursor: Cursor;
9
+ time: Timestamp;
10
+ kind: EventKind;
11
+ /** Kind-specific payload; the allOf below pins which one each kind carries. */
12
+ data: StateData | OutputData | ControlData | RefusedData | ErrorData;
13
+ } & (({
14
+ kind: "run.state";
15
+ } & {
16
+ data: StateData;
17
+ }) | ({
18
+ kind: "run.output";
19
+ } & {
20
+ data: OutputData;
21
+ }) | ({
22
+ kind: "run.control";
23
+ } & {
24
+ data: ControlData;
25
+ }) | ({
26
+ kind: "run.refused";
27
+ } & {
28
+ data: RefusedData;
29
+ }) | ({
30
+ kind: "run.error";
31
+ } & {
32
+ data: ErrorData;
33
+ }) | ({
34
+ kind: Exclude<EventKind, "run.state" | "run.output" | "run.control" | "run.refused" | "run.error">;
35
+ }));
36
+ export type EventKind = "run.state" | "run.output" | "run.control" | "run.refused" | "run.error";
37
+ /** A state transition. The first event of every run is `from: null, to: queued`. */
38
+ export type StateData = {
39
+ from: RunState | null;
40
+ to: RunState;
41
+ reason: string | null;
42
+ };
43
+ /** A chunk of harness output, normalized. `text` is a delta, never cumulative. Untrusted data: never interpreted as a control command. */
44
+ export type OutputData = {
45
+ /** 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). */
46
+ channel: "text" | "reasoning" | "tool_call" | "tool_result" | "diagnostic";
47
+ text: string;
48
+ /** Tool name for tool_call and tool_result, when the harness names one. */
49
+ tool?: string;
50
+ extension?: Extension;
51
+ };
52
+ /** A control action that was accepted and delivered to the worker. */
53
+ export type ControlData = {
54
+ action: ActionRecord & {
55
+ outcome?: "accepted";
56
+ };
57
+ };
58
+ /** 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. */
59
+ export type RefusedData = {
60
+ action: ActionRecord & ({
61
+ outcome?: "refused";
62
+ error?: ErrorBody & ({
63
+ code?: "unsupported" | "conflict";
64
+ });
65
+ });
66
+ };
67
+ /** An error during the run. fatal: true means a `run.state` event to `failed` or `unknown` follows. */
68
+ export type ErrorData = {
69
+ error: ErrorBody;
70
+ fatal: boolean;
71
+ };
72
+ /** Response of GET /v1/runs/{run_id}/events (non-streaming logs). */
73
+ export type EventPage = {
74
+ run_id: RunId;
75
+ events: RunEvent[];
76
+ /** The run's newest cursor at the time of the read. */
77
+ last_cursor: Cursor;
78
+ /** True when events after the last returned one exist (page was truncated by `limit`). */
79
+ more: boolean;
80
+ };
@@ -0,0 +1,3 @@
1
+ // GENERATED by core/scripts/gen-contract-types.mjs from contract/event.json. Do not edit.
2
+ export {};
3
+ //# sourceMappingURL=event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../../../../src/contract/generated/event.ts"],"names":[],"mappings":"AAAA,0FAA0F"}