@warmdrift/kgauto-compiler 2.0.0-alpha.71 → 2.0.0-alpha.72

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tryGetProfile
3
- } from "./chunk-4UO4CCSP.mjs";
3
+ } from "./chunk-N36LE3MK.mjs";
4
4
 
5
5
  // src/brain-query.ts
6
6
  var FRESH_SNAPSHOT = {
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var LIBRARY_VERSION = "2.0.0-alpha.71";
2
+ var LIBRARY_VERSION = "2.0.0-alpha.72";
3
3
 
4
4
  // src/key-health.ts
5
5
  var JSON_HEADERS = { "Content-Type": "application/json" };
@@ -47,7 +47,8 @@ var PROFILES_RAW = [
47
47
  id: "claude-fable-5",
48
48
  verifiedAgainstDocs: "2026-06-21",
49
49
  provider: "anthropic",
50
- status: "preview",
50
+ status: "current",
51
+ // s76 2026-07-25: GA since 2026-06-09 per docs; was preview.
51
52
  maxContextTokens: 1e6,
52
53
  maxOutputTokens: 128e3,
53
54
  maxTools: 64,
@@ -101,7 +102,8 @@ var PROFILES_RAW = [
101
102
  id: "claude-opus-4-8",
102
103
  verifiedAgainstDocs: "2026-06-21",
103
104
  provider: "anthropic",
104
- status: "current",
105
+ status: "legacy",
106
+ // s76 2026-07-25: docs list as LEGACY (Opus 5 generation is current).
105
107
  maxContextTokens: 1e6,
106
108
  maxOutputTokens: 128e3,
107
109
  maxTools: 64,
@@ -141,11 +143,78 @@ var PROFILES_RAW = [
141
143
  classify: 8
142
144
  }
143
145
  },
146
+ {
147
+ // ── Claude Opus 5 — added s76 (2026-07-25, alpha.72) ──────────────────
148
+ // The model every seat in the portfolio actually runs, absent from the
149
+ // roster until now. Found by a catalog QA, not by the release watcher:
150
+ // the watcher detects unknown IDs on a provider's /models endpoint, but
151
+ // detection was never wired to ingestion, so the gap sat open. (That is
152
+ // what `scripts/catalog-sync.mjs` exists to close.)
153
+ //
154
+ // PROVENANCE — doc-verified 2026-07-25 against
155
+ // platform.claude.com/docs/en/docs/about-claude/models/overview:
156
+ // 1M context · 128k max output · $5/$25 per MTok · adaptive thinking YES
157
+ // · extended thinking NO · `effort` defaults to 'high' on the Claude API
158
+ // · reliable knowledge cutoff May 2026.
159
+ //
160
+ // FAMILY-INHERITED (not doc-read): maxTools, parallelToolCalls,
161
+ // structuredOutput, systemPromptMode, streaming. These are identical
162
+ // across opus-4-6 / 4-7 / 4-8 / sonnet-5 / fable-5 — five consecutive
163
+ // models — so they are a structural provider constant rather than a
164
+ // per-model value. Deliberately distinguished from the gemini-3.1-flash-lite
165
+ // failure, where a template-clone of PRICE (the field that actually varies,
166
+ // there by 2.5-3.75x) went unverified for 65 days.
167
+ id: "claude-opus-5",
168
+ verifiedAgainstDocs: "2026-07-25",
169
+ provider: "anthropic",
170
+ status: "current",
171
+ maxContextTokens: 1e6,
172
+ maxOutputTokens: 128e3,
173
+ maxTools: 64,
174
+ parallelToolCalls: true,
175
+ structuredOutput: "grammar",
176
+ systemPromptMode: "inline",
177
+ streaming: true,
178
+ cliffs: [],
179
+ costInputPer1m: 5,
180
+ costOutputPer1m: 25,
181
+ lowering: ANTHROPIC_LOWERING_BASE,
182
+ recovery: [
183
+ {
184
+ signal: "rate_limit",
185
+ action: "escalate",
186
+ reason: "429 from Anthropic \u2014 escalate to fallback chain"
187
+ },
188
+ {
189
+ signal: "model_not_found",
190
+ action: "escalate",
191
+ reason: "Model deprecated/renamed \u2014 escalate (L-061)"
192
+ }
193
+ ],
194
+ strengths: ["reasoning", "agentic_coding", "long_context", "reliable_tool_use", "structured_output"],
195
+ weaknesses: ["cost", "latency"],
196
+ notes: "Anthropic frontier for complex agentic coding + enterprise work; the Opus-tier current default as of 2026-07-25, superseding 4.8/4.7/4.6 (all now legacy). Doc-verified 2026-07-25: 1M ctx, 128k out, $5/$25, adaptive thinking (extended thinking NOT supported \u2014 that is Haiku 4.5 only in this generation), `effort` defaults to high on the Claude API. Price is unchanged from 4.5 through 5 \u2014 the tier moved without a cost change.",
197
+ // COLD-START PRIOR cloned from claude-opus-4-8. Self-labelling: below
198
+ // MEASURED_GROUNDING_MIN_N (10) brain rows these resolve as
199
+ // grounding:'judgment', so nothing reads them as measured until they are.
200
+ archetypePerf: {
201
+ critique: 10,
202
+ plan: 10,
203
+ generate: 9,
204
+ ask: 9,
205
+ extract: 9,
206
+ transform: 9,
207
+ hunt: 8,
208
+ summarize: 8,
209
+ classify: 8
210
+ }
211
+ },
144
212
  {
145
213
  id: "claude-opus-4-7",
146
214
  verifiedAgainstDocs: "2026-05-08",
147
215
  provider: "anthropic",
148
- status: "current",
216
+ status: "legacy",
217
+ // s76 2026-07-25: docs list as LEGACY (Opus 5 is current). Bundle said current while the brain already said legacy — the two disagreed.
149
218
  maxContextTokens: 1e6,
150
219
  maxOutputTokens: 128e3,
151
220
  maxTools: 64,
@@ -239,7 +308,8 @@ var PROFILES_RAW = [
239
308
  id: "claude-sonnet-4-6",
240
309
  verifiedAgainstDocs: "2026-05-08",
241
310
  provider: "anthropic",
242
- status: "current",
311
+ status: "legacy",
312
+ // s76 2026-07-25: docs list as LEGACY (Sonnet 5 is current).
243
313
  maxContextTokens: 1e6,
244
314
  maxOutputTokens: 64e3,
245
315
  maxTools: 64,
@@ -1378,7 +1448,8 @@ var PROFILES_RAW = [
1378
1448
  id: "claude-sonnet-5",
1379
1449
  verifiedAgainstDocs: "2026-07-02",
1380
1450
  provider: "anthropic",
1381
- status: "preview",
1451
+ status: "current",
1452
+ // s76 2026-07-25: GA per docs; was preview.
1382
1453
  maxContextTokens: 1e6,
1383
1454
  maxOutputTokens: 128e3,
1384
1455
  maxTools: 64,
@@ -101,7 +101,8 @@ var PROFILES_RAW = [
101
101
  id: "claude-fable-5",
102
102
  verifiedAgainstDocs: "2026-06-21",
103
103
  provider: "anthropic",
104
- status: "preview",
104
+ status: "current",
105
+ // s76 2026-07-25: GA since 2026-06-09 per docs; was preview.
105
106
  maxContextTokens: 1e6,
106
107
  maxOutputTokens: 128e3,
107
108
  maxTools: 64,
@@ -155,7 +156,8 @@ var PROFILES_RAW = [
155
156
  id: "claude-opus-4-8",
156
157
  verifiedAgainstDocs: "2026-06-21",
157
158
  provider: "anthropic",
158
- status: "current",
159
+ status: "legacy",
160
+ // s76 2026-07-25: docs list as LEGACY (Opus 5 generation is current).
159
161
  maxContextTokens: 1e6,
160
162
  maxOutputTokens: 128e3,
161
163
  maxTools: 64,
@@ -195,11 +197,78 @@ var PROFILES_RAW = [
195
197
  classify: 8
196
198
  }
197
199
  },
200
+ {
201
+ // ── Claude Opus 5 — added s76 (2026-07-25, alpha.72) ──────────────────
202
+ // The model every seat in the portfolio actually runs, absent from the
203
+ // roster until now. Found by a catalog QA, not by the release watcher:
204
+ // the watcher detects unknown IDs on a provider's /models endpoint, but
205
+ // detection was never wired to ingestion, so the gap sat open. (That is
206
+ // what `scripts/catalog-sync.mjs` exists to close.)
207
+ //
208
+ // PROVENANCE — doc-verified 2026-07-25 against
209
+ // platform.claude.com/docs/en/docs/about-claude/models/overview:
210
+ // 1M context · 128k max output · $5/$25 per MTok · adaptive thinking YES
211
+ // · extended thinking NO · `effort` defaults to 'high' on the Claude API
212
+ // · reliable knowledge cutoff May 2026.
213
+ //
214
+ // FAMILY-INHERITED (not doc-read): maxTools, parallelToolCalls,
215
+ // structuredOutput, systemPromptMode, streaming. These are identical
216
+ // across opus-4-6 / 4-7 / 4-8 / sonnet-5 / fable-5 — five consecutive
217
+ // models — so they are a structural provider constant rather than a
218
+ // per-model value. Deliberately distinguished from the gemini-3.1-flash-lite
219
+ // failure, where a template-clone of PRICE (the field that actually varies,
220
+ // there by 2.5-3.75x) went unverified for 65 days.
221
+ id: "claude-opus-5",
222
+ verifiedAgainstDocs: "2026-07-25",
223
+ provider: "anthropic",
224
+ status: "current",
225
+ maxContextTokens: 1e6,
226
+ maxOutputTokens: 128e3,
227
+ maxTools: 64,
228
+ parallelToolCalls: true,
229
+ structuredOutput: "grammar",
230
+ systemPromptMode: "inline",
231
+ streaming: true,
232
+ cliffs: [],
233
+ costInputPer1m: 5,
234
+ costOutputPer1m: 25,
235
+ lowering: ANTHROPIC_LOWERING_BASE,
236
+ recovery: [
237
+ {
238
+ signal: "rate_limit",
239
+ action: "escalate",
240
+ reason: "429 from Anthropic \u2014 escalate to fallback chain"
241
+ },
242
+ {
243
+ signal: "model_not_found",
244
+ action: "escalate",
245
+ reason: "Model deprecated/renamed \u2014 escalate (L-061)"
246
+ }
247
+ ],
248
+ strengths: ["reasoning", "agentic_coding", "long_context", "reliable_tool_use", "structured_output"],
249
+ weaknesses: ["cost", "latency"],
250
+ notes: "Anthropic frontier for complex agentic coding + enterprise work; the Opus-tier current default as of 2026-07-25, superseding 4.8/4.7/4.6 (all now legacy). Doc-verified 2026-07-25: 1M ctx, 128k out, $5/$25, adaptive thinking (extended thinking NOT supported \u2014 that is Haiku 4.5 only in this generation), `effort` defaults to high on the Claude API. Price is unchanged from 4.5 through 5 \u2014 the tier moved without a cost change.",
251
+ // COLD-START PRIOR cloned from claude-opus-4-8. Self-labelling: below
252
+ // MEASURED_GROUNDING_MIN_N (10) brain rows these resolve as
253
+ // grounding:'judgment', so nothing reads them as measured until they are.
254
+ archetypePerf: {
255
+ critique: 10,
256
+ plan: 10,
257
+ generate: 9,
258
+ ask: 9,
259
+ extract: 9,
260
+ transform: 9,
261
+ hunt: 8,
262
+ summarize: 8,
263
+ classify: 8
264
+ }
265
+ },
198
266
  {
199
267
  id: "claude-opus-4-7",
200
268
  verifiedAgainstDocs: "2026-05-08",
201
269
  provider: "anthropic",
202
- status: "current",
270
+ status: "legacy",
271
+ // s76 2026-07-25: docs list as LEGACY (Opus 5 is current). Bundle said current while the brain already said legacy — the two disagreed.
203
272
  maxContextTokens: 1e6,
204
273
  maxOutputTokens: 128e3,
205
274
  maxTools: 64,
@@ -293,7 +362,8 @@ var PROFILES_RAW = [
293
362
  id: "claude-sonnet-4-6",
294
363
  verifiedAgainstDocs: "2026-05-08",
295
364
  provider: "anthropic",
296
- status: "current",
365
+ status: "legacy",
366
+ // s76 2026-07-25: docs list as LEGACY (Sonnet 5 is current).
297
367
  maxContextTokens: 1e6,
298
368
  maxOutputTokens: 64e3,
299
369
  maxTools: 64,
@@ -1432,7 +1502,8 @@ var PROFILES_RAW = [
1432
1502
  id: "claude-sonnet-5",
1433
1503
  verifiedAgainstDocs: "2026-07-02",
1434
1504
  provider: "anthropic",
1435
- status: "preview",
1505
+ status: "current",
1506
+ // s76 2026-07-25: GA per docs; was preview.
1436
1507
  maxContextTokens: 1e6,
1437
1508
  maxOutputTokens: 128e3,
1438
1509
  maxTools: 64,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  ARCHETYPE_FLOOR_DEFAULT,
3
3
  getDefaultFallbackChain
4
- } from "../chunk-SBFSYCQG.mjs";
4
+ } from "../chunk-46U2NVOL.mjs";
5
5
  import {
6
6
  tryGetProfile
7
- } from "../chunk-4UO4CCSP.mjs";
7
+ } from "../chunk-N36LE3MK.mjs";
8
8
  import {
9
9
  subscribe,
10
10
  subscribeApp
package/dist/index.d.mts CHANGED
@@ -1009,7 +1009,7 @@ declare function runGoldenEval(opts: GoldenEvalOptions): Promise<GoldenEvalRunRe
1009
1009
  * guard in `tests/version.test.ts` fails the suite (and therefore
1010
1010
  * `prepublishOnly`) when they diverge — a stale constant cannot reach npm.
1011
1011
  */
1012
- declare const LIBRARY_VERSION = "2.0.0-alpha.71";
1012
+ declare const LIBRARY_VERSION = "2.0.0-alpha.72";
1013
1013
 
1014
1014
  /**
1015
1015
  * Oracle contract — how an app tells the brain whether a response was good.
package/dist/index.d.ts CHANGED
@@ -1009,7 +1009,7 @@ declare function runGoldenEval(opts: GoldenEvalOptions): Promise<GoldenEvalRunRe
1009
1009
  * guard in `tests/version.test.ts` fails the suite (and therefore
1010
1010
  * `prepublishOnly`) when they diverge — a stale constant cannot reach npm.
1011
1011
  */
1012
- declare const LIBRARY_VERSION = "2.0.0-alpha.71";
1012
+ declare const LIBRARY_VERSION = "2.0.0-alpha.72";
1013
1013
 
1014
1014
  /**
1015
1015
  * Oracle contract — how an app tells the brain whether a response was good.
package/dist/index.js CHANGED
@@ -362,7 +362,8 @@ var PROFILES_RAW = [
362
362
  id: "claude-fable-5",
363
363
  verifiedAgainstDocs: "2026-06-21",
364
364
  provider: "anthropic",
365
- status: "preview",
365
+ status: "current",
366
+ // s76 2026-07-25: GA since 2026-06-09 per docs; was preview.
366
367
  maxContextTokens: 1e6,
367
368
  maxOutputTokens: 128e3,
368
369
  maxTools: 64,
@@ -416,7 +417,8 @@ var PROFILES_RAW = [
416
417
  id: "claude-opus-4-8",
417
418
  verifiedAgainstDocs: "2026-06-21",
418
419
  provider: "anthropic",
419
- status: "current",
420
+ status: "legacy",
421
+ // s76 2026-07-25: docs list as LEGACY (Opus 5 generation is current).
420
422
  maxContextTokens: 1e6,
421
423
  maxOutputTokens: 128e3,
422
424
  maxTools: 64,
@@ -456,11 +458,78 @@ var PROFILES_RAW = [
456
458
  classify: 8
457
459
  }
458
460
  },
461
+ {
462
+ // ── Claude Opus 5 — added s76 (2026-07-25, alpha.72) ──────────────────
463
+ // The model every seat in the portfolio actually runs, absent from the
464
+ // roster until now. Found by a catalog QA, not by the release watcher:
465
+ // the watcher detects unknown IDs on a provider's /models endpoint, but
466
+ // detection was never wired to ingestion, so the gap sat open. (That is
467
+ // what `scripts/catalog-sync.mjs` exists to close.)
468
+ //
469
+ // PROVENANCE — doc-verified 2026-07-25 against
470
+ // platform.claude.com/docs/en/docs/about-claude/models/overview:
471
+ // 1M context · 128k max output · $5/$25 per MTok · adaptive thinking YES
472
+ // · extended thinking NO · `effort` defaults to 'high' on the Claude API
473
+ // · reliable knowledge cutoff May 2026.
474
+ //
475
+ // FAMILY-INHERITED (not doc-read): maxTools, parallelToolCalls,
476
+ // structuredOutput, systemPromptMode, streaming. These are identical
477
+ // across opus-4-6 / 4-7 / 4-8 / sonnet-5 / fable-5 — five consecutive
478
+ // models — so they are a structural provider constant rather than a
479
+ // per-model value. Deliberately distinguished from the gemini-3.1-flash-lite
480
+ // failure, where a template-clone of PRICE (the field that actually varies,
481
+ // there by 2.5-3.75x) went unverified for 65 days.
482
+ id: "claude-opus-5",
483
+ verifiedAgainstDocs: "2026-07-25",
484
+ provider: "anthropic",
485
+ status: "current",
486
+ maxContextTokens: 1e6,
487
+ maxOutputTokens: 128e3,
488
+ maxTools: 64,
489
+ parallelToolCalls: true,
490
+ structuredOutput: "grammar",
491
+ systemPromptMode: "inline",
492
+ streaming: true,
493
+ cliffs: [],
494
+ costInputPer1m: 5,
495
+ costOutputPer1m: 25,
496
+ lowering: ANTHROPIC_LOWERING_BASE,
497
+ recovery: [
498
+ {
499
+ signal: "rate_limit",
500
+ action: "escalate",
501
+ reason: "429 from Anthropic \u2014 escalate to fallback chain"
502
+ },
503
+ {
504
+ signal: "model_not_found",
505
+ action: "escalate",
506
+ reason: "Model deprecated/renamed \u2014 escalate (L-061)"
507
+ }
508
+ ],
509
+ strengths: ["reasoning", "agentic_coding", "long_context", "reliable_tool_use", "structured_output"],
510
+ weaknesses: ["cost", "latency"],
511
+ notes: "Anthropic frontier for complex agentic coding + enterprise work; the Opus-tier current default as of 2026-07-25, superseding 4.8/4.7/4.6 (all now legacy). Doc-verified 2026-07-25: 1M ctx, 128k out, $5/$25, adaptive thinking (extended thinking NOT supported \u2014 that is Haiku 4.5 only in this generation), `effort` defaults to high on the Claude API. Price is unchanged from 4.5 through 5 \u2014 the tier moved without a cost change.",
512
+ // COLD-START PRIOR cloned from claude-opus-4-8. Self-labelling: below
513
+ // MEASURED_GROUNDING_MIN_N (10) brain rows these resolve as
514
+ // grounding:'judgment', so nothing reads them as measured until they are.
515
+ archetypePerf: {
516
+ critique: 10,
517
+ plan: 10,
518
+ generate: 9,
519
+ ask: 9,
520
+ extract: 9,
521
+ transform: 9,
522
+ hunt: 8,
523
+ summarize: 8,
524
+ classify: 8
525
+ }
526
+ },
459
527
  {
460
528
  id: "claude-opus-4-7",
461
529
  verifiedAgainstDocs: "2026-05-08",
462
530
  provider: "anthropic",
463
- status: "current",
531
+ status: "legacy",
532
+ // s76 2026-07-25: docs list as LEGACY (Opus 5 is current). Bundle said current while the brain already said legacy — the two disagreed.
464
533
  maxContextTokens: 1e6,
465
534
  maxOutputTokens: 128e3,
466
535
  maxTools: 64,
@@ -554,7 +623,8 @@ var PROFILES_RAW = [
554
623
  id: "claude-sonnet-4-6",
555
624
  verifiedAgainstDocs: "2026-05-08",
556
625
  provider: "anthropic",
557
- status: "current",
626
+ status: "legacy",
627
+ // s76 2026-07-25: docs list as LEGACY (Sonnet 5 is current).
558
628
  maxContextTokens: 1e6,
559
629
  maxOutputTokens: 64e3,
560
630
  maxTools: 64,
@@ -1693,7 +1763,8 @@ var PROFILES_RAW = [
1693
1763
  id: "claude-sonnet-5",
1694
1764
  verifiedAgainstDocs: "2026-07-02",
1695
1765
  provider: "anthropic",
1696
- status: "preview",
1766
+ status: "current",
1767
+ // s76 2026-07-25: GA per docs; was preview.
1697
1768
  maxContextTokens: 1e6,
1698
1769
  maxOutputTokens: 128e3,
1699
1770
  maxTools: 64,
@@ -3171,6 +3242,12 @@ function lower(ir, profile, hints = {}) {
3171
3242
  }
3172
3243
  function lowerAnthropic(ir, profile, hints) {
3173
3244
  const systemBlocks = buildAnthropicSystemBlocks(ir.sections, profile);
3245
+ if (ir.constraints?.structuredOutput) {
3246
+ systemBlocks.push({
3247
+ type: "text",
3248
+ text: "Respond with a single valid JSON value and nothing else. Do not wrap it in a markdown code fence, and do not add any prose before or after it."
3249
+ });
3250
+ }
3174
3251
  const history = (ir.history ?? []).filter((m) => m.role !== "system");
3175
3252
  const policy = ir.historyCachePolicy;
3176
3253
  const markIndex = resolveHistoryMarkIndex(history.length, policy);
@@ -5788,6 +5865,41 @@ async function recordGoldenIr(input) {
5788
5865
  }
5789
5866
  }
5790
5867
 
5868
+ // src/json-loose.ts
5869
+ function parseJsonLoose(raw) {
5870
+ const attempt = (s) => {
5871
+ try {
5872
+ return JSON.parse(s);
5873
+ } catch {
5874
+ return FAILED;
5875
+ }
5876
+ };
5877
+ const direct = attempt(raw);
5878
+ if (direct !== FAILED) return { ok: true, value: direct, recovered: false };
5879
+ const cleaned = raw.trim().replace(/^```(?:json|JSON)?\s*/, "").replace(/\s*```$/, "").trim();
5880
+ const fenced = attempt(cleaned);
5881
+ if (fenced !== FAILED) return { ok: true, value: fenced, recovered: true };
5882
+ const objStart = cleaned.indexOf("{");
5883
+ const arrStart = cleaned.indexOf("[");
5884
+ const start = objStart === -1 ? arrStart : arrStart === -1 ? objStart : Math.min(objStart, arrStart);
5885
+ if (start !== -1) {
5886
+ const openChar = cleaned[start];
5887
+ const closeChar = openChar === "{" ? "}" : "]";
5888
+ const end = cleaned.lastIndexOf(closeChar);
5889
+ if (end > start) {
5890
+ const span = attempt(cleaned.slice(start, end + 1));
5891
+ if (span !== FAILED) return { ok: true, value: span, recovered: true };
5892
+ }
5893
+ }
5894
+ try {
5895
+ JSON.parse(raw);
5896
+ return { ok: false, error: "unreachable" };
5897
+ } catch (err) {
5898
+ return { ok: false, error: err instanceof Error ? err.message : String(err) };
5899
+ }
5900
+ }
5901
+ var FAILED = /* @__PURE__ */ Symbol("parse-failed");
5902
+
5791
5903
  // src/ir.ts
5792
5904
  var CallError = class extends Error {
5793
5905
  attempts;
@@ -7744,10 +7856,12 @@ function validateStructuredContract(exec, ir) {
7744
7856
  if (!exec.response.text) {
7745
7857
  return { ok: true, response: exec.response };
7746
7858
  }
7747
- try {
7748
- const parsed = JSON.parse(exec.response.text);
7749
- return { ok: true, response: { ...exec.response, structuredOutput: parsed } };
7750
- } catch (err) {
7859
+ const parsedResult = parseJsonLoose(exec.response.text);
7860
+ if (parsedResult.ok) {
7861
+ return { ok: true, response: { ...exec.response, structuredOutput: parsedResult.value } };
7862
+ }
7863
+ {
7864
+ const err = new Error(parsedResult.error);
7751
7865
  return {
7752
7866
  ok: false,
7753
7867
  status: exec.status,
@@ -8627,7 +8741,7 @@ function createBrainForwardRoutes(config) {
8627
8741
  }
8628
8742
 
8629
8743
  // src/version.ts
8630
- var LIBRARY_VERSION = "2.0.0-alpha.71";
8744
+ var LIBRARY_VERSION = "2.0.0-alpha.72";
8631
8745
 
8632
8746
  // src/key-health.ts
8633
8747
  var JSON_HEADERS2 = { "Content-Type": "application/json" };
package/dist/index.mjs CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  import {
17
17
  LIBRARY_VERSION,
18
18
  createKeyHealthRoute
19
- } from "./chunk-URFQR3SB.mjs";
19
+ } from "./chunk-AI4NNR5T.mjs";
20
20
  import {
21
21
  ABSOLUTE_FLOOR,
22
22
  ARCHETYPE_FLOOR_DEFAULT,
@@ -42,7 +42,7 @@ import {
42
42
  loadChainsFromBrain,
43
43
  readBrainReadEnv,
44
44
  resolveProviderKey
45
- } from "./chunk-SBFSYCQG.mjs";
45
+ } from "./chunk-46U2NVOL.mjs";
46
46
  import {
47
47
  ALIASES,
48
48
  LATENCY_TIER_MS,
@@ -53,7 +53,7 @@ import {
53
53
  latencyTierOf,
54
54
  profilesByProvider,
55
55
  tryGetProfile
56
- } from "./chunk-4UO4CCSP.mjs";
56
+ } from "./chunk-N36LE3MK.mjs";
57
57
  import {
58
58
  emitAdvisoryFired,
59
59
  emitCompileDone,
@@ -1138,6 +1138,12 @@ function lower(ir, profile, hints = {}) {
1138
1138
  }
1139
1139
  function lowerAnthropic(ir, profile, hints) {
1140
1140
  const systemBlocks = buildAnthropicSystemBlocks(ir.sections, profile);
1141
+ if (ir.constraints?.structuredOutput) {
1142
+ systemBlocks.push({
1143
+ type: "text",
1144
+ text: "Respond with a single valid JSON value and nothing else. Do not wrap it in a markdown code fence, and do not add any prose before or after it."
1145
+ });
1146
+ }
1141
1147
  const history = (ir.history ?? []).filter((m) => m.role !== "system");
1142
1148
  const policy = ir.historyCachePolicy;
1143
1149
  const markIndex = resolveHistoryMarkIndex(history.length, policy);
@@ -3755,6 +3761,41 @@ async function recordGoldenIr(input) {
3755
3761
  }
3756
3762
  }
3757
3763
 
3764
+ // src/json-loose.ts
3765
+ function parseJsonLoose(raw) {
3766
+ const attempt = (s) => {
3767
+ try {
3768
+ return JSON.parse(s);
3769
+ } catch {
3770
+ return FAILED;
3771
+ }
3772
+ };
3773
+ const direct = attempt(raw);
3774
+ if (direct !== FAILED) return { ok: true, value: direct, recovered: false };
3775
+ const cleaned = raw.trim().replace(/^```(?:json|JSON)?\s*/, "").replace(/\s*```$/, "").trim();
3776
+ const fenced = attempt(cleaned);
3777
+ if (fenced !== FAILED) return { ok: true, value: fenced, recovered: true };
3778
+ const objStart = cleaned.indexOf("{");
3779
+ const arrStart = cleaned.indexOf("[");
3780
+ const start = objStart === -1 ? arrStart : arrStart === -1 ? objStart : Math.min(objStart, arrStart);
3781
+ if (start !== -1) {
3782
+ const openChar = cleaned[start];
3783
+ const closeChar = openChar === "{" ? "}" : "]";
3784
+ const end = cleaned.lastIndexOf(closeChar);
3785
+ if (end > start) {
3786
+ const span = attempt(cleaned.slice(start, end + 1));
3787
+ if (span !== FAILED) return { ok: true, value: span, recovered: true };
3788
+ }
3789
+ }
3790
+ try {
3791
+ JSON.parse(raw);
3792
+ return { ok: false, error: "unreachable" };
3793
+ } catch (err) {
3794
+ return { ok: false, error: err instanceof Error ? err.message : String(err) };
3795
+ }
3796
+ }
3797
+ var FAILED = /* @__PURE__ */ Symbol("parse-failed");
3798
+
3758
3799
  // src/ir.ts
3759
3800
  var CallError = class extends Error {
3760
3801
  attempts;
@@ -4972,10 +5013,12 @@ function validateStructuredContract(exec, ir) {
4972
5013
  if (!exec.response.text) {
4973
5014
  return { ok: true, response: exec.response };
4974
5015
  }
4975
- try {
4976
- const parsed = JSON.parse(exec.response.text);
4977
- return { ok: true, response: { ...exec.response, structuredOutput: parsed } };
4978
- } catch (err) {
5016
+ const parsedResult = parseJsonLoose(exec.response.text);
5017
+ if (parsedResult.ok) {
5018
+ return { ok: true, response: { ...exec.response, structuredOutput: parsedResult.value } };
5019
+ }
5020
+ {
5021
+ const err = new Error(parsedResult.error);
4979
5022
  return {
4980
5023
  ok: false,
4981
5024
  status: exec.status,
@@ -25,7 +25,7 @@ __export(key_health_exports, {
25
25
  module.exports = __toCommonJS(key_health_exports);
26
26
 
27
27
  // src/version.ts
28
- var LIBRARY_VERSION = "2.0.0-alpha.71";
28
+ var LIBRARY_VERSION = "2.0.0-alpha.72";
29
29
 
30
30
  // src/key-health.ts
31
31
  var JSON_HEADERS = { "Content-Type": "application/json" };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createKeyHealthRoute
3
- } from "./chunk-URFQR3SB.mjs";
3
+ } from "./chunk-AI4NNR5T.mjs";
4
4
  export {
5
5
  createKeyHealthRoute
6
6
  };
package/dist/profiles.js CHANGED
@@ -79,7 +79,8 @@ var PROFILES_RAW = [
79
79
  id: "claude-fable-5",
80
80
  verifiedAgainstDocs: "2026-06-21",
81
81
  provider: "anthropic",
82
- status: "preview",
82
+ status: "current",
83
+ // s76 2026-07-25: GA since 2026-06-09 per docs; was preview.
83
84
  maxContextTokens: 1e6,
84
85
  maxOutputTokens: 128e3,
85
86
  maxTools: 64,
@@ -133,7 +134,8 @@ var PROFILES_RAW = [
133
134
  id: "claude-opus-4-8",
134
135
  verifiedAgainstDocs: "2026-06-21",
135
136
  provider: "anthropic",
136
- status: "current",
137
+ status: "legacy",
138
+ // s76 2026-07-25: docs list as LEGACY (Opus 5 generation is current).
137
139
  maxContextTokens: 1e6,
138
140
  maxOutputTokens: 128e3,
139
141
  maxTools: 64,
@@ -173,11 +175,78 @@ var PROFILES_RAW = [
173
175
  classify: 8
174
176
  }
175
177
  },
178
+ {
179
+ // ── Claude Opus 5 — added s76 (2026-07-25, alpha.72) ──────────────────
180
+ // The model every seat in the portfolio actually runs, absent from the
181
+ // roster until now. Found by a catalog QA, not by the release watcher:
182
+ // the watcher detects unknown IDs on a provider's /models endpoint, but
183
+ // detection was never wired to ingestion, so the gap sat open. (That is
184
+ // what `scripts/catalog-sync.mjs` exists to close.)
185
+ //
186
+ // PROVENANCE — doc-verified 2026-07-25 against
187
+ // platform.claude.com/docs/en/docs/about-claude/models/overview:
188
+ // 1M context · 128k max output · $5/$25 per MTok · adaptive thinking YES
189
+ // · extended thinking NO · `effort` defaults to 'high' on the Claude API
190
+ // · reliable knowledge cutoff May 2026.
191
+ //
192
+ // FAMILY-INHERITED (not doc-read): maxTools, parallelToolCalls,
193
+ // structuredOutput, systemPromptMode, streaming. These are identical
194
+ // across opus-4-6 / 4-7 / 4-8 / sonnet-5 / fable-5 — five consecutive
195
+ // models — so they are a structural provider constant rather than a
196
+ // per-model value. Deliberately distinguished from the gemini-3.1-flash-lite
197
+ // failure, where a template-clone of PRICE (the field that actually varies,
198
+ // there by 2.5-3.75x) went unverified for 65 days.
199
+ id: "claude-opus-5",
200
+ verifiedAgainstDocs: "2026-07-25",
201
+ provider: "anthropic",
202
+ status: "current",
203
+ maxContextTokens: 1e6,
204
+ maxOutputTokens: 128e3,
205
+ maxTools: 64,
206
+ parallelToolCalls: true,
207
+ structuredOutput: "grammar",
208
+ systemPromptMode: "inline",
209
+ streaming: true,
210
+ cliffs: [],
211
+ costInputPer1m: 5,
212
+ costOutputPer1m: 25,
213
+ lowering: ANTHROPIC_LOWERING_BASE,
214
+ recovery: [
215
+ {
216
+ signal: "rate_limit",
217
+ action: "escalate",
218
+ reason: "429 from Anthropic \u2014 escalate to fallback chain"
219
+ },
220
+ {
221
+ signal: "model_not_found",
222
+ action: "escalate",
223
+ reason: "Model deprecated/renamed \u2014 escalate (L-061)"
224
+ }
225
+ ],
226
+ strengths: ["reasoning", "agentic_coding", "long_context", "reliable_tool_use", "structured_output"],
227
+ weaknesses: ["cost", "latency"],
228
+ notes: "Anthropic frontier for complex agentic coding + enterprise work; the Opus-tier current default as of 2026-07-25, superseding 4.8/4.7/4.6 (all now legacy). Doc-verified 2026-07-25: 1M ctx, 128k out, $5/$25, adaptive thinking (extended thinking NOT supported \u2014 that is Haiku 4.5 only in this generation), `effort` defaults to high on the Claude API. Price is unchanged from 4.5 through 5 \u2014 the tier moved without a cost change.",
229
+ // COLD-START PRIOR cloned from claude-opus-4-8. Self-labelling: below
230
+ // MEASURED_GROUNDING_MIN_N (10) brain rows these resolve as
231
+ // grounding:'judgment', so nothing reads them as measured until they are.
232
+ archetypePerf: {
233
+ critique: 10,
234
+ plan: 10,
235
+ generate: 9,
236
+ ask: 9,
237
+ extract: 9,
238
+ transform: 9,
239
+ hunt: 8,
240
+ summarize: 8,
241
+ classify: 8
242
+ }
243
+ },
176
244
  {
177
245
  id: "claude-opus-4-7",
178
246
  verifiedAgainstDocs: "2026-05-08",
179
247
  provider: "anthropic",
180
- status: "current",
248
+ status: "legacy",
249
+ // s76 2026-07-25: docs list as LEGACY (Opus 5 is current). Bundle said current while the brain already said legacy — the two disagreed.
181
250
  maxContextTokens: 1e6,
182
251
  maxOutputTokens: 128e3,
183
252
  maxTools: 64,
@@ -271,7 +340,8 @@ var PROFILES_RAW = [
271
340
  id: "claude-sonnet-4-6",
272
341
  verifiedAgainstDocs: "2026-05-08",
273
342
  provider: "anthropic",
274
- status: "current",
343
+ status: "legacy",
344
+ // s76 2026-07-25: docs list as LEGACY (Sonnet 5 is current).
275
345
  maxContextTokens: 1e6,
276
346
  maxOutputTokens: 64e3,
277
347
  maxTools: 64,
@@ -1410,7 +1480,8 @@ var PROFILES_RAW = [
1410
1480
  id: "claude-sonnet-5",
1411
1481
  verifiedAgainstDocs: "2026-07-02",
1412
1482
  provider: "anthropic",
1413
- status: "preview",
1483
+ status: "current",
1484
+ // s76 2026-07-25: GA per docs; was preview.
1414
1485
  maxContextTokens: 1e6,
1415
1486
  maxOutputTokens: 128e3,
1416
1487
  maxTools: 64,
package/dist/profiles.mjs CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  latencyTierOf,
9
9
  profilesByProvider,
10
10
  tryGetProfile
11
- } from "./chunk-4UO4CCSP.mjs";
11
+ } from "./chunk-N36LE3MK.mjs";
12
12
  export {
13
13
  ALIASES,
14
14
  LATENCY_TIER_MS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warmdrift/kgauto-compiler",
3
- "version": "2.0.0-alpha.71",
3
+ "version": "2.0.0-alpha.72",
4
4
  "description": "Prompt compiler with executable provider knowledge for multi-model AI apps: normalized multi-provider transport with fallback chains, compile-time cliff guards, a curated model registry, and a telemetry flight recorder. Swap models without rewriting prompts.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",