@caupulican/pi-adaptative 0.94.1 → 0.96.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/bundled-resources/extensions/tmux-agent-manager/README.md +32 -13
  3. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +7 -4
  4. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
  5. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +201 -293
  6. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
  7. package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +272 -392
  8. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.d.ts +52 -0
  9. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.d.ts.map +1 -0
  10. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.js +118 -0
  11. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.js.map +1 -0
  12. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.ts +169 -0
  13. package/dist/bundled-resources/extensions/tmux-agent-manager/templates/builder-validator.json +1 -1
  14. package/dist/bundled-resources/extensions/tmux-agent-manager/templates/provider-prompt-smoke.json +1 -1
  15. package/dist/bundled-resources/extensions/tps/index.d.ts +3 -0
  16. package/dist/bundled-resources/extensions/tps/index.d.ts.map +1 -0
  17. package/dist/bundled-resources/extensions/tps/index.js +44 -0
  18. package/dist/bundled-resources/extensions/tps/index.js.map +1 -0
  19. package/dist/bundled-resources/extensions/tps/index.ts +48 -0
  20. package/dist/bundled-resources/skills/pi-harness-learning/SKILL.md +13 -7
  21. package/dist/bundled-resources/skills/worker-profile-writer/SKILL.md +11 -11
  22. package/dist/core/agent-session-services.d.ts.map +1 -1
  23. package/dist/core/agent-session-services.js +12 -3
  24. package/dist/core/agent-session-services.js.map +1 -1
  25. package/dist/core/agent-session.d.ts +11 -41
  26. package/dist/core/agent-session.d.ts.map +1 -1
  27. package/dist/core/agent-session.js +93 -160
  28. package/dist/core/agent-session.js.map +1 -1
  29. package/dist/core/autonomy/envelope-enforcement.d.ts +6 -1
  30. package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
  31. package/dist/core/autonomy/envelope-enforcement.js +26 -25
  32. package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
  33. package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -1
  34. package/dist/core/autonomy/lane-private-paths.js +2 -1
  35. package/dist/core/autonomy/lane-private-paths.js.map +1 -1
  36. package/dist/core/autonomy/lane-tool-surface.d.ts +8 -8
  37. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  38. package/dist/core/autonomy/lane-tool-surface.js +45 -30
  39. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  40. package/dist/core/autonomy/worker-session-private-scope.d.ts +12 -0
  41. package/dist/core/autonomy/worker-session-private-scope.d.ts.map +1 -0
  42. package/dist/core/autonomy/worker-session-private-scope.js +42 -0
  43. package/dist/core/autonomy/worker-session-private-scope.js.map +1 -0
  44. package/dist/core/autonomy/worker-tool-adapter-registry.d.ts +65 -0
  45. package/dist/core/autonomy/worker-tool-adapter-registry.d.ts.map +1 -0
  46. package/dist/core/autonomy/worker-tool-adapter-registry.js +145 -0
  47. package/dist/core/autonomy/worker-tool-adapter-registry.js.map +1 -0
  48. package/dist/core/background-lane-controller.d.ts +1 -1
  49. package/dist/core/background-lane-controller.d.ts.map +1 -1
  50. package/dist/core/background-lane-controller.js +1 -1
  51. package/dist/core/background-lane-controller.js.map +1 -1
  52. package/dist/core/background-tool-task-controller.d.ts +8 -2
  53. package/dist/core/background-tool-task-controller.d.ts.map +1 -1
  54. package/dist/core/background-tool-task-controller.js +10 -2
  55. package/dist/core/background-tool-task-controller.js.map +1 -1
  56. package/dist/core/compaction-controller.d.ts +3 -0
  57. package/dist/core/compaction-controller.d.ts.map +1 -1
  58. package/dist/core/compaction-controller.js +12 -1
  59. package/dist/core/compaction-controller.js.map +1 -1
  60. package/dist/core/cost-guard-controller.d.ts +37 -0
  61. package/dist/core/cost-guard-controller.d.ts.map +1 -0
  62. package/dist/core/cost-guard-controller.js +71 -0
  63. package/dist/core/cost-guard-controller.js.map +1 -0
  64. package/dist/core/cost-guard.d.ts +9 -4
  65. package/dist/core/cost-guard.d.ts.map +1 -1
  66. package/dist/core/cost-guard.js +7 -3
  67. package/dist/core/cost-guard.js.map +1 -1
  68. package/dist/core/delegation/worker-attempt-executor.d.ts +1 -1
  69. package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
  70. package/dist/core/delegation/worker-attempt-executor.js +0 -1
  71. package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
  72. package/dist/core/delegation/worker-authority-resolver.d.ts +16 -3
  73. package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
  74. package/dist/core/delegation/worker-authority-resolver.js +114 -55
  75. package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
  76. package/dist/core/delegation/worker-claim.d.ts +1 -2
  77. package/dist/core/delegation/worker-claim.d.ts.map +1 -1
  78. package/dist/core/delegation/worker-claim.js.map +1 -1
  79. package/dist/core/delegation/worker-delegation-controller.d.ts +19 -6
  80. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  81. package/dist/core/delegation/worker-delegation-controller.js +125 -40
  82. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  83. package/dist/core/delegation/worker-delegation-request.d.ts +3 -3
  84. package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
  85. package/dist/core/delegation/worker-delegation-request.js +13 -19
  86. package/dist/core/delegation/worker-delegation-request.js.map +1 -1
  87. package/dist/core/delegation/worker-execution-policy.d.ts +3 -2
  88. package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
  89. package/dist/core/delegation/worker-execution-policy.js +54 -39
  90. package/dist/core/delegation/worker-execution-policy.js.map +1 -1
  91. package/dist/core/delegation/worker-fleet-limits.d.ts +3 -3
  92. package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -1
  93. package/dist/core/delegation/worker-fleet-limits.js +7 -7
  94. package/dist/core/delegation/worker-fleet-limits.js.map +1 -1
  95. package/dist/core/delegation/worker-machine-scope.d.ts +12 -0
  96. package/dist/core/delegation/worker-machine-scope.d.ts.map +1 -0
  97. package/dist/core/delegation/worker-machine-scope.js +38 -0
  98. package/dist/core/delegation/worker-machine-scope.js.map +1 -0
  99. package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
  100. package/dist/core/delegation/worker-recovery-coordinator.js +6 -1
  101. package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
  102. package/dist/core/delegation/worker-runner.d.ts +5 -7
  103. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  104. package/dist/core/delegation/worker-runner.js +1 -4
  105. package/dist/core/delegation/worker-runner.js.map +1 -1
  106. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +3 -2
  107. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
  108. package/dist/core/delegation/worker-write-reservation-coordinator.js +50 -25
  109. package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
  110. package/dist/core/durable-custom-message-turn-controller.d.ts +6 -0
  111. package/dist/core/durable-custom-message-turn-controller.d.ts.map +1 -1
  112. package/dist/core/durable-custom-message-turn-controller.js +38 -15
  113. package/dist/core/durable-custom-message-turn-controller.js.map +1 -1
  114. package/dist/core/extension-binding-controller.d.ts +5 -1
  115. package/dist/core/extension-binding-controller.d.ts.map +1 -1
  116. package/dist/core/extension-binding-controller.js +15 -0
  117. package/dist/core/extension-binding-controller.js.map +1 -1
  118. package/dist/core/extension-import-authority.d.ts +3 -1
  119. package/dist/core/extension-import-authority.d.ts.map +1 -1
  120. package/dist/core/extension-import-authority.js +15 -0
  121. package/dist/core/extension-import-authority.js.map +1 -1
  122. package/dist/core/extensions/factory-runtime.d.ts.map +1 -1
  123. package/dist/core/extensions/factory-runtime.js +5 -0
  124. package/dist/core/extensions/factory-runtime.js.map +1 -1
  125. package/dist/core/extensions/runner.d.ts.map +1 -1
  126. package/dist/core/extensions/runner.js +1 -0
  127. package/dist/core/extensions/runner.js.map +1 -1
  128. package/dist/core/extensions/types.d.ts +8 -4
  129. package/dist/core/extensions/types.d.ts.map +1 -1
  130. package/dist/core/extensions/types.js.map +1 -1
  131. package/dist/core/foreground-terminal-handoff-controller.d.ts +14 -0
  132. package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
  133. package/dist/core/foreground-terminal-handoff-controller.js +188 -72
  134. package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
  135. package/dist/core/goals/goal-session-controller.d.ts +2 -0
  136. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  137. package/dist/core/goals/goal-session-controller.js +8 -0
  138. package/dist/core/goals/goal-session-controller.js.map +1 -1
  139. package/dist/core/goals/goal-tool-core.d.ts +5 -4
  140. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  141. package/dist/core/goals/goal-tool-core.js +23 -19
  142. package/dist/core/goals/goal-tool-core.js.map +1 -1
  143. package/dist/core/keybindings.d.ts +2 -2
  144. package/dist/core/keybindings.d.ts.map +1 -1
  145. package/dist/core/keybindings.js +2 -2
  146. package/dist/core/keybindings.js.map +1 -1
  147. package/dist/core/learning/auto-learn-settings.d.ts +84 -0
  148. package/dist/core/learning/auto-learn-settings.d.ts.map +1 -0
  149. package/dist/core/learning/auto-learn-settings.js +66 -0
  150. package/dist/core/learning/auto-learn-settings.js.map +1 -0
  151. package/dist/core/learning/reflection-engine.d.ts +4 -0
  152. package/dist/core/learning/reflection-engine.d.ts.map +1 -1
  153. package/dist/core/learning/reflection-engine.js +48 -10
  154. package/dist/core/learning/reflection-engine.js.map +1 -1
  155. package/dist/core/local-prefix-warm-controller.d.ts +24 -0
  156. package/dist/core/local-prefix-warm-controller.d.ts.map +1 -0
  157. package/dist/core/local-prefix-warm-controller.js +79 -0
  158. package/dist/core/local-prefix-warm-controller.js.map +1 -0
  159. package/dist/core/memory/providers/file-store.d.ts +2 -0
  160. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  161. package/dist/core/memory/providers/file-store.js +71 -15
  162. package/dist/core/memory/providers/file-store.js.map +1 -1
  163. package/dist/core/memory/worker-memory-tools.d.ts +5 -0
  164. package/dist/core/memory/worker-memory-tools.d.ts.map +1 -0
  165. package/dist/core/memory/worker-memory-tools.js +5 -0
  166. package/dist/core/memory/worker-memory-tools.js.map +1 -0
  167. package/dist/core/model-capability.d.ts +7 -0
  168. package/dist/core/model-capability.d.ts.map +1 -1
  169. package/dist/core/model-capability.js +12 -0
  170. package/dist/core/model-capability.js.map +1 -1
  171. package/dist/core/model-registry.d.ts.map +1 -1
  172. package/dist/core/model-registry.js +2 -10
  173. package/dist/core/model-registry.js.map +1 -1
  174. package/dist/core/model-router-controller.d.ts +3 -2
  175. package/dist/core/model-router-controller.d.ts.map +1 -1
  176. package/dist/core/model-router-controller.js +3 -2
  177. package/dist/core/model-router-controller.js.map +1 -1
  178. package/dist/core/orchestration/contracts.d.ts +16 -12
  179. package/dist/core/orchestration/contracts.d.ts.map +1 -1
  180. package/dist/core/orchestration/contracts.js +2 -2
  181. package/dist/core/orchestration/contracts.js.map +1 -1
  182. package/dist/core/orchestration/lane-tool-manifests.d.ts +2 -2
  183. package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
  184. package/dist/core/orchestration/lane-tool-manifests.js +6 -1
  185. package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
  186. package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
  187. package/dist/core/orchestration/profile-registry.js +14 -0
  188. package/dist/core/orchestration/profile-registry.js.map +1 -1
  189. package/dist/core/orchestration/task-profile-writer.d.ts +7 -4
  190. package/dist/core/orchestration/task-profile-writer.d.ts.map +1 -1
  191. package/dist/core/orchestration/task-profile-writer.js +71 -59
  192. package/dist/core/orchestration/task-profile-writer.js.map +1 -1
  193. package/dist/core/orchestration/thinking-level-schema.d.ts +7 -0
  194. package/dist/core/orchestration/thinking-level-schema.d.ts.map +1 -0
  195. package/dist/core/orchestration/thinking-level-schema.js +19 -0
  196. package/dist/core/orchestration/thinking-level-schema.js.map +1 -0
  197. package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
  198. package/dist/core/orchestration/worker-execution-contract.js +12 -5
  199. package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
  200. package/dist/core/profile-filter-controller.d.ts.map +1 -1
  201. package/dist/core/profile-filter-controller.js +5 -2
  202. package/dist/core/profile-filter-controller.js.map +1 -1
  203. package/dist/core/provider-prompt-contracts.d.ts +6 -5
  204. package/dist/core/provider-prompt-contracts.d.ts.map +1 -1
  205. package/dist/core/provider-prompt-contracts.js +9 -11
  206. package/dist/core/provider-prompt-contracts.js.map +1 -1
  207. package/dist/core/provider-request-context-controller.d.ts +2 -0
  208. package/dist/core/provider-request-context-controller.d.ts.map +1 -1
  209. package/dist/core/provider-request-context-controller.js +10 -3
  210. package/dist/core/provider-request-context-controller.js.map +1 -1
  211. package/dist/core/reflection-controller.d.ts +56 -27
  212. package/dist/core/reflection-controller.d.ts.map +1 -1
  213. package/dist/core/reflection-controller.js +206 -117
  214. package/dist/core/reflection-controller.js.map +1 -1
  215. package/dist/core/resource-loader.d.ts.map +1 -1
  216. package/dist/core/resource-loader.js +6 -2
  217. package/dist/core/resource-loader.js.map +1 -1
  218. package/dist/core/risk-classifier.d.ts.map +1 -1
  219. package/dist/core/risk-classifier.js +22 -2
  220. package/dist/core/risk-classifier.js.map +1 -1
  221. package/dist/core/runtime-builder.d.ts +1 -0
  222. package/dist/core/runtime-builder.d.ts.map +1 -1
  223. package/dist/core/runtime-builder.js +25 -14
  224. package/dist/core/runtime-builder.js.map +1 -1
  225. package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
  226. package/dist/core/secrets/credential-exposure-guard.js +55 -10
  227. package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
  228. package/dist/core/session-role.d.ts +6 -8
  229. package/dist/core/session-role.d.ts.map +1 -1
  230. package/dist/core/session-role.js +8 -18
  231. package/dist/core/session-role.js.map +1 -1
  232. package/dist/core/settings-manager.d.ts +20 -16
  233. package/dist/core/settings-manager.d.ts.map +1 -1
  234. package/dist/core/settings-manager.js +75 -50
  235. package/dist/core/settings-manager.js.map +1 -1
  236. package/dist/core/skill-vault.d.ts +15 -0
  237. package/dist/core/skill-vault.d.ts.map +1 -1
  238. package/dist/core/skill-vault.js +79 -45
  239. package/dist/core/skill-vault.js.map +1 -1
  240. package/dist/core/skills.d.ts +3 -0
  241. package/dist/core/skills.d.ts.map +1 -1
  242. package/dist/core/skills.js +6 -6
  243. package/dist/core/skills.js.map +1 -1
  244. package/dist/core/system-prompt-builder.d.ts +3 -0
  245. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  246. package/dist/core/system-prompt-builder.js +73 -13
  247. package/dist/core/system-prompt-builder.js.map +1 -1
  248. package/dist/core/system-prompt.d.ts.map +1 -1
  249. package/dist/core/system-prompt.js +6 -2
  250. package/dist/core/system-prompt.js.map +1 -1
  251. package/dist/core/tool-capability-policy.d.ts +3 -0
  252. package/dist/core/tool-capability-policy.d.ts.map +1 -1
  253. package/dist/core/tool-capability-policy.js +13 -2
  254. package/dist/core/tool-capability-policy.js.map +1 -1
  255. package/dist/core/toolkit/script-runner.d.ts +2 -1
  256. package/dist/core/toolkit/script-runner.d.ts.map +1 -1
  257. package/dist/core/toolkit/script-runner.js +10 -2
  258. package/dist/core/toolkit/script-runner.js.map +1 -1
  259. package/dist/core/tools/delegate-status.d.ts +1 -1
  260. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  261. package/dist/core/tools/delegate-status.js +1 -1
  262. package/dist/core/tools/delegate-status.js.map +1 -1
  263. package/dist/core/tools/delegate.d.ts +4 -15
  264. package/dist/core/tools/delegate.d.ts.map +1 -1
  265. package/dist/core/tools/delegate.js +111 -73
  266. package/dist/core/tools/delegate.js.map +1 -1
  267. package/dist/core/tools/goal.d.ts +3 -4
  268. package/dist/core/tools/goal.d.ts.map +1 -1
  269. package/dist/core/tools/goal.js +30 -23
  270. package/dist/core/tools/goal.js.map +1 -1
  271. package/dist/core/tools/orchestration-panel.d.ts +7 -0
  272. package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
  273. package/dist/core/tools/orchestration-panel.js +58 -9
  274. package/dist/core/tools/orchestration-panel.js.map +1 -1
  275. package/dist/core/tools/profile-writer.d.ts +2 -8
  276. package/dist/core/tools/profile-writer.d.ts.map +1 -1
  277. package/dist/core/tools/profile-writer.js +6 -18
  278. package/dist/core/tools/profile-writer.js.map +1 -1
  279. package/dist/core/tools/run-toolkit-script.d.ts +1 -1
  280. package/dist/core/tools/run-toolkit-script.d.ts.map +1 -1
  281. package/dist/core/tools/run-toolkit-script.js +2 -2
  282. package/dist/core/tools/run-toolkit-script.js.map +1 -1
  283. package/dist/core/tools/skill-audit.d.ts +28 -1
  284. package/dist/core/tools/skill-audit.d.ts.map +1 -1
  285. package/dist/core/tools/skill-audit.js +56 -12
  286. package/dist/core/tools/skill-audit.js.map +1 -1
  287. package/dist/core/tools/skill.d.ts +12 -1
  288. package/dist/core/tools/skill.d.ts.map +1 -1
  289. package/dist/core/tools/skill.js +52 -0
  290. package/dist/core/tools/skill.js.map +1 -1
  291. package/dist/core/tools/skillify.d.ts.map +1 -1
  292. package/dist/core/tools/skillify.js +16 -7
  293. package/dist/core/tools/skillify.js.map +1 -1
  294. package/dist/core/tools/task-steps.d.ts.map +1 -1
  295. package/dist/core/tools/task-steps.js +2 -1
  296. package/dist/core/tools/task-steps.js.map +1 -1
  297. package/dist/core/tools/tmux-dispatch.d.ts +4 -16
  298. package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
  299. package/dist/core/tools/tmux-dispatch.js +5 -20
  300. package/dist/core/tools/tmux-dispatch.js.map +1 -1
  301. package/dist/core/worktree-sync/codes.d.ts +1 -2
  302. package/dist/core/worktree-sync/codes.d.ts.map +1 -1
  303. package/dist/core/worktree-sync/codes.js +1 -2
  304. package/dist/core/worktree-sync/codes.js.map +1 -1
  305. package/dist/core/worktree-sync/lane-gate.d.ts +4 -8
  306. package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -1
  307. package/dist/core/worktree-sync/lane-gate.js +5 -51
  308. package/dist/core/worktree-sync/lane-gate.js.map +1 -1
  309. package/dist/index.d.ts +5 -0
  310. package/dist/index.d.ts.map +1 -1
  311. package/dist/index.js +7 -0
  312. package/dist/index.js.map +1 -1
  313. package/dist/modes/interactive/auto-learn-controller.d.ts +6 -7
  314. package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
  315. package/dist/modes/interactive/auto-learn-controller.js +30 -207
  316. package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
  317. package/dist/modes/interactive/autonomy-commands.js +2 -2
  318. package/dist/modes/interactive/autonomy-commands.js.map +1 -1
  319. package/dist/modes/interactive/components/agents-overlay.d.ts +16 -4
  320. package/dist/modes/interactive/components/agents-overlay.d.ts.map +1 -1
  321. package/dist/modes/interactive/components/agents-overlay.js +108 -29
  322. package/dist/modes/interactive/components/agents-overlay.js.map +1 -1
  323. package/dist/modes/interactive/components/custom-message.js +17 -0
  324. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  325. package/dist/modes/interactive/components/fitness-role-selector.d.ts.map +1 -1
  326. package/dist/modes/interactive/components/fitness-role-selector.js +2 -2
  327. package/dist/modes/interactive/components/fitness-role-selector.js.map +1 -1
  328. package/dist/modes/interactive/components/footer.js +1 -1
  329. package/dist/modes/interactive/components/footer.js.map +1 -1
  330. package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
  331. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  332. package/dist/modes/interactive/components/settings-selector.js +150 -73
  333. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  334. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  335. package/dist/modes/interactive/interactive-mode.js +5 -4
  336. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  337. package/dist/modes/interactive/report-commands.d.ts.map +1 -1
  338. package/dist/modes/interactive/report-commands.js +8 -4
  339. package/dist/modes/interactive/report-commands.js.map +1 -1
  340. package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
  341. package/dist/modes/interactive/settings-selector-flow.js +10 -0
  342. package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
  343. package/docs/extensions.md +10 -0
  344. package/docs/harness-architecture.md +28 -32
  345. package/docs/index.md +2 -1
  346. package/docs/keybindings.md +2 -0
  347. package/docs/process-matrix.md +8 -6
  348. package/docs/resources.md +1 -1
  349. package/docs/settings.md +61 -51
  350. package/docs/task-steps.md +2 -0
  351. package/docs/tmux-agent-manager.md +48 -41
  352. package/docs/usage.md +1 -1
  353. package/docs/work-lifecycle.md +137 -0
  354. package/docs/worker-profiles.md +8 -6
  355. package/docs/worktree-sync.md +26 -20
  356. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  357. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  358. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  359. package/examples/extensions/sandbox/package-lock.json +2 -2
  360. package/examples/extensions/sandbox/package.json +1 -1
  361. package/examples/extensions/with-deps/package-lock.json +2 -2
  362. package/examples/extensions/with-deps/package.json +1 -1
  363. package/npm-shrinkwrap.json +12 -12
  364. package/package.json +4 -4
  365. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +0 -133
  366. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +0 -1
  367. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +0 -199
  368. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +0 -1
  369. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +0 -312
@@ -1,22 +1,24 @@
1
1
  # Task worker presets
2
2
 
3
- Native delegation does not require a profile. `delegate.authority` can choose a child model, reasoning level, role label, and classified tool names directly. Omitted fields inherit from the caller, and Pi persists the resulting immutable execution grant. The model-facing tool has no token, cost, time, attempt, or tool-call ceiling fields; those come only from host settings or owner-authored profiles.
3
+ Native delegation does not require a profile. The model-facing `delegate start` action exposes only top-level `model`, `thinkingLevel`, `path`, and `toolNames` overrides. Omitted fields inherit the live compatible foreground model, thinking level, classified tools, and machine scope. Pi compiles that request into an immutable host execution grant; the model does not provide an authority envelope, role/capability grant, budget, or tool-call ceiling. Budgets, leases, and other limits come from host settings and owner-authored profiles.
4
4
 
5
5
  `delegate` profile actions remain useful when the foreground orchestrator wants a reusable session-scoped preset. They do not edit user or project profile files. Task presets are:
6
6
 
7
- - Derived only from an owner-authorized base profile.
7
+ - Derived from an owner-authored base profile or the live compatible foreground contract.
8
8
  - Immutable and assigned a `task-...` ID by Pi.
9
9
  - Stored on the owning session branch, never shared across independent sessions.
10
10
  - Limited to 32 presets per session.
11
- - Unable to add tools or resources beyond the base profile, and always inherit its budget unchanged.
11
+ - Unable to add tools or resources; tools may only narrow the inherited surface and resources/budgets stay host-owned.
12
12
  - Limited to configured, authenticated, non-exhausted models and a reasoning level that model supports.
13
13
 
14
- Use `delegate { action: "profile_inspect" }` when the reusable bases or model combinations are unknown. Then call `profile_create` with a concise task and only the model/tool/resource defaults worth preserving. Pass the returned profile ID unchanged to `delegate start`; never invent one.
14
+ Use `delegate { action: "profile_inspect" }` when reusable owner-authored bases or model combinations are unknown. Otherwise `profile_create` can derive directly from the live foreground contract. Supply a concise task and only the model, thinking, path, or tool narrowing worth preserving. Pass the returned profile ID unchanged to `delegate start`; never invent one.
15
15
 
16
- Worker agents do not receive the root-only profile/status actions. They receive `delegate` only when their admitted tool set and capability ceiling both retain delegation; a caller can create a non-delegating leaf by narrowing either field. Delegating workers may recursively create descendants within the fixed depth, direct-child, session-agent, and queue bounds. They can discover safe session-peer metadata, exchange non-waking threaded messages and bounded broadcasts, and use event-driven `wait`/`wait_many`, but bounded transcript reads and waking controls remain limited to the caller's own control subtree. Transcript cursors address raw session entries, so a continuation page may be empty after non-message entries; an individually oversized message is omitted with a count instead of being truncated. A descendant may vary model or role through another preset, but it cannot acquire new resources: pointers must fully match the ancestor's admitted pointer metadata, soul text must match exactly, and verifier resources and authority stay within the ancestral verifier or worker boundary.
16
+ Worker agents are root-managed leaves. They do not receive root-only profile/status/control actions or `delegate`, and cannot create descendants. The root owns worker lifecycle, queue admission, budgets, leases, cancellation, status, and bounded transcript retrieval. Each fresh worker receives a new classified tool surface and the live compatible model, thinking level, tools, and machine scope; top-level overrides can narrow or focus that inherited base. Worker output is untrusted evidence delivered to the owning root through the durable terminal handoff.
17
+
18
+ The root `memory` tool and raw memory prompt snapshot never enter a worker or child session. When retrieval is enabled and the admitted profile or dispatch selects `memory_read`, Pi materializes a fresh query-only broker with `memory.query` authority and returns bounded, source-labeled evidence; it cannot write memory or expose memory files.
17
19
 
18
20
  New agents may receive immutable sanitized birth context with `forkTurns: "none"`, `"all"`, or a positive user-turn count such as `"3"`. Omitted starts receive no parent transcript, so a self-contained task cannot inherit and mistake parent-level orchestration intent for child ownership. Explicit inheritance remains available inside the exact provider/model boundary. Crossing either provider or model defaults to no inherited turns, and an explicit non-`none` cross-boundary fork is rejected. Tool calls/results, reasoning/commentary, system/developer/custom messages, mailbox controls, non-text content, and incomplete assistant output never enter the snapshot. Dispatching another task with an existing `agentId` reuses that agent's durable transcript and cannot replace its birth context.
19
21
 
20
22
  `delegate tasks` is the bounded view of the same durable task/DAG runtime used for dispatch and recovery. A new task may name existing same-objective task IDs with `dependsOn`; it remains pending until those dependencies complete, while invalid or cyclic edges fail closed. Evidence-classified transient failures retain their attempt/retry count and exact `notBefore` deadline across restart. Agent, task, and attempt projections are independently capped at 256 entries.
21
23
 
22
- Pi admits fleet and queue capacity before registering a new logical child; every accepted queued child then has a stable agent ID. Queue and projection admission preserve one continuation slot for every pending mandatory verifier, and a verifier blocked by saturation is retried from durable subject state when capacity changes. A parent that waits yields its scheduler slot until an event-driven state change. A worker cannot wait for itself or for a queued target blocked by its own write reservation; that wait fails immediately and tells the worker to finish its task so the owning parent can continue coordination. Every terminal child writes one bounded, idempotent handoff to its owning parent's mailbox. Review-pending results retain terminal status `partial`, and project-level blockers retain `blocked`; neither is projected as a harness failure. Evidence-classified retries stay nonterminal and report that their durable state is preserved. A full mailbox retains that handoff by terminal attempt ID until an explicit capacity/state/recovery signal drains it; no timer polls for delivery. Active parents receive the handoff without transcript races; idle registered parents resume once. Child output remains in the child transcript. `interrupt`, `resume`, `cancel`, and `follow_up` are subtree-scoped; a paused objective keeps a suspended worker nonterminal until resume. `retire` closes only an idle leaf with no unresolved mailbox/reply work and preserves its binding and transcript. A resumed worker retains the exact admitted preset or adaptive grant, model, resources, lineage, and transcript.
24
+ Pi admits fleet and queue capacity before registering each root-dispatched worker; every accepted queued worker then has a stable agent ID. Queue and projection admission preserve one continuation slot for every pending mandatory verifier, and a verifier blocked by saturation is retried from durable subject state when capacity changes. The root yields its scheduler slot while waiting for an event-driven state change. A worker cannot wait for itself or for a queued target blocked by its own write reservation; that wait fails immediately and tells the worker to finish its task so the root can continue coordination. Every terminal worker writes one bounded, idempotent handoff to the owning root's mailbox. Review-pending results retain terminal status `partial`, and project-level blockers retain `blocked`; neither is projected as a harness failure. Evidence-classified retries stay nonterminal and report that their durable state is preserved. A full mailbox retains that handoff by terminal attempt ID until an explicit capacity/state/recovery signal drains it; no timer polls for delivery. The root receives the handoff without transcript races and resumes once when idle. Worker output remains in the worker transcript. `interrupt`, `resume`, `cancel`, and `follow_up` are root-owned; a paused objective keeps a suspended worker nonterminal until resume. `retire` closes only an idle leaf with no unresolved mailbox/reply work and preserves its binding and transcript. A resumed worker retains the exact admitted preset or adaptive grant, model, resources, lineage, and transcript.
@@ -164,24 +164,22 @@ environment value a lane-bound process can set to shed the worker ceiling below.
164
164
 
165
165
  ### Forbidden-tool ceiling
166
166
 
167
- A worker session can never activate: `goal`, `pipeline`, `delegate`, `improvement_loop`,
168
- `extensionify`, `skillify`, `run_toolkit_script`, `model_fitness`, `tmux_agent_manager`,
169
- `context_scout`, `python`. This is enforced as the FIRST line of the tool registry's allow
167
+ A worker session can never activate: the legacy composite `goal`, `secret_store`, `memory`, `delegate`,
168
+ `improvement_loop`, `model_fitness`, `tmux_agent_manager`, or `context_scout`. This is enforced as the FIRST line of the tool registry's allow
170
169
  predicate (`RuntimeBuilder.refreshToolRegistry`'s `isAllowedTool`) -- it wins over an allow-list,
171
- an exclude-list, or an active resource profile that names the tool explicitly. `goal`/`delegate`/
172
- `tmux_agent_manager` are sub-orchestration (a worker dispatching its own workers
173
- defeats single-owner lane accountability); `improvement_loop`/`extensionify`/`skillify` are
174
- self-adaptation surface a worker should never mutate; `run_toolkit_script`/`model_fitness` spend
175
- budget a worker's dispatcher does not control. **`python`** is included because it is a bounded but
176
- still largely unrestricted execution contract -- excluding it is load-bearing for the zero-footprint
177
- guarantee below (an unbounded interpreter can write state anywhere it can reach on disk).
178
- **`context_scout`** is excluded because it is itself sub-orchestration: it spawns its own isolated
179
- agent loop.
180
-
181
- `bash` is deliberately **not** forbidden. It stays available as the same documented cooperative
182
- boundary the lane gate already applies to foreign (non-`pi`) CLIs it cannot structurally contain --
183
- a worker's bash access is bounded by the lane gate's G8/G10 rules and the path envelope below, not
184
- by removing the tool.
170
+ an exclude-list, or an active resource profile that names the tool explicitly. The legacy `goal`
171
+ stays root-only because its composite action set embeds `dispatch_worker`; its non-dispatching
172
+ `create_goal`/`get_goal`/`update_goal` lifecycle tools inherit normally. `delegate`,
173
+ `tmux_agent_manager`, `context_scout`, and `model_fitness` launch agent/provider worker loops.
174
+ `memory` and `improvement_loop` mutate root-owned reflection state, while `secret_store` mutates
175
+ machine credential/project bindings. Ordinary tools including `pipeline`, `ask_question`, `skill`,
176
+ `extensionify`, `skillify`, and `run_toolkit_script` inherit when the orchestrator exposes them.
177
+
178
+ `bash` and `python` are deliberately **not** forbidden. Removing only one execution route would not
179
+ create a meaningful filesystem boundary. Pi hard-denies private harness roots for structural
180
+ read/write/edit/search calls, but arbitrary process code remains a deliberate host-trust boundary and
181
+ can reach any file visible to the OS account. The harness does not claim a process sandbox it does not
182
+ have; lane G8/G10 and the land gate remain the backstops for repository integration.
185
183
 
186
184
  ### `worktree_sync` tool scoping for a worker
187
185
 
@@ -207,7 +205,15 @@ deliberately engine-level and applies to `land`/`release_lane` ONLY -- `sync`/`c
207
205
  from the tool-layer `laneKey` check above. `release_lane`'s existing G11 discard-confirm requirement
208
206
  is unaffected: it still applies once ownership no longer conflicts.
209
207
 
210
- ### Edit/write path envelope
208
+ ### Structural path envelopes
209
+
210
+ Every worker session wraps structural read/write/edit/grep/find/ls calls in a symlink-safe private-path
211
+ envelope. `auth.json`, `MEMORY.md`, `USER.md`, settings/model files, session/state/work roots, and the
212
+ active project's `.pi/settings.json` are denied before the underlying tool runs. The positive scope is
213
+ empty for an unrestricted worker, meaning arbitrary sibling projects and machine paths remain available
214
+ as required by the inherited full-machine profile. A managed Pi worker launched with an explicit profile
215
+ `path` receives that path through an immutable startup channel, and the same envelope then denies
216
+ structural access outside it.
211
217
 
212
218
  For a lane-bound session, `edit`/`write` targets are checked against the lane's own worktree root
213
219
  (`WorktreeLaneGate.checkMutation`'s `targetPath` parameter, resolved by `RuntimeBuilder`'s tool
@@ -216,8 +222,8 @@ lane's worktree root and the target are both resolved through `realpath` (walkin
216
222
  nearest EXISTING ancestor when the target itself does not exist yet, so a not-yet-created file
217
223
  cannot be smuggled through a symlink that escapes the lane). A target outside the resolved lane root
218
224
  is refused (`path_outside_lane`). No active lane record leaves the existing fail-open behavior
219
- unchanged. `bash` is untouched by this check -- its containment stays the G10 cooperative boundary
220
- described above.
225
+ unchanged. Arbitrary process code is untouched by the structural envelope and retains the explicit
226
+ host-trust semantics described above.
221
227
 
222
228
  ### Zero state/settings footprint
223
229
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider",
3
- "version": "0.94.1",
3
+ "version": "0.96.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-custom-provider",
9
- "version": "0.94.1",
9
+ "version": "0.96.0",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.52.0"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-anthropic",
3
3
  "private": true,
4
- "version": "0.94.1",
4
+ "version": "0.96.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-gitlab-duo",
3
3
  "private": true,
4
- "version": "0.94.1",
4
+ "version": "0.96.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
- "version": "0.94.1",
3
+ "version": "0.96.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-sandbox",
9
- "version": "0.94.1",
9
+ "version": "0.96.0",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sandbox-runtime": "^0.0.26"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
3
  "private": true,
4
- "version": "0.94.1",
4
+ "version": "0.96.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
- "version": "0.94.1",
3
+ "version": "0.96.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-with-deps",
9
- "version": "0.94.1",
9
+ "version": "0.96.0",
10
10
  "dependencies": {
11
11
  "ms": "^2.1.3"
12
12
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
3
  "private": true,
4
- "version": "0.94.1",
4
+ "version": "0.96.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@caupulican/pi-adaptative",
3
- "version": "0.94.1",
3
+ "version": "0.96.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@caupulican/pi-adaptative",
9
- "version": "0.94.1",
9
+ "version": "0.96.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@caupulican/pi-agent-core": "^0.94.1",
13
- "@caupulican/pi-ai": "^0.94.1",
14
- "@caupulican/pi-tui": "^0.94.1",
12
+ "@caupulican/pi-agent-core": "^0.96.0",
13
+ "@caupulican/pi-ai": "^0.96.0",
14
+ "@caupulican/pi-tui": "^0.96.0",
15
15
  "@silvia-odwyer/photon-node": "0.3.4",
16
16
  "chalk": "5.6.2",
17
17
  "cross-spawn": "7.0.6",
@@ -506,11 +506,11 @@
506
506
  }
507
507
  },
508
508
  "node_modules/@caupulican/pi-agent-core": {
509
- "version": "0.94.1",
510
- "resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.94.1.tgz",
509
+ "version": "0.96.0",
510
+ "resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.96.0.tgz",
511
511
  "license": "MIT",
512
512
  "dependencies": {
513
- "@caupulican/pi-ai": "^0.94.1",
513
+ "@caupulican/pi-ai": "^0.96.0",
514
514
  "ignore": "7.0.5",
515
515
  "typebox": "1.1.38",
516
516
  "yaml": "2.9.0"
@@ -520,8 +520,8 @@
520
520
  }
521
521
  },
522
522
  "node_modules/@caupulican/pi-ai": {
523
- "version": "0.94.1",
524
- "resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.94.1.tgz",
523
+ "version": "0.96.0",
524
+ "resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.96.0.tgz",
525
525
  "license": "MIT",
526
526
  "dependencies": {
527
527
  "@anthropic-ai/sdk": "0.117.1",
@@ -546,8 +546,8 @@
546
546
  }
547
547
  },
548
548
  "node_modules/@caupulican/pi-tui": {
549
- "version": "0.94.1",
550
- "resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.94.1.tgz",
549
+ "version": "0.96.0",
550
+ "resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.96.0.tgz",
551
551
  "license": "MIT",
552
552
  "dependencies": {
553
553
  "get-east-asian-width": "1.6.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caupulican/pi-adaptative",
3
- "version": "0.94.1",
3
+ "version": "0.96.0",
4
4
  "description": "Adaptive fork of Pi coding agent for self-evolving agent harness experiments",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -89,9 +89,9 @@
89
89
  "postinstall": "node scripts/postinstall-python-runtime.mjs"
90
90
  },
91
91
  "dependencies": {
92
- "@caupulican/pi-agent-core": "^0.94.1",
93
- "@caupulican/pi-ai": "^0.94.1",
94
- "@caupulican/pi-tui": "^0.94.1",
92
+ "@caupulican/pi-agent-core": "^0.96.0",
93
+ "@caupulican/pi-ai": "^0.96.0",
94
+ "@caupulican/pi-tui": "^0.96.0",
95
95
  "@silvia-odwyer/photon-node": "0.3.4",
96
96
  "chalk": "5.6.2",
97
97
  "cross-spawn": "7.0.6",
@@ -1,133 +0,0 @@
1
- import type { Usage } from "@caupulican/pi-ai";
2
- /**
3
- * The STANDING GRANT for approval-gated tmux dispatch (owner authorizes once via `grant_dispatch`;
4
- * the extension then dispatches unattended WITHIN the grant's bounds). Pure data + pure decode/decision
5
- * logic only — no session/tmux/filesystem access, so every function here is directly unit-testable.
6
- * The extension (index.ts) owns reading/writing session custom entries and calls into this module for
7
- * decoding and authorization decisions.
8
- *
9
- * HONEST TRUST BOUNDARY: this grant bounds WHO may be launched, HOW OFTEN, and WITH WHAT launch-time
10
- * envelope (pushed into the child's own CLI flags) — it never claims to gate the child's in-process
11
- * tool loop, which is a separate OS process outside this runtime's `beforeToolCall` machinery.
12
- */
13
- export type Provider = "pi" | "codex" | "agy" | "claude" | "opencode" | "custom";
14
- export declare const GRANT_CUSTOM_TYPE = "tmux-dispatch-grant";
15
- export declare const GRANT_USAGE_CUSTOM_TYPE = "tmux-dispatch-grant-usage";
16
- export interface TmuxDispatchGrantEnvelope {
17
- allowedTools?: string[];
18
- resourceProfile?: string;
19
- writePaths?: string[];
20
- }
21
- export interface TmuxDispatchGrantBudget {
22
- maxLaunches: number;
23
- maxWallClockMs?: number;
24
- maxUsdAdvisory?: number;
25
- }
26
- export interface TmuxDispatchGrant {
27
- grantId: string;
28
- createdAt: string;
29
- agent: Provider;
30
- scope: {
31
- goalId?: string;
32
- };
33
- envelope: TmuxDispatchGrantEnvelope;
34
- budget: TmuxDispatchGrantBudget;
35
- expiresAt?: string;
36
- }
37
- /** Appended by `revoke_grant`. Shares `GRANT_CUSTOM_TYPE` so the SAME latest-on-branch read that
38
- * resolves an active grant also sees a revocation and stops treating any older grant beneath it as
39
- * active — a tombstone is a hard stop, never skipped over to resurrect an earlier grant. */
40
- export interface TmuxDispatchGrantTombstone {
41
- tombstone: true;
42
- grantId: string;
43
- revokedAt: string;
44
- }
45
- export interface TmuxDispatchGrantUsage {
46
- grantId: string;
47
- jobId: string;
48
- at: string;
49
- }
50
- export declare function isTmuxDispatchGrantTombstone(value: unknown): value is TmuxDispatchGrantTombstone;
51
- export declare function isTmuxDispatchGrant(value: unknown): value is TmuxDispatchGrant;
52
- export declare function isTmuxDispatchGrantUsage(value: unknown): value is TmuxDispatchGrantUsage;
53
- export declare function makeGrantId(): string;
54
- export interface GrantCoverageRequest {
55
- agent: Provider;
56
- goalId?: string;
57
- nowIso?: string;
58
- }
59
- /** Whether `grant` authorizes a launch for `request`: same agent, goal-scope match (an UNSCOPED grant
60
- * covers any goal including none; a goal-SCOPED grant covers ONLY that exact goalId), and the grant is
61
- * not past `expiresAt`. Budget (maxLaunches) is checked separately via {@link isGrantBudgetExhausted}
62
- * because counting usages requires the caller's session-entry access. */
63
- export declare function grantCovers(grant: TmuxDispatchGrant, request: GrantCoverageRequest): boolean;
64
- /** Count spend entries for `grantId` among already-decoded custom-entry payloads (the caller walks the
65
- * session branch and passes the raw `data` values — this stays pure/session-agnostic). */
66
- export declare function countGrantUsages(grantId: string, usageEntries: readonly unknown[]): number;
67
- export declare function isGrantBudgetExhausted(grant: TmuxDispatchGrant, usedCount: number): boolean;
68
- export declare function buildGrantUsageEntry(grantId: string, jobId: string, nowIso?: string): TmuxDispatchGrantUsage;
69
- export declare function buildTombstone(grantId: string, nowIso?: string): TmuxDispatchGrantTombstone;
70
- export interface GrantDispatchParams {
71
- agent: Provider;
72
- goalId?: string;
73
- allowedTools?: string[];
74
- resourceProfile?: string;
75
- writePaths?: string[];
76
- maxLaunches: number;
77
- expiresInMinutes?: number;
78
- maxUsdAdvisory?: number;
79
- }
80
- /** Build a new grant record from `grant_dispatch` params. Pure — the caller (index.ts) owns the
81
- * approval gate (ui.confirm / opt-in flag) and the `pi.appendEntry` persistence; this only shapes the
82
- * data, so it stays independently testable and never itself decides whether creation is authorized. */
83
- export declare function buildGrant(params: GrantDispatchParams, nowIso?: string): TmuxDispatchGrant;
84
- export declare function describeGrant(grant: TmuxDispatchGrant): string;
85
- export declare const DEFAULT_READ_BIASED_TOOLS: readonly string[];
86
- export interface LaunchProfileSource {
87
- /** Human-readable identity for the scoped system prompt (e.g. "grant <id>" or a one-shot label). */
88
- identity: string;
89
- allowedTools?: string[];
90
- resourceProfile?: string;
91
- writePaths?: string[];
92
- /**
93
- * Worktree-sync lane key this launch is bound to (per-agent -- see `applyLaunchProfile`'s caller,
94
- * which builds a per-agent `LaunchProfileSource` only when that agent carries `worktreeLane`).
95
- * When present, `buildLaunchProfileFlags` appends `--worktree-lane <key>` (the same CLI flag
96
- * `src/cli/args.ts` already exposes, sugar over the `PI_WORKTREE_LANE` env contract) and
97
- * `buildScopedSystemPrompt` appends one lane-doctrine sentence.
98
- */
99
- worktreeLane?: string;
100
- /**
101
- * Process-matrix parent identity for this launch (see `core/process-matrix/runtime.ts`): the
102
- * dispatching process's own pid/sessionId. When present, `buildLaunchProfileFlags` appends
103
- * `--parent-pid`/`--parent-session` (sugar over `PI_PARENT_PID`/`PI_PARENT_SESSION`) so the
104
- * child self-registers as a worker of this session and winds down gracefully if it disappears.
105
- */
106
- parentPid?: number;
107
- parentSession?: string;
108
- /** Stable goal/task identity used to fence process-matrix recovery. */
109
- taskRef?: string;
110
- }
111
- /** A grant-covered launch derives its profile from the grant's envelope. */
112
- export declare function launchProfileSourceFromGrant(grant: TmuxDispatchGrant): LaunchProfileSource;
113
- /** A one-shot interactively-approved launch (no standing grant) still gets the conservative default
114
- * profile — approving a single launch is not the same as defining an unrestricted envelope. */
115
- export declare const ONE_SHOT_LAUNCH_PROFILE_SOURCE: LaunchProfileSource;
116
- export interface LaunchProfileFlag {
117
- flag: string;
118
- value?: string;
119
- }
120
- /** Build the CLI flags to append to a child `pi` invocation so the grant's envelope lives in the
121
- * child's OWN launch config (verified flag names: --tools, --resource-profile, --no-extensions,
122
- * --no-skills, --append-system-prompt). Never includes --no-approve: the child must keep gating its
123
- * own hard stops. */
124
- export declare function buildLaunchProfileFlags(source: LaunchProfileSource): LaunchProfileFlag[];
125
- export declare function buildScopedSystemPrompt(source: LaunchProfileSource): string;
126
- /** Permissively decode a worker-reported usage CLAIM (a cooperative worker may write this to a
127
- * well-known sibling file before printing its completion marker). Read-defensive: missing/malformed
128
- * numeric fields default to 0 rather than throwing — this is untrusted, OPTIONAL, advisory input, never
129
- * an authoritative billing record. Returns undefined only when `raw` isn't even an object, so the
130
- * caller can distinguish "no claim offered" (skip reporting) from "a claim was offered" (report it,
131
- * however partial). */
132
- export declare function decodeTmuxWorkerUsageClaim(raw: unknown): Usage | undefined;
133
- //# sourceMappingURL=dispatch-grant.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatch-grant.d.ts","sourceRoot":"","sources":["../../../../src/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts"],"names":[],"mappings":"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"}
@@ -1,199 +0,0 @@
1
- import * as crypto from "node:crypto";
2
- export const GRANT_CUSTOM_TYPE = "tmux-dispatch-grant";
3
- export const GRANT_USAGE_CUSTOM_TYPE = "tmux-dispatch-grant-usage";
4
- const PROVIDERS = ["pi", "codex", "agy", "claude", "opencode", "custom"];
5
- function isProvider(value) {
6
- return typeof value === "string" && PROVIDERS.includes(value);
7
- }
8
- function isPlainRecord(value) {
9
- return typeof value === "object" && value !== null && !Array.isArray(value);
10
- }
11
- export function isTmuxDispatchGrantTombstone(value) {
12
- if (!isPlainRecord(value))
13
- return false;
14
- return value.tombstone === true && typeof value.grantId === "string" && typeof value.revokedAt === "string";
15
- }
16
- export function isTmuxDispatchGrant(value) {
17
- if (!isPlainRecord(value) || value.tombstone === true)
18
- return false;
19
- if (typeof value.grantId !== "string" || typeof value.createdAt !== "string" || !isProvider(value.agent))
20
- return false;
21
- if (!isPlainRecord(value.scope) || !isPlainRecord(value.envelope) || !isPlainRecord(value.budget))
22
- return false;
23
- return typeof value.budget.maxLaunches === "number" && Number.isFinite(value.budget.maxLaunches);
24
- }
25
- export function isTmuxDispatchGrantUsage(value) {
26
- if (!isPlainRecord(value))
27
- return false;
28
- return typeof value.grantId === "string" && typeof value.jobId === "string" && typeof value.at === "string";
29
- }
30
- export function makeGrantId() {
31
- return `grant-${Date.now().toString(36)}-${crypto.randomBytes(4).toString("hex")}`;
32
- }
33
- /** Whether `grant` authorizes a launch for `request`: same agent, goal-scope match (an UNSCOPED grant
34
- * covers any goal including none; a goal-SCOPED grant covers ONLY that exact goalId), and the grant is
35
- * not past `expiresAt`. Budget (maxLaunches) is checked separately via {@link isGrantBudgetExhausted}
36
- * because counting usages requires the caller's session-entry access. */
37
- export function grantCovers(grant, request) {
38
- if (grant.agent !== request.agent)
39
- return false;
40
- if (grant.scope.goalId && grant.scope.goalId !== request.goalId)
41
- return false;
42
- if (grant.expiresAt) {
43
- const now = Date.parse(request.nowIso ?? new Date().toISOString());
44
- const expiry = Date.parse(grant.expiresAt);
45
- if (Number.isFinite(expiry) && Number.isFinite(now) && now >= expiry)
46
- return false;
47
- }
48
- return true;
49
- }
50
- /** Count spend entries for `grantId` among already-decoded custom-entry payloads (the caller walks the
51
- * session branch and passes the raw `data` values — this stays pure/session-agnostic). */
52
- export function countGrantUsages(grantId, usageEntries) {
53
- let count = 0;
54
- for (const entry of usageEntries)
55
- if (isTmuxDispatchGrantUsage(entry) && entry.grantId === grantId)
56
- count++;
57
- return count;
58
- }
59
- export function isGrantBudgetExhausted(grant, usedCount) {
60
- return usedCount >= grant.budget.maxLaunches;
61
- }
62
- export function buildGrantUsageEntry(grantId, jobId, nowIso = new Date().toISOString()) {
63
- return { grantId, jobId, at: nowIso };
64
- }
65
- export function buildTombstone(grantId, nowIso = new Date().toISOString()) {
66
- return { tombstone: true, grantId, revokedAt: nowIso };
67
- }
68
- /** Build a new grant record from `grant_dispatch` params. Pure — the caller (index.ts) owns the
69
- * approval gate (ui.confirm / opt-in flag) and the `pi.appendEntry` persistence; this only shapes the
70
- * data, so it stays independently testable and never itself decides whether creation is authorized. */
71
- export function buildGrant(params, nowIso = new Date().toISOString()) {
72
- if (!Number.isFinite(params.maxLaunches) || params.maxLaunches < 1)
73
- throw new Error("grant_dispatch requires maxLaunches >= 1");
74
- const expiresAt = params.expiresInMinutes !== undefined
75
- ? new Date(Date.parse(nowIso) + Math.max(1, params.expiresInMinutes) * 60_000).toISOString()
76
- : undefined;
77
- return {
78
- grantId: makeGrantId(),
79
- createdAt: nowIso,
80
- agent: params.agent,
81
- scope: { goalId: params.goalId },
82
- envelope: {
83
- allowedTools: params.allowedTools,
84
- resourceProfile: params.resourceProfile,
85
- writePaths: params.writePaths,
86
- },
87
- budget: {
88
- maxLaunches: Math.trunc(params.maxLaunches),
89
- maxUsdAdvisory: params.maxUsdAdvisory,
90
- },
91
- expiresAt,
92
- };
93
- }
94
- export function describeGrant(grant) {
95
- return [
96
- `Grant id: ${grant.grantId}`,
97
- `Agent: ${grant.agent}`,
98
- grant.scope.goalId ? `Goal scope: ${grant.scope.goalId}` : "Goal scope: none (covers any goal)",
99
- `Max launches: ${grant.budget.maxLaunches}`,
100
- grant.expiresAt ? `Expires: ${grant.expiresAt}` : "Expires: never (until revoke_grant)",
101
- grant.envelope.allowedTools?.length
102
- ? `Allowed tools: ${grant.envelope.allowedTools.join(", ")}`
103
- : `Allowed tools: read-biased safe default (${DEFAULT_READ_BIASED_TOOLS.join(", ")})`,
104
- grant.envelope.resourceProfile
105
- ? `Resource profile: ${grant.envelope.resourceProfile}`
106
- : "Resource profile: none (child launches with --no-extensions --no-skills)",
107
- grant.envelope.writePaths?.length
108
- ? `Write paths: ${grant.envelope.writePaths.join(", ")}`
109
- : "Write paths: none declared",
110
- grant.budget.maxUsdAdvisory !== undefined
111
- ? `Advisory USD cap: ${grant.budget.maxUsdAdvisory} (not enforced across the process boundary — advisory only)`
112
- : undefined,
113
- ]
114
- .filter((line) => Boolean(line))
115
- .join("\n");
116
- }
117
- // ---------------------------------------------------------------------------
118
- // Launch-profile flags: the REAL lever — pushed into the child `pi` CLI's own config.
119
- // ---------------------------------------------------------------------------
120
- export const DEFAULT_READ_BIASED_TOOLS = ["read", "grep", "find", "ls"];
121
- /** A grant-covered launch derives its profile from the grant's envelope. */
122
- export function launchProfileSourceFromGrant(grant) {
123
- return {
124
- identity: `grant ${grant.grantId}`,
125
- allowedTools: grant.envelope.allowedTools,
126
- resourceProfile: grant.envelope.resourceProfile,
127
- writePaths: grant.envelope.writePaths,
128
- };
129
- }
130
- /** A one-shot interactively-approved launch (no standing grant) still gets the conservative default
131
- * profile — approving a single launch is not the same as defining an unrestricted envelope. */
132
- export const ONE_SHOT_LAUNCH_PROFILE_SOURCE = {
133
- identity: "a one-shot owner-approved tmux dispatch (no standing grant)",
134
- };
135
- /** Build the CLI flags to append to a child `pi` invocation so the grant's envelope lives in the
136
- * child's OWN launch config (verified flag names: --tools, --resource-profile, --no-extensions,
137
- * --no-skills, --append-system-prompt). Never includes --no-approve: the child must keep gating its
138
- * own hard stops. */
139
- export function buildLaunchProfileFlags(source) {
140
- const tools = source.allowedTools?.length ? source.allowedTools : DEFAULT_READ_BIASED_TOOLS;
141
- const flags = [{ flag: "--tools", value: tools.join(",") }];
142
- if (source.resourceProfile)
143
- flags.push({ flag: "--resource-profile", value: source.resourceProfile });
144
- else
145
- flags.push({ flag: "--no-extensions" }, { flag: "--no-skills" });
146
- if (source.worktreeLane)
147
- flags.push({ flag: "--worktree-lane", value: source.worktreeLane });
148
- if (source.parentPid !== undefined)
149
- flags.push({ flag: "--parent-pid", value: String(source.parentPid) });
150
- if (source.parentSession)
151
- flags.push({ flag: "--parent-session", value: source.parentSession });
152
- if (source.taskRef)
153
- flags.push({ flag: "--task-ref", value: source.taskRef });
154
- flags.push({ flag: "--append-system-prompt", value: buildScopedSystemPrompt(source) });
155
- flags.push({ flag: "--session-mode", value: "worker" });
156
- return flags;
157
- }
158
- export function buildScopedSystemPrompt(source) {
159
- const paths = source.writePaths?.length ? source.writePaths.join(", ") : "no additional paths granted";
160
- const sentences = [
161
- `You are a tmux worker dispatched under ${source.identity}.`,
162
- `Stay within these write paths: ${paths}.`,
163
- "Hard stops — publishing/npm, git push, tagging a release, changing credentials/auth, or destructive deletion — require returning BLOCKED for owner approval. Never self-approve a hard stop.",
164
- ];
165
- if (source.worktreeLane) {
166
- sentences.push(`You are bound to worktree-sync lane '${source.worktreeLane}': work only inside this lane's own worktree, integrate exclusively via worktree_sync land, and never touch main directly.`);
167
- }
168
- return sentences.join(" ");
169
- }
170
- // ---------------------------------------------------------------------------
171
- // Advisory worker usage claim: budget stays advisory across the process boundary.
172
- // ---------------------------------------------------------------------------
173
- /** Permissively decode a worker-reported usage CLAIM (a cooperative worker may write this to a
174
- * well-known sibling file before printing its completion marker). Read-defensive: missing/malformed
175
- * numeric fields default to 0 rather than throwing — this is untrusted, OPTIONAL, advisory input, never
176
- * an authoritative billing record. Returns undefined only when `raw` isn't even an object, so the
177
- * caller can distinguish "no claim offered" (skip reporting) from "a claim was offered" (report it,
178
- * however partial). */
179
- export function decodeTmuxWorkerUsageClaim(raw) {
180
- if (!isPlainRecord(raw))
181
- return undefined;
182
- const num = (value) => (typeof value === "number" && Number.isFinite(value) ? value : 0);
183
- const cost = isPlainRecord(raw.cost) ? raw.cost : {};
184
- return {
185
- input: num(raw.input),
186
- output: num(raw.output),
187
- cacheRead: num(raw.cacheRead),
188
- cacheWrite: num(raw.cacheWrite),
189
- totalTokens: num(raw.totalTokens),
190
- cost: {
191
- input: num(cost.input),
192
- output: num(cost.output),
193
- cacheRead: num(cost.cacheRead),
194
- cacheWrite: num(cost.cacheWrite),
195
- total: num(cost.total),
196
- },
197
- };
198
- }
199
- //# sourceMappingURL=dispatch-grant.js.map