@bevel-software/platform-core-frontend 0.7.5 → 0.9.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/core/registry.ts +16 -4
- 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/admin/state/admin.context.tsx +15 -0
- 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} +197 -106
- package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +363 -0
- package/src/modules/library/__tests__/{GroupsSidebar.contextmenu.test.tsx → PluginsSidebar.contextmenu.test.tsx} +32 -31
- package/src/modules/library/__tests__/{GroupsSidebar.locked.test.tsx → PluginsSidebar.locked.test.tsx} +29 -28
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +171 -0
- 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__/library-data.test.ts +82 -0
- 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 +80 -71
- 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 +23 -5
- package/src/modules/library/components/PageActions.tsx +34 -11
- package/src/modules/library/components/PersonalAddDialog.tsx +5 -5
- package/src/modules/library/components/{PersonalGroupPage.tsx → PersonalPluginPage.tsx} +29 -19
- 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/PluginJoinRequests.tsx +77 -0
- package/src/modules/library/components/{GroupPage.tsx → PluginPage.tsx} +112 -72
- package/src/modules/library/components/{GroupsIndexPage.tsx → PluginsIndexPage.tsx} +91 -48
- package/src/modules/library/components/{GroupsSidebar.tsx → PluginsSidebar.tsx} +105 -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} +218 -27
- 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 +32 -19
- 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 +67 -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__/creator-welcome.test.tsx +318 -0
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +86 -8
- package/src/modules/onboarding/agent-clients.ts +18 -14
- package/src/modules/onboarding/components/CreatorWelcomePage.tsx +143 -0
- package/src/modules/onboarding/components/WelcomePage.tsx +30 -22
- package/src/modules/onboarding/components/WelcomeRoute.tsx +57 -0
- package/src/modules/onboarding/welcome-state.ts +36 -0
- 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/setup/__tests__/setup.test.tsx +203 -0
- package/src/modules/setup/components/SetupScreen.tsx +235 -68
- 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/FileRoute.tsx +8 -1
- package/src/modules/workspace/components/FileViewer.tsx +95 -38
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +14 -14
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +20 -0
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +227 -18
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +7 -2
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +25 -0
- package/src/modules/workspace/routing/kb-routes.ts +23 -1
- package/src/modules/workspace/utils/__tests__/diff.test.ts +1 -1
- package/src/modules/workspace/utils/fileTree.ts +54 -3
- package/src/shared/components/Surface.tsx +15 -0
- 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
- package/src/modules/library/__tests__/GroupsIndexPage.test.tsx +0 -283
- package/src/modules/library/__tests__/GroupsSidebar.test.tsx +0 -142
- package/src/modules/library/components/GroupJoinRequests.tsx +0 -56
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { Navigate, useParams } from 'react-router-dom';
|
|
2
|
-
import { DEFAULT_BRANCH,
|
|
2
|
+
import { DEFAULT_BRANCH, PLUGINS_DIR } from '@bevel-software/platform-shared';
|
|
3
3
|
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
4
4
|
import { useLibrary } from '../state/library-data';
|
|
5
5
|
import { SkillPage } from '../components/skill-page/SkillPage';
|
|
6
6
|
import { ToolPage } from '../components/tool-page/ToolPage';
|
|
7
|
-
import { LIBRARY_ROOT,
|
|
7
|
+
import { LIBRARY_ROOT, pathForPlugin } from './library-paths';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The library page behind a canonical workspace URL —
|
|
11
|
-
* `/workspace/<default>/<kbDir>/
|
|
11
|
+
* `/workspace/<default>/<kbDir>/Plugins/<plugin>/<...>` — rendered INSIDE the
|
|
12
12
|
* same `LibraryLayout` route tree as every other library page, so the sidebar
|
|
13
13
|
* is the one the reader already had and nothing remounts on the way in.
|
|
14
14
|
*
|
|
15
|
-
* Resolution is STRUCTURAL, not a catalog lookup: under `
|
|
15
|
+
* Resolution is STRUCTURAL, not a catalog lookup: under `Plugins/<plugin>/`, a
|
|
16
16
|
* `*.tool` file is a tool page, any other direct FILE (an extension, no
|
|
17
|
-
* segments below it — `access.md`) belongs to the
|
|
17
|
+
* segments below it — `access.md`) belongs to the plugin page, and everything
|
|
18
18
|
* else is a skill FOLDER whose name is the skill's id — the same identity the
|
|
19
19
|
* old name-based route used. That is what makes a skill created a moment ago
|
|
20
20
|
* open instantly: its URL says everything the page needs, and `SkillPage`
|
|
21
21
|
* fetches the skill by name itself. Waiting on the catalog here raced every
|
|
22
|
-
* reload and lost (the just-created skill bounced to its
|
|
22
|
+
* reload and lost (the just-created skill bounced to its plugin's page).
|
|
23
23
|
*
|
|
24
24
|
* The catalog is consulted only to REFINE a tool's slug (a `.tool` may
|
|
25
25
|
* declare an explicit id different from its filename); the filename is the
|
|
@@ -35,19 +35,19 @@ export function WorkspaceItemRoute() {
|
|
|
35
35
|
// Shape re-validation: the route pattern (`:branch/*`) is broader than the
|
|
36
36
|
// shape the shell dispatches here, and a stray URL must not read as a page.
|
|
37
37
|
const segments = splat.split('/').filter(Boolean).map(safeDecode);
|
|
38
|
-
if (branch !== DEFAULT_BRANCH || segments[1] !==
|
|
38
|
+
if (branch !== DEFAULT_BRANCH || segments[1] !== PLUGINS_DIR || segments.length < 3) {
|
|
39
39
|
return <Navigate to={LIBRARY_ROOT} replace />;
|
|
40
40
|
}
|
|
41
41
|
if (kbDirName !== null && segments[0] !== kbDirName) {
|
|
42
42
|
return <Navigate to={LIBRARY_ROOT} replace />;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const [, ,
|
|
45
|
+
const [, , plugin, ...tail] = segments;
|
|
46
46
|
const last = tail[tail.length - 1];
|
|
47
|
-
if (!
|
|
47
|
+
if (!plugin || !last) {
|
|
48
48
|
return <Navigate to={LIBRARY_ROOT} replace />;
|
|
49
49
|
}
|
|
50
|
-
const repoRel = `${
|
|
50
|
+
const repoRel = `${PLUGINS_DIR}/${plugin}/${tail.join('/')}`;
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* `key={name}` is load-bearing. A provisional name gets CORRECTED once the
|
|
@@ -61,9 +61,9 @@ export function WorkspaceItemRoute() {
|
|
|
61
61
|
);
|
|
62
62
|
|
|
63
63
|
// A `.tool` is a tool page wherever it sits. The backend finds manuals at
|
|
64
|
-
// ANY depth below `
|
|
64
|
+
// ANY depth below `Plugins/` (`walkFiles` over the whole tree), so a manual
|
|
65
65
|
// filed inside a category folder is a real, listed tool — matching only at
|
|
66
|
-
// the
|
|
66
|
+
// the plugin's top level would list it and then 404 the click.
|
|
67
67
|
if (last.toLowerCase().endsWith('.tool')) {
|
|
68
68
|
const catalogSlug = data.items.find(
|
|
69
69
|
(i) => i.kind === 'integration' && i.path === repoRel,
|
|
@@ -72,7 +72,7 @@ export function WorkspaceItemRoute() {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
// THE CATALOG IS THE AUTHORITY on which folder is a skill and what its id
|
|
75
|
-
// is.
|
|
75
|
+
// is. Plugins may nest (`Plugins/Engineering/coding/create-ticket/SKILL.md`),
|
|
76
76
|
// and a skill's id is its frontmatter `id`/`name` — only FALLING BACK to the
|
|
77
77
|
// folder name — so neither the depth nor the id can be read off the URL with
|
|
78
78
|
// certainty. Take the DEEPEST skill whose folder contains this path: a
|
|
@@ -88,10 +88,10 @@ export function WorkspaceItemRoute() {
|
|
|
88
88
|
// Not in the catalog. A `SKILL.md` still names its own skill structurally —
|
|
89
89
|
// the folder holding it — and that is deliberately catalog-FREE: a skill
|
|
90
90
|
// created a moment ago opens from its URL alone, before any reload lands.
|
|
91
|
-
// (`
|
|
91
|
+
// (`Plugins/<plugin>/SKILL.md` makes the plugin folder itself the skill, which
|
|
92
92
|
// is what the backend's walk would report for it.)
|
|
93
93
|
if (last === 'SKILL.md') {
|
|
94
|
-
return skillPage(tail.length >= 2 ? tail[tail.length - 2]! :
|
|
94
|
+
return skillPage(tail.length >= 2 ? tail[tail.length - 2]! : plugin, 'SKILL.md', true);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
// Everything below is decided on POSITIVE evidence only. What the catalog
|
|
@@ -99,24 +99,24 @@ export function WorkspaceItemRoute() {
|
|
|
99
99
|
// failed refresh — but what it does NOT know proves nothing: it may be
|
|
100
100
|
// loading, stale (a skill created seconds ago), or have failed outright.
|
|
101
101
|
// Reading absence as "this is not a page" is what bounced valid deep links
|
|
102
|
-
// to the
|
|
102
|
+
// to the plugin, so this no longer draws that inference at all.
|
|
103
103
|
|
|
104
104
|
// A folder with catalog skills UNDER it is a category, not a skill. That is
|
|
105
105
|
// the discriminator between a category folder and a just-created skill whose
|
|
106
106
|
// reload hasn't landed: the former has known descendants, the latter has
|
|
107
|
-
// none. A category has no page of its own; its
|
|
107
|
+
// none. A category has no page of its own; its plugin does.
|
|
108
108
|
if (!hasExtension(last) && containsCatalogSkill(data.items, repoRel)) {
|
|
109
|
-
return <Navigate to={
|
|
109
|
+
return <Navigate to={pathForPlugin(plugin)} replace />;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
// A FILE is the
|
|
113
|
-
// sits directly in the
|
|
112
|
+
// A FILE is the plugin's business when it cannot be a skill's file: either it
|
|
113
|
+
// sits directly in the plugin folder (structurally never inside a skill), or
|
|
114
114
|
// its own folder is a known category. `access.md` at either level, a stray
|
|
115
115
|
// upload. A file under an UNKNOWN folder is left alone — that folder is most
|
|
116
116
|
// likely a skill the catalog hasn't caught up with.
|
|
117
117
|
const parentRel = repoRel.slice(0, repoRel.length - last.length - 1);
|
|
118
118
|
if (hasExtension(last) && (tail.length === 1 || containsCatalogSkill(data.items, parentRel))) {
|
|
119
|
-
return <Navigate to={
|
|
119
|
+
return <Navigate to={pathForPlugin(plugin)} replace />;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
// Nothing positive settled it. While the catalog is still loading, WAIT: the
|
|
@@ -131,7 +131,7 @@ export function WorkspaceItemRoute() {
|
|
|
131
131
|
// so SkillPage must not turn a failed lookup into "doesn't exist" until the
|
|
132
132
|
// catalog has actually answered.
|
|
133
133
|
return hasExtension(last)
|
|
134
|
-
? skillPage(tail.length >= 2 ? tail[tail.length - 2]! :
|
|
134
|
+
? skillPage(tail.length >= 2 ? tail[tail.length - 2]! : plugin, last, true)
|
|
135
135
|
: skillPage(last, 'SKILL.md', true);
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -154,9 +154,9 @@ function containsCatalogSkill(
|
|
|
154
154
|
/**
|
|
155
155
|
* The catalog skill whose folder contains `repoRel`, deepest first — the skill
|
|
156
156
|
* a bundled file belongs to. Deepest wins because a category folder is never a
|
|
157
|
-
* skill itself, so between `
|
|
157
|
+
* skill itself, so between `Plugins/E/coding` and `Plugins/E/coding/create-ticket`
|
|
158
158
|
* only the latter can be a real entry; taking the shallower match would hand
|
|
159
|
-
* the file to whichever skill sat nearest the
|
|
159
|
+
* the file to whichever skill sat nearest the plugin root.
|
|
160
160
|
*
|
|
161
161
|
* Compares on whole segments (`path + '/'`), never a bare `startsWith`: a
|
|
162
162
|
* sibling named `create-ticket-v2` shares a prefix with `create-ticket` and
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_BRANCH,
|
|
1
|
+
import { DEFAULT_BRANCH, PLUGINS_DIR, pluginOfPath, isPersonalPluginFolder } from '@bevel-software/platform-shared';
|
|
2
2
|
import { matchPath } from 'react-router-dom';
|
|
3
3
|
import { kbFileUrl } from '../../workspace/routing/kb-routes';
|
|
4
4
|
import type { LibraryFilter } from '../utils/status';
|
|
@@ -8,7 +8,7 @@ import type { LibraryFilter } from '../utils/status';
|
|
|
8
8
|
*
|
|
9
9
|
* Pure functions rather than logic inside the layout, because three surfaces
|
|
10
10
|
* need them: the layout (to light the right sidebar row), every page that links
|
|
11
|
-
* to a
|
|
11
|
+
* to a plugin, and the tests. Keeping the pair together is what makes the round
|
|
12
12
|
* trip auditable — a path that maps to a filter must map back to itself.
|
|
13
13
|
*/
|
|
14
14
|
|
|
@@ -17,21 +17,21 @@ export const LIBRARY_ROOT = '/skills-and-tools';
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* What the sidebar should show as selected for a path. `null` on the pages that
|
|
20
|
-
* are not a filtered view of the catalog — the all-
|
|
21
|
-
* `
|
|
20
|
+
* are not a filtered view of the catalog — the all-plugins index (the root, see
|
|
21
|
+
* `isPluginsIndexPath`) and the item pages — where the gallery rows are all
|
|
22
22
|
* inactive.
|
|
23
23
|
*
|
|
24
24
|
* `matchPath` hands params back RAW (react-router decodes neither here nor in
|
|
25
|
-
* `useParams`), so a
|
|
26
|
-
* and has to be decoded to match the catalog's folder name. The
|
|
27
|
-
* the same decode on `useParams().
|
|
25
|
+
* `useParams`), so a plugin named `Sales & Ops` arrives as `Sales%20%26%20Ops`
|
|
26
|
+
* and has to be decoded to match the catalog's folder name. The plugin page owes
|
|
27
|
+
* the same decode on `useParams().plugin`.
|
|
28
28
|
*/
|
|
29
29
|
export function libraryFilterForPath(pathname: string): LibraryFilter | null {
|
|
30
30
|
if (matchPath({ path: `${LIBRARY_ROOT}/everything`, end: true }, pathname)) return { kind: 'all' };
|
|
31
31
|
if (matchPath({ path: `${LIBRARY_ROOT}/owned`, end: true }, pathname)) return { kind: 'owned' };
|
|
32
32
|
if (matchPath({ path: `${LIBRARY_ROOT}/yours`, end: true }, pathname)) return { kind: 'ungrouped' };
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
33
|
+
const plugin = matchPath({ path: `${LIBRARY_ROOT}/plugins/:plugin`, end: true }, pathname);
|
|
34
|
+
if (plugin?.params.plugin) return { kind: 'group', plugin: decodeSegment(plugin.params.plugin) };
|
|
35
35
|
return null;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -45,32 +45,32 @@ export function pathForLibraryFilter(filter: LibraryFilter): string {
|
|
|
45
45
|
case 'ungrouped':
|
|
46
46
|
return `${LIBRARY_ROOT}/yours`;
|
|
47
47
|
case 'group':
|
|
48
|
-
return
|
|
48
|
+
return pathForPlugin(filter.plugin);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
/** The route for one
|
|
53
|
-
export function
|
|
54
|
-
return `${LIBRARY_ROOT}/
|
|
52
|
+
/** The route for one plugin — member view or locked view, the page decides. */
|
|
53
|
+
export function pathForPlugin(plugin: string): string {
|
|
54
|
+
return `${LIBRARY_ROOT}/plugins/${encodeURIComponent(plugin)}`;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* The all-
|
|
59
|
-
* surface, so the index of them is what the root shows; `
|
|
58
|
+
* The all-plugins index — the Library's HOME. Plugins are the structure of this
|
|
59
|
+
* surface, so the index of them is what the root shows; `plugins` is kept as a
|
|
60
60
|
* redirect so the links that used to name it still land.
|
|
61
61
|
*/
|
|
62
|
-
export function
|
|
62
|
+
export function pathForPluginsIndex(): string {
|
|
63
63
|
return LIBRARY_ROOT;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
* Read a `:
|
|
67
|
+
* Read a `:plugin` route param. React-router 7 hands params back RAW from both
|
|
68
68
|
* `matchPath` and `useParams`, so every reader owes this decode — and a
|
|
69
69
|
* malformed escape (`%zz`, from a hand-edited or truncated link) THROWS, which
|
|
70
70
|
* would blank the page. A bad link is a bad link, not a crash: fall back to the
|
|
71
|
-
* raw segment and let the
|
|
71
|
+
* raw segment and let the plugin simply not be found.
|
|
72
72
|
*/
|
|
73
|
-
export function
|
|
73
|
+
export function decodePluginSegment(raw: string): string {
|
|
74
74
|
return decodeSegment(raw);
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -98,9 +98,9 @@ export function urlForSkillFile(kbDirName: string, skillPath: string, file = 'SK
|
|
|
98
98
|
/**
|
|
99
99
|
* Whether a location belongs to the LIBRARY surface — decided by URL SHAPE
|
|
100
100
|
* alone, never by catalog contents: `/skills-and-tools/...`, or a
|
|
101
|
-
* default-branch workspace URL under `
|
|
102
|
-
* (`/workspace/<default>/<kbDir>/
|
|
103
|
-
* to the Knowledge surface,
|
|
101
|
+
* default-branch workspace URL under `Plugins/`
|
|
102
|
+
* (`/workspace/<default>/<kbDir>/Plugins/<plugin>/...`). KnowledgeBase paths go
|
|
103
|
+
* to the Knowledge surface, Plugins paths to Skills & Tools — the two roots ARE
|
|
104
104
|
* the two apps. A shape rule means a just-created skill routes correctly
|
|
105
105
|
* before any catalog has heard of it.
|
|
106
106
|
*
|
|
@@ -113,8 +113,8 @@ export function isLibraryLocation(pathname: string): boolean {
|
|
|
113
113
|
return (
|
|
114
114
|
segments[0] === 'workspace' &&
|
|
115
115
|
segments[1] === DEFAULT_BRANCH &&
|
|
116
|
-
segments[3] ===
|
|
117
|
-
segments.length >= 6 // workspace/<branch>/<kbDir>/
|
|
116
|
+
segments[3] === PLUGINS_DIR &&
|
|
117
|
+
segments.length >= 6 // workspace/<branch>/<kbDir>/Plugins/<plugin>/<item>
|
|
118
118
|
);
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -142,18 +142,18 @@ export function pathForSkill(name: string): string {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
|
-
* Whether a path is the all-
|
|
146
|
-
*
|
|
145
|
+
* Whether a path is the all-plugins index — the one path that lights the "All
|
|
146
|
+
* plugins" row. It is not a `LibraryFilter`: the index lists PLACES, not a
|
|
147
147
|
* filtered slice of the catalog, which is why selection for it travels beside
|
|
148
148
|
* the filter rather than inside it.
|
|
149
149
|
*
|
|
150
|
-
* `
|
|
150
|
+
* `plugins` answers true as well even though it only ever redirects, so the row
|
|
151
151
|
* is already lit while the redirect resolves.
|
|
152
152
|
*/
|
|
153
|
-
export function
|
|
153
|
+
export function isPluginsIndexPath(pathname: string): boolean {
|
|
154
154
|
return (
|
|
155
155
|
matchPath({ path: LIBRARY_ROOT, end: true }, pathname) !== null ||
|
|
156
|
-
matchPath({ path: `${LIBRARY_ROOT}/
|
|
156
|
+
matchPath({ path: `${LIBRARY_ROOT}/plugins`, end: true }, pathname) !== null
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
159
|
|
|
@@ -170,21 +170,21 @@ function decodeSegment(raw: string): string {
|
|
|
170
170
|
* Where an item's back link points: the page the item LIVES on.
|
|
171
171
|
*
|
|
172
172
|
* `‹ All skills & tools` used to be the one answer, and it stopped being
|
|
173
|
-
* true the day the Library's root became the all-
|
|
174
|
-
* opened from its
|
|
173
|
+
* true the day the Library's root became the all-plugins index — a skill
|
|
174
|
+
* opened from its plugin page went "back" to a page the reader had never
|
|
175
175
|
* been on. The honest destination is derivable from the path alone: the
|
|
176
|
-
*
|
|
176
|
+
* plugin page for a grouped item, the personal page for a personal one, and
|
|
177
177
|
* the root only for the legacy shapes that live in neither.
|
|
178
178
|
*/
|
|
179
179
|
export function libraryHomeForItemPath(repoRelativePath: string): {
|
|
180
180
|
label: string;
|
|
181
181
|
path: string;
|
|
182
182
|
} {
|
|
183
|
-
const
|
|
184
|
-
if (
|
|
185
|
-
return { label:
|
|
183
|
+
const plugin = pluginOfPath(repoRelativePath);
|
|
184
|
+
if (plugin !== null && !isPersonalPluginFolder(plugin)) {
|
|
185
|
+
return { label: plugin, path: pathForPlugin(plugin) };
|
|
186
186
|
}
|
|
187
|
-
if (
|
|
187
|
+
if (plugin !== null) {
|
|
188
188
|
return { label: 'Yours', path: `${LIBRARY_ROOT}/yours` };
|
|
189
189
|
}
|
|
190
190
|
return { label: 'All skills & tools', path: LIBRARY_ROOT };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_BRANCH,
|
|
1
|
+
import { DEFAULT_BRANCH, PLUGINS_DIR, type PullRequestSummary } from '@bevel-software/platform-shared';
|
|
2
2
|
import { authFetch } from '../../../lib/api';
|
|
3
3
|
import { handleApiResponse } from '../../git/services/git.api';
|
|
4
4
|
import { createBranch } from '../../git/services/git.api';
|
|
@@ -6,7 +6,7 @@ import { deleteFile, getOrCreateWorkspace, writeFile } from '../../workspace/ser
|
|
|
6
6
|
import { openChangeRequest } from '../../pr/services/pr-open.api';
|
|
7
7
|
import { postPrComment } from '../../pr/services/pr-comments.api';
|
|
8
8
|
import { branchSegment } from '../../change-requests/services/propose.api';
|
|
9
|
-
import {
|
|
9
|
+
import { ensurePersonalPlugin } from './plugins.api';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Library data access. Skills come from the browser skill routes
|
|
@@ -31,7 +31,7 @@ export interface LibrarySkillSummary {
|
|
|
31
31
|
name: string;
|
|
32
32
|
description: string;
|
|
33
33
|
version?: string;
|
|
34
|
-
/** Repo-root-relative skill folder, e.g. `
|
|
34
|
+
/** Repo-root-relative skill folder, e.g. `Plugins/Everyone/rfi`. */
|
|
35
35
|
path: string;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -204,7 +204,7 @@ export type CreateSkillInput = {
|
|
|
204
204
|
userName: string;
|
|
205
205
|
} & (
|
|
206
206
|
| {
|
|
207
|
-
/** Repo-root-relative
|
|
207
|
+
/** Repo-root-relative plugin folder the skill lands in — `Plugins/GTM`. */
|
|
208
208
|
parentPath: string;
|
|
209
209
|
/** False (or unknown) routes the new file through a change request instead. */
|
|
210
210
|
canWrite: boolean;
|
|
@@ -212,7 +212,7 @@ export type CreateSkillInput = {
|
|
|
212
212
|
| {
|
|
213
213
|
/**
|
|
214
214
|
* The skill is the caller's own: it lands in their personal folder
|
|
215
|
-
* (`
|
|
215
|
+
* (`Plugins/personal-<id>/`), which the provisioning endpoint ensures —
|
|
216
216
|
* and commits — first. Always a direct write: the ensured folder's
|
|
217
217
|
* access.md names the caller as owner, so the write gate passes on its
|
|
218
218
|
* own, with no permission special-case anywhere.
|
|
@@ -248,7 +248,7 @@ export interface CreatedSkill {
|
|
|
248
248
|
export async function createEmptySkill(input: CreateSkillInput): Promise<CreatedSkill> {
|
|
249
249
|
const parentPath =
|
|
250
250
|
'personal' in input
|
|
251
|
-
? `${
|
|
251
|
+
? `${PLUGINS_DIR}/${(await ensurePersonalPlugin()).folder}`
|
|
252
252
|
: input.parentPath;
|
|
253
253
|
const repoRelativePath = `${parentPath}/${input.name}/SKILL.md`;
|
|
254
254
|
|
|
@@ -279,11 +279,11 @@ export async function createEmptySkill(input: CreateSkillInput): Promise<Created
|
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
/**
|
|
282
|
-
* Delete a skill folder or tool file from the default branch — the
|
|
283
|
-
* manager's "remove from
|
|
282
|
+
* Delete a skill folder or tool file from the default branch — the plugin
|
|
283
|
+
* manager's "remove from plugin". One call for both shapes: the backend's
|
|
284
284
|
* delete route recurses a folder into per-file lock+commit cycles, and every
|
|
285
285
|
* one of those locks runs the per-path ACL gate, so a caller who does not
|
|
286
|
-
* manage the
|
|
286
|
+
* manage the plugin is refused by the same rule that governs editing it.
|
|
287
287
|
*/
|
|
288
288
|
export async function removeLibraryItem(repoRelativePath: string): Promise<void> {
|
|
289
289
|
const { workspace } = await getOrCreateWorkspace(DEFAULT_BRANCH);
|
|
@@ -2,105 +2,105 @@ import { authFetch } from '../../../lib/api';
|
|
|
2
2
|
import { handleApiResponse } from '../../git/services/git.api';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* `modules/
|
|
5
|
+
* Plugin enumeration + join requests — the browser half of the backend's
|
|
6
|
+
* `modules/plugins`.
|
|
7
7
|
*
|
|
8
8
|
* Enumeration is fail-closed with three ordinary access verdicts: a listed
|
|
9
|
-
*
|
|
10
|
-
* admin-rescued), or may DISCOVER (they can read the
|
|
11
|
-
* file — granted by its own `read: everyone` frontmatter). A
|
|
9
|
+
* plugin is one the caller is a MEMBER of (`canRead`), MANAGES (`canWrite`,
|
|
10
|
+
* admin-rescued), or may DISCOVER (they can read the plugin's `access.md`
|
|
11
|
+
* file — granted by its own `read: everyone` frontmatter). A plugin with no
|
|
12
12
|
* verdict is absent. Asking to join opens a plain change request; nothing
|
|
13
13
|
* request-shaped is stored anywhere else.
|
|
14
14
|
*
|
|
15
|
-
* Every type below MIRRORS the backend contract (`
|
|
15
|
+
* Every type below MIRRORS the backend contract (`plugins.contract.ts`). Keep
|
|
16
16
|
* them in step.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
export interface
|
|
19
|
+
export interface PluginPrincipals {
|
|
20
20
|
roles: string[];
|
|
21
21
|
users: { name: string; email: string }[];
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export interface
|
|
24
|
+
export interface PluginReaders extends PluginPrincipals {
|
|
25
25
|
/** False when `read: everyone` applies cleanly (the lists are then empty). */
|
|
26
26
|
restricted: boolean;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export interface
|
|
30
|
-
/**
|
|
29
|
+
export interface PluginSummary {
|
|
30
|
+
/** Plugin folder name, e.g. `GTM`. */
|
|
31
31
|
name: string;
|
|
32
|
-
/** Repo-relative constituent folders, e.g. `['
|
|
32
|
+
/** Repo-relative constituent folders, e.g. `['Plugins/GTM']`. */
|
|
33
33
|
folders: string[];
|
|
34
34
|
/** Per-caller: can read the folder (membership). Locked === !canRead. */
|
|
35
35
|
canRead: boolean;
|
|
36
|
-
/** Per-caller; true ⇒ may manage the
|
|
36
|
+
/** Per-caller; true ⇒ may manage the plugin's access (admin-rescue applies). */
|
|
37
37
|
canWrite: boolean;
|
|
38
38
|
/**
|
|
39
39
|
* Per-caller: holds the `owner` verb on the folder (owner-lists only, no
|
|
40
|
-
* admin rescue). Deleting the
|
|
40
|
+
* admin rescue). Deleting the plugin is the owner's verb — the DELETE route
|
|
41
41
|
* enforces this same verdict, so it also decides who sees the affordance.
|
|
42
42
|
*/
|
|
43
43
|
isOwner: boolean;
|
|
44
|
-
/** The
|
|
44
|
+
/** The plugin's TOTALS, not the caller's slice. */
|
|
45
45
|
skillCount: number;
|
|
46
46
|
toolCount: number;
|
|
47
|
-
owners:
|
|
48
|
-
writers:
|
|
49
|
-
readers:
|
|
50
|
-
/** The caller has an OPEN join change request for this
|
|
47
|
+
owners: PluginPrincipals;
|
|
48
|
+
writers: PluginPrincipals;
|
|
49
|
+
readers: PluginReaders;
|
|
50
|
+
/** The caller has an OPEN join change request for this plugin. */
|
|
51
51
|
hasRequested: boolean;
|
|
52
52
|
/** That CR's number when `hasRequested` (deep-links the review UI). */
|
|
53
53
|
requestNumber: number | null;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export async function
|
|
57
|
-
const res = await authFetch('/api/
|
|
58
|
-
if (!res.ok) throw new Error("Couldn't load
|
|
59
|
-
const data = (await res.json()) as {
|
|
60
|
-
return data.
|
|
56
|
+
export async function listPlugins(): Promise<PluginSummary[]> {
|
|
57
|
+
const res = await authFetch('/api/plugins');
|
|
58
|
+
if (!res.ok) throw new Error("Couldn't load plugins.");
|
|
59
|
+
const data = (await res.json()) as { plugins: PluginSummary[] };
|
|
60
|
+
return data.plugins;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* Create a
|
|
64
|
+
* Create a plugin — the dedicated provisioning endpoint, not a workspace
|
|
65
65
|
* write. The server owns name validation and the collision verdict (its
|
|
66
66
|
* check is against the live tree, ours against a stale catalog), commits the
|
|
67
67
|
* seeded `access.md` before answering, and refuses with its own words —
|
|
68
68
|
* worth surfacing verbatim.
|
|
69
69
|
*/
|
|
70
|
-
export async function
|
|
71
|
-
const res = await authFetch('/api/
|
|
70
|
+
export async function createPlugin(name: string): Promise<{ folder: string }> {
|
|
71
|
+
const res = await authFetch('/api/plugins', {
|
|
72
72
|
method: 'POST',
|
|
73
73
|
headers: { 'Content-Type': 'application/json' },
|
|
74
74
|
body: JSON.stringify({ name }),
|
|
75
75
|
});
|
|
76
76
|
if (!res.ok) {
|
|
77
77
|
const body = (await res.json().catch(() => ({}))) as { error?: string };
|
|
78
|
-
throw new Error(body.error ?? "Couldn't create that
|
|
78
|
+
throw new Error(body.error ?? "Couldn't create that plugin.");
|
|
79
79
|
}
|
|
80
80
|
return (await res.json()) as { folder: string };
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
* Delete a
|
|
84
|
+
* Delete a plugin — the whole folder, skills and tools included, in one
|
|
85
85
|
* commit. Owner-gated server-side (the `owner` verdict on the folder); a
|
|
86
86
|
* refusal names the rule and is worth surfacing verbatim. Fail-closed: a
|
|
87
|
-
*
|
|
87
|
+
* plugin the caller doesn't own answers exactly like one that doesn't exist.
|
|
88
88
|
*/
|
|
89
|
-
export async function
|
|
90
|
-
const res = await authFetch(`/api/
|
|
89
|
+
export async function deletePlugin(name: string): Promise<void> {
|
|
90
|
+
const res = await authFetch(`/api/plugins/${encodeURIComponent(name)}`, { method: 'DELETE' });
|
|
91
91
|
if (!res.ok) {
|
|
92
92
|
const body = (await res.json().catch(() => ({}))) as { error?: string };
|
|
93
|
-
throw new Error(body.error ?? "Couldn't delete that
|
|
93
|
+
throw new Error(body.error ?? "Couldn't delete that plugin.");
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
* Ensure the caller's personal folder (`
|
|
98
|
+
* Ensure the caller's personal folder (`Plugins/personal-<id>/`) exists.
|
|
99
99
|
* Idempotent; the server answers only after the folder's access.md is
|
|
100
100
|
* COMMITTED, so a write into the folder may follow immediately.
|
|
101
101
|
*/
|
|
102
|
-
export async function
|
|
103
|
-
const res = await authFetch('/api/
|
|
102
|
+
export async function ensurePersonalPlugin(): Promise<{ folder: string; created: boolean }> {
|
|
103
|
+
const res = await authFetch('/api/plugins/personal', { method: 'POST' });
|
|
104
104
|
if (!res.ok) {
|
|
105
105
|
const body = (await res.json().catch(() => ({}))) as { error?: string };
|
|
106
106
|
throw new Error(body.error ?? "Couldn't prepare your personal folder.");
|
|
@@ -111,18 +111,18 @@ export async function ensurePersonalGroup(): Promise<{ folder: string; created:
|
|
|
111
111
|
/**
|
|
112
112
|
* Thrown when a join request is refused because access already landed —
|
|
113
113
|
* between the page load and the click. Not an error to show: the right
|
|
114
|
-
* response is to reload the library and let the
|
|
114
|
+
* response is to reload the library and let the plugin appear unlocked.
|
|
115
115
|
*/
|
|
116
116
|
export class AlreadyReadableError extends Error {
|
|
117
117
|
constructor() {
|
|
118
|
-
super('You can already read this
|
|
118
|
+
super('You can already read this plugin');
|
|
119
119
|
this.name = 'AlreadyReadableError';
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/** Open (or return the existing) join change request. Idempotent server-side. */
|
|
124
|
-
export async function
|
|
125
|
-
const res = await authFetch(`/api/
|
|
124
|
+
export async function requestPluginAccess(name: string): Promise<{ number: number }> {
|
|
125
|
+
const res = await authFetch(`/api/plugins/${encodeURIComponent(name)}/join-request`, {
|
|
126
126
|
method: 'POST',
|
|
127
127
|
});
|
|
128
128
|
if (res.status === 409) {
|
|
@@ -162,13 +162,13 @@ export interface JoinRequest {
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
/**
|
|
165
|
-
* Open join requests for a
|
|
165
|
+
* Open join requests for a plugin the caller MANAGES, each with what it still
|
|
166
166
|
* proposes. Non-managers get `[]` (never a 403), so the caller may ask
|
|
167
|
-
* unconditionally — the same posture every other
|
|
167
|
+
* unconditionally — the same posture every other plugin surface takes.
|
|
168
168
|
*/
|
|
169
169
|
export async function listJoinRequests(name: string): Promise<JoinRequest[]> {
|
|
170
170
|
const data = await handleApiResponse<{ requests: JoinRequest[] }>(
|
|
171
|
-
await authFetch(`/api/
|
|
171
|
+
await authFetch(`/api/plugins/${encodeURIComponent(name)}/join-requests`),
|
|
172
172
|
);
|
|
173
173
|
return data.requests;
|
|
174
174
|
}
|
|
@@ -181,7 +181,7 @@ export async function listJoinRequests(name: string): Promise<JoinRequest[]> {
|
|
|
181
181
|
export async function reconcileJoinRequest(name: string, number: number): Promise<boolean> {
|
|
182
182
|
const data = await handleApiResponse<{ closed: boolean }>(
|
|
183
183
|
await authFetch(
|
|
184
|
-
`/api/
|
|
184
|
+
`/api/plugins/${encodeURIComponent(name)}/join-requests/${number}/reconcile`,
|
|
185
185
|
{ method: 'POST' },
|
|
186
186
|
),
|
|
187
187
|
);
|
|
@@ -58,3 +58,57 @@ export async function getToolDetail(slug: string): Promise<ToolManualDetail> {
|
|
|
58
58
|
if (!res.ok) await unwrap(res, "Couldn't load this tool.");
|
|
59
59
|
return ((await res.json()) as { tool: ToolManualDetail }).tool;
|
|
60
60
|
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The server-scoped view/edit surface for an mcp.json-backed tool. One
|
|
64
|
+
* server's truth spans two files (mcp.json + plugin.json's extensions block);
|
|
65
|
+
* these endpoints are the pair kept in step, so the form never shows a writer
|
|
66
|
+
* half of it. Absent (404) for `.tool`-backed manuals — those edit as files.
|
|
67
|
+
*/
|
|
68
|
+
export type McpTransport = 'streamable-http' | 'sse' | 'stdio';
|
|
69
|
+
|
|
70
|
+
export interface McpServerView {
|
|
71
|
+
name: string;
|
|
72
|
+
transport: McpTransport;
|
|
73
|
+
url?: string;
|
|
74
|
+
command?: string;
|
|
75
|
+
args?: string[];
|
|
76
|
+
cwd?: string;
|
|
77
|
+
env?: Record<string, string>;
|
|
78
|
+
literalHeaders: Record<string, string>;
|
|
79
|
+
authHeaders: Record<string, string>;
|
|
80
|
+
variables: { name: string; scope: 'admin' | 'user'; label?: string }[];
|
|
81
|
+
description?: string;
|
|
82
|
+
local: boolean;
|
|
83
|
+
canWrite: boolean;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export type McpServerWrite = Omit<Partial<McpServerView>, 'name' | 'canWrite'> & {
|
|
87
|
+
transport: McpTransport;
|
|
88
|
+
newName?: string;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export async function getMcpServer(slug: string): Promise<McpServerView | null> {
|
|
92
|
+
const res = await authFetch(`/api/tools/${encodeURIComponent(slug)}/server`);
|
|
93
|
+
if (res.status === 404) {
|
|
94
|
+
// Two 404s share this status and only ONE is an absence: `Not found` is
|
|
95
|
+
// the expected no-server-pair case (a .tool-backed manual), while `Not
|
|
96
|
+
// available` means the edit service isn't wired at all — a deployment
|
|
97
|
+
// fault that must surface, not render as a quietly server-less page.
|
|
98
|
+
const body = (await res.json().catch(() => null)) as { error?: string } | null;
|
|
99
|
+
if (body?.error === 'Not found') return null;
|
|
100
|
+
throw new Error(body?.error ?? "Couldn't load the server configuration.");
|
|
101
|
+
}
|
|
102
|
+
if (!res.ok) await unwrap(res, "Couldn't load the server configuration.");
|
|
103
|
+
return (await res.json()) as McpServerView;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export async function putMcpServer(slug: string, write: McpServerWrite): Promise<{ name: string }> {
|
|
107
|
+
const res = await authFetch(`/api/tools/${encodeURIComponent(slug)}/server`, {
|
|
108
|
+
method: 'PUT',
|
|
109
|
+
headers: { 'Content-Type': 'application/json' },
|
|
110
|
+
body: JSON.stringify(write),
|
|
111
|
+
});
|
|
112
|
+
if (!res.ok) await unwrap(res, "Couldn't save the server configuration.");
|
|
113
|
+
return (await res.json()) as { name: string };
|
|
114
|
+
}
|