@deksden-com/cpa-kit-react
v0.1.3
Published
Portable, host-authenticated CPA console. No login page, router, Next.js, Tailwind scanner or toast provider is required.
Readme
CPA Kit React
Portable, host-authenticated CPA console. No login page, router, Next.js, Tailwind scanner or toast provider is required.
Available on npm:
pnpm add @deksden-com/cpa-kit-react @deksden-com/cpa-kit. No install token required.
import { useMemo } from 'react';
import { createCpaAdminClient } from '@deksden-com/cpa-kit/client';
import { CpaConsole } from '@deksden-com/cpa-kit-react';
import '@deksden-com/cpa-kit-react/styles.css';
export function Administration({ csrfToken }: { csrfToken: string }) {
const client = useMemo(() => createCpaAdminClient({
baseUrl: '/api/cpa', instanceId: 'primary',
headers: () => ({ 'X-CSRF-Token': csrfToken }),
}), [csrfToken]);
return <CpaConsole client={client} instanceId="primary" locale="ru" theme="dark" />;
}Documentation index: installation, host API and safe runtime updates. React and React DOM 19.2.x are required; use the matching core peer version.
Memoize the scoped client for the lifetime of the instance. initialPanel provides internal navigation; panel + onNavigate allows a host router to control navigation. initialOperationId resumes a durable job after reload; onOperationChange lets the host put its safe operation ID in the URL. The package never stores credentials, files or management/inference keys in browser storage. The host must authenticate and authorize every read/mutation, enforce same-origin/CSRF and execute the accepted operation in a durable worker.
initialCandidateId can reopen an owner-authorized import preview, including an alias resolved by the host API. Apply/cancel always use the canonical candidateId from the validated preview response, never the URL alias. Capability modes and overwrite govern the available import controls; absent policy fails closed. PG merge-only pools cannot select full replacement or overwrite existing identities.
Individual CpaOverviewPanel, CpaCredentialsPanel, CpaModelsPanel, CpaVersionsPanel, and CpaOperationsPanel use the same props; when controlled the host must handle onNavigate. locale supports Russian and English; labels overrides phrasing without a mandatory i18n dependency. probeProtocols and reasoningProfiles must match host-approved probe policies. A probe always requires explicit confirmation. Missing capabilities show disabled actions with reason codes; management unavailability does not imply inference failure.
Import is one ZIP/JSON control, with an optional native directory picker inside a disclosure. Unsupported directory pickers fall back to ZIP. Preview is explicit, and deletions must be confirmed. Polling is 1 second active/5 seconds hidden, transient backoff capped at 30 seconds, stopped at terminal or recovery state and aborted on unmount. The redacted operation outcome is displayed inline, not only as a transient toast.
All styles are scoped under .cpa-kit, with overridable --cpa-* CSS custom properties. No fonts or global reset are injected. Light/dark, reduced-motion-compatible static UI, 320px layout and keyboard focus are supported. Keys and upstream error bodies must not be passed as props.
