@deepthonk/core 0.1.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/LICENSE +21 -0
- package/README.md +293 -0
- package/dist/artifacts.d.ts +36 -0
- package/dist/artifacts.js +211 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/bradleyTerry.d.ts +2 -0
- package/dist/bradleyTerry.js +204 -0
- package/dist/bradleyTerry.js.map +1 -0
- package/dist/budget.d.ts +14 -0
- package/dist/budget.js +41 -0
- package/dist/budget.js.map +1 -0
- package/dist/budgetTracker.d.ts +16 -0
- package/dist/budgetTracker.js +137 -0
- package/dist/budgetTracker.js.map +1 -0
- package/dist/critique.d.ts +2 -0
- package/dist/critique.js +52 -0
- package/dist/critique.js.map +1 -0
- package/dist/errors.d.ts +24 -0
- package/dist/errors.js +27 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/json.d.ts +1 -0
- package/dist/json.js +28 -0
- package/dist/json.js.map +1 -0
- package/dist/lifecycle.d.ts +63 -0
- package/dist/lifecycle.js +45 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/pairScheduler.d.ts +6 -0
- package/dist/pairScheduler.js +79 -0
- package/dist/pairScheduler.js.map +1 -0
- package/dist/prompts.d.ts +15 -0
- package/dist/prompts.js +200 -0
- package/dist/prompts.js.map +1 -0
- package/dist/rng.d.ts +8 -0
- package/dist/rng.js +31 -0
- package/dist/rng.js.map +1 -0
- package/dist/runner.d.ts +11 -0
- package/dist/runner.js +518 -0
- package/dist/runner.js.map +1 -0
- package/dist/schemas.d.ts +648 -0
- package/dist/schemas.js +119 -0
- package/dist/schemas.js.map +1 -0
- package/dist/services.d.ts +40 -0
- package/dist/services.js +104 -0
- package/dist/services.js.map +1 -0
- package/dist/traceStore.d.ts +22 -0
- package/dist/traceStore.js +105 -0
- package/dist/traceStore.js.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Xule Lin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# DeepThonk
|
|
2
|
+
|
|
3
|
+
*thonk harder, not richer.*
|
|
4
|
+
|
|
5
|
+
DeepThonk implements the OpenDeepThink algorithm (Zhou et al., 2026, [arXiv:2605.15177](https://arxiv.org/abs/2605.15177)) as a budget-friendly, provider-neutral "deep think / pro mode" wrapper, with first-class DeepSeek support. See [Acknowledgments](#acknowledgments).
|
|
6
|
+
|
|
7
|
+
DeepThonk runs a population of candidate answers through pairwise judging, Bradley-Terry ranking, critique-guided mutation, elite preservation, and a final dense ranking pass. The CLI and MCP server both call the same TypeScript core engine.
|
|
8
|
+
|
|
9
|
+
**Designed for agents.** Every algorithm dimension — population shape (`n`, `k`, `t`, `m`), regularization (`lambda`), per-phase temperatures, prompt style, and per-phase prompt templates — is reachable inline through MCP arguments and CLI flags. No filesystem detours required. Every intermediate artifact (candidates, comparisons, scores, per-call usage, status) is exposed as a streaming MCP resource so an agent can inspect any step. See [Customization](https://github.com/linxule/deepthonk/blob/main/docs/customization.md) for the full agent-composable surface.
|
|
10
|
+
|
|
11
|
+
Use it for hard, verifiable reasoning, coding, planning, and synthesis where breadth plus judgment can beat one expensive single shot. Avoid it for highly subjective tasks where judge noise dominates.
|
|
12
|
+
|
|
13
|
+
## Quickstart
|
|
14
|
+
|
|
15
|
+
Run without installing:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx -y deepthonk plan --profile paper
|
|
19
|
+
npx -y deepthonk run --provider fake --profile quick \
|
|
20
|
+
--task "Find the smallest positive integer divisible by 3, 4, and 5." \
|
|
21
|
+
--out runs/test-quick
|
|
22
|
+
npx -y deepthonk inspect runs/test-quick
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or install globally:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g deepthonk
|
|
29
|
+
deepthonk plan --profile paper
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The paper profile plans 285 model calls and 8 sequential rounds. Confirm budget and provider pricing before pointing it at paid models. The short alias `dt` is installed alongside `deepthonk`. Develop from source: see [Development](#development).
|
|
33
|
+
|
|
34
|
+
> v0.1 scope: an independent TypeScript reimplementation of the OpenDeepThink algorithm as a CLI + MCP server. The published algorithm is the load-bearing part; this release is a practical integration layer with explicit limits documented below. Cost guarantees rely on provider pricing being present in config; resume only inspects trace state, it does not replay; the MCP HTTP transport is loopback-only. The included acceptance smoke uses the deterministic fake provider and a toy task — it is not a CF-73 / HLE reproduction; see `docs/` and [Acknowledgments](#acknowledgments) for the canonical paper and Python reference.
|
|
35
|
+
|
|
36
|
+
## Setup
|
|
37
|
+
|
|
38
|
+
Create a reusable local config:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
deepthonk setup \
|
|
42
|
+
--provider deepseek \
|
|
43
|
+
--api-key-env DEEPSEEK_API_KEY \
|
|
44
|
+
--fast-model deepseek-v4-flash \
|
|
45
|
+
--judge-model deepseek-v4-pro
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
By default this writes `~/.config/deepthonk/config.yaml`. `deepthonk run` loads that file automatically when `--config` is not supplied. If you pass `--api-key`, setup stores it in `~/.config/deepthonk/env`; otherwise it uses the named environment variable from your shell.
|
|
49
|
+
|
|
50
|
+
## DeepSeek
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
export DEEPSEEK_API_KEY=...
|
|
54
|
+
deepthonk run \
|
|
55
|
+
--task task.md \
|
|
56
|
+
--profile paper \
|
|
57
|
+
--provider deepseek \
|
|
58
|
+
--generator-model deepseek-v4-flash \
|
|
59
|
+
--mutator-model deepseek-v4-flash \
|
|
60
|
+
--judge-model deepseek-v4-pro \
|
|
61
|
+
--out runs/task-paper
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
DeepSeek is implemented as an OpenAI-compatible profile using `https://api.deepseek.com/v1`. DeepThonk ships default USD pricing for `deepseek-v4-flash` and `deepseek-v4-pro` from the official DeepSeek pricing page, including cache-hit/cache-miss input rates. Model names and prices are still editable config because both can change.
|
|
65
|
+
|
|
66
|
+
Before paid runs, inspect cost shape and resolved config:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
deepthonk plan --config ~/.config/deepthonk/config.yaml
|
|
70
|
+
deepthonk run --task task.md --config ~/.config/deepthonk/config.yaml --profile quick --dry-run
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Start with `--profile quick` and consider `--max-concurrency`, `--max-input-tokens`, `--max-output-tokens`, `--max-usd`, and `--request-timeout-ms` before larger paid profiles. Runtime token/USD budgets are enforced after completed provider calls and can overshoot by at most the active concurrency window. Every completed run summary includes call/token usage, and includes `usage.usd` when matching model pricing is available.
|
|
74
|
+
|
|
75
|
+
## OpenAI-Compatible Providers
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
export DEEPTHONK_API_KEY=...
|
|
79
|
+
deepthonk run \
|
|
80
|
+
--task task.md \
|
|
81
|
+
--profile balanced \
|
|
82
|
+
--provider openai-compatible \
|
|
83
|
+
--base-url https://provider.example.com/v1 \
|
|
84
|
+
--api-key-env DEEPTHONK_API_KEY \
|
|
85
|
+
--generator-model cheap-model \
|
|
86
|
+
--judge-model strong-model
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The driver calls `POST {base_url}/chat/completions` and requests JSON mode for comparisons when supported. If a provider returns a `400` with a body that mentions `response_format` or `json`, the driver retries without JSON mode and uses robust JSON extraction on the plain text response. Providers that reject JSON mode with a different status code (e.g. `422`) surface as a normal provider error — set `supportsJsonMode: false` in YAML to disable JSON mode up front.
|
|
90
|
+
|
|
91
|
+
Provider names are flexible. For a custom OpenAI-compatible endpoint, use any provider label with `--base-url`, `--api-key-env`, and role-specific model flags. For OpenRouter:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
export OPENROUTER_API_KEY=...
|
|
95
|
+
deepthonk run \
|
|
96
|
+
--task task.md \
|
|
97
|
+
--profile balanced \
|
|
98
|
+
--provider openrouter \
|
|
99
|
+
--generator-model openrouter/auto \
|
|
100
|
+
--mutator-model openrouter/auto \
|
|
101
|
+
--judge-model openrouter/auto
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
For mixed-provider runs, use YAML config and override individual roles under `providers`, especially `judge`.
|
|
105
|
+
|
|
106
|
+
Optional `finalizer_model` / `--finalizer-model` can post-process the ranked winner. Leave it unset when you want the raw ranked answer as the final artifact.
|
|
107
|
+
|
|
108
|
+
## MCP
|
|
109
|
+
|
|
110
|
+
The MCP server exposes the same engine the CLI runs. Once wired into an MCP host, the host can plan budgets, kick off background runs, poll status, fetch winners, and stream structured trace artifacts — all through MCP tools, resources, and prompts.
|
|
111
|
+
|
|
112
|
+
Provider API keys come from the host process's environment, not from DeepThonk's config alone. Each host handles env passthrough slightly differently — see the concrete patterns below.
|
|
113
|
+
|
|
114
|
+
### Claude Code
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
claude mcp add deepthonk \
|
|
118
|
+
-e DEEPSEEK_API_KEY=$DEEPSEEK_API_KEY \
|
|
119
|
+
-- npx -y deepthonk serve-mcp --transport stdio
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Use `-s user` for cross-project scope or `-s project` to commit registration into `.claude/`. Verify with `claude mcp list`. See `claude mcp --help` for the authoritative flag set.
|
|
123
|
+
|
|
124
|
+
### Claude Desktop
|
|
125
|
+
|
|
126
|
+
Config path: `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS), `%APPDATA%\Claude\claude_desktop_config.json` (Windows), `~/.config/Claude/claude_desktop_config.json` (Linux). Add:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"mcpServers": {
|
|
131
|
+
"deepthonk": {
|
|
132
|
+
"command": "npx",
|
|
133
|
+
"args": ["-y", "deepthonk", "serve-mcp", "--transport", "stdio"],
|
|
134
|
+
"env": {
|
|
135
|
+
"DEEPSEEK_API_KEY": "sk-..."
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Restart Claude Desktop after editing.
|
|
143
|
+
|
|
144
|
+
### Cursor
|
|
145
|
+
|
|
146
|
+
Project-scoped: `.cursor/mcp.json` in the workspace. User-global: `~/.cursor/mcp.json`. Same JSON shape as Claude Desktop:
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"mcpServers": {
|
|
151
|
+
"deepthonk": {
|
|
152
|
+
"command": "npx",
|
|
153
|
+
"args": ["-y", "deepthonk", "serve-mcp", "--transport", "stdio"],
|
|
154
|
+
"env": { "DEEPSEEK_API_KEY": "sk-..." }
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Other MCP hosts (stdio)
|
|
161
|
+
|
|
162
|
+
Any host that speaks MCP stdio launches:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
npx -y deepthonk serve-mcp --transport stdio
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
with the relevant provider env vars set on the process. If you'd rather install globally, `npm install -g deepthonk` then use `command: "deepthonk"` directly. Refer to the host's MCP registration docs for the configuration shape.
|
|
169
|
+
|
|
170
|
+
### Streamable HTTP
|
|
171
|
+
|
|
172
|
+
For local web hosts, or when stdio isn't available:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
deepthonk serve-mcp --transport http --port 3333
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
The server binds `127.0.0.1:3333` only (loopback) and the endpoint is `POST http://127.0.0.1:3333/mcp`. DNS rebinding protection is on (CVE-2025-66414): requests with `Host` headers outside `127.0.0.1:3333` / `localhost:3333` are rejected. Do not expose this port through a reverse proxy without re-evaluating that trust boundary.
|
|
179
|
+
|
|
180
|
+
### Tools
|
|
181
|
+
|
|
182
|
+
| Tool | Purpose |
|
|
183
|
+
|---|---|
|
|
184
|
+
| `deepthonk.plan` | Estimate calls and sequential rounds for a profile (no model calls). Use before paid runs. |
|
|
185
|
+
| `deepthonk.start` | Start a run in the background; returns `run_dir` + `job_id`. |
|
|
186
|
+
| `deepthonk.status` | Poll job status from a `run_dir`. |
|
|
187
|
+
| `deepthonk.result` | Return final summary + winner once a job is complete. |
|
|
188
|
+
| `deepthonk.cancel` | Request cancellation by writing `cancel.json` into the run directory. |
|
|
189
|
+
| `deepthonk.run` | Blocking convenience: start + await completion in one call. Prefer `start` + polling for long-running jobs. |
|
|
190
|
+
| `deepthonk.rank` | Rank a user-supplied candidate set with pairwise judging + Bradley-Terry (skip generation). |
|
|
191
|
+
| `deepthonk.mutate` | Mutate one supplied candidate with critique (one-shot). |
|
|
192
|
+
| `deepthonk.resume` | Detect whether a run can be resumed. Reports state only; does not replay yet. |
|
|
193
|
+
| `deepthonk.export` | Export run summary or full trace in JSON or markdown. |
|
|
194
|
+
|
|
195
|
+
All tools accept inline provider/model fields, or `config_path` pointing at a DeepThonk YAML config.
|
|
196
|
+
|
|
197
|
+
### Resources
|
|
198
|
+
|
|
199
|
+
- `deepthonk://runs` — JSON index of all runs in `runs/`.
|
|
200
|
+
- `deepthonk://runs/{run_id}/summary` — run summary (JSON).
|
|
201
|
+
- `deepthonk://runs/{run_id}/{candidates|comparisons|scores|trace}` — per-phase NDJSON.
|
|
202
|
+
- `deepthonk://runs/{run_id}/{winner|final}` — text artifacts.
|
|
203
|
+
- `deepthonk://runs/{run_id}/status` — run state (JSON).
|
|
204
|
+
- `deepthonk://jobs/{job_id}/{status|result}?run_dir=...` — job-scoped lookup; the `run_dir` query param is required.
|
|
205
|
+
|
|
206
|
+
### Prompts
|
|
207
|
+
|
|
208
|
+
Four templates mirror the core loop: `deepthonk/generate`, `deepthonk/compare`, `deepthonk/mutate`, `deepthonk/finalize`. Hosts can render them directly to drive the algorithm by hand without invoking the tool surface.
|
|
209
|
+
|
|
210
|
+
### Limits
|
|
211
|
+
|
|
212
|
+
MCP Sampling is deferred and not exposed as a provider mode — direct provider mode is the only option in v0.1. `deepthonk.resume` reports trace state and safe phase boundaries but does not replay interrupted runs. The HTTP transport is loopback-only by design.
|
|
213
|
+
|
|
214
|
+
## Customization
|
|
215
|
+
|
|
216
|
+
Every algorithm dimension is reachable through MCP arguments and CLI flags:
|
|
217
|
+
|
|
218
|
+
- **Population shape**: `n`, `k`, `t`, `m` — override profile defaults inline.
|
|
219
|
+
- **Algorithm constants**: `lambda`, `sample_temperature`, `mutate_temperature`, `judge_temperature`.
|
|
220
|
+
- **Prompt style**: `general` or `paper-programming`.
|
|
221
|
+
- **Per-phase prompt templates**: override `generate`, `compare`, `mutate`, or `finalize` with custom system/user templates and variable substitution (`{task}`, `{rubric}`, `{candidate}`, `{candidateA}`, `{candidateB}`, `{critique}`). Unknown variables throw a fail-fast error at run-start.
|
|
222
|
+
- **Concurrency**: per-phase caps for `generate`, `judge`, `mutate`.
|
|
223
|
+
|
|
224
|
+
Example agent call (MCP), no YAML file required:
|
|
225
|
+
|
|
226
|
+
```json
|
|
227
|
+
{
|
|
228
|
+
"task": "Draft a concise non-solicitation clause for a senior sales employee.",
|
|
229
|
+
"profile": "balanced",
|
|
230
|
+
"n": 6, "t": 1,
|
|
231
|
+
"provider": "deepseek",
|
|
232
|
+
"judge_model": "deepseek-v4-pro",
|
|
233
|
+
"prompts": {
|
|
234
|
+
"generate": { "system": "You are an experienced employment-law attorney." },
|
|
235
|
+
"compare": { "system": "Prefer enforceable clauses under California law. Return strict JSON only." }
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
CLI accepts the same surface, except prompt overrides are loaded from a YAML file via `--prompts <yaml>` (shell-quoting multi-line templates is hostile). MCP and CLI both merge over any `--config`/`config_path` YAML defaults.
|
|
241
|
+
|
|
242
|
+
See the [Customization guide](https://github.com/linxule/deepthonk/blob/main/docs/customization.md) for the complete variable contract, the compare-phase JSON safety rule, and three worked examples. Per-role provider routing (`providers.judge.provider = openrouter`) and per-model pricing remain YAML-only — they're nested structured config, not inline ergonomics.
|
|
243
|
+
|
|
244
|
+
## Trace Files
|
|
245
|
+
|
|
246
|
+
A successful run writes:
|
|
247
|
+
|
|
248
|
+
```txt
|
|
249
|
+
runs/{run_id}/
|
|
250
|
+
config.json
|
|
251
|
+
events.jsonl
|
|
252
|
+
candidates.jsonl
|
|
253
|
+
comparisons.jsonl
|
|
254
|
+
scores.jsonl
|
|
255
|
+
usage.jsonl
|
|
256
|
+
summary.json
|
|
257
|
+
artifacts/winner.txt
|
|
258
|
+
artifacts/final.txt
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
`status.json` is written when the run is launched through MCP `deepthonk.start` (so async clients can poll). `cancel.json` is written only when cancellation is requested. A `run.lock` file is held for the duration of the run.
|
|
262
|
+
|
|
263
|
+
JSONL writes are streamed as each candidate / comparison / call completes, and all appends go through a per-trace serialization queue. If a run is killed mid-tournament, completed pairs are durable on disk and the JSONL files remain readable.
|
|
264
|
+
|
|
265
|
+
`usage.jsonl` carries one row per provider call (generator, judge, mutator, finalizer) with phase/role/provider/model/token/USD/latency/retry. It contains no prompt content. `jq` over `usage.jsonl` is the simplest way to break a run's cost down by role.
|
|
266
|
+
|
|
267
|
+
Prompts and raw model outputs are off by default. API keys are never written. Candidate answers, critiques, scores, and final artifacts are trace data and are stored/exported by design, so do not use a shared run directory for sensitive tasks unless that is acceptable.
|
|
268
|
+
|
|
269
|
+
## Development
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
pnpm install
|
|
273
|
+
pnpm run build
|
|
274
|
+
pnpm test
|
|
275
|
+
pnpm run lint
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
This repository is source-only. Generated run traces, paper notes, build output, coverage, logs, and `node_modules` are intentionally ignored.
|
|
279
|
+
|
|
280
|
+
Known limits for this release:
|
|
281
|
+
|
|
282
|
+
- Conservative resume reports trace state and safe phase boundaries, but does not replay interrupted runs yet.
|
|
283
|
+
- MCP Sampling is deferred until there is a real host-backed Sampling driver.
|
|
284
|
+
- `maxUsd` requires known model pricing; add explicit prices in YAML for custom providers and model IDs. Optional fields `longContextThresholdTokens`, `inputUsdPerMillionLong`, and `outputUsdPerMillionLong` enable tiered pricing for models with a long-context surcharge (e.g., Gemini at 200K input tokens). Cache hit/miss rates remain flat.
|
|
285
|
+
|
|
286
|
+
## Acknowledgments
|
|
287
|
+
|
|
288
|
+
DeepThonk is an independent TypeScript reimplementation of the OpenDeepThink algorithm. It is not a fork; no source code from the reference implementation is vendored. Credit for the algorithm, the benchmark methodology, and the empirical results belongs to the paper authors.
|
|
289
|
+
|
|
290
|
+
- **Paper**: Shang Zhou, Wenhao Chai, Kaiyuan Liu, Huanzhi Mao, Qiuyang Mang, Jingbo Shang. *OpenDeepThink: Parallel Reasoning via Bradley–Terry Aggregation*. arXiv:2605.15177, 2026. <https://arxiv.org/abs/2605.15177>
|
|
291
|
+
- **Reference Python implementation**: <https://github.com/ZhouShang0817/open-deep-think> (MIT). This is the authors' code release and the canonical implementation for reproducing paper results (CF-73, HLE).
|
|
292
|
+
|
|
293
|
+
DeepThonk's contribution is an integration layer: a provider-neutral TypeScript core, an MCP server, a CLI, structured trace artifacts, and budget enforcement. The algorithm itself is theirs.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const runArtifactFiles: {
|
|
2
|
+
readonly config: "config.json";
|
|
3
|
+
readonly summary: "summary.json";
|
|
4
|
+
readonly candidates: "candidates.jsonl";
|
|
5
|
+
readonly comparisons: "comparisons.jsonl";
|
|
6
|
+
readonly scores: "scores.jsonl";
|
|
7
|
+
readonly usage: "usage.jsonl";
|
|
8
|
+
readonly trace: "events.jsonl";
|
|
9
|
+
readonly final: "artifacts/final.txt";
|
|
10
|
+
readonly winner: "artifacts/winner.txt";
|
|
11
|
+
readonly status: "status.json";
|
|
12
|
+
readonly cancel: "cancel.json";
|
|
13
|
+
readonly lock: "run.lock";
|
|
14
|
+
};
|
|
15
|
+
export type RunArtifactName = keyof typeof runArtifactFiles;
|
|
16
|
+
export type RunExportFormat = "json" | "markdown" | "jsonl";
|
|
17
|
+
export declare const traceJsonlFiles: readonly ["events.jsonl", "candidates.jsonl", "comparisons.jsonl", "scores.jsonl"];
|
|
18
|
+
export interface ResumeStatus {
|
|
19
|
+
status: "completed" | "interrupted" | "missing" | "running" | "cancel_requested" | "cancelled" | "failed" | "budget_exceeded" | "resumable";
|
|
20
|
+
message: string;
|
|
21
|
+
run_id?: string;
|
|
22
|
+
phase?: string;
|
|
23
|
+
generation?: number | "final";
|
|
24
|
+
safe_to_continue?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface RunRecord {
|
|
27
|
+
run_id: string;
|
|
28
|
+
run_dir: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function readRunArtifact(runDir: string, artifact: RunArtifactName): Promise<string>;
|
|
31
|
+
export declare function readRunSummary(runDir: string): Promise<Record<string, unknown>>;
|
|
32
|
+
export declare function exportRun(runDir: string, format: RunExportFormat): Promise<Record<string, unknown>>;
|
|
33
|
+
export declare function detectResumeState(runDir: string): Promise<ResumeStatus>;
|
|
34
|
+
export declare function resolveRunDir(runId: string, runsRoot?: string): Promise<string>;
|
|
35
|
+
export declare function listRunRecords(runsRoot?: string): Promise<RunRecord[]>;
|
|
36
|
+
export declare function recordRunIndex(runId: string, runDir: string, runsRoot?: string): Promise<void>;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
export const runArtifactFiles = {
|
|
4
|
+
config: "config.json",
|
|
5
|
+
summary: "summary.json",
|
|
6
|
+
candidates: "candidates.jsonl",
|
|
7
|
+
comparisons: "comparisons.jsonl",
|
|
8
|
+
scores: "scores.jsonl",
|
|
9
|
+
usage: "usage.jsonl",
|
|
10
|
+
trace: "events.jsonl",
|
|
11
|
+
final: "artifacts/final.txt",
|
|
12
|
+
winner: "artifacts/winner.txt",
|
|
13
|
+
status: "status.json",
|
|
14
|
+
cancel: "cancel.json",
|
|
15
|
+
lock: "run.lock"
|
|
16
|
+
};
|
|
17
|
+
export const traceJsonlFiles = [
|
|
18
|
+
runArtifactFiles.trace,
|
|
19
|
+
runArtifactFiles.candidates,
|
|
20
|
+
runArtifactFiles.comparisons,
|
|
21
|
+
runArtifactFiles.scores
|
|
22
|
+
];
|
|
23
|
+
export async function readRunArtifact(runDir, artifact) {
|
|
24
|
+
return readFile(join(runDir, runArtifactFiles[artifact]), "utf8");
|
|
25
|
+
}
|
|
26
|
+
export async function readRunSummary(runDir) {
|
|
27
|
+
return JSON.parse(await readRunArtifact(runDir, "summary"));
|
|
28
|
+
}
|
|
29
|
+
export async function exportRun(runDir, format) {
|
|
30
|
+
if (format === "json")
|
|
31
|
+
return readRunSummary(runDir);
|
|
32
|
+
if (format === "jsonl") {
|
|
33
|
+
const text = await Promise.all(traceJsonlFiles.map((file) => readFile(join(runDir, file), "utf8").catch(() => "")));
|
|
34
|
+
return { jsonl: text.join("") };
|
|
35
|
+
}
|
|
36
|
+
if (format !== "markdown")
|
|
37
|
+
throw new Error(`Unsupported export format: ${format}. Use json, markdown, or jsonl.`);
|
|
38
|
+
const summary = await readRunSummary(runDir);
|
|
39
|
+
const final = await readRunArtifact(runDir, "final").catch(() => "");
|
|
40
|
+
return { markdown: `# DeepThonk Run ${summary.run_id}\n\nWinner: ${summary.winner_id}\n\nCalls: ${summary.calls}\n\n## Final Answer\n\n${final}` };
|
|
41
|
+
}
|
|
42
|
+
export async function detectResumeState(runDir) {
|
|
43
|
+
try {
|
|
44
|
+
const summary = await readRunSummary(runDir);
|
|
45
|
+
return {
|
|
46
|
+
status: "completed",
|
|
47
|
+
message: "Run already has summary.json; nothing to resume.",
|
|
48
|
+
run_id: typeof summary.run_id === "string" ? summary.run_id : undefined,
|
|
49
|
+
safe_to_continue: false
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
const status = await readStatusArtifact(runDir);
|
|
54
|
+
if (status) {
|
|
55
|
+
if ((status.state === "running" || status.state === "pending") && isLiveWorker(status.worker_pid)) {
|
|
56
|
+
return {
|
|
57
|
+
status: "running",
|
|
58
|
+
message: `Run is ${status.state} at phase ${status.phase}. Use status/result or cancel before starting a replay.`,
|
|
59
|
+
run_id: status.run_id,
|
|
60
|
+
phase: status.phase,
|
|
61
|
+
generation: status.generation,
|
|
62
|
+
safe_to_continue: false
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (status.state === "running" || status.state === "pending") {
|
|
66
|
+
return {
|
|
67
|
+
status: "interrupted",
|
|
68
|
+
message: `Run status is stale at phase ${status.phase}; the recorded worker is no longer live.`,
|
|
69
|
+
run_id: status.run_id,
|
|
70
|
+
phase: status.phase,
|
|
71
|
+
generation: status.generation,
|
|
72
|
+
safe_to_continue: false
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (status.state === "cancelled" || status.state === "failed" || status.state === "budget_exceeded") {
|
|
76
|
+
return {
|
|
77
|
+
status: status.state,
|
|
78
|
+
message: resumeMessage(status),
|
|
79
|
+
run_id: status.run_id,
|
|
80
|
+
phase: status.phase,
|
|
81
|
+
generation: status.generation,
|
|
82
|
+
safe_to_continue: false
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
await readRunArtifact(runDir, "cancel");
|
|
88
|
+
return { status: "cancel_requested", message: "Cancellation has been requested, but no active run status exists.", safe_to_continue: false };
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Continue with trace detection.
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
await readRunArtifact(runDir, "trace");
|
|
95
|
+
return {
|
|
96
|
+
status: "interrupted",
|
|
97
|
+
message: "Interrupted trace detected. Conservative resume is trace-boundary only; this trace has no complete resumable boundary marker.",
|
|
98
|
+
safe_to_continue: false
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return { status: "missing", message: "No DeepThonk trace found in run directory.", safe_to_continue: false };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function readStatusArtifact(runDir) {
|
|
107
|
+
try {
|
|
108
|
+
return JSON.parse(await readRunArtifact(runDir, "status"));
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function isLiveWorker(pid) {
|
|
115
|
+
if (!pid)
|
|
116
|
+
return true;
|
|
117
|
+
try {
|
|
118
|
+
process.kill(pid, 0);
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function resumeMessage(status) {
|
|
126
|
+
const phase = status.phase ? ` at phase ${status.phase}` : "";
|
|
127
|
+
const error = status.error?.message ? ` Last error: ${status.error.message}` : "";
|
|
128
|
+
const fix = status.error?.fix ? ` Fix: ${status.error.fix}` : "";
|
|
129
|
+
return `Run is ${status.state ?? "interrupted"}${phase}.${error}${fix}`;
|
|
130
|
+
}
|
|
131
|
+
export async function resolveRunDir(runId, runsRoot = "runs") {
|
|
132
|
+
const direct = join(runsRoot, runId);
|
|
133
|
+
try {
|
|
134
|
+
await readRunArtifact(direct, "summary");
|
|
135
|
+
return direct;
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
// Fall through and scan the run index plus run summaries.
|
|
139
|
+
}
|
|
140
|
+
const indexed = await readRunIndex(runId, runsRoot);
|
|
141
|
+
if (indexed)
|
|
142
|
+
return indexed;
|
|
143
|
+
const entries = await readdir(runsRoot, { withFileTypes: true }).catch(() => []);
|
|
144
|
+
for (const entry of entries) {
|
|
145
|
+
if (!entry.isDirectory())
|
|
146
|
+
continue;
|
|
147
|
+
const candidate = join(runsRoot, entry.name);
|
|
148
|
+
try {
|
|
149
|
+
const summary = (await readRunSummary(candidate));
|
|
150
|
+
if (summary.run_id === runId)
|
|
151
|
+
return candidate;
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
// Ignore incomplete or non-DeepThonk directories.
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return direct;
|
|
158
|
+
}
|
|
159
|
+
export async function listRunRecords(runsRoot = "runs") {
|
|
160
|
+
const records = new Map();
|
|
161
|
+
for (const entry of await readRunIndexEntries(runsRoot)) {
|
|
162
|
+
if (!entry.run_id || !entry.run_dir)
|
|
163
|
+
continue;
|
|
164
|
+
try {
|
|
165
|
+
await readRunSummary(entry.run_dir);
|
|
166
|
+
records.set(entry.run_id, { run_id: entry.run_id, run_dir: entry.run_dir });
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
// Ignore stale index entries.
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const entries = await readdir(runsRoot, { withFileTypes: true }).catch(() => []);
|
|
173
|
+
for (const entry of entries) {
|
|
174
|
+
if (!entry.isDirectory())
|
|
175
|
+
continue;
|
|
176
|
+
const runDir = join(runsRoot, entry.name);
|
|
177
|
+
try {
|
|
178
|
+
const summary = (await readRunSummary(runDir));
|
|
179
|
+
const runId = summary.run_id ?? entry.name;
|
|
180
|
+
records.set(runId, { run_id: runId, run_dir: runDir });
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
// Ignore incomplete or non-DeepThonk directories.
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return [...records.values()].sort((left, right) => left.run_id.localeCompare(right.run_id));
|
|
187
|
+
}
|
|
188
|
+
export async function recordRunIndex(runId, runDir, runsRoot = "runs") {
|
|
189
|
+
await mkdir(runsRoot, { recursive: true });
|
|
190
|
+
await writeFile(join(runsRoot, "index.jsonl"), `${JSON.stringify({ run_id: runId, run_dir: runDir })}\n`, {
|
|
191
|
+
encoding: "utf8",
|
|
192
|
+
flag: "a"
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
async function readRunIndex(runId, runsRoot) {
|
|
196
|
+
const entries = await readRunIndexEntries(runsRoot);
|
|
197
|
+
return entries.reverse().find((entry) => entry.run_id === runId)?.run_dir;
|
|
198
|
+
}
|
|
199
|
+
async function readRunIndexEntries(runsRoot) {
|
|
200
|
+
try {
|
|
201
|
+
const text = await readFile(join(runsRoot, "index.jsonl"), "utf8");
|
|
202
|
+
return text
|
|
203
|
+
.split("\n")
|
|
204
|
+
.filter(Boolean)
|
|
205
|
+
.map((line) => JSON.parse(line));
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
return [];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../src/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,cAAc;IACvB,UAAU,EAAE,kBAAkB;IAC9B,WAAW,EAAE,mBAAmB;IAChC,MAAM,EAAE,cAAc;IACtB,KAAK,EAAE,aAAa;IACpB,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,qBAAqB;IAC5B,MAAM,EAAE,sBAAsB;IAC9B,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,aAAa;IACrB,IAAI,EAAE,UAAU;CACR,CAAC;AAKX,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,gBAAgB,CAAC,KAAK;IACtB,gBAAgB,CAAC,UAAU;IAC3B,gBAAgB,CAAC,WAAW;IAC5B,gBAAgB,CAAC,MAAM;CACf,CAAC;AAgBX,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAAc,EAAE,QAAyB;IAC7E,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAc;IACjD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,CAA4B,CAAC;AACzF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAc,EAAE,MAAuB;IACrE,IAA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