@townco/agent 0.1.21 → 0.1.23

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.
Files changed (46) hide show
  1. package/dist/acp-server/adapter.d.ts +10 -14
  2. package/dist/acp-server/cli.d.ts +1 -3
  3. package/dist/acp-server/cli.js +5 -9
  4. package/dist/acp-server/http.d.ts +1 -3
  5. package/dist/bin.js +0 -0
  6. package/dist/definition/index.d.ts +6 -0
  7. package/dist/definition/index.js +9 -0
  8. package/dist/index.js +11 -5
  9. package/dist/runner/agent-runner.d.ts +6 -0
  10. package/dist/runner/index.d.ts +1 -3
  11. package/dist/runner/index.js +14 -18
  12. package/dist/runner/langchain/index.js +10 -0
  13. package/dist/runner/langchain/tools/todo.d.ts +32 -48
  14. package/dist/runner/langchain/tools/todo.js +13 -16
  15. package/dist/runner/langchain/tools/web_search.d.ts +1 -1
  16. package/dist/runner/langchain/tools/web_search.js +18 -21
  17. package/dist/runner/tools.d.ts +16 -0
  18. package/dist/runner/tools.js +10 -1
  19. package/dist/scaffold/copy-gui.js +7 -81
  20. package/dist/scaffold/copy-tui.js +1 -65
  21. package/dist/scaffold/index.d.ts +2 -0
  22. package/dist/scaffold/index.js +26 -31
  23. package/dist/scaffold/project-scaffold.d.ts +12 -0
  24. package/dist/scaffold/project-scaffold.js +314 -0
  25. package/dist/storage/index.d.ts +5 -0
  26. package/dist/storage/index.js +60 -24
  27. package/dist/templates/index.d.ts +7 -2
  28. package/dist/templates/index.js +13 -16
  29. package/dist/tsconfig.tsbuildinfo +1 -1
  30. package/dist/utils/index.d.ts +1 -0
  31. package/dist/utils/index.js +1 -0
  32. package/dist/utils/tool.d.ts +36 -0
  33. package/dist/utils/tool.js +33 -0
  34. package/index.ts +11 -7
  35. package/package.json +6 -5
  36. package/templates/index.ts +23 -18
  37. package/dist/definition/mcp.d.ts +0 -0
  38. package/dist/definition/mcp.js +0 -0
  39. package/dist/definition/tools/todo.d.ts +0 -49
  40. package/dist/definition/tools/todo.js +0 -80
  41. package/dist/definition/tools/web_search.d.ts +0 -4
  42. package/dist/definition/tools/web_search.js +0 -26
  43. package/dist/dev-agent/index.d.ts +0 -2
  44. package/dist/dev-agent/index.js +0 -18
  45. package/dist/example.d.ts +0 -2
  46. package/dist/example.js +0 -19
@@ -1,52 +1,47 @@
1
1
  import { spawn } from "node:child_process";
2
- import { chmod, mkdir, writeFile } from "node:fs/promises";
2
+ import { mkdir, stat, writeFile } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
- import { agentExists, ensureAgentsDir, getAgentPath } from "../storage";
5
- import { generateAgentJson, generateBinTs, generateEnvExample, generateGitignore, generateIndexTs, generatePackageJson, generateReadme, generateTsConfig, getTemplateVars, } from "../templates";
4
+ import { generateBinTs, generateIndexTs, getTemplateVars } from "../templates";
6
5
  import { copyGuiApp } from "./copy-gui";
7
6
  import { copyTuiApp } from "./copy-tui";
8
7
  /**
9
8
  * Scaffold a new agent package
10
9
  */
11
10
  export async function scaffoldAgent(options) {
12
- const { name, definition, overwrite = false, includeGui = true, includeTui = true, } = options;
11
+ const { name, definition, overwrite = false, includeGui = true, includeTui = true, agentsDir, } = options;
13
12
  try {
14
- // Ensure base directory exists
15
- await ensureAgentsDir();
13
+ // Ensure the agents directory exists
14
+ await mkdir(agentsDir, { recursive: true });
16
15
  // Check if agent already exists
17
- const exists = await agentExists(name);
18
- if (exists && !overwrite) {
19
- return {
20
- success: false,
21
- path: getAgentPath(name),
22
- error: `Agent "${name}" already exists. Use overwrite option to replace it.`,
23
- };
16
+ const agentPath = join(agentsDir, name);
17
+ try {
18
+ const agentStat = await stat(agentPath);
19
+ if (agentStat.isDirectory() && !overwrite) {
20
+ return {
21
+ success: false,
22
+ path: agentPath,
23
+ error: `Agent "${name}" already exists. Use overwrite option to replace it.`,
24
+ };
25
+ }
26
+ }
27
+ catch {
28
+ // Agent doesn't exist, which is fine
24
29
  }
25
- const agentPath = getAgentPath(name);
26
30
  // Create the agent directory
27
31
  await mkdir(agentPath, { recursive: true });
28
32
  const vars = getTemplateVars(name, definition);
29
- // Generate all template files
33
+ // Generate template files - just the essentials
30
34
  const files = [
31
- { path: "package.json", content: generatePackageJson(vars) },
32
- { path: "agent.json", content: generateAgentJson(vars) },
33
- { path: "index.ts", content: generateIndexTs() },
35
+ { path: "index.ts", content: await generateIndexTs(vars) },
34
36
  { path: "bin.ts", content: generateBinTs(), executable: true },
35
- { path: "tsconfig.json", content: generateTsConfig() },
36
- { path: "README.md", content: generateReadme(vars) },
37
- { path: ".gitignore", content: generateGitignore() },
38
37
  ];
39
- // Add .env.example if needed
40
- const envExample = generateEnvExample(vars);
41
- if (envExample) {
42
- files.push({ path: ".env.example", content: envExample });
43
- }
44
38
  // Write all files
45
39
  for (const file of files) {
46
40
  const filePath = join(agentPath, file.path);
47
41
  await writeFile(filePath, file.content, "utf-8");
48
- // Make executable if needed
49
- if (file.executable) {
42
+ // Make executable if specified
43
+ if ("executable" in file && file.executable) {
44
+ const { chmod } = await import("node:fs/promises");
50
45
  await chmod(filePath, 0o755);
51
46
  }
52
47
  }
@@ -64,8 +59,6 @@ export async function scaffoldAgent(options) {
64
59
  const tuiPath = join(agentPath, "tui");
65
60
  await runBunInstall(tuiPath);
66
61
  }
67
- // Run bun install in agent root to fetch dependencies from npm
68
- await runBunInstall(agentPath);
69
62
  return {
70
63
  success: true,
71
64
  path: agentPath,
@@ -74,7 +67,7 @@ export async function scaffoldAgent(options) {
74
67
  catch (error) {
75
68
  return {
76
69
  success: false,
77
- path: getAgentPath(name),
70
+ path: join(agentsDir, name),
78
71
  error: error instanceof Error ? error.message : String(error),
79
72
  };
80
73
  }
@@ -101,3 +94,5 @@ function runBunInstall(agentPath) {
101
94
  });
102
95
  });
103
96
  }
97
+ // Export project scaffolding
98
+ export { scaffoldProject } from "./project-scaffold";
@@ -0,0 +1,12 @@
1
+ export interface ScaffoldProjectOptions {
2
+ path: string;
3
+ }
4
+ export interface ScaffoldProjectResult {
5
+ success: boolean;
6
+ path: string;
7
+ error?: string;
8
+ }
9
+ /**
10
+ * Scaffold a new standalone project
11
+ */
12
+ export declare function scaffoldProject(options: ScaffoldProjectOptions): Promise<ScaffoldProjectResult>;
@@ -0,0 +1,314 @@
1
+ import { spawn } from "node:child_process";
2
+ import { mkdir, writeFile } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ /**
5
+ * Generate project package.json
6
+ */
7
+ function generateProjectPackageJson() {
8
+ const pkg = {
9
+ name: "town-agents-project",
10
+ version: "0.1.0",
11
+ type: "module",
12
+ private: true,
13
+ scripts: {},
14
+ dependencies: {
15
+ "@agentclientprotocol/sdk": "^0.5.1",
16
+ "@optique/core": "^0.6.2",
17
+ "@optique/run": "^0.6.2",
18
+ "@radix-ui/react-dialog": "^1.1.15",
19
+ "@radix-ui/react-label": "^2.1.8",
20
+ "@radix-ui/react-select": "^2.2.6",
21
+ "@radix-ui/react-slot": "^1.2.4",
22
+ "@radix-ui/react-tabs": "^1.1.13",
23
+ "@townco/ui": "^0.1.0",
24
+ "@townco/agent": "^0.1.20",
25
+ "class-variance-authority": "^0.7.1",
26
+ clsx: "^2.1.1",
27
+ "ink-text-input": "^6.0.0",
28
+ ink: "^6.4.0",
29
+ "lucide-react": "^0.552.0",
30
+ "react-dom": "^19.2.0",
31
+ "react-markdown": "^10.1.0",
32
+ react: "^19.2.0",
33
+ "remark-gfm": "^4.0.1",
34
+ "tailwind-merge": "^3.3.1",
35
+ zod: "^4.1.12",
36
+ zustand: "^5.0.8",
37
+ },
38
+ devDependencies: {
39
+ "@tailwindcss/postcss": "^4.1.17",
40
+ "@types/react": "^19.2.2",
41
+ "@types/react-dom": "^19.2.2",
42
+ "@vitejs/plugin-react": "^5.1.0",
43
+ autoprefixer: "^10.4.21",
44
+ postcss: "^8.5.6",
45
+ tailwindcss: "^4.1.17",
46
+ typescript: "^5.9.3",
47
+ vite: "^7.2.1",
48
+ },
49
+ };
50
+ return JSON.stringify(pkg, null, 2);
51
+ }
52
+ /**
53
+ * Generate add-two-numbers tool
54
+ */
55
+ function generateAddTwoNumbersTool() {
56
+ return `// biome-ignore lint/suspicious/noExplicitAny: .
57
+ export const schema = (z: any) =>
58
+ z.object({
59
+ a: z.number().describe("First number"),
60
+ b: z.number().describe("Second number"),
61
+ });
62
+
63
+ export const name = "add_two_numbers";
64
+ export const description = "Add two numbers together and return the result";
65
+
66
+ export default function addTwoNumbers(input: unknown) {
67
+ const { a, b } = input as { a: number; b: number };
68
+ return { result: a + b };
69
+ }
70
+ `;
71
+ }
72
+ /**
73
+ * Generate project tsconfig.json
74
+ */
75
+ function generateProjectTsConfig() {
76
+ const config = {
77
+ compilerOptions: {
78
+ target: "ESNext",
79
+ module: "ESNext",
80
+ moduleResolution: "bundler",
81
+ lib: ["ESNext"],
82
+ outDir: "./dist",
83
+ strict: true,
84
+ esModuleInterop: true,
85
+ skipLibCheck: true,
86
+ forceConsistentCasingInFileNames: true,
87
+ resolveJsonModule: true,
88
+ allowSyntheticDefaultImports: true,
89
+ },
90
+ include: ["agents/**/*.ts", "tools/**/*.ts"],
91
+ exclude: ["node_modules", "dist"],
92
+ };
93
+ return JSON.stringify(config, null, 2);
94
+ }
95
+ /**
96
+ * Generate project README.md
97
+ */
98
+ function generateProjectReadme() {
99
+ return `# Town Agents Project
100
+
101
+ A standalone project for developing Town agents with custom tools.
102
+
103
+ ## Project Structure
104
+
105
+ \`\`\`
106
+ .
107
+ ├── agents/ # Agent implementations (created with 'town create')
108
+ ├── tools/ # Custom tools
109
+ │ └── add-two-numbers.ts # Example tool
110
+ ├── package.json # Project dependencies
111
+ └── tsconfig.json # TypeScript configuration
112
+ \`\`\`
113
+
114
+ ## Getting Started
115
+
116
+ 1. Install dependencies (if not already done):
117
+
118
+ \`\`\`bash
119
+ bun install
120
+ \`\`\`
121
+
122
+ 2. Create your first agent:
123
+
124
+ \`\`\`bash
125
+ town create
126
+ \`\`\`
127
+
128
+ This will launch an interactive wizard to create a new agent in the \`agents/\` directory.
129
+ The agent will include GUI and TUI interfaces for interaction.
130
+
131
+ ## Creating Agents
132
+
133
+ Run \`town create\` inside your project directory to create new agents.
134
+ Each agent will be placed in \`agents/<agent-name>/\` with the following structure:
135
+
136
+ \`\`\`
137
+ agents/my-agent/
138
+ ├── agent.json # Agent configuration
139
+ ├── index.ts # Agent entry point
140
+ ├── gui/ # Web-based GUI interface
141
+ └── tui/ # Terminal UI interface
142
+ \`\`\`
143
+
144
+ ## Running Agents
145
+
146
+ Each agent can be run in different modes:
147
+
148
+ \`\`\`bash
149
+ # CLI mode (stdio)
150
+ bun agents/<agent-name>/index.ts stdio
151
+
152
+ # HTTP server mode
153
+ PORT=3100 bun agents/<agent-name>/index.ts http
154
+ \`\`\`
155
+
156
+ ## Creating Custom Tools
157
+
158
+ Tools are defined in the \`tools/\` directory. Each tool exports:
159
+
160
+ - \`schema\`: A Zod schema factory function
161
+ - \`name\`: The tool name
162
+ - \`description\`: Tool description
163
+ - \`default\`: The tool implementation function
164
+
165
+ Example:
166
+
167
+ \`\`\`typescript
168
+ export const schema = (z: any) =>
169
+ z.object({
170
+ input: z.string(),
171
+ });
172
+
173
+ export const name = "my_tool";
174
+ export const description = "My custom tool";
175
+
176
+ export default function myTool(input: unknown) {
177
+ // Implementation
178
+ return { result: "success" };
179
+ }
180
+ \`\`\`
181
+
182
+ To use a tool in an agent, import it in the agent's \`index.ts\`:
183
+
184
+ \`\`\`typescript
185
+ import myTool, { name, description, schema } from "../../tools/my-tool.js";
186
+
187
+ const agent: AgentDefinition = {
188
+ // ...
189
+ tools: [
190
+ {
191
+ type: "direct",
192
+ name,
193
+ description,
194
+ fn: myTool,
195
+ schema: schema(z),
196
+ },
197
+ ],
198
+ };
199
+ \`\`\`
200
+ `;
201
+ }
202
+ /**
203
+ * Generate .gitignore
204
+ */
205
+ function generateProjectGitignore() {
206
+ return `node_modules
207
+ dist
208
+ .env
209
+ *.log
210
+ `;
211
+ }
212
+ /**
213
+ * Run bun install
214
+ */
215
+ function runBunInstall(projectPath) {
216
+ return new Promise((resolve, reject) => {
217
+ const bunInstall = spawn("bun", ["install"], {
218
+ cwd: projectPath,
219
+ stdio: "pipe",
220
+ });
221
+ let stdout = "";
222
+ let stderr = "";
223
+ // Capture stdout
224
+ bunInstall.stdout?.on("data", (data) => {
225
+ stdout += data.toString();
226
+ });
227
+ // Capture stderr
228
+ bunInstall.stderr?.on("data", (data) => {
229
+ stderr += data.toString();
230
+ });
231
+ bunInstall.on("close", (code) => {
232
+ if (code === 0) {
233
+ resolve();
234
+ }
235
+ else {
236
+ // Print captured output on failure
237
+ if (stdout) {
238
+ process.stdout.write(stdout);
239
+ }
240
+ if (stderr) {
241
+ process.stderr.write(stderr);
242
+ }
243
+ reject(new Error(`bun install failed with code ${code}`));
244
+ }
245
+ });
246
+ bunInstall.on("error", (error) => {
247
+ // Print captured output on error
248
+ if (stdout) {
249
+ process.stdout.write(stdout);
250
+ }
251
+ if (stderr) {
252
+ process.stderr.write(stderr);
253
+ }
254
+ reject(error);
255
+ });
256
+ });
257
+ }
258
+ /**
259
+ * Scaffold a new standalone project
260
+ */
261
+ export async function scaffoldProject(options) {
262
+ const { path: projectPath } = options;
263
+ try {
264
+ // Create project root directory
265
+ await mkdir(projectPath, { recursive: true });
266
+ // Create agents directory (empty, to be populated by 'town create')
267
+ const agentsDir = join(projectPath, "agents");
268
+ await mkdir(agentsDir, { recursive: true });
269
+ // Create tools directory
270
+ const toolsDir = join(projectPath, "tools");
271
+ await mkdir(toolsDir, { recursive: true });
272
+ // Generate and write files
273
+ const files = [
274
+ {
275
+ path: "package.json",
276
+ content: generateProjectPackageJson(),
277
+ },
278
+ {
279
+ path: "tsconfig.json",
280
+ content: generateProjectTsConfig(),
281
+ },
282
+ {
283
+ path: ".gitignore",
284
+ content: generateProjectGitignore(),
285
+ },
286
+ {
287
+ path: "README.md",
288
+ content: generateProjectReadme(),
289
+ },
290
+ {
291
+ path: join("tools", "add-two-numbers.ts"),
292
+ content: generateAddTwoNumbersTool(),
293
+ },
294
+ ];
295
+ // Write all files
296
+ for (const file of files) {
297
+ const filePath = join(projectPath, file.path);
298
+ await writeFile(filePath, file.content, "utf-8");
299
+ }
300
+ // Run bun install
301
+ await runBunInstall(projectPath);
302
+ return {
303
+ success: true,
304
+ path: projectPath,
305
+ };
306
+ }
307
+ catch (error) {
308
+ return {
309
+ success: false,
310
+ path: projectPath,
311
+ error: error instanceof Error ? error.message : String(error),
312
+ };
313
+ }
314
+ }
@@ -22,3 +22,8 @@ export declare function deleteAgent(name: string): Promise<void>;
22
22
  * Ensure the agents directory exists
23
23
  */
24
24
  export declare function ensureAgentsDir(): Promise<void>;
25
+ /**
26
+ * Check if we're inside a Town project by looking for project markers
27
+ * Returns the project root path if found, null otherwise
28
+ */
29
+ export declare function isInsideTownProject(startPath?: string): Promise<string | null>;
@@ -1,57 +1,93 @@
1
1
  import { mkdir, readdir, rm, stat } from "node:fs/promises";
2
2
  import { homedir } from "node:os";
3
- import { join } from "node:path";
4
-
3
+ import { dirname, join } from "node:path";
5
4
  const AGENTS_DIR = join(homedir(), ".config", "town", "agents");
6
5
  /**
7
6
  * Get the base directory where all agents are stored
8
7
  */
9
8
  export function getAgentsDir() {
10
- return AGENTS_DIR;
9
+ return AGENTS_DIR;
11
10
  }
12
11
  /**
13
12
  * Get the directory path for a specific agent
14
13
  */
15
14
  export function getAgentPath(name) {
16
- return join(AGENTS_DIR, name);
15
+ return join(AGENTS_DIR, name);
17
16
  }
18
17
  /**
19
18
  * Check if an agent exists
20
19
  */
21
20
  export async function agentExists(name) {
22
- try {
23
- const agentPath = getAgentPath(name);
24
- const stats = await stat(agentPath);
25
- return stats.isDirectory();
26
- } catch {
27
- return false;
28
- }
21
+ try {
22
+ const agentPath = getAgentPath(name);
23
+ const stats = await stat(agentPath);
24
+ return stats.isDirectory();
25
+ }
26
+ catch {
27
+ return false;
28
+ }
29
29
  }
30
30
  /**
31
31
  * List all created agents
32
32
  */
33
33
  export async function listAgents() {
34
- try {
35
- await mkdir(AGENTS_DIR, { recursive: true });
36
- const entries = await readdir(AGENTS_DIR, { withFileTypes: true });
37
- return entries
38
- .filter((entry) => entry.isDirectory())
39
- .map((entry) => entry.name);
40
- } catch (error) {
41
- console.error("Error listing agents:", error);
42
- return [];
43
- }
34
+ try {
35
+ await mkdir(AGENTS_DIR, { recursive: true });
36
+ const entries = await readdir(AGENTS_DIR, { withFileTypes: true });
37
+ return entries
38
+ .filter((entry) => entry.isDirectory())
39
+ .map((entry) => entry.name);
40
+ }
41
+ catch (error) {
42
+ console.error("Error listing agents:", error);
43
+ return [];
44
+ }
44
45
  }
45
46
  /**
46
47
  * Delete an agent
47
48
  */
48
49
  export async function deleteAgent(name) {
49
- const agentPath = getAgentPath(name);
50
- await rm(agentPath, { recursive: true, force: true });
50
+ const agentPath = getAgentPath(name);
51
+ await rm(agentPath, { recursive: true, force: true });
51
52
  }
52
53
  /**
53
54
  * Ensure the agents directory exists
54
55
  */
55
56
  export async function ensureAgentsDir() {
56
- await mkdir(AGENTS_DIR, { recursive: true });
57
+ await mkdir(AGENTS_DIR, { recursive: true });
58
+ }
59
+ /**
60
+ * Check if we're inside a Town project by looking for project markers
61
+ * Returns the project root path if found, null otherwise
62
+ */
63
+ export async function isInsideTownProject(startPath = process.cwd()) {
64
+ let currentPath = startPath;
65
+ while (true) {
66
+ try {
67
+ // Check if this is a Town project by looking for:
68
+ // 1. agents/ directory exists
69
+ // (this is very naive right now)
70
+ const agentsDir = join(currentPath, "agents");
71
+ try {
72
+ const agentsDirStat = await stat(agentsDir);
73
+ if (agentsDirStat.isDirectory()) {
74
+ return currentPath;
75
+ }
76
+ }
77
+ catch {
78
+ // agents/ directory doesn't exist, continue searching
79
+ }
80
+ }
81
+ catch {
82
+ // package.json doesn't exist or can't be read, continue searching
83
+ }
84
+ // Move up one directory
85
+ const parentPath = dirname(currentPath);
86
+ if (parentPath === currentPath) {
87
+ // Reached the filesystem root
88
+ break;
89
+ }
90
+ currentPath = parentPath;
91
+ }
92
+ return null;
57
93
  }
@@ -8,14 +8,19 @@ export interface TemplateVars {
8
8
  } | {
9
9
  type: "filesystem";
10
10
  working_directory?: string | undefined;
11
+ } | {
12
+ type: "direct";
13
+ name: string;
14
+ description: string;
15
+ fn: any;
16
+ schema: unknown;
11
17
  }>;
12
18
  systemPrompt: string | null;
13
19
  hasWebSearch: boolean;
14
20
  }
15
21
  export declare function getTemplateVars(name: string, definition: AgentDefinition): TemplateVars;
16
22
  export declare function generatePackageJson(vars: TemplateVars): string;
17
- export declare function generateIndexTs(): string;
18
- export declare function generateAgentJson(vars: TemplateVars): string;
23
+ export declare function generateIndexTs(vars: TemplateVars): Promise<string>;
19
24
  export declare function generateBinTs(): string;
20
25
  export declare function generateGitignore(): string;
21
26
  export declare function generateTsConfig(): string;
@@ -1,3 +1,4 @@
1
+ import * as prettier from "prettier";
1
2
  export function getTemplateVars(name, definition) {
2
3
  const tools = definition.tools ?? [];
3
4
  return {
@@ -42,15 +43,17 @@ export function generatePackageJson(vars) {
42
43
  };
43
44
  return JSON.stringify(pkg, null, 2);
44
45
  }
45
- export function generateIndexTs() {
46
- return `import { readFileSync } from "node:fs";
47
- import { join } from "node:path";
48
- import { makeHttpTransport, makeStdioTransport } from "@townco/agent/acp-server";
46
+ export async function generateIndexTs(vars) {
47
+ const agentDef = {
48
+ model: vars.model,
49
+ systemPrompt: vars.systemPrompt,
50
+ tools: vars.tools,
51
+ };
52
+ return prettier.format(`import { makeHttpTransport, makeStdioTransport } from "@townco/agent/acp-server";
49
53
  import type { AgentDefinition } from "@townco/agent/definition";
50
54
 
51
55
  // Load agent definition from JSON file
52
- const configPath = join(import.meta.dir, "agent.json");
53
- const agent: AgentDefinition = JSON.parse(readFileSync(configPath, "utf-8"));
56
+ const agent: AgentDefinition = ${JSON.stringify(agentDef)};
54
57
 
55
58
  const transport = process.argv[2] || "stdio";
56
59
 
@@ -62,19 +65,11 @@ if (transport === "http") {
62
65
  console.error(\`Invalid transport: \${transport}\`);
63
66
  process.exit(1);
64
67
  }
65
- `;
66
- }
67
- export function generateAgentJson(vars) {
68
- const agentDef = {
69
- model: vars.model,
70
- systemPrompt: vars.systemPrompt,
71
- tools: vars.tools,
72
- };
73
- return JSON.stringify(agentDef, null, 2);
68
+ `, { parser: "typescript" });
74
69
  }
75
70
  export function generateBinTs() {
76
71
  return `#!/usr/bin/env bun
77
- import "./index.js";
72
+ import "./index.ts";
78
73
  `;
79
74
  }
80
75
  export function generateGitignore() {
@@ -113,6 +108,8 @@ export function generateReadme(vars) {
113
108
  return tool.modulePath;
114
109
  if (tool.type === "filesystem")
115
110
  return `filesystem${tool.working_directory ? ` (${tool.working_directory})` : ""}`;
111
+ if (tool.type === "direct")
112
+ return tool.name;
116
113
  return "";
117
114
  })
118
115
  .join(", ")