synurex 2026.2.19-1

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 (1944) hide show
  1. package/CHANGELOG.md +1594 -0
  2. package/LICENSE +21 -0
  3. package/README-header.png +0 -0
  4. package/README.md +547 -0
  5. package/THIRD_PARTY_LICENSES.txt +27 -0
  6. package/assets/avatar-placeholder.svg +19 -0
  7. package/assets/chrome-extension/README.md +22 -0
  8. package/assets/chrome-extension/background.js +438 -0
  9. package/assets/chrome-extension/icons/icon128.png +0 -0
  10. package/assets/chrome-extension/icons/icon16.png +0 -0
  11. package/assets/chrome-extension/icons/icon32.png +0 -0
  12. package/assets/chrome-extension/icons/icon48.png +0 -0
  13. package/assets/chrome-extension/manifest.json +25 -0
  14. package/assets/chrome-extension/options.html +196 -0
  15. package/assets/chrome-extension/options.js +59 -0
  16. package/assets/dmg-background-small.png +0 -0
  17. package/assets/dmg-background.png +0 -0
  18. package/dist/Synurex-root-CbEdPwLE.js +84 -0
  19. package/dist/Synurex-root-CwTH98Xq.js +84 -0
  20. package/dist/accounts-B6AkTILW.js +250 -0
  21. package/dist/accounts-BqN2SY0Z.js +251 -0
  22. package/dist/acp-cli-C1jHGRAm.js +926 -0
  23. package/dist/acp-cli-C3a9o7M2.js +923 -0
  24. package/dist/agent-9DtpfYJk.js +704 -0
  25. package/dist/agent-N2Qtra36.js +704 -0
  26. package/dist/agent-scope-CRRhJ7Hf.js +370 -0
  27. package/dist/agent-scope-CpSMNwey.js +611 -0
  28. package/dist/agent-scope-DNmzkYn4.js +370 -0
  29. package/dist/archive-Dy3Ezb-5.js +85 -0
  30. package/dist/archive-ccN9aDgq.js +85 -0
  31. package/dist/audit--oGM5x0J.js +1853 -0
  32. package/dist/audit-CM8pyctg.js +1853 -0
  33. package/dist/auth-3NYeRZYb.js +192 -0
  34. package/dist/auth-CVOB8Q9A.js +192 -0
  35. package/dist/auth-health-BSF-YNSl.js +149 -0
  36. package/dist/auth-health-BrChJQW-.js +149 -0
  37. package/dist/auth-profiles-xwZAMwdh.js +2981 -0
  38. package/dist/boolean-BgXe2hyu.js +30 -0
  39. package/dist/brew-CAcErcKz.js +46 -0
  40. package/dist/brew-CcZV0dSS.js +46 -0
  41. package/dist/call-BJsfB_NC.js +280 -0
  42. package/dist/call-mnjMMyVJ.js +280 -0
  43. package/dist/channel-options-BXpm2xHl.js +32 -0
  44. package/dist/channel-options-Bjh17Z08.js +62 -0
  45. package/dist/channel-selection-D2iDbzGy.js +51 -0
  46. package/dist/channel-selection-i-6yBKAk.js +51 -0
  47. package/dist/channel-summary-Cw9cmi4M.js +1216 -0
  48. package/dist/channel-summary-D7joKboS.js +1216 -0
  49. package/dist/channels-cli-8HUWD1_p.js +1415 -0
  50. package/dist/channels-cli-DFia3kGl.js +1413 -0
  51. package/dist/channels-status-issues-CT6Q1t1h.js +18 -0
  52. package/dist/channels-status-issues-CgVNTMMz.js +18 -0
  53. package/dist/chrome-CXlGlG3I.js +1953 -0
  54. package/dist/chrome-D0V3Ybil.js +1973 -0
  55. package/dist/clack-prompter-B9yLhyOm.js +92 -0
  56. package/dist/clack-prompter-C7J7X7j7.js +92 -0
  57. package/dist/cli-1b35n5Cc.js +86 -0
  58. package/dist/cli-BYL7Dz_4.js +89 -0
  59. package/dist/cli-utils-BkRQdAoC.js +43 -0
  60. package/dist/cli-utils-DzrdzskQ.js +43 -0
  61. package/dist/client-atZzP6kK.js +1814 -0
  62. package/dist/command-format-CEnDvS9q.js +56 -0
  63. package/dist/command-format-DUskR3Ej.js +42 -0
  64. package/dist/command-format-rFzrPj6c.js +56 -0
  65. package/dist/command-options-BnW-e302.js +33 -0
  66. package/dist/commands-U_88HsqX.js +230 -0
  67. package/dist/completion-cli-Bh3ds9Rv.js +773 -0
  68. package/dist/completion-cli-BhVl7J3C.js +434 -0
  69. package/dist/config-AFzxllYx.js +4924 -0
  70. package/dist/config-BBxxzNm-.js +4923 -0
  71. package/dist/config-UB10lGn3.js +5664 -0
  72. package/dist/config-guard-BCvAEaxA.js +5484 -0
  73. package/dist/configure-0W-OLHK1.js +895 -0
  74. package/dist/configure-D4ci8KU6.js +896 -0
  75. package/dist/constants-Cf-Zsiqd.js +65 -0
  76. package/dist/constants-CpnpJcmu.js +65 -0
  77. package/dist/control-service-BLzGkUMf.js +61 -0
  78. package/dist/control-service-DpyCNhOa.js +61 -0
  79. package/dist/cron-cli-2W0wnKNI.js +457 -0
  80. package/dist/cron-cli-BGc0ZmXl.js +454 -0
  81. package/dist/daemon-cli-C4IIRXZr.js +758 -0
  82. package/dist/daemon-cli-RFrEzOyc.js +757 -0
  83. package/dist/daemon-runtime-BlKOqOPH.js +517 -0
  84. package/dist/daemon-runtime-CRdmLdkD.js +517 -0
  85. package/dist/deliver-B0C5m0kU.js +2587 -0
  86. package/dist/deliver-BUV-sfaF.js +2557 -0
  87. package/dist/deliver-CQQ0e2eM.js +2587 -0
  88. package/dist/deps-D1eiWUgD.js +27 -0
  89. package/dist/deps-DgFrcXzw.js +27 -0
  90. package/dist/devices-cli-CUYqlUBU.js +207 -0
  91. package/dist/devices-cli-De1Q_0ob.js +204 -0
  92. package/dist/directory-cli-DYkFHmO6.js +244 -0
  93. package/dist/directory-cli-DoquUzqm.js +247 -0
  94. package/dist/dispatcher-BLeixzBZ.js +160 -0
  95. package/dist/dns-cli-C5dXU6Nk.js +198 -0
  96. package/dist/dns-cli-rkR0HJpi.js +201 -0
  97. package/dist/docs-cli-CqtgkhfC.js +161 -0
  98. package/dist/docs-cli-DrFTuzUe.js +159 -0
  99. package/dist/doctor-Cakg6jea.js +2577 -0
  100. package/dist/doctor-Cuk5zryG.js +2579 -0
  101. package/dist/entry.js +1336 -0
  102. package/dist/env-DgIs6BZg.js +32 -0
  103. package/dist/errors-C8t2PjW_.js +1952 -0
  104. package/dist/exec-B8JKbXKW.js +246 -0
  105. package/dist/exec-Dloa-d0d.js +246 -0
  106. package/dist/exec-EqLC5sqa.js +1103 -0
  107. package/dist/exec-approvals-B-sykLIC.js +1043 -0
  108. package/dist/exec-approvals-Ff_p0CYa.js +1043 -0
  109. package/dist/exec-approvals-cli-CfSTGR7F.js +388 -0
  110. package/dist/exec-approvals-cli-DBgnm_6P.js +385 -0
  111. package/dist/extensionAPI.js +68185 -0
  112. package/dist/format-8citvr_1.js +34 -0
  113. package/dist/format-tlvh4-cQ.js +34 -0
  114. package/dist/gateway-cli-BKJbSNiq.js +17878 -0
  115. package/dist/gateway-cli-DMbgzP3o.js +17877 -0
  116. package/dist/gateway-rpc-CFkdcw9l.js +28 -0
  117. package/dist/gateway-rpc-CJljb7MY.js +28 -0
  118. package/dist/github-copilot-auth-BGWtD7lK.js +1256 -0
  119. package/dist/github-copilot-auth-Bog6I9WM.js +1256 -0
  120. package/dist/github-copilot-token-BOoCTERW.js +103 -0
  121. package/dist/github-copilot-token-SLWintYd.js +103 -0
  122. package/dist/github-copilot-token-_jdpoYjM.js +103 -0
  123. package/dist/gmail-setup-utils-C97cHaGd.js +428 -0
  124. package/dist/gmail-setup-utils-n354D0jO.js +428 -0
  125. package/dist/health-format-CLSugjQl.js +1383 -0
  126. package/dist/health-format-KsXnqZiA.js +1382 -0
  127. package/dist/help-format-DuMTLWZ-.js +17 -0
  128. package/dist/help-format-GYRujDx9.js +17 -0
  129. package/dist/helpers-BiyEksaK.js +25 -0
  130. package/dist/helpers-DMlRCrD6.js +10 -0
  131. package/dist/helpers-azbX_hrI.js +25 -0
  132. package/dist/helpers-yjIEMzi8.js +10 -0
  133. package/dist/hooks-cli-DXs2Jiyd.js +1061 -0
  134. package/dist/hooks-cli-Dsah_Ryz.js +1058 -0
  135. package/dist/hooks-status-CpkHFMVY.js +443 -0
  136. package/dist/hooks-status-DQRtaH38.js +443 -0
  137. package/dist/image-C6SHcuJM.js +1421 -0
  138. package/dist/image-Cyv4Hr2t.js +629 -0
  139. package/dist/image-DXuHvpqC.js +629 -0
  140. package/dist/index.js +5667 -0
  141. package/dist/installs-BvY-yqDY.js +425 -0
  142. package/dist/installs-Snp4gUlG.js +425 -0
  143. package/dist/is-main-B6kCyqsv.js +25 -0
  144. package/dist/is-main-PYGa3tDA.js +25 -0
  145. package/dist/links-B79LZSNJ.js +15 -0
  146. package/dist/links-iCD68SwJ.js +15 -0
  147. package/dist/loader-ysGIXyYq.js +64701 -0
  148. package/dist/logging-BWRYHvLp.js +1 -0
  149. package/dist/logging-CzN9OPmT.js +15 -0
  150. package/dist/logging-awp_aUN6.js +15 -0
  151. package/dist/logging-pqyrk15z.js +1 -0
  152. package/dist/login-qr-BEXsF0Oj.js +475 -0
  153. package/dist/login-qr-D823w1Qv.js +478 -0
  154. package/dist/login-qr-wnUfVUoC.js +478 -0
  155. package/dist/logs-cli-D912P9Qo.js +230 -0
  156. package/dist/logs-cli-DHYl4Nfl.js +227 -0
  157. package/dist/manager-DORkoiXy.js +3216 -0
  158. package/dist/manager-MLoKmXjg.js +3218 -0
  159. package/dist/manager-e20ne1Ai.js +3216 -0
  160. package/dist/manifest-registry-D8FEq9qs.js +668 -0
  161. package/dist/manifest-registry-DjRSe72U.js +668 -0
  162. package/dist/message-channel-DJEeCAZD.js +110 -0
  163. package/dist/message-channel-DcxF0eJh.js +110 -0
  164. package/dist/model-selection-CjYymzT8.js +2983 -0
  165. package/dist/model-selection-Cz_VcpX5.js +2734 -0
  166. package/dist/models-cli-CURq5BOw.js +2542 -0
  167. package/dist/models-cli-_y06d7uQ.js +2545 -0
  168. package/dist/net-MZzhgr1g.js +1814 -0
  169. package/dist/node-cli-BkEdPem3.js +1456 -0
  170. package/dist/node-cli-PesFC8YY.js +1459 -0
  171. package/dist/node-service-CmyQuldc.js +67 -0
  172. package/dist/node-service-DB0Rp9Fr.js +67 -0
  173. package/dist/nodes-cli-BV7z71Ke.js +1207 -0
  174. package/dist/nodes-cli-D-pPXmLu.js +1210 -0
  175. package/dist/nodes-screen-B240wNB8.js +157 -0
  176. package/dist/nodes-screen-CGLXLco9.js +157 -0
  177. package/dist/note-_C44YfAQ.js +73 -0
  178. package/dist/note-rStT8AJi.js +73 -0
  179. package/dist/onboard-channels-CSGrNeHm.js +671 -0
  180. package/dist/onboard-channels-CyYMvXjh.js +671 -0
  181. package/dist/onboard-skills-BzZrWnt3.js +3452 -0
  182. package/dist/onboard-skills-Z3OoXEqp.js +3452 -0
  183. package/dist/onboarding--5CEtfSX.js +3269 -0
  184. package/dist/pairing-cli-BrPmwezL.js +114 -0
  185. package/dist/pairing-cli-CN183i69.js +117 -0
  186. package/dist/pairing-labels-CrJtLbMY.js +9 -0
  187. package/dist/pairing-labels-DXioxZ5X.js +9 -0
  188. package/dist/pairing-store-D_NP0mJs.js +391 -0
  189. package/dist/pairing-store-pdzxfI5n.js +391 -0
  190. package/dist/parse-BZz5lHzQ.js +23 -0
  191. package/dist/parse-DqAvJRIf.js +23 -0
  192. package/dist/parse-log-line-BnB7770k.js +44 -0
  193. package/dist/parse-log-line-DSvJi17i.js +44 -0
  194. package/dist/parse-timeout-DV8NQQWk.js +16 -0
  195. package/dist/parse-timeout-Du-wHHNi.js +16 -0
  196. package/dist/path-env-Bc8ZqjfY.js +77 -0
  197. package/dist/path-env-DwZUJC_M.js +77 -0
  198. package/dist/paths-8P2BYpvK.js +156 -0
  199. package/dist/paths-Cn5vXlEi.js +43 -0
  200. package/dist/paths-D4TjaAs9.js +40 -0
  201. package/dist/paths-Drx5WZ13.js +172 -0
  202. package/dist/paths-mzsdSoO2.js +43 -0
  203. package/dist/pi-embedded-helpers-Dpu3lm3V.js +1303 -0
  204. package/dist/pi-embedded-helpers-N_L31uhW.js +1303 -0
  205. package/dist/pi-embedded-helpers-dkrwwXev.js +8481 -0
  206. package/dist/pi-model-discovery-CV2V1HHz.js +20 -0
  207. package/dist/pi-model-discovery-DzEIEgHL.js +20 -0
  208. package/dist/pi-model-discovery-EhM2JAQo.js +20 -0
  209. package/dist/pi-tools.policy-m0G0As1p.js +230 -0
  210. package/dist/plugin-auto-enable-Bu3hK0U6.js +460 -0
  211. package/dist/plugin-auto-enable-Ca3Ou67i.js +460 -0
  212. package/dist/plugin-sdk/index.js +24446 -0
  213. package/dist/plugin-sdk/pi-model-discovery-Dw3A6oXH.js +37 -0
  214. package/dist/plugins-Bng3p5bC.js +496 -0
  215. package/dist/plugins-C1mc_xWv.js +495 -0
  216. package/dist/plugins-cli-B8FonfqG.js +441 -0
  217. package/dist/plugins-cli-B9q0wqUI.js +444 -0
  218. package/dist/ports-DKGBzWgI.js +96 -0
  219. package/dist/program-_5hB5I-4.js +191 -0
  220. package/dist/progress-Bcjniu7m.js +133 -0
  221. package/dist/progress-DWODVbwW.js +133 -0
  222. package/dist/prompt-style-CFsleyxV.js +9 -0
  223. package/dist/prompt-style-DZli5767.js +9 -0
  224. package/dist/prompts-CudpZgTI.js +10 -0
  225. package/dist/prompts-FbZThK8w.js +10 -0
  226. package/dist/pw-ai-BUeSOvm-.js +1649 -0
  227. package/dist/pw-ai-GjX4Az_L.js +1649 -0
  228. package/dist/pw-ai-bugVLPkL.js +1651 -0
  229. package/dist/qmd-manager-C1JB3Owf.js +677 -0
  230. package/dist/qmd-manager-TkF_5Pm-.js +676 -0
  231. package/dist/qmd-manager-t9qHekRb.js +674 -0
  232. package/dist/redact-BIMJ3ntQ.js +94 -0
  233. package/dist/redact-Bt-krp_b.js +97 -0
  234. package/dist/redact-DJCFY628.js +97 -0
  235. package/dist/register.subclis-CZG20DZj.js +348 -0
  236. package/dist/reply-8T1JOF0R.js +64704 -0
  237. package/dist/rolldown-runtime-Cbj13DAv.js +20 -0
  238. package/dist/routes-BxFcXB4m.js +2411 -0
  239. package/dist/routes-Dw3vw8Re.js +2411 -0
  240. package/dist/rpc-DgcF4XNR.js +95 -0
  241. package/dist/rpc-f-LmE9z_.js +95 -0
  242. package/dist/run-main-_bbXf2vQ.js +194 -0
  243. package/dist/sandbox-BcOPJhQv.js +2945 -0
  244. package/dist/sandbox-DfBaWfDh.js +2944 -0
  245. package/dist/sandbox-cli-BRcke02J.js +460 -0
  246. package/dist/sandbox-cli-CbUgIVf2.js +463 -0
  247. package/dist/security-cli-76hHzPsz.js +505 -0
  248. package/dist/security-cli-CQ6iSAev.js +508 -0
  249. package/dist/server-context-BuV65eg5.js +740 -0
  250. package/dist/server-context-CFielb4y.js +740 -0
  251. package/dist/server-node-events-CkLBKtGs.js +216 -0
  252. package/dist/server-node-events-D_3bg9qE.js +219 -0
  253. package/dist/service-CZFM7dlu.js +680 -0
  254. package/dist/service-audit-DBdadurs.js +537 -0
  255. package/dist/service-audit-DptlZVXP.js +537 -0
  256. package/dist/service-sZqtAG53.js +680 -0
  257. package/dist/session-cost-usage-CPvtWzot.js +692 -0
  258. package/dist/session-cost-usage-lYVH5MAy.js +692 -0
  259. package/dist/session-key-DrNCyvP1.js +182 -0
  260. package/dist/session-key-n2HVbrj0.js +182 -0
  261. package/dist/shared-Bl4lcfSF.js +74 -0
  262. package/dist/shared-C79dnas0.js +74 -0
  263. package/dist/shared-CDe5yKDd.js +152 -0
  264. package/dist/shared-Cpd7X2eE.js +152 -0
  265. package/dist/skill-scanner-BoGjHXUZ.js +255 -0
  266. package/dist/skill-scanner-COatt01v.js +255 -0
  267. package/dist/skills-CrYcs9jK.js +694 -0
  268. package/dist/skills-DxzXqcWw.js +693 -0
  269. package/dist/skills-cli-BWqUiFIC.js +287 -0
  270. package/dist/skills-cli-C2rWGqKQ.js +290 -0
  271. package/dist/skills-status-Bhe2beiQ.js +187 -0
  272. package/dist/skills-status-DQyBTrvU.js +187 -0
  273. package/dist/sqlite-BjBQdG8T.js +239 -0
  274. package/dist/sqlite-BjhYBODp.js +221 -0
  275. package/dist/sqlite-CbZh0dx1.js +239 -0
  276. package/dist/status-BF8IVV7c.js +21 -0
  277. package/dist/status-BHPh7bCk.js +27 -0
  278. package/dist/status-CWDof7Cn.js +21 -0
  279. package/dist/status-DyjCSdtm.js +27 -0
  280. package/dist/status-RJGk9wHW.js +3177 -0
  281. package/dist/subsystem-DPYBJG7C.js +838 -0
  282. package/dist/system-cli-BY3oOcLX.js +83 -0
  283. package/dist/system-cli-pg7MxYKd.js +80 -0
  284. package/dist/systemd-DerMq_3Y.js +438 -0
  285. package/dist/systemd-Gt0riLnX.js +438 -0
  286. package/dist/systemd-hints-C6JS-A6Y.js +19 -0
  287. package/dist/systemd-hints-Db4JjAxJ.js +19 -0
  288. package/dist/systemd-linger-CRL7Xf4C.js +75 -0
  289. package/dist/systemd-linger-DS0IcHsk.js +75 -0
  290. package/dist/table-BzJyfJCd.js +279 -0
  291. package/dist/table-DCcFNw6e.js +279 -0
  292. package/dist/tailnet-Byp3obcc.js +42 -0
  293. package/dist/tailnet-DLDGNuH2.js +42 -0
  294. package/dist/tailscale-9MusRvOi.js +225 -0
  295. package/dist/tailscale-CGhNcgVS.js +252 -0
  296. package/dist/tool-display-C9u4CdQu.js +795 -0
  297. package/dist/tool-display-D_HGmnfa.js +795 -0
  298. package/dist/transcript-events-Bv_eRVym.js +17 -0
  299. package/dist/transcript-events-ChU6IQwp.js +17 -0
  300. package/dist/transcript-events-JLH5W4He.js +17 -0
  301. package/dist/tui-BPqDn4Jf.js +3090 -0
  302. package/dist/tui-BniTBjBP.js +3089 -0
  303. package/dist/tui-cli-AeeP52_J.js +58 -0
  304. package/dist/tui-cli-DrWl0dkQ.js +55 -0
  305. package/dist/update-BKGU5x_o.js +317 -0
  306. package/dist/update-CZqqbW73.js +317 -0
  307. package/dist/update-cli-DTXxX27F.js +1036 -0
  308. package/dist/update-cli-j0POazuO.js +1034 -0
  309. package/dist/update-runner-BY-i_k4L.js +1458 -0
  310. package/dist/update-runner-CmdPxJg5.js +1458 -0
  311. package/dist/usage-format-BcU1flOY.js +36 -0
  312. package/dist/usage-format-DvowRSs-.js +36 -0
  313. package/dist/utils-C7NsUvD1.js +192 -0
  314. package/dist/utils-DBu98aoz.js +188 -0
  315. package/dist/webhooks-cli-BBw-pRTs.js +309 -0
  316. package/dist/webhooks-cli-BXxSGFuL.js +312 -0
  317. package/dist/widearea-dns-C2mRm6hu.js +127 -0
  318. package/dist/widearea-dns-DbdWF6kP.js +127 -0
  319. package/dist/ws-CEcdsnN9.js +13 -0
  320. package/dist/ws-D091yo4M.js +13 -0
  321. package/dist/ws-log-Bpm8rpoP.js +267 -0
  322. package/dist/ws-log-vBkmxf4_.js +267 -0
  323. package/dist/wsl-QYB9yGZN.js +160 -0
  324. package/docs/.i18n/README.md +31 -0
  325. package/docs/.i18n/glossary.zh-CN.json +210 -0
  326. package/docs/.i18n/zh-CN.tm.jsonl +1329 -0
  327. package/docs/CNAME +1 -0
  328. package/docs/assets/macos-onboarding/01-macos-warning.jpeg +0 -0
  329. package/docs/assets/macos-onboarding/02-local-networks.jpeg +0 -0
  330. package/docs/assets/macos-onboarding/03-security-notice.png +0 -0
  331. package/docs/assets/macos-onboarding/04-choose-gateway.png +0 -0
  332. package/docs/assets/macos-onboarding/05-permissions.png +0 -0
  333. package/docs/assets/openclaw-logo-text-dark.png +0 -0
  334. package/docs/assets/openclaw-logo-text.png +0 -0
  335. package/docs/assets/pixel-lobster.svg +60 -0
  336. package/docs/assets/showcase/agents-ui.jpg +0 -0
  337. package/docs/assets/showcase/bambu-cli.png +0 -0
  338. package/docs/assets/showcase/codexmonitor.png +0 -0
  339. package/docs/assets/showcase/gohome-grafana.png +0 -0
  340. package/docs/assets/showcase/ios-testflight.jpg +0 -0
  341. package/docs/assets/showcase/oura-health.png +0 -0
  342. package/docs/assets/showcase/padel-cli.svg +11 -0
  343. package/docs/assets/showcase/padel-screenshot.jpg +0 -0
  344. package/docs/assets/showcase/papla-tts.jpg +0 -0
  345. package/docs/assets/showcase/pr-review-telegram.jpg +0 -0
  346. package/docs/assets/showcase/roborock-screenshot.jpg +0 -0
  347. package/docs/assets/showcase/roborock-status.svg +13 -0
  348. package/docs/assets/showcase/roof-camera-sky.jpg +0 -0
  349. package/docs/assets/showcase/snag.png +0 -0
  350. package/docs/assets/showcase/tesco-shop.jpg +0 -0
  351. package/docs/assets/showcase/wienerlinien.png +0 -0
  352. package/docs/assets/showcase/wine-cellar-skill.jpg +0 -0
  353. package/docs/assets/showcase/winix-air-purifier.jpg +0 -0
  354. package/docs/assets/showcase/xuezh-pronunciation.jpeg +0 -0
  355. package/docs/automation/auth-monitoring.md +44 -0
  356. package/docs/automation/cron-jobs.md +471 -0
  357. package/docs/automation/cron-vs-heartbeat.md +282 -0
  358. package/docs/automation/gmail-pubsub.md +256 -0
  359. package/docs/automation/hooks.md +916 -0
  360. package/docs/automation/poll.md +69 -0
  361. package/docs/automation/troubleshooting.md +122 -0
  362. package/docs/automation/webhook.md +163 -0
  363. package/docs/brave-search.md +41 -0
  364. package/docs/channels/bluebubbles.md +340 -0
  365. package/docs/channels/broadcast-groups.md +442 -0
  366. package/docs/channels/channel-routing.md +114 -0
  367. package/docs/channels/discord.md +476 -0
  368. package/docs/channels/feishu.md +579 -0
  369. package/docs/channels/googlechat.md +252 -0
  370. package/docs/channels/grammy.md +31 -0
  371. package/docs/channels/group-messages.md +84 -0
  372. package/docs/channels/groups.md +374 -0
  373. package/docs/channels/imessage.md +321 -0
  374. package/docs/channels/index.md +46 -0
  375. package/docs/channels/line.md +186 -0
  376. package/docs/channels/location.md +56 -0
  377. package/docs/channels/matrix.md +259 -0
  378. package/docs/channels/mattermost.md +138 -0
  379. package/docs/channels/msteams.md +769 -0
  380. package/docs/channels/nextcloud-talk.md +138 -0
  381. package/docs/channels/nostr.md +233 -0
  382. package/docs/channels/pairing.md +86 -0
  383. package/docs/channels/signal.md +228 -0
  384. package/docs/channels/slack.md +574 -0
  385. package/docs/channels/telegram.md +770 -0
  386. package/docs/channels/tlon.md +132 -0
  387. package/docs/channels/troubleshooting.md +116 -0
  388. package/docs/channels/twitch.md +379 -0
  389. package/docs/channels/whatsapp.md +406 -0
  390. package/docs/channels/zalo.md +189 -0
  391. package/docs/channels/zalouser.md +140 -0
  392. package/docs/cli/acp.md +170 -0
  393. package/docs/cli/agent.md +24 -0
  394. package/docs/cli/agents.md +75 -0
  395. package/docs/cli/approvals.md +50 -0
  396. package/docs/cli/browser.md +107 -0
  397. package/docs/cli/channels.md +79 -0
  398. package/docs/cli/config.md +50 -0
  399. package/docs/cli/configure.md +33 -0
  400. package/docs/cli/cron.md +42 -0
  401. package/docs/cli/dashboard.md +16 -0
  402. package/docs/cli/devices.md +70 -0
  403. package/docs/cli/directory.md +63 -0
  404. package/docs/cli/dns.md +23 -0
  405. package/docs/cli/docs.md +15 -0
  406. package/docs/cli/doctor.md +41 -0
  407. package/docs/cli/gateway.md +202 -0
  408. package/docs/cli/health.md +21 -0
  409. package/docs/cli/hooks.md +304 -0
  410. package/docs/cli/index.md +1031 -0
  411. package/docs/cli/logs.md +24 -0
  412. package/docs/cli/memory.md +45 -0
  413. package/docs/cli/message.md +239 -0
  414. package/docs/cli/models.md +79 -0
  415. package/docs/cli/node.md +112 -0
  416. package/docs/cli/nodes.md +73 -0
  417. package/docs/cli/onboard.md +43 -0
  418. package/docs/cli/pairing.md +21 -0
  419. package/docs/cli/plugins.md +62 -0
  420. package/docs/cli/reset.md +17 -0
  421. package/docs/cli/sandbox.md +152 -0
  422. package/docs/cli/security.md +26 -0
  423. package/docs/cli/sessions.md +16 -0
  424. package/docs/cli/setup.md +29 -0
  425. package/docs/cli/skills.md +26 -0
  426. package/docs/cli/status.md +26 -0
  427. package/docs/cli/system.md +60 -0
  428. package/docs/cli/tui.md +23 -0
  429. package/docs/cli/uninstall.md +17 -0
  430. package/docs/cli/update.md +98 -0
  431. package/docs/cli/voicecall.md +34 -0
  432. package/docs/cli/webhooks.md +25 -0
  433. package/docs/concepts/agent-loop.md +146 -0
  434. package/docs/concepts/agent-workspace.md +233 -0
  435. package/docs/concepts/agent.md +123 -0
  436. package/docs/concepts/architecture.md +131 -0
  437. package/docs/concepts/compaction.md +61 -0
  438. package/docs/concepts/context.md +161 -0
  439. package/docs/concepts/features.md +53 -0
  440. package/docs/concepts/markdown-formatting.md +130 -0
  441. package/docs/concepts/memory.md +556 -0
  442. package/docs/concepts/messages.md +154 -0
  443. package/docs/concepts/model-failover.md +149 -0
  444. package/docs/concepts/model-providers.md +316 -0
  445. package/docs/concepts/models.md +208 -0
  446. package/docs/concepts/multi-agent.md +376 -0
  447. package/docs/concepts/oauth.md +145 -0
  448. package/docs/concepts/presence.md +102 -0
  449. package/docs/concepts/queue.md +89 -0
  450. package/docs/concepts/retry.md +69 -0
  451. package/docs/concepts/session-pruning.md +122 -0
  452. package/docs/concepts/session-tool.md +193 -0
  453. package/docs/concepts/session.md +204 -0
  454. package/docs/concepts/sessions.md +10 -0
  455. package/docs/concepts/streaming.md +135 -0
  456. package/docs/concepts/system-prompt.md +115 -0
  457. package/docs/concepts/timezone.md +91 -0
  458. package/docs/concepts/typebox.md +289 -0
  459. package/docs/concepts/typing-indicators.md +68 -0
  460. package/docs/concepts/usage-tracking.md +35 -0
  461. package/docs/date-time.md +128 -0
  462. package/docs/debug/node-issue.md +85 -0
  463. package/docs/diagnostics/flags.md +91 -0
  464. package/docs/docs.json +1802 -0
  465. package/docs/experiments/onboarding-config-protocol.md +40 -0
  466. package/docs/experiments/plans/cron-add-hardening.md +63 -0
  467. package/docs/experiments/plans/group-policy-hardening.md +40 -0
  468. package/docs/experiments/plans/openresponses-gateway.md +123 -0
  469. package/docs/experiments/proposals/model-config.md +36 -0
  470. package/docs/experiments/research/memory.md +228 -0
  471. package/docs/gateway/authentication.md +145 -0
  472. package/docs/gateway/background-process.md +93 -0
  473. package/docs/gateway/bonjour.md +170 -0
  474. package/docs/gateway/bridge-protocol.md +89 -0
  475. package/docs/gateway/cli-backends.md +225 -0
  476. package/docs/gateway/configuration-examples.md +606 -0
  477. package/docs/gateway/configuration.md +3416 -0
  478. package/docs/gateway/discovery.md +116 -0
  479. package/docs/gateway/doctor.md +282 -0
  480. package/docs/gateway/gateway-lock.md +34 -0
  481. package/docs/gateway/health.md +35 -0
  482. package/docs/gateway/heartbeat.md +364 -0
  483. package/docs/gateway/index.md +330 -0
  484. package/docs/gateway/local-models.md +150 -0
  485. package/docs/gateway/logging.md +113 -0
  486. package/docs/gateway/multiple-gateways.md +112 -0
  487. package/docs/gateway/network-model.md +17 -0
  488. package/docs/gateway/openai-http-api.md +118 -0
  489. package/docs/gateway/openresponses-http-api.md +317 -0
  490. package/docs/gateway/pairing.md +99 -0
  491. package/docs/gateway/protocol.md +221 -0
  492. package/docs/gateway/remote-gateway-readme.md +157 -0
  493. package/docs/gateway/remote.md +129 -0
  494. package/docs/gateway/sandbox-vs-tool-policy-vs-elevated.md +128 -0
  495. package/docs/gateway/sandboxing.md +193 -0
  496. package/docs/gateway/security/index.md +829 -0
  497. package/docs/gateway/tailscale.md +127 -0
  498. package/docs/gateway/tools-invoke-http-api.md +85 -0
  499. package/docs/gateway/troubleshooting.md +318 -0
  500. package/docs/help/debugging.md +162 -0
  501. package/docs/help/environment.md +81 -0
  502. package/docs/help/faq.md +2848 -0
  503. package/docs/help/index.md +21 -0
  504. package/docs/help/scripts.md +28 -0
  505. package/docs/help/submitting-a-pr.md +398 -0
  506. package/docs/help/submitting-an-issue.md +152 -0
  507. package/docs/help/testing.md +368 -0
  508. package/docs/help/troubleshooting.md +265 -0
  509. package/docs/hooks/soul-evil.md +69 -0
  510. package/docs/images/feishu-step2-create-app.png +0 -0
  511. package/docs/images/feishu-step3-credentials.png +0 -0
  512. package/docs/images/feishu-step4-permissions.png +0 -0
  513. package/docs/images/feishu-step5-bot-capability.png +0 -0
  514. package/docs/images/feishu-step6-event-subscription.png +0 -0
  515. package/docs/images/groups-flow.svg +52 -0
  516. package/docs/images/mobile-ui-screenshot.png +0 -0
  517. package/docs/index.md +192 -0
  518. package/docs/install/ansible.md +208 -0
  519. package/docs/install/bun.md +59 -0
  520. package/docs/install/development-channels.md +75 -0
  521. package/docs/install/docker.md +567 -0
  522. package/docs/install/exe-dev.md +126 -0
  523. package/docs/install/fly.md +486 -0
  524. package/docs/install/gcp.md +504 -0
  525. package/docs/install/hetzner.md +330 -0
  526. package/docs/install/index.md +203 -0
  527. package/docs/install/installer.md +385 -0
  528. package/docs/install/macos-vm.md +281 -0
  529. package/docs/install/migrating.md +192 -0
  530. package/docs/install/nix.md +96 -0
  531. package/docs/install/node.md +138 -0
  532. package/docs/install/northflank.mdx +53 -0
  533. package/docs/install/railway.mdx +99 -0
  534. package/docs/install/render.mdx +159 -0
  535. package/docs/install/uninstall.md +128 -0
  536. package/docs/install/updating.md +231 -0
  537. package/docs/logging.md +350 -0
  538. package/docs/network.md +54 -0
  539. package/docs/nodes/audio.md +114 -0
  540. package/docs/nodes/camera.md +156 -0
  541. package/docs/nodes/images.md +72 -0
  542. package/docs/nodes/index.md +342 -0
  543. package/docs/nodes/location-command.md +113 -0
  544. package/docs/nodes/media-understanding.md +379 -0
  545. package/docs/nodes/talk.md +90 -0
  546. package/docs/nodes/troubleshooting.md +112 -0
  547. package/docs/nodes/voicewake.md +65 -0
  548. package/docs/perplexity.md +80 -0
  549. package/docs/pi-dev.md +70 -0
  550. package/docs/pi.md +612 -0
  551. package/docs/platforms/android.md +151 -0
  552. package/docs/platforms/digitalocean.md +262 -0
  553. package/docs/platforms/index.md +53 -0
  554. package/docs/platforms/ios.md +107 -0
  555. package/docs/platforms/linux.md +94 -0
  556. package/docs/platforms/mac/bundled-gateway.md +73 -0
  557. package/docs/platforms/mac/canvas.md +125 -0
  558. package/docs/platforms/mac/child-process.md +69 -0
  559. package/docs/platforms/mac/dev-setup.md +104 -0
  560. package/docs/platforms/mac/health.md +34 -0
  561. package/docs/platforms/mac/icon.md +31 -0
  562. package/docs/platforms/mac/logging.md +57 -0
  563. package/docs/platforms/mac/menu-bar.md +81 -0
  564. package/docs/platforms/mac/peekaboo.md +65 -0
  565. package/docs/platforms/mac/permissions.md +50 -0
  566. package/docs/platforms/mac/release.md +85 -0
  567. package/docs/platforms/mac/remote.md +83 -0
  568. package/docs/platforms/mac/signing.md +47 -0
  569. package/docs/platforms/mac/skills.md +33 -0
  570. package/docs/platforms/mac/voice-overlay.md +60 -0
  571. package/docs/platforms/mac/voicewake.md +67 -0
  572. package/docs/platforms/mac/webchat.md +43 -0
  573. package/docs/platforms/mac/xpc.md +61 -0
  574. package/docs/platforms/macos.md +203 -0
  575. package/docs/platforms/oracle.md +303 -0
  576. package/docs/platforms/raspberry-pi.md +358 -0
  577. package/docs/platforms/windows.md +159 -0
  578. package/docs/plugins/agent-tools.md +99 -0
  579. package/docs/plugins/manifest.md +71 -0
  580. package/docs/plugins/voice-call.md +284 -0
  581. package/docs/plugins/zalouser.md +81 -0
  582. package/docs/prose.md +134 -0
  583. package/docs/providers/anthropic.md +152 -0
  584. package/docs/providers/bedrock.md +176 -0
  585. package/docs/providers/claude-max-api-proxy.md +148 -0
  586. package/docs/providers/cloudflare-ai-gateway.md +71 -0
  587. package/docs/providers/deepgram.md +93 -0
  588. package/docs/providers/github-copilot.md +72 -0
  589. package/docs/providers/glm.md +33 -0
  590. package/docs/providers/index.md +64 -0
  591. package/docs/providers/minimax.md +208 -0
  592. package/docs/providers/models.md +52 -0
  593. package/docs/providers/moonshot.md +142 -0
  594. package/docs/providers/ollama.md +277 -0
  595. package/docs/providers/openai.md +62 -0
  596. package/docs/providers/opencode.md +36 -0
  597. package/docs/providers/openrouter.md +37 -0
  598. package/docs/providers/qianfan.md +38 -0
  599. package/docs/providers/qwen.md +53 -0
  600. package/docs/providers/synthetic.md +99 -0
  601. package/docs/providers/venice.md +267 -0
  602. package/docs/providers/vercel-ai-gateway.md +50 -0
  603. package/docs/providers/xiaomi.md +64 -0
  604. package/docs/providers/zai.md +36 -0
  605. package/docs/refactor/clawnet.md +417 -0
  606. package/docs/refactor/exec-host.md +316 -0
  607. package/docs/refactor/outbound-session-mirroring.md +85 -0
  608. package/docs/refactor/plugin-sdk.md +214 -0
  609. package/docs/refactor/strict-config.md +93 -0
  610. package/docs/reference/AGENTS.default.md +123 -0
  611. package/docs/reference/RELEASING.md +120 -0
  612. package/docs/reference/api-usage-costs.md +138 -0
  613. package/docs/reference/credits.md +27 -0
  614. package/docs/reference/device-models.md +47 -0
  615. package/docs/reference/rpc.md +43 -0
  616. package/docs/reference/session-management-compaction.md +285 -0
  617. package/docs/reference/templates/AGENTS.dev.md +83 -0
  618. package/docs/reference/templates/AGENTS.md +218 -0
  619. package/docs/reference/templates/BOOT.md +10 -0
  620. package/docs/reference/templates/BOOTSTRAP.md +61 -0
  621. package/docs/reference/templates/HEARTBEAT.md +11 -0
  622. package/docs/reference/templates/IDENTITY.dev.md +47 -0
  623. package/docs/reference/templates/IDENTITY.md +29 -0
  624. package/docs/reference/templates/SOUL.dev.md +76 -0
  625. package/docs/reference/templates/SOUL.md +42 -0
  626. package/docs/reference/templates/TOOLS.dev.md +24 -0
  627. package/docs/reference/templates/TOOLS.md +46 -0
  628. package/docs/reference/templates/USER.dev.md +18 -0
  629. package/docs/reference/templates/USER.md +23 -0
  630. package/docs/reference/test.md +50 -0
  631. package/docs/reference/token-use.md +112 -0
  632. package/docs/reference/transcript-hygiene.md +129 -0
  633. package/docs/reference/wizard.md +269 -0
  634. package/docs/security/formal-verification.md +164 -0
  635. package/docs/start/bootstrapping.md +41 -0
  636. package/docs/start/docs-directory.md +64 -0
  637. package/docs/start/getting-started.md +120 -0
  638. package/docs/start/hubs.md +197 -0
  639. package/docs/start/lore.md +219 -0
  640. package/docs/start/onboarding.md +80 -0
  641. package/docs/start/openclaw.md +224 -0
  642. package/docs/start/quickstart.md +22 -0
  643. package/docs/start/setup.md +162 -0
  644. package/docs/start/showcase.md +416 -0
  645. package/docs/start/wizard-cli-automation.md +141 -0
  646. package/docs/start/wizard-cli-reference.md +247 -0
  647. package/docs/start/wizard.md +108 -0
  648. package/docs/style.css +3 -0
  649. package/docs/tools/agent-send.md +53 -0
  650. package/docs/tools/apply-patch.md +50 -0
  651. package/docs/tools/browser-linux-troubleshooting.md +139 -0
  652. package/docs/tools/browser-login.md +67 -0
  653. package/docs/tools/browser.md +576 -0
  654. package/docs/tools/chrome-extension.md +178 -0
  655. package/docs/tools/clawhub.md +257 -0
  656. package/docs/tools/creating-skills.md +54 -0
  657. package/docs/tools/elevated.md +57 -0
  658. package/docs/tools/exec-approvals.md +246 -0
  659. package/docs/tools/exec.md +179 -0
  660. package/docs/tools/firecrawl.md +61 -0
  661. package/docs/tools/index.md +512 -0
  662. package/docs/tools/llm-task.md +115 -0
  663. package/docs/tools/lobster.md +342 -0
  664. package/docs/tools/multi-agent-sandbox-tools.md +396 -0
  665. package/docs/tools/plugin.md +664 -0
  666. package/docs/tools/reactions.md +22 -0
  667. package/docs/tools/skills-config.md +76 -0
  668. package/docs/tools/skills.md +300 -0
  669. package/docs/tools/slash-commands.md +198 -0
  670. package/docs/tools/subagents.md +151 -0
  671. package/docs/tools/thinking.md +74 -0
  672. package/docs/tools/web.md +261 -0
  673. package/docs/tts.md +396 -0
  674. package/docs/vps.md +43 -0
  675. package/docs/web/control-ui.md +223 -0
  676. package/docs/web/dashboard.md +46 -0
  677. package/docs/web/index.md +116 -0
  678. package/docs/web/tui.md +162 -0
  679. package/docs/web/webchat.md +49 -0
  680. package/docs/whatsapp-openclaw-ai-zh.jpg +0 -0
  681. package/docs/whatsapp-openclaw.jpg +0 -0
  682. package/docs/zh-CN/AGENTS.md +59 -0
  683. package/docs/zh-CN/automation/auth-monitoring.md +47 -0
  684. package/docs/zh-CN/automation/cron-jobs.md +424 -0
  685. package/docs/zh-CN/automation/cron-vs-heartbeat.md +286 -0
  686. package/docs/zh-CN/automation/gmail-pubsub.md +249 -0
  687. package/docs/zh-CN/automation/hooks.md +919 -0
  688. package/docs/zh-CN/automation/poll.md +76 -0
  689. package/docs/zh-CN/automation/troubleshooting.md +8 -0
  690. package/docs/zh-CN/automation/webhook.md +163 -0
  691. package/docs/zh-CN/brave-search.md +48 -0
  692. package/docs/zh-CN/channels/bluebubbles.md +271 -0
  693. package/docs/zh-CN/channels/broadcast-groups.md +449 -0
  694. package/docs/zh-CN/channels/channel-routing.md +117 -0
  695. package/docs/zh-CN/channels/discord.md +468 -0
  696. package/docs/zh-CN/channels/feishu.md +629 -0
  697. package/docs/zh-CN/channels/googlechat.md +257 -0
  698. package/docs/zh-CN/channels/grammy.md +38 -0
  699. package/docs/zh-CN/channels/group-messages.md +91 -0
  700. package/docs/zh-CN/channels/groups.md +379 -0
  701. package/docs/zh-CN/channels/imessage.md +302 -0
  702. package/docs/zh-CN/channels/index.md +53 -0
  703. package/docs/zh-CN/channels/line.md +180 -0
  704. package/docs/zh-CN/channels/location.md +63 -0
  705. package/docs/zh-CN/channels/matrix.md +221 -0
  706. package/docs/zh-CN/channels/mattermost.md +144 -0
  707. package/docs/zh-CN/channels/msteams.md +775 -0
  708. package/docs/zh-CN/channels/nextcloud-talk.md +142 -0
  709. package/docs/zh-CN/channels/nostr.md +240 -0
  710. package/docs/zh-CN/channels/pairing.md +89 -0
  711. package/docs/zh-CN/channels/signal.md +209 -0
  712. package/docs/zh-CN/channels/slack.md +531 -0
  713. package/docs/zh-CN/channels/telegram.md +751 -0
  714. package/docs/zh-CN/channels/tlon.md +136 -0
  715. package/docs/zh-CN/channels/troubleshooting.md +36 -0
  716. package/docs/zh-CN/channels/twitch.md +385 -0
  717. package/docs/zh-CN/channels/whatsapp.md +411 -0
  718. package/docs/zh-CN/channels/zalo.md +196 -0
  719. package/docs/zh-CN/channels/zalouser.md +147 -0
  720. package/docs/zh-CN/cli/acp.md +173 -0
  721. package/docs/zh-CN/cli/agent.md +30 -0
  722. package/docs/zh-CN/cli/agents.md +82 -0
  723. package/docs/zh-CN/cli/approvals.md +57 -0
  724. package/docs/zh-CN/cli/browser.md +114 -0
  725. package/docs/zh-CN/cli/channels.md +86 -0
  726. package/docs/zh-CN/cli/config.md +57 -0
  727. package/docs/zh-CN/cli/configure.md +38 -0
  728. package/docs/zh-CN/cli/cron.md +43 -0
  729. package/docs/zh-CN/cli/dashboard.md +23 -0
  730. package/docs/zh-CN/cli/devices.md +74 -0
  731. package/docs/zh-CN/cli/directory.md +70 -0
  732. package/docs/zh-CN/cli/dns.md +30 -0
  733. package/docs/zh-CN/cli/docs.md +22 -0
  734. package/docs/zh-CN/cli/doctor.md +48 -0
  735. package/docs/zh-CN/cli/gateway.md +206 -0
  736. package/docs/zh-CN/cli/health.md +28 -0
  737. package/docs/zh-CN/cli/hooks.md +311 -0
  738. package/docs/zh-CN/cli/index.md +1032 -0
  739. package/docs/zh-CN/cli/logs.md +31 -0
  740. package/docs/zh-CN/cli/memory.md +52 -0
  741. package/docs/zh-CN/cli/message.md +246 -0
  742. package/docs/zh-CN/cli/models.md +85 -0
  743. package/docs/zh-CN/cli/node.md +115 -0
  744. package/docs/zh-CN/cli/nodes.md +80 -0
  745. package/docs/zh-CN/cli/onboard.md +36 -0
  746. package/docs/zh-CN/cli/pairing.md +28 -0
  747. package/docs/zh-CN/cli/plugins.md +66 -0
  748. package/docs/zh-CN/cli/reset.md +24 -0
  749. package/docs/zh-CN/cli/sandbox.md +158 -0
  750. package/docs/zh-CN/cli/security.md +33 -0
  751. package/docs/zh-CN/cli/sessions.md +23 -0
  752. package/docs/zh-CN/cli/setup.md +36 -0
  753. package/docs/zh-CN/cli/skills.md +33 -0
  754. package/docs/zh-CN/cli/status.md +33 -0
  755. package/docs/zh-CN/cli/system.md +63 -0
  756. package/docs/zh-CN/cli/tui.md +30 -0
  757. package/docs/zh-CN/cli/uninstall.md +24 -0
  758. package/docs/zh-CN/cli/update.md +101 -0
  759. package/docs/zh-CN/cli/voicecall.md +41 -0
  760. package/docs/zh-CN/cli/webhooks.md +32 -0
  761. package/docs/zh-CN/concepts/agent-loop.md +146 -0
  762. package/docs/zh-CN/concepts/agent-workspace.md +219 -0
  763. package/docs/zh-CN/concepts/agent.md +115 -0
  764. package/docs/zh-CN/concepts/architecture.md +123 -0
  765. package/docs/zh-CN/concepts/compaction.md +67 -0
  766. package/docs/zh-CN/concepts/context.md +168 -0
  767. package/docs/zh-CN/concepts/features.md +59 -0
  768. package/docs/zh-CN/concepts/markdown-formatting.md +117 -0
  769. package/docs/zh-CN/concepts/memory.md +412 -0
  770. package/docs/zh-CN/concepts/messages.md +141 -0
  771. package/docs/zh-CN/concepts/model-failover.md +145 -0
  772. package/docs/zh-CN/concepts/model-providers.md +320 -0
  773. package/docs/zh-CN/concepts/models.md +196 -0
  774. package/docs/zh-CN/concepts/multi-agent.md +372 -0
  775. package/docs/zh-CN/concepts/oauth.md +151 -0
  776. package/docs/zh-CN/concepts/presence.md +99 -0
  777. package/docs/zh-CN/concepts/queue.md +94 -0
  778. package/docs/zh-CN/concepts/retry.md +76 -0
  779. package/docs/zh-CN/concepts/session-pruning.md +129 -0
  780. package/docs/zh-CN/concepts/session-tool.md +200 -0
  781. package/docs/zh-CN/concepts/session.md +166 -0
  782. package/docs/zh-CN/concepts/sessions.md +17 -0
  783. package/docs/zh-CN/concepts/streaming.md +133 -0
  784. package/docs/zh-CN/concepts/system-prompt.md +101 -0
  785. package/docs/zh-CN/concepts/timezone.md +96 -0
  786. package/docs/zh-CN/concepts/typebox.md +284 -0
  787. package/docs/zh-CN/concepts/typing-indicators.md +74 -0
  788. package/docs/zh-CN/concepts/usage-tracking.md +42 -0
  789. package/docs/zh-CN/date-time.md +129 -0
  790. package/docs/zh-CN/debug/node-issue.md +90 -0
  791. package/docs/zh-CN/diagnostics/flags.md +98 -0
  792. package/docs/zh-CN/experiments/onboarding-config-protocol.md +47 -0
  793. package/docs/zh-CN/experiments/plans/cron-add-hardening.md +70 -0
  794. package/docs/zh-CN/experiments/plans/group-policy-hardening.md +45 -0
  795. package/docs/zh-CN/experiments/plans/openresponses-gateway.md +121 -0
  796. package/docs/zh-CN/experiments/proposals/model-config.md +42 -0
  797. package/docs/zh-CN/experiments/research/memory.md +235 -0
  798. package/docs/zh-CN/gateway/authentication.md +142 -0
  799. package/docs/zh-CN/gateway/background-process.md +100 -0
  800. package/docs/zh-CN/gateway/bonjour.md +174 -0
  801. package/docs/zh-CN/gateway/bridge-protocol.md +86 -0
  802. package/docs/zh-CN/gateway/cli-backends.md +213 -0
  803. package/docs/zh-CN/gateway/configuration-examples.md +587 -0
  804. package/docs/zh-CN/gateway/configuration.md +3332 -0
  805. package/docs/zh-CN/gateway/discovery.md +123 -0
  806. package/docs/zh-CN/gateway/doctor.md +238 -0
  807. package/docs/zh-CN/gateway/gateway-lock.md +41 -0
  808. package/docs/zh-CN/gateway/health.md +42 -0
  809. package/docs/zh-CN/gateway/heartbeat.md +274 -0
  810. package/docs/zh-CN/gateway/index.md +335 -0
  811. package/docs/zh-CN/gateway/local-models.md +157 -0
  812. package/docs/zh-CN/gateway/logging.md +114 -0
  813. package/docs/zh-CN/gateway/multiple-gateways.md +119 -0
  814. package/docs/zh-CN/gateway/network-model.md +23 -0
  815. package/docs/zh-CN/gateway/openai-http-api.md +125 -0
  816. package/docs/zh-CN/gateway/openresponses-http-api.md +317 -0
  817. package/docs/zh-CN/gateway/pairing.md +99 -0
  818. package/docs/zh-CN/gateway/protocol.md +220 -0
  819. package/docs/zh-CN/gateway/remote-gateway-readme.md +164 -0
  820. package/docs/zh-CN/gateway/remote.md +133 -0
  821. package/docs/zh-CN/gateway/sandbox-vs-tool-policy-vs-elevated.md +135 -0
  822. package/docs/zh-CN/gateway/sandboxing.md +188 -0
  823. package/docs/zh-CN/gateway/security/index.md +777 -0
  824. package/docs/zh-CN/gateway/tailscale.md +124 -0
  825. package/docs/zh-CN/gateway/tools-invoke-http-api.md +92 -0
  826. package/docs/zh-CN/gateway/troubleshooting.md +771 -0
  827. package/docs/zh-CN/help/debugging.md +160 -0
  828. package/docs/zh-CN/help/environment.md +88 -0
  829. package/docs/zh-CN/help/faq.md +2628 -0
  830. package/docs/zh-CN/help/index.md +28 -0
  831. package/docs/zh-CN/help/scripts.md +35 -0
  832. package/docs/zh-CN/help/submitting-a-pr.md +8 -0
  833. package/docs/zh-CN/help/submitting-an-issue.md +8 -0
  834. package/docs/zh-CN/help/testing.md +375 -0
  835. package/docs/zh-CN/help/troubleshooting.md +104 -0
  836. package/docs/zh-CN/hooks/soul-evil.md +72 -0
  837. package/docs/zh-CN/index.md +186 -0
  838. package/docs/zh-CN/install/ansible.md +215 -0
  839. package/docs/zh-CN/install/bun.md +65 -0
  840. package/docs/zh-CN/install/development-channels.md +81 -0
  841. package/docs/zh-CN/install/docker.md +532 -0
  842. package/docs/zh-CN/install/exe-dev.md +127 -0
  843. package/docs/zh-CN/install/fly.md +490 -0
  844. package/docs/zh-CN/install/gcp.md +510 -0
  845. package/docs/zh-CN/install/hetzner.md +337 -0
  846. package/docs/zh-CN/install/index.md +193 -0
  847. package/docs/zh-CN/install/installer.md +128 -0
  848. package/docs/zh-CN/install/macos-vm.md +288 -0
  849. package/docs/zh-CN/install/migrating.md +199 -0
  850. package/docs/zh-CN/install/nix.md +99 -0
  851. package/docs/zh-CN/install/node.md +8 -0
  852. package/docs/zh-CN/install/northflank.mdx +60 -0
  853. package/docs/zh-CN/install/railway.mdx +106 -0
  854. package/docs/zh-CN/install/render.mdx +169 -0
  855. package/docs/zh-CN/install/uninstall.md +135 -0
  856. package/docs/zh-CN/install/updating.md +233 -0
  857. package/docs/zh-CN/logging.md +329 -0
  858. package/docs/zh-CN/network.md +59 -0
  859. package/docs/zh-CN/nodes/audio.md +120 -0
  860. package/docs/zh-CN/nodes/camera.md +162 -0
  861. package/docs/zh-CN/nodes/images.md +79 -0
  862. package/docs/zh-CN/nodes/index.md +348 -0
  863. package/docs/zh-CN/nodes/location-command.md +120 -0
  864. package/docs/zh-CN/nodes/media-understanding.md +380 -0
  865. package/docs/zh-CN/nodes/talk.md +97 -0
  866. package/docs/zh-CN/nodes/troubleshooting.md +8 -0
  867. package/docs/zh-CN/nodes/voicewake.md +72 -0
  868. package/docs/zh-CN/perplexity.md +84 -0
  869. package/docs/zh-CN/pi-dev.md +77 -0
  870. package/docs/zh-CN/pi.md +619 -0
  871. package/docs/zh-CN/platforms/android.md +155 -0
  872. package/docs/zh-CN/platforms/digitalocean.md +269 -0
  873. package/docs/zh-CN/platforms/index.md +60 -0
  874. package/docs/zh-CN/platforms/ios.md +114 -0
  875. package/docs/zh-CN/platforms/linux.md +101 -0
  876. package/docs/zh-CN/platforms/mac/bundled-gateway.md +75 -0
  877. package/docs/zh-CN/platforms/mac/canvas.md +128 -0
  878. package/docs/zh-CN/platforms/mac/child-process.md +73 -0
  879. package/docs/zh-CN/platforms/mac/dev-setup.md +109 -0
  880. package/docs/zh-CN/platforms/mac/health.md +41 -0
  881. package/docs/zh-CN/platforms/mac/icon.md +38 -0
  882. package/docs/zh-CN/platforms/mac/logging.md +64 -0
  883. package/docs/zh-CN/platforms/mac/menu-bar.md +88 -0
  884. package/docs/zh-CN/platforms/mac/peekaboo.md +62 -0
  885. package/docs/zh-CN/platforms/mac/permissions.md +46 -0
  886. package/docs/zh-CN/platforms/mac/release.md +92 -0
  887. package/docs/zh-CN/platforms/mac/remote.md +90 -0
  888. package/docs/zh-CN/platforms/mac/signing.md +54 -0
  889. package/docs/zh-CN/platforms/mac/skills.md +40 -0
  890. package/docs/zh-CN/platforms/mac/voice-overlay.md +67 -0
  891. package/docs/zh-CN/platforms/mac/voicewake.md +74 -0
  892. package/docs/zh-CN/platforms/mac/webchat.md +43 -0
  893. package/docs/zh-CN/platforms/mac/xpc.md +68 -0
  894. package/docs/zh-CN/platforms/macos.md +193 -0
  895. package/docs/zh-CN/platforms/oracle.md +310 -0
  896. package/docs/zh-CN/platforms/raspberry-pi.md +365 -0
  897. package/docs/zh-CN/platforms/windows.md +156 -0
  898. package/docs/zh-CN/plugins/agent-tools.md +99 -0
  899. package/docs/zh-CN/plugins/manifest.md +68 -0
  900. package/docs/zh-CN/plugins/voice-call.md +250 -0
  901. package/docs/zh-CN/plugins/zalouser.md +88 -0
  902. package/docs/zh-CN/prose.md +141 -0
  903. package/docs/zh-CN/providers/anthropic.md +159 -0
  904. package/docs/zh-CN/providers/bedrock.md +170 -0
  905. package/docs/zh-CN/providers/claude-max-api-proxy.md +155 -0
  906. package/docs/zh-CN/providers/deepgram.md +97 -0
  907. package/docs/zh-CN/providers/github-copilot.md +67 -0
  908. package/docs/zh-CN/providers/glm.md +39 -0
  909. package/docs/zh-CN/providers/index.md +68 -0
  910. package/docs/zh-CN/providers/minimax.md +206 -0
  911. package/docs/zh-CN/providers/models.md +55 -0
  912. package/docs/zh-CN/providers/moonshot.md +145 -0
  913. package/docs/zh-CN/providers/ollama.md +230 -0
  914. package/docs/zh-CN/providers/openai.md +68 -0
  915. package/docs/zh-CN/providers/opencode.md +41 -0
  916. package/docs/zh-CN/providers/openrouter.md +43 -0
  917. package/docs/zh-CN/providers/qianfan.md +8 -0
  918. package/docs/zh-CN/providers/qwen.md +55 -0
  919. package/docs/zh-CN/providers/synthetic.md +102 -0
  920. package/docs/zh-CN/providers/venice.md +274 -0
  921. package/docs/zh-CN/providers/vercel-ai-gateway.md +57 -0
  922. package/docs/zh-CN/providers/xiaomi.md +68 -0
  923. package/docs/zh-CN/providers/zai.md +41 -0
  924. package/docs/zh-CN/refactor/clawnet.md +424 -0
  925. package/docs/zh-CN/refactor/exec-host.md +323 -0
  926. package/docs/zh-CN/refactor/outbound-session-mirroring.md +92 -0
  927. package/docs/zh-CN/refactor/plugin-sdk.md +221 -0
  928. package/docs/zh-CN/refactor/strict-config.md +100 -0
  929. package/docs/zh-CN/reference/AGENTS.default.md +131 -0
  930. package/docs/zh-CN/reference/RELEASING.md +123 -0
  931. package/docs/zh-CN/reference/api-usage-costs.md +136 -0
  932. package/docs/zh-CN/reference/credits.md +34 -0
  933. package/docs/zh-CN/reference/device-models.md +54 -0
  934. package/docs/zh-CN/reference/rpc.md +48 -0
  935. package/docs/zh-CN/reference/session-management-compaction.md +287 -0
  936. package/docs/zh-CN/reference/templates/AGENTS.dev.md +89 -0
  937. package/docs/zh-CN/reference/templates/AGENTS.md +225 -0
  938. package/docs/zh-CN/reference/templates/BOOT.md +17 -0
  939. package/docs/zh-CN/reference/templates/BOOTSTRAP.md +68 -0
  940. package/docs/zh-CN/reference/templates/HEARTBEAT.md +18 -0
  941. package/docs/zh-CN/reference/templates/IDENTITY.dev.md +54 -0
  942. package/docs/zh-CN/reference/templates/IDENTITY.md +36 -0
  943. package/docs/zh-CN/reference/templates/SOUL.dev.md +83 -0
  944. package/docs/zh-CN/reference/templates/SOUL.md +49 -0
  945. package/docs/zh-CN/reference/templates/TOOLS.dev.md +31 -0
  946. package/docs/zh-CN/reference/templates/TOOLS.md +53 -0
  947. package/docs/zh-CN/reference/templates/USER.dev.md +25 -0
  948. package/docs/zh-CN/reference/templates/USER.md +30 -0
  949. package/docs/zh-CN/reference/test.md +57 -0
  950. package/docs/zh-CN/reference/token-use.md +119 -0
  951. package/docs/zh-CN/reference/transcript-hygiene.md +109 -0
  952. package/docs/zh-CN/reference/wizard.md +9 -0
  953. package/docs/zh-CN/security/formal-verification.md +171 -0
  954. package/docs/zh-CN/start/bootstrapping.md +9 -0
  955. package/docs/zh-CN/start/docs-directory.md +70 -0
  956. package/docs/zh-CN/start/getting-started.md +206 -0
  957. package/docs/zh-CN/start/hubs.md +200 -0
  958. package/docs/zh-CN/start/lore.md +226 -0
  959. package/docs/zh-CN/start/onboarding.md +105 -0
  960. package/docs/zh-CN/start/openclaw.md +248 -0
  961. package/docs/zh-CN/start/quickstart.md +88 -0
  962. package/docs/zh-CN/start/setup.md +153 -0
  963. package/docs/zh-CN/start/showcase.md +423 -0
  964. package/docs/zh-CN/start/wizard.md +331 -0
  965. package/docs/zh-CN/tools/agent-send.md +59 -0
  966. package/docs/zh-CN/tools/apply-patch.md +57 -0
  967. package/docs/zh-CN/tools/browser-linux-troubleshooting.md +144 -0
  968. package/docs/zh-CN/tools/browser-login.md +75 -0
  969. package/docs/zh-CN/tools/browser.md +553 -0
  970. package/docs/zh-CN/tools/chrome-extension.md +183 -0
  971. package/docs/zh-CN/tools/clawhub.md +209 -0
  972. package/docs/zh-CN/tools/creating-skills.md +61 -0
  973. package/docs/zh-CN/tools/elevated.md +64 -0
  974. package/docs/zh-CN/tools/exec-approvals.md +234 -0
  975. package/docs/zh-CN/tools/exec.md +169 -0
  976. package/docs/zh-CN/tools/firecrawl.md +68 -0
  977. package/docs/zh-CN/tools/index.md +515 -0
  978. package/docs/zh-CN/tools/llm-task.md +117 -0
  979. package/docs/zh-CN/tools/lobster.md +349 -0
  980. package/docs/zh-CN/tools/multi-agent-sandbox-tools.md +401 -0
  981. package/docs/zh-CN/tools/plugin.md +639 -0
  982. package/docs/zh-CN/tools/reactions.md +29 -0
  983. package/docs/zh-CN/tools/skills-config.md +78 -0
  984. package/docs/zh-CN/tools/skills.md +279 -0
  985. package/docs/zh-CN/tools/slash-commands.md +205 -0
  986. package/docs/zh-CN/tools/subagents.md +156 -0
  987. package/docs/zh-CN/tools/thinking.md +80 -0
  988. package/docs/zh-CN/tools/web.md +257 -0
  989. package/docs/zh-CN/tts.md +375 -0
  990. package/docs/zh-CN/vps.md +47 -0
  991. package/docs/zh-CN/web/control-ui.md +191 -0
  992. package/docs/zh-CN/web/dashboard.md +53 -0
  993. package/docs/zh-CN/web/index.md +118 -0
  994. package/docs/zh-CN/web/tui.md +166 -0
  995. package/docs/zh-CN/web/webchat.md +56 -0
  996. package/extensions/bluebubbles/README.md +45 -0
  997. package/extensions/bluebubbles/index.ts +19 -0
  998. package/extensions/bluebubbles/node_modules/.bin/clawdbot +21 -0
  999. package/extensions/bluebubbles/node_modules/.bin/clawdbot.CMD +12 -0
  1000. package/extensions/bluebubbles/node_modules/.bin/clawdbot.ps1 +41 -0
  1001. package/extensions/bluebubbles/node_modules/.bin/openclaw +21 -0
  1002. package/extensions/bluebubbles/node_modules/.bin/openclaw.CMD +12 -0
  1003. package/extensions/bluebubbles/node_modules/.bin/openclaw.ps1 +41 -0
  1004. package/extensions/bluebubbles/node_modules/.bin/synurex +21 -0
  1005. package/extensions/bluebubbles/node_modules/.bin/synurex.CMD +12 -0
  1006. package/extensions/bluebubbles/node_modules/.bin/synurex.ps1 +41 -0
  1007. package/extensions/bluebubbles/package.json +36 -0
  1008. package/extensions/bluebubbles/src/accounts.ts +88 -0
  1009. package/extensions/bluebubbles/src/actions.test.ts +650 -0
  1010. package/extensions/bluebubbles/src/actions.ts +438 -0
  1011. package/extensions/bluebubbles/src/attachments.test.ts +345 -0
  1012. package/extensions/bluebubbles/src/attachments.ts +302 -0
  1013. package/extensions/bluebubbles/src/channel.ts +414 -0
  1014. package/extensions/bluebubbles/src/chat.test.ts +461 -0
  1015. package/extensions/bluebubbles/src/chat.ts +382 -0
  1016. package/extensions/bluebubbles/src/config-schema.ts +51 -0
  1017. package/extensions/bluebubbles/src/media-send.ts +174 -0
  1018. package/extensions/bluebubbles/src/monitor.test.ts +2384 -0
  1019. package/extensions/bluebubbles/src/monitor.ts +2517 -0
  1020. package/extensions/bluebubbles/src/onboarding.ts +352 -0
  1021. package/extensions/bluebubbles/src/probe.ts +144 -0
  1022. package/extensions/bluebubbles/src/reactions.test.ts +392 -0
  1023. package/extensions/bluebubbles/src/reactions.ts +188 -0
  1024. package/extensions/bluebubbles/src/runtime.ts +14 -0
  1025. package/extensions/bluebubbles/src/send.test.ts +889 -0
  1026. package/extensions/bluebubbles/src/send.ts +474 -0
  1027. package/extensions/bluebubbles/src/targets.test.ts +183 -0
  1028. package/extensions/bluebubbles/src/targets.ts +422 -0
  1029. package/extensions/bluebubbles/src/types.ts +127 -0
  1030. package/extensions/bluebubbles/synurex.plugin.json +9 -0
  1031. package/extensions/copilot-proxy/README.md +24 -0
  1032. package/extensions/copilot-proxy/index.ts +149 -0
  1033. package/extensions/copilot-proxy/node_modules/.bin/clawdbot +21 -0
  1034. package/extensions/copilot-proxy/node_modules/.bin/clawdbot.CMD +12 -0
  1035. package/extensions/copilot-proxy/node_modules/.bin/clawdbot.ps1 +41 -0
  1036. package/extensions/copilot-proxy/node_modules/.bin/openclaw +21 -0
  1037. package/extensions/copilot-proxy/node_modules/.bin/openclaw.CMD +12 -0
  1038. package/extensions/copilot-proxy/node_modules/.bin/openclaw.ps1 +41 -0
  1039. package/extensions/copilot-proxy/node_modules/.bin/synurex +21 -0
  1040. package/extensions/copilot-proxy/node_modules/.bin/synurex.CMD +12 -0
  1041. package/extensions/copilot-proxy/node_modules/.bin/synurex.ps1 +41 -0
  1042. package/extensions/copilot-proxy/package.json +14 -0
  1043. package/extensions/copilot-proxy/synurex.plugin.json +9 -0
  1044. package/extensions/diagnostics-otel/index.ts +15 -0
  1045. package/extensions/diagnostics-otel/node_modules/.bin/clawdbot +21 -0
  1046. package/extensions/diagnostics-otel/node_modules/.bin/clawdbot.CMD +12 -0
  1047. package/extensions/diagnostics-otel/node_modules/.bin/clawdbot.ps1 +41 -0
  1048. package/extensions/diagnostics-otel/node_modules/.bin/openclaw +21 -0
  1049. package/extensions/diagnostics-otel/node_modules/.bin/openclaw.CMD +12 -0
  1050. package/extensions/diagnostics-otel/node_modules/.bin/openclaw.ps1 +41 -0
  1051. package/extensions/diagnostics-otel/node_modules/.bin/synurex +21 -0
  1052. package/extensions/diagnostics-otel/node_modules/.bin/synurex.CMD +12 -0
  1053. package/extensions/diagnostics-otel/node_modules/.bin/synurex.ps1 +41 -0
  1054. package/extensions/diagnostics-otel/package.json +27 -0
  1055. package/extensions/diagnostics-otel/src/service.test.ts +226 -0
  1056. package/extensions/diagnostics-otel/src/service.ts +635 -0
  1057. package/extensions/diagnostics-otel/synurex.plugin.json +8 -0
  1058. package/extensions/discord/index.ts +17 -0
  1059. package/extensions/discord/node_modules/.bin/clawdbot +21 -0
  1060. package/extensions/discord/node_modules/.bin/clawdbot.CMD +12 -0
  1061. package/extensions/discord/node_modules/.bin/clawdbot.ps1 +41 -0
  1062. package/extensions/discord/node_modules/.bin/openclaw +21 -0
  1063. package/extensions/discord/node_modules/.bin/openclaw.CMD +12 -0
  1064. package/extensions/discord/node_modules/.bin/openclaw.ps1 +41 -0
  1065. package/extensions/discord/node_modules/.bin/synurex +21 -0
  1066. package/extensions/discord/node_modules/.bin/synurex.CMD +12 -0
  1067. package/extensions/discord/node_modules/.bin/synurex.ps1 +41 -0
  1068. package/extensions/discord/package.json +14 -0
  1069. package/extensions/discord/src/channel.ts +422 -0
  1070. package/extensions/discord/src/runtime.ts +14 -0
  1071. package/extensions/discord/synurex.plugin.json +9 -0
  1072. package/extensions/feishu/index.ts +63 -0
  1073. package/extensions/feishu/node_modules/.bin/clawdbot +21 -0
  1074. package/extensions/feishu/node_modules/.bin/clawdbot.CMD +12 -0
  1075. package/extensions/feishu/node_modules/.bin/clawdbot.ps1 +41 -0
  1076. package/extensions/feishu/node_modules/.bin/openclaw +21 -0
  1077. package/extensions/feishu/node_modules/.bin/openclaw.CMD +12 -0
  1078. package/extensions/feishu/node_modules/.bin/openclaw.ps1 +41 -0
  1079. package/extensions/feishu/node_modules/.bin/synurex +21 -0
  1080. package/extensions/feishu/node_modules/.bin/synurex.CMD +12 -0
  1081. package/extensions/feishu/node_modules/.bin/synurex.ps1 +41 -0
  1082. package/extensions/feishu/package.json +37 -0
  1083. package/extensions/feishu/skills/feishu-doc/SKILL.md +105 -0
  1084. package/extensions/feishu/skills/feishu-doc/references/block-types.md +103 -0
  1085. package/extensions/feishu/skills/feishu-drive/SKILL.md +97 -0
  1086. package/extensions/feishu/skills/feishu-perm/SKILL.md +119 -0
  1087. package/extensions/feishu/skills/feishu-wiki/SKILL.md +111 -0
  1088. package/extensions/feishu/src/accounts.ts +144 -0
  1089. package/extensions/feishu/src/bitable.ts +459 -0
  1090. package/extensions/feishu/src/bot.ts +871 -0
  1091. package/extensions/feishu/src/channel.ts +341 -0
  1092. package/extensions/feishu/src/client.ts +118 -0
  1093. package/extensions/feishu/src/config-schema.ts +172 -0
  1094. package/extensions/feishu/src/directory.ts +177 -0
  1095. package/extensions/feishu/src/doc-schema.ts +47 -0
  1096. package/extensions/feishu/src/docx.ts +521 -0
  1097. package/extensions/feishu/src/drive-schema.ts +46 -0
  1098. package/extensions/feishu/src/drive.ts +227 -0
  1099. package/extensions/feishu/src/media.ts +527 -0
  1100. package/extensions/feishu/src/mention.ts +126 -0
  1101. package/extensions/feishu/src/monitor.ts +190 -0
  1102. package/extensions/feishu/src/onboarding.ts +356 -0
  1103. package/extensions/feishu/src/outbound.ts +40 -0
  1104. package/extensions/feishu/src/perm-schema.ts +52 -0
  1105. package/extensions/feishu/src/perm.ts +173 -0
  1106. package/extensions/feishu/src/policy.ts +104 -0
  1107. package/extensions/feishu/src/probe.ts +44 -0
  1108. package/extensions/feishu/src/reactions.ts +160 -0
  1109. package/extensions/feishu/src/reply-dispatcher.ts +184 -0
  1110. package/extensions/feishu/src/runtime.ts +14 -0
  1111. package/extensions/feishu/src/send.ts +358 -0
  1112. package/extensions/feishu/src/targets.ts +78 -0
  1113. package/extensions/feishu/src/tools-config.ts +21 -0
  1114. package/extensions/feishu/src/types.ts +75 -0
  1115. package/extensions/feishu/src/typing.ts +80 -0
  1116. package/extensions/feishu/src/wiki-schema.ts +55 -0
  1117. package/extensions/feishu/src/wiki.ts +232 -0
  1118. package/extensions/feishu/synurex.plugin.json +10 -0
  1119. package/extensions/google-antigravity-auth/README.md +24 -0
  1120. package/extensions/google-antigravity-auth/index.ts +461 -0
  1121. package/extensions/google-antigravity-auth/node_modules/.bin/clawdbot +21 -0
  1122. package/extensions/google-antigravity-auth/node_modules/.bin/clawdbot.CMD +12 -0
  1123. package/extensions/google-antigravity-auth/node_modules/.bin/clawdbot.ps1 +41 -0
  1124. package/extensions/google-antigravity-auth/node_modules/.bin/openclaw +21 -0
  1125. package/extensions/google-antigravity-auth/node_modules/.bin/openclaw.CMD +12 -0
  1126. package/extensions/google-antigravity-auth/node_modules/.bin/openclaw.ps1 +41 -0
  1127. package/extensions/google-antigravity-auth/node_modules/.bin/synurex +21 -0
  1128. package/extensions/google-antigravity-auth/node_modules/.bin/synurex.CMD +12 -0
  1129. package/extensions/google-antigravity-auth/node_modules/.bin/synurex.ps1 +41 -0
  1130. package/extensions/google-antigravity-auth/package.json +14 -0
  1131. package/extensions/google-antigravity-auth/synurex.plugin.json +9 -0
  1132. package/extensions/google-gemini-cli-auth/README.md +35 -0
  1133. package/extensions/google-gemini-cli-auth/index.ts +88 -0
  1134. package/extensions/google-gemini-cli-auth/node_modules/.bin/clawdbot +21 -0
  1135. package/extensions/google-gemini-cli-auth/node_modules/.bin/clawdbot.CMD +12 -0
  1136. package/extensions/google-gemini-cli-auth/node_modules/.bin/clawdbot.ps1 +41 -0
  1137. package/extensions/google-gemini-cli-auth/node_modules/.bin/openclaw +21 -0
  1138. package/extensions/google-gemini-cli-auth/node_modules/.bin/openclaw.CMD +12 -0
  1139. package/extensions/google-gemini-cli-auth/node_modules/.bin/openclaw.ps1 +41 -0
  1140. package/extensions/google-gemini-cli-auth/node_modules/.bin/synurex +21 -0
  1141. package/extensions/google-gemini-cli-auth/node_modules/.bin/synurex.CMD +12 -0
  1142. package/extensions/google-gemini-cli-auth/node_modules/.bin/synurex.ps1 +41 -0
  1143. package/extensions/google-gemini-cli-auth/oauth.test.ts +240 -0
  1144. package/extensions/google-gemini-cli-auth/oauth.ts +662 -0
  1145. package/extensions/google-gemini-cli-auth/package.json +14 -0
  1146. package/extensions/google-gemini-cli-auth/synurex.plugin.json +9 -0
  1147. package/extensions/googlechat/index.ts +19 -0
  1148. package/extensions/googlechat/node_modules/.bin/clawdbot +21 -0
  1149. package/extensions/googlechat/node_modules/.bin/clawdbot.CMD +12 -0
  1150. package/extensions/googlechat/node_modules/.bin/clawdbot.ps1 +41 -0
  1151. package/extensions/googlechat/node_modules/.bin/openclaw +21 -0
  1152. package/extensions/googlechat/node_modules/.bin/openclaw.CMD +12 -0
  1153. package/extensions/googlechat/node_modules/.bin/openclaw.ps1 +41 -0
  1154. package/extensions/googlechat/node_modules/.bin/synurex +21 -0
  1155. package/extensions/googlechat/node_modules/.bin/synurex.CMD +12 -0
  1156. package/extensions/googlechat/node_modules/.bin/synurex.ps1 +41 -0
  1157. package/extensions/googlechat/package.json +39 -0
  1158. package/extensions/googlechat/src/accounts.ts +147 -0
  1159. package/extensions/googlechat/src/actions.ts +181 -0
  1160. package/extensions/googlechat/src/api.test.ts +61 -0
  1161. package/extensions/googlechat/src/api.ts +282 -0
  1162. package/extensions/googlechat/src/auth.ts +137 -0
  1163. package/extensions/googlechat/src/channel.ts +583 -0
  1164. package/extensions/googlechat/src/monitor.test.ts +22 -0
  1165. package/extensions/googlechat/src/monitor.ts +960 -0
  1166. package/extensions/googlechat/src/onboarding.ts +269 -0
  1167. package/extensions/googlechat/src/runtime.ts +14 -0
  1168. package/extensions/googlechat/src/targets.test.ts +32 -0
  1169. package/extensions/googlechat/src/targets.ts +65 -0
  1170. package/extensions/googlechat/src/types.config.ts +3 -0
  1171. package/extensions/googlechat/src/types.ts +73 -0
  1172. package/extensions/googlechat/synurex.plugin.json +9 -0
  1173. package/extensions/imessage/index.ts +17 -0
  1174. package/extensions/imessage/node_modules/.bin/clawdbot +21 -0
  1175. package/extensions/imessage/node_modules/.bin/clawdbot.CMD +12 -0
  1176. package/extensions/imessage/node_modules/.bin/clawdbot.ps1 +41 -0
  1177. package/extensions/imessage/node_modules/.bin/openclaw +21 -0
  1178. package/extensions/imessage/node_modules/.bin/openclaw.CMD +12 -0
  1179. package/extensions/imessage/node_modules/.bin/openclaw.ps1 +41 -0
  1180. package/extensions/imessage/node_modules/.bin/synurex +21 -0
  1181. package/extensions/imessage/node_modules/.bin/synurex.CMD +12 -0
  1182. package/extensions/imessage/node_modules/.bin/synurex.ps1 +41 -0
  1183. package/extensions/imessage/package.json +14 -0
  1184. package/extensions/imessage/src/channel.ts +294 -0
  1185. package/extensions/imessage/src/runtime.ts +14 -0
  1186. package/extensions/imessage/synurex.plugin.json +9 -0
  1187. package/extensions/line/index.ts +19 -0
  1188. package/extensions/line/node_modules/.bin/clawdbot +21 -0
  1189. package/extensions/line/node_modules/.bin/clawdbot.CMD +12 -0
  1190. package/extensions/line/node_modules/.bin/clawdbot.ps1 +41 -0
  1191. package/extensions/line/node_modules/.bin/openclaw +21 -0
  1192. package/extensions/line/node_modules/.bin/openclaw.CMD +12 -0
  1193. package/extensions/line/node_modules/.bin/openclaw.ps1 +41 -0
  1194. package/extensions/line/node_modules/.bin/synurex +21 -0
  1195. package/extensions/line/node_modules/.bin/synurex.CMD +12 -0
  1196. package/extensions/line/node_modules/.bin/synurex.ps1 +41 -0
  1197. package/extensions/line/package.json +29 -0
  1198. package/extensions/line/src/card-command.ts +344 -0
  1199. package/extensions/line/src/channel.logout.test.ts +99 -0
  1200. package/extensions/line/src/channel.sendPayload.test.ts +306 -0
  1201. package/extensions/line/src/channel.ts +780 -0
  1202. package/extensions/line/src/runtime.ts +14 -0
  1203. package/extensions/line/synurex.plugin.json +9 -0
  1204. package/extensions/llm-task/README.md +97 -0
  1205. package/extensions/llm-task/index.ts +6 -0
  1206. package/extensions/llm-task/node_modules/.bin/clawdbot +21 -0
  1207. package/extensions/llm-task/node_modules/.bin/clawdbot.CMD +12 -0
  1208. package/extensions/llm-task/node_modules/.bin/clawdbot.ps1 +41 -0
  1209. package/extensions/llm-task/node_modules/.bin/openclaw +21 -0
  1210. package/extensions/llm-task/node_modules/.bin/openclaw.CMD +12 -0
  1211. package/extensions/llm-task/node_modules/.bin/openclaw.ps1 +41 -0
  1212. package/extensions/llm-task/node_modules/.bin/synurex +21 -0
  1213. package/extensions/llm-task/node_modules/.bin/synurex.CMD +12 -0
  1214. package/extensions/llm-task/node_modules/.bin/synurex.ps1 +41 -0
  1215. package/extensions/llm-task/package.json +14 -0
  1216. package/extensions/llm-task/src/llm-task-tool.test.ts +138 -0
  1217. package/extensions/llm-task/src/llm-task-tool.ts +245 -0
  1218. package/extensions/llm-task/synurex.plugin.json +21 -0
  1219. package/extensions/lobster/README.md +75 -0
  1220. package/extensions/lobster/SKILL.md +97 -0
  1221. package/extensions/lobster/index.ts +14 -0
  1222. package/extensions/lobster/node_modules/.bin/clawdbot +21 -0
  1223. package/extensions/lobster/node_modules/.bin/clawdbot.CMD +12 -0
  1224. package/extensions/lobster/node_modules/.bin/clawdbot.ps1 +41 -0
  1225. package/extensions/lobster/node_modules/.bin/openclaw +21 -0
  1226. package/extensions/lobster/node_modules/.bin/openclaw.CMD +12 -0
  1227. package/extensions/lobster/node_modules/.bin/openclaw.ps1 +41 -0
  1228. package/extensions/lobster/node_modules/.bin/synurex +21 -0
  1229. package/extensions/lobster/node_modules/.bin/synurex.CMD +12 -0
  1230. package/extensions/lobster/node_modules/.bin/synurex.ps1 +41 -0
  1231. package/extensions/lobster/package.json +14 -0
  1232. package/extensions/lobster/src/lobster-tool.test.ts +247 -0
  1233. package/extensions/lobster/src/lobster-tool.ts +328 -0
  1234. package/extensions/lobster/synurex.plugin.json +10 -0
  1235. package/extensions/matrix/CHANGELOG.md +111 -0
  1236. package/extensions/matrix/index.ts +17 -0
  1237. package/extensions/matrix/node_modules/.bin/clawdbot +21 -0
  1238. package/extensions/matrix/node_modules/.bin/clawdbot.CMD +12 -0
  1239. package/extensions/matrix/node_modules/.bin/clawdbot.ps1 +41 -0
  1240. package/extensions/matrix/node_modules/.bin/markdown-it +21 -0
  1241. package/extensions/matrix/node_modules/.bin/markdown-it.CMD +12 -0
  1242. package/extensions/matrix/node_modules/.bin/markdown-it.ps1 +41 -0
  1243. package/extensions/matrix/node_modules/.bin/openclaw +21 -0
  1244. package/extensions/matrix/node_modules/.bin/openclaw.CMD +12 -0
  1245. package/extensions/matrix/node_modules/.bin/openclaw.ps1 +41 -0
  1246. package/extensions/matrix/node_modules/.bin/synurex +21 -0
  1247. package/extensions/matrix/node_modules/.bin/synurex.CMD +12 -0
  1248. package/extensions/matrix/node_modules/.bin/synurex.ps1 +41 -0
  1249. package/extensions/matrix/package.json +36 -0
  1250. package/extensions/matrix/src/actions.ts +195 -0
  1251. package/extensions/matrix/src/channel.directory.test.ts +64 -0
  1252. package/extensions/matrix/src/channel.ts +439 -0
  1253. package/extensions/matrix/src/config-schema.ts +63 -0
  1254. package/extensions/matrix/src/directory-live.ts +188 -0
  1255. package/extensions/matrix/src/group-mentions.ts +66 -0
  1256. package/extensions/matrix/src/matrix/accounts.test.ts +82 -0
  1257. package/extensions/matrix/src/matrix/accounts.ts +65 -0
  1258. package/extensions/matrix/src/matrix/actions/client.ts +57 -0
  1259. package/extensions/matrix/src/matrix/actions/messages.ts +128 -0
  1260. package/extensions/matrix/src/matrix/actions/pins.ts +76 -0
  1261. package/extensions/matrix/src/matrix/actions/reactions.ts +96 -0
  1262. package/extensions/matrix/src/matrix/actions/room.ts +85 -0
  1263. package/extensions/matrix/src/matrix/actions/summary.ts +75 -0
  1264. package/extensions/matrix/src/matrix/actions/types.ts +84 -0
  1265. package/extensions/matrix/src/matrix/actions.ts +15 -0
  1266. package/extensions/matrix/src/matrix/active-client.ts +11 -0
  1267. package/extensions/matrix/src/matrix/client/config.ts +160 -0
  1268. package/extensions/matrix/src/matrix/client/create-client.ts +123 -0
  1269. package/extensions/matrix/src/matrix/client/logging.ts +36 -0
  1270. package/extensions/matrix/src/matrix/client/runtime.ts +4 -0
  1271. package/extensions/matrix/src/matrix/client/shared.ts +170 -0
  1272. package/extensions/matrix/src/matrix/client/storage.ts +131 -0
  1273. package/extensions/matrix/src/matrix/client/types.ts +34 -0
  1274. package/extensions/matrix/src/matrix/client.test.ts +56 -0
  1275. package/extensions/matrix/src/matrix/client.ts +5 -0
  1276. package/extensions/matrix/src/matrix/credentials.ts +105 -0
  1277. package/extensions/matrix/src/matrix/deps.ts +60 -0
  1278. package/extensions/matrix/src/matrix/format.test.ts +33 -0
  1279. package/extensions/matrix/src/matrix/format.ts +22 -0
  1280. package/extensions/matrix/src/matrix/index.ts +11 -0
  1281. package/extensions/matrix/src/matrix/monitor/allowlist.test.ts +45 -0
  1282. package/extensions/matrix/src/matrix/monitor/allowlist.ts +103 -0
  1283. package/extensions/matrix/src/matrix/monitor/auto-join.ts +71 -0
  1284. package/extensions/matrix/src/matrix/monitor/direct.ts +104 -0
  1285. package/extensions/matrix/src/matrix/monitor/events.ts +101 -0
  1286. package/extensions/matrix/src/matrix/monitor/handler.ts +665 -0
  1287. package/extensions/matrix/src/matrix/monitor/index.ts +338 -0
  1288. package/extensions/matrix/src/matrix/monitor/location.ts +100 -0
  1289. package/extensions/matrix/src/matrix/monitor/media.test.ts +102 -0
  1290. package/extensions/matrix/src/matrix/monitor/media.ts +113 -0
  1291. package/extensions/matrix/src/matrix/monitor/mentions.ts +31 -0
  1292. package/extensions/matrix/src/matrix/monitor/replies.ts +97 -0
  1293. package/extensions/matrix/src/matrix/monitor/room-info.ts +55 -0
  1294. package/extensions/matrix/src/matrix/monitor/rooms.test.ts +39 -0
  1295. package/extensions/matrix/src/matrix/monitor/rooms.ts +47 -0
  1296. package/extensions/matrix/src/matrix/monitor/threads.ts +68 -0
  1297. package/extensions/matrix/src/matrix/monitor/types.ts +39 -0
  1298. package/extensions/matrix/src/matrix/poll-types.test.ts +21 -0
  1299. package/extensions/matrix/src/matrix/poll-types.ts +166 -0
  1300. package/extensions/matrix/src/matrix/probe.ts +70 -0
  1301. package/extensions/matrix/src/matrix/send/client.ts +66 -0
  1302. package/extensions/matrix/src/matrix/send/formatting.ts +89 -0
  1303. package/extensions/matrix/src/matrix/send/media.ts +229 -0
  1304. package/extensions/matrix/src/matrix/send/targets.test.ts +98 -0
  1305. package/extensions/matrix/src/matrix/send/targets.ts +147 -0
  1306. package/extensions/matrix/src/matrix/send/types.ts +109 -0
  1307. package/extensions/matrix/src/matrix/send.test.ts +171 -0
  1308. package/extensions/matrix/src/matrix/send.ts +260 -0
  1309. package/extensions/matrix/src/onboarding.ts +449 -0
  1310. package/extensions/matrix/src/outbound.ts +52 -0
  1311. package/extensions/matrix/src/resolve-targets.test.ts +48 -0
  1312. package/extensions/matrix/src/resolve-targets.ts +135 -0
  1313. package/extensions/matrix/src/runtime.ts +14 -0
  1314. package/extensions/matrix/src/tool-actions.ts +164 -0
  1315. package/extensions/matrix/src/types.ts +97 -0
  1316. package/extensions/matrix/synurex.plugin.json +9 -0
  1317. package/extensions/mattermost/index.ts +17 -0
  1318. package/extensions/mattermost/node_modules/.bin/clawdbot +21 -0
  1319. package/extensions/mattermost/node_modules/.bin/clawdbot.CMD +12 -0
  1320. package/extensions/mattermost/node_modules/.bin/clawdbot.ps1 +41 -0
  1321. package/extensions/mattermost/node_modules/.bin/openclaw +21 -0
  1322. package/extensions/mattermost/node_modules/.bin/openclaw.CMD +12 -0
  1323. package/extensions/mattermost/node_modules/.bin/openclaw.ps1 +41 -0
  1324. package/extensions/mattermost/node_modules/.bin/synurex +21 -0
  1325. package/extensions/mattermost/node_modules/.bin/synurex.CMD +12 -0
  1326. package/extensions/mattermost/node_modules/.bin/synurex.ps1 +41 -0
  1327. package/extensions/mattermost/package.json +28 -0
  1328. package/extensions/mattermost/src/channel.test.ts +72 -0
  1329. package/extensions/mattermost/src/channel.ts +337 -0
  1330. package/extensions/mattermost/src/config-schema.ts +56 -0
  1331. package/extensions/mattermost/src/group-mentions.ts +15 -0
  1332. package/extensions/mattermost/src/mattermost/accounts.ts +128 -0
  1333. package/extensions/mattermost/src/mattermost/client.ts +220 -0
  1334. package/extensions/mattermost/src/mattermost/index.ts +9 -0
  1335. package/extensions/mattermost/src/mattermost/monitor-helpers.ts +166 -0
  1336. package/extensions/mattermost/src/mattermost/monitor.ts +991 -0
  1337. package/extensions/mattermost/src/mattermost/probe.ts +74 -0
  1338. package/extensions/mattermost/src/mattermost/send.ts +231 -0
  1339. package/extensions/mattermost/src/normalize.ts +46 -0
  1340. package/extensions/mattermost/src/onboarding-helpers.ts +44 -0
  1341. package/extensions/mattermost/src/onboarding.ts +186 -0
  1342. package/extensions/mattermost/src/runtime.ts +14 -0
  1343. package/extensions/mattermost/src/types.ts +52 -0
  1344. package/extensions/mattermost/synurex.plugin.json +9 -0
  1345. package/extensions/memory-core/index.ts +38 -0
  1346. package/extensions/memory-core/node_modules/.bin/clawdbot +21 -0
  1347. package/extensions/memory-core/node_modules/.bin/clawdbot.CMD +12 -0
  1348. package/extensions/memory-core/node_modules/.bin/clawdbot.ps1 +41 -0
  1349. package/extensions/memory-core/node_modules/.bin/openclaw +21 -0
  1350. package/extensions/memory-core/node_modules/.bin/openclaw.CMD +12 -0
  1351. package/extensions/memory-core/node_modules/.bin/openclaw.ps1 +41 -0
  1352. package/extensions/memory-core/node_modules/.bin/synurex +21 -0
  1353. package/extensions/memory-core/node_modules/.bin/synurex.CMD +12 -0
  1354. package/extensions/memory-core/node_modules/.bin/synurex.ps1 +41 -0
  1355. package/extensions/memory-core/package.json +17 -0
  1356. package/extensions/memory-core/synurex.plugin.json +9 -0
  1357. package/extensions/memory-lancedb/config.ts +139 -0
  1358. package/extensions/memory-lancedb/index.test.ts +253 -0
  1359. package/extensions/memory-lancedb/index.ts +622 -0
  1360. package/extensions/memory-lancedb/node_modules/.bin/clawdbot +21 -0
  1361. package/extensions/memory-lancedb/node_modules/.bin/clawdbot.CMD +12 -0
  1362. package/extensions/memory-lancedb/node_modules/.bin/clawdbot.ps1 +41 -0
  1363. package/extensions/memory-lancedb/node_modules/.bin/openai +21 -0
  1364. package/extensions/memory-lancedb/node_modules/.bin/openai.CMD +12 -0
  1365. package/extensions/memory-lancedb/node_modules/.bin/openai.ps1 +41 -0
  1366. package/extensions/memory-lancedb/node_modules/.bin/openclaw +21 -0
  1367. package/extensions/memory-lancedb/node_modules/.bin/openclaw.CMD +12 -0
  1368. package/extensions/memory-lancedb/node_modules/.bin/openclaw.ps1 +41 -0
  1369. package/extensions/memory-lancedb/node_modules/.bin/synurex +21 -0
  1370. package/extensions/memory-lancedb/node_modules/.bin/synurex.CMD +12 -0
  1371. package/extensions/memory-lancedb/node_modules/.bin/synurex.ps1 +41 -0
  1372. package/extensions/memory-lancedb/package.json +19 -0
  1373. package/extensions/memory-lancedb/synurex.plugin.json +60 -0
  1374. package/extensions/minimax-portal-auth/README.md +33 -0
  1375. package/extensions/minimax-portal-auth/index.ts +155 -0
  1376. package/extensions/minimax-portal-auth/node_modules/.bin/clawdbot +21 -0
  1377. package/extensions/minimax-portal-auth/node_modules/.bin/clawdbot.CMD +12 -0
  1378. package/extensions/minimax-portal-auth/node_modules/.bin/clawdbot.ps1 +41 -0
  1379. package/extensions/minimax-portal-auth/node_modules/.bin/openclaw +21 -0
  1380. package/extensions/minimax-portal-auth/node_modules/.bin/openclaw.CMD +12 -0
  1381. package/extensions/minimax-portal-auth/node_modules/.bin/openclaw.ps1 +41 -0
  1382. package/extensions/minimax-portal-auth/node_modules/.bin/synurex +21 -0
  1383. package/extensions/minimax-portal-auth/node_modules/.bin/synurex.CMD +12 -0
  1384. package/extensions/minimax-portal-auth/node_modules/.bin/synurex.ps1 +41 -0
  1385. package/extensions/minimax-portal-auth/oauth.ts +247 -0
  1386. package/extensions/minimax-portal-auth/package.json +14 -0
  1387. package/extensions/minimax-portal-auth/synurex.plugin.json +9 -0
  1388. package/extensions/msteams/CHANGELOG.md +107 -0
  1389. package/extensions/msteams/index.ts +17 -0
  1390. package/extensions/msteams/node_modules/.bin/clawdbot +21 -0
  1391. package/extensions/msteams/node_modules/.bin/clawdbot.CMD +12 -0
  1392. package/extensions/msteams/node_modules/.bin/clawdbot.ps1 +41 -0
  1393. package/extensions/msteams/node_modules/.bin/openclaw +21 -0
  1394. package/extensions/msteams/node_modules/.bin/openclaw.CMD +12 -0
  1395. package/extensions/msteams/node_modules/.bin/openclaw.ps1 +41 -0
  1396. package/extensions/msteams/node_modules/.bin/synurex +21 -0
  1397. package/extensions/msteams/node_modules/.bin/synurex.CMD +12 -0
  1398. package/extensions/msteams/node_modules/.bin/synurex.ps1 +41 -0
  1399. package/extensions/msteams/package.json +39 -0
  1400. package/extensions/msteams/src/attachments/download.ts +283 -0
  1401. package/extensions/msteams/src/attachments/graph.ts +353 -0
  1402. package/extensions/msteams/src/attachments/html.ts +90 -0
  1403. package/extensions/msteams/src/attachments/payload.ts +22 -0
  1404. package/extensions/msteams/src/attachments/shared.ts +291 -0
  1405. package/extensions/msteams/src/attachments/types.ts +37 -0
  1406. package/extensions/msteams/src/attachments.test.ts +459 -0
  1407. package/extensions/msteams/src/attachments.ts +18 -0
  1408. package/extensions/msteams/src/channel.directory.test.ts +48 -0
  1409. package/extensions/msteams/src/channel.ts +459 -0
  1410. package/extensions/msteams/src/conversation-store-fs.test.ts +88 -0
  1411. package/extensions/msteams/src/conversation-store-fs.ts +165 -0
  1412. package/extensions/msteams/src/conversation-store-memory.ts +47 -0
  1413. package/extensions/msteams/src/conversation-store.ts +41 -0
  1414. package/extensions/msteams/src/directory-live.ts +205 -0
  1415. package/extensions/msteams/src/errors.test.ts +45 -0
  1416. package/extensions/msteams/src/errors.ts +190 -0
  1417. package/extensions/msteams/src/file-consent-helpers.test.ts +243 -0
  1418. package/extensions/msteams/src/file-consent-helpers.ts +73 -0
  1419. package/extensions/msteams/src/file-consent.ts +126 -0
  1420. package/extensions/msteams/src/graph-chat.ts +53 -0
  1421. package/extensions/msteams/src/graph-upload.ts +453 -0
  1422. package/extensions/msteams/src/inbound.test.ts +66 -0
  1423. package/extensions/msteams/src/inbound.ts +48 -0
  1424. package/extensions/msteams/src/index.ts +4 -0
  1425. package/extensions/msteams/src/media-helpers.test.ts +189 -0
  1426. package/extensions/msteams/src/media-helpers.ts +86 -0
  1427. package/extensions/msteams/src/messenger.test.ts +248 -0
  1428. package/extensions/msteams/src/messenger.ts +495 -0
  1429. package/extensions/msteams/src/monitor-handler/inbound-media.ts +128 -0
  1430. package/extensions/msteams/src/monitor-handler/message-handler.ts +641 -0
  1431. package/extensions/msteams/src/monitor-handler.ts +162 -0
  1432. package/extensions/msteams/src/monitor-types.ts +5 -0
  1433. package/extensions/msteams/src/monitor.ts +295 -0
  1434. package/extensions/msteams/src/onboarding.ts +431 -0
  1435. package/extensions/msteams/src/outbound.ts +46 -0
  1436. package/extensions/msteams/src/pending-uploads.ts +89 -0
  1437. package/extensions/msteams/src/policy.test.ts +209 -0
  1438. package/extensions/msteams/src/policy.ts +273 -0
  1439. package/extensions/msteams/src/polls-store-memory.ts +32 -0
  1440. package/extensions/msteams/src/polls-store.test.ts +38 -0
  1441. package/extensions/msteams/src/polls.test.ts +72 -0
  1442. package/extensions/msteams/src/polls.ts +315 -0
  1443. package/extensions/msteams/src/probe.test.ts +58 -0
  1444. package/extensions/msteams/src/probe.ts +107 -0
  1445. package/extensions/msteams/src/reply-dispatcher.ts +132 -0
  1446. package/extensions/msteams/src/resolve-allowlist.ts +297 -0
  1447. package/extensions/msteams/src/runtime.ts +14 -0
  1448. package/extensions/msteams/src/sdk-types.ts +19 -0
  1449. package/extensions/msteams/src/sdk.ts +33 -0
  1450. package/extensions/msteams/src/send-context.ts +164 -0
  1451. package/extensions/msteams/src/send.ts +519 -0
  1452. package/extensions/msteams/src/sent-message-cache.test.ts +15 -0
  1453. package/extensions/msteams/src/sent-message-cache.ts +47 -0
  1454. package/extensions/msteams/src/storage.ts +25 -0
  1455. package/extensions/msteams/src/store-fs.ts +83 -0
  1456. package/extensions/msteams/src/token.ts +19 -0
  1457. package/extensions/msteams/synurex.plugin.json +9 -0
  1458. package/extensions/nextcloud-talk/index.ts +17 -0
  1459. package/extensions/nextcloud-talk/node_modules/.bin/clawdbot +21 -0
  1460. package/extensions/nextcloud-talk/node_modules/.bin/clawdbot.CMD +12 -0
  1461. package/extensions/nextcloud-talk/node_modules/.bin/clawdbot.ps1 +41 -0
  1462. package/extensions/nextcloud-talk/node_modules/.bin/openclaw +21 -0
  1463. package/extensions/nextcloud-talk/node_modules/.bin/openclaw.CMD +12 -0
  1464. package/extensions/nextcloud-talk/node_modules/.bin/openclaw.ps1 +41 -0
  1465. package/extensions/nextcloud-talk/node_modules/.bin/synurex +21 -0
  1466. package/extensions/nextcloud-talk/node_modules/.bin/synurex.CMD +12 -0
  1467. package/extensions/nextcloud-talk/node_modules/.bin/synurex.ps1 +41 -0
  1468. package/extensions/nextcloud-talk/package.json +33 -0
  1469. package/extensions/nextcloud-talk/src/accounts.ts +174 -0
  1470. package/extensions/nextcloud-talk/src/channel.ts +409 -0
  1471. package/extensions/nextcloud-talk/src/config-schema.ts +79 -0
  1472. package/extensions/nextcloud-talk/src/format.ts +79 -0
  1473. package/extensions/nextcloud-talk/src/inbound.ts +327 -0
  1474. package/extensions/nextcloud-talk/src/monitor.ts +246 -0
  1475. package/extensions/nextcloud-talk/src/normalize.ts +39 -0
  1476. package/extensions/nextcloud-talk/src/onboarding.ts +343 -0
  1477. package/extensions/nextcloud-talk/src/policy.test.ts +33 -0
  1478. package/extensions/nextcloud-talk/src/policy.ts +180 -0
  1479. package/extensions/nextcloud-talk/src/room-info.ts +125 -0
  1480. package/extensions/nextcloud-talk/src/runtime.ts +14 -0
  1481. package/extensions/nextcloud-talk/src/send.ts +215 -0
  1482. package/extensions/nextcloud-talk/src/signature.ts +72 -0
  1483. package/extensions/nextcloud-talk/src/types.ts +181 -0
  1484. package/extensions/nextcloud-talk/synurex.plugin.json +9 -0
  1485. package/extensions/nostr/CHANGELOG.md +98 -0
  1486. package/extensions/nostr/README.md +136 -0
  1487. package/extensions/nostr/index.ts +68 -0
  1488. package/extensions/nostr/node_modules/.bin/clawdbot +21 -0
  1489. package/extensions/nostr/node_modules/.bin/clawdbot.CMD +12 -0
  1490. package/extensions/nostr/node_modules/.bin/clawdbot.ps1 +41 -0
  1491. package/extensions/nostr/node_modules/.bin/openclaw +21 -0
  1492. package/extensions/nostr/node_modules/.bin/openclaw.CMD +12 -0
  1493. package/extensions/nostr/node_modules/.bin/openclaw.ps1 +41 -0
  1494. package/extensions/nostr/node_modules/.bin/synurex +21 -0
  1495. package/extensions/nostr/node_modules/.bin/synurex.CMD +12 -0
  1496. package/extensions/nostr/node_modules/.bin/synurex.ps1 +41 -0
  1497. package/extensions/nostr/package.json +34 -0
  1498. package/extensions/nostr/src/channel.test.ts +151 -0
  1499. package/extensions/nostr/src/channel.ts +353 -0
  1500. package/extensions/nostr/src/config-schema.ts +90 -0
  1501. package/extensions/nostr/src/metrics.ts +478 -0
  1502. package/extensions/nostr/src/nostr-bus.fuzz.test.ts +533 -0
  1503. package/extensions/nostr/src/nostr-bus.integration.test.ts +448 -0
  1504. package/extensions/nostr/src/nostr-bus.test.ts +199 -0
  1505. package/extensions/nostr/src/nostr-bus.ts +715 -0
  1506. package/extensions/nostr/src/nostr-profile-http.test.ts +378 -0
  1507. package/extensions/nostr/src/nostr-profile-http.ts +546 -0
  1508. package/extensions/nostr/src/nostr-profile-import.test.ts +119 -0
  1509. package/extensions/nostr/src/nostr-profile-import.ts +262 -0
  1510. package/extensions/nostr/src/nostr-profile.fuzz.test.ts +477 -0
  1511. package/extensions/nostr/src/nostr-profile.test.ts +410 -0
  1512. package/extensions/nostr/src/nostr-profile.ts +277 -0
  1513. package/extensions/nostr/src/nostr-state-store.test.ts +131 -0
  1514. package/extensions/nostr/src/nostr-state-store.ts +226 -0
  1515. package/extensions/nostr/src/runtime.ts +14 -0
  1516. package/extensions/nostr/src/seen-tracker.ts +303 -0
  1517. package/extensions/nostr/src/types.test.ts +157 -0
  1518. package/extensions/nostr/src/types.ts +101 -0
  1519. package/extensions/nostr/synurex.plugin.json +9 -0
  1520. package/extensions/nostr/test/setup.ts +5 -0
  1521. package/extensions/open-prose/README.md +25 -0
  1522. package/extensions/open-prose/index.ts +5 -0
  1523. package/extensions/open-prose/node_modules/.bin/clawdbot +21 -0
  1524. package/extensions/open-prose/node_modules/.bin/clawdbot.CMD +12 -0
  1525. package/extensions/open-prose/node_modules/.bin/clawdbot.ps1 +41 -0
  1526. package/extensions/open-prose/node_modules/.bin/openclaw +21 -0
  1527. package/extensions/open-prose/node_modules/.bin/openclaw.CMD +12 -0
  1528. package/extensions/open-prose/node_modules/.bin/openclaw.ps1 +41 -0
  1529. package/extensions/open-prose/node_modules/.bin/synurex +21 -0
  1530. package/extensions/open-prose/node_modules/.bin/synurex.CMD +12 -0
  1531. package/extensions/open-prose/node_modules/.bin/synurex.ps1 +41 -0
  1532. package/extensions/open-prose/package.json +14 -0
  1533. package/extensions/open-prose/skills/prose/LICENSE +21 -0
  1534. package/extensions/open-prose/skills/prose/SKILL.md +323 -0
  1535. package/extensions/open-prose/skills/prose/alt-borges.md +141 -0
  1536. package/extensions/open-prose/skills/prose/alts/arabian-nights.md +358 -0
  1537. package/extensions/open-prose/skills/prose/alts/borges.md +360 -0
  1538. package/extensions/open-prose/skills/prose/alts/folk.md +322 -0
  1539. package/extensions/open-prose/skills/prose/alts/homer.md +346 -0
  1540. package/extensions/open-prose/skills/prose/alts/kafka.md +373 -0
  1541. package/extensions/open-prose/skills/prose/compiler.md +2971 -0
  1542. package/extensions/open-prose/skills/prose/examples/01-hello-world.prose +4 -0
  1543. package/extensions/open-prose/skills/prose/examples/02-research-and-summarize.prose +6 -0
  1544. package/extensions/open-prose/skills/prose/examples/03-code-review.prose +17 -0
  1545. package/extensions/open-prose/skills/prose/examples/04-write-and-refine.prose +14 -0
  1546. package/extensions/open-prose/skills/prose/examples/05-debug-issue.prose +20 -0
  1547. package/extensions/open-prose/skills/prose/examples/06-explain-codebase.prose +17 -0
  1548. package/extensions/open-prose/skills/prose/examples/07-refactor.prose +20 -0
  1549. package/extensions/open-prose/skills/prose/examples/08-blog-post.prose +20 -0
  1550. package/extensions/open-prose/skills/prose/examples/09-research-with-agents.prose +25 -0
  1551. package/extensions/open-prose/skills/prose/examples/10-code-review-agents.prose +32 -0
  1552. package/extensions/open-prose/skills/prose/examples/11-skills-and-imports.prose +27 -0
  1553. package/extensions/open-prose/skills/prose/examples/12-secure-agent-permissions.prose +43 -0
  1554. package/extensions/open-prose/skills/prose/examples/13-variables-and-context.prose +51 -0
  1555. package/extensions/open-prose/skills/prose/examples/14-composition-blocks.prose +48 -0
  1556. package/extensions/open-prose/skills/prose/examples/15-inline-sequences.prose +23 -0
  1557. package/extensions/open-prose/skills/prose/examples/16-parallel-reviews.prose +19 -0
  1558. package/extensions/open-prose/skills/prose/examples/17-parallel-research.prose +19 -0
  1559. package/extensions/open-prose/skills/prose/examples/18-mixed-parallel-sequential.prose +36 -0
  1560. package/extensions/open-prose/skills/prose/examples/19-advanced-parallel.prose +71 -0
  1561. package/extensions/open-prose/skills/prose/examples/20-fixed-loops.prose +20 -0
  1562. package/extensions/open-prose/skills/prose/examples/21-pipeline-operations.prose +35 -0
  1563. package/extensions/open-prose/skills/prose/examples/22-error-handling.prose +51 -0
  1564. package/extensions/open-prose/skills/prose/examples/23-retry-with-backoff.prose +63 -0
  1565. package/extensions/open-prose/skills/prose/examples/24-choice-blocks.prose +86 -0
  1566. package/extensions/open-prose/skills/prose/examples/25-conditionals.prose +114 -0
  1567. package/extensions/open-prose/skills/prose/examples/26-parameterized-blocks.prose +100 -0
  1568. package/extensions/open-prose/skills/prose/examples/27-string-interpolation.prose +105 -0
  1569. package/extensions/open-prose/skills/prose/examples/28-automated-pr-review.prose +37 -0
  1570. package/extensions/open-prose/skills/prose/examples/28-gas-town.prose +1572 -0
  1571. package/extensions/open-prose/skills/prose/examples/29-captains-chair.prose +218 -0
  1572. package/extensions/open-prose/skills/prose/examples/30-captains-chair-simple.prose +42 -0
  1573. package/extensions/open-prose/skills/prose/examples/31-captains-chair-with-memory.prose +145 -0
  1574. package/extensions/open-prose/skills/prose/examples/33-pr-review-autofix.prose +168 -0
  1575. package/extensions/open-prose/skills/prose/examples/34-content-pipeline.prose +204 -0
  1576. package/extensions/open-prose/skills/prose/examples/35-feature-factory.prose +296 -0
  1577. package/extensions/open-prose/skills/prose/examples/36-bug-hunter.prose +237 -0
  1578. package/extensions/open-prose/skills/prose/examples/37-the-forge.prose +1474 -0
  1579. package/extensions/open-prose/skills/prose/examples/38-skill-scan.prose +455 -0
  1580. package/extensions/open-prose/skills/prose/examples/39-architect-by-simulation.prose +277 -0
  1581. package/extensions/open-prose/skills/prose/examples/40-rlm-self-refine.prose +32 -0
  1582. package/extensions/open-prose/skills/prose/examples/41-rlm-divide-conquer.prose +38 -0
  1583. package/extensions/open-prose/skills/prose/examples/42-rlm-filter-recurse.prose +46 -0
  1584. package/extensions/open-prose/skills/prose/examples/43-rlm-pairwise.prose +50 -0
  1585. package/extensions/open-prose/skills/prose/examples/44-run-endpoint-ux-test.prose +261 -0
  1586. package/extensions/open-prose/skills/prose/examples/45-plugin-release.prose +159 -0
  1587. package/extensions/open-prose/skills/prose/examples/45-run-endpoint-ux-test-with-remediation.prose +637 -0
  1588. package/extensions/open-prose/skills/prose/examples/46-run-endpoint-ux-test-fast.prose +148 -0
  1589. package/extensions/open-prose/skills/prose/examples/46-workflow-crystallizer.prose +225 -0
  1590. package/extensions/open-prose/skills/prose/examples/47-language-self-improvement.prose +356 -0
  1591. package/extensions/open-prose/skills/prose/examples/48-habit-miner.prose +445 -0
  1592. package/extensions/open-prose/skills/prose/examples/49-prose-run-retrospective.prose +210 -0
  1593. package/extensions/open-prose/skills/prose/examples/README.md +391 -0
  1594. package/extensions/open-prose/skills/prose/examples/roadmap/README.md +22 -0
  1595. package/extensions/open-prose/skills/prose/examples/roadmap/iterative-refinement.prose +20 -0
  1596. package/extensions/open-prose/skills/prose/examples/roadmap/parallel-review.prose +18 -0
  1597. package/extensions/open-prose/skills/prose/examples/roadmap/simple-pipeline.prose +17 -0
  1598. package/extensions/open-prose/skills/prose/examples/roadmap/syntax/open-prose-syntax.prose +223 -0
  1599. package/extensions/open-prose/skills/prose/guidance/antipatterns.md +951 -0
  1600. package/extensions/open-prose/skills/prose/guidance/patterns.md +700 -0
  1601. package/extensions/open-prose/skills/prose/guidance/system-prompt.md +180 -0
  1602. package/extensions/open-prose/skills/prose/help.md +144 -0
  1603. package/extensions/open-prose/skills/prose/lib/README.md +108 -0
  1604. package/extensions/open-prose/skills/prose/lib/calibrator.prose +215 -0
  1605. package/extensions/open-prose/skills/prose/lib/cost-analyzer.prose +174 -0
  1606. package/extensions/open-prose/skills/prose/lib/error-forensics.prose +250 -0
  1607. package/extensions/open-prose/skills/prose/lib/inspector.prose +196 -0
  1608. package/extensions/open-prose/skills/prose/lib/profiler.prose +460 -0
  1609. package/extensions/open-prose/skills/prose/lib/program-improver.prose +275 -0
  1610. package/extensions/open-prose/skills/prose/lib/project-memory.prose +118 -0
  1611. package/extensions/open-prose/skills/prose/lib/user-memory.prose +93 -0
  1612. package/extensions/open-prose/skills/prose/lib/vm-improver.prose +243 -0
  1613. package/extensions/open-prose/skills/prose/primitives/session.md +593 -0
  1614. package/extensions/open-prose/skills/prose/prose.md +1237 -0
  1615. package/extensions/open-prose/skills/prose/state/filesystem.md +498 -0
  1616. package/extensions/open-prose/skills/prose/state/in-context.md +384 -0
  1617. package/extensions/open-prose/skills/prose/state/postgres.md +880 -0
  1618. package/extensions/open-prose/skills/prose/state/sqlite.md +574 -0
  1619. package/extensions/open-prose/synurex.plugin.json +11 -0
  1620. package/extensions/qwen-portal-auth/README.md +24 -0
  1621. package/extensions/qwen-portal-auth/index.ts +130 -0
  1622. package/extensions/qwen-portal-auth/oauth.ts +190 -0
  1623. package/extensions/qwen-portal-auth/synurex.plugin.json +9 -0
  1624. package/extensions/signal/index.ts +17 -0
  1625. package/extensions/signal/node_modules/.bin/clawdbot +21 -0
  1626. package/extensions/signal/node_modules/.bin/clawdbot.CMD +12 -0
  1627. package/extensions/signal/node_modules/.bin/clawdbot.ps1 +41 -0
  1628. package/extensions/signal/node_modules/.bin/openclaw +21 -0
  1629. package/extensions/signal/node_modules/.bin/openclaw.CMD +12 -0
  1630. package/extensions/signal/node_modules/.bin/openclaw.ps1 +41 -0
  1631. package/extensions/signal/node_modules/.bin/synurex +21 -0
  1632. package/extensions/signal/node_modules/.bin/synurex.CMD +12 -0
  1633. package/extensions/signal/node_modules/.bin/synurex.ps1 +41 -0
  1634. package/extensions/signal/package.json +14 -0
  1635. package/extensions/signal/src/channel.ts +315 -0
  1636. package/extensions/signal/src/runtime.ts +14 -0
  1637. package/extensions/signal/synurex.plugin.json +9 -0
  1638. package/extensions/slack/index.ts +17 -0
  1639. package/extensions/slack/node_modules/.bin/clawdbot +21 -0
  1640. package/extensions/slack/node_modules/.bin/clawdbot.CMD +12 -0
  1641. package/extensions/slack/node_modules/.bin/clawdbot.ps1 +41 -0
  1642. package/extensions/slack/node_modules/.bin/openclaw +21 -0
  1643. package/extensions/slack/node_modules/.bin/openclaw.CMD +12 -0
  1644. package/extensions/slack/node_modules/.bin/openclaw.ps1 +41 -0
  1645. package/extensions/slack/node_modules/.bin/synurex +21 -0
  1646. package/extensions/slack/node_modules/.bin/synurex.CMD +12 -0
  1647. package/extensions/slack/node_modules/.bin/synurex.ps1 +41 -0
  1648. package/extensions/slack/package.json +14 -0
  1649. package/extensions/slack/src/channel.ts +604 -0
  1650. package/extensions/slack/src/runtime.ts +14 -0
  1651. package/extensions/slack/synurex.plugin.json +9 -0
  1652. package/extensions/telegram/index.ts +17 -0
  1653. package/extensions/telegram/node_modules/.bin/clawdbot +21 -0
  1654. package/extensions/telegram/node_modules/.bin/clawdbot.CMD +12 -0
  1655. package/extensions/telegram/node_modules/.bin/clawdbot.ps1 +41 -0
  1656. package/extensions/telegram/node_modules/.bin/openclaw +21 -0
  1657. package/extensions/telegram/node_modules/.bin/openclaw.CMD +12 -0
  1658. package/extensions/telegram/node_modules/.bin/openclaw.ps1 +41 -0
  1659. package/extensions/telegram/node_modules/.bin/synurex +21 -0
  1660. package/extensions/telegram/node_modules/.bin/synurex.CMD +12 -0
  1661. package/extensions/telegram/node_modules/.bin/synurex.ps1 +41 -0
  1662. package/extensions/telegram/package.json +14 -0
  1663. package/extensions/telegram/src/channel.ts +482 -0
  1664. package/extensions/telegram/src/runtime.ts +14 -0
  1665. package/extensions/telegram/synurex.plugin.json +9 -0
  1666. package/extensions/tlon/README.md +5 -0
  1667. package/extensions/tlon/index.ts +17 -0
  1668. package/extensions/tlon/node_modules/.bin/clawdbot +21 -0
  1669. package/extensions/tlon/node_modules/.bin/clawdbot.CMD +12 -0
  1670. package/extensions/tlon/node_modules/.bin/clawdbot.ps1 +41 -0
  1671. package/extensions/tlon/node_modules/.bin/openclaw +21 -0
  1672. package/extensions/tlon/node_modules/.bin/openclaw.CMD +12 -0
  1673. package/extensions/tlon/node_modules/.bin/openclaw.ps1 +41 -0
  1674. package/extensions/tlon/node_modules/.bin/synurex +21 -0
  1675. package/extensions/tlon/node_modules/.bin/synurex.CMD +12 -0
  1676. package/extensions/tlon/node_modules/.bin/synurex.ps1 +41 -0
  1677. package/extensions/tlon/package.json +33 -0
  1678. package/extensions/tlon/src/channel.ts +392 -0
  1679. package/extensions/tlon/src/config-schema.test.ts +31 -0
  1680. package/extensions/tlon/src/config-schema.ts +45 -0
  1681. package/extensions/tlon/src/monitor/discovery.ts +76 -0
  1682. package/extensions/tlon/src/monitor/history.ts +90 -0
  1683. package/extensions/tlon/src/monitor/index.ts +580 -0
  1684. package/extensions/tlon/src/monitor/processed-messages.test.ts +23 -0
  1685. package/extensions/tlon/src/monitor/processed-messages.ts +46 -0
  1686. package/extensions/tlon/src/monitor/utils.ts +106 -0
  1687. package/extensions/tlon/src/onboarding.ts +214 -0
  1688. package/extensions/tlon/src/runtime.ts +14 -0
  1689. package/extensions/tlon/src/targets.ts +89 -0
  1690. package/extensions/tlon/src/types.ts +92 -0
  1691. package/extensions/tlon/src/urbit/auth.ts +18 -0
  1692. package/extensions/tlon/src/urbit/http-api.ts +38 -0
  1693. package/extensions/tlon/src/urbit/send.test.ts +38 -0
  1694. package/extensions/tlon/src/urbit/send.ts +131 -0
  1695. package/extensions/tlon/src/urbit/sse-client.test.ts +40 -0
  1696. package/extensions/tlon/src/urbit/sse-client.ts +395 -0
  1697. package/extensions/tlon/synurex.plugin.json +9 -0
  1698. package/extensions/twitch/CHANGELOG.md +69 -0
  1699. package/extensions/twitch/README.md +89 -0
  1700. package/extensions/twitch/index.ts +20 -0
  1701. package/extensions/twitch/node_modules/.bin/clawdbot +21 -0
  1702. package/extensions/twitch/node_modules/.bin/clawdbot.CMD +12 -0
  1703. package/extensions/twitch/node_modules/.bin/clawdbot.ps1 +41 -0
  1704. package/extensions/twitch/node_modules/.bin/openclaw +21 -0
  1705. package/extensions/twitch/node_modules/.bin/openclaw.CMD +12 -0
  1706. package/extensions/twitch/node_modules/.bin/openclaw.ps1 +41 -0
  1707. package/extensions/twitch/node_modules/.bin/synurex +21 -0
  1708. package/extensions/twitch/node_modules/.bin/synurex.CMD +12 -0
  1709. package/extensions/twitch/node_modules/.bin/synurex.ps1 +41 -0
  1710. package/extensions/twitch/package.json +20 -0
  1711. package/extensions/twitch/src/access-control.test.ts +489 -0
  1712. package/extensions/twitch/src/access-control.ts +166 -0
  1713. package/extensions/twitch/src/actions.ts +173 -0
  1714. package/extensions/twitch/src/client-manager-registry.ts +115 -0
  1715. package/extensions/twitch/src/config-schema.ts +84 -0
  1716. package/extensions/twitch/src/config.test.ts +87 -0
  1717. package/extensions/twitch/src/config.ts +116 -0
  1718. package/extensions/twitch/src/monitor.ts +272 -0
  1719. package/extensions/twitch/src/onboarding.test.ts +311 -0
  1720. package/extensions/twitch/src/onboarding.ts +417 -0
  1721. package/extensions/twitch/src/outbound.test.ts +373 -0
  1722. package/extensions/twitch/src/outbound.ts +184 -0
  1723. package/extensions/twitch/src/plugin.test.ts +39 -0
  1724. package/extensions/twitch/src/plugin.ts +274 -0
  1725. package/extensions/twitch/src/probe.test.ts +195 -0
  1726. package/extensions/twitch/src/probe.ts +120 -0
  1727. package/extensions/twitch/src/resolver.ts +137 -0
  1728. package/extensions/twitch/src/runtime.ts +14 -0
  1729. package/extensions/twitch/src/send.test.ts +289 -0
  1730. package/extensions/twitch/src/send.ts +136 -0
  1731. package/extensions/twitch/src/status.test.ts +270 -0
  1732. package/extensions/twitch/src/status.ts +178 -0
  1733. package/extensions/twitch/src/token.test.ts +171 -0
  1734. package/extensions/twitch/src/token.ts +91 -0
  1735. package/extensions/twitch/src/twitch-client.test.ts +589 -0
  1736. package/extensions/twitch/src/twitch-client.ts +277 -0
  1737. package/extensions/twitch/src/types.ts +143 -0
  1738. package/extensions/twitch/src/utils/markdown.ts +98 -0
  1739. package/extensions/twitch/src/utils/twitch.ts +78 -0
  1740. package/extensions/twitch/synurex.plugin.json +9 -0
  1741. package/extensions/twitch/test/setup.ts +7 -0
  1742. package/extensions/voice-call/CHANGELOG.md +133 -0
  1743. package/extensions/voice-call/README.md +139 -0
  1744. package/extensions/voice-call/index.ts +493 -0
  1745. package/extensions/voice-call/node_modules/.bin/clawdbot +21 -0
  1746. package/extensions/voice-call/node_modules/.bin/clawdbot.CMD +12 -0
  1747. package/extensions/voice-call/node_modules/.bin/clawdbot.ps1 +41 -0
  1748. package/extensions/voice-call/node_modules/.bin/openclaw +21 -0
  1749. package/extensions/voice-call/node_modules/.bin/openclaw.CMD +12 -0
  1750. package/extensions/voice-call/node_modules/.bin/openclaw.ps1 +41 -0
  1751. package/extensions/voice-call/node_modules/.bin/synurex +21 -0
  1752. package/extensions/voice-call/node_modules/.bin/synurex.CMD +12 -0
  1753. package/extensions/voice-call/node_modules/.bin/synurex.ps1 +41 -0
  1754. package/extensions/voice-call/package.json +19 -0
  1755. package/extensions/voice-call/src/allowlist.ts +19 -0
  1756. package/extensions/voice-call/src/cli.ts +279 -0
  1757. package/extensions/voice-call/src/config.test.ts +234 -0
  1758. package/extensions/voice-call/src/config.ts +523 -0
  1759. package/extensions/voice-call/src/core-bridge.ts +159 -0
  1760. package/extensions/voice-call/src/manager/context.ts +21 -0
  1761. package/extensions/voice-call/src/manager/events.ts +188 -0
  1762. package/extensions/voice-call/src/manager/lookup.ts +35 -0
  1763. package/extensions/voice-call/src/manager/outbound.ts +275 -0
  1764. package/extensions/voice-call/src/manager/state.ts +48 -0
  1765. package/extensions/voice-call/src/manager/store.ts +91 -0
  1766. package/extensions/voice-call/src/manager/timers.ts +89 -0
  1767. package/extensions/voice-call/src/manager/twiml.ts +9 -0
  1768. package/extensions/voice-call/src/manager.test.ts +224 -0
  1769. package/extensions/voice-call/src/manager.ts +887 -0
  1770. package/extensions/voice-call/src/media-stream.test.ts +96 -0
  1771. package/extensions/voice-call/src/media-stream.ts +411 -0
  1772. package/extensions/voice-call/src/providers/base.ts +67 -0
  1773. package/extensions/voice-call/src/providers/index.ts +10 -0
  1774. package/extensions/voice-call/src/providers/mock.ts +165 -0
  1775. package/extensions/voice-call/src/providers/plivo.test.ts +27 -0
  1776. package/extensions/voice-call/src/providers/plivo.ts +515 -0
  1777. package/extensions/voice-call/src/providers/stt-openai-realtime.ts +311 -0
  1778. package/extensions/voice-call/src/providers/telnyx.ts +371 -0
  1779. package/extensions/voice-call/src/providers/tts-openai.ts +259 -0
  1780. package/extensions/voice-call/src/providers/twilio/api.ts +42 -0
  1781. package/extensions/voice-call/src/providers/twilio/webhook.ts +32 -0
  1782. package/extensions/voice-call/src/providers/twilio.test.ts +60 -0
  1783. package/extensions/voice-call/src/providers/twilio.ts +626 -0
  1784. package/extensions/voice-call/src/response-generator.ts +158 -0
  1785. package/extensions/voice-call/src/runtime.ts +212 -0
  1786. package/extensions/voice-call/src/telephony-audio.ts +90 -0
  1787. package/extensions/voice-call/src/telephony-tts.ts +104 -0
  1788. package/extensions/voice-call/src/tunnel.ts +314 -0
  1789. package/extensions/voice-call/src/types.ts +272 -0
  1790. package/extensions/voice-call/src/utils.ts +14 -0
  1791. package/extensions/voice-call/src/voice-mapping.ts +67 -0
  1792. package/extensions/voice-call/src/webhook-security.test.ts +377 -0
  1793. package/extensions/voice-call/src/webhook-security.ts +689 -0
  1794. package/extensions/voice-call/src/webhook.ts +516 -0
  1795. package/extensions/voice-call/synurex.plugin.json +559 -0
  1796. package/extensions/whatsapp/index.ts +17 -0
  1797. package/extensions/whatsapp/node_modules/.bin/clawdbot +21 -0
  1798. package/extensions/whatsapp/node_modules/.bin/clawdbot.CMD +12 -0
  1799. package/extensions/whatsapp/node_modules/.bin/clawdbot.ps1 +41 -0
  1800. package/extensions/whatsapp/node_modules/.bin/openclaw +21 -0
  1801. package/extensions/whatsapp/node_modules/.bin/openclaw.CMD +12 -0
  1802. package/extensions/whatsapp/node_modules/.bin/openclaw.ps1 +41 -0
  1803. package/extensions/whatsapp/node_modules/.bin/synurex +21 -0
  1804. package/extensions/whatsapp/node_modules/.bin/synurex.CMD +12 -0
  1805. package/extensions/whatsapp/node_modules/.bin/synurex.ps1 +41 -0
  1806. package/extensions/whatsapp/package.json +14 -0
  1807. package/extensions/whatsapp/src/channel.ts +508 -0
  1808. package/extensions/whatsapp/src/runtime.ts +14 -0
  1809. package/extensions/whatsapp/synurex.plugin.json +9 -0
  1810. package/extensions/zalo/CHANGELOG.md +113 -0
  1811. package/extensions/zalo/README.md +50 -0
  1812. package/extensions/zalo/index.ts +19 -0
  1813. package/extensions/zalo/node_modules/.bin/clawdbot +21 -0
  1814. package/extensions/zalo/node_modules/.bin/clawdbot.CMD +12 -0
  1815. package/extensions/zalo/node_modules/.bin/clawdbot.ps1 +41 -0
  1816. package/extensions/zalo/node_modules/.bin/openclaw +21 -0
  1817. package/extensions/zalo/node_modules/.bin/openclaw.CMD +12 -0
  1818. package/extensions/zalo/node_modules/.bin/openclaw.ps1 +41 -0
  1819. package/extensions/zalo/node_modules/.bin/synurex +21 -0
  1820. package/extensions/zalo/node_modules/.bin/synurex.CMD +12 -0
  1821. package/extensions/zalo/node_modules/.bin/synurex.ps1 +41 -0
  1822. package/extensions/zalo/package.json +36 -0
  1823. package/extensions/zalo/src/accounts.ts +80 -0
  1824. package/extensions/zalo/src/actions.ts +67 -0
  1825. package/extensions/zalo/src/api.ts +208 -0
  1826. package/extensions/zalo/src/channel.directory.test.ts +43 -0
  1827. package/extensions/zalo/src/channel.ts +414 -0
  1828. package/extensions/zalo/src/config-schema.ts +25 -0
  1829. package/extensions/zalo/src/monitor.ts +764 -0
  1830. package/extensions/zalo/src/monitor.webhook.test.ts +73 -0
  1831. package/extensions/zalo/src/onboarding.ts +401 -0
  1832. package/extensions/zalo/src/probe.ts +46 -0
  1833. package/extensions/zalo/src/proxy.ts +21 -0
  1834. package/extensions/zalo/src/runtime.ts +14 -0
  1835. package/extensions/zalo/src/send.ts +124 -0
  1836. package/extensions/zalo/src/status-issues.ts +53 -0
  1837. package/extensions/zalo/src/token.ts +63 -0
  1838. package/extensions/zalo/src/types.ts +44 -0
  1839. package/extensions/zalo/synurex.plugin.json +9 -0
  1840. package/extensions/zalouser/CHANGELOG.md +85 -0
  1841. package/extensions/zalouser/README.md +225 -0
  1842. package/extensions/zalouser/index.ts +31 -0
  1843. package/extensions/zalouser/node_modules/.bin/clawdbot +21 -0
  1844. package/extensions/zalouser/node_modules/.bin/clawdbot.CMD +12 -0
  1845. package/extensions/zalouser/node_modules/.bin/clawdbot.ps1 +41 -0
  1846. package/extensions/zalouser/node_modules/.bin/openclaw +21 -0
  1847. package/extensions/zalouser/node_modules/.bin/openclaw.CMD +12 -0
  1848. package/extensions/zalouser/node_modules/.bin/openclaw.ps1 +41 -0
  1849. package/extensions/zalouser/node_modules/.bin/synurex +21 -0
  1850. package/extensions/zalouser/node_modules/.bin/synurex.CMD +12 -0
  1851. package/extensions/zalouser/node_modules/.bin/synurex.ps1 +41 -0
  1852. package/extensions/zalouser/package.json +36 -0
  1853. package/extensions/zalouser/src/accounts.ts +135 -0
  1854. package/extensions/zalouser/src/channel.test.ts +18 -0
  1855. package/extensions/zalouser/src/channel.ts +686 -0
  1856. package/extensions/zalouser/src/config-schema.ts +28 -0
  1857. package/extensions/zalouser/src/monitor.ts +601 -0
  1858. package/extensions/zalouser/src/onboarding.ts +504 -0
  1859. package/extensions/zalouser/src/probe.ts +28 -0
  1860. package/extensions/zalouser/src/runtime.ts +14 -0
  1861. package/extensions/zalouser/src/send.ts +160 -0
  1862. package/extensions/zalouser/src/status-issues.test.ts +57 -0
  1863. package/extensions/zalouser/src/status-issues.ts +89 -0
  1864. package/extensions/zalouser/src/tool.ts +164 -0
  1865. package/extensions/zalouser/src/types.ts +110 -0
  1866. package/extensions/zalouser/src/zca.ts +202 -0
  1867. package/extensions/zalouser/synurex.plugin.json +9 -0
  1868. package/package.json +263 -0
  1869. package/skills/1password/SKILL.md +70 -0
  1870. package/skills/1password/references/cli-examples.md +29 -0
  1871. package/skills/1password/references/get-started.md +17 -0
  1872. package/skills/apple-notes/SKILL.md +77 -0
  1873. package/skills/apple-reminders/SKILL.md +96 -0
  1874. package/skills/bear-notes/SKILL.md +107 -0
  1875. package/skills/blogwatcher/SKILL.md +69 -0
  1876. package/skills/blucli/SKILL.md +47 -0
  1877. package/skills/bluebubbles/SKILL.md +131 -0
  1878. package/skills/camsnap/SKILL.md +45 -0
  1879. package/skills/canvas/SKILL.md +198 -0
  1880. package/skills/clawhub/SKILL.md +77 -0
  1881. package/skills/coding-agent/SKILL.md +284 -0
  1882. package/skills/discord/SKILL.md +578 -0
  1883. package/skills/eightctl/SKILL.md +50 -0
  1884. package/skills/food-order/SKILL.md +48 -0
  1885. package/skills/gemini/SKILL.md +43 -0
  1886. package/skills/gifgrep/SKILL.md +79 -0
  1887. package/skills/github/SKILL.md +77 -0
  1888. package/skills/gog/SKILL.md +116 -0
  1889. package/skills/goplaces/SKILL.md +52 -0
  1890. package/skills/healthcheck/SKILL.md +245 -0
  1891. package/skills/himalaya/SKILL.md +257 -0
  1892. package/skills/himalaya/references/configuration.md +184 -0
  1893. package/skills/himalaya/references/message-composition.md +199 -0
  1894. package/skills/imsg/SKILL.md +74 -0
  1895. package/skills/local-places/SERVER_README.md +101 -0
  1896. package/skills/local-places/SKILL.md +102 -0
  1897. package/skills/local-places/pyproject.toml +21 -0
  1898. package/skills/local-places/src/local_places/__init__.py +2 -0
  1899. package/skills/local-places/src/local_places/google_places.py +314 -0
  1900. package/skills/local-places/src/local_places/main.py +65 -0
  1901. package/skills/local-places/src/local_places/schemas.py +107 -0
  1902. package/skills/mcporter/SKILL.md +61 -0
  1903. package/skills/model-usage/SKILL.md +69 -0
  1904. package/skills/model-usage/references/codexbar-cli.md +33 -0
  1905. package/skills/model-usage/scripts/model_usage.py +310 -0
  1906. package/skills/nano-banana-pro/SKILL.md +58 -0
  1907. package/skills/nano-banana-pro/scripts/generate_image.py +184 -0
  1908. package/skills/nano-pdf/SKILL.md +38 -0
  1909. package/skills/notion/SKILL.md +172 -0
  1910. package/skills/obsidian/SKILL.md +81 -0
  1911. package/skills/openai-image-gen/SKILL.md +89 -0
  1912. package/skills/openai-image-gen/scripts/gen.py +240 -0
  1913. package/skills/openai-whisper/SKILL.md +38 -0
  1914. package/skills/openai-whisper-api/SKILL.md +52 -0
  1915. package/skills/openai-whisper-api/scripts/transcribe.sh +85 -0
  1916. package/skills/openhue/SKILL.md +51 -0
  1917. package/skills/oracle/SKILL.md +125 -0
  1918. package/skills/ordercli/SKILL.md +78 -0
  1919. package/skills/peekaboo/SKILL.md +190 -0
  1920. package/skills/sag/SKILL.md +87 -0
  1921. package/skills/session-logs/SKILL.md +115 -0
  1922. package/skills/sherpa-onnx-tts/SKILL.md +103 -0
  1923. package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +178 -0
  1924. package/skills/skill-creator/SKILL.md +370 -0
  1925. package/skills/skill-creator/license.txt +202 -0
  1926. package/skills/skill-creator/scripts/init_skill.py +378 -0
  1927. package/skills/skill-creator/scripts/package_skill.py +111 -0
  1928. package/skills/skill-creator/scripts/quick_validate.py +101 -0
  1929. package/skills/slack/SKILL.md +144 -0
  1930. package/skills/songsee/SKILL.md +49 -0
  1931. package/skills/sonoscli/SKILL.md +46 -0
  1932. package/skills/spotify-player/SKILL.md +64 -0
  1933. package/skills/summarize/SKILL.md +87 -0
  1934. package/skills/things-mac/SKILL.md +86 -0
  1935. package/skills/tmux/SKILL.md +135 -0
  1936. package/skills/tmux/scripts/find-sessions.sh +112 -0
  1937. package/skills/tmux/scripts/wait-for-text.sh +83 -0
  1938. package/skills/trello/SKILL.md +95 -0
  1939. package/skills/video-frames/SKILL.md +46 -0
  1940. package/skills/video-frames/scripts/frame.sh +81 -0
  1941. package/skills/voice-call/SKILL.md +45 -0
  1942. package/skills/wacli/SKILL.md +72 -0
  1943. package/skills/weather/SKILL.md +54 -0
  1944. package/synurex.mjs +33 -0
@@ -0,0 +1,2983 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
2
+ import { g as resolveStateDir, h as resolveOAuthPath } from "./paths-Drx5WZ13.js";
3
+ import { n as DEFAULT_AGENT_ID } from "./session-key-DrNCyvP1.js";
4
+ import { t as createSubsystemLogger } from "./subsystem-DPYBJG7C.js";
5
+ import { h as resolveUserPath } from "./utils-C7NsUvD1.js";
6
+ import { a as resolveAgentModelPrimary } from "./agent-scope-CRRhJ7Hf.js";
7
+ import { a as saveJsonFile, i as loadJsonFile, r as resolveCopilotApiToken, t as DEFAULT_COPILOT_API_BASE_URL } from "./github-copilot-token-_jdpoYjM.js";
8
+ import { t as formatCliCommand } from "./command-format-CEnDvS9q.js";
9
+ import { t as isTruthyEnvValue } from "./env-DgIs6BZg.js";
10
+ import path from "node:path";
11
+ import fs from "node:fs";
12
+ import { execFileSync, execSync } from "node:child_process";
13
+ import lockfile from "proper-lockfile";
14
+ import { createHash, randomBytes } from "node:crypto";
15
+ import { getEnvApiKey, getOAuthApiKey, getOAuthProviders } from "@mariozechner/pi-ai";
16
+ import { BedrockClient, ListFoundationModelsCommand } from "@aws-sdk/client-bedrock";
17
+
18
+ //#region src/agents/defaults.ts
19
+ const DEFAULT_PROVIDER = "anthropic";
20
+ const DEFAULT_MODEL = "claude-opus-4-6";
21
+ const DEFAULT_CONTEXT_TOKENS = 2e5;
22
+
23
+ //#endregion
24
+ //#region src/agents/auth-profiles/constants.ts
25
+ const AUTH_STORE_VERSION = 1;
26
+ const AUTH_PROFILE_FILENAME = "auth-profiles.json";
27
+ const LEGACY_AUTH_FILENAME = "auth.json";
28
+ const CLAUDE_CLI_PROFILE_ID = "anthropic:claude-cli";
29
+ const CODEX_CLI_PROFILE_ID = "openai-codex:codex-cli";
30
+ const QWEN_CLI_PROFILE_ID = "qwen-portal:qwen-cli";
31
+ const MINIMAX_CLI_PROFILE_ID = "minimax-portal:minimax-cli";
32
+ const AUTH_STORE_LOCK_OPTIONS = {
33
+ retries: {
34
+ retries: 10,
35
+ factor: 2,
36
+ minTimeout: 100,
37
+ maxTimeout: 1e4,
38
+ randomize: true
39
+ },
40
+ stale: 3e4
41
+ };
42
+ const EXTERNAL_CLI_SYNC_TTL_MS = 900 * 1e3;
43
+ const EXTERNAL_CLI_NEAR_EXPIRY_MS = 600 * 1e3;
44
+ const log$1 = createSubsystemLogger("agents/auth-profiles");
45
+
46
+ //#endregion
47
+ //#region src/agents/auth-profiles/display.ts
48
+ function resolveAuthProfileDisplayLabel(params) {
49
+ const { cfg, store, profileId } = params;
50
+ const profile = store.profiles[profileId];
51
+ const email = cfg?.auth?.profiles?.[profileId]?.email?.trim() || (profile && "email" in profile ? profile.email?.trim() : void 0);
52
+ if (email) return `${profileId} (${email})`;
53
+ return profileId;
54
+ }
55
+
56
+ //#endregion
57
+ //#region src/agents/cli-credentials.ts
58
+ const log = createSubsystemLogger("agents/auth-profiles");
59
+ const QWEN_CLI_CREDENTIALS_RELATIVE_PATH = ".qwen/oauth_creds.json";
60
+ const MINIMAX_CLI_CREDENTIALS_RELATIVE_PATH = ".minimax/oauth_creds.json";
61
+ let qwenCliCache = null;
62
+ let minimaxCliCache = null;
63
+ function resolveQwenCliCredentialsPath(homeDir) {
64
+ const baseDir = homeDir ?? resolveUserPath("~");
65
+ return path.join(baseDir, QWEN_CLI_CREDENTIALS_RELATIVE_PATH);
66
+ }
67
+ function resolveMiniMaxCliCredentialsPath(homeDir) {
68
+ const baseDir = homeDir ?? resolveUserPath("~");
69
+ return path.join(baseDir, MINIMAX_CLI_CREDENTIALS_RELATIVE_PATH);
70
+ }
71
+ function readQwenCliCredentials(options) {
72
+ const raw = loadJsonFile(resolveQwenCliCredentialsPath(options?.homeDir));
73
+ if (!raw || typeof raw !== "object") return null;
74
+ const data = raw;
75
+ const accessToken = data.access_token;
76
+ const refreshToken = data.refresh_token;
77
+ const expiresAt = data.expiry_date;
78
+ if (typeof accessToken !== "string" || !accessToken) return null;
79
+ if (typeof refreshToken !== "string" || !refreshToken) return null;
80
+ if (typeof expiresAt !== "number" || !Number.isFinite(expiresAt)) return null;
81
+ return {
82
+ type: "oauth",
83
+ provider: "qwen-portal",
84
+ access: accessToken,
85
+ refresh: refreshToken,
86
+ expires: expiresAt
87
+ };
88
+ }
89
+ function readMiniMaxCliCredentials(options) {
90
+ const raw = loadJsonFile(resolveMiniMaxCliCredentialsPath(options?.homeDir));
91
+ if (!raw || typeof raw !== "object") return null;
92
+ const data = raw;
93
+ const accessToken = data.access_token;
94
+ const refreshToken = data.refresh_token;
95
+ const expiresAt = data.expiry_date;
96
+ if (typeof accessToken !== "string" || !accessToken) return null;
97
+ if (typeof refreshToken !== "string" || !refreshToken) return null;
98
+ if (typeof expiresAt !== "number" || !Number.isFinite(expiresAt)) return null;
99
+ return {
100
+ type: "oauth",
101
+ provider: "minimax-portal",
102
+ access: accessToken,
103
+ refresh: refreshToken,
104
+ expires: expiresAt
105
+ };
106
+ }
107
+ function readQwenCliCredentialsCached(options) {
108
+ const ttlMs = options?.ttlMs ?? 0;
109
+ const now = Date.now();
110
+ const cacheKey = resolveQwenCliCredentialsPath(options?.homeDir);
111
+ if (ttlMs > 0 && qwenCliCache && qwenCliCache.cacheKey === cacheKey && now - qwenCliCache.readAt < ttlMs) return qwenCliCache.value;
112
+ const value = readQwenCliCredentials({ homeDir: options?.homeDir });
113
+ if (ttlMs > 0) qwenCliCache = {
114
+ value,
115
+ readAt: now,
116
+ cacheKey
117
+ };
118
+ return value;
119
+ }
120
+ function readMiniMaxCliCredentialsCached(options) {
121
+ const ttlMs = options?.ttlMs ?? 0;
122
+ const now = Date.now();
123
+ const cacheKey = resolveMiniMaxCliCredentialsPath(options?.homeDir);
124
+ if (ttlMs > 0 && minimaxCliCache && minimaxCliCache.cacheKey === cacheKey && now - minimaxCliCache.readAt < ttlMs) return minimaxCliCache.value;
125
+ const value = readMiniMaxCliCredentials({ homeDir: options?.homeDir });
126
+ if (ttlMs > 0) minimaxCliCache = {
127
+ value,
128
+ readAt: now,
129
+ cacheKey
130
+ };
131
+ return value;
132
+ }
133
+
134
+ //#endregion
135
+ //#region src/agents/auth-profiles/external-cli-sync.ts
136
+ function shallowEqualOAuthCredentials(a, b) {
137
+ if (!a) return false;
138
+ if (a.type !== "oauth") return false;
139
+ return a.provider === b.provider && a.access === b.access && a.refresh === b.refresh && a.expires === b.expires && a.email === b.email && a.enterpriseUrl === b.enterpriseUrl && a.projectId === b.projectId && a.accountId === b.accountId;
140
+ }
141
+ function isExternalProfileFresh(cred, now) {
142
+ if (!cred) return false;
143
+ if (cred.type !== "oauth" && cred.type !== "token") return false;
144
+ if (cred.provider !== "qwen-portal" && cred.provider !== "minimax-portal") return false;
145
+ if (typeof cred.expires !== "number") return true;
146
+ return cred.expires > now + EXTERNAL_CLI_NEAR_EXPIRY_MS;
147
+ }
148
+ /** Sync external CLI credentials into the store for a given provider. */
149
+ function syncExternalCliCredentialsForProvider(store, profileId, provider, readCredentials, now) {
150
+ const existing = store.profiles[profileId];
151
+ const creds = !existing || existing.provider !== provider || !isExternalProfileFresh(existing, now) ? readCredentials() : null;
152
+ if (!creds) return false;
153
+ const existingOAuth = existing?.type === "oauth" ? existing : void 0;
154
+ if ((!existingOAuth || existingOAuth.provider !== provider || existingOAuth.expires <= now || creds.expires > existingOAuth.expires) && !shallowEqualOAuthCredentials(existingOAuth, creds)) {
155
+ store.profiles[profileId] = creds;
156
+ log$1.info(`synced ${provider} credentials from external cli`, {
157
+ profileId,
158
+ expires: new Date(creds.expires).toISOString()
159
+ });
160
+ return true;
161
+ }
162
+ return false;
163
+ }
164
+ /**
165
+ * Sync OAuth credentials from external CLI tools (Qwen Code CLI, MiniMax CLI) into the store.
166
+ *
167
+ * Returns true if any credentials were updated.
168
+ */
169
+ function syncExternalCliCredentials(store) {
170
+ let mutated = false;
171
+ const now = Date.now();
172
+ const existingQwen = store.profiles[QWEN_CLI_PROFILE_ID];
173
+ const qwenCreds = !existingQwen || existingQwen.provider !== "qwen-portal" || !isExternalProfileFresh(existingQwen, now) ? readQwenCliCredentialsCached({ ttlMs: EXTERNAL_CLI_SYNC_TTL_MS }) : null;
174
+ if (qwenCreds) {
175
+ const existing = store.profiles[QWEN_CLI_PROFILE_ID];
176
+ const existingOAuth = existing?.type === "oauth" ? existing : void 0;
177
+ if ((!existingOAuth || existingOAuth.provider !== "qwen-portal" || existingOAuth.expires <= now || qwenCreds.expires > existingOAuth.expires) && !shallowEqualOAuthCredentials(existingOAuth, qwenCreds)) {
178
+ store.profiles[QWEN_CLI_PROFILE_ID] = qwenCreds;
179
+ mutated = true;
180
+ log$1.info("synced qwen credentials from qwen cli", {
181
+ profileId: QWEN_CLI_PROFILE_ID,
182
+ expires: new Date(qwenCreds.expires).toISOString()
183
+ });
184
+ }
185
+ }
186
+ if (syncExternalCliCredentialsForProvider(store, MINIMAX_CLI_PROFILE_ID, "minimax-portal", () => readMiniMaxCliCredentialsCached({ ttlMs: EXTERNAL_CLI_SYNC_TTL_MS }), now)) mutated = true;
187
+ return mutated;
188
+ }
189
+
190
+ //#endregion
191
+ //#region src/agents/agent-paths.ts
192
+ function resolveSynurexAgentDir() {
193
+ const override = process.env.SYNUREX_AGENT_DIR?.trim() || process.env.PI_CODING_AGENT_DIR?.trim();
194
+ if (override) return resolveUserPath(override);
195
+ return resolveUserPath(path.join(resolveStateDir(), "agents", DEFAULT_AGENT_ID, "agent"));
196
+ }
197
+
198
+ //#endregion
199
+ //#region src/agents/auth-profiles/paths.ts
200
+ function resolveAuthStorePath(agentDir) {
201
+ const resolved = resolveUserPath(agentDir ?? resolveSynurexAgentDir());
202
+ return path.join(resolved, AUTH_PROFILE_FILENAME);
203
+ }
204
+ function resolveLegacyAuthStorePath(agentDir) {
205
+ const resolved = resolveUserPath(agentDir ?? resolveSynurexAgentDir());
206
+ return path.join(resolved, LEGACY_AUTH_FILENAME);
207
+ }
208
+ function resolveAuthStorePathForDisplay(agentDir) {
209
+ const pathname = resolveAuthStorePath(agentDir);
210
+ return pathname.startsWith("~") ? pathname : resolveUserPath(pathname);
211
+ }
212
+ function ensureAuthStoreFile(pathname) {
213
+ if (fs.existsSync(pathname)) return;
214
+ saveJsonFile(pathname, {
215
+ version: AUTH_STORE_VERSION,
216
+ profiles: {}
217
+ });
218
+ }
219
+
220
+ //#endregion
221
+ //#region src/agents/auth-profiles/store.ts
222
+ async function updateAuthProfileStoreWithLock(params) {
223
+ const authPath = resolveAuthStorePath(params.agentDir);
224
+ ensureAuthStoreFile(authPath);
225
+ let release;
226
+ try {
227
+ release = await lockfile.lock(authPath, AUTH_STORE_LOCK_OPTIONS);
228
+ const store = ensureAuthProfileStore(params.agentDir);
229
+ if (params.updater(store)) saveAuthProfileStore(store, params.agentDir);
230
+ return store;
231
+ } catch {
232
+ return null;
233
+ } finally {
234
+ if (release) try {
235
+ await release();
236
+ } catch {}
237
+ }
238
+ }
239
+ function coerceLegacyStore(raw) {
240
+ if (!raw || typeof raw !== "object") return null;
241
+ const record = raw;
242
+ if ("profiles" in record) return null;
243
+ const entries = {};
244
+ for (const [key, value] of Object.entries(record)) {
245
+ if (!value || typeof value !== "object") continue;
246
+ const typed = value;
247
+ if (typed.type !== "api_key" && typed.type !== "oauth" && typed.type !== "token") continue;
248
+ entries[key] = {
249
+ ...typed,
250
+ provider: String(typed.provider ?? key)
251
+ };
252
+ }
253
+ return Object.keys(entries).length > 0 ? entries : null;
254
+ }
255
+ function coerceAuthStore(raw) {
256
+ if (!raw || typeof raw !== "object") return null;
257
+ const record = raw;
258
+ if (!record.profiles || typeof record.profiles !== "object") return null;
259
+ const profiles = record.profiles;
260
+ const normalized = {};
261
+ for (const [key, value] of Object.entries(profiles)) {
262
+ if (!value || typeof value !== "object") continue;
263
+ const typed = value;
264
+ if (typed.type !== "api_key" && typed.type !== "oauth" && typed.type !== "token") continue;
265
+ if (!typed.provider) continue;
266
+ normalized[key] = typed;
267
+ }
268
+ const order = record.order && typeof record.order === "object" ? Object.entries(record.order).reduce((acc, [provider, value]) => {
269
+ if (!Array.isArray(value)) return acc;
270
+ const list = value.map((entry) => typeof entry === "string" ? entry.trim() : "").filter(Boolean);
271
+ if (list.length === 0) return acc;
272
+ acc[provider] = list;
273
+ return acc;
274
+ }, {}) : void 0;
275
+ return {
276
+ version: Number(record.version ?? AUTH_STORE_VERSION),
277
+ profiles: normalized,
278
+ order,
279
+ lastGood: record.lastGood && typeof record.lastGood === "object" ? record.lastGood : void 0,
280
+ usageStats: record.usageStats && typeof record.usageStats === "object" ? record.usageStats : void 0
281
+ };
282
+ }
283
+ function mergeRecord(base, override) {
284
+ if (!base && !override) return;
285
+ if (!base) return { ...override };
286
+ if (!override) return { ...base };
287
+ return {
288
+ ...base,
289
+ ...override
290
+ };
291
+ }
292
+ function mergeAuthProfileStores(base, override) {
293
+ if (Object.keys(override.profiles).length === 0 && !override.order && !override.lastGood && !override.usageStats) return base;
294
+ return {
295
+ version: Math.max(base.version, override.version ?? base.version),
296
+ profiles: {
297
+ ...base.profiles,
298
+ ...override.profiles
299
+ },
300
+ order: mergeRecord(base.order, override.order),
301
+ lastGood: mergeRecord(base.lastGood, override.lastGood),
302
+ usageStats: mergeRecord(base.usageStats, override.usageStats)
303
+ };
304
+ }
305
+ function mergeOAuthFileIntoStore(store) {
306
+ const oauthRaw = loadJsonFile(resolveOAuthPath());
307
+ if (!oauthRaw || typeof oauthRaw !== "object") return false;
308
+ const oauthEntries = oauthRaw;
309
+ let mutated = false;
310
+ for (const [provider, creds] of Object.entries(oauthEntries)) {
311
+ if (!creds || typeof creds !== "object") continue;
312
+ const profileId = `${provider}:default`;
313
+ if (store.profiles[profileId]) continue;
314
+ store.profiles[profileId] = {
315
+ type: "oauth",
316
+ provider,
317
+ ...creds
318
+ };
319
+ mutated = true;
320
+ }
321
+ return mutated;
322
+ }
323
+ function loadAuthProfileStore() {
324
+ const authPath = resolveAuthStorePath();
325
+ const asStore = coerceAuthStore(loadJsonFile(authPath));
326
+ if (asStore) {
327
+ if (syncExternalCliCredentials(asStore)) saveJsonFile(authPath, asStore);
328
+ return asStore;
329
+ }
330
+ const legacy = coerceLegacyStore(loadJsonFile(resolveLegacyAuthStorePath()));
331
+ if (legacy) {
332
+ const store = {
333
+ version: AUTH_STORE_VERSION,
334
+ profiles: {}
335
+ };
336
+ for (const [provider, cred] of Object.entries(legacy)) {
337
+ const profileId = `${provider}:default`;
338
+ if (cred.type === "api_key") store.profiles[profileId] = {
339
+ type: "api_key",
340
+ provider: String(cred.provider ?? provider),
341
+ key: cred.key,
342
+ ...cred.email ? { email: cred.email } : {}
343
+ };
344
+ else if (cred.type === "token") store.profiles[profileId] = {
345
+ type: "token",
346
+ provider: String(cred.provider ?? provider),
347
+ token: cred.token,
348
+ ...typeof cred.expires === "number" ? { expires: cred.expires } : {},
349
+ ...cred.email ? { email: cred.email } : {}
350
+ };
351
+ else store.profiles[profileId] = {
352
+ type: "oauth",
353
+ provider: String(cred.provider ?? provider),
354
+ access: cred.access,
355
+ refresh: cred.refresh,
356
+ expires: cred.expires,
357
+ ...cred.enterpriseUrl ? { enterpriseUrl: cred.enterpriseUrl } : {},
358
+ ...cred.projectId ? { projectId: cred.projectId } : {},
359
+ ...cred.accountId ? { accountId: cred.accountId } : {},
360
+ ...cred.email ? { email: cred.email } : {}
361
+ };
362
+ }
363
+ syncExternalCliCredentials(store);
364
+ return store;
365
+ }
366
+ const store = {
367
+ version: AUTH_STORE_VERSION,
368
+ profiles: {}
369
+ };
370
+ syncExternalCliCredentials(store);
371
+ return store;
372
+ }
373
+ function loadAuthProfileStoreForAgent(agentDir, _options) {
374
+ const authPath = resolveAuthStorePath(agentDir);
375
+ const asStore = coerceAuthStore(loadJsonFile(authPath));
376
+ if (asStore) {
377
+ if (syncExternalCliCredentials(asStore)) saveJsonFile(authPath, asStore);
378
+ return asStore;
379
+ }
380
+ if (agentDir) {
381
+ const mainStore = coerceAuthStore(loadJsonFile(resolveAuthStorePath()));
382
+ if (mainStore && Object.keys(mainStore.profiles).length > 0) {
383
+ saveJsonFile(authPath, mainStore);
384
+ log$1.info("inherited auth-profiles from main agent", { agentDir });
385
+ return mainStore;
386
+ }
387
+ }
388
+ const legacy = coerceLegacyStore(loadJsonFile(resolveLegacyAuthStorePath(agentDir)));
389
+ const store = {
390
+ version: AUTH_STORE_VERSION,
391
+ profiles: {}
392
+ };
393
+ if (legacy) for (const [provider, cred] of Object.entries(legacy)) {
394
+ const profileId = `${provider}:default`;
395
+ if (cred.type === "api_key") store.profiles[profileId] = {
396
+ type: "api_key",
397
+ provider: String(cred.provider ?? provider),
398
+ key: cred.key,
399
+ ...cred.email ? { email: cred.email } : {}
400
+ };
401
+ else if (cred.type === "token") store.profiles[profileId] = {
402
+ type: "token",
403
+ provider: String(cred.provider ?? provider),
404
+ token: cred.token,
405
+ ...typeof cred.expires === "number" ? { expires: cred.expires } : {},
406
+ ...cred.email ? { email: cred.email } : {}
407
+ };
408
+ else store.profiles[profileId] = {
409
+ type: "oauth",
410
+ provider: String(cred.provider ?? provider),
411
+ access: cred.access,
412
+ refresh: cred.refresh,
413
+ expires: cred.expires,
414
+ ...cred.enterpriseUrl ? { enterpriseUrl: cred.enterpriseUrl } : {},
415
+ ...cred.projectId ? { projectId: cred.projectId } : {},
416
+ ...cred.accountId ? { accountId: cred.accountId } : {},
417
+ ...cred.email ? { email: cred.email } : {}
418
+ };
419
+ }
420
+ const mergedOAuth = mergeOAuthFileIntoStore(store);
421
+ const syncedCli = syncExternalCliCredentials(store);
422
+ const shouldWrite = legacy !== null || mergedOAuth || syncedCli;
423
+ if (shouldWrite) saveJsonFile(authPath, store);
424
+ if (shouldWrite && legacy !== null) {
425
+ const legacyPath = resolveLegacyAuthStorePath(agentDir);
426
+ try {
427
+ fs.unlinkSync(legacyPath);
428
+ } catch (err) {
429
+ if (err?.code !== "ENOENT") log$1.warn("failed to delete legacy auth.json after migration", {
430
+ err,
431
+ legacyPath
432
+ });
433
+ }
434
+ }
435
+ return store;
436
+ }
437
+ function ensureAuthProfileStore(agentDir, options) {
438
+ const store = loadAuthProfileStoreForAgent(agentDir, options);
439
+ const authPath = resolveAuthStorePath(agentDir);
440
+ const mainAuthPath = resolveAuthStorePath();
441
+ if (!agentDir || authPath === mainAuthPath) return store;
442
+ return mergeAuthProfileStores(loadAuthProfileStoreForAgent(void 0, options), store);
443
+ }
444
+ function saveAuthProfileStore(store, agentDir) {
445
+ saveJsonFile(resolveAuthStorePath(agentDir), {
446
+ version: AUTH_STORE_VERSION,
447
+ profiles: store.profiles,
448
+ order: store.order ?? void 0,
449
+ lastGood: store.lastGood ?? void 0,
450
+ usageStats: store.usageStats ?? void 0
451
+ });
452
+ }
453
+
454
+ //#endregion
455
+ //#region src/agents/auth-profiles/profiles.ts
456
+ async function setAuthProfileOrder(params) {
457
+ const providerKey = normalizeProviderId(params.provider);
458
+ const sanitized = params.order && Array.isArray(params.order) ? params.order.map((entry) => String(entry).trim()).filter(Boolean) : [];
459
+ const deduped = [];
460
+ for (const entry of sanitized) if (!deduped.includes(entry)) deduped.push(entry);
461
+ return await updateAuthProfileStoreWithLock({
462
+ agentDir: params.agentDir,
463
+ updater: (store) => {
464
+ store.order = store.order ?? {};
465
+ if (deduped.length === 0) {
466
+ if (!store.order[providerKey]) return false;
467
+ delete store.order[providerKey];
468
+ if (Object.keys(store.order).length === 0) store.order = void 0;
469
+ return true;
470
+ }
471
+ store.order[providerKey] = deduped;
472
+ return true;
473
+ }
474
+ });
475
+ }
476
+ function upsertAuthProfile(params) {
477
+ const store = ensureAuthProfileStore(params.agentDir);
478
+ store.profiles[params.profileId] = params.credential;
479
+ saveAuthProfileStore(store, params.agentDir);
480
+ }
481
+ function listProfilesForProvider(store, provider) {
482
+ const providerKey = normalizeProviderId(provider);
483
+ return Object.entries(store.profiles).filter(([, cred]) => normalizeProviderId(cred.provider) === providerKey).map(([id]) => id);
484
+ }
485
+ async function markAuthProfileGood(params) {
486
+ const { store, provider, profileId, agentDir } = params;
487
+ const updated = await updateAuthProfileStoreWithLock({
488
+ agentDir,
489
+ updater: (freshStore) => {
490
+ const profile = freshStore.profiles[profileId];
491
+ if (!profile || profile.provider !== provider) return false;
492
+ freshStore.lastGood = {
493
+ ...freshStore.lastGood,
494
+ [provider]: profileId
495
+ };
496
+ return true;
497
+ }
498
+ });
499
+ if (updated) {
500
+ store.lastGood = updated.lastGood;
501
+ return;
502
+ }
503
+ const profile = store.profiles[profileId];
504
+ if (!profile || profile.provider !== provider) return;
505
+ store.lastGood = {
506
+ ...store.lastGood,
507
+ [provider]: profileId
508
+ };
509
+ saveAuthProfileStore(store, agentDir);
510
+ }
511
+
512
+ //#endregion
513
+ //#region src/agents/auth-profiles/repair.ts
514
+ function getProfileSuffix(profileId) {
515
+ const idx = profileId.indexOf(":");
516
+ if (idx < 0) return "";
517
+ return profileId.slice(idx + 1);
518
+ }
519
+ function isEmailLike(value) {
520
+ const trimmed = value.trim();
521
+ if (!trimmed) return false;
522
+ return trimmed.includes("@") && trimmed.includes(".");
523
+ }
524
+ function suggestOAuthProfileIdForLegacyDefault(params) {
525
+ const providerKey = normalizeProviderId(params.provider);
526
+ if (getProfileSuffix(params.legacyProfileId) !== "default") return null;
527
+ const legacyCfg = params.cfg?.auth?.profiles?.[params.legacyProfileId];
528
+ if (legacyCfg && normalizeProviderId(legacyCfg.provider) === providerKey && legacyCfg.mode !== "oauth") return null;
529
+ const oauthProfiles = listProfilesForProvider(params.store, providerKey).filter((id) => params.store.profiles[id]?.type === "oauth");
530
+ if (oauthProfiles.length === 0) return null;
531
+ const configuredEmail = legacyCfg?.email?.trim();
532
+ if (configuredEmail) {
533
+ const byEmail = oauthProfiles.find((id) => {
534
+ const cred = params.store.profiles[id];
535
+ if (!cred || cred.type !== "oauth") return false;
536
+ return cred.email?.trim() === configuredEmail || id === `${providerKey}:${configuredEmail}`;
537
+ });
538
+ if (byEmail) return byEmail;
539
+ }
540
+ const lastGood = params.store.lastGood?.[providerKey] ?? params.store.lastGood?.[params.provider];
541
+ if (lastGood && oauthProfiles.includes(lastGood)) return lastGood;
542
+ const nonLegacy = oauthProfiles.filter((id) => id !== params.legacyProfileId);
543
+ if (nonLegacy.length === 1) return nonLegacy[0] ?? null;
544
+ const emailLike = nonLegacy.filter((id) => isEmailLike(getProfileSuffix(id)));
545
+ if (emailLike.length === 1) return emailLike[0] ?? null;
546
+ return null;
547
+ }
548
+ function repairOAuthProfileIdMismatch(params) {
549
+ const legacyProfileId = params.legacyProfileId ?? `${normalizeProviderId(params.provider)}:default`;
550
+ const legacyCfg = params.cfg.auth?.profiles?.[legacyProfileId];
551
+ if (!legacyCfg) return {
552
+ config: params.cfg,
553
+ changes: [],
554
+ migrated: false
555
+ };
556
+ if (legacyCfg.mode !== "oauth") return {
557
+ config: params.cfg,
558
+ changes: [],
559
+ migrated: false
560
+ };
561
+ if (normalizeProviderId(legacyCfg.provider) !== normalizeProviderId(params.provider)) return {
562
+ config: params.cfg,
563
+ changes: [],
564
+ migrated: false
565
+ };
566
+ const toProfileId = suggestOAuthProfileIdForLegacyDefault({
567
+ cfg: params.cfg,
568
+ store: params.store,
569
+ provider: params.provider,
570
+ legacyProfileId
571
+ });
572
+ if (!toProfileId || toProfileId === legacyProfileId) return {
573
+ config: params.cfg,
574
+ changes: [],
575
+ migrated: false
576
+ };
577
+ const toCred = params.store.profiles[toProfileId];
578
+ const toEmail = toCred?.type === "oauth" ? toCred.email?.trim() : void 0;
579
+ const nextProfiles = { ...params.cfg.auth?.profiles };
580
+ delete nextProfiles[legacyProfileId];
581
+ nextProfiles[toProfileId] = {
582
+ ...legacyCfg,
583
+ ...toEmail ? { email: toEmail } : {}
584
+ };
585
+ const providerKey = normalizeProviderId(params.provider);
586
+ const nextOrder = (() => {
587
+ const order = params.cfg.auth?.order;
588
+ if (!order) return;
589
+ const resolvedKey = Object.keys(order).find((key) => normalizeProviderId(key) === providerKey);
590
+ if (!resolvedKey) return order;
591
+ const existing = order[resolvedKey];
592
+ if (!Array.isArray(existing)) return order;
593
+ const replaced = existing.map((id) => id === legacyProfileId ? toProfileId : id).filter((id) => typeof id === "string" && id.trim().length > 0);
594
+ const deduped = [];
595
+ for (const entry of replaced) if (!deduped.includes(entry)) deduped.push(entry);
596
+ return {
597
+ ...order,
598
+ [resolvedKey]: deduped
599
+ };
600
+ })();
601
+ return {
602
+ config: {
603
+ ...params.cfg,
604
+ auth: {
605
+ ...params.cfg.auth,
606
+ profiles: nextProfiles,
607
+ ...nextOrder ? { order: nextOrder } : {}
608
+ }
609
+ },
610
+ changes: [`Auth: migrate ${legacyProfileId} → ${toProfileId} (OAuth profile id)`],
611
+ migrated: true,
612
+ fromProfileId: legacyProfileId,
613
+ toProfileId
614
+ };
615
+ }
616
+
617
+ //#endregion
618
+ //#region src/agents/auth-profiles/doctor.ts
619
+ function formatAuthDoctorHint(params) {
620
+ const providerKey = normalizeProviderId(params.provider);
621
+ if (providerKey !== "anthropic") return "";
622
+ const legacyProfileId = params.profileId ?? "anthropic:default";
623
+ const suggested = suggestOAuthProfileIdForLegacyDefault({
624
+ cfg: params.cfg,
625
+ store: params.store,
626
+ provider: providerKey,
627
+ legacyProfileId
628
+ });
629
+ if (!suggested || suggested === legacyProfileId) return "";
630
+ const storeOauthProfiles = listProfilesForProvider(params.store, providerKey).filter((id) => params.store.profiles[id]?.type === "oauth").join(", ");
631
+ const cfgMode = params.cfg?.auth?.profiles?.[legacyProfileId]?.mode;
632
+ const cfgProvider = params.cfg?.auth?.profiles?.[legacyProfileId]?.provider;
633
+ return [
634
+ "Doctor hint (for GitHub issue):",
635
+ `- provider: ${providerKey}`,
636
+ `- config: ${legacyProfileId}${cfgProvider || cfgMode ? ` (provider=${cfgProvider ?? "?"}, mode=${cfgMode ?? "?"})` : ""}`,
637
+ `- auth store oauth profiles: ${storeOauthProfiles || "(none)"}`,
638
+ `- suggested profile: ${suggested}`,
639
+ `Fix: run "${formatCliCommand("synurex doctor --yes")}"`
640
+ ].join("\n");
641
+ }
642
+
643
+ //#endregion
644
+ //#region src/providers/qwen-portal-oauth.ts
645
+ const QWEN_OAUTH_TOKEN_ENDPOINT = `https://chat.qwen.ai/api/v1/oauth2/token`;
646
+ const QWEN_OAUTH_CLIENT_ID = "f0304373b74a44d2b584a3fb70ca9e56";
647
+ async function refreshQwenPortalCredentials(credentials) {
648
+ if (!credentials.refresh?.trim()) throw new Error("Qwen OAuth refresh token missing; re-authenticate.");
649
+ const response = await fetch(QWEN_OAUTH_TOKEN_ENDPOINT, {
650
+ method: "POST",
651
+ headers: {
652
+ "Content-Type": "application/x-www-form-urlencoded",
653
+ Accept: "application/json"
654
+ },
655
+ body: new URLSearchParams({
656
+ grant_type: "refresh_token",
657
+ refresh_token: credentials.refresh,
658
+ client_id: QWEN_OAUTH_CLIENT_ID
659
+ })
660
+ });
661
+ if (!response.ok) {
662
+ const text = await response.text();
663
+ if (response.status === 400) throw new Error(`Qwen OAuth refresh token expired or invalid. Re-authenticate with \`${formatCliCommand("synurex models auth login --provider qwen-portal")}\`.`);
664
+ throw new Error(`Qwen OAuth refresh failed: ${text || response.statusText}`);
665
+ }
666
+ const payload = await response.json();
667
+ if (!payload.access_token || !payload.expires_in) throw new Error("Qwen OAuth refresh response missing access token.");
668
+ return {
669
+ ...credentials,
670
+ access: payload.access_token,
671
+ refresh: payload.refresh_token || credentials.refresh,
672
+ expires: Date.now() + payload.expires_in * 1e3
673
+ };
674
+ }
675
+
676
+ //#endregion
677
+ //#region src/agents/chutes-oauth.ts
678
+ const CHUTES_OAUTH_ISSUER = "https://api.chutes.ai";
679
+ const CHUTES_AUTHORIZE_ENDPOINT = `${CHUTES_OAUTH_ISSUER}/idp/authorize`;
680
+ const CHUTES_TOKEN_ENDPOINT = `${CHUTES_OAUTH_ISSUER}/idp/token`;
681
+ const CHUTES_USERINFO_ENDPOINT = `${CHUTES_OAUTH_ISSUER}/idp/userinfo`;
682
+ const DEFAULT_EXPIRES_BUFFER_MS = 300 * 1e3;
683
+ function generateChutesPkce() {
684
+ const verifier = randomBytes(32).toString("hex");
685
+ return {
686
+ verifier,
687
+ challenge: createHash("sha256").update(verifier).digest("base64url")
688
+ };
689
+ }
690
+ function parseOAuthCallbackInput(input, expectedState) {
691
+ const trimmed = input.trim();
692
+ if (!trimmed) return { error: "No input provided" };
693
+ try {
694
+ const url = new URL(trimmed);
695
+ const code = url.searchParams.get("code");
696
+ const state = url.searchParams.get("state");
697
+ if (!code) return { error: "Missing 'code' parameter in URL" };
698
+ if (!state) return { error: "Missing 'state' parameter. Paste the full URL." };
699
+ return {
700
+ code,
701
+ state
702
+ };
703
+ } catch {
704
+ if (!expectedState) return { error: "Paste the full redirect URL, not just the code." };
705
+ return {
706
+ code: trimmed,
707
+ state: expectedState
708
+ };
709
+ }
710
+ }
711
+ function coerceExpiresAt(expiresInSeconds, now) {
712
+ const value = now + Math.max(0, Math.floor(expiresInSeconds)) * 1e3 - DEFAULT_EXPIRES_BUFFER_MS;
713
+ return Math.max(value, now + 3e4);
714
+ }
715
+ async function fetchChutesUserInfo(params) {
716
+ const response = await (params.fetchFn ?? fetch)(CHUTES_USERINFO_ENDPOINT, { headers: { Authorization: `Bearer ${params.accessToken}` } });
717
+ if (!response.ok) return null;
718
+ const data = await response.json();
719
+ if (!data || typeof data !== "object") return null;
720
+ return data;
721
+ }
722
+ async function exchangeChutesCodeForTokens(params) {
723
+ const fetchFn = params.fetchFn ?? fetch;
724
+ const now = params.now ?? Date.now();
725
+ const body = new URLSearchParams({
726
+ grant_type: "authorization_code",
727
+ client_id: params.app.clientId,
728
+ code: params.code,
729
+ redirect_uri: params.app.redirectUri,
730
+ code_verifier: params.codeVerifier
731
+ });
732
+ if (params.app.clientSecret) body.set("client_secret", params.app.clientSecret);
733
+ const response = await fetchFn(CHUTES_TOKEN_ENDPOINT, {
734
+ method: "POST",
735
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
736
+ body
737
+ });
738
+ if (!response.ok) {
739
+ const text = await response.text();
740
+ throw new Error(`Chutes token exchange failed: ${text}`);
741
+ }
742
+ const data = await response.json();
743
+ const access = data.access_token?.trim();
744
+ const refresh = data.refresh_token?.trim();
745
+ const expiresIn = data.expires_in ?? 0;
746
+ if (!access) throw new Error("Chutes token exchange returned no access_token");
747
+ if (!refresh) throw new Error("Chutes token exchange returned no refresh_token");
748
+ const info = await fetchChutesUserInfo({
749
+ accessToken: access,
750
+ fetchFn
751
+ });
752
+ return {
753
+ access,
754
+ refresh,
755
+ expires: coerceExpiresAt(expiresIn, now),
756
+ email: info?.username,
757
+ accountId: info?.sub,
758
+ clientId: params.app.clientId
759
+ };
760
+ }
761
+ async function refreshChutesTokens(params) {
762
+ const fetchFn = params.fetchFn ?? fetch;
763
+ const now = params.now ?? Date.now();
764
+ const refreshToken = params.credential.refresh?.trim();
765
+ if (!refreshToken) throw new Error("Chutes OAuth credential is missing refresh token");
766
+ const clientId = params.credential.clientId?.trim() ?? process.env.CHUTES_CLIENT_ID?.trim();
767
+ if (!clientId) throw new Error("Missing CHUTES_CLIENT_ID for Chutes OAuth refresh (set env var or re-auth).");
768
+ const clientSecret = process.env.CHUTES_CLIENT_SECRET?.trim() || void 0;
769
+ const body = new URLSearchParams({
770
+ grant_type: "refresh_token",
771
+ client_id: clientId,
772
+ refresh_token: refreshToken
773
+ });
774
+ if (clientSecret) body.set("client_secret", clientSecret);
775
+ const response = await fetchFn(CHUTES_TOKEN_ENDPOINT, {
776
+ method: "POST",
777
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
778
+ body
779
+ });
780
+ if (!response.ok) {
781
+ const text = await response.text();
782
+ throw new Error(`Chutes token refresh failed: ${text}`);
783
+ }
784
+ const data = await response.json();
785
+ const access = data.access_token?.trim();
786
+ const newRefresh = data.refresh_token?.trim();
787
+ const expiresIn = data.expires_in ?? 0;
788
+ if (!access) throw new Error("Chutes token refresh returned no access_token");
789
+ return {
790
+ ...params.credential,
791
+ access,
792
+ refresh: newRefresh || refreshToken,
793
+ expires: coerceExpiresAt(expiresIn, now),
794
+ clientId
795
+ };
796
+ }
797
+
798
+ //#endregion
799
+ //#region src/agents/auth-profiles/oauth.ts
800
+ const OAUTH_PROVIDER_IDS = new Set(getOAuthProviders().map((provider) => provider.id));
801
+ const isOAuthProvider = (provider) => OAUTH_PROVIDER_IDS.has(provider);
802
+ const resolveOAuthProvider = (provider) => isOAuthProvider(provider) ? provider : null;
803
+ function buildOAuthApiKey(provider, credentials) {
804
+ return provider === "google-gemini-cli" || provider === "google-antigravity" ? JSON.stringify({
805
+ token: credentials.access,
806
+ projectId: credentials.projectId
807
+ }) : credentials.access;
808
+ }
809
+ async function refreshOAuthTokenWithLock(params) {
810
+ const authPath = resolveAuthStorePath(params.agentDir);
811
+ ensureAuthStoreFile(authPath);
812
+ let release;
813
+ try {
814
+ release = await lockfile.lock(authPath, { ...AUTH_STORE_LOCK_OPTIONS });
815
+ const store = ensureAuthProfileStore(params.agentDir);
816
+ const cred = store.profiles[params.profileId];
817
+ if (!cred || cred.type !== "oauth") return null;
818
+ if (Date.now() < cred.expires) return {
819
+ apiKey: buildOAuthApiKey(cred.provider, cred),
820
+ newCredentials: cred
821
+ };
822
+ const oauthCreds = { [cred.provider]: cred };
823
+ const result = String(cred.provider) === "chutes" ? await (async () => {
824
+ const newCredentials = await refreshChutesTokens({ credential: cred });
825
+ return {
826
+ apiKey: newCredentials.access,
827
+ newCredentials
828
+ };
829
+ })() : String(cred.provider) === "qwen-portal" ? await (async () => {
830
+ const newCredentials = await refreshQwenPortalCredentials(cred);
831
+ return {
832
+ apiKey: newCredentials.access,
833
+ newCredentials
834
+ };
835
+ })() : await (async () => {
836
+ const oauthProvider = resolveOAuthProvider(cred.provider);
837
+ if (!oauthProvider) return null;
838
+ return await getOAuthApiKey(oauthProvider, oauthCreds);
839
+ })();
840
+ if (!result) return null;
841
+ store.profiles[params.profileId] = {
842
+ ...cred,
843
+ ...result.newCredentials,
844
+ type: "oauth"
845
+ };
846
+ saveAuthProfileStore(store, params.agentDir);
847
+ return result;
848
+ } finally {
849
+ if (release) try {
850
+ await release();
851
+ } catch {}
852
+ }
853
+ }
854
+ async function tryResolveOAuthProfile(params) {
855
+ const { cfg, store, profileId } = params;
856
+ const cred = store.profiles[profileId];
857
+ if (!cred || cred.type !== "oauth") return null;
858
+ const profileConfig = cfg?.auth?.profiles?.[profileId];
859
+ if (profileConfig && profileConfig.provider !== cred.provider) return null;
860
+ if (profileConfig && profileConfig.mode !== cred.type) return null;
861
+ if (Date.now() < cred.expires) return {
862
+ apiKey: buildOAuthApiKey(cred.provider, cred),
863
+ provider: cred.provider,
864
+ email: cred.email
865
+ };
866
+ const refreshed = await refreshOAuthTokenWithLock({
867
+ profileId,
868
+ agentDir: params.agentDir
869
+ });
870
+ if (!refreshed) return null;
871
+ return {
872
+ apiKey: refreshed.apiKey,
873
+ provider: cred.provider,
874
+ email: cred.email
875
+ };
876
+ }
877
+ async function resolveApiKeyForProfile(params) {
878
+ const { cfg, store, profileId } = params;
879
+ const cred = store.profiles[profileId];
880
+ if (!cred) return null;
881
+ const profileConfig = cfg?.auth?.profiles?.[profileId];
882
+ if (profileConfig && profileConfig.provider !== cred.provider) return null;
883
+ if (profileConfig && profileConfig.mode !== cred.type) {
884
+ if (!(profileConfig.mode === "oauth" && cred.type === "token")) return null;
885
+ }
886
+ if (cred.type === "api_key") {
887
+ const key = cred.key?.trim();
888
+ if (!key) return null;
889
+ return {
890
+ apiKey: key,
891
+ provider: cred.provider,
892
+ email: cred.email
893
+ };
894
+ }
895
+ if (cred.type === "token") {
896
+ const token = cred.token?.trim();
897
+ if (!token) return null;
898
+ if (typeof cred.expires === "number" && Number.isFinite(cred.expires) && cred.expires > 0 && Date.now() >= cred.expires) return null;
899
+ return {
900
+ apiKey: token,
901
+ provider: cred.provider,
902
+ email: cred.email
903
+ };
904
+ }
905
+ if (Date.now() < cred.expires) return {
906
+ apiKey: buildOAuthApiKey(cred.provider, cred),
907
+ provider: cred.provider,
908
+ email: cred.email
909
+ };
910
+ try {
911
+ const result = await refreshOAuthTokenWithLock({
912
+ profileId,
913
+ agentDir: params.agentDir
914
+ });
915
+ if (!result) return null;
916
+ return {
917
+ apiKey: result.apiKey,
918
+ provider: cred.provider,
919
+ email: cred.email
920
+ };
921
+ } catch (error) {
922
+ const refreshedStore = ensureAuthProfileStore(params.agentDir);
923
+ const refreshed = refreshedStore.profiles[profileId];
924
+ if (refreshed?.type === "oauth" && Date.now() < refreshed.expires) return {
925
+ apiKey: buildOAuthApiKey(refreshed.provider, refreshed),
926
+ provider: refreshed.provider,
927
+ email: refreshed.email ?? cred.email
928
+ };
929
+ const fallbackProfileId = suggestOAuthProfileIdForLegacyDefault({
930
+ cfg,
931
+ store: refreshedStore,
932
+ provider: cred.provider,
933
+ legacyProfileId: profileId
934
+ });
935
+ if (fallbackProfileId && fallbackProfileId !== profileId) try {
936
+ const fallbackResolved = await tryResolveOAuthProfile({
937
+ cfg,
938
+ store: refreshedStore,
939
+ profileId: fallbackProfileId,
940
+ agentDir: params.agentDir
941
+ });
942
+ if (fallbackResolved) return fallbackResolved;
943
+ } catch {}
944
+ if (params.agentDir) try {
945
+ const mainCred = ensureAuthProfileStore(void 0).profiles[profileId];
946
+ if (mainCred?.type === "oauth" && Date.now() < mainCred.expires) {
947
+ refreshedStore.profiles[profileId] = { ...mainCred };
948
+ saveAuthProfileStore(refreshedStore, params.agentDir);
949
+ log$1.info("inherited fresh OAuth credentials from main agent", {
950
+ profileId,
951
+ agentDir: params.agentDir,
952
+ expires: new Date(mainCred.expires).toISOString()
953
+ });
954
+ return {
955
+ apiKey: buildOAuthApiKey(mainCred.provider, mainCred),
956
+ provider: mainCred.provider,
957
+ email: mainCred.email
958
+ };
959
+ }
960
+ } catch {}
961
+ const message = error instanceof Error ? error.message : String(error);
962
+ const hint = formatAuthDoctorHint({
963
+ cfg,
964
+ store: refreshedStore,
965
+ provider: cred.provider,
966
+ profileId
967
+ });
968
+ throw new Error(`OAuth token refresh failed for ${cred.provider}: ${message}. Please try again or re-authenticate.` + (hint ? `\n\n${hint}` : ""), { cause: error });
969
+ }
970
+ }
971
+
972
+ //#endregion
973
+ //#region src/agents/auth-profiles/usage.ts
974
+ function resolveProfileUnusableUntil$1(stats) {
975
+ const values = [stats.cooldownUntil, stats.disabledUntil].filter((value) => typeof value === "number").filter((value) => Number.isFinite(value) && value > 0);
976
+ if (values.length === 0) return null;
977
+ return Math.max(...values);
978
+ }
979
+ /**
980
+ * Check if a profile is currently in cooldown (due to rate limiting or errors).
981
+ */
982
+ function isProfileInCooldown(store, profileId) {
983
+ const stats = store.usageStats?.[profileId];
984
+ if (!stats) return false;
985
+ const unusableUntil = resolveProfileUnusableUntil$1(stats);
986
+ return unusableUntil ? Date.now() < unusableUntil : false;
987
+ }
988
+ /**
989
+ * Mark a profile as successfully used. Resets error count and updates lastUsed.
990
+ * Uses store lock to avoid overwriting concurrent usage updates.
991
+ */
992
+ async function markAuthProfileUsed(params) {
993
+ const { store, profileId, agentDir } = params;
994
+ const updated = await updateAuthProfileStoreWithLock({
995
+ agentDir,
996
+ updater: (freshStore) => {
997
+ if (!freshStore.profiles[profileId]) return false;
998
+ freshStore.usageStats = freshStore.usageStats ?? {};
999
+ freshStore.usageStats[profileId] = {
1000
+ ...freshStore.usageStats[profileId],
1001
+ lastUsed: Date.now(),
1002
+ errorCount: 0,
1003
+ cooldownUntil: void 0,
1004
+ disabledUntil: void 0,
1005
+ disabledReason: void 0,
1006
+ failureCounts: void 0
1007
+ };
1008
+ return true;
1009
+ }
1010
+ });
1011
+ if (updated) {
1012
+ store.usageStats = updated.usageStats;
1013
+ return;
1014
+ }
1015
+ if (!store.profiles[profileId]) return;
1016
+ store.usageStats = store.usageStats ?? {};
1017
+ store.usageStats[profileId] = {
1018
+ ...store.usageStats[profileId],
1019
+ lastUsed: Date.now(),
1020
+ errorCount: 0,
1021
+ cooldownUntil: void 0,
1022
+ disabledUntil: void 0,
1023
+ disabledReason: void 0,
1024
+ failureCounts: void 0
1025
+ };
1026
+ saveAuthProfileStore(store, agentDir);
1027
+ }
1028
+ function calculateAuthProfileCooldownMs(errorCount) {
1029
+ const normalized = Math.max(1, errorCount);
1030
+ return Math.min(3600 * 1e3, 60 * 1e3 * 5 ** Math.min(normalized - 1, 3));
1031
+ }
1032
+ function resolveAuthCooldownConfig(params) {
1033
+ const defaults = {
1034
+ billingBackoffHours: 5,
1035
+ billingMaxHours: 24,
1036
+ failureWindowHours: 24
1037
+ };
1038
+ const resolveHours = (value, fallback) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
1039
+ const cooldowns = params.cfg?.auth?.cooldowns;
1040
+ const billingBackoffHours = resolveHours((() => {
1041
+ const map = cooldowns?.billingBackoffHoursByProvider;
1042
+ if (!map) return;
1043
+ for (const [key, value] of Object.entries(map)) if (normalizeProviderId(key) === params.providerId) return value;
1044
+ })() ?? cooldowns?.billingBackoffHours, defaults.billingBackoffHours);
1045
+ const billingMaxHours = resolveHours(cooldowns?.billingMaxHours, defaults.billingMaxHours);
1046
+ const failureWindowHours = resolveHours(cooldowns?.failureWindowHours, defaults.failureWindowHours);
1047
+ return {
1048
+ billingBackoffMs: billingBackoffHours * 60 * 60 * 1e3,
1049
+ billingMaxMs: billingMaxHours * 60 * 60 * 1e3,
1050
+ failureWindowMs: failureWindowHours * 60 * 60 * 1e3
1051
+ };
1052
+ }
1053
+ function calculateAuthProfileBillingDisableMsWithConfig(params) {
1054
+ const normalized = Math.max(1, params.errorCount);
1055
+ const baseMs = Math.max(6e4, params.baseMs);
1056
+ const maxMs = Math.max(baseMs, params.maxMs);
1057
+ const raw = baseMs * 2 ** Math.min(normalized - 1, 10);
1058
+ return Math.min(maxMs, raw);
1059
+ }
1060
+ function resolveProfileUnusableUntilForDisplay(store, profileId) {
1061
+ const stats = store.usageStats?.[profileId];
1062
+ if (!stats) return null;
1063
+ return resolveProfileUnusableUntil$1(stats);
1064
+ }
1065
+ function computeNextProfileUsageStats(params) {
1066
+ const windowMs = params.cfgResolved.failureWindowMs;
1067
+ const windowExpired = typeof params.existing.lastFailureAt === "number" && params.existing.lastFailureAt > 0 && params.now - params.existing.lastFailureAt > windowMs;
1068
+ const nextErrorCount = (windowExpired ? 0 : params.existing.errorCount ?? 0) + 1;
1069
+ const failureCounts = windowExpired ? {} : { ...params.existing.failureCounts };
1070
+ failureCounts[params.reason] = (failureCounts[params.reason] ?? 0) + 1;
1071
+ const updatedStats = {
1072
+ ...params.existing,
1073
+ errorCount: nextErrorCount,
1074
+ failureCounts,
1075
+ lastFailureAt: params.now
1076
+ };
1077
+ if (params.reason === "billing") {
1078
+ const backoffMs = calculateAuthProfileBillingDisableMsWithConfig({
1079
+ errorCount: failureCounts.billing ?? 1,
1080
+ baseMs: params.cfgResolved.billingBackoffMs,
1081
+ maxMs: params.cfgResolved.billingMaxMs
1082
+ });
1083
+ updatedStats.disabledUntil = params.now + backoffMs;
1084
+ updatedStats.disabledReason = "billing";
1085
+ } else {
1086
+ const backoffMs = calculateAuthProfileCooldownMs(nextErrorCount);
1087
+ updatedStats.cooldownUntil = params.now + backoffMs;
1088
+ }
1089
+ return updatedStats;
1090
+ }
1091
+ /**
1092
+ * Mark a profile as failed for a specific reason. Billing failures are treated
1093
+ * as "disabled" (longer backoff) vs the regular cooldown window.
1094
+ */
1095
+ async function markAuthProfileFailure(params) {
1096
+ const { store, profileId, reason, agentDir, cfg } = params;
1097
+ const updated = await updateAuthProfileStoreWithLock({
1098
+ agentDir,
1099
+ updater: (freshStore) => {
1100
+ const profile = freshStore.profiles[profileId];
1101
+ if (!profile) return false;
1102
+ freshStore.usageStats = freshStore.usageStats ?? {};
1103
+ const existing = freshStore.usageStats[profileId] ?? {};
1104
+ const now = Date.now();
1105
+ const cfgResolved = resolveAuthCooldownConfig({
1106
+ cfg,
1107
+ providerId: normalizeProviderId(profile.provider)
1108
+ });
1109
+ freshStore.usageStats[profileId] = computeNextProfileUsageStats({
1110
+ existing,
1111
+ now,
1112
+ reason,
1113
+ cfgResolved
1114
+ });
1115
+ return true;
1116
+ }
1117
+ });
1118
+ if (updated) {
1119
+ store.usageStats = updated.usageStats;
1120
+ return;
1121
+ }
1122
+ if (!store.profiles[profileId]) return;
1123
+ store.usageStats = store.usageStats ?? {};
1124
+ const existing = store.usageStats[profileId] ?? {};
1125
+ const now = Date.now();
1126
+ const cfgResolved = resolveAuthCooldownConfig({
1127
+ cfg,
1128
+ providerId: normalizeProviderId(store.profiles[profileId]?.provider ?? "")
1129
+ });
1130
+ store.usageStats[profileId] = computeNextProfileUsageStats({
1131
+ existing,
1132
+ now,
1133
+ reason,
1134
+ cfgResolved
1135
+ });
1136
+ saveAuthProfileStore(store, agentDir);
1137
+ }
1138
+
1139
+ //#endregion
1140
+ //#region src/agents/auth-profiles/order.ts
1141
+ function resolveProfileUnusableUntil(stats) {
1142
+ const values = [stats.cooldownUntil, stats.disabledUntil].filter((value) => typeof value === "number").filter((value) => Number.isFinite(value) && value > 0);
1143
+ if (values.length === 0) return null;
1144
+ return Math.max(...values);
1145
+ }
1146
+ function resolveAuthProfileOrder(params) {
1147
+ const { cfg, store, provider, preferredProfile } = params;
1148
+ const providerKey = normalizeProviderId(provider);
1149
+ const now = Date.now();
1150
+ const storedOrder = (() => {
1151
+ const order = store.order;
1152
+ if (!order) return;
1153
+ for (const [key, value] of Object.entries(order)) if (normalizeProviderId(key) === providerKey) return value;
1154
+ })();
1155
+ const configuredOrder = (() => {
1156
+ const order = cfg?.auth?.order;
1157
+ if (!order) return;
1158
+ for (const [key, value] of Object.entries(order)) if (normalizeProviderId(key) === providerKey) return value;
1159
+ })();
1160
+ const explicitOrder = storedOrder ?? configuredOrder;
1161
+ const explicitProfiles = cfg?.auth?.profiles ? Object.entries(cfg.auth.profiles).filter(([, profile]) => normalizeProviderId(profile.provider) === providerKey).map(([profileId]) => profileId) : [];
1162
+ const baseOrder = explicitOrder ?? (explicitProfiles.length > 0 ? explicitProfiles : listProfilesForProvider(store, providerKey));
1163
+ if (baseOrder.length === 0) return [];
1164
+ const filtered = baseOrder.filter((profileId) => {
1165
+ const cred = store.profiles[profileId];
1166
+ if (!cred) return false;
1167
+ if (normalizeProviderId(cred.provider) !== providerKey) return false;
1168
+ const profileConfig = cfg?.auth?.profiles?.[profileId];
1169
+ if (profileConfig) {
1170
+ if (normalizeProviderId(profileConfig.provider) !== providerKey) return false;
1171
+ if (profileConfig.mode !== cred.type) {
1172
+ if (!(profileConfig.mode === "oauth" && cred.type === "token")) return false;
1173
+ }
1174
+ }
1175
+ if (cred.type === "api_key") return Boolean(cred.key?.trim());
1176
+ if (cred.type === "token") {
1177
+ if (!cred.token?.trim()) return false;
1178
+ if (typeof cred.expires === "number" && Number.isFinite(cred.expires) && cred.expires > 0 && now >= cred.expires) return false;
1179
+ return true;
1180
+ }
1181
+ if (cred.type === "oauth") return Boolean(cred.access?.trim() || cred.refresh?.trim());
1182
+ return false;
1183
+ });
1184
+ const deduped = [];
1185
+ for (const entry of filtered) if (!deduped.includes(entry)) deduped.push(entry);
1186
+ if (explicitOrder && explicitOrder.length > 0) {
1187
+ const available = [];
1188
+ const inCooldown = [];
1189
+ for (const profileId of deduped) {
1190
+ const cooldownUntil = resolveProfileUnusableUntil(store.usageStats?.[profileId] ?? {}) ?? 0;
1191
+ if (typeof cooldownUntil === "number" && Number.isFinite(cooldownUntil) && cooldownUntil > 0 && now < cooldownUntil) inCooldown.push({
1192
+ profileId,
1193
+ cooldownUntil
1194
+ });
1195
+ else available.push(profileId);
1196
+ }
1197
+ const cooldownSorted = inCooldown.toSorted((a, b) => a.cooldownUntil - b.cooldownUntil).map((entry) => entry.profileId);
1198
+ const ordered = [...available, ...cooldownSorted];
1199
+ if (preferredProfile && ordered.includes(preferredProfile)) return [preferredProfile, ...ordered.filter((e) => e !== preferredProfile)];
1200
+ return ordered;
1201
+ }
1202
+ const sorted = orderProfilesByMode(deduped, store);
1203
+ if (preferredProfile && sorted.includes(preferredProfile)) return [preferredProfile, ...sorted.filter((e) => e !== preferredProfile)];
1204
+ return sorted;
1205
+ }
1206
+ function orderProfilesByMode(order, store) {
1207
+ const now = Date.now();
1208
+ const available = [];
1209
+ const inCooldown = [];
1210
+ for (const profileId of order) if (isProfileInCooldown(store, profileId)) inCooldown.push(profileId);
1211
+ else available.push(profileId);
1212
+ const sorted = available.map((profileId) => {
1213
+ const type = store.profiles[profileId]?.type;
1214
+ return {
1215
+ profileId,
1216
+ typeScore: type === "oauth" ? 0 : type === "token" ? 1 : type === "api_key" ? 2 : 3,
1217
+ lastUsed: store.usageStats?.[profileId]?.lastUsed ?? 0
1218
+ };
1219
+ }).toSorted((a, b) => {
1220
+ if (a.typeScore !== b.typeScore) return a.typeScore - b.typeScore;
1221
+ return a.lastUsed - b.lastUsed;
1222
+ }).map((entry) => entry.profileId);
1223
+ const cooldownSorted = inCooldown.map((profileId) => ({
1224
+ profileId,
1225
+ cooldownUntil: resolveProfileUnusableUntil(store.usageStats?.[profileId] ?? {}) ?? now
1226
+ })).toSorted((a, b) => a.cooldownUntil - b.cooldownUntil).map((entry) => entry.profileId);
1227
+ return [...sorted, ...cooldownSorted];
1228
+ }
1229
+
1230
+ //#endregion
1231
+ //#region src/agents/auth-profiles.ts
1232
+ var auth_profiles_exports = /* @__PURE__ */ __exportAll({ ensureAuthProfileStore: () => ensureAuthProfileStore });
1233
+
1234
+ //#endregion
1235
+ //#region src/agents/bedrock-discovery.ts
1236
+ const DEFAULT_REFRESH_INTERVAL_SECONDS = 3600;
1237
+ const DEFAULT_CONTEXT_WINDOW = 32e3;
1238
+ const DEFAULT_MAX_TOKENS = 4096;
1239
+ const DEFAULT_COST = {
1240
+ input: 0,
1241
+ output: 0,
1242
+ cacheRead: 0,
1243
+ cacheWrite: 0
1244
+ };
1245
+ const discoveryCache = /* @__PURE__ */ new Map();
1246
+ let hasLoggedBedrockError = false;
1247
+ function normalizeProviderFilter(filter) {
1248
+ if (!filter || filter.length === 0) return [];
1249
+ const normalized = new Set(filter.map((entry) => entry.trim().toLowerCase()).filter((entry) => entry.length > 0));
1250
+ return Array.from(normalized).toSorted();
1251
+ }
1252
+ function buildCacheKey(params) {
1253
+ return JSON.stringify(params);
1254
+ }
1255
+ function includesTextModalities(modalities) {
1256
+ return (modalities ?? []).some((entry) => entry.toLowerCase() === "text");
1257
+ }
1258
+ function isActive(summary) {
1259
+ const status = summary.modelLifecycle?.status;
1260
+ return typeof status === "string" ? status.toUpperCase() === "ACTIVE" : false;
1261
+ }
1262
+ function mapInputModalities(summary) {
1263
+ const inputs = summary.inputModalities ?? [];
1264
+ const mapped = /* @__PURE__ */ new Set();
1265
+ for (const modality of inputs) {
1266
+ const lower = modality.toLowerCase();
1267
+ if (lower === "text") mapped.add("text");
1268
+ if (lower === "image") mapped.add("image");
1269
+ }
1270
+ if (mapped.size === 0) mapped.add("text");
1271
+ return Array.from(mapped);
1272
+ }
1273
+ function inferReasoningSupport(summary) {
1274
+ const haystack = `${summary.modelId ?? ""} ${summary.modelName ?? ""}`.toLowerCase();
1275
+ return haystack.includes("reasoning") || haystack.includes("thinking");
1276
+ }
1277
+ function resolveDefaultContextWindow(config) {
1278
+ const value = Math.floor(config?.defaultContextWindow ?? DEFAULT_CONTEXT_WINDOW);
1279
+ return value > 0 ? value : DEFAULT_CONTEXT_WINDOW;
1280
+ }
1281
+ function resolveDefaultMaxTokens(config) {
1282
+ const value = Math.floor(config?.defaultMaxTokens ?? DEFAULT_MAX_TOKENS);
1283
+ return value > 0 ? value : DEFAULT_MAX_TOKENS;
1284
+ }
1285
+ function matchesProviderFilter(summary, filter) {
1286
+ if (filter.length === 0) return true;
1287
+ const normalized = (summary.providerName ?? (typeof summary.modelId === "string" ? summary.modelId.split(".")[0] : void 0))?.trim().toLowerCase();
1288
+ if (!normalized) return false;
1289
+ return filter.includes(normalized);
1290
+ }
1291
+ function shouldIncludeSummary(summary, filter) {
1292
+ if (!summary.modelId?.trim()) return false;
1293
+ if (!matchesProviderFilter(summary, filter)) return false;
1294
+ if (summary.responseStreamingSupported !== true) return false;
1295
+ if (!includesTextModalities(summary.outputModalities)) return false;
1296
+ if (!isActive(summary)) return false;
1297
+ return true;
1298
+ }
1299
+ function toModelDefinition(summary, defaults) {
1300
+ const id = summary.modelId?.trim() ?? "";
1301
+ return {
1302
+ id,
1303
+ name: summary.modelName?.trim() || id,
1304
+ reasoning: inferReasoningSupport(summary),
1305
+ input: mapInputModalities(summary),
1306
+ cost: DEFAULT_COST,
1307
+ contextWindow: defaults.contextWindow,
1308
+ maxTokens: defaults.maxTokens
1309
+ };
1310
+ }
1311
+ async function discoverBedrockModels(params) {
1312
+ const refreshIntervalSeconds = Math.max(0, Math.floor(params.config?.refreshInterval ?? DEFAULT_REFRESH_INTERVAL_SECONDS));
1313
+ const providerFilter = normalizeProviderFilter(params.config?.providerFilter);
1314
+ const defaultContextWindow = resolveDefaultContextWindow(params.config);
1315
+ const defaultMaxTokens = resolveDefaultMaxTokens(params.config);
1316
+ const cacheKey = buildCacheKey({
1317
+ region: params.region,
1318
+ providerFilter,
1319
+ refreshIntervalSeconds,
1320
+ defaultContextWindow,
1321
+ defaultMaxTokens
1322
+ });
1323
+ const now = params.now?.() ?? Date.now();
1324
+ if (refreshIntervalSeconds > 0) {
1325
+ const cached = discoveryCache.get(cacheKey);
1326
+ if (cached?.value && cached.expiresAt > now) return cached.value;
1327
+ if (cached?.inFlight) return cached.inFlight;
1328
+ }
1329
+ const client = (params.clientFactory ?? ((region) => new BedrockClient({ region })))(params.region);
1330
+ const discoveryPromise = (async () => {
1331
+ const response = await client.send(new ListFoundationModelsCommand({}));
1332
+ const discovered = [];
1333
+ for (const summary of response.modelSummaries ?? []) {
1334
+ if (!shouldIncludeSummary(summary, providerFilter)) continue;
1335
+ discovered.push(toModelDefinition(summary, {
1336
+ contextWindow: defaultContextWindow,
1337
+ maxTokens: defaultMaxTokens
1338
+ }));
1339
+ }
1340
+ return discovered.toSorted((a, b) => a.name.localeCompare(b.name));
1341
+ })();
1342
+ if (refreshIntervalSeconds > 0) discoveryCache.set(cacheKey, {
1343
+ expiresAt: now + refreshIntervalSeconds * 1e3,
1344
+ inFlight: discoveryPromise
1345
+ });
1346
+ try {
1347
+ const value = await discoveryPromise;
1348
+ if (refreshIntervalSeconds > 0) discoveryCache.set(cacheKey, {
1349
+ expiresAt: now + refreshIntervalSeconds * 1e3,
1350
+ value
1351
+ });
1352
+ return value;
1353
+ } catch (error) {
1354
+ if (refreshIntervalSeconds > 0) discoveryCache.delete(cacheKey);
1355
+ if (!hasLoggedBedrockError) {
1356
+ hasLoggedBedrockError = true;
1357
+ console.warn(`[bedrock-discovery] Failed to list models: ${String(error)}`);
1358
+ }
1359
+ return [];
1360
+ }
1361
+ }
1362
+
1363
+ //#endregion
1364
+ //#region src/agents/cloudflare-ai-gateway.ts
1365
+ const CLOUDFLARE_AI_GATEWAY_PROVIDER_ID = "cloudflare-ai-gateway";
1366
+ const CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_ID = "claude-sonnet-4-5";
1367
+ const CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF = `${CLOUDFLARE_AI_GATEWAY_PROVIDER_ID}/${CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_ID}`;
1368
+ const CLOUDFLARE_AI_GATEWAY_DEFAULT_CONTEXT_WINDOW = 2e5;
1369
+ const CLOUDFLARE_AI_GATEWAY_DEFAULT_MAX_TOKENS = 64e3;
1370
+ const CLOUDFLARE_AI_GATEWAY_DEFAULT_COST = {
1371
+ input: 3,
1372
+ output: 15,
1373
+ cacheRead: .3,
1374
+ cacheWrite: 3.75
1375
+ };
1376
+ function buildCloudflareAiGatewayModelDefinition(params) {
1377
+ return {
1378
+ id: params?.id?.trim() || CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_ID,
1379
+ name: params?.name ?? "Claude Sonnet 4.5",
1380
+ reasoning: params?.reasoning ?? true,
1381
+ input: params?.input ?? ["text", "image"],
1382
+ cost: CLOUDFLARE_AI_GATEWAY_DEFAULT_COST,
1383
+ contextWindow: CLOUDFLARE_AI_GATEWAY_DEFAULT_CONTEXT_WINDOW,
1384
+ maxTokens: CLOUDFLARE_AI_GATEWAY_DEFAULT_MAX_TOKENS
1385
+ };
1386
+ }
1387
+ function resolveCloudflareAiGatewayBaseUrl(params) {
1388
+ const accountId = params.accountId.trim();
1389
+ const gatewayId = params.gatewayId.trim();
1390
+ if (!accountId || !gatewayId) return "";
1391
+ return `https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/anthropic`;
1392
+ }
1393
+
1394
+ //#endregion
1395
+ //#region src/infra/shell-env.ts
1396
+ const DEFAULT_TIMEOUT_MS = 15e3;
1397
+ const DEFAULT_MAX_BUFFER_BYTES = 2 * 1024 * 1024;
1398
+ let lastAppliedKeys = [];
1399
+ let cachedShellPath;
1400
+ function resolveShell(env) {
1401
+ const shell = env.SHELL?.trim();
1402
+ return shell && shell.length > 0 ? shell : "/bin/sh";
1403
+ }
1404
+ function parseShellEnv(stdout) {
1405
+ const shellEnv = /* @__PURE__ */ new Map();
1406
+ const parts = stdout.toString("utf8").split("\0");
1407
+ for (const part of parts) {
1408
+ if (!part) continue;
1409
+ const eq = part.indexOf("=");
1410
+ if (eq <= 0) continue;
1411
+ const key = part.slice(0, eq);
1412
+ const value = part.slice(eq + 1);
1413
+ if (!key) continue;
1414
+ shellEnv.set(key, value);
1415
+ }
1416
+ return shellEnv;
1417
+ }
1418
+ function loadShellEnvFallback(opts) {
1419
+ const logger = opts.logger ?? console;
1420
+ const exec = opts.exec ?? execFileSync;
1421
+ if (!opts.enabled) {
1422
+ lastAppliedKeys = [];
1423
+ return {
1424
+ ok: true,
1425
+ applied: [],
1426
+ skippedReason: "disabled"
1427
+ };
1428
+ }
1429
+ if (opts.expectedKeys.some((key) => Boolean(opts.env[key]?.trim()))) {
1430
+ lastAppliedKeys = [];
1431
+ return {
1432
+ ok: true,
1433
+ applied: [],
1434
+ skippedReason: "already-has-keys"
1435
+ };
1436
+ }
1437
+ const timeoutMs = typeof opts.timeoutMs === "number" && Number.isFinite(opts.timeoutMs) ? Math.max(0, opts.timeoutMs) : DEFAULT_TIMEOUT_MS;
1438
+ const shell = resolveShell(opts.env);
1439
+ let stdout;
1440
+ try {
1441
+ stdout = exec(shell, [
1442
+ "-l",
1443
+ "-c",
1444
+ "env -0"
1445
+ ], {
1446
+ encoding: "buffer",
1447
+ timeout: timeoutMs,
1448
+ maxBuffer: DEFAULT_MAX_BUFFER_BYTES,
1449
+ env: opts.env,
1450
+ stdio: [
1451
+ "ignore",
1452
+ "pipe",
1453
+ "pipe"
1454
+ ]
1455
+ });
1456
+ } catch (err) {
1457
+ const msg = err instanceof Error ? err.message : String(err);
1458
+ logger.warn(`[Synurex] shell env fallback failed: ${msg}`);
1459
+ lastAppliedKeys = [];
1460
+ return {
1461
+ ok: false,
1462
+ error: msg,
1463
+ applied: []
1464
+ };
1465
+ }
1466
+ const shellEnv = parseShellEnv(stdout);
1467
+ const applied = [];
1468
+ for (const key of opts.expectedKeys) {
1469
+ if (opts.env[key]?.trim()) continue;
1470
+ const value = shellEnv.get(key);
1471
+ if (!value?.trim()) continue;
1472
+ opts.env[key] = value;
1473
+ applied.push(key);
1474
+ }
1475
+ lastAppliedKeys = applied;
1476
+ return {
1477
+ ok: true,
1478
+ applied
1479
+ };
1480
+ }
1481
+ function shouldEnableShellEnvFallback(env) {
1482
+ return isTruthyEnvValue(env.SYNUREX_LOAD_SHELL_ENV);
1483
+ }
1484
+ function shouldDeferShellEnvFallback(env) {
1485
+ return isTruthyEnvValue(env.SYNUREX_DEFER_SHELL_ENV_FALLBACK);
1486
+ }
1487
+ function resolveShellEnvFallbackTimeoutMs(env) {
1488
+ const raw = env.SYNUREX_SHELL_ENV_TIMEOUT_MS?.trim();
1489
+ if (!raw) return DEFAULT_TIMEOUT_MS;
1490
+ const parsed = Number.parseInt(raw, 10);
1491
+ if (!Number.isFinite(parsed)) return DEFAULT_TIMEOUT_MS;
1492
+ return Math.max(0, parsed);
1493
+ }
1494
+ function getShellPathFromLoginShell(opts) {
1495
+ if (cachedShellPath !== void 0) return cachedShellPath;
1496
+ if (process.platform === "win32") {
1497
+ cachedShellPath = null;
1498
+ return cachedShellPath;
1499
+ }
1500
+ const exec = opts.exec ?? execFileSync;
1501
+ const timeoutMs = typeof opts.timeoutMs === "number" && Number.isFinite(opts.timeoutMs) ? Math.max(0, opts.timeoutMs) : DEFAULT_TIMEOUT_MS;
1502
+ const shell = resolveShell(opts.env);
1503
+ let stdout;
1504
+ try {
1505
+ stdout = exec(shell, [
1506
+ "-l",
1507
+ "-c",
1508
+ "env -0"
1509
+ ], {
1510
+ encoding: "buffer",
1511
+ timeout: timeoutMs,
1512
+ maxBuffer: DEFAULT_MAX_BUFFER_BYTES,
1513
+ env: opts.env,
1514
+ stdio: [
1515
+ "ignore",
1516
+ "pipe",
1517
+ "pipe"
1518
+ ]
1519
+ });
1520
+ } catch {
1521
+ cachedShellPath = null;
1522
+ return cachedShellPath;
1523
+ }
1524
+ const shellPath = parseShellEnv(stdout).get("PATH")?.trim();
1525
+ cachedShellPath = shellPath && shellPath.length > 0 ? shellPath : null;
1526
+ return cachedShellPath;
1527
+ }
1528
+ function getShellEnvAppliedKeys() {
1529
+ return [...lastAppliedKeys];
1530
+ }
1531
+
1532
+ //#endregion
1533
+ //#region src/agents/model-auth.ts
1534
+ const AWS_BEARER_ENV = "AWS_BEARER_TOKEN_BEDROCK";
1535
+ const AWS_ACCESS_KEY_ENV = "AWS_ACCESS_KEY_ID";
1536
+ const AWS_SECRET_KEY_ENV = "AWS_SECRET_ACCESS_KEY";
1537
+ const AWS_PROFILE_ENV = "AWS_PROFILE";
1538
+ function resolveProviderConfig(cfg, provider) {
1539
+ const providers = cfg?.models?.providers ?? {};
1540
+ const direct = providers[provider];
1541
+ if (direct) return direct;
1542
+ const normalized = normalizeProviderId(provider);
1543
+ if (normalized === provider) return Object.entries(providers).find(([key]) => normalizeProviderId(key) === normalized)?.[1];
1544
+ return providers[normalized] ?? Object.entries(providers).find(([key]) => normalizeProviderId(key) === normalized)?.[1];
1545
+ }
1546
+ function getCustomProviderApiKey(cfg, provider) {
1547
+ return resolveProviderConfig(cfg, provider)?.apiKey?.trim() || void 0;
1548
+ }
1549
+ function resolveProviderAuthOverride(cfg, provider) {
1550
+ const auth = resolveProviderConfig(cfg, provider)?.auth;
1551
+ if (auth === "api-key" || auth === "aws-sdk" || auth === "oauth" || auth === "token") return auth;
1552
+ }
1553
+ function resolveEnvSourceLabel(params) {
1554
+ return `${params.envVars.some((envVar) => params.applied.has(envVar)) ? "shell env: " : "env: "}${params.label}`;
1555
+ }
1556
+ function resolveAwsSdkEnvVarName(env = process.env) {
1557
+ if (env[AWS_BEARER_ENV]?.trim()) return AWS_BEARER_ENV;
1558
+ if (env[AWS_ACCESS_KEY_ENV]?.trim() && env[AWS_SECRET_KEY_ENV]?.trim()) return AWS_ACCESS_KEY_ENV;
1559
+ if (env[AWS_PROFILE_ENV]?.trim()) return AWS_PROFILE_ENV;
1560
+ }
1561
+ function resolveAwsSdkAuthInfo() {
1562
+ const applied = new Set(getShellEnvAppliedKeys());
1563
+ if (process.env[AWS_BEARER_ENV]?.trim()) return {
1564
+ mode: "aws-sdk",
1565
+ source: resolveEnvSourceLabel({
1566
+ applied,
1567
+ envVars: [AWS_BEARER_ENV],
1568
+ label: AWS_BEARER_ENV
1569
+ })
1570
+ };
1571
+ if (process.env[AWS_ACCESS_KEY_ENV]?.trim() && process.env[AWS_SECRET_KEY_ENV]?.trim()) return {
1572
+ mode: "aws-sdk",
1573
+ source: resolveEnvSourceLabel({
1574
+ applied,
1575
+ envVars: [AWS_ACCESS_KEY_ENV, AWS_SECRET_KEY_ENV],
1576
+ label: `${AWS_ACCESS_KEY_ENV} + ${AWS_SECRET_KEY_ENV}`
1577
+ })
1578
+ };
1579
+ if (process.env[AWS_PROFILE_ENV]?.trim()) return {
1580
+ mode: "aws-sdk",
1581
+ source: resolveEnvSourceLabel({
1582
+ applied,
1583
+ envVars: [AWS_PROFILE_ENV],
1584
+ label: AWS_PROFILE_ENV
1585
+ })
1586
+ };
1587
+ return {
1588
+ mode: "aws-sdk",
1589
+ source: "aws-sdk default chain"
1590
+ };
1591
+ }
1592
+ async function resolveApiKeyForProvider(params) {
1593
+ const { provider, cfg, profileId, preferredProfile } = params;
1594
+ const store = params.store ?? ensureAuthProfileStore(params.agentDir);
1595
+ if (profileId) {
1596
+ const resolved = await resolveApiKeyForProfile({
1597
+ cfg,
1598
+ store,
1599
+ profileId,
1600
+ agentDir: params.agentDir
1601
+ });
1602
+ if (!resolved) throw new Error(`No credentials found for profile "${profileId}".`);
1603
+ const mode = store.profiles[profileId]?.type;
1604
+ return {
1605
+ apiKey: resolved.apiKey,
1606
+ profileId,
1607
+ source: `profile:${profileId}`,
1608
+ mode: mode === "oauth" ? "oauth" : mode === "token" ? "token" : "api-key"
1609
+ };
1610
+ }
1611
+ const authOverride = resolveProviderAuthOverride(cfg, provider);
1612
+ if (authOverride === "aws-sdk") return resolveAwsSdkAuthInfo();
1613
+ const order = resolveAuthProfileOrder({
1614
+ cfg,
1615
+ store,
1616
+ provider,
1617
+ preferredProfile
1618
+ });
1619
+ for (const candidate of order) try {
1620
+ const resolved = await resolveApiKeyForProfile({
1621
+ cfg,
1622
+ store,
1623
+ profileId: candidate,
1624
+ agentDir: params.agentDir
1625
+ });
1626
+ if (resolved) {
1627
+ const mode = store.profiles[candidate]?.type;
1628
+ return {
1629
+ apiKey: resolved.apiKey,
1630
+ profileId: candidate,
1631
+ source: `profile:${candidate}`,
1632
+ mode: mode === "oauth" ? "oauth" : mode === "token" ? "token" : "api-key"
1633
+ };
1634
+ }
1635
+ } catch {}
1636
+ const envResolved = resolveEnvApiKey(provider);
1637
+ if (envResolved) return {
1638
+ apiKey: envResolved.apiKey,
1639
+ source: envResolved.source,
1640
+ mode: envResolved.source.includes("OAUTH_TOKEN") ? "oauth" : "api-key"
1641
+ };
1642
+ const customKey = getCustomProviderApiKey(cfg, provider);
1643
+ if (customKey) return {
1644
+ apiKey: customKey,
1645
+ source: "models.json",
1646
+ mode: "api-key"
1647
+ };
1648
+ const normalized = normalizeProviderId(provider);
1649
+ if (authOverride === void 0 && normalized === "amazon-bedrock") return resolveAwsSdkAuthInfo();
1650
+ if (provider === "openai") {
1651
+ if (listProfilesForProvider(store, "openai-codex").length > 0) throw new Error("No API key found for provider \"openai\". You are authenticated with OpenAI Codex OAuth. Use openai-codex/gpt-5.3-codex (OAuth) or set OPENAI_API_KEY to use openai/gpt-5.1-codex.");
1652
+ }
1653
+ const authStorePath = resolveAuthStorePathForDisplay(params.agentDir);
1654
+ const resolvedAgentDir = path.dirname(authStorePath);
1655
+ throw new Error([
1656
+ `No API key found for provider "${provider}".`,
1657
+ `Auth store: ${authStorePath} (agentDir: ${resolvedAgentDir}).`,
1658
+ `Configure auth for this agent (${formatCliCommand("synurex agents add <id>")}) or copy auth-profiles.json from the main agentDir.`
1659
+ ].join(" "));
1660
+ }
1661
+ function resolveEnvApiKey(provider) {
1662
+ const normalized = normalizeProviderId(provider);
1663
+ const applied = new Set(getShellEnvAppliedKeys());
1664
+ const pick = (envVar) => {
1665
+ const value = process.env[envVar]?.trim();
1666
+ if (!value) return null;
1667
+ return {
1668
+ apiKey: value,
1669
+ source: applied.has(envVar) ? `shell env: ${envVar}` : `env: ${envVar}`
1670
+ };
1671
+ };
1672
+ if (normalized === "github-copilot") return pick("COPILOT_GITHUB_TOKEN") ?? pick("GH_TOKEN") ?? pick("GITHUB_TOKEN");
1673
+ if (normalized === "anthropic") return pick("ANTHROPIC_OAUTH_TOKEN") ?? pick("ANTHROPIC_API_KEY");
1674
+ if (normalized === "chutes") return pick("CHUTES_OAUTH_TOKEN") ?? pick("CHUTES_API_KEY");
1675
+ if (normalized === "zai") return pick("ZAI_API_KEY") ?? pick("Z_AI_API_KEY");
1676
+ if (normalized === "google-vertex") {
1677
+ const envKey = getEnvApiKey(normalized);
1678
+ if (!envKey) return null;
1679
+ return {
1680
+ apiKey: envKey,
1681
+ source: "gcloud adc"
1682
+ };
1683
+ }
1684
+ if (normalized === "opencode") return pick("OPENCODE_API_KEY") ?? pick("OPENCODE_ZEN_API_KEY");
1685
+ if (normalized === "qwen-portal") return pick("QWEN_OAUTH_TOKEN") ?? pick("QWEN_PORTAL_API_KEY");
1686
+ if (normalized === "minimax-portal") return pick("MINIMAX_OAUTH_TOKEN") ?? pick("MINIMAX_API_KEY");
1687
+ if (normalized === "kimi-coding") return pick("KIMI_API_KEY") ?? pick("KIMICODE_API_KEY");
1688
+ const envVar = {
1689
+ openai: "OPENAI_API_KEY",
1690
+ google: "GEMINI_API_KEY",
1691
+ voyage: "VOYAGE_API_KEY",
1692
+ groq: "GROQ_API_KEY",
1693
+ deepgram: "DEEPGRAM_API_KEY",
1694
+ cerebras: "CEREBRAS_API_KEY",
1695
+ xai: "XAI_API_KEY",
1696
+ openrouter: "OPENROUTER_API_KEY",
1697
+ "vercel-ai-gateway": "AI_GATEWAY_API_KEY",
1698
+ "cloudflare-ai-gateway": "CLOUDFLARE_AI_GATEWAY_API_KEY",
1699
+ moonshot: "MOONSHOT_API_KEY",
1700
+ minimax: "MINIMAX_API_KEY",
1701
+ xiaomi: "XIAOMI_API_KEY",
1702
+ synthetic: "SYNTHETIC_API_KEY",
1703
+ venice: "VENICE_API_KEY",
1704
+ mistral: "MISTRAL_API_KEY",
1705
+ opencode: "OPENCODE_API_KEY",
1706
+ qianfan: "QIANFAN_API_KEY",
1707
+ ollama: "OLLAMA_API_KEY"
1708
+ }[normalized];
1709
+ if (!envVar) return null;
1710
+ return pick(envVar);
1711
+ }
1712
+ function resolveModelAuthMode(provider, cfg, store) {
1713
+ const resolved = provider?.trim();
1714
+ if (!resolved) return;
1715
+ const authOverride = resolveProviderAuthOverride(cfg, resolved);
1716
+ if (authOverride === "aws-sdk") return "aws-sdk";
1717
+ const authStore = store ?? ensureAuthProfileStore();
1718
+ const profiles = listProfilesForProvider(authStore, resolved);
1719
+ if (profiles.length > 0) {
1720
+ const modes = new Set(profiles.map((id) => authStore.profiles[id]?.type).filter((mode) => Boolean(mode)));
1721
+ if ([
1722
+ "oauth",
1723
+ "token",
1724
+ "api_key"
1725
+ ].filter((k) => modes.has(k)).length >= 2) return "mixed";
1726
+ if (modes.has("oauth")) return "oauth";
1727
+ if (modes.has("token")) return "token";
1728
+ if (modes.has("api_key")) return "api-key";
1729
+ }
1730
+ if (authOverride === void 0 && normalizeProviderId(resolved) === "amazon-bedrock") return "aws-sdk";
1731
+ const envKey = resolveEnvApiKey(resolved);
1732
+ if (envKey?.apiKey) return envKey.source.includes("OAUTH_TOKEN") ? "oauth" : "api-key";
1733
+ if (getCustomProviderApiKey(cfg, resolved)) return "api-key";
1734
+ return "unknown";
1735
+ }
1736
+ async function getApiKeyForModel(params) {
1737
+ return resolveApiKeyForProvider({
1738
+ provider: params.model.provider,
1739
+ cfg: params.cfg,
1740
+ profileId: params.profileId,
1741
+ preferredProfile: params.preferredProfile,
1742
+ store: params.store,
1743
+ agentDir: params.agentDir
1744
+ });
1745
+ }
1746
+ function requireApiKey(auth, provider) {
1747
+ const key = auth.apiKey?.trim();
1748
+ if (key) return key;
1749
+ throw new Error(`No API key resolved for provider "${provider}" (auth mode: ${auth.mode}).`);
1750
+ }
1751
+
1752
+ //#endregion
1753
+ //#region src/agents/synthetic-models.ts
1754
+ const SYNTHETIC_BASE_URL = "https://api.synthetic.new/anthropic";
1755
+ const SYNTHETIC_DEFAULT_MODEL_ID = "hf:MiniMaxAI/MiniMax-M2.1";
1756
+ const SYNTHETIC_DEFAULT_MODEL_REF = `synthetic/${SYNTHETIC_DEFAULT_MODEL_ID}`;
1757
+ const SYNTHETIC_DEFAULT_COST = {
1758
+ input: 0,
1759
+ output: 0,
1760
+ cacheRead: 0,
1761
+ cacheWrite: 0
1762
+ };
1763
+ const SYNTHETIC_MODEL_CATALOG = [
1764
+ {
1765
+ id: SYNTHETIC_DEFAULT_MODEL_ID,
1766
+ name: "MiniMax M2.1",
1767
+ reasoning: false,
1768
+ input: ["text"],
1769
+ contextWindow: 192e3,
1770
+ maxTokens: 65536
1771
+ },
1772
+ {
1773
+ id: "hf:moonshotai/Kimi-K2-Thinking",
1774
+ name: "Kimi K2 Thinking",
1775
+ reasoning: true,
1776
+ input: ["text"],
1777
+ contextWindow: 256e3,
1778
+ maxTokens: 8192
1779
+ },
1780
+ {
1781
+ id: "hf:zai-org/GLM-4.7",
1782
+ name: "GLM-4.7",
1783
+ reasoning: false,
1784
+ input: ["text"],
1785
+ contextWindow: 198e3,
1786
+ maxTokens: 128e3
1787
+ },
1788
+ {
1789
+ id: "hf:deepseek-ai/DeepSeek-R1-0528",
1790
+ name: "DeepSeek R1 0528",
1791
+ reasoning: false,
1792
+ input: ["text"],
1793
+ contextWindow: 128e3,
1794
+ maxTokens: 8192
1795
+ },
1796
+ {
1797
+ id: "hf:deepseek-ai/DeepSeek-V3-0324",
1798
+ name: "DeepSeek V3 0324",
1799
+ reasoning: false,
1800
+ input: ["text"],
1801
+ contextWindow: 128e3,
1802
+ maxTokens: 8192
1803
+ },
1804
+ {
1805
+ id: "hf:deepseek-ai/DeepSeek-V3.1",
1806
+ name: "DeepSeek V3.1",
1807
+ reasoning: false,
1808
+ input: ["text"],
1809
+ contextWindow: 128e3,
1810
+ maxTokens: 8192
1811
+ },
1812
+ {
1813
+ id: "hf:deepseek-ai/DeepSeek-V3.1-Terminus",
1814
+ name: "DeepSeek V3.1 Terminus",
1815
+ reasoning: false,
1816
+ input: ["text"],
1817
+ contextWindow: 128e3,
1818
+ maxTokens: 8192
1819
+ },
1820
+ {
1821
+ id: "hf:deepseek-ai/DeepSeek-V3.2",
1822
+ name: "DeepSeek V3.2",
1823
+ reasoning: false,
1824
+ input: ["text"],
1825
+ contextWindow: 159e3,
1826
+ maxTokens: 8192
1827
+ },
1828
+ {
1829
+ id: "hf:meta-llama/Llama-3.3-70B-Instruct",
1830
+ name: "Llama 3.3 70B Instruct",
1831
+ reasoning: false,
1832
+ input: ["text"],
1833
+ contextWindow: 128e3,
1834
+ maxTokens: 8192
1835
+ },
1836
+ {
1837
+ id: "hf:meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8",
1838
+ name: "Llama 4 Maverick 17B 128E Instruct FP8",
1839
+ reasoning: false,
1840
+ input: ["text"],
1841
+ contextWindow: 524e3,
1842
+ maxTokens: 8192
1843
+ },
1844
+ {
1845
+ id: "hf:moonshotai/Kimi-K2-Instruct-0905",
1846
+ name: "Kimi K2 Instruct 0905",
1847
+ reasoning: false,
1848
+ input: ["text"],
1849
+ contextWindow: 256e3,
1850
+ maxTokens: 8192
1851
+ },
1852
+ {
1853
+ id: "hf:moonshotai/Kimi-K2.5",
1854
+ name: "Kimi K2.5",
1855
+ reasoning: true,
1856
+ input: ["text"],
1857
+ contextWindow: 256e3,
1858
+ maxTokens: 8192
1859
+ },
1860
+ {
1861
+ id: "hf:openai/gpt-oss-120b",
1862
+ name: "GPT OSS 120B",
1863
+ reasoning: false,
1864
+ input: ["text"],
1865
+ contextWindow: 128e3,
1866
+ maxTokens: 8192
1867
+ },
1868
+ {
1869
+ id: "hf:Qwen/Qwen3-235B-A22B-Instruct-2507",
1870
+ name: "Qwen3 235B A22B Instruct 2507",
1871
+ reasoning: false,
1872
+ input: ["text"],
1873
+ contextWindow: 256e3,
1874
+ maxTokens: 8192
1875
+ },
1876
+ {
1877
+ id: "hf:Qwen/Qwen3-Coder-480B-A35B-Instruct",
1878
+ name: "Qwen3 Coder 480B A35B Instruct",
1879
+ reasoning: false,
1880
+ input: ["text"],
1881
+ contextWindow: 256e3,
1882
+ maxTokens: 8192
1883
+ },
1884
+ {
1885
+ id: "hf:Qwen/Qwen3-VL-235B-A22B-Instruct",
1886
+ name: "Qwen3 VL 235B A22B Instruct",
1887
+ reasoning: false,
1888
+ input: ["text", "image"],
1889
+ contextWindow: 25e4,
1890
+ maxTokens: 8192
1891
+ },
1892
+ {
1893
+ id: "hf:zai-org/GLM-4.5",
1894
+ name: "GLM-4.5",
1895
+ reasoning: false,
1896
+ input: ["text"],
1897
+ contextWindow: 128e3,
1898
+ maxTokens: 128e3
1899
+ },
1900
+ {
1901
+ id: "hf:zai-org/GLM-4.6",
1902
+ name: "GLM-4.6",
1903
+ reasoning: false,
1904
+ input: ["text"],
1905
+ contextWindow: 198e3,
1906
+ maxTokens: 128e3
1907
+ },
1908
+ {
1909
+ id: "hf:deepseek-ai/DeepSeek-V3",
1910
+ name: "DeepSeek V3",
1911
+ reasoning: false,
1912
+ input: ["text"],
1913
+ contextWindow: 128e3,
1914
+ maxTokens: 8192
1915
+ },
1916
+ {
1917
+ id: "hf:Qwen/Qwen3-235B-A22B-Thinking-2507",
1918
+ name: "Qwen3 235B A22B Thinking 2507",
1919
+ reasoning: true,
1920
+ input: ["text"],
1921
+ contextWindow: 256e3,
1922
+ maxTokens: 8192
1923
+ }
1924
+ ];
1925
+ function buildSyntheticModelDefinition(entry) {
1926
+ return {
1927
+ id: entry.id,
1928
+ name: entry.name,
1929
+ reasoning: entry.reasoning,
1930
+ input: [...entry.input],
1931
+ cost: SYNTHETIC_DEFAULT_COST,
1932
+ contextWindow: entry.contextWindow,
1933
+ maxTokens: entry.maxTokens
1934
+ };
1935
+ }
1936
+
1937
+ //#endregion
1938
+ //#region src/agents/venice-models.ts
1939
+ const VENICE_BASE_URL = "https://api.venice.ai/api/v1";
1940
+ const VENICE_DEFAULT_MODEL_ID = "llama-3.3-70b";
1941
+ const VENICE_DEFAULT_MODEL_REF = `venice/${VENICE_DEFAULT_MODEL_ID}`;
1942
+ const VENICE_DEFAULT_COST = {
1943
+ input: 0,
1944
+ output: 0,
1945
+ cacheRead: 0,
1946
+ cacheWrite: 0
1947
+ };
1948
+ /**
1949
+ * Complete catalog of Venice AI models.
1950
+ *
1951
+ * Venice provides two privacy modes:
1952
+ * - "private": Fully private inference, no logging, ephemeral
1953
+ * - "anonymized": Proxied through Venice with metadata stripped (for proprietary models)
1954
+ *
1955
+ * Note: The `privacy` field is included for documentation purposes but is not
1956
+ * propagated to ModelDefinitionConfig as it's not part of the core model schema.
1957
+ * Privacy mode is determined by the model itself, not configurable at runtime.
1958
+ *
1959
+ * This catalog serves as a fallback when the Venice API is unreachable.
1960
+ */
1961
+ const VENICE_MODEL_CATALOG = [
1962
+ {
1963
+ id: "llama-3.3-70b",
1964
+ name: "Llama 3.3 70B",
1965
+ reasoning: false,
1966
+ input: ["text"],
1967
+ contextWindow: 131072,
1968
+ maxTokens: 8192,
1969
+ privacy: "private"
1970
+ },
1971
+ {
1972
+ id: "llama-3.2-3b",
1973
+ name: "Llama 3.2 3B",
1974
+ reasoning: false,
1975
+ input: ["text"],
1976
+ contextWindow: 131072,
1977
+ maxTokens: 8192,
1978
+ privacy: "private"
1979
+ },
1980
+ {
1981
+ id: "hermes-3-llama-3.1-405b",
1982
+ name: "Hermes 3 Llama 3.1 405B",
1983
+ reasoning: false,
1984
+ input: ["text"],
1985
+ contextWindow: 131072,
1986
+ maxTokens: 8192,
1987
+ privacy: "private"
1988
+ },
1989
+ {
1990
+ id: "qwen3-235b-a22b-thinking-2507",
1991
+ name: "Qwen3 235B Thinking",
1992
+ reasoning: true,
1993
+ input: ["text"],
1994
+ contextWindow: 131072,
1995
+ maxTokens: 8192,
1996
+ privacy: "private"
1997
+ },
1998
+ {
1999
+ id: "qwen3-235b-a22b-instruct-2507",
2000
+ name: "Qwen3 235B Instruct",
2001
+ reasoning: false,
2002
+ input: ["text"],
2003
+ contextWindow: 131072,
2004
+ maxTokens: 8192,
2005
+ privacy: "private"
2006
+ },
2007
+ {
2008
+ id: "qwen3-coder-480b-a35b-instruct",
2009
+ name: "Qwen3 Coder 480B",
2010
+ reasoning: false,
2011
+ input: ["text"],
2012
+ contextWindow: 262144,
2013
+ maxTokens: 8192,
2014
+ privacy: "private"
2015
+ },
2016
+ {
2017
+ id: "qwen3-next-80b",
2018
+ name: "Qwen3 Next 80B",
2019
+ reasoning: false,
2020
+ input: ["text"],
2021
+ contextWindow: 262144,
2022
+ maxTokens: 8192,
2023
+ privacy: "private"
2024
+ },
2025
+ {
2026
+ id: "qwen3-vl-235b-a22b",
2027
+ name: "Qwen3 VL 235B (Vision)",
2028
+ reasoning: false,
2029
+ input: ["text", "image"],
2030
+ contextWindow: 262144,
2031
+ maxTokens: 8192,
2032
+ privacy: "private"
2033
+ },
2034
+ {
2035
+ id: "qwen3-4b",
2036
+ name: "Venice Small (Qwen3 4B)",
2037
+ reasoning: true,
2038
+ input: ["text"],
2039
+ contextWindow: 32768,
2040
+ maxTokens: 8192,
2041
+ privacy: "private"
2042
+ },
2043
+ {
2044
+ id: "deepseek-v3.2",
2045
+ name: "DeepSeek V3.2",
2046
+ reasoning: true,
2047
+ input: ["text"],
2048
+ contextWindow: 163840,
2049
+ maxTokens: 8192,
2050
+ privacy: "private"
2051
+ },
2052
+ {
2053
+ id: "venice-uncensored",
2054
+ name: "Venice Uncensored (Dolphin-Mistral)",
2055
+ reasoning: false,
2056
+ input: ["text"],
2057
+ contextWindow: 32768,
2058
+ maxTokens: 8192,
2059
+ privacy: "private"
2060
+ },
2061
+ {
2062
+ id: "mistral-31-24b",
2063
+ name: "Venice Medium (Mistral)",
2064
+ reasoning: false,
2065
+ input: ["text", "image"],
2066
+ contextWindow: 131072,
2067
+ maxTokens: 8192,
2068
+ privacy: "private"
2069
+ },
2070
+ {
2071
+ id: "google-gemma-3-27b-it",
2072
+ name: "Google Gemma 3 27B Instruct",
2073
+ reasoning: false,
2074
+ input: ["text", "image"],
2075
+ contextWindow: 202752,
2076
+ maxTokens: 8192,
2077
+ privacy: "private"
2078
+ },
2079
+ {
2080
+ id: "openai-gpt-oss-120b",
2081
+ name: "OpenAI GPT OSS 120B",
2082
+ reasoning: false,
2083
+ input: ["text"],
2084
+ contextWindow: 131072,
2085
+ maxTokens: 8192,
2086
+ privacy: "private"
2087
+ },
2088
+ {
2089
+ id: "zai-org-glm-4.7",
2090
+ name: "GLM 4.7",
2091
+ reasoning: true,
2092
+ input: ["text"],
2093
+ contextWindow: 202752,
2094
+ maxTokens: 8192,
2095
+ privacy: "private"
2096
+ },
2097
+ {
2098
+ id: "claude-opus-45",
2099
+ name: "Claude Opus 4.5 (via Venice)",
2100
+ reasoning: true,
2101
+ input: ["text", "image"],
2102
+ contextWindow: 202752,
2103
+ maxTokens: 8192,
2104
+ privacy: "anonymized"
2105
+ },
2106
+ {
2107
+ id: "claude-sonnet-45",
2108
+ name: "Claude Sonnet 4.5 (via Venice)",
2109
+ reasoning: true,
2110
+ input: ["text", "image"],
2111
+ contextWindow: 202752,
2112
+ maxTokens: 8192,
2113
+ privacy: "anonymized"
2114
+ },
2115
+ {
2116
+ id: "openai-gpt-52",
2117
+ name: "GPT-5.2 (via Venice)",
2118
+ reasoning: true,
2119
+ input: ["text"],
2120
+ contextWindow: 262144,
2121
+ maxTokens: 8192,
2122
+ privacy: "anonymized"
2123
+ },
2124
+ {
2125
+ id: "openai-gpt-52-codex",
2126
+ name: "GPT-5.2 Codex (via Venice)",
2127
+ reasoning: true,
2128
+ input: ["text", "image"],
2129
+ contextWindow: 262144,
2130
+ maxTokens: 8192,
2131
+ privacy: "anonymized"
2132
+ },
2133
+ {
2134
+ id: "gemini-3-pro-preview",
2135
+ name: "Gemini 3 Pro (via Venice)",
2136
+ reasoning: true,
2137
+ input: ["text", "image"],
2138
+ contextWindow: 202752,
2139
+ maxTokens: 8192,
2140
+ privacy: "anonymized"
2141
+ },
2142
+ {
2143
+ id: "gemini-3-flash-preview",
2144
+ name: "Gemini 3 Flash (via Venice)",
2145
+ reasoning: true,
2146
+ input: ["text", "image"],
2147
+ contextWindow: 262144,
2148
+ maxTokens: 8192,
2149
+ privacy: "anonymized"
2150
+ },
2151
+ {
2152
+ id: "grok-41-fast",
2153
+ name: "Grok 4.1 Fast (via Venice)",
2154
+ reasoning: true,
2155
+ input: ["text", "image"],
2156
+ contextWindow: 262144,
2157
+ maxTokens: 8192,
2158
+ privacy: "anonymized"
2159
+ },
2160
+ {
2161
+ id: "grok-code-fast-1",
2162
+ name: "Grok Code Fast 1 (via Venice)",
2163
+ reasoning: true,
2164
+ input: ["text"],
2165
+ contextWindow: 262144,
2166
+ maxTokens: 8192,
2167
+ privacy: "anonymized"
2168
+ },
2169
+ {
2170
+ id: "kimi-k2-thinking",
2171
+ name: "Kimi K2 Thinking (via Venice)",
2172
+ reasoning: true,
2173
+ input: ["text"],
2174
+ contextWindow: 262144,
2175
+ maxTokens: 8192,
2176
+ privacy: "anonymized"
2177
+ },
2178
+ {
2179
+ id: "minimax-m21",
2180
+ name: "MiniMax M2.1 (via Venice)",
2181
+ reasoning: true,
2182
+ input: ["text"],
2183
+ contextWindow: 202752,
2184
+ maxTokens: 8192,
2185
+ privacy: "anonymized"
2186
+ }
2187
+ ];
2188
+ /**
2189
+ * Build a ModelDefinitionConfig from a Venice catalog entry.
2190
+ *
2191
+ * Note: The `privacy` field from the catalog is not included in the output
2192
+ * as ModelDefinitionConfig doesn't support custom metadata fields. Privacy
2193
+ * mode is inherent to each model and documented in the catalog/docs.
2194
+ */
2195
+ function buildVeniceModelDefinition(entry) {
2196
+ return {
2197
+ id: entry.id,
2198
+ name: entry.name,
2199
+ reasoning: entry.reasoning,
2200
+ input: [...entry.input],
2201
+ cost: VENICE_DEFAULT_COST,
2202
+ contextWindow: entry.contextWindow,
2203
+ maxTokens: entry.maxTokens
2204
+ };
2205
+ }
2206
+ /**
2207
+ * Discover models from Venice API with fallback to static catalog.
2208
+ * The /models endpoint is public and doesn't require authentication.
2209
+ */
2210
+ async function discoverVeniceModels() {
2211
+ if (process.env.VITEST) return VENICE_MODEL_CATALOG.map(buildVeniceModelDefinition);
2212
+ try {
2213
+ const response = await fetch(`${VENICE_BASE_URL}/models`, { signal: AbortSignal.timeout(5e3) });
2214
+ if (!response.ok) {
2215
+ console.warn(`[venice-models] Failed to discover models: HTTP ${response.status}, using static catalog`);
2216
+ return VENICE_MODEL_CATALOG.map(buildVeniceModelDefinition);
2217
+ }
2218
+ const data = await response.json();
2219
+ if (!Array.isArray(data.data) || data.data.length === 0) {
2220
+ console.warn("[venice-models] No models found from API, using static catalog");
2221
+ return VENICE_MODEL_CATALOG.map(buildVeniceModelDefinition);
2222
+ }
2223
+ const catalogById = new Map(VENICE_MODEL_CATALOG.map((m) => [m.id, m]));
2224
+ const models = [];
2225
+ for (const apiModel of data.data) {
2226
+ const catalogEntry = catalogById.get(apiModel.id);
2227
+ if (catalogEntry) models.push(buildVeniceModelDefinition(catalogEntry));
2228
+ else {
2229
+ const isReasoning = apiModel.model_spec.capabilities.supportsReasoning || apiModel.id.toLowerCase().includes("thinking") || apiModel.id.toLowerCase().includes("reason") || apiModel.id.toLowerCase().includes("r1");
2230
+ const hasVision = apiModel.model_spec.capabilities.supportsVision;
2231
+ models.push({
2232
+ id: apiModel.id,
2233
+ name: apiModel.model_spec.name || apiModel.id,
2234
+ reasoning: isReasoning,
2235
+ input: hasVision ? ["text", "image"] : ["text"],
2236
+ cost: VENICE_DEFAULT_COST,
2237
+ contextWindow: apiModel.model_spec.availableContextTokens || 128e3,
2238
+ maxTokens: 8192
2239
+ });
2240
+ }
2241
+ }
2242
+ return models.length > 0 ? models : VENICE_MODEL_CATALOG.map(buildVeniceModelDefinition);
2243
+ } catch (error) {
2244
+ console.warn(`[venice-models] Discovery failed: ${String(error)}, using static catalog`);
2245
+ return VENICE_MODEL_CATALOG.map(buildVeniceModelDefinition);
2246
+ }
2247
+ }
2248
+
2249
+ //#endregion
2250
+ //#region src/agents/models-config.providers.ts
2251
+ const MINIMAX_API_BASE_URL = "https://api.minimax.chat/v1";
2252
+ const MINIMAX_PORTAL_BASE_URL = "https://api.minimax.io/anthropic";
2253
+ const MINIMAX_DEFAULT_MODEL_ID = "MiniMax-M2.1";
2254
+ const MINIMAX_DEFAULT_VISION_MODEL_ID = "MiniMax-VL-01";
2255
+ const MINIMAX_DEFAULT_CONTEXT_WINDOW = 2e5;
2256
+ const MINIMAX_DEFAULT_MAX_TOKENS = 8192;
2257
+ const MINIMAX_OAUTH_PLACEHOLDER = "minimax-oauth";
2258
+ const MINIMAX_API_COST = {
2259
+ input: 15,
2260
+ output: 60,
2261
+ cacheRead: 2,
2262
+ cacheWrite: 10
2263
+ };
2264
+ const XIAOMI_BASE_URL = "https://api.xiaomimimo.com/anthropic";
2265
+ const XIAOMI_DEFAULT_MODEL_ID = "mimo-v2-flash";
2266
+ const XIAOMI_DEFAULT_CONTEXT_WINDOW = 262144;
2267
+ const XIAOMI_DEFAULT_MAX_TOKENS = 8192;
2268
+ const XIAOMI_DEFAULT_COST = {
2269
+ input: 0,
2270
+ output: 0,
2271
+ cacheRead: 0,
2272
+ cacheWrite: 0
2273
+ };
2274
+ const MOONSHOT_BASE_URL = "https://api.moonshot.ai/v1";
2275
+ const MOONSHOT_DEFAULT_MODEL_ID = "kimi-k2.5";
2276
+ const MOONSHOT_DEFAULT_CONTEXT_WINDOW = 256e3;
2277
+ const MOONSHOT_DEFAULT_MAX_TOKENS = 8192;
2278
+ const MOONSHOT_DEFAULT_COST = {
2279
+ input: 0,
2280
+ output: 0,
2281
+ cacheRead: 0,
2282
+ cacheWrite: 0
2283
+ };
2284
+ const QWEN_PORTAL_BASE_URL = "https://portal.qwen.ai/v1";
2285
+ const QWEN_PORTAL_OAUTH_PLACEHOLDER = "qwen-oauth";
2286
+ const QWEN_PORTAL_DEFAULT_CONTEXT_WINDOW = 128e3;
2287
+ const QWEN_PORTAL_DEFAULT_MAX_TOKENS = 8192;
2288
+ const QWEN_PORTAL_DEFAULT_COST = {
2289
+ input: 0,
2290
+ output: 0,
2291
+ cacheRead: 0,
2292
+ cacheWrite: 0
2293
+ };
2294
+ const OLLAMA_BASE_URL = "http://127.0.0.1:11434/v1";
2295
+ const OLLAMA_API_BASE_URL = "http://127.0.0.1:11434";
2296
+ const OLLAMA_DEFAULT_CONTEXT_WINDOW = 128e3;
2297
+ const OLLAMA_DEFAULT_MAX_TOKENS = 8192;
2298
+ const OLLAMA_DEFAULT_COST = {
2299
+ input: 0,
2300
+ output: 0,
2301
+ cacheRead: 0,
2302
+ cacheWrite: 0
2303
+ };
2304
+ const QIANFAN_BASE_URL = "https://qianfan.baidubce.com/v2";
2305
+ const QIANFAN_DEFAULT_MODEL_ID = "deepseek-v3.2";
2306
+ const QIANFAN_DEFAULT_CONTEXT_WINDOW = 98304;
2307
+ const QIANFAN_DEFAULT_MAX_TOKENS = 32768;
2308
+ const QIANFAN_DEFAULT_COST = {
2309
+ input: 0,
2310
+ output: 0,
2311
+ cacheRead: 0,
2312
+ cacheWrite: 0
2313
+ };
2314
+ async function discoverOllamaModels() {
2315
+ if (process.env.VITEST || false) return [];
2316
+ try {
2317
+ const response = await fetch(`${OLLAMA_API_BASE_URL}/api/tags`, { signal: AbortSignal.timeout(5e3) });
2318
+ if (!response.ok) {
2319
+ console.warn(`Failed to discover Ollama models: ${response.status}`);
2320
+ return [];
2321
+ }
2322
+ const data = await response.json();
2323
+ if (!data.models || data.models.length === 0) {
2324
+ console.warn("No Ollama models found on local instance");
2325
+ return [];
2326
+ }
2327
+ return data.models.map((model) => {
2328
+ const modelId = model.name;
2329
+ return {
2330
+ id: modelId,
2331
+ name: modelId,
2332
+ reasoning: modelId.toLowerCase().includes("r1") || modelId.toLowerCase().includes("reasoning"),
2333
+ input: ["text"],
2334
+ cost: OLLAMA_DEFAULT_COST,
2335
+ contextWindow: OLLAMA_DEFAULT_CONTEXT_WINDOW,
2336
+ maxTokens: OLLAMA_DEFAULT_MAX_TOKENS,
2337
+ params: { streaming: false }
2338
+ };
2339
+ });
2340
+ } catch (error) {
2341
+ console.warn(`Failed to discover Ollama models: ${String(error)}`);
2342
+ return [];
2343
+ }
2344
+ }
2345
+ function normalizeApiKeyConfig(value) {
2346
+ const trimmed = value.trim();
2347
+ return /^\$\{([A-Z0-9_]+)\}$/.exec(trimmed)?.[1] ?? trimmed;
2348
+ }
2349
+ function resolveEnvApiKeyVarName(provider) {
2350
+ const resolved = resolveEnvApiKey(provider);
2351
+ if (!resolved) return;
2352
+ const match = /^(?:env: |shell env: )([A-Z0-9_]+)$/.exec(resolved.source);
2353
+ return match ? match[1] : void 0;
2354
+ }
2355
+ function resolveAwsSdkApiKeyVarName() {
2356
+ return resolveAwsSdkEnvVarName() ?? "AWS_PROFILE";
2357
+ }
2358
+ function resolveApiKeyFromProfiles(params) {
2359
+ const ids = listProfilesForProvider(params.store, params.provider);
2360
+ for (const id of ids) {
2361
+ const cred = params.store.profiles[id];
2362
+ if (!cred) continue;
2363
+ if (cred.type === "api_key") return cred.key;
2364
+ if (cred.type === "token") return cred.token;
2365
+ }
2366
+ }
2367
+ function normalizeGoogleModelId(id) {
2368
+ if (id === "gemini-3-pro") return "gemini-3-pro-preview";
2369
+ if (id === "gemini-3-flash") return "gemini-3-flash-preview";
2370
+ return id;
2371
+ }
2372
+ function normalizeGoogleProvider(provider) {
2373
+ let mutated = false;
2374
+ const models = provider.models.map((model) => {
2375
+ const nextId = normalizeGoogleModelId(model.id);
2376
+ if (nextId === model.id) return model;
2377
+ mutated = true;
2378
+ return {
2379
+ ...model,
2380
+ id: nextId
2381
+ };
2382
+ });
2383
+ return mutated ? {
2384
+ ...provider,
2385
+ models
2386
+ } : provider;
2387
+ }
2388
+ function normalizeProviders(params) {
2389
+ const { providers } = params;
2390
+ if (!providers) return providers;
2391
+ const authStore = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
2392
+ let mutated = false;
2393
+ const next = {};
2394
+ for (const [key, provider] of Object.entries(providers)) {
2395
+ const normalizedKey = key.trim();
2396
+ let normalizedProvider = provider;
2397
+ if (normalizedProvider.apiKey && normalizeApiKeyConfig(normalizedProvider.apiKey) !== normalizedProvider.apiKey) {
2398
+ mutated = true;
2399
+ normalizedProvider = {
2400
+ ...normalizedProvider,
2401
+ apiKey: normalizeApiKeyConfig(normalizedProvider.apiKey)
2402
+ };
2403
+ }
2404
+ if (Array.isArray(normalizedProvider.models) && normalizedProvider.models.length > 0 && !normalizedProvider.apiKey?.trim()) if ((normalizedProvider.auth ?? (normalizedKey === "amazon-bedrock" ? "aws-sdk" : void 0)) === "aws-sdk") {
2405
+ const apiKey = resolveAwsSdkApiKeyVarName();
2406
+ mutated = true;
2407
+ normalizedProvider = {
2408
+ ...normalizedProvider,
2409
+ apiKey
2410
+ };
2411
+ } else {
2412
+ const fromEnv = resolveEnvApiKeyVarName(normalizedKey);
2413
+ const fromProfiles = resolveApiKeyFromProfiles({
2414
+ provider: normalizedKey,
2415
+ store: authStore
2416
+ });
2417
+ const apiKey = fromEnv ?? fromProfiles;
2418
+ if (apiKey?.trim()) {
2419
+ mutated = true;
2420
+ normalizedProvider = {
2421
+ ...normalizedProvider,
2422
+ apiKey
2423
+ };
2424
+ }
2425
+ }
2426
+ if (normalizedKey === "google") {
2427
+ const googleNormalized = normalizeGoogleProvider(normalizedProvider);
2428
+ if (googleNormalized !== normalizedProvider) mutated = true;
2429
+ normalizedProvider = googleNormalized;
2430
+ }
2431
+ next[key] = normalizedProvider;
2432
+ }
2433
+ return mutated ? next : providers;
2434
+ }
2435
+ function buildMinimaxProvider() {
2436
+ return {
2437
+ baseUrl: MINIMAX_API_BASE_URL,
2438
+ api: "openai-completions",
2439
+ models: [{
2440
+ id: MINIMAX_DEFAULT_MODEL_ID,
2441
+ name: "MiniMax M2.1",
2442
+ reasoning: false,
2443
+ input: ["text"],
2444
+ cost: MINIMAX_API_COST,
2445
+ contextWindow: MINIMAX_DEFAULT_CONTEXT_WINDOW,
2446
+ maxTokens: MINIMAX_DEFAULT_MAX_TOKENS
2447
+ }, {
2448
+ id: MINIMAX_DEFAULT_VISION_MODEL_ID,
2449
+ name: "MiniMax VL 01",
2450
+ reasoning: false,
2451
+ input: ["text", "image"],
2452
+ cost: MINIMAX_API_COST,
2453
+ contextWindow: MINIMAX_DEFAULT_CONTEXT_WINDOW,
2454
+ maxTokens: MINIMAX_DEFAULT_MAX_TOKENS
2455
+ }]
2456
+ };
2457
+ }
2458
+ function buildMinimaxPortalProvider() {
2459
+ return {
2460
+ baseUrl: MINIMAX_PORTAL_BASE_URL,
2461
+ api: "anthropic-messages",
2462
+ models: [{
2463
+ id: MINIMAX_DEFAULT_MODEL_ID,
2464
+ name: "MiniMax M2.1",
2465
+ reasoning: false,
2466
+ input: ["text"],
2467
+ cost: MINIMAX_API_COST,
2468
+ contextWindow: MINIMAX_DEFAULT_CONTEXT_WINDOW,
2469
+ maxTokens: MINIMAX_DEFAULT_MAX_TOKENS
2470
+ }]
2471
+ };
2472
+ }
2473
+ function buildMoonshotProvider() {
2474
+ return {
2475
+ baseUrl: MOONSHOT_BASE_URL,
2476
+ api: "openai-completions",
2477
+ models: [{
2478
+ id: MOONSHOT_DEFAULT_MODEL_ID,
2479
+ name: "Kimi K2.5",
2480
+ reasoning: false,
2481
+ input: ["text"],
2482
+ cost: MOONSHOT_DEFAULT_COST,
2483
+ contextWindow: MOONSHOT_DEFAULT_CONTEXT_WINDOW,
2484
+ maxTokens: MOONSHOT_DEFAULT_MAX_TOKENS
2485
+ }]
2486
+ };
2487
+ }
2488
+ function buildQwenPortalProvider() {
2489
+ return {
2490
+ baseUrl: QWEN_PORTAL_BASE_URL,
2491
+ api: "openai-completions",
2492
+ models: [{
2493
+ id: "coder-model",
2494
+ name: "Qwen Coder",
2495
+ reasoning: false,
2496
+ input: ["text"],
2497
+ cost: QWEN_PORTAL_DEFAULT_COST,
2498
+ contextWindow: QWEN_PORTAL_DEFAULT_CONTEXT_WINDOW,
2499
+ maxTokens: QWEN_PORTAL_DEFAULT_MAX_TOKENS
2500
+ }, {
2501
+ id: "vision-model",
2502
+ name: "Qwen Vision",
2503
+ reasoning: false,
2504
+ input: ["text", "image"],
2505
+ cost: QWEN_PORTAL_DEFAULT_COST,
2506
+ contextWindow: QWEN_PORTAL_DEFAULT_CONTEXT_WINDOW,
2507
+ maxTokens: QWEN_PORTAL_DEFAULT_MAX_TOKENS
2508
+ }]
2509
+ };
2510
+ }
2511
+ function buildSyntheticProvider() {
2512
+ return {
2513
+ baseUrl: SYNTHETIC_BASE_URL,
2514
+ api: "anthropic-messages",
2515
+ models: SYNTHETIC_MODEL_CATALOG.map(buildSyntheticModelDefinition)
2516
+ };
2517
+ }
2518
+ function buildXiaomiProvider() {
2519
+ return {
2520
+ baseUrl: XIAOMI_BASE_URL,
2521
+ api: "anthropic-messages",
2522
+ models: [{
2523
+ id: XIAOMI_DEFAULT_MODEL_ID,
2524
+ name: "Xiaomi MiMo V2 Flash",
2525
+ reasoning: false,
2526
+ input: ["text"],
2527
+ cost: XIAOMI_DEFAULT_COST,
2528
+ contextWindow: XIAOMI_DEFAULT_CONTEXT_WINDOW,
2529
+ maxTokens: XIAOMI_DEFAULT_MAX_TOKENS
2530
+ }]
2531
+ };
2532
+ }
2533
+ async function buildVeniceProvider() {
2534
+ return {
2535
+ baseUrl: VENICE_BASE_URL,
2536
+ api: "openai-completions",
2537
+ models: await discoverVeniceModels()
2538
+ };
2539
+ }
2540
+ async function buildOllamaProvider() {
2541
+ return {
2542
+ baseUrl: OLLAMA_BASE_URL,
2543
+ api: "openai-completions",
2544
+ models: await discoverOllamaModels()
2545
+ };
2546
+ }
2547
+ function buildQianfanProvider() {
2548
+ return {
2549
+ baseUrl: QIANFAN_BASE_URL,
2550
+ api: "openai-completions",
2551
+ models: [{
2552
+ id: QIANFAN_DEFAULT_MODEL_ID,
2553
+ name: "DEEPSEEK V3.2",
2554
+ reasoning: true,
2555
+ input: ["text"],
2556
+ cost: QIANFAN_DEFAULT_COST,
2557
+ contextWindow: QIANFAN_DEFAULT_CONTEXT_WINDOW,
2558
+ maxTokens: QIANFAN_DEFAULT_MAX_TOKENS
2559
+ }, {
2560
+ id: "ernie-5.0-thinking-preview",
2561
+ name: "ERNIE-5.0-Thinking-Preview",
2562
+ reasoning: true,
2563
+ input: ["text", "image"],
2564
+ cost: QIANFAN_DEFAULT_COST,
2565
+ contextWindow: 119e3,
2566
+ maxTokens: 64e3
2567
+ }]
2568
+ };
2569
+ }
2570
+ async function resolveImplicitProviders(params) {
2571
+ const providers = {};
2572
+ const authStore = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
2573
+ const minimaxKey = resolveEnvApiKeyVarName("minimax") ?? resolveApiKeyFromProfiles({
2574
+ provider: "minimax",
2575
+ store: authStore
2576
+ });
2577
+ if (minimaxKey) providers.minimax = {
2578
+ ...buildMinimaxProvider(),
2579
+ apiKey: minimaxKey
2580
+ };
2581
+ if (listProfilesForProvider(authStore, "minimax-portal").length > 0) providers["minimax-portal"] = {
2582
+ ...buildMinimaxPortalProvider(),
2583
+ apiKey: MINIMAX_OAUTH_PLACEHOLDER
2584
+ };
2585
+ const moonshotKey = resolveEnvApiKeyVarName("moonshot") ?? resolveApiKeyFromProfiles({
2586
+ provider: "moonshot",
2587
+ store: authStore
2588
+ });
2589
+ if (moonshotKey) providers.moonshot = {
2590
+ ...buildMoonshotProvider(),
2591
+ apiKey: moonshotKey
2592
+ };
2593
+ const syntheticKey = resolveEnvApiKeyVarName("synthetic") ?? resolveApiKeyFromProfiles({
2594
+ provider: "synthetic",
2595
+ store: authStore
2596
+ });
2597
+ if (syntheticKey) providers.synthetic = {
2598
+ ...buildSyntheticProvider(),
2599
+ apiKey: syntheticKey
2600
+ };
2601
+ const veniceKey = resolveEnvApiKeyVarName("venice") ?? resolveApiKeyFromProfiles({
2602
+ provider: "venice",
2603
+ store: authStore
2604
+ });
2605
+ if (veniceKey) providers.venice = {
2606
+ ...await buildVeniceProvider(),
2607
+ apiKey: veniceKey
2608
+ };
2609
+ if (listProfilesForProvider(authStore, "qwen-portal").length > 0) providers["qwen-portal"] = {
2610
+ ...buildQwenPortalProvider(),
2611
+ apiKey: QWEN_PORTAL_OAUTH_PLACEHOLDER
2612
+ };
2613
+ const xiaomiKey = resolveEnvApiKeyVarName("xiaomi") ?? resolveApiKeyFromProfiles({
2614
+ provider: "xiaomi",
2615
+ store: authStore
2616
+ });
2617
+ if (xiaomiKey) providers.xiaomi = {
2618
+ ...buildXiaomiProvider(),
2619
+ apiKey: xiaomiKey
2620
+ };
2621
+ const cloudflareProfiles = listProfilesForProvider(authStore, "cloudflare-ai-gateway");
2622
+ for (const profileId of cloudflareProfiles) {
2623
+ const cred = authStore.profiles[profileId];
2624
+ if (cred?.type !== "api_key") continue;
2625
+ const accountId = cred.metadata?.accountId?.trim();
2626
+ const gatewayId = cred.metadata?.gatewayId?.trim();
2627
+ if (!accountId || !gatewayId) continue;
2628
+ const baseUrl = resolveCloudflareAiGatewayBaseUrl({
2629
+ accountId,
2630
+ gatewayId
2631
+ });
2632
+ if (!baseUrl) continue;
2633
+ const apiKey = resolveEnvApiKeyVarName("cloudflare-ai-gateway") ?? cred.key?.trim() ?? "";
2634
+ if (!apiKey) continue;
2635
+ providers["cloudflare-ai-gateway"] = {
2636
+ baseUrl,
2637
+ api: "anthropic-messages",
2638
+ apiKey,
2639
+ models: [buildCloudflareAiGatewayModelDefinition()]
2640
+ };
2641
+ break;
2642
+ }
2643
+ const ollamaKey = resolveEnvApiKeyVarName("ollama") ?? resolveApiKeyFromProfiles({
2644
+ provider: "ollama",
2645
+ store: authStore
2646
+ });
2647
+ if (ollamaKey) providers.ollama = {
2648
+ ...await buildOllamaProvider(),
2649
+ apiKey: ollamaKey
2650
+ };
2651
+ const qianfanKey = resolveEnvApiKeyVarName("qianfan") ?? resolveApiKeyFromProfiles({
2652
+ provider: "qianfan",
2653
+ store: authStore
2654
+ });
2655
+ if (qianfanKey) providers.qianfan = {
2656
+ ...buildQianfanProvider(),
2657
+ apiKey: qianfanKey
2658
+ };
2659
+ return providers;
2660
+ }
2661
+ async function resolveImplicitCopilotProvider(params) {
2662
+ const env = params.env ?? process.env;
2663
+ const authStore = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
2664
+ const hasProfile = listProfilesForProvider(authStore, "github-copilot").length > 0;
2665
+ const githubToken = (env.COPILOT_GITHUB_TOKEN ?? env.GH_TOKEN ?? env.GITHUB_TOKEN ?? "").trim();
2666
+ if (!hasProfile && !githubToken) return null;
2667
+ let selectedGithubToken = githubToken;
2668
+ if (!selectedGithubToken && hasProfile) {
2669
+ const profileId = listProfilesForProvider(authStore, "github-copilot")[0];
2670
+ const profile = profileId ? authStore.profiles[profileId] : void 0;
2671
+ if (profile && profile.type === "token") selectedGithubToken = profile.token;
2672
+ }
2673
+ let baseUrl = DEFAULT_COPILOT_API_BASE_URL;
2674
+ if (selectedGithubToken) try {
2675
+ baseUrl = (await resolveCopilotApiToken({
2676
+ githubToken: selectedGithubToken,
2677
+ env
2678
+ })).baseUrl;
2679
+ } catch {
2680
+ baseUrl = DEFAULT_COPILOT_API_BASE_URL;
2681
+ }
2682
+ return {
2683
+ baseUrl,
2684
+ models: []
2685
+ };
2686
+ }
2687
+ async function resolveImplicitBedrockProvider(params) {
2688
+ const env = params.env ?? process.env;
2689
+ const discoveryConfig = params.config?.models?.bedrockDiscovery;
2690
+ const enabled = discoveryConfig?.enabled;
2691
+ const hasAwsCreds = resolveAwsSdkEnvVarName(env) !== void 0;
2692
+ if (enabled === false) return null;
2693
+ if (enabled !== true && !hasAwsCreds) return null;
2694
+ const region = discoveryConfig?.region ?? env.AWS_REGION ?? env.AWS_DEFAULT_REGION ?? "us-east-1";
2695
+ const models = await discoverBedrockModels({
2696
+ region,
2697
+ config: discoveryConfig
2698
+ });
2699
+ if (models.length === 0) return null;
2700
+ return {
2701
+ baseUrl: `https://bedrock-runtime.${region}.amazonaws.com`,
2702
+ api: "bedrock-converse-stream",
2703
+ auth: "aws-sdk",
2704
+ models
2705
+ };
2706
+ }
2707
+
2708
+ //#endregion
2709
+ //#region src/agents/model-selection.ts
2710
+ const ANTHROPIC_MODEL_ALIASES = {
2711
+ "opus-4.6": "claude-opus-4-6",
2712
+ "opus-4.5": "claude-opus-4-5",
2713
+ "sonnet-4.5": "claude-sonnet-4-5"
2714
+ };
2715
+ function normalizeAliasKey(value) {
2716
+ return value.trim().toLowerCase();
2717
+ }
2718
+ function modelKey(provider, model) {
2719
+ return `${provider}/${model}`;
2720
+ }
2721
+ function normalizeProviderId(provider) {
2722
+ const normalized = provider.trim().toLowerCase();
2723
+ if (normalized === "z.ai" || normalized === "z-ai") return "zai";
2724
+ if (normalized === "opencode-zen") return "opencode";
2725
+ if (normalized === "qwen") return "qwen-portal";
2726
+ if (normalized === "kimi-code") return "kimi-coding";
2727
+ return normalized;
2728
+ }
2729
+ function isCliProvider(provider, cfg) {
2730
+ const normalized = normalizeProviderId(provider);
2731
+ if (normalized === "claude-cli") return true;
2732
+ if (normalized === "codex-cli") return true;
2733
+ const backends = cfg?.agents?.defaults?.cliBackends ?? {};
2734
+ return Object.keys(backends).some((key) => normalizeProviderId(key) === normalized);
2735
+ }
2736
+ function normalizeAnthropicModelId(model) {
2737
+ const trimmed = model.trim();
2738
+ if (!trimmed) return trimmed;
2739
+ return ANTHROPIC_MODEL_ALIASES[trimmed.toLowerCase()] ?? trimmed;
2740
+ }
2741
+ function normalizeProviderModelId(provider, model) {
2742
+ if (provider === "anthropic") return normalizeAnthropicModelId(model);
2743
+ if (provider === "google") return normalizeGoogleModelId(model);
2744
+ return model;
2745
+ }
2746
+ function parseModelRef(raw, defaultProvider) {
2747
+ const trimmed = raw.trim();
2748
+ if (!trimmed) return null;
2749
+ const slash = trimmed.indexOf("/");
2750
+ if (slash === -1) {
2751
+ const provider = normalizeProviderId(defaultProvider);
2752
+ return {
2753
+ provider,
2754
+ model: normalizeProviderModelId(provider, trimmed)
2755
+ };
2756
+ }
2757
+ const provider = normalizeProviderId(trimmed.slice(0, slash).trim());
2758
+ const model = trimmed.slice(slash + 1).trim();
2759
+ if (!provider || !model) return null;
2760
+ return {
2761
+ provider,
2762
+ model: normalizeProviderModelId(provider, model)
2763
+ };
2764
+ }
2765
+ function resolveAllowlistModelKey(raw, defaultProvider) {
2766
+ const parsed = parseModelRef(raw, defaultProvider);
2767
+ if (!parsed) return null;
2768
+ return modelKey(parsed.provider, parsed.model);
2769
+ }
2770
+ function buildConfiguredAllowlistKeys(params) {
2771
+ const rawAllowlist = Object.keys(params.cfg?.agents?.defaults?.models ?? {});
2772
+ if (rawAllowlist.length === 0) return null;
2773
+ const keys = /* @__PURE__ */ new Set();
2774
+ for (const raw of rawAllowlist) {
2775
+ const key = resolveAllowlistModelKey(String(raw ?? ""), params.defaultProvider);
2776
+ if (key) keys.add(key);
2777
+ }
2778
+ return keys.size > 0 ? keys : null;
2779
+ }
2780
+ function buildModelAliasIndex(params) {
2781
+ const byAlias = /* @__PURE__ */ new Map();
2782
+ const byKey = /* @__PURE__ */ new Map();
2783
+ const rawModels = params.cfg.agents?.defaults?.models ?? {};
2784
+ for (const [keyRaw, entryRaw] of Object.entries(rawModels)) {
2785
+ const parsed = parseModelRef(String(keyRaw ?? ""), params.defaultProvider);
2786
+ if (!parsed) continue;
2787
+ const alias = String(entryRaw?.alias ?? "").trim();
2788
+ if (!alias) continue;
2789
+ const aliasKey = normalizeAliasKey(alias);
2790
+ byAlias.set(aliasKey, {
2791
+ alias,
2792
+ ref: parsed
2793
+ });
2794
+ const key = modelKey(parsed.provider, parsed.model);
2795
+ const existing = byKey.get(key) ?? [];
2796
+ existing.push(alias);
2797
+ byKey.set(key, existing);
2798
+ }
2799
+ return {
2800
+ byAlias,
2801
+ byKey
2802
+ };
2803
+ }
2804
+ function resolveModelRefFromString(params) {
2805
+ const trimmed = params.raw.trim();
2806
+ if (!trimmed) return null;
2807
+ if (!trimmed.includes("/")) {
2808
+ const aliasKey = normalizeAliasKey(trimmed);
2809
+ const aliasMatch = params.aliasIndex?.byAlias.get(aliasKey);
2810
+ if (aliasMatch) return {
2811
+ ref: aliasMatch.ref,
2812
+ alias: aliasMatch.alias
2813
+ };
2814
+ }
2815
+ const parsed = parseModelRef(trimmed, params.defaultProvider);
2816
+ if (!parsed) return null;
2817
+ return { ref: parsed };
2818
+ }
2819
+ function resolveConfiguredModelRef(params) {
2820
+ const rawModel = (() => {
2821
+ const raw = params.cfg.agents?.defaults?.model;
2822
+ if (typeof raw === "string") return raw.trim();
2823
+ return raw?.primary?.trim() ?? "";
2824
+ })();
2825
+ if (rawModel) {
2826
+ const trimmed = rawModel.trim();
2827
+ const aliasIndex = buildModelAliasIndex({
2828
+ cfg: params.cfg,
2829
+ defaultProvider: params.defaultProvider
2830
+ });
2831
+ if (!trimmed.includes("/")) {
2832
+ const aliasKey = normalizeAliasKey(trimmed);
2833
+ const aliasMatch = aliasIndex.byAlias.get(aliasKey);
2834
+ if (aliasMatch) return aliasMatch.ref;
2835
+ console.warn(`[Synurex] Model "${trimmed}" specified without provider. Falling back to "anthropic/${trimmed}". Please use "anthropic/${trimmed}" in your config.`);
2836
+ return {
2837
+ provider: "anthropic",
2838
+ model: trimmed
2839
+ };
2840
+ }
2841
+ const resolved = resolveModelRefFromString({
2842
+ raw: trimmed,
2843
+ defaultProvider: params.defaultProvider,
2844
+ aliasIndex
2845
+ });
2846
+ if (resolved) return resolved.ref;
2847
+ }
2848
+ return {
2849
+ provider: params.defaultProvider,
2850
+ model: params.defaultModel
2851
+ };
2852
+ }
2853
+ function resolveDefaultModelForAgent(params) {
2854
+ const agentModelOverride = params.agentId ? resolveAgentModelPrimary(params.cfg, params.agentId) : void 0;
2855
+ return resolveConfiguredModelRef({
2856
+ cfg: agentModelOverride && agentModelOverride.length > 0 ? {
2857
+ ...params.cfg,
2858
+ agents: {
2859
+ ...params.cfg.agents,
2860
+ defaults: {
2861
+ ...params.cfg.agents?.defaults,
2862
+ model: {
2863
+ ...typeof params.cfg.agents?.defaults?.model === "object" ? params.cfg.agents.defaults.model : void 0,
2864
+ primary: agentModelOverride
2865
+ }
2866
+ }
2867
+ }
2868
+ } : params.cfg,
2869
+ defaultProvider: DEFAULT_PROVIDER,
2870
+ defaultModel: DEFAULT_MODEL
2871
+ });
2872
+ }
2873
+ function buildAllowedModelSet(params) {
2874
+ const rawAllowlist = (() => {
2875
+ const modelMap = params.cfg.agents?.defaults?.models ?? {};
2876
+ return Object.keys(modelMap);
2877
+ })();
2878
+ const allowAny = rawAllowlist.length === 0;
2879
+ const defaultModel = params.defaultModel?.trim();
2880
+ const defaultKey = defaultModel && params.defaultProvider ? modelKey(params.defaultProvider, defaultModel) : void 0;
2881
+ const catalogKeys = new Set(params.catalog.map((entry) => modelKey(entry.provider, entry.id)));
2882
+ if (allowAny) {
2883
+ if (defaultKey) catalogKeys.add(defaultKey);
2884
+ return {
2885
+ allowAny: true,
2886
+ allowedCatalog: params.catalog,
2887
+ allowedKeys: catalogKeys
2888
+ };
2889
+ }
2890
+ const allowedKeys = /* @__PURE__ */ new Set();
2891
+ const configuredProviders = params.cfg.models?.providers ?? {};
2892
+ for (const raw of rawAllowlist) {
2893
+ const parsed = parseModelRef(String(raw), params.defaultProvider);
2894
+ if (!parsed) continue;
2895
+ const key = modelKey(parsed.provider, parsed.model);
2896
+ const providerKey = normalizeProviderId(parsed.provider);
2897
+ if (isCliProvider(parsed.provider, params.cfg)) allowedKeys.add(key);
2898
+ else if (catalogKeys.has(key)) allowedKeys.add(key);
2899
+ else if (configuredProviders[providerKey] != null) allowedKeys.add(key);
2900
+ }
2901
+ if (defaultKey) allowedKeys.add(defaultKey);
2902
+ const allowedCatalog = params.catalog.filter((entry) => allowedKeys.has(modelKey(entry.provider, entry.id)));
2903
+ if (allowedCatalog.length === 0 && allowedKeys.size === 0) {
2904
+ if (defaultKey) catalogKeys.add(defaultKey);
2905
+ return {
2906
+ allowAny: true,
2907
+ allowedCatalog: params.catalog,
2908
+ allowedKeys: catalogKeys
2909
+ };
2910
+ }
2911
+ return {
2912
+ allowAny: false,
2913
+ allowedCatalog,
2914
+ allowedKeys
2915
+ };
2916
+ }
2917
+ function getModelRefStatus(params) {
2918
+ const allowed = buildAllowedModelSet({
2919
+ cfg: params.cfg,
2920
+ catalog: params.catalog,
2921
+ defaultProvider: params.defaultProvider,
2922
+ defaultModel: params.defaultModel
2923
+ });
2924
+ const key = modelKey(params.ref.provider, params.ref.model);
2925
+ return {
2926
+ key,
2927
+ inCatalog: params.catalog.some((entry) => modelKey(entry.provider, entry.id) === key),
2928
+ allowAny: allowed.allowAny,
2929
+ allowed: allowed.allowAny || allowed.allowedKeys.has(key)
2930
+ };
2931
+ }
2932
+ function resolveAllowedModelRef(params) {
2933
+ const trimmed = params.raw.trim();
2934
+ if (!trimmed) return { error: "invalid model: empty" };
2935
+ const aliasIndex = buildModelAliasIndex({
2936
+ cfg: params.cfg,
2937
+ defaultProvider: params.defaultProvider
2938
+ });
2939
+ const resolved = resolveModelRefFromString({
2940
+ raw: trimmed,
2941
+ defaultProvider: params.defaultProvider,
2942
+ aliasIndex
2943
+ });
2944
+ if (!resolved) return { error: `invalid model: ${trimmed}` };
2945
+ const status = getModelRefStatus({
2946
+ cfg: params.cfg,
2947
+ catalog: params.catalog,
2948
+ ref: resolved.ref,
2949
+ defaultProvider: params.defaultProvider,
2950
+ defaultModel: params.defaultModel
2951
+ });
2952
+ if (!status.allowed) return { error: `model not allowed: ${status.key}` };
2953
+ return {
2954
+ ref: resolved.ref,
2955
+ key: status.key
2956
+ };
2957
+ }
2958
+ function resolveThinkingDefault(params) {
2959
+ const configured = params.cfg.agents?.defaults?.thinkingDefault;
2960
+ if (configured) return configured;
2961
+ if ((params.catalog?.find((entry) => entry.provider === params.provider && entry.id === params.model))?.reasoning) return "low";
2962
+ return "off";
2963
+ }
2964
+ /**
2965
+ * Resolve the model configured for Gmail hook processing.
2966
+ * Returns null if hooks.gmail.model is not set.
2967
+ */
2968
+ function resolveHooksGmailModel(params) {
2969
+ const hooksModel = params.cfg.hooks?.gmail?.model;
2970
+ if (!hooksModel?.trim()) return null;
2971
+ const aliasIndex = buildModelAliasIndex({
2972
+ cfg: params.cfg,
2973
+ defaultProvider: params.defaultProvider
2974
+ });
2975
+ return resolveModelRefFromString({
2976
+ raw: hooksModel,
2977
+ defaultProvider: params.defaultProvider,
2978
+ aliasIndex
2979
+ })?.ref ?? null;
2980
+ }
2981
+
2982
+ //#endregion
2983
+ export { markAuthProfileFailure as $, SYNTHETIC_BASE_URL as A, resolveModelAuthMode as B, resolveImplicitBedrockProvider as C, DEFAULT_PROVIDER as Ct, VENICE_DEFAULT_MODEL_REF as D, VENICE_BASE_URL as E, getCustomProviderApiKey as F, shouldDeferShellEnvFallback as G, getShellPathFromLoginShell as H, requireApiKey as I, buildCloudflareAiGatewayModelDefinition as J, shouldEnableShellEnvFallback as K, resolveApiKeyForProvider as L, SYNTHETIC_MODEL_CATALOG as M, buildSyntheticModelDefinition as N, VENICE_MODEL_CATALOG as O, getApiKeyForModel as P, isProfileInCooldown as Q, resolveAwsSdkEnvVarName as R, normalizeProviders as S, DEFAULT_MODEL as St, resolveImplicitProviders as T, loadShellEnvFallback as U, getShellEnvAppliedKeys as V, resolveShellEnvFallbackTimeoutMs as W, auth_profiles_exports as X, resolveCloudflareAiGatewayBaseUrl as Y, resolveAuthProfileOrder as Z, QIANFAN_DEFAULT_MODEL_ID as _, resolveSynurexAgentDir as _t, isCliProvider as a, generateChutesPkce as at, buildXiaomiProvider as b, CODEX_CLI_PROFILE_ID as bt, parseModelRef as c, listProfilesForProvider as ct, resolveConfiguredModelRef as d, upsertAuthProfile as dt, markAuthProfileUsed as et, resolveDefaultModelForAgent as f, ensureAuthProfileStore as ft, QIANFAN_BASE_URL as g, resolveAuthStorePathForDisplay as gt, resolveThinkingDefault as h, resolveAuthStorePath as ht, getModelRefStatus as i, exchangeChutesCodeForTokens as it, SYNTHETIC_DEFAULT_MODEL_REF as j, buildVeniceModelDefinition as k, resolveAllowedModelRef as l, markAuthProfileGood as lt, resolveModelRefFromString as m, updateAuthProfileStoreWithLock as mt, buildConfiguredAllowlistKeys as n, resolveApiKeyForProfile as nt, modelKey as o, parseOAuthCallbackInput as ot, resolveHooksGmailModel as p, loadAuthProfileStore as pt, CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF as q, buildModelAliasIndex as r, CHUTES_AUTHORIZE_ENDPOINT as rt, normalizeProviderId as s, repairOAuthProfileIdMismatch as st, buildAllowedModelSet as t, resolveProfileUnusableUntilForDisplay as tt, resolveAllowlistModelKey as u, setAuthProfileOrder as ut, XIAOMI_DEFAULT_MODEL_ID as v, resolveAuthProfileDisplayLabel as vt, resolveImplicitCopilotProvider as w, normalizeGoogleModelId as x, DEFAULT_CONTEXT_TOKENS as xt, buildQianfanProvider as y, CLAUDE_CLI_PROFILE_ID as yt, resolveEnvApiKey as z };