import { FileInfo, Workspace } from "@cloudflare/shell"; //#region src/tools/workspace.d.ts type WorkspaceLike = Pick< Workspace, | "readFile" | "readFileBytes" | "writeFile" | "readDir" | "rm" | "glob" | "mkdir" | "stat" >; interface ReadOperations { readFile(path: string): Promise; readFileBytes(path: string): Promise; stat(path: string): Promise | FileInfo | null; } interface WriteOperations { writeFile(path: string, content: string): Promise; mkdir( path: string, opts?: { recursive?: boolean; } ): Promise | void; } interface EditOperations { readFile(path: string): Promise; writeFile(path: string, content: string): Promise; } interface ListOperations { readDir( dir: string, opts?: { limit?: number; offset?: number; } ): Promise | FileInfo[]; } interface FindOperations { glob(pattern: string): Promise | FileInfo[]; } interface DeleteOperations { rm( path: string, opts?: { recursive?: boolean; force?: boolean; } ): Promise; } interface GrepOperations { glob(pattern: string): Promise | FileInfo[]; readFile(path: string): Promise; } interface BashOperations { readDir( dir: string, opts?: { limit?: number; offset?: number; } ): Promise | FileInfo[]; readFileBytes(path: string): Promise; writeFile(path: string, content: string): Promise; writeFileBytes?: (path: string, content: Uint8Array) => Promise; mkdir( path: string, opts?: { recursive?: boolean; } ): Promise | void; rm( path: string, opts?: { recursive?: boolean; force?: boolean; } ): Promise; } interface WorkspaceToolsOptions { /** * Include the default workspace Bash tool. Enabled by default; pass `false` * to omit it, or an options object to tune execution limits. */ bash?: boolean | Omit; } type WorkspaceTools = { read: ReturnType; write: ReturnType; edit: ReturnType; list: ReturnType; find: ReturnType; grep: ReturnType; delete: ReturnType; bash?: ReturnType; }; /** * Create a complete set of AI SDK tools backed by a workspace. * * Accepts either a concrete `Workspace` from `@cloudflare/shell` or any * `WorkspaceLike` implementation — e.g. a proxy that forwards calls to a * shared workspace owned by a parent DO. * * ```ts * import { Workspace } from "@cloudflare/shell"; * import { createWorkspaceTools } from "@cloudflare/think"; * * class MyAgent extends Agent { * workspace = new Workspace({ sql: this.ctx.storage.sql, name: () => this.name }); * * async onChatMessage() { * const tools = createWorkspaceTools(this.workspace); * const result = streamText({ model, tools, messages }); * return result.toUIMessageStreamResponse(); * } * } * ``` */ declare function createWorkspaceTools( workspace: WorkspaceLike, options?: WorkspaceToolsOptions ): WorkspaceTools; type TextReadToolOutput = { path: string; content: string; totalLines: number; fromLine?: number; toLine?: number; }; type ImageReadToolOutput = { kind: "image"; path: string; name: string; mediaType: string; sizeBytes: number; }; type FileReadToolOutput = { kind: "file"; path: string; name: string; mediaType: string; sizeBytes: number; }; type BinaryReadToolOutput = { kind: "binary"; path: string; name: string; mediaType: string; sizeBytes: number; unsupported: true; }; type ReadToolError = { error: string; }; type ReadToolOutput = | TextReadToolOutput | ImageReadToolOutput | FileReadToolOutput | BinaryReadToolOutput | ReadToolError; interface ReadToolOptions { ops: ReadOperations; } declare function createReadTool(options: ReadToolOptions): import("ai").Tool< { path: string; offset?: number | undefined; limit?: number | undefined; }, ReadToolOutput >; interface WriteToolOptions { ops: WriteOperations; } declare function createWriteTool(options: WriteToolOptions): import("ai").Tool< { path: string; content: string; }, { path: string; bytesWritten: number; lines: number; } >; interface EditToolOptions { ops: EditOperations; } declare function createEditTool(options: EditToolOptions): import("ai").Tool< { path: string; old_string: string; new_string: string; }, | { error: string; path?: undefined; created?: undefined; lines?: undefined; replaced?: undefined; fuzzyMatch?: undefined; } | { path: string; created: boolean; lines: number; error?: undefined; replaced?: undefined; fuzzyMatch?: undefined; } | { path: string; replaced: boolean; fuzzyMatch: boolean; lines: number; error?: undefined; created?: undefined; } | { path: string; replaced: boolean; lines: number; error?: undefined; created?: undefined; fuzzyMatch?: undefined; } >; interface ListToolOptions { ops: ListOperations; } declare function createListTool(options: ListToolOptions): import("ai").Tool< { path: string; limit?: number | undefined; offset?: number | undefined; }, { path: string; count: number; entries: string[]; } >; interface FindToolOptions { ops: FindOperations; } declare function createFindTool(options: FindToolOptions): import("ai").Tool< { pattern: string; }, Record >; interface GrepToolOptions { ops: GrepOperations; } declare function createGrepTool(options: GrepToolOptions): import("ai").Tool< { query: string; include?: string | undefined; fixedString?: boolean | undefined; caseSensitive?: boolean | undefined; contextLines?: number | undefined; }, Record >; type BashChangedFiles = { created: string[]; updated: string[]; deleted: string[]; directoriesCreated: string[]; directoriesDeleted: string[]; }; interface BashToolOptions { ops: BashOperations; timeout?: number; network?: boolean; maxWorkspaceFiles?: number; maxWorkspaceFileBytes?: number; maxOutputBytes?: number; } declare function createBashTool(options: BashToolOptions): import("ai").Tool< { script: string; cwd?: string | undefined; }, { errors?: string[] | undefined; skippedFiles?: string[] | undefined; stdout: string; stderr: string; exitCode: number; changedFiles: BashChangedFiles; } >; interface DeleteToolOptions { ops: DeleteOperations; } declare function createDeleteTool( options: DeleteToolOptions ): import("ai").Tool< { path: string; recursive?: boolean | undefined; }, { deleted: string; } >; //#endregion export { createFindTool as C, createWorkspaceTools as D, createReadTool as E, createWriteTool as O, createEditTool as S, createListTool as T, WorkspaceToolsOptions as _, EditOperations as a, createBashTool as b, FindToolOptions as c, ListOperations as d, ListToolOptions as f, WorkspaceTools as g, WorkspaceLike as h, DeleteToolOptions as i, GrepOperations as l, ReadToolOptions as m, BashToolOptions as n, EditToolOptions as o, ReadOperations as p, DeleteOperations as r, FindOperations as s, BashOperations as t, GrepToolOptions as u, WriteOperations as v, createGrepTool as w, createDeleteTool as x, WriteToolOptions as y }; //# sourceMappingURL=workspace-BZXdZcuw.d.ts.map