import type { RuleStore } from "../corpus/store.ts"; import { type AgentEvent, type TraceStep } from "./events.ts"; import type { Profile } from "./profile.ts"; import { type ReferenceOptions } from "./references.ts"; import { type Skill } from "./skills.ts"; import { type RuleTool } from "./tools.ts"; import { type RetrievedRule, type Turn, type UsageTotals } from "./turn.ts"; /** * The agent, running on the AI SDK. * * This is the default runtime. It needs one model credential and nothing else: * no agent framework, no separate process, no deployment of its own. The Eve * template in `templates/` is the alternative, and both emit the same events, so * the interface cannot tell them apart. * * The AI SDK is a peer dependency. Import this module only if you use it. */ export type AskInput = { question: string; history?: Turn[]; /** Rules an earlier stage already found, so the agent need not search again. */ rules?: RetrievedRule[]; }; export type RulesAgentOptions = { store: RuleStore; profile: Profile; /** * The model, as a plain "provider/model" string or an AI SDK model object. * * A string routes through the AI SDK's gateway, which is what lets a fork * change provider by changing one environment variable. Nothing in this * project requires a particular provider. */ model: string | LanguageModelLike; /** * Provider-specific settings, passed to the AI SDK untouched. * * There is no portable way to ask for a reasoning effort, a thinking budget, * or a safety setting: every provider spells them differently and respells * them between model versions. So this project does not invent a name for * them and translate. It hands yours through and takes no position. * * An earlier version did try, mapping a `reasoning: "low"` option onto one * provider's thinking field. It was wrong within a model generation, and * every request failed with a message about a field this project chose. * * providerOptions: { anthropic: { thinking: { type: "adaptive" } } } * * Read your provider's AI SDK page for the shape it wants. */ providerOptions?: Record>; /** * A ceiling on the model calls one turn may make. * * **Unset by default, which means no ceiling.** A turn ends when the model * stops calling tools and writes its answer. See `NO_STEP_CAP` in * `@rulekitai/rulekit/agent/turn` for why this project sets none: a cap is a cost * control, and cost is the fork's decision, not this project's. * * Set it when you pay per token. A capped turn hands the reader whatever was * written when the ceiling hit, which can be half a sentence. */ stepCap?: number | null; /** Instructions override. Defaults to buildInstructions(profile) plus the skills. */ instructions?: string; /** Extra tools, merged with the corpus tools. */ extraTools?: RuleTool[]; /** * Sites outside the corpus that this agent may read when the corpus misses. * * **Off unless you set it, and rulekit ships no sites.** Setting it grants * this agent outbound network access, so it is an option on the runtime rather * than a field in a corpus: copying a corpus must never grant a server a * capability it did not ask for. * * Pass the sites here rather than building the tools yourself and passing them * through `extraTools`. This option also adds the instruction block that makes * the model label an outside claim as one, and the tools without that block * produce answers that cite somebody's website as though it were the rules. * * You are responsible for each site's terms of use. */ references?: ReferenceOptions; /** * Procedures to inline, REPLACING the ones that ship with this package. * * Prefer `extraSkills`, which adds to them. Setting this drops the card and * rulings procedures unless you spread `builtinSkills()` back in, and dropping * them is silent. */ skills?: Skill[]; /** * Procedures of your own, added to the ones that ship. * * **A tool is not enough on its own.** The instructions tell the model to * decline whole subjects, such as shops, events, prices, and real people. A * tool whose subject is on that list is never called, no error appears, and * the model simply declines. A procedure is how you tell the model that this * assistant now answers that subject. * * Set `requiresTool` on the procedure, and it is dropped when its tool is * absent. */ extraSkills?: Skill[]; }; /** The shape of an AI SDK model object, without importing the type. */ type LanguageModelLike = { readonly modelId: string; }; /** What one completed turn produced. */ export type AgentAnswer = { text: string; complete: boolean; steps: TraceStep[]; usage: UsageTotals | null; model: string | null; latencyMs: number; }; /** * The answer a finished turn produced, or the reason there is none. * * A turn that failed before writing a word is a failure, not an empty answer. * The stream reports the error and STILL ends with a terminal event, because * that event is the only one carrying what the failed steps cost. Returning it * would turn a provider outage into a silent blank, and a caller grading * answers would score the blank as clean: it cites nothing and quotes nothing, * so every check on the content passes. * * Partial text survives. A model that wrote something and then failed returns * what it wrote, marked incomplete, because that is worth more than nothing. */ export declare function resolveAnswer(done: AgentAnswer | null, error: string | null): AgentAnswer; /** * Build the agent for one corpus. * * The returned object exposes two shapes of the same turn. `stream` yields * events as they happen, and `ask` waits for the whole answer. `ask` is written * in terms of `stream` on purpose: two implementations of one loop is how a * streaming path and a non-streaming path come to disagree about what an answer * is. */ export declare function createRulesAgent(options: RulesAgentOptions): { stream: (input: AskInput) => AsyncGenerator; ask: (input: AskInput) => Promise; toNdjsonStream: (input: AskInput) => ReadableStream; tools: () => Promise; instructions: () => Promise; }; export type RulesAgent = ReturnType; export {}; //# sourceMappingURL=runtime.d.ts.map