/** * agent-types.ts — Unified agent type registry. * * Merges embedded default agents with user-defined agents from .pi/agents/*.md. * User agents override defaults with the same name. Disabled agents are kept but excluded from spawning. */ import { getReadOnlyMemoryToolNames } from "./readonly-helpers.js"; import type { AgentConfig } from "./types.js"; /** * Resolve which tools are allowed based on partition memberships. * Pure function — no side effects, same input = same output. * * - Early exit: no partitions → all of config's built-in tools (no filtering) * - Early exit: no partitionMembership on config → feature disabled, all tools * - Partitions specified → union of all tool names from matching partition memberships * - Empty partitionMembership ({}) → empty set = isolated */ export declare function filterByPartitions(config: AgentConfig, partitions?: readonly string[]): string[]; /** * All known built-in tool names. * * Subset of the official opencode/pi tool list. `find` and `ls` were * removed in audit B8 — they are Claude Code carry-over, not real pi * tools, and would never be invoked successfully by this extension. */ export declare const BUILTIN_TOOL_NAMES: string[]; /** * Normalize a custom agent's `builtinToolNames` array. * * Agents may declare `"*"` to mean "all built-in tools" (audit A1). This helper * expands the wildcard to a copy of {@link BUILTIN_TOOL_NAMES}, preserving any * non-wildcard entries alongside it (deduplicated via Set). The caller's input * array is never mutated — a fresh array is always returned. * * Choice: normalization is applied at read-time in this module rather than at * load-time in {@link custom-agents.ts}. Reasons: * 1. The source AgentConfig keeps the user's literal request intact, which * keeps frontmatter round-tripping honest and makes the wildcard a pure * resolution-layer concern. * 2. There is one canonical expansion site, so adding a new built-in tool * or changing wildcard semantics only requires editing this file. * 3. Default agents and absolute fallbacks use the bare `BUILTIN_TOOL_NAMES` * constant directly, bypassing this function — no risk of double expansion. * * @param names - The raw `builtinToolNames` array from an AgentConfig * @returns A fresh, normalized array; `undefined` if the input was undefined */ export declare function normalizeBuiltinToolNames(names: readonly string[] | undefined): string[] | undefined; /** * Context-mode sandbox tool names from @onlinechef/context-mode (optional dependency). * * Re-exported here from `./ctx-tool-names.ts` for back-compat — pre-existing * consumers (notably `test/e2e-chain.test.ts`) import `CTX_TOOL_NAMES` from * `./agent-types.js`. The canonical definition lives in `src/ctx-tool-names.ts`; * treat this export as a stable alias, not as the source of truth. */ export declare const CTX_TOOL_NAMES: readonly string[]; /** * Register default + user agents in the unified registry. * * Starts with {@link DEFAULT_AGENTS}, then overlays user agents. User agents with * the same name as a default override the default. Disabled agents (`enabled === false`) * are kept in the registry for UI listing but excluded from spawning. * * @param userAgents - Map of user-defined agent configs from {@link loadCustomAgents} */ export declare function registerAgents(userAgents: Map): void; /** Resolve a type name case-insensitively. Returns the canonical key or undefined. */ export declare function resolveType(name: string): string | undefined; /** Get the agent config for a type (case-insensitive). */ export declare function getAgentConfig(name: string): AgentConfig | undefined; /** Get all enabled type names (for spawning and tool descriptions). */ export declare function getAvailableTypes(): string[]; /** Get all type names including disabled (for UI listing). */ export declare function getAllTypes(): string[]; /** Get names of default agents currently in the registry. */ export declare function getDefaultAgentNames(): string[]; /** Get names of user-defined agents (non-defaults) currently in the registry. */ export declare function getUserAgentNames(): string[]; /** Check if a type is valid and enabled (case-insensitive). */ export declare function isValidType(type: string): boolean; /** * Get memory tool names (read/write/edit) not already in the provided set. */ export declare function getMemoryToolNames(existingToolNames: Set): string[]; export { getReadOnlyMemoryToolNames }; /** Get built-in tool names for a type (case-insensitive). */ export declare function getToolNamesForType(type: string): string[]; /** Effective config shape used for permission inheritance. Distinct from the full return type. */ export interface EffectiveConfig { builtinToolNames: string[]; extensions: true | string[] | false; skills: true | string[] | false; } /** * Resolve the effective configuration for an agent type. * * This is the main entry point for agent config resolution. It performs: * 1. Lookup of the agent config (custom agents override defaults) * 2. Parent permission inheritance via {@link PermissionUtils.applyParentRestrictions} * 3. Context-mode tool injection (if `useContextMode` is true and ctx module available) * 4. Partition-based tool filtering via {@link applyPartitionFilter} * * Falls back to "general-purpose" config if the type is unknown or disabled. * * @param type - Agent type name (case-insensitive) * @param parentConfig - Optional parent agent config for permission inheritance * @param partitions - Optional partition names for tool filtering * @returns Effective config with resolved tools, extensions, skills, and prompt mode */ export declare function getConfig(type: string, parentConfig?: EffectiveConfig, partitions?: readonly string[]): { displayName: string; description: string; builtinToolNames: string[]; extensions: true | string[] | false; skills: true | string[] | false; promptMode: "replace" | "append"; };