@bevel-software/platform-core-frontend 0.12.1 → 0.13.3
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/modules/library/__tests__/McpServerSection.test.tsx +95 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +209 -5
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +31 -0
- package/src/modules/library/__tests__/ToolVarRow.test.tsx +18 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +178 -9
- package/src/modules/library/components/tool-page/McpServerSection.tsx +338 -65
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +25 -9
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +8 -0
- package/src/modules/library/services/tools.api.ts +23 -1
- package/src/modules/secrets-vault/components/SecretsPage.tsx +321 -313
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +20 -11
- package/src/modules/secrets-vault/services/secrets.api.ts +2 -0
- package/src/modules/secrets-vault/services/tool-secrets.api.ts +6 -3
- package/src/modules/workspace/components/EditorTabs.tsx +9 -17
- package/src/modules/workspace/components/FileExplorer.tsx +10 -4
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +170 -1
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +58 -0
- package/src/modules/workspace/utils/fileTree.ts +10 -1
- package/src/shared/components/__tests__/usePointerMenuPosition.test.tsx +50 -0
- package/src/shared/components/index.ts +2 -0
- package/src/shared/components/usePointerMenuPosition.ts +92 -0
|
@@ -1,313 +1,321 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import { Link } from 'react-router-dom';
|
|
3
|
-
import { Badge, Banner, Button, Surface, TextField } from '../../../shared/components';
|
|
4
|
-
import { PageShell } from '../../../shared/components/PageShell';
|
|
5
|
-
import { pathForTool } from '../../library/routes/library-paths';
|
|
6
|
-
import { ToolLogo } from '../../library/components/ToolLogo';
|
|
7
|
-
import {
|
|
8
|
-
listSecrets,
|
|
9
|
-
createOAuthSecret,
|
|
10
|
-
deleteSecret,
|
|
11
|
-
startOAuth,
|
|
12
|
-
type SecretSummary,
|
|
13
|
-
} from '../services/secrets.api';
|
|
14
|
-
import { listToolSecrets, type ToolSecrets } from '../services/tool-secrets.api';
|
|
15
|
-
import { ToolSecretsPanel } from './ToolSecretsPanel';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The Secrets page, routed standalone at `/secrets` (below the persistent
|
|
19
|
-
* toolbar). Primary surface is PER-TOOL: each `.tool` manual declares which
|
|
20
|
-
* `${VAR}`s are set by the tool owner (shared) vs by each user, and the panels
|
|
21
|
-
* let the right people fill the right values. OAuth credentials (per-user)
|
|
22
|
-
* live under "Advanced" — the callback/refresh flow is keyed by secret id.
|
|
23
|
-
*
|
|
24
|
-
* `/secrets` is also the standalone-secret OAuth landing: the backend
|
|
25
|
-
* callback returns the browser here with the outcome in the URL fragment
|
|
26
|
-
* (`#authorized` / `#error`), which the page surfaces and then strips.
|
|
27
|
-
*
|
|
28
|
-
* Visually this is the Library's sibling: tool logos lead the cards, statuses
|
|
29
|
-
* say `Connected` / `Set` / `Needs …` in the same grammar, and everything sits
|
|
30
|
-
* on the shared components rather than hand-rolled borders.
|
|
31
|
-
*/
|
|
32
|
-
/**
|
|
33
|
-
* The OAuth-callback outcome carried in the URL fragment
|
|
34
|
-
* (`#authorized` / `#error=<message>`), or null when there is none.
|
|
35
|
-
* `URLSearchParams` already percent-decodes, so the value is used as-is (a
|
|
36
|
-
* second `decodeURIComponent` would corrupt messages containing `%`).
|
|
37
|
-
*/
|
|
38
|
-
function readHashOutcome(): { kind: 'authorized' | 'error'; text: string } | null {
|
|
39
|
-
const hash = window.location.hash.replace(/^#/, '');
|
|
40
|
-
if (!hash) return null;
|
|
41
|
-
const params = new URLSearchParams(hash);
|
|
42
|
-
if (params.has('authorized')) return { kind: 'authorized', text: 'Authorization complete.' };
|
|
43
|
-
if (params.has('error'))
|
|
44
|
-
return { kind: 'error', text: params.get('error') || 'Authorization failed.' };
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function SecretsPage() {
|
|
49
|
-
const [tools, setTools] = useState<ToolSecrets[]>([]);
|
|
50
|
-
const [secrets, setSecrets] = useState<SecretSummary[]>([]);
|
|
51
|
-
const [loading, setLoading] = useState(true);
|
|
52
|
-
const [error, setError] = useState<string | null>(null);
|
|
53
|
-
// Read ONCE, synchronously, before the fragment is stripped below. Kept in
|
|
54
|
-
// its own slot (not the API `error` above) so the initial refresh() — whose
|
|
55
|
-
// success path clears the API error — can't race the outcome away.
|
|
56
|
-
const [oauthOutcome] = useState(readHashOutcome);
|
|
57
|
-
|
|
58
|
-
const refresh = useCallback(async () => {
|
|
59
|
-
setLoading(true);
|
|
60
|
-
try {
|
|
61
|
-
const [t, s] = await Promise.all([listToolSecrets(), listSecrets()]);
|
|
62
|
-
setTools(t);
|
|
63
|
-
setSecrets(s);
|
|
64
|
-
setError(null);
|
|
65
|
-
} catch (err) {
|
|
66
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
67
|
-
} finally {
|
|
68
|
-
setLoading(false);
|
|
69
|
-
}
|
|
70
|
-
}, []);
|
|
71
|
-
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
void refresh();
|
|
74
|
-
}, [refresh]);
|
|
75
|
-
|
|
76
|
-
// Strip the consumed fragment so a refresh doesn't re-announce the outcome.
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
if (oauthOutcome) window.history.replaceState(null, '', window.location.pathname);
|
|
79
|
-
}, [oauthOutcome]);
|
|
80
|
-
|
|
81
|
-
// A live API error wins over the (historical) callback outcome; otherwise
|
|
82
|
-
// the callback error stays visible even after the list load succeeds.
|
|
83
|
-
const shownError = error ?? (oauthOutcome?.kind === 'error' ? oauthOutcome.text : null);
|
|
84
|
-
const notice = oauthOutcome?.kind === 'authorized' ? oauthOutcome.text : null;
|
|
85
|
-
|
|
86
|
-
const oauthSecrets = secrets.filter((s) => s.kind === 'oauth');
|
|
87
|
-
|
|
88
|
-
const onDelete = async (id: string) => {
|
|
89
|
-
try {
|
|
90
|
-
await deleteSecret(id);
|
|
91
|
-
await refresh();
|
|
92
|
-
} catch (err) {
|
|
93
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const onAuthorize = async (id: string) => {
|
|
98
|
-
try {
|
|
99
|
-
const url = await startOAuth(id);
|
|
100
|
-
window.location.href = url;
|
|
101
|
-
} catch (err) {
|
|
102
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
return (
|
|
107
|
-
<PageShell
|
|
108
|
-
title="Secrets"
|
|
109
|
-
actions={
|
|
110
|
-
<Button variant="quiet" size="sm" disabled={loading} onClick={() => void refresh()}>
|
|
111
|
-
Refresh
|
|
112
|
-
</Button>
|
|
113
|
-
}
|
|
114
|
-
>
|
|
115
|
-
{shownError && (
|
|
116
|
-
<Banner role="alert" tone="danger" className="mb-3">
|
|
117
|
-
{shownError}
|
|
118
|
-
</Banner>
|
|
119
|
-
)}
|
|
120
|
-
{notice && (
|
|
121
|
-
<Banner role="status" tone="ok" className="mb-3">
|
|
122
|
-
{notice}
|
|
123
|
-
</Banner>
|
|
124
|
-
)}
|
|
125
|
-
|
|
126
|
-
<p className="mb-5 text-ui text-ink-muted">
|
|
127
|
-
Secrets back the{' '}
|
|
128
|
-
<code className="rounded-sm bg-sunken px-1 py-0.5 font-mono text-meta text-ink">
|
|
129
|
-
{'${VARIABLE}'}
|
|
130
|
-
</code>{' '}
|
|
131
|
-
placeholders in your tool manuals. Each tool declares which variables its owner sets once
|
|
132
|
-
(shared by everyone) and which each user sets for themselves. Values are never displayed
|
|
133
|
-
after saving.
|
|
134
|
-
</p>
|
|
135
|
-
|
|
136
|
-
{loading ? (
|
|
137
|
-
<p className="py-10 text-center text-ui text-ink-faint">Loading…</p>
|
|
138
|
-
) : tools.length === 0 ? (
|
|
139
|
-
<p className="py-10 text-center text-ui text-ink-faint">
|
|
140
|
-
No tools you can access declare secrets yet.
|
|
141
|
-
</p>
|
|
142
|
-
) : (
|
|
143
|
-
<ul className="mb-6 flex flex-col gap-2.5">
|
|
144
|
-
{tools.map((tool) => (
|
|
145
|
-
<li key={tool.slug}>
|
|
146
|
-
<Surface tone="surface" radius="xl" elevation="card" padded>
|
|
147
|
-
<div className="mb-3 flex items-center gap-2.5">
|
|
148
|
-
<ToolLogo slug={tool.slug} name={tool.name} />
|
|
149
|
-
{/* The tool's own page is where its description, capabilities
|
|
150
|
-
and owner-side setup live — this panel only shows the
|
|
151
|
-
values. */}
|
|
152
|
-
<Link
|
|
153
|
-
to={pathForTool(tool.slug)}
|
|
154
|
-
className="truncate rounded-xs text-ui font-semibold text-ink hover:underline"
|
|
155
|
-
aria-label={`Open ${tool.name}`}
|
|
156
|
-
>
|
|
157
|
-
{tool.name}
|
|
158
|
-
</Link>
|
|
159
|
-
<span className="truncate text-meta text-ink-faint">{tool.path}</span>
|
|
160
|
-
{tool.canWrite && (
|
|
161
|
-
<Badge tone="outline" size="xs" className="ml-auto shrink-0">
|
|
162
|
-
You can edit shared secrets
|
|
163
|
-
</Badge>
|
|
164
|
-
)}
|
|
165
|
-
</div>
|
|
166
|
-
<ToolSecretsPanel tool={tool} onChanged={() => void refresh()} />
|
|
167
|
-
</Surface>
|
|
168
|
-
</li>
|
|
169
|
-
))}
|
|
170
|
-
</ul>
|
|
171
|
-
)}
|
|
172
|
-
|
|
173
|
-
<details>
|
|
174
|
-
<summary className="cursor-pointer text-detail font-semibold text-ink-muted">
|
|
175
|
-
Advanced: OAuth credentials
|
|
176
|
-
</summary>
|
|
177
|
-
<div className="mt-3 flex flex-col gap-3.5">
|
|
178
|
-
<p className="text-detail text-ink-muted">
|
|
179
|
-
OAuth secrets are per-user. Name the variable key exactly as the tool references it{' '}
|
|
180
|
-
<code className="rounded-sm bg-sunken px-1 py-0.5 font-mono text-meta text-ink">
|
|
181
|
-
{'<Manual>_<VAR>'}
|
|
182
|
-
</code>
|
|
183
|
-
, then sign in to complete the flow.
|
|
184
|
-
</p>
|
|
185
|
-
{oauthSecrets.length > 0 && (
|
|
186
|
-
<ul className="flex flex-col gap-1.5">
|
|
187
|
-
{oauthSecrets.map((s) => (
|
|
188
|
-
<li
|
|
189
|
-
key={s.id}
|
|
190
|
-
className="flex items-center gap-2 rounded-lg border border-line bg-surface px-3 py-2.5"
|
|
191
|
-
>
|
|
192
|
-
<code className="rounded-sm bg-sunken px-1.5 py-0.5 font-mono text-meta text-ink">
|
|
193
|
-
{`\${${s.key}}`}
|
|
194
|
-
</code>
|
|
195
|
-
<Badge tone={s.authorized ? 'ok' : 'wait'} size="xs" className="shrink-0">
|
|
196
|
-
{s.authorized ? 'Connected' : 'Needs your sign-in'}
|
|
197
|
-
</Badge>
|
|
198
|
-
<span className="ml-auto flex shrink-0 items-center gap-1.5">
|
|
199
|
-
<Button variant="outline" size="tiny" onClick={() => void onAuthorize(s.id)}>
|
|
200
|
-
{s.authorized ? 'Reconnect' : 'Sign in'}
|
|
201
|
-
</Button>
|
|
202
|
-
{/* The accessible name has to START with the visible word
|
|
203
|
-
(WCAG 2.5.3): "Delete secret" meant voice control could
|
|
204
|
-
not act on a button that reads "Remove". The key is what
|
|
205
|
-
makes it unambiguous in a list of otherwise identical
|
|
206
|
-
rows, so it comes after. */}
|
|
207
|
-
<Button
|
|
208
|
-
variant="quiet"
|
|
209
|
-
size="tiny"
|
|
210
|
-
aria-label={`Remove ${s.key}`}
|
|
211
|
-
onClick={() => void onDelete(s.id)}
|
|
212
|
-
>
|
|
213
|
-
Remove
|
|
214
|
-
</Button>
|
|
215
|
-
</span>
|
|
216
|
-
</li>
|
|
217
|
-
))}
|
|
218
|
-
</ul>
|
|
219
|
-
)}
|
|
220
|
-
<Surface tone="sunken" radius="lg" elevation="none" padded>
|
|
221
|
-
<OAuthSecretForm onSaved={() => void refresh()} onError={setError} />
|
|
222
|
-
</Surface>
|
|
223
|
-
</div>
|
|
224
|
-
</details>
|
|
225
|
-
</PageShell>
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function OAuthSecretForm({ onSaved, onError }: { onSaved: () => void; onError: (m: string) => void }) {
|
|
230
|
-
const [key, setKey] = useState('');
|
|
231
|
-
const [authorizationUrl, setAuthorizationUrl] = useState('');
|
|
232
|
-
const [tokenUrl, setTokenUrl] = useState('');
|
|
233
|
-
const [clientId, setClientId] = useState('');
|
|
234
|
-
const [clientSecret, setClientSecret] = useState('');
|
|
235
|
-
const [scopes, setScopes] = useState('');
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { Link } from 'react-router-dom';
|
|
3
|
+
import { Badge, Banner, Button, Surface, TextField } from '../../../shared/components';
|
|
4
|
+
import { PageShell } from '../../../shared/components/PageShell';
|
|
5
|
+
import { pathForTool } from '../../library/routes/library-paths';
|
|
6
|
+
import { ToolLogo } from '../../library/components/ToolLogo';
|
|
7
|
+
import {
|
|
8
|
+
listSecrets,
|
|
9
|
+
createOAuthSecret,
|
|
10
|
+
deleteSecret,
|
|
11
|
+
startOAuth,
|
|
12
|
+
type SecretSummary,
|
|
13
|
+
} from '../services/secrets.api';
|
|
14
|
+
import { listToolSecrets, type ToolSecrets } from '../services/tool-secrets.api';
|
|
15
|
+
import { ToolSecretsPanel } from './ToolSecretsPanel';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The Secrets page, routed standalone at `/secrets` (below the persistent
|
|
19
|
+
* toolbar). Primary surface is PER-TOOL: each `.tool` manual declares which
|
|
20
|
+
* `${VAR}`s are set by the tool owner (shared) vs by each user, and the panels
|
|
21
|
+
* let the right people fill the right values. OAuth credentials (per-user)
|
|
22
|
+
* live under "Advanced" — the callback/refresh flow is keyed by secret id.
|
|
23
|
+
*
|
|
24
|
+
* `/secrets` is also the standalone-secret OAuth landing: the backend
|
|
25
|
+
* callback returns the browser here with the outcome in the URL fragment
|
|
26
|
+
* (`#authorized` / `#error`), which the page surfaces and then strips.
|
|
27
|
+
*
|
|
28
|
+
* Visually this is the Library's sibling: tool logos lead the cards, statuses
|
|
29
|
+
* say `Connected` / `Set` / `Needs …` in the same grammar, and everything sits
|
|
30
|
+
* on the shared components rather than hand-rolled borders.
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* The OAuth-callback outcome carried in the URL fragment
|
|
34
|
+
* (`#authorized` / `#error=<message>`), or null when there is none.
|
|
35
|
+
* `URLSearchParams` already percent-decodes, so the value is used as-is (a
|
|
36
|
+
* second `decodeURIComponent` would corrupt messages containing `%`).
|
|
37
|
+
*/
|
|
38
|
+
function readHashOutcome(): { kind: 'authorized' | 'error'; text: string } | null {
|
|
39
|
+
const hash = window.location.hash.replace(/^#/, '');
|
|
40
|
+
if (!hash) return null;
|
|
41
|
+
const params = new URLSearchParams(hash);
|
|
42
|
+
if (params.has('authorized')) return { kind: 'authorized', text: 'Authorization complete.' };
|
|
43
|
+
if (params.has('error'))
|
|
44
|
+
return { kind: 'error', text: params.get('error') || 'Authorization failed.' };
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function SecretsPage() {
|
|
49
|
+
const [tools, setTools] = useState<ToolSecrets[]>([]);
|
|
50
|
+
const [secrets, setSecrets] = useState<SecretSummary[]>([]);
|
|
51
|
+
const [loading, setLoading] = useState(true);
|
|
52
|
+
const [error, setError] = useState<string | null>(null);
|
|
53
|
+
// Read ONCE, synchronously, before the fragment is stripped below. Kept in
|
|
54
|
+
// its own slot (not the API `error` above) so the initial refresh() — whose
|
|
55
|
+
// success path clears the API error — can't race the outcome away.
|
|
56
|
+
const [oauthOutcome] = useState(readHashOutcome);
|
|
57
|
+
|
|
58
|
+
const refresh = useCallback(async () => {
|
|
59
|
+
setLoading(true);
|
|
60
|
+
try {
|
|
61
|
+
const [t, s] = await Promise.all([listToolSecrets(), listSecrets()]);
|
|
62
|
+
setTools(t);
|
|
63
|
+
setSecrets(s);
|
|
64
|
+
setError(null);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
67
|
+
} finally {
|
|
68
|
+
setLoading(false);
|
|
69
|
+
}
|
|
70
|
+
}, []);
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
void refresh();
|
|
74
|
+
}, [refresh]);
|
|
75
|
+
|
|
76
|
+
// Strip the consumed fragment so a refresh doesn't re-announce the outcome.
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (oauthOutcome) window.history.replaceState(null, '', window.location.pathname);
|
|
79
|
+
}, [oauthOutcome]);
|
|
80
|
+
|
|
81
|
+
// A live API error wins over the (historical) callback outcome; otherwise
|
|
82
|
+
// the callback error stays visible even after the list load succeeds.
|
|
83
|
+
const shownError = error ?? (oauthOutcome?.kind === 'error' ? oauthOutcome.text : null);
|
|
84
|
+
const notice = oauthOutcome?.kind === 'authorized' ? oauthOutcome.text : null;
|
|
85
|
+
|
|
86
|
+
const oauthSecrets = secrets.filter((s) => s.kind === 'oauth');
|
|
87
|
+
|
|
88
|
+
const onDelete = async (id: string) => {
|
|
89
|
+
try {
|
|
90
|
+
await deleteSecret(id);
|
|
91
|
+
await refresh();
|
|
92
|
+
} catch (err) {
|
|
93
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const onAuthorize = async (id: string) => {
|
|
98
|
+
try {
|
|
99
|
+
const url = await startOAuth(id);
|
|
100
|
+
window.location.href = url;
|
|
101
|
+
} catch (err) {
|
|
102
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<PageShell
|
|
108
|
+
title="Secrets"
|
|
109
|
+
actions={
|
|
110
|
+
<Button variant="quiet" size="sm" disabled={loading} onClick={() => void refresh()}>
|
|
111
|
+
Refresh
|
|
112
|
+
</Button>
|
|
113
|
+
}
|
|
114
|
+
>
|
|
115
|
+
{shownError && (
|
|
116
|
+
<Banner role="alert" tone="danger" className="mb-3">
|
|
117
|
+
{shownError}
|
|
118
|
+
</Banner>
|
|
119
|
+
)}
|
|
120
|
+
{notice && (
|
|
121
|
+
<Banner role="status" tone="ok" className="mb-3">
|
|
122
|
+
{notice}
|
|
123
|
+
</Banner>
|
|
124
|
+
)}
|
|
125
|
+
|
|
126
|
+
<p className="mb-5 text-ui text-ink-muted">
|
|
127
|
+
Secrets back the{' '}
|
|
128
|
+
<code className="rounded-sm bg-sunken px-1 py-0.5 font-mono text-meta text-ink">
|
|
129
|
+
{'${VARIABLE}'}
|
|
130
|
+
</code>{' '}
|
|
131
|
+
placeholders in your tool manuals. Each tool declares which variables its owner sets once
|
|
132
|
+
(shared by everyone) and which each user sets for themselves. Values are never displayed
|
|
133
|
+
after saving.
|
|
134
|
+
</p>
|
|
135
|
+
|
|
136
|
+
{loading ? (
|
|
137
|
+
<p className="py-10 text-center text-ui text-ink-faint">Loading…</p>
|
|
138
|
+
) : tools.length === 0 ? (
|
|
139
|
+
<p className="py-10 text-center text-ui text-ink-faint">
|
|
140
|
+
No tools you can access declare secrets yet.
|
|
141
|
+
</p>
|
|
142
|
+
) : (
|
|
143
|
+
<ul className="mb-6 flex flex-col gap-2.5">
|
|
144
|
+
{tools.map((tool) => (
|
|
145
|
+
<li key={tool.slug}>
|
|
146
|
+
<Surface tone="surface" radius="xl" elevation="card" padded>
|
|
147
|
+
<div className="mb-3 flex items-center gap-2.5">
|
|
148
|
+
<ToolLogo slug={tool.slug} name={tool.name} />
|
|
149
|
+
{/* The tool's own page is where its description, capabilities
|
|
150
|
+
and owner-side setup live — this panel only shows the
|
|
151
|
+
values. */}
|
|
152
|
+
<Link
|
|
153
|
+
to={pathForTool(tool.slug)}
|
|
154
|
+
className="truncate rounded-xs text-ui font-semibold text-ink hover:underline"
|
|
155
|
+
aria-label={`Open ${tool.name}`}
|
|
156
|
+
>
|
|
157
|
+
{tool.name}
|
|
158
|
+
</Link>
|
|
159
|
+
<span className="truncate text-meta text-ink-faint">{tool.path}</span>
|
|
160
|
+
{tool.canWrite && (
|
|
161
|
+
<Badge tone="outline" size="xs" className="ml-auto shrink-0">
|
|
162
|
+
You can edit shared secrets
|
|
163
|
+
</Badge>
|
|
164
|
+
)}
|
|
165
|
+
</div>
|
|
166
|
+
<ToolSecretsPanel tool={tool} onChanged={() => void refresh()} />
|
|
167
|
+
</Surface>
|
|
168
|
+
</li>
|
|
169
|
+
))}
|
|
170
|
+
</ul>
|
|
171
|
+
)}
|
|
172
|
+
|
|
173
|
+
<details>
|
|
174
|
+
<summary className="cursor-pointer text-detail font-semibold text-ink-muted">
|
|
175
|
+
Advanced: OAuth credentials
|
|
176
|
+
</summary>
|
|
177
|
+
<div className="mt-3 flex flex-col gap-3.5">
|
|
178
|
+
<p className="text-detail text-ink-muted">
|
|
179
|
+
OAuth secrets are per-user. Name the variable key exactly as the tool references it{' '}
|
|
180
|
+
<code className="rounded-sm bg-sunken px-1 py-0.5 font-mono text-meta text-ink">
|
|
181
|
+
{'<Manual>_<VAR>'}
|
|
182
|
+
</code>
|
|
183
|
+
, then sign in to complete the flow.
|
|
184
|
+
</p>
|
|
185
|
+
{oauthSecrets.length > 0 && (
|
|
186
|
+
<ul className="flex flex-col gap-1.5">
|
|
187
|
+
{oauthSecrets.map((s) => (
|
|
188
|
+
<li
|
|
189
|
+
key={s.id}
|
|
190
|
+
className="flex items-center gap-2 rounded-lg border border-line bg-surface px-3 py-2.5"
|
|
191
|
+
>
|
|
192
|
+
<code className="rounded-sm bg-sunken px-1.5 py-0.5 font-mono text-meta text-ink">
|
|
193
|
+
{`\${${s.key}}`}
|
|
194
|
+
</code>
|
|
195
|
+
<Badge tone={s.authorized ? 'ok' : 'wait'} size="xs" className="shrink-0">
|
|
196
|
+
{s.authorized ? 'Connected' : 'Needs your sign-in'}
|
|
197
|
+
</Badge>
|
|
198
|
+
<span className="ml-auto flex shrink-0 items-center gap-1.5">
|
|
199
|
+
<Button variant="outline" size="tiny" onClick={() => void onAuthorize(s.id)}>
|
|
200
|
+
{s.authorized ? 'Reconnect' : 'Sign in'}
|
|
201
|
+
</Button>
|
|
202
|
+
{/* The accessible name has to START with the visible word
|
|
203
|
+
(WCAG 2.5.3): "Delete secret" meant voice control could
|
|
204
|
+
not act on a button that reads "Remove". The key is what
|
|
205
|
+
makes it unambiguous in a list of otherwise identical
|
|
206
|
+
rows, so it comes after. */}
|
|
207
|
+
<Button
|
|
208
|
+
variant="quiet"
|
|
209
|
+
size="tiny"
|
|
210
|
+
aria-label={`Remove ${s.key}`}
|
|
211
|
+
onClick={() => void onDelete(s.id)}
|
|
212
|
+
>
|
|
213
|
+
Remove
|
|
214
|
+
</Button>
|
|
215
|
+
</span>
|
|
216
|
+
</li>
|
|
217
|
+
))}
|
|
218
|
+
</ul>
|
|
219
|
+
)}
|
|
220
|
+
<Surface tone="sunken" radius="lg" elevation="none" padded>
|
|
221
|
+
<OAuthSecretForm onSaved={() => void refresh()} onError={setError} />
|
|
222
|
+
</Surface>
|
|
223
|
+
</div>
|
|
224
|
+
</details>
|
|
225
|
+
</PageShell>
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function OAuthSecretForm({ onSaved, onError }: { onSaved: () => void; onError: (m: string) => void }) {
|
|
230
|
+
const [key, setKey] = useState('');
|
|
231
|
+
const [authorizationUrl, setAuthorizationUrl] = useState('');
|
|
232
|
+
const [tokenUrl, setTokenUrl] = useState('');
|
|
233
|
+
const [clientId, setClientId] = useState('');
|
|
234
|
+
const [clientSecret, setClientSecret] = useState('');
|
|
235
|
+
const [scopes, setScopes] = useState('');
|
|
236
|
+
// On by default: MCP-spec providers require PKCE, and one that doesn't
|
|
237
|
+
// implement it ignores the extra parameters — off is the rare exception.
|
|
238
|
+
const [pkce, setPkce] = useState(true);
|
|
239
|
+
const [busy, setBusy] = useState(false);
|
|
240
|
+
|
|
241
|
+
const submit = async () => {
|
|
242
|
+
setBusy(true);
|
|
243
|
+
try {
|
|
244
|
+
await createOAuthSecret({
|
|
245
|
+
key: key.trim(),
|
|
246
|
+
provider: {
|
|
247
|
+
authorizationUrl: authorizationUrl.trim(),
|
|
248
|
+
tokenUrl: tokenUrl.trim(),
|
|
249
|
+
clientId: clientId.trim(),
|
|
250
|
+
clientSecret: clientSecret.trim() || undefined,
|
|
251
|
+
scopes: scopes.split(/[\s,]+/).filter(Boolean),
|
|
252
|
+
pkce,
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
onSaved();
|
|
256
|
+
} catch (err) {
|
|
257
|
+
onError(err instanceof Error ? err.message : String(err));
|
|
258
|
+
} finally {
|
|
259
|
+
setBusy(false);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
return (
|
|
264
|
+
<div className="flex flex-col gap-2.5">
|
|
265
|
+
<Field label="Variable key (Manual_VAR)">
|
|
266
|
+
<TextField
|
|
267
|
+
className="w-full"
|
|
268
|
+
value={key}
|
|
269
|
+
onChange={(e) => setKey(e.target.value)}
|
|
270
|
+
placeholder="github_GITHUB_TOKEN"
|
|
271
|
+
/>
|
|
272
|
+
</Field>
|
|
273
|
+
<Field label="Authorization URL">
|
|
274
|
+
<TextField className="w-full" value={authorizationUrl} onChange={(e) => setAuthorizationUrl(e.target.value)} />
|
|
275
|
+
</Field>
|
|
276
|
+
<Field label="Token URL">
|
|
277
|
+
<TextField className="w-full" value={tokenUrl} onChange={(e) => setTokenUrl(e.target.value)} />
|
|
278
|
+
</Field>
|
|
279
|
+
<Field label="Client ID">
|
|
280
|
+
<TextField className="w-full" value={clientId} onChange={(e) => setClientId(e.target.value)} />
|
|
281
|
+
</Field>
|
|
282
|
+
<Field label="Client secret (optional)">
|
|
283
|
+
<TextField
|
|
284
|
+
className="w-full"
|
|
285
|
+
type="password"
|
|
286
|
+
value={clientSecret}
|
|
287
|
+
onChange={(e) => setClientSecret(e.target.value)}
|
|
288
|
+
/>
|
|
289
|
+
</Field>
|
|
290
|
+
<Field label="Scopes (space or comma separated)">
|
|
291
|
+
<TextField className="w-full" value={scopes} onChange={(e) => setScopes(e.target.value)} />
|
|
292
|
+
</Field>
|
|
293
|
+
<label className="flex items-center gap-2 text-detail text-ink-muted">
|
|
294
|
+
<input type="checkbox" checked={pkce} onChange={(e) => setPkce(e.target.checked)} />
|
|
295
|
+
PKCE (S256) — required by MCP servers; harmless for providers that ignore it
|
|
296
|
+
</label>
|
|
297
|
+
<p className="text-detail text-ink-muted">
|
|
298
|
+
Save first, then click “Sign in” on the secret to complete the flow.
|
|
299
|
+
</p>
|
|
300
|
+
<div>
|
|
301
|
+
<Button
|
|
302
|
+
variant="primary"
|
|
303
|
+
size="sm"
|
|
304
|
+
disabled={busy || !key.trim() || !authorizationUrl.trim() || !tokenUrl.trim() || !clientId.trim()}
|
|
305
|
+
onClick={() => void submit()}
|
|
306
|
+
>
|
|
307
|
+
Save OAuth secret
|
|
308
|
+
</Button>
|
|
309
|
+
</div>
|
|
310
|
+
</div>
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function Field({ label, children }: { label: string; children: React.ReactNode }) {
|
|
315
|
+
return (
|
|
316
|
+
<label className="block">
|
|
317
|
+
<span className="mb-0.5 block text-detail font-medium text-ink-muted">{label}</span>
|
|
318
|
+
{children}
|
|
319
|
+
</label>
|
|
320
|
+
);
|
|
321
|
+
}
|