@agent-native/core 0.98.17 → 0.99.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (545) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +15 -0
  3. package/corpus/core/docs/content/actions.mdx +1 -1
  4. package/corpus/core/docs/content/authentication.mdx +1 -1
  5. package/corpus/core/docs/content/dispatch.mdx +3 -3
  6. package/corpus/core/docs/content/external-agents.mdx +30 -19
  7. package/corpus/core/docs/content/locales/ar-SA/actions.mdx +1 -1
  8. package/corpus/core/docs/content/locales/ar-SA/authentication.mdx +1 -1
  9. package/corpus/core/docs/content/locales/ar-SA/dispatch.mdx +3 -3
  10. package/corpus/core/docs/content/locales/ar-SA/external-agents.mdx +23 -19
  11. package/corpus/core/docs/content/locales/ar-SA/mcp-clients.mdx +31 -3
  12. package/corpus/core/docs/content/locales/ar-SA/mcp-protocol.mdx +29 -15
  13. package/corpus/core/docs/content/locales/ar-SA/plan-plugin.mdx +3 -3
  14. package/corpus/core/docs/content/locales/ar-SA/server.mdx +2 -2
  15. package/corpus/core/docs/content/locales/ar-SA/skills-guide.mdx +1 -1
  16. package/corpus/core/docs/content/locales/ar-SA/template-assets.mdx +1 -1
  17. package/corpus/core/docs/content/locales/ar-SA/template-dispatch.mdx +2 -2
  18. package/corpus/core/docs/content/locales/ar-SA/template-plan.mdx +3 -3
  19. package/corpus/core/docs/content/locales/de-DE/actions.mdx +1 -1
  20. package/corpus/core/docs/content/locales/de-DE/authentication.mdx +1 -1
  21. package/corpus/core/docs/content/locales/de-DE/dispatch.mdx +3 -3
  22. package/corpus/core/docs/content/locales/de-DE/external-agents.mdx +23 -19
  23. package/corpus/core/docs/content/locales/de-DE/mcp-clients.mdx +37 -3
  24. package/corpus/core/docs/content/locales/de-DE/mcp-protocol.mdx +29 -15
  25. package/corpus/core/docs/content/locales/de-DE/plan-plugin.mdx +3 -3
  26. package/corpus/core/docs/content/locales/de-DE/server.mdx +2 -2
  27. package/corpus/core/docs/content/locales/de-DE/skills-guide.mdx +1 -1
  28. package/corpus/core/docs/content/locales/de-DE/template-assets.mdx +1 -1
  29. package/corpus/core/docs/content/locales/de-DE/template-dispatch.mdx +2 -2
  30. package/corpus/core/docs/content/locales/de-DE/template-plan.mdx +3 -3
  31. package/corpus/core/docs/content/locales/es-ES/actions.mdx +1 -1
  32. package/corpus/core/docs/content/locales/es-ES/authentication.mdx +1 -1
  33. package/corpus/core/docs/content/locales/es-ES/dispatch.mdx +3 -3
  34. package/corpus/core/docs/content/locales/es-ES/external-agents.mdx +32 -19
  35. package/corpus/core/docs/content/locales/es-ES/mcp-clients.mdx +17 -3
  36. package/corpus/core/docs/content/locales/es-ES/mcp-protocol.mdx +38 -15
  37. package/corpus/core/docs/content/locales/es-ES/plan-plugin.mdx +3 -3
  38. package/corpus/core/docs/content/locales/es-ES/server.mdx +2 -2
  39. package/corpus/core/docs/content/locales/es-ES/skills-guide.mdx +1 -1
  40. package/corpus/core/docs/content/locales/es-ES/template-assets.mdx +1 -1
  41. package/corpus/core/docs/content/locales/es-ES/template-dispatch.mdx +2 -2
  42. package/corpus/core/docs/content/locales/es-ES/template-plan.mdx +3 -3
  43. package/corpus/core/docs/content/locales/fr-FR/actions.mdx +1 -1
  44. package/corpus/core/docs/content/locales/fr-FR/authentication.mdx +1 -1
  45. package/corpus/core/docs/content/locales/fr-FR/dispatch.mdx +3 -3
  46. package/corpus/core/docs/content/locales/fr-FR/external-agents.mdx +23 -19
  47. package/corpus/core/docs/content/locales/fr-FR/mcp-clients.mdx +17 -3
  48. package/corpus/core/docs/content/locales/fr-FR/mcp-protocol.mdx +29 -15
  49. package/corpus/core/docs/content/locales/fr-FR/plan-plugin.mdx +3 -3
  50. package/corpus/core/docs/content/locales/fr-FR/server.mdx +2 -2
  51. package/corpus/core/docs/content/locales/fr-FR/skills-guide.mdx +1 -1
  52. package/corpus/core/docs/content/locales/fr-FR/template-assets.mdx +1 -1
  53. package/corpus/core/docs/content/locales/fr-FR/template-dispatch.mdx +2 -2
  54. package/corpus/core/docs/content/locales/fr-FR/template-plan.mdx +3 -3
  55. package/corpus/core/docs/content/locales/hi-IN/actions.mdx +1 -1
  56. package/corpus/core/docs/content/locales/hi-IN/authentication.mdx +1 -1
  57. package/corpus/core/docs/content/locales/hi-IN/dispatch.mdx +3 -3
  58. package/corpus/core/docs/content/locales/hi-IN/external-agents.mdx +31 -19
  59. package/corpus/core/docs/content/locales/hi-IN/mcp-clients.mdx +17 -3
  60. package/corpus/core/docs/content/locales/hi-IN/mcp-protocol.mdx +36 -15
  61. package/corpus/core/docs/content/locales/hi-IN/plan-plugin.mdx +3 -3
  62. package/corpus/core/docs/content/locales/hi-IN/server.mdx +2 -2
  63. package/corpus/core/docs/content/locales/hi-IN/skills-guide.mdx +1 -1
  64. package/corpus/core/docs/content/locales/hi-IN/template-assets.mdx +1 -1
  65. package/corpus/core/docs/content/locales/hi-IN/template-dispatch.mdx +2 -2
  66. package/corpus/core/docs/content/locales/hi-IN/template-plan.mdx +3 -3
  67. package/corpus/core/docs/content/locales/ja-JP/actions.mdx +1 -1
  68. package/corpus/core/docs/content/locales/ja-JP/authentication.mdx +1 -1
  69. package/corpus/core/docs/content/locales/ja-JP/dispatch.mdx +3 -3
  70. package/corpus/core/docs/content/locales/ja-JP/external-agents.mdx +23 -19
  71. package/corpus/core/docs/content/locales/ja-JP/mcp-clients.mdx +34 -3
  72. package/corpus/core/docs/content/locales/ja-JP/mcp-protocol.mdx +29 -15
  73. package/corpus/core/docs/content/locales/ja-JP/plan-plugin.mdx +3 -3
  74. package/corpus/core/docs/content/locales/ja-JP/server.mdx +2 -2
  75. package/corpus/core/docs/content/locales/ja-JP/skills-guide.mdx +1 -1
  76. package/corpus/core/docs/content/locales/ja-JP/template-assets.mdx +1 -1
  77. package/corpus/core/docs/content/locales/ja-JP/template-dispatch.mdx +2 -2
  78. package/corpus/core/docs/content/locales/ja-JP/template-plan.mdx +3 -3
  79. package/corpus/core/docs/content/locales/ko-KR/actions.mdx +1 -1
  80. package/corpus/core/docs/content/locales/ko-KR/authentication.mdx +1 -1
  81. package/corpus/core/docs/content/locales/ko-KR/dispatch.mdx +3 -3
  82. package/corpus/core/docs/content/locales/ko-KR/external-agents.mdx +30 -19
  83. package/corpus/core/docs/content/locales/ko-KR/mcp-clients.mdx +33 -3
  84. package/corpus/core/docs/content/locales/ko-KR/mcp-protocol.mdx +36 -15
  85. package/corpus/core/docs/content/locales/ko-KR/plan-plugin.mdx +3 -3
  86. package/corpus/core/docs/content/locales/ko-KR/server.mdx +2 -2
  87. package/corpus/core/docs/content/locales/ko-KR/skills-guide.mdx +1 -1
  88. package/corpus/core/docs/content/locales/ko-KR/template-assets.mdx +1 -1
  89. package/corpus/core/docs/content/locales/ko-KR/template-dispatch.mdx +2 -2
  90. package/corpus/core/docs/content/locales/ko-KR/template-plan.mdx +3 -3
  91. package/corpus/core/docs/content/locales/pt-BR/actions.mdx +1 -1
  92. package/corpus/core/docs/content/locales/pt-BR/authentication.mdx +1 -1
  93. package/corpus/core/docs/content/locales/pt-BR/dispatch.mdx +3 -3
  94. package/corpus/core/docs/content/locales/pt-BR/external-agents.mdx +32 -19
  95. package/corpus/core/docs/content/locales/pt-BR/mcp-clients.mdx +34 -3
  96. package/corpus/core/docs/content/locales/pt-BR/mcp-protocol.mdx +32 -15
  97. package/corpus/core/docs/content/locales/pt-BR/plan-plugin.mdx +3 -3
  98. package/corpus/core/docs/content/locales/pt-BR/server.mdx +2 -2
  99. package/corpus/core/docs/content/locales/pt-BR/skills-guide.mdx +1 -1
  100. package/corpus/core/docs/content/locales/pt-BR/template-assets.mdx +1 -1
  101. package/corpus/core/docs/content/locales/pt-BR/template-dispatch.mdx +2 -2
  102. package/corpus/core/docs/content/locales/pt-BR/template-plan.mdx +3 -3
  103. package/corpus/core/docs/content/locales/zh-CN/actions.mdx +1 -1
  104. package/corpus/core/docs/content/locales/zh-CN/authentication.mdx +1 -1
  105. package/corpus/core/docs/content/locales/zh-CN/dispatch.mdx +3 -3
  106. package/corpus/core/docs/content/locales/zh-CN/external-agents.mdx +23 -19
  107. package/corpus/core/docs/content/locales/zh-CN/mcp-clients.mdx +28 -3
  108. package/corpus/core/docs/content/locales/zh-CN/mcp-protocol.mdx +29 -15
  109. package/corpus/core/docs/content/locales/zh-CN/plan-plugin.mdx +3 -3
  110. package/corpus/core/docs/content/locales/zh-CN/server.mdx +2 -2
  111. package/corpus/core/docs/content/locales/zh-CN/skills-guide.mdx +1 -1
  112. package/corpus/core/docs/content/locales/zh-CN/template-assets.mdx +1 -1
  113. package/corpus/core/docs/content/locales/zh-CN/template-dispatch.mdx +2 -2
  114. package/corpus/core/docs/content/locales/zh-CN/template-plan.mdx +3 -3
  115. package/corpus/core/docs/content/locales/zh-TW/actions.mdx +1 -1
  116. package/corpus/core/docs/content/locales/zh-TW/authentication.mdx +1 -1
  117. package/corpus/core/docs/content/locales/zh-TW/dispatch.mdx +3 -3
  118. package/corpus/core/docs/content/locales/zh-TW/external-agents.mdx +23 -19
  119. package/corpus/core/docs/content/locales/zh-TW/mcp-clients.mdx +28 -3
  120. package/corpus/core/docs/content/locales/zh-TW/mcp-protocol.mdx +30 -15
  121. package/corpus/core/docs/content/locales/zh-TW/plan-plugin.mdx +3 -3
  122. package/corpus/core/docs/content/locales/zh-TW/server.mdx +2 -2
  123. package/corpus/core/docs/content/locales/zh-TW/skills-guide.mdx +1 -1
  124. package/corpus/core/docs/content/locales/zh-TW/template-assets.mdx +1 -1
  125. package/corpus/core/docs/content/locales/zh-TW/template-dispatch.mdx +2 -2
  126. package/corpus/core/docs/content/locales/zh-TW/template-plan.mdx +3 -3
  127. package/corpus/core/docs/content/mcp-clients.mdx +31 -4
  128. package/corpus/core/docs/content/mcp-protocol.mdx +35 -15
  129. package/corpus/core/docs/content/plan-plugin.mdx +3 -3
  130. package/corpus/core/docs/content/server.mdx +2 -2
  131. package/corpus/core/docs/content/skills-guide.mdx +1 -1
  132. package/corpus/core/docs/content/template-assets.mdx +1 -1
  133. package/corpus/core/docs/content/template-dispatch.mdx +2 -2
  134. package/corpus/core/docs/content/template-plan.mdx +3 -3
  135. package/corpus/core/package.json +1 -1
  136. package/corpus/core/src/a2a/client.ts +3 -0
  137. package/corpus/core/src/a2a/handlers.ts +95 -7
  138. package/corpus/core/src/cli/connect.ts +50 -24
  139. package/corpus/core/src/cli/mcp-config-writers.ts +10 -0
  140. package/corpus/core/src/cli/mcp.ts +5 -5
  141. package/corpus/core/src/cli/skills-content/assets-skill.ts +1 -1
  142. package/corpus/core/src/cli/skills-content/design-exploration-skill.ts +1 -1
  143. package/corpus/core/src/cli/skills-content/help.ts +1 -1
  144. package/corpus/core/src/cli/skills-content/plan-setup-auth.ts +1 -1
  145. package/corpus/core/src/cli/skills-content/visual-plan-skill.ts +1 -1
  146. package/corpus/core/src/cli/skills-content/visual-recap-skill.ts +2 -2
  147. package/corpus/core/src/cli/skills.ts +23 -12
  148. package/corpus/core/src/client/resources/McpIntegrationDialog.tsx +5 -0
  149. package/corpus/core/src/client/resources/mcp-integration-catalog.ts +17 -0
  150. package/corpus/core/src/embedding/agent.ts +8 -6
  151. package/corpus/core/src/localization/default-messages.ts +7 -0
  152. package/corpus/core/src/mcp/ask-app-inline-tasks.ts +125 -0
  153. package/corpus/core/src/mcp/build-server.ts +65 -3
  154. package/corpus/core/src/mcp/builtin-tools.ts +186 -22
  155. package/corpus/core/src/mcp/connect-route.ts +17 -14
  156. package/corpus/core/src/mcp/oauth-route.ts +38 -13
  157. package/corpus/core/src/mcp/route-paths.ts +34 -0
  158. package/corpus/core/src/mcp/server.ts +21 -10
  159. package/corpus/core/src/mcp/stdio.ts +34 -16
  160. package/corpus/core/src/mcp/workspace-resolve.ts +2 -1
  161. package/corpus/core/src/mcp-client/manager.ts +5 -3
  162. package/corpus/core/src/mcp-client/remote-store.ts +10 -10
  163. package/corpus/core/src/server/agent-chat-plugin.ts +42 -9
  164. package/corpus/core/src/server/auth.ts +22 -6
  165. package/corpus/core/src/server/core-routes-plugin.ts +30 -24
  166. package/corpus/core/src/server/csrf.ts +17 -0
  167. package/corpus/core/src/server/framework-request-handler.ts +8 -2
  168. package/corpus/core/src/server/google-oauth.ts +6 -0
  169. package/corpus/core/src/server/http-response-telemetry.ts +6 -1
  170. package/corpus/core/src/server/recap-image-route.ts +3 -3
  171. package/corpus/core/src/server/security-headers.ts +7 -1
  172. package/corpus/core/src/server/ssr-handler.ts +2 -0
  173. package/corpus/core/src/shared/cache-control.ts +6 -4
  174. package/corpus/core/src/templates/default/.agents/skills/security/SKILL.md +10 -0
  175. package/corpus/core/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +15 -6
  176. package/corpus/core/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +16 -10
  177. package/corpus/core/src/templates/workspace-core/.agents/skills/performance/SKILL.md +20 -1
  178. package/corpus/core/src/templates/workspace-core/.agents/skills/security/SKILL.md +10 -0
  179. package/corpus/templates/analytics/.agents/skills/security/SKILL.md +10 -0
  180. package/corpus/templates/analytics/app/global.css +63 -4
  181. package/corpus/templates/analytics/app/pages/sessions/SessionDetailPage.tsx +8 -5
  182. package/corpus/templates/analytics/changelog/2026-07-13-daily-dashboard-emails-recover-more-reliably-from-serverless.md +6 -0
  183. package/corpus/templates/analytics/changelog/2026-07-13-session-replays-keep-a-visible-mac-style-cursor-over-the-vis.md +6 -0
  184. package/corpus/templates/analytics/server/jobs/dashboard-report.ts +21 -2
  185. package/corpus/templates/analytics/server/lib/dashboard-report-subscriptions.ts +57 -1
  186. package/corpus/templates/analytics/server/lib/dashboard-report.ts +266 -28
  187. package/corpus/templates/analytics/server/routes/[...page].get.ts +0 -2
  188. package/corpus/templates/assets/.agents/skills/security/SKILL.md +10 -0
  189. package/corpus/templates/assets/agent-native.app-skill.json +1 -1
  190. package/corpus/templates/brain/.agents/skills/security/SKILL.md +10 -0
  191. package/corpus/templates/calendar/.agents/skills/security/SKILL.md +10 -0
  192. package/corpus/templates/calendar/AGENTS.md +2 -1
  193. package/corpus/templates/calendar/app/components/calendar/EventDetailPopover.tsx +0 -19
  194. package/corpus/templates/calendar/app/lib/attendee-local-time.ts +14 -5
  195. package/corpus/templates/calendar/changelog/2026-07-13-your-local-time-now-follows-your-browser-timezone-and-event-.md +6 -0
  196. package/corpus/templates/chat/.agents/skills/security/SKILL.md +10 -0
  197. package/corpus/templates/clips/.agents/skills/recording/SKILL.md +7 -2
  198. package/corpus/templates/clips/.agents/skills/security/SKILL.md +10 -0
  199. package/corpus/templates/clips/AGENTS.md +7 -0
  200. package/corpus/templates/clips/actions/list-meetings.ts +19 -4
  201. package/corpus/templates/clips/actions/start-meeting-recording.ts +7 -1
  202. package/corpus/templates/clips/app/components/meetings/transcript-bubbles.tsx +75 -78
  203. package/corpus/templates/clips/app/components/recorder/confetti-canvas.tsx +18 -1
  204. package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +6 -12
  205. package/corpus/templates/clips/app/components/recorder/recording-toolbar.tsx +19 -2
  206. package/corpus/templates/clips/app/lib/camera-composite.ts +70 -10
  207. package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +1 -1
  208. package/corpus/templates/clips/app/routes/record.tsx +5 -25
  209. package/corpus/templates/clips/changelog/2026-07-13-clips-desktop-now-requires-macos-13-for-native-capture.md +6 -0
  210. package/corpus/templates/clips/changelog/2026-07-13-clips-hide-solo-meeting-reminders.md +6 -0
  211. package/corpus/templates/clips/changelog/2026-07-13-clips-now-removes-duplicate-mic-and-system-transcript-turns-.md +6 -0
  212. package/corpus/templates/clips/changelog/2026-07-13-desktop-recordings-run-cooler-and-quieter-live-transcription.md +6 -0
  213. package/corpus/templates/clips/changelog/2026-07-13-meeting-recordings-now-stop-after-a-calendar-meeting-ends-an.md +6 -0
  214. package/corpus/templates/clips/changelog/2026-07-13-meeting-transcripts-now-use-a-clean-agent-chat-style-reading.md +6 -0
  215. package/corpus/templates/clips/changelog/2026-07-13-screen-recordings-use-less-processing-power-during-longer-ca.md +6 -0
  216. package/corpus/templates/clips/chrome-extension/src/background.ts +5 -3
  217. package/corpus/templates/clips/chrome-extension/src/offscreen.ts +17 -14
  218. package/corpus/templates/clips/chrome-extension/src/overlay.ts +8 -2
  219. package/corpus/templates/clips/desktop/README.md +3 -0
  220. package/corpus/templates/clips/desktop/src/hooks/useMeetingTranscription.ts +9 -0
  221. package/corpus/templates/clips/desktop/src/lib/recorder.ts +8 -2
  222. package/corpus/templates/clips/desktop/src/lib/silence-events.ts +1 -0
  223. package/corpus/templates/clips/desktop/src/lib/transcription-capture.ts +5 -0
  224. package/corpus/templates/clips/desktop/src/lib/transcription-engine.ts +134 -5
  225. package/corpus/templates/clips/desktop/src/lib/upload-video-stream.ts +28 -0
  226. package/corpus/templates/clips/desktop/src/overlays/flow-bar.tsx +10 -3
  227. package/corpus/templates/clips/desktop/src/overlays/meeting-notification.tsx +42 -9
  228. package/corpus/templates/clips/desktop/src/overlays/recording-pill.tsx +10 -2
  229. package/corpus/templates/clips/desktop/src-tauri/Cargo.toml +6 -1
  230. package/corpus/templates/clips/desktop/src-tauri/src/notifications.rs +77 -1
  231. package/corpus/templates/clips/desktop/src-tauri/src/silence_detector.rs +104 -25
  232. package/corpus/templates/clips/desktop/src-tauri/src/system_audio.rs +4 -0
  233. package/corpus/templates/clips/desktop/src-tauri/src/whisper_speech.rs +287 -32
  234. package/corpus/templates/clips/desktop/src-tauri/tauri.conf.json +1 -1
  235. package/corpus/templates/clips/server/lib/calendar-event-classification.ts +28 -0
  236. package/corpus/templates/clips/server/routes/[...page].get.ts +1 -59
  237. package/corpus/templates/clips/shared/recording-capture.ts +37 -0
  238. package/corpus/templates/content/.agents/skills/security/SKILL.md +10 -0
  239. package/corpus/templates/content/agent-native.app-skill.json +1 -1
  240. package/corpus/templates/content/server/routes/[...page].get.ts +1 -15
  241. package/corpus/templates/design/.agents/skills/security/SKILL.md +10 -0
  242. package/corpus/templates/design/actions/connect-assets-mcp.ts +1 -1
  243. package/corpus/templates/design/agent-native.app-skill.json +1 -1
  244. package/corpus/templates/design/app/components/design/DesignCanvas.tsx +88 -12
  245. package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +1 -0
  246. package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +4 -1
  247. package/corpus/templates/design/changelog/2026-07-13-adding-shapes-preserves-canvas-background.md +6 -0
  248. package/corpus/templates/design/changelog/2026-07-13-clicking-quickly-between-overlapping-elements-no-longer-bounc.md +6 -0
  249. package/corpus/templates/design/server/plugins/assets-mcp.ts +1 -1
  250. package/corpus/templates/design/server/routes/[...page].get.ts +0 -2
  251. package/corpus/templates/dispatch/.agents/skills/security/SKILL.md +10 -0
  252. package/corpus/templates/forms/.agents/skills/security/SKILL.md +10 -0
  253. package/corpus/templates/macros/.agents/skills/security/SKILL.md +10 -0
  254. package/corpus/templates/mail/.agents/skills/security/SKILL.md +10 -0
  255. package/corpus/templates/plan/.agents/skills/security/SKILL.md +10 -0
  256. package/corpus/templates/plan/.agents/skills/visual-plan/SKILL.md +1 -1
  257. package/corpus/templates/plan/.agents/skills/visual-recap/SKILL.md +2 -2
  258. package/corpus/templates/plan/agent-native.app-skill.json +1 -1
  259. package/corpus/templates/plan/app/lib/plan-local-bridge.ts +6 -1
  260. package/corpus/templates/plan/app/pages/PlansPage.tsx +15 -6
  261. package/corpus/templates/plan/changelog/2026-07-13-fixed-local-plan-previews-continuously-flickering-while-revi.md +6 -0
  262. package/corpus/templates/plan/server/routes/[...page].get.ts +0 -2
  263. package/corpus/templates/slides/.agents/skills/security/SKILL.md +10 -0
  264. package/dist/a2a/client.d.ts +2 -0
  265. package/dist/a2a/client.d.ts.map +1 -1
  266. package/dist/a2a/client.js +2 -0
  267. package/dist/a2a/client.js.map +1 -1
  268. package/dist/a2a/handlers.d.ts.map +1 -1
  269. package/dist/a2a/handlers.js +84 -7
  270. package/dist/a2a/handlers.js.map +1 -1
  271. package/dist/cli/connect.d.ts +2 -2
  272. package/dist/cli/connect.d.ts.map +1 -1
  273. package/dist/cli/connect.js +45 -23
  274. package/dist/cli/connect.js.map +1 -1
  275. package/dist/cli/mcp-config-writers.d.ts.map +1 -1
  276. package/dist/cli/mcp-config-writers.js +7 -0
  277. package/dist/cli/mcp-config-writers.js.map +1 -1
  278. package/dist/cli/mcp.js +5 -3
  279. package/dist/cli/mcp.js.map +1 -1
  280. package/dist/cli/skills-content/assets-skill.d.ts +1 -1
  281. package/dist/cli/skills-content/assets-skill.d.ts.map +1 -1
  282. package/dist/cli/skills-content/assets-skill.js +1 -1
  283. package/dist/cli/skills-content/assets-skill.js.map +1 -1
  284. package/dist/cli/skills-content/design-exploration-skill.d.ts +1 -1
  285. package/dist/cli/skills-content/design-exploration-skill.d.ts.map +1 -1
  286. package/dist/cli/skills-content/design-exploration-skill.js +1 -1
  287. package/dist/cli/skills-content/design-exploration-skill.js.map +1 -1
  288. package/dist/cli/skills-content/help.d.ts +1 -1
  289. package/dist/cli/skills-content/help.d.ts.map +1 -1
  290. package/dist/cli/skills-content/help.js +1 -1
  291. package/dist/cli/skills-content/help.js.map +1 -1
  292. package/dist/cli/skills-content/plan-setup-auth.d.ts +1 -1
  293. package/dist/cli/skills-content/plan-setup-auth.d.ts.map +1 -1
  294. package/dist/cli/skills-content/plan-setup-auth.js +1 -1
  295. package/dist/cli/skills-content/plan-setup-auth.js.map +1 -1
  296. package/dist/cli/skills-content/visual-plan-skill.d.ts +1 -1
  297. package/dist/cli/skills-content/visual-plan-skill.d.ts.map +1 -1
  298. package/dist/cli/skills-content/visual-plan-skill.js +1 -1
  299. package/dist/cli/skills-content/visual-plan-skill.js.map +1 -1
  300. package/dist/cli/skills-content/visual-recap-skill.d.ts +1 -1
  301. package/dist/cli/skills-content/visual-recap-skill.d.ts.map +1 -1
  302. package/dist/cli/skills-content/visual-recap-skill.js +2 -2
  303. package/dist/cli/skills-content/visual-recap-skill.js.map +1 -1
  304. package/dist/cli/skills.d.ts.map +1 -1
  305. package/dist/cli/skills.js +16 -12
  306. package/dist/cli/skills.js.map +1 -1
  307. package/dist/client/resources/McpIntegrationDialog.d.ts.map +1 -1
  308. package/dist/client/resources/McpIntegrationDialog.js +1 -1
  309. package/dist/client/resources/McpIntegrationDialog.js.map +1 -1
  310. package/dist/client/resources/mcp-integration-catalog.d.ts +1 -0
  311. package/dist/client/resources/mcp-integration-catalog.d.ts.map +1 -1
  312. package/dist/client/resources/mcp-integration-catalog.js +14 -0
  313. package/dist/client/resources/mcp-integration-catalog.js.map +1 -1
  314. package/dist/collab/routes.d.ts +2 -2
  315. package/dist/collab/struct-routes.d.ts +1 -1
  316. package/dist/embedding/agent.d.ts.map +1 -1
  317. package/dist/embedding/agent.js +6 -7
  318. package/dist/embedding/agent.js.map +1 -1
  319. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  320. package/dist/localization/default-messages.d.ts +5 -0
  321. package/dist/localization/default-messages.d.ts.map +1 -1
  322. package/dist/localization/default-messages.js +5 -0
  323. package/dist/localization/default-messages.js.map +1 -1
  324. package/dist/mcp/ask-app-inline-tasks.d.ts +47 -0
  325. package/dist/mcp/ask-app-inline-tasks.d.ts.map +1 -0
  326. package/dist/mcp/ask-app-inline-tasks.js +87 -0
  327. package/dist/mcp/ask-app-inline-tasks.js.map +1 -0
  328. package/dist/mcp/build-server.d.ts.map +1 -1
  329. package/dist/mcp/build-server.js +56 -3
  330. package/dist/mcp/build-server.js.map +1 -1
  331. package/dist/mcp/builtin-tools.d.ts.map +1 -1
  332. package/dist/mcp/builtin-tools.js +141 -21
  333. package/dist/mcp/builtin-tools.js.map +1 -1
  334. package/dist/mcp/connect-route.d.ts +12 -10
  335. package/dist/mcp/connect-route.d.ts.map +1 -1
  336. package/dist/mcp/connect-route.js +17 -14
  337. package/dist/mcp/connect-route.js.map +1 -1
  338. package/dist/mcp/oauth-route.d.ts +1 -1
  339. package/dist/mcp/oauth-route.d.ts.map +1 -1
  340. package/dist/mcp/oauth-route.js +30 -13
  341. package/dist/mcp/oauth-route.js.map +1 -1
  342. package/dist/mcp/route-paths.d.ts +13 -0
  343. package/dist/mcp/route-paths.d.ts.map +1 -0
  344. package/dist/mcp/route-paths.js +27 -0
  345. package/dist/mcp/route-paths.js.map +1 -0
  346. package/dist/mcp/server.d.ts +2 -1
  347. package/dist/mcp/server.d.ts.map +1 -1
  348. package/dist/mcp/server.js +14 -6
  349. package/dist/mcp/server.js.map +1 -1
  350. package/dist/mcp/stdio.d.ts +7 -6
  351. package/dist/mcp/stdio.d.ts.map +1 -1
  352. package/dist/mcp/stdio.js +27 -15
  353. package/dist/mcp/stdio.js.map +1 -1
  354. package/dist/mcp/workspace-resolve.d.ts +2 -1
  355. package/dist/mcp/workspace-resolve.d.ts.map +1 -1
  356. package/dist/mcp/workspace-resolve.js +2 -1
  357. package/dist/mcp/workspace-resolve.js.map +1 -1
  358. package/dist/mcp-client/manager.js +6 -3
  359. package/dist/mcp-client/manager.js.map +1 -1
  360. package/dist/mcp-client/remote-store.js +5 -7
  361. package/dist/mcp-client/remote-store.js.map +1 -1
  362. package/dist/notifications/routes.d.ts +3 -3
  363. package/dist/observability/routes.d.ts +5 -5
  364. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  365. package/dist/resources/handlers.d.ts +2 -2
  366. package/dist/secrets/routes.d.ts +9 -9
  367. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  368. package/dist/server/agent-chat-plugin.js +43 -11
  369. package/dist/server/agent-chat-plugin.js.map +1 -1
  370. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  371. package/dist/server/auth.d.ts.map +1 -1
  372. package/dist/server/auth.js +16 -6
  373. package/dist/server/auth.js.map +1 -1
  374. package/dist/server/core-routes-plugin.d.ts +4 -3
  375. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  376. package/dist/server/core-routes-plugin.js +20 -15
  377. package/dist/server/core-routes-plugin.js.map +1 -1
  378. package/dist/server/csrf.d.ts.map +1 -1
  379. package/dist/server/csrf.js +11 -0
  380. package/dist/server/csrf.js.map +1 -1
  381. package/dist/server/framework-request-handler.d.ts.map +1 -1
  382. package/dist/server/framework-request-handler.js +8 -2
  383. package/dist/server/framework-request-handler.js.map +1 -1
  384. package/dist/server/google-oauth.d.ts +2 -0
  385. package/dist/server/google-oauth.d.ts.map +1 -1
  386. package/dist/server/google-oauth.js +5 -0
  387. package/dist/server/google-oauth.js.map +1 -1
  388. package/dist/server/http-response-telemetry.d.ts.map +1 -1
  389. package/dist/server/http-response-telemetry.js +4 -1
  390. package/dist/server/http-response-telemetry.js.map +1 -1
  391. package/dist/server/recap-image-route.js +3 -3
  392. package/dist/server/recap-image-route.js.map +1 -1
  393. package/dist/server/security-headers.d.ts.map +1 -1
  394. package/dist/server/security-headers.js +4 -1
  395. package/dist/server/security-headers.js.map +1 -1
  396. package/dist/server/ssr-handler.d.ts.map +1 -1
  397. package/dist/server/ssr-handler.js +3 -1
  398. package/dist/server/ssr-handler.js.map +1 -1
  399. package/dist/shared/cache-control.d.ts +7 -6
  400. package/dist/shared/cache-control.d.ts.map +1 -1
  401. package/dist/shared/cache-control.js +4 -3
  402. package/dist/shared/cache-control.js.map +1 -1
  403. package/dist/templates/default/.agents/skills/security/SKILL.md +10 -0
  404. package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +15 -6
  405. package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +16 -10
  406. package/dist/templates/workspace-core/.agents/skills/performance/SKILL.md +20 -1
  407. package/dist/templates/workspace-core/.agents/skills/security/SKILL.md +10 -0
  408. package/docs/content/actions.mdx +1 -1
  409. package/docs/content/authentication.mdx +1 -1
  410. package/docs/content/dispatch.mdx +3 -3
  411. package/docs/content/external-agents.mdx +30 -19
  412. package/docs/content/locales/ar-SA/actions.mdx +1 -1
  413. package/docs/content/locales/ar-SA/authentication.mdx +1 -1
  414. package/docs/content/locales/ar-SA/dispatch.mdx +3 -3
  415. package/docs/content/locales/ar-SA/external-agents.mdx +23 -19
  416. package/docs/content/locales/ar-SA/mcp-clients.mdx +31 -3
  417. package/docs/content/locales/ar-SA/mcp-protocol.mdx +29 -15
  418. package/docs/content/locales/ar-SA/plan-plugin.mdx +3 -3
  419. package/docs/content/locales/ar-SA/server.mdx +2 -2
  420. package/docs/content/locales/ar-SA/skills-guide.mdx +1 -1
  421. package/docs/content/locales/ar-SA/template-assets.mdx +1 -1
  422. package/docs/content/locales/ar-SA/template-dispatch.mdx +2 -2
  423. package/docs/content/locales/ar-SA/template-plan.mdx +3 -3
  424. package/docs/content/locales/de-DE/actions.mdx +1 -1
  425. package/docs/content/locales/de-DE/authentication.mdx +1 -1
  426. package/docs/content/locales/de-DE/dispatch.mdx +3 -3
  427. package/docs/content/locales/de-DE/external-agents.mdx +23 -19
  428. package/docs/content/locales/de-DE/mcp-clients.mdx +37 -3
  429. package/docs/content/locales/de-DE/mcp-protocol.mdx +29 -15
  430. package/docs/content/locales/de-DE/plan-plugin.mdx +3 -3
  431. package/docs/content/locales/de-DE/server.mdx +2 -2
  432. package/docs/content/locales/de-DE/skills-guide.mdx +1 -1
  433. package/docs/content/locales/de-DE/template-assets.mdx +1 -1
  434. package/docs/content/locales/de-DE/template-dispatch.mdx +2 -2
  435. package/docs/content/locales/de-DE/template-plan.mdx +3 -3
  436. package/docs/content/locales/es-ES/actions.mdx +1 -1
  437. package/docs/content/locales/es-ES/authentication.mdx +1 -1
  438. package/docs/content/locales/es-ES/dispatch.mdx +3 -3
  439. package/docs/content/locales/es-ES/external-agents.mdx +32 -19
  440. package/docs/content/locales/es-ES/mcp-clients.mdx +17 -3
  441. package/docs/content/locales/es-ES/mcp-protocol.mdx +38 -15
  442. package/docs/content/locales/es-ES/plan-plugin.mdx +3 -3
  443. package/docs/content/locales/es-ES/server.mdx +2 -2
  444. package/docs/content/locales/es-ES/skills-guide.mdx +1 -1
  445. package/docs/content/locales/es-ES/template-assets.mdx +1 -1
  446. package/docs/content/locales/es-ES/template-dispatch.mdx +2 -2
  447. package/docs/content/locales/es-ES/template-plan.mdx +3 -3
  448. package/docs/content/locales/fr-FR/actions.mdx +1 -1
  449. package/docs/content/locales/fr-FR/authentication.mdx +1 -1
  450. package/docs/content/locales/fr-FR/dispatch.mdx +3 -3
  451. package/docs/content/locales/fr-FR/external-agents.mdx +23 -19
  452. package/docs/content/locales/fr-FR/mcp-clients.mdx +17 -3
  453. package/docs/content/locales/fr-FR/mcp-protocol.mdx +29 -15
  454. package/docs/content/locales/fr-FR/plan-plugin.mdx +3 -3
  455. package/docs/content/locales/fr-FR/server.mdx +2 -2
  456. package/docs/content/locales/fr-FR/skills-guide.mdx +1 -1
  457. package/docs/content/locales/fr-FR/template-assets.mdx +1 -1
  458. package/docs/content/locales/fr-FR/template-dispatch.mdx +2 -2
  459. package/docs/content/locales/fr-FR/template-plan.mdx +3 -3
  460. package/docs/content/locales/hi-IN/actions.mdx +1 -1
  461. package/docs/content/locales/hi-IN/authentication.mdx +1 -1
  462. package/docs/content/locales/hi-IN/dispatch.mdx +3 -3
  463. package/docs/content/locales/hi-IN/external-agents.mdx +31 -19
  464. package/docs/content/locales/hi-IN/mcp-clients.mdx +17 -3
  465. package/docs/content/locales/hi-IN/mcp-protocol.mdx +36 -15
  466. package/docs/content/locales/hi-IN/plan-plugin.mdx +3 -3
  467. package/docs/content/locales/hi-IN/server.mdx +2 -2
  468. package/docs/content/locales/hi-IN/skills-guide.mdx +1 -1
  469. package/docs/content/locales/hi-IN/template-assets.mdx +1 -1
  470. package/docs/content/locales/hi-IN/template-dispatch.mdx +2 -2
  471. package/docs/content/locales/hi-IN/template-plan.mdx +3 -3
  472. package/docs/content/locales/ja-JP/actions.mdx +1 -1
  473. package/docs/content/locales/ja-JP/authentication.mdx +1 -1
  474. package/docs/content/locales/ja-JP/dispatch.mdx +3 -3
  475. package/docs/content/locales/ja-JP/external-agents.mdx +23 -19
  476. package/docs/content/locales/ja-JP/mcp-clients.mdx +34 -3
  477. package/docs/content/locales/ja-JP/mcp-protocol.mdx +29 -15
  478. package/docs/content/locales/ja-JP/plan-plugin.mdx +3 -3
  479. package/docs/content/locales/ja-JP/server.mdx +2 -2
  480. package/docs/content/locales/ja-JP/skills-guide.mdx +1 -1
  481. package/docs/content/locales/ja-JP/template-assets.mdx +1 -1
  482. package/docs/content/locales/ja-JP/template-dispatch.mdx +2 -2
  483. package/docs/content/locales/ja-JP/template-plan.mdx +3 -3
  484. package/docs/content/locales/ko-KR/actions.mdx +1 -1
  485. package/docs/content/locales/ko-KR/authentication.mdx +1 -1
  486. package/docs/content/locales/ko-KR/dispatch.mdx +3 -3
  487. package/docs/content/locales/ko-KR/external-agents.mdx +30 -19
  488. package/docs/content/locales/ko-KR/mcp-clients.mdx +33 -3
  489. package/docs/content/locales/ko-KR/mcp-protocol.mdx +36 -15
  490. package/docs/content/locales/ko-KR/plan-plugin.mdx +3 -3
  491. package/docs/content/locales/ko-KR/server.mdx +2 -2
  492. package/docs/content/locales/ko-KR/skills-guide.mdx +1 -1
  493. package/docs/content/locales/ko-KR/template-assets.mdx +1 -1
  494. package/docs/content/locales/ko-KR/template-dispatch.mdx +2 -2
  495. package/docs/content/locales/ko-KR/template-plan.mdx +3 -3
  496. package/docs/content/locales/pt-BR/actions.mdx +1 -1
  497. package/docs/content/locales/pt-BR/authentication.mdx +1 -1
  498. package/docs/content/locales/pt-BR/dispatch.mdx +3 -3
  499. package/docs/content/locales/pt-BR/external-agents.mdx +32 -19
  500. package/docs/content/locales/pt-BR/mcp-clients.mdx +34 -3
  501. package/docs/content/locales/pt-BR/mcp-protocol.mdx +32 -15
  502. package/docs/content/locales/pt-BR/plan-plugin.mdx +3 -3
  503. package/docs/content/locales/pt-BR/server.mdx +2 -2
  504. package/docs/content/locales/pt-BR/skills-guide.mdx +1 -1
  505. package/docs/content/locales/pt-BR/template-assets.mdx +1 -1
  506. package/docs/content/locales/pt-BR/template-dispatch.mdx +2 -2
  507. package/docs/content/locales/pt-BR/template-plan.mdx +3 -3
  508. package/docs/content/locales/zh-CN/actions.mdx +1 -1
  509. package/docs/content/locales/zh-CN/authentication.mdx +1 -1
  510. package/docs/content/locales/zh-CN/dispatch.mdx +3 -3
  511. package/docs/content/locales/zh-CN/external-agents.mdx +23 -19
  512. package/docs/content/locales/zh-CN/mcp-clients.mdx +28 -3
  513. package/docs/content/locales/zh-CN/mcp-protocol.mdx +29 -15
  514. package/docs/content/locales/zh-CN/plan-plugin.mdx +3 -3
  515. package/docs/content/locales/zh-CN/server.mdx +2 -2
  516. package/docs/content/locales/zh-CN/skills-guide.mdx +1 -1
  517. package/docs/content/locales/zh-CN/template-assets.mdx +1 -1
  518. package/docs/content/locales/zh-CN/template-dispatch.mdx +2 -2
  519. package/docs/content/locales/zh-CN/template-plan.mdx +3 -3
  520. package/docs/content/locales/zh-TW/actions.mdx +1 -1
  521. package/docs/content/locales/zh-TW/authentication.mdx +1 -1
  522. package/docs/content/locales/zh-TW/dispatch.mdx +3 -3
  523. package/docs/content/locales/zh-TW/external-agents.mdx +23 -19
  524. package/docs/content/locales/zh-TW/mcp-clients.mdx +28 -3
  525. package/docs/content/locales/zh-TW/mcp-protocol.mdx +30 -15
  526. package/docs/content/locales/zh-TW/plan-plugin.mdx +3 -3
  527. package/docs/content/locales/zh-TW/server.mdx +2 -2
  528. package/docs/content/locales/zh-TW/skills-guide.mdx +1 -1
  529. package/docs/content/locales/zh-TW/template-assets.mdx +1 -1
  530. package/docs/content/locales/zh-TW/template-dispatch.mdx +2 -2
  531. package/docs/content/locales/zh-TW/template-plan.mdx +3 -3
  532. package/docs/content/mcp-clients.mdx +31 -4
  533. package/docs/content/mcp-protocol.mdx +35 -15
  534. package/docs/content/plan-plugin.mdx +3 -3
  535. package/docs/content/server.mdx +2 -2
  536. package/docs/content/skills-guide.mdx +1 -1
  537. package/docs/content/template-assets.mdx +1 -1
  538. package/docs/content/template-dispatch.mdx +2 -2
  539. package/docs/content/template-plan.mdx +3 -3
  540. package/package.json +1 -1
  541. package/src/templates/default/.agents/skills/security/SKILL.md +10 -0
  542. package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +15 -6
  543. package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +16 -10
  544. package/src/templates/workspace-core/.agents/skills/performance/SKILL.md +20 -1
  545. package/src/templates/workspace-core/.agents/skills/security/SKILL.md +10 -0
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-config-writers.d.ts","sourceRoot":"","sources":["../../src/cli/mcp-config-writers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,MAAM,MAAM,QAAQ,GAChB,aAAa,GACb,iBAAiB,GACjB,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,gBAAgB,CAAC;AAErB,eAAO,MAAM,OAAO,EAAE,QAAQ,EAQ7B,CAAC;AAEF,mEAAmE;AACnE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,YAAY,CAUd;AAYD,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA6BzB;AAED,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,QAAQ,EAChB,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuBzB;AAMD;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED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,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,MAAM,EAAE,CAEV;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,MAAM,EAAE,CA4EV;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,QAAQ,EAChB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,EAAE,CAWV"}
@@ -25,6 +25,8 @@
25
25
  import fs from "node:fs";
26
26
  import os from "node:os";
27
27
  import path from "node:path";
28
+ const MCP_LEGACY_ROUTE_PREFIX = "/_agent-native/mcp";
29
+ const MCP_PUBLIC_ROUTE_PREFIX = "/mcp";
28
30
  export const CLIENTS = [
29
31
  "claude-code",
30
32
  "claude-code-cli",
@@ -560,6 +562,11 @@ export function canonicalUrl(value) {
560
562
  const u = new URL(value);
561
563
  u.hash = "";
562
564
  u.search = "";
565
+ const pathname = u.pathname.replace(/\/+$/, "");
566
+ if (pathname === MCP_LEGACY_ROUTE_PREFIX ||
567
+ pathname.endsWith(MCP_LEGACY_ROUTE_PREFIX)) {
568
+ u.pathname = `${pathname.slice(0, -MCP_LEGACY_ROUTE_PREFIX.length)}${MCP_PUBLIC_ROUTE_PREFIX}`;
569
+ }
563
570
  return u.toString().replace(/\/+$/, "");
564
571
  }
565
572
  catch {
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-config-writers.js","sourceRoot":"","sources":["../../src/cli/mcp-config-writers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAW7B,M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AAC,CAAC;IAC5B,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC;AACxB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC9C,MAAgB,EAChB,UAAkB,EAClB,MAAc,EACd,OAAe,EACf,KAAyB;IAEzB,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACnD,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QACvB,OAAO,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,gCAAgC,CACrC,IAAI,EACJ,yBAAyB,CAAC,MAAM,CAAC,EACjC,MAAM,EACN,UAAU,CACX,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Shared MCP client-config writers.\n *\n * Extracted so both `agent-native mcp install` (see `mcp.ts`) and\n * `agent-native connect` (see `connect.ts`) write the EXACT same on-disk\n * config file targets and formats for every supported client.\n *\n * Supported clients and their config files:\n * - claude-code / claude-code-cli → `.mcp.json` (project) or\n * `~/.claude.json` (user). JSON `mcpServers[name] = entry`.\n * - cowork → `~/.cowork/mcp.json`. Same JSON shape.\n * - cursor → `.cursor/mcp.json` (project) or\n * `~/.cursor/mcp.json` (user). JSON `mcpServers[name] = entry`.\n * - opencode → `opencode.json` (project) or\n * `~/.config/opencode/opencode.json` (user). JSON `mcp[name] = entry`.\n * - github-copilot → `.vscode/mcp.json` (project) or the\n * VS Code user `mcp.json`. JSON `servers[name] = entry`.\n * - codex → `$CODEX_HOME/config.toml` when set,\n * otherwise `~/.codex/config.toml`.\n * `[mcp_servers.<name>]` block.\n *\n * Node-only. No new npm deps — hand-rolled JSON merge + minimal TOML block\n * merge, mirroring `mcp.ts`.\n */\n\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\nexport type ClientId =\n | \"claude-code\"\n | \"claude-code-cli\"\n | \"codex\"\n | \"cowork\"\n | \"cursor\"\n | \"opencode\"\n | \"github-copilot\";\n\nexport const CLIENTS: ClientId[] = [\n \"claude-code\",\n \"claude-code-cli\",\n \"codex\",\n \"cowork\",\n \"cursor\",\n \"opencode\",\n \"github-copilot\",\n];\n\n/** The HTTP MCP server entry written into a JSON client config. */\nexport interface HttpMcpEntry {\n type: \"http\";\n url: string;\n headers?: Record<string, string>;\n}\n\n/** Build the HTTP MCP server entry for a deployed agent-native app. */\nexport function buildHttpMcpEntry(\n mcpUrl: string,\n token?: string,\n headers?: Record<string, string>,\n): HttpMcpEntry {\n const mergedHeaders = {\n ...(headers ?? {}),\n ...(token ? { Authorization: `Bearer ${token}` } : {}),\n };\n return {\n type: \"http\",\n url: mcpUrl,\n ...(Object.keys(mergedHeaders).length ? { headers: mergedHeaders } : {}),\n };\n}\n\nfunction mergedHeadersFor(\n token?: string,\n headers?: Record<string, string>,\n): Record<string, string> {\n return {\n ...(headers ?? {}),\n ...(token ? { Authorization: `Bearer ${token}` } : {}),\n };\n}\n\nexport function buildHttpMcpEntryForClient(\n client: ClientId,\n mcpUrl: string,\n token?: string,\n headers?: Record<string, string>,\n): Record<string, unknown> {\n const mergedHeaders = mergedHeadersFor(token, headers);\n if (client === \"cursor\") {\n return {\n url: mcpUrl,\n ...(Object.keys(mergedHeaders).length ? { headers: mergedHeaders } : {}),\n };\n }\n if (client === \"opencode\") {\n return {\n type: \"remote\",\n url: mcpUrl,\n enabled: true,\n ...(Object.keys(mergedHeaders).length ? { headers: mergedHeaders } : {}),\n };\n }\n if (client === \"github-copilot\") {\n return {\n type: \"http\",\n url: mcpUrl,\n ...(Object.keys(mergedHeaders).length\n ? { requestInit: { headers: mergedHeaders } }\n : {}),\n };\n }\n return buildHttpMcpEntry(mcpUrl, token, headers) as unknown as Record<\n string,\n unknown\n >;\n}\n\nexport function buildLocalMcpEntryForClient(\n client: ClientId,\n args: string[],\n env?: Record<string, string>,\n): Record<string, unknown> {\n const cleanEnv = env ? Object.fromEntries(Object.entries(env)) : {};\n if (client === \"opencode\") {\n return {\n type: \"local\",\n command: [\"agent-native\", ...args],\n enabled: true,\n ...(Object.keys(cleanEnv).length ? { environment: cleanEnv } : {}),\n };\n }\n if (client === \"github-copilot\") {\n return {\n type: \"stdio\",\n command: \"agent-native\",\n args,\n ...(Object.keys(cleanEnv).length ? { env: cleanEnv } : {}),\n };\n }\n return {\n command: \"agent-native\",\n args,\n ...(Object.keys(cleanEnv).length ? { env: cleanEnv } : {}),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Config file locations — kept identical to `mcp.ts`.\n// ---------------------------------------------------------------------------\n\n/**\n * Cowork consumes MCP exactly like Claude Code (same JSON server-entry\n * shape). Resolved lazily so `os.homedir()` reflects the current `$HOME`.\n */\nexport function coworkConfigPath(): string {\n return path.join(os.homedir(), \".cowork\", \"mcp.json\");\n}\n\nexport function claudeCodeProjectConfig(baseDir: string): string {\n return path.join(baseDir, \".mcp.json\");\n}\n\nexport function claudeCodeUserConfig(): string {\n return path.join(os.homedir(), \".claude.json\");\n}\n\nexport function codexConfigPath(): string {\n const codexHome = process.env.CODEX_HOME?.trim();\n if (codexHome) return path.join(codexHome, \"config.toml\");\n return path.join(os.homedir(), \".codex\", \"config.toml\");\n}\n\nexport function cursorProjectConfig(baseDir: string): string {\n return path.join(baseDir, \".cursor\", \"mcp.json\");\n}\n\nexport function cursorUserConfig(): string {\n return path.join(os.homedir(), \".cursor\", \"mcp.json\");\n}\n\nexport function opencodeProjectConfig(baseDir: string): string {\n return path.join(baseDir, \"opencode.json\");\n}\n\nexport function opencodeUserConfig(): string {\n const xdgConfigHome = process.env.XDG_CONFIG_HOME?.trim();\n const configRoot = xdgConfigHome || path.join(os.homedir(), \".config\");\n return path.join(configRoot, \"opencode\", \"opencode.json\");\n}\n\nexport function githubCopilotProjectConfig(baseDir: string): string {\n return path.join(baseDir, \".vscode\", \"mcp.json\");\n}\n\nexport function githubCopilotUserConfig(): string {\n if (process.platform === \"darwin\") {\n return path.join(\n os.homedir(),\n \"Library\",\n \"Application Support\",\n \"Code\",\n \"User\",\n \"mcp.json\",\n );\n }\n if (process.platform === \"win32\") {\n const appData =\n process.env.APPDATA || path.join(os.homedir(), \"AppData\", \"Roaming\");\n return path.join(appData, \"Code\", \"User\", \"mcp.json\");\n }\n const xdgConfigHome = process.env.XDG_CONFIG_HOME?.trim();\n const configRoot = xdgConfigHome || path.join(os.homedir(), \".config\");\n return path.join(configRoot, \"Code\", \"User\", \"mcp.json\");\n}\n\n/**\n * Resolve the on-disk config path for a client.\n *\n * `scope` only affects Claude Code / Claude Code CLI: `\"user\"` → the global\n * `~/.claude.json`, anything else → the project-local `.mcp.json` rooted at\n * `baseDir`.\n */\nexport function configPathFor(\n client: ClientId,\n baseDir: string,\n scope: string | undefined,\n): string {\n switch (client) {\n case \"claude-code\":\n case \"claude-code-cli\":\n return scope === \"user\"\n ? claudeCodeUserConfig()\n : claudeCodeProjectConfig(baseDir);\n case \"cowork\":\n return coworkConfigPath();\n case \"codex\":\n return codexConfigPath();\n case \"cursor\":\n return scope === \"user\"\n ? cursorUserConfig()\n : cursorProjectConfig(baseDir);\n case \"opencode\":\n return scope === \"user\"\n ? opencodeUserConfig()\n : opencodeProjectConfig(baseDir);\n case \"github-copilot\":\n return scope === \"user\"\n ? githubCopilotUserConfig()\n : githubCopilotProjectConfig(baseDir);\n }\n}\n\n// ---------------------------------------------------------------------------\n// JSON client configs (Claude Code, Claude Code CLI, Cowork)\n// ---------------------------------------------------------------------------\n\n/**\n * Read and parse a JSON config file.\n *\n * - Missing file → returns `{}` (fresh config).\n * - Empty file → returns `{}` (treat as not-yet-initialised).\n * - Non-empty file that fails to parse → throws a descriptive Error so the\n * caller can surface it to the user instead of silently overwriting the\n * file with only the new MCP entry (data-loss hazard).\n */\nfunction readJsonFile(file: string): Record<string, any> {\n let raw: string;\n try {\n raw = fs.readFileSync(file, \"utf-8\");\n } catch {\n // Missing (ENOENT) or unreadable file — treat as empty.\n return {};\n }\n if (!raw.trim()) return {};\n try {\n const parsed = JSON.parse(raw);\n return parsed && typeof parsed === \"object\" ? parsed : {};\n } catch {\n throw new Error(\n `Cannot parse JSON config file: ${file}\\n` +\n `Fix or move the file and re-run. The file has not been modified.`,\n );\n }\n}\n\n/**\n * Write `data` to `file` atomically: write a sibling temp file, then rename it\n * over the target. `rename(2)` is atomic on the same filesystem, so a crash or\n * `kill` mid-write can never leave a half-written/truncated file. This matters\n * most for `~/.claude.json`, which is Claude Code's entire user state (projects,\n * history, auth) — a torn write there would corrupt the user's whole config,\n * not just our MCP entry. The temp file lives in the target's directory so the\n * rename stays within one filesystem.\n */\nexport function writeFileAtomic(file: string, data: string): void {\n const dir = path.dirname(file);\n fs.mkdirSync(dir, { recursive: true });\n // Preserve the target's existing permission bits. A fresh temp file would\n // otherwise be created with the umask default (typically 0644), silently\n // loosening a secret-bearing file the user locked down to 0600 (e.g. .env).\n let mode: number | undefined;\n try {\n mode = fs.statSync(file).mode & 0o777;\n } catch {\n // Target doesn't exist yet — let the default creation mode apply.\n }\n const tmp = path.join(dir, `.${path.basename(file)}.tmp-${process.pid}`);\n try {\n fs.writeFileSync(tmp, data, \"utf-8\");\n if (mode !== undefined) fs.chmodSync(tmp, mode);\n fs.renameSync(tmp, file);\n } catch (err) {\n try {\n fs.rmSync(tmp, { force: true });\n } catch {}\n throw err;\n }\n}\n\n/**\n * Idempotently write `mcpServers[name] = entry` into a JSON config file.\n * Pass `entry === null` to delete the named entry. Re-running with the same\n * name replaces the existing entry in place — never duplicates.\n */\nexport function jsonMcpConfigKeyForClient(client: ClientId): string {\n if (client === \"opencode\") return \"mcp\";\n if (client === \"github-copilot\") return \"servers\";\n return \"mcpServers\";\n}\n\nfunction writeJsonMcpEntryAtKey(\n file: string,\n serversKey: string,\n name: string,\n entry: Record<string, unknown> | null,\n): void {\n const config = readJsonFile(file);\n if (!config[serversKey] || typeof config[serversKey] !== \"object\") {\n config[serversKey] = {};\n }\n const servers = config[serversKey] as Record<string, unknown>;\n if (entry === null) {\n delete servers[name];\n } else {\n servers[name] = entry;\n }\n writeFileAtomic(file, JSON.stringify(config, null, 2) + \"\\n\");\n}\n\nexport function writeJsonMcpEntry(\n file: string,\n name: string,\n entry: Record<string, unknown> | null,\n): void {\n writeJsonMcpEntryAtKey(file, \"mcpServers\", name, entry);\n}\n\nexport function writeJsonMcpEntryForClient(\n client: ClientId,\n file: string,\n name: string,\n entry: Record<string, unknown> | null,\n): void {\n writeJsonMcpEntryAtKey(file, jsonMcpConfigKeyForClient(client), name, entry);\n}\n\nexport function hasJsonMcpEntry(file: string, name: string): boolean {\n const config = readJsonFile(file);\n return !!config?.mcpServers && name in config.mcpServers;\n}\n\nexport function hasJsonMcpEntryForClient(\n client: ClientId,\n file: string,\n name: string,\n): boolean {\n const config = readJsonFile(file);\n const servers = config?.[jsonMcpConfigKeyForClient(client)];\n return !!servers && typeof servers === \"object\" && name in servers;\n}\n\n// ---------------------------------------------------------------------------\n// Codex TOML (hand-rolled minimal block merge, no new dep)\n// ---------------------------------------------------------------------------\n\nfunction tomlQuote(s: string): string {\n return `\"${s.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"')}\"`;\n}\n\nfunction codexMcpHeader(name: string): string {\n return `[mcp_servers.${tomlQuote(name)}]`;\n}\n\n/**\n * Parse a TOML table-header line such as `[mcp_servers.\"plan\".http_headers]`\n * or `[mcp_servers.plan] # local note` into its decoded dotted-key components\n * (`[\"mcp_servers\", \"plan\", \"http_headers\"]`). Returns `null` when the line is\n * not a single `[table]` header — blank lines, key/value pairs, comments,\n * invalid trailing content, and `[[array-of-tables]]` headers all return `null`,\n * so the result doubles as a reliable \"is this line a table boundary?\" check.\n *\n * Handles bare keys (`A-Za-z0-9_-`) and quoted keys (basic `\"...\"` with `\\`\n * escapes, and literal `'...'`), tolerating whitespace around the dot\n * separators per the TOML spec. Quoted-key escape handling mirrors the inverse\n * of `tomlQuote` (`\\\"` → `\"`, `\\\\` → `\\`).\n */\nfunction parseTomlTableHeader(line: string): string[] | null {\n const trimmed = line.trim();\n if (trimmed.length < 2 || trimmed[0] !== \"[\") return null;\n // `[[array-of-tables]]` is a different construct — leave it untouched.\n if (trimmed[1] === \"[\") return null;\n\n let quote: '\"' | \"'\" | null = null;\n let escaped = false;\n let closeIndex = -1;\n for (let i = 1; i < trimmed.length; i++) {\n const ch = trimmed[i];\n if (quote === '\"') {\n if (escaped) {\n escaped = false;\n continue;\n }\n if (ch === \"\\\\\") {\n escaped = true;\n continue;\n }\n if (ch === '\"') quote = null;\n continue;\n }\n if (quote === \"'\") {\n if (ch === \"'\") quote = null;\n continue;\n }\n if (ch === '\"' || ch === \"'\") {\n quote = ch;\n continue;\n }\n if (ch === \"]\") {\n closeIndex = i;\n break;\n }\n }\n if (closeIndex < 0) return null;\n const trailing = trimmed.slice(closeIndex + 1).trim();\n if (trailing && !trailing.startsWith(\"#\")) return null;\n\n const inner = trimmed.slice(1, closeIndex);\n const keys: string[] = [];\n const isWs = (c: string) => c === \" \" || c === \"\\t\";\n const isBare = (c: string) => /[A-Za-z0-9_-]/.test(c);\n let i = 0;\n let expectKey = true;\n while (i < inner.length) {\n while (i < inner.length && isWs(inner[i])) i++;\n if (i >= inner.length) break;\n const ch = inner[i];\n if (ch === \".\") {\n if (expectKey) return null; // leading or doubled dot\n expectKey = true;\n i++;\n continue;\n }\n if (!expectKey) return null; // two keys with no dot between them\n if (ch === '\"' || ch === \"'\") {\n const quote = ch;\n i++;\n let key = \"\";\n while (i < inner.length && inner[i] !== quote) {\n if (quote === '\"' && inner[i] === \"\\\\\" && i + 1 < inner.length) {\n const next = inner[i + 1];\n key += next === '\"' ? '\"' : next === \"\\\\\" ? \"\\\\\" : `\\\\${next}`;\n i += 2;\n continue;\n }\n key += inner[i];\n i++;\n }\n if (i >= inner.length) return null; // unterminated quote\n i++; // consume the closing quote\n keys.push(key);\n expectKey = false;\n } else if (isBare(ch)) {\n let key = \"\";\n while (i < inner.length && isBare(inner[i])) {\n key += inner[i];\n i++;\n }\n keys.push(key);\n expectKey = false;\n } else {\n return null; // unexpected character — not a table header\n }\n }\n if (expectKey) return null; // empty header or trailing dot\n return keys.length ? keys : null;\n}\n\n/**\n * The MCP server name a TOML table header belongs to, or `undefined` when the\n * header is not under `[mcp_servers.*]`. The server's own table\n * (`[mcp_servers.<name>]`) AND every sub-table of it\n * (`[mcp_servers.<name>.http_headers]`, `[mcp_servers.<name>.env]`, …) resolve\n * to the same `<name>`, so callers can treat a server and all its sub-tables as\n * one removable unit. This is what prevents a re-install from orphaning a stale\n * `[mcp_servers.<name>.http_headers]` sub-table that would then collide with the\n * freshly written inline `http_headers` (a TOML duplicate-key error).\n */\nfunction codexServerNameOfHeader(line: string): string | undefined {\n const keys = parseTomlTableHeader(line);\n if (!keys || keys.length < 2 || keys[0] !== \"mcp_servers\") return undefined;\n return keys[1];\n}\n\n/** Build a `[mcp_servers.<name>]` block for an HTTP-type MCP server. */\nexport function buildCodexHttpBlock(\n name: string,\n mcpUrl: string,\n token?: string,\n headers?: Record<string, string>,\n): string {\n const lines: string[] = [codexMcpHeader(name)];\n lines.push(`url = ${tomlQuote(mcpUrl)}`);\n const mergedHeaders = {\n ...(headers ?? {}),\n ...(token ? { Authorization: `Bearer ${token}` } : {}),\n };\n const headerEntries = Object.entries(mergedHeaders);\n if (headerEntries.length) {\n lines.push(\n `http_headers = { ${headerEntries\n .map(([key, value]) => `${tomlQuote(key)} = ${tomlQuote(value)}`)\n .join(\", \")} }`,\n );\n }\n return lines.join(\"\\n\") + \"\\n\";\n}\n\nexport function buildCodexLocalBlock(\n name: string,\n args: string[],\n env?: Record<string, string>,\n): string {\n const lines: string[] = [codexMcpHeader(name)];\n lines.push(`command = \"agent-native\"`);\n lines.push(`args = [${args.map(tomlQuote).join(\", \")}]`);\n const cleanEnv = env ? Object.fromEntries(Object.entries(env)) : {};\n if (Object.keys(cleanEnv).length) {\n const inline = Object.entries(cleanEnv)\n .map(([key, value]) => `${key} = ${tomlQuote(value)}`)\n .join(\", \");\n lines.push(`env = { ${inline} }`);\n }\n return lines.join(\"\\n\") + \"\\n\";\n}\n\n/**\n * Replace (or append) the entire `[mcp_servers.<name>]` footprint in a TOML\n * file without disturbing other content. The footprint is the server's own\n * table AND every sub-table of it (`[mcp_servers.<name>.http_headers]`,\n * `[mcp_servers.<name>.env]`, …), each spanning its header line plus every\n * following line until the next table header or EOF. Removing the whole\n * footprint — wherever the pieces sit in the file — is what keeps a re-install\n * from leaving a stale sub-table that collides with the freshly written inline\n * block (a TOML duplicate-key error). Matches both the canonical quoted header\n * and the legacy bare header. Pass `block === null` to remove the footprint.\n * Identical algorithm to `mcp.ts`'s `writeCodexBlock` so the two never diverge.\n */\nexport function writeCodexBlock(\n file: string,\n name: string,\n block: string | null,\n): void {\n let content = \"\";\n try {\n content = fs.readFileSync(file, \"utf-8\");\n } catch {\n content = \"\";\n }\n\n const lines = content.split(/\\r?\\n/);\n const out: string[] = [];\n let i = 0;\n let removed = false;\n while (i < lines.length) {\n const line = lines[i];\n if (codexServerNameOfHeader(line) === name) {\n // Skip this table and its body (until the next table header), covering\n // the server table itself and any of its sub-tables.\n removed = true;\n i++;\n while (i < lines.length && parseTomlTableHeader(lines[i]) === null) i++;\n continue;\n }\n out.push(line);\n i++;\n }\n\n let next = out\n .join(\"\\n\")\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .replace(/\\n*$/, \"\\n\");\n if (block !== null) {\n next = next.replace(/\\n*$/, \"\\n\");\n if (next.trim().length) next += \"\\n\";\n next += block;\n }\n if (block === null && !removed) return; // nothing to do\n\n writeFileAtomic(file, next);\n}\n\nexport function codexHasBlock(file: string, name: string): boolean {\n try {\n const content = fs.readFileSync(file, \"utf-8\");\n return content\n .split(/\\r?\\n/)\n .some((line) => codexServerNameOfHeader(line) === name);\n } catch {\n return false;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Unified write helper\n// ---------------------------------------------------------------------------\n\n/**\n * Idempotently write the HTTP MCP server entry for `serverName` into the\n * given client's config file and return the file path that was written.\n * Re-running replaces the same named entry — never duplicates.\n */\nexport function writeHttpEntryForClient(\n client: ClientId,\n serverName: string,\n mcpUrl: string,\n token: string | undefined,\n baseDir: string,\n scope: string | undefined,\n headers?: Record<string, string>,\n): string {\n const file = configPathFor(client, baseDir, scope);\n if (client === \"codex\") {\n writeCodexBlock(\n file,\n serverName,\n buildCodexHttpBlock(serverName, mcpUrl, token, headers),\n );\n } else {\n writeJsonMcpEntryForClient(\n client,\n file,\n serverName,\n buildHttpMcpEntryForClient(client, mcpUrl, token, headers),\n );\n }\n return file;\n}\n\n// ---------------------------------------------------------------------------\n// Same-URL duplicate removal\n// ---------------------------------------------------------------------------\n\n/**\n * Canonicalise a URL for comparison: strip hash, search params, and trailing\n * slashes. Returns `undefined` for invalid URLs.\n */\nexport function canonicalUrl(value: string | undefined): string | undefined {\n if (!value) return undefined;\n try {\n const u = new URL(value);\n u.hash = \"\";\n u.search = \"\";\n return u.toString().replace(/\\/+$/, \"\");\n } catch {\n return undefined;\n }\n}\n\n/**\n * After writing the canonical `keepName` entry into a JSON config file,\n * remove any OTHER entries whose URL normalises to the same value as\n * `mcpUrl`. This cleans up stale alias names, legacy default names, and\n * leftover custom names that all pointed at the same server.\n *\n * Returns the list of entry names that were removed.\n */\nfunction removeJsonSameUrlDuplicatesAtKey(\n file: string,\n serversKey: string,\n mcpUrl: string,\n keepName: string,\n): string[] {\n let config: Record<string, any>;\n try {\n const raw = fs.readFileSync(file, \"utf-8\");\n if (!raw.trim()) return [];\n config = JSON.parse(raw);\n } catch {\n return [];\n }\n const servers = config?.[serversKey];\n if (!servers || typeof servers !== \"object\" || Array.isArray(servers)) {\n return [];\n }\n const targetCanonical = canonicalUrl(mcpUrl);\n if (!targetCanonical) return [];\n\n const toRemove: string[] = [];\n for (const name of Object.keys(servers)) {\n if (name === keepName) continue;\n const entry = servers[name];\n if (!entry || typeof entry !== \"object\") continue;\n const entryUrl = typeof entry.url === \"string\" ? entry.url : undefined;\n if (canonicalUrl(entryUrl) === targetCanonical) {\n toRemove.push(name);\n }\n }\n if (toRemove.length === 0) return [];\n for (const name of toRemove) {\n delete servers[name];\n }\n writeFileAtomic(file, JSON.stringify(config, null, 2) + \"\\n\");\n return toRemove;\n}\n\nexport function removeJsonSameUrlDuplicates(\n file: string,\n mcpUrl: string,\n keepName: string,\n): string[] {\n return removeJsonSameUrlDuplicatesAtKey(file, \"mcpServers\", mcpUrl, keepName);\n}\n\n/**\n * After writing the canonical `keepName` Codex block, remove any OTHER\n * `[mcp_servers.*]` servers in the same TOML file whose `url =` line normalises\n * to the same value as `mcpUrl`. A server's entire footprint is removed — its\n * own table AND any sub-tables (`.http_headers`, `.env`, …), even when they are\n * not contiguous — so cleanup never leaves an orphaned sub-table behind.\n * Returns removed entry names in first-seen order.\n */\nexport function removeCodexSameUrlDuplicates(\n file: string,\n mcpUrl: string,\n keepName: string,\n): string[] {\n let content = \"\";\n try {\n content = fs.readFileSync(file, \"utf-8\");\n } catch {\n return [];\n }\n const targetCanonical = canonicalUrl(mcpUrl);\n if (!targetCanonical) return [];\n\n const lines = content.split(/\\r?\\n/);\n\n // Pass 1: map each server name to the canonical URL declared on its own\n // table, preserving first-seen order. Sub-tables don't carry the URL, so they\n // only register the name.\n const serverUrls = new Map<string, string | undefined>();\n let i = 0;\n while (i < lines.length) {\n const keys = parseTomlTableHeader(lines[i]);\n const name =\n keys && keys.length >= 2 && keys[0] === \"mcp_servers\"\n ? keys[1]\n : undefined;\n if (name === undefined) {\n i++;\n continue;\n }\n const isServerTable = keys!.length === 2;\n const body: string[] = [];\n i++;\n while (i < lines.length && parseTomlTableHeader(lines[i]) === null) {\n body.push(lines[i]);\n i++;\n }\n if (isServerTable) {\n const urlMatch = body\n .join(\"\\n\")\n .match(/^\\s*url\\s*=\\s*\"((?:\\\\.|[^\"])*)\"/m);\n const blockUrl = urlMatch\n ? urlMatch[1].replace(/\\\\\"/g, '\"').replace(/\\\\\\\\/g, \"\\\\\")\n : undefined;\n serverUrls.set(name, canonicalUrl(blockUrl));\n } else if (!serverUrls.has(name)) {\n serverUrls.set(name, undefined);\n }\n }\n\n const removeSet = new Set<string>();\n for (const [name, canonical] of serverUrls) {\n if (name !== keepName && canonical && canonical === targetCanonical) {\n removeSet.add(name);\n }\n }\n if (removeSet.size === 0) return [];\n\n // Pass 2: rebuild, dropping every table/sub-table belonging to a removed\n // server.\n const out: string[] = [];\n i = 0;\n while (i < lines.length) {\n const name = codexServerNameOfHeader(lines[i]);\n if (name !== undefined && removeSet.has(name)) {\n i++;\n while (i < lines.length && parseTomlTableHeader(lines[i]) === null) i++;\n continue;\n }\n out.push(lines[i]);\n i++;\n }\n\n const next = out\n .join(\"\\n\")\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .replace(/\\n*$/, \"\\n\");\n writeFileAtomic(file, next);\n return [...removeSet];\n}\n\n/**\n * Unified helper: after writing the canonical `serverName` entry for the\n * given `client`, remove same-URL duplicates from its config file.\n * Returns the list of removed names (empty if nothing was cleaned up).\n */\nexport function removeSameUrlDuplicatesForClient(\n client: ClientId,\n serverName: string,\n mcpUrl: string,\n baseDir: string,\n scope: string | undefined,\n): string[] {\n const file = configPathFor(client, baseDir, scope);\n if (client === \"codex\") {\n return removeCodexSameUrlDuplicates(file, mcpUrl, serverName);\n }\n return removeJsonSameUrlDuplicatesAtKey(\n file,\n jsonMcpConfigKeyForClient(client),\n mcpUrl,\n serverName,\n );\n}\n"]}
1
+ {"version":3,"file":"mcp-config-writers.js","sourceRoot":"","sources":["../../src/cli/mcp-config-writers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,uBAAuB,GAAG,oBAAoB,CAAC;AACrD,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAWvC,MAAM,CAAC,MAAM,OAAO,GAAe;IACjC,aAAa;IACb,iBAAiB;IAC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AC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC,EAAE,CAAC;IACN,CAAC;IAED,MAAM,IAAI,GAAG,GAAG;SACb,IAAI,CAAC,IAAI,CAAC;SACV,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;SAC1B,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACzB,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC;AACxB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC9C,MAAgB,EAChB,UAAkB,EAClB,MAAc,EACd,OAAe,EACf,KAAyB;IAEzB,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACnD,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QACvB,OAAO,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,gCAAgC,CACrC,IAAI,EACJ,yBAAyB,CAAC,MAAM,CAAC,EACjC,MAAM,EACN,UAAU,CACX,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Shared MCP client-config writers.\n *\n * Extracted so both `agent-native mcp install` (see `mcp.ts`) and\n * `agent-native connect` (see `connect.ts`) write the EXACT same on-disk\n * config file targets and formats for every supported client.\n *\n * Supported clients and their config files:\n * - claude-code / claude-code-cli → `.mcp.json` (project) or\n * `~/.claude.json` (user). JSON `mcpServers[name] = entry`.\n * - cowork → `~/.cowork/mcp.json`. Same JSON shape.\n * - cursor → `.cursor/mcp.json` (project) or\n * `~/.cursor/mcp.json` (user). JSON `mcpServers[name] = entry`.\n * - opencode → `opencode.json` (project) or\n * `~/.config/opencode/opencode.json` (user). JSON `mcp[name] = entry`.\n * - github-copilot → `.vscode/mcp.json` (project) or the\n * VS Code user `mcp.json`. JSON `servers[name] = entry`.\n * - codex → `$CODEX_HOME/config.toml` when set,\n * otherwise `~/.codex/config.toml`.\n * `[mcp_servers.<name>]` block.\n *\n * Node-only. No new npm deps — hand-rolled JSON merge + minimal TOML block\n * merge, mirroring `mcp.ts`.\n */\n\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\nconst MCP_LEGACY_ROUTE_PREFIX = \"/_agent-native/mcp\";\nconst MCP_PUBLIC_ROUTE_PREFIX = \"/mcp\";\n\nexport type ClientId =\n | \"claude-code\"\n | \"claude-code-cli\"\n | \"codex\"\n | \"cowork\"\n | \"cursor\"\n | \"opencode\"\n | \"github-copilot\";\n\nexport const CLIENTS: ClientId[] = [\n \"claude-code\",\n \"claude-code-cli\",\n \"codex\",\n \"cowork\",\n \"cursor\",\n \"opencode\",\n \"github-copilot\",\n];\n\n/** The HTTP MCP server entry written into a JSON client config. */\nexport interface HttpMcpEntry {\n type: \"http\";\n url: string;\n headers?: Record<string, string>;\n}\n\n/** Build the HTTP MCP server entry for a deployed agent-native app. */\nexport function buildHttpMcpEntry(\n mcpUrl: string,\n token?: string,\n headers?: Record<string, string>,\n): HttpMcpEntry {\n const mergedHeaders = {\n ...(headers ?? {}),\n ...(token ? { Authorization: `Bearer ${token}` } : {}),\n };\n return {\n type: \"http\",\n url: mcpUrl,\n ...(Object.keys(mergedHeaders).length ? { headers: mergedHeaders } : {}),\n };\n}\n\nfunction mergedHeadersFor(\n token?: string,\n headers?: Record<string, string>,\n): Record<string, string> {\n return {\n ...(headers ?? {}),\n ...(token ? { Authorization: `Bearer ${token}` } : {}),\n };\n}\n\nexport function buildHttpMcpEntryForClient(\n client: ClientId,\n mcpUrl: string,\n token?: string,\n headers?: Record<string, string>,\n): Record<string, unknown> {\n const mergedHeaders = mergedHeadersFor(token, headers);\n if (client === \"cursor\") {\n return {\n url: mcpUrl,\n ...(Object.keys(mergedHeaders).length ? { headers: mergedHeaders } : {}),\n };\n }\n if (client === \"opencode\") {\n return {\n type: \"remote\",\n url: mcpUrl,\n enabled: true,\n ...(Object.keys(mergedHeaders).length ? { headers: mergedHeaders } : {}),\n };\n }\n if (client === \"github-copilot\") {\n return {\n type: \"http\",\n url: mcpUrl,\n ...(Object.keys(mergedHeaders).length\n ? { requestInit: { headers: mergedHeaders } }\n : {}),\n };\n }\n return buildHttpMcpEntry(mcpUrl, token, headers) as unknown as Record<\n string,\n unknown\n >;\n}\n\nexport function buildLocalMcpEntryForClient(\n client: ClientId,\n args: string[],\n env?: Record<string, string>,\n): Record<string, unknown> {\n const cleanEnv = env ? Object.fromEntries(Object.entries(env)) : {};\n if (client === \"opencode\") {\n return {\n type: \"local\",\n command: [\"agent-native\", ...args],\n enabled: true,\n ...(Object.keys(cleanEnv).length ? { environment: cleanEnv } : {}),\n };\n }\n if (client === \"github-copilot\") {\n return {\n type: \"stdio\",\n command: \"agent-native\",\n args,\n ...(Object.keys(cleanEnv).length ? { env: cleanEnv } : {}),\n };\n }\n return {\n command: \"agent-native\",\n args,\n ...(Object.keys(cleanEnv).length ? { env: cleanEnv } : {}),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Config file locations — kept identical to `mcp.ts`.\n// ---------------------------------------------------------------------------\n\n/**\n * Cowork consumes MCP exactly like Claude Code (same JSON server-entry\n * shape). Resolved lazily so `os.homedir()` reflects the current `$HOME`.\n */\nexport function coworkConfigPath(): string {\n return path.join(os.homedir(), \".cowork\", \"mcp.json\");\n}\n\nexport function claudeCodeProjectConfig(baseDir: string): string {\n return path.join(baseDir, \".mcp.json\");\n}\n\nexport function claudeCodeUserConfig(): string {\n return path.join(os.homedir(), \".claude.json\");\n}\n\nexport function codexConfigPath(): string {\n const codexHome = process.env.CODEX_HOME?.trim();\n if (codexHome) return path.join(codexHome, \"config.toml\");\n return path.join(os.homedir(), \".codex\", \"config.toml\");\n}\n\nexport function cursorProjectConfig(baseDir: string): string {\n return path.join(baseDir, \".cursor\", \"mcp.json\");\n}\n\nexport function cursorUserConfig(): string {\n return path.join(os.homedir(), \".cursor\", \"mcp.json\");\n}\n\nexport function opencodeProjectConfig(baseDir: string): string {\n return path.join(baseDir, \"opencode.json\");\n}\n\nexport function opencodeUserConfig(): string {\n const xdgConfigHome = process.env.XDG_CONFIG_HOME?.trim();\n const configRoot = xdgConfigHome || path.join(os.homedir(), \".config\");\n return path.join(configRoot, \"opencode\", \"opencode.json\");\n}\n\nexport function githubCopilotProjectConfig(baseDir: string): string {\n return path.join(baseDir, \".vscode\", \"mcp.json\");\n}\n\nexport function githubCopilotUserConfig(): string {\n if (process.platform === \"darwin\") {\n return path.join(\n os.homedir(),\n \"Library\",\n \"Application Support\",\n \"Code\",\n \"User\",\n \"mcp.json\",\n );\n }\n if (process.platform === \"win32\") {\n const appData =\n process.env.APPDATA || path.join(os.homedir(), \"AppData\", \"Roaming\");\n return path.join(appData, \"Code\", \"User\", \"mcp.json\");\n }\n const xdgConfigHome = process.env.XDG_CONFIG_HOME?.trim();\n const configRoot = xdgConfigHome || path.join(os.homedir(), \".config\");\n return path.join(configRoot, \"Code\", \"User\", \"mcp.json\");\n}\n\n/**\n * Resolve the on-disk config path for a client.\n *\n * `scope` only affects Claude Code / Claude Code CLI: `\"user\"` → the global\n * `~/.claude.json`, anything else → the project-local `.mcp.json` rooted at\n * `baseDir`.\n */\nexport function configPathFor(\n client: ClientId,\n baseDir: string,\n scope: string | undefined,\n): string {\n switch (client) {\n case \"claude-code\":\n case \"claude-code-cli\":\n return scope === \"user\"\n ? claudeCodeUserConfig()\n : claudeCodeProjectConfig(baseDir);\n case \"cowork\":\n return coworkConfigPath();\n case \"codex\":\n return codexConfigPath();\n case \"cursor\":\n return scope === \"user\"\n ? cursorUserConfig()\n : cursorProjectConfig(baseDir);\n case \"opencode\":\n return scope === \"user\"\n ? opencodeUserConfig()\n : opencodeProjectConfig(baseDir);\n case \"github-copilot\":\n return scope === \"user\"\n ? githubCopilotUserConfig()\n : githubCopilotProjectConfig(baseDir);\n }\n}\n\n// ---------------------------------------------------------------------------\n// JSON client configs (Claude Code, Claude Code CLI, Cowork)\n// ---------------------------------------------------------------------------\n\n/**\n * Read and parse a JSON config file.\n *\n * - Missing file → returns `{}` (fresh config).\n * - Empty file → returns `{}` (treat as not-yet-initialised).\n * - Non-empty file that fails to parse → throws a descriptive Error so the\n * caller can surface it to the user instead of silently overwriting the\n * file with only the new MCP entry (data-loss hazard).\n */\nfunction readJsonFile(file: string): Record<string, any> {\n let raw: string;\n try {\n raw = fs.readFileSync(file, \"utf-8\");\n } catch {\n // Missing (ENOENT) or unreadable file — treat as empty.\n return {};\n }\n if (!raw.trim()) return {};\n try {\n const parsed = JSON.parse(raw);\n return parsed && typeof parsed === \"object\" ? parsed : {};\n } catch {\n throw new Error(\n `Cannot parse JSON config file: ${file}\\n` +\n `Fix or move the file and re-run. The file has not been modified.`,\n );\n }\n}\n\n/**\n * Write `data` to `file` atomically: write a sibling temp file, then rename it\n * over the target. `rename(2)` is atomic on the same filesystem, so a crash or\n * `kill` mid-write can never leave a half-written/truncated file. This matters\n * most for `~/.claude.json`, which is Claude Code's entire user state (projects,\n * history, auth) — a torn write there would corrupt the user's whole config,\n * not just our MCP entry. The temp file lives in the target's directory so the\n * rename stays within one filesystem.\n */\nexport function writeFileAtomic(file: string, data: string): void {\n const dir = path.dirname(file);\n fs.mkdirSync(dir, { recursive: true });\n // Preserve the target's existing permission bits. A fresh temp file would\n // otherwise be created with the umask default (typically 0644), silently\n // loosening a secret-bearing file the user locked down to 0600 (e.g. .env).\n let mode: number | undefined;\n try {\n mode = fs.statSync(file).mode & 0o777;\n } catch {\n // Target doesn't exist yet — let the default creation mode apply.\n }\n const tmp = path.join(dir, `.${path.basename(file)}.tmp-${process.pid}`);\n try {\n fs.writeFileSync(tmp, data, \"utf-8\");\n if (mode !== undefined) fs.chmodSync(tmp, mode);\n fs.renameSync(tmp, file);\n } catch (err) {\n try {\n fs.rmSync(tmp, { force: true });\n } catch {}\n throw err;\n }\n}\n\n/**\n * Idempotently write `mcpServers[name] = entry` into a JSON config file.\n * Pass `entry === null` to delete the named entry. Re-running with the same\n * name replaces the existing entry in place — never duplicates.\n */\nexport function jsonMcpConfigKeyForClient(client: ClientId): string {\n if (client === \"opencode\") return \"mcp\";\n if (client === \"github-copilot\") return \"servers\";\n return \"mcpServers\";\n}\n\nfunction writeJsonMcpEntryAtKey(\n file: string,\n serversKey: string,\n name: string,\n entry: Record<string, unknown> | null,\n): void {\n const config = readJsonFile(file);\n if (!config[serversKey] || typeof config[serversKey] !== \"object\") {\n config[serversKey] = {};\n }\n const servers = config[serversKey] as Record<string, unknown>;\n if (entry === null) {\n delete servers[name];\n } else {\n servers[name] = entry;\n }\n writeFileAtomic(file, JSON.stringify(config, null, 2) + \"\\n\");\n}\n\nexport function writeJsonMcpEntry(\n file: string,\n name: string,\n entry: Record<string, unknown> | null,\n): void {\n writeJsonMcpEntryAtKey(file, \"mcpServers\", name, entry);\n}\n\nexport function writeJsonMcpEntryForClient(\n client: ClientId,\n file: string,\n name: string,\n entry: Record<string, unknown> | null,\n): void {\n writeJsonMcpEntryAtKey(file, jsonMcpConfigKeyForClient(client), name, entry);\n}\n\nexport function hasJsonMcpEntry(file: string, name: string): boolean {\n const config = readJsonFile(file);\n return !!config?.mcpServers && name in config.mcpServers;\n}\n\nexport function hasJsonMcpEntryForClient(\n client: ClientId,\n file: string,\n name: string,\n): boolean {\n const config = readJsonFile(file);\n const servers = config?.[jsonMcpConfigKeyForClient(client)];\n return !!servers && typeof servers === \"object\" && name in servers;\n}\n\n// ---------------------------------------------------------------------------\n// Codex TOML (hand-rolled minimal block merge, no new dep)\n// ---------------------------------------------------------------------------\n\nfunction tomlQuote(s: string): string {\n return `\"${s.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"')}\"`;\n}\n\nfunction codexMcpHeader(name: string): string {\n return `[mcp_servers.${tomlQuote(name)}]`;\n}\n\n/**\n * Parse a TOML table-header line such as `[mcp_servers.\"plan\".http_headers]`\n * or `[mcp_servers.plan] # local note` into its decoded dotted-key components\n * (`[\"mcp_servers\", \"plan\", \"http_headers\"]`). Returns `null` when the line is\n * not a single `[table]` header — blank lines, key/value pairs, comments,\n * invalid trailing content, and `[[array-of-tables]]` headers all return `null`,\n * so the result doubles as a reliable \"is this line a table boundary?\" check.\n *\n * Handles bare keys (`A-Za-z0-9_-`) and quoted keys (basic `\"...\"` with `\\`\n * escapes, and literal `'...'`), tolerating whitespace around the dot\n * separators per the TOML spec. Quoted-key escape handling mirrors the inverse\n * of `tomlQuote` (`\\\"` → `\"`, `\\\\` → `\\`).\n */\nfunction parseTomlTableHeader(line: string): string[] | null {\n const trimmed = line.trim();\n if (trimmed.length < 2 || trimmed[0] !== \"[\") return null;\n // `[[array-of-tables]]` is a different construct — leave it untouched.\n if (trimmed[1] === \"[\") return null;\n\n let quote: '\"' | \"'\" | null = null;\n let escaped = false;\n let closeIndex = -1;\n for (let i = 1; i < trimmed.length; i++) {\n const ch = trimmed[i];\n if (quote === '\"') {\n if (escaped) {\n escaped = false;\n continue;\n }\n if (ch === \"\\\\\") {\n escaped = true;\n continue;\n }\n if (ch === '\"') quote = null;\n continue;\n }\n if (quote === \"'\") {\n if (ch === \"'\") quote = null;\n continue;\n }\n if (ch === '\"' || ch === \"'\") {\n quote = ch;\n continue;\n }\n if (ch === \"]\") {\n closeIndex = i;\n break;\n }\n }\n if (closeIndex < 0) return null;\n const trailing = trimmed.slice(closeIndex + 1).trim();\n if (trailing && !trailing.startsWith(\"#\")) return null;\n\n const inner = trimmed.slice(1, closeIndex);\n const keys: string[] = [];\n const isWs = (c: string) => c === \" \" || c === \"\\t\";\n const isBare = (c: string) => /[A-Za-z0-9_-]/.test(c);\n let i = 0;\n let expectKey = true;\n while (i < inner.length) {\n while (i < inner.length && isWs(inner[i])) i++;\n if (i >= inner.length) break;\n const ch = inner[i];\n if (ch === \".\") {\n if (expectKey) return null; // leading or doubled dot\n expectKey = true;\n i++;\n continue;\n }\n if (!expectKey) return null; // two keys with no dot between them\n if (ch === '\"' || ch === \"'\") {\n const quote = ch;\n i++;\n let key = \"\";\n while (i < inner.length && inner[i] !== quote) {\n if (quote === '\"' && inner[i] === \"\\\\\" && i + 1 < inner.length) {\n const next = inner[i + 1];\n key += next === '\"' ? '\"' : next === \"\\\\\" ? \"\\\\\" : `\\\\${next}`;\n i += 2;\n continue;\n }\n key += inner[i];\n i++;\n }\n if (i >= inner.length) return null; // unterminated quote\n i++; // consume the closing quote\n keys.push(key);\n expectKey = false;\n } else if (isBare(ch)) {\n let key = \"\";\n while (i < inner.length && isBare(inner[i])) {\n key += inner[i];\n i++;\n }\n keys.push(key);\n expectKey = false;\n } else {\n return null; // unexpected character — not a table header\n }\n }\n if (expectKey) return null; // empty header or trailing dot\n return keys.length ? keys : null;\n}\n\n/**\n * The MCP server name a TOML table header belongs to, or `undefined` when the\n * header is not under `[mcp_servers.*]`. The server's own table\n * (`[mcp_servers.<name>]`) AND every sub-table of it\n * (`[mcp_servers.<name>.http_headers]`, `[mcp_servers.<name>.env]`, …) resolve\n * to the same `<name>`, so callers can treat a server and all its sub-tables as\n * one removable unit. This is what prevents a re-install from orphaning a stale\n * `[mcp_servers.<name>.http_headers]` sub-table that would then collide with the\n * freshly written inline `http_headers` (a TOML duplicate-key error).\n */\nfunction codexServerNameOfHeader(line: string): string | undefined {\n const keys = parseTomlTableHeader(line);\n if (!keys || keys.length < 2 || keys[0] !== \"mcp_servers\") return undefined;\n return keys[1];\n}\n\n/** Build a `[mcp_servers.<name>]` block for an HTTP-type MCP server. */\nexport function buildCodexHttpBlock(\n name: string,\n mcpUrl: string,\n token?: string,\n headers?: Record<string, string>,\n): string {\n const lines: string[] = [codexMcpHeader(name)];\n lines.push(`url = ${tomlQuote(mcpUrl)}`);\n const mergedHeaders = {\n ...(headers ?? {}),\n ...(token ? { Authorization: `Bearer ${token}` } : {}),\n };\n const headerEntries = Object.entries(mergedHeaders);\n if (headerEntries.length) {\n lines.push(\n `http_headers = { ${headerEntries\n .map(([key, value]) => `${tomlQuote(key)} = ${tomlQuote(value)}`)\n .join(\", \")} }`,\n );\n }\n return lines.join(\"\\n\") + \"\\n\";\n}\n\nexport function buildCodexLocalBlock(\n name: string,\n args: string[],\n env?: Record<string, string>,\n): string {\n const lines: string[] = [codexMcpHeader(name)];\n lines.push(`command = \"agent-native\"`);\n lines.push(`args = [${args.map(tomlQuote).join(\", \")}]`);\n const cleanEnv = env ? Object.fromEntries(Object.entries(env)) : {};\n if (Object.keys(cleanEnv).length) {\n const inline = Object.entries(cleanEnv)\n .map(([key, value]) => `${key} = ${tomlQuote(value)}`)\n .join(\", \");\n lines.push(`env = { ${inline} }`);\n }\n return lines.join(\"\\n\") + \"\\n\";\n}\n\n/**\n * Replace (or append) the entire `[mcp_servers.<name>]` footprint in a TOML\n * file without disturbing other content. The footprint is the server's own\n * table AND every sub-table of it (`[mcp_servers.<name>.http_headers]`,\n * `[mcp_servers.<name>.env]`, …), each spanning its header line plus every\n * following line until the next table header or EOF. Removing the whole\n * footprint — wherever the pieces sit in the file — is what keeps a re-install\n * from leaving a stale sub-table that collides with the freshly written inline\n * block (a TOML duplicate-key error). Matches both the canonical quoted header\n * and the legacy bare header. Pass `block === null` to remove the footprint.\n * Identical algorithm to `mcp.ts`'s `writeCodexBlock` so the two never diverge.\n */\nexport function writeCodexBlock(\n file: string,\n name: string,\n block: string | null,\n): void {\n let content = \"\";\n try {\n content = fs.readFileSync(file, \"utf-8\");\n } catch {\n content = \"\";\n }\n\n const lines = content.split(/\\r?\\n/);\n const out: string[] = [];\n let i = 0;\n let removed = false;\n while (i < lines.length) {\n const line = lines[i];\n if (codexServerNameOfHeader(line) === name) {\n // Skip this table and its body (until the next table header), covering\n // the server table itself and any of its sub-tables.\n removed = true;\n i++;\n while (i < lines.length && parseTomlTableHeader(lines[i]) === null) i++;\n continue;\n }\n out.push(line);\n i++;\n }\n\n let next = out\n .join(\"\\n\")\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .replace(/\\n*$/, \"\\n\");\n if (block !== null) {\n next = next.replace(/\\n*$/, \"\\n\");\n if (next.trim().length) next += \"\\n\";\n next += block;\n }\n if (block === null && !removed) return; // nothing to do\n\n writeFileAtomic(file, next);\n}\n\nexport function codexHasBlock(file: string, name: string): boolean {\n try {\n const content = fs.readFileSync(file, \"utf-8\");\n return content\n .split(/\\r?\\n/)\n .some((line) => codexServerNameOfHeader(line) === name);\n } catch {\n return false;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Unified write helper\n// ---------------------------------------------------------------------------\n\n/**\n * Idempotently write the HTTP MCP server entry for `serverName` into the\n * given client's config file and return the file path that was written.\n * Re-running replaces the same named entry — never duplicates.\n */\nexport function writeHttpEntryForClient(\n client: ClientId,\n serverName: string,\n mcpUrl: string,\n token: string | undefined,\n baseDir: string,\n scope: string | undefined,\n headers?: Record<string, string>,\n): string {\n const file = configPathFor(client, baseDir, scope);\n if (client === \"codex\") {\n writeCodexBlock(\n file,\n serverName,\n buildCodexHttpBlock(serverName, mcpUrl, token, headers),\n );\n } else {\n writeJsonMcpEntryForClient(\n client,\n file,\n serverName,\n buildHttpMcpEntryForClient(client, mcpUrl, token, headers),\n );\n }\n return file;\n}\n\n// ---------------------------------------------------------------------------\n// Same-URL duplicate removal\n// ---------------------------------------------------------------------------\n\n/**\n * Canonicalise a URL for comparison: strip hash, search params, and trailing\n * slashes. Returns `undefined` for invalid URLs.\n */\nexport function canonicalUrl(value: string | undefined): string | undefined {\n if (!value) return undefined;\n try {\n const u = new URL(value);\n u.hash = \"\";\n u.search = \"\";\n const pathname = u.pathname.replace(/\\/+$/, \"\");\n if (\n pathname === MCP_LEGACY_ROUTE_PREFIX ||\n pathname.endsWith(MCP_LEGACY_ROUTE_PREFIX)\n ) {\n u.pathname = `${pathname.slice(0, -MCP_LEGACY_ROUTE_PREFIX.length)}${MCP_PUBLIC_ROUTE_PREFIX}`;\n }\n return u.toString().replace(/\\/+$/, \"\");\n } catch {\n return undefined;\n }\n}\n\n/**\n * After writing the canonical `keepName` entry into a JSON config file,\n * remove any OTHER entries whose URL normalises to the same value as\n * `mcpUrl`. This cleans up stale alias names, legacy default names, and\n * leftover custom names that all pointed at the same server.\n *\n * Returns the list of entry names that were removed.\n */\nfunction removeJsonSameUrlDuplicatesAtKey(\n file: string,\n serversKey: string,\n mcpUrl: string,\n keepName: string,\n): string[] {\n let config: Record<string, any>;\n try {\n const raw = fs.readFileSync(file, \"utf-8\");\n if (!raw.trim()) return [];\n config = JSON.parse(raw);\n } catch {\n return [];\n }\n const servers = config?.[serversKey];\n if (!servers || typeof servers !== \"object\" || Array.isArray(servers)) {\n return [];\n }\n const targetCanonical = canonicalUrl(mcpUrl);\n if (!targetCanonical) return [];\n\n const toRemove: string[] = [];\n for (const name of Object.keys(servers)) {\n if (name === keepName) continue;\n const entry = servers[name];\n if (!entry || typeof entry !== \"object\") continue;\n const entryUrl = typeof entry.url === \"string\" ? entry.url : undefined;\n if (canonicalUrl(entryUrl) === targetCanonical) {\n toRemove.push(name);\n }\n }\n if (toRemove.length === 0) return [];\n for (const name of toRemove) {\n delete servers[name];\n }\n writeFileAtomic(file, JSON.stringify(config, null, 2) + \"\\n\");\n return toRemove;\n}\n\nexport function removeJsonSameUrlDuplicates(\n file: string,\n mcpUrl: string,\n keepName: string,\n): string[] {\n return removeJsonSameUrlDuplicatesAtKey(file, \"mcpServers\", mcpUrl, keepName);\n}\n\n/**\n * After writing the canonical `keepName` Codex block, remove any OTHER\n * `[mcp_servers.*]` servers in the same TOML file whose `url =` line normalises\n * to the same value as `mcpUrl`. A server's entire footprint is removed — its\n * own table AND any sub-tables (`.http_headers`, `.env`, …), even when they are\n * not contiguous — so cleanup never leaves an orphaned sub-table behind.\n * Returns removed entry names in first-seen order.\n */\nexport function removeCodexSameUrlDuplicates(\n file: string,\n mcpUrl: string,\n keepName: string,\n): string[] {\n let content = \"\";\n try {\n content = fs.readFileSync(file, \"utf-8\");\n } catch {\n return [];\n }\n const targetCanonical = canonicalUrl(mcpUrl);\n if (!targetCanonical) return [];\n\n const lines = content.split(/\\r?\\n/);\n\n // Pass 1: map each server name to the canonical URL declared on its own\n // table, preserving first-seen order. Sub-tables don't carry the URL, so they\n // only register the name.\n const serverUrls = new Map<string, string | undefined>();\n let i = 0;\n while (i < lines.length) {\n const keys = parseTomlTableHeader(lines[i]);\n const name =\n keys && keys.length >= 2 && keys[0] === \"mcp_servers\"\n ? keys[1]\n : undefined;\n if (name === undefined) {\n i++;\n continue;\n }\n const isServerTable = keys!.length === 2;\n const body: string[] = [];\n i++;\n while (i < lines.length && parseTomlTableHeader(lines[i]) === null) {\n body.push(lines[i]);\n i++;\n }\n if (isServerTable) {\n const urlMatch = body\n .join(\"\\n\")\n .match(/^\\s*url\\s*=\\s*\"((?:\\\\.|[^\"])*)\"/m);\n const blockUrl = urlMatch\n ? urlMatch[1].replace(/\\\\\"/g, '\"').replace(/\\\\\\\\/g, \"\\\\\")\n : undefined;\n serverUrls.set(name, canonicalUrl(blockUrl));\n } else if (!serverUrls.has(name)) {\n serverUrls.set(name, undefined);\n }\n }\n\n const removeSet = new Set<string>();\n for (const [name, canonical] of serverUrls) {\n if (name !== keepName && canonical && canonical === targetCanonical) {\n removeSet.add(name);\n }\n }\n if (removeSet.size === 0) return [];\n\n // Pass 2: rebuild, dropping every table/sub-table belonging to a removed\n // server.\n const out: string[] = [];\n i = 0;\n while (i < lines.length) {\n const name = codexServerNameOfHeader(lines[i]);\n if (name !== undefined && removeSet.has(name)) {\n i++;\n while (i < lines.length && parseTomlTableHeader(lines[i]) === null) i++;\n continue;\n }\n out.push(lines[i]);\n i++;\n }\n\n const next = out\n .join(\"\\n\")\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .replace(/\\n*$/, \"\\n\");\n writeFileAtomic(file, next);\n return [...removeSet];\n}\n\n/**\n * Unified helper: after writing the canonical `serverName` entry for the\n * given `client`, remove same-URL duplicates from its config file.\n * Returns the list of removed names (empty if nothing was cleaned up).\n */\nexport function removeSameUrlDuplicatesForClient(\n client: ClientId,\n serverName: string,\n mcpUrl: string,\n baseDir: string,\n scope: string | undefined,\n): string[] {\n const file = configPathFor(client, baseDir, scope);\n if (client === \"codex\") {\n return removeCodexSameUrlDuplicates(file, mcpUrl, serverName);\n }\n return removeJsonSameUrlDuplicatesAtKey(\n file,\n jsonMcpConfigKeyForClient(client),\n mcpUrl,\n serverName,\n );\n}\n"]}
package/dist/cli/mcp.js CHANGED
@@ -15,6 +15,7 @@
15
15
  import crypto from "node:crypto";
16
16
  import fs from "node:fs";
17
17
  import path from "node:path";
18
+ import { MCP_PUBLIC_ROUTE_PREFIX } from "../mcp/route-paths.js";
18
19
  import { runScreenMemoryMCPStdio } from "../mcp/screen-memory-stdio.js";
19
20
  import { runMCPStdio } from "../mcp/stdio.js";
20
21
  import { findWorkspaceRoot, resolveLocalAppOrigin, resolveWorkspace, } from "../mcp/workspace-resolve.js";
@@ -139,7 +140,7 @@ function ensureLocalToken(cwd, rotate = false) {
139
140
  /**
140
141
  * Detect a hosted deployment URL. When the workspace .env points at a hosted
141
142
  * origin (APP_URL / BETTER_AUTH_URL with a non-localhost host) we write an
142
- * `http` client entry pointing at `<origin>/_agent-native/mcp` with a JWT
143
+ * `http` client entry pointing at `<origin>/mcp` with a JWT
143
144
  * bearer instead of a stdio entry.
144
145
  */
145
146
  function detectHostedUrl(cwd) {
@@ -154,7 +155,8 @@ function detectHostedUrl(cwd) {
154
155
  try {
155
156
  const u = new URL(v);
156
157
  if (!/^(localhost|127\.0\.0\.1|\[::1\])$/.test(u.hostname)) {
157
- return `${u.origin}/_agent-native/mcp`;
158
+ const appPath = u.pathname.replace(/\/+$/, "");
159
+ return `${u.origin}${appPath === "/" ? "" : appPath}${MCP_PUBLIC_ROUTE_PREFIX}`;
158
160
  }
159
161
  }
160
162
  catch {
@@ -378,7 +380,7 @@ async function cmdStatus() {
378
380
  logOut(` App: ${appId}`);
379
381
  logOut(hostedUrl
380
382
  ? ` MCP URL: ${hostedUrl} (hosted)`
381
- : ` MCP URL: ${origin}/_agent-native/mcp${port ? ` (port ${port})` : ""}`);
383
+ : ` MCP URL: ${origin}/mcp${port ? ` (port ${port})` : ""}`);
382
384
  logOut(` ACCESS_TOKEN: ${hasToken ? "set" : "not set"} (.env)`);
383
385
  logOut(` A2A_SECRET: ${hasA2A ? "set" : "not set"}`);
384
386
  logOut(` Clients:`);
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/cli/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,OAAO,EAEP,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,eAAe,EACf,aAAa,EACb,aAAa,IAAI,mBAAmB,EACpC,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AAEjC,MAAM,kBAAkB,GAAG,cAAc,CAAC;AAa1C,SAAS,SAAS,CAAC,IAAc;IAC/B,MAAM,GAAG,GAAe,EAAE,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACpE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,GAAG,GAAG,CAAC,IAAY,EAAsB,EAAE;YAC/C,IAAI,CAAC,KAAK,IAAI;gBAAE,OAAO,IAAI,CA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AAC,CAAC,CAAC;YAChB,OAAO;QACT,KAAK,QAAQ;YACX,MAAM,SAAS,EAAE,CAAC;YAClB,OAAO;QACT,KAAK,OAAO;YACV,QAAQ,CAAC,CAAC,CAAC,CAAC;YACZ,OAAO;QACT,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,IAAI,CAAC;QACV,KAAK,MAAM;YACT,MAAM,CAAC,IAAI,CAAC,CAAC;YACb,OAAO;QACT;YACE,MAAM,CAAC,2BAA2B,GAAG,EAAE,CAAC,CAAC;YACzC,MAAM,CAAC,IAAI,CAAC,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACH,CAAC","sourcesContent":["/**\n * `agent-native mcp <subcommand>` — connect external coding agents (Claude\n * Code desktop & CLI, Claude Cowork, Codex, Cursor, OpenCode, GitHub Copilot /\n * VS Code) to this agent-native app/workspace over MCP.\n *\n * serve Run the MCP stdio transport (this is what client configs spawn).\n * install Provision a token + write the client's MCP config idempotently.\n * uninstall Remove the named entry from a client's MCP config.\n * status Print resolved MCP URL/port, token state, and per-client entries.\n * token Print or rotate the local ACCESS_TOKEN in the workspace .env.\n *\n * Node-only CLI module. Hand-rolled `.env` upsert + minimal TOML block merge\n * keep this dependency-free (no new npm deps).\n */\n\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { runScreenMemoryMCPStdio } from \"../mcp/screen-memory-stdio.js\";\nimport { runMCPStdio } from \"../mcp/stdio.js\";\nimport {\n findWorkspaceRoot,\n resolveLocalAppOrigin,\n resolveWorkspace,\n} from \"../mcp/workspace-resolve.js\";\nimport {\n CLIENTS,\n type ClientId,\n buildCodexHttpBlock,\n buildCodexLocalBlock,\n buildHttpMcpEntryForClient,\n buildLocalMcpEntryForClient,\n codexConfigPath,\n codexHasBlock,\n configPathFor as clientConfigPathFor,\n hasJsonMcpEntryForClient,\n writeCodexBlock,\n writeFileAtomic,\n writeJsonMcpEntryForClient,\n} from \"./mcp-config-writers.js\";\n\nconst SERVER_NAME_PREFIX = \"agent-native\";\n\ninterface ParsedArgs {\n _: string[];\n client?: string;\n app?: string;\n port?: number;\n screenMemoryDir?: string;\n scope?: string;\n standalone: boolean;\n rotate: boolean;\n}\n\nfunction parseArgs(argv: string[]): ParsedArgs {\n const out: ParsedArgs = { _: [], standalone: false, rotate: false };\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i];\n const eat = (flag: string): string | undefined => {\n if (a === flag) return argv[++i];\n if (a.startsWith(`${flag}=`)) return a.slice(flag.length + 1);\n return undefined;\n };\n let v: string | undefined;\n if ((v = eat(\"--client\")) !== undefined) out.client = v;\n else if ((v = eat(\"--app\")) !== undefined) out.app = v;\n else if ((v = eat(\"--port\")) !== undefined) out.port = Number(v);\n else if ((v = eat(\"--dir\")) !== undefined) out.screenMemoryDir = v;\n else if ((v = eat(\"--scope\")) !== undefined) out.scope = v;\n else if (a === \"--standalone\") out.standalone = true;\n else if (a === \"--rotate\") out.rotate = true;\n else if (!a.startsWith(\"-\")) out._.push(a);\n }\n return out;\n}\n\nfunction logErr(msg: string): void {\n process.stderr.write(`${msg}\\n`);\n}\nfunction logOut(msg: string): void {\n process.stdout.write(`${msg}\\n`);\n}\n\n// ---------------------------------------------------------------------------\n// .env token provisioning (local dev) — hand-rolled idempotent upsert\n// ---------------------------------------------------------------------------\n\n/** Workspace root (or cwd for a standalone app) — where .env lives. */\nfunction envBaseDir(cwd = process.cwd()): string {\n return findWorkspaceRoot(cwd) ?? path.resolve(cwd);\n}\n\n/** Prefer .env.local, else .env. Returns the path we should write to. */\nfunction envFilePath(baseDir: string): string {\n const local = path.join(baseDir, \".env.local\");\n if (fs.existsSync(local)) return local;\n return path.join(baseDir, \".env\");\n}\n\nfunction readEnvFile(file: string): string {\n try {\n return fs.readFileSync(file, \"utf-8\");\n } catch {\n return \"\";\n }\n}\n\n/** Read a single key from a dotenv-format string (last assignment wins). */\nfunction getEnvValue(content: string, key: string): string | undefined {\n let found: string | undefined;\n for (const line of content.split(/\\r?\\n/)) {\n const m = line.match(/^\\s*([A-Z0-9_]+)\\s*=\\s*(.*)\\s*$/i);\n if (m && m[1] === key) {\n found = m[2].replace(/^[\"']|[\"']$/g, \"\");\n }\n }\n return found;\n}\n\n/**\n * Idempotently set `key=value` in the dotenv file. If the key already exists\n * we leave it untouched unless `force` is set (used by `token --rotate`).\n * Never clobbers an existing token implicitly.\n */\nfunction upsertEnv(\n file: string,\n key: string,\n value: string,\n force = false,\n): { changed: boolean; value: string } {\n const content = readEnvFile(file);\n const existing = getEnvValue(content, key);\n if (existing && !force) return { changed: false, value: existing };\n\n const line = `${key}=${value}`;\n let next: string;\n if (new RegExp(`^\\\\s*${key}\\\\s*=`, \"m\").test(content)) {\n next = content.replace(new RegExp(`^\\\\s*${key}\\\\s*=.*$`, \"m\"), line);\n } else {\n next =\n content.length === 0\n ? `${line}\\n`\n : `${content.replace(/\\n*$/, \"\")}\\n${line}\\n`;\n }\n writeFileAtomic(file, next);\n return { changed: true, value };\n}\n\nfunction generateToken(): string {\n return crypto.randomBytes(24).toString(\"base64url\");\n}\n\n/**\n * Ensure a local ACCESS_TOKEN exists in the workspace .env and return it.\n * Existing tokens are reused (never clobbered). Set `rotate` to replace it.\n */\nfunction ensureLocalToken(\n cwd: string,\n rotate = false,\n): { token: string; file: string; created: boolean } {\n const baseDir = envBaseDir(cwd);\n const file = envFilePath(baseDir);\n const content = readEnvFile(file);\n const existing = getEnvValue(content, \"ACCESS_TOKEN\");\n if (existing && !rotate) {\n return { token: existing, file, created: false };\n }\n const token = generateToken();\n upsertEnv(file, \"ACCESS_TOKEN\", token, true);\n return { token, file, created: true };\n}\n\n// ---------------------------------------------------------------------------\n// Hosted vs local detection\n// ---------------------------------------------------------------------------\n\n/**\n * Detect a hosted deployment URL. When the workspace .env points at a hosted\n * origin (APP_URL / BETTER_AUTH_URL with a non-localhost host) we write an\n * `http` client entry pointing at `<origin>/_agent-native/mcp` with a JWT\n * bearer instead of a stdio entry.\n */\nfunction detectHostedUrl(cwd: string): string | undefined {\n const baseDir = envBaseDir(cwd);\n const content =\n readEnvFile(path.join(baseDir, \".env.local\")) +\n \"\\n\" +\n readEnvFile(path.join(baseDir, \".env\"));\n for (const key of [\"AGENT_NATIVE_MCP_URL\", \"APP_URL\", \"BETTER_AUTH_URL\"]) {\n const v = getEnvValue(content, key);\n if (!v) continue;\n try {\n const u = new URL(v);\n if (!/^(localhost|127\\.0\\.0\\.1|\\[::1\\])$/.test(u.hostname)) {\n return `${u.origin}/_agent-native/mcp`;\n }\n } catch {\n // not a URL — skip\n }\n }\n return undefined;\n}\n\nasync function mintHostedJwt(cwd: string): Promise<string | undefined> {\n // Reuse the existing A2A signer — do not reinvent JWT minting.\n const owner =\n process.env.AGENT_NATIVE_OWNER_EMAIL ||\n process.env.OWNER_EMAIL ||\n \"owner@localhost\";\n let fileA2ASecret: string | undefined;\n if (!process.env.A2A_SECRET) {\n const baseDir = envBaseDir(cwd);\n const content =\n readEnvFile(path.join(baseDir, \".env.local\")) +\n \"\\n\" +\n readEnvFile(path.join(baseDir, \".env\"));\n fileA2ASecret = getEnvValue(content, \"A2A_SECRET\");\n }\n try {\n const { signA2AToken } = await import(\"../a2a/client.js\");\n return await signA2AToken(\n owner,\n undefined,\n process.env.A2A_SECRET || fileA2ASecret,\n {\n preferGlobalSecret: true,\n expiresIn: \"30d\",\n },\n );\n } catch (err: any) {\n logErr(\n ` Could not mint a hosted JWT (${err?.message ?? err}). ` +\n `Set A2A_SECRET in your workspace .env, or use the local stdio entry.`,\n );\n return undefined;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Client config entries\n// ---------------------------------------------------------------------------\n\ninterface ServerEntryInputs {\n serverName: string;\n appId: string;\n token?: string;\n ownerEmail?: string;\n hostedUrl?: string;\n standalone: boolean;\n}\n\nfunction mcpServeArgs(i: ServerEntryInputs): string[] {\n const args = [\"mcp\", \"serve\"];\n if (i.appId) args.push(\"--app\", i.appId);\n if (i.standalone) args.push(\"--standalone\");\n return args;\n}\n\nfunction mcpServeEnv(i: ServerEntryInputs): Record<string, string> {\n const env: Record<string, string> = {};\n if (i.token) env.ACCESS_TOKEN = i.token;\n if (i.ownerEmail) env.AGENT_NATIVE_OWNER_EMAIL = i.ownerEmail;\n return env;\n}\n\nfunction buildJsonServerEntry(\n client: ClientId,\n i: ServerEntryInputs,\n): Record<string, unknown> {\n if (i.hostedUrl) {\n return buildHttpMcpEntryForClient(client, i.hostedUrl, i.token);\n }\n return buildLocalMcpEntryForClient(client, mcpServeArgs(i), mcpServeEnv(i));\n}\n\nfunction buildCodexBlock(name: string, i: ServerEntryInputs): string {\n if (i.hostedUrl) {\n return buildCodexHttpBlock(name, i.hostedUrl, i.token);\n }\n return buildCodexLocalBlock(name, mcpServeArgs(i), mcpServeEnv(i));\n}\n\n// ---------------------------------------------------------------------------\n// Per-client install/uninstall/status\n// ---------------------------------------------------------------------------\n\nfunction configPathFor(\n client: ClientId,\n cwd: string,\n scope: string | undefined,\n): string {\n return clientConfigPathFor(client, envBaseDir(cwd), scope);\n}\n\nfunction serverNameFor(appId: string): string {\n return `${SERVER_NAME_PREFIX}-${appId}`;\n}\n\n// Clients advertised in usage/help and listed by status. Excludes the legacy\n// `claude-code-cli` alias so only a single \"Claude Code\" appears (it is still\n// accepted via --client and collapses to claude-code).\nconst SELECTABLE_CLIENTS: ClientId[] = CLIENTS.filter(\n (c) => c !== \"claude-code-cli\",\n);\n\nfunction normalizeClientId(raw: string | undefined): ClientId | null {\n const value = (raw ?? \"\").toLowerCase();\n if (\n value === \"claude\" ||\n value === \"claude-code-desktop\" ||\n value === \"claude-code-cli\"\n ) {\n return \"claude-code\";\n }\n if (value === \"open-code\") return \"opencode\";\n if (value === \"copilot\" || value === \"vscode\" || value === \"vs-code\") {\n return \"github-copilot\";\n }\n return (CLIENTS as string[]).includes(value) ? (value as ClientId) : null;\n}\n\nfunction installForClient(\n client: ClientId,\n inputs: ServerEntryInputs,\n cwd: string,\n scope: string | undefined,\n): string {\n const name = inputs.serverName;\n const file = configPathFor(client, cwd, scope);\n if (client === \"codex\") {\n writeCodexBlock(file, name, buildCodexBlock(name, inputs));\n } else {\n writeJsonMcpEntryForClient(\n client,\n file,\n name,\n buildJsonServerEntry(client, inputs),\n );\n }\n return file;\n}\n\nfunction uninstallForClient(\n client: ClientId,\n appId: string,\n cwd: string,\n scope: string | undefined,\n): { file: string; removed: boolean } {\n const name = serverNameFor(appId);\n const file = configPathFor(client, cwd, scope);\n if (client === \"codex\") {\n const had = codexHasBlock(file, name);\n if (had) writeCodexBlock(file, name, null);\n return { file, removed: had };\n }\n const had = hasJsonMcpEntryForClient(client, file, name);\n if (had) writeJsonMcpEntryForClient(client, file, name, null);\n return { file, removed: had };\n}\n\nfunction clientHasEntry(client: ClientId, appId: string, cwd: string): boolean {\n const name = serverNameFor(appId);\n if (client === \"codex\") return codexHasBlock(codexConfigPath(), name);\n if (client === \"cowork\") {\n return hasJsonMcpEntryForClient(\n client,\n configPathFor(client, cwd, undefined),\n name,\n );\n }\n return (\n hasJsonMcpEntryForClient(\n client,\n configPathFor(client, cwd, \"project\"),\n name,\n ) ||\n hasJsonMcpEntryForClient(client, configPathFor(client, cwd, \"user\"), name)\n );\n}\n\n// ---------------------------------------------------------------------------\n// Subcommands\n// ---------------------------------------------------------------------------\n\nasync function cmdServe(p: ParsedArgs): Promise<void> {\n await runMCPStdio({\n appId: p.app,\n port: p.port,\n standalone: p.standalone,\n });\n}\n\nasync function cmdInstall(p: ParsedArgs): Promise<void> {\n const client = normalizeClientId(p.client);\n if (!client) {\n logErr(\n `Usage: npx @agent-native/core@latest mcp install --client ${SELECTABLE_CLIENTS.join(\"|\")} ` +\n `[--app <id>] [--scope user|project]`,\n );\n process.exit(1);\n }\n const cwd = process.cwd();\n\n // Resolve which app this entry targets (default = workspace default app).\n let appId = p.app;\n if (!appId) {\n try {\n const resolved = await resolveLocalAppOrigin({ cwd });\n appId = resolved.appId;\n } catch {\n appId = \"app\";\n }\n }\n const serverName = serverNameFor(appId);\n\n const hostedUrl = detectHostedUrl(cwd);\n const ownerEmail = process.env.AGENT_NATIVE_OWNER_EMAIL;\n\n let token: string | undefined;\n if (hostedUrl) {\n token = await mintHostedJwt(cwd);\n logOut(`Detected hosted deployment: ${hostedUrl}`);\n } else {\n const t = ensureLocalToken(cwd, false);\n token = t.token;\n logOut(\n t.created\n ? `Provisioned ACCESS_TOKEN in ${t.file}`\n : `Reusing existing ACCESS_TOKEN from ${t.file}`,\n );\n }\n\n const inputs: ServerEntryInputs = {\n serverName,\n appId: appId!,\n token,\n ownerEmail,\n hostedUrl,\n standalone: p.standalone,\n };\n\n const file = installForClient(client, inputs, cwd, p.scope);\n logOut(`Installed \"${serverName}\" for ${client} → ${file}`);\n logOut(\n hostedUrl\n ? ` Mode: http (${hostedUrl})`\n : ` Mode: stdio (npx @agent-native/core@latest mcp serve --app ${appId}${\n p.standalone ? \" --standalone\" : \"\"\n })`,\n );\n logOut(` Restart ${client} to pick up the new MCP server.`);\n}\n\nfunction cmdUninstall(p: ParsedArgs): void {\n const client = normalizeClientId(p.client);\n if (!client) {\n logErr(\n `Usage: npx @agent-native/core@latest mcp uninstall --client ${SELECTABLE_CLIENTS.join(\"|\")} ` +\n `[--app <id>]`,\n );\n process.exit(1);\n }\n const cwd = process.cwd();\n const appId = p.app ?? \"app\";\n const { file, removed } = uninstallForClient(client, appId, cwd, p.scope);\n logOut(\n removed\n ? `Removed \"${serverNameFor(appId)}\" from ${client} → ${file}`\n : `No \"${serverNameFor(appId)}\" entry found for ${client} (${file}) — nothing to do.`,\n );\n}\n\nasync function cmdStatus(): Promise<void> {\n const cwd = process.cwd();\n let appId = \"app\";\n let origin = \"(app not running)\";\n let port: number | undefined;\n try {\n const resolved = await resolveLocalAppOrigin({ cwd });\n appId = resolved.appId;\n origin = resolved.origin;\n const ws = await resolveWorkspace(cwd);\n port = ws.apps.find((a) => a.id === appId)?.port;\n } catch (err: any) {\n logErr(` Could not resolve app: ${err?.message ?? err}`);\n }\n\n const hostedUrl = detectHostedUrl(cwd);\n const baseDir = envBaseDir(cwd);\n const envContent =\n readEnvFile(path.join(baseDir, \".env.local\")) +\n \"\\n\" +\n readEnvFile(path.join(baseDir, \".env\"));\n const hasToken = !!getEnvValue(envContent, \"ACCESS_TOKEN\");\n const hasA2A =\n !!process.env.A2A_SECRET || !!getEnvValue(envContent, \"A2A_SECRET\");\n\n logOut(`Agent-Native MCP status`);\n logOut(` App: ${appId}`);\n logOut(\n hostedUrl\n ? ` MCP URL: ${hostedUrl} (hosted)`\n : ` MCP URL: ${origin}/_agent-native/mcp${\n port ? ` (port ${port})` : \"\"\n }`,\n );\n logOut(` ACCESS_TOKEN: ${hasToken ? \"set\" : \"not set\"} (.env)`);\n logOut(` A2A_SECRET: ${hasA2A ? \"set\" : \"not set\"}`);\n logOut(` Clients:`);\n for (const client of SELECTABLE_CLIENTS) {\n const present = clientHasEntry(client, appId, cwd);\n logOut(` ${client.padEnd(18)} ${present ? \"configured\" : \"—\"}`);\n }\n}\n\nfunction cmdToken(p: ParsedArgs): void {\n const cwd = process.cwd();\n const t = ensureLocalToken(cwd, p.rotate);\n logOut(\n p.rotate\n ? `Rotated ACCESS_TOKEN in ${t.file}`\n : t.created\n ? `Provisioned ACCESS_TOKEN in ${t.file}`\n : `ACCESS_TOKEN (${t.file}):`,\n );\n logOut(t.token);\n if (p.rotate) {\n logOut(\n ` Re-run \\`npx @agent-native/core@latest mcp install --client <c>\\` so client configs ` +\n `pick up the new token.`,\n );\n }\n}\n\nconst HELP = `npx @agent-native/core@latest mcp — connect external coding agents over MCP\n\nUsage:\n npx @agent-native/core@latest mcp serve [--app <id>] [--port <n>] [--standalone]\n Run the MCP stdio transport (what client configs spawn).\n Default: proxy to the running local app; --standalone builds from disk.\n\n npx @agent-native/core@latest mcp screen-memory [--dir <path>]\n Run the local Clips Screen Memory stdio server.\n Defaults to the Clips app-data screen-memory folder.\n\n npx @agent-native/core@latest mcp install --client <c> [--app <id>] [--scope user|project]\n Provision a token and write the client's MCP config (idempotent).\n Clients: claude-code, codex, cowork, cursor, opencode, github-copilot\n\n npx @agent-native/core@latest mcp uninstall --client <c> [--app <id>]\n Remove the named MCP entry from a client's config (idempotent).\n\n npx @agent-native/core@latest mcp status\n Show resolved MCP URL/port, token state, and per-client entries.\n\n npx @agent-native/core@latest mcp token [--rotate]\n Print (or rotate) the local ACCESS_TOKEN in the workspace .env.`;\n\nexport async function runMcp(args: string[]): Promise<void> {\n const p = parseArgs(args);\n const sub = p._[0];\n\n switch (sub) {\n case \"serve\":\n await cmdServe(p);\n return;\n case \"screen-memory\":\n await runScreenMemoryMCPStdio({ storeDir: p.screenMemoryDir });\n return;\n case \"install\":\n await cmdInstall(p);\n return;\n case \"uninstall\":\n cmdUninstall(p);\n return;\n case \"status\":\n await cmdStatus();\n return;\n case \"token\":\n cmdToken(p);\n return;\n case undefined:\n case \"--help\":\n case \"-h\":\n case \"help\":\n logOut(HELP);\n return;\n default:\n logErr(`Unknown mcp subcommand: ${sub}`);\n logOut(HELP);\n process.exit(1);\n }\n}\n"]}
1
+ {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/cli/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,OAAO,EAEP,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,eAAe,EAC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CLI, Claude Cowork, Codex, Cursor, OpenCode, GitHub Copilot /\n * VS Code) to this agent-native app/workspace over MCP.\n *\n * serve Run the MCP stdio transport (this is what client configs spawn).\n * install Provision a token + write the client's MCP config idempotently.\n * uninstall Remove the named entry from a client's MCP config.\n * status Print resolved MCP URL/port, token state, and per-client entries.\n * token Print or rotate the local ACCESS_TOKEN in the workspace .env.\n *\n * Node-only CLI module. Hand-rolled `.env` upsert + minimal TOML block merge\n * keep this dependency-free (no new npm deps).\n */\n\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { MCP_PUBLIC_ROUTE_PREFIX } from \"../mcp/route-paths.js\";\nimport { runScreenMemoryMCPStdio } from \"../mcp/screen-memory-stdio.js\";\nimport { runMCPStdio } from \"../mcp/stdio.js\";\nimport {\n findWorkspaceRoot,\n resolveLocalAppOrigin,\n resolveWorkspace,\n} from \"../mcp/workspace-resolve.js\";\nimport {\n CLIENTS,\n type ClientId,\n buildCodexHttpBlock,\n buildCodexLocalBlock,\n buildHttpMcpEntryForClient,\n buildLocalMcpEntryForClient,\n codexConfigPath,\n codexHasBlock,\n configPathFor as clientConfigPathFor,\n hasJsonMcpEntryForClient,\n writeCodexBlock,\n writeFileAtomic,\n writeJsonMcpEntryForClient,\n} from \"./mcp-config-writers.js\";\n\nconst SERVER_NAME_PREFIX = \"agent-native\";\n\ninterface ParsedArgs {\n _: string[];\n client?: string;\n app?: string;\n port?: number;\n screenMemoryDir?: string;\n scope?: string;\n standalone: boolean;\n rotate: boolean;\n}\n\nfunction parseArgs(argv: string[]): ParsedArgs {\n const out: ParsedArgs = { _: [], standalone: false, rotate: false };\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i];\n const eat = (flag: string): string | undefined => {\n if (a === flag) return argv[++i];\n if (a.startsWith(`${flag}=`)) return a.slice(flag.length + 1);\n return undefined;\n };\n let v: string | undefined;\n if ((v = eat(\"--client\")) !== undefined) out.client = v;\n else if ((v = eat(\"--app\")) !== undefined) out.app = v;\n else if ((v = eat(\"--port\")) !== undefined) out.port = Number(v);\n else if ((v = eat(\"--dir\")) !== undefined) out.screenMemoryDir = v;\n else if ((v = eat(\"--scope\")) !== undefined) out.scope = v;\n else if (a === \"--standalone\") out.standalone = true;\n else if (a === \"--rotate\") out.rotate = true;\n else if (!a.startsWith(\"-\")) out._.push(a);\n }\n return out;\n}\n\nfunction logErr(msg: string): void {\n process.stderr.write(`${msg}\\n`);\n}\nfunction logOut(msg: string): void {\n process.stdout.write(`${msg}\\n`);\n}\n\n// ---------------------------------------------------------------------------\n// .env token provisioning (local dev) — hand-rolled idempotent upsert\n// ---------------------------------------------------------------------------\n\n/** Workspace root (or cwd for a standalone app) — where .env lives. */\nfunction envBaseDir(cwd = process.cwd()): string {\n return findWorkspaceRoot(cwd) ?? path.resolve(cwd);\n}\n\n/** Prefer .env.local, else .env. Returns the path we should write to. */\nfunction envFilePath(baseDir: string): string {\n const local = path.join(baseDir, \".env.local\");\n if (fs.existsSync(local)) return local;\n return path.join(baseDir, \".env\");\n}\n\nfunction readEnvFile(file: string): string {\n try {\n return fs.readFileSync(file, \"utf-8\");\n } catch {\n return \"\";\n }\n}\n\n/** Read a single key from a dotenv-format string (last assignment wins). */\nfunction getEnvValue(content: string, key: string): string | undefined {\n let found: string | undefined;\n for (const line of content.split(/\\r?\\n/)) {\n const m = line.match(/^\\s*([A-Z0-9_]+)\\s*=\\s*(.*)\\s*$/i);\n if (m && m[1] === key) {\n found = m[2].replace(/^[\"']|[\"']$/g, \"\");\n }\n }\n return found;\n}\n\n/**\n * Idempotently set `key=value` in the dotenv file. If the key already exists\n * we leave it untouched unless `force` is set (used by `token --rotate`).\n * Never clobbers an existing token implicitly.\n */\nfunction upsertEnv(\n file: string,\n key: string,\n value: string,\n force = false,\n): { changed: boolean; value: string } {\n const content = readEnvFile(file);\n const existing = getEnvValue(content, key);\n if (existing && !force) return { changed: false, value: existing };\n\n const line = `${key}=${value}`;\n let next: string;\n if (new RegExp(`^\\\\s*${key}\\\\s*=`, \"m\").test(content)) {\n next = content.replace(new RegExp(`^\\\\s*${key}\\\\s*=.*$`, \"m\"), line);\n } else {\n next =\n content.length === 0\n ? `${line}\\n`\n : `${content.replace(/\\n*$/, \"\")}\\n${line}\\n`;\n }\n writeFileAtomic(file, next);\n return { changed: true, value };\n}\n\nfunction generateToken(): string {\n return crypto.randomBytes(24).toString(\"base64url\");\n}\n\n/**\n * Ensure a local ACCESS_TOKEN exists in the workspace .env and return it.\n * Existing tokens are reused (never clobbered). Set `rotate` to replace it.\n */\nfunction ensureLocalToken(\n cwd: string,\n rotate = false,\n): { token: string; file: string; created: boolean } {\n const baseDir = envBaseDir(cwd);\n const file = envFilePath(baseDir);\n const content = readEnvFile(file);\n const existing = getEnvValue(content, \"ACCESS_TOKEN\");\n if (existing && !rotate) {\n return { token: existing, file, created: false };\n }\n const token = generateToken();\n upsertEnv(file, \"ACCESS_TOKEN\", token, true);\n return { token, file, created: true };\n}\n\n// ---------------------------------------------------------------------------\n// Hosted vs local detection\n// ---------------------------------------------------------------------------\n\n/**\n * Detect a hosted deployment URL. When the workspace .env points at a hosted\n * origin (APP_URL / BETTER_AUTH_URL with a non-localhost host) we write an\n * `http` client entry pointing at `<origin>/mcp` with a JWT\n * bearer instead of a stdio entry.\n */\nfunction detectHostedUrl(cwd: string): string | undefined {\n const baseDir = envBaseDir(cwd);\n const content =\n readEnvFile(path.join(baseDir, \".env.local\")) +\n \"\\n\" +\n readEnvFile(path.join(baseDir, \".env\"));\n for (const key of [\"AGENT_NATIVE_MCP_URL\", \"APP_URL\", \"BETTER_AUTH_URL\"]) {\n const v = getEnvValue(content, key);\n if (!v) continue;\n try {\n const u = new URL(v);\n if (!/^(localhost|127\\.0\\.0\\.1|\\[::1\\])$/.test(u.hostname)) {\n const appPath = u.pathname.replace(/\\/+$/, \"\");\n return `${u.origin}${appPath === \"/\" ? \"\" : appPath}${MCP_PUBLIC_ROUTE_PREFIX}`;\n }\n } catch {\n // not a URL — skip\n }\n }\n return undefined;\n}\n\nasync function mintHostedJwt(cwd: string): Promise<string | undefined> {\n // Reuse the existing A2A signer — do not reinvent JWT minting.\n const owner =\n process.env.AGENT_NATIVE_OWNER_EMAIL ||\n process.env.OWNER_EMAIL ||\n \"owner@localhost\";\n let fileA2ASecret: string | undefined;\n if (!process.env.A2A_SECRET) {\n const baseDir = envBaseDir(cwd);\n const content =\n readEnvFile(path.join(baseDir, \".env.local\")) +\n \"\\n\" +\n readEnvFile(path.join(baseDir, \".env\"));\n fileA2ASecret = getEnvValue(content, \"A2A_SECRET\");\n }\n try {\n const { signA2AToken } = await import(\"../a2a/client.js\");\n return await signA2AToken(\n owner,\n undefined,\n process.env.A2A_SECRET || fileA2ASecret,\n {\n preferGlobalSecret: true,\n expiresIn: \"30d\",\n },\n );\n } catch (err: any) {\n logErr(\n ` Could not mint a hosted JWT (${err?.message ?? err}). ` +\n `Set A2A_SECRET in your workspace .env, or use the local stdio entry.`,\n );\n return undefined;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Client config entries\n// ---------------------------------------------------------------------------\n\ninterface ServerEntryInputs {\n serverName: string;\n appId: string;\n token?: string;\n ownerEmail?: string;\n hostedUrl?: string;\n standalone: boolean;\n}\n\nfunction mcpServeArgs(i: ServerEntryInputs): string[] {\n const args = [\"mcp\", \"serve\"];\n if (i.appId) args.push(\"--app\", i.appId);\n if (i.standalone) args.push(\"--standalone\");\n return args;\n}\n\nfunction mcpServeEnv(i: ServerEntryInputs): Record<string, string> {\n const env: Record<string, string> = {};\n if (i.token) env.ACCESS_TOKEN = i.token;\n if (i.ownerEmail) env.AGENT_NATIVE_OWNER_EMAIL = i.ownerEmail;\n return env;\n}\n\nfunction buildJsonServerEntry(\n client: ClientId,\n i: ServerEntryInputs,\n): Record<string, unknown> {\n if (i.hostedUrl) {\n return buildHttpMcpEntryForClient(client, i.hostedUrl, i.token);\n }\n return buildLocalMcpEntryForClient(client, mcpServeArgs(i), mcpServeEnv(i));\n}\n\nfunction buildCodexBlock(name: string, i: ServerEntryInputs): string {\n if (i.hostedUrl) {\n return buildCodexHttpBlock(name, i.hostedUrl, i.token);\n }\n return buildCodexLocalBlock(name, mcpServeArgs(i), mcpServeEnv(i));\n}\n\n// ---------------------------------------------------------------------------\n// Per-client install/uninstall/status\n// ---------------------------------------------------------------------------\n\nfunction configPathFor(\n client: ClientId,\n cwd: string,\n scope: string | undefined,\n): string {\n return clientConfigPathFor(client, envBaseDir(cwd), scope);\n}\n\nfunction serverNameFor(appId: string): string {\n return `${SERVER_NAME_PREFIX}-${appId}`;\n}\n\n// Clients advertised in usage/help and listed by status. Excludes the legacy\n// `claude-code-cli` alias so only a single \"Claude Code\" appears (it is still\n// accepted via --client and collapses to claude-code).\nconst SELECTABLE_CLIENTS: ClientId[] = CLIENTS.filter(\n (c) => c !== \"claude-code-cli\",\n);\n\nfunction normalizeClientId(raw: string | undefined): ClientId | null {\n const value = (raw ?? \"\").toLowerCase();\n if (\n value === \"claude\" ||\n value === \"claude-code-desktop\" ||\n value === \"claude-code-cli\"\n ) {\n return \"claude-code\";\n }\n if (value === \"open-code\") return \"opencode\";\n if (value === \"copilot\" || value === \"vscode\" || value === \"vs-code\") {\n return \"github-copilot\";\n }\n return (CLIENTS as string[]).includes(value) ? (value as ClientId) : null;\n}\n\nfunction installForClient(\n client: ClientId,\n inputs: ServerEntryInputs,\n cwd: string,\n scope: string | undefined,\n): string {\n const name = inputs.serverName;\n const file = configPathFor(client, cwd, scope);\n if (client === \"codex\") {\n writeCodexBlock(file, name, buildCodexBlock(name, inputs));\n } else {\n writeJsonMcpEntryForClient(\n client,\n file,\n name,\n buildJsonServerEntry(client, inputs),\n );\n }\n return file;\n}\n\nfunction uninstallForClient(\n client: ClientId,\n appId: string,\n cwd: string,\n scope: string | undefined,\n): { file: string; removed: boolean } {\n const name = serverNameFor(appId);\n const file = configPathFor(client, cwd, scope);\n if (client === \"codex\") {\n const had = codexHasBlock(file, name);\n if (had) writeCodexBlock(file, name, null);\n return { file, removed: had };\n }\n const had = hasJsonMcpEntryForClient(client, file, name);\n if (had) writeJsonMcpEntryForClient(client, file, name, null);\n return { file, removed: had };\n}\n\nfunction clientHasEntry(client: ClientId, appId: string, cwd: string): boolean {\n const name = serverNameFor(appId);\n if (client === \"codex\") return codexHasBlock(codexConfigPath(), name);\n if (client === \"cowork\") {\n return hasJsonMcpEntryForClient(\n client,\n configPathFor(client, cwd, undefined),\n name,\n );\n }\n return (\n hasJsonMcpEntryForClient(\n client,\n configPathFor(client, cwd, \"project\"),\n name,\n ) ||\n hasJsonMcpEntryForClient(client, configPathFor(client, cwd, \"user\"), name)\n );\n}\n\n// ---------------------------------------------------------------------------\n// Subcommands\n// ---------------------------------------------------------------------------\n\nasync function cmdServe(p: ParsedArgs): Promise<void> {\n await runMCPStdio({\n appId: p.app,\n port: p.port,\n standalone: p.standalone,\n });\n}\n\nasync function cmdInstall(p: ParsedArgs): Promise<void> {\n const client = normalizeClientId(p.client);\n if (!client) {\n logErr(\n `Usage: npx @agent-native/core@latest mcp install --client ${SELECTABLE_CLIENTS.join(\"|\")} ` +\n `[--app <id>] [--scope user|project]`,\n );\n process.exit(1);\n }\n const cwd = process.cwd();\n\n // Resolve which app this entry targets (default = workspace default app).\n let appId = p.app;\n if (!appId) {\n try {\n const resolved = await resolveLocalAppOrigin({ cwd });\n appId = resolved.appId;\n } catch {\n appId = \"app\";\n }\n }\n const serverName = serverNameFor(appId);\n\n const hostedUrl = detectHostedUrl(cwd);\n const ownerEmail = process.env.AGENT_NATIVE_OWNER_EMAIL;\n\n let token: string | undefined;\n if (hostedUrl) {\n token = await mintHostedJwt(cwd);\n logOut(`Detected hosted deployment: ${hostedUrl}`);\n } else {\n const t = ensureLocalToken(cwd, false);\n token = t.token;\n logOut(\n t.created\n ? `Provisioned ACCESS_TOKEN in ${t.file}`\n : `Reusing existing ACCESS_TOKEN from ${t.file}`,\n );\n }\n\n const inputs: ServerEntryInputs = {\n serverName,\n appId: appId!,\n token,\n ownerEmail,\n hostedUrl,\n standalone: p.standalone,\n };\n\n const file = installForClient(client, inputs, cwd, p.scope);\n logOut(`Installed \"${serverName}\" for ${client} → ${file}`);\n logOut(\n hostedUrl\n ? ` Mode: http (${hostedUrl})`\n : ` Mode: stdio (npx @agent-native/core@latest mcp serve --app ${appId}${\n p.standalone ? \" --standalone\" : \"\"\n })`,\n );\n logOut(` Restart ${client} to pick up the new MCP server.`);\n}\n\nfunction cmdUninstall(p: ParsedArgs): void {\n const client = normalizeClientId(p.client);\n if (!client) {\n logErr(\n `Usage: npx @agent-native/core@latest mcp uninstall --client ${SELECTABLE_CLIENTS.join(\"|\")} ` +\n `[--app <id>]`,\n );\n process.exit(1);\n }\n const cwd = process.cwd();\n const appId = p.app ?? \"app\";\n const { file, removed } = uninstallForClient(client, appId, cwd, p.scope);\n logOut(\n removed\n ? `Removed \"${serverNameFor(appId)}\" from ${client} → ${file}`\n : `No \"${serverNameFor(appId)}\" entry found for ${client} (${file}) — nothing to do.`,\n );\n}\n\nasync function cmdStatus(): Promise<void> {\n const cwd = process.cwd();\n let appId = \"app\";\n let origin = \"(app not running)\";\n let port: number | undefined;\n try {\n const resolved = await resolveLocalAppOrigin({ cwd });\n appId = resolved.appId;\n origin = resolved.origin;\n const ws = await resolveWorkspace(cwd);\n port = ws.apps.find((a) => a.id === appId)?.port;\n } catch (err: any) {\n logErr(` Could not resolve app: ${err?.message ?? err}`);\n }\n\n const hostedUrl = detectHostedUrl(cwd);\n const baseDir = envBaseDir(cwd);\n const envContent =\n readEnvFile(path.join(baseDir, \".env.local\")) +\n \"\\n\" +\n readEnvFile(path.join(baseDir, \".env\"));\n const hasToken = !!getEnvValue(envContent, \"ACCESS_TOKEN\");\n const hasA2A =\n !!process.env.A2A_SECRET || !!getEnvValue(envContent, \"A2A_SECRET\");\n\n logOut(`Agent-Native MCP status`);\n logOut(` App: ${appId}`);\n logOut(\n hostedUrl\n ? ` MCP URL: ${hostedUrl} (hosted)`\n : ` MCP URL: ${origin}/mcp${port ? ` (port ${port})` : \"\"}`,\n );\n logOut(` ACCESS_TOKEN: ${hasToken ? \"set\" : \"not set\"} (.env)`);\n logOut(` A2A_SECRET: ${hasA2A ? \"set\" : \"not set\"}`);\n logOut(` Clients:`);\n for (const client of SELECTABLE_CLIENTS) {\n const present = clientHasEntry(client, appId, cwd);\n logOut(` ${client.padEnd(18)} ${present ? \"configured\" : \"—\"}`);\n }\n}\n\nfunction cmdToken(p: ParsedArgs): void {\n const cwd = process.cwd();\n const t = ensureLocalToken(cwd, p.rotate);\n logOut(\n p.rotate\n ? `Rotated ACCESS_TOKEN in ${t.file}`\n : t.created\n ? `Provisioned ACCESS_TOKEN in ${t.file}`\n : `ACCESS_TOKEN (${t.file}):`,\n );\n logOut(t.token);\n if (p.rotate) {\n logOut(\n ` Re-run \\`npx @agent-native/core@latest mcp install --client <c>\\` so client configs ` +\n `pick up the new token.`,\n );\n }\n}\n\nconst HELP = `npx @agent-native/core@latest mcp — connect external coding agents over MCP\n\nUsage:\n npx @agent-native/core@latest mcp serve [--app <id>] [--port <n>] [--standalone]\n Run the MCP stdio transport (what client configs spawn).\n Default: proxy to the running local app; --standalone builds from disk.\n\n npx @agent-native/core@latest mcp screen-memory [--dir <path>]\n Run the local Clips Screen Memory stdio server.\n Defaults to the Clips app-data screen-memory folder.\n\n npx @agent-native/core@latest mcp install --client <c> [--app <id>] [--scope user|project]\n Provision a token and write the client's MCP config (idempotent).\n Clients: claude-code, codex, cowork, cursor, opencode, github-copilot\n\n npx @agent-native/core@latest mcp uninstall --client <c> [--app <id>]\n Remove the named MCP entry from a client's config (idempotent).\n\n npx @agent-native/core@latest mcp status\n Show resolved MCP URL/port, token state, and per-client entries.\n\n npx @agent-native/core@latest mcp token [--rotate]\n Print (or rotate) the local ACCESS_TOKEN in the workspace .env.`;\n\nexport async function runMcp(args: string[]): Promise<void> {\n const p = parseArgs(args);\n const sub = p._[0];\n\n switch (sub) {\n case \"serve\":\n await cmdServe(p);\n return;\n case \"screen-memory\":\n await runScreenMemoryMCPStdio({ storeDir: p.screenMemoryDir });\n return;\n case \"install\":\n await cmdInstall(p);\n return;\n case \"uninstall\":\n cmdUninstall(p);\n return;\n case \"status\":\n await cmdStatus();\n return;\n case \"token\":\n cmdToken(p);\n return;\n case undefined:\n case \"--help\":\n case \"-h\":\n case \"help\":\n logOut(HELP);\n return;\n default:\n logErr(`Unknown mcp subcommand: ${sub}`);\n logOut(HELP);\n process.exit(1);\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const ASSETS_SKILL_MD = "---\nname: assets\ndescription: >-\n Use Assets for image or video generation requests, brand-safe media,\n human picker UI, search/list/export actions, and cross-app asset selection.\n Prefer this over generic image tools when installed.\nmetadata:\n visibility: exported\n---\n\n# Assets\n\nUse the Assets app when a workflow needs reusable brand media, a human picker,\nor generated image/video assets that another app can reference by ID and URL.\nWhen this skill is available, route plain image-generation requests here instead\nof using a generic image generator.\n\n## Choose The Path\n\n- Use `open-asset-picker` when a person should browse, search, generate, and\n select an asset in UI. Pass `mediaType: \"image\"` by default, or\n `mediaType: \"video\"` for video libraries. When the user asks to create a\n specific image and choose the best option, pass `prompt`,\n `autoGenerate: true`, and `count: 3` so the picker opens with candidates\n to preview and select.\n- Use unattended actions when the agent already knows what to do:\n `search-assets`, `list-assets`, `generate-image`,\n `generate-image-batch`, `generate-video`,\n `refresh-generation-run`, and `export-asset`.\n- Use browser/deep-link fallback when the host cannot render MCP Apps inline.\n Surface the returned picker link. If it opens in a normal browser tab, have\n the user select an asset there and paste back the copied handoff summary.\n Treat Codex, Claude Code, and Claude Desktop Code as link-out hosts; do not\n promise inline MCP App rendering there.\n If the skill instructions are available but the MCP tool namespace has not\n appeared yet, use the Assets browser fallback URL shape instead of switching\n to a generic generator:\n `https://assets.agent-native.com/library?mediaType=image&prompt=...&autoGenerate=1&count=3`.\n When reporting the final selected image in Codex or Claude Code, include the\n asset link and, if an inline preview is important, download the selected\n `previewUrl`/`downloadUrl` to a local temp image and embed that absolute\n local path. Remote CDN markdown images can fail to render in code-editor chat\n surfaces.\n\n## Image And Video Workflows\n\n1. Pick or match the library with `list-libraries` or `match-library`.\n2. For images, call `generate-image` or `generate-image-batch`. Image\n actions are synchronous: one batch call should return the finished image\n candidates, so do not poll or regenerate unless a returned slot failed.\n3. For videos, call `generate-video` and poll `refresh-generation-run`\n until the run completes.\n4. Preserve returned `assetId`, `runId`, `previewUrl`, `downloadUrl`,\n media type, and dimensions so the caller can attach or embed the result.\n\n## Cross-App Use\n\n- Hosted default: connect `https://assets.agent-native.com/_agent-native/mcp`.\n Do not put shared secrets in skill files.\n- For CLI/code-editor clients, keep any `npx @agent-native/core@latest connect` command\n running until browser authorization finishes. Stopping it early can leave the\n browser approved but the local MCP config unwritten. Restart or reload the\n agent client after installing or connecting if Assets tools do not appear in\n the live session.\n- Local customization: use `npx @agent-native/core@latest app-skill launch --local` from an\n Assets app-skill manifest, or pass `--into <path>` for editable source.\n- Do not call image/video providers directly from another app. Assets owns\n generation, picker UI, search/list/export, and asset context.\n- If an Assets tool call returns `Session terminated`, `needs auth`, or\n another connector/session error, do not keep retrying the tool. Stop and give\n the user the reconnect step: in Claude Code run `/mcp` and choose\n Authenticate/Reconnect for the Assets connector; from any terminal run\n `npx -y @agent-native/core@latest reconnect https://assets.agent-native.com` \u2014 this\n re-authenticates WITHOUT reinstalling. Never reinstall from scratch just to fix\n auth. Continue once the connector is available.\n- Do not hand-roll MCP HTTP requests with curl from the agent session. Use the\n host-exposed Assets tools after restart/reload, or use the returned\n browser/deep-link fallback.\n- If a batch image generation request times out in browser fallback, retry with\n `count: 1` only after telling the user the multi-candidate request timed out.\n- If you inspect local MCP config, redact `Authorization`, `http_headers`,\n and token values. Never paste bearer tokens into chat or logs.\n";
1
+ export declare const ASSETS_SKILL_MD = "---\nname: assets\ndescription: >-\n Use Assets for image or video generation requests, brand-safe media,\n human picker UI, search/list/export actions, and cross-app asset selection.\n Prefer this over generic image tools when installed.\nmetadata:\n visibility: exported\n---\n\n# Assets\n\nUse the Assets app when a workflow needs reusable brand media, a human picker,\nor generated image/video assets that another app can reference by ID and URL.\nWhen this skill is available, route plain image-generation requests here instead\nof using a generic image generator.\n\n## Choose The Path\n\n- Use `open-asset-picker` when a person should browse, search, generate, and\n select an asset in UI. Pass `mediaType: \"image\"` by default, or\n `mediaType: \"video\"` for video libraries. When the user asks to create a\n specific image and choose the best option, pass `prompt`,\n `autoGenerate: true`, and `count: 3` so the picker opens with candidates\n to preview and select.\n- Use unattended actions when the agent already knows what to do:\n `search-assets`, `list-assets`, `generate-image`,\n `generate-image-batch`, `generate-video`,\n `refresh-generation-run`, and `export-asset`.\n- Use browser/deep-link fallback when the host cannot render MCP Apps inline.\n Surface the returned picker link. If it opens in a normal browser tab, have\n the user select an asset there and paste back the copied handoff summary.\n Treat Codex, Claude Code, and Claude Desktop Code as link-out hosts; do not\n promise inline MCP App rendering there.\n If the skill instructions are available but the MCP tool namespace has not\n appeared yet, use the Assets browser fallback URL shape instead of switching\n to a generic generator:\n `https://assets.agent-native.com/library?mediaType=image&prompt=...&autoGenerate=1&count=3`.\n When reporting the final selected image in Codex or Claude Code, include the\n asset link and, if an inline preview is important, download the selected\n `previewUrl`/`downloadUrl` to a local temp image and embed that absolute\n local path. Remote CDN markdown images can fail to render in code-editor chat\n surfaces.\n\n## Image And Video Workflows\n\n1. Pick or match the library with `list-libraries` or `match-library`.\n2. For images, call `generate-image` or `generate-image-batch`. Image\n actions are synchronous: one batch call should return the finished image\n candidates, so do not poll or regenerate unless a returned slot failed.\n3. For videos, call `generate-video` and poll `refresh-generation-run`\n until the run completes.\n4. Preserve returned `assetId`, `runId`, `previewUrl`, `downloadUrl`,\n media type, and dimensions so the caller can attach or embed the result.\n\n## Cross-App Use\n\n- Hosted default: connect `https://assets.agent-native.com/mcp`.\n Do not put shared secrets in skill files.\n- For CLI/code-editor clients, keep any `npx @agent-native/core@latest connect` command\n running until browser authorization finishes. Stopping it early can leave the\n browser approved but the local MCP config unwritten. Restart or reload the\n agent client after installing or connecting if Assets tools do not appear in\n the live session.\n- Local customization: use `npx @agent-native/core@latest app-skill launch --local` from an\n Assets app-skill manifest, or pass `--into <path>` for editable source.\n- Do not call image/video providers directly from another app. Assets owns\n generation, picker UI, search/list/export, and asset context.\n- If an Assets tool call returns `Session terminated`, `needs auth`, or\n another connector/session error, do not keep retrying the tool. Stop and give\n the user the reconnect step: in Claude Code run `/mcp` and choose\n Authenticate/Reconnect for the Assets connector; from any terminal run\n `npx -y @agent-native/core@latest reconnect https://assets.agent-native.com` \u2014 this\n re-authenticates WITHOUT reinstalling. Never reinstall from scratch just to fix\n auth. Continue once the connector is available.\n- Do not hand-roll MCP HTTP requests with curl from the agent session. Use the\n host-exposed Assets tools after restart/reload, or use the returned\n browser/deep-link fallback.\n- If a batch image generation request times out in browser fallback, retry with\n `count: 1` only after telling the user the multi-candidate request timed out.\n- If you inspect local MCP config, redact `Authorization`, `http_headers`,\n and token values. Never paste bearer tokens into chat or logs.\n";
2
2
  //# sourceMappingURL=assets-skill.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assets-skill.d.ts","sourceRoot":"","sources":["../../../src/cli/skills-content/assets-skill.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,m9IAkF3B,CAAC"}
1
+ {"version":3,"file":"assets-skill.d.ts","sourceRoot":"","sources":["../../../src/cli/skills-content/assets-skill.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,q8IAkF3B,CAAC"}
@@ -55,7 +55,7 @@ of using a generic image generator.
55
55
 
56
56
  ## Cross-App Use
57
57
 
58
- - Hosted default: connect \`https://assets.agent-native.com/_agent-native/mcp\`.
58
+ - Hosted default: connect \`https://assets.agent-native.com/mcp\`.
59
59
  Do not put shared secrets in skill files.
60
60
  - For CLI/code-editor clients, keep any \`npx @agent-native/core@latest connect\` command
61
61
  running until browser authorization finishes. Stopping it early can leave the
@@ -1 +1 @@
1
- {"version":3,"file":"assets-skill.js","sourceRoot":"","sources":["../../../src/cli/skills-content/assets-skill.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkF9B,CAAC","sourcesContent":["export const ASSETS_SKILL_MD = `---\nname: assets\ndescription: >-\n Use Assets for image or video generation requests, brand-safe media,\n human picker UI, search/list/export actions, and cross-app asset selection.\n Prefer this over generic image tools when installed.\nmetadata:\n visibility: exported\n---\n\n# Assets\n\nUse the Assets app when a workflow needs reusable brand media, a human picker,\nor generated image/video assets that another app can reference by ID and URL.\nWhen this skill is available, route plain image-generation requests here instead\nof using a generic image generator.\n\n## Choose The Path\n\n- Use \\`open-asset-picker\\` when a person should browse, search, generate, and\n select an asset in UI. Pass \\`mediaType: \"image\"\\` by default, or\n \\`mediaType: \"video\"\\` for video libraries. When the user asks to create a\n specific image and choose the best option, pass \\`prompt\\`,\n \\`autoGenerate: true\\`, and \\`count: 3\\` so the picker opens with candidates\n to preview and select.\n- Use unattended actions when the agent already knows what to do:\n \\`search-assets\\`, \\`list-assets\\`, \\`generate-image\\`,\n \\`generate-image-batch\\`, \\`generate-video\\`,\n \\`refresh-generation-run\\`, and \\`export-asset\\`.\n- Use browser/deep-link fallback when the host cannot render MCP Apps inline.\n Surface the returned picker link. If it opens in a normal browser tab, have\n the user select an asset there and paste back the copied handoff summary.\n Treat Codex, Claude Code, and Claude Desktop Code as link-out hosts; do not\n promise inline MCP App rendering there.\n If the skill instructions are available but the MCP tool namespace has not\n appeared yet, use the Assets browser fallback URL shape instead of switching\n to a generic generator:\n \\`https://assets.agent-native.com/library?mediaType=image&prompt=...&autoGenerate=1&count=3\\`.\n When reporting the final selected image in Codex or Claude Code, include the\n asset link and, if an inline preview is important, download the selected\n \\`previewUrl\\`/\\`downloadUrl\\` to a local temp image and embed that absolute\n local path. Remote CDN markdown images can fail to render in code-editor chat\n surfaces.\n\n## Image And Video Workflows\n\n1. Pick or match the library with \\`list-libraries\\` or \\`match-library\\`.\n2. For images, call \\`generate-image\\` or \\`generate-image-batch\\`. Image\n actions are synchronous: one batch call should return the finished image\n candidates, so do not poll or regenerate unless a returned slot failed.\n3. For videos, call \\`generate-video\\` and poll \\`refresh-generation-run\\`\n until the run completes.\n4. Preserve returned \\`assetId\\`, \\`runId\\`, \\`previewUrl\\`, \\`downloadUrl\\`,\n media type, and dimensions so the caller can attach or embed the result.\n\n## Cross-App Use\n\n- Hosted default: connect \\`https://assets.agent-native.com/_agent-native/mcp\\`.\n Do not put shared secrets in skill files.\n- For CLI/code-editor clients, keep any \\`npx @agent-native/core@latest connect\\` command\n running until browser authorization finishes. Stopping it early can leave the\n browser approved but the local MCP config unwritten. Restart or reload the\n agent client after installing or connecting if Assets tools do not appear in\n the live session.\n- Local customization: use \\`npx @agent-native/core@latest app-skill launch --local\\` from an\n Assets app-skill manifest, or pass \\`--into <path>\\` for editable source.\n- Do not call image/video providers directly from another app. Assets owns\n generation, picker UI, search/list/export, and asset context.\n- If an Assets tool call returns \\`Session terminated\\`, \\`needs auth\\`, or\n another connector/session error, do not keep retrying the tool. Stop and give\n the user the reconnect step: in Claude Code run \\`/mcp\\` and choose\n Authenticate/Reconnect for the Assets connector; from any terminal run\n \\`npx -y @agent-native/core@latest reconnect https://assets.agent-native.com\\` — this\n re-authenticates WITHOUT reinstalling. Never reinstall from scratch just to fix\n auth. Continue once the connector is available.\n- Do not hand-roll MCP HTTP requests with curl from the agent session. Use the\n host-exposed Assets tools after restart/reload, or use the returned\n browser/deep-link fallback.\n- If a batch image generation request times out in browser fallback, retry with\n \\`count: 1\\` only after telling the user the multi-candidate request timed out.\n- If you inspect local MCP config, redact \\`Authorization\\`, \\`http_headers\\`,\n and token values. Never paste bearer tokens into chat or logs.\n`;\n"]}
1
+ {"version":3,"file":"assets-skill.js","sourceRoot":"","sources":["../../../src/cli/skills-content/assets-skill.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkF9B,CAAC","sourcesContent":["export const ASSETS_SKILL_MD = `---\nname: assets\ndescription: >-\n Use Assets for image or video generation requests, brand-safe media,\n human picker UI, search/list/export actions, and cross-app asset selection.\n Prefer this over generic image tools when installed.\nmetadata:\n visibility: exported\n---\n\n# Assets\n\nUse the Assets app when a workflow needs reusable brand media, a human picker,\nor generated image/video assets that another app can reference by ID and URL.\nWhen this skill is available, route plain image-generation requests here instead\nof using a generic image generator.\n\n## Choose The Path\n\n- Use \\`open-asset-picker\\` when a person should browse, search, generate, and\n select an asset in UI. Pass \\`mediaType: \"image\"\\` by default, or\n \\`mediaType: \"video\"\\` for video libraries. When the user asks to create a\n specific image and choose the best option, pass \\`prompt\\`,\n \\`autoGenerate: true\\`, and \\`count: 3\\` so the picker opens with candidates\n to preview and select.\n- Use unattended actions when the agent already knows what to do:\n \\`search-assets\\`, \\`list-assets\\`, \\`generate-image\\`,\n \\`generate-image-batch\\`, \\`generate-video\\`,\n \\`refresh-generation-run\\`, and \\`export-asset\\`.\n- Use browser/deep-link fallback when the host cannot render MCP Apps inline.\n Surface the returned picker link. If it opens in a normal browser tab, have\n the user select an asset there and paste back the copied handoff summary.\n Treat Codex, Claude Code, and Claude Desktop Code as link-out hosts; do not\n promise inline MCP App rendering there.\n If the skill instructions are available but the MCP tool namespace has not\n appeared yet, use the Assets browser fallback URL shape instead of switching\n to a generic generator:\n \\`https://assets.agent-native.com/library?mediaType=image&prompt=...&autoGenerate=1&count=3\\`.\n When reporting the final selected image in Codex or Claude Code, include the\n asset link and, if an inline preview is important, download the selected\n \\`previewUrl\\`/\\`downloadUrl\\` to a local temp image and embed that absolute\n local path. Remote CDN markdown images can fail to render in code-editor chat\n surfaces.\n\n## Image And Video Workflows\n\n1. Pick or match the library with \\`list-libraries\\` or \\`match-library\\`.\n2. For images, call \\`generate-image\\` or \\`generate-image-batch\\`. Image\n actions are synchronous: one batch call should return the finished image\n candidates, so do not poll or regenerate unless a returned slot failed.\n3. For videos, call \\`generate-video\\` and poll \\`refresh-generation-run\\`\n until the run completes.\n4. Preserve returned \\`assetId\\`, \\`runId\\`, \\`previewUrl\\`, \\`downloadUrl\\`,\n media type, and dimensions so the caller can attach or embed the result.\n\n## Cross-App Use\n\n- Hosted default: connect \\`https://assets.agent-native.com/mcp\\`.\n Do not put shared secrets in skill files.\n- For CLI/code-editor clients, keep any \\`npx @agent-native/core@latest connect\\` command\n running until browser authorization finishes. Stopping it early can leave the\n browser approved but the local MCP config unwritten. Restart or reload the\n agent client after installing or connecting if Assets tools do not appear in\n the live session.\n- Local customization: use \\`npx @agent-native/core@latest app-skill launch --local\\` from an\n Assets app-skill manifest, or pass \\`--into <path>\\` for editable source.\n- Do not call image/video providers directly from another app. Assets owns\n generation, picker UI, search/list/export, and asset context.\n- If an Assets tool call returns \\`Session terminated\\`, \\`needs auth\\`, or\n another connector/session error, do not keep retrying the tool. Stop and give\n the user the reconnect step: in Claude Code run \\`/mcp\\` and choose\n Authenticate/Reconnect for the Assets connector; from any terminal run\n \\`npx -y @agent-native/core@latest reconnect https://assets.agent-native.com\\` — this\n re-authenticates WITHOUT reinstalling. Never reinstall from scratch just to fix\n auth. Continue once the connector is available.\n- Do not hand-roll MCP HTTP requests with curl from the agent session. Use the\n host-exposed Assets tools after restart/reload, or use the returned\n browser/deep-link fallback.\n- If a batch image generation request times out in browser fallback, retry with\n \\`count: 1\\` only after telling the user the multi-candidate request timed out.\n- If you inspect local MCP config, redact \\`Authorization\\`, \\`http_headers\\`,\n and token values. Never paste bearer tokens into chat or logs.\n`;\n"]}
@@ -1,2 +1,2 @@
1
- export declare const DESIGN_EXPLORATION_SKILL_MD = "---\nname: design-exploration\ndescription: >-\n Use Design for UI/UX exploration, side-by-side design directions,\n interactive prototype previews, user selection, iteration, and design-to-code\n handoff through the hosted Design MCP app.\nmetadata:\n visibility: exported\n---\n\n# Design Exploration\n\nUse the Design app when a workflow needs visual UI exploration, prototype\niteration, or a human-in-the-loop choice among design directions.\n\n## Choose The Path\n\n- Use `create-design` first to create a project shell. Do not report the\n design as ready until it has renderable HTML.\n- For open-ended UX exploration, generate distinct, compact, complete HTML\n directions (2-5, three by default) and call `present-design-variants`. Each\n direction should be one representative screen or directional snapshot, not a\n full app per variant. Design saves every option as a normal screen on the\n overview board and renders an inline chat choice with one button per screen\n name. After the user picks, delete the unchosen variant screens and continue\n from the kept screen by first calling `get-design-snapshot` with that\n screen's `fileId`, then calling `edit-design` on that same `fileId` in a\n bounded single-file pass. Use `mode: \"replace-file\"` when expanding the\n representative placeholder into the full chosen direction. Do not call\n `generate-design` after a variant pick.\n- If the chat choice buttons are not available in the host, ask the user to\n tell you the screen name they prefer. The variants are already real screens\n on the board, so do not ask them to paste HTML or copy a generated handoff\n summary.\n- For direct refinements to an already chosen direction, call\n `get-design-snapshot`, edit from the current tuned HTML, and use\n `edit-design` for surgical changes or `mode: \"replace-file\"` for a bounded\n selected-file replacement. Use `generate-design` for new files only.\n- Use `export-coding-handoff` when the user wants to implement the chosen\n design in a codebase.\n\n## Exploration Defaults\n\n1. Default to three variants unless the user asks for a different count\n (`present-design-variants` accepts 2-5; three is the sweet spot).\n2. Make variants structurally and stylistically distinct, not just color swaps.\n3. Each variant must be a compact, complete standalone HTML document that\n renders without a build step.\n4. For product UI redesigns, prefer cleaner hierarchy, progressive disclosure,\n and realistic controls over decorative mockups.\n5. After `present-design-variants`, wait for the user's pick before\n generating the next version. Keep the chosen screen, delete the other\n variant screens, call `get-design-snapshot` with `fileId` for the kept\n screen, then call `edit-design` on that same `fileId` in a bounded pass.\n Use `mode: \"replace-file\"` when expanding the representative placeholder\n into the full chosen direction. Do not call `generate-design` after a\n variant pick. Stop after the first successful `edit-design` save.\n\n## Design Quality Bar\n\nGeneric \"AI slop\" comes from letting one prompt set taste, explore, and emit code\nat once \u2014 so the model returns the training-average (Inter, an indigo/violet\ngradient, a centered hero, three rounded cards). The variant flow above exists to\nseparate those jobs; use it, and hold this bar:\n\n- Before generating, name the concrete audience, the screen's primary job, and\n the visual thesis. If the brief is vague, make a reasonable choice and state\n it instead of producing a generic dashboard/landing-page default.\n- Refuse the defaults, and pair every \"don't\" with a \"do\" (banning Inter alone\n just makes you reach for Roboto). Avoid Inter/Roboto/system fonts, the\n indigo/violet slop palette (`#6366F1`/`#8B5CF6`/`#A855F7`) and purple-on-white\n gradients, and centered-hero + three-icon-card layouts; instead pick a\n distinctive font pairing, one non-default palette family with a single decisive\n accent, and an asymmetric layout with a clear focal point.\n- Make each direction distinct in structure and behavior, not just palette.\n Give every variant one memorable signature choice, then keep the surrounding\n chrome disciplined. Even your creative picks converge (Space Grotesk\n everywhere) \u2014 vary deliberately so two directions never share a fingerprint.\n- For existing products, inspect the current screen, design system, tokens, and\n component language before inventing a new direction. Treat any drift back to a\n default as a missing token to pin, and vary layout per screen so on-brand does\n not become same-in-your-colors.\n- Treat copy, data, and imagery as design material. Use realistic domain\n content and first-party/generated assets when images matter; avoid lorem\n ipsum, vague SaaS filler, and decorative placeholder boxes.\n- Build to a quiet quality floor: responsive desktop/mobile layout, visible\n keyboard focus, useful loading/empty/error states for app UI, and reduced\n motion support when custom motion is present.\n- After broad generation or refinement, inspect the rendered Design surface or\n a screenshot-capable host before calling it ready. Fix obvious hierarchy,\n overflow, contrast, broken interaction, and placeholder-content issues first.\n\n## Cross-App Use\n\n- Hosted default: connect `https://design.agent-native.com/_agent-native/mcp`.\n Do not put shared secrets in skill files.\n- For CLI/code-editor clients, keep any `npx @agent-native/core@latest connect` command\n running until browser authorization finishes. Stopping it early can leave the\n browser approved but the local MCP config unwritten. Restart or reload the\n agent client after installing or connecting if Design tools do not appear in\n the live session.\n- Dispatch can expose Design alongside other apps. Use Design for UI/UX design\n tasks, Assets for image/media selection, Slides for decks, and so on.\n- Keep the loop visual: surface the inline MCP App or the returned \"Open\n design\" link instead of pasting large HTML blobs into chat.\n- If a Design tool call returns `Session terminated`, `needs auth`, or\n another connector/session error, do not keep retrying the tool. Stop and give\n the user the reconnect step: in Claude Code run `/mcp` and choose\n Authenticate/Reconnect for the Design connector; from any terminal run\n `npx -y @agent-native/core@latest reconnect https://design.agent-native.com` \u2014 this\n re-authenticates WITHOUT reinstalling. Never reinstall from scratch just to fix\n auth. Continue once the connector is available.\n- Do not hand-roll MCP HTTP requests with curl from the agent session. Use the\n host-exposed Design tools after restart/reload, or use the returned\n browser/deep-link fallback.\n- If you inspect local MCP config, redact `Authorization`, `http_headers`,\n and token values. Never paste bearer tokens into chat or logs.\n";
1
+ export declare const DESIGN_EXPLORATION_SKILL_MD = "---\nname: design-exploration\ndescription: >-\n Use Design for UI/UX exploration, side-by-side design directions,\n interactive prototype previews, user selection, iteration, and design-to-code\n handoff through the hosted Design MCP app.\nmetadata:\n visibility: exported\n---\n\n# Design Exploration\n\nUse the Design app when a workflow needs visual UI exploration, prototype\niteration, or a human-in-the-loop choice among design directions.\n\n## Choose The Path\n\n- Use `create-design` first to create a project shell. Do not report the\n design as ready until it has renderable HTML.\n- For open-ended UX exploration, generate distinct, compact, complete HTML\n directions (2-5, three by default) and call `present-design-variants`. Each\n direction should be one representative screen or directional snapshot, not a\n full app per variant. Design saves every option as a normal screen on the\n overview board and renders an inline chat choice with one button per screen\n name. After the user picks, delete the unchosen variant screens and continue\n from the kept screen by first calling `get-design-snapshot` with that\n screen's `fileId`, then calling `edit-design` on that same `fileId` in a\n bounded single-file pass. Use `mode: \"replace-file\"` when expanding the\n representative placeholder into the full chosen direction. Do not call\n `generate-design` after a variant pick.\n- If the chat choice buttons are not available in the host, ask the user to\n tell you the screen name they prefer. The variants are already real screens\n on the board, so do not ask them to paste HTML or copy a generated handoff\n summary.\n- For direct refinements to an already chosen direction, call\n `get-design-snapshot`, edit from the current tuned HTML, and use\n `edit-design` for surgical changes or `mode: \"replace-file\"` for a bounded\n selected-file replacement. Use `generate-design` for new files only.\n- Use `export-coding-handoff` when the user wants to implement the chosen\n design in a codebase.\n\n## Exploration Defaults\n\n1. Default to three variants unless the user asks for a different count\n (`present-design-variants` accepts 2-5; three is the sweet spot).\n2. Make variants structurally and stylistically distinct, not just color swaps.\n3. Each variant must be a compact, complete standalone HTML document that\n renders without a build step.\n4. For product UI redesigns, prefer cleaner hierarchy, progressive disclosure,\n and realistic controls over decorative mockups.\n5. After `present-design-variants`, wait for the user's pick before\n generating the next version. Keep the chosen screen, delete the other\n variant screens, call `get-design-snapshot` with `fileId` for the kept\n screen, then call `edit-design` on that same `fileId` in a bounded pass.\n Use `mode: \"replace-file\"` when expanding the representative placeholder\n into the full chosen direction. Do not call `generate-design` after a\n variant pick. Stop after the first successful `edit-design` save.\n\n## Design Quality Bar\n\nGeneric \"AI slop\" comes from letting one prompt set taste, explore, and emit code\nat once \u2014 so the model returns the training-average (Inter, an indigo/violet\ngradient, a centered hero, three rounded cards). The variant flow above exists to\nseparate those jobs; use it, and hold this bar:\n\n- Before generating, name the concrete audience, the screen's primary job, and\n the visual thesis. If the brief is vague, make a reasonable choice and state\n it instead of producing a generic dashboard/landing-page default.\n- Refuse the defaults, and pair every \"don't\" with a \"do\" (banning Inter alone\n just makes you reach for Roboto). Avoid Inter/Roboto/system fonts, the\n indigo/violet slop palette (`#6366F1`/`#8B5CF6`/`#A855F7`) and purple-on-white\n gradients, and centered-hero + three-icon-card layouts; instead pick a\n distinctive font pairing, one non-default palette family with a single decisive\n accent, and an asymmetric layout with a clear focal point.\n- Make each direction distinct in structure and behavior, not just palette.\n Give every variant one memorable signature choice, then keep the surrounding\n chrome disciplined. Even your creative picks converge (Space Grotesk\n everywhere) \u2014 vary deliberately so two directions never share a fingerprint.\n- For existing products, inspect the current screen, design system, tokens, and\n component language before inventing a new direction. Treat any drift back to a\n default as a missing token to pin, and vary layout per screen so on-brand does\n not become same-in-your-colors.\n- Treat copy, data, and imagery as design material. Use realistic domain\n content and first-party/generated assets when images matter; avoid lorem\n ipsum, vague SaaS filler, and decorative placeholder boxes.\n- Build to a quiet quality floor: responsive desktop/mobile layout, visible\n keyboard focus, useful loading/empty/error states for app UI, and reduced\n motion support when custom motion is present.\n- After broad generation or refinement, inspect the rendered Design surface or\n a screenshot-capable host before calling it ready. Fix obvious hierarchy,\n overflow, contrast, broken interaction, and placeholder-content issues first.\n\n## Cross-App Use\n\n- Hosted default: connect `https://design.agent-native.com/mcp`.\n Do not put shared secrets in skill files.\n- For CLI/code-editor clients, keep any `npx @agent-native/core@latest connect` command\n running until browser authorization finishes. Stopping it early can leave the\n browser approved but the local MCP config unwritten. Restart or reload the\n agent client after installing or connecting if Design tools do not appear in\n the live session.\n- Dispatch can expose Design alongside other apps. Use Design for UI/UX design\n tasks, Assets for image/media selection, Slides for decks, and so on.\n- Keep the loop visual: surface the inline MCP App or the returned \"Open\n design\" link instead of pasting large HTML blobs into chat.\n- If a Design tool call returns `Session terminated`, `needs auth`, or\n another connector/session error, do not keep retrying the tool. Stop and give\n the user the reconnect step: in Claude Code run `/mcp` and choose\n Authenticate/Reconnect for the Design connector; from any terminal run\n `npx -y @agent-native/core@latest reconnect https://design.agent-native.com` \u2014 this\n re-authenticates WITHOUT reinstalling. Never reinstall from scratch just to fix\n auth. Continue once the connector is available.\n- Do not hand-roll MCP HTTP requests with curl from the agent session. Use the\n host-exposed Design tools after restart/reload, or use the returned\n browser/deep-link fallback.\n- If you inspect local MCP config, redact `Authorization`, `http_headers`,\n and token values. Never paste bearer tokens into chat or logs.\n";
2
2
  //# sourceMappingURL=design-exploration-skill.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"design-exploration-skill.d.ts","sourceRoot":"","sources":["../../../src/cli/skills-content/design-exploration-skill.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,8yNAqHvC,CAAC"}
1
+ {"version":3,"file":"design-exploration-skill.d.ts","sourceRoot":"","sources":["../../../src/cli/skills-content/design-exploration-skill.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,gyNAqHvC,CAAC"}