modelpace 0.0.0-stage → 0.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/AGENTS.md +147 -0
- package/CHANGELOG.md +14 -0
- package/LICENSE +21 -0
- package/README.md +216 -2
- package/README.zh-CN.md +198 -0
- package/SECURITY.md +16 -0
- package/bin/modelpace-mcp.mjs +337 -0
- package/bin/modelpace.mjs +383 -0
- package/docs/SCHEMA.md +170 -0
- package/examples/multi-account.config.json +168 -0
- package/examples/multi-account.snapshot.json +227 -0
- package/examples/record.example.json +23 -0
- package/examples/sample-snapshot.json +173 -0
- package/llms.txt +26 -0
- package/package.json +56 -4
- package/skills/modelpace/SKILL.md +82 -0
- package/src/adapters/json-snapshot.mjs +360 -0
- package/src/adapters/t3-auto.mjs +160 -0
- package/src/adapters/t3-config.mjs +337 -0
- package/src/adapters/t3-rpc.mjs +275 -0
- package/src/context.mjs +73 -0
- package/src/core/decide.mjs +435 -0
- package/src/core/pacing.mjs +569 -0
- package/src/core/policy.mjs +252 -0
- package/src/core/scores.mjs +491 -0
- package/src/index.mjs +48 -0
- package/src/speed/collect.mjs +47 -0
- package/src/speed/histogram.mjs +170 -0
- package/src/speed/scanner.mjs +390 -0
- package/src/ui/client.js +522 -0
- package/src/ui/dashboard.css +106 -0
- package/src/ui/dashboard.mjs +150 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# modelpace — guide for coding agents
|
|
2
|
+
|
|
3
|
+
modelpace recommends which T3 Code provider instance and model should take a task, based on live quota (Even Pace), reset credits and past acceptance records. It only advises: you still call `delegate_task` yourself. Zero runtime dependencies, Node.js >= 22, MIT.
|
|
4
|
+
|
|
5
|
+
In this file `modelpace` means `node <checkout>/bin/modelpace.mjs` (from a clone) or `npx modelpace` (once published to npm). Field reference: [docs/SCHEMA.md](./docs/SCHEMA.md). Skill: [skills/modelpace/SKILL.md](./skills/modelpace/SKILL.md).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
git clone https://github.com/jieyuexing/modelpace.git
|
|
11
|
+
cd modelpace
|
|
12
|
+
node ./bin/modelpace.mjs --version
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Nothing to build, no dependencies. Check `node --version` is 22 or newer first.
|
|
16
|
+
|
|
17
|
+
## First run: validate, plan, record
|
|
18
|
+
|
|
19
|
+
These blocks run offline against files in this repository (`--now` pins the clock to the sample snapshot's time, otherwise it would be stale). They create demo files (`dispatch.config.json`, `dispatch-scores.jsonl`) in the current directory: do this in a scratch directory and delete them afterwards. The example record is fake; never record it into the user's real ledger (always pass `--scores` as below).
|
|
20
|
+
|
|
21
|
+
<!-- docs-test -->
|
|
22
|
+
```bash
|
|
23
|
+
modelpace init --out dispatch.config.json
|
|
24
|
+
modelpace validate --config dispatch.config.json
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
<!-- docs-test expect: Action: run -> codex / gpt-5.3-codex -->
|
|
28
|
+
```bash
|
|
29
|
+
modelpace plan --config dispatch.config.json --snapshot examples/sample-snapshot.json --now 2026-11-23T07:05:00Z --task slice
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`Action: run` plus a `delegate_task target: {...}` line is a recommendation you can pass to `delegate_task`. Then, after you have independently verified the delegated result, record it. `examples/record.example.json` is a complete template; edit it, do not guess fields:
|
|
33
|
+
|
|
34
|
+
<!-- docs-test expect: Recorded codex/gpt-5.3-codex/high/default/local -->
|
|
35
|
+
```bash
|
|
36
|
+
modelpace record --json examples/record.example.json --scores dispatch-scores.jsonl
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
<!-- docs-test expect: codex/gpt-5.3-codex/high/default -->
|
|
40
|
+
```bash
|
|
41
|
+
modelpace scores --scores dispatch-scores.jsonl
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Against the user's real T3 Code, replace `--snapshot ... --now ...` with `--t3-auto` (see Data and privacy first):
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
modelpace plan --t3-auto --task slice
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Without `--config` the built-in policy is used (instances `codex`, `claudeAgent`, `antigravity`, the official T3 Code defaults). If the user has other instance ids or accounts, write a config from `modelpace init` or `examples/multi-account.config.json`.
|
|
51
|
+
|
|
52
|
+
## When to run what
|
|
53
|
+
|
|
54
|
+
| Situation | Command | MCP tool |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
| About to call `delegate_task` | `modelpace plan --t3-auto --task <general\|research\|review\|slice\|long> --format json` | `dispatch_plan` |
|
|
57
|
+
| A delegated result was independently verified (tests, diff, user acceptance) | `modelpace record --json FILE\|-` | `dispatch_record` |
|
|
58
|
+
| Asked why a model is (not) preferred | `modelpace scores` | `dispatch_scores` |
|
|
59
|
+
| Asked which model is fastest on this machine | `modelpace speed --days 30` | `dispatch_speed` |
|
|
60
|
+
| User wants a visual overview | `modelpace dashboard --t3-auto --out dashboard.html` (or `serve`) | none |
|
|
61
|
+
| Checking or creating a policy | `modelpace validate --config FILE`, `modelpace init` | none |
|
|
62
|
+
|
|
63
|
+
Never record a result on the sub-agent's own say-so. `plan` never changes anything outside the ledger, and only `record` writes to it.
|
|
64
|
+
|
|
65
|
+
## Reading a plan
|
|
66
|
+
|
|
67
|
+
`--format json` returns `{ action, recommended, waitUntil, redeemCandidate, nextCheckAt, reasons, candidates }`.
|
|
68
|
+
|
|
69
|
+
| `action` | Do this |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `run` | Pass `recommended.target` (`{ providerInstanceId, model, options }`) to `delegate_task` unchanged. Keep `recommended.executor` for the record. |
|
|
72
|
+
| `wait` | Retry at `waitUntil`, or dispatch elsewhere. Only returned when you passed `--wait-minutes`. |
|
|
73
|
+
| `redeem` | Ask the user to redeem the reset credit in `redeemCandidate`, then plan again. |
|
|
74
|
+
| `refresh` | The usage snapshot is missing or stale. Re-run with `--t3-auto` / `--t3-origin`; when replaying a file, pass `--now` near its `observedAt`. |
|
|
75
|
+
| `pause` | Every candidate is blocked. Read `reasons`, retry at `nextCheckAt`, or tell the user. |
|
|
76
|
+
|
|
77
|
+
To record, copy `recommended.executor` (`provider`, `model`, `effort`, `tier`) into the record's `executor` and add `"site": "local"`. A candidate becomes `qualified` after 5 successful records with the same executor and task; until then it is `trial` and is never blocked.
|
|
78
|
+
|
|
79
|
+
## MCP server
|
|
80
|
+
|
|
81
|
+
Start command: `node <checkout>/bin/modelpace-mcp.mjs` (stdio; after an npm release: `npx -y -p modelpace modelpace-mcp`, because the package is `modelpace` and `modelpace-mcp` is only its second binary). Optional environment: `MODELPACE_AUTO=1`, `MODELPACE_CONFIG`, `MODELPACE_SCORES`, `MODELPACE_ORIGIN`, `MODELPACE_TOKEN`, `MODELPACE_SNAPSHOT`.
|
|
82
|
+
|
|
83
|
+
Register it with the client the user runs (use absolute paths):
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Claude Code
|
|
87
|
+
claude mcp add modelpace -- node /abs/path/modelpace/bin/modelpace-mcp.mjs
|
|
88
|
+
# Codex CLI
|
|
89
|
+
codex mcp add modelpace -- node /abs/path/modelpace/bin/modelpace-mcp.mjs
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
These leave quota access off (`dispatch_plan` then needs `snapshotPath` or `t3Origin`). Only after the user agrees to `--t3-auto`, add the variable: `claude mcp add modelpace -e MODELPACE_AUTO=1 -- node ...` or `codex mcp add modelpace --env MODELPACE_AUTO=1 -- node ...`.
|
|
93
|
+
|
|
94
|
+
Codex `~/.codex/config.toml` equivalent (the `env` table is the `--t3-auto` opt-in; leave it out until the user agrees):
|
|
95
|
+
|
|
96
|
+
```toml
|
|
97
|
+
[mcp_servers.modelpace]
|
|
98
|
+
command = "node"
|
|
99
|
+
args = ["/abs/path/modelpace/bin/modelpace-mcp.mjs"]
|
|
100
|
+
|
|
101
|
+
[mcp_servers.modelpace.env]
|
|
102
|
+
MODELPACE_AUTO = "1"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Any other MCP client: `{ "mcpServers": { "modelpace": { "command": "node", "args": ["/abs/path/modelpace/bin/modelpace-mcp.mjs"] } } }` (add `"env": { "MODELPACE_AUTO": "1" }` with the user's agreement).
|
|
106
|
+
|
|
107
|
+
Inside T3 Code there is no separate MCP setting for this: T3 Code starts Claude and Codex itself, and per the T3 Code source it loads Claude's user, project and local settings and Codex's `config.toml` (unless a provider instance is given its own home directory), so the registrations above are picked up. This was read from the source, not run; if the tools do not appear in a T3 Code session, check that instance's home setting.
|
|
108
|
+
|
|
109
|
+
| Tool | Arguments (all optional unless marked) | Returns |
|
|
110
|
+
| --- | --- | --- |
|
|
111
|
+
| `dispatch_plan` | `task`, `tier`, `slot`, `waitMinutes`, `claudeModel`, `configPath`, `scoresPath`, `t3Auto`, `t3Origin`, `snapshotPath`, `snapshot`, `budgetPath`, `includeSpeed`, `speedMetrics`, `days` | The plan object above |
|
|
112
|
+
| `dispatch_record` | `record` (required), `scoresPath`, `configPath` | `{ file, identity, task }` |
|
|
113
|
+
| `dispatch_scores` | `scoresPath`, `configPath` | Cells with pass rate, 90% interval, median duration, cost; ranking per task |
|
|
114
|
+
| `dispatch_speed` | `days`, `scoresPath`, `configPath` | `{ days, ranking, metrics, sources, warnings }` |
|
|
115
|
+
|
|
116
|
+
Failures come back as a tool result with `isError: true` and a message that says what to change.
|
|
117
|
+
|
|
118
|
+
## Data and privacy
|
|
119
|
+
|
|
120
|
+
- Network: only the T3 origin you give (`--t3-origin`) or the local T3 Code server found by `--t3-auto`. No telemetry.
|
|
121
|
+
- `--t3-auto` (or `MODELPACE_AUTO=1`) runs the local T3 CLI: `t3 auth session issue --scope orchestration:read --ttl 2m --label modelpace`, reads `server.getConfig`, then revokes the session. The token can only read orchestration state, not open terminals or write files, and lives at most 2 minutes. It is on only when you pass the flag or variable; ask the user before first use, or avoid it with `--snapshot FILE` or `--t3-origin URL` plus `MODELPACE_TOKEN`. Each `plan` issues one session; `serve --t3-auto` issues one every 15 seconds.
|
|
122
|
+
- Local files read: the config, snapshot and budget files you pass; the ledger; and, only for `speed`, `dashboard`, `serve`, `plan --speed-scan` and `includeSpeed`, session logs for timestamps, model names and token counts (`~/.claude/projects`, `~/.codex/sessions`, the OpenCode database, `~/.gemini/antigravity`; override with `MODELPACE_CLAUDE_DIR`, `MODELPACE_CODEX_DIR`, `MODELPACE_OPENCODE_DB`, `MODELPACE_ANTIGRAVITY_PATHS`).
|
|
123
|
+
- Local files written: the ledger (default `$XDG_DATA_HOME/modelpace/scores.jsonl`, i.e. `~/.local/share/modelpace/scores.jsonl`; `%LOCALAPPDATA%\modelpace\scores.jsonl` on Windows; mode 0600) and the speed cache (`~/.cache/modelpace/speed-cache.json`). Missing directories are created with mode 0700; existing ones are left alone.
|
|
124
|
+
- Credential files are never read. Prefer `MODELPACE_TOKEN` or `--t3-token-cmd` over `--t3-token`, which shows in the process list.
|
|
125
|
+
|
|
126
|
+
## Troubleshooting
|
|
127
|
+
|
|
128
|
+
| Message or symptom | Cause and fix |
|
|
129
|
+
| --- | --- |
|
|
130
|
+
| `Action: refresh` with `Snapshot is stale (age 133.5m)` | A saved snapshot is older than 15 minutes. Use `--t3-auto`, or add `--now <time near observedAt>` when replaying. |
|
|
131
|
+
| `Blocked <candidate> (unknown): Instance not found in snapshot.` | The config's `instanceId` does not exist in T3. Compare with the `instances` keys of the snapshot (`modelpace plan --format json` lists candidates), fix the config or use the built-in policy. |
|
|
132
|
+
| `plan needs a usage source: ...` | No quota source given. Add `--t3-auto`, `--t3-origin URL` with a token, or `--snapshot FILE`. |
|
|
133
|
+
| `Local T3 Code CLI not found (set MODELPACE_T3_BIN, or put t3 on PATH)` | `--t3-auto` cannot find the `t3` CLI. Set `MODELPACE_T3_BIN` to its path or add it to `PATH`. |
|
|
134
|
+
| `No running local T3 Code server found (start T3 Code, or pass an origin)` | T3 Code is not running (or `T3CODE_HOME` differs). Start it, or pass `--t3-origin`. |
|
|
135
|
+
| `Failed to issue a temporary T3 session via the local T3 CLI` | The `t3 auth session issue` call failed. Run it by hand to see why; an older T3 CLI may not support `--scope`. |
|
|
136
|
+
| `Failed to obtain WebSocket ticket` | The origin or token was rejected. Check the URL and that the token is current. |
|
|
137
|
+
| `Invalid dispatch record: missing record.<field>` | Records need all fifteen fields. Start from `examples/record.example.json`. |
|
|
138
|
+
| Candidate stays `trial` after recording | The record's `executor` differs from the plan's identity. Compare `recommended.scoreIdentity` with the identity printed by `scores`; copy `recommended.executor` exactly. |
|
|
139
|
+
| `Unknown dispatch slot "x"` / `Invalid tier "x"` | The name is not in the config. The message lists the valid values; omit `--slot` / `--tier` to use defaults. |
|
|
140
|
+
| `Cannot read FILE: ENOENT` | Wrong path. `modelpace init --out FILE` creates a config. |
|
|
141
|
+
|
|
142
|
+
## Developing this repository
|
|
143
|
+
|
|
144
|
+
- Pure Node.js ESM, zero runtime dependencies: only `node:*` built-ins, global `fetch` and `WebSocket`.
|
|
145
|
+
- Tests: `node --test test/*.test.mjs` (Node 22 or newer). A new behavior needs a test that fails without it. Commands in this file and in the READMEs that are preceded by `<!-- docs-test -->` are executed by `test/docs-commands.test.mjs`, so keep them runnable.
|
|
146
|
+
- Docs and CLI help are in English; `README.zh-CN.md` mirrors the README.
|
|
147
|
+
- Never commit credentials, tokens, personal paths or data from a real ledger or session logs.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
First public release (renamed from `t3-dispatch` to `modelpace`).
|
|
6
|
+
|
|
7
|
+
- `plan`: quota-gated dispatch recommendation with Even Pace, reset credits and quality × speed ranking; `--now ISO` replays a saved snapshot at a fixed instant.
|
|
8
|
+
- Built-in default policy for official T3 Code instance ids (`codex`, `claudeAgent`, `antigravity`); multi-account setups live in `examples/multi-account.config.json`.
|
|
9
|
+
- `record` / `scores`: JSONL acceptance ledger with Beta posterior pass rates; `plan` returns a ready-to-copy `recommended.executor`. Default ledger: `$XDG_DATA_HOME/modelpace/scores.jsonl`.
|
|
10
|
+
- `speed` / `dashboard` / `serve`: local Speed leaderboard from session logs and a self-contained HTML dashboard.
|
|
11
|
+
- `--t3-auto`: reads quota from the local T3 Code through a 2-minute `orchestration:read` session that is always revoked.
|
|
12
|
+
- Zero-dependency MCP server (`modelpace-mcp`) with `dispatch_plan`, `dispatch_record`, `dispatch_scores`, `dispatch_speed`.
|
|
13
|
+
- Agent entry points: `AGENTS.md` (install, validate/plan/record loop, MCP setup for Claude Code and Codex, privacy, troubleshooting), `llms.txt`, an Agent Skills `SKILL.md`, `examples/record.example.json`, MCP tool descriptions written for agents, and fix hints in CLI errors and `plan` reasons. Commands marked `<!-- docs-test -->` in the docs are executed by the tests.
|
|
14
|
+
- Experimental Agent Plugins package in `plugin/` (repository only, not in the npm package).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 jieyuexing
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,217 @@
|
|
|
1
|
-
#
|
|
1
|
+
# modelpace
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**for T3 Code**
|
|
4
|
+
|
|
5
|
+
> **Unofficial community tool** — not affiliated with or endorsed by T3 Tools Inc.
|
|
6
|
+
|
|
7
|
+
Zero-dependency (Node.js >= 22 ESM) multi-model dispatch, Even Pace quota pacing, reset-credit accounting, and Bayesian acceptance-scoring engine for **T3 Code**.
|
|
8
|
+
|
|
9
|
+
[中文文档](./README.zh-CN.md)
|
|
10
|
+
|
|
11
|
+
## What it does
|
|
12
|
+
|
|
13
|
+
Before an agent calls `delegate_task`, modelpace answers one question: *which provider instance and model should take this task right now?* It reads your live T3 Code quota (Even Pace, reset credits), prefers models that actually passed your earlier acceptance checks, and prints a ready-to-use target. It only advises; your agent still starts the work.
|
|
14
|
+
|
|
15
|
+
## Give this to your agent
|
|
16
|
+
|
|
17
|
+
Paste this into Claude Code, Codex, T3 Code or any coding agent:
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
Set up modelpace for me. Read AGENTS.md at https://github.com/jieyuexing/modelpace (or in the clone), clone the repo and check it works with the offline replay from AGENTS.md (in a scratch directory; never record the demo record into my real ledger), register its MCP server with this client, and then call dispatch_plan before every delegate_task and dispatch_record after I accept a result. Ask me before using --t3-auto.
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Agents can also start from [AGENTS.md](./AGENTS.md) (install, commands, MCP tools, privacy, troubleshooting), [llms.txt](./llms.txt) (index) and [skills/modelpace/SKILL.md](./skills/modelpace/SKILL.md).
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
Requires Node.js 22 or newer. There is nothing to build and no dependencies to install.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
git clone https://github.com/jieyuexing/modelpace.git
|
|
31
|
+
cd modelpace
|
|
32
|
+
node ./bin/modelpace.mjs --version
|
|
33
|
+
|
|
34
|
+
npx github:jieyuexing/modelpace --version
|
|
35
|
+
npx modelpace --version
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The examples below use the checkout form `node ./bin/modelpace.mjs`; replace it with `npx modelpace` if you installed from npm.
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
<!-- docs-test expect: Action: run -> codex -->
|
|
43
|
+
```bash
|
|
44
|
+
# Replay a saved snapshot at a fixed instant (--now keeps the example reproducible)
|
|
45
|
+
node ./bin/modelpace.mjs plan \
|
|
46
|
+
--snapshot examples/sample-snapshot.json \
|
|
47
|
+
--now 2026-11-23T07:05:00Z \
|
|
48
|
+
--task slice
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Output:
|
|
52
|
+
|
|
53
|
+
```text
|
|
54
|
+
Note: using the built-in default policy (official T3 Code instance ids). Pass --config FILE to use your own; "modelpace init" writes a starting point.
|
|
55
|
+
Action: run -> codex / gpt-5.3-codex (slot=worker, task=slice)
|
|
56
|
+
delegate_task target: {"providerInstanceId":"codex","model":"gpt-5.3-codex","options":{"reasoningEffort":"high"}}
|
|
57
|
+
- Selected codex-worker (codex/gpt-5.3-codex) for slot=worker, task=slice [quota=available, quality=trial].
|
|
58
|
+
Next check: 2026-11-23T07:15:00.000Z
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
A snapshot older than 15 minutes yields `Action: refresh`, so a saved file only works with `--now` set near its `observedAt`. Against a live T3 Code there is nothing to pin:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Zero-config: discover the local T3 Code (see "Connecting to T3 Code" below)
|
|
65
|
+
node ./bin/modelpace.mjs plan --t3-auto --task slice
|
|
66
|
+
|
|
67
|
+
# Or a T3 server you point at explicitly
|
|
68
|
+
node ./bin/modelpace.mjs plan --t3-origin http://127.0.0.1:3773 --t3-token "$T3_TOKEN" --task long
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Policy
|
|
72
|
+
|
|
73
|
+
Without `--config` (or `MODELPACE_CONFIG`) the built-in default policy is used, and `plan` says so in its text output. It targets the official T3 Code default instance ids `codex`, `claudeAgent` and `antigravity` — one instance per driver — with three slots (`worker`, `heavy`, `review`). Candidates whose instance is missing from the snapshot are skipped.
|
|
74
|
+
|
|
75
|
+
To change models, priorities, thresholds or to add more accounts (several Codex or Antigravity subscriptions, custom instance ids), start from the built-in policy or an example:
|
|
76
|
+
|
|
77
|
+
<!-- docs-test expect: Valid dispatch policy -->
|
|
78
|
+
```bash
|
|
79
|
+
node ./bin/modelpace.mjs init --out dispatch.config.json
|
|
80
|
+
node ./bin/modelpace.mjs validate --config dispatch.config.json
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`examples/multi-account.config.json` (with `examples/multi-account.snapshot.json`) shows a setup with two Antigravity subscriptions, a Codex and a Claude instance. Every field is documented in [docs/SCHEMA.md](./docs/SCHEMA.md).
|
|
84
|
+
|
|
85
|
+
### Recording outcomes
|
|
86
|
+
|
|
87
|
+
`plan` only recommends; the agent that calls `delegate_task` does the dispatching. After you have verified a result, record it so later plans can prefer models that actually pass:
|
|
88
|
+
|
|
89
|
+
<!-- docs-test expect: Recorded codex/gpt-5.3-codex/high/default/local -->
|
|
90
|
+
```bash
|
|
91
|
+
node ./bin/modelpace.mjs plan --snapshot examples/sample-snapshot.json --now 2026-11-23T07:05:00Z --task slice --format json
|
|
92
|
+
# copy decision.recommended.executor into a record and add "site"; examples/record.example.json is a complete template
|
|
93
|
+
node ./bin/modelpace.mjs record --json examples/record.example.json --scores demo-scores.jsonl
|
|
94
|
+
node ./bin/modelpace.mjs scores --scores demo-scores.jsonl
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The example record is fake and `demo-scores.jsonl` is a throwaway demo ledger: delete it afterwards, and without `--scores` records go to your real ledger (see below).
|
|
98
|
+
|
|
99
|
+
The ledger defaults to `$XDG_DATA_HOME/modelpace/scores.jsonl` (`~/.local/share/modelpace/scores.jsonl`; `%LOCALAPPDATA%\modelpace\scores.jsonl` on Windows). Override it with `--scores FILE` or `MODELPACE_SCORES`. `record` creates missing directories with mode 0700 and the ledger with mode 0600, and leaves existing directories untouched. Agents can follow [skills/modelpace/SKILL.md](./skills/modelpace/SKILL.md). A candidate becomes `qualified` after 5 successful records for the same executor identity and task; the record fields and the identity rules are in [docs/SCHEMA.md](./docs/SCHEMA.md#record-one-json-object-per-ledger-line).
|
|
100
|
+
|
|
101
|
+
### Connecting to T3 Code
|
|
102
|
+
|
|
103
|
+
`--t3-auto` runs the local T3 CLI (`t3 auth session issue --scope orchestration:read --ttl 2m --label modelpace`), reads `server.getConfig` with that token, and revokes the session in a `finally` step. The session lives at most 2 minutes and can only read orchestration state — it cannot open terminals or write files. It is opt-in per command (`--t3-auto` or `MODELPACE_AUTO=1`); leave it off and use `--snapshot` or `--t3-origin` with your own token if you prefer. Every `plan --t3-auto` issues one session. `dashboard` also scans local session logs for Speed, and `serve` re-runs the whole load every 15 seconds while its page is open, so `serve --t3-auto` issues and revokes a session every 15 seconds.
|
|
104
|
+
|
|
105
|
+
Prefer `MODELPACE_TOKEN` or `--t3-token-cmd` over `--t3-token`, which is visible in the process list.
|
|
106
|
+
|
|
107
|
+
## Features
|
|
108
|
+
|
|
109
|
+
- **Zero Runtime Dependencies**: Pure Node.js ESM (`>= 22.0.0`), using built-in `node:*`, `fetch`, and `WebSocket`. No `node_modules` needed.
|
|
110
|
+
- **Direct T3 WebSocket RPC Adapter**: Fetches live `server.getConfig` (`usageLimits` + `usageLimitSources`) from T3 Code via `/api/auth/websocket-ticket` and `/ws?orchestrationProtocol=2`. Supports an explicit bearer token or an external token command without ever reading credential cache files.
|
|
111
|
+
- **Multi-Provider `UsageSnapshot v2`**: Normalizes Codex, Claude, Gemini / Antigravity (multi-instance + `gemini`/`carbon`/`argon`/`3p` pool isolation), Grok, OpenCode, and optional pay-as-you-go API budgets.
|
|
112
|
+
- **Even Pace & Reset Credits**:
|
|
113
|
+
- Compares `effectiveRemainingPercent` against `remainingTimePercent` across weekly/long windows.
|
|
114
|
+
- Supports short-window burst caps (`shortWindowMaxUsedPercent`) and secondary-account overflow thresholds (`maxShortUsedPercent`).
|
|
115
|
+
- Accounts for Codex (`codexRateLimits`) and Claude (`claudeSession`, `claudeWeekly`, `claudeFable`, `claudeFull`) reset credits with near-reset skip logic.
|
|
116
|
+
- **Quality × Speed Fusion**:
|
|
117
|
+
- Exact Beta(1, 1) posterior pass rate and 90% credible intervals (Lanczos log-Gamma + continued fraction).
|
|
118
|
+
- Separates `qualified`, `trial` (cold start, never blocked), and `below_threshold` (`demote` / `strict` / `advisory`).
|
|
119
|
+
- Ranks qualified models by median successful duration ascending, with Speed `longRate` (tok/s) and Even Pace surplus tie-breaking.
|
|
120
|
+
- **Local Speed Leaderboard**: measures real output speed from your own session logs (Claude Code, Codex, OpenCode, plus a generic event format for Antigravity / Gemini). Sparse log-scale histograms (bin ratio 1.02, median error <= 1%), incremental cache, read-only. Feeds `plan` as a tie-breaker.
|
|
121
|
+
- **Zero-config T3 connection** (`--t3-auto`): discovers the local T3 Code, issues a 2-minute `orchestration:read` session through the official `auth session issue` CLI, reads `server.getConfig`, and always revokes the session. No credential file is read.
|
|
122
|
+
- **Self-contained dashboard**: one HTML file (no CDN, light/dark, EN/ZH) with Quota & Even Pace, a Speed leaderboard with a one-click Share Image (1200px @2x PNG), and acceptance scores with a dispatch audit.
|
|
123
|
+
- **CLI & Zero-Dependency MCP Server**:
|
|
124
|
+
- `modelpace` (`plan`, `record`, `scores`, `speed`, `dashboard`, `serve`, `validate`, `init`)
|
|
125
|
+
- `modelpace-mcp` (stdio JSON-RPC 2.0 MCP server exposing `dispatch_plan`, `dispatch_record`, `dispatch_scores`, `dispatch_speed`)
|
|
126
|
+
- **Experimental T3 plugin** (`plugin/`, repository only): see [T3 Plugin](#t3-plugin-experimental).
|
|
127
|
+
|
|
128
|
+
## Speed & Dashboard
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Local speed leaderboard (text | json | html)
|
|
132
|
+
node ./bin/modelpace.mjs speed --days 30
|
|
133
|
+
node ./bin/modelpace.mjs speed --format html --out speed.html
|
|
134
|
+
|
|
135
|
+
# Zero-config: plan against the local T3 Code and fold measured speed into the decision
|
|
136
|
+
node ./bin/modelpace.mjs plan --t3-auto --speed-scan --task slice
|
|
137
|
+
|
|
138
|
+
# One self-contained HTML dashboard, or a live one on localhost
|
|
139
|
+
node ./bin/modelpace.mjs dashboard --t3-auto --scores dispatch-scores.jsonl --out dashboard.html
|
|
140
|
+
node ./bin/modelpace.mjs serve --t3-auto --scores dispatch-scores.jsonl --port 8787
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Speed rules (per request): output tokens / wall time, counted only for >= 100 output tokens and 0.5 s < duration < 900 s. The headline number is the median tok/s of requests with >= 1000 output tokens; rows with fewer than 20 such requests are marked low-sample and excluded from `plan` tie-breaking. The Dispatch Pass column uses the same success formula as the acceptance scores.
|
|
144
|
+
|
|
145
|
+
Sources (all read-only, all paths overridable): `MODELPACE_CLAUDE_DIR` (default `~/.claude/projects`), `MODELPACE_CODEX_DIR` (`~/.codex/sessions`), `MODELPACE_OPENCODE_DB` (`~/.local/share/opencode/opencode.db`, needs `node:sqlite`), `MODELPACE_ANTIGRAVITY_PATHS` (default `~/.gemini/antigravity`; JSONL files or SQLite files with a `speed_events` table, one event `{ model, outputTokens, startedAt, endedAt }` per request). `MODELPACE_SPEED_CACHE` moves the incremental cache (default `~/.cache/modelpace/speed-cache.json`).
|
|
146
|
+
|
|
147
|
+
`--t3-auto` / `MODELPACE_AUTO=1` finds the T3 CLI via `MODELPACE_T3_BIN`, then `t3` on `PATH`, then the macOS app bundle with id `com.t3tools.t3code`; the server origin comes from the running server's `userdata/server-runtime.json` under `T3CODE_HOME` (default `~/.t3`) or `MODELPACE_ORIGIN`.
|
|
148
|
+
|
|
149
|
+
The dashboard is a pure function: `renderDashboardHtml({ decision, snapshot, scoresSummary, speedRanking, options })` returns the HTML string, so it also works inside T3 Code's `html_render`.
|
|
150
|
+
|
|
151
|
+
## T3 Plugin (experimental)
|
|
152
|
+
|
|
153
|
+
`plugin/` is an Agent Plugins 1.0 package. It only works in a T3 Code build that implements the plugin-host extension it declares (the `com.jieyuexing.t3code` extension namespace); the official T3 Code release has no plugin host, so the plugin does nothing there. It is not part of the npm package: use it from a checkout, because it reuses the engine in `../src`.
|
|
154
|
+
|
|
155
|
+
- view `dashboard` (side panel) — the same dashboard, refreshed through the host bridge;
|
|
156
|
+
- read-only services `dispatch.plan` (`run`), `dispatch.scores` (`get`), `dispatch.speed` (`get`), callable by agents;
|
|
157
|
+
- settings: local T3 connection, snapshot file, config, scores ledger, speed window.
|
|
158
|
+
|
|
159
|
+
## MCP Integration
|
|
160
|
+
|
|
161
|
+
The MCP server speaks stdio. Register it with the client your agent runs in, using an absolute path to the checkout (T3 Code launches Claude and Codex itself and, per its source, loads their normal settings — Claude's user, project and local scopes and Codex's `config.toml`, unless a provider instance has its own home directory — so there is no separate T3 Code MCP setting; this was read from the source, not run):
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Claude Code
|
|
165
|
+
claude mcp add modelpace -- node /absolute/path/to/modelpace/bin/modelpace-mcp.mjs
|
|
166
|
+
# Codex CLI
|
|
167
|
+
codex mcp add modelpace -- node /absolute/path/to/modelpace/bin/modelpace-mcp.mjs
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
These leave quota access off. To let the server read quota from the local T3 Code (a 2-minute `orchestration:read` session, see [Connecting to T3 Code](#connecting-to-t3-code)), add `-e MODELPACE_AUTO=1` after the name for Claude Code or `--env MODELPACE_AUTO=1` for Codex.
|
|
171
|
+
|
|
172
|
+
Codex `~/.codex/config.toml` (the `env` table opts into `--t3-auto`; omit it to keep quota access off):
|
|
173
|
+
|
|
174
|
+
```toml
|
|
175
|
+
[mcp_servers.modelpace]
|
|
176
|
+
command = "node"
|
|
177
|
+
args = ["/absolute/path/to/modelpace/bin/modelpace-mcp.mjs"]
|
|
178
|
+
|
|
179
|
+
[mcp_servers.modelpace.env]
|
|
180
|
+
MODELPACE_AUTO = "1"
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Any other MCP client (JSON; `MODELPACE_AUTO` is the `--t3-auto` opt-in, omit it to keep quota access off):
|
|
184
|
+
|
|
185
|
+
```json
|
|
186
|
+
{
|
|
187
|
+
"mcpServers": {
|
|
188
|
+
"modelpace": {
|
|
189
|
+
"command": "node",
|
|
190
|
+
"args": ["/absolute/path/to/modelpace/bin/modelpace-mcp.mjs"],
|
|
191
|
+
"env": {
|
|
192
|
+
"MODELPACE_CONFIG": "/path/to/dispatch.config.json",
|
|
193
|
+
"MODELPACE_SCORES": "/path/to/dispatch-scores.jsonl",
|
|
194
|
+
"MODELPACE_AUTO": "1"
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
After the npm release replace `node /absolute/path/.../modelpace-mcp.mjs` with `npx -y -p modelpace modelpace-mcp`: the package is `modelpace` and `modelpace-mcp` is its second binary, so plain `npx -y modelpace-mcp` would look for a different package. Config and ledger are optional (built-in policy and default ledger apply); drop `MODELPACE_AUTO` to keep quota access off.
|
|
202
|
+
|
|
203
|
+
Tools exposed:
|
|
204
|
+
- `dispatch_plan` — accepts `t3Auto` / `MODELPACE_AUTO=1` and `includeSpeed` (measures local Speed as a tie-breaker); returns `{ action, recommended: { target: { providerInstanceId, model, options }, executor, delegateReady }, waitUntil, nextCheckAt, reasons, candidates }`
|
|
205
|
+
- `dispatch_record` — validates and appends an acceptance record to JSONL
|
|
206
|
+
- `dispatch_scores` — returns ranked cells, Beta 90% intervals, median durations, and nominal costs
|
|
207
|
+
- `dispatch_speed` — returns the local speed ranking (`days`), the metrics map `plan` consumes, per-source scan counts and warnings
|
|
208
|
+
|
|
209
|
+
## Testing
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
node --test test/*.test.mjs
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## License
|
|
216
|
+
|
|
217
|
+
[MIT](./LICENSE)
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# modelpace
|
|
2
|
+
|
|
3
|
+
**for T3 Code**
|
|
4
|
+
|
|
5
|
+
> **非官方社区工具(Unofficial)** — 与 T3 Tools Inc. 无隶属或官方背书关系。
|
|
6
|
+
|
|
7
|
+
面向 **T3 Code** 的零运行时依赖(Node.js >= 22 ESM)多模型派发、Even Pace 均匀用量门控、重置卡计算与贝叶斯验收评分引擎。
|
|
8
|
+
|
|
9
|
+
[English README](./README.md)
|
|
10
|
+
|
|
11
|
+
## 它做什么
|
|
12
|
+
|
|
13
|
+
Agent 调用 `delegate_task` 之前,modelpace 回答一个问题:*现在这个任务该交给哪个供应商实例和模型?* 它读取你 T3 Code 的实时额度(Even Pace、重置卡),优先选在你历史验收里真正通过的模型,并打印可直接使用的目标。它只给建议,真正开工的还是你的 Agent。
|
|
14
|
+
|
|
15
|
+
## 交给你的 Agent
|
|
16
|
+
|
|
17
|
+
把下面这段粘给 Claude Code、Codex、T3 Code 或任何 coding agent:
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
帮我装好 modelpace。先读 https://github.com/jieyuexing/modelpace 的 AGENTS.md(或克隆后的本地副本),克隆仓库并用 AGENTS.md 里的离线回放确认能跑(在临时目录里跑,演示记录不要写进我真正的账本),把它的 MCP Server 注册到当前客户端;之后每次 delegate_task 前调用 dispatch_plan,我验收通过后调用 dispatch_record。用 --t3-auto 之前先问我。
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Agent 也可以直接从 [AGENTS.md](./AGENTS.md)(安装、命令、MCP 工具、隐私、排错,英文)、[llms.txt](./llms.txt)(索引)和 [skills/modelpace/SKILL.md](./skills/modelpace/SKILL.md) 开始。
|
|
24
|
+
|
|
25
|
+
## 安装
|
|
26
|
+
|
|
27
|
+
需要 Node.js 22 及以上,无需构建,也没有依赖要装。
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
git clone https://github.com/jieyuexing/modelpace.git
|
|
31
|
+
cd modelpace
|
|
32
|
+
node ./bin/modelpace.mjs --version
|
|
33
|
+
|
|
34
|
+
npx github:jieyuexing/modelpace --version
|
|
35
|
+
npx modelpace --version
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
下文示例都用检出目录的写法 `node ./bin/modelpace.mjs`;从 npm 安装时换成 `npx modelpace`。
|
|
39
|
+
|
|
40
|
+
## 快速开始
|
|
41
|
+
|
|
42
|
+
<!-- docs-test expect: 建议动作: run -->
|
|
43
|
+
```bash
|
|
44
|
+
# 用固定时刻回放一份已保存的快照(--now 让示例可复现)
|
|
45
|
+
node ./bin/modelpace.mjs plan \
|
|
46
|
+
--snapshot examples/sample-snapshot.json \
|
|
47
|
+
--now 2026-11-23T07:05:00Z \
|
|
48
|
+
--task slice \
|
|
49
|
+
--lang zh
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
快照超过 15 分钟会得到 `refresh`,所以保存的文件只有在 `--now` 接近其 `observedAt` 时才有意义。连实时的 T3 Code 则无需固定时间:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# 零配置:自动发现本机 T3 Code(见下文「连接 T3 Code」)
|
|
56
|
+
node ./bin/modelpace.mjs plan --t3-auto --task slice
|
|
57
|
+
|
|
58
|
+
# 或显式指定 T3 服务
|
|
59
|
+
node ./bin/modelpace.mjs plan --t3-origin http://127.0.0.1:3773 --t3-token "$T3_TOKEN" --task long
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 策略
|
|
63
|
+
|
|
64
|
+
不传 `--config`(也没有 `MODELPACE_CONFIG`)时使用内置默认策略,`plan` 的文本输出会明确提示。它面向官方 T3 Code 的默认实例 id `codex`、`claudeAgent`、`antigravity`(一种 driver 一个实例),有 `worker`、`heavy`、`review` 三个槽位;快照里没有的实例对应的候选会被跳过。
|
|
65
|
+
|
|
66
|
+
要调整模型、优先级、阈值,或加入多个账号(多个 Codex / Antigravity 订阅、自定义实例 id),从内置策略或示例出发:
|
|
67
|
+
|
|
68
|
+
<!-- docs-test expect: Valid dispatch policy -->
|
|
69
|
+
```bash
|
|
70
|
+
node ./bin/modelpace.mjs init --out dispatch.config.json
|
|
71
|
+
node ./bin/modelpace.mjs validate --config dispatch.config.json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`examples/multi-account.config.json`(配 `examples/multi-account.snapshot.json`)演示了双 Antigravity 订阅加 Codex、Claude 的组合。全部字段见 [docs/SCHEMA.md](./docs/SCHEMA.md)(英文)。
|
|
75
|
+
|
|
76
|
+
### 记录验收结果
|
|
77
|
+
|
|
78
|
+
`plan` 只给建议,真正派发的是调用 `delegate_task` 的 Agent。独立验证结果之后再记录,之后的 `plan` 才会偏向真正通过的模型:
|
|
79
|
+
|
|
80
|
+
<!-- docs-test expect: Recorded codex/gpt-5.3-codex/high/default/local -->
|
|
81
|
+
```bash
|
|
82
|
+
node ./bin/modelpace.mjs plan --snapshot examples/sample-snapshot.json --now 2026-11-23T07:05:00Z --task slice --format json
|
|
83
|
+
# 把 decision.recommended.executor 抄进记录并补上 "site";examples/record.example.json 是完整模板
|
|
84
|
+
node ./bin/modelpace.mjs record --json examples/record.example.json --scores demo-scores.jsonl
|
|
85
|
+
node ./bin/modelpace.mjs scores --scores demo-scores.jsonl
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
示例记录是假的,`demo-scores.jsonl` 只是演示用账本,用完请删除;不带 `--scores` 时记录会写进你真正的账本(见下)。
|
|
89
|
+
|
|
90
|
+
账本默认在 `$XDG_DATA_HOME/modelpace/scores.jsonl`(`~/.local/share/modelpace/scores.jsonl`;Windows 为 `%LOCALAPPDATA%\modelpace\scores.jsonl`),可用 `--scores FILE` 或 `MODELPACE_SCORES` 改。`record` 新建缺失目录时权限为 0700、账本文件 0600,不改已存在目录的权限。Agent 可参照 [skills/modelpace/SKILL.md](./skills/modelpace/SKILL.md)。同一执行身份、同一任务有 5 条成功记录后,候选变为 `qualified`;记录字段与身份规则见 [docs/SCHEMA.md](./docs/SCHEMA.md)。
|
|
91
|
+
|
|
92
|
+
### 连接 T3 Code
|
|
93
|
+
|
|
94
|
+
`--t3-auto` 会运行本机 T3 CLI(`t3 auth session issue --scope orchestration:read --ttl 2m --label modelpace`),用该令牌读取 `server.getConfig`,并在 `finally` 中吊销会话。会话最长 2 分钟,只能读取编排状态,不能开终端或写文件。它按命令显式开启(`--t3-auto` 或 `MODELPACE_AUTO=1`);不想用就改用 `--snapshot`,或 `--t3-origin` 加自己的令牌。每次 `plan --t3-auto` 签发一次会话;`dashboard` 还会扫描本机会话日志算 Speed;`serve` 在页面打开期间每 15 秒重跑一遍完整加载,所以 `serve --t3-auto` 每 15 秒签发并吊销一次会话。
|
|
95
|
+
|
|
96
|
+
令牌建议走 `MODELPACE_TOKEN` 或 `--t3-token-cmd`,不要用命令行参数 `--t3-token`(进程列表可见)。
|
|
97
|
+
|
|
98
|
+
## 核心特性
|
|
99
|
+
|
|
100
|
+
- **零外部运行时依赖**:纯 Node.js ESM(`>= 22.0.0`),仅使用内置 `node:*`、全局 `fetch` 与 `WebSocket`,无需 `node_modules`。
|
|
101
|
+
- **直连 T3 WebSocket RPC**:通过 `/api/auth/websocket-ticket` 与 `/ws?orchestrationProtocol=2` 实时拉取 `server.getConfig`(`usageLimits` 与 `usageLimitSources`),支持显式 `bearer` 或外部 `tokenCommand`,绝不直接读取任何凭据缓存文件。
|
|
102
|
+
- **统一快照 `UsageSnapshot v2`**:规整 Codex、Claude、Gemini / Antigravity(多实例及 `gemini`/`carbon`/`argon`/`3p` 池隔离)、Grok、OpenCode 与按量付费 API 预算。
|
|
103
|
+
- **Even Pace 与重置卡门控**:
|
|
104
|
+
- 长周期窗口对比 `effectiveRemainingPercent` 与 `remainingTimePercent`。
|
|
105
|
+
- 支持短窗突发上限(`shortWindowMaxUsedPercent`)与副号泄洪阈值(`maxShortUsedPercent`)。
|
|
106
|
+
- 支持 Codex(`codexRateLimits`)与 Claude(`claudeSession`、`claudeWeekly`、`claudeFable`、`claudeFull`)重置卡覆盖、持卡节奏与临近自然重置跳过逻辑。
|
|
107
|
+
- **质量 × 速度融合排序**:
|
|
108
|
+
- 精确 Beta(1, 1) 后验通过率与 90% 置信区间(Lanczos log-Gamma + 续分数)。
|
|
109
|
+
- 区分 `qualified`、`trial`(冷启动不拦截)与 `below_threshold`(支持 `demote` / `strict` / `advisory`)。
|
|
110
|
+
- 达标模型按成功任务耗时中位数升序,在容差范围内按 Speed `longRate`(tok/s)与 Even Pace 富余度决胜。
|
|
111
|
+
- **本机 Speed 排行**:只读解析自己的会话日志(Claude Code、Codex、OpenCode,以及 Antigravity / Gemini 的通用事件格式)测出真实输出速度;稀疏对数直方图(桶比 1.02,中位数误差 ≤ 1%)、增量缓存,并作为 `plan` 的决胜因子。
|
|
112
|
+
- **零配置连接 T3**(`--t3-auto`):自动发现本机 T3 Code,经官方 `auth session issue` 签发 2 分钟、仅含 `orchestration:read` 的会话,读取 `server.getConfig` 后必定吊销;不读取任何凭据文件。
|
|
113
|
+
- **自包含仪表盘**:单文件 HTML(无 CDN、明暗主题、EN/ZH 切换),含额度与 Even Pace、速度排行及一键分享图(1200px @2x PNG)、验收评分与派发审计。
|
|
114
|
+
- **CLI 与零依赖 MCP Server**:
|
|
115
|
+
- `modelpace`(`plan`、`record`、`scores`、`speed`、`dashboard`、`serve`、`validate`、`init`,支持 `--lang en|zh` 与 `--format`)
|
|
116
|
+
- `modelpace-mcp`(标准 stdio JSON-RPC 2.0 MCP Server,提供 `dispatch_plan`、`dispatch_record`、`dispatch_scores`、`dispatch_speed`)
|
|
117
|
+
- **实验性 T3 插件**(`plugin/`,仅在仓库内):见下文「T3 插件」。
|
|
118
|
+
|
|
119
|
+
## Speed 与仪表盘
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# 本机速度排行(text | json | html)
|
|
123
|
+
node ./bin/modelpace.mjs speed --days 30
|
|
124
|
+
node ./bin/modelpace.mjs speed --format html --out speed.html
|
|
125
|
+
|
|
126
|
+
# 零配置:连本机 T3 规划,并把实测速度并入决策
|
|
127
|
+
node ./bin/modelpace.mjs plan --t3-auto --speed-scan --task slice
|
|
128
|
+
|
|
129
|
+
# 自包含 HTML 仪表盘,或本机实时服务
|
|
130
|
+
node ./bin/modelpace.mjs dashboard --t3-auto --scores dispatch-scores.jsonl --out dashboard.html
|
|
131
|
+
node ./bin/modelpace.mjs serve --t3-auto --scores dispatch-scores.jsonl --port 8787
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
口径(单次请求):输出 token ÷ 墙钟耗时,仅统计输出 ≥ 100 token 且 0.5 秒 < 耗时 < 900 秒的请求。主指标是输出 ≥ 1000 token 请求的 tok/s 中位数;长请求少于 20 次的行标「样本少」,不参与 `plan` 决胜。「派发通过」列与验收评分共用同一成功公式。
|
|
135
|
+
|
|
136
|
+
数据源(全部只读、路径均可覆盖):`MODELPACE_CLAUDE_DIR`(默认 `~/.claude/projects`)、`MODELPACE_CODEX_DIR`(`~/.codex/sessions`)、`MODELPACE_OPENCODE_DB`(`~/.local/share/opencode/opencode.db`,需要 `node:sqlite`)、`MODELPACE_ANTIGRAVITY_PATHS`(默认 `~/.gemini/antigravity`,JSONL 文件或含 `speed_events` 表的 SQLite,每请求一条 `{ model, outputTokens, startedAt, endedAt }`)。`MODELPACE_SPEED_CACHE` 指定增量缓存位置(默认 `~/.cache/modelpace/speed-cache.json`)。
|
|
137
|
+
|
|
138
|
+
`--t3-auto` / `MODELPACE_AUTO=1` 依次找 `MODELPACE_T3_BIN`、`PATH` 中的 `t3`、macOS 上 bundle id 为 `com.t3tools.t3code` 的应用;服务 origin 取自 `T3CODE_HOME`(默认 `~/.t3`)下运行中服务的 `userdata/server-runtime.json`,或 `MODELPACE_ORIGIN`。
|
|
139
|
+
|
|
140
|
+
仪表盘是纯函数:`renderDashboardHtml({ decision, snapshot, scoresSummary, speedRanking, options })` 返回 HTML 字符串,也可直接用于 T3 Code 的 `html_render`。
|
|
141
|
+
|
|
142
|
+
## T3 插件(实验性)
|
|
143
|
+
|
|
144
|
+
`plugin/` 是 Agent Plugins 1.0 包,只适用于实现了它所声明的插件宿主扩展(扩展命名空间 `com.jieyuexing.t3code`)的 T3 Code 构建;官方 T3 Code 发行版没有插件宿主,装了也不起作用。它不在 npm 包里,需从检出目录使用(复用 `../src` 的引擎):侧栏视图 `dashboard`、只读服务 `dispatch.plan`、`dispatch.scores`、`dispatch.speed`,以及本机 T3 连接、快照、配置、评分文件、速度窗口等设置项。
|
|
145
|
+
|
|
146
|
+
## MCP 集成
|
|
147
|
+
|
|
148
|
+
MCP Server 走 stdio。在你的 Agent 所用的客户端里注册,路径写检出目录的绝对路径(T3 Code 自己拉起 Claude 和 Codex,并且按其源码会加载它们的常规设置——Claude 的 user、project、local 三级设置与 Codex 的 `config.toml`,除非某个供应商实例单独指定了 home 目录——所以没有单独的 T3 Code MCP 设置;这是读源码得出的,没有实际运行):
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Claude Code
|
|
152
|
+
claude mcp add modelpace -- node /absolute/path/to/modelpace/bin/modelpace-mcp.mjs
|
|
153
|
+
# Codex CLI
|
|
154
|
+
codex mcp add modelpace -- node /absolute/path/to/modelpace/bin/modelpace-mcp.mjs
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
以上默认不访问额度。要让服务读取本机 T3 Code 的额度(2 分钟、仅 `orchestration:read` 的会话,见「连接 T3 Code」),Claude Code 在名字后加 `-e MODELPACE_AUTO=1`,Codex 加 `--env MODELPACE_AUTO=1`。
|
|
158
|
+
|
|
159
|
+
Codex 的 `~/.codex/config.toml`(`env` 表即开启 `--t3-auto`,不想访问额度就删掉):
|
|
160
|
+
|
|
161
|
+
```toml
|
|
162
|
+
[mcp_servers.modelpace]
|
|
163
|
+
command = "node"
|
|
164
|
+
args = ["/absolute/path/to/modelpace/bin/modelpace-mcp.mjs"]
|
|
165
|
+
|
|
166
|
+
[mcp_servers.modelpace.env]
|
|
167
|
+
MODELPACE_AUTO = "1"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
其他 MCP 客户端(JSON;`MODELPACE_AUTO` 即开启 `--t3-auto`,不想访问额度就删掉):
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"mcpServers": {
|
|
175
|
+
"modelpace": {
|
|
176
|
+
"command": "node",
|
|
177
|
+
"args": ["/absolute/path/to/modelpace/bin/modelpace-mcp.mjs"],
|
|
178
|
+
"env": {
|
|
179
|
+
"MODELPACE_CONFIG": "/path/to/dispatch.config.json",
|
|
180
|
+
"MODELPACE_SCORES": "/path/to/dispatch-scores.jsonl",
|
|
181
|
+
"MODELPACE_AUTO": "1"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
发布到 npm 后,把 `node /absolute/path/.../modelpace-mcp.mjs` 换成 `npx -y -p modelpace modelpace-mcp`:包名是 `modelpace`,`modelpace-mcp` 只是它的第二个可执行名,直接写 `npx -y modelpace-mcp` 会去找另一个包。配置与账本都可省略(用内置策略与默认账本);去掉 `MODELPACE_AUTO` 即不访问额度。提供的工具:`dispatch_plan`、`dispatch_record`、`dispatch_scores`、`dispatch_speed`,入参与返回见 [AGENTS.md](./AGENTS.md)。
|
|
189
|
+
|
|
190
|
+
## 运行测试
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
node --test test/*.test.mjs
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## 许可证
|
|
197
|
+
|
|
198
|
+
[MIT](./LICENSE)
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
## Reporting a vulnerability
|
|
4
|
+
|
|
5
|
+
Please report vulnerabilities privately through GitHub's "Report a vulnerability" button on the repository's Security tab (private vulnerability reporting), not in a public issue. Include the version, a description and, if possible, a reproduction. You can expect an acknowledgement within a week.
|
|
6
|
+
|
|
7
|
+
## What modelpace touches
|
|
8
|
+
|
|
9
|
+
- It connects only to the T3 Code origin you configure (or the local server found by `--t3-auto`); there is no telemetry.
|
|
10
|
+
- `--t3-auto` asks the local T3 CLI for a 2-minute session limited to `orchestration:read` and revokes it afterwards. It never reads credential or auth cache files.
|
|
11
|
+
- It reads session logs of local agent tools for timestamps, model names and token counts, and writes only the speed cache and the acceptance ledger (mode 0600).
|
|
12
|
+
- Prefer `MODELPACE_TOKEN` or `--t3-token-cmd` over `--t3-token`, which is visible in the process list.
|
|
13
|
+
|
|
14
|
+
## Supported versions
|
|
15
|
+
|
|
16
|
+
Only the latest release receives fixes.
|