@townco/agent 0.1.52 → 0.1.53

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 (38) hide show
  1. package/dist/acp-server/adapter.d.ts +2 -0
  2. package/dist/acp-server/adapter.js +28 -3
  3. package/dist/acp-server/cli.d.ts +3 -1
  4. package/dist/acp-server/session-storage.d.ts +2 -0
  5. package/dist/acp-server/session-storage.js +2 -0
  6. package/dist/bin.js +0 -0
  7. package/dist/definition/mcp.d.ts +0 -0
  8. package/dist/definition/mcp.js +0 -0
  9. package/dist/definition/tools/todo.d.ts +49 -0
  10. package/dist/definition/tools/todo.js +80 -0
  11. package/dist/definition/tools/web_search.d.ts +4 -0
  12. package/dist/definition/tools/web_search.js +26 -0
  13. package/dist/dev-agent/index.d.ts +2 -0
  14. package/dist/dev-agent/index.js +18 -0
  15. package/dist/example.d.ts +2 -0
  16. package/dist/example.js +19 -0
  17. package/dist/runner/agent-runner.d.ts +4 -0
  18. package/dist/runner/index.d.ts +3 -1
  19. package/dist/runner/langchain/index.d.ts +0 -1
  20. package/dist/runner/langchain/index.js +88 -27
  21. package/dist/tsconfig.tsbuildinfo +1 -1
  22. package/dist/utils/__tests__/tool-overhead-calculator.test.d.ts +1 -0
  23. package/dist/utils/__tests__/tool-overhead-calculator.test.js +153 -0
  24. package/dist/utils/context-size-calculator.d.ts +9 -4
  25. package/dist/utils/context-size-calculator.js +23 -6
  26. package/dist/utils/tool-overhead-calculator.d.ts +30 -0
  27. package/dist/utils/tool-overhead-calculator.js +54 -0
  28. package/package.json +6 -6
  29. package/dist/check-jaeger.d.ts +0 -5
  30. package/dist/check-jaeger.js +0 -82
  31. package/dist/run-subagents.d.ts +0 -9
  32. package/dist/run-subagents.js +0 -110
  33. package/dist/runner/langchain/custom-stream-types.d.ts +0 -36
  34. package/dist/runner/langchain/custom-stream-types.js +0 -23
  35. package/dist/runner/langchain/tools/bash.d.ts +0 -14
  36. package/dist/runner/langchain/tools/bash.js +0 -135
  37. package/dist/test-telemetry.d.ts +0 -5
  38. package/dist/test-telemetry.js +0 -88
@@ -0,0 +1,153 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { estimateAllToolsOverhead, estimateToolDefinitionTokens, extractToolMetadata, } from "../tool-overhead-calculator.js";
3
+ describe("tool-overhead-calculator", () => {
4
+ describe("estimateToolDefinitionTokens", () => {
5
+ test("estimates tokens for a simple tool", () => {
6
+ const tool = {
7
+ name: "simple_tool",
8
+ description: "A simple tool",
9
+ schema: {
10
+ type: "object",
11
+ properties: {
12
+ param1: { type: "string" },
13
+ },
14
+ },
15
+ };
16
+ const tokens = estimateToolDefinitionTokens(tool);
17
+ // Should return a positive number
18
+ expect(tokens).toBeGreaterThan(0);
19
+ // Rough sanity check: a simple tool should be at least 20 tokens
20
+ expect(tokens).toBeGreaterThanOrEqual(20);
21
+ });
22
+ test("estimates more tokens for a complex tool", () => {
23
+ const simpleTool = {
24
+ name: "simple",
25
+ description: "Simple",
26
+ schema: { type: "object" },
27
+ };
28
+ const complexTool = {
29
+ name: "complex_tool_with_long_name",
30
+ description: "A very complex tool with a long description that explains what it does in great detail and provides usage notes and examples.",
31
+ schema: {
32
+ type: "object",
33
+ properties: {
34
+ param1: {
35
+ type: "string",
36
+ description: "First parameter description",
37
+ },
38
+ param2: {
39
+ type: "number",
40
+ description: "Second parameter description",
41
+ },
42
+ param3: {
43
+ type: "array",
44
+ items: { type: "string" },
45
+ description: "Third parameter description",
46
+ },
47
+ },
48
+ required: ["param1", "param2"],
49
+ },
50
+ };
51
+ const simpleTokens = estimateToolDefinitionTokens(simpleTool);
52
+ const complexTokens = estimateToolDefinitionTokens(complexTool);
53
+ expect(complexTokens).toBeGreaterThan(simpleTokens);
54
+ });
55
+ test("handles empty description", () => {
56
+ const tool = {
57
+ name: "test",
58
+ description: "",
59
+ schema: {},
60
+ };
61
+ const tokens = estimateToolDefinitionTokens(tool);
62
+ expect(tokens).toBeGreaterThan(0);
63
+ });
64
+ });
65
+ describe("estimateAllToolsOverhead", () => {
66
+ test("returns 0 for empty array", () => {
67
+ const tools = [];
68
+ const tokens = estimateAllToolsOverhead(tools);
69
+ expect(tokens).toBe(0);
70
+ });
71
+ test("sums tokens for multiple tools", () => {
72
+ const tools = [
73
+ {
74
+ name: "tool1",
75
+ description: "First tool",
76
+ schema: { type: "object" },
77
+ },
78
+ {
79
+ name: "tool2",
80
+ description: "Second tool",
81
+ schema: { type: "object" },
82
+ },
83
+ ];
84
+ const totalTokens = estimateAllToolsOverhead(tools);
85
+ const tool1Tokens = estimateToolDefinitionTokens(tools[0]);
86
+ const tool2Tokens = estimateToolDefinitionTokens(tools[1]);
87
+ expect(totalTokens).toBe(tool1Tokens + tool2Tokens);
88
+ });
89
+ test("handles large tool collections", () => {
90
+ const tools = Array.from({ length: 10 }, (_, i) => ({
91
+ name: `tool_${i}`,
92
+ description: `Tool number ${i} with description`,
93
+ schema: {
94
+ type: "object",
95
+ properties: {
96
+ param: { type: "string" },
97
+ },
98
+ },
99
+ }));
100
+ const totalTokens = estimateAllToolsOverhead(tools);
101
+ // With 10 tools, should be substantial
102
+ expect(totalTokens).toBeGreaterThan(100);
103
+ });
104
+ });
105
+ describe("extractToolMetadata", () => {
106
+ test("extracts metadata from LangChain tool object", () => {
107
+ const langchainTool = {
108
+ name: "test_tool",
109
+ description: "Test description",
110
+ schema: {
111
+ type: "object",
112
+ properties: { x: { type: "number" } },
113
+ },
114
+ };
115
+ const metadata = extractToolMetadata(langchainTool);
116
+ expect(metadata.name).toBe("test_tool");
117
+ expect(metadata.description).toBe("Test description");
118
+ expect(metadata.schema).toEqual({
119
+ type: "object",
120
+ properties: { x: { type: "number" } },
121
+ });
122
+ });
123
+ test("handles missing description", () => {
124
+ const langchainTool = {
125
+ name: "test_tool",
126
+ schema: { type: "object" },
127
+ };
128
+ const metadata = extractToolMetadata(langchainTool);
129
+ expect(metadata.name).toBe("test_tool");
130
+ expect(metadata.description).toBe("");
131
+ expect(metadata.schema).toEqual({ type: "object" });
132
+ });
133
+ test("handles missing schema", () => {
134
+ const langchainTool = {
135
+ name: "test_tool",
136
+ description: "Test",
137
+ };
138
+ const metadata = extractToolMetadata(langchainTool);
139
+ expect(metadata.name).toBe("test_tool");
140
+ expect(metadata.description).toBe("Test");
141
+ expect(metadata.schema).toEqual({});
142
+ });
143
+ test("handles missing description and schema", () => {
144
+ const langchainTool = {
145
+ name: "test_tool",
146
+ };
147
+ const metadata = extractToolMetadata(langchainTool);
148
+ expect(metadata.name).toBe("test_tool");
149
+ expect(metadata.description).toBe("");
150
+ expect(metadata.schema).toEqual({});
151
+ });
152
+ });
153
+ });
@@ -5,6 +5,8 @@
5
5
  import type { SessionMessage } from "../acp-server/session-storage.js";
6
6
  export interface ContextSize {
7
7
  systemPromptTokens: number;
8
+ toolOverheadTokens?: number;
9
+ mcpOverheadTokens?: number;
8
10
  userMessagesTokens: number;
9
11
  assistantMessagesTokens: number;
10
12
  toolInputTokens: number;
@@ -22,8 +24,11 @@ export interface ContextSize {
22
24
  * all messages, and all tool results
23
25
  * - We pass this as `llmReportedTokens` for comparison with our estimate
24
26
  * - This helps us validate the accuracy of our tokenizer estimates
25
- * - Tool declarations are NOT counted separately in our estimate since they're
26
- * included in the LLM-reported value
27
+ *
28
+ * @param messages - Resolved messages from context entry
29
+ * @param systemPrompt - Base system prompt (without TODO instructions)
30
+ * @param llmReportedTokens - From API usage_metadata.input_tokens
31
+ * @param toolOverheadTokens - Pre-calculated tool overhead (built-in/custom/filesystem tool definitions + TODO instructions)
32
+ * @param mcpOverheadTokens - Pre-calculated MCP tool overhead (MCP tool definitions)
27
33
  */
28
- export declare function calculateContextSize(messages: SessionMessage[], // Resolved messages from context entry
29
- systemPrompt?: string, llmReportedTokens?: number): ContextSize;
34
+ export declare function calculateContextSize(messages: SessionMessage[], systemPrompt?: string, llmReportedTokens?: number, toolOverheadTokens?: number, mcpOverheadTokens?: number): ContextSize;
@@ -37,12 +37,17 @@ function countContentBlock(block) {
37
37
  * all messages, and all tool results
38
38
  * - We pass this as `llmReportedTokens` for comparison with our estimate
39
39
  * - This helps us validate the accuracy of our tokenizer estimates
40
- * - Tool declarations are NOT counted separately in our estimate since they're
41
- * included in the LLM-reported value
40
+ *
41
+ * @param messages - Resolved messages from context entry
42
+ * @param systemPrompt - Base system prompt (without TODO instructions)
43
+ * @param llmReportedTokens - From API usage_metadata.input_tokens
44
+ * @param toolOverheadTokens - Pre-calculated tool overhead (built-in/custom/filesystem tool definitions + TODO instructions)
45
+ * @param mcpOverheadTokens - Pre-calculated MCP tool overhead (MCP tool definitions)
42
46
  */
43
- export function calculateContextSize(messages, // Resolved messages from context entry
44
- systemPrompt, llmReportedTokens) {
47
+ export function calculateContextSize(messages, systemPrompt, llmReportedTokens, toolOverheadTokens, mcpOverheadTokens) {
45
48
  const systemPromptTokens = systemPrompt ? countTokens(systemPrompt) : 0;
49
+ const toolOverheadTokensEstimate = toolOverheadTokens ?? 0;
50
+ const mcpOverheadTokensEstimate = mcpOverheadTokens ?? 0;
46
51
  let userMessagesTokens = 0;
47
52
  let assistantMessagesTokens = 0;
48
53
  let toolInputTokens = 0;
@@ -62,17 +67,29 @@ systemPrompt, llmReportedTokens) {
62
67
  }
63
68
  }
64
69
  }
65
- return {
70
+ const result = {
66
71
  systemPromptTokens,
67
72
  userMessagesTokens,
68
73
  assistantMessagesTokens,
69
74
  toolInputTokens,
70
75
  toolResultsTokens,
71
76
  totalEstimated: systemPromptTokens +
77
+ toolOverheadTokensEstimate +
78
+ mcpOverheadTokensEstimate +
72
79
  userMessagesTokens +
73
80
  assistantMessagesTokens +
74
81
  toolInputTokens +
75
82
  toolResultsTokens,
76
- llmReportedInputTokens: llmReportedTokens,
77
83
  };
84
+ // Only include optional fields if they have values
85
+ if (toolOverheadTokensEstimate > 0) {
86
+ result.toolOverheadTokens = toolOverheadTokensEstimate;
87
+ }
88
+ if (mcpOverheadTokensEstimate > 0) {
89
+ result.mcpOverheadTokens = mcpOverheadTokensEstimate;
90
+ }
91
+ if (llmReportedTokens !== undefined) {
92
+ result.llmReportedInputTokens = llmReportedTokens;
93
+ }
94
+ return result;
78
95
  }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Tool overhead calculation utilities
3
+ * Estimates token overhead from tool definitions sent to LLM APIs
4
+ */
5
+ export interface ToolMetadata {
6
+ name: string;
7
+ description: string;
8
+ schema: Record<string, unknown>;
9
+ }
10
+ /**
11
+ * Estimate tokens for a single tool definition
12
+ * LLMs receive tools as JSON with name, description, and parameters schema
13
+ *
14
+ * Note: Different LLM providers (Anthropic, OpenAI, Gemini) serialize tools
15
+ * slightly differently. This is a rough approximation based on the general format.
16
+ */
17
+ export declare function estimateToolDefinitionTokens(tool: ToolMetadata): number;
18
+ /**
19
+ * Estimate total tokens for all tool definitions
20
+ */
21
+ export declare function estimateAllToolsOverhead(tools: ToolMetadata[]): number;
22
+ /**
23
+ * Extract metadata from LangChain tools
24
+ * LangChain tools have .name, .description, and .schema properties
25
+ */
26
+ export declare function extractToolMetadata(langchainTool: {
27
+ name: string;
28
+ description?: string;
29
+ schema?: unknown;
30
+ }): ToolMetadata;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Tool overhead calculation utilities
3
+ * Estimates token overhead from tool definitions sent to LLM APIs
4
+ */
5
+ import { countTokens } from "./token-counter.js";
6
+ /**
7
+ * Estimate tokens for a single tool definition
8
+ * LLMs receive tools as JSON with name, description, and parameters schema
9
+ *
10
+ * Note: Different LLM providers (Anthropic, OpenAI, Gemini) serialize tools
11
+ * slightly differently. This is a rough approximation based on the general format.
12
+ */
13
+ export function estimateToolDefinitionTokens(tool) {
14
+ // Rough serialization of how tools are sent to APIs:
15
+ // {"name": "tool_name", "description": "...", "input_schema": {...}}
16
+ const approximateJson = JSON.stringify({
17
+ name: tool.name,
18
+ description: tool.description,
19
+ input_schema: tool.schema,
20
+ });
21
+ return countTokens(approximateJson);
22
+ }
23
+ /**
24
+ * Estimate total tokens for all tool definitions
25
+ */
26
+ export function estimateAllToolsOverhead(tools) {
27
+ return tools.reduce((total, tool) => total + estimateToolDefinitionTokens(tool), 0);
28
+ }
29
+ /**
30
+ * Extract metadata from LangChain tools
31
+ * LangChain tools have .name, .description, and .schema properties
32
+ */
33
+ export function extractToolMetadata(langchainTool) {
34
+ // LangChain tools may have Zod schemas - serialize them to JSON
35
+ let schemaObject = {};
36
+ if (langchainTool.schema) {
37
+ // If it's a Zod schema, it might have a _def property
38
+ if (typeof langchainTool.schema === "object" &&
39
+ langchainTool.schema !== null) {
40
+ // Try to serialize to JSON, fallback to empty object
41
+ try {
42
+ schemaObject = JSON.parse(JSON.stringify(langchainTool.schema));
43
+ }
44
+ catch {
45
+ schemaObject = {};
46
+ }
47
+ }
48
+ }
49
+ return {
50
+ name: langchainTool.name,
51
+ description: langchainTool.description || "",
52
+ schema: schemaObject,
53
+ };
54
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@townco/agent",
3
- "version": "0.1.52",
3
+ "version": "0.1.53",
4
4
  "type": "module",
5
5
  "module": "index.ts",
6
6
  "files": [
@@ -73,11 +73,11 @@
73
73
  "@opentelemetry/sdk-trace-base": "^1.28.0",
74
74
  "@opentelemetry/sdk-trace-node": "^1.28.0",
75
75
  "@opentelemetry/semantic-conventions": "^1.28.0",
76
- "@townco/core": "0.0.25",
77
- "@townco/gui-template": "0.1.44",
78
- "@townco/tsconfig": "0.1.44",
79
- "@townco/tui-template": "0.1.44",
80
- "@townco/ui": "0.1.47",
76
+ "@townco/core": "0.0.26",
77
+ "@townco/gui-template": "0.1.45",
78
+ "@townco/tsconfig": "0.1.45",
79
+ "@townco/tui-template": "0.1.45",
80
+ "@townco/ui": "0.1.48",
81
81
  "exa-js": "^2.0.0",
82
82
  "hono": "^4.10.4",
83
83
  "langchain": "^1.0.3",
@@ -1,5 +0,0 @@
1
- /**
2
- * Quick script to verify Jaeger connectivity
3
- * Run with: bun check-jaeger.ts
4
- */
5
- export {};
@@ -1,82 +0,0 @@
1
- /**
2
- * Quick script to verify Jaeger connectivity
3
- * Run with: bun check-jaeger.ts
4
- */
5
- export {}; // Make this a module for top-level await
6
- console.log("šŸ” Checking Jaeger connectivity...\n");
7
- // Check if Jaeger collector is accepting OTLP on gRPC port
8
- const checkPort = async (port, protocol) => {
9
- try {
10
- const net = await import("node:net");
11
- const socket = new net.Socket();
12
- return new Promise((resolve) => {
13
- socket.setTimeout(2000);
14
- socket.on("connect", () => {
15
- console.log(`āœ… ${protocol} port ${port} is accepting connections`);
16
- socket.destroy();
17
- resolve(true);
18
- });
19
- socket.on("timeout", () => {
20
- console.log(`āŒ ${protocol} port ${port} timed out`);
21
- socket.destroy();
22
- resolve(false);
23
- });
24
- socket.on("error", (error) => {
25
- console.log(`āŒ ${protocol} port ${port} not reachable: ${error.message}`);
26
- resolve(false);
27
- });
28
- socket.connect(port, "localhost");
29
- });
30
- }
31
- catch (error) {
32
- console.log(`āŒ Error checking ${protocol} port ${port}:`, error);
33
- return false;
34
- }
35
- };
36
- // Check Jaeger ports
37
- console.log("Checking Jaeger ports:");
38
- console.log("─────────────────────────────");
39
- await checkPort(4317, "OTLP gRPC"); // Collector OTLP gRPC
40
- await checkPort(4318, "OTLP HTTP"); // Collector OTLP HTTP
41
- await checkPort(16686, "UI "); // Query UI
42
- console.log("\nšŸ” Checking Docker container...\n");
43
- // Check if Jaeger container is running
44
- try {
45
- const { execSync } = await import("node:child_process");
46
- const output = execSync("docker ps --filter name=jaeger --format '{{.Status}}'", {
47
- encoding: "utf-8",
48
- }).trim();
49
- if (output) {
50
- console.log(`āœ… Jaeger container is running: ${output}`);
51
- // Check container logs for OTLP
52
- try {
53
- const logs = execSync("docker logs jaeger 2>&1 | tail -20", {
54
- encoding: "utf-8",
55
- });
56
- console.log("\nšŸ“‹ Recent container logs:");
57
- console.log("─────────────────────────────");
58
- console.log(logs);
59
- }
60
- catch (e) {
61
- console.log("āš ļø Could not fetch container logs");
62
- }
63
- }
64
- else {
65
- console.log("āŒ No Jaeger container running with name 'jaeger'");
66
- console.log("\nšŸ’” Start Jaeger with:");
67
- console.log("docker run -d --name jaeger \\");
68
- console.log(" -e COLLECTOR_OTLP_ENABLED=true \\");
69
- console.log(" -p 16686:16686 \\");
70
- console.log(" -p 4317:4317 \\");
71
- console.log(" -p 4318:4318 \\");
72
- console.log(" jaegertracing/all-in-one:latest");
73
- }
74
- }
75
- catch (error) {
76
- console.log("āš ļø Could not check Docker container:", error);
77
- }
78
- console.log("\nšŸŽÆ Next steps:");
79
- console.log("─────────────────────────────");
80
- console.log("1. Make sure ports above show āœ…");
81
- console.log("2. Run the test: ENABLE_TELEMETRY=true bun test-telemetry.ts");
82
- console.log("3. Check UI: http://localhost:16686");
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * Helper script to test makeSubagentsTool
4
- *
5
- * Usage:
6
- * bun packages/agent/run-subagents.ts
7
- * bun packages/agent/run-subagents.ts "your custom query here"
8
- */
9
- export {};
@@ -1,110 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * Helper script to test makeSubagentsTool
4
- *
5
- * Usage:
6
- * bun packages/agent/run-subagents.ts
7
- * bun packages/agent/run-subagents.ts "your custom query here"
8
- */
9
- import { makeSubagentsTool } from "./utils";
10
- import { makeRunnerFromDefinition } from "./runner";
11
- // Default query if none provided
12
- const defaultQuery = "Can you search for news about artificial intelligence?";
13
- const userQuery = process.argv[2] || defaultQuery;
14
- console.log("🧪 Testing makeSubagentsTool\n");
15
- console.log("Query:", userQuery);
16
- console.log("─".repeat(60));
17
- // Create a simple subagent definition
18
- const simpleSubagent = {
19
- model: "claude-sonnet-4-5-20250929",
20
- systemPrompt: "You are a helpful research assistant. Provide concise, informative responses.",
21
- tools: [
22
- "web_search",
23
- "todo_write",
24
- ],
25
- mcps: [],
26
- };
27
- // Create the coordinator agent with subagent tool
28
- const coordinatorAgent = {
29
- model: "claude-sonnet-4-5-20250929",
30
- systemPrompt: `You are a coordinator agent that delegates tasks to specialized subagents.
31
- When you receive a query, evaluate if it needs to be delegated to a subagent.
32
- If so, use the Task tool with the appropriate subagent.`,
33
- tools: [
34
- makeSubagentsTool([
35
- {
36
- agentName: "researcher",
37
- description: "Use this agent to research topics, search the web, and gather information",
38
- path: import.meta.filename, // Points to itself as a simple test
39
- },
40
- {
41
- agentName: "simple",
42
- description: "Use this for general tasks that don't require specialized tools",
43
- path: import.meta.filename,
44
- },
45
- ]),
46
- ],
47
- mcps: [],
48
- };
49
- // Run the test
50
- async function runTest() {
51
- console.log("\nšŸ“ Creating runner...");
52
- const runner = makeRunnerFromDefinition(coordinatorAgent);
53
- console.log("šŸš€ Running query...\n");
54
- try {
55
- const stream = runner.invoke({
56
- prompt: [
57
- {
58
- type: "text",
59
- text: userQuery,
60
- },
61
- ],
62
- sessionId: "test-session",
63
- messageId: "msg-1",
64
- });
65
- console.log("šŸ“Š Stream output:");
66
- console.log("─".repeat(60));
67
- let messageCount = 0;
68
- let toolCallCount = 0;
69
- let lastTextContent = "";
70
- for await (const chunk of stream) {
71
- messageCount++;
72
- // Pretty print different types of chunks
73
- if (chunk.type === "agent_message_chunk") {
74
- const content = chunk.content;
75
- if (content.type === "text" && content.text) {
76
- process.stdout.write(content.text);
77
- lastTextContent += content.text;
78
- }
79
- else if (content.type === "tool_use") {
80
- toolCallCount++;
81
- console.log(`\n\nšŸ”§ Tool Call #${toolCallCount}: ${content.name}`);
82
- console.log(" Input:", JSON.stringify(content.input, null, 2).split('\n').join('\n '));
83
- }
84
- }
85
- else if (chunk.type === "tool_result") {
86
- console.log("\n\nāœ… Tool Result:");
87
- console.log(" ", JSON.stringify(chunk, null, 2).split('\n').join('\n '));
88
- }
89
- else {
90
- // Print other chunk types for debugging
91
- console.log("\n\nšŸ“¦ Chunk:", JSON.stringify(chunk, null, 2));
92
- }
93
- }
94
- console.log("\n\n" + "─".repeat(60));
95
- console.log("✨ Test completed!");
96
- console.log(` Total chunks: ${messageCount}`);
97
- console.log(` Tool calls: ${toolCallCount}`);
98
- console.log("─".repeat(60));
99
- }
100
- catch (error) {
101
- console.error("\nāŒ Error during test:");
102
- console.error(error);
103
- process.exit(1);
104
- }
105
- }
106
- // Run the test
107
- runTest().catch((error) => {
108
- console.error("Fatal error:", error);
109
- process.exit(1);
110
- });
@@ -1,36 +0,0 @@
1
- import { z } from "zod";
2
- /**
3
- * Custom stream events emitted by subagent tools via config.writer
4
- */
5
- export declare const SubagentToolCallEventSchema: z.ZodObject<{
6
- type: z.ZodLiteral<"tool_call">;
7
- toolName: z.ZodString;
8
- }, z.core.$strip>;
9
- export declare const SubagentMessageEventSchema: z.ZodObject<{
10
- type: z.ZodLiteral<"message">;
11
- text: z.ZodString;
12
- }, z.core.$strip>;
13
- export declare const SubagentEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
14
- type: z.ZodLiteral<"tool_call">;
15
- toolName: z.ZodString;
16
- }, z.core.$strip>, z.ZodObject<{
17
- type: z.ZodLiteral<"message">;
18
- text: z.ZodString;
19
- }, z.core.$strip>], "type">;
20
- export type SubagentToolCallEvent = z.infer<typeof SubagentToolCallEventSchema>;
21
- export type SubagentMessageEvent = z.infer<typeof SubagentMessageEventSchema>;
22
- export type SubagentEvent = z.infer<typeof SubagentEventSchema>;
23
- /**
24
- * Wrapper for subagent events that includes the parent tool call ID
25
- */
26
- export declare const CustomStreamChunkSchema: z.ZodObject<{
27
- parentToolCallId: z.ZodString;
28
- event: z.ZodDiscriminatedUnion<[z.ZodObject<{
29
- type: z.ZodLiteral<"tool_call">;
30
- toolName: z.ZodString;
31
- }, z.core.$strip>, z.ZodObject<{
32
- type: z.ZodLiteral<"message">;
33
- text: z.ZodString;
34
- }, z.core.$strip>], "type">;
35
- }, z.core.$strip>;
36
- export type CustomStreamChunk = z.infer<typeof CustomStreamChunkSchema>;
@@ -1,23 +0,0 @@
1
- import { z } from "zod";
2
- /**
3
- * Custom stream events emitted by subagent tools via config.writer
4
- */
5
- export const SubagentToolCallEventSchema = z.object({
6
- type: z.literal("tool_call"),
7
- toolName: z.string(),
8
- });
9
- export const SubagentMessageEventSchema = z.object({
10
- type: z.literal("message"),
11
- text: z.string(),
12
- });
13
- export const SubagentEventSchema = z.discriminatedUnion("type", [
14
- SubagentToolCallEventSchema,
15
- SubagentMessageEventSchema,
16
- ]);
17
- /**
18
- * Wrapper for subagent events that includes the parent tool call ID
19
- */
20
- export const CustomStreamChunkSchema = z.object({
21
- parentToolCallId: z.string(),
22
- event: SubagentEventSchema,
23
- });
@@ -1,14 +0,0 @@
1
- import { z } from "zod";
2
- export declare function makeBashTool(workingDirectory?: string): import("langchain").DynamicStructuredTool<z.ZodObject<{
3
- command: z.ZodString;
4
- timeout: z.ZodOptional<z.ZodNumber>;
5
- description: z.ZodOptional<z.ZodString>;
6
- }, z.core.$strip>, {
7
- command: string;
8
- timeout?: number | undefined;
9
- description?: string | undefined;
10
- }, {
11
- command: string;
12
- timeout?: number | undefined;
13
- description?: string | undefined;
14
- }, unknown>;