import { M as SkillsConfig, O as SkillConfig, j as SkillSource, k as SkillDiagnostic, l as SkillActivationState, r as AgentHooks } from "./agent-BHkvYIH9.js";
import { c as ExecutionHandle, s as ExecutionContext } from "./types-BibzMDjX.js";
import { Hookable } from "hookable";

//#region src/skills/allowed-tools.d.ts
/** Tools that are always allowed regardless of the active skills' allow-list. */
declare const IMPLICITLY_ALLOWED_SKILL_TOOLS: readonly string[];
/**
 * Register `tool:gate` / `mcp:tool:gate` handlers that enforce the union of
 * `allowedTools` across active skills.
 *
 * No-op when no active skill declares an allow-list (permissive default —
 * matches the spec's "experimental" note for `allowed-tools`).
 *
 * Returns an `uninstall` fn. The agent calls this at run end to detach the
 * handlers and prevent cross-run hook leaks.
 */
declare function installAllowedToolsGate(hooks: Hookable<AgentHooks>, state: SkillActivationState): () => void;
//#endregion
//#region src/skills/catalog.d.ts
interface BuildCatalogOptions {
  /**
   * When true (the default), the prose instructs the model to call
   * `skills_use`. Set to false when `SkillsConfig.tool === false` so the
   * system prompt matches the active activation mechanism.
   */
  skillsToolRegistered?: boolean;
  /**
   * Name of the tool the model should use to read `SKILL.md` files when
   * `skillsToolRegistered` is false. Defaults to `'read_file'`.
   */
  readToolName?: string;
}
/**
 * Build the skill catalog XML and behavioral instructions for the system prompt.
 */
declare function buildCatalog(skills: SkillConfig[], options?: BuildCatalogOptions): string;
//#endregion
//#region src/skills/discovery.d.ts
interface ParsedSkillFile {
  frontmatter: Record<string, unknown>;
  body: string;
  diagnostics: SkillDiagnostic[];
}
/**
 * Parse a SKILL.md file into frontmatter + body.
 *
 * Uses a simple regex-based YAML extractor that handles:
 * - Flat key: value pairs
 * - Quoted values
 * - One-level nested maps (for `metadata:`)
 * - One-level nested block lists, `key:` followed by indented `- item`
 *   lines (for `allowed-tools` and any future array fields). Items are
 *   unquoted with the same rules as scalar values.
 * - Flow-style scalars are preserved verbatim — interpretation (e.g.
 *   `[a, b]` as a list) is left to per-field consumers via
 *   {@link takeStringOrArray}.
 * - Lenient recovery from unquoted-colon values (e.g.
 *   `description: Use when: the user asks …`) via a quote-wrap retry.
 */
declare function parseFrontmatter(content: string): ParsedSkillFile;
interface ParseSkillOptions {
  /** Source tag to attach to the returned SkillConfig. */
  source?: SkillSource;
}
/**
 * Parse a SKILL.md file into a SkillConfig (lenient).
 *
 * Returns `null` only when the skill is fundamentally unusable:
 * - The file is missing
 * - The description is absent (required by spec for disclosure)
 *
 * All other issues are surfaced as `SkillConfig.diagnostics` with severity
 * `warning`. Deprecated top-level fields (`paths`, `model`, `thinking`) are
 * auto-migrated into `metadata['zidane.*']`.
 */
declare function parseSkillFile(filePath: string, options?: ParseSkillOptions): Promise<SkillConfig | null>;
/** A scan path paired with the source tag that should be attached to any skills found in it. */
interface SourcedScanPath {
  path: string;
  source: SkillSource;
}
/**
 * Return the default scan paths tagged by source. Project-scope paths come
 * first; their skills therefore win on name collisions against user-scope
 * skills (first-found wins in discovery).
 */
declare function getDefaultScanPaths(): SourcedScanPath[];
/**
 * Infer a source tag for a user-provided scan path.
 * Paths under `$HOME` are treated as 'user'; everything else as 'project'.
 */
declare function inferSource(path: string): SkillSource;
/**
 * Discover skills from sourced filesystem paths.
 * Each path is scanned for subdirectories containing SKILL.md.
 * Earlier paths have higher priority (first-found wins on name collision).
 *
 * `signal` is checked between each `parseSkillFile` so a rapid `cwd` switch
 * in the host (TUI / GUI) can stop a long scan without leaking I/O. Aborts
 * reject with the signal's `reason` (or a default `AbortError`) — same shape
 * `AbortSignal.throwIfAborted()` produces in modern runtimes.
 */
declare function discoverSkills(paths: SourcedScanPath[], signal?: AbortSignal): Promise<SkillConfig[]>;
//#endregion
//#region src/skills/interpolate.d.ts
/**
 * Replace every !\`command\` pattern with a static placeholder, without
 * executing anything. Used when shell interpolation is disabled
 * (`SkillsConfig.allowShellInterpolation: false`): skill content can be
 * third-party input, and running its embedded commands on activation
 * bypasses the allowed-tools gate.
 */
declare function stripShellInterpolations(instructions: string): string;
interface InterpolateShellCommandsOptions {
  /**
   * Called once per !\`command\` that failed (non-zero exit or exec throw)
   * with the command text and the inline placeholder it was replaced with.
   * Lets callers surface a visible warning instead of activation silently
   * proceeding on partial content.
   */
  onFailure?: (command: string, placeholder: string) => void;
}
/**
 * Interpolate shell commands in skill instructions.
 *
 * Runs each !\`command\` through the execution context and replaces
 * the placeholder with the command's stdout. If a command fails,
 * the placeholder is replaced with an error message (and
 * `options.onFailure` is notified when provided).
 *
 * @param instructions - Raw skill instructions with potential !\`command\` patterns
 * @param execution - The execution context to run commands in
 * @param handle - The active execution handle
 * @returns Instructions with all !\`command\` patterns replaced by output
 */
declare function interpolateShellCommands(instructions: string, execution: ExecutionContext, handle: ExecutionHandle, options?: InterpolateShellCommandsOptions): Promise<string>;
//#endregion
//#region src/skills/resolve.d.ts
/**
 * Resolved-skills bundle: the materialized list plus a `cleanup` fn that
 * removes any temporary directory created for `config.write` skills.
 *
 * Inline skills must live on disk for the lifetime of the agent (the
 * `skills_read` / `skills_run_script` tools resolve relative paths against
 * `baseDir`), so cleanup is deferred to `agent.destroy()`. When no temp
 * directory was created, `cleanup` is a no-op.
 */
interface ResolvedSkillsBundle {
  skills: SkillConfig[];
  cleanup: () => void;
}
/**
 * Resolve all skills from a SkillsConfig:
 *
 * 1. Materialize `config.write` entries to a temp directory, tagged as `inline`
 * 2. Combine with default + user-provided scan paths (project-first, user-next)
 * 3. Run lenient disk discovery
 * 4. Merge with any host-provided `config.catalog`. Catalog entries seed the
 *    resolution map FIRST, so they shadow disk-discovered skills with the
 *    same name (shadow diagnostic attached to the winner — same shape as
 *    the disk-vs-disk collision case).
 * 5. Apply filters: optional project-skill trust gate, `exclude`,
 *    `enabled` allowlist
 *
 * Returns `{ skills, cleanup }` — call `cleanup()` on agent destroy to remove
 * the temp directory created for inline `config.write` skills. The agent
 * factory wires this automatically; standalone callers must invoke it
 * themselves to avoid leaking OS temp.
 */
declare function resolveSkills(config: SkillsConfig): Promise<ResolvedSkillsBundle>;
//#endregion
//#region src/skills/validate.d.ts
/**
 * A single issue surfaced by skill-authoring validation.
 * Distinct from `ValidationResult` in `tools/validation.ts` (tool-input JSON
 * schema validation) — different domain, different module.
 */
interface SkillValidationIssue {
  /** Stable machine-readable code for consumer matching. */
  code: string;
  /** Human-readable description. */
  message: string;
  /** Frontmatter field name the issue relates to, when applicable. */
  field?: string;
}
interface SkillValidationResult {
  valid: boolean;
  errors: SkillValidationIssue[];
}
/**
 * Validate a skill name per the spec:
 * - 1–64 characters
 * - Lowercase alphanumeric + hyphens only
 * - Must not start or end with a hyphen
 * - Must not contain consecutive hyphens
 *
 * The parent-directory match is validated separately (it requires knowing the
 * skill's `location`, which this function does not).
 */
declare function validateSkillName(name: string): boolean;
/**
 * Strict validation for a skill that is about to be authored / written to disk.
 * Rejects anything that would violate the spec. Use the lenient parser path
 * (`parseSkillFile`) for loading third-party skills.
 */
declare function validateSkillForWrite(skill: SkillConfig): SkillValidationResult;
/**
 * Validate that `relPath` stays inside `baseDir` when resolved.
 *
 * Rejects:
 * - Absolute paths (`/etc/passwd`, `C:\…`)
 * - Parent traversal (`..` segments that escape baseDir)
 * - Null-byte tricks
 *
 * Returns `{ valid: true, absolutePath }` on success or `{ valid: false, error }`
 * with a human-readable reason.
 */
declare function validateResourcePath(relPath: string, baseDir: string): {
  valid: true;
  absolutePath: string;
} | {
  valid: false;
  error: string;
};
/**
 * Symlink-hardened variant of {@link validateResourcePath}: after the lexical
 * check passes, resolve both the target and `baseDir` through `realpath` and
 * re-confirm the target still lives under the skill directory. A symlink
 * placed inside the skill dir pointing at e.g. `/etc/passwd` passes the
 * lexical check but fails here.
 *
 * Falls back to the lexical verdict when `realpath` fails (target or baseDir
 * not present on the LOCAL filesystem) — the common causes are a remote
 * execution context (docker/sandbox, where the local realpath is meaningless
 * and the remote side resolves the path itself) or a not-yet-existing file.
 * The returned `absolutePath` is always the lexical one: it's what the
 * execution context resolves; realpath here is verification only.
 */
declare function validateResourcePathReal(relPath: string, baseDir: string): Promise<{
  valid: true;
  absolutePath: string;
} | {
  valid: false;
  error: string;
}>;
/**
 * Parse a single `allowed-tools` entry into its tool name + optional argument pattern.
 *
 * Examples:
 * - `Read` → `{ tool: 'Read' }`
 * - `Bash(git:*)` → `{ tool: 'Bash', argPrefix: 'git' }`
 */
declare function parseAllowedToolPattern(entry: string): {
  tool: string;
  argPrefix?: string;
} | null;
/**
 * Check whether a tool call (identified by its wire/displayName and argument input)
 * matches a skill's allow-list entry.
 *
 * Matching rules (Zidane's interpretation of the spec's unspecified syntax):
 * - Exact match: displayName === pattern (no parens).
 * - Prefix match: for `Tool(arg:*)`, displayName === 'Tool' AND **any** string
 *   value in the input object starts with `arg`. This is intentionally
 *   permissive: it doesn't depend on a convention about which property carries
 *   the "command" (schemas vary across tools), and for the common
 *   `shell({ command: 'git …' })` shape it behaves identically to a "primary
 *   string" rule.
 * - For tools whose inputs carry no string values, the arg-match returns false.
 */
declare function matchesAllowedTool(displayName: string, input: Record<string, unknown>, pattern: string): boolean;
/**
 * Test whether a tool call is allowed by the union of `allowedTools` across a set
 * of active skills. Returns `true` when the union is empty (permissive default)
 * OR when any entry matches.
 */
declare function isToolAllowedByUnion(displayName: string, input: Record<string, unknown>, union: readonly string[]): boolean;
//#endregion
//#region src/skills/writer.d.ts
/**
 * Write a `SkillConfig` to disk as a proper skill directory with SKILL.md.
 * Returns the path to the written SKILL.md file.
 *
 * Throws if the skill fails `validateSkillForWrite` — the authoring path is
 * strict on purpose. For loading third-party skills, use `parseSkillFile`
 * directly (lenient).
 */
declare function writeSkillToDisk(skill: SkillConfig, targetDir: string): string;
/**
 * Write multiple `SkillConfig` objects to a target directory.
 * Each skill gets its own subdirectory with a SKILL.md file.
 * Returns the target directory path (for use as a scan path).
 */
declare function writeSkillsToDisk(skills: SkillConfig[], targetDir: string): string;
//#endregion
//#region src/skills/index.d.ts
/**
 * Define an inline skill configuration.
 *
 * Strict-validates at author-time — throws if the config would be rejected by
 * `writeSkillToDisk` or the spec. Source defaults to `'inline'`.
 */
declare function defineSkill(config: Omit<SkillConfig, 'source'> & {
  source?: SkillConfig['source'];
}): SkillConfig;
//#endregion
export { buildCatalog as C, parseSkillFile as S, installAllowedToolsGate as T, SourcedScanPath as _, SkillValidationResult as a, inferSource as b, parseAllowedToolPattern as c, validateSkillForWrite as d, validateSkillName as f, stripShellInterpolations as g, interpolateShellCommands as h, SkillValidationIssue as i, validateResourcePath as l, InterpolateShellCommandsOptions as m, writeSkillToDisk as n, isToolAllowedByUnion as o, resolveSkills as p, writeSkillsToDisk as r, matchesAllowedTool as s, defineSkill as t, validateResourcePathReal as u, discoverSkills as v, IMPLICITLY_ALLOWED_SKILL_TOOLS as w, parseFrontmatter as x, getDefaultScanPaths as y };
//# sourceMappingURL=index-BIo67xLV.d.ts.map