@0xmaxma/claude-gateway 1.8.13 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (594) hide show
  1. package/README.md +28 -1605
  2. package/config.template.json +7 -1
  3. package/dist/agent/runner.d.ts +394 -0
  4. package/dist/agent/runner.d.ts.map +1 -1
  5. package/dist/agent/runner.js +867 -38
  6. package/dist/agent/runner.js.map +1 -1
  7. package/dist/agent/skill-learning/index.d.ts +6 -4
  8. package/dist/agent/skill-learning/index.d.ts.map +1 -1
  9. package/dist/agent/skill-learning/index.js +3 -3
  10. package/dist/agent/skill-learning/index.js.map +1 -1
  11. package/dist/agent/skill-learning/notifier.d.ts +3 -4
  12. package/dist/agent/skill-learning/notifier.d.ts.map +1 -1
  13. package/dist/agent/skill-learning/notifier.js +15 -13
  14. package/dist/agent/skill-learning/notifier.js.map +1 -1
  15. package/dist/agent/skill-learning/reviewer.d.ts.map +1 -1
  16. package/dist/agent/skill-learning/reviewer.js +3 -1
  17. package/dist/agent/skill-learning/reviewer.js.map +1 -1
  18. package/dist/api/connectors-router.d.ts.map +1 -1
  19. package/dist/api/connectors-router.js +110 -4
  20. package/dist/api/connectors-router.js.map +1 -1
  21. package/dist/api/gateway-router.d.ts +1 -0
  22. package/dist/api/gateway-router.d.ts.map +1 -1
  23. package/dist/api/gateway-router.js +13 -1
  24. package/dist/api/gateway-router.js.map +1 -1
  25. package/dist/api/line-webhook-router.d.ts +2 -2
  26. package/dist/api/line-webhook-router.d.ts.map +1 -1
  27. package/dist/api/line-webhook-router.js +264 -230
  28. package/dist/api/line-webhook-router.js.map +1 -1
  29. package/dist/api/router.d.ts.map +1 -1
  30. package/dist/api/router.js +372 -11
  31. package/dist/api/router.js.map +1 -1
  32. package/dist/api/share-router.d.ts.map +1 -1
  33. package/dist/api/share-router.js +29 -10
  34. package/dist/api/share-router.js.map +1 -1
  35. package/dist/api/slack-client.d.ts +2 -0
  36. package/dist/api/slack-client.d.ts.map +1 -1
  37. package/dist/api/slack-client.js +6 -2
  38. package/dist/api/slack-client.js.map +1 -1
  39. package/dist/api/slack-webhook-router.d.ts +3 -0
  40. package/dist/api/slack-webhook-router.d.ts.map +1 -1
  41. package/dist/api/slack-webhook-router.js +226 -131
  42. package/dist/api/slack-webhook-router.js.map +1 -1
  43. package/dist/api/voice-router.d.ts +21 -0
  44. package/dist/api/voice-router.d.ts.map +1 -0
  45. package/dist/api/voice-router.js +372 -0
  46. package/dist/api/voice-router.js.map +1 -0
  47. package/dist/api/voice-settings-router.d.ts +5 -0
  48. package/dist/api/voice-settings-router.d.ts.map +1 -0
  49. package/dist/api/voice-settings-router.js +318 -0
  50. package/dist/api/voice-settings-router.js.map +1 -0
  51. package/dist/api/wechat-access.d.ts +45 -0
  52. package/dist/api/wechat-access.d.ts.map +1 -0
  53. package/dist/api/wechat-access.js +48 -0
  54. package/dist/api/wechat-access.js.map +1 -0
  55. package/dist/apps/agent-container-migration.d.ts +11 -0
  56. package/dist/apps/agent-container-migration.d.ts.map +1 -0
  57. package/dist/apps/agent-container-migration.js +85 -0
  58. package/dist/apps/agent-container-migration.js.map +1 -0
  59. package/dist/apps/installer.d.ts +1 -1
  60. package/dist/apps/installer.d.ts.map +1 -1
  61. package/dist/apps/installer.js +2 -1
  62. package/dist/apps/installer.js.map +1 -1
  63. package/dist/cli/commands/tasks.d.ts +5 -0
  64. package/dist/cli/commands/tasks.d.ts.map +1 -0
  65. package/dist/cli/commands/tasks.js +92 -0
  66. package/dist/cli/commands/tasks.js.map +1 -0
  67. package/dist/cli/http-client.d.ts +2 -0
  68. package/dist/cli/http-client.d.ts.map +1 -1
  69. package/dist/cli/http-client.js +8 -3
  70. package/dist/cli/http-client.js.map +1 -1
  71. package/dist/cli/index.d.ts.map +1 -1
  72. package/dist/cli/index.js +5 -1
  73. package/dist/cli/index.js.map +1 -1
  74. package/dist/config/config-write-lock.d.ts +2 -0
  75. package/dist/config/config-write-lock.d.ts.map +1 -1
  76. package/dist/config/config-write-lock.js +5 -0
  77. package/dist/config/config-write-lock.js.map +1 -1
  78. package/dist/config/loader.d.ts.map +1 -1
  79. package/dist/config/loader.js +87 -2
  80. package/dist/config/loader.js.map +1 -1
  81. package/dist/config/migrator.d.ts.map +1 -1
  82. package/dist/config/migrator.js +12 -1
  83. package/dist/config/migrator.js.map +1 -1
  84. package/dist/config/watcher.d.ts.map +1 -1
  85. package/dist/config/watcher.js +6 -0
  86. package/dist/config/watcher.js.map +1 -1
  87. package/dist/connectors/resolve.d.ts.map +1 -1
  88. package/dist/connectors/resolve.js +3 -1
  89. package/dist/connectors/resolve.js.map +1 -1
  90. package/dist/connectors/types.d.ts +8 -0
  91. package/dist/connectors/types.d.ts.map +1 -1
  92. package/dist/cron/manager.d.ts.map +1 -1
  93. package/dist/cron/manager.js +21 -2
  94. package/dist/cron/manager.js.map +1 -1
  95. package/dist/discord/receiver.d.ts +2 -1
  96. package/dist/discord/receiver.d.ts.map +1 -1
  97. package/dist/discord/receiver.js +5 -1
  98. package/dist/discord/receiver.js.map +1 -1
  99. package/dist/history/db.d.ts +3 -0
  100. package/dist/history/db.d.ts.map +1 -1
  101. package/dist/history/db.js +21 -1
  102. package/dist/history/db.js.map +1 -1
  103. package/dist/history/types.d.ts +12 -1
  104. package/dist/history/types.d.ts.map +1 -1
  105. package/dist/history/types.js +10 -1
  106. package/dist/history/types.js.map +1 -1
  107. package/dist/index.js +48 -9
  108. package/dist/index.js.map +1 -1
  109. package/dist/orchestration/bounded-queue.d.ts +15 -0
  110. package/dist/orchestration/bounded-queue.d.ts.map +1 -0
  111. package/dist/orchestration/bounded-queue.js +58 -0
  112. package/dist/orchestration/bounded-queue.js.map +1 -0
  113. package/dist/orchestration/bridge.d.ts +55 -0
  114. package/dist/orchestration/bridge.d.ts.map +1 -0
  115. package/dist/orchestration/bridge.js +234 -0
  116. package/dist/orchestration/bridge.js.map +1 -0
  117. package/dist/orchestration/browser-routing.d.ts +7 -0
  118. package/dist/orchestration/browser-routing.d.ts.map +1 -0
  119. package/dist/orchestration/browser-routing.js +22 -0
  120. package/dist/orchestration/browser-routing.js.map +1 -0
  121. package/dist/orchestration/capabilities.d.ts +49 -0
  122. package/dist/orchestration/capabilities.d.ts.map +1 -0
  123. package/dist/orchestration/capabilities.js +417 -0
  124. package/dist/orchestration/capabilities.js.map +1 -0
  125. package/dist/orchestration/capacity.d.ts +14 -0
  126. package/dist/orchestration/capacity.d.ts.map +1 -0
  127. package/dist/orchestration/capacity.js +52 -0
  128. package/dist/orchestration/capacity.js.map +1 -0
  129. package/dist/orchestration/channel-activity.d.ts +21 -0
  130. package/dist/orchestration/channel-activity.d.ts.map +1 -0
  131. package/dist/orchestration/channel-activity.js +72 -0
  132. package/dist/orchestration/channel-activity.js.map +1 -0
  133. package/dist/orchestration/channel-controls.d.ts +32 -0
  134. package/dist/orchestration/channel-controls.d.ts.map +1 -0
  135. package/dist/orchestration/channel-controls.js +105 -0
  136. package/dist/orchestration/channel-controls.js.map +1 -0
  137. package/dist/orchestration/channel-input-media.d.ts +11 -0
  138. package/dist/orchestration/channel-input-media.d.ts.map +1 -0
  139. package/dist/orchestration/channel-input-media.js +54 -0
  140. package/dist/orchestration/channel-input-media.js.map +1 -0
  141. package/dist/orchestration/channel-media.d.ts +4 -0
  142. package/dist/orchestration/channel-media.d.ts.map +1 -0
  143. package/dist/orchestration/channel-media.js +70 -0
  144. package/dist/orchestration/channel-media.js.map +1 -0
  145. package/dist/orchestration/channel-speech.d.ts +7 -0
  146. package/dist/orchestration/channel-speech.d.ts.map +1 -0
  147. package/dist/orchestration/channel-speech.js +65 -0
  148. package/dist/orchestration/channel-speech.js.map +1 -0
  149. package/dist/orchestration/cli-skills.d.ts +12 -0
  150. package/dist/orchestration/cli-skills.d.ts.map +1 -0
  151. package/dist/orchestration/cli-skills.js +132 -0
  152. package/dist/orchestration/cli-skills.js.map +1 -0
  153. package/dist/orchestration/config.d.ts +256 -0
  154. package/dist/orchestration/config.d.ts.map +1 -0
  155. package/dist/orchestration/config.js +110 -0
  156. package/dist/orchestration/config.js.map +1 -0
  157. package/dist/orchestration/container.d.ts +21 -0
  158. package/dist/orchestration/container.d.ts.map +1 -0
  159. package/dist/orchestration/container.js +195 -0
  160. package/dist/orchestration/container.js.map +1 -0
  161. package/dist/orchestration/control-delivery.d.ts +5 -0
  162. package/dist/orchestration/control-delivery.d.ts.map +1 -0
  163. package/dist/orchestration/control-delivery.js +50 -0
  164. package/dist/orchestration/control-delivery.js.map +1 -0
  165. package/dist/orchestration/conversation-intake.d.ts +32 -0
  166. package/dist/orchestration/conversation-intake.d.ts.map +1 -0
  167. package/dist/orchestration/conversation-intake.js +92 -0
  168. package/dist/orchestration/conversation-intake.js.map +1 -0
  169. package/dist/orchestration/decisions.d.ts +27 -0
  170. package/dist/orchestration/decisions.d.ts.map +1 -0
  171. package/dist/orchestration/decisions.js +148 -0
  172. package/dist/orchestration/decisions.js.map +1 -0
  173. package/dist/orchestration/delivery.d.ts +30 -0
  174. package/dist/orchestration/delivery.d.ts.map +1 -0
  175. package/dist/orchestration/delivery.js +219 -0
  176. package/dist/orchestration/delivery.js.map +1 -0
  177. package/dist/orchestration/display-stream.d.ts +4 -0
  178. package/dist/orchestration/display-stream.d.ts.map +1 -0
  179. package/dist/orchestration/display-stream.js +77 -0
  180. package/dist/orchestration/display-stream.js.map +1 -0
  181. package/dist/orchestration/events.d.ts +30 -0
  182. package/dist/orchestration/events.d.ts.map +1 -0
  183. package/dist/orchestration/events.js +65 -0
  184. package/dist/orchestration/events.js.map +1 -0
  185. package/dist/orchestration/execution-observation.d.ts +38 -0
  186. package/dist/orchestration/execution-observation.d.ts.map +1 -0
  187. package/dist/orchestration/execution-observation.js +25 -0
  188. package/dist/orchestration/execution-observation.js.map +1 -0
  189. package/dist/orchestration/file-delivery.d.ts +16 -0
  190. package/dist/orchestration/file-delivery.d.ts.map +1 -0
  191. package/dist/orchestration/file-delivery.js +139 -0
  192. package/dist/orchestration/file-delivery.js.map +1 -0
  193. package/dist/orchestration/gateway-config.d.ts +17 -0
  194. package/dist/orchestration/gateway-config.d.ts.map +1 -0
  195. package/dist/orchestration/gateway-config.js +128 -0
  196. package/dist/orchestration/gateway-config.js.map +1 -0
  197. package/dist/orchestration/history.d.ts +13 -0
  198. package/dist/orchestration/history.d.ts.map +1 -0
  199. package/dist/orchestration/history.js +48 -0
  200. package/dist/orchestration/history.js.map +1 -0
  201. package/dist/orchestration/identity.d.ts +6 -0
  202. package/dist/orchestration/identity.d.ts.map +1 -0
  203. package/dist/orchestration/identity.js +13 -0
  204. package/dist/orchestration/identity.js.map +1 -0
  205. package/dist/orchestration/inference-errors.d.ts +3 -0
  206. package/dist/orchestration/inference-errors.d.ts.map +1 -0
  207. package/dist/orchestration/inference-errors.js +16 -0
  208. package/dist/orchestration/inference-errors.js.map +1 -0
  209. package/dist/orchestration/input-images.d.ts +12 -0
  210. package/dist/orchestration/input-images.d.ts.map +1 -0
  211. package/dist/orchestration/input-images.js +66 -0
  212. package/dist/orchestration/input-images.js.map +1 -0
  213. package/dist/orchestration/instance-lock.d.ts +5 -0
  214. package/dist/orchestration/instance-lock.d.ts.map +1 -0
  215. package/dist/orchestration/instance-lock.js +33 -0
  216. package/dist/orchestration/instance-lock.js.map +1 -0
  217. package/dist/orchestration/line-loading.d.ts +21 -0
  218. package/dist/orchestration/line-loading.d.ts.map +1 -0
  219. package/dist/orchestration/line-loading.js +89 -0
  220. package/dist/orchestration/line-loading.js.map +1 -0
  221. package/dist/orchestration/media.d.ts +3 -0
  222. package/dist/orchestration/media.d.ts.map +1 -0
  223. package/dist/orchestration/media.js +46 -0
  224. package/dist/orchestration/media.js.map +1 -0
  225. package/dist/orchestration/migrations/schema.d.ts +3 -0
  226. package/dist/orchestration/migrations/schema.d.ts.map +1 -0
  227. package/dist/orchestration/migrations/schema.js +80 -0
  228. package/dist/orchestration/migrations/schema.js.map +1 -0
  229. package/dist/orchestration/notification-mailbox.d.ts +5 -0
  230. package/dist/orchestration/notification-mailbox.d.ts.map +1 -0
  231. package/dist/orchestration/notification-mailbox.js +29 -0
  232. package/dist/orchestration/notification-mailbox.js.map +1 -0
  233. package/dist/orchestration/process-activity.d.ts +23 -0
  234. package/dist/orchestration/process-activity.d.ts.map +1 -0
  235. package/dist/orchestration/process-activity.js +95 -0
  236. package/dist/orchestration/process-activity.js.map +1 -0
  237. package/dist/orchestration/process-supervisor.d.ts +15 -0
  238. package/dist/orchestration/process-supervisor.d.ts.map +1 -0
  239. package/dist/orchestration/process-supervisor.js +92 -0
  240. package/dist/orchestration/process-supervisor.js.map +1 -0
  241. package/dist/orchestration/process-turn.d.ts +35 -0
  242. package/dist/orchestration/process-turn.d.ts.map +1 -0
  243. package/dist/orchestration/process-turn.js +246 -0
  244. package/dist/orchestration/process-turn.js.map +1 -0
  245. package/dist/orchestration/progress-review.d.ts +28 -0
  246. package/dist/orchestration/progress-review.d.ts.map +1 -0
  247. package/dist/orchestration/progress-review.js +48 -0
  248. package/dist/orchestration/progress-review.js.map +1 -0
  249. package/dist/orchestration/recovery.d.ts +8 -0
  250. package/dist/orchestration/recovery.d.ts.map +1 -0
  251. package/dist/orchestration/recovery.js +35 -0
  252. package/dist/orchestration/recovery.js.map +1 -0
  253. package/dist/orchestration/reply-context.d.ts +7 -0
  254. package/dist/orchestration/reply-context.d.ts.map +1 -0
  255. package/dist/orchestration/reply-context.js +54 -0
  256. package/dist/orchestration/reply-context.js.map +1 -0
  257. package/dist/orchestration/runtime.d.ts +232 -0
  258. package/dist/orchestration/runtime.d.ts.map +1 -0
  259. package/dist/orchestration/runtime.js +962 -0
  260. package/dist/orchestration/runtime.js.map +1 -0
  261. package/dist/orchestration/skills.d.ts +17 -0
  262. package/dist/orchestration/skills.d.ts.map +1 -0
  263. package/dist/orchestration/skills.js +32 -0
  264. package/dist/orchestration/skills.js.map +1 -0
  265. package/dist/orchestration/source-policy.d.ts +6 -0
  266. package/dist/orchestration/source-policy.d.ts.map +1 -0
  267. package/dist/orchestration/source-policy.js +16 -0
  268. package/dist/orchestration/source-policy.js.map +1 -0
  269. package/dist/orchestration/speech.d.ts +24 -0
  270. package/dist/orchestration/speech.d.ts.map +1 -0
  271. package/dist/orchestration/speech.js +61 -0
  272. package/dist/orchestration/speech.js.map +1 -0
  273. package/dist/orchestration/stop-controls.d.ts +30 -0
  274. package/dist/orchestration/stop-controls.d.ts.map +1 -0
  275. package/dist/orchestration/stop-controls.js +79 -0
  276. package/dist/orchestration/stop-controls.js.map +1 -0
  277. package/dist/orchestration/store.d.ts +86 -0
  278. package/dist/orchestration/store.d.ts.map +1 -0
  279. package/dist/orchestration/store.js +275 -0
  280. package/dist/orchestration/store.js.map +1 -0
  281. package/dist/orchestration/task-controls.d.ts +130 -0
  282. package/dist/orchestration/task-controls.d.ts.map +1 -0
  283. package/dist/orchestration/task-controls.js +55 -0
  284. package/dist/orchestration/task-controls.js.map +1 -0
  285. package/dist/orchestration/task-files.d.ts +29 -0
  286. package/dist/orchestration/task-files.d.ts.map +1 -0
  287. package/dist/orchestration/task-files.js +200 -0
  288. package/dist/orchestration/task-files.js.map +1 -0
  289. package/dist/orchestration/task-report.d.ts +7 -0
  290. package/dist/orchestration/task-report.d.ts.map +1 -0
  291. package/dist/orchestration/task-report.js +33 -0
  292. package/dist/orchestration/task-report.js.map +1 -0
  293. package/dist/orchestration/tasks/checkpoint-hook.d.ts +19 -0
  294. package/dist/orchestration/tasks/checkpoint-hook.d.ts.map +1 -0
  295. package/dist/orchestration/tasks/checkpoint-hook.js +49 -0
  296. package/dist/orchestration/tasks/checkpoint-hook.js.map +1 -0
  297. package/dist/orchestration/tasks/cleanup.d.ts +18 -0
  298. package/dist/orchestration/tasks/cleanup.d.ts.map +1 -0
  299. package/dist/orchestration/tasks/cleanup.js +113 -0
  300. package/dist/orchestration/tasks/cleanup.js.map +1 -0
  301. package/dist/orchestration/tasks/driver.d.ts +23 -0
  302. package/dist/orchestration/tasks/driver.d.ts.map +1 -0
  303. package/dist/orchestration/tasks/driver.js +209 -0
  304. package/dist/orchestration/tasks/driver.js.map +1 -0
  305. package/dist/orchestration/tasks/failure.d.ts +5 -0
  306. package/dist/orchestration/tasks/failure.d.ts.map +1 -0
  307. package/dist/orchestration/tasks/failure.js +17 -0
  308. package/dist/orchestration/tasks/failure.js.map +1 -0
  309. package/dist/orchestration/tasks/pool.d.ts +18 -0
  310. package/dist/orchestration/tasks/pool.d.ts.map +1 -0
  311. package/dist/orchestration/tasks/pool.js +73 -0
  312. package/dist/orchestration/tasks/pool.js.map +1 -0
  313. package/dist/orchestration/tasks/scheduler.d.ts +38 -0
  314. package/dist/orchestration/tasks/scheduler.d.ts.map +1 -0
  315. package/dist/orchestration/tasks/scheduler.js +160 -0
  316. package/dist/orchestration/tasks/scheduler.js.map +1 -0
  317. package/dist/orchestration/tasks/service.d.ts +109 -0
  318. package/dist/orchestration/tasks/service.d.ts.map +1 -0
  319. package/dist/orchestration/tasks/service.js +697 -0
  320. package/dist/orchestration/tasks/service.js.map +1 -0
  321. package/dist/orchestration/tasks/shared-workspace.d.ts +25 -0
  322. package/dist/orchestration/tasks/shared-workspace.d.ts.map +1 -0
  323. package/dist/orchestration/tasks/shared-workspace.js +162 -0
  324. package/dist/orchestration/tasks/shared-workspace.js.map +1 -0
  325. package/dist/orchestration/tasks/task-directive.d.ts +6 -0
  326. package/dist/orchestration/tasks/task-directive.d.ts.map +1 -0
  327. package/dist/orchestration/tasks/task-directive.js +41 -0
  328. package/dist/orchestration/tasks/task-directive.js.map +1 -0
  329. package/dist/orchestration/tasks/timing.d.ts +15 -0
  330. package/dist/orchestration/tasks/timing.d.ts.map +1 -0
  331. package/dist/orchestration/tasks/timing.js +48 -0
  332. package/dist/orchestration/tasks/timing.js.map +1 -0
  333. package/dist/orchestration/tasks/tool-repetition.d.ts +3 -0
  334. package/dist/orchestration/tasks/tool-repetition.d.ts.map +1 -0
  335. package/dist/orchestration/tasks/tool-repetition.js +30 -0
  336. package/dist/orchestration/tasks/tool-repetition.js.map +1 -0
  337. package/dist/orchestration/tasks/workspace.d.ts +24 -0
  338. package/dist/orchestration/tasks/workspace.d.ts.map +1 -0
  339. package/dist/orchestration/tasks/workspace.js +147 -0
  340. package/dist/orchestration/tasks/workspace.js.map +1 -0
  341. package/dist/orchestration/telegram-speech.d.ts +17 -0
  342. package/dist/orchestration/telegram-speech.d.ts.map +1 -0
  343. package/dist/orchestration/telegram-speech.js +55 -0
  344. package/dist/orchestration/telegram-speech.js.map +1 -0
  345. package/dist/orchestration/telegram-tool-status.d.ts +23 -0
  346. package/dist/orchestration/telegram-tool-status.d.ts.map +1 -0
  347. package/dist/orchestration/telegram-tool-status.js +207 -0
  348. package/dist/orchestration/telegram-tool-status.js.map +1 -0
  349. package/dist/orchestration/telegram-voices.d.ts +42 -0
  350. package/dist/orchestration/telegram-voices.d.ts.map +1 -0
  351. package/dist/orchestration/telegram-voices.js +70 -0
  352. package/dist/orchestration/telegram-voices.js.map +1 -0
  353. package/dist/orchestration/tool-activity.d.ts +10 -0
  354. package/dist/orchestration/tool-activity.d.ts.map +1 -0
  355. package/dist/orchestration/tool-activity.js +38 -0
  356. package/dist/orchestration/tool-activity.js.map +1 -0
  357. package/dist/orchestration/types.d.ts +177 -0
  358. package/dist/orchestration/types.d.ts.map +1 -0
  359. package/dist/orchestration/types.js +13 -0
  360. package/dist/orchestration/types.js.map +1 -0
  361. package/dist/orchestration/voice-reply-policy.d.ts +8 -0
  362. package/dist/orchestration/voice-reply-policy.d.ts.map +1 -0
  363. package/dist/orchestration/voice-reply-policy.js +46 -0
  364. package/dist/orchestration/voice-reply-policy.js.map +1 -0
  365. package/dist/orchestration/worker-shares.d.ts +8 -0
  366. package/dist/orchestration/worker-shares.d.ts.map +1 -0
  367. package/dist/orchestration/worker-shares.js +59 -0
  368. package/dist/orchestration/worker-shares.js.map +1 -0
  369. package/dist/orchestration/workflow.d.ts +121 -0
  370. package/dist/orchestration/workflow.d.ts.map +1 -0
  371. package/dist/orchestration/workflow.js +69 -0
  372. package/dist/orchestration/workflow.js.map +1 -0
  373. package/dist/session/input-image.d.ts +10 -0
  374. package/dist/session/input-image.d.ts.map +1 -0
  375. package/dist/session/input-image.js +3 -0
  376. package/dist/session/input-image.js.map +1 -0
  377. package/dist/session/process.d.ts +15 -3
  378. package/dist/session/process.d.ts.map +1 -1
  379. package/dist/session/process.js +144 -35
  380. package/dist/session/process.js.map +1 -1
  381. package/dist/session/runtime-profile.d.ts +36 -0
  382. package/dist/session/runtime-profile.d.ts.map +1 -0
  383. package/dist/session/runtime-profile.js +63 -0
  384. package/dist/session/runtime-profile.js.map +1 -0
  385. package/dist/session/store.d.ts.map +1 -1
  386. package/dist/session/store.js +23 -1
  387. package/dist/session/store.js.map +1 -1
  388. package/dist/share/share-store.d.ts +3 -1
  389. package/dist/share/share-store.d.ts.map +1 -1
  390. package/dist/share/share-store.js +13 -2
  391. package/dist/share/share-store.js.map +1 -1
  392. package/dist/shared/line-request-order.d.ts +2 -0
  393. package/dist/shared/line-request-order.d.ts.map +1 -0
  394. package/dist/shared/line-request-order.js +16 -0
  395. package/dist/shared/line-request-order.js.map +1 -0
  396. package/dist/shared/task-elapsed.d.ts +3 -0
  397. package/dist/shared/task-elapsed.d.ts.map +1 -0
  398. package/dist/shared/task-elapsed.js +12 -0
  399. package/dist/shared/task-elapsed.js.map +1 -0
  400. package/dist/shared/task-updated-time.d.ts +3 -0
  401. package/dist/shared/task-updated-time.d.ts.map +1 -0
  402. package/dist/shared/task-updated-time.js +15 -0
  403. package/dist/shared/task-updated-time.js.map +1 -0
  404. package/dist/skills/loader.d.ts +2 -0
  405. package/dist/skills/loader.d.ts.map +1 -1
  406. package/dist/skills/loader.js.map +1 -1
  407. package/dist/telegram/chunks.d.ts +19 -0
  408. package/dist/telegram/chunks.d.ts.map +1 -0
  409. package/dist/telegram/chunks.js +129 -0
  410. package/dist/telegram/chunks.js.map +1 -0
  411. package/dist/telegram/markdown.d.ts.map +1 -1
  412. package/dist/telegram/markdown.js +18 -3
  413. package/dist/telegram/markdown.js.map +1 -1
  414. package/dist/telegram/receiver.d.ts +2 -1
  415. package/dist/telegram/receiver.d.ts.map +1 -1
  416. package/dist/telegram/receiver.js +6 -1
  417. package/dist/telegram/receiver.js.map +1 -1
  418. package/dist/types.d.ts +54 -0
  419. package/dist/types.d.ts.map +1 -1
  420. package/dist/ui/web-ui.d.ts.map +1 -1
  421. package/dist/ui/web-ui.js +31 -5
  422. package/dist/ui/web-ui.js.map +1 -1
  423. package/dist/voice/diagnostics.d.ts +29 -0
  424. package/dist/voice/diagnostics.d.ts.map +1 -0
  425. package/dist/voice/diagnostics.js +37 -0
  426. package/dist/voice/diagnostics.js.map +1 -0
  427. package/dist/voice/errors.d.ts +19 -0
  428. package/dist/voice/errors.d.ts.map +1 -0
  429. package/dist/voice/errors.js +133 -0
  430. package/dist/voice/errors.js.map +1 -0
  431. package/dist/voice/line-audio.d.ts +4 -0
  432. package/dist/voice/line-audio.d.ts.map +1 -0
  433. package/dist/voice/line-audio.js +27 -0
  434. package/dist/voice/line-audio.js.map +1 -0
  435. package/dist/voice/managed-quota.d.ts +5 -0
  436. package/dist/voice/managed-quota.d.ts.map +1 -0
  437. package/dist/voice/managed-quota.js +35 -0
  438. package/dist/voice/managed-quota.js.map +1 -0
  439. package/dist/voice/mp3.d.ts +3 -0
  440. package/dist/voice/mp3.d.ts.map +1 -0
  441. package/dist/voice/mp3.js +30 -0
  442. package/dist/voice/mp3.js.map +1 -0
  443. package/dist/voice/notes.d.ts +9 -0
  444. package/dist/voice/notes.d.ts.map +1 -0
  445. package/dist/voice/notes.js +68 -0
  446. package/dist/voice/notes.js.map +1 -0
  447. package/dist/voice/playback.d.ts +22 -0
  448. package/dist/voice/playback.d.ts.map +1 -0
  449. package/dist/voice/playback.js +52 -0
  450. package/dist/voice/playback.js.map +1 -0
  451. package/dist/voice/preview.d.ts +6 -0
  452. package/dist/voice/preview.d.ts.map +1 -0
  453. package/dist/voice/preview.js +44 -0
  454. package/dist/voice/preview.js.map +1 -0
  455. package/dist/voice/protocol.d.ts +10 -0
  456. package/dist/voice/protocol.d.ts.map +1 -0
  457. package/dist/voice/protocol.js +30 -0
  458. package/dist/voice/protocol.js.map +1 -0
  459. package/dist/voice/providers/cartesia-tts.d.ts +26 -0
  460. package/dist/voice/providers/cartesia-tts.d.ts.map +1 -0
  461. package/dist/voice/providers/cartesia-tts.js +95 -0
  462. package/dist/voice/providers/cartesia-tts.js.map +1 -0
  463. package/dist/voice/providers/deepgram-stt.d.ts +20 -0
  464. package/dist/voice/providers/deepgram-stt.d.ts.map +1 -0
  465. package/dist/voice/providers/deepgram-stt.js +66 -0
  466. package/dist/voice/providers/deepgram-stt.js.map +1 -0
  467. package/dist/voice/providers/elevenlabs-stt.d.ts +20 -0
  468. package/dist/voice/providers/elevenlabs-stt.d.ts.map +1 -0
  469. package/dist/voice/providers/elevenlabs-stt.js +92 -0
  470. package/dist/voice/providers/elevenlabs-stt.js.map +1 -0
  471. package/dist/voice/providers/elevenlabs-tts.d.ts +26 -0
  472. package/dist/voice/providers/elevenlabs-tts.d.ts.map +1 -0
  473. package/dist/voice/providers/elevenlabs-tts.js +82 -0
  474. package/dist/voice/providers/elevenlabs-tts.js.map +1 -0
  475. package/dist/voice/providers/encoded-audio-tts.d.ts +21 -0
  476. package/dist/voice/providers/encoded-audio-tts.d.ts.map +1 -0
  477. package/dist/voice/providers/encoded-audio-tts.js +175 -0
  478. package/dist/voice/providers/encoded-audio-tts.js.map +1 -0
  479. package/dist/voice/providers/fake.d.ts +39 -0
  480. package/dist/voice/providers/fake.d.ts.map +1 -0
  481. package/dist/voice/providers/fake.js +41 -0
  482. package/dist/voice/providers/fake.js.map +1 -0
  483. package/dist/voice/providers/gemini-live-stt.d.ts +21 -0
  484. package/dist/voice/providers/gemini-live-stt.d.ts.map +1 -0
  485. package/dist/voice/providers/gemini-live-stt.js +158 -0
  486. package/dist/voice/providers/gemini-live-stt.js.map +1 -0
  487. package/dist/voice/providers/gemini.d.ts +60 -0
  488. package/dist/voice/providers/gemini.d.ts.map +1 -0
  489. package/dist/voice/providers/gemini.js +124 -0
  490. package/dist/voice/providers/gemini.js.map +1 -0
  491. package/dist/voice/providers/model-ref.d.ts +9 -0
  492. package/dist/voice/providers/model-ref.d.ts.map +1 -0
  493. package/dist/voice/providers/model-ref.js +31 -0
  494. package/dist/voice/providers/model-ref.js.map +1 -0
  495. package/dist/voice/providers/openrouter.d.ts +39 -0
  496. package/dist/voice/providers/openrouter.d.ts.map +1 -0
  497. package/dist/voice/providers/openrouter.js +154 -0
  498. package/dist/voice/providers/openrouter.js.map +1 -0
  499. package/dist/voice/providers/paxalabs-stt.d.ts +12 -0
  500. package/dist/voice/providers/paxalabs-stt.d.ts.map +1 -0
  501. package/dist/voice/providers/paxalabs-stt.js +41 -0
  502. package/dist/voice/providers/paxalabs-stt.js.map +1 -0
  503. package/dist/voice/providers/paxalabs-tts.d.ts +23 -0
  504. package/dist/voice/providers/paxalabs-tts.d.ts.map +1 -0
  505. package/dist/voice/providers/paxalabs-tts.js +80 -0
  506. package/dist/voice/providers/paxalabs-tts.js.map +1 -0
  507. package/dist/voice/providers/recorded-stt.d.ts +34 -0
  508. package/dist/voice/providers/recorded-stt.d.ts.map +1 -0
  509. package/dist/voice/providers/recorded-stt.js +59 -0
  510. package/dist/voice/providers/recorded-stt.js.map +1 -0
  511. package/dist/voice/providers/registry.d.ts +10 -0
  512. package/dist/voice/providers/registry.d.ts.map +1 -0
  513. package/dist/voice/providers/registry.js +77 -0
  514. package/dist/voice/providers/registry.js.map +1 -0
  515. package/dist/voice/providers/socket.d.ts +10 -0
  516. package/dist/voice/providers/socket.d.ts.map +1 -0
  517. package/dist/voice/providers/socket.js +91 -0
  518. package/dist/voice/providers/socket.js.map +1 -0
  519. package/dist/voice/providers/upstream.d.ts +9 -0
  520. package/dist/voice/providers/upstream.d.ts.map +1 -0
  521. package/dist/voice/providers/upstream.js +51 -0
  522. package/dist/voice/providers/upstream.js.map +1 -0
  523. package/dist/voice/providers/voice-catalog.d.ts +17 -0
  524. package/dist/voice/providers/voice-catalog.d.ts.map +1 -0
  525. package/dist/voice/providers/voice-catalog.js +167 -0
  526. package/dist/voice/providers/voice-catalog.js.map +1 -0
  527. package/dist/voice/queue.d.ts +2 -0
  528. package/dist/voice/queue.d.ts.map +1 -0
  529. package/dist/voice/queue.js +6 -0
  530. package/dist/voice/queue.js.map +1 -0
  531. package/dist/voice/session.d.ts +86 -0
  532. package/dist/voice/session.d.ts.map +1 -0
  533. package/dist/voice/session.js +464 -0
  534. package/dist/voice/session.js.map +1 -0
  535. package/dist/voice/turn-manager.d.ts +27 -0
  536. package/dist/voice/turn-manager.d.ts.map +1 -0
  537. package/dist/voice/turn-manager.js +75 -0
  538. package/dist/voice/turn-manager.js.map +1 -0
  539. package/dist/voice/types.d.ts +78 -0
  540. package/dist/voice/types.d.ts.map +1 -0
  541. package/dist/voice/types.js +18 -0
  542. package/dist/voice/types.js.map +1 -0
  543. package/dist/voice/wav.d.ts +2 -0
  544. package/dist/voice/wav.d.ts.map +1 -0
  545. package/dist/voice/wav.js +21 -0
  546. package/dist/voice/wav.js.map +1 -0
  547. package/dist/wechat/ilink-client.d.ts +207 -0
  548. package/dist/wechat/ilink-client.d.ts.map +1 -0
  549. package/dist/wechat/ilink-client.js +660 -0
  550. package/dist/wechat/ilink-client.js.map +1 -0
  551. package/dist/wechat/manager.d.ts +93 -0
  552. package/dist/wechat/manager.d.ts.map +1 -0
  553. package/dist/wechat/manager.js +409 -0
  554. package/dist/wechat/manager.js.map +1 -0
  555. package/dist/whatsapp/manager.d.ts.map +1 -1
  556. package/dist/whatsapp/manager.js +51 -1
  557. package/dist/whatsapp/manager.js.map +1 -1
  558. package/mcp/capability-catalog.ts +206 -0
  559. package/mcp/modules.ts +56 -0
  560. package/mcp/server.ts +18 -35
  561. package/mcp/tools/browser/module.ts +1 -1
  562. package/mcp/tools/browser/skills/open-browser/SKILL.md +5 -3
  563. package/mcp/tools/discord/commands.ts +17 -1
  564. package/mcp/tools/discord/inbound.ts +11 -0
  565. package/mcp/tools/discord/module.ts +42 -2
  566. package/mcp/tools/discord/receiver-server.ts +10 -0
  567. package/mcp/tools/discord/types.ts +4 -1
  568. package/mcp/tools/image/module.ts +3 -1
  569. package/mcp/tools/receiver-spool.test.ts +28 -0
  570. package/mcp/tools/receiver-spool.ts +56 -0
  571. package/mcp/tools/share-file/module.ts +9 -1
  572. package/mcp/tools/shared/share-client.ts +19 -0
  573. package/mcp/tools/tasks/module.ts +35 -0
  574. package/mcp/tools/telegram/media-group.ts +21 -0
  575. package/mcp/tools/telegram/receiver-server.ts +232 -11
  576. package/mcp/tools/telegram/selection-confirmation.ts +20 -0
  577. package/mcp/tools/telegram/task-browser.ts +117 -0
  578. package/mcp/tools/telegram/task-detail.ts +36 -0
  579. package/mcp/tools/telegram/task-elapsed.ts +1 -0
  580. package/mcp/tools/telegram/typing.ts +6 -116
  581. package/mcp/tools/video/module.ts +1 -1
  582. package/mcp/tools/wechat/client.ts +49 -0
  583. package/mcp/tools/wechat/module.ts +88 -0
  584. package/mcp/types.ts +5 -0
  585. package/package.json +2 -1
  586. package/resource/claude_gateway.jpeg +0 -0
  587. package/scripts/orchestration/bench-store.cjs +30 -0
  588. package/scripts/orchestration/inspect.cjs +16 -0
  589. package/scripts/orchestration/probe-profile.cjs +67 -0
  590. package/scripts/orchestration/reconcile.cjs +21 -0
  591. package/scripts/orchestration/smoke-elevenlabs.cjs +90 -0
  592. package/scripts/orchestration/smoke-media.cjs +70 -0
  593. package/scripts/orchestration/smoke-text.cjs +101 -0
  594. package/scripts/orchestration/smoke-vision.cjs +49 -0
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AGENT_WORKFLOW_RULES = exports.WORKER_WORKFLOW_RULES = exports.WORKFLOW_SCHEMA = void 0;
4
+ exports.parseWorkflow = parseWorkflow;
5
+ exports.advanceWorkflow = advanceWorkflow;
6
+ const types_1 = require("./types");
7
+ const text = { type: 'string', maxLength: 1024 };
8
+ exports.WORKFLOW_SCHEMA = {
9
+ type: 'object', additionalProperties: false,
10
+ properties: {
11
+ phase: text, evidenceVersion: text, nextAction: text,
12
+ checks: { type: 'array', maxItems: 30, items: { type: 'object', additionalProperties: false, properties: { id: text, outcome: text, evidenceVersion: text }, required: ['id', 'outcome', 'evidenceVersion'] } },
13
+ findings: { type: 'array', maxItems: 30, items: { type: 'object', additionalProperties: false, properties: { id: text, status: { type: 'string', enum: ['open', 'resolved', 'dismissed'] }, summary: text }, required: ['id', 'status', 'summary'] } },
14
+ review: { type: 'object', additionalProperties: false, properties: { id: text, kind: { type: 'string', enum: ['full', 'targeted'] }, reason: text }, required: ['id', 'kind'] },
15
+ }, required: ['phase', 'evidenceVersion', 'nextAction', 'checks', 'findings'],
16
+ };
17
+ function parseWorkflow(value) {
18
+ if (value === undefined)
19
+ return undefined;
20
+ const bad = () => { throw new types_1.OrchestrationError('INVALID_WORKFLOW_CHECKPOINT'); };
21
+ const obj = (v, keys) => { if (!v || typeof v !== 'object' || Array.isArray(v) || Object.keys(v).some(k => !keys.includes(k)))
22
+ bad(); return v; };
23
+ const str = (v) => { if (typeof v !== 'string' || v.length > 1024)
24
+ bad(); };
25
+ const v = obj(value, ['phase', 'evidenceVersion', 'nextAction', 'checks', 'findings', 'review']);
26
+ for (const k of ['phase', 'evidenceVersion', 'nextAction'])
27
+ str(v[k]);
28
+ for (const key of ['checks', 'findings']) {
29
+ const items = v[key];
30
+ if (!Array.isArray(items) || items.length > 30)
31
+ bad();
32
+ for (const item of items) {
33
+ const fields = key === 'checks' ? ['id', 'outcome', 'evidenceVersion'] : ['id', 'status', 'summary'];
34
+ const row = obj(item, fields);
35
+ for (const f of fields)
36
+ str(row[f]);
37
+ if (key === 'findings' && !['open', 'resolved', 'dismissed'].includes(String(row.status)))
38
+ bad();
39
+ }
40
+ }
41
+ if (v.review !== undefined) {
42
+ const r = obj(v.review, ['id', 'kind', 'reason']);
43
+ str(r.id);
44
+ if (!['full', 'targeted'].includes(String(r.kind)))
45
+ bad();
46
+ if (r.reason !== undefined)
47
+ str(r.reason);
48
+ }
49
+ if (JSON.stringify(v).length > 16384)
50
+ bad();
51
+ return v;
52
+ }
53
+ function advanceWorkflow(previous, checkpoint, attemptId) {
54
+ if (previous?.attemptId === attemptId && JSON.stringify(previous.checkpoint) === JSON.stringify(checkpoint))
55
+ return previous;
56
+ const reviews = [...(previous?.reviews ?? [])], review = checkpoint.review;
57
+ let warning;
58
+ if (review && !reviews.some(r => r.id === review.id && r.evidenceVersion === checkpoint.evidenceVersion)) {
59
+ if (review.kind === 'full' && reviews.some(r => r.kind === 'full') && !review.reason?.trim())
60
+ warning = 'A full review already exists. Verify the changed evidence and unresolved findings; do not restart the full workflow merely because a fix was applied. State the new risk or explicit user request if another full review is necessary.';
61
+ reviews.push({ id: review.id, kind: review.kind, evidenceVersion: checkpoint.evidenceVersion });
62
+ }
63
+ return { version: (previous?.version ?? 0) + 1, observedAt: Date.now(), attemptId, checkpoint, reviews: reviews.slice(-24), warning };
64
+ }
65
+ exports.WORKER_WORKFLOW_RULES = `Work to a verifiable stopping condition, not repeated reassurance. Follow the requested skill's actual steps; do not add a second/native/full review merely because this is delegated work. Track completed verification against the evidence version (commit/tree/document revision), open findings by stable ID, and the next necessary action. Use task_report_progress with checkpoint at phase changes, after a review, after resolving findings, and before finalization; use ordinary text progress for short tasks. This is internal bookkeeping, not a request to message the user each time.
66
+ For a defect, trace the user's actual entry path and test the integration that fails before adding extra defensive layers. A missing helper/export is not proof of the original behavior regression. Check contradictory review findings against reachable code before changing anything. A completed full review is followed by fixes and targeted verification of affected behavior; another full review needs new substantial risk or an explicit user request, not just "one final check". Keep unresolved findings visible; do not suppress real defects to finish faster.
67
+ Choose checks appropriate to the work and machine capacity. Reuse successful checks only for unchanged relevant evidence. Batch related fixes and formatting before commit/push to avoid repeated full-suite hooks. Never bypass required checks, security boundaries or user approvals. Once required work and verification are complete, return the result with evidence and remaining limitations; optional polish or an advisory checkpoint must not restart completed phases. Advisory guidance is fallible: prefer newer direct evidence over stale claims that an earlier fix was already proven. These rules apply equally to native subagents you delegate to.`;
68
+ exports.AGENT_WORKFLOW_RULES = `Preserve the user's requested workflow without adding review rounds or widening its scope. A requested skill owns its procedure; do not append a mandatory second/native review unless the user or the actual skill requires it. Supervise from the latest task_status checkpoint (phase, evidenceVersion, checks and findings), not old progress prose or tool names. Worker checkpoints are reports, not independently verified facts. If evidence is missing or superseded, ask for a fresh checkpoint rather than declaring an old fix correct or forbidding relevant investigation. Advice should name the changed evidence, unresolved finding or concrete next step; do not repeatedly say finish/open PR/run review when those steps are already complete. Do not mistake an idle tool sample for a stall or a browser command from an earlier phase for current work. Keep user updates separate from internal supervision.`;
69
+ //# sourceMappingURL=workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/orchestration/workflow.ts"],"names":[],"mappings":";;;AA0BA,sCAkBC;AACD,0CAUC;AAvDD,mCAA6C;AAgB7C,MAAM,IAAI,GAAG,EAAC,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,IAAI,EAAC,CAAC;AAC/B,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAC,QAAQ,EAAC,oBAAoB,EAAC,KAAK;IACxC,UAAU,EAAC;QACT,KAAK,EAAC,IAAI,EAAC,eAAe,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI;QAC/C,MAAM,EAAC,EAAC,IAAI,EAAC,OAAO,EAAC,QAAQ,EAAC,EAAE,EAAC,KAAK,EAAC,EAAC,IAAI,EAAC,QAAQ,EAAC,oBAAoB,EAAC,KAAK,EAAC,UAAU,EAAC,EAAC,EAAE,EAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAC,eAAe,EAAC,IAAI,EAAC,EAAC,QAAQ,EAAC,CAAC,IAAI,EAAC,SAAS,EAAC,iBAAiB,CAAC,EAAC,EAAC;QACrL,QAAQ,EAAC,EAAC,IAAI,EAAC,OAAO,EAAC,QAAQ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CAAC;QAC7F,IAAG,MAAM,CAAC,IAAI,KAAG,MAAM,IAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA,EAAE,CAAA,CAAC,CAAC,IAAI,KAAG,MAAM,CAAC,IAAE,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE;YAC/E,OAAO,GAAC,wOAAwO,CAAC;QACnP,OAAO,CAAC,IAAI,CAAC,EAAC,EAAE,EAAC,MAAM,CAAC,EAAE,EAAC,IAAI,EAAC,MAAM,CAAC,IAAI,EAAC,eAAe,EAAC,UAAU,CAAC,eAAe,EAAC,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO,EAAC,OAAO,EAAC,CAAC,QAAQ,EAAE,OAAO,IAAE,CAAC,CAAC,GAAC,CAAC,EAAC,UAAU,EAAC,IAAI,CAAC,GAAG,EAAE,EAAC,SAAS,EAAC,UAAU,EAAC,OAAO,EAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAC,OAAO,EAAC,CAAC;AAC1H,CAAC;AACY,QAAA,qBAAqB,GAAG;;woBAEmmB,CAAC;AAC5nB,QAAA,oBAAoB,GAAG,s4BAAs4B,CAAC"}
@@ -0,0 +1,10 @@
1
+ /** Native Claude stream-json image input; never a file-reading tool grant. */
2
+ export interface InputImage {
3
+ type: 'image';
4
+ source: {
5
+ type: 'base64';
6
+ media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
7
+ data: string;
8
+ };
9
+ }
10
+ //# sourceMappingURL=input-image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-image.d.ts","sourceRoot":"","sources":["../../src/session/input-image.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,UAAU,EAAE,YAAY,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/G"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=input-image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-image.js","sourceRoot":"","sources":["../../src/session/input-image.ts"],"names":[],"mappings":""}
@@ -1,4 +1,6 @@
1
+ import type { InputImage } from './input-image';
1
2
  import { EventEmitter } from 'events';
3
+ import { RuntimeProfile } from './runtime-profile';
2
4
  import { AgentConfig, GatewayConfig } from '../types';
3
5
  import { type ChatChannelOrApi } from '../history/types';
4
6
  import { SessionStore } from './store';
@@ -13,6 +15,12 @@ export declare const INTERRUPTED_NO_REPLY_TEXT = "Session was interrupted before
13
15
  */
14
16
  export declare function resolveMaxHistoryMessages(agentMax?: number, globalMax?: number): number;
15
17
  export declare class SessionProcess extends EventEmitter {
18
+ readonly runtimeProfile?: RuntimeProfile | undefined;
19
+ private managedProcessGroup?;
20
+ private containerAttempt?;
21
+ managedGroupStopped: boolean;
22
+ get processId(): number | undefined;
23
+ get managedProcessId(): number | undefined;
16
24
  readonly sessionId: string;
17
25
  readonly chatId: string;
18
26
  readonly source: ChatChannelOrApi;
@@ -65,7 +73,8 @@ export declare class SessionProcess extends EventEmitter {
65
73
  private _querySettled;
66
74
  private pendingInitialPrompt?;
67
75
  private spawnedConnectors;
68
- constructor(sessionId: string, source: ChatChannelOrApi, agentConfig: AgentConfig, gatewayConfig: GatewayConfig, sessionStore: SessionStore, chatId?: string);
76
+ constructor(sessionId: string, source: ChatChannelOrApi, agentConfig: AgentConfig, gatewayConfig: GatewayConfig, sessionStore: SessionStore, chatId?: string, // for telegram/discord: actual chatId; for api: same as sessionId
77
+ runtimeProfile?: RuntimeProfile | undefined);
69
78
  /**
70
79
  * Resolve the model for this session.
71
80
  * Priority: per-session override > config.json on disk > cached agentConfig.
@@ -162,6 +171,9 @@ export declare class SessionProcess extends EventEmitter {
162
171
  * it is a tool-less API session that gets no MCP servers at all.
163
172
  */
164
173
  connectorConfigChanged(connectorId: string, resolvedServer: unknown): boolean;
174
+ /** Only trust connector namespaces actually written into this subprocess config. */
175
+ isSpawnedConnectorTool(name: string): boolean;
176
+ private managedMcpConfigPath?;
165
177
  private writeMcpConfig;
166
178
  /** Find the first API key that has access to this agent (agents: '*' or includes agentId). */
167
179
  private findApiKeyForAgent;
@@ -191,7 +203,7 @@ export declare class SessionProcess extends EventEmitter {
191
203
  * that Claude Code was replaying on every request.
192
204
  */
193
205
  private recoverFromCorruptedThinking;
194
- sendMessage(text: string): void;
206
+ sendMessage(text: string, images?: readonly InputImage[]): void;
195
207
  /**
196
208
  * Send a control keystroke to the PTY wrapper (Epic #195, Phase 3b). Only
197
209
  * meaningful on the interactive (pty-shell) backend — the headless backend has
@@ -215,7 +227,7 @@ export declare class SessionProcess extends EventEmitter {
215
227
  private isTrackedDispatchStillOutstanding;
216
228
  private resetBackgroundDispatchState;
217
229
  /**
218
- * Extend Telegram's working state only while a parent session is waiting for
230
+ * Extend Telegram's working state only while a agent session is waiting for
219
231
  * background Agent/Workflow/Monitor work. A bounded expiry (BACKGROUND_AGENT_GRACE_MS,
220
232
  * fixed from the dispatch timestamp — not renewed by later activity) releases
221
233
  * the state if the dispatch never sends its completion notification within
@@ -1 +1 @@
1
- {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/session/process.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAKtC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGtD,OAAO,EAAmC,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAevC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAqHvC,eAAO,MAAM,yBAAyB,oDAAoD,CAAC;AAE3F;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ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;;;OASG;IACH,kBAAkB,IAAI,OAAO;IAI7B,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAI/B;;;;;;;;OAQG;IACH,kCAAkC,IAAI,OAAO;IAK7C,SAAS,IAAI,OAAO;IAOd,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CA2D5B"}
@@ -38,12 +38,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.SessionProcess = exports.INTERRUPTED_NO_REPLY_TEXT = exports.MAX_HISTORY_MESSAGES = void 0;
40
40
  exports.resolveMaxHistoryMessages = resolveMaxHistoryMessages;
41
+ const container_1 = require("../orchestration/container");
41
42
  const child_process_1 = require("child_process");
42
43
  const crypto_1 = require("crypto");
43
44
  const events_1 = require("events");
44
45
  const fs = __importStar(require("fs"));
45
46
  const os = __importStar(require("os"));
46
47
  const path = __importStar(require("path"));
48
+ const runtime_profile_1 = require("./runtime-profile");
49
+ const string_decoder_1 = require("string_decoder");
50
+ const process_supervisor_1 = require("../orchestration/process-supervisor");
51
+ const capacity_1 = require("../orchestration/capacity");
47
52
  const chokidar_1 = __importDefault(require("chokidar"));
48
53
  const knowledge_1 = require("../agent/knowledge");
49
54
  const config_1 = require("../agent/dreaming/config");
@@ -229,10 +234,16 @@ const STATE_SUBDIR = {
229
234
  // in config.json, not here — see AgentConfig.whatsapp_cloud's doc comment),
230
235
  // so unlike `whatsapp` above this is single-purpose: message-turn state only.
231
236
  whatsapp_cloud: '.whatsapp-cloud-state',
237
+ wechat: '.wechat-state',
232
238
  };
233
239
  class SessionProcess extends events_1.EventEmitter {
234
- constructor(sessionId, source, agentConfig, gatewayConfig, sessionStore, chatId) {
240
+ get processId() { return this.isRunning() ? this.process?.pid : undefined; }
241
+ get managedProcessId() { return this.managedProcessGroup; }
242
+ constructor(sessionId, source, agentConfig, gatewayConfig, sessionStore, chatId, // for telegram/discord: actual chatId; for api: same as sessionId
243
+ runtimeProfile) {
235
244
  super();
245
+ this.runtimeProfile = runtimeProfile;
246
+ this.managedGroupStopped = false;
236
247
  this.lastActivityAt = Date.now(); // accessible by AgentRunner for eviction sort
237
248
  // Wall-clock time of the most recent BACKGROUND_DISPATCH_TOOLS tool_use seen
238
249
  // in this session's own turn, while no NEWER turn has started since. Cleared
@@ -362,6 +373,8 @@ class SessionProcess extends events_1.EventEmitter {
362
373
  return path.join(this.agentConfig.workspace, STATE_SUBDIR[this.sessionChannel], 'typing');
363
374
  }
364
375
  appendToStore(msg) {
376
+ if (this.runtimeProfile)
377
+ return Promise.resolve(); // orchestration owns canonical history operations
365
378
  return this.source !== 'api'
366
379
  ? this.sessionStore.appendTelegramMessage(this.agentConfig.id, this.chatId, this.sessionId, msg, this.sessionChannel)
367
380
  : this.sessionStore.appendMessage(this.agentConfig.id, this.sessionId, msg);
@@ -406,7 +419,7 @@ class SessionProcess extends events_1.EventEmitter {
406
419
  * re-spawn it with the latest model from config.json.
407
420
  */
408
421
  setupRestartWatcher() {
409
- if (this.restartWatcher)
422
+ if (this.restartWatcher || this.runtimeProfile)
410
423
  return;
411
424
  this.restartWatcher = chokidar_1.default.watch(this.restartSignalPath, { ignoreInitial: true });
412
425
  this.restartWatcher.on('add', () => {
@@ -647,7 +660,36 @@ class SessionProcess extends events_1.EventEmitter {
647
660
  const now = resolvedServer === undefined ? undefined : connectorFingerprint(resolvedServer);
648
661
  return this.spawnedConnectors.get(connectorId) !== now;
649
662
  }
663
+ /** Only trust connector namespaces actually written into this subprocess config. */
664
+ isSpawnedConnectorTool(name) {
665
+ if (!this.spawnedConnectors || this.agentConfig.type === 'app-agent' ||
666
+ this.agentConfig.allow_tools === false || this.runtimeProfile?.role === 'agent' || this.runtimeProfile?.connectorsAllowed === false ||
667
+ (this.runtimeProfile?.role === 'worker' && !this.runtimeProfile.hostExecution))
668
+ return false;
669
+ return [...this.spawnedConnectors.keys()].some(id => name.startsWith(`mcp__${id}__`) && name.length > id.length + 7);
670
+ }
650
671
  writeMcpConfig() {
672
+ if (this.runtimeProfile) {
673
+ // Orchestrators dispatch execution; only eligible workers receive connectors.
674
+ // App and isolated workers must never receive host connector credentials
675
+ // or start host-configured stdio servers inside their execution boundary.
676
+ if (this.runtimeProfile.role === 'agent' || this.agentConfig.allow_tools === false || this.runtimeProfile.connectorsAllowed === false || this.agentConfig.type === 'app-agent' || (this.runtimeProfile.role === 'worker' && !this.runtimeProfile.hostExecution))
677
+ return this.runtimeProfile.mcpConfigPath;
678
+ const ticket = JSON.parse(fs.readFileSync(this.runtimeProfile.mcpConfigPath, 'utf8'));
679
+ const connectors = (0, resolve_1.resolveEnabledConnectors)(this.agentConfig, this.gatewayConfig.gateway.customConnectors, this.gatewayConfig.gateway.connectorsDefaultEnabled ?? true);
680
+ this.spawnedConnectors = new Map();
681
+ for (const [id, server] of Object.entries(connectors)) {
682
+ if ((0, custom_1.isReservedConnectorId)(id))
683
+ continue;
684
+ this.spawnedConnectors.set(id, connectorFingerprint(server));
685
+ }
686
+ const servers = Object.fromEntries([...this.spawnedConnectors.keys()].map(id => [id, connectors[id]]));
687
+ const configPath = path.join(path.dirname(this.runtimeProfile.mcpConfigPath), 'managed-connectors.json');
688
+ fs.writeFileSync(configPath, JSON.stringify({ mcpServers: { ...servers, ...ticket.mcpServers } }), { mode: 0o600 });
689
+ fs.chmodSync(configPath, 0o600);
690
+ this.managedMcpConfigPath = configPath;
691
+ return configPath;
692
+ }
651
693
  if (this.source === 'api' && !this.agentConfig.allow_tools)
652
694
  return null;
653
695
  const stateDir = path.join(this.agentConfig.workspace, '.telegram-state');
@@ -845,6 +887,20 @@ class SessionProcess extends events_1.EventEmitter {
845
887
  '--print',
846
888
  '--verbose',
847
889
  ];
890
+ if (this.runtimeProfile) {
891
+ if (this.agentConfig.type === 'app-agent' && this.runtimeProfile.hostExecution)
892
+ throw new Error('Container roles cannot use host execution');
893
+ if (this.gatewayConfig.gateway.headless === false)
894
+ throw new Error('Orchestration runtime profile is only verified for the configured headless backend');
895
+ const context = this.runtimeProfile.context ?? fs.readFileSync(path.join(this.agentConfig.workspace, 'CLAUDE.md'), 'utf8');
896
+ args.push(...(0, runtime_profile_1.runtimeProfileArgs)({ ...this.runtimeProfile, context, checkpointCommand: this.containerAttempt && this.runtimeProfile.checkpointCommand ? `node ${this.containerAttempt.directory}/checkpoint.cjs ${this.containerAttempt.directory}/ticket.json` : this.runtimeProfile.checkpointCommand, containerExecution: this.agentConfig.type === 'app-agent', mcpConfigPath: this.containerAttempt?.config ?? mcpConfigPath ?? this.runtimeProfile.mcpConfigPath, skillPluginDir: this.containerAttempt && this.runtimeProfile.skillPluginDir ? this.containerAttempt.directory + '/skill-plugin' : this.runtimeProfile.skillPluginDir }, this.agentConfig.claude.extraFlags ?? []));
897
+ if (this.runtimeProfile.workerSession) {
898
+ const session = this.runtimeProfile.workerSession;
899
+ args.push(session.resume ? '--resume' : '--session-id', session.id);
900
+ }
901
+ args.push('--dangerously-skip-permissions');
902
+ return args;
903
+ }
848
904
  if (mcpConfigPath) {
849
905
  // NOTE: --strict-mcp-config is intentionally omitted.
850
906
  // With --strict-mcp-config, Claude Code blocks all plugin MCP servers (e.g. figma).
@@ -868,17 +924,22 @@ class SessionProcess extends events_1.EventEmitter {
868
924
  return args;
869
925
  // NOTE: NO --channels flag — messages arrive via stdin injection, not Telegram channels
870
926
  }
871
- static toStreamJsonTurn(text) {
927
+ static toStreamJsonTurn(text, images = []) {
872
928
  return JSON.stringify({
873
929
  type: 'user',
874
- message: { role: 'user', content: [{ type: 'text', text }] },
930
+ message: { role: 'user', content: [{ type: 'text', text }, ...images] },
875
931
  });
876
932
  }
877
933
  async spawnProcess() {
878
934
  const { historyPrompt, loadedAtSpawn, archivedCount, messageCountAtSpawn } = await this.buildInitialPrompt();
879
935
  this.spawnContext = { loadedAtSpawn, archivedCount, messageCountAtSpawn };
880
936
  // Determine if this is a docker-exec app-agent before computing paths
937
+ (0, container_1.assertContainerBinding)(this.agentConfig, this.runtimeProfile);
881
938
  const isAppAgent = this.agentConfig.type === 'app-agent' && !!this.agentConfig.container;
939
+ if (isAppAgent && this.runtimeProfile) {
940
+ this.containerAttempt = await (0, container_1.prepareContainerProfile)(this.agentConfig, this.runtimeProfile);
941
+ this.runtimeProfile.context = await (0, container_1.containerNode)(this.agentConfig.container, "process.stdout.write(require('fs').readFileSync('/workspace/CLAUDE.md','utf8'))");
942
+ }
882
943
  const mcpConfigPath = this.writeMcpConfig();
883
944
  // For app-agents, Claude runs inside the container where /workspace is mounted.
884
945
  // Convert host paths (agentConfig.workspace-relative) to container paths (/workspace/...).
@@ -978,7 +1039,7 @@ class SessionProcess extends events_1.EventEmitter {
978
1039
  CLAUDE_WORKSPACE: '/workspace',
979
1040
  GATEWAY_RESTART_SIGNAL_PATH: containerRestartPath,
980
1041
  };
981
- if (process.env.GATEWAY_API_URL)
1042
+ if (!this.runtimeProfile && process.env.GATEWAY_API_URL)
982
1043
  containerEnv.GATEWAY_API_URL = process.env.GATEWAY_API_URL;
983
1044
  // Secrets are forwarded by NAME only (`-e KEY`, no `=value`), which makes
984
1045
  // Docker read the value from this process's own environment (set on the spawn
@@ -989,8 +1050,8 @@ class SessionProcess extends events_1.EventEmitter {
989
1050
  // TELEGRAM_BOT_TOKEN travels by name for exactly the same reason as the
990
1051
  // Claude credentials — it is a bearer token for the agent's whole bot
991
1052
  // account. It is already placed in the spawn env below, unconditionally.
992
- const containerAuthEnv = isAppAgent ? this.resolveContainerAuthEnv() : {};
993
- const byNameKeys = ['TELEGRAM_BOT_TOKEN', ...Object.keys(containerAuthEnv)];
1053
+ const containerAuthEnv = isAppAgent || (this.runtimeProfile?.checkpointCommand && !this.runtimeProfile.hostExecution) ? this.resolveContainerAuthEnv() : {};
1054
+ const byNameKeys = [...(this.runtimeProfile ? [] : ['TELEGRAM_BOT_TOKEN']), ...Object.keys(containerAuthEnv)];
994
1055
  const dockerEnvFlags = [
995
1056
  ...Object.entries(containerEnv).flatMap(([k, v]) => ['-e', `${k}=${v}`]),
996
1057
  ...byNameKeys.flatMap((k) => ['-e', k]),
@@ -1000,7 +1061,7 @@ class SessionProcess extends events_1.EventEmitter {
1000
1061
  'exec', '--workdir', '/workspace', '--user', String(containerUid), '-i',
1001
1062
  ...dockerEnvFlags,
1002
1063
  this.agentConfig.container,
1003
- this.agentConfig.claudeBin ?? claudeBin,
1064
+ ...(this.containerAttempt ? ['node', '-e', container_1.CONTAINER_SUPERVISOR, this.containerAttempt.directory, this.agentConfig.claudeBin ?? claudeBin] : [this.agentConfig.claudeBin ?? claudeBin]),
1004
1065
  ...allArgs,
1005
1066
  ]
1006
1067
  : allArgs;
@@ -1015,22 +1076,42 @@ class SessionProcess extends events_1.EventEmitter {
1015
1076
  // so a bare `claude` resolves even if the gateway itself was launched with a
1016
1077
  // minimal PATH that predates the native-installer migration.
1017
1078
  const hardenedPath = (0, claude_bin_1.pathWithNativeBin)();
1018
- const proc = (0, child_process_1.spawn)(spawnBin, spawnArgs, {
1019
- env: {
1020
- ...process.env,
1021
- ...containerAuthEnv,
1022
- ...(hardenedPath ? { PATH: hardenedPath } : {}),
1023
- CLAUDE_WORKSPACE: isAppAgent ? '/workspace' : this.agentConfig.workspace,
1024
- TELEGRAM_BOT_TOKEN: this.agentConfig.telegram?.botToken ?? '',
1025
- GATEWAY_RESTART_SIGNAL_PATH: this.restartSignalPath,
1026
- ...(ptyRealBin ? { CLAUDE_REAL_BIN: ptyRealBin } : {}),
1027
- ...(ptyHeartbeatPath ? { PTY_SHELL_HEARTBEAT_PATH: ptyHeartbeatPath } : {}),
1028
- ...(ptyStreamSocketPath ? { PTY_SHELL_STREAM_SOCKET: ptyStreamSocketPath } : {}),
1029
- },
1030
- cwd: this.agentConfig.workspace,
1031
- stdio: ['pipe', 'pipe', 'pipe'],
1032
- });
1079
+ const capacityEnabled = Boolean(this.runtimeProfile || this.gatewayConfig.gateway.processLimits || this.gatewayConfig.agents?.some(agent => agent.orchestration?.enabled));
1080
+ const releaseCapacity = this.runtimeProfile?.capacityReserved ? () => { } : (0, capacity_1.gatewayCapacity)(this.gatewayConfig).acquire(this.runtimeProfile?.role ?? 'legacy', capacityEnabled);
1081
+ if (!releaseCapacity)
1082
+ throw Object.assign(new Error('Gateway process capacity exceeded'), { code: 'CAPACITY_EXCEEDED' });
1083
+ let proc;
1084
+ try {
1085
+ proc = (0, child_process_1.spawn)(spawnBin, spawnArgs, {
1086
+ env: {
1087
+ ...process.env,
1088
+ ...(!isAppAgent && this.runtimeProfile?.checkpointCommand && !this.runtimeProfile.hostExecution ? Object.fromEntries(CONTAINER_CREDENTIAL_KEYS.map(key => [key, undefined])) : {}),
1089
+ ...containerAuthEnv,
1090
+ ...(hardenedPath ? { PATH: hardenedPath } : {}),
1091
+ GATEWAY_ORIGIN_SESSION_ID: this.runtimeProfile?.originSessionId ?? this.sessionId,
1092
+ GATEWAY_TASK_ID: this.runtimeProfile?.taskId ?? '',
1093
+ GATEWAY_TASK_ATTEMPT_ID: this.runtimeProfile?.attemptId ?? '',
1094
+ CLAUDE_WORKSPACE: isAppAgent ? '/workspace' : this.agentConfig.workspace,
1095
+ TELEGRAM_BOT_TOKEN: this.agentConfig.telegram?.botToken ?? '',
1096
+ GATEWAY_RESTART_SIGNAL_PATH: this.restartSignalPath,
1097
+ ...(ptyRealBin ? { CLAUDE_REAL_BIN: ptyRealBin } : {}),
1098
+ ...(ptyHeartbeatPath ? { PTY_SHELL_HEARTBEAT_PATH: ptyHeartbeatPath } : {}),
1099
+ ...(ptyStreamSocketPath ? { PTY_SHELL_STREAM_SOCKET: ptyStreamSocketPath } : {}),
1100
+ },
1101
+ cwd: this.agentConfig.workspace,
1102
+ ...(this.runtimeProfile?.role === 'worker' && process.platform === 'linux' ? { detached: true } : {}),
1103
+ stdio: ['pipe', 'pipe', 'pipe'],
1104
+ });
1105
+ }
1106
+ catch (error) {
1107
+ releaseCapacity();
1108
+ throw error;
1109
+ }
1033
1110
  this.process = proc;
1111
+ proc.once('exit', releaseCapacity);
1112
+ proc.once('error', releaseCapacity);
1113
+ if (this.runtimeProfile?.role === 'worker' && process.platform === 'linux')
1114
+ this.managedProcessGroup = proc.pid;
1034
1115
  // Fresh child is alive: clear any exit observed for a prior process (e.g.
1035
1116
  // after an auto-restart), so isRunning()/interrupt() see it as live.
1036
1117
  this._exited = false;
@@ -1049,7 +1130,10 @@ class SessionProcess extends events_1.EventEmitter {
1049
1130
  // becomes Turn 2 — two separate responses forwarded to the channel. Deferring
1050
1131
  // history to sendMessage() bundles [history + activation + user reply] into a
1051
1132
  // single turn so Claude produces exactly one response.
1052
- if (this.source !== 'api') {
1133
+ if (this.runtimeProfile) {
1134
+ this.pendingInitialPrompt = historyPrompt ?? undefined;
1135
+ }
1136
+ else if (this.source !== 'api') {
1053
1137
  if (historyPrompt) {
1054
1138
  // Has history: defer to first incoming user message to prevent double-response.
1055
1139
  this.pendingInitialPrompt = `${historyPrompt}\n\n${CHANNELS_ACTIVATION_PROMPT}`;
@@ -1063,7 +1147,7 @@ class SessionProcess extends events_1.EventEmitter {
1063
1147
  this.pendingInitialPrompt = historyPrompt;
1064
1148
  }
1065
1149
  // Capture stdout — emit output events + persist assistant replies
1066
- const typingDir = this.source !== 'api' ? this.typingDir : null;
1150
+ const typingDir = this.source !== 'api' && !this.runtimeProfile ? this.typingDir : null;
1067
1151
  const heartbeatPath = typingDir ? path.join(typingDir, `${this.chatId}.heartbeat`) : null;
1068
1152
  const statusPath = typingDir ? path.join(typingDir, `${this.chatId}.status`) : null;
1069
1153
  const writeStatus = (status, detail) => {
@@ -1089,10 +1173,12 @@ class SessionProcess extends events_1.EventEmitter {
1089
1173
  // Track context from message_start events (first sub-call of each turn) for accurate context % display.
1090
1174
  // result.usage is cumulative across all sub-calls; message_start.usage reflects a single API call's context.
1091
1175
  let lastMessageStartContext = 0;
1176
+ let orchestrationOutputBuffer = '';
1177
+ const orchestrationDecoder = new string_decoder_1.StringDecoder('utf8');
1092
1178
  proc.stdout?.on('data', (data) => {
1093
1179
  // Child produced output => the session is doing real work right now. Count
1094
1180
  // this as activity so the idle reaper measures "time since the session last
1095
- // did anything", not just "time since the parent last injected a message".
1181
+ // did anything", not just "time since the agent last injected a message".
1096
1182
  // Without this, a self-paced loop (a /loop in dynamic mode using
1097
1183
  // ScheduleWakeup) that wakes itself and works entirely inside this child
1098
1184
  // process stays invisible to the idle timer and gets reaped mid-flight.
@@ -1104,7 +1190,11 @@ class SessionProcess extends events_1.EventEmitter {
1104
1190
  }
1105
1191
  catch { }
1106
1192
  }
1107
- const lines = data.toString().split('\n');
1193
+ const lines = this.runtimeProfile
1194
+ ? (orchestrationOutputBuffer + orchestrationDecoder.write(data)).split('\n')
1195
+ : data.toString().split('\n');
1196
+ if (this.runtimeProfile)
1197
+ orchestrationOutputBuffer = lines.pop() ?? '';
1108
1198
  for (const line of lines) {
1109
1199
  if (!line.trim())
1110
1200
  continue;
@@ -1410,7 +1500,7 @@ class SessionProcess extends events_1.EventEmitter {
1410
1500
  if (this.lastSpawnAt && Date.now() - this.lastSpawnAt >= RESTART_COUNT_RESET_MS) {
1411
1501
  this.restartCount = 0;
1412
1502
  }
1413
- if (!this.stopping)
1503
+ if (!this.stopping && !this.runtimeProfile)
1414
1504
  this.scheduleRestart();
1415
1505
  });
1416
1506
  proc.on('error', (err) => {
@@ -1498,6 +1588,8 @@ class SessionProcess extends events_1.EventEmitter {
1498
1588
  * that Claude Code was replaying on every request.
1499
1589
  */
1500
1590
  recoverFromCorruptedThinking() {
1591
+ if (this.runtimeProfile)
1592
+ return; // recovery belongs to the orchestration, never replay task effects
1501
1593
  if (this.restartRequested || this.stopping)
1502
1594
  return; // already respawning
1503
1595
  if (this.thinkingRecoveryCount >= MAX_THINKING_RECOVERIES) {
@@ -1517,7 +1609,7 @@ class SessionProcess extends events_1.EventEmitter {
1517
1609
  if (this.process)
1518
1610
  this.process.kill('SIGTERM');
1519
1611
  }
1520
- sendMessage(text) {
1612
+ sendMessage(text, images = []) {
1521
1613
  if (!this.process?.stdin?.writable) {
1522
1614
  this.logger.warn('Cannot send message: subprocess not running', {
1523
1615
  sessionId: this.sessionId,
@@ -1530,7 +1622,7 @@ class SessionProcess extends events_1.EventEmitter {
1530
1622
  // Signal queued state + ensure typing signal file exists for this turn.
1531
1623
  // If the previous turn already called stop() and cleared the typing loop,
1532
1624
  // re-creating the signal file here lets stop() restart the loop for queued turns.
1533
- if (this.source !== 'api') {
1625
+ if (this.source !== 'api' && !this.runtimeProfile) {
1534
1626
  const typingDir = this.typingDir;
1535
1627
  const typingSignalPath = path.join(typingDir, this.chatId);
1536
1628
  const statusPath = path.join(typingDir, `${this.chatId}.status`);
@@ -1546,7 +1638,7 @@ class SessionProcess extends events_1.EventEmitter {
1546
1638
  ? `${this.pendingInitialPrompt}\n\n${text}`
1547
1639
  : text;
1548
1640
  this.pendingInitialPrompt = undefined;
1549
- this.process.stdin.write(SessionProcess.toStreamJsonTurn(fullText) + '\n');
1641
+ this.process.stdin.write(SessionProcess.toStreamJsonTurn(fullText, images) + '\n');
1550
1642
  }
1551
1643
  /**
1552
1644
  * Send a control keystroke to the PTY wrapper (Epic #195, Phase 3b). Only
@@ -1651,7 +1743,7 @@ class SessionProcess extends events_1.EventEmitter {
1651
1743
  this.clearBackgroundWaitTimer();
1652
1744
  }
1653
1745
  /**
1654
- * Extend Telegram's working state only while a parent session is waiting for
1746
+ * Extend Telegram's working state only while a agent session is waiting for
1655
1747
  * background Agent/Workflow/Monitor work. A bounded expiry (BACKGROUND_AGENT_GRACE_MS,
1656
1748
  * fixed from the dispatch timestamp — not renewed by later activity) releases
1657
1749
  * the state if the dispatch never sends its completion notification within
@@ -1660,7 +1752,7 @@ class SessionProcess extends events_1.EventEmitter {
1660
1752
  * BACKGROUND_AGENT_GRACE_MS.
1661
1753
  */
1662
1754
  retainBackgroundWorkingState() {
1663
- if (this.source !== 'telegram' || !this.hasLikelyOutstandingBackgroundWork())
1755
+ if (this.runtimeProfile || this.source !== 'telegram' || !this.hasLikelyOutstandingBackgroundWork())
1664
1756
  return false;
1665
1757
  const processingPath = path.join(this.typingDir, `${this.chatId}.processing`);
1666
1758
  try {
@@ -1712,7 +1804,7 @@ class SessionProcess extends events_1.EventEmitter {
1712
1804
  }
1713
1805
  }
1714
1806
  this.emit('processingChange', active);
1715
- if (this.source === 'telegram') {
1807
+ if (this.source === 'telegram' && !this.runtimeProfile) {
1716
1808
  const processingPath = path.join(this.typingDir, `${this.chatId}.processing`);
1717
1809
  try {
1718
1810
  if (active) {
@@ -1815,6 +1907,16 @@ class SessionProcess extends events_1.EventEmitter {
1815
1907
  }
1816
1908
  async stop() {
1817
1909
  this.stopping = true;
1910
+ if (this.containerAttempt && this.agentConfig.container) {
1911
+ this.managedGroupStopped = await (0, container_1.stopContainerProfile)(this.agentConfig.container, this.containerAttempt.directory);
1912
+ this.containerAttempt = undefined;
1913
+ }
1914
+ if (this.managedProcessGroup) {
1915
+ const hostStopped = await (0, process_supervisor_1.stopProcessGroup)(this.managedProcessGroup);
1916
+ this.managedGroupStopped = this.agentConfig.type === 'app-agent' ? this.managedGroupStopped && hostStopped : hostStopped;
1917
+ if (this.managedGroupStopped)
1918
+ this.managedProcessGroup = undefined;
1919
+ }
1818
1920
  this.resetBackgroundDispatchState();
1819
1921
  await this.restartWatcher?.close();
1820
1922
  this.restartWatcher = null;
@@ -1822,7 +1924,7 @@ class SessionProcess extends events_1.EventEmitter {
1822
1924
  fs.rmSync(this.restartSignalPath, { force: true });
1823
1925
  }
1824
1926
  catch { }
1825
- if (this.source === 'telegram') {
1927
+ if (this.source === 'telegram' && !this.runtimeProfile) {
1826
1928
  try {
1827
1929
  fs.rmSync(path.join(this.typingDir, `${this.chatId}.processing`), { force: true });
1828
1930
  }
@@ -1837,6 +1939,13 @@ class SessionProcess extends events_1.EventEmitter {
1837
1939
  // bind-mounts this path) can be alive for up to the 10s graceful-shutdown
1838
1940
  // window immediately after this point, and must not find it gone under it.
1839
1941
  const removeSessionDir = () => {
1942
+ if (this.managedMcpConfigPath) {
1943
+ try {
1944
+ fs.rmSync(this.managedMcpConfigPath, { force: true });
1945
+ }
1946
+ catch { }
1947
+ this.managedMcpConfigPath = undefined;
1948
+ }
1840
1949
  try {
1841
1950
  fs.rmSync(path.join(this.agentConfig.workspace, '.sessions', this.sessionId), { recursive: true, force: true });
1842
1951
  }