import type { AIClient, AIMessage } from '../types.js'; import { type ToolAccessCheck } from './tool-scope.js'; import { type AssistantChatResult } from './assistant-chat.js'; import type { GroundingSources } from '../utils/index.js'; import type { ToolAttachment, UnattendedRunRef } from '../tool-registry/types.js'; import type { ToolCallRecord } from '../tool-registry/call-recorder.js'; import { type ToolFront } from './tool-budget.js'; /** Lookups a registry conversation may take before it answers from what it has (operato-twin's assistant takes 16 too). */ export declare const REGISTRY_MAX_ITERATIONS = 16; export interface RegistryAssistantInput { /** Provider client. Must implement `chatWithTools`. */ client: AIClient; /** The conversation so far, newest last. The caller owns history and truncation. */ messages: AIMessage[]; /** Who the assistant is and what this surface is. The host owns this prose. */ systemPrompt: string; /** * Categories this conversation may use. **Omitting it allows nothing** — the same as an empty * list, a plain conversation with no tools (A1, 2026-09-17). It used to mean every registered * category, which is how a Board-creating tool reached any conversation. */ toolCategories?: string[]; /** * What goes in front when the scope is larger than one call carries (ADR-0061 decision 9) - the screen's records, * the tools this conversation used. The rest the model opens with `openTools`. Without it, only `openTools` is in * front of a scope that does not fit. */ front?: ToolFront; /** * Answers whether the caller holds a tool's declared privilege. Without it, every tool that * declares a privilege stays closed. The host builds it from the request — this package does * not know auth. */ toolAccess?: ToolAccessCheck; /** Passed to tools as `context.host`. Client-supplied — never used for authorization. */ hostContext?: any; /** * Which conversation this is — `{ kind, target }` from the registered mode (ADR-0061 decision 3). * * Tools see it as `context.mode`. It is the server's value, resolved from the registry before the * turn runs, so a tool that behaves differently in two conversations reads it here and not from * `host`, which the client fills. */ mode?: { kind: string; target?: string; }; /** Caller's koa state (domain, user, tx). Tools that read the database need it. */ state: any; model?: string; temperature?: number; maxTokens?: number; /** Make the model call a tool before it may answer. For surfaces that report live state. */ requireToolOnFirstTurn?: boolean; /** * The request's translator — the stop notice is then in the reader's language, and tools write what a person * reads with it (`context.t`). Without it tools get `defaultValueTranslate`: the English default values. */ t?: (key: string, params?: Record) => string; /** * The files sent with this turn, after the caller's server checked them — stored with this conversation, the * conversation the caller's to write, the mode's policy met (ADR-0061, 2026-10-16 decision 2). Tools see them as * `context.attachments`. Never built from the client's request: what a client puts in `hostContext` stays there. */ attachments?: ToolAttachment[]; /** Texts the answer is allowed to draw identifiers from, besides the tool results. */ groundingSources?: Omit; /** Stops the loop and the provider request - an unattended run's time limit. */ signal?: AbortSignal; /** Lookups before the answer; `REGISTRY_MAX_ITERATIONS` when absent. */ maxIterations?: number; /** At the lookup limit, one more call without tools to answer from what was read. On when absent. */ salvageOnMaxIterations?: boolean; /** * Each call as the recorders get it (`digestOf`, never its raw values) - an unattended run lists the reads its draft * rested on from the same digest the audit keeps, so the two cannot describe one call differently. */ onToolCall?: (record: ToolCallRecord) => void; /** Where a tool's progress goes while the person waits (ToolCallContext.progress). */ progress?: (text: string) => void; /** Set for an unattended run; tools and recorders see it as `context.run`. */ run?: UnattendedRunRef; /** The stored conversation of this turn; tools see it as `context.conversation`. The caller's value, never the client's. */ conversation?: { id: string; }; } export interface RegistryAssistantResult extends AssistantChatResult { /** Tool names actually offered to the model this turn. The caller may log or return it. */ offeredTools: string[]; /** Tools of the scope the model could have opened and did not (ADR-0061 decision 9) - with `offeredTools`, all it may use. */ openableTools: string[]; } /** * Run one turn of a conversation whose only tools come from the registry. * * Throws when the client cannot use tools at all — a surface built on registered tools that * silently ran without them would answer from nothing and look like it had checked. */ export declare function registryAssistantChat(input: RegistryAssistantInput): Promise;