@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,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.
|
|
@@ -611,7 +611,7 @@ describe('FileExplorer chevron collapse: userIntent vs autoExpanded', () => {
|
|
|
611
611
|
});
|
|
612
612
|
|
|
613
613
|
// The KB level splits the well-known root folders into labelled top-level
|
|
614
|
-
// sections — with one deliberate exception, `
|
|
614
|
+
// sections — with one deliberate exception, `Plugins/`.
|
|
615
615
|
describe('FileExplorer sections: root folders', () => {
|
|
616
616
|
beforeEach(() => {
|
|
617
617
|
cleanup();
|
|
@@ -645,38 +645,38 @@ describe('FileExplorer sections: root folders', () => {
|
|
|
645
645
|
});
|
|
646
646
|
|
|
647
647
|
/**
|
|
648
|
-
* `
|
|
649
|
-
*
|
|
648
|
+
* `Plugins/` is the Skills & Tools app's storage, and that app presents it as
|
|
649
|
+
* plugins, skills and tools. Listing it here offered a second, worse way in —
|
|
650
650
|
* raw markdown editing of a SKILL.md, on a folder whose access is managed
|
|
651
|
-
* from the
|
|
651
|
+
* from the plugin page.
|
|
652
652
|
*
|
|
653
653
|
* Not shown, and NOT folded into Knowledge either: it is a reserved root, so
|
|
654
654
|
* the "stray content folder" path must not pick it up. Both halves are
|
|
655
655
|
* asserted, because dropping it from the reserved set would still hide the
|
|
656
656
|
* section while quietly moving the whole folder under Knowledge.
|
|
657
657
|
*/
|
|
658
|
-
it('never shows
|
|
658
|
+
it('never shows Plugins in the knowledge view', () => {
|
|
659
659
|
const tree: FileTreeEntry = {
|
|
660
660
|
name: '.',
|
|
661
661
|
relativePath: '.',
|
|
662
662
|
type: 'directory',
|
|
663
|
-
children: [dir('KnowledgeBase'), dir('
|
|
663
|
+
children: [dir('KnowledgeBase'), dir('Plugins')],
|
|
664
664
|
};
|
|
665
665
|
renderExplorer({ fileTree: tree });
|
|
666
666
|
expect(screen.getByText('Knowledge')).toBeInTheDocument();
|
|
667
|
-
expect(screen.queryByText('
|
|
667
|
+
expect(screen.queryByText('Plugins')).not.toBeInTheDocument();
|
|
668
668
|
});
|
|
669
669
|
|
|
670
|
-
/** A KB whose only root is
|
|
671
|
-
it('does not fall back to the flat tree when
|
|
670
|
+
/** A KB whose only root is Plugins still has a knowledge view — an empty one. */
|
|
671
|
+
it('does not fall back to the flat tree when Plugins is the only root', () => {
|
|
672
672
|
const tree: FileTreeEntry = {
|
|
673
673
|
name: '.',
|
|
674
674
|
relativePath: '.',
|
|
675
675
|
type: 'directory',
|
|
676
|
-
children: [dir('
|
|
676
|
+
children: [dir('Plugins')],
|
|
677
677
|
};
|
|
678
678
|
renderExplorer({ fileTree: tree });
|
|
679
|
-
expect(screen.queryByText('
|
|
679
|
+
expect(screen.queryByText('Plugins')).not.toBeInTheDocument();
|
|
680
680
|
});
|
|
681
681
|
});
|
|
682
682
|
|
|
@@ -893,12 +893,12 @@ describe('FileExplorer rows: the prototype tree', () => {
|
|
|
893
893
|
it('does not synthesize a row under a root folder the server hid', () => {
|
|
894
894
|
renderExplorer({
|
|
895
895
|
fileTree: TREE,
|
|
896
|
-
// `
|
|
896
|
+
// `Plugins` is not in TREE — the server filtered it (bevelignored). The
|
|
897
897
|
// touched file underneath must NOT appear.
|
|
898
|
-
minePaths: new Map([['
|
|
898
|
+
minePaths: new Map([['Plugins/newsletter/SKILL.md', 12]]),
|
|
899
899
|
});
|
|
900
900
|
expect(screen.queryByTitle('Proposed by you: opens the change request')).toBeNull();
|
|
901
|
-
expect(screen.queryByText('
|
|
901
|
+
expect(screen.queryByText('Plugins')).toBeNull();
|
|
902
902
|
expect(screen.queryByText('SKILL.md')).toBeNull();
|
|
903
903
|
});
|
|
904
904
|
|
|
@@ -3,6 +3,7 @@ import { parse as parseYaml } from 'yaml';
|
|
|
3
3
|
import { extractFrontmatter } from '@bevel-software/platform-shared';
|
|
4
4
|
import type { FileRendererProps, RendererSaveState } from './types';
|
|
5
5
|
import { authFetch } from '../../../../lib/api';
|
|
6
|
+
import { Surface } from '../../../../shared/components';
|
|
6
7
|
import { Markdown } from '../../../../shared/markdown/Markdown';
|
|
7
8
|
import { ToolForm } from './ToolForm';
|
|
8
9
|
import { ToolSecretsPanel } from '../../../secrets-vault/components/ToolSecretsPanel';
|
|
@@ -268,7 +269,11 @@ export function ToolRenderer({
|
|
|
268
269
|
);
|
|
269
270
|
|
|
270
271
|
return (
|
|
271
|
-
|
|
272
|
+
// The same framed look every prose file gets from its pane card — this
|
|
273
|
+
// renderer is full-bleed (it owns a definite-height two-column layout the
|
|
274
|
+
// auto-height card would collapse), so it draws the frame itself; without
|
|
275
|
+
// it the form floats on the page unlike every other document.
|
|
276
|
+
<Surface tone="surface" radius="lg" elevation="card" className="flex h-full min-h-0 overflow-hidden">
|
|
272
277
|
<div className="flex min-h-0 flex-1 flex-col border-r border-line">
|
|
273
278
|
<div className="flex shrink-0 items-center gap-2 border-b border-line px-3 py-1.5">
|
|
274
279
|
<span className="text-xs font-medium text-ink-muted">{filePath.split('/').pop()}</span>
|
|
@@ -412,6 +417,6 @@ export function ToolRenderer({
|
|
|
412
417
|
)}
|
|
413
418
|
</section>
|
|
414
419
|
</aside>
|
|
415
|
-
</
|
|
420
|
+
</Surface>
|
|
416
421
|
);
|
|
417
422
|
}
|
|
@@ -8,7 +8,7 @@ import { computeDiff } from '../diff';
|
|
|
8
8
|
*/
|
|
9
9
|
describe('computeDiff', () => {
|
|
10
10
|
it('emits removed before added within one change run', () => {
|
|
11
|
-
// `
|
|
11
|
+
// `pluginDiffBlocks` in MarkdownDiffViewer bundles consecutive
|
|
12
12
|
// removed+added runs into one red/green block — interleaving would split
|
|
13
13
|
// a single edit into several blocks.
|
|
14
14
|
const out = computeDiff('a\nold line\nz', 'a\nnew line\nz');
|