mythos-router 1.0.0 → 1.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 -21
- package/README.md +317 -229
- package/dist/budget.d.ts +47 -0
- package/dist/budget.d.ts.map +1 -0
- package/dist/budget.js +157 -0
- package/dist/budget.js.map +1 -0
- package/dist/cli.js +11 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/chat.d.ts +9 -2
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +122 -22
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/dream.d.ts +1 -0
- package/dist/commands/dream.d.ts.map +1 -1
- package/dist/commands/dream.js +7 -3
- package/dist/commands/dream.js.map +1 -1
- package/dist/commands/verify.d.ts +3 -1
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +7 -3
- package/dist/commands/verify.js.map +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +56 -46
- package/dist/config.js.map +1 -1
- package/dist/memory.d.ts +2 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +15 -5
- package/dist/memory.js.map +1 -1
- package/dist/swd.d.ts +8 -0
- package/dist/swd.d.ts.map +1 -1
- package/dist/swd.js +77 -1
- package/dist/swd.js.map +1 -1
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +41 -12
- package/dist/utils.js.map +1 -1
- package/package.json +63 -63
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 thewaltero
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 thewaltero
|
|
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
CHANGED
|
@@ -1,229 +1,317 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
mythos
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
mythos
|
|
115
|
-
mythos
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
███╗ ███╗██╗ ██╗████████╗██╗ ██╗ ██████╗ ███████╗
|
|
5
|
+
████╗ ████║╚██╗ ██╔╝╚══██╔══╝██║ ██║██╔═══██╗██╔════╝
|
|
6
|
+
██╔████╔██║ ╚████╔╝ ██║ ███████║██║ ██║███████╗
|
|
7
|
+
██║╚██╔╝██║ ╚██╔╝ ██║ ██╔══██║██║ ██║╚════██║
|
|
8
|
+
██║ ╚═╝ ██║ ██║ ██║ ██║ ██║╚██████╔╝███████║
|
|
9
|
+
╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### Capybara Tier · Claude Opus 4.6 · Strict Write Discipline
|
|
13
|
+
|
|
14
|
+
**The leaked Anthropic reasoning protocol. Running locally.**
|
|
15
|
+
|
|
16
|
+
[](https://www.npmjs.com/package/mythos-router)
|
|
17
|
+
[](https://nodejs.org)
|
|
18
|
+
[](https://typescriptlang.org)
|
|
19
|
+
[](https://anthropic.com)
|
|
20
|
+
[](./LICENSE)
|
|
21
|
+
[](https://github.com/thewaltero/mythos-router)
|
|
22
|
+
|
|
23
|
+
<p align="center">
|
|
24
|
+
<img src="assets/demo.png" alt="mythos-router terminal demo" width="700" />
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Try it now
|
|
29
|
+
npx mythos-router chat
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## What is this?
|
|
37
|
+
|
|
38
|
+
**mythos-router** is a local CLI power tool that implements the *leaked Anthropic "Capybara" reasoning protocol* — the specialized tier designed for PhD-level reasoning and cybersecurity analysis.
|
|
39
|
+
|
|
40
|
+
Unlike standard Claude wrappers, mythos-router enforces **Strict Write Discipline (SWD)**: every file operation the AI claims to perform is *verified against the actual filesystem*. If the model hallucinates a write, it gets a Correction Turn. If it fails twice, it yields to the human.
|
|
41
|
+
|
|
42
|
+
Zero slop. Zero hallucinated state. Full adaptive thinking.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
| Feature | Description |
|
|
49
|
+
|---------|-------------|
|
|
50
|
+
| 🧠 **Adaptive Thinking** | Opus 4.6 with configurable effort levels (high/medium/low) |
|
|
51
|
+
| 🔒 **Strict Write Discipline** | Pre/post filesystem snapshots verify every model claim |
|
|
52
|
+
| 💤 **Self-Healing Memory** | `MEMORY.md` logs every action; auto-compresses via "Dream" |
|
|
53
|
+
| ⟲ **Correction Turns** | Model gets 2 retries to match filesystem reality, then yields |
|
|
54
|
+
| 📋 **Drift Detection** | `verify` command syncs codebase state with memory |
|
|
55
|
+
| 💰 **Token Limiter** | Budget cap with graceful save — progress saved to MEMORY.md, never lose work |
|
|
56
|
+
| 🔍 **Dry-Run Mode** | Preview every file operation before it executes — full transparency |
|
|
57
|
+
| 📊 **Verbose Tracing** | See exactly what the AI is parsing, thinking, and verifying |
|
|
58
|
+
| 🚀 **Zero Build** | Runs directly via `tsx` — no compile step in dev |
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
### Quick Start (npm)
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Install globally
|
|
68
|
+
npm install -g mythos-router
|
|
69
|
+
|
|
70
|
+
# Set your API key
|
|
71
|
+
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
72
|
+
# Windows: $env:ANTHROPIC_API_KEY = "sk-ant-..."
|
|
73
|
+
|
|
74
|
+
# Go
|
|
75
|
+
mythos chat
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Or try without installing
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npx mythos-router chat
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### From Source
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
git clone https://github.com/thewaltero/mythos-router.git
|
|
88
|
+
cd mythos-router
|
|
89
|
+
npm install
|
|
90
|
+
npm run chat
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Usage
|
|
96
|
+
|
|
97
|
+
### `mythos chat` — Interactive Capybara Session
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
mythos chat # Full power (high effort)
|
|
101
|
+
mythos chat --effort low # Budget mode
|
|
102
|
+
mythos chat --effort medium # Balanced
|
|
103
|
+
mythos chat --dry-run # Preview all file changes before executing
|
|
104
|
+
mythos chat --verbose # See full SWD traces and thinking
|
|
105
|
+
mythos chat --dry-run --verbose # Maximum transparency
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### 💰 Financial Safety — Never Burn Money Again
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
mythos chat # Default: 500K tokens, 25 turns
|
|
112
|
+
mythos chat --max-tokens 100000 # Cap at 100K tokens
|
|
113
|
+
mythos chat --max-turns 10 # Cap at 10 turns
|
|
114
|
+
mythos chat --max-tokens 50000 --max-turns 5 # Tight budget
|
|
115
|
+
mythos chat --no-budget # Expert mode (no limits)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The budget limiter tracks every token, turn, and estimated cost in real-time:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
budget: [████████░░░░░░░░░░░░] 78,342/500,000 tokens · [██████░░░░] 12/25 turns · ~$1.2340 · 4m 32s
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
At 80%, you get a yellow warning. At 100%, the session performs a **graceful save** — current progress is written to `MEMORY.md` so you can resume context in your next session. No work lost. Use `--no-budget` to disable (at your own risk).
|
|
125
|
+
|
|
126
|
+
#### 🔍 Dry-Run Mode — The Trust Builder
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
mythos chat --dry-run
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
In dry-run mode, every file operation is previewed before execution:
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
DRY-RUN ── File Action Preview ──
|
|
136
|
+
2 file action(s) detected. Review each:
|
|
137
|
+
|
|
138
|
+
1/2 MODIFY src/index.ts
|
|
139
|
+
Description: Change 'axios' to 'fetch'
|
|
140
|
+
Current state: 1,832 bytes, hash: 7a3f2c1e...
|
|
141
|
+
DRY-RUN Accept MODIFY on src/index.ts? [Y/n] y
|
|
142
|
+
✔ Accepted: MODIFY src/index.ts
|
|
143
|
+
|
|
144
|
+
2/2 CREATE src/utils.ts
|
|
145
|
+
Description: Add helper utilities
|
|
146
|
+
Current state: does not exist
|
|
147
|
+
DRY-RUN Accept CREATE on src/utils.ts? [Y/n] n
|
|
148
|
+
⚠ Rejected: CREATE src/utils.ts
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
In-session commands:
|
|
152
|
+
- `/exit` — End session (shows final budget summary)
|
|
153
|
+
- `/memory` — Show memory status
|
|
154
|
+
- `/budget` — Show current budget consumption
|
|
155
|
+
- `/clear` — Clear conversation (memory persists)
|
|
156
|
+
|
|
157
|
+
### `mythos verify` — Zero-Drift Codebase Scan
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
mythos verify # Scan and log results to MEMORY.md
|
|
161
|
+
mythos verify --dry-run # Scan without writing to MEMORY.md
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Scans every file in your project and cross-references against `MEMORY.md`:
|
|
165
|
+
- ✅ **Verified** — File state matches memory
|
|
166
|
+
- ⚠️ **Drift** — File changed but memory doesn't reflect it
|
|
167
|
+
- ❌ **Missing** — Memory references a file that doesn't exist
|
|
168
|
+
|
|
169
|
+
### `mythos dream` — Memory Compression
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
mythos dream # Auto-compress when needed
|
|
173
|
+
mythos dream --force # Force compression
|
|
174
|
+
mythos dream --dry-run # Preview without writing
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
When `MEMORY.md` exceeds 100 entries, older logs are compressed into a summary block using Claude (low effort, minimal token burn). Recent entries are preserved intact.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Architecture
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
mythos-router/
|
|
185
|
+
├── src/
|
|
186
|
+
│ ├── cli.ts # Commander.js entry point
|
|
187
|
+
│ ├── config.ts # Capybara system prompt + constants + budget defaults
|
|
188
|
+
│ ├── client.ts # Anthropic SDK (adaptive thinking)
|
|
189
|
+
│ ├── budget.ts # Session budget limiter (token cap, turn cap)
|
|
190
|
+
│ ├── swd.ts # Strict Write Discipline + dry-run preview
|
|
191
|
+
│ ├── memory.ts # MEMORY.md self-healing manager (dry-run aware)
|
|
192
|
+
│ ├── utils.ts # Terminal formatting, badges, prompts (zero-dep)
|
|
193
|
+
│ └── commands/
|
|
194
|
+
│ ├── chat.ts # Interactive REPL (budget + dry-run + verbose)
|
|
195
|
+
│ ├── verify.ts # Codebase ↔ Memory scanner (dry-run aware)
|
|
196
|
+
│ └── dream.ts # Memory compression (dry-run aware)
|
|
197
|
+
├── .mythosignore # SWD scan exclusions
|
|
198
|
+
├── MEMORY.md # Auto-generated agentic memory
|
|
199
|
+
└── AGENTS.md # Project conventions
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### The SWD Protocol
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
User Input
|
|
206
|
+
│
|
|
207
|
+
▼
|
|
208
|
+
[Pre-Snapshot] ── filesystem state captured
|
|
209
|
+
│
|
|
210
|
+
▼
|
|
211
|
+
[Claude Opus 4.6] ── adaptive thinking (high effort)
|
|
212
|
+
│
|
|
213
|
+
▼
|
|
214
|
+
[Parse FILE_ACTION blocks] ── extract claimed operations
|
|
215
|
+
│
|
|
216
|
+
▼
|
|
217
|
+
[Post-Snapshot] ── filesystem state re-captured
|
|
218
|
+
│
|
|
219
|
+
▼
|
|
220
|
+
[Verify] ── before vs. after vs. model claims
|
|
221
|
+
│
|
|
222
|
+
├── ✅ All verified → Log to MEMORY.md
|
|
223
|
+
│
|
|
224
|
+
└── ❌ Mismatch → Correction Turn (max 2 retries)
|
|
225
|
+
│
|
|
226
|
+
└── Still failing → Yield to human
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## MEMORY.md — Should You Commit It?
|
|
232
|
+
|
|
233
|
+
**Yes.** `MEMORY.md` is designed to be committed to your repository. It becomes a "collaborative brain" where:
|
|
234
|
+
- Multiple developers can see what the AI did in previous sessions
|
|
235
|
+
- Different AI agents can reference past context
|
|
236
|
+
- You get a full audit trail of every AI-assisted file operation
|
|
237
|
+
|
|
238
|
+
If you prefer to keep it private, add `MEMORY.md` to your `.gitignore`.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## The Capybara System Prompt
|
|
243
|
+
|
|
244
|
+
The system prompt implements the leaked Anthropic protocol:
|
|
245
|
+
|
|
246
|
+
> **Tier: Capybara** (Specialized in Cybersecurity & PhD Reasoning)
|
|
247
|
+
>
|
|
248
|
+
> Follow 'Strict Write Discipline' and never hallucinate filesystem state.
|
|
249
|
+
> Every file operation must be wrapped in `[FILE_ACTION]` blocks for verification.
|
|
250
|
+
|
|
251
|
+
The model is instructed to emit machine-readable delimiters around every file operation, making SWD verification 100% reliable.
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Configuration
|
|
256
|
+
|
|
257
|
+
| Env Variable | Required | Description |
|
|
258
|
+
|-------------|----------|-------------|
|
|
259
|
+
| `ANTHROPIC_API_KEY` | ✅ | Your Anthropic API key |
|
|
260
|
+
|
|
261
|
+
| File | Purpose |
|
|
262
|
+
|------|---------|
|
|
263
|
+
| `.mythosignore` | Patterns to exclude from SWD scanning |
|
|
264
|
+
| `MEMORY.md` | Auto-generated agentic memory log |
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## Token Usage & Budget
|
|
269
|
+
|
|
270
|
+
### Opus 4.6 Pricing (as of 2026-04)
|
|
271
|
+
|
|
272
|
+
| Rate | USD |
|
|
273
|
+
|------|-----|
|
|
274
|
+
| Input tokens | $15.00 / 1M tokens |
|
|
275
|
+
| Output tokens | $75.00 / 1M tokens |
|
|
276
|
+
|
|
277
|
+
> Pricing constants live in `src/config.ts`. When Anthropic updates rates, change two lines — no budget math to refactor.
|
|
278
|
+
|
|
279
|
+
| Mode | Typical Cost Per Turn |
|
|
280
|
+
|------|----------------------|
|
|
281
|
+
| `--effort high` | Full Opus 4.6 pricing (deep reasoning) |
|
|
282
|
+
| `--effort medium` | Balanced — good for most tasks |
|
|
283
|
+
| `--effort low` | Minimal thinking — quick answers |
|
|
284
|
+
| `dream` | Low effort summarization (~500 tokens) |
|
|
285
|
+
|
|
286
|
+
| Budget Setting | Default |
|
|
287
|
+
|---------------|--------|
|
|
288
|
+
| `--max-tokens` | 500,000 per session |
|
|
289
|
+
| `--max-turns` | 25 per session |
|
|
290
|
+
| Warning threshold | 80% consumption |
|
|
291
|
+
| `--no-budget` | Disables all limits |
|
|
292
|
+
|
|
293
|
+
### Graceful Save
|
|
294
|
+
|
|
295
|
+
When the budget is reached, mythos doesn't just kill your session — it performs a **graceful save**:
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
⏸ BUDGET REACHED — Graceful Save
|
|
299
|
+
498,231 tokens consumed across 25 turns (~$7.4200).
|
|
300
|
+
Progress saved to MEMORY.md. Resume with mythos chat to continue.
|
|
301
|
+
Increase limits: mythos chat --max-tokens 1000000 --max-turns 50
|
|
302
|
+
Disable limits: mythos chat --no-budget
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Token counts, estimated cost, and budget status are displayed after every chat response.
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## License
|
|
310
|
+
|
|
311
|
+
MIT
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
<div align="center">
|
|
316
|
+
<sub>Built with the leaked Capybara protocol. No affiliation with Anthropic. Use responsibly.</sub>
|
|
317
|
+
</div>
|
package/dist/budget.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface BudgetConfig {
|
|
2
|
+
maxTokens: number;
|
|
3
|
+
maxTurns: number;
|
|
4
|
+
warnAtPercent: number;
|
|
5
|
+
/** Cost per input token in USD (update when Anthropic changes pricing) */
|
|
6
|
+
costPerInputToken: number;
|
|
7
|
+
/** Cost per output token in USD (update when Anthropic changes pricing) */
|
|
8
|
+
costPerOutputToken: number;
|
|
9
|
+
}
|
|
10
|
+
export interface BudgetCheck {
|
|
11
|
+
ok: boolean;
|
|
12
|
+
reason?: string;
|
|
13
|
+
tokensPercent: number;
|
|
14
|
+
turnsPercent: number;
|
|
15
|
+
warning: boolean;
|
|
16
|
+
/** True when budget is exhausted — signals the caller to perform a graceful save */
|
|
17
|
+
exhausted: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface BudgetSnapshot {
|
|
20
|
+
totalTokens: number;
|
|
21
|
+
inputTokens: number;
|
|
22
|
+
outputTokens: number;
|
|
23
|
+
turns: number;
|
|
24
|
+
maxTokens: number;
|
|
25
|
+
maxTurns: number;
|
|
26
|
+
startedAt: number;
|
|
27
|
+
elapsedMs: number;
|
|
28
|
+
/** Estimated cost in USD based on configured token pricing */
|
|
29
|
+
estimatedCostUSD: number;
|
|
30
|
+
}
|
|
31
|
+
export declare class SessionBudget {
|
|
32
|
+
private config;
|
|
33
|
+
private totalInput;
|
|
34
|
+
private totalOutput;
|
|
35
|
+
private turnCount;
|
|
36
|
+
private startedAt;
|
|
37
|
+
private enabled;
|
|
38
|
+
constructor(config?: Partial<BudgetConfig>, enabled?: boolean);
|
|
39
|
+
record(inputTokens: number, outputTokens: number): void;
|
|
40
|
+
check(): BudgetCheck;
|
|
41
|
+
status(): BudgetSnapshot;
|
|
42
|
+
isEnabled(): boolean;
|
|
43
|
+
formatBar(width?: number): string;
|
|
44
|
+
formatWarning(): string | null;
|
|
45
|
+
formatSessionSummary(): string;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=budget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget.d.ts","sourceRoot":"","sources":["../src/budget.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,2EAA2E;IAC3E,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,oFAAoF;IACpF,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAGD,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAU;gBAEb,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EAAE,OAAO,UAAO;IAa1D,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAOvD,KAAK,IAAI,WAAW;IA6CpB,MAAM,IAAI,cAAc;IAkBxB,SAAS,IAAI,OAAO;IAKpB,SAAS,CAAC,KAAK,SAAK,GAAG,MAAM;IAkC7B,aAAa,IAAI,MAAM,GAAG,IAAI;IA6B9B,oBAAoB,IAAI,MAAM;CAQ/B"}
|