bashkit 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/AGENTS.md +442 -0
  2. package/LICENSE +21 -0
  3. package/README.md +713 -0
  4. package/dist/cli/init.d.ts +2 -0
  5. package/dist/cli/init.js +179 -0
  6. package/dist/index.d.ts +14 -0
  7. package/dist/index.js +1805 -0
  8. package/dist/middleware/anthropic-cache.d.ts +17 -0
  9. package/dist/middleware/index.d.ts +1 -0
  10. package/dist/sandbox/e2b.d.ts +9 -0
  11. package/dist/sandbox/index.d.ts +4 -0
  12. package/dist/sandbox/interface.d.ts +21 -0
  13. package/dist/sandbox/local.d.ts +5 -0
  14. package/dist/sandbox/vercel.d.ts +13 -0
  15. package/dist/setup/index.d.ts +2 -0
  16. package/dist/setup/setup-environment.d.ts +36 -0
  17. package/dist/setup/types.d.ts +47 -0
  18. package/dist/skills/discovery.d.ts +9 -0
  19. package/dist/skills/fetch.d.ts +56 -0
  20. package/dist/skills/index.d.ts +6 -0
  21. package/dist/skills/loader.d.ts +11 -0
  22. package/dist/skills/types.d.ts +29 -0
  23. package/dist/skills/xml.d.ts +26 -0
  24. package/dist/tools/bash.d.ts +18 -0
  25. package/dist/tools/edit.d.ts +16 -0
  26. package/dist/tools/exit-plan-mode.d.ts +11 -0
  27. package/dist/tools/glob.d.ts +14 -0
  28. package/dist/tools/grep.d.ts +42 -0
  29. package/dist/tools/index.d.ts +45 -0
  30. package/dist/tools/read.d.ts +25 -0
  31. package/dist/tools/task.d.ts +50 -0
  32. package/dist/tools/todo-write.d.ts +28 -0
  33. package/dist/tools/web-fetch.d.ts +20 -0
  34. package/dist/tools/web-search.d.ts +24 -0
  35. package/dist/tools/write.d.ts +14 -0
  36. package/dist/types.d.ts +32 -0
  37. package/dist/utils/compact-conversation.d.ts +85 -0
  38. package/dist/utils/context-status.d.ts +71 -0
  39. package/dist/utils/index.d.ts +3 -0
  40. package/dist/utils/prune-messages.d.ts +32 -0
  41. package/package.json +84 -0
@@ -0,0 +1,17 @@
1
+ import type { LanguageModelV2Middleware } from "@ai-sdk/provider";
2
+ /**
3
+ * Middleware that enables Anthropic's prompt caching feature.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * import { wrapLanguageModel } from 'ai';
8
+ * import { anthropic } from '@ai-sdk/anthropic';
9
+ * import { anthropicPromptCacheMiddleware } from 'bashkit';
10
+ *
11
+ * const model = wrapLanguageModel({
12
+ * model: anthropic('claude-sonnet-4-20250514'),
13
+ * middleware: anthropicPromptCacheMiddleware,
14
+ * });
15
+ * ```
16
+ */
17
+ export declare const anthropicPromptCacheMiddleware: LanguageModelV2Middleware;
@@ -0,0 +1 @@
1
+ export { anthropicPromptCacheMiddleware } from "./anthropic-cache";
@@ -0,0 +1,9 @@
1
+ import type { Sandbox } from "./interface";
2
+ export interface E2BSandboxConfig {
3
+ apiKey?: string;
4
+ template?: string;
5
+ timeout?: number;
6
+ cwd?: string;
7
+ metadata?: Record<string, string>;
8
+ }
9
+ export declare function createE2BSandbox(config?: E2BSandboxConfig): Sandbox;
@@ -0,0 +1,4 @@
1
+ export { createE2BSandbox, type E2BSandboxConfig } from "./e2b";
2
+ export type { ExecOptions, ExecResult, Sandbox } from "./interface";
3
+ export { createLocalSandbox, type LocalSandboxConfig } from "./local";
4
+ export { createVercelSandbox, type VercelSandboxConfig } from "./vercel";
@@ -0,0 +1,21 @@
1
+ export interface ExecOptions {
2
+ timeout?: number;
3
+ cwd?: string;
4
+ restart?: boolean;
5
+ }
6
+ export interface ExecResult {
7
+ stdout: string;
8
+ stderr: string;
9
+ exitCode: number;
10
+ durationMs: number;
11
+ interrupted: boolean;
12
+ }
13
+ export interface Sandbox {
14
+ exec(command: string, options?: ExecOptions): Promise<ExecResult>;
15
+ readFile(path: string): Promise<string>;
16
+ writeFile(path: string, content: string): Promise<void>;
17
+ readDir(path: string): Promise<string[]>;
18
+ fileExists(path: string): Promise<boolean>;
19
+ isDirectory(path: string): Promise<boolean>;
20
+ destroy(): Promise<void>;
21
+ }
@@ -0,0 +1,5 @@
1
+ import type { Sandbox } from "./interface";
2
+ export interface LocalSandboxConfig {
3
+ cwd?: string;
4
+ }
5
+ export declare function createLocalSandbox(config?: LocalSandboxConfig): Sandbox;
@@ -0,0 +1,13 @@
1
+ import type { Sandbox } from "./interface";
2
+ export interface VercelSandboxConfig {
3
+ runtime?: "node22" | "python3.13";
4
+ resources?: {
5
+ vcpus: number;
6
+ };
7
+ timeout?: number;
8
+ cwd?: string;
9
+ teamId?: string;
10
+ projectId?: string;
11
+ token?: string;
12
+ }
13
+ export declare function createVercelSandbox(config?: VercelSandboxConfig): Sandbox;
@@ -0,0 +1,2 @@
1
+ export type { AgentEnvironmentConfig, SetupResult, SkillContent, } from "./types";
2
+ export { setupAgentEnvironment } from "./setup-environment";
@@ -0,0 +1,36 @@
1
+ import type { Sandbox } from "../sandbox/interface";
2
+ import type { AgentEnvironmentConfig, SetupResult } from "./types";
3
+ /**
4
+ * Sets up an agent environment in a sandbox.
5
+ *
6
+ * Creates workspace directories and seeds skills into the sandbox filesystem.
7
+ * Returns parsed skill metadata for use with skillsToXml().
8
+ *
9
+ * @param sandbox - The sandbox to set up
10
+ * @param config - Environment configuration
11
+ * @returns Setup result with skills metadata
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const pdfSkill = await fetchSkill('anthropics/skills/pdf');
16
+ *
17
+ * const config = {
18
+ * workspace: {
19
+ * notes: 'files/notes/',
20
+ * outputs: 'files/outputs/',
21
+ * },
22
+ * skills: {
23
+ * 'pdf': pdfSkill, // SkillBundle with all files
24
+ * 'my-custom': mySkillContent, // inline string
25
+ * },
26
+ * };
27
+ *
28
+ * const { skills } = await setupAgentEnvironment(sandbox, config);
29
+ *
30
+ * const systemPrompt = `You are an assistant.
31
+ * Save notes to: ${config.workspace.notes}
32
+ * ${skillsToXml(skills)}
33
+ * `;
34
+ * ```
35
+ */
36
+ export declare function setupAgentEnvironment(sandbox: Sandbox, config: AgentEnvironmentConfig): Promise<SetupResult>;
@@ -0,0 +1,47 @@
1
+ import type { SkillMetadata } from "../skills";
2
+ import type { SkillBundle } from "../skills/fetch";
3
+ /**
4
+ * A skill can be either:
5
+ * - A string (just SKILL.md content for inline skills)
6
+ * - A SkillBundle (complete folder with all files, from fetchSkill)
7
+ */
8
+ export type SkillContent = string | SkillBundle;
9
+ /**
10
+ * Configuration for setting up an agent environment in a sandbox.
11
+ */
12
+ export interface AgentEnvironmentConfig {
13
+ /**
14
+ * Workspace directories to create in the sandbox.
15
+ * Keys are logical names, values are paths.
16
+ *
17
+ * @example
18
+ * workspace: {
19
+ * notes: 'files/notes/',
20
+ * outputs: 'files/outputs/',
21
+ * }
22
+ */
23
+ workspace?: Record<string, string>;
24
+ /**
25
+ * Skills to seed into the sandbox.
26
+ * Keys are skill names (folder names).
27
+ * Values can be:
28
+ * - A string: just the SKILL.md content (for inline skills)
29
+ * - A SkillBundle: complete folder from fetchSkill() (for remote skills)
30
+ *
31
+ * @example
32
+ * skills: {
33
+ * 'web-research': webResearchSkillContent, // inline string
34
+ * 'pdf': await fetchSkill('anthropics/skills/pdf'), // SkillBundle
35
+ * }
36
+ */
37
+ skills?: Record<string, SkillContent>;
38
+ }
39
+ /**
40
+ * Result from setting up an agent environment.
41
+ */
42
+ export interface SetupResult {
43
+ /**
44
+ * Parsed skill metadata for use with skillsToXml().
45
+ */
46
+ skills: SkillMetadata[];
47
+ }
@@ -0,0 +1,9 @@
1
+ import type { DiscoverSkillsOptions, SkillMetadata } from "./types";
2
+ /**
3
+ * Discovers skills from configured directories.
4
+ * Parses only frontmatter metadata for progressive disclosure.
5
+ *
6
+ * @param options - Discovery options
7
+ * @returns Array of skill metadata (empty if no skills found)
8
+ */
9
+ export declare function discoverSkills(options?: DiscoverSkillsOptions): Promise<SkillMetadata[]>;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Fetches skills from GitHub repositories.
3
+ *
4
+ * Reference format: `owner/repo/skillName`
5
+ * Example: `anthropics/skills/pdf` fetches the entire skill folder from
6
+ * https://github.com/anthropics/skills/tree/main/skills/pdf
7
+ */
8
+ /**
9
+ * A complete skill bundle with all files from the skill folder.
10
+ */
11
+ export interface SkillBundle {
12
+ /** The skill name (folder name) */
13
+ name: string;
14
+ /** All files in the skill folder. Keys are relative paths, values are file contents. */
15
+ files: Record<string, string>;
16
+ }
17
+ /**
18
+ * Fetches a complete skill folder from GitHub.
19
+ *
20
+ * @param ref - GitHub reference in format `owner/repo/skillName`
21
+ * Example: `anthropics/skills/pdf`
22
+ * @returns A SkillBundle containing all files in the skill folder
23
+ * @throws Error if the skill cannot be fetched
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const pdfSkill = await fetchSkill('anthropics/skills/pdf');
28
+ * // Returns:
29
+ * // {
30
+ * // name: 'pdf',
31
+ * // files: {
32
+ * // 'SKILL.md': '---\nname: pdf\n...',
33
+ * // 'scripts/extract.py': '...',
34
+ * // 'reference.md': '...',
35
+ * // }
36
+ * // }
37
+ * ```
38
+ */
39
+ export declare function fetchSkill(ref: string): Promise<SkillBundle>;
40
+ /**
41
+ * Fetches multiple skill folders from GitHub in parallel.
42
+ *
43
+ * @param refs - Array of GitHub references in format `owner/repo/skillName`
44
+ * @returns Object mapping skill names to their SkillBundle
45
+ * @throws Error if any skill fails to fetch
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * const skills = await fetchSkills([
50
+ * 'anthropics/skills/pdf',
51
+ * 'anthropics/skills/web-research',
52
+ * ]);
53
+ * // Returns: { 'pdf': SkillBundle, 'web-research': SkillBundle }
54
+ * ```
55
+ */
56
+ export declare function fetchSkills(refs: string[]): Promise<Record<string, SkillBundle>>;
@@ -0,0 +1,6 @@
1
+ export type { DiscoverSkillsOptions, SkillMetadata } from "./types";
2
+ export type { SkillBundle } from "./fetch";
3
+ export { discoverSkills } from "./discovery";
4
+ export { fetchSkill, fetchSkills } from "./fetch";
5
+ export { parseSkillMetadata } from "./loader";
6
+ export { skillsToXml } from "./xml";
@@ -0,0 +1,11 @@
1
+ import type { SkillMetadata } from "./types";
2
+ /**
3
+ * Parses YAML frontmatter from a SKILL.md file content.
4
+ * Only extracts metadata - ignores the markdown body for progressive disclosure.
5
+ *
6
+ * @param content - Raw content of SKILL.md file
7
+ * @param skillPath - Absolute path to the SKILL.md file
8
+ * @returns Parsed skill metadata
9
+ * @throws Error if required fields (name, description) are missing
10
+ */
11
+ export declare function parseSkillMetadata(content: string, skillPath: string): SkillMetadata;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Lightweight skill metadata loaded at startup.
3
+ * Does NOT include instructions - agent reads full SKILL.md via Read tool when activating.
4
+ */
5
+ export interface SkillMetadata {
6
+ /** Skill identifier: 1-64 chars, lowercase + hyphens, matches folder name */
7
+ name: string;
8
+ /** When to use this skill: 1-1024 chars */
9
+ description: string;
10
+ /** Absolute path to SKILL.md file (agent uses Read tool to get full content) */
11
+ path: string;
12
+ /** License name or reference to bundled license file */
13
+ license?: string;
14
+ /** Environment requirements (intended product, system packages, network access, etc.) */
15
+ compatibility?: string;
16
+ /** Arbitrary key-value mapping for additional metadata */
17
+ metadata?: Record<string, string>;
18
+ /** Space-delimited list of pre-approved tools (experimental) */
19
+ allowedTools?: string[];
20
+ }
21
+ /**
22
+ * Options for discovering skills from the filesystem.
23
+ */
24
+ export interface DiscoverSkillsOptions {
25
+ /** Override default discovery paths. Default: [".skills/", "~/.bashkit/skills/"] */
26
+ paths?: string[];
27
+ /** Working directory for resolving relative paths. Default: process.cwd() */
28
+ cwd?: string;
29
+ }
@@ -0,0 +1,26 @@
1
+ import type { SkillMetadata } from "./types";
2
+ /**
3
+ * Generates XML representation of available skills for system prompts.
4
+ * This is the recommended format for Claude models per the Agent Skills spec.
5
+ *
6
+ * The output includes name, description, and location for each skill.
7
+ * Agents can use the location path with the Read tool to activate a skill.
8
+ *
9
+ * @param skills - Array of skill metadata
10
+ * @returns XML string to inject into system prompt
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const skills = await discoverSkills();
15
+ * const xml = skillsToXml(skills);
16
+ * // Returns:
17
+ * // <available_skills>
18
+ * // <skill>
19
+ * // <name>pdf-processing</name>
20
+ * // <description>Extract text from PDFs...</description>
21
+ * // <location>/path/to/.skills/pdf-processing/SKILL.md</location>
22
+ * // </skill>
23
+ * // </available_skills>
24
+ * ```
25
+ */
26
+ export declare function skillsToXml(skills: SkillMetadata[]): string;
@@ -0,0 +1,18 @@
1
+ import type { Sandbox } from "../sandbox/interface";
2
+ import type { ToolConfig } from "../types";
3
+ export interface BashOutput {
4
+ stdout: string;
5
+ stderr: string;
6
+ exit_code: number;
7
+ interrupted: boolean;
8
+ duration_ms: number;
9
+ }
10
+ export interface BashError {
11
+ error: string;
12
+ }
13
+ export declare function createBashTool(sandbox: Sandbox, config?: ToolConfig): import("ai").Tool<{
14
+ command: string;
15
+ timeout?: number | undefined;
16
+ description?: string | undefined;
17
+ run_in_background?: boolean | undefined;
18
+ }, BashOutput | BashError>;
@@ -0,0 +1,16 @@
1
+ import type { Sandbox } from "../sandbox/interface";
2
+ import type { ToolConfig } from "../types";
3
+ export interface EditOutput {
4
+ message: string;
5
+ file_path: string;
6
+ replacements: number;
7
+ }
8
+ export interface EditError {
9
+ error: string;
10
+ }
11
+ export declare function createEditTool(sandbox: Sandbox, config?: ToolConfig): import("ai").Tool<{
12
+ file_path: string;
13
+ old_string: string;
14
+ new_string: string;
15
+ replace_all?: boolean | undefined;
16
+ }, EditOutput | EditError>;
@@ -0,0 +1,11 @@
1
+ import type { ToolConfig } from "../types";
2
+ export interface ExitPlanModeOutput {
3
+ message: string;
4
+ approved?: boolean;
5
+ }
6
+ export interface ExitPlanModeError {
7
+ error: string;
8
+ }
9
+ export declare function createExitPlanModeTool(config?: ToolConfig, onPlanSubmit?: (plan: string) => Promise<boolean> | boolean): import("ai").Tool<{
10
+ plan: string;
11
+ }, ExitPlanModeOutput | ExitPlanModeError>;
@@ -0,0 +1,14 @@
1
+ import type { Sandbox } from "../sandbox/interface";
2
+ import type { ToolConfig } from "../types";
3
+ export interface GlobOutput {
4
+ matches: string[];
5
+ count: number;
6
+ search_path: string;
7
+ }
8
+ export interface GlobError {
9
+ error: string;
10
+ }
11
+ export declare function createGlobTool(sandbox: Sandbox, config?: ToolConfig): import("ai").Tool<{
12
+ pattern: string;
13
+ path?: string | undefined;
14
+ }, GlobOutput | GlobError>;
@@ -0,0 +1,42 @@
1
+ import type { Sandbox } from "../sandbox/interface";
2
+ import type { ToolConfig } from "../types";
3
+ export interface GrepMatch {
4
+ file: string;
5
+ line_number?: number;
6
+ line: string;
7
+ before_context?: string[];
8
+ after_context?: string[];
9
+ }
10
+ export interface GrepContentOutput {
11
+ matches: GrepMatch[];
12
+ total_matches: number;
13
+ }
14
+ export interface GrepFilesOutput {
15
+ files: string[];
16
+ count: number;
17
+ }
18
+ export interface GrepCountOutput {
19
+ counts: Array<{
20
+ file: string;
21
+ count: number;
22
+ }>;
23
+ total: number;
24
+ }
25
+ export interface GrepError {
26
+ error: string;
27
+ }
28
+ export type GrepOutput = GrepContentOutput | GrepFilesOutput | GrepCountOutput | GrepError;
29
+ export declare function createGrepTool(sandbox: Sandbox, config?: ToolConfig): import("ai").Tool<{
30
+ pattern: string;
31
+ path?: string | undefined;
32
+ glob?: string | undefined;
33
+ type?: string | undefined;
34
+ output_mode?: "content" | "count" | "files_with_matches" | undefined;
35
+ "-i"?: boolean | undefined;
36
+ "-n"?: boolean | undefined;
37
+ "-B"?: number | undefined;
38
+ "-A"?: number | undefined;
39
+ "-C"?: number | undefined;
40
+ head_limit?: number | undefined;
41
+ multiline?: boolean | undefined;
42
+ }, GrepOutput>;
@@ -0,0 +1,45 @@
1
+ import type { ToolSet } from "ai";
2
+ import type { Sandbox } from "../sandbox/interface";
3
+ import type { AgentConfig } from "../types";
4
+ /**
5
+ * Creates all sandbox-based agent tools for AI SDK's generateText/streamText.
6
+ * Returns an object with Bash, Read, Write, Edit, Glob, Grep tools.
7
+ * Optionally includes WebSearch and WebFetch if configured.
8
+ *
9
+ * @param sandbox - The sandbox to execute commands in
10
+ * @param config - Optional configuration for individual tools and web tools
11
+ *
12
+ * @example
13
+ * // Basic sandbox tools only
14
+ * const tools = createAgentTools(sandbox);
15
+ *
16
+ * @example
17
+ * // With web tools included
18
+ * const tools = createAgentTools(sandbox, {
19
+ * webSearch: { apiKey: process.env.PARALLEL_API_KEY },
20
+ * webFetch: { apiKey: process.env.PARALLEL_API_KEY, model: haiku },
21
+ * });
22
+ */
23
+ export declare function createAgentTools(sandbox: Sandbox, config?: AgentConfig): ToolSet;
24
+ export type { BashError, BashOutput } from "./bash";
25
+ export { createBashTool } from "./bash";
26
+ export type { EditError, EditOutput } from "./edit";
27
+ export { createEditTool } from "./edit";
28
+ export type { ExitPlanModeError, ExitPlanModeOutput } from "./exit-plan-mode";
29
+ export { createExitPlanModeTool } from "./exit-plan-mode";
30
+ export type { GlobError, GlobOutput } from "./glob";
31
+ export { createGlobTool } from "./glob";
32
+ export type { GrepContentOutput, GrepCountOutput, GrepError, GrepFilesOutput, GrepMatch, GrepOutput, } from "./grep";
33
+ export { createGrepTool } from "./grep";
34
+ export type { ReadDirectoryOutput, ReadError, ReadOutput, ReadTextOutput, } from "./read";
35
+ export { createReadTool } from "./read";
36
+ export type { SubagentStepEvent, SubagentTypeConfig, TaskError, TaskOutput, TaskToolConfig, } from "./task";
37
+ export { createTaskTool } from "./task";
38
+ export type { TodoItem, TodoState, TodoWriteError, TodoWriteOutput, } from "./todo-write";
39
+ export { createTodoWriteTool } from "./todo-write";
40
+ export type { WebFetchError, WebFetchOutput, WebFetchToolConfig, } from "./web-fetch";
41
+ export { createWebFetchTool } from "./web-fetch";
42
+ export type { WebSearchError, WebSearchOutput, WebSearchResult, WebSearchToolConfig, } from "./web-search";
43
+ export { createWebSearchTool } from "./web-search";
44
+ export type { WriteError, WriteOutput } from "./write";
45
+ export { createWriteTool } from "./write";
@@ -0,0 +1,25 @@
1
+ import type { Sandbox } from "../sandbox/interface";
2
+ import type { ToolConfig } from "../types";
3
+ export interface ReadTextOutput {
4
+ type: "text";
5
+ content: string;
6
+ lines: Array<{
7
+ line_number: number;
8
+ content: string;
9
+ }>;
10
+ total_lines: number;
11
+ }
12
+ export interface ReadDirectoryOutput {
13
+ type: "directory";
14
+ entries: string[];
15
+ count: number;
16
+ }
17
+ export interface ReadError {
18
+ error: string;
19
+ }
20
+ export type ReadOutput = ReadTextOutput | ReadDirectoryOutput | ReadError;
21
+ export declare function createReadTool(sandbox: Sandbox, config?: ToolConfig): import("ai").Tool<{
22
+ file_path: string;
23
+ offset?: number | undefined;
24
+ limit?: number | undefined;
25
+ }, ReadOutput>;
@@ -0,0 +1,50 @@
1
+ import { type LanguageModel, type PrepareStepFunction, type StepResult, type StopCondition, type Tool, type ToolSet } from "ai";
2
+ export interface TaskOutput {
3
+ result: string;
4
+ usage?: {
5
+ input_tokens: number;
6
+ output_tokens: number;
7
+ };
8
+ total_cost_usd?: number;
9
+ duration_ms?: number;
10
+ }
11
+ export interface TaskError {
12
+ error: string;
13
+ }
14
+ /** Event emitted for each step a subagent takes */
15
+ export interface SubagentStepEvent {
16
+ subagentType: string;
17
+ description: string;
18
+ step: StepResult<ToolSet>;
19
+ }
20
+ export interface SubagentTypeConfig {
21
+ /** Model to use for this subagent type */
22
+ model?: LanguageModel;
23
+ /** System prompt for this subagent type */
24
+ systemPrompt?: string;
25
+ /** Tool names this subagent can use (filters from parent tools) */
26
+ tools?: string[];
27
+ /** Stop condition for this subagent (default: stepCountIs(15)) */
28
+ stopWhen?: StopCondition<ToolSet>;
29
+ /** Prepare step callback for dynamic control per step */
30
+ prepareStep?: PrepareStepFunction<ToolSet>;
31
+ /** Callback for each step this subagent takes */
32
+ onStepFinish?: (step: StepResult<ToolSet>) => void | Promise<void>;
33
+ }
34
+ export interface TaskToolConfig {
35
+ /** Default model for subagents */
36
+ model: LanguageModel;
37
+ /** All available tools that subagents can use */
38
+ tools: ToolSet;
39
+ /** Configuration for each subagent type */
40
+ subagentTypes?: Record<string, SubagentTypeConfig>;
41
+ /** Cost per input token for usage tracking */
42
+ costPerInputToken?: number;
43
+ /** Cost per output token for usage tracking */
44
+ costPerOutputToken?: number;
45
+ /** Default stop condition for subagents (default: stepCountIs(15)) */
46
+ defaultStopWhen?: StopCondition<ToolSet>;
47
+ /** Default callback for each step any subagent takes */
48
+ defaultOnStepFinish?: (event: SubagentStepEvent) => void | Promise<void>;
49
+ }
50
+ export declare function createTaskTool(config: TaskToolConfig): Tool;
@@ -0,0 +1,28 @@
1
+ import type { ToolConfig } from "../types";
2
+ export interface TodoItem {
3
+ content: string;
4
+ status: "pending" | "in_progress" | "completed";
5
+ activeForm: string;
6
+ }
7
+ export interface TodoWriteOutput {
8
+ message: string;
9
+ stats: {
10
+ total: number;
11
+ pending: number;
12
+ in_progress: number;
13
+ completed: number;
14
+ };
15
+ }
16
+ export interface TodoWriteError {
17
+ error: string;
18
+ }
19
+ export interface TodoState {
20
+ todos: TodoItem[];
21
+ }
22
+ export declare function createTodoWriteTool(state: TodoState, config?: ToolConfig, onUpdate?: (todos: TodoItem[]) => void): import("ai").Tool<{
23
+ todos: {
24
+ content: string;
25
+ status: "pending" | "in_progress" | "completed";
26
+ activeForm: string;
27
+ }[];
28
+ }, TodoWriteOutput | TodoWriteError>;
@@ -0,0 +1,20 @@
1
+ import type { LanguageModel } from "ai";
2
+ export interface WebFetchOutput {
3
+ response: string;
4
+ url: string;
5
+ final_url?: string;
6
+ status_code?: number;
7
+ }
8
+ export interface WebFetchError {
9
+ error: string;
10
+ status_code?: number;
11
+ retryable?: boolean;
12
+ }
13
+ export interface WebFetchToolConfig {
14
+ apiKey: string;
15
+ model: LanguageModel;
16
+ }
17
+ export declare function createWebFetchTool(config: WebFetchToolConfig): import("ai").Tool<{
18
+ url: string;
19
+ prompt: string;
20
+ }, WebFetchOutput | WebFetchError>;
@@ -0,0 +1,24 @@
1
+ export interface WebSearchResult {
2
+ title: string;
3
+ url: string;
4
+ snippet: string;
5
+ metadata?: Record<string, unknown>;
6
+ }
7
+ export interface WebSearchOutput {
8
+ results: WebSearchResult[];
9
+ total_results: number;
10
+ query: string;
11
+ }
12
+ export interface WebSearchError {
13
+ error: string;
14
+ status_code?: number;
15
+ retryable?: boolean;
16
+ }
17
+ export interface WebSearchToolConfig {
18
+ apiKey: string;
19
+ }
20
+ export declare function createWebSearchTool(config: WebSearchToolConfig): import("ai").Tool<{
21
+ query: string;
22
+ allowed_domains?: string[] | undefined;
23
+ blocked_domains?: string[] | undefined;
24
+ }, WebSearchOutput | WebSearchError>;
@@ -0,0 +1,14 @@
1
+ import type { Sandbox } from "../sandbox/interface";
2
+ import type { ToolConfig } from "../types";
3
+ export interface WriteOutput {
4
+ message: string;
5
+ bytes_written: number;
6
+ file_path: string;
7
+ }
8
+ export interface WriteError {
9
+ error: string;
10
+ }
11
+ export declare function createWriteTool(sandbox: Sandbox, config?: ToolConfig): import("ai").Tool<{
12
+ file_path: string;
13
+ content: string;
14
+ }, WriteOutput | WriteError>;