@bevel-software/platform-core-frontend 0.13.6 → 0.15.1
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/package.json +2 -2
- package/src/core/CoreAppShell.tsx +18 -17
- package/src/core/__tests__/bootstrap.test.ts +33 -1
- package/src/core/bootstrap.ts +30 -1
- package/src/lib/__tests__/api.test.ts +38 -0
- package/src/lib/__tests__/utils.test.ts +43 -0
- package/src/lib/api.ts +19 -2
- package/src/lib/utils.ts +17 -7
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +111 -1
- package/src/modules/access/__tests__/plugin-token.test.ts +21 -0
- package/src/modules/access/api.ts +52 -4
- package/src/modules/access/components/ManageAccessDialog.tsx +112 -83
- package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +65 -1
- package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
- package/src/modules/layout/components/SidebarFrame.tsx +1 -1
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +2 -1
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +1 -1
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +121 -0
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +6 -0
- package/src/modules/library/__tests__/McpServerSection.test.tsx +7 -1
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +5 -4
- package/src/modules/library/__tests__/PluginExtras.test.tsx +15 -0
- package/src/modules/library/__tests__/PluginPage.test.tsx +195 -1
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +1 -1
- package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +1 -1
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +64 -3
- package/src/modules/library/__tests__/SkillPage.test.tsx +9 -2
- package/src/modules/library/__tests__/SkillsTree.test.tsx +172 -0
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +216 -8
- package/src/modules/library/__tests__/ToolPage.test.tsx +23 -3
- package/src/modules/library/__tests__/ToolVarRow.test.tsx +7 -7
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +115 -4
- package/src/modules/library/__tests__/library-data.stale.test.tsx +90 -0
- package/src/modules/library/__tests__/library-paths.test.ts +32 -0
- package/src/modules/library/__tests__/link-membership.test.ts +120 -0
- package/src/modules/library/__tests__/plugin-summary.test.ts +32 -0
- package/src/modules/library/__tests__/status.test.ts +84 -0
- package/src/modules/library/__tests__/useJoinRequests.test.tsx +46 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +33 -0
- package/src/modules/library/components/LibraryCard.tsx +21 -1
- package/src/modules/library/components/LibraryLayout.tsx +24 -14
- package/src/modules/library/components/LinkSkillPanel.tsx +171 -0
- package/src/modules/library/components/LockedPluginView.tsx +2 -2
- package/src/modules/library/components/NewPluginDialog.tsx +4 -4
- package/src/modules/library/components/PageActions.tsx +21 -1
- package/src/modules/library/components/PersonalPluginPage.tsx +2 -1
- package/src/modules/library/components/PluginExtras.tsx +3 -1
- package/src/modules/library/components/PluginPage.tsx +92 -12
- package/src/modules/library/components/PluginsIndexPage.tsx +11 -6
- package/src/modules/library/components/PluginsSidebar.tsx +110 -53
- package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
- package/src/modules/library/components/SkillsTree.tsx +91 -0
- package/src/modules/library/components/StatusDot.tsx +1 -0
- package/src/modules/library/components/plugin-page-parts.tsx +32 -9
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +218 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +75 -7
- package/src/modules/library/components/tool-page/McpServerSection.tsx +9 -1
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +223 -8
- package/src/modules/library/components/tool-page/ToolPage.tsx +30 -2
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +30 -8
- package/src/modules/library/hooks/useJoinRequests.ts +48 -18
- package/src/modules/library/hooks/useToolPage.ts +28 -11
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +180 -83
- package/src/modules/library/routes/library-paths.ts +21 -8
- package/src/modules/library/services/library.api.ts +55 -1
- package/src/modules/library/services/plugins.api.ts +94 -3
- package/src/modules/library/state/library-data.tsx +115 -22
- package/src/modules/library/utils/plugin-summary.ts +36 -0
- package/src/modules/library/utils/status.ts +173 -17
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +3 -2
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +29 -14
- package/src/modules/secrets-vault/components/SecretsPage.tsx +4 -1
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +4 -1
- package/src/modules/secrets-vault/services/tool-secrets.api.ts +36 -0
- package/src/modules/settings/components/ClaudeConnectionCard.tsx +169 -0
- package/src/modules/settings/components/DeploymentPage.tsx +15 -1
- package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +10 -0
- package/src/modules/settings/services/github-facade.api.ts +43 -0
- package/src/modules/setup/__tests__/setup.test.tsx +118 -0
- package/src/modules/setup/components/SetupGate.tsx +1 -1
- package/src/modules/setup/components/SetupScreen.tsx +195 -2
- package/src/modules/setup/services/setup.api.ts +78 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +301 -93
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +129 -6
- package/src/modules/toolbar/services/external-api-keys.api.ts +2 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +1 -0
- package/src/modules/workspace/components/FileExplorer.tsx +292 -236
- package/src/modules/workspace/components/FileRoute.tsx +37 -0
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +39 -0
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +1 -0
- package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +70 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +17 -3
- package/src/modules/workspace/routing/kb-routes.ts +1 -1
- package/src/modules/workspace/state/workspace.context.ts +8 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +15 -0
- package/src/modules/workspace/utils/fileTree.ts +14 -16
- package/src/shared/__tests__/marketplace-url.test.ts +54 -0
- package/src/shared/components/Badge.tsx +3 -1
- package/src/shared/components/Banner.tsx +5 -1
- package/src/shared/marketplace-url.ts +90 -0
- package/src/shared/theme/tokens.css +9 -0
|
@@ -40,8 +40,10 @@ const MCP_OAUTH_STATE_KEY = 'mcp-oauth-state';
|
|
|
40
40
|
* sends the browser back to the agent.
|
|
41
41
|
*
|
|
42
42
|
* DESIGN: this page speaks the Library's vocabulary, because it is the other
|
|
43
|
-
* half of the same job. Every state reads
|
|
44
|
-
*
|
|
43
|
+
* half of the same job. Every state reads what is STORED — `Signed in`,
|
|
44
|
+
* `Key saved` — or `Needs …` (never a third phrasing; `Connected` is
|
|
45
|
+
* reserved for the tool page, whose probe actually earns the word), nothing
|
|
46
|
+
* that needs a person is grey, and a tool is
|
|
45
47
|
* identified by its mark before its name — the same `ToolLogo` the gallery
|
|
46
48
|
* cards use. It went through the design system wholesale: no raw palette, no
|
|
47
49
|
* off-scale type, no ad-hoc bordered `div`s pretending to be Surfaces.
|
|
@@ -118,7 +120,9 @@ export function ConnectToolsPage() {
|
|
|
118
120
|
const hash = window.location.hash.replace(/^#/, '');
|
|
119
121
|
if (!hash) return;
|
|
120
122
|
const params = new URLSearchParams(hash);
|
|
121
|
-
|
|
123
|
+
// "Signed in", not "Connected": the sign-in landing here proves a token was
|
|
124
|
+
// issued, not that a call with it will succeed.
|
|
125
|
+
if (params.has('authorized')) setNotice('Signed in. You can go back to your agent and try again.');
|
|
122
126
|
else if (params.has('error')) setError(params.get('error') || 'Authorization failed.');
|
|
123
127
|
if (params.has('authorized') || params.has('error')) {
|
|
124
128
|
window.history.replaceState(null, '', window.location.pathname + window.location.search);
|
|
@@ -301,7 +305,10 @@ export function ConnectToolsPage() {
|
|
|
301
305
|
<>
|
|
302
306
|
{outstanding === 0 && (
|
|
303
307
|
<Banner role="status" tone="ok" className="mb-5">
|
|
304
|
-
|
|
308
|
+
{/* Not "everything is connected": nothing on this page has
|
|
309
|
+
called a provider, so every row above is stored-but-untested.
|
|
310
|
+
The banner has to make the same claim its rows do. */}
|
|
311
|
+
Everything is set up. You can use your tools in your agent.
|
|
305
312
|
</Banner>
|
|
306
313
|
)}
|
|
307
314
|
|
|
@@ -325,7 +332,7 @@ export function ConnectToolsPage() {
|
|
|
325
332
|
: o.needsReauth
|
|
326
333
|
? 'needs-reauth'
|
|
327
334
|
: o.authorized
|
|
328
|
-
? '
|
|
335
|
+
? 'signed-in'
|
|
329
336
|
: 'needs-signin'
|
|
330
337
|
}
|
|
331
338
|
onToggle={() =>
|
|
@@ -354,7 +361,7 @@ export function ConnectToolsPage() {
|
|
|
354
361
|
label={o.label || o.key}
|
|
355
362
|
on
|
|
356
363
|
busy={false}
|
|
357
|
-
state={o.authorized ? '
|
|
364
|
+
state={o.authorized ? 'signed-in' : 'needs-signin'}
|
|
358
365
|
action={
|
|
359
366
|
<Button
|
|
360
367
|
variant="outline"
|
|
@@ -391,7 +398,7 @@ export function ConnectToolsPage() {
|
|
|
391
398
|
label={tool.name}
|
|
392
399
|
on={on}
|
|
393
400
|
busy={wiping.has(id)}
|
|
394
|
-
state={!on ? 'skipped' : unset > 0 ? 'needs-key' : '
|
|
401
|
+
state={!on ? 'skipped' : unset > 0 ? 'needs-key' : 'key-saved'}
|
|
395
402
|
onToggle={() =>
|
|
396
403
|
void onToggle(id, configured, async () => {
|
|
397
404
|
for (const v of tool.variables.filter((x) => x.configured)) {
|
|
@@ -438,18 +445,26 @@ function Section({ title, children }: { title: string; children: React.ReactNode
|
|
|
438
445
|
}
|
|
439
446
|
|
|
440
447
|
/**
|
|
441
|
-
* The
|
|
448
|
+
* The things a row can be — and the words for each.
|
|
442
449
|
*
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
*
|
|
450
|
+
* The same vocabulary the Library uses, because this is the page you land on to
|
|
451
|
+
* FIX what the Library told you was broken and the two must not disagree about
|
|
452
|
+
* what is wrong. "skipped" is the one non-status here: it is a choice you made,
|
|
453
|
+
* not a state of the tool, so it stays grey.
|
|
454
|
+
*
|
|
455
|
+
* Note what is NOT here: `Connected`. This page knows only what is STORED, and
|
|
456
|
+
* the one word that asserts a working connection is reserved for a probe that
|
|
457
|
+
* actually called the provider — which only the tool page does. Two states
|
|
458
|
+
* rather than one, because "signed in" and "key saved" describe two different
|
|
459
|
+
* things the reader did, and telling someone a key was saved when they signed
|
|
460
|
+
* in is a small lie of exactly the kind this vocabulary exists to stop.
|
|
447
461
|
*/
|
|
448
462
|
const ROW_STATE: Record<
|
|
449
|
-
'
|
|
463
|
+
'signed-in' | 'key-saved' | 'needs-signin' | 'needs-reauth' | 'needs-key' | 'skipped',
|
|
450
464
|
{ text: string; tone: 'ok' | 'wait' | 'outline' }
|
|
451
465
|
> = {
|
|
452
|
-
|
|
466
|
+
'signed-in': { text: 'Signed in', tone: 'ok' },
|
|
467
|
+
'key-saved': { text: 'Key saved', tone: 'ok' },
|
|
453
468
|
'needs-signin': { text: 'Needs your sign-in', tone: 'wait' },
|
|
454
469
|
'needs-reauth': { text: 'Needs signing in again', tone: 'wait' },
|
|
455
470
|
'needs-key': { text: 'Needs a key from you', tone: 'wait' },
|
|
@@ -193,7 +193,10 @@ export function SecretsPage() {
|
|
|
193
193
|
{`\${${s.key}}`}
|
|
194
194
|
</code>
|
|
195
195
|
<Badge tone={s.authorized ? 'ok' : 'wait'} size="xs" className="shrink-0">
|
|
196
|
-
{
|
|
196
|
+
{/* "Signed in", not "Connected": a stored token is the whole
|
|
197
|
+
of what this page knows, and only a probe that called the
|
|
198
|
+
provider may claim the connection works. */}
|
|
199
|
+
{s.authorized ? 'Signed in' : 'Needs your sign-in'}
|
|
197
200
|
</Badge>
|
|
198
201
|
<span className="ml-auto flex shrink-0 items-center gap-1.5">
|
|
199
202
|
<Button variant="outline" size="tiny" onClick={() => void onAuthorize(s.id)}>
|
|
@@ -320,10 +320,13 @@ function OAuthVarRow({
|
|
|
320
320
|
size="xs"
|
|
321
321
|
className="shrink-0"
|
|
322
322
|
>
|
|
323
|
+
{/* "Signed in", not "Connected": at variable level all we know is that
|
|
324
|
+
a token is stored. Only the tool page runs a probe, and only a
|
|
325
|
+
probe may claim the connection works. */}
|
|
323
326
|
{v.needsReauth
|
|
324
327
|
? 'Needs signing in again'
|
|
325
328
|
: v.authorized
|
|
326
|
-
? '
|
|
329
|
+
? 'Signed in'
|
|
327
330
|
: 'Needs your sign-in'}
|
|
328
331
|
</Badge>
|
|
329
332
|
<Button
|
|
@@ -45,6 +45,27 @@ export interface ToolSetup {
|
|
|
45
45
|
reason?: string;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* The verdict of the last credential PROBE — a different question from every
|
|
50
|
+
* `ToolVarStatus` field, which say only what is STORED.
|
|
51
|
+
*
|
|
52
|
+
* - `ok` — the provider was called and accepted the credential.
|
|
53
|
+
* - `failed` — the provider rejected it; `detail` is what it said.
|
|
54
|
+
* - `unverifiable` — we don't know: either the tool offers no way to test it,
|
|
55
|
+
* or the attempt couldn't reach a verdict. `detail` says which.
|
|
56
|
+
*
|
|
57
|
+
* NOT stored anywhere. A verdict is returned to the page that asked for it and
|
|
58
|
+
* lives in that page's state until it is closed or reloaded — because a saved
|
|
59
|
+
* verdict is evidence with a date on it, and a credential can be revoked or
|
|
60
|
+
* expire between the check and the render. "Connected" therefore means "a call
|
|
61
|
+
* succeeded moments ago", which is the only claim a badge can honestly make.
|
|
62
|
+
*/
|
|
63
|
+
export interface ProbeVerdict {
|
|
64
|
+
status: 'ok' | 'failed' | 'unverifiable';
|
|
65
|
+
detail: string | null;
|
|
66
|
+
checkedAt: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
48
69
|
export interface ToolSecrets {
|
|
49
70
|
slug: string;
|
|
50
71
|
name: string;
|
|
@@ -111,6 +132,21 @@ export async function setOAuthClientSecret(slug: string, varName: string, client
|
|
|
111
132
|
if (!res.ok) await unwrap(res, "Couldn't save the client secret.");
|
|
112
133
|
}
|
|
113
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Probe this tool's credential NOW and return the verdict.
|
|
137
|
+
*
|
|
138
|
+
* Called after saving a key so the user learns immediately whether it works,
|
|
139
|
+
* while they still have it to hand — the moment a wrong key is cheapest to fix.
|
|
140
|
+
* A rejected credential is a SUCCESSFUL check, so it resolves with
|
|
141
|
+
* `status: 'failed'` rather than throwing; only a transport or access failure
|
|
142
|
+
* rejects.
|
|
143
|
+
*/
|
|
144
|
+
export async function checkToolConnection(slug: string): Promise<ProbeVerdict> {
|
|
145
|
+
const res = await authFetch(`/api/secrets/tools/${encodeURIComponent(slug)}/check`, { method: 'POST' });
|
|
146
|
+
if (!res.ok) await unwrap(res, "Couldn't test this connection.");
|
|
147
|
+
return ((await res.json()) as { verdict: ProbeVerdict }).verdict;
|
|
148
|
+
}
|
|
149
|
+
|
|
114
150
|
export const setAdminVar = (slug: string, varName: string, value: string, label?: string | null) =>
|
|
115
151
|
putVar(slug, varName, 'admin', value, label);
|
|
116
152
|
export const setUserVar = (slug: string, varName: string, value: string, label?: string | null) =>
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Banner, Button } from '../../../shared/components';
|
|
3
|
+
import { Dialog } from '../../../shared/components/Dialog';
|
|
4
|
+
import { CopyBlock } from '../../../shared/mcp';
|
|
5
|
+
import {
|
|
6
|
+
fetchGitHubFacade,
|
|
7
|
+
rotateGitHubFacade,
|
|
8
|
+
type GitHubFacadeCredentials,
|
|
9
|
+
} from '../services/github-facade.api';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The admin's half of "add this marketplace in Cowork or claude.ai".
|
|
13
|
+
*
|
|
14
|
+
* Those surfaces sync marketplaces only from hosts they know, and the one
|
|
15
|
+
* kind of host an organization can add itself is a GitHub Enterprise Server.
|
|
16
|
+
* Hexis presents itself as one: an Owner registers this deployment once in
|
|
17
|
+
* Claude's admin settings, pasting the fields below, and from then on every
|
|
18
|
+
* person connects their own claude.ai account through the ordinary hexis
|
|
19
|
+
* sign-in and gets the marketplace compiled for what they may read.
|
|
20
|
+
*
|
|
21
|
+
* The fields are exactly the ones the "Add manually" form asks for, in its
|
|
22
|
+
* order, so the card reads as a copy source, not a form of its own. Rotate
|
|
23
|
+
* replaces the generated ones: the registration on the Claude side stops
|
|
24
|
+
* matching until an Owner re-enters them, while people's existing
|
|
25
|
+
* connections — connection keys, ours — keep working.
|
|
26
|
+
*
|
|
27
|
+
* What is on screen is always the LATEST answer the server gave: a load
|
|
28
|
+
* that was in flight when a rotation returned is discarded, never applied
|
|
29
|
+
* over the new set — an admin copying pre-rotation values into Claude would
|
|
30
|
+
* register a secret that no longer exists.
|
|
31
|
+
*/
|
|
32
|
+
export function ClaudeConnectionCard() {
|
|
33
|
+
const [creds, setCreds] = useState<GitHubFacadeCredentials | null>(null);
|
|
34
|
+
const [error, setError] = useState<string | null>(null);
|
|
35
|
+
const [loaded, setLoaded] = useState(false);
|
|
36
|
+
const [confirmRotate, setConfirmRotate] = useState(false);
|
|
37
|
+
const [rotating, setRotating] = useState(false);
|
|
38
|
+
const [rotateError, setRotateError] = useState<string | null>(null);
|
|
39
|
+
// Every request takes a number; only the newest one's answer is applied.
|
|
40
|
+
const latest = useRef(0);
|
|
41
|
+
|
|
42
|
+
const refresh = useCallback(() => {
|
|
43
|
+
const seq = ++latest.current;
|
|
44
|
+
fetchGitHubFacade()
|
|
45
|
+
.then((c) => {
|
|
46
|
+
if (seq !== latest.current) return;
|
|
47
|
+
setCreds(c);
|
|
48
|
+
setError(null);
|
|
49
|
+
})
|
|
50
|
+
.catch((err: unknown) => {
|
|
51
|
+
if (seq !== latest.current) return;
|
|
52
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
53
|
+
})
|
|
54
|
+
.finally(() => {
|
|
55
|
+
if (seq === latest.current) setLoaded(true);
|
|
56
|
+
});
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
useEffect(refresh, [refresh]);
|
|
60
|
+
|
|
61
|
+
const rotate = async () => {
|
|
62
|
+
const seq = ++latest.current;
|
|
63
|
+
setRotating(true);
|
|
64
|
+
setRotateError(null);
|
|
65
|
+
try {
|
|
66
|
+
const next = await rotateGitHubFacade();
|
|
67
|
+
if (seq !== latest.current) return;
|
|
68
|
+
setCreds(next);
|
|
69
|
+
setError(null);
|
|
70
|
+
setConfirmRotate(false);
|
|
71
|
+
} catch (err) {
|
|
72
|
+
// Inside the dialog, where the person is looking — not behind its scrim.
|
|
73
|
+
if (seq === latest.current) setRotateError(err instanceof Error ? err.message : String(err));
|
|
74
|
+
} finally {
|
|
75
|
+
setRotating(false);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const closeRotate = () => {
|
|
80
|
+
setConfirmRotate(false);
|
|
81
|
+
setRotateError(null);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<section aria-labelledby="claude-connection-heading" className="space-y-3">
|
|
86
|
+
<div>
|
|
87
|
+
<h2 id="claude-connection-heading" className="text-title font-semibold text-ink">
|
|
88
|
+
Claude connection
|
|
89
|
+
</h2>
|
|
90
|
+
<p className="mt-1 text-xs text-ink-muted leading-snug">
|
|
91
|
+
Lets people add this deployment's skills marketplace in Cowork and on claude.ai, which
|
|
92
|
+
accept marketplaces only from a GitHub Enterprise Server their organization registered.
|
|
93
|
+
Hexis answers as one. Register it once (Owner role, Team or Enterprise plan): in Claude's
|
|
94
|
+
admin settings, under Claude Code, GitHub Enterprise Server, choose <b>Add manually</b>{' '}
|
|
95
|
+
and paste the fields below. When it asks you to connect your GitHub Enterprise account,
|
|
96
|
+
you sign in here.
|
|
97
|
+
</p>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
{!loaded && <div className="text-xs text-ink-muted">Loading…</div>}
|
|
101
|
+
|
|
102
|
+
{error && (
|
|
103
|
+
<Banner tone="danger" role="alert">
|
|
104
|
+
{error}
|
|
105
|
+
<Button variant="outline" size="sm" className="ml-3" onClick={refresh}>
|
|
106
|
+
Try again
|
|
107
|
+
</Button>
|
|
108
|
+
</Banner>
|
|
109
|
+
)}
|
|
110
|
+
|
|
111
|
+
{creds && (
|
|
112
|
+
<div className="border border-line rounded p-3 space-y-3">
|
|
113
|
+
<CopyBlock label="Hostname" value={creds.host} rows={1} />
|
|
114
|
+
<CopyBlock label="App ID" value={creds.appId} rows={1} />
|
|
115
|
+
<CopyBlock label="Client ID" value={creds.clientId} rows={1} />
|
|
116
|
+
<CopyBlock label="Client secret" value={creds.clientSecret} rows={1} />
|
|
117
|
+
<CopyBlock label="Webhook secret" value={creds.webhookSecret} rows={1} />
|
|
118
|
+
<CopyBlock label="Private key" value={creds.privateKeyPem} rows={6} />
|
|
119
|
+
<p className="text-meta text-ink-muted leading-snug">
|
|
120
|
+
The webhook URL Claude generates after saving can be ignored: nothing here sends
|
|
121
|
+
webhooks yet. The private key is required by the form but not used by the
|
|
122
|
+
user-added marketplace flow.
|
|
123
|
+
</p>
|
|
124
|
+
<CopyBlock label="Marketplace URL people add" value={creds.marketplaceUrl} rows={1} />
|
|
125
|
+
<div className="flex items-center justify-between gap-3">
|
|
126
|
+
<span className="text-meta text-ink-muted">
|
|
127
|
+
{creds.rotatedAt
|
|
128
|
+
? `Rotated ${new Date(creds.rotatedAt).toLocaleString()}`
|
|
129
|
+
: `Generated ${new Date(creds.createdAt).toLocaleString()}`}
|
|
130
|
+
</span>
|
|
131
|
+
<Button variant="outline" size="sm" onClick={() => setConfirmRotate(true)}>
|
|
132
|
+
Rotate credentials
|
|
133
|
+
</Button>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
)}
|
|
137
|
+
|
|
138
|
+
<Dialog
|
|
139
|
+
open={confirmRotate}
|
|
140
|
+
onClose={closeRotate}
|
|
141
|
+
title="Rotate the Claude connection credentials?"
|
|
142
|
+
size="sm"
|
|
143
|
+
busy={rotating}
|
|
144
|
+
footer={
|
|
145
|
+
<>
|
|
146
|
+
<Button variant="outline" size="sm" onClick={closeRotate} disabled={rotating}>
|
|
147
|
+
Cancel
|
|
148
|
+
</Button>
|
|
149
|
+
<Button variant="danger" size="sm" onClick={() => void rotate()} disabled={rotating}>
|
|
150
|
+
{rotating ? 'Rotating…' : rotateError ? 'Try again' : 'Rotate'}
|
|
151
|
+
</Button>
|
|
152
|
+
</>
|
|
153
|
+
}
|
|
154
|
+
>
|
|
155
|
+
<p className="text-sm text-ink">
|
|
156
|
+
The App ID, Client ID, client secret, webhook secret and private key change; the
|
|
157
|
+
hostname and the marketplace URL stay the same. The registration in Claude's admin
|
|
158
|
+
settings stops working until an Owner enters the new values there. People who already
|
|
159
|
+
connected keep their connection.
|
|
160
|
+
</p>
|
|
161
|
+
{rotateError && (
|
|
162
|
+
<Banner tone="danger" role="alert" className="mt-3">
|
|
163
|
+
{rotateError}
|
|
164
|
+
</Banner>
|
|
165
|
+
)}
|
|
166
|
+
</Dialog>
|
|
167
|
+
</section>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
@@ -4,6 +4,7 @@ import { Banner, Button } from '../../../shared/components';
|
|
|
4
4
|
import { useAdmin } from '../../admin/state/admin.context';
|
|
5
5
|
import { fetchSetupStatus, type SetupStatus } from '../../setup/services/setup.api';
|
|
6
6
|
import { SetupScreen } from '../../setup/components/SetupScreen';
|
|
7
|
+
import { ClaudeConnectionCard } from './ClaudeConnectionCard';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Deployment settings, routed at `/deployment` — the first-run setup screen
|
|
@@ -82,7 +83,20 @@ export function DeploymentPage() {
|
|
|
82
83
|
|
|
83
84
|
{loaded && status?.settings && (
|
|
84
85
|
<div className="mt-6">
|
|
85
|
-
<SetupScreen
|
|
86
|
+
<SetupScreen
|
|
87
|
+
settings={status.settings}
|
|
88
|
+
sync={status.sync}
|
|
89
|
+
onSaved={refresh}
|
|
90
|
+
variant="settings"
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
|
|
95
|
+
{/* Below the settings form, not inside it: these are generated, not
|
|
96
|
+
typed — a copy source for Claude's admin settings, with one verb. */}
|
|
97
|
+
{loaded && status?.settings && (
|
|
98
|
+
<div className="mt-10">
|
|
99
|
+
<ClaudeConnectionCard />
|
|
86
100
|
</div>
|
|
87
101
|
)}
|
|
88
102
|
</PageShell>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { ClaudeConnectionCard } from '../ClaudeConnectionCard';
|
|
5
|
+
|
|
6
|
+
const { fetchMock, rotateMock } = vi.hoisted(() => ({ fetchMock: vi.fn(), rotateMock: vi.fn() }));
|
|
7
|
+
vi.mock('../../services/github-facade.api', () => ({
|
|
8
|
+
fetchGitHubFacade: fetchMock,
|
|
9
|
+
rotateGitHubFacade: rotateMock,
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
const CREDS = {
|
|
13
|
+
host: 'kb.acme.com',
|
|
14
|
+
appId: '123456',
|
|
15
|
+
clientId: 'Iv1.0123456789abcdef',
|
|
16
|
+
clientSecret: 'secret-1',
|
|
17
|
+
webhookSecret: 'hook-1',
|
|
18
|
+
privateKeyPem: '-----BEGIN RSA PRIVATE KEY-----\nabc\n-----END RSA PRIVATE KEY-----\n',
|
|
19
|
+
marketplaceUrl: 'https://kb.acme.com/git/marketplace.git',
|
|
20
|
+
createdAt: Date.UTC(2026, 8, 7),
|
|
21
|
+
rotatedAt: null,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
fetchMock.mockReset().mockResolvedValue(CREDS);
|
|
26
|
+
rotateMock.mockReset().mockResolvedValue({ ...CREDS, clientId: 'Iv1.fedcba9876543210', clientSecret: 'secret-2', rotatedAt: Date.now() });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/** Every textarea's value — the card is a copy source, so its values are its contract. */
|
|
30
|
+
const values = () => screen.getAllByRole('textbox').map((el) => (el as HTMLTextAreaElement).value);
|
|
31
|
+
|
|
32
|
+
describe('ClaudeConnectionCard', () => {
|
|
33
|
+
it("shows every field Claude's Add-manually form asks for, plus the URL people add", async () => {
|
|
34
|
+
render(<ClaudeConnectionCard />);
|
|
35
|
+
await screen.findByText('Hostname');
|
|
36
|
+
const shown = values();
|
|
37
|
+
for (const v of [CREDS.host, CREDS.appId, CREDS.clientId, CREDS.clientSecret, CREDS.webhookSecret, CREDS.privateKeyPem, CREDS.marketplaceUrl]) {
|
|
38
|
+
expect(shown).toContain(v);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('rotates only after a confirmation, and shows the new set', async () => {
|
|
43
|
+
const user = userEvent.setup();
|
|
44
|
+
render(<ClaudeConnectionCard />);
|
|
45
|
+
await screen.findByText('Hostname');
|
|
46
|
+
await user.click(screen.getByRole('button', { name: 'Rotate credentials' }));
|
|
47
|
+
expect(rotateMock).not.toHaveBeenCalled();
|
|
48
|
+
await user.click(screen.getByRole('button', { name: 'Rotate' }));
|
|
49
|
+
await waitFor(() => expect(rotateMock).toHaveBeenCalledTimes(1));
|
|
50
|
+
await waitFor(() => expect(values()).toContain('secret-2'));
|
|
51
|
+
expect(values()).not.toContain('secret-1');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('says what went wrong and offers a retry', async () => {
|
|
55
|
+
fetchMock.mockRejectedValueOnce(new Error('SECRETS_ENC_KEY is not set, so the Claude connection credentials cannot be stored.'));
|
|
56
|
+
const user = userEvent.setup();
|
|
57
|
+
render(<ClaudeConnectionCard />);
|
|
58
|
+
const alert = await screen.findByRole('alert');
|
|
59
|
+
expect(alert).toHaveTextContent('SECRETS_ENC_KEY');
|
|
60
|
+
await user.click(screen.getByRole('button', { name: 'Try again' }));
|
|
61
|
+
await screen.findByText('Hostname');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -11,6 +11,16 @@ import { AdminContext, type AdminContextValue } from '../../../admin/state/admin
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
const apiMock = vi.hoisted(() => ({ fetchSetupStatus: vi.fn(), saveSettings: vi.fn() }));
|
|
14
|
+
// The Claude connection card fetches its credentials on mount; answer it so
|
|
15
|
+
// its retry button never stands beside the page's own.
|
|
16
|
+
vi.mock('../../services/github-facade.api', () => ({
|
|
17
|
+
fetchGitHubFacade: vi.fn(async () => ({
|
|
18
|
+
host: 'kb.test', appId: '123456', clientId: 'Iv1.x', clientSecret: 's', webhookSecret: 'w',
|
|
19
|
+
privateKeyPem: 'p', marketplaceUrl: 'https://kb.test/git/marketplace.git', createdAt: 0, rotatedAt: null,
|
|
20
|
+
})),
|
|
21
|
+
rotateGitHubFacade: vi.fn(),
|
|
22
|
+
}));
|
|
23
|
+
|
|
14
24
|
vi.mock('../../../setup/services/setup.api', async (importOriginal) => ({
|
|
15
25
|
...(await importOriginal<object>()),
|
|
16
26
|
fetchSetupStatus: apiMock.fetchSetupStatus,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { authFetch } from '../../../lib/api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What an Owner pastes into Claude's admin settings to register this
|
|
5
|
+
* deployment as a GitHub Enterprise Server — the credentials hexis generated
|
|
6
|
+
* for that purpose. Admins only; every field is shown so it can be copied.
|
|
7
|
+
*/
|
|
8
|
+
export interface GitHubFacadeCredentials {
|
|
9
|
+
/** The hostname to register. */
|
|
10
|
+
host: string;
|
|
11
|
+
appId: string;
|
|
12
|
+
clientId: string;
|
|
13
|
+
clientSecret: string;
|
|
14
|
+
webhookSecret: string;
|
|
15
|
+
privateKeyPem: string;
|
|
16
|
+
/** The marketplace URL people paste in Cowork and claude.ai — the same one Claude Code clones. */
|
|
17
|
+
marketplaceUrl: string;
|
|
18
|
+
createdAt: number;
|
|
19
|
+
rotatedAt: number | null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function unwrap(res: Response, fallback: string): Promise<never> {
|
|
23
|
+
let serverError: string | undefined;
|
|
24
|
+
try {
|
|
25
|
+
const body = (await res.json()) as { error?: string };
|
|
26
|
+
if (typeof body.error === 'string' && body.error.length > 0) serverError = body.error;
|
|
27
|
+
} catch {
|
|
28
|
+
// Non-JSON error body — fall through.
|
|
29
|
+
}
|
|
30
|
+
throw new Error(serverError ?? fallback);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function fetchGitHubFacade(): Promise<GitHubFacadeCredentials> {
|
|
34
|
+
const res = await authFetch('/api/admin/github-facade');
|
|
35
|
+
if (!res.ok) await unwrap(res, "Couldn't load the Claude connection.");
|
|
36
|
+
return res.json() as Promise<GitHubFacadeCredentials>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function rotateGitHubFacade(): Promise<GitHubFacadeCredentials> {
|
|
40
|
+
const res = await authFetch('/api/admin/github-facade/rotate', { method: 'POST' });
|
|
41
|
+
if (!res.ok) await unwrap(res, "Couldn't rotate the Claude connection.");
|
|
42
|
+
return res.json() as Promise<GitHubFacadeCredentials>;
|
|
43
|
+
}
|
|
@@ -6,6 +6,7 @@ const api = vi.hoisted(() => ({
|
|
|
6
6
|
fetchSetupStatus: vi.fn(),
|
|
7
7
|
saveSettings: vi.fn(),
|
|
8
8
|
testConnection: vi.fn(),
|
|
9
|
+
syncNow: vi.fn(),
|
|
9
10
|
}));
|
|
10
11
|
vi.mock('../services/setup.api', async () => {
|
|
11
12
|
// The error class is real — the screen distinguishes field problems from a
|
|
@@ -43,6 +44,7 @@ beforeEach(() => {
|
|
|
43
44
|
api.fetchSetupStatus.mockReset();
|
|
44
45
|
api.saveSettings.mockReset();
|
|
45
46
|
api.testConnection.mockReset();
|
|
47
|
+
api.syncNow.mockReset();
|
|
46
48
|
reload = vi.fn();
|
|
47
49
|
Object.defineProperty(window, 'location', {
|
|
48
50
|
configurable: true,
|
|
@@ -741,3 +743,119 @@ describe('SetupScreen', () => {
|
|
|
741
743
|
expect(await screen.findByText(/restart it when convenient/)).toBeInTheDocument();
|
|
742
744
|
});
|
|
743
745
|
});
|
|
746
|
+
|
|
747
|
+
describe('SetupScreen — remote sync panel', () => {
|
|
748
|
+
const SYNC_SETTING: SettingStatus = {
|
|
749
|
+
key: 'kbSyncSecret', envVar: 'KB_SYNC_SECRET', section: KB, source: 'unset', configured: false, secret: true, restartToApply: false,
|
|
750
|
+
};
|
|
751
|
+
const SYNC = {
|
|
752
|
+
url: 'https://hexis.example.test/api/sync',
|
|
753
|
+
last: {
|
|
754
|
+
at: Date.UTC(2026, 8, 4, 12, 0, 0),
|
|
755
|
+
by: 'github-signature',
|
|
756
|
+
status: 'synced' as const,
|
|
757
|
+
results: [{ branch: 'main', outcome: 'updated' as const, from: 'aaa', to: 'bbb' }],
|
|
758
|
+
},
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
it('shows the address a hook calls on first run, without a Sync now button', () => {
|
|
762
|
+
render(<SetupScreen settings={[...SETTINGS, SYNC_SETTING]} sync={SYNC} onSaved={() => {}} />);
|
|
763
|
+
expect(screen.getByText('https://hexis.example.test/api/sync/<branch>')).toBeTruthy();
|
|
764
|
+
expect(screen.getByRole('button', { name: 'Copy the sync address' })).toBeTruthy();
|
|
765
|
+
// The 'setup' variant never offers the button or the history, whatever the
|
|
766
|
+
// record says: on first run the repository behind them is not connected yet.
|
|
767
|
+
expect(screen.queryByRole('button', { name: 'Sync now' })).toBeNull();
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
it('shows the address on the Deployment page too', () => {
|
|
771
|
+
render(
|
|
772
|
+
<SetupScreen settings={[...SETTINGS, SYNC_SETTING]} sync={SYNC} onSaved={() => {}} variant="settings" />,
|
|
773
|
+
);
|
|
774
|
+
expect(screen.getByText('https://hexis.example.test/api/sync/<branch>')).toBeTruthy();
|
|
775
|
+
expect(screen.getByRole('button', { name: 'Sync now' })).toBeTruthy();
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
it('keeps the panel when the secret is set by the environment', () => {
|
|
779
|
+
const fromEnv: SettingStatus = { ...SYNC_SETTING, source: 'env', configured: true };
|
|
780
|
+
render(
|
|
781
|
+
<SetupScreen settings={[...SETTINGS, fromEnv]} sync={SYNC} onSaved={() => {}} variant="settings" />,
|
|
782
|
+
);
|
|
783
|
+
// The secret itself is locked, listed under the environment…
|
|
784
|
+
expect(screen.getByText('KB_SYNC_SECRET')).toBeTruthy();
|
|
785
|
+
// …but the address, the history and Sync now are still there.
|
|
786
|
+
expect(screen.getByText('https://hexis.example.test/api/sync/<branch>')).toBeTruthy();
|
|
787
|
+
expect(screen.getByRole('button', { name: 'Sync now' })).toBeTruthy();
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
it('on the Deployment page: says what the last sync did, and Sync now reports the result', async () => {
|
|
791
|
+
api.syncNow.mockResolvedValue({
|
|
792
|
+
ok: true,
|
|
793
|
+
status: 'synced',
|
|
794
|
+
results: [
|
|
795
|
+
{ branch: 'main', outcome: 'updated' },
|
|
796
|
+
{ branch: 'ali/x', outcome: 'up-to-date' },
|
|
797
|
+
],
|
|
798
|
+
});
|
|
799
|
+
const onSaved = vi.fn();
|
|
800
|
+
render(
|
|
801
|
+
<SetupScreen
|
|
802
|
+
settings={[...SETTINGS, SYNC_SETTING]}
|
|
803
|
+
sync={SYNC}
|
|
804
|
+
onSaved={onSaved}
|
|
805
|
+
variant="settings"
|
|
806
|
+
/>,
|
|
807
|
+
);
|
|
808
|
+
expect(screen.getByText(/Last sync .* by github-signature: main updated\./)).toBeTruthy();
|
|
809
|
+
|
|
810
|
+
await userEvent.click(screen.getByRole('button', { name: 'Sync now' }));
|
|
811
|
+
await waitFor(() => expect(screen.getByText('Synced: main updated, ali/x up to date.')).toBeTruthy());
|
|
812
|
+
expect(api.syncNow).toHaveBeenCalledTimes(1);
|
|
813
|
+
// The status carries the last-sync record, so the page refetches it.
|
|
814
|
+
expect(onSaved).toHaveBeenCalled();
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
it('a conflict comes back as the branch’s own message', async () => {
|
|
818
|
+
api.syncNow.mockResolvedValue({
|
|
819
|
+
ok: false,
|
|
820
|
+
status: 'partial',
|
|
821
|
+
results: [
|
|
822
|
+
{ branch: 'main', outcome: 'conflict', error: 'main is not in sync yet: a.md changed both in Hexis and on the git host.' },
|
|
823
|
+
],
|
|
824
|
+
});
|
|
825
|
+
render(
|
|
826
|
+
<SetupScreen
|
|
827
|
+
settings={[...SETTINGS, SYNC_SETTING]}
|
|
828
|
+
sync={{ ...SYNC, last: null }}
|
|
829
|
+
onSaved={() => {}}
|
|
830
|
+
variant="settings"
|
|
831
|
+
/>,
|
|
832
|
+
);
|
|
833
|
+
expect(screen.getByText('No sync since this server started.')).toBeTruthy();
|
|
834
|
+
await userEvent.click(screen.getByRole('button', { name: 'Sync now' }));
|
|
835
|
+
await waitFor(() =>
|
|
836
|
+
expect(screen.getByText(/main is not in sync yet: a\.md changed both/)).toBeTruthy(),
|
|
837
|
+
);
|
|
838
|
+
});
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
describe('SetupScreen — sync panel when the whole knowledge base is env-set', () => {
|
|
842
|
+
it('still renders the address and Sync now, in a section of its own', () => {
|
|
843
|
+
const KB_FROM_ENV: SettingStatus[] = SETTINGS.map((s) =>
|
|
844
|
+
s.section === 'knowledge-base' ? { ...s, source: 'env', configured: true } : s,
|
|
845
|
+
);
|
|
846
|
+
const syncFromEnv: SettingStatus = {
|
|
847
|
+
key: 'kbSyncSecret', envVar: 'KB_SYNC_SECRET', section: 'knowledge-base', source: 'env', configured: true, secret: true, restartToApply: false,
|
|
848
|
+
};
|
|
849
|
+
render(
|
|
850
|
+
<SetupScreen
|
|
851
|
+
settings={[...KB_FROM_ENV, syncFromEnv]}
|
|
852
|
+
sync={{ url: 'https://hexis.example.test/api/sync', last: null }}
|
|
853
|
+
onSaved={() => {}}
|
|
854
|
+
variant="settings"
|
|
855
|
+
/>,
|
|
856
|
+
);
|
|
857
|
+
expect(screen.getByText('https://hexis.example.test/api/sync/<branch>')).toBeTruthy();
|
|
858
|
+
expect(screen.getByRole('button', { name: 'Sync now' })).toBeTruthy();
|
|
859
|
+
expect(screen.getByRole('heading', { name: 'Repository sync' })).toBeTruthy();
|
|
860
|
+
});
|
|
861
|
+
});
|