talon-agent 1.5.0 → 1.6.1
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/README.md +184 -50
- package/package.json +1 -1
- package/src/__tests__/chat-settings.test.ts +20 -7
- package/src/__tests__/fuzz.test.ts +3 -0
- package/src/__tests__/reload-plugins.test.ts +11 -5
- package/src/backend/claude-sdk/constants.ts +63 -0
- package/src/backend/claude-sdk/handler.ts +236 -0
- package/src/backend/claude-sdk/index.ts +7 -556
- package/src/backend/claude-sdk/models.ts +216 -0
- package/src/backend/claude-sdk/options.ts +129 -0
- package/src/backend/claude-sdk/state.ts +59 -0
- package/src/backend/claude-sdk/stream.ts +226 -0
- package/src/backend/claude-sdk/warm.ts +89 -0
- package/src/bootstrap.ts +19 -5
- package/src/cli.ts +30 -15
- package/src/core/dream.ts +5 -17
- package/src/core/gateway-actions.ts +3 -12
- package/src/core/gateway.ts +5 -2
- package/src/core/heartbeat.ts +4 -17
- package/src/core/models.ts +149 -0
- package/src/core/types.ts +4 -0
- package/src/frontend/teams/index.ts +1 -3
- package/src/frontend/telegram/callbacks.ts +15 -27
- package/src/frontend/telegram/commands.ts +23 -28
- package/src/frontend/telegram/helpers.ts +13 -15
- package/src/frontend/telegram/index.ts +1 -1
- package/src/frontend/terminal/commands.ts +7 -4
- package/src/index.ts +2 -1
- package/src/storage/chat-settings.ts +5 -19
package/README.md
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
# Talon
|
|
2
2
|
|
|
3
3
|
[](https://nodejs.org)
|
|
4
|
-
[](https://www.typescriptlang.org/)
|
|
5
5
|
[](https://github.com/anthropics/claude-agent-sdk-typescript)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](https://github.com/dylanneve1/talon/actions/workflows/ci.yml)
|
|
8
8
|
|
|
9
|
-
Multi-platform agentic AI harness powered by Claude. Runs on Telegram
|
|
9
|
+
Multi-platform agentic AI harness powered by Claude. Runs on **Telegram**, **Teams**, and **Terminal** with full tool access through MCP.
|
|
10
|
+
|
|
11
|
+
---
|
|
10
12
|
|
|
11
13
|
## Features
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
| | |
|
|
16
|
+
|---|---|
|
|
17
|
+
| **Multi-frontend** | Telegram (Grammy + GramJS userbot), Microsoft Teams (Bot Framework), Terminal with live tool visibility |
|
|
18
|
+
| **Claude Agent SDK** | Streaming responses, extended thinking, adaptive effort, 1M token context, dynamic model discovery |
|
|
19
|
+
| **MCP tools** | Messaging, media, history, search, web fetch, cron jobs, stickers, file system, admin controls |
|
|
20
|
+
| **Plugins** | Hot-reloadable plugin system. Built-in: GitHub, MemPalace, Playwright, Brave Search |
|
|
21
|
+
| **Background agents** | Heartbeat (periodic maintenance) and Dream (memory consolidation + diary) |
|
|
22
|
+
| **Per-chat settings** | Model, effort level, and pulse toggle per conversation via inline keyboard |
|
|
23
|
+
| **Model registry** | Models discovered from the SDK at startup --- new models appear in all pickers automatically |
|
|
24
|
+
|
|
25
|
+
---
|
|
20
26
|
|
|
21
27
|
## Quick Start
|
|
22
28
|
|
|
@@ -24,39 +30,134 @@ Multi-platform agentic AI harness powered by Claude. Runs on Telegram, Teams, an
|
|
|
24
30
|
git clone https://github.com/dylanneve1/talon.git && cd talon
|
|
25
31
|
npm install
|
|
26
32
|
|
|
27
|
-
# Interactive setup (select frontend, configure tokens)
|
|
33
|
+
# Interactive setup (select frontend, configure tokens, pick model)
|
|
28
34
|
npx talon setup
|
|
29
35
|
|
|
30
36
|
# Start
|
|
31
|
-
npx talon start # configured frontend (
|
|
37
|
+
npx talon start # configured frontend (daemon mode)
|
|
32
38
|
npx talon chat # terminal chat mode
|
|
33
39
|
```
|
|
34
40
|
|
|
35
|
-
|
|
41
|
+
**Prerequisites:**
|
|
42
|
+
- [Node.js 22+](https://nodejs.org/)
|
|
43
|
+
- [Claude Code](https://docs.anthropic.com/en/docs/claude-code) installed and authenticated (`claude` CLI on PATH)
|
|
44
|
+
|
|
45
|
+
---
|
|
36
46
|
|
|
37
47
|
## Architecture
|
|
38
48
|
|
|
39
49
|
```
|
|
40
|
-
index.ts
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
index.ts Composition root
|
|
51
|
+
|
|
|
52
|
+
+-- core/ Platform-agnostic engine
|
|
53
|
+
| +-- models.ts Model registry (dynamic SDK discovery)
|
|
54
|
+
| +-- gateway.ts HTTP bridge for MCP tool calls
|
|
55
|
+
| +-- dispatcher.ts Per-chat serial, cross-chat parallel execution
|
|
56
|
+
| +-- plugin.ts Plugin loader, registry, hot-reload
|
|
57
|
+
| +-- heartbeat.ts Periodic background agent
|
|
58
|
+
| +-- dream.ts Memory consolidation agent
|
|
59
|
+
| +-- pulse.ts Conversation-aware group engagement
|
|
60
|
+
| +-- cron.ts Persistent scheduled jobs
|
|
61
|
+
| +-- tools/ MCP tool definitions (13 files)
|
|
62
|
+
|
|
|
63
|
+
+-- backend/
|
|
64
|
+
| +-- claude-sdk/ Claude Agent SDK (modular: handler, stream,
|
|
65
|
+
| | options, state, warm, models, constants)
|
|
66
|
+
| +-- opencode/ OpenCode SDK alternative backend
|
|
67
|
+
|
|
|
68
|
+
+-- frontend/
|
|
69
|
+
| +-- telegram/ Grammy bot + GramJS userbot (10 files)
|
|
70
|
+
| +-- teams/ Bot Framework + Graph API
|
|
71
|
+
| +-- terminal/ Readline CLI with tool call visibility
|
|
72
|
+
|
|
|
73
|
+
+-- storage/ Sessions, history, chat settings,
|
|
74
|
+
| cron jobs, media index, daily logs
|
|
75
|
+
+-- util/ Config, logging, workspace, paths, time
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Dependency rule:** `core/` imports nothing from `frontend/` or `backend/`. Frontends and backends depend on core types, never on each other.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Built-in Plugins
|
|
83
|
+
|
|
84
|
+
### GitHub
|
|
85
|
+
|
|
86
|
+
GitHub API access via the official GitHub MCP server. Gives the agent access to repositories, issues, PRs, code search, and more.
|
|
87
|
+
|
|
88
|
+
**Requirements:** Docker installed and running.
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"github": {
|
|
93
|
+
"enabled": true,
|
|
94
|
+
"token": "ghp_..."
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The token is optional --- defaults to the output of `gh auth token` if the GitHub CLI is authenticated.
|
|
100
|
+
|
|
101
|
+
### MemPalace
|
|
102
|
+
|
|
103
|
+
Structured long-term memory with vector search. The agent can store, search, and retrieve memories semantically. Integrates with Dream mode for automatic memory consolidation and personal diary entries.
|
|
104
|
+
|
|
105
|
+
**Requirements:** Python 3.10+ with the `mempalace` package.
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Set up a Python environment
|
|
109
|
+
python -m venv ~/.talon/mempalace-venv
|
|
110
|
+
~/.talon/mempalace-venv/bin/pip install mempalace # Unix
|
|
111
|
+
# or: ~/.talon/mempalace-venv/Scripts/pip install mempalace # Windows
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"mempalace": {
|
|
117
|
+
"enabled": true,
|
|
118
|
+
"palacePath": "~/.talon/workspace/palace",
|
|
119
|
+
"pythonPath": "~/.talon/mempalace-venv/bin/python"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
55
122
|
```
|
|
56
123
|
|
|
57
|
-
|
|
124
|
+
Both paths are optional --- defaults to `~/.talon/workspace/palace/` and the venv Python respectively.
|
|
125
|
+
|
|
126
|
+
### Playwright
|
|
58
127
|
|
|
59
|
-
|
|
128
|
+
Headless browser automation via the Playwright MCP server. The agent can browse websites, take screenshots, generate PDFs, fill forms, and scrape content.
|
|
129
|
+
|
|
130
|
+
**Requirements:** None --- `@playwright/mcp` is bundled with Talon.
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"playwright": {
|
|
135
|
+
"enabled": true,
|
|
136
|
+
"browser": "chromium",
|
|
137
|
+
"headless": true
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Supported browsers: `chromium` (default), `chrome`, `firefox`, `webkit`, `msedge`.
|
|
143
|
+
|
|
144
|
+
### Brave Search
|
|
145
|
+
|
|
146
|
+
Web search via the Brave Search MCP server. Replaces the built-in WebSearch/WebFetch tools with higher-quality search results.
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"braveApiKey": "BSA..."
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Get an API key at [brave.com/search/api](https://brave.com/search/api/).
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Custom Plugins
|
|
159
|
+
|
|
160
|
+
Plugins add MCP tools and gateway actions without modifying core code. SOLID interface --- only `name` is required.
|
|
60
161
|
|
|
61
162
|
```json
|
|
62
163
|
{
|
|
@@ -80,59 +181,92 @@ export default {
|
|
|
80
181
|
};
|
|
81
182
|
```
|
|
82
183
|
|
|
184
|
+
Plugins support hot-reload via the `reload_plugins` MCP tool --- no restart required.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
83
188
|
## CLI
|
|
84
189
|
|
|
85
190
|
```
|
|
86
|
-
talon setup Interactive setup wizard
|
|
87
|
-
talon start Start
|
|
191
|
+
talon setup Interactive setup wizard
|
|
192
|
+
talon start Start as a background daemon
|
|
193
|
+
talon stop Stop the daemon
|
|
88
194
|
talon chat Terminal chat mode (always available)
|
|
89
|
-
talon status Health, sessions,
|
|
90
|
-
talon config View
|
|
195
|
+
talon status Health, sessions, plugins, disk usage
|
|
196
|
+
talon config View or edit configuration
|
|
91
197
|
talon logs Tail structured log file
|
|
92
|
-
talon doctor Validate environment
|
|
198
|
+
talon doctor Validate environment and dependencies
|
|
93
199
|
```
|
|
94
200
|
|
|
201
|
+
---
|
|
202
|
+
|
|
95
203
|
## Configuration
|
|
96
204
|
|
|
97
|
-
|
|
205
|
+
Config file: `~/.talon/config.json`
|
|
98
206
|
|
|
99
207
|
| Field | Default | Description |
|
|
100
208
|
|-------|---------|-------------|
|
|
101
|
-
| `frontend` | `"telegram"` | `"telegram"`, `"terminal"`, or
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
209
|
+
| `frontend` | `"telegram"` | `"telegram"`, `"terminal"`, `"teams"`, or an array |
|
|
210
|
+
| `backend` | `"claude"` | `"claude"` or `"opencode"` |
|
|
211
|
+
| `botToken` | --- | Telegram bot token |
|
|
212
|
+
| `model` | `"claude-sonnet-4-6"` | Default model (discovered from SDK at startup) |
|
|
213
|
+
| `concurrency` | `1` | Max concurrent AI queries (1--20) |
|
|
105
214
|
| `pulse` | `true` | Periodic group engagement |
|
|
215
|
+
| `heartbeat` | `false` | Background maintenance agent |
|
|
216
|
+
| `heartbeatIntervalMinutes` | `60` | Heartbeat interval |
|
|
217
|
+
| `braveApiKey` | --- | Brave Search API key |
|
|
218
|
+
| `timezone` | --- | IANA timezone (e.g. `"Europe/London"`) |
|
|
106
219
|
| `plugins` | `[]` | External plugin packages |
|
|
107
|
-
| `adminUserId` |
|
|
108
|
-
| `
|
|
220
|
+
| `adminUserId` | --- | Telegram user ID for `/admin` commands |
|
|
221
|
+
| `allowedUsers` | --- | Whitelist of Telegram user IDs |
|
|
222
|
+
| `apiId` / `apiHash` | --- | Telegram API credentials for full message history |
|
|
223
|
+
| `github` | --- | GitHub plugin config (see above) |
|
|
224
|
+
| `mempalace` | --- | MemPalace plugin config (see above) |
|
|
225
|
+
| `playwright` | --- | Playwright plugin config (see above) |
|
|
226
|
+
|
|
227
|
+
---
|
|
109
228
|
|
|
110
229
|
## Terminal Mode
|
|
111
230
|
|
|
112
231
|
```bash
|
|
113
|
-
talon chat
|
|
232
|
+
npx talon chat
|
|
114
233
|
```
|
|
115
234
|
|
|
116
|
-
Tool calls shown in real-time with parameters. Streaming phase indicators (thinking/responding/using tools). Per-turn stats
|
|
235
|
+
Tool calls shown in real-time with parameters. Streaming phase indicators (thinking / responding / using tools). Per-turn stats: duration, tokens, cache hit rate, tool count.
|
|
236
|
+
|
|
237
|
+
Commands: `/model`, `/effort`, `/reset`, `/status`, `/help`
|
|
238
|
+
|
|
239
|
+
---
|
|
117
240
|
|
|
118
241
|
## Production
|
|
119
242
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
243
|
+
**Docker:**
|
|
244
|
+
```bash
|
|
245
|
+
docker compose up -d
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Systemd:** `talon.service` included in the repository.
|
|
249
|
+
|
|
250
|
+
**Health endpoint:** `GET http://localhost:19876/health` returns JSON with uptime, memory, queue depth, active sessions, and last activity timestamp.
|
|
251
|
+
|
|
252
|
+
**Logging:** Structured JSON via pino to `~/.talon/talon.log`. Rotated on startup when the file exceeds 10MB.
|
|
253
|
+
|
|
254
|
+
**Resilience:** Dynamic model fallback on overload, session auto-retry on expiry, rate limit handling with backoff, atomic file writes, graceful shutdown with 15-second drain timeout.
|
|
255
|
+
|
|
256
|
+
---
|
|
125
257
|
|
|
126
258
|
## Development
|
|
127
259
|
|
|
128
260
|
```bash
|
|
129
261
|
npm run dev # watch mode
|
|
130
|
-
npm test #
|
|
131
|
-
npm run test:coverage # with coverage
|
|
262
|
+
npm test # 1300+ tests
|
|
263
|
+
npm run test:coverage # with coverage report
|
|
132
264
|
npm run typecheck # tsc --noEmit
|
|
133
265
|
npm run lint # oxlint
|
|
134
266
|
```
|
|
135
267
|
|
|
268
|
+
---
|
|
269
|
+
|
|
136
270
|
## License
|
|
137
271
|
|
|
138
272
|
MIT
|
package/package.json
CHANGED
|
@@ -31,9 +31,13 @@ const {
|
|
|
31
31
|
loadChatSettings,
|
|
32
32
|
resolveModelName,
|
|
33
33
|
EFFORT_LEVELS,
|
|
34
|
-
MODEL_ALIASES,
|
|
35
34
|
} = await import("../storage/chat-settings.js");
|
|
36
35
|
|
|
36
|
+
// Register Claude models (static — no SDK subprocess in tests)
|
|
37
|
+
const { registerClaudeModelsStatic, CLAUDE_MODELS_STATIC } =
|
|
38
|
+
await import("../backend/claude-sdk/models.js");
|
|
39
|
+
registerClaudeModelsStatic(CLAUDE_MODELS_STATIC);
|
|
40
|
+
|
|
37
41
|
describe("chat-settings", () => {
|
|
38
42
|
describe("getChatSettings", () => {
|
|
39
43
|
it("returns empty object for unknown chat", () => {
|
|
@@ -166,12 +170,21 @@ describe("chat-settings", () => {
|
|
|
166
170
|
});
|
|
167
171
|
});
|
|
168
172
|
|
|
169
|
-
describe("
|
|
170
|
-
it("
|
|
171
|
-
expect(
|
|
172
|
-
expect(
|
|
173
|
-
expect(
|
|
174
|
-
|
|
173
|
+
describe("model alias resolution (via registry)", () => {
|
|
174
|
+
it("resolves short aliases to full model IDs", () => {
|
|
175
|
+
expect(resolveModelName("sonnet")).toBe("claude-sonnet-4-6");
|
|
176
|
+
expect(resolveModelName("opus")).toBe("claude-opus-4-6");
|
|
177
|
+
expect(resolveModelName("haiku")).toBe("claude-haiku-4-5");
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("resolves versioned aliases", () => {
|
|
181
|
+
expect(resolveModelName("sonnet-4-6")).toBe("claude-sonnet-4-6");
|
|
182
|
+
expect(resolveModelName("opus-4.6")).toBe("claude-opus-4-6");
|
|
183
|
+
expect(resolveModelName("haiku-4.5")).toBe("claude-haiku-4-5");
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("passes through unknown names unchanged", () => {
|
|
187
|
+
expect(resolveModelName("gpt-4o")).toBe("gpt-4o");
|
|
175
188
|
});
|
|
176
189
|
});
|
|
177
190
|
|
|
@@ -49,6 +49,9 @@ const { classify, TalonError } = await import("../core/errors.js");
|
|
|
49
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
|
+
const { registerClaudeModelsStatic, CLAUDE_MODELS_STATIC } =
|
|
53
|
+
await import("../backend/claude-sdk/models.js");
|
|
54
|
+
registerClaudeModelsStatic(CLAUDE_MODELS_STATIC);
|
|
52
55
|
const { Cron } = await import("croner");
|
|
53
56
|
|
|
54
57
|
// ── Configuration ───────────────────────────────────────────────────────────
|
|
@@ -75,12 +75,14 @@ vi.mock("../util/config.js", () => ({
|
|
|
75
75
|
),
|
|
76
76
|
}));
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
// Backend mock — passed as 3rd arg to handleSharedAction
|
|
79
|
+
const mockBackend = {
|
|
80
|
+
query: vi.fn(),
|
|
79
81
|
updateSystemPrompt: (...args: unknown[]) =>
|
|
80
82
|
mockUpdateSystemPrompt(
|
|
81
83
|
...(args as Parameters<typeof mockUpdateSystemPrompt>),
|
|
82
84
|
),
|
|
83
|
-
}
|
|
85
|
+
};
|
|
84
86
|
|
|
85
87
|
// ── Import after mocks ────────────────────────────────────────────────────
|
|
86
88
|
|
|
@@ -105,6 +107,7 @@ describe("reload_plugins gateway action", () => {
|
|
|
105
107
|
const result = await handleSharedAction(
|
|
106
108
|
{ action: "reload_plugins" },
|
|
107
109
|
12345,
|
|
110
|
+
mockBackend,
|
|
108
111
|
);
|
|
109
112
|
expect(result).not.toBeNull();
|
|
110
113
|
expect(result!.ok).toBe(true);
|
|
@@ -115,19 +118,19 @@ describe("reload_plugins gateway action", () => {
|
|
|
115
118
|
});
|
|
116
119
|
|
|
117
120
|
it("calls reloadPlugins without explicit frontends (derived from config)", async () => {
|
|
118
|
-
await handleSharedAction({ action: "reload_plugins" }, 12345);
|
|
121
|
+
await handleSharedAction({ action: "reload_plugins" }, 12345, mockBackend);
|
|
119
122
|
// Gateway no longer passes frontends — reloadPlugins derives them from config
|
|
120
123
|
expect(mockReloadPlugins).toHaveBeenCalledWith();
|
|
121
124
|
});
|
|
122
125
|
|
|
123
126
|
it("rebuilds system prompt after reloading", async () => {
|
|
124
|
-
await handleSharedAction({ action: "reload_plugins" }, 12345);
|
|
127
|
+
await handleSharedAction({ action: "reload_plugins" }, 12345, mockBackend);
|
|
125
128
|
expect(mockRebuildSystemPrompt).toHaveBeenCalledTimes(1);
|
|
126
129
|
expect(mockGetPluginPromptAdditions).toHaveBeenCalledTimes(1);
|
|
127
130
|
});
|
|
128
131
|
|
|
129
132
|
it("updates backend system prompt after rebuild", async () => {
|
|
130
|
-
await handleSharedAction({ action: "reload_plugins" }, 12345);
|
|
133
|
+
await handleSharedAction({ action: "reload_plugins" }, 12345, mockBackend);
|
|
131
134
|
expect(mockUpdateSystemPrompt).toHaveBeenCalledTimes(1);
|
|
132
135
|
});
|
|
133
136
|
|
|
@@ -138,6 +141,7 @@ describe("reload_plugins gateway action", () => {
|
|
|
138
141
|
const result = await handleSharedAction(
|
|
139
142
|
{ action: "reload_plugins" },
|
|
140
143
|
12345,
|
|
144
|
+
mockBackend,
|
|
141
145
|
);
|
|
142
146
|
expect(result).not.toBeNull();
|
|
143
147
|
expect(result!.ok).toBe(false);
|
|
@@ -151,6 +155,7 @@ describe("reload_plugins gateway action", () => {
|
|
|
151
155
|
const result = await handleSharedAction(
|
|
152
156
|
{ action: "reload_plugins" },
|
|
153
157
|
12345,
|
|
158
|
+
mockBackend,
|
|
154
159
|
);
|
|
155
160
|
expect(result!.ok).toBe(false);
|
|
156
161
|
expect(result!.error).toContain("Invalid JSON in config");
|
|
@@ -164,6 +169,7 @@ describe("reload_plugins gateway action", () => {
|
|
|
164
169
|
const result = await handleSharedAction(
|
|
165
170
|
{ action: "reload_plugins" },
|
|
166
171
|
12345,
|
|
172
|
+
mockBackend,
|
|
167
173
|
);
|
|
168
174
|
expect(result!.ok).toBe(true);
|
|
169
175
|
expect(result!.text).toContain("(0)");
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared constants for Claude SDK backend and background agents.
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for disallowed tool lists, thinking effort
|
|
5
|
+
* configuration, and streaming parameters.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// ── Disallowed tool lists ──────────────────────────────────────────────────
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Core tools disallowed in all SDK query contexts (chat, heartbeat, dream).
|
|
12
|
+
* These are interactive or planning-only tools that make no sense in a
|
|
13
|
+
* headless agent context.
|
|
14
|
+
*/
|
|
15
|
+
export const DISALLOWED_TOOLS_CORE = [
|
|
16
|
+
"EnterPlanMode",
|
|
17
|
+
"ExitPlanMode",
|
|
18
|
+
"EnterWorktree",
|
|
19
|
+
"ExitWorktree",
|
|
20
|
+
"TodoWrite",
|
|
21
|
+
"TodoRead",
|
|
22
|
+
"TaskCreate",
|
|
23
|
+
"TaskUpdate",
|
|
24
|
+
"TaskGet",
|
|
25
|
+
"TaskList",
|
|
26
|
+
"TaskOutput",
|
|
27
|
+
"TaskStop",
|
|
28
|
+
"AskUserQuestion",
|
|
29
|
+
] as const;
|
|
30
|
+
|
|
31
|
+
/** Disallowed tools for the main chat handler (core + web tools replaced by Brave MCP). */
|
|
32
|
+
export const DISALLOWED_TOOLS_CHAT = [
|
|
33
|
+
...DISALLOWED_TOOLS_CORE,
|
|
34
|
+
"WebSearch",
|
|
35
|
+
"WebFetch",
|
|
36
|
+
] as const;
|
|
37
|
+
|
|
38
|
+
/** Disallowed tools for background agents — heartbeat and dream (core + Agent). */
|
|
39
|
+
export const DISALLOWED_TOOLS_BACKGROUND = [
|
|
40
|
+
...DISALLOWED_TOOLS_CORE,
|
|
41
|
+
"Agent",
|
|
42
|
+
] as const;
|
|
43
|
+
|
|
44
|
+
// ── Thinking / effort configuration ────────────────────────────────────────
|
|
45
|
+
|
|
46
|
+
export const EFFORT_MAP: Record<
|
|
47
|
+
string,
|
|
48
|
+
{
|
|
49
|
+
thinking: { type: "adaptive" | "disabled" };
|
|
50
|
+
effort?: "low" | "medium" | "high" | "max";
|
|
51
|
+
}
|
|
52
|
+
> = {
|
|
53
|
+
off: { thinking: { type: "disabled" } },
|
|
54
|
+
low: { thinking: { type: "adaptive" }, effort: "low" },
|
|
55
|
+
medium: { thinking: { type: "adaptive" }, effort: "medium" },
|
|
56
|
+
high: { thinking: { type: "adaptive" }, effort: "high" },
|
|
57
|
+
max: { thinking: { type: "adaptive" }, effort: "max" },
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// ── Streaming ──────────────────────────────────────────────────────────────
|
|
61
|
+
|
|
62
|
+
/** Minimum interval (ms) between streaming delta callbacks to avoid flooding frontends. */
|
|
63
|
+
export const STREAM_INTERVAL = 1000;
|