UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

123 lines • 5.21 kB
import type { CssVocabulary, TailwindTokens } from './sandbox-styles.js'; /** One prop of a kit component, as its TypeScript type declares it. */ export interface SandboxKitPropDoc { name: string; /** The type as TypeScript prints it: `"default" | "outline"`, `(value: number[]) => void`. */ type: string; required: boolean; description?: string; /** From a `@default` JSDoc tag. */ default?: string; } /** One kit component — an export of the kit entry the model may use as `<Name />`. */ export interface SandboxKitComponentDoc { name: string; description?: string; props: SandboxKitPropDoc[]; /** The element whose native attributes it also takes (`button`), when it spreads them. */ inherits?: string; } /** * What the model is told about the app's design system: its components (when there are any), what * its styles are — Tailwind (its tokens) or plain CSS (its class vocabulary) — the theme's variables, * and the app's own notes. Only what exists is described. */ export interface SandboxKitDocs { version: 2; /** The kit's components, from their types (or names and propTypes in a JavaScript project). */ components: SandboxKitComponentDoc[]; /** The model writes JSX: a kit bundle exists (components, or a wrapper). */ jsx?: boolean; /** The App is rendered inside the app's wrapper (`genuiSandboxKit({ wrapper })`: providers, theme). */ wrapper?: boolean; /** The theme variables (name → light value) the app's CSS declares — what the prompt names. */ theme?: { vars: Record<string, string>; }; /** The styles use Tailwind: the frame runs it, with these tokens. */ tailwind?: { version: 3 | 4; tokens: TailwindTokens; }; /** The styles are plain CSS (Sass, Less, Bootstrap…): the classes they define. */ vocabulary?: CssVocabulary; /** The app's own guidance on its styles (`stylesDocs`), as written. */ guide?: string; } /** Where the browser fetches the frame's assets from (same origin). `null`: there is none. */ export interface SandboxKitAssets { /** React, ReactDOM, the components and the wrapper, as one classic script (JSX views only). */ kit: { url: string; hash?: string; } | null; /** The app's styles, compiled (fonts and images inlined). */ css: { url: string; hash?: string; } | null; /** The Tailwind v4 browser runtime, and the app's Tailwind directives (`@theme`, variants, utilities). */ tailwind: { url: string; css?: string; } | null; } /** What the Vite plugin writes (dev) and emits (build), and what the server discovers. */ export interface SandboxKitDescriptor extends SandboxKitDocs { assets: SandboxKitAssets; } /** * What a sandbox renderer needs from the server (`GET <agent>/config` → `genui.sandbox`): whether to * pass the theme in, and where the kit bundle, the compiled styles and the Tailwind runtime are. */ export interface SandboxClientConfig { theme: boolean; /** The kit's name, when it is a named one (`genuiSandboxKit({ name })`): whose dev rebuilds to follow. */ name?: string; kit?: { url: string; hash?: string; }; css?: { url: string; hash?: string; }; tailwind?: { url: string; css?: string; }; } /** What the opt-in assets weigh: fetched once per page, handed to (or inlined into) every frame that uses them. */ export declare const SANDBOX_ASSET_SIZES: { /** `@tailwindcss/browser` v4 (minified, as inlined; ≈75 KB gzipped over the wire, once). */ readonly tailwind: '≈280 KB'; /** React + ReactDOM in the kit bundle, before the app's own components. */ readonly kit: '≈230 KB + your components'; }; /** The kit as the model reads it: one entry per component, its props from their types. */ export declare function kitDocsToModelText(docs: Pick<SandboxKitDocs, 'components'>): string; /** The rules for writing the sandbox as JSX. */ export declare function kitJsxInstructions(options?: { components?: boolean; wrapper?: boolean; }): string; /** The rule for a kit with styles but no components: the model writes HTML with those styles. */ export declare function kitHtmlInstructions(): string; /** * The script that draws the model's JSX in the frame: it holds the transpiler, compiles what the * host posts (`{ type: jsxMessage, code, final }`), runs it in a scope with the kit components and * React's hooks, and renders `App` into `#agora-sandbox-root`. A partial program is drawn only once * it closes into code that parses and renders; until then — and whenever a later version fails — * the last good one stays on screen. Errors are reported (to the host) only for the final program. * A partial program is not tried before its JSX has begun (nothing to draw before then). */ export declare function sandboxJsxRuntime(options: { token: string; jsxMessage: string; /** Code to draw at once (a document built for a whole program). */ initial?: { code: string; final: boolean; }; }): string; //# sourceMappingURL=sandbox-kit.d.ts.map