@caupulican/pi-adaptative 0.94.0 → 0.95.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 (371) hide show
  1. package/CHANGELOG.md +55 -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 +173 -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 +247 -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/skills/pi-harness-learning/SKILL.md +13 -7
  16. package/dist/bundled-resources/skills/worker-profile-writer/SKILL.md +11 -11
  17. package/dist/core/agent-paths.d.ts +2 -0
  18. package/dist/core/agent-paths.d.ts.map +1 -1
  19. package/dist/core/agent-paths.js +7 -0
  20. package/dist/core/agent-paths.js.map +1 -1
  21. package/dist/core/agent-session.d.ts +11 -41
  22. package/dist/core/agent-session.d.ts.map +1 -1
  23. package/dist/core/agent-session.js +98 -161
  24. package/dist/core/agent-session.js.map +1 -1
  25. package/dist/core/autonomy/envelope-enforcement.d.ts +6 -1
  26. package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
  27. package/dist/core/autonomy/envelope-enforcement.js +26 -25
  28. package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
  29. package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -1
  30. package/dist/core/autonomy/lane-private-paths.js +2 -1
  31. package/dist/core/autonomy/lane-private-paths.js.map +1 -1
  32. package/dist/core/autonomy/lane-tool-surface.d.ts +8 -8
  33. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  34. package/dist/core/autonomy/lane-tool-surface.js +45 -30
  35. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  36. package/dist/core/autonomy/worker-session-private-scope.d.ts +12 -0
  37. package/dist/core/autonomy/worker-session-private-scope.d.ts.map +1 -0
  38. package/dist/core/autonomy/worker-session-private-scope.js +42 -0
  39. package/dist/core/autonomy/worker-session-private-scope.js.map +1 -0
  40. package/dist/core/autonomy/worker-tool-adapter-registry.d.ts +65 -0
  41. package/dist/core/autonomy/worker-tool-adapter-registry.d.ts.map +1 -0
  42. package/dist/core/autonomy/worker-tool-adapter-registry.js +145 -0
  43. package/dist/core/autonomy/worker-tool-adapter-registry.js.map +1 -0
  44. package/dist/core/background-lane-controller.d.ts +9 -1
  45. package/dist/core/background-lane-controller.d.ts.map +1 -1
  46. package/dist/core/background-lane-controller.js +76 -6
  47. package/dist/core/background-lane-controller.js.map +1 -1
  48. package/dist/core/background-tool-task-controller.d.ts +23 -2
  49. package/dist/core/background-tool-task-controller.d.ts.map +1 -1
  50. package/dist/core/background-tool-task-controller.js +132 -17
  51. package/dist/core/background-tool-task-controller.js.map +1 -1
  52. package/dist/core/context/long-term-memory-trigger.d.ts +3 -1
  53. package/dist/core/context/long-term-memory-trigger.d.ts.map +1 -1
  54. package/dist/core/context/long-term-memory-trigger.js +1 -1
  55. package/dist/core/context/long-term-memory-trigger.js.map +1 -1
  56. package/dist/core/context/okf-memory-provider.d.ts +3 -0
  57. package/dist/core/context/okf-memory-provider.d.ts.map +1 -1
  58. package/dist/core/context/okf-memory-provider.js +66 -31
  59. package/dist/core/context/okf-memory-provider.js.map +1 -1
  60. package/dist/core/context/okf-memory.d.ts +18 -1
  61. package/dist/core/context/okf-memory.d.ts.map +1 -1
  62. package/dist/core/context/okf-memory.js +48 -0
  63. package/dist/core/context/okf-memory.js.map +1 -1
  64. package/dist/core/cost-guard-controller.d.ts +37 -0
  65. package/dist/core/cost-guard-controller.d.ts.map +1 -0
  66. package/dist/core/cost-guard-controller.js +71 -0
  67. package/dist/core/cost-guard-controller.js.map +1 -0
  68. package/dist/core/cost-guard.d.ts +9 -4
  69. package/dist/core/cost-guard.d.ts.map +1 -1
  70. package/dist/core/cost-guard.js +7 -3
  71. package/dist/core/cost-guard.js.map +1 -1
  72. package/dist/core/delegation/worker-agent-control.d.ts +4 -0
  73. package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
  74. package/dist/core/delegation/worker-agent-control.js.map +1 -1
  75. package/dist/core/delegation/worker-attempt-executor.d.ts +1 -1
  76. package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
  77. package/dist/core/delegation/worker-attempt-executor.js +0 -1
  78. package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
  79. package/dist/core/delegation/worker-authority-resolver.d.ts +16 -3
  80. package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
  81. package/dist/core/delegation/worker-authority-resolver.js +114 -55
  82. package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
  83. package/dist/core/delegation/worker-claim.d.ts +1 -2
  84. package/dist/core/delegation/worker-claim.d.ts.map +1 -1
  85. package/dist/core/delegation/worker-claim.js.map +1 -1
  86. package/dist/core/delegation/worker-delegation-controller.d.ts +19 -6
  87. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  88. package/dist/core/delegation/worker-delegation-controller.js +125 -40
  89. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  90. package/dist/core/delegation/worker-delegation-request.d.ts +3 -3
  91. package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
  92. package/dist/core/delegation/worker-delegation-request.js +13 -19
  93. package/dist/core/delegation/worker-delegation-request.js.map +1 -1
  94. package/dist/core/delegation/worker-execution-policy.d.ts +3 -2
  95. package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
  96. package/dist/core/delegation/worker-execution-policy.js +54 -39
  97. package/dist/core/delegation/worker-execution-policy.js.map +1 -1
  98. package/dist/core/delegation/worker-fleet-limits.d.ts +3 -3
  99. package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -1
  100. package/dist/core/delegation/worker-fleet-limits.js +7 -7
  101. package/dist/core/delegation/worker-fleet-limits.js.map +1 -1
  102. package/dist/core/delegation/worker-machine-scope.d.ts +12 -0
  103. package/dist/core/delegation/worker-machine-scope.d.ts.map +1 -0
  104. package/dist/core/delegation/worker-machine-scope.js +38 -0
  105. package/dist/core/delegation/worker-machine-scope.js.map +1 -0
  106. package/dist/core/delegation/worker-notification-coordinator.d.ts +10 -0
  107. package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
  108. package/dist/core/delegation/worker-notification-coordinator.js +69 -3
  109. package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
  110. package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
  111. package/dist/core/delegation/worker-recovery-coordinator.js +6 -1
  112. package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
  113. package/dist/core/delegation/worker-runner.d.ts +5 -7
  114. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  115. package/dist/core/delegation/worker-runner.js +1 -4
  116. package/dist/core/delegation/worker-runner.js.map +1 -1
  117. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +3 -2
  118. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
  119. package/dist/core/delegation/worker-write-reservation-coordinator.js +50 -25
  120. package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
  121. package/dist/core/durable-custom-message-turn-controller.d.ts +6 -0
  122. package/dist/core/durable-custom-message-turn-controller.d.ts.map +1 -1
  123. package/dist/core/durable-custom-message-turn-controller.js +38 -15
  124. package/dist/core/durable-custom-message-turn-controller.js.map +1 -1
  125. package/dist/core/extension-binding-controller.d.ts +5 -1
  126. package/dist/core/extension-binding-controller.d.ts.map +1 -1
  127. package/dist/core/extension-binding-controller.js +15 -0
  128. package/dist/core/extension-binding-controller.js.map +1 -1
  129. package/dist/core/extensions/factory-runtime.d.ts.map +1 -1
  130. package/dist/core/extensions/factory-runtime.js +5 -0
  131. package/dist/core/extensions/factory-runtime.js.map +1 -1
  132. package/dist/core/extensions/runner.d.ts.map +1 -1
  133. package/dist/core/extensions/runner.js +1 -0
  134. package/dist/core/extensions/runner.js.map +1 -1
  135. package/dist/core/extensions/types.d.ts +8 -4
  136. package/dist/core/extensions/types.d.ts.map +1 -1
  137. package/dist/core/extensions/types.js.map +1 -1
  138. package/dist/core/foreground-terminal-handoff-controller.d.ts +31 -0
  139. package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
  140. package/dist/core/foreground-terminal-handoff-controller.js +239 -55
  141. package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
  142. package/dist/core/goals/goal-session-controller.d.ts +2 -0
  143. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  144. package/dist/core/goals/goal-session-controller.js +8 -0
  145. package/dist/core/goals/goal-session-controller.js.map +1 -1
  146. package/dist/core/goals/goal-tool-core.d.ts +5 -4
  147. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  148. package/dist/core/goals/goal-tool-core.js +23 -19
  149. package/dist/core/goals/goal-tool-core.js.map +1 -1
  150. package/dist/core/learning/auto-learn-settings.d.ts +84 -0
  151. package/dist/core/learning/auto-learn-settings.d.ts.map +1 -0
  152. package/dist/core/learning/auto-learn-settings.js +66 -0
  153. package/dist/core/learning/auto-learn-settings.js.map +1 -0
  154. package/dist/core/learning/learning-audit.d.ts +5 -1
  155. package/dist/core/learning/learning-audit.d.ts.map +1 -1
  156. package/dist/core/learning/learning-audit.js +32 -1
  157. package/dist/core/learning/learning-audit.js.map +1 -1
  158. package/dist/core/learning/reflection-engine.d.ts +24 -0
  159. package/dist/core/learning/reflection-engine.d.ts.map +1 -1
  160. package/dist/core/learning/reflection-engine.js +104 -8
  161. package/dist/core/learning/reflection-engine.js.map +1 -1
  162. package/dist/core/local-prefix-warm-controller.d.ts +24 -0
  163. package/dist/core/local-prefix-warm-controller.d.ts.map +1 -0
  164. package/dist/core/local-prefix-warm-controller.js +79 -0
  165. package/dist/core/local-prefix-warm-controller.js.map +1 -0
  166. package/dist/core/memory/okf-project-memory-store.d.ts +28 -0
  167. package/dist/core/memory/okf-project-memory-store.d.ts.map +1 -0
  168. package/dist/core/memory/okf-project-memory-store.js +111 -0
  169. package/dist/core/memory/okf-project-memory-store.js.map +1 -0
  170. package/dist/core/memory/providers/file-store.d.ts +44 -1
  171. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  172. package/dist/core/memory/providers/file-store.js +341 -24
  173. package/dist/core/memory/providers/file-store.js.map +1 -1
  174. package/dist/core/memory/worker-memory-tools.d.ts +5 -0
  175. package/dist/core/memory/worker-memory-tools.d.ts.map +1 -0
  176. package/dist/core/memory/worker-memory-tools.js +5 -0
  177. package/dist/core/memory/worker-memory-tools.js.map +1 -0
  178. package/dist/core/memory-controller.d.ts +10 -1
  179. package/dist/core/memory-controller.d.ts.map +1 -1
  180. package/dist/core/memory-controller.js +72 -8
  181. package/dist/core/memory-controller.js.map +1 -1
  182. package/dist/core/model-capability.d.ts +7 -0
  183. package/dist/core/model-capability.d.ts.map +1 -1
  184. package/dist/core/model-capability.js +12 -0
  185. package/dist/core/model-capability.js.map +1 -1
  186. package/dist/core/model-registry.d.ts.map +1 -1
  187. package/dist/core/model-registry.js +2 -10
  188. package/dist/core/model-registry.js.map +1 -1
  189. package/dist/core/model-router-controller.d.ts +3 -2
  190. package/dist/core/model-router-controller.d.ts.map +1 -1
  191. package/dist/core/model-router-controller.js +3 -2
  192. package/dist/core/model-router-controller.js.map +1 -1
  193. package/dist/core/orchestration/contracts.d.ts +16 -12
  194. package/dist/core/orchestration/contracts.d.ts.map +1 -1
  195. package/dist/core/orchestration/contracts.js +2 -2
  196. package/dist/core/orchestration/contracts.js.map +1 -1
  197. package/dist/core/orchestration/lane-tool-manifests.d.ts +2 -2
  198. package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
  199. package/dist/core/orchestration/lane-tool-manifests.js +6 -1
  200. package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
  201. package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
  202. package/dist/core/orchestration/profile-registry.js +14 -0
  203. package/dist/core/orchestration/profile-registry.js.map +1 -1
  204. package/dist/core/orchestration/task-profile-writer.d.ts +7 -4
  205. package/dist/core/orchestration/task-profile-writer.d.ts.map +1 -1
  206. package/dist/core/orchestration/task-profile-writer.js +71 -59
  207. package/dist/core/orchestration/task-profile-writer.js.map +1 -1
  208. package/dist/core/orchestration/thinking-level-schema.d.ts +7 -0
  209. package/dist/core/orchestration/thinking-level-schema.d.ts.map +1 -0
  210. package/dist/core/orchestration/thinking-level-schema.js +19 -0
  211. package/dist/core/orchestration/thinking-level-schema.js.map +1 -0
  212. package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
  213. package/dist/core/orchestration/worker-execution-contract.js +12 -5
  214. package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
  215. package/dist/core/provider-prompt-contracts.d.ts +1 -4
  216. package/dist/core/provider-prompt-contracts.d.ts.map +1 -1
  217. package/dist/core/provider-prompt-contracts.js +13 -29
  218. package/dist/core/provider-prompt-contracts.js.map +1 -1
  219. package/dist/core/provider-request-context-controller.d.ts +2 -0
  220. package/dist/core/provider-request-context-controller.d.ts.map +1 -1
  221. package/dist/core/provider-request-context-controller.js +10 -3
  222. package/dist/core/provider-request-context-controller.js.map +1 -1
  223. package/dist/core/reflection-controller.d.ts +63 -27
  224. package/dist/core/reflection-controller.d.ts.map +1 -1
  225. package/dist/core/reflection-controller.js +300 -132
  226. package/dist/core/reflection-controller.js.map +1 -1
  227. package/dist/core/runtime-builder.d.ts +1 -0
  228. package/dist/core/runtime-builder.d.ts.map +1 -1
  229. package/dist/core/runtime-builder.js +25 -14
  230. package/dist/core/runtime-builder.js.map +1 -1
  231. package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
  232. package/dist/core/secrets/credential-exposure-guard.js +55 -10
  233. package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
  234. package/dist/core/session-role.d.ts +6 -8
  235. package/dist/core/session-role.d.ts.map +1 -1
  236. package/dist/core/session-role.js +8 -18
  237. package/dist/core/session-role.js.map +1 -1
  238. package/dist/core/settings-manager.d.ts +13 -16
  239. package/dist/core/settings-manager.d.ts.map +1 -1
  240. package/dist/core/settings-manager.js +53 -50
  241. package/dist/core/settings-manager.js.map +1 -1
  242. package/dist/core/skill-vault.d.ts +15 -0
  243. package/dist/core/skill-vault.d.ts.map +1 -1
  244. package/dist/core/skill-vault.js +79 -45
  245. package/dist/core/skill-vault.js.map +1 -1
  246. package/dist/core/skills.d.ts +3 -0
  247. package/dist/core/skills.d.ts.map +1 -1
  248. package/dist/core/skills.js +6 -6
  249. package/dist/core/skills.js.map +1 -1
  250. package/dist/core/system-prompt-builder.d.ts +2 -0
  251. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  252. package/dist/core/system-prompt-builder.js +52 -12
  253. package/dist/core/system-prompt-builder.js.map +1 -1
  254. package/dist/core/system-prompt.js +1 -1
  255. package/dist/core/system-prompt.js.map +1 -1
  256. package/dist/core/tool-capability-policy.d.ts +3 -0
  257. package/dist/core/tool-capability-policy.d.ts.map +1 -1
  258. package/dist/core/tool-capability-policy.js +13 -2
  259. package/dist/core/tool-capability-policy.js.map +1 -1
  260. package/dist/core/toolkit/script-runner.d.ts +2 -1
  261. package/dist/core/toolkit/script-runner.d.ts.map +1 -1
  262. package/dist/core/toolkit/script-runner.js +10 -2
  263. package/dist/core/toolkit/script-runner.js.map +1 -1
  264. package/dist/core/tools/delegate-status.d.ts +3 -1
  265. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  266. package/dist/core/tools/delegate-status.js +5 -1
  267. package/dist/core/tools/delegate-status.js.map +1 -1
  268. package/dist/core/tools/delegate.d.ts +4 -13
  269. package/dist/core/tools/delegate.d.ts.map +1 -1
  270. package/dist/core/tools/delegate.js +173 -73
  271. package/dist/core/tools/delegate.js.map +1 -1
  272. package/dist/core/tools/goal.d.ts +3 -4
  273. package/dist/core/tools/goal.d.ts.map +1 -1
  274. package/dist/core/tools/goal.js +24 -7
  275. package/dist/core/tools/goal.js.map +1 -1
  276. package/dist/core/tools/profile-writer.d.ts +2 -8
  277. package/dist/core/tools/profile-writer.d.ts.map +1 -1
  278. package/dist/core/tools/profile-writer.js +6 -18
  279. package/dist/core/tools/profile-writer.js.map +1 -1
  280. package/dist/core/tools/run-toolkit-script.d.ts +1 -1
  281. package/dist/core/tools/run-toolkit-script.d.ts.map +1 -1
  282. package/dist/core/tools/run-toolkit-script.js +2 -2
  283. package/dist/core/tools/run-toolkit-script.js.map +1 -1
  284. package/dist/core/tools/skill-audit.d.ts +28 -1
  285. package/dist/core/tools/skill-audit.d.ts.map +1 -1
  286. package/dist/core/tools/skill-audit.js +56 -12
  287. package/dist/core/tools/skill-audit.js.map +1 -1
  288. package/dist/core/tools/skill.d.ts +12 -1
  289. package/dist/core/tools/skill.d.ts.map +1 -1
  290. package/dist/core/tools/skill.js +52 -0
  291. package/dist/core/tools/skill.js.map +1 -1
  292. package/dist/core/tools/skillify.d.ts.map +1 -1
  293. package/dist/core/tools/skillify.js +16 -7
  294. package/dist/core/tools/skillify.js.map +1 -1
  295. package/dist/core/tools/task-steps.js +1 -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/tools/tool-task.d.ts +1 -0
  302. package/dist/core/tools/tool-task.d.ts.map +1 -1
  303. package/dist/core/tools/tool-task.js +13 -8
  304. package/dist/core/tools/tool-task.js.map +1 -1
  305. package/dist/core/util/atomic-file.d.ts +2 -0
  306. package/dist/core/util/atomic-file.d.ts.map +1 -1
  307. package/dist/core/util/atomic-file.js +4 -0
  308. package/dist/core/util/atomic-file.js.map +1 -1
  309. package/dist/core/worktree-sync/codes.d.ts +1 -2
  310. package/dist/core/worktree-sync/codes.d.ts.map +1 -1
  311. package/dist/core/worktree-sync/codes.js +1 -2
  312. package/dist/core/worktree-sync/codes.js.map +1 -1
  313. package/dist/core/worktree-sync/lane-gate.d.ts +4 -8
  314. package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -1
  315. package/dist/core/worktree-sync/lane-gate.js +5 -51
  316. package/dist/core/worktree-sync/lane-gate.js.map +1 -1
  317. package/dist/index.d.ts +5 -0
  318. package/dist/index.d.ts.map +1 -1
  319. package/dist/index.js +7 -0
  320. package/dist/index.js.map +1 -1
  321. package/dist/modes/interactive/auto-learn-controller.d.ts +6 -7
  322. package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
  323. package/dist/modes/interactive/auto-learn-controller.js +32 -207
  324. package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
  325. package/dist/modes/interactive/autonomy-commands.js +2 -2
  326. package/dist/modes/interactive/autonomy-commands.js.map +1 -1
  327. package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
  328. package/dist/modes/interactive/components/activity-lane.js +12 -23
  329. package/dist/modes/interactive/components/activity-lane.js.map +1 -1
  330. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  331. package/dist/modes/interactive/components/custom-message.js +142 -1
  332. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  333. package/dist/modes/interactive/components/fitness-role-selector.d.ts.map +1 -1
  334. package/dist/modes/interactive/components/fitness-role-selector.js +2 -2
  335. package/dist/modes/interactive/components/fitness-role-selector.js.map +1 -1
  336. package/dist/modes/interactive/components/footer.js +1 -1
  337. package/dist/modes/interactive/components/footer.js.map +1 -1
  338. package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
  339. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  340. package/dist/modes/interactive/components/settings-selector.js +150 -73
  341. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  342. package/dist/modes/interactive/report-commands.d.ts.map +1 -1
  343. package/dist/modes/interactive/report-commands.js +8 -4
  344. package/dist/modes/interactive/report-commands.js.map +1 -1
  345. package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
  346. package/dist/modes/interactive/settings-selector-flow.js +10 -0
  347. package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
  348. package/docs/extensions.md +8 -0
  349. package/docs/harness-architecture.md +28 -32
  350. package/docs/index.md +1 -1
  351. package/docs/process-matrix.md +8 -6
  352. package/docs/resources.md +1 -1
  353. package/docs/settings.md +61 -51
  354. package/docs/tmux-agent-manager.md +47 -40
  355. package/docs/usage.md +1 -1
  356. package/docs/worker-profiles.md +8 -6
  357. package/docs/worktree-sync.md +26 -20
  358. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  359. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  360. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  361. package/examples/extensions/sandbox/package-lock.json +2 -2
  362. package/examples/extensions/sandbox/package.json +1 -1
  363. package/examples/extensions/with-deps/package-lock.json +2 -2
  364. package/examples/extensions/with-deps/package.json +1 -1
  365. package/npm-shrinkwrap.json +12 -12
  366. package/package.json +4 -4
  367. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +0 -133
  368. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +0 -1
  369. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +0 -199
  370. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +0 -1
  371. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +0 -312
@@ -0,0 +1,52 @@
1
+ import type { ThinkingLevel } from "@caupulican/pi-agent-core";
2
+ import type { Usage } from "@caupulican/pi-ai";
3
+ export type Provider = "pi" | "codex" | "agy" | "claude" | "opencode" | "custom";
4
+ /** Full host-auditable Pi worker surface after the shared worker ceiling removes agent launchers
5
+ * and root-owned durable mutation controls. */
6
+ export declare const DEFAULT_MANAGED_WORKER_TOOLS: readonly string[];
7
+ export declare class WorkerLaunchProfileError extends Error {
8
+ readonly code: "worker_profile_tools_rejected";
9
+ readonly rejectedTools: readonly string[];
10
+ constructor(rejectedTools: readonly string[]);
11
+ }
12
+ export interface WorkerLaunchProfileInput {
13
+ identity: string;
14
+ inheritedTools?: readonly string[];
15
+ allowedTools?: readonly string[];
16
+ resourceProfile?: string;
17
+ resourceProfileJson?: string;
18
+ writePaths?: readonly string[];
19
+ thinkingLevel?: ThinkingLevel;
20
+ worktreeLane?: string;
21
+ parentPid?: number;
22
+ parentSession?: string;
23
+ taskRef?: string;
24
+ }
25
+ /** Immutable profile compiled once before a managed process is reserved or launched. Empty
26
+ * `writePaths` means the host-derived machine-root scope; a non-empty list is an explicit narrowing. */
27
+ export interface WorkerLaunchProfile {
28
+ readonly identity: string;
29
+ readonly allowedTools: readonly string[];
30
+ readonly resourceProfile?: string;
31
+ readonly resourceProfileJson?: string;
32
+ readonly writePaths: readonly string[];
33
+ readonly thinkingLevel?: ThinkingLevel;
34
+ readonly worktreeLane?: string;
35
+ readonly parentPid?: number;
36
+ readonly parentSession?: string;
37
+ readonly taskRef?: string;
38
+ }
39
+ export declare function deriveWorkerLaunchProfile(input: WorkerLaunchProfileInput): WorkerLaunchProfile;
40
+ export interface LaunchProfileFlag {
41
+ flag: string;
42
+ value?: string;
43
+ }
44
+ /** Render a Pi child's immutable profile into its own CLI configuration. The manager supplies either
45
+ * an explicit resource-profile override or a one-shot snapshot of the parent's effective resources;
46
+ * standalone callers that omit both retain the child's normal resources. */
47
+ export declare function buildLaunchProfileFlags(profile: WorkerLaunchProfile): LaunchProfileFlag[];
48
+ export declare function buildScopedSystemPrompt(profile: WorkerLaunchProfile): string;
49
+ /** Decode an optional cooperative worker usage claim. Malformed numeric fields are zeroed because
50
+ * the claim is advisory and must never become an authoritative billing record. */
51
+ export declare function decodeTmuxWorkerUsageClaim(raw: unknown): Usage | undefined;
52
+ //# sourceMappingURL=launch-profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launch-profile.d.ts","sourceRoot":"","sources":["../../../../src/bundled-resources/extensions/tmux-agent-manager/launch-profile.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;AAKjF;+CAC+C;AAC/C,eAAO,MAAM,4BAA4B,EAAE,SAAS,MAAM,EAAkD,CAAC;AAE7G,qBAAa,wBAAyB,SAAQ,KAAK;IAClD,QAAQ,CAAC,IAAI,EAAG,+BAA+B,CAAU;IACzD,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAE1C,YAAY,aAAa,EAAE,SAAS,MAAM,EAAE,EAK3C;CACD;AAED,MAAM,WAAW,wBAAwB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,aAAa,CAAC,EAAE,aAAa,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from "@caupulican/pi-adaptative";
2
+ const MANAGED_WORKER_TOOL_NAMES = POLICY_OWNED_RUNTIME_TOOL_NAMES.filter((tool) => !WORKER_FORBIDDEN_TOOLS.has(tool));
3
+ const MANAGED_WORKER_TOOL_NAME_SET = new Set(MANAGED_WORKER_TOOL_NAMES);
4
+ /** Full host-auditable Pi worker surface after the shared worker ceiling removes agent launchers
5
+ * and root-owned durable mutation controls. */
6
+ export const DEFAULT_MANAGED_WORKER_TOOLS = Object.freeze([...MANAGED_WORKER_TOOL_NAMES]);
7
+ export class WorkerLaunchProfileError extends Error {
8
+ constructor(rejectedTools) {
9
+ const displayNames = rejectedTools.map((tool) => (tool ? `'${tool}'` : "<empty>"));
10
+ super(`Worker profile requested unavailable or forbidden tools: ${displayNames.join(", ")}.`);
11
+ this.code = "worker_profile_tools_rejected";
12
+ this.name = "WorkerLaunchProfileError";
13
+ this.rejectedTools = Object.freeze([...rejectedTools]);
14
+ }
15
+ }
16
+ function normalizeToolNames(tools) {
17
+ return mapToolNamesForPlatform(tools.map((tool) => tool.trim().toLowerCase()));
18
+ }
19
+ function uniqueClassifiedTools(tools) {
20
+ const selected = new Set(normalizeToolNames(tools).filter((tool) => tool.length > 0));
21
+ return MANAGED_WORKER_TOOL_NAMES.filter((tool) => selected.has(tool));
22
+ }
23
+ export function deriveWorkerLaunchProfile(input) {
24
+ if (input.allowedTools !== undefined) {
25
+ const inheritedToolSet = input.inheritedTools === undefined
26
+ ? MANAGED_WORKER_TOOL_NAME_SET
27
+ : new Set(uniqueClassifiedTools(input.inheritedTools));
28
+ const rejectedTools = [
29
+ ...new Set(normalizeToolNames(input.allowedTools).filter((tool) => !MANAGED_WORKER_TOOL_NAME_SET.has(tool) || !inheritedToolSet.has(tool))),
30
+ ];
31
+ if (rejectedTools.length > 0)
32
+ throw new WorkerLaunchProfileError(rejectedTools);
33
+ }
34
+ const sourceTools = input.allowedTools ?? input.inheritedTools ?? DEFAULT_MANAGED_WORKER_TOOLS;
35
+ const allowedTools = Object.freeze(uniqueClassifiedTools(sourceTools));
36
+ const writePaths = Object.freeze([
37
+ ...new Set(input.writePaths?.map((entry) => entry.trim()).filter((entry) => entry.length > 0) ?? []),
38
+ ]);
39
+ return Object.freeze({
40
+ identity: input.identity,
41
+ allowedTools,
42
+ writePaths,
43
+ ...(input.resourceProfile ? { resourceProfile: input.resourceProfile } : {}),
44
+ ...(input.resourceProfileJson ? { resourceProfileJson: input.resourceProfileJson } : {}),
45
+ ...(input.thinkingLevel ? { thinkingLevel: input.thinkingLevel } : {}),
46
+ ...(input.worktreeLane ? { worktreeLane: input.worktreeLane } : {}),
47
+ ...(input.parentPid !== undefined ? { parentPid: input.parentPid } : {}),
48
+ ...(input.parentSession ? { parentSession: input.parentSession } : {}),
49
+ ...(input.taskRef ? { taskRef: input.taskRef } : {}),
50
+ });
51
+ }
52
+ /** Render a Pi child's immutable profile into its own CLI configuration. The manager supplies either
53
+ * an explicit resource-profile override or a one-shot snapshot of the parent's effective resources;
54
+ * standalone callers that omit both retain the child's normal resources. */
55
+ export function buildLaunchProfileFlags(profile) {
56
+ const flags = profile.allowedTools.length
57
+ ? [{ flag: "--tools", value: profile.allowedTools.join(",") }]
58
+ : [{ flag: "--no-tools" }];
59
+ if (profile.resourceProfileJson)
60
+ flags.push({ flag: "--resource-profile-json", value: profile.resourceProfileJson });
61
+ if (profile.resourceProfile)
62
+ flags.push({ flag: "--resource-profile", value: profile.resourceProfile });
63
+ if (profile.thinkingLevel)
64
+ flags.push({ flag: "--thinking", value: profile.thinkingLevel });
65
+ if (profile.worktreeLane)
66
+ flags.push({ flag: "--worktree-lane", value: profile.worktreeLane });
67
+ if (profile.parentPid !== undefined)
68
+ flags.push({ flag: "--parent-pid", value: String(profile.parentPid) });
69
+ if (profile.parentSession)
70
+ flags.push({ flag: "--parent-session", value: profile.parentSession });
71
+ if (profile.taskRef)
72
+ flags.push({ flag: "--task-ref", value: profile.taskRef });
73
+ flags.push({ flag: "--append-system-prompt", value: buildScopedSystemPrompt(profile) });
74
+ flags.push({ flag: "--session-mode", value: "worker" });
75
+ return flags;
76
+ }
77
+ export function buildScopedSystemPrompt(profile) {
78
+ const scope = profile.writePaths.length
79
+ ? `Structural filesystem tools are limited to: ${profile.writePaths.join(", ")}. Process tools retain host access and must honor this assigned scope.`
80
+ : "Filesystem authority inherits the host's full-machine worker scope except private harness paths.";
81
+ const sentences = [
82
+ `You are a tmux worker running under immutable profile ${profile.identity}.`,
83
+ scope,
84
+ "Work autonomously to completion with the allowed tools; do not ask for routine permission inside the assigned task.",
85
+ "Do not spawn or delegate to other agents.",
86
+ "Report BLOCKED only when the objective is genuinely impossible with the assigned profile or missing external information.",
87
+ ];
88
+ if (profile.worktreeLane) {
89
+ sentences.push(`You are bound to worktree-sync lane '${profile.worktreeLane}': work only inside this lane's own worktree, integrate exclusively via worktree_sync land, and never touch main directly.`);
90
+ }
91
+ return sentences.join(" ");
92
+ }
93
+ function isPlainRecord(value) {
94
+ return typeof value === "object" && value !== null && !Array.isArray(value);
95
+ }
96
+ /** Decode an optional cooperative worker usage claim. Malformed numeric fields are zeroed because
97
+ * the claim is advisory and must never become an authoritative billing record. */
98
+ export function decodeTmuxWorkerUsageClaim(raw) {
99
+ if (!isPlainRecord(raw))
100
+ return undefined;
101
+ const num = (value) => (typeof value === "number" && Number.isFinite(value) ? value : 0);
102
+ const cost = isPlainRecord(raw.cost) ? raw.cost : {};
103
+ return {
104
+ input: num(raw.input),
105
+ output: num(raw.output),
106
+ cacheRead: num(raw.cacheRead),
107
+ cacheWrite: num(raw.cacheWrite),
108
+ totalTokens: num(raw.totalTokens),
109
+ cost: {
110
+ input: num(cost.input),
111
+ output: num(cost.output),
112
+ cacheRead: num(cost.cacheRead),
113
+ cacheWrite: num(cost.cacheWrite),
114
+ total: num(cost.total),
115
+ },
116
+ };
117
+ }
118
+ //# sourceMappingURL=launch-profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launch-profile.js","sourceRoot":"","sources":["../../../../src/bundled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CAAC,CAAC;IAC1G,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACrD,OAAO;QACN,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC;QACrB,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC;QACvB,SAAS,EAAE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC;QAC7B,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC;QAC/B,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC;QACjC,IAAI,EAAE;YACL,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;YACtB,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;YACxB,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;YAC9B,UAAU,EAAE,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;YAChC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;SACtB;KACD,CAAC;AACH,CAAC","sourcesContent":["import {\n\tmapToolNamesForPlatform,\n\tPOLICY_OWNED_RUNTIME_TOOL_NAMES,\n\tWORKER_FORBIDDEN_TOOLS,\n} from \"@caupulican/pi-adaptative\";\nimport type { ThinkingLevel } from \"@caupulican/pi-agent-core\";\nimport type { Usage } from \"@caupulican/pi-ai\";\n\nexport type Provider = \"pi\" | \"codex\" | \"agy\" | \"claude\" | \"opencode\" | \"custom\";\n\nconst MANAGED_WORKER_TOOL_NAMES = POLICY_OWNED_RUNTIME_TOOL_NAMES.filter((tool) => !WORKER_FORBIDDEN_TOOLS.has(tool));\nconst MANAGED_WORKER_TOOL_NAME_SET: ReadonlySet<string> = new Set(MANAGED_WORKER_TOOL_NAMES);\n\n/** Full host-auditable Pi worker surface after the shared worker ceiling removes agent launchers\n * and root-owned durable mutation controls. */\nexport const DEFAULT_MANAGED_WORKER_TOOLS: readonly string[] = Object.freeze([...MANAGED_WORKER_TOOL_NAMES]);\n\nexport class WorkerLaunchProfileError extends Error {\n\treadonly code = \"worker_profile_tools_rejected\" as const;\n\treadonly rejectedTools: readonly string[];\n\n\tconstructor(rejectedTools: readonly string[]) {\n\t\tconst displayNames = rejectedTools.map((tool) => (tool ? `'${tool}'` : \"<empty>\"));\n\t\tsuper(`Worker profile requested unavailable or forbidden tools: ${displayNames.join(\", \")}.`);\n\t\tthis.name = \"WorkerLaunchProfileError\";\n\t\tthis.rejectedTools = Object.freeze([...rejectedTools]);\n\t}\n}\n\nexport interface WorkerLaunchProfileInput {\n\tidentity: string;\n\tinheritedTools?: readonly string[];\n\tallowedTools?: readonly string[];\n\tresourceProfile?: string;\n\tresourceProfileJson?: string;\n\twritePaths?: readonly string[];\n\tthinkingLevel?: ThinkingLevel;\n\tworktreeLane?: string;\n\tparentPid?: number;\n\tparentSession?: string;\n\ttaskRef?: string;\n}\n\n/** Immutable profile compiled once before a managed process is reserved or launched. Empty\n * `writePaths` means the host-derived machine-root scope; a non-empty list is an explicit narrowing. */\nexport interface WorkerLaunchProfile {\n\treadonly identity: string;\n\treadonly allowedTools: readonly string[];\n\treadonly resourceProfile?: string;\n\treadonly resourceProfileJson?: string;\n\treadonly writePaths: readonly string[];\n\treadonly thinkingLevel?: ThinkingLevel;\n\treadonly worktreeLane?: string;\n\treadonly parentPid?: number;\n\treadonly parentSession?: string;\n\treadonly taskRef?: string;\n}\n\nfunction normalizeToolNames(tools: readonly string[]): string[] {\n\treturn mapToolNamesForPlatform(tools.map((tool) => tool.trim().toLowerCase()));\n}\n\nfunction uniqueClassifiedTools(tools: readonly string[]): string[] {\n\tconst selected = new Set(normalizeToolNames(tools).filter((tool) => tool.length > 0));\n\treturn MANAGED_WORKER_TOOL_NAMES.filter((tool) => selected.has(tool));\n}\n\nexport function deriveWorkerLaunchProfile(input: WorkerLaunchProfileInput): WorkerLaunchProfile {\n\tif (input.allowedTools !== undefined) {\n\t\tconst inheritedToolSet =\n\t\t\tinput.inheritedTools === undefined\n\t\t\t\t? MANAGED_WORKER_TOOL_NAME_SET\n\t\t\t\t: new Set(uniqueClassifiedTools(input.inheritedTools));\n\t\tconst rejectedTools = [\n\t\t\t...new Set(\n\t\t\t\tnormalizeToolNames(input.allowedTools).filter(\n\t\t\t\t\t(tool) => !MANAGED_WORKER_TOOL_NAME_SET.has(tool) || !inheritedToolSet.has(tool),\n\t\t\t\t),\n\t\t\t),\n\t\t];\n\t\tif (rejectedTools.length > 0) throw new WorkerLaunchProfileError(rejectedTools);\n\t}\n\tconst sourceTools = input.allowedTools ?? input.inheritedTools ?? DEFAULT_MANAGED_WORKER_TOOLS;\n\tconst allowedTools = Object.freeze(uniqueClassifiedTools(sourceTools));\n\tconst writePaths = Object.freeze([\n\t\t...new Set(input.writePaths?.map((entry) => entry.trim()).filter((entry) => entry.length > 0) ?? []),\n\t]);\n\treturn Object.freeze({\n\t\tidentity: input.identity,\n\t\tallowedTools,\n\t\twritePaths,\n\t\t...(input.resourceProfile ? { resourceProfile: input.resourceProfile } : {}),\n\t\t...(input.resourceProfileJson ? { resourceProfileJson: input.resourceProfileJson } : {}),\n\t\t...(input.thinkingLevel ? { thinkingLevel: input.thinkingLevel } : {}),\n\t\t...(input.worktreeLane ? { worktreeLane: input.worktreeLane } : {}),\n\t\t...(input.parentPid !== undefined ? { parentPid: input.parentPid } : {}),\n\t\t...(input.parentSession ? { parentSession: input.parentSession } : {}),\n\t\t...(input.taskRef ? { taskRef: input.taskRef } : {}),\n\t});\n}\n\nexport interface LaunchProfileFlag {\n\tflag: string;\n\tvalue?: string;\n}\n\n/** Render a Pi child's immutable profile into its own CLI configuration. The manager supplies either\n * an explicit resource-profile override or a one-shot snapshot of the parent's effective resources;\n * standalone callers that omit both retain the child's normal resources. */\nexport function buildLaunchProfileFlags(profile: WorkerLaunchProfile): LaunchProfileFlag[] {\n\tconst flags: LaunchProfileFlag[] = profile.allowedTools.length\n\t\t? [{ flag: \"--tools\", value: profile.allowedTools.join(\",\") }]\n\t\t: [{ flag: \"--no-tools\" }];\n\tif (profile.resourceProfileJson) flags.push({ flag: \"--resource-profile-json\", value: profile.resourceProfileJson });\n\tif (profile.resourceProfile) flags.push({ flag: \"--resource-profile\", value: profile.resourceProfile });\n\tif (profile.thinkingLevel) flags.push({ flag: \"--thinking\", value: profile.thinkingLevel });\n\tif (profile.worktreeLane) flags.push({ flag: \"--worktree-lane\", value: profile.worktreeLane });\n\tif (profile.parentPid !== undefined) flags.push({ flag: \"--parent-pid\", value: String(profile.parentPid) });\n\tif (profile.parentSession) flags.push({ flag: \"--parent-session\", value: profile.parentSession });\n\tif (profile.taskRef) flags.push({ flag: \"--task-ref\", value: profile.taskRef });\n\tflags.push({ flag: \"--append-system-prompt\", value: buildScopedSystemPrompt(profile) });\n\tflags.push({ flag: \"--session-mode\", value: \"worker\" });\n\treturn flags;\n}\n\nexport function buildScopedSystemPrompt(profile: WorkerLaunchProfile): string {\n\tconst scope = profile.writePaths.length\n\t\t? `Structural filesystem tools are limited to: ${profile.writePaths.join(\", \")}. Process tools retain host access and must honor this assigned scope.`\n\t\t: \"Filesystem authority inherits the host's full-machine worker scope except private harness paths.\";\n\tconst sentences = [\n\t\t`You are a tmux worker running under immutable profile ${profile.identity}.`,\n\t\tscope,\n\t\t\"Work autonomously to completion with the allowed tools; do not ask for routine permission inside the assigned task.\",\n\t\t\"Do not spawn or delegate to other agents.\",\n\t\t\"Report BLOCKED only when the objective is genuinely impossible with the assigned profile or missing external information.\",\n\t];\n\tif (profile.worktreeLane) {\n\t\tsentences.push(\n\t\t\t`You are bound to worktree-sync lane '${profile.worktreeLane}': work only inside this lane's own worktree, integrate exclusively via worktree_sync land, and never touch main directly.`,\n\t\t);\n\t}\n\treturn sentences.join(\" \");\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** Decode an optional cooperative worker usage claim. Malformed numeric fields are zeroed because\n * the claim is advisory and must never become an authoritative billing record. */\nexport function decodeTmuxWorkerUsageClaim(raw: unknown): Usage | undefined {\n\tif (!isPlainRecord(raw)) return undefined;\n\tconst num = (value: unknown): number => (typeof value === \"number\" && Number.isFinite(value) ? value : 0);\n\tconst cost = isPlainRecord(raw.cost) ? raw.cost : {};\n\treturn {\n\t\tinput: num(raw.input),\n\t\toutput: num(raw.output),\n\t\tcacheRead: num(raw.cacheRead),\n\t\tcacheWrite: num(raw.cacheWrite),\n\t\ttotalTokens: num(raw.totalTokens),\n\t\tcost: {\n\t\t\tinput: num(cost.input),\n\t\t\toutput: num(cost.output),\n\t\t\tcacheRead: num(cost.cacheRead),\n\t\t\tcacheWrite: num(cost.cacheWrite),\n\t\t\ttotal: num(cost.total),\n\t\t},\n\t};\n}\n"]}
@@ -0,0 +1,169 @@
1
+ import {
2
+ mapToolNamesForPlatform,
3
+ POLICY_OWNED_RUNTIME_TOOL_NAMES,
4
+ WORKER_FORBIDDEN_TOOLS,
5
+ } from "@caupulican/pi-adaptative";
6
+ import type { ThinkingLevel } from "@caupulican/pi-agent-core";
7
+ import type { Usage } from "@caupulican/pi-ai";
8
+
9
+ export type Provider = "pi" | "codex" | "agy" | "claude" | "opencode" | "custom";
10
+
11
+ const MANAGED_WORKER_TOOL_NAMES = POLICY_OWNED_RUNTIME_TOOL_NAMES.filter((tool) => !WORKER_FORBIDDEN_TOOLS.has(tool));
12
+ const MANAGED_WORKER_TOOL_NAME_SET: ReadonlySet<string> = new Set(MANAGED_WORKER_TOOL_NAMES);
13
+
14
+ /** Full host-auditable Pi worker surface after the shared worker ceiling removes agent launchers
15
+ * and root-owned durable mutation controls. */
16
+ export const DEFAULT_MANAGED_WORKER_TOOLS: readonly string[] = Object.freeze([...MANAGED_WORKER_TOOL_NAMES]);
17
+
18
+ export class WorkerLaunchProfileError extends Error {
19
+ readonly code = "worker_profile_tools_rejected" as const;
20
+ readonly rejectedTools: readonly string[];
21
+
22
+ constructor(rejectedTools: readonly string[]) {
23
+ const displayNames = rejectedTools.map((tool) => (tool ? `'${tool}'` : "<empty>"));
24
+ super(`Worker profile requested unavailable or forbidden tools: ${displayNames.join(", ")}.`);
25
+ this.name = "WorkerLaunchProfileError";
26
+ this.rejectedTools = Object.freeze([...rejectedTools]);
27
+ }
28
+ }
29
+
30
+ export interface WorkerLaunchProfileInput {
31
+ identity: string;
32
+ inheritedTools?: readonly string[];
33
+ allowedTools?: readonly string[];
34
+ resourceProfile?: string;
35
+ resourceProfileJson?: string;
36
+ writePaths?: readonly string[];
37
+ thinkingLevel?: ThinkingLevel;
38
+ worktreeLane?: string;
39
+ parentPid?: number;
40
+ parentSession?: string;
41
+ taskRef?: string;
42
+ }
43
+
44
+ /** Immutable profile compiled once before a managed process is reserved or launched. Empty
45
+ * `writePaths` means the host-derived machine-root scope; a non-empty list is an explicit narrowing. */
46
+ export interface WorkerLaunchProfile {
47
+ readonly identity: string;
48
+ readonly allowedTools: readonly string[];
49
+ readonly resourceProfile?: string;
50
+ readonly resourceProfileJson?: string;
51
+ readonly writePaths: readonly string[];
52
+ readonly thinkingLevel?: ThinkingLevel;
53
+ readonly worktreeLane?: string;
54
+ readonly parentPid?: number;
55
+ readonly parentSession?: string;
56
+ readonly taskRef?: string;
57
+ }
58
+
59
+ function normalizeToolNames(tools: readonly string[]): string[] {
60
+ return mapToolNamesForPlatform(tools.map((tool) => tool.trim().toLowerCase()));
61
+ }
62
+
63
+ function uniqueClassifiedTools(tools: readonly string[]): string[] {
64
+ const selected = new Set(normalizeToolNames(tools).filter((tool) => tool.length > 0));
65
+ return MANAGED_WORKER_TOOL_NAMES.filter((tool) => selected.has(tool));
66
+ }
67
+
68
+ export function deriveWorkerLaunchProfile(input: WorkerLaunchProfileInput): WorkerLaunchProfile {
69
+ if (input.allowedTools !== undefined) {
70
+ const inheritedToolSet =
71
+ input.inheritedTools === undefined
72
+ ? MANAGED_WORKER_TOOL_NAME_SET
73
+ : new Set(uniqueClassifiedTools(input.inheritedTools));
74
+ const rejectedTools = [
75
+ ...new Set(
76
+ normalizeToolNames(input.allowedTools).filter(
77
+ (tool) => !MANAGED_WORKER_TOOL_NAME_SET.has(tool) || !inheritedToolSet.has(tool),
78
+ ),
79
+ ),
80
+ ];
81
+ if (rejectedTools.length > 0) throw new WorkerLaunchProfileError(rejectedTools);
82
+ }
83
+ const sourceTools = input.allowedTools ?? input.inheritedTools ?? DEFAULT_MANAGED_WORKER_TOOLS;
84
+ const allowedTools = Object.freeze(uniqueClassifiedTools(sourceTools));
85
+ const writePaths = Object.freeze([
86
+ ...new Set(input.writePaths?.map((entry) => entry.trim()).filter((entry) => entry.length > 0) ?? []),
87
+ ]);
88
+ return Object.freeze({
89
+ identity: input.identity,
90
+ allowedTools,
91
+ writePaths,
92
+ ...(input.resourceProfile ? { resourceProfile: input.resourceProfile } : {}),
93
+ ...(input.resourceProfileJson ? { resourceProfileJson: input.resourceProfileJson } : {}),
94
+ ...(input.thinkingLevel ? { thinkingLevel: input.thinkingLevel } : {}),
95
+ ...(input.worktreeLane ? { worktreeLane: input.worktreeLane } : {}),
96
+ ...(input.parentPid !== undefined ? { parentPid: input.parentPid } : {}),
97
+ ...(input.parentSession ? { parentSession: input.parentSession } : {}),
98
+ ...(input.taskRef ? { taskRef: input.taskRef } : {}),
99
+ });
100
+ }
101
+
102
+ export interface LaunchProfileFlag {
103
+ flag: string;
104
+ value?: string;
105
+ }
106
+
107
+ /** Render a Pi child's immutable profile into its own CLI configuration. The manager supplies either
108
+ * an explicit resource-profile override or a one-shot snapshot of the parent's effective resources;
109
+ * standalone callers that omit both retain the child's normal resources. */
110
+ export function buildLaunchProfileFlags(profile: WorkerLaunchProfile): LaunchProfileFlag[] {
111
+ const flags: LaunchProfileFlag[] = profile.allowedTools.length
112
+ ? [{ flag: "--tools", value: profile.allowedTools.join(",") }]
113
+ : [{ flag: "--no-tools" }];
114
+ if (profile.resourceProfileJson) flags.push({ flag: "--resource-profile-json", value: profile.resourceProfileJson });
115
+ if (profile.resourceProfile) flags.push({ flag: "--resource-profile", value: profile.resourceProfile });
116
+ if (profile.thinkingLevel) flags.push({ flag: "--thinking", value: profile.thinkingLevel });
117
+ if (profile.worktreeLane) flags.push({ flag: "--worktree-lane", value: profile.worktreeLane });
118
+ if (profile.parentPid !== undefined) flags.push({ flag: "--parent-pid", value: String(profile.parentPid) });
119
+ if (profile.parentSession) flags.push({ flag: "--parent-session", value: profile.parentSession });
120
+ if (profile.taskRef) flags.push({ flag: "--task-ref", value: profile.taskRef });
121
+ flags.push({ flag: "--append-system-prompt", value: buildScopedSystemPrompt(profile) });
122
+ flags.push({ flag: "--session-mode", value: "worker" });
123
+ return flags;
124
+ }
125
+
126
+ export function buildScopedSystemPrompt(profile: WorkerLaunchProfile): string {
127
+ const scope = profile.writePaths.length
128
+ ? `Structural filesystem tools are limited to: ${profile.writePaths.join(", ")}. Process tools retain host access and must honor this assigned scope.`
129
+ : "Filesystem authority inherits the host's full-machine worker scope except private harness paths.";
130
+ const sentences = [
131
+ `You are a tmux worker running under immutable profile ${profile.identity}.`,
132
+ scope,
133
+ "Work autonomously to completion with the allowed tools; do not ask for routine permission inside the assigned task.",
134
+ "Do not spawn or delegate to other agents.",
135
+ "Report BLOCKED only when the objective is genuinely impossible with the assigned profile or missing external information.",
136
+ ];
137
+ if (profile.worktreeLane) {
138
+ sentences.push(
139
+ `You are bound to worktree-sync lane '${profile.worktreeLane}': work only inside this lane's own worktree, integrate exclusively via worktree_sync land, and never touch main directly.`,
140
+ );
141
+ }
142
+ return sentences.join(" ");
143
+ }
144
+
145
+ function isPlainRecord(value: unknown): value is Record<string, unknown> {
146
+ return typeof value === "object" && value !== null && !Array.isArray(value);
147
+ }
148
+
149
+ /** Decode an optional cooperative worker usage claim. Malformed numeric fields are zeroed because
150
+ * the claim is advisory and must never become an authoritative billing record. */
151
+ export function decodeTmuxWorkerUsageClaim(raw: unknown): Usage | undefined {
152
+ if (!isPlainRecord(raw)) return undefined;
153
+ const num = (value: unknown): number => (typeof value === "number" && Number.isFinite(value) ? value : 0);
154
+ const cost = isPlainRecord(raw.cost) ? raw.cost : {};
155
+ return {
156
+ input: num(raw.input),
157
+ output: num(raw.output),
158
+ cacheRead: num(raw.cacheRead),
159
+ cacheWrite: num(raw.cacheWrite),
160
+ totalTokens: num(raw.totalTokens),
161
+ cost: {
162
+ input: num(cost.input),
163
+ output: num(cost.output),
164
+ cacheRead: num(cost.cacheRead),
165
+ cacheWrite: num(cost.cacheWrite),
166
+ total: num(cost.total),
167
+ },
168
+ };
169
+ }
@@ -9,6 +9,6 @@
9
9
  { "provider": "pi", "name": "coordinator" }
10
10
  ],
11
11
  "notes": [
12
- "Use for owner-approved implementation/QA batches; never claim complete until result files and validation evidence are inspected."
12
+ "Use for implementation/QA batches; never claim complete until result files and validation evidence are inspected."
13
13
  ]
14
14
  }
@@ -9,6 +9,6 @@
9
9
  ],
10
10
  "notes": [
11
11
  "Use only when model-token/auth validation is intended.",
12
- "The manager opens each CLI in tmux, injects the prompt, captures pane output, and watches DONE/BLOCKED markers."
12
+ "The manager arms pane capture, starts each CLI with its initial prompt, and watches DONE/BLOCKED markers."
13
13
  ]
14
14
  }
@@ -98,22 +98,28 @@ history. This is not single-session summarization.
98
98
  5. Pick the smallest useful layer: Automata memory, skill, prompt template,
99
99
  role agent, extension/tool, then core source only when lower layers cannot
100
100
  solve it.
101
- 6. When `autoLearn.enabled` is true, long sessions may autonomously launch a
102
- background learner with the selected active/in-use model. Learners must share
103
- the Auto Learn state file, use per-session tenant leases, renew/complete
104
- their lease, and avoid colliding with learners from other sessions.
105
- 7. Auto Learn learners must look for memory. If Automata/user memory is enabled
101
+ 6. Automatic reflection is root-only: at most one durable cue is pending for
102
+ the orchestrator and projected transiently into its next ordinary provider
103
+ request. Accepting that request consumes the cue. Disabling reflection
104
+ dismisses it; re-enabling cannot resurrect its evidence. Reflection never
105
+ launches a second, background, or isolated model request. Workers do not
106
+ reflect or mutate durable memory; they return evidence to the orchestrator.
107
+ 7. An explicit `/auto-learn run` may launch one bounded background learner with
108
+ the selected active/in-use model. Learners must share the Auto Learn state
109
+ file, use per-session tenant leases, renew/complete their lease, and avoid
110
+ colliding with learners from other sessions.
111
+ 8. Auto Learn learners must look for memory. If Automata/user memory is enabled
106
112
  and contains rules, preferences, corrections, or project facts, query it
107
113
  before judging candidates and use it to polish proposals, avoid duplicates,
108
114
  and improve behavioral/tooling accuracy.
109
- 8. Apply policy gates: memory may be auto-applied only after overlap checks;
115
+ 9. Apply policy gates: memory may be auto-applied only after overlap checks;
110
116
  safe low-risk user-level skill/prompt changes may be applied when the current
111
117
  request or standing grant authorizes self-improvement. A direct request to
112
118
  fix or improve the harness is authorization for scoped source changes; do
113
119
  not ask for duplicate approval at each layer transition. Settings,
114
120
  credentials, destructive actions, executable authority expansion,
115
121
  publishing, pushing, tagging, and releases still require specific approval.
116
- 9. Leave an audit artifact with evidence sources, recurrence count, chosen
122
+ 10. Leave an audit artifact with evidence sources, recurrence count, chosen
117
123
  layer, action/approval need, expected benefit, risk, and validation.
118
124
 
119
125
  ## After-action learning workflow
@@ -9,7 +9,7 @@ description: "Use only when you need a reusable session-scoped worker preset (pr
9
9
 
10
10
  Use this skill only to create a session-scoped task preset. Do not load it to start workers.
11
11
 
12
- Native `delegate start` does not need an owner-authored base. Omit `profileId` and set `authority` (role `explorer` or `implementer`, model/reasoning, and tools). Empty `profile_inspect` bases are not a start block. Never add a budget: host settings and owner-authored profiles own ceilings.
12
+ Native `delegate start` does not need an owner-authored base. Omit `profileId` to inherit the foreground model, live reasoning level, compatible tools, and machine scope. Use only the optional top-level `model`, `thinkingLevel`, `path`, and `toolNames` fields to narrow or focus that inheritance. Empty `profile_inspect` bases are not a start block. Never add a budget or authority object: the host compiles grants and owns ceilings. Every generated profile inherits the base budget unchanged.
13
13
 
14
14
  Freedom Dial: high freedom for describing and composing the bounded task; low freedom for authority, persistence, model availability, and budget checks. Pi's core engineering and evidence rules remain mandatory.
15
15
 
@@ -22,13 +22,13 @@ Create the smallest immutable profile that can complete one explicit task, then
22
22
  ### 1. Establish the contract
23
23
 
24
24
  1. State the worker's single outcome, required evidence, intended files, and completion boundary.
25
- 2. Call `delegate` with `action: "profile_inspect"` only when you are about to `profile_create` and the reusable bases or configured model/thinking combinations are unknown.
26
- 3. If inspect lists no owner-authored explorer/implementer base, do not ask the user to authorize one just to start work. Start with `delegate start` and `authority`. Ask the user only if they explicitly want a durable reusable base for future `profile_create`.
27
- 4. When creating a preset, choose an owner-authored base whose role and authority already cover the task. Never derive from another generated task profile.
25
+ 2. Call `delegate` with `action: "profile_inspect"` only when you are about to `profile_create` and reusable owner bases or configured model/thinking combinations are unknown. Inspection is optional.
26
+ 3. If no owner-authored base is selected, `profile_create` derives its base directly from the foreground inheritance. Do not ask the user to authorize a base just to start work or create a preset.
27
+ 4. When an owner-authored base is useful, choose one whose authority already covers the task. Never derive from another generated task profile.
28
28
  5. Prefer the fastest model with demonstrated ability to satisfy the task contract. Configuration and authentication prove availability, not fitness; use existing fitness evidence or `model_fitness` when the risk justifies its token cost.
29
- 6. Request only the tools and resource profiles the task needs. Omitted fields inherit the base; supplied fields must be exact subsets. The generated profile inherits the base budget unchanged because `profile_create` has no budget field.
29
+ 6. Request only the model, thinking level, one workspace path, and exact tool subset the task needs. Omitted fields inherit the base. Resources and budget always remain host-owned and inherited.
30
30
 
31
- Human edge: if `profile_create` is required and the task needs an unlisted base, unavailable credentials, broader tools/resources, or a different budget, stop and ask the user to authorize a durable owner-profile change. Do not route around a rejection. Do not treat that as a ban on `delegate start`.
31
+ Human edge: if an explicitly requested reusable preset needs unavailable credentials, tools outside its inherited surface, or a different budget, report the exact rejection and ask for an owner-profile change. Do not route around a rejection. Ordinary inherited `delegate start` remains available unless the host reports a real admission block.
32
32
 
33
33
  ### 2. Execute and verify
34
34
 
@@ -43,15 +43,15 @@ Human edge: if `profile_create` is required and the task needs an unlisted base,
43
43
  - Blocking `delegate start` because `profile_inspect` listed no bases.
44
44
  - Writing one-off profile JSON, settings, reports, or dependencies into the repository.
45
45
  - Selecting a model or thinking level that `inspect` did not report as available.
46
- - Giving a worker extra tools "just in case" or attempting to author a per-dispatch budget.
46
+ - Giving a worker extra tools "just in case", authoring resource/capability arrays, or attempting a per-dispatch budget.
47
47
  - Inventing, guessing, editing, or reusing a generated profile ID across sessions or branches.
48
48
  - Treating a fast model as fit without task-shaped evidence.
49
49
 
50
50
  ## Examples
51
51
 
52
- Positive: inspect, derive from a read/write implementer, select an authenticated fast model at `low`, narrow tools to `read`, `grep`, and `edit`, inherit the base budget unchanged, then delegate with the returned `task-...` ID.
52
+ Positive: omit inspect and base, derive from foreground inheritance, select an authenticated fast model at `low`, narrow tools to `read`, `grep`, and `edit`, inherit host resources and budget unchanged, then delegate with the returned `task-...` ID.
53
53
 
54
- Positive: inspect returns no bases; start two workers with `authority.role` `explorer` and `implementer` and no `profileId`.
54
+ Positive: start two workers with self-contained instructions and no `profileId`; omit overrides when both should inherit the foreground model, reasoning, tools, and machine scope.
55
55
 
56
56
  Negative: a base exposes only `read` and `grep`, but the task requires `edit`. Do not request `edit` from `profile_create`; select an authorized write-capable base or ask the user for an owner-profile change. Starting without a profile remains allowed.
57
57
 
@@ -62,9 +62,9 @@ Negative: telling the user workers are blocked until they authorize explorer/imp
62
62
  - Ordinary start omitted `profileId` unless a returned `task-...` ID is in hand.
63
63
  - Empty inspect bases did not stop start.
64
64
  - The task has one bounded outcome and explicit acceptance evidence.
65
- - The base, if used, is owner-authored and authorized for this orchestrator.
65
+ - The base is foreground inheritance or an owner-authored profile authorized for this orchestrator.
66
66
  - Model and thinking level were reported available or otherwise resolved by the harness.
67
- - Tools/resources are subsets and the owner-authored base budget is unchanged.
67
+ - Tools are an exact subset; resources and budget remain inherited and host-owned.
68
68
  - The returned ID is passed unchanged; no project/user profile file was created.
69
69
 
70
70
  ## Known Gaps
@@ -9,6 +9,8 @@ export declare function isCanonicalAgentRootEntry(name: string): boolean;
9
9
  export declare function configFile(agentDir: string, name: string): string;
10
10
  /** `<agentDir>/okf-memory` -- user-authored durable OKF memory documents. */
11
11
  export declare function okfMemoryDir(agentDir: string): string;
12
+ /** `<agentDir>/okf-memory/projects/<project-key>` -- managed project-isolated OKF records. */
13
+ export declare function okfProjectMemoryDir(agentDir: string, projectKey: string): string;
12
14
  /** `<agentDir>/state` -- durable machine-managed state. Deleting it loses real history, not just cache. */
13
15
  export declare function stateDir(agentDir: string): string;
14
16
  /** `<agentDir>/state/<segments…>` */
@@ -1 +1 @@
1
- {"version":3,"file":"agent-paths.d.ts","sourceRoot":"","sources":["../../src/core/agent-paths.ts"],"names":[],"mappings":"AAyCA,OAAO,EACN,cAAc,EACd,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGhE,wEAAwE;AACxE,eAAO,MAAM,qBAAqB,YACjC,WAAW,EACX,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,WAAW,EACX,kBAAkB,CACT,CAAC;AAEX,oFAAoF;AACpF,eAAO,MAAM,0BAA0B,YACtC,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,UAAU,EACV,WAAW,EACX,OAAO,EACP,OAAO,EACP,KAAK,EACL,MAAM,EACN,UAAU,EACV,QAAQ,EACR,UAAU,EACV,KAAK,EACL,KAAK,EACL,WAAW,CACF,CAAC;AAIX,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE/D;AAED,4GAA4G;AAC5G,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC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AM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAS7G;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAExF;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAS9G;AAED,wDAAwD;AACxD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,gEAAgE;AAChE,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,CAAC;AAE1G,oGAAoG;AACpG,wBAAgB,WAAW,CAAC,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED,4FAA4F;AAC5F,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;GAKG;AACH,OAAO,EACN,WAAW,EACX,yBAAyB,EACzB,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,eAAe,GACf,CAAC;AACF,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE5G;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,iCAA2B,CAAC"}
@@ -85,6 +85,13 @@ export function configFile(agentDir, name) {
85
85
  export function okfMemoryDir(agentDir) {
86
86
  return join(agentDir, "okf-memory");
87
87
  }
88
+ /** `<agentDir>/okf-memory/projects/<project-key>` -- managed project-isolated OKF records. */
89
+ export function okfProjectMemoryDir(agentDir, projectKey) {
90
+ if (!/^[a-f0-9]{16}$/i.test(projectKey)) {
91
+ throw new TypeError("OKF project key must be a 16-character hexadecimal digest.");
92
+ }
93
+ return join(okfMemoryDir(agentDir), "projects", projectKey.toLowerCase());
94
+ }
88
95
  /** `<agentDir>/state` -- durable machine-managed state. Deleting it loses real history, not just cache. */
89
96
  export function stateDir(agentDir) {
90
97
  return join(agentDir, "state");