@townco/agent 0.1.20 → 0.1.22
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/dist/acp-server/adapter.js +77 -73
- package/dist/acp-server/http.js +233 -10
- package/dist/index.js +5 -11
- package/dist/runner/agent-runner.d.ts +16 -2
- package/dist/runner/agent-runner.js +4 -4
- package/dist/runner/langchain/index.d.ts +4 -4
- package/dist/runner/langchain/index.js +32 -10
- package/dist/runner/langchain/tools/todo.js +13 -16
- package/dist/runner/langchain/tools/web_search.js +18 -21
- package/dist/test-script.js +12 -12
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/index.ts +7 -11
- package/package.json +5 -5
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { tool } from "langchain";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
export const todoItemSchema = z.object({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
content: z.string().min(1),
|
|
5
|
+
status: z.enum(["pending", "in_progress", "completed"]),
|
|
6
|
+
activeForm: z.string().min(1),
|
|
7
7
|
});
|
|
8
|
-
export const todoWrite = tool(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
name: "todo_write",
|
|
15
|
-
description: `Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
|
|
8
|
+
export const todoWrite = tool(({ todos }) => {
|
|
9
|
+
// Simple implementation that confirms the todos were written
|
|
10
|
+
return `Successfully updated todo list with ${todos.length} items`;
|
|
11
|
+
}, {
|
|
12
|
+
name: "todo_write",
|
|
13
|
+
description: `Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
|
|
16
14
|
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
17
15
|
|
|
18
16
|
## When to Use This Tool
|
|
@@ -73,8 +71,7 @@ NOTE that you should not use this tool if there is only one trivial task to do.
|
|
|
73
71
|
- activeForm: "Fixing authentication bug"
|
|
74
72
|
|
|
75
73
|
When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.`,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
);
|
|
74
|
+
schema: z.object({
|
|
75
|
+
todos: z.array(todoItemSchema),
|
|
76
|
+
}),
|
|
77
|
+
});
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import { ExaSearchResults } from "@langchain/exa";
|
|
2
2
|
import Exa from "exa-js";
|
|
3
|
-
|
|
4
3
|
let _webSearchInstance = null;
|
|
5
4
|
export function makeWebSearchTool() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
return _webSearchInstance;
|
|
5
|
+
if (_webSearchInstance) {
|
|
6
|
+
return _webSearchInstance;
|
|
7
|
+
}
|
|
8
|
+
const apiKey = process.env.EXA_API_KEY;
|
|
9
|
+
if (!apiKey) {
|
|
10
|
+
throw new Error("EXA_API_KEY environment variable is required to use the web_search tool. " +
|
|
11
|
+
"Please set it to your Exa API key from https://exa.ai");
|
|
12
|
+
}
|
|
13
|
+
const client = new Exa(apiKey);
|
|
14
|
+
_webSearchInstance = new ExaSearchResults({
|
|
15
|
+
client,
|
|
16
|
+
searchArgs: {
|
|
17
|
+
numResults: 5,
|
|
18
|
+
type: "auto",
|
|
19
|
+
text: true,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
return _webSearchInstance;
|
|
26
23
|
}
|
package/dist/test-script.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { LangchainAgent } from "./runner/langchain";
|
|
2
|
-
|
|
3
2
|
const agent = new LangchainAgent({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
model: "claude-sonnet-4-5-20250929",
|
|
4
|
+
systemPrompt: "You are a helpful assistant.",
|
|
5
|
+
tools: ["todo_write"],
|
|
7
6
|
});
|
|
8
7
|
for await (const event of agent.invoke({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
prompt: [
|
|
9
|
+
{
|
|
10
|
+
type: "text",
|
|
11
|
+
text: "Whats the weather in Tokyo?",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
sessionId: "test-session",
|
|
15
|
+
messageId: "test-message-1",
|
|
16
16
|
})) {
|
|
17
|
-
|
|
17
|
+
console.log(event);
|
|
18
18
|
}
|