@cat-factory/server 0.6.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 (338) hide show
  1. package/LICENSE +21 -0
  2. package/dist/agents/CompositeAgentExecutor.d.ts +39 -0
  3. package/dist/agents/CompositeAgentExecutor.d.ts.map +1 -0
  4. package/dist/agents/CompositeAgentExecutor.js +169 -0
  5. package/dist/agents/CompositeAgentExecutor.js.map +1 -0
  6. package/dist/agents/ContainerAgentExecutor.d.ts +235 -0
  7. package/dist/agents/ContainerAgentExecutor.d.ts.map +1 -0
  8. package/dist/agents/ContainerAgentExecutor.js +825 -0
  9. package/dist/agents/ContainerAgentExecutor.js.map +1 -0
  10. package/dist/agents/ContainerRepoBootstrapper.d.ts +78 -0
  11. package/dist/agents/ContainerRepoBootstrapper.d.ts.map +1 -0
  12. package/dist/agents/ContainerRepoBootstrapper.js +279 -0
  13. package/dist/agents/ContainerRepoBootstrapper.js.map +1 -0
  14. package/dist/agents/ModelRouter.d.ts +69 -0
  15. package/dist/agents/ModelRouter.d.ts.map +1 -0
  16. package/dist/agents/ModelRouter.js +84 -0
  17. package/dist/agents/ModelRouter.js.map +1 -0
  18. package/dist/agents/RunnerJobClient.d.ts +41 -0
  19. package/dist/agents/RunnerJobClient.d.ts.map +1 -0
  20. package/dist/agents/RunnerJobClient.js +43 -0
  21. package/dist/agents/RunnerJobClient.js.map +1 -0
  22. package/dist/agents/modelProviderResolver.d.ts +33 -0
  23. package/dist/agents/modelProviderResolver.d.ts.map +1 -0
  24. package/dist/agents/modelProviderResolver.js +48 -0
  25. package/dist/agents/modelProviderResolver.js.map +1 -0
  26. package/dist/agents/providerCapabilities.d.ts +22 -0
  27. package/dist/agents/providerCapabilities.d.ts.map +1 -0
  28. package/dist/agents/providerCapabilities.js +43 -0
  29. package/dist/agents/providerCapabilities.js.map +1 -0
  30. package/dist/agents/resolveRepoTarget.d.ts +33 -0
  31. package/dist/agents/resolveRepoTarget.d.ts.map +1 -0
  32. package/dist/agents/resolveRepoTarget.js +81 -0
  33. package/dist/agents/resolveRepoTarget.js.map +1 -0
  34. package/dist/app.d.ts +12 -0
  35. package/dist/app.d.ts.map +1 -0
  36. package/dist/app.js +102 -0
  37. package/dist/app.js.map +1 -0
  38. package/dist/auth/GitHubOAuth.d.ts +39 -0
  39. package/dist/auth/GitHubOAuth.d.ts.map +1 -0
  40. package/dist/auth/GitHubOAuth.js +90 -0
  41. package/dist/auth/GitHubOAuth.js.map +1 -0
  42. package/dist/auth/GoogleOAuth.d.ts +35 -0
  43. package/dist/auth/GoogleOAuth.d.ts.map +1 -0
  44. package/dist/auth/GoogleOAuth.js +66 -0
  45. package/dist/auth/GoogleOAuth.js.map +1 -0
  46. package/dist/auth/middleware.d.ts +15 -0
  47. package/dist/auth/middleware.d.ts.map +1 -0
  48. package/dist/auth/middleware.js +63 -0
  49. package/dist/auth/middleware.js.map +1 -0
  50. package/dist/auth/signing.d.ts +50 -0
  51. package/dist/auth/signing.d.ts.map +1 -0
  52. package/dist/auth/signing.js +96 -0
  53. package/dist/auth/signing.js.map +1 -0
  54. package/dist/auth/wsTicket.d.ts +34 -0
  55. package/dist/auth/wsTicket.d.ts.map +1 -0
  56. package/dist/auth/wsTicket.js +50 -0
  57. package/dist/auth/wsTicket.js.map +1 -0
  58. package/dist/config/types.d.ts +294 -0
  59. package/dist/config/types.d.ts.map +1 -0
  60. package/dist/config/types.js +2 -0
  61. package/dist/config/types.js.map +1 -0
  62. package/dist/config/url-safety.d.ts +8 -0
  63. package/dist/config/url-safety.d.ts.map +1 -0
  64. package/dist/config/url-safety.js +11 -0
  65. package/dist/config/url-safety.js.map +1 -0
  66. package/dist/containers/ContainerSessionService.d.ts +67 -0
  67. package/dist/containers/ContainerSessionService.d.ts.map +1 -0
  68. package/dist/containers/ContainerSessionService.js +44 -0
  69. package/dist/containers/ContainerSessionService.js.map +1 -0
  70. package/dist/crypto/WebCryptoPasswordHasher.d.ts +9 -0
  71. package/dist/crypto/WebCryptoPasswordHasher.d.ts.map +1 -0
  72. package/dist/crypto/WebCryptoPasswordHasher.js +67 -0
  73. package/dist/crypto/WebCryptoPasswordHasher.js.map +1 -0
  74. package/dist/crypto/WebCryptoPersonalSecretCipher.d.ts +6 -0
  75. package/dist/crypto/WebCryptoPersonalSecretCipher.d.ts.map +1 -0
  76. package/dist/crypto/WebCryptoPersonalSecretCipher.js +57 -0
  77. package/dist/crypto/WebCryptoPersonalSecretCipher.js.map +1 -0
  78. package/dist/crypto/WebCryptoSecretCipher.d.ts +23 -0
  79. package/dist/crypto/WebCryptoSecretCipher.d.ts.map +1 -0
  80. package/dist/crypto/WebCryptoSecretCipher.js +60 -0
  81. package/dist/crypto/WebCryptoSecretCipher.js.map +1 -0
  82. package/dist/crypto/encoding.d.ts +14 -0
  83. package/dist/crypto/encoding.d.ts.map +1 -0
  84. package/dist/crypto/encoding.js +58 -0
  85. package/dist/crypto/encoding.js.map +1 -0
  86. package/dist/events/FanOutEventPublisher.d.ts +32 -0
  87. package/dist/events/FanOutEventPublisher.d.ts.map +1 -0
  88. package/dist/events/FanOutEventPublisher.js +76 -0
  89. package/dist/events/FanOutEventPublisher.js.map +1 -0
  90. package/dist/events/InAppNotificationChannel.d.ts +20 -0
  91. package/dist/events/InAppNotificationChannel.d.ts.map +1 -0
  92. package/dist/events/InAppNotificationChannel.js +23 -0
  93. package/dist/events/InAppNotificationChannel.js.map +1 -0
  94. package/dist/github/FetchGitHubClient.d.ts +72 -0
  95. package/dist/github/FetchGitHubClient.d.ts.map +1 -0
  96. package/dist/github/FetchGitHubClient.js +485 -0
  97. package/dist/github/FetchGitHubClient.js.map +1 -0
  98. package/dist/github/FetchGitHubProvisioningClient.d.ts +13 -0
  99. package/dist/github/FetchGitHubProvisioningClient.d.ts.map +1 -0
  100. package/dist/github/FetchGitHubProvisioningClient.js +59 -0
  101. package/dist/github/FetchGitHubProvisioningClient.js.map +1 -0
  102. package/dist/github/GitHubAppAuth.d.ts +30 -0
  103. package/dist/github/GitHubAppAuth.d.ts.map +1 -0
  104. package/dist/github/GitHubAppAuth.js +95 -0
  105. package/dist/github/GitHubAppAuth.js.map +1 -0
  106. package/dist/github/GitHubAppRegistry.d.ts +57 -0
  107. package/dist/github/GitHubAppRegistry.d.ts.map +1 -0
  108. package/dist/github/GitHubAppRegistry.js +51 -0
  109. package/dist/github/GitHubAppRegistry.js.map +1 -0
  110. package/dist/github/GitHubCiStatusProvider.d.ts +21 -0
  111. package/dist/github/GitHubCiStatusProvider.d.ts.map +1 -0
  112. package/dist/github/GitHubCiStatusProvider.js +39 -0
  113. package/dist/github/GitHubCiStatusProvider.js.map +1 -0
  114. package/dist/github/GitHubMergeabilityProvider.d.ts +26 -0
  115. package/dist/github/GitHubMergeabilityProvider.d.ts.map +1 -0
  116. package/dist/github/GitHubMergeabilityProvider.js +38 -0
  117. package/dist/github/GitHubMergeabilityProvider.js.map +1 -0
  118. package/dist/github/GitHubPullRequestMerger.d.ts +23 -0
  119. package/dist/github/GitHubPullRequestMerger.d.ts.map +1 -0
  120. package/dist/github/GitHubPullRequestMerger.js +38 -0
  121. package/dist/github/GitHubPullRequestMerger.js.map +1 -0
  122. package/dist/github/WebCryptoWebhookVerifier.d.ts +9 -0
  123. package/dist/github/WebCryptoWebhookVerifier.d.ts.map +1 -0
  124. package/dist/github/WebCryptoWebhookVerifier.js +40 -0
  125. package/dist/github/WebCryptoWebhookVerifier.js.map +1 -0
  126. package/dist/github/ensureWorkBranch.d.ts +26 -0
  127. package/dist/github/ensureWorkBranch.d.ts.map +1 -0
  128. package/dist/github/ensureWorkBranch.js +97 -0
  129. package/dist/github/ensureWorkBranch.js.map +1 -0
  130. package/dist/github/state.d.ts +19 -0
  131. package/dist/github/state.d.ts.map +1 -0
  132. package/dist/github/state.js +55 -0
  133. package/dist/github/state.js.map +1 -0
  134. package/dist/http/authGate.d.ts +21 -0
  135. package/dist/http/authGate.d.ts.map +1 -0
  136. package/dist/http/authGate.js +77 -0
  137. package/dist/http/authGate.js.map +1 -0
  138. package/dist/http/cors.d.ts +13 -0
  139. package/dist/http/cors.d.ts.map +1 -0
  140. package/dist/http/cors.js +30 -0
  141. package/dist/http/cors.js.map +1 -0
  142. package/dist/http/env.d.ts +68 -0
  143. package/dist/http/env.d.ts.map +1 -0
  144. package/dist/http/env.js +2 -0
  145. package/dist/http/env.js.map +1 -0
  146. package/dist/http/errorHandler.d.ts +4 -0
  147. package/dist/http/errorHandler.d.ts.map +1 -0
  148. package/dist/http/errorHandler.js +33 -0
  149. package/dist/http/errorHandler.js.map +1 -0
  150. package/dist/http/params.d.ts +8 -0
  151. package/dist/http/params.d.ts.map +1 -0
  152. package/dist/http/params.js +13 -0
  153. package/dist/http/params.js.map +1 -0
  154. package/dist/http/validation.d.ts +12 -0
  155. package/dist/http/validation.d.ts.map +1 -0
  156. package/dist/http/validation.js +21 -0
  157. package/dist/http/validation.js.map +1 -0
  158. package/dist/index.d.ts +46 -0
  159. package/dist/index.d.ts.map +1 -0
  160. package/dist/index.js +63 -0
  161. package/dist/index.js.map +1 -0
  162. package/dist/modules/accounts/AccountController.d.ts +10 -0
  163. package/dist/modules/accounts/AccountController.d.ts.map +1 -0
  164. package/dist/modules/accounts/AccountController.js +197 -0
  165. package/dist/modules/accounts/AccountController.js.map +1 -0
  166. package/dist/modules/agentRuns/AgentRunController.d.ts +10 -0
  167. package/dist/modules/agentRuns/AgentRunController.d.ts.map +1 -0
  168. package/dist/modules/agentRuns/AgentRunController.js +65 -0
  169. package/dist/modules/agentRuns/AgentRunController.js.map +1 -0
  170. package/dist/modules/auth/AuthController.d.ts +12 -0
  171. package/dist/modules/auth/AuthController.d.ts.map +1 -0
  172. package/dist/modules/auth/AuthController.js +457 -0
  173. package/dist/modules/auth/AuthController.js.map +1 -0
  174. package/dist/modules/board/BoardController.d.ts +8 -0
  175. package/dist/modules/board/BoardController.d.ts.map +1 -0
  176. package/dist/modules/board/BoardController.js +89 -0
  177. package/dist/modules/board/BoardController.js.map +1 -0
  178. package/dist/modules/boardScan/BoardScanController.d.ts +10 -0
  179. package/dist/modules/boardScan/BoardScanController.d.ts.map +1 -0
  180. package/dist/modules/boardScan/BoardScanController.js +53 -0
  181. package/dist/modules/boardScan/BoardScanController.js.map +1 -0
  182. package/dist/modules/bootstrap/BootstrapController.d.ts +10 -0
  183. package/dist/modules/bootstrap/BootstrapController.d.ts.map +1 -0
  184. package/dist/modules/bootstrap/BootstrapController.js +75 -0
  185. package/dist/modules/bootstrap/BootstrapController.js.map +1 -0
  186. package/dist/modules/clarity/ClarityReviewController.d.ts +11 -0
  187. package/dist/modules/clarity/ClarityReviewController.d.ts.map +1 -0
  188. package/dist/modules/clarity/ClarityReviewController.js +97 -0
  189. package/dist/modules/clarity/ClarityReviewController.js.map +1 -0
  190. package/dist/modules/consensus/ConsensusController.d.ts +12 -0
  191. package/dist/modules/consensus/ConsensusController.d.ts.map +1 -0
  192. package/dist/modules/consensus/ConsensusController.js +23 -0
  193. package/dist/modules/consensus/ConsensusController.js.map +1 -0
  194. package/dist/modules/documents/DocumentSourceController.d.ts +10 -0
  195. package/dist/modules/documents/DocumentSourceController.d.ts.map +1 -0
  196. package/dist/modules/documents/DocumentSourceController.js +116 -0
  197. package/dist/modules/documents/DocumentSourceController.js.map +1 -0
  198. package/dist/modules/environments/EnvironmentController.d.ts +10 -0
  199. package/dist/modules/environments/EnvironmentController.d.ts.map +1 -0
  200. package/dist/modules/environments/EnvironmentController.js +95 -0
  201. package/dist/modules/environments/EnvironmentController.js.map +1 -0
  202. package/dist/modules/events/EventsController.d.ts +26 -0
  203. package/dist/modules/events/EventsController.d.ts.map +1 -0
  204. package/dist/modules/events/EventsController.js +56 -0
  205. package/dist/modules/events/EventsController.js.map +1 -0
  206. package/dist/modules/execution/ExecutionController.d.ts +10 -0
  207. package/dist/modules/execution/ExecutionController.d.ts.map +1 -0
  208. package/dist/modules/execution/ExecutionController.js +156 -0
  209. package/dist/modules/execution/ExecutionController.js.map +1 -0
  210. package/dist/modules/fragmentLibrary/FragmentLibraryController.d.ts +14 -0
  211. package/dist/modules/fragmentLibrary/FragmentLibraryController.d.ts.map +1 -0
  212. package/dist/modules/fragmentLibrary/FragmentLibraryController.js +128 -0
  213. package/dist/modules/fragmentLibrary/FragmentLibraryController.js.map +1 -0
  214. package/dist/modules/github/GitHubController.d.ts +12 -0
  215. package/dist/modules/github/GitHubController.d.ts.map +1 -0
  216. package/dist/modules/github/GitHubController.js +234 -0
  217. package/dist/modules/github/GitHubController.js.map +1 -0
  218. package/dist/modules/github/GitHubWebhookController.d.ts +13 -0
  219. package/dist/modules/github/GitHubWebhookController.d.ts.map +1 -0
  220. package/dist/modules/github/GitHubWebhookController.js +74 -0
  221. package/dist/modules/github/GitHubWebhookController.js.map +1 -0
  222. package/dist/modules/llmProxy/LlmProxyController.d.ts +18 -0
  223. package/dist/modules/llmProxy/LlmProxyController.d.ts.map +1 -0
  224. package/dist/modules/llmProxy/LlmProxyController.js +567 -0
  225. package/dist/modules/llmProxy/LlmProxyController.js.map +1 -0
  226. package/dist/modules/localModels/LocalModelEndpointController.d.ts +4 -0
  227. package/dist/modules/localModels/LocalModelEndpointController.d.ts.map +1 -0
  228. package/dist/modules/localModels/LocalModelEndpointController.js +58 -0
  229. package/dist/modules/localModels/LocalModelEndpointController.js.map +1 -0
  230. package/dist/modules/merge/MergePresetController.d.ts +9 -0
  231. package/dist/modules/merge/MergePresetController.d.ts.map +1 -0
  232. package/dist/modules/merge/MergePresetController.js +46 -0
  233. package/dist/modules/merge/MergePresetController.js.map +1 -0
  234. package/dist/modules/modelDefaults/ModelDefaultsController.d.ts +9 -0
  235. package/dist/modules/modelDefaults/ModelDefaultsController.d.ts.map +1 -0
  236. package/dist/modules/modelDefaults/ModelDefaultsController.js +32 -0
  237. package/dist/modules/modelDefaults/ModelDefaultsController.js.map +1 -0
  238. package/dist/modules/models/ModelController.d.ts +11 -0
  239. package/dist/modules/models/ModelController.d.ts.map +1 -0
  240. package/dist/modules/models/ModelController.js +38 -0
  241. package/dist/modules/models/ModelController.js.map +1 -0
  242. package/dist/modules/notifications/NotificationController.d.ts +13 -0
  243. package/dist/modules/notifications/NotificationController.d.ts.map +1 -0
  244. package/dist/modules/notifications/NotificationController.js +67 -0
  245. package/dist/modules/notifications/NotificationController.js.map +1 -0
  246. package/dist/modules/pipelines/PipelineController.d.ts +5 -0
  247. package/dist/modules/pipelines/PipelineController.d.ts.map +1 -0
  248. package/dist/modules/pipelines/PipelineController.js +46 -0
  249. package/dist/modules/pipelines/PipelineController.js.map +1 -0
  250. package/dist/modules/promptFragments/PromptFragmentController.d.ts +11 -0
  251. package/dist/modules/promptFragments/PromptFragmentController.d.ts.map +1 -0
  252. package/dist/modules/promptFragments/PromptFragmentController.js +18 -0
  253. package/dist/modules/promptFragments/PromptFragmentController.js.map +1 -0
  254. package/dist/modules/providers/ApiKeyController.d.ts +13 -0
  255. package/dist/modules/providers/ApiKeyController.d.ts.map +1 -0
  256. package/dist/modules/providers/ApiKeyController.js +98 -0
  257. package/dist/modules/providers/ApiKeyController.js.map +1 -0
  258. package/dist/modules/providers/PersonalSubscriptionController.d.ts +4 -0
  259. package/dist/modules/providers/PersonalSubscriptionController.d.ts.map +1 -0
  260. package/dist/modules/providers/PersonalSubscriptionController.js +48 -0
  261. package/dist/modules/providers/PersonalSubscriptionController.js.map +1 -0
  262. package/dist/modules/providers/VendorCredentialController.d.ts +4 -0
  263. package/dist/modules/providers/VendorCredentialController.d.ts.map +1 -0
  264. package/dist/modules/providers/VendorCredentialController.js +55 -0
  265. package/dist/modules/providers/VendorCredentialController.js.map +1 -0
  266. package/dist/modules/providers/personalCredentialGate.d.ts +34 -0
  267. package/dist/modules/providers/personalCredentialGate.d.ts.map +1 -0
  268. package/dist/modules/providers/personalCredentialGate.js +106 -0
  269. package/dist/modules/providers/personalCredentialGate.js.map +1 -0
  270. package/dist/modules/recurring/RecurringPipelineController.d.ts +8 -0
  271. package/dist/modules/recurring/RecurringPipelineController.d.ts.map +1 -0
  272. package/dist/modules/recurring/RecurringPipelineController.js +58 -0
  273. package/dist/modules/recurring/RecurringPipelineController.js.map +1 -0
  274. package/dist/modules/recurring/TrackerSettingsController.d.ts +8 -0
  275. package/dist/modules/recurring/TrackerSettingsController.d.ts.map +1 -0
  276. package/dist/modules/recurring/TrackerSettingsController.js +30 -0
  277. package/dist/modules/recurring/TrackerSettingsController.js.map +1 -0
  278. package/dist/modules/releaseHealth/ReleaseHealthController.d.ts +9 -0
  279. package/dist/modules/releaseHealth/ReleaseHealthController.d.ts.map +1 -0
  280. package/dist/modules/releaseHealth/ReleaseHealthController.js +58 -0
  281. package/dist/modules/releaseHealth/ReleaseHealthController.js.map +1 -0
  282. package/dist/modules/requirements/RequirementReviewController.d.ts +12 -0
  283. package/dist/modules/requirements/RequirementReviewController.d.ts.map +1 -0
  284. package/dist/modules/requirements/RequirementReviewController.js +107 -0
  285. package/dist/modules/requirements/RequirementReviewController.js.map +1 -0
  286. package/dist/modules/runners/RunnerPoolController.d.ts +10 -0
  287. package/dist/modules/runners/RunnerPoolController.d.ts.map +1 -0
  288. package/dist/modules/runners/RunnerPoolController.js +52 -0
  289. package/dist/modules/runners/RunnerPoolController.js.map +1 -0
  290. package/dist/modules/serviceFragmentDefaults/ServiceFragmentDefaultsController.d.ts +9 -0
  291. package/dist/modules/serviceFragmentDefaults/ServiceFragmentDefaultsController.d.ts.map +1 -0
  292. package/dist/modules/serviceFragmentDefaults/ServiceFragmentDefaultsController.js +32 -0
  293. package/dist/modules/serviceFragmentDefaults/ServiceFragmentDefaultsController.js.map +1 -0
  294. package/dist/modules/services/ServiceMountController.d.ts +11 -0
  295. package/dist/modules/services/ServiceMountController.d.ts.map +1 -0
  296. package/dist/modules/services/ServiceMountController.js +64 -0
  297. package/dist/modules/services/ServiceMountController.js.map +1 -0
  298. package/dist/modules/settings/WorkspaceSettingsController.d.ts +9 -0
  299. package/dist/modules/settings/WorkspaceSettingsController.d.ts.map +1 -0
  300. package/dist/modules/settings/WorkspaceSettingsController.js +32 -0
  301. package/dist/modules/settings/WorkspaceSettingsController.js.map +1 -0
  302. package/dist/modules/slack/SlackController.d.ts +17 -0
  303. package/dist/modules/slack/SlackController.d.ts.map +1 -0
  304. package/dist/modules/slack/SlackController.js +135 -0
  305. package/dist/modules/slack/SlackController.js.map +1 -0
  306. package/dist/modules/tasks/TaskSourceController.d.ts +9 -0
  307. package/dist/modules/tasks/TaskSourceController.d.ts.map +1 -0
  308. package/dist/modules/tasks/TaskSourceController.js +103 -0
  309. package/dist/modules/tasks/TaskSourceController.js.map +1 -0
  310. package/dist/modules/webSearch/WebSearchProxyController.d.ts +4 -0
  311. package/dist/modules/webSearch/WebSearchProxyController.d.ts.map +1 -0
  312. package/dist/modules/webSearch/WebSearchProxyController.js +78 -0
  313. package/dist/modules/webSearch/WebSearchProxyController.js.map +1 -0
  314. package/dist/modules/webSearch/upstreams.d.ts +50 -0
  315. package/dist/modules/webSearch/upstreams.d.ts.map +1 -0
  316. package/dist/modules/webSearch/upstreams.js +107 -0
  317. package/dist/modules/webSearch/upstreams.js.map +1 -0
  318. package/dist/modules/workspaces/WorkspaceController.d.ts +5 -0
  319. package/dist/modules/workspaces/WorkspaceController.d.ts.map +1 -0
  320. package/dist/modules/workspaces/WorkspaceController.js +167 -0
  321. package/dist/modules/workspaces/WorkspaceController.js.map +1 -0
  322. package/dist/observability/logger.d.ts +9 -0
  323. package/dist/observability/logger.d.ts.map +1 -0
  324. package/dist/observability/logger.js +39 -0
  325. package/dist/observability/logger.js.map +1 -0
  326. package/dist/persistence/mappers.d.ts +101 -0
  327. package/dist/persistence/mappers.d.ts.map +1 -0
  328. package/dist/persistence/mappers.js +260 -0
  329. package/dist/persistence/mappers.js.map +1 -0
  330. package/dist/runtime/escalateNotifications.d.ts +12 -0
  331. package/dist/runtime/escalateNotifications.d.ts.map +1 -0
  332. package/dist/runtime/escalateNotifications.js +25 -0
  333. package/dist/runtime/escalateNotifications.js.map +1 -0
  334. package/dist/runtime/gateways.d.ts +159 -0
  335. package/dist/runtime/gateways.d.ts.map +1 -0
  336. package/dist/runtime/gateways.js +2 -0
  337. package/dist/runtime/gateways.js.map +1 -0
  338. package/package.json +44 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Igor Savin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,39 @@
1
+ import { type AgentExecutor, type AgentJobHandle, type AgentJobUpdate, type AgentRunContext, type AgentRunResult, type AsyncAgentExecutor } from '@cat-factory/kernel';
2
+ export declare class CompositeAgentExecutor implements AsyncAgentExecutor {
3
+ private readonly inline;
4
+ private readonly container;
5
+ constructor(inline: AgentExecutor, container: AgentExecutor | null);
6
+ /**
7
+ * The executor that handles a given step's kind. Container kinds REQUIRE a real
8
+ * sandbox: with none wired we throw rather than fall back to the inline executor,
9
+ * because a one-shot LLM call cannot operate on repo contents.
10
+ */
11
+ private pick;
12
+ run(context: AgentRunContext): Promise<AgentRunResult>;
13
+ /**
14
+ * Preview the model the step will run, forwarding to the executor that will
15
+ * handle its kind. Best-effort: returns undefined when the picked executor can't
16
+ * preview. `pick` throws for an unwired container kind — that real error surfaces
17
+ * at dispatch, so the engine treats this preview as optional and guards the call.
18
+ */
19
+ resolveModel(context: AgentRunContext): Promise<string | undefined>;
20
+ /**
21
+ * Whether the step runs on a flat-rate subscription (quota) model, forwarding to
22
+ * the executor that handles its kind (only the container executor runs subscription
23
+ * harnesses). Best-effort: an inline kind, an unwired container, or an executor
24
+ * without the capability all report false (budget-metered, the prior behaviour).
25
+ */
26
+ isQuotaBased(context: AgentRunContext): Promise<boolean>;
27
+ /** Async only for container kinds whose executor actually supports polling. */
28
+ runsAsync(context: AgentRunContext): boolean;
29
+ startJob(context: AgentRunContext): Promise<AgentJobHandle>;
30
+ pollJob(handle: AgentJobHandle): Promise<AgentJobUpdate>;
31
+ /**
32
+ * Best-effort container reclaim. The engine narrows the composite (not the inner
33
+ * container executor) when stopping a run, so the composite must forward stopJob
34
+ * to the container — otherwise the Layer-2 reclaim silently no-ops and leaks a
35
+ * warm instance. Delegates only when a container that supports it is wired.
36
+ */
37
+ stopJob(handle: AgentJobHandle): Promise<void>;
38
+ }
39
+ //# sourceMappingURL=CompositeAgentExecutor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompositeAgentExecutor.d.ts","sourceRoot":"","sources":["../../src/agents/CompositeAgentExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EAExB,MAAM,qBAAqB,CAAA;AAkF5B,qBAAa,sBAAuB,YAAW,kBAAkB;IAE7D,OAAO,CAAC,QAAQ,CAAC,MAAM;IAGvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAJ5B,YACmB,MAAM,EAAE,aAAa,EAGrB,SAAS,EAAE,aAAa,GAAG,IAAI,EAC9C;IAEJ;;;;OAIG;IACH,OAAO,CAAC,IAAI;IAmBZ,GAAG,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAErD;IAED;;;;;OAKG;IACH,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAGlE;IAED;;;;;OAKG;IACH,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAMvD;IAED,+EAA+E;IAC/E,SAAS,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAG3C;IAED,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAM1D;IAED,OAAO,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAMvD;IAED;;;;;OAKG;IACG,OAAO,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAInD;CACF"}
@@ -0,0 +1,169 @@
1
+ import { isAsyncAgentExecutor, } from '@cat-factory/kernel';
2
+ import { registeredKindRequiresContainer } from '@cat-factory/agents';
3
+ // Routes each pipeline step to the right executor by agent kind. The kinds that
4
+ // produce and commit files against a real checkout — implementation (`coder`),
5
+ // the external-dependency mock builder (`mocker`), the Playwright e2e test
6
+ // writer (`playwright`) and the business-logic documenter (`business-documenter`,
7
+ // which reads the implementation and commits domain-rules docs) — run in a real
8
+ // sandbox via the container executor. The `architect` also runs in a container, but
9
+ // read-only: it explores the repo before proposing (no commits, like `analysis`).
10
+ // Every other kind (reviewer and the other companions, tester, the
11
+ // `business-reviewer` that reports on a change, custom) stays on the inline LLM
12
+ // executor. This keeps container cost/latency to the phases that actually need a real
13
+ // workspace, while pure review/companion steps remain single-shot LLM calls.
14
+ //
15
+ // There is deliberately NO inline fallback for the container kinds: a one-shot
16
+ // LLM call cannot clone a repo, edit files, commit and open a PR, so routing an
17
+ // implementer step to the inline executor produces plausible-looking text that is
18
+ // silently useless. When no sandbox is wired (`container` is null), the container
19
+ // kinds throw instead — the run fails loudly rather than pretending to succeed.
20
+ //
21
+ // Runtime-neutral: both the Cloudflare Worker and the Node service wire this
22
+ // composite (inline `AiAgentExecutor` + a container executor backed by a
23
+ // per-run Cloudflare Container or an org's self-hosted runner pool).
24
+ /**
25
+ * Agent kinds that need a real checkout to operate on repo contents (clone,
26
+ * edit/commit files, open a PR) and so run in a container rather than inline:
27
+ * code implementation (`coder`), WireMock mock building (`mocker`), Playwright
28
+ * end-to-end test authoring (`playwright`) and business-logic documentation
29
+ * (`business-documenter`, which reads the code and commits the domain-rules docs).
30
+ */
31
+ const CONTAINER_KINDS = new Set([
32
+ 'coder',
33
+ 'mocker',
34
+ 'playwright',
35
+ 'business-documenter',
36
+ // The Blueprinter step clones the repo, regenerates the in-repo `blueprints/`
37
+ // folder and commits it — a real-checkout operation, so it runs in a container.
38
+ 'blueprints',
39
+ // The spec-writer clones (or creates) the implementation branch and commits the
40
+ // in-repo `spec/` folder onto it — a real-checkout operation, so it runs in a
41
+ // container. Like the blueprinter it returns a structured doc.
42
+ 'spec-writer',
43
+ // The architect explores the repository (read-only) before proposing a design, so
44
+ // it needs a real checkout. Like `analysis` it makes no edits — the harness produces
45
+ // no commit and opens no PR — and returns its proposal as prose `output`.
46
+ 'architect',
47
+ // The CI-fixer clones the PR head branch, runs the failing build/tests, fixes
48
+ // them and pushes back to the same branch — a real-checkout operation. (The `ci`
49
+ // step itself is NOT here: it is a special, non-agent gate handled in the engine
50
+ // that *dispatches* a `ci-fixer` job; only the fixer reaches this executor.)
51
+ 'ci-fixer',
52
+ // The conflict-resolver clones the PR head branch, merges the base in and resolves
53
+ // the conflicts on the same branch — a real-checkout operation. (The `conflicts`
54
+ // gate itself is NOT here: like `ci` it is a non-agent engine gate that *dispatches*
55
+ // a `conflict-resolver` job; only the resolver reaches this executor.)
56
+ 'conflict-resolver',
57
+ // The merger clones the PR head branch to assess the diff (complexity/risk/impact)
58
+ // before the engine decides whether to auto-merge — a real-checkout operation.
59
+ 'merger',
60
+ // The tech-debt `analysis` agent clones the repo to inspect it and emit a report.
61
+ // It is read-only (makes no edits) so the coding-agent harness produces no commit
62
+ // and opens no PR — but it still needs a real checkout, so it runs in a container.
63
+ 'analysis',
64
+ // The tester clones the PR branch, stands up infra (local docker-compose or an
65
+ // ephemeral env), runs the suite and returns a structured report — a real-checkout
66
+ // operation. (The `tester` step is also a special engine gate that loops a `fixer`
67
+ // on a withheld greenlight, mirroring `ci`/`ci-fixer`; the engine dispatches both
68
+ // jobs, which reach this executor.)
69
+ 'tester',
70
+ // The fixer clones the PR head branch, applies fixes from the Tester's report and
71
+ // pushes back to the same branch — a real-checkout operation, like `ci-fixer`.
72
+ 'fixer',
73
+ // The on-call agent clones the released PR head to correlate its diff with the
74
+ // Datadog regression evidence and returns a JSON assessment — a real-checkout
75
+ // operation (makes no commits). (The `post-release-health` gate itself is NOT here:
76
+ // like `ci` it is a non-agent engine gate that *dispatches* an `on-call` job; only
77
+ // the on-call agent reaches this executor.)
78
+ 'on-call',
79
+ ]);
80
+ export class CompositeAgentExecutor {
81
+ inline;
82
+ container;
83
+ constructor(inline,
84
+ // null when no sandbox is wired — container kinds then fail loudly (see below)
85
+ // rather than silently degrading to a useless one-shot inline call.
86
+ container) {
87
+ this.inline = inline;
88
+ this.container = container;
89
+ }
90
+ /**
91
+ * The executor that handles a given step's kind. Container kinds REQUIRE a real
92
+ * sandbox: with none wired we throw rather than fall back to the inline executor,
93
+ * because a one-shot LLM call cannot operate on repo contents.
94
+ */
95
+ pick(context) {
96
+ // Built-in container kinds, plus any custom kind a deployment registered with
97
+ // `requiresContainer: true` (e.g. a proprietary org package contributing a
98
+ // repo-operating agent), need a real checkout; everything else runs inline.
99
+ const needsContainer = CONTAINER_KINDS.has(context.agentKind) || registeredKindRequiresContainer(context.agentKind);
100
+ if (!needsContainer)
101
+ return this.inline;
102
+ if (!this.container) {
103
+ throw new Error(`Agent kind '${context.agentKind}' needs a real checkout (clone/edit/commit/PR) ` +
104
+ 'and cannot run as a one-shot LLM call. Its sandbox prerequisites must be wired: ' +
105
+ 'a runner backend (the EXEC_CONTAINER binding on the Worker, or a registered ' +
106
+ 'runner pool with RUNNERS_ENABLED), plus the GitHub App, the public proxy URL ' +
107
+ 'and AUTH_SESSION_SECRET.');
108
+ }
109
+ return this.container;
110
+ }
111
+ run(context) {
112
+ return this.pick(context).run(context);
113
+ }
114
+ /**
115
+ * Preview the model the step will run, forwarding to the executor that will
116
+ * handle its kind. Best-effort: returns undefined when the picked executor can't
117
+ * preview. `pick` throws for an unwired container kind — that real error surfaces
118
+ * at dispatch, so the engine treats this preview as optional and guards the call.
119
+ */
120
+ resolveModel(context) {
121
+ const executor = this.pick(context);
122
+ return executor.resolveModel?.(context) ?? Promise.resolve(undefined);
123
+ }
124
+ /**
125
+ * Whether the step runs on a flat-rate subscription (quota) model, forwarding to
126
+ * the executor that handles its kind (only the container executor runs subscription
127
+ * harnesses). Best-effort: an inline kind, an unwired container, or an executor
128
+ * without the capability all report false (budget-metered, the prior behaviour).
129
+ */
130
+ isQuotaBased(context) {
131
+ if (!this.container)
132
+ return Promise.resolve(false);
133
+ const needsContainer = CONTAINER_KINDS.has(context.agentKind) || registeredKindRequiresContainer(context.agentKind);
134
+ if (!needsContainer)
135
+ return Promise.resolve(false);
136
+ return this.container.isQuotaBased?.(context) ?? Promise.resolve(false);
137
+ }
138
+ /** Async only for container kinds whose executor actually supports polling. */
139
+ runsAsync(context) {
140
+ const executor = this.pick(context);
141
+ return isAsyncAgentExecutor(executor) && executor.runsAsync(context);
142
+ }
143
+ startJob(context) {
144
+ const executor = this.pick(context);
145
+ if (!isAsyncAgentExecutor(executor)) {
146
+ throw new Error(`No async executor for agent kind '${context.agentKind}'`);
147
+ }
148
+ return executor.startJob(context);
149
+ }
150
+ pollJob(handle) {
151
+ // Only the container executor runs async jobs, so polls route there.
152
+ if (!this.container || !isAsyncAgentExecutor(this.container)) {
153
+ throw new Error('Container executor does not support async jobs');
154
+ }
155
+ return this.container.pollJob(handle);
156
+ }
157
+ /**
158
+ * Best-effort container reclaim. The engine narrows the composite (not the inner
159
+ * container executor) when stopping a run, so the composite must forward stopJob
160
+ * to the container — otherwise the Layer-2 reclaim silently no-ops and leaks a
161
+ * warm instance. Delegates only when a container that supports it is wired.
162
+ */
163
+ async stopJob(handle) {
164
+ if (this.container && isAsyncAgentExecutor(this.container) && this.container.stopJob) {
165
+ await this.container.stopJob(handle);
166
+ }
167
+ }
168
+ }
169
+ //# sourceMappingURL=CompositeAgentExecutor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompositeAgentExecutor.js","sourceRoot":"","sources":["../../src/agents/CompositeAgentExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,oBAAoB,GACrB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAA;AAErE,gFAAgF;AAChF,+EAA+E;AAC/E,2EAA2E;AAC3E,kFAAkF;AAClF,gFAAgF;AAChF,oFAAoF;AACpF,kFAAkF;AAClF,mEAAmE;AACnE,gFAAgF;AAChF,sFAAsF;AACtF,6EAA6E;AAC7E,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,kFAAkF;AAClF,kFAAkF;AAClF,gFAAgF;AAChF,EAAE;AACF,6EAA6E;AAC7E,yEAAyE;AACzE,qEAAqE;AAErE;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,OAAO;IACP,QAAQ;IACR,YAAY;IACZ,qBAAqB;IACrB,8EAA8E;IAC9E,gFAAgF;IAChF,YAAY;IACZ,gFAAgF;IAChF,8EAA8E;IAC9E,+DAA+D;IAC/D,aAAa;IACb,kFAAkF;IAClF,qFAAqF;IACrF,0EAA0E;IAC1E,WAAW;IACX,8EAA8E;IAC9E,iFAAiF;IACjF,iFAAiF;IACjF,6EAA6E;IAC7E,UAAU;IAC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AAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7D,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAA;QACnE,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACvC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAO,CAAC,MAAsB;QAClC,IAAI,IAAI,CAAC,SAAS,IAAI,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;YACrF,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACtC,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,235 @@
1
+ import { type AgentJobHandle, type AgentJobUpdate, type AgentRunContext, type AgentRunResult, type AsyncAgentExecutor, type LlmTraceSink, type ModelRef, type SubscriptionVendor } from '@cat-factory/kernel';
2
+ import { type AgentRouting } from '@cat-factory/agents';
3
+ import type { ContainerSessionService } from '../containers/ContainerSessionService.js';
4
+ import { type ResolveRunnerTransport } from './RunnerJobClient.js';
5
+ export type { ResolveRunnerTransport };
6
+ export interface RepoTarget {
7
+ installationId: number;
8
+ owner: string;
9
+ name: string;
10
+ baseBranch: string;
11
+ /**
12
+ * For a service in a monorepo, the subdirectory (relative to the repo root) the
13
+ * service lives in, e.g. `packages/api`. Present only when the resolved repo is
14
+ * flagged a monorepo AND the service pins a directory; the harness then runs the
15
+ * agent within that subtree and tells it so. Absent ⇒ whole-repo behaviour.
16
+ */
17
+ serviceDirectory?: string;
18
+ }
19
+ export type ResolveRepoTarget = (workspaceId: string, blockId: string) => Promise<RepoTarget | null>;
20
+ export type MintInstallationToken = (installationId: number) => Promise<string>;
21
+ /**
22
+ * Ensure the per-task work branch exists on the remote, so every agent in the pipeline
23
+ * operates on the SAME branch. Returns whether the branch is present afterwards; a
24
+ * `false`/absent result makes read-only agents fall back to the base branch (writers
25
+ * create-or-resume the branch in their harness regardless). `options.create` is `true`
26
+ * for writers (create from base when absent) and `false` for read-only agents (probe
27
+ * only — never create, since a missing branch means there is nothing yet to read).
28
+ */
29
+ export type EnsureWorkBranch = (repo: RepoTarget, branch: string, options: {
30
+ create: boolean;
31
+ }) => Promise<boolean>;
32
+ /** A subscription token leased from the workspace's pool for a vendor. */
33
+ export interface LeasedSubscriptionToken {
34
+ tokenId: string;
35
+ secret: string;
36
+ }
37
+ /** Lease the least-loaded subscription token for a vendor, or throw if none. */
38
+ export type LeaseSubscriptionToken = (workspaceId: string, vendor: SubscriptionVendor) => Promise<LeasedSubscriptionToken>;
39
+ /**
40
+ * Lease the run-initiator's OWN activated personal credential for an individual-usage
41
+ * vendor (Claude). Scoped to the run + user (not pooled); throws a
42
+ * `CredentialRequiredError` when the run has no live activation (the user must re-enter
43
+ * their password). Returns just the raw secret — no token id, since there is no pool
44
+ * rotation/usage to attribute for a single-user credential.
45
+ */
46
+ export type LeasePersonalSubscriptionToken = (executionId: string, userId: string, vendor: SubscriptionVendor) => Promise<{
47
+ secret: string;
48
+ }>;
49
+ /** Fold a finished subscription job's usage into the leased token + telemetry. */
50
+ export type RecordSubscriptionUsage = (workspaceId: string, tokenId: string, usage: {
51
+ inputTokens: number;
52
+ outputTokens: number;
53
+ }) => Promise<void>;
54
+ export interface ContainerAgentExecutorDependencies {
55
+ /** Resolve which runner backend (Cloudflare container or self-hosted pool) a job runs on. */
56
+ resolveTransport: ResolveRunnerTransport;
57
+ /** Default model routing; used when the block pins no (usable) model. */
58
+ agentRouting: AgentRouting;
59
+ /** Resolve a block's selected model id to a concrete ref (direct flavour). */
60
+ resolveBlockModel: (modelId: string | undefined) => ModelRef | undefined;
61
+ /**
62
+ * Resolve the workspace's per-agent-kind default model id, consulted when the
63
+ * block pins no model. Optional: absent → the env routing for the kind is used.
64
+ */
65
+ resolveWorkspaceModelDefault?: (workspaceId: string, agentKind: string) => Promise<string | undefined>;
66
+ /** Resolve which repo (and installation) a run targets. */
67
+ resolveRepoTarget: ResolveRepoTarget;
68
+ /**
69
+ * Resolve a workspace's owning account id, signed into the proxy session token so the
70
+ * proxy can lease an account-scoped API key from the merged pool. Optional; absent ⇒
71
+ * only the workspace + initiator scopes are leased.
72
+ */
73
+ resolveAccountId?: (workspaceId: string) => Promise<string | null | undefined>;
74
+ /** Mint a short-lived GitHub installation token for cloning + opening the PR. */
75
+ mintInstallationToken: MintInstallationToken;
76
+ /**
77
+ * Create the shared per-task work branch up front so every agent — including the
78
+ * read-only design agents — operates on the same branch. Optional: absent (tests, no
79
+ * GitHub) ⇒ read-only agents clone the base branch, the prior behaviour.
80
+ */
81
+ ensureWorkBranch?: EnsureWorkBranch;
82
+ /** Mints the signed LLM-proxy session token the container uses (Pi harness). */
83
+ sessionService: ContainerSessionService;
84
+ /**
85
+ * Lease a pooled subscription token for a vendor. Required for the Claude Code /
86
+ * Codex subscription harnesses; absent ⇒ those harnesses are unavailable and a
87
+ * subscription-only model fails loudly at dispatch.
88
+ */
89
+ leaseSubscriptionToken?: LeaseSubscriptionToken;
90
+ /**
91
+ * Lease the run-initiator's personal (individual-usage) credential for a vendor like
92
+ * Claude. Required to run an individual-usage model; absent ⇒ such models fail loudly
93
+ * at dispatch (the per-user personal store isn't wired on this deployment).
94
+ */
95
+ leasePersonalSubscriptionToken?: LeasePersonalSubscriptionToken;
96
+ /** Attribute a finished subscription job's usage to its leased token (usage-aware rotation). */
97
+ recordSubscriptionUsage?: RecordSubscriptionUsage;
98
+ /**
99
+ * Whether the workspace has a pooled token for a vendor. Drives "subscriptions
100
+ * always win" for POOLABLE vendors: a step pinned to a dual-mode model (Kimi/DeepSeek
101
+ * with a Cloudflare base) is auto-routed to its subscription flavour when this returns
102
+ * true.
103
+ */
104
+ hasSubscriptionToken?: (workspaceId: string, vendor: SubscriptionVendor) => Promise<boolean>;
105
+ /**
106
+ * Whether the run-initiator has their OWN personal subscription for an INDIVIDUAL-usage
107
+ * vendor. Individual vendors (e.g. GLM) are never pooled, so a dual-mode individual
108
+ * model is auto-routed to the user's personal subscription when this returns true, and
109
+ * otherwise stays on its Cloudflare base — so a subscriber runs GLM on their plan while
110
+ * a non-subscriber on the same workspace falls back to Cloudflare GLM.
111
+ */
112
+ hasPersonalSubscription?: (userId: string, vendor: SubscriptionVendor) => Promise<boolean>;
113
+ /**
114
+ * Public base URL of the facade's OpenAI-compatible LLM proxy, including the
115
+ * `/v1` suffix — Pi posts to `${proxyBaseUrl}/chat/completions`.
116
+ */
117
+ proxyBaseUrl: string;
118
+ /** GitHub REST base for opening the PR (GitHub Enterprise / api.github.com). */
119
+ githubApiBase?: string;
120
+ /**
121
+ * Whether the facade wired a container web-search upstream (the `/v1/web-search`
122
+ * proxy). When true, coding/ci-fixer jobs are told to point Pi's `web_search` tool
123
+ * at `${proxyBaseUrl}/web-search` with their session token — so no provider key
124
+ * reaches the sandbox. Off ⇒ container web search stays disabled.
125
+ */
126
+ webSearchProxyEnabled?: boolean;
127
+ /**
128
+ * Optional observability trace sink (e.g. Langfuse). When wired, each poll forwards
129
+ * the container's drained tool spans as child spans under the run's trace — the same
130
+ * sink the LLM proxy fans generations out to, so the trace tree is complete.
131
+ * Best-effort and isolated: a sink failure never affects the job lifecycle.
132
+ */
133
+ llmTraceSink?: LlmTraceSink;
134
+ }
135
+ /**
136
+ * An {@link AgentExecutor} that performs implementation work in a real sandbox:
137
+ * it dispatches a per-run container running the Pi coding agent (a per-run
138
+ * Cloudflare Container, or an org's self-hosted runner pool), feeds it the block's
139
+ * composed prompt fragments as context, and has it clone the repo, implement the
140
+ * block, push a branch and open a PR.
141
+ *
142
+ * Secrets never reach the container image. Provider keys stay in the backend; the
143
+ * container reaches models only through the facade's LLM proxy using a
144
+ * short-lived, model-locked session token, and clones/pushes with a short-lived
145
+ * GitHub installation token — both handed over per job. Token usage is metered
146
+ * by the proxy (the single metering point), so this executor reports no `usage`
147
+ * to avoid double-counting in the execution engine.
148
+ */
149
+ export declare class ContainerAgentExecutor implements AsyncAgentExecutor {
150
+ private readonly deps;
151
+ /** Shared backend-polymorphic dispatch/poll/release plumbing (see RunnerJobClient). */
152
+ private readonly jobs;
153
+ /**
154
+ * Job ids whose subscription usage has already been folded into the leased token.
155
+ * `recordSubscriptionUsage` is additive, and the durable driver polls a finished
156
+ * job inside a retriable step — so a poll that records usage and then throws (or
157
+ * whose surrounding upsert/emit throws) would replay and double-count, unfairly
158
+ * penalising the token in the usage-aware rotation. Recording once per job id
159
+ * guards that. Best-effort + bounded: cleared wholesale past a cap, and it cannot
160
+ * survive a cold isolate replay — a re-record there is the documented, benign
161
+ * worst case (one extra job's tokens on one row), never silent over-counting.
162
+ */
163
+ private readonly recordedUsageJobs;
164
+ /** Resolves which model + subscription path a step runs on (routing policy). */
165
+ private readonly modelRouter;
166
+ constructor(deps: ContainerAgentExecutorDependencies);
167
+ /** Repo-operating steps always run as polled async jobs (the coding can be long). */
168
+ runsAsync(_context: AgentRunContext): boolean;
169
+ /**
170
+ * Dispatch the implementation job to this run's container and return a handle.
171
+ * Returns as soon as the job is accepted — the work continues in the container,
172
+ * polled via {@link pollJob}. Idempotent: the harness re-attaches to a job
173
+ * already running for `executionId`, so a replayed dispatch never duplicates work.
174
+ */
175
+ startJob(context: AgentRunContext): Promise<AgentJobHandle>;
176
+ /** Poll a dispatched job for its state, mapping the runner view into an update. */
177
+ pollJob(handle: AgentJobHandle): Promise<AgentJobUpdate>;
178
+ /**
179
+ * Stop a running job and reclaim its backing runner: resolve the same transport
180
+ * the job dispatched to (by workspace) and `release` it — for the Cloudflare
181
+ * backend this SIGKILLs the per-run container instead of letting it idle out.
182
+ * Best-effort/idempotent: a transport without `release`, or an already-gone job,
183
+ * is a no-op.
184
+ */
185
+ stopJob(handle: AgentJobHandle): Promise<void>;
186
+ /**
187
+ * Synchronous convenience for non-durable callers (and tests): dispatch then
188
+ * poll inline until the job finishes. The durable driver does not use this — it
189
+ * calls {@link startJob}/{@link pollJob} so it can sleep durably between polls.
190
+ */
191
+ run(context: AgentRunContext): Promise<AgentRunResult>;
192
+ /**
193
+ * Preview the model this job will run, without dispatching the container. The
194
+ * proxyable-provider guard is deliberately left to `buildJobBody` (the dispatch
195
+ * path) so an unservable model still fails loudly there; this only names it.
196
+ */
197
+ resolveModel(context: AgentRunContext): Promise<string>;
198
+ /**
199
+ * Whether this step will run on a flat-rate subscription (quota) model — it
200
+ * resolves to a Claude Code / Codex harness (a subscription-only model, or a
201
+ * dual-mode model auto-routed to its subscription flavour because the workspace has
202
+ * a token). The engine's spend gate consults this so a quota run is not paused by
203
+ * an exhausted monetary budget it never contributes to. Best-effort: without a
204
+ * workspace id it reports false.
205
+ */
206
+ isQuotaBased(context: AgentRunContext): Promise<boolean>;
207
+ /**
208
+ * Per-service provisioning hints for the dispatch: the cloud provider the service
209
+ * runs on and the abstract instance size resolved to the target's concrete
210
+ * instance-type id. Cloudflare maps the id to a Container instance type; a
211
+ * self-hosted pool forwards it (with the provider) and provisions itself. Undefined
212
+ * when the service pins no provider/size (the transport keeps its default).
213
+ */
214
+ private dispatchOptions;
215
+ /** Validate the ids every container job needs, narrowing them to non-empty strings. */
216
+ private requireIds;
217
+ /** Resolve tokens/prompts/target and assemble the harness job body for `context`. */
218
+ private buildJobBody;
219
+ /**
220
+ * Resolve the per-job auth the harness carries: the proxy session token for Pi, or a
221
+ * leased subscription token for Claude Code / Codex. Spread into every job body
222
+ * (`common`) so the per-kind bodies can't drift on which auth they forward.
223
+ */
224
+ private resolveAuth;
225
+ /**
226
+ * Build the per-kind harness job body: the shared `common` fields plus ONLY the delta
227
+ * specific to this kind's harness endpoint (its prompts, the branch it runs on, and
228
+ * any per-kind extras), and the matching dispatch `kind`. The web-search fields live
229
+ * in `webTools` (shared by the kinds that allow web access). The dispatch precedence
230
+ * matches the original if-ladder exactly: the specific kinds first, then any read-only
231
+ * kind, then the default coder body.
232
+ */
233
+ private buildKindBody;
234
+ }
235
+ //# sourceMappingURL=ContainerAgentExecutor.d.ts.map
@@ -0,0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