@0xmaxma/claude-gateway 2.0.10 → 2.0.12

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 (356) hide show
  1. package/README.md +15 -0
  2. package/config.template.json +1 -1
  3. package/dist/agent/runner.d.ts +119 -11
  4. package/dist/agent/runner.d.ts.map +1 -1
  5. package/dist/agent/runner.js +58 -8
  6. package/dist/agent/runner.js.map +1 -1
  7. package/dist/api/browser-bindings-router.d.ts +6 -0
  8. package/dist/api/browser-bindings-router.d.ts.map +1 -0
  9. package/dist/api/browser-bindings-router.js +150 -0
  10. package/dist/api/browser-bindings-router.js.map +1 -0
  11. package/dist/api/connectors-router.js +1 -1
  12. package/dist/api/connectors-router.js.map +1 -1
  13. package/dist/api/gateway-router.d.ts.map +1 -1
  14. package/dist/api/gateway-router.js +30 -2
  15. package/dist/api/gateway-router.js.map +1 -1
  16. package/dist/api/jev-router.d.ts +8 -0
  17. package/dist/api/jev-router.d.ts.map +1 -0
  18. package/dist/api/jev-router.js +128 -0
  19. package/dist/api/jev-router.js.map +1 -0
  20. package/dist/api/router.d.ts.map +1 -1
  21. package/dist/api/router.js +53 -6
  22. package/dist/api/router.js.map +1 -1
  23. package/dist/api/voice-router.d.ts.map +1 -1
  24. package/dist/api/voice-router.js +42 -3
  25. package/dist/api/voice-router.js.map +1 -1
  26. package/dist/automation/browser-command.d.ts +79 -0
  27. package/dist/automation/browser-command.d.ts.map +1 -0
  28. package/dist/automation/browser-command.js +118 -0
  29. package/dist/automation/browser-command.js.map +1 -0
  30. package/dist/automation/browser-outcome.d.ts +3 -0
  31. package/dist/automation/browser-outcome.d.ts.map +1 -0
  32. package/dist/automation/browser-outcome.js +78 -0
  33. package/dist/automation/browser-outcome.js.map +1 -0
  34. package/dist/automation/browser-steps.d.ts +33 -0
  35. package/dist/automation/browser-steps.d.ts.map +1 -0
  36. package/dist/automation/browser-steps.js +293 -0
  37. package/dist/automation/browser-steps.js.map +1 -0
  38. package/dist/automation/browser-trace.d.ts +60 -0
  39. package/dist/automation/browser-trace.d.ts.map +1 -0
  40. package/dist/automation/browser-trace.js +24 -0
  41. package/dist/automation/browser-trace.js.map +1 -0
  42. package/dist/automation/browser-use.d.ts +210 -0
  43. package/dist/automation/browser-use.d.ts.map +1 -0
  44. package/dist/automation/browser-use.js +1271 -0
  45. package/dist/automation/browser-use.js.map +1 -0
  46. package/dist/automation/command-speech.d.ts +33 -0
  47. package/dist/automation/command-speech.d.ts.map +1 -0
  48. package/dist/automation/command-speech.js +117 -0
  49. package/dist/automation/command-speech.js.map +1 -0
  50. package/dist/automation/command-steps.d.ts +35 -0
  51. package/dist/automation/command-steps.d.ts.map +1 -0
  52. package/dist/automation/command-steps.js +155 -0
  53. package/dist/automation/command-steps.js.map +1 -0
  54. package/dist/automation/computer-choice-ids.d.ts +7 -0
  55. package/dist/automation/computer-choice-ids.d.ts.map +1 -0
  56. package/dist/automation/computer-choice-ids.js +24 -0
  57. package/dist/automation/computer-choice-ids.js.map +1 -0
  58. package/dist/automation/computer-command.d.ts +126 -0
  59. package/dist/automation/computer-command.d.ts.map +1 -0
  60. package/dist/automation/computer-command.js +313 -0
  61. package/dist/automation/computer-command.js.map +1 -0
  62. package/dist/automation/computer-outcome.d.ts +8 -0
  63. package/dist/automation/computer-outcome.d.ts.map +1 -0
  64. package/dist/automation/computer-outcome.js +82 -0
  65. package/dist/automation/computer-outcome.js.map +1 -0
  66. package/dist/automation/computer-policy.d.ts +84 -0
  67. package/dist/automation/computer-policy.d.ts.map +1 -0
  68. package/dist/automation/computer-policy.js +56 -0
  69. package/dist/automation/computer-policy.js.map +1 -0
  70. package/dist/automation/computer-safety.d.ts +27 -0
  71. package/dist/automation/computer-safety.d.ts.map +1 -0
  72. package/dist/automation/computer-safety.js +47 -0
  73. package/dist/automation/computer-safety.js.map +1 -0
  74. package/dist/automation/computer-steps.d.ts +20 -0
  75. package/dist/automation/computer-steps.d.ts.map +1 -0
  76. package/dist/automation/computer-steps.js +251 -0
  77. package/dist/automation/computer-steps.js.map +1 -0
  78. package/dist/automation/computer-use.d.ts +315 -0
  79. package/dist/automation/computer-use.d.ts.map +1 -0
  80. package/dist/automation/computer-use.js +864 -0
  81. package/dist/automation/computer-use.js.map +1 -0
  82. package/dist/automation/direct-command.d.ts +51 -0
  83. package/dist/automation/direct-command.d.ts.map +1 -0
  84. package/dist/automation/direct-command.js +152 -0
  85. package/dist/automation/direct-command.js.map +1 -0
  86. package/dist/automation/interrupt.d.ts +4 -0
  87. package/dist/automation/interrupt.d.ts.map +1 -0
  88. package/dist/automation/interrupt.js +26 -0
  89. package/dist/automation/interrupt.js.map +1 -0
  90. package/dist/build-provenance.json +4 -4
  91. package/dist/child-env-exclusions.d.ts +4 -0
  92. package/dist/child-env-exclusions.d.ts.map +1 -0
  93. package/dist/child-env-exclusions.js +23 -0
  94. package/dist/child-env-exclusions.js.map +1 -0
  95. package/dist/cli/startup-diagnostics.d.ts.map +1 -1
  96. package/dist/cli/startup-diagnostics.js +19 -0
  97. package/dist/cli/startup-diagnostics.js.map +1 -1
  98. package/dist/config/loader.d.ts.map +1 -1
  99. package/dist/config/loader.js +4 -0
  100. package/dist/config/loader.js.map +1 -1
  101. package/dist/config/reload-policy.d.ts.map +1 -1
  102. package/dist/config/reload-policy.js +2 -1
  103. package/dist/config/reload-policy.js.map +1 -1
  104. package/dist/jev/automatic-browser-bindings.d.ts +15 -0
  105. package/dist/jev/automatic-browser-bindings.d.ts.map +1 -0
  106. package/dist/jev/automatic-browser-bindings.js +115 -0
  107. package/dist/jev/automatic-browser-bindings.js.map +1 -0
  108. package/dist/jev/browser-connector.d.ts +29 -0
  109. package/dist/jev/browser-connector.d.ts.map +1 -0
  110. package/dist/jev/browser-connector.js +347 -0
  111. package/dist/jev/browser-connector.js.map +1 -0
  112. package/dist/jev/browser-consent.d.ts +6 -0
  113. package/dist/jev/browser-consent.d.ts.map +1 -0
  114. package/dist/jev/browser-consent.js +50 -0
  115. package/dist/jev/browser-consent.js.map +1 -0
  116. package/dist/jev/browser-contract.d.ts +215 -0
  117. package/dist/jev/browser-contract.d.ts.map +1 -0
  118. package/dist/jev/browser-contract.js +10 -0
  119. package/dist/jev/browser-contract.js.map +1 -0
  120. package/dist/jev/browser-evidence-summary.d.ts +73 -0
  121. package/dist/jev/browser-evidence-summary.d.ts.map +1 -0
  122. package/dist/jev/browser-evidence-summary.js +22 -0
  123. package/dist/jev/browser-evidence-summary.js.map +1 -0
  124. package/dist/jev/browser-module-import.d.ts +3 -0
  125. package/dist/jev/browser-module-import.d.ts.map +1 -0
  126. package/dist/jev/browser-module-import.js +6 -0
  127. package/dist/jev/browser-module-import.js.map +1 -0
  128. package/dist/jev/child-env.d.ts +11 -0
  129. package/dist/jev/child-env.d.ts.map +1 -0
  130. package/dist/jev/child-env.js +60 -0
  131. package/dist/jev/child-env.js.map +1 -0
  132. package/dist/jev/computer-connector.d.ts +34 -0
  133. package/dist/jev/computer-connector.d.ts.map +1 -0
  134. package/dist/jev/computer-connector.js +82 -0
  135. package/dist/jev/computer-connector.js.map +1 -0
  136. package/dist/jev/computer-inputs.d.ts +41 -0
  137. package/dist/jev/computer-inputs.d.ts.map +1 -0
  138. package/dist/jev/computer-inputs.js +7 -0
  139. package/dist/jev/computer-inputs.js.map +1 -0
  140. package/dist/jev/index.d.ts +6 -0
  141. package/dist/jev/index.d.ts.map +1 -0
  142. package/dist/jev/index.js +25 -0
  143. package/dist/jev/index.js.map +1 -0
  144. package/dist/jev/relay-grants.d.ts +9 -0
  145. package/dist/jev/relay-grants.d.ts.map +1 -0
  146. package/dist/jev/relay-grants.js +49 -0
  147. package/dist/jev/relay-grants.js.map +1 -0
  148. package/dist/jev/service.d.ts +27 -0
  149. package/dist/jev/service.d.ts.map +1 -0
  150. package/dist/jev/service.js +264 -0
  151. package/dist/jev/service.js.map +1 -0
  152. package/dist/jev/thinking-provider.d.ts +7 -0
  153. package/dist/jev/thinking-provider.d.ts.map +1 -0
  154. package/dist/jev/thinking-provider.js +25 -0
  155. package/dist/jev/thinking-provider.js.map +1 -0
  156. package/dist/jev/types.d.ts +124 -0
  157. package/dist/jev/types.d.ts.map +1 -0
  158. package/dist/jev/types.js +13 -0
  159. package/dist/jev/types.js.map +1 -0
  160. package/dist/jev/validation.d.ts +45 -0
  161. package/dist/jev/validation.d.ts.map +1 -0
  162. package/dist/jev/validation.js +179 -0
  163. package/dist/jev/validation.js.map +1 -0
  164. package/dist/load-dotenv.d.ts.map +1 -1
  165. package/dist/load-dotenv.js +5 -1
  166. package/dist/load-dotenv.js.map +1 -1
  167. package/dist/orchestration/agent-tool-schemas.d.ts.map +1 -1
  168. package/dist/orchestration/agent-tool-schemas.js +12 -7
  169. package/dist/orchestration/agent-tool-schemas.js.map +1 -1
  170. package/dist/orchestration/background-work.d.ts +1 -0
  171. package/dist/orchestration/background-work.d.ts.map +1 -1
  172. package/dist/orchestration/background-work.js +1 -0
  173. package/dist/orchestration/background-work.js.map +1 -1
  174. package/dist/orchestration/bridge.d.ts +4 -0
  175. package/dist/orchestration/bridge.d.ts.map +1 -1
  176. package/dist/orchestration/bridge.js +176 -41
  177. package/dist/orchestration/bridge.js.map +1 -1
  178. package/dist/orchestration/browser-fields.d.ts +25 -0
  179. package/dist/orchestration/browser-fields.d.ts.map +1 -0
  180. package/dist/orchestration/browser-fields.js +23 -0
  181. package/dist/orchestration/browser-fields.js.map +1 -0
  182. package/dist/orchestration/browser-routing.d.ts +1 -1
  183. package/dist/orchestration/browser-routing.d.ts.map +1 -1
  184. package/dist/orchestration/browser-routing.js +7 -3
  185. package/dist/orchestration/browser-routing.js.map +1 -1
  186. package/dist/orchestration/capabilities.d.ts +4 -1
  187. package/dist/orchestration/capabilities.d.ts.map +1 -1
  188. package/dist/orchestration/capabilities.js +15 -9
  189. package/dist/orchestration/capabilities.js.map +1 -1
  190. package/dist/orchestration/channel-controls.js +1 -1
  191. package/dist/orchestration/channel-controls.js.map +1 -1
  192. package/dist/orchestration/cli-skills.d.ts.map +1 -1
  193. package/dist/orchestration/cli-skills.js +3 -2
  194. package/dist/orchestration/cli-skills.js.map +1 -1
  195. package/dist/orchestration/computer-end-screenshot.d.ts +11 -0
  196. package/dist/orchestration/computer-end-screenshot.d.ts.map +1 -0
  197. package/dist/orchestration/computer-end-screenshot.js +37 -0
  198. package/dist/orchestration/computer-end-screenshot.js.map +1 -0
  199. package/dist/orchestration/computer-prompt.d.ts +6 -0
  200. package/dist/orchestration/computer-prompt.d.ts.map +1 -0
  201. package/dist/orchestration/computer-prompt.js +24 -0
  202. package/dist/orchestration/computer-prompt.js.map +1 -0
  203. package/dist/orchestration/config.d.ts +17 -0
  204. package/dist/orchestration/config.d.ts.map +1 -1
  205. package/dist/orchestration/config.js +10 -4
  206. package/dist/orchestration/config.js.map +1 -1
  207. package/dist/orchestration/container-tool-schemas.d.ts +47 -3
  208. package/dist/orchestration/container-tool-schemas.d.ts.map +1 -1
  209. package/dist/orchestration/container-tool-schemas.js +41 -6
  210. package/dist/orchestration/container-tool-schemas.js.map +1 -1
  211. package/dist/orchestration/container.d.ts +4 -1
  212. package/dist/orchestration/container.d.ts.map +1 -1
  213. package/dist/orchestration/container.js +48 -29
  214. package/dist/orchestration/container.js.map +1 -1
  215. package/dist/orchestration/context-footprint.d.ts +1 -1
  216. package/dist/orchestration/context-footprint.d.ts.map +1 -1
  217. package/dist/orchestration/context-footprint.js +5 -5
  218. package/dist/orchestration/context-footprint.js.map +1 -1
  219. package/dist/orchestration/control-notification.d.ts +6 -0
  220. package/dist/orchestration/control-notification.d.ts.map +1 -0
  221. package/dist/orchestration/control-notification.js +23 -0
  222. package/dist/orchestration/control-notification.js.map +1 -0
  223. package/dist/orchestration/dashboard-reader-worker.js +2 -2
  224. package/dist/orchestration/dashboard-reader-worker.js.map +1 -1
  225. package/dist/orchestration/execution-observation.d.ts +3 -0
  226. package/dist/orchestration/execution-observation.d.ts.map +1 -1
  227. package/dist/orchestration/execution-observation.js.map +1 -1
  228. package/dist/orchestration/gateway-tasks/browser.d.ts +59 -0
  229. package/dist/orchestration/gateway-tasks/browser.d.ts.map +1 -0
  230. package/dist/orchestration/gateway-tasks/browser.js +426 -0
  231. package/dist/orchestration/gateway-tasks/browser.js.map +1 -0
  232. package/dist/orchestration/gateway-tasks/computer-context.d.ts +6 -0
  233. package/dist/orchestration/gateway-tasks/computer-context.d.ts.map +1 -0
  234. package/dist/orchestration/gateway-tasks/computer-context.js +19 -0
  235. package/dist/orchestration/gateway-tasks/computer-context.js.map +1 -0
  236. package/dist/orchestration/gateway-tasks/computer.d.ts +123 -0
  237. package/dist/orchestration/gateway-tasks/computer.d.ts.map +1 -0
  238. package/dist/orchestration/gateway-tasks/computer.js +519 -0
  239. package/dist/orchestration/gateway-tasks/computer.js.map +1 -0
  240. package/dist/orchestration/gateway-tasks/controller.d.ts +40 -6
  241. package/dist/orchestration/gateway-tasks/controller.d.ts.map +1 -1
  242. package/dist/orchestration/gateway-tasks/controller.js +118 -12
  243. package/dist/orchestration/gateway-tasks/controller.js.map +1 -1
  244. package/dist/orchestration/gateway-tasks/safemode.d.ts.map +1 -1
  245. package/dist/orchestration/gateway-tasks/safemode.js +2 -1
  246. package/dist/orchestration/gateway-tasks/safemode.js.map +1 -1
  247. package/dist/orchestration/jev-gateway.d.ts +25 -0
  248. package/dist/orchestration/jev-gateway.d.ts.map +1 -0
  249. package/dist/orchestration/jev-gateway.js +103 -0
  250. package/dist/orchestration/jev-gateway.js.map +1 -0
  251. package/dist/orchestration/jev-tool.d.ts +45 -0
  252. package/dist/orchestration/jev-tool.d.ts.map +1 -0
  253. package/dist/orchestration/jev-tool.js +10 -0
  254. package/dist/orchestration/jev-tool.js.map +1 -0
  255. package/dist/orchestration/live-execution-input.d.ts +26 -0
  256. package/dist/orchestration/live-execution-input.d.ts.map +1 -0
  257. package/dist/orchestration/live-execution-input.js +70 -0
  258. package/dist/orchestration/live-execution-input.js.map +1 -0
  259. package/dist/orchestration/notification-mailbox.d.ts.map +1 -1
  260. package/dist/orchestration/notification-mailbox.js +5 -2
  261. package/dist/orchestration/notification-mailbox.js.map +1 -1
  262. package/dist/orchestration/process-platform.d.ts +0 -3
  263. package/dist/orchestration/process-platform.d.ts.map +1 -1
  264. package/dist/orchestration/process-platform.js +0 -4
  265. package/dist/orchestration/process-platform.js.map +1 -1
  266. package/dist/orchestration/process-turn.d.ts +8 -0
  267. package/dist/orchestration/process-turn.d.ts.map +1 -1
  268. package/dist/orchestration/process-turn.js +65 -8
  269. package/dist/orchestration/process-turn.js.map +1 -1
  270. package/dist/orchestration/response-errors.d.ts.map +1 -1
  271. package/dist/orchestration/response-errors.js +1 -0
  272. package/dist/orchestration/response-errors.js.map +1 -1
  273. package/dist/orchestration/runtime.d.ts +51 -1
  274. package/dist/orchestration/runtime.d.ts.map +1 -1
  275. package/dist/orchestration/runtime.js +383 -27
  276. package/dist/orchestration/runtime.js.map +1 -1
  277. package/dist/orchestration/skill-catalog-budget.d.ts +6 -0
  278. package/dist/orchestration/skill-catalog-budget.d.ts.map +1 -0
  279. package/dist/orchestration/skill-catalog-budget.js +9 -0
  280. package/dist/orchestration/skill-catalog-budget.js.map +1 -0
  281. package/dist/orchestration/skills.d.ts +4 -2
  282. package/dist/orchestration/skills.d.ts.map +1 -1
  283. package/dist/orchestration/skills.js +44 -3
  284. package/dist/orchestration/skills.js.map +1 -1
  285. package/dist/orchestration/store.d.ts +1 -0
  286. package/dist/orchestration/store.d.ts.map +1 -1
  287. package/dist/orchestration/store.js +2 -0
  288. package/dist/orchestration/store.js.map +1 -1
  289. package/dist/orchestration/task-controls.d.ts +78 -8
  290. package/dist/orchestration/task-controls.d.ts.map +1 -1
  291. package/dist/orchestration/task-controls.js +6 -1
  292. package/dist/orchestration/task-controls.js.map +1 -1
  293. package/dist/orchestration/tasks/automation-session.d.ts +25 -0
  294. package/dist/orchestration/tasks/automation-session.d.ts.map +1 -0
  295. package/dist/orchestration/tasks/automation-session.js +68 -0
  296. package/dist/orchestration/tasks/automation-session.js.map +1 -0
  297. package/dist/orchestration/tasks/driver.d.ts.map +1 -1
  298. package/dist/orchestration/tasks/driver.js +3 -2
  299. package/dist/orchestration/tasks/driver.js.map +1 -1
  300. package/dist/orchestration/tasks/service.d.ts +68 -7
  301. package/dist/orchestration/tasks/service.d.ts.map +1 -1
  302. package/dist/orchestration/tasks/service.js +646 -44
  303. package/dist/orchestration/tasks/service.js.map +1 -1
  304. package/dist/orchestration/types.d.ts +82 -3
  305. package/dist/orchestration/types.d.ts.map +1 -1
  306. package/dist/orchestration/types.js.map +1 -1
  307. package/dist/safemode/context.d.ts.map +1 -1
  308. package/dist/safemode/context.js +169 -72
  309. package/dist/safemode/context.js.map +1 -1
  310. package/dist/safemode/external-owners.d.ts +4 -1
  311. package/dist/safemode/external-owners.d.ts.map +1 -1
  312. package/dist/safemode/external-owners.js +36 -9
  313. package/dist/safemode/external-owners.js.map +1 -1
  314. package/dist/safemode/native.d.ts.map +1 -1
  315. package/dist/safemode/native.js +16 -10
  316. package/dist/safemode/native.js.map +1 -1
  317. package/dist/session/codex-extension-discovery.d.ts.map +1 -1
  318. package/dist/session/codex-extension-discovery.js +4 -2
  319. package/dist/session/codex-extension-discovery.js.map +1 -1
  320. package/dist/session/codex-native-mcp-client.d.ts.map +1 -1
  321. package/dist/session/codex-native-mcp-client.js +2 -1
  322. package/dist/session/codex-native-mcp-client.js.map +1 -1
  323. package/dist/session/codex-process.d.ts.map +1 -1
  324. package/dist/session/codex-process.js +9 -4
  325. package/dist/session/codex-process.js.map +1 -1
  326. package/dist/session/process.d.ts +16 -4
  327. package/dist/session/process.d.ts.map +1 -1
  328. package/dist/session/process.js +153 -75
  329. package/dist/session/process.js.map +1 -1
  330. package/dist/session/runtime-profile.d.ts +10 -5
  331. package/dist/session/runtime-profile.d.ts.map +1 -1
  332. package/dist/session/runtime-profile.js +5 -5
  333. package/dist/session/runtime-profile.js.map +1 -1
  334. package/dist/session/worker-extensions.d.ts.map +1 -1
  335. package/dist/session/worker-extensions.js +2 -1
  336. package/dist/session/worker-extensions.js.map +1 -1
  337. package/dist/types.d.ts +5 -0
  338. package/dist/types.d.ts.map +1 -1
  339. package/dist/ui/dashboard-client.d.ts.map +1 -1
  340. package/dist/ui/dashboard-client.js +33 -3
  341. package/dist/ui/dashboard-client.js.map +1 -1
  342. package/dist/ui/web-ui.js +1 -1
  343. package/lib/automation/browser-thinking.cjs +9 -0
  344. package/lib/automation/browser-thinking.d.cts +2 -0
  345. package/lib/automation/computer-thinking.cjs +10 -0
  346. package/lib/automation/computer-thinking.d.cts +2 -0
  347. package/lib/automation/index.cjs +47 -0
  348. package/lib/automation/index.d.cts +3 -0
  349. package/lib/automation/reasoning-instructions.cjs +5 -0
  350. package/lib/automation/thinking.cjs +35 -0
  351. package/lib/automation/thinking.d.cts +2 -0
  352. package/mcp/capability-catalog.ts +2 -2
  353. package/mcp/server.ts +1 -1
  354. package/mcp/tools/tasks/module.ts +9 -0
  355. package/package.json +5 -3
  356. package/scripts/orchestration/smoke-safemode-codex.cjs +1 -1
@@ -42,6 +42,7 @@ const response_errors_1 = require("../orchestration/response-errors");
42
42
  const voice_settings_router_1 = require("./voice-settings-router");
43
43
  const express_1 = require("express");
44
44
  const identity_1 = require("../orchestration/identity");
45
+ const types_1 = require("../orchestration/types");
45
46
  const crypto_1 = require("crypto");
46
47
  const fs = __importStar(require("fs"));
47
48
  const fsp = __importStar(require("fs/promises"));
@@ -56,7 +57,7 @@ const config_write_lock_1 = require("../config/config-write-lock");
56
57
  const auth_1 = require("./auth");
57
58
  const media_store_1 = require("../history/media-store");
58
59
  const db_1 = require("../history/db");
59
- const types_1 = require("../history/types");
60
+ const types_2 = require("../history/types");
60
61
  const wizard_state_1 = require("./wizard-state");
61
62
  const pending_senders_1 = require("./pending-senders");
62
63
  const create_agent_prompts_1 = require("../agent/create-agent-prompts");
@@ -117,6 +118,12 @@ const SAFE_FILENAME_RE = /^[a-zA-Z0-9._\-() ]+$/;
117
118
  // escape the agent's directory. Clients may pass custom (non-UUID) session ids, so
118
119
  // this preserves that while blocking path traversal.
119
120
  const SESSION_ID_RE = /^[a-zA-Z0-9_-]{1,64}$/;
121
+ // Task and command ids are server/client-generated UUIDs; controlByUser rejects anything else.
122
+ const TASK_CONTROL_UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
123
+ const TASK_CONTROL_ERROR_STATUS = {
124
+ INVALID_INPUT: 400, EXECUTION_DENIED: 403, AUTOMATION_SESSION_CLOSED: 410, COMMAND_QUEUE_FULL: 429,
125
+ REVISION_CONFLICT: 409, STATE_CONFLICT: 409, NOTHING_TO_RESUME: 409, IDEMPOTENCY_CONFLICT: 409, ORCHESTRATION_DISABLED: 409,
126
+ };
120
127
  function isValidSessionId(v) {
121
128
  return typeof v === 'string' && SESSION_ID_RE.test(v);
122
129
  }
@@ -623,6 +630,11 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
623
630
  return;
624
631
  }
625
632
  const clientMessageId = client_message_id;
633
+ if (body.execution_task_id !== undefined && !isValidSessionId(body.execution_task_id)) {
634
+ res.status(400).json({ error: 'Invalid execution task' });
635
+ return;
636
+ }
637
+ const executionTaskId = body.execution_task_id;
626
638
  if (message !== undefined && typeof message !== 'string') {
627
639
  res.status(400).json({ error: 'message must be a string if provided' });
628
640
  return;
@@ -811,7 +823,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
811
823
  const inputId = await runner.acceptApiMessage(sessionId, chatIdStr, trimmedMessage, {
812
824
  timeoutMs, allowTools: agentConfigs.get(agentId)?.allow_tools ?? !!apiKey.allow_tools, mediaFiles: validatedMediaFiles, model: modelStr,
813
825
  imageParams: validatedImageParams, videoParams: validatedVideoParams,
814
- requestId, principalId: (0, identity_1.apiPrincipal)(apiKey), clientMessageId,
826
+ requestId, principalId: (0, identity_1.apiPrincipal)(apiKey), clientMessageId, executionTaskId,
815
827
  });
816
828
  res.status(202).json({ status: 'accepted', input_id: inputId, session_id: sessionId, client_message_id: clientMessageId });
817
829
  }
@@ -849,7 +861,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
849
861
  openSseStream(res);
850
862
  const agentCfg = agentConfigs.get(agentId);
851
863
  const allowTools = agentCfg.allow_tools ?? !!apiKey.allow_tools;
852
- onClientDisconnect = await runner.sendApiMessageStream(sessionId, chatIdStr, trimmedMessage, sseCallbacks, { timeoutMs, allowTools, mediaFiles: validatedMediaFiles, model: modelStr, skipUserMessage, imageParams: validatedImageParams, videoParams: validatedVideoParams, requestId, principalId: (0, identity_1.apiPrincipal)(apiKey), clientMessageId });
864
+ onClientDisconnect = await runner.sendApiMessageStream(sessionId, chatIdStr, trimmedMessage, sseCallbacks, { timeoutMs, allowTools, mediaFiles: validatedMediaFiles, model: modelStr, skipUserMessage, imageParams: validatedImageParams, videoParams: validatedVideoParams, requestId, principalId: (0, identity_1.apiPrincipal)(apiKey), clientMessageId, executionTaskId });
853
865
  // Client disconnect — detaches this connection's sink. The turn keeps
854
866
  // running and keeps buffering, so the client can resume it on a new
855
867
  // connection via GET …/sessions/:sessionId/stream?after_seq= (#421).
@@ -896,7 +908,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
896
908
  videoParams: validatedVideoParams,
897
909
  requestId,
898
910
  principalId: (0, identity_1.apiPrincipal)(apiKey),
899
- clientMessageId,
911
+ clientMessageId, executionTaskId,
900
912
  }));
901
913
  }
902
914
  const syncResult = {
@@ -4153,7 +4165,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
4153
4165
  return;
4154
4166
  }
4155
4167
  const { source, rawChatId } = parseHistoryChatId(chatId);
4156
- if (!(0, types_1.isChatChannel)(source)) {
4168
+ if (!(0, types_2.isChatChannel)(source)) {
4157
4169
  res.status(400).json({ error: 'Sessions endpoint only supports telegram/discord/line/slack/whatsapp/whatsapp_cloud chats' });
4158
4170
  return;
4159
4171
  }
@@ -4339,7 +4351,7 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
4339
4351
  return;
4340
4352
  }
4341
4353
  const { source, rawChatId } = parseHistoryChatId(chatId);
4342
- if (!(0, types_1.isChatChannel)(source)) {
4354
+ if (!(0, types_2.isChatChannel)(source)) {
4343
4355
  res.status(400).json({ error: 'Cross-channel messaging only supported for telegram/discord/line/slack/whatsapp/whatsapp_cloud chats' });
4344
4356
  return;
4345
4357
  }
@@ -5188,6 +5200,41 @@ function createApiRouter(agentRunners, agentConfigs, apiKeys, configPath, models
5188
5200
  res.status(403).json({ error: 'Question unavailable for this principal or already answered' });
5189
5201
  }
5190
5202
  });
5203
+ router.post('/v1/agents/:agentId/sessions/:sessionId/tasks/:taskId/control', auth, async (req, res) => {
5204
+ const { agentId, sessionId, taskId } = req.params;
5205
+ const key = req.apiKey, runner = agentRunners.get(agentId);
5206
+ if (!(0, auth_1.canAccessAgent)(key, agentId) || !runner) {
5207
+ res.status(403).json({ error: 'ACCESS_DENIED' });
5208
+ return;
5209
+ }
5210
+ if (!isValidSessionId(sessionId) || !TASK_CONTROL_UUID_RE.test(taskId)) {
5211
+ res.status(400).json({ error: 'INVALID_INPUT' });
5212
+ return;
5213
+ }
5214
+ if (!(runner.getAgentConfig().allow_tools ?? Boolean(key.allow_tools))) {
5215
+ res.status(403).json({ error: 'EXECUTION_DENIED' });
5216
+ return;
5217
+ }
5218
+ const b = req.body;
5219
+ if (!b || Object.keys(b).some(k => !['id', 'action', 'expectedRevision', 'text'].includes(k)) || typeof b.id !== 'string' || !TASK_CONTROL_UUID_RE.test(b.id) || !['pause', 'revise', 'resume', 'agent', 'user'].includes(b.action) || !Number.isSafeInteger(b.expectedRevision) || b.expectedRevision < 1 || (b.action === 'revise' ? (typeof b.text !== 'string' || !b.text.trim() || b.text.length > 4000) : b.text !== undefined)) {
5220
+ res.status(400).json({ error: 'INVALID_INPUT' });
5221
+ return;
5222
+ }
5223
+ try {
5224
+ res.status(202).json({ task: await runner.controlApiTask(sessionId, (0, identity_1.apiPrincipal)(key), taskId, b) });
5225
+ }
5226
+ catch (e) {
5227
+ // Map by code: OrchestrationError messages may carry human-readable detail.
5228
+ const code = e instanceof types_1.OrchestrationError ? e.code : e instanceof Error ? e.message : '';
5229
+ const status = TASK_CONTROL_ERROR_STATUS[code];
5230
+ if (status) {
5231
+ res.status(status).json({ error: code });
5232
+ return;
5233
+ }
5234
+ // Unknown codes (e.g. TASK_NOT_FOUND) stay ACCESS_DENIED so task existence is not revealed.
5235
+ res.status(403).json({ error: 'ACCESS_DENIED' });
5236
+ }
5237
+ });
5191
5238
  router.post('/v1/agents/:agentId/sessions/:sessionId/tasks/:taskId/cancel', auth, async (req, res) => {
5192
5239
  const { agentId, sessionId, taskId } = req.params;
5193
5240
  const key = req.apiKey, runner = agentRunners.get(agentId);