pi-harness-runtime 0.9.25 → 1.1.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 (350) hide show
  1. package/CHANGELOG.md +49 -7
  2. package/README.md +173 -51
  3. package/harness/auto-compact.ts +1 -1
  4. package/harness/autonomous-review.ts +88 -0
  5. package/harness/context-compact-orchestrator.ts +23 -23
  6. package/harness/context-window-manager.ts +5 -5
  7. package/harness/continue-prompt.ts +3 -3
  8. package/harness/e2e/minimax-quota-scraper.ts +5 -5
  9. package/harness/e2e/openai-quota-scraper.ts +13 -8
  10. package/harness/forked-summarizer.ts +4 -4
  11. package/harness/herdr-agents.ts +91 -0
  12. package/harness/index.ts +5 -5
  13. package/harness/loop-code-agent.ts +284 -0
  14. package/harness/loop-controller.ts +201 -0
  15. package/harness/loop-review-agent.ts +295 -0
  16. package/harness/loop-runtime.ts +10 -10
  17. package/harness/loop-types.ts +118 -0
  18. package/harness/notification-events.ts +3 -3
  19. package/harness/output-limit-handler.ts +1 -1
  20. package/harness/partial-recovery.ts +3 -3
  21. package/harness/session-memory.ts +5 -5
  22. package/index.ts +139 -34
  23. package/package.json +1 -1
  24. package/packages/a2a-adapter/package.json +1 -1
  25. package/packages/a2a-adapter/src/types.ts +5 -5
  26. package/packages/auth/package.json +1 -1
  27. package/packages/autonomous-refactor/package.json +1 -1
  28. package/packages/autonomous-runtime/dist/inbox.d.ts +3 -3
  29. package/packages/autonomous-runtime/dist/inbox.js +12 -12
  30. package/packages/autonomous-runtime/dist/lease.js +14 -14
  31. package/packages/autonomous-runtime/dist/types.js +1 -1
  32. package/packages/autonomous-runtime/package.json +1 -1
  33. package/packages/autonomous-runtime/src/inbox.ts +12 -12
  34. package/packages/autonomous-runtime/src/lease.ts +15 -15
  35. package/packages/autonomous-runtime/src/types.ts +13 -13
  36. package/packages/autonomous-runtime/tsconfig.tsbuildinfo +1 -1
  37. package/packages/cache-strategy/package.json +1 -1
  38. package/packages/capability-registry/dist/types.js +1 -1
  39. package/packages/capability-registry/package.json +1 -1
  40. package/packages/capability-registry/src/types.ts +5 -5
  41. package/packages/checkpoint/README.md +6 -6
  42. package/packages/checkpoint/dist/differ.js +2 -2
  43. package/packages/checkpoint/dist/engine.js +3 -3
  44. package/packages/checkpoint/dist/index.js +5 -5
  45. package/packages/checkpoint/dist/storage.js +3 -3
  46. package/packages/checkpoint/dist/types.js +1 -1
  47. package/packages/checkpoint/package.json +1 -1
  48. package/packages/checkpoint/src/differ.ts +2 -2
  49. package/packages/checkpoint/src/engine.ts +3 -3
  50. package/packages/checkpoint/src/index.ts +5 -5
  51. package/packages/checkpoint/src/storage.ts +3 -3
  52. package/packages/checkpoint/src/types.ts +10 -10
  53. package/packages/checkpoint/tsconfig.tsbuildinfo +1 -1
  54. package/packages/cli-plugin-sdk/package.json +1 -1
  55. package/packages/clipboard/dist/src/clipboard.d.ts.map +1 -1
  56. package/packages/clipboard/dist/src/clipboard.js +15 -7
  57. package/packages/clipboard/dist/src/clipboard.js.map +1 -1
  58. package/packages/clipboard/dist/src/copy-sync.d.ts +27 -0
  59. package/packages/clipboard/dist/src/copy-sync.d.ts.map +1 -0
  60. package/packages/clipboard/dist/src/copy-sync.js +170 -0
  61. package/packages/clipboard/dist/src/copy-sync.js.map +1 -0
  62. package/packages/clipboard/dist/src/gist-relay.d.ts +48 -0
  63. package/packages/clipboard/dist/src/gist-relay.d.ts.map +1 -0
  64. package/packages/clipboard/dist/src/gist-relay.js +186 -0
  65. package/packages/clipboard/dist/src/gist-relay.js.map +1 -0
  66. package/packages/clipboard/dist/src/github-login.d.ts +16 -0
  67. package/packages/clipboard/dist/src/github-login.d.ts.map +1 -0
  68. package/packages/clipboard/dist/src/github-login.js +69 -0
  69. package/packages/clipboard/dist/src/github-login.js.map +1 -0
  70. package/packages/clipboard/dist/src/index.d.ts +2 -0
  71. package/packages/clipboard/dist/src/index.d.ts.map +1 -1
  72. package/packages/clipboard/dist/src/index.js +2 -1
  73. package/packages/clipboard/dist/src/index.js.map +1 -1
  74. package/packages/clipboard/package.json +1 -1
  75. package/packages/clipboard/src/clipboard.ts +16 -9
  76. package/packages/clipboard/src/copy-sync.ts +201 -0
  77. package/packages/clipboard/src/gist-relay.ts +240 -0
  78. package/packages/clipboard/src/github-login.ts +107 -0
  79. package/packages/clipboard/src/index.ts +2 -0
  80. package/packages/clipboard/test/mojibake.test.mjs +143 -0
  81. package/packages/code-generation/README.md +13 -13
  82. package/packages/code-generation/dist/faker.js +4 -4
  83. package/packages/code-generation/dist/generator.js +3 -3
  84. package/packages/code-generation/dist/index.js +3 -3
  85. package/packages/code-generation/dist/templates/registry.js +1 -1
  86. package/packages/code-generation/dist/types.js +1 -1
  87. package/packages/code-generation/package.json +1 -1
  88. package/packages/code-generation/src/faker.ts +5 -5
  89. package/packages/code-generation/src/generator.ts +4 -4
  90. package/packages/code-generation/src/index.ts +3 -3
  91. package/packages/code-generation/src/templates/registry.ts +1 -1
  92. package/packages/code-generation/src/types.ts +10 -10
  93. package/packages/code-generation/tsconfig.tsbuildinfo +1 -1
  94. package/packages/code-review/README.md +13 -13
  95. package/packages/code-review/dist/engine.js +3 -3
  96. package/packages/code-review/dist/index.js +3 -3
  97. package/packages/code-review/dist/types.js +1 -1
  98. package/packages/code-review/package.json +1 -1
  99. package/packages/code-review/src/engine.ts +3 -3
  100. package/packages/code-review/src/index.ts +3 -3
  101. package/packages/code-review/src/types.ts +10 -10
  102. package/packages/code-review/tsconfig.tsbuildinfo +1 -1
  103. package/packages/codex-adapter/package.json +1 -1
  104. package/packages/context-compiler/dist/compiler.js +1 -1
  105. package/packages/context-compiler/package.json +1 -1
  106. package/packages/context-compiler/src/compiler.ts +1 -1
  107. package/packages/context-compiler/src/types.ts +11 -11
  108. package/packages/context-compiler/test/context-compiler.test.ts +11 -11
  109. package/packages/context-discovery/package.json +1 -1
  110. package/packages/context-manager/package.json +1 -1
  111. package/packages/cookie-sanitizer/README.md +27 -27
  112. package/packages/cookie-sanitizer/package.json +1 -1
  113. package/packages/cost-optimizer/package.json +1 -1
  114. package/packages/cost-optimizer/src/types.ts +5 -5
  115. package/packages/dependency-analyzer/package.json +1 -1
  116. package/packages/django-plugin/dist/analyzer.js +7 -7
  117. package/packages/django-plugin/package.json +1 -1
  118. package/packages/django-plugin/src/analyzer.ts +7 -7
  119. package/packages/doc-generator/package.json +1 -1
  120. package/packages/evaluation-engine/dist/engine.js +9 -9
  121. package/packages/evaluation-engine/package.json +1 -1
  122. package/packages/evaluation-engine/src/engine.ts +9 -9
  123. package/packages/evaluation-engine/src/types.ts +3 -3
  124. package/packages/evaluation-runner/package.json +1 -1
  125. package/packages/event-bus/dist/src/herdr-bus.d.ts +121 -0
  126. package/packages/event-bus/dist/src/herdr-bus.d.ts.map +1 -0
  127. package/packages/event-bus/dist/src/herdr-bus.js +322 -0
  128. package/packages/event-bus/dist/src/herdr-bus.js.map +1 -0
  129. package/packages/event-bus/dist/src/index.d.ts +2 -0
  130. package/packages/event-bus/dist/src/index.d.ts.map +1 -1
  131. package/packages/event-bus/dist/src/index.js +1 -0
  132. package/packages/event-bus/dist/src/index.js.map +1 -1
  133. package/packages/event-bus/package.json +1 -1
  134. package/packages/event-bus/src/herdr-bus.ts +525 -0
  135. package/packages/event-bus/src/index.ts +29 -0
  136. package/packages/event-store/package.json +1 -1
  137. package/packages/experience-replay/dist/replay.js +7 -7
  138. package/packages/experience-replay/package.json +1 -1
  139. package/packages/experience-replay/src/replay.ts +7 -7
  140. package/packages/experience-replay/src/types.ts +5 -5
  141. package/packages/feedback-collector/package.json +1 -1
  142. package/packages/framework-detector/README.md +18 -18
  143. package/packages/framework-detector/dist/detector.js +3 -3
  144. package/packages/framework-detector/dist/index.js +3 -3
  145. package/packages/framework-detector/dist/signatures/registry.js +24 -24
  146. package/packages/framework-detector/dist/types.js +1 -1
  147. package/packages/framework-detector/package.json +1 -1
  148. package/packages/framework-detector/src/detector.ts +3 -3
  149. package/packages/framework-detector/src/index.ts +3 -3
  150. package/packages/framework-detector/src/signatures/registry.ts +24 -24
  151. package/packages/framework-detector/src/types.ts +7 -7
  152. package/packages/framework-detector/tsconfig.tsbuildinfo +1 -1
  153. package/packages/framework-plugin-sdk/README.md +23 -23
  154. package/packages/framework-plugin-sdk/dist/index.js +2 -2
  155. package/packages/framework-plugin-sdk/dist/manager.js +3 -3
  156. package/packages/framework-plugin-sdk/dist/types.js +2 -2
  157. package/packages/framework-plugin-sdk/package.json +1 -1
  158. package/packages/framework-plugin-sdk/src/index.ts +2 -2
  159. package/packages/framework-plugin-sdk/src/manager.ts +3 -3
  160. package/packages/framework-plugin-sdk/src/types.ts +10 -10
  161. package/packages/framework-plugin-sdk/tsconfig.tsbuildinfo +1 -1
  162. package/packages/frappe-plugin/dist/analyzer.js +8 -8
  163. package/packages/frappe-plugin/dist/types.js +1 -1
  164. package/packages/frappe-plugin/package.json +1 -1
  165. package/packages/frappe-plugin/src/analyzer.ts +8 -8
  166. package/packages/frappe-plugin/src/types.ts +10 -10
  167. package/packages/generic-web-plugin/dist/analyzer.js +5 -5
  168. package/packages/generic-web-plugin/package.json +1 -1
  169. package/packages/generic-web-plugin/src/analyzer.ts +5 -5
  170. package/packages/health-monitor/package.json +1 -1
  171. package/packages/health-monitor/src/monitor.ts +1 -1
  172. package/packages/intent-analyzer/package.json +1 -1
  173. package/packages/laravel-plugin/dist/analyzer.js +11 -11
  174. package/packages/laravel-plugin/package.json +1 -1
  175. package/packages/laravel-plugin/src/analyzer.ts +11 -11
  176. package/packages/learning-engine/dist/engine.js +5 -5
  177. package/packages/learning-engine/dist/types.js +1 -1
  178. package/packages/learning-engine/package.json +1 -1
  179. package/packages/learning-engine/src/engine.ts +5 -5
  180. package/packages/learning-engine/src/types.ts +6 -6
  181. package/packages/mcp-adapter/package.json +1 -1
  182. package/packages/memory-engine/dist/engine.js +8 -8
  183. package/packages/memory-engine/dist/types.js +2 -2
  184. package/packages/memory-engine/package.json +1 -1
  185. package/packages/memory-engine/src/engine.ts +8 -8
  186. package/packages/memory-engine/src/types.ts +9 -9
  187. package/packages/model-registry/package.json +1 -1
  188. package/packages/model-registry/src/types.ts +4 -4
  189. package/packages/nextjs-plugin/dist/analyzer.js +9 -9
  190. package/packages/nextjs-plugin/package.json +1 -1
  191. package/packages/nextjs-plugin/src/analyzer.ts +9 -9
  192. package/packages/notification/dist/notification-center.js +1 -1
  193. package/packages/notification/package.json +1 -1
  194. package/packages/notification/src/notification-center.ts +1 -1
  195. package/packages/observability/dist/alerts.js +2 -2
  196. package/packages/observability/dist/health.js +4 -4
  197. package/packages/observability/dist/index.js +6 -6
  198. package/packages/observability/dist/logger.js +7 -7
  199. package/packages/observability/dist/metrics.js +11 -11
  200. package/packages/observability/dist/tracer.js +3 -3
  201. package/packages/observability/dist/types.js +1 -1
  202. package/packages/observability/package.json +1 -1
  203. package/packages/observability/src/alerts.ts +2 -2
  204. package/packages/observability/src/health.ts +4 -4
  205. package/packages/observability/src/index.ts +6 -6
  206. package/packages/observability/src/logger.ts +7 -7
  207. package/packages/observability/src/metrics.ts +11 -11
  208. package/packages/observability/src/tracer.ts +3 -3
  209. package/packages/observability/src/types.ts +7 -7
  210. package/packages/observability/test/observability.test.ts +4 -4
  211. package/packages/observability/tsconfig.tsbuildinfo +1 -1
  212. package/packages/performance-optimizer/dist/optimizer.js +1 -1
  213. package/packages/performance-optimizer/package.json +1 -1
  214. package/packages/performance-optimizer/src/optimizer.ts +1 -1
  215. package/packages/performance-optimizer/src/types.ts +4 -4
  216. package/packages/privilege-broker/package.json +1 -1
  217. package/packages/project-analyzer/dist/analyzer.js +4 -4
  218. package/packages/project-analyzer/dist/index.js +8 -8
  219. package/packages/project-analyzer/dist/signals.js +3 -3
  220. package/packages/project-analyzer/dist/types.js +1 -1
  221. package/packages/project-analyzer/package.json +1 -1
  222. package/packages/project-analyzer/src/analyzer.ts +4 -4
  223. package/packages/project-analyzer/src/index.ts +9 -9
  224. package/packages/project-analyzer/src/signals.ts +4 -4
  225. package/packages/project-analyzer/src/types.ts +15 -15
  226. package/packages/project-analyzer/test/index.test.ts +17 -17
  227. package/packages/project-analyzer/tsconfig.tsbuildinfo +1 -1
  228. package/packages/projection-engine/package.json +1 -1
  229. package/packages/prompt-compiler/dist/section-builder.js +1 -1
  230. package/packages/prompt-compiler/dist/types.js +3 -3
  231. package/packages/prompt-compiler/package.json +1 -1
  232. package/packages/prompt-compiler/src/section-builder.ts +1 -1
  233. package/packages/prompt-compiler/src/types.ts +12 -12
  234. package/packages/prompt-compiler/test/prompt-compiler.test.ts +12 -12
  235. package/packages/prompt-versioning/package.json +1 -1
  236. package/packages/provider-adapter-sdk/dist/builder.js +1 -1
  237. package/packages/provider-adapter-sdk/dist/index.js +5 -5
  238. package/packages/provider-adapter-sdk/dist/registry.js +1 -1
  239. package/packages/provider-adapter-sdk/dist/tester.js +1 -1
  240. package/packages/provider-adapter-sdk/dist/types.js +1 -1
  241. package/packages/provider-adapter-sdk/package.json +1 -1
  242. package/packages/provider-adapter-sdk/src/builder.ts +1 -1
  243. package/packages/provider-adapter-sdk/src/index.ts +6 -6
  244. package/packages/provider-adapter-sdk/src/registry.ts +1 -1
  245. package/packages/provider-adapter-sdk/src/tester.ts +1 -1
  246. package/packages/provider-adapter-sdk/src/types.ts +5 -5
  247. package/packages/provider-adapter-sdk/tsconfig.tsbuildinfo +1 -1
  248. package/packages/provider-router/package.json +1 -1
  249. package/packages/provider-router/src/types.ts +4 -4
  250. package/packages/provider-selector/package.json +1 -1
  251. package/packages/providers/dist/deepagents-adapter.js +1 -1
  252. package/packages/providers/package.json +1 -1
  253. package/packages/providers/src/deepagents-adapter.ts +1 -1
  254. package/packages/quota-manager/package.json +1 -1
  255. package/packages/rate-limiter/package.json +1 -1
  256. package/packages/react-vite-plugin/dist/analyzer.js +7 -7
  257. package/packages/react-vite-plugin/package.json +1 -1
  258. package/packages/react-vite-plugin/src/analyzer.ts +7 -7
  259. package/packages/release-manager/package.json +1 -1
  260. package/packages/requirement-compiler/dist/compiler.js +17 -17
  261. package/packages/requirement-compiler/dist/types.js +2 -2
  262. package/packages/requirement-compiler/package.json +1 -1
  263. package/packages/requirement-compiler/src/compiler.ts +17 -17
  264. package/packages/requirement-compiler/src/types.ts +21 -21
  265. package/packages/requirement-compiler/test/requirement-compiler.test.ts +17 -17
  266. package/packages/runtime/dist/command-executor.js +1 -1
  267. package/packages/runtime/dist/local-runtime-agent.js +1 -1
  268. package/packages/runtime/dist/policy-engine.js +1 -1
  269. package/packages/runtime/dist/runtime-api.js +1 -1
  270. package/packages/runtime/dist/workspace-manager.js +1 -1
  271. package/packages/runtime/package.json +1 -1
  272. package/packages/runtime/src/command-executor.ts +1 -1
  273. package/packages/runtime/src/local-runtime-agent.ts +1 -1
  274. package/packages/runtime/src/policy-engine.ts +1 -1
  275. package/packages/runtime/src/runtime-api.ts +1 -1
  276. package/packages/runtime/src/workspace-manager.ts +1 -1
  277. package/packages/scheduler/package.json +1 -1
  278. package/packages/scheduler-adapter/package.json +1 -1
  279. package/packages/session/README.md +18 -18
  280. package/packages/session/dist/history.js +3 -3
  281. package/packages/session/dist/index.js +5 -5
  282. package/packages/session/dist/manager.js +3 -3
  283. package/packages/session/dist/policy.js +2 -2
  284. package/packages/session/dist/store.js +2 -2
  285. package/packages/session/dist/types.js +1 -1
  286. package/packages/session/package.json +1 -1
  287. package/packages/session/src/history.ts +3 -3
  288. package/packages/session/src/index.ts +5 -5
  289. package/packages/session/src/manager.ts +3 -3
  290. package/packages/session/src/policy.ts +4 -4
  291. package/packages/session/src/store.ts +3 -3
  292. package/packages/session/src/types.ts +10 -10
  293. package/packages/session/tsconfig.tsbuildinfo +1 -1
  294. package/packages/session-api/package.json +1 -1
  295. package/packages/session-export/package.json +1 -1
  296. package/packages/shared-context/package.json +1 -1
  297. package/packages/skill-registry/package.json +1 -1
  298. package/packages/skill-registry/src/types.ts +4 -4
  299. package/packages/sprint-planner/package.json +1 -1
  300. package/packages/subscription-engine/package.json +1 -1
  301. package/packages/task-compiler/dist/compiler.js +7 -7
  302. package/packages/task-compiler/dist/decompose.js +11 -11
  303. package/packages/task-compiler/dist/file-scope.js +6 -6
  304. package/packages/task-compiler/dist/graph.js +6 -6
  305. package/packages/task-compiler/dist/index.js +2 -2
  306. package/packages/task-compiler/dist/types.js +5 -5
  307. package/packages/task-compiler/dist/validate.js +2 -2
  308. package/packages/task-compiler/dist/verification.js +2 -2
  309. package/packages/task-compiler/package.json +1 -1
  310. package/packages/task-compiler/src/command-policy.ts +1 -1
  311. package/packages/task-compiler/src/compiler.ts +7 -7
  312. package/packages/task-compiler/src/decompose.ts +11 -11
  313. package/packages/task-compiler/src/file-scope.ts +6 -6
  314. package/packages/task-compiler/src/graph.ts +6 -6
  315. package/packages/task-compiler/src/index.ts +3 -3
  316. package/packages/task-compiler/src/types.ts +14 -14
  317. package/packages/task-compiler/src/validate.ts +2 -2
  318. package/packages/task-compiler/src/verification.ts +2 -2
  319. package/packages/task-compiler/test/task-compiler.test.ts +10 -10
  320. package/packages/test-data-generator/README.md +13 -13
  321. package/packages/test-data-generator/dist/faker-adapter.js +4 -4
  322. package/packages/test-data-generator/dist/generator.js +3 -3
  323. package/packages/test-data-generator/dist/index.js +3 -3
  324. package/packages/test-data-generator/dist/types.js +1 -1
  325. package/packages/test-data-generator/package.json +1 -1
  326. package/packages/test-data-generator/src/faker-adapter.ts +4 -4
  327. package/packages/test-data-generator/src/generator.ts +3 -3
  328. package/packages/test-data-generator/src/index.ts +3 -3
  329. package/packages/test-data-generator/src/types.ts +9 -9
  330. package/packages/test-data-generator/tsconfig.tsbuildinfo +1 -1
  331. package/packages/test-generator/package.json +1 -1
  332. package/packages/todo-bd-sync/package.json +22 -0
  333. package/packages/todo-bd-sync/src/detector.ts +150 -0
  334. package/packages/todo-bd-sync/src/extension.ts +101 -0
  335. package/packages/todo-bd-sync/src/index.ts +401 -0
  336. package/packages/todo-bd-sync/src/sync.ts +322 -0
  337. package/packages/todo-bd-sync/src/todo-reminder.ts +418 -0
  338. package/packages/todo-bd-sync/src/types.ts +137 -0
  339. package/packages/token-estimation/package.json +1 -1
  340. package/packages/token-optimizer/package.json +1 -1
  341. package/packages/tui/package.json +1 -1
  342. package/packages/types/package.json +1 -1
  343. package/packages/types/src/agent-worker-types.ts +5 -5
  344. package/packages/types/src/runtime-types.ts +12 -12
  345. package/packages/types/tsconfig.tsbuildinfo +1 -1
  346. package/packages/workflow-events/package.json +1 -1
  347. package/packages/workspace-scanner/package.json +1 -1
  348. package/packages/worktree/package.json +1 -1
  349. package/renderer.ts +7 -7
  350. package/skills/harness-runtime/SKILL.md +15 -15
@@ -6,23 +6,23 @@
6
6
  */
7
7
  import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync, } from "node:fs";
8
8
  import { getInboxDir, getTasksPath } from "./types.js";
9
- // ─── Errors ───────────────────────────────────────────────────────────────────
9
+ // --- Errors -------------------------------------------------------------------
10
10
  export class InboxError extends Error {
11
11
  constructor(msg) {
12
12
  super(`[InboxError] ${msg}`);
13
13
  this.name = "InboxError";
14
14
  }
15
15
  }
16
- // ─── TaskInbox ────────────────────────────────────────────────────────────────
16
+ // --- TaskInbox ----------------------------------------------------------------
17
17
  /**
18
18
  * Manages the append-only task inbox at `~/.pi/harness/inbox/tasks.jsonl`.
19
19
  *
20
20
  * Storage layout:
21
21
  * ```
22
22
  * ~/.pi/harness/inbox/
23
- * ├── tasks.jsonl # append-only log (one JSON line per task)
24
- * ├── claimed/ # active leases (one JSON file per task)
25
- * └── BACKLOG.md # human-friendly authoring surface (optional)
23
+ * +-- tasks.jsonl # append-only log (one JSON line per task)
24
+ * +-- claimed/ # active leases (one JSON file per task)
25
+ * +-- BACKLOG.md # human-friendly authoring surface (optional)
26
26
  * ```
27
27
  *
28
28
  * Operations are:
@@ -46,7 +46,7 @@ export class TaskInbox {
46
46
  mkdirSync(this.inboxDir, { recursive: true });
47
47
  }
48
48
  }
49
- // ─── append ──────────────────────────────────────────────────────────────
49
+ // --- append --------------------------------------------------------------
50
50
  /**
51
51
  * Append a new task to tasks.jsonl.
52
52
  * The task is validated before writing. Duplicate ids are rejected.
@@ -64,7 +64,7 @@ export class TaskInbox {
64
64
  appendFileSync(this.tasksPath, line, "utf8");
65
65
  this._cache = null; // invalidate
66
66
  }
67
- // ─── list ─────────────────────────────────────────────────────────────────
67
+ // --- list -----------------------------------------------------------------
68
68
  /**
69
69
  * Read all tasks from tasks.jsonl.
70
70
  * Results are sorted by priority ASC then createdAt ASC (oldest first).
@@ -106,13 +106,13 @@ export class TaskInbox {
106
106
  });
107
107
  return filtered;
108
108
  }
109
- // ─── get ─────────────────────────────────────────────────────────────────
109
+ // --- get -----------------------------------------------------------------
110
110
  /** Retrieve a single task by id, or null if not found. */
111
111
  get(id) {
112
112
  const tasks = this.list();
113
113
  return tasks.find((t) => t.id === id) ?? null;
114
114
  }
115
- // ─── transition ──────────────────────────────────────────────────────────
115
+ // --- transition ----------------------------------------------------------
116
116
  /**
117
117
  * Update a task's status in-place inside tasks.jsonl.
118
118
  *
@@ -159,7 +159,7 @@ export class TaskInbox {
159
159
  this._cache = null;
160
160
  return updated;
161
161
  }
162
- // ─── markDone / markFailed ───────────────────────────────────────────────
162
+ // --- markDone / markFailed -----------------------------------------------
163
163
  /** Convenience: mark a task as completed with a result. */
164
164
  complete(taskId, result) {
165
165
  return this.transition(taskId, "completed", { result }, {
@@ -179,7 +179,7 @@ export class TaskInbox {
179
179
  payload: { reason, attempts },
180
180
  });
181
181
  }
182
- // ─── reindex ─────────────────────────────────────────────────────────────
182
+ // --- reindex -------------------------------------------------------------
183
183
  /** Rewrite tasks.jsonl from the given task list. */
184
184
  _rewriteAll(tasks) {
185
185
  const tmp = `${this.tasksPath}.tmp`;
@@ -198,7 +198,7 @@ export class TaskInbox {
198
198
  this._rewriteAll(tasks);
199
199
  this._cache = null;
200
200
  }
201
- // ─── count ───────────────────────────────────────────────────────────────
201
+ // --- count ---------------------------------------------------------------
202
202
  /** Return counts of tasks grouped by status. */
203
203
  stats() {
204
204
  const tasks = this.list();
@@ -7,9 +7,9 @@
7
7
  * Filesystem layout:
8
8
  * ```
9
9
  * ~/.pi/harness/inbox/
10
- * ├── tasks.jsonl # task records
11
- * └── claimed/
12
- * └── <task-id>.lease.json # one lease file per claimed task
10
+ * +-- tasks.jsonl # task records
11
+ * +-- claimed/
12
+ * +-- <task-id>.lease.json # one lease file per claimed task
13
13
  * ```
14
14
  *
15
15
  * Safety properties:
@@ -20,14 +20,14 @@
20
20
  import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, unlinkSync, writeFileSync, writeSync, } from "node:fs";
21
21
  import { join } from "node:path";
22
22
  import { getLeasesDir } from "./types.js";
23
- // ─── Errors ───────────────────────────────────────────────────────────────────
23
+ // --- Errors -------------------------------------------------------------------
24
24
  export class LeaseError extends Error {
25
25
  constructor(msg) {
26
26
  super(`[LeaseError] ${msg}`);
27
27
  this.name = "LeaseError";
28
28
  }
29
29
  }
30
- // ─── Constants ────────────────────────────────────────────────────────────────
30
+ // --- Constants ----------------------------------------------------------------
31
31
  /** Default lease duration before heartbeat extension is required. */
32
32
  export const DEFAULT_LEASE_TTL_MS = 30_000; // 30 s
33
33
  /** Heartbeat interval sent by the worker. */
@@ -50,7 +50,7 @@ export class LeaseManager {
50
50
  mkdirSync(this.leasesDir, { recursive: true });
51
51
  }
52
52
  }
53
- // ─── claim ───────────────────────────────────────────────────────────────
53
+ // --- claim ---------------------------------------------------------------
54
54
  /**
55
55
  * Atomically claim a task for a worker.
56
56
  *
@@ -111,7 +111,7 @@ export class LeaseManager {
111
111
  throw err;
112
112
  }
113
113
  }
114
- // ─── heartbeat ────────────────────────────────────────────────────────────
114
+ // --- heartbeat ------------------------------------------------------------
115
115
  /**
116
116
  * Extend a lease's expiry time.
117
117
  * Only the worker that holds the lease can extend it.
@@ -133,7 +133,7 @@ export class LeaseManager {
133
133
  this._writeLease(updated);
134
134
  return updated;
135
135
  }
136
- // ─── release ─────────────────────────────────────────────────────────────
136
+ // --- release -------------------------------------------------------------
137
137
  /**
138
138
  * Explicitly release a lease (task completed or failed without retry).
139
139
  */
@@ -146,7 +146,7 @@ export class LeaseManager {
146
146
  }
147
147
  this._removeLease(taskId);
148
148
  }
149
- // ─── get ─────────────────────────────────────────────────────────────────
149
+ // --- get -----------------------------------------------------------------
150
150
  /** Read a lease by taskId. Returns null if not found. */
151
151
  get(taskId) {
152
152
  const path = this._leasePath(taskId);
@@ -159,12 +159,12 @@ export class LeaseManager {
159
159
  return null;
160
160
  }
161
161
  }
162
- // ─── isExpired ────────────────────────────────────────────────────────────
162
+ // --- isExpired ------------------------------------------------------------
163
163
  /** Check if a lease has expired (expiresAt is in the past). */
164
164
  isExpired(lease) {
165
165
  return new Date(lease.expiresAt).getTime() < Date.now();
166
166
  }
167
- // ─── reap ────────────────────────────────────────────────────────────────
167
+ // --- reap ----------------------------------------------------------------
168
168
  /**
169
169
  * Scan all leases and return the ones that have expired.
170
170
  * Does NOT remove them — call reapAndRelease() to remove atomically.
@@ -214,7 +214,7 @@ export class LeaseManager {
214
214
  }
215
215
  return released;
216
216
  }
217
- // ─── recoverOrphanLeases ─────────────────────────────────────────────────
217
+ // --- recoverOrphanLeases -------------------------------------------------
218
218
  /**
219
219
  * On worker startup, release any leases held by dead workers.
220
220
  * A lease is orphaned if its worker has not re-claimed it since startup.
@@ -225,7 +225,7 @@ export class LeaseManager {
225
225
  recoverOnStartup() {
226
226
  return this.reapAndRelease();
227
227
  }
228
- // ─── listActive ───────────────────────────────────────────────────────────
228
+ // --- listActive -----------------------------------------------------------
229
229
  /** Return all active (non-expired) leases. */
230
230
  listActive() {
231
231
  if (!existsSync(this.leasesDir))
@@ -254,7 +254,7 @@ export class LeaseManager {
254
254
  }
255
255
  return active;
256
256
  }
257
- // ─── internals ───────────────────────────────────────────────────────────
257
+ // --- internals -----------------------------------------------------------
258
258
  _leasePath(taskId) {
259
259
  return join(this.leasesDir, `${taskId}.lease.json`);
260
260
  }
@@ -6,7 +6,7 @@
6
6
  * These types are the canonical contracts. Do not re-define them in other packages.
7
7
  */
8
8
  import { env } from "node:process";
9
- // ─── Storage paths ────────────────────────────────────────────────────────────
9
+ // --- Storage paths ------------------------------------------------------------
10
10
  const DEFAULT_ROOT = `${env["HOME"] ?? "."}/.pi/harness`;
11
11
  /** Returns the standard storage root for the runtime. */
12
12
  export function getRuntimeRoot() {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/autonomous-runtime",
3
- "version": "0.9.24",
3
+ "version": "1.1.0",
4
4
  "description": "Autonomous Operations Runtime — task inbox, lease management, and worker lifecycle (RFC-0101)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15,7 +15,7 @@ import { dirname } from "node:path";
15
15
  import type { TaskRecord, TaskStatus, TaskEvent } from "./types.js";
16
16
  import { getInboxDir, getTasksPath } from "./types.js";
17
17
 
18
- // ─── Errors ───────────────────────────────────────────────────────────────────
18
+ // --- Errors -------------------------------------------------------------------
19
19
 
20
20
  export class InboxError extends Error {
21
21
  constructor(msg: string) {
@@ -24,7 +24,7 @@ export class InboxError extends Error {
24
24
  }
25
25
  }
26
26
 
27
- // ─── TaskInbox ────────────────────────────────────────────────────────────────
27
+ // --- TaskInbox ----------------------------------------------------------------
28
28
 
29
29
  /**
30
30
  * Manages the append-only task inbox at `~/.pi/harness/inbox/tasks.jsonl`.
@@ -32,9 +32,9 @@ export class InboxError extends Error {
32
32
  * Storage layout:
33
33
  * ```
34
34
  * ~/.pi/harness/inbox/
35
- * ├── tasks.jsonl # append-only log (one JSON line per task)
36
- * ├── claimed/ # active leases (one JSON file per task)
37
- * └── BACKLOG.md # human-friendly authoring surface (optional)
35
+ * +-- tasks.jsonl # append-only log (one JSON line per task)
36
+ * +-- claimed/ # active leases (one JSON file per task)
37
+ * +-- BACKLOG.md # human-friendly authoring surface (optional)
38
38
  * ```
39
39
  *
40
40
  * Operations are:
@@ -61,7 +61,7 @@ export class TaskInbox {
61
61
  }
62
62
  }
63
63
 
64
- // ─── append ──────────────────────────────────────────────────────────────
64
+ // --- append --------------------------------------------------------------
65
65
 
66
66
  /**
67
67
  * Append a new task to tasks.jsonl.
@@ -85,7 +85,7 @@ export class TaskInbox {
85
85
  this._cache = null; // invalidate
86
86
  }
87
87
 
88
- // ─── list ─────────────────────────────────────────────────────────────────
88
+ // --- list -----------------------------------------------------------------
89
89
 
90
90
  /**
91
91
  * Read all tasks from tasks.jsonl.
@@ -131,7 +131,7 @@ export class TaskInbox {
131
131
  return filtered;
132
132
  }
133
133
 
134
- // ─── get ─────────────────────────────────────────────────────────────────
134
+ // --- get -----------------------------------------------------------------
135
135
 
136
136
  /** Retrieve a single task by id, or null if not found. */
137
137
  get(id: string): TaskRecord | null {
@@ -139,7 +139,7 @@ export class TaskInbox {
139
139
  return tasks.find((t) => t.id === id) ?? null;
140
140
  }
141
141
 
142
- // ─── transition ──────────────────────────────────────────────────────────
142
+ // --- transition ----------------------------------------------------------
143
143
 
144
144
  /**
145
145
  * Update a task's status in-place inside tasks.jsonl.
@@ -197,7 +197,7 @@ export class TaskInbox {
197
197
  return updated;
198
198
  }
199
199
 
200
- // ─── markDone / markFailed ───────────────────────────────────────────────
200
+ // --- markDone / markFailed -----------------------------------------------
201
201
 
202
202
  /** Convenience: mark a task as completed with a result. */
203
203
  complete(taskId: string, result: TaskRecord["result"]): TaskRecord {
@@ -231,7 +231,7 @@ export class TaskInbox {
231
231
  );
232
232
  }
233
233
 
234
- // ─── reindex ─────────────────────────────────────────────────────────────
234
+ // --- reindex -------------------------------------------------------------
235
235
 
236
236
  /** Rewrite tasks.jsonl from the given task list. */
237
237
  private _rewriteAll(tasks: TaskRecord[]): void {
@@ -252,7 +252,7 @@ export class TaskInbox {
252
252
  this._cache = null;
253
253
  }
254
254
 
255
- // ─── count ───────────────────────────────────────────────────────────────
255
+ // --- count ---------------------------------------------------------------
256
256
 
257
257
  /** Return counts of tasks grouped by status. */
258
258
  stats(): Record<TaskStatus, number> {
@@ -7,9 +7,9 @@
7
7
  * Filesystem layout:
8
8
  * ```
9
9
  * ~/.pi/harness/inbox/
10
- * ├── tasks.jsonl # task records
11
- * └── claimed/
12
- * └── <task-id>.lease.json # one lease file per claimed task
10
+ * +-- tasks.jsonl # task records
11
+ * +-- claimed/
12
+ * +-- <task-id>.lease.json # one lease file per claimed task
13
13
  * ```
14
14
  *
15
15
  * Safety properties:
@@ -33,7 +33,7 @@ import { join } from "node:path";
33
33
  import type { TaskLease } from "./types.js";
34
34
  import { getLeasesDir } from "./types.js";
35
35
 
36
- // ─── Errors ───────────────────────────────────────────────────────────────────
36
+ // --- Errors -------------------------------------------------------------------
37
37
 
38
38
  export class LeaseError extends Error {
39
39
  constructor(msg: string) {
@@ -42,7 +42,7 @@ export class LeaseError extends Error {
42
42
  }
43
43
  }
44
44
 
45
- // ─── Constants ────────────────────────────────────────────────────────────────
45
+ // --- Constants ----------------------------------------------------------------
46
46
 
47
47
  /** Default lease duration before heartbeat extension is required. */
48
48
  export const DEFAULT_LEASE_TTL_MS = 30_000; // 30 s
@@ -53,7 +53,7 @@ export const HEARTBEAT_INTERVAL_MS = 5_000; // 5 s
53
53
  /** Default worker heartbeat interval extension. */
54
54
  export const HEARTBEAT_EXTENSION_MS = 30_000; // extend by 30 s
55
55
 
56
- // ─── LeaseManager ─────────────────────────────────────────────────────────────
56
+ // --- LeaseManager -------------------------------------------------------------
57
57
 
58
58
  export interface LeaseOptions {
59
59
  leasesDir?: string;
@@ -80,7 +80,7 @@ export class LeaseManager {
80
80
  }
81
81
  }
82
82
 
83
- // ─── claim ───────────────────────────────────────────────────────────────
83
+ // --- claim ---------------------------------------------------------------
84
84
 
85
85
  /**
86
86
  * Atomically claim a task for a worker.
@@ -143,7 +143,7 @@ export class LeaseManager {
143
143
  }
144
144
  }
145
145
 
146
- // ─── heartbeat ────────────────────────────────────────────────────────────
146
+ // --- heartbeat ------------------------------------------------------------
147
147
 
148
148
  /**
149
149
  * Extend a lease's expiry time.
@@ -170,7 +170,7 @@ export class LeaseManager {
170
170
  return updated;
171
171
  }
172
172
 
173
- // ─── release ─────────────────────────────────────────────────────────────
173
+ // --- release -------------------------------------------------------------
174
174
 
175
175
  /**
176
176
  * Explicitly release a lease (task completed or failed without retry).
@@ -186,7 +186,7 @@ export class LeaseManager {
186
186
  this._removeLease(taskId);
187
187
  }
188
188
 
189
- // ─── get ─────────────────────────────────────────────────────────────────
189
+ // --- get -----------------------------------------------------------------
190
190
 
191
191
  /** Read a lease by taskId. Returns null if not found. */
192
192
  get(taskId: string): TaskLease | null {
@@ -199,14 +199,14 @@ export class LeaseManager {
199
199
  }
200
200
  }
201
201
 
202
- // ─── isExpired ────────────────────────────────────────────────────────────
202
+ // --- isExpired ------------------------------------------------------------
203
203
 
204
204
  /** Check if a lease has expired (expiresAt is in the past). */
205
205
  isExpired(lease: TaskLease): boolean {
206
206
  return new Date(lease.expiresAt).getTime() < Date.now();
207
207
  }
208
208
 
209
- // ─── reap ────────────────────────────────────────────────────────────────
209
+ // --- reap ----------------------------------------------------------------
210
210
 
211
211
  /**
212
212
  * Scan all leases and return the ones that have expired.
@@ -256,7 +256,7 @@ export class LeaseManager {
256
256
  return released;
257
257
  }
258
258
 
259
- // ─── recoverOrphanLeases ─────────────────────────────────────────────────
259
+ // --- recoverOrphanLeases -------------------------------------------------
260
260
 
261
261
  /**
262
262
  * On worker startup, release any leases held by dead workers.
@@ -269,7 +269,7 @@ export class LeaseManager {
269
269
  return this.reapAndRelease();
270
270
  }
271
271
 
272
- // ─── listActive ───────────────────────────────────────────────────────────
272
+ // --- listActive -----------------------------------------------------------
273
273
 
274
274
  /** Return all active (non-expired) leases. */
275
275
  listActive(): TaskLease[] {
@@ -298,7 +298,7 @@ export class LeaseManager {
298
298
  return active;
299
299
  }
300
300
 
301
- // ─── internals ───────────────────────────────────────────────────────────
301
+ // --- internals -----------------------------------------------------------
302
302
 
303
303
  private _leasePath(taskId: string): string {
304
304
  return join(this.leasesDir, `${taskId}.lease.json`);
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { env } from "node:process";
9
9
 
10
- // ─── Capability model ──────────────────────────────────────────────────────────
10
+ // --- Capability model ----------------------------------------------------------
11
11
 
12
12
  /** A named capability that the privilege broker may grant. */
13
13
  export type CapabilityName =
@@ -35,7 +35,7 @@ export type ApprovalClass =
35
35
  | "human_approval_required" // must ask operator
36
36
  | "forbidden"; // never grant, regardless of override
37
37
 
38
- // ─── Task lifecycle ───────────────────────────────────────────────────────────
38
+ // --- Task lifecycle -----------------------------------------------------------
39
39
 
40
40
  export type TaskStatus =
41
41
  | "queued"
@@ -68,7 +68,7 @@ export type TaskEvent = {
68
68
  payload?: Record<string, unknown>;
69
69
  };
70
70
 
71
- // ─── Task record ─────────────────────────────────────────────────────────────
71
+ // --- Task record -------------------------------------------------------------
72
72
 
73
73
  /** The primary durable record for a task. */
74
74
  export interface TaskRecord {
@@ -96,7 +96,7 @@ export interface TaskRecord {
96
96
  history: TaskEvent[];
97
97
  }
98
98
 
99
- // ─── Leasing ──────────────────────────────────────────────────────────────────
99
+ // --- Leasing ------------------------------------------------------------------
100
100
 
101
101
  /** A lease held by a worker on a specific task. */
102
102
  export interface TaskLease {
@@ -108,7 +108,7 @@ export interface TaskLease {
108
108
  attempt: number; // which attempt this lease covers
109
109
  }
110
110
 
111
- // ─── Worker registry ──────────────────────────────────────────────────────────
111
+ // --- Worker registry ----------------------------------------------------------
112
112
 
113
113
  /** Heartbeat emitted by a worker every 5 s to worker-registry.json. */
114
114
  export interface WorkerHeartbeat {
@@ -119,7 +119,7 @@ export interface WorkerHeartbeat {
119
119
  inflightTaskIds: string[];
120
120
  }
121
121
 
122
- // ─── Privilege broker ─────────────────────────────────────────────────────────
122
+ // --- Privilege broker ---------------------------------------------------------
123
123
 
124
124
  /** A resolved grant from the privilege broker. */
125
125
  export interface CapabilityGrant {
@@ -131,7 +131,7 @@ export interface CapabilityGrant {
131
131
  timeoutMs: number;
132
132
  }
133
133
 
134
- // ─── Approval ─────────────────────────────────────────────────────────────────
134
+ // --- Approval -----------------------------------------------------------------
135
135
 
136
136
  /** An in-flight human approval request. */
137
137
  export interface ApprovalRequest {
@@ -145,7 +145,7 @@ export interface ApprovalRequest {
145
145
  expiresAt: string; // ISO-8601 — timeout threshold
146
146
  }
147
147
 
148
- // ─── Scheduler ───────────────────────────────────────────────────────────────
148
+ // --- Scheduler ---------------------------------------------------------------
149
149
 
150
150
  /** A scheduled recurring task. */
151
151
  export interface ScheduledTask {
@@ -165,7 +165,7 @@ export type ScheduleSpec =
165
165
  | { kind: "interval"; intervalMs: number }
166
166
  | { kind: "once"; at: string };
167
167
 
168
- // ─── Notification ─────────────────────────────────────────────────────────────
168
+ // --- Notification -------------------------------------------------------------
169
169
 
170
170
  export type RuntimeNotificationEvent =
171
171
  | "task.claimed"
@@ -189,7 +189,7 @@ export interface NotificationEvent {
189
189
  payload: Record<string, unknown>;
190
190
  }
191
191
 
192
- // ─── Checkpoint ───────────────────────────────────────────────────────────────
192
+ // --- Checkpoint ---------------------------------------------------------------
193
193
 
194
194
  export interface Checkpoint {
195
195
  taskId: string;
@@ -198,7 +198,7 @@ export interface Checkpoint {
198
198
  savedAt: string; // ISO-8601
199
199
  }
200
200
 
201
- // ─── Execution context ────────────────────────────────────────────────────────
201
+ // --- Execution context --------------------------------------------------------
202
202
 
203
203
  /** The context given to the loop runtime when executing a task. */
204
204
  export interface ExecutionContext {
@@ -212,7 +212,7 @@ export interface ExecutionContext {
212
212
  okfBundles: string[]; // content hashes available to planner
213
213
  }
214
214
 
215
- // ─── Task result ─────────────────────────────────────────────────────────────
215
+ // --- Task result -------------------------------------------------------------
216
216
 
217
217
  export interface TaskResult {
218
218
  taskId: string;
@@ -227,7 +227,7 @@ export interface TaskResult {
227
227
  modelUsage?: { inputTokens: number; outputTokens: number; provider: string };
228
228
  }
229
229
 
230
- // ─── Storage paths ────────────────────────────────────────────────────────────
230
+ // --- Storage paths ------------------------------------------------------------
231
231
 
232
232
  const DEFAULT_ROOT = `${env["HOME"] ?? "."}/.pi/harness`;
233
233