talon-agent 1.2.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.
Files changed (46) hide show
  1. package/package.json +7 -6
  2. package/prompts/dream.md +6 -2
  3. package/prompts/mempalace.md +57 -0
  4. package/src/__tests__/compose-tools.test.ts +216 -0
  5. package/src/__tests__/cron-store-extended.test.ts +1 -1
  6. package/src/__tests__/dream.test.ts +118 -1
  7. package/src/__tests__/fuzz.test.ts +1 -3
  8. package/src/__tests__/gateway-actions.test.ts +1 -423
  9. package/src/__tests__/gateway-retry.test.ts +0 -4
  10. package/src/__tests__/handlers.test.ts +0 -4
  11. package/src/__tests__/heartbeat.test.ts +3 -0
  12. package/src/__tests__/mempalace-plugin.test.ts +295 -0
  13. package/src/__tests__/plugin.test.ts +169 -0
  14. package/src/__tests__/storage-save-errors.test.ts +1 -1
  15. package/src/__tests__/time.test.ts +1 -1
  16. package/src/__tests__/watchdog.test.ts +1 -3
  17. package/src/__tests__/workspace.test.ts +0 -1
  18. package/src/backend/claude-sdk/index.ts +39 -54
  19. package/src/backend/opencode/index.ts +5 -20
  20. package/src/bootstrap.ts +140 -11
  21. package/src/core/dream.ts +40 -6
  22. package/src/core/gateway-actions.ts +0 -87
  23. package/src/core/plugin.ts +103 -16
  24. package/src/core/tools/bridge.ts +40 -0
  25. package/src/core/tools/chat.ts +52 -0
  26. package/src/core/tools/history.ts +80 -0
  27. package/src/core/tools/index.ts +82 -0
  28. package/src/core/tools/mcp-server.ts +64 -0
  29. package/src/core/tools/media.ts +23 -0
  30. package/src/core/tools/members.ts +46 -0
  31. package/src/core/tools/messaging.ts +300 -0
  32. package/src/core/tools/scheduling.ts +89 -0
  33. package/src/core/tools/stickers.ts +143 -0
  34. package/src/core/tools/types.ts +60 -0
  35. package/src/core/tools/web.ts +26 -0
  36. package/src/frontend/telegram/actions.ts +10 -1
  37. package/src/frontend/telegram/handlers.ts +5 -17
  38. package/src/plugins/github/index.ts +106 -0
  39. package/src/plugins/mempalace/index.ts +147 -0
  40. package/src/plugins/playwright/index.ts +82 -0
  41. package/src/storage/sessions.ts +0 -10
  42. package/src/util/config.ts +31 -1
  43. package/src/util/log.ts +4 -1
  44. package/src/util/paths.ts +9 -0
  45. package/src/backend/claude-sdk/tools.ts +0 -651
  46. package/src/frontend/teams/tools.ts +0 -175
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "talon-agent",
3
- "version": "1.2.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",
@@ -44,7 +44,6 @@
44
44
  "test": "vitest run",
45
45
  "test:watch": "vitest",
46
46
  "test:coverage": "vitest run --coverage",
47
- "test:mutation": "stryker run",
48
47
  "typecheck": "tsc --noEmit",
49
48
  "lint": "oxlint src/",
50
49
  "knip": "knip",
@@ -52,12 +51,14 @@
52
51
  "format:check": "prettier --check src/ prompts/"
53
52
  },
54
53
  "dependencies": {
55
- "@anthropic-ai/claude-agent-sdk": "^0.2.96",
54
+ "@anthropic-ai/claude-agent-sdk": "^0.2.97",
55
+ "@brave/brave-search-mcp-server": "^2.0.75",
56
56
  "@clack/prompts": "^1.2.0",
57
57
  "@grammyjs/auto-retry": "^2.0.2",
58
58
  "@grammyjs/transformer-throttler": "^1.2.1",
59
59
  "@modelcontextprotocol/sdk": "^1.29.0",
60
60
  "@opencode-ai/sdk": "^1.4.0",
61
+ "@playwright/mcp": "^0.0.70",
61
62
  "big-integer": "^1.6.52",
62
63
  "cheerio": "^1.2.0",
63
64
  "croner": "^10.0.1",
@@ -74,9 +75,6 @@
74
75
  "zod": "^4.3.6"
75
76
  },
76
77
  "devDependencies": {
77
- "@stryker-mutator/core": "^9.6.0",
78
- "@stryker-mutator/typescript-checker": "^9.6.0",
79
- "@stryker-mutator/vitest-runner": "^9.6.0",
80
78
  "@types/node": "^25.5.2",
81
79
  "@types/write-file-atomic": "^4.0.3",
82
80
  "@vitest/coverage-v8": "^4.1.3",
@@ -86,5 +84,8 @@
86
84
  "prettier": "^3.8.1",
87
85
  "typescript": "^6.0.2",
88
86
  "vitest": "^4.1.3"
87
+ },
88
+ "overrides": {
89
+ "@anthropic-ai/sdk": "^0.86.1"
89
90
  }
90
91
  }
package/prompts/dream.md CHANGED
@@ -1,8 +1,8 @@
1
1
  You are Talon's background memory consolidation agent. Your job is to update the persistent memory file with new information learned from recent interaction logs.
2
2
 
3
- You have access ONLY to filesystem tools (Read, Write, Edit, Bash, Glob, Grep). Do NOT attempt to use any Telegram, MCP, or messaging tools.
3
+ You primarily use filesystem tools (Read, Write, Edit, Bash, Glob, Grep). Do NOT attempt to use any Telegram or other messaging tools. MCP tools may be used if required by Stage 5.
4
4
 
5
- ## Your 4-stage task
5
+ ## Your 5-stage task
6
6
 
7
7
  ### Stage 1 — Orient
8
8
 
@@ -42,4 +42,8 @@ You have access ONLY to filesystem tools (Read, Write, Edit, Bash, Glob, Grep).
42
42
  - Do NOT remove entries just because they're old — only remove if wrong or superseded
43
43
  - Write the updated memory.md back to `{{memoryFile}}`
44
44
 
45
+ ### Stage 5 — Mine to MemPalace & Write Diary (optional)
46
+
47
+ {{mempalaceSection}}
48
+
45
49
  When done with memory consolidation, stop. The system handles all dream_state.json updates.
@@ -0,0 +1,57 @@
1
+ ## MemPalace — Long-term Memory
2
+
3
+ You have access to a local memory palace via MCP tools. The palace stores verbatim conversation history and a temporal knowledge graph — all local, zero cloud, zero API calls.
4
+
5
+ ### Architecture
6
+
7
+ - **Wings** = top-level categories (people, projects, topics)
8
+ - **Rooms** = specific subjects within a wing
9
+ - **Drawers** = individual memory chunks (verbatim text)
10
+ - **Knowledge Graph** = entity-relationship facts with temporal validity
11
+
12
+ ### Protocol — FOLLOW EVERY SESSION
13
+
14
+ 1. **BEFORE RESPONDING** about any person, project, or past event: call `mempalace_search` or `mempalace_kg_query` FIRST. Never guess — verify from the palace.
15
+ 2. **IF UNSURE** about a fact (name, age, relationship, preference): query the palace. Wrong is worse than slow.
16
+ 3. **WHEN FACTS CHANGE**: Call `mempalace_kg_invalidate` on the old fact, then `mempalace_kg_add` for the new one.
17
+ 4. **AFTER LEARNING** something important: store it. Use `mempalace_add_drawer` for rich context, `mempalace_kg_add` for structured facts.
18
+
19
+ ### Tools
20
+
21
+ **Search & Browse:**
22
+
23
+ - `mempalace_search` — Semantic search. Use short keywords/questions, not full sentences. Filter by wing/room.
24
+ - `mempalace_check_duplicate` — Check before filing new content (threshold default 0.9, lower to 0.85 to catch near-dupes).
25
+ - `mempalace_status` — Palace overview: total drawers, wings, rooms.
26
+ - `mempalace_list_wings` / `mempalace_list_rooms` — Browse structure.
27
+ - `mempalace_get_taxonomy` — Full wing/room/count tree.
28
+
29
+ **Knowledge Graph (Temporal Facts):**
30
+
31
+ - `mempalace_kg_query` — Query entity relationships. Supports `as_of` date filtering.
32
+ - `mempalace_kg_add` — Add fact: subject -> predicate -> object. Optional `valid_from`.
33
+ - `mempalace_kg_invalidate` — Mark a fact as no longer true.
34
+ - `mempalace_kg_timeline` — Chronological story of an entity.
35
+ - `mempalace_kg_stats` — Graph overview: entities, triples, relationship types.
36
+
37
+ **Palace Graph (Cross-Domain Connections):**
38
+
39
+ - `mempalace_traverse` — Walk from a room, find connected ideas across wings.
40
+ - `mempalace_find_tunnels` — Find rooms that bridge two wings.
41
+ - `mempalace_graph_stats` — Graph connectivity overview.
42
+
43
+ **Write:**
44
+
45
+ - `mempalace_add_drawer` — Store verbatim content into a wing/room. Auto-checks duplicates.
46
+ - `mempalace_delete_drawer` — Remove a drawer by ID.
47
+ - `mempalace_diary_write` — Write a session diary entry (agent_name, entry, topic).
48
+ - `mempalace_diary_read` — Read recent diary entries.
49
+
50
+ ### Tips
51
+
52
+ - Search is **semantic** (meaning-based), not keyword. "What did we discuss about database performance?" works better than "database".
53
+ - The knowledge graph stores typed relationships with **time windows**. It knows WHEN things were true.
54
+ - Use `mempalace_check_duplicate` before storing new content to avoid clutter.
55
+ - Diary entries accumulate across sessions. Write them to build continuity of self.
56
+
57
+ ### Palace location: `{{palacePath}}`
@@ -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
+ });
@@ -596,7 +596,7 @@ describe("loadCronJobs — invalid timezone stripping", () => {
596
596
  beforeEach(() => existsSyncMock.mockReset().mockReturnValue(false));
597
597
 
598
598
  it("strips invalid timezone from loaded job", async () => {
599
- const { isValidTimezone } = await import("../storage/cron-store.js");
599
+ await import("../storage/cron-store.js");
600
600
  const jobWithBadTz: Record<string, unknown> = {
601
601
  "tz-bad-id": {
602
602
  id: "tz-bad-id",
@@ -747,6 +747,7 @@ describe("dream error paths", () => {
747
747
  vi.doMock("write-file-atomic", () => ({ default: { sync: vi.fn() } }));
748
748
  vi.doMock("@anthropic-ai/claude-agent-sdk", () => ({
749
749
  query: vi.fn(async function* () {
750
+ yield; // satisfy require-yield
750
751
  throw new Error("agent crashed unexpectedly");
751
752
  }),
752
753
  }));
@@ -811,6 +812,7 @@ describe("dream error paths", () => {
811
812
  }));
812
813
  vi.doMock("@anthropic-ai/claude-agent-sdk", () => ({
813
814
  query: vi.fn(async function* () {
815
+ yield; // satisfy require-yield
814
816
  await queryPromise; // suspend until we release
815
817
  }),
816
818
  }));
@@ -957,7 +959,8 @@ describe("runDreamAgent — timeout arrow fn fires after DREAM_TIMEOUT_MS", () =
957
959
  // query never resolves — so the 10-minute timeout wins the race
958
960
  vi.doMock("@anthropic-ai/claude-agent-sdk", () => ({
959
961
  query: vi.fn(async function* () {
960
- await new Promise(() => {}); // never yields
962
+ yield; // satisfy require-yield
963
+ await new Promise(() => {}); // never resolves
961
964
  }),
962
965
  }));
963
966
 
@@ -973,6 +976,120 @@ describe("runDreamAgent — timeout arrow fn fires after DREAM_TIMEOUT_MS", () =
973
976
  });
974
977
  });
975
978
 
979
+ describe("mempalace section gating in dream prompt", () => {
980
+ beforeEach(() => {
981
+ vi.resetModules();
982
+ });
983
+
984
+ it("includes mempalace mining command and diary instructions when mempalace is configured", async () => {
985
+ vi.doMock("node:fs", () => ({
986
+ existsSync: vi.fn(() => false),
987
+ readFileSync: vi.fn(() => "PROMPT START {{mempalaceSection}} PROMPT END"),
988
+ mkdirSync: vi.fn(),
989
+ appendFileSync: vi.fn(),
990
+ }));
991
+ vi.doMock("write-file-atomic", () => ({ default: { sync: vi.fn() } }));
992
+ vi.doMock("../util/log.js", () => ({
993
+ log: vi.fn(),
994
+ logError: vi.fn(),
995
+ logWarn: vi.fn(),
996
+ }));
997
+ vi.doMock("../util/paths.js", () => ({
998
+ files: {
999
+ dreamState: "/fake/.talon/data/dream_state.json",
1000
+ memory: "/fake/.talon/workspace/memory/memory.md",
1001
+ log: "/fake/.talon/talon.log",
1002
+ },
1003
+ dirs: {
1004
+ root: "/fake/.talon",
1005
+ logs: "/fake/.talon/workspace/logs",
1006
+ workspace: "/fake/.talon/workspace",
1007
+ data: "/fake/.talon/data",
1008
+ memory: "/fake/.talon/workspace/memory",
1009
+ dailyMemory: "/fake/.talon/workspace/memory/daily",
1010
+ },
1011
+ }));
1012
+ const queryMock = vi.fn(async function* () {});
1013
+ vi.doMock("@anthropic-ai/claude-agent-sdk", () => ({ query: queryMock }));
1014
+
1015
+ const mod = await import("../core/dream.js");
1016
+ mod.initDream({
1017
+ model: "claude-sonnet-4-6",
1018
+ workspace: "/fake/ws",
1019
+ mempalace: {
1020
+ pythonPath: "/usr/bin/python3",
1021
+ palacePath: "/fake/palace",
1022
+ },
1023
+ });
1024
+ await mod.forceDream();
1025
+
1026
+ expect(queryMock).toHaveBeenCalled();
1027
+ const callArgs = (queryMock.mock.calls[0] as unknown[])[0] as {
1028
+ prompt: string;
1029
+ };
1030
+ // Mempalace mining command should be in the prompt
1031
+ expect(callArgs.prompt).toContain("-m mempalace mine");
1032
+ // Diary instructions should be in the prompt
1033
+ expect(callArgs.prompt).toContain("mempalace_diary_write");
1034
+ // Should NOT contain the skip message
1035
+ expect(callArgs.prompt).not.toContain(
1036
+ "MemPalace is not configured. Skip this stage.",
1037
+ );
1038
+ });
1039
+
1040
+ it("includes skip message when mempalace is not configured", async () => {
1041
+ vi.doMock("node:fs", () => ({
1042
+ existsSync: vi.fn(() => false),
1043
+ readFileSync: vi.fn(() => "PROMPT START {{mempalaceSection}} PROMPT END"),
1044
+ mkdirSync: vi.fn(),
1045
+ appendFileSync: vi.fn(),
1046
+ }));
1047
+ vi.doMock("write-file-atomic", () => ({ default: { sync: vi.fn() } }));
1048
+ vi.doMock("../util/log.js", () => ({
1049
+ log: vi.fn(),
1050
+ logError: vi.fn(),
1051
+ logWarn: vi.fn(),
1052
+ }));
1053
+ vi.doMock("../util/paths.js", () => ({
1054
+ files: {
1055
+ dreamState: "/fake/.talon/data/dream_state.json",
1056
+ memory: "/fake/.talon/workspace/memory/memory.md",
1057
+ log: "/fake/.talon/talon.log",
1058
+ },
1059
+ dirs: {
1060
+ root: "/fake/.talon",
1061
+ logs: "/fake/.talon/workspace/logs",
1062
+ workspace: "/fake/.talon/workspace",
1063
+ data: "/fake/.talon/data",
1064
+ memory: "/fake/.talon/workspace/memory",
1065
+ dailyMemory: "/fake/.talon/workspace/memory/daily",
1066
+ },
1067
+ }));
1068
+ const queryMock = vi.fn(async function* () {});
1069
+ vi.doMock("@anthropic-ai/claude-agent-sdk", () => ({ query: queryMock }));
1070
+
1071
+ const mod = await import("../core/dream.js");
1072
+ // No mempalace config
1073
+ mod.initDream({
1074
+ model: "claude-sonnet-4-6",
1075
+ workspace: "/fake/ws",
1076
+ });
1077
+ await mod.forceDream();
1078
+
1079
+ expect(queryMock).toHaveBeenCalled();
1080
+ const callArgs = (queryMock.mock.calls[0] as unknown[])[0] as {
1081
+ prompt: string;
1082
+ };
1083
+ // Should contain the skip message
1084
+ expect(callArgs.prompt).toContain(
1085
+ "MemPalace is not configured. Skip this stage.",
1086
+ );
1087
+ // Should NOT contain mempalace mining commands
1088
+ expect(callArgs.prompt).not.toContain("-m mempalace mine");
1089
+ expect(callArgs.prompt).not.toContain("mempalace_diary_write");
1090
+ });
1091
+ });
1092
+
976
1093
  describe("maybeStartDream — () => {} catch callback on executeDream rejection", () => {
977
1094
  it("fires the catch callback silently when executeDream('auto') rejects", async () => {
978
1095
  vi.resetModules();
@@ -46,7 +46,7 @@ vi.mock("../storage/cron-store.js", () => ({
46
46
  // ── Imports (after mocks) ────────────────────────────────────────────────────
47
47
 
48
48
  const { classify, TalonError } = await import("../core/errors.js");
49
- const { validateCronExpression } = await import("../storage/cron-store.js");
49
+ await import("../storage/cron-store.js");
50
50
  const { handleSharedAction } = await import("../core/gateway-actions.js");
51
51
  const { resolveModelName } = await import("../storage/chat-settings.js");
52
52
  const { Cron } = await import("croner");
@@ -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",