| 1 | import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
| 2 | import { createRoot } from 'react-dom/client';
|
| 3 | import './styles.css';
|
| 4 |
|
| 5 | declare const __AUTH0_DOMAIN__: string;
|
| 6 | declare const __AUTH0_CLIENT_ID__: string;
|
| 7 | declare const __AUTH0_AUDIENCE__: string;
|
| 8 |
|
| 9 | type Auth0User = { sub: string; name?: string; email?: string; picture?: string };
|
| 10 | type AuthSession = { user: Auth0User };
|
| 11 | type AuthTransaction = { state: string; nonce: string; verifier: string };
|
| 12 | type Theme = 'dark' | 'light';
|
| 13 |
|
| 14 | const authTransactionKey = 'openclasp.auth0.transaction';
|
| 15 | const themeKey = 'openclasp.theme.v1';
|
| 16 |
|
| 17 | type DashboardData = {
|
| 18 | agents: Record<string, any>[];
|
| 19 | projects: Record<string, any>[];
|
| 20 | installations: Record<string, any>[];
|
| 21 | setupRequests: Record<string, any>[];
|
| 22 | publications: Record<string, any>[];
|
| 23 | interactions: Record<string, any>[];
|
| 24 | federatedInteractions: Record<string, any>[];
|
| 25 | events: Record<string, any>[];
|
| 26 | conflicts: Record<string, any>[];
|
| 27 | receipts: Record<string, any>[];
|
| 28 | profiles: Record<string, any>[];
|
| 29 | };
|
| 30 |
|
| 31 | type Settings = {
|
| 32 | displayName: string;
|
| 33 | contributionEnabled: boolean;
|
| 34 | retentionDays: number;
|
| 35 | evidenceSharing: 'never' | 'ask' | 'contract_only';
|
| 36 | rawConversationsStored: true;
|
| 37 | };
|
| 38 |
|
| 39 | const emptyData: DashboardData = {
|
| 40 | agents: [],
|
| 41 | projects: [],
|
| 42 | installations: [],
|
| 43 | setupRequests: [],
|
| 44 | publications: [],
|
| 45 | interactions: [],
|
| 46 | federatedInteractions: [],
|
| 47 | events: [],
|
| 48 | conflicts: [],
|
| 49 | receipts: [],
|
| 50 | profiles: [],
|
| 51 | };
|
| 52 | const defaultSettings: Settings = {
|
| 53 | displayName: '',
|
| 54 | contributionEnabled: false,
|
| 55 | retentionDays: 30,
|
| 56 | evidenceSharing: 'ask',
|
| 57 | rawConversationsStored: true,
|
| 58 | };
|
| 59 | const pages = ['dashboard', 'history', 'agents', 'insights', 'connect', 'settings'] as const;
|
| 60 | type Page = (typeof pages)[number];
|
| 61 |
|
| 62 | function base64Url(bytes: Uint8Array) {
|
| 63 | let binary = '';
|
| 64 | for (const byte of bytes) binary += String.fromCharCode(byte);
|
| 65 | return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
| 66 | }
|
| 67 |
|
| 68 | function randomValue(size = 32) {
|
| 69 | return base64Url(crypto.getRandomValues(new Uint8Array(size)));
|
| 70 | }
|
| 71 |
|
| 72 | async function beginAuth(provider: 'google' | 'github') {
|
| 73 | const verifier = randomValue(48);
|
| 74 | const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(verifier));
|
| 75 | const transaction: AuthTransaction = { state: randomValue(), nonce: randomValue(), verifier };
|
| 76 | sessionStorage.setItem(authTransactionKey, JSON.stringify(transaction));
|
| 77 | const parameters = new URLSearchParams({
|
| 78 | client_id: __AUTH0_CLIENT_ID__,
|
| 79 | redirect_uri: `${location.origin}/sso-callback`,
|
| 80 | response_type: 'code',
|
| 81 | scope: 'openid profile email',
|
| 82 | audience: __AUTH0_AUDIENCE__,
|
| 83 | state: transaction.state,
|
| 84 | nonce: transaction.nonce,
|
| 85 | code_challenge: base64Url(new Uint8Array(digest)),
|
| 86 | code_challenge_method: 'S256',
|
| 87 | connection: provider === 'google' ? 'google-oauth2' : 'github',
|
| 88 | });
|
| 89 | location.assign(`https://${__AUTH0_DOMAIN__}/authorize?${parameters}`);
|
| 90 | }
|
| 91 |
|
| 92 | async function signOut() {
|
| 93 | await fetch('/api/session', { method: 'DELETE', credentials: 'same-origin' });
|
| 94 | const parameters = new URLSearchParams({
|
| 95 | client_id: __AUTH0_CLIENT_ID__,
|
| 96 | returnTo: `${location.origin}/login`,
|
| 97 | });
|
| 98 | location.assign(`https://${__AUTH0_DOMAIN__}/v2/logout?${parameters}`);
|
| 99 | }
|
| 100 |
|
| 101 | async function api(path: string, init?: RequestInit) {
|
| 102 | const headers = new Headers(init?.headers);
|
| 103 | if (init?.body && !headers.has('content-type')) headers.set('content-type', 'application/json');
|
| 104 | return fetch(path, {
|
| 105 | ...init,
|
| 106 | credentials: 'same-origin',
|
| 107 | headers,
|
| 108 | }).then(async (response) => {
|
| 109 | if (!response.ok)
|
| 110 | throw new Error((await response.text()) || `Request failed: ${response.status}`);
|
| 111 | return response.json();
|
| 112 | });
|
| 113 | }
|
| 114 |
|
| 115 | function route(): Page {
|
| 116 | const value = location.pathname.slice(1) || 'dashboard';
|
| 117 | return pages.includes(value as Page) ? (value as Page) : 'dashboard';
|
| 118 | }
|
| 119 |
|
| 120 | function initialTheme(): Theme {
|
| 121 | const saved = localStorage.getItem(themeKey);
|
| 122 | if (saved === 'dark' || saved === 'light') return saved;
|
| 123 | return matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';
|
| 124 | }
|
| 125 |
|
| 126 | function App() {
|
| 127 | const [session, setSession] = useState<AuthSession | null>();
|
| 128 | const [theme, setTheme] = useState<Theme>(initialTheme);
|
| 129 | const [page, setPage] = useState<Page>(route());
|
| 130 | const [data, setData] = useState<DashboardData>(emptyData);
|
| 131 | const [settings, setSettings] = useState<Settings>(defaultSettings);
|
| 132 | const [loading, setLoading] = useState(true);
|
| 133 | const [error, setError] = useState('');
|
| 134 | const refreshDashboard = useCallback(async () => {
|
| 135 | setData((await api('/v0.1/dashboard')) as DashboardData);
|
| 136 | }, []);
|
| 137 |
|
| 138 | useEffect(() => {
|
| 139 | fetch('/api/session', { credentials: 'same-origin' })
|
| 140 | .then(async (response) => {
|
| 141 | if (!response.ok) return null;
|
| 142 | return (await response.json()) as AuthSession;
|
| 143 | })
|
| 144 | .then(setSession)
|
| 145 | .catch(() => setSession(null));
|
| 146 | }, []);
|
| 147 |
|
| 148 | useEffect(() => {
|
| 149 | document.documentElement.dataset.theme = theme;
|
| 150 | localStorage.setItem(themeKey, theme);
|
| 151 | }, [theme]);
|
| 152 |
|
| 153 | useEffect(() => {
|
| 154 | const onPopState = () => setPage(route());
|
| 155 | addEventListener('popstate', onPopState);
|
| 156 | return () => removeEventListener('popstate', onPopState);
|
| 157 | }, []);
|
| 158 |
|
| 159 | useEffect(() => {
|
| 160 | if (session === undefined) return;
|
| 161 | if (!session && location.pathname !== '/login') history.replaceState({}, '', '/login');
|
| 162 | if (!session) return;
|
| 163 | if (location.pathname === '/login') history.replaceState({}, '', '/dashboard');
|
| 164 | setPage(route());
|
| 165 | Promise.all([api('/v0.1/dashboard'), api('/v0.1/settings')])
|
| 166 | .then(([dashboard, accountSettings]) => {
|
| 167 | setData(dashboard as DashboardData);
|
| 168 | setSettings(accountSettings as Settings);
|
| 169 | })
|
| 170 | .catch((reason: unknown) =>
|
| 171 | setError(reason instanceof Error ? reason.message : 'Load failed'),
|
| 172 | )
|
| 173 | .finally(() => setLoading(false));
|
| 174 | }, [session]);
|
| 175 |
|
| 176 | useEffect(() => {
|
| 177 | if (!session) return;
|
| 178 | const refresh = () => {
|
| 179 | if (document.visibilityState === 'visible') void refreshDashboard().catch(() => undefined);
|
| 180 | };
|
| 181 | const timer = window.setInterval(refresh, 10_000);
|
| 182 | document.addEventListener('visibilitychange', refresh);
|
| 183 | return () => {
|
| 184 | window.clearInterval(timer);
|
| 185 | document.removeEventListener('visibilitychange', refresh);
|
| 186 | };
|
| 187 | }, [session, refreshDashboard]);
|
| 188 |
|
| 189 | const navigate = (next: Page) => {
|
| 190 | history.pushState({}, '', `/${next}`);
|
| 191 | setPage(next);
|
| 192 | };
|
| 193 |
|
| 194 | if (session === undefined) return <Loading />;
|
| 195 | if (!session) return <Login />;
|
| 196 |
|
| 197 | return (
|
| 198 | <div className="appShell">
|
| 199 | <aside>
|
| 200 | <div className="brand">
|
| 201 | <div className="mark">OC</div>
|
| 202 | <div>
|
| 203 | <strong>OpenClasp</strong>
|
| 204 | <small>ASSURANCE NETWORK</small>
|
| 205 | </div>
|
| 206 | </div>
|
| 207 | <nav>
|
| 208 | <Nav page="dashboard" active={page} onClick={navigate} label="Overview" glyph="⌂" />
|
| 209 | <Nav page="history" active={page} onClick={navigate} label="History" glyph="≡" />
|
| 210 | <Nav page="agents" active={page} onClick={navigate} label="Agents" glyph="◇" />
|
| 211 | <Nav page="insights" active={page} onClick={navigate} label="Insights" glyph="⌁" />
|
| 212 | <Nav page="connect" active={page} onClick={navigate} label="Connect" glyph="+" />
|
| 213 | <Nav page="settings" active={page} onClick={navigate} label="Settings" glyph="⚙" />
|
| 214 | </nav>
|
| 215 | <button
|
| 216 | className="themeSwitch"
|
| 217 | onClick={() => setTheme((current) => (current === 'dark' ? 'light' : 'dark'))}
|
| 218 | aria-label={`Switch to ${theme === 'dark' ? 'light' : 'dark'} theme`}
|
| 219 | >
|
| 220 | <span>{theme === 'dark' ? '☼' : '◐'}</span>
|
| 221 | {theme === 'dark' ? 'Light theme' : 'Dark theme'}
|
| 222 | </button>
|
| 223 | <div className="privacyStamp">
|
| 224 | <span className="liveDot" />
|
| 225 | <div>
|
| 226 | <strong>Privacy separated</strong>
|
| 227 | <small>Gateway bodies expire in 24h</small>
|
| 228 | </div>
|
| 229 | </div>
|
| 230 | <button className="account" onClick={() => void signOut()}>
|
| 231 | <span>{initials(session.user.name || session.user.email || 'OC')}</span>
|
| 232 | <div>
|
| 233 | <strong>{session.user.name || 'OpenClasp user'}</strong>
|
| 234 | <small>{session.user.email || 'Sign out'}</small>
|
| 235 | </div>
|
| 236 | <b>↗</b>
|
| 237 | </button>
|
| 238 | </aside>
|
| 239 | <main>
|
| 240 | {error && <div className="errorBar">{error}</div>}
|
| 241 | {loading ? (
|
| 242 | <Loading compact />
|
| 243 | ) : (
|
| 244 | <PageContent
|
| 245 | page={page}
|
| 246 | data={data}
|
| 247 | settings={settings}
|
| 248 | setSettings={setSettings}
|
| 249 | navigate={navigate}
|
| 250 | refreshDashboard={refreshDashboard}
|
| 251 | />
|
| 252 | )}
|
| 253 | </main>
|
| 254 | </div>
|
| 255 | );
|
| 256 | }
|
| 257 |
|
| 258 | function Login() {
|
| 259 | const [error, setError] = useState('');
|
| 260 | const continueWith = async (provider: 'google' | 'github') => {
|
| 261 | setError('');
|
| 262 | try {
|
| 263 | await beginAuth(provider);
|
| 264 | } catch {
|
| 265 | setError(`${provider === 'google' ? 'Google' : 'GitHub'} sign-in is not configured yet.`);
|
| 266 | }
|
| 267 | };
|
| 268 | return (
|
| 269 | <div className="loginPage">
|
| 270 | <section className="loginPitch">
|
| 271 | <div className="brand">
|
| 272 | <div className="mark">OC</div>
|
| 273 | <strong>OpenClasp</strong>
|
| 274 | </div>
|
| 275 | <div>
|
| 276 | <p className="eyebrow">AGENT-TO-AGENT ASSURANCE</p>
|
| 277 | <h1>Know who your agent is dealing with.</h1>
|
| 278 | <p>
|
| 279 | Verified identities, signed outcomes, private warnings, and contextual
|
| 280 | reliability—without using message bodies for scoring.
|
| 281 | </p>
|
| 282 | </div>
|
| 283 | <div className="loginProof">
|
| 284 | <span>01</span> User-owned history<span>02</span> No universal trust score<span>03</span>{' '}
|
| 285 | Explicit network consent
|
| 286 | </div>
|
| 287 | </section>
|
| 288 | <section className="loginCard">
|
| 289 | <div>
|
| 290 | <p className="eyebrow">SECURE ACCESS</p>
|
| 291 | <h2>Sign in to OpenClasp</h2>
|
| 292 | <p>
|
| 293 | Manage connected agents, review signed history, and control what contributes to the
|
| 294 | network.
|
| 295 | </p>
|
| 296 | </div>
|
| 297 | <div className="socialButtons">
|
| 298 | <button onClick={() => void continueWith('google')}>
|
| 299 | <span className="google">G</span> Continue with Google
|
| 300 | </button>
|
| 301 | <button onClick={() => void continueWith('github')}>
|
| 302 | <span>◉</span> Continue with GitHub
|
| 303 | </button>
|
| 304 | </div>
|
| 305 | {error && <div className="loginError">{error}</div>}
|
| 306 | <small>
|
| 307 | Google and GitHub handle authentication. OpenClasp never receives your password.
|
| 308 | </small>
|
| 309 | </section>
|
| 310 | </div>
|
| 311 | );
|
| 312 | }
|
| 313 |
|
| 314 | let callbackStarted = false;
|
| 315 | function AuthCallback() {
|
| 316 | const [error, setError] = useState('');
|
| 317 | useEffect(() => {
|
| 318 | if (callbackStarted) return;
|
| 319 | callbackStarted = true;
|
| 320 | const finish = async () => {
|
| 321 | const query = new URLSearchParams(location.search);
|
| 322 | const oauthError = query.get('error_description') ?? query.get('error');
|
| 323 | if (oauthError) throw new Error(oauthError);
|
| 324 | const code = query.get('code');
|
| 325 | const returnedState = query.get('state');
|
| 326 | const rawTransaction = sessionStorage.getItem(authTransactionKey);
|
| 327 | if (!code || !returnedState || !rawTransaction) throw new Error('Missing OAuth transaction');
|
| 328 | const transaction = JSON.parse(rawTransaction) as AuthTransaction;
|
| 329 | sessionStorage.removeItem(authTransactionKey);
|
| 330 | if (returnedState !== transaction.state) throw new Error('OAuth state mismatch');
|
| 331 | const response = await fetch('/api/session', {
|
| 332 | method: 'POST',
|
| 333 | credentials: 'same-origin',
|
| 334 | headers: { 'content-type': 'application/json' },
|
| 335 | body: JSON.stringify({
|
| 336 | code,
|
| 337 | codeVerifier: transaction.verifier,
|
| 338 | }),
|
| 339 | });
|
| 340 | if (!response.ok) throw new Error('Auth0 token exchange failed');
|
| 341 | location.replace('/dashboard');
|
| 342 | };
|
| 343 | void finish().catch((reason: unknown) =>
|
| 344 | setError(reason instanceof Error ? reason.message : 'Authentication failed'),
|
| 345 | );
|
| 346 | }, []);
|
| 347 | if (error)
|
| 348 | return (
|
| 349 | <div className="loading">
|
| 350 | <span className="mark">OC</span>
|
| 351 | <p>{error}</p>
|
| 352 | <a href="/login">Return to login</a>
|
| 353 | </div>
|
| 354 | );
|
| 355 | return <Loading />;
|
| 356 | }
|
| 357 |
|
| 358 | function PageContent({
|
| 359 | page,
|
| 360 | data,
|
| 361 | settings,
|
| 362 | setSettings,
|
| 363 | navigate,
|
| 364 | refreshDashboard,
|
| 365 | }: {
|
| 366 | page: Page;
|
| 367 | data: DashboardData;
|
| 368 | settings: Settings;
|
| 369 | setSettings: React.Dispatch<React.SetStateAction<Settings>>;
|
| 370 | navigate: (page: Page) => void;
|
| 371 | refreshDashboard: () => Promise<void>;
|
| 372 | }) {
|
| 373 | if (page === 'history') return <History data={data} />;
|
| 374 | if (page === 'agents')
|
| 375 | return <Agents data={data} navigate={navigate} refreshDashboard={refreshDashboard} />;
|
| 376 | if (page === 'insights') return <Insights data={data} />;
|
| 377 | if (page === 'connect') return <Connect data={data} refreshDashboard={refreshDashboard} />;
|
| 378 | if (page === 'settings') return <SettingsPage settings={settings} setSettings={setSettings} />;
|
| 379 | return <Overview data={data} navigate={navigate} refreshDashboard={refreshDashboard} />;
|
| 380 | }
|
| 381 |
|
| 382 | function Overview({
|
| 383 | data,
|
| 384 | navigate,
|
| 385 | refreshDashboard,
|
| 386 | }: {
|
| 387 | data: DashboardData;
|
| 388 | navigate: (page: Page) => void;
|
| 389 | refreshDashboard: () => Promise<void>;
|
| 390 | }) {
|
| 391 | const completed = data.receipts.filter((item) => item.outcome === 'success').length;
|
| 392 | const warnings = data.events.filter((item) =>
|
| 393 | ['policy_warning', 'policy_violation', 'objection'].includes(String(item.eventType)),
|
| 394 | ).length;
|
| 395 | const publishedIds = new Set(
|
| 396 | data.publications
|
| 397 | .filter((publication) => publication.published)
|
| 398 | .map((publication) => String(publication.agentId)),
|
| 399 | );
|
| 400 | const readyAgents = data.agents.filter((agent) => publishedIds.has(String(agent.agentId))).length;
|
| 401 | const pendingInvitations = data.federatedInteractions.filter(
|
| 402 | (interaction) => interaction.status === 'pending',
|
| 403 | ).length;
|
| 404 | return (
|
| 405 | <>
|
| 406 | <PageHead
|
| 407 | eyebrow="NETWORK OVERVIEW"
|
| 408 | title="Assurance, at a glance."
|
| 409 | action="Connect agent"
|
| 410 | onAction={() => navigate('connect')}
|
| 411 | />
|
| 412 | <section
|
| 413 | className={`readiness ${readyAgents === data.agents.length && readyAgents ? 'ready' : ''}`}
|
| 414 | >
|
| 415 | <div>
|
| 416 | <span className="statusOrb">{readyAgents ? '✓' : '!'}</span>
|
| 417 | <div>
|
| 418 | <strong>
|
| 419 | {readyAgents === data.agents.length && readyAgents
|
| 420 | ? 'Your agent network is ready'
|
| 421 | : `${readyAgents} of ${data.agents.length} agents can receive A2A work`}
|
| 422 | </strong>
|
| 423 | <small>
|
| 424 | Safe matching requests activate automatically. Everything else waits for approval.
|
| 425 | </small>
|
| 426 | </div>
|
| 427 | </div>
|
| 428 | <button className="secondary" onClick={() => navigate('agents')}>
|
| 429 | Manage automation
|
| 430 | </button>
|
| 431 | </section>
|
| 432 | <section className="metrics">
|
| 433 | <Metric label="Connected agents" value={data.agents.length} note="bound identities" />
|
| 434 | <Metric
|
| 435 | label="Interactions"
|
| 436 | value={data.interactions.length + data.federatedInteractions.length}
|
| 437 | note="local and shared"
|
| 438 | />
|
| 439 | <Metric label="Successful outcomes" value={completed} note="receipt-backed" />
|
| 440 | <Metric
|
| 441 | label="Needs review"
|
| 442 | value={warnings + pendingInvitations}
|
| 443 | note="warnings or approvals"
|
| 444 | warn={warnings + pendingInvitations > 0}
|
| 445 | />
|
| 446 | </section>
|
| 447 | <Invitations data={data} refreshDashboard={refreshDashboard} />
|
| 448 | <section className="contentGrid">
|
| 449 | <Panel title="Recent activity" subtitle="Structured events and signed outcomes">
|
| 450 | <Timeline events={data.events.slice(-6).reverse()} />
|
| 451 | <TextButton onClick={() => navigate('history')}>View complete history →</TextButton>
|
| 452 | </Panel>
|
| 453 | <Panel
|
| 454 | title="Reliability context"
|
| 455 | subtitle="Task-specific profiles, never a universal score"
|
| 456 | >
|
| 457 | {data.profiles.length ? (
|
| 458 | data.profiles
|
| 459 | .slice(0, 4)
|
| 460 | .map((profile) => (
|
| 461 | <Profile key={`${profile.agentId}-${profile.taskCategory}`} profile={profile} />
|
| 462 | ))
|
| 463 | ) : (
|
| 464 | <Empty
|
| 465 | title="No reliability profile yet"
|
| 466 | text="Profiles appear after signed receipts and eligible bilateral feedback."
|
| 467 | />
|
| 468 | )}
|
| 469 | </Panel>
|
| 470 | </section>
|
| 471 | </>
|
| 472 | );
|
| 473 | }
|
| 474 |
|
| 475 | function History({ data }: { data: DashboardData }) {
|
| 476 | const records = useMemo(
|
| 477 | () =>
|
| 478 | [
|
| 479 | ...data.interactions.map((value) => ({ ...value, _kind: 'interaction' })),
|
| 480 | ...data.federatedInteractions.map((value) => ({
|
| 481 | ...value,
|
| 482 | _kind: 'federated interaction',
|
| 483 | })),
|
| 484 | ...data.events.map((value) => ({ ...value, _kind: 'event' })),
|
| 485 | ...data.receipts.map((value) => ({ ...value, _kind: 'receipt' })),
|
| 486 | ...data.conflicts.map((value) => ({ ...value, _kind: 'dispute' })),
|
| 487 | ].sort((a, b) => Date.parse(timestamp(b)) - Date.parse(timestamp(a))),
|
| 488 | [data],
|
| 489 | );
|
| 490 | return (
|
| 491 | <>
|
| 492 | <PageHead eyebrow="AUDIT HISTORY" title="What happened, and what proves it." />
|
| 493 | <Panel
|
| 494 | title="Account history"
|
| 495 | subtitle="Only structured metadata, signatures, hashes, and permitted evidence are hosted"
|
| 496 | >
|
| 497 | {records.length ? (
|
| 498 | records.map((item, index) => (
|
| 499 | <HistoryRow
|
| 500 | key={String(
|
| 501 | (item as Record<string, any>).eventId ??
|
| 502 | (item as Record<string, any>).receiptId ??
|
| 503 | (item as Record<string, any>).interactionId ??
|
| 504 | index,
|
| 505 | )}
|
| 506 | item={item}
|
| 507 | />
|
| 508 | ))
|
| 509 | ) : (
|
| 510 | <Empty
|
| 511 | title="No interactions recorded"
|
| 512 | text="Connect an agent and start an assured interaction. Raw message bodies will not appear here."
|
| 513 | />
|
| 514 | )}
|
| 515 | </Panel>
|
| 516 | </>
|
| 517 | );
|
| 518 | }
|
| 519 |
|
| 520 | function Agents({
|
| 521 | data,
|
| 522 | navigate,
|
| 523 | refreshDashboard,
|
| 524 | }: {
|
| 525 | data: DashboardData;
|
| 526 | navigate: (page: Page) => void;
|
| 527 | refreshDashboard: () => Promise<void>;
|
| 528 | }) {
|
| 529 | const [working, setWorking] = useState('');
|
| 530 | const [error, setError] = useState('');
|
| 531 | const saveAutomation = async (
|
| 532 | agentId: string,
|
| 533 | value: {
|
| 534 | autoPublish: boolean;
|
| 535 | autoAcceptPolicy: 'off' | 'safe_matching';
|
| 536 | autoAcceptTaskCategories: string[];
|
| 537 | },
|
| 538 | ) => {
|
| 539 | setWorking(agentId);
|
| 540 | setError('');
|
| 541 | try {
|
| 542 | await api(`/v0.1/agents/${encodeURIComponent(agentId)}/automation`, {
|
| 543 | method: 'PUT',
|
| 544 | body: JSON.stringify(value),
|
| 545 | });
|
| 546 | await refreshDashboard();
|
| 547 | } catch (reason) {
|
| 548 | setError(reason instanceof Error ? reason.message : 'Directory update failed');
|
| 549 | } finally {
|
| 550 | setWorking('');
|
| 551 | }
|
| 552 | };
|
| 553 | return (
|
| 554 | <>
|
| 555 | <PageHead
|
| 556 | eyebrow="IDENTITY REGISTRY"
|
| 557 | title="Your connected agents."
|
| 558 | action="Connect agent"
|
| 559 | onAction={() => navigate('connect')}
|
| 560 | />
|
| 561 | <div className="notice">
|
| 562 | <strong>One approval, then automatic.</strong> OpenClasp creates and hosts the agent's A2A
|
| 563 | endpoint. Safe matching tasks can be accepted automatically; sensitive or mismatched
|
| 564 | requests still require review.
|
| 565 | </div>
|
| 566 | {error && <div className="errorBar">{error}</div>}
|
| 567 | <section className="agentGrid">
|
| 568 | {data.agents.length ? (
|
| 569 | data.agents.map((agent) => (
|
| 570 | <AgentCard
|
| 571 | key={agent.agentId}
|
| 572 | agent={agent}
|
| 573 | projectName={
|
| 574 | data.projects.find((project) => project.projectId === agent.projectId)?.name
|
| 575 | }
|
| 576 | published={data.publications.some(
|
| 577 | (publication) => publication.agentId === agent.agentId && publication.published,
|
| 578 | )}
|
| 579 | working={working === agent.agentId}
|
| 580 | onSave={(value) => saveAutomation(agent.agentId, value)}
|
| 581 | />
|
| 582 | ))
|
| 583 | ) : (
|
| 584 | <Empty
|
| 585 | title="No agents connected"
|
| 586 | text="Install the remote MCP endpoint in an agent, sign in, then create and register its identity."
|
| 587 | action="Open connection guide"
|
| 588 | onAction={() => navigate('connect')}
|
| 589 | />
|
| 590 | )}
|
| 591 | </section>
|
| 592 | </>
|
| 593 | );
|
| 594 | }
|
| 595 |
|
| 596 | function Invitations({
|
| 597 | data,
|
| 598 | refreshDashboard,
|
| 599 | }: {
|
| 600 | data: DashboardData;
|
| 601 | refreshDashboard: () => Promise<void>;
|
| 602 | }) {
|
| 603 | const [working, setWorking] = useState('');
|
| 604 | const [error, setError] = useState('');
|
| 605 | const ownedAgentIds = useMemo(
|
| 606 | () => new Set(data.agents.map((agent) => String(agent.agentId))),
|
| 607 | [data.agents],
|
| 608 | );
|
| 609 | const incoming = data.federatedInteractions.filter(
|
| 610 | (interaction) =>
|
| 611 | interaction.status === 'pending' && ownedAgentIds.has(String(interaction.responderAgentId)),
|
| 612 | );
|
| 613 | const respond = async (interactionId: string, agentId: string, decision: 'accept' | 'reject') => {
|
| 614 | setWorking(interactionId);
|
| 615 | setError('');
|
| 616 | try {
|
| 617 | await api(`/v0.1/federated-interactions/${encodeURIComponent(interactionId)}/respond`, {
|
| 618 | method: 'POST',
|
| 619 | body: JSON.stringify({ agentId, decision }),
|
| 620 | });
|
| 621 | await refreshDashboard();
|
| 622 | } catch (reason) {
|
| 623 | setError(reason instanceof Error ? reason.message : 'Could not respond to invitation');
|
| 624 | } finally {
|
| 625 | setWorking('');
|
| 626 | }
|
| 627 | };
|
| 628 | if (!incoming.length && !data.federatedInteractions.length) return null;
|
| 629 | return (
|
| 630 | <Panel
|
| 631 | title={incoming.length ? `Agent invitations (${incoming.length})` : 'Shared interactions'}
|
| 632 | subtitle="Both accounts see the same immutable contract and acceptance state"
|
| 633 | >
|
| 634 | {error ? <div className="errorBar">{error}</div> : null}
|
| 635 | {(incoming.length ? incoming : data.federatedInteractions.slice(0, 5)).map((interaction) => (
|
| 636 | <article className="setupRequest" key={interaction.interactionId}>
|
| 637 | <div>
|
| 638 | <strong>{interaction.contract?.purpose ?? interaction.interactionId}</strong>
|
| 639 | <small>
|
| 640 | {interaction.initiatorAgentId} → {interaction.responderAgentId} · {interaction.status}
|
| 641 | </small>
|
| 642 | <small>Contract: {String(interaction.termsHash).slice(0, 16)}…</small>
|
| 643 | {interaction.status === 'active' &&
|
| 644 | interaction.acceptances?.[interaction.responderAgentId]?.method ===
|
| 645 | 'policy_auto_accept' ? (
|
| 646 | <small className="autoAccepted">✓ Auto-approved by the responder's safe policy</small>
|
| 647 | ) : null}
|
| 648 | </div>
|
| 649 | {interaction.status === 'pending' &&
|
| 650 | ownedAgentIds.has(String(interaction.responderAgentId)) ? (
|
| 651 | <div className="decisionButtons">
|
| 652 | <button
|
| 653 | className="secondary"
|
| 654 | disabled={working === interaction.interactionId}
|
| 655 | onClick={() =>
|
| 656 | void respond(interaction.interactionId, interaction.responderAgentId, 'reject')
|
| 657 | }
|
| 658 | >
|
| 659 | Reject
|
| 660 | </button>
|
| 661 | <button
|
| 662 | className="primary"
|
| 663 | disabled={working === interaction.interactionId}
|
| 664 | onClick={() =>
|
| 665 | void respond(interaction.interactionId, interaction.responderAgentId, 'accept')
|
| 666 | }
|
| 667 | >
|
| 668 | {working === interaction.interactionId ? 'Working…' : 'Accept contract'}
|
| 669 | </button>
|
| 670 | </div>
|
| 671 | ) : null}
|
| 672 | </article>
|
| 673 | ))}
|
| 674 | </Panel>
|
| 675 | );
|
| 676 | }
|
| 677 |
|
| 678 | function Insights({ data }: { data: DashboardData }) {
|
| 679 | return (
|
| 680 | <>
|
| 681 | <PageHead eyebrow="BEHAVIOURAL CONTEXT" title="Evidence, not reputation theatre." />
|
| 682 | <div className="notice">
|
| 683 | <strong>Context matters.</strong> OpenClasp profiles an agent by task category and version.
|
| 684 | It does not produce a single universal trust score.
|
| 685 | </div>
|
| 686 | <section className="agentGrid">
|
| 687 | {data.profiles.length ? (
|
| 688 | data.profiles.map((profile) => (
|
| 689 | <Panel
|
| 690 | key={`${profile.agentId}-${profile.taskCategory}`}
|
| 691 | title={profile.agentId}
|
| 692 | subtitle={`${profile.taskCategory} · v${profile.agentVersion}`}
|
| 693 | >
|
| 694 | <Profile profile={profile} expanded />
|
| 695 | </Panel>
|
| 696 | ))
|
| 697 | ) : (
|
| 698 | <Empty
|
| 699 | title="Not enough verified evidence"
|
| 700 | text="Insights grow only from signed outcomes, eligible feedback, corrections, disputes, and version-aware history."
|
| 701 | />
|
| 702 | )}
|
| 703 | </section>
|
| 704 | </>
|
| 705 | );
|
| 706 | }
|
| 707 |
|
| 708 | function Connect({
|
| 709 | data,
|
| 710 | refreshDashboard,
|
| 711 | }: {
|
| 712 | data: DashboardData;
|
| 713 | refreshDashboard: () => Promise<void>;
|
| 714 | }) {
|
| 715 | const endpoint = 'https://openclasp.vercel.app/mcp';
|
| 716 | const [copied, setCopied] = useState(false);
|
| 717 | const [working, setWorking] = useState('');
|
| 718 | const [decisionError, setDecisionError] = useState('');
|
| 719 | const pending = data.setupRequests.filter((request) => request.status === 'pending');
|
| 720 | useEffect(() => {
|
| 721 | const poll = () => void refreshDashboard().catch(() => undefined);
|
| 722 | poll();
|
| 723 | const timer = window.setInterval(poll, 5000);
|
| 724 | return () => window.clearInterval(timer);
|
| 725 | }, [refreshDashboard]);
|
| 726 | const decide = async (requestId: string, decision: 'approve' | 'reject') => {
|
| 727 | setWorking(requestId);
|
| 728 | setDecisionError('');
|
| 729 | try {
|
| 730 | await api(`/v0.1/onboarding/${encodeURIComponent(requestId)}/${decision}`, {
|
| 731 | method: 'POST',
|
| 732 | });
|
| 733 | await refreshDashboard();
|
| 734 | } catch (reason) {
|
| 735 | setDecisionError(reason instanceof Error ? reason.message : 'Could not update setup request');
|
| 736 | } finally {
|
| 737 | setWorking('');
|
| 738 | }
|
| 739 | };
|
| 740 | return (
|
| 741 | <>
|
| 742 | <PageHead eyebrow="AGENT CONNECTION" title="Add OpenClasp to an agent." />
|
| 743 | {pending.length > 0 && (
|
| 744 | <section className="setupRequests">
|
| 745 | <div>
|
| 746 | <p className="eyebrow">CONFIRMATION REQUIRED</p>
|
| 747 | <h2>Approve agent setup</h2>
|
| 748 | <p>
|
| 749 | An agent proposed this identity. Confirm it before OpenClasp binds the installation.
|
| 750 | </p>
|
| 751 | </div>
|
| 752 | {pending.map((request) => (
|
| 753 | <article className="setupRequest" key={request.requestId}>
|
| 754 | <div>
|
| 755 | <strong>{request.agentName ?? 'Switch installation'}</strong>
|
| 756 | <small>
|
| 757 | {request.projectName ?? request.existingAgentId} · {request.framework}
|
| 758 | </small>
|
| 759 | {!!request.capabilities?.length && (
|
| 760 | <div className="tags">
|
| 761 | {request.capabilities.slice(0, 5).map((capability: string) => (
|
| 762 | <span key={capability}>{capability}</span>
|
| 763 | ))}
|
| 764 | </div>
|
| 765 | )}
|
| 766 | {!!request.limitations?.length && (
|
| 767 | <small>Limitations: {request.limitations.join(' · ')}</small>
|
| 768 | )}
|
| 769 | <div className="automationPreview">
|
| 770 | <span>{request.autoPublish ? 'Public after approval' : 'Private'}</span>
|
| 771 | <span>
|
| 772 | {request.autoAcceptPolicy === 'safe_matching'
|
| 773 | ? 'Auto-accept safe matches'
|
| 774 | : 'Review every request'}
|
| 775 | </span>
|
| 776 | </div>
|
| 777 | </div>
|
| 778 | <div className="decisionButtons">
|
| 779 | <button
|
| 780 | className="secondary"
|
| 781 | disabled={working === request.requestId}
|
| 782 | onClick={() => void decide(request.requestId, 'reject')}
|
| 783 | >
|
| 784 | Reject
|
| 785 | </button>
|
| 786 | <button
|
| 787 | className="primary"
|
| 788 | disabled={working === request.requestId}
|
| 789 | onClick={() => void decide(request.requestId, 'approve')}
|
| 790 | >
|
| 791 | {working === request.requestId ? 'Working…' : 'Approve & automate'}
|
| 792 | </button>
|
| 793 | </div>
|
| 794 | </article>
|
| 795 | ))}
|
| 796 | {decisionError && <div className="loginError">{decisionError}</div>}
|
| 797 | </section>
|
| 798 | )}
|
| 799 | <section className="connectLayout">
|
| 800 | <Panel title="Connect once" subtitle="OpenClasp handles the routine steps afterward">
|
| 801 | <div className="endpoint">
|
| 802 | <code>{endpoint}</code>
|
| 803 | <button
|
| 804 | onClick={() => {
|
| 805 | void navigator.clipboard.writeText(endpoint);
|
| 806 | setCopied(true);
|
| 807 | }}
|
| 808 | >
|
| 809 | {copied ? 'Copied' : 'Copy'}
|
| 810 | </button>
|
| 811 | </div>
|
| 812 | <ol>
|
| 813 | <li>Add this MCP URL and complete the OAuth sign-in.</li>
|
| 814 | <li>
|
| 815 | Tell the agent: <code>Set yourself up on OpenClasp</code>.
|
| 816 | </li>
|
| 817 | <li>
|
| 818 | Approve its identity and automation policy here once. That is the last routine manual
|
| 819 | step.
|
| 820 | </li>
|
| 821 | </ol>
|
| 822 | </Panel>
|
| 823 | <Panel
|
| 824 | title="What becomes automatic"
|
| 825 | subtitle="Safe defaults with deterministic approval boundaries"
|
| 826 | >
|
| 827 | <ul className="checkList">
|
| 828 | <li>Agent Card publication and discovery</li>
|
| 829 | <li>Contract defaults inferred from the task</li>
|
| 830 | <li>Safe matching invitations accepted immediately</li>
|
| 831 | <li>Ready-to-send A2A endpoint, headers, and metadata</li>
|
| 832 | <li>Risky requests routed to human review</li>
|
| 833 | </ul>
|
| 834 | </Panel>
|
| 835 | </section>
|
| 836 | </>
|
| 837 | );
|
| 838 | }
|
| 839 |
|
| 840 | function SettingsPage({
|
| 841 | settings,
|
| 842 | setSettings,
|
| 843 | }: {
|
| 844 | settings: Settings;
|
| 845 | setSettings: React.Dispatch<React.SetStateAction<Settings>>;
|
| 846 | }) {
|
| 847 | const [saving, setSaving] = useState(false);
|
| 848 | const [saved, setSaved] = useState(false);
|
| 849 | const save = useCallback(async () => {
|
| 850 | setSaving(true);
|
| 851 | setSaved(false);
|
| 852 | const updated = (await api('/v0.1/settings', {
|
| 853 | method: 'PUT',
|
| 854 | body: JSON.stringify(settings),
|
| 855 | })) as Settings;
|
| 856 | setSettings(updated);
|
| 857 | setSaving(false);
|
| 858 | setSaved(true);
|
| 859 | }, [settings, setSettings]);
|
| 860 | return (
|
| 861 | <>
|
| 862 | <PageHead eyebrow="ACCOUNT CONTROLS" title="Privacy and network settings." />
|
| 863 | <section className="settingsCard">
|
| 864 | <Setting label="Display name" description="Shown only inside your OpenClasp account.">
|
| 865 | <input
|
| 866 | value={settings.displayName}
|
| 867 | onChange={(event) =>
|
| 868 | setSettings((value) => ({ ...value, displayName: event.target.value }))
|
| 869 | }
|
| 870 | placeholder="Team or operator name"
|
| 871 | />
|
| 872 | </Setting>
|
| 873 | <Setting
|
| 874 | label="Network contribution"
|
| 875 | description="Allow eligible structured aggregates to improve contextual intelligence. Raw conversations are never included."
|
| 876 | >
|
| 877 | <Toggle
|
| 878 | checked={settings.contributionEnabled}
|
| 879 | onChange={(checked) =>
|
| 880 | setSettings((value) => ({ ...value, contributionEnabled: checked }))
|
| 881 | }
|
| 882 | />
|
| 883 | </Setting>
|
| 884 | <Setting
|
| 885 | label="Evidence sharing"
|
| 886 | description="Controls when permitted evidence references may be shared with interaction participants."
|
| 887 | >
|
| 888 | <select
|
| 889 | value={settings.evidenceSharing}
|
| 890 | onChange={(event) =>
|
| 891 | setSettings((value) => ({
|
| 892 | ...value,
|
| 893 | evidenceSharing: event.target.value as Settings['evidenceSharing'],
|
| 894 | }))
|
| 895 | }
|
| 896 | >
|
| 897 | <option value="never">Never</option>
|
| 898 | <option value="ask">Ask every time</option>
|
| 899 | <option value="contract_only">When contract permits</option>
|
| 900 | </select>
|
| 901 | </Setting>
|
| 902 | <Setting
|
| 903 | label="Structured record retention"
|
| 904 | description="Retention for hosted account records. Signed protocol records may require separate revocation markers."
|
| 905 | >
|
| 906 | <select
|
| 907 | value={settings.retentionDays}
|
| 908 | onChange={(event) =>
|
| 909 | setSettings((value) => ({ ...value, retentionDays: Number(event.target.value) }))
|
| 910 | }
|
| 911 | >
|
| 912 | <option value={7}>7 days</option>
|
| 913 | <option value={30}>30 days</option>
|
| 914 | <option value={90}>90 days</option>
|
| 915 | <option value={365}>1 year</option>
|
| 916 | <option value={0}>No automatic deletion</option>
|
| 917 | </select>
|
| 918 | </Setting>
|
| 919 | <Setting
|
| 920 | label="Gateway message bodies"
|
| 921 | description="Encrypted at rest, deleted on acknowledgement, and automatically expired after 24 hours. Never used for profiles."
|
| 922 | >
|
| 923 | <span className="locked">24H MAX</span>
|
| 924 | </Setting>
|
| 925 | <div className="saveRow">
|
| 926 | <button className="primary" onClick={() => void save()} disabled={saving}>
|
| 927 | {saving ? 'Saving…' : 'Save settings'}
|
| 928 | </button>
|
| 929 | {saved && <span>Saved</span>}
|
| 930 | </div>
|
| 931 | </section>
|
| 932 | </>
|
| 933 | );
|
| 934 | }
|
| 935 |
|
| 936 | function PageHead({
|
| 937 | eyebrow,
|
| 938 | title,
|
| 939 | action,
|
| 940 | onAction,
|
| 941 | }: {
|
| 942 | eyebrow: string;
|
| 943 | title: string;
|
| 944 | action?: string;
|
| 945 | onAction?: () => void;
|
| 946 | }) {
|
| 947 | return (
|
| 948 | <header className="pageHead">
|
| 949 | <div>
|
| 950 | <p className="eyebrow">{eyebrow}</p>
|
| 951 | <h1>{title}</h1>
|
| 952 | </div>
|
| 953 | {action && (
|
| 954 | <button className="primary" onClick={onAction}>
|
| 955 | {action}
|
| 956 | </button>
|
| 957 | )}
|
| 958 | </header>
|
| 959 | );
|
| 960 | }
|
| 961 | function Nav({
|
| 962 | page,
|
| 963 | active,
|
| 964 | onClick,
|
| 965 | label,
|
| 966 | glyph,
|
| 967 | }: {
|
| 968 | page: Page;
|
| 969 | active: Page;
|
| 970 | onClick: (page: Page) => void;
|
| 971 | label: string;
|
| 972 | glyph: string;
|
| 973 | }) {
|
| 974 | return (
|
| 975 | <button className={active === page ? 'active' : ''} onClick={() => onClick(page)}>
|
| 976 | <span>{glyph}</span>
|
| 977 | {label}
|
| 978 | </button>
|
| 979 | );
|
| 980 | }
|
| 981 | function Metric({
|
| 982 | label,
|
| 983 | value,
|
| 984 | note,
|
| 985 | warn,
|
| 986 | }: {
|
| 987 | label: string;
|
| 988 | value: number;
|
| 989 | note: string;
|
| 990 | warn?: boolean;
|
| 991 | }) {
|
| 992 | return (
|
| 993 | <article className={warn ? 'metric warn' : 'metric'}>
|
| 994 | <span>{label}</span>
|
| 995 | <strong>{String(value).padStart(2, '0')}</strong>
|
| 996 | <small>{note}</small>
|
| 997 | </article>
|
| 998 | );
|
| 999 | }
|
| 1000 | function Panel({
|
| 1001 | title,
|
| 1002 | subtitle,
|
| 1003 | children,
|
| 1004 | }: React.PropsWithChildren<{ title: string; subtitle: string }>) {
|
| 1005 | return (
|
| 1006 | <section className="panel">
|
| 1007 | <div className="panelHead">
|
| 1008 | <div>
|
| 1009 | <h2>{title}</h2>
|
| 1010 | <p>{subtitle}</p>
|
| 1011 | </div>
|
| 1012 | </div>
|
| 1013 | {children}
|
| 1014 | </section>
|
| 1015 | );
|
| 1016 | }
|
| 1017 | function Timeline({ events }: { events: Record<string, any>[] }) {
|
| 1018 | return events.length ? (
|
| 1019 | <div className="timeline">
|
| 1020 | {events.map((event) => (
|
| 1021 | <HistoryRow key={event.eventId} item={{ ...event, _kind: 'event' }} />
|
| 1022 | ))}
|
| 1023 | </div>
|
| 1024 | ) : (
|
| 1025 | <Empty
|
| 1026 | title="Nothing recorded yet"
|
| 1027 | text="Activity appears after your connected agents submit signed structured events."
|
| 1028 | />
|
| 1029 | );
|
| 1030 | }
|
| 1031 | function HistoryRow({ item }: { item: Record<string, any> }) {
|
| 1032 | const kind = String(item.eventType ?? item._kind ?? 'record').replaceAll('_', ' ');
|
| 1033 | const id = String(item.agentId ?? item.interactionId ?? item.receiptId ?? 'OpenClasp');
|
| 1034 | return (
|
| 1035 | <article className="historyRow">
|
| 1036 | <span className={`eventDot ${item.eventType ?? item._kind}`} />
|
| 1037 | <div>
|
| 1038 | <strong>{kind}</strong>
|
| 1039 | <small>
|
| 1040 | {id} · {new Date(timestamp(item)).toLocaleString()}
|
| 1041 | </small>
|
| 1042 | </div>
|
| 1043 | <b>{item.visibility ?? item.outcome ?? item.status ?? 'SIGNED'}</b>
|
| 1044 | </article>
|
| 1045 | );
|
| 1046 | }
|
| 1047 | function AgentCard({
|
| 1048 | agent,
|
| 1049 | projectName,
|
| 1050 | published,
|
| 1051 | working,
|
| 1052 | onSave,
|
| 1053 | }: {
|
| 1054 | agent: Record<string, any>;
|
| 1055 | projectName?: string;
|
| 1056 | published: boolean;
|
| 1057 | working: boolean;
|
| 1058 | onSave: (value: {
|
| 1059 | autoPublish: boolean;
|
| 1060 | autoAcceptPolicy: 'off' | 'safe_matching';
|
| 1061 | autoAcceptTaskCategories: string[];
|
| 1062 | }) => void;
|
| 1063 | }) {
|
| 1064 | const [editing, setEditing] = useState(false);
|
| 1065 | const [autoPublish, setAutoPublish] = useState(Boolean(agent.autoPublish ?? published));
|
| 1066 | const [autoAcceptPolicy, setAutoAcceptPolicy] = useState<'off' | 'safe_matching'>(
|
| 1067 | agent.autoAcceptPolicy === 'safe_matching' ? 'safe_matching' : 'off',
|
| 1068 | );
|
| 1069 | const [categories, setCategories] = useState<string>(
|
| 1070 | (agent.autoAcceptTaskCategories?.length
|
| 1071 | ? agent.autoAcceptTaskCategories
|
| 1072 | : (agent.capabilities ?? [])
|
| 1073 | ).join(', '),
|
| 1074 | );
|
| 1075 | const ready = published;
|
| 1076 | const endpoint = `${window.location.origin}/a2a/${encodeURIComponent(agent.agentId)}`;
|
| 1077 | const identityLabel = agent.revoked
|
| 1078 | ? 'REVOKED'
|
| 1079 | : agent.identityMode === 'oauth_installation'
|
| 1080 | ? 'AUTHENTICATED'
|
| 1081 | : 'VERIFIED';
|
| 1082 | return (
|
| 1083 | <article className="agentCard">
|
| 1084 | <div className="agentTop">
|
| 1085 | <span className="agentGlyph">◇</span>
|
| 1086 | <div className="agentBadges">
|
| 1087 | <b className={agent.revoked ? 'bad' : ''}>{identityLabel}</b>
|
| 1088 | <b className={ready ? 'readyBadge' : 'needsBadge'}>{ready ? 'READY' : 'SETUP NEEDED'}</b>
|
| 1089 | </div>
|
| 1090 | </div>
|
| 1091 | <h2>{agent.name ?? agent.agentId}</h2>
|
| 1092 | <p>{projectName ?? `Version ${agent.agentVersion ?? '1.0.0'}`}</p>
|
| 1093 | <div className="tags">
|
| 1094 | {(agent.capabilities ?? []).slice(0, 4).map((capability: string) => (
|
| 1095 | <span key={capability}>{capability}</span>
|
| 1096 | ))}
|
| 1097 | </div>
|
| 1098 | <small>
|
| 1099 | {agent.framework ? `${agent.framework} · ` : ''}
|
| 1100 | {agent.identityMode === 'oauth_installation' ? 'OAuth-bound · ' : 'Ed25519 · '}Created{' '}
|
| 1101 | {new Date(agent.createdAt).toLocaleDateString()}
|
| 1102 | </small>
|
| 1103 | {published ? (
|
| 1104 | <a
|
| 1105 | href={`/agents/${encodeURIComponent(agent.agentId)}/card.json`}
|
| 1106 | target="_blank"
|
| 1107 | rel="noreferrer"
|
| 1108 | >
|
| 1109 | Public Agent Card ↗
|
| 1110 | </a>
|
| 1111 | ) : null}
|
| 1112 | <div className="automationSummary">
|
| 1113 | <span>{published ? '● Public discovery' : '○ Private'}</span>
|
| 1114 | <span>↗ OpenClasp A2A gateway</span>
|
| 1115 | <span>
|
| 1116 | {agent.autoAcceptPolicy === 'safe_matching'
|
| 1117 | ? '⚡ Safe tasks automatic'
|
| 1118 | : '◷ Manual approval'}
|
| 1119 | </span>
|
| 1120 | </div>
|
| 1121 | {editing ? (
|
| 1122 | <div className="automationForm">
|
| 1123 | <label>
|
| 1124 | <span>Hosted A2A endpoint</span>
|
| 1125 | <input type="url" value={endpoint} readOnly />
|
| 1126 | </label>
|
| 1127 | <label>
|
| 1128 | <span>Invitation policy</span>
|
| 1129 | <select
|
| 1130 | value={autoAcceptPolicy}
|
| 1131 | onChange={(event) =>
|
| 1132 | setAutoAcceptPolicy(event.target.value as 'off' | 'safe_matching')
|
| 1133 | }
|
| 1134 | >
|
| 1135 | <option value="safe_matching">Auto-accept safe matches</option>
|
| 1136 | <option value="off">Review every request</option>
|
| 1137 | </select>
|
| 1138 | </label>
|
| 1139 | <label>
|
| 1140 | <span>Safe task categories</span>
|
| 1141 | <input
|
| 1142 | value={categories}
|
| 1143 | onChange={(event) => setCategories(event.target.value)}
|
| 1144 | placeholder="research, planning, coding"
|
| 1145 | />
|
| 1146 | </label>
|
| 1147 | <label className="checkControl">
|
| 1148 | <input
|
| 1149 | type="checkbox"
|
| 1150 | checked={autoPublish}
|
| 1151 | onChange={(event) => setAutoPublish(event.target.checked)}
|
| 1152 | />
|
| 1153 | <span>Publish and keep Agent Card updated</span>
|
| 1154 | </label>
|
| 1155 | <div className="agentActions">
|
| 1156 | <button className="secondary" onClick={() => setEditing(false)}>
|
| 1157 | Cancel
|
| 1158 | </button>
|
| 1159 | <button
|
| 1160 | className="primary"
|
| 1161 | disabled={working || agent.status === 'revoked'}
|
| 1162 | onClick={() =>
|
| 1163 | onSave({
|
| 1164 | autoPublish,
|
| 1165 | autoAcceptPolicy,
|
| 1166 | autoAcceptTaskCategories: categories
|
| 1167 | .split(',')
|
| 1168 | .map((value) => value.trim())
|
| 1169 | .filter(Boolean),
|
| 1170 | })
|
| 1171 | }
|
| 1172 | >
|
| 1173 | {working ? 'Saving…' : 'Save automation'}
|
| 1174 | </button>
|
| 1175 | </div>
|
| 1176 | </div>
|
| 1177 | ) : (
|
| 1178 | <button
|
| 1179 | className="secondary"
|
| 1180 | disabled={working || agent.status === 'revoked'}
|
| 1181 | onClick={() => setEditing(true)}
|
| 1182 | >
|
| 1183 | Configure automation
|
| 1184 | </button>
|
| 1185 | )}
|
| 1186 | </article>
|
| 1187 | );
|
| 1188 | }
|
| 1189 | function Profile({ profile, expanded }: { profile: Record<string, any>; expanded?: boolean }) {
|
| 1190 | const dimensions = [
|
| 1191 | ['Completion', profile.completion],
|
| 1192 | ['Scope', profile.scope],
|
| 1193 | ['Evidence', profile.evidence],
|
| 1194 | ...(expanded
|
| 1195 | ? [
|
| 1196 | ['Communication', profile.communication],
|
| 1197 | ['Deadline', profile.deadline],
|
| 1198 | ]
|
| 1199 | : []),
|
| 1200 | ] as [string, number][];
|
| 1201 | return (
|
| 1202 | <article className="profile">
|
| 1203 | <div>
|
| 1204 | <strong>{profile.agentId}</strong>
|
| 1205 | <small>
|
| 1206 | {profile.taskCategory} · {profile.sampleSize} outcome(s)
|
| 1207 | </small>
|
| 1208 | </div>
|
| 1209 | {dimensions.map(([label, value]) => (
|
| 1210 | <Meter key={label} label={label} value={value ?? 0} />
|
| 1211 | ))}
|
| 1212 | </article>
|
| 1213 | );
|
| 1214 | }
|
| 1215 | function Meter({ label, value }: { label: string; value: number }) {
|
| 1216 | return (
|
| 1217 | <div className="meter">
|
| 1218 | <span>{label}</span>
|
| 1219 | <i>
|
| 1220 | <b style={{ width: `${Math.round(value * 100)}%` }} />
|
| 1221 | </i>
|
| 1222 | <strong>{Math.round(value * 100)}%</strong>
|
| 1223 | </div>
|
| 1224 | );
|
| 1225 | }
|
| 1226 | function Empty({
|
| 1227 | title,
|
| 1228 | text,
|
| 1229 | action,
|
| 1230 | onAction,
|
| 1231 | }: {
|
| 1232 | title: string;
|
| 1233 | text: string;
|
| 1234 | action?: string;
|
| 1235 | onAction?: () => void;
|
| 1236 | }) {
|
| 1237 | return (
|
| 1238 | <div className="empty">
|
| 1239 | <span>◇</span>
|
| 1240 | <strong>{title}</strong>
|
| 1241 | <p>{text}</p>
|
| 1242 | {action && (
|
| 1243 | <button className="secondary" onClick={onAction}>
|
| 1244 | {action}
|
| 1245 | </button>
|
| 1246 | )}
|
| 1247 | </div>
|
| 1248 | );
|
| 1249 | }
|
| 1250 | function TextButton({ children, onClick }: React.PropsWithChildren<{ onClick: () => void }>) {
|
| 1251 | return (
|
| 1252 | <button className="textButton" onClick={onClick}>
|
| 1253 | {children}
|
| 1254 | </button>
|
| 1255 | );
|
| 1256 | }
|
| 1257 | function Setting({
|
| 1258 | label,
|
| 1259 | description,
|
| 1260 | children,
|
| 1261 | }: React.PropsWithChildren<{ label: string; description: string }>) {
|
| 1262 | return (
|
| 1263 | <div className="setting">
|
| 1264 | <div>
|
| 1265 | <strong>{label}</strong>
|
| 1266 | <p>{description}</p>
|
| 1267 | </div>
|
| 1268 | <div>{children}</div>
|
| 1269 | </div>
|
| 1270 | );
|
| 1271 | }
|
| 1272 | function Toggle({ checked, onChange }: { checked: boolean; onChange: (checked: boolean) => void }) {
|
| 1273 | return (
|
| 1274 | <button
|
| 1275 | className={checked ? 'toggle on' : 'toggle'}
|
| 1276 | role="switch"
|
| 1277 | aria-checked={checked}
|
| 1278 | onClick={() => onChange(!checked)}
|
| 1279 | >
|
| 1280 | <span />
|
| 1281 | </button>
|
| 1282 | );
|
| 1283 | }
|
| 1284 | function Loading({ compact }: { compact?: boolean }) {
|
| 1285 | return (
|
| 1286 | <div className={compact ? 'loading compact' : 'loading'}>
|
| 1287 | <span className="mark">OC</span>
|
| 1288 | <p>Verifying session…</p>
|
| 1289 | </div>
|
| 1290 | );
|
| 1291 | }
|
| 1292 | function initials(value: string) {
|
| 1293 | return value
|
| 1294 | .split(/\s+|@/)
|
| 1295 | .slice(0, 2)
|
| 1296 | .map((part) => part[0]?.toUpperCase())
|
| 1297 | .join('');
|
| 1298 | }
|
| 1299 | function timestamp(item: Record<string, any>) {
|
| 1300 | return String(item.timestamp ?? item.completedAt ?? item.createdAt ?? new Date(0).toISOString());
|
| 1301 | }
|
| 1302 |
|
| 1303 | if (!__AUTH0_DOMAIN__ || !__AUTH0_CLIENT_ID__ || !__AUTH0_AUDIENCE__)
|
| 1304 | throw new Error('Auth0 public configuration is incomplete');
|
| 1305 | createRoot(document.getElementById('root')!).render(
|
| 1306 | <React.StrictMode>
|
| 1307 | {location.pathname === '/sso-callback' ? <AuthCallback /> : <App />}
|
| 1308 | </React.StrictMode>,
|
| 1309 | );
|