@caupulican/pi-adaptative 0.81.38 → 0.81.40

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 (881) hide show
  1. package/CHANGELOG.md +131 -0
  2. package/README.md +2 -0
  3. package/dist/bundled-resources/extensions/tmux-agent-manager/README.md +18 -1
  4. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +133 -0
  5. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -0
  6. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +198 -0
  7. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -0
  8. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +311 -0
  9. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +31 -2
  10. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
  11. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +823 -79
  12. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
  13. package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +1043 -86
  14. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/__init__.py +43 -0
  15. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/fs.py +270 -0
  16. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/search.py +252 -0
  17. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/strings.py +399 -0
  18. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +575 -0
  19. package/dist/bundled-resources/runtimes/pi-shell-engine/context.py +52 -0
  20. package/dist/bundled-resources/runtimes/pi-shell-engine/errors.py +49 -0
  21. package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +734 -0
  22. package/dist/bundled-resources/runtimes/pi-shell-engine/expand.py +238 -0
  23. package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +132 -0
  24. package/dist/bundled-resources/runtimes/pi-shell-engine/nodes.py +116 -0
  25. package/dist/bundled-resources/runtimes/pi-shell-engine/parser.py +287 -0
  26. package/dist/bundled-resources/runtimes/pi-shell-engine/proc.py +137 -0
  27. package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +100 -0
  28. package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +579 -0
  29. package/dist/bundled-resources/skills/tool-call-repair/SKILL.md +19 -9
  30. package/dist/bundled-resources/skills/tool-call-repair/references/failure-grammar.md +22 -5
  31. package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +7 -7
  32. package/dist/bundled-resources/skills/tool-call-repair/references/text-protocol-grammar.md +28 -7
  33. package/dist/cli/args.d.ts +5 -0
  34. package/dist/cli/args.d.ts.map +1 -1
  35. package/dist/cli/args.js +24 -0
  36. package/dist/cli/args.js.map +1 -1
  37. package/dist/core/agent-directory-layout.d.ts +15 -0
  38. package/dist/core/agent-directory-layout.d.ts.map +1 -0
  39. package/dist/core/agent-directory-layout.js +72 -0
  40. package/dist/core/agent-directory-layout.js.map +1 -0
  41. package/dist/core/agent-paths.d.ts +66 -0
  42. package/dist/core/agent-paths.d.ts.map +1 -0
  43. package/dist/core/agent-paths.js +170 -0
  44. package/dist/core/agent-paths.js.map +1 -0
  45. package/dist/core/agent-session-runtime.d.ts +52 -8
  46. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  47. package/dist/core/agent-session-runtime.js +397 -79
  48. package/dist/core/agent-session-runtime.js.map +1 -1
  49. package/dist/core/agent-session-services.d.ts +1 -0
  50. package/dist/core/agent-session-services.d.ts.map +1 -1
  51. package/dist/core/agent-session-services.js +4 -3
  52. package/dist/core/agent-session-services.js.map +1 -1
  53. package/dist/core/agent-session.d.ts +255 -103
  54. package/dist/core/agent-session.d.ts.map +1 -1
  55. package/dist/core/agent-session.js +754 -1173
  56. package/dist/core/agent-session.js.map +1 -1
  57. package/dist/core/autonomy/approval-gate.d.ts +3 -2
  58. package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
  59. package/dist/core/autonomy/approval-gate.js +6 -28
  60. package/dist/core/autonomy/approval-gate.js.map +1 -1
  61. package/dist/core/autonomy/bounded-completion.d.ts +1 -1
  62. package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
  63. package/dist/core/autonomy/bounded-completion.js +1 -1
  64. package/dist/core/autonomy/bounded-completion.js.map +1 -1
  65. package/dist/core/autonomy/contracts.d.ts +26 -9
  66. package/dist/core/autonomy/contracts.d.ts.map +1 -1
  67. package/dist/core/autonomy/contracts.js.map +1 -1
  68. package/dist/core/autonomy/foreground-envelope.d.ts +8 -2
  69. package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
  70. package/dist/core/autonomy/foreground-envelope.js +8 -25
  71. package/dist/core/autonomy/foreground-envelope.js.map +1 -1
  72. package/dist/core/autonomy/gates.d.ts.map +1 -1
  73. package/dist/core/autonomy/gates.js +8 -10
  74. package/dist/core/autonomy/gates.js.map +1 -1
  75. package/dist/core/autonomy/lane-private-paths.d.ts +2 -0
  76. package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -0
  77. package/dist/core/autonomy/lane-private-paths.js +16 -0
  78. package/dist/core/autonomy/lane-private-paths.js.map +1 -0
  79. package/dist/core/autonomy/lane-tool-surface.d.ts +10 -0
  80. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  81. package/dist/core/autonomy/lane-tool-surface.js +46 -8
  82. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  83. package/dist/core/autonomy/lane-tracker.d.ts +24 -1
  84. package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
  85. package/dist/core/autonomy/lane-tracker.js +43 -1
  86. package/dist/core/autonomy/lane-tracker.js.map +1 -1
  87. package/dist/core/autonomy/risk-assessment.d.ts +1 -2
  88. package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
  89. package/dist/core/autonomy/risk-assessment.js +1 -123
  90. package/dist/core/autonomy/risk-assessment.js.map +1 -1
  91. package/dist/core/autonomy/session-lane-record.d.ts +4 -4
  92. package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
  93. package/dist/core/autonomy/session-lane-record.js +16 -29
  94. package/dist/core/autonomy/session-lane-record.js.map +1 -1
  95. package/dist/core/autonomy/telemetry-events.d.ts +1 -1
  96. package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
  97. package/dist/core/autonomy/telemetry-events.js +1 -1
  98. package/dist/core/autonomy/telemetry-events.js.map +1 -1
  99. package/dist/core/autonomy-telemetry.d.ts +7 -7
  100. package/dist/core/autonomy-telemetry.d.ts.map +1 -1
  101. package/dist/core/autonomy-telemetry.js +9 -9
  102. package/dist/core/autonomy-telemetry.js.map +1 -1
  103. package/dist/core/background-lane-controller.d.ts +90 -156
  104. package/dist/core/background-lane-controller.d.ts.map +1 -1
  105. package/dist/core/background-lane-controller.js +192 -968
  106. package/dist/core/background-lane-controller.js.map +1 -1
  107. package/dist/core/bash-execution-controller.d.ts +4 -0
  108. package/dist/core/bash-execution-controller.d.ts.map +1 -1
  109. package/dist/core/bash-execution-controller.js +7 -1
  110. package/dist/core/bash-execution-controller.js.map +1 -1
  111. package/dist/core/capability-contract.d.ts +4 -0
  112. package/dist/core/capability-contract.d.ts.map +1 -0
  113. package/dist/core/capability-contract.js +28 -0
  114. package/dist/core/capability-contract.js.map +1 -0
  115. package/dist/core/compaction-controller.d.ts +90 -0
  116. package/dist/core/compaction-controller.d.ts.map +1 -0
  117. package/dist/core/compaction-controller.js +452 -0
  118. package/dist/core/compaction-controller.js.map +1 -0
  119. package/dist/core/compaction-support.d.ts +24 -13
  120. package/dist/core/compaction-support.d.ts.map +1 -1
  121. package/dist/core/compaction-support.js +43 -7
  122. package/dist/core/compaction-support.js.map +1 -1
  123. package/dist/core/context/context-artifacts.d.ts +6 -2
  124. package/dist/core/context/context-artifacts.d.ts.map +1 -1
  125. package/dist/core/context/context-artifacts.js +34 -2
  126. package/dist/core/context/context-artifacts.js.map +1 -1
  127. package/dist/core/context/context-audit.d.ts +33 -1
  128. package/dist/core/context/context-audit.d.ts.map +1 -1
  129. package/dist/core/context/context-audit.js +31 -5
  130. package/dist/core/context/context-audit.js.map +1 -1
  131. package/dist/core/context/context-store-retention.d.ts +8 -2
  132. package/dist/core/context/context-store-retention.d.ts.map +1 -1
  133. package/dist/core/context/context-store-retention.js +158 -35
  134. package/dist/core/context/context-store-retention.js.map +1 -1
  135. package/dist/core/context/okf-memory.d.ts.map +1 -1
  136. package/dist/core/context/okf-memory.js +9 -11
  137. package/dist/core/context/okf-memory.js.map +1 -1
  138. package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
  139. package/dist/core/context/sqlite-runtime-index.js +6 -8
  140. package/dist/core/context/sqlite-runtime-index.js.map +1 -1
  141. package/dist/core/context-gc.d.ts +3 -0
  142. package/dist/core/context-gc.d.ts.map +1 -1
  143. package/dist/core/context-gc.js +26 -6
  144. package/dist/core/context-gc.js.map +1 -1
  145. package/dist/core/context-pipeline.d.ts +26 -4
  146. package/dist/core/context-pipeline.d.ts.map +1 -1
  147. package/dist/core/context-pipeline.js +146 -18
  148. package/dist/core/context-pipeline.js.map +1 -1
  149. package/dist/core/cost-guard.d.ts +19 -3
  150. package/dist/core/cost-guard.d.ts.map +1 -1
  151. package/dist/core/cost-guard.js +18 -3
  152. package/dist/core/cost-guard.js.map +1 -1
  153. package/dist/core/default-tool-surface.d.ts.map +1 -1
  154. package/dist/core/default-tool-surface.js +1 -0
  155. package/dist/core/default-tool-surface.js.map +1 -1
  156. package/dist/core/delegation/managed-lane-controller.d.ts +34 -0
  157. package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -0
  158. package/dist/core/delegation/managed-lane-controller.js +217 -0
  159. package/dist/core/delegation/managed-lane-controller.js.map +1 -0
  160. package/dist/core/delegation/session-worker-claim.d.ts +44 -0
  161. package/dist/core/delegation/session-worker-claim.d.ts.map +1 -0
  162. package/dist/core/delegation/session-worker-claim.js +98 -0
  163. package/dist/core/delegation/session-worker-claim.js.map +1 -0
  164. package/dist/core/delegation/worker-actions.d.ts +7 -5
  165. package/dist/core/delegation/worker-actions.d.ts.map +1 -1
  166. package/dist/core/delegation/worker-actions.js +20 -4
  167. package/dist/core/delegation/worker-actions.js.map +1 -1
  168. package/dist/core/delegation/worker-claim.d.ts +56 -0
  169. package/dist/core/delegation/worker-claim.d.ts.map +1 -0
  170. package/dist/core/delegation/worker-claim.js +239 -0
  171. package/dist/core/delegation/worker-claim.js.map +1 -0
  172. package/dist/core/delegation/worker-delegation-controller.d.ts +110 -0
  173. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -0
  174. package/dist/core/delegation/worker-delegation-controller.js +861 -0
  175. package/dist/core/delegation/worker-delegation-controller.js.map +1 -0
  176. package/dist/core/delegation/worker-delegation-request.d.ts +11 -0
  177. package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -0
  178. package/dist/core/delegation/worker-delegation-request.js +2 -0
  179. package/dist/core/delegation/worker-delegation-request.js.map +1 -0
  180. package/dist/core/delegation/worker-dispatch-scheduler.d.ts +40 -0
  181. package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -0
  182. package/dist/core/delegation/worker-dispatch-scheduler.js +93 -0
  183. package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -0
  184. package/dist/core/delegation/worker-execution-policy.d.ts +62 -0
  185. package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -0
  186. package/dist/core/delegation/worker-execution-policy.js +160 -0
  187. package/dist/core/delegation/worker-execution-policy.js.map +1 -0
  188. package/dist/core/delegation/worker-lane-projection.d.ts +14 -0
  189. package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -0
  190. package/dist/core/delegation/worker-lane-projection.js +100 -0
  191. package/dist/core/delegation/worker-lane-projection.js.map +1 -0
  192. package/dist/core/delegation/worker-lifecycle.d.ts +97 -0
  193. package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -0
  194. package/dist/core/delegation/worker-lifecycle.js +339 -0
  195. package/dist/core/delegation/worker-lifecycle.js.map +1 -0
  196. package/dist/core/delegation/worker-notification-coordinator.d.ts +36 -0
  197. package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -0
  198. package/dist/core/delegation/worker-notification-coordinator.js +90 -0
  199. package/dist/core/delegation/worker-notification-coordinator.js.map +1 -0
  200. package/dist/core/delegation/worker-profile-resolver.d.ts +55 -0
  201. package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -0
  202. package/dist/core/delegation/worker-profile-resolver.js +113 -0
  203. package/dist/core/delegation/worker-profile-resolver.js.map +1 -0
  204. package/dist/core/delegation/worker-runner.d.ts +25 -14
  205. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  206. package/dist/core/delegation/worker-runner.js +122 -53
  207. package/dist/core/delegation/worker-runner.js.map +1 -1
  208. package/dist/core/delegation/worker-task-label.d.ts +3 -0
  209. package/dist/core/delegation/worker-task-label.d.ts.map +1 -0
  210. package/dist/core/delegation/worker-task-label.js +11 -0
  211. package/dist/core/delegation/worker-task-label.js.map +1 -0
  212. package/dist/core/doctor.d.ts +8 -0
  213. package/dist/core/doctor.d.ts.map +1 -1
  214. package/dist/core/doctor.js +32 -1
  215. package/dist/core/doctor.js.map +1 -1
  216. package/dist/core/extensions/index.d.ts +1 -1
  217. package/dist/core/extensions/index.d.ts.map +1 -1
  218. package/dist/core/extensions/index.js.map +1 -1
  219. package/dist/core/extensions/loader.d.ts +5 -1
  220. package/dist/core/extensions/loader.d.ts.map +1 -1
  221. package/dist/core/extensions/loader.js +68 -13
  222. package/dist/core/extensions/loader.js.map +1 -1
  223. package/dist/core/extensions/runner.d.ts.map +1 -1
  224. package/dist/core/extensions/runner.js +7 -0
  225. package/dist/core/extensions/runner.js.map +1 -1
  226. package/dist/core/extensions/storage.d.ts +8 -0
  227. package/dist/core/extensions/storage.d.ts.map +1 -0
  228. package/dist/core/extensions/storage.js +28 -0
  229. package/dist/core/extensions/storage.js.map +1 -0
  230. package/dist/core/extensions/types.d.ts +101 -1
  231. package/dist/core/extensions/types.d.ts.map +1 -1
  232. package/dist/core/extensions/types.js.map +1 -1
  233. package/dist/core/failure-corpus.d.ts +1 -15
  234. package/dist/core/failure-corpus.d.ts.map +1 -1
  235. package/dist/core/failure-corpus.js +9 -37
  236. package/dist/core/failure-corpus.js.map +1 -1
  237. package/dist/core/foreground-recovery-controller.d.ts +52 -0
  238. package/dist/core/foreground-recovery-controller.d.ts.map +1 -0
  239. package/dist/core/foreground-recovery-controller.js +111 -0
  240. package/dist/core/foreground-recovery-controller.js.map +1 -0
  241. package/dist/core/gateways/channel-provider.d.ts +3 -0
  242. package/dist/core/gateways/channel-provider.d.ts.map +1 -1
  243. package/dist/core/gateways/channel-provider.js +31 -6
  244. package/dist/core/gateways/channel-provider.js.map +1 -1
  245. package/dist/core/goal-loop-controller.d.ts +17 -1
  246. package/dist/core/goal-loop-controller.d.ts.map +1 -1
  247. package/dist/core/goal-loop-controller.js +79 -11
  248. package/dist/core/goal-loop-controller.js.map +1 -1
  249. package/dist/core/goals/goal-acceptance.d.ts +11 -0
  250. package/dist/core/goals/goal-acceptance.d.ts.map +1 -0
  251. package/dist/core/goals/goal-acceptance.js +25 -0
  252. package/dist/core/goals/goal-acceptance.js.map +1 -0
  253. package/dist/core/goals/goal-auto-continue-controller.d.ts +27 -0
  254. package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -0
  255. package/dist/core/goals/goal-auto-continue-controller.js +93 -0
  256. package/dist/core/goals/goal-auto-continue-controller.js.map +1 -0
  257. package/dist/core/goals/goal-continuation-controller.d.ts +48 -2
  258. package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
  259. package/dist/core/goals/goal-continuation-controller.js +87 -0
  260. package/dist/core/goals/goal-continuation-controller.js.map +1 -1
  261. package/dist/core/goals/goal-continuation-defaults.d.ts +39 -0
  262. package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
  263. package/dist/core/goals/goal-continuation-defaults.js +42 -0
  264. package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
  265. package/dist/core/goals/goal-continuation-prompt.d.ts +5 -1
  266. package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
  267. package/dist/core/goals/goal-continuation-prompt.js +56 -15
  268. package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
  269. package/dist/core/goals/goal-lifecycle.d.ts +20 -0
  270. package/dist/core/goals/goal-lifecycle.d.ts.map +1 -0
  271. package/dist/core/goals/goal-lifecycle.js +17 -0
  272. package/dist/core/goals/goal-lifecycle.js.map +1 -0
  273. package/dist/core/goals/goal-runtime-snapshot.d.ts +105 -4
  274. package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
  275. package/dist/core/goals/goal-runtime-snapshot.js +91 -6
  276. package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
  277. package/dist/core/goals/goal-state.d.ts +90 -1
  278. package/dist/core/goals/goal-state.d.ts.map +1 -1
  279. package/dist/core/goals/goal-state.js +78 -15
  280. package/dist/core/goals/goal-state.js.map +1 -1
  281. package/dist/core/goals/goal-tool-core.d.ts +58 -2
  282. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  283. package/dist/core/goals/goal-tool-core.js +82 -6
  284. package/dist/core/goals/goal-tool-core.js.map +1 -1
  285. package/dist/core/goals/session-goal-state.d.ts +13 -6
  286. package/dist/core/goals/session-goal-state.d.ts.map +1 -1
  287. package/dist/core/goals/session-goal-state.js +20 -28
  288. package/dist/core/goals/session-goal-state.js.map +1 -1
  289. package/dist/core/human-input.d.ts +100 -0
  290. package/dist/core/human-input.d.ts.map +1 -0
  291. package/dist/core/human-input.js +362 -0
  292. package/dist/core/human-input.js.map +1 -0
  293. package/dist/core/index.d.ts +9 -1
  294. package/dist/core/index.d.ts.map +1 -1
  295. package/dist/core/index.js +9 -1
  296. package/dist/core/index.js.map +1 -1
  297. package/dist/core/{telemetry.d.ts → install-telemetry.d.ts} +1 -1
  298. package/dist/core/install-telemetry.d.ts.map +1 -0
  299. package/dist/core/{telemetry.js → install-telemetry.js} +1 -1
  300. package/dist/core/install-telemetry.js.map +1 -0
  301. package/dist/core/keybindings.d.ts +27 -1
  302. package/dist/core/keybindings.d.ts.map +1 -1
  303. package/dist/core/keybindings.js +34 -8
  304. package/dist/core/keybindings.js.map +1 -1
  305. package/dist/core/learning/learning-audit.d.ts +2 -4
  306. package/dist/core/learning/learning-audit.d.ts.map +1 -1
  307. package/dist/core/learning/learning-audit.js +9 -29
  308. package/dist/core/learning/learning-audit.js.map +1 -1
  309. package/dist/core/learning/learning-gate.d.ts.map +1 -1
  310. package/dist/core/learning/learning-gate.js +1 -6
  311. package/dist/core/learning/learning-gate.js.map +1 -1
  312. package/dist/core/learning/observation-store.d.ts +12 -3
  313. package/dist/core/learning/observation-store.d.ts.map +1 -1
  314. package/dist/core/learning/observation-store.js +30 -15
  315. package/dist/core/learning/observation-store.js.map +1 -1
  316. package/dist/core/learning/session-learning-decision.d.ts +2 -4
  317. package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
  318. package/dist/core/learning/session-learning-decision.js +9 -29
  319. package/dist/core/learning/session-learning-decision.js.map +1 -1
  320. package/dist/core/learning/skill-curator.d.ts +5 -1
  321. package/dist/core/learning/skill-curator.d.ts.map +1 -1
  322. package/dist/core/learning/skill-curator.js +21 -19
  323. package/dist/core/learning/skill-curator.js.map +1 -1
  324. package/dist/core/local-runtime-controller.d.ts +65 -3
  325. package/dist/core/local-runtime-controller.d.ts.map +1 -1
  326. package/dist/core/local-runtime-controller.js +186 -26
  327. package/dist/core/local-runtime-controller.js.map +1 -1
  328. package/dist/core/memory/providers/file-store.d.ts +1 -1
  329. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  330. package/dist/core/memory/providers/file-store.js +6 -6
  331. package/dist/core/memory/providers/file-store.js.map +1 -1
  332. package/dist/core/memory-controller.d.ts.map +1 -1
  333. package/dist/core/memory-controller.js +4 -4
  334. package/dist/core/memory-controller.js.map +1 -1
  335. package/dist/core/model-capability.d.ts +34 -0
  336. package/dist/core/model-capability.d.ts.map +1 -1
  337. package/dist/core/model-capability.js +43 -1
  338. package/dist/core/model-capability.js.map +1 -1
  339. package/dist/core/model-resolver.d.ts +1 -1
  340. package/dist/core/model-resolver.d.ts.map +1 -1
  341. package/dist/core/model-resolver.js +6 -9
  342. package/dist/core/model-resolver.js.map +1 -1
  343. package/dist/core/model-router/intent-classifier.d.ts +1 -4
  344. package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
  345. package/dist/core/model-router/intent-classifier.js +1 -156
  346. package/dist/core/model-router/intent-classifier.js.map +1 -1
  347. package/dist/core/model-router/tool-escalation.d.ts +15 -0
  348. package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
  349. package/dist/core/model-router/tool-escalation.js +23 -1
  350. package/dist/core/model-router/tool-escalation.js.map +1 -1
  351. package/dist/core/model-router-controller.d.ts +34 -7
  352. package/dist/core/model-router-controller.d.ts.map +1 -1
  353. package/dist/core/model-router-controller.js +95 -16
  354. package/dist/core/model-router-controller.js.map +1 -1
  355. package/dist/core/model-selection-controller.d.ts +4 -4
  356. package/dist/core/model-selection-controller.d.ts.map +1 -1
  357. package/dist/core/model-selection-controller.js.map +1 -1
  358. package/dist/core/model-tool-protocol.d.ts +23 -0
  359. package/dist/core/model-tool-protocol.d.ts.map +1 -0
  360. package/dist/core/model-tool-protocol.js +43 -0
  361. package/dist/core/model-tool-protocol.js.map +1 -0
  362. package/dist/core/models/adaptation-store.d.ts +10 -5
  363. package/dist/core/models/adaptation-store.d.ts.map +1 -1
  364. package/dist/core/models/adaptation-store.js +129 -81
  365. package/dist/core/models/adaptation-store.js.map +1 -1
  366. package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
  367. package/dist/core/models/default-model-suggestions.js +17 -0
  368. package/dist/core/models/default-model-suggestions.js.map +1 -1
  369. package/dist/core/models/fitness-store.d.ts +4 -11
  370. package/dist/core/models/fitness-store.d.ts.map +1 -1
  371. package/dist/core/models/fitness-store.js +87 -51
  372. package/dist/core/models/fitness-store.js.map +1 -1
  373. package/dist/core/models/host-state-store.d.ts +34 -0
  374. package/dist/core/models/host-state-store.d.ts.map +1 -0
  375. package/dist/core/models/host-state-store.js +86 -0
  376. package/dist/core/models/host-state-store.js.map +1 -0
  377. package/dist/core/models/llamacpp-runtime.d.ts +180 -0
  378. package/dist/core/models/llamacpp-runtime.d.ts.map +1 -0
  379. package/dist/core/models/llamacpp-runtime.js +475 -0
  380. package/dist/core/models/llamacpp-runtime.js.map +1 -0
  381. package/dist/core/models/local-registration.d.ts +40 -0
  382. package/dist/core/models/local-registration.d.ts.map +1 -1
  383. package/dist/core/models/local-registration.js +94 -5
  384. package/dist/core/models/local-registration.js.map +1 -1
  385. package/dist/core/models/local-runtime.d.ts.map +1 -1
  386. package/dist/core/models/local-runtime.js +6 -5
  387. package/dist/core/models/local-runtime.js.map +1 -1
  388. package/dist/core/models/model-ref.d.ts +7 -0
  389. package/dist/core/models/model-ref.d.ts.map +1 -1
  390. package/dist/core/models/model-ref.js +26 -0
  391. package/dist/core/models/model-ref.js.map +1 -1
  392. package/dist/core/models/needle-runtime.d.ts +257 -0
  393. package/dist/core/models/needle-runtime.d.ts.map +1 -0
  394. package/dist/core/models/needle-runtime.js +519 -0
  395. package/dist/core/models/needle-runtime.js.map +1 -0
  396. package/dist/core/models/prism-llamacpp-lifecycle.d.ts +89 -0
  397. package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -0
  398. package/dist/core/models/prism-llamacpp-lifecycle.js +121 -0
  399. package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -0
  400. package/dist/core/orchestration/agent-resume.d.ts +24 -0
  401. package/dist/core/orchestration/agent-resume.d.ts.map +1 -0
  402. package/dist/core/orchestration/agent-resume.js +90 -0
  403. package/dist/core/orchestration/agent-resume.js.map +1 -0
  404. package/dist/core/orchestration/capability-gateway.d.ts +61 -0
  405. package/dist/core/orchestration/capability-gateway.d.ts.map +1 -0
  406. package/dist/core/orchestration/capability-gateway.js +152 -0
  407. package/dist/core/orchestration/capability-gateway.js.map +1 -0
  408. package/dist/core/orchestration/contracts.d.ts +343 -0
  409. package/dist/core/orchestration/contracts.d.ts.map +1 -0
  410. package/dist/core/orchestration/contracts.js +135 -0
  411. package/dist/core/orchestration/contracts.js.map +1 -0
  412. package/dist/core/orchestration/delegation-ledger.d.ts +56 -0
  413. package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -0
  414. package/dist/core/orchestration/delegation-ledger.js +197 -0
  415. package/dist/core/orchestration/delegation-ledger.js.map +1 -0
  416. package/dist/core/orchestration/event-store.d.ts +83 -0
  417. package/dist/core/orchestration/event-store.d.ts.map +1 -0
  418. package/dist/core/orchestration/event-store.js +560 -0
  419. package/dist/core/orchestration/event-store.js.map +1 -0
  420. package/dist/core/orchestration/lane-tool-manifests.d.ts +9 -0
  421. package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -0
  422. package/dist/core/orchestration/lane-tool-manifests.js +37 -0
  423. package/dist/core/orchestration/lane-tool-manifests.js.map +1 -0
  424. package/dist/core/orchestration/model-binding.d.ts +15 -0
  425. package/dist/core/orchestration/model-binding.d.ts.map +1 -0
  426. package/dist/core/orchestration/model-binding.js +29 -0
  427. package/dist/core/orchestration/model-binding.js.map +1 -0
  428. package/dist/core/orchestration/policy-compiler.d.ts +49 -0
  429. package/dist/core/orchestration/policy-compiler.d.ts.map +1 -0
  430. package/dist/core/orchestration/policy-compiler.js +191 -0
  431. package/dist/core/orchestration/policy-compiler.js.map +1 -0
  432. package/dist/core/orchestration/policy-gate.d.ts +18 -0
  433. package/dist/core/orchestration/policy-gate.d.ts.map +1 -0
  434. package/dist/core/orchestration/policy-gate.js +24 -0
  435. package/dist/core/orchestration/policy-gate.js.map +1 -0
  436. package/dist/core/orchestration/profile-registry.d.ts +51 -0
  437. package/dist/core/orchestration/profile-registry.d.ts.map +1 -0
  438. package/dist/core/orchestration/profile-registry.js +393 -0
  439. package/dist/core/orchestration/profile-registry.js.map +1 -0
  440. package/dist/core/orchestration/profile-store.d.ts +31 -0
  441. package/dist/core/orchestration/profile-store.d.ts.map +1 -0
  442. package/dist/core/orchestration/profile-store.js +136 -0
  443. package/dist/core/orchestration/profile-store.js.map +1 -0
  444. package/dist/core/orchestration/risk-budget.d.ts +9 -0
  445. package/dist/core/orchestration/risk-budget.d.ts.map +1 -0
  446. package/dist/core/orchestration/risk-budget.js +48 -0
  447. package/dist/core/orchestration/risk-budget.js.map +1 -0
  448. package/dist/core/orchestration/task-runtime.d.ts +168 -0
  449. package/dist/core/orchestration/task-runtime.d.ts.map +1 -0
  450. package/dist/core/orchestration/task-runtime.js +1600 -0
  451. package/dist/core/orchestration/task-runtime.js.map +1 -0
  452. package/dist/core/orchestration/work-state-projection.d.ts +32 -0
  453. package/dist/core/orchestration/work-state-projection.d.ts.map +1 -0
  454. package/dist/core/orchestration/work-state-projection.js +116 -0
  455. package/dist/core/orchestration/work-state-projection.js.map +1 -0
  456. package/dist/core/orchestration/worker-execution-contract.d.ts +21 -0
  457. package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -0
  458. package/dist/core/orchestration/worker-execution-contract.js +179 -0
  459. package/dist/core/orchestration/worker-execution-contract.js.map +1 -0
  460. package/dist/core/orchestration/worker-result-adapter.d.ts +21 -0
  461. package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -0
  462. package/dist/core/orchestration/worker-result-adapter.js +109 -0
  463. package/dist/core/orchestration/worker-result-adapter.js.map +1 -0
  464. package/dist/core/package-manager.d.ts.map +1 -1
  465. package/dist/core/package-manager.js +11 -10
  466. package/dist/core/package-manager.js.map +1 -1
  467. package/dist/core/process-identity.d.ts +11 -0
  468. package/dist/core/process-identity.d.ts.map +1 -0
  469. package/dist/core/process-identity.js +26 -0
  470. package/dist/core/process-identity.js.map +1 -0
  471. package/dist/core/process-matrix/codes.d.ts +83 -0
  472. package/dist/core/process-matrix/codes.d.ts.map +1 -0
  473. package/dist/core/process-matrix/codes.js +15 -0
  474. package/dist/core/process-matrix/codes.js.map +1 -0
  475. package/dist/core/process-matrix/resume-launcher.d.ts +26 -0
  476. package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -0
  477. package/dist/core/process-matrix/resume-launcher.js +62 -0
  478. package/dist/core/process-matrix/resume-launcher.js.map +1 -0
  479. package/dist/core/process-matrix/runtime.d.ts +78 -0
  480. package/dist/core/process-matrix/runtime.d.ts.map +1 -0
  481. package/dist/core/process-matrix/runtime.js +633 -0
  482. package/dist/core/process-matrix/runtime.js.map +1 -0
  483. package/dist/core/process-matrix/store.d.ts +25 -0
  484. package/dist/core/process-matrix/store.d.ts.map +1 -0
  485. package/dist/core/process-matrix/store.js +189 -0
  486. package/dist/core/process-matrix/store.js.map +1 -0
  487. package/dist/core/process-matrix/supervisor.d.ts +75 -0
  488. package/dist/core/process-matrix/supervisor.d.ts.map +1 -0
  489. package/dist/core/process-matrix/supervisor.js +161 -0
  490. package/dist/core/process-matrix/supervisor.js.map +1 -0
  491. package/dist/core/profile-registry.d.ts +7 -0
  492. package/dist/core/profile-registry.d.ts.map +1 -1
  493. package/dist/core/profile-registry.js +25 -7
  494. package/dist/core/profile-registry.js.map +1 -1
  495. package/dist/core/python-runtime.d.ts.map +1 -1
  496. package/dist/core/python-runtime.js +3 -3
  497. package/dist/core/python-runtime.js.map +1 -1
  498. package/dist/core/reflection-controller.d.ts +33 -9
  499. package/dist/core/reflection-controller.d.ts.map +1 -1
  500. package/dist/core/reflection-controller.js +217 -127
  501. package/dist/core/reflection-controller.js.map +1 -1
  502. package/dist/core/reload-blockers.d.ts +36 -0
  503. package/dist/core/reload-blockers.d.ts.map +1 -1
  504. package/dist/core/reload-blockers.js +50 -8
  505. package/dist/core/reload-blockers.js.map +1 -1
  506. package/dist/core/research/evidence-bundle.d.ts.map +1 -1
  507. package/dist/core/research/evidence-bundle.js +1 -6
  508. package/dist/core/research/evidence-bundle.js.map +1 -1
  509. package/dist/core/research/lane-model-resolver.d.ts +33 -0
  510. package/dist/core/research/lane-model-resolver.d.ts.map +1 -0
  511. package/dist/core/research/lane-model-resolver.js +65 -0
  512. package/dist/core/research/lane-model-resolver.js.map +1 -0
  513. package/dist/core/research/model-fitness-controller.d.ts +38 -0
  514. package/dist/core/research/model-fitness-controller.d.ts.map +1 -0
  515. package/dist/core/research/model-fitness-controller.js +106 -0
  516. package/dist/core/research/model-fitness-controller.js.map +1 -0
  517. package/dist/core/research/model-fitness.d.ts +1 -1
  518. package/dist/core/research/model-fitness.d.ts.map +1 -1
  519. package/dist/core/research/model-fitness.js +4 -4
  520. package/dist/core/research/model-fitness.js.map +1 -1
  521. package/dist/core/research/research-gate.d.ts.map +1 -1
  522. package/dist/core/research/research-gate.js +7 -7
  523. package/dist/core/research/research-gate.js.map +1 -1
  524. package/dist/core/research/research-lane-controller.d.ts +62 -0
  525. package/dist/core/research/research-lane-controller.d.ts.map +1 -0
  526. package/dist/core/research/research-lane-controller.js +292 -0
  527. package/dist/core/research/research-lane-controller.js.map +1 -0
  528. package/dist/core/research/session-evidence-bundle.d.ts +2 -4
  529. package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
  530. package/dist/core/research/session-evidence-bundle.js +10 -46
  531. package/dist/core/research/session-evidence-bundle.js.map +1 -1
  532. package/dist/core/resource-loader.d.ts.map +1 -1
  533. package/dist/core/resource-loader.js +15 -9
  534. package/dist/core/resource-loader.js.map +1 -1
  535. package/dist/core/risk-classifier.d.ts +6 -0
  536. package/dist/core/risk-classifier.d.ts.map +1 -0
  537. package/dist/core/risk-classifier.js +225 -0
  538. package/dist/core/risk-classifier.js.map +1 -0
  539. package/dist/core/runtime-builder.d.ts +76 -17
  540. package/dist/core/runtime-builder.d.ts.map +1 -1
  541. package/dist/core/runtime-builder.js +367 -124
  542. package/dist/core/runtime-builder.js.map +1 -1
  543. package/dist/core/scout-controller.d.ts +6 -0
  544. package/dist/core/scout-controller.d.ts.map +1 -1
  545. package/dist/core/scout-controller.js +66 -52
  546. package/dist/core/scout-controller.js.map +1 -1
  547. package/dist/core/sdk.d.ts +6 -3
  548. package/dist/core/sdk.d.ts.map +1 -1
  549. package/dist/core/sdk.js +64 -27
  550. package/dist/core/sdk.js.map +1 -1
  551. package/dist/core/session-analytics.d.ts.map +1 -1
  552. package/dist/core/session-analytics.js +28 -1
  553. package/dist/core/session-analytics.js.map +1 -1
  554. package/dist/core/session-image-store.d.ts +33 -0
  555. package/dist/core/session-image-store.d.ts.map +1 -0
  556. package/dist/core/session-image-store.js +283 -0
  557. package/dist/core/session-image-store.js.map +1 -0
  558. package/dist/core/session-role.d.ts +33 -0
  559. package/dist/core/session-role.d.ts.map +1 -0
  560. package/dist/core/session-role.js +58 -0
  561. package/dist/core/session-role.js.map +1 -0
  562. package/dist/core/session-snapshot.d.ts +34 -0
  563. package/dist/core/session-snapshot.d.ts.map +1 -0
  564. package/dist/core/session-snapshot.js +68 -0
  565. package/dist/core/session-snapshot.js.map +1 -0
  566. package/dist/core/session-supervision-runtime.d.ts +31 -0
  567. package/dist/core/session-supervision-runtime.d.ts.map +1 -0
  568. package/dist/core/session-supervision-runtime.js +97 -0
  569. package/dist/core/session-supervision-runtime.js.map +1 -0
  570. package/dist/core/settings-manager.d.ts +51 -7
  571. package/dist/core/settings-manager.d.ts.map +1 -1
  572. package/dist/core/settings-manager.js +168 -82
  573. package/dist/core/settings-manager.js.map +1 -1
  574. package/dist/core/system-prompt-builder.d.ts +12 -0
  575. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  576. package/dist/core/system-prompt-builder.js +6 -0
  577. package/dist/core/system-prompt-builder.js.map +1 -1
  578. package/dist/core/system-prompt.d.ts +14 -1
  579. package/dist/core/system-prompt.d.ts.map +1 -1
  580. package/dist/core/system-prompt.js +20 -3
  581. package/dist/core/system-prompt.js.map +1 -1
  582. package/dist/core/tasks/session-task-state.d.ts +13 -6
  583. package/dist/core/tasks/session-task-state.d.ts.map +1 -1
  584. package/dist/core/tasks/session-task-state.js +20 -22
  585. package/dist/core/tasks/session-task-state.js.map +1 -1
  586. package/dist/core/tasks/task-contract-monitor.d.ts +45 -0
  587. package/dist/core/tasks/task-contract-monitor.d.ts.map +1 -0
  588. package/dist/core/tasks/task-contract-monitor.js +56 -0
  589. package/dist/core/tasks/task-contract-monitor.js.map +1 -0
  590. package/dist/core/tasks/task-projection.d.ts +20 -0
  591. package/dist/core/tasks/task-projection.d.ts.map +1 -0
  592. package/dist/core/tasks/task-projection.js +47 -0
  593. package/dist/core/tasks/task-projection.js.map +1 -0
  594. package/dist/core/tasks/task-state.d.ts +12 -0
  595. package/dist/core/tasks/task-state.d.ts.map +1 -1
  596. package/dist/core/tasks/task-state.js +56 -12
  597. package/dist/core/tasks/task-state.js.map +1 -1
  598. package/dist/core/tool-capability-policy.d.ts +13 -0
  599. package/dist/core/tool-capability-policy.d.ts.map +1 -0
  600. package/dist/core/tool-capability-policy.js +85 -0
  601. package/dist/core/tool-capability-policy.js.map +1 -0
  602. package/dist/core/tool-gate-controller.d.ts.map +1 -1
  603. package/dist/core/tool-gate-controller.js +5 -0
  604. package/dist/core/tool-gate-controller.js.map +1 -1
  605. package/dist/core/tool-protocol-controller.d.ts +91 -0
  606. package/dist/core/tool-protocol-controller.d.ts.map +1 -0
  607. package/dist/core/tool-protocol-controller.js +512 -0
  608. package/dist/core/tool-protocol-controller.js.map +1 -0
  609. package/dist/core/tool-recovery-log-records.d.ts +6 -0
  610. package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
  611. package/dist/core/tool-recovery-log-records.js +13 -31
  612. package/dist/core/tool-recovery-log-records.js.map +1 -1
  613. package/dist/core/tool-selection/promotion.d.ts +54 -0
  614. package/dist/core/tool-selection/promotion.d.ts.map +1 -0
  615. package/dist/core/tool-selection/promotion.js +81 -0
  616. package/dist/core/tool-selection/promotion.js.map +1 -0
  617. package/dist/core/tool-selection/tool-performance-store.d.ts +39 -6
  618. package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
  619. package/dist/core/tool-selection/tool-performance-store.js +153 -110
  620. package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
  621. package/dist/core/tool-selection/tool-selection-controller.d.ts +45 -0
  622. package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
  623. package/dist/core/tool-selection/tool-selection-controller.js +96 -0
  624. package/dist/core/tool-selection/tool-selection-controller.js.map +1 -1
  625. package/dist/core/tools/ask-question.d.ts +124 -0
  626. package/dist/core/tools/ask-question.d.ts.map +1 -0
  627. package/dist/core/tools/ask-question.js +693 -0
  628. package/dist/core/tools/ask-question.js.map +1 -0
  629. package/dist/core/tools/bash.d.ts +18 -0
  630. package/dist/core/tools/bash.d.ts.map +1 -1
  631. package/dist/core/tools/bash.js +95 -16
  632. package/dist/core/tools/bash.js.map +1 -1
  633. package/dist/core/tools/delegate-status.d.ts +44 -2
  634. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  635. package/dist/core/tools/delegate-status.js +214 -19
  636. package/dist/core/tools/delegate-status.js.map +1 -1
  637. package/dist/core/tools/delegate.d.ts +15 -13
  638. package/dist/core/tools/delegate.d.ts.map +1 -1
  639. package/dist/core/tools/delegate.js +124 -22
  640. package/dist/core/tools/delegate.js.map +1 -1
  641. package/dist/core/tools/extensionify.d.ts.map +1 -1
  642. package/dist/core/tools/extensionify.js +1 -0
  643. package/dist/core/tools/extensionify.js.map +1 -1
  644. package/dist/core/tools/goal.d.ts +94 -3
  645. package/dist/core/tools/goal.d.ts.map +1 -1
  646. package/dist/core/tools/goal.js +165 -15
  647. package/dist/core/tools/goal.js.map +1 -1
  648. package/dist/core/tools/model-fitness.d.ts +7 -0
  649. package/dist/core/tools/model-fitness.d.ts.map +1 -1
  650. package/dist/core/tools/model-fitness.js +4 -4
  651. package/dist/core/tools/model-fitness.js.map +1 -1
  652. package/dist/core/tools/orchestration-panel.d.ts +43 -0
  653. package/dist/core/tools/orchestration-panel.d.ts.map +1 -0
  654. package/dist/core/tools/orchestration-panel.js +168 -0
  655. package/dist/core/tools/orchestration-panel.js.map +1 -0
  656. package/dist/core/tools/run-process.d.ts +26 -0
  657. package/dist/core/tools/run-process.d.ts.map +1 -0
  658. package/dist/core/tools/run-process.js +138 -0
  659. package/dist/core/tools/run-process.js.map +1 -0
  660. package/dist/core/tools/shell-contract-router.d.ts +6 -1
  661. package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
  662. package/dist/core/tools/shell-contract-router.js +23 -2
  663. package/dist/core/tools/shell-contract-router.js.map +1 -1
  664. package/dist/core/tools/shell-session.d.ts +89 -0
  665. package/dist/core/tools/shell-session.d.ts.map +1 -0
  666. package/dist/core/tools/shell-session.js +432 -0
  667. package/dist/core/tools/shell-session.js.map +1 -0
  668. package/dist/core/tools/task-steps.d.ts +6 -0
  669. package/dist/core/tools/task-steps.d.ts.map +1 -1
  670. package/dist/core/tools/task-steps.js +165 -8
  671. package/dist/core/tools/task-steps.js.map +1 -1
  672. package/dist/core/tools/tmux-dispatch.d.ts +84 -0
  673. package/dist/core/tools/tmux-dispatch.d.ts.map +1 -0
  674. package/dist/core/tools/tmux-dispatch.js +91 -0
  675. package/dist/core/tools/tmux-dispatch.js.map +1 -0
  676. package/dist/core/tools/windows-shell-engine.d.ts +42 -0
  677. package/dist/core/tools/windows-shell-engine.d.ts.map +1 -0
  678. package/dist/core/tools/windows-shell-engine.js +151 -0
  679. package/dist/core/tools/windows-shell-engine.js.map +1 -0
  680. package/dist/core/tools/windows-shell-state.d.ts +40 -0
  681. package/dist/core/tools/windows-shell-state.d.ts.map +1 -0
  682. package/dist/core/tools/windows-shell-state.js +59 -0
  683. package/dist/core/tools/windows-shell-state.js.map +1 -0
  684. package/dist/core/tools/worktree-sync.d.ts +24 -0
  685. package/dist/core/tools/worktree-sync.d.ts.map +1 -0
  686. package/dist/core/tools/worktree-sync.js +338 -0
  687. package/dist/core/tools/worktree-sync.js.map +1 -0
  688. package/dist/core/trust-manager.d.ts +4 -1
  689. package/dist/core/trust-manager.d.ts.map +1 -1
  690. package/dist/core/trust-manager.js +20 -2
  691. package/dist/core/trust-manager.js.map +1 -1
  692. package/dist/core/util/atomic-file.d.ts +55 -0
  693. package/dist/core/util/atomic-file.d.ts.map +1 -0
  694. package/dist/core/util/atomic-file.js +255 -0
  695. package/dist/core/util/atomic-file.js.map +1 -0
  696. package/dist/core/util/bounded-jsonl.d.ts +10 -0
  697. package/dist/core/util/bounded-jsonl.d.ts.map +1 -0
  698. package/dist/core/util/bounded-jsonl.js +75 -0
  699. package/dist/core/util/bounded-jsonl.js.map +1 -0
  700. package/dist/core/util/minimatch-cache.d.ts +33 -0
  701. package/dist/core/util/minimatch-cache.d.ts.map +1 -0
  702. package/dist/core/util/minimatch-cache.js +0 -0
  703. package/dist/core/util/minimatch-cache.js.map +1 -0
  704. package/dist/core/util/value-guards.d.ts +5 -0
  705. package/dist/core/util/value-guards.d.ts.map +1 -0
  706. package/dist/core/util/value-guards.js +12 -0
  707. package/dist/core/util/value-guards.js.map +1 -0
  708. package/dist/core/worktree-sync/codes.d.ts +227 -0
  709. package/dist/core/worktree-sync/codes.d.ts.map +1 -0
  710. package/dist/core/worktree-sync/codes.js +14 -0
  711. package/dist/core/worktree-sync/codes.js.map +1 -0
  712. package/dist/core/worktree-sync/git-engine.d.ts +156 -0
  713. package/dist/core/worktree-sync/git-engine.d.ts.map +1 -0
  714. package/dist/core/worktree-sync/git-engine.js +1191 -0
  715. package/dist/core/worktree-sync/git-engine.js.map +1 -0
  716. package/dist/core/worktree-sync/lane-gate.d.ts +75 -0
  717. package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -0
  718. package/dist/core/worktree-sync/lane-gate.js +360 -0
  719. package/dist/core/worktree-sync/lane-gate.js.map +1 -0
  720. package/dist/core/worktree-sync/runtime.d.ts +47 -0
  721. package/dist/core/worktree-sync/runtime.d.ts.map +1 -0
  722. package/dist/core/worktree-sync/runtime.js +96 -0
  723. package/dist/core/worktree-sync/runtime.js.map +1 -0
  724. package/dist/core/worktree-sync/store.d.ts +69 -0
  725. package/dist/core/worktree-sync/store.d.ts.map +1 -0
  726. package/dist/core/worktree-sync/store.js +252 -0
  727. package/dist/core/worktree-sync/store.js.map +1 -0
  728. package/dist/core/worktree-sync/watcher.d.ts +29 -0
  729. package/dist/core/worktree-sync/watcher.d.ts.map +1 -0
  730. package/dist/core/worktree-sync/watcher.js +93 -0
  731. package/dist/core/worktree-sync/watcher.js.map +1 -0
  732. package/dist/index.d.ts +13 -3
  733. package/dist/index.d.ts.map +1 -1
  734. package/dist/index.js +12 -2
  735. package/dist/index.js.map +1 -1
  736. package/dist/main.d.ts.map +1 -1
  737. package/dist/main.js +179 -1
  738. package/dist/main.js.map +1 -1
  739. package/dist/migrations.d.ts +7 -0
  740. package/dist/migrations.d.ts.map +1 -1
  741. package/dist/migrations.js +197 -1
  742. package/dist/migrations.js.map +1 -1
  743. package/dist/modes/interactive/auto-learn-controller.d.ts +16 -1
  744. package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
  745. package/dist/modes/interactive/auto-learn-controller.js +50 -8
  746. package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
  747. package/dist/modes/interactive/clipboard-input.d.ts +7 -1
  748. package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
  749. package/dist/modes/interactive/clipboard-input.js +44 -6
  750. package/dist/modes/interactive/clipboard-input.js.map +1 -1
  751. package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
  752. package/dist/modes/interactive/components/profile-resource-editor.js +23 -1
  753. package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
  754. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  755. package/dist/modes/interactive/components/settings-selector.js +2 -2
  756. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  757. package/dist/modes/interactive/config-backup.d.ts.map +1 -1
  758. package/dist/modes/interactive/config-backup.js +5 -4
  759. package/dist/modes/interactive/config-backup.js.map +1 -1
  760. package/dist/modes/interactive/extension-ui-host.d.ts +14 -0
  761. package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
  762. package/dist/modes/interactive/extension-ui-host.js +76 -15
  763. package/dist/modes/interactive/extension-ui-host.js.map +1 -1
  764. package/dist/modes/interactive/interactive-mode.d.ts +4 -0
  765. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  766. package/dist/modes/interactive/interactive-mode.js +67 -1
  767. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  768. package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
  769. package/dist/modes/interactive/key-handlers.js +1 -1
  770. package/dist/modes/interactive/key-handlers.js.map +1 -1
  771. package/dist/modes/interactive/local-model-commands.d.ts +43 -0
  772. package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
  773. package/dist/modes/interactive/local-model-commands.js +290 -3
  774. package/dist/modes/interactive/local-model-commands.js.map +1 -1
  775. package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
  776. package/dist/modes/interactive/profile-menu-controller.js +7 -7
  777. package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
  778. package/dist/modes/interactive/report-commands.d.ts.map +1 -1
  779. package/dist/modes/interactive/report-commands.js +21 -0
  780. package/dist/modes/interactive/report-commands.js.map +1 -1
  781. package/dist/modes/interactive/session-flow-commands.d.ts +17 -2
  782. package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
  783. package/dist/modes/interactive/session-flow-commands.js +74 -21
  784. package/dist/modes/interactive/session-flow-commands.js.map +1 -1
  785. package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
  786. package/dist/modes/interactive/session-io-commands.js +16 -6
  787. package/dist/modes/interactive/session-io-commands.js.map +1 -1
  788. package/dist/modes/interactive/session-replacement-errors.d.ts +7 -0
  789. package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -0
  790. package/dist/modes/interactive/session-replacement-errors.js +15 -0
  791. package/dist/modes/interactive/session-replacement-errors.js.map +1 -0
  792. package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
  793. package/dist/modes/interactive/startup-checks.js +1 -1
  794. package/dist/modes/interactive/startup-checks.js.map +1 -1
  795. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  796. package/dist/modes/rpc/rpc-mode.js +82 -23
  797. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  798. package/dist/modes/rpc/rpc-types.d.ts +15 -0
  799. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  800. package/dist/modes/rpc/rpc-types.js +138 -1
  801. package/dist/modes/rpc/rpc-types.js.map +1 -1
  802. package/dist/utils/clipboard-image.d.ts.map +1 -1
  803. package/dist/utils/clipboard-image.js +2 -13
  804. package/dist/utils/clipboard-image.js.map +1 -1
  805. package/dist/utils/clipboard-native.d.ts +1 -0
  806. package/dist/utils/clipboard-native.d.ts.map +1 -1
  807. package/dist/utils/clipboard-native.js.map +1 -1
  808. package/dist/utils/clipboard.d.ts +1 -0
  809. package/dist/utils/clipboard.d.ts.map +1 -1
  810. package/dist/utils/clipboard.js +52 -1
  811. package/dist/utils/clipboard.js.map +1 -1
  812. package/dist/utils/fs-watch.d.ts +11 -0
  813. package/dist/utils/fs-watch.d.ts.map +1 -1
  814. package/dist/utils/fs-watch.js +20 -2
  815. package/dist/utils/fs-watch.js.map +1 -1
  816. package/dist/utils/highlight-js-languages.d.ts +4 -0
  817. package/dist/utils/highlight-js-languages.d.ts.map +1 -0
  818. package/dist/utils/highlight-js-languages.js +573 -0
  819. package/dist/utils/highlight-js-languages.js.map +1 -0
  820. package/dist/utils/platform.d.ts +3 -0
  821. package/dist/utils/platform.d.ts.map +1 -0
  822. package/dist/utils/platform.js +8 -0
  823. package/dist/utils/platform.js.map +1 -0
  824. package/dist/utils/shell.d.ts +7 -1
  825. package/dist/utils/shell.d.ts.map +1 -1
  826. package/dist/utils/shell.js +21 -6
  827. package/dist/utils/shell.js.map +1 -1
  828. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  829. package/dist/utils/syntax-highlight.js +53 -5
  830. package/dist/utils/syntax-highlight.js.map +1 -1
  831. package/dist/utils/tools-manager.d.ts.map +1 -1
  832. package/dist/utils/tools-manager.js +112 -1
  833. package/dist/utils/tools-manager.js.map +1 -1
  834. package/dist/utils/work-directory.d.ts +11 -0
  835. package/dist/utils/work-directory.d.ts.map +1 -1
  836. package/dist/utils/work-directory.js +30 -9
  837. package/dist/utils/work-directory.js.map +1 -1
  838. package/docs/UI_POLISH_ORCHESTRATION.md +44 -0
  839. package/docs/UI_QUALITY_ORCHESTRATION.md +30 -0
  840. package/docs/docs.json +4 -0
  841. package/docs/extensions.md +62 -2
  842. package/docs/harness-architecture.md +156 -0
  843. package/docs/keybindings.md +11 -1
  844. package/docs/process-matrix.md +153 -0
  845. package/docs/rpc.md +45 -2
  846. package/docs/sessions.md +15 -0
  847. package/docs/settings.md +128 -11
  848. package/docs/task-steps.md +8 -0
  849. package/docs/telemetry.md +19 -0
  850. package/docs/tmux-agent-manager.md +92 -2
  851. package/docs/ui-reference/README.md +9 -0
  852. package/docs/ui-reference/orchestration-after.txt +7 -0
  853. package/docs/ui-reference/orchestration-before.txt +7 -0
  854. package/docs/ui-reference/orchestration-reference.txt +6 -0
  855. package/docs/usage.md +14 -2
  856. package/docs/windows.md +52 -3
  857. package/docs/work-directory.md +42 -2
  858. package/docs/worktree-sync.md +250 -0
  859. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  860. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  861. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  862. package/examples/extensions/question.ts +34 -245
  863. package/examples/extensions/questionnaire.ts +41 -407
  864. package/examples/extensions/sandbox/package-lock.json +2 -2
  865. package/examples/extensions/sandbox/package.json +1 -1
  866. package/examples/extensions/with-deps/package-lock.json +2 -2
  867. package/examples/extensions/with-deps/package.json +1 -1
  868. package/npm-shrinkwrap.json +12 -12
  869. package/package.json +10 -4
  870. package/dist/core/delegation/session-worker-result.d.ts +0 -16
  871. package/dist/core/delegation/session-worker-result.d.ts.map +0 -1
  872. package/dist/core/delegation/session-worker-result.js +0 -53
  873. package/dist/core/delegation/session-worker-result.js.map +0 -1
  874. package/dist/core/delegation/worker-result.d.ts +0 -15
  875. package/dist/core/delegation/worker-result.d.ts.map +0 -1
  876. package/dist/core/delegation/worker-result.js +0 -161
  877. package/dist/core/delegation/worker-result.js.map +0 -1
  878. package/dist/core/telemetry.d.ts.map +0 -1
  879. package/dist/core/telemetry.js.map +0 -1
  880. package/docs/integration-sweep-builder-blueprint-2026-07-09.md +0 -365
  881. package/docs/integration-sweep-resume-2026-07-09.md +0 -407
@@ -1 +1 @@
1
- {"version":3,"file":"work-directory.js","sourceRoot":"","sources":["../../src/utils/work-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAEN,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,YAAY,EACZ,SAAS,EACT,MAAM,EACN,UAAU,EACV,UAAU,EACV,aAAa,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAC/C,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAE1D,MAAM,gBAAgB,GAAG,SAAS,CAAC;AACnC,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAC5C,MAAM,kBAAkB,GAAG,CAAC,GAAG,IAAI,CAAC;AACpC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACpD,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,uBAAuB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAClD,MAAM,2BAA2B,GAAG,OAAO,CAAC;AAC5C,MAAM,wBAAwB,GAAG,MAAM,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E,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QACxF,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACX,CAAC;IAED,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,OAAO;QACN,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,KAAK;QACL,KAAK,GAAS;YACb,IAAI,QAAQ;gBAAE,OAAO;YACrB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;YAC7B,IAAI,CAAC;gBACJ,UAAU,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;gBAC7C,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;YAC1C,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QAAA,CACV;QACD,OAAO,GAAS;YACf,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,UAAU,CAAC,UAAU,CAAC,CAAC;YACvB,IAAI,CAAC;gBACJ,SAAS,CAAC,SAAS,CAAC,CAAC;YACtB,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;YACV,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;YAC7B,IAAI,CAAC;gBACJ,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;YAC1C,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QAAA,CACV;KACD,CAAC;AAAA,CACF","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport {\n\ttype Dir,\n\texistsSync,\n\tlstatSync,\n\tmkdirSync,\n\topendirSync,\n\treadFileSync,\n\trmdirSync,\n\trmSync,\n\tunlinkSync,\n\tutimesSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { hostname } from \"node:os\";\nimport { join } from \"node:path\";\n\nexport const PI_WORK_ROOT_ENV = \"PI_WORK_ROOT\";\nexport const WORK_RUN_MANIFEST_FILE = \".pi-work-run.json\";\n\nconst LEASES_DIRECTORY = \".leases\";\nconst CLEANUP_MARKER_FILE = \".cleanup.json\";\nconst MAX_METADATA_BYTES = 4 * 1024;\nconst MAX_LEASE_MARKERS = 256;\nconst MAX_DIRECTORY_DEPTH = 64;\nconst DEFAULT_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1000;\nconst DEFAULT_MAX_RUNS = 64;\nconst DEFAULT_MAX_TOTAL_BYTES = 512 * 1024 * 1024;\nconst DEFAULT_MAX_SCANNED_ENTRIES = 100_000;\nconst DEFAULT_MAX_SCANNED_RUNS = 10_000;\nconst SEGMENT_PATTERN = /^[a-z0-9][a-z0-9._-]{0,63}$/;\nconst WINDOWS_RESERVED_NAMES = new Set([\n\t\"aux\",\n\t\"clock$\",\n\t\"con\",\n\t\"nul\",\n\t\"prn\",\n\t...Array.from({ length: 9 }, (_, index) => `com${index + 1}`),\n\t...Array.from({ length: 9 }, (_, index) => `lpt${index + 1}`),\n]);\n\ninterface WorkRunManifest {\n\tversion: 1;\n\tcategory: string;\n\ttenant: string;\n\trunId: string;\n\tcreatedAt: number;\n}\n\ninterface WorkMarker {\n\tversion: 1;\n\thostname: string;\n\tpid: number;\n\tcreatedAt: number;\n}\n\ninterface InspectedRun {\n\tpath: string;\n\tmtimeMs: number;\n\tbytes: number;\n}\n\ninterface ScanBudget {\n\tremaining: number;\n}\n\nexport interface WorkRetentionOptions {\n\tmaxAgeMs?: number;\n\tmaxRuns?: number;\n\tmaxTotalBytes?: number;\n\t/** Fixed tenant-wide cap for recursive file entries inspected during one prune. */\n\tmaxScannedEntries?: number;\n\t/** Fixed cap for run directories inspected during one prune. */\n\tmaxScannedRuns?: number;\n\tnow?: number;\n}\n\nexport interface AcquireWorkRunOptions {\n\tagentDir: string;\n\tcategory: string;\n\ttenant: string;\n\trunId?: string;\n\tretention?: WorkRetentionOptions | false;\n\tnow?: number;\n}\n\nexport interface WorkRunLease {\n\treadonly path: string;\n\treadonly category: string;\n\treadonly tenant: string;\n\treadonly runId: string;\n\ttouch(): void;\n\trelease(): void;\n}\n\nconst processWorkRuns = new Map<string, WorkRunLease>();\n\nfunction nonNegativeLimit(value: number | undefined, fallback: number): number {\n\treturn value !== undefined && Number.isFinite(value) && value >= 0 ? Math.floor(value) : fallback;\n}\n\nfunction assertPortableSegment(label: string, value: string): void {\n\tif (!SEGMENT_PATTERN.test(value) || value.endsWith(\".\")) {\n\t\tthrow new Error(`${label} must be a lowercase portable path segment (1-64 characters)`);\n\t}\n\tconst stem = value.split(\".\", 1)[0];\n\tif (stem && WINDOWS_RESERVED_NAMES.has(stem)) {\n\t\tthrow new Error(`${label} uses a Windows-reserved path name: ${value}`);\n\t}\n}\n\nfunction ensureDirectory(path: string): void {\n\ttry {\n\t\tmkdirSync(path);\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n\t}\n\tconst stats = lstatSync(path);\n\tif (!stats.isDirectory() || stats.isSymbolicLink()) {\n\t\tthrow new Error(`Work path is not a real directory: ${path}`);\n\t}\n}\n\nfunction ensureTenantDirectory(agentDir: string, category: string, tenant: string): string {\n\tmkdirSync(agentDir, { recursive: true });\n\tconst workRoot = getWorkRoot(agentDir);\n\tensureDirectory(workRoot);\n\tconst categoryDir = join(workRoot, category);\n\tensureDirectory(categoryDir);\n\tconst tenantDir = join(categoryDir, tenant);\n\tensureDirectory(tenantDir);\n\treturn tenantDir;\n}\n\nfunction readSmallJson(path: string): unknown {\n\tconst stats = lstatSync(path);\n\tif (!stats.isFile() || stats.isSymbolicLink() || stats.size > MAX_METADATA_BYTES) {\n\t\tthrow new Error(`Invalid work metadata file: ${path}`);\n\t}\n\treturn JSON.parse(readFileSync(path, \"utf8\")) as unknown;\n}\n\nfunction isManifest(value: unknown, category: string, tenant: string, runId: string): value is WorkRunManifest {\n\tif (!value || typeof value !== \"object\") return false;\n\tconst manifest = value as Partial<WorkRunManifest>;\n\treturn (\n\t\tmanifest.version === 1 &&\n\t\tmanifest.category === category &&\n\t\tmanifest.tenant === tenant &&\n\t\tmanifest.runId === runId &&\n\t\ttypeof manifest.createdAt === \"number\" &&\n\t\tNumber.isFinite(manifest.createdAt)\n\t);\n}\n\nfunction isMarker(value: unknown): value is WorkMarker {\n\tif (!value || typeof value !== \"object\") return false;\n\tconst marker = value as Partial<WorkMarker>;\n\treturn (\n\t\tmarker.version === 1 &&\n\t\ttypeof marker.hostname === \"string\" &&\n\t\ttypeof marker.pid === \"number\" &&\n\t\tNumber.isSafeInteger(marker.pid) &&\n\t\tmarker.pid > 0 &&\n\t\ttypeof marker.createdAt === \"number\" &&\n\t\tNumber.isFinite(marker.createdAt)\n\t);\n}\n\nfunction markerState(path: string): \"active\" | \"stale\" | \"unknown\" {\n\ttry {\n\t\tconst value = readSmallJson(path);\n\t\tif (!isMarker(value)) return \"unknown\";\n\t\tif (value.hostname !== hostname()) return \"active\";\n\t\ttry {\n\t\t\tprocess.kill(value.pid, 0);\n\t\t\treturn \"active\";\n\t\t} catch (error) {\n\t\t\treturn (error as NodeJS.ErrnoException).code === \"EPERM\" ? \"active\" : \"stale\";\n\t\t}\n\t} catch (error) {\n\t\treturn (error as NodeJS.ErrnoException).code === \"ENOENT\" ? \"stale\" : \"unknown\";\n\t}\n}\n\nfunction removeFile(path: string): void {\n\ttry {\n\t\tunlinkSync(path);\n\t} catch {}\n}\n\nfunction cleanupMarkerBlocksAcquisition(runDir: string): boolean {\n\tconst markerPath = join(runDir, CLEANUP_MARKER_FILE);\n\tif (!existsSync(markerPath)) return false;\n\tconst state = markerState(markerPath);\n\tif (state !== \"stale\") return true;\n\tremoveFile(markerPath);\n\treturn existsSync(markerPath);\n}\n\nfunction hasActiveLease(runDir: string): boolean {\n\tconst leasesDir = join(runDir, LEASES_DIRECTORY);\n\tif (!existsSync(leasesDir)) return false;\n\tlet handle: Dir | undefined;\n\ttry {\n\t\thandle = opendirSync(leasesDir);\n\t\tlet scanned = 0;\n\t\twhile (true) {\n\t\t\tconst entry = handle.readSync();\n\t\t\tif (!entry) break;\n\t\t\tscanned++;\n\t\t\tif (scanned > MAX_LEASE_MARKERS) return true;\n\t\t\tif (!entry.isFile()) return true;\n\t\t\tconst markerPath = join(leasesDir, entry.name);\n\t\t\tconst state = markerState(markerPath);\n\t\t\tif (state === \"active\" || state === \"unknown\") return true;\n\t\t\tremoveFile(markerPath);\n\t\t}\n\t} catch {\n\t\treturn true;\n\t} finally {\n\t\ttry {\n\t\t\thandle?.closeSync();\n\t\t} catch {}\n\t}\n\ttry {\n\t\trmdirSync(leasesDir);\n\t} catch {}\n\treturn false;\n}\n\nfunction measureDirectory(path: string, budget: ScanBudget, depth = 0): { bytes: number; complete: boolean } {\n\tif (depth > MAX_DIRECTORY_DEPTH || budget.remaining <= 0) return { bytes: 0, complete: false };\n\tlet bytes = 0;\n\tlet complete = true;\n\tlet handle: Dir | undefined;\n\ttry {\n\t\thandle = opendirSync(path);\n\t\twhile (true) {\n\t\t\tconst entry = handle.readSync();\n\t\t\tif (!entry) break;\n\t\t\tif (budget.remaining <= 0) return { bytes, complete: false };\n\t\t\tbudget.remaining--;\n\t\t\tconst childPath = join(path, entry.name);\n\t\t\ttry {\n\t\t\t\tconst stats = lstatSync(childPath);\n\t\t\t\tif (stats.isDirectory() && !stats.isSymbolicLink()) {\n\t\t\t\t\tconst child = measureDirectory(childPath, budget, depth + 1);\n\t\t\t\t\tbytes += child.bytes;\n\t\t\t\t\tcomplete = complete && child.complete;\n\t\t\t\t} else {\n\t\t\t\t\tbytes += stats.size;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tcomplete = false;\n\t\t\t}\n\t\t}\n\t} catch {\n\t\treturn { bytes, complete: false };\n\t} finally {\n\t\ttry {\n\t\t\thandle?.closeSync();\n\t\t} catch {}\n\t}\n\treturn { bytes, complete };\n}\n\nfunction inspectRun(\n\trunPath: string,\n\tcategory: string,\n\ttenant: string,\n\trunId: string,\n\tbudget: ScanBudget,\n\tunknownBytes: number,\n): InspectedRun | undefined {\n\ttry {\n\t\tconst stats = lstatSync(runPath);\n\t\tif (!stats.isDirectory() || stats.isSymbolicLink()) return undefined;\n\t\tconst manifest = readSmallJson(join(runPath, WORK_RUN_MANIFEST_FILE));\n\t\tif (!isManifest(manifest, category, tenant, runId)) return undefined;\n\t\tconst measured = measureDirectory(runPath, budget);\n\t\treturn {\n\t\t\tpath: runPath,\n\t\t\tmtimeMs: stats.mtimeMs,\n\t\t\tbytes: measured.complete ? measured.bytes : unknownBytes,\n\t\t};\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction createCleanupMarker(runDir: string, now: number): string | undefined {\n\tconst path = join(runDir, CLEANUP_MARKER_FILE);\n\tconst marker: WorkMarker = { version: 1, hostname: hostname(), pid: process.pid, createdAt: now };\n\ttry {\n\t\twriteFileSync(path, JSON.stringify(marker), { encoding: \"utf8\", flag: \"wx\" });\n\t\treturn path;\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code !== \"EEXIST\") return undefined;\n\t\tif (markerState(path) !== \"stale\") return undefined;\n\t\tremoveFile(path);\n\t\ttry {\n\t\t\twriteFileSync(path, JSON.stringify(marker), { encoding: \"utf8\", flag: \"wx\" });\n\t\t\treturn path;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n\nfunction removeRunIfInactive(runPath: string, now: number): boolean {\n\tconst cleanupMarker = createCleanupMarker(runPath, now);\n\tif (!cleanupMarker) return false;\n\tif (hasActiveLease(runPath)) {\n\t\tremoveFile(cleanupMarker);\n\t\treturn false;\n\t}\n\ttry {\n\t\trmSync(runPath, { recursive: true, force: true });\n\t\treturn !existsSync(runPath);\n\t} catch {\n\t\tremoveFile(cleanupMarker);\n\t\treturn false;\n\t}\n}\n\nexport function getWorkRoot(agentDir: string): string {\n\treturn join(agentDir, \"work\");\n}\n\nexport function getWorkTenantDir(agentDir: string, category: string, tenant: string): string {\n\tassertPortableSegment(\"Work category\", category);\n\tassertPortableSegment(\"Work tenant\", tenant);\n\treturn join(getWorkRoot(agentDir), category, tenant);\n}\n\nexport function getWorkRunDir(agentDir: string, category: string, tenant: string, runId: string): string {\n\tassertPortableSegment(\"Work category\", category);\n\tassertPortableSegment(\"Work tenant\", tenant);\n\tassertPortableSegment(\"Work run id\", runId);\n\treturn join(getWorkRoot(agentDir), category, tenant, runId);\n}\n\nexport function createWorkRunId(now = Date.now()): string {\n\treturn `run-${now.toString(36)}-${process.pid.toString(36)}-${randomUUID().slice(0, 12)}`;\n}\n\nexport function pruneWorkTenant(\n\tagentDir: string,\n\tcategory: string,\n\ttenant: string,\n\toptions: WorkRetentionOptions = {},\n): string[] {\n\tconst tenantDir = getWorkTenantDir(agentDir, category, tenant);\n\tif (!existsSync(tenantDir)) return [];\n\ttry {\n\t\tconst stats = lstatSync(tenantDir);\n\t\tif (!stats.isDirectory() || stats.isSymbolicLink()) return [];\n\t} catch {\n\t\treturn [];\n\t}\n\n\tconst now = options.now ?? Date.now();\n\tconst maxAgeMs = nonNegativeLimit(options.maxAgeMs, DEFAULT_MAX_AGE_MS);\n\tconst maxRuns = nonNegativeLimit(options.maxRuns, DEFAULT_MAX_RUNS);\n\tconst maxTotalBytes = nonNegativeLimit(options.maxTotalBytes, DEFAULT_MAX_TOTAL_BYTES);\n\tconst maxScannedRuns = nonNegativeLimit(options.maxScannedRuns, DEFAULT_MAX_SCANNED_RUNS);\n\tconst budget: ScanBudget = {\n\t\tremaining: nonNegativeLimit(options.maxScannedEntries, DEFAULT_MAX_SCANNED_ENTRIES),\n\t};\n\tconst unknownBytes = Math.max(1, maxTotalBytes + 1);\n\tconst runs: InspectedRun[] = [];\n\tlet truncated = false;\n\tlet handle: Dir | undefined;\n\ttry {\n\t\thandle = opendirSync(tenantDir);\n\t\twhile (true) {\n\t\t\tconst entry = handle.readSync();\n\t\t\tif (!entry) break;\n\t\t\tif (entry.name.startsWith(\".\")) continue;\n\t\t\tif (runs.length >= maxScannedRuns) {\n\t\t\t\ttruncated = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!entry.isDirectory() || entry.isSymbolicLink()) continue;\n\t\t\tconst inspected = inspectRun(join(tenantDir, entry.name), category, tenant, entry.name, budget, unknownBytes);\n\t\t\tif (inspected) runs.push(inspected);\n\t\t}\n\t} catch {\n\t\treturn [];\n\t} finally {\n\t\ttry {\n\t\t\thandle?.closeSync();\n\t\t} catch {}\n\t}\n\n\tconst removed: string[] = [];\n\tlet retainedCount = runs.length + (truncated ? maxRuns + 1 : 0);\n\tlet retainedBytes = runs.reduce((sum, run) => sum + run.bytes, 0);\n\tfor (const run of runs.sort((left, right) => left.mtimeMs - right.mtimeMs)) {\n\t\tconst expired = now - run.mtimeMs > maxAgeMs;\n\t\tconst overCount = retainedCount > maxRuns;\n\t\tconst overBytes = retainedBytes > maxTotalBytes;\n\t\tif (!expired && !overCount && !overBytes) continue;\n\t\tif (!removeRunIfInactive(run.path, now)) continue;\n\t\tremoved.push(run.path);\n\t\tretainedCount--;\n\t\tretainedBytes -= run.bytes;\n\t}\n\treturn removed;\n}\n\nexport function getProcessWorkRun(agentDir: string, category: string, tenant: string, runId?: string): WorkRunLease {\n\tconst key = `${agentDir}\\0${category}\\0${tenant}\\0${runId ?? \"\"}`;\n\tconst existing = processWorkRuns.get(key);\n\tif (existing && existsSync(existing.path)) return existing;\n\tconst acquired = acquireWorkRun({ agentDir, category, tenant, runId });\n\tprocessWorkRuns.set(key, acquired);\n\treturn acquired;\n}\n\nexport function acquireWorkRun(options: AcquireWorkRunOptions): WorkRunLease {\n\tconst now = options.now ?? Date.now();\n\tconst runId = options.runId ?? createWorkRunId(now);\n\tassertPortableSegment(\"Work category\", options.category);\n\tassertPortableSegment(\"Work tenant\", options.tenant);\n\tassertPortableSegment(\"Work run id\", runId);\n\tconst tenantDir = ensureTenantDirectory(options.agentDir, options.category, options.tenant);\n\tconst runDir = join(tenantDir, runId);\n\tlet created = false;\n\ttry {\n\t\tmkdirSync(runDir);\n\t\tcreated = true;\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n\t\tconst stats = lstatSync(runDir);\n\t\tif (!stats.isDirectory() || stats.isSymbolicLink()) {\n\t\t\tthrow new Error(`Work run path is not a real directory: ${runDir}`);\n\t\t}\n\t}\n\n\tconst manifestPath = join(runDir, WORK_RUN_MANIFEST_FILE);\n\tif (created) {\n\t\tconst manifest: WorkRunManifest = {\n\t\t\tversion: 1,\n\t\t\tcategory: options.category,\n\t\t\ttenant: options.tenant,\n\t\t\trunId,\n\t\t\tcreatedAt: now,\n\t\t};\n\t\twriteFileSync(manifestPath, JSON.stringify(manifest), { encoding: \"utf8\", flag: \"wx\" });\n\t} else {\n\t\tlet manifest: unknown;\n\t\ttry {\n\t\t\tmanifest = readSmallJson(manifestPath);\n\t\t} catch {\n\t\t\tthrow new Error(`Refusing to adopt unowned work directory: ${runDir}`);\n\t\t}\n\t\tif (!isManifest(manifest, options.category, options.tenant, runId)) {\n\t\t\tthrow new Error(`Work directory manifest does not match its path: ${runDir}`);\n\t\t}\n\t}\n\n\tif (cleanupMarkerBlocksAcquisition(runDir)) {\n\t\tthrow new Error(`Work run is being cleaned: ${runDir}`);\n\t}\n\tconst leasesDir = join(runDir, LEASES_DIRECTORY);\n\tensureDirectory(leasesDir);\n\tconst markerPath = join(leasesDir, `active-${process.pid}-${randomUUID()}.json`);\n\tconst marker: WorkMarker = { version: 1, hostname: hostname(), pid: process.pid, createdAt: now };\n\twriteFileSync(markerPath, JSON.stringify(marker), { encoding: \"utf8\", flag: \"wx\" });\n\tif (cleanupMarkerBlocksAcquisition(runDir)) {\n\t\tremoveFile(markerPath);\n\t\tthrow new Error(`Work run entered cleanup while it was being acquired: ${runDir}`);\n\t}\n\ttry {\n\t\tutimesSync(runDir, new Date(now), new Date(now));\n\t} catch {}\n\n\tif (options.retention !== false) {\n\t\ttry {\n\t\t\tpruneWorkTenant(options.agentDir, options.category, options.tenant, options.retention);\n\t\t} catch {}\n\t}\n\n\tlet released = false;\n\treturn {\n\t\tpath: runDir,\n\t\tcategory: options.category,\n\t\ttenant: options.tenant,\n\t\trunId,\n\t\ttouch(): void {\n\t\t\tif (released) return;\n\t\t\tconst touchedAt = new Date();\n\t\t\ttry {\n\t\t\t\tutimesSync(markerPath, touchedAt, touchedAt);\n\t\t\t\tutimesSync(runDir, touchedAt, touchedAt);\n\t\t\t} catch {}\n\t\t},\n\t\trelease(): void {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\tremoveFile(markerPath);\n\t\t\ttry {\n\t\t\t\trmdirSync(leasesDir);\n\t\t\t} catch {}\n\t\t\tconst touchedAt = new Date();\n\t\t\ttry {\n\t\t\t\tutimesSync(runDir, touchedAt, touchedAt);\n\t\t\t} catch {}\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"work-directory.js","sourceRoot":"","sources":["../../src/utils/work-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAEN,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,YAAY,EACZ,SAAS,EACT,MAAM,EACN,UAAU,EACV,UAAU,EACV,aAAa,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAC/C,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAE1D,MAAM,gBAAgB,GAAG,SAAS,CAAC;AACnC,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAC5C,MAAM,kBAAkB,GAAG,CAAC,GAAG,IAAI,CAAC;AACpC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,kBAAkB,GAAG,EAAE,GAAG,E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KAAK,CAAC;IACrB,OAAO;QACN,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,KAAK;QACL,KAAK,GAAS;YACb,IAAI,QAAQ;gBAAE,OAAO;YACrB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;YAC7B,IAAI,CAAC;gBACJ,UAAU,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;gBAC7C,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;YAC1C,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QAAA,CACV;QACD,OAAO,GAAS;YACf,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,UAAU,CAAC,UAAU,CAAC,CAAC;YACvB,IAAI,CAAC;gBACJ,SAAS,CAAC,SAAS,CAAC,CAAC;YACtB,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;YACV,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;YAC7B,IAAI,CAAC;gBACJ,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;YAC1C,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QAAA,CACV;KACD,CAAC;AAAA,CACF","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport {\n\ttype Dir,\n\texistsSync,\n\tlstatSync,\n\tmkdirSync,\n\topendirSync,\n\treadFileSync,\n\trmdirSync,\n\trmSync,\n\tunlinkSync,\n\tutimesSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { hostname } from \"node:os\";\nimport { join } from \"node:path\";\n\nexport const PI_WORK_ROOT_ENV = \"PI_WORK_ROOT\";\nexport const WORK_RUN_MANIFEST_FILE = \".pi-work-run.json\";\n\nconst LEASES_DIRECTORY = \".leases\";\nconst CLEANUP_MARKER_FILE = \".cleanup.json\";\nconst MAX_METADATA_BYTES = 4 * 1024;\nconst MAX_LEASE_MARKERS = 256;\nconst MAX_DIRECTORY_DEPTH = 64;\nconst DEFAULT_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1000;\nconst DEFAULT_MAX_RUNS = 64;\nconst DEFAULT_MAX_TOTAL_BYTES = 512 * 1024 * 1024;\nconst DEFAULT_MAX_SCANNED_ENTRIES = 100_000;\nconst DEFAULT_MAX_SCANNED_RUNS = 10_000;\nconst SEGMENT_PATTERN = /^[a-z0-9][a-z0-9._-]{0,63}$/;\nconst WINDOWS_RESERVED_NAMES = new Set([\n\t\"aux\",\n\t\"clock$\",\n\t\"con\",\n\t\"nul\",\n\t\"prn\",\n\t...Array.from({ length: 9 }, (_, index) => `com${index + 1}`),\n\t...Array.from({ length: 9 }, (_, index) => `lpt${index + 1}`),\n]);\n\ninterface WorkRunManifest {\n\tversion: 1;\n\tcategory: string;\n\ttenant: string;\n\trunId: string;\n\tcreatedAt: number;\n}\n\ninterface WorkMarker {\n\tversion: 1;\n\thostname: string;\n\tpid: number;\n\tcreatedAt: number;\n}\n\ninterface InspectedRun {\n\tpath: string;\n\tmtimeMs: number;\n\tbytes: number;\n}\n\ninterface ScanBudget {\n\tremaining: number;\n}\n\nexport interface WorkRetentionOptions {\n\tmaxAgeMs?: number;\n\tmaxRuns?: number;\n\tmaxTotalBytes?: number;\n\t/** Fixed tenant-wide cap for recursive file entries inspected during one prune. */\n\tmaxScannedEntries?: number;\n\t/** Fixed cap for run directories inspected during one prune. */\n\tmaxScannedRuns?: number;\n\tnow?: number;\n}\n\n/**\n * Clamp caller-selected retention to the harness ceiling. Consumers may retain less, but cannot turn\n * a managed work tenant into an unbounded artifact store by raising or disabling these limits.\n */\nexport function boundedWorkRetention(options: WorkRetentionOptions = {}): WorkRetentionOptions {\n\treturn {\n\t\tmaxAgeMs: Math.min(nonNegativeLimit(options.maxAgeMs, DEFAULT_MAX_AGE_MS), DEFAULT_MAX_AGE_MS),\n\t\tmaxRuns: Math.min(nonNegativeLimit(options.maxRuns, DEFAULT_MAX_RUNS), DEFAULT_MAX_RUNS),\n\t\tmaxTotalBytes: Math.min(\n\t\t\tnonNegativeLimit(options.maxTotalBytes, DEFAULT_MAX_TOTAL_BYTES),\n\t\t\tDEFAULT_MAX_TOTAL_BYTES,\n\t\t),\n\t\tmaxScannedEntries: Math.min(\n\t\t\tnonNegativeLimit(options.maxScannedEntries, DEFAULT_MAX_SCANNED_ENTRIES),\n\t\t\tDEFAULT_MAX_SCANNED_ENTRIES,\n\t\t),\n\t\tmaxScannedRuns: Math.min(\n\t\t\tnonNegativeLimit(options.maxScannedRuns, DEFAULT_MAX_SCANNED_RUNS),\n\t\t\tDEFAULT_MAX_SCANNED_RUNS,\n\t\t),\n\t\tnow: options.now,\n\t};\n}\n\nexport interface AcquireWorkRunOptions {\n\tagentDir: string;\n\tcategory: string;\n\ttenant: string;\n\trunId?: string;\n\tretention?: WorkRetentionOptions | false;\n\tnow?: number;\n}\n\nexport interface WorkRunLease {\n\treadonly path: string;\n\treadonly category: string;\n\treadonly tenant: string;\n\treadonly runId: string;\n\ttouch(): void;\n\trelease(): void;\n}\n\nconst processWorkRuns = new Map<string, WorkRunLease>();\n\nfunction nonNegativeLimit(value: number | undefined, fallback: number): number {\n\treturn value !== undefined && Number.isFinite(value) && value >= 0 ? Math.floor(value) : fallback;\n}\n\nexport function assertPortablePathSegment(label: string, value: string): void {\n\tif (!SEGMENT_PATTERN.test(value) || value.endsWith(\".\")) {\n\t\tthrow new Error(`${label} must be a lowercase portable path segment (1-64 characters)`);\n\t}\n\tconst stem = value.split(\".\", 1)[0];\n\tif (stem && WINDOWS_RESERVED_NAMES.has(stem)) {\n\t\tthrow new Error(`${label} uses a Windows-reserved path name: ${value}`);\n\t}\n}\n\nfunction ensureDirectory(path: string): void {\n\ttry {\n\t\tmkdirSync(path);\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n\t}\n\tconst stats = lstatSync(path);\n\tif (!stats.isDirectory() || stats.isSymbolicLink()) {\n\t\tthrow new Error(`Work path is not a real directory: ${path}`);\n\t}\n}\n\nfunction ensureTenantDirectory(agentDir: string, category: string, tenant: string): string {\n\tmkdirSync(agentDir, { recursive: true });\n\tconst workRoot = getWorkRoot(agentDir);\n\tensureDirectory(workRoot);\n\tconst categoryDir = join(workRoot, category);\n\tensureDirectory(categoryDir);\n\tconst tenantDir = join(categoryDir, tenant);\n\tensureDirectory(tenantDir);\n\treturn tenantDir;\n}\n\nfunction readSmallJson(path: string): unknown {\n\tconst stats = lstatSync(path);\n\tif (!stats.isFile() || stats.isSymbolicLink() || stats.size > MAX_METADATA_BYTES) {\n\t\tthrow new Error(`Invalid work metadata file: ${path}`);\n\t}\n\treturn JSON.parse(readFileSync(path, \"utf8\")) as unknown;\n}\n\nfunction isManifest(value: unknown, category: string, tenant: string, runId: string): value is WorkRunManifest {\n\tif (!value || typeof value !== \"object\") return false;\n\tconst manifest = value as Partial<WorkRunManifest>;\n\treturn (\n\t\tmanifest.version === 1 &&\n\t\tmanifest.category === category &&\n\t\tmanifest.tenant === tenant &&\n\t\tmanifest.runId === runId &&\n\t\ttypeof manifest.createdAt === \"number\" &&\n\t\tNumber.isFinite(manifest.createdAt)\n\t);\n}\n\nfunction isMarker(value: unknown): value is WorkMarker {\n\tif (!value || typeof value !== \"object\") return false;\n\tconst marker = value as Partial<WorkMarker>;\n\treturn (\n\t\tmarker.version === 1 &&\n\t\ttypeof marker.hostname === \"string\" &&\n\t\ttypeof marker.pid === \"number\" &&\n\t\tNumber.isSafeInteger(marker.pid) &&\n\t\tmarker.pid > 0 &&\n\t\ttypeof marker.createdAt === \"number\" &&\n\t\tNumber.isFinite(marker.createdAt)\n\t);\n}\n\nfunction markerState(path: string): \"active\" | \"stale\" | \"unknown\" {\n\ttry {\n\t\tconst value = readSmallJson(path);\n\t\tif (!isMarker(value)) return \"unknown\";\n\t\tif (value.hostname !== hostname()) return \"active\";\n\t\ttry {\n\t\t\tprocess.kill(value.pid, 0);\n\t\t\treturn \"active\";\n\t\t} catch (error) {\n\t\t\treturn (error as NodeJS.ErrnoException).code === \"EPERM\" ? \"active\" : \"stale\";\n\t\t}\n\t} catch (error) {\n\t\treturn (error as NodeJS.ErrnoException).code === \"ENOENT\" ? \"stale\" : \"unknown\";\n\t}\n}\n\nfunction removeFile(path: string): void {\n\ttry {\n\t\tunlinkSync(path);\n\t} catch {}\n}\n\nfunction cleanupMarkerBlocksAcquisition(runDir: string): boolean {\n\tconst markerPath = join(runDir, CLEANUP_MARKER_FILE);\n\tif (!existsSync(markerPath)) return false;\n\tconst state = markerState(markerPath);\n\tif (state !== \"stale\") return true;\n\tremoveFile(markerPath);\n\treturn existsSync(markerPath);\n}\n\nfunction hasActiveLease(runDir: string): boolean {\n\tconst leasesDir = join(runDir, LEASES_DIRECTORY);\n\tif (!existsSync(leasesDir)) return false;\n\tlet handle: Dir | undefined;\n\ttry {\n\t\thandle = opendirSync(leasesDir);\n\t\tlet scanned = 0;\n\t\twhile (true) {\n\t\t\tconst entry = handle.readSync();\n\t\t\tif (!entry) break;\n\t\t\tscanned++;\n\t\t\tif (scanned > MAX_LEASE_MARKERS) return true;\n\t\t\tif (!entry.isFile()) return true;\n\t\t\tconst markerPath = join(leasesDir, entry.name);\n\t\t\tconst state = markerState(markerPath);\n\t\t\tif (state === \"active\" || state === \"unknown\") return true;\n\t\t\tremoveFile(markerPath);\n\t\t}\n\t} catch {\n\t\treturn true;\n\t} finally {\n\t\ttry {\n\t\t\thandle?.closeSync();\n\t\t} catch {}\n\t}\n\ttry {\n\t\trmdirSync(leasesDir);\n\t} catch {}\n\treturn false;\n}\n\n/**\n * Report whether a managed run is leased or being cleaned. Stale local markers are removed as part\n * of the check; malformed or foreign-host markers remain fail-closed and count as active.\n */\nexport function hasActiveWorkRunLease(runDir: string): boolean {\n\treturn cleanupMarkerBlocksAcquisition(runDir) || hasActiveLease(runDir);\n}\n\nfunction measureDirectory(path: string, budget: ScanBudget, depth = 0): { bytes: number; complete: boolean } {\n\tif (depth > MAX_DIRECTORY_DEPTH || budget.remaining <= 0) return { bytes: 0, complete: false };\n\tlet bytes = 0;\n\tlet complete = true;\n\tlet handle: Dir | undefined;\n\ttry {\n\t\thandle = opendirSync(path);\n\t\twhile (true) {\n\t\t\tconst entry = handle.readSync();\n\t\t\tif (!entry) break;\n\t\t\tif (budget.remaining <= 0) return { bytes, complete: false };\n\t\t\tbudget.remaining--;\n\t\t\tconst childPath = join(path, entry.name);\n\t\t\ttry {\n\t\t\t\tconst stats = lstatSync(childPath);\n\t\t\t\tif (stats.isDirectory() && !stats.isSymbolicLink()) {\n\t\t\t\t\tconst child = measureDirectory(childPath, budget, depth + 1);\n\t\t\t\t\tbytes += child.bytes;\n\t\t\t\t\tcomplete = complete && child.complete;\n\t\t\t\t} else {\n\t\t\t\t\tbytes += stats.size;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tcomplete = false;\n\t\t\t}\n\t\t}\n\t} catch {\n\t\treturn { bytes, complete: false };\n\t} finally {\n\t\ttry {\n\t\t\thandle?.closeSync();\n\t\t} catch {}\n\t}\n\treturn { bytes, complete };\n}\n\nfunction inspectRun(\n\trunPath: string,\n\tcategory: string,\n\ttenant: string,\n\trunId: string,\n\tbudget: ScanBudget,\n\tunknownBytes: number,\n): InspectedRun | undefined {\n\ttry {\n\t\tconst stats = lstatSync(runPath);\n\t\tif (!stats.isDirectory() || stats.isSymbolicLink()) return undefined;\n\t\tconst manifest = readSmallJson(join(runPath, WORK_RUN_MANIFEST_FILE));\n\t\tif (!isManifest(manifest, category, tenant, runId)) return undefined;\n\t\tconst measured = measureDirectory(runPath, budget);\n\t\treturn {\n\t\t\tpath: runPath,\n\t\t\tmtimeMs: stats.mtimeMs,\n\t\t\tbytes: measured.complete ? measured.bytes : unknownBytes,\n\t\t};\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction createCleanupMarker(runDir: string, now: number): string | undefined {\n\tconst path = join(runDir, CLEANUP_MARKER_FILE);\n\tconst marker: WorkMarker = { version: 1, hostname: hostname(), pid: process.pid, createdAt: now };\n\ttry {\n\t\twriteFileSync(path, JSON.stringify(marker), { encoding: \"utf8\", flag: \"wx\" });\n\t\treturn path;\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code !== \"EEXIST\") return undefined;\n\t\tif (markerState(path) !== \"stale\") return undefined;\n\t\tremoveFile(path);\n\t\ttry {\n\t\t\twriteFileSync(path, JSON.stringify(marker), { encoding: \"utf8\", flag: \"wx\" });\n\t\t\treturn path;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n\nfunction removeRunIfInactive(runPath: string, now: number): boolean {\n\tconst cleanupMarker = createCleanupMarker(runPath, now);\n\tif (!cleanupMarker) return false;\n\tif (hasActiveLease(runPath)) {\n\t\tremoveFile(cleanupMarker);\n\t\treturn false;\n\t}\n\ttry {\n\t\trmSync(runPath, { recursive: true, force: true });\n\t\treturn !existsSync(runPath);\n\t} catch {\n\t\tremoveFile(cleanupMarker);\n\t\treturn false;\n\t}\n}\n\nexport function getWorkRoot(agentDir: string): string {\n\treturn join(agentDir, \"work\");\n}\n\nexport function getWorkTenantDir(agentDir: string, category: string, tenant: string): string {\n\tassertPortablePathSegment(\"Work category\", category);\n\tassertPortablePathSegment(\"Work tenant\", tenant);\n\treturn join(getWorkRoot(agentDir), category, tenant);\n}\n\nexport function getWorkRunDir(agentDir: string, category: string, tenant: string, runId: string): string {\n\tassertPortablePathSegment(\"Work category\", category);\n\tassertPortablePathSegment(\"Work tenant\", tenant);\n\tassertPortablePathSegment(\"Work run id\", runId);\n\treturn join(getWorkRoot(agentDir), category, tenant, runId);\n}\n\nexport function createWorkRunId(now = Date.now()): string {\n\treturn `run-${now.toString(36)}-${process.pid.toString(36)}-${randomUUID().slice(0, 12)}`;\n}\n\nexport function pruneWorkTenant(\n\tagentDir: string,\n\tcategory: string,\n\ttenant: string,\n\toptions: WorkRetentionOptions = {},\n): string[] {\n\tconst tenantDir = getWorkTenantDir(agentDir, category, tenant);\n\tif (!existsSync(tenantDir)) return [];\n\ttry {\n\t\tconst stats = lstatSync(tenantDir);\n\t\tif (!stats.isDirectory() || stats.isSymbolicLink()) return [];\n\t} catch {\n\t\treturn [];\n\t}\n\n\tconst now = options.now ?? Date.now();\n\tconst maxAgeMs = nonNegativeLimit(options.maxAgeMs, DEFAULT_MAX_AGE_MS);\n\tconst maxRuns = nonNegativeLimit(options.maxRuns, DEFAULT_MAX_RUNS);\n\tconst maxTotalBytes = nonNegativeLimit(options.maxTotalBytes, DEFAULT_MAX_TOTAL_BYTES);\n\tconst maxScannedRuns = nonNegativeLimit(options.maxScannedRuns, DEFAULT_MAX_SCANNED_RUNS);\n\tconst budget: ScanBudget = {\n\t\tremaining: nonNegativeLimit(options.maxScannedEntries, DEFAULT_MAX_SCANNED_ENTRIES),\n\t};\n\tconst unknownBytes = Math.max(1, maxTotalBytes + 1);\n\tconst runs: InspectedRun[] = [];\n\tlet truncated = false;\n\tlet handle: Dir | undefined;\n\ttry {\n\t\thandle = opendirSync(tenantDir);\n\t\twhile (true) {\n\t\t\tconst entry = handle.readSync();\n\t\t\tif (!entry) break;\n\t\t\tif (entry.name.startsWith(\".\")) continue;\n\t\t\tif (runs.length >= maxScannedRuns) {\n\t\t\t\ttruncated = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!entry.isDirectory() || entry.isSymbolicLink()) continue;\n\t\t\tconst inspected = inspectRun(join(tenantDir, entry.name), category, tenant, entry.name, budget, unknownBytes);\n\t\t\tif (inspected) runs.push(inspected);\n\t\t}\n\t} catch {\n\t\treturn [];\n\t} finally {\n\t\ttry {\n\t\t\thandle?.closeSync();\n\t\t} catch {}\n\t}\n\n\tconst removed: string[] = [];\n\tlet retainedCount = runs.length + (truncated ? maxRuns + 1 : 0);\n\tlet retainedBytes = runs.reduce((sum, run) => sum + run.bytes, 0);\n\tfor (const run of runs.sort((left, right) => left.mtimeMs - right.mtimeMs)) {\n\t\tconst expired = now - run.mtimeMs > maxAgeMs;\n\t\tconst overCount = retainedCount > maxRuns;\n\t\tconst overBytes = retainedBytes > maxTotalBytes;\n\t\tif (!expired && !overCount && !overBytes) continue;\n\t\tif (!removeRunIfInactive(run.path, now)) continue;\n\t\tremoved.push(run.path);\n\t\tretainedCount--;\n\t\tretainedBytes -= run.bytes;\n\t}\n\treturn removed;\n}\n\nexport function getProcessWorkRun(agentDir: string, category: string, tenant: string, runId?: string): WorkRunLease {\n\tconst key = `${agentDir}\\0${category}\\0${tenant}\\0${runId ?? \"\"}`;\n\tconst existing = processWorkRuns.get(key);\n\tif (existing && existsSync(existing.path)) return existing;\n\tconst acquired = acquireWorkRun({ agentDir, category, tenant, runId });\n\tprocessWorkRuns.set(key, acquired);\n\treturn acquired;\n}\n\nexport function acquireWorkRun(options: AcquireWorkRunOptions): WorkRunLease {\n\tconst now = options.now ?? Date.now();\n\tconst runId = options.runId ?? createWorkRunId(now);\n\tassertPortablePathSegment(\"Work category\", options.category);\n\tassertPortablePathSegment(\"Work tenant\", options.tenant);\n\tassertPortablePathSegment(\"Work run id\", runId);\n\tconst tenantDir = ensureTenantDirectory(options.agentDir, options.category, options.tenant);\n\tconst runDir = join(tenantDir, runId);\n\tlet created = false;\n\ttry {\n\t\tmkdirSync(runDir);\n\t\tcreated = true;\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n\t\tconst stats = lstatSync(runDir);\n\t\tif (!stats.isDirectory() || stats.isSymbolicLink()) {\n\t\t\tthrow new Error(`Work run path is not a real directory: ${runDir}`);\n\t\t}\n\t}\n\n\tconst manifestPath = join(runDir, WORK_RUN_MANIFEST_FILE);\n\tif (created) {\n\t\tconst manifest: WorkRunManifest = {\n\t\t\tversion: 1,\n\t\t\tcategory: options.category,\n\t\t\ttenant: options.tenant,\n\t\t\trunId,\n\t\t\tcreatedAt: now,\n\t\t};\n\t\twriteFileSync(manifestPath, JSON.stringify(manifest), { encoding: \"utf8\", flag: \"wx\" });\n\t} else {\n\t\tlet manifest: unknown;\n\t\ttry {\n\t\t\tmanifest = readSmallJson(manifestPath);\n\t\t} catch {\n\t\t\tthrow new Error(`Refusing to adopt unowned work directory: ${runDir}`);\n\t\t}\n\t\tif (!isManifest(manifest, options.category, options.tenant, runId)) {\n\t\t\tthrow new Error(`Work directory manifest does not match its path: ${runDir}`);\n\t\t}\n\t}\n\n\tif (cleanupMarkerBlocksAcquisition(runDir)) {\n\t\tthrow new Error(`Work run is being cleaned: ${runDir}`);\n\t}\n\tconst leasesDir = join(runDir, LEASES_DIRECTORY);\n\tensureDirectory(leasesDir);\n\tconst markerPath = join(leasesDir, `active-${process.pid}-${randomUUID()}.json`);\n\tconst marker: WorkMarker = { version: 1, hostname: hostname(), pid: process.pid, createdAt: now };\n\twriteFileSync(markerPath, JSON.stringify(marker), { encoding: \"utf8\", flag: \"wx\" });\n\tif (cleanupMarkerBlocksAcquisition(runDir)) {\n\t\tremoveFile(markerPath);\n\t\tthrow new Error(`Work run entered cleanup while it was being acquired: ${runDir}`);\n\t}\n\ttry {\n\t\tutimesSync(runDir, new Date(now), new Date(now));\n\t} catch {}\n\n\tif (options.retention !== false) {\n\t\ttry {\n\t\t\tpruneWorkTenant(options.agentDir, options.category, options.tenant, options.retention);\n\t\t} catch {}\n\t}\n\n\tlet released = false;\n\treturn {\n\t\tpath: runDir,\n\t\tcategory: options.category,\n\t\ttenant: options.tenant,\n\t\trunId,\n\t\ttouch(): void {\n\t\t\tif (released) return;\n\t\t\tconst touchedAt = new Date();\n\t\t\ttry {\n\t\t\t\tutimesSync(markerPath, touchedAt, touchedAt);\n\t\t\t\tutimesSync(runDir, touchedAt, touchedAt);\n\t\t\t} catch {}\n\t\t},\n\t\trelease(): void {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\tremoveFile(markerPath);\n\t\t\ttry {\n\t\t\t\trmdirSync(leasesDir);\n\t\t\t} catch {}\n\t\t\tconst touchedAt = new Date();\n\t\t\ttry {\n\t\t\t\tutimesSync(runDir, touchedAt, touchedAt);\n\t\t\t} catch {}\n\t\t},\n\t};\n}\n"]}
@@ -0,0 +1,44 @@
1
+ # UI polish — native orchestration
2
+
3
+ UI type: desktop pro-tool TUI. Named incumbent: the owner's Pi Teams and task-steps extensions. Phase: context/presentation consolidation. Same-task frames are indexed in `docs/ui-reference/`; only information choreography was extracted. No extension code, branding, frame geometry, commands, polling, or storage behavior was copied.
4
+
5
+ ## Ranked findings
6
+
7
+ 1. Fact: native tools rendered implementation-oriented text while the reference made active state scannable in one glance → risk: the packaged harness felt less integrated than its extensions → fix: one semantic, width-aware orchestration panel shared by checklist and workers → M, completed.
8
+ 2. Fact: worker activity lived in a footer fragment and checklist state lived only in transcript output → risk: users had to mentally reconcile two surfaces → fix: one quiet below-editor projection from native session truth, absent when idle → M, completed.
9
+ 3. Fact: extension widget lifecycle was the only reusable mounting path → risk: native UI either impersonated an extension or disappeared on `/reload` → fix: separate host-owned and extension-owned widget maps while keeping one renderer/container path → M, completed.
10
+ 4. Fact: raw details exposed IDs and long evidence at the same weight as current work → risk: dense output buried the next action → fix: collapsed views omit checklist IDs and defer bounded evidence/claims to expansion → S, completed.
11
+
12
+ ## Visual battery
13
+
14
+ | Check | Verdict | Evidence |
15
+ |---|---|---|
16
+ | Iconography / imagery weight | PASS | One restrained status-glyph language; no decorative icon set is appropriate for a terminal. |
17
+ | Surface tone steps + tonal grace | PASS | Existing semantic theme tones carry title, text, dim metadata, accent, warning, and error without hard borders. |
18
+ | Spacing rhythm + alignment / symmetry / balance | PASS | Shared two/four-cell insets and measured suffix/label widths keep rows aligned. |
19
+ | Typography hierarchy | PASS | Badge/action, bold active work, normal labels, and dim metadata form a closed hierarchy. |
20
+ | State clarity — selection, hover, focus | PASS | Non-interactive rows encode every state; existing keyboard expansion remains the single focused interaction. |
21
+ | Content-quality bugs wearing UI clothes | PASS | Empty, hidden-count, missing-evidence, unreviewed, skipped, and unknown-lane states are explicit and bounded. |
22
+ | Density calibration | PASS | At most eight persistent rows plus header/notice; idle state mounts nothing. |
23
+ | Theme, width, and DPI parity | PASS | No literal colors or cell assumptions; semantic tokens and `visibleWidth` bounds cover terminal variation. |
24
+
25
+ ## UX battery
26
+
27
+ | Check | Verdict | Evidence |
28
+ |---|---|---|
29
+ | Surrounding-context compatibility | PASS | No polling, focus capture, modal, shell, filesystem, or extension-lifecycle side effect. |
30
+ | First-60-seconds friction | PASS | State appears automatically when native work exists and disappears automatically when drained. |
31
+ | Interruption audit | PASS | Updates replace a host widget in place and never steal focus. |
32
+ | Dead-end audit | PASS | Empty/error/skipped/review-required states explain the condition in text. |
33
+ | Muscle-memory parity | PASS | Existing `/task`, `task_steps`, `delegate_status`, and tool-expansion paths remain unchanged. |
34
+ | Latency honesty | PASS | Session and lane terminal events update immediately; no hidden completion polling. |
35
+ | Destructive-action safety | N/A | Presentation owns no mutation or destructive control. |
36
+ | Discoverability | PASS | The automatic panel is visible during work; slash-command help and tool results remain the full entry paths. |
37
+
38
+ Accessibility gate: PASS. State is conveyed by glyph and text as well as color, focus remains in the editor, motion is absent, and lines are clipped by display-cell width.
39
+
40
+ ## Acceptance test
41
+
42
+ Repeat the same before/reference/after task at the same 80-column terminal width, then at 34 columns and in both themes. It must pass the art-design-system filters: flow (state → work → evidence), product (one coherent native system), and reality (long content, concurrent lanes, reload/resume, idle cleanup). Leak-check every frame before reuse.
43
+
44
+ The packaged TUI was also smoked at 100 columns with an isolated agent directory: add → `ready`, start → `active`, done → widget absent. No provider request was sent.
@@ -0,0 +1,30 @@
1
+ # UI quality — native orchestration
2
+
3
+ Milestone: native orchestration consolidation, 2026-07-23. Mode: REMEDIATE. UI type: dense desktop terminal tool; keyboard-first, low-motion, state-heavy. Reference: the owner's Pi Teams and task-steps extensions. The extracted presentation grammar is original to the packaged harness: show one compact state summary, order work by urgency, reveal evidence only on expansion, and disappear when idle.
4
+
5
+ ## Seven-dimension score
6
+
7
+ | Dimension | Score | Evidence |
8
+ |---|---:|---|
9
+ | Color and tone balance | 2/3 | Semantic Pi theme tokens; accent is limited to active state and success/warning/error retain distinct glyphs. |
10
+ | Depth and softness | 2/3 | Hierarchy uses tone, indentation, and whitespace instead of a hard box frame; terminal surfaces cannot express physical shadow/radius. |
11
+ | Spatial rhythm | 2/3 | One header, two-cell row inset, four-cell detail inset, bounded row count, and width-safe truncation. |
12
+ | Typographic feel | 2/3 | Bold active labels, dim metadata, struck terminal work, and a short two-level hierarchy within terminal typography. |
13
+ | Motion and effects | 3/3 | Event-driven replacement with no decorative animation is the correct reduced-motion path for this pro-tool. |
14
+ | Drive-feel | 3/3 | Task and lane events update immediately; loading, empty, active, blocked, terminal, and review-required states are designed. |
15
+ | Coherence and finish | 2/3 | `task_steps`, `delegate`, `delegate_status`, and the persistent strip use one renderer and one status vocabulary. |
16
+
17
+ Accessibility gate: pass. Status is never color-only; every line is width-bounded; no motion path exists to disable; existing keyboard tool expansion reveals details; empty/error states remain textual.
18
+
19
+ ## Ranked findings and remediation
20
+
21
+ 1. Generic raw task/worker output hid state priority → increased scanning cost and made orchestration feel bolted on → route all three native tools through `core/tools/orchestration-panel.ts` with shared glyph, tone, spacing, and truncation rules → M, completed.
22
+ 2. Native state lacked a persistent visual owner → users lost the active checklist between tool calls and extension reloads could erase improvised widgets → add host-owned widget lanes in `modes/interactive/extension-ui-host.ts` and refresh them only from session/worker events → M, completed.
23
+ 3. Detailed evidence competed with the action state → long notes and claims dominated normal use → keep the compact panel status-first and reveal bounded evidence, changed files, and blockers only through existing tool expansion → S, completed.
24
+ 4. Theme and narrow-terminal regressions could silently fracture alignment → perceived quality would vary by environment → retain semantic tokens only and lock every rendered line to measured terminal width in focused tests → S, completed.
25
+
26
+ ## Acceptance gate
27
+
28
+ Re-run the frames in `docs/ui-reference/` at narrow and normal terminal widths. Flow passes when status, work, and evidence read in that order. Product passes when task and worker state look like one manufactured system. Reality passes with long labels, blocked work, queued workers, missing evidence, extension reload, resume, and no active work. No dimension may score 0 and the event-driven active-state moment must remain 3/3.
29
+
30
+ Controlled 100-column TUI smoke: `/task add` mounted `ready` with one open row, `/task start` changed the same panel to `active`, and `/task done` removed the panel. The run used an isolated temporary agent directory, made no model call, and left no runtime directory in the repository.
package/docs/docs.json CHANGED
@@ -136,6 +136,10 @@
136
136
  {
137
137
  "title": "Development",
138
138
  "items": [
139
+ {
140
+ "title": "Harness Architecture",
141
+ "path": "harness-architecture.md"
142
+ },
139
143
  {
140
144
  "title": "Development",
141
145
  "path": "development.md"
@@ -13,6 +13,7 @@ Extensions are TypeScript modules that extend pi's behavior. They can subscribe
13
13
  - **Custom UI components** - Full TUI components with keyboard input via `ctx.ui.custom()` for complex interactions
14
14
  - **Custom commands** - Register commands like `/mycommand` via `pi.registerCommand()`
15
15
  - **Session persistence** - Store state that survives restarts via `pi.appendEntry()`
16
+ - **Owned storage** - Keep durable state, rebuildable cache, and bounded work in one extension namespace
16
17
  - **Custom rendering** - Control how tool calls/results and messages appear in TUI
17
18
 
18
19
  **Example use cases:**
@@ -1268,6 +1269,49 @@ export default function (pi: ExtensionAPI) {
1268
1269
 
1269
1270
  ## ExtensionAPI Methods
1270
1271
 
1272
+ ### pi.getStorage(namespace)
1273
+
1274
+ Bind one portable storage namespace to the current extension generation:
1275
+
1276
+ ```typescript
1277
+ import { mkdir, writeFile } from "node:fs/promises";
1278
+ import { join } from "node:path";
1279
+
1280
+ export default function (pi: ExtensionAPI) {
1281
+ const storage = pi.getStorage("my-extension");
1282
+
1283
+ pi.registerCommand("save-extension-state", {
1284
+ handler: async (_args, ctx) => {
1285
+ await mkdir(storage.stateDir, { recursive: true });
1286
+ await writeFile(join(storage.stateDir, "state.json"), JSON.stringify({ cwd: ctx.cwd }), "utf8");
1287
+ },
1288
+ });
1289
+ }
1290
+ ```
1291
+
1292
+ The returned paths have separate lifecycles:
1293
+
1294
+ - `stateDir` → `~/.pi/agent/state/extensions/<namespace>/`: durable machine state. Deleting it loses history.
1295
+ - `cacheDir` → `~/.pi/agent/cache/extensions/<namespace>/`: rebuildable data. It must be safe to delete.
1296
+ - `acquireWorkRun()` → `~/.pi/agent/work/extensions/<namespace>/<run-id>/`: transient output with an ownership manifest, active lease, and hard retention ceilings.
1297
+
1298
+ Calling `getStorage()` is zero-write. It validates the namespace and only returns paths; create `stateDir` or `cacheDir` when the extension actually writes. A generation may bind only one namespace, repeated calls with that namespace return the same view, and unrelated loaded extensions cannot claim the same namespace. Names are lowercase portable path segments of at most 64 characters; traversal, separators, uppercase ambiguity, trailing dots, and Windows-reserved names are rejected.
1299
+
1300
+ Work leases are released automatically if the factory fails and when the extension unloads or reloads. Release a lease sooner when the operation is finished; release is idempotent and does not immediately delete its artifacts:
1301
+
1302
+ ```typescript
1303
+ const run = storage.acquireWorkRun({ runId: "export-1", retention: { maxRuns: 8 } });
1304
+ try {
1305
+ await writeFile(join(run.path, "report.json"), JSON.stringify(report), "utf8");
1306
+ } finally {
1307
+ run.release();
1308
+ }
1309
+ ```
1310
+
1311
+ Extension-selected retention can only reduce the harness defaults. It cannot exceed 30 days, 64 inactive runs, 512 MiB, 10,000 scanned runs, or 100,000 recursively scanned entries, and it cannot be disabled through this API. Do not create extension-specific directories directly beside `auth.json` and `settings.json`. Do not store credentials in extension state or cache; use Pi authentication configuration, environment-backed references, or an external credential manager.
1312
+
1313
+ Extensions are trusted process code, so Pi cannot prevent one from bypassing this API and writing an arbitrary filesystem path. The enforceable package contract is: bundled/packaged extensions use `getStorage()`, transient artifacts go through bounded leases, and `pi doctor` makes nonconforming root writers visible. Durable state must compact its own history; rebuildable cache must impose its own file/byte policy. Neither directory is an unbounded artifact sink.
1314
+
1271
1315
  ### pi.on(event, handler)
1272
1316
 
1273
1317
  Subscribe to events. See [Events](#events) for event types and return values.
@@ -1684,6 +1728,15 @@ pi.registerCommand("my-setup-teardown", {
1684
1728
 
1685
1729
  ## State Management
1686
1730
 
1731
+ Use the storage class that matches the data:
1732
+
1733
+ - Branch/session state that must follow conversation history belongs in tool result `details` or `pi.appendEntry()`.
1734
+ - Durable extension-global machine state belongs in `pi.getStorage(...).stateDir`.
1735
+ - Recomputable indexes and downloaded derivatives belong in `cacheDir`.
1736
+ - Reports, downloads, subprocess output, and scratch files belong in a leased `acquireWorkRun()` directory.
1737
+
1738
+ Never place extension artifacts directly under `~/.pi/agent/`; `pi doctor` reports unexpected root entries without moving or deleting them.
1739
+
1687
1740
  Extensions with state should store it in tool result `details` for proper branching support:
1688
1741
 
1689
1742
  ```typescript
@@ -2011,6 +2064,10 @@ import {
2011
2064
  DEFAULT_MAX_BYTES, // 50KB
2012
2065
  DEFAULT_MAX_LINES, // 2000
2013
2066
  } from "@caupulican/pi-adaptative";
2067
+ import { writeFile } from "node:fs/promises";
2068
+ import { join } from "node:path";
2069
+
2070
+ const storage = pi.getStorage("my-extension");
2014
2071
 
2015
2072
  async execute(toolCallId, params, signal, onUpdate, ctx) {
2016
2073
  const output = await runCommand();
@@ -2024,8 +2081,11 @@ async execute(toolCallId, params, signal, onUpdate, ctx) {
2024
2081
  let result = truncation.content;
2025
2082
 
2026
2083
  if (truncation.truncated) {
2027
- // Write full output to temp file
2028
- const tempFile = writeTempFile(output);
2084
+ // Write full output into this extension's bounded work area
2085
+ const run = storage.acquireWorkRun();
2086
+ const tempFile = join(run.path, "full-output.txt");
2087
+ await writeFile(tempFile, output, "utf8");
2088
+ run.release();
2029
2089
 
2030
2090
  // Inform the LLM where to find complete output
2031
2091
  result += `\n\n[Output truncated: ${truncation.outputLines} of ${truncation.totalLines} lines`;
@@ -0,0 +1,156 @@
1
+ # Harness architecture
2
+
3
+ Pi Adaptative has one production harness. `AgentSession` is its public facade and composition root;
4
+ the low-level agent loop and provider transports remain separate packages. The deleted
5
+ `packages/agent` `AgentHarness` was a competing implementation and must not be restored.
6
+
7
+ ## Package boundaries
8
+
9
+ ```text
10
+ coding-agent/AgentSession
11
+ ├─ runtime + resource policy RuntimeBuilder, ResourceLoader, ProfileFilterController
12
+ ├─ model execution policy ModelSelection, ModelRouter, LocalRuntime, ToolProtocolController
13
+ ├─ foreground turn coordination ContextPipeline, CompactionController, ForegroundRecoveryController
14
+ └─ child work coordination WorkerDelegation, BackgroundLane, Reflection, managed-lane bridge
15
+
16
+
17
+ agent ai
18
+ agent loop + session tree model metadata + provider transports + wire-format repair
19
+ ```
20
+
21
+ Provider-specific request and response behavior belongs in `packages/ai`. Provider-neutral choices
22
+ about which model, reasoning level, tools, resources, or lane to use belong in `packages/coding-agent`.
23
+ `packages/agent` owns the reusable loop, session tree, retry primitives, and compaction mechanics; it
24
+ does not own a second application harness.
25
+
26
+ ## Model execution contract
27
+
28
+ Every foreground or child request resolves the same four facts before transport:
29
+
30
+ 1. Model identity and metadata come from `ModelRegistry` as `Model<Api>`.
31
+ 2. Authentication and headers come from the registry for that exact model.
32
+ 3. `resolveModelThinkingLevel()` applies explicit intent, model defaults, harness fallback, and
33
+ capability clamping.
34
+ 4. `resolveModelToolProtocol()` selects native calls, a forced text fallback, or the exact calibrated
35
+ text dialect. Foreground and isolated tool loops use the same result.
36
+
37
+ Provider adapters may translate those facts to their wire protocol, but must not make orchestration
38
+ policy. Tool names that collide with a provider-reserved namespace are mapped only at the provider
39
+ boundary and mapped back for local execution and history.
40
+
41
+ ## UAC is construction-time omission
42
+
43
+ UAC's primary guarantee is that a withheld capability is not materialized. Runtime checks remain a
44
+ second line of defense, not the main implementation.
45
+
46
+ - `RuntimeBuilder` resolves one access policy before invoking built-in or override tool factories.
47
+ The same policy governs registration and activation, preventing construction/activation drift.
48
+ - `ResourceLoader` filters extension paths before module import and filters skill, prompt, theme, and
49
+ context paths before content loading. Live extension loading repeats the profile check before
50
+ import.
51
+ - Isolated research and worker lanes create fresh tools only for their expanded lane grant. They do
52
+ not copy the foreground registry, extensions, skills, shell, or mutable memory surface.
53
+ - Worker orchestration state is lazily materialized only when the active surface grants `delegate`
54
+ (or a managed-lane terminal report requires the shared notifier); worker-role sessions allocate no
55
+ worker scheduler, lifecycle store, or notification coordinator.
56
+ - Managed children carry parent identity. A valid parent PID classifies the process as a worker before
57
+ settings, stores, resources, or tools are built, so the hard worker ceiling cannot be re-granted by
58
+ a permissive profile.
59
+ - Per-call path/capability gates still validate every isolated lane tool invocation. Worktree-bound
60
+ workers additionally run behind the lane mutation gate.
61
+
62
+ An extension is the unit of module loading. If a profile grants an extension, its module code may
63
+ register several definitions before tool-level filtering. Profiles that need zero extension
64
+ footprint must omit that extension at the resource layer, not merely block one of its tools.
65
+
66
+ ## Child work contracts
67
+
68
+ Owner-authored orchestration profiles are the routing authority. A profile fixes role, ordered model
69
+ policy, exact thinking level, tool names, resource profiles, semantic capability ceiling, budgets,
70
+ concurrency, lease duration, and verification policy. An architect profile additionally declares the
71
+ only worker profile IDs it may dispatch. The model-facing dispatch request contains a task, profile
72
+ ID, instructions, and resource pointers; it has no model, thinking, tool, budget, or concurrency
73
+ override fields.
74
+
75
+ The durable control plane is an append-only session event store projected into objectives, DAG
76
+ tasks, attempts, leases, checkpoints, logical agent bindings, typed results, and a notification
77
+ outbox. Every result carries its attempt lease and fencing token. A stale worker therefore cannot
78
+ win a race after retry or resume. In-process isolated completions have no resumable transcript: an
79
+ interrupted lease is fenced and its persisted dispatch is re-queued as a new attempt. A process-backed
80
+ Pi worker instead retains its logical agent ID and resume context and is woken with `/resume` against
81
+ the same session, worktree, orchestration profile, and checkpoint pointers when present.
82
+
83
+ Policy is a mandatory pre-lease gate. An attempt cannot lease without a compiled execution grant.
84
+ When compilation crosses owner authority or budget, the gate persists a typed approval request and
85
+ an owner notification; approval and rejection replay as durable human decisions. Approval alone is
86
+ never authority: an approved attempt remains unleaseable until policy compiles and binds a new grant
87
+ under the expanded owner authorization. Pausing an objective blocks lease, start, and agent resume;
88
+ cancellation remains a replayable terminal transition across its open tasks and attempts.
89
+
90
+ Acceptance is a runtime invariant, not a worker claim. Task criterion IDs must refer to their
91
+ objective, a completed criterion-bound result must carry trusted evidence for every linked criterion,
92
+ and an objective cannot close until all required criteria have trusted evidence in its task results.
93
+
94
+ In-process workers are bounded child loops with fresh context, a synthetic cache-affinity key, a
95
+ profile-pinned model and exact reasoning level, a construction-filtered tool surface,
96
+ turn/time/token/tool/cost bounds, and parent validation of the result. Process-capable profiles may
97
+ expose `run_process`, which uses an exact executable allowlist, direct argv, a scoped environment,
98
+ bounded output, and process-tree termination; unrestricted shell is not inherited. Worker output is
99
+ untrusted; the parent retrieves it through `delegate_status` after a terminal lane event. A profile
100
+ that requires independent verification names a separate owner-pinned verifier profile. The runtime
101
+ automatically dispatches that verifier as a durable task, withholds the implementation's terminal
102
+ handoff, and reconciles the typed verdict before the implementation can become accepted. Restart
103
+ recovery closes both persistence gaps: an implementation awaiting a not-yet-created verifier is
104
+ re-dispatched, while a persisted verifier result awaiting reconciliation is applied exactly once.
105
+
106
+ Out-of-process managed workers use the same lifecycle shape:
107
+
108
+ ```text
109
+ queued → running → terminal signal → bounded persisted handoff → parent notification → explicit retrieval
110
+ ```
111
+
112
+ Completion discovery is event-driven. A parent never polls pane output to learn whether work ended,
113
+ and a late worker result is never injected into an active foreground transcript. Every managed
114
+ process must emit a terminal signal even on failure, persist a bounded handoff, and wake its owner.
115
+
116
+ ## Runtime generations and reload
117
+
118
+ A runtime generation consists of the selected resource profile, loaded resources, base tool
119
+ definitions, extension runner, wrapped registry, active tool request, and derived system prompt.
120
+ Reload constructs and doctors a candidate generation, then commits it or restores the complete prior
121
+ snapshot. Model/profile changes are re-applied only after extension providers are bound. In-flight
122
+ turns, compaction, and child work register with the shared quiescence gate, so live mutation never
123
+ races an active execution unit.
124
+
125
+ ## Ownership rules for further growth
126
+
127
+ - Keep `AgentSession` as facade and composition root; move coherent state machines into controllers
128
+ with narrow dependencies instead of adding another facade with overlapping state.
129
+ - Add a capability decision to the shared model/resource contract first, then consume it everywhere.
130
+ Do not add provider-name branches to orchestration code when model metadata can express the fact.
131
+ - Decide resource and tool authority before loading or construction. Keep execution gates for path,
132
+ argument, and race-sensitive checks.
133
+ - A background process is incomplete until its terminal event, durable bounded handoff, and owner
134
+ notification all succeed or are reported failed.
135
+ - Persist only serializable facts and stable identities. Runtime tools, extension functions, streams,
136
+ and credentials are reconstructed dependencies, never session payloads.
137
+ - New harness behavior requires a focused faux-provider regression. Provider APIs and paid tokens are
138
+ not used by the coding-agent suite.
139
+
140
+ Worker lifecycle, scheduling, execution, verification, recovery, and notification are owned by
141
+ `WorkerDelegationController`. `ResearchLaneController`, `ModelFitnessController`, and
142
+ `GoalAutoContinueController` own their respective timers, guards, cancellation, accounting, and
143
+ persistence; research and fitness share only the provider-neutral `LaneModelResolver`.
144
+ `BackgroundLaneController` only coordinates these owners and their shared lane read model;
145
+ `ManagedLaneController` owns the distinct out-of-process managed-lane bridge. `ToolProtocolController` owns model protocol selection, probing, calibration,
146
+ circuit breaking, repair teaching, and its per-turn state. `CompactionController` owns manual and
147
+ automatic detection, execution, retries, cancellation, persistence, and extension notification;
148
+ `CompactionSupport` is its provider-neutral model/auth/settings policy.
149
+ `ForegroundRecoveryController` owns the terminal-response latch and ordered retry, quota failover,
150
+ retry closeout, compaction, and queued-continuation decisions. Foreground prompt submission remains
151
+ an `AgentSession` transaction because it composes those independent owners and the public event
152
+ surface; extracting it today would create a callback-heavy proxy rather than a new state owner. Its
153
+ contract is balanced routing events, commit-on-success `nextTurn` consumption, stable per-turn cost
154
+ accounting, and bounded early-message identity cleanup.
155
+ `HostStateStore` owns validated versioned host partitions, lock-scoped mutations, atomic replacement,
156
+ and worker-role zero-write behavior for fitness, model adaptation, and tool-selection evidence.
@@ -87,7 +87,17 @@ Modifier combinations: `ctrl+shift+x`, `alt+ctrl+x`, `ctrl+shift+alt+x`, `ctrl+1
87
87
  | `app.exit` | `ctrl+d` | Exit (when editor empty) |
88
88
  | `app.suspend` | `ctrl+z` (none on Windows) | Suspend to background |
89
89
  | `app.editor.external` | `ctrl+g` | Open in external editor (`$VISUAL` or `$EDITOR`) |
90
- | `app.clipboard.pasteImage` | `alt+v` | Paste image from clipboard |
90
+ | `app.clipboard.pasteImage` | `ctrl+v` (Unix/macOS), `alt+v` (Windows), both (WSL) | Paste image or clipboard text |
91
+
92
+ ### Native Questions
93
+
94
+ These actions apply while the built-in `ask_question` interaction has focus. The dialog also uses the configurable `tui.select.*` and `tui.input.*` actions above, plus `app.clipboard.pasteImage` while entering a custom **Other** answer.
95
+
96
+ | Keybinding id | Default | Description |
97
+ |--------|---------|-------------|
98
+ | `app.question.next` | `tab`, `right` | Move to the next question or review |
99
+ | `app.question.previous` | `shift+tab`, `left` | Move to the previous question |
100
+ | `app.question.toggle` | `space` | Toggle a multi-select answer |
91
101
 
92
102
  ### Sessions
93
103