@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.
- package/README.md +420 -43
- package/dist/chat-sdk-Bb93yaZh.js +669 -0
- package/dist/chat-sdk-Bb93yaZh.js.map +1 -0
- package/dist/{classPrivateFieldGet2-BP1jgEfY.js → classPrivateFieldGet2-D_obpP6O.js} +5 -5
- package/dist/extensions/index.d.ts +2 -2
- package/dist/extensions/index.js +2 -2
- package/dist/{hook-proxy-5248W-ea.js → hook-proxy-CkF0EhRO.js} +1 -1
- package/dist/{hook-proxy-5248W-ea.js.map → hook-proxy-CkF0EhRO.js.map} +1 -1
- package/dist/{index-BsB4GUsL.d.ts → index-B-zgBVj2.d.ts} +2 -2
- package/dist/index-DpPdyY46.d.ts +2309 -0
- package/dist/{manager-px912SoZ.js → manager-DnCkoyVo.js} +3 -3
- package/dist/{manager-px912SoZ.js.map → manager-DnCkoyVo.js.map} +1 -1
- package/dist/{manager-DCbSiSWT.d.ts → manager-dOcdCX4u.d.ts} +1 -1
- package/dist/messengers/index.d.ts +110 -0
- package/dist/messengers/index.js +2 -0
- package/dist/messengers/telegram.d.ts +62 -0
- package/dist/messengers/telegram.js +84 -0
- package/dist/messengers/telegram.js.map +1 -0
- package/dist/think.d.ts +73 -1160
- package/dist/think.js +2391 -204
- package/dist/think.js.map +1 -1
- package/dist/tools/extensions.d.ts +1 -1
- package/dist/tools/extensions.js +1 -1
- package/dist/tools/workspace.d.ts +35 -334
- package/dist/tools/workspace.js +283 -3
- package/dist/tools/workspace.js.map +1 -1
- package/dist/workflows.d.ts +78 -0
- package/dist/workflows.js +119 -0
- package/dist/workflows.js.map +1 -0
- package/dist/workspace-BZXdZcuw.d.ts +342 -0
- package/package.json +25 -8
package/dist/tools/extensions.js
CHANGED
|
@@ -1,337 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|