import type { ResolvedSkillSelection } from "../types/skill-selection.js"; import { type ResolvedSelectionContext, type SelectionResolverOptions } from "./selection-resolver.js"; export interface SkillContextInput { prompt?: string; cwd?: string; sessionId?: string; profileId?: string; restore?: boolean; agentId?: string; /** Exact native session custody; null explicitly declares a root. */ parentSessionId?: string | null; skills?: string[]; paths?: string[]; } export interface SkillContextOptions extends SelectionResolverOptions { maxChars?: number; maxSkills?: number; /** * An unnamed prompt match whose longest matched phrase has fewer words than * this is offered as a load command instead of being injected, however many * such words matched. Named, explicit, path and required selections are not * affected. Unset, every counted match may be injected. */ minPromptPhraseWords?: number; /** Print load pointers with --cache-first even though this context didn't come from the cache: a managed hook that fell back to the service. */ pointerCacheFirst?: boolean; /** Bodies a child session receives from its parent's loaded skills; the rest are offered. Unset, HISTORY_BODY_LIMITS applies. */ inheritedBodies?: number; /** Called with the resolved pin before any payload is read (again if a new child is resolved again); metadata only. */ onResolved?: (resolved: ResolvedSelectionContext) => void; /** * performance.now() time after which a new child whose parent receipt * changed while it resolved is not resolved again (the managed hook passes * its renewal deadline). Without it the single retry is unconditional. */ resolveAgainBefore?: number; } export interface ContextSelectionReceipt extends ResolvedSkillSelection { reason: string; } export interface SkillContextResult { context: string; selections: ContextSelectionReceipt[]; omitted: Array<{ slug: string; version: string; reason: string; loadCommand: string; }>; receipt: { schemaVersion: 1; id: string; profileId: string; profileRevision: string; authority: string; workspaceId: string; source: "api" | "verified-cache"; sessionId?: string; restored: boolean; chars: number; selections: ContextSelectionReceipt[]; }; } /** * Re-delivered history (a subagent's inheritance and a restore after * compaction or resume) carries no prompt, so its relevance is recency: the * most recently loaded skills first, a few bodies, then load commands. Older * history stays loadable with `skills load` and is not re-listed. */ export declare const HISTORY_BODY_LIMITS: Readonly>; export declare const HISTORY_CANDIDATE_LIMIT = 10; /** * The one fixed line that says a context was limited because this session's * record could not be updated: newly read skills are offered as load commands * instead of being delivered unrecorded. */ export declare const SESSION_WRITE_BUSY_NOTICE = "Skills context was limited [SESSION_WRITE_BUSY]: another Skills process was updating this session's record, so newly selected skills are listed as load commands instead of being delivered. Load them with those commands when the task needs them."; /** * Select and read context for one prompt, recording newly delivered skills in * the session receipt. * * A new child's first receipt write fences its parent's exact receipt. When * the parent recorded a load or committed a renewal while the child resolved * (its pin itself unchanged), that write refuses with SESSION_PARENT_CHANGED; * as the refusal prescribes, the child is resolved once more from the current * parent pin. A parent whose pin changed (a migration or reconciliation), a * second change, or no time left before options.resolveAgainBefore keeps the * refusal. * * Receipt writes run synchronously and, under contention, block the calling * thread for at most SESSION_WRITE_LOCK_WAIT_MS while they wait for another * live writer's lock. */ export declare function buildSkillContext(input: SkillContextInput, options?: SkillContextOptions): Promise;