@polderlabs/bizar 10.23.1 → 10.23.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/models.mjs +44 -10
- package/cli/commands/validate.mjs +19 -21
- package/cli/doctor.mjs +7 -11
- package/cli/provision.mjs +4 -1
- package/config/claude/hooks/sessionstart-model-sync.mjs +13 -2
- package/package.json +1 -1
- package/packages/sdk/dist/version.d.ts +1 -1
- package/packages/sdk/dist/version.js +1 -1
- package/packages/sdk/package.json +1 -1
package/cli/commands/models.mjs
CHANGED
|
@@ -923,16 +923,16 @@ export function partitionStalePicks({ liveIds, pickedIds, disabledProviders }) {
|
|
|
923
923
|
|
|
924
924
|
/**
|
|
925
925
|
* Sync `userSelected.models` into Claude Code's settings.json under
|
|
926
|
-
* `modelOverrides` using
|
|
926
|
+
* `modelOverrides` using recognized Claude IDs as keys and gateway IDs as
|
|
927
|
+
* values. This
|
|
927
928
|
* suppresses `[claude-code:unrecognized_model]` diagnostics on every turn
|
|
928
929
|
* for any picked ID the gateway serves. Stale IDs (not returned by the
|
|
929
930
|
* gateway) are excluded so the diagnostic still surfaces them.
|
|
930
931
|
*
|
|
931
932
|
* Behavior:
|
|
932
933
|
* - Reads `settings.json` if present; preserves every other field.
|
|
933
|
-
* - Writes `modelOverrides` as a sparse object
|
|
934
|
-
*
|
|
935
|
-
* identical (Claude Code dispatches the literal ID).
|
|
934
|
+
* - Writes `modelOverrides` as a sparse object for picked IDs that are
|
|
935
|
+
* also in `liveIds`; Claude Code still dispatches each literal value.
|
|
936
936
|
* - Atomic replace via temp-file + rename (matches `applyModels`).
|
|
937
937
|
* - When `settingsJsonPath` is provided (tests), uses that instead of
|
|
938
938
|
* `~/.claude/settings.json`.
|
|
@@ -962,13 +962,13 @@ export function applyModelOverrides({ settingsJsonPath, pickedIds, liveIds = [],
|
|
|
962
962
|
}
|
|
963
963
|
const live = new Set(Array.isArray(liveIds) ? liveIds : []);
|
|
964
964
|
const incoming = Array.isArray(pickedIds) ? pickedIds.filter((id) => typeof id === 'string' && id.trim()) : [];
|
|
965
|
-
// 10.22.0 / Phase 4: strip disabled-provider ids BEFORE the
|
|
966
|
-
// so Claude Code never sees an `anthropic/*`
|
|
965
|
+
// 10.22.0 / Phase 4: strip disabled-provider ids BEFORE the mapping
|
|
966
|
+
// so Claude Code never sees an `anthropic/*` override value. The
|
|
967
967
|
// skipped ids are reported back so the operator can see what was
|
|
968
968
|
// dropped (without crashing on the disabled list).
|
|
969
969
|
const disabled = Array.isArray(disabledProviders) ? disabledProviders : readDisabledProviders();
|
|
970
970
|
const { kept: picks, stripped: skippedDisabled } = filterCandidatesByDisabledProviders(incoming, disabled);
|
|
971
|
-
//
|
|
971
|
+
// Map only IDs the live gateway serves. Stale IDs intentionally stay
|
|
972
972
|
// out so the `[claude-code:unrecognized_model]` diagnostic still fires
|
|
973
973
|
// for them — the operator should re-run `bizar models` to drop them.
|
|
974
974
|
const synced = live.size === 0
|
|
@@ -987,9 +987,10 @@ export function applyModelOverrides({ settingsJsonPath, pickedIds, liveIds = [],
|
|
|
987
987
|
return { wrote: false, syncedIds: [], skippedStale: skipped, skippedDisabled, settingsPath: path };
|
|
988
988
|
}
|
|
989
989
|
}
|
|
990
|
-
//
|
|
991
|
-
//
|
|
992
|
-
|
|
990
|
+
// Claude Code ignores unknown override keys. Recognized Anthropic model IDs
|
|
991
|
+
// must be keys; configured gateway aliases are values. This also suppresses
|
|
992
|
+
// print-mode `[claude-code:unrecognized_model]` diagnostics for Agent SDK calls.
|
|
993
|
+
settings.modelOverrides = buildClaudeModelOverrides(synced);
|
|
993
994
|
const previousModel = typeof settings.model === 'string' ? settings.model : null;
|
|
994
995
|
const previousContext = profiles?.[previousModel]?.limits?.contextTokens;
|
|
995
996
|
const nextModel = synced[0] || null;
|
|
@@ -1022,6 +1023,39 @@ export function configuredFallbackModels(router) {
|
|
|
1022
1023
|
return filterCandidatesByDisabledProviders(ids, disabled).kept;
|
|
1023
1024
|
}
|
|
1024
1025
|
|
|
1026
|
+
export function configuredEnabledModels(router) {
|
|
1027
|
+
const disabled = extractDisabledProviders(router);
|
|
1028
|
+
const selected = currentSelection(router, { disabledProviders: disabled }).models;
|
|
1029
|
+
return selected.length > 0 ? selected : configuredFallbackModels(router);
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
export const CLAUDE_MODEL_OVERRIDE_KEYS = Object.freeze([
|
|
1033
|
+
'claude-fable-5',
|
|
1034
|
+
'claude-opus-5',
|
|
1035
|
+
'claude-sonnet-5',
|
|
1036
|
+
'claude-haiku-4-5-20251001',
|
|
1037
|
+
'claude-opus-4-8',
|
|
1038
|
+
'claude-opus-4-7',
|
|
1039
|
+
'claude-opus-4-6',
|
|
1040
|
+
'claude-sonnet-4-6',
|
|
1041
|
+
'claude-opus-4-5-20251101',
|
|
1042
|
+
'claude-sonnet-4-5-20250929',
|
|
1043
|
+
'claude-opus-4-1-20250805',
|
|
1044
|
+
'claude-opus-4-20250514',
|
|
1045
|
+
'claude-sonnet-4-20250514',
|
|
1046
|
+
'claude-3-7-sonnet-20250219',
|
|
1047
|
+
'claude-3-5-haiku-20241022',
|
|
1048
|
+
'claude-3-5-sonnet-20241022',
|
|
1049
|
+
]);
|
|
1050
|
+
|
|
1051
|
+
export function buildClaudeModelOverrides(modelIds) {
|
|
1052
|
+
const unique = [...new Set((Array.isArray(modelIds) ? modelIds : [])
|
|
1053
|
+
.filter((id) => typeof id === 'string' && id.trim())
|
|
1054
|
+
.map((id) => id.trim()))];
|
|
1055
|
+
return Object.fromEntries(unique.slice(0, CLAUDE_MODEL_OVERRIDE_KEYS.length)
|
|
1056
|
+
.map((id, index) => [CLAUDE_MODEL_OVERRIDE_KEYS[index], id]));
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1025
1059
|
/**
|
|
1026
1060
|
* Derive a human-readable label for a model ID. Used to populate the
|
|
1027
1061
|
* `modelPicker` array in settings.json so Claude Code's `/model` picker
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* - 7 rules mirrored from `config/rules/` → `~/.claude/rules/`
|
|
16
16
|
* - guarded autonomy hooks, including approval, compaction, and advisor context
|
|
17
17
|
* - shipped slash commands in `~/.claude/commands/`
|
|
18
|
-
* - permissions
|
|
18
|
+
* - permissions follow the current hook-enforced policy
|
|
19
19
|
* - the complete hook-enforced approval floor is wired
|
|
20
20
|
* - ~/.config/bizar/ exists (loop/runtime state)
|
|
21
21
|
*
|
|
@@ -27,7 +27,7 @@ import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
|
27
27
|
import { join } from 'node:path';
|
|
28
28
|
import { spawnSync } from 'node:child_process';
|
|
29
29
|
import { resolveBizarHome, resolveClaudeConfigDir, resolveGlobalModelRouter } from '../config-paths.mjs';
|
|
30
|
-
import {
|
|
30
|
+
import { configuredEnabledModels, listModels, resolveEndpoint } from './models.mjs';
|
|
31
31
|
|
|
32
32
|
function claudeDir() { return resolveClaudeConfigDir(); }
|
|
33
33
|
function bizarHome() { return resolveBizarHome(); }
|
|
@@ -159,14 +159,14 @@ const CHECKS = {
|
|
|
159
159
|
return `MCP command OK: ${actual}`;
|
|
160
160
|
},
|
|
161
161
|
|
|
162
|
-
'permissions-
|
|
162
|
+
'permissions-policy-current': async () => {
|
|
163
163
|
const cfg = readJsonSafe(settingsJsonPath());
|
|
164
164
|
const allow = cfg?.permissions?.allow || [];
|
|
165
|
-
const
|
|
166
|
-
if (
|
|
167
|
-
throw new Error('
|
|
165
|
+
const staleWildcard = allow.find((p) => typeof p === 'string' && p === 'mcp__*');
|
|
166
|
+
if (staleWildcard) {
|
|
167
|
+
throw new Error('legacy mcp__* wildcard remains in permissions.allow');
|
|
168
168
|
}
|
|
169
|
-
return
|
|
169
|
+
return `hook-enforced policy active (${allow.length} explicit allow entries)`;
|
|
170
170
|
},
|
|
171
171
|
|
|
172
172
|
'permissions-deny-dangerous': async () => {
|
|
@@ -188,8 +188,9 @@ const CHECKS = {
|
|
|
188
188
|
if (!Array.isArray(arr) || arr.length === 0) {
|
|
189
189
|
throw new Error('no PreToolUse hooks wired in settings.json');
|
|
190
190
|
}
|
|
191
|
-
const m = arr.find((h) => h.matcher
|
|
192
|
-
|
|
191
|
+
const m = arr.find((h) => h.matcher === '*'
|
|
192
|
+
|| (h.matcher && h.matcher.includes('Write') && h.matcher.includes('Edit')));
|
|
193
|
+
if (!m) throw new Error('PreToolUse matcher does not cover Write and Edit');
|
|
193
194
|
return `${arr.length} PreToolUse hook(s) wired (matcher: ${m.matcher})`;
|
|
194
195
|
},
|
|
195
196
|
|
|
@@ -348,24 +349,21 @@ const CHECKS = {
|
|
|
348
349
|
},
|
|
349
350
|
|
|
350
351
|
'provider-reachable': async () => {
|
|
351
|
-
const
|
|
352
|
-
if (!
|
|
352
|
+
const { endpoint, authToken } = resolveEndpoint();
|
|
353
|
+
if (!endpoint) {
|
|
353
354
|
const path = resolveGlobalModelRouter();
|
|
354
355
|
const router = readJsonSafe(path);
|
|
355
|
-
const fallback = router ?
|
|
356
|
+
const fallback = router ? configuredEnabledModels(router) : [];
|
|
356
357
|
if (fallback.length === 0) {
|
|
357
358
|
throw new Error(`no gateway URL or enabled configured model in ${path}; implicit defaults are prohibited`);
|
|
358
359
|
}
|
|
359
360
|
return `no gateway URL; explicit configured fallback is ${fallback[0]}`;
|
|
360
361
|
}
|
|
361
|
-
const ac = new AbortController();
|
|
362
|
-
const timer = setTimeout(() => ac.abort(), 4000);
|
|
363
362
|
try {
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
clearTimeout(timer);
|
|
363
|
+
const models = await listModels({ endpoint, authToken, timeoutMs: 4000 });
|
|
364
|
+
return `provider reachable at ${endpoint} (${models.length} models)`;
|
|
365
|
+
} catch (err) {
|
|
366
|
+
throw new Error(`provider at ${endpoint} unreachable: ${err.message ?? err}`);
|
|
369
367
|
}
|
|
370
368
|
},
|
|
371
369
|
|
|
@@ -387,7 +385,7 @@ const CHECK_ORDER = [
|
|
|
387
385
|
'claude-settings-schema',
|
|
388
386
|
'mcp-server-bizar-registered',
|
|
389
387
|
'mcp-server-bizar-command',
|
|
390
|
-
'permissions-
|
|
388
|
+
'permissions-policy-current',
|
|
391
389
|
'permissions-deny-dangerous',
|
|
392
390
|
'hooks-pretooluse-wired',
|
|
393
391
|
'hooks-posttooluse-wired',
|
|
@@ -431,7 +429,7 @@ export function showValidateHelp() {
|
|
|
431
429
|
integrated with Claude Code:
|
|
432
430
|
• claude CLI reachable + version
|
|
433
431
|
• ~/.claude/settings.json parses + Bizar MCP server registered
|
|
434
|
-
• permissions
|
|
432
|
+
• permissions follow the current hook-enforced policy
|
|
435
433
|
• hook-enforced approval and destructive-action floor
|
|
436
434
|
• all 14 Claude Code lifecycle events wired in settings.json
|
|
437
435
|
• all 16 agent files installed with unique Claude Code names
|
package/cli/doctor.mjs
CHANGED
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
REQUIRED_COMMANDS,
|
|
42
42
|
REQUIRED_HOOKS,
|
|
43
43
|
} from './commands/validate.mjs';
|
|
44
|
-
import {
|
|
44
|
+
import { configuredEnabledModels, listModels, resolveEndpoint } from './commands/models.mjs';
|
|
45
45
|
|
|
46
46
|
const REQUIRED_RULES = [
|
|
47
47
|
'general.md', 'git.md', 'javascript.md', 'python.md',
|
|
@@ -181,8 +181,8 @@ async function checkBizarHome() {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
async function checkProviderReachable() {
|
|
184
|
-
const
|
|
185
|
-
if (!
|
|
184
|
+
const { endpoint, authToken } = resolveEndpoint();
|
|
185
|
+
if (!endpoint) {
|
|
186
186
|
const routerPath = resolveGlobalModelRouter();
|
|
187
187
|
let router;
|
|
188
188
|
try {
|
|
@@ -190,22 +190,18 @@ async function checkProviderReachable() {
|
|
|
190
190
|
} catch {
|
|
191
191
|
throw new Error(`no provider URL and no readable global model router at ${routerPath}`);
|
|
192
192
|
}
|
|
193
|
-
const configured =
|
|
193
|
+
const configured = configuredEnabledModels(router);
|
|
194
194
|
if (configured.length === 0) {
|
|
195
195
|
throw new Error('no enabled configured model; implicit provider defaults are prohibited');
|
|
196
196
|
}
|
|
197
197
|
return `no gateway URL; explicit configured fallback is ${configured[0]}`;
|
|
198
198
|
}
|
|
199
|
-
let res;
|
|
200
199
|
try {
|
|
201
|
-
|
|
200
|
+
const models = await listModels({ endpoint, authToken, timeoutMs: 3000 });
|
|
201
|
+
return `provider at ${endpoint} ok (${models.length} models)`;
|
|
202
202
|
} catch (err) {
|
|
203
|
-
throw new Error(`provider at ${
|
|
203
|
+
throw new Error(`provider at ${endpoint} unreachable: ${err.message ?? err}`);
|
|
204
204
|
}
|
|
205
|
-
if (!res.ok) {
|
|
206
|
-
throw new Error(`provider at ${url} responded HTTP ${res.status}`);
|
|
207
|
-
}
|
|
208
|
-
return `provider at ${url} ok`;
|
|
209
205
|
}
|
|
210
206
|
|
|
211
207
|
// ── runner ──────────────────────────────────────────────────────────────────
|
package/cli/provision.mjs
CHANGED
|
@@ -32,6 +32,7 @@ import { homedir } from 'node:os';
|
|
|
32
32
|
import { dirname, join, resolve, sep } from 'node:path';
|
|
33
33
|
import { fileURLToPath } from 'node:url';
|
|
34
34
|
import { resolveBizarHome } from './config-paths.mjs';
|
|
35
|
+
import { buildClaudeModelOverrides, configuredEnabledModels } from './commands/models.mjs';
|
|
35
36
|
|
|
36
37
|
const __filename = fileURLToPath(import.meta.url);
|
|
37
38
|
const __dirname = dirname(__filename);
|
|
@@ -944,11 +945,13 @@ export function writeClaudeSettings({ dryRun = false, force = false } = {}) {
|
|
|
944
945
|
const legacyRouterPath = join(CLAUDE_DIR, 'model-router.json');
|
|
945
946
|
let installModel;
|
|
946
947
|
let installContextTokens;
|
|
948
|
+
let installModels = [];
|
|
947
949
|
for (const p of [bizarRouterPath, legacyRouterPath]) {
|
|
948
950
|
if (!existsSync(p)) continue;
|
|
949
951
|
const parsed = readJsonSafe(p, null);
|
|
950
952
|
if (!parsed || typeof parsed !== 'object') continue;
|
|
951
953
|
installModel = configuredInstallModel(parsed);
|
|
954
|
+
installModels = configuredEnabledModels(parsed);
|
|
952
955
|
installContextTokens = installModel ? configuredModelContextTokens(parsed, installModel) : undefined;
|
|
953
956
|
if (installModel) break;
|
|
954
957
|
// The Bizar path is authoritative even when it has no enabled candidates.
|
|
@@ -956,7 +959,7 @@ export function writeClaudeSettings({ dryRun = false, force = false } = {}) {
|
|
|
956
959
|
}
|
|
957
960
|
if (installModel) {
|
|
958
961
|
bizarSettings.model = installModel;
|
|
959
|
-
bizarSettings.modelOverrides =
|
|
962
|
+
bizarSettings.modelOverrides = buildClaudeModelOverrides(installModels);
|
|
960
963
|
const configuredContext = pickEnv('CLAUDE_CODE_MAX_CONTEXT_TOKENS') || installContextTokens;
|
|
961
964
|
if (configuredContext) bizarSettings.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS = String(configuredContext);
|
|
962
965
|
} else {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Claude Code settings keys that the operator owns:
|
|
8
8
|
*
|
|
9
9
|
* - modelPicker → { options: [{ model, label }] } in user pick order
|
|
10
|
-
* - modelOverrides → { <id>: <id> }
|
|
10
|
+
* - modelOverrides → { <recognized Claude id>: <gateway id> }
|
|
11
11
|
* - model → reset to the first user pick if the current value
|
|
12
12
|
* starts with `claude-` (the dead gateway namespace —
|
|
13
13
|
* the live gateway rejects it with model_not_found)
|
|
@@ -223,8 +223,19 @@ function syncOnce() {
|
|
|
223
223
|
return option;
|
|
224
224
|
});
|
|
225
225
|
|
|
226
|
+
const overrideKeys = [
|
|
227
|
+
'claude-fable-5', 'claude-opus-5', 'claude-sonnet-5',
|
|
228
|
+
'claude-haiku-4-5-20251001', 'claude-opus-4-8', 'claude-opus-4-7',
|
|
229
|
+
'claude-opus-4-6', 'claude-sonnet-4-6', 'claude-opus-4-5-20251101',
|
|
230
|
+
'claude-sonnet-4-5-20250929', 'claude-opus-4-1-20250805',
|
|
231
|
+
'claude-opus-4-20250514', 'claude-sonnet-4-20250514',
|
|
232
|
+
'claude-3-7-sonnet-20250219', 'claude-3-5-haiku-20241022',
|
|
233
|
+
'claude-3-5-sonnet-20241022',
|
|
234
|
+
];
|
|
226
235
|
settings.modelPicker = { options };
|
|
227
|
-
settings.modelOverrides = Object.fromEntries(
|
|
236
|
+
settings.modelOverrides = Object.fromEntries(
|
|
237
|
+
liveIds.slice(0, overrideKeys.length).map((id, index) => [overrideKeys[index], id]),
|
|
238
|
+
);
|
|
228
239
|
|
|
229
240
|
let modelChanged = false;
|
|
230
241
|
if (typeof settings.model !== 'string' || !liveIds.includes(settings.model)) {
|
package/package.json
CHANGED