/** * Per-runtime registry for deterministic user-intent routes owned by plugins. * Plugins declare the natural-language boundary, eligible action names, * capability tags, and contexts; the message pipeline applies the normal * role, context, connector, and validation gates before promoting a simple * Stage-1 answer to the planner. */ import type { AgentContext } from "../types/contexts.js"; import type { Memory } from "../types/memory.js"; import type { IAgentRuntime } from "../types/runtime.js"; export interface DirectActionRoutingRule { /** Stable diagnostic identifier owned by the registering plugin. */ readonly id: string; /** Runtime action names that can satisfy this intent. */ readonly actionNames: readonly string[]; /** * Stage-1 candidates that this rule may replace after its action has passed * the normal execution gates. This is intentionally opt-in: an owner route * must not rewrite an unrelated, already-tool-bearing plan. */ readonly replacesActionNames?: readonly string[]; /** * Every selected action must declare all of these tags. This prevents a * same-named or context-adjacent action from masquerading as the required * read/write capability. */ readonly requiredActionTags: readonly string[]; /** Contexts to add when the route is selected. */ readonly contexts: readonly AgentContext[]; /** * Optional, stricter ownership of the complete original request. Only an * admitted, unambiguous owner may replace model-derived intent scope. The * broad matches() route remains additive for other requests. Named fields are * inferred operation-scope extensions, never core or original source data. */ readonly wholeRequest?: { matches(messageText: string, message?: Memory): boolean; readonly invalidateFields: readonly string[]; /** The closed request has no visible-surface dependency. Never inferred from model output. */ readonly inputScope?: "domain-only"; }; /** * Fail-closed reply used when this exact intent is owned by the rule but no * eligible action is available for the current actor/turn. This is opt-in: * rules without an unavailable contract preserve their existing Stage-1 * fallback behavior. */ readonly unavailable?: { /** Stable machine-readable identifier, also included in diagnostics. */ readonly code: string; /** Honest user-facing reply; must not claim that an action ran. */ readonly reply: string; }; /** * True only for a current-turn request owned by this route. The optional * message exposes typed control metadata for routing, never effect authority. */ matches(messageText: string, message?: Memory): boolean; } export declare function registerDirectActionRoutingRule(runtime: IAgentRuntime, rule: DirectActionRoutingRule): void; export declare function getDirectActionRoutingRules(runtime: IAgentRuntime): readonly DirectActionRoutingRule[]; export declare function __resetDirectActionRoutingRulesForTests(runtime: IAgentRuntime): void;