@cuylabs/agent-code 0.1.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.
@@ -0,0 +1,3 @@
1
+ export * from '@cuylabs/agent-core';
2
+ export { BashParams, EditParams, GlobParams, GrepParams, ReadParams, ToolsetBuilder, WriteParams, bashParameters, bashTool, defaultCodingTools, editParameters, editTool, executeBash, executeGrep, globParameters, globTool, grepParameters, grepTool, readParameters, readTool, resolveTools, setupToolRegistry, toolset, writeParameters, writeTool } from './tools/index.js';
3
+ import 'zod';
package/dist/index.js ADDED
@@ -0,0 +1,45 @@
1
+ import {
2
+ ToolsetBuilder,
3
+ bashParameters,
4
+ bashTool,
5
+ defaultCodingTools,
6
+ editParameters,
7
+ editTool,
8
+ executeBash,
9
+ executeGrep,
10
+ globParameters,
11
+ globTool,
12
+ grepParameters,
13
+ grepTool,
14
+ readParameters,
15
+ readTool,
16
+ resolveTools,
17
+ setupToolRegistry,
18
+ toolset,
19
+ writeParameters,
20
+ writeTool
21
+ } from "./chunk-IOXLKDEB.js";
22
+
23
+ // src/index.ts
24
+ export * from "@cuylabs/agent-core";
25
+ export {
26
+ ToolsetBuilder,
27
+ bashParameters,
28
+ bashTool,
29
+ defaultCodingTools,
30
+ editParameters,
31
+ editTool,
32
+ executeBash,
33
+ executeGrep,
34
+ globParameters,
35
+ globTool,
36
+ grepParameters,
37
+ grepTool,
38
+ readParameters,
39
+ readTool,
40
+ resolveTools,
41
+ setupToolRegistry,
42
+ toolset,
43
+ writeParameters,
44
+ writeTool
45
+ };
@@ -0,0 +1,360 @@
1
+ import { Tool, ToolHost, ExecResult, ToolSpec } from '@cuylabs/agent-core';
2
+ import { z } from 'zod';
3
+
4
+ /**
5
+ * Bash tool - Execute shell commands
6
+ * Based on OpenCode's tool/bash.ts patterns
7
+ */
8
+
9
+ declare const bashParameters: z.ZodObject<{
10
+ command: z.ZodString;
11
+ timeout: z.ZodOptional<z.ZodNumber>;
12
+ workdir: z.ZodOptional<z.ZodString>;
13
+ description: z.ZodString;
14
+ }, "strip", z.ZodTypeAny, {
15
+ command: string;
16
+ description: string;
17
+ timeout?: number | undefined;
18
+ workdir?: string | undefined;
19
+ }, {
20
+ command: string;
21
+ description: string;
22
+ timeout?: number | undefined;
23
+ workdir?: string | undefined;
24
+ }>;
25
+ type BashParams = z.infer<typeof bashParameters>;
26
+ /**
27
+ * Execute a bash command via a ToolHost.
28
+ */
29
+ declare function executeBash(params: BashParams, host: ToolHost, cwd: string, abort?: AbortSignal): Promise<ExecResult>;
30
+ /**
31
+ * Bash tool definition
32
+ */
33
+ declare const bashTool: Tool.Info<z.ZodObject<{
34
+ command: z.ZodString;
35
+ timeout: z.ZodOptional<z.ZodNumber>;
36
+ workdir: z.ZodOptional<z.ZodString>;
37
+ description: z.ZodString;
38
+ }, "strip", z.ZodTypeAny, {
39
+ command: string;
40
+ description: string;
41
+ timeout?: number | undefined;
42
+ workdir?: string | undefined;
43
+ }, {
44
+ command: string;
45
+ description: string;
46
+ timeout?: number | undefined;
47
+ workdir?: string | undefined;
48
+ }>, {
49
+ exitCode: number | null;
50
+ timedOut: boolean;
51
+ truncated: boolean;
52
+ outputPath: string | undefined;
53
+ }>;
54
+
55
+ /**
56
+ * Read tool - Read file contents
57
+ * Based on OpenCode's tool/read.ts patterns
58
+ */
59
+
60
+ declare const readParameters: z.ZodObject<{
61
+ filePath: z.ZodString;
62
+ offset: z.ZodOptional<z.ZodNumber>;
63
+ limit: z.ZodOptional<z.ZodNumber>;
64
+ }, "strip", z.ZodTypeAny, {
65
+ filePath: string;
66
+ offset?: number | undefined;
67
+ limit?: number | undefined;
68
+ }, {
69
+ filePath: string;
70
+ offset?: number | undefined;
71
+ limit?: number | undefined;
72
+ }>;
73
+ type ReadParams = z.infer<typeof readParameters>;
74
+ /**
75
+ * Read tool definition
76
+ */
77
+ declare const readTool: Tool.Info<z.ZodObject<{
78
+ filePath: z.ZodString;
79
+ offset: z.ZodOptional<z.ZodNumber>;
80
+ limit: z.ZodOptional<z.ZodNumber>;
81
+ }, "strip", z.ZodTypeAny, {
82
+ filePath: string;
83
+ offset?: number | undefined;
84
+ limit?: number | undefined;
85
+ }, {
86
+ filePath: string;
87
+ offset?: number | undefined;
88
+ limit?: number | undefined;
89
+ }>, {
90
+ totalLines: number;
91
+ linesRead: number;
92
+ offset: number;
93
+ truncated: boolean;
94
+ preview: string;
95
+ }>;
96
+
97
+ /**
98
+ * Edit tool - Edit files by replacing text
99
+ * Based on OpenCode's tool/edit.ts patterns
100
+ */
101
+
102
+ declare const editParameters: z.ZodObject<{
103
+ filePath: z.ZodString;
104
+ oldString: z.ZodString;
105
+ newString: z.ZodString;
106
+ replaceAll: z.ZodOptional<z.ZodBoolean>;
107
+ }, "strip", z.ZodTypeAny, {
108
+ filePath: string;
109
+ oldString: string;
110
+ newString: string;
111
+ replaceAll?: boolean | undefined;
112
+ }, {
113
+ filePath: string;
114
+ oldString: string;
115
+ newString: string;
116
+ replaceAll?: boolean | undefined;
117
+ }>;
118
+ type EditParams = z.infer<typeof editParameters>;
119
+ /**
120
+ * Edit tool definition
121
+ */
122
+ declare const editTool: Tool.Info<z.ZodObject<{
123
+ filePath: z.ZodString;
124
+ oldString: z.ZodString;
125
+ newString: z.ZodString;
126
+ replaceAll: z.ZodOptional<z.ZodBoolean>;
127
+ }, "strip", z.ZodTypeAny, {
128
+ filePath: string;
129
+ oldString: string;
130
+ newString: string;
131
+ replaceAll?: boolean | undefined;
132
+ }, {
133
+ filePath: string;
134
+ oldString: string;
135
+ newString: string;
136
+ replaceAll?: boolean | undefined;
137
+ }>, {
138
+ filepath: string;
139
+ created: boolean;
140
+ additions: number;
141
+ deletions: number;
142
+ diff: string;
143
+ }>;
144
+
145
+ /**
146
+ * Write tool - Create or overwrite files
147
+ * Based on OpenCode's tool/write.ts patterns
148
+ */
149
+
150
+ declare const writeParameters: z.ZodObject<{
151
+ filePath: z.ZodString;
152
+ content: z.ZodString;
153
+ }, "strip", z.ZodTypeAny, {
154
+ filePath: string;
155
+ content: string;
156
+ }, {
157
+ filePath: string;
158
+ content: string;
159
+ }>;
160
+ type WriteParams = z.infer<typeof writeParameters>;
161
+ /**
162
+ * Write tool definition
163
+ */
164
+ declare const writeTool: Tool.Info<z.ZodObject<{
165
+ filePath: z.ZodString;
166
+ content: z.ZodString;
167
+ }, "strip", z.ZodTypeAny, {
168
+ filePath: string;
169
+ content: string;
170
+ }, {
171
+ filePath: string;
172
+ content: string;
173
+ }>, {
174
+ filepath: string;
175
+ created: boolean;
176
+ updated: boolean;
177
+ lines: number;
178
+ }>;
179
+
180
+ /**
181
+ * Grep tool - Search file contents
182
+ * Based on OpenCode's tool/grep.ts patterns
183
+ */
184
+
185
+ declare const grepParameters: z.ZodObject<{
186
+ pattern: z.ZodString;
187
+ path: z.ZodOptional<z.ZodString>;
188
+ include: z.ZodOptional<z.ZodString>;
189
+ }, "strip", z.ZodTypeAny, {
190
+ pattern: string;
191
+ path?: string | undefined;
192
+ include?: string | undefined;
193
+ }, {
194
+ pattern: string;
195
+ path?: string | undefined;
196
+ include?: string | undefined;
197
+ }>;
198
+ type GrepParams = z.infer<typeof grepParameters>;
199
+ /**
200
+ * Execute grep search
201
+ */
202
+ declare function executeGrep(params: GrepParams, host: ToolHost, cwd: string, abort?: AbortSignal): Promise<{
203
+ matches: Array<{
204
+ file: string;
205
+ line: number;
206
+ text: string;
207
+ }>;
208
+ truncated: boolean;
209
+ }>;
210
+ /**
211
+ * Grep tool definition
212
+ */
213
+ declare const grepTool: Tool.Info<z.ZodObject<{
214
+ pattern: z.ZodString;
215
+ path: z.ZodOptional<z.ZodString>;
216
+ include: z.ZodOptional<z.ZodString>;
217
+ }, "strip", z.ZodTypeAny, {
218
+ pattern: string;
219
+ path?: string | undefined;
220
+ include?: string | undefined;
221
+ }, {
222
+ pattern: string;
223
+ path?: string | undefined;
224
+ include?: string | undefined;
225
+ }>, {
226
+ matches: number;
227
+ truncated: boolean;
228
+ }>;
229
+
230
+ /**
231
+ * Glob tool - Find files by pattern
232
+ * Based on OpenCode's tool/glob.ts patterns
233
+ */
234
+
235
+ declare const globParameters: z.ZodObject<{
236
+ pattern: z.ZodString;
237
+ path: z.ZodOptional<z.ZodString>;
238
+ }, "strip", z.ZodTypeAny, {
239
+ pattern: string;
240
+ path?: string | undefined;
241
+ }, {
242
+ pattern: string;
243
+ path?: string | undefined;
244
+ }>;
245
+ type GlobParams = z.infer<typeof globParameters>;
246
+ /**
247
+ * Glob tool definition
248
+ */
249
+ declare const globTool: Tool.Info<z.ZodObject<{
250
+ pattern: z.ZodString;
251
+ path: z.ZodOptional<z.ZodString>;
252
+ }, "strip", z.ZodTypeAny, {
253
+ pattern: string;
254
+ path?: string | undefined;
255
+ }, {
256
+ pattern: string;
257
+ path?: string | undefined;
258
+ }>, {
259
+ count: number;
260
+ truncated: boolean;
261
+ }>;
262
+
263
+ /**
264
+ * Default tool collections
265
+ */
266
+
267
+ /**
268
+ * Default tools for a coding agent
269
+ */
270
+ declare const defaultCodingTools: Tool.AnyInfo[];
271
+
272
+ /**
273
+ * Tool composition and registry setup for @cuylabs/agent-code.
274
+ *
275
+ * Registers all coding tools into the default registry, defines standard
276
+ * groups, and provides a fluent `toolset()` builder for easy composition.
277
+ *
278
+ * @example
279
+ * ```typescript
280
+ * import { toolset, resolveTools } from "@cuylabs/agent-code";
281
+ *
282
+ * // Fluent builder
283
+ * const tools = toolset("read-only").add(myCustomTool).build();
284
+ *
285
+ * // Spec-based resolution
286
+ * const tools = resolveTools("all,-bash");
287
+ * const tools = resolveTools("read,grep,glob");
288
+ * const tools = resolveTools("safe");
289
+ * ```
290
+ */
291
+
292
+ /**
293
+ * Register all coding tools and standard groups into the default registry.
294
+ * Uses `set()` (upsert) so it's safe to call multiple times, even after
295
+ * `clear()`.
296
+ */
297
+ declare function setupToolRegistry(): void;
298
+ /**
299
+ * Fluent tool composition builder.
300
+ *
301
+ * @example
302
+ * ```typescript
303
+ * // Start from a group and customize
304
+ * const tools = toolset("read-only").add(myTool).build();
305
+ *
306
+ * // Start from all and exclude
307
+ * const tools = toolset("all").remove("bash").build();
308
+ *
309
+ * // Start empty and pick
310
+ * const tools = toolset().add("read").add("grep").build();
311
+ * ```
312
+ */
313
+ declare class ToolsetBuilder {
314
+ private tools;
315
+ constructor(base?: ToolSpec);
316
+ /** Add a tool by ID (from registry) or by instance. */
317
+ add(tool: string | Tool.AnyInfo): this;
318
+ /** Remove a tool by ID. */
319
+ remove(id: string): this;
320
+ /** Keep only the specified tool IDs (intersection). */
321
+ only(...ids: string[]): this;
322
+ /** Return the final tool array. */
323
+ build(): Tool.AnyInfo[];
324
+ }
325
+ /**
326
+ * Create a toolset builder with an optional base spec.
327
+ *
328
+ * @param base Starting point — group name, tool IDs, boolean, or array.
329
+ * Defaults to empty (call `.add()` to populate).
330
+ *
331
+ * @example
332
+ * ```typescript
333
+ * // All tools except bash
334
+ * const tools = toolset("all").remove("bash").build();
335
+ *
336
+ * // Read-only with a custom tool
337
+ * const tools = toolset("read-only").add(mySearchTool).build();
338
+ * ```
339
+ */
340
+ declare function toolset(base?: ToolSpec): ToolsetBuilder;
341
+ /**
342
+ * Resolve a tool spec to an array of tools.
343
+ *
344
+ * Ensures the coding tool registry is initialized, then delegates to
345
+ * `defaultRegistry.resolve()`.
346
+ *
347
+ * @param spec Group name, comma-separated IDs, boolean, or array.
348
+ *
349
+ * @example
350
+ * ```typescript
351
+ * resolveTools("read-only"); // → [readTool, grepTool, globTool]
352
+ * resolveTools("all,-bash"); // → all except bash
353
+ * resolveTools("read,grep"); // → [readTool, grepTool]
354
+ * resolveTools(true); // → all coding tools
355
+ * resolveTools(false); // → []
356
+ * ```
357
+ */
358
+ declare function resolveTools(spec: ToolSpec): Tool.AnyInfo[];
359
+
360
+ export { type BashParams, type EditParams, type GlobParams, type GrepParams, type ReadParams, ToolsetBuilder, type WriteParams, bashParameters, bashTool, defaultCodingTools, editParameters, editTool, executeBash, executeGrep, globParameters, globTool, grepParameters, grepTool, readParameters, readTool, resolveTools, setupToolRegistry, toolset, writeParameters, writeTool };
@@ -0,0 +1,42 @@
1
+ import {
2
+ ToolsetBuilder,
3
+ bashParameters,
4
+ bashTool,
5
+ defaultCodingTools,
6
+ editParameters,
7
+ editTool,
8
+ executeBash,
9
+ executeGrep,
10
+ globParameters,
11
+ globTool,
12
+ grepParameters,
13
+ grepTool,
14
+ readParameters,
15
+ readTool,
16
+ resolveTools,
17
+ setupToolRegistry,
18
+ toolset,
19
+ writeParameters,
20
+ writeTool
21
+ } from "../chunk-IOXLKDEB.js";
22
+ export {
23
+ ToolsetBuilder,
24
+ bashParameters,
25
+ bashTool,
26
+ defaultCodingTools,
27
+ editParameters,
28
+ editTool,
29
+ executeBash,
30
+ executeGrep,
31
+ globParameters,
32
+ globTool,
33
+ grepParameters,
34
+ grepTool,
35
+ readParameters,
36
+ readTool,
37
+ resolveTools,
38
+ setupToolRegistry,
39
+ toolset,
40
+ writeParameters,
41
+ writeTool
42
+ };
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@cuylabs/agent-code",
3
+ "version": "0.1.0",
4
+ "description": "Embeddable AI coding agent built on @cuylabs/agent-core",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./tools": {
15
+ "types": "./dist/tools/index.d.ts",
16
+ "import": "./dist/tools/index.js",
17
+ "default": "./dist/tools/index.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README.md"
23
+ ],
24
+ "scripts": {
25
+ "build": "tsup src/index.ts src/tools/index.ts --format esm --dts --clean",
26
+ "dev": "tsup src/index.ts src/tools/index.ts --format esm --dts --watch",
27
+ "typecheck": "tsc --noEmit",
28
+ "test": "vitest run"
29
+ },
30
+ "dependencies": {
31
+ "@cuylabs/agent-core": "workspace:*",
32
+ "ai": "^6.0.67",
33
+ "zod": "^3.24.0"
34
+ },
35
+ "peerDependencies": {
36
+ "@ai-sdk/anthropic": "^3.0.0",
37
+ "@ai-sdk/google": "^1.0.0",
38
+ "@ai-sdk/openai": "^3.0.0"
39
+ },
40
+ "peerDependenciesMeta": {
41
+ "@ai-sdk/anthropic": {
42
+ "optional": true
43
+ },
44
+ "@ai-sdk/openai": {
45
+ "optional": true
46
+ },
47
+ "@ai-sdk/google": {
48
+ "optional": true
49
+ }
50
+ },
51
+ "devDependencies": {
52
+ "@ai-sdk/anthropic": "^3.0.35",
53
+ "@ai-sdk/openai": "^3.0.25",
54
+ "@types/node": "^22.0.0",
55
+ "dotenv": "^17.2.3",
56
+ "tsup": "^8.0.0",
57
+ "typescript": "^5.7.0",
58
+ "vitest": "^3.0.0"
59
+ },
60
+ "keywords": [
61
+ "ai",
62
+ "agent",
63
+ "llm",
64
+ "vercel-ai-sdk",
65
+ "embeddable",
66
+ "coding-agent"
67
+ ],
68
+ "author": "cuylabs",
69
+ "license": "Apache-2.0",
70
+ "repository": {
71
+ "type": "git",
72
+ "url": "https://github.com/cuylabs-ai/agents-ts.git",
73
+ "directory": "packages/agent-code"
74
+ }
75
+ }