tiiny-router-pi 0.0.2 → 0.0.3
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 +157 -74
- package/bin/pirouter +4 -4
- package/package.json +2 -2
- package/scripts/{install.sh → init.sh} +7 -7
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# tiiny router
|
|
1
|
+
# tiiny router pi
|
|
2
2
|
|
|
3
|
-
**`tiiny` + `pi
|
|
3
|
+
**`tiiny` + `pi` + model routing**
|
|
4
4
|
|
|
5
|
-
Forked from
|
|
6
|
-
[garciacionet-alt/AI_Articles]
|
|
5
|
+
Forked from
|
|
6
|
+
[garciacionet-alt/AI_Articles][upstream],
|
|
7
7
|
but with `pi` harness instead of `hermes`.
|
|
8
8
|
|
|
9
9
|
This is a [pi](https://pi.dev) extension that sends each task to the best model
|
|
@@ -16,19 +16,21 @@ model, and a task whose shape is unclear goes to the generalist.
|
|
|
16
16
|
|
|
17
17
|
<!-- toc -->
|
|
18
18
|
|
|
19
|
-
- [
|
|
20
|
-
* [
|
|
19
|
+
- [Quickstart](#quickstart)
|
|
20
|
+
* [Install](#install)
|
|
21
|
+
- [Configure](#configure)
|
|
22
|
+
- [Dry Run](#dry-run)
|
|
21
23
|
- [Uninstall](#uninstall)
|
|
22
|
-
- [Loops](#
|
|
23
|
-
- [
|
|
24
|
+
- [`redeye`/Loops](#redeyeloops)
|
|
25
|
+
- [Examples](#examples)
|
|
24
26
|
* [Interactive](#interactive)
|
|
25
27
|
* [One-off](#one-off)
|
|
26
|
-
* [With
|
|
28
|
+
* [With `redeye`](#with-redeye)
|
|
27
29
|
* [Delegating with subagents](#delegating-with-subagents)
|
|
28
30
|
* [Batches: plan, reserve, load, release](#batches-plan-reserve-load-release)
|
|
29
31
|
- [Commands](#commands)
|
|
30
32
|
* [`npx pirouter`](#npx-pirouter)
|
|
31
|
-
* [`pirouter
|
|
33
|
+
* [`pirouter init`](#pirouter-init)
|
|
32
34
|
* [`pirouter uninstall`](#pirouter-uninstall)
|
|
33
35
|
* [`pirouter check`](#pirouter-check)
|
|
34
36
|
* [`pirouter status`](#pirouter-status)
|
|
@@ -56,47 +58,68 @@ model, and a task whose shape is unclear goes to the generalist.
|
|
|
56
58
|
|
|
57
59
|
</details>
|
|
58
60
|
|
|
61
|
+
## Quickstart
|
|
59
62
|
|
|
60
|
-
|
|
63
|
+
### Install
|
|
61
64
|
|
|
62
|
-
|
|
65
|
+
Use in an existing npm project with pi installed. Install locally with npm,
|
|
66
|
+
then run the setup script.
|
|
63
67
|
|
|
64
68
|
```bash
|
|
65
|
-
npm i -D tiiny-router
|
|
69
|
+
npm i -D tiiny-router-pi
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Setup:
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
npx pirouter init
|
|
66
76
|
```
|
|
67
77
|
|
|
68
78
|
Installing is local to your current repo only, not global or user-scope.
|
|
69
79
|
|
|
70
|
-
|
|
80
|
+
## Configure
|
|
81
|
+
|
|
82
|
+
`TIINY_API_KEY` must be available in the shell, and the `tiiny` provider must
|
|
83
|
+
be in the file `~/.pi/agent/models.json`.
|
|
84
|
+
|
|
85
|
+
Export and configure the
|
|
86
|
+
`tiiny` provider in pi's `~/.pi/agent/models.json`. Register every
|
|
87
|
+
model ID in `tiers.json` with its context window and output limit.
|
|
88
|
+
Use the device's inference URL, `api: "openai-completions"` and
|
|
89
|
+
`apiKey: "$TIINY_API_KEY"`. If `PI_CODING_AGENT_DIR` is set, put
|
|
90
|
+
`models.json` there instead. The installer does not create this config.
|
|
91
|
+
See [Configuration](#configuration) for the router's environment variables.
|
|
92
|
+
|
|
93
|
+
After installing via `npm`, initialize the project with `npx pirouter init`.
|
|
71
94
|
The script adds symbolic links, and copies a folder
|
|
72
95
|
to the project's `.pi/` directory, so pi can load the router's extension,
|
|
73
96
|
the router's agents, and router skills in the project.
|
|
74
97
|
|
|
75
|
-
To remove it, run `npx pirouter uninstall`, then `npm rm tiiny-router`.
|
|
98
|
+
To remove it, run `npx pirouter uninstall`, then `npm rm tiiny-router-pi`.
|
|
76
99
|
See [Uninstall](#uninstall). Uninstall leaves `~/.pi/agent/tiiny` in
|
|
77
100
|
place. Delete it yourself if you no longer use the controller.
|
|
78
101
|
|
|
79
|
-
|
|
102
|
+
## Dry Run
|
|
80
103
|
|
|
81
104
|
Print what would change without changing anything:
|
|
82
105
|
|
|
83
106
|
```bash
|
|
84
|
-
npx pirouter
|
|
107
|
+
npx pirouter init --dry-run
|
|
85
108
|
```
|
|
86
109
|
|
|
87
110
|
Then install the extension, agents, and skill:
|
|
88
111
|
|
|
89
112
|
```bash
|
|
90
|
-
npx pirouter
|
|
113
|
+
npx pirouter init
|
|
91
114
|
```
|
|
92
115
|
|
|
93
|
-
Run these from the project root. `npx pirouter
|
|
94
|
-
if the current directory has no `package.json`. It runs `scripts/
|
|
116
|
+
Run these from the project root. `npx pirouter init` stops with an error
|
|
117
|
+
if the current directory has no `package.json`. It runs `scripts/init.sh`,
|
|
95
118
|
which writes inside the project's `.pi/` directory. It makes these changes,
|
|
96
119
|
in this order:
|
|
97
120
|
|
|
98
121
|
1. Links the package as a pi extension:
|
|
99
|
-
`.pi/extensions/tiiny-router -> node_modules/tiiny-router`. pi reads
|
|
122
|
+
`.pi/extensions/tiiny-router -> node_modules/tiiny-router-pi`. pi reads
|
|
100
123
|
the `pi.extensions` field of the package's `package.json` to find
|
|
101
124
|
`index.ts`, which registers the `tiiny-router/*` virtual models.
|
|
102
125
|
2. Links each agent definition into `.pi/agents/`: `tiiny-browser.md`,
|
|
@@ -104,7 +127,7 @@ in this order:
|
|
|
104
127
|
`tiiny-researcher.md` and `tiiny-worker.md`. These are for the
|
|
105
128
|
subagent tool (see [Delegating with subagents](#delegating-with-subagents)).
|
|
106
129
|
3. Links the skill folder:
|
|
107
|
-
`.pi/skills/tiiny-routing -> node_modules/tiiny-router/skill`.
|
|
130
|
+
`.pi/skills/tiiny-routing -> node_modules/tiiny-router-pi/skill`.
|
|
108
131
|
4. Copies `index.ts` and `agents.ts` from pi's example `subagent`
|
|
109
132
|
extension into `.pi/extensions/subagent`, then edits the copy to set
|
|
110
133
|
`MAX_CONCURRENCY = 1` (see [One task at a time](#one-task-at-a-time)).
|
|
@@ -113,11 +136,13 @@ in this order:
|
|
|
113
136
|
a copy, not a link, so later pi updates do not change it.
|
|
114
137
|
|
|
115
138
|
Steps 1 to 3 create symbolic links. Because they point into
|
|
116
|
-
`node_modules`, upgrading `tiiny-router` with npm updates them too.
|
|
139
|
+
`node_modules`, upgrading `tiiny-router-pi` with npm updates them too.
|
|
140
|
+
The links use absolute paths. Run the installer again after moving the
|
|
141
|
+
project; use [Loops](#loops) for config that works across worktrees.
|
|
117
142
|
|
|
118
143
|
It doesn't overwrite files or directories. If a destination exists
|
|
119
144
|
and is not a symbolic link, it prints `skip:` and moves on. If it is a
|
|
120
|
-
symbolic link, it is replaced, so running `
|
|
145
|
+
symbolic link, it is replaced, so running `init` again is safe and
|
|
121
146
|
re-points old links at the current package. Step 4 is skipped if
|
|
122
147
|
`.pi/extensions/subagent` exists in any form. In that case, set
|
|
123
148
|
`MAX_CONCURRENCY = 1` in your own subagent extension. Step 4 is also
|
|
@@ -143,12 +168,15 @@ Everything else, the controller and the route checker, is a
|
|
|
143
168
|
`pirouter` subcommand too. Run `npx pirouter` with no arguments for
|
|
144
169
|
the list.
|
|
145
170
|
|
|
146
|
-
To try the
|
|
171
|
+
To try the extension for one run without linking it into `.pi/`:
|
|
147
172
|
|
|
148
173
|
```bash
|
|
149
|
-
pi -e npm:tiiny-router --model tiiny-router/auto
|
|
174
|
+
pi -e npm:tiiny-router-pi --model tiiny-router/auto
|
|
150
175
|
```
|
|
151
176
|
|
|
177
|
+
pi caches the npm package in its agent directory. This loads the
|
|
178
|
+
extension only; it does not install the agents or the routing skill.
|
|
179
|
+
|
|
152
180
|
## Uninstall
|
|
153
181
|
|
|
154
182
|
From the project directory, preview the removal, then uninstall:
|
|
@@ -159,7 +187,9 @@ npx pirouter uninstall
|
|
|
159
187
|
```
|
|
160
188
|
|
|
161
189
|
This removes router entries from global `~/.pi/agent/settings.json` and
|
|
162
|
-
local `.pi/settings.json`, including
|
|
190
|
+
local `.pi/settings.json`, including local package paths and the legacy
|
|
191
|
+
npm source `npm:tiiny-router`. The current uninstaller does not recognize
|
|
192
|
+
`npm:tiiny-router-pi` sources; remove those `packages` entries manually.
|
|
163
193
|
It also removes links to the router's extension, agents and skill from
|
|
164
194
|
both scopes. If `PI_CODING_AGENT_DIR` is set, that directory is used for
|
|
165
195
|
global config instead. Other projects' local config is unchanged.
|
|
@@ -173,28 +203,33 @@ them. Running uninstall again is safe, and no `package.json` is required.
|
|
|
173
203
|
Restart pi or run `/reload`. To also remove the npm dependency, run:
|
|
174
204
|
|
|
175
205
|
```bash
|
|
176
|
-
npm rm tiiny-router
|
|
206
|
+
npm rm tiiny-router-pi
|
|
177
207
|
```
|
|
178
208
|
|
|
179
209
|
|
|
180
|
-
## Loops
|
|
210
|
+
## `redeye`/Loops
|
|
181
211
|
|
|
182
212
|
For an orchestrator such as
|
|
183
213
|
[redeye](https://github.com/nichoth/redeye) that runs `pi` in fresh `git`
|
|
184
214
|
worktrees, add the package to the project's `pi` settings instead:
|
|
185
215
|
|
|
186
216
|
```bash
|
|
187
|
-
npm i -D tiiny-router
|
|
217
|
+
npm i -D tiiny-router-pi
|
|
188
218
|
```
|
|
189
219
|
|
|
190
220
|
Commit `.pi/settings.json`:
|
|
191
221
|
|
|
192
222
|
```json
|
|
193
|
-
{ "packages": ["../node_modules/tiiny-router"] }
|
|
223
|
+
{ "packages": ["../node_modules/tiiny-router-pi"] }
|
|
194
224
|
```
|
|
195
225
|
|
|
196
226
|
The path is relative to `.pi/`, so each worktree loads its own installed
|
|
197
|
-
copy
|
|
227
|
+
copy after installing dependencies. Commit `package.json` and the lockfile
|
|
228
|
+
too. This entry loads only the extension: the package manifest does not
|
|
229
|
+
declare skills, and pi does not discover these agent files from it.
|
|
230
|
+
The interactive install above provides those resources in one checkout.
|
|
231
|
+
|
|
232
|
+
Then use the `auto` model, which infers a tier for each message:
|
|
198
233
|
|
|
199
234
|
```sh
|
|
200
235
|
npx redeye pi -m tiiny-router/auto --concurrency 1
|
|
@@ -203,7 +238,7 @@ npx redeye pi -m tiiny-router/auto --concurrency 1
|
|
|
203
238
|
To pin every task to one tier instead, name it, as in
|
|
204
239
|
`-m tiiny-router/code`.
|
|
205
240
|
|
|
206
|
-
##
|
|
241
|
+
## Examples
|
|
207
242
|
|
|
208
243
|
### Interactive
|
|
209
244
|
|
|
@@ -213,9 +248,10 @@ pi --model tiiny-router/auto
|
|
|
213
248
|
|
|
214
249
|
The footer shows the selection and the routed model (for example
|
|
215
250
|
`auto -> Qwen3.6-35B-A3B-turbo`), and the status line shows the route
|
|
216
|
-
label, such as `tiiny: draft->generalist [think:off]`. In `auto`,
|
|
217
|
-
new message is
|
|
218
|
-
|
|
251
|
+
label, such as `tiiny: draft->generalist [think:off]`. In `auto`, each
|
|
252
|
+
new message's tier is inferred again. If the tier is unchanged and the
|
|
253
|
+
previous model is still loaded, the session keeps that model, even if
|
|
254
|
+
a preferred candidate has since been loaded.
|
|
219
255
|
|
|
220
256
|
### One-off
|
|
221
257
|
|
|
@@ -223,12 +259,16 @@ session stays on the same model.
|
|
|
223
259
|
pi --model tiiny-router/index:off -p "Classify every file under ./notes by topic"
|
|
224
260
|
```
|
|
225
261
|
|
|
226
|
-
### With
|
|
262
|
+
### With `redeye`
|
|
227
263
|
|
|
228
264
|
Use this with the [`redeye` CLI](https://github.com/nichoth/redeye) tool.
|
|
229
265
|
See [the redeye docs](https://github.com/nichoth/redeye#local-model-with-pi)
|
|
230
266
|
for more examples.
|
|
231
267
|
|
|
268
|
+
```sh
|
|
269
|
+
npx redeye pi -m tiiny-router/auto --concurrency 1
|
|
270
|
+
```
|
|
271
|
+
|
|
232
272
|
### Delegating with subagents
|
|
233
273
|
|
|
234
274
|
The installed agents each pin a tier:
|
|
@@ -264,7 +304,7 @@ The subagent tool looks for agents in two places:
|
|
|
264
304
|
- project agents, in the nearest `.pi/agents/` above the working
|
|
265
305
|
directory
|
|
266
306
|
|
|
267
|
-
`pirouter
|
|
307
|
+
`pirouter init` puts the `tiiny-*` agents in the project's
|
|
268
308
|
`.pi/agents/`, so they are project agents. The tool's `agentScope`
|
|
269
309
|
parameter chooses where it looks:
|
|
270
310
|
|
|
@@ -272,7 +312,7 @@ parameter chooses where it looks:
|
|
|
272
312
|
|---|---|
|
|
273
313
|
| `"user"` (default) | user agents only |
|
|
274
314
|
| `"project"` | project agents only |
|
|
275
|
-
| `"both"` | both
|
|
315
|
+
| `"both"` | both; project agents take precedence when names match |
|
|
276
316
|
|
|
277
317
|
With the default, the `tiiny-*` agents cannot be found. The model sets
|
|
278
318
|
the tool's parameters, so say in your request that it should use project
|
|
@@ -319,12 +359,16 @@ planned, one at a time. Then restore the device and drop the lock:
|
|
|
319
359
|
npx pirouter release
|
|
320
360
|
```
|
|
321
361
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
`
|
|
326
|
-
|
|
327
|
-
|
|
362
|
+
Repeat the load and delegation steps for every wave. Always release,
|
|
363
|
+
including after a failed batch.
|
|
364
|
+
|
|
365
|
+
`plan` packs the batch into waves that fit in 100% NPU and writes
|
|
366
|
+
`~/.pi/agent/tiiny/tiiny-plan.json`. The router prefers a planned model
|
|
367
|
+
when it is loaded, or when residency cannot be read. If it is known to
|
|
368
|
+
be unloaded, the router uses its normal fallback order. Planning does
|
|
369
|
+
not change which models are loaded. `release` restores the `required`
|
|
370
|
+
models from `tiers.json` and verifies them. It leaves other batch models
|
|
371
|
+
loaded if they still fit; it does not restore the exact previous set.
|
|
328
372
|
|
|
329
373
|
See [Commands](#commands) for every option.
|
|
330
374
|
The `tiiny-routing` skill walks a pi agent through this sequence.
|
|
@@ -339,26 +383,35 @@ pirouter [--device NAME] <command> [options]
|
|
|
339
383
|
|
|
340
384
|
Run `npx pirouter` with no arguments for a list of commands.
|
|
341
385
|
|
|
342
|
-
`
|
|
386
|
+
`init`, `uninstall` and `check` are handled by `pirouter` itself.
|
|
343
387
|
Every other command runs
|
|
344
388
|
the controller, `controller/tiiny_ctl.py`, with `python3`.
|
|
345
389
|
`npx pirouter check -h` and `npx pirouter <controller command> -h`
|
|
346
390
|
show a command's options.
|
|
347
391
|
|
|
348
|
-
`--device NAME`
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
392
|
+
`--device NAME` is a controller option, so it goes before a controller
|
|
393
|
+
command. It requires an external `devices.py` registry module, which
|
|
394
|
+
this package does not ship. Without that module, the option has no
|
|
395
|
+
effect; use `TIINY_BASE_URL`, `TIINY_HOST` and the Tiiny CLI's device
|
|
396
|
+
configuration instead. These variables do not change the inference URL
|
|
397
|
+
in pi's `models.json`; configure that separately.
|
|
398
|
+
|
|
399
|
+
With a registry, lock and plan files include the device name
|
|
400
|
+
(`tiiny-lock-<name>.json`, `tiiny-plan-<name>.json`). Set
|
|
401
|
+
`TIINY_PLAN_FILE` to the same path for both the controller and pi,
|
|
402
|
+
because the extension does not select a named plan automatically.
|
|
352
403
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
404
|
+
`reserve` requires `--owner`. `load`, `ensure` and `release` default to
|
|
405
|
+
`$TIINY_OWNER`, or else `$USER` outside a legacy Hermes profile. These
|
|
406
|
+
three commands refuse to change the device while another owner holds
|
|
407
|
+
the lock, unless you pass `--force`. `plan` defaults to `$TIINY_OWNER`
|
|
408
|
+
or `unassigned`. The lock is cooperative; it does not block direct
|
|
409
|
+
Tiiny CLI calls or `image --load`.
|
|
357
410
|
|
|
358
|
-
### `pirouter
|
|
411
|
+
### `pirouter init`
|
|
359
412
|
|
|
360
413
|
```bash
|
|
361
|
-
npx pirouter
|
|
414
|
+
npx pirouter init [--dry-run]
|
|
362
415
|
```
|
|
363
416
|
|
|
364
417
|
Link the extension, agents and skill into `./.pi`, and copy the
|
|
@@ -412,13 +465,14 @@ npx pirouter plan --goal "GOAL" [--goal "GOAL" ...] [options]
|
|
|
412
465
|
|
|
413
466
|
Picks a model for each goal, packs the models into waves that each fit
|
|
414
467
|
in 100% NPU, and writes the plan file. It needs at least one `--goal`.
|
|
415
|
-
|
|
468
|
+
Candidates must already be resident or marked downloaded/running in
|
|
469
|
+
the catalogue. If none qualifies, it falls back to the generalist.
|
|
416
470
|
|
|
417
471
|
| Option | Meaning |
|
|
418
472
|
|---|---|
|
|
419
473
|
| `--goal GOAL` | a task goal; repeat it for a batch |
|
|
420
474
|
| `--tier TIER` | use this tier for every goal |
|
|
421
|
-
| `--model MODEL` |
|
|
475
|
+
| `--model MODEL` | restrict each goal to this model in its tier's candidates |
|
|
422
476
|
| `--owner OWNER` | who is planning |
|
|
423
477
|
| `--task TASK` | what the batch is for |
|
|
424
478
|
|
|
@@ -428,9 +482,9 @@ Only models downloaded to the device are chosen.
|
|
|
428
482
|
npx pirouter reserve --owner OWNER [options]
|
|
429
483
|
```
|
|
430
484
|
|
|
431
|
-
Takes the lock, so other
|
|
432
|
-
|
|
433
|
-
not hold
|
|
485
|
+
Takes the lock, so other owners' `load`, `ensure` and `release`
|
|
486
|
+
commands refuse to change the device while your batch runs. The lock
|
|
487
|
+
expires on its own, so a crashed agent does not hold it forever.
|
|
434
488
|
|
|
435
489
|
| Option | Meaning |
|
|
436
490
|
|---|---|
|
|
@@ -482,7 +536,8 @@ npx pirouter release [--owner OWNER] [--force]
|
|
|
482
536
|
|
|
483
537
|
Clears the hold, reloads the `required` models from `tiers.json`,
|
|
484
538
|
checks that they loaded, and clears the lock. It checks who holds the
|
|
485
|
-
lock before it changes anything.
|
|
539
|
+
lock before it changes anything. Batch models may remain loaded;
|
|
540
|
+
release does not restore the exact pre-batch residency.
|
|
486
541
|
|
|
487
542
|
| Option | Meaning |
|
|
488
543
|
|---|---|
|
|
@@ -505,6 +560,10 @@ now be wrong.
|
|
|
505
560
|
| `--update` | save the current store as the new snapshot |
|
|
506
561
|
| `--refresh` | the same as `--update` |
|
|
507
562
|
|
|
563
|
+
The current command only saves a snapshot if one already exists and
|
|
564
|
+
contains models. With no snapshot, it lists the store and returns,
|
|
565
|
+
even with `--update` or `--refresh`.
|
|
566
|
+
|
|
508
567
|
### `pirouter image`
|
|
509
568
|
|
|
510
569
|
```bash
|
|
@@ -517,7 +576,10 @@ shows its NPU share, whether it is loaded, and the other candidates.
|
|
|
517
576
|
| Option | Meaning |
|
|
518
577
|
|---|---|
|
|
519
578
|
| `--kind KIND` | `image` (default), `music` or `ocr` |
|
|
520
|
-
| `--load` | load the
|
|
579
|
+
| `--load` | load the model and record it as the hold; skips the lock check |
|
|
580
|
+
|
|
581
|
+
`release` clears the hold and restores required models, but does not
|
|
582
|
+
necessarily unload the image model.
|
|
521
583
|
|
|
522
584
|
|
|
523
585
|
|
|
@@ -534,15 +596,17 @@ The thinking level on the virtual model sets the reasoning mode:
|
|
|
534
596
|
For `off` and `on`, the router reads the routed model's `thinking` block
|
|
535
597
|
from the device and rewrites the request:
|
|
536
598
|
|
|
537
|
-
-
|
|
599
|
+
- For a model reported as reasoning-capable,
|
|
600
|
+
`chat_template_kwargs.enable_thinking` is always sent, because the
|
|
538
601
|
device's `toggleable` flag is not always right.
|
|
539
602
|
- If the model has levels but no switch (for example `gpt-oss-20b`),
|
|
540
603
|
`reasoning_effort` is set to its cheapest level for `off` and its
|
|
541
604
|
highest for `on`. The label then says `off->low`, since the model still
|
|
542
605
|
reasons, only less.
|
|
543
|
-
-
|
|
544
|
-
|
|
545
|
-
with
|
|
606
|
+
- The output budget (`max_tokens`, or `max_completion_tokens` if
|
|
607
|
+
present) is raised to at least 4096 by default. Override the floor
|
|
608
|
+
with `TIINY_THINKING_MAX_TOKENS`. A reasoning model with a small
|
|
609
|
+
budget can spend it all on the trace and return an empty answer.
|
|
546
610
|
|
|
547
611
|
The achieved state, not the requested one, is shown in the label:
|
|
548
612
|
`off`, `on`, `off->low`, `on->high`, `unsupported` (the model does not
|
|
@@ -577,7 +641,14 @@ TIINY_ROUTER_TRACE=/tmp/tiiny-routes.jsonl pi --model tiiny-router/auto
|
|
|
577
641
|
```
|
|
578
642
|
|
|
579
643
|
```json
|
|
580
|
-
{
|
|
644
|
+
{
|
|
645
|
+
"reason": "user",
|
|
646
|
+
"virtual": "auto",
|
|
647
|
+
"tier": "index",
|
|
648
|
+
"model": "Qwen/Qwen3.6-35B-A3B-turbo",
|
|
649
|
+
"label": "index->generalist",
|
|
650
|
+
"thinking": "off->off"
|
|
651
|
+
}
|
|
581
652
|
```
|
|
582
653
|
|
|
583
654
|
## The tier table
|
|
@@ -619,12 +690,16 @@ same time.
|
|
|
619
690
|
| `TIINY_HOST` | `http://tiinyhost.local` | model store catalogue |
|
|
620
691
|
| `TIINY_PI_PROVIDER` | `tiiny` | provider id in `models.json` |
|
|
621
692
|
| `TIINY_HOME` | `~/.pi/agent/tiiny` | plan, lock and hold files |
|
|
622
|
-
| `TIINY_OWNER` |
|
|
693
|
+
| `TIINY_OWNER` | see [Commands](#commands) | controller owner |
|
|
623
694
|
| `TIINY_PLAN_FILE` | `$TIINY_HOME/tiiny-plan.json` | plan the router reads |
|
|
624
|
-
| `TIINY_TIERS_FILE` |
|
|
695
|
+
| `TIINY_TIERS_FILE` | package's `tiers.json` | tier table |
|
|
625
696
|
| `TIINY_THINKING_MAX_TOKENS` | `4096` | output floor when reasoning is set |
|
|
626
697
|
| `TIINY_ROUTER_TRACE` | (off) | JSON-lines route log |
|
|
627
698
|
|
|
699
|
+
`TIINY_BIN` selects the controller's Tiiny CLI executable; its default
|
|
700
|
+
is `~/.local/tiiny/bin/tiiny`. `TIINY_LOCK_FILE`, `TIINY_HOLD_FILE` and
|
|
701
|
+
`TIINY_SNAPSHOT_FILE` override the controller's state file paths.
|
|
702
|
+
|
|
628
703
|
## Operating notes
|
|
629
704
|
|
|
630
705
|
### One task at a time
|
|
@@ -633,8 +708,9 @@ The device serves one generation-heavy stream at a time. Two heavy
|
|
|
633
708
|
requests do not fail; they **hang**, and the device keeps reporting
|
|
634
709
|
healthy. This applies to the device as a whole, not just to pi. Killing
|
|
635
710
|
a client does not seem to stop its request on the device, so later
|
|
636
|
-
requests can hang behind it until it finishes. To clear stuck work,
|
|
637
|
-
|
|
711
|
+
requests can hang behind it until it finishes. To clear stuck work,
|
|
712
|
+
run `tiiny interrupt --all`, but note that it stops every active
|
|
713
|
+
request on the device, not just yours.
|
|
638
714
|
|
|
639
715
|
### A 404 is residency, not a bad id
|
|
640
716
|
|
|
@@ -662,7 +738,7 @@ agents/ tiiny-* subagent definitions
|
|
|
662
738
|
skill/SKILL.md the tiiny-routing skill
|
|
663
739
|
controller/ tiiny_ctl.py and tiiny-swap.sh, adapted for pi
|
|
664
740
|
bin/pirouter the `pirouter` command line
|
|
665
|
-
scripts/
|
|
741
|
+
scripts/init.sh `pirouter init`: links everything into ./.pi
|
|
666
742
|
```
|
|
667
743
|
|
|
668
744
|
## Development
|
|
@@ -722,6 +798,10 @@ they never touch `~/.pi` or a real device. They cover:
|
|
|
722
798
|
- the whole cycle: plan, reserve, load, then a routed child on the loaded
|
|
723
799
|
specialist, then release
|
|
724
800
|
|
|
801
|
+
The install-package tests also pack the repo, install the tarball in
|
|
802
|
+
fresh projects under `.test-tmp/`, and check the links and CLI from the
|
|
803
|
+
installed copy. Set `KEEP_TEST_TMP=1` to preserve these fixtures.
|
|
804
|
+
|
|
725
805
|
```bash
|
|
726
806
|
npm run test:live
|
|
727
807
|
```
|
|
@@ -739,7 +819,10 @@ holds the lock. Run them only when nothing else is using the device.
|
|
|
739
819
|
|
|
740
820
|
The routing design, the controller (`controller/tiiny_ctl.py`,
|
|
741
821
|
`controller/tiiny-swap.sh`) and the special-model table come from
|
|
742
|
-
[AI_Articles/tiiny-model-routing]
|
|
822
|
+
[AI_Articles/tiiny-model-routing][upstream]
|
|
743
823
|
by Gary Garcia, under the MIT License. The controller was changed to keep
|
|
744
824
|
its state in `TIINY_HOME` and to read its tier table and restore set from
|
|
745
825
|
`tiers.json`.
|
|
826
|
+
|
|
827
|
+
[upstream]:
|
|
828
|
+
https://github.com/garciacionet-alt/AI_Articles/tree/main/tiiny-model-routing
|
package/bin/pirouter
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# pirouter: the tiiny-router command line.
|
|
3
3
|
#
|
|
4
|
-
# pirouter
|
|
4
|
+
# pirouter init [--dry-run]
|
|
5
5
|
# link the extension, agents and skill into ./.pi
|
|
6
6
|
# pirouter uninstall [--dry-run]
|
|
7
7
|
# remove the router from global and local pi configuration
|
|
@@ -17,7 +17,7 @@ usage () {
|
|
|
17
17
|
cat <<'EOF'
|
|
18
18
|
usage: pirouter <command> [args]
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
init [--dry-run] link tiiny-router into this project's .pi/
|
|
21
21
|
uninstall [--dry-run] remove global and local pi configuration
|
|
22
22
|
check [opts] "goal" show the tier, model and thinking for a goal
|
|
23
23
|
(--tier T, --thinking auto|off|on, --all)
|
|
@@ -42,9 +42,9 @@ case "${1:-}" in
|
|
|
42
42
|
''|-h|--help|help)
|
|
43
43
|
usage
|
|
44
44
|
;;
|
|
45
|
-
|
|
45
|
+
init)
|
|
46
46
|
shift
|
|
47
|
-
exec bash "$pkg/scripts/
|
|
47
|
+
exec bash "$pkg/scripts/init.sh" "$@"
|
|
48
48
|
;;
|
|
49
49
|
check|uninstall)
|
|
50
50
|
command="$1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiiny-router-pi",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "pi extension that routes each task to the Tiiny model matching its shape",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"typecheck": "tsc --noEmit",
|
|
33
33
|
"build": "tsc -p tsconfig.build.json",
|
|
34
34
|
"route-check": "node src/cli/route-check.ts",
|
|
35
|
-
"
|
|
35
|
+
"init-pi": "bin/pirouter init",
|
|
36
36
|
"toc": "markdown-toc --maxdepth 3 -i README.md",
|
|
37
37
|
"prepack": "npm run build",
|
|
38
38
|
"version": "npm run toc && git add README.md",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
2
|
+
# Initialize this project's .pi/ directory with links into
|
|
3
3
|
# the installed package. Run it from the project root, through `pirouter`:
|
|
4
4
|
#
|
|
5
|
-
# npx pirouter
|
|
6
|
-
# npx pirouter
|
|
5
|
+
# npx pirouter init initialize the project
|
|
6
|
+
# npx pirouter init --dry-run print what would change
|
|
7
7
|
#
|
|
8
8
|
# It never overwrites a real file: an existing path that is not a symlink
|
|
9
9
|
# is reported and skipped.
|
|
@@ -16,9 +16,9 @@ dry=0
|
|
|
16
16
|
|
|
17
17
|
usage () {
|
|
18
18
|
cat <<'EOF'
|
|
19
|
-
usage: pirouter
|
|
19
|
+
usage: pirouter init [--dry-run]
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Initialize tiiny-router in this project's .pi/ directory. Run it from the
|
|
22
22
|
project root, the directory with package.json.
|
|
23
23
|
|
|
24
24
|
It makes these changes:
|
|
@@ -43,7 +43,7 @@ for arg in "$@"; do
|
|
|
43
43
|
--dry-run) dry=1 ;;
|
|
44
44
|
-h|--help) usage; exit 0 ;;
|
|
45
45
|
*)
|
|
46
|
-
echo "pirouter
|
|
46
|
+
echo "pirouter init: unknown option $arg" >&2
|
|
47
47
|
echo >&2
|
|
48
48
|
usage >&2
|
|
49
49
|
exit 2
|
|
@@ -52,7 +52,7 @@ for arg in "$@"; do
|
|
|
52
52
|
done
|
|
53
53
|
|
|
54
54
|
if [ ! -f "$project/package.json" ]; then
|
|
55
|
-
echo "pirouter
|
|
55
|
+
echo "pirouter init: no package.json in $project; run it from the" \
|
|
56
56
|
"project root" >&2
|
|
57
57
|
exit 1
|
|
58
58
|
fi
|