import { ActionProcedureDescriptor } from '@voltro/protocol'; import { Guards } from '@voltro/protocol'; import { QueryProcedureDescriptor } from '@voltro/protocol'; import { Schema } from 'effect'; declare const AGENT_DESCRIPTOR_BRAND: "@voltro/ai/AgentDescriptor"; /** * WHO MAY TALK TO an agent — the same three-state decision a mutation makes, * applied to BOTH synthesized routes (`.send` and `.messages`). * * The two routes used to carry a hard-coded `openAccess`, honestly worded: * "serves any session this app authenticates; defineAgent declares no per-agent * guard vocabulary today". That sentence made every agent a free model-spend * surface for anyone who could open the socket — anonymous included, since the * routes never looked at the subject — and it made the boot gate's carve-out * ("synthesized routes are not the app's to guard") true only because there * was nothing on the descriptor to read. There is now, so the gate judges an * agent like a workflow: one that declares neither refuses the boot under * `security.defaultDeny`. */ export declare interface AgentAccessOptions { /** A caller must hold a scope (`{ scope: 'support:chat' }`), or a * relationship to the thread (`{ action, resourceType, resource: (i) => * i.threadId }`). Checked on every `send` and on every `messages` delivery. */ readonly guards?: Guards; /** Anyone who can open the socket may talk to it — and WHY. A reason, not a * boolean. Note what it does NOT buy: an anonymous caller owns no thread, so * thread privacy (below) is only enforced for authenticated subjects. */ readonly openAccess?: string; } export declare interface AgentDescriptor { readonly _brand: typeof AGENT_DESCRIPTOR_BRAND; /** Wire id → rpc tags `.send` / `.messages`. */ readonly name: string; /** Input schema (default `{ prompt: string }`). The send route's wire input * extends this with `{ threadId, order }`. */ readonly input?: S; /** WHO MAY TALK TO IT — see {@link AgentAccessOptions}. */ readonly guards?: Guards; readonly openAccess?: string; } /** The decoded input an agent's executor sees, derived from its schema. */ export declare type AgentInput = Schema.Schema.Type; /** The agent's input schema (default `{ prompt: string }`). */ export declare const agentInputSchema: (desc: AnyAgentDescriptor) => Schema.Schema.Any; export declare const agentMessageSchema: Schema.Struct<{ id: typeof Schema.String; threadId: typeof Schema.String; role: typeof Schema.String; content: typeof Schema.String; streaming: typeof Schema.Boolean; order: typeof Schema.Number; stepOrder: typeof Schema.Number; parts: Schema.Array$>; }>; /** * The two browser-safe route descriptors synthesized for an agent. The SAME * source the runtime synthesis (`agentSynthesis.ts`) and codegen both consume, * so "what the server serves" and "what the client is typed for" can't drift. */ export declare const agentRouteDescriptors: (desc: AnyAgentDescriptor) => { send: ActionProcedureDescriptor<`${string}.send`, Schema.Schema.Any, Schema.Struct<{ text: typeof Schema.String; }>, typeof AgentThreadAccessDenied>; messages: QueryProcedureDescriptor<`${string}.messages`, Schema.Struct<{ threadId: typeof Schema.String; }>, Schema.Array$>; }>>, typeof AgentThreadAccessDenied>; }; /** The one field both synthesized routes share on the wire — what a * resource-scoped agent guard may read its id from. */ export declare interface AgentRouteInput { readonly threadId: string; } /** * A thread belongs to the subject that opened it. Raised by `.send` and * `.messages` when an authenticated caller addresses a thread another * subject created — the isolation the old `openAccess` sentence said it could * not claim. In the routes' error union, so it reaches the client typed. */ export declare class AgentThreadAccessDenied extends AgentThreadAccessDenied_base { get message(): string; } declare const AgentThreadAccessDenied_base: Schema.TaggedErrorClass; } & { threadId: typeof Schema.String; }>; /** A descriptor of any input shape — for the type-erased runtime helpers. */ export declare type AnyAgentDescriptor = AgentDescriptor; declare const DEFAULT_INPUT: Schema.Struct<{ prompt: typeof Schema.String; }>; /** Default input schema type when `input` is omitted (`{ prompt: string }`). */ export declare type DefaultAgentInputSchema = typeof DEFAULT_INPUT; /** * Declare an agent's browser-safe wire contract: its `name` and `input` * schema. The decoded input type is inferred from the schema (like * `defineQuery`). Behaviour (system prompt, tools, model + key, maxSteps) lives * in the paired `*.agent.server.tsx` via `defineAgentExecutor`. * * ```ts * // support.agent.tsx (browser-safe descriptor) * export const support = defineAgent({ * name: 'support', * input: Schema.Struct({ prompt: Schema.String, locale: Schema.optional(Schema.String) }), * }) * ``` */ export declare const defineAgent: (config: { readonly name: string; readonly input?: S; } & AgentAccessOptions) => AgentDescriptor; /** Discovery predicate for `*.agent.tsx` exports. */ export declare const isAgentDescriptor: (x: unknown) => x is AnyAgentDescriptor; export { }