@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
|
@@ -3,6 +3,15 @@ import { Link } from 'react-router-dom';
|
|
|
3
3
|
import { Check, Copy, Wrench, ExternalLink } from 'lucide-react';
|
|
4
4
|
import { Dialog } from '../../../shared/components/Dialog';
|
|
5
5
|
import { PageShell } from '../../../shared/components/PageShell';
|
|
6
|
+
import { buttonClasses } from '../../../shared/components';
|
|
7
|
+
import {
|
|
8
|
+
ConnectionInstructions,
|
|
9
|
+
claudeCodeCommand,
|
|
10
|
+
jsonConfigSnippet,
|
|
11
|
+
langdockSnippet,
|
|
12
|
+
mcpEndpointUrl,
|
|
13
|
+
useCopyFeedback,
|
|
14
|
+
} from '../../../shared/mcp';
|
|
6
15
|
import {
|
|
7
16
|
type ExternalApiKeySummary,
|
|
8
17
|
type MintedExternalApiKey,
|
|
@@ -12,29 +21,6 @@ import {
|
|
|
12
21
|
listExternalApiKeys,
|
|
13
22
|
} from '../services/external-api-keys.api';
|
|
14
23
|
|
|
15
|
-
/**
|
|
16
|
-
* "Copied" affordance with a 1500ms auto-reset. Owns the timer + its teardown
|
|
17
|
-
* (so an unmounting page can't fire a stale setState), shared by the reveal
|
|
18
|
-
* modal and every CopyBlock. `copy(text)` writes to the clipboard and flags
|
|
19
|
-
* copied; a rejected write (insecure context / denied permission) leaves the
|
|
20
|
-
* textarea selectable for manual copy and shows no false "Copied".
|
|
21
|
-
*/
|
|
22
|
-
function useCopyFeedback(): { copied: boolean; copy: (text: string) => void } {
|
|
23
|
-
const [copied, setCopied] = useState(false);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (!copied) return;
|
|
26
|
-
const timerId = window.setTimeout(() => setCopied(false), 1500);
|
|
27
|
-
return () => window.clearTimeout(timerId);
|
|
28
|
-
}, [copied]);
|
|
29
|
-
const copy = useCallback((text: string) => {
|
|
30
|
-
void navigator.clipboard
|
|
31
|
-
.writeText(text)
|
|
32
|
-
.then(() => setCopied(true))
|
|
33
|
-
.catch(() => {});
|
|
34
|
-
}, []);
|
|
35
|
-
return { copied, copy };
|
|
36
|
-
}
|
|
37
|
-
|
|
38
24
|
const MAX_LABEL_LEN = 200;
|
|
39
25
|
|
|
40
26
|
function formatRelative(ts: number | null): string {
|
|
@@ -70,6 +56,15 @@ function formatRelative(ts: number | null): string {
|
|
|
70
56
|
export function ExternalAgentAccessPage() {
|
|
71
57
|
const labelInputId = useId();
|
|
72
58
|
|
|
59
|
+
/**
|
|
60
|
+
* What this deployment says its own address is. Read ONCE here and threaded
|
|
61
|
+
* down, so the interactive tab and the key-bearing snippets in the reveal
|
|
62
|
+
* modal cannot end up quoting different servers — which is exactly what
|
|
63
|
+
* happened while six separate sites each rebuilt it from
|
|
64
|
+
* `window.location.origin`.
|
|
65
|
+
*/
|
|
66
|
+
const mcpUrl = mcpEndpointUrl();
|
|
67
|
+
|
|
73
68
|
const [tab, setTab] = useState<'agent' | 'autonomous'>('agent');
|
|
74
69
|
const [keys, setKeys] = useState<ExternalApiKeySummary[]>([]);
|
|
75
70
|
const [loading, setLoading] = useState(false);
|
|
@@ -154,7 +149,7 @@ export function ExternalAgentAccessPage() {
|
|
|
154
149
|
const canSubmit = trimmed.length > 0 && trimmed.length <= MAX_LABEL_LEN && !creating;
|
|
155
150
|
|
|
156
151
|
// Surface the keys that matter: active keys first (most-recently-used at the
|
|
157
|
-
// top, never-used ones last
|
|
152
|
+
// top, never-used ones last among the active), with disconnected keys sunk
|
|
158
153
|
// to the bottom. Non-destructive — nothing is hidden or deleted, just ordered
|
|
159
154
|
// so a long list of stale/test keys doesn't bury the ones in use.
|
|
160
155
|
const sortedKeys = [...keys].sort((a, b) => {
|
|
@@ -197,52 +192,21 @@ export function ExternalAgentAccessPage() {
|
|
|
197
192
|
needed: the first time the agent connects, your browser opens so you can sign in and
|
|
198
193
|
choose which tools to share with it. Everything it saves appears under your name.
|
|
199
194
|
</p>
|
|
195
|
+
{/* `buttonClasses`, not a hand-rolled class string — the one
|
|
196
|
+
button primitive exists because 171 sites once shared 153
|
|
197
|
+
variants between them, and its docstring prescribes exactly
|
|
198
|
+
this shape for links. */}
|
|
200
199
|
<Link
|
|
201
200
|
to="/connect"
|
|
202
201
|
target="_blank"
|
|
203
202
|
rel="noopener noreferrer"
|
|
204
|
-
className=
|
|
203
|
+
className={buttonClasses({ variant: 'outline', size: 'sm', className: 'w-full' })}
|
|
205
204
|
>
|
|
206
205
|
<Wrench size={12} />
|
|
207
206
|
Configure your tools
|
|
208
|
-
<ExternalLink size={11} className="opacity-60" />
|
|
207
|
+
<ExternalLink size={11} className="opacity-60" aria-hidden="true" />
|
|
209
208
|
</Link>
|
|
210
|
-
<
|
|
211
|
-
label="Connect Claude Code"
|
|
212
|
-
value={`claude mcp add --transport http knowledge-base ${window.location.origin}/api/mcp`}
|
|
213
|
-
rows={2}
|
|
214
|
-
/>
|
|
215
|
-
<div>
|
|
216
|
-
<div className="text-xs font-medium text-ink mb-1">claude.ai / Claude Desktop</div>
|
|
217
|
-
<p className="text-[11px] text-ink-muted mb-1 leading-snug">
|
|
218
|
-
Settings → Connectors → Add custom connector, then paste this URL. When asked to
|
|
219
|
-
authorize, your browser opens this app to finish connecting.
|
|
220
|
-
</p>
|
|
221
|
-
<CopyBlock label={null} value={`${window.location.origin}/api/mcp`} rows={1} />
|
|
222
|
-
</div>
|
|
223
|
-
<div>
|
|
224
|
-
<div className="text-xs font-medium text-ink mb-1">Other agents (JSON config)</div>
|
|
225
|
-
<p className="text-[11px] text-ink-muted mb-1 leading-snug">
|
|
226
|
-
Works with Cursor, Windsurf, Cline, and most clients that load servers from a JSON
|
|
227
|
-
config and support signing in.
|
|
228
|
-
</p>
|
|
229
|
-
<CopyBlock
|
|
230
|
-
label={null}
|
|
231
|
-
value={JSON.stringify(
|
|
232
|
-
{
|
|
233
|
-
mcpServers: {
|
|
234
|
-
'knowledge-base': {
|
|
235
|
-
type: 'http',
|
|
236
|
-
url: `${window.location.origin}/api/mcp`,
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
null,
|
|
241
|
-
2,
|
|
242
|
-
)}
|
|
243
|
-
rows={9}
|
|
244
|
-
/>
|
|
245
|
-
</div>
|
|
209
|
+
<ConnectionInstructions mcpUrl={mcpUrl} />
|
|
246
210
|
<p className="text-[11px] text-ink-muted leading-snug">
|
|
247
211
|
Running an unattended pipeline or CI agent that can't open a browser? Use the{' '}
|
|
248
212
|
<button
|
|
@@ -450,7 +414,7 @@ export function ExternalAgentAccessPage() {
|
|
|
450
414
|
</div>
|
|
451
415
|
<textarea
|
|
452
416
|
readOnly
|
|
453
|
-
value={
|
|
417
|
+
value={claudeCodeCommand(mcpUrl, reveal.plaintext)}
|
|
454
418
|
rows={3}
|
|
455
419
|
className="w-full font-mono text-[11px] bg-sunken border border-line rounded px-2 py-1.5 resize-none"
|
|
456
420
|
onFocus={(e) => e.currentTarget.select()}
|
|
@@ -468,7 +432,7 @@ export function ExternalAgentAccessPage() {
|
|
|
468
432
|
</ol>
|
|
469
433
|
<textarea
|
|
470
434
|
readOnly
|
|
471
|
-
value={
|
|
435
|
+
value={langdockSnippet(mcpUrl, reveal.plaintext)}
|
|
472
436
|
rows={3}
|
|
473
437
|
className="w-full font-mono text-[11px] bg-sunken border border-line rounded px-2 py-1.5 resize-none"
|
|
474
438
|
onFocus={(e) => e.currentTarget.select()}
|
|
@@ -483,21 +447,7 @@ export function ExternalAgentAccessPage() {
|
|
|
483
447
|
</p>
|
|
484
448
|
<textarea
|
|
485
449
|
readOnly
|
|
486
|
-
value={
|
|
487
|
-
{
|
|
488
|
-
mcpServers: {
|
|
489
|
-
'knowledge-base': {
|
|
490
|
-
type: 'http',
|
|
491
|
-
url: `${window.location.origin}/api/mcp`,
|
|
492
|
-
headers: {
|
|
493
|
-
Authorization: `Bearer ${reveal.plaintext}`,
|
|
494
|
-
},
|
|
495
|
-
},
|
|
496
|
-
},
|
|
497
|
-
},
|
|
498
|
-
null,
|
|
499
|
-
2,
|
|
500
|
-
)}
|
|
450
|
+
value={jsonConfigSnippet(mcpUrl, reveal.plaintext)}
|
|
501
451
|
rows={11}
|
|
502
452
|
className="w-full font-mono text-[11px] bg-sunken border border-line rounded px-2 py-1.5 resize-none"
|
|
503
453
|
onFocus={(e) => e.currentTarget.select()}
|
|
@@ -518,31 +468,3 @@ export function ExternalAgentAccessPage() {
|
|
|
518
468
|
</>
|
|
519
469
|
);
|
|
520
470
|
}
|
|
521
|
-
|
|
522
|
-
/** Read-only snippet with a copy button, for the no-key connection configs. */
|
|
523
|
-
function CopyBlock({ label, value, rows }: { label: string | null; value: string; rows: number }) {
|
|
524
|
-
const { copied, copy } = useCopyFeedback();
|
|
525
|
-
|
|
526
|
-
return (
|
|
527
|
-
<div>
|
|
528
|
-
<div className="flex items-center justify-between mb-1">
|
|
529
|
-
{label !== null && <div className="text-xs font-medium text-ink">{label}</div>}
|
|
530
|
-
<button
|
|
531
|
-
onClick={() => copy(value)}
|
|
532
|
-
className="ml-auto p-1 rounded hover:bg-hover text-ink-muted"
|
|
533
|
-
aria-label={label ? `Copy: ${label}` : 'Copy to clipboard'}
|
|
534
|
-
title="Copy to clipboard"
|
|
535
|
-
>
|
|
536
|
-
{copied ? <Check size={14} /> : <Copy size={14} />}
|
|
537
|
-
</button>
|
|
538
|
-
</div>
|
|
539
|
-
<textarea
|
|
540
|
-
readOnly
|
|
541
|
-
value={value}
|
|
542
|
-
rows={rows}
|
|
543
|
-
className="w-full font-mono text-[11px] bg-sunken border border-line rounded px-2 py-1.5 resize-none"
|
|
544
|
-
onFocus={(e) => e.currentTarget.select()}
|
|
545
|
-
/>
|
|
546
|
-
</div>
|
|
547
|
-
);
|
|
548
|
-
}
|
|
@@ -93,7 +93,7 @@ describe('AppSwitcher', () => {
|
|
|
93
93
|
*/
|
|
94
94
|
it('honours a shell-provided active app over the URL prefix', () => {
|
|
95
95
|
renderSwitcher({
|
|
96
|
-
path: '/workspace/main/knowledge-base/
|
|
96
|
+
path: '/workspace/main/knowledge-base/Plugins/Sales/create-sales-deck/SKILL.md',
|
|
97
97
|
shellActiveId: 'skills-tools',
|
|
98
98
|
});
|
|
99
99
|
expect(screen.getByRole('button', { name: 'Switch app' })).toHaveTextContent(
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
5
|
+
import { ExternalAgentAccessPage } from '../ExternalAgentAccessPage';
|
|
6
|
+
import { configureMcpUrl } from '../../../../shared/mcp';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The Connect page's contract, and the reason this file exists at all: every
|
|
10
|
+
* address it hands out is the DEPLOYMENT's, never the browser's.
|
|
11
|
+
*
|
|
12
|
+
* Six sites on this page used to rebuild the endpoint from
|
|
13
|
+
* `window.location.origin` — three keyless, three carrying a freshly minted
|
|
14
|
+
* external API key. They agreed with the server's own idea of its address
|
|
15
|
+
* only by luck, and a proxy or a second domain was enough to break it. The
|
|
16
|
+
* regression cases below name all six.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const { listMock, createMock } = vi.hoisted(() => ({
|
|
20
|
+
listMock: vi.fn(),
|
|
21
|
+
createMock: vi.fn(),
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
vi.mock('../../services/external-api-keys.api', () => ({
|
|
25
|
+
listExternalApiKeys: listMock,
|
|
26
|
+
createExternalApiKey: createMock,
|
|
27
|
+
disconnectExternalApiKey: vi.fn(async () => {}),
|
|
28
|
+
deleteExternalApiKey: vi.fn(async () => {}),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
/** A deployment configured the way a real one is: public, https, its own domain. */
|
|
32
|
+
const PUBLIC_URL = 'https://kb.acme.com/api/mcp';
|
|
33
|
+
/** What an unconfigured deployment actually runs with — see `.env.example`. */
|
|
34
|
+
const LOCALHOST_URL = 'http://localhost:3001/api/mcp';
|
|
35
|
+
|
|
36
|
+
const KEY = 'bvl_live_s3cret';
|
|
37
|
+
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
listMock.mockResolvedValue([]);
|
|
40
|
+
createMock.mockResolvedValue({
|
|
41
|
+
plaintext: KEY,
|
|
42
|
+
summary: {
|
|
43
|
+
id: 'k1',
|
|
44
|
+
label: 'CI',
|
|
45
|
+
createdAt: Date.now(),
|
|
46
|
+
lastUsedAt: null,
|
|
47
|
+
revokedAt: null,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
function mount(mcpUrl: string) {
|
|
53
|
+
configureMcpUrl(mcpUrl);
|
|
54
|
+
return render(
|
|
55
|
+
<MemoryRouter>
|
|
56
|
+
<ExternalAgentAccessPage />
|
|
57
|
+
</MemoryRouter>,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Every read-only snippet on screen, as plain strings. */
|
|
62
|
+
function snippets(): string[] {
|
|
63
|
+
return screen
|
|
64
|
+
.getAllByRole('textbox')
|
|
65
|
+
.map((el) => (el as HTMLTextAreaElement).value);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Mint a key so the reveal modal — and its three keyed snippets — is on screen. */
|
|
69
|
+
async function revealAKey(user: ReturnType<typeof userEvent.setup>) {
|
|
70
|
+
await user.click(screen.getByRole('tab', { name: 'Autonomous agents' }));
|
|
71
|
+
await user.type(screen.getByRole('textbox', { name: /Create an external API key/ }), 'CI');
|
|
72
|
+
await user.click(screen.getByRole('button', { name: 'Create key' }));
|
|
73
|
+
await screen.findByRole('heading', { name: /Save this external API key now/ });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
describe('the interactive tab quotes the deployment, not the browser', () => {
|
|
77
|
+
it('builds all three keyless snippets from the configured URL', () => {
|
|
78
|
+
mount(PUBLIC_URL);
|
|
79
|
+
const values = snippets();
|
|
80
|
+
|
|
81
|
+
// 1. the Claude Code one-liner
|
|
82
|
+
expect(values).toContain(
|
|
83
|
+
`claude mcp add --transport http knowledge-base ${PUBLIC_URL}`,
|
|
84
|
+
);
|
|
85
|
+
// 2. the bare URL for claude.ai / Claude Desktop
|
|
86
|
+
expect(values).toContain(PUBLIC_URL);
|
|
87
|
+
// 3. the JSON config for everything else
|
|
88
|
+
const json = values.find((v) => v.includes('mcpServers'));
|
|
89
|
+
expect(JSON.parse(json!).mcpServers['knowledge-base'].url).toBe(PUBLIC_URL);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The regression stated as a negative: the page's own origin must appear
|
|
94
|
+
* nowhere, or one of the six sites quietly went back to deriving it.
|
|
95
|
+
*/
|
|
96
|
+
it('never falls back to the page origin', () => {
|
|
97
|
+
mount(PUBLIC_URL);
|
|
98
|
+
for (const value of snippets()) {
|
|
99
|
+
expect(value).not.toContain(window.location.origin);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('still offers the tool-configuration link', () => {
|
|
104
|
+
mount(PUBLIC_URL);
|
|
105
|
+
expect(screen.getByRole('link', { name: /Configure your tools/ })).toBeInTheDocument();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A bare `<button>` defaults to `type="submit"`. These render inside a
|
|
110
|
+
* shared component that does not get to assume which tree it lands in, and
|
|
111
|
+
* a copy button that submits an enclosing form is a nasty surprise.
|
|
112
|
+
*/
|
|
113
|
+
it('gives every copy button an explicit type so it cannot submit a form', () => {
|
|
114
|
+
mount(PUBLIC_URL);
|
|
115
|
+
const copyButtons = screen.getAllByRole('button', { name: /^Copy/ });
|
|
116
|
+
expect(copyButtons.length).toBeGreaterThan(0);
|
|
117
|
+
for (const button of copyButtons) {
|
|
118
|
+
expect(button).toHaveAttribute('type', 'button');
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('the key-bearing snippets quote the deployment too', () => {
|
|
124
|
+
it('builds all three keyed snippets from the configured URL', async () => {
|
|
125
|
+
const user = userEvent.setup();
|
|
126
|
+
mount(PUBLIC_URL);
|
|
127
|
+
await revealAKey(user);
|
|
128
|
+
const values = snippets();
|
|
129
|
+
|
|
130
|
+
// 4. the Claude Code one-liner, with the key
|
|
131
|
+
expect(values).toContain(
|
|
132
|
+
`claude mcp add --transport http knowledge-base ${PUBLIC_URL} --header "Authorization: Bearer ${KEY}"`,
|
|
133
|
+
);
|
|
134
|
+
// 5. the Langdock field list
|
|
135
|
+
expect(values).toContain(
|
|
136
|
+
`URL: ${PUBLIC_URL}\nHeader name: Authorization\nHeader value: Bearer ${KEY}`,
|
|
137
|
+
);
|
|
138
|
+
// 6. the JSON config, with the key
|
|
139
|
+
const json = values.find((v) => v.includes('mcpServers') && v.includes('headers'));
|
|
140
|
+
const parsed = JSON.parse(json!).mcpServers['knowledge-base'];
|
|
141
|
+
expect(parsed.url).toBe(PUBLIC_URL);
|
|
142
|
+
expect(parsed.headers.Authorization).toBe(`Bearer ${KEY}`);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The consolidation's real risk: three snippets that must carry a secret
|
|
147
|
+
* and three that must not. Losing the token during the move would look
|
|
148
|
+
* like working code and fail at connect time.
|
|
149
|
+
*/
|
|
150
|
+
it('keeps the key in the keyed snippets and out of the keyless ones', async () => {
|
|
151
|
+
const user = userEvent.setup();
|
|
152
|
+
mount(PUBLIC_URL);
|
|
153
|
+
expect(snippets().some((v) => v.includes(KEY))).toBe(false);
|
|
154
|
+
await revealAKey(user);
|
|
155
|
+
expect(snippets().filter((v) => v.includes(KEY))).toHaveLength(
|
|
156
|
+
// the reveal textarea itself, plus the three keyed snippets
|
|
157
|
+
4,
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
describe('the one-click install link', () => {
|
|
163
|
+
it('offers Add to Claude on a reachable deployment', () => {
|
|
164
|
+
mount(PUBLIC_URL);
|
|
165
|
+
const link = screen.getByRole('link', { name: 'Add to Claude' });
|
|
166
|
+
const href = new URL(link.getAttribute('href')!);
|
|
167
|
+
expect(href.origin + href.pathname).toBe('https://claude.ai/customize/connectors');
|
|
168
|
+
expect(href.searchParams.get('modal')).toBe('add-custom-connector');
|
|
169
|
+
expect(href.searchParams.get('connectorUrl')).toBe(PUBLIC_URL);
|
|
170
|
+
expect(href.searchParams.get('connectorName')).toBe('Hexis — kb.acme.com');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('opens in a new tab without handing Claude a window reference', () => {
|
|
174
|
+
mount(PUBLIC_URL);
|
|
175
|
+
const link = screen.getByRole('link', { name: 'Add to Claude' });
|
|
176
|
+
expect(link).toHaveAttribute('target', '_blank');
|
|
177
|
+
expect(link).toHaveAttribute('rel', 'noopener noreferrer');
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The default install. claude.ai fetches the server from Anthropic's
|
|
182
|
+
* infrastructure and cannot reach a laptop, so the button would be dead —
|
|
183
|
+
* and a dead button is worse than none.
|
|
184
|
+
*/
|
|
185
|
+
it('offers nothing to click on a localhost deployment', () => {
|
|
186
|
+
mount(LOCALHOST_URL);
|
|
187
|
+
expect(screen.queryByRole('link', { name: 'Add to Claude' })).toBeNull();
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* ...but this surface's reader is plausibly the person holding the env
|
|
192
|
+
* file, so the dead state names the variable that fixes it. Without this,
|
|
193
|
+
* one-click is a feature nobody can discover they are missing.
|
|
194
|
+
*/
|
|
195
|
+
it('names PUBLIC_BACKEND_URL so an admin can turn it on', () => {
|
|
196
|
+
mount(LOCALHOST_URL);
|
|
197
|
+
expect(screen.getByText(/PUBLIC_BACKEND_URL/)).toBeInTheDocument();
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// Whatever the button does, the manual route stays — it is the only one
|
|
201
|
+
// that works on every deployment.
|
|
202
|
+
it('keeps the copy-paste URL in both states', () => {
|
|
203
|
+
const { unmount } = mount(PUBLIC_URL);
|
|
204
|
+
expect(snippets()).toContain(PUBLIC_URL);
|
|
205
|
+
unmount();
|
|
206
|
+
mount(LOCALHOST_URL);
|
|
207
|
+
expect(snippets()).toContain(LOCALHOST_URL);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
describe('tabs', () => {
|
|
212
|
+
it('starts on the interactive tab', () => {
|
|
213
|
+
mount(PUBLIC_URL);
|
|
214
|
+
const tabs = screen.getAllByRole('tab');
|
|
215
|
+
expect(tabs.map((t) => t.textContent)).toEqual(['Your agent', 'Autonomous agents']);
|
|
216
|
+
expect(tabs[0]).toHaveAttribute('aria-selected', 'true');
|
|
217
|
+
expect(tabs[1]).toHaveAttribute('aria-selected', 'false');
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// The install link belongs to the interactive tab only — the autonomous
|
|
221
|
+
// tab is for agents that cannot open a browser at all.
|
|
222
|
+
it('does not offer one-click connect on the autonomous tab', async () => {
|
|
223
|
+
const user = userEvent.setup();
|
|
224
|
+
mount(PUBLIC_URL);
|
|
225
|
+
await user.click(screen.getByRole('tab', { name: 'Autonomous agents' }));
|
|
226
|
+
expect(screen.queryByRole('link', { name: 'Add to Claude' })).toBeNull();
|
|
227
|
+
});
|
|
228
|
+
});
|
|
@@ -276,7 +276,7 @@ describe('Toolbar', () => {
|
|
|
276
276
|
|
|
277
277
|
// ONE nav toggle, first in the row and left of the brand, for the app's ONE
|
|
278
278
|
// sidebar. There were two buttons here — same glyph, same spot, different
|
|
279
|
-
// state — until Knowledge's file tree and the Library's
|
|
279
|
+
// state — until Knowledge's file tree and the Library's plugin list became
|
|
280
280
|
// the same sidebar.
|
|
281
281
|
describe('sidebar toggle', () => {
|
|
282
282
|
beforeEach(() => setSidebarCollapsed(false));
|
|
@@ -306,7 +306,7 @@ describe('Toolbar', () => {
|
|
|
306
306
|
// follow the claim — the old path test made it vanish here.
|
|
307
307
|
[
|
|
308
308
|
'a canonical /workspace item URL, by the claimed app',
|
|
309
|
-
'/workspace/main/knowledge-base/
|
|
309
|
+
'/workspace/main/knowledge-base/Plugins/Sales/create-sales-deck/SKILL.md',
|
|
310
310
|
false,
|
|
311
311
|
'skills-tools',
|
|
312
312
|
],
|
|
@@ -391,7 +391,7 @@ describe('Toolbar', () => {
|
|
|
391
391
|
await userEvent.click(screen.getByRole('button', { name: 'Test User' }));
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
-
// The panel is a labelled
|
|
394
|
+
// The panel is a labelled PLUGIN of buttons, not a `role="menu"`: it has no
|
|
395
395
|
// arrow-key navigation, so claiming the menu role would promise a keyboard
|
|
396
396
|
// model it does not implement. Every assertion below is the one it always
|
|
397
397
|
// was; only the selector moved.
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
validateFilename,
|
|
22
22
|
KNOWLEDGE_BASE_DIR,
|
|
23
23
|
DATA_DIR,
|
|
24
|
-
|
|
24
|
+
PLUGINS_DIR,
|
|
25
25
|
AGENTS_DIR,
|
|
26
26
|
PIPELINES_DIR,
|
|
27
27
|
} from '@bevel-software/platform-shared';
|
|
@@ -43,7 +43,7 @@ import { useAppRegistry } from '../../../core/registry';
|
|
|
43
43
|
/**
|
|
44
44
|
* The tree row — the prototype's `.trow` (proto:684-693), and token for token
|
|
45
45
|
* the same string as the Library sidebar's `rowClass`
|
|
46
|
-
* (`
|
|
46
|
+
* (`PluginsSidebar.tsx:68-72`). Two sidebars in one app should not read as two
|
|
47
47
|
* different products, and the only way to guarantee that is for both to be
|
|
48
48
|
* this one declaration.
|
|
49
49
|
*
|
|
@@ -982,7 +982,7 @@ export function FileExplorer() {
|
|
|
982
982
|
* read gates). The client cannot evaluate those rules itself, but it can
|
|
983
983
|
* read their verdict off the tree: if the path's top-level folder under
|
|
984
984
|
* the repo root is absent, the whole subtree is hidden (a skill proposal
|
|
985
|
-
* under a bevelignored `
|
|
985
|
+
* under a bevelignored `Plugins/` was the observed leak), so the overlay
|
|
986
986
|
* must not resurrect it. The known cost: a proposal that CREATES a new
|
|
987
987
|
* top-level root folder shows no row until it merges.
|
|
988
988
|
*/
|
|
@@ -1073,12 +1073,12 @@ export function FileExplorer() {
|
|
|
1073
1073
|
// below a divider. Clones that predate the split (none of the well-known root
|
|
1074
1074
|
// dirs) fall back to the flat tree.
|
|
1075
1075
|
//
|
|
1076
|
-
// `
|
|
1077
|
-
// folder per
|
|
1078
|
-
// it as
|
|
1076
|
+
// `Plugins/` is NOT among them. It is the Skills & Tools app's storage — one
|
|
1077
|
+
// folder per plugin holding its skills and its tools — and that app presents
|
|
1078
|
+
// it as plugins, skills and tools rather than as files. Listing it here too
|
|
1079
1079
|
// offered a second, worse way in: raw markdown editing of a SKILL.md with
|
|
1080
1080
|
// none of the surrounding affordances, on a folder whose access is managed
|
|
1081
|
-
// from the
|
|
1081
|
+
// from the plugin page. Deep links into a plugin file still resolve; the
|
|
1082
1082
|
// folder just is not a browsing destination in Knowledge.
|
|
1083
1083
|
//
|
|
1084
1084
|
// `Data/`, `Agents/` and `Pipelines/` are rendered when PRESENT but never
|
|
@@ -1095,17 +1095,17 @@ export function FileExplorer() {
|
|
|
1095
1095
|
const data = findDir(DATA_DIR);
|
|
1096
1096
|
const agents = findDir(AGENTS_DIR);
|
|
1097
1097
|
const pipelines = findDir(PIPELINES_DIR);
|
|
1098
|
-
//
|
|
1098
|
+
// Plugins counts toward "is this a split layout?" even though it is never
|
|
1099
1099
|
// rendered: its presence proves the split just as well as the others, and
|
|
1100
|
-
// without it a KB whose only root is
|
|
1100
|
+
// without it a KB whose only root is Plugins would fail this check, fall
|
|
1101
1101
|
// back to the flat tree, and show the folder that way instead.
|
|
1102
|
-
const
|
|
1103
|
-
if (!knowledgeBase && !data && !agents && !pipelines && !
|
|
1102
|
+
const plugins = findDir(PLUGINS_DIR);
|
|
1103
|
+
if (!knowledgeBase && !data && !agents && !pipelines && !plugins) return null;
|
|
1104
1104
|
// Any other top-level content folder (e.g. a stray `Legal/`) folds into Knowledge.
|
|
1105
1105
|
const otherDirs = kids.filter(
|
|
1106
1106
|
(c) => c.type === 'directory' && !KB_ROOT_DIRS.has(c.name),
|
|
1107
1107
|
);
|
|
1108
|
-
// Present Knowledge, Data and
|
|
1108
|
+
// Present Knowledge, Data, Agents and Pipelines as named roots. Knowledge is
|
|
1109
1109
|
// synthetic so it can relabel `KnowledgeBase` and absorb the stray
|
|
1110
1110
|
// content folders; it reuses KnowledgeBase's own path so file ops on the
|
|
1111
1111
|
// row still resolve.
|
|
@@ -24,7 +24,14 @@ export function FileRoute() {
|
|
|
24
24
|
const params = useParams<{ branch: string; '*': string }>();
|
|
25
25
|
const navigate = useNavigate();
|
|
26
26
|
const location = useLocation();
|
|
27
|
-
|
|
27
|
+
// NOT decoded again: the router percent-decodes path params before handing
|
|
28
|
+
// them over. A second pass turns a branch legitimately named `my%20branch`
|
|
29
|
+
// into `my branch`, which bootstraps the workspace under a branch that does
|
|
30
|
+
// not exist and never matches `currentBranch` — and a name ending in a bare
|
|
31
|
+
// `%` throws a URIError out of render. (`BranchSwitcher` slices the same
|
|
32
|
+
// branch out of `location.pathname` by hand, which IS still encoded, so its
|
|
33
|
+
// decode is correct and stays.)
|
|
34
|
+
const branchFromUrl = params.branch ?? '';
|
|
28
35
|
// The trailing URL segment is either a node id (`/workspace/<branch>/<id>` —
|
|
29
36
|
// the canonical node URL) or a file path (`/workspace/<branch>/<path>`). The id
|
|
30
37
|
// grammar (lowercase, no slash/dot) is disjoint from a real workspace path, so
|