UNPKG

agents

Version:

A home for your AI agents

92 lines (90 loc) • 3.2 kB
import { f as SkillResourceKind, n as Skill } from "./skill-DRBcIBjC.js"; //#region src/skills/script.d.ts /** A request to run one bundled skill script. */ interface SkillScriptRequest { /** The skill that owns the script. */ readonly skill: Skill; /** Script path relative to the skill, under `scripts/`. */ readonly path: string; /** Script source. */ readonly source: string; /** JSON input from the model. */ readonly input: unknown; /** Other files bundled with the skill, mounted for the script. */ readonly resources?: readonly SkillScriptFile[]; } /** A bundled file made available to a running script. */ interface SkillScriptFile { /** Path relative to the skill directory. */ readonly path: string; /** UTF-8 text, or base64 when `encoding` is `"base64"`. */ readonly content: string; /** Defaults to `"text"`. */ readonly encoding?: "text" | "base64"; /** Role of the file in the skill. */ readonly kind?: SkillResourceKind; } /** Runs skill scripts. Enables Think's `run_skill_script` tool. */ interface SkillScriptRunner { /** * Run a script. * * @param request - The script and its skill. * @returns The script's result. * @throws When the script fails; the tool reports the message to the model. */ run(request: SkillScriptRequest): Promise<unknown>; } /** Skill metadata passed to running scripts. */ interface SkillScriptContext { /** The skill that owns the script. */ readonly skill: { readonly name: string; readonly description: string; readonly license?: string; readonly compatibility?: string; readonly metadata: Readonly<Record<string, string>>; readonly allowedTools: readonly string[]; }; } /** * The `ctx` object passed as the second argument to function-style JS * skill scripts (`export default async function run(input, ctx)`). * * Capabilities are gated by the runner: `workspace` throws unless workspace * access is enabled, and `tools` only resolves tools the runner was given. */ interface SkillRunContext { /** Metadata for the skill that owns this script. */ skill: SkillScriptContext["skill"]; /** Text bundled resources by relative path (e.g. `references/style-guide.md`). */ files: Record<string, string>; /** Workspace access, gated by the runner's `workspace` permission. */ workspace: { readFile(path: string): Promise<string | null>; listFiles(path?: string): Promise<unknown>; glob(pattern: string): Promise<unknown>; stat(path: string): Promise<{ type: string; size: number; } | null>; writeFile(path: string, content: string): Promise<void>; }; /** Explicitly granted tools: `tools.call(name, input)` or `tools.<name>(input)`. */ tools: { call(name: string, input?: unknown): Promise<unknown>; } & Record<string, (input?: unknown) => Promise<unknown>>; /** Scratch artifacts returned to the model as `outputFiles`. */ output: { writeFile(name: string, content: string): Promise<void>; }; } //#endregion export { SkillScriptRunner as a, SkillScriptRequest as i, SkillScriptContext as n, SkillScriptFile as r, SkillRunContext as t }; //# sourceMappingURL=script-CFDLTk5b.d.ts.map