/** * The live view of `ctx.skills` for one attached session. * * One object, read by three surfaces — the slash menu, the submit * adjudication, and the `/skills` inspector — so none of them fetches, * filters, or caches on its own. It holds no skill body, performs no * discovery, and resolves no duplicate: it observes the catalog Harness has * already resolved for THIS agent, at THIS session's cwd, and remembers the * last observation that was authoritative. * * Skills are an optional capability. The registry is reached through * `ctx.inject(['skills'], …)` rather than a one-shot `ctx.get`, so a profile * that mounts the service later, drops it, or mounts it again is followed * rather than sampled once at attach time. * @module dshline/skills/catalog */ import type { Context } from '@deepseek-ai/cordis'; import type { SkillView } from './model.ts'; /** What the catalog can currently say about the skills of this session. */ export type SkillCatalogReading = /** No skill registry is mounted in this composition. */ { readonly kind: 'unavailable'; } /** A registry is mounted and no authoritative observation has arrived yet. */ | { readonly kind: 'loading'; } /** * Discovery settled without completing and there is no last-good catalog to * fall back on. Whatever the incomplete observation did carry is shown, and * is never trusted for a negative answer. */ | { readonly kind: 'incomplete'; readonly skills: readonly SkillView[]; } /** A complete observation, possibly superseded by a change not yet refetched. */ | { readonly kind: 'ready'; readonly skills: readonly SkillView[]; /** An invalidation arrived after this catalog was collected. */ readonly stale: boolean; /** A refresh is in flight right now. */ readonly refreshing: boolean; }; /** What one leading `/name` submission turns out to be. */ export type SkillVerdict = /** A user-invocable skill: the line belongs to Harness, unchanged. */ { readonly kind: 'user-invocable'; readonly skill: SkillView; } /** A known skill no human gesture may invoke. Costs no model turn. */ | { readonly kind: 'not-user-invocable'; readonly skill: SkillView; } /** An authoritative miss: the existing unknown-command protection applies. */ | { readonly kind: 'unknown'; } /** Discovery could not be completed, so nothing may be declared about the name. */ | { readonly kind: 'unverifiable'; }; /** What the catalog needs from the attachment that owns it. */ export interface SkillCatalogSpec { /** Context carrying the optional skill registry. */ readonly ctx: Context; /** * The viewing scope: the attached Agent, which is its own Harness scope key. * * Omitting it would read the global layer alone and silently hide every * skill a preset's own composition contributes. */ readonly scope: object; /** The session's workspace, for cwd-sensitive providers. */ readonly cwd: string; /** Ask the runner to redraw, and recompute anything already on screen. */ readonly changed: () => void; } /** * The one Harness skill surface this frontend reads. * * `snapshot` rather than `list`, because `complete` is the whole difference * between "this agent has no such skill" and "discovery did not finish", and * only the first of those may deny a submitted line. */ export declare class SkillCatalog { private readonly spec; private readonly lifetime; private service; /** The newest COMPLETE observation. Never overwritten by an incomplete one. */ private complete; /** The newest incomplete observation, shown only while there is no last-good. */ private partial; /** An invalidation arrived after {@link complete} was collected. */ private dirty; private refreshing; /** Whether any refresh has settled, so `loading` can end without a catalog. */ private settled; /** Bumped by every invalidation, so a refresh can tell if it was overtaken. */ private changes; /** Bumped by every refresh and every service transition; guards late results. */ private generation; private disposed; /** @param spec - the context, the viewing scope, the cwd, and the redraw sink. */ constructor(spec: SkillCatalogSpec); /** * Follow the optional registry for as long as this catalog lives. * * The injected fiber is what makes mount, unmount, and remount ordinary * lifecycle rather than three cases to detect: its body runs once per * mount, and its effect's disposer runs on unmount. * @returns a disposer that stops following and abandons work in flight. */ install(): () => void; /** What this catalog can currently say. */ reading(): SkillCatalogReading; /** * The skills to offer right now, without waiting for anything. * * The slash menu is rebuilt on every keystroke and cannot await discovery, * so it reads whatever the last observation left — which is exactly the * behavior a stale POSITIVE is safe for: Harness re-resolves the name at the * invocation boundary regardless of what was offered. * @returns the last observed skills, or none. */ skills(): readonly SkillView[]; /** * Decide what a leading `/name` submission is, refetching when the answer * would otherwise rest on an observation that may already be wrong. * * A stale positive is safe; a stale NEGATIVE is not, because a skill added a * moment ago would be reported as a typo. So an untrusted catalog is * refreshed before anything is denied, and a refresh that still cannot * complete yields `unverifiable` rather than a verdict. * @param name - the leading token, without its slash. * @param signal - bounds the refresh this may have to wait for, so a provider * that never settles cannot leave a submitted line in limbo. An aborted * refresh simply fails to complete, which is already `unverifiable`. * @returns what the name turned out to be. */ verify(name: string, signal?: AbortSignal): Promise; /** * Refetch the catalog for this agent and cwd. * * Every call starts its own snapshot and claims a generation: an older * observation that resolves late finds the generation moved and drops its * result rather than overwriting a newer one. * @param signal - an optional caller deadline, honoured alongside this * catalog's own lifetime. * @returns when this refresh has settled or been superseded. */ refresh(signal?: AbortSignal): Promise; /** * Declare the catalog possibly changed and refetch it. * * Called by `skills/change` and by the one lifecycle event that changes the * effective catalog without a registry mutation: re-parenting this agent's * scope onto another preset's composition. */ invalidate(): void; /** Whether the current catalog may answer a NEGATIVE question. */ private trusted; /** * Whether a settled snapshot is still the newest one for the same service. * @param generation - the generation the refresh claimed. * @param service - the registry the refresh was issued against. * @returns whether its result may be applied. */ private current; /** * Start following a newly mounted registry. * @param service - the registry this composition just published. */ private attach; /** Stop following a registry that has gone away, and forget what it said. */ private detach; } //# sourceMappingURL=catalog.d.ts.map