@routerlab/cli 0.0.1
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 -0
- package/README.md +171 -0
- package/dist/commands/eval.d.ts +21 -0
- package/dist/commands/eval.d.ts.map +1 -0
- package/dist/commands/eval.js +104 -0
- package/dist/commands/eval.js.map +1 -0
- package/dist/commands/frontier.d.ts +29 -0
- package/dist/commands/frontier.d.ts.map +1 -0
- package/dist/commands/frontier.js +212 -0
- package/dist/commands/frontier.js.map +1 -0
- package/dist/commands/help.d.ts +3 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +55 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/models.d.ts +7 -0
- package/dist/commands/models.d.ts.map +1 -0
- package/dist/commands/models.js +71 -0
- package/dist/commands/models.js.map +1 -0
- package/dist/commands/route.d.ts +7 -0
- package/dist/commands/route.d.ts.map +1 -0
- package/dist/commands/route.js +173 -0
- package/dist/commands/route.js.map +1 -0
- package/dist/commands/version.d.ts +8 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +21 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +32 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/io.d.ts +33 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +47 -0
- package/dist/io.js.map +1 -0
- package/dist/main.d.ts +14 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +64 -0
- package/dist/main.js.map +1 -0
- package/dist/parse.d.ts +44 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +125 -0
- package/dist/parse.js.map +1 -0
- package/package.json +30 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may accept and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Faraazuddin Mohammed
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# `@routerlab/cli`
|
|
2
|
+
|
|
3
|
+
> `route` — the terminal interface to routerlab's cost-quality routing engine.
|
|
4
|
+
|
|
5
|
+
The CLI lets you route prompts, inspect published Pareto frontiers, list
|
|
6
|
+
candidate models, and run the frontier eval pipeline — all from a shell.
|
|
7
|
+
It wraps `@routerlab/core` so every routing decision is grounded in the
|
|
8
|
+
same atlas-calibrated empirical token economics that powers the library.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
> **Runtime**: `@routerlab/cli` requires [Bun](https://bun.sh) (>= 1.1.0).
|
|
13
|
+
> The binary's shebang is `#!/usr/bin/env bun` and the `eval` subcommand
|
|
14
|
+
> dynamically imports a `.ts` runner module. Node.js is not supported as
|
|
15
|
+
> the CLI runtime. The library package
|
|
16
|
+
> ([`@routerlab/core`](https://www.npmjs.com/package/@routerlab/core)) is
|
|
17
|
+
> runtime-agnostic and works on both.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bun add @routerlab/cli
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or, inside the routerlab monorepo:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
bun install
|
|
27
|
+
bun packages/cli/src/index.ts --help
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick examples
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Route a prompt for QA at quality bar 0.85:
|
|
34
|
+
echo "What's the capital of France?" \
|
|
35
|
+
| route route --task=qa --quality-bar=0.85
|
|
36
|
+
|
|
37
|
+
# Same, with a $0.005 hard budget and JSON output for piping into jq:
|
|
38
|
+
echo "Write a python function that ..." \
|
|
39
|
+
| route route --task=codegen --quality-bar=0.80 --max-cost-usd=0.005 --json \
|
|
40
|
+
| jq '.chosen.model.model'
|
|
41
|
+
|
|
42
|
+
# Read the prompt from a file instead of stdin:
|
|
43
|
+
route route --task=qa --quality-bar=0.85 --input=./prompt.txt
|
|
44
|
+
|
|
45
|
+
# Inspect the published Pareto frontier for codegen:
|
|
46
|
+
route frontier --task=codegen
|
|
47
|
+
|
|
48
|
+
# Same, as JSON:
|
|
49
|
+
route frontier --task=codegen --format=json
|
|
50
|
+
|
|
51
|
+
# List candidate models (optionally filtered by provider):
|
|
52
|
+
route models
|
|
53
|
+
route models --provider=anthropic
|
|
54
|
+
route models --json
|
|
55
|
+
|
|
56
|
+
# Run the frontier eval pipeline for a single task:
|
|
57
|
+
route eval frontier --task=qa --n=20
|
|
58
|
+
|
|
59
|
+
# Print versions:
|
|
60
|
+
route version
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Subcommands
|
|
64
|
+
|
|
65
|
+
### `route route --task=<t> --quality-bar=<q> [flags]`
|
|
66
|
+
|
|
67
|
+
Reads a prompt from `--input <file>` or stdin and prints the engine's
|
|
68
|
+
decision: the chosen model, ordered fallbacks, and a skipped-with-reasons
|
|
69
|
+
list. Default output is human-friendly; `--json` emits the raw
|
|
70
|
+
`RouteDecision` for piping.
|
|
71
|
+
|
|
72
|
+
| Flag | Required | Description |
|
|
73
|
+
| ------------------- | -------- | ------------------------------------------------------ |
|
|
74
|
+
| `--task=<t>` | yes | One of `qa, codegen, summarization, classification, reasoning` |
|
|
75
|
+
| `--quality-bar=<q>` | yes | Float in [0, 1] |
|
|
76
|
+
| `--input=<path>` | no | Read prompt from file (else stdin) |
|
|
77
|
+
| `--max-cost-usd=<n>`| no | Hard budget cap, USD |
|
|
78
|
+
| `--max-latency-ms=<n>` | no | Hard latency cap, milliseconds |
|
|
79
|
+
| `--json` | no | Emit raw `RouteDecision` JSON |
|
|
80
|
+
|
|
81
|
+
Example output:
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
Decision: claude-sonnet-4-6 (anthropic)
|
|
85
|
+
expected cost: $0.001533
|
|
86
|
+
expected quality: 0.900
|
|
87
|
+
reasoning: cheapest model meeting quality bar 0.850 for task "qa"; ...
|
|
88
|
+
|
|
89
|
+
Fallbacks (ordered by next-cheapest):
|
|
90
|
+
1. claude-opus-4-7 (anthropic) cost-rank 2 of 2 ...
|
|
91
|
+
|
|
92
|
+
Skipped (4):
|
|
93
|
+
- claude-haiku-4-5: expected quality 0.800 for task "qa" is below quality bar 0.850
|
|
94
|
+
- llama-3.3-70b: expected quality 0.800 for task "qa" is below quality bar 0.850
|
|
95
|
+
- ...
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### `route frontier --task=<t> [flags]`
|
|
99
|
+
|
|
100
|
+
Reads `eval/results/frontier.json` and pretty-prints the Pareto frontier
|
|
101
|
+
for the requested task. Useful for "what should I pick for codegen at
|
|
102
|
+
quality bar 0.85?" Q&A from the terminal.
|
|
103
|
+
|
|
104
|
+
| Flag | Required | Description |
|
|
105
|
+
| ------------------- | -------- | -------------------------------------------------------------- |
|
|
106
|
+
| `--task=<t>` | yes | Task class |
|
|
107
|
+
| `--format=table\|json` | no | Default `table` |
|
|
108
|
+
| `--path=<p>` | no | Override the frontier.json path (else uses repo default or `ROUTERLAB_FRONTIER_PATH`) |
|
|
109
|
+
|
|
110
|
+
### `route models [flags]`
|
|
111
|
+
|
|
112
|
+
Lists the engine's candidate model pool from
|
|
113
|
+
`packages/core/src/candidates.json`.
|
|
114
|
+
|
|
115
|
+
| Flag | Description |
|
|
116
|
+
| ------------------- | ------------------------------------------ |
|
|
117
|
+
| `--provider=<p>` | Filter to one of `anthropic, openai, google, groq, together, hf, openrouter` |
|
|
118
|
+
| `--json` | JSON output |
|
|
119
|
+
|
|
120
|
+
### `route eval frontier --task=<t> [--n=<n>]`
|
|
121
|
+
|
|
122
|
+
Invokes the frontier builder at `eval/frontier/runner.ts` for a single
|
|
123
|
+
task with `n` examples (default per the runner). Persists outcomes to
|
|
124
|
+
`eval/results/` and prints a JSON summary on stdout.
|
|
125
|
+
|
|
126
|
+
The runner is loaded dynamically; override its module path with
|
|
127
|
+
`ROUTERLAB_FRONTIER_RUNNER_MODULE` if you've vendored it elsewhere.
|
|
128
|
+
|
|
129
|
+
### `route version`
|
|
130
|
+
|
|
131
|
+
Prints `@routerlab/cli` and `@routerlab/core` versions.
|
|
132
|
+
|
|
133
|
+
## Exit codes
|
|
134
|
+
|
|
135
|
+
| Code | Meaning |
|
|
136
|
+
| ---- | ------------------------------------------------------- |
|
|
137
|
+
| 0 | Success |
|
|
138
|
+
| 1 | No candidates pass the filters |
|
|
139
|
+
| 2 | Invalid input (bad flag, malformed value, missing arg) |
|
|
140
|
+
| 3 | Downstream error (calibration / runner / missing file) |
|
|
141
|
+
|
|
142
|
+
These are stable. Script against them.
|
|
143
|
+
|
|
144
|
+
## Programmatic use
|
|
145
|
+
|
|
146
|
+
The CLI is a thin wrapper around `@routerlab/core`. For library access:
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
import { route } from "@routerlab/core";
|
|
150
|
+
|
|
151
|
+
const decision = route({
|
|
152
|
+
task: "qa",
|
|
153
|
+
prompt: "What's the capital of France?",
|
|
154
|
+
qualityBar: 0.85,
|
|
155
|
+
maxCostUsd: 0.005,
|
|
156
|
+
});
|
|
157
|
+
console.log(decision.chosen.model.model);
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Environment variables
|
|
161
|
+
|
|
162
|
+
| Variable | Effect |
|
|
163
|
+
| --------------------------------------- | --------------------------------------------------------------------- |
|
|
164
|
+
| `ROUTERLAB_FRONTIER_PATH` | Override the default `frontier.json` path |
|
|
165
|
+
| `ROUTERLAB_FRONTIER_RUNNER_MODULE` | Override the dynamically-imported frontier runner module path |
|
|
166
|
+
| `ROUTERLAB_ATLAS_RESULTS_PATH` | Atlas calibration file path (read by `@routerlab/core/cost.ts`) |
|
|
167
|
+
| `ROUTERLAB_QUALITY_TABLE_PATH` | Quality table path (read by `@routerlab/core/quality_predictor.ts`) |
|
|
168
|
+
|
|
169
|
+
## License
|
|
170
|
+
|
|
171
|
+
Apache-2.0. See [`LICENSE`](./LICENSE).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type CliContext } from "../io.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal contract the dynamically-loaded frontier runner must satisfy.
|
|
4
|
+
* Matches the public surface of `eval/frontier/runner.ts`'s `runFrontier`.
|
|
5
|
+
* Kept structurally typed (rather than importing the real type) so the
|
|
6
|
+
* CLI doesn't take a hard dependency on the eval harness — the runner
|
|
7
|
+
* lives outside of `@routerlab/core`'s public surface.
|
|
8
|
+
*/
|
|
9
|
+
export interface FrontierRunnerModule {
|
|
10
|
+
runFrontier: (opts: {
|
|
11
|
+
tasks?: readonly string[];
|
|
12
|
+
examplesPerTask?: number;
|
|
13
|
+
quiet?: boolean;
|
|
14
|
+
}) => Promise<unknown> | unknown;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Entry point for the `eval ...` namespace. The first positional after
|
|
18
|
+
* `eval` selects the sub-subcommand.
|
|
19
|
+
*/
|
|
20
|
+
export declare function runEval(ctx: CliContext): Promise<number>;
|
|
21
|
+
//# sourceMappingURL=eval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eval.d.ts","sourceRoot":"","sources":["../../src/commands/eval.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,KAAK,UAAU,EAAa,MAAM,UAAU,CAAC;AAoBtD;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,CAAC,IAAI,EAAE;QAClB,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;QAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAkB9D"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// commands/eval.ts — the `eval` namespace.
|
|
2
|
+
//
|
|
3
|
+
// Currently exposes one sub-subcommand: `eval frontier --task=<t> --n=<n>`.
|
|
4
|
+
// The brief says this should delegate to `eval/frontier/runner.ts` either
|
|
5
|
+
// via subprocess or direct import.
|
|
6
|
+
//
|
|
7
|
+
// At the moment the frontier runner has not been published yet by the
|
|
8
|
+
// router-frontier agent; rather than failing in a hostile way, we attempt
|
|
9
|
+
// a dynamic import of the runner module by its conventional path. If the
|
|
10
|
+
// module is present we invoke its `runFrontier({ task, n })` export; if
|
|
11
|
+
// not, we exit 3 with a clear "not yet implemented in this build" message
|
|
12
|
+
// so the user knows what's going on.
|
|
13
|
+
//
|
|
14
|
+
// This design keeps the CLI shippable now and "just works" the moment the
|
|
15
|
+
// runner agent lands its module — no further CLI changes needed.
|
|
16
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
17
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
18
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
19
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return path;
|
|
23
|
+
};
|
|
24
|
+
import { parseArgs } from "node:util";
|
|
25
|
+
import { fileURLToPath } from "node:url";
|
|
26
|
+
import { dirname, resolve as resolvePath } from "node:path";
|
|
27
|
+
import { CliError, EXIT_DOWNSTREAM, EXIT_INVALID_INPUT } from "../errors.js";
|
|
28
|
+
import { writeLine } from "../io.js";
|
|
29
|
+
import { parsePositiveIntOptional, parseTask } from "../parse.js";
|
|
30
|
+
const FRONTIER_RUNNER_MODULE_ENV_VAR = "ROUTERLAB_FRONTIER_RUNNER_MODULE";
|
|
31
|
+
// Resolve repo-relative path from this module's location so the CLI works on
|
|
32
|
+
// any machine without hardcoded absolute paths. This file lives at
|
|
33
|
+
// `packages/cli/src/commands/eval.ts`; the runner is at
|
|
34
|
+
// `eval/frontier/runner.ts` relative to the repo root (4 levels up).
|
|
35
|
+
const DEFAULT_FRONTIER_RUNNER_MODULE = resolvePath(dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "..", "eval", "frontier", "runner.ts");
|
|
36
|
+
/**
|
|
37
|
+
* Entry point for the `eval ...` namespace. The first positional after
|
|
38
|
+
* `eval` selects the sub-subcommand.
|
|
39
|
+
*/
|
|
40
|
+
export async function runEval(ctx) {
|
|
41
|
+
const [first, ...rest] = ctx.argv;
|
|
42
|
+
if (first === undefined) {
|
|
43
|
+
throw new CliError(EXIT_INVALID_INPUT, "eval: missing subcommand. Usage: route eval frontier --task=<t> [--n=<n>]");
|
|
44
|
+
}
|
|
45
|
+
const subCtx = { ...ctx, argv: rest };
|
|
46
|
+
switch (first) {
|
|
47
|
+
case "frontier":
|
|
48
|
+
return runEvalFrontier(subCtx);
|
|
49
|
+
default:
|
|
50
|
+
throw new CliError(EXIT_INVALID_INPUT, `eval: unknown subcommand "${first}". Known: frontier`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* `eval frontier --task=<task> [--n=<n>]` — invoke the frontier builder.
|
|
55
|
+
*/
|
|
56
|
+
async function runEvalFrontier(ctx) {
|
|
57
|
+
let parsed;
|
|
58
|
+
try {
|
|
59
|
+
parsed = parseArgs({
|
|
60
|
+
args: [...ctx.argv],
|
|
61
|
+
options: {
|
|
62
|
+
task: { type: "string" },
|
|
63
|
+
n: { type: "string" },
|
|
64
|
+
},
|
|
65
|
+
strict: true,
|
|
66
|
+
allowPositionals: false,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
throw new CliError(EXIT_INVALID_INPUT, `eval frontier: ${e instanceof Error ? e.message : String(e)}`);
|
|
71
|
+
}
|
|
72
|
+
const task = parseTask(parsed.values["task"]);
|
|
73
|
+
const n = parsePositiveIntOptional("n", parsed.values["n"]);
|
|
74
|
+
const modulePath = resolveRunnerModule(ctx);
|
|
75
|
+
let mod;
|
|
76
|
+
try {
|
|
77
|
+
const imported = (await import(__rewriteRelativeImportExtension(modulePath)));
|
|
78
|
+
if (typeof imported.runFrontier !== "function") {
|
|
79
|
+
throw new Error(`module at ${modulePath} does not export a "runFrontier" function`);
|
|
80
|
+
}
|
|
81
|
+
mod = imported;
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
85
|
+
throw new CliError(EXIT_DOWNSTREAM, `eval frontier: frontier runner is not available at ${modulePath}: ${msg}. ` +
|
|
86
|
+
`Set ${FRONTIER_RUNNER_MODULE_ENV_VAR} to override the runner path.`);
|
|
87
|
+
}
|
|
88
|
+
writeLine(ctx.stderr, `eval frontier: invoking ${modulePath} (task=${task}${n !== undefined ? `, examplesPerTask=${n}` : ""})`);
|
|
89
|
+
const opts = {
|
|
90
|
+
tasks: [task],
|
|
91
|
+
quiet: true,
|
|
92
|
+
...(n !== undefined ? { examplesPerTask: n } : {}),
|
|
93
|
+
};
|
|
94
|
+
const result = await Promise.resolve(mod.runFrontier(opts));
|
|
95
|
+
writeLine(ctx.stdout, JSON.stringify({ task, n, result: result ?? null }, null, 2));
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
function resolveRunnerModule(ctx) {
|
|
99
|
+
const fromEnv = ctx.env[FRONTIER_RUNNER_MODULE_ENV_VAR];
|
|
100
|
+
if (typeof fromEnv === "string" && fromEnv.length > 0)
|
|
101
|
+
return fromEnv;
|
|
102
|
+
return DEFAULT_FRONTIER_RUNNER_MODULE;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=eval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eval.js","sourceRoot":"","sources":["../../src/commands/eval.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,EAAE;AACF,4EAA4E;AAC5E,0EAA0E;AAC1E,mCAAmC;AACnC,EAAE;AACF,sEAAsE;AACtE,0EAA0E;AAC1E,yEAAyE;AACzE,wEAAwE;AACxE,0EAA0E;AAC1E,qCAAqC;AACrC,EAAE;AACF,0EAA0E;AAC1E,iEAAiE;;;;;;;;;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAmB,SAAS,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAElE,MAAM,8BAA8B,GAAG,kCAAkC,CAAC;AAE1E,6EAA6E;AAC7E,mEAAmE;AACnE,wDAAwD;AACxD,qEAAqE;AACrE,MAAM,8BAA8B,GAAG,WAAW,CAChD,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACvC,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,UAAU,EACV,WAAW,CACZ,CAAC;AAiBF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,GAAe;IAC3C,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,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CAAC,CAC7D,CAAC;IACF,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAe;IAC1C,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;IACxD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IACtE,OAAO,8BAA8B,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type CliContext } from "../io.ts";
|
|
2
|
+
/**
|
|
3
|
+
* One row of a published Pareto frontier. The optional CI fields are
|
|
4
|
+
* present when the row came from a measured quality table (post Phase 3);
|
|
5
|
+
* absent when the row was generated from the seeded prior.
|
|
6
|
+
*/
|
|
7
|
+
export interface FrontierRow {
|
|
8
|
+
model: string;
|
|
9
|
+
provider: string;
|
|
10
|
+
expectedCost: number;
|
|
11
|
+
expectedQuality: number;
|
|
12
|
+
qualityLo95?: number;
|
|
13
|
+
qualityHi95?: number;
|
|
14
|
+
n?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parsed shape of the on-disk frontier file. Only the fields we render are
|
|
18
|
+
* required; everything else is tolerated and ignored.
|
|
19
|
+
*/
|
|
20
|
+
export interface FrontierFile {
|
|
21
|
+
schema_version?: number;
|
|
22
|
+
generated_at?: string;
|
|
23
|
+
frontiers: Partial<Record<string, FrontierRow[]>>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parse and execute the `frontier` subcommand.
|
|
27
|
+
*/
|
|
28
|
+
export declare function runFrontier(ctx: CliContext): number;
|
|
29
|
+
//# sourceMappingURL=frontier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontier.d.ts","sourceRoot":"","sources":["../../src/commands/frontier.ts"],"names":[],"mappings":"AAkCA,OAAO,EAAE,KAAK,UAAU,EAAa,MAAM,UAAU,CAAC;AAmBtD;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;CACnD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAqDnD"}
|