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,238 @@
1
+ /**
2
+ * Deterministic `.wnlp` archive writer (WP-A1).
3
+ *
4
+ * Canonical tar rules (see `docs/bundles.md`): regular-file entries only,
5
+ * `/`-separated paths sorted by ascending UTF-8 bytes, uid/gid 0, empty
6
+ * uname/gname, mtime 0, mode 0755 when any source execute bit is set and
7
+ * 0644 otherwise, USTAR name when it fits (UTF-8 bytes ≤ 100), else ONE
8
+ * deterministic POSIX PAX `path` extended record in a `PaxHeader` block
9
+ * (mode 0644, uid/gid 0, mtime 0), exactly two trailing zero blocks. The
10
+ * gzip wrapper uses fixed options, zero mtime bytes, and OS byte 0 (patched
11
+ * explicitly — Node reports OS 19 on Darwin). The raw header helpers are
12
+ * deliberately module-private: the public bundle surface exposes only the
13
+ * high-level pack/inspect/digest/unpack API.
14
+ */
15
+ import { lstatSync, readdirSync } from 'node:fs';
16
+ import { join, resolve } from 'node:path';
17
+ import { gzipSync } from 'node:zlib';
18
+ import { canonicalBundleFilePrefix, canonicalBundlePathViolation, canonicalPaxNamePlaceholder, DEFAULT_TAR_LIMITS, } from "../archive.js";
19
+ import { BundleError } from "./types.js";
20
+ const BLOCK = 512;
21
+ /** Fixed gzip level for canonical output. */
22
+ export const BUNDLE_GZIP_LEVEL = 9;
23
+ /** An octal header field: `width - 1` zero-padded octal digits plus a trailing NUL. */
24
+ function octalField(value, width) {
25
+ const digits = value.toString(8);
26
+ if (digits.length > width - 1) {
27
+ throw new BundleError('MANIFEST_ERROR', `tar field overflow: ${value} does not fit ${width} bytes`);
28
+ }
29
+ return Buffer.from(digits.padStart(width - 1, '0') + '\0', 'ascii');
30
+ }
31
+ function padBlock(data) {
32
+ const padded = Math.ceil(data.length / BLOCK) * BLOCK;
33
+ const out = Buffer.alloc(padded);
34
+ Buffer.from(data).copy(out);
35
+ return out;
36
+ }
37
+ /**
38
+ * One 512-byte canonical USTAR header: name (ASCII, ≤100 bytes), mode,
39
+ * uid/gid 0, size, mtime 0, checksum, typeflag, magic `ustar\0`, version
40
+ * `00`, empty uname/gname and blank prefix/dev fields (zero-filled).
41
+ */
42
+ function buildHeader(name, size, typeflag, mode) {
43
+ const buf = Buffer.alloc(BLOCK);
44
+ const nameBytes = Buffer.from(name, 'utf8');
45
+ if (nameBytes.length > 100) {
46
+ throw new BundleError('ARCHIVE_PATH_TOO_LONG', `tar name field cannot hold '${name}'`);
47
+ }
48
+ nameBytes.copy(buf, 0);
49
+ octalField(mode, 8).copy(buf, 100);
50
+ octalField(0, 8).copy(buf, 108); // uid
51
+ octalField(0, 8).copy(buf, 116); // gid
52
+ octalField(size, 12).copy(buf, 124);
53
+ octalField(0, 12).copy(buf, 136); // mtime
54
+ buf.fill(0x20, 148, 156); // checksum field: spaces while computing
55
+ buf[156] = typeflag.charCodeAt(0);
56
+ buf.write('ustar', 257, 'ascii'); // magic "ustar\0" (rest zero-filled)
57
+ buf[262] = 0;
58
+ buf.write('00', 263, 2, 'ascii'); // version
59
+ // uname/gname (265..329), linkname (329..400), prefix (345..500), devmajor/
60
+ // devminor stay zero — canonical.
61
+ let sum = 0;
62
+ for (let i = 0; i < BLOCK; i++)
63
+ sum += buf[i];
64
+ const chksum = Buffer.from(sum.toString(8).padStart(6, '0') + '\0 ', 'ascii');
65
+ chksum.copy(buf, 148);
66
+ return buf;
67
+ }
68
+ /** The one canonical pax extended-header data block: a single self-inclusive `path` record. */
69
+ function buildPaxPathRecord(path) {
70
+ const valueBytes = Buffer.byteLength(path, 'utf8');
71
+ // Record: "<len> path=<value>\n"; len counts every byte of the record.
72
+ const suffixLen = 1 + 'path='.length + valueBytes + 1;
73
+ let digits = String(suffixLen).length;
74
+ let total = digits + suffixLen;
75
+ while (String(total).length !== digits) {
76
+ digits = String(total).length;
77
+ total = digits + suffixLen;
78
+ }
79
+ return Buffer.from(`${total} path=${path}\n`, 'utf8');
80
+ }
81
+ /**
82
+ * Build the canonical uncompressed tar bytes for a set of files. The input
83
+ * MUST already be sorted by ascending UTF-8 byte order of `path` and carry
84
+ * canonical modes; the bundle packer guarantees both.
85
+ */
86
+ export function buildCanonicalTar(files, limits = DEFAULT_TAR_LIMITS) {
87
+ let headerCount = 0;
88
+ const chunks = [];
89
+ let previousPath;
90
+ const filePaths = new Set();
91
+ for (const f of files) {
92
+ const violation = canonicalBundlePathViolation(f.path);
93
+ if (violation) {
94
+ throw new BundleError('SOURCE_INVALID_PATH', `unsafe path '${f.path}': ${violation}`, f.path);
95
+ }
96
+ if (previousPath !== undefined) {
97
+ const order = compareUtf8Paths(previousPath, f.path);
98
+ if (order === 0) {
99
+ throw new BundleError('ARCHIVE_DUPLICATE_PATH', `duplicate archive path '${f.path}'`, f.path);
100
+ }
101
+ if (order > 0) {
102
+ throw new BundleError('NON_CANONICAL_HEADER', `archive entries are not sorted by UTF-8 path: '${f.path}' follows '${previousPath}'`, f.path);
103
+ }
104
+ }
105
+ const filePrefix = canonicalBundleFilePrefix(f.path, filePaths);
106
+ if (filePrefix !== undefined) {
107
+ throw new BundleError('ARCHIVE_PATH_PREFIX_COLLISION', `archive file path '${filePrefix}' is a complete-segment prefix of '${f.path}'`, f.path);
108
+ }
109
+ filePaths.add(f.path);
110
+ previousPath = f.path;
111
+ if (f.path.length > limits.maxPathLength) {
112
+ throw new BundleError('ARCHIVE_PATH_TOO_LONG', `archive entry path length ${f.path.length} exceeds limit of ${limits.maxPathLength} chars`, f.path);
113
+ }
114
+ if (f.bytes.length > limits.maxFileBytes) {
115
+ throw new BundleError('ARCHIVE_ENTRY_TOO_LARGE', `archive entry '${f.path}' is ${f.bytes.length} bytes; limit is ${limits.maxFileBytes}`, f.path);
116
+ }
117
+ if (f.mode !== 0o644 && f.mode !== 0o755) {
118
+ throw new BundleError('NON_CANONICAL_HEADER', `archive entry '${f.path}' must use mode 0644 or 0755`, f.path);
119
+ }
120
+ const nameBytes = Buffer.byteLength(f.path, 'utf8');
121
+ if (nameBytes > 100) {
122
+ // USTAR name cannot hold it — emit a deterministic PAX path header.
123
+ headerCount += 2;
124
+ const paxData = buildPaxPathRecord(f.path);
125
+ chunks.push(buildHeader('PaxHeader', paxData.length, 'x', 0o644));
126
+ chunks.push(padBlock(paxData));
127
+ // The 100-byte name field is only a deterministic placeholder; the PAX
128
+ // record carries the effective UTF-8 path. Use the shared placeholder
129
+ // rule so the strict reader requires exactly what the writer emits.
130
+ chunks.push(buildHeader(canonicalPaxNamePlaceholder(f.path), f.bytes.length, '0', f.mode));
131
+ }
132
+ else {
133
+ headerCount += 1;
134
+ chunks.push(buildHeader(f.path, f.bytes.length, '0', f.mode));
135
+ }
136
+ if (headerCount > limits.maxFileCount) {
137
+ throw new BundleError('ARCHIVE_TOO_MANY_ENTRIES', `archive entry count exceeds limit of ${limits.maxFileCount}`);
138
+ }
139
+ chunks.push(padBlock(f.bytes));
140
+ }
141
+ chunks.push(Buffer.alloc(BLOCK * 2)); // two zero blocks end the archive
142
+ const tar = Buffer.concat(chunks);
143
+ if (tar.length > limits.maxExpandedBytes) {
144
+ throw new BundleError('BUNDLE_LIMIT', `expanded archive size ${tar.length} exceeds limit of ${limits.maxExpandedBytes} bytes`);
145
+ }
146
+ return tar;
147
+ }
148
+ /**
149
+ * Gzip `tar` with fixed options and a normalized header: no FEXTRA/FNAME/
150
+ * FCOMMENT, mtime bytes zeroed, OS byte forced to 0. Node's zlib reports
151
+ * OS 19 on Darwin and embeds the clock in mtime by default — patch both so
152
+ * the output is byte-identical across platforms and times.
153
+ */
154
+ export function gzipDeterministic(tar) {
155
+ const gz = gzipSync(Buffer.from(tar), { level: BUNDLE_GZIP_LEVEL });
156
+ gz[4] = 0; // mtime byte 0
157
+ gz[5] = 0; // mtime byte 1
158
+ gz[6] = 0; // mtime byte 2
159
+ gz[7] = 0; // mtime byte 3
160
+ gz[9] = 0; // OS byte (Darwin reports 19; the format fixes 0)
161
+ return gz;
162
+ }
163
+ /** Compare archive paths by ascending UTF-8 bytes, as required by canonical packing. */
164
+ export function compareUtf8Paths(a, b) {
165
+ return Buffer.compare(Buffer.from(a, 'utf8'), Buffer.from(b, 'utf8'));
166
+ }
167
+ const byNameBytes = (a, b) => compareUtf8Paths(a.name, b.name);
168
+ export function collectSourceFiles(sourceRoot, limits = DEFAULT_TAR_LIMITS, options = {}) {
169
+ const root = resolve(sourceRoot);
170
+ const readDir = options.readDir ?? ((directory) => readdirSync(directory, { withFileTypes: true }));
171
+ let rootStat;
172
+ try {
173
+ rootStat = lstatSync(root);
174
+ }
175
+ catch {
176
+ throw new BundleError('SOURCE_NOT_A_DIRECTORY', `source directory '${sourceRoot}' does not exist`);
177
+ }
178
+ if (rootStat.isSymbolicLink()) {
179
+ throw new BundleError('SOURCE_SYMLINK', `source root '${sourceRoot}' is a symbolic link`);
180
+ }
181
+ if (!rootStat.isDirectory()) {
182
+ throw new BundleError('SOURCE_NOT_A_DIRECTORY', `source '${sourceRoot}' is not a directory`);
183
+ }
184
+ const out = [];
185
+ let archiveEntryCount = 0;
186
+ const walk = (dirAbs, relPrefix) => {
187
+ let dirents;
188
+ try {
189
+ dirents = readDir(dirAbs);
190
+ }
191
+ catch (e) {
192
+ throw new BundleError('SOURCE_NOT_A_DIRECTORY', `cannot read '${dirAbs}': ${e.message}`);
193
+ }
194
+ dirents.sort(byNameBytes);
195
+ for (const d of dirents) {
196
+ const abs = join(dirAbs, d.name);
197
+ const rel = relPrefix === '' ? d.name : `${relPrefix}/${d.name}`;
198
+ options.onVisit?.(rel);
199
+ const violation = canonicalBundlePathViolation(rel);
200
+ if (violation) {
201
+ throw new BundleError('SOURCE_INVALID_PATH', `unsafe path '${rel}': ${violation}`, rel);
202
+ }
203
+ if (rel.length > limits.maxPathLength) {
204
+ throw new BundleError('ARCHIVE_PATH_TOO_LONG', `archive entry path length ${rel.length} exceeds limit of ${limits.maxPathLength} chars`, rel);
205
+ }
206
+ const st = lstatSync(abs);
207
+ if (st.isSymbolicLink()) {
208
+ throw new BundleError('SOURCE_SYMLINK', `symbolic link '${rel}' cannot be packed`, rel);
209
+ }
210
+ if (st.isDirectory()) {
211
+ walk(abs, rel);
212
+ continue;
213
+ }
214
+ if (!st.isFile()) {
215
+ throw new BundleError('SOURCE_NOT_A_FILE', `'${rel}' is not a regular file or directory`, rel);
216
+ }
217
+ if (st.size > limits.maxFileBytes) {
218
+ throw new BundleError('ARCHIVE_ENTRY_TOO_LARGE', `archive entry '${rel}' is ${st.size} bytes; limit is ${limits.maxFileBytes}`, rel);
219
+ }
220
+ out.push({ rel, abs, executable: (st.mode & 0o111) !== 0 });
221
+ archiveEntryCount += Buffer.byteLength(rel, 'utf8') > 100 ? 2 : 1;
222
+ if (archiveEntryCount > limits.maxFileCount) {
223
+ throw new BundleError('ARCHIVE_TOO_MANY_ENTRIES', `archive entry count exceeds limit of ${limits.maxFileCount}`);
224
+ }
225
+ }
226
+ };
227
+ walk(root, '');
228
+ out.sort((a, b) => compareUtf8Paths(a.rel, b.rel));
229
+ const filePaths = new Set();
230
+ for (const file of out) {
231
+ const filePrefix = canonicalBundleFilePrefix(file.rel, filePaths);
232
+ if (filePrefix !== undefined) {
233
+ throw new BundleError('ARCHIVE_PATH_PREFIX_COLLISION', `source file path '${filePrefix}' is a complete-segment prefix of '${file.rel}'`, file.rel);
234
+ }
235
+ filePaths.add(file.rel);
236
+ }
237
+ return out;
238
+ }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Public types for the deterministic `.wnlp` bundle format (WP-A1).
3
+ *
4
+ * A `.wnlp` file is gzip-compressed canonical POSIX/PAX tar; its identity
5
+ * ("def digest") is the lowercase SHA-256 of the UNCOMPRESSED canonical tar
6
+ * bytes. See `docs/bundles.md` for the full format contract.
7
+ */
8
+ import type { TarLimits } from '../archive.ts';
9
+ /** Every bundle failure carries one of these stable codes (machines match on `code`). */
10
+ export type BundleErrorCode = 'BUNDLE_IO' | 'BUNDLE_NOT_GZIP' | 'BUNDLE_LIMIT' | 'ARCHIVE_TOO_MANY_ENTRIES' | 'ARCHIVE_ENTRY_TOO_LARGE' | 'ARCHIVE_PATH_TOO_LONG' | 'ARCHIVE_PATH_VIOLATION' | 'ARCHIVE_DUPLICATE_PATH' | 'ARCHIVE_PATH_PREFIX_COLLISION' | 'ARCHIVE_TRUNCATED' | 'ARCHIVE_BAD_CHECKSUM' | 'ARCHIVE_BAD_OCTAL' | 'ARCHIVE_BAD_PAX' | 'ARCHIVE_DANGLING_PAX' | 'ARCHIVE_TRAILING_BYTES' | 'UNSUPPORTED_ENTRY_TYPE' | 'NON_CANONICAL_HEADER' | 'MANIFEST_ERROR' | 'RUNTIME_INCOMPATIBLE' | 'UNSUPPORTED_FORMAT_VERSION' | 'MANIFEST_MISSING' | 'WORKFLOW_MISSING' | 'WORKFLOW_INVALID' | 'INTEGRITY_MISMATCH' | 'SOURCE_NOT_A_DIRECTORY' | 'SOURCE_NOT_A_FILE' | 'SOURCE_SYMLINK' | 'SOURCE_INVALID_PATH' | 'SOURCE_FILE_CHANGED' | 'OUTPUT_INSIDE_SOURCE' | 'OUTPUT_INVALID' | 'DESTINATION_EXISTS' | 'DESTINATION_PARENT_INVALID' | 'WORKFLOW_ERROR';
11
+ /**
12
+ * A typed bundle failure. `message` is human-readable; `entryPath` carries
13
+ * the offending archive/manifest entry when applicable.
14
+ */
15
+ export declare class BundleError extends Error {
16
+ readonly code: BundleErrorCode;
17
+ readonly entryPath?: string;
18
+ constructor(code: BundleErrorCode, message: string, entryPath?: string);
19
+ }
20
+ /** Compatibility requirements that a format-v2 bundle places on its reader/runtime. */
21
+ export interface BundleRuntimeRequirements {
22
+ /** Minimum canonical Owenloop SemVer accepted by the bundle. */
23
+ minVersion?: string;
24
+ /** Versioned runtime feature identifiers that the reader must implement. */
25
+ features?: string[];
26
+ }
27
+ /**
28
+ * The v2 package-only manifest (`bundle.yaml`). All collections are
29
+ * duplicate-free; serialization order is deterministic (see
30
+ * `docs/bundles.md` §Manifest).
31
+ */
32
+ export interface BundleManifest {
33
+ /** Always `2` in this format version. */
34
+ formatVersion: 2;
35
+ package: {
36
+ /** Portable package namespace. */
37
+ name: string;
38
+ /** Non-empty version string. */
39
+ version: string;
40
+ };
41
+ /** Optional reader/runtime compatibility requirements. */
42
+ runtime?: BundleRuntimeRequirements;
43
+ /** Workflow name to archive-relative definition path. */
44
+ workflows: Record<string, string>;
45
+ /** Optional default workflow name. */
46
+ default?: string;
47
+ /** Platform selectors this package targets (may be empty). */
48
+ platforms: string[];
49
+ integrity: {
50
+ /** Always `'sha256'`. */
51
+ algorithm: 'sha256';
52
+ /**
53
+ * Lowercase 64-hex SHA-256 for every regular archive file EXCEPT
54
+ * `bundle.yaml` (self-hash is recursive; the def digest still covers the
55
+ * manifest through the canonical tar).
56
+ */
57
+ files: Record<string, string>;
58
+ };
59
+ /**
60
+ * Requested capability classes and values — REQUESTS only; this format
61
+ * neither grants nor enforces them.
62
+ */
63
+ capabilities: Record<string, string[]>;
64
+ /**
65
+ * Digest-pinned cross-bundle references: exact `namespace/name@version`
66
+ * reference text → lowercase 64-hex def digest of the called bundle.
67
+ */
68
+ lock: Record<string, string>;
69
+ }
70
+ /** One regular-file entry of a bundle, as returned by pack/inspect. */
71
+ export interface BundleEntryInfo {
72
+ path: string;
73
+ size: number;
74
+ /** True when the source carried any execute bit (canonical mode 0755). */
75
+ executable: boolean;
76
+ /** Lowercase 64-hex SHA-256 of the entry's bytes. */
77
+ sha256: string;
78
+ }
79
+ /** Result of {@link packBundle}. */
80
+ export interface PackResult {
81
+ /** The complete `.wnlp` bytes (gzip of the canonical tar). */
82
+ bytes: Uint8Array;
83
+ /** Lowercase 64-hex SHA-256 over the uncompressed canonical tar bytes. */
84
+ digest: string;
85
+ /** The canonical manifest actually archived (source manifest regenerated). */
86
+ manifest: BundleManifest;
87
+ /** Archive entries in canonical (sorted) order, including `bundle.yaml`. */
88
+ entries: BundleEntryInfo[];
89
+ }
90
+ /** Result of {@link inspectBundle}. */
91
+ export interface InspectResult {
92
+ digest: string;
93
+ manifest: BundleManifest;
94
+ entries: BundleEntryInfo[];
95
+ }
96
+ /** Resource bounds for reading/writing bundles (the shared archive limits). */
97
+ export type BundleLimits = TarLimits;
98
+ /** Options for {@link packBundle}. */
99
+ export interface PackOptions {
100
+ limits?: Partial<BundleLimits>;
101
+ }
102
+ /** Options for {@link inspectBundle} / {@link digestBundle} / {@link unpackBundle}. */
103
+ export interface InspectOptions {
104
+ limits?: Partial<BundleLimits>;
105
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Public types for the deterministic `.wnlp` bundle format (WP-A1).
3
+ *
4
+ * A `.wnlp` file is gzip-compressed canonical POSIX/PAX tar; its identity
5
+ * ("def digest") is the lowercase SHA-256 of the UNCOMPRESSED canonical tar
6
+ * bytes. See `docs/bundles.md` for the full format contract.
7
+ */
8
+ /**
9
+ * A typed bundle failure. `message` is human-readable; `entryPath` carries
10
+ * the offending archive/manifest entry when applicable.
11
+ */
12
+ export class BundleError extends Error {
13
+ code;
14
+ entryPath;
15
+ constructor(code, message, entryPath) {
16
+ super(message);
17
+ this.code = code;
18
+ if (entryPath !== undefined)
19
+ this.entryPath = entryPath;
20
+ }
21
+ }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The owenloop CLI — a thin, scriptable surface over the engine.
3
3
  *
4
- * Every data command prints JSON to stdout, so a *wiring* (the worker/automation
4
+ * Every data command prints JSON to stdout, so a *wiring* (the Step Agent/automation
5
5
  * that actually runs orders) can drive the engine programmatically: `tick` to
6
6
  * pull orders, run them, then `green` / `emit` / `seal` / `reject` / `close` to
7
7
  * report outcomes. The engine itself is domain-neutral; this binary just maps
@@ -9,6 +9,7 @@
9
9
  *
10
10
  * owenloop defs list available workflow definitions
11
11
  * owenloop add <owner>/<repo>[@ref] fetch, validate, and install a repo's workflow defs (public repos)
12
+ * owenloop start <def> [--provide n=json] [--crew name] start a published hub workflow
12
13
  * owenloop create <def> [--provide n=json] [--title t] start an instance
13
14
  * owenloop provide <wf> <name> [--value json] supply an owed input
14
15
  * owenloop tick <wf> [--now ms] pull eligible orders
@@ -31,9 +32,13 @@
31
32
  *
32
33
  * Global: --db <path> (env OWENLOOP_DB), --defs <dir> (env OWENLOOP_DEFS).
33
34
  */
35
+ import { hasDefiniteCheckDefect } from './model.ts';
36
+ import { PrincipalKeyManager } from './crypto/keys.ts';
34
37
  import type { LineStream } from './mcp/server.ts';
38
+ import type { BundleIngestor, PreCommitVerifier } from './store/index.ts';
35
39
  import type { AgentIdentitySummary, Keychain } from './hub.ts';
36
40
  export type { Keychain } from './hub.ts';
41
+ export type HarnessId = 'claude-code' | 'codex';
37
42
  export interface CliIO {
38
43
  cwd: string;
39
44
  env: Record<string, string | undefined>;
@@ -41,6 +46,24 @@ export interface CliIO {
41
46
  err: (line: string) => void;
42
47
  /** Injectable for hermetic tests — the network-touching verbs (`add`, hub commands) use this. */
43
48
  fetch?: typeof globalThis.fetch;
49
+ /**
50
+ * The bundle adapter for the `.wnlp` install route (unpacking, manifest
51
+ * integrity, canonical digest, coordinate). Injectable for tests and for
52
+ * wiring layers that carry the bundle-format module. `add` with bundle
53
+ * input FAILS CLOSED when this is absent — there is no default accepting
54
+ * parser or digest algorithm. The GitHub repo route never uses it.
55
+ */
56
+ bundleIngestor?: BundleIngestor;
57
+ /**
58
+ * The pre-commit verifier for the `.wnlp` install route, called after
59
+ * content/engine validation and before any object swap or index write.
60
+ * Injectable for tests and for wiring layers that carry the verification
61
+ * module. `add` with bundle input FAILS CLOSED when this is absent — there
62
+ * is no default accepting verifier. The GitHub repo route never uses it.
63
+ */
64
+ preCommitVerifier?: PreCommitVerifier;
65
+ /** Optional test/runtime override for the external install/repair transaction marker directory. */
66
+ recoveryMarkerDir?: string;
44
67
  /** Open a URL in the user's browser (login). Default: fire-and-forget `open`/`xdg-open`/`start`. */
45
68
  openUrl?: (url: string) => void;
46
69
  /**
@@ -70,19 +93,33 @@ export interface CliIO {
70
93
  */
71
94
  prompt?: (question: string) => Promise<string>;
72
95
  /**
73
- * Run a local command and capture its result — used ONLY by `setup`/`doctor`'s
74
- * Claude Code plugin probe (`claude plugin list`). Default: a `spawnSync`
96
+ * Run a local command and capture its result — used by `setup`/`doctor`'s
97
+ * Claude Code and Codex plugin probes and convergers. Default: a `spawnSync`
75
98
  * wrapper with `shell: false` (never interpolates argv into a shell) that
76
- * never inherits stdio. Injectable so tests model the plugin state without a
77
- * real `claude` binary.
99
+ * never inherits stdio. Injectable so tests model plugin state and installs
100
+ * without real harness binaries or configuration writes.
78
101
  */
79
102
  runCommand?: (cmd: string, args: string[]) => {
80
103
  status: number | null;
81
104
  stdout: string;
82
105
  stderr: string;
83
106
  };
107
+ /** Optional resolver override for hermetic tests of a missing bundled marketplace. */
108
+ resolveBundledMarketplaceRoot?: (harness: HarnessId) => string | null;
109
+ /**
110
+ * The principal signing-key manager for `setup`'s `[4/7] signing keys` step.
111
+ * Injectable so setup tests never reach the developer's real `ssh-keygen`,
112
+ * Keychain, libsecret, SSH agent, or `$HOME` (`makeFakePrincipalKeys` in
113
+ * test/hubkit.ts). Default: a real `PrincipalKeyManager` over `io.env`.
114
+ * Structurally `Pick<PrincipalKeyManager, 'ensure' | 'inspect' | 'withSigningKey' |
115
+ * 'resolveRef'>` — the narrow surface setup and publish use — so fakes stay
116
+ * hermetic.
117
+ */
118
+ principalKeys?: Pick<PrincipalKeyManager, 'ensure' | 'inspect' | 'withSigningKey' | 'resolveRef'>;
84
119
  }
85
- export declare const USAGE = "owenloop \u2014 a dataflow workflow engine\n\nUsage: owenloop <command> [args] [--db <path>] [--defs <dir>]\n\nCommands:\n defs list available workflow definitions\n add <owner>/<repo>[@ref] fetch, validate, and install a repo's workflow defs (public repos)\n add --recover finish or undo a crash-interrupted install (offline; no network)\n login [--hub <url>] [--with-token] [--as <slot>] authenticate the CLI against a hub, verified via whoami (loopback OAuth, or --with-token from stdin)\n logout [--hub <url>] [--as <slot>] delete the stored credential for a hub in one slot\n connect [--hub <url>] [--as <slot>] bind this project to a hub and verify the stored credential (whoami)\n push [<defName>...] [--force] [--dry-run] [--as <slot>] publish local workflow defs to the bound hub (server-diffed, idempotent)\n --as names the credential slot: human (default), agent, or agent:<account>\n agent new <name> [--pools <a,b>] [--hub <url>] mint a new agent identity on the hub and store its token in slot agent:<name> (the token is never printed)\n setup [--hub <url>] [--new-agent <name> | --replace-agent <name>] [--pools <a,b>] converge this machine's install: human login, agent credential, owenwork settings, plugin (idempotent)\n doctor [--hub <url>] check this machine's owenloop install and report each piece (read-only)\n mcp [--hub <url>] serve the hub control plane over stdio MCP (spawned by MCP hosts, not run by humans)\n lint [<def-name>] check def(s) for wiring problems\n check <def> [--format text|json] [--max-depth N] [--max-states N] [--max-collection N] [--assume-provided] [--strict-inputs]\n bounded reachability check (stall states, true deadlocks, stuck, dead steps, declared invariants)\n create <def> [--title t] [--provide name=json ...] [--param k=v ...]\n provide <wf> <name> [--value json] supply an owed (seedOwed) input\n adopt <wf> re-pin an instance to the current def (\u00A728); settles new debts\n tick <wf> [--now <ms>] [--shallow] [--label <l>]... pull eligible orders (deep: also from calls: children; --shallow for this instance only; --label filters to matching-label steps)\n reap <wf> [--now] run the reaper; --now forces every claim stale (TTL 0)\n runs <wf> [--open] list this instance's runs (+ claim state for open ones)\n order <wf> <run> print the order packet issued at claim time (persisted in the claim txn)\n status <wf> derive debts / eligible / blocked\n status --all every instance's status in one call (fleet read)\n wait <wf> --until eligible|done [--timeout <dur>] block until engine state matches\n show <wf> dump raw artifacts\n trace <wf> [--format text] causal timeline + artifact biographies\n graph <def-or-wf> [--format dot|mermaid|json] wiring graph (+ live overlay if wf id)\n list list workflow instances\n green <wf> <run> <path> [--value json] [--terminal]\n emit <wf> <run> --items '[{...}]' accrete collection elements\n seal <wf> <run> [--value json] signal a collection is complete\n reject <wf> <path> --by <author> --text <msg>\n retract <wf> <path> --by <author> --text <msg>\n skip <wf> <path> --by <author> --text <msg>\n retry <wf> <path> [--by <author>] [--text <guidance>] clear a \u00A76 stall\n heartbeat <wf> <run> [--now <ms>] touch liveness timestamp on an open run\n close <wf> <run> [--outcome ok|no_work|failed|skipped] [--summary s]\n delete <wf> [--recursive] refuse if children exist unless --recursive (cascades)\n\nEnvironment: OWENLOOP_DB, OWENLOOP_DEFS";
120
+ export declare function defaultIO(): CliIO;
121
+ export declare const USAGE: string;
122
+ export { hasDefiniteCheckDefect };
86
123
  /**
87
124
  * Single source of truth for the `--options` each command accepts, consulted by
88
125
  * `preflight` before any side effect. Unknown-OPTION rejection AND
@@ -97,6 +134,40 @@ export declare const USAGE = "owenloop \u2014 a dataflow workflow engine\n\nUsag
97
134
  * `last/all/flag/needOpt/numOpt` call site.
98
135
  */
99
136
  export declare const COMMAND_OPTIONS: ReadonlyMap<string, ReadonlySet<string>>;
137
+ /**
138
+ * The classification of a single `add` positional. Pure and independently
139
+ * tested: no filesystem access, no network, no state.
140
+ *
141
+ * - `github`: `owner/repo[@ref]` with no URL scheme and no `.wnlp` path —
142
+ * the byte-for-byte preserved GitHub route.
143
+ * - `file`: a local path ending in `.wnlp` — a bundle FILE (origin data only,
144
+ * never identity).
145
+ * - `url`: an `http:`/`https:` URL — a bundle URL; any other scheme is
146
+ * rejected, never a silent fallback.
147
+ */
148
+ export type AddSource = {
149
+ kind: 'github';
150
+ spec: string;
151
+ } | {
152
+ kind: 'file';
153
+ path: string;
154
+ } | {
155
+ kind: 'url';
156
+ url: string;
157
+ };
158
+ /**
159
+ * Classify one `add` positional WITHOUT changing GitHub behavior: the GitHub
160
+ * shape (`owner/repo[@ref]`, no scheme, not a `.wnlp` path) returns
161
+ * `{ kind: 'github' }` for exactly the same inputs `parseRepoSpec` accepts,
162
+ * and the GitHub route keeps parsing it — so every error message for a
163
+ * malformed repo spec is unchanged. `.wnlp` file paths and http/https URLs
164
+ * take the bundle route; everything else is a specific usage refusal.
165
+ *
166
+ * The classifier never inspects the filesystem: a `.wnlp` path that does not
167
+ * exist is still classified as a file (the reader refuses it afterward with
168
+ * the reason), and a URL is classified by scheme alone.
169
+ */
170
+ export declare function classifyAddSource(spec: string): AddSource;
100
171
  /**
101
172
  * Coerce a raw string (a hostname) into a valid agent account name, or `''` when
102
173
  * nothing usable survives. Lowercase; drop every character outside the account
@@ -118,6 +189,20 @@ export declare function lastActiveMs(identity: AgentIdentitySummary): number | n
118
189
  * renders `never`. Negative deltas (clock skew) clamp to `just now`.
119
190
  */
120
191
  export declare function formatLastActive(deltaMs: number | null): string;
192
+ export interface HarnessPluginState {
193
+ id: HarnessId;
194
+ cliName: 'claude' | 'codex';
195
+ cliFound: boolean;
196
+ installed: boolean;
197
+ installedVersion: string | null;
198
+ cliVersion: string | null;
199
+ }
200
+ /**
201
+ * Resolve a bundled marketplace root from either the source tree (`src/cli.ts`)
202
+ * or the shipped tree (`dist/src/cli.js`). The manifest check prevents a partial
203
+ * package from producing a path that the harness cannot consume.
204
+ */
205
+ export declare function resolveBundledMarketplaceRoot(harness: HarnessId): string | null;
121
206
  /**
122
207
  * Async entry point that adds network I/O for `add` and the hub commands on top
123
208
  * of the otherwise fully-synchronous engine/CLI (see the doc comment on
@@ -128,5 +213,5 @@ export declare function formatLastActive(deltaMs: number | null): string;
128
213
  */
129
214
  export declare const ASYNC_COMMANDS: Set<string>;
130
215
  export declare function mainAsync(argv: string[], io?: CliIO): Promise<number>;
131
- /** Run the CLI. Returns a process exit code. */
216
+ /** Run the synchronous engine CLI. The `work` and `shift` namespaces are async-only. */
132
217
  export declare function main(argv: string[], io?: CliIO): number;