@townco/agent 0.1.13 → 0.1.15
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.d.ts +14 -10
- package/dist/acp-server/adapter.js +73 -72
- package/dist/acp-server/cli.d.ts +3 -1
- package/dist/acp-server/cli.js +9 -5
- package/dist/acp-server/http.d.ts +3 -1
- package/dist/acp-server/http.js +173 -163
- package/dist/bin.js +0 -0
- package/dist/definition/mcp.d.ts +0 -0
- package/dist/definition/mcp.js +0 -0
- package/dist/definition/tools/todo.d.ts +49 -0
- package/dist/definition/tools/todo.js +80 -0
- package/dist/definition/tools/web_search.d.ts +4 -0
- package/dist/definition/tools/web_search.js +26 -0
- package/dist/example.d.ts +2 -0
- package/dist/example.js +19 -0
- package/dist/index.js +12 -13
- package/dist/runner/agent-runner.js +4 -4
- package/dist/runner/index.d.ts +3 -1
- package/dist/runner/index.js +18 -14
- package/dist/runner/langchain/tools/todo.d.ts +48 -32
- package/dist/runner/langchain/tools/todo.js +16 -13
- package/dist/runner/langchain/tools/web_search.d.ts +1 -1
- package/dist/runner/langchain/tools/web_search.js +21 -18
- package/dist/scaffold/copy-gui.d.ts +1 -1
- package/dist/scaffold/copy-gui.js +22 -113
- package/dist/scaffold/index.d.ts +10 -8
- package/dist/scaffold/index.js +1 -4
- package/dist/storage/index.js +23 -24
- package/dist/templates/index.js +4 -3
- package/dist/test-script.js +12 -11
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -2
- package/templates/index.ts +4 -3
package/dist/storage/index.js
CHANGED
|
@@ -1,58 +1,57 @@
|
|
|
1
1
|
import { mkdir, readdir, rm, stat } from "node:fs/promises";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
+
|
|
4
5
|
const AGENTS_DIR = join(homedir(), ".config", "town", "agents");
|
|
5
6
|
/**
|
|
6
7
|
* Get the base directory where all agents are stored
|
|
7
8
|
*/
|
|
8
9
|
export function getAgentsDir() {
|
|
9
|
-
|
|
10
|
+
return AGENTS_DIR;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* Get the directory path for a specific agent
|
|
13
14
|
*/
|
|
14
15
|
export function getAgentPath(name) {
|
|
15
|
-
|
|
16
|
+
return join(AGENTS_DIR, name);
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* Check if an agent exists
|
|
19
20
|
*/
|
|
20
21
|
export async function agentExists(name) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
22
|
+
try {
|
|
23
|
+
const agentPath = getAgentPath(name);
|
|
24
|
+
const stats = await stat(agentPath);
|
|
25
|
+
return stats.isDirectory();
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
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
|
+
}
|
|
45
44
|
}
|
|
46
45
|
/**
|
|
47
46
|
* Delete an agent
|
|
48
47
|
*/
|
|
49
48
|
export async function deleteAgent(name) {
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const agentPath = getAgentPath(name);
|
|
50
|
+
await rm(agentPath, { recursive: true, force: true });
|
|
52
51
|
}
|
|
53
52
|
/**
|
|
54
53
|
* Ensure the agents directory exists
|
|
55
54
|
*/
|
|
56
55
|
export async function ensureAgentsDir() {
|
|
57
|
-
|
|
56
|
+
await mkdir(AGENTS_DIR, { recursive: true });
|
|
58
57
|
}
|
package/dist/templates/index.js
CHANGED
|
@@ -9,8 +9,9 @@ export function getTemplateVars(name, definition) {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
export function generatePackageJson(vars) {
|
|
12
|
-
// Include
|
|
12
|
+
// Include @townco/agent as a dependency instead of bundling
|
|
13
13
|
const dependencies = {
|
|
14
|
+
"@townco/agent": "^0.1.14",
|
|
14
15
|
"@agentclientprotocol/sdk": "^0.5.1",
|
|
15
16
|
"@langchain/anthropic": "^1.0.0",
|
|
16
17
|
"@langchain/core": "^1.0.3",
|
|
@@ -43,8 +44,8 @@ export function generatePackageJson(vars) {
|
|
|
43
44
|
export function generateIndexTs() {
|
|
44
45
|
return `import { readFileSync } from "node:fs";
|
|
45
46
|
import { join } from "node:path";
|
|
46
|
-
import { makeHttpTransport, makeStdioTransport } from "
|
|
47
|
-
import type { AgentDefinition } from "
|
|
47
|
+
import { makeHttpTransport, makeStdioTransport } from "@townco/agent/acp-server";
|
|
48
|
+
import type { AgentDefinition } from "@townco/agent/definition";
|
|
48
49
|
|
|
49
50
|
// Load agent definition from JSON file
|
|
50
51
|
const configPath = join(import.meta.dir, "agent.json");
|
package/dist/test-script.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { LangchainAgent } from "./runner/langchain";
|
|
2
|
+
|
|
2
3
|
const agent = new LangchainAgent({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
model: "claude-sonnet-4-5-20250929",
|
|
5
|
+
systemPrompt: "You are a helpful assistant.",
|
|
6
|
+
tools: ["todo_write"],
|
|
6
7
|
});
|
|
7
8
|
for await (const event of agent.invoke({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
prompt: [
|
|
10
|
+
{
|
|
11
|
+
type: "text",
|
|
12
|
+
text: "Whats the weather in Tokyo?",
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
sessionId: "test-session",
|
|
15
16
|
})) {
|
|
16
|
-
|
|
17
|
+
console.log(event);
|
|
17
18
|
}
|