talon-agent 1.3.0 → 1.4.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "talon-agent",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Multi-frontend AI agent with full tool access, streaming, cron jobs, and plugin system",
5
5
  "author": "Dylan Neve",
6
6
  "license": "MIT",
@@ -52,11 +52,13 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@anthropic-ai/claude-agent-sdk": "^0.2.97",
55
+ "@brave/brave-search-mcp-server": "^2.0.75",
55
56
  "@clack/prompts": "^1.2.0",
56
57
  "@grammyjs/auto-retry": "^2.0.2",
57
58
  "@grammyjs/transformer-throttler": "^1.2.1",
58
59
  "@modelcontextprotocol/sdk": "^1.29.0",
59
60
  "@opencode-ai/sdk": "^1.4.0",
61
+ "@playwright/mcp": "^0.0.70",
60
62
  "big-integer": "^1.6.52",
61
63
  "cheerio": "^1.2.0",
62
64
  "croner": "^10.0.1",
@@ -0,0 +1,216 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { ALL_TOOLS, composeTools } from "../core/tools/index.js";
3
+ import type {
4
+ ToolDefinition,
5
+ ToolFrontend,
6
+ ToolTag,
7
+ } from "../core/tools/types.js";
8
+
9
+ describe("ALL_TOOLS registry", () => {
10
+ it("contains tools from every domain", () => {
11
+ const tags = new Set(ALL_TOOLS.map((t) => t.tag));
12
+ expect(tags).toContain("messaging");
13
+ expect(tags).toContain("chat");
14
+ expect(tags).toContain("history");
15
+ expect(tags).toContain("members");
16
+ expect(tags).toContain("media");
17
+ expect(tags).toContain("stickers");
18
+ expect(tags).toContain("scheduling");
19
+ expect(tags).toContain("web");
20
+ });
21
+
22
+ it("has no duplicate tool names", () => {
23
+ const names = ALL_TOOLS.map((t) => t.name);
24
+ expect(new Set(names).size).toBe(names.length);
25
+ });
26
+
27
+ it("every tool has required fields", () => {
28
+ for (const tool of ALL_TOOLS) {
29
+ expect(tool.name).toBeTruthy();
30
+ expect(tool.description).toBeTruthy();
31
+ expect(tool.schema).toBeDefined();
32
+ expect(typeof tool.execute).toBe("function");
33
+ expect(tool.tag).toBeTruthy();
34
+ }
35
+ });
36
+ });
37
+
38
+ describe("composeTools()", () => {
39
+ it("returns all tools when no options are given", () => {
40
+ const tools = composeTools();
41
+ expect(tools).toHaveLength(ALL_TOOLS.length);
42
+ });
43
+
44
+ it("returns a new array (not a reference to ALL_TOOLS)", () => {
45
+ const tools = composeTools();
46
+ expect(tools).not.toBe(ALL_TOOLS);
47
+ });
48
+
49
+ // ── Frontend filtering ────────────────────────────────────────────────
50
+
51
+ it("filters tools by telegram frontend", () => {
52
+ const tools = composeTools({ frontend: "telegram" });
53
+ // Should include telegram-specific and universal tools
54
+ expect(tools.length).toBeGreaterThan(0);
55
+ expect(tools.length).toBeLessThan(ALL_TOOLS.length);
56
+
57
+ for (const t of tools) {
58
+ const f = t.frontends;
59
+ expect(!f || f.includes("all") || f.includes("telegram")).toBe(true);
60
+ }
61
+ });
62
+
63
+ it("filters tools by teams frontend", () => {
64
+ const tools = composeTools({ frontend: "teams" });
65
+ expect(tools.length).toBeGreaterThan(0);
66
+
67
+ for (const t of tools) {
68
+ const f = t.frontends;
69
+ expect(!f || f.includes("all") || f.includes("teams")).toBe(true);
70
+ }
71
+ });
72
+
73
+ it("excludes telegram-only tools from teams", () => {
74
+ const teamsTools = composeTools({ frontend: "teams" });
75
+ const teamsNames = new Set(teamsTools.map((t) => t.name));
76
+
77
+ // react is telegram-only
78
+ expect(teamsNames.has("react")).toBe(false);
79
+ // send_message is teams-only — should be present
80
+ expect(teamsNames.has("send_message")).toBe(true);
81
+ });
82
+
83
+ it("excludes teams-only tools from telegram", () => {
84
+ const tgTools = composeTools({ frontend: "telegram" });
85
+ const tgNames = new Set(tgTools.map((t) => t.name));
86
+
87
+ // send_message is teams-only
88
+ expect(tgNames.has("send_message")).toBe(false);
89
+ // send is telegram-only — should be present
90
+ expect(tgNames.has("send")).toBe(true);
91
+ });
92
+
93
+ it("includes universal tools (no frontends set) for any frontend", () => {
94
+ const universalTools = ALL_TOOLS.filter((t) => !t.frontends);
95
+ expect(universalTools.length).toBeGreaterThan(0);
96
+
97
+ for (const frontend of [
98
+ "telegram",
99
+ "teams",
100
+ "terminal",
101
+ ] as ToolFrontend[]) {
102
+ const tools = composeTools({ frontend });
103
+ const names = new Set(tools.map((t) => t.name));
104
+ for (const ut of universalTools) {
105
+ expect(names.has(ut.name)).toBe(true);
106
+ }
107
+ }
108
+ });
109
+
110
+ it("includes tools with frontends: ['all'] for any frontend", () => {
111
+ const allFrontendTools = ALL_TOOLS.filter((t) =>
112
+ t.frontends?.includes("all"),
113
+ );
114
+ // Even if there are none right now, the filter logic is tested via universal tools
115
+ for (const frontend of [
116
+ "telegram",
117
+ "teams",
118
+ "terminal",
119
+ ] as ToolFrontend[]) {
120
+ const tools = composeTools({ frontend });
121
+ const names = new Set(tools.map((t) => t.name));
122
+ for (const t of allFrontendTools) {
123
+ expect(names.has(t.name)).toBe(true);
124
+ }
125
+ }
126
+ });
127
+
128
+ // ── Tag filtering ─────────────────────────────────────────────────────
129
+
130
+ it("filters by tags (include)", () => {
131
+ const tools = composeTools({ tags: ["web"] });
132
+ expect(tools.length).toBeGreaterThan(0);
133
+ for (const t of tools) {
134
+ expect(t.tag).toBe("web");
135
+ }
136
+ });
137
+
138
+ it("filters by multiple tags", () => {
139
+ const tools = composeTools({ tags: ["web", "scheduling"] });
140
+ expect(tools.length).toBeGreaterThan(0);
141
+ for (const t of tools) {
142
+ expect(["web", "scheduling"]).toContain(t.tag);
143
+ }
144
+ });
145
+
146
+ it("filters by excludeTags", () => {
147
+ const tools = composeTools({ excludeTags: ["stickers", "media"] });
148
+ for (const t of tools) {
149
+ expect(t.tag).not.toBe("stickers");
150
+ expect(t.tag).not.toBe("media");
151
+ }
152
+ expect(tools.length).toBeLessThan(ALL_TOOLS.length);
153
+ });
154
+
155
+ // ── Name exclusion ────────────────────────────────────────────────────
156
+
157
+ it("excludes tools by name", () => {
158
+ const tools = composeTools({ excludeNames: ["send", "react"] });
159
+ const names = new Set(tools.map((t) => t.name));
160
+ expect(names.has("send")).toBe(false);
161
+ expect(names.has("react")).toBe(false);
162
+ expect(tools.length).toBe(ALL_TOOLS.length - 2);
163
+ });
164
+
165
+ // ── Combined filters ──────────────────────────────────────────────────
166
+
167
+ it("combines frontend + tag filters", () => {
168
+ const tools = composeTools({ frontend: "telegram", tags: ["messaging"] });
169
+ expect(tools.length).toBeGreaterThan(0);
170
+ for (const t of tools) {
171
+ expect(t.tag).toBe("messaging");
172
+ const f = t.frontends;
173
+ expect(!f || f.includes("all") || f.includes("telegram")).toBe(true);
174
+ }
175
+ // Should NOT include teams send_message
176
+ const names = new Set(tools.map((t) => t.name));
177
+ expect(names.has("send_message")).toBe(false);
178
+ });
179
+
180
+ it("combines frontend + excludeTags", () => {
181
+ const tools = composeTools({
182
+ frontend: "telegram",
183
+ excludeTags: ["stickers"],
184
+ });
185
+ for (const t of tools) {
186
+ expect(t.tag).not.toBe("stickers");
187
+ }
188
+ });
189
+
190
+ it("combines frontend + excludeNames", () => {
191
+ const tools = composeTools({
192
+ frontend: "telegram",
193
+ excludeNames: ["fetch_url"],
194
+ });
195
+ const names = new Set(tools.map((t) => t.name));
196
+ expect(names.has("fetch_url")).toBe(false);
197
+ expect(names.has("send")).toBe(true);
198
+ });
199
+
200
+ // ── Edge cases ────────────────────────────────────────────────────────
201
+
202
+ it("returns empty array when tags match nothing", () => {
203
+ const tools = composeTools({ tags: ["nonexistent" as ToolTag] });
204
+ expect(tools).toEqual([]);
205
+ });
206
+
207
+ it("returns all tools when excludeNames is empty", () => {
208
+ const tools = composeTools({ excludeNames: [] });
209
+ expect(tools).toHaveLength(ALL_TOOLS.length);
210
+ });
211
+
212
+ it("returns all tools when excludeTags is empty", () => {
213
+ const tools = composeTools({ excludeTags: [] });
214
+ expect(tools).toHaveLength(ALL_TOOLS.length);
215
+ });
216
+ });
@@ -193,7 +193,6 @@ describe("fuzz: handleSharedAction() — unknown actions", () => {
193
193
  "get_user_messages",
194
194
  "list_known_users",
195
195
  "list_media",
196
- "web_search",
197
196
  "fetch_url",
198
197
  "create_cron_job",
199
198
  "list_cron_jobs",
@@ -224,7 +223,6 @@ describe("fuzz: handleSharedAction() — unknown actions", () => {
224
223
  "get_user_messages",
225
224
  "list_known_users",
226
225
  "list_media",
227
- "web_search",
228
226
  "fetch_url",
229
227
  "create_cron_job",
230
228
  "list_cron_jobs",