@warmdrift/kgauto-compiler 2.0.0-alpha.97 → 2.0.0-alpha.99

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.
Files changed (37) hide show
  1. package/dist/{chunk-77AHSX6Y.mjs → chunk-2YCTWV4S.mjs} +1 -1
  2. package/dist/{chunk-AFYBZRQV.mjs → chunk-G33BUB43.mjs} +96 -20
  3. package/dist/{chunk-IEEROFZW.mjs → chunk-L3VBUB4I.mjs} +1 -1
  4. package/dist/{chunk-HHIXHL4O.mjs → chunk-PY4CBZFF.mjs} +12 -2
  5. package/dist/{compile-C2IfAGV1.d.mts → compile-hh_l7COL.d.mts} +1 -1
  6. package/dist/{compile-BlMXv6QT.d.ts → compile-nNpq-6yu.d.ts} +1 -1
  7. package/dist/glassbox/index.d.mts +3 -3
  8. package/dist/glassbox/index.d.ts +3 -3
  9. package/dist/glassbox-routes/format.d.mts +2 -2
  10. package/dist/glassbox-routes/format.d.ts +2 -2
  11. package/dist/glassbox-routes/index.d.mts +4 -4
  12. package/dist/glassbox-routes/index.d.ts +4 -4
  13. package/dist/glassbox-routes/index.js +12 -2
  14. package/dist/glassbox-routes/index.mjs +2 -2
  15. package/dist/glassbox-routes/react/index.d.mts +2 -2
  16. package/dist/glassbox-routes/react/index.d.ts +2 -2
  17. package/dist/index.d.mts +74 -9
  18. package/dist/index.d.ts +74 -9
  19. package/dist/index.js +109 -23
  20. package/dist/index.mjs +6 -6
  21. package/dist/{ir-DyMJ84je.d.mts → ir-BZ2qOPMp.d.mts} +13 -0
  22. package/dist/{ir-DbvOFKF-.d.ts → ir-CpkidtAd.d.ts} +13 -0
  23. package/dist/key-health.js +1 -1
  24. package/dist/key-health.mjs +1 -1
  25. package/dist/probe.d.mts +2 -2
  26. package/dist/probe.d.ts +2 -2
  27. package/dist/probe.js +106 -20
  28. package/dist/probe.mjs +3 -3
  29. package/dist/profiles.d.mts +1 -1
  30. package/dist/profiles.d.ts +1 -1
  31. package/dist/profiles.js +12 -2
  32. package/dist/profiles.mjs +1 -1
  33. package/dist/{types-D441T-KC.d.mts → types-BkdfoONZ.d.mts} +1 -1
  34. package/dist/{types-5TqjBeZD.d.ts → types-Bn-zF0S4.d.ts} +1 -1
  35. package/dist/{types-_myk4bxn.d.mts → types-DJFlO7ux.d.mts} +1 -1
  36. package/dist/{types-BlrbNQfj.d.ts → types-uWypgaAU.d.ts} +1 -1
  37. package/package.json +1 -1
package/dist/probe.js CHANGED
@@ -912,7 +912,12 @@ var PROFILES_RAW = [
912
912
  // "7-8 calls per step" — which was never a claim that only one tool may be
913
913
  // offered. See the note in lower.ts:lowerDeepSeek.
914
914
  parallelToolCalls: true,
915
- structuredOutput: "native",
915
+ structuredOutput: "grammar",
916
+ // alpha.99 — MEASURED 2026-08-29: DeepSeek rejects
917
+ // `response_format: {type:'json_schema'}` outright ("This response_format type is
918
+ // unavailable now"), so there is no schema-enforced mode for `'native'` to name.
919
+ // It supports `json_object` only, and only when the prompt contains the literal
920
+ // word "json" — the lowering emits the instruction that guarantees it.
916
921
  systemPromptMode: "inline",
917
922
  streaming: true,
918
923
  // alpha.96 — the `tool_count@1 -> drop_to_top_relevant` cliff was DELETED.
@@ -1006,7 +1011,12 @@ var PROFILES_RAW = [
1006
1011
  // "7-8 calls per step" — which was never a claim that only one tool may be
1007
1012
  // offered. See the note in lower.ts:lowerDeepSeek.
1008
1013
  parallelToolCalls: true,
1009
- structuredOutput: "native",
1014
+ structuredOutput: "grammar",
1015
+ // alpha.99 — MEASURED 2026-08-29: DeepSeek rejects
1016
+ // `response_format: {type:'json_schema'}` outright ("This response_format type is
1017
+ // unavailable now"), so there is no schema-enforced mode for `'native'` to name.
1018
+ // It supports `json_object` only, and only when the prompt contains the literal
1019
+ // word "json" — the lowering emits the instruction that guarantees it.
1010
1020
  systemPromptMode: "inline",
1011
1021
  streaming: true,
1012
1022
  // alpha.96 — the `tool_count@1 -> drop_to_top_relevant` cliff was DELETED.
@@ -3655,7 +3665,7 @@ function lowerGoogle(ir, profile, hints) {
3655
3665
  if (hints.forceTerseOutput) {
3656
3666
  generationConfig.maxOutputTokens = 200;
3657
3667
  }
3658
- if (ir.constraints?.structuredOutput && profile.structuredOutput === "native") {
3668
+ if (ir.constraints?.structuredOutput && profile.structuredOutput !== "none") {
3659
3669
  generationConfig.responseMimeType = "application/json";
3660
3670
  }
3661
3671
  const contents = buildGoogleContents(ir.history ?? [], ir.currentTurn);
@@ -3714,7 +3724,9 @@ function toGoogleTools(tools) {
3714
3724
  }
3715
3725
  function lowerOpenAI(ir, profile, hints) {
3716
3726
  const ordered = sortSections(ir.sections);
3717
- const systemText = ordered.map((s) => s.text).join("\n\n");
3727
+ const sectionText = ordered.map((s) => s.text).join("\n\n");
3728
+ const jsonInstruction = ir.constraints?.structuredOutput ? "Respond with a single valid JSON value and nothing else. Do not wrap the JSON in a markdown code fence, and do not add any prose before or after it." : "";
3729
+ const systemText = [sectionText, jsonInstruction].filter(Boolean).join("\n\n");
3718
3730
  const systemRole = profile.systemPromptMode === "as_developer" ? "developer" : "system";
3719
3731
  const messages = systemText ? [{ role: systemRole, content: systemText }] : [];
3720
3732
  for (const m of ir.history ?? []) {
@@ -3760,7 +3772,9 @@ function toOpenAITools(tools) {
3760
3772
  }
3761
3773
  function lowerDeepSeek(ir, profile, hints) {
3762
3774
  const ordered = sortSections(ir.sections);
3763
- const systemText = ordered.map((s) => s.text).join("\n\n");
3775
+ const sectionText = ordered.map((s) => s.text).join("\n\n");
3776
+ const jsonInstruction = ir.constraints?.structuredOutput ? "Respond with a single valid JSON value and nothing else. Do not wrap the JSON in a markdown code fence, and do not add any prose before or after it." : "";
3777
+ const systemText = [sectionText, jsonInstruction].filter(Boolean).join("\n\n");
3764
3778
  const messages = systemText ? [{ role: "system", content: systemText }] : [];
3765
3779
  for (const m of ir.history ?? []) {
3766
3780
  if (m.role === "system") continue;
@@ -3780,6 +3794,9 @@ function lowerDeepSeek(ir, profile, hints) {
3780
3794
  provider: "deepseek",
3781
3795
  model: profile.id,
3782
3796
  messages,
3797
+ // Safe only because `jsonInstruction` above guarantees the literal word
3798
+ // "json" reaches the prompt — DeepSeek 400s otherwise (measurement C).
3799
+ response_format: ir.constraints?.structuredOutput ? { type: "json_object" } : void 0,
3783
3800
  // Every tool the IR carries. Never fewer — see the note above.
3784
3801
  tools: ir.tools && ir.tools.length > 0 ? ir.tools.map((t) => ({
3785
3802
  type: "function",
@@ -3799,7 +3816,9 @@ function lowerDeepSeek(ir, profile, hints) {
3799
3816
  }
3800
3817
  function buildOpenAICompatibleParts(ir) {
3801
3818
  const ordered = sortSections(ir.sections);
3802
- const systemText = ordered.map((s) => s.text).join("\n\n");
3819
+ const sectionText = ordered.map((s) => s.text).join("\n\n");
3820
+ const jsonInstruction = ir.constraints?.structuredOutput ? "Respond with a single valid JSON value and nothing else. Do not wrap the JSON in a markdown code fence, and do not add any prose before or after it." : "";
3821
+ const systemText = [sectionText, jsonInstruction].filter(Boolean).join("\n\n");
3803
3822
  const messages = systemText ? [{ role: "system", content: systemText }] : [];
3804
3823
  for (const m of ir.history ?? []) {
3805
3824
  if (m.role === "system") continue;
@@ -4284,12 +4303,19 @@ function mapRows(rows) {
4284
4303
  if (!isRawFailureRow(row)) continue;
4285
4304
  const n = coerceCount(row.n);
4286
4305
  const nFail = coerceCount(row.n_fail) ?? 0;
4287
- if (n === null || n <= 0) continue;
4306
+ const nAttempted = coerceCount(row.n_attempted);
4307
+ const nUnavailable = coerceCount(row.n_unavailable) ?? 0;
4308
+ const nUnclassified = coerceCount(row.n_unclassified) ?? 0;
4309
+ if (n === null) continue;
4310
+ if (n <= 0 && nUnavailable <= 0) continue;
4288
4311
  out.push({
4289
4312
  archetype: row.intent_archetype,
4290
4313
  model: row.model,
4291
4314
  n,
4292
- nFail
4315
+ nFail,
4316
+ nAttempted: nAttempted ?? n,
4317
+ nUnavailable,
4318
+ nUnclassified
4293
4319
  });
4294
4320
  }
4295
4321
  return out;
@@ -4313,7 +4339,24 @@ var MEASURED_FAILURE_CFG = {
4313
4339
  /** 95% one-sided-ish confidence (standard two-sided z at α=0.05). */
4314
4340
  z: 1.96,
4315
4341
  /** Must match the view's window. Documented here for the advisory text. */
4316
- windowDays: 28
4342
+ windowDays: 28,
4343
+ /**
4344
+ * alpha.98 — the AVAILABILITY axis. Same statistic, separate vocabulary,
4345
+ * separate verdict, because a 429 and a parse-failure send an operator in
4346
+ * opposite directions (fund or throttle the account vs. distrust the
4347
+ * model's declared structuredOutput). Merging them into one "failure rate"
4348
+ * is the s75 normalization defect.
4349
+ *
4350
+ * Thresholds match the quality axis deliberately: "we are 95% confident
4351
+ * this model is unreachable more often than not" is the same unarguable
4352
+ * bar, and a de-rank is the same remedy. Kept as a distinct config block
4353
+ * so the two can be tuned apart when evidence says they should be.
4354
+ */
4355
+ availability: {
4356
+ minSample: 5,
4357
+ lowerBoundThreshold: 0.5,
4358
+ z: 1.96
4359
+ }
4317
4360
  };
4318
4361
  function wilsonLowerBound(failures, n, z = MEASURED_FAILURE_CFG.z) {
4319
4362
  if (n <= 0) return 0;
@@ -4327,15 +4370,53 @@ function wilsonLowerBound(failures, n, z = MEASURED_FAILURE_CFG.z) {
4327
4370
  }
4328
4371
  function judgeMeasuredFailure(row, cfg = MEASURED_FAILURE_CFG) {
4329
4372
  if (!row) return void 0;
4330
- const normalized = "nFail" in row && typeof row.n === "number" ? row : mapRows([row])[0];
4331
- if (!normalized || normalized.n < cfg.minSample) return void 0;
4332
- const lowerBound = wilsonLowerBound(normalized.nFail, normalized.n, cfg.z);
4373
+ const raw = "nFail" in row && typeof row.n === "number" ? row : mapRows([row])[0];
4374
+ if (!raw) return void 0;
4375
+ const normalized = {
4376
+ ...raw,
4377
+ nAttempted: typeof raw.nAttempted === "number" ? raw.nAttempted : raw.n,
4378
+ nUnavailable: typeof raw.nUnavailable === "number" ? raw.nUnavailable : 0,
4379
+ nUnclassified: typeof raw.nUnclassified === "number" ? raw.nUnclassified : 0
4380
+ };
4381
+ const quality = judgeAxis(
4382
+ normalized.nFail,
4383
+ normalized.n,
4384
+ cfg.minSample,
4385
+ cfg.lowerBoundThreshold,
4386
+ cfg.z
4387
+ );
4388
+ const availability = judgeAxis(
4389
+ normalized.nUnavailable,
4390
+ normalized.nAttempted,
4391
+ cfg.availability.minSample,
4392
+ cfg.availability.lowerBoundThreshold,
4393
+ cfg.availability.z
4394
+ );
4395
+ if (normalized.n < cfg.minSample && normalized.nAttempted < cfg.availability.minSample) {
4396
+ return void 0;
4397
+ }
4398
+ const axis = quality.gated ? "quality" : availability.gated ? "availability" : void 0;
4399
+ const lead = axis === "availability" ? availability : quality;
4333
4400
  return {
4334
- gated: lowerBound > cfg.lowerBoundThreshold,
4335
- rate: normalized.nFail / normalized.n,
4401
+ gated: quality.gated || availability.gated,
4402
+ axis,
4403
+ rate: lead.rate,
4404
+ lowerBound: lead.lowerBound,
4405
+ n: lead.n,
4406
+ nFail: lead.nFail,
4407
+ quality,
4408
+ availability,
4409
+ nUnclassified: normalized.nUnclassified
4410
+ };
4411
+ }
4412
+ function judgeAxis(failures, n, minSample, threshold, z) {
4413
+ const lowerBound = wilsonLowerBound(failures, n, z);
4414
+ return {
4415
+ rate: n > 0 ? failures / n : 0,
4336
4416
  lowerBound,
4337
- n: normalized.n,
4338
- nFail: normalized.nFail
4417
+ n,
4418
+ nFail: failures,
4419
+ gated: n >= minSample && lowerBound > threshold
4339
4420
  };
4340
4421
  }
4341
4422
  var snapshots2 = /* @__PURE__ */ new Map();
@@ -5199,9 +5280,13 @@ function detectSingleModelArray(ir, policy) {
5199
5280
  ];
5200
5281
  }
5201
5282
  function suppressedRecommendationReason(ir, archetype, altProfile) {
5202
- if (getMeasuredFailureVerdict({ appId: ir.appId, archetype, model: altProfile.id })?.gated === true) {
5203
- return "measured-failure-gate";
5204
- }
5283
+ const measured = getMeasuredFailureVerdict({
5284
+ appId: ir.appId,
5285
+ archetype,
5286
+ model: altProfile.id
5287
+ });
5288
+ if (measured?.quality.gated === true) return "measured-failure-gate";
5289
+ if (measured?.availability.gated === true) return "measured-unavailable-gate";
5205
5290
  if (ir.constraints?.structuredOutput && effectiveConventions(altProfile).some(
5206
5291
  (c) => c.archetype === archetype && c.structuredOutputHint === "avoid"
5207
5292
  )) {
@@ -5586,7 +5671,8 @@ function compile(ir, opts = {}) {
5586
5671
  rate: verdict.rate,
5587
5672
  lowerBound: verdict.lowerBound,
5588
5673
  n: verdict.n,
5589
- nFail: verdict.nFail
5674
+ nFail: verdict.nFail,
5675
+ axis: verdict.axis ?? "quality"
5590
5676
  });
5591
5677
  }
5592
5678
  }
package/dist/probe.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  compile
3
- } from "./chunk-AFYBZRQV.mjs";
4
- import "./chunk-77AHSX6Y.mjs";
3
+ } from "./chunk-G33BUB43.mjs";
4
+ import "./chunk-2YCTWV4S.mjs";
5
5
  import "./chunk-FEMPY6EC.mjs";
6
6
  import {
7
7
  deriveCliffEvidenceClass,
8
8
  getProfile
9
- } from "./chunk-HHIXHL4O.mjs";
9
+ } from "./chunk-PY4CBZFF.mjs";
10
10
 
11
11
  // src/probe.ts
12
12
  function compileSuppressing(ir, opts) {
@@ -1,4 +1,4 @@
1
- import { l as Provider } from './ir-DyMJ84je.mjs';
1
+ import { l as Provider } from './ir-BZ2qOPMp.mjs';
2
2
  import { IntentArchetypeName } from './dialect.mjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { l as Provider } from './ir-DbvOFKF-.js';
1
+ import { l as Provider } from './ir-CpkidtAd.js';
2
2
  import { IntentArchetypeName } from './dialect.js';
3
3
 
4
4
  /**
package/dist/profiles.js CHANGED
@@ -843,7 +843,12 @@ var PROFILES_RAW = [
843
843
  // "7-8 calls per step" — which was never a claim that only one tool may be
844
844
  // offered. See the note in lower.ts:lowerDeepSeek.
845
845
  parallelToolCalls: true,
846
- structuredOutput: "native",
846
+ structuredOutput: "grammar",
847
+ // alpha.99 — MEASURED 2026-08-29: DeepSeek rejects
848
+ // `response_format: {type:'json_schema'}` outright ("This response_format type is
849
+ // unavailable now"), so there is no schema-enforced mode for `'native'` to name.
850
+ // It supports `json_object` only, and only when the prompt contains the literal
851
+ // word "json" — the lowering emits the instruction that guarantees it.
847
852
  systemPromptMode: "inline",
848
853
  streaming: true,
849
854
  // alpha.96 — the `tool_count@1 -> drop_to_top_relevant` cliff was DELETED.
@@ -937,7 +942,12 @@ var PROFILES_RAW = [
937
942
  // "7-8 calls per step" — which was never a claim that only one tool may be
938
943
  // offered. See the note in lower.ts:lowerDeepSeek.
939
944
  parallelToolCalls: true,
940
- structuredOutput: "native",
945
+ structuredOutput: "grammar",
946
+ // alpha.99 — MEASURED 2026-08-29: DeepSeek rejects
947
+ // `response_format: {type:'json_schema'}` outright ("This response_format type is
948
+ // unavailable now"), so there is no schema-enforced mode for `'native'` to name.
949
+ // It supports `json_object` only, and only when the prompt contains the literal
950
+ // word "json" — the lowering emits the instruction that guarantees it.
941
951
  systemPromptMode: "inline",
942
952
  streaming: true,
943
953
  // alpha.96 — the `tool_count@1 -> drop_to_top_relevant` cliff was DELETED.
package/dist/profiles.mjs CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  registerProfiles,
15
15
  resolveModelAlias,
16
16
  tryGetProfile
17
- } from "./chunk-HHIXHL4O.mjs";
17
+ } from "./chunk-PY4CBZFF.mjs";
18
18
  export {
19
19
  ALIASES,
20
20
  LATENCY_TIER_MS,
@@ -1,4 +1,4 @@
1
- import { j as Adapter, F as FallbackReason, y as SectionKind } from './ir-DyMJ84je.mjs';
1
+ import { j as Adapter, F as FallbackReason, y as SectionKind } from './ir-BZ2qOPMp.mjs';
2
2
 
3
3
  /**
4
4
  * Wire contract for the Glass-Box Chrome extension's brain-poll endpoint.
@@ -1,4 +1,4 @@
1
- import { j as Adapter, F as FallbackReason, y as SectionKind } from './ir-DbvOFKF-.js';
1
+ import { j as Adapter, F as FallbackReason, y as SectionKind } from './ir-CpkidtAd.js';
2
2
 
3
3
  /**
4
4
  * Wire contract for the Glass-Box Chrome extension's brain-poll endpoint.
@@ -1,4 +1,4 @@
1
- import { t as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, n as CallAttempt } from './ir-DyMJ84je.mjs';
1
+ import { t as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, n as CallAttempt } from './ir-BZ2qOPMp.mjs';
2
2
 
3
3
  /**
4
4
  * Glass-Box observability types (alpha.17).
@@ -1,4 +1,4 @@
1
- import { t as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, n as CallAttempt } from './ir-DbvOFKF-.js';
1
+ import { t as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, n as CallAttempt } from './ir-CpkidtAd.js';
2
2
 
3
3
  /**
4
4
  * Glass-Box observability types (alpha.17).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warmdrift/kgauto-compiler",
3
- "version": "2.0.0-alpha.97",
3
+ "version": "2.0.0-alpha.99",
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",