import type { AgentEffect } from './effects.js'; import type { AgentSessionStorage } from './factory.js'; export type EffectHandlerHost = { send(msg: unknown): void; /** Wraps an agentConnect msg into an app-Msg. */ wrapAgentConnect(m: unknown): unknown; /** * Wraps an agentAttention msg into an app-Msg. Optional; when * undefined, the `AgentAttentionFlashTimeout` effect no-ops on * fire and the attention spotlight stays set until the next * dispatch replaces it. Hosts that wire the attention slice * provide this; hosts that don't can leave it unset. */ wrapAgentAttention?(m: unknown): unknown; /** Called for AgentForwardMsg — the payload is re-dispatched via send. */ forward(payload: unknown): void; /** fetch for HTTP effects; override in tests. */ fetch?: typeof fetch; /** Called before opening WS / on WS lifecycle events. */ openWs(token: string, wsUrl: string): void; closeWs(): void; /** * Optional storage adapter. When set, `AgentSessionPersist` writes * to it and `AgentSessionClear` clears it; the host doesn't need * to handle these effects itself. When `null` or `undefined`, the * effects no-op here and host code (if any) handles them in the * outer effect router. The factory passes * `defaultSessionStorage()` by default, so the framework is * refresh-survival-ready out of the box. */ sessionStorage?: AgentSessionStorage | null; /** * Base path for agent HTTP endpoints. Default: `'/agent'` (matches * the canonical paths in `@llui/vite-plugin`'s dev middleware and * `@llui/agent/server/http/router.ts`). * * Override when the consumer ships `@cloudflare/vite-plugin` in * dev — that plugin routes every non-`/cdn-cgi/*` path to the * worker, shadowing canonical `/agent/*` URLs. The vite-plugin * registers a parallel handler at `/cdn-cgi/agent/*`; pass * `agentBasePath: '/cdn-cgi/agent'` here so the client hits that. * * Production deployments without cloudflare-vite leave this * unset; the agent server's router serves the canonical paths. */ agentBasePath?: string; }; /** * Top-level dispatcher. The switch is intentionally thin — each * `case` delegates to a per-effect function below. Splitting was * motivated by the previous 150-line monolith mixing HTTP, WS, and * browser-only side effects in one switch; per-effect handlers are * directly unit-testable and the dispatcher reads as a flat catalogue * of supported effect types. */ export declare function createEffectHandler(host: EffectHandlerHost): (effect: AgentEffect) => Promise; //# sourceMappingURL=effect-handler.d.ts.map