export { D as DavepiClient, a as DavepiClientOptions, b as DavepiError, L as ListParams, c as ListResponse, d as createDavepiClient } from './client-BLdA4Ob7.js'; export { AuthContextValue, AuthGuard, AuthGuardProps, AuthProvider, AuthProviderProps, AuthUser, LoginPage, LoginPageProps, RegisterInput, SessionTokens, UserMenu, UserMenuProps, useAuth, useOptionalAuth } from './auth/index.js'; export { DescribeProvider, DescribeProviderProps, MutationOptions, UseDescribeData, UseResourceListOptions, UseResourceOptions, resourcePath, useAnonymousDescribe, useCreateResource, useDeleteResource, useDescribe, useResource, useResourceList, useUpdateResource } from './hooks/index.js'; export { ConfigProvider, ConfigProviderProps, DavepiConfigContextValue, useDavepiConfig, useResourceConfig } from './config/index.js'; export { AclOp, AclResult, useFieldAcl, useResourcePerm } from './acl/index.js'; import 'react'; import '@tanstack/react-query'; import '@davepi/ui-core'; import 'react/jsx-runtime'; /** * Standalone client for a `@davepi/agent` HTTP channel. * * The agent is a separate process from the davepi backend (it connects to * davepi over MCP), so this client is intentionally decoupled from the * davepi HTTP client / AuthProvider: it takes a base URL and talks to the * agent's own `GET /health` and `POST /chat` (SSE) endpoints. Chat runs as * the agent's configured identity (service mode) — the browser sends no * bearer — so nothing here reads the admin session. * * The agent must allow the admin's origin via `AGENT_CORS_ORIGINS`; requests * are sent with `credentials: 'include'` so per-user (cookie) mode keeps * working if the operator later switches the agent to it. */ /** Identity block returned by the agent's `GET /health`. */ interface AgentInfo { ok: boolean; agent: string; auth: string; /** `AGENT_KEY` of the process, or `null` when unset. */ agentKey: string | null; /** Human-friendly name (the key title-cased, or `'Assistant'`). */ name: string; /** True when the agent fronts a team it delegates to. */ isTeam: boolean; /** Roster of specialists the leader delegates to (empty for a solo agent). */ team: Array<{ key: string; name: string; }>; } /** A table payload emitted by the agent's `render_table` tool. */ interface AgentTablePayload { type: 'table'; title: string | null; columns: Array<{ key: string; label: string; }>; rows: Array>; } /** A chart payload emitted by the agent's `render_chart` tool. */ interface AgentChartPayload { type: 'chart'; title: string | null; vegaLiteSpec: unknown; } type AgentRenderPayload = AgentTablePayload | AgentChartPayload; /** * Normalised chat event surfaced to the UI. Mirrors the orchestrator's SSE * events (`token` / `tool_call` / `tool_result` / `render` / `final`) plus * the HTTP channel's terminal `done` / `error`. */ type AgentChatEvent = { type: 'token'; text: string; } | { type: 'tool_call'; name: string; args?: unknown; } | { type: 'tool_result'; name: string; result?: unknown; } | { type: 'render'; payload: AgentRenderPayload; } | { type: 'final'; text: string; history?: ChatMessage[]; } | { type: 'done'; } | { type: 'error'; code: string; message: string; linkUrl?: string; }; /** A single turn in the conversation, round-tripped to the agent as history. */ interface ChatMessage { role: 'user' | 'assistant'; content: string; } /** Lifecycle state of a persisted conversation. */ type ConversationStatus = 'open' | 'resolved' | 'abandoned' | (string & {}); /** * A conversation as listed by `GET /conversations` — metadata only, no * transcript. Newest first, keyed by the stable `conversationId` the client * mints and sends on `POST /chat`. */ interface ConversationSummary { conversationId: string; channelUserId: string | null; status: ConversationStatus; /** ISO timestamp of the most recent turn. */ lastTurnAt: string; snapshotAt?: string | null; /** Short preview of the conversation (e.g. the opening prompt). */ preview: string | null; } /** A full conversation transcript from `GET /conversations/:id`, ready to resume. */ interface ConversationDetail { conversationId: string; status: ConversationStatus; lastTurnAt: string; /** Shaped exactly as `POST /chat`'s `history` — load straight into the UI. */ history: ChatMessage[]; } /** * Probe the agent's `GET /health`. Resolves to the parsed {@link AgentInfo} * when the agent is reachable and reports an agent, or `null` otherwise (no * agent configured, network error, non-2xx, or a non-agent response). Never * throws — a missing agent is a normal state, not an error. */ declare function probeAgent(baseUrl: string, signal?: AbortSignal): Promise; /** * Stream a chat turn from the agent's `POST /chat` (Server-Sent Events). * * Each SSE frame is parsed and forwarded to `onEvent`. Resolves when the * stream ends (a `done` event or the connection closing); rejects only on a * transport-level failure before any event arrived. Errors the agent reports * mid-stream arrive as an `{ type: 'error' }` event rather than a rejection, * matching the HTTP channel's error shaping. * * Pass an `AbortSignal` to cancel an in-flight turn (e.g. component unmount). */ declare function streamAgentChat(baseUrl: string, params: { message: string; history?: ChatMessage[]; /** * Stable id for this conversation. Reuse across turns to append to one * persisted transcript (service mode); omit → nothing persisted. In * per-user mode the agent keys on its own cookie and ignores this. */ conversationId?: string; signal?: AbortSignal; }, onEvent: (event: AgentChatEvent) => void): Promise; /** * Outcome of {@link listConversations}. `conversations` is the listed rows on * success, else `null`. `unsupported` is `true` only when the route is * *definitively* absent (HTTP 404) — an agent older than 0.5.0 — so callers can * hide the sidebar for good. Any other failure (network error, 5xx, malformed * body) leaves `unsupported: false`, marking it a transient miss worth * retrying rather than a permanent capability gap. */ interface ConversationListResult { conversations: ConversationSummary[] | null; unsupported: boolean; } /** * List persisted conversations from the agent's `GET /conversations`, newest * first. Never throws — returns a {@link ConversationListResult} that * distinguishes a definitively-absent route (404, `unsupported: true`) from a * transient miss (`conversations: null, unsupported: false`), so the sidebar * can hide permanently for old agents yet recover from a passing blip. Rows are * sanitised, so callers can render them without extra guards. */ declare function listConversations(baseUrl: string, signal?: AbortSignal): Promise; /** * Fetch a single conversation's full transcript from * `GET /conversations/:conversationId` to resume it. The returned `history` * is shaped exactly as `POST /chat`'s `history`, so it loads straight into the * chat transcript. Throws on a non-2xx (e.g. 404 when the id is unknown) so a * failed click-to-resume can surface an error to the user. */ declare function getConversation(baseUrl: string, conversationId: string, signal?: AbortSignal): Promise; /** * Resolved agent state for the admin shell. * * - `configured` — the app declares an agent (`config.agent.url`) and it is * not disabled. * - `available` — the configured agent answered `GET /health` as a davepi * agent. Only when this is `true` should the UI swap the dashboard for a * chat panel; otherwise fall back to the plain dashboard. * - `info` — the agent's identity payload (name / team roster) once probed. */ interface AgentState { configured: boolean; available: boolean; url: string | null; /** Effective chat heading: `config.agent.title` ?? `info.name`. */ title: string | null; placeholder: string; info: AgentInfo | null; isPending: boolean; } /** * Detect whether this admin fronts a `@davepi/agent` and, if so, whether it * is reachable right now. Reads `config.agent` and probes the agent's * `/health`. The probe result is cached for the session and retried on * reconnect, so a chat panel appears the moment the agent process comes up * without a manual refresh — but a down agent doesn't wedge the dashboard. * * @example * const agent = useAgent(); * if (agent.available) return ; * return ; */ declare function useAgent(): AgentState; export { type AgentChartPayload, type AgentChatEvent, type AgentInfo, type AgentRenderPayload, type AgentState, type AgentTablePayload, type ChatMessage, type ConversationDetail, type ConversationListResult, type ConversationStatus, type ConversationSummary, getConversation, listConversations, probeAgent, streamAgentChat, useAgent };