@warmdrift/kgauto-compiler 2.0.0-alpha.4 → 2.0.0-alpha.42

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 (40) hide show
  1. package/README.md +87 -3
  2. package/dist/chunk-JQGRWJZO.mjs +1216 -0
  3. package/dist/chunk-KCNQUMHN.mjs +694 -0
  4. package/dist/chunk-NBO4R5PC.mjs +313 -0
  5. package/dist/chunk-P3TOAEG4.mjs +56 -0
  6. package/dist/chunk-RO22VFIF.mjs +29 -0
  7. package/dist/glassbox/index.d.mts +59 -0
  8. package/dist/glassbox/index.d.ts +59 -0
  9. package/dist/glassbox/index.js +312 -0
  10. package/dist/glassbox/index.mjs +12 -0
  11. package/dist/glassbox-routes/format.d.mts +24 -0
  12. package/dist/glassbox-routes/format.d.ts +24 -0
  13. package/dist/glassbox-routes/format.js +86 -0
  14. package/dist/glassbox-routes/format.mjs +18 -0
  15. package/dist/glassbox-routes/index.d.mts +191 -0
  16. package/dist/glassbox-routes/index.d.ts +191 -0
  17. package/dist/glassbox-routes/index.js +2473 -0
  18. package/dist/glassbox-routes/index.mjs +663 -0
  19. package/dist/glassbox-routes/react/index.d.mts +74 -0
  20. package/dist/glassbox-routes/react/index.d.ts +74 -0
  21. package/dist/glassbox-routes/react/index.js +819 -0
  22. package/dist/glassbox-routes/react/index.mjs +754 -0
  23. package/dist/index.d.mts +1796 -9
  24. package/dist/index.d.ts +1796 -9
  25. package/dist/index.js +4771 -312
  26. package/dist/index.mjs +2951 -275
  27. package/dist/ir-BG70lg9b.d.mts +1229 -0
  28. package/dist/ir-BmumS1Du.d.ts +1229 -0
  29. package/dist/profiles.d.mts +164 -2
  30. package/dist/profiles.d.ts +164 -2
  31. package/dist/profiles.js +820 -11
  32. package/dist/profiles.mjs +5 -1
  33. package/dist/types-Cs_hsBGm.d.ts +131 -0
  34. package/dist/types-DIl0tCDX.d.mts +149 -0
  35. package/dist/types-eKKDeADI.d.mts +131 -0
  36. package/dist/types-kFsIDC_5.d.ts +149 -0
  37. package/package.json +42 -6
  38. package/dist/chunk-MBEI5UOM.mjs +0 -409
  39. package/dist/profiles-CDttLtaD.d.ts +0 -521
  40. package/dist/profiles-CH_nKPjp.d.mts +0 -521
@@ -1,2 +1,164 @@
1
- export { f as ALIASES, g as CacheStrategy, j as CliffRule, L as LoweringSpec, M as ModelProfile, q as RecoveryRule, S as StructuredOutputCapability, r as SystemPromptMode, t as allProfiles, u as getProfile, v as profilesByProvider, w as tryGetProfile } from './profiles-CH_nKPjp.mjs';
2
- import './dialect.mjs';
1
+ import { k as Provider } from './ir-BG70lg9b.mjs';
2
+ import { IntentArchetypeName } from './dialect.mjs';
3
+
4
+ /**
5
+ * Model profiles — executable knowledge about each provider/model.
6
+ *
7
+ * Unlike v1 which carried `known_failures` as prose strings, v2 makes them
8
+ * executable: cliffs trigger guards, lowering describes the wire format,
9
+ * recovery handlers describe what to do after specific failures.
10
+ *
11
+ * Each profile is the answer to "if I want to call THIS model with THIS
12
+ * shape of work, what does it need from me, and what should I do when it
13
+ * fails?"
14
+ */
15
+
16
+ type StructuredOutputCapability = 'native' | 'grammar' | 'none';
17
+ type SystemPromptMode = 'inline' | 'separate' | 'as_developer' | 'unsupported';
18
+ type CacheStrategy = 'cache_control' | 'cachedContent' | 'unsupported';
19
+ interface CliffRule {
20
+ /** What metric triggers this cliff. */
21
+ metric: 'input_tokens' | 'tool_count' | 'history_turns' | 'thinking_with_short_output';
22
+ /** Threshold — meaning depends on metric. */
23
+ threshold: number;
24
+ /** What action to take when triggered. */
25
+ action: 'downgrade_quality_warning' | 'drop_to_top_relevant' | 'force_thinking_budget_zero' | 'force_terse_output' | 'escalate_target' | 'strip_tools';
26
+ /**
27
+ * Optional: only fire this cliff when the IR's intent.archetype matches.
28
+ * Used for archetype-specific failure modes (e.g. Gemini Flash returns
29
+ * empty when summarize is offered tools).
30
+ */
31
+ whenIntent?: IntentArchetypeName;
32
+ /** Human-readable reason for digest reporting. */
33
+ reason: string;
34
+ }
35
+ interface RecoveryRule {
36
+ /** What signal triggers recovery. */
37
+ signal: 'empty_response_after_tool' | 'empty_response' | 'malformed_function_call' | 'rate_limit' | 'model_not_found' | 'context_overflow';
38
+ /** Action: retry with adjusted params, or escalate to next fallback. */
39
+ action: 'retry_with_params' | 'escalate' | 'log_only';
40
+ /** When action=retry_with_params, the param adjustments to apply. */
41
+ retryParams?: Record<string, unknown>;
42
+ /** Max retries with this rule. */
43
+ maxRetries?: number;
44
+ /** Human-readable reason for digest reporting. */
45
+ reason: string;
46
+ }
47
+ interface LoweringSpec {
48
+ /** Where the system prompt goes. */
49
+ system: {
50
+ mode: SystemPromptMode;
51
+ field?: string;
52
+ };
53
+ /** Cache strategy + parameters. */
54
+ cache: {
55
+ strategy: CacheStrategy;
56
+ /** Min tokens before caching is worth it (provider rules). */
57
+ minTokens?: number;
58
+ /** Discount factor on cached input (0.1 = 10% of normal price). */
59
+ discount?: number;
60
+ /** TTL hint in seconds. */
61
+ ttlSeconds?: number;
62
+ };
63
+ /** Tool format identifier — see lower.ts for supported formats. */
64
+ tools?: {
65
+ format: 'anthropic' | 'google' | 'openai' | 'deepseek';
66
+ };
67
+ /** Thinking config — present iff this model has a thinking knob. */
68
+ thinking?: {
69
+ /** Field path on the request. */
70
+ field: string;
71
+ /** Default value when caller hasn't specified. */
72
+ default?: number | 'auto' | 'off';
73
+ };
74
+ }
75
+ interface ModelProfile {
76
+ id: string;
77
+ provider: Provider;
78
+ status: 'current' | 'preview' | 'legacy';
79
+ maxContextTokens: number;
80
+ maxOutputTokens: number;
81
+ maxTools: number;
82
+ parallelToolCalls: boolean;
83
+ structuredOutput: StructuredOutputCapability;
84
+ systemPromptMode: SystemPromptMode;
85
+ streaming: boolean;
86
+ cliffs: CliffRule[];
87
+ costInputPer1m: number;
88
+ costOutputPer1m: number;
89
+ lowering: LoweringSpec;
90
+ recovery: RecoveryRule[];
91
+ strengths: string[];
92
+ weaknesses: string[];
93
+ notes?: string;
94
+ verifiedAgainstDocs?: string;
95
+ /**
96
+ * Hand-curated per-archetype performance score on a 0-10 scale.
97
+ *
98
+ * 10 = frontier on this archetype (e.g. Opus 4.7 on critique)
99
+ * 8 = strong second tier (Sonnet on plan, Pro on extract)
100
+ * 7 = competent (Haiku on classify, Flash on hunt)
101
+ * 5 = acceptable for tolerant archetypes (Flash-Lite on classify)
102
+ * 3 = degraded (Flash on critique, DeepSeek on hunt)
103
+ *
104
+ * Missing archetypes default to `5` (no data, neutral). Each non-default
105
+ * value should carry a one-line rationale in the profile's note or inline
106
+ * comment citing brain evidence, family prior, or "starter hypothesis —
107
+ * verify with telemetry."
108
+ *
109
+ * Source today: hand-curated from master plan §3.3 + §6.2 starter tables.
110
+ * Source tomorrow (alpha.10+): brain `archetype_model_evidence` view.
111
+ *
112
+ * Anti-hallucination guardrail (master plan §2.5): when the watcher's
113
+ * `--audit-fields` flag flags a profile stale (>90 days since
114
+ * verifiedAgainstDocs), the archetypePerf values get re-audited
115
+ * alongside capability fields. AI-trained intuition is NOT a valid
116
+ * source — only docs or brain evidence.
117
+ *
118
+ * alpha.9.
119
+ */
120
+ archetypePerf?: Partial<Record<IntentArchetypeName, number>>;
121
+ /**
122
+ * alpha.41 — model-family identifier (e.g. `'claude-opus'`,
123
+ * `'gemini-flash'`). Reads through from `kgauto_models.family` (migration
124
+ * 024). When unset on a brain row, runtime falls back to
125
+ * `deriveFamilyFromModelId(model.id)` (see `family-resolution.ts`).
126
+ *
127
+ * Used by `getRecommendedPrimary({ family, ... })` and the IR-level
128
+ * `{ family: string }` chain entry resolution at compile time.
129
+ */
130
+ family?: string;
131
+ /**
132
+ * alpha.41 — version string of the kgauto release that first introduced
133
+ * this profile (e.g. `'2.0.0-alpha.36'`). Threaded through from the brain
134
+ * row's `version_added` column. Family-resolution sorts candidates by
135
+ * `version_added DESC` (lexicographic) as the secondary tiebreaker after
136
+ * `archetypePerf[archetype]`. Undefined on bundled profiles (no brain
137
+ * row).
138
+ */
139
+ versionAdded?: string;
140
+ /**
141
+ * alpha.41 — whether the brain row is `active = TRUE`. False or undefined
142
+ * means the model is retired / not actively served (kgauto_models row
143
+ * exists but won't be selected by family resolution). Bundled profiles
144
+ * default to `true` when not threaded through (every PROFILES_RAW entry
145
+ * is by definition the active source of truth at bundle time).
146
+ */
147
+ active?: boolean;
148
+ }
149
+ declare const ALIASES: Record<string, string>;
150
+ interface ProfileBrainHook {
151
+ getProfile?: (canonicalId: string) => ModelProfile | undefined;
152
+ resolveAlias?: (id: string) => string | undefined;
153
+ }
154
+ /** @internal — called by models-brain.ts at module load. */
155
+ declare function _setProfileBrainHook(hook: ProfileBrainHook): void;
156
+ declare function getProfile(id: string): ModelProfile;
157
+ declare function tryGetProfile(id: string): ModelProfile | undefined;
158
+ declare function allProfiles(): readonly ModelProfile[];
159
+ /** @internal — bundled-only access for adapters that need a non-brain
160
+ * fallback baseline (avoids a brain → profiles → brain re-entry). */
161
+ declare function allProfilesRaw(): readonly ModelProfile[];
162
+ declare function profilesByProvider(provider: Provider): readonly ModelProfile[];
163
+
164
+ export { ALIASES, type CacheStrategy, type CliffRule, type LoweringSpec, type ModelProfile, type RecoveryRule, type StructuredOutputCapability, type SystemPromptMode, _setProfileBrainHook, allProfiles, allProfilesRaw, getProfile, profilesByProvider, tryGetProfile };
@@ -1,2 +1,164 @@
1
- export { f as ALIASES, g as CacheStrategy, j as CliffRule, L as LoweringSpec, M as ModelProfile, q as RecoveryRule, S as StructuredOutputCapability, r as SystemPromptMode, t as allProfiles, u as getProfile, v as profilesByProvider, w as tryGetProfile } from './profiles-CDttLtaD.js';
2
- import './dialect.js';
1
+ import { k as Provider } from './ir-BmumS1Du.js';
2
+ import { IntentArchetypeName } from './dialect.js';
3
+
4
+ /**
5
+ * Model profiles — executable knowledge about each provider/model.
6
+ *
7
+ * Unlike v1 which carried `known_failures` as prose strings, v2 makes them
8
+ * executable: cliffs trigger guards, lowering describes the wire format,
9
+ * recovery handlers describe what to do after specific failures.
10
+ *
11
+ * Each profile is the answer to "if I want to call THIS model with THIS
12
+ * shape of work, what does it need from me, and what should I do when it
13
+ * fails?"
14
+ */
15
+
16
+ type StructuredOutputCapability = 'native' | 'grammar' | 'none';
17
+ type SystemPromptMode = 'inline' | 'separate' | 'as_developer' | 'unsupported';
18
+ type CacheStrategy = 'cache_control' | 'cachedContent' | 'unsupported';
19
+ interface CliffRule {
20
+ /** What metric triggers this cliff. */
21
+ metric: 'input_tokens' | 'tool_count' | 'history_turns' | 'thinking_with_short_output';
22
+ /** Threshold — meaning depends on metric. */
23
+ threshold: number;
24
+ /** What action to take when triggered. */
25
+ action: 'downgrade_quality_warning' | 'drop_to_top_relevant' | 'force_thinking_budget_zero' | 'force_terse_output' | 'escalate_target' | 'strip_tools';
26
+ /**
27
+ * Optional: only fire this cliff when the IR's intent.archetype matches.
28
+ * Used for archetype-specific failure modes (e.g. Gemini Flash returns
29
+ * empty when summarize is offered tools).
30
+ */
31
+ whenIntent?: IntentArchetypeName;
32
+ /** Human-readable reason for digest reporting. */
33
+ reason: string;
34
+ }
35
+ interface RecoveryRule {
36
+ /** What signal triggers recovery. */
37
+ signal: 'empty_response_after_tool' | 'empty_response' | 'malformed_function_call' | 'rate_limit' | 'model_not_found' | 'context_overflow';
38
+ /** Action: retry with adjusted params, or escalate to next fallback. */
39
+ action: 'retry_with_params' | 'escalate' | 'log_only';
40
+ /** When action=retry_with_params, the param adjustments to apply. */
41
+ retryParams?: Record<string, unknown>;
42
+ /** Max retries with this rule. */
43
+ maxRetries?: number;
44
+ /** Human-readable reason for digest reporting. */
45
+ reason: string;
46
+ }
47
+ interface LoweringSpec {
48
+ /** Where the system prompt goes. */
49
+ system: {
50
+ mode: SystemPromptMode;
51
+ field?: string;
52
+ };
53
+ /** Cache strategy + parameters. */
54
+ cache: {
55
+ strategy: CacheStrategy;
56
+ /** Min tokens before caching is worth it (provider rules). */
57
+ minTokens?: number;
58
+ /** Discount factor on cached input (0.1 = 10% of normal price). */
59
+ discount?: number;
60
+ /** TTL hint in seconds. */
61
+ ttlSeconds?: number;
62
+ };
63
+ /** Tool format identifier — see lower.ts for supported formats. */
64
+ tools?: {
65
+ format: 'anthropic' | 'google' | 'openai' | 'deepseek';
66
+ };
67
+ /** Thinking config — present iff this model has a thinking knob. */
68
+ thinking?: {
69
+ /** Field path on the request. */
70
+ field: string;
71
+ /** Default value when caller hasn't specified. */
72
+ default?: number | 'auto' | 'off';
73
+ };
74
+ }
75
+ interface ModelProfile {
76
+ id: string;
77
+ provider: Provider;
78
+ status: 'current' | 'preview' | 'legacy';
79
+ maxContextTokens: number;
80
+ maxOutputTokens: number;
81
+ maxTools: number;
82
+ parallelToolCalls: boolean;
83
+ structuredOutput: StructuredOutputCapability;
84
+ systemPromptMode: SystemPromptMode;
85
+ streaming: boolean;
86
+ cliffs: CliffRule[];
87
+ costInputPer1m: number;
88
+ costOutputPer1m: number;
89
+ lowering: LoweringSpec;
90
+ recovery: RecoveryRule[];
91
+ strengths: string[];
92
+ weaknesses: string[];
93
+ notes?: string;
94
+ verifiedAgainstDocs?: string;
95
+ /**
96
+ * Hand-curated per-archetype performance score on a 0-10 scale.
97
+ *
98
+ * 10 = frontier on this archetype (e.g. Opus 4.7 on critique)
99
+ * 8 = strong second tier (Sonnet on plan, Pro on extract)
100
+ * 7 = competent (Haiku on classify, Flash on hunt)
101
+ * 5 = acceptable for tolerant archetypes (Flash-Lite on classify)
102
+ * 3 = degraded (Flash on critique, DeepSeek on hunt)
103
+ *
104
+ * Missing archetypes default to `5` (no data, neutral). Each non-default
105
+ * value should carry a one-line rationale in the profile's note or inline
106
+ * comment citing brain evidence, family prior, or "starter hypothesis —
107
+ * verify with telemetry."
108
+ *
109
+ * Source today: hand-curated from master plan §3.3 + §6.2 starter tables.
110
+ * Source tomorrow (alpha.10+): brain `archetype_model_evidence` view.
111
+ *
112
+ * Anti-hallucination guardrail (master plan §2.5): when the watcher's
113
+ * `--audit-fields` flag flags a profile stale (>90 days since
114
+ * verifiedAgainstDocs), the archetypePerf values get re-audited
115
+ * alongside capability fields. AI-trained intuition is NOT a valid
116
+ * source — only docs or brain evidence.
117
+ *
118
+ * alpha.9.
119
+ */
120
+ archetypePerf?: Partial<Record<IntentArchetypeName, number>>;
121
+ /**
122
+ * alpha.41 — model-family identifier (e.g. `'claude-opus'`,
123
+ * `'gemini-flash'`). Reads through from `kgauto_models.family` (migration
124
+ * 024). When unset on a brain row, runtime falls back to
125
+ * `deriveFamilyFromModelId(model.id)` (see `family-resolution.ts`).
126
+ *
127
+ * Used by `getRecommendedPrimary({ family, ... })` and the IR-level
128
+ * `{ family: string }` chain entry resolution at compile time.
129
+ */
130
+ family?: string;
131
+ /**
132
+ * alpha.41 — version string of the kgauto release that first introduced
133
+ * this profile (e.g. `'2.0.0-alpha.36'`). Threaded through from the brain
134
+ * row's `version_added` column. Family-resolution sorts candidates by
135
+ * `version_added DESC` (lexicographic) as the secondary tiebreaker after
136
+ * `archetypePerf[archetype]`. Undefined on bundled profiles (no brain
137
+ * row).
138
+ */
139
+ versionAdded?: string;
140
+ /**
141
+ * alpha.41 — whether the brain row is `active = TRUE`. False or undefined
142
+ * means the model is retired / not actively served (kgauto_models row
143
+ * exists but won't be selected by family resolution). Bundled profiles
144
+ * default to `true` when not threaded through (every PROFILES_RAW entry
145
+ * is by definition the active source of truth at bundle time).
146
+ */
147
+ active?: boolean;
148
+ }
149
+ declare const ALIASES: Record<string, string>;
150
+ interface ProfileBrainHook {
151
+ getProfile?: (canonicalId: string) => ModelProfile | undefined;
152
+ resolveAlias?: (id: string) => string | undefined;
153
+ }
154
+ /** @internal — called by models-brain.ts at module load. */
155
+ declare function _setProfileBrainHook(hook: ProfileBrainHook): void;
156
+ declare function getProfile(id: string): ModelProfile;
157
+ declare function tryGetProfile(id: string): ModelProfile | undefined;
158
+ declare function allProfiles(): readonly ModelProfile[];
159
+ /** @internal — bundled-only access for adapters that need a non-brain
160
+ * fallback baseline (avoids a brain → profiles → brain re-entry). */
161
+ declare function allProfilesRaw(): readonly ModelProfile[];
162
+ declare function profilesByProvider(provider: Provider): readonly ModelProfile[];
163
+
164
+ export { ALIASES, type CacheStrategy, type CliffRule, type LoweringSpec, type ModelProfile, type RecoveryRule, type StructuredOutputCapability, type SystemPromptMode, _setProfileBrainHook, allProfiles, allProfilesRaw, getProfile, profilesByProvider, tryGetProfile };