/** * Load Skill Tool Module - Built-in tool for progressive skill instruction loading. * * Features: * - Exposes `load_skill` tool definition for model-visible tool catalogs * - Resolves skills by `skill_id` from core skill registry state * - Reads full SKILL.md content only on demand * - Enforces HITL approval before applying skill instructions in interactive runtimes * - Executes instruction-referenced skill scripts under validated scope checks * - Returns structured success, not-found, and read-error payloads * * Implementation Notes: * - Uses registry metadata as source of truth for lookup and skill name/description * - Reads file content from registry-provided source path (no directory rescans) * - Reuses shell tool safeguards (`validateShellCommandScope`) for script execution safety * - Uses generic HITL option requests for user approval (`yes_once`, `yes_in_session`, `no`) * - Session approvals are scoped by world/chat/skill to avoid accidental cross-session reuse * - Keeps payload format deterministic for stable downstream parsing * * Recent Changes: * - 2026-03-12: Added `read` permission level guard to script execution — instructions load normally but all script execution steps are blocked with an inline note when toolPermission is 'read'. * - 2026-03-06: Removed `world.currentChatId` fallback from interactive approval/result scoping; interactive `load_skill` now requires explicit `context.chatId`. * - 2026-03-01: Removed minimal-check mode branch so `load_skill` always runs script/reference preflight consistently and keeps script-root execution guidance available. * - 2026-03-01: Relaxed execution-directive narration requirements to avoid mandatory pre-tool plan text and reduce token overhead. * - 2026-03-01: Added skill-description thread-through and acknowledgment-first execution directive requirements after successful `load_skill`, including unconditional pre-execution plan narration. * - 2026-02-28: Updated `` to require concise tool-use intent text before tool calls and to allow mixed text + tool-call turns when supported by the provider. * - 2026-02-27: Run-scoped `load_skill` cache now stores only successful outcomes so declined/error/not-found paths remain retryable in the same run. * - 2026-02-27: Added run-scoped `load_skill` result caching keyed by latest user-turn marker so repeated same-skill calls are auto-suppressed across assistant/tool hops. * - 2026-02-27: Replaced `[load_skill:hitl]` console logs with structured category logger events (`load_skill.hitl`). * - 2026-02-27: Added same-turn `yes_once` approval reuse + in-flight approval dedupe so repeated/concurrent `load_skill` calls for the same skill do not spam duplicate HITL prompts. * - 2026-02-25: Added persisted synthetic HITL tool-call/response messages for `load_skill` approval so frontends can reconstruct prompts from memory without relying on transient event timing. * - 2026-02-24: Surface non-zero script exits as informational output instead of blocking errors (scripts may be CLI tools requiring args). * - 2026-02-24: Execute skill scripts with cwd set to trusted working directory when provided, otherwise use the skill root. * - 2026-02-14: Strip SKILL.md YAML front matter from injected `` content. * - 2026-02-14: Omit `` from `load_skill` payloads when no instruction-referenced scripts are present. * - 2026-02-14: Added skill-level HITL gating so `load_skill` requires approval even when no script references are present. * - 2026-02-14: Added HITL-gated safe script execution and `` payload rendering. */ type LoadSkillToolContext = { world?: { id?: string; currentChatId?: string | null; eventEmitter?: unknown; }; chatId?: string | null; abortSignal?: AbortSignal; workingDirectory?: string; messages?: Array>; toolCallId?: string; agentName?: string; persistToolEnvelope?: boolean; }; /** * Reconstruct skill approval caches from persisted message history. * Called during chat restore so that `yes_in_session` and `yes_once` grants * survive app restarts without re-prompting the user. * * Scans `role: 'tool'` messages whose JSON content contains `skillId` and * `optionId` fields (written by `persistLoadSkillApprovalResolutionMessage`). * * - `yes_in_session` grants are restored unconditionally (session-scoped). * - `yes_once` grants are restored only when they belong to the current turn * (i.e. appear after the last `role: 'user'` message in the history). */ export declare function reconstructSkillApprovalsFromMessages(worldId: string, chatId: string | null, messages: Array>): number; /** * Clear cached skill approvals and run results scoped to a specific chat. * Must be called when messages are removed (e.g. edit+resubmit) so that * HITL approval prompts fire again for the reprocessed message. */ export declare function clearChatSkillApprovals(worldId: string, chatId: string | null): void; export declare function createLoadSkillToolDefinition(): { description: string; parameters: { type: string; properties: { skill_id: { type: string; description: string; }; }; required: string[]; additionalProperties: boolean; }; execute: (args: any, _sequenceId?: string, _parentToolCall?: string, context?: LoadSkillToolContext) => Promise; }; export {};