import type { Agent, AgentDefinitionResolutionContext, DiscoveredContribution, ProviderResolver } from "../contracts.js"; import type { PermissionPolicy, TrustPolicy } from "../security.js"; /** Options for {@link resolveAgentBundle}. */ export interface ResolveAgentBundleOptions { /** File reader. Defaults to `node:fs/promises.readFile`. */ readonly readFile?: (path: string) => Promise; /** Workspace root for the repo-level project prompt (`AGENTS.md`) and repo contributions. */ readonly workspaceRoot?: string; /** Repo-level contributions from {@link discoverContributions}. */ readonly repoContributions?: readonly DiscoveredContribution[]; /** Host registries (models, providers, context providers). */ readonly registries?: AgentDefinitionResolutionContext["registries"]; /** Provider resolver override. */ readonly providerSource?: ProviderResolver; /** Tool scope override. */ readonly tools?: AgentDefinitionResolutionContext["tools"]; /** Skill registry override. */ readonly skillsRegistry?: AgentDefinitionResolutionContext["skillsRegistry"]; /** Migration-only: omitted `tools`/`skills` activate every in-scope tool/skill. Defaults to fail-closed. */ readonly activateAllCapabilities?: AgentDefinitionResolutionContext["activateAllCapabilities"]; /** Final config overrides applied after the bundle is resolved. */ readonly overrides?: AgentDefinitionResolutionContext["overrides"]; /** Trust policy gating the app-config root (`SYSTEM.md`) and workspace root (`AGENTS.md`) independently. */ readonly trust?: TrustPolicy; /** Permission policy asserting each prompt-file read. */ readonly permission?: PermissionPolicy; /** Scope inclusion flags. All sources default to `true`. */ readonly include?: AgentBundleScopeFlags; } /** Which scopes contribute to a {@link resolveAgentBundle} call. */ export interface AgentBundleScopeFlags { readonly systemPrompt?: boolean; readonly agentPrompt?: boolean; readonly repoPrompt?: boolean; readonly globalSkills?: boolean; readonly agentSkills?: boolean; readonly repoSkills?: boolean; readonly globalTools?: boolean; readonly agentTools?: boolean; readonly repoTools?: boolean; } /** Lightweight envelope describing an app-config agent bundle discovered on disk. */ export interface AgentBundle { /** Agent name (from the containing directory or AGENT.md frontmatter, validated later). */ readonly name: string; /** Absolute path to the per-agent `AGENT.md` file. */ readonly path: string; /** Root directory that was scanned. */ readonly configRoot: string; /** Path to the app-global `SYSTEM.md` prompt, if present. */ readonly systemPromptPath?: string; /** Paths to global skills under `/agents/skills/`. */ readonly globalSkills: readonly string[]; /** Paths to global tools under `/agents/tools/`. */ readonly globalTools: readonly string[]; /** Paths to agent-specific skills under `/skills/`. */ readonly agentSkills: readonly string[]; /** Paths to agent-specific tools under `/tools/`. */ readonly agentTools: readonly string[]; } /** Options for {@link discoverAgentBundles}. */ export interface DiscoverAgentBundlesOptions { /** App configuration root. Scans `/agents/`. */ readonly configRoot: string; readonly trust?: TrustPolicy; readonly permission?: PermissionPolicy; readonly signal?: AbortSignal; } /** Discover app-config agent bundles under `/agents/`. * * Returns one {@link AgentBundle} per subdirectory containing an `AGENT.md` file. * Also collects paths to the app-global `SYSTEM.md`, global skills/tools, and * per-agent skills/tools. No file content is parsed here; resolution happens in * {@link resolveAgentBundle}. Trust/permission policies apply to `configRoot` * and its subdirectories; symlinks escaping `configRoot/agents` are excluded. */ export declare function discoverAgentBundles(options: DiscoverAgentBundlesOptions): Promise; /** Resolve a discovered {@link AgentBundle} into a runnable {@link Agent}. * * Builds union tool/skill registries across the included scopes (global, * agent-specific, and repo-level). Duplicate names across included scopes throw * rather than override. System prompts append in fixed order * `SYSTEM.md` → `AGENT.md` → `AGENTS.md` when enabled, before delegating to * {@link resolveAgentDefinition}. No `import()` is performed; descriptor-only * repo tools throw if executed. * * The caller controls scope by which registries and flags it passes. Missing * dependencies fail closed at resolution time. Each prompt file is read at * most once per call; resolution is one-shot, so no cross-call cache is kept * (ponytail: add memoization only if a host resolves the same bundle repeatedly). */ export declare function resolveAgentBundle(bundle: AgentBundle, options: ResolveAgentBundleOptions): Promise;