@townco/agent 0.1.52 → 0.1.54
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 +18 -0
- package/dist/acp-server/adapter.js +258 -19
- package/dist/acp-server/http.js +39 -1
- package/dist/acp-server/session-storage.d.ts +18 -1
- package/dist/acp-server/session-storage.js +25 -0
- package/dist/definition/index.d.ts +2 -2
- package/dist/definition/index.js +1 -0
- package/dist/runner/agent-runner.d.ts +11 -2
- package/dist/runner/langchain/index.d.ts +0 -1
- package/dist/runner/langchain/index.js +265 -64
- package/dist/runner/langchain/tools/generate_image.d.ts +28 -0
- package/dist/runner/langchain/tools/generate_image.js +135 -0
- package/dist/runner/langchain/tools/subagent.d.ts +6 -1
- package/dist/runner/langchain/tools/subagent.js +12 -2
- package/dist/runner/tools.d.ts +19 -2
- package/dist/runner/tools.js +9 -0
- package/dist/telemetry/index.js +7 -1
- package/dist/templates/index.d.ts +3 -0
- package/dist/templates/index.js +26 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/context-size-calculator.d.ts +9 -4
- package/dist/utils/context-size-calculator.js +23 -6
- package/dist/utils/tool-overhead-calculator.d.ts +30 -0
- package/dist/utils/tool-overhead-calculator.js +54 -0
- package/package.json +7 -6
- package/templates/index.ts +36 -5
- package/dist/check-jaeger.d.ts +0 -5
- package/dist/check-jaeger.js +0 -82
- package/dist/run-subagents.d.ts +0 -9
- package/dist/run-subagents.js +0 -110
- package/dist/runner/langchain/custom-stream-types.d.ts +0 -36
- package/dist/runner/langchain/custom-stream-types.js +0 -23
- package/dist/runner/langchain/tools/bash.d.ts +0 -14
- package/dist/runner/langchain/tools/bash.js +0 -135
- package/dist/scaffold/link-local.d.ts +0 -1
- package/dist/scaffold/link-local.js +0 -54
- package/dist/test-telemetry.d.ts +0 -5
- package/dist/test-telemetry.js +0 -88
- package/dist/utils/logger.d.ts +0 -39
- package/dist/utils/logger.js +0 -175
|
@@ -9,7 +9,7 @@ import { SUBAGENT_MODE_KEY } from "../../../acp-server/adapter.js";
|
|
|
9
9
|
/**
|
|
10
10
|
* Name of the Task tool created by makeSubagentsTool
|
|
11
11
|
*/
|
|
12
|
-
export const
|
|
12
|
+
export const SUBAGENT_TOOL_NAME = "subagent";
|
|
13
13
|
/**
|
|
14
14
|
* Creates a DirectTool that delegates work to one of multiple configured subagents.
|
|
15
15
|
*
|
|
@@ -61,9 +61,17 @@ export function makeSubagentsTool(configs) {
|
|
|
61
61
|
.map((config) => `"${config.agentName}": ${config.description}`)
|
|
62
62
|
.join("\n");
|
|
63
63
|
const agentNames = configs.map((c) => c.agentName);
|
|
64
|
+
// Extract subagent configs for metadata (agentName, description, displayName)
|
|
65
|
+
const subagentConfigs = configs.map((config) => ({
|
|
66
|
+
agentName: config.agentName,
|
|
67
|
+
description: config.description,
|
|
68
|
+
displayName: config.displayName,
|
|
69
|
+
}));
|
|
64
70
|
return {
|
|
65
71
|
type: "direct",
|
|
66
|
-
name:
|
|
72
|
+
name: SUBAGENT_TOOL_NAME,
|
|
73
|
+
prettyName: "Subagent",
|
|
74
|
+
icon: "BrainCircuit",
|
|
67
75
|
description: `Launch a new agent to handle complex, multi-step tasks autonomously.
|
|
68
76
|
|
|
69
77
|
The Task tool launches specialized agents (subprocesses) that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.
|
|
@@ -129,6 +137,8 @@ assistant: "I'm going to use the Task tool to launch the greeting-responder agen
|
|
|
129
137
|
.describe("The name of the subagent to use"),
|
|
130
138
|
query: z.string().describe("The query or task to send to the subagent"),
|
|
131
139
|
}),
|
|
140
|
+
// Expose subagent configs for metadata extraction by the adapter
|
|
141
|
+
subagentConfigs,
|
|
132
142
|
fn: async (input) => {
|
|
133
143
|
const { agentName, query } = input;
|
|
134
144
|
const agent = agentMap.get(agentName);
|
package/dist/runner/tools.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
/** Built-in tool types. */
|
|
3
|
-
export declare const zBuiltInToolType: z.ZodUnion<readonly [z.ZodLiteral<"todo_write">, z.ZodLiteral<"get_weather">, z.ZodLiteral<"web_search">, z.ZodLiteral<"filesystem">]>;
|
|
3
|
+
export declare const zBuiltInToolType: z.ZodUnion<readonly [z.ZodLiteral<"todo_write">, z.ZodLiteral<"get_weather">, z.ZodLiteral<"web_search">, z.ZodLiteral<"filesystem">, z.ZodLiteral<"generate_image">]>;
|
|
4
|
+
/** Subagent configuration schema for Task tools. */
|
|
5
|
+
export declare const zSubagentConfig: z.ZodObject<{
|
|
6
|
+
agentName: z.ZodString;
|
|
7
|
+
description: z.ZodString;
|
|
8
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>;
|
|
4
10
|
/** Direct tool object schema (for tools imported directly in code). */
|
|
5
11
|
declare const zDirectTool: z.ZodObject<{
|
|
6
12
|
type: z.ZodLiteral<"direct">;
|
|
@@ -10,9 +16,14 @@ declare const zDirectTool: z.ZodObject<{
|
|
|
10
16
|
schema: z.ZodAny;
|
|
11
17
|
prettyName: z.ZodOptional<z.ZodString>;
|
|
12
18
|
icon: z.ZodOptional<z.ZodString>;
|
|
19
|
+
subagentConfigs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
20
|
+
agentName: z.ZodString;
|
|
21
|
+
description: z.ZodString;
|
|
22
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strip>>>;
|
|
13
24
|
}, z.core.$strip>;
|
|
14
25
|
/** Tool type - can be a built-in tool string or custom tool object. */
|
|
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<{
|
|
26
|
+
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.ZodLiteral<"generate_image">]>, z.ZodObject<{
|
|
16
27
|
type: z.ZodLiteral<"custom">;
|
|
17
28
|
modulePath: z.ZodString;
|
|
18
29
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -26,8 +37,14 @@ export declare const zToolType: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodL
|
|
|
26
37
|
schema: z.ZodAny;
|
|
27
38
|
prettyName: z.ZodOptional<z.ZodString>;
|
|
28
39
|
icon: z.ZodOptional<z.ZodString>;
|
|
40
|
+
subagentConfigs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
41
|
+
agentName: z.ZodString;
|
|
42
|
+
description: z.ZodString;
|
|
43
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$strip>>>;
|
|
29
45
|
}, z.core.$strip>]>;
|
|
30
46
|
export type ToolType = z.infer<typeof zToolType>;
|
|
31
47
|
export type BuiltInToolType = z.infer<typeof zBuiltInToolType>;
|
|
32
48
|
export type DirectTool = z.infer<typeof zDirectTool>;
|
|
49
|
+
export type SubagentConfig = z.infer<typeof zSubagentConfig>;
|
|
33
50
|
export {};
|
package/dist/runner/tools.js
CHANGED
|
@@ -5,6 +5,7 @@ export const zBuiltInToolType = z.union([
|
|
|
5
5
|
z.literal("get_weather"),
|
|
6
6
|
z.literal("web_search"),
|
|
7
7
|
z.literal("filesystem"),
|
|
8
|
+
z.literal("generate_image"),
|
|
8
9
|
]);
|
|
9
10
|
/** Custom tool schema (loaded from module path). */
|
|
10
11
|
const zCustomTool = z.object({
|
|
@@ -16,6 +17,12 @@ const zFilesystemTool = z.object({
|
|
|
16
17
|
type: z.literal("filesystem"),
|
|
17
18
|
working_directory: z.string().optional(),
|
|
18
19
|
});
|
|
20
|
+
/** Subagent configuration schema for Task tools. */
|
|
21
|
+
export const zSubagentConfig = z.object({
|
|
22
|
+
agentName: z.string(),
|
|
23
|
+
description: z.string(),
|
|
24
|
+
displayName: z.string().optional(),
|
|
25
|
+
});
|
|
19
26
|
/** Direct tool object schema (for tools imported directly in code). */
|
|
20
27
|
const zDirectTool = z.object({
|
|
21
28
|
type: z.literal("direct"),
|
|
@@ -25,6 +32,8 @@ const zDirectTool = z.object({
|
|
|
25
32
|
schema: z.any(), // Accept any Zod schema
|
|
26
33
|
prettyName: z.string().optional(),
|
|
27
34
|
icon: z.string().optional(),
|
|
35
|
+
/** Subagent configurations (only present for Task tools created by makeSubagentsTool). */
|
|
36
|
+
subagentConfigs: z.array(zSubagentConfig).optional(),
|
|
28
37
|
});
|
|
29
38
|
/** Tool type - can be a built-in tool string or custom tool object. */
|
|
30
39
|
export const zToolType = z.union([
|
package/dist/telemetry/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Provides tracing and logging capabilities for agent operations
|
|
4
4
|
*/
|
|
5
5
|
import { context, SpanStatusCode, trace, } from "@opentelemetry/api";
|
|
6
|
-
import { logs } from "@opentelemetry/api-logs";
|
|
6
|
+
import { logs, SeverityNumber, } from "@opentelemetry/api-logs";
|
|
7
7
|
class AgentTelemetry {
|
|
8
8
|
tracer = null;
|
|
9
9
|
logger = null;
|
|
@@ -115,7 +115,13 @@ class AgentTelemetry {
|
|
|
115
115
|
if (!this.enabled || !this.logger) {
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
|
+
const severityNumber = {
|
|
119
|
+
info: SeverityNumber.INFO,
|
|
120
|
+
warn: SeverityNumber.WARN,
|
|
121
|
+
error: SeverityNumber.ERROR,
|
|
122
|
+
}[level];
|
|
118
123
|
this.logger.emit({
|
|
124
|
+
severityNumber,
|
|
119
125
|
severityText: level.toUpperCase(),
|
|
120
126
|
body: message,
|
|
121
127
|
attributes: {
|
|
@@ -2,6 +2,9 @@ import type { AgentDefinition } from "../definition";
|
|
|
2
2
|
export interface TemplateVars {
|
|
3
3
|
name: string;
|
|
4
4
|
model: string;
|
|
5
|
+
displayName?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
suggestedPrompts?: string[];
|
|
5
8
|
tools: Array<string | {
|
|
6
9
|
type: "custom";
|
|
7
10
|
modulePath: string;
|
package/dist/templates/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as prettier from "prettier";
|
|
2
2
|
export function getTemplateVars(name, definition) {
|
|
3
3
|
const tools = definition.tools ?? [];
|
|
4
|
-
|
|
4
|
+
const result = {
|
|
5
5
|
name,
|
|
6
6
|
model: definition.model,
|
|
7
7
|
tools,
|
|
@@ -9,6 +9,16 @@ export function getTemplateVars(name, definition) {
|
|
|
9
9
|
hasWebSearch: tools.some((tool) => typeof tool === "string" && tool === "web_search"),
|
|
10
10
|
hooks: definition.hooks,
|
|
11
11
|
};
|
|
12
|
+
if (definition.displayName) {
|
|
13
|
+
result.displayName = definition.displayName;
|
|
14
|
+
}
|
|
15
|
+
if (definition.description) {
|
|
16
|
+
result.description = definition.description;
|
|
17
|
+
}
|
|
18
|
+
if (definition.suggestedPrompts) {
|
|
19
|
+
result.suggestedPrompts = definition.suggestedPrompts;
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
12
22
|
}
|
|
13
23
|
export function generatePackageJson(vars) {
|
|
14
24
|
// Include @townco/agent as a dependency instead of bundling
|
|
@@ -44,12 +54,24 @@ export function generatePackageJson(vars) {
|
|
|
44
54
|
return JSON.stringify(pkg, null, 2);
|
|
45
55
|
}
|
|
46
56
|
export async function generateIndexTs(vars) {
|
|
57
|
+
// Build agent definition with fields in a logical order
|
|
47
58
|
const agentDef = {
|
|
48
59
|
model: vars.model,
|
|
49
|
-
systemPrompt: vars.systemPrompt,
|
|
50
|
-
tools: vars.tools,
|
|
51
|
-
hooks: vars.hooks,
|
|
52
60
|
};
|
|
61
|
+
if (vars.displayName) {
|
|
62
|
+
agentDef.displayName = vars.displayName;
|
|
63
|
+
}
|
|
64
|
+
if (vars.description) {
|
|
65
|
+
agentDef.description = vars.description;
|
|
66
|
+
}
|
|
67
|
+
if (vars.suggestedPrompts) {
|
|
68
|
+
agentDef.suggestedPrompts = vars.suggestedPrompts;
|
|
69
|
+
}
|
|
70
|
+
agentDef.systemPrompt = vars.systemPrompt;
|
|
71
|
+
agentDef.tools = vars.tools;
|
|
72
|
+
if (vars.hooks) {
|
|
73
|
+
agentDef.hooks = vars.hooks;
|
|
74
|
+
}
|
|
53
75
|
return prettier.format(`import { makeHttpTransport, makeStdioTransport } from "@townco/agent/acp-server";
|
|
54
76
|
import type { AgentDefinition } from "@townco/agent/definition";
|
|
55
77
|
import { basename } from "node:path";
|