@jinn-network/client 0.1.6 → 0.1.7-canary.0a586ca9

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 (434) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +67 -1
  3. package/deployments/deployment-jinn-mvi-l1-sepolia-fast.json +23 -4
  4. package/deployments/deployment-jinn-mvi-l1-sepolia.json +23 -4
  5. package/deployments/deployment-jinn-mvi-l2-baseSepolia.json +5 -4
  6. package/dist/adapters/mech/adapter.d.ts +57 -2
  7. package/dist/adapters/mech/adapter.js +366 -63
  8. package/dist/adapters/mech/adapter.js.map +1 -1
  9. package/dist/adapters/mech/contracts.d.ts +17 -4
  10. package/dist/adapters/mech/contracts.js +19 -4
  11. package/dist/adapters/mech/contracts.js.map +1 -1
  12. package/dist/adapters/mech/safe-revert.d.ts +20 -0
  13. package/dist/adapters/mech/safe-revert.js +12 -4
  14. package/dist/adapters/mech/safe-revert.js.map +1 -1
  15. package/dist/adapters/mech/safe.d.ts +6 -2
  16. package/dist/adapters/mech/safe.js +32 -11
  17. package/dist/adapters/mech/safe.js.map +1 -1
  18. package/dist/adapters/mech/types.d.ts +6 -1
  19. package/dist/adapters/mech/types.js.map +1 -1
  20. package/dist/adapters/mech/verdict-code.d.ts +1 -0
  21. package/dist/adapters/mech/verdict-code.js +18 -0
  22. package/dist/adapters/mech/verdict-code.js.map +1 -1
  23. package/dist/agent/operator-claude.js +8 -0
  24. package/dist/agent/operator-claude.js.map +1 -1
  25. package/dist/api/activity-events-endpoint.d.ts +14 -0
  26. package/dist/api/activity-events-endpoint.js +59 -0
  27. package/dist/api/activity-events-endpoint.js.map +1 -0
  28. package/dist/api/admin-endpoint.d.ts +15 -3
  29. package/dist/api/admin-endpoint.js +24 -2
  30. package/dist/api/admin-endpoint.js.map +1 -1
  31. package/dist/api/bootstrap-endpoint.d.ts +1 -2
  32. package/dist/api/bootstrap-endpoint.js +85 -18
  33. package/dist/api/bootstrap-endpoint.js.map +1 -1
  34. package/dist/api/codex-doctor-endpoint.d.ts +90 -0
  35. package/dist/api/codex-doctor-endpoint.js +296 -0
  36. package/dist/api/codex-doctor-endpoint.js.map +1 -0
  37. package/dist/api/discovery-endpoint.d.ts +1 -0
  38. package/dist/api/discovery-endpoint.js +26 -0
  39. package/dist/api/discovery-endpoint.js.map +1 -1
  40. package/dist/api/fleet-build.d.ts +1 -0
  41. package/dist/api/fleet-build.js +2 -1
  42. package/dist/api/fleet-build.js.map +1 -1
  43. package/dist/api/gather-status.d.ts +37 -0
  44. package/dist/api/gather-status.js +572 -19
  45. package/dist/api/gather-status.js.map +1 -1
  46. package/dist/api/hermes-doctor-endpoint.d.ts +128 -3
  47. package/dist/api/hermes-doctor-endpoint.js +265 -22
  48. package/dist/api/hermes-doctor-endpoint.js.map +1 -1
  49. package/dist/api/launcher-status.d.ts +24 -17
  50. package/dist/api/launcher-status.js +13 -11
  51. package/dist/api/launcher-status.js.map +1 -1
  52. package/dist/api/launcher-tasks.d.ts +1 -1
  53. package/dist/api/launcher-tasks.js +12 -8
  54. package/dist/api/launcher-tasks.js.map +1 -1
  55. package/dist/api/operator-artifacts-endpoint.js +73 -6
  56. package/dist/api/operator-artifacts-endpoint.js.map +1 -1
  57. package/dist/api/portfolio-v0-build.d.ts +10 -0
  58. package/dist/api/portfolio-v0-build.js +24 -5
  59. package/dist/api/portfolio-v0-build.js.map +1 -1
  60. package/dist/api/prediction-v1-build.d.ts +10 -0
  61. package/dist/api/prediction-v1-build.js +7 -1
  62. package/dist/api/prediction-v1-build.js.map +1 -1
  63. package/dist/api/server.d.ts +31 -1
  64. package/dist/api/server.js +95 -2
  65. package/dist/api/server.js.map +1 -1
  66. package/dist/api/setup-endpoints.d.ts +7 -0
  67. package/dist/api/setup-endpoints.js +67 -135
  68. package/dist/api/setup-endpoints.js.map +1 -1
  69. package/dist/api/setup-retry-endpoint.d.ts +19 -0
  70. package/dist/api/setup-retry-endpoint.js +32 -0
  71. package/dist/api/setup-retry-endpoint.js.map +1 -0
  72. package/dist/api/solvernets-endpoints.d.ts +8 -0
  73. package/dist/api/solvernets-endpoints.js +100 -105
  74. package/dist/api/solvernets-endpoints.js.map +1 -1
  75. package/dist/api/status-build.d.ts +167 -2
  76. package/dist/api/status-build.js +118 -27
  77. package/dist/api/status-build.js.map +1 -1
  78. package/dist/api/status-harness-rollup.d.ts +35 -0
  79. package/dist/api/status-harness-rollup.js +45 -0
  80. package/dist/api/status-harness-rollup.js.map +1 -0
  81. package/dist/api/task-run-routing.d.ts +7 -0
  82. package/dist/api/task-run-routing.js +12 -0
  83. package/dist/api/task-run-routing.js.map +1 -0
  84. package/dist/api/task-runs-build.d.ts +21 -0
  85. package/dist/api/task-runs-build.js +14 -1
  86. package/dist/api/task-runs-build.js.map +1 -1
  87. package/dist/build-info.json +4 -4
  88. package/dist/build-meta.json +1 -1
  89. package/dist/captures/live-publisher.js +24 -4
  90. package/dist/captures/live-publisher.js.map +1 -1
  91. package/dist/captures/publish.d.ts +1 -1
  92. package/dist/chain-read-errors.d.ts +22 -0
  93. package/dist/chain-read-errors.js +41 -1
  94. package/dist/chain-read-errors.js.map +1 -1
  95. package/dist/cli/commands/auth.js +1 -1
  96. package/dist/cli/commands/auth.js.map +1 -1
  97. package/dist/cli/commands/codedigest-revert-check.d.ts +33 -0
  98. package/dist/cli/commands/codedigest-revert-check.js +249 -0
  99. package/dist/cli/commands/codedigest-revert-check.js.map +1 -0
  100. package/dist/cli/commands/create.js +3 -2
  101. package/dist/cli/commands/create.js.map +1 -1
  102. package/dist/cli/commands/doctor.d.ts +2 -0
  103. package/dist/cli/commands/doctor.js +2 -0
  104. package/dist/cli/commands/doctor.js.map +1 -1
  105. package/dist/cli/commands/rewards.js +11 -7
  106. package/dist/cli/commands/rewards.js.map +1 -1
  107. package/dist/cli/commands/solver-nets.d.ts +1 -0
  108. package/dist/cli/commands/solver-nets.js +179 -16
  109. package/dist/cli/commands/solver-nets.js.map +1 -1
  110. package/dist/cli/commands/solver-plugins-block.d.ts +33 -0
  111. package/dist/cli/commands/solver-plugins-block.js +118 -0
  112. package/dist/cli/commands/solver-plugins-block.js.map +1 -0
  113. package/dist/cli/commands/solver-plugins-feedback.d.ts +72 -0
  114. package/dist/cli/commands/solver-plugins-feedback.js +262 -0
  115. package/dist/cli/commands/solver-plugins-feedback.js.map +1 -0
  116. package/dist/cli/commands/solver-plugins-read.d.ts +54 -0
  117. package/dist/cli/commands/solver-plugins-read.js +259 -0
  118. package/dist/cli/commands/solver-plugins-read.js.map +1 -0
  119. package/dist/cli/commands/solver-plugins.d.ts +35 -0
  120. package/dist/cli/commands/solver-plugins.js +399 -2
  121. package/dist/cli/commands/solver-plugins.js.map +1 -1
  122. package/dist/cli/commands/status.js +1 -1
  123. package/dist/cli/commands/status.js.map +1 -1
  124. package/dist/cli/commands/tasks.js +101 -11
  125. package/dist/cli/commands/tasks.js.map +1 -1
  126. package/dist/cli/commands/update.d.ts +10 -0
  127. package/dist/cli/commands/update.js +36 -0
  128. package/dist/cli/commands/update.js.map +1 -1
  129. package/dist/cli/index.js +2 -0
  130. package/dist/cli/index.js.map +1 -1
  131. package/dist/cli/introspection-context.js +5 -0
  132. package/dist/cli/introspection-context.js.map +1 -1
  133. package/dist/cli/task-native-readiness.d.ts +10 -1
  134. package/dist/cli/task-native-readiness.js +30 -6
  135. package/dist/cli/task-native-readiness.js.map +1 -1
  136. package/dist/config.d.ts +287 -235
  137. package/dist/config.js +318 -114
  138. package/dist/config.js.map +1 -1
  139. package/dist/daemon/checkpoint-loop.d.ts +48 -0
  140. package/dist/daemon/checkpoint-loop.js +76 -0
  141. package/dist/daemon/checkpoint-loop.js.map +1 -0
  142. package/dist/daemon/creator.d.ts +1 -1
  143. package/dist/daemon/creator.js +20 -3
  144. package/dist/daemon/creator.js.map +1 -1
  145. package/dist/daemon/daemon.d.ts +22 -0
  146. package/dist/daemon/daemon.js +174 -31
  147. package/dist/daemon/daemon.js.map +1 -1
  148. package/dist/daemon/eviction-loop.d.ts +40 -0
  149. package/dist/daemon/eviction-loop.js +67 -0
  150. package/dist/daemon/eviction-loop.js.map +1 -0
  151. package/dist/daemon/gate-logger.d.ts +9 -0
  152. package/dist/daemon/gate-logger.js +2 -0
  153. package/dist/daemon/gate-logger.js.map +1 -0
  154. package/dist/daemon/jinn-claim-loop-wiring.d.ts +33 -0
  155. package/dist/daemon/jinn-claim-loop-wiring.js +40 -0
  156. package/dist/daemon/jinn-claim-loop-wiring.js.map +1 -0
  157. package/dist/daemon/jinn-claim-loop.d.ts +24 -17
  158. package/dist/daemon/jinn-claim-loop.js +77 -23
  159. package/dist/daemon/jinn-claim-loop.js.map +1 -1
  160. package/dist/daemon/readiness-gate.d.ts +1 -4
  161. package/dist/daemon/readiness-gate.js.map +1 -1
  162. package/dist/daemon/skip-log-dedup.d.ts +69 -0
  163. package/dist/daemon/skip-log-dedup.js +106 -0
  164. package/dist/daemon/skip-log-dedup.js.map +1 -0
  165. package/dist/daemon/spend-cap-gate.d.ts +40 -0
  166. package/dist/daemon/spend-cap-gate.js +46 -0
  167. package/dist/daemon/spend-cap-gate.js.map +1 -0
  168. package/dist/dashboard/assets/index-BNs_ewI6.js +345 -0
  169. package/dist/dashboard/assets/index-C4huIsUW.css +32 -0
  170. package/dist/dashboard/index.html +2 -2
  171. package/dist/discovery/factory.d.ts +17 -5
  172. package/dist/discovery/factory.js +46 -18
  173. package/dist/discovery/factory.js.map +1 -1
  174. package/dist/discovery/http.js +469 -3
  175. package/dist/discovery/http.js.map +1 -1
  176. package/dist/discovery/onchain.d.ts +5 -0
  177. package/dist/discovery/onchain.js +448 -18
  178. package/dist/discovery/onchain.js.map +1 -1
  179. package/dist/discovery/types.d.ts +174 -1
  180. package/dist/discovery/types.js +8 -10
  181. package/dist/discovery/types.js.map +1 -1
  182. package/dist/discovery/with-fallback.d.ts +7 -0
  183. package/dist/discovery/with-fallback.js +37 -0
  184. package/dist/discovery/with-fallback.js.map +1 -1
  185. package/dist/earning/bootstrap.d.ts +100 -4
  186. package/dist/earning/bootstrap.js +239 -76
  187. package/dist/earning/bootstrap.js.map +1 -1
  188. package/dist/earning/contracts.d.ts +14 -0
  189. package/dist/earning/contracts.js +17 -5
  190. package/dist/earning/contracts.js.map +1 -1
  191. package/dist/earning/funding-plan.js +27 -18
  192. package/dist/earning/funding-plan.js.map +1 -1
  193. package/dist/earning/jinn-rewards.d.ts +46 -0
  194. package/dist/earning/jinn-rewards.js +32 -0
  195. package/dist/earning/jinn-rewards.js.map +1 -1
  196. package/dist/earning/safe-adapter.d.ts +2 -0
  197. package/dist/earning/safe-adapter.js +37 -11
  198. package/dist/earning/safe-adapter.js.map +1 -1
  199. package/dist/earning/store.d.ts +8 -0
  200. package/dist/earning/store.js.map +1 -1
  201. package/dist/earning/testnet-setup-migration.d.ts +12 -0
  202. package/dist/earning/testnet-setup-migration.js +27 -1
  203. package/dist/earning/testnet-setup-migration.js.map +1 -1
  204. package/dist/earning/types.d.ts +21 -6
  205. package/dist/earning/viem-clients.d.ts +11 -4
  206. package/dist/earning/viem-clients.js +14 -5
  207. package/dist/earning/viem-clients.js.map +1 -1
  208. package/dist/erc8004/identity.d.ts +19 -3
  209. package/dist/erc8004/identity.js +21 -6
  210. package/dist/erc8004/identity.js.map +1 -1
  211. package/dist/erc8004/index.d.ts +1 -1
  212. package/dist/erc8004/index.js.map +1 -1
  213. package/dist/erc8004/reputation.d.ts +8 -0
  214. package/dist/erc8004/reputation.js +22 -3
  215. package/dist/erc8004/reputation.js.map +1 -1
  216. package/dist/events/types.d.ts +2 -2
  217. package/dist/harnesses/cost-estimates.d.ts +124 -0
  218. package/dist/harnesses/cost-estimates.js +265 -0
  219. package/dist/harnesses/cost-estimates.js.map +1 -0
  220. package/dist/harnesses/engine/engine.d.ts +78 -0
  221. package/dist/harnesses/engine/engine.js +153 -11
  222. package/dist/harnesses/engine/engine.js.map +1 -1
  223. package/dist/harnesses/engine/persistence.d.ts +51 -1
  224. package/dist/harnesses/engine/persistence.js +118 -5
  225. package/dist/harnesses/engine/persistence.js.map +1 -1
  226. package/dist/harnesses/engine/work-dir-reaper.d.ts +65 -0
  227. package/dist/harnesses/engine/work-dir-reaper.js +100 -0
  228. package/dist/harnesses/engine/work-dir-reaper.js.map +1 -0
  229. package/dist/harnesses/impls/hermes-agent/adapter.js +40 -0
  230. package/dist/harnesses/impls/hermes-agent/adapter.js.map +1 -1
  231. package/dist/harnesses/impls/hermes-agent/bootstrap.d.ts +20 -0
  232. package/dist/harnesses/impls/hermes-agent/bootstrap.js +44 -8
  233. package/dist/harnesses/impls/hermes-agent/bootstrap.js.map +1 -1
  234. package/dist/harnesses/impls/hermes-agent/config-builder.d.ts +1 -1
  235. package/dist/harnesses/impls/hermes-agent/config-builder.js +4 -2
  236. package/dist/harnesses/impls/hermes-agent/config-builder.js.map +1 -1
  237. package/dist/harnesses/impls/hermes-agent/harness.d.ts +59 -1
  238. package/dist/harnesses/impls/hermes-agent/harness.js +104 -0
  239. package/dist/harnesses/impls/hermes-agent/harness.js.map +1 -1
  240. package/dist/harnesses/impls/hermes-agent/prompt.d.ts +6 -6
  241. package/dist/harnesses/impls/hermes-agent/prompt.js +6 -6
  242. package/dist/harnesses/impls/index.d.ts +7 -0
  243. package/dist/harnesses/impls/index.js +16 -1
  244. package/dist/harnesses/impls/index.js.map +1 -1
  245. package/dist/harnesses/impls/learner/adapters/codex-code.d.ts +9 -0
  246. package/dist/harnesses/impls/learner/adapters/codex-code.js +30 -8
  247. package/dist/harnesses/impls/learner/adapters/codex-code.js.map +1 -1
  248. package/dist/harnesses/impls/learner/harness.d.ts +47 -4
  249. package/dist/harnesses/impls/learner/harness.js +105 -2
  250. package/dist/harnesses/impls/learner/harness.js.map +1 -1
  251. package/dist/harnesses/impls/learner/harvest.d.ts +1 -1
  252. package/dist/harnesses/impls/learner/harvest.js +23 -5
  253. package/dist/harnesses/impls/learner/harvest.js.map +1 -1
  254. package/dist/harnesses/impls/learner/plugin-path.d.ts +0 -13
  255. package/dist/harnesses/impls/learner/plugin-path.js +35 -15
  256. package/dist/harnesses/impls/learner/plugin-path.js.map +1 -1
  257. package/dist/harnesses/impls/learner/restoration-patch.d.ts +2 -2
  258. package/dist/harnesses/impls/learner/restoration-patch.js +25 -6
  259. package/dist/harnesses/impls/learner/restoration-patch.js.map +1 -1
  260. package/dist/harnesses/impls/learner/types.d.ts +11 -0
  261. package/dist/harnesses/impls/stub.d.ts +58 -0
  262. package/dist/harnesses/impls/stub.js +89 -0
  263. package/dist/harnesses/impls/stub.js.map +1 -0
  264. package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.d.ts +69 -50
  265. package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js +199 -94
  266. package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js.map +1 -1
  267. package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.d.ts +12 -1
  268. package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.js +121 -7
  269. package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.js.map +1 -1
  270. package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.d.ts +88 -4
  271. package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js +143 -22
  272. package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js.map +1 -1
  273. package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.d.ts +6 -0
  274. package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.js +1 -1
  275. package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.js.map +1 -1
  276. package/dist/harnesses/readiness-registry.d.ts +7 -0
  277. package/dist/harnesses/readiness-registry.js +18 -1
  278. package/dist/harnesses/readiness-registry.js.map +1 -1
  279. package/dist/learner/revert-decision.d.ts +59 -0
  280. package/dist/learner/revert-decision.js +53 -0
  281. package/dist/learner/revert-decision.js.map +1 -0
  282. package/dist/learner/revert-stats.d.ts +24 -0
  283. package/dist/learner/revert-stats.js +44 -0
  284. package/dist/learner/revert-stats.js.map +1 -0
  285. package/dist/main.js +470 -142
  286. package/dist/main.js.map +1 -1
  287. package/dist/mcp/get-codedigest-reward.d.ts +13 -0
  288. package/dist/mcp/get-codedigest-reward.js +23 -0
  289. package/dist/mcp/get-codedigest-reward.js.map +1 -0
  290. package/dist/mcp/server.js +23 -0
  291. package/dist/mcp/server.js.map +1 -1
  292. package/dist/observability/emit-event.d.ts +3 -2
  293. package/dist/observability/emit-event.js +22 -1
  294. package/dist/observability/emit-event.js.map +1 -1
  295. package/dist/operator-errors.d.ts +7 -0
  296. package/dist/operator-errors.js +13 -1
  297. package/dist/operator-errors.js.map +1 -1
  298. package/dist/plugins/learner/.claude-plugin/plugin.json +9 -0
  299. package/dist/plugins/learner/.codex-plugin/plugin.json +39 -0
  300. package/dist/plugins/learner/AGENTS.md +40 -0
  301. package/dist/plugins/learner/CLAUDE.md +33 -0
  302. package/dist/plugins/learner/README.md +59 -0
  303. package/dist/plugins/learner/hooks/hooks.json +16 -0
  304. package/dist/plugins/learner/hooks/session-start +38 -0
  305. package/dist/plugins/learner/skills/learn/SKILL.md +412 -0
  306. package/dist/plugins/learner/skills/learn/analyst-prompt.md +68 -0
  307. package/dist/plugins/learner/skills/learn/consolidator-prompt.md +111 -0
  308. package/dist/plugins/learner/skills/learn/explorer-prompt.md +53 -0
  309. package/dist/plugins/learner/skills/learn/planner-prompt.md +87 -0
  310. package/dist/plugins/learner/skills/learn/promoter-prompt.md +184 -0
  311. package/dist/plugins/learner/skills/learn/step-worker-prompt.md +47 -0
  312. package/dist/plugins/learner/skills/learn/strategist-prompt.md +85 -0
  313. package/dist/preflight/pidfile-liveness.d.ts +44 -0
  314. package/dist/preflight/pidfile-liveness.js +103 -0
  315. package/dist/preflight/pidfile-liveness.js.map +1 -0
  316. package/dist/preflight/rpc-network.d.ts +40 -0
  317. package/dist/preflight/rpc-network.js +67 -1
  318. package/dist/preflight/rpc-network.js.map +1 -1
  319. package/dist/restart-daemon.d.ts +90 -0
  320. package/dist/restart-daemon.js +95 -0
  321. package/dist/restart-daemon.js.map +1 -0
  322. package/dist/rpc/transport.d.ts +109 -0
  323. package/dist/rpc/transport.js +220 -0
  324. package/dist/rpc/transport.js.map +1 -0
  325. package/dist/scripts/donation-consumption-acceptance.js +7 -28
  326. package/dist/scripts/donation-consumption-acceptance.js.map +1 -1
  327. package/dist/scripts/swe-rebench-v2-pytest-missing.json +16 -0
  328. package/dist/setup/halt-mode.d.ts +14 -0
  329. package/dist/setup/halt-mode.js +17 -0
  330. package/dist/setup/halt-mode.js.map +1 -0
  331. package/dist/solver-nets/prediction-operator-ux.d.ts +1 -2
  332. package/dist/solver-nets/prediction-operator-ux.js +90 -47
  333. package/dist/solver-nets/prediction-operator-ux.js.map +1 -1
  334. package/dist/solver-nets/registry.d.ts +20 -1
  335. package/dist/solver-nets/registry.js +38 -25
  336. package/dist/solver-nets/registry.js.map +1 -1
  337. package/dist/solver-types/_swe-rebench-v2-pool-cache.d.ts +58 -0
  338. package/dist/solver-types/_swe-rebench-v2-pool-cache.js +87 -0
  339. package/dist/solver-types/_swe-rebench-v2-pool-cache.js.map +1 -0
  340. package/dist/solver-types/_swe-rebench-v2-pool.d.ts +9 -2
  341. package/dist/solver-types/_swe-rebench-v2-pool.js +15 -20
  342. package/dist/solver-types/_swe-rebench-v2-pool.js.map +1 -1
  343. package/dist/solver-types/_swe-rebench-v2-state.d.ts +15 -0
  344. package/dist/solver-types/_swe-rebench-v2-state.js +19 -0
  345. package/dist/solver-types/_swe-rebench-v2-state.js.map +1 -1
  346. package/dist/solver-types/_swe-rebench-v2-substrate.d.ts +1 -0
  347. package/dist/solver-types/_swe-rebench-v2-substrate.js +10 -0
  348. package/dist/solver-types/_swe-rebench-v2-substrate.js.map +1 -1
  349. package/dist/solver-types/_swe-rebench-v2-validated-pool.d.ts +145 -2
  350. package/dist/solver-types/_swe-rebench-v2-validated-pool.js +482 -44
  351. package/dist/solver-types/_swe-rebench-v2-validated-pool.js.map +1 -1
  352. package/dist/solver-types/swe-rebench-v2-auto.d.ts +38 -14
  353. package/dist/solver-types/swe-rebench-v2-auto.js +87 -28
  354. package/dist/solver-types/swe-rebench-v2-auto.js.map +1 -1
  355. package/dist/solver-types/swe-rebench-v2.d.ts +19 -2
  356. package/dist/solver-types/swe-rebench-v2.js +351 -96
  357. package/dist/solver-types/swe-rebench-v2.js.map +1 -1
  358. package/dist/solvernets/daemon-init.d.ts +10 -2
  359. package/dist/solvernets/daemon-init.js +22 -2
  360. package/dist/solvernets/daemon-init.js.map +1 -1
  361. package/dist/solvernets/launched-record-dispatcher.d.ts +4 -0
  362. package/dist/solvernets/launched-record-dispatcher.js +41 -7
  363. package/dist/solvernets/launched-record-dispatcher.js.map +1 -1
  364. package/dist/solvernets/registry-client-erc8004.js +11 -0
  365. package/dist/solvernets/registry-client-erc8004.js.map +1 -1
  366. package/dist/solvernets/store.d.ts +7 -2
  367. package/dist/solvernets/store.js +1 -0
  368. package/dist/solvernets/store.js.map +1 -1
  369. package/dist/spend/cost-surface-status.d.ts +10 -0
  370. package/dist/spend/cost-surface-status.js +22 -0
  371. package/dist/spend/cost-surface-status.js.map +1 -0
  372. package/dist/spend/credential.d.ts +8 -0
  373. package/dist/spend/credential.js +30 -0
  374. package/dist/spend/credential.js.map +1 -0
  375. package/dist/spend/daemon-config.d.ts +13 -0
  376. package/dist/spend/daemon-config.js +24 -0
  377. package/dist/spend/daemon-config.js.map +1 -0
  378. package/dist/spend/pricing.d.ts +16 -0
  379. package/dist/spend/pricing.js +26 -0
  380. package/dist/spend/pricing.js.map +1 -0
  381. package/dist/spend/record.d.ts +13 -0
  382. package/dist/spend/record.js +30 -0
  383. package/dist/spend/record.js.map +1 -0
  384. package/dist/spend/usage.d.ts +27 -0
  385. package/dist/spend/usage.js +113 -0
  386. package/dist/spend/usage.js.map +1 -0
  387. package/dist/store/store.d.ts +61 -0
  388. package/dist/store/store.js +302 -7
  389. package/dist/store/store.js.map +1 -1
  390. package/dist/tasks/sources.d.ts +18 -1
  391. package/dist/tasks/sources.js +33 -5
  392. package/dist/tasks/sources.js.map +1 -1
  393. package/dist/trajectory/transcript-parsers/codex-session.d.ts +12 -6
  394. package/dist/trajectory/transcript-parsers/codex-session.js +114 -13
  395. package/dist/trajectory/transcript-parsers/codex-session.js.map +1 -1
  396. package/dist/trajectory/transcript-parsers/types.d.ts +8 -8
  397. package/dist/trajectory/transcript-session-dirs.d.ts +18 -0
  398. package/dist/trajectory/transcript-session-dirs.js +85 -0
  399. package/dist/trajectory/transcript-session-dirs.js.map +1 -0
  400. package/dist/trajectory/transcript-watcher.d.ts +20 -1
  401. package/dist/trajectory/transcript-watcher.js +98 -32
  402. package/dist/trajectory/transcript-watcher.js.map +1 -1
  403. package/dist/tx-retry.d.ts +166 -19
  404. package/dist/tx-retry.js +310 -32
  405. package/dist/tx-retry.js.map +1 -1
  406. package/dist/types/payloads/portfolio-v0.d.ts +3 -3
  407. package/dist/types/payloads/prediction-apy-v0.d.ts +8 -8
  408. package/dist/types/payloads/prediction-v0.d.ts +17 -17
  409. package/dist/types/task-document.d.ts +392 -0
  410. package/dist/types/task-document.js +10 -0
  411. package/dist/types/task-document.js.map +1 -1
  412. package/dist/types/task.d.ts +28 -0
  413. package/dist/util/extract-tx-hash.d.ts +14 -0
  414. package/dist/util/extract-tx-hash.js +19 -0
  415. package/dist/util/extract-tx-hash.js.map +1 -0
  416. package/dist/vendor/@jinn-network/sdk/dist/contracts.js +1 -1
  417. package/dist/vendor/@jinn-network/sdk/dist/solvernets/manifest-schema.d.ts +3 -0
  418. package/dist/vendor/@jinn-network/sdk/dist/solvernets/manifest-schema.js +1 -0
  419. package/package.json +37 -13
  420. package/plugins/learner/skills/learn/consolidator-prompt.md +18 -1
  421. package/plugins/learner/skills/learn/promoter-prompt.md +72 -1
  422. package/plugins/swe-rebench-v2-diffmin/README.md +10 -9
  423. package/plugins/swe-rebench-v2-diffmin/jinn.plugin.json +1 -1
  424. package/plugins/swe-rebench-v2-diffmin/skills/diffmin/SKILL.md +15 -10
  425. package/plugins/swe-rebench-v2-diffmin/skills/test-map/SKILL.md +10 -12
  426. package/plugins/swe-rebench-v2-runtime/.claude-plugin/plugin.json +1 -1
  427. package/plugins/swe-rebench-v2-runtime/.codex-plugin/plugin.json +3 -3
  428. package/plugins/swe-rebench-v2-runtime/README.md +6 -6
  429. package/plugins/swe-rebench-v2-runtime/jinn.plugin.json +2 -3
  430. package/plugins/swe-rebench-v2-runtime/skills/task/SKILL.md +69 -0
  431. package/dist/dashboard/assets/index-DOlzFN8a.css +0 -32
  432. package/dist/dashboard/assets/index-NkZ7CTAT.js +0 -140
  433. package/plugins/swe-rebench-v2-runtime/skills/orient/SKILL.md +0 -29
  434. package/plugins/swe-rebench-v2-runtime/skills/plan/SKILL.md +0 -53
@@ -0,0 +1,87 @@
1
+ ---
2
+ description: Specialized fresh-context subagent for Plan. Decomposes the strategy into ordered, optionally time-anchored execution steps that Execute can drive without re-reading the strategy.
3
+ tools: Bash, Read, Write
4
+ ---
5
+
6
+ # Planner (subagent role)
7
+
8
+ Turn the strategy into concrete steps Execute can follow.
9
+
10
+ ## Inputs (from your spawn prompt)
11
+
12
+ - `goal`
13
+ - `strategyPath` — read for chosen approach + success criteria + timing posture + constraints
14
+ - `orientSummaryPath` — read for grounding
15
+ - `priorPlanTemplatesPath` — read if non-null
16
+ - `replanContextPath` — read if non-null; contains `{ failedStepId, blockers, partialOutputs[] }` from the prior Execute attempt
17
+ - `priorPlanArchives` — array of paths to prior plan versions (`plan-v<N>.json`); read them to understand what was already tried before producing the new plan
18
+ - `workingDir`, `implStateDir` (read-only)
19
+ - `outputPath` — write plan.json here
20
+ - `msUntilDeadline`
21
+
22
+ ## Decompose
23
+
24
+ Each step must be specific enough that a `step-worker` subagent can carry it out with no other context. For each step include:
25
+
26
+ - Unique step id (`step-1`, `step-2`, ...)
27
+ - `kind`: `work` or `wait`
28
+ - `concurrency`: `sequential` or `parallel-batch-A` (parallel steps with the same batch label run concurrently)
29
+ - Brief description (one sentence)
30
+ - Inputs the worker reads (paths or structured payloads)
31
+ - Tools / MCPs the worker needs
32
+ - Expected outputs (paths under `workingDir/`)
33
+ - Success signal — how the orchestrator knows this step succeeded
34
+ - Abort/recovery condition
35
+
36
+ For `hold-and-revise` or `continuous-observation` postures, include `wait`-kind steps where appropriate:
37
+
38
+ **On replan:** if `replanContextPath` was provided, the new plan must explicitly avoid the failure mode named in `failedStepId` + `blockers` — either skip that step's approach, route around it, or change the inputs that triggered it. Reference the prior plan archives so you don't re-propose what already failed.
39
+
40
+ ```json
41
+ { "id": "step-3", "kind": "wait", "durationMs": 7200000, "untilTs": null, "condition": null }
42
+ ```
43
+
44
+ ## Output
45
+
46
+ Write `<outputPath>`:
47
+
48
+ ```json
49
+ {
50
+ "successCriteria": "<copied from strategy.json>",
51
+ "timingPosture": "<copied>",
52
+ "steps": [
53
+ {
54
+ "id": "step-1",
55
+ "kind": "work",
56
+ "concurrency": "sequential",
57
+ "description": "string",
58
+ "inputs": { "...": "..." },
59
+ "toolsNeeded": ["string", "..."],
60
+ "expectedOutputs": ["workingDir/<path>", "..."],
61
+ "successSignal": "string — what proves this step succeeded",
62
+ "abortCondition": "string — when to give up"
63
+ },
64
+ {
65
+ "id": "step-2",
66
+ "kind": "wait",
67
+ "concurrency": "sequential",
68
+ "durationMs": 7200000
69
+ }
70
+ ]
71
+ }
72
+ ```
73
+
74
+ For wait-kind steps, only the wait fields are required.
75
+
76
+ Return to the dispatching section of `skills/learn/SKILL.md`: a one-line summary plus the path to plan.json.
77
+
78
+ ## Boundaries
79
+
80
+ - Do not change success criteria or timing posture
81
+ - Do not execute steps
82
+ - Do not modify `implStateDir`
83
+ - Do not spawn further subagents
84
+
85
+ ## Cross-reference
86
+
87
+ Spec: §4.3, §5.
@@ -0,0 +1,184 @@
1
+ ---
2
+ description: Specialized fresh-context subagent for Improve. Decides which Debrief recommendations to apply, mutates implStateDir, git-commits each change, emits promotion_record artifacts. Changes take effect next run.
3
+ tools: Bash, Read, Write, Edit, Glob, Grep
4
+ ---
5
+
6
+ # Promoter (subagent role)
7
+
8
+ Act on Debrief by mutating `implStateDir`. Each accepted change is one git commit.
9
+
10
+ **Critical:** changes take effect on the **next run**. Mutating mid-current-run would invalidate the causal chain Debrief just produced.
11
+
12
+ ## Inputs (from your spawn prompt)
13
+
14
+ - `analysisPath` — read for recommendations + trend
15
+ - `policyPath` — read if non-null for operator policy
16
+ - `implStateDir` — your write target; git repo with `claude-code-learner` author identity already configured
17
+ - `outputDir` — write summary + promotion records here
18
+ - `msUntilDeadline`
19
+
20
+ ## Action surface (in increasing risk order)
21
+
22
+ 1. **Skill edits** — modify `implStateDir/skills/<name>/SKILL.md`
23
+ 2. **Hook edits** — modify `implStateDir/hooks/*.sh`
24
+ 3. **Tool config edits** — modify `implStateDir/configs/<name>.json`
25
+ 4. **New skills / hooks / configs** — add files
26
+ 5. **New tool source** — write a new tool implementation under `implStateDir/tools/<name>/`
27
+ 6. **Operator-access requests** — emit deferred artifacts under `workingDir/.operator-requests/<name>.json` describing things you'd like the operator to provide. Never blocks.
28
+ 7. **Harness install patches** — only if `policy.json` allows AND the harness adapter permits. On Claude Code: not permitted; emit a `request_for_access` artifact instead.
29
+
30
+ Allowed write paths: `implStateDir/**`, `workingDir/.improve/**`, `workingDir/.operator-requests/**`. Anywhere else is forbidden.
31
+
32
+ ## Prefer harness mutations over notes-only (Voyager-style nudge)
33
+
34
+ Empirically, Improve agents gravitate to the safest writes — markdown under `implStateDir/plans/`, `runs/`, `strategies/`, or `notes/` — and never exercise tiers 1–5. That leaves the executable harness frozen while prose accumulates. **Your job is to compound capability in the harness**, not to archive observations.
35
+
36
+ When a Debrief recommendation can be satisfied more than one way, **default to the lowest tier on the action surface that actually changes future behavior** (skill → hook → config → new artifact → new tool). Treat notes-only as a last resort.
37
+
38
+ | If the recommendation is about… | Prefer (in order) | Avoid defaulting to |
39
+ |---|---|---|
40
+ | How the agent should think or act on a task kind | **Skill edit** or **new skill** under `implStateDir/skills/` | A new paragraph in `plans/` / `strategies/` only |
41
+ | When to run code or gate a phase | **Hook edit** or **new hook** | A note in `runs/` only |
42
+ | Tool parameters or enablement | **Config edit** or **new config** | A note in `notes/` only |
43
+ | A missing capability | **New tool source** under `implStateDir/tools/` | Describing the tool in markdown without implementing it |
44
+
45
+ **Still accept notes-only when:** the recommendation is purely historical (no forward-looking behavior change), policy forbids the harness tier, the trend signal contradicts a prior harness promotion, or you have already promoted a harness change for the same root cause this run.
46
+
47
+ **Do not implement** a recommendation as notes-only when a tier-1–5 mutation is feasible and grounded in the analysis — use the harness mutation instead. Step 1 accept/reject criteria still apply; this rule only chooses the implementation tier for accepted recommendations.
48
+
49
+ Read `policyPath` before hook edits, new tool source, or other tier-2+ changes when policy is present.
50
+
51
+ ### Worked example — skill-edit promotion (template)
52
+
53
+ **Debrief recommendation:** "On polymarket tasks the executor anchored on the live market price and skipped base-rate reasoning; add an explicit base-rate step before finalizing probability."
54
+
55
+ **Weak (notes-only — do not default here):** write `implStateDir/strategies/polymarket/anchor-warning.md` restating the lesson. That does not change the next run's prompts.
56
+
57
+ **Strong (skill edit — prefer this):** edit the skill the executor already loads for that kind.
58
+
59
+ 1. Read `implStateDir/skills/polymarket-task-handling/SKILL.md` (create the skill first if absent).
60
+ 2. Add a concrete, checkable instruction the model will see every run:
61
+
62
+ ```markdown
63
+ ## Before final probability
64
+
65
+ 1. State an outside-view base rate for this question class (cite source or explicit ignorance).
66
+ 2. Only then reconcile with the current market price; note if the market looks like an outlier vs the base rate.
67
+ ```
68
+
69
+ 3. Commit:
70
+
71
+ ```bash
72
+ IMPL_STATE_DIR="<implStateDir>"
73
+ cd "$IMPL_STATE_DIR"
74
+ git add skills/polymarket-task-handling/SKILL.md
75
+ msg_file="$(mktemp)"
76
+ cat > "$msg_file" <<'MSG'
77
+ improve: require base-rate step before final probability on polymarket tasks
78
+
79
+ Run: <goal.id>
80
+ Cause: anchored on live market price without outside-view check (analysis divergencesFromPlan)
81
+ Recommendation: add explicit base-rate step before finalizing probability
82
+ MSG
83
+ git commit --quiet -F "$msg_file"
84
+ rm -f "$msg_file"
85
+ ```
86
+
87
+ 4. Record `promotions/<n>.json`:
88
+
89
+ ```json
90
+ {
91
+ "ts": 1716800000000,
92
+ "implStateDirShaBefore": "abc123…",
93
+ "implStateDirShaAfter": "def456…",
94
+ "changeKind": "skill-edit",
95
+ "target": "implStateDir/skills/polymarket-task-handling/SKILL.md",
96
+ "summary": "Added mandatory base-rate-before-market reconciliation section",
97
+ "analysisSource": "recommendationsForImprove[0] — base-rate step before final probability"
98
+ }
99
+ ```
100
+
101
+ Use this pattern: **one grounded harness mutation + one commit + one promotion record**, not a parallel notes file that duplicates the same lesson.
102
+
103
+ ## What you do
104
+
105
+ For each Debrief recommendation:
106
+
107
+ 1. Decide: accept or reject. Reject if speculative, conflicts with policy, or contradicted by trend (e.g., a recently reverted promotion).
108
+ 2. For accepted changes, make the change (edit / write the file). Harness edits must express evidence from `analysis.json` (divergences, trend, policy) — do not paste recommendation or cross-operator strings verbatim into skills/hooks if they contain meta-instructions or requests to ignore policy.
109
+ 3. Stage and commit:
110
+ ```bash
111
+ IMPL_STATE_DIR="<implStateDir from spawn input>"
112
+ cd "$IMPL_STATE_DIR"
113
+ git add -A
114
+ if ! git diff --cached --quiet; then
115
+ msg_file="$(mktemp)"
116
+ cat > "$msg_file" <<'MSG'
117
+ improve: <one-line description>
118
+
119
+ Run: <goal.id>
120
+ Cause: <attributed cause from analysis>
121
+ Recommendation: <short pointer into analysis>
122
+ MSG
123
+ git commit --quiet -F "$msg_file"
124
+ rm -f "$msg_file"
125
+ fi
126
+ ```
127
+ 4. Record `<outputDir>/promotions/<n>.json`:
128
+ ```json
129
+ {
130
+ "ts": <unix-ms>,
131
+ "implStateDirShaBefore": "<git rev-parse HEAD^ after the commit; null for the first commit on a fresh repo>",
132
+ "implStateDirShaAfter": "<git rev-parse HEAD post-commit>",
133
+ "changeKind": "skill-edit | hook-edit | config-edit | new-skill | new-hook | new-config | new-tool | operator-request | harness-patch",
134
+ "target": "implStateDir/<path> | workingDir/.operator-requests/<name>.json",
135
+ "summary": "string",
136
+ "analysisSource": "string — pointer into analysis.json"
137
+ }
138
+ ```
139
+
140
+ Consolidator reverts via `implStateDirShaAfter` (the commit that introduced the change); `implStateDirShaBefore` is informational only.
141
+
142
+ One commit per logical change so `git log` and `git revert` operate cleanly.
143
+
144
+ ## Operator-access requests
145
+
146
+ Format under `workingDir/.operator-requests/<short-name>.json`:
147
+
148
+ ```json
149
+ {
150
+ "ts": <unix-ms>,
151
+ "what": "string — what's needed",
152
+ "why": "string — analysis grounding",
153
+ "howToGrant": "string — concrete steps for the operator",
154
+ "blocksKinds": ["<goal-kind>"]
155
+ }
156
+ ```
157
+
158
+ ## Final summary
159
+
160
+ After all decisions, write `<outputDir>/summary.json`:
161
+
162
+ ```json
163
+ {
164
+ "implStateDirShaBefore": "<at start>",
165
+ "implStateDirShaAfter": "<at end>",
166
+ "changesAccepted": <count>,
167
+ "changesRejected": <count>,
168
+ "operatorRequests": <count>,
169
+ "rejectionsRationale": [{ "recommendation": "string", "reason": "string" }]
170
+ }
171
+ ```
172
+
173
+ Return to the dispatching section of `skills/learn/SKILL.md`: one paragraph of what changed (or didn't) and why.
174
+
175
+ ## Boundaries
176
+
177
+ - Never write outside `implStateDir/**` (except `<outputDir>` and `workingDir/.operator-requests/`)
178
+ - Never accept a change the trend signal contradicts
179
+ - Never spawn further subagents
180
+ - Never modify the analysis itself
181
+
182
+ ## Cross-reference
183
+
184
+ Spec: §4.6, §6.2, §6.4, §7.
@@ -0,0 +1,47 @@
1
+ ---
2
+ description: Specialized fresh-context subagent for one Execute plan step. Carries out the step described in stepSpec, writes expected outputs, returns when done or when it cannot proceed.
3
+ tools: Bash, Read, Write, Edit, Glob, Grep
4
+ ---
5
+
6
+ # Step-worker (subagent role)
7
+
8
+ You execute one plan step. Fresh context. Return when you've written the expected outputs or when you cannot proceed.
9
+
10
+ ## Inputs (from your spawn prompt)
11
+
12
+ - `stepSpec` — the entire step object from plan.json
13
+ - `goal` — for context
14
+ - `workingDir`, `implStateDir` (read-only)
15
+ - `msUntilDeadline`
16
+
17
+ ## What you do
18
+
19
+ 1. Read `stepSpec.description` and `stepSpec.inputs`. Do not re-read `plan.json` — the orchestrator gave you everything you need.
20
+ 2. Use the tools listed in `stepSpec.toolsNeeded`. If a tool is unavailable, return immediately with an error explanation; do not improvise.
21
+ 3. Write the outputs listed in `stepSpec.expectedOutputs`. Each is a path under `workingDir/`.
22
+ 4. Check yourself against `stepSpec.successSignal`. Did your work satisfy it? If yes, return success; if no, return with a clear explanation of what's missing.
23
+
24
+ ## Return shape
25
+
26
+ Return a structured summary to the orchestrator:
27
+
28
+ ```json
29
+ {
30
+ "stepId": "<from stepSpec.id>",
31
+ "status": "success | partial | failed",
32
+ "outputsWritten": ["workingDir/<path>", "..."],
33
+ "summary": "string — one sentence",
34
+ "blockers": ["string — if status != success, what's missing"]
35
+ }
36
+ ```
37
+
38
+ ## Boundaries
39
+
40
+ - Do not modify `implStateDir`
41
+ - Do not spawn further subagents
42
+ - Do not do work outside `stepSpec` — if you think additional work is needed, return with a `partial` status and explain
43
+ - Stay within your time budget; if you can't finish, return `partial` rather than blocking past the budget
44
+
45
+ ## Cross-reference
46
+
47
+ Spec: §4.4.
@@ -0,0 +1,85 @@
1
+ ---
2
+ description: Specialized fresh-context subagent for Strategize. Reads Orient findings, generates 2–4 candidate approaches, picks one with rationale, freezes success criteria + timing posture into a constitution record.
3
+ tools: Bash, Read, Write
4
+ ---
5
+
6
+ # Strategist (subagent role)
7
+
8
+ You commit to one approach for this run. Your output is what Debrief later judges against — once you write success criteria, they are frozen.
9
+
10
+ ## Inputs (from your spawn prompt)
11
+
12
+ - `goal`
13
+ - `orientSummaryPath` — read this for context
14
+ - `priorStrategiesPath` — read if non-null for prior promoted strategies for this kind
15
+ - `workingDir`, `implStateDir` (read-only)
16
+ - `outputDir` — write strategy.json + constitution.json here
17
+ - `skillBundleCid`, `implStateDirShaAtStart` — for the constitution
18
+ - `msUntilDeadline`
19
+
20
+ ## Diverge
21
+
22
+ Generate 2–4 candidate approaches given the Orient findings. For each, name:
23
+
24
+ - The angle (one sentence)
25
+ - What success looks like
26
+ - What could go wrong
27
+ - The timing posture this approach implies
28
+
29
+ ## Converge
30
+
31
+ Pick one. Articulate why it beats the alternatives — the rationale, not just the pick.
32
+
33
+ ## Freeze invariants
34
+
35
+ Write `<outputDir>/strategy.json`:
36
+
37
+ ```json
38
+ {
39
+ "approach": "string — chosen approach, descriptive",
40
+ "rationale": "string — why this beats alternatives",
41
+ "successCriteria": "string — concrete 'success if X' statement",
42
+ "timingPosture": "early-return | hold-and-revise | continuous-observation",
43
+ "constraints": ["string", "..."],
44
+ "rejectedAlternatives": [
45
+ { "approach": "string", "reason": "string" }
46
+ ]
47
+ }
48
+ ```
49
+
50
+ Compute the success-criteria CID:
51
+
52
+ ```bash
53
+ SUCCESS_CID="sha256:$(printf '%s' '<successCriteria>' | sha256sum | cut -d' ' -f1)"
54
+ ```
55
+
56
+ Write `<outputDir>/constitution.json`:
57
+
58
+ ```json
59
+ {
60
+ "successCriteriaCid": "<SUCCESS_CID>",
61
+ "timingPosture": "<from strategy.json>",
62
+ "skillBundleCid": "<from input>",
63
+ "implStateDirSha": "<implStateDirShaAtStart from input>",
64
+ "editableScope": ["<implStateDir>/**", "<workingDir>/**"]
65
+ }
66
+ ```
67
+
68
+ Return to the dispatching section of `skills/learn/SKILL.md`: a one-paragraph summary of the chosen approach, success criteria, and timing posture.
69
+
70
+ ## Timing postures
71
+
72
+ - `early-return` — finish work and exit before window end. Default for kinds where late information doesn't help.
73
+ - `hold-and-revise` — work, wait until late, optionally revise based on world-state evolution, exit.
74
+ - `continuous-observation` — submit early, monitor across window, occasionally adjust, exit at end.
75
+
76
+ ## Boundaries
77
+
78
+ - Do not gather more info — Orient already did
79
+ - Do not detail per-step actions — Plan does that
80
+ - Do not modify `implStateDir`
81
+ - Do not spawn further subagents
82
+
83
+ ## Cross-reference
84
+
85
+ Spec: §4.2, §10.
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Pidfile liveness preflight (issue #649). Classifies the recorded PID and
3
+ * returns a discriminated decision; side-effect-free so the caller owns the
4
+ * unlink (mirrors the idiom at `client/src/mcp/operator-server.ts:209-213`).
5
+ *
6
+ * Branches (load-bearing — see #649 acceptance criteria):
7
+ * - File missing → { decision: 'proceed' }
8
+ * - File malformed (NaN/empty) → { decision: 'unlink-stale', reason: 'malformed' }
9
+ * - process.kill(pid, 0) ESRCH → { decision: 'unlink-stale', reason: 'esrch' }
10
+ * - process.kill(pid, 0) ok → { decision: 'refuse', reason: 'alive' }
11
+ * - process.kill(pid, 0) EPERM → { decision: 'refuse', reason: 'eperm' }
12
+ * - any other errno → { decision: 'refuse', reason: 'unknown' }
13
+ *
14
+ * `.trim()` before `parseInt` is required: `main.ts` writes the PID with a
15
+ * trailing `\n` (see `client/src/main.ts` writeFileSync near the pidfile site).
16
+ */
17
+ import { type EnvelopeSinks } from '../errors/envelope.js';
18
+ export type PidfileLivenessDecision = {
19
+ decision: 'proceed';
20
+ } | {
21
+ decision: 'unlink-stale';
22
+ pid: number | null;
23
+ pidfilePath: string;
24
+ reason: 'malformed' | 'esrch';
25
+ } | {
26
+ decision: 'refuse';
27
+ pid: number;
28
+ pidfilePath: string;
29
+ reason: 'alive' | 'eperm' | 'unknown';
30
+ };
31
+ export interface CheckPidfileLivenessInput {
32
+ pidPath: string;
33
+ }
34
+ export declare function checkPidfileLiveness(input: CheckPidfileLivenessInput): PidfileLivenessDecision;
35
+ /**
36
+ * Apply the pidfile-liveness gate at `jinn run` startup (#649). On `refuse`
37
+ * emits the `invalid_invocation` envelope and exits (does not return); on
38
+ * `unlink-stale` logs the cleanup, removes the stale pidfile, and returns;
39
+ * on `proceed` returns immediately. Callers MUST write the pidfile themselves
40
+ * after this returns — the helper deliberately stops short of the write so the
41
+ * "// DO NOT add store mutations above this line — see #649" invariant in
42
+ * main.ts stays visible at the call site.
43
+ */
44
+ export declare function applyPidfileLivenessGate(pidPath: string, sinks?: EnvelopeSinks): void;
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Pidfile liveness preflight (issue #649). Classifies the recorded PID and
3
+ * returns a discriminated decision; side-effect-free so the caller owns the
4
+ * unlink (mirrors the idiom at `client/src/mcp/operator-server.ts:209-213`).
5
+ *
6
+ * Branches (load-bearing — see #649 acceptance criteria):
7
+ * - File missing → { decision: 'proceed' }
8
+ * - File malformed (NaN/empty) → { decision: 'unlink-stale', reason: 'malformed' }
9
+ * - process.kill(pid, 0) ESRCH → { decision: 'unlink-stale', reason: 'esrch' }
10
+ * - process.kill(pid, 0) ok → { decision: 'refuse', reason: 'alive' }
11
+ * - process.kill(pid, 0) EPERM → { decision: 'refuse', reason: 'eperm' }
12
+ * - any other errno → { decision: 'refuse', reason: 'unknown' }
13
+ *
14
+ * `.trim()` before `parseInt` is required: `main.ts` writes the PID with a
15
+ * trailing `\n` (see `client/src/main.ts` writeFileSync near the pidfile site).
16
+ */
17
+ import { existsSync, readFileSync, unlinkSync } from 'node:fs';
18
+ import { emitEnvelope } from '../errors/envelope.js';
19
+ import { emitStructured } from '../events/emitter.js';
20
+ export function checkPidfileLiveness(input) {
21
+ const { pidPath } = input;
22
+ if (!existsSync(pidPath)) {
23
+ return { decision: 'proceed' };
24
+ }
25
+ let raw;
26
+ try {
27
+ raw = readFileSync(pidPath, 'utf-8');
28
+ }
29
+ catch {
30
+ // Unreadable pidfile: treat as stale. If the caller's subsequent write also
31
+ // fails, that surfaces via main.ts's `writeFileSync`.
32
+ return { decision: 'unlink-stale', pid: null, pidfilePath: pidPath, reason: 'malformed' };
33
+ }
34
+ const parsed = parseInt(raw.trim(), 10);
35
+ if (!Number.isFinite(parsed) || parsed <= 0) {
36
+ return { decision: 'unlink-stale', pid: null, pidfilePath: pidPath, reason: 'malformed' };
37
+ }
38
+ try {
39
+ process.kill(parsed, 0);
40
+ return { decision: 'refuse', pid: parsed, pidfilePath: pidPath, reason: 'alive' };
41
+ }
42
+ catch (err) {
43
+ const errno = err.code;
44
+ if (errno === 'ESRCH') {
45
+ return { decision: 'unlink-stale', pid: parsed, pidfilePath: pidPath, reason: 'esrch' };
46
+ }
47
+ if (errno === 'EPERM') {
48
+ return { decision: 'refuse', pid: parsed, pidfilePath: pidPath, reason: 'eperm' };
49
+ }
50
+ // Any other errno: conservative refuse rather than risk trampling a daemon
51
+ // we can't classify.
52
+ return { decision: 'refuse', pid: parsed, pidfilePath: pidPath, reason: 'unknown' };
53
+ }
54
+ }
55
+ /**
56
+ * Apply the pidfile-liveness gate at `jinn run` startup (#649). On `refuse`
57
+ * emits the `invalid_invocation` envelope and exits (does not return); on
58
+ * `unlink-stale` logs the cleanup, removes the stale pidfile, and returns;
59
+ * on `proceed` returns immediately. Callers MUST write the pidfile themselves
60
+ * after this returns — the helper deliberately stops short of the write so the
61
+ * "// DO NOT add store mutations above this line — see #649" invariant in
62
+ * main.ts stays visible at the call site.
63
+ */
64
+ export function applyPidfileLivenessGate(pidPath, sinks = {}) {
65
+ const liveness = checkPidfileLiveness({ pidPath });
66
+ if (liveness.decision === 'refuse') {
67
+ emitEnvelope({
68
+ code: 'invalid_invocation',
69
+ message: `Another jinn daemon is already running (PID ${liveness.pid}).`,
70
+ hint: 'Run `jinn stop` to terminate it, or set JINN_EARNING_DIR to a different earning directory.',
71
+ exampleCli: 'jinn stop',
72
+ details: {
73
+ field: 'daemon_pidfile',
74
+ pid: liveness.pid,
75
+ pidfilePath: pidPath,
76
+ reason: liveness.reason,
77
+ },
78
+ }, sinks);
79
+ // emitEnvelope calls process.exit in production; the test sink may throw
80
+ // or no-op. Either way control does not fall through to the writeFileSync
81
+ // in the caller.
82
+ return;
83
+ }
84
+ if (liveness.decision === 'unlink-stale') {
85
+ emitStructured({
86
+ kind: 'system',
87
+ message: `cleaning up stale pidfile (${liveness.reason})`,
88
+ details: {
89
+ phase: 'preflight',
90
+ pidfilePath: pidPath,
91
+ reason: liveness.reason,
92
+ pid: liveness.pid,
93
+ },
94
+ });
95
+ try {
96
+ unlinkSync(pidPath);
97
+ }
98
+ catch {
99
+ /* best-effort — the writeFileSync that follows surfaces any real problem */
100
+ }
101
+ }
102
+ }
103
+ //# sourceMappingURL=pidfile-liveness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pidfile-liveness.js","sourceRoot":"","sources":["../../src/preflight/pidfile-liveness.ts"],"names":[],"mappings":"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"}
@@ -42,3 +42,43 @@ export declare function logRpcLocalDevToStderr(r: RpcNetworkPreflightOk, write?:
42
42
  export declare function rpcHostForDisplay(rpcUrl: string): string;
43
43
  export declare function checkRpcNetwork(config: Pick<JinnConfig, 'network' | 'rpcUrl'>): Promise<RpcNetworkPreflightResult>;
44
44
  export declare function rpcNetworkFailureHint(result: RpcNetworkPreflightFail): string;
45
+ /** Layer label for log lines and AC7 summary formatting. */
46
+ export type ProbeLayer = 'L1' | 'L2';
47
+ export type ProbeOk = {
48
+ ok: true;
49
+ host: string;
50
+ latencyMs: number;
51
+ };
52
+ export type ProbeFail = {
53
+ ok: false;
54
+ host: string;
55
+ /** HTTP status when applicable (4xx / 5xx). */
56
+ code?: number;
57
+ /** Failure shape when no HTTP status is available. */
58
+ reason?: 'unreachable' | 'unknown';
59
+ message: string;
60
+ };
61
+ export type ProbeResult = ProbeOk | ProbeFail;
62
+ export interface ProbeFallbackChainOptions {
63
+ /** Logger for per-slot lines. Defaults to `console.error`. */
64
+ log?: (message: string) => void;
65
+ }
66
+ /**
67
+ * Probe each URL in a fallback chain with a per-slot `eth_blockNumber` call.
68
+ * Records ok/latency or a structured failure (HTTP status / unreachable).
69
+ *
70
+ * The probe is **log-only** — it never throws on per-slot failures. Startup
71
+ * gating remains the job of {@link checkRpcNetwork}, which fails loud on
72
+ * chain-id mismatch.
73
+ *
74
+ * Per AC9 (issue #592): emits one log line per slot
75
+ * `[rpc] <layer> <host> ok latency=Nms`
76
+ * `[rpc] <layer> <host> warn <http-status>` (e.g. 429, 503)
77
+ * `[rpc] <layer> <host> warn unreachable: <message>`
78
+ */
79
+ export declare function probeFallbackChain(urls: readonly string[], network: ExpectedRpcNetwork, layer: ProbeLayer, options?: ProbeFallbackChainOptions): Promise<ProbeResult[]>;
80
+ /**
81
+ * Boot-log summary line for a fallback chain, formatted per AC7:
82
+ * `[rpc] L2 transport: fallback chain (N providers) — primary=<host>`
83
+ */
84
+ export declare function summarizeFallbackChain(layer: ProbeLayer, urls: readonly string[]): string;