tiiny-router-pi 0.0.0 → 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 -72
- 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,17 +16,21 @@ model, and a task whose shape is unclear goes to the generalist.
|
|
|
16
16
|
|
|
17
17
|
<!-- toc -->
|
|
18
18
|
|
|
19
|
-
- [
|
|
19
|
+
- [Quickstart](#quickstart)
|
|
20
|
+
* [Install](#install)
|
|
21
|
+
- [Configure](#configure)
|
|
22
|
+
- [Dry Run](#dry-run)
|
|
20
23
|
- [Uninstall](#uninstall)
|
|
21
|
-
- [Loops](#
|
|
22
|
-
- [
|
|
24
|
+
- [`redeye`/Loops](#redeyeloops)
|
|
25
|
+
- [Examples](#examples)
|
|
23
26
|
* [Interactive](#interactive)
|
|
24
27
|
* [One-off](#one-off)
|
|
28
|
+
* [With `redeye`](#with-redeye)
|
|
25
29
|
* [Delegating with subagents](#delegating-with-subagents)
|
|
26
30
|
* [Batches: plan, reserve, load, release](#batches-plan-reserve-load-release)
|
|
27
31
|
- [Commands](#commands)
|
|
28
32
|
* [`npx pirouter`](#npx-pirouter)
|
|
29
|
-
* [`pirouter
|
|
33
|
+
* [`pirouter init`](#pirouter-init)
|
|
30
34
|
* [`pirouter uninstall`](#pirouter-uninstall)
|
|
31
35
|
* [`pirouter check`](#pirouter-check)
|
|
32
36
|
* [`pirouter status`](#pirouter-status)
|
|
@@ -54,47 +58,68 @@ model, and a task whose shape is unclear goes to the generalist.
|
|
|
54
58
|
|
|
55
59
|
</details>
|
|
56
60
|
|
|
61
|
+
## Quickstart
|
|
57
62
|
|
|
58
|
-
|
|
63
|
+
### Install
|
|
59
64
|
|
|
60
|
-
|
|
65
|
+
Use in an existing npm project with pi installed. Install locally with npm,
|
|
66
|
+
then run the setup script.
|
|
61
67
|
|
|
62
68
|
```bash
|
|
63
|
-
npm i -D tiiny-router
|
|
69
|
+
npm i -D tiiny-router-pi
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Setup:
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
npx pirouter init
|
|
64
76
|
```
|
|
65
77
|
|
|
66
78
|
Installing is local to your current repo only, not global or user-scope.
|
|
67
79
|
|
|
68
|
-
|
|
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`.
|
|
69
94
|
The script adds symbolic links, and copies a folder
|
|
70
95
|
to the project's `.pi/` directory, so pi can load the router's extension,
|
|
71
96
|
the router's agents, and router skills in the project.
|
|
72
97
|
|
|
73
|
-
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`.
|
|
74
99
|
See [Uninstall](#uninstall). Uninstall leaves `~/.pi/agent/tiiny` in
|
|
75
100
|
place. Delete it yourself if you no longer use the controller.
|
|
76
101
|
|
|
77
|
-
|
|
102
|
+
## Dry Run
|
|
78
103
|
|
|
79
104
|
Print what would change without changing anything:
|
|
80
105
|
|
|
81
106
|
```bash
|
|
82
|
-
npx pirouter
|
|
107
|
+
npx pirouter init --dry-run
|
|
83
108
|
```
|
|
84
109
|
|
|
85
110
|
Then install the extension, agents, and skill:
|
|
86
111
|
|
|
87
112
|
```bash
|
|
88
|
-
npx pirouter
|
|
113
|
+
npx pirouter init
|
|
89
114
|
```
|
|
90
115
|
|
|
91
|
-
Run these from the project root. `npx pirouter
|
|
92
|
-
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`,
|
|
93
118
|
which writes inside the project's `.pi/` directory. It makes these changes,
|
|
94
119
|
in this order:
|
|
95
120
|
|
|
96
121
|
1. Links the package as a pi extension:
|
|
97
|
-
`.pi/extensions/tiiny-router -> node_modules/tiiny-router`. pi reads
|
|
122
|
+
`.pi/extensions/tiiny-router -> node_modules/tiiny-router-pi`. pi reads
|
|
98
123
|
the `pi.extensions` field of the package's `package.json` to find
|
|
99
124
|
`index.ts`, which registers the `tiiny-router/*` virtual models.
|
|
100
125
|
2. Links each agent definition into `.pi/agents/`: `tiiny-browser.md`,
|
|
@@ -102,7 +127,7 @@ in this order:
|
|
|
102
127
|
`tiiny-researcher.md` and `tiiny-worker.md`. These are for the
|
|
103
128
|
subagent tool (see [Delegating with subagents](#delegating-with-subagents)).
|
|
104
129
|
3. Links the skill folder:
|
|
105
|
-
`.pi/skills/tiiny-routing -> node_modules/tiiny-router/skill`.
|
|
130
|
+
`.pi/skills/tiiny-routing -> node_modules/tiiny-router-pi/skill`.
|
|
106
131
|
4. Copies `index.ts` and `agents.ts` from pi's example `subagent`
|
|
107
132
|
extension into `.pi/extensions/subagent`, then edits the copy to set
|
|
108
133
|
`MAX_CONCURRENCY = 1` (see [One task at a time](#one-task-at-a-time)).
|
|
@@ -111,11 +136,13 @@ in this order:
|
|
|
111
136
|
a copy, not a link, so later pi updates do not change it.
|
|
112
137
|
|
|
113
138
|
Steps 1 to 3 create symbolic links. Because they point into
|
|
114
|
-
`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.
|
|
115
142
|
|
|
116
143
|
It doesn't overwrite files or directories. If a destination exists
|
|
117
144
|
and is not a symbolic link, it prints `skip:` and moves on. If it is a
|
|
118
|
-
symbolic link, it is replaced, so running `
|
|
145
|
+
symbolic link, it is replaced, so running `init` again is safe and
|
|
119
146
|
re-points old links at the current package. Step 4 is skipped if
|
|
120
147
|
`.pi/extensions/subagent` exists in any form. In that case, set
|
|
121
148
|
`MAX_CONCURRENCY = 1` in your own subagent extension. Step 4 is also
|
|
@@ -141,12 +168,15 @@ Everything else, the controller and the route checker, is a
|
|
|
141
168
|
`pirouter` subcommand too. Run `npx pirouter` with no arguments for
|
|
142
169
|
the list.
|
|
143
170
|
|
|
144
|
-
To try the
|
|
171
|
+
To try the extension for one run without linking it into `.pi/`:
|
|
145
172
|
|
|
146
173
|
```bash
|
|
147
|
-
pi -e npm:tiiny-router --model tiiny-router/auto
|
|
174
|
+
pi -e npm:tiiny-router-pi --model tiiny-router/auto
|
|
148
175
|
```
|
|
149
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
|
+
|
|
150
180
|
## Uninstall
|
|
151
181
|
|
|
152
182
|
From the project directory, preview the removal, then uninstall:
|
|
@@ -157,7 +187,9 @@ npx pirouter uninstall
|
|
|
157
187
|
```
|
|
158
188
|
|
|
159
189
|
This removes router entries from global `~/.pi/agent/settings.json` and
|
|
160
|
-
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.
|
|
161
193
|
It also removes links to the router's extension, agents and skill from
|
|
162
194
|
both scopes. If `PI_CODING_AGENT_DIR` is set, that directory is used for
|
|
163
195
|
global config instead. Other projects' local config is unchanged.
|
|
@@ -171,28 +203,33 @@ them. Running uninstall again is safe, and no `package.json` is required.
|
|
|
171
203
|
Restart pi or run `/reload`. To also remove the npm dependency, run:
|
|
172
204
|
|
|
173
205
|
```bash
|
|
174
|
-
npm rm tiiny-router
|
|
206
|
+
npm rm tiiny-router-pi
|
|
175
207
|
```
|
|
176
208
|
|
|
177
209
|
|
|
178
|
-
## Loops
|
|
210
|
+
## `redeye`/Loops
|
|
179
211
|
|
|
180
212
|
For an orchestrator such as
|
|
181
213
|
[redeye](https://github.com/nichoth/redeye) that runs `pi` in fresh `git`
|
|
182
214
|
worktrees, add the package to the project's `pi` settings instead:
|
|
183
215
|
|
|
184
216
|
```bash
|
|
185
|
-
npm i -D tiiny-router
|
|
217
|
+
npm i -D tiiny-router-pi
|
|
186
218
|
```
|
|
187
219
|
|
|
188
220
|
Commit `.pi/settings.json`:
|
|
189
221
|
|
|
190
222
|
```json
|
|
191
|
-
{ "packages": ["../node_modules/tiiny-router"] }
|
|
223
|
+
{ "packages": ["../node_modules/tiiny-router-pi"] }
|
|
192
224
|
```
|
|
193
225
|
|
|
194
226
|
The path is relative to `.pi/`, so each worktree loads its own installed
|
|
195
|
-
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:
|
|
196
233
|
|
|
197
234
|
```sh
|
|
198
235
|
npx redeye pi -m tiiny-router/auto --concurrency 1
|
|
@@ -201,7 +238,7 @@ npx redeye pi -m tiiny-router/auto --concurrency 1
|
|
|
201
238
|
To pin every task to one tier instead, name it, as in
|
|
202
239
|
`-m tiiny-router/code`.
|
|
203
240
|
|
|
204
|
-
##
|
|
241
|
+
## Examples
|
|
205
242
|
|
|
206
243
|
### Interactive
|
|
207
244
|
|
|
@@ -211,9 +248,10 @@ pi --model tiiny-router/auto
|
|
|
211
248
|
|
|
212
249
|
The footer shows the selection and the routed model (for example
|
|
213
250
|
`auto -> Qwen3.6-35B-A3B-turbo`), and the status line shows the route
|
|
214
|
-
label, such as `tiiny: draft->generalist [think:off]`. In `auto`,
|
|
215
|
-
new message is
|
|
216
|
-
|
|
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.
|
|
217
255
|
|
|
218
256
|
### One-off
|
|
219
257
|
|
|
@@ -221,12 +259,16 @@ session stays on the same model.
|
|
|
221
259
|
pi --model tiiny-router/index:off -p "Classify every file under ./notes by topic"
|
|
222
260
|
```
|
|
223
261
|
|
|
224
|
-
### With
|
|
262
|
+
### With `redeye`
|
|
225
263
|
|
|
226
264
|
Use this with the [`redeye` CLI](https://github.com/nichoth/redeye) tool.
|
|
227
265
|
See [the redeye docs](https://github.com/nichoth/redeye#local-model-with-pi)
|
|
228
266
|
for more examples.
|
|
229
267
|
|
|
268
|
+
```sh
|
|
269
|
+
npx redeye pi -m tiiny-router/auto --concurrency 1
|
|
270
|
+
```
|
|
271
|
+
|
|
230
272
|
### Delegating with subagents
|
|
231
273
|
|
|
232
274
|
The installed agents each pin a tier:
|
|
@@ -262,7 +304,7 @@ The subagent tool looks for agents in two places:
|
|
|
262
304
|
- project agents, in the nearest `.pi/agents/` above the working
|
|
263
305
|
directory
|
|
264
306
|
|
|
265
|
-
`pirouter
|
|
307
|
+
`pirouter init` puts the `tiiny-*` agents in the project's
|
|
266
308
|
`.pi/agents/`, so they are project agents. The tool's `agentScope`
|
|
267
309
|
parameter chooses where it looks:
|
|
268
310
|
|
|
@@ -270,7 +312,7 @@ parameter chooses where it looks:
|
|
|
270
312
|
|---|---|
|
|
271
313
|
| `"user"` (default) | user agents only |
|
|
272
314
|
| `"project"` | project agents only |
|
|
273
|
-
| `"both"` | both
|
|
315
|
+
| `"both"` | both; project agents take precedence when names match |
|
|
274
316
|
|
|
275
317
|
With the default, the `tiiny-*` agents cannot be found. The model sets
|
|
276
318
|
the tool's parameters, so say in your request that it should use project
|
|
@@ -317,12 +359,16 @@ planned, one at a time. Then restore the device and drop the lock:
|
|
|
317
359
|
npx pirouter release
|
|
318
360
|
```
|
|
319
361
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
`
|
|
324
|
-
|
|
325
|
-
|
|
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.
|
|
326
372
|
|
|
327
373
|
See [Commands](#commands) for every option.
|
|
328
374
|
The `tiiny-routing` skill walks a pi agent through this sequence.
|
|
@@ -337,26 +383,35 @@ pirouter [--device NAME] <command> [options]
|
|
|
337
383
|
|
|
338
384
|
Run `npx pirouter` with no arguments for a list of commands.
|
|
339
385
|
|
|
340
|
-
`
|
|
386
|
+
`init`, `uninstall` and `check` are handled by `pirouter` itself.
|
|
341
387
|
Every other command runs
|
|
342
388
|
the controller, `controller/tiiny_ctl.py`, with `python3`.
|
|
343
389
|
`npx pirouter check -h` and `npx pirouter <controller command> -h`
|
|
344
390
|
show a command's options.
|
|
345
391
|
|
|
346
|
-
`--device NAME`
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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.
|
|
350
403
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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`.
|
|
355
410
|
|
|
356
|
-
### `pirouter
|
|
411
|
+
### `pirouter init`
|
|
357
412
|
|
|
358
413
|
```bash
|
|
359
|
-
npx pirouter
|
|
414
|
+
npx pirouter init [--dry-run]
|
|
360
415
|
```
|
|
361
416
|
|
|
362
417
|
Link the extension, agents and skill into `./.pi`, and copy the
|
|
@@ -410,13 +465,14 @@ npx pirouter plan --goal "GOAL" [--goal "GOAL" ...] [options]
|
|
|
410
465
|
|
|
411
466
|
Picks a model for each goal, packs the models into waves that each fit
|
|
412
467
|
in 100% NPU, and writes the plan file. It needs at least one `--goal`.
|
|
413
|
-
|
|
468
|
+
Candidates must already be resident or marked downloaded/running in
|
|
469
|
+
the catalogue. If none qualifies, it falls back to the generalist.
|
|
414
470
|
|
|
415
471
|
| Option | Meaning |
|
|
416
472
|
|---|---|
|
|
417
473
|
| `--goal GOAL` | a task goal; repeat it for a batch |
|
|
418
474
|
| `--tier TIER` | use this tier for every goal |
|
|
419
|
-
| `--model MODEL` |
|
|
475
|
+
| `--model MODEL` | restrict each goal to this model in its tier's candidates |
|
|
420
476
|
| `--owner OWNER` | who is planning |
|
|
421
477
|
| `--task TASK` | what the batch is for |
|
|
422
478
|
|
|
@@ -426,9 +482,9 @@ Only models downloaded to the device are chosen.
|
|
|
426
482
|
npx pirouter reserve --owner OWNER [options]
|
|
427
483
|
```
|
|
428
484
|
|
|
429
|
-
Takes the lock, so other
|
|
430
|
-
|
|
431
|
-
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.
|
|
432
488
|
|
|
433
489
|
| Option | Meaning |
|
|
434
490
|
|---|---|
|
|
@@ -480,7 +536,8 @@ npx pirouter release [--owner OWNER] [--force]
|
|
|
480
536
|
|
|
481
537
|
Clears the hold, reloads the `required` models from `tiers.json`,
|
|
482
538
|
checks that they loaded, and clears the lock. It checks who holds the
|
|
483
|
-
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.
|
|
484
541
|
|
|
485
542
|
| Option | Meaning |
|
|
486
543
|
|---|---|
|
|
@@ -503,6 +560,10 @@ now be wrong.
|
|
|
503
560
|
| `--update` | save the current store as the new snapshot |
|
|
504
561
|
| `--refresh` | the same as `--update` |
|
|
505
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
|
+
|
|
506
567
|
### `pirouter image`
|
|
507
568
|
|
|
508
569
|
```bash
|
|
@@ -515,7 +576,10 @@ shows its NPU share, whether it is loaded, and the other candidates.
|
|
|
515
576
|
| Option | Meaning |
|
|
516
577
|
|---|---|
|
|
517
578
|
| `--kind KIND` | `image` (default), `music` or `ocr` |
|
|
518
|
-
| `--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.
|
|
519
583
|
|
|
520
584
|
|
|
521
585
|
|
|
@@ -532,15 +596,17 @@ The thinking level on the virtual model sets the reasoning mode:
|
|
|
532
596
|
For `off` and `on`, the router reads the routed model's `thinking` block
|
|
533
597
|
from the device and rewrites the request:
|
|
534
598
|
|
|
535
|
-
-
|
|
599
|
+
- For a model reported as reasoning-capable,
|
|
600
|
+
`chat_template_kwargs.enable_thinking` is always sent, because the
|
|
536
601
|
device's `toggleable` flag is not always right.
|
|
537
602
|
- If the model has levels but no switch (for example `gpt-oss-20b`),
|
|
538
603
|
`reasoning_effort` is set to its cheapest level for `off` and its
|
|
539
604
|
highest for `on`. The label then says `off->low`, since the model still
|
|
540
605
|
reasons, only less.
|
|
541
|
-
-
|
|
542
|
-
|
|
543
|
-
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.
|
|
544
610
|
|
|
545
611
|
The achieved state, not the requested one, is shown in the label:
|
|
546
612
|
`off`, `on`, `off->low`, `on->high`, `unsupported` (the model does not
|
|
@@ -575,7 +641,14 @@ TIINY_ROUTER_TRACE=/tmp/tiiny-routes.jsonl pi --model tiiny-router/auto
|
|
|
575
641
|
```
|
|
576
642
|
|
|
577
643
|
```json
|
|
578
|
-
{
|
|
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
|
+
}
|
|
579
652
|
```
|
|
580
653
|
|
|
581
654
|
## The tier table
|
|
@@ -617,12 +690,16 @@ same time.
|
|
|
617
690
|
| `TIINY_HOST` | `http://tiinyhost.local` | model store catalogue |
|
|
618
691
|
| `TIINY_PI_PROVIDER` | `tiiny` | provider id in `models.json` |
|
|
619
692
|
| `TIINY_HOME` | `~/.pi/agent/tiiny` | plan, lock and hold files |
|
|
620
|
-
| `TIINY_OWNER` |
|
|
693
|
+
| `TIINY_OWNER` | see [Commands](#commands) | controller owner |
|
|
621
694
|
| `TIINY_PLAN_FILE` | `$TIINY_HOME/tiiny-plan.json` | plan the router reads |
|
|
622
|
-
| `TIINY_TIERS_FILE` |
|
|
695
|
+
| `TIINY_TIERS_FILE` | package's `tiers.json` | tier table |
|
|
623
696
|
| `TIINY_THINKING_MAX_TOKENS` | `4096` | output floor when reasoning is set |
|
|
624
697
|
| `TIINY_ROUTER_TRACE` | (off) | JSON-lines route log |
|
|
625
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
|
+
|
|
626
703
|
## Operating notes
|
|
627
704
|
|
|
628
705
|
### One task at a time
|
|
@@ -631,8 +708,9 @@ The device serves one generation-heavy stream at a time. Two heavy
|
|
|
631
708
|
requests do not fail; they **hang**, and the device keeps reporting
|
|
632
709
|
healthy. This applies to the device as a whole, not just to pi. Killing
|
|
633
710
|
a client does not seem to stop its request on the device, so later
|
|
634
|
-
requests can hang behind it until it finishes. To clear stuck work,
|
|
635
|
-
|
|
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.
|
|
636
714
|
|
|
637
715
|
### A 404 is residency, not a bad id
|
|
638
716
|
|
|
@@ -660,7 +738,7 @@ agents/ tiiny-* subagent definitions
|
|
|
660
738
|
skill/SKILL.md the tiiny-routing skill
|
|
661
739
|
controller/ tiiny_ctl.py and tiiny-swap.sh, adapted for pi
|
|
662
740
|
bin/pirouter the `pirouter` command line
|
|
663
|
-
scripts/
|
|
741
|
+
scripts/init.sh `pirouter init`: links everything into ./.pi
|
|
664
742
|
```
|
|
665
743
|
|
|
666
744
|
## Development
|
|
@@ -720,6 +798,10 @@ they never touch `~/.pi` or a real device. They cover:
|
|
|
720
798
|
- the whole cycle: plan, reserve, load, then a routed child on the loaded
|
|
721
799
|
specialist, then release
|
|
722
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
|
+
|
|
723
805
|
```bash
|
|
724
806
|
npm run test:live
|
|
725
807
|
```
|
|
@@ -737,7 +819,10 @@ holds the lock. Run them only when nothing else is using the device.
|
|
|
737
819
|
|
|
738
820
|
The routing design, the controller (`controller/tiiny_ctl.py`,
|
|
739
821
|
`controller/tiiny-swap.sh`) and the special-model table come from
|
|
740
|
-
[AI_Articles/tiiny-model-routing]
|
|
822
|
+
[AI_Articles/tiiny-model-routing][upstream]
|
|
741
823
|
by Gary Garcia, under the MIT License. The controller was changed to keep
|
|
742
824
|
its state in `TIINY_HOME` and to read its tier table and restore set from
|
|
743
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
|