@uniqbit/mate-core 0.21.1 → 1.0.0-canary.10

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 (467) hide show
  1. package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
  2. package/claude-plugin/hooks/hooks.json +32 -1
  3. package/claude-plugin/hooks/workflow-turn.mjs +68 -0
  4. package/opencode-plugin/src/companion.ts +6 -0
  5. package/opencode-plugin/src/server.ts +24 -0
  6. package/package.json +9 -4
  7. package/src/cli/commands/artifact/apply-context.ts +1 -0
  8. package/src/cli/commands/artifact/artifact.ts +16 -0
  9. package/src/cli/commands/artifact/delivery/archive.ts +37 -112
  10. package/src/cli/commands/artifact/delivery/branch-flags.ts +19 -1
  11. package/src/cli/commands/artifact/delivery/environment.ts +30 -90
  12. package/src/cli/commands/artifact/delivery/link.ts +26 -26
  13. package/src/cli/commands/artifact/delivery/output.ts +27 -4
  14. package/src/cli/commands/artifact/delivery/resolve.ts +102 -0
  15. package/src/cli/commands/artifact/delivery/submit.ts +171 -0
  16. package/src/cli/commands/artifact/delivery/take.ts +46 -0
  17. package/src/cli/commands/artifact/extract-repo-name.ts +1 -1
  18. package/src/cli/commands/artifact/finish/command.ts +486 -55
  19. package/src/cli/commands/artifact/finish/engine.ts +87 -69
  20. package/src/cli/commands/artifact/finish/finisher.ts +5 -12
  21. package/src/cli/commands/artifact/finish/git.ts +9 -10
  22. package/src/cli/commands/artifact/finish/openspec.ts +21 -174
  23. package/src/cli/commands/artifact/finish/secret-scan.ts +5 -43
  24. package/src/cli/commands/artifact/finish/worktree-cleanup.ts +57 -7
  25. package/src/cli/commands/artifact/pending/command.ts +187 -10
  26. package/src/cli/commands/artifact/pending/discovery.ts +7 -11
  27. package/src/cli/commands/artifact/project/command.ts +59 -0
  28. package/src/cli/commands/cap/tokensave.ts +2 -2
  29. package/src/cli/commands/companion/hub.ts +11 -6
  30. package/src/cli/commands/companion/link.ts +173 -46
  31. package/src/cli/commands/companion/list.ts +70 -14
  32. package/src/cli/commands/companion/sync.ts +18 -0
  33. package/src/cli/commands/companion/update.ts +4 -3
  34. package/src/cli/commands/doctor.ts +84 -4
  35. package/src/cli/commands/friction.ts +558 -0
  36. package/src/cli/commands/install.ts +9 -4
  37. package/src/cli/commands/plugin/install.ts +82 -35
  38. package/src/cli/commands/studio/companion-add.ts +12 -27
  39. package/src/cli/commands/studio/connection.ts +53 -0
  40. package/src/{lib/factory/outcomes/sessions.ts → cli/commands/studio/live-sessions.ts} +7 -5
  41. package/src/cli/commands/studio/mcp-manager.ts +162 -0
  42. package/src/cli/commands/studio/payload.ts +172 -17
  43. package/src/cli/commands/studio/reports.ts +19 -18
  44. package/src/cli/commands/studio/routes.ts +8 -24
  45. package/src/cli/commands/studio/selection.ts +13 -4
  46. package/src/cli/commands/studio/server.ts +267 -243
  47. package/src/cli/commands/studio/service-host.ts +269 -0
  48. package/src/cli/commands/studio/services.ts +53 -34
  49. package/src/cli/commands/studio/studio-app.ts +1 -0
  50. package/src/cli/commands/studio/terminal.ts +1 -1
  51. package/src/cli/commands/studio/vault.ts +41 -40
  52. package/src/cli/commands/studio/views/model.ts +1 -9
  53. package/src/cli/commands/studio/views/vault/markdown-tree.ts +6 -5
  54. package/src/cli/commands/triage.ts +172 -0
  55. package/src/cli/commands/vscode/release-vsix.json +2 -2
  56. package/src/cli/commands/workflow/workflow.ts +516 -0
  57. package/src/cli/commands/working/cleanup.ts +1 -18
  58. package/src/cli/companion-link-wizard.tsx +158 -91
  59. package/src/cli/install-plan.tsx +3 -0
  60. package/src/cli/main.ts +106 -26
  61. package/src/cli/plugin-commands.ts +6 -1
  62. package/src/cli/repo-list-table.tsx +73 -37
  63. package/src/cli/usage.ts +30 -9
  64. package/src/create-mate.ts +15 -6
  65. package/src/distribution.ts +2 -0
  66. package/src/factory-host.ts +75 -0
  67. package/src/hooks/companion-instructions.ts +19 -8
  68. package/src/hooks/hook-io.ts +3 -1
  69. package/src/hooks/session-banner.ts +25 -0
  70. package/src/hooks/validate-artifact-path.ts +73 -22
  71. package/src/hooks/workflow-turn.ts +219 -0
  72. package/src/index.ts +1 -0
  73. package/src/lib/apply-context/fingerprint.ts +2 -1
  74. package/src/lib/apply-context/protocol.ts +2 -2
  75. package/src/lib/artifact-trailer.ts +27 -0
  76. package/src/lib/change-layout.ts +83 -38
  77. package/src/lib/delivery/branch-template.ts +4 -12
  78. package/src/lib/delivery/checkout.ts +3 -2
  79. package/src/lib/delivery/environment.ts +129 -7
  80. package/src/lib/delivery/merge-git.ts +312 -28
  81. package/src/lib/delivery/overlap.ts +81 -16
  82. package/src/lib/delivery/record-delivery.ts +102 -9
  83. package/src/lib/delivery/record.ts +186 -24
  84. package/src/lib/delivery/refresh.ts +241 -152
  85. package/src/lib/delivery/remote.ts +66 -0
  86. package/src/lib/delivery/repository-access.ts +30 -66
  87. package/src/lib/delivery/stages.ts +83 -50
  88. package/src/lib/delivery/staging/apply-chain.ts +182 -0
  89. package/src/lib/delivery/staging/artifact-type.ts +101 -0
  90. package/src/lib/delivery/staging/declared-type.ts +277 -0
  91. package/src/lib/delivery/staging/linked-merges.ts +175 -0
  92. package/src/lib/delivery/staging/naming.ts +67 -0
  93. package/src/lib/delivery/staging/openspec-type.ts +166 -0
  94. package/src/lib/delivery/staging/pending-edit.ts +291 -0
  95. package/src/lib/delivery/staging/pending.ts +922 -0
  96. package/src/lib/delivery/staging/preflight.ts +239 -0
  97. package/src/lib/delivery/staging/project.ts +512 -0
  98. package/src/lib/delivery/staging/publish.ts +1024 -0
  99. package/src/lib/delivery/staging/refs.ts +258 -0
  100. package/src/lib/delivery/staging/registry.ts +73 -0
  101. package/src/lib/delivery/staging/replay.ts +310 -0
  102. package/src/lib/delivery/staging/requirement-blocks.ts +10 -0
  103. package/src/lib/delivery/staging/resolve.ts +264 -0
  104. package/src/lib/delivery/staging/settle-linked.ts +176 -0
  105. package/src/lib/delivery/staging/submit.ts +1050 -0
  106. package/src/lib/delivery/staging/worktree.ts +130 -0
  107. package/src/lib/delivery/submit-change.ts +569 -0
  108. package/src/lib/friction/describe.ts +42 -0
  109. package/src/lib/friction/fields.ts +60 -0
  110. package/src/lib/friction/mark.ts +194 -0
  111. package/src/lib/friction/view/model.ts +67 -0
  112. package/src/lib/friction/view/read.ts +145 -0
  113. package/src/lib/friction/view/select.ts +54 -0
  114. package/src/lib/git-key.ts +15 -0
  115. package/src/lib/install.ts +2 -0
  116. package/src/lib/mcp-manager/resolve.ts +88 -0
  117. package/src/lib/mcp-manager/store.ts +133 -0
  118. package/src/lib/mcp-manager/types.ts +72 -0
  119. package/src/lib/mcp-manager/validate.ts +242 -0
  120. package/src/lib/openspec-canonical-frontmatter.ts +159 -0
  121. package/src/lib/openspec-cli.ts +10 -5
  122. package/src/lib/orchestrator/adapters/base.ts +31 -20
  123. package/src/lib/orchestrator/adapters/claude.ts +21 -7
  124. package/src/lib/orchestrator/adapters/opencode.ts +4 -0
  125. package/src/lib/orchestrator/companion-git-sync.ts +152 -16
  126. package/src/lib/orchestrator/config-store.ts +30 -7
  127. package/src/lib/orchestrator/engine-floor.ts +16 -4
  128. package/src/lib/orchestrator/engine-guard.ts +7 -1
  129. package/src/lib/orchestrator/framework-context.ts +15 -1
  130. package/src/lib/orchestrator/projection-claude-links.ts +1 -0
  131. package/src/lib/orchestrator/refresh-working-claude-links.ts +1 -0
  132. package/src/lib/orchestrator/repo-local-store.ts +14 -0
  133. package/src/lib/orchestrator/repository-link.ts +80 -52
  134. package/src/lib/orchestrator/root-context.ts +40 -7
  135. package/src/lib/orchestrator/session-prepare.ts +11 -1
  136. package/src/lib/orchestrator/types.ts +4 -0
  137. package/src/lib/orchestrator/umbrella-checkouts.ts +4 -4
  138. package/src/lib/package-paths.ts +23 -15
  139. package/src/lib/prebuilt-workspace-prepare.ts +2 -1
  140. package/src/lib/prebuilt-workspace.ts +1 -0
  141. package/src/lib/session-attribution.ts +3 -7
  142. package/src/lib/session-state.ts +3 -2
  143. package/src/lib/skills-cli.ts +38 -0
  144. package/src/lib/tool-manifest.ts +73 -0
  145. package/src/lib/triage/context.ts +312 -0
  146. package/src/lib/triage/launch.ts +52 -0
  147. package/src/lib/triage/prepare.ts +112 -0
  148. package/src/lib/triage/session.ts +126 -0
  149. package/src/lib/workflow/declaration.ts +6 -0
  150. package/src/lib/workflow/handoff.ts +90 -0
  151. package/src/lib/workflow/hook-trust.ts +108 -0
  152. package/src/lib/workflow/position.ts +524 -0
  153. package/src/lib/workflow/report.ts +79 -0
  154. package/src/lib/workflow/work.ts +106 -0
  155. package/src/lib/workset/factory-local.ts +2 -2
  156. package/src/lib/workset/repositories.ts +2 -2
  157. package/src/lib/workset/stage.ts +4 -2
  158. package/src/lib/workset/stages.ts +64 -4
  159. package/src/lib/workset/worktree.ts +32 -14
  160. package/src/opencode/companion-hooks.ts +63 -14
  161. package/src/opencode/projected-guidance.ts +7 -2
  162. package/src/opencode/turn-hook.ts +241 -0
  163. package/src/playbooks/companion-guidance.ts +7 -4
  164. package/src/plugin-api.ts +48 -0
  165. package/src/runtime/artifact-trailers.ts +63 -0
  166. package/src/runtime/claude-hook-group.ts +2 -0
  167. package/src/runtime/command-arg.ts +15 -0
  168. package/src/runtime/command-friction.ts +97 -0
  169. package/src/runtime/companion-git-state.ts +155 -10
  170. package/src/runtime/companion-git.ts +86 -11
  171. package/src/runtime/companion-guidance.ts +120 -17
  172. package/src/runtime/companion-instructions.ts +1 -1
  173. package/src/runtime/companion-sync.ts +109 -21
  174. package/src/runtime/env-names.ts +2 -2
  175. package/src/runtime/env.ts +7 -6
  176. package/src/runtime/forge-remote.ts +54 -0
  177. package/src/runtime/friction-fingerprint.ts +35 -0
  178. package/src/runtime/friction-log.ts +376 -0
  179. package/src/runtime/friction-recorder.ts +212 -0
  180. package/src/runtime/friction-retention.ts +1 -0
  181. package/src/runtime/friction-state.ts +110 -0
  182. package/src/runtime/friction-switch.ts +26 -0
  183. package/src/runtime/friction-vocabulary.ts +42 -0
  184. package/src/runtime/git-layout.ts +21 -7
  185. package/src/runtime/git-tracked.ts +13 -2
  186. package/src/runtime/json-fields.ts +8 -0
  187. package/src/runtime/pending-records.ts +533 -0
  188. package/src/runtime/projected-guidance.ts +8 -3
  189. package/src/runtime/publication-secret-scan.ts +45 -0
  190. package/src/runtime/secret-patterns.ts +7 -5
  191. package/src/runtime/secret-values.ts +16 -0
  192. package/src/runtime/session-id.ts +24 -0
  193. package/src/runtime/session-prepare-runner.ts +3 -0
  194. package/src/runtime/skill-prefix.ts +75 -0
  195. package/src/runtime/submitted-arrivals.ts +547 -0
  196. package/src/runtime/turn-state.d.mts +14 -0
  197. package/src/runtime/turn-state.mjs +93 -0
  198. package/src/runtime/umbrella-children.ts +52 -0
  199. package/src/runtime/umbrella-folder.ts +31 -3
  200. package/src/runtime/workflow/change-folders.ts +66 -0
  201. package/src/runtime/workflow/declaration.ts +720 -0
  202. package/src/runtime/workflow/globs.ts +85 -0
  203. package/src/runtime/workflow/next-handoff-process.ts +99 -0
  204. package/src/runtime/workflow/turn.ts +311 -0
  205. package/src/runtime/workflow/workflow.ts +262 -0
  206. package/src/studio.ts +113 -23
  207. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/schema.yaml +3 -3
  208. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/design.md +1 -1
  209. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/proposal.md +1 -1
  210. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/tasks.md +1 -1
  211. package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +7 -3
  212. package/src/templates/capabilities/react-doctor/mate-react-doctor/SKILL.md +28 -0
  213. package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +84 -28
  214. package/src/templates/mate-skills/agents/mate-apply-change/references/openspec-apply-change.md +1 -1
  215. package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +30 -68
  216. package/src/templates/mate-skills/agents/mate-backfill-spec/SKILL.md +23 -1
  217. package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +39 -8
  218. package/src/templates/mate-skills/agents/mate-domain-modeling/SKILL.md +38 -0
  219. package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +65 -12
  220. package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +28 -0
  221. package/src/templates/mate-skills/agents/mate-grill-with-docs/SKILL.md +28 -0
  222. package/src/templates/mate-skills/agents/mate-grilling/SKILL.md +25 -0
  223. package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +28 -0
  224. package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +68 -28
  225. package/src/templates/mate-skills/agents/mate-propose-change/references/mate-revise.md +13 -7
  226. package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-update-change.md +1 -1
  227. package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +136 -86
  228. package/src/templates/mate-skills/agents/mate-publish-artifact/references/openspec.md +111 -100
  229. package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +28 -3
  230. package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +39 -5
  231. package/src/templates/mate-skills/agents/mate-submit-change/SKILL.md +138 -0
  232. package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +84 -28
  233. package/src/templates/mate-skills/claude/mate-apply-change/references/openspec-apply-change.md +1 -1
  234. package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +30 -68
  235. package/src/templates/mate-skills/claude/mate-backfill-spec/SKILL.md +23 -1
  236. package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +39 -8
  237. package/src/templates/mate-skills/claude/mate-domain-modeling/SKILL.md +38 -0
  238. package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +65 -12
  239. package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +28 -0
  240. package/src/templates/mate-skills/claude/mate-grill-with-docs/SKILL.md +28 -0
  241. package/src/templates/mate-skills/claude/mate-grilling/SKILL.md +25 -0
  242. package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +28 -0
  243. package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +68 -28
  244. package/src/templates/mate-skills/claude/mate-propose-change/references/mate-revise.md +13 -7
  245. package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-update-change.md +1 -1
  246. package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +136 -86
  247. package/src/templates/mate-skills/claude/mate-publish-artifact/references/openspec.md +111 -100
  248. package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +28 -3
  249. package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +39 -5
  250. package/src/templates/mate-skills/claude/mate-submit-change/SKILL.md +138 -0
  251. package/src/templates/mate-skills/openspec-references.ts +3 -2
  252. package/src/templates/triage/PLAYBOOK.md +120 -0
  253. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +678 -170
  254. package/src/tools/setup/capabilities/graphify.ts +23 -1
  255. package/src/tools/setup/capabilities/mcp-manager.ts +73 -0
  256. package/src/tools/setup/capabilities/openspec.ts +54 -15
  257. package/src/tools/setup/capabilities/rtk.ts +47 -94
  258. package/src/tools/setup/capabilities/tokensave.ts +79 -56
  259. package/src/tools/setup/context-services.ts +35 -6
  260. package/src/tools/setup/dynamic-plugins/api.ts +38 -0
  261. package/src/tools/setup/dynamic-plugins/audiences.ts +31 -16
  262. package/src/tools/setup/dynamic-plugins/host.ts +2 -32
  263. package/src/tools/setup/dynamic-plugins/hydrate.ts +32 -14
  264. package/src/tools/setup/dynamic-plugins/install.ts +2 -0
  265. package/src/tools/setup/dynamic-plugins/installed.ts +73 -0
  266. package/src/tools/setup/dynamic-plugins/loader.ts +12 -10
  267. package/src/tools/setup/dynamic-plugins/local.ts +492 -0
  268. package/src/tools/setup/dynamic-plugins/paths.ts +34 -6
  269. package/src/tools/setup/dynamic-plugins/verify.ts +34 -14
  270. package/src/tools/setup/dynamic-plugins/workspaces.ts +21 -12
  271. package/src/tools/setup/engine.ts +75 -4
  272. package/src/tools/setup/mate.ts +28 -1
  273. package/src/tools/setup/package-managers/bun.ts +8 -8
  274. package/src/tools/setup/plugin.ts +28 -1
  275. package/src/tools/setup/plugins/gitignore.ts +45 -12
  276. package/src/tools/setup/plugins/guidance.ts +4 -2
  277. package/src/tools/setup/providers/claude-format.ts +39 -2
  278. package/src/tools/setup/providers/claude-plugin-hooks.ts +18 -0
  279. package/src/tools/setup/providers/claude.ts +56 -6
  280. package/src/tools/setup/providers/opencode-format.ts +13 -3
  281. package/src/tools/setup/providers/opencode.ts +7 -18
  282. package/src/tools/setup/providers/relative-path-warnings.ts +26 -0
  283. package/src/tools/setup/service-registry.ts +69 -0
  284. package/src/tools/setup/service.ts +245 -0
  285. package/src/tools/setup/utils.ts +34 -4
  286. package/src/tools/setup.ts +16 -2
  287. package/studio-dist/client/assets/DialogTitle-B_G47-lk.js +1 -0
  288. package/studio-dist/client/assets/app-0NoFqMou.css +2 -0
  289. package/studio-dist/client/assets/button-D_0295cs.js +1 -0
  290. package/studio-dist/client/assets/cn-Cx_D6I3u.js +1 -0
  291. package/studio-dist/client/assets/combobox-D0iPQP50.js +1 -0
  292. package/studio-dist/client/assets/{companion-view-CrabvxS8.js → companion-view-D3A76MLj.js} +1 -1
  293. package/studio-dist/client/assets/fields-Ctheim1h.js +1 -0
  294. package/studio-dist/client/assets/friction-Cn9n_zBA.js +1 -0
  295. package/studio-dist/client/assets/getting-started-DgoVWbWo.js +1 -0
  296. package/studio-dist/client/assets/{getting-started-D6kgWwWZ.js → getting-started-MmLqvy01.js} +1 -1
  297. package/studio-dist/client/assets/getting-started._topic-DBF0khhz.js +1 -0
  298. package/studio-dist/client/assets/getting-started.index-BRdAVqIh.js +1 -0
  299. package/studio-dist/client/assets/graph-BVRdq46V.js +2 -0
  300. package/studio-dist/client/assets/{graph-canvas-Ba37Y5AE.js → graph-canvas-BNzd-eVb.js} +1 -1
  301. package/studio-dist/client/assets/guides-DY1W9LRs.js +1 -0
  302. package/studio-dist/client/assets/index-CuTIc9yd.js +40 -0
  303. package/studio-dist/client/assets/{markdown-view-BOX6x0rL.js → markdown-view-BqZQkk_k.js} +1 -1
  304. package/studio-dist/client/assets/mcp-CIFxmDs0.js +4 -0
  305. package/studio-dist/client/assets/panel-DafanLQ4.js +1 -0
  306. package/studio-dist/client/assets/plugins._service._view-xSRLxHNM.js +1 -0
  307. package/studio-dist/client/assets/prepaint-C--F50QZ.js +27 -0
  308. package/studio-dist/client/assets/{queries-RvHeXY12.js → queries-ByCoiacy.js} +1 -1
  309. package/studio-dist/client/assets/react-BYUSgtBs.js +1 -0
  310. package/studio-dist/client/assets/reports-Diryyked.js +1 -0
  311. package/studio-dist/client/assets/routes-DbRwPd55.js +1 -0
  312. package/studio-dist/client/assets/search-BDKQRwa5.js +1 -0
  313. package/studio-dist/client/assets/select-_9JT3hpU.js +1 -0
  314. package/studio-dist/client/assets/skills-D5a6ybQM.js +1 -0
  315. package/studio-dist/client/assets/{specs-B0ldF_6J.js → specs-COAWUTog.js} +1 -1
  316. package/studio-dist/client/assets/specs-view-9eTn9TcN.js +1 -0
  317. package/studio-dist/client/assets/steps-BS588WAV.js +1 -0
  318. package/studio-dist/client/assets/store-3cffhIO6.js +1 -0
  319. package/studio-dist/client/assets/studio-CG9eioSx.js +100 -0
  320. package/studio-dist/client/assets/studio-queries-BS1yR7Wc.js +2 -0
  321. package/studio-dist/client/assets/{usage-C2QJ_0IZ.js → usage-Ccl4d7w0.js} +15 -15
  322. package/studio-dist/client/assets/useAnchoredPopupScrollLock-D_y83VP7.js +1 -0
  323. package/studio-dist/client/assets/useBlocker-BQOfcu_f.js +1 -0
  324. package/studio-dist/client/assets/useMutation-BDmS2V6y.js +1 -0
  325. package/studio-dist/client/assets/usePopupHandleStore-BcqpNR-F.js +1 -0
  326. package/studio-dist/client/assets/vault-C1tOhQMe.js +1 -0
  327. package/studio-dist/client/assets/warnings-BZ_X1nkO.js +1 -0
  328. package/studio-dist/client/assets/workflow-Cm2fsnly.js +1 -0
  329. package/studio-dist/server/assets/DialogTitle-KSVhF_7V.js +421 -0
  330. package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-Bn896ZYj.js → __23tanstack-start-server-fn-resolver-QQnIXyKi.js} +40 -28
  331. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +84 -74
  332. package/studio-dist/server/assets/{button-CgOIVdmD.js → button-C7EMLaX6.js} +229 -5527
  333. package/studio-dist/server/assets/cn-D7uJiH_O.js +5528 -0
  334. package/studio-dist/server/assets/{combobox-DV_s9W0s.js → combobox-Dc4_y20Y.js} +6 -5
  335. package/studio-dist/server/assets/{companion-view-BKVXD3TO.js → companion-view-CrSi37Mb.js} +2 -2
  336. package/studio-dist/server/assets/{companions-C7fctnU9.js → companions-CDSuLqA4.js} +1 -1
  337. package/studio-dist/server/assets/{fields-BbieQTD0.js → fields-BxBN6-Dz.js} +10 -2
  338. package/studio-dist/server/assets/friction-B1K8Kp8r.js +62 -0
  339. package/studio-dist/server/assets/friction-Vl3B6THL.js +943 -0
  340. package/studio-dist/server/assets/{getting-started-CRxMWorQ.js → getting-started-B3lu5W7M.js} +2 -2
  341. package/studio-dist/server/assets/{getting-started._topic-DJKQAzYl.js → getting-started._topic-EYtxZM-Y.js} +2 -2
  342. package/studio-dist/server/assets/{getting-started.index-D84gec1t.js → getting-started.index-CTaXYycH.js} +2 -2
  343. package/studio-dist/server/assets/{graph-DDZzXM1L.js → graph-Bhmk7H8V.js} +1 -1
  344. package/studio-dist/server/assets/{graph-CSje3029.js → graph-D3fXCaKt.js} +8 -8
  345. package/studio-dist/server/assets/{graph-canvas-22bWB5-2.js → graph-canvas-DIvTodML.js} +2 -2
  346. package/studio-dist/server/assets/{guides-IE-19POz.js → guides-BZWFpJl-.js} +1 -1
  347. package/studio-dist/server/assets/{guides-D9dk1Frq.js → guides-CHBkRO6R.js} +1 -1
  348. package/studio-dist/server/assets/{guides.server-vcYRY5wx.js → guides.server-DX9KRkcK.js} +1 -1
  349. package/studio-dist/server/assets/{markdown-view-BR8dJ7aR.js → markdown-view-qrCSkVta.js} +1 -1
  350. package/studio-dist/server/assets/mcp-Ljf4simO.js +1103 -0
  351. package/studio-dist/server/assets/mcp-manager-DohRwmJU.js +50 -0
  352. package/studio-dist/server/assets/{panel-BR_t9iMM.js → panel-CAwz4mKp.js} +6 -4
  353. package/studio-dist/server/assets/plugins._service._view-DUpAo5D_.js +97 -0
  354. package/studio-dist/server/assets/prepaint-BxZ-pU7t.js +45 -0
  355. package/studio-dist/server/assets/{queries-DWoTin-q.js → queries-W4LXzTnT.js} +1 -1
  356. package/studio-dist/server/assets/react-CiBZPDs8.js +45 -0
  357. package/studio-dist/server/assets/{reports-CQ9qQ1-n.js → reports-BVNSPHU3.js} +13 -7
  358. package/studio-dist/server/assets/{reports-dYDEoBeq.js → reports-CGG_wRN5.js} +1 -1
  359. package/studio-dist/server/assets/{router-DkRHNTpE.js → router-KH1x6ryF.js} +1039 -1096
  360. package/studio-dist/server/assets/{routes-B6GfOew4.js → routes-Bl90FC4R.js} +333 -38
  361. package/studio-dist/server/assets/search-BjG5f16n.js +110 -0
  362. package/studio-dist/server/assets/{select-Af7Wibii.js → select-B8q9tLbl.js} +5 -4
  363. package/studio-dist/server/assets/{shell-Hq-hXgnT.js → shell-C5emwofr.js} +12 -3
  364. package/studio-dist/server/assets/{skills-B7nEuVbx.js → skills-10l0eCfP.js} +8 -8
  365. package/studio-dist/server/assets/{skills-B_YYL7q8.js → skills-vG6TTvP1.js} +1 -1
  366. package/studio-dist/server/assets/{specs-BpLUFntA.js → specs-C1P2BEao.js} +4 -4
  367. package/studio-dist/server/assets/{specs-view-0peMVd22.js → specs-view-csUBtMWU.js} +10 -10
  368. package/studio-dist/server/assets/{steps-D56DApvK.js → steps-T4wXftgd.js} +88 -45
  369. package/studio-dist/server/assets/store-CWlRjv9s.js +93 -0
  370. package/studio-dist/server/assets/{studio-CAcKp3bM.js → studio-D-ZPWSMv.js} +1567 -59
  371. package/studio-dist/server/assets/{studio-queries-BtRGzDdh.js → studio-queries-DC273ifg.js} +66 -124
  372. package/studio-dist/server/assets/{usage-COdjd1gD.js → usage-CT3IWLJc.js} +13 -30
  373. package/studio-dist/server/assets/{usage-f6pqE1tm.js → usage-D4t_ibR8.js} +1 -1
  374. package/studio-dist/server/assets/{useAnchoredPopupScrollLock-DlBKHRw7.js → useAnchoredPopupScrollLock-BchJDJYg.js} +2 -2
  375. package/studio-dist/server/assets/useBlocker-CQtANHK8.js +111 -0
  376. package/studio-dist/server/assets/{useMutation-DzTZGenE.js → useMutation-0HbcKUsQ.js} +2 -2
  377. package/studio-dist/server/assets/usePopupHandleStore-B3SNGTic.js +26 -0
  378. package/studio-dist/server/assets/{vault-BDuIUq0F.js → vault-BIytrudF.js} +10 -117
  379. package/studio-dist/server/assets/{vault-BVLp6zu3.js → vault-MINXmyXA.js} +1 -1
  380. package/studio-dist/server/assets/{views-flRUr21z.js → views-DrmY_3J5.js} +7 -4
  381. package/studio-dist/server/assets/{warnings-CDy9pdgL.js → warnings-BVZCDbIz.js} +2 -2
  382. package/studio-dist/server/assets/{workflow-D9GKI2EV.js → workflow-DFdqnMtW.js} +57 -50
  383. package/studio-dist/server/server.js +2 -2
  384. package/tool-manifest.yaml +85 -0
  385. package/src/cli/commands/factory/factory.ts +0 -311
  386. package/src/cli/commands/studio/factory-credential.ts +0 -35
  387. package/src/cli/commands/studio/factory-git-tokens.ts +0 -40
  388. package/src/cli/commands/studio/factory-relay.ts +0 -18
  389. package/src/cli/commands/studio/repository-add.ts +0 -116
  390. package/src/cli/commands/studio/workset-session.ts +0 -164
  391. package/src/lib/delivery/archive-change.ts +0 -165
  392. package/src/lib/delivery/forge.ts +0 -279
  393. package/src/lib/delivery/token.ts +0 -24
  394. package/src/lib/factory/attach-client.ts +0 -123
  395. package/src/lib/factory/attach.ts +0 -178
  396. package/src/lib/factory/broker.ts +0 -187
  397. package/src/lib/factory/bun-commands.ts +0 -39
  398. package/src/lib/factory/client.ts +0 -113
  399. package/src/lib/factory/clone-url.ts +0 -39
  400. package/src/lib/factory/command.ts +0 -77
  401. package/src/lib/factory/credential-store.ts +0 -153
  402. package/src/lib/factory/frames.ts +0 -77
  403. package/src/lib/factory/git-auth.ts +0 -61
  404. package/src/lib/factory/git-credential-store.ts +0 -181
  405. package/src/lib/factory/ids.ts +0 -68
  406. package/src/lib/factory/outcomes/actions.ts +0 -130
  407. package/src/lib/factory/outcomes/index.ts +0 -457
  408. package/src/lib/factory/outcomes/lifecycle.ts +0 -212
  409. package/src/lib/factory/outcomes/runs.ts +0 -81
  410. package/src/lib/factory/prepare.ts +0 -55
  411. package/src/lib/factory/pty.ts +0 -103
  412. package/src/lib/factory/runner/companion-context.ts +0 -178
  413. package/src/lib/factory/runner/control.ts +0 -92
  414. package/src/lib/factory/runner/harness-agent.ts +0 -250
  415. package/src/lib/factory/runner/live.ts +0 -159
  416. package/src/lib/factory/runner/questions.ts +0 -22
  417. package/src/lib/factory/runner/rank.ts +0 -26
  418. package/src/lib/factory/runner/run-policy.ts +0 -12
  419. package/src/lib/factory/runner/run.ts +0 -199
  420. package/src/lib/factory/runner/scheduler.ts +0 -498
  421. package/src/lib/factory/runner/state.ts +0 -233
  422. package/src/lib/factory/runner/workflow.ts +0 -546
  423. package/src/lib/factory/runtime.ts +0 -1081
  424. package/src/lib/factory/sandbox.ts +0 -292
  425. package/src/lib/factory/worktree-branch.ts +0 -17
  426. package/src/templates/capabilities/openspec-cap/mate-v1/templates/explore-brief.md +0 -25
  427. package/studio-dist/client/assets/app-D9cw6szy.css +0 -2
  428. package/studio-dist/client/assets/artifacts-WD2ZXYrx.js +0 -1
  429. package/studio-dist/client/assets/button-Br0O1sXw.js +0 -1
  430. package/studio-dist/client/assets/combobox-DA7RAUUZ.js +0 -1
  431. package/studio-dist/client/assets/factory-DGS0E16C.js +0 -6
  432. package/studio-dist/client/assets/fields-6aXBpFhJ.js +0 -1
  433. package/studio-dist/client/assets/getting-started-Clde4w6P.js +0 -1
  434. package/studio-dist/client/assets/getting-started._topic-BiunccbT.js +0 -1
  435. package/studio-dist/client/assets/getting-started.index-DpiNoGw8.js +0 -1
  436. package/studio-dist/client/assets/graph-B_TCBVbu.js +0 -2
  437. package/studio-dist/client/assets/guides-Du_RtJxP.js +0 -1
  438. package/studio-dist/client/assets/index-Df8L1LQa.js +0 -40
  439. package/studio-dist/client/assets/panel-dbmCx7Mx.js +0 -1
  440. package/studio-dist/client/assets/react-3QStrcDO.js +0 -27
  441. package/studio-dist/client/assets/report-url-XRL0x1SY.js +0 -1
  442. package/studio-dist/client/assets/reports-r3IK7Doz.js +0 -1
  443. package/studio-dist/client/assets/routes-C0A5LTFc.js +0 -1
  444. package/studio-dist/client/assets/select-CnaMd617.js +0 -1
  445. package/studio-dist/client/assets/skills-CzjzHpBT.js +0 -1
  446. package/studio-dist/client/assets/specs-view-BnCLA0gW.js +0 -1
  447. package/studio-dist/client/assets/spinner-Dcm3fqK1.js +0 -1
  448. package/studio-dist/client/assets/steps-C0p2N1Pb.js +0 -1
  449. package/studio-dist/client/assets/store-Dw34catY.js +0 -1
  450. package/studio-dist/client/assets/studio-Cpz_HRHp.js +0 -100
  451. package/studio-dist/client/assets/studio-queries-ibmpFo6R.js +0 -2
  452. package/studio-dist/client/assets/useAnchoredPopupScrollLock-Bj-FWb8z.js +0 -1
  453. package/studio-dist/client/assets/useMutation-aAr2uiay.js +0 -1
  454. package/studio-dist/client/assets/vault-BGcxkSIY.js +0 -1
  455. package/studio-dist/client/assets/warnings-R1cE1rLf.js +0 -1
  456. package/studio-dist/client/assets/workflow-C2qTrMDH.js +0 -1
  457. package/studio-dist/server/assets/actions-DYSv-9VV.js +0 -60
  458. package/studio-dist/server/assets/artifacts-DnF9L3dZ.js +0 -216
  459. package/studio-dist/server/assets/factory-C7Ybg0xG.js +0 -3075
  460. package/studio-dist/server/assets/factory-Df5uAHjb.js +0 -116
  461. package/studio-dist/server/assets/react-CdqSUhaL.js +0 -89
  462. package/studio-dist/server/assets/report-url-BUXPcE_8.js +0 -9
  463. package/studio-dist/server/assets/search-BJnWLfkG.js +0 -55
  464. package/studio-dist/server/assets/spinner-CdwJW4VB.js +0 -20
  465. package/studio-dist/server/assets/store-Cs17okNG.js +0 -280
  466. /package/src/lib/{factory/keyed-serial.ts → keyed-serial.ts} +0 -0
  467. /package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/spec.md +0 -0
@@ -0,0 +1,1103 @@
1
+ import { B as DialogDescription, L as Dialog, R as DialogClose, V as DialogTitle, b as useRetryFocus, d as Route, f as mcpManagerQuery, m as saveMcpManager, p as mcpPreviewQuery, pt as useSuspenseQuery, z as DialogContent } from "./router-KH1x6ryF.js";
2
+ import { B as keepPreviousData, u as shellQuery } from "./studio-queries-DC273ifg.js";
3
+ import { t as useMutation } from "./useMutation-0HbcKUsQ.js";
4
+ import { Lr as useQuery, ct as ROW, it as PAGE_PAD, lt as StatusWord, nt as EmptyNote, ot as Pills, r as Icon, rt as ListCard, t as Button, ut as ViewLoading } from "./button-C7EMLaX6.js";
5
+ import { m as useQueryClient, t as cn } from "./cn-D7uJiH_O.js";
6
+ import { t as useBlocker } from "./useBlocker-CQtANHK8.js";
7
+ import { n as require_react, o as __toESM, t as require_jsx_runtime } from "./jsx-runtime-Bt0s0YKS.js";
8
+ import { i as Textarea, t as Input } from "./fields-BxBN6-Dz.js";
9
+ import { n as MCP_MANAGER_TRANSPORTS, r as parseHeaderRef, t as MCP_MANAGER_HEADER_PREFIXES } from "./studio-D-ZPWSMv.js";
10
+ import { a as Select, c as SelectTrigger, l as SelectValue, o as SelectContent, s as SelectItem } from "./select-B8q9tLbl.js";
11
+ // src/views/mcp/mcp-model.ts
12
+ var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
13
+ var KIND_WORD = {
14
+ servers: "server",
15
+ groups: "group"
16
+ };
17
+ var NEXT_CELL = {
18
+ enabled: "off",
19
+ off: "enabled",
20
+ inherit: "enable",
21
+ enable: "disable",
22
+ disable: "inherit"
23
+ };
24
+ var names = (selection, kind) => selection?.[kind] ?? [];
25
+ /** `audience` null is the base column. */
26
+ function cellOf(state, audience, kind, name) {
27
+ if (audience === null) return names(state.catalog?.enabled, kind).includes(name) ? "enabled" : "off";
28
+ const selection = state.audiences[audience];
29
+ if (names(selection?.enable, kind).includes(name)) return "enable";
30
+ if (names(selection?.disable, kind).includes(name)) return "disable";
31
+ return "inherit";
32
+ }
33
+ function listed(selection, kind, name, on) {
34
+ const others = names(selection, kind).filter((entry) => entry !== name);
35
+ return {
36
+ ...selection,
37
+ [kind]: on ? [...others, name] : others
38
+ };
39
+ }
40
+ /** The state after one click on a cell. */
41
+ function cycleCell(state, audience, kind, name) {
42
+ const cell = NEXT_CELL[cellOf(state, audience, kind, name)];
43
+ if (audience === null) {
44
+ const enabled = listed(state.catalog?.enabled, kind, name, cell === "enabled");
45
+ return {
46
+ ...state,
47
+ catalog: {
48
+ ...state.catalog,
49
+ enabled
50
+ }
51
+ };
52
+ }
53
+ const selection = state.audiences[audience];
54
+ return {
55
+ ...state,
56
+ audiences: {
57
+ ...state.audiences,
58
+ [audience]: {
59
+ enable: listed(selection?.enable, kind, name, cell === "enable"),
60
+ disable: listed(selection?.disable, kind, name, cell === "disable")
61
+ }
62
+ }
63
+ };
64
+ }
65
+ /** Where a server or group is named, so a delete can say what it also changes. */
66
+ function referencesOf(state, kind, name) {
67
+ return {
68
+ groups: (kind === "servers" ? Object.entries(state.catalog?.groups ?? {}) : []).filter(([, members]) => members.includes(name)).map(([group]) => group),
69
+ base: cellOf(state, null, kind, name) === "enabled",
70
+ audiences: Object.keys(state.audiences).filter((audience) => cellOf(state, audience, kind, name) !== "inherit")
71
+ };
72
+ }
73
+ /** "a, b and c". */
74
+ function inWords(parts) {
75
+ return parts.length < 2 ? parts.join("") : `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}`;
76
+ }
77
+ /** What else a delete changes, in words; null when nothing names the entry. */
78
+ function referenceText(state, kind, name) {
79
+ const { groups, base, audiences } = referencesOf(state, kind, name);
80
+ const parts = [
81
+ ...groups.length > 0 ? [`${groups.length === 1 ? "group" : "groups"} ${inWords(groups)}`] : [],
82
+ ...base ? ["the base selection"] : [],
83
+ ...audiences.length > 0 ? [`${audiences.length === 1 ? "audience" : "audiences"} ${inWords(audiences)}`] : []
84
+ ];
85
+ return parts.length > 0 ? inWords(parts) : null;
86
+ }
87
+ /** Every reference to `name` renamed to `to`, or dropped when `to` is null. */
88
+ function rewritten(state, kind, name, to) {
89
+ const list = (entries) => entries.flatMap((entry) => entry === name ? to ?? [] : entry);
90
+ const selection = (held) => held?.[kind] ? {
91
+ ...held,
92
+ [kind]: list(held[kind])
93
+ } : held;
94
+ const groups = state.catalog?.groups;
95
+ return {
96
+ catalog: {
97
+ ...state.catalog,
98
+ groups: kind === "servers" && groups ? Object.fromEntries(Object.entries(groups).map(([group, members]) => [group, list(members)])) : groups,
99
+ enabled: selection(state.catalog?.enabled)
100
+ },
101
+ audiences: Object.fromEntries(Object.entries(state.audiences).map(([audience, held]) => [audience, {
102
+ enable: selection(held.enable),
103
+ disable: selection(held.disable)
104
+ }]))
105
+ };
106
+ }
107
+ /** The state without the entry and without any reference to it. */
108
+ function withoutEntry(state, kind, name) {
109
+ const next = rewritten(state, kind, name, null);
110
+ const { [name]: _removed, ...kept } = next.catalog?.[kind] ?? {};
111
+ return {
112
+ ...next,
113
+ catalog: {
114
+ ...next.catalog,
115
+ [kind]: kept
116
+ }
117
+ };
118
+ }
119
+ /**
120
+ * The state with the entry added, or replacing `previous` in its place; a changed name moves
121
+ * every reference to the new one.
122
+ */
123
+ function withEntry(state, kind, previous, name, value) {
124
+ const next = previous !== null && previous !== name ? rewritten(state, kind, previous, name) : state;
125
+ const entries = Object.entries(next.catalog?.[kind] ?? {});
126
+ const at = entries.findIndex(([entry]) => entry === previous);
127
+ if (at === -1) entries.push([name, value]);
128
+ else entries[at] = [name, value];
129
+ return {
130
+ ...next,
131
+ catalog: {
132
+ ...next.catalog,
133
+ [kind]: Object.fromEntries(entries)
134
+ }
135
+ };
136
+ }
137
+ /** Whether another entry of `kind` already holds `name`; core checks the other kind. */
138
+ function nameTaken(state, kind, previous, name) {
139
+ return name !== previous && Object.hasOwn(state.catalog?.[kind] ?? {}, name);
140
+ }
141
+ var TRANSPORTS = ["stdio", ...MCP_MANAGER_TRANSPORTS];
142
+ function transportOf(server) {
143
+ return "command" in server ? "stdio" : server.transport ?? "http";
144
+ }
145
+ function headerRows(headers) {
146
+ return Object.entries(headers ?? {}).map(([header, value]) => ({
147
+ header,
148
+ ...parseHeaderRef(value) ?? {
149
+ prefix: "",
150
+ variable: ""
151
+ }
152
+ }));
153
+ }
154
+ function serverForm(name = "", server) {
155
+ const stdio = server && "command" in server ? server : void 0;
156
+ const remote = server && "url" in server ? server : void 0;
157
+ return {
158
+ name,
159
+ transport: server ? transportOf(server) : "stdio",
160
+ command: stdio?.command ?? "",
161
+ args: (stdio?.args ?? []).join("\n"),
162
+ url: remote?.url ?? "",
163
+ env: (server?.env ?? []).join("\n"),
164
+ headers: headerRows(remote?.headers)
165
+ };
166
+ }
167
+ var lines = (text) => text.split("\n").map((line) => line.trim()).filter(Boolean);
168
+ /** The server a form declares, without empty lists; core validates it. */
169
+ function serverOf(form) {
170
+ const env = lines(form.env);
171
+ const shared = env.length > 0 ? { env } : {};
172
+ if (form.transport === "stdio") {
173
+ const args = lines(form.args);
174
+ return {
175
+ command: form.command.trim(),
176
+ ...args.length > 0 ? { args } : {},
177
+ ...shared
178
+ };
179
+ }
180
+ const headers = form.headers.filter((row) => row.header.trim() || row.variable.trim());
181
+ return {
182
+ url: form.url.trim(),
183
+ ...form.transport === "sse" ? { transport: "sse" } : {},
184
+ ...headers.length > 0 ? { headers: Object.fromEntries(headers.map((row) => [row.header.trim(), `${row.prefix}\${${row.variable.trim()}}`])) } : {},
185
+ ...shared
186
+ };
187
+ }
188
+ // src/views/mcp/mcp-dialogs.tsx
189
+ var import_jsx_runtime = require_jsx_runtime();
190
+ var NO_PREFIX = "none";
191
+ var PREFIXES = [{
192
+ value: NO_PREFIX,
193
+ label: "No prefix"
194
+ }, ...MCP_MANAGER_HEADER_PREFIXES.map((prefix) => ({
195
+ value: prefix,
196
+ label: prefix.trim()
197
+ }))];
198
+ /**
199
+ * One dialog for the server form, the group form and the delete confirmation. `dialog` stays
200
+ * set while it closes, so its content is still there for the closing transition.
201
+ */
202
+ function McpDialogs({ dialog, open, finalFocus, ...body }) {
203
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dialog, {
204
+ open,
205
+ onOpenChange: (next) => {
206
+ if (!next) body.onClose();
207
+ },
208
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogContent, {
209
+ className: "grid max-h-[80vh] w-[min(520px,calc(100vw-32px))] gap-4 overflow-y-auto p-5",
210
+ finalFocus,
211
+ children: [
212
+ dialog?.kind === "form" && dialog.entry === "servers" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ServerBody, {
213
+ previous: dialog.previous,
214
+ ...body
215
+ }) : null,
216
+ dialog?.kind === "form" && dialog.entry === "groups" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GroupBody, {
217
+ previous: dialog.previous,
218
+ ...body
219
+ }) : null,
220
+ dialog?.kind === "delete" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DeleteBody, {
221
+ entry: dialog.entry,
222
+ name: dialog.name,
223
+ ...body
224
+ }, `${dialog.entry}/${dialog.name}`) : null
225
+ ]
226
+ })
227
+ });
228
+ }
229
+ /**
230
+ * Adds or replaces an entry only once core accepts the resulting state; a name another entry of
231
+ * the kind holds, or core's refusal, is shown instead.
232
+ */
233
+ function useCheckedEntry({ companion, state, onApply, onClose }, entry, previous) {
234
+ const queryClient = useQueryClient();
235
+ const [taken, setTaken] = (0, import_react.useState)(null);
236
+ const check = useMutation({
237
+ mutationFn: (next) => queryClient.fetchQuery(mcpPreviewQuery(companion, next)),
238
+ onSuccess: (preview, next) => {
239
+ if (!preview.ok) return;
240
+ onApply(next);
241
+ onClose();
242
+ }
243
+ });
244
+ const submit = (name, value) => {
245
+ if (nameTaken(state, entry, previous, name)) {
246
+ check.reset();
247
+ return setTaken(name);
248
+ }
249
+ setTaken(null);
250
+ check.mutate(withEntry(state, entry, previous, name, value));
251
+ };
252
+ const refusal = taken ? `A ${KIND_WORD[entry]} named ${taken} already exists.` : check.isError ? check.error.message || "The entry could not be checked." : check.data?.ok === false ? check.data.reason : null;
253
+ return {
254
+ submit,
255
+ pending: check.isPending,
256
+ refusal
257
+ };
258
+ }
259
+ function DialogHead({ title, children }) {
260
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
261
+ className: "grid gap-1.5",
262
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogTitle, {
263
+ className: "text-md",
264
+ children: title
265
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogDescription, { children })]
266
+ });
267
+ }
268
+ function CodeInput({ className, ...props }) {
269
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
270
+ className: cn("font-mono", className),
271
+ autoComplete: "off",
272
+ spellCheck: false,
273
+ ...props
274
+ });
275
+ }
276
+ function NameField(props) {
277
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
278
+ label: "Name",
279
+ hint: "Lowercase letters, digits and hyphens.",
280
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodeInput, { ...props })
281
+ });
282
+ }
283
+ function Field({ label, hint, children }) {
284
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
285
+ className: "grid gap-1.5 text-sm",
286
+ children: [
287
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: label }),
288
+ children,
289
+ hint ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
290
+ className: "text-xs text-muted",
291
+ children: hint
292
+ }) : null
293
+ ]
294
+ });
295
+ }
296
+ function FormActions({ pending, action }) {
297
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
298
+ className: "flex justify-end gap-2",
299
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogClose, {
300
+ render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, { variant: "ghost" }),
301
+ children: "Cancel"
302
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
303
+ type: "submit",
304
+ variant: "primary",
305
+ disabled: pending,
306
+ children: pending ? "Checking…" : action
307
+ })]
308
+ });
309
+ }
310
+ function Refusal({ children }) {
311
+ return children ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
312
+ className: "m-0 text-sm text-bad",
313
+ role: "alert",
314
+ children
315
+ }) : null;
316
+ }
317
+ function ServerBody({ previous, ...body }) {
318
+ const { state } = body;
319
+ const [form, setForm] = (0, import_react.useState)(() => serverForm(previous ?? "", previous ? state.catalog?.servers?.[previous] : void 0));
320
+ const checked = useCheckedEntry(body, "servers", previous);
321
+ const set = (key, value) => setForm((held) => ({
322
+ ...held,
323
+ [key]: value
324
+ }));
325
+ const submit = (event) => {
326
+ event.preventDefault();
327
+ checked.submit(form.name.trim(), serverOf(form));
328
+ };
329
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
330
+ className: "grid gap-3.5",
331
+ onSubmit: submit,
332
+ children: [
333
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogHead, {
334
+ title: previous ? `Edit ${previous}` : "Add a server",
335
+ children: "Variables are given by name only. Mate never stores or shows a value."
336
+ }),
337
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NameField, {
338
+ value: form.name,
339
+ placeholder: "acme-docs",
340
+ onChange: (event) => set("name", event.currentTarget.value)
341
+ }),
342
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
343
+ className: "grid gap-1.5 text-sm",
344
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Transport" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pills, {
345
+ label: "Transport",
346
+ options: TRANSPORTS.map((transport) => ({
347
+ value: transport,
348
+ label: transport
349
+ })),
350
+ value: form.transport,
351
+ onChange: (transport) => set("transport", transport)
352
+ })]
353
+ }),
354
+ form.transport === "stdio" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
355
+ label: "Command",
356
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodeInput, {
357
+ value: form.command,
358
+ placeholder: "acme-docs-mcp",
359
+ onChange: (event) => set("command", event.currentTarget.value)
360
+ })
361
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
362
+ label: "Arguments",
363
+ hint: "One per line.",
364
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Textarea, {
365
+ className: "min-h-16 font-mono",
366
+ value: form.args,
367
+ spellCheck: false,
368
+ onChange: (event) => set("args", event.currentTarget.value)
369
+ })
370
+ })] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
371
+ label: "URL",
372
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodeInput, {
373
+ value: form.url,
374
+ placeholder: "https://acme.test/mcp",
375
+ onChange: (event) => set("url", event.currentTarget.value)
376
+ })
377
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HeaderRows, {
378
+ rows: form.headers,
379
+ onChange: (headers) => set("headers", headers)
380
+ })] }),
381
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
382
+ label: "Environment variable names",
383
+ hint: "One name per line, such as ACME_TOKEN. Set the values where Studio and your agents run.",
384
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Textarea, {
385
+ className: "min-h-16 font-mono",
386
+ value: form.env,
387
+ spellCheck: false,
388
+ onChange: (event) => set("env", event.currentTarget.value)
389
+ })
390
+ }),
391
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Refusal, { children: checked.refusal }),
392
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormActions, {
393
+ pending: checked.pending,
394
+ action: previous ? "Apply" : "Add server"
395
+ })
396
+ ]
397
+ });
398
+ }
399
+ /** Each header is a name, an optional scheme prefix and the one variable holding its value. */
400
+ function HeaderRows({ rows, onChange }) {
401
+ const add = (0, import_react.useRef)(null);
402
+ const id = (0, import_react.useId)();
403
+ const change = (index, patch) => onChange(rows.map((row, at) => at === index ? {
404
+ ...row,
405
+ ...patch
406
+ } : row));
407
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("fieldset", {
408
+ className: "m-0 grid gap-1.5 border-0 p-0 text-sm",
409
+ children: [
410
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("legend", {
411
+ className: "mb-1.5 p-0",
412
+ children: "Headers"
413
+ }),
414
+ rows.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
415
+ className: "flex items-center gap-1.5",
416
+ children: [
417
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodeInput, {
418
+ className: "min-w-0 flex-1",
419
+ value: row.header,
420
+ placeholder: "Authorization",
421
+ "aria-label": `Header ${index + 1} name`,
422
+ onChange: (event) => change(index, { header: event.currentTarget.value })
423
+ }),
424
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Select, {
425
+ items: PREFIXES,
426
+ value: row.prefix || NO_PREFIX,
427
+ onValueChange: (next) => {
428
+ if (next !== null) change(index, { prefix: next === NO_PREFIX ? "" : next });
429
+ },
430
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectTrigger, {
431
+ className: "w-32 flex-none",
432
+ "aria-label": `Header ${index + 1} prefix`,
433
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectValue, {})
434
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectContent, { children: PREFIXES.map((prefix) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItem, {
435
+ value: prefix.value,
436
+ children: prefix.label
437
+ }, prefix.value)) })]
438
+ }),
439
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodeInput, {
440
+ className: "min-w-0 flex-1",
441
+ value: row.variable,
442
+ placeholder: "ACME_KEY",
443
+ "aria-label": `Header ${index + 1} variable name`,
444
+ onChange: (event) => change(index, { variable: event.currentTarget.value })
445
+ }),
446
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
447
+ variant: "ghost",
448
+ size: "icon",
449
+ "aria-label": `Remove header ${index + 1}`,
450
+ onClick: () => {
451
+ onChange(rows.filter((_, at) => at !== index));
452
+ add.current?.focus();
453
+ },
454
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "close" })
455
+ })
456
+ ]
457
+ }, `${id}-${index}`)),
458
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
459
+ ref: add,
460
+ size: "sm",
461
+ onClick: () => onChange([...rows, {
462
+ header: "",
463
+ prefix: "",
464
+ variable: ""
465
+ }]),
466
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
467
+ name: "plus",
468
+ className: "size-3.5"
469
+ }), "Add header"]
470
+ }) }),
471
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
472
+ className: "text-xs text-muted",
473
+ children: "A header's value is the prefix followed by the named variable."
474
+ })
475
+ ]
476
+ });
477
+ }
478
+ function GroupBody({ previous, ...body }) {
479
+ const { state } = body;
480
+ const servers = Object.keys(state.catalog?.servers ?? {});
481
+ const [name, setName] = (0, import_react.useState)(previous ?? "");
482
+ const [members, setMembers] = (0, import_react.useState)(() => (previous ? state.catalog?.groups?.[previous] : void 0) ?? []);
483
+ const checked = useCheckedEntry(body, "groups", previous);
484
+ const submit = (event) => {
485
+ event.preventDefault();
486
+ checked.submit(name.trim(), servers.filter((server) => members.includes(server)));
487
+ };
488
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
489
+ className: "grid gap-3.5",
490
+ onSubmit: submit,
491
+ children: [
492
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogHead, {
493
+ title: previous ? `Edit ${previous}` : "Add a group",
494
+ children: "A group lets a selection turn several servers on or off at once."
495
+ }),
496
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NameField, {
497
+ value: name,
498
+ placeholder: "acme-data",
499
+ onChange: (event) => setName(event.currentTarget.value)
500
+ }),
501
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("fieldset", {
502
+ className: "m-0 grid gap-1 border-0 p-0 text-sm",
503
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("legend", {
504
+ className: "mb-1.5 p-0",
505
+ children: "Servers"
506
+ }), servers.map((server) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
507
+ className: "inline-flex items-center gap-2 font-mono text-xs",
508
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
509
+ type: "checkbox",
510
+ checked: members.includes(server),
511
+ onChange: (event) => setMembers(event.currentTarget.checked ? [...members, server] : members.filter((member) => member !== server))
512
+ }), server]
513
+ }, server))]
514
+ }),
515
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Refusal, { children: checked.refusal }),
516
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormActions, {
517
+ pending: checked.pending,
518
+ action: previous ? "Apply" : "Add group"
519
+ })
520
+ ]
521
+ });
522
+ }
523
+ function DeleteBody({ entry, name, state, onApply, onClose }) {
524
+ const [references] = (0, import_react.useState)(() => referenceText(state, entry, name));
525
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogHead, {
526
+ title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
527
+ "Delete ",
528
+ KIND_WORD[entry],
529
+ " ",
530
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
531
+ className: "font-mono",
532
+ children: name
533
+ }),
534
+ "?"
535
+ ] }),
536
+ children: [
537
+ references ? `It is used by ${references}. Deleting it removes it there too.` : "No group or selection uses it.",
538
+ " ",
539
+ "Nothing is written until you save."
540
+ ]
541
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
542
+ className: "flex justify-end gap-2",
543
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogClose, {
544
+ render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, { variant: "ghost" }),
545
+ children: "Cancel"
546
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
547
+ variant: "danger",
548
+ onClick: () => {
549
+ onApply(withoutEntry(state, entry, name));
550
+ onClose();
551
+ },
552
+ children: [
553
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "trash" }),
554
+ "Delete ",
555
+ KIND_WORD[entry]
556
+ ]
557
+ })]
558
+ })] });
559
+ }
560
+ // src/views/mcp/mcp-view.tsx
561
+ /** The companion's MCP servers, groups and per-audience selection, edited as one unsaved draft. */
562
+ function Mcp({ companion, writable }) {
563
+ const query = useQuery(mcpManagerQuery(companion));
564
+ const filter = (0, import_react.useRef)(null);
565
+ const { button: addServer, retried } = useRetryFocus(query.isSuccess, writable ? void 0 : filter);
566
+ if (query.data) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(McpEditor, {
567
+ companion,
568
+ writable,
569
+ loaded: query.data,
570
+ addServer,
571
+ filter
572
+ });
573
+ if (!query.isError) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ViewLoading, { title: "Reading MCP servers…" });
574
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
575
+ className: cn(PAGE_PAD, "text-sm"),
576
+ role: "alert",
577
+ children: [
578
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
579
+ className: "m-0 text-bad",
580
+ children: "The MCP servers could not be read."
581
+ }),
582
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
583
+ className: "m-0 mt-1 text-muted",
584
+ children: query.error.message
585
+ }),
586
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
587
+ className: "mt-3",
588
+ onClick: () => {
589
+ retried();
590
+ query.refetch();
591
+ },
592
+ disabled: query.isFetching,
593
+ children: "Retry"
594
+ })
595
+ ]
596
+ });
597
+ }
598
+ var stateOf = ({ catalog, audiences }) => ({
599
+ catalog,
600
+ audiences
601
+ });
602
+ function McpEditor({ companion, writable, loaded, addServer, filter }) {
603
+ const queryClient = useQueryClient();
604
+ /** Unsaved edits and the read they started from; null while the view shows what was read. */
605
+ const [edit, setEdit] = (0, import_react.useState)(null);
606
+ const [conflict, setConflict] = (0, import_react.useState)(null);
607
+ const [saved, setSaved] = (0, import_react.useState)(false);
608
+ const [dialog, setDialog] = (0, import_react.useState)({
609
+ shown: null,
610
+ open: false
611
+ });
612
+ const opener = (0, import_react.useRef)(null);
613
+ useBlocker({
614
+ shouldBlockFn: () => !window.confirm("Discard unsaved changes?"),
615
+ disabled: edit === null
616
+ });
617
+ const base = edit?.base ?? loaded;
618
+ const draft = edit?.draft ?? stateOf(loaded);
619
+ const preview = useQuery({
620
+ ...mcpPreviewQuery(companion, draft),
621
+ enabled: edit !== null,
622
+ placeholderData: keepPreviousData
623
+ });
624
+ const checked = edit ? preview.data : void 0;
625
+ const derived = checked?.ok ? checked : base;
626
+ const invalid = checked?.ok === false ? checked.reason : null;
627
+ const show = (view) => {
628
+ queryClient.setQueryData(mcpManagerQuery(companion).queryKey, view);
629
+ setEdit(null);
630
+ setConflict(null);
631
+ requestAnimationFrame(() => addServer.current?.focus());
632
+ };
633
+ const save = useMutation({
634
+ mutationFn: (token) => saveMcpManager({ data: {
635
+ companion,
636
+ next: draft,
637
+ token
638
+ } }),
639
+ onSuccess: (result) => {
640
+ if (result.kind === "conflict") return setConflict(result.current);
641
+ show(result.view);
642
+ setSaved(true);
643
+ }
644
+ });
645
+ const apply = (next) => {
646
+ if (save.isError) save.reset();
647
+ setEdit({
648
+ base,
649
+ draft: next
650
+ });
651
+ setSaved(false);
652
+ };
653
+ const discard = (view) => {
654
+ save.reset();
655
+ show(view);
656
+ };
657
+ const editable = writable && !save.isPending;
658
+ const open = (shown) => (event) => {
659
+ opener.current = event.currentTarget;
660
+ setDialog({
661
+ shown,
662
+ open: true
663
+ });
664
+ };
665
+ const servers = Object.entries(draft.catalog?.servers ?? {});
666
+ const groups = Object.entries(draft.catalog?.groups ?? {});
667
+ const rowActions = (entry, name) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
668
+ className: "ml-auto flex flex-none items-center gap-1",
669
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
670
+ variant: "ghost",
671
+ size: "sm",
672
+ disabled: !editable,
673
+ "aria-label": `Edit ${name}`,
674
+ onClick: open({
675
+ kind: "form",
676
+ entry,
677
+ previous: name
678
+ }),
679
+ children: "Edit"
680
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
681
+ variant: "ghost",
682
+ size: "sm",
683
+ disabled: !editable,
684
+ "aria-label": `Delete ${name}`,
685
+ onClick: open({
686
+ kind: "delete",
687
+ entry,
688
+ name
689
+ }),
690
+ children: "Delete"
691
+ })]
692
+ });
693
+ const addButton = (entry, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
694
+ ref,
695
+ size: "sm",
696
+ disabled: !writable,
697
+ onClick: open({
698
+ kind: "form",
699
+ entry,
700
+ previous: null
701
+ }),
702
+ children: [
703
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
704
+ name: "plus",
705
+ className: "size-3.5"
706
+ }),
707
+ "Add ",
708
+ KIND_WORD[entry]
709
+ ]
710
+ });
711
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
712
+ className: cn(PAGE_PAD, "grid gap-3 pb-8"),
713
+ children: [
714
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SaveBar, {
715
+ writable,
716
+ dirty: edit !== null,
717
+ saved,
718
+ pending: save.isPending,
719
+ blocked: invalid !== null || conflict !== null,
720
+ error: invalid ?? (save.isError ? save.error.message || "The save failed." : null),
721
+ onSave: () => save.mutate(base.token),
722
+ onDiscard: () => discard(conflict ?? loaded)
723
+ }),
724
+ conflict ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Conflict, {
725
+ current: conflict,
726
+ pending: save.isPending,
727
+ onLoad: () => discard(conflict),
728
+ onOverwrite: () => save.mutate(conflict.token)
729
+ }) : null,
730
+ servers.length === 0 && groups.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(EmptyNote, {
731
+ className: "grid justify-items-start gap-3",
732
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "This companion declares no MCP servers. Add the first one to give its agents a tool." }), addButton("servers", addServer)]
733
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
734
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ListCard, {
735
+ title: "Servers",
736
+ count: servers.length,
737
+ hint: addButton("servers", addServer),
738
+ children: [
739
+ servers.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
740
+ className: "m-0 px-4 py-3 text-sm text-muted",
741
+ children: "No servers. The groups below have no server to turn on."
742
+ }) : null,
743
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
744
+ className: "m-0 list-none p-0",
745
+ children: servers.map(([name, server]) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
746
+ className: ROW_LINE,
747
+ "data-mcp-server": name,
748
+ children: [
749
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
750
+ className: "w-40 flex-none truncate font-mono text-sm",
751
+ children: name
752
+ }),
753
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
754
+ className: "w-12 flex-none text-xs text-muted",
755
+ children: transportOf(server)
756
+ }),
757
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
758
+ className: "min-w-0 flex-1 truncate font-mono text-xs",
759
+ children: "command" in server ? [server.command, ...server.args ?? []].join(" ") : server.url
760
+ }),
761
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Variables, { statuses: derived.variables[name] ?? [] }),
762
+ rowActions("servers", name)
763
+ ]
764
+ }, name))
765
+ }),
766
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
767
+ className: "m-0 border-t border-rule-soft px-4 py-2 text-xs text-muted",
768
+ children: "Set and missing describe the environment of this Studio process, which the sessions it starts inherit. A variable set only for a session elsewhere shows as missing. Values never reach this page."
769
+ })
770
+ ]
771
+ }),
772
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListCard, {
773
+ title: "Groups",
774
+ count: groups.length,
775
+ hint: addButton("groups"),
776
+ children: groups.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
777
+ className: "m-0 px-4 py-3 text-sm text-muted",
778
+ children: "No groups. A group lets a selection turn several servers on or off at once."
779
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
780
+ className: "m-0 list-none p-0",
781
+ children: groups.map(([name, members]) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
782
+ className: ROW_LINE,
783
+ children: [
784
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
785
+ className: "w-40 flex-none truncate font-mono text-sm",
786
+ children: name
787
+ }),
788
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
789
+ className: "min-w-0 flex-1 truncate font-mono text-xs",
790
+ children: members.length > 0 ? members.join(", ") : "no servers"
791
+ }),
792
+ rowActions("groups", name)
793
+ ]
794
+ }, name))
795
+ })
796
+ }),
797
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectionGrid, {
798
+ state: draft,
799
+ effective: derived.effective,
800
+ stale: edit !== null && (preview.isPlaceholderData || !checked?.ok),
801
+ writable: editable,
802
+ filterRef: filter,
803
+ onChange: apply
804
+ })
805
+ ] }),
806
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(McpDialogs, {
807
+ dialog: dialog.shown,
808
+ open: dialog.open,
809
+ companion,
810
+ state: draft,
811
+ onApply: apply,
812
+ onClose: () => setDialog((held) => ({
813
+ ...held,
814
+ open: false
815
+ })),
816
+ finalFocus: () => opener.current?.isConnected ? opener.current : addServer.current
817
+ })
818
+ ]
819
+ });
820
+ }
821
+ var ROW_LINE = cn(ROW, "py-1.5 hover:bg-transparent");
822
+ function Variables({ statuses }) {
823
+ if (statuses.length === 0) return null;
824
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
825
+ className: "flex flex-none flex-wrap items-center gap-x-3 gap-y-1",
826
+ children: statuses.map(({ name, set }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
827
+ className: "inline-flex items-center gap-2 font-mono text-xs",
828
+ children: [name, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusWord, {
829
+ marker: set ? "done" : "warn",
830
+ children: set ? "set" : "missing"
831
+ })]
832
+ }, name))
833
+ });
834
+ }
835
+ function SaveBar({ writable, dirty, saved, pending, blocked, error, onSave, onDiscard }) {
836
+ if (!writable) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
837
+ className: "m-0 text-sm text-muted",
838
+ "data-mcp-read-only": "",
839
+ children: [
840
+ "Studio is read-only. Start it with ",
841
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
842
+ className: "font-mono",
843
+ children: "--writable"
844
+ }),
845
+ " to change MCP servers."
846
+ ]
847
+ });
848
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
849
+ className: "flex flex-wrap items-center gap-x-3 gap-y-1.5",
850
+ children: [
851
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
852
+ className: "m-0 mr-auto text-sm text-muted",
853
+ role: "status",
854
+ children: dirty ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
855
+ className: "inline-flex items-center gap-1.5 text-warn",
856
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
857
+ className: "size-[7px] rounded-full bg-current",
858
+ "aria-hidden": "true"
859
+ }), "Unsaved changes"]
860
+ }) : saved ? "Saved. The changes apply at the next sync or launch." : "Changes are written to framework.yaml when you save."
861
+ }),
862
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
863
+ variant: "ghost",
864
+ size: "sm",
865
+ disabled: !dirty || pending,
866
+ onClick: onDiscard,
867
+ children: "Discard"
868
+ }),
869
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
870
+ variant: "primary",
871
+ size: "sm",
872
+ disabled: !dirty || pending || blocked,
873
+ onClick: onSave,
874
+ children: pending ? "Saving…" : "Save"
875
+ }),
876
+ error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
877
+ className: "m-0 basis-full text-sm text-bad",
878
+ role: "alert",
879
+ children: error
880
+ }) : null
881
+ ]
882
+ });
883
+ }
884
+ /** A stale save: the file's current content beside the kept edits, and the two ways on. */
885
+ function Conflict({ current, pending, onLoad, onOverwrite }) {
886
+ const servers = Object.keys(current.catalog?.servers ?? {});
887
+ const groups = Object.keys(current.catalog?.groups ?? {});
888
+ const load = (0, import_react.useRef)(null);
889
+ (0, import_react.useEffect)(() => {
890
+ if (!pending) load.current?.focus();
891
+ }, [pending]);
892
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
893
+ className: "grid gap-2 rounded-card border border-[color-mix(in_srgb,var(--warn)_40%,var(--border))] bg-warn-soft px-4 py-3 text-sm",
894
+ role: "alert",
895
+ "aria-label": "Save conflict",
896
+ "data-mcp-conflict": "",
897
+ children: [
898
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
899
+ className: "m-0 text-base font-semibold text-warn",
900
+ children: "framework.yaml changed after this view loaded"
901
+ }),
902
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
903
+ className: "m-0",
904
+ children: "Nothing was saved. Your edits are still in the view below."
905
+ }),
906
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", {
907
+ className: "m-0 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-3 gap-y-1",
908
+ children: [
909
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConflictLine, {
910
+ label: "Servers in the file",
911
+ names: servers
912
+ }),
913
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConflictLine, {
914
+ label: "Groups in the file",
915
+ names: groups
916
+ }),
917
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConflictLine, {
918
+ label: "Base servers in the file",
919
+ names: current.effective.base
920
+ })
921
+ ]
922
+ }),
923
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
924
+ className: "flex flex-wrap gap-2",
925
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
926
+ ref: load,
927
+ size: "sm",
928
+ disabled: pending,
929
+ onClick: onLoad,
930
+ children: "Discard my edits and load the file"
931
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
932
+ size: "sm",
933
+ variant: "danger",
934
+ disabled: pending,
935
+ onClick: onOverwrite,
936
+ children: "Overwrite the file with my edits"
937
+ })]
938
+ })
939
+ ]
940
+ });
941
+ }
942
+ function ConflictLine({ label, names }) {
943
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", {
944
+ className: "text-muted",
945
+ children: label
946
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", {
947
+ className: "m-0 min-w-0 font-mono text-xs break-words",
948
+ children: names.length > 0 ? names.join(", ") : "none"
949
+ })] });
950
+ }
951
+ var ON = "border-accent bg-accent-soft font-semibold text-text";
952
+ var QUIET = "border-transparent text-muted";
953
+ var CELL_VIEW = {
954
+ enabled: {
955
+ word: "Enabled",
956
+ look: ON,
957
+ icon: "check"
958
+ },
959
+ enable: {
960
+ word: "Enable",
961
+ look: ON,
962
+ icon: "check"
963
+ },
964
+ disable: {
965
+ word: "Disable",
966
+ look: "border-rule bg-surface font-semibold text-text",
967
+ icon: "close"
968
+ },
969
+ off: {
970
+ word: "Off",
971
+ look: QUIET
972
+ },
973
+ inherit: {
974
+ word: "Inherit",
975
+ look: QUIET
976
+ }
977
+ };
978
+ var HEAD_CELL = "sticky top-0 z-10 border-b border-rule bg-surface px-3 py-2 text-left text-xs font-semibold whitespace-nowrap";
979
+ var NAME_CELL = "sticky left-0 border-t border-rule-soft bg-page px-4 py-1.5 text-left font-normal";
980
+ /**
981
+ * Base and each audience against every server and group. A base cell is enabled or off; an
982
+ * audience cell inherits the base, or enables or disables on top of it. The last row is what
983
+ * core resolves for the column.
984
+ */
985
+ function SelectionGrid({ state, effective, stale, writable, filterRef, onChange }) {
986
+ const [filter, setFilter] = (0, import_react.useState)("");
987
+ const needle = filter.trim().toLowerCase();
988
+ const rows = ["servers", "groups"].flatMap((kind) => Object.keys(state.catalog?.[kind] ?? {}).filter((name) => name.toLowerCase().includes(needle)).map((name) => ({
989
+ kind,
990
+ name
991
+ })));
992
+ const columns = [null, ...Object.keys(state.audiences)];
993
+ const cell = (kind, name, audience) => {
994
+ const held = cellOf(state, audience, kind, name);
995
+ const { word, look, icon } = CELL_VIEW[held];
996
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
997
+ className: "border-t border-rule-soft px-3 py-1",
998
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
999
+ type: "button",
1000
+ className: cn("inline-flex h-7 min-w-24 items-center gap-1.5 rounded-control border px-2 text-xs transition-colors enabled:hover:border-accent disabled:cursor-not-allowed", look),
1001
+ disabled: !writable,
1002
+ "aria-label": `${name} for ${audience ?? "base"}: ${word}`,
1003
+ "data-mcp-cell": `${audience ?? "base"}/${name}`,
1004
+ "data-state": held,
1005
+ onClick: () => onChange(cycleCell(state, audience, kind, name)),
1006
+ children: [icon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
1007
+ name: icon,
1008
+ className: "size-3.5"
1009
+ }) : null, word]
1010
+ })
1011
+ }, audience ?? "");
1012
+ };
1013
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ListCard, {
1014
+ title: "Selection",
1015
+ hint: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
1016
+ ref: filterRef,
1017
+ className: "h-7 w-48",
1018
+ value: filter,
1019
+ placeholder: "Filter by name",
1020
+ "aria-label": "Filter servers and groups by name",
1021
+ onChange: (event) => setFilter(event.currentTarget.value)
1022
+ }),
1023
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1024
+ className: "max-h-[60vh] overflow-auto",
1025
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", {
1026
+ className: "w-full border-separate border-spacing-0 text-sm",
1027
+ children: [
1028
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
1029
+ scope: "col",
1030
+ className: cn(HEAD_CELL, "left-0 z-20 px-4"),
1031
+ children: "Server or group"
1032
+ }), columns.map((audience) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
1033
+ scope: "col",
1034
+ className: HEAD_CELL,
1035
+ children: audience === null ? "Base" : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1036
+ className: "font-mono",
1037
+ children: audience
1038
+ })
1039
+ }, audience ?? ""))] }) }),
1040
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tbody", { children: [rows.map(({ kind, name }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("th", {
1041
+ scope: "row",
1042
+ className: NAME_CELL,
1043
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1044
+ className: "font-mono text-sm",
1045
+ children: name
1046
+ }), kind === "groups" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1047
+ className: "ml-2 text-xs text-muted",
1048
+ children: "group"
1049
+ }) : null]
1050
+ }), columns.map((audience) => cell(kind, name, audience))] }, `${kind}/${name}`)), rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
1051
+ colSpan: columns.length + 1,
1052
+ className: "px-4 py-3 text-sm text-muted",
1053
+ children: "No server or group matches the filter."
1054
+ }) }) : null] }),
1055
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tfoot", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
1056
+ "aria-busy": stale,
1057
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
1058
+ scope: "row",
1059
+ className: cn(NAME_CELL, "border-rule align-top font-semibold"),
1060
+ children: "Effective servers"
1061
+ }), columns.map((audience) => {
1062
+ const names = audience === null ? effective.base : effective.audiences[audience];
1063
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
1064
+ className: cn("border-t border-rule px-3 py-2 align-top font-mono text-xs", stale && "opacity-60"),
1065
+ children: names && names.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
1066
+ className: "m-0 grid list-none gap-0.5 p-0",
1067
+ children: names.map((name) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: name }, name))
1068
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1069
+ className: "font-sans text-muted",
1070
+ children: "none"
1071
+ })
1072
+ }, audience ?? "");
1073
+ })]
1074
+ }) })
1075
+ ]
1076
+ })
1077
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
1078
+ className: "m-0 border-t border-rule-soft px-4 py-2 text-xs text-muted",
1079
+ children: [
1080
+ "Base applies to every session. An audience column applies on top of it to sessions started with ",
1081
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
1082
+ className: "font-mono",
1083
+ children: "MATE_AUDIENCE"
1084
+ }),
1085
+ " set to that audience. A sync writes the base servers plus the active audience's changes."
1086
+ ]
1087
+ })]
1088
+ });
1089
+ }
1090
+ // src/routes/mcp.tsx?tsr-split=component
1091
+ var SplitComponent = function McpRoute() {
1092
+ const search = Route.useSearch();
1093
+ const { data: shell } = useSuspenseQuery(shellQuery({
1094
+ companion: search.companion,
1095
+ studioMode: search.studioMode
1096
+ }));
1097
+ if (!search.companion || !shell.selected) return null;
1098
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Mcp, {
1099
+ companion: search.companion,
1100
+ writable: shell.writable
1101
+ }, search.companion);
1102
+ };
1103
+ export { SplitComponent as component };