bashkit 0.1.3 → 0.2.1

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.
@@ -1,4 +1,3 @@
1
- import type { ToolConfig } from "../types";
2
1
  export interface TodoItem {
3
2
  content: string;
4
3
  status: "pending" | "in_progress" | "completed";
@@ -19,7 +18,7 @@ export interface TodoWriteError {
19
18
  export interface TodoState {
20
19
  todos: TodoItem[];
21
20
  }
22
- export declare function createTodoWriteTool(state: TodoState, config?: ToolConfig, onUpdate?: (todos: TodoItem[]) => void): import("ai").Tool<{
21
+ export declare function createTodoWriteTool(state: TodoState, onUpdate?: (todos: TodoItem[]) => void): import("ai").Tool<{
23
22
  todos: {
24
23
  content: string;
25
24
  status: "pending" | "in_progress" | "completed";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * HTTP status codes that indicate a retryable error.
3
+ * Shared between web-search and web-fetch tools.
4
+ */
5
+ export declare const RETRYABLE_STATUS_CODES: number[];
@@ -1,4 +1,4 @@
1
- import type { LanguageModel } from "ai";
1
+ import type { WebFetchConfig } from "../types";
2
2
  export interface WebFetchOutput {
3
3
  response: string;
4
4
  url: string;
@@ -10,11 +10,7 @@ export interface WebFetchError {
10
10
  status_code?: number;
11
11
  retryable?: boolean;
12
12
  }
13
- export interface WebFetchToolConfig {
14
- apiKey: string;
15
- model: LanguageModel;
16
- }
17
- export declare function createWebFetchTool(config: WebFetchToolConfig): import("ai").Tool<{
13
+ export declare function createWebFetchTool(config: WebFetchConfig): import("ai").Tool<{
18
14
  url: string;
19
15
  prompt: string;
20
16
  }, WebFetchOutput | WebFetchError>;
@@ -1,3 +1,4 @@
1
+ import type { WebSearchConfig } from "../types";
1
2
  export interface WebSearchResult {
2
3
  title: string;
3
4
  url: string;
@@ -14,10 +15,7 @@ export interface WebSearchError {
14
15
  status_code?: number;
15
16
  retryable?: boolean;
16
17
  }
17
- export interface WebSearchToolConfig {
18
- apiKey: string;
19
- }
20
- export declare function createWebSearchTool(config: WebSearchToolConfig): import("ai").Tool<{
18
+ export declare function createWebSearchTool(config: WebSearchConfig): import("ai").Tool<{
21
19
  query: string;
22
20
  allowed_domains?: string[] | undefined;
23
21
  blocked_domains?: string[] | undefined;
package/dist/types.d.ts CHANGED
@@ -1,23 +1,37 @@
1
- import type { LanguageModel } from "ai";
1
+ import type { LanguageModel, Tool } from "ai";
2
+ import type { CacheStore } from "./cache/types";
2
3
  import type { SkillMetadata } from "./skills/types";
4
+ /**
5
+ * SDK tool options picked from the Tool type.
6
+ * This automatically adapts to the user's installed AI SDK version.
7
+ * - v5 users get v5 options (if any)
8
+ * - v6 users get v6 options (needsApproval, strict, etc.)
9
+ *
10
+ * Uses `any` for input/output to allow typed needsApproval functions.
11
+ */
12
+ export type SDKToolOptions = Partial<Pick<Tool<any, any>, "strict" | "needsApproval" | "providerOptions">>;
13
+ /**
14
+ * Configuration for sandbox-based tools.
15
+ * Extends AI SDK tool options for version-appropriate type safety.
16
+ */
3
17
  export type ToolConfig = {
4
18
  timeout?: number;
5
19
  maxFileSize?: number;
6
20
  maxOutputLength?: number;
7
21
  allowedPaths?: string[];
8
22
  blockedCommands?: string[];
9
- };
23
+ } & SDKToolOptions;
10
24
  export type GrepToolConfig = ToolConfig & {
11
25
  /** Use ripgrep (rg) instead of grep. Requires ripgrep to be installed. Default: false */
12
26
  useRipgrep?: boolean;
13
27
  };
14
28
  export type WebSearchConfig = {
15
29
  apiKey: string;
16
- };
30
+ } & SDKToolOptions;
17
31
  export type WebFetchConfig = {
18
32
  apiKey: string;
19
33
  model: LanguageModel;
20
- };
34
+ } & SDKToolOptions;
21
35
  export type AskUserConfig = {
22
36
  /** Callback to handle questions and return answers */
23
37
  onQuestion?: (question: string) => Promise<string> | string;
@@ -28,6 +42,40 @@ export type SkillConfig = {
28
42
  /** Callback when a skill is activated */
29
43
  onActivate?: (skill: SkillMetadata, instructions: string) => void | Promise<void>;
30
44
  };
45
+ /**
46
+ * Cache configuration for tool result caching.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * // Enable with defaults (LRU cache, 5min TTL, safe tools only)
51
+ * cache: true
52
+ *
53
+ * // Custom cache store
54
+ * cache: myRedisStore
55
+ *
56
+ * // Per-tool control
57
+ * cache: { Read: true, Glob: true, Bash: false }
58
+ *
59
+ * // Full options
60
+ * cache: { store: myStore, ttl: 600000, debug: true, Read: true }
61
+ * ```
62
+ */
63
+ export type CacheConfig = boolean | CacheStore | {
64
+ /** Custom cache store (default: LRUCacheStore) */
65
+ store?: CacheStore;
66
+ /** TTL in milliseconds (default: 5 minutes) */
67
+ ttl?: number;
68
+ /** Enable debug logging for cache hits/misses */
69
+ debug?: boolean;
70
+ /** Callback when cache hit occurs */
71
+ onHit?: (toolName: string, key: string) => void;
72
+ /** Callback when cache miss occurs */
73
+ onMiss?: (toolName: string, key: string) => void;
74
+ /** Custom key generator for cache keys */
75
+ keyGenerator?: (toolName: string, params: unknown) => string;
76
+ /** Per-tool overrides - any tool name can be enabled/disabled */
77
+ [toolName: string]: boolean | CacheStore | number | ((toolName: string, key: string) => void) | ((toolName: string, params: unknown) => string) | undefined;
78
+ };
31
79
  export type AgentConfig = {
32
80
  tools?: {
33
81
  Bash?: ToolConfig;
@@ -47,6 +95,8 @@ export type AgentConfig = {
47
95
  webSearch?: WebSearchConfig;
48
96
  /** Include WebFetch tool with this config */
49
97
  webFetch?: WebFetchConfig;
98
+ /** Enable tool result caching */
99
+ cache?: CacheConfig;
50
100
  defaultTimeout?: number;
51
101
  workingDirectory?: string;
52
102
  };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * HTTP status codes that indicate a retryable error.
3
+ * Shared between web-search and web-fetch tools.
4
+ */
5
+ export declare const RETRYABLE_STATUS_CODES: number[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bashkit",
3
- "version": "0.1.3",
3
+ "version": "0.2.1",
4
4
  "description": "Agentic coding tools for the Vercel AI SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -54,17 +54,18 @@
54
54
  "@clack/prompts": "^0.7.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@ai-sdk/anthropic": "^2.0.50",
57
+ "@ai-sdk/anthropic": "^3.0.1",
58
58
  "@biomejs/biome": "^2.3.9",
59
59
  "@e2b/code-interpreter": "^1.5.1",
60
60
  "@types/bun": "latest",
61
61
  "@types/node": "^24.10.0",
62
62
  "@vercel/sandbox": "^1.0.4",
63
+ "ai": "^6.0.0",
63
64
  "parallel-web": "^0.2.4",
64
65
  "typescript": "^5.9.3"
65
66
  },
66
67
  "peerDependencies": {
67
- "ai": "^5.0.0",
68
+ "ai": ">=5.0.0",
68
69
  "zod": "^4.1.8",
69
70
  "@vercel/sandbox": "^1.0.0",
70
71
  "@e2b/code-interpreter": "^1.0.0",