agent-fabric
React
Overview

@veridex/agents-react

A suite of focused hooks that each mirror exactly one runtime concern, plus a <AgentProvider> that holds the connection and run registry.

npm install @veridex/agents-react

Provider

import { AgentProvider } from '@veridex/agents-react';
 
export default function App({ children }) {
  return (
    <AgentProvider
      endpoint="/api/agent"            // your SSE/WS endpoint
      getToken={async () => session.accessToken}
    >
      {children}
    </AgentProvider>
  );
}

The provider negotiates SSE first, falls back to WebSocket. High-frequency events are batched at 30 Hz; consumers see settled state.

Hooks at a glance

HookMirrorsUse it for
useRunrun lifecycleSubmit input, observe status, stream tokens
useApprovalsApprovalManagerApproval inbox; decide
useTraceEventBusInspector UIs, debugging
useMemoryMemoryManagerInspect, promote, revoke memory
useContextHealthContextCompilerLive VeV_e utilisation and per-section tokens
useSkillsskill registryToggle skills per run
useBudgetmetricsCost dashboards
useCheckpointCheckpointManagerRestore points
useSandboxStatussandboxRunning tools, resource usage
useAgentaggregatorSimple cases

See Hooks Reference for full signatures.

Example: an approval inbox + budget dashboard

import { useApprovals, useBudget } from '@veridex/agents-react';
 
function Dashboard({ tenantId }: { tenantId: string }) {
  const { pending, decide } = useApprovals({ scope: { tenantId } });
  const { dollars, tokensIn, tokensOut } = useBudget({ scope: { tenantId, window: 'day' } });
 
  return (
    <Grid>
      <Card title="Today's spend">${dollars.toFixed(2)} · {tokensIn + tokensOut} tokens</Card>
      <Section title="Pending approvals">
        {pending.map(req => (
          <ApprovalCard key={req.id} request={req}
            onAllow={(r) => decide(req.id, { decision: 'allow', reason: r })}
            onDeny={(r)  => decide(req.id, { decision: 'deny',  reason: r })}
          />
        ))}
      </Section>
    </Grid>
  );
}

Principles

  1. One hook per concern. Compose at the app layer.
  2. Server-pushed, optimistically rendered. Trace events stream; submissions are optimistic.
  3. Strict typing. Payloads are the same TraceEvent shape as the server.
  4. No hidden global state. Mount <MockAgentProvider> in tests.

Related