import { type Sha256Hex } from "./sha256.js"; import type { RegisteredSkill, SkillDef, SkillResourceRef, SkillSummary, SkillWarn } from "./types.js"; /** * The code-skill registry — what a deployment's own source contributes, as * against what its users author. * * **A factory, not a module singleton**, for the same two reasons the tool * registry is one: module state in a workerd isolate has a lifetime the host * does not control, and an implicit global makes every test share a registry * with every other. A host that wants singleton ergonomics wraps one instance * in a module of its own — that decision belongs to the host. * * The registry is deliberately **not** the whole skill library. It holds code * skills, whose bodies are build artifacts and whose version history is source * control. Host-stored skills never enter it; they meet code skills only in the * resolved {@link SkillSummary} catalog, which is source-agnostic by design. */ export interface SkillRegistry { /** * Register a standalone skill with no owning plugin — available to every * agent. * * `ownerPlugin` on the def is **ignored** and warned about. A platform skill * is unowned by definition, and honouring a stray field here would make the * loader auto-activate a plugin and mislabel the skill as that plugin's. */ registerPlatform(def: SkillDef): void; /** * Register a skill contributed by a tool plugin. `ownerPlugin` is filled from * `pluginName` rather than the def, so a recipe is only ever offered to an * agent that can load the tools it describes. */ registerPlugin(pluginName: string, def: SkillDef): void; get(name: string): RegisteredSkill | undefined; all(): RegisteredSkill[]; /** Tier-1 summaries, gated to the plugins available on this run. */ summaries(options?: { availablePlugins?: Iterable; }): SkillSummary[]; /** Drop every registration. For a test that wants a controlled set. */ clear(): void; } export interface SkillRegistryOptions { /** * Observe a likely author bug: a name collision, or a platform registration * carrying an owner. Both overwrite/ignore and continue — a bad skill must * not take down agent startup — so this is the only signal they happened. */ onWarn?: SkillWarn; /** Override the content digest. Must be synchronous SHA-256 (see `sha256.ts`). */ sha256Hex?: Sha256Hex; } /** The Tier-3 listing for a code skill: metadata, with sizes measured in UTF-8 bytes. */ export declare function codeSkillResourceRefs(def: SkillDef): SkillResourceRef[]; /** Project a registered code skill into the source-agnostic Tier-1 summary. */ export declare function toCodeSkillSummary(skill: RegisteredSkill): SkillSummary; export declare function createSkillRegistry(options?: SkillRegistryOptions): SkillRegistry;