@cloudflare/think 0.7.3 → 0.8.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,7 +1,7 @@
1
1
  import {
2
2
  a as ExtensionPermissions,
3
3
  t as ExtensionManager
4
- } from "../manager-DCbSiSWT.js";
4
+ } from "../manager-dOcdCX4u.js";
5
5
  //#region src/tools/extensions.d.ts
6
6
  interface ExtensionToolsOptions {
7
7
  manager: ExtensionManager;
@@ -1,4 +1,4 @@
1
- import { r as sanitizeName } from "../manager-px912SoZ.js";
1
+ import { r as sanitizeName } from "../manager-DnCkoyVo.js";
2
2
  import { tool } from "ai";
3
3
  import { z } from "zod";
4
4
  //#region src/tools/extensions.ts
@@ -1,337 +1,36 @@
1
- import { FileInfo, Workspace } from "@cloudflare/shell";
2
-
3
- //#region src/tools/workspace.d.ts
4
- type WorkspaceLike = Pick<
5
- Workspace,
6
- | "readFile"
7
- | "readFileBytes"
8
- | "writeFile"
9
- | "readDir"
10
- | "rm"
11
- | "glob"
12
- | "mkdir"
13
- | "stat"
14
- >;
15
- interface ReadOperations {
16
- readFile(path: string): Promise<string | null>;
17
- readFileBytes(path: string): Promise<Uint8Array | null>;
18
- stat(path: string): Promise<FileInfo | null> | FileInfo | null;
19
- }
20
- interface WriteOperations {
21
- writeFile(path: string, content: string): Promise<void>;
22
- mkdir(
23
- path: string,
24
- opts?: {
25
- recursive?: boolean;
26
- }
27
- ): Promise<void> | void;
28
- }
29
- interface EditOperations {
30
- readFile(path: string): Promise<string | null>;
31
- writeFile(path: string, content: string): Promise<void>;
32
- }
33
- interface ListOperations {
34
- readDir(
35
- dir: string,
36
- opts?: {
37
- limit?: number;
38
- offset?: number;
39
- }
40
- ): Promise<FileInfo[]> | FileInfo[];
41
- }
42
- interface FindOperations {
43
- glob(pattern: string): Promise<FileInfo[]> | FileInfo[];
44
- }
45
- interface DeleteOperations {
46
- rm(
47
- path: string,
48
- opts?: {
49
- recursive?: boolean;
50
- force?: boolean;
51
- }
52
- ): Promise<void>;
53
- }
54
- interface GrepOperations {
55
- glob(pattern: string): Promise<FileInfo[]> | FileInfo[];
56
- readFile(path: string): Promise<string | null>;
57
- }
58
- /**
59
- * Create a complete set of AI SDK tools backed by a workspace.
60
- *
61
- * Accepts either a concrete `Workspace` from `@cloudflare/shell` or any
62
- * `WorkspaceLike` implementation — e.g. a proxy that forwards calls to a
63
- * shared workspace owned by a parent DO.
64
- *
65
- * ```ts
66
- * import { Workspace } from "@cloudflare/shell";
67
- * import { createWorkspaceTools } from "@cloudflare/think";
68
- *
69
- * class MyAgent extends Agent<Env> {
70
- * workspace = new Workspace({ sql: this.ctx.storage.sql, name: () => this.name });
71
- *
72
- * async onChatMessage() {
73
- * const tools = createWorkspaceTools(this.workspace);
74
- * const result = streamText({ model, tools, messages });
75
- * return result.toUIMessageStreamResponse();
76
- * }
77
- * }
78
- * ```
79
- */
80
- declare function createWorkspaceTools(workspace: WorkspaceLike): {
81
- read: import("ai").Tool<
82
- {
83
- path: string;
84
- offset?: number | undefined;
85
- limit?: number | undefined;
86
- },
87
- ReadToolOutput
88
- >;
89
- write: import("ai").Tool<
90
- {
91
- path: string;
92
- content: string;
93
- },
94
- {
95
- path: string;
96
- bytesWritten: number;
97
- lines: number;
98
- }
99
- >;
100
- edit: import("ai").Tool<
101
- {
102
- path: string;
103
- old_string: string;
104
- new_string: string;
105
- },
106
- | {
107
- error: string;
108
- path?: undefined;
109
- created?: undefined;
110
- lines?: undefined;
111
- replaced?: undefined;
112
- fuzzyMatch?: undefined;
113
- }
114
- | {
115
- path: string;
116
- created: boolean;
117
- lines: number;
118
- error?: undefined;
119
- replaced?: undefined;
120
- fuzzyMatch?: undefined;
121
- }
122
- | {
123
- path: string;
124
- replaced: boolean;
125
- fuzzyMatch: boolean;
126
- lines: number;
127
- error?: undefined;
128
- created?: undefined;
129
- }
130
- | {
131
- path: string;
132
- replaced: boolean;
133
- lines: number;
134
- error?: undefined;
135
- created?: undefined;
136
- fuzzyMatch?: undefined;
137
- }
138
- >;
139
- list: import("ai").Tool<
140
- {
141
- path: string;
142
- limit?: number | undefined;
143
- offset?: number | undefined;
144
- },
145
- {
146
- path: string;
147
- count: number;
148
- entries: string[];
149
- }
150
- >;
151
- find: import("ai").Tool<
152
- {
153
- pattern: string;
154
- },
155
- Record<string, unknown>
156
- >;
157
- grep: import("ai").Tool<
158
- {
159
- query: string;
160
- include?: string | undefined;
161
- fixedString?: boolean | undefined;
162
- caseSensitive?: boolean | undefined;
163
- contextLines?: number | undefined;
164
- },
165
- Record<string, unknown>
166
- >;
167
- delete: import("ai").Tool<
168
- {
169
- path: string;
170
- recursive?: boolean | undefined;
171
- },
172
- {
173
- deleted: string;
174
- }
175
- >;
176
- };
177
- type TextReadToolOutput = {
178
- path: string;
179
- content: string;
180
- totalLines: number;
181
- fromLine?: number;
182
- toLine?: number;
183
- };
184
- type ImageReadToolOutput = {
185
- kind: "image";
186
- path: string;
187
- name: string;
188
- mediaType: string;
189
- sizeBytes: number;
190
- };
191
- type FileReadToolOutput = {
192
- kind: "file";
193
- path: string;
194
- name: string;
195
- mediaType: string;
196
- sizeBytes: number;
197
- };
198
- type BinaryReadToolOutput = {
199
- kind: "binary";
200
- path: string;
201
- name: string;
202
- mediaType: string;
203
- sizeBytes: number;
204
- unsupported: true;
205
- };
206
- type ReadToolError = {
207
- error: string;
208
- };
209
- type ReadToolOutput =
210
- | TextReadToolOutput
211
- | ImageReadToolOutput
212
- | FileReadToolOutput
213
- | BinaryReadToolOutput
214
- | ReadToolError;
215
- interface ReadToolOptions {
216
- ops: ReadOperations;
217
- }
218
- declare function createReadTool(options: ReadToolOptions): import("ai").Tool<
219
- {
220
- path: string;
221
- offset?: number | undefined;
222
- limit?: number | undefined;
223
- },
224
- ReadToolOutput
225
- >;
226
- interface WriteToolOptions {
227
- ops: WriteOperations;
228
- }
229
- declare function createWriteTool(options: WriteToolOptions): import("ai").Tool<
230
- {
231
- path: string;
232
- content: string;
233
- },
234
- {
235
- path: string;
236
- bytesWritten: number;
237
- lines: number;
238
- }
239
- >;
240
- interface EditToolOptions {
241
- ops: EditOperations;
242
- }
243
- declare function createEditTool(options: EditToolOptions): import("ai").Tool<
244
- {
245
- path: string;
246
- old_string: string;
247
- new_string: string;
248
- },
249
- | {
250
- error: string;
251
- path?: undefined;
252
- created?: undefined;
253
- lines?: undefined;
254
- replaced?: undefined;
255
- fuzzyMatch?: undefined;
256
- }
257
- | {
258
- path: string;
259
- created: boolean;
260
- lines: number;
261
- error?: undefined;
262
- replaced?: undefined;
263
- fuzzyMatch?: undefined;
264
- }
265
- | {
266
- path: string;
267
- replaced: boolean;
268
- fuzzyMatch: boolean;
269
- lines: number;
270
- error?: undefined;
271
- created?: undefined;
272
- }
273
- | {
274
- path: string;
275
- replaced: boolean;
276
- lines: number;
277
- error?: undefined;
278
- created?: undefined;
279
- fuzzyMatch?: undefined;
280
- }
281
- >;
282
- interface ListToolOptions {
283
- ops: ListOperations;
284
- }
285
- declare function createListTool(options: ListToolOptions): import("ai").Tool<
286
- {
287
- path: string;
288
- limit?: number | undefined;
289
- offset?: number | undefined;
290
- },
291
- {
292
- path: string;
293
- count: number;
294
- entries: string[];
295
- }
296
- >;
297
- interface FindToolOptions {
298
- ops: FindOperations;
299
- }
300
- declare function createFindTool(options: FindToolOptions): import("ai").Tool<
301
- {
302
- pattern: string;
303
- },
304
- Record<string, unknown>
305
- >;
306
- interface GrepToolOptions {
307
- ops: GrepOperations;
308
- }
309
- declare function createGrepTool(options: GrepToolOptions): import("ai").Tool<
310
- {
311
- query: string;
312
- include?: string | undefined;
313
- fixedString?: boolean | undefined;
314
- caseSensitive?: boolean | undefined;
315
- contextLines?: number | undefined;
316
- },
317
- Record<string, unknown>
318
- >;
319
- interface DeleteToolOptions {
320
- ops: DeleteOperations;
321
- }
322
- declare function createDeleteTool(
323
- options: DeleteToolOptions
324
- ): import("ai").Tool<
325
- {
326
- path: string;
327
- recursive?: boolean | undefined;
328
- },
329
- {
330
- deleted: string;
331
- }
332
- >;
333
- //#endregion
1
+ import {
2
+ C as createFindTool,
3
+ D as createWorkspaceTools,
4
+ E as createReadTool,
5
+ O as createWriteTool,
6
+ S as createEditTool,
7
+ T as createListTool,
8
+ _ as WorkspaceToolsOptions,
9
+ a as EditOperations,
10
+ b as createBashTool,
11
+ c as FindToolOptions,
12
+ d as ListOperations,
13
+ f as ListToolOptions,
14
+ g as WorkspaceTools,
15
+ h as WorkspaceLike,
16
+ i as DeleteToolOptions,
17
+ l as GrepOperations,
18
+ m as ReadToolOptions,
19
+ n as BashToolOptions,
20
+ o as EditToolOptions,
21
+ p as ReadOperations,
22
+ r as DeleteOperations,
23
+ s as FindOperations,
24
+ t as BashOperations,
25
+ u as GrepToolOptions,
26
+ v as WriteOperations,
27
+ w as createGrepTool,
28
+ x as createDeleteTool,
29
+ y as WriteToolOptions
30
+ } from "../workspace-BZXdZcuw.js";
334
31
  export {
32
+ BashOperations,
33
+ BashToolOptions,
335
34
  DeleteOperations,
336
35
  DeleteToolOptions,
337
36
  EditOperations,
@@ -345,8 +44,11 @@ export {
345
44
  ReadOperations,
346
45
  ReadToolOptions,
347
46
  WorkspaceLike,
47
+ WorkspaceTools,
48
+ WorkspaceToolsOptions,
348
49
  WriteOperations,
349
50
  WriteToolOptions,
51
+ createBashTool,
350
52
  createDeleteTool,
351
53
  createEditTool,
352
54
  createFindTool,
@@ -356,4 +58,3 @@ export {
356
58
  createWorkspaceTools,
357
59
  createWriteTool
358
60
  };
359
- //# sourceMappingURL=workspace.d.ts.map