@cloudflare/think 0.20.1 → 0.21.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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"workspace.js","names":[],"sources":["../../src/tools/workspace.ts"],"sourcesContent":["import type { Workspace, FileInfo } from \"@cloudflare/shell\";\nimport type { JSONValue, Tool } from \"ai\";\nimport type { InitialFiles } from \"just-bash\";\nimport { Bash } from \"just-bash\";\nimport { tool } from \"ai\";\nimport { z } from \"zod\";\n\n// ── WorkspaceLike ─────────────────────────────────────────────────\n//\n// Minimum workspace surface that Think's internals rely on. Covers the\n// methods called by `createWorkspaceTools()` below plus the handful\n// Think itself uses (`readFile`/`writeFile`/`readDir`/`rm` in\n// `think.ts`). The read tool also needs `readFileBytes` so image/PDF\n// reads can be rehydrated as AI SDK multimodal content. A concrete\n// `Workspace` from `@cloudflare/shell` satisfies this; so do custom\n// implementations like the `SharedWorkspace` proxy in `examples/assistant`\n// that forwards to a parent DO.\n//\n// Consumers who reach for the fuller filesystem API (e.g.\n// `createWorkspaceStateBackend` for codemode's `state.*` in a sandbox)\n// still need a concrete `Workspace`.\n//\n// @experimental The API surface may change before stabilizing.\n\nexport type WorkspaceLike = Pick<\n Workspace,\n | \"readFile\"\n | \"readFileBytes\"\n | \"writeFile\"\n | \"readDir\"\n | \"rm\"\n | \"glob\"\n | \"mkdir\"\n | \"stat\"\n> &\n /**\n * Optional so a custom workspace written before it existed still\n * satisfies the type. Media eviction and skills projection need it and\n * become no-ops (with a warning) when it is absent.\n */\n Partial<Pick<Workspace, \"writeFileBytes\">>;\n\n// ── Operations interfaces ─────────────────────────────────────────\n// Abstractions over file I/O so the same tools can work against\n// Workspace, a local filesystem, or anything else.\n\nexport interface ReadOperations {\n readFile(path: string): Promise<string | null>;\n readFileBytes(path: string): Promise<Uint8Array | null>;\n stat(path: string): Promise<FileInfo | null> | FileInfo | null;\n}\n\nexport interface WriteOperations {\n writeFile(path: string, content: string): Promise<void>;\n mkdir(path: string, opts?: { recursive?: boolean }): Promise<void> | void;\n}\n\nexport interface EditOperations {\n readFile(path: string): Promise<string | null>;\n writeFile(path: string, content: string): Promise<void>;\n}\n\nexport interface ListOperations {\n readDir(\n dir: string,\n opts?: { limit?: number; offset?: number }\n ): Promise<FileInfo[]> | FileInfo[];\n}\n\nexport interface FindOperations {\n glob(pattern: string): Promise<FileInfo[]> | FileInfo[];\n}\n\nexport interface DeleteOperations {\n rm(\n path: string,\n opts?: { recursive?: boolean; force?: boolean }\n ): Promise<void>;\n}\n\nexport interface GrepOperations {\n glob(pattern: string): Promise<FileInfo[]> | FileInfo[];\n readFile(path: string): Promise<string | null>;\n}\n\nexport interface BashOperations {\n readDir(\n dir: string,\n opts?: { limit?: number; offset?: number }\n ): Promise<FileInfo[]> | FileInfo[];\n readFileBytes(path: string): Promise<Uint8Array | null>;\n writeFile(path: string, content: string): Promise<void>;\n writeFileBytes?: (path: string, content: Uint8Array) => Promise<void>;\n mkdir(path: string, opts?: { recursive?: boolean }): Promise<void> | void;\n rm(\n path: string,\n opts?: { recursive?: boolean; force?: boolean }\n ): Promise<void>;\n}\n\n// ── Workspace-backed operation factories ──────────────────────────\n\nfunction workspaceReadOps(ws: WorkspaceLike): ReadOperations {\n return {\n readFile: (path) => ws.readFile(path),\n readFileBytes: (path) => ws.readFileBytes(path),\n stat: (path) => ws.stat(path)\n };\n}\n\nfunction workspaceWriteOps(ws: WorkspaceLike): WriteOperations {\n return {\n writeFile: (path, content) => ws.writeFile(path, content),\n mkdir: (path, opts) => ws.mkdir(path, opts)\n };\n}\n\nfunction workspaceEditOps(ws: WorkspaceLike): EditOperations {\n return {\n readFile: (path) => ws.readFile(path),\n writeFile: (path, content) => ws.writeFile(path, content)\n };\n}\n\nfunction workspaceListOps(ws: WorkspaceLike): ListOperations {\n return {\n readDir: (dir, opts) => ws.readDir(dir, opts)\n };\n}\n\nfunction workspaceFindOps(ws: WorkspaceLike): FindOperations {\n return {\n glob: (pattern) => ws.glob(pattern)\n };\n}\n\nfunction workspaceDeleteOps(ws: WorkspaceLike): DeleteOperations {\n return {\n rm: (path, opts) => ws.rm(path, opts)\n };\n}\n\nfunction workspaceGrepOps(ws: WorkspaceLike): GrepOperations {\n return {\n glob: (pattern) => ws.glob(pattern),\n readFile: (path) => ws.readFile(path)\n };\n}\n\nfunction workspaceBashOps(ws: WorkspaceLike): BashOperations {\n const maybeBytesWriter = ws as WorkspaceLike & {\n writeFileBytes?: (path: string, content: Uint8Array) => Promise<void>;\n };\n return {\n readDir: (dir, opts) => ws.readDir(dir, opts),\n readFileBytes: (path) => ws.readFileBytes(path),\n writeFile: (path, content) => ws.writeFile(path, content),\n writeFileBytes: maybeBytesWriter.writeFileBytes\n ? (path, content) => maybeBytesWriter.writeFileBytes!(path, content)\n : undefined,\n mkdir: (path, opts) => ws.mkdir(path, opts),\n rm: (path, opts) => ws.rm(path, opts)\n };\n}\n\nexport interface WorkspaceToolsOptions {\n /**\n * Include the default workspace Bash tool. Enabled by default; pass `false`\n * to omit it, or an options object to tune execution limits.\n */\n bash?: boolean | Omit<BashToolOptions, \"ops\">;\n}\n\nexport type WorkspaceTools = {\n read: ReturnType<typeof createReadTool>;\n write: ReturnType<typeof createWriteTool>;\n edit: ReturnType<typeof createEditTool>;\n list: ReturnType<typeof createListTool>;\n find: ReturnType<typeof createFindTool>;\n grep: ReturnType<typeof createGrepTool>;\n delete: ReturnType<typeof createDeleteTool>;\n bash?: ReturnType<typeof createBashTool>;\n};\n\n/**\n * Create a complete set of AI SDK tools backed by a workspace.\n *\n * Accepts either a concrete `Workspace` from `@cloudflare/shell` or any\n * `WorkspaceLike` implementation — e.g. a proxy that forwards calls to a\n * shared workspace owned by a parent DO.\n *\n * ```ts\n * import { Workspace } from \"@cloudflare/shell\";\n * import { createWorkspaceTools } from \"@cloudflare/think\";\n *\n * class MyAgent extends Agent<Env> {\n * workspace = new Workspace({ sql: this.ctx.storage.sql, name: () => this.name });\n *\n * async onChatMessage() {\n * const tools = createWorkspaceTools(this.workspace);\n * const result = streamText({ model, tools, messages });\n * return result.toUIMessageStreamResponse();\n * }\n * }\n * ```\n */\nexport function createWorkspaceTools(\n workspace: WorkspaceLike,\n options: WorkspaceToolsOptions = {}\n): WorkspaceTools {\n const tools: WorkspaceTools = {\n read: createReadTool({ ops: workspaceReadOps(workspace) }),\n write: createWriteTool({ ops: workspaceWriteOps(workspace) }),\n edit: createEditTool({ ops: workspaceEditOps(workspace) }),\n list: createListTool({ ops: workspaceListOps(workspace) }),\n find: createFindTool({ ops: workspaceFindOps(workspace) }),\n grep: createGrepTool({ ops: workspaceGrepOps(workspace) }),\n delete: createDeleteTool({ ops: workspaceDeleteOps(workspace) })\n };\n\n if (options.bash !== false) {\n tools.bash = createBashTool({\n ...(typeof options.bash === \"object\" ? options.bash : {}),\n ops: workspaceBashOps(workspace)\n });\n }\n\n return tools;\n}\n\n// ── Read ────────────────────────────────────────────────────────────\n\nconst MAX_LINES = 2000;\nconst MAX_LINE_LENGTH = 2000;\nconst MAX_MODEL_FILE_BYTES = 3.5 * 1024 * 1024;\n\ntype TextReadToolOutput = {\n path: string;\n content: string;\n totalLines: number;\n fromLine?: number;\n toLine?: number;\n};\n\ntype ImageReadToolOutput = {\n kind: \"image\";\n path: string;\n name: string;\n mediaType: string;\n sizeBytes: number;\n};\n\ntype FileReadToolOutput = {\n kind: \"file\";\n path: string;\n name: string;\n mediaType: string;\n sizeBytes: number;\n};\n\ntype BinaryReadToolOutput = {\n kind: \"binary\";\n path: string;\n name: string;\n mediaType: string;\n sizeBytes: number;\n unsupported: true;\n};\n\ntype ReadToolError = { error: string };\n\ntype ReadToolOutput =\n | TextReadToolOutput\n | ImageReadToolOutput\n | FileReadToolOutput\n | BinaryReadToolOutput\n | ReadToolError;\n\ntype ReadToolInput = {\n path: string;\n offset?: number;\n limit?: number;\n};\n\nexport interface ReadToolOptions {\n ops: ReadOperations;\n}\n\nexport function createReadTool(options: ReadToolOptions): Tool {\n const { ops } = options;\n\n return tool({\n description:\n \"Read a workspace file. Text files return line-numbered content. \" +\n \"Images and PDFs are passed to capable models as file content. \" +\n \"Use offset and limit for large text files. Returns null if the file does not exist.\",\n inputSchema: z.object({\n path: z.string().describe(\"Absolute path to the file\"),\n offset: z\n .number()\n .int()\n .min(1)\n .optional()\n .describe(\"1-indexed line number to start reading from\"),\n limit: z\n .number()\n .int()\n .min(1)\n .optional()\n .describe(\"Number of lines to read\")\n }),\n execute: async ({\n path,\n offset,\n limit\n }: ReadToolInput): Promise<ReadToolOutput> => {\n const stat = await ops.stat(path);\n if (!stat) {\n return { error: `File not found: ${path}` };\n }\n if (stat.type === \"directory\") {\n return { error: `${path} is a directory, not a file` };\n }\n\n const mediaType = await detectWorkspaceMediaType({ ops, path, stat });\n\n if (mediaType.startsWith(\"image/\")) {\n return {\n kind: \"image\",\n path,\n name: stat.name,\n mediaType,\n sizeBytes: stat.size\n };\n }\n\n if (mediaType === \"application/pdf\") {\n return {\n kind: \"file\",\n path,\n name: stat.name,\n mediaType,\n sizeBytes: stat.size\n };\n }\n\n if (!isTextMediaType(mediaType)) {\n return {\n kind: \"binary\",\n path,\n name: stat.name,\n mediaType,\n sizeBytes: stat.size,\n unsupported: true\n };\n }\n\n return readTextWithLineNumbers({ ops, path, offset, limit });\n },\n toModelOutput: async ({\n input,\n output\n }: {\n input: unknown;\n output: unknown;\n }) => {\n const replayOutput: unknown = output;\n\n if (!isRecord(replayOutput)) {\n return { type: \"text\", value: String(replayOutput) };\n }\n\n if (typeof replayOutput.error === \"string\") {\n return { type: \"error-text\", value: replayOutput.error };\n }\n\n if (typeof replayOutput.content === \"string\") {\n return { type: \"text\", value: replayOutput.content };\n }\n\n if (replayOutput.kind === \"binary\") {\n return {\n type: \"json\",\n value: toJSONValue(replayOutput)\n };\n }\n\n if (!isModelFileReadOutput(replayOutput)) {\n return {\n type: \"json\",\n value: toJSONValue(replayOutput)\n };\n }\n\n if (!isReadToolInput(input)) {\n return {\n type: \"json\",\n value: toJSONValue(replayOutput)\n };\n }\n\n const bytes = await ops.readFileBytes(input.path);\n if (bytes === null) {\n return {\n type: \"error-text\",\n value: `Could not read file bytes: ${input.path}`\n };\n }\n if (bytes.byteLength > MAX_MODEL_FILE_BYTES) {\n return {\n type: \"error-text\",\n value:\n `Read ${replayOutput.path} (${replayOutput.mediaType}, ${formatSize(bytes.byteLength)}), ` +\n `but it exceeds the ${formatSize(MAX_MODEL_FILE_BYTES)} inline model output limit.`\n };\n }\n\n const data = uint8ArrayToBase64(bytes);\n const note = `Read ${replayOutput.path} (${replayOutput.mediaType}, ${formatSize(bytes.byteLength)}).`;\n\n // AI SDK v6 routes `image-data` as an image but `file-data` as a\n // document. v7 accepts and normalizes `image-data`, so preserve this\n // distinction across both supported majors.\n if (replayOutput.kind === \"image\") {\n return {\n type: \"content\",\n value: [\n { type: \"text\", text: note },\n { type: \"image-data\", data, mediaType: replayOutput.mediaType }\n ]\n };\n }\n\n return {\n type: \"content\",\n value: [\n { type: \"text\", text: note },\n {\n // `file-data` (base64 string `data`) is accepted by both AI SDK v6\n // and v7. v7 also offers the newer `{ type: \"file\", data: { type:\n // \"data\", data } }` shape, but that does not exist in v6, so we use\n // the cross-major form here.\n type: \"file-data\",\n data,\n mediaType: replayOutput.mediaType,\n filename: replayOutput.name\n }\n ]\n };\n }\n });\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction isModelFileReadOutput(\n value: Record<string, unknown>\n): value is ImageReadToolOutput | FileReadToolOutput {\n return (\n (value.kind === \"image\" || value.kind === \"file\") &&\n typeof value.path === \"string\" &&\n typeof value.name === \"string\" &&\n typeof value.mediaType === \"string\"\n );\n}\n\nfunction isReadToolInput(value: unknown): value is ReadToolInput {\n return isRecord(value) && typeof value.path === \"string\";\n}\n\nfunction toJSONValue(value: unknown): JSONValue {\n try {\n const json = JSON.stringify(value);\n return json === undefined ? null : (JSON.parse(json) as JSONValue);\n } catch {\n return String(value);\n }\n}\n\nfunction readTextWithLineNumbers({\n ops,\n path,\n offset,\n limit\n}: {\n ops: ReadOperations;\n path: string;\n offset?: number;\n limit?: number;\n}): Promise<TextReadToolOutput | ReadToolError> {\n return Promise.resolve(ops.readFile(path)).then((content) => {\n if (content === null) {\n return { error: `Could not read file: ${path}` };\n }\n\n const allLines = content.split(\"\\n\");\n const totalLines = allLines.length;\n\n // Apply offset/limit\n const startLine = offset ? offset - 1 : 0;\n const endLine = limit ? startLine + limit : allLines.length;\n const lines = allLines.slice(startLine, endLine);\n\n // Format with line numbers, truncate long lines\n const numbered = lines.map((line, i) => {\n const lineNum = startLine + i + 1;\n const truncated =\n line.length > MAX_LINE_LENGTH\n ? line.slice(0, MAX_LINE_LENGTH) + \"... (truncated)\"\n : line;\n return `${lineNum}\\t${truncated}`;\n });\n\n // Truncate if too many lines\n let output: string;\n if (numbered.length > MAX_LINES) {\n output =\n numbered.slice(0, MAX_LINES).join(\"\\n\") +\n `\\n... (${numbered.length - MAX_LINES} more lines truncated)`;\n } else {\n output = numbered.join(\"\\n\");\n }\n\n const result: TextReadToolOutput = {\n path,\n content: output,\n totalLines\n };\n\n if (offset || limit) {\n result.fromLine = startLine + 1;\n result.toLine = Math.min(endLine, totalLines);\n }\n\n return result;\n });\n}\n\nasync function detectWorkspaceMediaType({\n ops,\n path,\n stat\n}: {\n ops: ReadOperations;\n path: string;\n stat: FileInfo;\n}): Promise<string> {\n const statMime = normalizeMediaType(stat.mimeType);\n if (statMime && !isGenericMediaType(statMime)) {\n return statMime;\n }\n\n const bytes = await ops.readFileBytes(path);\n if (bytes === null) {\n return statMime || \"application/octet-stream\";\n }\n\n const sniffed = sniffMediaType(bytes);\n if (sniffed) {\n return sniffed;\n }\n\n return looksLikeText(bytes) ? \"text/plain\" : \"application/octet-stream\";\n}\n\nfunction normalizeMediaType(mediaType: string | undefined): string | null {\n const normalized = mediaType?.split(\";\")[0]?.trim().toLowerCase();\n return normalized || null;\n}\n\nfunction isGenericMediaType(mediaType: string): boolean {\n return (\n mediaType === \"application/octet-stream\" ||\n mediaType === \"binary/octet-stream\"\n );\n}\n\nfunction isTextMediaType(mediaType: string): boolean {\n return (\n mediaType.startsWith(\"text/\") ||\n mediaType === \"application/json\" ||\n mediaType === \"application/javascript\" ||\n mediaType === \"application/typescript\" ||\n mediaType === \"application/xml\" ||\n mediaType === \"application/x-javascript\" ||\n mediaType.endsWith(\"+json\") ||\n mediaType.endsWith(\"+xml\")\n );\n}\n\nfunction sniffMediaType(bytes: Uint8Array): string | null {\n if (startsWith(bytes, [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])) {\n return \"image/png\";\n }\n if (startsWith(bytes, [0xff, 0xd8, 0xff])) {\n return \"image/jpeg\";\n }\n if (startsWithAscii(bytes, \"GIF87a\") || startsWithAscii(bytes, \"GIF89a\")) {\n return \"image/gif\";\n }\n if (startsWithAscii(bytes, \"RIFF\") && asciiAt(bytes, 8, 12) === \"WEBP\") {\n return \"image/webp\";\n }\n if (startsWithAscii(bytes, \"%PDF-\")) {\n return \"application/pdf\";\n }\n if (looksLikeSvg(bytes)) {\n return \"image/svg+xml\";\n }\n return null;\n}\n\nfunction startsWith(bytes: Uint8Array, prefix: number[]): boolean {\n if (bytes.length < prefix.length) return false;\n return prefix.every((byte, index) => bytes[index] === byte);\n}\n\nfunction startsWithAscii(bytes: Uint8Array, prefix: string): boolean {\n return asciiAt(bytes, 0, prefix.length) === prefix;\n}\n\nfunction asciiAt(bytes: Uint8Array, start: number, end: number): string {\n return String.fromCharCode(...bytes.subarray(start, end));\n}\n\nfunction looksLikeSvg(bytes: Uint8Array): boolean {\n const prefix = new TextDecoder()\n .decode(bytes.subarray(0, Math.min(bytes.length, 512)))\n .trimStart()\n .toLowerCase();\n return prefix.startsWith(\"<svg\") || prefix.includes(\"<svg\");\n}\n\nfunction looksLikeText(bytes: Uint8Array): boolean {\n if (bytes.length === 0) return true;\n if (bytes.includes(0)) return false;\n\n const text = new TextDecoder().decode(bytes.subarray(0, 4096));\n if (text.length === 0) return true;\n\n let replacementChars = 0;\n for (const char of text) {\n if (char === \"\\uFFFD\") {\n replacementChars++;\n }\n }\n return replacementChars / text.length < 0.01;\n}\n\nfunction uint8ArrayToBase64(bytes: Uint8Array): string {\n let binary = \"\";\n const chunkSize = 0x8000;\n for (let i = 0; i < bytes.length; i += chunkSize) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunkSize));\n }\n return btoa(binary);\n}\n\n// ── Write ───────────────────────────────────────────────────────────\n\nexport interface WriteToolOptions {\n ops: WriteOperations;\n}\n\nexport function createWriteTool(options: WriteToolOptions): Tool {\n const { ops } = options;\n\n return tool({\n description:\n \"Write content to a file. Creates the file if it does not exist, \" +\n \"overwrites if it does. Parent directories are created automatically.\",\n inputSchema: z.object({\n path: z.string().describe(\"Absolute path to the file\"),\n content: z.string().describe(\"Content to write to the file\")\n }),\n execute: async ({ path, content }) => {\n // Ensure parent directory exists\n const parent = path.replace(/\\/[^/]+$/, \"\");\n if (parent && parent !== \"/\") {\n await ops.mkdir(parent, { recursive: true });\n }\n\n await ops.writeFile(path, content);\n\n const lines = content.split(\"\\n\").length;\n return {\n path,\n bytesWritten: new TextEncoder().encode(content).byteLength,\n lines\n };\n }\n });\n}\n\n// ── Edit ────────────────────────────────────────────────────────────\n\nexport interface EditToolOptions {\n ops: EditOperations;\n}\n\nexport function createEditTool(options: EditToolOptions): Tool {\n const { ops } = options;\n\n return tool({\n description:\n \"Make a targeted edit to a file by replacing an exact string match. \" +\n \"Provide the old_string to find and new_string to replace it with. \" +\n \"The old_string must match exactly (including whitespace and indentation). \" +\n \"Use an empty old_string with new_string to create a new file.\",\n inputSchema: z.object({\n path: z.string().describe(\"Absolute path to the file\"),\n old_string: z\n .string()\n .describe(\n \"Exact text to find and replace. Empty string to create a new file.\"\n ),\n new_string: z.string().describe(\"Replacement text\")\n }),\n execute: async ({ path, old_string, new_string }) => {\n // Create new file\n if (old_string === \"\") {\n const existing = await ops.readFile(path);\n if (existing !== null) {\n return {\n error:\n \"File already exists. Provide old_string to edit, or use the write tool to overwrite.\"\n };\n }\n await ops.writeFile(path, new_string);\n return {\n path,\n created: true,\n lines: new_string.split(\"\\n\").length\n };\n }\n\n // Edit existing file\n const content = await ops.readFile(path);\n if (content === null) {\n return { error: `File not found: ${path}` };\n }\n\n // Count occurrences\n const occurrences = countOccurrences(content, old_string);\n if (occurrences === 0) {\n // Try fuzzy match — normalize whitespace and look again\n const fuzzyResult = fuzzyReplace(content, old_string, new_string);\n if (fuzzyResult === \"ambiguous\") {\n return {\n error:\n \"old_string matches multiple locations after whitespace normalization. \" +\n \"Include more surrounding context to make the match unique.\"\n };\n }\n if (fuzzyResult !== null) {\n await ops.writeFile(path, fuzzyResult);\n return {\n path,\n replaced: true,\n fuzzyMatch: true,\n lines: fuzzyResult.split(\"\\n\").length\n };\n }\n\n return {\n error:\n \"old_string not found in file. Make sure it matches exactly, \" +\n \"including whitespace and indentation. Read the file first to verify.\"\n };\n }\n\n if (occurrences > 1) {\n return {\n error:\n `old_string appears ${occurrences} times in the file. ` +\n \"Include more surrounding context to make the match unique.\"\n };\n }\n\n const newContent = content.replace(old_string, new_string);\n await ops.writeFile(path, newContent);\n\n return {\n path,\n replaced: true,\n lines: newContent.split(\"\\n\").length\n };\n }\n });\n}\n\nfunction countOccurrences(text: string, search: string): number {\n let count = 0;\n let pos = 0;\n while (true) {\n const idx = text.indexOf(search, pos);\n if (idx === -1) break;\n count++;\n pos = idx + 1;\n }\n return count;\n}\n\n/**\n * Fuzzy replacement: normalize whitespace in both the file content\n * and the search string, find the match, then replace the corresponding\n * region in the original content.\n */\nfunction fuzzyReplace(\n content: string,\n oldStr: string,\n newStr: string\n): string | \"ambiguous\" | null {\n const normalizedContent = normalizeWhitespace(content);\n const normalizedSearch = normalizeWhitespace(oldStr);\n\n if (!normalizedSearch) return null;\n\n const idx = normalizedContent.indexOf(normalizedSearch);\n if (idx === -1) return null;\n\n // Check for multiple fuzzy matches\n const secondIdx = normalizedContent.indexOf(\n normalizedSearch,\n idx + normalizedSearch.length\n );\n if (secondIdx !== -1) return \"ambiguous\";\n\n // Map the normalized index back to the original content.\n // Walk both strings in parallel to find the original start/end.\n const originalStart = mapToOriginal(content, idx);\n const originalEnd = mapToOriginal(content, idx + normalizedSearch.length);\n\n return content.slice(0, originalStart) + newStr + content.slice(originalEnd);\n}\n\nfunction normalizeWhitespace(s: string): string {\n return s.replace(/[ \\t]+/g, \" \").replace(/\\r\\n/g, \"\\n\");\n}\n\n/**\n * Map a position in the normalized string back to the original string.\n * Walks both strings char-by-char, skipping extra whitespace in the original.\n */\nfunction mapToOriginal(original: string, normalizedPos: number): number {\n let ni = 0;\n let oi = 0;\n\n while (ni < normalizedPos && oi < original.length) {\n const oc = original[oi];\n if (oc === \"\\r\" && original[oi + 1] === \"\\n\") {\n // \\r\\n in original maps to \\n in normalized\n oi += 2;\n ni += 1;\n } else if (oc === \" \" || oc === \"\\t\") {\n // Consume a run of spaces/tabs in original → single space in normalized\n oi++;\n while (\n oi < original.length &&\n (original[oi] === \" \" || original[oi] === \"\\t\")\n ) {\n oi++;\n }\n ni++;\n } else {\n oi++;\n ni++;\n }\n }\n\n return oi;\n}\n\n// ── List ────────────────────────────────────────────────────────────\n\nexport interface ListToolOptions {\n ops: ListOperations;\n}\n\nexport function createListTool(options: ListToolOptions): Tool {\n const { ops } = options;\n\n return tool({\n description:\n \"List files and directories in a given path. \" +\n \"Returns names, types, and sizes for each entry.\",\n inputSchema: z.object({\n path: z\n .string()\n .default(\"/\")\n .describe(\"Absolute path to the directory to list\"),\n limit: z\n .number()\n .int()\n .min(1)\n .max(1000)\n .optional()\n .describe(\"Maximum number of entries to return (default: 200)\"),\n offset: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe(\"Number of entries to skip (for pagination)\")\n }),\n execute: async ({ path, limit, offset }) => {\n const maxEntries = limit ?? 200;\n const entries = await ops.readDir(path, {\n limit: maxEntries,\n offset: offset ?? 0\n });\n\n const formatted = entries.map((entry) => {\n const suffix = entry.type === \"directory\" ? \"/\" : \"\";\n const sizeStr =\n entry.type === \"file\" ? ` (${formatSize(entry.size)})` : \"\";\n return `${entry.name}${suffix}${sizeStr}`;\n });\n\n return {\n path,\n count: entries.length,\n entries: formatted\n };\n }\n });\n}\n\nfunction formatSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n// ── Find ────────────────────────────────────────────────────────────\n\nexport interface FindToolOptions {\n ops: FindOperations;\n}\n\nexport function createFindTool(options: FindToolOptions): Tool {\n const { ops } = options;\n\n return tool({\n description:\n \"Find files matching a glob pattern. \" +\n \"Supports standard glob syntax: * matches any file, ** matches directories recursively, \" +\n \"? matches a single character. Returns matching file paths with types and sizes.\",\n inputSchema: z.object({\n pattern: z\n .string()\n .describe(\n 'Glob pattern to match (e.g. \"**/*.ts\", \"src/**/*.test.ts\", \"*.md\")'\n )\n }),\n execute: async ({ pattern }) => {\n const matches = await ops.glob(pattern);\n\n const MAX_RESULTS = 200;\n const truncated = matches.length > MAX_RESULTS;\n const results = matches.slice(0, MAX_RESULTS);\n\n const formatted = results.map((entry) => {\n const suffix = entry.type === \"directory\" ? \"/\" : \"\";\n return `${entry.path}${suffix}`;\n });\n\n const result: Record<string, unknown> = {\n pattern,\n count: matches.length,\n files: formatted\n };\n\n if (truncated) {\n result.truncated = true;\n result.showing = MAX_RESULTS;\n }\n\n return result;\n }\n });\n}\n\n// ── Grep ────────────────────────────────────────────────────────────\n\nconst MAX_MATCHES = 200;\nconst MAX_FILE_SIZE = 1_048_576; // 1 MB — skip files larger than this in grep\n\nexport interface GrepToolOptions {\n ops: GrepOperations;\n}\n\nexport function createGrepTool(options: GrepToolOptions): Tool {\n const { ops } = options;\n\n return tool({\n description:\n \"Search file contents using a regular expression or fixed string. \" +\n \"Returns matching lines with file paths and line numbers. \" +\n \"Searches all files matching the include glob, or all files if not specified.\",\n inputSchema: z.object({\n query: z.string().describe(\"Search pattern (regex or fixed string)\"),\n include: z\n .string()\n .optional()\n .describe(\n 'Glob pattern to filter files (e.g. \"**/*.ts\"). Defaults to \"**/*\"'\n ),\n fixedString: z\n .boolean()\n .optional()\n .describe(\"If true, treat query as a literal string instead of regex\"),\n caseSensitive: z\n .boolean()\n .optional()\n .describe(\"If true, search is case-sensitive (default: false)\"),\n contextLines: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .describe(\"Number of context lines around each match (default: 0)\")\n }),\n execute: async ({\n query,\n include,\n fixedString,\n caseSensitive,\n contextLines\n }) => {\n const pattern = include ?? \"**/*\";\n const allFiles = await ops.glob(pattern);\n const files = allFiles.filter((f: { type: string }) => f.type === \"file\");\n\n let regex: RegExp;\n try {\n const escaped = fixedString ? escapeRegex(query) : query;\n regex = new RegExp(escaped, caseSensitive ? \"g\" : \"gi\");\n } catch {\n return { error: `Invalid regex: ${query}` };\n }\n\n const ctx = contextLines ?? 0;\n const matches: Array<{\n file: string;\n line: number;\n text: string;\n context?: string[];\n }> = [];\n let totalMatches = 0;\n let filesSearched = 0;\n let filesWithMatches = 0;\n\n let filesSkipped = 0;\n\n for (const file of files) {\n if (totalMatches >= MAX_MATCHES) break;\n\n // Skip files larger than 1 MB to avoid memory blowup\n if (file.size > MAX_FILE_SIZE) {\n filesSkipped++;\n continue;\n }\n\n const content = await ops.readFile(file.path);\n if (content === null) continue;\n filesSearched++;\n\n const lines = content.split(\"\\n\");\n let fileHasMatch = false;\n\n for (let i = 0; i < lines.length; i++) {\n if (totalMatches >= MAX_MATCHES) break;\n\n regex.lastIndex = 0;\n if (regex.test(lines[i])) {\n if (!fileHasMatch) {\n fileHasMatch = true;\n filesWithMatches++;\n }\n totalMatches++;\n\n const match: {\n file: string;\n line: number;\n text: string;\n context?: string[];\n } = {\n file: file.path,\n line: i + 1,\n text: lines[i]\n };\n\n if (ctx > 0) {\n const start = Math.max(0, i - ctx);\n const end = Math.min(lines.length, i + ctx + 1);\n match.context = lines.slice(start, end).map((l, j) => {\n const lineNum = start + j + 1;\n const marker = lineNum === i + 1 ? \">\" : \" \";\n return `${marker} ${lineNum}\\t${l}`;\n });\n }\n\n matches.push(match);\n }\n }\n }\n\n const result: Record<string, unknown> = {\n query,\n filesSearched,\n filesWithMatches,\n totalMatches,\n matches: matches.map((m) => {\n if (m.context) {\n return {\n file: m.file,\n line: m.line,\n context: m.context.join(\"\\n\")\n };\n }\n return `${m.file}:${m.line}: ${m.text}`;\n })\n };\n\n if (totalMatches >= MAX_MATCHES) {\n result.truncated = true;\n }\n if (filesSkipped > 0) {\n result.filesSkipped = filesSkipped;\n result.note = `${filesSkipped} file(s) skipped (larger than 1 MB)`;\n }\n\n return result;\n }\n });\n}\n\nfunction escapeRegex(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n// ── Bash ─────────────────────────────────────────────────────────────\n\nconst DEFAULT_BASH_TIMEOUT_MS = 30_000;\nconst DEFAULT_BASH_MAX_WORKSPACE_FILES = 1_000;\nconst DEFAULT_BASH_MAX_WORKSPACE_FILE_BYTES = 1_000_000;\nconst DEFAULT_BASH_MAX_OUTPUT_BYTES = 64_000;\nconst BASH_READDIR_PAGE_SIZE = 1_000;\n// Synthetic paths the bash sandbox creates for itself (shell builtins under\n// /bin and /usr/bin, pseudo-filesystems, scratch space). New files here must\n// never be persisted to the workspace — only pre-existing workspace files\n// under these roots keep syncing.\nconst BASH_EXCLUDED_SYNC_ROOTS = [\"/bin\", \"/usr\", \"/dev\", \"/proc\", \"/sys\"];\n\ntype BashToolInput = {\n script: string;\n cwd?: string;\n};\n\ntype BashChangedFiles = {\n created: string[];\n updated: string[];\n deleted: string[];\n directoriesCreated: string[];\n directoriesDeleted: string[];\n};\n\nexport interface BashToolOptions {\n ops: BashOperations;\n timeout?: number;\n network?: boolean;\n maxWorkspaceFiles?: number;\n maxWorkspaceFileBytes?: number;\n maxOutputBytes?: number;\n}\n\nexport function createBashTool(options: BashToolOptions): Tool {\n return tool({\n description:\n \"Run a Bash script against the workspace. Use for shell-style workflows \" +\n \"that combine multiple file operations. The script runs in a sandboxed \" +\n \"virtual filesystem with the workspace mounted at `/` (also the default \" +\n \"working directory) — there is no `/workspace` or `/home`; use absolute \" +\n \"paths like `/notes.txt`. Changed files are written back to the workspace.\",\n inputSchema: z.object({\n script: z.string().describe(\"Bash script to run\"),\n cwd: z\n .string()\n .optional()\n .describe(\n \"Working directory for the script. Defaults to / (the workspace root)\"\n )\n }),\n execute: async ({ script, cwd }: BashToolInput) => {\n const timeout = options.timeout ?? DEFAULT_BASH_TIMEOUT_MS;\n const maxOutputBytes =\n options.maxOutputBytes ?? DEFAULT_BASH_MAX_OUTPUT_BYTES;\n const snapshot = await snapshotWorkspaceForBash(options);\n const bash = new Bash({\n files: snapshot.files,\n cwd: normalizeWorkspacePath(cwd ?? \"/\"),\n defenseInDepth: true,\n network: options.network ? {} : undefined\n });\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeout);\n let result:\n | {\n stdout: string;\n stderr: string;\n exitCode: number;\n }\n | undefined;\n try {\n for (const directory of snapshot.directories) {\n await bash.fs.mkdir(directory, { recursive: true }).catch(() => {});\n }\n\n try {\n result = await bash.exec(script, {\n cwd: normalizeWorkspacePath(cwd ?? \"/\"),\n signal: controller.signal,\n rawScript: true\n });\n } catch (error) {\n result = {\n stdout: \"\",\n stderr: errorMessage(error),\n exitCode: controller.signal.aborted ? 124 : 1\n };\n }\n\n const sync = await syncBashFilesToWorkspace({\n ops: options.ops,\n bash,\n initialFiles: snapshot.initialFiles,\n initialDirectories: snapshot.initialDirectories,\n protectedPaths: snapshot.protectedPaths\n });\n\n return {\n stdout: truncateToolOutput(result.stdout, maxOutputBytes),\n stderr: truncateToolOutput(result.stderr, maxOutputBytes),\n exitCode: result.exitCode,\n changedFiles: sync.changedFiles,\n ...(snapshot.skippedFiles.length > 0\n ? { skippedFiles: snapshot.skippedFiles }\n : {}),\n ...(sync.errors.length > 0 ? { errors: sync.errors } : {})\n };\n } finally {\n clearTimeout(timer);\n }\n }\n });\n}\n\nasync function snapshotWorkspaceForBash(options: BashToolOptions): Promise<{\n files: InitialFiles;\n initialFiles: Map<string, Uint8Array>;\n initialDirectories: Set<string>;\n protectedPaths: Set<string>;\n directories: string[];\n skippedFiles: string[];\n}> {\n const maxFiles =\n options.maxWorkspaceFiles ?? DEFAULT_BASH_MAX_WORKSPACE_FILES;\n const maxFileBytes =\n options.maxWorkspaceFileBytes ?? DEFAULT_BASH_MAX_WORKSPACE_FILE_BYTES;\n const files: InitialFiles = {};\n const initialFiles = new Map<string, Uint8Array>();\n const initialDirectories = new Set<string>([\"/\"]);\n const protectedPaths = new Set<string>();\n const skippedFiles: string[] = [];\n const pending = [\"/\"];\n\n while (pending.length > 0) {\n const dir = pending.shift()!;\n const entries = await readAllBashDirEntries(options.ops, dir);\n for (const entry of entries) {\n const path = normalizeWorkspacePath(entry.path);\n if (entry.type === \"directory\") {\n initialDirectories.add(path);\n pending.push(path);\n continue;\n }\n if (entry.type !== \"file\") continue;\n if (initialFiles.size >= maxFiles || entry.size > maxFileBytes) {\n protectedPaths.add(path);\n skippedFiles.push(path);\n continue;\n }\n const bytes = await options.ops.readFileBytes(path);\n if (bytes === null) {\n protectedPaths.add(path);\n skippedFiles.push(path);\n continue;\n }\n files[path] = bytes;\n initialFiles.set(path, bytes);\n }\n }\n\n return {\n files,\n initialFiles,\n initialDirectories,\n protectedPaths,\n directories: [...initialDirectories].sort((a, b) => a.localeCompare(b)),\n skippedFiles\n };\n}\n\nasync function readAllBashDirEntries(\n ops: BashOperations,\n dir: string\n): Promise<FileInfo[]> {\n const entries: FileInfo[] = [];\n let offset = 0;\n\n while (true) {\n const page = await ops.readDir(dir, {\n limit: BASH_READDIR_PAGE_SIZE,\n offset\n });\n entries.push(...page);\n if (page.length !== BASH_READDIR_PAGE_SIZE) break;\n offset += page.length;\n }\n\n return entries;\n}\n\nasync function syncBashFilesToWorkspace({\n ops,\n bash,\n initialFiles,\n initialDirectories,\n protectedPaths\n}: {\n ops: BashOperations;\n bash: {\n fs: {\n getAllPaths(): string[];\n stat(path: string): Promise<{ isFile: boolean; isDirectory: boolean }>;\n readFileBuffer(path: string): Promise<Uint8Array>;\n };\n };\n initialFiles: Map<string, Uint8Array>;\n initialDirectories: Set<string>;\n protectedPaths: Set<string>;\n}): Promise<{ changedFiles: BashChangedFiles; errors: string[] }> {\n const changedFiles: BashChangedFiles = {\n created: [],\n updated: [],\n deleted: [],\n directoriesCreated: [],\n directoriesDeleted: []\n };\n const errors: string[] = [];\n const finalFiles = new Map<string, Uint8Array>();\n const finalDirectories = new Set<string>([\"/\"]);\n\n for (const rawPath of bash.fs.getAllPaths()) {\n const path = normalizeWorkspacePath(rawPath);\n if (!shouldSyncBashPath(path, initialFiles, protectedPaths)) continue;\n const stat = await bash.fs.stat(path).catch(() => null);\n if (stat?.isDirectory) {\n finalDirectories.add(path);\n continue;\n }\n if (stat?.isFile) {\n finalFiles.set(path, await bash.fs.readFileBuffer(path));\n }\n }\n\n for (const path of [...finalDirectories].sort((a, b) => a.localeCompare(b))) {\n if (path === \"/\" || initialDirectories.has(path)) continue;\n if (hasProtectedDescendant(path, protectedPaths)) {\n errors.push(\n `Skipped creating directory ${path}: contains protected paths.`\n );\n continue;\n }\n const created = await Promise.resolve(ops.mkdir(path, { recursive: true }))\n .then(() => true)\n .catch((error: unknown) => {\n errors.push(\n `Failed to create directory ${path}: ${errorMessage(error)}`\n );\n return false;\n });\n if (!created) continue;\n changedFiles.directoriesCreated.push(path);\n }\n\n for (const [path, bytes] of finalFiles) {\n if (protectedPaths.has(path)) {\n errors.push(`Skipped writing protected workspace file: ${path}`);\n continue;\n }\n const existing = initialFiles.get(path);\n if (existing && bytesEqual(existing, bytes)) continue;\n const written = await writeWorkspaceBytes(ops, path, bytes, errors);\n if (!written) continue;\n if (existing) changedFiles.updated.push(path);\n else changedFiles.created.push(path);\n }\n\n for (const path of [...initialFiles.keys()].sort((a, b) =>\n b.localeCompare(a)\n )) {\n if (finalFiles.has(path) || protectedPaths.has(path)) continue;\n const deleted = await ops\n .rm(path, { force: true })\n .then(() => true)\n .catch((error: unknown) => {\n errors.push(`Failed to delete ${path}: ${errorMessage(error)}`);\n return false;\n });\n if (!deleted) continue;\n changedFiles.deleted.push(path);\n }\n\n for (const path of [...initialDirectories].sort((a, b) =>\n b.localeCompare(a)\n )) {\n if (path === \"/\" || finalDirectories.has(path)) continue;\n if (hasProtectedDescendant(path, protectedPaths)) {\n errors.push(`Skipped deleting protected workspace directory: ${path}`);\n continue;\n }\n const deleted = await ops\n .rm(path, { recursive: true, force: true })\n .then(() => true)\n .catch((error: unknown) => {\n errors.push(\n `Failed to delete directory ${path}: ${errorMessage(error)}`\n );\n return false;\n });\n if (!deleted) continue;\n changedFiles.directoriesDeleted.push(path);\n }\n\n changedFiles.created.sort();\n changedFiles.updated.sort();\n changedFiles.deleted.sort();\n changedFiles.directoriesCreated.sort();\n changedFiles.directoriesDeleted.sort();\n\n return { changedFiles, errors };\n}\n\nasync function writeWorkspaceBytes(\n ops: BashOperations,\n path: string,\n bytes: Uint8Array,\n errors: string[]\n): Promise<boolean> {\n const parent = parentDir(path);\n if (parent !== \"/\") {\n const parentCreated = await Promise.resolve(\n ops.mkdir(parent, { recursive: true })\n )\n .then(() => true)\n .catch((error: unknown) => {\n errors.push(\n `Failed to create parent directory ${parent}: ${errorMessage(error)}`\n );\n return false;\n });\n if (!parentCreated) return false;\n }\n\n if (ops.writeFileBytes) {\n return ops\n .writeFileBytes(path, bytes)\n .then(() => true)\n .catch((error: unknown) => {\n errors.push(`Failed to write ${path}: ${errorMessage(error)}`);\n return false;\n });\n }\n\n if (!looksLikeText(bytes)) {\n errors.push(\n `Could not persist binary file ${path}: workspace does not support writeFileBytes.`\n );\n return false;\n }\n\n const content = new TextDecoder().decode(bytes);\n return ops\n .writeFile(path, content)\n .then(() => true)\n .catch((error: unknown) => {\n errors.push(`Failed to write ${path}: ${errorMessage(error)}`);\n return false;\n });\n}\n\nfunction shouldSyncBashPath(\n path: string,\n initialFiles: Map<string, Uint8Array>,\n protectedPaths: Set<string>\n): boolean {\n if (path === \"/\") return false;\n if (initialFiles.has(path)) return true;\n if (protectedPaths.has(path)) return true;\n if (path === \"/tmp\" || path.startsWith(\"/tmp/\")) return false;\n return !BASH_EXCLUDED_SYNC_ROOTS.some(\n (root) => path === root || path.startsWith(`${root}/`)\n );\n}\n\nfunction hasProtectedDescendant(\n path: string,\n protectedPaths: Set<string>\n): boolean {\n const prefix = path.endsWith(\"/\") ? path : `${path}/`;\n for (const protectedPath of protectedPaths) {\n if (protectedPath.startsWith(prefix)) return true;\n }\n return false;\n}\n\nfunction normalizeWorkspacePath(path: string): string {\n const parts: string[] = [];\n const raw = path.startsWith(\"/\") ? path : `/${path}`;\n for (const part of raw.split(\"/\")) {\n if (!part || part === \".\") continue;\n if (part === \"..\") parts.pop();\n else parts.push(part);\n }\n return `/${parts.join(\"/\")}`;\n}\n\nfunction parentDir(path: string): string {\n const normalized = normalizeWorkspacePath(path);\n const index = normalized.lastIndexOf(\"/\");\n return index <= 0 ? \"/\" : normalized.slice(0, index);\n}\n\nfunction bytesEqual(a: Uint8Array, b: Uint8Array): boolean {\n if (a.byteLength !== b.byteLength) return false;\n for (let i = 0; i < a.byteLength; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\nfunction truncateToolOutput(value: string, maxBytes: number): string {\n const bytes = new TextEncoder().encode(value);\n if (bytes.byteLength <= maxBytes) return value;\n const truncated = new TextDecoder().decode(bytes.slice(0, maxBytes));\n return `${truncated}\\n... (${formatSize(bytes.byteLength - maxBytes)} truncated)`;\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n// ── Delete ──────────────────────────────────────────────────────────\n\nexport interface DeleteToolOptions {\n ops: DeleteOperations;\n}\n\nexport function createDeleteTool(options: DeleteToolOptions): Tool {\n const { ops } = options;\n\n return tool({\n description:\n \"Delete a file or directory. \" +\n \"Set recursive to true to remove non-empty directories.\",\n inputSchema: z.object({\n path: z.string().describe(\"Absolute path to the file or directory\"),\n recursive: z\n .boolean()\n .optional()\n .describe(\"If true, remove directories and their contents recursively\")\n }),\n execute: async ({ path, recursive }) => {\n await ops.rm(path, { recursive, force: true });\n return { deleted: path };\n }\n });\n}\n"],"mappings":";;;;AAsGA,SAAS,iBAAiB,IAAmC;CAC3D,OAAO;EACL,WAAW,SAAS,GAAG,SAAS,IAAI;EACpC,gBAAgB,SAAS,GAAG,cAAc,IAAI;EAC9C,OAAO,SAAS,GAAG,KAAK,IAAI;CAC9B;AACF;AAEA,SAAS,kBAAkB,IAAoC;CAC7D,OAAO;EACL,YAAY,MAAM,YAAY,GAAG,UAAU,MAAM,OAAO;EACxD,QAAQ,MAAM,SAAS,GAAG,MAAM,MAAM,IAAI;CAC5C;AACF;AAEA,SAAS,iBAAiB,IAAmC;CAC3D,OAAO;EACL,WAAW,SAAS,GAAG,SAAS,IAAI;EACpC,YAAY,MAAM,YAAY,GAAG,UAAU,MAAM,OAAO;CAC1D;AACF;AAEA,SAAS,iBAAiB,IAAmC;CAC3D,OAAO,EACL,UAAU,KAAK,SAAS,GAAG,QAAQ,KAAK,IAAI,EAC9C;AACF;AAEA,SAAS,iBAAiB,IAAmC;CAC3D,OAAO,EACL,OAAO,YAAY,GAAG,KAAK,OAAO,EACpC;AACF;AAEA,SAAS,mBAAmB,IAAqC;CAC/D,OAAO,EACL,KAAK,MAAM,SAAS,GAAG,GAAG,MAAM,IAAI,EACtC;AACF;AAEA,SAAS,iBAAiB,IAAmC;CAC3D,OAAO;EACL,OAAO,YAAY,GAAG,KAAK,OAAO;EAClC,WAAW,SAAS,GAAG,SAAS,IAAI;CACtC;AACF;AAEA,SAAS,iBAAiB,IAAmC;CAC3D,MAAM,mBAAmB;CAGzB,OAAO;EACL,UAA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9C,MAAM,QAAQ,WAAW,YAAY,GAAG;CACxC,OAAO,SAAS,IAAI,MAAM,WAAW,MAAM,GAAG,KAAK;AACrD;AAEA,SAAS,WAAW,GAAe,GAAwB;CACzD,IAAI,EAAE,eAAe,EAAE,YAAY,OAAO;CAC1C,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,YAAY,KAChC,IAAI,EAAE,OAAO,EAAE,IAAI,OAAO;CAE5B,OAAO;AACT;AAEA,SAAS,mBAAmB,OAAe,UAA0B;CACnE,MAAM,QAAQ,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;CAC5C,IAAI,MAAM,cAAc,UAAU,OAAO;CAEzC,OAAO,GADW,IAAI,YAAY,CAAC,CAAC,OAAO,MAAM,MAAM,GAAG,QAAQ,CAChD,EAAE,SAAS,WAAW,MAAM,aAAa,QAAQ,EAAE;AACvE;AAEA,SAAS,aAAa,OAAwB;CAC5C,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;AAQA,SAAgB,iBAAiB,SAAkC;CACjE,MAAM,EAAE,QAAQ;CAEhB,OAAO,KAAK;EACV,aACE;EAEF,aAAa,EAAE,OAAO;GACpB,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS,wCAAwC;GAClE,WAAW,EACR,QAAQ,CAAC,CACT,SAAS,CAAC,CACV,SAAS,4DAA4D;EAC1E,CAAC;EACD,SAAS,OAAO,EAAE,MAAM,gBAAgB;GACtC,MAAM,IAAI,GAAG,MAAM;IAAE;IAAW,OAAO;GAAK,CAAC;GAC7C,OAAO,EAAE,SAAS,KAAK;EACzB;CACF,CAAC;AACH"}
@@ -1,201 +0,0 @@
1
- import { Tool } from "ai";
2
- import { FileInfo, Workspace } from "@cloudflare/shell";
3
-
4
- //#region src/tools/workspace.d.ts
5
- type WorkspaceLike = Pick<
6
- Workspace,
7
- | "readFile"
8
- | "readFileBytes"
9
- | "writeFile"
10
- | "readDir"
11
- | "rm"
12
- | "glob"
13
- | "mkdir"
14
- | "stat"
15
- > &
16
- /**
17
- * Optional so a custom workspace written before it existed still
18
- * satisfies the type. Media eviction and skills projection need it and
19
- * become no-ops (with a warning) when it is absent.
20
- */
21
- Partial<Pick<Workspace, "writeFileBytes">>;
22
- interface ReadOperations {
23
- readFile(path: string): Promise<string | null>;
24
- readFileBytes(path: string): Promise<Uint8Array | null>;
25
- stat(path: string): Promise<FileInfo | null> | FileInfo | null;
26
- }
27
- interface WriteOperations {
28
- writeFile(path: string, content: string): Promise<void>;
29
- mkdir(
30
- path: string,
31
- opts?: {
32
- recursive?: boolean;
33
- }
34
- ): Promise<void> | void;
35
- }
36
- interface EditOperations {
37
- readFile(path: string): Promise<string | null>;
38
- writeFile(path: string, content: string): Promise<void>;
39
- }
40
- interface ListOperations {
41
- readDir(
42
- dir: string,
43
- opts?: {
44
- limit?: number;
45
- offset?: number;
46
- }
47
- ): Promise<FileInfo[]> | FileInfo[];
48
- }
49
- interface FindOperations {
50
- glob(pattern: string): Promise<FileInfo[]> | FileInfo[];
51
- }
52
- interface DeleteOperations {
53
- rm(
54
- path: string,
55
- opts?: {
56
- recursive?: boolean;
57
- force?: boolean;
58
- }
59
- ): Promise<void>;
60
- }
61
- interface GrepOperations {
62
- glob(pattern: string): Promise<FileInfo[]> | FileInfo[];
63
- readFile(path: string): Promise<string | null>;
64
- }
65
- interface BashOperations {
66
- readDir(
67
- dir: string,
68
- opts?: {
69
- limit?: number;
70
- offset?: number;
71
- }
72
- ): Promise<FileInfo[]> | FileInfo[];
73
- readFileBytes(path: string): Promise<Uint8Array | null>;
74
- writeFile(path: string, content: string): Promise<void>;
75
- writeFileBytes?: (path: string, content: Uint8Array) => Promise<void>;
76
- mkdir(
77
- path: string,
78
- opts?: {
79
- recursive?: boolean;
80
- }
81
- ): Promise<void> | void;
82
- rm(
83
- path: string,
84
- opts?: {
85
- recursive?: boolean;
86
- force?: boolean;
87
- }
88
- ): Promise<void>;
89
- }
90
- interface WorkspaceToolsOptions {
91
- /**
92
- * Include the default workspace Bash tool. Enabled by default; pass `false`
93
- * to omit it, or an options object to tune execution limits.
94
- */
95
- bash?: boolean | Omit<BashToolOptions, "ops">;
96
- }
97
- type WorkspaceTools = {
98
- read: ReturnType<typeof createReadTool>;
99
- write: ReturnType<typeof createWriteTool>;
100
- edit: ReturnType<typeof createEditTool>;
101
- list: ReturnType<typeof createListTool>;
102
- find: ReturnType<typeof createFindTool>;
103
- grep: ReturnType<typeof createGrepTool>;
104
- delete: ReturnType<typeof createDeleteTool>;
105
- bash?: ReturnType<typeof createBashTool>;
106
- };
107
- /**
108
- * Create a complete set of AI SDK tools backed by a workspace.
109
- *
110
- * Accepts either a concrete `Workspace` from `@cloudflare/shell` or any
111
- * `WorkspaceLike` implementation — e.g. a proxy that forwards calls to a
112
- * shared workspace owned by a parent DO.
113
- *
114
- * ```ts
115
- * import { Workspace } from "@cloudflare/shell";
116
- * import { createWorkspaceTools } from "@cloudflare/think";
117
- *
118
- * class MyAgent extends Agent<Env> {
119
- * workspace = new Workspace({ sql: this.ctx.storage.sql, name: () => this.name });
120
- *
121
- * async onChatMessage() {
122
- * const tools = createWorkspaceTools(this.workspace);
123
- * const result = streamText({ model, tools, messages });
124
- * return result.toUIMessageStreamResponse();
125
- * }
126
- * }
127
- * ```
128
- */
129
- declare function createWorkspaceTools(
130
- workspace: WorkspaceLike,
131
- options?: WorkspaceToolsOptions
132
- ): WorkspaceTools;
133
- interface ReadToolOptions {
134
- ops: ReadOperations;
135
- }
136
- declare function createReadTool(options: ReadToolOptions): Tool;
137
- interface WriteToolOptions {
138
- ops: WriteOperations;
139
- }
140
- declare function createWriteTool(options: WriteToolOptions): Tool;
141
- interface EditToolOptions {
142
- ops: EditOperations;
143
- }
144
- declare function createEditTool(options: EditToolOptions): Tool;
145
- interface ListToolOptions {
146
- ops: ListOperations;
147
- }
148
- declare function createListTool(options: ListToolOptions): Tool;
149
- interface FindToolOptions {
150
- ops: FindOperations;
151
- }
152
- declare function createFindTool(options: FindToolOptions): Tool;
153
- interface GrepToolOptions {
154
- ops: GrepOperations;
155
- }
156
- declare function createGrepTool(options: GrepToolOptions): Tool;
157
- interface BashToolOptions {
158
- ops: BashOperations;
159
- timeout?: number;
160
- network?: boolean;
161
- maxWorkspaceFiles?: number;
162
- maxWorkspaceFileBytes?: number;
163
- maxOutputBytes?: number;
164
- }
165
- declare function createBashTool(options: BashToolOptions): Tool;
166
- interface DeleteToolOptions {
167
- ops: DeleteOperations;
168
- }
169
- declare function createDeleteTool(options: DeleteToolOptions): Tool;
170
- //#endregion
171
- export {
172
- createFindTool as C,
173
- createWorkspaceTools as D,
174
- createReadTool as E,
175
- createWriteTool as O,
176
- createEditTool as S,
177
- createListTool as T,
178
- WorkspaceToolsOptions as _,
179
- EditOperations as a,
180
- createBashTool as b,
181
- FindToolOptions as c,
182
- ListOperations as d,
183
- ListToolOptions as f,
184
- WorkspaceTools as g,
185
- WorkspaceLike as h,
186
- DeleteToolOptions as i,
187
- GrepOperations as l,
188
- ReadToolOptions as m,
189
- BashToolOptions as n,
190
- EditToolOptions as o,
191
- ReadOperations as p,
192
- DeleteOperations as r,
193
- FindOperations as s,
194
- BashOperations as t,
195
- GrepToolOptions as u,
196
- WriteOperations as v,
197
- createGrepTool as w,
198
- createDeleteTool as x,
199
- WriteToolOptions as y
200
- };
201
- //# sourceMappingURL=workspace-CNeXc2vl.d.ts.map