/** * Skill self-improvement (Python parity: `Agent(self_improve=...)`, * `agent/skill_review.py` `SkillReviewMixin`, `skills/protocols.py` * `DefaultSkillReviewPolicy` / `SkillReviewProtocol`). * * After a task finishes, an opt-in *guarded* review turn runs an isolated * model call restricted to the single `skill_manage` tool and asks whether * the session revealed a reusable technique worth persisting as a skill. * * Guarantees kept from Python: off by default; never runs with the full * toolset; the review cannot trigger another review; any failure is * swallowed so the main task is never broken. */ export type SelfImproveMode = 'inline' | 'background'; /** What a review turn knows about the task (Python's `trajectory` dict). */ export interface SkillReviewTrajectory { prompt: string; response: string; toolsUsed: string[]; } /** A skill the review turn proposed via `skill_manage`. */ export interface SkillProposal { action: 'create' | 'patch'; name: string; description: string; instructions: string; } /** Python `SkillReviewProtocol`. */ export interface SkillReviewPolicy { shouldReview(trajectory: SkillReviewTrajectory): boolean; reviewPrompt(trajectory: SkillReviewTrajectory): string; /** Called with each proposal the review turn makes (TypeScript-only hook). */ onProposal?(proposal: SkillProposal): void | Promise; } export interface SelfImproveConfig { enabled: boolean; mode: SelfImproveMode; policy: SkillReviewPolicy; } /** * Python `DefaultSkillReviewPolicy`: review only when the session did real * work (at least `minToolCalls` tool invocations, default 1). */ export declare class DefaultSkillReviewPolicy implements SkillReviewPolicy { static readonly MAX_PROMPT_CHARS = 500; readonly minToolCalls: number; constructor(minToolCalls?: number); shouldReview(trajectory: SkillReviewTrajectory): boolean; reviewPrompt(trajectory: SkillReviewTrajectory): string; } /** The single tool the review turn may use (Python `skill_manage`). */ export declare const SKILL_MANAGE_TOOL: { readonly type: "function"; readonly function: { readonly name: "skill_manage"; readonly description: "Create or patch a reusable skill learned in this session, or skip when nothing durable emerged."; readonly parameters: { readonly type: "object"; readonly properties: { readonly action: { readonly type: "string"; readonly enum: readonly ["create", "patch", "skip"]; readonly description: "What to do."; }; readonly name: { readonly type: "string"; readonly description: "Skill name (kebab-case)."; }; readonly description: { readonly type: "string"; readonly description: "One-line description of when to use the skill."; }; readonly instructions: { readonly type: "string"; readonly description: "Step-by-step instructions (markdown)."; }; readonly reason: { readonly type: "string"; readonly description: "Why the skill is (not) worth persisting."; }; }; readonly required: readonly ["action"]; }; }; }; /** * Resolve the constructor option. `true`/`'inline'` review after the turn * before returning; `'background'` reviews without blocking the caller; a * policy object customises when/what to review. An unknown mode string * disables the feature (as Python does, with a warning). */ export declare function resolveSelfImprove(input: boolean | string | Record | undefined | null, warn?: (message: string) => void): SelfImproveConfig; /** Read a `skill_manage` tool call's arguments into a proposal (null for `skip`/invalid). */ export declare function proposalFromToolArgs(args: Record): SkillProposal | null; /** * A tool call as either transport reports it: the OpenAI-compatible shape * (`function.name` + a JSON `arguments` string) or the AI SDK's * (`toolName` + parsed `args`). */ export interface RawSkillToolCall { function?: { name?: string; arguments?: string; }; toolName?: string; args?: unknown; } /** * Run one review turn and return what it proposed (Python * `agent/skill_review.py` `SkillReviewMixin`). * * `askModel` performs the isolated call: it is given the review prompt and the * single tool the turn may use, and returns the tool calls the model made. * Keeping the transport outside means the Agent decides how to reach the * model and this stays testable without one. * * Nothing here throws: a review is bookkeeping, and it must never break the * task that produced it. Failures are reported through `onError`. */ export declare function runSkillReviewTurn(config: SelfImproveConfig, trajectory: SkillReviewTrajectory, askModel: (prompt: string, tool: typeof SKILL_MANAGE_TOOL) => Promise, onError?: (error: unknown) => void): Promise;