@bevel-software/platform-core-frontend 0.7.4 → 0.8.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/LICENSE +202 -202
- package/THIRD-PARTY-NOTICES.md +344 -988
- package/package.json +5 -5
- package/src/core/CoreAppShell.tsx +4 -4
- package/src/core/__tests__/ShellRoutes.test.tsx +1 -1
- package/src/core/__tests__/bootstrap.test.ts +47 -2
- package/src/core/bootstrap.ts +20 -0
- package/src/css-side-effect-imports.d.ts +7 -7
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +1 -1
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +5 -5
- package/src/modules/access/api.ts +5 -5
- package/src/modules/access/components/ManageAccessDialog.tsx +21 -20
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
- package/src/modules/admin/components/AdminRolesPage.tsx +1 -1
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +2 -2
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +1 -1
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +1 -1
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +4 -4
- package/src/modules/layout/__tests__/SidebarToggle.test.tsx +4 -4
- package/src/modules/layout/__tests__/breakpoints.test.ts +1 -1
- package/src/modules/layout/components/SidebarFrame.tsx +2 -2
- package/src/modules/library/__tests__/{AddToGroupDialog.test.tsx → AddToPluginDialog.test.tsx} +34 -34
- package/src/modules/library/__tests__/LibraryCard.test.tsx +30 -11
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +84 -59
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +51 -51
- package/src/modules/library/__tests__/{LockedGroupView.test.tsx → LockedPluginView.test.tsx} +33 -33
- package/src/modules/library/__tests__/McpServerSection.test.tsx +138 -0
- package/src/modules/library/__tests__/{NewGroupDialog.test.tsx → NewPluginDialog.test.tsx} +22 -22
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +7 -7
- package/src/modules/library/__tests__/PluginExtras.test.tsx +131 -0
- package/src/modules/library/__tests__/{GroupJoinRequests.test.tsx → PluginJoinRequests.test.tsx} +24 -24
- package/src/modules/library/__tests__/{GroupPage.test.tsx → PluginPage.test.tsx} +101 -101
- package/src/modules/library/__tests__/{GroupsIndexPage.test.tsx → PluginsIndexPage.test.tsx} +57 -57
- package/src/modules/library/__tests__/{GroupsSidebar.contextmenu.test.tsx → PluginsSidebar.contextmenu.test.tsx} +31 -31
- package/src/modules/library/__tests__/{GroupsSidebar.locked.test.tsx → PluginsSidebar.locked.test.tsx} +28 -28
- package/src/modules/library/__tests__/{GroupsSidebar.test.tsx → PluginsSidebar.test.tsx} +39 -39
- package/src/modules/library/__tests__/{GroupsSidebarMenu.test.tsx → PluginsSidebarMenu.test.tsx} +18 -18
- package/src/modules/library/__tests__/SkillPage.test.tsx +8 -8
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +2 -2
- package/src/modules/library/__tests__/ToolPage.test.tsx +41 -12
- package/src/modules/library/__tests__/ToolSharePanel.test.tsx +1 -1
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +57 -57
- package/src/modules/library/__tests__/auth-harness.tsx +4 -4
- package/src/modules/library/__tests__/status.test.ts +19 -19
- package/src/modules/library/__tests__/tools.api.test.ts +70 -0
- package/src/modules/library/__tests__/useToolPage.test.tsx +4 -4
- package/src/modules/library/components/AccessRequestsBanner.tsx +8 -8
- package/src/modules/library/components/{AddToGroupDialog.tsx → AddToPluginDialog.tsx} +11 -11
- package/src/modules/library/components/ChangeRequestDock.tsx +1 -1
- package/src/modules/library/components/{DeleteGroupDialog.tsx → DeletePluginDialog.tsx} +9 -9
- package/src/modules/library/components/LibraryCard.tsx +26 -2
- package/src/modules/library/components/LibraryLayout.tsx +70 -70
- package/src/modules/library/components/LibraryPage.tsx +8 -8
- package/src/modules/library/components/LockGlyph.tsx +1 -1
- package/src/modules/library/components/{LockedGroupView.tsx → LockedPluginView.tsx} +35 -35
- package/src/modules/library/components/{ManagedGroupRequests.tsx → ManagedPluginRequests.tsx} +13 -13
- package/src/modules/library/components/{NewGroupDialog.tsx → NewPluginDialog.tsx} +24 -24
- package/src/modules/library/components/NewSkillPanel.tsx +5 -5
- package/src/modules/library/components/PageActions.tsx +3 -3
- package/src/modules/library/components/PersonalAddDialog.tsx +5 -5
- package/src/modules/library/components/{PersonalGroupPage.tsx → PersonalPluginPage.tsx} +17 -17
- package/src/modules/library/components/PluginExtras.tsx +195 -0
- package/src/modules/library/components/{GroupIndexRow.tsx → PluginIndexRow.tsx} +6 -6
- package/src/modules/library/components/{GroupJoinRequests.tsx → PluginJoinRequests.tsx} +12 -12
- package/src/modules/library/components/{GroupPage.tsx → PluginPage.tsx} +72 -69
- package/src/modules/library/components/{GroupsIndexPage.tsx → PluginsIndexPage.tsx} +46 -46
- package/src/modules/library/components/{GroupsSidebar.tsx → PluginsSidebar.tsx} +55 -55
- package/src/modules/library/components/{GroupsSidebarMenu.tsx → PluginsSidebarMenu.tsx} +15 -15
- package/src/modules/library/components/{group-page-parts.tsx → plugin-page-parts.tsx} +35 -24
- package/src/modules/library/components/skill-page/SkillPage.tsx +12 -12
- package/src/modules/library/components/tool-page/McpServerSection.tsx +380 -0
- package/src/modules/library/components/tool-page/ToolPage.tsx +22 -5
- package/src/modules/library/hooks/useJoinRequests.ts +8 -8
- package/src/modules/library/routes/LibraryRoutes.tsx +30 -17
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +24 -24
- package/src/modules/library/routes/library-paths.ts +36 -36
- package/src/modules/library/services/library.api.ts +9 -9
- package/src/modules/library/services/{groups.api.ts → plugins.api.ts} +43 -43
- package/src/modules/library/services/tools.api.ts +54 -0
- package/src/modules/library/state/library-data.tsx +46 -46
- package/src/modules/library/utils/names.ts +1 -1
- package/src/modules/library/utils/{personal-group.ts → personal-plugin.ts} +8 -8
- package/src/modules/library/utils/{group-summary.ts → plugin-summary.ts} +14 -14
- package/src/modules/library/utils/status.ts +17 -17
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +86 -8
- package/src/modules/onboarding/agent-clients.ts +18 -14
- package/src/modules/onboarding/components/WelcomePage.tsx +19 -8
- package/src/modules/review/components/MarkdownDiffViewer.tsx +1 -1
- package/src/modules/review/components/ReviewPanel.tsx +11 -11
- package/src/modules/review/components/__tests__/{isGroupItemPath.test.ts → isPluginItemPath.test.ts} +24 -24
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +3 -3
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +1 -1
- package/src/modules/settings/components/SettingsLayout.tsx +1 -1
- package/src/modules/settings/components/SettingsNav.tsx +5 -5
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +29 -107
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +1 -1
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +228 -0
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +3 -3
- package/src/modules/workspace/components/FileExplorer.tsx +12 -12
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +14 -14
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +7 -2
- package/src/modules/workspace/utils/__tests__/diff.test.ts +1 -1
- package/src/modules/workspace/utils/fileTree.ts +3 -3
- package/src/shared/mcp/ClaudeInstallLink.tsx +88 -0
- package/src/shared/mcp/ConnectionInstructions.tsx +51 -0
- package/src/shared/mcp/CopyBlock.tsx +42 -0
- package/src/shared/mcp/__tests__/ClaudeInstallLink.test.tsx +40 -0
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +431 -0
- package/src/shared/mcp/__tests__/useCopyFeedback.test.ts +112 -0
- package/src/shared/mcp/connect-snippets.ts +353 -0
- package/src/shared/mcp/index.ts +28 -0
- package/src/shared/mcp/useCopyFeedback.ts +46 -0
- package/src/test-setup.ts +11 -0
|
@@ -3,27 +3,27 @@ import { Link } from 'react-router-dom';
|
|
|
3
3
|
import { Funnel, RotateCw, Trash2 } from 'lucide-react';
|
|
4
4
|
import { cn } from '../../../lib/utils';
|
|
5
5
|
import { Banner, Button, Dialog, IconButton } from '../../../shared/components';
|
|
6
|
-
import {
|
|
6
|
+
import { pathForPluginsIndex } from '../routes/library-paths';
|
|
7
7
|
import type { LibraryItem } from '../state/library-data';
|
|
8
8
|
import { removeLibraryItem } from '../services/library.api';
|
|
9
9
|
import { LibraryCard } from './LibraryCard';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* The furniture a
|
|
12
|
+
* The furniture a plugin page is made of, shared by the two pages that are one.
|
|
13
13
|
*
|
|
14
|
-
* `
|
|
14
|
+
* `PluginPage` (a folder in the KB) and `PersonalPluginPage` (the items in no
|
|
15
15
|
* folder at all) are different QUERIES over the same catalog, and the user
|
|
16
16
|
* asked for the second to look like the first. Shared components rather than a
|
|
17
|
-
* copy: a
|
|
17
|
+
* copy: a plugin page is a promise about layout, and two implementations of one
|
|
18
18
|
* promise drift the first time either is touched.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
/** `All
|
|
22
|
-
export function
|
|
21
|
+
/** `All plugins › {name}` — the page's place in the Library, and the way back. */
|
|
22
|
+
export function PluginBreadcrumb({ name }: { name: string }) {
|
|
23
23
|
return (
|
|
24
24
|
<nav aria-label="Breadcrumb" className="flex items-center gap-1.5 text-detail text-ink-faint">
|
|
25
|
-
<Link to={
|
|
26
|
-
All
|
|
25
|
+
<Link to={pathForPluginsIndex()} className="rounded-xs hover:text-ink">
|
|
26
|
+
All plugins
|
|
27
27
|
</Link>
|
|
28
28
|
<span aria-hidden="true">›</span>
|
|
29
29
|
<span aria-current="page" className="truncate text-ink-muted">
|
|
@@ -50,7 +50,7 @@ export function GroupBreadcrumb({ name }: { name: string }) {
|
|
|
50
50
|
* switched on has to stay lit — a filter you cannot see is a page lying about
|
|
51
51
|
* what it is showing — so `controlsActive` lifts the whole wrapper instead.
|
|
52
52
|
*/
|
|
53
|
-
export function
|
|
53
|
+
export function PluginSection({
|
|
54
54
|
title,
|
|
55
55
|
count,
|
|
56
56
|
controls,
|
|
@@ -100,7 +100,7 @@ export function GroupSection({
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
|
-
* The auto-filling card track a
|
|
103
|
+
* The auto-filling card track a plugin's contents sit in.
|
|
104
104
|
*
|
|
105
105
|
* The track floor is `min(236px, 100%)` rather than a flat 236px so a
|
|
106
106
|
* container narrower than one card still gets a single column that fits,
|
|
@@ -130,14 +130,25 @@ export function CardGrid({
|
|
|
130
130
|
>
|
|
131
131
|
{items.map((item) => {
|
|
132
132
|
// The change-request number is part of the key, not decoration: two
|
|
133
|
-
// people can propose a skill of the same name into different
|
|
133
|
+
// people can propose a skill of the same name into different plugins,
|
|
134
134
|
// and until one of them merges neither is in the catalog to collide
|
|
135
135
|
// with — so the name alone is not yet unique.
|
|
136
136
|
const key = `${item.kind}:${item.id}:${item.pending?.changeRequestNumber ?? ''}`;
|
|
137
|
+
// The flavor badge names the DECLARATION file — which file an owner
|
|
138
|
+
// edits — not the transport: a `.tool` manual whose call template is
|
|
139
|
+
// `type: mcp` still edits as a UTCP manual, so the path suffix is the
|
|
140
|
+
// authoritative signal, not the tool's `type` metadata.
|
|
141
|
+
const kindProps =
|
|
142
|
+
item.kind === 'integration'
|
|
143
|
+
? ({
|
|
144
|
+
kind: 'integration',
|
|
145
|
+
flavor: item.path.endsWith('/mcp.json') ? 'mcp' : 'utcp',
|
|
146
|
+
} as const)
|
|
147
|
+
: ({ kind: 'skill' } as const);
|
|
137
148
|
const card = (
|
|
138
149
|
<LibraryCard
|
|
139
150
|
key={key}
|
|
140
|
-
|
|
151
|
+
{...kindProps}
|
|
141
152
|
id={item.id}
|
|
142
153
|
name={item.name}
|
|
143
154
|
description={item.description}
|
|
@@ -185,7 +196,7 @@ export function CardGrid({
|
|
|
185
196
|
|
|
186
197
|
/**
|
|
187
198
|
* The "are you sure" a removal deserves: deleting a skill or tool from a
|
|
188
|
-
*
|
|
199
|
+
* plugin takes it from EVERYONE in the plugin, not from a personal shelf, and
|
|
189
200
|
* there is no undo shortcut — the content survives only in git history.
|
|
190
201
|
*/
|
|
191
202
|
export function RemoveLibraryItemDialog({
|
|
@@ -195,7 +206,7 @@ export function RemoveLibraryItemDialog({
|
|
|
195
206
|
onRemoved,
|
|
196
207
|
}: {
|
|
197
208
|
item: LibraryItem;
|
|
198
|
-
/** Where it is being removed from, for the copy: a
|
|
209
|
+
/** Where it is being removed from, for the copy: a plugin name, or "your space". */
|
|
199
210
|
place: string;
|
|
200
211
|
onClose(): void;
|
|
201
212
|
/** Fired after the delete lands; the host page reloads and says so. */
|
|
@@ -255,11 +266,11 @@ export function RemoveLibraryItemDialog({
|
|
|
255
266
|
/**
|
|
256
267
|
* The Skills and Tools bands, in that order, with their empty states.
|
|
257
268
|
*
|
|
258
|
-
* The empty copy differs per page (a
|
|
269
|
+
* The empty copy differs per page (a plugin can be filled by an agent; your own
|
|
259
270
|
* space is filled by you), so it arrives as props rather than being derived
|
|
260
271
|
* from a name here.
|
|
261
272
|
*/
|
|
262
|
-
export function
|
|
273
|
+
export function PluginItemSections({
|
|
263
274
|
skillItems,
|
|
264
275
|
toolItems,
|
|
265
276
|
onOpen,
|
|
@@ -284,13 +295,13 @@ export function GroupItemSections({
|
|
|
284
295
|
* already show.
|
|
285
296
|
*/
|
|
286
297
|
skillControls?: ReactNode;
|
|
287
|
-
/** One of `skillControls` is mid-act — keep the row visible. See `
|
|
298
|
+
/** One of `skillControls` is mid-act — keep the row visible. See `PluginSection`. */
|
|
288
299
|
skillControlsActive?: boolean;
|
|
289
300
|
/**
|
|
290
301
|
* Drop a band with nothing in it instead of showing its empty state.
|
|
291
302
|
*
|
|
292
|
-
* A
|
|
293
|
-
*
|
|
303
|
+
* A PLUGIN says "No skills yet" because the absence is a fact about that
|
|
304
|
+
* plugin and an invitation to fix it. A SEARCH RESULT says nothing, because
|
|
294
305
|
* "No tools yet" under a query for `rfi` is not a fact about your library.
|
|
295
306
|
*/
|
|
296
307
|
hideEmpty?: boolean;
|
|
@@ -298,7 +309,7 @@ export function GroupItemSections({
|
|
|
298
309
|
return (
|
|
299
310
|
<>
|
|
300
311
|
{!(hideEmpty && skillItems.length === 0) && (
|
|
301
|
-
<
|
|
312
|
+
<PluginSection
|
|
302
313
|
title="Skills"
|
|
303
314
|
count={skillItems.length}
|
|
304
315
|
controls={skillControls}
|
|
@@ -309,17 +320,17 @@ export function GroupItemSections({
|
|
|
309
320
|
) : (
|
|
310
321
|
<CardGrid items={skillItems} onOpen={onOpen} onRemove={onRemove} />
|
|
311
322
|
)}
|
|
312
|
-
</
|
|
323
|
+
</PluginSection>
|
|
313
324
|
)}
|
|
314
325
|
|
|
315
326
|
{!(hideEmpty && toolItems.length === 0) && (
|
|
316
|
-
<
|
|
327
|
+
<PluginSection title="Tools" count={toolItems.length}>
|
|
317
328
|
{toolItems.length === 0 ? (
|
|
318
329
|
<p className="text-ui text-ink-faint">{emptyTools}</p>
|
|
319
330
|
) : (
|
|
320
331
|
<CardGrid items={toolItems} onOpen={onOpen} onRemove={onRemove} />
|
|
321
332
|
)}
|
|
322
|
-
</
|
|
333
|
+
</PluginSection>
|
|
323
334
|
)}
|
|
324
335
|
</>
|
|
325
336
|
);
|
|
@@ -363,7 +374,7 @@ export function ShareGlyph({ className }: { className?: string }) {
|
|
|
363
374
|
*
|
|
364
375
|
* `filter` narrows the band to the items waiting on you, and it STAYS LIT when
|
|
365
376
|
* on — a filter you cannot see is a page lying about what it is showing. The
|
|
366
|
-
* opting-out is `
|
|
377
|
+
* opting-out is `PluginSection`'s `controlsActive`, because that is the element
|
|
367
378
|
* carrying the fade; an `opacity-100` on the button inside it would multiply
|
|
368
379
|
* against the wrapper's zero and do nothing.
|
|
369
380
|
*
|
|
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useId, useMemo, useState, type ReactNode } from
|
|
|
2
2
|
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
3
3
|
import {
|
|
4
4
|
DEFAULT_BRANCH,
|
|
5
|
-
|
|
5
|
+
pluginOfPath,
|
|
6
6
|
type PullRequestSummary,
|
|
7
7
|
} from '@bevel-software/platform-shared';
|
|
8
8
|
import '../../library.css';
|
|
@@ -22,7 +22,7 @@ import { useLibrary } from '../../state/library-data';
|
|
|
22
22
|
import { useLibraryToast } from '../../state/toast.context';
|
|
23
23
|
import { libraryHomeForItemPath, urlForSkillFile } from '../../routes/library-paths';
|
|
24
24
|
import { changeAuthorName, formatWhen } from '../../../change-requests/utils/author';
|
|
25
|
-
import { ownersTextOf } from '../../utils/
|
|
25
|
+
import { ownersTextOf } from '../../utils/plugin-summary';
|
|
26
26
|
import { neededToolsFor, toolStatus } from '../../utils/status';
|
|
27
27
|
import { StatusDot } from '../StatusDot';
|
|
28
28
|
import { ChangeRequestDock } from '../ChangeRequestDock';
|
|
@@ -107,16 +107,16 @@ export function SkillPage({
|
|
|
107
107
|
const prefix = `${skillPath}/`;
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
|
-
* Who has to say yes. A skill has no owner of its own — it inherits its
|
|
110
|
+
* Who has to say yes. A skill has no owner of its own — it inherits its plugin
|
|
111
111
|
* folder's `access.md` — so the people who review a change to it are the
|
|
112
|
-
*
|
|
113
|
-
* the neutral fallback when the
|
|
112
|
+
* plugin's owners. Naming the wrong reviewer is worse than naming none, hence
|
|
113
|
+
* the neutral fallback when the plugin index hasn't resolved.
|
|
114
114
|
*/
|
|
115
115
|
const ownerName = useMemo(() => {
|
|
116
|
-
const
|
|
117
|
-
const summary =
|
|
116
|
+
const plugin = skill ? pluginOfPath(skill.path) : null;
|
|
117
|
+
const summary = plugin ? data.pluginSummaries.find((g) => g.name === plugin) : undefined;
|
|
118
118
|
return summary ? ownersTextOf(summary) : 'the owner';
|
|
119
|
-
}, [skill, data.
|
|
119
|
+
}, [skill, data.pluginSummaries]);
|
|
120
120
|
|
|
121
121
|
const files = useMemo(
|
|
122
122
|
() => ['SKILL.md', ...(skill?.files ?? []).map((f) => f.slice(prefix.length))],
|
|
@@ -377,7 +377,7 @@ export function SkillPage({
|
|
|
377
377
|
}
|
|
378
378
|
|
|
379
379
|
// The page the skill lives on, not the Library root: "back" from a skill
|
|
380
|
-
// you opened off its
|
|
380
|
+
// you opened off its plugin page must land on that plugin page. Derived from
|
|
381
381
|
// the path, so a deep link gets the same honest destination as a click.
|
|
382
382
|
const home = libraryHomeForItemPath(skillPath);
|
|
383
383
|
const backLink = (
|
|
@@ -391,7 +391,7 @@ export function SkillPage({
|
|
|
391
391
|
// just mean we asked with the wrong name. Only the catalog can correct that,
|
|
392
392
|
// and only a SUCCESSFUL catalog response counts — `loading: false` also
|
|
393
393
|
// describes a catalog that failed, which is "we couldn't ask", not "there is
|
|
394
|
-
// no such skill". The same distinction
|
|
394
|
+
// no such skill". The same distinction PluginPage draws a few files over.
|
|
395
395
|
//
|
|
396
396
|
// A confirmed name (the catalog resolved this URL to it) is unaffected: its
|
|
397
397
|
// detail error is real and gets reported immediately.
|
|
@@ -451,8 +451,8 @@ export function SkillPage({
|
|
|
451
451
|
and its frontmatter panel already says what the skill is for.
|
|
452
452
|
Repeating it above the pane said the same sentence twice on the
|
|
453
453
|
first screenful. */}
|
|
454
|
-
{/* No `Manage access` here, deliberately — a skill inherits its
|
|
455
|
-
folder's `access.md`, and the
|
|
454
|
+
{/* No `Manage access` here, deliberately — a skill inherits its plugin
|
|
455
|
+
folder's `access.md`, and the plugin's Share panel is the one place
|
|
456
456
|
those rules are decided. Same call the tool page made. */}
|
|
457
457
|
</header>
|
|
458
458
|
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useNavigate } from 'react-router-dom';
|
|
3
|
+
import { Badge, Banner, Button, Dialog } from '../../../../shared/components';
|
|
4
|
+
import {
|
|
5
|
+
getMcpServer,
|
|
6
|
+
putMcpServer,
|
|
7
|
+
type McpServerView,
|
|
8
|
+
type McpTransport,
|
|
9
|
+
} from '../../services/tools.api';
|
|
10
|
+
import { pathForTool } from '../../routes/library-paths';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The server-scoped editor for an mcp.json-backed tool — the form that
|
|
14
|
+
* replaces dropping a writer into raw JSON. It shows nothing for `.tool`
|
|
15
|
+
* manuals (the GET 404s: those edit as files) and renders read-only facts for
|
|
16
|
+
* non-writers, whose editing surface this page has never been.
|
|
17
|
+
*
|
|
18
|
+
* RENAME CONFIRMS, WITH THE COST NAMED. The server's name is the namespace
|
|
19
|
+
* its vault secrets bind to (`<name>_<VAR>`), so renaming disconnects every
|
|
20
|
+
* configured value and completed sign-in under the old name. The page already
|
|
21
|
+
* knows how many that is; the dialog says the number instead of "are you
|
|
22
|
+
* sure".
|
|
23
|
+
*/
|
|
24
|
+
export function McpServerSection({
|
|
25
|
+
slug,
|
|
26
|
+
configuredCount,
|
|
27
|
+
onSaved,
|
|
28
|
+
onError,
|
|
29
|
+
}: {
|
|
30
|
+
slug: string;
|
|
31
|
+
/** Configured secrets + sign-ins under this server's name — what a rename disconnects. */
|
|
32
|
+
configuredCount: number;
|
|
33
|
+
/** Called after a save lands; the new slug when the server was renamed. */
|
|
34
|
+
onSaved(newSlug?: string): void;
|
|
35
|
+
onError(message: string): void;
|
|
36
|
+
}) {
|
|
37
|
+
const navigate = useNavigate();
|
|
38
|
+
const [server, setServer] = useState<McpServerView | null>(null);
|
|
39
|
+
const [editing, setEditing] = useState(false);
|
|
40
|
+
const [saving, setSaving] = useState(false);
|
|
41
|
+
const [confirmingRename, setConfirmingRename] = useState(false);
|
|
42
|
+
|
|
43
|
+
// Draft fields, seeded from the loaded view when editing opens.
|
|
44
|
+
const [name, setName] = useState('');
|
|
45
|
+
const [transport, setTransport] = useState<McpTransport>('streamable-http');
|
|
46
|
+
const [url, setUrl] = useState('');
|
|
47
|
+
const [command, setCommand] = useState('');
|
|
48
|
+
const [args, setArgs] = useState('');
|
|
49
|
+
const [literalHeaders, setLiteralHeaders] = useState('');
|
|
50
|
+
const [authHeaders, setAuthHeaders] = useState('');
|
|
51
|
+
const [local, setLocal] = useState(false);
|
|
52
|
+
const [variables, setVariables] = useState<McpServerView['variables']>([]);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
let live = true;
|
|
56
|
+
getMcpServer(slug)
|
|
57
|
+
.then((view) => {
|
|
58
|
+
if (live) setServer(view);
|
|
59
|
+
})
|
|
60
|
+
.catch((err: unknown) => {
|
|
61
|
+
// A 404 already came back as null (a .tool-backed manual). Anything
|
|
62
|
+
// ELSE is a real failure, and vanishing silently would make it
|
|
63
|
+
// indistinguishable from that expected case.
|
|
64
|
+
if (live) onError(err instanceof Error ? err.message : 'Could not load the server configuration.');
|
|
65
|
+
});
|
|
66
|
+
return () => {
|
|
67
|
+
live = false;
|
|
68
|
+
};
|
|
69
|
+
}, [slug]);
|
|
70
|
+
|
|
71
|
+
if (!server) return null;
|
|
72
|
+
|
|
73
|
+
const openEditor = () => {
|
|
74
|
+
setName(server.name);
|
|
75
|
+
setTransport(server.transport);
|
|
76
|
+
setUrl(server.url ?? '');
|
|
77
|
+
setCommand(server.command ?? '');
|
|
78
|
+
setArgs((server.args ?? []).join('\n'));
|
|
79
|
+
setLiteralHeaders(headersToLines(server.literalHeaders));
|
|
80
|
+
setAuthHeaders(headersToLines(server.authHeaders));
|
|
81
|
+
setLocal(server.local);
|
|
82
|
+
setVariables(server.variables);
|
|
83
|
+
setEditing(true);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const save = async () => {
|
|
87
|
+
const renaming = name.trim() !== server.name;
|
|
88
|
+
// EVERY rename confirms: this caller's page only knows their own and the
|
|
89
|
+
// shared credentials — other members' user-scoped values and sign-ins are
|
|
90
|
+
// invisible here, so a zero count proves nothing about what disconnects.
|
|
91
|
+
if (renaming && !confirmingRename) {
|
|
92
|
+
setConfirmingRename(true);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
setSaving(true);
|
|
96
|
+
setConfirmingRename(false);
|
|
97
|
+
try {
|
|
98
|
+
const result = await putMcpServer(slug, {
|
|
99
|
+
...(renaming ? { newName: name.trim() } : {}),
|
|
100
|
+
transport,
|
|
101
|
+
...(transport === 'stdio'
|
|
102
|
+
? {
|
|
103
|
+
command: command.trim(),
|
|
104
|
+
args: args.split('\n').map((a) => a.trim()).filter(Boolean),
|
|
105
|
+
// `cwd`/`env` have no fields in this form. The PUT preserves
|
|
106
|
+
// omitted fields, but echoing them as read keeps values a
|
|
107
|
+
// hand-edited mcp.json carries safe on any backend semantics.
|
|
108
|
+
...(server.cwd ? { cwd: server.cwd } : {}),
|
|
109
|
+
...(server.env ? { env: server.env } : {}),
|
|
110
|
+
}
|
|
111
|
+
: { url: url.trim() }),
|
|
112
|
+
literalHeaders: linesToHeaders(literalHeaders),
|
|
113
|
+
authHeaders: linesToHeaders(authHeaders),
|
|
114
|
+
variables: variables
|
|
115
|
+
.map((v) => ({ ...v, name: v.name.trim(), label: v.label?.trim() || undefined }))
|
|
116
|
+
.filter((v) => v.name.length > 0),
|
|
117
|
+
...(server.description ? { description: server.description } : {}),
|
|
118
|
+
local,
|
|
119
|
+
});
|
|
120
|
+
setEditing(false);
|
|
121
|
+
if (result.name !== server.name) {
|
|
122
|
+
// The slug IS the name — the old page no longer exists.
|
|
123
|
+
navigate(pathForTool(result.name), { replace: true });
|
|
124
|
+
onSaved(result.name);
|
|
125
|
+
} else {
|
|
126
|
+
setServer(null); // refetch on next render via onSaved's reload
|
|
127
|
+
onSaved();
|
|
128
|
+
}
|
|
129
|
+
} catch (err) {
|
|
130
|
+
onError(err instanceof Error ? err.message : 'Save failed.');
|
|
131
|
+
} finally {
|
|
132
|
+
setSaving(false);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<section className="mt-8">
|
|
138
|
+
<h2 className="mb-2.5 flex items-center gap-2 text-label font-semibold uppercase text-ink-faint">
|
|
139
|
+
Server
|
|
140
|
+
<Badge tone="outline" size="xs" className="uppercase">
|
|
141
|
+
MCP server
|
|
142
|
+
</Badge>
|
|
143
|
+
</h2>
|
|
144
|
+
|
|
145
|
+
{!editing && (
|
|
146
|
+
<div className="flex items-start justify-between gap-4 rounded-md border border-line px-3.5 py-2.5">
|
|
147
|
+
<dl className="min-w-0 text-detail text-ink-muted">
|
|
148
|
+
<div className="flex gap-2">
|
|
149
|
+
<dt className="shrink-0 font-semibold">Transport</dt>
|
|
150
|
+
<dd>{server.transport}</dd>
|
|
151
|
+
</div>
|
|
152
|
+
{server.url && (
|
|
153
|
+
<div className="flex gap-2">
|
|
154
|
+
<dt className="shrink-0 font-semibold">URL</dt>
|
|
155
|
+
<dd className="truncate">{server.url}</dd>
|
|
156
|
+
</div>
|
|
157
|
+
)}
|
|
158
|
+
{server.command && (
|
|
159
|
+
<div className="flex gap-2">
|
|
160
|
+
<dt className="shrink-0 font-semibold">Command</dt>
|
|
161
|
+
<dd className="truncate">
|
|
162
|
+
{server.command} {(server.args ?? []).join(' ')}
|
|
163
|
+
</dd>
|
|
164
|
+
</div>
|
|
165
|
+
)}
|
|
166
|
+
{server.local && (
|
|
167
|
+
<div className="mt-1 text-ink-faint">
|
|
168
|
+
Runs locally — served by hexis-mcp on each member's machine, never by the workspace.
|
|
169
|
+
</div>
|
|
170
|
+
)}
|
|
171
|
+
</dl>
|
|
172
|
+
{server.canWrite && (
|
|
173
|
+
<Button variant="outline" size="sm" onClick={openEditor}>
|
|
174
|
+
Edit server
|
|
175
|
+
</Button>
|
|
176
|
+
)}
|
|
177
|
+
</div>
|
|
178
|
+
)}
|
|
179
|
+
|
|
180
|
+
{editing && (
|
|
181
|
+
<div className="flex flex-col gap-3 rounded-md border border-line px-3.5 py-3">
|
|
182
|
+
<LabeledInput label="Name" value={name} onChange={setName} mono
|
|
183
|
+
hint="The name is this server's secret namespace — renaming disconnects configured secrets." />
|
|
184
|
+
<label className="flex flex-col gap-1 text-detail">
|
|
185
|
+
<span className="font-semibold text-ink">Transport</span>
|
|
186
|
+
<select
|
|
187
|
+
className="rounded-md border border-line bg-white px-2.5 py-1.5 text-ui"
|
|
188
|
+
value={transport}
|
|
189
|
+
onChange={(e) => setTransport(e.target.value as McpTransport)}
|
|
190
|
+
>
|
|
191
|
+
<option value="streamable-http">streamable-http</option>
|
|
192
|
+
<option value="sse">sse (legacy)</option>
|
|
193
|
+
<option value="stdio">stdio — runs on each member's machine</option>
|
|
194
|
+
</select>
|
|
195
|
+
</label>
|
|
196
|
+
{transport === 'stdio' ? (
|
|
197
|
+
<>
|
|
198
|
+
<LabeledInput label="Command" value={command} onChange={setCommand} mono
|
|
199
|
+
hint="A bare executable name, or a ./ path inside the plugin." />
|
|
200
|
+
<LabeledTextarea label="Arguments" value={args} onChange={setArgs}
|
|
201
|
+
hint="One argument per line — spaces inside an argument survive. ${PLUGIN_ROOT} and ${PLUGIN_DATA} expand at launch." />
|
|
202
|
+
</>
|
|
203
|
+
) : (
|
|
204
|
+
<LabeledInput label="URL" value={url} onChange={setUrl} mono />
|
|
205
|
+
)}
|
|
206
|
+
<LabeledTextarea label="Headers (portable)" value={literalHeaders} onChange={setLiteralHeaders}
|
|
207
|
+
hint="One `Header: value` per line. Visible package data — no secrets here." />
|
|
208
|
+
<LabeledTextarea label="Auth headers" value={authHeaders} onChange={setAuthHeaders}
|
|
209
|
+
hint="One per line; values may use ${VAR} vault references, e.g. `Authorization: Bearer ${API_KEY}`." />
|
|
210
|
+
<VariablesEditor variables={variables} onChange={setVariables} />
|
|
211
|
+
{transport !== 'stdio' && (
|
|
212
|
+
<label className="flex items-center gap-2 text-detail text-ink-muted">
|
|
213
|
+
<input type="checkbox" checked={local} onChange={(e) => setLocal(e.target.checked)} />
|
|
214
|
+
Local-only — reachable only from a member's own machine (e.g. localhost)
|
|
215
|
+
</label>
|
|
216
|
+
)}
|
|
217
|
+
<div className="flex gap-2">
|
|
218
|
+
<Button size="sm" onClick={() => void save()} disabled={saving}>
|
|
219
|
+
{saving ? 'Saving…' : 'Save'}
|
|
220
|
+
</Button>
|
|
221
|
+
<Button variant="quiet" size="sm" onClick={() => setEditing(false)} disabled={saving}>
|
|
222
|
+
Cancel
|
|
223
|
+
</Button>
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
)}
|
|
227
|
+
|
|
228
|
+
{confirmingRename && (
|
|
229
|
+
<Dialog open onClose={() => setConfirmingRename(false)} title="Rename this server?">
|
|
230
|
+
<Banner tone="danger" role="alert" className="mb-3">
|
|
231
|
+
Renaming <b>{server.name}</b> to <b>{name.trim()}</b> disconnects every secret and
|
|
232
|
+
sign-in stored under the old name
|
|
233
|
+
{configuredCount > 0
|
|
234
|
+
? ` — at least ${configuredCount === 1 ? 'one is' : `${configuredCount} are`} configured from your view alone, and other members' sign-ins disconnect too.`
|
|
235
|
+
: " — including other members' values, which this page cannot see."}
|
|
236
|
+
</Banner>
|
|
237
|
+
<div className="flex justify-end gap-2">
|
|
238
|
+
<Button variant="quiet" size="sm" onClick={() => setConfirmingRename(false)}>
|
|
239
|
+
Keep the name
|
|
240
|
+
</Button>
|
|
241
|
+
<Button size="sm" onClick={() => void save()}>
|
|
242
|
+
Rename anyway
|
|
243
|
+
</Button>
|
|
244
|
+
</div>
|
|
245
|
+
</Dialog>
|
|
246
|
+
)}
|
|
247
|
+
</section>
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function LabeledInput({
|
|
252
|
+
label,
|
|
253
|
+
value,
|
|
254
|
+
onChange,
|
|
255
|
+
hint,
|
|
256
|
+
mono,
|
|
257
|
+
}: {
|
|
258
|
+
label: string;
|
|
259
|
+
value: string;
|
|
260
|
+
onChange(v: string): void;
|
|
261
|
+
hint?: string;
|
|
262
|
+
mono?: boolean;
|
|
263
|
+
}) {
|
|
264
|
+
return (
|
|
265
|
+
<label className="flex flex-col gap-1 text-detail">
|
|
266
|
+
<span className="font-semibold text-ink">{label}</span>
|
|
267
|
+
<input
|
|
268
|
+
className={`rounded-md border border-line bg-white px-2.5 py-1.5 text-ui ${mono ? 'font-mono' : ''}`}
|
|
269
|
+
value={value}
|
|
270
|
+
onChange={(e) => onChange(e.target.value)}
|
|
271
|
+
/>
|
|
272
|
+
{hint && <span className="text-ink-faint">{hint}</span>}
|
|
273
|
+
</label>
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function LabeledTextarea({
|
|
278
|
+
label,
|
|
279
|
+
value,
|
|
280
|
+
onChange,
|
|
281
|
+
hint,
|
|
282
|
+
}: {
|
|
283
|
+
label: string;
|
|
284
|
+
value: string;
|
|
285
|
+
onChange(v: string): void;
|
|
286
|
+
hint?: string;
|
|
287
|
+
}) {
|
|
288
|
+
return (
|
|
289
|
+
<label className="flex flex-col gap-1 text-detail">
|
|
290
|
+
<span className="font-semibold text-ink">{label}</span>
|
|
291
|
+
<textarea
|
|
292
|
+
className="min-h-16 rounded-md border border-line bg-white px-2.5 py-1.5 font-mono text-ui"
|
|
293
|
+
value={value}
|
|
294
|
+
onChange={(e) => onChange(e.target.value)}
|
|
295
|
+
/>
|
|
296
|
+
{hint && <span className="text-ink-faint">{hint}</span>}
|
|
297
|
+
</label>
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Declared `${VAR}`s and who provisions each: `admin` (one shared value, set
|
|
303
|
+
* by a tool writer) or `user` (each member their own, on the Connect page).
|
|
304
|
+
* The names must match the `${VAR}` references in the auth headers — the vault
|
|
305
|
+
* key is `<server>_<VAR>`, derived from exactly these names.
|
|
306
|
+
*/
|
|
307
|
+
function VariablesEditor({
|
|
308
|
+
variables,
|
|
309
|
+
onChange,
|
|
310
|
+
}: {
|
|
311
|
+
variables: McpServerView['variables'];
|
|
312
|
+
onChange(next: McpServerView['variables']): void;
|
|
313
|
+
}) {
|
|
314
|
+
const update = (i: number, patch: Partial<McpServerView['variables'][number]>) =>
|
|
315
|
+
onChange(variables.map((v, j) => (j === i ? { ...v, ...patch } : v)));
|
|
316
|
+
return (
|
|
317
|
+
<div className="flex flex-col gap-1 text-detail">
|
|
318
|
+
<span className="font-semibold text-ink">Variables</span>
|
|
319
|
+
{variables.map((v, i) => (
|
|
320
|
+
// Index keys are correct here: rows are edited in place and have no
|
|
321
|
+
// identity beyond their position until saved.
|
|
322
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
323
|
+
<div key={i} className="flex items-center gap-2">
|
|
324
|
+
<input
|
|
325
|
+
aria-label={`Variable ${i + 1} name`}
|
|
326
|
+
className="w-40 rounded-md border border-line bg-white px-2 py-1 font-mono text-ui"
|
|
327
|
+
value={v.name}
|
|
328
|
+
onChange={(e) => update(i, { name: e.target.value })}
|
|
329
|
+
/>
|
|
330
|
+
<select
|
|
331
|
+
aria-label={`Variable ${i + 1} scope`}
|
|
332
|
+
className="rounded-md border border-line bg-white px-2 py-1 text-ui"
|
|
333
|
+
value={v.scope}
|
|
334
|
+
onChange={(e) => update(i, { scope: e.target.value as 'admin' | 'user' })}
|
|
335
|
+
>
|
|
336
|
+
<option value="admin">admin — one shared value</option>
|
|
337
|
+
<option value="user">user — each member their own</option>
|
|
338
|
+
</select>
|
|
339
|
+
<input
|
|
340
|
+
aria-label={`Variable ${i + 1} label`}
|
|
341
|
+
className="min-w-0 flex-1 rounded-md border border-line bg-white px-2 py-1 text-ui"
|
|
342
|
+
placeholder="Label shown in the secrets UI"
|
|
343
|
+
value={v.label ?? ''}
|
|
344
|
+
onChange={(e) => update(i, { label: e.target.value || undefined })}
|
|
345
|
+
/>
|
|
346
|
+
<Button variant="quiet" size="sm" onClick={() => onChange(variables.filter((_, j) => j !== i))}>
|
|
347
|
+
Remove
|
|
348
|
+
</Button>
|
|
349
|
+
</div>
|
|
350
|
+
))}
|
|
351
|
+
<div>
|
|
352
|
+
<Button variant="outline" size="sm" onClick={() => onChange([...variables, { name: '', scope: 'admin' }])}>
|
|
353
|
+
Add variable
|
|
354
|
+
</Button>
|
|
355
|
+
</div>
|
|
356
|
+
<span className="text-ink-faint">
|
|
357
|
+
Names must match the {'`${VAR}`'} references in the auth headers; secrets are stored under{' '}
|
|
358
|
+
<code><server>_<VAR></code>.
|
|
359
|
+
</span>
|
|
360
|
+
</div>
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function headersToLines(headers: Record<string, string>): string {
|
|
365
|
+
return Object.entries(headers)
|
|
366
|
+
.map(([k, v]) => `${k}: ${v}`)
|
|
367
|
+
.join('\n');
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function linesToHeaders(text: string): Record<string, string> {
|
|
371
|
+
const out: Record<string, string> = {};
|
|
372
|
+
for (const line of text.split('\n')) {
|
|
373
|
+
const idx = line.indexOf(':');
|
|
374
|
+
if (idx <= 0) continue;
|
|
375
|
+
const key = line.slice(0, idx).trim();
|
|
376
|
+
const value = line.slice(idx + 1).trim();
|
|
377
|
+
if (key) out[key] = value;
|
|
378
|
+
}
|
|
379
|
+
return out;
|
|
380
|
+
}
|
|
@@ -2,6 +2,7 @@ import { useEffect, useState, type ReactNode } from 'react';
|
|
|
2
2
|
import { Link, useNavigate, useParams } from 'react-router-dom';
|
|
3
3
|
import { Banner, Button, buttonClasses } from '../../../../shared/components';
|
|
4
4
|
import { useToolPage } from '../../hooks/useToolPage';
|
|
5
|
+
import { McpServerSection } from './McpServerSection';
|
|
5
6
|
import { libraryHomeForItemPath, LIBRARY_ROOT } from '../../routes/library-paths';
|
|
6
7
|
import { readOAuthFragment } from '../../utils/oauth-fragment';
|
|
7
8
|
import type { ToolCapability } from '../../services/tools.api';
|
|
@@ -52,7 +53,7 @@ export function ToolPage({
|
|
|
52
53
|
}, [oauthOutcome]);
|
|
53
54
|
|
|
54
55
|
// Same rule as the skill page: back goes to the page the tool LIVES on —
|
|
55
|
-
// its
|
|
56
|
+
// its plugin, or the personal page — never to a root the reader may not
|
|
56
57
|
// have come from. Falls back to the root while the tool is still loading.
|
|
57
58
|
const home = libraryHomeForItemPath(page.tool?.path ?? '');
|
|
58
59
|
const backLink = (
|
|
@@ -121,10 +122,10 @@ export function ToolPage({
|
|
|
121
122
|
)}
|
|
122
123
|
</div>
|
|
123
124
|
{/* No `Manage access` here, deliberately. Access is decided at the
|
|
124
|
-
|
|
125
|
-
this page would either duplicate the
|
|
126
|
-
per-file override that nobody looking at the
|
|
127
|
-
|
|
125
|
+
PLUGIN — a tool inherits its folder's `access.md`, so an editor on
|
|
126
|
+
this page would either duplicate the plugin's one or quietly write a
|
|
127
|
+
per-file override that nobody looking at the plugin would see. The
|
|
128
|
+
plugin's `Share` panel is the single place. */}
|
|
128
129
|
</header>
|
|
129
130
|
|
|
130
131
|
{actionError && (
|
|
@@ -142,6 +143,22 @@ export function ToolPage({
|
|
|
142
143
|
onError={setActionError}
|
|
143
144
|
/>
|
|
144
145
|
|
|
146
|
+
{/* Only an mcp-type tool can have an mcp.json server pair — mounting the
|
|
147
|
+
section for inline/http manuals sends a `/server` GET whose 404 is
|
|
148
|
+
guaranteed. (A `.tool`-declared mcp manual still 404s and the section
|
|
149
|
+
self-hides on the null; the type cannot pre-decide that case.) */}
|
|
150
|
+
{tool.type === 'mcp' && (
|
|
151
|
+
<McpServerSection
|
|
152
|
+
slug={tool.slug}
|
|
153
|
+
configuredCount={tool.variables.filter((v) => v.adminConfigured || v.userConfigured || v.authorized === true).length}
|
|
154
|
+
onSaved={() => {
|
|
155
|
+
setActionError(null);
|
|
156
|
+
page.reload();
|
|
157
|
+
}}
|
|
158
|
+
onError={setActionError}
|
|
159
|
+
/>
|
|
160
|
+
)}
|
|
161
|
+
|
|
145
162
|
{page.detail && page.detail.capabilities.length > 0 && (
|
|
146
163
|
<CapabilitiesSection capabilities={page.detail.capabilities} />
|
|
147
164
|
)}
|