pi-harness-runtime 0.9.22 → 0.10.0

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 (393) hide show
  1. package/CHANGELOG.md +49 -7
  2. package/README.md +51 -51
  3. package/footer-status.ts +84 -44
  4. package/harness/auto-compact.ts +1 -1
  5. package/harness/auto-quota-resume.ts +15 -12
  6. package/harness/autonomous-review.ts +88 -0
  7. package/harness/context-compact-orchestrator.ts +23 -23
  8. package/harness/context-window-manager.ts +5 -5
  9. package/harness/continue-prompt.ts +3 -3
  10. package/harness/e2e/minimax-quota-scraper.ts +10 -10
  11. package/harness/e2e/openai-quota-scraper.ts +442 -0
  12. package/harness/forked-summarizer.ts +4 -4
  13. package/harness/herdr-agents.ts +91 -0
  14. package/harness/index.ts +5 -5
  15. package/harness/loop-code-agent.ts +284 -0
  16. package/harness/loop-controller.ts +201 -0
  17. package/harness/loop-review-agent.ts +295 -0
  18. package/harness/loop-runtime.ts +21 -17
  19. package/harness/loop-types.ts +118 -0
  20. package/harness/notification-events.ts +3 -3
  21. package/harness/output-limit-handler.ts +1 -1
  22. package/harness/partial-recovery.ts +3 -3
  23. package/harness/session-memory.ts +5 -5
  24. package/index.ts +211 -80
  25. package/package.json +2 -2
  26. package/packages/a2a-adapter/package.json +1 -1
  27. package/packages/a2a-adapter/src/types.ts +5 -5
  28. package/packages/auth/dist/minimax-browser-auth.d.ts +89 -0
  29. package/packages/auth/dist/minimax-browser-auth.d.ts.map +1 -0
  30. package/packages/auth/dist/minimax-browser-auth.js +890 -0
  31. package/packages/auth/dist/minimax-browser-auth.js.map +1 -0
  32. package/packages/auth/dist/run-minimax-auth.d.ts +19 -0
  33. package/packages/auth/dist/run-minimax-auth.d.ts.map +1 -0
  34. package/packages/auth/dist/run-minimax-auth.js +112 -0
  35. package/packages/auth/dist/run-minimax-auth.js.map +1 -0
  36. package/packages/auth/package.json +1 -1
  37. package/packages/auth/tsconfig.json +9 -0
  38. package/packages/autonomous-refactor/package.json +1 -1
  39. package/packages/autonomous-runtime/dist/inbox.d.ts +3 -3
  40. package/packages/autonomous-runtime/dist/inbox.js +12 -12
  41. package/packages/autonomous-runtime/dist/lease.js +14 -14
  42. package/packages/autonomous-runtime/dist/types.js +1 -1
  43. package/packages/autonomous-runtime/package.json +1 -1
  44. package/packages/autonomous-runtime/src/inbox.ts +12 -12
  45. package/packages/autonomous-runtime/src/lease.ts +15 -15
  46. package/packages/autonomous-runtime/src/types.ts +13 -13
  47. package/packages/autonomous-runtime/tsconfig.tsbuildinfo +1 -1
  48. package/packages/cache-strategy/package.json +1 -1
  49. package/packages/capability-registry/dist/types.js +1 -1
  50. package/packages/capability-registry/package.json +1 -1
  51. package/packages/capability-registry/src/types.ts +5 -5
  52. package/packages/checkpoint/README.md +6 -6
  53. package/packages/checkpoint/dist/differ.js +2 -2
  54. package/packages/checkpoint/dist/engine.js +3 -3
  55. package/packages/checkpoint/dist/index.js +5 -5
  56. package/packages/checkpoint/dist/storage.js +3 -3
  57. package/packages/checkpoint/dist/types.js +1 -1
  58. package/packages/checkpoint/package.json +1 -1
  59. package/packages/checkpoint/src/differ.ts +2 -2
  60. package/packages/checkpoint/src/engine.ts +3 -3
  61. package/packages/checkpoint/src/index.ts +5 -5
  62. package/packages/checkpoint/src/storage.ts +3 -3
  63. package/packages/checkpoint/src/types.ts +10 -10
  64. package/packages/checkpoint/tsconfig.tsbuildinfo +1 -1
  65. package/packages/cli-plugin-sdk/package.json +1 -1
  66. package/packages/clipboard/dist/src/clipboard.d.ts.map +1 -1
  67. package/packages/clipboard/dist/src/clipboard.js +15 -7
  68. package/packages/clipboard/dist/src/clipboard.js.map +1 -1
  69. package/packages/clipboard/package.json +1 -1
  70. package/packages/clipboard/src/clipboard.ts +16 -9
  71. package/packages/code-generation/README.md +13 -13
  72. package/packages/code-generation/dist/faker.js +4 -4
  73. package/packages/code-generation/dist/generator.js +3 -3
  74. package/packages/code-generation/dist/index.js +3 -3
  75. package/packages/code-generation/dist/templates/registry.js +1 -1
  76. package/packages/code-generation/dist/types.js +1 -1
  77. package/packages/code-generation/package.json +1 -1
  78. package/packages/code-generation/src/faker.ts +5 -5
  79. package/packages/code-generation/src/generator.ts +4 -4
  80. package/packages/code-generation/src/index.ts +3 -3
  81. package/packages/code-generation/src/templates/registry.ts +1 -1
  82. package/packages/code-generation/src/types.ts +10 -10
  83. package/packages/code-generation/tsconfig.tsbuildinfo +1 -1
  84. package/packages/code-review/README.md +13 -13
  85. package/packages/code-review/dist/engine.js +3 -3
  86. package/packages/code-review/dist/index.js +3 -3
  87. package/packages/code-review/dist/types.js +1 -1
  88. package/packages/code-review/package.json +1 -1
  89. package/packages/code-review/src/engine.ts +3 -3
  90. package/packages/code-review/src/index.ts +3 -3
  91. package/packages/code-review/src/types.ts +10 -10
  92. package/packages/code-review/tsconfig.tsbuildinfo +1 -1
  93. package/packages/codex-adapter/package.json +1 -1
  94. package/packages/context-compiler/dist/compiler.js +1 -1
  95. package/packages/context-compiler/package.json +1 -1
  96. package/packages/context-compiler/src/compiler.ts +1 -1
  97. package/packages/context-compiler/src/types.ts +11 -11
  98. package/packages/context-compiler/test/context-compiler.test.ts +11 -11
  99. package/packages/context-discovery/package.json +1 -1
  100. package/packages/context-manager/package.json +1 -1
  101. package/packages/cookie-sanitizer/README.md +27 -27
  102. package/packages/cookie-sanitizer/package.json +1 -1
  103. package/packages/cost-optimizer/package.json +1 -1
  104. package/packages/cost-optimizer/src/types.ts +5 -5
  105. package/packages/dependency-analyzer/package.json +1 -1
  106. package/packages/django-plugin/dist/analyzer.js +7 -7
  107. package/packages/django-plugin/package.json +1 -1
  108. package/packages/django-plugin/src/analyzer.ts +7 -7
  109. package/packages/doc-generator/package.json +1 -1
  110. package/packages/evaluation-engine/dist/engine.js +9 -9
  111. package/packages/evaluation-engine/package.json +1 -1
  112. package/packages/evaluation-engine/src/engine.ts +9 -9
  113. package/packages/evaluation-engine/src/types.ts +3 -3
  114. package/packages/evaluation-runner/package.json +1 -1
  115. package/packages/event-bus/dist/src/herdr-bus.d.ts +121 -0
  116. package/packages/event-bus/dist/src/herdr-bus.d.ts.map +1 -0
  117. package/packages/event-bus/dist/src/herdr-bus.js +322 -0
  118. package/packages/event-bus/dist/src/herdr-bus.js.map +1 -0
  119. package/packages/event-bus/dist/src/index.d.ts +2 -0
  120. package/packages/event-bus/dist/src/index.d.ts.map +1 -1
  121. package/packages/event-bus/dist/src/index.js +1 -0
  122. package/packages/event-bus/dist/src/index.js.map +1 -1
  123. package/packages/event-bus/package.json +1 -1
  124. package/packages/event-bus/src/herdr-bus.ts +525 -0
  125. package/packages/event-bus/src/index.ts +29 -0
  126. package/packages/event-store/package.json +1 -1
  127. package/packages/experience-replay/dist/replay.js +7 -7
  128. package/packages/experience-replay/package.json +1 -1
  129. package/packages/experience-replay/src/replay.ts +7 -7
  130. package/packages/experience-replay/src/types.ts +5 -5
  131. package/packages/feedback-collector/package.json +1 -1
  132. package/packages/framework-detector/README.md +18 -18
  133. package/packages/framework-detector/dist/detector.js +3 -3
  134. package/packages/framework-detector/dist/index.js +3 -3
  135. package/packages/framework-detector/dist/signatures/registry.js +24 -24
  136. package/packages/framework-detector/dist/types.js +1 -1
  137. package/packages/framework-detector/package.json +1 -1
  138. package/packages/framework-detector/src/detector.ts +3 -3
  139. package/packages/framework-detector/src/index.ts +3 -3
  140. package/packages/framework-detector/src/signatures/registry.ts +24 -24
  141. package/packages/framework-detector/src/types.ts +7 -7
  142. package/packages/framework-detector/tsconfig.tsbuildinfo +1 -1
  143. package/packages/framework-plugin-sdk/README.md +23 -23
  144. package/packages/framework-plugin-sdk/dist/index.js +2 -2
  145. package/packages/framework-plugin-sdk/dist/manager.js +3 -3
  146. package/packages/framework-plugin-sdk/dist/types.js +2 -2
  147. package/packages/framework-plugin-sdk/package.json +1 -1
  148. package/packages/framework-plugin-sdk/src/index.ts +2 -2
  149. package/packages/framework-plugin-sdk/src/manager.ts +3 -3
  150. package/packages/framework-plugin-sdk/src/types.ts +10 -10
  151. package/packages/framework-plugin-sdk/tsconfig.tsbuildinfo +1 -1
  152. package/packages/frappe-plugin/dist/analyzer.js +8 -8
  153. package/packages/frappe-plugin/dist/types.js +1 -1
  154. package/packages/frappe-plugin/package.json +1 -1
  155. package/packages/frappe-plugin/src/analyzer.ts +8 -8
  156. package/packages/frappe-plugin/src/types.ts +10 -10
  157. package/packages/generic-web-plugin/dist/analyzer.js +5 -5
  158. package/packages/generic-web-plugin/package.json +1 -1
  159. package/packages/generic-web-plugin/src/analyzer.ts +5 -5
  160. package/packages/health-monitor/package.json +1 -1
  161. package/packages/health-monitor/src/monitor.ts +1 -1
  162. package/packages/intent-analyzer/package.json +1 -1
  163. package/packages/laravel-plugin/dist/analyzer.js +11 -11
  164. package/packages/laravel-plugin/package.json +1 -1
  165. package/packages/laravel-plugin/src/analyzer.ts +11 -11
  166. package/packages/learning-engine/dist/engine.js +5 -5
  167. package/packages/learning-engine/dist/types.js +1 -1
  168. package/packages/learning-engine/package.json +1 -1
  169. package/packages/learning-engine/src/engine.ts +5 -5
  170. package/packages/learning-engine/src/types.ts +6 -6
  171. package/packages/mcp-adapter/package.json +1 -1
  172. package/packages/memory-engine/dist/engine.js +8 -8
  173. package/packages/memory-engine/dist/types.js +2 -2
  174. package/packages/memory-engine/package.json +1 -1
  175. package/packages/memory-engine/src/engine.ts +8 -8
  176. package/packages/memory-engine/src/types.ts +9 -9
  177. package/packages/model-registry/package.json +1 -1
  178. package/packages/model-registry/src/types.ts +4 -4
  179. package/packages/nextjs-plugin/dist/analyzer.js +9 -9
  180. package/packages/nextjs-plugin/package.json +1 -1
  181. package/packages/nextjs-plugin/src/analyzer.ts +9 -9
  182. package/packages/notification/dist/notification-center.js +1 -1
  183. package/packages/notification/package.json +1 -1
  184. package/packages/notification/src/notification-center.ts +1 -1
  185. package/packages/observability/dist/alerts.js +2 -2
  186. package/packages/observability/dist/health.js +4 -4
  187. package/packages/observability/dist/index.js +6 -6
  188. package/packages/observability/dist/logger.js +7 -7
  189. package/packages/observability/dist/metrics.js +11 -11
  190. package/packages/observability/dist/tracer.js +3 -3
  191. package/packages/observability/dist/types.js +1 -1
  192. package/packages/observability/package.json +1 -1
  193. package/packages/observability/src/alerts.ts +2 -2
  194. package/packages/observability/src/health.ts +4 -4
  195. package/packages/observability/src/index.ts +6 -6
  196. package/packages/observability/src/logger.ts +7 -7
  197. package/packages/observability/src/metrics.ts +11 -11
  198. package/packages/observability/src/tracer.ts +3 -3
  199. package/packages/observability/src/types.ts +7 -7
  200. package/packages/observability/test/observability.test.ts +4 -4
  201. package/packages/observability/tsconfig.tsbuildinfo +1 -1
  202. package/packages/performance-optimizer/dist/optimizer.js +1 -1
  203. package/packages/performance-optimizer/package.json +1 -1
  204. package/packages/performance-optimizer/src/optimizer.ts +1 -1
  205. package/packages/performance-optimizer/src/types.ts +4 -4
  206. package/packages/privilege-broker/package.json +1 -1
  207. package/packages/project-analyzer/dist/analyzer.js +4 -4
  208. package/packages/project-analyzer/dist/index.js +8 -8
  209. package/packages/project-analyzer/dist/signals.js +3 -3
  210. package/packages/project-analyzer/dist/types.js +1 -1
  211. package/packages/project-analyzer/package.json +1 -1
  212. package/packages/project-analyzer/src/analyzer.ts +4 -4
  213. package/packages/project-analyzer/src/index.ts +9 -9
  214. package/packages/project-analyzer/src/signals.ts +4 -4
  215. package/packages/project-analyzer/src/types.ts +15 -15
  216. package/packages/project-analyzer/test/index.test.ts +17 -17
  217. package/packages/project-analyzer/tsconfig.tsbuildinfo +1 -1
  218. package/packages/projection-engine/package.json +1 -1
  219. package/packages/prompt-compiler/dist/section-builder.js +1 -1
  220. package/packages/prompt-compiler/dist/types.js +3 -3
  221. package/packages/prompt-compiler/package.json +1 -1
  222. package/packages/prompt-compiler/src/section-builder.ts +1 -1
  223. package/packages/prompt-compiler/src/types.ts +12 -12
  224. package/packages/prompt-compiler/test/prompt-compiler.test.ts +12 -12
  225. package/packages/prompt-versioning/package.json +1 -1
  226. package/packages/provider-adapter-sdk/dist/builder.js +1 -1
  227. package/packages/provider-adapter-sdk/dist/index.js +5 -5
  228. package/packages/provider-adapter-sdk/dist/registry.js +1 -1
  229. package/packages/provider-adapter-sdk/dist/tester.js +1 -1
  230. package/packages/provider-adapter-sdk/dist/types.js +1 -1
  231. package/packages/provider-adapter-sdk/package.json +1 -1
  232. package/packages/provider-adapter-sdk/src/builder.ts +1 -1
  233. package/packages/provider-adapter-sdk/src/index.ts +6 -6
  234. package/packages/provider-adapter-sdk/src/registry.ts +1 -1
  235. package/packages/provider-adapter-sdk/src/tester.ts +1 -1
  236. package/packages/provider-adapter-sdk/src/types.ts +5 -5
  237. package/packages/provider-adapter-sdk/tsconfig.tsbuildinfo +1 -1
  238. package/packages/provider-router/package.json +1 -1
  239. package/packages/provider-router/src/types.ts +4 -4
  240. package/packages/provider-selector/package.json +1 -1
  241. package/packages/providers/dist/deepagents-adapter.js +1 -1
  242. package/packages/providers/dist/provider-id.d.ts +5 -0
  243. package/packages/providers/dist/provider-id.d.ts.map +1 -1
  244. package/packages/providers/dist/provider-id.js +6 -1
  245. package/packages/providers/dist/provider-id.js.map +1 -1
  246. package/packages/providers/package.json +1 -1
  247. package/packages/providers/src/deepagents-adapter.ts +1 -1
  248. package/packages/providers/src/provider-id.ts +6 -1
  249. package/packages/quota-manager/dist/tui-usage-monitor.d.ts.map +1 -1
  250. package/packages/quota-manager/dist/tui-usage-monitor.js +0 -6
  251. package/packages/quota-manager/dist/tui-usage-monitor.js.map +1 -1
  252. package/packages/quota-manager/package.json +1 -1
  253. package/packages/quota-manager/src/tui-usage-monitor.ts +0 -21
  254. package/packages/rate-limiter/package.json +1 -1
  255. package/packages/react-vite-plugin/dist/analyzer.js +7 -7
  256. package/packages/react-vite-plugin/package.json +1 -1
  257. package/packages/react-vite-plugin/src/analyzer.ts +7 -7
  258. package/packages/release-manager/package.json +1 -1
  259. package/packages/requirement-compiler/dist/compiler.js +17 -17
  260. package/packages/requirement-compiler/dist/types.js +2 -2
  261. package/packages/requirement-compiler/package.json +1 -1
  262. package/packages/requirement-compiler/src/compiler.ts +17 -17
  263. package/packages/requirement-compiler/src/types.ts +21 -21
  264. package/packages/requirement-compiler/test/requirement-compiler.test.ts +17 -17
  265. package/packages/runtime/dist/command-executor.js +1 -1
  266. package/packages/runtime/dist/local-runtime-agent.js +1 -1
  267. package/packages/runtime/dist/policy-engine.js +1 -1
  268. package/packages/runtime/dist/runtime-api.js +1 -1
  269. package/packages/runtime/dist/workspace-manager.js +1 -1
  270. package/packages/runtime/package.json +1 -1
  271. package/packages/runtime/src/command-executor.ts +1 -1
  272. package/packages/runtime/src/local-runtime-agent.ts +1 -1
  273. package/packages/runtime/src/policy-engine.ts +1 -1
  274. package/packages/runtime/src/runtime-api.ts +1 -1
  275. package/packages/runtime/src/workspace-manager.ts +1 -1
  276. package/packages/scheduler/package.json +1 -1
  277. package/packages/scheduler-adapter/package.json +1 -1
  278. package/packages/session/README.md +18 -18
  279. package/packages/session/dist/history.js +3 -3
  280. package/packages/session/dist/index.js +5 -5
  281. package/packages/session/dist/manager.js +3 -3
  282. package/packages/session/dist/policy.js +2 -2
  283. package/packages/session/dist/store.js +2 -2
  284. package/packages/session/dist/types.js +1 -1
  285. package/packages/session/package.json +1 -1
  286. package/packages/session/src/history.ts +3 -3
  287. package/packages/session/src/index.ts +5 -5
  288. package/packages/session/src/manager.ts +3 -3
  289. package/packages/session/src/policy.ts +4 -4
  290. package/packages/session/src/store.ts +3 -3
  291. package/packages/session/src/types.ts +10 -10
  292. package/packages/session/tsconfig.tsbuildinfo +1 -1
  293. package/packages/session-api/package.json +1 -1
  294. package/packages/session-export/package.json +1 -1
  295. package/packages/shared-context/package.json +1 -1
  296. package/packages/skill-registry/package.json +1 -1
  297. package/packages/skill-registry/src/types.ts +4 -4
  298. package/packages/sprint-planner/package.json +1 -1
  299. package/packages/subscription-engine/package.json +1 -1
  300. package/packages/task-compiler/dist/compiler.js +7 -7
  301. package/packages/task-compiler/dist/decompose.js +11 -11
  302. package/packages/task-compiler/dist/file-scope.js +6 -6
  303. package/packages/task-compiler/dist/graph.js +6 -6
  304. package/packages/task-compiler/dist/index.js +2 -2
  305. package/packages/task-compiler/dist/types.js +5 -5
  306. package/packages/task-compiler/dist/validate.js +2 -2
  307. package/packages/task-compiler/dist/verification.js +2 -2
  308. package/packages/task-compiler/package.json +1 -1
  309. package/packages/task-compiler/src/command-policy.ts +1 -1
  310. package/packages/task-compiler/src/compiler.ts +7 -7
  311. package/packages/task-compiler/src/decompose.ts +11 -11
  312. package/packages/task-compiler/src/file-scope.ts +6 -6
  313. package/packages/task-compiler/src/graph.ts +6 -6
  314. package/packages/task-compiler/src/index.ts +3 -3
  315. package/packages/task-compiler/src/types.ts +14 -14
  316. package/packages/task-compiler/src/validate.ts +2 -2
  317. package/packages/task-compiler/src/verification.ts +2 -2
  318. package/packages/task-compiler/test/task-compiler.test.ts +10 -10
  319. package/packages/test-data-generator/README.md +13 -13
  320. package/packages/test-data-generator/dist/faker-adapter.js +4 -4
  321. package/packages/test-data-generator/dist/generator.js +3 -3
  322. package/packages/test-data-generator/dist/index.js +3 -3
  323. package/packages/test-data-generator/dist/types.js +1 -1
  324. package/packages/test-data-generator/package.json +1 -1
  325. package/packages/test-data-generator/src/faker-adapter.ts +4 -4
  326. package/packages/test-data-generator/src/generator.ts +3 -3
  327. package/packages/test-data-generator/src/index.ts +3 -3
  328. package/packages/test-data-generator/src/types.ts +9 -9
  329. package/packages/test-data-generator/tsconfig.tsbuildinfo +1 -1
  330. package/packages/test-generator/package.json +1 -1
  331. package/packages/token-estimation/package.json +1 -1
  332. package/packages/token-optimizer/package.json +1 -1
  333. package/packages/tui/package.json +1 -1
  334. package/packages/types/package.json +1 -1
  335. package/packages/types/src/agent-worker-types.ts +5 -5
  336. package/packages/types/src/runtime-types.ts +12 -12
  337. package/packages/types/tsconfig.tsbuildinfo +1 -1
  338. package/packages/workflow-events/package.json +1 -1
  339. package/packages/workspace-scanner/package.json +1 -1
  340. package/packages/worktree/package.json +1 -1
  341. package/renderer.ts +7 -7
  342. package/skills/harness-runtime/SKILL.md +15 -15
  343. package/packages/dependency-analyzer/dist/analyzer.d.ts +0 -17
  344. package/packages/dependency-analyzer/dist/analyzer.d.ts.map +0 -1
  345. package/packages/dependency-analyzer/dist/analyzer.js +0 -106
  346. package/packages/dependency-analyzer/dist/analyzer.js.map +0 -1
  347. package/packages/dependency-analyzer/dist/imports.d.ts +0 -12
  348. package/packages/dependency-analyzer/dist/imports.d.ts.map +0 -1
  349. package/packages/dependency-analyzer/dist/imports.js +0 -73
  350. package/packages/dependency-analyzer/dist/imports.js.map +0 -1
  351. package/packages/dependency-analyzer/dist/index.d.ts +0 -4
  352. package/packages/dependency-analyzer/dist/index.d.ts.map +0 -1
  353. package/packages/dependency-analyzer/dist/index.js +0 -3
  354. package/packages/dependency-analyzer/dist/index.js.map +0 -1
  355. package/packages/dependency-analyzer/dist/test/analyzer.test.js +0 -37
  356. package/packages/dependency-analyzer/dist/types.d.ts +0 -28
  357. package/packages/dependency-analyzer/dist/types.d.ts.map +0 -1
  358. package/packages/dependency-analyzer/dist/types.js +0 -5
  359. package/packages/dependency-analyzer/dist/types.js.map +0 -1
  360. package/packages/intent-analyzer/dist/analyzer.d.ts +0 -13
  361. package/packages/intent-analyzer/dist/analyzer.d.ts.map +0 -1
  362. package/packages/intent-analyzer/dist/analyzer.js +0 -72
  363. package/packages/intent-analyzer/dist/analyzer.js.map +0 -1
  364. package/packages/intent-analyzer/dist/index.d.ts +0 -3
  365. package/packages/intent-analyzer/dist/index.d.ts.map +0 -1
  366. package/packages/intent-analyzer/dist/index.js +0 -2
  367. package/packages/intent-analyzer/dist/index.js.map +0 -1
  368. package/packages/intent-analyzer/dist/test/analyzer.test.js +0 -56
  369. package/packages/intent-analyzer/dist/types.d.ts +0 -26
  370. package/packages/intent-analyzer/dist/types.d.ts.map +0 -1
  371. package/packages/intent-analyzer/dist/types.js +0 -7
  372. package/packages/intent-analyzer/dist/types.js.map +0 -1
  373. package/packages/workspace-scanner/dist/detect.d.ts +0 -3
  374. package/packages/workspace-scanner/dist/detect.d.ts.map +0 -1
  375. package/packages/workspace-scanner/dist/detect.js +0 -58
  376. package/packages/workspace-scanner/dist/detect.js.map +0 -1
  377. package/packages/workspace-scanner/dist/git.d.ts +0 -7
  378. package/packages/workspace-scanner/dist/git.d.ts.map +0 -1
  379. package/packages/workspace-scanner/dist/git.js +0 -75
  380. package/packages/workspace-scanner/dist/git.js.map +0 -1
  381. package/packages/workspace-scanner/dist/index.d.ts +0 -5
  382. package/packages/workspace-scanner/dist/index.d.ts.map +0 -1
  383. package/packages/workspace-scanner/dist/index.js +0 -4
  384. package/packages/workspace-scanner/dist/index.js.map +0 -1
  385. package/packages/workspace-scanner/dist/scanner.d.ts +0 -11
  386. package/packages/workspace-scanner/dist/scanner.d.ts.map +0 -1
  387. package/packages/workspace-scanner/dist/scanner.js +0 -46
  388. package/packages/workspace-scanner/dist/scanner.js.map +0 -1
  389. package/packages/workspace-scanner/dist/test/scanner.test.js +0 -34
  390. package/packages/workspace-scanner/dist/types.d.ts +0 -35
  391. package/packages/workspace-scanner/dist/types.d.ts.map +0 -1
  392. package/packages/workspace-scanner/dist/types.js +0 -5
  393. package/packages/workspace-scanner/dist/types.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,48 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [0.10.0](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.9.24...v0.10.0) (2026-07-30)
6
+
7
+
8
+ ### Features
9
+
10
+ * blackboard-coordinated loop controller with early exit ([f3cf3ea](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f3cf3ea479170dd75b7e9a7c3515dde230bb0da7))
11
+ * herdr inter-agent event bus for autonomous code review ([1490cdd](https://github.com/ManotLuijiu/pi-harness-runtime/commit/1490cddec80dac812065c3c681984524ad3194e1))
12
+ * loop controller for write-review cycles with early exit ([95066ce](https://github.com/ManotLuijiu/pi-harness-runtime/commit/95066ce8cb58c55eaa14d69fd826b5aaff680c16))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **clipboard:** pass UTF-8 bytes directly to xclip via stdin, avoid pipeline corruption ([051ca18](https://github.com/ManotLuijiu/pi-harness-runtime/commit/051ca18fb1deb1169a8a4da16aa9314d2e6ec66d))
18
+ * herdr-bus refactoring — rename publishers to *Simple variants ([d727591](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d7275913a89deb56a6bcfdb912ea9d17e3a80ce1))
19
+ * import LoopConfig from index.js, remove unused LoopNextAction import ([1100a4e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/1100a4e87433e54416259dfdad41bc5e0def19b3))
20
+ * periodic quota refresh every 15 minutes via setInterval ([f28e700](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f28e7004d089aeada1659f4d55a35461baba76fc))
21
+ * replace all Unicode box-drawing characters with ASCII ([dd4223a](https://github.com/ManotLuijiu/pi-harness-runtime/commit/dd4223abb0e25f746ee09ced05f6b3e40a10eb85))
22
+ * replace Unicode dashes and arrows with ASCII equivalents ([e9027e6](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e9027e689c06fdc1ca2ac4a6365ed6a6a0a384fd))
23
+ * trigger cookie sync on startup so pre-existing cookies aren't ignored ([2914299](https://github.com/ManotLuijiu/pi-harness-runtime/commit/2914299b8caa02acbb06620c7cb8e4870acfa40e))
24
+
25
+ ### [0.9.25](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.9.21...v0.9.25) (2026-07-27)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **ci:** explicitly list test files to exclude cookie auth tests in release workflow ([1c96002](https://github.com/ManotLuijiu/pi-harness-runtime/commit/1c9600232282a1ef9323300fbd763c962aff49f6))
31
+ * **ci:** skip browser auth tests in release workflow ([6117ed5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/6117ed5af11357c6f12d11f4cd8d3441de519043))
32
+ * **ci:** skip tests in release workflow ([8357ecd](https://github.com/ManotLuijiu/pi-harness-runtime/commit/8357ecd0b7d9c0c6ef81680902ca731da59a37c4))
33
+ * **e2e:** add OpenAIUsageResponse type to fix rate_limit TS error ([2ed0891](https://github.com/ManotLuijiu/pi-harness-runtime/commit/2ed08911410ec07815d828028db1a6c9eaf2df2c))
34
+ * **release:** add --workspaces=false to npm publish so only pi-harness-runtime is published ([31e715d](https://github.com/ManotLuijiu/pi-harness-runtime/commit/31e715d97e7fce5b82b503a95b86037d757db906))
35
+
36
+ ### [0.9.24](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.9.21...v0.9.24) (2026-07-27)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * **ci:** skip browser auth tests in release workflow ([6117ed5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/6117ed5af11357c6f12d11f4cd8d3441de519043))
42
+ * **e2e:** add OpenAIUsageResponse type to fix rate_limit TS error ([2ed0891](https://github.com/ManotLuijiu/pi-harness-runtime/commit/2ed08911410ec07815d828028db1a6c9eaf2df2c))
43
+ * **release:** add --workspaces=false to npm publish so only pi-harness-runtime is published ([31e715d](https://github.com/ManotLuijiu/pi-harness-runtime/commit/31e715d97e7fce5b82b503a95b86037d757db906))
44
+
45
+ ### [0.9.23](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.9.21...v0.9.23) (2026-07-27)
46
+
5
47
  ### [0.9.22](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.9.21...v0.9.22) (2026-07-27)
6
48
 
7
49
  ### [0.9.11](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.9.8...v0.9.11) (2026-07-23)
@@ -95,7 +137,7 @@ All notable changes to this project will be documented in this file. See [standa
95
137
  ### Bug Fixes
96
138
 
97
139
  * publish missing runtime modules ([3fc7058](https://github.com/ManotLuijiu/pi-harness-runtime/commit/3fc70586d0cd10f4d38eab67e4cadaec20aaeb56))
98
- * **release:** remove redundant Bump version step — was double-bumping version (0.7.10.8.0) when tag pushed ([413ad6d](https://github.com/ManotLuijiu/pi-harness-runtime/commit/413ad6d49356ec62b94e9a4e09d3475ef39bebd6))
140
+ * **release:** remove redundant Bump version step — was double-bumping version (0.7.1->0.8.0) when tag pushed ([413ad6d](https://github.com/ManotLuijiu/pi-harness-runtime/commit/413ad6d49356ec62b94e9a4e09d3475ef39bebd6))
99
141
 
100
142
  ## [0.9.0](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.7.1...v0.9.0) (2026-07-13)
101
143
 
@@ -105,7 +147,7 @@ All notable changes to this project will be documented in this file. See [standa
105
147
 
106
148
  ### Bug Fixes
107
149
 
108
- * **release:** remove redundant Bump version step — was double-bumping version (0.7.10.8.0) when tag pushed ([413ad6d](https://github.com/ManotLuijiu/pi-harness-runtime/commit/413ad6d49356ec62b94e9a4e09d3475ef39bebd6))
150
+ * **release:** remove redundant Bump version step — was double-bumping version (0.7.1->0.8.0) when tag pushed ([413ad6d](https://github.com/ManotLuijiu/pi-harness-runtime/commit/413ad6d49356ec62b94e9a4e09d3475ef39bebd6))
109
151
 
110
152
  ### [0.7.1](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.6.3...v0.7.1) (2026-07-13)
111
153
 
@@ -136,11 +178,11 @@ All notable changes to this project will be documented in this file. See [standa
136
178
 
137
179
  ### Changed
138
180
 
139
- * **Project rename**: `pi-usage-status` `pi-harness-runtime`
140
- * npm package name: `pi-usage-status` `pi-harness-runtime`
141
- * Repository: `ManotLuijiu/pi-usage-status` `ManotLuijiu/pi-harness-runtime`
142
- * Bundled skill: `usage-status` `harness-runtime` (file path `skills/usage-status/` `skills/harness-runtime/`)
143
- * Status bar key: `usage-status` `harness-runtime`
181
+ * **Project rename**: `pi-usage-status` -> `pi-harness-runtime`
182
+ * npm package name: `pi-usage-status` -> `pi-harness-runtime`
183
+ * Repository: `ManotLuijiu/pi-usage-status` -> `ManotLuijiu/pi-harness-runtime`
184
+ * Bundled skill: `usage-status` -> `harness-runtime` (file path `skills/usage-status/` -> `skills/harness-runtime/`)
185
+ * Status bar key: `usage-status` -> `harness-runtime`
144
186
  * **Data directory unchanged**: still `~/.pi/usage-status/` (preserves existing user data)
145
187
  * **Env var unchanged**: still `PI_USAGE_DIR` (preserves existing user configs)
146
188
  * **Extension symlink unchanged**: still `~/.pi/agent/extensions/pi-usage-status` (repointed to renamed project directory)
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)
5
5
  [![Platform](https://img.shields.io/badge/Platform-macOS%20|Linux-blue?style=for-the-badge)]()
6
6
 
7
- > ⚠️ **Beta Notice — Not Production Ready ⚠️**
7
+ > !️ **Beta Notice — Not Production Ready !️**
8
8
  > This project is in active development. Core features work.
9
9
 
10
10
  **Autonomous AI coding harness for pi: local token tracking + provider mirror + task orchestration.**
@@ -54,10 +54,10 @@ Requires Pi v0.37.3+.
54
54
  /harness start Build a REST API with JWT authentication
55
55
 
56
56
  # Runtime creates task graph:
57
- # task-001: Analyze requirements ready
58
- # task-002: Implement API depends on task-001
59
- # task-003: Write tests depends on task-002
60
- # task-004: Code review depends on task-003
57
+ # task-001: Analyze requirements -> ready
58
+ # task-002: Implement API -> depends on task-001
59
+ # task-003: Write tests -> depends on task-002
60
+ # task-004: Code review -> depends on task-003
61
61
 
62
62
  /harness status
63
63
  # Job: job-123, Status: running
@@ -74,48 +74,48 @@ Requires Pi v0.37.3+.
74
74
  # When all tasks complete:
75
75
  /harness status
76
76
  # Job: job-123, Status: ready_for_client
77
- # Tasks: 4/4 done
77
+ # Tasks: 4/4 done [x]
78
78
  ```
79
79
 
80
80
  ## Architecture
81
81
 
82
82
  ```
83
83
  pi-harness-runtime/
84
- ├── index.ts # Extension entry point
85
- ├── footer-status.ts # Footer bar renderer (local vs. mirror mode)
86
- ├── mirror.ts # Per-provider quota mirror (mirror.json)
87
- ├── harness/
88
- ├── job-state-machine.ts # 14-state lifecycle machine
89
- ├── task-graph.ts # DAG-based task management
90
- ├── master-planner.ts # Requirement task graph
91
- ├── loop-runtime.ts # Core execution loop
92
- ├── repair-engine.ts # Auto-fix failures
93
- ├── blackboard.ts # Agent coordination
94
- ├── context-window-manager.ts # Context tracking
95
- ├── agent-handoff.ts # Clean agent transitions
96
- ├── e2e/
97
- ├── minimax-quota-scraper.ts # Playwright MiniMax scraper
98
- └── playwright-runner.ts # Browser automation
99
- └── project-detector/
100
- └── detector.ts # Auto-detect project type
101
- ├── packages/
102
- ├── cookie-sanitizer/ # Live cookie-file sync via chokidar
103
- ├── providers/ # MiniMax, OpenAI, Codex adapters
104
- ├── quota-manager/ # Quota signal collection
105
- ├── auth/ # MiniMax browser auth
106
- └── worktree/ # Git worktree per task
107
- └── skills/
108
- └── harness-runtime/
109
- └── SKILL.md # Skill documentation
84
+ +-- index.ts # Extension entry point
85
+ +-- footer-status.ts # Footer bar renderer (local vs. mirror mode)
86
+ +-- mirror.ts # Per-provider quota mirror (mirror.json)
87
+ +-- harness/
88
+ | +-- job-state-machine.ts # 14-state lifecycle machine
89
+ | +-- task-graph.ts # DAG-based task management
90
+ | +-- master-planner.ts # Requirement -> task graph
91
+ | +-- loop-runtime.ts # Core execution loop
92
+ | +-- repair-engine.ts # Auto-fix failures
93
+ | +-- blackboard.ts # Agent coordination
94
+ | +-- context-window-manager.ts # Context tracking
95
+ | +-- agent-handoff.ts # Clean agent transitions
96
+ | +-- e2e/
97
+ | | +-- minimax-quota-scraper.ts # Playwright MiniMax scraper
98
+ | | +-- playwright-runner.ts # Browser automation
99
+ | +-- project-detector/
100
+ | +-- detector.ts # Auto-detect project type
101
+ +-- packages/
102
+ | +-- cookie-sanitizer/ # Live cookie-file sync via chokidar
103
+ | +-- providers/ # MiniMax, OpenAI, Codex adapters
104
+ | +-- quota-manager/ # Quota signal collection
105
+ | +-- auth/ # MiniMax browser auth
106
+ | +-- worktree/ # Git worktree per task
107
+ +-- skills/
108
+ +-- harness-runtime/
109
+ +-- SKILL.md # Skill documentation
110
110
  ```
111
111
 
112
112
  ## Job State Machine
113
113
 
114
114
  ```
115
- created planning queued running testing reviewing
116
-
115
+ created -> planning -> queued -> running -> testing -> reviewing
116
+ v v v v v
117
117
  cancelled blocked waiting_human repairing ready_for_client
118
-
118
+ v v
119
119
  paused_quota archived
120
120
  ```
121
121
 
@@ -136,18 +136,18 @@ All data stored locally in `~/.pi/`:
136
136
 
137
137
  ```
138
138
  ~/.pi/
139
- ├── usage-status/ # /usage data
140
- ├── usage.jsonl
141
- └── mirror.json # per-provider quota mirror
142
- ├── harness/ # /harness data
143
- └── jobs/
144
- └── <job-id>/
145
- ├── checkpoint.json
146
- ├── events.jsonl
147
- ├── task-graph.json
148
- ├── blackboard/
149
- └── repair-tasks.jsonl
150
- └── okf/ # (optional) Your custom OKF knowledge
139
+ +-- usage-status/ # /usage data
140
+ | +-- usage.jsonl
141
+ | +-- mirror.json # per-provider quota mirror
142
+ +-- harness/ # /harness data
143
+ | +-- jobs/
144
+ | +-- <job-id>/
145
+ | +-- checkpoint.json
146
+ | +-- events.jsonl
147
+ | +-- task-graph.json
148
+ | +-- blackboard/
149
+ | +-- repair-tasks.jsonl
150
+ +-- okf/ # (optional) Your custom OKF knowledge
151
151
  ```
152
152
 
153
153
  ## Custom OKF Knowledge (Optional)
@@ -156,9 +156,9 @@ Create `~/.pi/okf/` to add your custom knowledge that the runtime reads during c
156
156
 
157
157
  ```
158
158
  ~/.pi/okf/
159
- ├── <skill-name>.md # Your custom skill/procedure
160
- ├── <domain>.md # Domain-specific knowledge
161
- └── <project>.md # Project-specific rules
159
+ +-- <skill-name>.md # Your custom skill/procedure
160
+ +-- <domain>.md # Domain-specific knowledge
161
+ +-- <project>.md # Project-specific rules
162
162
  ```
163
163
 
164
164
  The runtime automatically detects and reads these files. If the folder doesn't exist, compilation proceeds without them.
@@ -221,7 +221,7 @@ MiniMax: cookies not found — drop any cookie file into
221
221
 
222
222
  The runtime watches `~/.pi-harness-runtime/cookies/` for cookie files. Drop any cookie export there — it syncs within ~1 second:
223
223
 
224
- 1. **Install EditThisCookie** Chrome extension export from `platform.minimax.io`
224
+ 1. **Install EditThisCookie** Chrome extension -> export from `platform.minimax.io`
225
225
  2. **Create the drop folder:**
226
226
 
227
227
  ```bash
package/footer-status.ts CHANGED
@@ -1,11 +1,16 @@
1
1
  import type { MirrorRecord, ProviderMirrorRecord } from "./mirror.ts";
2
- import { formatQuotaStatus } from "./harness/e2e/quota-status.js";
2
+
3
3
  import {
4
4
  parseContextWindowStatusLine,
5
5
  parseQuotaUsageStatusLine,
6
6
  type ParsedContextWindowUsage,
7
7
  type ParsedQuotaUsageData,
8
8
  } from "./status-parsers.ts";
9
+ import { getProviderLabel } from "./packages/types/src/ai-providers.js";
10
+ import {
11
+ providerHasContinuousScrape,
12
+ providerHasTUISignal,
13
+ } from "./packages/providers/src/provider-id.js";
9
14
 
10
15
  export type ParsedFooterStatusValue =
11
16
  | { kind: "quota"; value: ParsedQuotaUsageData }
@@ -39,46 +44,52 @@ export function parseFooterStatusValue(value: string): ParsedFooterStatusValue {
39
44
  return { kind: "unknown", value: null };
40
45
  }
41
46
 
42
- /** Display name for a provider id. Used as the footer label. */
47
+ /**
48
+ * Get display label for a provider id.
49
+ * Uses the canonical getProviderLabel() from packages/types/src/ai-providers.ts
50
+ * which handles all 9 known providers: minimax, openai, anthropic, glm,
51
+ * openrouter, openai-codex, deepseek, gemini, kimi.
52
+ */
43
53
  function providerDisplayName(provider: string | null | undefined): string {
44
54
  if (!provider) return "Provider";
45
- switch (provider) {
46
- case "minimax":
47
- return "MiniMax";
48
- case "openai":
49
- return "OpenAI";
50
- case "openai-codex":
51
- return "OpenAI Codex";
52
- case "glm":
53
- return "GLM";
54
- case "anthropic":
55
- return "Anthropic";
56
- case "openrouter":
57
- return "OpenRouter";
58
- default:
59
- return provider;
60
- }
55
+ return getProviderLabel(provider);
61
56
  }
62
57
 
63
- /** Hint shown when the provider has no usage data yet. */
58
+ /**
59
+ * Hint shown when the provider has no usage data yet.
60
+ * Covers all 9 known providers from KNOWN_AI_PROVIDERS.
61
+ */
64
62
  function missingDataHint(
65
63
  provider: string | null | undefined,
66
64
  hasCookieSource: boolean,
67
65
  ): string {
66
+ if (!provider) return "no usage source configured";
67
+
68
+ // MiniMax: needs cookies for continuous scrape
68
69
  if (provider === "minimax") {
69
- return "drop minimax cookies into ~/.pi-harness-runtime/cookies/";
70
+ return hasCookieSource
71
+ ? "no data yet (updates after first scrape)"
72
+ : "drop minimax cookies into ~/.pi-harness-runtime/cookies/";
70
73
  }
71
- if (provider === "openai-codex") {
72
- return "will update on first TUI limit signal";
73
- }
74
- if (
75
- provider === "openai" ||
76
- provider === "glm" ||
77
- provider === "anthropic" ||
78
- provider === "openrouter"
79
- ) {
74
+
75
+ // TUI signal providers: one-shot signal on limit hit
76
+ if (providerHasTUISignal(provider)) {
80
77
  return "no signal yet (updates on first limit hit)";
81
78
  }
79
+
80
+ // Providers without any tracking implementation yet
81
+ // deepseek, gemini, kimi, or any unknown provider
82
+ if (provider === "deepseek") {
83
+ return "deepseek usage tracking not yet implemented";
84
+ }
85
+ if (provider === "gemini") {
86
+ return "gemini usage tracking not yet implemented";
87
+ }
88
+ if (provider === "kimi") {
89
+ return "kimi usage tracking not yet implemented";
90
+ }
91
+
92
+ // Generic fallback for any other unknown provider
82
93
  if (!hasCookieSource) return "no usage source configured";
83
94
  return "no data yet";
84
95
  }
@@ -114,33 +125,62 @@ export function buildFooterStatusValue(
114
125
  const provider = activeProvider ?? view?.provider ?? null;
115
126
  const label = providerDisplayName(provider);
116
127
 
117
- // Continuous data path: a fresh record has 5h or weekly percentages.
128
+ // TUI-signal exhaustion path: fires when limit is hit (one-shot signal).
129
+ // This takes priority over continuous data to show the most recent state.
118
130
  if (
131
+ provider &&
132
+ view &&
133
+ view.exhausted &&
134
+ (view.limitType !== undefined ||
135
+ view.resets_at !== undefined ||
136
+ view.h5_resets_at !== undefined)
137
+ ) {
138
+ const reset = view.resets_at ?? view.h5_resets_at ?? "soon";
139
+ const limitType = view.limitType ?? "tokens";
140
+ return `${label}: limit hit (${limitType}), reset ${reset}`;
141
+ }
142
+
143
+ // Continuous data path: providers with continuous scrape (MiniMax has 5h+weekly, OpenAI has weekly-only)
144
+ if (
145
+ provider &&
146
+ providerHasContinuousScrape(provider) &&
119
147
  view &&
120
148
  freshness !== "expired" &&
121
149
  (view.h5_used_pct !== undefined || view.weekly_used_pct !== undefined)
122
150
  ) {
123
- const quotaStatus = formatQuotaStatus({
124
- provider: (provider ?? "minimax") as "minimax",
125
- h5UsedPct: view.h5_used_pct ?? 0,
126
- h5ResetsAt: view.h5_resets_at,
127
- weeklyUsedPct: view.weekly_used_pct ?? 0,
128
- weeklyResetsAt: view.weekly_resets_at,
129
- scrapedAt: view.synced_at,
130
- });
151
+ const weeklyPct = view.weekly_used_pct ?? 0;
152
+ const weeklyLeft = Math.max(0, 100 - weeklyPct);
153
+ const weeklyResets = view.weekly_resets_at ?? "soon";
154
+
155
+ let statusLine: string;
156
+ if (view.h5_used_pct !== undefined) {
157
+ // MiniMax: has both 5h and weekly windows
158
+ const h5Pct = view.h5_used_pct;
159
+ const h5Left = Math.max(0, 100 - h5Pct);
160
+ statusLine = `5h: ${h5Left.toFixed(0)}% left · week: ${weeklyLeft.toFixed(0)}% left`;
161
+ } else {
162
+ // OpenAI: weekly-only (no 5h window)
163
+ statusLine = `week: ${weeklyLeft.toFixed(0)}% left (resets ${weeklyResets})`;
164
+ }
165
+
131
166
  const freshnessSuffix =
132
167
  freshness === "fresh" || freshness === "missing" ? "" : ` · ${freshness}`;
133
- return `${label}: ${quotaStatus.extended}${freshnessSuffix}`;
168
+ return `${label}: ${statusLine}${freshnessSuffix}`;
134
169
  }
135
170
 
136
- // TUI-signal path: an exhausted record from a limit hit.
171
+ // TUI signal providers (OpenAI, Anthropic, GLM, OpenRouter):
172
+ // Show monitoring status when we have a record but haven't hit limits.
173
+ // These providers only emit data when a limit is hit.
137
174
  if (
175
+ provider &&
176
+ providerHasTUISignal(provider) &&
138
177
  view &&
139
- view.exhausted &&
140
- (view.limitType !== undefined || view.resets_at !== undefined)
178
+ freshness !== "expired"
141
179
  ) {
142
- const reset = view.resets_at ?? view.h5_resets_at ?? "soon";
143
- return `${label}: limit hit (${view.limitType ?? "tokens"}), reset ${reset}`;
180
+ // If exhausted is not set, we're monitoring normally
181
+ if (!view.exhausted) {
182
+ return `${label}: monitoring (no limits hit)`;
183
+ }
144
184
  }
145
185
 
146
186
  // Discoverable hint when we have no data yet.
@@ -256,7 +256,7 @@ export class AutoCompactEngine {
256
256
  return existsSync(join(this.rootDir, "continue_prompt.md"));
257
257
  }
258
258
 
259
- // ─── Private Methods ────────────────────────────────────────────────
259
+ // --- Private Methods ------------------------------------------------
260
260
 
261
261
  private ensureDir(): void {
262
262
  if (!existsSync(this.rootDir)) {
@@ -58,17 +58,20 @@ export function scheduleAutoResume(
58
58
 
59
59
  const resetEpoch = record.h5_resets_at_epoch;
60
60
  const now = Date.now();
61
- const delayMs = Math.max(resetEpoch - now - RESUME_BUFFER_MS, MIN_RESUME_DELAY_MS);
61
+ const delayMs = Math.max(
62
+ resetEpoch - now - RESUME_BUFFER_MS,
63
+ MIN_RESUME_DELAY_MS,
64
+ );
62
65
  const resumeAt = now + delayMs;
63
66
  const resumeAtIso = new Date(resumeAt).toISOString();
64
67
 
65
68
  // Persist to checkpoint so resumeAt survives worker restart
66
69
  machine.setResumeTime(resumeAtIso);
67
70
 
68
- console.log(
69
- `[auto-quota-resume] ${provider} 5h quota exhausted.` +
70
- ` Auto-resume scheduled at ${resumeAtIso} (in ${Math.round(delayMs / 1000)}s)`,
71
- );
71
+ // console.log(
72
+ // `[auto-quota-resume] ${provider} 5h quota exhausted.` +
73
+ // ` Auto-resume scheduled at ${resumeAtIso} (in ${Math.round(delayMs / 1000)}s)`,
74
+ // );
72
75
 
73
76
  const timeout = setTimeout(async () => {
74
77
  activeTimers.delete(jobId);
@@ -84,10 +87,10 @@ export function scheduleAutoResume(
84
87
  if (updated?.h5_resets_at_epoch) {
85
88
  const stillExhausted = Date.now() < updated.h5_resets_at_epoch;
86
89
  if (stillExhausted) {
87
- console.log(
88
- `[auto-quota-resume] ${provider} still exhausted at scheduled time.` +
89
- ` Re-scheduling...`,
90
- );
90
+ // console.log(
91
+ // `[auto-quota-resume] ${provider} still exhausted at scheduled time.` +
92
+ // ` Re-scheduling...`,
93
+ // );
91
94
  scheduleAutoResume(provider, machine, mirrorStore);
92
95
  return;
93
96
  }
@@ -95,9 +98,9 @@ export function scheduleAutoResume(
95
98
 
96
99
  const result = await machine.transition("running");
97
100
  if (result.success) {
98
- console.log(
99
- `[auto-quota-resume] Job ${jobId} auto-resumed after ${provider} 5h quota reset.`,
100
- );
101
+ // console.log(
102
+ // `[auto-quota-resume] Job ${jobId} auto-resumed after ${provider} 5h quota reset.`,
103
+ // );
101
104
  } else {
102
105
  console.error(
103
106
  `[auto-quota-resume] Auto-resume failed for ${jobId}: ${result.error}`,
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Autonomous Review Agent — polls for code.written events and auto-triggers review.
3
+ * Human on the loop, not in the loop.
4
+ */
5
+ import { existsSync, readFileSync, writeFileSync } from "fs";
6
+ import { join } from "path";
7
+ import {
8
+ createHerdrBus,
9
+ ensureHerdrWorkspace,
10
+ publishReviewCompletedSimple,
11
+ publishReviewRequestedSimple,
12
+ } from "../packages/event-bus/src/herdr-bus.js";
13
+
14
+ const AGENT_ID = "review-agent";
15
+ const REVIEW_TIMEOUT_MS = 5 * 60 * 1000;
16
+
17
+ type CodeWrittenPayload = { taskId: string; files: string[]; branch?: string };
18
+
19
+ async function runReview(
20
+ bus: ReturnType<typeof createHerdrBus>,
21
+ codePayload: CodeWrittenPayload,
22
+ ): Promise<void> {
23
+ const { taskId, files } = codePayload;
24
+ const reportFile = join(
25
+ ensureHerdrWorkspace().reviews,
26
+ `${taskId}-review.md`,
27
+ );
28
+ console.log(`[${AGENT_ID}] Reviewing task ${taskId}, ${files.length} files`);
29
+
30
+ try {
31
+ publishReviewRequestedSimple(bus, taskId, taskId);
32
+
33
+ const fileBlocks = await Promise.all(
34
+ files.map(async (file) => {
35
+ const content = existsSync(file)
36
+ ? readFileSync(file, "utf-8").slice(0, 5000)
37
+ : `[Not found: ${file}]`;
38
+ return `## ${file}\n\n\`\`\`\n${content}\n\`\`\`\n`;
39
+ }),
40
+ );
41
+
42
+ const report = `# Code Review — Task ${taskId}
43
+ ## Files: ${files.join(", ")}
44
+
45
+ > Auto-generated. GPT review tab fills this in.
46
+
47
+ ${fileBlocks.join("\n")}
48
+ `;
49
+ writeFileSync(reportFile, report);
50
+ console.log(`[${AGENT_ID}] Report: ${reportFile}`);
51
+ publishReviewCompletedSimple(bus, taskId, reportFile, "changes_requested");
52
+
53
+ // Wait for GPT tab to update
54
+ await waitForGptReview(reportFile);
55
+ } catch (err) {
56
+ console.error(`[${AGENT_ID}] Review failed:`, err);
57
+ publishReviewCompletedSimple(bus, taskId, reportFile, "failed");
58
+ }
59
+ }
60
+
61
+ async function waitForGptReview(reportFile: string): Promise<void> {
62
+ const deadline = Date.now() + REVIEW_TIMEOUT_MS;
63
+ while (Date.now() < deadline) {
64
+ if (existsSync(reportFile)) {
65
+ const content = readFileSync(reportFile, "utf-8");
66
+ if (!content.includes("Pending")) return;
67
+ }
68
+ await new Promise((r) => setTimeout(r, 5000));
69
+ }
70
+ console.log(`[${AGENT_ID}] GPT review timed out`);
71
+ }
72
+
73
+ async function main(): Promise<void> {
74
+ console.log(`[${AGENT_ID}] Starting...`);
75
+ const bus = createHerdrBus(AGENT_ID);
76
+ ensureHerdrWorkspace();
77
+ bus.subscribe("code.written");
78
+ bus.startPolling(async (payload) => {
79
+ if (payload.topic === "code.written") {
80
+ const data = payload.data as CodeWrittenPayload;
81
+ if (data.files?.length) runReview(bus, data).catch(console.error);
82
+ }
83
+ });
84
+ console.log(`[${AGENT_ID}] Workspace: ${bus.getWorkspace()}`);
85
+ console.log(`[${AGENT_ID}] Polling for code.written...`);
86
+ }
87
+
88
+ main().catch(console.error);