@nzkbuild/toche 1.0.9 → 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 +201 -201
- package/NOTICE +18 -18
- package/README.md +421 -367
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/npm/install.js +13 -4
- package/npm/install.test.js +53 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,367 +1,421 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src="assets/branding/toche-wordmark.png" alt="Toche" width="620">
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
<p align="center">
|
|
6
|
-
<strong>
|
|
7
|
-
</p>
|
|
8
|
-
|
|
9
|
-
<p align="center">
|
|
10
|
-
Toche is a local gateway
|
|
11
|
-
It removes avoidable work
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<a href="#what-
|
|
21
|
-
<a href="#
|
|
22
|
-
<a href="#
|
|
23
|
-
<a href="#
|
|
24
|
-
<a href="#
|
|
25
|
-
<a href="#
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
|
243
|
-
|
|
244
|
-
| `toche
|
|
245
|
-
| `toche
|
|
246
|
-
| `toche
|
|
247
|
-
| `toche
|
|
248
|
-
| `toche
|
|
249
|
-
| `toche
|
|
250
|
-
| `toche
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
| `
|
|
262
|
-
| `
|
|
263
|
-
| `
|
|
264
|
-
| `
|
|
265
|
-
| `
|
|
266
|
-
| `
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/branding/toche-wordmark.png" alt="Toche" width="620">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<strong>One local runtime. Multiple AI clients. Every request leaves a receipt.</strong>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
Toche is a local multi-client gateway that sits between your AI coding tools and
|
|
11
|
+
their upstream API endpoints. It removes avoidable work, isolates trust boundaries,
|
|
12
|
+
and keeps every optimization visible and reversible.
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<img src="assets/branding/toche-status.svg" alt="Toche 1.1.0: Multi-client runtime, Claude Code and Codex, 65 filters, duplicate requests coalesced from many to one, zero hosted accounts" width="820">
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<a href="#what-toche-is">What Toche is</a> ·
|
|
21
|
+
<a href="#what-toche-is-not">What it is not</a> ·
|
|
22
|
+
<a href="#install">Install</a> ·
|
|
23
|
+
<a href="#how-it-works">How it works</a> ·
|
|
24
|
+
<a href="#supported-clients">Supported clients</a> ·
|
|
25
|
+
<a href="#command-reference">Commands</a> ·
|
|
26
|
+
<a href="#trust-and-isolation">Trust and isolation</a> ·
|
|
27
|
+
<a href="#documentation">Docs</a>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
## What Toche is
|
|
31
|
+
|
|
32
|
+
Toche is a local runtime that accepts connections from multiple AI coding clients
|
|
33
|
+
simultaneously and routes their requests to your configured upstream API endpoints.
|
|
34
|
+
While a request passes through, Toche can:
|
|
35
|
+
|
|
36
|
+
- **Coalesce identical in-flight requests** so N clients sharing the same upstream
|
|
37
|
+
and trust domain make one upstream call instead of N.
|
|
38
|
+
- **Replay eligible responses** from a persistent cross-session cache when the
|
|
39
|
+
workspace fingerprint matches.
|
|
40
|
+
- **Reduce known tool-output noise** with 65 built-in TOML-defined filters
|
|
41
|
+
while keeping the original content recoverable with `toche expand`.
|
|
42
|
+
- **Inject provider prompt-cache breakpoints** to maximize Anthropic cache hits.
|
|
43
|
+
- **Record every request** in a local SQLite ledger so `toche stats` can explain
|
|
44
|
+
what happened.
|
|
45
|
+
|
|
46
|
+
Toche does not host an account, send telemetry, or require a cloud service.
|
|
47
|
+
|
|
48
|
+
## What Toche is not
|
|
49
|
+
|
|
50
|
+
Toche is not a provider account manager, a model load balancer, a protocol
|
|
51
|
+
translator, or a hosted API gateway. It does not select providers automatically
|
|
52
|
+
or fall back between them. It does not translate between Anthropic and OpenAI
|
|
53
|
+
protocols. These are explicit non-goals for the 1.1.0 release.
|
|
54
|
+
|
|
55
|
+
## Install
|
|
56
|
+
|
|
57
|
+
### Prerequisites
|
|
58
|
+
|
|
59
|
+
- Node.js 18 or newer for the npm installer.
|
|
60
|
+
- At least one supported AI coding client already installed and working.
|
|
61
|
+
- Windows x64, Linux x64, macOS Intel, or macOS Apple silicon.
|
|
62
|
+
|
|
63
|
+
Rust is not required when installing from npm.
|
|
64
|
+
|
|
65
|
+
### One-time setup
|
|
66
|
+
|
|
67
|
+
```shell
|
|
68
|
+
npm install -g @nzkbuild/toche
|
|
69
|
+
toche setup
|
|
70
|
+
toche
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Then, in other terminals, run your clients normally:
|
|
74
|
+
|
|
75
|
+
```shell
|
|
76
|
+
claude
|
|
77
|
+
codex
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`toche setup` detects your existing client configurations, imports your current
|
|
81
|
+
upstreams, and writes a local `config.toml`. It never silently sends a paid model
|
|
82
|
+
request. You can run it again later to review or modify your configuration.
|
|
83
|
+
|
|
84
|
+
### Managed mode (optional convenience)
|
|
85
|
+
|
|
86
|
+
Instead of starting the runtime separately, you can launch a client through Toche
|
|
87
|
+
in one step:
|
|
88
|
+
|
|
89
|
+
```shell
|
|
90
|
+
toche run claude -- --dangerously-skip-permissions
|
|
91
|
+
toche run codex
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Managed mode uses the same runtime, configuration, protocol handling, trust
|
|
95
|
+
isolation, ledger, and optimization pipeline as persistent mode.
|
|
96
|
+
|
|
97
|
+
### Normal daily use
|
|
98
|
+
|
|
99
|
+
After setup, the routine is:
|
|
100
|
+
|
|
101
|
+
1. Run `toche` and leave it open.
|
|
102
|
+
2. Run your clients in other terminals.
|
|
103
|
+
|
|
104
|
+
### Clean uninstall
|
|
105
|
+
|
|
106
|
+
```shell
|
|
107
|
+
toche disconnect claude
|
|
108
|
+
toche disconnect codex
|
|
109
|
+
npm uninstall -g @nzkbuild/toche
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
<details>
|
|
113
|
+
<summary><strong>Build from source instead of npm</strong></summary>
|
|
114
|
+
|
|
115
|
+
You need Rust 1.86 or newer.
|
|
116
|
+
|
|
117
|
+
```shell
|
|
118
|
+
git clone https://github.com/nzkbuild/toche.git
|
|
119
|
+
cd toche
|
|
120
|
+
cargo build --release
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The binary is `target/release/toche` (`.exe` on Windows).
|
|
124
|
+
|
|
125
|
+
</details>
|
|
126
|
+
|
|
127
|
+
## How it works
|
|
128
|
+
|
|
129
|
+
```mermaid
|
|
130
|
+
flowchart LR
|
|
131
|
+
subgraph Clients
|
|
132
|
+
A[Claude Code]
|
|
133
|
+
B[Codex CLI]
|
|
134
|
+
end
|
|
135
|
+
A --> C[Toche on 127.0.0.1:8743]
|
|
136
|
+
B --> C
|
|
137
|
+
C --> D{Protocol router}
|
|
138
|
+
D --> E[Anthropic Messages pipeline]
|
|
139
|
+
D --> F[OpenAI Responses pipeline]
|
|
140
|
+
E --> G[Shield coalescing]
|
|
141
|
+
F --> G
|
|
142
|
+
G --> H[Safe cache]
|
|
143
|
+
H --> I[Output reduction]
|
|
144
|
+
I --> J[Efficiency injection]
|
|
145
|
+
J --> K[Prompt cache injection]
|
|
146
|
+
K --> L[Configured upstream APIs]
|
|
147
|
+
L --> C
|
|
148
|
+
C --> M[Local ledger and CAS]
|
|
149
|
+
C --> A
|
|
150
|
+
C --> B
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
In plain language, your AI clients send their normal API requests to Toche on
|
|
154
|
+
`127.0.0.1:8743`. Toche then:
|
|
155
|
+
|
|
156
|
+
1. Routes the request through the correct protocol driver (Anthropic Messages
|
|
157
|
+
or OpenAI Responses).
|
|
158
|
+
2. Gives the request a stable fingerprint.
|
|
159
|
+
3. Shares an already-running identical request (within the same trust domain)
|
|
160
|
+
or checks for an eligible local replay.
|
|
161
|
+
4. Shortens supported tool output and keeps the original locally recoverable.
|
|
162
|
+
5. Applies the selected efficiency and provider prompt-cache policy.
|
|
163
|
+
6. Forwards any remaining work to your configured upstream API endpoint.
|
|
164
|
+
7. Records the outcome locally so `toche stats` can explain it.
|
|
165
|
+
|
|
166
|
+
The internal pipeline order is:
|
|
167
|
+
|
|
168
|
+
```text
|
|
169
|
+
protocol dispatch → fingerprint → shield → safe cache → reduce → efficiency → cache → forward → ledger
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Supported clients
|
|
173
|
+
|
|
174
|
+
| Client | Protocol | Persistent mode | Managed mode | Setup |
|
|
175
|
+
|--------|----------|-----------------|--------------|-------|
|
|
176
|
+
| Claude Code | Anthropic Messages | `toche` + `claude` | `toche run claude` | `toche setup` |
|
|
177
|
+
| Codex CLI | OpenAI Responses | `toche` + `codex` | `toche run codex` | `toche setup` |
|
|
178
|
+
|
|
179
|
+
Multiple instances of the same client are supported. Claude Code and Codex can
|
|
180
|
+
run simultaneously through the same Toche runtime.
|
|
181
|
+
|
|
182
|
+
### Persistent vs. managed mode
|
|
183
|
+
|
|
184
|
+
**Persistent mode** (`toche` in one terminal, client in another) is the primary
|
|
185
|
+
workflow. Start Toche once and launch as many clients as you need.
|
|
186
|
+
|
|
187
|
+
**Managed mode** (`toche run <client>`) is a convenience that starts Toche and
|
|
188
|
+
the client together. It uses the exact same pipeline as persistent mode.
|
|
189
|
+
|
|
190
|
+
## Trust and isolation
|
|
191
|
+
|
|
192
|
+
Different credential references never share cache entries or in-flight request
|
|
193
|
+
coalescing. If you configure a personal Anthropic API key and a work OpenAI key,
|
|
194
|
+
their traffic is isolated by trust domain — even if they happen to target the
|
|
195
|
+
same upstream URL.
|
|
196
|
+
|
|
197
|
+
Trust domains are derived from the combination of integration identity, upstream
|
|
198
|
+
identity, and credential reference. Raw credential values are never placed in
|
|
199
|
+
logs, IDs, hashes, database diagnostics, or receipts.
|
|
200
|
+
|
|
201
|
+
Attribution confidence is recorded honestly: Toche distinguishes between exact
|
|
202
|
+
process identity, client-reported identity, workspace-level identity, inference,
|
|
203
|
+
and unknown identity. It does not fabricate identity where it cannot be observed.
|
|
204
|
+
|
|
205
|
+
## Data storage
|
|
206
|
+
|
|
207
|
+
Everything lives in `~/.toche/` (overridable with `TOCHE_CONFIG_DIR`):
|
|
208
|
+
|
|
209
|
+
| Path | Purpose |
|
|
210
|
+
|------|---------|
|
|
211
|
+
| `config.toml` | Runtime configuration, integrations, upstreams, policies |
|
|
212
|
+
| `ledger.db` | SQLite ledger of every routed request |
|
|
213
|
+
| `cas/` | Content-addressed storage for reduced originals and cached responses |
|
|
214
|
+
| `runtime_id` | Persistent UUIDv7 runtime identity |
|
|
215
|
+
|
|
216
|
+
Toche never sends your data to a cloud account.
|
|
217
|
+
|
|
218
|
+
## Measurement confidence
|
|
219
|
+
|
|
220
|
+
Every value reported by `toche stats` is classified by how it was obtained:
|
|
221
|
+
|
|
222
|
+
| Confidence | Meaning |
|
|
223
|
+
|------------|---------|
|
|
224
|
+
| `measured` | Toche observed it directly |
|
|
225
|
+
| `provider-reported` | The upstream API reported it |
|
|
226
|
+
| `estimated` | Derived from available data (e.g. list-price estimate) |
|
|
227
|
+
| `configured` | Comes from your configuration |
|
|
228
|
+
| `unknown` | Could not be determined |
|
|
229
|
+
|
|
230
|
+
Missing prices do not become zero. Missing usage does not become fabricated
|
|
231
|
+
usage. Cost estimates are labelled as equivalent public list-price estimates,
|
|
232
|
+
not your actual billed cost.
|
|
233
|
+
|
|
234
|
+
## Command reference
|
|
235
|
+
|
|
236
|
+
### Primary commands
|
|
237
|
+
|
|
238
|
+
| Command | What it does |
|
|
239
|
+
|---------|-------------|
|
|
240
|
+
| `toche` | Start the runtime on `127.0.0.1:8743` |
|
|
241
|
+
| `toche setup` | Guided, rerunnable configuration |
|
|
242
|
+
| `toche setup --dry-run` | Preview changes without writing |
|
|
243
|
+
| `toche setup --force` | Regenerate configuration (backup created) |
|
|
244
|
+
| `toche connect [client]` | Route a client through Toche |
|
|
245
|
+
| `toche disconnect [client]` | Restore direct upstream routing |
|
|
246
|
+
| `toche run <client>` | Run a client in managed mode |
|
|
247
|
+
| `toche doctor` | Verify installation and configuration |
|
|
248
|
+
| `toche status` | Show runtime status, active flights, protocol counts |
|
|
249
|
+
| `toche status --json` | Machine-readable status |
|
|
250
|
+
| `toche stats` | Show usage, tokens, and cost estimates |
|
|
251
|
+
| `toche stats --json` | Machine-readable statistics |
|
|
252
|
+
| `toche stats --protocol anthropic` | Filter by protocol |
|
|
253
|
+
| `toche stats --integration <name>` | Filter by integration |
|
|
254
|
+
| `toche expand <hash>` | Restore original tool output from a reduction hash |
|
|
255
|
+
|
|
256
|
+
### Advanced commands
|
|
257
|
+
|
|
258
|
+
| Command | What it does |
|
|
259
|
+
|---------|-------------|
|
|
260
|
+
| `toche cache inspect` | List persistent safe-cache entries |
|
|
261
|
+
| `toche cache clear` | Clear entries for the current project |
|
|
262
|
+
| `toche cache clear --all` | Clear all persistent cache entries |
|
|
263
|
+
| `toche cache why <fingerprint>` | Explain the cache decision for a fingerprint |
|
|
264
|
+
| `toche checkpoint save` | Save a session checkpoint |
|
|
265
|
+
| `toche checkpoint list` | List saved checkpoints |
|
|
266
|
+
| `toche checkpoint show` | Show the latest checkpoint |
|
|
267
|
+
| `toche checkpoint delete <id>` | Delete a checkpoint |
|
|
268
|
+
| `toche graph query <question>` | Query the optional knowledge graph |
|
|
269
|
+
| `toche graph status` | Show graph node and edge counts |
|
|
270
|
+
| `toche graph extract` | Rebuild the knowledge graph |
|
|
271
|
+
|
|
272
|
+
### Per-request bypass headers
|
|
273
|
+
|
|
274
|
+
Set a header to `true` (case-insensitive) to skip a stage for one request.
|
|
275
|
+
The umbrella bypass takes precedence over individual bypasses.
|
|
276
|
+
|
|
277
|
+
| Header | Skips |
|
|
278
|
+
|--------|-------|
|
|
279
|
+
| `x-toche-bypass` | The complete optimization pipeline |
|
|
280
|
+
| `x-toche-bypass-shield` | Request coalescing |
|
|
281
|
+
| `x-toche-bypass-safe-cache` | Persistent cache lookup and storage |
|
|
282
|
+
| `x-toche-bypass-reduce` | Tool-output reduction |
|
|
283
|
+
| `x-toche-bypass-efficiency` | Efficiency instruction injection |
|
|
284
|
+
| `x-toche-bypass-cache` | Provider prompt-cache injection |
|
|
285
|
+
|
|
286
|
+
## Configuration
|
|
287
|
+
|
|
288
|
+
Toche stores its configuration in `~/.toche/config.toml`. Running `toche setup`
|
|
289
|
+
generates it from your existing client configurations.
|
|
290
|
+
|
|
291
|
+
<details>
|
|
292
|
+
<summary><strong>Example config.toml</strong></summary>
|
|
293
|
+
|
|
294
|
+
```toml
|
|
295
|
+
schema_version = 2
|
|
296
|
+
|
|
297
|
+
[runtime]
|
|
298
|
+
port = 8743
|
|
299
|
+
listen_address = "127.0.0.1"
|
|
300
|
+
request_timeout_ms = 300000
|
|
301
|
+
|
|
302
|
+
[defaults]
|
|
303
|
+
integration = "abc12345"
|
|
304
|
+
|
|
305
|
+
[[integrations]]
|
|
306
|
+
id = "abc12345"
|
|
307
|
+
name = "default"
|
|
308
|
+
upstream = "def67890"
|
|
309
|
+
policy = "pol11111"
|
|
310
|
+
|
|
311
|
+
[[upstreams]]
|
|
312
|
+
id = "def67890"
|
|
313
|
+
name = "Anthropic"
|
|
314
|
+
url = "https://api.anthropic.com"
|
|
315
|
+
|
|
316
|
+
[upstreams.auth]
|
|
317
|
+
secret_ref = { type = "environment", key = "ANTHROPIC_API_KEY" }
|
|
318
|
+
header_name = "x-api-key"
|
|
319
|
+
|
|
320
|
+
[upstreams.headers]
|
|
321
|
+
anthropic-version = "2023-06-01"
|
|
322
|
+
|
|
323
|
+
[[policies]]
|
|
324
|
+
id = "pol11111"
|
|
325
|
+
name = "default"
|
|
326
|
+
|
|
327
|
+
[policies.cache]
|
|
328
|
+
enabled = true
|
|
329
|
+
mode = "auto"
|
|
330
|
+
breakpoint = "standard"
|
|
331
|
+
|
|
332
|
+
[policies.reduce]
|
|
333
|
+
enabled = true
|
|
334
|
+
|
|
335
|
+
[policies.efficiency]
|
|
336
|
+
mode = "concise"
|
|
337
|
+
|
|
338
|
+
[policies.safe_cache]
|
|
339
|
+
enabled = true
|
|
340
|
+
ttl_days = 30
|
|
341
|
+
max_entry_bytes = 1048576
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
</details>
|
|
345
|
+
|
|
346
|
+
## Troubleshooting
|
|
347
|
+
|
|
348
|
+
<details>
|
|
349
|
+
<summary><strong>The runtime will not start</strong></summary>
|
|
350
|
+
|
|
351
|
+
- Check that nothing else is listening on port 8743.
|
|
352
|
+
- Run `toche doctor` to verify that `config.toml` exists and is valid.
|
|
353
|
+
- Enable debug logging with `RUST_LOG=toche=debug toche`.
|
|
354
|
+
|
|
355
|
+
</details>
|
|
356
|
+
|
|
357
|
+
<details>
|
|
358
|
+
<summary><strong>A client cannot connect</strong></summary>
|
|
359
|
+
|
|
360
|
+
- Start the runtime before running `toche connect`.
|
|
361
|
+
- Run `toche doctor` in a second terminal after connecting.
|
|
362
|
+
- Check that `toche status` shows the expected integrations.
|
|
363
|
+
|
|
364
|
+
</details>
|
|
365
|
+
|
|
366
|
+
<details>
|
|
367
|
+
<summary><strong>Stats or cache entries are empty</strong></summary>
|
|
368
|
+
|
|
369
|
+
- The ledger records only requests routed through the runtime.
|
|
370
|
+
- The persistent cache stores only eligible text-only responses without `tool_use` blocks.
|
|
371
|
+
- Use `toche cache why <fingerprint>` to inspect a cache rejection.
|
|
372
|
+
|
|
373
|
+
</details>
|
|
374
|
+
|
|
375
|
+
<details>
|
|
376
|
+
<summary><strong>Routing still points to Toche after disconnecting</strong></summary>
|
|
377
|
+
|
|
378
|
+
Run `toche doctor`. If environment variables or settings still reference Toche
|
|
379
|
+
while the runtime is stopped, run `toche disconnect` for each affected client.
|
|
380
|
+
|
|
381
|
+
</details>
|
|
382
|
+
|
|
383
|
+
## Upgrading from 1.0.x
|
|
384
|
+
|
|
385
|
+
Toche 1.1.0 migrates your existing `profiles.toml` to the new `config.toml`
|
|
386
|
+
format automatically on first load. The migration:
|
|
387
|
+
|
|
388
|
+
- Converts each profile into separate Integration, Upstream, and Policy entries.
|
|
389
|
+
- Backs up `profiles.toml` to `profiles.toml.v1.bak`.
|
|
390
|
+
- Preserves your ledger, safe-cache metadata, CAS, checkpoints, and Graphify data.
|
|
391
|
+
- Is idempotent — running it again is a no-op.
|
|
392
|
+
- Fails safely on malformed configuration without modifying anything.
|
|
393
|
+
|
|
394
|
+
An older binary encountering a newer schema version will refuse to modify it.
|
|
395
|
+
|
|
396
|
+
## Requirements
|
|
397
|
+
|
|
398
|
+
- Rust 1.86 or newer (edition 2024) when building from source
|
|
399
|
+
- At least one supported AI coding client
|
|
400
|
+
- No hosted Toche service
|
|
401
|
+
- SQLite is bundled through `rusqlite`
|
|
402
|
+
|
|
403
|
+
## Documentation
|
|
404
|
+
|
|
405
|
+
- [Architecture](docs/ARCHITECTURE.md): system design, crate map, data flow, decision records
|
|
406
|
+
- [Changelog](CHANGELOG.md): release history from 1.0.0 through 1.1.0
|
|
407
|
+
- [Contributing](CONTRIBUTING.md): setup, conventions, and PR workflow
|
|
408
|
+
- [Code of Conduct](CODE_OF_CONDUCT.md): Contributor Covenant
|
|
409
|
+
- [Bug tracker](docs/BUG_TRACKER.md): issues found and fixed during dogfooding
|
|
410
|
+
- [npm publishing](docs/NPM_PUBLISHING.md): maintainer checklist for npm releases
|
|
411
|
+
- [Third-party notices](THIRD_PARTY_NOTICES.md): reused ideas, integration decisions, and attribution
|
|
412
|
+
|
|
413
|
+
## Built from good work
|
|
414
|
+
|
|
415
|
+
Toche's Rust implementation was informed by ideas and patterns from ccusage, RTK,
|
|
416
|
+
Graphify, andrej-karpathy-skills, and caveman-claude. Their licenses and attribution
|
|
417
|
+
are preserved in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
|
418
|
+
|
|
419
|
+
## License
|
|
420
|
+
|
|
421
|
+
Licensed under the [Apache License 2.0](LICENSE).
|