@caupulican/pi-adaptative 0.81.42 → 0.84.1

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 (1414) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/dist/bun/cli.d.ts.map +1 -1
  3. package/dist/bun/cli.js.map +1 -1
  4. package/dist/bun/register-bedrock.d.ts.map +1 -1
  5. package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
  6. package/dist/bun/restore-sandbox-env.js.map +1 -1
  7. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
  8. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
  9. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
  10. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +52 -49
  11. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
  12. package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +62 -57
  13. package/dist/bundled-resources/prompts/skillify.md +1 -1
  14. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/fs.py +16 -19
  15. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/search.py +12 -26
  16. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/strings.py +15 -121
  17. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +52 -79
  18. package/dist/bundled-resources/runtimes/pi-shell-engine/escapes.py +70 -0
  19. package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +110 -61
  20. package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +106 -23
  21. package/dist/bundled-resources/runtimes/pi-shell-engine/paths.py +10 -0
  22. package/dist/bundled-resources/runtimes/pi-shell-engine/proc.py +12 -4
  23. package/dist/bundled-resources/runtimes/pi-shell-engine/shell_args.py +22 -0
  24. package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +9 -2
  25. package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +129 -259
  26. package/dist/bundled-resources/skills/authorized-web-security-audit/SKILL.md +187 -0
  27. package/dist/bundled-resources/skills/authorized-web-security-audit/references/assessment-contract.md +92 -0
  28. package/dist/bundled-resources/skills/deduplicate-by-evidence/SKILL.md +134 -0
  29. package/dist/bundled-resources/skills/evidence-gated-tdd/SKILL.md +93 -0
  30. package/dist/bundled-resources/skills/evidence-gated-tdd/references/evidence-model.md +27 -0
  31. package/dist/bundled-resources/skills/evidence-gated-tdd/references/security-scanners.md +24 -0
  32. package/dist/bundled-resources/skills/harness-self-adaptation/SKILL.md +4 -2
  33. package/dist/bundled-resources/skills/secure-agent-tool-surfaces/SKILL.md +217 -0
  34. package/dist/bundled-resources/skills/secure-agent-tool-surfaces/references/defensive-exploit-catalogue.md +175 -0
  35. package/dist/bundled-resources/skills/secure-agent-tool-surfaces/references/tool-boundary-checklist.md +87 -0
  36. package/dist/bundled-resources/skills/skill-architect/SKILL.md +2 -2
  37. package/dist/bundled-resources/skills/skill-creator/SKILL.md +188 -0
  38. package/dist/bundled-resources/skills/skill-creator/references/pi-skill-contract.md +73 -0
  39. package/dist/bundled-resources/skills/skill-creator/scripts/init-skill.mjs +142 -0
  40. package/dist/bundled-resources/skills/skill-creator/scripts/validate-skill.mjs +122 -0
  41. package/dist/cli/args.d.ts.map +1 -1
  42. package/dist/cli/args.js.map +1 -1
  43. package/dist/cli/config-selector.d.ts.map +1 -1
  44. package/dist/cli/config-selector.js.map +1 -1
  45. package/dist/cli/file-processor.d.ts.map +1 -1
  46. package/dist/cli/file-processor.js +8 -8
  47. package/dist/cli/file-processor.js.map +1 -1
  48. package/dist/cli/initial-message.d.ts +1 -1
  49. package/dist/cli/initial-message.d.ts.map +1 -1
  50. package/dist/cli/initial-message.js.map +1 -1
  51. package/dist/cli/list-models.d.ts.map +1 -1
  52. package/dist/cli/list-models.js.map +1 -1
  53. package/dist/cli/piped-stdin.d.ts +4 -0
  54. package/dist/cli/piped-stdin.d.ts.map +1 -0
  55. package/dist/cli/piped-stdin.js +13 -0
  56. package/dist/cli/piped-stdin.js.map +1 -0
  57. package/dist/cli/session-picker.d.ts.map +1 -1
  58. package/dist/cli/session-picker.js.map +1 -1
  59. package/dist/cli.d.ts.map +1 -1
  60. package/dist/cli.js.map +1 -1
  61. package/dist/config.d.ts +1 -1
  62. package/dist/config.d.ts.map +1 -1
  63. package/dist/config.js +10 -15
  64. package/dist/config.js.map +1 -1
  65. package/dist/core/agent-directory-layout.d.ts.map +1 -1
  66. package/dist/core/agent-directory-layout.js.map +1 -1
  67. package/dist/core/agent-paths.d.ts +1 -1
  68. package/dist/core/agent-paths.d.ts.map +1 -1
  69. package/dist/core/agent-paths.js +1 -1
  70. package/dist/core/agent-paths.js.map +1 -1
  71. package/dist/core/agent-session-contracts.d.ts +5 -9
  72. package/dist/core/agent-session-contracts.d.ts.map +1 -1
  73. package/dist/core/agent-session-contracts.js +1 -12
  74. package/dist/core/agent-session-contracts.js.map +1 -1
  75. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  76. package/dist/core/agent-session-runtime.js +10 -25
  77. package/dist/core/agent-session-runtime.js.map +1 -1
  78. package/dist/core/agent-session-services.d.ts.map +1 -1
  79. package/dist/core/agent-session-services.js.map +1 -1
  80. package/dist/core/agent-session.d.ts +24 -1
  81. package/dist/core/agent-session.d.ts.map +1 -1
  82. package/dist/core/agent-session.js +210 -237
  83. package/dist/core/agent-session.js.map +1 -1
  84. package/dist/core/auth-guidance.d.ts.map +1 -1
  85. package/dist/core/auth-guidance.js.map +1 -1
  86. package/dist/core/auth-storage.d.ts +4 -1
  87. package/dist/core/auth-storage.d.ts.map +1 -1
  88. package/dist/core/auth-storage.js +13 -39
  89. package/dist/core/auth-storage.js.map +1 -1
  90. package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
  91. package/dist/core/autonomy/approval-gate.js.map +1 -1
  92. package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
  93. package/dist/core/autonomy/bounded-completion.js.map +1 -1
  94. package/dist/core/autonomy/contracts.d.ts.map +1 -1
  95. package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
  96. package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
  97. package/dist/core/autonomy/evidence-finding-projection.d.ts +11 -0
  98. package/dist/core/autonomy/evidence-finding-projection.d.ts.map +1 -0
  99. package/dist/core/autonomy/evidence-finding-projection.js +37 -0
  100. package/dist/core/autonomy/evidence-finding-projection.js.map +1 -0
  101. package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
  102. package/dist/core/autonomy/foreground-envelope.js.map +1 -1
  103. package/dist/core/autonomy/gates.d.ts.map +1 -1
  104. package/dist/core/autonomy/gates.js.map +1 -1
  105. package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -1
  106. package/dist/core/autonomy/lane-private-paths.js.map +1 -1
  107. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  108. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  109. package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
  110. package/dist/core/autonomy/lane-tracker.js +2 -3
  111. package/dist/core/autonomy/lane-tracker.js.map +1 -1
  112. package/dist/core/autonomy/path-scope.d.ts.map +1 -1
  113. package/dist/core/autonomy/path-scope.js.map +1 -1
  114. package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
  115. package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
  116. package/dist/core/autonomy/session-lane-record.js.map +1 -1
  117. package/dist/core/autonomy/status.d.ts.map +1 -1
  118. package/dist/core/autonomy/status.js.map +1 -1
  119. package/dist/core/autonomy/subagent-prompt.d.ts.map +1 -1
  120. package/dist/core/autonomy/subagent-prompt.js.map +1 -1
  121. package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
  122. package/dist/core/autonomy/telemetry-events.js.map +1 -1
  123. package/dist/core/autonomy-telemetry.d.ts.map +1 -1
  124. package/dist/core/autonomy-telemetry.js +2 -4
  125. package/dist/core/autonomy-telemetry.js.map +1 -1
  126. package/dist/core/background-lane-controller.d.ts.map +1 -1
  127. package/dist/core/background-lane-controller.js +2 -15
  128. package/dist/core/background-lane-controller.js.map +1 -1
  129. package/dist/core/background-tool-task-controller.d.ts +88 -0
  130. package/dist/core/background-tool-task-controller.d.ts.map +1 -0
  131. package/dist/core/background-tool-task-controller.js +470 -0
  132. package/dist/core/background-tool-task-controller.js.map +1 -0
  133. package/dist/core/bash-execution-controller.d.ts +1 -0
  134. package/dist/core/bash-execution-controller.d.ts.map +1 -1
  135. package/dist/core/bash-execution-controller.js +5 -4
  136. package/dist/core/bash-execution-controller.js.map +1 -1
  137. package/dist/core/bash-executor.d.ts.map +1 -1
  138. package/dist/core/bash-executor.js.map +1 -1
  139. package/dist/core/bedrock-sso-login.d.ts.map +1 -1
  140. package/dist/core/bedrock-sso-login.js.map +1 -1
  141. package/dist/core/billing-failover-controller.d.ts.map +1 -1
  142. package/dist/core/billing-failover-controller.js +3 -3
  143. package/dist/core/billing-failover-controller.js.map +1 -1
  144. package/dist/core/billing-failover.d.ts.map +1 -1
  145. package/dist/core/billing-failover.js.map +1 -1
  146. package/dist/core/capability-contract.d.ts.map +1 -1
  147. package/dist/core/catalog-manager.d.ts.map +1 -1
  148. package/dist/core/catalog-manager.js +0 -0
  149. package/dist/core/catalog-manager.js.map +1 -1
  150. package/dist/core/compaction-controller.d.ts +2 -0
  151. package/dist/core/compaction-controller.d.ts.map +1 -1
  152. package/dist/core/compaction-controller.js +21 -8
  153. package/dist/core/compaction-controller.js.map +1 -1
  154. package/dist/core/compaction-support.d.ts +8 -0
  155. package/dist/core/compaction-support.d.ts.map +1 -1
  156. package/dist/core/compaction-support.js +0 -2
  157. package/dist/core/compaction-support.js.map +1 -1
  158. package/dist/core/context/artifact-retrieval.d.ts.map +1 -1
  159. package/dist/core/context/artifact-retrieval.js.map +1 -1
  160. package/dist/core/context/brain-curator.d.ts.map +1 -1
  161. package/dist/core/context/brain-curator.js +14 -33
  162. package/dist/core/context/brain-curator.js.map +1 -1
  163. package/dist/core/context/context-artifacts.d.ts.map +1 -1
  164. package/dist/core/context/context-artifacts.js +16 -24
  165. package/dist/core/context/context-artifacts.js.map +1 -1
  166. package/dist/core/context/context-audit.d.ts.map +1 -1
  167. package/dist/core/context/context-audit.js +3 -17
  168. package/dist/core/context/context-audit.js.map +1 -1
  169. package/dist/core/context/context-composition.d.ts.map +1 -1
  170. package/dist/core/context/context-composition.js.map +1 -1
  171. package/dist/core/context/context-item.d.ts.map +1 -1
  172. package/dist/core/context/context-item.js.map +1 -1
  173. package/dist/core/context/context-prompt-enforcement.d.ts.map +1 -1
  174. package/dist/core/context/context-prompt-enforcement.js +3 -16
  175. package/dist/core/context/context-prompt-enforcement.js.map +1 -1
  176. package/dist/core/context/context-prompt-policy.d.ts.map +1 -1
  177. package/dist/core/context/context-prompt-policy.js.map +1 -1
  178. package/dist/core/context/context-retention.d.ts.map +1 -1
  179. package/dist/core/context/context-retention.js.map +1 -1
  180. package/dist/core/context/context-store-retention.d.ts.map +1 -1
  181. package/dist/core/context/context-store-retention.js.map +1 -1
  182. package/dist/core/context/context-store.d.ts.map +1 -1
  183. package/dist/core/context/context-store.js.map +1 -1
  184. package/dist/core/context/context-tool-result.d.ts +4 -0
  185. package/dist/core/context/context-tool-result.d.ts.map +1 -0
  186. package/dist/core/context/context-tool-result.js +15 -0
  187. package/dist/core/context/context-tool-result.js.map +1 -0
  188. package/dist/core/context/current-work-memory.d.ts.map +1 -1
  189. package/dist/core/context/current-work-memory.js.map +1 -1
  190. package/dist/core/context/file-store-memory-provider.d.ts.map +1 -1
  191. package/dist/core/context/file-store-memory-provider.js +7 -28
  192. package/dist/core/context/file-store-memory-provider.js.map +1 -1
  193. package/dist/core/context/local-memory-search.d.ts +11 -0
  194. package/dist/core/context/local-memory-search.d.ts.map +1 -0
  195. package/dist/core/context/local-memory-search.js +37 -0
  196. package/dist/core/context/local-memory-search.js.map +1 -0
  197. package/dist/core/context/long-term-memory-trigger.d.ts.map +1 -1
  198. package/dist/core/context/long-term-memory-trigger.js.map +1 -1
  199. package/dist/core/context/memory-diagnostics.d.ts.map +1 -1
  200. package/dist/core/context/memory-diagnostics.js.map +1 -1
  201. package/dist/core/context/memory-index-store.d.ts.map +1 -1
  202. package/dist/core/context/memory-index-store.js.map +1 -1
  203. package/dist/core/context/memory-prompt-block.d.ts.map +1 -1
  204. package/dist/core/context/memory-prompt-block.js.map +1 -1
  205. package/dist/core/context/memory-prompt-budget.d.ts.map +1 -1
  206. package/dist/core/context/memory-prompt-budget.js.map +1 -1
  207. package/dist/core/context/memory-provider-contract.d.ts.map +1 -1
  208. package/dist/core/context/memory-provider-contract.js.map +1 -1
  209. package/dist/core/context/memory-retrieval.d.ts.map +1 -1
  210. package/dist/core/context/memory-retrieval.js.map +1 -1
  211. package/dist/core/context/memory-tier-composer.d.ts.map +1 -1
  212. package/dist/core/context/memory-tier-composer.js.map +1 -1
  213. package/dist/core/context/message-text.d.ts +7 -0
  214. package/dist/core/context/message-text.d.ts.map +1 -0
  215. package/dist/core/context/message-text.js +68 -0
  216. package/dist/core/context/message-text.js.map +1 -0
  217. package/dist/core/context/okf-memory-provider.d.ts.map +1 -1
  218. package/dist/core/context/okf-memory-provider.js +4 -30
  219. package/dist/core/context/okf-memory-provider.js.map +1 -1
  220. package/dist/core/context/okf-memory.d.ts.map +1 -1
  221. package/dist/core/context/okf-memory.js.map +1 -1
  222. package/dist/core/context/policy-engine.d.ts.map +1 -1
  223. package/dist/core/context/policy-engine.js.map +1 -1
  224. package/dist/core/context/policy-types.d.ts.map +1 -1
  225. package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
  226. package/dist/core/context/sqlite-runtime-index.js.map +1 -1
  227. package/dist/core/context/storage-authority.d.ts.map +1 -1
  228. package/dist/core/context/tool-output-packer.d.ts.map +1 -1
  229. package/dist/core/context/tool-output-packer.js.map +1 -1
  230. package/dist/core/context-gc.d.ts.map +1 -1
  231. package/dist/core/context-gc.js +14 -21
  232. package/dist/core/context-gc.js.map +1 -1
  233. package/dist/core/context-pipeline.d.ts +1 -3
  234. package/dist/core/context-pipeline.d.ts.map +1 -1
  235. package/dist/core/context-pipeline.js +64 -145
  236. package/dist/core/context-pipeline.js.map +1 -1
  237. package/dist/core/cost/cost-summary.d.ts.map +1 -1
  238. package/dist/core/cost/cost-summary.js.map +1 -1
  239. package/dist/core/cost/daily-usage.d.ts.map +1 -1
  240. package/dist/core/cost/daily-usage.js.map +1 -1
  241. package/dist/core/cost/session-usage.d.ts.map +1 -1
  242. package/dist/core/cost/session-usage.js.map +1 -1
  243. package/dist/core/cost-guard.d.ts.map +1 -1
  244. package/dist/core/cost-guard.js.map +1 -1
  245. package/dist/core/default-tool-surface.d.ts.map +1 -1
  246. package/dist/core/default-tool-surface.js +1 -0
  247. package/dist/core/default-tool-surface.js.map +1 -1
  248. package/dist/core/defaults.d.ts.map +1 -1
  249. package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -1
  250. package/dist/core/delegation/managed-lane-controller.js +2 -6
  251. package/dist/core/delegation/managed-lane-controller.js.map +1 -1
  252. package/dist/core/delegation/session-worker-claim.d.ts.map +1 -1
  253. package/dist/core/delegation/session-worker-claim.js.map +1 -1
  254. package/dist/core/delegation/worker-action-journal.d.ts.map +1 -1
  255. package/dist/core/delegation/worker-action-journal.js +0 -4
  256. package/dist/core/delegation/worker-action-journal.js.map +1 -1
  257. package/dist/core/delegation/worker-actions.d.ts.map +1 -1
  258. package/dist/core/delegation/worker-actions.js.map +1 -1
  259. package/dist/core/delegation/worker-agent-control-coordinator.d.ts +1 -0
  260. package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
  261. package/dist/core/delegation/worker-agent-control-coordinator.js +13 -15
  262. package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
  263. package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
  264. package/dist/core/delegation/worker-agent-control.js +1 -4
  265. package/dist/core/delegation/worker-agent-control.js.map +1 -1
  266. package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
  267. package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
  268. package/dist/core/delegation/worker-claim.d.ts.map +1 -1
  269. package/dist/core/delegation/worker-claim.js.map +1 -1
  270. package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -1
  271. package/dist/core/delegation/worker-conversation-store.js +0 -2
  272. package/dist/core/delegation/worker-conversation-store.js.map +1 -1
  273. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  274. package/dist/core/delegation/worker-delegation-controller.js +5 -14
  275. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  276. package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
  277. package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -1
  278. package/dist/core/delegation/worker-dispatch-scheduler.js +5 -6
  279. package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -1
  280. package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
  281. package/dist/core/delegation/worker-execution-policy.js.map +1 -1
  282. package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
  283. package/dist/core/delegation/worker-lane-projection.js.map +1 -1
  284. package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
  285. package/dist/core/delegation/worker-lifecycle.js +0 -3
  286. package/dist/core/delegation/worker-lifecycle.js.map +1 -1
  287. package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
  288. package/dist/core/delegation/worker-notification-coordinator.js +4 -5
  289. package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
  290. package/dist/core/delegation/worker-process-owner.d.ts.map +1 -1
  291. package/dist/core/delegation/worker-process-owner.js.map +1 -1
  292. package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -1
  293. package/dist/core/delegation/worker-profile-resolver.js +1 -2
  294. package/dist/core/delegation/worker-profile-resolver.js.map +1 -1
  295. package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
  296. package/dist/core/delegation/worker-recovery-coordinator.js +3 -4
  297. package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
  298. package/dist/core/delegation/worker-resource-catalog.d.ts.map +1 -1
  299. package/dist/core/delegation/worker-resource-catalog.js.map +1 -1
  300. package/dist/core/delegation/worker-resource-materializer.d.ts.map +1 -1
  301. package/dist/core/delegation/worker-resource-materializer.js +1 -4
  302. package/dist/core/delegation/worker-resource-materializer.js.map +1 -1
  303. package/dist/core/delegation/worker-runner.d.ts +2 -4
  304. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  305. package/dist/core/delegation/worker-runner.js +6 -18
  306. package/dist/core/delegation/worker-runner.js.map +1 -1
  307. package/dist/core/delegation/worker-task-label.d.ts.map +1 -1
  308. package/dist/core/delegation/worker-task-label.js.map +1 -1
  309. package/dist/core/delegation/worker-terminal-finalizer.d.ts.map +1 -1
  310. package/dist/core/delegation/worker-terminal-finalizer.js.map +1 -1
  311. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
  312. package/dist/core/delegation/worker-write-reservation-coordinator.js +1 -4
  313. package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
  314. package/dist/core/delegation/worker-write-reservation.d.ts.map +1 -1
  315. package/dist/core/delegation/worker-write-reservation.js +0 -2
  316. package/dist/core/delegation/worker-write-reservation.js.map +1 -1
  317. package/dist/core/diagnostics.d.ts.map +1 -1
  318. package/dist/core/doctor.d.ts +5 -5
  319. package/dist/core/doctor.d.ts.map +1 -1
  320. package/dist/core/doctor.js +16 -20
  321. package/dist/core/doctor.js.map +1 -1
  322. package/dist/core/event-bus.d.ts.map +1 -1
  323. package/dist/core/event-bus.js.map +1 -1
  324. package/dist/core/exec.d.ts.map +1 -1
  325. package/dist/core/exec.js +26 -7
  326. package/dist/core/exec.js.map +1 -1
  327. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  328. package/dist/core/export-html/ansi-to-html.js +21 -74
  329. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  330. package/dist/core/export-html/index.d.ts.map +1 -1
  331. package/dist/core/export-html/index.js +4 -0
  332. package/dist/core/export-html/index.js.map +1 -1
  333. package/dist/core/export-html/session-tree-foundations.d.mts +67 -0
  334. package/dist/core/export-html/session-tree-foundations.mjs +313 -0
  335. package/dist/core/export-html/template.css +14 -41
  336. package/dist/core/export-html/template.html +3 -1
  337. package/dist/core/export-html/template.js +26 -435
  338. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  339. package/dist/core/export-html/tool-renderer.js.map +1 -1
  340. package/dist/core/extension-import-authority.d.ts.map +1 -1
  341. package/dist/core/extension-import-authority.js.map +1 -1
  342. package/dist/core/extension-metadata.d.ts.map +1 -1
  343. package/dist/core/extension-metadata.js.map +1 -1
  344. package/dist/core/extensions/builtin.d.ts +17 -0
  345. package/dist/core/extensions/builtin.d.ts.map +1 -1
  346. package/dist/core/extensions/builtin.js +18 -54
  347. package/dist/core/extensions/builtin.js.map +1 -1
  348. package/dist/core/extensions/entry-resolution.d.ts +3 -0
  349. package/dist/core/extensions/entry-resolution.d.ts.map +1 -0
  350. package/dist/core/extensions/entry-resolution.js +17 -0
  351. package/dist/core/extensions/entry-resolution.js.map +1 -0
  352. package/dist/core/extensions/index.d.ts.map +1 -1
  353. package/dist/core/extensions/loader.d.ts.map +1 -1
  354. package/dist/core/extensions/loader.js +76 -21
  355. package/dist/core/extensions/loader.js.map +1 -1
  356. package/dist/core/extensions/runner.d.ts +2 -0
  357. package/dist/core/extensions/runner.d.ts.map +1 -1
  358. package/dist/core/extensions/runner.js +41 -112
  359. package/dist/core/extensions/runner.js.map +1 -1
  360. package/dist/core/extensions/stale-context.d.ts.map +1 -1
  361. package/dist/core/extensions/storage.d.ts.map +1 -1
  362. package/dist/core/extensions/storage.js.map +1 -1
  363. package/dist/core/extensions/types.d.ts.map +1 -1
  364. package/dist/core/extensions/types.js.map +1 -1
  365. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  366. package/dist/core/extensions/wrapper.js.map +1 -1
  367. package/dist/core/failure-corpus.d.ts.map +1 -1
  368. package/dist/core/failure-corpus.js +2 -5
  369. package/dist/core/failure-corpus.js.map +1 -1
  370. package/dist/core/footer-data-provider.d.ts.map +1 -1
  371. package/dist/core/footer-data-provider.js +27 -33
  372. package/dist/core/footer-data-provider.js.map +1 -1
  373. package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
  374. package/dist/core/foreground-recovery-controller.js +0 -4
  375. package/dist/core/foreground-recovery-controller.js.map +1 -1
  376. package/dist/core/gateways/channel-provider.d.ts.map +1 -1
  377. package/dist/core/gateways/channel-provider.js +7 -5
  378. package/dist/core/gateways/channel-provider.js.map +1 -1
  379. package/dist/core/goal-loop-controller.d.ts.map +1 -1
  380. package/dist/core/goal-loop-controller.js +0 -1
  381. package/dist/core/goal-loop-controller.js.map +1 -1
  382. package/dist/core/goals/compact-goal-context.d.ts.map +1 -1
  383. package/dist/core/goals/compact-goal-context.js +2 -4
  384. package/dist/core/goals/compact-goal-context.js.map +1 -1
  385. package/dist/core/goals/goal-acceptance.d.ts.map +1 -1
  386. package/dist/core/goals/goal-acceptance.js.map +1 -1
  387. package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
  388. package/dist/core/goals/goal-auto-continue-controller.js +1 -3
  389. package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
  390. package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
  391. package/dist/core/goals/goal-continuation-controller.js.map +1 -1
  392. package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
  393. package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
  394. package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
  395. package/dist/core/goals/goal-lifecycle.d.ts.map +1 -1
  396. package/dist/core/goals/goal-lifecycle.js.map +1 -1
  397. package/dist/core/goals/goal-record.d.ts.map +1 -1
  398. package/dist/core/goals/goal-record.js.map +1 -1
  399. package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
  400. package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
  401. package/dist/core/goals/goal-session-controller.d.ts +15 -0
  402. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  403. package/dist/core/goals/goal-session-controller.js +27 -3
  404. package/dist/core/goals/goal-session-controller.js.map +1 -1
  405. package/dist/core/goals/goal-state.d.ts.map +1 -1
  406. package/dist/core/goals/goal-state.js +35 -51
  407. package/dist/core/goals/goal-state.js.map +1 -1
  408. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  409. package/dist/core/goals/goal-tool-core.js.map +1 -1
  410. package/dist/core/goals/natural-language-goal.d.ts +9 -0
  411. package/dist/core/goals/natural-language-goal.d.ts.map +1 -0
  412. package/dist/core/goals/natural-language-goal.js +23 -0
  413. package/dist/core/goals/natural-language-goal.js.map +1 -0
  414. package/dist/core/goals/session-goal-state.d.ts.map +1 -1
  415. package/dist/core/goals/session-goal-state.js.map +1 -1
  416. package/dist/core/http-dispatcher.d.ts.map +1 -1
  417. package/dist/core/http-dispatcher.js.map +1 -1
  418. package/dist/core/human-input-controller.d.ts.map +1 -1
  419. package/dist/core/human-input-controller.js +2 -3
  420. package/dist/core/human-input-controller.js.map +1 -1
  421. package/dist/core/human-input.d.ts.map +1 -1
  422. package/dist/core/human-input.js.map +1 -1
  423. package/dist/core/improvement-loop.d.ts.map +1 -1
  424. package/dist/core/improvement-loop.js +11 -11
  425. package/dist/core/improvement-loop.js.map +1 -1
  426. package/dist/core/index.d.ts.map +1 -1
  427. package/dist/core/install-telemetry.d.ts.map +1 -1
  428. package/dist/core/install-telemetry.js.map +1 -1
  429. package/dist/core/isolated-text-completion.d.ts +17 -0
  430. package/dist/core/isolated-text-completion.d.ts.map +1 -0
  431. package/dist/core/isolated-text-completion.js +15 -0
  432. package/dist/core/isolated-text-completion.js.map +1 -0
  433. package/dist/core/keybindings.d.ts +47 -2
  434. package/dist/core/keybindings.d.ts.map +1 -1
  435. package/dist/core/keybindings.js +12 -1
  436. package/dist/core/keybindings.js.map +1 -1
  437. package/dist/core/learning/learning-audit.d.ts.map +1 -1
  438. package/dist/core/learning/learning-audit.js.map +1 -1
  439. package/dist/core/learning/learning-gate.d.ts.map +1 -1
  440. package/dist/core/learning/learning-gate.js.map +1 -1
  441. package/dist/core/learning/observation-store.d.ts.map +1 -1
  442. package/dist/core/learning/observation-store.js +0 -2
  443. package/dist/core/learning/observation-store.js.map +1 -1
  444. package/dist/core/learning/reflection-engine.d.ts +1 -1
  445. package/dist/core/learning/reflection-engine.d.ts.map +1 -1
  446. package/dist/core/learning/reflection-engine.js +3 -0
  447. package/dist/core/learning/reflection-engine.js.map +1 -1
  448. package/dist/core/learning/reflection-turn-analysis.d.ts +20 -0
  449. package/dist/core/learning/reflection-turn-analysis.d.ts.map +1 -0
  450. package/dist/core/learning/reflection-turn-analysis.js +136 -0
  451. package/dist/core/learning/reflection-turn-analysis.js.map +1 -0
  452. package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
  453. package/dist/core/learning/session-learning-decision.js.map +1 -1
  454. package/dist/core/learning/skill-curator.d.ts.map +1 -1
  455. package/dist/core/learning/skill-curator.js +0 -3
  456. package/dist/core/learning/skill-curator.js.map +1 -1
  457. package/dist/core/local-runtime-controller.d.ts +39 -0
  458. package/dist/core/local-runtime-controller.d.ts.map +1 -1
  459. package/dist/core/local-runtime-controller.js +41 -62
  460. package/dist/core/local-runtime-controller.js.map +1 -1
  461. package/dist/core/memory/effectiveness-tracker.d.ts.map +1 -1
  462. package/dist/core/memory/effectiveness-tracker.js +4 -2
  463. package/dist/core/memory/effectiveness-tracker.js.map +1 -1
  464. package/dist/core/memory/memory-manager.d.ts.map +1 -1
  465. package/dist/core/memory/memory-manager.js +7 -7
  466. package/dist/core/memory/memory-manager.js.map +1 -1
  467. package/dist/core/memory/memory-provider.d.ts.map +1 -1
  468. package/dist/core/memory/providers/file-store.d.ts +7 -0
  469. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  470. package/dist/core/memory/providers/file-store.js +48 -13
  471. package/dist/core/memory/providers/file-store.js.map +1 -1
  472. package/dist/core/memory/providers/transcript-recall-worker-protocol.d.ts +47 -0
  473. package/dist/core/memory/providers/transcript-recall-worker-protocol.d.ts.map +1 -0
  474. package/dist/core/memory/providers/transcript-recall-worker-protocol.js +50 -0
  475. package/dist/core/memory/providers/transcript-recall-worker-protocol.js.map +1 -0
  476. package/dist/core/memory/providers/transcript-recall-worker.d.ts +2 -0
  477. package/dist/core/memory/providers/transcript-recall-worker.d.ts.map +1 -0
  478. package/dist/core/memory/providers/transcript-recall-worker.js +143 -0
  479. package/dist/core/memory/providers/transcript-recall-worker.js.map +1 -0
  480. package/dist/core/memory/providers/transcript-recall.d.ts +24 -13
  481. package/dist/core/memory/providers/transcript-recall.d.ts.map +1 -1
  482. package/dist/core/memory/providers/transcript-recall.js +143 -141
  483. package/dist/core/memory/providers/transcript-recall.js.map +1 -1
  484. package/dist/core/memory/providers/user-memory-archive.d.ts +39 -0
  485. package/dist/core/memory/providers/user-memory-archive.d.ts.map +1 -0
  486. package/dist/core/memory/providers/user-memory-archive.js +258 -0
  487. package/dist/core/memory/providers/user-memory-archive.js.map +1 -0
  488. package/dist/core/memory/transcript-index.d.ts.map +1 -1
  489. package/dist/core/memory/transcript-index.js +1 -1
  490. package/dist/core/memory/transcript-index.js.map +1 -1
  491. package/dist/core/memory-controller.d.ts +9 -0
  492. package/dist/core/memory-controller.d.ts.map +1 -1
  493. package/dist/core/memory-controller.js +57 -16
  494. package/dist/core/memory-controller.js.map +1 -1
  495. package/dist/core/model-capability.d.ts.map +1 -1
  496. package/dist/core/model-capability.js.map +1 -1
  497. package/dist/core/model-output-json.d.ts +10 -0
  498. package/dist/core/model-output-json.d.ts.map +1 -0
  499. package/dist/core/model-output-json.js +43 -0
  500. package/dist/core/model-output-json.js.map +1 -0
  501. package/dist/core/model-registry.d.ts +8 -8
  502. package/dist/core/model-registry.d.ts.map +1 -1
  503. package/dist/core/model-registry.js +29 -52
  504. package/dist/core/model-registry.js.map +1 -1
  505. package/dist/core/model-resolver.d.ts.map +1 -1
  506. package/dist/core/model-resolver.js +1 -1
  507. package/dist/core/model-resolver.js.map +1 -1
  508. package/dist/core/model-router/config-diagnostics.d.ts.map +1 -1
  509. package/dist/core/model-router/config-diagnostics.js.map +1 -1
  510. package/dist/core/model-router/executor-route.d.ts.map +1 -1
  511. package/dist/core/model-router/executor-route.js.map +1 -1
  512. package/dist/core/model-router/fitness-gate.d.ts.map +1 -1
  513. package/dist/core/model-router/fitness-gate.js.map +1 -1
  514. package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
  515. package/dist/core/model-router/route-judge.d.ts.map +1 -1
  516. package/dist/core/model-router/route-judge.js +18 -36
  517. package/dist/core/model-router/route-judge.js.map +1 -1
  518. package/dist/core/model-router/session-buffer.d.ts.map +1 -1
  519. package/dist/core/model-router/session-buffer.js.map +1 -1
  520. package/dist/core/model-router/status.d.ts.map +1 -1
  521. package/dist/core/model-router/status.js.map +1 -1
  522. package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
  523. package/dist/core/model-router/tool-escalation.js.map +1 -1
  524. package/dist/core/model-router-controller.d.ts +1 -0
  525. package/dist/core/model-router-controller.d.ts.map +1 -1
  526. package/dist/core/model-router-controller.js +25 -56
  527. package/dist/core/model-router-controller.js.map +1 -1
  528. package/dist/core/model-selection-controller.d.ts +10 -0
  529. package/dist/core/model-selection-controller.d.ts.map +1 -1
  530. package/dist/core/model-selection-controller.js +0 -1
  531. package/dist/core/model-selection-controller.js.map +1 -1
  532. package/dist/core/model-tool-protocol.d.ts.map +1 -1
  533. package/dist/core/model-tool-protocol.js.map +1 -1
  534. package/dist/core/models/adaptation-store.d.ts.map +1 -1
  535. package/dist/core/models/adaptation-store.js +0 -1
  536. package/dist/core/models/adaptation-store.js.map +1 -1
  537. package/dist/core/models/context-sizing.d.ts.map +1 -1
  538. package/dist/core/models/context-sizing.js.map +1 -1
  539. package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
  540. package/dist/core/models/default-model-suggestions.js.map +1 -1
  541. package/dist/core/models/fitness-store.d.ts.map +1 -1
  542. package/dist/core/models/fitness-store.js +0 -1
  543. package/dist/core/models/fitness-store.js.map +1 -1
  544. package/dist/core/models/host-state-store.d.ts.map +1 -1
  545. package/dist/core/models/host-state-store.js +1 -6
  546. package/dist/core/models/host-state-store.js.map +1 -1
  547. package/dist/core/models/llamacpp-runtime.d.ts +4 -19
  548. package/dist/core/models/llamacpp-runtime.d.ts.map +1 -1
  549. package/dist/core/models/llamacpp-runtime.js +32 -136
  550. package/dist/core/models/llamacpp-runtime.js.map +1 -1
  551. package/dist/core/models/local-registration.d.ts.map +1 -1
  552. package/dist/core/models/local-registration.js +82 -115
  553. package/dist/core/models/local-registration.js.map +1 -1
  554. package/dist/core/models/local-runtime.d.ts +12 -18
  555. package/dist/core/models/local-runtime.d.ts.map +1 -1
  556. package/dist/core/models/local-runtime.js +60 -204
  557. package/dist/core/models/local-runtime.js.map +1 -1
  558. package/dist/core/models/model-endpoint.d.ts.map +1 -1
  559. package/dist/core/models/model-endpoint.js.map +1 -1
  560. package/dist/core/models/model-ref.d.ts.map +1 -1
  561. package/dist/core/models/model-ref.js.map +1 -1
  562. package/dist/core/models/needle-runtime.d.ts +7 -3
  563. package/dist/core/models/needle-runtime.d.ts.map +1 -1
  564. package/dist/core/models/needle-runtime.js +16 -92
  565. package/dist/core/models/needle-runtime.js.map +1 -1
  566. package/dist/core/models/perf-profile.d.ts +1 -1
  567. package/dist/core/models/perf-profile.d.ts.map +1 -1
  568. package/dist/core/models/perf-profile.js +6 -13
  569. package/dist/core/models/perf-profile.js.map +1 -1
  570. package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -1
  571. package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -1
  572. package/dist/core/models/runtime-arbiter.d.ts.map +1 -1
  573. package/dist/core/models/runtime-arbiter.js +3 -15
  574. package/dist/core/models/runtime-arbiter.js.map +1 -1
  575. package/dist/core/models/runtime-process.d.ts +100 -0
  576. package/dist/core/models/runtime-process.d.ts.map +1 -0
  577. package/dist/core/models/runtime-process.js +183 -0
  578. package/dist/core/models/runtime-process.js.map +1 -0
  579. package/dist/core/orchestration/agent-resume.d.ts.map +1 -1
  580. package/dist/core/orchestration/agent-resume.js.map +1 -1
  581. package/dist/core/orchestration/attempt-usage.d.ts.map +1 -1
  582. package/dist/core/orchestration/attempt-usage.js.map +1 -1
  583. package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
  584. package/dist/core/orchestration/capability-gateway.js +0 -14
  585. package/dist/core/orchestration/capability-gateway.js.map +1 -1
  586. package/dist/core/orchestration/contracts.d.ts.map +1 -1
  587. package/dist/core/orchestration/contracts.js.map +1 -1
  588. package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
  589. package/dist/core/orchestration/delegation-ledger.js +0 -2
  590. package/dist/core/orchestration/delegation-ledger.js.map +1 -1
  591. package/dist/core/orchestration/event-store.d.ts.map +1 -1
  592. package/dist/core/orchestration/event-store.js +1 -14
  593. package/dist/core/orchestration/event-store.js.map +1 -1
  594. package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
  595. package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
  596. package/dist/core/orchestration/model-binding.d.ts.map +1 -1
  597. package/dist/core/orchestration/model-binding.js.map +1 -1
  598. package/dist/core/orchestration/policy-compiler.d.ts.map +1 -1
  599. package/dist/core/orchestration/policy-compiler.js +0 -3
  600. package/dist/core/orchestration/policy-compiler.js.map +1 -1
  601. package/dist/core/orchestration/policy-gate.d.ts.map +1 -1
  602. package/dist/core/orchestration/policy-gate.js +0 -2
  603. package/dist/core/orchestration/policy-gate.js.map +1 -1
  604. package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
  605. package/dist/core/orchestration/profile-registry.js +1 -1
  606. package/dist/core/orchestration/profile-registry.js.map +1 -1
  607. package/dist/core/orchestration/profile-store.d.ts.map +1 -1
  608. package/dist/core/orchestration/profile-store.js +0 -3
  609. package/dist/core/orchestration/profile-store.js.map +1 -1
  610. package/dist/core/orchestration/risk-budget.d.ts.map +1 -1
  611. package/dist/core/orchestration/risk-budget.js.map +1 -1
  612. package/dist/core/orchestration/task-runtime.d.ts +1 -0
  613. package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
  614. package/dist/core/orchestration/task-runtime.js +27 -42
  615. package/dist/core/orchestration/task-runtime.js.map +1 -1
  616. package/dist/core/orchestration/work-state-projection.d.ts.map +1 -1
  617. package/dist/core/orchestration/work-state-projection.js.map +1 -1
  618. package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
  619. package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
  620. package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -1
  621. package/dist/core/orchestration/worker-result-adapter.js.map +1 -1
  622. package/dist/core/output-guard.d.ts.map +1 -1
  623. package/dist/core/output-guard.js.map +1 -1
  624. package/dist/core/package-manager.d.ts +3 -0
  625. package/dist/core/package-manager.d.ts.map +1 -1
  626. package/dist/core/package-manager.js +88 -353
  627. package/dist/core/package-manager.js.map +1 -1
  628. package/dist/core/process-identity.d.ts.map +1 -1
  629. package/dist/core/process-identity.js.map +1 -1
  630. package/dist/core/process-liveness.d.ts +3 -0
  631. package/dist/core/process-liveness.d.ts.map +1 -0
  632. package/dist/core/process-liveness.js +17 -0
  633. package/dist/core/process-liveness.js.map +1 -0
  634. package/dist/core/process-matrix/codes.d.ts.map +1 -1
  635. package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -1
  636. package/dist/core/process-matrix/resume-launcher.js.map +1 -1
  637. package/dist/core/process-matrix/runtime.d.ts.map +1 -1
  638. package/dist/core/process-matrix/runtime.js.map +1 -1
  639. package/dist/core/process-matrix/store.d.ts.map +1 -1
  640. package/dist/core/process-matrix/store.js.map +1 -1
  641. package/dist/core/process-matrix/supervisor.d.ts.map +1 -1
  642. package/dist/core/process-matrix/supervisor.js.map +1 -1
  643. package/dist/core/profile-filter-controller.d.ts.map +1 -1
  644. package/dist/core/profile-filter-controller.js +7 -8
  645. package/dist/core/profile-filter-controller.js.map +1 -1
  646. package/dist/core/profile-registry.d.ts.map +1 -1
  647. package/dist/core/profile-registry.js +1 -2
  648. package/dist/core/profile-registry.js.map +1 -1
  649. package/dist/core/profile-resource-selection.d.ts.map +1 -1
  650. package/dist/core/profile-resource-selection.js +18 -59
  651. package/dist/core/profile-resource-selection.js.map +1 -1
  652. package/dist/core/prompt-markup.d.ts +3 -0
  653. package/dist/core/prompt-markup.d.ts.map +1 -0
  654. package/dist/core/prompt-markup.js +7 -0
  655. package/dist/core/prompt-markup.js.map +1 -0
  656. package/dist/core/prompt-templates.d.ts.map +1 -1
  657. package/dist/core/prompt-templates.js +13 -39
  658. package/dist/core/prompt-templates.js.map +1 -1
  659. package/dist/core/provider-display-names.d.ts.map +1 -1
  660. package/dist/core/python-runtime.d.ts.map +1 -1
  661. package/dist/core/python-runtime.js.map +1 -1
  662. package/dist/core/reflection-controller.d.ts +22 -1
  663. package/dist/core/reflection-controller.d.ts.map +1 -1
  664. package/dist/core/reflection-controller.js +143 -25
  665. package/dist/core/reflection-controller.js.map +1 -1
  666. package/dist/core/reload-blockers.d.ts +2 -1
  667. package/dist/core/reload-blockers.d.ts.map +1 -1
  668. package/dist/core/reload-blockers.js +4 -14
  669. package/dist/core/reload-blockers.js.map +1 -1
  670. package/dist/core/request-auth.d.ts.map +1 -1
  671. package/dist/core/request-auth.js.map +1 -1
  672. package/dist/core/research/automata-provider.d.ts.map +1 -1
  673. package/dist/core/research/automata-provider.js.map +1 -1
  674. package/dist/core/research/evidence-bundle.d.ts.map +1 -1
  675. package/dist/core/research/evidence-bundle.js.map +1 -1
  676. package/dist/core/research/lane-model-resolver.d.ts.map +1 -1
  677. package/dist/core/research/lane-model-resolver.js +0 -1
  678. package/dist/core/research/lane-model-resolver.js.map +1 -1
  679. package/dist/core/research/model-fitness-controller.d.ts.map +1 -1
  680. package/dist/core/research/model-fitness-controller.js +17 -33
  681. package/dist/core/research/model-fitness-controller.js.map +1 -1
  682. package/dist/core/research/model-fitness.d.ts.map +1 -1
  683. package/dist/core/research/model-fitness.js +4 -25
  684. package/dist/core/research/model-fitness.js.map +1 -1
  685. package/dist/core/research/research-gate.d.ts.map +1 -1
  686. package/dist/core/research/research-gate.js.map +1 -1
  687. package/dist/core/research/research-lane-controller.d.ts.map +1 -1
  688. package/dist/core/research/research-lane-controller.js +5 -10
  689. package/dist/core/research/research-lane-controller.js.map +1 -1
  690. package/dist/core/research/research-runner.d.ts +2 -4
  691. package/dist/core/research/research-runner.d.ts.map +1 -1
  692. package/dist/core/research/research-runner.js +17 -48
  693. package/dist/core/research/research-runner.js.map +1 -1
  694. package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
  695. package/dist/core/research/session-evidence-bundle.js.map +1 -1
  696. package/dist/core/research/workspace-collector.d.ts.map +1 -1
  697. package/dist/core/research/workspace-collector.js.map +1 -1
  698. package/dist/core/resolve-config-value.d.ts.map +1 -1
  699. package/dist/core/resolve-config-value.js.map +1 -1
  700. package/dist/core/resource-ignore.d.ts +6 -0
  701. package/dist/core/resource-ignore.d.ts.map +1 -0
  702. package/dist/core/resource-ignore.js +44 -0
  703. package/dist/core/resource-ignore.js.map +1 -0
  704. package/dist/core/resource-loader.d.ts +0 -1
  705. package/dist/core/resource-loader.d.ts.map +1 -1
  706. package/dist/core/resource-loader.js +52 -187
  707. package/dist/core/resource-loader.js.map +1 -1
  708. package/dist/core/resource-profile-blocks.d.ts +3 -1
  709. package/dist/core/resource-profile-blocks.d.ts.map +1 -1
  710. package/dist/core/resource-profile-blocks.js +8 -5
  711. package/dist/core/resource-profile-blocks.js.map +1 -1
  712. package/dist/core/resource-profile-equality.d.ts.map +1 -1
  713. package/dist/core/resource-profile-equality.js.map +1 -1
  714. package/dist/core/resource-traversal.d.ts +43 -0
  715. package/dist/core/resource-traversal.d.ts.map +1 -0
  716. package/dist/core/resource-traversal.js +84 -0
  717. package/dist/core/resource-traversal.js.map +1 -0
  718. package/dist/core/risk-classifier.d.ts.map +1 -1
  719. package/dist/core/risk-classifier.js.map +1 -1
  720. package/dist/core/runtime-builder.d.ts +4 -1
  721. package/dist/core/runtime-builder.d.ts.map +1 -1
  722. package/dist/core/runtime-builder.js +25 -50
  723. package/dist/core/runtime-builder.js.map +1 -1
  724. package/dist/core/scout-controller.d.ts.map +1 -1
  725. package/dist/core/scout-controller.js +0 -1
  726. package/dist/core/scout-controller.js.map +1 -1
  727. package/dist/core/sdk.d.ts.map +1 -1
  728. package/dist/core/sdk.js.map +1 -1
  729. package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
  730. package/dist/core/secrets/credential-exposure-guard.js +101 -43
  731. package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
  732. package/dist/core/secrets/secret-dotenv.d.ts.map +1 -1
  733. package/dist/core/secrets/secret-dotenv.js +0 -1
  734. package/dist/core/secrets/secret-dotenv.js.map +1 -1
  735. package/dist/core/secrets/secret-vault-format.d.ts.map +1 -1
  736. package/dist/core/secrets/secret-vault-format.js +0 -1
  737. package/dist/core/secrets/secret-vault-format.js.map +1 -1
  738. package/dist/core/secrets/secret-vault.d.ts.map +1 -1
  739. package/dist/core/secrets/secret-vault.js +2 -10
  740. package/dist/core/secrets/secret-vault.js.map +1 -1
  741. package/dist/core/security/secret-text.d.ts.map +1 -1
  742. package/dist/core/security/secret-text.js.map +1 -1
  743. package/dist/core/security/untrusted-boundary.d.ts.map +1 -1
  744. package/dist/core/security/untrusted-boundary.js.map +1 -1
  745. package/dist/core/session-analytics.d.ts.map +1 -1
  746. package/dist/core/session-analytics.js +18 -50
  747. package/dist/core/session-analytics.js.map +1 -1
  748. package/dist/core/session-artifact-bundle.d.ts.map +1 -1
  749. package/dist/core/session-artifact-bundle.js.map +1 -1
  750. package/dist/core/session-cwd.d.ts.map +1 -1
  751. package/dist/core/session-cwd.js +0 -1
  752. package/dist/core/session-cwd.js.map +1 -1
  753. package/dist/core/session-entry-index.d.ts +8 -0
  754. package/dist/core/session-entry-index.d.ts.map +1 -0
  755. package/dist/core/session-entry-index.js +16 -0
  756. package/dist/core/session-entry-index.js.map +1 -0
  757. package/dist/core/session-image-store.d.ts.map +1 -1
  758. package/dist/core/session-image-store.js +0 -3
  759. package/dist/core/session-image-store.js.map +1 -1
  760. package/dist/core/session-jsonl-writer.d.ts +3 -0
  761. package/dist/core/session-jsonl-writer.d.ts.map +1 -0
  762. package/dist/core/session-jsonl-writer.js +38 -0
  763. package/dist/core/session-jsonl-writer.js.map +1 -0
  764. package/dist/core/session-manager-factory.d.ts.map +1 -1
  765. package/dist/core/session-manager-factory.js.map +1 -1
  766. package/dist/core/session-role.d.ts.map +1 -1
  767. package/dist/core/session-role.js.map +1 -1
  768. package/dist/core/session-snapshot.d.ts.map +1 -1
  769. package/dist/core/session-snapshot.js.map +1 -1
  770. package/dist/core/session-supervision-runtime.d.ts.map +1 -1
  771. package/dist/core/session-supervision-runtime.js +1 -4
  772. package/dist/core/session-supervision-runtime.js.map +1 -1
  773. package/dist/core/session-tree-navigator.d.ts.map +1 -1
  774. package/dist/core/session-tree-navigator.js +0 -1
  775. package/dist/core/session-tree-navigator.js.map +1 -1
  776. package/dist/core/settings-manager.d.ts +2 -1
  777. package/dist/core/settings-manager.d.ts.map +1 -1
  778. package/dist/core/settings-manager.js +64 -162
  779. package/dist/core/settings-manager.js.map +1 -1
  780. package/dist/core/skill-block.d.mts +8 -0
  781. package/dist/core/skill-block.mjs +52 -0
  782. package/dist/core/skill-discovery.d.ts +5 -0
  783. package/dist/core/skill-discovery.d.ts.map +1 -0
  784. package/dist/core/skill-discovery.js +34 -0
  785. package/dist/core/skill-discovery.js.map +1 -0
  786. package/dist/core/skills.d.ts.map +1 -1
  787. package/dist/core/skills.js +23 -159
  788. package/dist/core/skills.js.map +1 -1
  789. package/dist/core/slash-commands.d.ts.map +1 -1
  790. package/dist/core/source-info.d.ts.map +1 -1
  791. package/dist/core/source-info.js.map +1 -1
  792. package/dist/core/spawned-usage.d.ts +21 -0
  793. package/dist/core/spawned-usage.d.ts.map +1 -0
  794. package/dist/core/spawned-usage.js +29 -0
  795. package/dist/core/spawned-usage.js.map +1 -0
  796. package/dist/core/system-prompt-builder.d.ts +4 -0
  797. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  798. package/dist/core/system-prompt-builder.js +15 -8
  799. package/dist/core/system-prompt-builder.js.map +1 -1
  800. package/dist/core/system-prompt.d.ts.map +1 -1
  801. package/dist/core/system-prompt.js +53 -35
  802. package/dist/core/system-prompt.js.map +1 -1
  803. package/dist/core/tasks/session-task-state.d.ts.map +1 -1
  804. package/dist/core/tasks/session-task-state.js.map +1 -1
  805. package/dist/core/tasks/task-command.d.ts.map +1 -1
  806. package/dist/core/tasks/task-command.js.map +1 -1
  807. package/dist/core/tasks/task-contract-monitor.d.ts.map +1 -1
  808. package/dist/core/tasks/task-contract-monitor.js.map +1 -1
  809. package/dist/core/tasks/task-projection.d.ts.map +1 -1
  810. package/dist/core/tasks/task-projection.js.map +1 -1
  811. package/dist/core/tasks/task-state.d.ts.map +1 -1
  812. package/dist/core/tasks/task-state.js.map +1 -1
  813. package/dist/core/text-preview.d.ts +4 -0
  814. package/dist/core/text-preview.d.ts.map +1 -0
  815. package/dist/core/text-preview.js +33 -0
  816. package/dist/core/text-preview.js.map +1 -0
  817. package/dist/core/timings.d.ts.map +1 -1
  818. package/dist/core/timings.js.map +1 -1
  819. package/dist/core/tool-capability-policy.d.ts.map +1 -1
  820. package/dist/core/tool-capability-policy.js.map +1 -1
  821. package/dist/core/tool-gate-controller.d.ts.map +1 -1
  822. package/dist/core/tool-gate-controller.js +86 -87
  823. package/dist/core/tool-gate-controller.js.map +1 -1
  824. package/dist/core/tool-protocol-controller.d.ts +4 -1
  825. package/dist/core/tool-protocol-controller.d.ts.map +1 -1
  826. package/dist/core/tool-protocol-controller.js +19 -23
  827. package/dist/core/tool-protocol-controller.js.map +1 -1
  828. package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
  829. package/dist/core/tool-recovery-log-records.js.map +1 -1
  830. package/dist/core/tool-recovery-log-worker.d.ts.map +1 -1
  831. package/dist/core/tool-recovery-log-worker.js.map +1 -1
  832. package/dist/core/tool-recovery-logger.d.ts.map +1 -1
  833. package/dist/core/tool-recovery-logger.js +12 -24
  834. package/dist/core/tool-recovery-logger.js.map +1 -1
  835. package/dist/core/tool-recovery-stats.d.ts.map +1 -1
  836. package/dist/core/tool-recovery-stats.js +16 -22
  837. package/dist/core/tool-recovery-stats.js.map +1 -1
  838. package/dist/core/tool-repair-health.d.ts.map +1 -1
  839. package/dist/core/tool-repair-health.js.map +1 -1
  840. package/dist/core/tool-repair-settings.d.ts.map +1 -1
  841. package/dist/core/tool-repair-settings.js.map +1 -1
  842. package/dist/core/tool-selection/expected-utility.d.ts.map +1 -1
  843. package/dist/core/tool-selection/expected-utility.js.map +1 -1
  844. package/dist/core/tool-selection/promotion.d.ts.map +1 -1
  845. package/dist/core/tool-selection/promotion.js.map +1 -1
  846. package/dist/core/tool-selection/tool-performance-store.d.ts +2 -0
  847. package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
  848. package/dist/core/tool-selection/tool-performance-store.js +49 -7
  849. package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
  850. package/dist/core/tool-selection/tool-phase-timing.d.ts +19 -0
  851. package/dist/core/tool-selection/tool-phase-timing.d.ts.map +1 -0
  852. package/dist/core/tool-selection/tool-phase-timing.js +63 -0
  853. package/dist/core/tool-selection/tool-phase-timing.js.map +1 -0
  854. package/dist/core/tool-selection/tool-selection-controller.d.ts +2 -5
  855. package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
  856. package/dist/core/tool-selection/tool-selection-controller.js +50 -30
  857. package/dist/core/tool-selection/tool-selection-controller.js.map +1 -1
  858. package/dist/core/toolkit/reflex-interpreter.d.ts +16 -0
  859. package/dist/core/toolkit/reflex-interpreter.d.ts.map +1 -1
  860. package/dist/core/toolkit/reflex-interpreter.js +21 -0
  861. package/dist/core/toolkit/reflex-interpreter.js.map +1 -1
  862. package/dist/core/toolkit/script-registry.d.ts.map +1 -1
  863. package/dist/core/toolkit/script-registry.js.map +1 -1
  864. package/dist/core/toolkit/script-runner.d.ts.map +1 -1
  865. package/dist/core/toolkit/script-runner.js.map +1 -1
  866. package/dist/core/tools/artifact-retrieve.d.ts.map +1 -1
  867. package/dist/core/tools/artifact-retrieve.js.map +1 -1
  868. package/dist/core/tools/ask-question.d.ts +2 -3
  869. package/dist/core/tools/ask-question.d.ts.map +1 -1
  870. package/dist/core/tools/ask-question.js +14 -40
  871. package/dist/core/tools/ask-question.js.map +1 -1
  872. package/dist/core/tools/bash.d.ts +2 -0
  873. package/dist/core/tools/bash.d.ts.map +1 -1
  874. package/dist/core/tools/bash.js +83 -30
  875. package/dist/core/tools/bash.js.map +1 -1
  876. package/dist/core/tools/context-scout.d.ts.map +1 -1
  877. package/dist/core/tools/context-scout.js.map +1 -1
  878. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  879. package/dist/core/tools/delegate-status.js +9 -7
  880. package/dist/core/tools/delegate-status.js.map +1 -1
  881. package/dist/core/tools/delegate.d.ts.map +1 -1
  882. package/dist/core/tools/delegate.js +6 -6
  883. package/dist/core/tools/delegate.js.map +1 -1
  884. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  885. package/dist/core/tools/edit-diff.js.map +1 -1
  886. package/dist/core/tools/edit.d.ts.map +1 -1
  887. package/dist/core/tools/edit.js.map +1 -1
  888. package/dist/core/tools/extensionify.d.ts.map +1 -1
  889. package/dist/core/tools/extensionify.js.map +1 -1
  890. package/dist/core/tools/fff-search-backend.d.ts +19 -0
  891. package/dist/core/tools/fff-search-backend.d.ts.map +1 -1
  892. package/dist/core/tools/fff-search-backend.js +28 -2
  893. package/dist/core/tools/fff-search-backend.js.map +1 -1
  894. package/dist/core/tools/file-encoding-policy.d.ts.map +1 -1
  895. package/dist/core/tools/file-encoding-policy.js.map +1 -1
  896. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  897. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  898. package/dist/core/tools/find.d.ts +1 -1
  899. package/dist/core/tools/find.d.ts.map +1 -1
  900. package/dist/core/tools/find.js +44 -108
  901. package/dist/core/tools/find.js.map +1 -1
  902. package/dist/core/tools/git-filter.d.ts.map +1 -1
  903. package/dist/core/tools/git-filter.js.map +1 -1
  904. package/dist/core/tools/goal.d.ts.map +1 -1
  905. package/dist/core/tools/goal.js +7 -7
  906. package/dist/core/tools/goal.js.map +1 -1
  907. package/dist/core/tools/grep.d.ts +1 -1
  908. package/dist/core/tools/grep.d.ts.map +1 -1
  909. package/dist/core/tools/grep.js +42 -102
  910. package/dist/core/tools/grep.js.map +1 -1
  911. package/dist/core/tools/index.d.ts.map +1 -1
  912. package/dist/core/tools/index.js.map +1 -1
  913. package/dist/core/tools/ls.d.ts.map +1 -1
  914. package/dist/core/tools/ls.js +20 -36
  915. package/dist/core/tools/ls.js.map +1 -1
  916. package/dist/core/tools/model-fitness.d.ts.map +1 -1
  917. package/dist/core/tools/model-fitness.js.map +1 -1
  918. package/dist/core/tools/orchestration-panel.d.ts +5 -0
  919. package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
  920. package/dist/core/tools/orchestration-panel.js +5 -5
  921. package/dist/core/tools/orchestration-panel.js.map +1 -1
  922. package/dist/core/tools/output-accumulator.d.ts +2 -0
  923. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  924. package/dist/core/tools/output-accumulator.js +24 -36
  925. package/dist/core/tools/output-accumulator.js.map +1 -1
  926. package/dist/core/tools/path-utils.d.ts.map +1 -1
  927. package/dist/core/tools/path-utils.js.map +1 -1
  928. package/dist/core/tools/persistent-process-coordinator.d.ts +31 -0
  929. package/dist/core/tools/persistent-process-coordinator.d.ts.map +1 -0
  930. package/dist/core/tools/persistent-process-coordinator.js +123 -0
  931. package/dist/core/tools/persistent-process-coordinator.js.map +1 -0
  932. package/dist/core/tools/python.d.ts.map +1 -1
  933. package/dist/core/tools/python.js.map +1 -1
  934. package/dist/core/tools/read.d.ts.map +1 -1
  935. package/dist/core/tools/read.js +14 -13
  936. package/dist/core/tools/read.js.map +1 -1
  937. package/dist/core/tools/render-utils.d.ts +29 -0
  938. package/dist/core/tools/render-utils.d.ts.map +1 -1
  939. package/dist/core/tools/render-utils.js +31 -1
  940. package/dist/core/tools/render-utils.js.map +1 -1
  941. package/dist/core/tools/run-process.d.ts.map +1 -1
  942. package/dist/core/tools/run-process.js.map +1 -1
  943. package/dist/core/tools/run-toolkit-script.d.ts.map +1 -1
  944. package/dist/core/tools/run-toolkit-script.js.map +1 -1
  945. package/dist/core/tools/search-command-guard.d.ts +10 -0
  946. package/dist/core/tools/search-command-guard.d.ts.map +1 -1
  947. package/dist/core/tools/search-command-guard.js +118 -31
  948. package/dist/core/tools/search-command-guard.js.map +1 -1
  949. package/dist/core/tools/search-router.d.ts.map +1 -1
  950. package/dist/core/tools/search-router.js.map +1 -1
  951. package/dist/core/tools/search-tool-runtime.d.ts +19 -0
  952. package/dist/core/tools/search-tool-runtime.d.ts.map +1 -0
  953. package/dist/core/tools/search-tool-runtime.js +12 -0
  954. package/dist/core/tools/search-tool-runtime.js.map +1 -0
  955. package/dist/core/tools/secret-store.d.ts.map +1 -1
  956. package/dist/core/tools/secret-store.js.map +1 -1
  957. package/dist/core/tools/shell-command-parser.d.ts.map +1 -1
  958. package/dist/core/tools/shell-command-parser.js.map +1 -1
  959. package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
  960. package/dist/core/tools/shell-contract-router.js +4 -1
  961. package/dist/core/tools/shell-contract-router.js.map +1 -1
  962. package/dist/core/tools/shell-execution-session.d.ts +4 -0
  963. package/dist/core/tools/shell-execution-session.d.ts.map +1 -0
  964. package/dist/core/tools/shell-execution-session.js +11 -0
  965. package/dist/core/tools/shell-execution-session.js.map +1 -0
  966. package/dist/core/tools/shell-output-projection.d.ts +49 -0
  967. package/dist/core/tools/shell-output-projection.d.ts.map +1 -0
  968. package/dist/core/tools/shell-output-projection.js +381 -0
  969. package/dist/core/tools/shell-output-projection.js.map +1 -0
  970. package/dist/core/tools/shell-session.d.ts +2 -13
  971. package/dist/core/tools/shell-session.d.ts.map +1 -1
  972. package/dist/core/tools/shell-session.js +36 -136
  973. package/dist/core/tools/shell-session.js.map +1 -1
  974. package/dist/core/tools/skill-audit.d.ts.map +1 -1
  975. package/dist/core/tools/skill-audit.js.map +1 -1
  976. package/dist/core/tools/skillify.d.ts.map +1 -1
  977. package/dist/core/tools/skillify.js.map +1 -1
  978. package/dist/core/tools/task-steps.d.ts +8 -8
  979. package/dist/core/tools/task-steps.d.ts.map +1 -1
  980. package/dist/core/tools/task-steps.js +17 -18
  981. package/dist/core/tools/task-steps.js.map +1 -1
  982. package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
  983. package/dist/core/tools/tmux-dispatch.js.map +1 -1
  984. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  985. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  986. package/dist/core/tools/tool-task.d.ts +23 -0
  987. package/dist/core/tools/tool-task.d.ts.map +1 -0
  988. package/dist/core/tools/tool-task.js +93 -0
  989. package/dist/core/tools/tool-task.js.map +1 -0
  990. package/dist/core/tools/windows-shell-engine.d.ts +17 -11
  991. package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
  992. package/dist/core/tools/windows-shell-engine.js +339 -117
  993. package/dist/core/tools/windows-shell-engine.js.map +1 -1
  994. package/dist/core/tools/windows-shell-state.d.ts.map +1 -1
  995. package/dist/core/tools/windows-shell-state.js.map +1 -1
  996. package/dist/core/tools/worktree-sync.d.ts.map +1 -1
  997. package/dist/core/tools/worktree-sync.js +8 -12
  998. package/dist/core/tools/worktree-sync.js.map +1 -1
  999. package/dist/core/tools/write.d.ts.map +1 -1
  1000. package/dist/core/tools/write.js +0 -1
  1001. package/dist/core/tools/write.js.map +1 -1
  1002. package/dist/core/trust-manager.d.ts.map +1 -1
  1003. package/dist/core/trust-manager.js +7 -40
  1004. package/dist/core/trust-manager.js.map +1 -1
  1005. package/dist/core/util/atomic-file.d.ts +19 -0
  1006. package/dist/core/util/atomic-file.d.ts.map +1 -1
  1007. package/dist/core/util/atomic-file.js +50 -15
  1008. package/dist/core/util/atomic-file.js.map +1 -1
  1009. package/dist/core/util/bounded-file.d.ts.map +1 -1
  1010. package/dist/core/util/bounded-file.js.map +1 -1
  1011. package/dist/core/util/bounded-jsonl.d.ts.map +1 -1
  1012. package/dist/core/util/bounded-jsonl.js +2 -9
  1013. package/dist/core/util/bounded-jsonl.js.map +1 -1
  1014. package/dist/core/util/bounded-value.d.ts.map +1 -1
  1015. package/dist/core/util/bounded-value.js.map +1 -1
  1016. package/dist/core/util/json-size.d.ts +3 -0
  1017. package/dist/core/util/json-size.d.ts.map +1 -0
  1018. package/dist/core/util/json-size.js +95 -0
  1019. package/dist/core/util/json-size.js.map +1 -0
  1020. package/dist/core/util/minimatch-cache.d.ts.map +1 -1
  1021. package/dist/core/util/minimatch-cache.js.map +1 -1
  1022. package/dist/core/util/value-guards.d.ts.map +1 -1
  1023. package/dist/core/util/value-guards.js.map +1 -1
  1024. package/dist/core/worktree-sync/codes.d.ts.map +1 -1
  1025. package/dist/core/worktree-sync/git-engine.d.ts.map +1 -1
  1026. package/dist/core/worktree-sync/git-engine.js +20 -36
  1027. package/dist/core/worktree-sync/git-engine.js.map +1 -1
  1028. package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -1
  1029. package/dist/core/worktree-sync/lane-gate.js +1 -4
  1030. package/dist/core/worktree-sync/lane-gate.js.map +1 -1
  1031. package/dist/core/worktree-sync/runtime.d.ts.map +1 -1
  1032. package/dist/core/worktree-sync/runtime.js.map +1 -1
  1033. package/dist/core/worktree-sync/store.d.ts.map +1 -1
  1034. package/dist/core/worktree-sync/store.js.map +1 -1
  1035. package/dist/core/worktree-sync/watcher.d.ts.map +1 -1
  1036. package/dist/core/worktree-sync/watcher.js.map +1 -1
  1037. package/dist/index.d.ts.map +1 -1
  1038. package/dist/index.js.map +1 -1
  1039. package/dist/main.d.ts.map +1 -1
  1040. package/dist/main.js +10 -32
  1041. package/dist/main.js.map +1 -1
  1042. package/dist/migrations.d.ts.map +1 -1
  1043. package/dist/migrations.js +6 -19
  1044. package/dist/migrations.js.map +1 -1
  1045. package/dist/modes/index.d.ts.map +1 -1
  1046. package/dist/modes/interactive/auth-dialogs-controller.d.ts +3 -0
  1047. package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
  1048. package/dist/modes/interactive/auth-dialogs-controller.js +96 -132
  1049. package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
  1050. package/dist/modes/interactive/auto-learn-controller.d.ts +1 -31
  1051. package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
  1052. package/dist/modes/interactive/auto-learn-controller.js +86 -307
  1053. package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
  1054. package/dist/modes/interactive/autocomplete-provider.d.ts.map +1 -1
  1055. package/dist/modes/interactive/autocomplete-provider.js.map +1 -1
  1056. package/dist/modes/interactive/autonomy-commands.d.ts.map +1 -1
  1057. package/dist/modes/interactive/autonomy-commands.js +2 -8
  1058. package/dist/modes/interactive/autonomy-commands.js.map +1 -1
  1059. package/dist/modes/interactive/clipboard-input.d.ts +5 -1
  1060. package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
  1061. package/dist/modes/interactive/clipboard-input.js +17 -0
  1062. package/dist/modes/interactive/clipboard-input.js.map +1 -1
  1063. package/dist/modes/interactive/compaction-queue.d.ts.map +1 -1
  1064. package/dist/modes/interactive/compaction-queue.js +13 -18
  1065. package/dist/modes/interactive/compaction-queue.js.map +1 -1
  1066. package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
  1067. package/dist/modes/interactive/components/activity-lane.js +6 -10
  1068. package/dist/modes/interactive/components/activity-lane.js.map +1 -1
  1069. package/dist/modes/interactive/components/armin.d.ts +1 -0
  1070. package/dist/modes/interactive/components/armin.d.ts.map +1 -1
  1071. package/dist/modes/interactive/components/armin.js +10 -21
  1072. package/dist/modes/interactive/components/armin.js.map +1 -1
  1073. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  1074. package/dist/modes/interactive/components/assistant-message.js +1 -6
  1075. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  1076. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  1077. package/dist/modes/interactive/components/bash-execution.js +4 -9
  1078. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  1079. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  1080. package/dist/modes/interactive/components/bordered-loader.js +0 -3
  1081. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  1082. package/dist/modes/interactive/components/branch-summary-message.d.ts +3 -8
  1083. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  1084. package/dist/modes/interactive/components/branch-summary-message.js +13 -35
  1085. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  1086. package/dist/modes/interactive/components/compaction-summary-message.d.ts +3 -8
  1087. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  1088. package/dist/modes/interactive/components/compaction-summary-message.js +14 -36
  1089. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  1090. package/dist/modes/interactive/components/config-selector.d.ts +1 -0
  1091. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  1092. package/dist/modes/interactive/components/config-selector.js +20 -43
  1093. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  1094. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  1095. package/dist/modes/interactive/components/countdown-timer.js +0 -5
  1096. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  1097. package/dist/modes/interactive/components/custom-editor.d.ts +2 -0
  1098. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  1099. package/dist/modes/interactive/components/custom-editor.js +4 -8
  1100. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  1101. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  1102. package/dist/modes/interactive/components/custom-message.js +1 -6
  1103. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  1104. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
  1105. package/dist/modes/interactive/components/daxnuts.js +6 -8
  1106. package/dist/modes/interactive/components/daxnuts.js.map +1 -1
  1107. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  1108. package/dist/modes/interactive/components/diff.js.map +1 -1
  1109. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  1110. package/dist/modes/interactive/components/dynamic-border.js +0 -1
  1111. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  1112. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
  1113. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
  1114. package/dist/modes/interactive/components/expandable-markdown-message.d.ts +21 -0
  1115. package/dist/modes/interactive/components/expandable-markdown-message.d.ts.map +1 -0
  1116. package/dist/modes/interactive/components/expandable-markdown-message.js +48 -0
  1117. package/dist/modes/interactive/components/expandable-markdown-message.js.map +1 -0
  1118. package/dist/modes/interactive/components/expandable-text.d.ts.map +1 -1
  1119. package/dist/modes/interactive/components/expandable-text.js +0 -2
  1120. package/dist/modes/interactive/components/expandable-text.js.map +1 -1
  1121. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  1122. package/dist/modes/interactive/components/extension-editor.js +1 -9
  1123. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  1124. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  1125. package/dist/modes/interactive/components/extension-input.js +2 -8
  1126. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  1127. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  1128. package/dist/modes/interactive/components/extension-selector.js +5 -20
  1129. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  1130. package/dist/modes/interactive/components/fitness-role-selector.d.ts.map +1 -1
  1131. package/dist/modes/interactive/components/fitness-role-selector.js +0 -1
  1132. package/dist/modes/interactive/components/fitness-role-selector.js.map +1 -1
  1133. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  1134. package/dist/modes/interactive/components/footer.js +1 -5
  1135. package/dist/modes/interactive/components/footer.js.map +1 -1
  1136. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  1137. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  1138. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  1139. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  1140. package/dist/modes/interactive/components/login-dialog.js +4 -10
  1141. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  1142. package/dist/modes/interactive/components/model-selector.d.ts +2 -2
  1143. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  1144. package/dist/modes/interactive/components/model-selector.js +21 -44
  1145. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  1146. package/dist/modes/interactive/components/model-suggestion-selector.d.ts.map +1 -1
  1147. package/dist/modes/interactive/components/model-suggestion-selector.js +0 -1
  1148. package/dist/modes/interactive/components/model-suggestion-selector.js.map +1 -1
  1149. package/dist/modes/interactive/components/oauth-selector.d.ts +1 -1
  1150. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  1151. package/dist/modes/interactive/components/oauth-selector.js +16 -32
  1152. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  1153. package/dist/modes/interactive/components/profile-resource-editor.d.ts +3 -4
  1154. package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
  1155. package/dist/modes/interactive/components/profile-resource-editor.js +34 -93
  1156. package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
  1157. package/dist/modes/interactive/components/profile-selector.d.ts.map +1 -1
  1158. package/dist/modes/interactive/components/profile-selector.js +0 -1
  1159. package/dist/modes/interactive/components/profile-selector.js.map +1 -1
  1160. package/dist/modes/interactive/components/scoped-models-selector.d.ts +3 -4
  1161. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  1162. package/dist/modes/interactive/components/scoped-models-selector.js +34 -79
  1163. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  1164. package/dist/modes/interactive/components/selector-list.d.ts +63 -0
  1165. package/dist/modes/interactive/components/selector-list.d.ts.map +1 -0
  1166. package/dist/modes/interactive/components/selector-list.js +186 -0
  1167. package/dist/modes/interactive/components/selector-list.js.map +1 -0
  1168. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  1169. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  1170. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  1171. package/dist/modes/interactive/components/session-selector.js +34 -59
  1172. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  1173. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  1174. package/dist/modes/interactive/components/settings-selector.js +40 -138
  1175. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  1176. package/dist/modes/interactive/components/show-images-selector.d.ts +2 -4
  1177. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  1178. package/dist/modes/interactive/components/show-images-selector.js +9 -28
  1179. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  1180. package/dist/modes/interactive/components/skill-invocation-message.d.ts +3 -8
  1181. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  1182. package/dist/modes/interactive/components/skill-invocation-message.js +12 -40
  1183. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  1184. package/dist/modes/interactive/components/theme-selector.d.ts +2 -5
  1185. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  1186. package/dist/modes/interactive/components/theme-selector.js +11 -37
  1187. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  1188. package/dist/modes/interactive/components/thinking-selector.d.ts +2 -4
  1189. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  1190. package/dist/modes/interactive/components/thinking-selector.js +9 -31
  1191. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  1192. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  1193. package/dist/modes/interactive/components/tool-execution.js +9 -28
  1194. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  1195. package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
  1196. package/dist/modes/interactive/components/tool-group.js +2 -3
  1197. package/dist/modes/interactive/components/tool-group.js.map +1 -1
  1198. package/dist/modes/interactive/components/tool-panel-registry.d.ts.map +1 -1
  1199. package/dist/modes/interactive/components/tool-panel-registry.js +5 -3
  1200. package/dist/modes/interactive/components/tool-panel-registry.js.map +1 -1
  1201. package/dist/modes/interactive/components/tool-title.d.ts.map +1 -1
  1202. package/dist/modes/interactive/components/tool-title.js +0 -4
  1203. package/dist/modes/interactive/components/tool-title.js.map +1 -1
  1204. package/dist/modes/interactive/components/transcript-pager.d.ts +26 -0
  1205. package/dist/modes/interactive/components/transcript-pager.d.ts.map +1 -0
  1206. package/dist/modes/interactive/components/transcript-pager.js +81 -0
  1207. package/dist/modes/interactive/components/transcript-pager.js.map +1 -0
  1208. package/dist/modes/interactive/components/tree-selector.d.ts +1 -12
  1209. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  1210. package/dist/modes/interactive/components/tree-selector.js +42 -402
  1211. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  1212. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
  1213. package/dist/modes/interactive/components/trust-selector.js +4 -16
  1214. package/dist/modes/interactive/components/trust-selector.js.map +1 -1
  1215. package/dist/modes/interactive/components/usage-action-selector.d.ts.map +1 -1
  1216. package/dist/modes/interactive/components/usage-action-selector.js +2 -10
  1217. package/dist/modes/interactive/components/usage-action-selector.js.map +1 -1
  1218. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  1219. package/dist/modes/interactive/components/user-message-selector.js +3 -6
  1220. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  1221. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  1222. package/dist/modes/interactive/components/user-message.js +0 -1
  1223. package/dist/modes/interactive/components/user-message.js.map +1 -1
  1224. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  1225. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  1226. package/dist/modes/interactive/config-backup.d.ts.map +1 -1
  1227. package/dist/modes/interactive/config-backup.js.map +1 -1
  1228. package/dist/modes/interactive/editor-overlay-host.d.ts.map +1 -1
  1229. package/dist/modes/interactive/editor-overlay-host.js +0 -3
  1230. package/dist/modes/interactive/editor-overlay-host.js.map +1 -1
  1231. package/dist/modes/interactive/extension-ui-host.d.ts +2 -0
  1232. package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
  1233. package/dist/modes/interactive/extension-ui-host.js +51 -72
  1234. package/dist/modes/interactive/extension-ui-host.js.map +1 -1
  1235. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  1236. package/dist/modes/interactive/external-editor.js +2 -15
  1237. package/dist/modes/interactive/external-editor.js.map +1 -1
  1238. package/dist/modes/interactive/history-reload-math.d.ts.map +1 -1
  1239. package/dist/modes/interactive/history-reload-math.js.map +1 -1
  1240. package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -1
  1241. package/dist/modes/interactive/interactive-event-controller.js +23 -16
  1242. package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
  1243. package/dist/modes/interactive/interactive-mode.d.ts +13 -4
  1244. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  1245. package/dist/modes/interactive/interactive-mode.js +126 -207
  1246. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  1247. package/dist/modes/interactive/interactive-selection-prompts.d.ts +20 -0
  1248. package/dist/modes/interactive/interactive-selection-prompts.d.ts.map +1 -0
  1249. package/dist/modes/interactive/interactive-selection-prompts.js +43 -0
  1250. package/dist/modes/interactive/interactive-selection-prompts.js.map +1 -0
  1251. package/dist/modes/interactive/key-handlers.d.ts +2 -1
  1252. package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
  1253. package/dist/modes/interactive/key-handlers.js +4 -2
  1254. package/dist/modes/interactive/key-handlers.js.map +1 -1
  1255. package/dist/modes/interactive/loaded-resources-view.d.ts.map +1 -1
  1256. package/dist/modes/interactive/loaded-resources-view.js.map +1 -1
  1257. package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
  1258. package/dist/modes/interactive/local-model-commands.js +4 -9
  1259. package/dist/modes/interactive/local-model-commands.js.map +1 -1
  1260. package/dist/modes/interactive/model-fitness-presentation.d.ts +21 -0
  1261. package/dist/modes/interactive/model-fitness-presentation.d.ts.map +1 -0
  1262. package/dist/modes/interactive/model-fitness-presentation.js +13 -0
  1263. package/dist/modes/interactive/model-fitness-presentation.js.map +1 -0
  1264. package/dist/modes/interactive/profile-menu-controller.d.ts +2 -0
  1265. package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
  1266. package/dist/modes/interactive/profile-menu-controller.js +79 -171
  1267. package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
  1268. package/dist/modes/interactive/report-commands.d.ts +2 -0
  1269. package/dist/modes/interactive/report-commands.d.ts.map +1 -1
  1270. package/dist/modes/interactive/report-commands.js +12 -6
  1271. package/dist/modes/interactive/report-commands.js.map +1 -1
  1272. package/dist/modes/interactive/resource-display.d.ts.map +1 -1
  1273. package/dist/modes/interactive/resource-display.js.map +1 -1
  1274. package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -1
  1275. package/dist/modes/interactive/resource-shell-commands.js +6 -23
  1276. package/dist/modes/interactive/resource-shell-commands.js.map +1 -1
  1277. package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
  1278. package/dist/modes/interactive/session-flow-commands.js +21 -25
  1279. package/dist/modes/interactive/session-flow-commands.js.map +1 -1
  1280. package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
  1281. package/dist/modes/interactive/session-io-commands.js.map +1 -1
  1282. package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -1
  1283. package/dist/modes/interactive/session-replacement-errors.js.map +1 -1
  1284. package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
  1285. package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
  1286. package/dist/modes/interactive/signal-lifecycle.d.ts.map +1 -1
  1287. package/dist/modes/interactive/signal-lifecycle.js.map +1 -1
  1288. package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
  1289. package/dist/modes/interactive/startup-checks.js +12 -8
  1290. package/dist/modes/interactive/startup-checks.js.map +1 -1
  1291. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  1292. package/dist/modes/interactive/theme/theme.js +10 -76
  1293. package/dist/modes/interactive/theme/theme.js.map +1 -1
  1294. package/dist/modes/interactive/usage-commands.d.ts.map +1 -1
  1295. package/dist/modes/interactive/usage-commands.js.map +1 -1
  1296. package/dist/modes/print-mode.d.ts.map +1 -1
  1297. package/dist/modes/print-mode.js +5 -22
  1298. package/dist/modes/print-mode.js.map +1 -1
  1299. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  1300. package/dist/modes/rpc/jsonl.js +1 -1
  1301. package/dist/modes/rpc/jsonl.js.map +1 -1
  1302. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  1303. package/dist/modes/rpc/rpc-client.js +7 -8
  1304. package/dist/modes/rpc/rpc-client.js.map +1 -1
  1305. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  1306. package/dist/modes/rpc/rpc-mode.js +5 -20
  1307. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  1308. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  1309. package/dist/modes/rpc/rpc-types.js.map +1 -1
  1310. package/dist/modes/termination-signals.d.ts +4 -0
  1311. package/dist/modes/termination-signals.d.ts.map +1 -0
  1312. package/dist/modes/termination-signals.js +21 -0
  1313. package/dist/modes/termination-signals.js.map +1 -0
  1314. package/dist/package-manager-cli.d.ts.map +1 -1
  1315. package/dist/package-manager-cli.js.map +1 -1
  1316. package/dist/utils/ansi-colors.d.ts +5 -0
  1317. package/dist/utils/ansi-colors.d.ts.map +1 -0
  1318. package/dist/utils/ansi-colors.js +38 -0
  1319. package/dist/utils/ansi-colors.js.map +1 -0
  1320. package/dist/utils/ansi.d.ts.map +1 -1
  1321. package/dist/utils/ansi.js.map +1 -1
  1322. package/dist/utils/changelog.d.ts.map +1 -1
  1323. package/dist/utils/changelog.js.map +1 -1
  1324. package/dist/utils/child-process.d.ts.map +1 -1
  1325. package/dist/utils/child-process.js.map +1 -1
  1326. package/dist/utils/clipboard-image.d.ts.map +1 -1
  1327. package/dist/utils/clipboard-image.js.map +1 -1
  1328. package/dist/utils/clipboard-native.d.ts.map +1 -1
  1329. package/dist/utils/clipboard-native.js.map +1 -1
  1330. package/dist/utils/clipboard.d.ts.map +1 -1
  1331. package/dist/utils/clipboard.js.map +1 -1
  1332. package/dist/utils/deprecation.d.ts.map +1 -1
  1333. package/dist/utils/deprecation.js.map +1 -1
  1334. package/dist/utils/exif-orientation.d.ts.map +1 -1
  1335. package/dist/utils/exif-orientation.js.map +1 -1
  1336. package/dist/utils/external-editor-command.d.ts.map +1 -1
  1337. package/dist/utils/external-editor-command.js.map +1 -1
  1338. package/dist/utils/frontmatter.d.ts.map +1 -1
  1339. package/dist/utils/frontmatter.js.map +1 -1
  1340. package/dist/utils/fs-watch.d.ts.map +1 -1
  1341. package/dist/utils/fs-watch.js.map +1 -1
  1342. package/dist/utils/git.d.ts.map +1 -1
  1343. package/dist/utils/git.js +20 -28
  1344. package/dist/utils/git.js.map +1 -1
  1345. package/dist/utils/highlight-js-languages.d.ts.map +1 -1
  1346. package/dist/utils/html.d.ts.map +1 -1
  1347. package/dist/utils/html.js.map +1 -1
  1348. package/dist/utils/image-convert.d.ts.map +1 -1
  1349. package/dist/utils/image-convert.js.map +1 -1
  1350. package/dist/utils/image-resize-core.d.ts.map +1 -1
  1351. package/dist/utils/image-resize-core.js.map +1 -1
  1352. package/dist/utils/image-resize-worker.d.ts.map +1 -1
  1353. package/dist/utils/image-resize-worker.js.map +1 -1
  1354. package/dist/utils/image-resize.d.ts.map +1 -1
  1355. package/dist/utils/image-resize.js.map +1 -1
  1356. package/dist/utils/json.d.ts.map +1 -1
  1357. package/dist/utils/json.js.map +1 -1
  1358. package/dist/utils/mime.d.ts.map +1 -1
  1359. package/dist/utils/mime.js.map +1 -1
  1360. package/dist/utils/open-browser.d.ts.map +1 -1
  1361. package/dist/utils/open-browser.js.map +1 -1
  1362. package/dist/utils/paths.d.ts.map +1 -1
  1363. package/dist/utils/paths.js.map +1 -1
  1364. package/dist/utils/photon.d.ts.map +1 -1
  1365. package/dist/utils/photon.js.map +1 -1
  1366. package/dist/utils/pi-user-agent.d.ts.map +1 -1
  1367. package/dist/utils/pi-user-agent.js.map +1 -1
  1368. package/dist/utils/platform.d.ts.map +1 -1
  1369. package/dist/utils/platform.js.map +1 -1
  1370. package/dist/utils/process-memory.d.ts.map +1 -1
  1371. package/dist/utils/process-memory.js.map +1 -1
  1372. package/dist/utils/safe-write-stream.d.ts.map +1 -1
  1373. package/dist/utils/safe-write-stream.js.map +1 -1
  1374. package/dist/utils/shell.d.ts.map +1 -1
  1375. package/dist/utils/shell.js.map +1 -1
  1376. package/dist/utils/sleep.d.ts.map +1 -1
  1377. package/dist/utils/sleep.js +2 -15
  1378. package/dist/utils/sleep.js.map +1 -1
  1379. package/dist/utils/stdin-events.d.ts +8 -0
  1380. package/dist/utils/stdin-events.d.ts.map +1 -0
  1381. package/dist/utils/stdin-events.js +19 -0
  1382. package/dist/utils/stdin-events.js.map +1 -0
  1383. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  1384. package/dist/utils/syntax-highlight.js +20 -13
  1385. package/dist/utils/syntax-highlight.js.map +1 -1
  1386. package/dist/utils/tools-manager.d.ts +6 -1
  1387. package/dist/utils/tools-manager.d.ts.map +1 -1
  1388. package/dist/utils/tools-manager.js +59 -2
  1389. package/dist/utils/tools-manager.js.map +1 -1
  1390. package/dist/utils/version-check.d.ts.map +1 -1
  1391. package/dist/utils/version-check.js.map +1 -1
  1392. package/dist/utils/windows-self-update.d.ts.map +1 -1
  1393. package/dist/utils/windows-self-update.js.map +1 -1
  1394. package/dist/utils/work-directory.d.ts.map +1 -1
  1395. package/dist/utils/work-directory.js.map +1 -1
  1396. package/docs/compaction.md +11 -3
  1397. package/docs/development.md +1 -1
  1398. package/docs/sessions.md +6 -0
  1399. package/docs/settings.md +1 -1
  1400. package/docs/windows.md +28 -3
  1401. package/docs/work-directory.md +10 -2
  1402. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  1403. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  1404. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  1405. package/examples/extensions/sandbox/package-lock.json +2 -2
  1406. package/examples/extensions/sandbox/package.json +1 -1
  1407. package/examples/extensions/with-deps/package-lock.json +2 -2
  1408. package/examples/extensions/with-deps/package.json +1 -1
  1409. package/npm-shrinkwrap.json +27 -27
  1410. package/package.json +11 -11
  1411. package/dist/utils/streaming-lines.d.ts +0 -20
  1412. package/dist/utils/streaming-lines.d.ts.map +0 -1
  1413. package/dist/utils/streaming-lines.js +0 -79
  1414. package/dist/utils/streaming-lines.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"profile-registry.js","sourceRoot":"","sources":["../../../src/core/orchestration/profile-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC7G,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAWrE,OAAO,EACN,oBAAoB,EACpB,mCAAmC,EACnC,oCAAoC,EACpC,8CAA8C,EAC9C,mCAAmC,EACnC,iCAAiC,EACjC,uCAAuC,EACvC,sCAAsC,EACtC,gCAAgC,EAChC,4BAA4B,EAC5B,6BAA6B,EAC7B,YAAY,EACZ,YAAY,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE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AO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC;AAAA,CACpH","sourcesContent":["import { describeToolCapabilityAuthority, resolveProfileToolCapability } from \"../tool-capability-policy.ts\";\nimport { hasOnlyKeys, isPlainRecord } from \"../util/value-guards.ts\";\nimport type {\n\tExecutionGrant,\n\tOrchestrationDispatchRequest,\n\tOrchestrationModelBinding,\n\tOrchestrationProfile,\n\tResourcePointer,\n\tRiskBudget,\n\tTaskContract,\n\tToolCapabilityManifest,\n} from \"./contracts.ts\";\nimport {\n\tHARNESS_CAPABILITIES,\n\tMAX_ORCHESTRATION_COLLECTION_LENGTH,\n\tMAX_ORCHESTRATION_DESCRIPTION_LENGTH,\n\tMAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH,\n\tMAX_ORCHESTRATION_IDENTIFIER_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_ID_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\tMAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES,\n\tMAX_WORKER_AUTHORITY_PATH_LENGTH,\n\tORCHESTRATION_SCHEMA_VERSION,\n\tORCHESTRATION_THINKING_LEVELS,\n\ttoJsonObject,\n\tWORKER_ROLES,\n} from \"./contracts.ts\";\nimport { ORCHESTRATION_PROFILE_TOOL_NAMES } from \"./lane-tool-manifests.ts\";\nimport {\n\ttype CompileExecutionGrantInput,\n\tDEFAULT_ROLE_CAPABILITY_CEILINGS,\n\ttype ExecutionPolicyCompiler,\n\ttype PolicyCompilationResult,\n} from \"./policy-compiler.ts\";\nimport { parseRiskBudget, validateRiskBudget } from \"./risk-budget.ts\";\n\nexport interface ModelHealthView {\n\tisHealthy(binding: OrchestrationModelBinding): boolean;\n}\n\nexport interface ProfileDispatchPlan {\n\tprofile: OrchestrationProfile;\n\tmodel: OrchestrationModelBinding;\n\tgrant: ExecutionGrant;\n\ttoolManifests: readonly ToolCapabilityManifest[];\n}\n\nexport type ProfileDispatchPlanResult =\n\t| { outcome: \"allow\"; plan: ProfileDispatchPlan }\n\t| Exclude<PolicyCompilationResult, { outcome: \"allow\" }>\n\t| { outcome: \"deny\"; decisions: readonly []; reasonCodes: readonly [\"profile_model_unavailable\"] };\n\nexport class OrchestrationProfileError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"OrchestrationProfileError\";\n\t}\n}\n\nfunction duplicateStrings(values: readonly string[]): string[] {\n\tconst seen = new Set<string>();\n\tconst duplicates = new Set<string>();\n\tfor (const value of values) {\n\t\tif (seen.has(value)) duplicates.add(value);\n\t\tseen.add(value);\n\t}\n\treturn [...duplicates];\n}\n\nexport function parseOrchestrationDispatchRequest(value: unknown): OrchestrationDispatchRequest {\n\tif (!isPlainRecord(value)) throw new OrchestrationProfileError(\"Dispatch request must be an object.\");\n\tif (!hasOnlyKeys(value, [\"taskId\", \"profileId\", \"instructions\", \"resourcePointerIds\"])) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t\"Dispatch request contains an unsupported field. Model and thinking overrides are forbidden; select a profileId.\",\n\t\t);\n\t}\n\tif (\n\t\ttypeof value.taskId !== \"string\" ||\n\t\t!value.taskId ||\n\t\tvalue.taskId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.profileId !== \"string\" ||\n\t\t!value.profileId ||\n\t\tvalue.profileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.instructions !== \"string\" ||\n\t\tvalue.instructions.length > MAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH ||\n\t\t!value.instructions.trim() ||\n\t\t!Array.isArray(value.resourcePointerIds) ||\n\t\tvalue.resourcePointerIds.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t!value.resourcePointerIds.every(\n\t\t\t(entry) =>\n\t\t\t\ttypeof entry === \"string\" && entry.length > 0 && entry.length <= MAX_ORCHESTRATION_IDENTIFIER_LENGTH,\n\t\t) ||\n\t\tnew Set(value.resourcePointerIds).size !== value.resourcePointerIds.length\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Dispatch request is invalid.\");\n\t}\n\treturn {\n\t\ttaskId: value.taskId,\n\t\tprofileId: value.profileId,\n\t\tinstructions: value.instructions.trim(),\n\t\tresourcePointerIds: [...value.resourcePointerIds],\n\t};\n}\n\nexport function validateOrchestrationProfile(profile: OrchestrationProfile): void {\n\tif (profile.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' has an unsupported schema version.`);\n\t}\n\tif (\n\t\tprofile.profileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\t!profile.profileId.trim() ||\n\t\tprofile.description.length > MAX_ORCHESTRATION_DESCRIPTION_LENGTH ||\n\t\t!profile.description.trim()\n\t)\n\t\tthrow new OrchestrationProfileError(\"Profile id and description are required.\");\n\tif (profile.role !== \"orchestrator\" && profile.dispatchProfileIds.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Only orchestrator profiles may declare dispatchProfileIds ('${profile.profileId}').`,\n\t\t);\n\t}\n\tif (profile.dispatchProfileIds.includes(profile.profileId)) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' cannot dispatch itself.`);\n\t}\n\tif (profile.requireIndependentVerification) {\n\t\tif (profile.role === \"verifier\") {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Verifier profile '${profile.profileId}' cannot require another verifier.`,\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t!profile.verificationProfileId?.trim() ||\n\t\t\tprofile.verificationProfileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Profile '${profile.profileId}' requires independent verification but has no verificationProfileId.`,\n\t\t\t);\n\t\t}\n\t} else if (profile.verificationProfileId !== undefined) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' cannot declare verificationProfileId without requiring verification.`,\n\t\t);\n\t}\n\tif (profile.verificationProfileId === profile.profileId) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' cannot verify itself.`);\n\t}\n\tif (\n\t\t!profile.createdAt.trim() ||\n\t\tprofile.createdAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\t!profile.updatedAt.trim() ||\n\t\tprofile.updatedAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' timestamps are invalid.`);\n\t}\n\tfor (const [label, values] of [\n\t\t[\"capabilityCeiling\", profile.capabilityCeiling],\n\t\t[\"toolNames\", profile.toolNames],\n\t\t[\"resourceProfileNames\", profile.resourceProfileNames],\n\t\t[\"dispatchProfileIds\", profile.dispatchProfileIds],\n\t] as const) {\n\t\tif (\n\t\t\tvalues.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t\tvalues.some((value) => !value.trim() || value.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH)\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' contains an invalid ${label}.`);\n\t\t}\n\t\tconst duplicates = duplicateStrings(values);\n\t\tif (duplicates.length > 0) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Profile '${profile.profileId}' contains duplicate ${label}: ${duplicates.join(\", \")}.`,\n\t\t\t);\n\t\t}\n\t}\n\tconst roleCeiling = new Set(DEFAULT_ROLE_CAPABILITY_CEILINGS[profile.role]);\n\tconst outOfRoleCapabilities = profile.capabilityCeiling.filter((capability) => !roleCeiling.has(capability));\n\tif (outOfRoleCapabilities.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' exceeds the ${profile.role} role ceiling: ${outOfRoleCapabilities.join(\", \")}.`,\n\t\t);\n\t}\n\tif (\n\t\tprofile.modelPolicy.candidates.length === 0 ||\n\t\tprofile.modelPolicy.candidates.length > MAX_ORCHESTRATION_COLLECTION_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' must declare a model candidate.`);\n\t}\n\tif (profile.modelPolicy.mode === \"fixed\" && profile.modelPolicy.candidates.length !== 1) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Fixed profile '${profile.profileId}' must declare exactly one model candidate.`,\n\t\t);\n\t}\n\tfor (const candidate of profile.modelPolicy.candidates) {\n\t\tif (\n\t\t\tcandidate.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t\t!candidate.provider.trim() ||\n\t\t\tcandidate.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH ||\n\t\t\t!candidate.modelId.trim()\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' contains an invalid model binding.`);\n\t\t}\n\t}\n\tconst duplicateModels = duplicateStrings(\n\t\tprofile.modelPolicy.candidates.map((candidate) => `${candidate.provider}/${candidate.modelId}`),\n\t);\n\tif (duplicateModels.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' contains duplicate model candidates: ${duplicateModels.join(\", \")}.`,\n\t\t);\n\t}\n\tif (!Number.isSafeInteger(profile.maxConcurrent) || profile.maxConcurrent <= 0) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' maxConcurrent must be positive.`);\n\t}\n\tif (!Number.isSafeInteger(profile.leaseTtlMs) || profile.leaseTtlMs <= 0) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' leaseTtlMs must be positive.`);\n\t}\n\ttry {\n\t\tvalidateRiskBudget(profile.budget, `Profile '${profile.profileId}' budget`);\n\t} catch (error) {\n\t\tthrow new OrchestrationProfileError(error instanceof Error ? error.message : String(error));\n\t}\n\tif (profile.budget.maxWallClockMs !== undefined && profile.budget.maxWallClockMs <= 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' maxWallClockMs budget must be positive when specified.`,\n\t\t);\n\t}\n\tif (profile.budget.maxWallClockMs !== undefined && profile.leaseTtlMs < profile.budget.maxWallClockMs) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' leaseTtlMs must cover its maxWallClockMs budget.`,\n\t\t);\n\t}\n\tconst processCapable =\n\t\tprofile.capabilityCeiling.includes(\"process.exec\") || profile.capabilityCeiling.includes(\"tests.execute\");\n\tif (processCapable && (!profile.executionPolicy || profile.executionPolicy.allowedExecutables.length === 0)) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' must declare executionPolicy.allowedExecutables for process capabilities.`,\n\t\t);\n\t}\n\tif (!processCapable && profile.executionPolicy) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' cannot declare executionPolicy without process capabilities.`,\n\t\t);\n\t}\n\tif (profile.executionPolicy) {\n\t\tif (\n\t\t\tprofile.executionPolicy.allowedExecutables.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t\tprofile.executionPolicy.allowedEnvironmentVariables.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t\tprofile.executionPolicy.allowedExecutables.some(\n\t\t\t\t(executable) =>\n\t\t\t\t\t!executable.trim() ||\n\t\t\t\t\texecutable.length > MAX_WORKER_AUTHORITY_PATH_LENGTH ||\n\t\t\t\t\t/[\\0\\r\\n]/.test(executable),\n\t\t\t) ||\n\t\t\tprofile.executionPolicy.allowedEnvironmentVariables.some(\n\t\t\t\t(name) => name.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(name),\n\t\t\t) ||\n\t\t\t!Number.isSafeInteger(profile.executionPolicy.maxOutputBytes) ||\n\t\t\tprofile.executionPolicy.maxOutputBytes <= 0 ||\n\t\t\tprofile.executionPolicy.maxOutputBytes > MAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' executionPolicy is invalid.`);\n\t\t}\n\t}\n\tconst unrestrictedProcessTools = profile.toolNames.filter((toolName) =>\n\t\t[\"bash\", \"python\", \"powershell\", \"run_toolkit_script\"].includes(toolName),\n\t);\n\tif (unrestrictedProcessTools.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' cannot expose unrestricted process tools (${unrestrictedProcessTools.join(\", \")}); use run_process with executionPolicy.`,\n\t\t);\n\t}\n\tconst unknownTools = profile.toolNames.filter(\n\t\t(toolName) => !(ORCHESTRATION_PROFILE_TOOL_NAMES as readonly string[]).includes(toolName),\n\t);\n\tif (unknownTools.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' contains unclassified orchestration tools: ${unknownTools.join(\", \")}.`,\n\t\t);\n\t}\n\tfor (const toolName of profile.toolNames) {\n\t\tif (!resolveProfileToolCapability(profile, toolName)) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Profile '${profile.profileId}' tool '${toolName}' lacks ${describeToolCapabilityAuthority(toolName)} authority.`,\n\t\t\t);\n\t\t}\n\t}\n\ttoJsonObject({ profile });\n}\n\nfunction isStringArray(value: unknown, maxLength = MAX_ORCHESTRATION_IDENTIFIER_LENGTH): value is string[] {\n\treturn (\n\t\tArray.isArray(value) &&\n\t\tvalue.length <= MAX_ORCHESTRATION_COLLECTION_LENGTH &&\n\t\tvalue.every((entry) => typeof entry === \"string\" && entry.length > 0 && entry.length <= maxLength)\n\t);\n}\n\nexport function parseOrchestrationProfile(value: unknown, sourcePath?: string): OrchestrationProfile {\n\tif (!isPlainRecord(value)) throw new OrchestrationProfileError(\"Orchestration profile must be an object.\");\n\tif (\n\t\t!hasOnlyKeys(value, [\n\t\t\t\"schemaVersion\",\n\t\t\t\"profileId\",\n\t\t\t\"description\",\n\t\t\t\"role\",\n\t\t\t\"modelPolicy\",\n\t\t\t\"capabilityCeiling\",\n\t\t\t\"toolNames\",\n\t\t\t\"resourceProfileNames\",\n\t\t\t\"dispatchProfileIds\",\n\t\t\t\"executionPolicy\",\n\t\t\t\"budget\",\n\t\t\t\"maxConcurrent\",\n\t\t\t\"leaseTtlMs\",\n\t\t\t\"requireIndependentVerification\",\n\t\t\t\"verificationProfileId\",\n\t\t\t\"createdAt\",\n\t\t\t\"updatedAt\",\n\t\t])\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile contains an unsupported field.\");\n\t}\n\tconst modelPolicy = value.modelPolicy;\n\tconst rawBudget = value.budget;\n\tlet budget: RiskBudget;\n\tconst executionPolicy = value.executionPolicy;\n\tif (\n\t\t!isPlainRecord(modelPolicy) ||\n\t\t!hasOnlyKeys(modelPolicy, [\"mode\", \"candidates\"]) ||\n\t\t!Array.isArray(modelPolicy.candidates) ||\n\t\tmodelPolicy.candidates.length > MAX_ORCHESTRATION_COLLECTION_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile modelPolicy is invalid.\");\n\t}\n\ttry {\n\t\tbudget = parseRiskBudget(rawBudget, \"Orchestration profile budget\");\n\t} catch (error) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\terror instanceof Error ? error.message : \"Orchestration profile budget is invalid.\",\n\t\t);\n\t}\n\tif (\n\t\texecutionPolicy !== undefined &&\n\t\t(!isPlainRecord(executionPolicy) ||\n\t\t\t!hasOnlyKeys(executionPolicy, [\"allowedExecutables\", \"allowedEnvironmentVariables\", \"maxOutputBytes\"]) ||\n\t\t\t!isStringArray(executionPolicy.allowedExecutables, MAX_WORKER_AUTHORITY_PATH_LENGTH) ||\n\t\t\t!isStringArray(executionPolicy.allowedEnvironmentVariables) ||\n\t\t\t!Number.isSafeInteger(executionPolicy.maxOutputBytes))\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile executionPolicy is invalid.\");\n\t}\n\tconst candidates = modelPolicy.candidates.map((candidate) => {\n\t\tif (!isPlainRecord(candidate) || !hasOnlyKeys(candidate, [\"provider\", \"modelId\", \"thinkingLevel\"])) {\n\t\t\tthrow new OrchestrationProfileError(\"Orchestration profile model candidate is invalid.\");\n\t\t}\n\t\tif (\n\t\t\ttypeof candidate.provider !== \"string\" ||\n\t\t\tcandidate.provider.length === 0 ||\n\t\t\tcandidate.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t\ttypeof candidate.modelId !== \"string\" ||\n\t\t\tcandidate.modelId.length === 0 ||\n\t\t\tcandidate.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH ||\n\t\t\ttypeof candidate.thinkingLevel !== \"string\" ||\n\t\t\t!ORCHESTRATION_THINKING_LEVELS.includes(\n\t\t\t\tcandidate.thinkingLevel as (typeof ORCHESTRATION_THINKING_LEVELS)[number],\n\t\t\t)\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(\"Orchestration profile model candidate is invalid.\");\n\t\t}\n\t\treturn {\n\t\t\tprovider: candidate.provider,\n\t\t\tmodelId: candidate.modelId,\n\t\t\tthinkingLevel: candidate.thinkingLevel as (typeof ORCHESTRATION_THINKING_LEVELS)[number],\n\t\t};\n\t});\n\tif (\n\t\tvalue.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION ||\n\t\ttypeof value.profileId !== \"string\" ||\n\t\tvalue.profileId.length === 0 ||\n\t\tvalue.profileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.description !== \"string\" ||\n\t\tvalue.description.length === 0 ||\n\t\tvalue.description.length > MAX_ORCHESTRATION_DESCRIPTION_LENGTH ||\n\t\ttypeof value.role !== \"string\" ||\n\t\t!WORKER_ROLES.includes(value.role as (typeof WORKER_ROLES)[number]) ||\n\t\t(modelPolicy.mode !== \"fixed\" && modelPolicy.mode !== \"ordered-fallback\") ||\n\t\t!Array.isArray(value.capabilityCeiling) ||\n\t\tvalue.capabilityCeiling.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t!value.capabilityCeiling.every(\n\t\t\t(capability) =>\n\t\t\t\ttypeof capability === \"string\" &&\n\t\t\t\tHARNESS_CAPABILITIES.includes(capability as (typeof HARNESS_CAPABILITIES)[number]),\n\t\t) ||\n\t\t!isStringArray(value.toolNames) ||\n\t\t!isStringArray(value.resourceProfileNames) ||\n\t\t!isStringArray(value.dispatchProfileIds) ||\n\t\t!Number.isSafeInteger(value.maxConcurrent) ||\n\t\t!Number.isSafeInteger(value.leaseTtlMs) ||\n\t\ttypeof value.requireIndependentVerification !== \"boolean\" ||\n\t\t(value.verificationProfileId !== undefined &&\n\t\t\t(typeof value.verificationProfileId !== \"string\" ||\n\t\t\t\tvalue.verificationProfileId.length === 0 ||\n\t\t\t\tvalue.verificationProfileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH)) ||\n\t\ttypeof value.createdAt !== \"string\" ||\n\t\tvalue.createdAt.length === 0 ||\n\t\tvalue.createdAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.updatedAt !== \"string\" ||\n\t\tvalue.updatedAt.length === 0 ||\n\t\tvalue.updatedAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile is invalid.\");\n\t}\n\tconst profile = structuredClone({\n\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\tprofileId: value.profileId,\n\t\tdescription: value.description,\n\t\trole: value.role as OrchestrationProfile[\"role\"],\n\t\tmodelPolicy: { mode: modelPolicy.mode as OrchestrationProfile[\"modelPolicy\"][\"mode\"], candidates },\n\t\tcapabilityCeiling: value.capabilityCeiling as OrchestrationProfile[\"capabilityCeiling\"],\n\t\ttoolNames: value.toolNames,\n\t\tresourceProfileNames: value.resourceProfileNames,\n\t\tdispatchProfileIds: value.dispatchProfileIds,\n\t\t...(executionPolicy\n\t\t\t? {\n\t\t\t\t\texecutionPolicy: {\n\t\t\t\t\t\tallowedExecutables: executionPolicy.allowedExecutables as string[],\n\t\t\t\t\t\tallowedEnvironmentVariables: executionPolicy.allowedEnvironmentVariables as string[],\n\t\t\t\t\t\tmaxOutputBytes: Number(executionPolicy.maxOutputBytes),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t\tbudget,\n\t\tmaxConcurrent: Number(value.maxConcurrent),\n\t\tleaseTtlMs: Number(value.leaseTtlMs),\n\t\trequireIndependentVerification: value.requireIndependentVerification,\n\t\t...(typeof value.verificationProfileId === \"string\"\n\t\t\t? { verificationProfileId: value.verificationProfileId }\n\t\t\t: {}),\n\t\t...(sourcePath ? { sourcePath } : {}),\n\t\tcreatedAt: value.createdAt,\n\t\tupdatedAt: value.updatedAt,\n\t}) as OrchestrationProfile;\n\tvalidateOrchestrationProfile(profile);\n\treturn profile;\n}\n\nfunction freezeProfile(profile: OrchestrationProfile): OrchestrationProfile {\n\tconst clone = structuredClone(profile);\n\tfor (const candidate of clone.modelPolicy.candidates) Object.freeze(candidate);\n\tObject.freeze(clone.modelPolicy.candidates);\n\tObject.freeze(clone.modelPolicy);\n\tObject.freeze(clone.capabilityCeiling);\n\tObject.freeze(clone.toolNames);\n\tObject.freeze(clone.resourceProfileNames);\n\tObject.freeze(clone.dispatchProfileIds);\n\tif (clone.executionPolicy) {\n\t\tObject.freeze(clone.executionPolicy.allowedExecutables);\n\t\tObject.freeze(clone.executionPolicy.allowedEnvironmentVariables);\n\t\tObject.freeze(clone.executionPolicy);\n\t}\n\tObject.freeze(clone.budget);\n\treturn Object.freeze(clone);\n}\n\nexport class OrchestrationProfileRegistry {\n\tprivate readonly profiles = new Map<string, OrchestrationProfile>();\n\n\tconstructor(profiles: readonly OrchestrationProfile[] = []) {\n\t\tfor (const profile of profiles) this.register(profile);\n\t\tfor (const profile of this.profiles.values()) {\n\t\t\tfor (const dispatchedProfileId of profile.dispatchProfileIds) {\n\t\t\t\tconst target = this.profiles.get(dispatchedProfileId);\n\t\t\t\tif (!target) {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' dispatches missing profile '${dispatchedProfileId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (target.role === \"orchestrator\") {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' cannot recursively dispatch orchestrator '${dispatchedProfileId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (profile.verificationProfileId) {\n\t\t\t\tconst verifier = this.profiles.get(profile.verificationProfileId);\n\t\t\t\tif (!verifier) {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' requires missing verifier profile '${profile.verificationProfileId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (verifier.role !== \"verifier\") {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' verificationProfileId '${profile.verificationProfileId}' is not a verifier.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (profile.role === \"orchestrator\") {\n\t\t\t\tfor (const dispatchedProfileId of profile.dispatchProfileIds) {\n\t\t\t\t\tconst worker = this.profiles.get(dispatchedProfileId);\n\t\t\t\t\tif (\n\t\t\t\t\t\tworker?.verificationProfileId &&\n\t\t\t\t\t\t!profile.dispatchProfileIds.includes(worker.verificationProfileId)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t\t`Orchestrator '${profile.profileId}' dispatches '${worker.profileId}' but not its verifier '${worker.verificationProfileId}'.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tregister(profile: OrchestrationProfile): void {\n\t\tvalidateOrchestrationProfile(profile);\n\t\tif (this.profiles.has(profile.profileId)) {\n\t\t\tthrow new OrchestrationProfileError(`Duplicate orchestration profile '${profile.profileId}'.`);\n\t\t}\n\t\tthis.profiles.set(profile.profileId, freezeProfile(profile));\n\t}\n\n\tget(profileId: string): OrchestrationProfile | undefined {\n\t\tconst profile = this.profiles.get(profileId);\n\t\treturn profile ? structuredClone(profile) : undefined;\n\t}\n\n\tlist(): OrchestrationProfile[] {\n\t\treturn [...this.profiles.values()].map((profile) => structuredClone(profile));\n\t}\n}\n\nexport function resolveProfileModel(\n\tprofile: OrchestrationProfile,\n\thealth: ModelHealthView,\n): OrchestrationModelBinding | undefined {\n\tif (profile.modelPolicy.mode === \"fixed\") {\n\t\tconst fixed = profile.modelPolicy.candidates[0];\n\t\treturn fixed && health.isHealthy(fixed) ? structuredClone(fixed) : undefined;\n\t}\n\tconst selected = profile.modelPolicy.candidates.find((candidate) => health.isHealthy(candidate));\n\treturn selected ? structuredClone(selected) : undefined;\n}\n\nexport function planProfileDispatch(args: {\n\trequest: OrchestrationDispatchRequest;\n\ttask: TaskContract;\n\tattemptId: string;\n\tsubjectId: string;\n\tregistry: OrchestrationProfileRegistry;\n\thealth: ModelHealthView;\n\tpolicyCompiler: ExecutionPolicyCompiler;\n\ttoolManifests: readonly ToolCapabilityManifest[];\n\tresources: readonly ResourcePointer[];\n\treadPaths: readonly string[];\n\twritePaths?: readonly string[];\n\tdeniedPaths?: readonly string[];\n\tpolicyVersion: string;\n}): ProfileDispatchPlanResult {\n\tconst profile = args.registry.get(args.request.profileId);\n\tif (!profile) return { outcome: \"deny\", decisions: [], reasonCodes: [\"profile_model_unavailable\"] };\n\tif (profile.role !== args.task.role) {\n\t\treturn { outcome: \"deny\", decisions: [], reasonCodes: [\"required_capability_exceeds_role_ceiling\"] };\n\t}\n\tconst model = resolveProfileModel(profile, args.health);\n\tif (!model) return { outcome: \"deny\", decisions: [], reasonCodes: [\"profile_model_unavailable\"] };\n\tconst selectedResources = args.resources.filter((resource) => args.request.resourcePointerIds.includes(resource.id));\n\tconst manifestsByName = new Map(args.toolManifests.map((manifest) => [manifest.toolName, manifest]));\n\tconst requestedTools = profile.toolNames.filter((toolName) => {\n\t\tconst manifest = manifestsByName.get(toolName);\n\t\treturn manifest?.capabilities.every((capability) => args.task.requiredCapabilities.includes(capability)) === true;\n\t});\n\tconst policyInput: CompileExecutionGrantInput = {\n\t\tobjectiveId: args.task.objectiveId,\n\t\ttaskId: args.task.taskId,\n\t\tattemptId: args.attemptId,\n\t\tsubjectId: args.subjectId,\n\t\trole: profile.role,\n\t\trequiredCapabilities: args.task.requiredCapabilities,\n\t\trequestedCapabilities: args.task.requiredCapabilities,\n\t\tauthorityCapabilities: profile.capabilityCeiling,\n\t\trequestedTools,\n\t\ttoolManifests: args.toolManifests,\n\t\tresources: selectedResources,\n\t\treadPaths: args.readPaths,\n\t\twritePaths: args.writePaths,\n\t\tdeniedPaths: args.deniedPaths,\n\t\trequestedBudget: profile.budget,\n\t\tauthorityBudget: profile.budget,\n\t\tpolicyVersion: args.policyVersion,\n\t};\n\tconst compiled = args.policyCompiler.compile(policyInput);\n\tif (compiled.outcome !== \"allow\") return compiled;\n\treturn { outcome: \"allow\", plan: { profile, model, grant: compiled.grant, toolManifests: compiled.toolManifests } };\n}\n"]}
1
+ {"version":3,"file":"profile-registry.js","sourceRoot":"","sources":["../../../src/core/orchestration/profile-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC7G,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAWrE,OAAO,EACN,oBAAoB,EACpB,mCAAmC,EACnC,oCAAoC,EACpC,8CAA8C,EAC9C,mCAAmC,EACnC,iCAAiC,EACjC,uCAAuC,EACvC,sCAAsC,EACtC,gCAAgC,EAChC,4BAA4B,EAC5B,6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AE,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC;AACrH,CAAC","sourcesContent":["import { describeToolCapabilityAuthority, resolveProfileToolCapability } from \"../tool-capability-policy.ts\";\nimport { hasOnlyKeys, isPlainRecord } from \"../util/value-guards.ts\";\nimport type {\n\tExecutionGrant,\n\tOrchestrationDispatchRequest,\n\tOrchestrationModelBinding,\n\tOrchestrationProfile,\n\tResourcePointer,\n\tRiskBudget,\n\tTaskContract,\n\tToolCapabilityManifest,\n} from \"./contracts.ts\";\nimport {\n\tHARNESS_CAPABILITIES,\n\tMAX_ORCHESTRATION_COLLECTION_LENGTH,\n\tMAX_ORCHESTRATION_DESCRIPTION_LENGTH,\n\tMAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH,\n\tMAX_ORCHESTRATION_IDENTIFIER_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_ID_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\tMAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES,\n\tMAX_WORKER_AUTHORITY_PATH_LENGTH,\n\tORCHESTRATION_SCHEMA_VERSION,\n\tORCHESTRATION_THINKING_LEVELS,\n\ttoJsonObject,\n\tWORKER_ROLES,\n} from \"./contracts.ts\";\nimport { ORCHESTRATION_PROFILE_TOOL_NAMES } from \"./lane-tool-manifests.ts\";\nimport {\n\ttype CompileExecutionGrantInput,\n\tDEFAULT_ROLE_CAPABILITY_CEILINGS,\n\ttype ExecutionPolicyCompiler,\n\ttype PolicyCompilationResult,\n} from \"./policy-compiler.ts\";\nimport { parseRiskBudget, validateRiskBudget } from \"./risk-budget.ts\";\n\nexport interface ModelHealthView {\n\tisHealthy(binding: OrchestrationModelBinding): boolean;\n}\n\nexport interface ProfileDispatchPlan {\n\tprofile: OrchestrationProfile;\n\tmodel: OrchestrationModelBinding;\n\tgrant: ExecutionGrant;\n\ttoolManifests: readonly ToolCapabilityManifest[];\n}\n\nexport type ProfileDispatchPlanResult =\n\t| { outcome: \"allow\"; plan: ProfileDispatchPlan }\n\t| Exclude<PolicyCompilationResult, { outcome: \"allow\" }>\n\t| { outcome: \"deny\"; decisions: readonly []; reasonCodes: readonly [\"profile_model_unavailable\"] };\n\nexport class OrchestrationProfileError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"OrchestrationProfileError\";\n\t}\n}\n\nfunction duplicateStrings(values: readonly string[]): string[] {\n\tconst seen = new Set<string>();\n\tconst duplicates = new Set<string>();\n\tfor (const value of values) {\n\t\tif (seen.has(value)) duplicates.add(value);\n\t\tseen.add(value);\n\t}\n\treturn [...duplicates];\n}\n\nexport function parseOrchestrationDispatchRequest(value: unknown): OrchestrationDispatchRequest {\n\tif (!isPlainRecord(value)) throw new OrchestrationProfileError(\"Dispatch request must be an object.\");\n\tif (!hasOnlyKeys(value, [\"taskId\", \"profileId\", \"instructions\", \"resourcePointerIds\"])) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t\"Dispatch request contains an unsupported field. Model and thinking overrides are forbidden; select a profileId.\",\n\t\t);\n\t}\n\tif (\n\t\ttypeof value.taskId !== \"string\" ||\n\t\t!value.taskId ||\n\t\tvalue.taskId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.profileId !== \"string\" ||\n\t\t!value.profileId ||\n\t\tvalue.profileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.instructions !== \"string\" ||\n\t\tvalue.instructions.length > MAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH ||\n\t\t!value.instructions.trim() ||\n\t\t!Array.isArray(value.resourcePointerIds) ||\n\t\tvalue.resourcePointerIds.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t!value.resourcePointerIds.every(\n\t\t\t(entry) =>\n\t\t\t\ttypeof entry === \"string\" && entry.length > 0 && entry.length <= MAX_ORCHESTRATION_IDENTIFIER_LENGTH,\n\t\t) ||\n\t\tnew Set(value.resourcePointerIds).size !== value.resourcePointerIds.length\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Dispatch request is invalid.\");\n\t}\n\treturn {\n\t\ttaskId: value.taskId,\n\t\tprofileId: value.profileId,\n\t\tinstructions: value.instructions.trim(),\n\t\tresourcePointerIds: [...value.resourcePointerIds],\n\t};\n}\n\nexport function validateOrchestrationProfile(profile: OrchestrationProfile): void {\n\tif (profile.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' has an unsupported schema version.`);\n\t}\n\tif (\n\t\tprofile.profileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\t!profile.profileId.trim() ||\n\t\tprofile.description.length > MAX_ORCHESTRATION_DESCRIPTION_LENGTH ||\n\t\t!profile.description.trim()\n\t)\n\t\tthrow new OrchestrationProfileError(\"Profile id and description are required.\");\n\tif (profile.role !== \"orchestrator\" && profile.dispatchProfileIds.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Only orchestrator profiles may declare dispatchProfileIds ('${profile.profileId}').`,\n\t\t);\n\t}\n\tif (profile.dispatchProfileIds.includes(profile.profileId)) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' cannot dispatch itself.`);\n\t}\n\tif (profile.requireIndependentVerification) {\n\t\tif (profile.role === \"verifier\") {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Verifier profile '${profile.profileId}' cannot require another verifier.`,\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t!profile.verificationProfileId?.trim() ||\n\t\t\tprofile.verificationProfileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Profile '${profile.profileId}' requires independent verification but has no verificationProfileId.`,\n\t\t\t);\n\t\t}\n\t} else if (profile.verificationProfileId !== undefined) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' cannot declare verificationProfileId without requiring verification.`,\n\t\t);\n\t}\n\tif (profile.verificationProfileId === profile.profileId) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' cannot verify itself.`);\n\t}\n\tif (\n\t\t!profile.createdAt.trim() ||\n\t\tprofile.createdAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\t!profile.updatedAt.trim() ||\n\t\tprofile.updatedAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' timestamps are invalid.`);\n\t}\n\tfor (const [label, values] of [\n\t\t[\"capabilityCeiling\", profile.capabilityCeiling],\n\t\t[\"toolNames\", profile.toolNames],\n\t\t[\"resourceProfileNames\", profile.resourceProfileNames],\n\t\t[\"dispatchProfileIds\", profile.dispatchProfileIds],\n\t] as const) {\n\t\tif (\n\t\t\tvalues.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t\tvalues.some((value) => !value.trim() || value.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH)\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' contains an invalid ${label}.`);\n\t\t}\n\t\tconst duplicates = duplicateStrings(values);\n\t\tif (duplicates.length > 0) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Profile '${profile.profileId}' contains duplicate ${label}: ${duplicates.join(\", \")}.`,\n\t\t\t);\n\t\t}\n\t}\n\tconst roleCeiling = new Set(DEFAULT_ROLE_CAPABILITY_CEILINGS[profile.role]);\n\tconst outOfRoleCapabilities = profile.capabilityCeiling.filter((capability) => !roleCeiling.has(capability));\n\tif (outOfRoleCapabilities.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' exceeds the ${profile.role} role ceiling: ${outOfRoleCapabilities.join(\", \")}.`,\n\t\t);\n\t}\n\tif (\n\t\tprofile.modelPolicy.candidates.length === 0 ||\n\t\tprofile.modelPolicy.candidates.length > MAX_ORCHESTRATION_COLLECTION_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' must declare a model candidate.`);\n\t}\n\tif (profile.modelPolicy.mode === \"fixed\" && profile.modelPolicy.candidates.length !== 1) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Fixed profile '${profile.profileId}' must declare exactly one model candidate.`,\n\t\t);\n\t}\n\tfor (const candidate of profile.modelPolicy.candidates) {\n\t\tif (\n\t\t\tcandidate.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t\t!candidate.provider.trim() ||\n\t\t\tcandidate.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH ||\n\t\t\t!candidate.modelId.trim()\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' contains an invalid model binding.`);\n\t\t}\n\t}\n\tconst duplicateModels = duplicateStrings(\n\t\tprofile.modelPolicy.candidates.map((candidate) => `${candidate.provider}/${candidate.modelId}`),\n\t);\n\tif (duplicateModels.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' contains duplicate model candidates: ${duplicateModels.join(\", \")}.`,\n\t\t);\n\t}\n\tif (!Number.isSafeInteger(profile.maxConcurrent) || profile.maxConcurrent <= 0) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' maxConcurrent must be positive.`);\n\t}\n\tif (!Number.isSafeInteger(profile.leaseTtlMs) || profile.leaseTtlMs <= 0) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' leaseTtlMs must be positive.`);\n\t}\n\ttry {\n\t\tvalidateRiskBudget(profile.budget, `Profile '${profile.profileId}' budget`);\n\t} catch (error) {\n\t\tthrow new OrchestrationProfileError(error instanceof Error ? error.message : String(error));\n\t}\n\tif (profile.budget.maxWallClockMs !== undefined && profile.budget.maxWallClockMs <= 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' maxWallClockMs budget must be positive when specified.`,\n\t\t);\n\t}\n\tif (profile.budget.maxWallClockMs !== undefined && profile.leaseTtlMs < profile.budget.maxWallClockMs) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' leaseTtlMs must cover its maxWallClockMs budget.`,\n\t\t);\n\t}\n\tconst processCapable =\n\t\tprofile.capabilityCeiling.includes(\"process.exec\") || profile.capabilityCeiling.includes(\"tests.execute\");\n\tif (processCapable && (!profile.executionPolicy || profile.executionPolicy.allowedExecutables.length === 0)) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' must declare executionPolicy.allowedExecutables for process capabilities.`,\n\t\t);\n\t}\n\tif (!processCapable && profile.executionPolicy) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' cannot declare executionPolicy without process capabilities.`,\n\t\t);\n\t}\n\tif (profile.executionPolicy) {\n\t\tif (\n\t\t\tprofile.executionPolicy.allowedExecutables.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t\tprofile.executionPolicy.allowedEnvironmentVariables.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t\tprofile.executionPolicy.allowedExecutables.some(\n\t\t\t\t(executable) =>\n\t\t\t\t\t!executable.trim() ||\n\t\t\t\t\texecutable.length > MAX_WORKER_AUTHORITY_PATH_LENGTH ||\n\t\t\t\t\t/[\\0\\r\\n]/.test(executable),\n\t\t\t) ||\n\t\t\tprofile.executionPolicy.allowedEnvironmentVariables.some(\n\t\t\t\t(name) => name.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(name),\n\t\t\t) ||\n\t\t\t!Number.isSafeInteger(profile.executionPolicy.maxOutputBytes) ||\n\t\t\tprofile.executionPolicy.maxOutputBytes <= 0 ||\n\t\t\tprofile.executionPolicy.maxOutputBytes > MAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' executionPolicy is invalid.`);\n\t\t}\n\t}\n\tconst unrestrictedProcessTools = profile.toolNames.filter((toolName) =>\n\t\t[\"bash\", \"python\", \"powershell\", \"run_toolkit_script\"].includes(toolName),\n\t);\n\tif (unrestrictedProcessTools.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' cannot expose unrestricted process tools (${unrestrictedProcessTools.join(\", \")}); use run_process with executionPolicy.`,\n\t\t);\n\t}\n\tconst unknownTools = profile.toolNames.filter(\n\t\t(toolName) => !(ORCHESTRATION_PROFILE_TOOL_NAMES as readonly string[]).includes(toolName),\n\t);\n\tif (unknownTools.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' contains unclassified orchestration tools: ${unknownTools.join(\", \")}.`,\n\t\t);\n\t}\n\tfor (const toolName of profile.toolNames) {\n\t\tif (!resolveProfileToolCapability(profile, toolName)) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Profile '${profile.profileId}' tool '${toolName}' lacks ${describeToolCapabilityAuthority(toolName)} authority.`,\n\t\t\t);\n\t\t}\n\t}\n\ttoJsonObject({ profile });\n}\n\nfunction isStringArray(value: unknown, maxLength = MAX_ORCHESTRATION_IDENTIFIER_LENGTH): value is string[] {\n\treturn (\n\t\tArray.isArray(value) &&\n\t\tvalue.length <= MAX_ORCHESTRATION_COLLECTION_LENGTH &&\n\t\tvalue.every((entry) => typeof entry === \"string\" && entry.length > 0 && entry.length <= maxLength)\n\t);\n}\n\nexport function parseOrchestrationProfile(value: unknown, sourcePath?: string): OrchestrationProfile {\n\tif (!isPlainRecord(value)) throw new OrchestrationProfileError(\"Orchestration profile must be an object.\");\n\tif (\n\t\t!hasOnlyKeys(value, [\n\t\t\t\"schemaVersion\",\n\t\t\t\"profileId\",\n\t\t\t\"description\",\n\t\t\t\"role\",\n\t\t\t\"modelPolicy\",\n\t\t\t\"capabilityCeiling\",\n\t\t\t\"toolNames\",\n\t\t\t\"resourceProfileNames\",\n\t\t\t\"dispatchProfileIds\",\n\t\t\t\"executionPolicy\",\n\t\t\t\"budget\",\n\t\t\t\"maxConcurrent\",\n\t\t\t\"leaseTtlMs\",\n\t\t\t\"requireIndependentVerification\",\n\t\t\t\"verificationProfileId\",\n\t\t\t\"createdAt\",\n\t\t\t\"updatedAt\",\n\t\t])\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile contains an unsupported field.\");\n\t}\n\tconst modelPolicy = value.modelPolicy;\n\tconst rawBudget = value.budget;\n\tlet budget: RiskBudget;\n\tconst executionPolicy = value.executionPolicy;\n\tif (\n\t\t!isPlainRecord(modelPolicy) ||\n\t\t!hasOnlyKeys(modelPolicy, [\"mode\", \"candidates\"]) ||\n\t\t!Array.isArray(modelPolicy.candidates) ||\n\t\tmodelPolicy.candidates.length > MAX_ORCHESTRATION_COLLECTION_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile modelPolicy is invalid.\");\n\t}\n\ttry {\n\t\tbudget = parseRiskBudget(rawBudget, \"Orchestration profile budget\");\n\t} catch (error) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\terror instanceof Error ? error.message : \"Orchestration profile budget is invalid.\",\n\t\t);\n\t}\n\tif (\n\t\texecutionPolicy !== undefined &&\n\t\t(!isPlainRecord(executionPolicy) ||\n\t\t\t!hasOnlyKeys(executionPolicy, [\"allowedExecutables\", \"allowedEnvironmentVariables\", \"maxOutputBytes\"]) ||\n\t\t\t!isStringArray(executionPolicy.allowedExecutables, MAX_WORKER_AUTHORITY_PATH_LENGTH) ||\n\t\t\t!isStringArray(executionPolicy.allowedEnvironmentVariables) ||\n\t\t\t!Number.isSafeInteger(executionPolicy.maxOutputBytes))\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile executionPolicy is invalid.\");\n\t}\n\tconst candidates = modelPolicy.candidates.map((candidate) => {\n\t\tif (!isPlainRecord(candidate) || !hasOnlyKeys(candidate, [\"provider\", \"modelId\", \"thinkingLevel\"])) {\n\t\t\tthrow new OrchestrationProfileError(\"Orchestration profile model candidate is invalid.\");\n\t\t}\n\t\tif (\n\t\t\ttypeof candidate.provider !== \"string\" ||\n\t\t\tcandidate.provider.length === 0 ||\n\t\t\tcandidate.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t\ttypeof candidate.modelId !== \"string\" ||\n\t\t\tcandidate.modelId.length === 0 ||\n\t\t\tcandidate.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH ||\n\t\t\ttypeof candidate.thinkingLevel !== \"string\" ||\n\t\t\t!ORCHESTRATION_THINKING_LEVELS.includes(\n\t\t\t\tcandidate.thinkingLevel as (typeof ORCHESTRATION_THINKING_LEVELS)[number],\n\t\t\t)\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(\"Orchestration profile model candidate is invalid.\");\n\t\t}\n\t\treturn {\n\t\t\tprovider: candidate.provider,\n\t\t\tmodelId: candidate.modelId,\n\t\t\tthinkingLevel: candidate.thinkingLevel as (typeof ORCHESTRATION_THINKING_LEVELS)[number],\n\t\t};\n\t});\n\tif (\n\t\tvalue.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION ||\n\t\ttypeof value.profileId !== \"string\" ||\n\t\tvalue.profileId.length === 0 ||\n\t\tvalue.profileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.description !== \"string\" ||\n\t\tvalue.description.length === 0 ||\n\t\tvalue.description.length > MAX_ORCHESTRATION_DESCRIPTION_LENGTH ||\n\t\ttypeof value.role !== \"string\" ||\n\t\t!WORKER_ROLES.includes(value.role as (typeof WORKER_ROLES)[number]) ||\n\t\t(modelPolicy.mode !== \"fixed\" && modelPolicy.mode !== \"ordered-fallback\") ||\n\t\t!Array.isArray(value.capabilityCeiling) ||\n\t\tvalue.capabilityCeiling.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t!value.capabilityCeiling.every(\n\t\t\t(capability) =>\n\t\t\t\ttypeof capability === \"string\" &&\n\t\t\t\tHARNESS_CAPABILITIES.includes(capability as (typeof HARNESS_CAPABILITIES)[number]),\n\t\t) ||\n\t\t!isStringArray(value.toolNames) ||\n\t\t!isStringArray(value.resourceProfileNames) ||\n\t\t!isStringArray(value.dispatchProfileIds) ||\n\t\t!Number.isSafeInteger(value.maxConcurrent) ||\n\t\t!Number.isSafeInteger(value.leaseTtlMs) ||\n\t\ttypeof value.requireIndependentVerification !== \"boolean\" ||\n\t\t(value.verificationProfileId !== undefined &&\n\t\t\t(typeof value.verificationProfileId !== \"string\" ||\n\t\t\t\tvalue.verificationProfileId.length === 0 ||\n\t\t\t\tvalue.verificationProfileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH)) ||\n\t\ttypeof value.createdAt !== \"string\" ||\n\t\tvalue.createdAt.length === 0 ||\n\t\tvalue.createdAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.updatedAt !== \"string\" ||\n\t\tvalue.updatedAt.length === 0 ||\n\t\tvalue.updatedAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile is invalid.\");\n\t}\n\tconst profile = structuredClone({\n\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\tprofileId: value.profileId,\n\t\tdescription: value.description,\n\t\trole: value.role as OrchestrationProfile[\"role\"],\n\t\tmodelPolicy: { mode: modelPolicy.mode as OrchestrationProfile[\"modelPolicy\"][\"mode\"], candidates },\n\t\tcapabilityCeiling: value.capabilityCeiling as OrchestrationProfile[\"capabilityCeiling\"],\n\t\ttoolNames: value.toolNames,\n\t\tresourceProfileNames: value.resourceProfileNames,\n\t\tdispatchProfileIds: value.dispatchProfileIds,\n\t\t...(executionPolicy\n\t\t\t? {\n\t\t\t\t\texecutionPolicy: {\n\t\t\t\t\t\tallowedExecutables: executionPolicy.allowedExecutables as string[],\n\t\t\t\t\t\tallowedEnvironmentVariables: executionPolicy.allowedEnvironmentVariables as string[],\n\t\t\t\t\t\tmaxOutputBytes: Number(executionPolicy.maxOutputBytes),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t\tbudget,\n\t\tmaxConcurrent: Number(value.maxConcurrent),\n\t\tleaseTtlMs: Number(value.leaseTtlMs),\n\t\trequireIndependentVerification: value.requireIndependentVerification,\n\t\t...(typeof value.verificationProfileId === \"string\"\n\t\t\t? { verificationProfileId: value.verificationProfileId }\n\t\t\t: {}),\n\t\t...(sourcePath ? { sourcePath } : {}),\n\t\tcreatedAt: value.createdAt,\n\t\tupdatedAt: value.updatedAt,\n\t}) as OrchestrationProfile;\n\tvalidateOrchestrationProfile(profile);\n\treturn profile;\n}\n\nfunction freezeProfile(profile: OrchestrationProfile): OrchestrationProfile {\n\tconst clone = structuredClone(profile);\n\tfor (const candidate of clone.modelPolicy.candidates) Object.freeze(candidate);\n\tObject.freeze(clone.modelPolicy.candidates);\n\tObject.freeze(clone.modelPolicy);\n\tObject.freeze(clone.capabilityCeiling);\n\tObject.freeze(clone.toolNames);\n\tObject.freeze(clone.resourceProfileNames);\n\tObject.freeze(clone.dispatchProfileIds);\n\tif (clone.executionPolicy) {\n\t\tObject.freeze(clone.executionPolicy.allowedExecutables);\n\t\tObject.freeze(clone.executionPolicy.allowedEnvironmentVariables);\n\t\tObject.freeze(clone.executionPolicy);\n\t}\n\tObject.freeze(clone.budget);\n\treturn Object.freeze(clone);\n}\n\nexport class OrchestrationProfileRegistry {\n\tprivate readonly profiles = new Map<string, OrchestrationProfile>();\n\n\tconstructor(profiles: readonly OrchestrationProfile[] = []) {\n\t\tfor (const profile of profiles) this.register(profile);\n\t\tfor (const profile of this.profiles.values()) {\n\t\t\tfor (const dispatchedProfileId of profile.dispatchProfileIds) {\n\t\t\t\tconst target = this.profiles.get(dispatchedProfileId);\n\t\t\t\tif (!target) {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' dispatches missing profile '${dispatchedProfileId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (target.role === \"orchestrator\") {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' cannot recursively dispatch orchestrator '${dispatchedProfileId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (profile.verificationProfileId) {\n\t\t\t\tconst verifier = this.profiles.get(profile.verificationProfileId);\n\t\t\t\tif (!verifier) {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' requires missing verifier profile '${profile.verificationProfileId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (verifier.role !== \"verifier\") {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' verificationProfileId '${profile.verificationProfileId}' is not a verifier.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (profile.role === \"orchestrator\") {\n\t\t\t\tfor (const dispatchedProfileId of profile.dispatchProfileIds) {\n\t\t\t\t\tconst worker = this.profiles.get(dispatchedProfileId);\n\t\t\t\t\tif (\n\t\t\t\t\t\tworker?.verificationProfileId &&\n\t\t\t\t\t\t!profile.dispatchProfileIds.includes(worker.verificationProfileId)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t\t`Orchestrator '${profile.profileId}' dispatches '${worker.profileId}' but not its verifier '${worker.verificationProfileId}'.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tregister(profile: OrchestrationProfile): void {\n\t\tvalidateOrchestrationProfile(profile);\n\t\tif (this.profiles.has(profile.profileId)) {\n\t\t\tthrow new OrchestrationProfileError(`Duplicate orchestration profile '${profile.profileId}'.`);\n\t\t}\n\t\tthis.profiles.set(profile.profileId, freezeProfile(profile));\n\t}\n\n\tget(profileId: string): OrchestrationProfile | undefined {\n\t\tconst profile = this.profiles.get(profileId);\n\t\treturn profile ? structuredClone(profile) : undefined;\n\t}\n\n\tlist(): OrchestrationProfile[] {\n\t\treturn [...this.profiles.values()].map((profile) => structuredClone(profile));\n\t}\n}\n\nexport function resolveProfileModel(\n\tprofile: OrchestrationProfile,\n\thealth: ModelHealthView,\n): OrchestrationModelBinding | undefined {\n\tif (profile.modelPolicy.mode === \"fixed\") {\n\t\tconst fixed = profile.modelPolicy.candidates[0];\n\t\treturn fixed && health.isHealthy(fixed) ? structuredClone(fixed) : undefined;\n\t}\n\tconst selected = profile.modelPolicy.candidates.find((candidate) => health.isHealthy(candidate));\n\treturn selected ? structuredClone(selected) : undefined;\n}\n\nexport function planProfileDispatch(args: {\n\trequest: OrchestrationDispatchRequest;\n\ttask: TaskContract;\n\tattemptId: string;\n\tsubjectId: string;\n\tregistry: OrchestrationProfileRegistry;\n\thealth: ModelHealthView;\n\tpolicyCompiler: ExecutionPolicyCompiler;\n\ttoolManifests: readonly ToolCapabilityManifest[];\n\tresources: readonly ResourcePointer[];\n\treadPaths: readonly string[];\n\twritePaths?: readonly string[];\n\tdeniedPaths?: readonly string[];\n\tpolicyVersion: string;\n}): ProfileDispatchPlanResult {\n\tconst profile = args.registry.get(args.request.profileId);\n\tif (!profile) return { outcome: \"deny\", decisions: [], reasonCodes: [\"profile_model_unavailable\"] };\n\tif (profile.role !== args.task.role) {\n\t\treturn { outcome: \"deny\", decisions: [], reasonCodes: [\"required_capability_exceeds_role_ceiling\"] };\n\t}\n\tconst model = resolveProfileModel(profile, args.health);\n\tif (!model) return { outcome: \"deny\", decisions: [], reasonCodes: [\"profile_model_unavailable\"] };\n\tconst selectedResources = args.resources.filter((resource) => args.request.resourcePointerIds.includes(resource.id));\n\tconst manifestsByName = new Map(args.toolManifests.map((manifest) => [manifest.toolName, manifest]));\n\tconst requestedTools = profile.toolNames.filter((toolName) => {\n\t\tconst manifest = manifestsByName.get(toolName);\n\t\treturn manifest?.capabilities.every((capability) => args.task.requiredCapabilities.includes(capability)) === true;\n\t});\n\tconst policyInput: CompileExecutionGrantInput = {\n\t\tobjectiveId: args.task.objectiveId,\n\t\ttaskId: args.task.taskId,\n\t\tattemptId: args.attemptId,\n\t\tsubjectId: args.subjectId,\n\t\trole: profile.role,\n\t\trequiredCapabilities: args.task.requiredCapabilities,\n\t\trequestedCapabilities: args.task.requiredCapabilities,\n\t\tauthorityCapabilities: profile.capabilityCeiling,\n\t\trequestedTools,\n\t\ttoolManifests: args.toolManifests,\n\t\tresources: selectedResources,\n\t\treadPaths: args.readPaths,\n\t\twritePaths: args.writePaths,\n\t\tdeniedPaths: args.deniedPaths,\n\t\trequestedBudget: profile.budget,\n\t\tauthorityBudget: profile.budget,\n\t\tpolicyVersion: args.policyVersion,\n\t};\n\tconst compiled = args.policyCompiler.compile(policyInput);\n\tif (compiled.outcome !== \"allow\") return compiled;\n\treturn { outcome: \"allow\", plan: { profile, model, grant: compiled.grant, toolManifests: compiled.toolManifests } };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"profile-store.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/profile-store.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAEN,4BAA4B,EAG5B,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE7D,MAAM,WAAW,8BAA8B;IAC9C,KAAK,EAAE,yBAAyB,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,8BAA8B;IAC9C,QAAQ,EAAE,4BAA4B,CAAC;IACvC,QAAQ,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC1C,WAAW,EAAE,SAAS,8BAA8B,EAAE,CAAC;CACvD;AAwBD,qBAAa,yBAAyB;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;IAEzC,YAAY,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,OAAO,CAAA;KAAE,EAI9E;IAED,SAAS,CAAC,KAAK,EAAE,yBAAyB,GAAG,MAAM,CAIlD;IAED,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,GAAG,MAAM,CAOpE;IAED,IAAI,IAAI,8BAA8B,CA0DrC;IAED,IAAI,CACH,OAAO,EAAE,oBAAoB,EAC7B,KAAK,EAAE,yBAAyB,EAChC,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAO,GACnC,MAAM,CAoBR;IAED,OAAO,CAAC,SAAS;CAuCjB","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../../config.ts\";\nimport { resourceDir } from \"../agent-paths.ts\";\nimport { withFileLockSync, writeFileAtomicSync } from \"../util/atomic-file.ts\";\nimport { readBoundedDirectoryNamesSync, readBoundedTextFileSync } from \"../util/bounded-file.ts\";\nimport type { OrchestrationProfile } from \"./contracts.ts\";\nimport {\n\tOrchestrationProfileError,\n\tOrchestrationProfileRegistry,\n\tparseOrchestrationProfile,\n\tvalidateOrchestrationProfile,\n} from \"./profile-registry.ts\";\n\nexport type OrchestrationProfileScope = \"global\" | \"project\";\n\nexport interface OrchestrationProfileDiagnostic {\n\tscope: OrchestrationProfileScope;\n\tpath: string;\n\tmessage: string;\n}\n\nexport interface OrchestrationProfileLoadResult {\n\tregistry: OrchestrationProfileRegistry;\n\tprofiles: readonly OrchestrationProfile[];\n\tdiagnostics: readonly OrchestrationProfileDiagnostic[];\n}\n\nconst PROFILE_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;\n/** A fully populated profile is below this cap; reject expansion before JSON parsing or persistence. */\nconst MAX_PROFILE_FILE_BYTES = 512 * 1024;\nconst MAX_PROFILE_DIRECTORY_ENTRIES = 512;\n\nfunction authoredProfile(profile: OrchestrationProfile): Omit<OrchestrationProfile, \"sourcePath\"> {\n\tconst { sourcePath: _sourcePath, ...authored } = profile;\n\treturn authored;\n}\n\nfunction messageFrom(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nfunction serializeBoundedProfile(profile: Omit<OrchestrationProfile, \"sourcePath\">): string {\n\tconst serialized = `${JSON.stringify(profile, null, 2)}\\n`;\n\tif (Buffer.byteLength(serialized, \"utf-8\") > MAX_PROFILE_FILE_BYTES) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile exceeds its byte limit.\");\n\t}\n\treturn serialized;\n}\n\nexport class OrchestrationProfileStore {\n\tprivate readonly agentDir: string;\n\tprivate readonly cwd: string;\n\tprivate readonly projectTrusted: boolean;\n\n\tconstructor(options: { agentDir: string; cwd: string; projectTrusted: boolean }) {\n\t\tthis.agentDir = resolve(options.agentDir);\n\t\tthis.cwd = resolve(options.cwd);\n\t\tthis.projectTrusted = options.projectTrusted;\n\t}\n\n\tdirectory(scope: OrchestrationProfileScope): string {\n\t\treturn scope === \"global\"\n\t\t\t? join(resourceDir(\"profiles\", this.agentDir), \"orchestration\")\n\t\t\t: join(this.cwd, CONFIG_DIR_NAME, \"profiles\", \"orchestration\");\n\t}\n\n\tfilePath(profileId: string, scope: OrchestrationProfileScope): string {\n\t\tif (!PROFILE_ID_PATTERN.test(profileId)) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\"Orchestration profile IDs must be 1-128 characters using only letters, numbers, '.', '_', or '-'.\",\n\t\t\t);\n\t\t}\n\t\treturn join(this.directory(scope), `${profileId}.json`);\n\t}\n\n\tload(): OrchestrationProfileLoadResult {\n\t\tconst diagnostics: OrchestrationProfileDiagnostic[] = [];\n\t\tconst globalProfiles = this.loadScope(\"global\", diagnostics);\n\t\tconst projectProfiles = this.projectTrusted ? this.loadScope(\"project\", diagnostics) : [];\n\t\tif (!this.projectTrusted && existsSync(this.directory(\"project\"))) {\n\t\t\tdiagnostics.push({\n\t\t\t\tscope: \"project\",\n\t\t\t\tpath: this.directory(\"project\"),\n\t\t\t\tmessage: \"Project orchestration profiles were not loaded because the project is untrusted.\",\n\t\t\t});\n\t\t}\n\t\tconst profilesById = new Map(globalProfiles.map((profile) => [profile.profileId, profile]));\n\t\tfor (const profile of projectProfiles) profilesById.set(profile.profileId, profile);\n\t\tlet profiles = [...profilesById.values()].sort((left, right) => left.profileId.localeCompare(right.profileId));\n\t\tlet removed = true;\n\t\twhile (removed) {\n\t\t\tremoved = false;\n\t\t\tconst available = new Map(profiles.map((profile) => [profile.profileId, profile]));\n\t\t\tprofiles = profiles.filter((profile) => {\n\t\t\t\tconst invalidTarget = profile.dispatchProfileIds.find((profileId) => {\n\t\t\t\t\tconst target = available.get(profileId);\n\t\t\t\t\treturn !target || target.role === \"orchestrator\";\n\t\t\t\t});\n\t\t\t\tconst verifier = profile.verificationProfileId ? available.get(profile.verificationProfileId) : undefined;\n\t\t\t\tconst invalidVerifier =\n\t\t\t\t\tprofile.verificationProfileId && verifier?.role !== \"verifier\"\n\t\t\t\t\t\t? profile.verificationProfileId\n\t\t\t\t\t\t: undefined;\n\t\t\t\tconst unauthorizedVerifier =\n\t\t\t\t\tprofile.role === \"orchestrator\"\n\t\t\t\t\t\t? profile.dispatchProfileIds\n\t\t\t\t\t\t\t\t.map((profileId) => available.get(profileId))\n\t\t\t\t\t\t\t\t.find(\n\t\t\t\t\t\t\t\t\t(target) =>\n\t\t\t\t\t\t\t\t\t\ttarget?.verificationProfileId &&\n\t\t\t\t\t\t\t\t\t\t!profile.dispatchProfileIds.includes(target.verificationProfileId),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: undefined;\n\t\t\t\tif (!invalidTarget && !invalidVerifier && !unauthorizedVerifier) return true;\n\t\t\t\tremoved = true;\n\t\t\t\tconst message = invalidTarget\n\t\t\t\t\t? `Dispatch target '${invalidTarget}' is missing or is another orchestrator.`\n\t\t\t\t\t: invalidVerifier\n\t\t\t\t\t\t? `Verifier target '${invalidVerifier}' is missing or is not a verifier.`\n\t\t\t\t\t\t: `Dispatched profile '${unauthorizedVerifier?.profileId}' requires verifier '${unauthorizedVerifier?.verificationProfileId}', which this orchestrator does not authorize.`;\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tscope: profile.sourcePath?.startsWith(this.directory(\"project\")) ? \"project\" : \"global\",\n\t\t\t\t\tpath: profile.sourcePath ?? profile.profileId,\n\t\t\t\t\tmessage,\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t});\n\t\t}\n\t\treturn {\n\t\t\tregistry: new OrchestrationProfileRegistry(profiles),\n\t\t\tprofiles,\n\t\t\tdiagnostics,\n\t\t};\n\t}\n\n\tsave(\n\t\tprofile: OrchestrationProfile,\n\t\tscope: OrchestrationProfileScope,\n\t\toptions: { overwrite?: boolean } = {},\n\t): string {\n\t\tif (scope === \"project\" && !this.projectTrusted) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\"Project is not trusted; refusing to write project orchestration profiles.\",\n\t\t\t);\n\t\t}\n\t\tvalidateOrchestrationProfile(profile);\n\t\tconst filePath = this.filePath(profile.profileId, scope);\n\t\tconst serialized = serializeBoundedProfile(authoredProfile(profile));\n\t\t// Keep the save path as strict as load: typed callers cannot persist a record the loader rejects.\n\t\tparseOrchestrationProfile(JSON.parse(serialized));\n\t\twithFileLockSync(filePath, () => {\n\t\t\tif (!options.overwrite && existsSync(filePath)) {\n\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t`Orchestration profile '${profile.profileId}' already exists in ${scope} scope.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\twriteFileAtomicSync(filePath, serialized);\n\t\t});\n\t\treturn filePath;\n\t}\n\n\tprivate loadScope(\n\t\tscope: OrchestrationProfileScope,\n\t\tdiagnostics: OrchestrationProfileDiagnostic[],\n\t): OrchestrationProfile[] {\n\t\tconst directory = this.directory(scope);\n\t\tif (!existsSync(directory)) return [];\n\t\tlet entries: string[];\n\t\ttry {\n\t\t\tentries = readBoundedDirectoryNamesSync(\n\t\t\t\tdirectory,\n\t\t\t\tMAX_PROFILE_DIRECTORY_ENTRIES,\n\t\t\t\t\"Orchestration profiles directory\",\n\t\t\t)\n\t\t\t\t.filter((entry) => entry.endsWith(\".json\"))\n\t\t\t\t.sort((left, right) => left.localeCompare(right));\n\t\t} catch (error) {\n\t\t\tdiagnostics.push({ scope, path: directory, message: messageFrom(error) });\n\t\t\treturn [];\n\t\t}\n\t\tconst profilesById = new Map<string, OrchestrationProfile>();\n\t\tfor (const entry of entries) {\n\t\t\tconst sourcePath = join(directory, entry);\n\t\t\ttry {\n\t\t\t\tconst profile = parseOrchestrationProfile(\n\t\t\t\t\tJSON.parse(readBoundedTextFileSync(sourcePath, MAX_PROFILE_FILE_BYTES, \"Orchestration profile\")),\n\t\t\t\t\tsourcePath,\n\t\t\t\t);\n\t\t\t\tif (profilesById.has(profile.profileId)) {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Duplicate orchestration profile '${profile.profileId}' in ${scope} scope.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tprofilesById.set(profile.profileId, profile);\n\t\t\t} catch (error) {\n\t\t\t\tdiagnostics.push({ scope, path: sourcePath, message: messageFrom(error) });\n\t\t\t}\n\t\t}\n\t\treturn [...profilesById.values()];\n\t}\n}\n"]}
1
+ {"version":3,"file":"profile-store.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/profile-store.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAEN,4BAA4B,EAG5B,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE7D,MAAM,WAAW,8BAA8B;IAC9C,KAAK,EAAE,yBAAyB,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,8BAA8B;IAC9C,QAAQ,EAAE,4BAA4B,CAAC;IACvC,QAAQ,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC1C,WAAW,EAAE,SAAS,8BAA8B,EAAE,CAAC;CACvD;AAwBD,qBAAa,yBAAyB;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;IAEzC,YAAY,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,OAAO,CAAA;KAAE,EAI9E;IAED,SAAS,CAAC,KAAK,EAAE,yBAAyB,GAAG,MAAM,CAIlD;IAED,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,GAAG,MAAM,CAOpE;IAED,IAAI,IAAI,8BAA8B,CA0DrC;IAED,IAAI,CACH,OAAO,EAAE,oBAAoB,EAC7B,KAAK,EAAE,yBAAyB,EAChC,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAO,GACnC,MAAM,CAoBR;IAED,OAAO,CAAC,SAAS;CAuCjB"}
@@ -24,9 +24,6 @@ function serializeBoundedProfile(profile) {
24
24
  return serialized;
25
25
  }
26
26
  export class OrchestrationProfileStore {
27
- agentDir;
28
- cwd;
29
- projectTrusted;
30
27
  constructor(options) {
31
28
  this.agentDir = resolve(options.agentDir);
32
29
  this.cwd = resolve(options.cwd);
@@ -1 +1 @@
1
- {"version":3,"file":"profile-store.js","sourceRoot":"","sources":["../../../src/core/orchestration/profile-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEjG,OAAO,EACN,yBAAyB,EACzB,4BAA4B,EAC5B,yBAAyB,EACzB,4BAA4B,GAC5B,MAAM,uBAAuB,CAAC;AAgB/B,MAAM,kBAAkB,GAAG,oCAAoC,CAAC;AAChE,wGAAwG;AACxG,MAAM,sBAAsB,GAAG,GAAG,GAAG,IAAI,CAAC;AAC1C,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAE1C,SAAS,eAAe,CAAC,OAA6B,EAA4C;IACjG,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,CAAC;IACzD,OAAO,QAAQ,CAAC;AAAA,CAChB;AAED,SAAS,WAAW,CAAC,KAAc,EAAU;IAC5C,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAAA,CAC9D;AAED,SAAS,uBAAuB,CAAC,OAAiD,EAAU;IAC3F,MAAM,UAAU,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,I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,KAAK,SAAS,CAC3E,CAAC;gBACH,CAAC;gBACD,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC9C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,WAAW,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC5E,CAAC;QACF,CAAC;QACD,OAAO,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;IAAA,CAClC;CACD","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../../config.ts\";\nimport { resourceDir } from \"../agent-paths.ts\";\nimport { withFileLockSync, writeFileAtomicSync } from \"../util/atomic-file.ts\";\nimport { readBoundedDirectoryNamesSync, readBoundedTextFileSync } from \"../util/bounded-file.ts\";\nimport type { OrchestrationProfile } from \"./contracts.ts\";\nimport {\n\tOrchestrationProfileError,\n\tOrchestrationProfileRegistry,\n\tparseOrchestrationProfile,\n\tvalidateOrchestrationProfile,\n} from \"./profile-registry.ts\";\n\nexport type OrchestrationProfileScope = \"global\" | \"project\";\n\nexport interface OrchestrationProfileDiagnostic {\n\tscope: OrchestrationProfileScope;\n\tpath: string;\n\tmessage: string;\n}\n\nexport interface OrchestrationProfileLoadResult {\n\tregistry: OrchestrationProfileRegistry;\n\tprofiles: readonly OrchestrationProfile[];\n\tdiagnostics: readonly OrchestrationProfileDiagnostic[];\n}\n\nconst PROFILE_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;\n/** A fully populated profile is below this cap; reject expansion before JSON parsing or persistence. */\nconst MAX_PROFILE_FILE_BYTES = 512 * 1024;\nconst MAX_PROFILE_DIRECTORY_ENTRIES = 512;\n\nfunction authoredProfile(profile: OrchestrationProfile): Omit<OrchestrationProfile, \"sourcePath\"> {\n\tconst { sourcePath: _sourcePath, ...authored } = profile;\n\treturn authored;\n}\n\nfunction messageFrom(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nfunction serializeBoundedProfile(profile: Omit<OrchestrationProfile, \"sourcePath\">): string {\n\tconst serialized = `${JSON.stringify(profile, null, 2)}\\n`;\n\tif (Buffer.byteLength(serialized, \"utf-8\") > MAX_PROFILE_FILE_BYTES) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile exceeds its byte limit.\");\n\t}\n\treturn serialized;\n}\n\nexport class OrchestrationProfileStore {\n\tprivate readonly agentDir: string;\n\tprivate readonly cwd: string;\n\tprivate readonly projectTrusted: boolean;\n\n\tconstructor(options: { agentDir: string; cwd: string; projectTrusted: boolean }) {\n\t\tthis.agentDir = resolve(options.agentDir);\n\t\tthis.cwd = resolve(options.cwd);\n\t\tthis.projectTrusted = options.projectTrusted;\n\t}\n\n\tdirectory(scope: OrchestrationProfileScope): string {\n\t\treturn scope === \"global\"\n\t\t\t? join(resourceDir(\"profiles\", this.agentDir), \"orchestration\")\n\t\t\t: join(this.cwd, CONFIG_DIR_NAME, \"profiles\", \"orchestration\");\n\t}\n\n\tfilePath(profileId: string, scope: OrchestrationProfileScope): string {\n\t\tif (!PROFILE_ID_PATTERN.test(profileId)) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\"Orchestration profile IDs must be 1-128 characters using only letters, numbers, '.', '_', or '-'.\",\n\t\t\t);\n\t\t}\n\t\treturn join(this.directory(scope), `${profileId}.json`);\n\t}\n\n\tload(): OrchestrationProfileLoadResult {\n\t\tconst diagnostics: OrchestrationProfileDiagnostic[] = [];\n\t\tconst globalProfiles = this.loadScope(\"global\", diagnostics);\n\t\tconst projectProfiles = this.projectTrusted ? this.loadScope(\"project\", diagnostics) : [];\n\t\tif (!this.projectTrusted && existsSync(this.directory(\"project\"))) {\n\t\t\tdiagnostics.push({\n\t\t\t\tscope: \"project\",\n\t\t\t\tpath: this.directory(\"project\"),\n\t\t\t\tmessage: \"Project orchestration profiles were not loaded because the project is untrusted.\",\n\t\t\t});\n\t\t}\n\t\tconst profilesById = new Map(globalProfiles.map((profile) => [profile.profileId, profile]));\n\t\tfor (const profile of projectProfiles) profilesById.set(profile.profileId, profile);\n\t\tlet profiles = [...profilesById.values()].sort((left, right) => left.profileId.localeCompare(right.profileId));\n\t\tlet removed = true;\n\t\twhile (removed) {\n\t\t\tremoved = false;\n\t\t\tconst available = new Map(profiles.map((profile) => [profile.profileId, profile]));\n\t\t\tprofiles = profiles.filter((profile) => {\n\t\t\t\tconst invalidTarget = profile.dispatchProfileIds.find((profileId) => {\n\t\t\t\t\tconst target = available.get(profileId);\n\t\t\t\t\treturn !target || target.role === \"orchestrator\";\n\t\t\t\t});\n\t\t\t\tconst verifier = profile.verificationProfileId ? available.get(profile.verificationProfileId) : undefined;\n\t\t\t\tconst invalidVerifier =\n\t\t\t\t\tprofile.verificationProfileId && verifier?.role !== \"verifier\"\n\t\t\t\t\t\t? profile.verificationProfileId\n\t\t\t\t\t\t: undefined;\n\t\t\t\tconst unauthorizedVerifier =\n\t\t\t\t\tprofile.role === \"orchestrator\"\n\t\t\t\t\t\t? profile.dispatchProfileIds\n\t\t\t\t\t\t\t\t.map((profileId) => available.get(profileId))\n\t\t\t\t\t\t\t\t.find(\n\t\t\t\t\t\t\t\t\t(target) =>\n\t\t\t\t\t\t\t\t\t\ttarget?.verificationProfileId &&\n\t\t\t\t\t\t\t\t\t\t!profile.dispatchProfileIds.includes(target.verificationProfileId),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: undefined;\n\t\t\t\tif (!invalidTarget && !invalidVerifier && !unauthorizedVerifier) return true;\n\t\t\t\tremoved = true;\n\t\t\t\tconst message = invalidTarget\n\t\t\t\t\t? `Dispatch target '${invalidTarget}' is missing or is another orchestrator.`\n\t\t\t\t\t: invalidVerifier\n\t\t\t\t\t\t? `Verifier target '${invalidVerifier}' is missing or is not a verifier.`\n\t\t\t\t\t\t: `Dispatched profile '${unauthorizedVerifier?.profileId}' requires verifier '${unauthorizedVerifier?.verificationProfileId}', which this orchestrator does not authorize.`;\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tscope: profile.sourcePath?.startsWith(this.directory(\"project\")) ? \"project\" : \"global\",\n\t\t\t\t\tpath: profile.sourcePath ?? profile.profileId,\n\t\t\t\t\tmessage,\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t});\n\t\t}\n\t\treturn {\n\t\t\tregistry: new OrchestrationProfileRegistry(profiles),\n\t\t\tprofiles,\n\t\t\tdiagnostics,\n\t\t};\n\t}\n\n\tsave(\n\t\tprofile: OrchestrationProfile,\n\t\tscope: OrchestrationProfileScope,\n\t\toptions: { overwrite?: boolean } = {},\n\t): string {\n\t\tif (scope === \"project\" && !this.projectTrusted) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\"Project is not trusted; refusing to write project orchestration profiles.\",\n\t\t\t);\n\t\t}\n\t\tvalidateOrchestrationProfile(profile);\n\t\tconst filePath = this.filePath(profile.profileId, scope);\n\t\tconst serialized = serializeBoundedProfile(authoredProfile(profile));\n\t\t// Keep the save path as strict as load: typed callers cannot persist a record the loader rejects.\n\t\tparseOrchestrationProfile(JSON.parse(serialized));\n\t\twithFileLockSync(filePath, () => {\n\t\t\tif (!options.overwrite && existsSync(filePath)) {\n\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t`Orchestration profile '${profile.profileId}' already exists in ${scope} scope.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\twriteFileAtomicSync(filePath, serialized);\n\t\t});\n\t\treturn filePath;\n\t}\n\n\tprivate loadScope(\n\t\tscope: OrchestrationProfileScope,\n\t\tdiagnostics: OrchestrationProfileDiagnostic[],\n\t): OrchestrationProfile[] {\n\t\tconst directory = this.directory(scope);\n\t\tif (!existsSync(directory)) return [];\n\t\tlet entries: string[];\n\t\ttry {\n\t\t\tentries = readBoundedDirectoryNamesSync(\n\t\t\t\tdirectory,\n\t\t\t\tMAX_PROFILE_DIRECTORY_ENTRIES,\n\t\t\t\t\"Orchestration profiles directory\",\n\t\t\t)\n\t\t\t\t.filter((entry) => entry.endsWith(\".json\"))\n\t\t\t\t.sort((left, right) => left.localeCompare(right));\n\t\t} catch (error) {\n\t\t\tdiagnostics.push({ scope, path: directory, message: messageFrom(error) });\n\t\t\treturn [];\n\t\t}\n\t\tconst profilesById = new Map<string, OrchestrationProfile>();\n\t\tfor (const entry of entries) {\n\t\t\tconst sourcePath = join(directory, entry);\n\t\t\ttry {\n\t\t\t\tconst profile = parseOrchestrationProfile(\n\t\t\t\t\tJSON.parse(readBoundedTextFileSync(sourcePath, MAX_PROFILE_FILE_BYTES, \"Orchestration profile\")),\n\t\t\t\t\tsourcePath,\n\t\t\t\t);\n\t\t\t\tif (profilesById.has(profile.profileId)) {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Duplicate orchestration profile '${profile.profileId}' in ${scope} scope.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tprofilesById.set(profile.profileId, profile);\n\t\t\t} catch (error) {\n\t\t\t\tdiagnostics.push({ scope, path: sourcePath, message: messageFrom(error) });\n\t\t\t}\n\t\t}\n\t\treturn [...profilesById.values()];\n\t}\n}\n"]}
1
+ {"version":3,"file":"profile-store.js","sourceRoot":"","sources":["../../../src/core/orchestration/profile-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEjG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E,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC1E,OAAO,EAAE,CAAC;QACX,CAAC;QACD,MAAM,YAAY,GAAG,IAAI,GAAG,EAAgC,CAAC;QAC7D,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAC1C,IAAI,CAAC;gBACJ,MAAM,OAAO,GAAG,yBAAyB,CACxC,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,UAAU,EAAE,sBAAsB,EAAE,uBAAuB,CAAC,CAAC,EAChG,UAAU,CACV,CAAC;gBACF,IAAI,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;oBACzC,MAAM,IAAI,yBAAyB,CAClC,oCAAoC,OAAO,CAAC,SAAS,QAAQ,KAAK,SAAS,CAC3E,CAAC;gBACH,CAAC;gBACD,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC9C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,WAAW,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC5E,CAAC;QACF,CAAC;QACD,OAAO,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;IACnC,CAAC;CACD","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../../config.ts\";\nimport { resourceDir } from \"../agent-paths.ts\";\nimport { withFileLockSync, writeFileAtomicSync } from \"../util/atomic-file.ts\";\nimport { readBoundedDirectoryNamesSync, readBoundedTextFileSync } from \"../util/bounded-file.ts\";\nimport type { OrchestrationProfile } from \"./contracts.ts\";\nimport {\n\tOrchestrationProfileError,\n\tOrchestrationProfileRegistry,\n\tparseOrchestrationProfile,\n\tvalidateOrchestrationProfile,\n} from \"./profile-registry.ts\";\n\nexport type OrchestrationProfileScope = \"global\" | \"project\";\n\nexport interface OrchestrationProfileDiagnostic {\n\tscope: OrchestrationProfileScope;\n\tpath: string;\n\tmessage: string;\n}\n\nexport interface OrchestrationProfileLoadResult {\n\tregistry: OrchestrationProfileRegistry;\n\tprofiles: readonly OrchestrationProfile[];\n\tdiagnostics: readonly OrchestrationProfileDiagnostic[];\n}\n\nconst PROFILE_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;\n/** A fully populated profile is below this cap; reject expansion before JSON parsing or persistence. */\nconst MAX_PROFILE_FILE_BYTES = 512 * 1024;\nconst MAX_PROFILE_DIRECTORY_ENTRIES = 512;\n\nfunction authoredProfile(profile: OrchestrationProfile): Omit<OrchestrationProfile, \"sourcePath\"> {\n\tconst { sourcePath: _sourcePath, ...authored } = profile;\n\treturn authored;\n}\n\nfunction messageFrom(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nfunction serializeBoundedProfile(profile: Omit<OrchestrationProfile, \"sourcePath\">): string {\n\tconst serialized = `${JSON.stringify(profile, null, 2)}\\n`;\n\tif (Buffer.byteLength(serialized, \"utf-8\") > MAX_PROFILE_FILE_BYTES) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile exceeds its byte limit.\");\n\t}\n\treturn serialized;\n}\n\nexport class OrchestrationProfileStore {\n\tprivate readonly agentDir: string;\n\tprivate readonly cwd: string;\n\tprivate readonly projectTrusted: boolean;\n\n\tconstructor(options: { agentDir: string; cwd: string; projectTrusted: boolean }) {\n\t\tthis.agentDir = resolve(options.agentDir);\n\t\tthis.cwd = resolve(options.cwd);\n\t\tthis.projectTrusted = options.projectTrusted;\n\t}\n\n\tdirectory(scope: OrchestrationProfileScope): string {\n\t\treturn scope === \"global\"\n\t\t\t? join(resourceDir(\"profiles\", this.agentDir), \"orchestration\")\n\t\t\t: join(this.cwd, CONFIG_DIR_NAME, \"profiles\", \"orchestration\");\n\t}\n\n\tfilePath(profileId: string, scope: OrchestrationProfileScope): string {\n\t\tif (!PROFILE_ID_PATTERN.test(profileId)) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\"Orchestration profile IDs must be 1-128 characters using only letters, numbers, '.', '_', or '-'.\",\n\t\t\t);\n\t\t}\n\t\treturn join(this.directory(scope), `${profileId}.json`);\n\t}\n\n\tload(): OrchestrationProfileLoadResult {\n\t\tconst diagnostics: OrchestrationProfileDiagnostic[] = [];\n\t\tconst globalProfiles = this.loadScope(\"global\", diagnostics);\n\t\tconst projectProfiles = this.projectTrusted ? this.loadScope(\"project\", diagnostics) : [];\n\t\tif (!this.projectTrusted && existsSync(this.directory(\"project\"))) {\n\t\t\tdiagnostics.push({\n\t\t\t\tscope: \"project\",\n\t\t\t\tpath: this.directory(\"project\"),\n\t\t\t\tmessage: \"Project orchestration profiles were not loaded because the project is untrusted.\",\n\t\t\t});\n\t\t}\n\t\tconst profilesById = new Map(globalProfiles.map((profile) => [profile.profileId, profile]));\n\t\tfor (const profile of projectProfiles) profilesById.set(profile.profileId, profile);\n\t\tlet profiles = [...profilesById.values()].sort((left, right) => left.profileId.localeCompare(right.profileId));\n\t\tlet removed = true;\n\t\twhile (removed) {\n\t\t\tremoved = false;\n\t\t\tconst available = new Map(profiles.map((profile) => [profile.profileId, profile]));\n\t\t\tprofiles = profiles.filter((profile) => {\n\t\t\t\tconst invalidTarget = profile.dispatchProfileIds.find((profileId) => {\n\t\t\t\t\tconst target = available.get(profileId);\n\t\t\t\t\treturn !target || target.role === \"orchestrator\";\n\t\t\t\t});\n\t\t\t\tconst verifier = profile.verificationProfileId ? available.get(profile.verificationProfileId) : undefined;\n\t\t\t\tconst invalidVerifier =\n\t\t\t\t\tprofile.verificationProfileId && verifier?.role !== \"verifier\"\n\t\t\t\t\t\t? profile.verificationProfileId\n\t\t\t\t\t\t: undefined;\n\t\t\t\tconst unauthorizedVerifier =\n\t\t\t\t\tprofile.role === \"orchestrator\"\n\t\t\t\t\t\t? profile.dispatchProfileIds\n\t\t\t\t\t\t\t\t.map((profileId) => available.get(profileId))\n\t\t\t\t\t\t\t\t.find(\n\t\t\t\t\t\t\t\t\t(target) =>\n\t\t\t\t\t\t\t\t\t\ttarget?.verificationProfileId &&\n\t\t\t\t\t\t\t\t\t\t!profile.dispatchProfileIds.includes(target.verificationProfileId),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: undefined;\n\t\t\t\tif (!invalidTarget && !invalidVerifier && !unauthorizedVerifier) return true;\n\t\t\t\tremoved = true;\n\t\t\t\tconst message = invalidTarget\n\t\t\t\t\t? `Dispatch target '${invalidTarget}' is missing or is another orchestrator.`\n\t\t\t\t\t: invalidVerifier\n\t\t\t\t\t\t? `Verifier target '${invalidVerifier}' is missing or is not a verifier.`\n\t\t\t\t\t\t: `Dispatched profile '${unauthorizedVerifier?.profileId}' requires verifier '${unauthorizedVerifier?.verificationProfileId}', which this orchestrator does not authorize.`;\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tscope: profile.sourcePath?.startsWith(this.directory(\"project\")) ? \"project\" : \"global\",\n\t\t\t\t\tpath: profile.sourcePath ?? profile.profileId,\n\t\t\t\t\tmessage,\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t});\n\t\t}\n\t\treturn {\n\t\t\tregistry: new OrchestrationProfileRegistry(profiles),\n\t\t\tprofiles,\n\t\t\tdiagnostics,\n\t\t};\n\t}\n\n\tsave(\n\t\tprofile: OrchestrationProfile,\n\t\tscope: OrchestrationProfileScope,\n\t\toptions: { overwrite?: boolean } = {},\n\t): string {\n\t\tif (scope === \"project\" && !this.projectTrusted) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\"Project is not trusted; refusing to write project orchestration profiles.\",\n\t\t\t);\n\t\t}\n\t\tvalidateOrchestrationProfile(profile);\n\t\tconst filePath = this.filePath(profile.profileId, scope);\n\t\tconst serialized = serializeBoundedProfile(authoredProfile(profile));\n\t\t// Keep the save path as strict as load: typed callers cannot persist a record the loader rejects.\n\t\tparseOrchestrationProfile(JSON.parse(serialized));\n\t\twithFileLockSync(filePath, () => {\n\t\t\tif (!options.overwrite && existsSync(filePath)) {\n\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t`Orchestration profile '${profile.profileId}' already exists in ${scope} scope.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\twriteFileAtomicSync(filePath, serialized);\n\t\t});\n\t\treturn filePath;\n\t}\n\n\tprivate loadScope(\n\t\tscope: OrchestrationProfileScope,\n\t\tdiagnostics: OrchestrationProfileDiagnostic[],\n\t): OrchestrationProfile[] {\n\t\tconst directory = this.directory(scope);\n\t\tif (!existsSync(directory)) return [];\n\t\tlet entries: string[];\n\t\ttry {\n\t\t\tentries = readBoundedDirectoryNamesSync(\n\t\t\t\tdirectory,\n\t\t\t\tMAX_PROFILE_DIRECTORY_ENTRIES,\n\t\t\t\t\"Orchestration profiles directory\",\n\t\t\t)\n\t\t\t\t.filter((entry) => entry.endsWith(\".json\"))\n\t\t\t\t.sort((left, right) => left.localeCompare(right));\n\t\t} catch (error) {\n\t\t\tdiagnostics.push({ scope, path: directory, message: messageFrom(error) });\n\t\t\treturn [];\n\t\t}\n\t\tconst profilesById = new Map<string, OrchestrationProfile>();\n\t\tfor (const entry of entries) {\n\t\t\tconst sourcePath = join(directory, entry);\n\t\t\ttry {\n\t\t\t\tconst profile = parseOrchestrationProfile(\n\t\t\t\t\tJSON.parse(readBoundedTextFileSync(sourcePath, MAX_PROFILE_FILE_BYTES, \"Orchestration profile\")),\n\t\t\t\t\tsourcePath,\n\t\t\t\t);\n\t\t\t\tif (profilesById.has(profile.profileId)) {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Duplicate orchestration profile '${profile.profileId}' in ${scope} scope.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tprofilesById.set(profile.profileId, profile);\n\t\t\t} catch (error) {\n\t\t\t\tdiagnostics.push({ scope, path: sourcePath, message: messageFrom(error) });\n\t\t\t}\n\t\t}\n\t\treturn [...profilesById.values()];\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"risk-budget.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/risk-budget.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,wBAAwB,uFAM3B,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7E,eAAO,MAAM,kBAAkB,sHAAwE,CAAC;AAgBxG,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAYzE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAW1E;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,oBAAoB,EAAE,CAM7G;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,CAAC,GAAG,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,CAWlF","sourcesContent":["import { isPlainRecord } from \"../util/value-guards.ts\";\nimport type { RiskBudget } from \"./contracts.ts\";\n\nexport const RISK_BUDGET_LIMIT_FIELDS = [\n\t\"maxTokens\",\n\t\"maxWallClockMs\",\n\t\"maxCostUsd\",\n\t\"maxAttempts\",\n\t\"maxToolCalls\",\n] as const;\n\nexport type RiskBudgetLimitField = (typeof RISK_BUDGET_LIMIT_FIELDS)[number];\n\nexport const RISK_BUDGET_FIELDS = [...RISK_BUDGET_LIMIT_FIELDS, \"requireApprovalAboveCostUsd\"] as const;\n\nconst DISCRETE_BUDGET_FIELDS: ReadonlySet<(typeof RISK_BUDGET_FIELDS)[number]> = new Set([\n\t\"maxTokens\",\n\t\"maxWallClockMs\",\n\t\"maxAttempts\",\n\t\"maxToolCalls\",\n]);\n\nfunction assertKnownRiskBudgetFields(budget: Record<string, unknown>, label: string): void {\n\tconst unknownField = Object.keys(budget).find(\n\t\t(field) => !RISK_BUDGET_FIELDS.includes(field as (typeof RISK_BUDGET_FIELDS)[number]),\n\t);\n\tif (unknownField) throw new TypeError(`${label} contains an unsupported field.`);\n}\n\n/** Parse raw durable budget input without cloning untrusted values. */\nexport function parseRiskBudget(value: unknown, label: string): RiskBudget {\n\tif (!isPlainRecord(value)) throw new TypeError(`${label} must be an object.`);\n\tassertKnownRiskBudgetFields(value, label);\n\tconst budget: RiskBudget = {};\n\tfor (const field of RISK_BUDGET_FIELDS) {\n\t\tconst candidate = value[field];\n\t\tif (candidate === undefined) continue;\n\t\tif (typeof candidate !== \"number\") throw new TypeError(`${label}.${field} must be a number.`);\n\t\tbudget[field] = candidate;\n\t}\n\tvalidateRiskBudget(budget, label);\n\treturn budget;\n}\n\nexport function validateRiskBudget(budget: RiskBudget, label: string): void {\n\tif (!isPlainRecord(budget)) throw new TypeError(`${label} must be an object.`);\n\tassertKnownRiskBudgetFields(budget, label);\n\tfor (const field of RISK_BUDGET_FIELDS) {\n\t\tconst value = (budget as RiskBudget)[field];\n\t\tif (value === undefined) continue;\n\t\tif (!Number.isFinite(value) || value < 0) throw new TypeError(`${label}.${field} must be non-negative.`);\n\t\tif (DISCRETE_BUDGET_FIELDS.has(field) && !Number.isSafeInteger(value)) {\n\t\t\tthrow new TypeError(`${label}.${field} must be a non-negative safe integer.`);\n\t\t}\n\t}\n}\n\nexport function exceededRiskBudgetFields(requested: RiskBudget, authority: RiskBudget): RiskBudgetLimitField[] {\n\treturn RISK_BUDGET_LIMIT_FIELDS.filter((field) => {\n\t\tconst request = requested[field];\n\t\tconst ceiling = authority[field];\n\t\treturn request !== undefined && ceiling !== undefined && request > ceiling;\n\t});\n}\n\n/** Intersects independent ceilings. Undefined fields do not constrain the result. */\nexport function intersectRiskBudgets(...budgets: readonly RiskBudget[]): RiskBudget {\n\tconst result: RiskBudget = {};\n\tfor (const field of RISK_BUDGET_FIELDS) {\n\t\tconst values = budgets.map((budget) => budget[field]).filter((value): value is number => value !== undefined);\n\t\tif (values.length > 0) result[field] = Math.min(...values);\n\t}\n\tconst approvalThreshold = result.requireApprovalAboveCostUsd;\n\tif (approvalThreshold !== undefined) {\n\t\tresult.maxCostUsd = Math.min(result.maxCostUsd ?? approvalThreshold, approvalThreshold);\n\t}\n\treturn result;\n}\n"]}
1
+ {"version":3,"file":"risk-budget.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/risk-budget.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,wBAAwB,YACpC,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,cAAc,CACL,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7E,eAAO,MAAM,kBAAkB,sHAAwE,CAAC;AAgBxG,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAYzE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAW1E;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,oBAAoB,EAAE,CAM7G;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,CAAC,GAAG,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,CAWlF"}
@@ -1 +1 @@
1
- {"version":3,"file":"risk-budget.js","sourceRoot":"","sources":["../../../src/core/orchestration/risk-budget.ts"],"names":[],"mappings":"AAAA,OAAO,E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,CAAC,GAAG,OAA8B,EAAc;IACnF,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,KAAK,MAAM,KAAK,IAAI,kBAAkB,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;QAC9G,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,iBAAiB,GAAG,MAAM,CAAC,2BAA2B,CAAC;IAC7D,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACrC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,IAAI,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IACzF,CAAC;IACD,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["import { isPlainRecord } from \"../util/value-guards.ts\";\nimport type { RiskBudget } from \"./contracts.ts\";\n\nexport const RISK_BUDGET_LIMIT_FIELDS = [\n\t\"maxTokens\",\n\t\"maxWallClockMs\",\n\t\"maxCostUsd\",\n\t\"maxAttempts\",\n\t\"maxToolCalls\",\n] as const;\n\nexport type RiskBudgetLimitField = (typeof RISK_BUDGET_LIMIT_FIELDS)[number];\n\nexport const RISK_BUDGET_FIELDS = [...RISK_BUDGET_LIMIT_FIELDS, \"requireApprovalAboveCostUsd\"] as const;\n\nconst DISCRETE_BUDGET_FIELDS: ReadonlySet<(typeof RISK_BUDGET_FIELDS)[number]> = new Set([\n\t\"maxTokens\",\n\t\"maxWallClockMs\",\n\t\"maxAttempts\",\n\t\"maxToolCalls\",\n]);\n\nfunction assertKnownRiskBudgetFields(budget: Record<string, unknown>, label: string): void {\n\tconst unknownField = Object.keys(budget).find(\n\t\t(field) => !RISK_BUDGET_FIELDS.includes(field as (typeof RISK_BUDGET_FIELDS)[number]),\n\t);\n\tif (unknownField) throw new TypeError(`${label} contains an unsupported field.`);\n}\n\n/** Parse raw durable budget input without cloning untrusted values. */\nexport function parseRiskBudget(value: unknown, label: string): RiskBudget {\n\tif (!isPlainRecord(value)) throw new TypeError(`${label} must be an object.`);\n\tassertKnownRiskBudgetFields(value, label);\n\tconst budget: RiskBudget = {};\n\tfor (const field of RISK_BUDGET_FIELDS) {\n\t\tconst candidate = value[field];\n\t\tif (candidate === undefined) continue;\n\t\tif (typeof candidate !== \"number\") throw new TypeError(`${label}.${field} must be a number.`);\n\t\tbudget[field] = candidate;\n\t}\n\tvalidateRiskBudget(budget, label);\n\treturn budget;\n}\n\nexport function validateRiskBudget(budget: RiskBudget, label: string): void {\n\tif (!isPlainRecord(budget)) throw new TypeError(`${label} must be an object.`);\n\tassertKnownRiskBudgetFields(budget, label);\n\tfor (const field of RISK_BUDGET_FIELDS) {\n\t\tconst value = (budget as RiskBudget)[field];\n\t\tif (value === undefined) continue;\n\t\tif (!Number.isFinite(value) || value < 0) throw new TypeError(`${label}.${field} must be non-negative.`);\n\t\tif (DISCRETE_BUDGET_FIELDS.has(field) && !Number.isSafeInteger(value)) {\n\t\t\tthrow new TypeError(`${label}.${field} must be a non-negative safe integer.`);\n\t\t}\n\t}\n}\n\nexport function exceededRiskBudgetFields(requested: RiskBudget, authority: RiskBudget): RiskBudgetLimitField[] {\n\treturn RISK_BUDGET_LIMIT_FIELDS.filter((field) => {\n\t\tconst request = requested[field];\n\t\tconst ceiling = authority[field];\n\t\treturn request !== undefined && ceiling !== undefined && request > ceiling;\n\t});\n}\n\n/** Intersects independent ceilings. Undefined fields do not constrain the result. */\nexport function intersectRiskBudgets(...budgets: readonly RiskBudget[]): RiskBudget {\n\tconst result: RiskBudget = {};\n\tfor (const field of RISK_BUDGET_FIELDS) {\n\t\tconst values = budgets.map((budget) => budget[field]).filter((value): value is number => value !== undefined);\n\t\tif (values.length > 0) result[field] = Math.min(...values);\n\t}\n\tconst approvalThreshold = result.requireApprovalAboveCostUsd;\n\tif (approvalThreshold !== undefined) {\n\t\tresult.maxCostUsd = Math.min(result.maxCostUsd ?? approvalThreshold, approvalThreshold);\n\t}\n\treturn result;\n}\n"]}
1
+ {"version":3,"file":"risk-budget.js","sourceRoot":"","sources":["../../../src/core/orchestration/risk-budget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACvC,WAAW;IACX,gBAAgB;IAChB,YAAY;IACZ,aAAa;IACb,cAAc;CACL,CAAC;AAIX,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAG,wBAAwB,EAAE,6BAA6B,CAAU,CAAC;AAExG,MAAM,sBAAsB,GAAqD,IAAI,GAAG,CAAC;IACxF,WAAW;IACX,gBAAgB;IAChB,aAAa;IACb,cAAc;CACd,CAAC,CAAC;AAEH,SAAS,2BAA2B,CAAC,MAA+B,EAAE,KAAa;IAClF,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAC5C,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,KAA4C,CAAC,CACrF,CAAC;IACF,IAAI,YAAY;QAAE,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,iCAAiC,CAAC,CAAC;AAClF,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,eAAe,CAAC,KAAc,EAAE,KAAa;IAC5D,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,qBAAqB,CAAC,CAAC;IAC9E,2BAA2B,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9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AAK,EAAE,EAAE;QAChD,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;QACjC,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,GAAG,OAAO,CAAC;IAC5E,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,oBAAoB,CAAC,GAAG,OAA8B;IACrE,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,KAAK,MAAM,KAAK,IAAI,kBAAkB,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;QAC9G,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,iBAAiB,GAAG,MAAM,CAAC,2BAA2B,CAAC;IAC7D,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACrC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,IAAI,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IACzF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import { isPlainRecord } from \"../util/value-guards.ts\";\nimport type { RiskBudget } from \"./contracts.ts\";\n\nexport const RISK_BUDGET_LIMIT_FIELDS = [\n\t\"maxTokens\",\n\t\"maxWallClockMs\",\n\t\"maxCostUsd\",\n\t\"maxAttempts\",\n\t\"maxToolCalls\",\n] as const;\n\nexport type RiskBudgetLimitField = (typeof RISK_BUDGET_LIMIT_FIELDS)[number];\n\nexport const RISK_BUDGET_FIELDS = [...RISK_BUDGET_LIMIT_FIELDS, \"requireApprovalAboveCostUsd\"] as const;\n\nconst DISCRETE_BUDGET_FIELDS: ReadonlySet<(typeof RISK_BUDGET_FIELDS)[number]> = new Set([\n\t\"maxTokens\",\n\t\"maxWallClockMs\",\n\t\"maxAttempts\",\n\t\"maxToolCalls\",\n]);\n\nfunction assertKnownRiskBudgetFields(budget: Record<string, unknown>, label: string): void {\n\tconst unknownField = Object.keys(budget).find(\n\t\t(field) => !RISK_BUDGET_FIELDS.includes(field as (typeof RISK_BUDGET_FIELDS)[number]),\n\t);\n\tif (unknownField) throw new TypeError(`${label} contains an unsupported field.`);\n}\n\n/** Parse raw durable budget input without cloning untrusted values. */\nexport function parseRiskBudget(value: unknown, label: string): RiskBudget {\n\tif (!isPlainRecord(value)) throw new TypeError(`${label} must be an object.`);\n\tassertKnownRiskBudgetFields(value, label);\n\tconst budget: RiskBudget = {};\n\tfor (const field of RISK_BUDGET_FIELDS) {\n\t\tconst candidate = value[field];\n\t\tif (candidate === undefined) continue;\n\t\tif (typeof candidate !== \"number\") throw new TypeError(`${label}.${field} must be a number.`);\n\t\tbudget[field] = candidate;\n\t}\n\tvalidateRiskBudget(budget, label);\n\treturn budget;\n}\n\nexport function validateRiskBudget(budget: RiskBudget, label: string): void {\n\tif (!isPlainRecord(budget)) throw new TypeError(`${label} must be an object.`);\n\tassertKnownRiskBudgetFields(budget, label);\n\tfor (const field of RISK_BUDGET_FIELDS) {\n\t\tconst value = (budget as RiskBudget)[field];\n\t\tif (value === undefined) continue;\n\t\tif (!Number.isFinite(value) || value < 0) throw new TypeError(`${label}.${field} must be non-negative.`);\n\t\tif (DISCRETE_BUDGET_FIELDS.has(field) && !Number.isSafeInteger(value)) {\n\t\t\tthrow new TypeError(`${label}.${field} must be a non-negative safe integer.`);\n\t\t}\n\t}\n}\n\nexport function exceededRiskBudgetFields(requested: RiskBudget, authority: RiskBudget): RiskBudgetLimitField[] {\n\treturn RISK_BUDGET_LIMIT_FIELDS.filter((field) => {\n\t\tconst request = requested[field];\n\t\tconst ceiling = authority[field];\n\t\treturn request !== undefined && ceiling !== undefined && request > ceiling;\n\t});\n}\n\n/** Intersects independent ceilings. Undefined fields do not constrain the result. */\nexport function intersectRiskBudgets(...budgets: readonly RiskBudget[]): RiskBudget {\n\tconst result: RiskBudget = {};\n\tfor (const field of RISK_BUDGET_FIELDS) {\n\t\tconst values = budgets.map((budget) => budget[field]).filter((value): value is number => value !== undefined);\n\t\tif (values.length > 0) result[field] = Math.min(...values);\n\t}\n\tconst approvalThreshold = result.requireApprovalAboveCostUsd;\n\tif (approvalThreshold !== undefined) {\n\t\tresult.maxCostUsd = Math.min(result.maxCostUsd ?? approvalThreshold, approvalThreshold);\n\t}\n\treturn result;\n}\n"]}
@@ -167,6 +167,7 @@ export declare class DurableTaskRuntime {
167
167
  private requireObjective;
168
168
  private requireDispatchableTask;
169
169
  private requireAttempt;
170
+ private issueLease;
170
171
  private approvalForAttempt;
171
172
  private pendingApprovalForTask;
172
173
  private requireActiveObjectiveForAttempt;