@jinn-network/client 0.1.9-canary.5c19fc6d → 0.1.9-canary.5ff3d8cb

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 (295) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/dist/adapters/mech/adapter.d.ts +10 -0
  3. package/dist/adapters/mech/adapter.js +19 -1
  4. package/dist/adapters/mech/adapter.js.map +1 -1
  5. package/dist/adapters/mech/types.d.ts +1 -88
  6. package/dist/adapters/mech/types.js +1 -45
  7. package/dist/adapters/mech/types.js.map +1 -1
  8. package/dist/api/bootstrap-endpoint.d.ts +18 -3
  9. package/dist/api/bootstrap-endpoint.js +3 -0
  10. package/dist/api/bootstrap-endpoint.js.map +1 -1
  11. package/dist/api/gather-status.js +6 -5
  12. package/dist/api/gather-status.js.map +1 -1
  13. package/dist/api/launcher-endpoints.js +6 -1
  14. package/dist/api/launcher-endpoints.js.map +1 -1
  15. package/dist/api/launcher-status.d.ts +2 -0
  16. package/dist/api/launcher-status.js.map +1 -1
  17. package/dist/api/launcher-tasks.d.ts +47 -0
  18. package/dist/api/launcher-tasks.js +88 -3
  19. package/dist/api/launcher-tasks.js.map +1 -1
  20. package/dist/api/loop-completion-build.d.ts +2 -2
  21. package/dist/api/loop-completion-build.js +2 -3
  22. package/dist/api/loop-completion-build.js.map +1 -1
  23. package/dist/api/portfolio-v0-build.d.ts +2 -1
  24. package/dist/api/portfolio-v0-build.js +5 -7
  25. package/dist/api/portfolio-v0-build.js.map +1 -1
  26. package/dist/api/prediction-v1-build.d.ts +2 -2
  27. package/dist/api/prediction-v1-build.js +5 -7
  28. package/dist/api/prediction-v1-build.js.map +1 -1
  29. package/dist/api/setup-endpoints.d.ts +4 -0
  30. package/dist/api/setup-endpoints.js +13 -7
  31. package/dist/api/setup-endpoints.js.map +1 -1
  32. package/dist/api/status-build.js +1 -4
  33. package/dist/api/status-build.js.map +1 -1
  34. package/dist/api/task-run-routing.d.ts +1 -1
  35. package/dist/api/task-runs-build.d.ts +2 -2
  36. package/dist/api/task-runs-build.js +5 -7
  37. package/dist/api/task-runs-build.js.map +1 -1
  38. package/dist/bin/jinn-distill-mcp.js +813 -0
  39. package/dist/bin/jinn-layer.js +4992 -1151
  40. package/dist/build-info.json +4 -4
  41. package/dist/build-meta.json +1 -1
  42. package/dist/captures/distil-export.d.ts +54 -0
  43. package/dist/captures/distil-export.js +135 -0
  44. package/dist/captures/distil-export.js.map +1 -0
  45. package/dist/captures/ingest.d.ts +21 -0
  46. package/dist/captures/ingest.js +144 -0
  47. package/dist/captures/ingest.js.map +1 -0
  48. package/dist/captures/live-publisher.js +4 -3
  49. package/dist/captures/live-publisher.js.map +1 -1
  50. package/dist/captures/publish.d.ts +4 -0
  51. package/dist/captures/publish.js +2 -2
  52. package/dist/captures/publish.js.map +1 -1
  53. package/dist/cli/execution-context.js +2 -1
  54. package/dist/cli/execution-context.js.map +1 -1
  55. package/dist/config.js +34 -1
  56. package/dist/config.js.map +1 -1
  57. package/dist/contracts/abis.d.ts +100 -0
  58. package/dist/contracts/abis.js +58 -0
  59. package/dist/contracts/abis.js.map +1 -0
  60. package/dist/contracts/addresses.d.ts +36 -0
  61. package/dist/contracts/addresses.js +60 -0
  62. package/dist/contracts/addresses.js.map +1 -0
  63. package/dist/corpus/onchain-query.d.ts +0 -1
  64. package/dist/corpus/onchain-query.js +2 -5
  65. package/dist/corpus/onchain-query.js.map +1 -1
  66. package/dist/daemon/balance-topup-loop.js +27 -12
  67. package/dist/daemon/balance-topup-loop.js.map +1 -1
  68. package/dist/daemon/creator.js +15 -13
  69. package/dist/daemon/creator.js.map +1 -1
  70. package/dist/daemon/daemon.js +35 -13
  71. package/dist/daemon/daemon.js.map +1 -1
  72. package/dist/daemon/loop-heartbeat.d.ts +62 -7
  73. package/dist/daemon/loop-heartbeat.js +50 -13
  74. package/dist/daemon/loop-heartbeat.js.map +1 -1
  75. package/dist/{api/peers.js → daemon/peer-sync.js} +2 -2
  76. package/dist/daemon/peer-sync.js.map +1 -0
  77. package/dist/daemon/reward-claim-loop.js +27 -12
  78. package/dist/daemon/reward-claim-loop.js.map +1 -1
  79. package/dist/daemon/spend-cap-gate.d.ts +0 -6
  80. package/dist/daemon/spend-cap-gate.js +1 -8
  81. package/dist/daemon/spend-cap-gate.js.map +1 -1
  82. package/dist/dashboard/assets/index-BdGCkGPF.js +157 -0
  83. package/dist/dashboard/assets/index-D7rvJRNa.css +1 -0
  84. package/dist/dashboard/index.html +2 -2
  85. package/dist/discovery/http.js +83 -1
  86. package/dist/discovery/http.js.map +1 -1
  87. package/dist/discovery/onchain.js +16 -8
  88. package/dist/discovery/onchain.js.map +1 -1
  89. package/dist/discovery/types.d.ts +43 -0
  90. package/dist/discovery/types.js.map +1 -1
  91. package/dist/discovery/with-fallback.js +10 -0
  92. package/dist/discovery/with-fallback.js.map +1 -1
  93. package/dist/earning/bootstrap-run.d.ts +25 -0
  94. package/dist/earning/bootstrap-run.js +315 -0
  95. package/dist/earning/bootstrap-run.js.map +1 -0
  96. package/dist/earning/bootstrap.d.ts +6 -11
  97. package/dist/earning/bootstrap.js +45 -195
  98. package/dist/earning/bootstrap.js.map +1 -1
  99. package/dist/earning/contracts.d.ts +2 -3
  100. package/dist/earning/contracts.js +12 -21
  101. package/dist/earning/contracts.js.map +1 -1
  102. package/dist/earning/master-gas.d.ts +10 -0
  103. package/dist/earning/master-gas.js +11 -0
  104. package/dist/earning/master-gas.js.map +1 -0
  105. package/dist/earning/safe-adapter.js +1 -45
  106. package/dist/earning/safe-adapter.js.map +1 -1
  107. package/dist/earning/steps/context.d.ts +42 -0
  108. package/dist/earning/steps/context.js +4 -0
  109. package/dist/earning/steps/context.js.map +1 -0
  110. package/dist/earning/steps/fleet-identity-register.d.ts +4 -0
  111. package/dist/earning/steps/fleet-identity-register.js +65 -0
  112. package/dist/earning/steps/fleet-identity-register.js.map +1 -0
  113. package/dist/earning/steps/fleet-safe-deploy.d.ts +4 -0
  114. package/dist/earning/steps/fleet-safe-deploy.js +62 -0
  115. package/dist/earning/steps/fleet-safe-deploy.js.map +1 -0
  116. package/dist/earning/steps/fleet-safe-predict.d.ts +4 -0
  117. package/dist/earning/steps/fleet-safe-predict.js +18 -0
  118. package/dist/earning/steps/fleet-safe-predict.js.map +1 -0
  119. package/dist/earning/steps/receipt-parsing.d.ts +12 -0
  120. package/dist/earning/steps/receipt-parsing.js +71 -0
  121. package/dist/earning/steps/receipt-parsing.js.map +1 -0
  122. package/dist/earning/stolas-staking.js +20 -14
  123. package/dist/earning/stolas-staking.js.map +1 -1
  124. package/dist/erc8004/addresses.d.ts +6 -5
  125. package/dist/erc8004/addresses.js +7 -5
  126. package/dist/erc8004/addresses.js.map +1 -1
  127. package/dist/erc8004/identity.d.ts +12 -1
  128. package/dist/erc8004/identity.js +31 -0
  129. package/dist/erc8004/identity.js.map +1 -1
  130. package/dist/erc8004/index.d.ts +1 -1
  131. package/dist/erc8004/index.js +1 -1
  132. package/dist/erc8004/index.js.map +1 -1
  133. package/dist/erc8004/reputation.js +16 -12
  134. package/dist/erc8004/reputation.js.map +1 -1
  135. package/dist/erc8004/validation.js +5 -4
  136. package/dist/erc8004/validation.js.map +1 -1
  137. package/dist/eval/capability-slate.d.ts +54 -0
  138. package/dist/eval/capability-slate.js +116 -0
  139. package/dist/eval/capability-slate.js.map +1 -0
  140. package/dist/eval/capability-stats.d.ts +39 -0
  141. package/dist/eval/capability-stats.js +123 -0
  142. package/dist/eval/capability-stats.js.map +1 -0
  143. package/dist/eval/contested-band.d.ts +18 -0
  144. package/dist/eval/contested-band.js +19 -0
  145. package/dist/eval/contested-band.js.map +1 -0
  146. package/dist/eval/corpus-index.d.ts +21 -0
  147. package/dist/eval/corpus-index.js +55 -0
  148. package/dist/eval/corpus-index.js.map +1 -0
  149. package/dist/eval/disjointness.d.ts +26 -0
  150. package/dist/eval/disjointness.js +67 -0
  151. package/dist/eval/disjointness.js.map +1 -0
  152. package/dist/eval/mcnemar-power.d.ts +14 -0
  153. package/dist/eval/mcnemar-power.js +40 -0
  154. package/dist/eval/mcnemar-power.js.map +1 -0
  155. package/dist/harnesses/engine/engine.d.ts +2 -1
  156. package/dist/harnesses/engine/engine.js +15 -2
  157. package/dist/harnesses/engine/engine.js.map +1 -1
  158. package/dist/harnesses/engine/persistence.d.ts +2 -61
  159. package/dist/harnesses/engine/persistence.js.map +1 -1
  160. package/dist/harnesses/impls/_evaluator-base.d.ts +48 -0
  161. package/dist/harnesses/impls/_evaluator-base.js +35 -0
  162. package/dist/harnesses/impls/_evaluator-base.js.map +1 -0
  163. package/dist/harnesses/impls/claude-mcp-prediction/index.d.ts +2 -3
  164. package/dist/harnesses/impls/claude-mcp-prediction/index.js +29 -99
  165. package/dist/harnesses/impls/claude-mcp-prediction/index.js.map +1 -1
  166. package/dist/harnesses/impls/claude-mcp-prediction/mcp-tools.js +4 -21
  167. package/dist/harnesses/impls/claude-mcp-prediction/mcp-tools.js.map +1 -1
  168. package/dist/harnesses/impls/claude-mcp-prediction/session-orchestrator.d.ts +2 -0
  169. package/dist/harnesses/impls/claude-mcp-prediction/session-orchestrator.js +1 -1
  170. package/dist/harnesses/impls/claude-mcp-prediction/session-orchestrator.js.map +1 -1
  171. package/dist/harnesses/impls/claude-mcp-prediction-apy/index.js +30 -79
  172. package/dist/harnesses/impls/claude-mcp-prediction-apy/index.js.map +1 -1
  173. package/dist/harnesses/impls/claude-mcp-prediction-apy/mcp-tools.js +4 -19
  174. package/dist/harnesses/impls/claude-mcp-prediction-apy/mcp-tools.js.map +1 -1
  175. package/dist/harnesses/impls/claude-mcp-prediction-apy/session-orchestrator.d.ts +2 -0
  176. package/dist/harnesses/impls/claude-mcp-prediction-apy/session-orchestrator.js +1 -1
  177. package/dist/harnesses/impls/claude-mcp-prediction-apy/session-orchestrator.js.map +1 -1
  178. package/dist/harnesses/impls/claude-mcp-shared/mcp-server-script.d.ts +39 -0
  179. package/dist/harnesses/impls/claude-mcp-shared/mcp-server-script.js +62 -0
  180. package/dist/harnesses/impls/claude-mcp-shared/mcp-server-script.js.map +1 -0
  181. package/dist/harnesses/impls/claude-mcp-shared/mcp-server.d.ts +40 -0
  182. package/dist/harnesses/impls/claude-mcp-shared/mcp-server.js +44 -0
  183. package/dist/harnesses/impls/claude-mcp-shared/mcp-server.js.map +1 -0
  184. package/dist/harnesses/impls/claude-mcp-shared/single-session-harness.d.ts +56 -0
  185. package/dist/harnesses/impls/claude-mcp-shared/single-session-harness.js +79 -0
  186. package/dist/harnesses/impls/claude-mcp-shared/single-session-harness.js.map +1 -0
  187. package/dist/harnesses/impls/learner/adapters/codex-code.d.ts +3 -1
  188. package/dist/harnesses/impls/learner/adapters/codex-code.js +39 -4
  189. package/dist/harnesses/impls/learner/adapters/codex-code.js.map +1 -1
  190. package/dist/harnesses/impls/portfolio-v0-evaluator/index.d.ts +5 -15
  191. package/dist/harnesses/impls/portfolio-v0-evaluator/index.js +10 -29
  192. package/dist/harnesses/impls/portfolio-v0-evaluator/index.js.map +1 -1
  193. package/dist/harnesses/impls/prediction-apy-v0-evaluator/index.d.ts +5 -15
  194. package/dist/harnesses/impls/prediction-apy-v0-evaluator/index.js +10 -23
  195. package/dist/harnesses/impls/prediction-apy-v0-evaluator/index.js.map +1 -1
  196. package/dist/harnesses/impls/prediction-v0-evaluator/index.d.ts +5 -15
  197. package/dist/harnesses/impls/prediction-v0-evaluator/index.js +10 -25
  198. package/dist/harnesses/impls/prediction-v0-evaluator/index.js.map +1 -1
  199. package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js +8 -0
  200. package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js.map +1 -1
  201. package/dist/learner/verification-gate.d.ts +53 -0
  202. package/dist/learner/verification-gate.js +80 -0
  203. package/dist/learner/verification-gate.js.map +1 -0
  204. package/dist/main.js +74 -457
  205. package/dist/main.js.map +1 -1
  206. package/dist/monitoring/net-liveness.d.ts +143 -0
  207. package/dist/monitoring/net-liveness.js +301 -0
  208. package/dist/monitoring/net-liveness.js.map +1 -0
  209. package/dist/observability/progress.d.ts +11 -0
  210. package/dist/observability/progress.js +16 -0
  211. package/dist/observability/progress.js.map +1 -0
  212. package/dist/pilot/cost.d.ts +19 -0
  213. package/dist/pilot/cost.js +31 -0
  214. package/dist/pilot/cost.js.map +1 -0
  215. package/dist/pilot/instance.d.ts +20 -0
  216. package/dist/pilot/instance.js +19 -0
  217. package/dist/pilot/instance.js.map +1 -0
  218. package/dist/pilot/repo.d.ts +31 -0
  219. package/dist/pilot/repo.js +42 -0
  220. package/dist/pilot/repo.js.map +1 -0
  221. package/dist/pilot/solve.d.ts +22 -0
  222. package/dist/pilot/solve.js +37 -0
  223. package/dist/pilot/solve.js.map +1 -0
  224. package/dist/pilot/tally.d.ts +35 -0
  225. package/dist/pilot/tally.js +61 -0
  226. package/dist/pilot/tally.js.map +1 -0
  227. package/dist/plugins/local-trace-distiller/.claude-plugin/plugin.json +9 -0
  228. package/dist/plugins/local-trace-distiller/.codex-plugin/plugin.json +41 -0
  229. package/dist/plugins/local-trace-distiller/.mcp.json +8 -0
  230. package/dist/plugins/local-trace-distiller/README.md +27 -0
  231. package/dist/plugins/local-trace-distiller/jinn.plugin.json +36 -0
  232. package/dist/plugins/local-trace-distiller/skills/distill/SKILL.md +51 -0
  233. package/dist/preflight/rpc-network.d.ts +10 -3
  234. package/dist/preflight/rpc-network.js +46 -13
  235. package/dist/preflight/rpc-network.js.map +1 -1
  236. package/dist/preflight/stable-cwd.d.ts +29 -0
  237. package/dist/preflight/stable-cwd.js +98 -0
  238. package/dist/preflight/stable-cwd.js.map +1 -0
  239. package/dist/solvernets/launched-record-dispatcher.js +6 -0
  240. package/dist/solvernets/launched-record-dispatcher.js.map +1 -1
  241. package/dist/spend/credential.d.ts +2 -2
  242. package/dist/spend/credential.js +9 -3
  243. package/dist/spend/credential.js.map +1 -1
  244. package/dist/spend/spend-cap.d.ts +10 -0
  245. package/dist/spend/spend-cap.js +13 -0
  246. package/dist/spend/spend-cap.js.map +1 -0
  247. package/dist/store/store.d.ts +14 -0
  248. package/dist/store/store.js +10 -1
  249. package/dist/store/store.js.map +1 -1
  250. package/dist/trajectory/processors/identity-scrub.js +22 -3
  251. package/dist/trajectory/processors/identity-scrub.js.map +1 -1
  252. package/dist/trajectory/scrub/build.d.ts +19 -0
  253. package/dist/trajectory/scrub/build.js +25 -0
  254. package/dist/trajectory/scrub/build.js.map +1 -1
  255. package/dist/trajectory/scrub/layer2.d.ts +23 -0
  256. package/dist/trajectory/scrub/layer2.js +33 -0
  257. package/dist/trajectory/scrub/layer2.js.map +1 -0
  258. package/dist/trajectory/scrub/openredaction-stage.d.ts +127 -0
  259. package/dist/trajectory/scrub/openredaction-stage.js +186 -2
  260. package/dist/trajectory/scrub/openredaction-stage.js.map +1 -1
  261. package/dist/trajectory/scrub/pipeline.d.ts +21 -0
  262. package/dist/trajectory/scrub/pipeline.js +57 -0
  263. package/dist/trajectory/scrub/pipeline.js.map +1 -1
  264. package/dist/trajectory/scrub/plain-patterns-stage.d.ts +14 -1
  265. package/dist/trajectory/scrub/plain-patterns-stage.js +35 -5
  266. package/dist/trajectory/scrub/plain-patterns-stage.js.map +1 -1
  267. package/dist/trajectory/scrub/secretlint-stage.d.ts +22 -3
  268. package/dist/trajectory/scrub/secretlint-stage.js +118 -27
  269. package/dist/trajectory/scrub/secretlint-stage.js.map +1 -1
  270. package/dist/trajectory/transcript-watcher.d.ts +26 -0
  271. package/dist/trajectory/transcript-watcher.js +33 -0
  272. package/dist/trajectory/transcript-watcher.js.map +1 -1
  273. package/dist/types/skill-artifact.d.ts +442 -0
  274. package/dist/types/skill-artifact.js +137 -0
  275. package/dist/types/skill-artifact.js.map +1 -0
  276. package/dist/types/task-run-read-model.d.ts +21 -0
  277. package/dist/types/task-run-read-model.js +2 -0
  278. package/dist/types/task-run-read-model.js.map +1 -0
  279. package/dist/types/task-run.d.ts +75 -0
  280. package/dist/types/task-run.js +2 -0
  281. package/dist/types/task-run.js.map +1 -0
  282. package/dist/util/redact-rpc-urls.d.ts +1 -1
  283. package/dist/util/redact-rpc-urls.js +57 -2
  284. package/dist/util/redact-rpc-urls.js.map +1 -1
  285. package/package.json +11 -8
  286. package/plugins/local-trace-distiller/.claude-plugin/plugin.json +9 -0
  287. package/plugins/local-trace-distiller/.codex-plugin/plugin.json +41 -0
  288. package/plugins/local-trace-distiller/.mcp.json +8 -0
  289. package/plugins/local-trace-distiller/README.md +27 -0
  290. package/plugins/local-trace-distiller/jinn.plugin.json +36 -0
  291. package/plugins/local-trace-distiller/skills/distill/SKILL.md +51 -0
  292. package/dist/api/peers.js.map +0 -1
  293. package/dist/dashboard/assets/index-BsrAAmvC.js +0 -171
  294. package/dist/dashboard/assets/index-DQOWJ2SF.css +0 -1
  295. /package/dist/{api/peers.d.ts → daemon/peer-sync.d.ts} +0 -0
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Unified MCP-server-script writer for the claude-mcp-prediction* impls.
3
+ *
4
+ * Both `claude-mcp-prediction` and `claude-mcp-prediction-apy` generate a
5
+ * wrapper `.mjs` that plain Node loads via `--mcp-config`. The wrapper imports
6
+ * `startMcpServer` from the venue's COMPILED `mcp-tools.js` sitting next to the
7
+ * caller and hands it the config path from argv[2].
8
+ *
9
+ * The only per-venue differences were the cosmetic header comment + usage
10
+ * string (the `serverLabel`), and the caller's own module URL used to resolve
11
+ * the sibling `mcp-tools.js`. Both are parameters here.
12
+ */
13
+ export interface WriteMcpServerScriptOptions {
14
+ /**
15
+ * The CALLING venue `index.ts`'s `import.meta.url`. Resolution of the sibling
16
+ * compiled `mcp-tools.js` is relative to THIS url — never this shared
17
+ * module's — so the wrapper loads the venue's own tools.
18
+ */
19
+ callerFileUrl: string;
20
+ /**
21
+ * Cosmetic label interpolated into the header comment + usage string
22
+ * (e.g. `jinn-prediction`, `jinn-apy-prediction`).
23
+ */
24
+ serverLabel: string;
25
+ }
26
+ /**
27
+ * Generate a wrapper script that spawns the venue's MCP server.
28
+ *
29
+ * Resolves the COMPILED `mcp-tools.js` path relative to `callerFileUrl`. The
30
+ * wrapper is spawned by plain Node (not tsx) via `--mcp-config`, so it must
31
+ * import a `.js` file. After `yarn build` the compiled artifact lives at
32
+ * `dist/.../mcp-tools.js`.
33
+ *
34
+ * - Production (running from dist/): callerFile is in /.../dist/... → sibling
35
+ * mcp-tools.js exists.
36
+ * - Dev/test (running source via tsx/vitest): callerFile is in /.../src/... →
37
+ * rewrite path into /.../dist/... .
38
+ */
39
+ export declare function writeMcpServerScript(outPath: string, opts: WriteMcpServerScriptOptions): void;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Unified MCP-server-script writer for the claude-mcp-prediction* impls.
3
+ *
4
+ * Both `claude-mcp-prediction` and `claude-mcp-prediction-apy` generate a
5
+ * wrapper `.mjs` that plain Node loads via `--mcp-config`. The wrapper imports
6
+ * `startMcpServer` from the venue's COMPILED `mcp-tools.js` sitting next to the
7
+ * caller and hands it the config path from argv[2].
8
+ *
9
+ * The only per-venue differences were the cosmetic header comment + usage
10
+ * string (the `serverLabel`), and the caller's own module URL used to resolve
11
+ * the sibling `mcp-tools.js`. Both are parameters here.
12
+ */
13
+ import { writeFileSync, existsSync, chmodSync } from 'node:fs';
14
+ import { join, dirname, basename } from 'node:path';
15
+ import { fileURLToPath } from 'node:url';
16
+ /**
17
+ * Generate a wrapper script that spawns the venue's MCP server.
18
+ *
19
+ * Resolves the COMPILED `mcp-tools.js` path relative to `callerFileUrl`. The
20
+ * wrapper is spawned by plain Node (not tsx) via `--mcp-config`, so it must
21
+ * import a `.js` file. After `yarn build` the compiled artifact lives at
22
+ * `dist/.../mcp-tools.js`.
23
+ *
24
+ * - Production (running from dist/): callerFile is in /.../dist/... → sibling
25
+ * mcp-tools.js exists.
26
+ * - Dev/test (running source via tsx/vitest): callerFile is in /.../src/... →
27
+ * rewrite path into /.../dist/... .
28
+ */
29
+ export function writeMcpServerScript(outPath, opts) {
30
+ const __filename = fileURLToPath(opts.callerFileUrl);
31
+ let mcpToolsPath = join(dirname(__filename), 'mcp-tools.js');
32
+ if (!existsSync(mcpToolsPath) && __filename.includes(`${'/'}src${'/'}`)) {
33
+ mcpToolsPath = __filename
34
+ .replace(`${'/'}src${'/'}`, `${'/'}dist${'/'}`)
35
+ .replace(/index\.(ts|js)$/, 'mcp-tools.js');
36
+ }
37
+ if (!existsSync(mcpToolsPath)) {
38
+ throw new Error(`E_DAEMON_MUST_RUN_FROM_DIST: ${mcpToolsPath} does not exist. ` +
39
+ `The ${opts.serverLabel} wrapper subprocess loads this compiled artifact. ` +
40
+ `Run \`yarn build\` before starting the daemon or isolation test.`);
41
+ }
42
+ const wrapperBasename = basename(outPath);
43
+ const script = `#!/usr/bin/env node
44
+ // Auto-generated ${opts.serverLabel} MCP wrapper — do not edit.
45
+ // Delegates to the compiled mcp-tools module; no business logic in the wrapper.
46
+ // Config is read from argv[2].
47
+ import { readFileSync } from 'node:fs';
48
+ import { startMcpServer } from ${JSON.stringify(mcpToolsPath)};
49
+
50
+ const configPath = process.argv[2];
51
+ if (!configPath) {
52
+ process.stderr.write('Usage: ${wrapperBasename} <config-file-path>\\n');
53
+ process.exit(1);
54
+ }
55
+
56
+ const config = JSON.parse(readFileSync(configPath, 'utf-8'));
57
+ await startMcpServer(config);
58
+ `.trim();
59
+ writeFileSync(outPath, script, { encoding: 'utf-8', mode: 0o600 });
60
+ chmodSync(outPath, 0o600);
61
+ }
62
+ //# sourceMappingURL=mcp-server-script.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server-script.js","sourceRoot":"","sources":["../../../../src/harnesses/impls/claude-mcp-shared/mcp-server-script.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAgBzC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe,EAAE,IAAiC;IACrF,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAErD,IAAI,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC,CAAC;IAC7D,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,GAAG,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC;QACxE,YAAY,GAAG,UAAU;aACtB,OAAO,CAAC,GAAG,GAAG,MAAM,GAAG,EAAE,EAAE,GAAG,GAAG,OAAO,GAAG,EAAE,CAAC;aAC9C,OAAO,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,gCAAgC,YAAY,mBAAmB;YAC7D,OAAO,IAAI,CAAC,WAAW,oDAAoD;YAC3E,kEAAkE,CACrE,CAAC;IACJ,CAAC;IAED,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG;oBACG,IAAI,CAAC,WAAW;;;;iCAIH,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;;;;iCAI5B,eAAe;;;;;;CAM/C,CAAC,IAAI,EAAE,CAAC;IAEP,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACnE,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Shared stdio MCP-server plumbing for the claude-mcp-prediction* impls.
3
+ *
4
+ * Both venues' `startMcpServer` build a venue publicClient + tool array, then
5
+ * register the tools on an `McpServer` over `StdioServerTransport` and keep the
6
+ * process alive until stdin closes. Only the venue-specific publicClient +
7
+ * tool-factory + submission field names differ; those stay per-venue. The
8
+ * register loop, transport connect, and stdin keepalive are unified here, along
9
+ * with the JSONL submission appender the onSubmit closure uses.
10
+ */
11
+ import type { z } from 'zod';
12
+ /** Minimal structural shape both venue tool-definition types satisfy. */
13
+ export interface StdioMcpTool {
14
+ name: string;
15
+ description: string;
16
+ schema: z.ZodObject<z.ZodRawShape>;
17
+ handler: (args: unknown) => Promise<{
18
+ content: {
19
+ type: 'text';
20
+ text: string;
21
+ }[];
22
+ }>;
23
+ }
24
+ export interface CreateStdioMcpServerOptions {
25
+ serverName: string;
26
+ version: string;
27
+ tools: StdioMcpTool[];
28
+ }
29
+ /**
30
+ * Append a submission record as a JSON line. The daemon tails this file across
31
+ * the process boundary to detect the submit-tool call; each record is stamped
32
+ * with a `ts`. This is the only IPC mechanism that survives the wrapper
33
+ * subprocess boundary.
34
+ */
35
+ export declare function appendSubmissionRecord(path: string, record: Record<string, unknown>): void;
36
+ /**
37
+ * Register the given tools on a fresh stdio `McpServer` and keep the process
38
+ * alive until stdin closes (Claude closes it at session end).
39
+ */
40
+ export declare function createStdioMcpServer(opts: CreateStdioMcpServerOptions): Promise<void>;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Shared stdio MCP-server plumbing for the claude-mcp-prediction* impls.
3
+ *
4
+ * Both venues' `startMcpServer` build a venue publicClient + tool array, then
5
+ * register the tools on an `McpServer` over `StdioServerTransport` and keep the
6
+ * process alive until stdin closes. Only the venue-specific publicClient +
7
+ * tool-factory + submission field names differ; those stay per-venue. The
8
+ * register loop, transport connect, and stdin keepalive are unified here, along
9
+ * with the JSONL submission appender the onSubmit closure uses.
10
+ */
11
+ import { appendFileSync } from 'node:fs';
12
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
13
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
14
+ /**
15
+ * Append a submission record as a JSON line. The daemon tails this file across
16
+ * the process boundary to detect the submit-tool call; each record is stamped
17
+ * with a `ts`. This is the only IPC mechanism that survives the wrapper
18
+ * subprocess boundary.
19
+ */
20
+ export function appendSubmissionRecord(path, record) {
21
+ appendFileSync(path, JSON.stringify({ ts: Date.now(), ...record }) + '\n', { encoding: 'utf-8' });
22
+ }
23
+ /**
24
+ * Register the given tools on a fresh stdio `McpServer` and keep the process
25
+ * alive until stdin closes (Claude closes it at session end).
26
+ */
27
+ export async function createStdioMcpServer(opts) {
28
+ const server = new McpServer({ name: opts.serverName, version: opts.version });
29
+ // Same cast-around-MCP-index-signature pattern as hyperliquid's startMcpServer.
30
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
+ const registerTool = server.tool.bind(server);
32
+ for (const tool of opts.tools) {
33
+ const shape = tool.schema.shape ?? {};
34
+ registerTool(tool.name, tool.description, shape, async (args) => tool.handler(args));
35
+ }
36
+ const transport = new StdioServerTransport();
37
+ await server.connect(transport);
38
+ // Keep alive until stdin closes (Claude closes it at session end).
39
+ await new Promise((resolve) => {
40
+ process.stdin.on('close', resolve);
41
+ process.stdin.on('end', resolve);
42
+ });
43
+ }
44
+ //# sourceMappingURL=mcp-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../../../../src/harnesses/impls/claude-mcp-shared/mcp-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAiBjF;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY,EAAE,MAA+B;IAClF,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;AACpG,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAAiC;IAC1E,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAE/E,gFAAgF;IAChF,8DAA8D;IAC9D,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAA6B,CAAC;IAE1E,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAI,IAAI,CAAC,MAAqC,CAAC,KAAK,IAAI,EAAE,CAAC;QACtE,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAChG,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,mEAAmE;IACnE,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QAClC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACnC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Shared LIVE-path scaffold for the claude-mcp-prediction* impls.
3
+ *
4
+ * Both `claude-mcp-prediction` and `claude-mcp-prediction-apy` run the same
5
+ * venue-agnostic middle in their `run()` live path:
6
+ *
7
+ * 1. mkdir `mcp/`.
8
+ * 2. Write an empty `submissions.jsonl` @ 0o600.
9
+ * 3. Write the wrapper `.mjs` + its JSON config @ 0o600.
10
+ * 4. Write `mcp-config.json` pointing Claude at the wrapper.
11
+ * 5. Tail the JSONL log to detect the submit-tool call (`isSubmitted`).
12
+ * 6. Spawn the single Claude session and return its result.
13
+ *
14
+ * The only per-venue pieces are threaded in as params: the wrapper basename,
15
+ * the mcp-server key, the SingleSessionConfig, the wrapper config builder, the
16
+ * script writer, and an `onRecord` that validates a JSONL line and fires the
17
+ * venue's submission side-effect. The test-mode short-circuit + `_finalize`
18
+ * stay per-venue.
19
+ */
20
+ import { type SingleSessionConfig, type SingleSessionResult } from './single-session-orchestrator.js';
21
+ export interface RunSingleSessionHarnessParams {
22
+ sessionId: string;
23
+ prompt: string;
24
+ workingDir: string;
25
+ /** Basename (no extension) for the wrapper `.mjs` + its `-config.json`. */
26
+ wrapperBasename: string;
27
+ /** Key under `mcpServers` in the generated `mcp-config.json`. */
28
+ mcpServerKey: string;
29
+ /** Orchestrator config (allowedTools / logTag / submissionToolName). */
30
+ sessionConfig: SingleSessionConfig;
31
+ /** Build the venue wrapper config; receives the resolved submission log path. */
32
+ buildWrapperConfig: (submissionLogPath: string) => Record<string, unknown>;
33
+ /** Write the venue wrapper script to the given path. */
34
+ writeScript: (outPath: string) => void;
35
+ /**
36
+ * Handle a JSONL record: validate it, fire the venue submission side-effect,
37
+ * and return true iff it was a valid submission (false otherwise).
38
+ */
39
+ onRecord: (record: unknown) => boolean;
40
+ }
41
+ export interface RunSingleSessionHarnessDeps {
42
+ claudePath: string;
43
+ claudeModel?: string;
44
+ abort: AbortSignal;
45
+ log: (event: {
46
+ level: 'info' | 'warn' | 'error';
47
+ msg: string;
48
+ data?: unknown;
49
+ }) => void;
50
+ sessionMaxMs?: number;
51
+ }
52
+ /**
53
+ * Run the venue-agnostic live-path middle and return the raw session result
54
+ * (transcriptPath / startedAt / endedAt) for the venue's `_finalize` to consume.
55
+ */
56
+ export declare function runSingleSessionHarness(params: RunSingleSessionHarnessParams, deps: RunSingleSessionHarnessDeps): Promise<SingleSessionResult>;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Shared LIVE-path scaffold for the claude-mcp-prediction* impls.
3
+ *
4
+ * Both `claude-mcp-prediction` and `claude-mcp-prediction-apy` run the same
5
+ * venue-agnostic middle in their `run()` live path:
6
+ *
7
+ * 1. mkdir `mcp/`.
8
+ * 2. Write an empty `submissions.jsonl` @ 0o600.
9
+ * 3. Write the wrapper `.mjs` + its JSON config @ 0o600.
10
+ * 4. Write `mcp-config.json` pointing Claude at the wrapper.
11
+ * 5. Tail the JSONL log to detect the submit-tool call (`isSubmitted`).
12
+ * 6. Spawn the single Claude session and return its result.
13
+ *
14
+ * The only per-venue pieces are threaded in as params: the wrapper basename,
15
+ * the mcp-server key, the SingleSessionConfig, the wrapper config builder, the
16
+ * script writer, and an `onRecord` that validates a JSONL line and fires the
17
+ * venue's submission side-effect. The test-mode short-circuit + `_finalize`
18
+ * stay per-venue.
19
+ */
20
+ import { writeFileSync, mkdirSync, readFileSync, chmodSync } from 'node:fs';
21
+ import { join } from 'node:path';
22
+ import { runSingleSession, } from './single-session-orchestrator.js';
23
+ /**
24
+ * Run the venue-agnostic live-path middle and return the raw session result
25
+ * (transcriptPath / startedAt / endedAt) for the venue's `_finalize` to consume.
26
+ */
27
+ export async function runSingleSessionHarness(params, deps) {
28
+ const mcpDir = join(params.workingDir, 'mcp');
29
+ mkdirSync(mcpDir, { recursive: true });
30
+ // Per-session submission log. The wrapper appends JSON lines here when the
31
+ // submit tool is invoked. We tail it to detect the submission.
32
+ const submissionLogPath = join(mcpDir, 'submissions.jsonl');
33
+ writeFileSync(submissionLogPath, '', { encoding: 'utf-8', mode: 0o600 });
34
+ chmodSync(submissionLogPath, 0o600);
35
+ // Write the wrapper script + its config.
36
+ const wrapperPath = join(mcpDir, `${params.wrapperBasename}.mjs`);
37
+ const wrapperConfigPath = join(mcpDir, `${params.wrapperBasename}-config.json`);
38
+ writeFileSync(wrapperConfigPath, JSON.stringify(params.buildWrapperConfig(submissionLogPath)), {
39
+ encoding: 'utf-8',
40
+ mode: 0o600,
41
+ });
42
+ chmodSync(wrapperConfigPath, 0o600);
43
+ params.writeScript(wrapperPath);
44
+ // MCP config file Claude reads via --mcp-config.
45
+ const mcpConfigPath = join(mcpDir, 'mcp-config.json');
46
+ writeFileSync(mcpConfigPath, JSON.stringify({
47
+ mcpServers: {
48
+ [params.mcpServerKey]: {
49
+ command: process.execPath,
50
+ args: [wrapperPath, wrapperConfigPath],
51
+ },
52
+ },
53
+ }, null, 2));
54
+ // isSubmitted reads the JSONL log; as soon as there's a valid line, we hand
55
+ // it to the venue's onRecord, which fires the submission side-effect.
56
+ const isSubmitted = () => {
57
+ try {
58
+ const contents = readFileSync(submissionLogPath, 'utf-8');
59
+ const lastLine = contents.trim().split('\n').pop() ?? '';
60
+ if (!lastLine)
61
+ return false;
62
+ return params.onRecord(JSON.parse(lastLine));
63
+ }
64
+ catch {
65
+ return false;
66
+ }
67
+ };
68
+ return runSingleSession(params.sessionId, params.prompt, params.sessionConfig, {
69
+ claudePath: deps.claudePath,
70
+ ...(deps.claudeModel ? { claudeModel: deps.claudeModel } : {}),
71
+ mcpConfigPath,
72
+ workingDir: params.workingDir,
73
+ abort: deps.abort,
74
+ log: deps.log,
75
+ isSubmitted,
76
+ ...(deps.sessionMaxMs !== undefined ? { sessionMaxMs: deps.sessionMaxMs } : {}),
77
+ });
78
+ }
79
+ //# sourceMappingURL=single-session-harness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-session-harness.js","sourceRoot":"","sources":["../../../../src/harnesses/impls/claude-mcp-shared/single-session-harness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAA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n, spawnSync } from 'node:child_process';
2
2
  import type { HarnessAdapter, TaskSessionInputs } from '../types.js';
3
3
  export interface CodexCodeHarnessAdapterConfig {
4
4
  codexPath?: string;
@@ -17,6 +17,7 @@ export interface CodexCodeHarnessAdapterConfig {
17
17
  };
18
18
  clientRoot?: string;
19
19
  _spawnFn?: typeof spawn;
20
+ _spawnSyncFn?: typeof spawnSync;
20
21
  _runSessionStartHook?: boolean;
21
22
  /**
22
23
  * Override the process-group kill for testing (#895, mirrors #883). Called
@@ -37,6 +38,7 @@ export declare class CodexCodeHarnessAdapter implements HarnessAdapter {
37
38
  private readonly corpusEnv;
38
39
  private readonly clientRoot;
39
40
  private readonly spawnFn;
41
+ private readonly spawnSyncFn;
40
42
  private readonly runSessionStartHook;
41
43
  private readonly killProcessGroup;
42
44
  constructor(config?: CodexCodeHarnessAdapterConfig);
@@ -6,6 +6,7 @@ import { fileURLToPath } from 'node:url';
6
6
  import { prepareCodexPluginWorkspace } from './codex-workspace.js';
7
7
  const DEFAULT_CODEX_MODEL = 'gpt-5.4-mini';
8
8
  const MACOS_CODEX_APP_BINARY = '/Applications/Codex.app/Contents/Resources/codex';
9
+ const SESSION_START_SHELL = '/bin/bash';
9
10
  const ENV_ALLOWLIST = [
10
11
  'PATH',
11
12
  'HOME',
@@ -80,7 +81,7 @@ function taskContextJson(inputs) {
80
81
  * SolverNet would require a code change in every adapter's prompt
81
82
  * builder.
82
83
  */
83
- function buildInitialPrompt(inputs) {
84
+ function buildInitialPrompt(inputs, sessionStartContext = '') {
84
85
  return [
85
86
  'You are executing a Jinn task.',
86
87
  'Complete the task described by the task payload below.',
@@ -96,6 +97,9 @@ function buildInitialPrompt(inputs) {
96
97
  `- goal.deadline = ${inputs.windowEndTs} (ms since epoch)`,
97
98
  `- msUntilDeadline = ${inputs.msUntilEndTs}`,
98
99
  `- mode = ${inputs.mode}`,
100
+ sessionStartContext.trim()
101
+ ? `\nSession start context:\n${sessionStartContext.trim()}`
102
+ : '',
99
103
  inputs.taskBody
100
104
  ? `\ngoal (full body):\n${JSON.stringify(inputs.taskBody, null, 2)}`
101
105
  : '',
@@ -106,6 +110,31 @@ function buildInitialPrompt(inputs) {
106
110
  function captureLogError(err) {
107
111
  return err instanceof Error ? err : new Error(String(err));
108
112
  }
113
+ function sessionStartContextFromHookStdout(stdout) {
114
+ for (const line of stdout.split(/\r?\n/).map((item) => item.trim()).filter(Boolean)) {
115
+ try {
116
+ const parsed = JSON.parse(line);
117
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
118
+ continue;
119
+ const hookSpecificOutput = parsed['hookSpecificOutput'];
120
+ if (!hookSpecificOutput || typeof hookSpecificOutput !== 'object' || Array.isArray(hookSpecificOutput)) {
121
+ continue;
122
+ }
123
+ const record = hookSpecificOutput;
124
+ if (record['hookEventName'] !== 'SessionStart')
125
+ continue;
126
+ const additionalContext = record['additionalContext'];
127
+ if (typeof additionalContext === 'string' && additionalContext.trim()) {
128
+ return additionalContext.trim();
129
+ }
130
+ }
131
+ catch {
132
+ // Codex runs hooks manually, so ignore non-JSON operational stdout. Hook
133
+ // failure is still fail-closed via the process exit status.
134
+ }
135
+ }
136
+ return '';
137
+ }
109
138
  export class CodexCodeHarnessAdapter {
110
139
  name = 'codex-code';
111
140
  allowsHarnessSelfModification = false;
@@ -117,6 +146,7 @@ export class CodexCodeHarnessAdapter {
117
146
  corpusEnv;
118
147
  clientRoot;
119
148
  spawnFn;
149
+ spawnSyncFn;
120
150
  runSessionStartHook;
121
151
  killProcessGroup;
122
152
  constructor(config = {}) {
@@ -128,6 +158,7 @@ export class CodexCodeHarnessAdapter {
128
158
  this.corpusEnv = config.corpusEnv;
129
159
  this.clientRoot = config.clientRoot ?? defaultClientRoot();
130
160
  this.spawnFn = config._spawnFn ?? spawn;
161
+ this.spawnSyncFn = config._spawnSyncFn ?? spawnSync;
131
162
  this.runSessionStartHook = config._runSessionStartHook ?? true;
132
163
  this.killProcessGroup =
133
164
  config._killProcessGroup ?? ((childPid, signal) => { process.kill(-childPid, signal); });
@@ -142,9 +173,9 @@ export class CodexCodeHarnessAdapter {
142
173
  * the positional-arg invocation used pre-0.133 is no longer supported.
143
174
  */
144
175
  async runTask(inputs, pluginRoot) {
145
- const prompt = buildInitialPrompt(inputs);
146
176
  const baseEnv = {
147
177
  IMPL_STATE_DIR: inputs.implStateDir,
178
+ JINN_HARNESS_MODE: inputs.mode ?? 'train',
148
179
  WORKING_DIR: inputs.workingDir,
149
180
  JINN_WORKING_DIR: inputs.workingDir,
150
181
  PLUGIN_ROOT: pluginRoot,
@@ -169,6 +200,7 @@ export class CodexCodeHarnessAdapter {
169
200
  ...(inputs.adapterEnv ?? {}),
170
201
  };
171
202
  const env = buildAgentEnv(baseEnv);
203
+ let sessionStartContext = '';
172
204
  if (this.runSessionStartHook) {
173
205
  // Sync spawnSync is acceptable here (#778, #398): this runs once per
174
206
  // claimed task during the synchronous `runTask` setup phase before the
@@ -178,15 +210,18 @@ export class CodexCodeHarnessAdapter {
178
210
  // outer task-execution timeout. The wedge fixed in #778 was the
179
211
  // post-execution `git diff --binary` in harvest.ts, which ran on every
180
212
  // delivery on the main thread with no upstream timeout.
181
- const hook = spawnSync('bash', [join(pluginRoot, 'hooks', 'session-start')], {
213
+ const hook = this.spawnSyncFn(SESSION_START_SHELL, [join(pluginRoot, 'hooks', 'session-start')], {
182
214
  cwd: inputs.workingDir,
183
215
  env,
184
216
  encoding: 'utf8',
185
217
  });
186
218
  if (hook.status !== 0) {
187
- throw new Error(`codex-code adapter: session-start hook failed: ${(hook.stderr || hook.stdout || '').slice(0, 500)}`);
219
+ const detail = hook.stderr || hook.stdout || hook.error?.message || '';
220
+ throw new Error(`codex-code adapter: session-start hook failed: ${detail.slice(0, 500)}`);
188
221
  }
222
+ sessionStartContext = sessionStartContextFromHookStdout(hook.stdout?.toString() ?? '');
189
223
  }
224
+ const prompt = buildInitialPrompt(inputs, sessionStartContext);
190
225
  const prepared = prepareCodexPluginWorkspace({
191
226
  workingDir: inputs.workingDir,
192
227
  pluginRoots: [pluginRoot, ...(inputs.pluginRoots ?? [])],
@@ -1 +1 @@
1
- {"version":3,"file":"codex-code.js","sourceRoot":"","sources":["../../../../../src/harnesses/impls/learner/adapters/codex-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAwC,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AA8BnE,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAC3C,MAAM,sBAAsB,GAAG,kDAAkD,CAAC;AAElF,MAAM,aAAa,GAAG;IACpB,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,QAAQ;IACR,iBAAiB;IACjB,eAAe;IACf,gBAAgB;IAChB,WAAW;IACX,cAAc;IACd,mBAAmB;IACnB,gBAAgB;IAChB,YAAY;IACZ,iBAAiB;CAClB,CAAC;AAEF,SAAS,iBAAiB;IACxB,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,OAAO,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAA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,CAAC,CAAC,6CAA6C,CAAC,CAAC;gBAC3D,CAAC;YACH,CAAC,CAAC,CAAC;YACH,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE;gBACrC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACnB,MAAM,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;YACzB,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;gBAChC,eAAe,CAAC,GAAG,EAAE;oBACnB,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;wBACf,cAAc,EAAE,CAAC;oBACnB,CAAC;yBAAM,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;wBAChC,cAAc,EAAE,CAAC;oBACnB,CAAC;yBAAM,CAAC;wBACN,MAAM,CACJ,IAAI,KAAK,CACP,8CAA8C,IAAI,WAAW,MAAM,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAC/F,CACF,CAAC;oBACJ,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;gBACxB,eAAe,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
1
+ {"version":3,"file":"codex-code.js","sourceRoot":"","sources":["../../../../../src/harnesses/impls/learner/adapters/codex-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAwC,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,EAA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B,CAAC,CAAC;4BAC1D,OAAO;wBACT,CAAC;oBACH,CAAC;oBAAC,MAAM,CAAC,CAAC,6CAA6C,CAAC,CAAC;gBAC3D,CAAC;YACH,CAAC,CAAC,CAAC;YACH,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE;gBACrC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACnB,MAAM,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;YACzB,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;gBAChC,eAAe,CAAC,GAAG,EAAE;oBACnB,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;wBACf,cAAc,EAAE,CAAC;oBACnB,CAAC;yBAAM,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;wBAChC,cAAc,EAAE,CAAC;oBACnB,CAAC;yBAAM,CAAC;wBACN,MAAM,CACJ,IAAI,KAAK,CACP,8CAA8C,IAAI,WAAW,MAAM,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAC/F,CACF,CAAC;oBACJ,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;gBACxB,eAAe,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -19,25 +19,15 @@
19
19
  * - Original task spec is at task.spec (PortfolioV0Spec) — no IPFS fetch needed
20
20
  * - task.restorationRequestId carries the on-chain request ID
21
21
  */
22
- import type { Harness, HarnessContext, Solution, ReadyStatus } from '../../types.js';
23
- import type { Task } from '../../../types/task.js';
22
+ import type { HarnessContext, Solution } from '../../types.js';
23
+ import { EvaluatorHarness, type EvaluatorHarnessShape } from '../_evaluator-base.js';
24
24
  import type { PortfolioV0EvaluatorConfig } from './types.js';
25
- export declare class PortfolioV0Evaluator implements Harness {
25
+ export declare class PortfolioV0Evaluator extends EvaluatorHarness {
26
26
  readonly name = "portfolio-v0-evaluator";
27
- readonly version = "1.0.0";
27
+ protected readonly shape: EvaluatorHarnessShape;
28
28
  private readonly config;
29
29
  constructor(config?: PortfolioV0EvaluatorConfig);
30
- supports(ctx: {
31
- solverType: string;
32
- role?: 'restoration' | 'evaluation';
33
- }): boolean;
34
- isReady(): Promise<ReadyStatus>;
35
- canAttempt(task: Task): Promise<{
36
- ok: true;
37
- } | {
38
- ok: false;
39
- reason: string;
40
- }>;
30
+ protected get stub(): boolean;
41
31
  run(ctx: HarnessContext): Promise<Solution>;
42
32
  private _buildOutput;
43
33
  }
@@ -24,7 +24,7 @@ import { createHash } from 'node:crypto';
24
24
  import { join } from 'node:path';
25
25
  import { keccak256 } from 'viem';
26
26
  import { privateKeyToAccount } from 'viem/accounts';
27
- import { REQUIRES_LIVE_DAEMON_READINESS } from '../../types.js';
27
+ import { EvaluatorHarness } from '../_evaluator-base.js';
28
28
  import { HyperliquidClient, HL_MAINNET_BASE_URL, HL_TESTNET_BASE_URL } from '../../../venues/hyperliquid/client.js';
29
29
  import { bracketGridPoints } from '../../../venues/hyperliquid/grid.js';
30
30
  import { canonicalJson } from '../../engine/canonical-json.js';
@@ -168,41 +168,22 @@ function _writeVerdictArtifact(workingDir, verdictManifest) {
168
168
  writeFileSync(verdictPath, JSON.stringify(verdictManifest, null, 2), 'utf-8');
169
169
  }
170
170
  // ── PortfolioV0Evaluator ──────────────────────────────────────────────────────
171
- export class PortfolioV0Evaluator {
171
+ export class PortfolioV0Evaluator extends EvaluatorHarness {
172
172
  name = 'portfolio-v0-evaluator';
173
- version = '1.0.0';
173
+ shape = {
174
+ solverType: 'portfolio.v0',
175
+ requiresRestorationRequestId: true,
176
+ };
174
177
  config;
175
178
  constructor(config = {}) {
179
+ super();
176
180
  this.config = config;
177
181
  }
178
- supports(ctx) {
179
- return ctx.solverType === 'portfolio.v0' && ctx.role === 'evaluation';
180
- }
181
- async isReady() {
182
- if (this.config.stub)
183
- return { ...REQUIRES_LIVE_DAEMON_READINESS };
184
- return { ready: true };
185
- }
186
- async canAttempt(task) {
187
- if (task.solverType !== 'portfolio.v0') {
188
- return { ok: false, reason: 'solverType is not portfolio.v0' };
189
- }
190
- if (task.role !== 'evaluation') {
191
- return { ok: false, reason: 'Task.role is not evaluation' };
192
- }
193
- if (!task.restorationRequestId) {
194
- return { ok: false, reason: 'restorationRequestId is required' };
195
- }
196
- const restorationResult = task.context?.['restorationResult'];
197
- if (typeof restorationResult !== 'string') {
198
- return { ok: false, reason: 'context.restorationResult (manifest JSON) is required' };
199
- }
200
- return { ok: true };
182
+ get stub() {
183
+ return Boolean(this.config.stub);
201
184
  }
202
185
  async run(ctx) {
203
- if (this.config.stub) {
204
- throw new Error('portfolio-v0-evaluator: stub registry cannot run evaluation (requires live daemon)');
205
- }
186
+ this.assertLive();
206
187
  const { task: task, log } = ctx;
207
188
  // ── Step 1: Parse harness's SignedEnvelope from inlined context ─────────
208
189
  // The envelope JSON is inlined at context.restorationResult.