@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,12 +1,15 @@
1
1
  import { randomUUID } from "node:crypto";
2
- import { getSupportedThinkingLevels } from "@caupulican/pi-ai/models";
2
+ import { getSupportedThinkingLevels, resolveModelThinkingLevel } from "@caupulican/pi-ai/models";
3
+ import { isPathWithinScope } from "../autonomy/path-scope.js";
4
+ import { LEAF_WORKER_DELEGATION_LIMITS } from "../delegation/worker-fleet-limits.js";
5
+ import { resolveWorkerWorkspacePath } from "../delegation/worker-machine-scope.js";
3
6
  import { MAX_ORCHESTRATION_DESCRIPTION_LENGTH } from "./contracts.js";
4
7
  import { resolvePinnedOrchestrationModel } from "./model-binding.js";
5
8
  import { validateOrchestrationProfile } from "./profile-registry.js";
6
9
  import { OrchestrationProfileStore } from "./profile-store.js";
7
10
  const MAX_INSPECTED_MODELS = 64;
8
11
  const MAX_TASK_DESCRIPTION_LENGTH = 3_500;
9
- const MAX_BUDGET_KEYS = ["maxTokens", "maxWallClockMs", "maxCostUsd", "maxAttempts", "maxToolCalls"];
12
+ const INHERITED_BASE_PROFILE_ID = "inherited-foreground";
10
13
  function sameStrings(left, right) {
11
14
  return left.length === right.length && left.every((value, index) => value === right[index]);
12
15
  }
@@ -15,31 +18,6 @@ function isExactSubset(candidate, ceiling) {
15
18
  const unique = new Set(candidate);
16
19
  return unique.size === candidate.length && candidate.every((value) => allowed.has(value));
17
20
  }
18
- function narrowBudget(base, patch) {
19
- if (!patch)
20
- return structuredClone(base);
21
- const narrowed = { ...base };
22
- for (const key of MAX_BUDGET_KEYS) {
23
- const requested = patch[key];
24
- if (requested === undefined)
25
- continue;
26
- const ceiling = base[key];
27
- if (ceiling !== undefined && requested > ceiling)
28
- return undefined;
29
- narrowed[key] = requested;
30
- }
31
- if (patch.requireApprovalAboveCostUsd !== undefined) {
32
- const ceiling = base.requireApprovalAboveCostUsd;
33
- if (ceiling !== undefined && patch.requireApprovalAboveCostUsd > ceiling)
34
- return undefined;
35
- narrowed.requireApprovalAboveCostUsd = patch.requireApprovalAboveCostUsd;
36
- }
37
- return narrowed;
38
- }
39
- function sameBudget(left, right) {
40
- return (MAX_BUDGET_KEYS.every((key) => left[key] === right[key]) &&
41
- left.requireApprovalAboveCostUsd === right.requireApprovalAboveCostUsd);
42
- }
43
21
  function sameModelPolicy(left, right) {
44
22
  return (left.mode === right.mode &&
45
23
  left.candidates.length === right.candidates.length &&
@@ -72,7 +50,11 @@ export class TaskProfileWriter {
72
50
  modelId: model.id,
73
51
  thinkingLevels: getSupportedThinkingLevels(model),
74
52
  }));
75
- return { baseProfiles, models };
53
+ return {
54
+ baseProfiles,
55
+ models,
56
+ inheritedToolNames: [...(this.options.getInheritedBaseProfile()?.toolNames ?? [])],
57
+ };
76
58
  }
77
59
  createTaskProfile(input) {
78
60
  try {
@@ -80,47 +62,78 @@ export class TaskProfileWriter {
80
62
  if (!task || task.length > MAX_TASK_DESCRIPTION_LENGTH) {
81
63
  return { created: false, reason: "task_profile_description_invalid" };
82
64
  }
83
- const bases = this.authorizedBaseProfiles();
84
- const baseProfileId = input.baseProfileId?.trim() || (bases.length === 1 ? bases[0].profileId : undefined);
85
- if (!baseProfileId)
86
- return { created: false, reason: "task_profile_base_required" };
87
- const ownerProfiles = this.loadOwnerProfiles();
88
- const base = ownerProfiles.get(baseProfileId);
89
- if (!base || base.role === "orchestrator") {
90
- return { created: false, reason: "task_profile_base_not_found" };
65
+ const requestedBaseProfileId = input.baseProfileId?.trim();
66
+ let baseProfileId = INHERITED_BASE_PROFILE_ID;
67
+ let base;
68
+ if (requestedBaseProfileId) {
69
+ baseProfileId = requestedBaseProfileId;
70
+ base = this.loadOwnerProfiles().get(baseProfileId);
71
+ if (!base || base.role === "orchestrator") {
72
+ return { created: false, reason: "task_profile_base_not_found" };
73
+ }
74
+ if (!this.authorizedBaseProfiles().some((candidate) => candidate.profileId === baseProfileId)) {
75
+ return { created: false, reason: "task_profile_base_not_authorized" };
76
+ }
91
77
  }
92
- if (!bases.some((candidate) => candidate.profileId === baseProfileId)) {
93
- return { created: false, reason: "task_profile_base_not_authorized" };
78
+ else {
79
+ base = this.options.getInheritedBaseProfile();
80
+ if (!base)
81
+ return { created: false, reason: "task_profile_inherited_base_unavailable" };
94
82
  }
95
- const toolNames = input.toolNames ? [...input.toolNames] : [...base.toolNames];
96
- if (!isExactSubset(toolNames, base.toolNames)) {
83
+ const compatibleBaseToolNames = base.toolNames.filter((toolName) => toolName !== "delegate");
84
+ const toolNames = input.toolNames ? [...input.toolNames] : compatibleBaseToolNames;
85
+ if (!isExactSubset(toolNames, compatibleBaseToolNames)) {
97
86
  return { created: false, reason: "task_profile_tool_authority_expansion" };
98
87
  }
99
- const resourceProfileNames = input.resourceProfileNames
100
- ? [...input.resourceProfileNames]
101
- : [...base.resourceProfileNames];
102
- if (!isExactSubset(resourceProfileNames, base.resourceProfileNames)) {
103
- return { created: false, reason: "task_profile_resource_authority_expansion" };
104
- }
105
- const budget = narrowBudget(base.budget, input.budget);
106
- if (!budget)
107
- return { created: false, reason: "task_profile_budget_expansion" };
88
+ const budget = structuredClone(base.budget);
108
89
  let modelPolicy = structuredClone(base.modelPolicy);
109
- if (input.model) {
110
- const binding = { ...input.model };
111
- const resolved = resolvePinnedOrchestrationModel(binding, this.options.getModelRegistry(), (model) => this.options.isModelExhausted(model.provider, model.id));
90
+ if (input.model || input.thinkingLevel) {
91
+ const baseBinding = base.modelPolicy.candidates[0];
92
+ if (!baseBinding)
93
+ return { created: false, reason: "task_profile_model_unavailable" };
94
+ const provider = input.model?.provider ?? baseBinding.provider;
95
+ const modelId = input.model?.modelId ?? baseBinding.modelId;
96
+ const model = this.options.getModelRegistry().find(provider, modelId);
97
+ if (!model)
98
+ return { created: false, reason: "task_profile_model_unavailable" };
99
+ const sameModel = provider === baseBinding.provider && modelId === baseBinding.modelId;
100
+ const binding = {
101
+ provider,
102
+ modelId,
103
+ thinkingLevel: input.thinkingLevel ??
104
+ (sameModel ? baseBinding.thinkingLevel : resolveModelThinkingLevel(model, undefined)),
105
+ };
106
+ const resolved = resolvePinnedOrchestrationModel(binding, this.options.getModelRegistry(), (candidate) => this.options.isModelExhausted(candidate.provider, candidate.id));
112
107
  if (!resolved)
113
108
  return { created: false, reason: "task_profile_model_unavailable" };
114
109
  modelPolicy = { mode: "fixed", candidates: [binding] };
115
110
  }
111
+ let workspacePath = base.workspacePath;
112
+ if (input.path !== undefined) {
113
+ const trimmedPath = input.path.trim();
114
+ if (!trimmedPath)
115
+ return { created: false, reason: "task_profile_path_invalid" };
116
+ const requestedPath = resolveWorkerWorkspacePath(this.options.cwd, trimmedPath);
117
+ if (base.workspacePath && !isPathWithinScope(requestedPath, base.workspacePath)) {
118
+ return { created: false, reason: "task_profile_path_authority_expansion" };
119
+ }
120
+ workspacePath = requestedPath;
121
+ }
116
122
  const now = new Date().toISOString();
117
123
  const profile = structuredClone(base);
118
124
  delete profile.sourcePath;
119
125
  profile.profileId = `task-${randomUUID()}`;
120
126
  profile.description = `Task-scoped worker: ${task}`.slice(0, MAX_ORCHESTRATION_DESCRIPTION_LENGTH);
121
127
  profile.modelPolicy = modelPolicy;
128
+ profile.capabilityCeiling = base.capabilityCeiling.filter((capability) => capability !== "workflow.delegate" && capability !== "memory.mutate");
122
129
  profile.toolNames = toolNames;
123
- profile.resourceProfileNames = resourceProfileNames;
130
+ if (workspacePath)
131
+ profile.workspacePath = workspacePath;
132
+ else
133
+ delete profile.workspacePath;
134
+ profile.resourceProfileNames = [...base.resourceProfileNames];
135
+ profile.dispatchProfileIds = [];
136
+ profile.delegationLimits = structuredClone(LEAF_WORKER_DELEGATION_LIMITS);
124
137
  profile.budget = budget;
125
138
  profile.createdAt = now;
126
139
  profile.updatedAt = now;
@@ -132,14 +145,13 @@ export class TaskProfileWriter {
132
145
  profile,
133
146
  });
134
147
  const changedFields = ["description"];
135
- if (input.model && !sameModelPolicy(modelPolicy, base.modelPolicy))
136
- changedFields.push("model");
148
+ if ((input.model || input.thinkingLevel) && !sameModelPolicy(modelPolicy, base.modelPolicy)) {
149
+ changedFields.push(input.model ? "model" : "thinking");
150
+ }
151
+ if (workspacePath !== base.workspacePath)
152
+ changedFields.push("path");
137
153
  if (!sameStrings(toolNames, base.toolNames))
138
154
  changedFields.push("tools");
139
- if (!sameStrings(resourceProfileNames, base.resourceProfileNames))
140
- changedFields.push("resources");
141
- if (!sameBudget(budget, base.budget))
142
- changedFields.push("budget");
143
155
  return { created: true, profileId: profile.profileId, baseProfileId, changedFields };
144
156
  }
145
157
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"task-profile-writer.js","sourceRoot":"","sources":["../../../src/core/orchestration/task-profile-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAUtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAkD/D,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,2BAA2B,GAAG,KAAK,CAAC;AAC1C,MAAM,eAAe,GAAG,CAAC,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,CAAU,CAAC;AAE9G,SAAS,WAAW,CAAC,IAAuB,EAAE,KAAwB;IACrE,OAAO,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7F,CAAC;AAED,SAAS,aAAa,CAAC,SAA4B,EAAE,OAA0B;IAC9E,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IAClC,OAAO,MAAM,CAAC,IAAI,KAAK,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AAM,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACxE,OAAO,CAAC,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CACnD,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,cAAc,IAAI,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAC5F,CAAC;IACH,CAAC;IAEO,iBAAiB;QACxB,MAAM,QAAQ,GAAG,IAAI,yBAAyB,CAAC;YAC9C,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;YAC/B,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG;YACrB,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,gBAAgB,EAAE;SACpE,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC;QACnB,OAAO,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { getSupportedThinkingLevels } from \"@caupulican/pi-ai/models\";\nimport type { ModelRegistry } from \"../model-registry.ts\";\nimport type { SettingsManager } from \"../settings-manager.ts\";\nimport type {\n\tOrchestrationModelBinding,\n\tOrchestrationModelPolicy,\n\tOrchestrationProfile,\n\tOrchestrationThinkingLevel,\n\tRiskBudget,\n} from \"./contracts.ts\";\nimport { MAX_ORCHESTRATION_DESCRIPTION_LENGTH } from \"./contracts.ts\";\nimport { resolvePinnedOrchestrationModel } from \"./model-binding.ts\";\nimport { validateOrchestrationProfile } from \"./profile-registry.ts\";\nimport { OrchestrationProfileStore } from \"./profile-store.ts\";\nimport type { SessionTaskProfileStore } from \"./session-task-profile-store.ts\";\n\nexport interface TaskProfileModelSelection {\n\tprovider: string;\n\tmodelId: string;\n\tthinkingLevel: OrchestrationThinkingLevel;\n}\n\nexport interface TaskProfileCreateInput {\n\ttask: string;\n\tbaseProfileId?: string;\n\tmodel?: TaskProfileModelSelection;\n\ttoolNames?: readonly string[];\n\tresourceProfileNames?: readonly string[];\n\tbudget?: RiskBudget;\n}\n\nexport interface TaskProfileInspection {\n\tbaseProfiles: Array<{ profileId: string; role: string; description: string }>;\n\tmodels: Array<{\n\t\tprovider: string;\n\t\tmodelId: string;\n\t\tthinkingLevels: readonly OrchestrationThinkingLevel[];\n\t}>;\n}\n\nexport interface TaskProfileCreateResult {\n\tcreated: boolean;\n\treason?: string;\n\tprofileId?: string;\n\tbaseProfileId?: string;\n\tchangedFields?: string[];\n}\n\nexport interface TaskProfileWriterPort {\n\tinspectTaskProfileOptions(): TaskProfileInspection;\n\tcreateTaskProfile(input: TaskProfileCreateInput): TaskProfileCreateResult;\n}\n\nexport interface TaskProfileWriterOptions {\n\tagentDir: string;\n\tcwd: string;\n\tstore: SessionTaskProfileStore;\n\tgetSettingsManager(): SettingsManager;\n\tgetModelRegistry(): ModelRegistry;\n\tisModelExhausted(provider: string, modelId: string): boolean;\n\tgetActiveOrchestrationProfile(): OrchestrationProfile | undefined;\n}\n\nconst MAX_INSPECTED_MODELS = 64;\nconst MAX_TASK_DESCRIPTION_LENGTH = 3_500;\nconst MAX_BUDGET_KEYS = [\"maxTokens\", \"maxWallClockMs\", \"maxCostUsd\", \"maxAttempts\", \"maxToolCalls\"] as const;\n\nfunction sameStrings(left: readonly string[], right: readonly string[]): boolean {\n\treturn left.length === right.length && left.every((value, index) => value === right[index]);\n}\n\nfunction isExactSubset(candidate: readonly string[], ceiling: readonly string[]): boolean {\n\tconst allowed = new Set(ceiling);\n\tconst unique = new Set(candidate);\n\treturn unique.size === candidate.length && candidate.every((value) => allowed.has(value));\n}\n\nfunction narrowBudget(base: RiskBudget, patch: RiskBudget | undefined): RiskBudget | undefined {\n\tif (!patch) return structuredClone(base);\n\tconst narrowed: RiskBudget = { ...base };\n\tfor (const key of MAX_BUDGET_KEYS) {\n\t\tconst requested = patch[key];\n\t\tif (requested === undefined) continue;\n\t\tconst ceiling = base[key];\n\t\tif (ceiling !== undefined && requested > ceiling) return undefined;\n\t\tnarrowed[key] = requested;\n\t}\n\tif (patch.requireApprovalAboveCostUsd !== undefined) {\n\t\tconst ceiling = base.requireApprovalAboveCostUsd;\n\t\tif (ceiling !== undefined && patch.requireApprovalAboveCostUsd > ceiling) return undefined;\n\t\tnarrowed.requireApprovalAboveCostUsd = patch.requireApprovalAboveCostUsd;\n\t}\n\treturn narrowed;\n}\n\nfunction sameBudget(left: RiskBudget, right: RiskBudget): boolean {\n\treturn (\n\t\tMAX_BUDGET_KEYS.every((key) => left[key] === right[key]) &&\n\t\tleft.requireApprovalAboveCostUsd === right.requireApprovalAboveCostUsd\n\t);\n}\n\nfunction sameModelPolicy(left: OrchestrationModelPolicy, right: OrchestrationModelPolicy): boolean {\n\treturn (\n\t\tleft.mode === right.mode &&\n\t\tleft.candidates.length === right.candidates.length &&\n\t\tleft.candidates.every((candidate, index) => {\n\t\t\tconst other = right.candidates[index];\n\t\t\treturn (\n\t\t\t\tother !== undefined &&\n\t\t\t\tcandidate.provider === other.provider &&\n\t\t\t\tcandidate.modelId === other.modelId &&\n\t\t\t\tcandidate.thinkingLevel === other.thinkingLevel\n\t\t\t);\n\t\t})\n\t);\n}\n\nexport class TaskProfileWriter implements TaskProfileWriterPort {\n\tprivate readonly options: TaskProfileWriterOptions;\n\n\tconstructor(options: TaskProfileWriterOptions) {\n\t\tthis.options = options;\n\t}\n\n\tinspectTaskProfileOptions(): TaskProfileInspection {\n\t\tconst baseProfiles = this.authorizedBaseProfiles().map((profile) => ({\n\t\t\tprofileId: profile.profileId,\n\t\t\trole: profile.role,\n\t\t\tdescription: profile.description,\n\t\t}));\n\t\tconst models = this.options\n\t\t\t.getModelRegistry()\n\t\t\t.getAvailable()\n\t\t\t.filter((model) => !this.options.isModelExhausted(model.provider, model.id))\n\t\t\t.sort((left, right) => `${left.provider}/${left.id}`.localeCompare(`${right.provider}/${right.id}`))\n\t\t\t.slice(0, MAX_INSPECTED_MODELS)\n\t\t\t.map((model) => ({\n\t\t\t\tprovider: model.provider,\n\t\t\t\tmodelId: model.id,\n\t\t\t\tthinkingLevels: getSupportedThinkingLevels(model),\n\t\t\t}));\n\t\treturn { baseProfiles, models };\n\t}\n\n\tcreateTaskProfile(input: TaskProfileCreateInput): TaskProfileCreateResult {\n\t\ttry {\n\t\t\tconst task = input.task.trim();\n\t\t\tif (!task || task.length > MAX_TASK_DESCRIPTION_LENGTH) {\n\t\t\t\treturn { created: false, reason: \"task_profile_description_invalid\" };\n\t\t\t}\n\t\t\tconst bases = this.authorizedBaseProfiles();\n\t\t\tconst baseProfileId = input.baseProfileId?.trim() || (bases.length === 1 ? bases[0].profileId : undefined);\n\t\t\tif (!baseProfileId) return { created: false, reason: \"task_profile_base_required\" };\n\t\t\tconst ownerProfiles = this.loadOwnerProfiles();\n\t\t\tconst base = ownerProfiles.get(baseProfileId);\n\t\t\tif (!base || base.role === \"orchestrator\") {\n\t\t\t\treturn { created: false, reason: \"task_profile_base_not_found\" };\n\t\t\t}\n\t\t\tif (!bases.some((candidate) => candidate.profileId === baseProfileId)) {\n\t\t\t\treturn { created: false, reason: \"task_profile_base_not_authorized\" };\n\t\t\t}\n\n\t\t\tconst toolNames = input.toolNames ? [...input.toolNames] : [...base.toolNames];\n\t\t\tif (!isExactSubset(toolNames, base.toolNames)) {\n\t\t\t\treturn { created: false, reason: \"task_profile_tool_authority_expansion\" };\n\t\t\t}\n\t\t\tconst resourceProfileNames = input.resourceProfileNames\n\t\t\t\t? [...input.resourceProfileNames]\n\t\t\t\t: [...base.resourceProfileNames];\n\t\t\tif (!isExactSubset(resourceProfileNames, base.resourceProfileNames)) {\n\t\t\t\treturn { created: false, reason: \"task_profile_resource_authority_expansion\" };\n\t\t\t}\n\t\t\tconst budget = narrowBudget(base.budget, input.budget);\n\t\t\tif (!budget) return { created: false, reason: \"task_profile_budget_expansion\" };\n\n\t\t\tlet modelPolicy = structuredClone(base.modelPolicy);\n\t\t\tif (input.model) {\n\t\t\t\tconst binding: OrchestrationModelBinding = { ...input.model };\n\t\t\t\tconst resolved = resolvePinnedOrchestrationModel(binding, this.options.getModelRegistry(), (model) =>\n\t\t\t\t\tthis.options.isModelExhausted(model.provider, model.id),\n\t\t\t\t);\n\t\t\t\tif (!resolved) return { created: false, reason: \"task_profile_model_unavailable\" };\n\t\t\t\tmodelPolicy = { mode: \"fixed\", candidates: [binding] };\n\t\t\t}\n\n\t\t\tconst now = new Date().toISOString();\n\t\t\tconst profile = structuredClone(base);\n\t\t\tdelete profile.sourcePath;\n\t\t\tprofile.profileId = `task-${randomUUID()}`;\n\t\t\tprofile.description = `Task-scoped worker: ${task}`.slice(0, MAX_ORCHESTRATION_DESCRIPTION_LENGTH);\n\t\t\tprofile.modelPolicy = modelPolicy;\n\t\t\tprofile.toolNames = toolNames;\n\t\t\tprofile.resourceProfileNames = resourceProfileNames;\n\t\t\tprofile.budget = budget;\n\t\t\tprofile.createdAt = now;\n\t\t\tprofile.updatedAt = now;\n\t\t\tvalidateOrchestrationProfile(profile);\n\n\t\t\tconst activeProfile = this.options.getActiveOrchestrationProfile();\n\t\t\tthis.options.store.append({\n\t\t\t\tbaseProfileId,\n\t\t\t\t...(activeProfile ? { authorProfileId: activeProfile.profileId } : {}),\n\t\t\t\tprofile,\n\t\t\t});\n\t\t\tconst changedFields = [\"description\"];\n\t\t\tif (input.model && !sameModelPolicy(modelPolicy, base.modelPolicy)) changedFields.push(\"model\");\n\t\t\tif (!sameStrings(toolNames, base.toolNames)) changedFields.push(\"tools\");\n\t\t\tif (!sameStrings(resourceProfileNames, base.resourceProfileNames)) changedFields.push(\"resources\");\n\t\t\tif (!sameBudget(budget, base.budget)) changedFields.push(\"budget\");\n\t\t\treturn { created: true, profileId: profile.profileId, baseProfileId, changedFields };\n\t\t} catch (error) {\n\t\t\treturn { created: false, reason: error instanceof Error ? error.message : String(error) };\n\t\t}\n\t}\n\n\tprivate authorizedBaseProfiles(): OrchestrationProfile[] {\n\t\tconst active = this.options.getActiveOrchestrationProfile();\n\t\tif (active && active.role !== \"orchestrator\") return [];\n\t\tconst allowed = active ? new Set(active.dispatchProfileIds) : undefined;\n\t\treturn [...this.loadOwnerProfiles().values()].filter(\n\t\t\t(profile) => profile.role !== \"orchestrator\" && (!allowed || allowed.has(profile.profileId)),\n\t\t);\n\t}\n\n\tprivate loadOwnerProfiles(): ReadonlyMap<string, OrchestrationProfile> {\n\t\tconst profiles = new OrchestrationProfileStore({\n\t\t\tagentDir: this.options.agentDir,\n\t\t\tcwd: this.options.cwd,\n\t\t\tprojectTrusted: this.options.getSettingsManager().isProjectTrusted(),\n\t\t}).load().profiles;\n\t\treturn new Map(profiles.map((profile) => [profile.profileId, profile]));\n\t}\n}\n"]}
1
+ {"version":3,"file":"task-profile-writer.js","sourceRoot":"","sources":["../../../src/core/orchestration/task-profile-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AASnF,OAAO,EAAE,oCAAoC,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAqD/D,MAAM,oBA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CAAC,CAAC,MAAM,CACnD,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,cAAc,IAAI,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAC5F,CAAC;IACH,CAAC;IAEO,iBAAiB;QACxB,MAAM,QAAQ,GAAG,IAAI,yBAAyB,CAAC;YAC9C,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;YAC/B,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG;YACrB,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,gBAAgB,EAAE;SACpE,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC;QACnB,OAAO,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { getSupportedThinkingLevels, resolveModelThinkingLevel } from \"@caupulican/pi-ai/models\";\nimport { isPathWithinScope } from \"../autonomy/path-scope.ts\";\nimport { LEAF_WORKER_DELEGATION_LIMITS } from \"../delegation/worker-fleet-limits.ts\";\nimport { resolveWorkerWorkspacePath } from \"../delegation/worker-machine-scope.ts\";\nimport type { ModelRegistry } from \"../model-registry.ts\";\nimport type { SettingsManager } from \"../settings-manager.ts\";\nimport type {\n\tOrchestrationModelBinding,\n\tOrchestrationModelPolicy,\n\tOrchestrationProfile,\n\tOrchestrationThinkingLevel,\n} from \"./contracts.ts\";\nimport { MAX_ORCHESTRATION_DESCRIPTION_LENGTH } from \"./contracts.ts\";\nimport { resolvePinnedOrchestrationModel } from \"./model-binding.ts\";\nimport { validateOrchestrationProfile } from \"./profile-registry.ts\";\nimport { OrchestrationProfileStore } from \"./profile-store.ts\";\nimport type { SessionTaskProfileStore } from \"./session-task-profile-store.ts\";\n\nexport interface TaskProfileModelSelection {\n\tprovider: string;\n\tmodelId: string;\n}\n\nexport interface TaskProfileCreateInput {\n\ttask: string;\n\tbaseProfileId?: string;\n\tmodel?: TaskProfileModelSelection;\n\tthinkingLevel?: OrchestrationThinkingLevel;\n\tpath?: string;\n\ttoolNames?: readonly string[];\n}\n\nexport interface TaskProfileInspection {\n\tbaseProfiles: Array<{ profileId: string; role: string; description: string }>;\n\t/** Exact native-lane surface a no-base profile inherits from the live foreground session. */\n\tinheritedToolNames: readonly string[];\n\tmodels: Array<{\n\t\tprovider: string;\n\t\tmodelId: string;\n\t\tthinkingLevels: readonly OrchestrationThinkingLevel[];\n\t}>;\n}\n\nexport interface TaskProfileCreateResult {\n\tcreated: boolean;\n\treason?: string;\n\tprofileId?: string;\n\tbaseProfileId?: string;\n\tchangedFields?: string[];\n}\n\nexport interface TaskProfileWriterPort {\n\tinspectTaskProfileOptions(): TaskProfileInspection;\n\tcreateTaskProfile(input: TaskProfileCreateInput): TaskProfileCreateResult;\n}\n\nexport interface TaskProfileWriterOptions {\n\tagentDir: string;\n\tcwd: string;\n\tstore: SessionTaskProfileStore;\n\tgetSettingsManager(): SettingsManager;\n\tgetModelRegistry(): ModelRegistry;\n\tisModelExhausted(provider: string, modelId: string): boolean;\n\tgetActiveOrchestrationProfile(): OrchestrationProfile | undefined;\n\t/** Host-compiled foreground inheritance used when no owner-authored base is selected. */\n\tgetInheritedBaseProfile(): OrchestrationProfile | undefined;\n}\n\nconst MAX_INSPECTED_MODELS = 64;\nconst MAX_TASK_DESCRIPTION_LENGTH = 3_500;\nconst INHERITED_BASE_PROFILE_ID = \"inherited-foreground\";\n\nfunction sameStrings(left: readonly string[], right: readonly string[]): boolean {\n\treturn left.length === right.length && left.every((value, index) => value === right[index]);\n}\n\nfunction isExactSubset(candidate: readonly string[], ceiling: readonly string[]): boolean {\n\tconst allowed = new Set(ceiling);\n\tconst unique = new Set(candidate);\n\treturn unique.size === candidate.length && candidate.every((value) => allowed.has(value));\n}\n\nfunction sameModelPolicy(left: OrchestrationModelPolicy, right: OrchestrationModelPolicy): boolean {\n\treturn (\n\t\tleft.mode === right.mode &&\n\t\tleft.candidates.length === right.candidates.length &&\n\t\tleft.candidates.every((candidate, index) => {\n\t\t\tconst other = right.candidates[index];\n\t\t\treturn (\n\t\t\t\tother !== undefined &&\n\t\t\t\tcandidate.provider === other.provider &&\n\t\t\t\tcandidate.modelId === other.modelId &&\n\t\t\t\tcandidate.thinkingLevel === other.thinkingLevel\n\t\t\t);\n\t\t})\n\t);\n}\n\nexport class TaskProfileWriter implements TaskProfileWriterPort {\n\tprivate readonly options: TaskProfileWriterOptions;\n\n\tconstructor(options: TaskProfileWriterOptions) {\n\t\tthis.options = options;\n\t}\n\n\tinspectTaskProfileOptions(): TaskProfileInspection {\n\t\tconst baseProfiles = this.authorizedBaseProfiles().map((profile) => ({\n\t\t\tprofileId: profile.profileId,\n\t\t\trole: profile.role,\n\t\t\tdescription: profile.description,\n\t\t}));\n\t\tconst models = this.options\n\t\t\t.getModelRegistry()\n\t\t\t.getAvailable()\n\t\t\t.filter((model) => !this.options.isModelExhausted(model.provider, model.id))\n\t\t\t.sort((left, right) => `${left.provider}/${left.id}`.localeCompare(`${right.provider}/${right.id}`))\n\t\t\t.slice(0, MAX_INSPECTED_MODELS)\n\t\t\t.map((model) => ({\n\t\t\t\tprovider: model.provider,\n\t\t\t\tmodelId: model.id,\n\t\t\t\tthinkingLevels: getSupportedThinkingLevels(model),\n\t\t\t}));\n\t\treturn {\n\t\t\tbaseProfiles,\n\t\t\tmodels,\n\t\t\tinheritedToolNames: [...(this.options.getInheritedBaseProfile()?.toolNames ?? [])],\n\t\t};\n\t}\n\n\tcreateTaskProfile(input: TaskProfileCreateInput): TaskProfileCreateResult {\n\t\ttry {\n\t\t\tconst task = input.task.trim();\n\t\t\tif (!task || task.length > MAX_TASK_DESCRIPTION_LENGTH) {\n\t\t\t\treturn { created: false, reason: \"task_profile_description_invalid\" };\n\t\t\t}\n\t\t\tconst requestedBaseProfileId = input.baseProfileId?.trim();\n\t\t\tlet baseProfileId = INHERITED_BASE_PROFILE_ID;\n\t\t\tlet base: OrchestrationProfile | undefined;\n\t\t\tif (requestedBaseProfileId) {\n\t\t\t\tbaseProfileId = requestedBaseProfileId;\n\t\t\t\tbase = this.loadOwnerProfiles().get(baseProfileId);\n\t\t\t\tif (!base || base.role === \"orchestrator\") {\n\t\t\t\t\treturn { created: false, reason: \"task_profile_base_not_found\" };\n\t\t\t\t}\n\t\t\t\tif (!this.authorizedBaseProfiles().some((candidate) => candidate.profileId === baseProfileId)) {\n\t\t\t\t\treturn { created: false, reason: \"task_profile_base_not_authorized\" };\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbase = this.options.getInheritedBaseProfile();\n\t\t\t\tif (!base) return { created: false, reason: \"task_profile_inherited_base_unavailable\" };\n\t\t\t}\n\n\t\t\tconst compatibleBaseToolNames = base.toolNames.filter((toolName) => toolName !== \"delegate\");\n\t\t\tconst toolNames = input.toolNames ? [...input.toolNames] : compatibleBaseToolNames;\n\t\t\tif (!isExactSubset(toolNames, compatibleBaseToolNames)) {\n\t\t\t\treturn { created: false, reason: \"task_profile_tool_authority_expansion\" };\n\t\t\t}\n\t\t\tconst budget = structuredClone(base.budget);\n\n\t\t\tlet modelPolicy = structuredClone(base.modelPolicy);\n\t\t\tif (input.model || input.thinkingLevel) {\n\t\t\t\tconst baseBinding = base.modelPolicy.candidates[0];\n\t\t\t\tif (!baseBinding) return { created: false, reason: \"task_profile_model_unavailable\" };\n\t\t\t\tconst provider = input.model?.provider ?? baseBinding.provider;\n\t\t\t\tconst modelId = input.model?.modelId ?? baseBinding.modelId;\n\t\t\t\tconst model = this.options.getModelRegistry().find(provider, modelId);\n\t\t\t\tif (!model) return { created: false, reason: \"task_profile_model_unavailable\" };\n\t\t\t\tconst sameModel = provider === baseBinding.provider && modelId === baseBinding.modelId;\n\t\t\t\tconst binding: OrchestrationModelBinding = {\n\t\t\t\t\tprovider,\n\t\t\t\t\tmodelId,\n\t\t\t\t\tthinkingLevel:\n\t\t\t\t\t\tinput.thinkingLevel ??\n\t\t\t\t\t\t(sameModel ? baseBinding.thinkingLevel : resolveModelThinkingLevel(model, undefined)),\n\t\t\t\t};\n\t\t\t\tconst resolved = resolvePinnedOrchestrationModel(binding, this.options.getModelRegistry(), (candidate) =>\n\t\t\t\t\tthis.options.isModelExhausted(candidate.provider, candidate.id),\n\t\t\t\t);\n\t\t\t\tif (!resolved) return { created: false, reason: \"task_profile_model_unavailable\" };\n\t\t\t\tmodelPolicy = { mode: \"fixed\", candidates: [binding] };\n\t\t\t}\n\n\t\t\tlet workspacePath = base.workspacePath;\n\t\t\tif (input.path !== undefined) {\n\t\t\t\tconst trimmedPath = input.path.trim();\n\t\t\t\tif (!trimmedPath) return { created: false, reason: \"task_profile_path_invalid\" };\n\t\t\t\tconst requestedPath = resolveWorkerWorkspacePath(this.options.cwd, trimmedPath);\n\t\t\t\tif (base.workspacePath && !isPathWithinScope(requestedPath, base.workspacePath)) {\n\t\t\t\t\treturn { created: false, reason: \"task_profile_path_authority_expansion\" };\n\t\t\t\t}\n\t\t\t\tworkspacePath = requestedPath;\n\t\t\t}\n\n\t\t\tconst now = new Date().toISOString();\n\t\t\tconst profile = structuredClone(base);\n\t\t\tdelete profile.sourcePath;\n\t\t\tprofile.profileId = `task-${randomUUID()}`;\n\t\t\tprofile.description = `Task-scoped worker: ${task}`.slice(0, MAX_ORCHESTRATION_DESCRIPTION_LENGTH);\n\t\t\tprofile.modelPolicy = modelPolicy;\n\t\t\tprofile.capabilityCeiling = base.capabilityCeiling.filter(\n\t\t\t\t(capability) => capability !== \"workflow.delegate\" && capability !== \"memory.mutate\",\n\t\t\t);\n\t\t\tprofile.toolNames = toolNames;\n\t\t\tif (workspacePath) profile.workspacePath = workspacePath;\n\t\t\telse delete profile.workspacePath;\n\t\t\tprofile.resourceProfileNames = [...base.resourceProfileNames];\n\t\t\tprofile.dispatchProfileIds = [];\n\t\t\tprofile.delegationLimits = structuredClone(LEAF_WORKER_DELEGATION_LIMITS);\n\t\t\tprofile.budget = budget;\n\t\t\tprofile.createdAt = now;\n\t\t\tprofile.updatedAt = now;\n\t\t\tvalidateOrchestrationProfile(profile);\n\n\t\t\tconst activeProfile = this.options.getActiveOrchestrationProfile();\n\t\t\tthis.options.store.append({\n\t\t\t\tbaseProfileId,\n\t\t\t\t...(activeProfile ? { authorProfileId: activeProfile.profileId } : {}),\n\t\t\t\tprofile,\n\t\t\t});\n\t\t\tconst changedFields = [\"description\"];\n\t\t\tif ((input.model || input.thinkingLevel) && !sameModelPolicy(modelPolicy, base.modelPolicy)) {\n\t\t\t\tchangedFields.push(input.model ? \"model\" : \"thinking\");\n\t\t\t}\n\t\t\tif (workspacePath !== base.workspacePath) changedFields.push(\"path\");\n\t\t\tif (!sameStrings(toolNames, base.toolNames)) changedFields.push(\"tools\");\n\t\t\treturn { created: true, profileId: profile.profileId, baseProfileId, changedFields };\n\t\t} catch (error) {\n\t\t\treturn { created: false, reason: error instanceof Error ? error.message : String(error) };\n\t\t}\n\t}\n\n\tprivate authorizedBaseProfiles(): OrchestrationProfile[] {\n\t\tconst active = this.options.getActiveOrchestrationProfile();\n\t\tif (active && active.role !== \"orchestrator\") return [];\n\t\tconst allowed = active ? new Set(active.dispatchProfileIds) : undefined;\n\t\treturn [...this.loadOwnerProfiles().values()].filter(\n\t\t\t(profile) => profile.role !== \"orchestrator\" && (!allowed || allowed.has(profile.profileId)),\n\t\t);\n\t}\n\n\tprivate loadOwnerProfiles(): ReadonlyMap<string, OrchestrationProfile> {\n\t\tconst profiles = new OrchestrationProfileStore({\n\t\t\tagentDir: this.options.agentDir,\n\t\t\tcwd: this.options.cwd,\n\t\t\tprojectTrusted: this.options.getSettingsManager().isProjectTrusted(),\n\t\t}).load().profiles;\n\t\treturn new Map(profiles.map((profile) => [profile.profileId, profile]));\n\t}\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import { Type } from "typebox";
2
+ /** Shared provider-facing thinking-level vocabulary for schemas at the orchestration boundary. */
3
+ export declare function orchestrationThinkingLevelSchema(description?: string): Type.TUnion<[Type.TLiteral<"off">, Type.TLiteral<"minimal">, Type.TLiteral<"low">, Type.TLiteral<"medium">, Type.TLiteral<"high">, Type.TLiteral<"xhigh">, Type.TLiteral<"max">, Type.TLiteral<"ultra">]>;
4
+ export declare const ORCHESTRATION_THINKING_LEVEL_SCHEMA: Type.TUnion<[Type.TLiteral<"off">, Type.TLiteral<"minimal">, Type.TLiteral<"low">, Type.TLiteral<"medium">, Type.TLiteral<"high">, Type.TLiteral<"xhigh">, Type.TLiteral<"max">, Type.TLiteral<"ultra">]>;
5
+ /** Model defaults intentionally exclude `off`; absence represents the provider/model default. */
6
+ export declare const MODEL_DEFAULT_THINKING_LEVEL_SCHEMA: Type.TUnion<[Type.TLiteral<"minimal">, Type.TLiteral<"low">, Type.TLiteral<"medium">, Type.TLiteral<"high">, Type.TLiteral<"xhigh">, Type.TLiteral<"max">, Type.TLiteral<"ultra">]>;
7
+ //# sourceMappingURL=thinking-level-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thinking-level-schema.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/thinking-level-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,kGAAkG;AAClG,wBAAgB,gCAAgC,CAAC,WAAW,CAAC,EAAE,MAAM,6MAcpE;AAED,eAAO,MAAM,mCAAmC,2MAAqC,CAAC;AAEtF,iGAAiG;AACjG,eAAO,MAAM,mCAAmC,qLAG/C,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { Type } from "typebox";
2
+ import { ORCHESTRATION_THINKING_LEVELS } from "./contracts.js";
3
+ /** Shared provider-facing thinking-level vocabulary for schemas at the orchestration boundary. */
4
+ export function orchestrationThinkingLevelSchema(description) {
5
+ return Type.Union([
6
+ Type.Literal(ORCHESTRATION_THINKING_LEVELS[0]),
7
+ Type.Literal(ORCHESTRATION_THINKING_LEVELS[1]),
8
+ Type.Literal(ORCHESTRATION_THINKING_LEVELS[2]),
9
+ Type.Literal(ORCHESTRATION_THINKING_LEVELS[3]),
10
+ Type.Literal(ORCHESTRATION_THINKING_LEVELS[4]),
11
+ Type.Literal(ORCHESTRATION_THINKING_LEVELS[5]),
12
+ Type.Literal(ORCHESTRATION_THINKING_LEVELS[6]),
13
+ Type.Literal(ORCHESTRATION_THINKING_LEVELS[7]),
14
+ ], description === undefined ? {} : { description });
15
+ }
16
+ export const ORCHESTRATION_THINKING_LEVEL_SCHEMA = orchestrationThinkingLevelSchema();
17
+ /** Model defaults intentionally exclude `off`; absence represents the provider/model default. */
18
+ export const MODEL_DEFAULT_THINKING_LEVEL_SCHEMA = Type.Exclude(ORCHESTRATION_THINKING_LEVEL_SCHEMA, Type.Literal("off"));
19
+ //# sourceMappingURL=thinking-level-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thinking-level-schema.js","sourceRoot":"","sources":["../../../src/core/orchestration/thinking-level-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAE/D,kGAAkG;AAClG,MAAM,UAAU,gCAAgC,CAAC,WAAoB;IACpE,OAAO,IAAI,CAAC,KAAK,CAChB;QACC,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,CAAC,CAAC;QAC9C,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,CAAC,CAAC;QAC9C,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,CAAC,CAAC;QAC9C,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,CAAC,CAAC;QAC9C,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,CAAC,CAAC;QAC9C,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,CAAC,CAAC;QAC9C,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,CAAC,CAAC;QAC9C,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,CAAC,CAAC;KAC9C,EACD,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAChD,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,mCAAmC,GAAG,gCAAgC,EAAE,CAAC;AAEtF,iGAAiG;AACjG,MAAM,CAAC,MAAM,mCAAmC,GAAG,IAAI,CAAC,OAAO,CAC9D,mCAAmC,EACnC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CACnB,CAAC","sourcesContent":["import { Type } from \"typebox\";\nimport { ORCHESTRATION_THINKING_LEVELS } from \"./contracts.ts\";\n\n/** Shared provider-facing thinking-level vocabulary for schemas at the orchestration boundary. */\nexport function orchestrationThinkingLevelSchema(description?: string) {\n\treturn Type.Union(\n\t\t[\n\t\t\tType.Literal(ORCHESTRATION_THINKING_LEVELS[0]),\n\t\t\tType.Literal(ORCHESTRATION_THINKING_LEVELS[1]),\n\t\t\tType.Literal(ORCHESTRATION_THINKING_LEVELS[2]),\n\t\t\tType.Literal(ORCHESTRATION_THINKING_LEVELS[3]),\n\t\t\tType.Literal(ORCHESTRATION_THINKING_LEVELS[4]),\n\t\t\tType.Literal(ORCHESTRATION_THINKING_LEVELS[5]),\n\t\t\tType.Literal(ORCHESTRATION_THINKING_LEVELS[6]),\n\t\t\tType.Literal(ORCHESTRATION_THINKING_LEVELS[7]),\n\t\t],\n\t\tdescription === undefined ? {} : { description },\n\t);\n}\n\nexport const ORCHESTRATION_THINKING_LEVEL_SCHEMA = orchestrationThinkingLevelSchema();\n\n/** Model defaults intentionally exclude `off`; absence represents the provider/model default. */\nexport const MODEL_DEFAULT_THINKING_LEVEL_SCHEMA = Type.Exclude(\n\tORCHESTRATION_THINKING_LEVEL_SCHEMA,\n\tType.Literal(\"off\"),\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"worker-execution-contract.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/worker-execution-contract.ts"],"names":[],"mappings":"AAIA,OAAO,EAaN,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,eAAe,EAEpB,KAAK,gCAAgC,EACrC,KAAK,uBAAuB,EAE5B,MAAM,gBAAgB,CAAC;AAIxB,qBAAa,4BAA6B,SAAQ,KAAK;IACtD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACD;AAyMD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,uBAAuB,CA2BpF;AAwBD,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IACnD,MAAM,EAAE;QACP,OAAO,EAAE,oBAAoB,CAAC;QAC9B,YAAY,EAAE,yBAAyB,CAAC;QACxC,SAAS,EAAE,gCAAgC,CAAC;QAC5C,gBAAgB,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;QAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF,QAAQ,CAAC,EAAE;QACV,OAAO,EAAE,oBAAoB,CAAC;QAC9B,YAAY,EAAE,yBAAyB,CAAC;QACxC,SAAS,EAAE,gCAAgC,CAAC;QAC5C,gBAAgB,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;QAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACF,GAAG,uBAAuB,CAM1B;AAED,wBAAgB,+BAA+B,CAC9C,QAAQ,EAAE,uBAAuB,GAC/B,uBAAuB,GAAG,SAAS,CAIrC"}
1
+ {"version":3,"file":"worker-execution-contract.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/worker-execution-contract.ts"],"names":[],"mappings":"AAIA,OAAO,EAaN,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,eAAe,EAEpB,KAAK,gCAAgC,EACrC,KAAK,uBAAuB,EAE5B,MAAM,gBAAgB,CAAC;AAIxB,qBAAa,4BAA6B,SAAQ,KAAK;IACtD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACD;AA6MD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,uBAAuB,CA2BpF;AAwBD,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IACnD,MAAM,EAAE;QACP,OAAO,EAAE,oBAAoB,CAAC;QAC9B,YAAY,EAAE,yBAAyB,CAAC;QACxC,SAAS,EAAE,gCAAgC,CAAC;QAC5C,gBAAgB,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;QAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF,QAAQ,CAAC,EAAE;QACV,OAAO,EAAE,oBAAoB,CAAC;QAC9B,YAAY,EAAE,yBAAyB,CAAC;QACxC,SAAS,EAAE,gCAAgC,CAAC;QAC5C,gBAAgB,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;QAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACF,GAAG,uBAAuB,CAM1B;AAED,wBAAgB,+BAA+B,CAC9C,QAAQ,EAAE,uBAAuB,GAC/B,uBAAuB,GAAG,SAAS,CAIrC"}
@@ -85,20 +85,26 @@ function parseResourcePointers(value, label) {
85
85
  }
86
86
  function parseAuthority(value, profile, label) {
87
87
  if (!isPlainRecord(value) ||
88
- !hasOnlyKeys(value, ["capabilities", "toolNames", "readPaths", "writePaths", "deniedPaths", "budget"])) {
88
+ !hasOnlyKeys(value, ["cwd", "capabilities", "toolNames", "readPaths", "writePaths", "deniedPaths", "budget"])) {
89
89
  throw new WorkerExecutionContractError(`${label} authority is invalid.`);
90
90
  }
91
+ const cwd = value.cwd;
92
+ if (cwd !== undefined &&
93
+ (typeof cwd !== "string" ||
94
+ !cwd.trim() ||
95
+ cwd.length > MAX_WORKER_AUTHORITY_PATH_LENGTH ||
96
+ (!path.isAbsolute(cwd) && !path.win32.isAbsolute(cwd)))) {
97
+ throw new WorkerExecutionContractError(`${label} authority cwd must be an absolute path.`);
98
+ }
91
99
  const capabilities = stringArray(value.capabilities, `${label} authority capabilities`);
92
100
  if (!capabilities.every(isHarnessCapability)) {
93
101
  throw new WorkerExecutionContractError(`${label} authority contains an unknown capability.`);
94
102
  }
95
- if (capabilities.some((capability) => capability !== "workflow.delegate" &&
96
- capability !== "memory.query" &&
97
- !profile.capabilityCeiling.includes(capability))) {
103
+ if (capabilities.some((capability) => capability !== "workflow.delegate" && !profile.capabilityCeiling.includes(capability))) {
98
104
  throw new WorkerExecutionContractError(`${label} authority exceeds its profile capability ceiling.`);
99
105
  }
100
106
  const toolNames = stringArray(value.toolNames, `${label} authority toolNames`);
101
- if (toolNames.some((toolName) => toolName !== "delegate" && toolName !== "memory" && !profile.toolNames.includes(toolName))) {
107
+ if (toolNames.some((toolName) => toolName !== "delegate" && !profile.toolNames.includes(toolName))) {
102
108
  throw new WorkerExecutionContractError(`${label} authority contains a tool outside its profile.`);
103
109
  }
104
110
  const pathArrayOptions = {
@@ -130,6 +136,7 @@ function parseAuthority(value, profile, label) {
130
136
  throw new WorkerExecutionContractError(`${label} write authority lacks a positive path scope.`);
131
137
  }
132
138
  return {
139
+ ...(typeof cwd === "string" ? { cwd } : {}),
133
140
  capabilities: capabilities,
134
141
  toolNames,
135
142
  readPaths,
@@ -1 +1 @@
1
- {"version":3,"file":"worker-execution-contract.js","sourceRoot":"","sources":["../../../src/core/orchestration/worker-execution-contract.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACN,mBAAmB,EACnB,qBAAqB,EACrB,iCAAiC,EACjC,uCAAuC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EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAC1G,CAAC,CAAC,SAAS,CAAC;AACd,CAAC","sourcesContent":["import path from \"node:path\";\nimport { isDeepStrictEqual } from \"node:util\";\nimport { hasOnlyKeys, isPlainRecord } from \"../util/value-guards.ts\";\nimport { parseBoundedStringArray } from \"./bounded-string-array.ts\";\nimport {\n\tisHarnessCapability,\n\tisResourcePointerKind,\n\tMAX_ORCHESTRATION_MODEL_ID_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\tMAX_WORKER_AUTHORITY_PATH_LENGTH,\n\tMAX_WORKER_AUTHORITY_PATHS,\n\tMAX_WORKER_RESOURCE_METADATA_NAME_LENGTH,\n\tMAX_WORKER_RESOURCE_PATH_LENGTH,\n\tMAX_WORKER_RESOURCE_POINTERS,\n\tMAX_WORKER_SOUL_LENGTH,\n\tORCHESTRATION_SCHEMA_VERSION,\n\tORCHESTRATION_THINKING_LEVELS,\n\ttype OrchestrationModelBinding,\n\ttype OrchestrationProfile,\n\ttype ResourcePointer,\n\ttype RiskBudget,\n\ttype WorkerExecutionAuthorityContract,\n\ttype WorkerExecutionContract,\n\ttype WorkerProfileExecutionContract,\n} from \"./contracts.ts\";\nimport { OrchestrationProfileError, parseOrchestrationProfile } from \"./profile-registry.ts\";\nimport { intersectRiskBudgets, parseRiskBudget } from \"./risk-budget.ts\";\n\nexport class WorkerExecutionContractError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"WorkerExecutionContractError\";\n\t}\n}\n\nfunction parseModelBinding(value: unknown, label: string): OrchestrationModelBinding {\n\tif (\n\t\t!isPlainRecord(value) ||\n\t\t!hasOnlyKeys(value, [\"provider\", \"modelId\", \"thinkingLevel\"]) ||\n\t\ttypeof value.provider !== \"string\" ||\n\t\tvalue.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t!value.provider.trim() ||\n\t\ttypeof value.modelId !== \"string\" ||\n\t\tvalue.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH ||\n\t\t!value.modelId.trim() ||\n\t\ttypeof value.thinkingLevel !== \"string\" ||\n\t\t!ORCHESTRATION_THINKING_LEVELS.includes(value.thinkingLevel as (typeof ORCHESTRATION_THINKING_LEVELS)[number])\n\t) {\n\t\tthrow new WorkerExecutionContractError(`${label} model binding is invalid.`);\n\t}\n\treturn {\n\t\tprovider: value.provider,\n\t\tmodelId: value.modelId,\n\t\tthinkingLevel: value.thinkingLevel as (typeof ORCHESTRATION_THINKING_LEVELS)[number],\n\t};\n}\n\nfunction stringArray(\n\tvalue: unknown,\n\tlabel: string,\n\toptions: { maxEntries?: number; maxLength?: number } = {},\n): string[] {\n\treturn parseBoundedStringArray(value, {\n\t\t...options,\n\t\tinvalidMessage: `${label} must be an array of non-empty strings.`,\n\t\tduplicateMessage: `${label} contains duplicates.`,\n\t\tcreateError: (message) => new WorkerExecutionContractError(message),\n\t});\n}\n\nfunction parseResourcePointers(value: unknown, label: string): ResourcePointer[] {\n\tif (!Array.isArray(value) || value.length > MAX_WORKER_RESOURCE_POINTERS) {\n\t\tthrow new WorkerExecutionContractError(`${label} resource pointers are invalid.`);\n\t}\n\tconst ids = new Set<string>();\n\treturn value.map((candidate) => {\n\t\tif (\n\t\t\t!isPlainRecord(candidate) ||\n\t\t\t!hasOnlyKeys(candidate, [\"id\", \"kind\", \"uri\", \"readOnly\", \"digest\", \"metadata\"]) ||\n\t\t\ttypeof candidate.id !== \"string\" ||\n\t\t\t!/^(skill|prompt):[a-f0-9]{64}$/i.test(candidate.id) ||\n\t\t\ttypeof candidate.kind !== \"string\" ||\n\t\t\t!isResourcePointerKind(candidate.kind) ||\n\t\t\t(candidate.kind !== \"skill\" && candidate.kind !== \"prompt\") ||\n\t\t\t!candidate.id.startsWith(`${candidate.kind}:`) ||\n\t\t\ttypeof candidate.uri !== \"string\" ||\n\t\t\tcandidate.uri.length === 0 ||\n\t\t\tcandidate.uri.length > MAX_WORKER_RESOURCE_PATH_LENGTH + 16 ||\n\t\t\t!candidate.uri.startsWith(\"file:\") ||\n\t\t\tcandidate.readOnly !== true ||\n\t\t\t(candidate.digest !== undefined &&\n\t\t\t\t(typeof candidate.digest !== \"string\" || !/^[a-f0-9]{64}$/i.test(candidate.digest))) ||\n\t\t\t(candidate.metadata !== undefined &&\n\t\t\t\t(!isPlainRecord(candidate.metadata) ||\n\t\t\t\t\ttypeof candidate.metadata.name !== \"string\" ||\n\t\t\t\t\tcandidate.metadata.name.length === 0 ||\n\t\t\t\t\tcandidate.metadata.name.length > MAX_WORKER_RESOURCE_METADATA_NAME_LENGTH ||\n\t\t\t\t\t!hasOnlyKeys(candidate.metadata, [\"name\"])))\n\t\t) {\n\t\t\tthrow new WorkerExecutionContractError(`${label} resource pointer is invalid.`);\n\t\t}\n\t\tif (ids.has(candidate.id)) {\n\t\t\tthrow new WorkerExecutionContractError(`${label} resource pointers contain duplicates.`);\n\t\t}\n\t\tids.add(candidate.id);\n\t\treturn {\n\t\t\tid: candidate.id,\n\t\t\tkind: candidate.kind,\n\t\t\turi: candidate.uri,\n\t\t\treadOnly: true,\n\t\t\t...(typeof candidate.digest === \"string\" ? { digest: candidate.digest } : {}),\n\t\t\t...(isPlainRecord(candidate.metadata) && typeof candidate.metadata.name === \"string\"\n\t\t\t\t? { metadata: { name: candidate.metadata.name } }\n\t\t\t\t: {}),\n\t\t};\n\t});\n}\n\nfunction parseAuthority(\n\tvalue: unknown,\n\tprofile: OrchestrationProfile,\n\tlabel: string,\n): WorkerExecutionAuthorityContract {\n\tif (\n\t\t!isPlainRecord(value) ||\n\t\t!hasOnlyKeys(value, [\"capabilities\", \"toolNames\", \"readPaths\", \"writePaths\", \"deniedPaths\", \"budget\"])\n\t) {\n\t\tthrow new WorkerExecutionContractError(`${label} authority is invalid.`);\n\t}\n\tconst capabilities = stringArray(value.capabilities, `${label} authority capabilities`);\n\tif (!capabilities.every(isHarnessCapability)) {\n\t\tthrow new WorkerExecutionContractError(`${label} authority contains an unknown capability.`);\n\t}\n\tif (\n\t\tcapabilities.some(\n\t\t\t(capability) =>\n\t\t\t\tcapability !== \"workflow.delegate\" &&\n\t\t\t\tcapability !== \"memory.query\" &&\n\t\t\t\t!profile.capabilityCeiling.includes(capability),\n\t\t)\n\t) {\n\t\tthrow new WorkerExecutionContractError(`${label} authority exceeds its profile capability ceiling.`);\n\t}\n\tconst toolNames = stringArray(value.toolNames, `${label} authority toolNames`);\n\tif (\n\t\ttoolNames.some(\n\t\t\t(toolName) => toolName !== \"delegate\" && toolName !== \"memory\" && !profile.toolNames.includes(toolName),\n\t\t)\n\t) {\n\t\tthrow new WorkerExecutionContractError(`${label} authority contains a tool outside its profile.`);\n\t}\n\tconst pathArrayOptions = {\n\t\tmaxEntries: MAX_WORKER_AUTHORITY_PATHS,\n\t\tmaxLength: MAX_WORKER_AUTHORITY_PATH_LENGTH,\n\t};\n\tconst readPaths = stringArray(value.readPaths, `${label} authority readPaths`, pathArrayOptions);\n\tconst writePaths = stringArray(value.writePaths, `${label} authority writePaths`, pathArrayOptions);\n\tconst deniedPaths = stringArray(value.deniedPaths, `${label} authority deniedPaths`, pathArrayOptions);\n\tif (\n\t\t[...readPaths, ...writePaths, ...deniedPaths].some(\n\t\t\t(entry) => !path.isAbsolute(entry) && !path.win32.isAbsolute(entry),\n\t\t)\n\t) {\n\t\tthrow new WorkerExecutionContractError(`${label} authority paths must be absolute.`);\n\t}\n\tlet budget: RiskBudget;\n\ttry {\n\t\tbudget = parseRiskBudget(value.budget, `${label} authority budget`);\n\t} catch (error) {\n\t\tthrow new WorkerExecutionContractError(error instanceof Error ? error.message : String(error));\n\t}\n\tif (!isDeepStrictEqual(intersectRiskBudgets(profile.budget, budget), budget)) {\n\t\tthrow new WorkerExecutionContractError(`${label} authority exceeds its profile budget.`);\n\t}\n\tconst readGranted = capabilities.some(\n\t\t(capability) => capability === \"filesystem.read\" || capability === \"worktree.read\",\n\t);\n\tconst writeGranted = capabilities.some(\n\t\t(capability) => capability === \"filesystem.write\" || capability === \"worktree.mutate\",\n\t);\n\tif (readGranted && readPaths.length === 0) {\n\t\tthrow new WorkerExecutionContractError(`${label} read authority lacks a positive path scope.`);\n\t}\n\tif (writeGranted && writePaths.length === 0) {\n\t\tthrow new WorkerExecutionContractError(`${label} write authority lacks a positive path scope.`);\n\t}\n\treturn {\n\t\tcapabilities: capabilities as WorkerExecutionAuthorityContract[\"capabilities\"],\n\t\ttoolNames,\n\t\treadPaths,\n\t\twritePaths,\n\t\tdeniedPaths,\n\t\tbudget,\n\t};\n}\n\nfunction parseProfileContract(value: unknown, label: string): WorkerProfileExecutionContract {\n\tif (\n\t\t!isPlainRecord(value) ||\n\t\t!hasOnlyKeys(value, [\"schemaVersion\", \"profile\", \"modelBinding\", \"authority\", \"resourcePointers\", \"soul\"]) ||\n\t\tvalue.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION\n\t) {\n\t\tthrow new WorkerExecutionContractError(`${label} is invalid.`);\n\t}\n\tlet profile: OrchestrationProfile;\n\ttry {\n\t\tprofile = parseOrchestrationProfile(value.profile);\n\t} catch (error) {\n\t\tthrow new WorkerExecutionContractError(\n\t\t\terror instanceof OrchestrationProfileError ? error.message : `${label} profile is invalid.`,\n\t\t);\n\t}\n\tconst modelBinding = parseModelBinding(value.modelBinding, label);\n\tif (!profile.modelPolicy.candidates.some((candidate) => isDeepStrictEqual(candidate, modelBinding))) {\n\t\tthrow new WorkerExecutionContractError(`${label} model binding is not declared by its profile.`);\n\t}\n\tif (\n\t\tvalue.soul !== undefined &&\n\t\t(typeof value.soul !== \"string\" || value.soul.length > MAX_WORKER_SOUL_LENGTH || !value.soul.trim())\n\t) {\n\t\tthrow new WorkerExecutionContractError(`${label} soul is invalid.`);\n\t}\n\tconst authority = parseAuthority(value.authority, profile, label);\n\tconst resourcePointers = parseResourcePointers(value.resourcePointers ?? [], label);\n\treturn {\n\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\tprofile,\n\t\tmodelBinding,\n\t\tauthority,\n\t\tresourcePointers,\n\t\t...(typeof value.soul === \"string\" ? { soul: value.soul } : {}),\n\t};\n}\n\nexport function parseWorkerExecutionContract(value: unknown): WorkerExecutionContract {\n\tif (\n\t\t!isPlainRecord(value) ||\n\t\t!hasOnlyKeys(value, [\"schemaVersion\", \"worker\", \"verifier\"]) ||\n\t\tvalue.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION\n\t) {\n\t\tthrow new WorkerExecutionContractError(\"Worker execution contract is invalid.\");\n\t}\n\tconst worker = parseProfileContract(value.worker, \"Worker execution contract\");\n\tconst verifier = value.verifier\n\t\t? parseProfileContract(value.verifier, \"Worker verifier execution contract\")\n\t\t: undefined;\n\tif (worker.profile.requireIndependentVerification) {\n\t\tif (!verifier || worker.profile.verificationProfileId !== verifier.profile.profileId) {\n\t\t\tthrow new WorkerExecutionContractError(\"Worker execution contract is missing its owner-pinned verifier.\");\n\t\t}\n\t\tif (verifier.profile.role !== \"verifier\") {\n\t\t\tthrow new WorkerExecutionContractError(\"Worker verifier execution contract does not use a verifier profile.\");\n\t\t}\n\t} else if (verifier) {\n\t\tthrow new WorkerExecutionContractError(\"Worker execution contract has an unexpected verifier.\");\n\t}\n\treturn {\n\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\tworker,\n\t\t...(verifier ? { verifier } : {}),\n\t};\n}\n\nfunction snapshotProfile(profile: OrchestrationProfile): OrchestrationProfile {\n\tconst { sourcePath: _sourcePath, ...persisted } = profile;\n\treturn structuredClone(persisted) as OrchestrationProfile;\n}\n\nfunction snapshotResolvedProfile(source: {\n\tprofile: OrchestrationProfile;\n\tmodelBinding: OrchestrationModelBinding;\n\tauthority: WorkerExecutionAuthorityContract;\n\tresourcePointers?: readonly ResourcePointer[];\n\tsoul?: string;\n}): WorkerProfileExecutionContract {\n\treturn {\n\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\tprofile: snapshotProfile(source.profile),\n\t\tmodelBinding: structuredClone(source.modelBinding),\n\t\tauthority: structuredClone(source.authority),\n\t\tresourcePointers: structuredClone(source.resourcePointers ?? []),\n\t\t...(source.soul ? { soul: source.soul } : {}),\n\t};\n}\n\nexport function createWorkerExecutionContract(args: {\n\tworker: {\n\t\tprofile: OrchestrationProfile;\n\t\tmodelBinding: OrchestrationModelBinding;\n\t\tauthority: WorkerExecutionAuthorityContract;\n\t\tresourcePointers?: readonly ResourcePointer[];\n\t\tsoul?: string;\n\t};\n\tverifier?: {\n\t\tprofile: OrchestrationProfile;\n\t\tmodelBinding: OrchestrationModelBinding;\n\t\tauthority: WorkerExecutionAuthorityContract;\n\t\tresourcePointers?: readonly ResourcePointer[];\n\t\tsoul?: string;\n\t};\n}): WorkerExecutionContract {\n\treturn parseWorkerExecutionContract({\n\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\tworker: snapshotResolvedProfile(args.worker),\n\t\t...(args.verifier ? { verifier: snapshotResolvedProfile(args.verifier) } : {}),\n\t});\n}\n\nexport function verifierWorkerExecutionContract(\n\tcontract: WorkerExecutionContract,\n): WorkerExecutionContract | undefined {\n\treturn contract.verifier\n\t\t? parseWorkerExecutionContract({ schemaVersion: ORCHESTRATION_SCHEMA_VERSION, worker: contract.verifier })\n\t\t: undefined;\n}\n"]}
1
+ {"version":3,"file":"worker-execution-contract.js","sourceRoot":"","sources":["../../../src/core/orchestration/worker-execution-contract.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACN,mBAAmB,EACnB,qBAAqB,EACrB,iCAAiC,EACjC,uCAAuC,EACvC,gCAAgC,EAChC,0BAA0B,EAC1B,wCAAwC,EACxC,+BAA+B,EAC/B,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C;QACnC,aAAa,EAAE,4BAA4B;QAC3C,MAAM,EAAE,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC;QAC5C,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,uBAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9E,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC9C,QAAiC;IAEjC,OAAO,QAAQ,CAAC,QAAQ;QACvB,CAAC,CAAC,4BAA4B,CAAC,EAAE,aAAa,EAAE,4BAA4B,EAAE,MAAM,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAC1G,CAAC,CAAC,SAAS,CAAC;AACd,CAAC","sourcesContent":["import path from \"node:path\";\nimport { isDeepStrictEqual } from \"node:util\";\nimport { hasOnlyKeys, isPlainRecord } from \"../util/value-guards.ts\";\nimport { parseBoundedStringArray } from \"./bounded-string-array.ts\";\nimport {\n\tisHarnessCapability,\n\tisResourcePointerKind,\n\tMAX_ORCHESTRATION_MODEL_ID_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\tMAX_WORKER_AUTHORITY_PATH_LENGTH,\n\tMAX_WORKER_AUTHORITY_PATHS,\n\tMAX_WORKER_RESOURCE_METADATA_NAME_LENGTH,\n\tMAX_WORKER_RESOURCE_PATH_LENGTH,\n\tMAX_WORKER_RESOURCE_POINTERS,\n\tMAX_WORKER_SOUL_LENGTH,\n\tORCHESTRATION_SCHEMA_VERSION,\n\tORCHESTRATION_THINKING_LEVELS,\n\ttype OrchestrationModelBinding,\n\ttype OrchestrationProfile,\n\ttype ResourcePointer,\n\ttype RiskBudget,\n\ttype WorkerExecutionAuthorityContract,\n\ttype WorkerExecutionContract,\n\ttype WorkerProfileExecutionContract,\n} from \"./contracts.ts\";\nimport { OrchestrationProfileError, parseOrchestrationProfile } from \"./profile-registry.ts\";\nimport { intersectRiskBudgets, parseRiskBudget } from \"./risk-budget.ts\";\n\nexport class WorkerExecutionContractError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"WorkerExecutionContractError\";\n\t}\n}\n\nfunction parseModelBinding(value: unknown, label: string): OrchestrationModelBinding {\n\tif (\n\t\t!isPlainRecord(value) ||\n\t\t!hasOnlyKeys(value, [\"provider\", \"modelId\", \"thinkingLevel\"]) ||\n\t\ttypeof value.provider !== \"string\" ||\n\t\tvalue.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t!value.provider.trim() ||\n\t\ttypeof value.modelId !== \"string\" ||\n\t\tvalue.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH ||\n\t\t!value.modelId.trim() ||\n\t\ttypeof value.thinkingLevel !== \"string\" ||\n\t\t!ORCHESTRATION_THINKING_LEVELS.includes(value.thinkingLevel as (typeof ORCHESTRATION_THINKING_LEVELS)[number])\n\t) {\n\t\tthrow new WorkerExecutionContractError(`${label} model binding is invalid.`);\n\t}\n\treturn {\n\t\tprovider: value.provider,\n\t\tmodelId: value.modelId,\n\t\tthinkingLevel: value.thinkingLevel as (typeof ORCHESTRATION_THINKING_LEVELS)[number],\n\t};\n}\n\nfunction stringArray(\n\tvalue: unknown,\n\tlabel: string,\n\toptions: { maxEntries?: number; maxLength?: number } = {},\n): string[] {\n\treturn parseBoundedStringArray(value, {\n\t\t...options,\n\t\tinvalidMessage: `${label} must be an array of non-empty strings.`,\n\t\tduplicateMessage: `${label} contains duplicates.`,\n\t\tcreateError: (message) => new WorkerExecutionContractError(message),\n\t});\n}\n\nfunction parseResourcePointers(value: unknown, label: string): ResourcePointer[] {\n\tif (!Array.isArray(value) || value.length > MAX_WORKER_RESOURCE_POINTERS) {\n\t\tthrow new WorkerExecutionContractError(`${label} resource pointers are invalid.`);\n\t}\n\tconst ids = new Set<string>();\n\treturn value.map((candidate) => {\n\t\tif (\n\t\t\t!isPlainRecord(candidate) ||\n\t\t\t!hasOnlyKeys(candidate, [\"id\", \"kind\", \"uri\", \"readOnly\", \"digest\", \"metadata\"]) ||\n\t\t\ttypeof candidate.id !== \"string\" ||\n\t\t\t!/^(skill|prompt):[a-f0-9]{64}$/i.test(candidate.id) ||\n\t\t\ttypeof candidate.kind !== \"string\" ||\n\t\t\t!isResourcePointerKind(candidate.kind) ||\n\t\t\t(candidate.kind !== \"skill\" && candidate.kind !== \"prompt\") ||\n\t\t\t!candidate.id.startsWith(`${candidate.kind}:`) ||\n\t\t\ttypeof candidate.uri !== \"string\" ||\n\t\t\tcandidate.uri.length === 0 ||\n\t\t\tcandidate.uri.length > MAX_WORKER_RESOURCE_PATH_LENGTH + 16 ||\n\t\t\t!candidate.uri.startsWith(\"file:\") ||\n\t\t\tcandidate.readOnly !== true ||\n\t\t\t(candidate.digest !== undefined &&\n\t\t\t\t(typeof candidate.digest !== \"string\" || !/^[a-f0-9]{64}$/i.test(candidate.digest))) ||\n\t\t\t(candidate.metadata !== undefined &&\n\t\t\t\t(!isPlainRecord(candidate.metadata) ||\n\t\t\t\t\ttypeof candidate.metadata.name !== \"string\" ||\n\t\t\t\t\tcandidate.metadata.name.length === 0 ||\n\t\t\t\t\tcandidate.metadata.name.length > MAX_WORKER_RESOURCE_METADATA_NAME_LENGTH ||\n\t\t\t\t\t!hasOnlyKeys(candidate.metadata, [\"name\"])))\n\t\t) {\n\t\t\tthrow new WorkerExecutionContractError(`${label} resource pointer is invalid.`);\n\t\t}\n\t\tif (ids.has(candidate.id)) {\n\t\t\tthrow new WorkerExecutionContractError(`${label} resource pointers contain duplicates.`);\n\t\t}\n\t\tids.add(candidate.id);\n\t\treturn {\n\t\t\tid: candidate.id,\n\t\t\tkind: candidate.kind,\n\t\t\turi: candidate.uri,\n\t\t\treadOnly: true,\n\t\t\t...(typeof candidate.digest === \"string\" ? { digest: candidate.digest } : {}),\n\t\t\t...(isPlainRecord(candidate.metadata) && typeof candidate.metadata.name === \"string\"\n\t\t\t\t? { metadata: { name: candidate.metadata.name } }\n\t\t\t\t: {}),\n\t\t};\n\t});\n}\n\nfunction parseAuthority(\n\tvalue: unknown,\n\tprofile: OrchestrationProfile,\n\tlabel: string,\n): WorkerExecutionAuthorityContract {\n\tif (\n\t\t!isPlainRecord(value) ||\n\t\t!hasOnlyKeys(value, [\"cwd\", \"capabilities\", \"toolNames\", \"readPaths\", \"writePaths\", \"deniedPaths\", \"budget\"])\n\t) {\n\t\tthrow new WorkerExecutionContractError(`${label} authority is invalid.`);\n\t}\n\tconst cwd = value.cwd;\n\tif (\n\t\tcwd !== undefined &&\n\t\t(typeof cwd !== \"string\" ||\n\t\t\t!cwd.trim() ||\n\t\t\tcwd.length > MAX_WORKER_AUTHORITY_PATH_LENGTH ||\n\t\t\t(!path.isAbsolute(cwd) && !path.win32.isAbsolute(cwd)))\n\t) {\n\t\tthrow new WorkerExecutionContractError(`${label} authority cwd must be an absolute path.`);\n\t}\n\tconst capabilities = stringArray(value.capabilities, `${label} authority capabilities`);\n\tif (!capabilities.every(isHarnessCapability)) {\n\t\tthrow new WorkerExecutionContractError(`${label} authority contains an unknown capability.`);\n\t}\n\tif (\n\t\tcapabilities.some(\n\t\t\t(capability) => capability !== \"workflow.delegate\" && !profile.capabilityCeiling.includes(capability),\n\t\t)\n\t) {\n\t\tthrow new WorkerExecutionContractError(`${label} authority exceeds its profile capability ceiling.`);\n\t}\n\tconst toolNames = stringArray(value.toolNames, `${label} authority toolNames`);\n\tif (toolNames.some((toolName) => toolName !== \"delegate\" && !profile.toolNames.includes(toolName))) {\n\t\tthrow new WorkerExecutionContractError(`${label} authority contains a tool outside its profile.`);\n\t}\n\tconst pathArrayOptions = {\n\t\tmaxEntries: MAX_WORKER_AUTHORITY_PATHS,\n\t\tmaxLength: MAX_WORKER_AUTHORITY_PATH_LENGTH,\n\t};\n\tconst readPaths = stringArray(value.readPaths, `${label} authority readPaths`, pathArrayOptions);\n\tconst writePaths = stringArray(value.writePaths, `${label} authority writePaths`, pathArrayOptions);\n\tconst deniedPaths = stringArray(value.deniedPaths, `${label} authority deniedPaths`, pathArrayOptions);\n\tif (\n\t\t[...readPaths, ...writePaths, ...deniedPaths].some(\n\t\t\t(entry) => !path.isAbsolute(entry) && !path.win32.isAbsolute(entry),\n\t\t)\n\t) {\n\t\tthrow new WorkerExecutionContractError(`${label} authority paths must be absolute.`);\n\t}\n\tlet budget: RiskBudget;\n\ttry {\n\t\tbudget = parseRiskBudget(value.budget, `${label} authority budget`);\n\t} catch (error) {\n\t\tthrow new WorkerExecutionContractError(error instanceof Error ? error.message : String(error));\n\t}\n\tif (!isDeepStrictEqual(intersectRiskBudgets(profile.budget, budget), budget)) {\n\t\tthrow new WorkerExecutionContractError(`${label} authority exceeds its profile budget.`);\n\t}\n\tconst readGranted = capabilities.some(\n\t\t(capability) => capability === \"filesystem.read\" || capability === \"worktree.read\",\n\t);\n\tconst writeGranted = capabilities.some(\n\t\t(capability) => capability === \"filesystem.write\" || capability === \"worktree.mutate\",\n\t);\n\tif (readGranted && readPaths.length === 0) {\n\t\tthrow new WorkerExecutionContractError(`${label} read authority lacks a positive path scope.`);\n\t}\n\tif (writeGranted && writePaths.length === 0) {\n\t\tthrow new WorkerExecutionContractError(`${label} write authority lacks a positive path scope.`);\n\t}\n\treturn {\n\t\t...(typeof cwd === \"string\" ? { cwd } : {}),\n\t\tcapabilities: capabilities as WorkerExecutionAuthorityContract[\"capabilities\"],\n\t\ttoolNames,\n\t\treadPaths,\n\t\twritePaths,\n\t\tdeniedPaths,\n\t\tbudget,\n\t};\n}\n\nfunction parseProfileContract(value: unknown, label: string): WorkerProfileExecutionContract {\n\tif (\n\t\t!isPlainRecord(value) ||\n\t\t!hasOnlyKeys(value, [\"schemaVersion\", \"profile\", \"modelBinding\", \"authority\", \"resourcePointers\", \"soul\"]) ||\n\t\tvalue.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION\n\t) {\n\t\tthrow new WorkerExecutionContractError(`${label} is invalid.`);\n\t}\n\tlet profile: OrchestrationProfile;\n\ttry {\n\t\tprofile = parseOrchestrationProfile(value.profile);\n\t} catch (error) {\n\t\tthrow new WorkerExecutionContractError(\n\t\t\terror instanceof OrchestrationProfileError ? error.message : `${label} profile is invalid.`,\n\t\t);\n\t}\n\tconst modelBinding = parseModelBinding(value.modelBinding, label);\n\tif (!profile.modelPolicy.candidates.some((candidate) => isDeepStrictEqual(candidate, modelBinding))) {\n\t\tthrow new WorkerExecutionContractError(`${label} model binding is not declared by its profile.`);\n\t}\n\tif (\n\t\tvalue.soul !== undefined &&\n\t\t(typeof value.soul !== \"string\" || value.soul.length > MAX_WORKER_SOUL_LENGTH || !value.soul.trim())\n\t) {\n\t\tthrow new WorkerExecutionContractError(`${label} soul is invalid.`);\n\t}\n\tconst authority = parseAuthority(value.authority, profile, label);\n\tconst resourcePointers = parseResourcePointers(value.resourcePointers ?? [], label);\n\treturn {\n\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\tprofile,\n\t\tmodelBinding,\n\t\tauthority,\n\t\tresourcePointers,\n\t\t...(typeof value.soul === \"string\" ? { soul: value.soul } : {}),\n\t};\n}\n\nexport function parseWorkerExecutionContract(value: unknown): WorkerExecutionContract {\n\tif (\n\t\t!isPlainRecord(value) ||\n\t\t!hasOnlyKeys(value, [\"schemaVersion\", \"worker\", \"verifier\"]) ||\n\t\tvalue.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION\n\t) {\n\t\tthrow new WorkerExecutionContractError(\"Worker execution contract is invalid.\");\n\t}\n\tconst worker = parseProfileContract(value.worker, \"Worker execution contract\");\n\tconst verifier = value.verifier\n\t\t? parseProfileContract(value.verifier, \"Worker verifier execution contract\")\n\t\t: undefined;\n\tif (worker.profile.requireIndependentVerification) {\n\t\tif (!verifier || worker.profile.verificationProfileId !== verifier.profile.profileId) {\n\t\t\tthrow new WorkerExecutionContractError(\"Worker execution contract is missing its owner-pinned verifier.\");\n\t\t}\n\t\tif (verifier.profile.role !== \"verifier\") {\n\t\t\tthrow new WorkerExecutionContractError(\"Worker verifier execution contract does not use a verifier profile.\");\n\t\t}\n\t} else if (verifier) {\n\t\tthrow new WorkerExecutionContractError(\"Worker execution contract has an unexpected verifier.\");\n\t}\n\treturn {\n\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\tworker,\n\t\t...(verifier ? { verifier } : {}),\n\t};\n}\n\nfunction snapshotProfile(profile: OrchestrationProfile): OrchestrationProfile {\n\tconst { sourcePath: _sourcePath, ...persisted } = profile;\n\treturn structuredClone(persisted) as OrchestrationProfile;\n}\n\nfunction snapshotResolvedProfile(source: {\n\tprofile: OrchestrationProfile;\n\tmodelBinding: OrchestrationModelBinding;\n\tauthority: WorkerExecutionAuthorityContract;\n\tresourcePointers?: readonly ResourcePointer[];\n\tsoul?: string;\n}): WorkerProfileExecutionContract {\n\treturn {\n\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\tprofile: snapshotProfile(source.profile),\n\t\tmodelBinding: structuredClone(source.modelBinding),\n\t\tauthority: structuredClone(source.authority),\n\t\tresourcePointers: structuredClone(source.resourcePointers ?? []),\n\t\t...(source.soul ? { soul: source.soul } : {}),\n\t};\n}\n\nexport function createWorkerExecutionContract(args: {\n\tworker: {\n\t\tprofile: OrchestrationProfile;\n\t\tmodelBinding: OrchestrationModelBinding;\n\t\tauthority: WorkerExecutionAuthorityContract;\n\t\tresourcePointers?: readonly ResourcePointer[];\n\t\tsoul?: string;\n\t};\n\tverifier?: {\n\t\tprofile: OrchestrationProfile;\n\t\tmodelBinding: OrchestrationModelBinding;\n\t\tauthority: WorkerExecutionAuthorityContract;\n\t\tresourcePointers?: readonly ResourcePointer[];\n\t\tsoul?: string;\n\t};\n}): WorkerExecutionContract {\n\treturn parseWorkerExecutionContract({\n\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\tworker: snapshotResolvedProfile(args.worker),\n\t\t...(args.verifier ? { verifier: snapshotResolvedProfile(args.verifier) } : {}),\n\t});\n}\n\nexport function verifierWorkerExecutionContract(\n\tcontract: WorkerExecutionContract,\n): WorkerExecutionContract | undefined {\n\treturn contract.verifier\n\t\t? parseWorkerExecutionContract({ schemaVersion: ORCHESTRATION_SCHEMA_VERSION, worker: contract.verifier })\n\t\t: undefined;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"profile-filter-controller.d.ts","sourceRoot":"","sources":["../../src/core/profile-filter-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,KAAK,wBAAwB,EAAmC,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAEN,KAAK,6BAA6B,EAClC,KAAK,eAAe,EACpB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,2BAA2B;IAC3C,kBAAkB,IAAI,eAAe,CAAC;IACtC,iBAAiB,IAAI,cAAc,CAAC;IACpC,gBAAgB,IAAI,aAAa,CAAC;IAClC,MAAM,IAAI,MAAM,CAAC;IACjB,QAAQ,IAAI,KAAK,CAAC;IAClB,iBAAiB,IAAI,cAAc,CAAC;IACpC,yEAAyE;IACzE,mBAAmB,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAC/C,0CAA0C;IAC1C,oBAAoB,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAChD,kFAAkF;IAClF,oBAAoB,IAAI,QAAQ,CAAC,6BAA6B,CAAC,GAAG,SAAS,CAAC;IAC5E,0FAA0F;IAC1F,eAAe,IAAI,OA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AC3C,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,2BAA2B,EAAE,MAAM,CAAC;IACpC,sBAAsB,EAAE,OAAO,CAAC;IAChC,yBAAyB,EAAE,OAAO,CAAC;CACnC;AAED,qBAAa,uBAAuB;IACnC,qFAAqF;IACrF,OAAO,CAAC,uBAAuB,CAAgB;IAC/C,kGAAkG;IAClG,OAAO,CAAC,4BAA4B,CAAK;IACzC,2GAA2G;IAC3G,OAAO,CAAC,uBAAuB,CAAS;IACxC,OAAO,CAAC,0BAA0B,CAAS;IAE3C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA8B;IAEnD,YAAY,IAAI,EAAE,2BAA2B,EAE5C;IAED,4FAA4F;IAC5F,yBAAyB,IAAI,MAAM,EAAE,CAEpC;IAED,oBAAoB,IAAI,2BAA2B,CAOlD;IAED,qBAAqB,CAAC,QAAQ,EAAE,2BAA2B,GAAG,IAAI,CAKjE;IAED;;;;OAIG;IACH,uBAAuB,IAAI,QAAQ,CAAC,6BAA6B,CAAC,CAGjE;IAED,+BAA+B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAUrD;IAED,OAAO,CAAC,4BAA4B;IASpC;;;;OAIG;IACH,sBAAsB,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,wBAAwB,EAAE,OAAO,SAAK,GAAG,OAAO,CAExG;IAED,0BAA0B,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,0BAA0B,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,EAAE,CAyDjH;IAED;;;;;;;;;;;;;OAaG;IACH,iCAAiC,IAAI,MAAM,EAAE,CA0B5C;IAED;;;;;OAKG;IACG,iCAAiC,IAAI,OAAO,CAAC,IAAI,CAAC,CA0DvD;CACD"}
@@ -7,7 +7,7 @@
7
7
  * re-applies a profile-bound model/thinking level unless an explicit launch flag set them. Owns the
8
8
  * inert-extension warnings and profile-denied-extension count; everything else is read through deps.
9
9
  */
10
- import { isExtensionPathAllowedForImport } from "./extension-import-authority.js";
10
+ import { isDefaultOnBundledExtension, isExtensionPathAllowedForImport, } from "./extension-import-authority.js";
11
11
  import { findInitialModel, resolveProfileModelSettings } from "./model-resolver.js";
12
12
  import { matchesResourceProfilePattern, } from "./settings-manager.js";
13
13
  export class ProfileFilterController {
@@ -95,6 +95,9 @@ export class ProfileFilterController {
95
95
  return extensions.filter((extension) => {
96
96
  if (extension.sourceInfo.source === "inline")
97
97
  return true;
98
+ if (isDefaultOnBundledExtension(extension.path, extension.sourceInfo.source)) {
99
+ return this.isExtensionPathAllowed(extension.path, "default-on", extension.sourceInfo.baseDir);
100
+ }
98
101
  const explicitlyApproved = extension.sourceInfo.source === "cli" ||
99
102
  explicitLiveExtensionPaths?.has(extension.path) === true ||
100
103
  explicitLiveExtensionPaths?.has(extension.resolvedPath) === true;
@@ -103,7 +106,7 @@ export class ProfileFilterController {
103
106
  });
104
107
  }
105
108
  const hasToolOrCommandGate = this._hasToolOrCommandProfileGate();
106
- const allowedExtensions = extensions.filter((extension) => this.isExtensionPathAllowed(extension.path, "profile", extension.sourceInfo.baseDir));
109
+ const allowedExtensions = extensions.filter((extension) => this.isExtensionPathAllowed(extension.path, isDefaultOnBundledExtension(extension.path, extension.sourceInfo.source) ? "default-on" : "profile", extension.sourceInfo.baseDir));
107
110
  this._profileDeniedExtensionCount = extensions.length - allowedExtensions.length;
108
111
  return allowedExtensions.map((extension) => {
109
112
  if (!hasToolOrCommandGate)