@vercel/factory 0.0.14 → 0.0.16

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 (510) hide show
  1. package/CHANGELOG.md +356 -0
  2. package/README.md +96 -2
  3. package/dist/agent-routes.d.mts +113 -0
  4. package/dist/agent-routes.mjs +91 -0
  5. package/dist/agent-routes.mjs.map +1 -0
  6. package/dist/api-contracts.d.mts +1768 -0
  7. package/dist/api-contracts.mjs +119 -0
  8. package/dist/api-contracts.mjs.map +1 -0
  9. package/dist/api-images.d.mts +30 -0
  10. package/dist/api-images.mjs +28 -0
  11. package/dist/api-images.mjs.map +1 -0
  12. package/dist/api-task-graph.mjs +57 -0
  13. package/dist/api-task-graph.mjs.map +1 -0
  14. package/dist/api.d.mts +111 -216
  15. package/dist/api.mjs +1063 -99
  16. package/dist/api.mjs.map +1 -1
  17. package/dist/approval-access.d.mts +39 -0
  18. package/dist/approval-access.mjs +62 -0
  19. package/dist/approval-access.mjs.map +1 -0
  20. package/dist/approval-contracts.d.mts +698 -0
  21. package/dist/approval-contracts.mjs +27 -0
  22. package/dist/approval-contracts.mjs.map +1 -0
  23. package/dist/approval.d.mts +49 -0
  24. package/dist/approval.mjs +39 -0
  25. package/dist/approval.mjs.map +1 -0
  26. package/dist/blob/artifacts.d.mts +37 -0
  27. package/dist/blob/artifacts.mjs +45 -0
  28. package/dist/blob/artifacts.mjs.map +1 -0
  29. package/dist/blob/index.d.mts +84 -12
  30. package/dist/blob/index.mjs +179 -45
  31. package/dist/blob/index.mjs.map +1 -1
  32. package/dist/budget.d.mts +115 -0
  33. package/dist/budget.mjs +147 -0
  34. package/dist/budget.mjs.map +1 -0
  35. package/dist/budgets.d.mts +4 -0
  36. package/dist/budgets.mjs +4 -0
  37. package/dist/build-factory.d.mts +7 -4
  38. package/dist/build-factory.mjs +2 -1
  39. package/dist/build-factory.mjs.map +1 -1
  40. package/dist/change-verification/brief.d.mts +9 -0
  41. package/dist/change-verification/brief.mjs +13 -0
  42. package/dist/change-verification/brief.mjs.map +1 -0
  43. package/dist/change-verification/dispatch.d.mts +37 -0
  44. package/dist/change-verification/dispatch.mjs +83 -0
  45. package/dist/change-verification/dispatch.mjs.map +1 -0
  46. package/dist/change-verification/eve-tool.d.mts +61 -0
  47. package/dist/change-verification/eve-tool.mjs +89 -0
  48. package/dist/change-verification/eve-tool.mjs.map +1 -0
  49. package/dist/change-verification/result.mjs +130 -0
  50. package/dist/change-verification/result.mjs.map +1 -0
  51. package/dist/changes/eve-record-change.d.mts +56 -0
  52. package/dist/changes/eve-record-change.mjs +131 -0
  53. package/dist/changes/eve-record-change.mjs.map +1 -0
  54. package/dist/changes/presentation.d.mts +14 -0
  55. package/dist/changes.d.mts +24 -0
  56. package/dist/changes.mjs +29 -0
  57. package/dist/changes.mjs.map +1 -0
  58. package/dist/client-events.d.mts +25 -0
  59. package/dist/client-events.mjs +45 -0
  60. package/dist/client-events.mjs.map +1 -0
  61. package/dist/client-stream.d.mts +28 -0
  62. package/dist/client-stream.mjs +210 -0
  63. package/dist/client-stream.mjs.map +1 -0
  64. package/dist/client-transcript.d.mts +41 -0
  65. package/dist/client-transcript.mjs +233 -0
  66. package/dist/client-transcript.mjs.map +1 -0
  67. package/dist/client.d.mts +343 -0
  68. package/dist/client.mjs +366 -0
  69. package/dist/client.mjs.map +1 -0
  70. package/dist/code-review/contracts.d.mts +27 -0
  71. package/dist/code-review/eve-post-review.d.mts +70 -0
  72. package/dist/code-review/eve-post-review.mjs +195 -0
  73. package/dist/code-review/eve-post-review.mjs.map +1 -0
  74. package/dist/code-review/eve-review-comments.d.mts +75 -0
  75. package/dist/code-review/eve-review-comments.mjs +193 -0
  76. package/dist/code-review/eve-review-comments.mjs.map +1 -0
  77. package/dist/code-review/github-contracts.d.mts +10 -0
  78. package/dist/code-review/github-reporter.d.mts +46 -0
  79. package/dist/code-review/github-reporter.mjs +262 -0
  80. package/dist/code-review/github-reporter.mjs.map +1 -0
  81. package/dist/code-review/preparation.d.mts +34 -0
  82. package/dist/code-review/preparation.mjs +23 -0
  83. package/dist/code-review/preparation.mjs.map +1 -0
  84. package/dist/code-review/stall.d.mts +17 -0
  85. package/dist/code-review/stall.mjs +30 -0
  86. package/dist/code-review/stall.mjs.map +1 -0
  87. package/dist/code-review.d.mts +7 -0
  88. package/dist/code-review.mjs +5 -0
  89. package/dist/communication.d.mts +9 -0
  90. package/dist/communication.mjs +9 -0
  91. package/dist/connectors/github.d.mts +26 -0
  92. package/dist/connectors/github.mjs +55 -0
  93. package/dist/connectors/github.mjs.map +1 -0
  94. package/dist/connectors/index.d.mts +35 -3
  95. package/dist/connectors/index.mjs +3 -52
  96. package/dist/connectors/index.mjs.map +1 -1
  97. package/dist/connectors/outbox.d.mts +34 -0
  98. package/dist/connectors/outbox.mjs +50 -0
  99. package/dist/connectors/outbox.mjs.map +1 -0
  100. package/dist/connectors/slack-approval-blocks.mjs +136 -0
  101. package/dist/connectors/slack-approval-blocks.mjs.map +1 -0
  102. package/dist/connectors/slack-approvals.d.mts +29 -0
  103. package/dist/connectors/slack-approvals.mjs +346 -0
  104. package/dist/connectors/slack-approvals.mjs.map +1 -0
  105. package/dist/connectors/slack.d.mts +35 -52
  106. package/dist/connectors/slack.mjs +13 -85
  107. package/dist/connectors/slack.mjs.map +1 -1
  108. package/dist/deepsec/eve-tool.d.mts +110 -0
  109. package/dist/deepsec/eve-tool.mjs +166 -0
  110. package/dist/deepsec/eve-tool.mjs.map +1 -0
  111. package/dist/deepsec/finding.d.mts +84 -0
  112. package/dist/deepsec/finding.mjs +56 -0
  113. package/dist/deepsec/finding.mjs.map +1 -0
  114. package/dist/deepsec.d.mts +3 -0
  115. package/dist/delivery-metrics/metrics.d.mts +93 -0
  116. package/dist/delivery-metrics/metrics.mjs +200 -0
  117. package/dist/delivery-metrics/metrics.mjs.map +1 -0
  118. package/dist/delivery-metrics.d.mts +2 -0
  119. package/dist/delivery-metrics.mjs +2 -0
  120. package/dist/dispatch.d.mts +152 -0
  121. package/dist/dispatch.mjs +199 -0
  122. package/dist/dispatch.mjs.map +1 -0
  123. package/dist/errors.d.mts +15 -0
  124. package/dist/errors.mjs +38 -0
  125. package/dist/errors.mjs.map +1 -0
  126. package/dist/eve/index.d.mts +209 -1277
  127. package/dist/eve/index.mjs +312 -1073
  128. package/dist/eve/index.mjs.map +1 -1
  129. package/dist/eve/invoke.d.mts +144 -0
  130. package/dist/eve/invoke.mjs +254 -0
  131. package/dist/eve/invoke.mjs.map +1 -0
  132. package/dist/eve/session-client.d.mts +186 -0
  133. package/dist/eve/session-client.mjs +245 -0
  134. package/dist/eve/session-client.mjs.map +1 -0
  135. package/dist/eve/task-execution.d.mts +380 -0
  136. package/dist/eve/task-execution.mjs +73 -0
  137. package/dist/eve/task-execution.mjs.map +1 -0
  138. package/dist/eve/task-session.d.mts +129 -0
  139. package/dist/eve/task-session.mjs +245 -0
  140. package/dist/eve/task-session.mjs.map +1 -0
  141. package/dist/eve/transcript.d.mts +37 -0
  142. package/dist/eve/transcript.mjs +69 -0
  143. package/dist/eve/transcript.mjs.map +1 -0
  144. package/dist/execution-public.d.mts +8 -0
  145. package/dist/execution-public.mjs +7 -0
  146. package/dist/execution.d.mts +183 -0
  147. package/dist/execution.mjs +223 -0
  148. package/dist/execution.mjs.map +1 -0
  149. package/dist/finding-remediation/admission.d.mts +53 -0
  150. package/dist/finding-remediation/admission.mjs +90 -0
  151. package/dist/finding-remediation/admission.mjs.map +1 -0
  152. package/dist/finding-remediation/brief.d.mts +14 -0
  153. package/dist/finding-remediation/brief.mjs +25 -0
  154. package/dist/finding-remediation/brief.mjs.map +1 -0
  155. package/dist/finding-remediation/eve-tool.d.mts +29 -0
  156. package/dist/finding-remediation/eve-tool.mjs +34 -0
  157. package/dist/finding-remediation/eve-tool.mjs.map +1 -0
  158. package/dist/findings/fingerprint.d.mts +14 -0
  159. package/dist/findings/fingerprint.mjs +28 -0
  160. package/dist/findings/fingerprint.mjs.map +1 -0
  161. package/dist/findings.d.mts +7 -0
  162. package/dist/findings.mjs +6 -0
  163. package/dist/github-app.d.mts +54 -0
  164. package/dist/github-app.mjs +121 -0
  165. package/dist/github-app.mjs.map +1 -0
  166. package/dist/github-publication.d.mts +199 -0
  167. package/dist/github-publication.mjs +442 -0
  168. package/dist/github-publication.mjs.map +1 -0
  169. package/dist/github-transfer.d.mts +81 -0
  170. package/dist/github-transfer.mjs +273 -0
  171. package/dist/github-transfer.mjs.map +1 -0
  172. package/dist/github.d.mts +446 -2
  173. package/dist/github.mjs +357 -56
  174. package/dist/github.mjs.map +1 -1
  175. package/dist/image-input.d.mts +51 -0
  176. package/dist/image-input.mjs +63 -0
  177. package/dist/image-input.mjs.map +1 -0
  178. package/dist/inbox-activity.d.mts +53 -0
  179. package/dist/inbox-activity.mjs +41 -0
  180. package/dist/inbox-activity.mjs.map +1 -0
  181. package/dist/index.d.mts +16 -484
  182. package/dist/index.mjs +15 -522
  183. package/dist/intake-contracts.d.mts +55 -0
  184. package/dist/intake-contracts.mjs +33 -0
  185. package/dist/intake-contracts.mjs.map +1 -0
  186. package/dist/integrations/deepsec.d.mts +5 -0
  187. package/dist/integrations/deepsec.mjs +3 -0
  188. package/dist/integrations/github.d.mts +11 -0
  189. package/dist/integrations/github.mjs +9 -0
  190. package/dist/integrations/slack.d.mts +5 -0
  191. package/dist/integrations/slack.mjs +5 -0
  192. package/dist/integrations/vercel.d.mts +5 -0
  193. package/dist/integrations/vercel.mjs +4 -0
  194. package/dist/merge-resolution/contracts.d.mts +17 -0
  195. package/dist/merge-resolution/contracts.mjs +19 -0
  196. package/dist/merge-resolution/contracts.mjs.map +1 -0
  197. package/dist/merge-resolution/eve-tools.d.mts +47 -0
  198. package/dist/merge-resolution/eve-tools.mjs +122 -0
  199. package/dist/merge-resolution/eve-tools.mjs.map +1 -0
  200. package/dist/model-settings.d.mts +41 -0
  201. package/dist/model-settings.mjs +35 -0
  202. package/dist/model-settings.mjs.map +1 -0
  203. package/dist/multi-repository-changes/coordination.d.mts +49 -0
  204. package/dist/multi-repository-changes/coordination.mjs +115 -0
  205. package/dist/multi-repository-changes/coordination.mjs.map +1 -0
  206. package/dist/planning/cancellation.mjs +82 -0
  207. package/dist/planning/cancellation.mjs.map +1 -0
  208. package/dist/planning/configuration.d.mts +23 -0
  209. package/dist/planning/configuration.mjs +56 -0
  210. package/dist/planning/configuration.mjs.map +1 -0
  211. package/dist/planning/contracts.d.mts +136 -0
  212. package/dist/planning/contracts.mjs +42 -0
  213. package/dist/planning/contracts.mjs.map +1 -0
  214. package/dist/planning/dependencies.mjs +44 -0
  215. package/dist/planning/dependencies.mjs.map +1 -0
  216. package/dist/planning/effects.mjs +122 -0
  217. package/dist/planning/effects.mjs.map +1 -0
  218. package/dist/planning/reconcile.mjs +279 -0
  219. package/dist/planning/reconcile.mjs.map +1 -0
  220. package/dist/planning/runtime.d.mts +27 -0
  221. package/dist/planning/runtime.mjs +25 -0
  222. package/dist/planning/runtime.mjs.map +1 -0
  223. package/dist/planning/state.mjs +92 -0
  224. package/dist/planning/state.mjs.map +1 -0
  225. package/dist/planning/turns.mjs +262 -0
  226. package/dist/planning/turns.mjs.map +1 -0
  227. package/dist/planning/validation.mjs +106 -0
  228. package/dist/planning/validation.mjs.map +1 -0
  229. package/dist/postgres/index.d.mts +48 -1
  230. package/dist/postgres/index.mjs +45 -3
  231. package/dist/postgres/index.mjs.map +1 -1
  232. package/dist/presets/software-development/approval.d.mts +14 -0
  233. package/dist/presets/software-development/approval.mjs +21 -0
  234. package/dist/presets/software-development/approval.mjs.map +1 -0
  235. package/dist/presets/software-development/deepsec-brief.d.mts +8 -0
  236. package/dist/presets/software-development/deepsec-brief.mjs +14 -0
  237. package/dist/presets/software-development/deepsec-brief.mjs.map +1 -0
  238. package/dist/presets/software-development/dispatch.d.mts +56 -0
  239. package/dist/presets/software-development/dispatch.mjs +67 -0
  240. package/dist/presets/software-development/dispatch.mjs.map +1 -0
  241. package/dist/presets/software-development/eve-delegation-policy.d.mts +7 -0
  242. package/dist/presets/software-development/eve-delegation-policy.mjs +34 -0
  243. package/dist/presets/software-development/eve-delegation-policy.mjs.map +1 -0
  244. package/dist/presets/software-development/eve.d.mts +18 -0
  245. package/dist/presets/software-development/eve.mjs +19 -0
  246. package/dist/presets/software-development/eve.mjs.map +1 -0
  247. package/dist/presets/software-development/finish-task-policy.d.mts +7 -0
  248. package/dist/presets/software-development/finish-task-policy.mjs +9 -0
  249. package/dist/presets/software-development/finish-task-policy.mjs.map +1 -0
  250. package/dist/presets/software-development/recovery.d.mts +32 -0
  251. package/dist/presets/software-development/recovery.mjs +120 -0
  252. package/dist/presets/software-development/recovery.mjs.map +1 -0
  253. package/dist/presets/software-development/task-communication.d.mts +24 -0
  254. package/dist/presets/software-development/task-communication.mjs +157 -0
  255. package/dist/presets/software-development/task-communication.mjs.map +1 -0
  256. package/dist/presets/software-development.d.mts +10 -0
  257. package/dist/presets/software-development.mjs +9 -0
  258. package/dist/pull-requests/contracts.d.mts +72 -0
  259. package/dist/pull-requests/eve-fetch.d.mts +57 -0
  260. package/dist/pull-requests/eve-fetch.mjs +151 -0
  261. package/dist/pull-requests/eve-fetch.mjs.map +1 -0
  262. package/dist/pull-requests/github-label-manager.d.mts +27 -0
  263. package/dist/pull-requests/github-label-manager.mjs +40 -0
  264. package/dist/pull-requests/github-label-manager.mjs.map +1 -0
  265. package/dist/pull-requests/github-publisher.d.mts +67 -0
  266. package/dist/pull-requests/github-publisher.mjs +405 -0
  267. package/dist/pull-requests/github-publisher.mjs.map +1 -0
  268. package/dist/pull-requests.d.mts +6 -0
  269. package/dist/pull-requests.mjs +4 -0
  270. package/dist/receipts.d.mts +4 -0
  271. package/dist/receipts.mjs +3 -0
  272. package/dist/repositories.d.mts +18 -0
  273. package/dist/repositories.mjs +33 -0
  274. package/dist/repositories.mjs.map +1 -0
  275. package/dist/sandbox/command.d.mts +18 -0
  276. package/dist/sandbox/execution-abort.d.mts +16 -0
  277. package/dist/sandbox/execution-abort.mjs +49 -0
  278. package/dist/sandbox/execution-abort.mjs.map +1 -0
  279. package/dist/sandbox/execution-environment.d.mts +25 -0
  280. package/dist/sandbox/execution-run-ledger.d.mts +115 -0
  281. package/dist/sandbox/execution-run-ledger.mjs +209 -0
  282. package/dist/sandbox/execution-run-ledger.mjs.map +1 -0
  283. package/dist/sandbox/execution.d.mts +54 -0
  284. package/dist/sandbox/execution.mjs +228 -0
  285. package/dist/sandbox/execution.mjs.map +1 -0
  286. package/dist/sandbox/harness-runner.d.mts +79 -0
  287. package/dist/sandbox/harness-runner.mjs +162 -0
  288. package/dist/sandbox/harness-runner.mjs.map +1 -0
  289. package/dist/sandbox/index.d.mts +10 -0
  290. package/dist/sandbox/index.mjs +7 -0
  291. package/dist/sandbox/task-environment.d.mts +50 -0
  292. package/dist/sandbox/task-environment.mjs +140 -0
  293. package/dist/sandbox/task-environment.mjs.map +1 -0
  294. package/dist/sandbox/workspace.d.mts +29 -0
  295. package/dist/sandbox/workspace.mjs +28 -0
  296. package/dist/sandbox/workspace.mjs.map +1 -0
  297. package/dist/schema/agent-route.d.mts +40 -0
  298. package/dist/schema/agent-route.mjs +33 -0
  299. package/dist/schema/agent-route.mjs.map +1 -0
  300. package/dist/schema/answer.d.mts +23 -0
  301. package/dist/schema/answer.mjs +21 -0
  302. package/dist/schema/answer.mjs.map +1 -0
  303. package/dist/schema/budget.d.mts +38 -0
  304. package/dist/schema/budget.mjs +30 -0
  305. package/dist/schema/budget.mjs.map +1 -0
  306. package/dist/schema/catalog.mjs +72 -0
  307. package/dist/schema/catalog.mjs.map +1 -0
  308. package/dist/schema/change.d.mts +117 -0
  309. package/dist/schema/change.mjs +68 -0
  310. package/dist/schema/change.mjs.map +1 -0
  311. package/dist/schema/common.d.mts +33 -0
  312. package/dist/{id-BLIkCVue.mjs → schema/common.mjs} +7 -16
  313. package/dist/schema/common.mjs.map +1 -0
  314. package/dist/schema/communication.d.mts +52 -0
  315. package/dist/{communication-Kd9nU5RP.mjs → schema/communication.mjs} +8 -3
  316. package/dist/schema/communication.mjs.map +1 -0
  317. package/dist/schema/execution.d.mts +101 -0
  318. package/dist/schema/execution.mjs +86 -0
  319. package/dist/schema/execution.mjs.map +1 -0
  320. package/dist/schema/factory-config.d.mts +122 -0
  321. package/dist/schema/factory-config.mjs +90 -0
  322. package/dist/schema/factory-config.mjs.map +1 -0
  323. package/dist/schema/finding.d.mts +125 -0
  324. package/dist/schema/finding.mjs +67 -0
  325. package/dist/schema/finding.mjs.map +1 -0
  326. package/dist/schema/id.d.mts +43 -0
  327. package/dist/schema/id.mjs +32 -0
  328. package/dist/schema/id.mjs.map +1 -0
  329. package/dist/schema/outbox.d.mts +240 -0
  330. package/dist/schema/outbox.mjs +53 -0
  331. package/dist/schema/outbox.mjs.map +1 -0
  332. package/dist/schema/question-route.mjs +16 -0
  333. package/dist/schema/question-route.mjs.map +1 -0
  334. package/dist/schema/receipt.d.mts +81 -0
  335. package/dist/schema/receipt.mjs +94 -0
  336. package/dist/schema/receipt.mjs.map +1 -0
  337. package/dist/schema/repository.d.mts +30 -0
  338. package/dist/schema/repository.mjs +29 -0
  339. package/dist/schema/repository.mjs.map +1 -0
  340. package/dist/schema/session.d.mts +136 -0
  341. package/dist/schema/session.mjs +54 -0
  342. package/dist/schema/session.mjs.map +1 -0
  343. package/dist/schema/signal.d.mts +105 -0
  344. package/dist/schema/signal.mjs +81 -0
  345. package/dist/schema/signal.mjs.map +1 -0
  346. package/dist/schema/slack-pr-notifications.d.mts +12 -0
  347. package/dist/schema/slack-pr-notifications.mjs +11 -0
  348. package/dist/schema/slack-pr-notifications.mjs.map +1 -0
  349. package/dist/schema/stored-session.mjs +10 -0
  350. package/dist/schema/stored-session.mjs.map +1 -0
  351. package/dist/schema/stored-task.mjs +20 -0
  352. package/dist/schema/stored-task.mjs.map +1 -0
  353. package/dist/schema/task-effect.d.mts +39 -0
  354. package/dist/schema/task-effect.mjs +29 -0
  355. package/dist/schema/task-effect.mjs.map +1 -0
  356. package/dist/schema/task-graph.d.mts +3173 -0
  357. package/dist/schema/task-graph.mjs +97 -0
  358. package/dist/schema/task-graph.mjs.map +1 -0
  359. package/dist/schema/task-message.d.mts +254 -0
  360. package/dist/schema/task-message.mjs +189 -0
  361. package/dist/schema/task-message.mjs.map +1 -0
  362. package/dist/schema/task.d.mts +273 -0
  363. package/dist/schema/task.mjs +200 -0
  364. package/dist/schema/task.mjs.map +1 -0
  365. package/dist/schema/transcript.d.mts +176 -0
  366. package/dist/schema/transcript.mjs +87 -0
  367. package/dist/schema/transcript.mjs.map +1 -0
  368. package/dist/schema/transitions.d.mts +50 -0
  369. package/dist/schema/transitions.mjs +303 -0
  370. package/dist/schema/transitions.mjs.map +1 -0
  371. package/dist/schema/work.d.mts +150 -0
  372. package/dist/schema/work.mjs +102 -0
  373. package/dist/schema/work.mjs.map +1 -0
  374. package/dist/session-previews.d.mts +76 -0
  375. package/dist/session-previews.mjs +55 -0
  376. package/dist/session-previews.mjs.map +1 -0
  377. package/dist/session-review.d.mts +120 -0
  378. package/dist/session-review.mjs +79 -0
  379. package/dist/session-review.mjs.map +1 -0
  380. package/dist/signal-triage.d.mts +20 -0
  381. package/dist/signal-triage.mjs +85 -0
  382. package/dist/signal-triage.mjs.map +1 -0
  383. package/dist/signals.d.mts +20 -0
  384. package/dist/signals.mjs +19 -0
  385. package/dist/signals.mjs.map +1 -0
  386. package/dist/stall.d.mts +41 -0
  387. package/dist/stall.mjs +83 -0
  388. package/dist/stall.mjs.map +1 -0
  389. package/dist/storage.d.mts +4 -0
  390. package/dist/storage.mjs +4 -0
  391. package/dist/store/driver.d.mts +65 -0
  392. package/dist/store/driver.mjs +42 -0
  393. package/dist/store/driver.mjs.map +1 -0
  394. package/dist/store/engine.d.mts +683 -0
  395. package/dist/store/engine.mjs +2309 -0
  396. package/dist/store/engine.mjs.map +1 -0
  397. package/dist/store/memory.d.mts +24 -0
  398. package/dist/store/memory.mjs +69 -0
  399. package/dist/store/memory.mjs.map +1 -0
  400. package/dist/store/slack-pr-notifications.d.mts +44 -0
  401. package/dist/store/slack-pr-notifications.mjs +121 -0
  402. package/dist/store/slack-pr-notifications.mjs.map +1 -0
  403. package/dist/store/task-effects.d.mts +38 -0
  404. package/dist/store/task-effects.mjs +118 -0
  405. package/dist/store/task-effects.mjs.map +1 -0
  406. package/dist/store/task-graphs.d.mts +60 -0
  407. package/dist/store/task-graphs.mjs +212 -0
  408. package/dist/store/task-graphs.mjs.map +1 -0
  409. package/dist/store/task-messages.d.mts +136 -0
  410. package/dist/store/task-messages.mjs +475 -0
  411. package/dist/store/task-messages.mjs.map +1 -0
  412. package/dist/store/task-work.d.mts +180 -0
  413. package/dist/store/task-work.mjs +137 -0
  414. package/dist/store/task-work.mjs.map +1 -0
  415. package/dist/store/work-notifications.d.mts +19 -0
  416. package/dist/store/work-notifications.mjs +48 -0
  417. package/dist/store/work-notifications.mjs.map +1 -0
  418. package/dist/sweep.d.mts +79 -0
  419. package/dist/sweep.mjs +171 -0
  420. package/dist/sweep.mjs.map +1 -0
  421. package/dist/task-communication.d.mts +35 -0
  422. package/dist/task-communication.mjs +47 -0
  423. package/dist/task-communication.mjs.map +1 -0
  424. package/dist/task-graph-view.d.mts +267 -0
  425. package/dist/task-graph-view.mjs +17 -0
  426. package/dist/task-graph-view.mjs.map +1 -0
  427. package/dist/task-message-processing.d.mts +60 -0
  428. package/dist/task-message-processing.mjs +200 -0
  429. package/dist/task-message-processing.mjs.map +1 -0
  430. package/dist/task-protocols.d.mts +80 -0
  431. package/dist/task-protocols.mjs +47 -0
  432. package/dist/task-protocols.mjs.map +1 -0
  433. package/dist/tasks.d.mts +17 -0
  434. package/dist/tasks.mjs +17 -0
  435. package/dist/vercel-git.d.mts +53 -0
  436. package/dist/vercel-git.mjs +344 -0
  437. package/dist/vercel-git.mjs.map +1 -0
  438. package/dist/vercel-github-api.d.mts +103 -0
  439. package/dist/vercel-github-api.mjs +363 -0
  440. package/dist/vercel-github-api.mjs.map +1 -0
  441. package/dist/vercel.d.mts +34 -2
  442. package/dist/vercel.mjs +49 -3
  443. package/dist/vercel.mjs.map +1 -1
  444. package/dist/work-triage/eve-tool.d.mts +29 -0
  445. package/dist/work-triage/eve-tool.mjs +32 -0
  446. package/dist/work-triage/eve-tool.mjs.map +1 -0
  447. package/dist/work-triage/find-existing-work.d.mts +32 -0
  448. package/dist/work-triage/find-existing-work.mjs +31 -0
  449. package/dist/work-triage/find-existing-work.mjs.map +1 -0
  450. package/dist/work-triage/github.d.mts +15 -0
  451. package/dist/work-triage/github.mjs +14 -0
  452. package/dist/work-triage/github.mjs.map +1 -0
  453. package/dist/work-triage.d.mts +4 -0
  454. package/dist/work-triage.mjs +3 -0
  455. package/dist/workflows.d.mts +146 -0
  456. package/dist/workflows.mjs +139 -0
  457. package/dist/workflows.mjs.map +1 -0
  458. package/dist/workspace-diff-assembly.d.mts +33 -0
  459. package/dist/workspace-diff-assembly.mjs +95 -0
  460. package/dist/workspace-diff-assembly.mjs.map +1 -0
  461. package/dist/workspace-diff.d.mts +90 -0
  462. package/dist/workspace-diff.mjs +61 -0
  463. package/dist/workspace-diff.mjs.map +1 -0
  464. package/dist/workspace-files-git.d.mts +15 -0
  465. package/dist/workspace-files-git.mjs +61 -0
  466. package/dist/workspace-files-git.mjs.map +1 -0
  467. package/dist/workspace-files.d.mts +107 -0
  468. package/dist/workspace-files.mjs +74 -0
  469. package/dist/workspace-files.mjs.map +1 -0
  470. package/dist/workspace-snapshot.d.mts +26 -0
  471. package/dist/workspace-snapshot.mjs +80 -0
  472. package/dist/workspace-snapshot.mjs.map +1 -0
  473. package/docs/getting-started.md +104 -0
  474. package/docs/index.md +100 -0
  475. package/docs/recipes/cancellation.md +215 -0
  476. package/docs/recipes/custom-workflow.md +153 -0
  477. package/docs/recipes/dependent-tasks.md +207 -0
  478. package/docs/recipes/eve-agent.md +277 -0
  479. package/docs/recipes/human-input.md +204 -0
  480. package/docs/recipes/persistence-recovery.md +268 -0
  481. package/docs/recipes/retry-recovery.md +241 -0
  482. package/docs/recipes/task-messaging.md +215 -0
  483. package/docs/recipes/typed-eve-result.md +161 -0
  484. package/docs/runtime-integration.md +137 -0
  485. package/package.json +142 -46
  486. package/dist/approval-JX2Px9IC.mjs +0 -132
  487. package/dist/approval-JX2Px9IC.mjs.map +0 -1
  488. package/dist/budget-DzSiIA4t.mjs +0 -42
  489. package/dist/budget-DzSiIA4t.mjs.map +0 -1
  490. package/dist/change-D2U6v7Ek.mjs +0 -554
  491. package/dist/change-D2U6v7Ek.mjs.map +0 -1
  492. package/dist/communication-Kd9nU5RP.mjs.map +0 -1
  493. package/dist/coordination-Cq08hb1l.mjs +0 -76
  494. package/dist/coordination-Cq08hb1l.mjs.map +0 -1
  495. package/dist/dispatch-BaZS3PT8.d.mts +0 -76
  496. package/dist/driver-BC0Mt5KG.d.mts +0 -34
  497. package/dist/driver-Bbd25rNM.mjs +0 -23
  498. package/dist/driver-Bbd25rNM.mjs.map +0 -1
  499. package/dist/engine-DFHU2Pe-.d.mts +0 -781
  500. package/dist/engine-WaUM2cGA.mjs +0 -1068
  501. package/dist/engine-WaUM2cGA.mjs.map +0 -1
  502. package/dist/factory-config-BoRXOw43.mjs +0 -50
  503. package/dist/factory-config-BoRXOw43.mjs.map +0 -1
  504. package/dist/factory-config-D2yU3G0c.d.mts +0 -58
  505. package/dist/github-C5HNBN6p.d.mts +0 -279
  506. package/dist/id-BLIkCVue.mjs.map +0 -1
  507. package/dist/index-Bw6hggoH.d.mts +0 -40
  508. package/dist/index.mjs.map +0 -1
  509. package/dist/task-CcOyOJ3k.mjs +0 -154
  510. package/dist/task-CcOyOJ3k.mjs.map +0 -1
@@ -0,0 +1,254 @@
1
+ import { changeIdSchema, repositoryIdsSchema, signalIdSchema, taskIdSchema } from "../schema/id.mjs";
2
+ import { agentRouteBindingSchema, parseAgentRouteBinding } from "../schema/agent-route.mjs";
3
+ import { optionalTaskIdForSession, replyToForSession, repositoryIdsForSession } from "./task-session.mjs";
4
+ import { routeTaskWork } from "../agent-routes.mjs";
5
+ import { dispatchTask } from "../dispatch.mjs";
6
+ import { startEveSession } from "./session-client.mjs";
7
+ import { z } from "zod";
8
+ import { defineTool } from "eve/tools";
9
+ //#region src/eve/invoke.ts
10
+ /**
11
+ * A tool that lets one agent hand work to another, NMA-style: the caller
12
+ * decides to invoke; trusted code owns the how. The handoff is recorded as a
13
+ * factory task (single-winner dispatch, receipts), then a fresh session is
14
+ * started on the target agent carrying only the task id — never the caller's
15
+ * context. The session start is create-once on the task attempt, so a retried
16
+ * launch cannot duplicate that attempt while a later attempt starts fresh.
17
+ */
18
+ function createInvokeAgentTool(stores, options) {
19
+ const doFetch = options.fetch ?? fetch;
20
+ return defineTool({
21
+ description: `${options.description} Hands the work to a separate agent in a fresh session; you will not see its reasoning. Returns the handoff task id.`,
22
+ inputSchema: z.object({
23
+ repositoryIds: repositoryIdsSchema,
24
+ parentTaskId: taskIdSchema.optional().describe("Your own task, when this work continues it."),
25
+ changeId: changeIdSchema.optional().describe("The change the target agent should work on."),
26
+ channel: z.string().min(1).describe("Reply connector, e.g. github."),
27
+ address: z.string().min(1).describe("Reply address, e.g. acme/web#41."),
28
+ brief: z.string().min(1).max(4e3).describe("What the target agent needs to know. Facts and references only, not your reasoning.")
29
+ }),
30
+ async execute(input) {
31
+ const taskInput = {
32
+ repositoryIds: input.repositoryIds,
33
+ kind: options.route.taskKind,
34
+ work: routeTaskWork({
35
+ route: options.route,
36
+ title: input.brief.trim().slice(0, 256),
37
+ input: { brief: input.brief }
38
+ }),
39
+ changeId: input.changeId,
40
+ replyTo: {
41
+ channel: input.channel,
42
+ address: input.address
43
+ }
44
+ };
45
+ const task = await stores.tasks.create(input.parentTaskId === void 0 ? {
46
+ ...taskInput,
47
+ origin: { operator: "factory" }
48
+ } : {
49
+ ...taskInput,
50
+ origin: {},
51
+ parentTaskId: input.parentTaskId
52
+ });
53
+ const running = await dispatchTask(stores, {
54
+ taskId: task.id,
55
+ route: options.route,
56
+ maxLaunchAttempts: 1,
57
+ budget: options.budget?.(),
58
+ launch: async (dispatched) => {
59
+ const headers = new Headers(await options.headers?.(dispatched));
60
+ headers.set("content-type", "application/json");
61
+ const token = await options.token?.();
62
+ if (token !== void 0) headers.set("authorization", `Bearer ${token}`);
63
+ const message = [
64
+ `You are assigned factory task ${dispatched.id}.`,
65
+ input.changeId === void 0 ? null : `Change under review: ${input.changeId}.`,
66
+ `Reply address: ${input.channel} ${input.address}.`,
67
+ "",
68
+ input.brief,
69
+ "",
70
+ "Read the task with get_task first, do the work, and record the outcome with your factory tools."
71
+ ].filter((line) => line !== null).join("\n");
72
+ return startEveSession({
73
+ agentUrl: options.targetUrl(),
74
+ agentName: "target agent",
75
+ headers,
76
+ message,
77
+ operationId: `factory-task:${dispatched.id}:${dispatched.attempt}`,
78
+ fetch: doFetch
79
+ });
80
+ }
81
+ });
82
+ return {
83
+ taskId: running.id,
84
+ kind: running.kind,
85
+ state: running.state
86
+ };
87
+ }
88
+ });
89
+ }
90
+ /**
91
+ * Give a conversational agent one bounded delegation surface backed by the
92
+ * application's route registry. The caller selects a declared route; trusted
93
+ * code owns task creation, budget enforcement, and the fresh target session.
94
+ */
95
+ function createDelegateAgentTool(stores, options) {
96
+ const doFetch = options.fetch ?? fetch;
97
+ const routeSummary = options.routes.routes.map((route) => `${route.id}@${route.version}: ${route.description}`).join("\n");
98
+ return defineTool({
99
+ description: "Delegate durable work to one registered specialist. Select only a listed route; the specialist runs independently and reports its result through Factory.\n" + routeSummary,
100
+ inputSchema: z.object({
101
+ route: agentRouteBindingSchema.describe("Exact route id and version listed in this tool's description."),
102
+ repositoryIds: repositoryIdsSchema.refine((repositoryIds) => new Set(repositoryIds).size === repositoryIds.length, "Repository ids must be unique."),
103
+ signalId: signalIdSchema.optional().describe("Pending external signal this delegation accepts."),
104
+ parentTaskId: taskIdSchema.optional().describe("Existing task this work continues."),
105
+ changeId: changeIdSchema.optional().describe("Existing change the specialist should inspect."),
106
+ channel: z.string().min(1).describe("Originating conversation channel."),
107
+ address: z.string().min(1).describe("Originating conversation reply address."),
108
+ brief: z.string().min(1).max(4e3).describe("Facts and desired outcome, without hidden reasoning.")
109
+ }),
110
+ async execute(input, ctx) {
111
+ const route = options.routes.get(input.route);
112
+ if (route === void 0) throw new Error(`Unknown agent route ${input.route.id}@${input.route.version}.`);
113
+ const replyTo = {
114
+ channel: input.channel,
115
+ address: input.address
116
+ };
117
+ const auth = ctx.session.auth.initiator;
118
+ const attributes = auth?.attributes;
119
+ const boundSignal = signalIdSchema.safeParse(attributes?.factorySignalId);
120
+ if (attributes?.factorySignalId !== void 0 && !boundSignal.success) throw new Error("Connector-authenticated Signal context is invalid.");
121
+ if (boundSignal.success && input.signalId !== void 0 && input.signalId !== boundSignal.data) throw new Error("Delegation must accept its authenticated Signal.");
122
+ const signalId = input.signalId ?? (boundSignal.success ? boundSignal.data : void 0);
123
+ const boundRepositoryIds = repositoryIdsForSession(auth);
124
+ if (boundRepositoryIds !== null && input.repositoryIds.some((id) => !boundRepositoryIds.includes(id))) throw new Error("Delegation includes a repository outside the connector-authenticated context.");
125
+ const boundReplyTo = replyToForSession(auth);
126
+ if (boundReplyTo !== null && (boundReplyTo.channel !== replyTo.channel || boundReplyTo.address !== replyTo.address)) throw new Error("Delegation reply address does not match the authenticated conversation.");
127
+ for (const repositoryId of input.repositoryIds) {
128
+ const repository = await stores.repositories.get(repositoryId);
129
+ if (repository === null || !repository.enabled) throw new Error(`Repository ${repositoryId} is not enabled in this factory.`);
130
+ }
131
+ const boundChange = changeIdSchema.safeParse(attributes?.factoryChangeId);
132
+ if (attributes?.factoryChangeId !== void 0 && !boundChange.success) throw new Error("Connector-authenticated change context is invalid.");
133
+ if (input.changeId !== void 0 && boundChange.success && input.changeId !== boundChange.data) throw new Error("Delegated change does not match the connector-authenticated context.");
134
+ const changeId = input.changeId ?? (boundChange.success ? boundChange.data : void 0);
135
+ if (changeId !== void 0) {
136
+ if (input.repositoryIds.length !== 1) throw new Error("Delegating work on an existing Change requires exactly one repository.");
137
+ const change = await stores.changes.get(changeId);
138
+ if (change === null || change.repositoryId !== input.repositoryIds[0] || change.state !== "verifying" && change.state !== "ready") throw new Error(`Change ${changeId} is not an open pull request in the selected repository.`);
139
+ }
140
+ if (signalId !== void 0) {
141
+ const signal = await stores.signals.get(signalId);
142
+ if (signal === null) throw new Error(`Signal ${signalId} does not exist.`);
143
+ if (boundSignal.success && (signal.triage?.attempt !== Number(attributes?.factorySignalAttempt) || signal.triage?.state !== "running" || signal.triage.sessionId !== void 0 && signal.triage.sessionId !== ctx.session.id)) throw new Error("Delegation requires the current running Signal triage attempt.");
144
+ if (!input.repositoryIds.includes(signal.repositoryId) || signal.replyTo.channel !== replyTo.channel || signal.replyTo.address !== replyTo.address) throw new Error("Delegation does not match the signal's authenticated repository and reply address.");
145
+ if (signal.outcome !== "pending" && signal.outcome !== "accepted") throw new Error(`Signal ${signal.id} is already ${signal.outcome}.`);
146
+ }
147
+ const acceptSignal = async () => {
148
+ if (signalId === void 0) return;
149
+ if ((await stores.signals.get(signalId))?.outcome === "accepted") return;
150
+ await stores.signals.decide(signalId, {
151
+ outcome: "accepted",
152
+ reason: `Foreman selected ${route.id}.`
153
+ });
154
+ };
155
+ let parentTaskId = input.parentTaskId;
156
+ const boundTaskId = optionalTaskIdForSession(auth);
157
+ if (boundTaskId !== null && boundReplyTo?.channel === "api") {
158
+ const boundTask = await stores.tasks.get(boundTaskId);
159
+ if (boundTask?.area === "conversation") {
160
+ if (parentTaskId !== void 0 && parentTaskId !== boundTask.id) throw new Error("Follow-up delegation must name its authenticated conversation task as parent.");
161
+ parentTaskId = boundTask.id;
162
+ }
163
+ }
164
+ const operator = ctx.session.auth.initiator?.principalId ?? "foreman";
165
+ const workflowResult = await options.workflow?.({
166
+ stores,
167
+ route,
168
+ repositoryIds: input.repositoryIds,
169
+ signalId,
170
+ parentTaskId,
171
+ changeId,
172
+ replyTo,
173
+ brief: input.brief,
174
+ operator,
175
+ dispatch: (task) => dispatchRouteTask(stores, options, doFetch, route, task, changeId, input.brief)
176
+ });
177
+ if (workflowResult !== void 0 && workflowResult !== null) {
178
+ await acceptSignal();
179
+ return workflowResult;
180
+ }
181
+ const taskInput = {
182
+ repositoryIds: input.repositoryIds,
183
+ kind: route.taskKind,
184
+ work: routeTaskWork({
185
+ route,
186
+ title: input.brief.trim().slice(0, 256),
187
+ input: { brief: input.brief }
188
+ }),
189
+ replyTo,
190
+ changeId,
191
+ ...signalId === void 0 ? {} : { dedupeKey: `route:${signalId}:${route.id}:${route.version}` }
192
+ };
193
+ const task = await stores.tasks.create(parentTaskId !== void 0 ? {
194
+ ...taskInput,
195
+ parentTaskId,
196
+ origin: {}
197
+ } : signalId !== void 0 ? {
198
+ ...taskInput,
199
+ origin: { signalId }
200
+ } : {
201
+ ...taskInput,
202
+ origin: { operator }
203
+ });
204
+ await acceptSignal();
205
+ const running = task.state === "queued" ? await dispatchRouteTask(stores, options, doFetch, route, task, changeId, input.brief) : task;
206
+ return {
207
+ taskId: running.id,
208
+ route: parseAgentRouteBinding({
209
+ id: route.id,
210
+ version: route.version
211
+ }),
212
+ agent: route.agent,
213
+ state: running.state
214
+ };
215
+ }
216
+ });
217
+ }
218
+ async function dispatchRouteTask(stores, options, doFetch, route, task, changeId, brief) {
219
+ return dispatchTask(stores, {
220
+ taskId: task.id,
221
+ route,
222
+ maxLaunchAttempts: options.maxLaunchAttempts?.(route) ?? 1,
223
+ budget: options.budget?.(route),
224
+ launch: async (dispatched) => {
225
+ if (options.launch) return options.launch({
226
+ task: dispatched,
227
+ route,
228
+ brief
229
+ });
230
+ const headers = new Headers(await options.headers?.(dispatched, route));
231
+ headers.set("content-type", "application/json");
232
+ const token = await options.token?.(route);
233
+ if (token !== void 0) headers.set("authorization", `Bearer ${token}`);
234
+ const message = [
235
+ `You are assigned factory task ${dispatched.id} through route ${route.id}.`,
236
+ changeId === void 0 ? null : `Change under review: ${changeId}.`,
237
+ brief,
238
+ "Read the task first and return exactly one bounded Factory outcome."
239
+ ].filter((line) => line !== null).join("\n\n");
240
+ return startEveSession({
241
+ agentUrl: options.targetUrl(route),
242
+ agentName: route.agent,
243
+ headers,
244
+ message,
245
+ operationId: `factory-task:${dispatched.id}:${dispatched.attempt}`,
246
+ fetch: doFetch
247
+ });
248
+ }
249
+ });
250
+ }
251
+ //#endregion
252
+ export { createDelegateAgentTool, createInvokeAgentTool };
253
+
254
+ //# sourceMappingURL=invoke.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoke.mjs","names":[],"sources":["../../src/eve/invoke.ts"],"sourcesContent":["import { defineTool, type ToolContext, type ToolDefinition } from \"eve/tools\";\nimport { z } from \"zod\";\nimport {\n agentRouteBindingSchema,\n parseAgentRouteBinding,\n routeTaskWork,\n type AgentRoute,\n type AgentRouteBinding,\n type AgentRouteRegistry,\n} from \"../agent-routes\";\nimport { dispatchTask, type DispatchBudget } from \"../dispatch\";\nimport type { MaybePromise, ReplyTo } from \"../schema/common\";\nimport {\n changeIdSchema,\n repositoryIdsSchema,\n signalIdSchema,\n taskIdSchema,\n type ChangeId,\n type RepositoryId,\n type RepositoryIds,\n type SignalId,\n type TaskId,\n} from \"../schema/id\";\nimport type { ExecutionReference, Task, TaskKind, TaskState } from \"../schema/task\";\nimport type { FactoryStores } from \"../store/engine\";\nimport {\n optionalTaskIdForSession,\n repositoryIdsForSession,\n replyToForSession,\n} from \"./task-session\";\nimport { startEveSession } from \"./session-client\";\n\n/** Graph, receipt, and Task capabilities required by the fixed-route invocation tool. */\nexport type InvokeAgentToolStores = Pick<FactoryStores, \"graphs\" | \"receipts\" | \"tasks\">;\n\n/** Durable capabilities required by route-based agent delegation. */\nexport type DelegateAgentToolStores = Pick<\n FactoryStores,\n \"changes\" | \"graphs\" | \"receipts\" | \"repositories\" | \"signals\" | \"tasks\" | \"work\"\n>;\n\n/** Configures one fixed agent handoff route and its authenticated Eve session boundary. */\nexport interface InvokeAgentToolOptions {\n /** Application-selected exact route for this handoff. */\n route: AgentRoute;\n /** Model-facing description of what the target agent does and when to invoke it. */\n description: string;\n /**\n * Base URL of the target agent's eve transport, e.g.\n * `https://factory.example.com/eve/agents/verifier`. Resolved at call time so\n * a deployment can derive it from its own origin.\n */\n targetUrl: () => string;\n /** Bearer token for the target agent's eve channel, when it requires auth. */\n token?: () => MaybePromise<string | undefined>;\n /** Extra headers for the session request, e.g. a deployment protection bypass. */\n headers?: (task: Task) => MaybePromise<HeadersInit>;\n /**\n * Reserve-before-execution limits for the handoff dispatch, resolved at\n * call time. Without it, handoff tasks run outside the budget.\n */\n budget?: () => DispatchBudget | undefined;\n fetch?: typeof fetch;\n}\n\n/** Scope, lineage, reply destination, and brief supplied to a fixed-route handoff. */\nexport interface InvokeAgentToolInput {\n repositoryIds: RepositoryIds;\n parentTaskId?: TaskId;\n changeId?: ChangeId;\n channel: string;\n address: string;\n brief: string;\n}\n\n/** Durable Task identity and lifecycle returned after a fixed-route handoff launches. */\nexport interface InvokeAgentToolResult {\n readonly taskId: TaskId;\n readonly kind: TaskKind;\n readonly state: TaskState;\n}\n\n/** Eve tool that launches work through one configured exact agent route. */\nexport interface InvokeAgentTool extends ToolDefinition<\n InvokeAgentToolInput,\n InvokeAgentToolResult\n> {\n execute(input: InvokeAgentToolInput, ctx: ToolContext): Promise<InvokeAgentToolResult>;\n}\n\ninterface DelegateAgentToolCommonOptions {\n routes: AgentRouteRegistry;\n /** Retry bound for application-owned routes with a reconciler; default is one launch. */\n maxLaunchAttempts?: (route: AgentRoute) => number;\n budget?: (route: AgentRoute) => DispatchBudget | undefined;\n /** Application workflow policy that may replace single-task delegation. */\n workflow?: DelegateWorkflowPolicy;\n}\n\n/** Identifies one validated delegated Task launch on its exact registered route. */\nexport interface DelegateAgentLaunchInput {\n readonly task: Task;\n readonly route: AgentRoute;\n readonly brief: string;\n}\n\n/** Delegation mode whose application owns the provider launch boundary. */\ninterface DelegateAgentCustomLaunchOptions extends DelegateAgentToolCommonOptions {\n /** Application execution boundary, after route, scope, approval, and budget validation. */\n launch(input: DelegateAgentLaunchInput): Promise<ExecutionReference>;\n targetUrl?: never;\n token?: never;\n headers?: never;\n fetch?: never;\n}\n\n/** Delegation mode that starts a fresh session through an Eve HTTP endpoint. */\ninterface DelegateAgentEveLaunchOptions extends DelegateAgentToolCommonOptions {\n launch?: never;\n targetUrl(route: AgentRoute): string;\n token?: (route: AgentRoute) => MaybePromise<string | undefined>;\n headers?: (task: Task, route: AgentRoute) => MaybePromise<HeadersInit>;\n fetch?: typeof fetch;\n}\n\n/** Configures route-based delegation with one explicit launch mode and workflow policy. */\nexport type DelegateAgentToolOptions =\n | DelegateAgentCustomLaunchOptions\n | DelegateAgentEveLaunchOptions;\n\n/** Exact route, scope, provenance, and brief supplied to bounded agent delegation. */\nexport interface DelegateAgentToolInput {\n route: AgentRouteBinding;\n repositoryIds: RepositoryIds;\n signalId?: SignalId;\n parentTaskId?: TaskId;\n changeId?: ChangeId;\n channel: string;\n address: string;\n brief: string;\n}\n\n/** Trusted context supplied to an application-owned delegation workflow policy. */\nexport interface DelegateWorkflowInput {\n stores: DelegateAgentToolStores;\n route: AgentRoute;\n repositoryIds: readonly RepositoryId[];\n signalId?: SignalId;\n parentTaskId?: TaskId;\n changeId?: ChangeId;\n replyTo: ReplyTo;\n brief: string;\n operator: string;\n dispatch(task: Task): Promise<Task>;\n}\n\n/** Identifies the durable work and exact agent route selected by a delegation policy. */\nexport interface DelegateWorkflowResult {\n readonly taskId: TaskId;\n readonly childTaskIds?: readonly TaskId[];\n readonly route: AgentRouteBinding;\n readonly agent: string;\n readonly state: Task[\"state\"];\n}\n\n/** Eve tool that delegates durable work through a registered exact agent route. */\nexport interface DelegateAgentTool extends ToolDefinition<\n DelegateAgentToolInput,\n DelegateWorkflowResult\n> {\n execute(input: DelegateAgentToolInput, ctx: ToolContext): Promise<DelegateWorkflowResult>;\n}\n\n/** Application policy that may replace ordinary single-Task delegation with a workflow. */\nexport type DelegateWorkflowPolicy = (\n input: DelegateWorkflowInput,\n) => Promise<DelegateWorkflowResult | null>;\n\n/**\n * A tool that lets one agent hand work to another, NMA-style: the caller\n * decides to invoke; trusted code owns the how. The handoff is recorded as a\n * factory task (single-winner dispatch, receipts), then a fresh session is\n * started on the target agent carrying only the task id — never the caller's\n * context. The session start is create-once on the task attempt, so a retried\n * launch cannot duplicate that attempt while a later attempt starts fresh.\n */\nexport function createInvokeAgentTool(\n stores: InvokeAgentToolStores,\n options: InvokeAgentToolOptions,\n): InvokeAgentTool {\n const doFetch = options.fetch ?? fetch;\n return defineTool({\n description: `${options.description} Hands the work to a separate agent in a fresh session; you will not see its reasoning. Returns the handoff task id.`,\n inputSchema: z.object({\n repositoryIds: repositoryIdsSchema,\n parentTaskId: taskIdSchema.optional().describe(\"Your own task, when this work continues it.\"),\n changeId: changeIdSchema.optional().describe(\"The change the target agent should work on.\"),\n channel: z.string().min(1).describe(\"Reply connector, e.g. github.\"),\n address: z.string().min(1).describe(\"Reply address, e.g. acme/web#41.\"),\n brief: z\n .string()\n .min(1)\n .max(4000)\n .describe(\n \"What the target agent needs to know. Facts and references only, not your reasoning.\",\n ),\n }),\n async execute(input) {\n const taskInput = {\n repositoryIds: input.repositoryIds,\n kind: options.route.taskKind,\n work: routeTaskWork({\n route: options.route,\n title: input.brief.trim().slice(0, 256),\n input: {\n brief: input.brief,\n },\n }),\n changeId: input.changeId,\n replyTo: { channel: input.channel, address: input.address },\n };\n const task = await stores.tasks.create(\n input.parentTaskId === undefined\n ? { ...taskInput, origin: { operator: \"factory\" } }\n : { ...taskInput, origin: {}, parentTaskId: input.parentTaskId },\n );\n\n const running = await dispatchTask(stores, {\n taskId: task.id,\n route: options.route,\n // Handoffs are launched by the caller, not the sweep, so a refused\n // session must fail now — no sweep would pick a re-queued handoff up.\n maxLaunchAttempts: 1,\n budget: options.budget?.(),\n launch: async (dispatched) => {\n const headers = new Headers(await options.headers?.(dispatched));\n headers.set(\"content-type\", \"application/json\");\n const token = await options.token?.();\n if (token !== undefined) {\n headers.set(\"authorization\", `Bearer ${token}`);\n }\n const message = [\n `You are assigned factory task ${dispatched.id}.`,\n input.changeId === undefined ? null : `Change under review: ${input.changeId}.`,\n `Reply address: ${input.channel} ${input.address}.`,\n \"\",\n input.brief,\n \"\",\n \"Read the task with get_task first, do the work, and record the outcome with your factory tools.\",\n ]\n .filter((line) => line !== null)\n .join(\"\\n\");\n return startEveSession({\n agentUrl: options.targetUrl(),\n agentName: \"target agent\",\n headers,\n message,\n operationId: `factory-task:${dispatched.id}:${dispatched.attempt}`,\n fetch: doFetch,\n });\n },\n });\n\n return { taskId: running.id, kind: running.kind, state: running.state };\n },\n });\n}\n\n/**\n * Give a conversational agent one bounded delegation surface backed by the\n * application's route registry. The caller selects a declared route; trusted\n * code owns task creation, budget enforcement, and the fresh target session.\n */\nexport function createDelegateAgentTool(\n stores: DelegateAgentToolStores,\n options: DelegateAgentToolOptions,\n): DelegateAgentTool {\n const doFetch = options.fetch ?? fetch;\n const routeSummary = options.routes.routes\n .map((route) => `${route.id}@${route.version}: ${route.description}`)\n .join(\"\\n\");\n return defineTool({\n description:\n \"Delegate durable work to one registered specialist. Select only a listed route; \" +\n \"the specialist runs independently and reports its result through Factory.\\n\" +\n routeSummary,\n inputSchema: z.object({\n route: agentRouteBindingSchema.describe(\n \"Exact route id and version listed in this tool's description.\",\n ),\n repositoryIds: repositoryIdsSchema.refine(\n (repositoryIds) => new Set(repositoryIds).size === repositoryIds.length,\n \"Repository ids must be unique.\",\n ),\n signalId: signalIdSchema\n .optional()\n .describe(\"Pending external signal this delegation accepts.\"),\n parentTaskId: taskIdSchema.optional().describe(\"Existing task this work continues.\"),\n changeId: changeIdSchema\n .optional()\n .describe(\"Existing change the specialist should inspect.\"),\n channel: z.string().min(1).describe(\"Originating conversation channel.\"),\n address: z.string().min(1).describe(\"Originating conversation reply address.\"),\n brief: z\n .string()\n .min(1)\n .max(4000)\n .describe(\"Facts and desired outcome, without hidden reasoning.\"),\n }),\n async execute(input, ctx) {\n const route = options.routes.get(input.route);\n if (route === undefined) {\n throw new Error(`Unknown agent route ${input.route.id}@${input.route.version}.`);\n }\n const replyTo = { channel: input.channel, address: input.address };\n const auth = ctx.session.auth.initiator;\n const attributes = auth?.attributes;\n const boundSignal = signalIdSchema.safeParse(attributes?.factorySignalId);\n if (attributes?.factorySignalId !== undefined && !boundSignal.success)\n throw new Error(\"Connector-authenticated Signal context is invalid.\");\n if (\n boundSignal.success &&\n input.signalId !== undefined &&\n input.signalId !== boundSignal.data\n )\n throw new Error(\"Delegation must accept its authenticated Signal.\");\n const signalId = input.signalId ?? (boundSignal.success ? boundSignal.data : undefined);\n const boundRepositoryIds = repositoryIdsForSession(auth);\n if (\n boundRepositoryIds !== null &&\n input.repositoryIds.some((id) => !boundRepositoryIds.includes(id))\n ) {\n throw new Error(\n \"Delegation includes a repository outside the connector-authenticated context.\",\n );\n }\n const boundReplyTo = replyToForSession(auth);\n if (\n boundReplyTo !== null &&\n (boundReplyTo.channel !== replyTo.channel || boundReplyTo.address !== replyTo.address)\n ) {\n throw new Error(\"Delegation reply address does not match the authenticated conversation.\");\n }\n for (const repositoryId of input.repositoryIds) {\n const repository = await stores.repositories.get(repositoryId);\n if (repository === null || !repository.enabled) {\n throw new Error(`Repository ${repositoryId} is not enabled in this factory.`);\n }\n }\n const boundChange = changeIdSchema.safeParse(attributes?.factoryChangeId);\n if (attributes?.factoryChangeId !== undefined && !boundChange.success) {\n throw new Error(\"Connector-authenticated change context is invalid.\");\n }\n if (\n input.changeId !== undefined &&\n boundChange.success &&\n input.changeId !== boundChange.data\n ) {\n throw new Error(\"Delegated change does not match the connector-authenticated context.\");\n }\n const changeId = input.changeId ?? (boundChange.success ? boundChange.data : undefined);\n if (changeId !== undefined) {\n if (input.repositoryIds.length !== 1) {\n throw new Error(\"Delegating work on an existing Change requires exactly one repository.\");\n }\n const change = await stores.changes.get(changeId);\n if (\n change === null ||\n change.repositoryId !== input.repositoryIds[0] ||\n (change.state !== \"verifying\" && change.state !== \"ready\")\n ) {\n throw new Error(\n `Change ${changeId} is not an open pull request in the selected repository.`,\n );\n }\n }\n if (signalId !== undefined) {\n const signal = await stores.signals.get(signalId);\n if (signal === null) throw new Error(`Signal ${signalId} does not exist.`);\n if (\n boundSignal.success &&\n (signal.triage?.attempt !== Number(attributes?.factorySignalAttempt) ||\n signal.triage?.state !== \"running\" ||\n (signal.triage.sessionId !== undefined && signal.triage.sessionId !== ctx.session.id))\n )\n throw new Error(\"Delegation requires the current running Signal triage attempt.\");\n if (\n !input.repositoryIds.includes(signal.repositoryId) ||\n signal.replyTo.channel !== replyTo.channel ||\n signal.replyTo.address !== replyTo.address\n ) {\n throw new Error(\n \"Delegation does not match the signal's authenticated repository and reply address.\",\n );\n }\n if (signal.outcome !== \"pending\" && signal.outcome !== \"accepted\") {\n throw new Error(`Signal ${signal.id} is already ${signal.outcome}.`);\n }\n }\n const acceptSignal = async () => {\n if (signalId === undefined) return;\n const signal = await stores.signals.get(signalId);\n if (signal?.outcome === \"accepted\") return;\n await stores.signals.decide(signalId, {\n outcome: \"accepted\",\n reason: `Foreman selected ${route.id}.`,\n });\n };\n let parentTaskId = input.parentTaskId;\n const boundTaskId = optionalTaskIdForSession(auth);\n if (boundTaskId !== null && boundReplyTo?.channel === \"api\") {\n const boundTask = await stores.tasks.get(boundTaskId);\n if (boundTask?.area === \"conversation\") {\n if (parentTaskId !== undefined && parentTaskId !== boundTask.id)\n throw new Error(\n \"Follow-up delegation must name its authenticated conversation task as parent.\",\n );\n parentTaskId = boundTask.id;\n }\n }\n const initiator = ctx.session.auth.initiator;\n const operator = initiator?.principalId ?? \"foreman\";\n const workflowResult = await options.workflow?.({\n stores,\n route,\n repositoryIds: input.repositoryIds,\n signalId,\n parentTaskId,\n changeId,\n replyTo,\n brief: input.brief,\n operator,\n dispatch: (task) =>\n dispatchRouteTask(stores, options, doFetch, route, task, changeId, input.brief),\n });\n if (workflowResult !== undefined && workflowResult !== null) {\n await acceptSignal();\n return workflowResult;\n }\n const taskInput = {\n repositoryIds: input.repositoryIds,\n kind: route.taskKind,\n work: routeTaskWork({\n route: route,\n title: input.brief.trim().slice(0, 256),\n input: { brief: input.brief },\n }),\n replyTo,\n changeId,\n ...(signalId === undefined\n ? {}\n : { dedupeKey: `route:${signalId}:${route.id}:${route.version}` }),\n };\n const task = await stores.tasks.create(\n parentTaskId !== undefined\n ? { ...taskInput, parentTaskId, origin: {} }\n : signalId !== undefined\n ? { ...taskInput, origin: { signalId } }\n : { ...taskInput, origin: { operator } },\n );\n await acceptSignal();\n const running =\n task.state === \"queued\"\n ? await dispatchRouteTask(stores, options, doFetch, route, task, changeId, input.brief)\n : task;\n return {\n taskId: running.id,\n route: parseAgentRouteBinding({ id: route.id, version: route.version }),\n agent: route.agent,\n state: running.state,\n };\n },\n });\n}\n\nasync function dispatchRouteTask(\n stores: DelegateAgentToolStores,\n options: DelegateAgentToolOptions,\n doFetch: typeof fetch,\n route: AgentRoute,\n task: Task,\n changeId: ChangeId | undefined,\n brief: string,\n): Promise<Task> {\n return dispatchTask(stores, {\n taskId: task.id,\n route,\n maxLaunchAttempts: options.maxLaunchAttempts?.(route) ?? 1,\n budget: options.budget?.(route),\n launch: async (dispatched) => {\n if (options.launch) return options.launch({ task: dispatched, route, brief });\n const headers = new Headers(await options.headers?.(dispatched, route));\n headers.set(\"content-type\", \"application/json\");\n const token = await options.token?.(route);\n if (token !== undefined) headers.set(\"authorization\", `Bearer ${token}`);\n const message = [\n `You are assigned factory task ${dispatched.id} through route ${route.id}.`,\n changeId === undefined ? null : `Change under review: ${changeId}.`,\n brief,\n \"Read the task first and return exactly one bounded Factory outcome.\",\n ]\n .filter((line) => line !== null)\n .join(\"\\n\\n\");\n return startEveSession({\n agentUrl: options.targetUrl(route),\n agentName: route.agent,\n headers,\n message,\n operationId: `factory-task:${dispatched.id}:${dispatched.attempt}`,\n fetch: doFetch,\n });\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA0LA,SAAgB,sBACd,QACA,SACiB;CACjB,MAAM,UAAU,QAAQ,SAAS;CACjC,OAAO,WAAW;EAChB,a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AAM,kBAAkB,QAAQ,SAAS,SAAS,OAAO,MAAM,UAAU,MAAM,KAAK,IACpF;GACN,OAAO;IACL,QAAQ,QAAQ;IAChB,OAAO,uBAAuB;KAAE,IAAI,MAAM;KAAI,SAAS,MAAM;IAAQ,CAAC;IACtE,OAAO,MAAM;IACb,OAAO,QAAQ;GACjB;EACF;CACF,CAAC;AACH;AAEA,eAAe,kBACb,QACA,SACA,SACA,OACA,MACA,UACA,OACe;CACf,OAAO,aAAa,QAAQ;EAC1B,QAAQ,KAAK;EACb;EACA,mBAAmB,QAAQ,oBAAoB,KAAK,KAAK;EACzD,QAAQ,QAAQ,SAAS,KAAK;EAC9B,QAAQ,OAAO,eAAe;GAC5B,IAAI,QAAQ,QAAQ,OAAO,QAAQ,OAAO;IAAE,MAAM;IAAY;IAAO;GAAM,CAAC;GAC5E,MAAM,UAAU,IAAI,QAAQ,MAAM,QAAQ,UAAU,YAAY,KAAK,CAAC;GACtE,QAAQ,IAAI,gBAAgB,kBAAkB;GAC9C,MAAM,QAAQ,MAAM,QAAQ,QAAQ,KAAK;GACzC,IAAI,UAAU,KAAA,GAAW,QAAQ,IAAI,iBAAiB,UAAU,OAAO;GACvE,MAAM,UAAU;IACd,iCAAiC,WAAW,GAAG,iBAAiB,MAAM,GAAG;IACzE,aAAa,KAAA,IAAY,OAAO,wBAAwB,SAAS;IACjE;IACA;GACF,CAAC,CACE,QAAQ,SAAS,SAAS,IAAI,CAAC,CAC/B,KAAK,MAAM;GACd,OAAO,gBAAgB;IACrB,UAAU,QAAQ,UAAU,KAAK;IACjC,WAAW,MAAM;IACjB;IACA;IACA,aAAa,gBAAgB,WAAW,GAAG,GAAG,WAAW;IACzD,OAAO;GACT,CAAC;EACH;CACF,CAAC;AACH"}
@@ -0,0 +1,186 @@
1
+ import { ExecutionReference } from "../schema/task.mjs";
2
+ import { MaybePromise } from "../schema/common.mjs";
3
+ //#region src/eve/session-client.d.ts
4
+ /** The minimal event shape consumed from an Eve session stream. */
5
+ interface EveSessionEvent {
6
+ /** Eve protocol event discriminator. */
7
+ type: string;
8
+ /** Provider payload retained as unknown until the consuming operation validates required fields. */
9
+ data?: unknown;
10
+ }
11
+ /** Identifies and bounds a direct read of one Eve session event stream. */
12
+ interface EveSessionStreamInput {
13
+ /** Base URL of the selected Eve agent. */
14
+ agentUrl: string;
15
+ /** Exact provider session whose ordered event log is read. */
16
+ sessionId: string;
17
+ /** Authentication and Factory binding headers for the stream request. */
18
+ headers: HeadersInit;
19
+ /** Cancellation or deadline signal that bounds the stream read. */
20
+ signal: AbortSignal;
21
+ /** Inclusive provider event index, or `-1` for the latest event. */
22
+ startIndex: number;
23
+ /** Whether the stream waits for events appended after the current end. */
24
+ follow: boolean;
25
+ }
26
+ /** Injectable reader for an Eve session's ordered event stream. */
27
+ type EveSessionStream = (input: EveSessionStreamInput) => AsyncIterable<EveSessionEvent>;
28
+ /** Configures an idempotent request to start or reconnect to an Eve session. */
29
+ interface StartEveSessionOptions {
30
+ /** Base URL of the selected Eve agent; trailing slashes are ignored. */
31
+ agentUrl: string;
32
+ /** Initial user message serialized into Eve's session-create request. */
33
+ message: unknown;
34
+ /** Stable application idempotency key reused when reconnecting the same logical launch. */
35
+ operationId: string;
36
+ /** Authentication and Factory binding headers, resolved immediately before the request. */
37
+ headers?: MaybePromise<HeadersInit>;
38
+ /**
39
+ * HTTP implementation. Defaults to `globalThis.fetch`. Transport rejections propagate; a launch
40
+ * adapter that owns durable recovery must translate ambiguous acceptance at its boundary.
41
+ */
42
+ fetch?: typeof globalThis.fetch;
43
+ /** Request deadline in milliseconds. Defaults to 20,000. */
44
+ timeoutMs?: number;
45
+ /** Human-readable agent name included in refusal diagnostics. Defaults to `Eve agent`. */
46
+ agentName?: string;
47
+ }
48
+ /**
49
+ * Starts or reconnects to one Eve session through its idempotent HTTP boundary.
50
+ *
51
+ * @remarks
52
+ * This call sends one POST to the selected agent's `/eve/v1/session` endpoint. Reusing
53
+ * `operationId` asks Eve to return the same logical session rather than create duplicate work.
54
+ * The returned execution reference identifies provider acceptance only; Factory dispatch must
55
+ * still persist it, and the agent must later complete or otherwise advance its Task.
56
+ *
57
+ * An HTTP refusal throws a regular error with the status. A successful response without a usable
58
+ * session ID throws `ExecutionLaunchPendingError`, because the provider may have accepted work and
59
+ * recovery must use the same operation ID. Request timeouts and transport failures propagate
60
+ * unchanged because this transport helper does not own a durable retry loop. A launcher that can
61
+ * recover the same running attempt must translate an ambiguous transport failure to
62
+ * `ExecutionLaunchPendingError` at that boundary and retry with the same operation ID.
63
+ *
64
+ * @param options - Agent URL, initial message, stable operation ID, and optional request controls.
65
+ * @returns An Eve execution reference containing the accepted session ID.
66
+ * @throws `ExecutionLaunchPendingError` after an accepted response without a session ID, and a
67
+ * regular error on timeout, transport failure, HTTP refusal, or invalid input.
68
+ * @see The shipped `docs/recipes/eve-agent.md` recipe for the complete dispatch boundary.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * import { startEveSession, taskHeaders } from "@vercel/factory";
73
+ * import type { TaskAttemptRef } from "@vercel/factory/execution";
74
+ *
75
+ * declare const task: TaskAttemptRef;
76
+ * const execution = await startEveSession({
77
+ * agentUrl: "https://factory.example/eve/agents/worker",
78
+ * message: `Work Task ${task.taskId}`,
79
+ * operationId: `factory-task:${task.taskId}:${task.attempt}`,
80
+ * headers: taskHeaders(task),
81
+ * });
82
+ * ```
83
+ */
84
+ declare function startEveSession(options: StartEveSessionOptions): Promise<ExecutionReference>;
85
+ /** Configures forwarding an authorized HTTP request to one exact Eve session. */
86
+ interface ForwardEveSessionRequestOptions {
87
+ /** Base URL of the selected Eve agent; trailing slashes are ignored. */
88
+ agentUrl: string;
89
+ /** Exact provider session that owns the forwarded Factory API request. */
90
+ sessionId: string;
91
+ /** Empty for the session endpoint, otherwise an absolute path/query suffix within it; fragments are refused. */
92
+ path: string;
93
+ /** Incoming request supplying method, abort signal, and POST body. */
94
+ source: Request;
95
+ /** Authentication and Factory binding headers, resolved immediately before forwarding. */
96
+ headers?: MaybePromise<HeadersInit>;
97
+ /** HTTP implementation. Defaults to `globalThis.fetch`. */
98
+ fetch?: typeof globalThis.fetch;
99
+ }
100
+ /**
101
+ * Forwards one authorized Factory API request to its exact Eve session.
102
+ *
103
+ * @remarks
104
+ * The caller must authenticate and authorize the source request before invoking this helper. It
105
+ * forwards the source method, abort signal, and POST body using the supplied binding headers, then
106
+ * returns Eve's response unchanged. It does not interpret non-success status codes, retry the
107
+ * request, or update Factory Task state, so callers retain operation-specific response and replay
108
+ * handling.
109
+ *
110
+ * @param options - Exact Eve session, path, authorized source request, and transport controls.
111
+ * @returns The unconsumed response from the Eve session endpoint.
112
+ * @throws When a nonempty path is not absolute, resolves outside the session, contains a fragment,
113
+ * or the request transport fails.
114
+ */
115
+ declare function forwardEveSessionRequest(options: ForwardEveSessionRequestOptions): Promise<Response>;
116
+ /** Configures cancellation and provider-stream confirmation for one exact Eve session. */
117
+ interface CancelEveSessionOptions {
118
+ /** Base URL of the selected Eve agent; trailing slashes are ignored. */
119
+ agentUrl: string;
120
+ /** Exact provider session to cancel and observe. */
121
+ sessionId: string;
122
+ /** Authentication and Factory binding headers used for cancellation and confirmation. */
123
+ headers?: MaybePromise<HeadersInit>;
124
+ /** HTTP implementation. Defaults to `globalThis.fetch`. */
125
+ fetch?: typeof globalThis.fetch;
126
+ /** Cancellation request deadline in milliseconds. Defaults to 10,000. */
127
+ requestTimeoutMs?: number;
128
+ /** Provider-stream confirmation deadline in milliseconds. Defaults to 5,000. */
129
+ confirmationTimeoutMs?: number;
130
+ /** Injectable ordered event reader. Defaults to the Eve client stream. */
131
+ stream?: EveSessionStream;
132
+ }
133
+ /**
134
+ * Requests cancellation and confirms that the exact Eve session has stopped running.
135
+ *
136
+ * @remarks
137
+ * A successful cancellation response is not sufficient by itself. Unless Eve reports
138
+ * `no_active_turn`, this helper follows from the latest provider event and returns only after
139
+ * observing `session.waiting`, `session.completed`, or `session.failed`. A refusal, timeout, stream
140
+ * failure, or non-confirming event throws; the caller should keep canonical Task cancellation and
141
+ * retry or inspect this same session rather than assume it stopped.
142
+ *
143
+ * This helper does not transition or settle a Factory Task. Use the higher-level execution
144
+ * cancellation flow when Task lifecycle and usage must be persisted together.
145
+ *
146
+ * @param options - Exact Eve session plus request and confirmation bounds.
147
+ * @returns After the provider confirms that the session has no active turn.
148
+ * @throws On HTTP refusal, request or confirmation timeout, stream failure, or missing confirmation.
149
+ */
150
+ declare function cancelEveSession(options: CancelEveSessionOptions): Promise<void>;
151
+ /** Configures a bounded scan for the response from the latest completed Eve turn. */
152
+ interface ReadCompletedEveTurnOptions {
153
+ /** Base URL of the selected Eve agent; trailing slashes are ignored. */
154
+ agentUrl: string;
155
+ /** Exact provider session whose finite event history is scanned. */
156
+ sessionId: string;
157
+ /** Authentication and Factory binding headers for the stream request. */
158
+ headers?: MaybePromise<HeadersInit>;
159
+ /** Event-stream read deadline in milliseconds. Defaults to 10,000. */
160
+ timeoutMs?: number;
161
+ /** Maximum events inspected before returning `null`. Defaults to 10,000. */
162
+ maxEvents?: number;
163
+ /** HTTP implementation used by the default bounded stream reader. Defaults to `globalThis.fetch`. */
164
+ fetch?: typeof globalThis.fetch;
165
+ /** Injectable ordered event reader; it must propagate transport failures to preserve certainty. */
166
+ stream?: EveSessionStream;
167
+ }
168
+ /**
169
+ * Reads the response from the latest fully completed Eve turn, if one exists.
170
+ *
171
+ * @remarks
172
+ * This performs a bounded, non-following scan from the start of the session. It returns a nonempty
173
+ * completed message only when the matching latest turn reaches `turn.completed`; failed,
174
+ * cancelled, incomplete, over-limit, or message-less turns return `null`. The operation is
175
+ * read-only and safe to repeat. The default reader verifies that it reached Eve's advertised
176
+ * durable tail before accepting output. Transport and timeout failures are propagated so callers
177
+ * can distinguish unavailable or truncated history from a confirmed lack of completed output.
178
+ *
179
+ * @param options - Exact Eve session plus stream deadline and event bound.
180
+ * @returns The latest completed turn response, or `null` when no bounded complete response exists.
181
+ * @throws When the event stream cannot be read or its deadline expires.
182
+ */
183
+ declare function readCompletedEveTurn(options: ReadCompletedEveTurnOptions): Promise<string | null>;
184
+ //#endregion
185
+ export { CancelEveSessionOptions, EveSessionEvent, EveSessionStream, EveSessionStreamInput, ForwardEveSessionRequestOptions, ReadCompletedEveTurnOptions, StartEveSessionOptions, cancelEveSession, forwardEveSessionRequest, readCompletedEveTurn, startEveSession };
186
+ //# sourceMappingURL=session-client.d.mts.map