/** * `~/.agentproto/imported-skills.json` — the user's curated set of skill * folders the daemon should deliver to spawned sessions. * * Mirrors `mcp-imports.ts` for MCP servers. Where `mcp_import` snapshots a * discovered server, a skill import COPIES a skill folder (the dir holding * `SKILL.md`) into `~/.agentproto/skills//` and records a content hash. * Copying, not symlinking, keeps the delivered tree stable if the source is * moved/deleted — and lets `resyncImportedSkill` re-copy on demand. * * File shape: * { * "version": 1, * "imports": [ * { * "id": "ap-import-mcp", // the skill's frontmatter `name` * "alias": "ap-import-mcp", // display/dir name (default = id) * "sourcePath": "/path/to/skill", // the folder the user pointed at * "sha": "…", // sha256 over the copied tree * "addedAt": "2026-10-13T…" * } * ] * } * * `sha` is a sha256 over the sorted relative paths + bytes of the copied * tree — `resyncImportedSkill` compares it against a freshly hashed source * to decide whether a re-copy is needed. */ declare const IMPORTED_SKILLS_PATH: () => string; /** Root holding one copied folder per import (`//SKILL.md`). */ declare const IMPORTED_SKILLS_ROOT: () => string; declare const IMPORTED_SKILLS_VERSION: 1; /** Every AIP-3 skill folder is identified by this file at its root. */ declare const SKILL_FILE = "SKILL.md"; /** * The subset of AIP-3 frontmatter the registry relies on. `@agentproto/skill` * owns the full schema; runtime doesn't depend on that package, so this mirrors * the fields that gate an import (name is the identity, description is * required by AIP-3). Unknown frontmatter keys are tolerated (`.loose()`). */ declare const NAME_PATTERN: RegExp; /** * An `alias` names the directory the driver copies a skill into * (`/skills//`), so it MUST be a bare slug — no * path separators, no `..`, no leading dot. Reusing `NAME_PATTERN` (the AIP-3 * skill-name grammar) guarantees it can never escape the target dir. */ declare function assertValidAlias(alias: string): void; interface ImportedSkillEntry { /** Stable identity: the skill's frontmatter `name`. */ id: string; /** Display/dir name — defaults to `id`, overridable at import time. */ alias: string; /** The folder the user pointed at (kept so `resync` can re-read it). */ sourcePath: string; /** sha256 over the copied tree (sorted relative paths + bytes). */ sha: string; addedAt: string; } interface ImportedSkillsConfig { version: typeof IMPORTED_SKILLS_VERSION; imports: ImportedSkillEntry[]; } /** Where a given import's copied tree lives. */ declare function skillImportDir(id: string, root?: string): string; /** Injectable paths so tests never touch the real `~/.agentproto`. */ interface SkillImportPaths { registryPath?: string; root?: string; } declare function loadImportedSkills(path?: string): Promise; declare function saveImportedSkills(config: ImportedSkillsConfig, path?: string): Promise; /** The current imports (convenience over `loadImportedSkills`). */ declare function listImportedSkills(paths?: SkillImportPaths): Promise; /** Find an import by its `id` OR its `alias` — the spawn-resolution lookup. */ declare function resolveImportedSkill(config: ImportedSkillsConfig, idOrAlias: string): ImportedSkillEntry | undefined; /** A skill resolved for per-session delivery: the alias names the dir the * driver copies into, `path` is the durable imported copy (NOT `sourcePath`). */ interface ResolvedSessionSkill { alias: string; path: string; } interface ResolveSessionSkillsResult { resolved: ResolvedSessionSkill[]; warnings: string[]; } /** * Map a spawn's resolved skill ids onto the imported registry. Each id matches * by `id` OR `alias`. An id that isn't imported is NOT an error — it stays in * the adapter-facing `skills` list (hermes resolves it; others may * auto-discover) — but it IS reported as a warning so the operator can see why * nothing was delivered for it (same shape/style as `mountImports` warnings). * Duplicate matches (id and alias both listed) collapse to one delivery. * * `path` points at the copied tree under the registry root, not the entry's * `sourcePath`: delivery must survive the source folder moving or being * deleted (that's the whole point of importing a snapshot). */ declare function resolveSessionSkills(ids: readonly string[], config: ImportedSkillsConfig, root?: string): ResolveSessionSkillsResult; /** * Parse a `SKILL.md`'s frontmatter, enforcing the AIP-3 minimum (a valid * `name` + a `description`). Throws with a field-naming message. */ declare function parseSkillFrontmatter(raw: string): { name: string; description: string; }; /** * sha256 over the sorted relative paths + bytes of a skill tree. A rename or * any byte change moves the hash; directory mtimes do not. Symlinks are * dereferenced (matching the copy), so the hash is over the delivered bytes. */ declare function computeSkillDirSha(dir: string): Promise; interface ImportSkillResult { config: ImportedSkillsConfig; entry: ImportedSkillEntry; } interface ImportSkillInput { sourcePath: string; alias?: string; } /** * Copy a skill folder into the registry and record it. Throws when the source * lacks a valid `SKILL.md` (the caller — `skill_import` — turns that into an * error reply). An existing import with the same id is replaced in place. */ declare function importSkill(input: ImportSkillInput, paths?: SkillImportPaths): Promise; interface RemoveSkillResult { config: ImportedSkillsConfig; removed: boolean; } /** Drop an import and delete its copied tree (best-effort). */ declare function removeImportedSkill(id: string, paths?: SkillImportPaths): Promise; interface ResyncSkillResult { config: ImportedSkillsConfig; entry?: ImportedSkillEntry; /** True when the source hash differed and a re-copy happened. */ changed: boolean; warnings: string[]; } /** * Re-copy an import from its `sourcePath` when the source's content hash * differs from the recorded `sha` (or when the copied tree went missing). * A missing/unreadable source is a warning, never a throw — it leaves the * existing entry intact. */ declare function resyncImportedSkill(id: string, paths?: SkillImportPaths): Promise; export { IMPORTED_SKILLS_PATH, IMPORTED_SKILLS_ROOT, IMPORTED_SKILLS_VERSION, type ImportSkillInput, type ImportSkillResult, type ImportedSkillEntry, type ImportedSkillsConfig, NAME_PATTERN, type RemoveSkillResult, type ResolveSessionSkillsResult, type ResolvedSessionSkill, type ResyncSkillResult, SKILL_FILE, type SkillImportPaths, assertValidAlias, computeSkillDirSha, importSkill, listImportedSkills, loadImportedSkills, parseSkillFrontmatter, removeImportedSkill, resolveImportedSkill, resolveSessionSkills, resyncImportedSkill, saveImportedSkills, skillImportDir };