@ai-agent-forge/agent-forge 0.86.7 → 0.88.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (717) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +10 -11
  3. package/dist/artifacts/artifact-store.d.ts.map +1 -1
  4. package/dist/artifacts/artifact-store.js +9 -5
  5. package/dist/artifacts/artifact-store.js.map +1 -1
  6. package/dist/bundle/.build-manifest.json +430 -413
  7. package/dist/bundle/chunks/{chunk-A7GUOX2H.js → chunk-6ZKDNZHA.js} +5 -1
  8. package/dist/bundle/chunks/chunk-HLJEVRWP.js +13 -0
  9. package/dist/bundle/chunks/chunk-YGHQME4V.js +1456 -0
  10. package/dist/bundle/chunks/image-resize-worker.js +12 -1
  11. package/dist/bundle/chunks/{virtual-modules-3IZ4MYSQ.js → virtual-modules-KZ5DRH7Q.js} +1 -1
  12. package/dist/bundle/cli.js +1 -1
  13. package/dist/bundle/client.js +1 -1
  14. package/dist/bundle/index.js +2 -2
  15. package/dist/bundle/rpc-entry.js +1 -1
  16. package/dist/cli/args.d.ts.map +1 -1
  17. package/dist/cli/args.js +231 -185
  18. package/dist/cli/args.js.map +1 -1
  19. package/dist/cli/auth-check.d.ts.map +1 -1
  20. package/dist/cli/auth-check.js +17 -4
  21. package/dist/cli/auth-check.js.map +1 -1
  22. package/dist/cli/auth-command.d.ts.map +1 -1
  23. package/dist/cli/auth-command.js +15 -9
  24. package/dist/cli/auth-command.js.map +1 -1
  25. package/dist/cli/credential-print.d.ts.map +1 -1
  26. package/dist/cli/credential-print.js +14 -7
  27. package/dist/cli/credential-print.js.map +1 -1
  28. package/dist/cli/experimental/command.d.ts.map +1 -1
  29. package/dist/cli/experimental/command.js +6 -5
  30. package/dist/cli/experimental/command.js.map +1 -1
  31. package/dist/cli/list-models.d.ts.map +1 -1
  32. package/dist/cli/list-models.js +9 -8
  33. package/dist/cli/list-models.js.map +1 -1
  34. package/dist/cli/plugin-manager-controller.d.ts.map +1 -1
  35. package/dist/cli/plugin-manager-controller.js +2 -1
  36. package/dist/cli/plugin-manager-controller.js.map +1 -1
  37. package/dist/cli/serve.d.ts.map +1 -1
  38. package/dist/cli/serve.js +8 -5
  39. package/dist/cli/serve.js.map +1 -1
  40. package/dist/client/remote-session.d.ts.map +1 -1
  41. package/dist/client/remote-session.js +16 -9
  42. package/dist/client/remote-session.js.map +1 -1
  43. package/dist/config.d.ts.map +1 -1
  44. package/dist/config.js +5 -3
  45. package/dist/config.js.map +1 -1
  46. package/dist/core/agent-capability-contract.d.ts +0 -7
  47. package/dist/core/agent-capability-contract.d.ts.map +1 -1
  48. package/dist/core/agent-capability-contract.js +72 -68
  49. package/dist/core/agent-capability-contract.js.map +1 -1
  50. package/dist/core/agent-session-bash.d.ts.map +1 -1
  51. package/dist/core/agent-session-bash.js +5 -4
  52. package/dist/core/agent-session-bash.js.map +1 -1
  53. package/dist/core/agent-session-compaction.d.ts +6 -10
  54. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  55. package/dist/core/agent-session-compaction.js +35 -133
  56. package/dist/core/agent-session-compaction.js.map +1 -1
  57. package/dist/core/agent-session-context.d.ts.map +1 -1
  58. package/dist/core/agent-session-context.js +18 -13
  59. package/dist/core/agent-session-context.js.map +1 -1
  60. package/dist/core/agent-session-internal.d.ts +0 -6
  61. package/dist/core/agent-session-internal.d.ts.map +1 -1
  62. package/dist/core/agent-session-internal.js.map +1 -1
  63. package/dist/core/agent-session-model.d.ts.map +1 -1
  64. package/dist/core/agent-session-model.js +2 -1
  65. package/dist/core/agent-session-model.js.map +1 -1
  66. package/dist/core/agent-session-retry.d.ts.map +1 -1
  67. package/dist/core/agent-session-retry.js +3 -3
  68. package/dist/core/agent-session-retry.js.map +1 -1
  69. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  70. package/dist/core/agent-session-runtime.js +7 -6
  71. package/dist/core/agent-session-runtime.js.map +1 -1
  72. package/dist/core/agent-session-services.d.ts +1 -1
  73. package/dist/core/agent-session-services.d.ts.map +1 -1
  74. package/dist/core/agent-session-services.js.map +1 -1
  75. package/dist/core/agent-session-tools.d.ts.map +1 -1
  76. package/dist/core/agent-session-tools.js +3 -2
  77. package/dist/core/agent-session-tools.js.map +1 -1
  78. package/dist/core/agent-session.d.ts +40 -22
  79. package/dist/core/agent-session.d.ts.map +1 -1
  80. package/dist/core/agent-session.js +147 -67
  81. package/dist/core/agent-session.js.map +1 -1
  82. package/dist/core/auth-guidance.d.ts.map +1 -1
  83. package/dist/core/auth-guidance.js +11 -5
  84. package/dist/core/auth-guidance.js.map +1 -1
  85. package/dist/core/auth-storage.d.ts.map +1 -1
  86. package/dist/core/auth-storage.js +9 -6
  87. package/dist/core/auth-storage.js.map +1 -1
  88. package/dist/core/compaction/compaction.d.ts.map +1 -1
  89. package/dist/core/compaction/compaction.js +2 -1
  90. package/dist/core/compaction/compaction.js.map +1 -1
  91. package/dist/core/embedded-sdk.d.ts.map +1 -1
  92. package/dist/core/embedded-sdk.js +10 -6
  93. package/dist/core/embedded-sdk.js.map +1 -1
  94. package/dist/core/export-html/index.d.ts.map +1 -1
  95. package/dist/core/export-html/index.js +9 -4
  96. package/dist/core/export-html/index.js.map +1 -1
  97. package/dist/core/extensions/agent-composition.d.ts.map +1 -1
  98. package/dist/core/extensions/agent-composition.js +26 -19
  99. package/dist/core/extensions/agent-composition.js.map +1 -1
  100. package/dist/core/extensions/bootstrap-agent-loop.d.ts.map +1 -1
  101. package/dist/core/extensions/bootstrap-agent-loop.js +3 -2
  102. package/dist/core/extensions/bootstrap-agent-loop.js.map +1 -1
  103. package/dist/core/extensions/bootstrap-compaction-policy.d.ts.map +1 -1
  104. package/dist/core/extensions/bootstrap-compaction-policy.js +0 -34
  105. package/dist/core/extensions/bootstrap-compaction-policy.js.map +1 -1
  106. package/dist/core/extensions/bootstrap-lifecycle.d.ts.map +1 -1
  107. package/dist/core/extensions/bootstrap-lifecycle.js +20 -17
  108. package/dist/core/extensions/bootstrap-lifecycle.js.map +1 -1
  109. package/dist/core/extensions/bootstrap-overflow-policy.d.ts.map +1 -1
  110. package/dist/core/extensions/bootstrap-overflow-policy.js +2 -1
  111. package/dist/core/extensions/bootstrap-overflow-policy.js.map +1 -1
  112. package/dist/core/extensions/bootstrap-retry-policy.d.ts.map +1 -1
  113. package/dist/core/extensions/bootstrap-retry-policy.js +4 -3
  114. package/dist/core/extensions/bootstrap-retry-policy.js.map +1 -1
  115. package/dist/core/extensions/bootstrap-skills.d.ts.map +1 -1
  116. package/dist/core/extensions/bootstrap-skills.js +7 -6
  117. package/dist/core/extensions/bootstrap-skills.js.map +1 -1
  118. package/dist/core/extensions/bootstrap-tools.d.ts.map +1 -1
  119. package/dist/core/extensions/bootstrap-tools.js +2 -1
  120. package/dist/core/extensions/bootstrap-tools.js.map +1 -1
  121. package/dist/core/extensions/capability-plugin.d.ts.map +1 -1
  122. package/dist/core/extensions/capability-plugin.js +37 -13
  123. package/dist/core/extensions/capability-plugin.js.map +1 -1
  124. package/dist/core/extensions/capability-runtime-events.d.ts.map +1 -1
  125. package/dist/core/extensions/capability-runtime-events.js +17 -13
  126. package/dist/core/extensions/capability-runtime-events.js.map +1 -1
  127. package/dist/core/extensions/capability-runtime-guards.d.ts.map +1 -1
  128. package/dist/core/extensions/capability-runtime-guards.js +16 -15
  129. package/dist/core/extensions/capability-runtime-guards.js.map +1 -1
  130. package/dist/core/extensions/capability-runtime-manifest.d.ts.map +1 -1
  131. package/dist/core/extensions/capability-runtime-manifest.js +52 -30
  132. package/dist/core/extensions/capability-runtime-manifest.js.map +1 -1
  133. package/dist/core/extensions/capability-runtime-validation.d.ts.map +1 -1
  134. package/dist/core/extensions/capability-runtime-validation.js +66 -65
  135. package/dist/core/extensions/capability-runtime-validation.js.map +1 -1
  136. package/dist/core/extensions/capability-runtime.d.ts.map +1 -1
  137. package/dist/core/extensions/capability-runtime.js +147 -127
  138. package/dist/core/extensions/capability-runtime.js.map +1 -1
  139. package/dist/core/extensions/compaction-memory-failure-mode.d.ts.map +1 -1
  140. package/dist/core/extensions/compaction-memory-failure-mode.js +3 -2
  141. package/dist/core/extensions/compaction-memory-failure-mode.js.map +1 -1
  142. package/dist/core/extensions/context-strategy-binding.d.ts.map +1 -1
  143. package/dist/core/extensions/context-strategy-binding.js +7 -4
  144. package/dist/core/extensions/context-strategy-binding.js.map +1 -1
  145. package/dist/core/extensions/lifecycle-catalog.d.ts.map +1 -1
  146. package/dist/core/extensions/lifecycle-catalog.js +290 -279
  147. package/dist/core/extensions/lifecycle-catalog.js.map +1 -1
  148. package/dist/core/extensions/lifecycle-delivery-queue.d.ts.map +1 -1
  149. package/dist/core/extensions/lifecycle-delivery-queue.js +3 -2
  150. package/dist/core/extensions/lifecycle-delivery-queue.js.map +1 -1
  151. package/dist/core/extensions/provider-failover.d.ts +7 -3
  152. package/dist/core/extensions/provider-failover.d.ts.map +1 -1
  153. package/dist/core/extensions/provider-failover.js +9 -8
  154. package/dist/core/extensions/provider-failover.js.map +1 -1
  155. package/dist/core/facade/coding-agent-facade.d.ts +6 -6
  156. package/dist/core/facade/coding-agent-facade.d.ts.map +1 -1
  157. package/dist/core/facade/coding-agent-facade.js +2 -3
  158. package/dist/core/facade/coding-agent-facade.js.map +1 -1
  159. package/dist/core/http-dispatcher.d.ts.map +1 -1
  160. package/dist/core/http-dispatcher.js +2 -1
  161. package/dist/core/http-dispatcher.js.map +1 -1
  162. package/dist/core/i18n/index.d.ts +14 -0
  163. package/dist/core/i18n/index.d.ts.map +1 -0
  164. package/dist/core/i18n/index.js +67 -0
  165. package/dist/core/i18n/index.js.map +1 -0
  166. package/dist/core/i18n/locales/en/example.d.ts +7 -0
  167. package/dist/core/i18n/locales/en/example.d.ts.map +1 -0
  168. package/dist/core/i18n/locales/en/example.js +7 -0
  169. package/dist/core/i18n/locales/en/example.js.map +1 -0
  170. package/dist/core/i18n/locales/zh-cn/cli.d.ts +8 -0
  171. package/dist/core/i18n/locales/zh-cn/cli.d.ts.map +1 -0
  172. package/dist/core/i18n/locales/zh-cn/cli.js +229 -0
  173. package/dist/core/i18n/locales/zh-cn/cli.js.map +1 -0
  174. package/dist/core/i18n/locales/zh-cn/common.d.ts +6 -0
  175. package/dist/core/i18n/locales/zh-cn/common.d.ts.map +1 -0
  176. package/dist/core/i18n/locales/zh-cn/common.js +6 -0
  177. package/dist/core/i18n/locales/zh-cn/common.js.map +1 -0
  178. package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts +13 -0
  179. package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts.map +1 -0
  180. package/dist/core/i18n/locales/zh-cn/core-contract-core.js +173 -0
  181. package/dist/core/i18n/locales/zh-cn/core-contract-core.js.map +1 -0
  182. package/dist/core/i18n/locales/zh-cn/core-contract-extensions.d.ts +12 -0
  183. package/dist/core/i18n/locales/zh-cn/core-contract-extensions.d.ts.map +1 -0
  184. package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js +582 -0
  185. package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js.map +1 -0
  186. package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts +9 -0
  187. package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts.map +1 -0
  188. package/dist/core/i18n/locales/zh-cn/core-contract-final.js +55 -0
  189. package/dist/core/i18n/locales/zh-cn/core-contract-final.js.map +1 -0
  190. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.d.ts +11 -0
  191. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.d.ts.map +1 -0
  192. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js +455 -0
  193. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js.map +1 -0
  194. package/dist/core/i18n/locales/zh-cn/core-errors.d.ts +9 -0
  195. package/dist/core/i18n/locales/zh-cn/core-errors.d.ts.map +1 -0
  196. package/dist/core/i18n/locales/zh-cn/core-errors.js +191 -0
  197. package/dist/core/i18n/locales/zh-cn/core-errors.js.map +1 -0
  198. package/dist/core/i18n/locales/zh-cn/example.d.ts +7 -0
  199. package/dist/core/i18n/locales/zh-cn/example.d.ts.map +1 -0
  200. package/dist/core/i18n/locales/zh-cn/example.js +10 -0
  201. package/dist/core/i18n/locales/zh-cn/example.js.map +1 -0
  202. package/dist/core/i18n/locales/zh-cn/index.d.ts +2 -0
  203. package/dist/core/i18n/locales/zh-cn/index.d.ts.map +1 -0
  204. package/dist/core/i18n/locales/zh-cn/index.js +41 -0
  205. package/dist/core/i18n/locales/zh-cn/index.js.map +1 -0
  206. package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts +10 -0
  207. package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts.map +1 -0
  208. package/dist/core/i18n/locales/zh-cn/interactive-mode.js +267 -0
  209. package/dist/core/i18n/locales/zh-cn/interactive-mode.js.map +1 -0
  210. package/dist/core/i18n/locales/zh-cn/keybindings.d.ts +11 -0
  211. package/dist/core/i18n/locales/zh-cn/keybindings.d.ts.map +1 -0
  212. package/dist/core/i18n/locales/zh-cn/keybindings.js +67 -0
  213. package/dist/core/i18n/locales/zh-cn/keybindings.js.map +1 -0
  214. package/dist/core/i18n/locales/zh-cn/slash-commands.d.ts +7 -0
  215. package/dist/core/i18n/locales/zh-cn/slash-commands.d.ts.map +1 -0
  216. package/dist/core/i18n/locales/zh-cn/slash-commands.js +39 -0
  217. package/dist/core/i18n/locales/zh-cn/slash-commands.js.map +1 -0
  218. package/dist/core/i18n/locales/zh-cn/tui-builtin.d.ts +10 -0
  219. package/dist/core/i18n/locales/zh-cn/tui-builtin.d.ts.map +1 -0
  220. package/dist/core/i18n/locales/zh-cn/tui-builtin.js +15 -0
  221. package/dist/core/i18n/locales/zh-cn/tui-builtin.js.map +1 -0
  222. package/dist/core/i18n/locales/zh-cn/tui-components-misc.d.ts +13 -0
  223. package/dist/core/i18n/locales/zh-cn/tui-components-misc.d.ts.map +1 -0
  224. package/dist/core/i18n/locales/zh-cn/tui-components-misc.js +102 -0
  225. package/dist/core/i18n/locales/zh-cn/tui-components-misc.js.map +1 -0
  226. package/dist/core/i18n/locales/zh-cn/tui-components-selectors.d.ts +12 -0
  227. package/dist/core/i18n/locales/zh-cn/tui-components-selectors.d.ts.map +1 -0
  228. package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js +286 -0
  229. package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js.map +1 -0
  230. package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.d.ts +9 -0
  231. package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.d.ts.map +1 -0
  232. package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.js +79 -0
  233. package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.js.map +1 -0
  234. package/dist/core/i18n/locales/zh-cn/tui-self-owned.d.ts +8 -0
  235. package/dist/core/i18n/locales/zh-cn/tui-self-owned.d.ts.map +1 -0
  236. package/dist/core/i18n/locales/zh-cn/tui-self-owned.js +72 -0
  237. package/dist/core/i18n/locales/zh-cn/tui-self-owned.js.map +1 -0
  238. package/dist/core/keybindings.d.ts +15 -0
  239. package/dist/core/keybindings.d.ts.map +1 -1
  240. package/dist/core/keybindings.js +18 -0
  241. package/dist/core/keybindings.js.map +1 -1
  242. package/dist/core/logger.d.ts.map +1 -1
  243. package/dist/core/logger.js +5 -1
  244. package/dist/core/logger.js.map +1 -1
  245. package/dist/core/model-config.d.ts +0 -1
  246. package/dist/core/model-config.d.ts.map +1 -1
  247. package/dist/core/model-config.js +9 -1
  248. package/dist/core/model-config.js.map +1 -1
  249. package/dist/core/model-registry.d.ts.map +1 -1
  250. package/dist/core/model-registry.js +2 -1
  251. package/dist/core/model-registry.js.map +1 -1
  252. package/dist/core/model-runtime.d.ts.map +1 -1
  253. package/dist/core/model-runtime.js +11 -7
  254. package/dist/core/model-runtime.js.map +1 -1
  255. package/dist/core/package-install-host.d.ts.map +1 -1
  256. package/dist/core/package-install-host.js +4 -3
  257. package/dist/core/package-install-host.js.map +1 -1
  258. package/dist/core/package-manager.d.ts.map +1 -1
  259. package/dist/core/package-manager.js +15 -10
  260. package/dist/core/package-manager.js.map +1 -1
  261. package/dist/core/package-resource-collection.d.ts.map +1 -1
  262. package/dist/core/package-resource-collection.js +2 -1
  263. package/dist/core/package-resource-collection.js.map +1 -1
  264. package/dist/core/package-source.d.ts.map +1 -1
  265. package/dist/core/package-source.js +3 -2
  266. package/dist/core/package-source.js.map +1 -1
  267. package/dist/core/provider-composer.d.ts +2 -2
  268. package/dist/core/provider-composer.d.ts.map +1 -1
  269. package/dist/core/provider-composer.js +29 -21
  270. package/dist/core/provider-composer.js.map +1 -1
  271. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  272. package/dist/core/remote-catalog-provider.js +6 -2
  273. package/dist/core/remote-catalog-provider.js.map +1 -1
  274. package/dist/core/resolve-config-value.d.ts.map +1 -1
  275. package/dist/core/resolve-config-value.js +15 -5
  276. package/dist/core/resolve-config-value.js.map +1 -1
  277. package/dist/core/sdk.d.ts +27 -5
  278. package/dist/core/sdk.d.ts.map +1 -1
  279. package/dist/core/sdk.js +80 -55
  280. package/dist/core/sdk.js.map +1 -1
  281. package/dist/core/session-cwd.d.ts.map +1 -1
  282. package/dist/core/session-cwd.js +5 -2
  283. package/dist/core/session-cwd.js.map +1 -1
  284. package/dist/core/session-export.d.ts.map +1 -1
  285. package/dist/core/session-export.js +2 -1
  286. package/dist/core/session-export.js.map +1 -1
  287. package/dist/core/session-manager.d.ts.map +1 -1
  288. package/dist/core/session-manager.js +39 -29
  289. package/dist/core/session-manager.js.map +1 -1
  290. package/dist/core/session-storage.d.ts.map +1 -1
  291. package/dist/core/session-storage.js +3 -3
  292. package/dist/core/session-storage.js.map +1 -1
  293. package/dist/core/settings-manager.d.ts +20 -20
  294. package/dist/core/settings-manager.d.ts.map +1 -1
  295. package/dist/core/settings-manager.js +47 -59
  296. package/dist/core/settings-manager.js.map +1 -1
  297. package/dist/core/slash-commands.d.ts.map +1 -1
  298. package/dist/core/slash-commands.js +53 -32
  299. package/dist/core/slash-commands.js.map +1 -1
  300. package/dist/core/system-prompt.d.ts.map +1 -1
  301. package/dist/core/system-prompt.js +25 -2
  302. package/dist/core/system-prompt.js.map +1 -1
  303. package/dist/core/tools/bash.d.ts.map +1 -1
  304. package/dist/core/tools/bash.js +11 -7
  305. package/dist/core/tools/bash.js.map +1 -1
  306. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  307. package/dist/core/tools/edit-diff.js +9 -4
  308. package/dist/core/tools/edit-diff.js.map +1 -1
  309. package/dist/core/tools/edit.d.ts.map +1 -1
  310. package/dist/core/tools/edit.js +4 -3
  311. package/dist/core/tools/edit.js.map +1 -1
  312. package/dist/core/tools/index.d.ts.map +1 -1
  313. package/dist/core/tools/index.js +3 -2
  314. package/dist/core/tools/index.js.map +1 -1
  315. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  316. package/dist/core/tools/output-accumulator.js +2 -1
  317. package/dist/core/tools/output-accumulator.js.map +1 -1
  318. package/dist/core/tools/read.d.ts.map +1 -1
  319. package/dist/core/tools/read.js +6 -2
  320. package/dist/core/tools/read.js.map +1 -1
  321. package/dist/core/tools/write.d.ts.map +1 -1
  322. package/dist/core/tools/write.js +2 -1
  323. package/dist/core/tools/write.js.map +1 -1
  324. package/dist/durable/durable-service.d.ts.map +1 -1
  325. package/dist/durable/durable-service.js +25 -18
  326. package/dist/durable/durable-service.js.map +1 -1
  327. package/dist/host/checkpoint-commit.d.ts.map +1 -1
  328. package/dist/host/checkpoint-commit.js +2 -1
  329. package/dist/host/checkpoint-commit.js.map +1 -1
  330. package/dist/host/manual-compaction.d.ts.map +1 -1
  331. package/dist/host/manual-compaction.js +2 -1
  332. package/dist/host/manual-compaction.js.map +1 -1
  333. package/dist/host/output-projection.d.ts +0 -13
  334. package/dist/host/output-projection.d.ts.map +1 -1
  335. package/dist/host/output-projection.js +16 -2
  336. package/dist/host/output-projection.js.map +1 -1
  337. package/dist/host/summary-retry.d.ts.map +1 -1
  338. package/dist/host/summary-retry.js +3 -2
  339. package/dist/host/summary-retry.js.map +1 -1
  340. package/dist/main.d.ts.map +1 -1
  341. package/dist/main.js +97 -60
  342. package/dist/main.js.map +1 -1
  343. package/dist/modes/interactive/components/agents-view.d.ts.map +1 -1
  344. package/dist/modes/interactive/components/agents-view.js +18 -15
  345. package/dist/modes/interactive/components/agents-view.js.map +1 -1
  346. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  347. package/dist/modes/interactive/components/assistant-message.js +6 -5
  348. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  349. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  350. package/dist/modes/interactive/components/bash-execution.js +12 -7
  351. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  352. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  353. package/dist/modes/interactive/components/bordered-loader.js +2 -1
  354. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  355. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  356. package/dist/modes/interactive/components/branch-summary-message.js +6 -5
  357. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  358. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  359. package/dist/modes/interactive/components/compaction-summary-message.js +9 -5
  360. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  361. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  362. package/dist/modes/interactive/components/config-selector.js +18 -15
  363. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  364. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  365. package/dist/modes/interactive/components/custom-entry.js +2 -1
  366. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  367. package/dist/modes/interactive/components/dialog-editor.d.ts.map +1 -1
  368. package/dist/modes/interactive/components/dialog-editor.js +5 -4
  369. package/dist/modes/interactive/components/dialog-editor.js.map +1 -1
  370. package/dist/modes/interactive/components/dialog-input.d.ts.map +1 -1
  371. package/dist/modes/interactive/components/dialog-input.js +2 -1
  372. package/dist/modes/interactive/components/dialog-input.js.map +1 -1
  373. package/dist/modes/interactive/components/dialog-selector.d.ts.map +1 -1
  374. package/dist/modes/interactive/components/dialog-selector.js +4 -3
  375. package/dist/modes/interactive/components/dialog-selector.js.map +1 -1
  376. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  377. package/dist/modes/interactive/components/first-time-setup.js +11 -10
  378. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  379. package/dist/modes/interactive/components/footer.d.ts +0 -2
  380. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  381. package/dist/modes/interactive/components/footer.js +8 -10
  382. package/dist/modes/interactive/components/footer.js.map +1 -1
  383. package/dist/modes/interactive/components/index.d.ts +1 -0
  384. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  385. package/dist/modes/interactive/components/index.js +1 -0
  386. package/dist/modes/interactive/components/index.js.map +1 -1
  387. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  388. package/dist/modes/interactive/components/keybinding-hints.js +3 -2
  389. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  390. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  391. package/dist/modes/interactive/components/login-dialog.js +12 -11
  392. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  393. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  394. package/dist/modes/interactive/components/mermaid.js +6 -2
  395. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  396. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  397. package/dist/modes/interactive/components/model-selector.js +28 -16
  398. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  399. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  400. package/dist/modes/interactive/components/oauth-selector.js +10 -9
  401. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  402. package/dist/modes/interactive/components/plugin-manager-entry.d.ts.map +1 -1
  403. package/dist/modes/interactive/components/plugin-manager-entry.js +22 -13
  404. package/dist/modes/interactive/components/plugin-manager-entry.js.map +1 -1
  405. package/dist/modes/interactive/components/plugin-selection-entry.d.ts.map +1 -1
  406. package/dist/modes/interactive/components/plugin-selection-entry.js +27 -12
  407. package/dist/modes/interactive/components/plugin-selection-entry.js.map +1 -1
  408. package/dist/modes/interactive/components/queue-manager-selector.d.ts +60 -0
  409. package/dist/modes/interactive/components/queue-manager-selector.d.ts.map +1 -0
  410. package/dist/modes/interactive/components/queue-manager-selector.js +166 -0
  411. package/dist/modes/interactive/components/queue-manager-selector.js.map +1 -0
  412. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  413. package/dist/modes/interactive/components/scoped-models-selector.js +16 -14
  414. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  415. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  416. package/dist/modes/interactive/components/session-selector.js +43 -31
  417. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  418. package/dist/modes/interactive/components/settings-selector.d.ts +4 -6
  419. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  420. package/dist/modes/interactive/components/settings-selector.js +115 -120
  421. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  422. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
  423. package/dist/modes/interactive/components/settings-submenu.js +5 -4
  424. package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
  425. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  426. package/dist/modes/interactive/components/show-images-selector.js +3 -2
  427. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  428. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  429. package/dist/modes/interactive/components/skill-invocation-message.js +4 -3
  430. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  431. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  432. package/dist/modes/interactive/components/status-indicator.js +14 -5
  433. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  434. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  435. package/dist/modes/interactive/components/theme-selector.js +2 -1
  436. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  437. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  438. package/dist/modes/interactive/components/thinking-selector.js +11 -4
  439. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  440. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  441. package/dist/modes/interactive/components/tool-execution.js +8 -3
  442. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  443. package/dist/modes/interactive/components/tree-list.d.ts.map +1 -1
  444. package/dist/modes/interactive/components/tree-list.js +7 -6
  445. package/dist/modes/interactive/components/tree-list.js.map +1 -1
  446. package/dist/modes/interactive/components/tree-render.d.ts.map +1 -1
  447. package/dist/modes/interactive/components/tree-render.js +28 -23
  448. package/dist/modes/interactive/components/tree-render.js.map +1 -1
  449. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  450. package/dist/modes/interactive/components/tree-selector.js +9 -7
  451. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  452. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  453. package/dist/modes/interactive/components/user-message-selector.js +5 -4
  454. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  455. package/dist/modes/interactive/components/workflow-view.d.ts.map +1 -1
  456. package/dist/modes/interactive/components/workflow-view.js +36 -21
  457. package/dist/modes/interactive/components/workflow-view.js.map +1 -1
  458. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  459. package/dist/modes/interactive/external-editor.js +2 -1
  460. package/dist/modes/interactive/external-editor.js.map +1 -1
  461. package/dist/modes/interactive/interactive-auth.d.ts.map +1 -1
  462. package/dist/modes/interactive/interactive-auth.js +71 -40
  463. package/dist/modes/interactive/interactive-auth.js.map +1 -1
  464. package/dist/modes/interactive/interactive-commands.d.ts +1 -0
  465. package/dist/modes/interactive/interactive-commands.d.ts.map +1 -1
  466. package/dist/modes/interactive/interactive-commands.js +3 -0
  467. package/dist/modes/interactive/interactive-commands.js.map +1 -1
  468. package/dist/modes/interactive/interactive-dialog-ui.d.ts.map +1 -1
  469. package/dist/modes/interactive/interactive-dialog-ui.js +5 -5
  470. package/dist/modes/interactive/interactive-dialog-ui.js.map +1 -1
  471. package/dist/modes/interactive/interactive-format.d.ts.map +1 -1
  472. package/dist/modes/interactive/interactive-format.js +34 -18
  473. package/dist/modes/interactive/interactive-format.js.map +1 -1
  474. package/dist/modes/interactive/interactive-helpers.d.ts.map +1 -1
  475. package/dist/modes/interactive/interactive-helpers.js +7 -2
  476. package/dist/modes/interactive/interactive-helpers.js.map +1 -1
  477. package/dist/modes/interactive/interactive-mode.d.ts +4 -2
  478. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  479. package/dist/modes/interactive/interactive-mode.js +350 -279
  480. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  481. package/dist/modes/interactive/interactive-selectors.d.ts +9 -0
  482. package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
  483. package/dist/modes/interactive/interactive-selectors.js +79 -25
  484. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  485. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  486. package/dist/modes/interactive/theme/theme-controller.js +5 -1
  487. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  488. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  489. package/dist/modes/interactive/theme/theme.js +26 -23
  490. package/dist/modes/interactive/theme/theme.js.map +1 -1
  491. package/dist/modes/json-event.d.ts.map +1 -1
  492. package/dist/modes/json-event.js +3 -2
  493. package/dist/modes/json-event.js.map +1 -1
  494. package/dist/modes/print-mode.d.ts.map +1 -1
  495. package/dist/modes/print-mode.js +3 -2
  496. package/dist/modes/print-mode.js.map +1 -1
  497. package/dist/modes/rpc/rpc-client.d.ts +0 -8
  498. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  499. package/dist/modes/rpc/rpc-client.js +3 -14
  500. package/dist/modes/rpc/rpc-client.js.map +1 -1
  501. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  502. package/dist/modes/rpc/rpc-mode.js +0 -9
  503. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  504. package/dist/modes/rpc/rpc-types.d.ts +0 -19
  505. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  506. package/dist/modes/rpc/rpc-types.js.map +1 -1
  507. package/dist/package-manager-cli.d.ts.map +1 -1
  508. package/dist/package-manager-cli.js +28 -13
  509. package/dist/package-manager-cli.js.map +1 -1
  510. package/dist/plugins/ecosystem/catalog.d.ts.map +1 -1
  511. package/dist/plugins/ecosystem/catalog.js +3 -2
  512. package/dist/plugins/ecosystem/catalog.js.map +1 -1
  513. package/dist/plugins/ecosystem/cli.d.ts.map +1 -1
  514. package/dist/plugins/ecosystem/cli.js +2 -1
  515. package/dist/plugins/ecosystem/cli.js.map +1 -1
  516. package/dist/plugins/ecosystem/default-plugin-market.d.ts.map +1 -1
  517. package/dist/plugins/ecosystem/default-plugin-market.js +3 -2
  518. package/dist/plugins/ecosystem/default-plugin-market.js.map +1 -1
  519. package/dist/plugins/ecosystem/distribution.d.ts.map +1 -1
  520. package/dist/plugins/ecosystem/distribution.js +2 -1
  521. package/dist/plugins/ecosystem/distribution.js.map +1 -1
  522. package/dist/plugins/ecosystem/installer.d.ts.map +1 -1
  523. package/dist/plugins/ecosystem/installer.js +3 -2
  524. package/dist/plugins/ecosystem/installer.js.map +1 -1
  525. package/dist/plugins/ecosystem/node-disk-registry-source.d.ts.map +1 -1
  526. package/dist/plugins/ecosystem/node-disk-registry-source.js +20 -17
  527. package/dist/plugins/ecosystem/node-disk-registry-source.js.map +1 -1
  528. package/dist/plugins/ecosystem/node-distribution-host.d.ts.map +1 -1
  529. package/dist/plugins/ecosystem/node-distribution-host.js +35 -34
  530. package/dist/plugins/ecosystem/node-distribution-host.js.map +1 -1
  531. package/dist/plugins/ecosystem/node-npm-registry-source.d.ts.map +1 -1
  532. package/dist/plugins/ecosystem/node-npm-registry-source.js +35 -34
  533. package/dist/plugins/ecosystem/node-npm-registry-source.js.map +1 -1
  534. package/dist/plugins/ecosystem/node-package-install-host.d.ts.map +1 -1
  535. package/dist/plugins/ecosystem/node-package-install-host.js +9 -8
  536. package/dist/plugins/ecosystem/node-package-install-host.js.map +1 -1
  537. package/dist/plugins/ecosystem/node-package-install-persistence.d.ts.map +1 -1
  538. package/dist/plugins/ecosystem/node-package-install-persistence.js +4 -3
  539. package/dist/plugins/ecosystem/node-package-install-persistence.js.map +1 -1
  540. package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts +9 -2
  541. package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts.map +1 -1
  542. package/dist/plugins/ecosystem/node-plugin-bootstrap.js +44 -5
  543. package/dist/plugins/ecosystem/node-plugin-bootstrap.js.map +1 -1
  544. package/dist/plugins/ecosystem/node-plugin-trust-root.d.ts.map +1 -1
  545. package/dist/plugins/ecosystem/node-plugin-trust-root.js +10 -9
  546. package/dist/plugins/ecosystem/node-plugin-trust-root.js.map +1 -1
  547. package/dist/plugins/ecosystem/node-registry-source.d.ts.map +1 -1
  548. package/dist/plugins/ecosystem/node-registry-source.js +31 -30
  549. package/dist/plugins/ecosystem/node-registry-source.js.map +1 -1
  550. package/dist/plugins/ecosystem/node-release-package-source.d.ts.map +1 -1
  551. package/dist/plugins/ecosystem/node-release-package-source.js +30 -29
  552. package/dist/plugins/ecosystem/node-release-package-source.js.map +1 -1
  553. package/dist/plugins/ecosystem/node-tar-writer.d.ts.map +1 -1
  554. package/dist/plugins/ecosystem/node-tar-writer.js +11 -10
  555. package/dist/plugins/ecosystem/node-tar-writer.js.map +1 -1
  556. package/dist/plugins/ecosystem/node-url-package-source.d.ts.map +1 -1
  557. package/dist/plugins/ecosystem/node-url-package-source.js +21 -20
  558. package/dist/plugins/ecosystem/node-url-package-source.js.map +1 -1
  559. package/dist/plugins/ecosystem/plugin-acquisition.d.ts.map +1 -1
  560. package/dist/plugins/ecosystem/plugin-acquisition.js +3 -2
  561. package/dist/plugins/ecosystem/plugin-acquisition.js.map +1 -1
  562. package/dist/plugins/ecosystem/plugin-bootstrap.d.ts +9 -1
  563. package/dist/plugins/ecosystem/plugin-bootstrap.d.ts.map +1 -1
  564. package/dist/plugins/ecosystem/plugin-bootstrap.js +5 -0
  565. package/dist/plugins/ecosystem/plugin-bootstrap.js.map +1 -1
  566. package/dist/plugins/ecosystem/registry-cli-adapter.d.ts.map +1 -1
  567. package/dist/plugins/ecosystem/registry-cli-adapter.js +2 -1
  568. package/dist/plugins/ecosystem/registry-cli-adapter.js.map +1 -1
  569. package/dist/plugins/ecosystem/registry.d.ts.map +1 -1
  570. package/dist/plugins/ecosystem/registry.js +35 -32
  571. package/dist/plugins/ecosystem/registry.js.map +1 -1
  572. package/dist/plugins/ecosystem/resolver.d.ts.map +1 -1
  573. package/dist/plugins/ecosystem/resolver.js +3 -2
  574. package/dist/plugins/ecosystem/resolver.js.map +1 -1
  575. package/dist/plugins/ecosystem/selection-store.d.ts.map +1 -1
  576. package/dist/plugins/ecosystem/selection-store.js +11 -10
  577. package/dist/plugins/ecosystem/selection-store.js.map +1 -1
  578. package/dist/plugins/ecosystem/selection.d.ts.map +1 -1
  579. package/dist/plugins/ecosystem/selection.js +8 -7
  580. package/dist/plugins/ecosystem/selection.js.map +1 -1
  581. package/dist/plugins/ecosystem/state.d.ts.map +1 -1
  582. package/dist/plugins/ecosystem/state.js +24 -23
  583. package/dist/plugins/ecosystem/state.js.map +1 -1
  584. package/dist/plugins/ecosystem/updates.d.ts.map +1 -1
  585. package/dist/plugins/ecosystem/updates.js +5 -4
  586. package/dist/plugins/ecosystem/updates.js.map +1 -1
  587. package/dist/plugins/mcp-http.d.ts +0 -17
  588. package/dist/plugins/mcp-http.d.ts.map +1 -1
  589. package/dist/plugins/mcp-http.js +30 -7
  590. package/dist/plugins/mcp-http.js.map +1 -1
  591. package/dist/plugins/plugin-supervisor.d.ts.map +1 -1
  592. package/dist/plugins/plugin-supervisor.js +19 -1
  593. package/dist/plugins/plugin-supervisor.js.map +1 -1
  594. package/dist/profile/first-roles.d.ts.map +1 -1
  595. package/dist/profile/first-roles.js +10 -1
  596. package/dist/profile/first-roles.js.map +1 -1
  597. package/dist/profile/goal-plugin.d.ts.map +1 -1
  598. package/dist/profile/goal-plugin.js +24 -5
  599. package/dist/profile/goal-plugin.js.map +1 -1
  600. package/dist/profile/identity.d.ts.map +1 -1
  601. package/dist/profile/identity.js +7 -6
  602. package/dist/profile/identity.js.map +1 -1
  603. package/dist/profile/lock.d.ts.map +1 -1
  604. package/dist/profile/lock.js +15 -1
  605. package/dist/profile/lock.js.map +1 -1
  606. package/dist/profile/plan-plugin.d.ts.map +1 -1
  607. package/dist/profile/plan-plugin.js +26 -13
  608. package/dist/profile/plan-plugin.js.map +1 -1
  609. package/dist/profile/plugin-profiles.d.ts.map +1 -1
  610. package/dist/profile/plugin-profiles.js +2 -1
  611. package/dist/profile/plugin-profiles.js.map +1 -1
  612. package/dist/profile/policy-manifest.d.ts.map +1 -1
  613. package/dist/profile/policy-manifest.js +5 -4
  614. package/dist/profile/policy-manifest.js.map +1 -1
  615. package/dist/profile/profile-registry.d.ts +0 -12
  616. package/dist/profile/profile-registry.d.ts.map +1 -1
  617. package/dist/profile/profile-registry.js +14 -1
  618. package/dist/profile/profile-registry.js.map +1 -1
  619. package/dist/profile/role-catalog.d.ts +0 -1
  620. package/dist/profile/role-catalog.d.ts.map +1 -1
  621. package/dist/profile/role-catalog.js +17 -15
  622. package/dist/profile/role-catalog.js.map +1 -1
  623. package/dist/profile/role-orchestrator.d.ts.map +1 -1
  624. package/dist/profile/role-orchestrator.js +8 -7
  625. package/dist/profile/role-orchestrator.js.map +1 -1
  626. package/dist/profile/role-runner.d.ts.map +1 -1
  627. package/dist/profile/role-runner.js +3 -2
  628. package/dist/profile/role-runner.js.map +1 -1
  629. package/dist/profile/root-facade.d.ts.map +1 -1
  630. package/dist/profile/root-facade.js +2 -1
  631. package/dist/profile/root-facade.js.map +1 -1
  632. package/dist/profile/skill-discovery-wiring.d.ts.map +1 -1
  633. package/dist/profile/skill-discovery-wiring.js +7 -2
  634. package/dist/profile/skill-discovery-wiring.js.map +1 -1
  635. package/dist/profile/state-store.d.ts.map +1 -1
  636. package/dist/profile/state-store.js +13 -9
  637. package/dist/profile/state-store.js.map +1 -1
  638. package/dist/profile/todo-plugin.d.ts.map +1 -1
  639. package/dist/profile/todo-plugin.js +9 -4
  640. package/dist/profile/todo-plugin.js.map +1 -1
  641. package/dist/profiles/builtin-suites.d.ts +13 -6
  642. package/dist/profiles/builtin-suites.d.ts.map +1 -1
  643. package/dist/profiles/builtin-suites.js +15 -6
  644. package/dist/profiles/builtin-suites.js.map +1 -1
  645. package/dist/profiles/suite-loader.d.ts +25 -1
  646. package/dist/profiles/suite-loader.d.ts.map +1 -1
  647. package/dist/profiles/suite-loader.js +34 -9
  648. package/dist/profiles/suite-loader.js.map +1 -1
  649. package/dist/remote/server-entry.d.ts.map +1 -1
  650. package/dist/remote/server-entry.js +3 -2
  651. package/dist/remote/server-entry.js.map +1 -1
  652. package/dist/remote/session-source.d.ts.map +1 -1
  653. package/dist/remote/session-source.js +8 -4
  654. package/dist/remote/session-source.js.map +1 -1
  655. package/dist/share/session-share.d.ts.map +1 -1
  656. package/dist/share/session-share.js +14 -2
  657. package/dist/share/session-share.js.map +1 -1
  658. package/dist/testing/plugin-testkit.d.ts.map +1 -1
  659. package/dist/testing/plugin-testkit.js +4 -3
  660. package/dist/testing/plugin-testkit.js.map +1 -1
  661. package/dist/testing/runtime-delivery-queue.d.ts.map +1 -1
  662. package/dist/testing/runtime-delivery-queue.js +2 -1
  663. package/dist/testing/runtime-delivery-queue.js.map +1 -1
  664. package/dist/testing/session-plugin-testkit.d.ts.map +1 -1
  665. package/dist/testing/session-plugin-testkit.js +10 -7
  666. package/dist/testing/session-plugin-testkit.js.map +1 -1
  667. package/dist/utils/ansi.d.ts.map +1 -1
  668. package/dist/utils/ansi.js +2 -1
  669. package/dist/utils/ansi.js.map +1 -1
  670. package/dist/utils/clipboard.d.ts.map +1 -1
  671. package/dist/utils/clipboard.js +7 -6
  672. package/dist/utils/clipboard.js.map +1 -1
  673. package/dist/utils/image-resize-worker.d.ts.map +1 -1
  674. package/dist/utils/image-resize-worker.js +3 -2
  675. package/dist/utils/image-resize-worker.js.map +1 -1
  676. package/dist/utils/photon.d.ts +2 -2
  677. package/dist/utils/photon.d.ts.map +1 -1
  678. package/dist/utils/photon.js +2 -2
  679. package/dist/utils/photon.js.map +1 -1
  680. package/dist/utils/shell.d.ts.map +1 -1
  681. package/dist/utils/shell.js +9 -8
  682. package/dist/utils/shell.js.map +1 -1
  683. package/dist/utils/tools-manager.d.ts.map +1 -1
  684. package/dist/utils/tools-manager.js +23 -13
  685. package/dist/utils/tools-manager.js.map +1 -1
  686. package/dist/utils/version-check.d.ts.map +1 -1
  687. package/dist/utils/version-check.js +5 -1
  688. package/dist/utils/version-check.js.map +1 -1
  689. package/docs/compaction.md +1 -3
  690. package/docs/docs.json +4 -0
  691. package/docs/index.md +1 -0
  692. package/docs/keybindings.md +3 -0
  693. package/docs/mcp.md +103 -0
  694. package/docs/models.md +14 -22
  695. package/docs/providers.md +0 -1
  696. package/docs/quickstart.md +1 -1
  697. package/docs/rpc.md +1 -26
  698. package/docs/sdk.md +4 -6
  699. package/docs/settings.md +10 -12
  700. package/docs/skills.md +1 -9
  701. package/docs/terminal-setup.md +2 -3
  702. package/docs/usage.md +7 -6
  703. package/examples/extensions/with-deps/package-lock.json +2 -2
  704. package/examples/extensions/with-deps/package.json +1 -1
  705. package/examples/extensions/with-deps/plugin.json +1 -1
  706. package/examples/sdk/10-settings.ts +2 -4
  707. package/examples/sdk/12-full-control.ts +1 -2
  708. package/package.json +1 -3
  709. package/dist/bundle/chunks/chunk-EALJ5DDX.js +0 -1452
  710. package/dist/core/extensions/microcompact.d.ts +0 -80
  711. package/dist/core/extensions/microcompact.d.ts.map +0 -1
  712. package/dist/core/extensions/microcompact.js +0 -134
  713. package/dist/core/extensions/microcompact.js.map +0 -1
  714. package/dist/server/create-harness.d.ts +0 -26
  715. package/dist/server/create-harness.d.ts.map +0 -1
  716. package/dist/server/create-harness.js +0 -106
  717. package/dist/server/create-harness.js.map +0 -1
@@ -7,28 +7,30 @@
7
7
  * catalog. Registered roles are validated and served as detached, frozen
8
8
  * snapshots.
9
9
  */
10
+ /** Memory scopes a role may write to (aligned with the 1C.1b store scopes). */
11
+ import { t } from "../core/i18n/index.js";
10
12
  const WRITABLE_SCOPES = ["session", "cycle", "long-term"];
11
13
  function assertNonEmptyString(value, label) {
12
14
  if (typeof value !== "string" || value.trim().length === 0)
13
- throw new Error(`${label} must be a non-empty string`);
15
+ throw new Error(t("{label} must be a non-empty string", { label }));
14
16
  }
15
17
  function assertIOSchemaRef(value, label) {
16
18
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
17
- throw new Error(`${label} must be a plain object`);
19
+ throw new Error(t("{label} must be a plain object", { label }));
18
20
  }
19
21
  const record = value;
20
22
  assertNonEmptyString(record.schemaId, `${label}.schemaId`);
21
23
  if (typeof record.schemaVersion !== "number" ||
22
24
  !Number.isSafeInteger(record.schemaVersion) ||
23
25
  record.schemaVersion < 1) {
24
- throw new Error(`${label}.schemaVersion must be a positive safe integer`);
26
+ throw new Error(t("{label}.schemaVersion must be a positive safe integer", { label }));
25
27
  }
26
28
  return Object.freeze({ schemaId: record.schemaId, schemaVersion: record.schemaVersion });
27
29
  }
28
30
  /** Validates role metadata and returns a detached, frozen snapshot. */
29
31
  export function validateRoleMetadataV1(value) {
30
32
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
31
- throw new Error("Role metadata must be a plain object");
33
+ throw new Error(t("Role metadata must be a plain object"));
32
34
  }
33
35
  const record = value;
34
36
  const required = [
@@ -43,34 +45,34 @@ export function validateRoleMetadataV1(value) {
43
45
  ];
44
46
  for (const key of required) {
45
47
  if (!(key in record))
46
- throw new Error(`Role metadata is missing required field: ${key}`);
48
+ throw new Error(t("Role metadata is missing required field: {key}", { key }));
47
49
  }
48
50
  const unsupported = Object.keys(record)
49
51
  .filter((key) => !required.includes(key))
50
52
  .sort();
51
53
  if (unsupported.length > 0)
52
- throw new Error(`Role metadata has unsupported fields: ${unsupported.join(", ")}`);
54
+ throw new Error(t("Role metadata has unsupported fields: {fields}", { fields: unsupported.join(", ") }));
53
55
  assertNonEmptyString(record.roleId, "Role metadata.roleId");
54
56
  assertNonEmptyString(record.title, "Role metadata.title");
55
57
  const input = assertIOSchemaRef(record.input, "Role metadata.input");
56
58
  const output = assertIOSchemaRef(record.output, "Role metadata.output");
57
59
  if (!Array.isArray(record.capabilityDependencies)) {
58
- throw new Error("Role metadata.capabilityDependencies must be an array");
60
+ throw new Error(t("Role metadata.capabilityDependencies must be an array"));
59
61
  }
60
62
  const capabilityDependencies = record.capabilityDependencies.map((item, index) => {
61
63
  const depLabel = `Role metadata.capabilityDependencies[${index}]`;
62
64
  if (item === null || typeof item !== "object" || Array.isArray(item)) {
63
- throw new Error(`${depLabel} must be a plain object`);
65
+ throw new Error(t("{label} must be a plain object", { label: depLabel }));
64
66
  }
65
67
  const dep = item;
66
68
  assertNonEmptyString(dep.capabilityId, `${depLabel}.capabilityId`);
67
69
  if (typeof dep.capabilityVersion !== "number" ||
68
70
  !Number.isSafeInteger(dep.capabilityVersion) ||
69
71
  dep.capabilityVersion < 1) {
70
- throw new Error(`${depLabel}.capabilityVersion must be a positive safe integer`);
72
+ throw new Error(t("{label}.capabilityVersion must be a positive safe integer", { label: depLabel }));
71
73
  }
72
74
  if (typeof dep.required !== "boolean")
73
- throw new Error(`${depLabel}.required must be boolean`);
75
+ throw new Error(t("{label}.required must be boolean", { label: depLabel }));
74
76
  return Object.freeze({
75
77
  capabilityId: dep.capabilityId,
76
78
  capabilityVersion: dep.capabilityVersion,
@@ -78,15 +80,15 @@ export function validateRoleMetadataV1(value) {
78
80
  });
79
81
  });
80
82
  if (!Array.isArray(record.writableScopes))
81
- throw new Error("Role metadata.writableScopes must be an array");
83
+ throw new Error(t("Role metadata.writableScopes must be an array"));
82
84
  for (const [index, scope] of record.writableScopes.entries()) {
83
85
  if (!WRITABLE_SCOPES.includes(scope)) {
84
- throw new Error(`Role metadata.writableScopes[${index}] is invalid`);
86
+ throw new Error(t("Role metadata.writableScopes[{index}] is invalid", { index }));
85
87
  }
86
88
  }
87
89
  assertNonEmptyString(record.completionCriteria, "Role metadata.completionCriteria");
88
90
  if (record.concurrency !== "single" && record.concurrency !== "parallel") {
89
- throw new Error("Role metadata.concurrency is invalid");
91
+ throw new Error(t("Role metadata.concurrency is invalid"));
90
92
  }
91
93
  return Object.freeze({
92
94
  roleId: record.roleId,
@@ -105,14 +107,14 @@ export function createRoleCatalog(initial = []) {
105
107
  for (const metadata of initial) {
106
108
  const validated = validateRoleMetadataV1(metadata);
107
109
  if (roles.has(validated.roleId))
108
- throw new Error(`Role already registered: ${validated.roleId}`);
110
+ throw new Error(t("Role already registered: {roleId}", { roleId: validated.roleId }));
109
111
  roles.set(validated.roleId, validated);
110
112
  }
111
113
  return {
112
114
  register(metadata) {
113
115
  const validated = validateRoleMetadataV1(metadata);
114
116
  if (roles.has(validated.roleId))
115
- throw new Error(`Role already registered: ${validated.roleId}`);
117
+ throw new Error(t("Role already registered: {roleId}", { roleId: validated.roleId }));
116
118
  roles.set(validated.roleId, validated);
117
119
  return validated;
118
120
  },
@@ -1 +1 @@
1
- {"version":3,"file":"role-catalog.js","sourceRoot":"","sources":["../../src/profile/role-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAqCH,MAAM,eAAe,GAAmC,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;AAE1F,SAAS,oBAAoB,CAAC,KAAc,EAAE,KAAa,EAA2B;IACrF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KA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,CACjB;QACD,GAAG,CAAC,MAAM,EAAE;YACX,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAAA,CACzB;QACD,IAAI,GAAG;YACN,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAAA,CACzG;QACD,gBAAgB,CAAC,YAAY,EAAE;YAC9B,OAAO,MAAM,CAAC,MAAM,CACnB,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CACnC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,YAAY,KAAK,YAAY,CAAC,CAC1F,CACD,CAAC;QAAA,CACF;KACD,CAAC;AAAA,CACF","sourcesContent":["/**\n * Role metadata catalog (2.2a).\n *\n * Role metadata is DISCOVERY data, not a security policy: roleId, input/output\n * schema references, capability dependencies, writable memory scopes,\n * concurrency, and completion criteria are all discoverable through the\n * catalog. Registered roles are validated and served as detached, frozen\n * snapshots.\n */\n\n/** Memory scopes a role may write to (aligned with the 1C.1b store scopes). */\nexport type RoleWritableScopeV1 = \"session\" | \"cycle\" | \"long-term\";\n\nexport interface RoleCapabilityDependencyV1 {\n\treadonly capabilityId: string;\n\treadonly capabilityVersion: number;\n\t/** Required dependencies fail role activation when missing. */\n\treadonly required: boolean;\n}\n\n/** Versioned input/output schema reference (schema bodies live with the domain plugin). */\nexport interface RoleIOSchemaRefV1 {\n\treadonly schemaId: string;\n\treadonly schemaVersion: number;\n}\n\nexport interface RoleMetadataV1 {\n\treadonly roleId: string;\n\treadonly title: string;\n\treadonly input: RoleIOSchemaRefV1;\n\treadonly output: RoleIOSchemaRefV1;\n\treadonly capabilityDependencies: readonly RoleCapabilityDependencyV1[];\n\treadonly writableScopes: readonly RoleWritableScopeV1[];\n\treadonly concurrency: \"single\" | \"parallel\";\n\treadonly completionCriteria: string;\n}\n\nexport interface RoleCatalogV1 {\n\tregister(metadata: RoleMetadataV1): RoleMetadataV1;\n\tget(roleId: string): RoleMetadataV1 | undefined;\n\tlist(): readonly RoleMetadataV1[];\n\t/** Roles declaring the given capability as a dependency (required or optional). */\n\tfindByCapability(capabilityId: string): readonly RoleMetadataV1[];\n}\n\nconst WRITABLE_SCOPES: readonly RoleWritableScopeV1[] = [\"session\", \"cycle\", \"long-term\"];\n\nfunction assertNonEmptyString(value: unknown, label: string): asserts value is string {\n\tif (typeof value !== \"string\" || value.trim().length === 0) throw new Error(`${label} must be a non-empty string`);\n}\n\nfunction assertIOSchemaRef(value: unknown, label: string): RoleIOSchemaRefV1 {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new Error(`${label} must be a plain object`);\n\t}\n\tconst record = value as Record<string, unknown>;\n\tassertNonEmptyString(record.schemaId, `${label}.schemaId`);\n\tif (\n\t\ttypeof record.schemaVersion !== \"number\" ||\n\t\t!Number.isSafeInteger(record.schemaVersion) ||\n\t\trecord.schemaVersion < 1\n\t) {\n\t\tthrow new Error(`${label}.schemaVersion must be a positive safe integer`);\n\t}\n\treturn Object.freeze({ schemaId: record.schemaId, schemaVersion: record.schemaVersion });\n}\n\n/** Validates role metadata and returns a detached, frozen snapshot. */\nexport function validateRoleMetadataV1(value: unknown): RoleMetadataV1 {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new Error(\"Role metadata must be a plain object\");\n\t}\n\tconst record = value as Record<string, unknown>;\n\tconst required = [\n\t\t\"roleId\",\n\t\t\"title\",\n\t\t\"input\",\n\t\t\"output\",\n\t\t\"capabilityDependencies\",\n\t\t\"writableScopes\",\n\t\t\"concurrency\",\n\t\t\"completionCriteria\",\n\t];\n\tfor (const key of required) {\n\t\tif (!(key in record)) throw new Error(`Role metadata is missing required field: ${key}`);\n\t}\n\tconst unsupported = Object.keys(record)\n\t\t.filter((key) => !required.includes(key))\n\t\t.sort();\n\tif (unsupported.length > 0) throw new Error(`Role metadata has unsupported fields: ${unsupported.join(\", \")}`);\n\n\tassertNonEmptyString(record.roleId, \"Role metadata.roleId\");\n\tassertNonEmptyString(record.title, \"Role metadata.title\");\n\tconst input = assertIOSchemaRef(record.input, \"Role metadata.input\");\n\tconst output = assertIOSchemaRef(record.output, \"Role metadata.output\");\n\n\tif (!Array.isArray(record.capabilityDependencies)) {\n\t\tthrow new Error(\"Role metadata.capabilityDependencies must be an array\");\n\t}\n\tconst capabilityDependencies = record.capabilityDependencies.map((item, index) => {\n\t\tconst depLabel = `Role metadata.capabilityDependencies[${index}]`;\n\t\tif (item === null || typeof item !== \"object\" || Array.isArray(item)) {\n\t\t\tthrow new Error(`${depLabel} must be a plain object`);\n\t\t}\n\t\tconst dep = item as Record<string, unknown>;\n\t\tassertNonEmptyString(dep.capabilityId, `${depLabel}.capabilityId`);\n\t\tif (\n\t\t\ttypeof dep.capabilityVersion !== \"number\" ||\n\t\t\t!Number.isSafeInteger(dep.capabilityVersion) ||\n\t\t\tdep.capabilityVersion < 1\n\t\t) {\n\t\t\tthrow new Error(`${depLabel}.capabilityVersion must be a positive safe integer`);\n\t\t}\n\t\tif (typeof dep.required !== \"boolean\") throw new Error(`${depLabel}.required must be boolean`);\n\t\treturn Object.freeze({\n\t\t\tcapabilityId: dep.capabilityId,\n\t\t\tcapabilityVersion: dep.capabilityVersion,\n\t\t\trequired: dep.required,\n\t\t});\n\t});\n\n\tif (!Array.isArray(record.writableScopes)) throw new Error(\"Role metadata.writableScopes must be an array\");\n\tfor (const [index, scope] of record.writableScopes.entries()) {\n\t\tif (!WRITABLE_SCOPES.includes(scope as RoleWritableScopeV1)) {\n\t\t\tthrow new Error(`Role metadata.writableScopes[${index}] is invalid`);\n\t\t}\n\t}\n\tassertNonEmptyString(record.completionCriteria, \"Role metadata.completionCriteria\");\n\tif (record.concurrency !== \"single\" && record.concurrency !== \"parallel\") {\n\t\tthrow new Error(\"Role metadata.concurrency is invalid\");\n\t}\n\n\treturn Object.freeze({\n\t\troleId: record.roleId,\n\t\ttitle: record.title,\n\t\tinput,\n\t\toutput,\n\t\tcapabilityDependencies: Object.freeze(capabilityDependencies),\n\t\twritableScopes: Object.freeze([...(record.writableScopes as readonly RoleWritableScopeV1[])]),\n\t\tconcurrency: record.concurrency as RoleMetadataV1[\"concurrency\"],\n\t\tcompletionCriteria: record.completionCriteria,\n\t});\n}\n\n/** Discoverable role catalog: register, get, list (sorted), find by capability. */\nexport function createRoleCatalog(initial: readonly RoleMetadataV1[] = []): RoleCatalogV1 {\n\tconst roles = new Map<string, RoleMetadataV1>();\n\tfor (const metadata of initial) {\n\t\tconst validated = validateRoleMetadataV1(metadata);\n\t\tif (roles.has(validated.roleId)) throw new Error(`Role already registered: ${validated.roleId}`);\n\t\troles.set(validated.roleId, validated);\n\t}\n\treturn {\n\t\tregister(metadata) {\n\t\t\tconst validated = validateRoleMetadataV1(metadata);\n\t\t\tif (roles.has(validated.roleId)) throw new Error(`Role already registered: ${validated.roleId}`);\n\t\t\troles.set(validated.roleId, validated);\n\t\t\treturn validated;\n\t\t},\n\t\tget(roleId) {\n\t\t\treturn roles.get(roleId);\n\t\t},\n\t\tlist() {\n\t\t\treturn Object.freeze([...roles.values()].sort((left, right) => left.roleId.localeCompare(right.roleId)));\n\t\t},\n\t\tfindByCapability(capabilityId) {\n\t\t\treturn Object.freeze(\n\t\t\t\t[...roles.values()].filter((role) =>\n\t\t\t\t\trole.capabilityDependencies.some((dependency) => dependency.capabilityId === capabilityId),\n\t\t\t\t),\n\t\t\t);\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"role-catalog.js","sourceRoot":"","sources":["../../src/profile/role-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,+EAA+E;A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EAAE,CACnC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,YAAY,KAAK,YAAY,CAAC,CAC1F,CACD,CAAC;QAAA,CACF;KACD,CAAC;AAAA,CACF","sourcesContent":["/**\n * Role metadata catalog (2.2a).\n *\n * Role metadata is DISCOVERY data, not a security policy: roleId, input/output\n * schema references, capability dependencies, writable memory scopes,\n * concurrency, and completion criteria are all discoverable through the\n * catalog. Registered roles are validated and served as detached, frozen\n * snapshots.\n */\n\n/** Memory scopes a role may write to (aligned with the 1C.1b store scopes). */\nimport { t } from \"../core/i18n/index.ts\";\n\nexport type RoleWritableScopeV1 = \"session\" | \"cycle\" | \"long-term\";\n\nexport interface RoleCapabilityDependencyV1 {\n\treadonly capabilityId: string;\n\treadonly capabilityVersion: number;\n\t/** Required dependencies fail role activation when missing. */\n\treadonly required: boolean;\n}\n\n/** Versioned input/output schema reference (schema bodies live with the domain plugin). */\nexport interface RoleIOSchemaRefV1 {\n\treadonly schemaId: string;\n\treadonly schemaVersion: number;\n}\n\nexport interface RoleMetadataV1 {\n\treadonly roleId: string;\n\treadonly title: string;\n\treadonly input: RoleIOSchemaRefV1;\n\treadonly output: RoleIOSchemaRefV1;\n\treadonly capabilityDependencies: readonly RoleCapabilityDependencyV1[];\n\treadonly writableScopes: readonly RoleWritableScopeV1[];\n\treadonly concurrency: \"single\" | \"parallel\";\n\treadonly completionCriteria: string;\n}\n\nexport interface RoleCatalogV1 {\n\tregister(metadata: RoleMetadataV1): RoleMetadataV1;\n\tget(roleId: string): RoleMetadataV1 | undefined;\n\tlist(): readonly RoleMetadataV1[];\n\t/** Roles declaring the given capability as a dependency (required or optional). */\n\tfindByCapability(capabilityId: string): readonly RoleMetadataV1[];\n}\n\nconst WRITABLE_SCOPES: readonly RoleWritableScopeV1[] = [\"session\", \"cycle\", \"long-term\"];\n\nfunction assertNonEmptyString(value: unknown, label: string): asserts value is string {\n\tif (typeof value !== \"string\" || value.trim().length === 0)\n\t\tthrow new Error(t(\"{label} must be a non-empty string\", { label }));\n}\n\nfunction assertIOSchemaRef(value: unknown, label: string): RoleIOSchemaRefV1 {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new Error(t(\"{label} must be a plain object\", { label }));\n\t}\n\tconst record = value as Record<string, unknown>;\n\tassertNonEmptyString(record.schemaId, `${label}.schemaId`);\n\tif (\n\t\ttypeof record.schemaVersion !== \"number\" ||\n\t\t!Number.isSafeInteger(record.schemaVersion) ||\n\t\trecord.schemaVersion < 1\n\t) {\n\t\tthrow new Error(t(\"{label}.schemaVersion must be a positive safe integer\", { label }));\n\t}\n\treturn Object.freeze({ schemaId: record.schemaId, schemaVersion: record.schemaVersion });\n}\n\n/** Validates role metadata and returns a detached, frozen snapshot. */\nexport function validateRoleMetadataV1(value: unknown): RoleMetadataV1 {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new Error(t(\"Role metadata must be a plain object\"));\n\t}\n\tconst record = value as Record<string, unknown>;\n\tconst required = [\n\t\t\"roleId\",\n\t\t\"title\",\n\t\t\"input\",\n\t\t\"output\",\n\t\t\"capabilityDependencies\",\n\t\t\"writableScopes\",\n\t\t\"concurrency\",\n\t\t\"completionCriteria\",\n\t];\n\tfor (const key of required) {\n\t\tif (!(key in record)) throw new Error(t(\"Role metadata is missing required field: {key}\", { key }));\n\t}\n\tconst unsupported = Object.keys(record)\n\t\t.filter((key) => !required.includes(key))\n\t\t.sort();\n\tif (unsupported.length > 0)\n\t\tthrow new Error(t(\"Role metadata has unsupported fields: {fields}\", { fields: unsupported.join(\", \") }));\n\n\tassertNonEmptyString(record.roleId, \"Role metadata.roleId\");\n\tassertNonEmptyString(record.title, \"Role metadata.title\");\n\tconst input = assertIOSchemaRef(record.input, \"Role metadata.input\");\n\tconst output = assertIOSchemaRef(record.output, \"Role metadata.output\");\n\n\tif (!Array.isArray(record.capabilityDependencies)) {\n\t\tthrow new Error(t(\"Role metadata.capabilityDependencies must be an array\"));\n\t}\n\tconst capabilityDependencies = record.capabilityDependencies.map((item, index) => {\n\t\tconst depLabel = `Role metadata.capabilityDependencies[${index}]`;\n\t\tif (item === null || typeof item !== \"object\" || Array.isArray(item)) {\n\t\t\tthrow new Error(t(\"{label} must be a plain object\", { label: depLabel }));\n\t\t}\n\t\tconst dep = item as Record<string, unknown>;\n\t\tassertNonEmptyString(dep.capabilityId, `${depLabel}.capabilityId`);\n\t\tif (\n\t\t\ttypeof dep.capabilityVersion !== \"number\" ||\n\t\t\t!Number.isSafeInteger(dep.capabilityVersion) ||\n\t\t\tdep.capabilityVersion < 1\n\t\t) {\n\t\t\tthrow new Error(t(\"{label}.capabilityVersion must be a positive safe integer\", { label: depLabel }));\n\t\t}\n\t\tif (typeof dep.required !== \"boolean\")\n\t\t\tthrow new Error(t(\"{label}.required must be boolean\", { label: depLabel }));\n\t\treturn Object.freeze({\n\t\t\tcapabilityId: dep.capabilityId,\n\t\t\tcapabilityVersion: dep.capabilityVersion,\n\t\t\trequired: dep.required,\n\t\t});\n\t});\n\n\tif (!Array.isArray(record.writableScopes)) throw new Error(t(\"Role metadata.writableScopes must be an array\"));\n\tfor (const [index, scope] of record.writableScopes.entries()) {\n\t\tif (!WRITABLE_SCOPES.includes(scope as RoleWritableScopeV1)) {\n\t\t\tthrow new Error(t(\"Role metadata.writableScopes[{index}] is invalid\", { index }));\n\t\t}\n\t}\n\tassertNonEmptyString(record.completionCriteria, \"Role metadata.completionCriteria\");\n\tif (record.concurrency !== \"single\" && record.concurrency !== \"parallel\") {\n\t\tthrow new Error(t(\"Role metadata.concurrency is invalid\"));\n\t}\n\n\treturn Object.freeze({\n\t\troleId: record.roleId,\n\t\ttitle: record.title,\n\t\tinput,\n\t\toutput,\n\t\tcapabilityDependencies: Object.freeze(capabilityDependencies),\n\t\twritableScopes: Object.freeze([...(record.writableScopes as readonly RoleWritableScopeV1[])]),\n\t\tconcurrency: record.concurrency as RoleMetadataV1[\"concurrency\"],\n\t\tcompletionCriteria: record.completionCriteria,\n\t});\n}\n\n/** Discoverable role catalog: register, get, list (sorted), find by capability. */\nexport function createRoleCatalog(initial: readonly RoleMetadataV1[] = []): RoleCatalogV1 {\n\tconst roles = new Map<string, RoleMetadataV1>();\n\tfor (const metadata of initial) {\n\t\tconst validated = validateRoleMetadataV1(metadata);\n\t\tif (roles.has(validated.roleId))\n\t\t\tthrow new Error(t(\"Role already registered: {roleId}\", { roleId: validated.roleId }));\n\t\troles.set(validated.roleId, validated);\n\t}\n\treturn {\n\t\tregister(metadata) {\n\t\t\tconst validated = validateRoleMetadataV1(metadata);\n\t\t\tif (roles.has(validated.roleId))\n\t\t\t\tthrow new Error(t(\"Role already registered: {roleId}\", { roleId: validated.roleId }));\n\t\t\troles.set(validated.roleId, validated);\n\t\t\treturn validated;\n\t\t},\n\t\tget(roleId) {\n\t\t\treturn roles.get(roleId);\n\t\t},\n\t\tlist() {\n\t\t\treturn Object.freeze([...roles.values()].sort((left, right) => left.roleId.localeCompare(right.roleId)));\n\t\t},\n\t\tfindByCapability(capabilityId) {\n\t\t\treturn Object.freeze(\n\t\t\t\t[...roles.values()].filter((role) =>\n\t\t\t\t\trole.capabilityDependencies.some((dependency) => dependency.capabilityId === capabilityId),\n\t\t\t\t),\n\t\t\t);\n\t\t},\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"role-orchestrator.d.ts","sourceRoot":"","sources":["../../src/profile/role-orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAmB,MAAM,kCAAkC,CAAC;AAE7F,OAAO,KAAK,EAAE,iBAAiB,EAAqB,kBAAkB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE/G;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,QAAY,CAAC;AAE9D,sEAAsE;AACtE,MAAM,MAAM,yBAAyB,GAAG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/**\n * Role orchestrator (2.2e) — root-side concurrent orchestration of registered\n * roles with bounded aggregation.\n *\n * Spawns one child per requested roleId through the public\n * `AgentCompositionAPI` (create/lease/run/wait bound to the root via\n * `parentInstanceId`), honoring the role's `RoleMetadataV1.concurrency`\n * metadata: `parallel` roles run concurrently, `single` roles execute one at\n * a time in stable roleId order. Aggregation reuses the multi-agent-tasks 6.3\n * semantics — entries sorted by roleId (never completion order), a per-entry\n * byte budget over the JSON-serialized output (`limitBytes`; over-budget\n * entries are dropped whole with an explicit `truncated` flag, outputs that\n * are absent carry `missing`), and `completionCriteria` metadata checked per\n * role into a structured satisfied/unmet/unchecked list (never thrown).\n * Child failures are collected, never swallowed: a failed child lands in its\n * structured entry while the orchestration still resolves (fail-collect at\n * the orchestration level, not fail-fast).\n *\n * Limit constants: multi-agent-tasks itself has no built-in numeric caps —\n * its `limitBytes`/`maxResultBytes` are caller-injected and default to\n * unbounded. This contract therefore defaults `limitBytes` to 16 KiB, the\n * magnitude of the repo's existing `DEFAULT_MAX_RESULT_BYTES_V1` (office\n * writer). No separate entry cap is added: the multi-agent-tasks aggregate\n * has none either, and the entry count here is already bounded by the\n * explicit `roleIds` list.\n *\n * Honest state-namespace boundary: state namespaces are partitioned per\n * plugin owner, not per child instance. Concurrent children therefore do NOT\n * get per-instance state isolation under this contract. The deterministic\n * injected run callbacks of this milestone never write state, so the boundary\n * is not exercised here; concurrent child state writes remain outside this\n * contract.\n */\nimport type { AgentCompositionAPI, AgentDefinition } from \"../core/extensions/public-api.ts\";\nimport type { RoleMetadataV1 } from \"./role-catalog.ts\";\nimport type { RoleRunCallbackV1, RoleRunnerInputV1, RoleRunnerResultV1, RoleRunnerV1 } from \"./role-runner.ts\";\n\n/**\n * Default aggregation byte budget. The multi-agent-tasks aggregate defaults\n * to unbounded (caller-injected limits); this default anchors the contract to\n * the repo's existing 16 KiB result-cap magnitude.\n */\nexport const DEFAULT_ROLE_AGGREGATION_LIMIT_BYTES = 16 * 1024;\n\n/** Terminal instance states an orchestrated child can settle into. */\nexport type RoleOrchestrationStatusV1 = \"succeeded\" | \"failed\" | \"cancelled\" | \"disposed\";\n\n/** One orchestrated child's aggregation entry (sorted by roleId, never completion order). */\nexport interface RoleOrchestrationEntryV1 {\n\treadonly roleId: string;\n\treadonly definitionId: string;\n\treadonly childInstanceId: string;\n\t/** Terminal revision of the child instance (result reference half, see 2.2b). */\n\treadonly revision: number;\n\treadonly status: RoleOrchestrationStatusV1;\n\t/** The entry's output exceeded the remaining byte budget and was dropped whole. */\n\treadonly truncated: boolean;\n\t/** No output was available (failure, cancellation, disposal, or truncation). */\n\treadonly missing: boolean;\n\t/** Present only for succeeded entries that fit the byte budget. */\n\treadonly result?: RoleRunnerResultV1;\n\t/** Structured failure text; present when the instance settled with an error. */\n\treadonly error?: string;\n}\n\n/** Per-role completion-criteria verdict produced at aggregation time (never thrown). */\nexport interface RoleCompletionCheckV1 {\n\treadonly roleId: string;\n\treadonly criteria: string;\n\t/**\n\t * `satisfied`/`unmet` come from an injected evaluator; `unchecked` means no\n\t * evaluator was available or the entry had no in-budget output to judge.\n\t */\n\treadonly status: \"satisfied\" | \"unmet\" | \"unchecked\";\n}\n\n/**\n * Deterministic completion evaluator. Returns `true`/`false` for a verdict or\n * `undefined` when the criteria cannot be judged from the result.\n */\nexport type RoleCompletionEvaluatorV1 = (input: {\n\treadonly roleId: string;\n\treadonly criteria: string;\n\treadonly result: RoleRunnerResultV1;\n}) => boolean | undefined;\n\n/** One orchestration request: explicit roleIds plus one shared spec string. */\nexport interface RoleOrchestratorRunRequestV1 {\n\treadonly roleIds: readonly string[];\n\treadonly spec: string;\n\t/** Per-role run overrides taking precedence for this request only. */\n\treadonly runs?: readonly { readonly roleId: string; readonly run: RoleRunCallbackV1 }[];\n\t/** Aggregation byte budget for this request (defaults to the orchestrator option). */\n\treadonly limitBytes?: number;\n\t/** Completion evaluator for this request (defaults to the orchestrator option). */\n\treadonly evaluateCompletion?: RoleCompletionEvaluatorV1;\n}\n\nexport interface RoleOrchestratorOptionsV1 {\n\treadonly composition: AgentCompositionAPI;\n\treadonly runner: RoleRunnerV1;\n\t/** Root instance the children are parented to via `parentInstanceId`. */\n\treadonly parentInstanceId: string;\n\t/** Controller-lease owner for the orchestrated children. */\n\treadonly owner?: string;\n\t/** Default aggregation byte budget (see {@link DEFAULT_ROLE_AGGREGATION_LIMIT_BYTES}). */\n\treadonly limitBytes?: number;\n\t/** Default completion evaluator. Without one every check reports `unchecked`. */\n\treadonly evaluateCompletion?: RoleCompletionEvaluatorV1;\n}\n\n/** Orchestration result: bounded aggregation plus completion verdicts. */\nexport interface RoleOrchestrationResultV1 {\n\t/** One entry per requested role, sorted by roleId (stable, never completion order). */\n\treadonly entries: readonly RoleOrchestrationEntryV1[];\n\t/** True when at least one entry was dropped for exceeding the byte budget. */\n\treadonly truncated: boolean;\n\t/** Completion verdicts per requested role, sorted by roleId. */\n\treadonly completionChecks: readonly RoleCompletionCheckV1[];\n}\n\nexport interface RoleOrchestratorV1 {\n\treadonly composition: AgentCompositionAPI;\n\treadonly runner: RoleRunnerV1;\n\treadonly parentInstanceId: string;\n\trunRoles(request: RoleOrchestratorRunRequestV1): Promise<RoleOrchestrationResultV1>;\n}\n\nconst DEFAULT_ORCHESTRATION_OWNER = \"role-orchestrator\";\n\ninterface SettledChildV1 {\n\treadonly roleId: string;\n\treadonly definitionId: string;\n\treadonly childInstanceId: string;\n\treadonly revision: number;\n\treadonly status: RoleOrchestrationStatusV1;\n\treadonly output?: RoleRunnerResultV1;\n\treadonly error?: string;\n}\n\n/** Creates the root-side concurrent role orchestrator (2.2e). */\nexport function createRoleOrchestrator(options: RoleOrchestratorOptionsV1): RoleOrchestratorV1 {\n\tconst owner = options.owner ?? DEFAULT_ORCHESTRATION_OWNER;\n\t// Definitions are registered once per roleId and reused across runs: a\n\t// composition instance is single-run, so every orchestration creates fresh\n\t// child instances from the same definitions.\n\tconst definitions = new Map<string, AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1>>();\n\tlet activeOverrides: ReadonlyMap<string, RoleRunCallbackV1> = new Map();\n\tlet runInFlight = false;\n\n\tfunction requireMetadata(roleId: string): RoleMetadataV1 {\n\t\tconst metadata = options.runner.catalog.get(roleId);\n\t\tif (!metadata) throw new Error(`Unknown role: ${roleId}`);\n\t\treturn metadata;\n\t}\n\n\tfunction definitionFor(roleId: string): AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1> {\n\t\tconst cached = definitions.get(roleId);\n\t\tif (cached) return cached;\n\t\tconst base = options.runner.createDefinition(roleId);\n\t\tconst definition: AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1> = {\n\t\t\t...base,\n\t\t\trun: (input, context) => {\n\t\t\t\tconst override = activeOverrides.get(roleId);\n\t\t\t\treturn override ? override(input, context) : options.runner.run(roleId, input, context);\n\t\t\t},\n\t\t};\n\t\tconst registered = options.composition.define(definition);\n\t\tdefinitions.set(roleId, registered);\n\t\treturn registered;\n\t}\n\n\tasync function runOne(roleId: string, spec: string, settled: Map<string, SettledChildV1>): Promise<void> {\n\t\tconst definition = definitionFor(roleId);\n\t\tconst instance = options.composition.create<RoleRunnerInputV1, RoleRunnerResultV1>(\n\t\t\t{ id: definition.id, version: definition.version },\n\t\t\t{ parentInstanceId: options.parentInstanceId },\n\t\t);\n\t\tconst childInstanceId = instance.id;\n\t\tconst lease = await instance.acquireControllerLease(owner);\n\t\ttry {\n\t\t\tconst operation = instance.run({ spec }, { lease });\n\t\t\ttry {\n\t\t\t\tawait operation.result;\n\t\t\t} catch {\n\t\t\t\t// run() rejects on failure/cancellation mid-flight; instance.wait()\n\t\t\t\t// below yields the terminal status and error.\n\t\t\t}\n\t\t\tconst terminal = await instance.wait();\n\t\t\tconst error =\n\t\t\t\tterminal.error === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: terminal.error instanceof Error\n\t\t\t\t\t\t? terminal.error.message\n\t\t\t\t\t\t: String(terminal.error);\n\t\t\tsettled.set(roleId, {\n\t\t\t\troleId,\n\t\t\t\tdefinitionId: definition.id,\n\t\t\t\tchildInstanceId,\n\t\t\t\trevision: terminal.revision,\n\t\t\t\tstatus: terminal.status,\n\t\t\t\t...(terminal.output !== undefined ? { output: terminal.output } : {}),\n\t\t\t\t...(error !== undefined ? { error } : {}),\n\t\t\t});\n\t\t} finally {\n\t\t\tif (lease.isActive()) await lease.release();\n\t\t}\n\t}\n\n\tasync function runRoles(request: RoleOrchestratorRunRequestV1): Promise<RoleOrchestrationResultV1> {\n\t\tif (runInFlight) throw new Error(\"Role orchestrator is already running an orchestration\");\n\t\t// Input validation fails explicitly before any child is spawned.\n\t\tconst seen = new Set<string>();\n\t\tfor (const roleId of request.roleIds) {\n\t\t\tif (typeof roleId !== \"string\" || roleId.trim().length === 0) {\n\t\t\t\tthrow new Error(\"Role id must be a non-empty string\");\n\t\t\t}\n\t\t\tif (seen.has(roleId)) throw new Error(`Duplicate roleId in orchestration request: ${roleId}`);\n\t\t\tseen.add(roleId);\n\t\t}\n\t\tconst overrides = new Map<string, RoleRunCallbackV1>();\n\t\tfor (const override of request.runs ?? []) {\n\t\t\tif (overrides.has(override.roleId)) throw new Error(`Duplicate run override for role: ${override.roleId}`);\n\t\t\toverrides.set(override.roleId, override.run);\n\t\t}\n\t\tfor (const roleId of overrides.keys()) {\n\t\t\tif (!seen.has(roleId)) throw new Error(`Run override for unrequested role: ${roleId}`);\n\t\t}\n\t\t// Stable execution order: roleId-sorted, `parallel` roles concurrent,\n\t\t// `single` roles strictly sequential. Aggregation order is independent\n\t\t// of this execution order.\n\t\tconst sorted = [...request.roleIds].sort((left, right) => left.localeCompare(right));\n\t\tfor (const roleId of sorted) {\n\t\t\trequireMetadata(roleId);\n\t\t\tdefinitionFor(roleId);\n\t\t}\n\n\t\trunInFlight = true;\n\t\ttry {\n\t\t\tactiveOverrides = overrides;\n\t\t\tconst settled = new Map<string, SettledChildV1>();\n\t\t\tif (sorted.length > 0) {\n\t\t\t\tconst parallelIds = sorted.filter((roleId) => requireMetadata(roleId).concurrency === \"parallel\");\n\t\t\t\tconst singleIds = sorted.filter((roleId) => requireMetadata(roleId).concurrency === \"single\");\n\t\t\t\tawait Promise.all(parallelIds.map((roleId) => runOne(roleId, request.spec, settled)));\n\t\t\t\tfor (const roleId of singleIds) await runOne(roleId, request.spec, settled);\n\t\t\t}\n\t\t\treturn aggregate(sorted, settled, request);\n\t\t} finally {\n\t\t\tactiveOverrides = new Map();\n\t\t\trunInFlight = false;\n\t\t}\n\t}\n\n\tfunction aggregate(\n\t\tsorted: readonly string[],\n\t\tsettled: ReadonlyMap<string, SettledChildV1>,\n\t\trequest: RoleOrchestratorRunRequestV1,\n\t): RoleOrchestrationResultV1 {\n\t\tconst limitBytes = request.limitBytes ?? options.limitBytes ?? DEFAULT_ROLE_AGGREGATION_LIMIT_BYTES;\n\t\t// 6.3 budget semantics: a running byte total over roleId-sorted entries;\n\t\t// an entry that would exceed the budget is dropped whole (truncated),\n\t\t// never partially sliced — mirroring multi-agent-tasks aggregate().\n\t\tlet used = 0;\n\t\tlet truncated = false;\n\t\tconst frozenEntries = sorted.map((roleId): RoleOrchestrationEntryV1 => {\n\t\t\tconst outcome = settled.get(roleId);\n\t\t\tif (!outcome) throw new Error(`Orchestration outcome missing for role: ${roleId}`);\n\t\t\tconst base = {\n\t\t\t\troleId: outcome.roleId,\n\t\t\t\tdefinitionId: outcome.definitionId,\n\t\t\t\tchildInstanceId: outcome.childInstanceId,\n\t\t\t\trevision: outcome.revision,\n\t\t\t\tstatus: outcome.status,\n\t\t\t};\n\t\t\tif (outcome.status !== \"succeeded\" || outcome.output === undefined) {\n\t\t\t\treturn Object.freeze({\n\t\t\t\t\t...base,\n\t\t\t\t\ttruncated: false,\n\t\t\t\t\tmissing: true,\n\t\t\t\t\t...(outcome.error !== undefined ? { error: outcome.error } : {}),\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst size = JSON.stringify(outcome.output).length;\n\t\t\tif (used + size > limitBytes) {\n\t\t\t\ttruncated = true;\n\t\t\t\treturn Object.freeze({ ...base, truncated: true, missing: false });\n\t\t\t}\n\t\t\tused += size;\n\t\t\treturn Object.freeze({ ...base, truncated: false, missing: false, result: outcome.output });\n\t\t});\n\t\tconst entryByRole = new Map(frozenEntries.map((entry) => [entry.roleId, entry]));\n\t\tconst evaluate = request.evaluateCompletion ?? options.evaluateCompletion;\n\t\tconst frozenChecks = sorted.map((roleId): RoleCompletionCheckV1 => {\n\t\t\tconst criteria = requireMetadata(roleId).completionCriteria;\n\t\t\tconst outcome = settled.get(roleId);\n\t\t\tconst entry = entryByRole.get(roleId);\n\t\t\tconst output = outcome?.output;\n\t\t\t// No evaluator, no output, or an output dropped by the byte budget:\n\t\t\t// the criteria cannot be judged, which is reported as unchecked\n\t\t\t// instead of being silently treated as satisfied or unmet.\n\t\t\tif (!evaluate || !output || entry?.truncated === true) {\n\t\t\t\treturn Object.freeze({ roleId, criteria, status: \"unchecked\" as const });\n\t\t\t}\n\t\t\tconst verdict = evaluate({ roleId, criteria, result: output });\n\t\t\treturn Object.freeze({\n\t\t\t\troleId,\n\t\t\t\tcriteria,\n\t\t\t\tstatus:\n\t\t\t\t\tverdict === true\n\t\t\t\t\t\t? (\"satisfied\" as const)\n\t\t\t\t\t\t: verdict === false\n\t\t\t\t\t\t\t? (\"unmet\" as const)\n\t\t\t\t\t\t\t: (\"unchecked\" as const),\n\t\t\t});\n\t\t});\n\t\treturn Object.freeze({\n\t\t\tentries: Object.freeze(frozenEntries),\n\t\t\ttruncated,\n\t\t\tcompletionChecks: Object.freeze(frozenChecks),\n\t\t});\n\t}\n\n\treturn {\n\t\tcomposition: options.composition,\n\t\trunner: options.runner,\n\t\tparentInstanceId: options.parentInstanceId,\n\t\trunRoles,\n\t};\n}\n"]}
1
+ {"version":3,"file":"role-orchestrator.d.ts","sourceRoot":"","sources":["../../src/profile/role-orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,KAAK,EA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;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACpF;AAcD,iEAAiE;AACjE,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,yBAAyB,GAAG,kBAAkB,CA6L7F","sourcesContent":["/**\n * Role orchestrator (2.2e) — root-side concurrent orchestration of registered\n * roles with bounded aggregation.\n *\n * Spawns one child per requested roleId through the public\n * `AgentCompositionAPI` (create/lease/run/wait bound to the root via\n * `parentInstanceId`), honoring the role's `RoleMetadataV1.concurrency`\n * metadata: `parallel` roles run concurrently, `single` roles execute one at\n * a time in stable roleId order. Aggregation reuses the multi-agent-tasks 6.3\n * semantics — entries sorted by roleId (never completion order), a per-entry\n * byte budget over the JSON-serialized output (`limitBytes`; over-budget\n * entries are dropped whole with an explicit `truncated` flag, outputs that\n * are absent carry `missing`), and `completionCriteria` metadata checked per\n * role into a structured satisfied/unmet/unchecked list (never thrown).\n * Child failures are collected, never swallowed: a failed child lands in its\n * structured entry while the orchestration still resolves (fail-collect at\n * the orchestration level, not fail-fast).\n *\n * Limit constants: multi-agent-tasks itself has no built-in numeric caps —\n * its `limitBytes`/`maxResultBytes` are caller-injected and default to\n * unbounded. This contract therefore defaults `limitBytes` to 16 KiB, the\n * magnitude of the repo's existing `DEFAULT_MAX_RESULT_BYTES_V1` (office\n * writer). No separate entry cap is added: the multi-agent-tasks aggregate\n * has none either, and the entry count here is already bounded by the\n * explicit `roleIds` list.\n *\n * Honest state-namespace boundary: state namespaces are partitioned per\n * plugin owner, not per child instance. Concurrent children therefore do NOT\n * get per-instance state isolation under this contract. The deterministic\n * injected run callbacks of this milestone never write state, so the boundary\n * is not exercised here; concurrent child state writes remain outside this\n * contract.\n */\nimport type { AgentCompositionAPI, AgentDefinition } from \"../core/extensions/public-api.ts\";\nimport { t } from \"../core/i18n/index.ts\";\nimport type { RoleMetadataV1 } from \"./role-catalog.ts\";\nimport type { RoleRunCallbackV1, RoleRunnerInputV1, RoleRunnerResultV1, RoleRunnerV1 } from \"./role-runner.ts\";\n\n/**\n * Default aggregation byte budget. The multi-agent-tasks aggregate defaults\n * to unbounded (caller-injected limits); this default anchors the contract to\n * the repo's existing 16 KiB result-cap magnitude.\n */\nexport const DEFAULT_ROLE_AGGREGATION_LIMIT_BYTES = 16 * 1024;\n\n/** Terminal instance states an orchestrated child can settle into. */\nexport type RoleOrchestrationStatusV1 = \"succeeded\" | \"failed\" | \"cancelled\" | \"disposed\";\n\n/** One orchestrated child's aggregation entry (sorted by roleId, never completion order). */\nexport interface RoleOrchestrationEntryV1 {\n\treadonly roleId: string;\n\treadonly definitionId: string;\n\treadonly childInstanceId: string;\n\t/** Terminal revision of the child instance (result reference half, see 2.2b). */\n\treadonly revision: number;\n\treadonly status: RoleOrchestrationStatusV1;\n\t/** The entry's output exceeded the remaining byte budget and was dropped whole. */\n\treadonly truncated: boolean;\n\t/** No output was available (failure, cancellation, disposal, or truncation). */\n\treadonly missing: boolean;\n\t/** Present only for succeeded entries that fit the byte budget. */\n\treadonly result?: RoleRunnerResultV1;\n\t/** Structured failure text; present when the instance settled with an error. */\n\treadonly error?: string;\n}\n\n/** Per-role completion-criteria verdict produced at aggregation time (never thrown). */\nexport interface RoleCompletionCheckV1 {\n\treadonly roleId: string;\n\treadonly criteria: string;\n\t/**\n\t * `satisfied`/`unmet` come from an injected evaluator; `unchecked` means no\n\t * evaluator was available or the entry had no in-budget output to judge.\n\t */\n\treadonly status: \"satisfied\" | \"unmet\" | \"unchecked\";\n}\n\n/**\n * Deterministic completion evaluator. Returns `true`/`false` for a verdict or\n * `undefined` when the criteria cannot be judged from the result.\n */\nexport type RoleCompletionEvaluatorV1 = (input: {\n\treadonly roleId: string;\n\treadonly criteria: string;\n\treadonly result: RoleRunnerResultV1;\n}) => boolean | undefined;\n\n/** One orchestration request: explicit roleIds plus one shared spec string. */\nexport interface RoleOrchestratorRunRequestV1 {\n\treadonly roleIds: readonly string[];\n\treadonly spec: string;\n\t/** Per-role run overrides taking precedence for this request only. */\n\treadonly runs?: readonly { readonly roleId: string; readonly run: RoleRunCallbackV1 }[];\n\t/** Aggregation byte budget for this request (defaults to the orchestrator option). */\n\treadonly limitBytes?: number;\n\t/** Completion evaluator for this request (defaults to the orchestrator option). */\n\treadonly evaluateCompletion?: RoleCompletionEvaluatorV1;\n}\n\nexport interface RoleOrchestratorOptionsV1 {\n\treadonly composition: AgentCompositionAPI;\n\treadonly runner: RoleRunnerV1;\n\t/** Root instance the children are parented to via `parentInstanceId`. */\n\treadonly parentInstanceId: string;\n\t/** Controller-lease owner for the orchestrated children. */\n\treadonly owner?: string;\n\t/** Default aggregation byte budget (see {@link DEFAULT_ROLE_AGGREGATION_LIMIT_BYTES}). */\n\treadonly limitBytes?: number;\n\t/** Default completion evaluator. Without one every check reports `unchecked`. */\n\treadonly evaluateCompletion?: RoleCompletionEvaluatorV1;\n}\n\n/** Orchestration result: bounded aggregation plus completion verdicts. */\nexport interface RoleOrchestrationResultV1 {\n\t/** One entry per requested role, sorted by roleId (stable, never completion order). */\n\treadonly entries: readonly RoleOrchestrationEntryV1[];\n\t/** True when at least one entry was dropped for exceeding the byte budget. */\n\treadonly truncated: boolean;\n\t/** Completion verdicts per requested role, sorted by roleId. */\n\treadonly completionChecks: readonly RoleCompletionCheckV1[];\n}\n\nexport interface RoleOrchestratorV1 {\n\treadonly composition: AgentCompositionAPI;\n\treadonly runner: RoleRunnerV1;\n\treadonly parentInstanceId: string;\n\trunRoles(request: RoleOrchestratorRunRequestV1): Promise<RoleOrchestrationResultV1>;\n}\n\nconst DEFAULT_ORCHESTRATION_OWNER = \"role-orchestrator\";\n\ninterface SettledChildV1 {\n\treadonly roleId: string;\n\treadonly definitionId: string;\n\treadonly childInstanceId: string;\n\treadonly revision: number;\n\treadonly status: RoleOrchestrationStatusV1;\n\treadonly output?: RoleRunnerResultV1;\n\treadonly error?: string;\n}\n\n/** Creates the root-side concurrent role orchestrator (2.2e). */\nexport function createRoleOrchestrator(options: RoleOrchestratorOptionsV1): RoleOrchestratorV1 {\n\tconst owner = options.owner ?? DEFAULT_ORCHESTRATION_OWNER;\n\t// Definitions are registered once per roleId and reused across runs: a\n\t// composition instance is single-run, so every orchestration creates fresh\n\t// child instances from the same definitions.\n\tconst definitions = new Map<string, AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1>>();\n\tlet activeOverrides: ReadonlyMap<string, RoleRunCallbackV1> = new Map();\n\tlet runInFlight = false;\n\n\tfunction requireMetadata(roleId: string): RoleMetadataV1 {\n\t\tconst metadata = options.runner.catalog.get(roleId);\n\t\tif (!metadata) throw new Error(t(\"Unknown role: {roleId}\", { roleId }));\n\t\treturn metadata;\n\t}\n\n\tfunction definitionFor(roleId: string): AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1> {\n\t\tconst cached = definitions.get(roleId);\n\t\tif (cached) return cached;\n\t\tconst base = options.runner.createDefinition(roleId);\n\t\tconst definition: AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1> = {\n\t\t\t...base,\n\t\t\trun: (input, context) => {\n\t\t\t\tconst override = activeOverrides.get(roleId);\n\t\t\t\treturn override ? override(input, context) : options.runner.run(roleId, input, context);\n\t\t\t},\n\t\t};\n\t\tconst registered = options.composition.define(definition);\n\t\tdefinitions.set(roleId, registered);\n\t\treturn registered;\n\t}\n\n\tasync function runOne(roleId: string, spec: string, settled: Map<string, SettledChildV1>): Promise<void> {\n\t\tconst definition = definitionFor(roleId);\n\t\tconst instance = options.composition.create<RoleRunnerInputV1, RoleRunnerResultV1>(\n\t\t\t{ id: definition.id, version: definition.version },\n\t\t\t{ parentInstanceId: options.parentInstanceId },\n\t\t);\n\t\tconst childInstanceId = instance.id;\n\t\tconst lease = await instance.acquireControllerLease(owner);\n\t\ttry {\n\t\t\tconst operation = instance.run({ spec }, { lease });\n\t\t\ttry {\n\t\t\t\tawait operation.result;\n\t\t\t} catch {\n\t\t\t\t// run() rejects on failure/cancellation mid-flight; instance.wait()\n\t\t\t\t// below yields the terminal status and error.\n\t\t\t}\n\t\t\tconst terminal = await instance.wait();\n\t\t\tconst error =\n\t\t\t\tterminal.error === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: terminal.error instanceof Error\n\t\t\t\t\t\t? terminal.error.message\n\t\t\t\t\t\t: String(terminal.error);\n\t\t\tsettled.set(roleId, {\n\t\t\t\troleId,\n\t\t\t\tdefinitionId: definition.id,\n\t\t\t\tchildInstanceId,\n\t\t\t\trevision: terminal.revision,\n\t\t\t\tstatus: terminal.status,\n\t\t\t\t...(terminal.output !== undefined ? { output: terminal.output } : {}),\n\t\t\t\t...(error !== undefined ? { error } : {}),\n\t\t\t});\n\t\t} finally {\n\t\t\tif (lease.isActive()) await lease.release();\n\t\t}\n\t}\n\n\tasync function runRoles(request: RoleOrchestratorRunRequestV1): Promise<RoleOrchestrationResultV1> {\n\t\tif (runInFlight) throw new Error(t(\"Role orchestrator is already running an orchestration\"));\n\t\t// Input validation fails explicitly before any child is spawned.\n\t\tconst seen = new Set<string>();\n\t\tfor (const roleId of request.roleIds) {\n\t\t\tif (typeof roleId !== \"string\" || roleId.trim().length === 0) {\n\t\t\t\tthrow new Error(t(\"Role id must be a non-empty string\"));\n\t\t\t}\n\t\t\tif (seen.has(roleId)) throw new Error(t(\"Duplicate roleId in orchestration request: {roleId}\", { roleId }));\n\t\t\tseen.add(roleId);\n\t\t}\n\t\tconst overrides = new Map<string, RoleRunCallbackV1>();\n\t\tfor (const override of request.runs ?? []) {\n\t\t\tif (overrides.has(override.roleId))\n\t\t\t\tthrow new Error(t(\"Duplicate run override for role: {roleId}\", { roleId: override.roleId }));\n\t\t\toverrides.set(override.roleId, override.run);\n\t\t}\n\t\tfor (const roleId of overrides.keys()) {\n\t\t\tif (!seen.has(roleId)) throw new Error(t(\"Run override for unrequested role: {roleId}\", { roleId }));\n\t\t}\n\t\t// Stable execution order: roleId-sorted, `parallel` roles concurrent,\n\t\t// `single` roles strictly sequential. Aggregation order is independent\n\t\t// of this execution order.\n\t\tconst sorted = [...request.roleIds].sort((left, right) => left.localeCompare(right));\n\t\tfor (const roleId of sorted) {\n\t\t\trequireMetadata(roleId);\n\t\t\tdefinitionFor(roleId);\n\t\t}\n\n\t\trunInFlight = true;\n\t\ttry {\n\t\t\tactiveOverrides = overrides;\n\t\t\tconst settled = new Map<string, SettledChildV1>();\n\t\t\tif (sorted.length > 0) {\n\t\t\t\tconst parallelIds = sorted.filter((roleId) => requireMetadata(roleId).concurrency === \"parallel\");\n\t\t\t\tconst singleIds = sorted.filter((roleId) => requireMetadata(roleId).concurrency === \"single\");\n\t\t\t\tawait Promise.all(parallelIds.map((roleId) => runOne(roleId, request.spec, settled)));\n\t\t\t\tfor (const roleId of singleIds) await runOne(roleId, request.spec, settled);\n\t\t\t}\n\t\t\treturn aggregate(sorted, settled, request);\n\t\t} finally {\n\t\t\tactiveOverrides = new Map();\n\t\t\trunInFlight = false;\n\t\t}\n\t}\n\n\tfunction aggregate(\n\t\tsorted: readonly string[],\n\t\tsettled: ReadonlyMap<string, SettledChildV1>,\n\t\trequest: RoleOrchestratorRunRequestV1,\n\t): RoleOrchestrationResultV1 {\n\t\tconst limitBytes = request.limitBytes ?? options.limitBytes ?? DEFAULT_ROLE_AGGREGATION_LIMIT_BYTES;\n\t\t// 6.3 budget semantics: a running byte total over roleId-sorted entries;\n\t\t// an entry that would exceed the budget is dropped whole (truncated),\n\t\t// never partially sliced — mirroring multi-agent-tasks aggregate().\n\t\tlet used = 0;\n\t\tlet truncated = false;\n\t\tconst frozenEntries = sorted.map((roleId): RoleOrchestrationEntryV1 => {\n\t\t\tconst outcome = settled.get(roleId);\n\t\t\tif (!outcome) throw new Error(t(\"Orchestration outcome missing for role: {roleId}\", { roleId }));\n\t\t\tconst base = {\n\t\t\t\troleId: outcome.roleId,\n\t\t\t\tdefinitionId: outcome.definitionId,\n\t\t\t\tchildInstanceId: outcome.childInstanceId,\n\t\t\t\trevision: outcome.revision,\n\t\t\t\tstatus: outcome.status,\n\t\t\t};\n\t\t\tif (outcome.status !== \"succeeded\" || outcome.output === undefined) {\n\t\t\t\treturn Object.freeze({\n\t\t\t\t\t...base,\n\t\t\t\t\ttruncated: false,\n\t\t\t\t\tmissing: true,\n\t\t\t\t\t...(outcome.error !== undefined ? { error: outcome.error } : {}),\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst size = JSON.stringify(outcome.output).length;\n\t\t\tif (used + size > limitBytes) {\n\t\t\t\ttruncated = true;\n\t\t\t\treturn Object.freeze({ ...base, truncated: true, missing: false });\n\t\t\t}\n\t\t\tused += size;\n\t\t\treturn Object.freeze({ ...base, truncated: false, missing: false, result: outcome.output });\n\t\t});\n\t\tconst entryByRole = new Map(frozenEntries.map((entry) => [entry.roleId, entry]));\n\t\tconst evaluate = request.evaluateCompletion ?? options.evaluateCompletion;\n\t\tconst frozenChecks = sorted.map((roleId): RoleCompletionCheckV1 => {\n\t\t\tconst criteria = requireMetadata(roleId).completionCriteria;\n\t\t\tconst outcome = settled.get(roleId);\n\t\t\tconst entry = entryByRole.get(roleId);\n\t\t\tconst output = outcome?.output;\n\t\t\t// No evaluator, no output, or an output dropped by the byte budget:\n\t\t\t// the criteria cannot be judged, which is reported as unchecked\n\t\t\t// instead of being silently treated as satisfied or unmet.\n\t\t\tif (!evaluate || !output || entry?.truncated === true) {\n\t\t\t\treturn Object.freeze({ roleId, criteria, status: \"unchecked\" as const });\n\t\t\t}\n\t\t\tconst verdict = evaluate({ roleId, criteria, result: output });\n\t\t\treturn Object.freeze({\n\t\t\t\troleId,\n\t\t\t\tcriteria,\n\t\t\t\tstatus:\n\t\t\t\t\tverdict === true\n\t\t\t\t\t\t? (\"satisfied\" as const)\n\t\t\t\t\t\t: verdict === false\n\t\t\t\t\t\t\t? (\"unmet\" as const)\n\t\t\t\t\t\t\t: (\"unchecked\" as const),\n\t\t\t});\n\t\t});\n\t\treturn Object.freeze({\n\t\t\tentries: Object.freeze(frozenEntries),\n\t\t\ttruncated,\n\t\t\tcompletionChecks: Object.freeze(frozenChecks),\n\t\t});\n\t}\n\n\treturn {\n\t\tcomposition: options.composition,\n\t\trunner: options.runner,\n\t\tparentInstanceId: options.parentInstanceId,\n\t\trunRoles,\n\t};\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { t } from "../core/i18n/index.js";
1
2
  /**
2
3
  * Default aggregation byte budget. The multi-agent-tasks aggregate defaults
3
4
  * to unbounded (caller-injected limits); this default anchors the contract to
@@ -17,7 +18,7 @@ export function createRoleOrchestrator(options) {
17
18
  function requireMetadata(roleId) {
18
19
  const metadata = options.runner.catalog.get(roleId);
19
20
  if (!metadata)
20
- throw new Error(`Unknown role: ${roleId}`);
21
+ throw new Error(t("Unknown role: {roleId}", { roleId }));
21
22
  return metadata;
22
23
  }
23
24
  function definitionFor(roleId) {
@@ -73,26 +74,26 @@ export function createRoleOrchestrator(options) {
73
74
  }
74
75
  async function runRoles(request) {
75
76
  if (runInFlight)
76
- throw new Error("Role orchestrator is already running an orchestration");
77
+ throw new Error(t("Role orchestrator is already running an orchestration"));
77
78
  // Input validation fails explicitly before any child is spawned.
78
79
  const seen = new Set();
79
80
  for (const roleId of request.roleIds) {
80
81
  if (typeof roleId !== "string" || roleId.trim().length === 0) {
81
- throw new Error("Role id must be a non-empty string");
82
+ throw new Error(t("Role id must be a non-empty string"));
82
83
  }
83
84
  if (seen.has(roleId))
84
- throw new Error(`Duplicate roleId in orchestration request: ${roleId}`);
85
+ throw new Error(t("Duplicate roleId in orchestration request: {roleId}", { roleId }));
85
86
  seen.add(roleId);
86
87
  }
87
88
  const overrides = new Map();
88
89
  for (const override of request.runs ?? []) {
89
90
  if (overrides.has(override.roleId))
90
- throw new Error(`Duplicate run override for role: ${override.roleId}`);
91
+ throw new Error(t("Duplicate run override for role: {roleId}", { roleId: override.roleId }));
91
92
  overrides.set(override.roleId, override.run);
92
93
  }
93
94
  for (const roleId of overrides.keys()) {
94
95
  if (!seen.has(roleId))
95
- throw new Error(`Run override for unrequested role: ${roleId}`);
96
+ throw new Error(t("Run override for unrequested role: {roleId}", { roleId }));
96
97
  }
97
98
  // Stable execution order: roleId-sorted, `parallel` roles concurrent,
98
99
  // `single` roles strictly sequential. Aggregation order is independent
@@ -130,7 +131,7 @@ export function createRoleOrchestrator(options) {
130
131
  const frozenEntries = sorted.map((roleId) => {
131
132
  const outcome = settled.get(roleId);
132
133
  if (!outcome)
133
- throw new Error(`Orchestration outcome missing for role: ${roleId}`);
134
+ throw new Error(t("Orchestration outcome missing for role: {roleId}", { roleId }));
134
135
  const base = {
135
136
  roleId: outcome.roleId,
136
137
  definitionId: outcome.definitionId,
@@ -1 +1 @@
1
- {"version":3,"file":"role-orchestrator.js","sourceRoot":"","sources":["../../src/profile/role-orchestrator.ts"],"names":[],"mappings":"AAqCA;;;;GAIG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,EAAE,GAAG,IAAI,CAAC;AAsF9D,MAAM,2BAA2B,GAAG,mBAAmB,CAAC;AAYxD,iEAAiE;AACjE,MAAM,UAAU,sBAAsB,CAAC,OAAkC,EAAsB;IAC9F,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,2BAA2B,CAAC;IAC3D,uEAAuE;IACvE,2EAA2E;IAC3E,6CAA6C;IAC7C,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkE,CAAC;IAC9F,IAAI,eAAe,GAA2C,IAAI,GAAG,EAAE,CAAC;IACxE,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,SAAS,eAAe,CAAC,MAAc,EAAkB;QACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,MAAM,EAAE,CAAC,CAAC;QAC1D,OAAO,QAAQ,CAAC;IAAA,CAChB;IAED,SAAS,aAAa,CAAC,MAAc,EAA0D;QAC9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AE,WAAqB;oBACxB,CAAC,CAAC,OAAO,KAAK,KAAK;wBAClB,CAAC,CAAE,OAAiB;wBACpB,CAAC,CAAE,WAAqB;aAC3B,CAAC,CAAC;QAAA,CACH,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,MAAM,CAAC;YACpB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;YACrC,SAAS;YACT,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;SAC7C,CAAC,CAAC;IAAA,CACH;IAED,OAAO;QACN,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,QAAQ;KACR,CAAC;AAAA,CACF","sourcesContent":["/**\n * Role orchestrator (2.2e) — root-side concurrent orchestration of registered\n * roles with bounded aggregation.\n *\n * Spawns one child per requested roleId through the public\n * `AgentCompositionAPI` (create/lease/run/wait bound to the root via\n * `parentInstanceId`), honoring the role's `RoleMetadataV1.concurrency`\n * metadata: `parallel` roles run concurrently, `single` roles execute one at\n * a time in stable roleId order. Aggregation reuses the multi-agent-tasks 6.3\n * semantics — entries sorted by roleId (never completion order), a per-entry\n * byte budget over the JSON-serialized output (`limitBytes`; over-budget\n * entries are dropped whole with an explicit `truncated` flag, outputs that\n * are absent carry `missing`), and `completionCriteria` metadata checked per\n * role into a structured satisfied/unmet/unchecked list (never thrown).\n * Child failures are collected, never swallowed: a failed child lands in its\n * structured entry while the orchestration still resolves (fail-collect at\n * the orchestration level, not fail-fast).\n *\n * Limit constants: multi-agent-tasks itself has no built-in numeric caps —\n * its `limitBytes`/`maxResultBytes` are caller-injected and default to\n * unbounded. This contract therefore defaults `limitBytes` to 16 KiB, the\n * magnitude of the repo's existing `DEFAULT_MAX_RESULT_BYTES_V1` (office\n * writer). No separate entry cap is added: the multi-agent-tasks aggregate\n * has none either, and the entry count here is already bounded by the\n * explicit `roleIds` list.\n *\n * Honest state-namespace boundary: state namespaces are partitioned per\n * plugin owner, not per child instance. Concurrent children therefore do NOT\n * get per-instance state isolation under this contract. The deterministic\n * injected run callbacks of this milestone never write state, so the boundary\n * is not exercised here; concurrent child state writes remain outside this\n * contract.\n */\nimport type { AgentCompositionAPI, AgentDefinition } from \"../core/extensions/public-api.ts\";\nimport type { RoleMetadataV1 } from \"./role-catalog.ts\";\nimport type { RoleRunCallbackV1, RoleRunnerInputV1, RoleRunnerResultV1, RoleRunnerV1 } from \"./role-runner.ts\";\n\n/**\n * Default aggregation byte budget. The multi-agent-tasks aggregate defaults\n * to unbounded (caller-injected limits); this default anchors the contract to\n * the repo's existing 16 KiB result-cap magnitude.\n */\nexport const DEFAULT_ROLE_AGGREGATION_LIMIT_BYTES = 16 * 1024;\n\n/** Terminal instance states an orchestrated child can settle into. */\nexport type RoleOrchestrationStatusV1 = \"succeeded\" | \"failed\" | \"cancelled\" | \"disposed\";\n\n/** One orchestrated child's aggregation entry (sorted by roleId, never completion order). */\nexport interface RoleOrchestrationEntryV1 {\n\treadonly roleId: string;\n\treadonly definitionId: string;\n\treadonly childInstanceId: string;\n\t/** Terminal revision of the child instance (result reference half, see 2.2b). */\n\treadonly revision: number;\n\treadonly status: RoleOrchestrationStatusV1;\n\t/** The entry's output exceeded the remaining byte budget and was dropped whole. */\n\treadonly truncated: boolean;\n\t/** No output was available (failure, cancellation, disposal, or truncation). */\n\treadonly missing: boolean;\n\t/** Present only for succeeded entries that fit the byte budget. */\n\treadonly result?: RoleRunnerResultV1;\n\t/** Structured failure text; present when the instance settled with an error. */\n\treadonly error?: string;\n}\n\n/** Per-role completion-criteria verdict produced at aggregation time (never thrown). */\nexport interface RoleCompletionCheckV1 {\n\treadonly roleId: string;\n\treadonly criteria: string;\n\t/**\n\t * `satisfied`/`unmet` come from an injected evaluator; `unchecked` means no\n\t * evaluator was available or the entry had no in-budget output to judge.\n\t */\n\treadonly status: \"satisfied\" | \"unmet\" | \"unchecked\";\n}\n\n/**\n * Deterministic completion evaluator. Returns `true`/`false` for a verdict or\n * `undefined` when the criteria cannot be judged from the result.\n */\nexport type RoleCompletionEvaluatorV1 = (input: {\n\treadonly roleId: string;\n\treadonly criteria: string;\n\treadonly result: RoleRunnerResultV1;\n}) => boolean | undefined;\n\n/** One orchestration request: explicit roleIds plus one shared spec string. */\nexport interface RoleOrchestratorRunRequestV1 {\n\treadonly roleIds: readonly string[];\n\treadonly spec: string;\n\t/** Per-role run overrides taking precedence for this request only. */\n\treadonly runs?: readonly { readonly roleId: string; readonly run: RoleRunCallbackV1 }[];\n\t/** Aggregation byte budget for this request (defaults to the orchestrator option). */\n\treadonly limitBytes?: number;\n\t/** Completion evaluator for this request (defaults to the orchestrator option). */\n\treadonly evaluateCompletion?: RoleCompletionEvaluatorV1;\n}\n\nexport interface RoleOrchestratorOptionsV1 {\n\treadonly composition: AgentCompositionAPI;\n\treadonly runner: RoleRunnerV1;\n\t/** Root instance the children are parented to via `parentInstanceId`. */\n\treadonly parentInstanceId: string;\n\t/** Controller-lease owner for the orchestrated children. */\n\treadonly owner?: string;\n\t/** Default aggregation byte budget (see {@link DEFAULT_ROLE_AGGREGATION_LIMIT_BYTES}). */\n\treadonly limitBytes?: number;\n\t/** Default completion evaluator. Without one every check reports `unchecked`. */\n\treadonly evaluateCompletion?: RoleCompletionEvaluatorV1;\n}\n\n/** Orchestration result: bounded aggregation plus completion verdicts. */\nexport interface RoleOrchestrationResultV1 {\n\t/** One entry per requested role, sorted by roleId (stable, never completion order). */\n\treadonly entries: readonly RoleOrchestrationEntryV1[];\n\t/** True when at least one entry was dropped for exceeding the byte budget. */\n\treadonly truncated: boolean;\n\t/** Completion verdicts per requested role, sorted by roleId. */\n\treadonly completionChecks: readonly RoleCompletionCheckV1[];\n}\n\nexport interface RoleOrchestratorV1 {\n\treadonly composition: AgentCompositionAPI;\n\treadonly runner: RoleRunnerV1;\n\treadonly parentInstanceId: string;\n\trunRoles(request: RoleOrchestratorRunRequestV1): Promise<RoleOrchestrationResultV1>;\n}\n\nconst DEFAULT_ORCHESTRATION_OWNER = \"role-orchestrator\";\n\ninterface SettledChildV1 {\n\treadonly roleId: string;\n\treadonly definitionId: string;\n\treadonly childInstanceId: string;\n\treadonly revision: number;\n\treadonly status: RoleOrchestrationStatusV1;\n\treadonly output?: RoleRunnerResultV1;\n\treadonly error?: string;\n}\n\n/** Creates the root-side concurrent role orchestrator (2.2e). */\nexport function createRoleOrchestrator(options: RoleOrchestratorOptionsV1): RoleOrchestratorV1 {\n\tconst owner = options.owner ?? DEFAULT_ORCHESTRATION_OWNER;\n\t// Definitions are registered once per roleId and reused across runs: a\n\t// composition instance is single-run, so every orchestration creates fresh\n\t// child instances from the same definitions.\n\tconst definitions = new Map<string, AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1>>();\n\tlet activeOverrides: ReadonlyMap<string, RoleRunCallbackV1> = new Map();\n\tlet runInFlight = false;\n\n\tfunction requireMetadata(roleId: string): RoleMetadataV1 {\n\t\tconst metadata = options.runner.catalog.get(roleId);\n\t\tif (!metadata) throw new Error(`Unknown role: ${roleId}`);\n\t\treturn metadata;\n\t}\n\n\tfunction definitionFor(roleId: string): AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1> {\n\t\tconst cached = definitions.get(roleId);\n\t\tif (cached) return cached;\n\t\tconst base = options.runner.createDefinition(roleId);\n\t\tconst definition: AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1> = {\n\t\t\t...base,\n\t\t\trun: (input, context) => {\n\t\t\t\tconst override = activeOverrides.get(roleId);\n\t\t\t\treturn override ? override(input, context) : options.runner.run(roleId, input, context);\n\t\t\t},\n\t\t};\n\t\tconst registered = options.composition.define(definition);\n\t\tdefinitions.set(roleId, registered);\n\t\treturn registered;\n\t}\n\n\tasync function runOne(roleId: string, spec: string, settled: Map<string, SettledChildV1>): Promise<void> {\n\t\tconst definition = definitionFor(roleId);\n\t\tconst instance = options.composition.create<RoleRunnerInputV1, RoleRunnerResultV1>(\n\t\t\t{ id: definition.id, version: definition.version },\n\t\t\t{ parentInstanceId: options.parentInstanceId },\n\t\t);\n\t\tconst childInstanceId = instance.id;\n\t\tconst lease = await instance.acquireControllerLease(owner);\n\t\ttry {\n\t\t\tconst operation = instance.run({ spec }, { lease });\n\t\t\ttry {\n\t\t\t\tawait operation.result;\n\t\t\t} catch {\n\t\t\t\t// run() rejects on failure/cancellation mid-flight; instance.wait()\n\t\t\t\t// below yields the terminal status and error.\n\t\t\t}\n\t\t\tconst terminal = await instance.wait();\n\t\t\tconst error =\n\t\t\t\tterminal.error === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: terminal.error instanceof Error\n\t\t\t\t\t\t? terminal.error.message\n\t\t\t\t\t\t: String(terminal.error);\n\t\t\tsettled.set(roleId, {\n\t\t\t\troleId,\n\t\t\t\tdefinitionId: definition.id,\n\t\t\t\tchildInstanceId,\n\t\t\t\trevision: terminal.revision,\n\t\t\t\tstatus: terminal.status,\n\t\t\t\t...(terminal.output !== undefined ? { output: terminal.output } : {}),\n\t\t\t\t...(error !== undefined ? { error } : {}),\n\t\t\t});\n\t\t} finally {\n\t\t\tif (lease.isActive()) await lease.release();\n\t\t}\n\t}\n\n\tasync function runRoles(request: RoleOrchestratorRunRequestV1): Promise<RoleOrchestrationResultV1> {\n\t\tif (runInFlight) throw new Error(\"Role orchestrator is already running an orchestration\");\n\t\t// Input validation fails explicitly before any child is spawned.\n\t\tconst seen = new Set<string>();\n\t\tfor (const roleId of request.roleIds) {\n\t\t\tif (typeof roleId !== \"string\" || roleId.trim().length === 0) {\n\t\t\t\tthrow new Error(\"Role id must be a non-empty string\");\n\t\t\t}\n\t\t\tif (seen.has(roleId)) throw new Error(`Duplicate roleId in orchestration request: ${roleId}`);\n\t\t\tseen.add(roleId);\n\t\t}\n\t\tconst overrides = new Map<string, RoleRunCallbackV1>();\n\t\tfor (const override of request.runs ?? []) {\n\t\t\tif (overrides.has(override.roleId)) throw new Error(`Duplicate run override for role: ${override.roleId}`);\n\t\t\toverrides.set(override.roleId, override.run);\n\t\t}\n\t\tfor (const roleId of overrides.keys()) {\n\t\t\tif (!seen.has(roleId)) throw new Error(`Run override for unrequested role: ${roleId}`);\n\t\t}\n\t\t// Stable execution order: roleId-sorted, `parallel` roles concurrent,\n\t\t// `single` roles strictly sequential. Aggregation order is independent\n\t\t// of this execution order.\n\t\tconst sorted = [...request.roleIds].sort((left, right) => left.localeCompare(right));\n\t\tfor (const roleId of sorted) {\n\t\t\trequireMetadata(roleId);\n\t\t\tdefinitionFor(roleId);\n\t\t}\n\n\t\trunInFlight = true;\n\t\ttry {\n\t\t\tactiveOverrides = overrides;\n\t\t\tconst settled = new Map<string, SettledChildV1>();\n\t\t\tif (sorted.length > 0) {\n\t\t\t\tconst parallelIds = sorted.filter((roleId) => requireMetadata(roleId).concurrency === \"parallel\");\n\t\t\t\tconst singleIds = sorted.filter((roleId) => requireMetadata(roleId).concurrency === \"single\");\n\t\t\t\tawait Promise.all(parallelIds.map((roleId) => runOne(roleId, request.spec, settled)));\n\t\t\t\tfor (const roleId of singleIds) await runOne(roleId, request.spec, settled);\n\t\t\t}\n\t\t\treturn aggregate(sorted, settled, request);\n\t\t} finally {\n\t\t\tactiveOverrides = new Map();\n\t\t\trunInFlight = false;\n\t\t}\n\t}\n\n\tfunction aggregate(\n\t\tsorted: readonly string[],\n\t\tsettled: ReadonlyMap<string, SettledChildV1>,\n\t\trequest: RoleOrchestratorRunRequestV1,\n\t): RoleOrchestrationResultV1 {\n\t\tconst limitBytes = request.limitBytes ?? options.limitBytes ?? DEFAULT_ROLE_AGGREGATION_LIMIT_BYTES;\n\t\t// 6.3 budget semantics: a running byte total over roleId-sorted entries;\n\t\t// an entry that would exceed the budget is dropped whole (truncated),\n\t\t// never partially sliced — mirroring multi-agent-tasks aggregate().\n\t\tlet used = 0;\n\t\tlet truncated = false;\n\t\tconst frozenEntries = sorted.map((roleId): RoleOrchestrationEntryV1 => {\n\t\t\tconst outcome = settled.get(roleId);\n\t\t\tif (!outcome) throw new Error(`Orchestration outcome missing for role: ${roleId}`);\n\t\t\tconst base = {\n\t\t\t\troleId: outcome.roleId,\n\t\t\t\tdefinitionId: outcome.definitionId,\n\t\t\t\tchildInstanceId: outcome.childInstanceId,\n\t\t\t\trevision: outcome.revision,\n\t\t\t\tstatus: outcome.status,\n\t\t\t};\n\t\t\tif (outcome.status !== \"succeeded\" || outcome.output === undefined) {\n\t\t\t\treturn Object.freeze({\n\t\t\t\t\t...base,\n\t\t\t\t\ttruncated: false,\n\t\t\t\t\tmissing: true,\n\t\t\t\t\t...(outcome.error !== undefined ? { error: outcome.error } : {}),\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst size = JSON.stringify(outcome.output).length;\n\t\t\tif (used + size > limitBytes) {\n\t\t\t\ttruncated = true;\n\t\t\t\treturn Object.freeze({ ...base, truncated: true, missing: false });\n\t\t\t}\n\t\t\tused += size;\n\t\t\treturn Object.freeze({ ...base, truncated: false, missing: false, result: outcome.output });\n\t\t});\n\t\tconst entryByRole = new Map(frozenEntries.map((entry) => [entry.roleId, entry]));\n\t\tconst evaluate = request.evaluateCompletion ?? options.evaluateCompletion;\n\t\tconst frozenChecks = sorted.map((roleId): RoleCompletionCheckV1 => {\n\t\t\tconst criteria = requireMetadata(roleId).completionCriteria;\n\t\t\tconst outcome = settled.get(roleId);\n\t\t\tconst entry = entryByRole.get(roleId);\n\t\t\tconst output = outcome?.output;\n\t\t\t// No evaluator, no output, or an output dropped by the byte budget:\n\t\t\t// the criteria cannot be judged, which is reported as unchecked\n\t\t\t// instead of being silently treated as satisfied or unmet.\n\t\t\tif (!evaluate || !output || entry?.truncated === true) {\n\t\t\t\treturn Object.freeze({ roleId, criteria, status: \"unchecked\" as const });\n\t\t\t}\n\t\t\tconst verdict = evaluate({ roleId, criteria, result: output });\n\t\t\treturn Object.freeze({\n\t\t\t\troleId,\n\t\t\t\tcriteria,\n\t\t\t\tstatus:\n\t\t\t\t\tverdict === true\n\t\t\t\t\t\t? (\"satisfied\" as const)\n\t\t\t\t\t\t: verdict === false\n\t\t\t\t\t\t\t? (\"unmet\" as const)\n\t\t\t\t\t\t\t: (\"unchecked\" as const),\n\t\t\t});\n\t\t});\n\t\treturn Object.freeze({\n\t\t\tentries: Object.freeze(frozenEntries),\n\t\t\ttruncated,\n\t\t\tcompletionChecks: Object.freeze(frozenChecks),\n\t\t});\n\t}\n\n\treturn {\n\t\tcomposition: options.composition,\n\t\trunner: options.runner,\n\t\tparentInstanceId: options.parentInstanceId,\n\t\trunRoles,\n\t};\n}\n"]}
1
+ {"version":3,"file":"role-orchestrator.js","sourceRoot":"","sources":["../../src/profile/role-orchestrator.ts"],"names":[],"mappings":"AAkCA,OAAO,EAAE,CAAC,EAAE,MAAM,uBAAuB,CAAC;AAI1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,EAAE,GAAG,IAAI,CAAC;AAsF9D,MAAM,2BAA2B,GAAG,mBAAmB,CAAC;AAYxD,iEAAiE;AACjE,MAAM,UAAU,sBAAsB,CAAC,OAAkC,EAAsB;IAC9F,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,2BAA2B,CAAC;IAC3D,uEAAuE;IACvE,2EAA2E;IAC3E,6CAA6C;IAC7C,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkE,CAAC;IAC9F,IAAI,eAAe,GAA2C,IAAI,GAAG,EAAE,CAAC;IACxE,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,SAAS,eAAe,CAAC,MAAc,EAAkB;QACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,wBAAwB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QACxE,OAAO,QAAQ,CAAC;IAAA,CAChB;IAED,SAAS,aAAa,CAAC,MAAc,EAA0D;QAC9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,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAC/D,OAAO,MAAM,CAAC,MAAM,CAAC;gBACpB,MAAM;gBACN,QAAQ;gBACR,MAAM,EACL,OAAO,KAAK,IAAI;oBACf,CAAC,CAAE,WAAqB;oBACxB,CAAC,CAAC,OAAO,KAAK,KAAK;wBAClB,CAAC,CAAE,OAAiB;wBACpB,CAAC,CAAE,WAAqB;aAC3B,CAAC,CAAC;QAAA,CACH,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,MAAM,CAAC;YACpB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;YACrC,SAAS;YACT,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;SAC7C,CAAC,CAAC;IAAA,CACH;IAED,OAAO;QACN,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,QAAQ;KACR,CAAC;AAAA,CACF","sourcesContent":["/**\n * Role orchestrator (2.2e) — root-side concurrent orchestration of registered\n * roles with bounded aggregation.\n *\n * Spawns one child per requested roleId through the public\n * `AgentCompositionAPI` (create/lease/run/wait bound to the root via\n * `parentInstanceId`), honoring the role's `RoleMetadataV1.concurrency`\n * metadata: `parallel` roles run concurrently, `single` roles execute one at\n * a time in stable roleId order. Aggregation reuses the multi-agent-tasks 6.3\n * semantics — entries sorted by roleId (never completion order), a per-entry\n * byte budget over the JSON-serialized output (`limitBytes`; over-budget\n * entries are dropped whole with an explicit `truncated` flag, outputs that\n * are absent carry `missing`), and `completionCriteria` metadata checked per\n * role into a structured satisfied/unmet/unchecked list (never thrown).\n * Child failures are collected, never swallowed: a failed child lands in its\n * structured entry while the orchestration still resolves (fail-collect at\n * the orchestration level, not fail-fast).\n *\n * Limit constants: multi-agent-tasks itself has no built-in numeric caps —\n * its `limitBytes`/`maxResultBytes` are caller-injected and default to\n * unbounded. This contract therefore defaults `limitBytes` to 16 KiB, the\n * magnitude of the repo's existing `DEFAULT_MAX_RESULT_BYTES_V1` (office\n * writer). No separate entry cap is added: the multi-agent-tasks aggregate\n * has none either, and the entry count here is already bounded by the\n * explicit `roleIds` list.\n *\n * Honest state-namespace boundary: state namespaces are partitioned per\n * plugin owner, not per child instance. Concurrent children therefore do NOT\n * get per-instance state isolation under this contract. The deterministic\n * injected run callbacks of this milestone never write state, so the boundary\n * is not exercised here; concurrent child state writes remain outside this\n * contract.\n */\nimport type { AgentCompositionAPI, AgentDefinition } from \"../core/extensions/public-api.ts\";\nimport { t } from \"../core/i18n/index.ts\";\nimport type { RoleMetadataV1 } from \"./role-catalog.ts\";\nimport type { RoleRunCallbackV1, RoleRunnerInputV1, RoleRunnerResultV1, RoleRunnerV1 } from \"./role-runner.ts\";\n\n/**\n * Default aggregation byte budget. The multi-agent-tasks aggregate defaults\n * to unbounded (caller-injected limits); this default anchors the contract to\n * the repo's existing 16 KiB result-cap magnitude.\n */\nexport const DEFAULT_ROLE_AGGREGATION_LIMIT_BYTES = 16 * 1024;\n\n/** Terminal instance states an orchestrated child can settle into. */\nexport type RoleOrchestrationStatusV1 = \"succeeded\" | \"failed\" | \"cancelled\" | \"disposed\";\n\n/** One orchestrated child's aggregation entry (sorted by roleId, never completion order). */\nexport interface RoleOrchestrationEntryV1 {\n\treadonly roleId: string;\n\treadonly definitionId: string;\n\treadonly childInstanceId: string;\n\t/** Terminal revision of the child instance (result reference half, see 2.2b). */\n\treadonly revision: number;\n\treadonly status: RoleOrchestrationStatusV1;\n\t/** The entry's output exceeded the remaining byte budget and was dropped whole. */\n\treadonly truncated: boolean;\n\t/** No output was available (failure, cancellation, disposal, or truncation). */\n\treadonly missing: boolean;\n\t/** Present only for succeeded entries that fit the byte budget. */\n\treadonly result?: RoleRunnerResultV1;\n\t/** Structured failure text; present when the instance settled with an error. */\n\treadonly error?: string;\n}\n\n/** Per-role completion-criteria verdict produced at aggregation time (never thrown). */\nexport interface RoleCompletionCheckV1 {\n\treadonly roleId: string;\n\treadonly criteria: string;\n\t/**\n\t * `satisfied`/`unmet` come from an injected evaluator; `unchecked` means no\n\t * evaluator was available or the entry had no in-budget output to judge.\n\t */\n\treadonly status: \"satisfied\" | \"unmet\" | \"unchecked\";\n}\n\n/**\n * Deterministic completion evaluator. Returns `true`/`false` for a verdict or\n * `undefined` when the criteria cannot be judged from the result.\n */\nexport type RoleCompletionEvaluatorV1 = (input: {\n\treadonly roleId: string;\n\treadonly criteria: string;\n\treadonly result: RoleRunnerResultV1;\n}) => boolean | undefined;\n\n/** One orchestration request: explicit roleIds plus one shared spec string. */\nexport interface RoleOrchestratorRunRequestV1 {\n\treadonly roleIds: readonly string[];\n\treadonly spec: string;\n\t/** Per-role run overrides taking precedence for this request only. */\n\treadonly runs?: readonly { readonly roleId: string; readonly run: RoleRunCallbackV1 }[];\n\t/** Aggregation byte budget for this request (defaults to the orchestrator option). */\n\treadonly limitBytes?: number;\n\t/** Completion evaluator for this request (defaults to the orchestrator option). */\n\treadonly evaluateCompletion?: RoleCompletionEvaluatorV1;\n}\n\nexport interface RoleOrchestratorOptionsV1 {\n\treadonly composition: AgentCompositionAPI;\n\treadonly runner: RoleRunnerV1;\n\t/** Root instance the children are parented to via `parentInstanceId`. */\n\treadonly parentInstanceId: string;\n\t/** Controller-lease owner for the orchestrated children. */\n\treadonly owner?: string;\n\t/** Default aggregation byte budget (see {@link DEFAULT_ROLE_AGGREGATION_LIMIT_BYTES}). */\n\treadonly limitBytes?: number;\n\t/** Default completion evaluator. Without one every check reports `unchecked`. */\n\treadonly evaluateCompletion?: RoleCompletionEvaluatorV1;\n}\n\n/** Orchestration result: bounded aggregation plus completion verdicts. */\nexport interface RoleOrchestrationResultV1 {\n\t/** One entry per requested role, sorted by roleId (stable, never completion order). */\n\treadonly entries: readonly RoleOrchestrationEntryV1[];\n\t/** True when at least one entry was dropped for exceeding the byte budget. */\n\treadonly truncated: boolean;\n\t/** Completion verdicts per requested role, sorted by roleId. */\n\treadonly completionChecks: readonly RoleCompletionCheckV1[];\n}\n\nexport interface RoleOrchestratorV1 {\n\treadonly composition: AgentCompositionAPI;\n\treadonly runner: RoleRunnerV1;\n\treadonly parentInstanceId: string;\n\trunRoles(request: RoleOrchestratorRunRequestV1): Promise<RoleOrchestrationResultV1>;\n}\n\nconst DEFAULT_ORCHESTRATION_OWNER = \"role-orchestrator\";\n\ninterface SettledChildV1 {\n\treadonly roleId: string;\n\treadonly definitionId: string;\n\treadonly childInstanceId: string;\n\treadonly revision: number;\n\treadonly status: RoleOrchestrationStatusV1;\n\treadonly output?: RoleRunnerResultV1;\n\treadonly error?: string;\n}\n\n/** Creates the root-side concurrent role orchestrator (2.2e). */\nexport function createRoleOrchestrator(options: RoleOrchestratorOptionsV1): RoleOrchestratorV1 {\n\tconst owner = options.owner ?? DEFAULT_ORCHESTRATION_OWNER;\n\t// Definitions are registered once per roleId and reused across runs: a\n\t// composition instance is single-run, so every orchestration creates fresh\n\t// child instances from the same definitions.\n\tconst definitions = new Map<string, AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1>>();\n\tlet activeOverrides: ReadonlyMap<string, RoleRunCallbackV1> = new Map();\n\tlet runInFlight = false;\n\n\tfunction requireMetadata(roleId: string): RoleMetadataV1 {\n\t\tconst metadata = options.runner.catalog.get(roleId);\n\t\tif (!metadata) throw new Error(t(\"Unknown role: {roleId}\", { roleId }));\n\t\treturn metadata;\n\t}\n\n\tfunction definitionFor(roleId: string): AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1> {\n\t\tconst cached = definitions.get(roleId);\n\t\tif (cached) return cached;\n\t\tconst base = options.runner.createDefinition(roleId);\n\t\tconst definition: AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1> = {\n\t\t\t...base,\n\t\t\trun: (input, context) => {\n\t\t\t\tconst override = activeOverrides.get(roleId);\n\t\t\t\treturn override ? override(input, context) : options.runner.run(roleId, input, context);\n\t\t\t},\n\t\t};\n\t\tconst registered = options.composition.define(definition);\n\t\tdefinitions.set(roleId, registered);\n\t\treturn registered;\n\t}\n\n\tasync function runOne(roleId: string, spec: string, settled: Map<string, SettledChildV1>): Promise<void> {\n\t\tconst definition = definitionFor(roleId);\n\t\tconst instance = options.composition.create<RoleRunnerInputV1, RoleRunnerResultV1>(\n\t\t\t{ id: definition.id, version: definition.version },\n\t\t\t{ parentInstanceId: options.parentInstanceId },\n\t\t);\n\t\tconst childInstanceId = instance.id;\n\t\tconst lease = await instance.acquireControllerLease(owner);\n\t\ttry {\n\t\t\tconst operation = instance.run({ spec }, { lease });\n\t\t\ttry {\n\t\t\t\tawait operation.result;\n\t\t\t} catch {\n\t\t\t\t// run() rejects on failure/cancellation mid-flight; instance.wait()\n\t\t\t\t// below yields the terminal status and error.\n\t\t\t}\n\t\t\tconst terminal = await instance.wait();\n\t\t\tconst error =\n\t\t\t\tterminal.error === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: terminal.error instanceof Error\n\t\t\t\t\t\t? terminal.error.message\n\t\t\t\t\t\t: String(terminal.error);\n\t\t\tsettled.set(roleId, {\n\t\t\t\troleId,\n\t\t\t\tdefinitionId: definition.id,\n\t\t\t\tchildInstanceId,\n\t\t\t\trevision: terminal.revision,\n\t\t\t\tstatus: terminal.status,\n\t\t\t\t...(terminal.output !== undefined ? { output: terminal.output } : {}),\n\t\t\t\t...(error !== undefined ? { error } : {}),\n\t\t\t});\n\t\t} finally {\n\t\t\tif (lease.isActive()) await lease.release();\n\t\t}\n\t}\n\n\tasync function runRoles(request: RoleOrchestratorRunRequestV1): Promise<RoleOrchestrationResultV1> {\n\t\tif (runInFlight) throw new Error(t(\"Role orchestrator is already running an orchestration\"));\n\t\t// Input validation fails explicitly before any child is spawned.\n\t\tconst seen = new Set<string>();\n\t\tfor (const roleId of request.roleIds) {\n\t\t\tif (typeof roleId !== \"string\" || roleId.trim().length === 0) {\n\t\t\t\tthrow new Error(t(\"Role id must be a non-empty string\"));\n\t\t\t}\n\t\t\tif (seen.has(roleId)) throw new Error(t(\"Duplicate roleId in orchestration request: {roleId}\", { roleId }));\n\t\t\tseen.add(roleId);\n\t\t}\n\t\tconst overrides = new Map<string, RoleRunCallbackV1>();\n\t\tfor (const override of request.runs ?? []) {\n\t\t\tif (overrides.has(override.roleId))\n\t\t\t\tthrow new Error(t(\"Duplicate run override for role: {roleId}\", { roleId: override.roleId }));\n\t\t\toverrides.set(override.roleId, override.run);\n\t\t}\n\t\tfor (const roleId of overrides.keys()) {\n\t\t\tif (!seen.has(roleId)) throw new Error(t(\"Run override for unrequested role: {roleId}\", { roleId }));\n\t\t}\n\t\t// Stable execution order: roleId-sorted, `parallel` roles concurrent,\n\t\t// `single` roles strictly sequential. Aggregation order is independent\n\t\t// of this execution order.\n\t\tconst sorted = [...request.roleIds].sort((left, right) => left.localeCompare(right));\n\t\tfor (const roleId of sorted) {\n\t\t\trequireMetadata(roleId);\n\t\t\tdefinitionFor(roleId);\n\t\t}\n\n\t\trunInFlight = true;\n\t\ttry {\n\t\t\tactiveOverrides = overrides;\n\t\t\tconst settled = new Map<string, SettledChildV1>();\n\t\t\tif (sorted.length > 0) {\n\t\t\t\tconst parallelIds = sorted.filter((roleId) => requireMetadata(roleId).concurrency === \"parallel\");\n\t\t\t\tconst singleIds = sorted.filter((roleId) => requireMetadata(roleId).concurrency === \"single\");\n\t\t\t\tawait Promise.all(parallelIds.map((roleId) => runOne(roleId, request.spec, settled)));\n\t\t\t\tfor (const roleId of singleIds) await runOne(roleId, request.spec, settled);\n\t\t\t}\n\t\t\treturn aggregate(sorted, settled, request);\n\t\t} finally {\n\t\t\tactiveOverrides = new Map();\n\t\t\trunInFlight = false;\n\t\t}\n\t}\n\n\tfunction aggregate(\n\t\tsorted: readonly string[],\n\t\tsettled: ReadonlyMap<string, SettledChildV1>,\n\t\trequest: RoleOrchestratorRunRequestV1,\n\t): RoleOrchestrationResultV1 {\n\t\tconst limitBytes = request.limitBytes ?? options.limitBytes ?? DEFAULT_ROLE_AGGREGATION_LIMIT_BYTES;\n\t\t// 6.3 budget semantics: a running byte total over roleId-sorted entries;\n\t\t// an entry that would exceed the budget is dropped whole (truncated),\n\t\t// never partially sliced — mirroring multi-agent-tasks aggregate().\n\t\tlet used = 0;\n\t\tlet truncated = false;\n\t\tconst frozenEntries = sorted.map((roleId): RoleOrchestrationEntryV1 => {\n\t\t\tconst outcome = settled.get(roleId);\n\t\t\tif (!outcome) throw new Error(t(\"Orchestration outcome missing for role: {roleId}\", { roleId }));\n\t\t\tconst base = {\n\t\t\t\troleId: outcome.roleId,\n\t\t\t\tdefinitionId: outcome.definitionId,\n\t\t\t\tchildInstanceId: outcome.childInstanceId,\n\t\t\t\trevision: outcome.revision,\n\t\t\t\tstatus: outcome.status,\n\t\t\t};\n\t\t\tif (outcome.status !== \"succeeded\" || outcome.output === undefined) {\n\t\t\t\treturn Object.freeze({\n\t\t\t\t\t...base,\n\t\t\t\t\ttruncated: false,\n\t\t\t\t\tmissing: true,\n\t\t\t\t\t...(outcome.error !== undefined ? { error: outcome.error } : {}),\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst size = JSON.stringify(outcome.output).length;\n\t\t\tif (used + size > limitBytes) {\n\t\t\t\ttruncated = true;\n\t\t\t\treturn Object.freeze({ ...base, truncated: true, missing: false });\n\t\t\t}\n\t\t\tused += size;\n\t\t\treturn Object.freeze({ ...base, truncated: false, missing: false, result: outcome.output });\n\t\t});\n\t\tconst entryByRole = new Map(frozenEntries.map((entry) => [entry.roleId, entry]));\n\t\tconst evaluate = request.evaluateCompletion ?? options.evaluateCompletion;\n\t\tconst frozenChecks = sorted.map((roleId): RoleCompletionCheckV1 => {\n\t\t\tconst criteria = requireMetadata(roleId).completionCriteria;\n\t\t\tconst outcome = settled.get(roleId);\n\t\t\tconst entry = entryByRole.get(roleId);\n\t\t\tconst output = outcome?.output;\n\t\t\t// No evaluator, no output, or an output dropped by the byte budget:\n\t\t\t// the criteria cannot be judged, which is reported as unchecked\n\t\t\t// instead of being silently treated as satisfied or unmet.\n\t\t\tif (!evaluate || !output || entry?.truncated === true) {\n\t\t\t\treturn Object.freeze({ roleId, criteria, status: \"unchecked\" as const });\n\t\t\t}\n\t\t\tconst verdict = evaluate({ roleId, criteria, result: output });\n\t\t\treturn Object.freeze({\n\t\t\t\troleId,\n\t\t\t\tcriteria,\n\t\t\t\tstatus:\n\t\t\t\t\tverdict === true\n\t\t\t\t\t\t? (\"satisfied\" as const)\n\t\t\t\t\t\t: verdict === false\n\t\t\t\t\t\t\t? (\"unmet\" as const)\n\t\t\t\t\t\t\t: (\"unchecked\" as const),\n\t\t\t});\n\t\t});\n\t\treturn Object.freeze({\n\t\t\tentries: Object.freeze(frozenEntries),\n\t\t\ttruncated,\n\t\t\tcompletionChecks: Object.freeze(frozenChecks),\n\t\t});\n\t}\n\n\treturn {\n\t\tcomposition: options.composition,\n\t\trunner: options.runner,\n\t\tparentInstanceId: options.parentInstanceId,\n\t\trunRoles,\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"role-runner.d.ts","sourceRoot":"","sources":["../../src/profile/role-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAC/F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,mBAAmB,CAAC;AAEvE,6EAA6E;AAC7E,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED,gFAAgF;AAChF,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC/B,KAAK,EAAE,iBAAiB,EACxB,OAAO,CAAC,EAAE,qBAAqB,KAC3B,kBAAkB,G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AAM,EAAE,qBAAqB,EAAE,SAAS,qBAAqB,EAAE,GAAG,qBAAqB,CAAC;IAClH,iFAAiF;IACjF,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC5G;AAQD,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,iBAAiB,EACxB,OAAO,CAAC,EAAE,qBAAqB,GAC7B,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAIlD;AAED,uEAAuE;AACvE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAoE3E","sourcesContent":["/**\n * Role runner binding (2.2d) — maps registered `RoleMetadataV1` roles to child\n * `AgentDefinition`s executable through the experimental `AgentCompositionAPI`.\n *\n * The default run implementation is the deterministic first-batch role\n * callbacks (architecture-analyst / implementer / test-designer, 2.2c); a\n * caller may inject a real implementation via `run`. This slice never calls a\n * model.\n *\n * Library-level use works without any guard. When used through the\n * capability-runtime guards (`src/core/extensions/capability-runtime-guards.ts`),\n * the produced definitions must be defined/created by a manifest that declares\n * the `child-agent-controller` role and the `owner` must equal that manifest\n * id — the guards enforce this at the plugin boundary; this contract does not\n * duplicate guard logic.\n *\n * Required capability dependencies are checked explicitly (2.5a structured\n * `missing` shape) before activation (create/lease); they are never silently\n * skipped. Domain role runtimes live INSIDE the composition's child role: the\n * root/child two-value role enum is unchanged by design.\n */\nimport type { AgentDefinition, AgentExecutionContext } from \"../core/extensions/public-api.ts\";\nimport type { AvailableCapabilityV1 } from \"./dependency-wiring.ts\";\nimport { FIRST_BATCH_ROLES } from \"./first-roles.ts\";\nimport type { RoleCatalogV1, RoleMetadataV1 } from \"./role-catalog.ts\";\n\n/** Deterministic role input: a single spec string (first-batch contract). */\nexport interface RoleRunnerInputV1 {\n\treadonly spec: string;\n}\n\n/** Deterministic role output: a single result string (first-batch contract). */\nexport interface RoleRunnerResultV1 {\n\treadonly result: string;\n}\n\n/**\n * Per-role run implementation. `context` is present when executed through\n * `AgentCompositionAPI`; direct deterministic execution may omit it.\n */\nexport type RoleRunCallbackV1 = (\n\tinput: RoleRunnerInputV1,\n\tcontext?: AgentExecutionContext,\n) => RoleRunnerResultV1 | Promise<RoleRunnerResultV1>;\n\n/** Runner-level run resolver; receives the roleId in addition to the callback arguments. */\nexport type RoleRunResolverV1 = (\n\troleId: string,\n\tinput: RoleRunnerInputV1,\n\tcontext?: AgentExecutionContext,\n) => RoleRunnerResultV1 | Promise<RoleRunnerResultV1>;\n\n/**\n * Role capability-dependency diagnostic: the 2.5a structured `missing` shape\n * (`capabilityId`/`requestedVersion`/`availableVersion?`/`reason`) with\n * `roleId` as the requester.\n */\nexport interface RoleMissingCapabilityV1 {\n\treadonly roleId: string;\n\treadonly capabilityId: string;\n\treadonly requestedVersion: number;\n\t/** Undefined when the capability is entirely absent from the registry. */\n\treadonly availableVersion?: number;\n\treadonly reason: \"missing\" | \"version_mismatch\";\n}\n\n/** Activation check result for one role's REQUIRED capability dependencies. */\nexport interface RoleCapabilityCheckV1 {\n\treadonly roleId: string;\n\treadonly status: \"satisfied\" | \"missing\";\n\t/** Required dependencies that are absent or version-mismatched; empty when satisfied. */\n\treadonly missing: readonly RoleMissingCapabilityV1[];\n}\n\nexport interface RoleRunnerOptionsV1 {\n\treadonly catalog: RoleCatalogV1;\n\t/**\n\t * Owner stamped onto produced child definitions. Required to equal the\n\t * declaring plugin manifest id when used behind the capability-runtime\n\t * guards; plain library use may omit it.\n\t */\n\treadonly owner?: string;\n\t/**\n\t * Injected run implementation replacing the deterministic first-batch\n\t * defaults entirely. Roles without any binding still fail explicitly on\n\t * execution.\n\t */\n\treadonly run?: RoleRunResolverV1;\n}\n\nexport interface RoleRunnerV1 {\n\treadonly catalog: RoleCatalogV1;\n\t/** Sorted registered roleIds. */\n\tlistRoleIds(): readonly string[];\n\t/**\n\t * Maps a registered role to a child agent definition (composition role\n\t * `child-agent-controller`, id `role:<roleId>`, version 1). Run the\n\t * capability check before creating/leasing an instance.\n\t */\n\tcreateDefinition(roleId: string): AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1>;\n\t/**\n\t * Pre-activation capability-dependency check against an exact-version\n\t * registry: a required dependency is satisfied only when the registry\n\t * offers the same capability id at exactly the requested version. Optional\n\t * dependencies never block activation and are not reported as missing.\n\t */\n\tcheckCapabilities(roleId: string, availableCapabilities: readonly AvailableCapabilityV1[]): RoleCapabilityCheckV1;\n\t/** Direct deterministic execution (the same run a produced definition binds). */\n\trun(roleId: string, input: RoleRunnerInputV1, context?: AgentExecutionContext): Promise<RoleRunnerResultV1>;\n}\n\nconst DEFINITION_VERSION = 1;\n\nconst FIRST_BATCH_RUNS = new Map<string, RoleRunCallbackV1>(\n\tFIRST_BATCH_ROLES.map((role) => [role.metadata.roleId, role.run]),\n);\n\n/** Default deterministic run dispatch: first-batch callbacks; explicit failure otherwise. */\nexport function runFirstBatchRole(\n\troleId: string,\n\tinput: RoleRunnerInputV1,\n\tcontext?: AgentExecutionContext,\n): RoleRunnerResultV1 | Promise<RoleRunnerResultV1> {\n\tconst callback = FIRST_BATCH_RUNS.get(roleId);\n\tif (!callback) throw new Error(`No run binding for role: ${roleId}`);\n\treturn callback(input, context);\n}\n\n/** Binds the catalog's registered roles to child agent definitions. */\nexport function createRoleRunner(options: RoleRunnerOptionsV1): RoleRunnerV1 {\n\tconst catalog = options.catalog;\n\n\tfunction requireRole(roleId: string): RoleMetadataV1 {\n\t\tconst metadata = catalog.get(roleId);\n\t\tif (!metadata) throw new Error(`Unknown role: ${roleId}`);\n\t\treturn metadata;\n\t}\n\n\tasync function execute(\n\t\troleId: string,\n\t\tinput: RoleRunnerInputV1,\n\t\tcontext?: AgentExecutionContext,\n\t): Promise<RoleRunnerResultV1> {\n\t\trequireRole(roleId);\n\t\tif (options.run) return options.run(roleId, input, context);\n\t\treturn runFirstBatchRole(roleId, input, context);\n\t}\n\n\treturn {\n\t\tcatalog,\n\t\tlistRoleIds() {\n\t\t\treturn catalog.list().map((role) => role.roleId);\n\t\t},\n\t\tcreateDefinition(roleId) {\n\t\t\tconst metadata = requireRole(roleId);\n\t\t\treturn {\n\t\t\t\tid: `role:${metadata.roleId}`,\n\t\t\t\tversion: DEFINITION_VERSION,\n\t\t\t\trole: \"child-agent-controller\",\n\t\t\t\t...(options.owner === undefined ? {} : { owner: options.owner }),\n\t\t\t\trun: (input, context) => execute(metadata.roleId, input, context),\n\t\t\t};\n\t\t},\n\t\tcheckCapabilities(roleId, availableCapabilities) {\n\t\t\tconst metadata = requireRole(roleId);\n\t\t\tconst registry = new Map(availableCapabilities.map((capability) => [capability.id, capability.version]));\n\t\t\tconst missing: RoleMissingCapabilityV1[] = [];\n\t\t\tfor (const dependency of metadata.capabilityDependencies) {\n\t\t\t\tif (!dependency.required) continue;\n\t\t\t\tconst availableVersion = registry.get(dependency.capabilityId);\n\t\t\t\tif (availableVersion === undefined) {\n\t\t\t\t\tmissing.push({\n\t\t\t\t\t\troleId,\n\t\t\t\t\t\tcapabilityId: dependency.capabilityId,\n\t\t\t\t\t\trequestedVersion: dependency.capabilityVersion,\n\t\t\t\t\t\treason: \"missing\",\n\t\t\t\t\t});\n\t\t\t\t} else if (availableVersion !== dependency.capabilityVersion) {\n\t\t\t\t\tmissing.push({\n\t\t\t\t\t\troleId,\n\t\t\t\t\t\tcapabilityId: dependency.capabilityId,\n\t\t\t\t\t\trequestedVersion: dependency.capabilityVersion,\n\t\t\t\t\t\tavailableVersion,\n\t\t\t\t\t\treason: \"version_mismatch\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\troleId,\n\t\t\t\tstatus: missing.length > 0 ? \"missing\" : \"satisfied\",\n\t\t\t\tmissing,\n\t\t\t};\n\t\t},\n\t\trun(roleId, input, context) {\n\t\t\treturn execute(roleId, input, context);\n\t\t},\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AC;IACxB,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;IACzC,yFAAyF;IACzF,QAAQ,CAAC,OAAO,EAAE,SAAS,uBAAuB,EAAE,CAAC;CACrD;AAED,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,iBAAiB,CAAC;CACjC;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,iCAAiC;IACjC,WAAW,IAAI,SAAS,MAAM,EAAE,CAAC;IACjC;;;;OAIG;IACH,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;IACzF;;;;;OAKG;IACH,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,qBAAqB,EAAE,SAAS,qBAAqB,EAAE,GAAG,qBAAqB,CAAC;IAClH,iFAAiF;IACjF,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC5G;AAQD,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,iBAAiB,EACxB,OAAO,CAAC,EAAE,qBAAqB,GAC7B,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAIlD;AAED,uEAAuE;AACvE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAoE3E","sourcesContent":["/**\n * Role runner binding (2.2d) — maps registered `RoleMetadataV1` roles to child\n * `AgentDefinition`s executable through the experimental `AgentCompositionAPI`.\n *\n * The default run implementation is the deterministic first-batch role\n * callbacks (architecture-analyst / implementer / test-designer, 2.2c); a\n * caller may inject a real implementation via `run`. This slice never calls a\n * model.\n *\n * Library-level use works without any guard. When used through the\n * capability-runtime guards (`src/core/extensions/capability-runtime-guards.ts`),\n * the produced definitions must be defined/created by a manifest that declares\n * the `child-agent-controller` role and the `owner` must equal that manifest\n * id — the guards enforce this at the plugin boundary; this contract does not\n * duplicate guard logic.\n *\n * Required capability dependencies are checked explicitly (2.5a structured\n * `missing` shape) before activation (create/lease); they are never silently\n * skipped. Domain role runtimes live INSIDE the composition's child role: the\n * root/child two-value role enum is unchanged by design.\n */\nimport type { AgentDefinition, AgentExecutionContext } from \"../core/extensions/public-api.ts\";\nimport { t } from \"../core/i18n/index.ts\";\nimport type { AvailableCapabilityV1 } from \"./dependency-wiring.ts\";\nimport { FIRST_BATCH_ROLES } from \"./first-roles.ts\";\nimport type { RoleCatalogV1, RoleMetadataV1 } from \"./role-catalog.ts\";\n\n/** Deterministic role input: a single spec string (first-batch contract). */\nexport interface RoleRunnerInputV1 {\n\treadonly spec: string;\n}\n\n/** Deterministic role output: a single result string (first-batch contract). */\nexport interface RoleRunnerResultV1 {\n\treadonly result: string;\n}\n\n/**\n * Per-role run implementation. `context` is present when executed through\n * `AgentCompositionAPI`; direct deterministic execution may omit it.\n */\nexport type RoleRunCallbackV1 = (\n\tinput: RoleRunnerInputV1,\n\tcontext?: AgentExecutionContext,\n) => RoleRunnerResultV1 | Promise<RoleRunnerResultV1>;\n\n/** Runner-level run resolver; receives the roleId in addition to the callback arguments. */\nexport type RoleRunResolverV1 = (\n\troleId: string,\n\tinput: RoleRunnerInputV1,\n\tcontext?: AgentExecutionContext,\n) => RoleRunnerResultV1 | Promise<RoleRunnerResultV1>;\n\n/**\n * Role capability-dependency diagnostic: the 2.5a structured `missing` shape\n * (`capabilityId`/`requestedVersion`/`availableVersion?`/`reason`) with\n * `roleId` as the requester.\n */\nexport interface RoleMissingCapabilityV1 {\n\treadonly roleId: string;\n\treadonly capabilityId: string;\n\treadonly requestedVersion: number;\n\t/** Undefined when the capability is entirely absent from the registry. */\n\treadonly availableVersion?: number;\n\treadonly reason: \"missing\" | \"version_mismatch\";\n}\n\n/** Activation check result for one role's REQUIRED capability dependencies. */\nexport interface RoleCapabilityCheckV1 {\n\treadonly roleId: string;\n\treadonly status: \"satisfied\" | \"missing\";\n\t/** Required dependencies that are absent or version-mismatched; empty when satisfied. */\n\treadonly missing: readonly RoleMissingCapabilityV1[];\n}\n\nexport interface RoleRunnerOptionsV1 {\n\treadonly catalog: RoleCatalogV1;\n\t/**\n\t * Owner stamped onto produced child definitions. Required to equal the\n\t * declaring plugin manifest id when used behind the capability-runtime\n\t * guards; plain library use may omit it.\n\t */\n\treadonly owner?: string;\n\t/**\n\t * Injected run implementation replacing the deterministic first-batch\n\t * defaults entirely. Roles without any binding still fail explicitly on\n\t * execution.\n\t */\n\treadonly run?: RoleRunResolverV1;\n}\n\nexport interface RoleRunnerV1 {\n\treadonly catalog: RoleCatalogV1;\n\t/** Sorted registered roleIds. */\n\tlistRoleIds(): readonly string[];\n\t/**\n\t * Maps a registered role to a child agent definition (composition role\n\t * `child-agent-controller`, id `role:<roleId>`, version 1). Run the\n\t * capability check before creating/leasing an instance.\n\t */\n\tcreateDefinition(roleId: string): AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1>;\n\t/**\n\t * Pre-activation capability-dependency check against an exact-version\n\t * registry: a required dependency is satisfied only when the registry\n\t * offers the same capability id at exactly the requested version. Optional\n\t * dependencies never block activation and are not reported as missing.\n\t */\n\tcheckCapabilities(roleId: string, availableCapabilities: readonly AvailableCapabilityV1[]): RoleCapabilityCheckV1;\n\t/** Direct deterministic execution (the same run a produced definition binds). */\n\trun(roleId: string, input: RoleRunnerInputV1, context?: AgentExecutionContext): Promise<RoleRunnerResultV1>;\n}\n\nconst DEFINITION_VERSION = 1;\n\nconst FIRST_BATCH_RUNS = new Map<string, RoleRunCallbackV1>(\n\tFIRST_BATCH_ROLES.map((role) => [role.metadata.roleId, role.run]),\n);\n\n/** Default deterministic run dispatch: first-batch callbacks; explicit failure otherwise. */\nexport function runFirstBatchRole(\n\troleId: string,\n\tinput: RoleRunnerInputV1,\n\tcontext?: AgentExecutionContext,\n): RoleRunnerResultV1 | Promise<RoleRunnerResultV1> {\n\tconst callback = FIRST_BATCH_RUNS.get(roleId);\n\tif (!callback) throw new Error(t(\"No run binding for role: {roleId}\", { roleId }));\n\treturn callback(input, context);\n}\n\n/** Binds the catalog's registered roles to child agent definitions. */\nexport function createRoleRunner(options: RoleRunnerOptionsV1): RoleRunnerV1 {\n\tconst catalog = options.catalog;\n\n\tfunction requireRole(roleId: string): RoleMetadataV1 {\n\t\tconst metadata = catalog.get(roleId);\n\t\tif (!metadata) throw new Error(t(\"Unknown role: {roleId}\", { roleId }));\n\t\treturn metadata;\n\t}\n\n\tasync function execute(\n\t\troleId: string,\n\t\tinput: RoleRunnerInputV1,\n\t\tcontext?: AgentExecutionContext,\n\t): Promise<RoleRunnerResultV1> {\n\t\trequireRole(roleId);\n\t\tif (options.run) return options.run(roleId, input, context);\n\t\treturn runFirstBatchRole(roleId, input, context);\n\t}\n\n\treturn {\n\t\tcatalog,\n\t\tlistRoleIds() {\n\t\t\treturn catalog.list().map((role) => role.roleId);\n\t\t},\n\t\tcreateDefinition(roleId) {\n\t\t\tconst metadata = requireRole(roleId);\n\t\t\treturn {\n\t\t\t\tid: `role:${metadata.roleId}`,\n\t\t\t\tversion: DEFINITION_VERSION,\n\t\t\t\trole: \"child-agent-controller\",\n\t\t\t\t...(options.owner === undefined ? {} : { owner: options.owner }),\n\t\t\t\trun: (input, context) => execute(metadata.roleId, input, context),\n\t\t\t};\n\t\t},\n\t\tcheckCapabilities(roleId, availableCapabilities) {\n\t\t\tconst metadata = requireRole(roleId);\n\t\t\tconst registry = new Map(availableCapabilities.map((capability) => [capability.id, capability.version]));\n\t\t\tconst missing: RoleMissingCapabilityV1[] = [];\n\t\t\tfor (const dependency of metadata.capabilityDependencies) {\n\t\t\t\tif (!dependency.required) continue;\n\t\t\t\tconst availableVersion = registry.get(dependency.capabilityId);\n\t\t\t\tif (availableVersion === undefined) {\n\t\t\t\t\tmissing.push({\n\t\t\t\t\t\troleId,\n\t\t\t\t\t\tcapabilityId: dependency.capabilityId,\n\t\t\t\t\t\trequestedVersion: dependency.capabilityVersion,\n\t\t\t\t\t\treason: \"missing\",\n\t\t\t\t\t});\n\t\t\t\t} else if (availableVersion !== dependency.capabilityVersion) {\n\t\t\t\t\tmissing.push({\n\t\t\t\t\t\troleId,\n\t\t\t\t\t\tcapabilityId: dependency.capabilityId,\n\t\t\t\t\t\trequestedVersion: dependency.capabilityVersion,\n\t\t\t\t\t\tavailableVersion,\n\t\t\t\t\t\treason: \"version_mismatch\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\troleId,\n\t\t\t\tstatus: missing.length > 0 ? \"missing\" : \"satisfied\",\n\t\t\t\tmissing,\n\t\t\t};\n\t\t},\n\t\trun(roleId, input, context) {\n\t\t\treturn execute(roleId, input, context);\n\t\t},\n\t};\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { t } from "../core/i18n/index.js";
1
2
  import { FIRST_BATCH_ROLES } from "./first-roles.js";
2
3
  const DEFINITION_VERSION = 1;
3
4
  const FIRST_BATCH_RUNS = new Map(FIRST_BATCH_ROLES.map((role) => [role.metadata.roleId, role.run]));
@@ -5,7 +6,7 @@ const FIRST_BATCH_RUNS = new Map(FIRST_BATCH_ROLES.map((role) => [role.metadata.
5
6
  export function runFirstBatchRole(roleId, input, context) {
6
7
  const callback = FIRST_BATCH_RUNS.get(roleId);
7
8
  if (!callback)
8
- throw new Error(`No run binding for role: ${roleId}`);
9
+ throw new Error(t("No run binding for role: {roleId}", { roleId }));
9
10
  return callback(input, context);
10
11
  }
11
12
  /** Binds the catalog's registered roles to child agent definitions. */
@@ -14,7 +15,7 @@ export function createRoleRunner(options) {
14
15
  function requireRole(roleId) {
15
16
  const metadata = catalog.get(roleId);
16
17
  if (!metadata)
17
- throw new Error(`Unknown role: ${roleId}`);
18
+ throw new Error(t("Unknown role: {roleId}", { roleId }));
18
19
  return metadata;
19
20
  }
20
21
  async function execute(roleId, input, context) {
@@ -1 +1 @@
1
- {"version":3,"file":"role-runner.js","sourceRoot":"","sources":["../../src/profile/role-runner.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAwFrD,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAC/B,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CACjE,CAAC;AAEF,6FAA6F;AAC7F,MAAM,UAAU,iBAAiB,CAChC,MAAc,EACd,KAAwB,EACxB,OAA+B,EACoB;IACnD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9C,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,MAAM,EAAE,CAAC,CAAC;IACrE,OAAO,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAAA,CAChC;AAED,uEAAuE;AACvE,MAAM,UAAU,gBAAgB,CAAC,OAA4B,EAAgB;IAC5E,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAEhC,SAAS,WAAW,CAAC,MAAc,EAAkB;QACpD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,MAAM,EAAE,CAAC,CAAC;QAC1D,OAAO,QAAQ,CAAC;IAAA,CAChB;IAED,KAAK,UAAU,OAAO,CACrB,MAAc,EACd,KAAwB,EACxB,OAA+B,EACD;QAC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AC,sBAAsB,EAAE,CAAC;gBAC1D,IAAI,CAAC,UAAU,CAAC,QAAQ;oBAAE,SAAS;gBACnC,MAAM,gBAAgB,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;gBAC/D,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;oBACpC,OAAO,CAAC,IAAI,CAAC;wBACZ,MAAM;wBACN,YAAY,EAAE,UAAU,CAAC,YAAY;wBACrC,gBAAgB,EAAE,UAAU,CAAC,iBAAiB;wBAC9C,MAAM,EAAE,SAAS;qBACjB,CAAC,CAAC;gBACJ,CAAC;qBAAM,IAAI,gBAAgB,KAAK,UAAU,CAAC,iBAAiB,EAAE,CAAC;oBAC9D,OAAO,CAAC,IAAI,CAAC;wBACZ,MAAM;wBACN,YAAY,EAAE,UAAU,CAAC,YAAY;wBACrC,gBAAgB,EAAE,UAAU,CAAC,iBAAiB;wBAC9C,gBAAgB;wBAChB,MAAM,EAAE,kBAAkB;qBAC1B,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;YACD,OAAO;gBACN,MAAM;gBACN,MAAM,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW;gBACpD,OAAO;aACP,CAAC;QAAA,CACF;QACD,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;YAC3B,OAAO,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAAA,CACvC;KACD,CAAC;AAAA,CACF","sourcesContent":["/**\n * Role runner binding (2.2d) — maps registered `RoleMetadataV1` roles to child\n * `AgentDefinition`s executable through the experimental `AgentCompositionAPI`.\n *\n * The default run implementation is the deterministic first-batch role\n * callbacks (architecture-analyst / implementer / test-designer, 2.2c); a\n * caller may inject a real implementation via `run`. This slice never calls a\n * model.\n *\n * Library-level use works without any guard. When used through the\n * capability-runtime guards (`src/core/extensions/capability-runtime-guards.ts`),\n * the produced definitions must be defined/created by a manifest that declares\n * the `child-agent-controller` role and the `owner` must equal that manifest\n * id — the guards enforce this at the plugin boundary; this contract does not\n * duplicate guard logic.\n *\n * Required capability dependencies are checked explicitly (2.5a structured\n * `missing` shape) before activation (create/lease); they are never silently\n * skipped. Domain role runtimes live INSIDE the composition's child role: the\n * root/child two-value role enum is unchanged by design.\n */\nimport type { AgentDefinition, AgentExecutionContext } from \"../core/extensions/public-api.ts\";\nimport type { AvailableCapabilityV1 } from \"./dependency-wiring.ts\";\nimport { FIRST_BATCH_ROLES } from \"./first-roles.ts\";\nimport type { RoleCatalogV1, RoleMetadataV1 } from \"./role-catalog.ts\";\n\n/** Deterministic role input: a single spec string (first-batch contract). */\nexport interface RoleRunnerInputV1 {\n\treadonly spec: string;\n}\n\n/** Deterministic role output: a single result string (first-batch contract). */\nexport interface RoleRunnerResultV1 {\n\treadonly result: string;\n}\n\n/**\n * Per-role run implementation. `context` is present when executed through\n * `AgentCompositionAPI`; direct deterministic execution may omit it.\n */\nexport type RoleRunCallbackV1 = (\n\tinput: RoleRunnerInputV1,\n\tcontext?: AgentExecutionContext,\n) => RoleRunnerResultV1 | Promise<RoleRunnerResultV1>;\n\n/** Runner-level run resolver; receives the roleId in addition to the callback arguments. */\nexport type RoleRunResolverV1 = (\n\troleId: string,\n\tinput: RoleRunnerInputV1,\n\tcontext?: AgentExecutionContext,\n) => RoleRunnerResultV1 | Promise<RoleRunnerResultV1>;\n\n/**\n * Role capability-dependency diagnostic: the 2.5a structured `missing` shape\n * (`capabilityId`/`requestedVersion`/`availableVersion?`/`reason`) with\n * `roleId` as the requester.\n */\nexport interface RoleMissingCapabilityV1 {\n\treadonly roleId: string;\n\treadonly capabilityId: string;\n\treadonly requestedVersion: number;\n\t/** Undefined when the capability is entirely absent from the registry. */\n\treadonly availableVersion?: number;\n\treadonly reason: \"missing\" | \"version_mismatch\";\n}\n\n/** Activation check result for one role's REQUIRED capability dependencies. */\nexport interface RoleCapabilityCheckV1 {\n\treadonly roleId: string;\n\treadonly status: \"satisfied\" | \"missing\";\n\t/** Required dependencies that are absent or version-mismatched; empty when satisfied. */\n\treadonly missing: readonly RoleMissingCapabilityV1[];\n}\n\nexport interface RoleRunnerOptionsV1 {\n\treadonly catalog: RoleCatalogV1;\n\t/**\n\t * Owner stamped onto produced child definitions. Required to equal the\n\t * declaring plugin manifest id when used behind the capability-runtime\n\t * guards; plain library use may omit it.\n\t */\n\treadonly owner?: string;\n\t/**\n\t * Injected run implementation replacing the deterministic first-batch\n\t * defaults entirely. Roles without any binding still fail explicitly on\n\t * execution.\n\t */\n\treadonly run?: RoleRunResolverV1;\n}\n\nexport interface RoleRunnerV1 {\n\treadonly catalog: RoleCatalogV1;\n\t/** Sorted registered roleIds. */\n\tlistRoleIds(): readonly string[];\n\t/**\n\t * Maps a registered role to a child agent definition (composition role\n\t * `child-agent-controller`, id `role:<roleId>`, version 1). Run the\n\t * capability check before creating/leasing an instance.\n\t */\n\tcreateDefinition(roleId: string): AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1>;\n\t/**\n\t * Pre-activation capability-dependency check against an exact-version\n\t * registry: a required dependency is satisfied only when the registry\n\t * offers the same capability id at exactly the requested version. Optional\n\t * dependencies never block activation and are not reported as missing.\n\t */\n\tcheckCapabilities(roleId: string, availableCapabilities: readonly AvailableCapabilityV1[]): RoleCapabilityCheckV1;\n\t/** Direct deterministic execution (the same run a produced definition binds). */\n\trun(roleId: string, input: RoleRunnerInputV1, context?: AgentExecutionContext): Promise<RoleRunnerResultV1>;\n}\n\nconst DEFINITION_VERSION = 1;\n\nconst FIRST_BATCH_RUNS = new Map<string, RoleRunCallbackV1>(\n\tFIRST_BATCH_ROLES.map((role) => [role.metadata.roleId, role.run]),\n);\n\n/** Default deterministic run dispatch: first-batch callbacks; explicit failure otherwise. */\nexport function runFirstBatchRole(\n\troleId: string,\n\tinput: RoleRunnerInputV1,\n\tcontext?: AgentExecutionContext,\n): RoleRunnerResultV1 | Promise<RoleRunnerResultV1> {\n\tconst callback = FIRST_BATCH_RUNS.get(roleId);\n\tif (!callback) throw new Error(`No run binding for role: ${roleId}`);\n\treturn callback(input, context);\n}\n\n/** Binds the catalog's registered roles to child agent definitions. */\nexport function createRoleRunner(options: RoleRunnerOptionsV1): RoleRunnerV1 {\n\tconst catalog = options.catalog;\n\n\tfunction requireRole(roleId: string): RoleMetadataV1 {\n\t\tconst metadata = catalog.get(roleId);\n\t\tif (!metadata) throw new Error(`Unknown role: ${roleId}`);\n\t\treturn metadata;\n\t}\n\n\tasync function execute(\n\t\troleId: string,\n\t\tinput: RoleRunnerInputV1,\n\t\tcontext?: AgentExecutionContext,\n\t): Promise<RoleRunnerResultV1> {\n\t\trequireRole(roleId);\n\t\tif (options.run) return options.run(roleId, input, context);\n\t\treturn runFirstBatchRole(roleId, input, context);\n\t}\n\n\treturn {\n\t\tcatalog,\n\t\tlistRoleIds() {\n\t\t\treturn catalog.list().map((role) => role.roleId);\n\t\t},\n\t\tcreateDefinition(roleId) {\n\t\t\tconst metadata = requireRole(roleId);\n\t\t\treturn {\n\t\t\t\tid: `role:${metadata.roleId}`,\n\t\t\t\tversion: DEFINITION_VERSION,\n\t\t\t\trole: \"child-agent-controller\",\n\t\t\t\t...(options.owner === undefined ? {} : { owner: options.owner }),\n\t\t\t\trun: (input, context) => execute(metadata.roleId, input, context),\n\t\t\t};\n\t\t},\n\t\tcheckCapabilities(roleId, availableCapabilities) {\n\t\t\tconst metadata = requireRole(roleId);\n\t\t\tconst registry = new Map(availableCapabilities.map((capability) => [capability.id, capability.version]));\n\t\t\tconst missing: RoleMissingCapabilityV1[] = [];\n\t\t\tfor (const dependency of metadata.capabilityDependencies) {\n\t\t\t\tif (!dependency.required) continue;\n\t\t\t\tconst availableVersion = registry.get(dependency.capabilityId);\n\t\t\t\tif (availableVersion === undefined) {\n\t\t\t\t\tmissing.push({\n\t\t\t\t\t\troleId,\n\t\t\t\t\t\tcapabilityId: dependency.capabilityId,\n\t\t\t\t\t\trequestedVersion: dependency.capabilityVersion,\n\t\t\t\t\t\treason: \"missing\",\n\t\t\t\t\t});\n\t\t\t\t} else if (availableVersion !== dependency.capabilityVersion) {\n\t\t\t\t\tmissing.push({\n\t\t\t\t\t\troleId,\n\t\t\t\t\t\tcapabilityId: dependency.capabilityId,\n\t\t\t\t\t\trequestedVersion: dependency.capabilityVersion,\n\t\t\t\t\t\tavailableVersion,\n\t\t\t\t\t\treason: \"version_mismatch\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\troleId,\n\t\t\t\tstatus: missing.length > 0 ? \"missing\" : \"satisfied\",\n\t\t\t\tmissing,\n\t\t\t};\n\t\t},\n\t\trun(roleId, input, context) {\n\t\t\treturn execute(roleId, input, context);\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"role-runner.js","sourceRoot":"","sources":["../../src/profile/role-runner.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,CAAC,EAAE,MAAM,uBAAuB,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAwFrD,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAC/B,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CACjE,CAAC;AAEF,6FAA6F;AAC7F,MAAM,UAAU,iBAAiB,CAChC,MAAc,EACd,KAAwB,EACxB,OAA+B,EACoB;IACnD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9C,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,mCAAmC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACnF,OAAO,QAAQ,CAAC,KAAK,EAAE,OAAO,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CAAC,WAAW;gBACpD,OAAO;aACP,CAAC;QAAA,CACF;QACD,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;YAC3B,OAAO,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAAA,CACvC;KACD,CAAC;AAAA,CACF","sourcesContent":["/**\n * Role runner binding (2.2d) — maps registered `RoleMetadataV1` roles to child\n * `AgentDefinition`s executable through the experimental `AgentCompositionAPI`.\n *\n * The default run implementation is the deterministic first-batch role\n * callbacks (architecture-analyst / implementer / test-designer, 2.2c); a\n * caller may inject a real implementation via `run`. This slice never calls a\n * model.\n *\n * Library-level use works without any guard. When used through the\n * capability-runtime guards (`src/core/extensions/capability-runtime-guards.ts`),\n * the produced definitions must be defined/created by a manifest that declares\n * the `child-agent-controller` role and the `owner` must equal that manifest\n * id — the guards enforce this at the plugin boundary; this contract does not\n * duplicate guard logic.\n *\n * Required capability dependencies are checked explicitly (2.5a structured\n * `missing` shape) before activation (create/lease); they are never silently\n * skipped. Domain role runtimes live INSIDE the composition's child role: the\n * root/child two-value role enum is unchanged by design.\n */\nimport type { AgentDefinition, AgentExecutionContext } from \"../core/extensions/public-api.ts\";\nimport { t } from \"../core/i18n/index.ts\";\nimport type { AvailableCapabilityV1 } from \"./dependency-wiring.ts\";\nimport { FIRST_BATCH_ROLES } from \"./first-roles.ts\";\nimport type { RoleCatalogV1, RoleMetadataV1 } from \"./role-catalog.ts\";\n\n/** Deterministic role input: a single spec string (first-batch contract). */\nexport interface RoleRunnerInputV1 {\n\treadonly spec: string;\n}\n\n/** Deterministic role output: a single result string (first-batch contract). */\nexport interface RoleRunnerResultV1 {\n\treadonly result: string;\n}\n\n/**\n * Per-role run implementation. `context` is present when executed through\n * `AgentCompositionAPI`; direct deterministic execution may omit it.\n */\nexport type RoleRunCallbackV1 = (\n\tinput: RoleRunnerInputV1,\n\tcontext?: AgentExecutionContext,\n) => RoleRunnerResultV1 | Promise<RoleRunnerResultV1>;\n\n/** Runner-level run resolver; receives the roleId in addition to the callback arguments. */\nexport type RoleRunResolverV1 = (\n\troleId: string,\n\tinput: RoleRunnerInputV1,\n\tcontext?: AgentExecutionContext,\n) => RoleRunnerResultV1 | Promise<RoleRunnerResultV1>;\n\n/**\n * Role capability-dependency diagnostic: the 2.5a structured `missing` shape\n * (`capabilityId`/`requestedVersion`/`availableVersion?`/`reason`) with\n * `roleId` as the requester.\n */\nexport interface RoleMissingCapabilityV1 {\n\treadonly roleId: string;\n\treadonly capabilityId: string;\n\treadonly requestedVersion: number;\n\t/** Undefined when the capability is entirely absent from the registry. */\n\treadonly availableVersion?: number;\n\treadonly reason: \"missing\" | \"version_mismatch\";\n}\n\n/** Activation check result for one role's REQUIRED capability dependencies. */\nexport interface RoleCapabilityCheckV1 {\n\treadonly roleId: string;\n\treadonly status: \"satisfied\" | \"missing\";\n\t/** Required dependencies that are absent or version-mismatched; empty when satisfied. */\n\treadonly missing: readonly RoleMissingCapabilityV1[];\n}\n\nexport interface RoleRunnerOptionsV1 {\n\treadonly catalog: RoleCatalogV1;\n\t/**\n\t * Owner stamped onto produced child definitions. Required to equal the\n\t * declaring plugin manifest id when used behind the capability-runtime\n\t * guards; plain library use may omit it.\n\t */\n\treadonly owner?: string;\n\t/**\n\t * Injected run implementation replacing the deterministic first-batch\n\t * defaults entirely. Roles without any binding still fail explicitly on\n\t * execution.\n\t */\n\treadonly run?: RoleRunResolverV1;\n}\n\nexport interface RoleRunnerV1 {\n\treadonly catalog: RoleCatalogV1;\n\t/** Sorted registered roleIds. */\n\tlistRoleIds(): readonly string[];\n\t/**\n\t * Maps a registered role to a child agent definition (composition role\n\t * `child-agent-controller`, id `role:<roleId>`, version 1). Run the\n\t * capability check before creating/leasing an instance.\n\t */\n\tcreateDefinition(roleId: string): AgentDefinition<RoleRunnerInputV1, RoleRunnerResultV1>;\n\t/**\n\t * Pre-activation capability-dependency check against an exact-version\n\t * registry: a required dependency is satisfied only when the registry\n\t * offers the same capability id at exactly the requested version. Optional\n\t * dependencies never block activation and are not reported as missing.\n\t */\n\tcheckCapabilities(roleId: string, availableCapabilities: readonly AvailableCapabilityV1[]): RoleCapabilityCheckV1;\n\t/** Direct deterministic execution (the same run a produced definition binds). */\n\trun(roleId: string, input: RoleRunnerInputV1, context?: AgentExecutionContext): Promise<RoleRunnerResultV1>;\n}\n\nconst DEFINITION_VERSION = 1;\n\nconst FIRST_BATCH_RUNS = new Map<string, RoleRunCallbackV1>(\n\tFIRST_BATCH_ROLES.map((role) => [role.metadata.roleId, role.run]),\n);\n\n/** Default deterministic run dispatch: first-batch callbacks; explicit failure otherwise. */\nexport function runFirstBatchRole(\n\troleId: string,\n\tinput: RoleRunnerInputV1,\n\tcontext?: AgentExecutionContext,\n): RoleRunnerResultV1 | Promise<RoleRunnerResultV1> {\n\tconst callback = FIRST_BATCH_RUNS.get(roleId);\n\tif (!callback) throw new Error(t(\"No run binding for role: {roleId}\", { roleId }));\n\treturn callback(input, context);\n}\n\n/** Binds the catalog's registered roles to child agent definitions. */\nexport function createRoleRunner(options: RoleRunnerOptionsV1): RoleRunnerV1 {\n\tconst catalog = options.catalog;\n\n\tfunction requireRole(roleId: string): RoleMetadataV1 {\n\t\tconst metadata = catalog.get(roleId);\n\t\tif (!metadata) throw new Error(t(\"Unknown role: {roleId}\", { roleId }));\n\t\treturn metadata;\n\t}\n\n\tasync function execute(\n\t\troleId: string,\n\t\tinput: RoleRunnerInputV1,\n\t\tcontext?: AgentExecutionContext,\n\t): Promise<RoleRunnerResultV1> {\n\t\trequireRole(roleId);\n\t\tif (options.run) return options.run(roleId, input, context);\n\t\treturn runFirstBatchRole(roleId, input, context);\n\t}\n\n\treturn {\n\t\tcatalog,\n\t\tlistRoleIds() {\n\t\t\treturn catalog.list().map((role) => role.roleId);\n\t\t},\n\t\tcreateDefinition(roleId) {\n\t\t\tconst metadata = requireRole(roleId);\n\t\t\treturn {\n\t\t\t\tid: `role:${metadata.roleId}`,\n\t\t\t\tversion: DEFINITION_VERSION,\n\t\t\t\trole: \"child-agent-controller\",\n\t\t\t\t...(options.owner === undefined ? {} : { owner: options.owner }),\n\t\t\t\trun: (input, context) => execute(metadata.roleId, input, context),\n\t\t\t};\n\t\t},\n\t\tcheckCapabilities(roleId, availableCapabilities) {\n\t\t\tconst metadata = requireRole(roleId);\n\t\t\tconst registry = new Map(availableCapabilities.map((capability) => [capability.id, capability.version]));\n\t\t\tconst missing: RoleMissingCapabilityV1[] = [];\n\t\t\tfor (const dependency of metadata.capabilityDependencies) {\n\t\t\t\tif (!dependency.required) continue;\n\t\t\t\tconst availableVersion = registry.get(dependency.capabilityId);\n\t\t\t\tif (availableVersion === undefined) {\n\t\t\t\t\tmissing.push({\n\t\t\t\t\t\troleId,\n\t\t\t\t\t\tcapabilityId: dependency.capabilityId,\n\t\t\t\t\t\trequestedVersion: dependency.capabilityVersion,\n\t\t\t\t\t\treason: \"missing\",\n\t\t\t\t\t});\n\t\t\t\t} else if (availableVersion !== dependency.capabilityVersion) {\n\t\t\t\t\tmissing.push({\n\t\t\t\t\t\troleId,\n\t\t\t\t\t\tcapabilityId: dependency.capabilityId,\n\t\t\t\t\t\trequestedVersion: dependency.capabilityVersion,\n\t\t\t\t\t\tavailableVersion,\n\t\t\t\t\t\treason: \"version_mismatch\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\troleId,\n\t\t\t\tstatus: missing.length > 0 ? \"missing\" : \"satisfied\",\n\t\t\t\tmissing,\n\t\t\t};\n\t\t},\n\t\trun(roleId, input, context) {\n\t\t\treturn execute(roleId, input, context);\n\t\t},\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"root-facade.d.ts","sourceRoot":"","sources":["../../src/profile/root-facade.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,MAAM,WAAW,2BAA2B,CAAC,OAAO;IACnD,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAC;IACnE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IACrE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,+FAAyF;IACzF,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAAC,CAAC;CACnH;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,EAAE,OAAO,EAAE;IACzE,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CACxG,GAAG,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CA4CrC","sourcesContent":["/**\n * Root-agent-controller facade adapter (2.1a).\n *\n * Proves the default root can be created and run through the public facade:\n * the adapter defines (or reuses) a `root-agent-controller` definition on the\n * composition and runs each turn on a fresh instance with the controller\n * lease acquired and released through the public API — no private main-loop\n * access. The TUI keeps its transitional path until 2.1c.\n */\nimport type { AgentCompositionAPI } from \"../core/extensions/public-api.ts\";\n\nexport interface RootAgentFacadeTurnResultV1<TResult> {\n\treadonly status: \"succeeded\" | \"failed\" | \"cancelled\" | \"disposed\";\n\treadonly output?: TResult;\n\treadonly revision: number;\n\treadonly error?: Error;\n\treadonly instanceId: string;\n\treadonly leaseId: string;\n}\n\nexport interface RootAgentFacadeV1<TInput = unknown, TResult = unknown> {\n\treadonly definitionId: string;\n\t/** Runs one minimal turn: create instance → acquire controller lease → run → release. */\n\trunTurn(input: TInput, options?: { readonly signal?: AbortSignal }): Promise<RootAgentFacadeTurnResultV1<TResult>>;\n}\n\nexport function createRootAgentFacade<TInput, TResult = unknown>(options: {\n\treadonly composition: AgentCompositionAPI;\n\treadonly rootDefinitionId?: string;\n\treadonly rootVersion?: number;\n\treadonly owner?: string;\n\t/** The root turn implementation (deterministic in tests). */\n\treadonly run: (input: TInput, context: { readonly signal?: AbortSignal }) => Promise<TResult> | TResult;\n}): RootAgentFacadeV1<TInput, TResult> {\n\tconst definitionId = options.rootDefinitionId ?? \"root-agent-controller\";\n\tconst owner = options.owner ?? \"root-facade\";\n\tconst definition = options.composition.define({\n\t\tid: definitionId,\n\t\tversion: options.rootVersion ?? 1,\n\t\trole: \"root-agent-controller\",\n\t\trun: (input: TInput, context: { readonly signal?: AbortSignal }) => options.run(input, context),\n\t});\n\tlet turnInFlight = false;\n\n\treturn {\n\t\tdefinitionId,\n\t\tasync runTurn(input, runOptions) {\n\t\t\t// Single-controller rule: one turn at a time per root facade.\n\t\t\tif (turnInFlight) {\n\t\t\t\tthrow new Error(\"Root facade is already running a turn\");\n\t\t\t}\n\t\t\tturnInFlight = true;\n\t\t\ttry {\n\t\t\t\t// A composition instance is single-run; every turn gets a fresh one.\n\t\t\t\tconst instance = options.composition.create<TInput, TResult>(definition);\n\t\t\t\tconst lease = await instance.acquireControllerLease(owner);\n\t\t\t\tconst leaseId = lease.id;\n\t\t\t\ttry {\n\t\t\t\t\tconst operation = instance.run(input, { lease, signal: runOptions?.signal });\n\t\t\t\t\tawait operation.result;\n\t\t\t\t\tconst instanceResult = await instance.wait();\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: instanceResult.status,\n\t\t\t\t\t\t...(instanceResult.output !== undefined ? { output: instanceResult.output } : {}),\n\t\t\t\t\t\t...(instanceResult.error instanceof Error ? { error: instanceResult.error } : {}),\n\t\t\t\t\t\trevision: instanceResult.revision,\n\t\t\t\t\t\tinstanceId: instance.id,\n\t\t\t\t\t\tleaseId,\n\t\t\t\t\t};\n\t\t\t\t} finally {\n\t\t\t\t\tif (lease.isActive()) await lease.release();\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tturnInFlight = false;\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"root-facade.d.ts","sourceRoot":"","sources":["../../src/profile/root-facade.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAG5E,MAAM,WAAW,2BAA2B,CAAC,OAAO;IACnD,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAC;IACnE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IACrE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,+FAAyF;IACzF,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAAC,CAAC;CACnH;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,EAAE,OAAO,EAAE;IACzE,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CACxG,GAAG,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CA4CrC","sourcesContent":["/**\n * Root-agent-controller facade adapter (2.1a).\n *\n * Proves the default root can be created and run through the public facade:\n * the adapter defines (or reuses) a `root-agent-controller` definition on the\n * composition and runs each turn on a fresh instance with the controller\n * lease acquired and released through the public API — no private main-loop\n * access. The TUI keeps its transitional path until 2.1c.\n */\nimport type { AgentCompositionAPI } from \"../core/extensions/public-api.ts\";\nimport { t } from \"../core/i18n/index.ts\";\n\nexport interface RootAgentFacadeTurnResultV1<TResult> {\n\treadonly status: \"succeeded\" | \"failed\" | \"cancelled\" | \"disposed\";\n\treadonly output?: TResult;\n\treadonly revision: number;\n\treadonly error?: Error;\n\treadonly instanceId: string;\n\treadonly leaseId: string;\n}\n\nexport interface RootAgentFacadeV1<TInput = unknown, TResult = unknown> {\n\treadonly definitionId: string;\n\t/** Runs one minimal turn: create instance → acquire controller lease → run → release. */\n\trunTurn(input: TInput, options?: { readonly signal?: AbortSignal }): Promise<RootAgentFacadeTurnResultV1<TResult>>;\n}\n\nexport function createRootAgentFacade<TInput, TResult = unknown>(options: {\n\treadonly composition: AgentCompositionAPI;\n\treadonly rootDefinitionId?: string;\n\treadonly rootVersion?: number;\n\treadonly owner?: string;\n\t/** The root turn implementation (deterministic in tests). */\n\treadonly run: (input: TInput, context: { readonly signal?: AbortSignal }) => Promise<TResult> | TResult;\n}): RootAgentFacadeV1<TInput, TResult> {\n\tconst definitionId = options.rootDefinitionId ?? \"root-agent-controller\";\n\tconst owner = options.owner ?? \"root-facade\";\n\tconst definition = options.composition.define({\n\t\tid: definitionId,\n\t\tversion: options.rootVersion ?? 1,\n\t\trole: \"root-agent-controller\",\n\t\trun: (input: TInput, context: { readonly signal?: AbortSignal }) => options.run(input, context),\n\t});\n\tlet turnInFlight = false;\n\n\treturn {\n\t\tdefinitionId,\n\t\tasync runTurn(input, runOptions) {\n\t\t\t// Single-controller rule: one turn at a time per root facade.\n\t\t\tif (turnInFlight) {\n\t\t\t\tthrow new Error(t(\"Root facade is already running a turn\"));\n\t\t\t}\n\t\t\tturnInFlight = true;\n\t\t\ttry {\n\t\t\t\t// A composition instance is single-run; every turn gets a fresh one.\n\t\t\t\tconst instance = options.composition.create<TInput, TResult>(definition);\n\t\t\t\tconst lease = await instance.acquireControllerLease(owner);\n\t\t\t\tconst leaseId = lease.id;\n\t\t\t\ttry {\n\t\t\t\t\tconst operation = instance.run(input, { lease, signal: runOptions?.signal });\n\t\t\t\t\tawait operation.result;\n\t\t\t\t\tconst instanceResult = await instance.wait();\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: instanceResult.status,\n\t\t\t\t\t\t...(instanceResult.output !== undefined ? { output: instanceResult.output } : {}),\n\t\t\t\t\t\t...(instanceResult.error instanceof Error ? { error: instanceResult.error } : {}),\n\t\t\t\t\t\trevision: instanceResult.revision,\n\t\t\t\t\t\tinstanceId: instance.id,\n\t\t\t\t\t\tleaseId,\n\t\t\t\t\t};\n\t\t\t\t} finally {\n\t\t\t\t\tif (lease.isActive()) await lease.release();\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tturnInFlight = false;\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { t } from "../core/i18n/index.js";
1
2
  export function createRootAgentFacade(options) {
2
3
  const definitionId = options.rootDefinitionId ?? "root-agent-controller";
3
4
  const owner = options.owner ?? "root-facade";
@@ -13,7 +14,7 @@ export function createRootAgentFacade(options) {
13
14
  async runTurn(input, runOptions) {
14
15
  // Single-controller rule: one turn at a time per root facade.
15
16
  if (turnInFlight) {
16
- throw new Error("Root facade is already running a turn");
17
+ throw new Error(t("Root facade is already running a turn"));
17
18
  }
18
19
  turnInFlight = true;
19
20
  try {