@uniqbit/mate-core 1.0.0-canary.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
- package/package.json +5 -4
- package/src/cli/commands/artifact/delivery/link.ts +1 -1
- package/src/cli/commands/artifact/delivery/output.ts +10 -1
- package/src/cli/commands/artifact/delivery/resolve.ts +3 -2
- package/src/cli/commands/artifact/delivery/submit.ts +9 -4
- package/src/cli/commands/artifact/delivery/take.ts +12 -9
- package/src/cli/commands/artifact/finish/command.ts +16 -14
- package/src/cli/commands/artifact/finish/engine.ts +8 -8
- package/src/cli/commands/artifact/project/command.ts +2 -3
- package/src/cli/commands/companion/hub.ts +11 -6
- package/src/cli/commands/companion/link.ts +173 -46
- package/src/cli/commands/doctor.ts +17 -0
- package/src/cli/commands/report/contract.ts +0 -17
- package/src/cli/commands/studio/access.ts +4 -0
- package/src/cli/commands/studio/actions.ts +35 -2
- package/src/cli/commands/studio/mcp-manager.ts +162 -0
- package/src/cli/commands/studio/routes.ts +12 -0
- package/src/cli/commands/studio/selection.ts +44 -11
- package/src/cli/commands/studio/server.ts +246 -2
- package/src/cli/commands/studio/services.ts +26 -0
- package/src/cli/commands/studio/terminal-launch.ts +21 -4
- package/src/cli/commands/studio/terminal.ts +3 -14
- package/src/cli/commands/studio/work-requests.ts +9 -0
- package/src/cli/commands/studio/work.ts +473 -0
- package/src/cli/commands/vscode/release-vsix.json +2 -2
- package/src/cli/commands/working/cleanup.ts +1 -18
- package/src/cli/companion-link-wizard.tsx +158 -91
- package/src/cli/usage.ts +1 -1
- package/src/create-mate.ts +4 -1
- package/src/lib/agent-credential.ts +131 -0
- package/src/lib/credential-kinds.ts +7 -0
- package/src/lib/delivery/merge-git.ts +16 -0
- package/src/lib/delivery/record-delivery.ts +12 -6
- package/src/lib/delivery/record.ts +5 -0
- package/src/lib/delivery/refresh.ts +34 -6
- package/src/lib/delivery/staging/refs.ts +9 -4
- package/src/lib/delivery/staging/submit.ts +81 -22
- package/src/lib/mcp-manager/resolve.ts +88 -0
- package/src/lib/mcp-manager/store.ts +133 -0
- package/src/lib/mcp-manager/types.ts +72 -0
- package/src/lib/mcp-manager/validate.ts +242 -0
- package/src/lib/opencode-server.ts +2 -17
- package/src/lib/orchestrator/config-store.ts +30 -7
- package/src/lib/orchestrator/engine-floor.ts +16 -4
- package/src/lib/orchestrator/engine-guard.ts +7 -1
- package/src/lib/orchestrator/repo-local-store.ts +14 -0
- package/src/lib/orchestrator/repository-link.ts +80 -52
- package/src/lib/orchestrator/root-context.ts +17 -1
- package/src/lib/orchestrator/types.ts +4 -0
- package/src/lib/studio-chat/agent.ts +139 -0
- package/src/lib/studio-chat/companion-context.ts +136 -0
- package/src/lib/studio-chat/credential.ts +79 -0
- package/src/lib/studio-chat/harness-chat-agent.ts +334 -0
- package/src/lib/studio-chat/host-sandbox.ts +578 -0
- package/src/lib/studio-chat/prepare-bridges.ts +95 -0
- package/src/lib/studio-chat/session.ts +15 -0
- package/src/lib/studio-chat/turns.ts +112 -0
- package/src/lib/workset/claims.ts +85 -0
- package/src/lib/workset/execution.ts +71 -0
- package/src/lib/workset/git-transaction.ts +74 -0
- package/src/lib/workset/groups.ts +176 -0
- package/src/lib/workset/inventory.ts +196 -0
- package/src/lib/workset/projection.ts +237 -0
- package/src/lib/workset/record.ts +101 -36
- package/src/lib/workset/repositories.ts +24 -0
- package/src/lib/workset/sharing.ts +951 -0
- package/src/lib/workset/stages.ts +50 -14
- package/src/lib/workset/transactions.ts +158 -0
- package/src/runtime/companion-git-state.ts +1 -0
- package/src/runtime/companion-guidance.ts +2 -2
- package/src/runtime/forge-remote.ts +6 -0
- package/src/runtime/host-process.ts +28 -0
- package/src/runtime/secret-guard.ts +18 -1
- package/src/runtime/secret-patterns.ts +4 -3
- package/src/runtime/submitted-arrivals.ts +28 -2
- package/src/runtime/workflow/turn.ts +14 -12
- package/src/runtime/write-atomic.ts +2 -2
- package/src/studio.ts +61 -0
- package/src/templates/capabilities/openspec-cap/mate-full/schema.yaml +1 -1
- package/src/templates/capabilities/openspec-cap/mate-full/templates/proposal.md +1 -1
- package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +3 -2
- package/src/templates/mate-skills/agents/mate-submit-change/SKILL.md +5 -3
- package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +3 -2
- package/src/templates/mate-skills/claude/mate-submit-change/SKILL.md +5 -3
- package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +12 -12
- package/src/tools/setup/capabilities/mcp-manager.ts +73 -0
- package/src/tools/setup/context-services.ts +35 -6
- package/src/tools/setup/dynamic-plugins/audiences.ts +3 -2
- package/src/tools/setup/dynamic-plugins/declarations.ts +0 -26
- package/src/tools/setup/engine.ts +55 -3
- package/src/tools/setup/plugin.ts +14 -0
- package/src/tools/setup/plugins/gitignore.ts +1 -0
- package/src/tools/setup/providers/claude-format.ts +40 -7
- package/src/tools/setup/providers/claude.ts +38 -3
- package/src/tools/setup/providers/opencode-format.ts +13 -3
- package/src/tools/setup/providers/opencode.ts +7 -18
- package/src/tools/setup/providers/relative-path-warnings.ts +26 -0
- package/studio-dist/THIRD-PARTY-NOTICES.md +297 -0
- package/studio-dist/client/THIRD-PARTY-LICENSES.md +4294 -0
- package/studio-dist/client/assets/DialogTitle-DOhjDa7H.js +1 -0
- package/studio-dist/client/assets/app-CG3vCgyA.css +2 -0
- package/studio-dist/client/assets/bundle-mjs-CdK3cBzO.js +1 -0
- package/studio-dist/client/assets/button-upSzkd-q.js +1 -0
- package/studio-dist/client/assets/chat-DbaMXb8H.js +157 -0
- package/studio-dist/client/assets/cn-BCnYnarL.js +1 -0
- package/studio-dist/client/assets/combobox-cP9OsRf2.js +1 -0
- package/studio-dist/client/assets/{companion-view-C_N237bf.js → companion-view-B54_Lj0S.js} +1 -1
- package/studio-dist/client/assets/fields-DNZ4a89M.js +1 -0
- package/studio-dist/client/assets/friction-DgEimeDB.js +1 -0
- package/studio-dist/client/assets/getting-started-BTfYCt5s.js +1 -0
- package/studio-dist/client/assets/{getting-started-djaQeWlu.js → getting-started-CAszmdDJ.js} +1 -1
- package/studio-dist/client/assets/getting-started._topic-CHJMf0pa.js +1 -0
- package/studio-dist/client/assets/getting-started.index-MR6HftWs.js +1 -0
- package/studio-dist/client/assets/{graph-canvas-ySGKMhmk.js → graph-canvas-BdNk2F9O.js} +1 -1
- package/studio-dist/client/assets/graph-hRijsC89.js +2 -0
- package/studio-dist/client/assets/guides-CwFnh08E.js +1 -0
- package/studio-dist/client/assets/highlighted-body-JLMTFACH-BcroQey-.js +1 -0
- package/studio-dist/client/assets/index-D5oGyvG8.js +41 -0
- package/studio-dist/client/assets/{markdown-view-jMiaBTSO.js → markdown-view-CJ8JsLb7.js} +1 -1
- package/studio-dist/client/assets/marked.esm-vFuq1cCd.js +65 -0
- package/studio-dist/client/assets/mcp-BE9M-bkO.js +4 -0
- package/studio-dist/client/assets/mermaid-WFAXDIZX-BjSsakrn.js +1 -0
- package/studio-dist/client/assets/panel-CDQ6Lryw.js +1 -0
- package/studio-dist/client/assets/plugins._service._view-DRVPUAWN.js +1 -0
- package/studio-dist/client/assets/{prepaint-CKsXyJOR.js → prepaint-sD_LlrDN.js} +1 -1
- package/studio-dist/client/assets/{queries-Dfp5deWj.js → queries-COL925ML.js} +1 -1
- package/studio-dist/client/assets/react-dom-K3Hp2Cdj.js +1 -0
- package/studio-dist/client/assets/{react-BYUSgtBs.js → react-h2xQ_NSp.js} +1 -1
- package/studio-dist/client/assets/reports-BClsojkb.js +1 -0
- package/studio-dist/client/assets/routes-CJQ2MAej.js +1 -0
- package/studio-dist/client/assets/search-DhWdEiKT.js +1 -0
- package/studio-dist/client/assets/select-B2FsN9FY.js +1 -0
- package/studio-dist/client/assets/skills-SoUHk77W.js +1 -0
- package/studio-dist/client/assets/{specs-BrCOjOch.js → specs-C_tZnAvF.js} +1 -1
- package/studio-dist/client/assets/specs-view-C6t3Y5IT.js +1 -0
- package/studio-dist/client/assets/steps-CF3-Zpmh.js +1 -0
- package/studio-dist/client/assets/{store-C3vJq8Wj.js → store-pY9gU4uS.js} +1 -1
- package/studio-dist/client/assets/studio-X7bnFrRe.js +36 -0
- package/studio-dist/client/assets/studio-queries-CKtAnIKP.js +2 -0
- package/studio-dist/client/assets/usage-BaaqUpTG.js +55 -0
- package/studio-dist/client/assets/useAnchoredPopupScrollLock-BspHR7Wt.js +1 -0
- package/studio-dist/client/assets/useBlocker-BQOfcu_f.js +1 -0
- package/studio-dist/client/assets/useMutation-DKeEoP5S.js +1 -0
- package/studio-dist/client/assets/useOpenInteractionType-CtaZCaFT.js +1 -0
- package/studio-dist/client/assets/usePopupHandleStore-Bc7Q4bnF.js +1 -0
- package/studio-dist/client/assets/vault-sAPFUnPN.js +1 -0
- package/studio-dist/client/assets/{warnings-CqOOGlPD.js → warnings-D7YY1HSG.js} +1 -1
- package/studio-dist/client/assets/work-BZek_LGB.js +5 -0
- package/studio-dist/client/assets/workflow-N5boHXFz.js +1 -0
- package/studio-dist/server/THIRD-PARTY-LICENSES.md +4371 -0
- package/studio-dist/server/assets/DialogTitle-DnKSl2V0.js +421 -0
- package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-gVfW5vIV.js → __23tanstack-start-server-fn-resolver-Bli9bpSB.js} +38 -18
- package/studio-dist/server/assets/_tanstack-start-manifest_v.js +91 -59
- package/studio-dist/server/assets/{actions-D8erOphH.js → actions-CHEFA1i9.js} +33 -1
- package/studio-dist/server/assets/{cn-FXJAM0KO.js → bundle-mjs-Ot6dQ8Pq.js} +1 -2056
- package/studio-dist/server/assets/{button-D6bvrFmm.js → button-BqA1urbl.js} +14 -7
- package/studio-dist/server/assets/chat-zl332Tvu.js +49486 -0
- package/studio-dist/server/assets/cn-B0fl6NWK.js +2057 -0
- package/studio-dist/server/assets/{combobox-D2MbYV1O.js → combobox-iTjvPCtS.js} +7 -6
- package/studio-dist/server/assets/{companion-view-Mf1ANbMb.js → companion-view-DIQ6AFIY.js} +2 -2
- package/studio-dist/server/assets/{companions-Dr6IpNAb.js → companions-aVwjRL8j.js} +1 -1
- package/studio-dist/server/assets/{fields-B4mAPETz.js → fields-BMap2_Ju.js} +10 -3
- package/studio-dist/server/assets/{friction-CWOTjpCV.js → friction-BER50hoD.js} +2 -2
- package/studio-dist/server/assets/{friction-9a5S1m7U.js → friction-BPs9KWdq.js} +8 -8
- package/studio-dist/server/assets/{getting-started-RU6tYU2Q.js → getting-started-DGfRVmZ_.js} +2 -2
- package/studio-dist/server/assets/{getting-started._topic-C02HGrC6.js → getting-started._topic-BgrBA4Vj.js} +2 -2
- package/studio-dist/server/assets/{getting-started.index-EzLRosbb.js → getting-started.index-BaFfQ9Mn.js} +2 -2
- package/studio-dist/server/assets/{graph-CZ2H9Fzr.js → graph-Cgzlrv3P.js} +8 -8
- package/studio-dist/server/assets/{graph-B11ITte0.js → graph-DODpuOy_.js} +1 -1
- package/studio-dist/server/assets/{graph-canvas-rP5TT14Z.js → graph-canvas-DW_zU1nA.js} +2 -2
- package/studio-dist/server/assets/{guides-BGftp4wf.js → guides-CA_EMG7E.js} +1 -1
- package/studio-dist/server/assets/{guides-B8HdeK_C.js → guides-D0SpoD32.js} +1 -1
- package/studio-dist/server/assets/{guides.server-DqFQAStf.js → guides.server-DJjQuy03.js} +1 -1
- package/studio-dist/server/assets/highlighted-body-JLMTFACH-BeHllu-r.js +41 -0
- package/studio-dist/server/assets/{markdown-view-CArpV-CS.js → markdown-view-CvVBGMZV.js} +1 -1
- package/studio-dist/server/assets/mcp-BU0fLYyJ.js +1103 -0
- package/studio-dist/server/assets/mcp-manager-D9YctTQe.js +50 -0
- package/studio-dist/server/assets/mermaid-WFAXDIZX-B1yDN6vG.js +1 -0
- package/studio-dist/server/assets/{panel-DR0iq46J.js → panel-D1K6Bsux.js} +4 -32
- package/studio-dist/server/assets/{plugins._service._view-n7u2k5dF.js → plugins._service._view-DdO1nELF.js} +4 -4
- package/studio-dist/server/assets/{prepaint-B28ClcPN.js → prepaint-BB3dwSmz.js} +1 -1
- package/studio-dist/server/assets/{queries-D-yVP9i0.js → queries-BwiDxQy5.js} +1 -1
- package/studio-dist/server/assets/{react-CiBZPDs8.js → react-B2cLiz-i.js} +1 -1
- package/studio-dist/server/assets/{reports-C2SmTgqh.js → reports-9Pr7Bz6o.js} +7 -7
- package/studio-dist/server/assets/{reports-B9k98oE6.js → reports-Cc9M3phM.js} +1 -1
- package/studio-dist/server/assets/{router-CPt0TAk_.js → router-DcWe0J7Y.js} +827 -548
- package/studio-dist/server/assets/{routes-CwH8LEy2.js → routes-BEXxl0py.js} +8 -8
- package/studio-dist/server/assets/{search-b-yQesv3.js → search-bltT7gwy.js} +39 -7
- package/studio-dist/server/assets/{select-C3i6TTX-.js → select-CZvHgGCi.js} +7 -6
- package/studio-dist/server/assets/{shell-CagqZZMZ.js → shell-BQ0vMKXN.js} +13 -4
- package/studio-dist/server/assets/{skills-DGg0mWDM.js → skills-Be_52h0i.js} +1 -1
- package/studio-dist/server/assets/{skills-C21Mg_8-.js → skills-BpGGUl6L.js} +8 -8
- package/studio-dist/server/assets/{specs-DetoMiaB.js → specs-CCGgXE-V.js} +5 -5
- package/studio-dist/server/assets/{specs-view-CmbfLDwN.js → specs-view-DtL5JxYM.js} +12 -11
- package/studio-dist/server/assets/{steps-D1tYAyWZ.js → steps-BWFSO6dM.js} +1 -1
- package/studio-dist/server/assets/{store-aC-I6f6o.js → store-X7yLPp7v.js} +1 -1
- package/studio-dist/server/assets/{studio-queries-Dqf-3nzj.js → studio-queries-ur1ygXi3.js} +117 -13
- package/studio-dist/server/assets/{studio-qRvQjRpz.js → studio-qzH-UETC.js} +1555 -179
- package/studio-dist/server/assets/{usage-Cwle9-xY.js → usage-C1o0DLzS.js} +1 -1
- package/studio-dist/server/assets/{usage-CS4CBK9D.js → usage-DWbSPrPD.js} +10 -9
- package/studio-dist/server/assets/{useAnchoredPopupScrollLock-BjMNgXv9.js → useAnchoredPopupScrollLock-DLDmv6kM.js} +4 -135
- package/studio-dist/server/assets/useBlocker-CQtANHK8.js +111 -0
- package/studio-dist/server/assets/{useMutation-DpBIuWXt.js → useMutation-NjlA8oFY.js} +2 -2
- package/studio-dist/server/assets/useOpenInteractionType-CZYscfOb.js +136 -0
- package/studio-dist/server/assets/usePopupHandleStore-DEEXJYv0.js +26 -0
- package/studio-dist/server/assets/{vault-CEBBRLMb.js → vault-B_kfi1h-.js} +1 -1
- package/studio-dist/server/assets/{vault-DVQidlId.js → vault-dL79JlKH.js} +8 -115
- package/studio-dist/server/assets/{views-UgO0Qz_g.js → views-BSGH56lb.js} +3 -3
- package/studio-dist/server/assets/{warnings-C7hgXpdk.js → warnings-DtUVPV-k.js} +2 -2
- package/studio-dist/server/assets/work-D789VXGH.js +110 -0
- package/studio-dist/server/assets/work-DsCEfhmK.js +3817 -0
- package/studio-dist/server/assets/work-requests-BLhOmQFO.js +11 -0
- package/studio-dist/server/assets/{workflow-6dZZ1ofw.js → workflow-BOZ2sRYg.js} +9 -9
- package/studio-dist/server/server.js +3 -3
- package/wrappers/bin/openspec +87 -2
- package/studio-dist/client/assets/app-ggXJ_QVh.css +0 -2
- package/studio-dist/client/assets/button-amJ3g5oD.js +0 -1
- package/studio-dist/client/assets/cn-BQPKiwI4.js +0 -1
- package/studio-dist/client/assets/combobox-CJ7aGFid.js +0 -1
- package/studio-dist/client/assets/fields-BAiGkJ5N.js +0 -1
- package/studio-dist/client/assets/friction-DqOU59v7.js +0 -1
- package/studio-dist/client/assets/getting-started-yp42dj5S.js +0 -1
- package/studio-dist/client/assets/getting-started._topic-C9zVXz_m.js +0 -1
- package/studio-dist/client/assets/getting-started.index-DWbDKICP.js +0 -1
- package/studio-dist/client/assets/graph-BYaD_5Bq.js +0 -2
- package/studio-dist/client/assets/guides-D6T6W_jV.js +0 -1
- package/studio-dist/client/assets/index-Qx7reRPD.js +0 -40
- package/studio-dist/client/assets/panel-C4bf_h2W.js +0 -1
- package/studio-dist/client/assets/plugins._service._view-y6f2FDAB.js +0 -1
- package/studio-dist/client/assets/reports-JFSwSueq.js +0 -1
- package/studio-dist/client/assets/routes-BdOWSgzK.js +0 -1
- package/studio-dist/client/assets/search-CXosfvYh.js +0 -1
- package/studio-dist/client/assets/select-BHYYWPhK.js +0 -1
- package/studio-dist/client/assets/skills-Bo9FLsBd.js +0 -1
- package/studio-dist/client/assets/specs-view-CdE2rlli.js +0 -1
- package/studio-dist/client/assets/steps-CKUno4lh.js +0 -1
- package/studio-dist/client/assets/studio-0ueISxwP.js +0 -100
- package/studio-dist/client/assets/studio-queries-BflKt9va.js +0 -2
- package/studio-dist/client/assets/usage-BLsLy0nN.js +0 -55
- package/studio-dist/client/assets/useAnchoredPopupScrollLock-DC7f8GOp.js +0 -1
- package/studio-dist/client/assets/useMutation-uJUrejsi.js +0 -1
- package/studio-dist/client/assets/vault-BB1B_OhR.js +0 -1
- package/studio-dist/client/assets/workflow-BFzmI-06.js +0 -1
|
@@ -0,0 +1,1103 @@
|
|
|
1
|
+
import { $ as DialogContent, Lt as useSuspenseQuery, P as useRetryFocus, Q as DialogClose, Rt as useQuery, Z as Dialog, et as DialogDescription, f as Route, h as saveMcpManager, m as mcpPreviewQuery, p as mcpManagerQuery, tt as DialogTitle } from "./router-DcWe0J7Y.js";
|
|
2
|
+
import { K as keepPreviousData, d as shellQuery } from "./studio-queries-ur1ygXi3.js";
|
|
3
|
+
import { t as useMutation } from "./useMutation-NjlA8oFY.js";
|
|
4
|
+
import { p as useQueryClient, t as cn } from "./cn-B0fl6NWK.js";
|
|
5
|
+
import { t as useBlocker } from "./useBlocker-CQtANHK8.js";
|
|
6
|
+
import { n as require_react, o as __toESM, t as require_jsx_runtime } from "./jsx-runtime-Bt0s0YKS.js";
|
|
7
|
+
import { 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-BqA1urbl.js";
|
|
8
|
+
import { i as Textarea, t as Input } from "./fields-BMap2_Ju.js";
|
|
9
|
+
import { n as MCP_MANAGER_TRANSPORTS, r as parseHeaderRef, t as MCP_MANAGER_HEADER_PREFIXES } from "./studio-qzH-UETC.js";
|
|
10
|
+
import { a as Select, c as SelectTrigger, l as SelectValue, o as SelectContent, s as SelectItem } from "./select-CZvHgGCi.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 Studio runs in, 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 };
|