@clagentic/console 1.8.0 → 1.9.0-beta.2
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/bin/cli.js +12 -1
- package/lib/agents.js +13 -3
- package/lib/build-sha.json +2 -2
- package/lib/cli/ipc-subcommands.js +40 -4
- package/lib/daemon.js +25 -1
- package/lib/generated/claude-model-catalog.json +180 -0
- package/lib/model-catalog.js +202 -0
- package/lib/model-families.js +243 -0
- package/lib/project-connection.js +30 -5
- package/lib/project-loop.js +46 -2
- package/lib/project-sessions.js +133 -21
- package/lib/project-user-message.js +70 -3
- package/lib/project.js +11 -1
- package/lib/public/app.js +14 -4
- package/lib/public/css/base.css +14 -0
- package/lib/public/css/home-hub.css +28 -8
- package/lib/public/css/icon-strip.css +17 -0
- package/lib/public/css/menus.css +67 -0
- package/lib/public/css/messages.css +11 -0
- package/lib/public/css/mobile-nav.css +22 -0
- package/lib/public/css/server-settings.css +72 -0
- package/lib/public/css/sidebar.css +15 -0
- package/lib/public/css/title-bar.css +10 -1
- package/lib/public/index.html +4 -0
- package/lib/public/modules/activity-latch.js +159 -0
- package/lib/public/modules/activity-state.js +157 -0
- package/lib/public/modules/app-connection.js +10 -4
- package/lib/public/modules/app-favicon.js +88 -1
- package/lib/public/modules/app-home-hub.js +14 -11
- package/lib/public/modules/app-loop-ui.js +90 -2
- package/lib/public/modules/app-messages.js +117 -28
- package/lib/public/modules/app-panels.js +184 -56
- package/lib/public/modules/app-projects.js +28 -8
- package/lib/public/modules/app-rate-limit.js +14 -2
- package/lib/public/modules/model-families.js +230 -0
- package/lib/public/modules/project-settings.js +1 -0
- package/lib/public/modules/scheduler.js +5 -0
- package/lib/public/modules/server-settings.js +14 -12
- package/lib/public/modules/settings-defaults.js +151 -41
- package/lib/public/modules/sidebar-mobile.js +32 -22
- package/lib/public/modules/sidebar-projects.js +42 -14
- package/lib/public/modules/sidebar-sessions.js +168 -48
- package/lib/public/modules/tools.js +22 -12
- package/lib/sdk-bridge.js +389 -35
- package/lib/sdk-message-processor.js +215 -7
- package/lib/sdk-skill-discovery.js +46 -6
- package/lib/sdk-slash-enrichment.js +5 -2
- package/lib/server-hub-sessions.js +70 -0
- package/lib/server.js +79 -22
- package/lib/session-activity.js +289 -0
- package/lib/sessions.js +104 -3
- package/lib/smtp.js +10 -1
- package/lib/terminal-manager.js +40 -0
- package/lib/utils.js +44 -0
- package/lib/ws-schema.js +17 -0
- package/lib/yoke/adapters/claude-worker.js +6 -2
- package/lib/yoke/adapters/claude.js +384 -88
- package/lib/yoke/adapters/codex.js +239 -31
- package/package.json +2 -2
- package/scripts/check-test-count.js +397 -0
- package/scripts/generate-model-catalog.js +337 -0
- package/scripts/test-file-completion-reporter.js +43 -0
- package/lib/model-context-windows.js +0 -65
- package/lib/public/modules/model-context-windows.js +0 -62
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// generate-model-catalog.js — release-time generator for
|
|
5
|
+
// lib/generated/claude-model-catalog.json (lr-f22787).
|
|
6
|
+
//
|
|
7
|
+
// Runs ONLY in CI (.github/workflows/release.yml, `stable` job), never at
|
|
8
|
+
// install time or runtime. Calls GET https://api.anthropic.com/v1/models
|
|
9
|
+
// using ANTHROPIC_API_KEY from the environment (injected as a GitHub
|
|
10
|
+
// Actions repo secret — never present on the operator's machine, never read
|
|
11
|
+
// by the daemon). This is NOT an LLM call (workspace CLAUDE.md rule 17 only
|
|
12
|
+
// governs the `claude` CLI invocation path for actual model inference), so
|
|
13
|
+
// using fetch() directly here does not violate the CLI-only rule.
|
|
14
|
+
//
|
|
15
|
+
// DESIGN DECISIONS (see PR body for lr-f22787 for the full write-up):
|
|
16
|
+
//
|
|
17
|
+
// (a) RETIRED MODELS — ADDITIVE, never overwrite. This script unions the
|
|
18
|
+
// freshly-fetched model list with whatever is already committed in
|
|
19
|
+
// lib/generated/claude-model-catalog.json. A model /v1/models stops
|
|
20
|
+
// returning (retired) stays in the catalog rather than disappearing
|
|
21
|
+
// out from under an operator who might still be running it — the
|
|
22
|
+
// picker's "Catalog" badge marks it as unconfirmed-live rather than
|
|
23
|
+
// hiding it.
|
|
24
|
+
//
|
|
25
|
+
// (b) MISSING SECRET / FETCH FAILURE — never fail the build, never emit an
|
|
26
|
+
// empty catalog. If ANTHROPIC_API_KEY is absent, or the API call
|
|
27
|
+
// returns any non-2xx status (401/402/403/429/5xx) or a network error,
|
|
28
|
+
// this script now falls through to the credential-free deprecations-
|
|
29
|
+
// page source (see "FALLBACK SOURCE" below) instead of giving up
|
|
30
|
+
// immediately — this is what lets the very first release (before the
|
|
31
|
+
// operator has wired the secret) still produce a real, non-degenerate
|
|
32
|
+
// catalog rather than shipping only the empty/minimal state. Only if
|
|
33
|
+
// BOTH sources fail does this script log a warning and exit 0 WITHOUT
|
|
34
|
+
// touching the existing committed catalog file — the release proceeds
|
|
35
|
+
// shipping the previously generated catalog. Stale is an acceptable,
|
|
36
|
+
// visible-in-git-history degradation; empty is not.
|
|
37
|
+
//
|
|
38
|
+
// (c) The catalog itself carries no "deprecated" flag from the vendor
|
|
39
|
+
// response (GET /v1/models simply omits retired IDs — see task
|
|
40
|
+
// ground truth). Distinguishing "confirmed still in the vendor's live
|
|
41
|
+
// list" from "carried forward from a previous generation, not
|
|
42
|
+
// reconfirmed this run" is out of scope for the wire format the picker
|
|
43
|
+
// consumes (lib/model-catalog.js's fromCatalog marker already
|
|
44
|
+
// distinguishes catalog-sourced entries from the vendor's live
|
|
45
|
+
// enumeration at runtime, which is the marker that actually matters to
|
|
46
|
+
// an operator deciding whether to trust a row).
|
|
47
|
+
//
|
|
48
|
+
// FALLBACK SOURCE — the public deprecations page (lr-f22787 follow-up,
|
|
49
|
+
// route (a)): if /v1/models is unreachable (missing key, or a non-2xx —
|
|
50
|
+
// 402/403/429/5xx), this script falls back to
|
|
51
|
+
// https://platform.claude.com/docs/en/about-claude/model-deprecations, a
|
|
52
|
+
// credential-free, server-rendered docs page. CONFIRMED against the live
|
|
53
|
+
// raw HTML (not the markdown-converted view a browsing tool would show) —
|
|
54
|
+
// the page has 11 real <table><tr><td> tables. Model IDs are NOT scattered
|
|
55
|
+
// as plain text: they appear ONLY as the text content of two specific
|
|
56
|
+
// widget shapes, both distinguishable from doc-site navigation noise
|
|
57
|
+
// (href="...claude-on-vertex-ai..." style path segments, changelog anchor
|
|
58
|
+
// slugs like "#2026-04-14-claude-sonnet-4-and-claude-opus-4-models", and
|
|
59
|
+
// prose link text like "whats-new-opus-5") by their exact tag/class
|
|
60
|
+
// signature:
|
|
61
|
+
// 1. The MAIN STATUS TABLE (<thead> columns: "API model name", "Current
|
|
62
|
+
// state", "Deprecated", "Tentative retirement date"): each <tr> has
|
|
63
|
+
// the model ID in td[0] as a click-to-copy
|
|
64
|
+
// <span ... data-state="closed" ...>MODEL_ID</span> widget, and the
|
|
65
|
+
// LITERAL STATUS ("Active" / "Deprecated" / "Retired" — confirmed
|
|
66
|
+
// verbatim against the live page, no other values appear in this
|
|
67
|
+
// column) as plain text in td[1]. This table is the authoritative
|
|
68
|
+
// status source (STATUS_TABLE_ROW_RE below).
|
|
69
|
+
// 2. Every per-release DEPRECATION-HISTORY TABLE ("Retirement date" /
|
|
70
|
+
// "Deprecated model" / "Recommended replacement" columns): td[1] and
|
|
71
|
+
// td[2] each hold a
|
|
72
|
+
// <code class="relative inline bg-neutral-30 ...">MODEL_ID</code> tag
|
|
73
|
+
// — td[1]'s ID is, by column meaning, always a deprecated/retired
|
|
74
|
+
// model (these are HISTORICAL superseded IDs, most of which never
|
|
75
|
+
// appear at all in the main status table because they retired before
|
|
76
|
+
// this doc revision); td[2]'s ID is the currently-recommended
|
|
77
|
+
// replacement. HISTORY_ROW_RE below captures both with that positional
|
|
78
|
+
// meaning (fallback status only used for an ID the main table doesn't
|
|
79
|
+
// already cover — see extractModelIdsFromHtml).
|
|
80
|
+
// A naive claude-[\w.-]+ scan over the raw page text (an earlier version of
|
|
81
|
+
// this script) also matched inside href attributes and link prose, pulling
|
|
82
|
+
// in dozens of doc-site slugs that are not model IDs at all (e.g.
|
|
83
|
+
// "claude-api-skill", "claude-on-vertex-ai", "claude-prompting-best-
|
|
84
|
+
// practices"). The row-scoped regexes below match only those two tag/class
|
|
85
|
+
// shapes, and MODEL_ID_VALUE_RE additionally requires the captured text
|
|
86
|
+
// itself to start with "claude-" (the last table on the page reuses the
|
|
87
|
+
// identical <code class="relative inline bg-neutral-30..."> class for
|
|
88
|
+
// non-model parameter names like "temperature"/"top_p"/"top_k", so
|
|
89
|
+
// tag-shape alone is not sufficient). This holds no hardcoded model ID
|
|
90
|
+
// list or status table — it is a structural extraction rule against the
|
|
91
|
+
// page's real, confirmed markup, so a future model release or a newly
|
|
92
|
+
// retired ID requires zero changes here (same discipline as
|
|
93
|
+
// model-families.js's family/version derivation).
|
|
94
|
+
//
|
|
95
|
+
// Row boundaries: the main status table's <span data-state="closed"...>
|
|
96
|
+
// opening tag contains an embedded literal newline in its class attribute
|
|
97
|
+
// (confirmed against the live page), so a per-LINE regex scan misses full
|
|
98
|
+
// rows there. STATUS_TABLE_ROW_RE / HISTORY_ROW_RE both use the `s` (dotall)
|
|
99
|
+
// flag and operate on the whole fetched HTML string, matching <tr>...</tr>
|
|
100
|
+
// boundaries directly rather than splitting into lines first.
|
|
101
|
+
const DEPRECATIONS_PAGE_URL = 'https://platform.claude.com/docs/en/about-claude/model-deprecations';
|
|
102
|
+
const MODEL_ID_VALUE_RE = /^claude-[a-z0-9][a-z0-9.-]*$/;
|
|
103
|
+
// Main status table row: captures the span-wrapped model ID (group 1) and
|
|
104
|
+
// the plain-text "Current state" cell (group 2) from the same <tr>.
|
|
105
|
+
const STATUS_TABLE_ROW_RE = /<tr\b[^>]*>\s*<td\b[^>]*><span\b[^>]*\bdata-state="closed"[^>]*>([^<]+)<\/span><\/td>\s*<td\b[^>]*>([^<]*)<\/td>/gs;
|
|
106
|
+
// Deprecation-history table row: captures the deprecated-model code tag
|
|
107
|
+
// (group 1) and the recommended-replacement code tag (group 2) from the
|
|
108
|
+
// same <tr> — td[0] (the retirement-date cell) is skipped by requiring
|
|
109
|
+
// exactly two <code>...</code> tags to follow it.
|
|
110
|
+
const HISTORY_ROW_RE = /<tr\b[^>]*>\s*<td\b[^>]*>[^<]*<\/td>\s*<td\b[^>]*><code\b[^>]*\bclass="[^"]*\bbg-neutral-30\b[^"]*"[^>]*>([^<]+)<\/code><\/td>\s*<td\b[^>]*><code\b[^>]*\bclass="[^"]*\bbg-neutral-30\b[^"]*"[^>]*>([^<]+)<\/code><\/td>/gs;
|
|
111
|
+
// Normalizes the page's three literal state strings to the catalog's
|
|
112
|
+
// lowercase status vocabulary (see STATUS_VALUES below). Anything else
|
|
113
|
+
// (should not happen against the confirmed page shape, but a doc-site
|
|
114
|
+
// wording change is not this script's business to guess at) falls back to
|
|
115
|
+
// "unknown" rather than silently mislabeling a model as active.
|
|
116
|
+
var STATUS_TABLE_TEXT_TO_STATUS = { Active: 'active', Deprecated: 'deprecated', Retired: 'retired' };
|
|
117
|
+
|
|
118
|
+
const fs = require('fs');
|
|
119
|
+
const path = require('path');
|
|
120
|
+
|
|
121
|
+
const CATALOG_PATH = path.join(__dirname, '..', 'lib', 'generated', 'claude-model-catalog.json');
|
|
122
|
+
const API_BASE = 'https://api.anthropic.com/v1/models';
|
|
123
|
+
const ANTHROPIC_VERSION = '2023-06-01';
|
|
124
|
+
const PAGE_LIMIT = 1000;
|
|
125
|
+
|
|
126
|
+
function readExistingCatalog() {
|
|
127
|
+
try {
|
|
128
|
+
const raw = fs.readFileSync(CATALOG_PATH, 'utf8');
|
|
129
|
+
const parsed = JSON.parse(raw);
|
|
130
|
+
if (parsed && Array.isArray(parsed.models)) return parsed.models;
|
|
131
|
+
} catch (e) {
|
|
132
|
+
// Missing or corrupt — treat as "nothing to union with" rather than failing.
|
|
133
|
+
}
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Paginate GET /v1/models fully via after_id, per the documented endpoint
|
|
138
|
+
// (supports after_id/before_id, limit up to 1000).
|
|
139
|
+
async function fetchAllModels(apiKey) {
|
|
140
|
+
const collected = [];
|
|
141
|
+
let afterId = null;
|
|
142
|
+
for (;;) {
|
|
143
|
+
const url = new URL(API_BASE);
|
|
144
|
+
url.searchParams.set('limit', String(PAGE_LIMIT));
|
|
145
|
+
if (afterId) url.searchParams.set('after_id', afterId);
|
|
146
|
+
|
|
147
|
+
const res = await fetch(url, {
|
|
148
|
+
headers: {
|
|
149
|
+
'x-api-key': apiKey,
|
|
150
|
+
'anthropic-version': ANTHROPIC_VERSION,
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
if (!res.ok) {
|
|
155
|
+
const text = await res.text().catch(() => '');
|
|
156
|
+
throw new Error(`GET /v1/models failed: ${res.status} ${res.statusText} ${text.slice(0, 300)}`);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const body = await res.json();
|
|
160
|
+
const page = Array.isArray(body.data) ? body.data : [];
|
|
161
|
+
for (const m of page) {
|
|
162
|
+
if (m && m.id) {
|
|
163
|
+
collected.push({
|
|
164
|
+
id: m.id,
|
|
165
|
+
displayName: m.display_name || m.id,
|
|
166
|
+
createdAt: m.created_at || null,
|
|
167
|
+
// GET /v1/models omits retired IDs outright (per the documented
|
|
168
|
+
// endpoint behavior, and the task's own established ground
|
|
169
|
+
// truth) — every entry it DOES return is, by construction,
|
|
170
|
+
// currently active. There is no separate "deprecated" flag on
|
|
171
|
+
// this endpoint to distinguish "active" from "deprecated but
|
|
172
|
+
// still listed" (unlike the deprecations-page fallback source,
|
|
173
|
+
// which has a real three-state column) — see status handling on
|
|
174
|
+
// the deprecations-page path below for that finer grain.
|
|
175
|
+
status: 'active',
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (!body.has_more || page.length === 0) break;
|
|
181
|
+
const last = page[page.length - 1];
|
|
182
|
+
if (!last || !last.id) break;
|
|
183
|
+
afterId = last.id;
|
|
184
|
+
}
|
|
185
|
+
return collected;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function unionModels(existing, fresh) {
|
|
189
|
+
const byId = {};
|
|
190
|
+
for (const m of existing) if (m && m.id) byId[m.id] = m;
|
|
191
|
+
for (const m of fresh) if (m && m.id) byId[m.id] = m; // fresh data wins on conflicting fields for the same ID
|
|
192
|
+
return Object.keys(byId).sort().map(function (id) { return byId[id]; });
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Extract every model ID from raw deprecations-page HTML, WITH its status
|
|
196
|
+
// (active/deprecated/retired/unknown), keyed by id. Scoped to the row
|
|
197
|
+
// shapes confirmed against the live page (see the header comment above) —
|
|
198
|
+
// never a bare text scan, which would also match navigation hrefs and
|
|
199
|
+
// changelog anchor slugs. Exported separately from the fetch so the
|
|
200
|
+
// extraction logic itself is unit-testable against a fixed HTML fixture
|
|
201
|
+
// without a network call.
|
|
202
|
+
//
|
|
203
|
+
// Precedence: the main status table is authoritative — if an ID appears
|
|
204
|
+
// there, its literal state wins outright. An ID that ONLY appears in a
|
|
205
|
+
// history table (never in the main table — i.e. it retired before this doc
|
|
206
|
+
// revision and dropped out of the main table entirely) is treated as
|
|
207
|
+
// "retired": that is exactly what a "Deprecated model" column entry with no
|
|
208
|
+
// corresponding main-table row means. A history-table "Recommended
|
|
209
|
+
// replacement" ID that doesn't otherwise appear is treated as "active" —
|
|
210
|
+
// the page recommends it as a live replacement.
|
|
211
|
+
function extractModelStatusesFromHtml(html) {
|
|
212
|
+
const statusById = {};
|
|
213
|
+
|
|
214
|
+
STATUS_TABLE_ROW_RE.lastIndex = 0;
|
|
215
|
+
let m;
|
|
216
|
+
while ((m = STATUS_TABLE_ROW_RE.exec(html)) !== null) {
|
|
217
|
+
const id = m[1].trim();
|
|
218
|
+
if (!MODEL_ID_VALUE_RE.test(id)) continue;
|
|
219
|
+
const stateText = m[2].trim();
|
|
220
|
+
statusById[id] = STATUS_TABLE_TEXT_TO_STATUS[stateText] || 'unknown';
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
HISTORY_ROW_RE.lastIndex = 0;
|
|
224
|
+
while ((m = HISTORY_ROW_RE.exec(html)) !== null) {
|
|
225
|
+
const deprecatedId = m[1].trim();
|
|
226
|
+
const replacementId = m[2].trim();
|
|
227
|
+
if (MODEL_ID_VALUE_RE.test(deprecatedId) && !statusById[deprecatedId]) {
|
|
228
|
+
statusById[deprecatedId] = 'retired';
|
|
229
|
+
}
|
|
230
|
+
if (MODEL_ID_VALUE_RE.test(replacementId) && !statusById[replacementId]) {
|
|
231
|
+
statusById[replacementId] = 'active';
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return statusById;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Backward-compat convenience wrapper: just the sorted id list, no status.
|
|
239
|
+
// Kept because it's a simpler surface for anything that only needs
|
|
240
|
+
// membership, not status (and to avoid breaking any external caller of the
|
|
241
|
+
// original extraction function's name/shape).
|
|
242
|
+
function extractModelIdsFromHtml(html) {
|
|
243
|
+
return Object.keys(extractModelStatusesFromHtml(html)).sort();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Fetch the credential-free deprecations page and extract every model ID it
|
|
247
|
+
// lists, with status, via extractModelStatusesFromHtml.
|
|
248
|
+
async function fetchDeprecationsPageModels() {
|
|
249
|
+
const res = await fetch(DEPRECATIONS_PAGE_URL);
|
|
250
|
+
if (!res.ok) {
|
|
251
|
+
throw new Error(`GET ${DEPRECATIONS_PAGE_URL} failed: ${res.status} ${res.statusText}`);
|
|
252
|
+
}
|
|
253
|
+
const html = await res.text();
|
|
254
|
+
const statusById = extractModelStatusesFromHtml(html);
|
|
255
|
+
return Object.keys(statusById).sort().map(function (id) {
|
|
256
|
+
return { id: id, displayName: id, createdAt: null, status: statusById[id] };
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Resolves the freshest model list this run, trying the authoritative API
|
|
261
|
+
// first and falling back to the credential-free deprecations page. Returns
|
|
262
|
+
// { fresh, source } or null when NEITHER source produced anything usable —
|
|
263
|
+
// the caller treats null as "leave the committed catalog untouched."
|
|
264
|
+
async function resolveFreshModels() {
|
|
265
|
+
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
266
|
+
if (apiKey) {
|
|
267
|
+
try {
|
|
268
|
+
const fresh = await fetchAllModels(apiKey);
|
|
269
|
+
if (fresh.length) return { fresh: fresh, source: 'anthropic-api' };
|
|
270
|
+
console.warn('[generate-model-catalog] GET /v1/models returned zero entries — falling back to the deprecations page.');
|
|
271
|
+
} catch (err) {
|
|
272
|
+
console.warn('[generate-model-catalog] GET /v1/models failed — falling back to the deprecations page: ' + (err.message || err));
|
|
273
|
+
}
|
|
274
|
+
} else {
|
|
275
|
+
console.warn('[generate-model-catalog] ANTHROPIC_API_KEY not set — falling back to the deprecations page.');
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
try {
|
|
279
|
+
const fresh = await fetchDeprecationsPageModels();
|
|
280
|
+
if (fresh.length) return { fresh: fresh, source: 'deprecations-page' };
|
|
281
|
+
console.warn('[generate-model-catalog] deprecations-page fallback returned zero entries.');
|
|
282
|
+
} catch (err) {
|
|
283
|
+
console.warn('[generate-model-catalog] deprecations-page fallback failed: ' + (err.message || err));
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
async function main() {
|
|
290
|
+
const existing = readExistingCatalog();
|
|
291
|
+
const resolved = await resolveFreshModels();
|
|
292
|
+
|
|
293
|
+
if (!resolved) {
|
|
294
|
+
console.warn('[generate-model-catalog] no source produced a model list this run — leaving the committed catalog untouched (never ship an empty catalog).');
|
|
295
|
+
process.exit(0);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const merged = unionModels(existing, resolved.fresh);
|
|
299
|
+
const payload = {
|
|
300
|
+
generatedAt: new Date().toISOString(),
|
|
301
|
+
source: resolved.source,
|
|
302
|
+
models: merged,
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
fs.mkdirSync(path.dirname(CATALOG_PATH), { recursive: true });
|
|
306
|
+
fs.writeFileSync(CATALOG_PATH, JSON.stringify(payload, null, 2) + '\n');
|
|
307
|
+
console.log(`[generate-model-catalog] wrote ${CATALOG_PATH} (${merged.length} models, ${resolved.fresh.length} from this run via ${resolved.source}, ${existing.length} previously committed)`);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Only run as a CLI entry point when invoked directly (CI / `node
|
|
311
|
+
// scripts/generate-model-catalog.js`) — requiring this file from a test
|
|
312
|
+
// must not trigger a real network call or process.exit().
|
|
313
|
+
if (require.main === module) {
|
|
314
|
+
main().catch(function (err) {
|
|
315
|
+
// Any unexpected error here is a bug in this script, not a vendor/secret
|
|
316
|
+
// condition — those are already handled above with a graceful exit(0).
|
|
317
|
+
// Fail loudly so it's visible in the workflow run, but this only affects
|
|
318
|
+
// catalog freshness, never the release itself (this script's exit code
|
|
319
|
+
// is not checked by the workflow step that invokes it — see release.yml).
|
|
320
|
+
console.error('[generate-model-catalog] unexpected error: ' + (err && err.stack || err));
|
|
321
|
+
process.exit(1);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
module.exports = {
|
|
326
|
+
fetchAllModels: fetchAllModels,
|
|
327
|
+
fetchDeprecationsPageModels: fetchDeprecationsPageModels,
|
|
328
|
+
extractModelIdsFromHtml: extractModelIdsFromHtml,
|
|
329
|
+
extractModelStatusesFromHtml: extractModelStatusesFromHtml,
|
|
330
|
+
unionModels: unionModels,
|
|
331
|
+
readExistingCatalog: readExistingCatalog,
|
|
332
|
+
resolveFreshModels: resolveFreshModels,
|
|
333
|
+
CATALOG_PATH: CATALOG_PATH,
|
|
334
|
+
API_BASE: API_BASE,
|
|
335
|
+
DEPRECATIONS_PAGE_URL: DEPRECATIONS_PAGE_URL,
|
|
336
|
+
PAGE_LIMIT: PAGE_LIMIT,
|
|
337
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//
|
|
3
|
+
// test-file-completion-reporter.js — custom `node --test` reporter for
|
|
4
|
+
// scripts/check-test-count.js (lr-795882, hardened after PEACHES/BOBBIE PR
|
|
5
|
+
// #395 review).
|
|
6
|
+
//
|
|
7
|
+
// WHY A CUSTOM REPORTER, NOT TAP TEXT PARSING: when `node --test` is given
|
|
8
|
+
// multiple file arguments, all of them run in ONE shared process and their
|
|
9
|
+
// results interleave into a single flat TAP stream with no per-file marker
|
|
10
|
+
// in the human-readable text — there is no way to tell from TAP output
|
|
11
|
+
// alone whether every file in the glob actually reported. An earlier
|
|
12
|
+
// version of this check ran each file as its OWN `node --test` invocation
|
|
13
|
+
// to get per-file attribution, but that changes timing/jitter
|
|
14
|
+
// characteristics enough to expose an unrelated pre-existing flake
|
|
15
|
+
// (test/project-connection-hydrate-session-model-lr-041af8.test.js's
|
|
16
|
+
// millisecond-tie-break race in findRestoredActiveSession, filed
|
|
17
|
+
// separately as a follow-up) — a mechanism change should not itself
|
|
18
|
+
// introduce new failure risk. Node's reporter API (this file) receives a
|
|
19
|
+
// `file` field on every test:pass/test:fail event regardless of TAP's own
|
|
20
|
+
// text output, so this gets real per-file attribution from the SAME
|
|
21
|
+
// single-process run `npm test` has always used, with no isolation/timing
|
|
22
|
+
// change at all.
|
|
23
|
+
//
|
|
24
|
+
// CONTRACT: this reporter is used TOGETHER with the default `tap` reporter
|
|
25
|
+
// (`node --test --test-reporter=tap --test-reporter-destination=stdout
|
|
26
|
+
// --test-reporter=./test-file-completion-reporter.js
|
|
27
|
+
// --test-reporter-destination=stderr`, see check-test-count.js) — Node
|
|
28
|
+
// supports multiple --test-reporter flags, each with its own
|
|
29
|
+
// --test-reporter-destination, so a developer running `npm test` still
|
|
30
|
+
// sees normal TAP output on stdout; this reporter's machine-readable
|
|
31
|
+
// RESULT lines go to a separate stream that scripts/check-test-count.js
|
|
32
|
+
// parses. Output shape, one line per test:pass/test:fail event:
|
|
33
|
+
// RESULT <pass|fail> <absolute-file-path>
|
|
34
|
+
|
|
35
|
+
module.exports = async function* fileCompletionReporter(source) {
|
|
36
|
+
for await (var event of source) {
|
|
37
|
+
if (event.type === "test:pass" || event.type === "test:fail") {
|
|
38
|
+
var file = (event.data && event.data.file) || "";
|
|
39
|
+
var kind = event.type === "test:pass" ? "pass" : "fail";
|
|
40
|
+
yield "RESULT " + kind + " " + file + "\n";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* model-context-windows.js — shared source of truth for the model context-window
|
|
3
|
-
* map and beta-aware resolution. (lr-336f)
|
|
4
|
-
*
|
|
5
|
-
* This is the CJS backend copy. The ES module (browser) copy lives at
|
|
6
|
-
* lib/public/modules/model-context-windows.js. A CI test
|
|
7
|
-
* (test/model-context-windows-parity.test.js) asserts both files produce
|
|
8
|
-
* identical resolution results so they cannot silently drift.
|
|
9
|
-
*
|
|
10
|
-
* When adding a new model: update BOTH this file and
|
|
11
|
-
* lib/public/modules/model-context-windows.js.
|
|
12
|
-
* The parity test will fail if they disagree.
|
|
13
|
-
*
|
|
14
|
-
* Keep this module dependency-light: no project imports, no Node built-ins.
|
|
15
|
-
* That constraint is what lets it stay close to the browser copy.
|
|
16
|
-
*
|
|
17
|
-
* The map is keyed by a lowercase model-name substring. Lookup is a linear scan so
|
|
18
|
-
* insertion order matters for overlapping substrings — more-specific keys should
|
|
19
|
-
* appear before less-specific ones.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
var KNOWN_CONTEXT_WINDOWS = {
|
|
23
|
-
"opus-4-6": 1000000,
|
|
24
|
-
"claude-sonnet-4": 1000000,
|
|
25
|
-
"gpt-5.5": 1048576,
|
|
26
|
-
"gpt-5.4": 1048576,
|
|
27
|
-
"gpt-5.3": 1048576,
|
|
28
|
-
"gpt-5.2": 1048576,
|
|
29
|
-
"gpt-4.1": 1047576,
|
|
30
|
-
"o3": 200000,
|
|
31
|
-
"o4-mini": 200000,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Resolve the context window for a model identifier, applying the beta-first
|
|
36
|
-
* rule for the context-1m beta.
|
|
37
|
-
*
|
|
38
|
-
* activeBetas: optional array of active beta strings. When any entry contains
|
|
39
|
-
* "context-1m", the true window is 1M regardless of the model — the SDK
|
|
40
|
-
* reports the model's base window in ModelUsage but the beta extends it.
|
|
41
|
-
*
|
|
42
|
-
* Returns the window size in tokens, or 0 when the model is not in
|
|
43
|
-
* KNOWN_CONTEXT_WINDOWS and no beta applies. Callers treat 0 as "unknown"
|
|
44
|
-
* and should degrade cleanly (skip any window-based guard rather than
|
|
45
|
-
* guessing a default).
|
|
46
|
-
*/
|
|
47
|
-
function resolveModelContextWindow(model, activeBetas) {
|
|
48
|
-
// Beta check must come first — the SDK does not reflect the extended window.
|
|
49
|
-
if (Array.isArray(activeBetas)) {
|
|
50
|
-
for (var bi = 0; bi < activeBetas.length; bi++) {
|
|
51
|
-
if (activeBetas[bi].indexOf("context-1m") !== -1) return 1000000;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (!model) return 0;
|
|
55
|
-
var lc = model.toLowerCase();
|
|
56
|
-
// UI beta-toggle appends [1m] to the model name
|
|
57
|
-
if (lc.indexOf("[1m]") !== -1) return 1000000;
|
|
58
|
-
var keys = Object.keys(KNOWN_CONTEXT_WINDOWS);
|
|
59
|
-
for (var i = 0; i < keys.length; i++) {
|
|
60
|
-
if (lc.indexOf(keys[i]) !== -1) return KNOWN_CONTEXT_WINDOWS[keys[i]];
|
|
61
|
-
}
|
|
62
|
-
return 0;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
module.exports = { KNOWN_CONTEXT_WINDOWS: KNOWN_CONTEXT_WINDOWS, resolveModelContextWindow: resolveModelContextWindow };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* model-context-windows.js — shared source of truth for the model context-window
|
|
3
|
-
* map and beta-aware resolution. (lr-336f)
|
|
4
|
-
*
|
|
5
|
-
* This is the ES module (browser) copy. The CJS backend copy lives at
|
|
6
|
-
* lib/model-context-windows.js. A CI test (test/model-context-windows-parity.test.js)
|
|
7
|
-
* asserts both files produce identical resolution results so they cannot silently drift.
|
|
8
|
-
*
|
|
9
|
-
* When adding a new model: update BOTH this file and lib/model-context-windows.js.
|
|
10
|
-
* The parity test will fail if they disagree.
|
|
11
|
-
*
|
|
12
|
-
* The map is keyed by a lowercase model-name substring. Lookup is a linear scan so
|
|
13
|
-
* insertion order matters for overlapping substrings — more-specific keys should
|
|
14
|
-
* appear before less-specific ones.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export var KNOWN_CONTEXT_WINDOWS = {
|
|
18
|
-
"opus-4-6": 1000000,
|
|
19
|
-
"claude-sonnet-4": 1000000,
|
|
20
|
-
"gpt-5.5": 1048576,
|
|
21
|
-
"gpt-5.4": 1048576,
|
|
22
|
-
"gpt-5.3": 1048576,
|
|
23
|
-
"gpt-5.2": 1048576,
|
|
24
|
-
"gpt-4.1": 1047576,
|
|
25
|
-
"o3": 200000,
|
|
26
|
-
"o4-mini": 200000,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Resolve the context window for a model identifier, applying the beta-first
|
|
31
|
-
* rule for the context-1m beta.
|
|
32
|
-
*
|
|
33
|
-
* activeBetas: optional array of active beta strings. When any entry contains
|
|
34
|
-
* "context-1m", the true window is 1M regardless of the model — the SDK
|
|
35
|
-
* reports the model's base window in ModelUsage but the beta extends it.
|
|
36
|
-
*
|
|
37
|
-
* Returns the window size in tokens, or 0 when the model is not in
|
|
38
|
-
* KNOWN_CONTEXT_WINDOWS and no beta applies. Callers treat 0 as "unknown"
|
|
39
|
-
* and should degrade cleanly (skip any window-based guard rather than
|
|
40
|
-
* guessing a default).
|
|
41
|
-
*
|
|
42
|
-
* Note: the resolveContextWindow wrapper in app-panels.js adds an sdkValue
|
|
43
|
-
* fallback and a hasBeta() store accessor on top of this core function.
|
|
44
|
-
* This function itself is store-agnostic.
|
|
45
|
-
*/
|
|
46
|
-
export function resolveModelContextWindow(model, activeBetas) {
|
|
47
|
-
// Beta check must come first — the SDK does not reflect the extended window.
|
|
48
|
-
if (Array.isArray(activeBetas)) {
|
|
49
|
-
for (var bi = 0; bi < activeBetas.length; bi++) {
|
|
50
|
-
if (activeBetas[bi].indexOf("context-1m") !== -1) return 1000000;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (!model) return 0;
|
|
54
|
-
var lc = model.toLowerCase();
|
|
55
|
-
// UI beta-toggle appends [1m] to the model name
|
|
56
|
-
if (lc.indexOf("[1m]") !== -1) return 1000000;
|
|
57
|
-
var keys = Object.keys(KNOWN_CONTEXT_WINDOWS);
|
|
58
|
-
for (var i = 0; i < keys.length; i++) {
|
|
59
|
-
if (lc.indexOf(keys[i]) !== -1) return KNOWN_CONTEXT_WINDOWS[keys[i]];
|
|
60
|
-
}
|
|
61
|
-
return 0;
|
|
62
|
-
}
|