@warmdrift/kgauto-compiler 2.0.0-alpha.26 → 2.0.0-alpha.28
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/dist/{chunk-7MTHFSNY.mjs → chunk-JQGRWJZO.mjs} +181 -48
- package/dist/chunk-WXCFWUCN.mjs +678 -0
- package/dist/glassbox/index.d.mts +3 -3
- package/dist/glassbox/index.d.ts +3 -3
- package/dist/glassbox-routes/index.d.mts +88 -6
- package/dist/glassbox-routes/index.d.ts +88 -6
- package/dist/glassbox-routes/index.js +1820 -8
- package/dist/glassbox-routes/index.mjs +320 -8
- package/dist/index.d.mts +184 -3
- package/dist/index.d.ts +184 -3
- package/dist/index.js +342 -53
- package/dist/index.mjs +108 -581
- package/dist/{ir-B_XX2LAO.d.ts → ir-5W0efxt9.d.ts} +86 -1
- package/dist/{ir-B9zqlwjH.d.mts → ir-MXCJA8L7.d.mts} +86 -1
- package/dist/profiles.d.mts +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/profiles.js +181 -48
- package/dist/profiles.mjs +1 -1
- package/dist/{types-bt0aVJb8.d.ts → types-CiZ9HLIU.d.ts} +1 -1
- package/dist/{types-o9etg93a.d.mts → types-sDZQzPM6.d.mts} +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
2
|
-
import '../ir-
|
|
1
|
+
import { G as GlassboxEvent } from '../types-sDZQzPM6.mjs';
|
|
2
|
+
import { h as Adapter } from '../ir-MXCJA8L7.mjs';
|
|
3
3
|
import '../dialect.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -30,11 +30,93 @@ interface TraceSummary {
|
|
|
30
30
|
tokensOut: number;
|
|
31
31
|
estimatedCostUsd: number;
|
|
32
32
|
}
|
|
33
|
+
|
|
34
|
+
interface AdvisoryRecord {
|
|
35
|
+
level: 'info' | 'warn' | 'critical';
|
|
36
|
+
/** Stable advisory identifier, e.g. "caching-off-on-claude". */
|
|
37
|
+
code: string;
|
|
38
|
+
/** Consumer-renderable message — no internal jargon ("L-040", "R3" etc.). */
|
|
39
|
+
message: string;
|
|
40
|
+
/** Optional secondary one-liner. Renders below `message` in italics. */
|
|
41
|
+
suggestion?: string;
|
|
42
|
+
/** Deep link to the relevant section of `interfaces/kgauto.md` or docs. */
|
|
43
|
+
docsUrl?: string;
|
|
44
|
+
/**
|
|
45
|
+
* alpha.28+ — closed-union adaptation hint surfaced by the advisor when
|
|
46
|
+
* the advisory can be auto-mitigated by a config knob. Renderer surfaces
|
|
47
|
+
* as `→ try toolOrchestration: 'sequential'` on the advisory row.
|
|
48
|
+
*
|
|
49
|
+
* MUST stay byte-identical to Builder C's
|
|
50
|
+
* `BestPracticeAdvisory.suggestedAdaptation` shape (verified at Phase 2
|
|
51
|
+
* integration; the Adapter type itself is the contract).
|
|
52
|
+
*/
|
|
53
|
+
suggestedAdaptation?: Adapter;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Cost-equivalent alternative the chain could have served. Computed at
|
|
57
|
+
* detail-view time by `computeCounterfactuals()` against the served row's
|
|
58
|
+
* observed token counts + archetype + cache state. Up to 2 entries, sorted
|
|
59
|
+
* cheapest first.
|
|
60
|
+
*/
|
|
61
|
+
interface TraceCounterfactual {
|
|
62
|
+
modelId: string;
|
|
63
|
+
estimatedCostUsd: number;
|
|
64
|
+
/** servedCostUsd - estimatedCostUsd (always > 0; only ≥10% savings kept). */
|
|
65
|
+
savingsUsd: number;
|
|
66
|
+
/** 0-100. */
|
|
67
|
+
savingsPercent: number;
|
|
68
|
+
/** Plain-English rationale tying archetype + perf score. */
|
|
69
|
+
reason: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Derived axis-health tri-state for the three Glass-Box dots
|
|
73
|
+
* (input-ratio · cache · fallback). Renderer reads; transformer computes.
|
|
74
|
+
*
|
|
75
|
+
* Thresholds (locked in design contract Phase 0):
|
|
76
|
+
* - inputRatio: green ≤ 0.65 · yellow 0.65–0.85 · red > 0.85
|
|
77
|
+
* - cache (only when historyCacheableTokens > 1000):
|
|
78
|
+
* green if inputCacheHitRatio ≥ 0.5
|
|
79
|
+
* yellow if 0.1 ≤ inputCacheHitRatio < 0.5
|
|
80
|
+
* red if inputCacheHitRatio < 0.1
|
|
81
|
+
* na if historyCacheableTokens ≤ 1000
|
|
82
|
+
* - fallback: red iff fellOverFrom !== undefined && fellOverFrom !== target
|
|
83
|
+
*/
|
|
84
|
+
interface TraceHealth {
|
|
85
|
+
inputRatioStatus: 'green' | 'yellow' | 'red';
|
|
86
|
+
cacheStatus: 'green' | 'yellow' | 'red' | 'na';
|
|
87
|
+
fallbackStatus: 'green' | 'red';
|
|
88
|
+
}
|
|
33
89
|
interface TraceDetail extends TraceSummary {
|
|
34
|
-
mutationsApplied:
|
|
35
|
-
advisories:
|
|
36
|
-
rawRequest?:
|
|
37
|
-
rawResponse?:
|
|
90
|
+
mutationsApplied: string[];
|
|
91
|
+
advisories: AdvisoryRecord[];
|
|
92
|
+
rawRequest?: string;
|
|
93
|
+
rawResponse?: string;
|
|
94
|
+
/** Set when consumer passed a forceModel / fallback fired. */
|
|
95
|
+
requestedModel?: string;
|
|
96
|
+
/** Provider finish reason — 'stop' / 'max_tokens' / 'tool_use' / etc. */
|
|
97
|
+
finishReason?: string;
|
|
98
|
+
/** Time to first token (ms); populated when provider surfaces it. */
|
|
99
|
+
ttftMs?: number;
|
|
100
|
+
/** End-to-end wall-clock (ms); from migration 018. */
|
|
101
|
+
totalMs?: number;
|
|
102
|
+
/** Tools kept after relevance pass. */
|
|
103
|
+
toolsCount?: number;
|
|
104
|
+
/** Number of history messages at compile time. */
|
|
105
|
+
historyDepth?: number;
|
|
106
|
+
/** Rendered system prompt size in characters. */
|
|
107
|
+
systemPromptChars?: number;
|
|
108
|
+
cacheReadInputTokens: number;
|
|
109
|
+
cacheCreationInputTokens: number;
|
|
110
|
+
historyCacheableTokens: number;
|
|
111
|
+
/** Derived: cacheReadInputTokens / max(tokensIn, 1). 0-1. */
|
|
112
|
+
inputCacheHitRatio: number;
|
|
113
|
+
fellOverFrom?: string;
|
|
114
|
+
fallbackReason?: 'rate_limit' | 'provider_auth_failed' | 'provider_error' | 'cliff' | 'cost_cap' | 'contract_violation';
|
|
115
|
+
/** Up to 2 alternatives. Empty array (not undefined) when none qualify. */
|
|
116
|
+
counterfactuals?: TraceCounterfactual[];
|
|
117
|
+
/** Undefined when 7d volume < 5/day (insufficient data). */
|
|
118
|
+
projectedDailyCostUsd?: number;
|
|
119
|
+
health: TraceHealth;
|
|
38
120
|
}
|
|
39
121
|
|
|
40
122
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
2
|
-
import '../ir-
|
|
1
|
+
import { G as GlassboxEvent } from '../types-CiZ9HLIU.js';
|
|
2
|
+
import { h as Adapter } from '../ir-5W0efxt9.js';
|
|
3
3
|
import '../dialect.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -30,11 +30,93 @@ interface TraceSummary {
|
|
|
30
30
|
tokensOut: number;
|
|
31
31
|
estimatedCostUsd: number;
|
|
32
32
|
}
|
|
33
|
+
|
|
34
|
+
interface AdvisoryRecord {
|
|
35
|
+
level: 'info' | 'warn' | 'critical';
|
|
36
|
+
/** Stable advisory identifier, e.g. "caching-off-on-claude". */
|
|
37
|
+
code: string;
|
|
38
|
+
/** Consumer-renderable message — no internal jargon ("L-040", "R3" etc.). */
|
|
39
|
+
message: string;
|
|
40
|
+
/** Optional secondary one-liner. Renders below `message` in italics. */
|
|
41
|
+
suggestion?: string;
|
|
42
|
+
/** Deep link to the relevant section of `interfaces/kgauto.md` or docs. */
|
|
43
|
+
docsUrl?: string;
|
|
44
|
+
/**
|
|
45
|
+
* alpha.28+ — closed-union adaptation hint surfaced by the advisor when
|
|
46
|
+
* the advisory can be auto-mitigated by a config knob. Renderer surfaces
|
|
47
|
+
* as `→ try toolOrchestration: 'sequential'` on the advisory row.
|
|
48
|
+
*
|
|
49
|
+
* MUST stay byte-identical to Builder C's
|
|
50
|
+
* `BestPracticeAdvisory.suggestedAdaptation` shape (verified at Phase 2
|
|
51
|
+
* integration; the Adapter type itself is the contract).
|
|
52
|
+
*/
|
|
53
|
+
suggestedAdaptation?: Adapter;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Cost-equivalent alternative the chain could have served. Computed at
|
|
57
|
+
* detail-view time by `computeCounterfactuals()` against the served row's
|
|
58
|
+
* observed token counts + archetype + cache state. Up to 2 entries, sorted
|
|
59
|
+
* cheapest first.
|
|
60
|
+
*/
|
|
61
|
+
interface TraceCounterfactual {
|
|
62
|
+
modelId: string;
|
|
63
|
+
estimatedCostUsd: number;
|
|
64
|
+
/** servedCostUsd - estimatedCostUsd (always > 0; only ≥10% savings kept). */
|
|
65
|
+
savingsUsd: number;
|
|
66
|
+
/** 0-100. */
|
|
67
|
+
savingsPercent: number;
|
|
68
|
+
/** Plain-English rationale tying archetype + perf score. */
|
|
69
|
+
reason: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Derived axis-health tri-state for the three Glass-Box dots
|
|
73
|
+
* (input-ratio · cache · fallback). Renderer reads; transformer computes.
|
|
74
|
+
*
|
|
75
|
+
* Thresholds (locked in design contract Phase 0):
|
|
76
|
+
* - inputRatio: green ≤ 0.65 · yellow 0.65–0.85 · red > 0.85
|
|
77
|
+
* - cache (only when historyCacheableTokens > 1000):
|
|
78
|
+
* green if inputCacheHitRatio ≥ 0.5
|
|
79
|
+
* yellow if 0.1 ≤ inputCacheHitRatio < 0.5
|
|
80
|
+
* red if inputCacheHitRatio < 0.1
|
|
81
|
+
* na if historyCacheableTokens ≤ 1000
|
|
82
|
+
* - fallback: red iff fellOverFrom !== undefined && fellOverFrom !== target
|
|
83
|
+
*/
|
|
84
|
+
interface TraceHealth {
|
|
85
|
+
inputRatioStatus: 'green' | 'yellow' | 'red';
|
|
86
|
+
cacheStatus: 'green' | 'yellow' | 'red' | 'na';
|
|
87
|
+
fallbackStatus: 'green' | 'red';
|
|
88
|
+
}
|
|
33
89
|
interface TraceDetail extends TraceSummary {
|
|
34
|
-
mutationsApplied:
|
|
35
|
-
advisories:
|
|
36
|
-
rawRequest?:
|
|
37
|
-
rawResponse?:
|
|
90
|
+
mutationsApplied: string[];
|
|
91
|
+
advisories: AdvisoryRecord[];
|
|
92
|
+
rawRequest?: string;
|
|
93
|
+
rawResponse?: string;
|
|
94
|
+
/** Set when consumer passed a forceModel / fallback fired. */
|
|
95
|
+
requestedModel?: string;
|
|
96
|
+
/** Provider finish reason — 'stop' / 'max_tokens' / 'tool_use' / etc. */
|
|
97
|
+
finishReason?: string;
|
|
98
|
+
/** Time to first token (ms); populated when provider surfaces it. */
|
|
99
|
+
ttftMs?: number;
|
|
100
|
+
/** End-to-end wall-clock (ms); from migration 018. */
|
|
101
|
+
totalMs?: number;
|
|
102
|
+
/** Tools kept after relevance pass. */
|
|
103
|
+
toolsCount?: number;
|
|
104
|
+
/** Number of history messages at compile time. */
|
|
105
|
+
historyDepth?: number;
|
|
106
|
+
/** Rendered system prompt size in characters. */
|
|
107
|
+
systemPromptChars?: number;
|
|
108
|
+
cacheReadInputTokens: number;
|
|
109
|
+
cacheCreationInputTokens: number;
|
|
110
|
+
historyCacheableTokens: number;
|
|
111
|
+
/** Derived: cacheReadInputTokens / max(tokensIn, 1). 0-1. */
|
|
112
|
+
inputCacheHitRatio: number;
|
|
113
|
+
fellOverFrom?: string;
|
|
114
|
+
fallbackReason?: 'rate_limit' | 'provider_auth_failed' | 'provider_error' | 'cliff' | 'cost_cap' | 'contract_violation';
|
|
115
|
+
/** Up to 2 alternatives. Empty array (not undefined) when none qualify. */
|
|
116
|
+
counterfactuals?: TraceCounterfactual[];
|
|
117
|
+
/** Undefined when 7d volume < 5/day (insufficient data). */
|
|
118
|
+
projectedDailyCostUsd?: number;
|
|
119
|
+
health: TraceHealth;
|
|
38
120
|
}
|
|
39
121
|
|
|
40
122
|
/**
|