t3-auto-build 2.0.0 → 2.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/CHANGELOG.md +19 -0
- package/README.md +22 -5
- package/bin/cli.mjs +10 -3
- package/hooks/_quota.mjs +12 -2
- package/hooks/_shared.mjs +3 -0
- package/lib/discover.mjs +95 -13
- package/lib/plans.mjs +17 -8
- package/lib/probe.mjs +1 -1
- package/lib/quota.mjs +8 -6
- package/package.json +1 -1
- package/skills/auto-build/SKILL.md.tmpl +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,24 @@ All notable changes to this project are documented here. The format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
|
|
5
5
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [2.0.1] - 2026-11-26
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `check-models` prints one `provider:model status` line per configured model.
|
|
12
|
+
- Lock rechecks: locks longer than 6 hours carry `setAt` and `recheckAfter`. Due provider locks are
|
|
13
|
+
probed (Claude, Codex) or reported as `recheck-via-t3` for a canary delegation. New
|
|
14
|
+
`check-models --recheck-locks`.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Codex `free` and `go` are CLI tiers with `gpt-6-luna`, `gpt-5.6-terra` and `gpt-5.6-luna`, one
|
|
19
|
+
parallel builder and no warning.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- `quota clear` accepts `provider:<provider>`.
|
|
24
|
+
|
|
7
25
|
## [2.0.0] - 2026-11-26
|
|
8
26
|
|
|
9
27
|
### Added
|
|
@@ -91,6 +109,7 @@ See [Migrating from v1](README.md#migrating-from-v1).
|
|
|
91
109
|
- Hardened the recursive `rm` guard, cooldown handling, the pre-compact state boundary and
|
|
92
110
|
`sync-models --force`.
|
|
93
111
|
|
|
112
|
+
[2.0.1]: https://github.com/mirceas94/t3-auto-build/compare/v2.0.0...v2.0.1
|
|
94
113
|
[2.0.0]: https://github.com/mirceas94/t3-auto-build/compare/v1.0.1...v2.0.0
|
|
95
114
|
[1.0.1]: https://github.com/mirceas94/t3-auto-build/compare/v1.0.0...v1.0.1
|
|
96
115
|
[1.0.0]: https://github.com/mirceas94/t3-auto-build/releases/tag/v1.0.0
|
package/README.md
CHANGED
|
@@ -84,8 +84,8 @@ v1 config. At least one provider needs a CLI-capable tier.
|
|
|
84
84
|
| claude | `team-premium` | yes | `claude-haiku-5-5`, `claude-sonnet-5-5`, `claude-opus-5-5` | – | 2 | – |
|
|
85
85
|
| claude | `api` | yes | `claude-haiku-5-5`, `claude-sonnet-5-5`, `claude-opus-5-5` | `claude-fable-5-2` | 3 | API usage is billed per token |
|
|
86
86
|
| codex | `none` | no | – | – | 0 | no Codex subscription selected |
|
|
87
|
-
| codex | `free` |
|
|
88
|
-
| codex | `go` |
|
|
87
|
+
| codex | `free` | yes | `gpt-6-luna`, `gpt-5.6-terra`, `gpt-5.6-luna` | – | 1 | – |
|
|
88
|
+
| codex | `go` | yes | `gpt-6-luna`, `gpt-5.6-terra`, `gpt-5.6-luna` | – | 1 | – |
|
|
89
89
|
| codex | `plus` | yes | `gpt-6-luna`, `gpt-6.1-terra` | – | 1 | – |
|
|
90
90
|
| codex | `pro-100` | yes | `gpt-6-luna`, `gpt-6.1-terra`, `gpt-6.1-sol` | `gpt-6-astra` | 2 | – |
|
|
91
91
|
| codex | `pro-200` | yes | `gpt-6-luna`, `gpt-6.1-terra`, `gpt-6.1-sol` | `gpt-6-astra` | 2 | – |
|
|
@@ -153,6 +153,22 @@ The skill runs `t3-auto-build check-models` at the start of every run. Results g
|
|
|
153
153
|
- A live manual mark beats discovery and probe results. Its `--ttl` is one number plus `m`, `h` or
|
|
154
154
|
`d`, above zero and at most `30d` (default `24h`).
|
|
155
155
|
- Antigravity has no probe support.
|
|
156
|
+
- After its summary line, `check-models` prints one `provider:model status` line per configured model:
|
|
157
|
+
`available` (nothing speaks against it), `rate-limited` (locked or limited), `plan-restricted`,
|
|
158
|
+
`unavailable` or `skipped-scarce`.
|
|
159
|
+
|
|
160
|
+
### Lock rechecks
|
|
161
|
+
|
|
162
|
+
A lock lasting more than 6 hours gets `setAt` and `recheckAfter` (6 hours later). Once a provider lock
|
|
163
|
+
is past `recheckAfter`, or for every provider lock with `--recheck-locks`, `check-models` tests the
|
|
164
|
+
cheapest configured standard model:
|
|
165
|
+
|
|
166
|
+
- With a Claude or Codex CLI installed, it sends one probe. Success clears the lock; any other result
|
|
167
|
+
moves `recheckAfter` 6 hours ahead.
|
|
168
|
+
- Otherwise (such as Antigravity) it prints `recheck-via-t3: <provider> (<model>)`. The skill then
|
|
169
|
+
clears the lock, sends a one-word canary `delegate_task`, and re-locks only on a rate limit.
|
|
170
|
+
|
|
171
|
+
Model and pool locks are not rechecked.
|
|
156
172
|
|
|
157
173
|
```sh
|
|
158
174
|
t3-auto-build availability mark antigravity:claude-opus-5-5 plan-restricted --ttl 24h --reason "not in plan"
|
|
@@ -263,7 +279,7 @@ resume later.
|
|
|
263
279
|
```text
|
|
264
280
|
t3-auto-build init
|
|
265
281
|
t3-auto-build upgrade [--yes]
|
|
266
|
-
t3-auto-build check-models [--refresh] [--probe-scarce] [--json]
|
|
282
|
+
t3-auto-build check-models [--refresh] [--probe-scarce] [--recheck-locks] [--json]
|
|
267
283
|
t3-auto-build sync-models [--auto] [--refresh] [--probe-scarce] [--apply]
|
|
268
284
|
t3-auto-build availability mark <provider:model> <available|plan-restricted|unavailable> [--ttl 24h] [--reason <text>]
|
|
269
285
|
t3-auto-build availability status
|
|
@@ -307,6 +323,7 @@ t3-auto-build uninstall
|
|
|
307
323
|
| `--force` | init, sync-models | Back up your changed files to `<file>.bak`, then overwrite. For `sync-models`, this covers a hand-edited `SKILL.md`. |
|
|
308
324
|
| `--refresh` | check-models, sync-models | Ignore the probe cache TTL. `sync-models` without `--apply` always probes. |
|
|
309
325
|
| `--probe-scarce` | check-models, sync-models | Also probe scarce-pool models. |
|
|
326
|
+
| `--recheck-locks` | check-models | Recheck every active provider lock now. |
|
|
310
327
|
| `--json` | check-models | Machine-readable result. |
|
|
311
328
|
| `--auto` | sync-models | Write without confirmation, like `--yes`. |
|
|
312
329
|
| `--apply` | sync-models | Promote newer versions from recorded drift. |
|
|
@@ -454,7 +471,7 @@ t3-auto-build quota check [provider]
|
|
|
454
471
|
pool.
|
|
455
472
|
- Reset times parsed from rate-limit messages are capped at 14 days. A manual `--until` is not capped.
|
|
456
473
|
- `status` drops expired locks and prints the rest.
|
|
457
|
-
- `clear <provider>` removes its provider and pool locks, not its model locks. `clear <model>`
|
|
474
|
+
- `clear <provider>` (or `clear provider:<provider>`) removes its provider and pool locks, not its model locks. `clear <model>`
|
|
458
475
|
removes that model's lock. `--all` deletes the file, even a corrupt one.
|
|
459
476
|
- `check` runs `claude auth status` and `codex login status` (Antigravity has no status command). It
|
|
460
477
|
reports login state only, unless the output explicitly says usage is exhausted; only then does it
|
|
@@ -487,7 +504,7 @@ Legacy `tier:<p>:heavy` keys are still read, and `quota check` or a probe may st
|
|
|
487
504
|
```
|
|
488
505
|
|
|
489
506
|
`scope` is `model`, `provider` or `tier`. `window` is `burst`, `5h`, `weekly` or `custom`. Legacy
|
|
490
|
-
`until_utc` is read. A key without a prefix needs a `scope` field, or it locks nothing. A malformed
|
|
507
|
+
`until_utc` is read. Long locks also carry `setAt` and `recheckAfter` (see [lock rechecks](#lock-rechecks)). A key without a prefix needs a `scope` field, or it locks nothing. A malformed
|
|
491
508
|
entry (such as one without a valid time) is skipped with a warning and kept in the file until it is
|
|
492
509
|
overwritten or cleared (`quota clear <name>` or `--all`). A file that is not a JSON object is
|
|
493
510
|
unreadable: hooks warn and ignore it. A write that leaves no entries removes the file.
|
package/bin/cli.mjs
CHANGED
|
@@ -51,6 +51,7 @@ init only:
|
|
|
51
51
|
check-models only:
|
|
52
52
|
--refresh ignore the probe cache TTL
|
|
53
53
|
--probe-scarce also probe scarce quota models
|
|
54
|
+
--recheck-locks retest every active provider lock now
|
|
54
55
|
--json print machine-readable results
|
|
55
56
|
|
|
56
57
|
sync-models only:
|
|
@@ -82,11 +83,11 @@ Examples:
|
|
|
82
83
|
Overflow to cross-hosted models requires an explicit provider, e.g. antigravity:claude-opus-5-5.`;
|
|
83
84
|
|
|
84
85
|
const VALUE_FLAGS = ['target', 'preset', 'modules', 'compaction', 'tiers', 'providers', 'until', 'reason', 'parent', 'claude-tier', 'codex-tier', 'antigravity-tier', 'ttl', 'pool'];
|
|
85
|
-
const SWITCHES = ['yes', 'force', 'help', 'version', 'probe', 'dry-run', 'all', 'auto', 'refresh', 'probe-scarce', 'apply', 'json', 'allow-usage-credits', 'allow-fast-modes', 'verified-org', ...QUOTA_WINDOWS];
|
|
86
|
+
const SWITCHES = ['yes', 'force', 'help', 'version', 'probe', 'dry-run', 'all', 'auto', 'refresh', 'probe-scarce', 'recheck-locks', 'apply', 'json', 'allow-usage-credits', 'allow-fast-modes', 'verified-org', ...QUOTA_WINDOWS];
|
|
86
87
|
const COMMAND_FLAGS = {
|
|
87
88
|
init: ['preset', 'modules', 'compaction', 'tiers', 'probe', 'yes', 'force', ...Object.values(TIER_FLAGS).map((f) => f.slice(2)), 'parent', 'allow-usage-credits', 'allow-fast-modes', 'verified-org'],
|
|
88
89
|
upgrade: ['yes'], doctor: [], uninstall: [],
|
|
89
|
-
'check-models': ['refresh', 'probe-scarce', 'json'],
|
|
90
|
+
'check-models': ['refresh', 'probe-scarce', 'recheck-locks', 'json'],
|
|
90
91
|
'sync-models': ['dry-run', 'providers', 'yes', 'auto', 'force', 'refresh', 'probe-scarce', 'apply'],
|
|
91
92
|
'availability mark': ['ttl', 'reason'], 'availability status': [],
|
|
92
93
|
'quota set': [...QUOTA_WINDOWS, 'until', 'reason', 'pool'],
|
|
@@ -185,10 +186,16 @@ async function init(target, flags) {
|
|
|
185
186
|
|
|
186
187
|
async function check(target, flags) {
|
|
187
188
|
const config = rawConfig(target);
|
|
188
|
-
const result = await checkModels({
|
|
189
|
+
const result = await checkModels({
|
|
190
|
+
configDir: target, config, refresh: flags.refresh, probeScarce: flags['probe-scarce'], recheckLocks: flags['recheck-locks'],
|
|
191
|
+
});
|
|
189
192
|
if (flags.json) console.log(JSON.stringify(result, null, 2));
|
|
190
193
|
else {
|
|
191
194
|
console.log(`availability ${result.stale ? 'stale' : 'fresh'}; probed ${result.probed.length}; skipped scarce ${result.skippedScarce.length}`);
|
|
195
|
+
for (const { ref, status } of result.statuses) console.log(`${ref} ${status}`);
|
|
196
|
+
for (const { key, provider, model, result: outcome } of result.rechecked) {
|
|
197
|
+
console.log(outcome === 'via-t3' ? `recheck-via-t3: ${provider} (${model})` : `rechecked ${key} with ${model}: ${outcome}`);
|
|
198
|
+
}
|
|
192
199
|
for (const entry of result.availability.discoveredNew ?? []) console.log(`discovered ${entry.provider}:${entry.model}${entry.supersedes ? ` supersedes ${entry.supersedes}` : ' (unknown family)'}`);
|
|
193
200
|
}
|
|
194
201
|
}
|
package/hooks/_quota.mjs
CHANGED
|
@@ -10,6 +10,15 @@ const MINUTE = 60_000;
|
|
|
10
10
|
const DAY = 24 * 60 * MINUTE;
|
|
11
11
|
// A parsed reset time comes from message text, so it can never lock for longer than this.
|
|
12
12
|
const MAX_LOCK = 14 * DAY;
|
|
13
|
+
export const RECHECK_AFTER = 360 * MINUTE;
|
|
14
|
+
|
|
15
|
+
/** A lock lasting more than RECHECK_AFTER past setAt gets a recheckAfter time; others are returned unchanged. */
|
|
16
|
+
export function withRecheck(entry, now = Date.now()) {
|
|
17
|
+
if (!Number.isNaN(Date.parse(entry.recheckAfter))) return entry;
|
|
18
|
+
const setAt = Date.parse(entry.setAt) || now;
|
|
19
|
+
if (!(Date.parse(entry.until) - setAt > RECHECK_AFTER)) return entry;
|
|
20
|
+
return { ...entry, setAt: new Date(setAt).toISOString(), recheckAfter: new Date(setAt + RECHECK_AFTER).toISOString() };
|
|
21
|
+
}
|
|
13
22
|
|
|
14
23
|
const HEAVY_MODELS = { claude: ['Claude Opus 5.5'], codex: ['gpt-6-luna'], antigravity: ['Gemini 4 Carbon'] };
|
|
15
24
|
export const SCARCE_POOL = { claude: 'fable', codex: 'astra', antigravity: 'third-party-claude' };
|
|
@@ -79,10 +88,11 @@ export function readCooldowns(file, onInvalid = (key) =>
|
|
|
79
88
|
* Atomic replace; an empty map removes the file. Invalid entries already in the file are kept as they are,
|
|
80
89
|
* unless data replaces their key or `remove` names it.
|
|
81
90
|
*/
|
|
82
|
-
export function writeCooldowns(file, data, { remove = [] } = {}) {
|
|
91
|
+
export function writeCooldowns(file, data, { remove = [], now = Date.now() } = {}) {
|
|
83
92
|
const invalid = Object.entries(readRaw(file))
|
|
84
93
|
.filter(([key, value]) => !Object.hasOwn(data, key) && !remove.includes(key) && !isValid(key, value));
|
|
85
|
-
const
|
|
94
|
+
const stamped = Object.entries(canonicalAll(data)).map(([key, entry]) => [key, withRecheck(entry, now)]);
|
|
95
|
+
const entries = Object.fromEntries([...stamped, ...invalid]);
|
|
86
96
|
if (Object.keys(entries).length === 0) {
|
|
87
97
|
fs.rmSync(file, { force: true });
|
|
88
98
|
return;
|
package/hooks/_shared.mjs
CHANGED
|
@@ -91,6 +91,9 @@ export const PROVIDER_ALIASES = new Map([
|
|
|
91
91
|
['claudeagent', 'claude'], ['claude', 'claude'], ['codex', 'codex'], ['antigravity', 'antigravity'],
|
|
92
92
|
]);
|
|
93
93
|
|
|
94
|
+
/** Like canonicalProvider without the prefix match: custom instances and model names are null. */
|
|
95
|
+
export const exactProvider = (id) => PROVIDER_ALIASES.get(String(id).toLowerCase().replace(/[^a-z0-9]/g, '')) ?? null;
|
|
96
|
+
|
|
94
97
|
/** 'claude' | 'codex' | 'antigravity' from a provider or instance id, else null. */
|
|
95
98
|
export function canonicalProvider(id) {
|
|
96
99
|
if (typeof id !== 'string') return null;
|
package/lib/discover.mjs
CHANGED
|
@@ -4,13 +4,13 @@ import fs from 'node:fs';
|
|
|
4
4
|
import os from 'node:os';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import {
|
|
7
|
-
AVAILABILITY_FILE, COOLDOWN_FILE, RETIRED_MODELS, canonicalProvider, inferProvider, isBanned, isObject, isStringList,
|
|
8
|
-
matchRetired, modelKeys, normalizeModel, readAvailability, warn, which as findOnPath,
|
|
7
|
+
AVAILABILITY_FILE, COOLDOWN_FILE, RETIRED_MODELS, canonicalProvider, exactProvider, inferProvider, isBanned, isObject, isStringList,
|
|
8
|
+
matchRetired, modelKeys, normalizeModel, readAvailability, restrictedBy, warn, which as findOnPath,
|
|
9
9
|
} from '../hooks/_shared.mjs';
|
|
10
|
-
import { prune, readCooldowns, writeCooldowns } from '../hooks/_quota.mjs';
|
|
10
|
+
import { isLocked, prune, readCooldowns, RECHECK_AFTER, withRecheck, writeCooldowns } from '../hooks/_quota.mjs';
|
|
11
11
|
import { CliError } from './paths.mjs';
|
|
12
|
-
import { MODELS, PROVIDERS, supersedes } from './plans.mjs';
|
|
13
|
-
import { probeModels } from './probe.mjs';
|
|
12
|
+
import { cheapestModel, MODELS, PROVIDERS, supersedes } from './plans.mjs';
|
|
13
|
+
import { PROBES, probeModels } from './probe.mjs';
|
|
14
14
|
|
|
15
15
|
const UNIT_MS = { m: 60_000, h: 3_600_000, d: 86_400_000 };
|
|
16
16
|
const MAX_TTL = 30 * UNIT_MS.d;
|
|
@@ -248,7 +248,7 @@ function put(models, provider, model, entry, now) {
|
|
|
248
248
|
models[`${provider}:${model}`] = entry;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
/** Drops expired locks
|
|
251
|
+
/** Drops expired locks, adds new ones without ever shortening an existing lock, and stamps missing recheck times. */
|
|
252
252
|
function updateCooldowns(configDir, now, locks = []) {
|
|
253
253
|
const file = path.join(configDir, COOLDOWN_FILE);
|
|
254
254
|
let stored;
|
|
@@ -265,15 +265,93 @@ function updateCooldowns(configDir, now, locks = []) {
|
|
|
265
265
|
kept[key] = entry;
|
|
266
266
|
added += 1;
|
|
267
267
|
}
|
|
268
|
-
|
|
268
|
+
const unstamped = Object.values(kept).some((entry) => withRecheck(entry, now) !== entry);
|
|
269
|
+
if (added || unstamped || Object.keys(removed).length > 0) {
|
|
270
|
+
writeCooldowns(file, kept, { remove: Object.keys(removed), now });
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const isExcluded = (model, config) => matchRetired(model, retiredPatterns(config)) || isBanned(model, bannedTerms(config));
|
|
275
|
+
|
|
276
|
+
/** "plan-restricted" or "unavailable" when the config or a live availability entry blocks the model, else null. */
|
|
277
|
+
function restriction(config, availability, provider, model, now) {
|
|
278
|
+
const refs = list(config?.planRestrictedModels);
|
|
279
|
+
if (refs.includes(model) || refs.includes(`${provider}:${model}`)) return 'plan-restricted';
|
|
280
|
+
return restrictedBy(availability, provider, model, now)?.status ?? null;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** The stored locks, or {} when the file cannot be read (updateCooldowns has already warned). */
|
|
284
|
+
function storedCooldowns(configDir) {
|
|
285
|
+
try {
|
|
286
|
+
return readCooldowns(path.join(configDir, COOLDOWN_FILE), () => {});
|
|
287
|
+
} catch {
|
|
288
|
+
return {};
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Tests provider locks that are due (all of them when force is set) against the cheapest standard model. Without a
|
|
294
|
+
* probeable local CLI the lock is left for the orchestrator ("via-t3"). Model and pool locks are not rechecked: a
|
|
295
|
+
* cheap standard model proves nothing about them.
|
|
296
|
+
*/
|
|
297
|
+
async function recheckLocks({ configDir, config, binaries, force, now, runner, which, probe }) {
|
|
298
|
+
const outcomes = [];
|
|
299
|
+
for (const [key, entry] of Object.entries(storedCooldowns(configDir))) {
|
|
300
|
+
const provider = entry.scope === 'provider' ? exactProvider(key.replace(/^provider:/i, '')) : null;
|
|
301
|
+
if (!provider || !(Date.parse(entry.until) > now)) continue;
|
|
302
|
+
if (!force && !(Date.parse(entry.recheckAfter) <= now)) continue;
|
|
303
|
+
const availability = readAvailabilityFile(configDir);
|
|
304
|
+
// A model under its own model or pool lock is no test of the provider, and the hook would block its canary.
|
|
305
|
+
const narrower = Object.fromEntries(Object.entries(storedCooldowns(configDir))
|
|
306
|
+
.filter(([, other]) => other.scope !== 'provider'));
|
|
307
|
+
const model = cheapestModel(provider, configuredModels(config)
|
|
308
|
+
.filter((item) => item.provider === provider && !item.scarceQuota && !isExcluded(item.model, config)
|
|
309
|
+
&& !restriction(config, availability, provider, item.model, now)
|
|
310
|
+
&& !isLocked(narrower, { provider, model: item.model, config }, now))
|
|
311
|
+
.map((item) => item.model));
|
|
312
|
+
if (!model) continue;
|
|
313
|
+
if (!binaries[provider]?.found || !Object.hasOwn(PROBES, provider)) {
|
|
314
|
+
outcomes.push({ key, provider, model, result: 'via-t3' });
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
const { results } = await probe({ config, candidates: { [provider]: [model] }, runner, which, now });
|
|
318
|
+
const cleared = results[0]?.state === 'available';
|
|
319
|
+
// Read again: a lock replaced while the probe ran is left alone.
|
|
320
|
+
const current = storedCooldowns(configDir);
|
|
321
|
+
if (current[key]?.until !== entry.until) continue;
|
|
322
|
+
if (cleared) delete current[key];
|
|
323
|
+
else current[key] = { ...current[key], recheckAfter: new Date(now + RECHECK_AFTER).toISOString() };
|
|
324
|
+
writeCooldowns(path.join(configDir, COOLDOWN_FILE), current, { remove: cleared ? [key] : [], now });
|
|
325
|
+
outcomes.push({ key, provider, model, result: cleared ? 'cleared' : 'still-locked' });
|
|
326
|
+
}
|
|
327
|
+
return outcomes;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** One status per configured model; a model nothing speaks against counts as available. */
|
|
331
|
+
function modelStatuses({ configDir, config, availability, results, probeScarce, now }) {
|
|
332
|
+
const cooldowns = storedCooldowns(configDir);
|
|
333
|
+
return configuredModels(config).map(({ provider, model, scarceQuota }) => {
|
|
334
|
+
const ref = `${provider}:${model}`;
|
|
335
|
+
const result = results.find((r) => canonicalProvider(r.provider) === provider && r.model === model);
|
|
336
|
+
// A failed probe (no CLI, logged out, timeout) blocks nothing, so it never reports "unavailable".
|
|
337
|
+
const cached = availability.models[ref]?.status;
|
|
338
|
+
const status = restriction(config, availability, provider, model, now)
|
|
339
|
+
|| (isExcluded(model, config) && 'unavailable')
|
|
340
|
+
|| (isLocked(cooldowns, { provider, model, config }, now) && 'rate-limited')
|
|
341
|
+
|| (result?.state === 'rate-limited' && 'rate-limited')
|
|
342
|
+
|| (STATUSES.includes(cached) && cached)
|
|
343
|
+
|| (scarceQuota && !probeScarce ? 'skipped-scarce' : 'available');
|
|
344
|
+
return { ref, status };
|
|
345
|
+
});
|
|
269
346
|
}
|
|
270
347
|
|
|
271
348
|
/** Configured models worth spending a probe on, grouped by provider, and the scarce ones left out. */
|
|
272
|
-
function probeCandidates(config, probeScarce) {
|
|
349
|
+
function probeCandidates(config, probeScarce, cooldowns, now) {
|
|
273
350
|
const candidates = {};
|
|
274
351
|
const skippedScarce = [];
|
|
275
352
|
for (const { provider, model, scarceQuota } of configuredModels(config)) {
|
|
276
|
-
|
|
353
|
+
// A locked model is left to recheckLocks: probing it again would spend quota and could extend the lock.
|
|
354
|
+
if (isExcluded(model, config) || isLocked(cooldowns, { provider, model, config }, now)) continue;
|
|
277
355
|
if (scarceQuota && !probeScarce) skippedScarce.push(`${provider}:${model}`);
|
|
278
356
|
else (candidates[provider] ??= []).push(model);
|
|
279
357
|
}
|
|
@@ -285,18 +363,21 @@ function probeCandidates(config, probeScarce) {
|
|
|
285
363
|
* checkedAt dates the last probe run, so discovery alone never keeps the cache fresh.
|
|
286
364
|
*/
|
|
287
365
|
export async function checkModels({
|
|
288
|
-
configDir, config, refresh = false, probeScarce = false,
|
|
289
|
-
probe = probeModels,
|
|
366
|
+
configDir, config, refresh = false, probeScarce = false, recheckLocks: force = false, ttlMs = CACHE_TTL,
|
|
367
|
+
now = Date.now(), runner, which, probe = probeModels,
|
|
290
368
|
} = {}) {
|
|
291
369
|
updateCooldowns(configDir, now);
|
|
292
370
|
const found = await discover({ config, runner, which, now });
|
|
371
|
+
const rechecked = await recheckLocks({
|
|
372
|
+
configDir, config, binaries: found.binaries, force, now, runner, which, probe,
|
|
373
|
+
});
|
|
293
374
|
const checkedAt = readAvailabilityFile(configDir)?.checkedAt;
|
|
294
375
|
const stale = !(now - Date.parse(checkedAt) <= ttlMs);
|
|
295
376
|
const probing = stale || refresh;
|
|
296
377
|
let results = [];
|
|
297
378
|
let skippedScarce = [];
|
|
298
379
|
if (probing) {
|
|
299
|
-
const selected = probeCandidates(config, probeScarce);
|
|
380
|
+
const selected = probeCandidates(config, probeScarce, storedCooldowns(configDir), now);
|
|
300
381
|
skippedScarce = selected.skippedScarce;
|
|
301
382
|
({ results } = await probe({
|
|
302
383
|
config, candidates: selected.candidates, probeScarce, runner, which, now,
|
|
@@ -325,7 +406,8 @@ export async function checkModels({
|
|
|
325
406
|
missingConfigured: found.missingConfigured,
|
|
326
407
|
});
|
|
327
408
|
const probed = results.filter((r) => !r.skipped).map((r) => `${canonicalProvider(r.provider)}:${r.model}`);
|
|
328
|
-
|
|
409
|
+
const statuses = modelStatuses({ configDir, config, availability, results, probeScarce, now });
|
|
410
|
+
return { availability, probed, skippedScarce, stale, statuses, rechecked };
|
|
329
411
|
}
|
|
330
412
|
|
|
331
413
|
/** Records a manual status for one hosting of a model, effective immediately and until the ttl ends. */
|
package/lib/plans.mjs
CHANGED
|
@@ -29,6 +29,8 @@ export const MODELS = deepFreeze({
|
|
|
29
29
|
'gpt-6.1-terra': model('codex', 'gpt-terra', '6.1'),
|
|
30
30
|
'gpt-6.1-sol': model('codex', 'gpt-sol', '6.1'),
|
|
31
31
|
'gpt-6-astra': model('codex', 'gpt-astra', '6', 'astra'),
|
|
32
|
+
'gpt-5.6-terra': model('codex', 'gpt-terra', '5.6'),
|
|
33
|
+
'gpt-5.6-luna': model('codex', 'gpt-luna', '5.6'),
|
|
32
34
|
'gemini-4-hydrogen': model('antigravity', 'gemini-hydrogen', '4'),
|
|
33
35
|
'gemini-4-neon': model('antigravity', 'gemini-neon', '4'),
|
|
34
36
|
'gemini-4-carbon': model('antigravity', 'gemini-carbon', '4'),
|
|
@@ -44,11 +46,11 @@ const PREFERENCE = {
|
|
|
44
46
|
auditor: ['claude-opus-5-5', 'claude-sonnet-5-5', 'claude-fable-5-2'],
|
|
45
47
|
},
|
|
46
48
|
codex: {
|
|
47
|
-
triage: ['gpt-6-luna', 'gpt-6.1-terra'],
|
|
48
|
-
planner: ['gpt-6.1-sol', 'gpt-6.1-terra', 'gpt-6-luna', 'gpt-6-astra'],
|
|
49
|
-
builder: ['gpt-6.1-terra', 'gpt-6.1-sol', 'gpt-6-luna', 'gpt-6-astra'],
|
|
50
|
-
tester: ['gpt-6-luna', 'gpt-6.1-terra', 'gpt-6.1-sol', 'gpt-6-astra'],
|
|
51
|
-
auditor: ['gpt-6.1-sol', 'gpt-6.1-terra', 'gpt-6-luna', 'gpt-6-astra'],
|
|
49
|
+
triage: ['gpt-6-luna', 'gpt-6.1-terra', 'gpt-5.6-luna', 'gpt-5.6-terra'],
|
|
50
|
+
planner: ['gpt-6.1-sol', 'gpt-6.1-terra', 'gpt-5.6-terra', 'gpt-6-luna', 'gpt-5.6-luna', 'gpt-6-astra'],
|
|
51
|
+
builder: ['gpt-6.1-terra', 'gpt-6.1-sol', 'gpt-5.6-terra', 'gpt-6-luna', 'gpt-5.6-luna', 'gpt-6-astra'],
|
|
52
|
+
tester: ['gpt-6-luna', 'gpt-6.1-terra', 'gpt-6.1-sol', 'gpt-5.6-luna', 'gpt-5.6-terra', 'gpt-6-astra'],
|
|
53
|
+
auditor: ['gpt-6.1-sol', 'gpt-6.1-terra', 'gpt-5.6-terra', 'gpt-6-luna', 'gpt-5.6-luna', 'gpt-6-astra'],
|
|
52
54
|
},
|
|
53
55
|
antigravity: {
|
|
54
56
|
triage: ['gemini-4-hydrogen', 'gemini-4-neon'],
|
|
@@ -131,13 +133,13 @@ function claudeTiers() {
|
|
|
131
133
|
function codexTiers() {
|
|
132
134
|
const base = ['gpt-6-luna', 'gpt-6.1-terra'];
|
|
133
135
|
const all = [...base, 'gpt-6.1-sol', 'gpt-6-astra'];
|
|
134
|
-
const
|
|
136
|
+
const starter = ['gpt-6-luna', 'gpt-5.6-terra', 'gpt-5.6-luna'];
|
|
135
137
|
const make = (id, label, options) => tier('codex', id, label, options);
|
|
136
138
|
const full = (id, label, builders) => make(id, label, { ids: all, builders, subCaps: { astra: 'weekly' } });
|
|
137
139
|
return [
|
|
138
140
|
make('none', 'No Codex plan'),
|
|
139
|
-
make('free', 'ChatGPT Free', {
|
|
140
|
-
make('go', 'ChatGPT Go', {
|
|
141
|
+
make('free', 'ChatGPT Free', { ids: starter, builders: 1 }),
|
|
142
|
+
make('go', 'ChatGPT Go', { ids: starter, builders: 1 }),
|
|
141
143
|
make('plus', 'ChatGPT Plus', { ids: base, builders: 1 }),
|
|
142
144
|
full('pro-100', 'ChatGPT Pro $100', 2),
|
|
143
145
|
full('pro-200', 'ChatGPT Pro $200', 2),
|
|
@@ -169,6 +171,13 @@ const byId = (tiers) => Object.fromEntries(tiers.map((t) => [t.id, t]));
|
|
|
169
171
|
|
|
170
172
|
export const CATALOG = deepFreeze({ claude: byId(claudeTiers()), codex: byId(codexTiers()), antigravity: byId(antigravityTiers()) });
|
|
171
173
|
|
|
174
|
+
/** The provider's cheapest (triage order) standard-pool model among ids, else null. */
|
|
175
|
+
export function cheapestModel(provider, ids) {
|
|
176
|
+
// Models outside the triage list rank last, in the given order.
|
|
177
|
+
const rank = (id) => (PREFERENCE[provider].triage.indexOf(id) + 1) || Number.MAX_SAFE_INTEGER;
|
|
178
|
+
return ids.filter((id) => !MODELS[id]?.scarceQuota).sort((a, b) => rank(a) - rank(b))[0] ?? null;
|
|
179
|
+
}
|
|
180
|
+
|
|
172
181
|
export function getTier(provider, tierId) {
|
|
173
182
|
if (!PROVIDERS.includes(provider)) throw new Error(`unknown provider "${provider}"; expected one of ${PROVIDERS.join(', ')}`);
|
|
174
183
|
if (!Object.hasOwn(CATALOG[provider], tierId)) {
|
package/lib/probe.mjs
CHANGED
|
@@ -17,7 +17,7 @@ const TIMEOUT = 20_000;
|
|
|
17
17
|
|
|
18
18
|
// Flags confirmed by `claude --help` and `codex exec --help`: one-word prompt, no tools or writes, nothing saved.
|
|
19
19
|
// There is no documented Antigravity probe. The prompt has no spaces so it survives a cmd.exe shim.
|
|
20
|
-
const PROBES = {
|
|
20
|
+
export const PROBES = {
|
|
21
21
|
claude: (id) => ['-p', 'ok', '--model', id, '--tools', '', '--safe-mode', '--no-session-persistence', '--output-format', 'text'],
|
|
22
22
|
codex: (id) => ['exec', '--model', id, '--sandbox', 'read-only', '--ephemeral', '--skip-git-repo-check',
|
|
23
23
|
'--ignore-user-config', '--ignore-rules', '--color', 'never', 'ok'],
|
package/lib/quota.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import {
|
|
5
|
-
COOLDOWN_FILE, canonicalProvider, cliModelId, inferProvider, loadConfig, modelKeys, normalizeModel, which as findOnPath,
|
|
5
|
+
COOLDOWN_FILE, canonicalProvider, cliModelId, exactProvider, inferProvider, loadConfig, modelKeys, normalizeModel, which as findOnPath,
|
|
6
6
|
} from '../hooks/_shared.mjs';
|
|
7
7
|
import { isLocked, parseRateLimit, prune, readCooldowns, SCARCE_POOL, writeCooldowns } from '../hooks/_quota.mjs';
|
|
8
8
|
import { HEAVY_MODELS } from './detect.mjs';
|
|
@@ -111,7 +111,7 @@ export function quotaSet(target, subject, { window, until, reason, pool, heavy =
|
|
|
111
111
|
scope, window: span, until: limit.until, reason: reason ?? `manual lock (${span})`, source: 'manual',
|
|
112
112
|
...(scope === 'tier' && { tier: poolKey }),
|
|
113
113
|
};
|
|
114
|
-
writeCooldowns(cooldownPath(target), { ...prune(load(target), now).kept, [key]: entry });
|
|
114
|
+
writeCooldowns(cooldownPath(target), { ...prune(load(target), now).kept, [key]: entry }, { now });
|
|
115
115
|
log(`locked ${key} until ${entry.until} (${span})`);
|
|
116
116
|
return { key, entry };
|
|
117
117
|
}
|
|
@@ -130,7 +130,7 @@ function countdown(ms) {
|
|
|
130
130
|
/** Drops expired locks and prints the rest. Returns the active ones. */
|
|
131
131
|
export function quotaStatus(target, { now = Date.now(), log = console.log } = {}) {
|
|
132
132
|
const { kept, removed } = prune(load(target), now);
|
|
133
|
-
if (Object.keys(removed).length) writeCooldowns(cooldownPath(target), kept);
|
|
133
|
+
if (Object.keys(removed).length) writeCooldowns(cooldownPath(target), kept, { now });
|
|
134
134
|
const locks = Object.entries(kept).map(([key, entry]) => ({ key, ...entry }));
|
|
135
135
|
if (!locks.length) log('no active cooldowns');
|
|
136
136
|
for (const { key, window, until, reason, source } of locks) {
|
|
@@ -148,7 +148,9 @@ export function quotaClear(target, subject, { log = console.log } = {}) {
|
|
|
148
148
|
return null;
|
|
149
149
|
}
|
|
150
150
|
const config = loadConfig(target);
|
|
151
|
-
|
|
151
|
+
// "provider:<p>" is the lock key as quota status prints it.
|
|
152
|
+
const named = String(subject ?? '').trim().replace(/^provider:/i, '');
|
|
153
|
+
const targetRef = resolveSubject(exactProvider(named) ? named : subject, config);
|
|
152
154
|
const { provider, model, qualified } = targetRef;
|
|
153
155
|
const bad = [];
|
|
154
156
|
const data = load(target, (key) => bad.push(key));
|
|
@@ -159,7 +161,7 @@ export function quotaClear(target, subject, { log = console.log } = {}) {
|
|
|
159
161
|
}]);
|
|
160
162
|
const removed = [...Object.entries(data), ...stubs].filter(([key, entry]) => {
|
|
161
163
|
if (provider && !model && entry.scope === 'tier') return key.toLowerCase().startsWith(`tier:${provider}:`);
|
|
162
|
-
if (provider && !model && entry.scope === 'provider') return key.
|
|
164
|
+
if (provider && !model && entry.scope === 'provider') return exactProvider(key.replace(/^provider:/i, '')) === provider;
|
|
163
165
|
if (model && entry.scope === 'tier') return false;
|
|
164
166
|
if (model && entry.scope === 'model' && qualified) {
|
|
165
167
|
return key.toLowerCase() === `model:${provider}:${targetRef.id}` || key.toLowerCase() === `model:${targetRef.id}`;
|
|
@@ -234,7 +236,7 @@ export async function quotaCheck(target, { providers, runner, which = findOnPath
|
|
|
234
236
|
// An existing lock that lasts longer is never shortened.
|
|
235
237
|
const longer = Object.entries(locks).filter(([key, { until }]) => !(Date.parse(stored[key]?.until) >= Date.parse(until)));
|
|
236
238
|
const next = { ...stored, ...Object.fromEntries(longer) };
|
|
237
|
-
writeCooldowns(cooldownPath(target), next);
|
|
239
|
+
writeCooldowns(cooldownPath(target), next, { now });
|
|
238
240
|
for (const key of Object.keys(locks)) log(`${key}: usage exhausted; locked until ${next[key].until}`);
|
|
239
241
|
} catch (error) {
|
|
240
242
|
log(`warning: lockout not recorded: ${error.message}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "t3-auto-build",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Cross-platform installer and $auto-build orchestration suite for T3 Code: subscription-aware cross-provider routing with quota and availability tracking.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
@@ -75,7 +75,7 @@ Select models by **Work Shape** and **Pipeline Role**, walking the full cross-pr
|
|
|
75
75
|
Lockouts persist across threads in `{{cooldownsPath}}`, combined with an in-run `EXHAUSTED` list:
|
|
76
76
|
- **Keys:** `model:<id>` (all hostings) | `model:<provider>:<id>` (that hosting only) | `provider:<p>` | `tier:<p>:<pool>` (scarce pools `fable`, `astra`, `third-party-claude`; legacy `tier:<p>:heavy` is still read). Model ids may be display names.
|
|
77
77
|
- **Entry:** `{ "scope": "model|provider|tier", "window": "burst|5h|weekly|custom", "until": "<ISO-8601 UTC>", "reason": "<short reason>", "source": "<who recorded it>" }`. Legacy entries (bare model/provider key with `scope` and `until_utc`) are still read.
|
|
78
|
-
- **Locked means unavailable:** An unexpired entry removes every model it covers from every ladder (a hook blocks locked models). Never retry or override a lock.
|
|
78
|
+
- **Locked means unavailable:** An unexpired entry removes every model it covers from every ladder (a hook blocks locked models). Never retry or override a lock, except for the `recheck-via-t3` canary in Step 0.
|
|
79
79
|
|
|
80
80
|
1. **Permanent Plan Errors** (model not in the plan/subscription, not entitled, unknown or unsupported model): Add to `EXHAUSTED`, fail over immediately, record NO cooldown, run `t3-auto-build availability mark <provider:model> plan-restricted --ttl 24h`, and advise the user to run `t3-auto-build sync-models`.
|
|
81
81
|
2. **Quota & Rate Limits:** Classify the error and record it with `t3-auto-build quota set <provider|model|provider:model> --burst|--5h|--weekly`:
|
|
@@ -89,6 +89,7 @@ Lockouts persist across threads in `{{cooldownsPath}}`, combined with an in-run
|
|
|
89
89
|
|
|
90
90
|
### Step 0: Lockout Check, Baseline Snapshot & Resume
|
|
91
91
|
1. **Before any delegation:** Apply `--reset-cooldowns` if present, then run `t3-auto-build check-models` (every run; TTL-cached and fast; never add `--probe-scarce` unless the user asked), `t3-auto-build quota status` (and `t3-auto-build quota check` if available). CLI not on PATH: read `{{availabilityPath}}` and `{{cooldownsPath}}` directly and ignore expired entries. Automatically skip every locked, `plan-restricted` or `unavailable` model and every provider at 0% remaining quota. Show the subscriptions in the run plan: {{subscriptionSummary}}.
|
|
92
|
+
- **`recheck-via-t3: <provider> (<model>)`** (a long provider lock is due and has no local CLI probe; skip under `--dry-run` or when a `--*-only` flag excludes the provider): note the `until` of the lock and of any `tier:<provider>:<pool>` lock from `t3-auto-build quota status`, run `t3-auto-build quota clear provider:<provider>`, restore each pool lock (`t3-auto-build quota set <provider> --pool <pool> --until <noted until>`), then send one canary `delegate_task` (that provider and model, `low` effort, prompt `Reply with one word: ok`). Only if it fails with a rate or usage limit, re-lock with `t3-auto-build quota set <provider> --until <noted until, or a later reset time from the error>`; any other outcome leaves it cleared (handle plan errors as in section 4).
|
|
92
93
|
2. Run `git status --short` to record pre-existing modified/untracked files.
|
|
93
94
|
3. **`--resume`:** Read `.claude/auto-build-state.json`, restore its `flags` (newly typed flags win), skip `completedWaves`, keep `modifiedFiles` in this run's diff scope, and continue with `remaining` and `blockers` (rebuild `REPO_BRIEF` first). If the file is missing or invalid, say so and stop.
|
|
94
95
|
- **State File (runs that edit code, plus `--plan-only`):** After each wave/step, overwrite `.claude/auto-build-state.json` with compact JSON `{"flags":[],"completedWaves":[],"modifiedFiles":[],"remaining":[],"blockers":[]}` (`remaining` names each pending wave/step and its files). Ensure it is gitignored: if `git check-ignore -q` on it fails, append its path to the file printed by `git rev-parse --git-path info/exclude`.
|