@bevel-software/platform-core-frontend 0.13.6 → 0.14.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/package.json +2 -2
- package/src/lib/__tests__/utils.test.ts +43 -0
- package/src/lib/utils.ts +15 -7
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +1 -0
- package/src/modules/library/__tests__/McpServerSection.test.tsx +7 -1
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +216 -8
- package/src/modules/library/__tests__/ToolPage.test.tsx +16 -3
- package/src/modules/library/__tests__/ToolVarRow.test.tsx +7 -7
- package/src/modules/library/__tests__/status.test.ts +84 -0
- package/src/modules/library/components/LibraryCard.tsx +7 -1
- package/src/modules/library/components/skill-page/SkillPage.tsx +5 -1
- 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 +19 -0
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +30 -8
- package/src/modules/library/hooks/useToolPage.ts +28 -11
- package/src/modules/library/utils/status.ts +99 -10
- 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/toolbar/components/ExternalAgentAccessPage.tsx +6 -10
|
@@ -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) =>
|
|
@@ -4,6 +4,7 @@ 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
6
|
import { buttonClasses } from '../../../shared/components';
|
|
7
|
+
import { formatRelativeTime } from '../../../lib/utils';
|
|
7
8
|
import {
|
|
8
9
|
ConnectionInstructions,
|
|
9
10
|
CopyBlock,
|
|
@@ -27,17 +28,12 @@ import {
|
|
|
27
28
|
|
|
28
29
|
const MAX_LABEL_LEN = 200;
|
|
29
30
|
|
|
31
|
+
/**
|
|
32
|
+
* The shared formatter, plus the one word it deliberately leaves to the caller:
|
|
33
|
+
* a key that has never been used has no instant to describe.
|
|
34
|
+
*/
|
|
30
35
|
function formatRelative(ts: number | null): string {
|
|
31
|
-
|
|
32
|
-
const diff = Date.now() - ts;
|
|
33
|
-
const minutes = Math.round(diff / 60_000);
|
|
34
|
-
if (minutes < 1) return 'just now';
|
|
35
|
-
if (minutes < 60) return `${minutes} min ago`;
|
|
36
|
-
const hours = Math.round(minutes / 60);
|
|
37
|
-
if (hours < 24) return `${hours} hr ago`;
|
|
38
|
-
const days = Math.round(hours / 24);
|
|
39
|
-
if (days < 30) return `${days} day${days === 1 ? '' : 's'} ago`;
|
|
40
|
-
return new Date(ts).toLocaleDateString();
|
|
36
|
+
return formatRelativeTime(ts) || 'never';
|
|
41
37
|
}
|
|
42
38
|
|
|
43
39
|
/**
|