owenloop 0.4.1 → 0.5.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 (282) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/README.md +182 -53
  3. package/bin/owenloop.mjs +50 -2
  4. package/dist/packages/work/src/agent/brief.d.ts +176 -0
  5. package/dist/packages/work/src/agent/brief.js +197 -0
  6. package/dist/packages/work/src/agent/loop.d.ts +141 -0
  7. package/dist/packages/work/src/agent/loop.js +669 -0
  8. package/dist/packages/work/src/agent/model-policy.d.ts +49 -0
  9. package/dist/packages/work/src/agent/model-policy.js +138 -0
  10. package/dist/packages/work/src/agent/workdir.d.ts +210 -0
  11. package/dist/packages/work/src/agent/workdir.js +319 -0
  12. package/dist/packages/work/src/bundle/cache.d.ts +92 -0
  13. package/dist/packages/work/src/bundle/cache.js +338 -0
  14. package/dist/packages/work/src/bundle/fetch.d.ts +87 -0
  15. package/dist/packages/work/src/bundle/fetch.js +345 -0
  16. package/dist/packages/work/src/bundle/types.d.ts +164 -0
  17. package/dist/packages/work/src/bundle/types.js +1 -0
  18. package/dist/packages/work/src/consumed-verifier.d.ts +45 -0
  19. package/dist/packages/work/src/consumed-verifier.js +205 -0
  20. package/dist/packages/work/src/credentials/owenloop.d.ts +11 -0
  21. package/dist/packages/work/src/credentials/owenloop.js +28 -0
  22. package/dist/packages/work/src/credentials/reader.d.ts +36 -0
  23. package/dist/packages/work/src/credentials/reader.js +32 -0
  24. package/dist/packages/work/src/credentials/resolve.d.ts +19 -0
  25. package/dist/packages/work/src/credentials/resolve.js +56 -0
  26. package/dist/packages/work/src/exec/instructions.d.ts +99 -0
  27. package/dist/packages/work/src/exec/instructions.js +323 -0
  28. package/dist/packages/work/src/exec/loop.d.ts +40 -0
  29. package/dist/packages/work/src/exec/loop.js +332 -0
  30. package/dist/packages/work/src/exec/payload.d.ts +29 -0
  31. package/dist/packages/work/src/exec/payload.js +54 -0
  32. package/dist/packages/work/src/exec/receipt.d.ts +41 -0
  33. package/dist/packages/work/src/exec/receipt.js +32 -0
  34. package/dist/packages/work/src/exec/runner.d.ts +71 -0
  35. package/dist/packages/work/src/exec/runner.js +256 -0
  36. package/dist/packages/work/src/harness/child-env.d.ts +100 -0
  37. package/dist/packages/work/src/harness/child-env.js +134 -0
  38. package/dist/packages/work/src/harness/claude.d.ts +140 -0
  39. package/dist/packages/work/src/harness/claude.js +837 -0
  40. package/dist/packages/work/src/harness/codex.d.ts +111 -0
  41. package/dist/packages/work/src/harness/codex.js +1024 -0
  42. package/dist/packages/work/src/harness/contract.d.ts +308 -0
  43. package/dist/packages/work/src/harness/contract.js +32 -0
  44. package/dist/packages/work/src/harness/fake.d.ts +59 -0
  45. package/dist/packages/work/src/harness/fake.js +91 -0
  46. package/dist/packages/work/src/harness/jsonrpc-stdio.d.ts +108 -0
  47. package/dist/packages/work/src/harness/jsonrpc-stdio.js +351 -0
  48. package/dist/packages/work/src/harness/permissions.d.ts +75 -0
  49. package/dist/packages/work/src/harness/permissions.js +182 -0
  50. package/dist/packages/work/src/harness/registry.d.ts +47 -0
  51. package/dist/packages/work/src/harness/registry.js +45 -0
  52. package/dist/packages/work/src/harness/session-store.d.ts +181 -0
  53. package/dist/packages/work/src/harness/session-store.js +523 -0
  54. package/dist/packages/work/src/harness/types.d.ts +29 -0
  55. package/dist/packages/work/src/harness/types.js +14 -0
  56. package/dist/packages/work/src/harnesses.d.ts +38 -0
  57. package/dist/packages/work/src/harnesses.js +38 -0
  58. package/dist/packages/work/src/hold/loop.d.ts +36 -0
  59. package/dist/packages/work/src/hold/loop.js +23 -0
  60. package/dist/packages/work/src/hold/mcp.d.ts +75 -0
  61. package/dist/packages/work/src/hold/mcp.js +264 -0
  62. package/dist/packages/work/src/hub/client.d.ts +23 -0
  63. package/dist/packages/work/src/hub/client.js +91 -0
  64. package/dist/packages/work/src/hub/types.d.ts +326 -0
  65. package/dist/packages/work/src/hub/types.js +26 -0
  66. package/dist/packages/work/src/lease/loop.d.ts +94 -0
  67. package/dist/packages/work/src/lease/loop.js +277 -0
  68. package/dist/packages/work/src/main.d.ts +1 -0
  69. package/dist/packages/work/src/main.js +48 -0
  70. package/dist/packages/work/src/mcp/server.d.ts +125 -0
  71. package/dist/packages/work/src/mcp/server.js +320 -0
  72. package/dist/packages/work/src/owenloop-bin.d.ts +1 -0
  73. package/dist/packages/work/src/owenloop-bin.js +18 -0
  74. package/dist/packages/work/src/roles/agent-run.d.ts +124 -0
  75. package/dist/packages/work/src/roles/agent-run.js +529 -0
  76. package/dist/packages/work/src/roles/exec.d.ts +48 -0
  77. package/dist/packages/work/src/roles/exec.js +228 -0
  78. package/dist/packages/work/src/roles/hold.d.ts +72 -0
  79. package/dist/packages/work/src/roles/hold.js +363 -0
  80. package/dist/packages/work/src/roles/join.d.ts +18 -0
  81. package/dist/packages/work/src/roles/join.js +204 -0
  82. package/dist/packages/work/src/roles/lint.d.ts +58 -0
  83. package/dist/packages/work/src/roles/lint.js +234 -0
  84. package/dist/packages/work/src/roles/prepare.d.ts +1 -0
  85. package/dist/packages/work/src/roles/prepare.js +249 -0
  86. package/dist/packages/work/src/roles/release.d.ts +48 -0
  87. package/dist/packages/work/src/roles/release.js +137 -0
  88. package/dist/packages/work/src/roles/sessions.d.ts +61 -0
  89. package/dist/packages/work/src/roles/sessions.js +180 -0
  90. package/dist/packages/work/src/roles/settings.d.ts +6 -0
  91. package/dist/packages/work/src/roles/settings.js +71 -0
  92. package/dist/packages/work/src/roles/shift.d.ts +13 -0
  93. package/dist/packages/work/src/roles/shift.js +250 -0
  94. package/dist/packages/work/src/roles/signals.d.ts +55 -0
  95. package/dist/packages/work/src/roles/signals.js +62 -0
  96. package/dist/packages/work/src/settings/provision.d.ts +21 -0
  97. package/dist/packages/work/src/settings/provision.js +47 -0
  98. package/dist/packages/work/src/settings/settings.d.ts +136 -0
  99. package/dist/packages/work/src/settings/settings.js +155 -0
  100. package/dist/packages/work/src/shift/client.d.ts +24 -0
  101. package/dist/packages/work/src/shift/client.js +124 -0
  102. package/dist/packages/work/src/shift/loop.d.ts +131 -0
  103. package/dist/packages/work/src/shift/loop.js +751 -0
  104. package/dist/packages/work/src/shift/protocol.d.ts +95 -0
  105. package/dist/packages/work/src/shift/protocol.js +24 -0
  106. package/dist/packages/work/src/shift/routing.d.ts +35 -0
  107. package/dist/packages/work/src/shift/routing.js +50 -0
  108. package/dist/packages/work/src/shift/runtime.d.ts +45 -0
  109. package/dist/packages/work/src/shift/runtime.js +337 -0
  110. package/dist/packages/work/src/shift/server.d.ts +23 -0
  111. package/dist/packages/work/src/shift/server.js +716 -0
  112. package/dist/packages/work/src/shift/spawn.d.ts +109 -0
  113. package/dist/packages/work/src/shift/spawn.js +158 -0
  114. package/dist/packages/work/src/shift/state.d.ts +79 -0
  115. package/dist/packages/work/src/shift/state.js +385 -0
  116. package/dist/packages/work/src/submit-proof.d.ts +36 -0
  117. package/dist/packages/work/src/submit-proof.js +93 -0
  118. package/dist/packages/work/src/usage.d.ts +6 -0
  119. package/dist/packages/work/src/usage.js +175 -0
  120. package/dist/src/add.d.ts +189 -0
  121. package/dist/src/add.js +300 -0
  122. package/dist/src/archive.d.ts +97 -0
  123. package/dist/src/archive.js +591 -0
  124. package/dist/src/bundle/index.d.ts +64 -0
  125. package/dist/src/bundle/index.js +508 -0
  126. package/dist/src/bundle/manifest.d.ts +50 -0
  127. package/dist/src/bundle/manifest.js +435 -0
  128. package/dist/src/bundle/runtime.d.ts +26 -0
  129. package/dist/src/bundle/runtime.js +64 -0
  130. package/dist/src/bundle/tar.d.ts +62 -0
  131. package/dist/src/bundle/tar.js +238 -0
  132. package/dist/src/bundle/types.d.ts +105 -0
  133. package/dist/src/bundle/types.js +21 -0
  134. package/dist/{cli.d.ts → src/cli.d.ts} +92 -7
  135. package/dist/src/cli.js +5968 -0
  136. package/dist/{credentials.d.ts → src/credentials.d.ts} +22 -15
  137. package/dist/{credentials.js → src/credentials.js} +35 -31
  138. package/dist/src/crypto/allowed-signers.d.ts +68 -0
  139. package/dist/src/crypto/allowed-signers.js +307 -0
  140. package/dist/src/crypto/canonical.d.ts +8 -0
  141. package/dist/src/crypto/canonical.js +92 -0
  142. package/dist/src/crypto/chain.d.ts +65 -0
  143. package/dist/src/crypto/chain.js +377 -0
  144. package/dist/src/crypto/dsse.d.ts +209 -0
  145. package/dist/src/crypto/dsse.js +282 -0
  146. package/dist/src/crypto/enrollment.d.ts +78 -0
  147. package/dist/src/crypto/enrollment.js +186 -0
  148. package/dist/src/crypto/index.d.ts +48 -0
  149. package/dist/src/crypto/index.js +44 -0
  150. package/dist/src/crypto/keys.d.ts +258 -0
  151. package/dist/src/crypto/keys.js +908 -0
  152. package/dist/src/crypto/org-root.d.ts +33 -0
  153. package/dist/src/crypto/org-root.js +78 -0
  154. package/dist/src/crypto/origin-rules.d.ts +56 -0
  155. package/dist/src/crypto/origin-rules.js +143 -0
  156. package/dist/src/crypto/policy-floor.d.ts +98 -0
  157. package/dist/src/crypto/policy-floor.js +353 -0
  158. package/dist/src/crypto/records.d.ts +316 -0
  159. package/dist/src/crypto/records.js +157 -0
  160. package/dist/src/crypto/scope.d.ts +49 -0
  161. package/dist/src/crypto/scope.js +83 -0
  162. package/dist/src/crypto/ssh.d.ts +171 -0
  163. package/dist/src/crypto/ssh.js +396 -0
  164. package/dist/src/crypto/submission.d.ts +33 -0
  165. package/dist/src/crypto/submission.js +47 -0
  166. package/dist/src/crypto/trust-roots.d.ts +29 -0
  167. package/dist/src/crypto/trust-roots.js +39 -0
  168. package/dist/src/crypto/verify-consumed.d.ts +67 -0
  169. package/dist/src/crypto/verify-consumed.js +259 -0
  170. package/dist/src/crypto/verify-origin.d.ts +50 -0
  171. package/dist/src/crypto/verify-origin.js +151 -0
  172. package/dist/src/crypto/verify-publication.d.ts +60 -0
  173. package/dist/src/crypto/verify-publication.js +150 -0
  174. package/dist/{defs.d.ts → src/defs.d.ts} +24 -1
  175. package/dist/{defs.js → src/defs.js} +181 -61
  176. package/dist/{engine.d.ts → src/engine.d.ts} +105 -9
  177. package/dist/{engine.js → src/engine.js} +251 -47
  178. package/dist/{factory.d.ts → src/factory.d.ts} +16 -0
  179. package/dist/{factory.js → src/factory.js} +16 -4
  180. package/dist/src/global-config.d.ts +59 -0
  181. package/dist/src/global-config.js +84 -0
  182. package/dist/{hub.d.ts → src/hub.d.ts} +280 -31
  183. package/dist/{hub.js → src/hub.js} +493 -52
  184. package/dist/src/index.d.ts +47 -0
  185. package/dist/src/index.js +41 -0
  186. package/dist/src/install.d.ts +538 -0
  187. package/dist/src/install.js +1981 -0
  188. package/dist/src/lock.d.ts +38 -0
  189. package/dist/src/lock.js +325 -0
  190. package/dist/src/mcp/serve.d.ts +109 -0
  191. package/dist/{mcp → src/mcp}/serve.js +335 -75
  192. package/dist/{mcp → src/mcp}/server.d.ts +6 -9
  193. package/dist/{mcp → src/mcp}/server.js +18 -10
  194. package/dist/{model.d.ts → src/model.d.ts} +15 -0
  195. package/dist/{model.js → src/model.js} +112 -2
  196. package/dist/src/order-resolver.d.ts +184 -0
  197. package/dist/src/order-resolver.js +252 -0
  198. package/dist/src/package-version.d.ts +10 -0
  199. package/dist/src/package-version.js +42 -0
  200. package/dist/{paths.d.ts → src/paths.d.ts} +14 -1
  201. package/dist/{paths.js → src/paths.js} +18 -0
  202. package/dist/src/schemas/enrollment-grant.v1.schema.json +90 -0
  203. package/dist/src/schemas/index.d.ts +1416 -0
  204. package/dist/src/schemas/index.js +31 -0
  205. package/dist/src/schemas/order.v1.schema.json +106 -0
  206. package/dist/src/schemas/origin.v1.schema.json +68 -0
  207. package/dist/src/schemas/policy-floor.v1.schema.json +29 -0
  208. package/dist/src/schemas/publication.v1.schema.json +31 -0
  209. package/dist/src/schemas/revocation.v1.schema.json +39 -0
  210. package/dist/src/schemas/submission.v1.schema.json +61 -0
  211. package/dist/src/store/def-source.d.ts +52 -0
  212. package/dist/src/store/def-source.js +335 -0
  213. package/dist/src/store/index-file.d.ts +69 -0
  214. package/dist/src/store/index-file.js +151 -0
  215. package/dist/src/store/index.d.ts +27 -0
  216. package/dist/src/store/index.js +22 -0
  217. package/dist/src/store/ingestor.d.ts +43 -0
  218. package/dist/src/store/ingestor.js +211 -0
  219. package/dist/src/store/install.d.ts +228 -0
  220. package/dist/src/store/install.js +555 -0
  221. package/dist/src/store/instruction-source.d.ts +49 -0
  222. package/dist/src/store/instruction-source.js +298 -0
  223. package/dist/src/store/origin-evidence.d.ts +21 -0
  224. package/dist/src/store/origin-evidence.js +66 -0
  225. package/dist/src/store/pre-commit-verifier.d.ts +68 -0
  226. package/dist/src/store/pre-commit-verifier.js +418 -0
  227. package/dist/src/store/resolve.d.ts +138 -0
  228. package/dist/src/store/resolve.js +363 -0
  229. package/dist/src/store/types.d.ts +288 -0
  230. package/dist/src/store/types.js +356 -0
  231. package/dist/{types.d.ts → src/types.d.ts} +58 -24
  232. package/dist/{untar.d.ts → src/untar.d.ts} +8 -23
  233. package/dist/src/untar.js +38 -0
  234. package/dist/{util.d.ts → src/util.d.ts} +3 -2
  235. package/dist/{util.js → src/util.js} +3 -2
  236. package/dist/{owenwork.d.ts → src/work-settings.d.ts} +22 -22
  237. package/dist/{owenwork.js → src/work-settings.js} +27 -27
  238. package/docs/agent-runner.md +86 -0
  239. package/docs/authoring.md +150 -59
  240. package/docs/bundles.md +250 -0
  241. package/docs/cli.md +1758 -163
  242. package/docs/crypto.md +816 -0
  243. package/docs/design.md +374 -52
  244. package/docs/embedding.md +135 -27
  245. package/docs/wire-contracts.md +380 -0
  246. package/examples/workflows/{command-worker.yaml → command-executor.yaml} +15 -15
  247. package/examples/workflows/compile-dev-playbook.yaml +338 -0
  248. package/examples/workflows/judges/gate-sharpness.md +39 -0
  249. package/examples/workflows/judges/security.md +34 -0
  250. package/package.json +22 -8
  251. package/plugins/claude-code/.claude-plugin/marketplace.json +14 -0
  252. package/plugins/claude-code/plugin/.claude-plugin/plugin.json +8 -0
  253. package/plugins/claude-code/plugin/.mcp.json +14 -0
  254. package/plugins/claude-code/plugin/hooks/hooks.json +26 -0
  255. package/plugins/claude-code/plugin/hooks/session-end.sh +40 -0
  256. package/plugins/claude-code/plugin/hooks/session-start.sh +52 -0
  257. package/plugins/claude-code/plugin/skills/author/SKILL.md +181 -0
  258. package/plugins/claude-code/plugin/skills/conduct/SKILL.md +106 -0
  259. package/plugins/claude-code/plugin/skills/shift/SKILL.md +105 -0
  260. package/plugins/codex/.agents/plugins/marketplace.json +21 -0
  261. package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +7 -0
  262. package/plugins/codex/plugins/owenloop/.mcp.json +20 -0
  263. package/plugins/codex/plugins/owenloop/hooks/hooks.json +26 -0
  264. package/plugins/codex/plugins/owenloop/hooks/session-end.sh +40 -0
  265. package/plugins/codex/plugins/owenloop/hooks/session-start.sh +52 -0
  266. package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +181 -0
  267. package/plugins/codex/plugins/owenloop/skills/conduct/SKILL.md +106 -0
  268. package/plugins/codex/plugins/owenloop/skills/shift/SKILL.md +105 -0
  269. package/dist/add.d.ts +0 -384
  270. package/dist/add.js +0 -834
  271. package/dist/cli.js +0 -3270
  272. package/dist/index.d.ts +0 -32
  273. package/dist/index.js +0 -23
  274. package/dist/lock.d.ts +0 -80
  275. package/dist/lock.js +0 -217
  276. package/dist/mcp/serve.d.ts +0 -84
  277. package/dist/untar.js +0 -164
  278. /package/dist/{schema.d.ts → src/schema.d.ts} +0 -0
  279. /package/dist/{schema.js → src/schema.js} +0 -0
  280. /package/dist/{store.d.ts → src/store.d.ts} +0 -0
  281. /package/dist/{store.js → src/store.js} +0 -0
  282. /package/dist/{types.js → src/types.js} +0 -0
@@ -0,0 +1,351 @@
1
+ /**
2
+ * A newline-delimited JSON-RPC 2.0 client over a child process's stdio.
3
+ *
4
+ * Attribution: adapted from the kanna project's app-server client
5
+ * (`github.com/jakemor/kanna`), MIT-style license, Copyright (c) 2025 Jake Mor.
6
+ * Knowledge was ported, not source; the fuller license note (kanna's grant
7
+ * carve-out, and why it does not bind typicalday) lives in the adapter module
8
+ * that names the vendor, because this file may not.
9
+ *
10
+ * VENDOR-NEUTRAL BY MANDATE. `test/harness-isolation.test.ts` greps a vendor
11
+ * pattern over the FULL TEXT — code and comments alike — of every `.ts` under
12
+ * `src/harness/`, and allowlists only the per-harness adapter modules by exact
13
+ * path. This file is NOT on that allowlist, so it may not name a provider, a
14
+ * provider's binary, a provider's env var, or a provider's own source files
15
+ * anywhere in it. Everything here is therefore described in protocol terms.
16
+ *
17
+ * WHY IT IS HAND-ROLLED. The repo keeps a deliberately small runtime dependency
18
+ * set, and the server this drives deviates from JSON-RPC 2.0 in a way that
19
+ * breaks strict libraries anyway (see `classifyFrame`): inbound frames carry no
20
+ * `jsonrpc` member at all.
21
+ *
22
+ * TWO LAYERS, ON PURPOSE:
23
+ * - `createRpcCore` — framing, correlation, timeouts, and dispatch over an
24
+ * injected `write` sink. No process, no streams, no timers you cannot
25
+ * control. This is the layer the framing/correlation unit tests drive, so a
26
+ * framing bug fails a test that never spawned anything.
27
+ * - `startStdioRpc` — spawns the child and wires the core to its stdio.
28
+ *
29
+ * Failure stance: total on the read path. A line that is not JSON, a response
30
+ * for an id nobody is waiting on, and a notification for an unknown method are
31
+ * all REPORTED (through `onStderr`) and skipped — never thrown, because one
32
+ * stray byte on stdout must not kill a live session. Every request is
33
+ * independently timed out, because a server that silently drops an unknown
34
+ * method (which the server this was written for does) would otherwise leak the
35
+ * pending promise forever.
36
+ */
37
+ import { spawn } from 'node:child_process';
38
+ import { StringDecoder } from 'node:string_decoder';
39
+ /** A JSON-RPC `error` object, surfaced as a rejection from `request`. */
40
+ export class JsonRpcError extends Error {
41
+ code;
42
+ data;
43
+ constructor(code, message, data) {
44
+ super(message);
45
+ this.name = 'JsonRpcError';
46
+ this.code = code;
47
+ this.data = data;
48
+ }
49
+ }
50
+ const DEFAULT_REQUEST_TIMEOUT_MS = 120_000;
51
+ /** How long `dispose` waits after SIGTERM before escalating to SIGKILL. */
52
+ const KILL_GRACE_MS = 2_000;
53
+ /**
54
+ * Classify a decoded frame.
55
+ *
56
+ * DELIBERATELY DOES NOT LOOK AT `jsonrpc`. The server this client was written
57
+ * against omits the `jsonrpc` member from every inbound frame — responses
58
+ * arrive as `{id, result}`, errors as `{error, id}`, notifications as
59
+ * `{method, params, emittedAtMs}`. A validator that requires `jsonrpc === '2.0'`
60
+ * rejects 100% of real traffic, so classification keys on the presence of
61
+ * `id` / `method` / `result` / `error` only, in this order.
62
+ *
63
+ * Exported so a unit test can pin the rule directly.
64
+ */
65
+ export function classifyFrame(frame) {
66
+ const hasId = 'id' in frame && frame.id !== undefined && frame.id !== null;
67
+ if (hasId && ('result' in frame || 'error' in frame))
68
+ return 'response';
69
+ if (hasId && typeof frame.method === 'string')
70
+ return 'server-request';
71
+ if (typeof frame.method === 'string')
72
+ return 'notification';
73
+ return 'unknown';
74
+ }
75
+ /**
76
+ * A line-oriented, UTF-8-safe reader over a byte stream.
77
+ *
78
+ * `StringDecoder` is what makes a multi-byte character split across two chunks
79
+ * survive: decoding each chunk independently emits replacement characters at
80
+ * the seam. Exported so the framing tests can drive it directly.
81
+ */
82
+ export function createLineReader(onLine) {
83
+ const decoder = new StringDecoder('utf8');
84
+ let buffer = '';
85
+ return (chunk) => {
86
+ buffer += typeof chunk === 'string' ? chunk : decoder.write(chunk);
87
+ let nl = buffer.indexOf('\n');
88
+ while (nl !== -1) {
89
+ const line = buffer.slice(0, nl);
90
+ buffer = buffer.slice(nl + 1);
91
+ // `noUncheckedIndexedAccess` is on; slicing avoids indexed reads entirely.
92
+ const trimmed = line.endsWith('\r') ? line.slice(0, -1) : line;
93
+ if (trimmed.trim() !== '')
94
+ onLine(trimmed);
95
+ nl = buffer.indexOf('\n');
96
+ }
97
+ };
98
+ }
99
+ /**
100
+ * The protocol engine: framing in, correlation and dispatch out, over an
101
+ * injected `write`. Knows nothing about processes.
102
+ */
103
+ export function createRpcCore(opts) {
104
+ const requestTimeoutMs = opts.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
105
+ const pending = new Map();
106
+ let nextId = 1;
107
+ function send(msg) {
108
+ opts.write(`${JSON.stringify(msg)}\n`);
109
+ }
110
+ function handleResponse(frame) {
111
+ const id = typeof frame.id === 'number' ? frame.id : Number(frame.id);
112
+ const p = pending.get(id);
113
+ if (p === undefined) {
114
+ // A LATE response for an id that already timed out (or was never ours)
115
+ // lands here. Reporting and dropping it is required — throwing would take
116
+ // down a healthy session over a message nobody is waiting for.
117
+ opts.onStderr(`[unmatched response] id=${String(frame.id)}`);
118
+ return;
119
+ }
120
+ clearTimeout(p.timer);
121
+ pending.delete(id);
122
+ if (frame.error !== undefined && frame.error !== null) {
123
+ p.reject(new JsonRpcError(frame.error.code, frame.error.message, frame.error.data));
124
+ return;
125
+ }
126
+ p.resolve(frame.result);
127
+ }
128
+ function handleServerRequest(frame) {
129
+ const id = frame.id;
130
+ const method = frame.method;
131
+ // ALWAYS exactly one reply. `void` the promise deliberately: the reply is
132
+ // written inside it, and there is no caller to await.
133
+ void (async () => {
134
+ try {
135
+ const result = await opts.onServerRequest(method, frame.params, id);
136
+ send({ jsonrpc: '2.0', id, result: result ?? {} });
137
+ }
138
+ catch (err) {
139
+ send({
140
+ jsonrpc: '2.0',
141
+ id,
142
+ error: { code: -32603, message: err instanceof Error ? err.message : String(err) },
143
+ });
144
+ }
145
+ })();
146
+ }
147
+ const onData = createLineReader((line) => {
148
+ let frame;
149
+ try {
150
+ frame = JSON.parse(line);
151
+ }
152
+ catch {
153
+ // A stray non-JSON line is a diagnostic, not a fatal error: report it and
154
+ // keep reading so the NEXT valid line still parses.
155
+ opts.onStderr(`[non-JSON stdout] ${line}`);
156
+ return;
157
+ }
158
+ if (typeof frame !== 'object' || frame === null) {
159
+ opts.onStderr(`[non-object frame] ${line}`);
160
+ return;
161
+ }
162
+ switch (classifyFrame(frame)) {
163
+ case 'response':
164
+ handleResponse(frame);
165
+ return;
166
+ case 'server-request':
167
+ handleServerRequest(frame);
168
+ return;
169
+ case 'notification':
170
+ opts.onNotification(frame.method, frame.params);
171
+ return;
172
+ case 'unknown':
173
+ opts.onStderr(`[unclassifiable frame] ${line}`);
174
+ return;
175
+ }
176
+ });
177
+ return {
178
+ onData,
179
+ pendingCount: () => pending.size,
180
+ rejectAll(err) {
181
+ for (const [, p] of pending) {
182
+ clearTimeout(p.timer);
183
+ p.reject(err);
184
+ }
185
+ pending.clear();
186
+ },
187
+ request(method, params, timeoutMs) {
188
+ const id = nextId++;
189
+ const budget = timeoutMs ?? requestTimeoutMs;
190
+ const startedAt = Date.now();
191
+ const p = new Promise((resolve, reject) => {
192
+ // MANDATORY (not defensive): this server answers a genuinely-absent
193
+ // method with NO frame at all, so correlation alone leaks the pending
194
+ // entry forever. `unref` so a still-pending request cannot hold the
195
+ // event loop — and therefore a test runner — open.
196
+ const timer = setTimeout(() => {
197
+ pending.delete(id);
198
+ reject(new Error(`request '${method}' timed out after ${Date.now() - startedAt}ms`));
199
+ }, budget);
200
+ timer.unref();
201
+ pending.set(id, {
202
+ method,
203
+ startedAt,
204
+ resolve: resolve,
205
+ reject,
206
+ timer,
207
+ });
208
+ });
209
+ send({ jsonrpc: '2.0', id, method, ...(params !== undefined ? { params } : {}) });
210
+ return p;
211
+ },
212
+ notify(method, params) {
213
+ send({ jsonrpc: '2.0', method, ...(params !== undefined ? { params } : {}) });
214
+ },
215
+ };
216
+ }
217
+ /** Spawn `command args` and speak newline-delimited JSON-RPC to its stdio. */
218
+ export function startStdioRpc(opts) {
219
+ // `detached: true` puts the child in its OWN process group, which is the only
220
+ // thing that makes `process.kill(-pid, ...)` able to reap the grandchildren
221
+ // the child spawns on its own.
222
+ //
223
+ // ENVIRONMENT: this transport does not decide it. With no `env` option the
224
+ // child inherits this process's environment untouched, which is the recorded
225
+ // decision for the adapter that uses this transport; with one, that value is
226
+ // the child's whole environment. Either way the policy lives in the caller.
227
+ const child = spawn(opts.command, opts.args, {
228
+ ...(opts.cwd !== undefined ? { cwd: opts.cwd } : {}),
229
+ ...(opts.env !== undefined ? { env: opts.env } : {}),
230
+ stdio: ['pipe', 'pipe', 'pipe'],
231
+ detached: true,
232
+ });
233
+ let disposed = false;
234
+ let exited = false;
235
+ let disposePromise;
236
+ const core = createRpcCore({
237
+ ...(opts.requestTimeoutMs !== undefined ? { requestTimeoutMs: opts.requestTimeoutMs } : {}),
238
+ write: (line) => {
239
+ if (child.stdin.destroyed || child.stdin.writableEnded)
240
+ return;
241
+ child.stdin.write(line);
242
+ },
243
+ onNotification: opts.onNotification,
244
+ onServerRequest: opts.onServerRequest,
245
+ onStderr: opts.onStderr,
246
+ });
247
+ child.stdout.on('data', core.onData);
248
+ child.stdout.on('error', (err) => opts.onStderr(`[stdout error] ${err.message}`));
249
+ const readStderr = createLineReader((line) => opts.onStderr(line));
250
+ child.stderr.on('data', readStderr);
251
+ child.stderr.on('error', (err) => opts.onStderr(`[stderr error] ${err.message}`));
252
+ child.stdin.on('error', (err) => opts.onStderr(`[stdin error] ${err.message}`));
253
+ child.on('error', (err) => {
254
+ opts.onStderr(`[spawn error] ${err.message}`);
255
+ // Node 22 emits `error` followed by `close`, but no `exit`, when the
256
+ // executable does not exist. Mark that pre-spawn failure terminal so
257
+ // `dispose()` does not wait on an `exit` event that can never arrive. Do
258
+ // not invoke `onExit`: the caller that owns the failed startup still has
259
+ // the original error and can report its safe, specific message once.
260
+ if (child.pid === undefined)
261
+ exited = true;
262
+ core.rejectAll(err);
263
+ });
264
+ child.on('exit', (code, signal) => {
265
+ exited = true;
266
+ core.rejectAll(new Error(`process exited (code=${String(code)}, signal=${String(signal)})`));
267
+ opts.onExit(code, signal);
268
+ });
269
+ return {
270
+ get pid() {
271
+ return child.pid;
272
+ },
273
+ request(method, params, timeoutMs) {
274
+ if (disposed || exited) {
275
+ return Promise.reject(new Error(`cannot send '${method}': the client is no longer running`));
276
+ }
277
+ return core.request(method, params, timeoutMs);
278
+ },
279
+ notify(method, params) {
280
+ if (disposed || exited)
281
+ return;
282
+ core.notify(method, params);
283
+ },
284
+ dispose() {
285
+ // Idempotent: the second call returns the same promise the first made.
286
+ if (disposePromise !== undefined)
287
+ return disposePromise;
288
+ disposed = true;
289
+ core.rejectAll(new Error('client disposed'));
290
+ disposePromise = (async () => {
291
+ if (exited)
292
+ return;
293
+ const done = new Promise((resolve) => {
294
+ if (exited) {
295
+ resolve();
296
+ return;
297
+ }
298
+ child.once('exit', () => resolve());
299
+ });
300
+ try {
301
+ child.stdin.end();
302
+ }
303
+ catch {
304
+ // a closed pipe is not an error at teardown
305
+ }
306
+ killGroup(child.pid, 'SIGTERM', opts.onStderr);
307
+ await Promise.race([done, sleepUnref(KILL_GRACE_MS)]);
308
+ if (!exited) {
309
+ killGroup(child.pid, 'SIGKILL', opts.onStderr);
310
+ await Promise.race([done, sleepUnref(KILL_GRACE_MS)]);
311
+ }
312
+ })();
313
+ return disposePromise;
314
+ },
315
+ };
316
+ }
317
+ /** A timer that cannot by itself keep the event loop alive. */
318
+ function sleepUnref(ms) {
319
+ return new Promise((resolve) => {
320
+ const t = setTimeout(resolve, ms);
321
+ t.unref();
322
+ });
323
+ }
324
+ /**
325
+ * Signal the child's whole process group, falling back to the process itself.
326
+ *
327
+ * `ESRCH` ("no such process") means it is already gone, which is the success
328
+ * case at teardown, not a failure. `EPERM` can happen when the group is gone
329
+ * but the pid was recycled; both are reported and swallowed.
330
+ */
331
+ function killGroup(pid, signal, onStderr) {
332
+ if (pid === undefined)
333
+ return;
334
+ try {
335
+ process.kill(-pid, signal);
336
+ return;
337
+ }
338
+ catch (err) {
339
+ const code = err.code;
340
+ if (code !== 'ESRCH' && code !== 'EPERM')
341
+ onStderr(`[kill group ${signal}] ${String(err)}`);
342
+ }
343
+ try {
344
+ process.kill(pid, signal);
345
+ }
346
+ catch (err) {
347
+ const code = err.code;
348
+ if (code !== 'ESRCH')
349
+ onStderr(`[kill ${signal}] ${String(err)}`);
350
+ }
351
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * `normalizeStepPermissions` — the PURE translation from a step def's
3
+ * harness-specific `x.<bagKey>` bag into the harness-neutral `StepPermissions`
4
+ * that every adapter reads.
5
+ *
6
+ * The type itself lives in `./contract.ts` (both adapters read it as part of the
7
+ * contract surface); only the normalizing function lives here, so the
8
+ * dependency runs one way and there is no cycle.
9
+ *
10
+ * SHAPE DECISION — this takes the ALREADY-EXTRACTED bag, not the step. If it
11
+ * took the step it would have to know which bag key to reach for, and that key
12
+ * IS a harness vendor name — putting a vendor name in a non-adapter file and
13
+ * breaking the isolation rule this phase establishes. The CALLER extracts the
14
+ * bag (Phase 3's worker today, Phase 5's normalized prepare later). Do not
15
+ * "fix" this by passing the step plus a bagKey argument: same leak, one
16
+ * indirection later.
17
+ *
18
+ * Failure stance: TOTAL. It never throws, never mutates its input, and has no
19
+ * I/O. A malformed bag normalizes to `{ extensions: {} }`. Validation is not
20
+ * this function's job — normalization runs at dispatch time where throwing would
21
+ * kill a live order. Two other layers do the validating, and BOTH report rather
22
+ * than degrade: the def parser (`parseHarnessCarrier` in `src/bundle/fetch.ts`)
23
+ * throws on a carrier it cannot read at all — including a def still carrying the
24
+ * legacy pre-`x.harness` bag key (`LEGACY_BAG_KEY`, same file) — and `owenloop
25
+ * lint` errors on a bad FIELD inside a well-formed bag.
26
+ *
27
+ * Field rules are carried over from the legacy compile layer's `KNOWN_FIELDS` /
28
+ * `RESERVED_KEYS` / `isStringOrStringArray`; the live copies now sit in this
29
+ * directory's per-harness adapter module (grep them there — `src/adapters/` was
30
+ * deleted in Phase 5, and do not trust a line number). Eight of the eighteen are
31
+ * harness-neutral and get lifted; two are reserved and are stripped; the other
32
+ * eight have no neutral meaning and land in `extensions`, along with every key
33
+ * the bag carries that the known list does not mention.
34
+ */
35
+ import type { PermissionIssue, StepPermissions } from './contract.ts';
36
+ import type { LintFinding } from './types.ts';
37
+ /**
38
+ * Translate one step's bag into `StepPermissions`.
39
+ *
40
+ * `bag` is the already-extracted `x.<bagKey>` object; `undefined`, `null`, an
41
+ * array, or any non-object all normalize to `{ extensions: {} }` (plus the
42
+ * step's model, when it has one).
43
+ *
44
+ * MODEL PRECEDENCE: the step's FIRST-CLASS `model` field wins over a bag-level
45
+ * `model`, carried over verbatim from the legacy frontmatter builder's
46
+ * `if (step.model !== undefined) fm['model'] = step.model`. That is today's live
47
+ * behavior and its meaning must not change — getting it backwards would silently
48
+ * alter which model live steps run under once Phase 5 routes prepare through
49
+ * this function. Note the precedence is decided on PRESENCE (a defined step
50
+ * model shadows the bag), and only then is the winner dropped if it is not a
51
+ * non-empty string.
52
+ *
53
+ * `extensions` is lossless by construction: every bag key that is neither
54
+ * lifted (the eight neutral fields) nor reserved (`name`/`description`) lands
55
+ * there verbatim, including keys the known-field list has never heard of. Lint
56
+ * stays the place that warns about unknown keys.
57
+ *
58
+ * The input is never mutated; nested values are shared by reference (verbatim
59
+ * pass-through is the point).
60
+ */
61
+ export declare function normalizeStepPermissions(bag: Record<string, unknown> | undefined, step?: {
62
+ model?: string;
63
+ }): StepPermissions;
64
+ /**
65
+ * Validate the reserved, harness-neutral `x.harness` fields before normalization.
66
+ * Unknown keys remain opaque and produce no finding here.
67
+ */
68
+ export declare function validateHarnessOptions(bag: Record<string, unknown>, step: string): LintFinding[];
69
+ /**
70
+ * Validate a normalized permission object at the final dispatch boundary.
71
+ * The stale-extension check catches caches produced before filesystem/network
72
+ * became first-class restrictions; running such a cache would silently ignore
73
+ * the authored restriction.
74
+ */
75
+ export declare function preflightStepPermissions(permissions: StepPermissions): PermissionIssue[];
@@ -0,0 +1,182 @@
1
+ /** Fields with a harness-neutral meaning — lifted out of the bag. */
2
+ const NEUTRAL_KEYS = [
3
+ 'tools',
4
+ 'disallowedTools',
5
+ 'filesystem',
6
+ 'network',
7
+ 'permissionMode',
8
+ 'maxTurns',
9
+ 'model',
10
+ 'effort',
11
+ ];
12
+ const FILESYSTEM_VALUES = new Set(['read-only', 'workspace-write', 'unrestricted']);
13
+ const NETWORK_VALUES = new Set(['owenloop-only', 'unrestricted']);
14
+ const STALE_RESTRICTION_KEYS = ['filesystem', 'network'];
15
+ /** Generated/reserved frontmatter keys. Stripped: an adapter must never see an
16
+ * author's attempt at them. They do NOT reach `extensions`. */
17
+ const RESERVED_KEYS = ['name', 'description'];
18
+ /** Keys that never appear in `extensions`, valid or not. */
19
+ const LIFTED_OR_STRIPPED = new Set([...NEUTRAL_KEYS, ...RESERVED_KEYS]);
20
+ function isPlainMap(v) {
21
+ return typeof v === 'object' && v !== null && !Array.isArray(v);
22
+ }
23
+ /**
24
+ * Normalize a tool list. The bag legitimately accepts EITHER a comma-separated
25
+ * string or a string array. A string is split on `,` with each entry trimmed and
26
+ * empties dropped; an array is copied with non-string entries dropped. Returns
27
+ * `[]` when the field was explicitly present but names no tools. This preserves
28
+ * the security-relevant distinction between an absent allow-list and `tools: []`.
29
+ */
30
+ function toolList(v) {
31
+ if (typeof v === 'string') {
32
+ return v.split(',').map((s) => s.trim()).filter((s) => s !== '');
33
+ }
34
+ if (Array.isArray(v)) {
35
+ return v.filter((e) => typeof e === 'string' && e !== '');
36
+ }
37
+ return undefined;
38
+ }
39
+ /** A non-empty string, verbatim and unvalidated; otherwise `undefined`. */
40
+ function nonEmptyString(v) {
41
+ return typeof v === 'string' && v !== '' ? v : undefined;
42
+ }
43
+ /** A positive integer, otherwise `undefined`. Anything else is dropped rather
44
+ * than corrected — lint already errors on it, and normalization must not throw. */
45
+ function positiveInt(v) {
46
+ return typeof v === 'number' && Number.isInteger(v) && v > 0 ? v : undefined;
47
+ }
48
+ /**
49
+ * Translate one step's bag into `StepPermissions`.
50
+ *
51
+ * `bag` is the already-extracted `x.<bagKey>` object; `undefined`, `null`, an
52
+ * array, or any non-object all normalize to `{ extensions: {} }` (plus the
53
+ * step's model, when it has one).
54
+ *
55
+ * MODEL PRECEDENCE: the step's FIRST-CLASS `model` field wins over a bag-level
56
+ * `model`, carried over verbatim from the legacy frontmatter builder's
57
+ * `if (step.model !== undefined) fm['model'] = step.model`. That is today's live
58
+ * behavior and its meaning must not change — getting it backwards would silently
59
+ * alter which model live steps run under once Phase 5 routes prepare through
60
+ * this function. Note the precedence is decided on PRESENCE (a defined step
61
+ * model shadows the bag), and only then is the winner dropped if it is not a
62
+ * non-empty string.
63
+ *
64
+ * `extensions` is lossless by construction: every bag key that is neither
65
+ * lifted (the eight neutral fields) nor reserved (`name`/`description`) lands
66
+ * there verbatim, including keys the known-field list has never heard of. Lint
67
+ * stays the place that warns about unknown keys.
68
+ *
69
+ * The input is never mutated; nested values are shared by reference (verbatim
70
+ * pass-through is the point).
71
+ */
72
+ export function normalizeStepPermissions(bag, step) {
73
+ const src = isPlainMap(bag) ? bag : {};
74
+ const extensions = {};
75
+ for (const [k, v] of Object.entries(src)) {
76
+ if (LIFTED_OR_STRIPPED.has(k))
77
+ continue;
78
+ extensions[k] = v;
79
+ }
80
+ const out = { extensions };
81
+ const tools = toolList(src['tools']);
82
+ if (tools !== undefined)
83
+ out.tools = tools;
84
+ const disallowedTools = toolList(src['disallowedTools']);
85
+ if (disallowedTools !== undefined)
86
+ out.disallowedTools = disallowedTools;
87
+ if (typeof src['filesystem'] === 'string' && FILESYSTEM_VALUES.has(src['filesystem'])) {
88
+ out.filesystem = src['filesystem'];
89
+ }
90
+ if (typeof src['network'] === 'string' && NETWORK_VALUES.has(src['network'])) {
91
+ out.network = src['network'];
92
+ }
93
+ const permissionMode = nonEmptyString(src['permissionMode']);
94
+ if (permissionMode !== undefined)
95
+ out.permissionMode = permissionMode;
96
+ const maxTurns = positiveInt(src['maxTurns']);
97
+ if (maxTurns !== undefined)
98
+ out.maxTurns = maxTurns;
99
+ const rawModel = step?.model !== undefined ? step.model : src['model'];
100
+ const model = nonEmptyString(rawModel);
101
+ if (model !== undefined)
102
+ out.model = model;
103
+ const effort = nonEmptyString(src['effort']);
104
+ if (effort !== undefined)
105
+ out.effort = effort;
106
+ return out;
107
+ }
108
+ function typeName(v) {
109
+ if (v === null)
110
+ return 'null';
111
+ if (Array.isArray(v))
112
+ return 'array';
113
+ return typeof v;
114
+ }
115
+ function isStringOrStringArray(v) {
116
+ return typeof v === 'string' || (Array.isArray(v) && v.every((entry) => typeof entry === 'string'));
117
+ }
118
+ /**
119
+ * Validate the reserved, harness-neutral `x.harness` fields before normalization.
120
+ * Unknown keys remain opaque and produce no finding here.
121
+ */
122
+ export function validateHarnessOptions(bag, step) {
123
+ const findings = [];
124
+ const error = (field, message) => {
125
+ findings.push({ severity: 'error', step, field, message });
126
+ };
127
+ const check = (field, ok, expected) => {
128
+ if (field in bag && !ok(bag[field])) {
129
+ error(field, `${field} must be ${expected}, got ${typeName(bag[field])}`);
130
+ }
131
+ };
132
+ check('tools', isStringOrStringArray, 'a string or string[]');
133
+ check('disallowedTools', isStringOrStringArray, 'a string or string[]');
134
+ check('permissionMode', (v) => typeof v === 'string' && v !== '', 'a non-empty string');
135
+ check('model', (v) => typeof v === 'string' && v !== '', 'a non-empty string');
136
+ check('effort', (v) => typeof v === 'string' && v !== '', 'a non-empty string');
137
+ check('maxTurns', (v) => typeof v === 'number' && Number.isInteger(v) && v > 0, 'a positive integer');
138
+ for (const key of RESERVED_KEYS) {
139
+ if (key in bag)
140
+ error(key, `'${key}' is generated and cannot be set in the bag`);
141
+ }
142
+ if ('filesystem' in bag && !FILESYSTEM_VALUES.has(bag['filesystem'])) {
143
+ error('filesystem', `filesystem must be one of ${[...FILESYSTEM_VALUES].join('|')}`);
144
+ }
145
+ if ('network' in bag && !NETWORK_VALUES.has(bag['network'])) {
146
+ error('network', `network must be one of ${[...NETWORK_VALUES].join('|')}`);
147
+ }
148
+ if (isStringOrStringArray(bag['tools']) && isStringOrStringArray(bag['disallowedTools'])) {
149
+ const allowed = new Set(toolList(bag['tools']) ?? []);
150
+ const denied = new Set(toolList(bag['disallowedTools']) ?? []);
151
+ const overlap = [...allowed].filter((tool) => denied.has(tool)).sort();
152
+ if (overlap.length > 0) {
153
+ error('tools', `tools and disallowedTools overlap: ${overlap.join(', ')}`);
154
+ }
155
+ }
156
+ return findings;
157
+ }
158
+ /**
159
+ * Validate a normalized permission object at the final dispatch boundary.
160
+ * The stale-extension check catches caches produced before filesystem/network
161
+ * became first-class restrictions; running such a cache would silently ignore
162
+ * the authored restriction.
163
+ */
164
+ export function preflightStepPermissions(permissions) {
165
+ const issues = [];
166
+ const overlap = (permissions.tools ?? [])
167
+ .filter((tool) => (permissions.disallowedTools ?? []).includes(tool))
168
+ .sort();
169
+ if (overlap.length > 0) {
170
+ issues.push({ field: 'tools', message: `tools and disallowedTools overlap: ${overlap.join(', ')}` });
171
+ }
172
+ for (const key of STALE_RESTRICTION_KEYS) {
173
+ if (key in permissions.extensions) {
174
+ issues.push({
175
+ field: key,
176
+ message: `restriction '${key}' is buried in permissions.extensions from an old cache and would be ignored; ` +
177
+ 'rerun `owenloop work prepare`',
178
+ });
179
+ }
180
+ }
181
+ return issues;
182
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Harness registry — a RUNTIME map from adapter id to `HarnessAdapter`.
3
+ *
4
+ * It is a RUNTIME registry because adapters self-register at import time and the
5
+ * fake is registered/unregistered inside individual tests.
6
+ *
7
+ * STARTS EMPTY, ON PURPOSE. Importing an adapter module from here would be the
8
+ * only way a harness vendor name could enter this file — which the isolation
9
+ * rule forbids. WHO imports the real adapter modules so their `register(...)`
10
+ * side effect fires is a COMPOSITION ROOT's job, not this module's. There are
11
+ * two: `src/roles/agent-run.ts` and `src/roles/lint.ts`. Do not add a
12
+ * barrel/index under `src/harness/` to do it: importers name the module.
13
+ *
14
+ * Failure stance: `register` THROWS on a duplicate id, because a duplicate is a
15
+ * wiring bug at composition time, not a runtime condition a caller can recover
16
+ * from. Every read is total (`undefined` / `[]`), never throws.
17
+ */
18
+ import type { HarnessAdapter } from './contract.ts';
19
+ /**
20
+ * Register an adapter under its own `id`. Throws when that id is already taken
21
+ * — two adapters claiming one id is a wiring bug, and silently letting the
22
+ * second win would route work to whichever module happened to import last.
23
+ */
24
+ export declare function register(adapter: HarnessAdapter): void;
25
+ /**
26
+ * Remove an adapter by id; returns whether one was there. Exists so a test that
27
+ * registers a fake can clean up in `afterEach` — production code has no reason
28
+ * to unregister.
29
+ */
30
+ export declare function unregister(id: string): boolean;
31
+ /** The adapter registered under `id`, or `undefined` when none is. */
32
+ export declare function adapterFor(id: string): HarnessAdapter | undefined;
33
+ /** Every registered adapter id, in registration order. */
34
+ export declare function registeredHarnessIds(): string[];
35
+ /**
36
+ * The built-in default harness id: the FIRST id in the registry, i.e. the first
37
+ * adapter module a composition root imported.
38
+ *
39
+ * Deliberately not a hardcoded literal. A literal default would be a harness
40
+ * VENDOR NAME in neutral code, which the isolation rule forbids outright — and
41
+ * this file is under `src/harness/`, where the rule is enforced by grep. The
42
+ * import-order rule gives the same behavior without the string.
43
+ *
44
+ * Returns `undefined` when nothing is registered; the caller then fails honestly
45
+ * (`'no-harness'`) rather than guessing.
46
+ */
47
+ export declare function defaultHarnessId(): string | undefined;