xaq-cli 0.0.0 → 0.1.0-nightly.72

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 (227) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +79 -0
  3. package/dist/admin-5gThRwgj.js +162 -0
  4. package/dist/admin-5gThRwgj.js.map +1 -0
  5. package/dist/admin-Btrm8mCd.js +218 -0
  6. package/dist/admin-Btrm8mCd.js.map +1 -0
  7. package/dist/admin-CWofnT_Q.js +2 -0
  8. package/dist/api-BFpElwqK.js +89 -0
  9. package/dist/api-BFpElwqK.js.map +1 -0
  10. package/dist/audit-BB7jK9Z5.js +2 -0
  11. package/dist/audit-BVYknW2i.js +79 -0
  12. package/dist/audit-BVYknW2i.js.map +1 -0
  13. package/dist/auth-CXmBdMqw.js +2 -0
  14. package/dist/auth-D-GmwNv-.js +550 -0
  15. package/dist/auth-D-GmwNv-.js.map +1 -0
  16. package/dist/brand--ZB8jTn1.js +32 -0
  17. package/dist/brand--ZB8jTn1.js.map +1 -0
  18. package/dist/bus-Cz0flS37.js +12 -0
  19. package/dist/bus-Cz0flS37.js.map +1 -0
  20. package/dist/bus-OKIGut72.js +2 -0
  21. package/dist/cli.js +234 -0
  22. package/dist/cli.js.map +1 -0
  23. package/dist/commands-BNVLjYXA.js +167 -0
  24. package/dist/commands-BNVLjYXA.js.map +1 -0
  25. package/dist/commands-CdA6-WE7.js +112 -0
  26. package/dist/commands-CdA6-WE7.js.map +1 -0
  27. package/dist/config-C9XmYZWO.js +94 -0
  28. package/dist/config-C9XmYZWO.js.map +1 -0
  29. package/dist/config-CNVi0v5t.js +2 -0
  30. package/dist/connect-TtJ9n0Rw.js +362 -0
  31. package/dist/connect-TtJ9n0Rw.js.map +1 -0
  32. package/dist/content-C1lKMxFS.js +1170 -0
  33. package/dist/content-C1lKMxFS.js.map +1 -0
  34. package/dist/content-worker.js +28 -0
  35. package/dist/content-worker.js.map +1 -0
  36. package/dist/crypto-fv2fj3S8.js +75 -0
  37. package/dist/crypto-fv2fj3S8.js.map +1 -0
  38. package/dist/db-BEUEUPyP.js +561 -0
  39. package/dist/db-BEUEUPyP.js.map +1 -0
  40. package/dist/db-Q5BQuwga.js +2 -0
  41. package/dist/errors-FbMS3QBo.js +39 -0
  42. package/dist/errors-FbMS3QBo.js.map +1 -0
  43. package/dist/filter-Ck6OMxvu.js +158 -0
  44. package/dist/filter-Ck6OMxvu.js.map +1 -0
  45. package/dist/hermes-CKyzt1mH.js +3 -0
  46. package/dist/hermes-DHnDTYJp.js +1023 -0
  47. package/dist/hermes-DHnDTYJp.js.map +1 -0
  48. package/dist/import-DsN5NZT3.js +910 -0
  49. package/dist/import-DsN5NZT3.js.map +1 -0
  50. package/dist/instance-CwWbFbJ8.js +2 -0
  51. package/dist/instance-Dj9TpJB2.js +195 -0
  52. package/dist/instance-Dj9TpJB2.js.map +1 -0
  53. package/dist/listen-B9iO7HgQ.js +1568 -0
  54. package/dist/listen-B9iO7HgQ.js.map +1 -0
  55. package/dist/listen-CXVKG9XD.js +2 -0
  56. package/dist/manage-Bo6COB4p.js +477 -0
  57. package/dist/manage-Bo6COB4p.js.map +1 -0
  58. package/dist/manage-DoXqvjnU.js +2 -0
  59. package/dist/mcpheader-B8c5YO1B.js +2 -0
  60. package/dist/mcpheader-C9H4vudu.js +185 -0
  61. package/dist/mcpheader-C9H4vudu.js.map +1 -0
  62. package/dist/mcpsetup-BnHudwpq.js +2 -0
  63. package/dist/mcpsetup-DXXo2qjf.js +1053 -0
  64. package/dist/mcpsetup-DXXo2qjf.js.map +1 -0
  65. package/dist/node-check-CjTk6VNL.js +24 -0
  66. package/dist/node-check-CjTk6VNL.js.map +1 -0
  67. package/dist/paths-d-C2kdjo.js +2 -0
  68. package/dist/paths-yzOKD6ow.js +46 -0
  69. package/dist/paths-yzOKD6ow.js.map +1 -0
  70. package/dist/profile-CcMZ4hn7.js +2 -0
  71. package/dist/profile-NmMKAczz.js +222 -0
  72. package/dist/profile-NmMKAczz.js.map +1 -0
  73. package/dist/prompt-CKMQx_MJ.js +114 -0
  74. package/dist/prompt-CKMQx_MJ.js.map +1 -0
  75. package/dist/recipes-C7TIDlRj.js +3 -0
  76. package/dist/recipes-DG_-doGq.js +314 -0
  77. package/dist/recipes-DG_-doGq.js.map +1 -0
  78. package/dist/send-Dk-t8ia-.js +108 -0
  79. package/dist/send-Dk-t8ia-.js.map +1 -0
  80. package/dist/server-CDqDp1q3.js +20640 -0
  81. package/dist/server-CDqDp1q3.js.map +1 -0
  82. package/dist/service-BVn3soZZ.js +766 -0
  83. package/dist/service-BVn3soZZ.js.map +1 -0
  84. package/dist/service-BaWGPmSd.js +2 -0
  85. package/dist/service-C7jfo-Ex.js +457 -0
  86. package/dist/service-C7jfo-Ex.js.map +1 -0
  87. package/dist/service-DxDyKDQ-.js +2 -0
  88. package/dist/settings-B5qSHxRM.js +134 -0
  89. package/dist/settings-B5qSHxRM.js.map +1 -0
  90. package/dist/settings-DQvZaMN1.js +2 -0
  91. package/dist/setup-token-CwuSzfLK.js +48 -0
  92. package/dist/setup-token-CwuSzfLK.js.map +1 -0
  93. package/dist/skill/SKILL.md +445 -0
  94. package/dist/skill-1UQj3qgW.js +69 -0
  95. package/dist/skill-1UQj3qgW.js.map +1 -0
  96. package/dist/skill-pelq18JQ.js +2 -0
  97. package/dist/ssrf-BlVpGZ7C.js +181 -0
  98. package/dist/ssrf-BlVpGZ7C.js.map +1 -0
  99. package/dist/types-BhJDbSzE.js +135 -0
  100. package/dist/types-BhJDbSzE.js.map +1 -0
  101. package/dist/ui-B8Sd4Y7Y.js +81 -0
  102. package/dist/ui-B8Sd4Y7Y.js.map +1 -0
  103. package/dist/urls-Dp8pBGMU.js +2 -0
  104. package/dist/urls-U_LfYV61.js +27 -0
  105. package/dist/urls-U_LfYV61.js.map +1 -0
  106. package/dist/version-BxH7OuWD.js +20 -0
  107. package/dist/version-BxH7OuWD.js.map +1 -0
  108. package/dist/web/assets/_agentId-DonOCOlC.js +1 -0
  109. package/dist/web/assets/_app-B7t5lEia.js +1 -0
  110. package/dist/web/assets/_app-DMTGqYpM.js +65 -0
  111. package/dist/web/assets/_connectionId-DR5vFXOg.js +1 -0
  112. package/dist/web/assets/_webhookId-LfUlsULp.js +1 -0
  113. package/dist/web/assets/account-status-CEszs13C.js +1 -0
  114. package/dist/web/assets/accounts-5m7aiXuZ.js +1 -0
  115. package/dist/web/assets/accounts-list-YfJzThZa.js +1 -0
  116. package/dist/web/assets/activity-DOIe7SAg.js +1 -0
  117. package/dist/web/assets/add-connection-C8JR-13R.js +1 -0
  118. package/dist/web/assets/agent-create-form-CPxnPYH4.js +1 -0
  119. package/dist/web/assets/agents-B2Qj5KxT.js +1 -0
  120. package/dist/web/assets/approvals-BGaVaoFy.js +1 -0
  121. package/dist/web/assets/approve._id-BLrQnzPM.js +1 -0
  122. package/dist/web/assets/arrow-left-DZVAXoKj.js +1 -0
  123. package/dist/web/assets/arrow-right-C2zcqRr2.js +1 -0
  124. package/dist/web/assets/attention-gO9Nw5uW.js +1 -0
  125. package/dist/web/assets/audit-BPXXre8S.js +1 -0
  126. package/dist/web/assets/audit-bits-CGyIprzK.js +1 -0
  127. package/dist/web/assets/bell-ring-ig3zn1iS.js +1 -0
  128. package/dist/web/assets/bot-Zk76q_39.js +1 -0
  129. package/dist/web/assets/calendar-notice-DsCfq3VJ.js +1 -0
  130. package/dist/web/assets/calendar-plus-Cycfkk0y.js +1 -0
  131. package/dist/web/assets/calendar-setup-Pn61Wj1n.js +2 -0
  132. package/dist/web/assets/card-GSO5o-Ug.js +1 -0
  133. package/dist/web/assets/check-check-Ds1bPIGv.js +1 -0
  134. package/dist/web/assets/checkbox-B937U-Fd.js +1 -0
  135. package/dist/web/assets/chevron-right-Cqh4mDk1.js +1 -0
  136. package/dist/web/assets/chips-input-2xWDofmE.js +1 -0
  137. package/dist/web/assets/choice-cards-CgAIqBGX.js +1 -0
  138. package/dist/web/assets/circle-x-DcU-0zVh.js +1 -0
  139. package/dist/web/assets/command-khhto70y.js +1 -0
  140. package/dist/web/assets/common-BPZV8TFb.js +1 -0
  141. package/dist/web/assets/connect-agent-guide-CJdw31p2.js +1 -0
  142. package/dist/web/assets/connect-host-lr2c3xWh.js +6 -0
  143. package/dist/web/assets/connection-row-DYx_5o0c.js +1 -0
  144. package/dist/web/assets/connections-C4NOFb5R.js +1 -0
  145. package/dist/web/assets/data-table-kW1pkRB5.js +1 -0
  146. package/dist/web/assets/empty-DzTDioBP.js +1 -0
  147. package/dist/web/assets/events-C9zJnPKK.js +1 -0
  148. package/dist/web/assets/eye-B9gT1QSq.js +1 -0
  149. package/dist/web/assets/eye-off-Diktqz_g.js +1 -0
  150. package/dist/web/assets/field-C6ejurju.js +1 -0
  151. package/dist/web/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  152. package/dist/web/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  153. package/dist/web/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  154. package/dist/web/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  155. package/dist/web/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
  156. package/dist/web/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
  157. package/dist/web/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
  158. package/dist/web/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
  159. package/dist/web/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
  160. package/dist/web/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
  161. package/dist/web/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  162. package/dist/web/assets/get-started-C38bq1gZ.js +2 -0
  163. package/dist/web/assets/hidden-chars-Dr9TxfvF.js +1 -0
  164. package/dist/web/assets/index-DGzo3kGh.js +11 -0
  165. package/dist/web/assets/index-zKOCQLGX.css +2 -0
  166. package/dist/web/assets/input-CWwJgozn.js +1 -0
  167. package/dist/web/assets/input-group-HG8OXcJ4.js +1 -0
  168. package/dist/web/assets/label-multi-select-sH8mllw8.js +1 -0
  169. package/dist/web/assets/labels-B5UqVwFo.js +1 -0
  170. package/dist/web/assets/laptop-BxJ4Nbj7.js +1 -0
  171. package/dist/web/assets/last-call-D-O5O94z.js +1 -0
  172. package/dist/web/assets/listener-handled-HNCuVrQ7.js +1 -0
  173. package/dist/web/assets/login-DaeKclcf.js +1 -0
  174. package/dist/web/assets/mail-C5fm2pTC.js +1 -0
  175. package/dist/web/assets/mcp-call-UoOTPFyh.js +1 -0
  176. package/dist/web/assets/mcp-call-card-Cr-OEDX2.js +3 -0
  177. package/dist/web/assets/message-square-quote-se8Bf3RP.js +1 -0
  178. package/dist/web/assets/mutations-CLPqJ6cj.js +1 -0
  179. package/dist/web/assets/network-igNw0VVx.js +1 -0
  180. package/dist/web/assets/pairing-XjuaVr2u.js +1 -0
  181. package/dist/web/assets/pairing-notifier-KPzOEZSO.js +1 -0
  182. package/dist/web/assets/paperclip-znS4iTrg.js +1 -0
  183. package/dist/web/assets/password-input-DV3aqcNf.js +1 -0
  184. package/dist/web/assets/pause-o-dK3khK.js +1 -0
  185. package/dist/web/assets/pencil-DkPFAhEq.js +1 -0
  186. package/dist/web/assets/play-DvCHND93.js +1 -0
  187. package/dist/web/assets/plug-CXAniEiR.js +1 -0
  188. package/dist/web/assets/plug-zap-BwR-l5wb.js +1 -0
  189. package/dist/web/assets/plus-B_TUslu3.js +1 -0
  190. package/dist/web/assets/preload-helper-Cc_aKyUb.js +1 -0
  191. package/dist/web/assets/public-url-rF2Xjyel.js +1 -0
  192. package/dist/web/assets/queries-Cv3nXx0U.js +42 -0
  193. package/dist/web/assets/refresh-cw-Ch5FNrby.js +1 -0
  194. package/dist/web/assets/revealed-keys-C_9NtJPY.js +1 -0
  195. package/dist/web/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  196. package/dist/web/assets/rotate-ccw-B-mzPDk0.js +1 -0
  197. package/dist/web/assets/search-CTVKGomS.js +1 -0
  198. package/dist/web/assets/select-Bb806bpq.js +1 -0
  199. package/dist/web/assets/send-DuMVuYs1.js +1 -0
  200. package/dist/web/assets/settings-BWauhfFf.js +1 -0
  201. package/dist/web/assets/setup-B7bNKQOp.js +1 -0
  202. package/dist/web/assets/sheet-CYPwpUsH.js +1 -0
  203. package/dist/web/assets/shield-alert-CSYB-ThV.js +1 -0
  204. package/dist/web/assets/shield-check-BulpsYqK.js +1 -0
  205. package/dist/web/assets/sparkles-CUTiob4K.js +1 -0
  206. package/dist/web/assets/stamp-BNXUGNa3.js +1 -0
  207. package/dist/web/assets/step-url-51aMNak-.js +1 -0
  208. package/dist/web/assets/stream-Du7fY5_Y.js +1 -0
  209. package/dist/web/assets/tag-I5_-1jFL.js +1 -0
  210. package/dist/web/assets/terminal-BvxDFTJc.js +1 -0
  211. package/dist/web/assets/test-email-button-DYi7V_6X.js +1 -0
  212. package/dist/web/assets/toggle-group-Bdo1gmQ1.js +1 -0
  213. package/dist/web/assets/trash-Ci0aICEl.js +1 -0
  214. package/dist/web/assets/use-delivery-speed-BBh7W2q6.js +1 -0
  215. package/dist/web/assets/use-label-names-BXicesnP.js +1 -0
  216. package/dist/web/assets/use-sign-out-CPrY_oVO.js +1 -0
  217. package/dist/web/assets/useInfiniteQuery-DJLIM8yJ.js +1 -0
  218. package/dist/web/assets/useQuery-MrTwwNy5.js +1 -0
  219. package/dist/web/assets/useRouterState-D4OBK8l5.js +1 -0
  220. package/dist/web/assets/webhook-DjeeZiNC.js +1 -0
  221. package/dist/web/assets/webhook-bits-jw-y2D3u.js +1 -0
  222. package/dist/web/assets/webhook-sheet-B8h0skDe.js +34 -0
  223. package/dist/web/assets/webhooks-Cfsdpoyd.js +1 -0
  224. package/dist/web/assets/x-MF2TZ9aG.js +1 -0
  225. package/dist/web/favicon.svg +1 -0
  226. package/dist/web/index.html +27 -0
  227. package/package.json +98 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpsetup-DXXo2qjf.js","names":["UNREADABLE","escapeRe"],"sources":["../server/connections-cli/toml.ts","../server/connections-cli/yaml.ts","../server/listen/mcpsetup.ts"],"sourcesContent":["/**\n * A small TOML reader for Codex's `[mcp_servers.*]` tables, without a TOML library. It reads table headers,\n * dotted and quoted keys, basic and literal strings, numbers, booleans, single- or multi-line arrays of those,\n * and one-line inline tables. Multi-line strings, dates and arrays of tables are UNREADABLE (for their value or\n * table), so the caller can skip an entry it can't read instead of guessing.\n */\n\nexport const UNREADABLE = Symbol(\"unreadable\");\nexport type TomlValue = string | number | boolean | typeof UNREADABLE | TomlValue[] | { [key: string]: TomlValue };\nexport type TomlTable = { [key: string]: TomlValue };\n\nclass Cursor {\n i = 0;\n constructor(readonly s: string) {}\n ws(): void {\n while (this.i < this.s.length && /[ \\t]/.test(this.s[this.i]!)) this.i++;\n }\n /** Whitespace, newlines and comments (inside arrays). */\n wsAll(): void {\n for (;;) {\n while (this.i < this.s.length && /[ \\t\\r\\n]/.test(this.s[this.i]!)) this.i++;\n if (this.s[this.i] !== \"#\") return;\n while (this.i < this.s.length && this.s[this.i] !== \"\\n\") this.i++;\n }\n }\n peek(): string | undefined {\n return this.s[this.i];\n }\n done(): boolean {\n return this.i >= this.s.length;\n }\n}\n\nclass Unreadable extends Error {}\n\nconst ESCAPES: Record<string, string> = { b: \"\\b\", t: \"\\t\", n: \"\\n\", f: \"\\f\", r: \"\\r\", '\"': '\"', \"\\\\\": \"\\\\\", e: \"\\x1b\" };\n\nfunction readString(c: Cursor): string {\n const q = c.peek();\n if (c.s.startsWith(`${q}${q}${q}`, c.i)) throw new Unreadable(\"multi-line string\");\n c.i++;\n let out = \"\";\n while (!c.done()) {\n const ch = c.s[c.i++]!;\n if (ch === \"\\n\") break;\n if (ch === q) return out;\n if (q === '\"' && ch === \"\\\\\") {\n const e = c.s[c.i++]!;\n if (ESCAPES[e] !== undefined) out += ESCAPES[e];\n else if (e === \"u\" || e === \"U\") {\n const len = e === \"u\" ? 4 : 8;\n const hex = c.s.slice(c.i, c.i + len);\n if (!/^[0-9a-fA-F]+$/.test(hex) || hex.length !== len) throw new Unreadable(\"bad escape\");\n out += String.fromCodePoint(Number.parseInt(hex, 16));\n c.i += len;\n } else throw new Unreadable(\"bad escape\");\n } else out += ch;\n }\n throw new Unreadable(\"unterminated string\");\n}\n\nfunction readKey(c: Cursor): string[] {\n const parts: string[] = [];\n for (;;) {\n c.ws();\n const ch = c.peek();\n if (ch === '\"' || ch === \"'\") parts.push(readString(c));\n else {\n const m = /^[A-Za-z0-9_-]+/.exec(c.s.slice(c.i));\n if (!m) throw new Unreadable(\"bad key\");\n parts.push(m[0]);\n c.i += m[0].length;\n }\n c.ws();\n if (c.peek() !== \".\") return parts;\n c.i++;\n }\n}\n\nfunction readValue(c: Cursor, multiline: boolean): TomlValue {\n const ch = c.peek();\n if (ch === '\"' || ch === \"'\") return readString(c);\n if (ch === \"[\") {\n c.i++;\n const items: TomlValue[] = [];\n for (;;) {\n if (multiline) c.wsAll();\n else c.ws();\n if (c.peek() === \"]\") {\n c.i++;\n return items;\n }\n items.push(readValue(c, multiline));\n if (multiline) c.wsAll();\n else c.ws();\n if (c.peek() === \",\") c.i++;\n else if (c.peek() !== \"]\") throw new Unreadable(\"bad array\");\n }\n }\n if (ch === \"{\") {\n c.i++;\n const table: TomlTable = {};\n c.ws();\n if (c.peek() === \"}\") {\n c.i++;\n return table;\n }\n for (;;) {\n const key = readKey(c);\n if (c.peek() !== \"=\") throw new Unreadable(\"bad inline table\");\n c.i++;\n c.ws();\n setPath(table, key, readValue(c, false));\n c.ws();\n if (c.peek() === \",\") {\n c.i++;\n continue;\n }\n if (c.peek() === \"}\") {\n c.i++;\n return table;\n }\n throw new Unreadable(\"bad inline table\");\n }\n }\n const m = /^[^\\s,\\]}#]+/.exec(c.s.slice(c.i));\n if (!m) throw new Unreadable(\"missing value\");\n c.i += m[0].length;\n if (m[0] === \"true\") return true;\n if (m[0] === \"false\") return false;\n const n = m[0].replace(/_/g, \"\");\n if (/^[-+]?(\\d+(\\.\\d+)?([eE][-+]?\\d+)?|0x[0-9a-fA-F]+|0o[0-7]+|0b[01]+)$/.test(n)) return Number(n);\n throw new Unreadable(\"unsupported value\");\n}\n\nfunction setPath(table: TomlTable, path: string[], value: TomlValue): void {\n let t = table;\n for (const p of path.slice(0, -1)) {\n const next = t[p];\n if (next === undefined) t = t[p] = {};\n else if (typeof next === \"object\" && !Array.isArray(next)) t = next as TomlTable;\n else throw new Unreadable(\"key redefined\");\n }\n const last = path[path.length - 1]!;\n if (Object.hasOwn(t, last)) throw new Unreadable(\"key redefined\");\n t[last] = value;\n}\n\nfunction tableAt(root: TomlTable, path: string[]): TomlTable {\n let t = root;\n for (const p of path) {\n const next = t[p];\n if (next === undefined) t = t[p] = {};\n else if (typeof next === \"object\" && !Array.isArray(next)) t = next as TomlTable;\n else throw new Unreadable(\"table redefined\");\n }\n return t;\n}\n\n/**\n * The `mcp_servers` table of a Codex config.toml: server name → entry. A server whose table (or a value in it)\n * can't be read maps to UNREADABLE. Problems outside mcp_servers are ignored.\n */\nexport function readTomlMcpServers(toml: string): { [name: string]: TomlTable | typeof UNREADABLE } {\n const root: TomlTable = {};\n const bad = new Set<string>();\n let current: string[] = [];\n const lines = toml.replace(/^/, \"\").split(\"\\n\");\n for (let n = 0; n < lines.length; n++) {\n const line = lines[n]!;\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n if (trimmed.startsWith(\"[[\")) {\n const c = new Cursor(trimmed.slice(2));\n try {\n current = [\"\\u0000array\", ...readKey(c)];\n } catch {\n current = [\"\\u0000array\"];\n }\n if (current[1] === \"mcp_servers\" && current[2]) bad.add(current[2]);\n continue;\n }\n if (trimmed.startsWith(\"[\")) {\n const c = new Cursor(trimmed.slice(1));\n try {\n current = readKey(c);\n if (c.peek() !== \"]\") throw new Unreadable(\"bad header\");\n if (current[0] === \"mcp_servers\") tableAt(root, current);\n } catch {\n current = [\"\\u0000bad\"];\n }\n continue;\n }\n if (current[0] !== \"mcp_servers\" && !/^\\s*mcp_servers\\s*[.=]/.test(line)) continue;\n // A value may continue over several lines (multi-line arrays): take lines until it parses.\n let text = line;\n let consumed = n;\n let parsed: { key: string[]; value: TomlValue } | null = null;\n for (;;) {\n const c = new Cursor(text);\n try {\n const key = readKey(c);\n if (c.peek() !== \"=\") throw new Unreadable(\"missing =\");\n c.i++;\n c.ws();\n const value = readValue(c, true);\n c.ws();\n if (!c.done() && c.peek() !== \"#\") throw new Unreadable(\"trailing characters\");\n parsed = { key, value };\n break;\n } catch {\n const open = (text.match(/\\[/g) ?? []).length > (text.match(/]/g) ?? []).length;\n if (!open || consumed + 1 >= lines.length) break;\n text += `\\n${lines[++consumed]}`;\n }\n }\n n = consumed;\n const full = parsed ? [...current, ...parsed.key] : current;\n const server = full[0] === \"mcp_servers\" ? full[1] : current[1];\n if (!parsed) {\n if (server) bad.add(server);\n continue;\n }\n try {\n setPath(root, full, parsed.value);\n } catch {\n if (server) bad.add(server);\n }\n }\n const servers = root.mcp_servers;\n const out: { [name: string]: TomlTable | typeof UNREADABLE } = {};\n if (servers && typeof servers === \"object\" && !Array.isArray(servers)) {\n for (const [name, entry] of Object.entries(servers as TomlTable)) {\n out[name] = bad.has(name) || !entry || typeof entry !== \"object\" || Array.isArray(entry) ? UNREADABLE : (entry as TomlTable);\n }\n }\n for (const name of bad) out[name] = UNREADABLE;\n return out;\n}\n","/**\n * A small reader for the `mcp_servers:` block of a Hermes config.yaml, without a YAML library (like\n * server/listen/mcpsetup.ts). It handles the block style Hermes writes and documents: nested maps, plain and\n * quoted scalars, flow sequences of scalars (`args: [\"-y\", \"pkg\"]`) and block sequences of scalars. Anything else\n * (anchors, block scalars, flow maps, tabs) becomes UNREADABLE for that value, so the caller can skip the entry\n * that uses it instead of guessing. Only the mcp_servers block is read: the rest of the file never matters.\n */\n\nexport const UNREADABLE = Symbol(\"unreadable\");\nexport type YamlValue = string | number | boolean | null | typeof UNREADABLE | YamlValue[] | { [key: string]: YamlValue };\nexport type YamlMap = { [key: string]: YamlValue };\n\ninterface Line {\n indent: number;\n text: string;\n}\n\n/** The text of a line without a trailing comment (a `#` after whitespace, outside quotes). */\nexport function stripComment(line: string): string {\n let quote: string | null = null;\n for (let i = 0; i < line.length; i++) {\n const ch = line[i]!;\n if (quote) {\n if (ch === \"\\\\\" && quote === '\"') i++;\n else if (ch === quote) quote = null;\n } else if (ch === '\"' || ch === \"'\") {\n if (i === 0 || /[\\s:[{,-]/.test(line[i - 1]!)) quote = ch;\n } else if (ch === \"#\" && (i === 0 || /\\s/.test(line[i - 1]!))) return line.slice(0, i).trimEnd();\n }\n return line.trimEnd();\n}\n\n/** The line range of the top-level `mcp_servers:` block, or null when there isn't exactly one. */\nexport function mcpServersBlock(yaml: string): { start: number; end: number; inline: string } | null {\n return topBlock(yaml, \"mcp_servers\");\n}\n\nconst keyRe = (key: string) => new RegExp(`^${key.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}\\\\s*:`);\n\n/** The line range of a top-level `<key>:` block, or null when there isn't exactly one. */\nexport function topBlock(yaml: string, key: string): { start: number; end: number; inline: string } | null {\n const re = keyRe(key);\n const lines = yaml.replace(/^/, \"\").split(\"\\n\");\n const tops = lines.flatMap((l, i) => (re.test(l) ? [i] : []));\n if (tops.length !== 1) return null;\n const start = tops[0]!;\n let end = start + 1;\n while (end < lines.length && (lines[end]!.trim() === \"\" || /^\\s/.test(lines[end]!) || lines[end]!.startsWith(\"#\"))) end++;\n // Trailing blank lines and column-0 comments belong to whatever comes next.\n while (end > start + 1 && (lines[end - 1]!.trim() === \"\" || lines[end - 1]!.startsWith(\"#\"))) end--;\n return { start, end, inline: stripComment(lines[start]!.replace(re, \"\")).trim() };\n}\n\nfunction unquote(raw: string): string | typeof UNREADABLE {\n if (raw.startsWith('\"')) {\n if (!raw.endsWith('\"') || raw.length < 2) return UNREADABLE;\n try {\n // YAML double-quoted escapes are a superset of JSON's; the common ones agree.\n return JSON.parse(raw.replace(/\\\\\\//g, \"/\")) as string;\n } catch {\n return UNREADABLE;\n }\n }\n if (raw.startsWith(\"'\")) {\n if (!raw.endsWith(\"'\") || raw.length < 2) return UNREADABLE;\n return raw.slice(1, -1).replace(/''/g, \"'\");\n }\n return raw;\n}\n\n/** Splits a flow sequence body on top-level commas. */\nfunction splitFlow(body: string): string[] | null {\n const out: string[] = [];\n let cur = \"\";\n let quote: string | null = null;\n for (let i = 0; i < body.length; i++) {\n const ch = body[i]!;\n if (quote) {\n cur += ch;\n if (ch === \"\\\\\" && quote === '\"') cur += body[++i] ?? \"\";\n else if (ch === quote) quote = null;\n } else if (ch === '\"' || ch === \"'\") {\n quote = ch;\n cur += ch;\n } else if (ch === \"[\" || ch === \"{\" || ch === \"]\" || ch === \"}\") return null;\n else if (ch === \",\") {\n out.push(cur.trim());\n cur = \"\";\n } else cur += ch;\n }\n if (quote) return null;\n if (cur.trim()) out.push(cur.trim());\n return out;\n}\n\nexport function scalar(raw: string): YamlValue {\n const v = raw.trim();\n if (v === \"\" || v === \"~\" || v === \"null\" || v === \"Null\" || v === \"NULL\") return null;\n if (/^[&*!|>]/.test(v) || v.startsWith(\"<<\") || v.startsWith(\"{\")) return UNREADABLE;\n if (v.startsWith(\"[\")) {\n if (!v.endsWith(\"]\")) return UNREADABLE;\n const items = splitFlow(v.slice(1, -1));\n return items ? items.map((i) => scalar(i)) : UNREADABLE;\n }\n if (v.startsWith('\"') || v.startsWith(\"'\")) return unquote(v);\n if (/^(true|True|TRUE)$/.test(v)) return true;\n if (/^(false|False|FALSE)$/.test(v)) return false;\n if (/^[-+]?\\d+(\\.\\d+)?$/.test(v)) return Number(v);\n return v;\n}\n\n/** `key: rest` with a plain or quoted key; null when the line isn't one. */\nfunction keyValue(text: string): { key: string; rest: string } | null {\n const m = /^(\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^']|'')*'|[^\"'#:\\s][^:]*?)\\s*:(?:\\s+(.*)|$)/.exec(text);\n if (!m) return null;\n const key = unquote(m[1]!);\n if (key === UNREADABLE) return null;\n return { key, rest: (m[2] ?? \"\").trim() };\n}\n\nfunction parseLines(lines: Line[], from: number, indent: number): { value: YamlValue; next: number } {\n const first = lines[from];\n if (!first || first.indent < indent) return { value: null, next: from };\n const childIndent = first.indent;\n if (first.text.startsWith(\"- \") || first.text === \"-\") {\n const items: YamlValue[] = [];\n let i = from;\n while (i < lines.length && lines[i]!.indent === childIndent && (lines[i]!.text.startsWith(\"- \") || lines[i]!.text === \"-\")) {\n const item = lines[i]!.text.slice(1).trim();\n i++;\n // A nested map or sequence inside an item is beyond this reader.\n if (!item || keyValue(item)) {\n items.push(UNREADABLE);\n while (i < lines.length && lines[i]!.indent > childIndent) i++;\n } else items.push(scalar(item));\n }\n return { value: items, next: i };\n }\n const map: YamlMap = {};\n let i = from;\n while (i < lines.length && lines[i]!.indent >= childIndent) {\n const line = lines[i]!;\n if (line.indent > childIndent) {\n // Over-indented line (a continued plain scalar, or broken YAML): poison the previous key.\n const keys = Object.keys(map);\n if (keys.length) map[keys[keys.length - 1]!] = UNREADABLE;\n i++;\n continue;\n }\n const kv = keyValue(line.text);\n i++;\n if (!kv) {\n map[`\\u0000line${i}`] = UNREADABLE;\n continue;\n }\n if (kv.rest) {\n map[kv.key] = Object.hasOwn(map, kv.key) ? UNREADABLE : scalar(kv.rest);\n continue;\n }\n const nested = i < lines.length && (lines[i]!.indent > childIndent || (lines[i]!.indent === childIndent && lines[i]!.text.startsWith(\"- \")));\n if (!nested) {\n map[kv.key] = null;\n continue;\n }\n const sub = parseLines(lines, i, lines[i]!.indent > childIndent ? childIndent + 1 : childIndent);\n map[kv.key] = Object.hasOwn(map, kv.key) ? UNREADABLE : sub.value;\n i = sub.next;\n }\n return { value: map, next: i };\n}\n\n/**\n * The `mcp_servers` map of a Hermes config.yaml: server name → its (partly) parsed entry. null when the file has\n * no single readable block (`{}` and an absent key give an empty map).\n */\nexport function readMcpServers(yaml: string): YamlMap | null {\n return readTopMap(yaml, \"mcp_servers\");\n}\n\n/** A top-level block map (e.g. `platform_toolsets`), read like mcp_servers. */\nexport function readTopMap(yaml: string, key: string): YamlMap | null {\n const block = topBlock(yaml, key);\n if (!block) return new RegExp(keyRe(key).source, \"m\").test(yaml) ? null : {};\n if (block.inline) return block.inline === \"{}\" || block.inline === \"null\" || block.inline === \"~\" ? {} : null;\n const raw = yaml.replace(/^/, \"\").split(\"\\n\").slice(block.start + 1, block.end);\n const lines: Line[] = [];\n for (const l of raw) {\n const text = stripComment(l);\n if (!text.trim()) continue;\n const ws = /^(\\s*)/.exec(text)![1]!;\n if (ws.includes(\"\\t\")) return null;\n lines.push({ indent: ws.length, text: text.trim() });\n }\n if (!lines.length) return {};\n const { value } = parseLines(lines, 0, 1);\n return value && typeof value === \"object\" && !Array.isArray(value) ? (value as YamlMap) : null;\n}\n\nconst escapeRe = (s: string) => s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/**\n * Removes `mcp_servers.<name>` for each name, keeping everything else byte for byte. Returns null when any of\n * them isn't a plain block entry this can cut out safely (then nothing should be written).\n */\n/**\n * Cuts the named entries out of an mcp_servers block body (its lines after `mcp_servers:`), whose entries sit at\n * `indent`. Comment and blank lines met inside a cut entry are held until the next real line decides: a sibling\n * key at `indent` (or less) keeps them with what follows (unless that is cut too), a deeper line means they were\n * part of the cut entry. So a commented-out property (`# timeout: 120`) or a note (` # TODO`) inside an entry\n * never ends it early, and none of its lines can end up under a neighbour. null when a layout can't be cut safely.\n */\n/**\n * Whether lines use YAML anchors, aliases or merge keys (`&a`, `*a`, `<<:`) outside quotes and comments. Cutting\n * an entry could then remove an anchor a kept entry still refers to, so those blocks are never rewritten.\n */\nexport function hasAnchors(lines: string[]): boolean {\n return lines.some((l) => {\n const t = stripComment(l)\n .replace(/\"(?:[^\"\\\\]|\\\\.)*\"/g, '\"\"')\n .replace(/'(?:[^']|'')*'/g, \"''\");\n return /(^|[\\s:[{,-])[&*][^\\s,\\]}]/.test(t) || /(^|[\\s{,-])<<\\s*:/.test(t);\n });\n}\n\nexport function cutEntries(body: string[], indent: string, names: string[]): { kept: string[]; found: Set<string> } | null {\n if (hasAnchors(body)) return null;\n const isKey = (l: string, name: string) => new RegExp(`^${escapeRe(indent)}([\"']?)${escapeRe(name)}\\\\1\\\\s*:`).test(l);\n const ind = (l: string) => /^(\\s*)/.exec(l)![1]!.length;\n const isComment = (l: string) => l.trimStart().startsWith(\"#\");\n const kept: string[] = [];\n const found = new Set<string>();\n let skipping = false;\n let pending: string[] = [];\n for (const l of body) {\n const blank = !l.trim();\n if (skipping && (blank || isComment(l))) {\n pending.push(l);\n continue;\n }\n if (blank || isComment(l)) {\n kept.push(l);\n continue;\n }\n const own = ind(l);\n if (own < indent.length) return null;\n if (own > indent.length) {\n // Part of the current entry: a cut one's held comments go with it.\n if (skipping) pending = [];\n else kept.push(l);\n continue;\n }\n // A sibling key: what was held belongs to it.\n const hit = names.find((n) => isKey(l, n)) ?? null;\n if (hit) {\n if (found.has(hit)) return null;\n found.add(hit);\n // Only block entries: a flow-style `name: { … }` might span lines we can't see the end of.\n if (stripComment(l).replace(/^[^:]*:/, \"\").trim()) return null;\n // Comments right above a cut entry (at its indent or less) were about it: they go with it.\n pending = [];\n while (kept.length && isComment(kept[kept.length - 1]!) && ind(kept[kept.length - 1]!) <= indent.length) kept.pop();\n skipping = true;\n continue;\n }\n if (skipping) kept.push(...pending.filter((x) => !x.trim() || ind(x) <= indent.length));\n pending = [];\n skipping = false;\n kept.push(l);\n }\n // Held lines at the end of the block were the cut entry's.\n return { kept, found };\n}\n\n/**\n * Removes `mcp_servers.<name>` for each name, keeping everything else byte for byte. Returns null when any of\n * them isn't a plain block entry this can cut out safely (then nothing should be written).\n */\nexport function removeYamlServers(yaml: string, names: string[]): string | null {\n if (!names.length) return yaml;\n const block = mcpServersBlock(yaml);\n if (!block || block.inline) return null;\n const lines = yaml.split(\"\\n\");\n const body = lines.slice(block.start + 1, block.end);\n const first = body.find((l) => l.trim() && !l.trimStart().startsWith(\"#\"));\n if (!first) return null;\n const indent = /^(\\s*)/.exec(first)![1]!;\n if (!indent || indent.includes(\"\\t\")) return null;\n const cut = cutEntries(body, indent, names);\n if (!cut || cut.found.size !== names.length) return null;\n const { kept } = cut;\n const hasChild = kept.some((l) => l.trim() && !l.trimStart().startsWith(\"#\"));\n const head = hasChild ? lines[block.start]! : \"mcp_servers: {}\";\n return [...lines.slice(0, block.start), head, ...(hasChild ? kept : kept.filter((l) => l.trim())), ...lines.slice(block.end)].join(\"\\n\");\n}\n","import { spawnSync } from \"node:child_process\";\nimport { chmodSync, existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport type { AgentTool } from \"../../shared/agent-api.ts\";\nimport { backupFile, isTooOpen, writePrivateFile } from \"./fsutil.ts\";\nimport { claudeServerEntry, helperNodeNote, helperScriptPath } from \"./mcpheader.ts\";\nimport type { Profile } from \"./profile.ts\";\nimport { DEFAULT_PROFILE } from \"./paths.ts\";\nimport { mcpServerName } from \"./recipes.ts\";\nimport { NPX } from \"./version.ts\";\nimport { safeText } from \"./ui.ts\";\nimport { isDeepStrictEqual } from \"node:util\";\nimport { readTomlMcpServers } from \"../connections-cli/toml.ts\";\nimport { cutEntries, hasAnchors, mcpServersBlock, readMcpServers, removeYamlServers } from \"../connections-cli/yaml.ts\";\n\n/**\n * `--setup-mcp`: registers the xaq MCP server in the agent's own tool without the key ever\n * being shown or pasted. Every file we modify is backed up first; the key is redacted from any\n * output we relay.\n */\n\nexport interface McpSetupResult {\n ok: boolean;\n /** What happened, safe to print (never contains the key). */\n message: string;\n backup?: string | null;\n /** Manual steps when automatic setup isn't possible. Never contains the key. */\n manual?: string[];\n /** Exactly what was (or, in a dry run, would be) changed. Never contains the key. */\n changes?: string[];\n /** How to check it worked. */\n verify?: string[];\n /** Nothing was changed (--dry-run). */\n dryRun?: boolean;\n /** Things to know afterwards, e.g. which Node.js the setup depends on. */\n notes?: string[];\n /** `removeServers` entries that were taken out. */\n removed?: string[];\n}\n\nexport interface McpSetupOptions {\n /** Print what would change; change nothing. */\n dryRun?: boolean;\n /**\n * Other entries to take out in the same write (`import --from`: servers now served through the broker). For the\n * file-based tools it's all or nothing: if one can't be removed safely, nothing is changed.\n */\n removeServers?: RemoveServer[];\n}\n\nexport interface RemoveServer {\n name: string;\n /** Claude Code: the scope it's defined in, and for local/project scope the project directory. */\n scope?: \"user\" | \"local\" | \"project\";\n projectDir?: string;\n}\n\n/**\n * The safety net under every rewrite: the new file, read back with the same readers, must hold exactly the old\n * entries minus the removed ones (each unchanged, deep-equal), plus our entry as intended. Anything else means the\n * rewrite moved a line where it doesn't belong (e.g. a header under another server): refuse it. Returns the\n * problem, or null when it's right.\n */\nexport function checkRewrite(\n before: Record<string, unknown> | null,\n after: Record<string, unknown> | null,\n ours: { name: string; entry: unknown },\n removed: string[],\n): string | null {\n if (!before || !after) return \"it can't be read back\";\n // A value the reader couldn't read compares equal to any other unreadable one: that verifies nothing.\n const opaque = (v: unknown): boolean => typeof v === \"symbol\" || (!!v && typeof v === \"object\" && Object.values(v as Record<string, unknown>).some(opaque));\n const gone = new Set(removed);\n for (const [name, entry] of Object.entries(before)) {\n if (name === ours.name || gone.has(name)) continue;\n if (!(name in after)) return `\"${name}\" would disappear`;\n if (opaque(entry) || opaque(after[name])) return `\"${name}\" has a value this can't read, so the result can't be verified`;\n if (!isDeepStrictEqual(after[name], entry)) return `\"${name}\" would change`;\n }\n for (const name of removed) if (name in after) return `\"${name}\" would still be there`;\n for (const name of Object.keys(after)) if (name !== ours.name && !(name in before)) return `\"${name}\" would appear`;\n if (!isDeepStrictEqual(after[ours.name], ours.entry)) return `\"${ours.name}\" wouldn't be exactly the new entry`;\n return null;\n}\n\nconst refused = (file: string, why: string, manual: string[]): McpSetupResult => ({\n ok: false,\n message: `Not rewriting ${file}: read back, the result isn't right (${why}). Nothing was changed.`,\n manual,\n});\n\n/** The entries to remove, never the xaq entry itself. */\nconst removals = (t: McpSetupTarget, opts: McpSetupOptions) => (opts.removeServers ?? []).filter((r) => r.name !== t.name);\nconst removedNote = (extra: RemoveServer[]) => (extra.length ? ` Removed ${extra.map((r) => `\"${r.name}\"`).join(\", \")} (now served through xaq).` : \"\");\nconst removedLine = (name: string, file: string) => `remove ${name} from ${file} (it's now served through xaq)`;\n\n/** Placeholder shown wherever the key would go in printed file contents. */\nconst KEY_SHOWN = \"<the key from your xaq profile>\";\nconst backupLine = (file: string) => (existsSync(file) ? `back up ${file} to ${file}.xaq-backup-<timestamp> (0600)` : `${file} doesn't exist yet: nothing to back up`);\nconst indent = (text: string) =>\n text\n .replace(/\\n$/, \"\")\n .split(\"\\n\")\n .map((l) => ` ${l}`);\n\nexport interface McpSetupTarget {\n name: string;\n url: string;\n key: string;\n}\n\nconst redact = (s: string, key: string) => s.split(key).join(\"aib_…(redacted)\");\n\n/**\n * The MCP endpoint is always derived from the URL the user connected to (and transport-checked\n * there), never taken from the daemon: a daemon's advertised mcpUrl comes from its publicUrl setting,\n * which defaults to http://localhost:8425 and could also point the key somewhere else entirely.\n */\nexport function mcpTarget(profileName: string, profile: Profile): McpSetupTarget & { profile: string } {\n return { name: mcpServerName(profileName), url: `${profile.url}/mcp`, key: profile.apiKey, profile: profileName };\n}\n\nexport function setupMcp(tool: AgentTool, t: McpSetupTarget & { profile?: string }, profileFile: string, opts: McpSetupOptions = {}): McpSetupResult {\n switch (tool) {\n case \"claude-code\":\n return setupClaude(t, t.profile ?? \"default\", opts);\n case \"codex\":\n return setupCodex(t, profileFile, opts);\n case \"cursor\":\n return setupCursor(t, profileFile, opts);\n case \"hermes\":\n return setupHermes(t, profileFile, opts);\n default:\n return { ok: false, message: \"No automatic MCP setup for --tool other.\", manual: manualGeneric(t, profileFile) };\n }\n}\n\nfunction manualGeneric(t: McpSetupTarget, profileFile: string): string[] {\n return [\n `MCP endpoint (streamable HTTP): ${t.url}`,\n `Header: Authorization: Bearer <key>. The key is the \"apiKey\" field in ${profileFile}; tools that run a header helper can use \\`${NPX} mcp-header\\`, which prints it as JSON to a pipe.`,\n ];\n}\n\n// ───────────── Claude Code ─────────────\n\nexport const claudeConfigFile = () => (process.env.CLAUDE_CONFIG_DIR ? join(process.env.CLAUDE_CONFIG_DIR, \".claude.json\") : join(homedir(), \".claude.json\"));\n\nfunction setupClaude(t: McpSetupTarget, profile: string, opts: McpSetupOptions): McpSetupResult {\n // headersHelper: Claude Code asks our helper for the header at connect time, so the key is never in\n // argv (visible in `ps`), in ~/.claude.json, or on screen.\n const json = JSON.stringify(claudeServerEntry(t.url, profile, { install: !opts.dryRun }));\n const addCommand = `claude mcp add-json --scope user ${t.name} '${json.replace(/'/g, `'\"'\"'`)}'`;\n const manual = [addCommand];\n const file = claudeConfigFile();\n const verify = [`claude mcp list (shows \"${t.name}\" as connected; inside Claude Code: /mcp)`];\n // The helper command names a node binary: say which, and how to recover when it goes away.\n const notes = [helperNodeNote(profile, `${NPX} setup-mcp --tool claude-code${profile === DEFAULT_PROFILE ? \"\" : ` --profile ${profile}`}`)];\n const removeArgs = removals(t, opts).map((r) => ({ r, args: [\"mcp\", \"remove\", r.name, \"--scope\", r.scope ?? \"user\"], cwd: r.projectDir }));\n const changes = [\n `write the header helper ${helperScriptPath()} (0600; reads the key from your profile when Claude Code connects)`,\n backupLine(file),\n `run: claude mcp remove ${t.name} --scope user (drops an earlier \"${t.name}\" entry, if any)`,\n `run: ${addCommand}`,\n ...removeArgs.map((x) => `run: claude ${x.args.join(\" \")}${x.cwd ? ` (in ${x.cwd})` : \"\"} (now served through xaq)`),\n `the key stays in your xaq profile: neither the command line nor ${file} contains it`,\n ];\n if (opts.dryRun) return { ok: true, dryRun: true, message: `Dry run for Claude Code: nothing was changed. setup-mcp would:`, changes, verify, notes };\n const probe = spawnSync(\"claude\", [\"--version\"], { stdio: \"ignore\" });\n if (probe.error || probe.status !== 0) return { ok: false, message: \"The `claude` CLI was not found on PATH.\", manual };\n const backup = backupFile(file);\n // `add-json` refuses an existing name, so replace it. argv arrays only, and nothing secret in them.\n spawnSync(\"claude\", [\"mcp\", \"remove\", t.name, \"--scope\", \"user\"], { stdio: \"ignore\" });\n const r = spawnSync(\"claude\", [\"mcp\", \"add-json\", \"--scope\", \"user\", t.name, json], { encoding: \"utf8\", stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n if (r.status !== 0) {\n const out = redact(`${r.stderr ?? \"\"}${r.stdout ?? \"\"}`, t.key).trim();\n return { ok: false, message: `claude mcp add-json failed${out ? `: ${safeText(out, 300)}` : \"\"}`, backup, manual };\n }\n // Only after the broker entry is in: a failed removal leaves a duplicate, never a gap.\n const done: string[] = [];\n for (const x of removeArgs) {\n const rr = spawnSync(\"claude\", x.args, { encoding: \"utf8\", stdio: [\"ignore\", \"pipe\", \"pipe\"], cwd: x.cwd });\n if (rr.status === 0) done.push(`ran: claude ${x.args.join(\" \")}`);\n else notes.push(`Couldn't remove \"${x.r.name}\" (${x.r.scope ?? \"user\"} scope): remove it yourself with claude ${x.args.join(\" \")}${x.cwd ? ` in ${x.cwd}` : \"\"}.`);\n }\n if (existsSync(file) && isTooOpen(file)) chmodSync(file, 0o600);\n return {\n ok: true,\n message: `Registered MCP server \"${t.name}\" in Claude Code (user scope). The key stays in your xaq profile; Claude Code asks for it through a header helper.`,\n backup,\n changes: [`ran: ${addCommand}`, `${file} now lists \"${t.name}\" (user scope)`, ...done],\n verify,\n notes,\n removed: removeArgs.filter((x) => done.includes(`ran: claude ${x.args.join(\" \")}`)).map((x) => x.r.name),\n };\n}\n\n// ───────────── Codex (~/.codex/config.toml) ─────────────\n\nexport const codexConfigFile = () => join(process.env.CODEX_HOME || join(homedir(), \".codex\"), \"config.toml\");\n\nconst escapeRe = (s: string) => s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\nconst tomlString = (s: string) => JSON.stringify(s);\n\n/** Removes `[mcp_servers.<name>]` and its sub-tables from a TOML document, or returns null if it's defined in a form we won't rewrite safely. */\nexport function removeTomlServer(toml: string, name: string): string | null {\n const keyForms = `(?:${escapeRe(name)}|\"${escapeRe(name)}\"|'${escapeRe(name)}')`;\n const header = new RegExp(`^\\\\s*\\\\[\\\\s*mcp_servers\\\\s*\\\\.\\\\s*${keyForms}\\\\s*(?:\\\\.[^\\\\]]*)?\\\\]\\\\s*(?:#.*)?$`);\n const anyHeader = /^\\s*\\[/;\n // Inline or dotted definitions (`mcp_servers = { … }`, `mcp_servers.xaq.url = …`): leave to the human.\n if (new RegExp(`^\\\\s*mcp_servers\\\\s*(?:=|\\\\.\\\\s*${keyForms}\\\\s*[.=])`, \"m\").test(toml)) return null;\n const out: string[] = [];\n let skipping = false;\n for (const line of toml.split(\"\\n\")) {\n if (anyHeader.test(line)) skipping = header.test(line);\n // Our own marker comment sits just above the table: drop it too, so re-running doesn't pile them up.\n if (!skipping && line.trim() !== CODEX_MARKER && line.trim() !== LEGACY_CODEX_MARKER) out.push(line);\n }\n return out.join(\"\\n\").replace(/\\n{3,}/g, \"\\n\\n\");\n}\n\nconst CODEX_MARKER = \"# Added by `xaq setup-mcp`. The key is also in your xaq profile; rotate it in the console.\";\n/** The marker setup-mcp wrote before the rename: dropped too when the table is rewritten. */\nconst LEGACY_CODEX_MARKER = \"# Added by `agentinbox setup-mcp`. The key is also in your agentinbox profile; rotate it in the console.\";\n\nexport function codexBlock(t: McpSetupTarget): string {\n return [\n CODEX_MARKER,\n `[mcp_servers.${t.name}]`,\n `url = ${tomlString(t.url)}`,\n `http_headers = { Authorization = ${tomlString(`Bearer ${t.key}`)} }`,\n `# codex exec never prompts: approve ${t.name} tools up front (the grant's send mode still applies).`,\n `default_tools_approval_mode = \"approve\"`,\n \"\",\n ].join(\"\\n\");\n}\n\nfunction setupCodex(t: McpSetupTarget, profileFile: string, opts: McpSetupOptions): McpSetupResult {\n const file = codexConfigFile();\n const manual = [\n `Add to ${file}:`,\n ` [mcp_servers.${t.name}]`,\n ` url = \"${t.url}\"`,\n ` http_headers = { Authorization = \"Bearer <key>\" } # <key>: the apiKey field of ${profileFile}`,\n ` default_tools_approval_mode = \"approve\"`,\n ];\n const current = existsSync(file) ? readFileSync(file, \"utf8\") : \"\";\n const withoutOurs = removeTomlServer(current, t.name);\n if (withoutOurs === null) return { ok: false, message: `${file} defines mcp_servers inline; not rewriting it automatically.`, manual };\n let without = withoutOurs;\n const extra = removals(t, opts);\n for (const r of extra) {\n const next = removeTomlServer(without, r.name);\n if (next === null || next === without) return { ok: false, message: `Couldn't remove [mcp_servers.${r.name}] from ${file} safely; nothing was changed.`, manual };\n without = next;\n }\n const verify = [`codex mcp list (shows \"${t.name}\")`];\n const replaces = withoutOurs !== current.replace(/\\n{3,}/g, \"\\n\\n\") ? `replace [mcp_servers.${t.name}] in` : `add [mcp_servers.${t.name}] to`;\n const changes = [\n backupLine(file),\n ...extra.map((r) => removedLine(`[mcp_servers.${r.name}]`, file)),\n `${replaces} ${file} (other tables are kept) and set the file to 0600, since it will hold the key:`,\n ...indent(codexBlock({ ...t, key: KEY_SHOWN })),\n ];\n const base = without.replace(/\\s*$/, \"\");\n const next = `${base ? `${base}\\n\\n` : \"\"}${codexBlock(t)}`;\n const toTable = (x: ReturnType<typeof readTomlMcpServers>) => x as Record<string, unknown>;\n const problem = checkRewrite(\n toTable(readTomlMcpServers(current)),\n toTable(readTomlMcpServers(next)),\n { name: t.name, entry: { url: t.url, http_headers: { Authorization: `Bearer ${t.key}` }, default_tools_approval_mode: \"approve\" } },\n extra.map((r) => r.name),\n );\n if (problem) return refused(file, problem, manual);\n if (opts.dryRun) return { ok: true, dryRun: true, message: `Dry run for Codex: nothing was changed. setup-mcp would:`, changes, verify };\n const backup = backupFile(file);\n writePrivateFile(file, next, { privateDir: false });\n return { ok: true, message: `Added [mcp_servers.${t.name}] to ${file} (now mode 0600: it holds the key).${removedNote(extra)}`, backup, verify, removed: extra.map((r) => r.name) };\n}\n\n// ───────────── Cursor (~/.cursor/mcp.json) ─────────────\n\nexport const cursorConfigFile = () => join(homedir(), \".cursor\", \"mcp.json\");\n\nfunction setupCursor(t: McpSetupTarget, profileFile: string, opts: McpSetupOptions): McpSetupResult {\n const file = cursorConfigFile();\n const manual = [\n `Add to ${file} under \"mcpServers\":`,\n ` \"${t.name}\": { \"url\": \"${t.url}\", \"headers\": { \"Authorization\": \"Bearer <key>\" } } // <key>: the apiKey field of ${profileFile}`,\n ];\n let doc: Record<string, unknown> = {};\n if (existsSync(file)) {\n const text = readFileSync(file, \"utf8\");\n if (text.trim()) {\n try {\n doc = JSON.parse(text) as Record<string, unknown>;\n } catch {\n return { ok: false, message: `${file} is not plain JSON (comments?); not rewriting it automatically.`, manual };\n }\n if (!doc || typeof doc !== \"object\" || Array.isArray(doc)) return { ok: false, message: `${file} is not a JSON object.`, manual };\n }\n }\n const servers = doc.mcpServers && typeof doc.mcpServers === \"object\" && !Array.isArray(doc.mcpServers) ? (doc.mcpServers as Record<string, unknown>) : {};\n const verify = [`agent mcp list (Cursor CLI; or Cursor Settings → MCP shows \"${t.name}\")`];\n const entry = (key: string) => ({ url: t.url, headers: { Authorization: `Bearer ${key}` } });\n const extra = removals(t, opts);\n const absent = extra.find((r) => !(r.name in servers));\n if (absent) return { ok: false, message: `\"mcpServers.${absent.name}\" isn't in ${file}; nothing was changed.`, manual };\n const changes = [\n backupLine(file),\n ...extra.map((r) => removedLine(`\"mcpServers.${r.name}\"`, file)),\n `${t.name in servers ? \"replace\" : \"add\"} \"mcpServers.${t.name}\" ${t.name in servers ? \"in\" : \"to\"} ${file} (other servers are kept) and set the file to 0600, since it will hold the key:`,\n ...indent(`\"${t.name}\": ${JSON.stringify(entry(KEY_SHOWN), null, 2)}`),\n ];\n if (opts.dryRun) return { ok: true, dryRun: true, message: `Dry run for Cursor: nothing was changed. setup-mcp would:`, changes, verify };\n const before = structuredClone(servers);\n for (const r of extra) delete servers[r.name];\n servers[t.name] = entry(t.key);\n doc.mcpServers = servers;\n const reread = (JSON.parse(JSON.stringify(doc)) as { mcpServers: Record<string, unknown> }).mcpServers;\n const problem = checkRewrite(before, reread, { name: t.name, entry: entry(t.key) }, extra.map((r) => r.name));\n if (problem) return refused(file, problem, manual);\n const backup = backupFile(file);\n writePrivateFile(file, JSON.stringify(doc, null, 2) + \"\\n\", { privateDir: false });\n return {\n ok: true,\n message: `Added \"${t.name}\" to ${file} (now mode 0600: it holds the key).${removedNote(extra)} Cursor may ask you to enable it once.`,\n backup,\n verify,\n removed: extra.map((r) => r.name),\n };\n}\n\n// ───────────── Hermes (~/.hermes/config.yaml + ~/.hermes/.env) ─────────────\n\n/**\n * The Hermes home a bare `hermes` uses (hermes_constants.py / hermes_cli/profiles.py): $HERMES_HOME, else\n * ~/.hermes (plus HERMES_DATA_DIR_SUFFIX), switched to profiles/<name> by the sticky `active_profile` file.\n * Commands xaq runs get HERMES_HOME set to this, so they edit the same files.\n */\nexport function hermesHome(env: NodeJS.ProcessEnv = process.env): string {\n const set = env.HERMES_HOME?.trim();\n if (set) return set.replace(/^~(?=\\/|$)/, homedir());\n const root = join(homedir(), `.hermes${env.HERMES_DATA_DIR_SUFFIX ?? \"\"}`);\n let active = \"\";\n try {\n active = readFileSync(join(root, \"active_profile\"), \"utf8\").replace(/^\\uFEFF/, \"\").trim().toLowerCase();\n } catch {\n // No sticky profile.\n }\n return active && active !== \"default\" && /^[a-z0-9][a-z0-9_-]*$/.test(active) ? join(root, \"profiles\", active) : root;\n}\n\n/**\n * Whether `mcp_servers.<name>` is on in a Hermes config.yaml (\"enabled\" absent, null or not a false word\n * is on, like Hermes' mcp_server_enabled). \"unknown\" for layouts this small block-YAML reader won't judge:\n * callers that need it on treat that as not on.\n */\nexport function yamlMcpServerState(yaml: string, name: string): \"enabled\" | \"disabled\" | \"missing\" | \"unknown\" {\n const lines = yaml.replace(/^\\uFEFF/, \"\").split(\"\\n\");\n const tops = lines.flatMap((l, i) => (/^mcp_servers\\s*:/.test(l) ? [i] : []));\n if (tops.length === 0) return \"missing\";\n if (tops.length > 1) return \"unknown\";\n const top = tops[0]!;\n const rest = lines[top]!.replace(/^mcp_servers\\s*:/, \"\").replace(/\\s#.*$/, \"\").trim();\n if (rest) return rest === \"{}\" || rest === \"null\" || rest === \"~\" ? \"missing\" : \"unknown\";\n let end = top + 1;\n while (end < lines.length && (lines[end]!.trim() === \"\" || /^\\s/.test(lines[end]!) || lines[end]!.startsWith(\"#\"))) end++;\n const body = lines.slice(top + 1, end).filter((l) => l.trim() && !l.trimStart().startsWith(\"#\"));\n if (!body.length) return \"missing\";\n const indent = body[0]!.match(/^(\\s*)/)![1]!;\n if (!indent || /\\t/.test(indent) || body.some((l) => /[&*]|<</.test(l.split(\"#\")[0]!))) return \"unknown\";\n const key = new RegExp(`^${indent}([\"']?)${name.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}\\\\1\\\\s*:(.*)$`);\n const starts = body.flatMap((l, i) => (key.test(l) ? [i] : []));\n if (starts.length === 0) return \"missing\";\n if (starts.length > 1) return \"unknown\";\n const inline = key.exec(body[starts[0]!]!)![2]!.replace(/\\s#.*$/, \"\").trim();\n if (inline) return \"unknown\"; // flow style ({ url: … })\n const own: string[] = [];\n for (const l of body.slice(starts[0]! + 1)) {\n if (l.match(/^(\\s*)/)![1]!.length <= indent.length) break;\n own.push(l);\n }\n if (!own.length) return \"unknown\";\n const childIndent = own[0]!.match(/^(\\s*)/)![1]!.length;\n const enabled = own.filter((l) => l.match(/^(\\s*)/)![1]!.length === childIndent && /^\\s*[\"']?enabled[\"']?\\s*:/.test(l));\n if (enabled.length > 1) return \"unknown\";\n if (!enabled.length) return \"enabled\";\n const value = enabled[0]!.replace(/^\\s*[\"']?enabled[\"']?\\s*:/, \"\").replace(/\\s#.*$/, \"\").trim().replace(/^[\"']|[\"']$/g, \"\").toLowerCase();\n return [\"false\", \"0\", \"no\", \"off\"].includes(value) ? \"disabled\" : \"enabled\";\n}\nexport const hermesEnvVar = (name: string) => name.toUpperCase().replace(/[^A-Z0-9]/g, \"_\") + \"_API_KEY\";\n\n/**\n * Inserts or replaces `mcp_servers.<name>` in a YAML document without a YAML library, handling the\n * common block-style layout. Returns null for anything unusual (flow style, anchors, odd indentation).\n */\nexport function upsertYamlServer(yaml: string, name: string, entry: string[]): string | null {\n const lines = yaml.split(\"\\n\");\n const top = lines.findIndex((l) => /^mcp_servers\\s*:/.test(l));\n const block = (indent: string) => [`${indent}${name}:`, ...entry.map((e) => `${indent}${indent}${e}`)];\n if (top < 0) {\n const base = yaml.replace(/\\s*$/, \"\");\n return `${base ? `${base}\\n\\n` : \"\"}mcp_servers:\\n${block(\" \").join(\"\\n\")}\\n`;\n }\n const rest = lines[top]!.replace(/^mcp_servers\\s*:/, \"\").replace(/#.*$/, \"\").trim();\n if (rest && rest !== \"{}\" && rest !== \"null\" && rest !== \"~\") return null;\n if (rest) lines[top] = \"mcp_servers:\";\n // The block runs until the next non-blank line at column 0.\n let end = top + 1;\n while (end < lines.length && (lines[end]!.trim() === \"\" || /^\\s/.test(lines[end]!))) end++;\n const body = lines.slice(top + 1, end);\n const firstChild = body.find((l) => l.trim() && !l.trimStart().startsWith(\"#\"));\n const indent = firstChild ? firstChild.match(/^(\\s*)/)![1]! : \" \";\n if (!indent || /\\t/.test(indent)) return null;\n // Comments inside the old entry never end it early (cutEntries), so none of its lines can land elsewhere.\n const cut = cutEntries(body, indent, [name]);\n if (!cut) return null;\n const { kept } = cut;\n const insert = block(indent);\n return [...lines.slice(0, top + 1), ...insert, ...kept, ...lines.slice(end)].join(\"\\n\");\n}\n\nfunction upsertEnvLine(text: string, key: string, value: string): string {\n const line = `${key}=${value}`;\n const re = new RegExp(`^\\\\s*(?:export\\\\s+)?${escapeRe(key)}\\\\s*=.*$`, \"m\");\n if (re.test(text)) return text.replace(re, line);\n const base = text.replace(/\\s*$/, \"\");\n return `${base ? `${base}\\n` : \"\"}${line}\\n`;\n}\n\nfunction setupHermes(t: McpSetupTarget, profileFile: string, opts: McpSetupOptions): McpSetupResult {\n const home = hermesHome();\n const configFile = join(home, \"config.yaml\");\n const envFile = join(home, \".env\");\n const envVar = hermesEnvVar(t.name);\n const entry = [`url: ${JSON.stringify(t.url)}`, `headers:`, ` Authorization: \"Bearer \\${${envVar}}\"`];\n const manual = [\n `Add to ${configFile}:`,\n ` mcp_servers:`,\n ` ${t.name}:`,\n ...entry.map((e) => ` ${e}`),\n `and to ${envFile}: ${envVar}=<key> (<key>: the apiKey field of ${profileFile})`,\n `then check it with: hermes mcp test ${t.name}`,\n ];\n const current = existsSync(configFile) ? readFileSync(configFile, \"utf8\") : \"\";\n const extra = removals(t, opts);\n const blk = mcpServersBlock(current);\n if (blk && hasAnchors(current.split(\"\\n\").slice(blk.start + 1, blk.end))) {\n return {\n ok: false,\n message: `${configFile} uses YAML anchors, aliases or merge keys (&, *, <<) under mcp_servers; not rewriting it automatically. Nothing was changed.`,\n manual,\n };\n }\n const upserted = upsertYamlServer(current, t.name, entry);\n // Removed in the same write, before anything touches the disk: one entry we can't cut out cleanly changes nothing.\n const next = upserted === null ? null : removeYamlServers(upserted, extra.map((r) => r.name));\n if (upserted !== null && next === null) {\n return { ok: false, message: `Couldn't remove ${extra.map((r) => `\"${r.name}\"`).join(\", \")} from ${configFile} safely; nothing was changed.`, manual };\n }\n if (next === null) return { ok: false, message: `${configFile} uses a layout we won't rewrite automatically.`, manual };\n {\n const ours = { url: t.url, headers: { Authorization: `Bearer \\${${envVar}}` } };\n const problem = checkRewrite(readMcpServers(current), readMcpServers(next), { name: t.name, entry: ours }, extra.map((r) => r.name));\n if (problem) return refused(configFile, problem, manual);\n }\n const verify = [`hermes mcp test ${t.name}`];\n const changes = [\n backupLine(configFile),\n backupLine(envFile),\n ...extra.map((r) => removedLine(`\"mcp_servers.${r.name}\"`, configFile)),\n `add (or replace) \"mcp_servers.${t.name}\" in ${configFile} (0600):`,\n ...indent([\"mcp_servers:\", ` ${t.name}:`, ...entry.map((e) => ` ${e}`)].join(\"\\n\")),\n `set ${envVar}=${KEY_SHOWN} in ${envFile} (0600; Hermes' place for secrets)`,\n ];\n if (opts.dryRun) return { ok: true, dryRun: true, message: `Dry run for Hermes: nothing was changed. setup-mcp would:`, changes, verify };\n const envCurrent = existsSync(envFile) ? readFileSync(envFile, \"utf8\") : \"\";\n const backup = backupFile(configFile);\n const envBackup = backupFile(envFile);\n writePrivateFile(envFile, upsertEnvLine(envCurrent, envVar, t.key), { privateDir: false });\n writePrivateFile(configFile, next.endsWith(\"\\n\") ? next : `${next}\\n`, { privateDir: false });\n return {\n ok: true,\n message: `Added \"${t.name}\" to ${configFile}; the key is in ${envFile} as ${envVar} (0600).${removedNote(extra)}`,\n backup: [backup, envBackup].filter(Boolean).join(\", \") || null,\n verify,\n removed: extra.map((r) => r.name),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAOA,MAAaA,eAAa,OAAO,YAAY;AAI7C,IAAM,SAAN,MAAa;CAEU;CADrB,IAAI;CACJ,YAAY,GAAoB;EAAX,KAAA,IAAA;CAAY;CACjC,KAAW;EACT,OAAO,KAAK,IAAI,KAAK,EAAE,UAAU,QAAQ,KAAK,KAAK,EAAE,KAAK,EAAG,GAAG,KAAK;CACvE;;CAEA,QAAc;EACZ,SAAS;GACP,OAAO,KAAK,IAAI,KAAK,EAAE,UAAU,YAAY,KAAK,KAAK,EAAE,KAAK,EAAG,GAAG,KAAK;GACzE,IAAI,KAAK,EAAE,KAAK,OAAO,KAAK;GAC5B,OAAO,KAAK,IAAI,KAAK,EAAE,UAAU,KAAK,EAAE,KAAK,OAAO,MAAM,KAAK;EACjE;CACF;CACA,OAA2B;EACzB,OAAO,KAAK,EAAE,KAAK;CACrB;CACA,OAAgB;EACd,OAAO,KAAK,KAAK,KAAK,EAAE;CAC1B;AACF;AAEA,IAAM,aAAN,cAAyB,MAAM,CAAC;AAEhC,MAAM,UAAkC;CAAE,GAAG;CAAM,GAAG;CAAM,GAAG;CAAM,GAAG;CAAM,GAAG;CAAM,MAAK;CAAK,MAAM;CAAM,GAAG;AA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CAAC;EACtE,iCAAiC,EAAE,KAAK,OAAO,WAAW;EAC1D,GAAG,OAAO;GAAC;GAAgB,KAAK,EAAE,KAAK;GAAI,GAAG,MAAM,KAAK,MAAM,OAAO,GAAG;EAAC,CAAC,CAAC,KAAK,IAAI,CAAC;EACtF,OAAO,OAAO,GAAG,UAAU,MAAM,QAAQ;CAC3C;CACA,IAAI,KAAK,QAAQ,OAAO;EAAE,IAAI;EAAM,QAAQ;EAAM,SAAS;EAA6D;EAAS;CAAO;CACxI,MAAM,aAAa,WAAW,OAAO,IAAI,aAAa,SAAS,MAAM,IAAI;CACzE,MAAM,SAAS,WAAW,UAAU;CACpC,MAAM,YAAY,WAAW,OAAO;CACpC,iBAAiB,SAAS,cAAc,YAAY,QAAQ,EAAE,GAAG,GAAG,EAAE,YAAY,MAAM,CAAC;CACzF,iBAAiB,YAAY,KAAK,SAAS,IAAI,IAAI,OAAO,GAAG,KAAK,KAAK,EAAE,YAAY,MAAM,CAAC;CAC5F,OAAO;EACL,IAAI;EACJ,SAAS,UAAU,EAAE,KAAK,OAAO,WAAW,kBAAkB,QAAQ,MAAM,OAAO,UAAU,YAAY,KAAK;EAC9G,QAAQ,CAAC,QAAQ,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI,KAAK;EAC1D;EACA,SAAS,MAAM,KAAK,MAAM,EAAE,IAAI;CAClC;AACF"}
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ //#region server/node-check.ts
3
+ /** The oldest Node.js xaq runs on (node:sqlite unflagged, import.meta.dirname). Keep in sync with package.json engines. */
4
+ const MIN_NODE = "22.13.0";
5
+ /** An explanation when `version` (e.g. process.versions.node) is too old, else null. */
6
+ function nodeVersionError(version) {
7
+ const parse = (v) => v.replace(/^v/, "").split(".").map((n) => Number.parseInt(n, 10) || 0);
8
+ const have = parse(version);
9
+ const need = parse(MIN_NODE);
10
+ for (let i = 0; i < 3; i++) {
11
+ if ((have[i] ?? 0) > need[i]) return null;
12
+ if ((have[i] ?? 0) < need[i]) return `xaq needs Node.js 22.13 or newer (you have ${version.replace(/^v?/, "v")}). Install a current Node.js from https://nodejs.org and try again.`;
13
+ }
14
+ return null;
15
+ }
16
+ const problem = nodeVersionError(process.versions.node);
17
+ if (problem) {
18
+ console.error(problem);
19
+ process.exit(1);
20
+ }
21
+ //#endregion
22
+ export { nodeVersionError as n, MIN_NODE as t };
23
+
24
+ //# sourceMappingURL=node-check-CjTk6VNL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-check-CjTk6VNL.js","names":[],"sources":["../server/node-check.ts"],"sourcesContent":["/** The oldest Node.js xaq runs on (node:sqlite unflagged, import.meta.dirname). Keep in sync with package.json engines. */\nexport const MIN_NODE = \"22.13.0\";\n\n/** An explanation when `version` (e.g. process.versions.node) is too old, else null. */\nexport function nodeVersionError(version: string): string | null {\n const parse = (v: string) => v.replace(/^v/, \"\").split(\".\").map((n) => Number.parseInt(n, 10) || 0);\n const have = parse(version);\n const need = parse(MIN_NODE);\n for (let i = 0; i < 3; i++) {\n if ((have[i] ?? 0) > need[i]!) return null;\n if ((have[i] ?? 0) < need[i]!) return `xaq needs Node.js 22.13 or newer (you have ${version.replace(/^v?/, \"v\")}). Install a current Node.js from https://nodejs.org and try again.`;\n }\n return null;\n}\n\n// Runs on import, before anything that needs a newer Node is loaded.\nconst problem = nodeVersionError(process.versions.node);\nif (problem) {\n console.error(problem);\n process.exit(1);\n}\n"],"mappings":";;;AACA,MAAa,WAAW;;AAGxB,SAAgB,iBAAiB,SAAgC;CAC/D,MAAM,SAAS,MAAc,EAAE,QAAQ,MAAM,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,MAAM,OAAO,SAAS,GAAG,EAAE,KAAK,CAAC;CAClG,MAAM,OAAO,MAAM,OAAO;CAC1B,MAAM,OAAO,MAAM,QAAQ;CAC3B,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK;EAC1B,KAAK,KAAK,MAAM,KAAK,KAAK,IAAK,OAAO;EACtC,KAAK,KAAK,MAAM,KAAK,KAAK,IAAK,OAAO,8CAA8C,QAAQ,QAAQ,OAAO,GAAG,EAAE;CAClH;CACA,OAAO;AACT;AAGA,MAAM,UAAU,iBAAiB,QAAQ,SAAS,IAAI;AACtD,IAAI,SAAS;CACX,QAAQ,MAAM,OAAO;CACrB,QAAQ,KAAK,CAAC;AAChB"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export { c as profilePath } from "./paths-yzOKD6ow.js";
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ import { r as pickDir, t as LEGACY_PRODUCT } from "./brand--ZB8jTn1.js";
3
+ import { join } from "node:path";
4
+ import { homedir } from "node:os";
5
+ //#region server/listen/paths.ts
6
+ /**
7
+ * Agent-side locations (the machine running `connect` / `listen`, not the daemon). XDG on Linux and
8
+ * macOS alike, so one set of paths works everywhere:
9
+ * config $XDG_CONFIG_HOME/xaq (~/.config/xaq) profiles/<name>.json (0600)
10
+ * state $XDG_STATE_HOME/xaq (~/.local/state/xaq) listen/<name>/{listen.log,dead.jsonl,status.json}
11
+ * data $XDG_DATA_HOME/xaq (~/.local/share/xaq) app/ (stable install the services run)
12
+ * Each one is still the pre-rename `…/agentinbox` while that exists and the `…/xaq` one doesn't: existing
13
+ * profiles, keys, logs and the listener services' install stay where they are. Nothing is moved.
14
+ */
15
+ const xdg = (envVar, fallback) => {
16
+ const v = process.env[envVar];
17
+ return v && v.startsWith("/") ? v : join(homedir(), fallback);
18
+ };
19
+ const named = (base) => pickDir(join(base, "xaq"), join(base, LEGACY_PRODUCT)).dir;
20
+ const configDir = () => named(xdg("XDG_CONFIG_HOME", ".config"));
21
+ const stateDir = () => named(xdg("XDG_STATE_HOME", ".local/state"));
22
+ const dataDir = () => named(xdg("XDG_DATA_HOME", ".local/share"));
23
+ const profilesDir = () => join(configDir(), "profiles");
24
+ const profilePath = (name) => join(profilesDir(), `${name}.json`);
25
+ const profileStateDir = (name) => join(stateDir(), "listen", name);
26
+ const logPath = (name) => join(profileStateDir(name), "listen.log");
27
+ /** `listen --backfill` and `--dry-run` log separately, so they can run next to the listener without both rotating one file. */
28
+ const oneOffLogPath = (name) => join(profileStateDir(name), "one-off.log");
29
+ const deadPath = (name) => join(profileStateDir(name), "dead.jsonl");
30
+ const statusPath = (name) => join(profileStateDir(name), "status.json");
31
+ /** Default working directory for --exec commands: private (0700), so no planted CLAUDE.md, .mcp.json or hooks apply. */
32
+ const workDir = (name) => join(profileStateDir(name), "work");
33
+ /** The listeners' stable install (shared by all profiles), staged and swapped like the daemon's `<data>/app`. */
34
+ const listenAppDir = () => join(dataDir(), "app");
35
+ const DEFAULT_PROFILE = "default";
36
+ const PROFILE_RE = /^[a-z0-9][a-z0-9_-]{0,39}$/;
37
+ /** Profile names become file names and service names, so they are kept boring. */
38
+ function validProfileName(name) {
39
+ const n = name.trim().toLowerCase();
40
+ if (!PROFILE_RE.test(n)) throw new Error(`Invalid profile name "${name}": use 1-40 lowercase letters, digits, "-" or "_", starting with a letter or digit.`);
41
+ return n;
42
+ }
43
+ //#endregion
44
+ export { listenAppDir as a, profilePath as c, stateDir as d, statusPath as f, deadPath as i, profileStateDir as l, workDir as m, configDir as n, logPath as o, validProfileName as p, dataDir as r, oneOffLogPath as s, DEFAULT_PROFILE as t, profilesDir as u };
45
+
46
+ //# sourceMappingURL=paths-yzOKD6ow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths-yzOKD6ow.js","names":[],"sources":["../server/listen/paths.ts"],"sourcesContent":["import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { LEGACY_PRODUCT, pickDir, PRODUCT } from \"../brand.ts\";\n\n/**\n * Agent-side locations (the machine running `connect` / `listen`, not the daemon). XDG on Linux and\n * macOS alike, so one set of paths works everywhere:\n * config $XDG_CONFIG_HOME/xaq (~/.config/xaq) profiles/<name>.json (0600)\n * state $XDG_STATE_HOME/xaq (~/.local/state/xaq) listen/<name>/{listen.log,dead.jsonl,status.json}\n * data $XDG_DATA_HOME/xaq (~/.local/share/xaq) app/ (stable install the services run)\n * Each one is still the pre-rename `…/agentinbox` while that exists and the `…/xaq` one doesn't: existing\n * profiles, keys, logs and the listener services' install stay where they are. Nothing is moved.\n */\n\nconst xdg = (envVar: string, fallback: string) => {\n const v = process.env[envVar];\n // The XDG spec says relative paths are invalid and must be ignored.\n return v && v.startsWith(\"/\") ? v : join(homedir(), fallback);\n};\n\nconst named = (base: string) => pickDir(join(base, PRODUCT), join(base, LEGACY_PRODUCT)).dir;\n\nexport const configDir = () => named(xdg(\"XDG_CONFIG_HOME\", \".config\"));\nexport const stateDir = () => named(xdg(\"XDG_STATE_HOME\", \".local/state\"));\nexport const dataDir = () => named(xdg(\"XDG_DATA_HOME\", \".local/share\"));\n\nexport const profilesDir = () => join(configDir(), \"profiles\");\nexport const profilePath = (name: string) => join(profilesDir(), `${name}.json`);\nexport const profileStateDir = (name: string) => join(stateDir(), \"listen\", name);\nexport const logPath = (name: string) => join(profileStateDir(name), \"listen.log\");\n/** `listen --backfill` and `--dry-run` log separately, so they can run next to the listener without both rotating one file. */\nexport const oneOffLogPath = (name: string) => join(profileStateDir(name), \"one-off.log\");\nexport const deadPath = (name: string) => join(profileStateDir(name), \"dead.jsonl\");\nexport const statusPath = (name: string) => join(profileStateDir(name), \"status.json\");\n/** Default working directory for --exec commands: private (0700), so no planted CLAUDE.md, .mcp.json or hooks apply. */\nexport const workDir = (name: string) => join(profileStateDir(name), \"work\");\n/** The listeners' stable install (shared by all profiles), staged and swapped like the daemon's `<data>/app`. */\nexport const listenAppDir = () => join(dataDir(), \"app\");\n\nexport const DEFAULT_PROFILE = \"default\";\nconst PROFILE_RE = /^[a-z0-9][a-z0-9_-]{0,39}$/;\n\n/** Profile names become file names and service names, so they are kept boring. */\nexport function validProfileName(name: string): string {\n const n = name.trim().toLowerCase();\n if (!PROFILE_RE.test(n)) {\n throw new Error(`Invalid profile name \"${name}\": use 1-40 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
1
+ #!/usr/bin/env node
2
+ export { n as loadProfile } from "./profile-NmMKAczz.js";
@@ -0,0 +1,222 @@
1
+ #!/usr/bin/env node
2
+ import { t as LEGACY_PRODUCT } from "./brand--ZB8jTn1.js";
3
+ import { v as isEventType } from "./types-BhJDbSzE.js";
4
+ import { t as NPX } from "./version-BxH7OuWD.js";
5
+ import { c as profilePath, p as validProfileName, t as DEFAULT_PROFILE, u as profilesDir } from "./paths-yzOKD6ow.js";
6
+ import { r as webhookFilterSchema } from "./filter-Ck6OMxvu.js";
7
+ import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
8
+ import { dirname } from "node:path";
9
+ import { randomBytes } from "node:crypto";
10
+ import { z } from "zod";
11
+ //#region server/listen/fsutil.ts
12
+ /** Creates a directory (and parents) readable only by this user. Tightens an existing one. */
13
+ function ensurePrivateDir(dir) {
14
+ mkdirSync(dir, {
15
+ recursive: true,
16
+ mode: 448
17
+ });
18
+ if (process.platform !== "win32" && (statSync(dir).mode & 63) !== 0) chmodSync(dir, 448);
19
+ }
20
+ /**
21
+ * Writes a file with mode 0600 atomically (temp file + rename), so a crash never leaves a
22
+ * half-written profile and the secret is never briefly world-readable.
23
+ */
24
+ function writePrivateFile(linkOrPath, content, opts = {}) {
25
+ const path = resolveLink(linkOrPath);
26
+ if (opts.privateDir !== false) ensurePrivateDir(dirname(path));
27
+ else mkdirSync(dirname(path), { recursive: true });
28
+ const tmp = `${path}.${randomBytes(4).toString("hex")}.tmp`;
29
+ try {
30
+ writeFileSync(tmp, content, {
31
+ mode: 384,
32
+ flag: "wx"
33
+ });
34
+ chmodSync(tmp, 384);
35
+ renameSync(tmp, path);
36
+ } catch (err) {
37
+ rmSync(tmp, { force: true });
38
+ throw err;
39
+ }
40
+ }
41
+ function resolveLink(path) {
42
+ try {
43
+ return lstatSync(path).isSymbolicLink() ? realpathSync(path) : path;
44
+ } catch {
45
+ return path;
46
+ }
47
+ }
48
+ /** Copies `path` next to itself as `<path>.xaq-backup-<timestamp>` (0600). Returns the copy, or null if there was nothing to back up. */
49
+ function backupFile(path) {
50
+ if (!existsSync(path)) return null;
51
+ const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
52
+ const content = readFileSync(path);
53
+ for (let n = 0;; n++) {
54
+ const backup = `${path}.xaq-backup-${stamp}${n ? `-${n}` : ""}`;
55
+ try {
56
+ writeFileSync(backup, content, {
57
+ mode: 384,
58
+ flag: "wx"
59
+ });
60
+ return backup;
61
+ } catch (err) {
62
+ if (err.code !== "EEXIST" || n > 20) throw err;
63
+ }
64
+ }
65
+ }
66
+ /** Tightens an existing file to 0600 (files created by appendFileSync keep their first mode). */
67
+ function tighten(path) {
68
+ if (process.platform !== "win32" && existsSync(path) && (statSync(path).mode & 63) !== 0) chmodSync(path, 384);
69
+ }
70
+ /**
71
+ * A directory commands may run in: must exist, be owned by this user and not be writable by group or
72
+ * others (otherwise someone else could plant agent instructions, MCP configs or hooks there).
73
+ */
74
+ function assertTrustedDir(dir) {
75
+ let st;
76
+ try {
77
+ st = statSync(dir);
78
+ } catch {
79
+ throw new Error(`--cwd ${dir} does not exist.`);
80
+ }
81
+ if (!st.isDirectory()) throw new Error(`--cwd ${dir} is not a directory.`);
82
+ const uid = process.getuid?.();
83
+ if (uid !== void 0 && st.uid !== uid) throw new Error(`Refusing --cwd ${dir}: it belongs to another user, who could plant instructions or hooks for the agent there.`);
84
+ if (process.platform !== "win32" && (st.mode & 18) !== 0) throw new Error(`Refusing --cwd ${dir}: it is writable by group or others (mode ${(st.mode & 511).toString(8)}). Use a directory only you can write to.`);
85
+ for (let p = dirname(dir); p !== dirname(p); p = dirname(p)) try {
86
+ const ps = statSync(p);
87
+ if (process.platform !== "win32" && (ps.mode & 18) !== 0 && (ps.mode & 512) === 0) {
88
+ process.stderr.write(`warning: --cwd ${dir}: its parent ${p} is writable by group or others, so they could replace it.\n`);
89
+ break;
90
+ }
91
+ } catch {
92
+ break;
93
+ }
94
+ return dir;
95
+ }
96
+ /** True when group or others can read/write the file. */
97
+ const isTooOpen = (path) => process.platform !== "win32" && (statSync(path).mode & 63) !== 0;
98
+ //#endregion
99
+ //#region server/listen/names.ts
100
+ /**
101
+ * The names a profile is known by in the agent's tools: its MCP server (`xaq`, or `xaq-<profile>`), which
102
+ * is also its Hermes webhook route and, as `mcp-<server>`, the route's toolset.
103
+ *
104
+ * A profile made before the rename keeps `agentinbox` / `agentinbox-<profile>`: Hermes routes are confined
105
+ * to `toolsets: ["mcp-agentinbox"]` and cron jobs to `["agentinbox"]`, saved Claude Code recipes allow
106
+ * `mcp__agentinbox`, and the client configs register that name. Renaming any of them would quietly break
107
+ * the others. So the name is saved in the profile (`mcpServer`): new profiles get `xaq…`, and a profile
108
+ * without the field was made by agentinbox and keeps `agentinbox…` (written into the file the next time
109
+ * it is saved).
110
+ */
111
+ const SERVER_NAME_RE = /^[a-z0-9][a-z0-9_-]{0,63}$/;
112
+ const isServerName = (s) => typeof s === "string" && SERVER_NAME_RE.test(s);
113
+ const named = (base, profile) => profile === "default" ? base : `${base}-${profile}`;
114
+ /** The MCP server name a new profile gets. */
115
+ const newServerName = (profile) => named("xaq", validProfileName(profile));
116
+ /** The name a profile from before the rename was registered under. */
117
+ const legacyServerName = (profile) => named(LEGACY_PRODUCT, validProfileName(profile));
118
+ /**
119
+ * The server name saved in the profile file; for a profile file without one (made before the rename),
120
+ * the pre-rename name; null when there is no profile file yet.
121
+ */
122
+ function savedServerName(profile) {
123
+ const path = profilePath(validProfileName(profile));
124
+ if (!existsSync(path)) return null;
125
+ try {
126
+ const saved = JSON.parse(readFileSync(path, "utf8"))?.mcpServer;
127
+ if (isServerName(saved)) return saved;
128
+ } catch {}
129
+ return legacyServerName(profile);
130
+ }
131
+ /** The MCP server (and Hermes route) name for a profile: see the comment at the top. */
132
+ const mcpServerName = (profile) => savedServerName(profile) ?? newServerName(profile);
133
+ /**
134
+ * The product name a profile's own texts use: "agentinbox" for a profile that kept its pre-rename names,
135
+ * else "xaq". It names the server in the keyless Claude Code MCP config (`mcp__<it>` in the recipe) and
136
+ * appears in the recipe prompts, so the commands saved in an old profile still match its recipes exactly.
137
+ */
138
+ const profileBrand = (profile) => mcpServerName(profile) === legacyServerName(profile) ? LEGACY_PRODUCT : "xaq";
139
+ //#endregion
140
+ //#region server/listen/profile.ts
141
+ const profileSchema = z.object({
142
+ url: z.string().refine((u) => URL.canParse(u), "url must be a full URL"),
143
+ apiKey: z.string().min(8),
144
+ agentId: z.string().min(1),
145
+ agentName: z.string(),
146
+ consumer: z.string().min(1).max(100),
147
+ insecure: z.boolean().optional(),
148
+ types: z.array(z.string().refine(isEventType)).transform((t) => t).optional(),
149
+ filter: webhookFilterSchema.optional(),
150
+ includeBody: z.boolean().optional(),
151
+ exec: z.string().min(1).optional(),
152
+ forward: z.object({
153
+ url: z.string(),
154
+ secret: z.string().startsWith("whsec_")
155
+ }).optional(),
156
+ concurrency: z.number().int().min(1).max(32).optional(),
157
+ timeoutSeconds: z.number().int().min(1).max(86400).optional(),
158
+ maxAttempts: z.number().int().min(1).max(100).optional(),
159
+ tool: z.enum([
160
+ "claude-code",
161
+ "codex",
162
+ "cursor",
163
+ "hermes",
164
+ "other"
165
+ ]).optional(),
166
+ mcpUrl: z.string().optional(),
167
+ skillUrl: z.string().optional(),
168
+ forwardSecret: z.string().startsWith("whsec_").optional(),
169
+ cwd: z.string().startsWith("/").optional(),
170
+ exclude: webhookFilterSchema.pick({
171
+ from: true,
172
+ labelIds: true
173
+ }).optional(),
174
+ skipCategories: z.array(z.string().regex(/^CATEGORY_[A-Z]+$/)).max(10).optional(),
175
+ batchSeconds: z.number().int().min(1).max(3600).optional(),
176
+ mcpServer: z.string().refine(isServerName, "mcpServer must be a plain name").optional(),
177
+ createdAt: z.string().optional()
178
+ }).loose();
179
+ const profileExists = (name) => existsSync(profilePath(validProfileName(name)));
180
+ function listProfiles() {
181
+ if (!existsSync(profilesDir())) return [];
182
+ return readdirSync(profilesDir()).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -5)).sort();
183
+ }
184
+ function loadProfile(name = DEFAULT_PROFILE) {
185
+ const n = validProfileName(name);
186
+ const path = profilePath(n);
187
+ if (!existsSync(path)) {
188
+ const others = listProfiles();
189
+ const hint = others.length ? ` Known profiles: ${others.join(", ")} (pick one with --profile).` : ` Run \`${NPX} connect <daemon-url>\` first.`;
190
+ throw new Error(`No xaq profile "${n}" (${path}).${hint}`);
191
+ }
192
+ if (isTooOpen(path)) {
193
+ chmodSync(path, 384);
194
+ process.stderr.write(`warning: ${path} was readable by other users; it is 0600 again. If anyone else could have read it, rotate the agent's key in the console and run \`${NPX} connect … --force\`.\n`);
195
+ }
196
+ let raw;
197
+ try {
198
+ raw = JSON.parse(readFileSync(path, "utf8"));
199
+ } catch (err) {
200
+ throw new Error(`Profile ${path} is not valid JSON (${err.message}). Fix it or run \`${NPX} connect\` again.`);
201
+ }
202
+ const parsed = profileSchema.safeParse(raw);
203
+ if (!parsed.success) {
204
+ const issue = parsed.error.issues[0];
205
+ throw new Error(`Profile ${path} is invalid: ${issue?.path.join(".") || "file"}: ${issue?.message}`);
206
+ }
207
+ return parsed.data;
208
+ }
209
+ function saveProfile(name, profile) {
210
+ const path = profilePath(validProfileName(name));
211
+ const withName = {
212
+ ...profile,
213
+ mcpServer: profile.mcpServer ?? mcpServerName(name)
214
+ };
215
+ const clean = Object.fromEntries(Object.entries(withName).filter(([, v]) => v !== void 0));
216
+ writePrivateFile(path, JSON.stringify(clean, null, 2) + "\n");
217
+ return path;
218
+ }
219
+ //#endregion
220
+ export { mcpServerName as a, backupFile as c, tighten as d, writePrivateFile as f, saveProfile as i, ensurePrivateDir as l, loadProfile as n, profileBrand as o, profileExists as r, assertTrustedDir as s, listProfiles as t, isTooOpen as u };
221
+
222
+ //# sourceMappingURL=profile-NmMKAczz.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-NmMKAczz.js","names":[],"sources":["../server/listen/fsutil.ts","../server/listen/names.ts","../server/listen/profile.ts"],"sourcesContent":["import { randomBytes } from \"node:crypto\";\nimport { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\n\n/** Creates a directory (and parents) readable only by this user. Tightens an existing one. */\nexport function ensurePrivateDir(dir: string): void {\n mkdirSync(dir, { recursive: true, mode: 0o700 });\n if (process.platform !== \"win32\" && (statSync(dir).mode & 0o077) !== 0) chmodSync(dir, 0o700);\n}\n\n/**\n * Writes a file with mode 0600 atomically (temp file + rename), so a crash never leaves a\n * half-written profile and the secret is never briefly world-readable.\n */\nexport function writePrivateFile(linkOrPath: string, content: string, opts: { privateDir?: boolean } = {}): void {\n // A symlinked config (dotfiles repos) is updated at its real location instead of being replaced by a plain file.\n const path = resolveLink(linkOrPath);\n if (opts.privateDir !== false) ensurePrivateDir(dirname(path));\n else mkdirSync(dirname(path), { recursive: true });\n const tmp = `${path}.${randomBytes(4).toString(\"hex\")}.tmp`;\n try {\n writeFileSync(tmp, content, { mode: 0o600, flag: \"wx\" });\n chmodSync(tmp, 0o600);\n renameSync(tmp, path);\n } catch (err) {\n rmSync(tmp, { force: true });\n throw err;\n }\n}\n\nfunction resolveLink(path: string): string {\n try {\n return lstatSync(path).isSymbolicLink() ? realpathSync(path) : path;\n } catch {\n return path;\n }\n}\n\n/** Copies `path` next to itself as `<path>.xaq-backup-<timestamp>` (0600). Returns the copy, or null if there was nothing to back up. */\nexport function backupFile(path: string): string | null {\n if (!existsSync(path)) return null;\n const stamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const content = readFileSync(path);\n // Created 0600 and exclusively (never through an existing file or symlink), then filled.\n for (let n = 0; ; n++) {\n const backup = `${path}.xaq-backup-${stamp}${n ? `-${n}` : \"\"}`;\n try {\n writeFileSync(backup, content, { mode: 0o600, flag: \"wx\" });\n return backup;\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"EEXIST\" || n > 20) throw err;\n }\n }\n}\n\n/** Tightens an existing file to 0600 (files created by appendFileSync keep their first mode). */\nexport function tighten(path: string): void {\n if (process.platform !== \"win32\" && existsSync(path) && (statSync(path).mode & 0o077) !== 0) chmodSync(path, 0o600);\n}\n\n/**\n * A directory commands may run in: must exist, be owned by this user and not be writable by group or\n * others (otherwise someone else could plant agent instructions, MCP configs or hooks there).\n */\nexport function assertTrustedDir(dir: string): string {\n let st;\n try {\n st = statSync(dir);\n } catch {\n throw new Error(`--cwd ${dir} does not exist.`);\n }\n if (!st.isDirectory()) throw new Error(`--cwd ${dir} is not a directory.`);\n const uid = process.getuid?.();\n if (uid !== undefined && st.uid !== uid) throw new Error(`Refusing --cwd ${dir}: it belongs to another user, who could plant instructions or hooks for the agent there.`);\n if (process.platform !== \"win32\" && (st.mode & 0o022) !== 0) {\n throw new Error(`Refusing --cwd ${dir}: it is writable by group or others (mode ${(st.mode & 0o777).toString(8)}). Use a directory only you can write to.`);\n }\n // A parent others can write to (without the sticky bit) lets them swap this directory out.\n for (let p = dirname(dir); p !== dirname(p); p = dirname(p)) {\n try {\n const ps = statSync(p);\n if (process.platform !== \"win32\" && (ps.mode & 0o022) !== 0 && (ps.mode & 0o1000) === 0) {\n process.stderr.write(`warning: --cwd ${dir}: its parent ${p} is writable by group or others, so they could replace it.\\n`);\n break;\n }\n } catch {\n break;\n }\n }\n return dir;\n}\n\n/** True when group or others can read/write the file. */\nexport const isTooOpen = (path: string) => process.platform !== \"win32\" && (statSync(path).mode & 0o077) !== 0;\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { LEGACY_PRODUCT, PRODUCT } from \"../brand.ts\";\nimport { DEFAULT_PROFILE, profilePath, validProfileName } from \"./paths.ts\";\n\n/**\n * The names a profile is known by in the agent's tools: its MCP server (`xaq`, or `xaq-<profile>`), which\n * is also its Hermes webhook route and, as `mcp-<server>`, the route's toolset.\n *\n * A profile made before the rename keeps `agentinbox` / `agentinbox-<profile>`: Hermes routes are confined\n * to `toolsets: [\"mcp-agentinbox\"]` and cron jobs to `[\"agentinbox\"]`, saved Claude Code recipes allow\n * `mcp__agentinbox`, and the client configs register that name. Renaming any of them would quietly break\n * the others. So the name is saved in the profile (`mcpServer`): new profiles get `xaq…`, and a profile\n * without the field was made by agentinbox and keeps `agentinbox…` (written into the file the next time\n * it is saved).\n */\n\nconst SERVER_NAME_RE = /^[a-z0-9][a-z0-9_-]{0,63}$/;\nexport const isServerName = (s: unknown): s is string => typeof s === \"string\" && SERVER_NAME_RE.test(s);\n\nconst named = (base: string, profile: string) => (profile === DEFAULT_PROFILE ? base : `${base}-${profile}`);\n/** The MCP server name a new profile gets. */\nexport const newServerName = (profile: string) => named(PRODUCT, validProfileName(profile));\n/** The name a profile from before the rename was registered under. */\nexport const legacyServerName = (profile: string) => named(LEGACY_PRODUCT, validProfileName(profile));\n\n/**\n * The server name saved in the profile file; for a profile file without one (made before the rename),\n * the pre-rename name; null when there is no profile file yet.\n */\nexport function savedServerName(profile: string): string | null {\n const path = profilePath(validProfileName(profile));\n if (!existsSync(path)) return null;\n try {\n const saved = (JSON.parse(readFileSync(path, \"utf8\")) as { mcpServer?: unknown } | null)?.mcpServer;\n if (isServerName(saved)) return saved;\n } catch {\n // Unreadable: loadProfile reports that properly; the name falls back like an old profile's.\n }\n return legacyServerName(profile);\n}\n\n/** The MCP server (and Hermes route) name for a profile: see the comment at the top. */\nexport const mcpServerName = (profile: string): string => savedServerName(profile) ?? newServerName(profile);\n\n/**\n * The product name a profile's own texts use: \"agentinbox\" for a profile that kept its pre-rename names,\n * else \"xaq\". It names the server in the keyless Claude Code MCP config (`mcp__<it>` in the recipe) and\n * appears in the recipe prompts, so the commands saved in an old profile still match its recipes exactly.\n */\nexport const profileBrand = (profile: string): string => (mcpServerName(profile) === legacyServerName(profile) ? LEGACY_PRODUCT : PRODUCT);\n","import { chmodSync, existsSync, readdirSync, readFileSync, rmSync } from \"node:fs\";\nimport { z } from \"zod\";\nimport type { AgentTool, ListenerConfig } from \"../../shared/agent-api.ts\";\nimport { type EventType, isEventType } from \"../../shared/types.ts\";\nimport { webhookFilterSchema } from \"../webhooks/filter.ts\";\nimport { isTooOpen, writePrivateFile } from \"./fsutil.ts\";\nimport { isServerName, mcpServerName } from \"./names.ts\";\nimport { DEFAULT_PROFILE, profilePath, profilesDir, validProfileName } from \"./paths.ts\";\nimport { NPX } from \"./version.ts\";\n\n/**\n * A profile file: the shared ListenerConfig plus a few agent-side extras. Holds the agent's API key,\n * so it is always 0600 inside a 0700 directory, and nothing ever prints it.\n */\nexport interface Profile extends ListenerConfig {\n tool?: AgentTool;\n mcpUrl?: string;\n skillUrl?: string;\n /** Forward-mode signing secret while no forward URL is saved (see forwardSecret()). */\n forwardSecret?: string;\n /** Working directory for --exec commands (default: a private dir in the state dir). */\n cwd?: string;\n /** Senders / labels to skip (listener-side; `--not-from`, `--not-label`). */\n exclude?: { from?: string[]; labelIds?: string[] };\n /** Gmail category labels to skip; absent = the default (promotions, social, forums), [] = none. */\n skipCategories?: string[];\n /** `--batch`: seconds to collect events into one --exec run. */\n batchSeconds?: number;\n /**\n * The MCP server name (also the Hermes route) registered for this profile: `xaq[-<profile>]`, or the\n * pre-rename `agentinbox[-<profile>]` it was set up with. Filled in on save; see names.ts. (rename-xaq: keep)\n */\n mcpServer?: string;\n createdAt?: string;\n}\n\nconst TOOLS = [\"claude-code\", \"codex\", \"cursor\", \"hermes\", \"other\"] as const;\n\nconst profileSchema = z\n .object({\n url: z.string().refine((u) => URL.canParse(u), \"url must be a full URL\"),\n apiKey: z.string().min(8),\n agentId: z.string().min(1),\n agentName: z.string(),\n consumer: z.string().min(1).max(100),\n insecure: z.boolean().optional(),\n types: z\n .array(z.string().refine(isEventType))\n .transform((t) => t as EventType[])\n .optional(),\n filter: webhookFilterSchema.optional(),\n includeBody: z.boolean().optional(),\n exec: z.string().min(1).optional(),\n forward: z.object({ url: z.string(), secret: z.string().startsWith(\"whsec_\") }).optional(),\n concurrency: z.number().int().min(1).max(32).optional(),\n timeoutSeconds: z.number().int().min(1).max(86_400).optional(),\n maxAttempts: z.number().int().min(1).max(100).optional(),\n tool: z.enum(TOOLS).optional(),\n mcpUrl: z.string().optional(),\n skillUrl: z.string().optional(),\n forwardSecret: z.string().startsWith(\"whsec_\").optional(),\n cwd: z.string().startsWith(\"/\").optional(),\n exclude: webhookFilterSchema.pick({ from: true, labelIds: true }).optional(),\n skipCategories: z.array(z.string().regex(/^CATEGORY_[A-Z]+$/)).max(10).optional(),\n batchSeconds: z.number().int().min(1).max(3600).optional(),\n mcpServer: z.string().refine(isServerName, \"mcpServer must be a plain name\").optional(),\n createdAt: z.string().optional(),\n })\n .loose();\n\nexport const profileExists = (name: string) => existsSync(profilePath(validProfileName(name)));\n\nexport function listProfiles(): string[] {\n if (!existsSync(profilesDir())) return [];\n return readdirSync(profilesDir())\n .filter((f) => f.endsWith(\".json\"))\n .map((f) => f.slice(0, -5))\n .sort();\n}\n\nexport function loadProfile(name: string = DEFAULT_PROFILE): Profile {\n const n = validProfileName(name);\n const path = profilePath(n);\n if (!existsSync(path)) {\n const others = listProfiles();\n const hint = others.length ? ` Known profiles: ${others.join(\", \")} (pick one with --profile).` : ` Run \\`${NPX} connect <daemon-url>\\` first.`;\n throw new Error(`No xaq profile \"${n}\" (${path}).${hint}`);\n }\n // Someone loosened the permissions: tighten them, and say the key may have been read meanwhile.\n if (isTooOpen(path)) {\n chmodSync(path, 0o600);\n process.stderr.write(\n `warning: ${path} was readable by other users; it is 0600 again. If anyone else could have read it, rotate the agent's key in the console and run \\`${NPX} connect … --force\\`.\\n`,\n );\n }\n let raw: unknown;\n try {\n raw = JSON.parse(readFileSync(path, \"utf8\"));\n } catch (err) {\n throw new Error(`Profile ${path} is not valid JSON (${(err as Error).message}). Fix it or run \\`${NPX} connect\\` again.`);\n }\n const parsed = profileSchema.safeParse(raw);\n if (!parsed.success) {\n const issue = parsed.error.issues[0];\n throw new Error(`Profile ${path} is invalid: ${issue?.path.join(\".\") || \"file\"}: ${issue?.message}`);\n }\n return parsed.data as Profile;\n}\n\nexport function saveProfile(name: string, profile: Profile): string {\n const path = profilePath(validProfileName(name));\n // The server name is pinned on every save: a new profile gets xaq…, one from before the rename (or one\n // replaced by `connect --force`) keeps the name its agent tools and Hermes routes already use.\n const withName: Profile = { ...profile, mcpServer: profile.mcpServer ?? mcpServerName(name) };\n const clean = Object.fromEntries(Object.entries(withName).filter(([, v]) => v !== undefined));\n writePrivateFile(path, JSON.stringify(clean, null, 2) + \"\\n\");\n return path;\n}\n\nexport function deleteProfile(name: string): void {\n rmSync(profilePath(validProfileName(name)), { force: true });\n}\n"],"mappings":";;;;;;;;;;;;AAKA,SAAgB,iBAAiB,KAAmB;CAClD,UAAU,KAAK;EAAE,WAAW;EAAM,MAAM;CAAM,CAAC;CAC/C,IAAI,QAAQ,aAAa,YAAY,SAAS,GAAG,CAAC,CAAC,OAAO,QAAW,GAAG,UAAU,KAAK,GAAK;AAC9F;;;;;AAMA,SAAgB,iBAAiB,YAAoB,SAAiB,OAAiC,CAAC,GAAS;CAE/G,MAAM,OAAO,YAAY,UAAU;CACnC,IAAI,KAAK,eAAe,OAAO,iBAAiB,QAAQ,IAAI,CAAC;MACxD,UAAU,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;CACjD,MAAM,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,SAAS,KAAK,EAAE;CACtD,IAAI;EACF,cAAc,KAAK,SAAS;GAAE,MAAM;GAAO,MAAM;EAAK,CAAC;EACvD,UAAU,KAAK,GAAK;EACpB,WAAW,KAAK,IAAI;CACtB,SAAS,KAAK;EACZ,OAAO,KAAK,EAAE,OAAO,KAAK,CAAC;EAC3B,MAAM;CACR;AACF;AAEA,SAAS,YAAY,MAAsB;CACzC,IAAI;EACF,OAAO,UAAU,IAAI,CAAC,CAAC,eAAe,IAAI,aAAa,IAAI,IAAI;CACjE,QAAQ;EACN,OAAO;CACT;AACF;;AAGA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