crp.frontend¶
Auto-generated reference for the crp.frontend subpackage.
frontend¶
crp.frontend ¶
Frontend components for the CRP Agent SDK.
agent_console_html(*, title='CRP Agent Console', stream_url='/v1/tel/stream', chat_url='/v1/chat/completions', session_id=None) ¶
Return a self-contained HTML/JS agent console.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title | str | Page title. | 'CRP Agent Console' |
stream_url | str | SSE endpoint for the transparency stream. | '/v1/tel/stream' |
chat_url | str | HTTP endpoint to POST chat requests. | '/v1/chat/completions' |
session_id | str | None | Optional fixed session id. | None |
Returns:
| Type | Description |
|---|---|
str | A complete HTML document as a string. |
mount_fastapi(app, *, path='/crp/console', stream_path='/v1/tel/stream', cors_origins=None) ¶
Mount the agent console on a FastAPI app at path.
If crp/frontend/static/index.html exists (the built Vite bundle), it is served as the console and the static/assets directory is mounted under path so relative asset links resolve. Otherwise the self-contained inline HTML console is served as a fallback.
Also mounts the TEL transparency stream at stream_path so the console's default stream_url resolves to a live endpoint.
CORS: browsers refuse cross-origin reads (including SSE) unless the backend allows the console's origin. The CDN-hosted console at https://console.crprotocol.io talks directly to a user's local backend, so that origin is allowed by default; pass cors_origins to override or extend (e.g. for a white-label domain).
frontend.console¶
crp.frontend.console ¶
Pre-built frontend components for the CRP Agent SDK.
Provides a drop-in HTML chat console with depth selection, a live AG-UI-compatible event panel, a readable chain-of-thought narrative, governance cards, and a visual provenance chain. This lets developers ship a governed agent UI without building their own streaming components.
agent_console_html(*, title='CRP Agent Console', stream_url='/v1/tel/stream', chat_url='/v1/chat/completions', session_id=None) ¶
Return a self-contained HTML/JS agent console.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title | str | Page title. | 'CRP Agent Console' |
stream_url | str | SSE endpoint for the transparency stream. | '/v1/tel/stream' |
chat_url | str | HTTP endpoint to POST chat requests. | '/v1/chat/completions' |
session_id | str | None | Optional fixed session id. | None |
Returns:
| Type | Description |
|---|---|
str | A complete HTML document as a string. |
mount_fastapi(app, *, path='/crp/console', stream_path='/v1/tel/stream', cors_origins=None) ¶
Mount the agent console on a FastAPI app at path.
If crp/frontend/static/index.html exists (the built Vite bundle), it is served as the console and the static/assets directory is mounted under path so relative asset links resolve. Otherwise the self-contained inline HTML console is served as a fallback.
Also mounts the TEL transparency stream at stream_path so the console's default stream_url resolves to a live endpoint.
CORS: browsers refuse cross-origin reads (including SSE) unless the backend allows the console's origin. The CDN-hosted console at https://console.crprotocol.io talks directly to a user's local backend, so that origin is allowed by default; pass cors_origins to override or extend (e.g. for a white-label domain).