@townco/agent 0.1.42 → 0.1.43

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.
@@ -17,6 +17,8 @@ const getWeather = tool(({ city }) => `It's always sunny in ${city}!`, {
17
17
  city: z.string(),
18
18
  }),
19
19
  });
20
+ getWeather.prettyName = "Get Weather";
21
+ getWeather.icon = "Cloud";
20
22
  export const TOOL_REGISTRY = {
21
23
  todo_write: todoWrite,
22
24
  get_weather: getWeather,
@@ -27,11 +29,14 @@ export const TOOL_REGISTRY = {
27
29
  // Custom tool loading
28
30
  // ============================================================================
29
31
  function toLangchainTool(resolved) {
30
- return tool(resolved.fn, {
32
+ const t = tool(resolved.fn, {
31
33
  name: resolved.name,
32
34
  description: resolved.description,
33
35
  schema: resolved.schema,
34
36
  });
37
+ t.prettyName = resolved.prettyName;
38
+ t.icon = resolved.icon;
39
+ return t;
35
40
  }
36
41
  async function loadCustomTool(modulePath) {
37
42
  const resolved = await loadCustomToolModule(modulePath);
@@ -84,6 +89,8 @@ export class LangchainAgent {
84
89
  description: t.description,
85
90
  schema: t.schema,
86
91
  });
92
+ addedTool.prettyName = t.prettyName;
93
+ addedTool.icon = t.icon;
87
94
  enabledTools.push(addedTool);
88
95
  }
89
96
  }
@@ -229,6 +236,9 @@ export class LangchainAgent {
229
236
  // todoWriteToolCallIds.add(toolCall.id);
230
237
  // continue;
231
238
  //}
239
+ const matchingTool = finalTools.find((t) => t.name === toolCall.name);
240
+ const prettyName = matchingTool?.prettyName;
241
+ const icon = matchingTool?.icon;
232
242
  yield {
233
243
  sessionUpdate: "tool_call",
234
244
  toolCallId: toolCall.id,
@@ -237,7 +247,11 @@ export class LangchainAgent {
237
247
  status: "pending",
238
248
  rawInput: toolCall.args,
239
249
  ...(tokenUsage ? { tokenUsage } : {}),
240
- _meta: { messageId: req.messageId },
250
+ _meta: {
251
+ messageId: req.messageId,
252
+ ...(prettyName ? { prettyName } : {}),
253
+ ...(icon ? { icon } : {}),
254
+ },
241
255
  };
242
256
  yield {
243
257
  sessionUpdate: "tool_call_update",
@@ -188,6 +188,8 @@ export function makeFilesystemTools(workingDirectory) {
188
188
  .describe("Enable multiline mode where . matches newlines and patterns can span lines (rg -U --multiline-dotall). Default: false."),
189
189
  }),
190
190
  });
191
+ grep.prettyName = "Codebase Search";
192
+ grep.icon = "Search";
191
193
  const read = tool(async ({ file_path, offset, limit }) => {
192
194
  await ensureSandbox(resolvedWd);
193
195
  assertAbsolutePath(file_path, "file_path");
@@ -230,6 +232,8 @@ export function makeFilesystemTools(workingDirectory) {
230
232
  .describe("The number of lines to read. Only provide if the file is too large to read at once."),
231
233
  }),
232
234
  });
235
+ read.prettyName = "Read File";
236
+ read.icon = "FileText";
233
237
  const write = tool(async ({ file_path, content }) => {
234
238
  await ensureSandbox(resolvedWd);
235
239
  assertAbsolutePath(file_path, "file_path");
@@ -257,5 +261,7 @@ export function makeFilesystemTools(workingDirectory) {
257
261
  content: z.string().describe("The content to write to the file"),
258
262
  }),
259
263
  });
264
+ write.prettyName = "Write File";
265
+ write.icon = "Edit";
260
266
  return [grep, read, write];
261
267
  }
@@ -76,3 +76,5 @@ When in doubt, use this tool. Being proactive with task management demonstrates
76
76
  todos: z.array(todoItemSchema),
77
77
  }),
78
78
  });
79
+ todoWrite.prettyName = "Todo List";
80
+ todoWrite.icon = "CheckSquare";
@@ -46,6 +46,8 @@ export function makeWebSearchTools() {
46
46
  query: z.string().describe("The search query to use"),
47
47
  }),
48
48
  });
49
+ webSearch.prettyName = "Web Search";
50
+ webSearch.icon = "Globe";
49
51
  // WebFetch tool - get contents of specific URLs
50
52
  const webFetch = tool(async ({ url, prompt }) => {
51
53
  const client = getExaClient();
@@ -118,6 +120,8 @@ export function makeWebSearchTools() {
118
120
  prompt: z.string().describe("The prompt to run on the fetched content"),
119
121
  }),
120
122
  });
123
+ webFetch.prettyName = "Web Fetch";
124
+ webFetch.icon = "Link";
121
125
  return [webSearch, webFetch];
122
126
  }
123
127
  function buildWebFetchUserMessage(pageContent, prompt) {
@@ -4,11 +4,15 @@ export type CustomToolModule = {
4
4
  schema: z.ZodTypeAny | ((z: typeof import("zod").z) => z.ZodTypeAny);
5
5
  name: string;
6
6
  description: string;
7
+ prettyName?: string;
8
+ icon?: string;
7
9
  };
8
10
  export type ResolvedCustomTool = {
9
11
  fn: (input: unknown) => unknown | Promise<unknown>;
10
12
  schema: z.ZodTypeAny;
11
13
  name: string;
12
14
  description: string;
15
+ prettyName?: string;
16
+ icon?: string;
13
17
  };
14
18
  export declare function loadCustomToolModule(modulePath: string): Promise<ResolvedCustomTool>;
@@ -35,6 +35,8 @@ export async function loadCustomToolModule(modulePath) {
35
35
  schema: resolvedSchema,
36
36
  name: mod.name,
37
37
  description: mod.description,
38
+ ...(mod.prettyName && { prettyName: mod.prettyName }),
39
+ ...(mod.icon && { icon: mod.icon }),
38
40
  };
39
41
  // Cache the resolved tool
40
42
  customToolCache.set(modulePath, resolved);
@@ -8,6 +8,8 @@ declare const zDirectTool: z.ZodObject<{
8
8
  description: z.ZodString;
9
9
  fn: z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>;
10
10
  schema: z.ZodAny;
11
+ prettyName: z.ZodOptional<z.ZodString>;
12
+ icon: z.ZodOptional<z.ZodString>;
11
13
  }, z.core.$strip>;
12
14
  /** Tool type - can be a built-in tool string or custom tool object. */
13
15
  export declare const zToolType: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"todo_write">, z.ZodLiteral<"get_weather">, z.ZodLiteral<"web_search">, z.ZodLiteral<"filesystem">]>, z.ZodObject<{
@@ -22,6 +24,8 @@ export declare const zToolType: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodL
22
24
  description: z.ZodString;
23
25
  fn: z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>;
24
26
  schema: z.ZodAny;
27
+ prettyName: z.ZodOptional<z.ZodString>;
28
+ icon: z.ZodOptional<z.ZodString>;
25
29
  }, z.core.$strip>]>;
26
30
  export type ToolType = z.infer<typeof zToolType>;
27
31
  export type BuiltInToolType = z.infer<typeof zBuiltInToolType>;
@@ -23,6 +23,8 @@ const zDirectTool = z.object({
23
23
  description: z.string(),
24
24
  fn: z.function(),
25
25
  schema: z.any(), // Accept any Zod schema
26
+ prettyName: z.string().optional(),
27
+ icon: z.string().optional(),
26
28
  });
27
29
  /** Tool type - can be a built-in tool string or custom tool object. */
28
30
  export const zToolType = z.union([