/**
 * Compatibility shim for legacy extensions importing the package root of
 * `@oh-my-pi/pi-coding-agent` (or one of its aliased scopes like
 * `@earendil-works/pi-coding-agent` or `@mariozechner/pi-coding-agent`).
 *
 * The coding-agent package's own barrel (`./src/index.ts`) cannot be listed
 * as a `bun --compile` extra entrypoint alongside the CLI entry without
 * silently breaking the main binary's startup (see issue #1474 follow-up).
 * Routing legacy plugin imports through this sibling shim sidesteps that
 * conflict: bun bundles a distinct entry whose path differs from the CLI
 * entry, while still re-exporting the canonical surface so plugins observe
 * the same module identity as a direct `@oh-my-pi/pi-coding-agent` import.
 */
import type { TSchema } from "@oh-my-pi/pi-ai";
import type { PromptTemplate } from "../config/prompt-templates.js";
import { Settings } from "../config/settings.js";
import type { CreateAgentSessionOptions, CreateAgentSessionResult, LoadExtensionsResult } from "../sdk.js";
import { EventBus } from "../utils/event-bus.js";
import type { ExtensionFactory, ToolDefinition } from "./extensions/types.js";
import type { Skill } from "./skills.js";
export interface BashSpawnContext {
    command: string;
    cwd: string;
    env: NodeJS.ProcessEnv;
}
export type BashSpawnHook = (context: BashSpawnContext) => BashSpawnContext;
export interface BashOperations {
    exec: (command: string, cwd: string, options: {
        onData: (data: Buffer) => void;
        signal?: AbortSignal;
        timeout?: number;
        env?: NodeJS.ProcessEnv;
    }) => Promise<{
        exitCode: number | null;
    }>;
}
export interface BashToolOptions {
    operations?: BashOperations;
    commandPrefix?: string;
    spawnHook?: BashSpawnHook;
}
export interface ReadToolOptions {
    /** Auto-resize large images; maps onto the `images.autoResize` setting. Default: true. */
    autoResizeImages?: boolean;
}
export interface GrepToolOptions {
    /**
     * Unsupported. The historical grep operations seam (isDirectory/readFile for
     * context lines) never delegated the search itself — ripgrep always ran
     * locally — and the built-in native grep tool exposes no filesystem seam at
     * all. Supplying operations throws at tool creation instead of silently
     * searching the local filesystem.
     */
    operations?: unknown;
}
export interface FindOperations {
    exists: (absolutePath: string) => Promise<boolean> | boolean;
    glob: (pattern: string, cwd: string, options: {
        ignore: string[];
        limit: number;
    }) => Promise<string[]> | string[];
}
export interface FindToolOptions {
    operations?: FindOperations;
}
export interface LsOperations {
    exists: (absolutePath: string) => Promise<boolean> | boolean;
    stat: (absolutePath: string) => Promise<{
        isDirectory(): boolean;
    }> | {
        isDirectory(): boolean;
    };
    readdir: (absolutePath: string) => Promise<string[]> | string[];
}
export interface LsToolOptions {
    operations?: LsOperations;
}
/** Parse frontmatter using the historical Pi package-root helper. */
export interface ParsedFrontmatter<T extends Record<string, unknown> = Record<string, unknown>> {
    frontmatter: T;
    body: string;
}
/** Parse YAML frontmatter and throw on invalid metadata. */
export declare function parseFrontmatter<T extends Record<string, unknown> = Record<string, unknown>>(content: string): ParsedFrontmatter<T>;
/** Return content without YAML frontmatter. */
export declare function stripFrontmatter(content: string): string;
/** Mark an extension-authored tool as a Pi-compatible tool definition. */
export declare function defineTool<TParams extends TSchema = TSchema, TDetails = unknown>(tool: ToolDefinition<TParams, TDetails>): ToolDefinition<TParams, TDetails>;
/** Create the legacy read tool definition. */
export declare function createReadToolDefinition(cwd: string, options?: ReadToolOptions): ToolDefinition;
/** Create the legacy read tool. */
export declare function createReadTool(cwd: string, options?: ReadToolOptions): ToolDefinition;
/** Create the legacy bash tool definition. */
export declare function createBashToolDefinition(cwd: string, options?: BashToolOptions): ToolDefinition;
/** Create the legacy bash tool. */
export declare function createBashTool(cwd: string, options?: BashToolOptions): ToolDefinition;
/** Create the legacy grep tool definition. */
export declare function createGrepToolDefinition(cwd: string, options?: GrepToolOptions): ToolDefinition;
/** Create the legacy grep tool. */
export declare function createGrepTool(cwd: string, options?: GrepToolOptions): ToolDefinition;
/** Create the legacy find tool definition. */
export declare function createFindToolDefinition(cwd: string, options?: FindToolOptions): ToolDefinition;
/** Create the legacy find tool. */
export declare function createFindTool(cwd: string, options?: FindToolOptions): ToolDefinition;
/** Create the legacy ls tool definition. */
export declare function createLsToolDefinition(cwd: string, options?: LsToolOptions): ToolDefinition;
/** Create the legacy ls tool. */
export declare function createLsTool(cwd: string, options?: LsToolOptions): ToolDefinition;
/** Create legacy read, bash, edit, and write tools. */
export declare function createCodingTools(cwd: string): ToolDefinition[];
/** Create legacy read, grep, find, and ls tools. */
export declare function createReadOnlyTools(cwd: string): ToolDefinition[];
export declare const SettingsManager: {
    readonly create: (cwd: string, agentDir?: string) => Promise<Settings>;
    readonly inMemory: () => Settings;
};
/**
 * Resource-loader compatibility layer for legacy pi extensions.
 *
 * Upstream `@earendil-works/pi-coding-agent` centralizes extension / skill /
 * prompt / theme / AGENTS.md discovery inside a `DefaultResourceLoader`
 * instance that the caller constructs, `reload()`s, and hands to
 * `createAgentSession({ resourceLoader })`. Every published version of
 * pi-schedule-prompt (≥0.2.0) and other pi extensions that spawn subagents
 * import the class at module scope; a missing export takes the whole
 * extension down at parse time (issue #4567).
 *
 * OMP does the same discovery inline inside `createAgentSession()`, so this
 * shim intentionally does NOT re-implement pi's ResourceLoader plumbing.
 * Instead the loader captures the caller's intent (`no*` flags, `*Override`
 * callbacks, `additional*Paths`, `extensionFactories`, `settingsManager`,
 * `eventBus`) plus the discovery results, and the sibling `createAgentSession`
 * override below translates them into OMP's native session options
 * (`disableExtensionDiscovery`, `preloadedExtensionPaths`, `extensions`,
 * `skills`, `promptTemplates`, `contextFiles`, `settings`, `eventBus`,
 * `systemPrompt`) before delegating to `../sdk`.
 *
 * The pi surface it emulates is the intersection actually used by real
 * extensions in the wild — themes are silently dropped (OMP has no
 * session-level themes surface); `extendResources`, `loadProjectTrustExtensions`,
 * and provider-trust hooks are omitted.
 */
export type ResourceDiagnostic = {
    type: "error" | "warning" | "info";
    message: string;
    path?: string;
};
export interface AgentsFile {
    path: string;
    content: string;
}
/** Marker interface preserved for pi extensions that type against upstream. */
export interface Theme {
    name: string;
}
export interface DefaultResourceLoaderOptions {
    cwd?: string;
    agentDir?: string;
    settingsManager?: Settings | Promise<Settings>;
    eventBus?: EventBus;
    additionalExtensionPaths?: string[];
    additionalSkillPaths?: string[];
    additionalPromptTemplatePaths?: string[];
    additionalThemePaths?: string[];
    extensionFactories?: ExtensionFactory[];
    noExtensions?: boolean;
    noSkills?: boolean;
    noPromptTemplates?: boolean;
    noThemes?: boolean;
    noContextFiles?: boolean;
    systemPrompt?: string;
    appendSystemPrompt?: string | string[];
    extensionsOverride?: (base: LoadExtensionsResult) => LoadExtensionsResult;
    skillsOverride?: (base: {
        skills: Skill[];
        diagnostics: ResourceDiagnostic[];
    }) => {
        skills: Skill[];
        diagnostics: ResourceDiagnostic[];
    };
    promptsOverride?: (base: {
        prompts: PromptTemplate[];
        diagnostics: ResourceDiagnostic[];
    }) => {
        prompts: PromptTemplate[];
        diagnostics: ResourceDiagnostic[];
    };
    themesOverride?: (base: {
        themes: Theme[];
        diagnostics: ResourceDiagnostic[];
    }) => {
        themes: Theme[];
        diagnostics: ResourceDiagnostic[];
    };
    agentsFilesOverride?: (base: {
        agentsFiles: AgentsFile[];
    }) => {
        agentsFiles: AgentsFile[];
    };
    systemPromptOverride?: (base: string | undefined) => string | undefined;
    appendSystemPromptOverride?: (base: string[]) => string[];
}
/**
 * The subset of {@link DefaultResourceLoader} state consumed by the
 * {@link createAgentSession} adapter. Kept as an explicit interface so tests
 * (and any future third-party ResourceLoader passed to `createAgentSession`)
 * only need to satisfy the read surface — not the reload lifecycle.
 */
export interface ResourceLoader {
    getExtensions(): LoadExtensionsResult;
    getSkills(): {
        skills: Skill[];
        diagnostics: ResourceDiagnostic[];
    };
    getPrompts(): {
        prompts: PromptTemplate[];
        diagnostics: ResourceDiagnostic[];
    };
    getThemes(): {
        themes: Theme[];
        diagnostics: ResourceDiagnostic[];
    };
    getAgentsFiles(): {
        agentsFiles: AgentsFile[];
    };
    getSystemPrompt(): string | undefined;
    getAppendSystemPrompt(): string[];
    reload(): Promise<void>;
    /** @internal — used by the shim's createAgentSession to detect its own loaders. */
    readonly __ompLegacyPiLoader?: true;
}
export declare class DefaultResourceLoader implements ResourceLoader {
    #private;
    readonly __ompLegacyPiLoader: true;
    constructor(options?: DefaultResourceLoaderOptions);
    getExtensions(): LoadExtensionsResult;
    getSkills(): {
        skills: Skill[];
        diagnostics: ResourceDiagnostic[];
    };
    getPrompts(): {
        prompts: PromptTemplate[];
        diagnostics: ResourceDiagnostic[];
    };
    getThemes(): {
        themes: Theme[];
        diagnostics: ResourceDiagnostic[];
    };
    getAgentsFiles(): {
        agentsFiles: AgentsFile[];
    };
    getSystemPrompt(): string | undefined;
    getAppendSystemPrompt(): string[];
    /**
     * Discovery snapshot used to seed the session. Emulates upstream pi's
     * `reload()` lifecycle: run every enabled discovery arm against the
     * resolved cwd/agentDir, then thread each result through the caller's
     * `*Override` callback. Discovery arms guarded by an `no*` flag start from
     * an empty base — callers that flipped the flag off still get the override
     * hook, so overrides can inject synthetic entries without triggering a
     * filesystem scan they explicitly opted out of.
     */
    reload(): Promise<void>;
    /** Test seam: whether `reload()` has completed at least once. */
    get loaded(): boolean;
    /** @internal — used by the shim's createAgentSession to translate options. */
    __getResolverState(): {
        cwd: string;
        agentDir: string;
        settingsPromise?: Promise<Settings>;
        eventBus: EventBus;
        extensionsResult: LoadExtensionsResult;
        skills: Skill[];
        prompts: PromptTemplate[];
        agentsFiles: AgentsFile[];
        systemPrompt: string | undefined;
        appendSystemPrompt: string[];
        extensionFactories: ExtensionFactory[];
    };
}
/**
 * Legacy pi extensions call `createAgentSession({ resourceLoader })`. OMP's
 * native option surface has no such field — extension / skill / prompt /
 * context-file discovery are configured directly on the session options — so
 * an untranslated call would silently ignore the loader (including its
 * `noExtensions`/`noSkills` opt-outs), re-run OMP's own discovery, and
 * happily re-load the calling extension into the subagent. That's exactly
 * the recursion the caller passed the loader to prevent.
 *
 * Translate the loader's captured state into OMP's option fields, then
 * delegate to the underlying SDK. Explicit fields on `options` override the
 * loader (matches upstream pi semantics — a caller can partially override a
 * shared loader).
 *
 * `resourceLoader` is not part of {@link CreateAgentSessionOptions}, so it's
 * accepted through a widened alias and stripped before the underlying call.
 */
export type LegacyPiCreateAgentSessionOptions = CreateAgentSessionOptions & {
    resourceLoader?: ResourceLoader;
};
export declare function createAgentSession(options?: LegacyPiCreateAgentSessionOptions): Promise<CreateAgentSessionResult>;
export * from "../index.js";
export { formatBytes as formatSize } from "../tools/render-utils.js";
export { Type } from "./typebox.js";
