@townco/agent 0.1.37 → 0.1.39
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/cli.d.ts +1 -3
- package/dist/acp-server/cli.js +5 -9
- package/dist/bin.js +0 -0
- package/dist/index.js +9 -3
- package/dist/runner/index.d.ts +1 -3
- package/dist/runner/index.js +14 -18
- package/dist/runner/langchain/index.js +1 -0
- package/dist/runner/langchain/model-factory.js +15 -1
- package/dist/runner/langchain/tools/subagent.js +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/index.ts +10 -3
- package/package.json +6 -6
- package/dist/definition/mcp.d.ts +0 -0
- package/dist/definition/mcp.js +0 -0
- package/dist/definition/tools/todo.d.ts +0 -49
- package/dist/definition/tools/todo.js +0 -80
- package/dist/definition/tools/web_search.d.ts +0 -4
- package/dist/definition/tools/web_search.js +0 -26
- package/dist/dev-agent/index.d.ts +0 -2
- package/dist/dev-agent/index.js +0 -18
- package/dist/example.d.ts +0 -2
- package/dist/example.js +0 -19
- package/dist/utils/logger.d.ts +0 -39
- package/dist/utils/logger.js +0 -175
package/dist/acp-server/cli.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import type { AgentDefinition } from "../definition";
|
|
2
2
|
import { type AgentRunner } from "../runner";
|
|
3
|
-
export declare function makeStdioTransport(
|
|
4
|
-
agent: AgentRunner | AgentDefinition,
|
|
5
|
-
): void;
|
|
3
|
+
export declare function makeStdioTransport(agent: AgentRunner | AgentDefinition): void;
|
package/dist/acp-server/cli.js
CHANGED
|
@@ -3,13 +3,9 @@ import * as acp from "@agentclientprotocol/sdk";
|
|
|
3
3
|
import { makeRunnerFromDefinition } from "../runner";
|
|
4
4
|
import { AgentAcpAdapter } from "./adapter";
|
|
5
5
|
export function makeStdioTransport(agent) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
new acp.AgentSideConnection(
|
|
12
|
-
(conn) => new AgentAcpAdapter(agentRunner, conn),
|
|
13
|
-
stream,
|
|
14
|
-
);
|
|
6
|
+
const agentRunner = "definition" in agent ? agent : makeRunnerFromDefinition(agent);
|
|
7
|
+
const input = Writable.toWeb(process.stdout);
|
|
8
|
+
const output = Readable.toWeb(process.stdin);
|
|
9
|
+
const stream = acp.ndJsonStream(input, output);
|
|
10
|
+
new acp.AgentSideConnection((conn) => new AgentAcpAdapter(agentRunner, conn), stream);
|
|
15
11
|
}
|
package/dist/bin.js
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -22,8 +22,14 @@ const exampleAgent = {
|
|
|
22
22
|
],
|
|
23
23
|
mcps: [],
|
|
24
24
|
};
|
|
25
|
-
// Parse transport type from command line
|
|
26
|
-
const
|
|
25
|
+
// Parse transport type and flags from command line arguments
|
|
26
|
+
const args = process.argv.slice(2);
|
|
27
|
+
const transport = args.find((arg) => !arg.startsWith("--")) || "stdio";
|
|
28
|
+
const noSession = args.includes("--no-session");
|
|
29
|
+
// Set TOWN_NO_SESSION environment variable if flag is present
|
|
30
|
+
if (noSession) {
|
|
31
|
+
process.env.TOWN_NO_SESSION = "true";
|
|
32
|
+
}
|
|
27
33
|
// Get agent directory and name for session storage
|
|
28
34
|
const agentDir = process.cwd();
|
|
29
35
|
const agentName = basename(agentDir);
|
|
@@ -35,6 +41,6 @@ else if (transport === "stdio") {
|
|
|
35
41
|
}
|
|
36
42
|
else {
|
|
37
43
|
console.error(`Invalid transport: ${transport}`);
|
|
38
|
-
console.error("Usage: bun run index.ts [stdio|http]");
|
|
44
|
+
console.error("Usage: bun run index.ts [stdio|http] [--no-session]");
|
|
39
45
|
process.exit(1);
|
|
40
46
|
}
|
package/dist/runner/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { AgentDefinition } from "../definition";
|
|
2
2
|
import { type AgentRunner } from "./agent-runner";
|
|
3
3
|
export type { AgentRunner };
|
|
4
|
-
export declare const makeRunnerFromDefinition: (
|
|
5
|
-
definition: AgentDefinition,
|
|
6
|
-
) => AgentRunner;
|
|
4
|
+
export declare const makeRunnerFromDefinition: (definition: AgentDefinition) => AgentRunner;
|
package/dist/runner/index.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { zAgentRunnerParams } from "./agent-runner";
|
|
2
2
|
import { LangchainAgent } from "./langchain";
|
|
3
3
|
export const makeRunnerFromDefinition = (definition) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
`Unsupported harness implementation: ${definition.harnessImplementation}`,
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
4
|
+
const agentRunnerParams = zAgentRunnerParams.safeParse(definition);
|
|
5
|
+
if (!agentRunnerParams.success) {
|
|
6
|
+
throw new Error(`Invalid agent definition: ${agentRunnerParams.error.message}`);
|
|
7
|
+
}
|
|
8
|
+
switch (definition.harnessImplementation) {
|
|
9
|
+
case undefined:
|
|
10
|
+
case "langchain": {
|
|
11
|
+
return new LangchainAgent(agentRunnerParams.data);
|
|
12
|
+
}
|
|
13
|
+
default: {
|
|
14
|
+
const _exhaustiveCheck = definition.harnessImplementation;
|
|
15
|
+
throw new Error(`Unsupported harness implementation: ${definition.harnessImplementation}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
22
18
|
};
|
|
@@ -54,13 +54,27 @@ export function createModelFromString(modelString) {
|
|
|
54
54
|
switch (provider) {
|
|
55
55
|
case "google_vertexai":
|
|
56
56
|
case "vertex":
|
|
57
|
-
case "vertexai":
|
|
57
|
+
case "vertexai": {
|
|
58
|
+
if (process.env.VERTEX_CREDENTIALS == null) {
|
|
59
|
+
throw new Error("VERTEX_CREDENTIALS environment variable not set");
|
|
60
|
+
}
|
|
61
|
+
let parsedEnv;
|
|
62
|
+
try {
|
|
63
|
+
parsedEnv = JSON.parse(process.env.VERTEX_CREDENTIALS);
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
throw new Error(`VERTEX_CREDENTIALS environment variable is not valid JSON ${e}`);
|
|
67
|
+
}
|
|
58
68
|
return new ChatVertexAI({
|
|
59
69
|
model: modelName,
|
|
60
70
|
// Default to reasonable settings
|
|
61
71
|
temperature: 0,
|
|
62
72
|
location: "global",
|
|
73
|
+
authOptions: {
|
|
74
|
+
credentials: parsedEnv,
|
|
75
|
+
},
|
|
63
76
|
});
|
|
77
|
+
}
|
|
64
78
|
case "google_genai":
|
|
65
79
|
case "gemini":
|
|
66
80
|
return new ChatGoogleGenerativeAI({
|
|
@@ -179,6 +179,10 @@ async function querySubagent(agentPath, agentWorkingDirectory, query) {
|
|
|
179
179
|
// Handle session updates from the agent
|
|
180
180
|
const paramsExtended = params;
|
|
181
181
|
const update = paramsExtended.update;
|
|
182
|
+
// Reset accumulated text when a tool call starts (marks a new message boundary)
|
|
183
|
+
if (update?.sessionUpdate === "tool_call") {
|
|
184
|
+
responseText = "";
|
|
185
|
+
}
|
|
182
186
|
// Accumulate agent_message_chunk text content
|
|
183
187
|
if (update?.sessionUpdate === "agent_message_chunk") {
|
|
184
188
|
const content = update.content;
|