/** * Design Studio detection + injection middleware. * * The system prompt is built ONCE per session (boot / project-switch), so a * system-prompt contributor cannot react to "the model just started building a * UI" mid-session. Instead, detection and injection ride the per-turn pipelines: * * - userInput middleware → detect UI intent in the user's message * - toolCall middleware → detect a frontend file being written * (both set `ctx.meta.designStudio`) * - request middleware → on every turn, read `ctx.meta.designStudio` and * append an ephemeral block to `req.system`: the kit menu (until a kit is * chosen) or a one-line adherence reminder (once chosen). * * Keeping the heavy kit body out of this path — the model loads it on demand via * the `design` tool — is what keeps per-turn token cost low. */ import type { AgentPipelines, ToolCallPipelinePayload, UserInputPayload } from '../core/agent-types.js'; import type { Context } from '../core/context.js'; import type { Middleware } from '../kernel/pipeline.js'; import type { DesignKitLoader, DesignStack, DesignStudioState } from '../types/design-kit.js'; import type { Request } from '../types/provider.js'; export declare function getDesignState(ctx: { meta: Record; }): DesignStudioState | undefined; /** Mark Design Studio active and merge in detected signals/stack. */ export declare function activateDesign(ctx: { meta: Record; }, signals: string[], stack?: DesignStack): DesignStudioState; /** Record the kit the model/user committed to. */ export declare function setActiveKit(ctx: { meta: Record; }, kitId: string, stack?: DesignStack, overrides?: Record | undefined): void; /** Merge color/token overrides into the live state (used by `design set`). */ export declare function setDesignOverrides(ctx: { meta: Record; }, overrides: Record): void; /** Clear the active kit (e.g. `/design off`), leaving detection state intact. */ export declare function clearActiveKit(ctx: { meta: Record; }): void; /** * Inspect user text for UI/design intent. Returns the strongest stack hint and * the matched signals, or `null` when nothing UI-ish was found. */ export declare function detectFrontendIntent(text: string): { stack?: DesignStack; signals: string[]; } | null; /** Detect whether a written/edited file path is a frontend file. */ export declare function detectFrontendFile(filePath: string): { stack?: DesignStack; } | null; /** userInput middleware: detect UI intent from the user's message. */ export declare function makeDesignDetectUserInputMiddleware(): Middleware; /** toolCall middleware: detect frontend file writes/edits. */ export declare function makeDesignDetectToolCallMiddleware(): Middleware; /** * toolCall middleware: after a frontend file is written/edited AND a kit is * pinned, scan the file for off-palette colors and append a non-blocking * warning to the tool result. This makes adherence PASSIVE — the model is * nudged toward kit tokens the moment it drifts, without anyone running * `design verify` by hand. Best-effort: any failure leaves the result untouched. */ export declare function makeDesignVerifyToolCallMiddleware(): Middleware; /** * request middleware: per-turn, inject the kit menu (until a kit is chosen) or a * compact adherence reminder (once chosen). No-op when Design Studio is inactive. * * Closes over the live `Context` because the `request` pipeline payload is just * the `Request` — it carries no ctx. `req.system` shares the array reference * with `ctx.systemPrompt`, so we return a NEW array rather than mutating it. */ export declare function makeDesignStudioRequestMiddleware(deps: { ctx: Context; loader: DesignKitLoader; enabled?: () => boolean; }): Middleware; /** * Install the Design Studio per-turn middleware onto an agent's pipelines. * Shared by every host (CLI/TUI + both WebUI servers) so auto-detection behaves * identically everywhere. All three are PREPENDED: * - detection runs first so a short-circuiting middleware can't suppress it; * - the request injector must sit ahead of `ModelRuntimeSettings`, which does * not call `next` and would otherwise end the chain before us. * * The `design` tool and `/design` command are wired separately (builtin pack + * slash registry); this only installs the activation behavior. */ export declare function installDesignStudioMiddleware(deps: { pipelines: AgentPipelines; ctx: Context; /** When false, nothing is installed (tool + /design stay manual). */ enabled?: boolean | undefined; }): void; //# sourceMappingURL=design-detect.d.ts.map