@warmdrift/kgauto-compiler 2.0.0-alpha.20 → 2.0.0-alpha.22
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/glassbox/index.d.mts +3 -3
- package/dist/glassbox/index.d.ts +3 -3
- package/dist/glassbox-routes/index.d.mts +2 -2
- package/dist/glassbox-routes/index.d.ts +2 -2
- package/dist/index.d.mts +153 -8
- package/dist/index.d.ts +153 -8
- package/dist/index.js +455 -181
- package/dist/index.mjs +447 -181
- package/dist/{ir-DTMbSnyE.d.mts → ir-CruZBtpK.d.mts} +56 -1
- package/dist/{ir-CsTU4cMB.d.ts → ir-Wr5lc8Mi.d.ts} +56 -1
- package/dist/profiles.d.mts +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{types-CwtaDaWN.d.ts → types-BiZKJU41.d.ts} +1 -1
- package/dist/{types-BYj1Kl2m.d.mts → types-zk238uNL.d.mts} +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
2
|
-
export { A as AdvisoryFiredData, C as CompileDoneData, a as CompileStartData, E as ExecuteAttemptData, b as ExecuteSuccessData, F as FallbackWalkedData, c as GLASSBOX_STREAM_TTL_MS, d as GlassboxEventKind, e as GlassboxPubSub } from '../types-
|
|
3
|
-
import '../ir-
|
|
1
|
+
import { G as GlassboxEvent } from '../types-zk238uNL.mjs';
|
|
2
|
+
export { A as AdvisoryFiredData, C as CompileDoneData, a as CompileStartData, E as ExecuteAttemptData, b as ExecuteSuccessData, F as FallbackWalkedData, c as GLASSBOX_STREAM_TTL_MS, d as GlassboxEventKind, e as GlassboxPubSub } from '../types-zk238uNL.mjs';
|
|
3
|
+
import '../ir-CruZBtpK.mjs';
|
|
4
4
|
import '../dialect.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/glassbox/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
2
|
-
export { A as AdvisoryFiredData, C as CompileDoneData, a as CompileStartData, E as ExecuteAttemptData, b as ExecuteSuccessData, F as FallbackWalkedData, c as GLASSBOX_STREAM_TTL_MS, d as GlassboxEventKind, e as GlassboxPubSub } from '../types-
|
|
3
|
-
import '../ir-
|
|
1
|
+
import { G as GlassboxEvent } from '../types-BiZKJU41.js';
|
|
2
|
+
export { A as AdvisoryFiredData, C as CompileDoneData, a as CompileStartData, E as ExecuteAttemptData, b as ExecuteSuccessData, F as FallbackWalkedData, c as GLASSBOX_STREAM_TTL_MS, d as GlassboxEventKind, e as GlassboxPubSub } from '../types-BiZKJU41.js';
|
|
3
|
+
import '../ir-Wr5lc8Mi.js';
|
|
4
4
|
import '../dialect.js';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CompilePolicy, N as NormalizedResponse, A as ApiKeys, P as ProviderOverrides, a as CompiledRequest, b as PromptIR, c as CallOptions, d as CallResult, R as RecordInput, e as RecordOutcomeInput, O as OutcomeResult, f as OracleScore, g as CompileResult, B as BestPracticeAdvisory, h as Provider } from './ir-
|
|
2
|
-
export {
|
|
1
|
+
import { C as CompilePolicy, N as NormalizedResponse, A as ApiKeys, P as ProviderOverrides, a as CompiledRequest, b as PromptIR, c as CallOptions, d as CallResult, R as RecordInput, e as RecordOutcomeInput, O as OutcomeResult, f as OracleScore, g as CompileResult, B as BestPracticeAdvisory, h as Provider, i as ChainEntry, G as Grounding } from './ir-CruZBtpK.mjs';
|
|
2
|
+
export { j as CallAttempt, k as CallError, l as ChainWithGrounding, m as Constraints, F as FallbackReason, H as HistoryCachePolicy, I as IntentDeclaration, M as Message, n as MutationApplied, o as NormalizedTokens, p as OutcomeKind, q as PromptSection, T as ToolCall, r as ToolDefinition } from './ir-CruZBtpK.mjs';
|
|
3
3
|
import { ModelProfile } from './profiles.mjs';
|
|
4
4
|
export { ALIASES, CacheStrategy, CliffRule, LoweringSpec, RecoveryRule, StructuredOutputCapability, SystemPromptMode, allProfiles, getProfile, profilesByProvider, tryGetProfile } from './profiles.mjs';
|
|
5
5
|
import { IntentArchetypeName } from './dialect.mjs';
|
|
@@ -326,14 +326,47 @@ declare function countTokens(text: string): number;
|
|
|
326
326
|
|
|
327
327
|
/** Subset of CompileResult fields the advisor needs. */
|
|
328
328
|
type AdvisorContext = Pick<CompileResult, 'target' | 'provider' | 'tokensIn' | 'diagnostics'>;
|
|
329
|
+
/**
|
|
330
|
+
* Optional Phase 2 (alpha.22) context — fallback chain + a profile resolver
|
|
331
|
+
* for cross-model comparison. Three new rules
|
|
332
|
+
* (`cost-mismatched-archetype`, `model-stale-evidence`, `tier-down`) consume
|
|
333
|
+
* this to surface measurement-substrate signals (alpha.20 clean-attribution +
|
|
334
|
+
* alpha.21 grounding labels) as actionable consumer guidance.
|
|
335
|
+
*
|
|
336
|
+
* When `fallbackChain` is empty, rules 1 + 3 stay silent (nothing to
|
|
337
|
+
* compare against). When `profileResolver` is omitted, the rules degrade
|
|
338
|
+
* gracefully — they can still inspect the chosen profile but not chain
|
|
339
|
+
* alternatives. Rule 2 (`model-stale-evidence`) is independent of chain
|
|
340
|
+
* shape and works on the chosen model alone.
|
|
341
|
+
*/
|
|
342
|
+
interface RunAdvisorPhase2Context {
|
|
343
|
+
fallbackChain: string[];
|
|
344
|
+
profileResolver?: (id: string) => ModelProfile | undefined;
|
|
345
|
+
}
|
|
329
346
|
/**
|
|
330
347
|
* Run all phased rules and return collected advisories. Order is fixed so
|
|
331
348
|
* output is stable across runs. The `policy` argument is alpha.9 — the
|
|
332
349
|
* `single-model-array` rule needs to know whether the consumer explicitly
|
|
333
350
|
* declared `posture: 'locked'` (in which case single-model is intentional
|
|
334
351
|
* and shouldn't warn).
|
|
352
|
+
*
|
|
353
|
+
* `phase2` is alpha.22 — gives the advisor access to the fallback chain +
|
|
354
|
+
* a profile resolver so the three new compile-time recommendation rules
|
|
355
|
+
* (`cost-mismatched-archetype`, `model-stale-evidence`, `tier-down`) can
|
|
356
|
+
* compare the chosen model against in-chain alternatives. Optional for
|
|
357
|
+
* backward compatibility with consumers calling `runAdvisor()` directly.
|
|
358
|
+
*/
|
|
359
|
+
declare function runAdvisor(ir: PromptIR, result: AdvisorContext, profile: ModelProfile, policy?: CompilePolicy, phase2?: RunAdvisorPhase2Context): BestPracticeAdvisory[];
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* alpha.22 — sync introspection: is brain-query mode active for a given
|
|
363
|
+
* table? Used by the advisor (`model-stale-evidence` rule) to decide
|
|
364
|
+
* whether a `judgment`-grounded chosen model is a measurement gap worth
|
|
365
|
+
* surfacing. Returns false on cold start, when configureBrain() was never
|
|
366
|
+
* called, or when the consumer explicitly opted the table out via
|
|
367
|
+
* `BrainConfig.brainQuery.<table> = false`.
|
|
335
368
|
*/
|
|
336
|
-
declare function
|
|
369
|
+
declare function isBrainQueryActiveFor(table: string): boolean;
|
|
337
370
|
|
|
338
371
|
/**
|
|
339
372
|
* env.ts — provider env-key resolution + reachability predicates.
|
|
@@ -516,6 +549,17 @@ interface GetDefaultFallbackChainOpts {
|
|
|
516
549
|
*/
|
|
517
550
|
toolOrchestration?: 'parallel' | 'sequential' | 'either';
|
|
518
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
* Returns the fallback chain for an archetype as a plain `string[]` of
|
|
554
|
+
* model ids.
|
|
555
|
+
*
|
|
556
|
+
* @deprecated since alpha.21 — prefer
|
|
557
|
+
* {@link getDefaultFallbackChainWithGrounding}, which returns the same chain
|
|
558
|
+
* shape with a `grounding` label on every entry (measured / capability-fact /
|
|
559
|
+
* judgment). The string[] return is preserved indefinitely for back-compat —
|
|
560
|
+
* no functional change in alpha.21. Existing callers don't need to migrate
|
|
561
|
+
* unless they want to surface the grounding gap to users.
|
|
562
|
+
*/
|
|
519
563
|
declare function getDefaultFallbackChain(opts: GetDefaultFallbackChainOpts): string[];
|
|
520
564
|
/**
|
|
521
565
|
* Returns a shallow copy of the hand-curated starter chain for an archetype.
|
|
@@ -527,6 +571,50 @@ declare function getStarterChain(archetype: IntentArchetypeName): string[];
|
|
|
527
571
|
* Useful for the `digest.mjs` readout and consumer audits.
|
|
528
572
|
*/
|
|
529
573
|
declare function getAllStarterChains(): Record<IntentArchetypeName, string[]>;
|
|
574
|
+
/**
|
|
575
|
+
* alpha.20 E3 introspection — returns the sequential-mode overlay for an
|
|
576
|
+
* archetype, or `undefined` when no overlay is registered (the archetype
|
|
577
|
+
* is mode-agnostic and reuses `STARTER_CHAINS[archetype]`).
|
|
578
|
+
*
|
|
579
|
+
* Useful for tests + the `scripts/digest.mjs` operator readout to surface
|
|
580
|
+
* the mode-aware chains.
|
|
581
|
+
*/
|
|
582
|
+
declare function getSequentialStarterChain(archetype: IntentArchetypeName): string[] | undefined;
|
|
583
|
+
/**
|
|
584
|
+
* alpha.21 (s78 Entry 1) — returns the fallback chain as `ChainEntry[]`,
|
|
585
|
+
* with a `grounding` label on every position.
|
|
586
|
+
*
|
|
587
|
+
* Same selection logic as {@link getDefaultFallbackChain} (primary anchoring,
|
|
588
|
+
* blockedModels filter, dedupe, reachability filter, maxDepth cap) — the
|
|
589
|
+
* only difference is the return shape: each position is a `ChainEntry`
|
|
590
|
+
* carrying `{ id, grounding, reason?, n? }` instead of a bare string.
|
|
591
|
+
*
|
|
592
|
+
* Use this when surfacing the chain to consumers who care WHY each entry
|
|
593
|
+
* sits where it sits — Glass-Box panels, operator dashboards, eval
|
|
594
|
+
* scaffolding deciding which entries deserve measurement priority.
|
|
595
|
+
*
|
|
596
|
+
* Returns `[]` when filtering empties the chain (same semantics as the
|
|
597
|
+
* string variant) — consumer decides what to do.
|
|
598
|
+
*/
|
|
599
|
+
declare function getDefaultFallbackChainWithGrounding(opts: GetDefaultFallbackChainOpts): ChainEntry[];
|
|
600
|
+
/**
|
|
601
|
+
* alpha.21 introspection — returns the grounded starter chain for an
|
|
602
|
+
* archetype (no primary anchoring, no policy filtering, no maxDepth cap).
|
|
603
|
+
* Use this when you want the raw, hand-curated grounded chain — every
|
|
604
|
+
* entry carries a `grounding` label and optional reason/n.
|
|
605
|
+
*/
|
|
606
|
+
declare function getStarterChainWithGrounding(archetype: IntentArchetypeName): ChainEntry[];
|
|
607
|
+
/**
|
|
608
|
+
* alpha.21 introspection — all grounded starter chains keyed by archetype.
|
|
609
|
+
* Useful for the `digest.mjs` readout and consumer audits that want to
|
|
610
|
+
* surface the grounding gap across the entire chain table.
|
|
611
|
+
*/
|
|
612
|
+
declare function getAllStarterChainsWithGrounding(): Record<IntentArchetypeName, ChainEntry[]>;
|
|
613
|
+
/**
|
|
614
|
+
* alpha.21 introspection — sequential-mode overlay with grounding labels,
|
|
615
|
+
* or `undefined` when no overlay is registered for the archetype.
|
|
616
|
+
*/
|
|
617
|
+
declare function getSequentialStarterChainWithGrounding(archetype: IntentArchetypeName): ChainEntry[] | undefined;
|
|
530
618
|
|
|
531
619
|
/**
|
|
532
620
|
* chains-brain — alpha.11 KG-11 adapter.
|
|
@@ -563,6 +651,13 @@ declare const loadChainsFromBrain: () => Record<"ask" | "hunt" | "classify" | "s
|
|
|
563
651
|
*/
|
|
564
652
|
|
|
565
653
|
type ArchetypePerfMap = Map<string, Partial<Record<IntentArchetypeName, number>>>;
|
|
654
|
+
/**
|
|
655
|
+
* alpha.21: per-(model, archetype) row count map. Same shape as
|
|
656
|
+
* ArchetypePerfMap but stores brain row counts when the brain backs a
|
|
657
|
+
* placement. Undefined entries → no row count seen → score is the
|
|
658
|
+
* hand-curated cold-start prior (grounding='judgment').
|
|
659
|
+
*/
|
|
660
|
+
type ArchetypePerfNMap = Map<string, Partial<Record<IntentArchetypeName, number>>>;
|
|
566
661
|
/**
|
|
567
662
|
* Sync reader for the brain-driven archetypePerf map. Returns bundled
|
|
568
663
|
* profile.archetypePerf data when brain-query is disabled, cold, or
|
|
@@ -570,11 +665,61 @@ type ArchetypePerfMap = Map<string, Partial<Record<IntentArchetypeName, number>>
|
|
|
570
665
|
*/
|
|
571
666
|
declare const loadArchetypePerfFromBrain: () => ArchetypePerfMap;
|
|
572
667
|
/**
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
668
|
+
* alpha.21 — sync reader for the brain row-count map paired with
|
|
669
|
+
* archetype-perf. Returns empty map (no measured backing) on cold start /
|
|
670
|
+
* brain-down / unreachable — all `getArchetypePerfScore` calls then
|
|
671
|
+
* resolve to `grounding: 'judgment'`. When the brain table includes an
|
|
672
|
+
* `n` column on each row, this map mirrors those counts so consumers can
|
|
673
|
+
* see how many measurements back each score.
|
|
674
|
+
*/
|
|
675
|
+
declare const loadArchetypePerfNFromBrain: () => ArchetypePerfNMap;
|
|
676
|
+
/**
|
|
677
|
+
* Threshold above which a brain row count counts as 'measured' grounding.
|
|
678
|
+
* Below this, the score is treated as 'judgment' (cold-start prior or
|
|
679
|
+
* not-yet-enough-evidence). Mirrors the alpha.20 `getCleanPerfScore`
|
|
680
|
+
* `minRows` default — same rule for consistency.
|
|
681
|
+
*/
|
|
682
|
+
declare const MEASURED_GROUNDING_MIN_N = 10;
|
|
683
|
+
/**
|
|
684
|
+
* alpha.21 — return shape for the extended {@link getArchetypePerfScore}.
|
|
685
|
+
* Wraps the existing 0..10 score with:
|
|
686
|
+
*
|
|
687
|
+
* - `n`: brain row count backing this score (0 when no measurement).
|
|
688
|
+
* - `grounding`: derived label — 'measured' when n >= 10, else 'judgment'.
|
|
689
|
+
*
|
|
690
|
+
* The score itself is unchanged from pre-alpha.21 (numeric, 5 = neutral
|
|
691
|
+
* default). 'capability-fact' is NOT a perf-score grounding — capability
|
|
692
|
+
* decisions live on chain entries, not on perf scores.
|
|
693
|
+
*/
|
|
694
|
+
interface ArchetypePerfScoreResult {
|
|
695
|
+
/** 0..10 perf score. 5 = neutral default when no entry exists. */
|
|
696
|
+
score: number;
|
|
697
|
+
/**
|
|
698
|
+
* Brain row count backing this score. 0 when bundled (cold-start prior)
|
|
699
|
+
* or when the brain row didn't carry an `n` column.
|
|
700
|
+
*/
|
|
701
|
+
n: number;
|
|
702
|
+
/**
|
|
703
|
+
* Provenance — 'measured' when `n >= 10`, else 'judgment'.
|
|
704
|
+
* Never 'capability-fact' (that label is reserved for chain-entry
|
|
705
|
+
* inclusion/exclusion decisions).
|
|
706
|
+
*/
|
|
707
|
+
grounding: Grounding;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Per-model accessor with grounding (alpha.21). Returns 5 (neutral) when no
|
|
711
|
+
* entry is found — consistent with the master plan §3.3 "missing archetypes
|
|
712
|
+
* default to 5" convention documented in profiles.ts
|
|
713
|
+
* ModelProfile.archetypePerf.
|
|
714
|
+
*
|
|
715
|
+
* Backwards-compat note: pre-alpha.21 callers expected `number` here. The
|
|
716
|
+
* new return shape `{ score, n, grounding }` is a breaking shape change at
|
|
717
|
+
* the type level, but `.score` carries the legacy value. Callers reading
|
|
718
|
+
* `.score` field-by-field continue working; callers using the bare number
|
|
719
|
+
* arithmetically need to switch to `.score`. The migration is single-line
|
|
720
|
+
* (`const x = getArchetypePerfScore(...)` → `const x = getArchetypePerfScore(...).score`).
|
|
576
721
|
*/
|
|
577
|
-
declare function getArchetypePerfScore(modelId: string, archetype: IntentArchetypeName):
|
|
722
|
+
declare function getArchetypePerfScore(modelId: string, archetype: IntentArchetypeName): ArchetypePerfScoreResult;
|
|
578
723
|
|
|
579
724
|
/**
|
|
580
725
|
* pricing-brain — alpha.11 KG-13 adapter.
|
|
@@ -758,4 +903,4 @@ declare const loadAliasesFromBrain: () => Record<string, string>;
|
|
|
758
903
|
*/
|
|
759
904
|
declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
|
|
760
905
|
|
|
761
|
-
export { ApiKeys, type AppOracle, type ArchetypePerfMap, BestPracticeAdvisory, type BrainConfig, type BrainQueryConfig, CallOptions, CallResult, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, type GetDefaultFallbackChainOpts, IntentArchetypeName, type LLMJudgeOptions, type ModelBrainRow, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, PROVIDER_ENV_KEYS, type PricingRow, type ProfileToRowOptions, PromptIR, Provider, ProviderOverrides, type ProviderReachability, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type SupportedProvider, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getAllStarterChains, getArchetypePerfScore, getDefaultFallbackChain, getReachabilityDiagnostic, getStarterChain, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, profileToRow, record, recordOutcome, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|
|
906
|
+
export { ApiKeys, type AppOracle, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, BestPracticeAdvisory, type BrainConfig, type BrainQueryConfig, CallOptions, CallResult, ChainEntry, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, type GetDefaultFallbackChainOpts, Grounding, IntentArchetypeName, type LLMJudgeOptions, MEASURED_GROUNDING_MIN_N, type ModelBrainRow, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, PROVIDER_ENV_KEYS, type PricingRow, type ProfileToRowOptions, PromptIR, Provider, ProviderOverrides, type ProviderReachability, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, type SupportedProvider, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getAllStarterChains, getAllStarterChainsWithGrounding, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getReachabilityDiagnostic, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStarterChain, getStarterChainWithGrounding, isBrainQueryActiveFor, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, profileToRow, record, recordOutcome, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CompilePolicy, N as NormalizedResponse, A as ApiKeys, P as ProviderOverrides, a as CompiledRequest, b as PromptIR, c as CallOptions, d as CallResult, R as RecordInput, e as RecordOutcomeInput, O as OutcomeResult, f as OracleScore, g as CompileResult, B as BestPracticeAdvisory, h as Provider } from './ir-
|
|
2
|
-
export {
|
|
1
|
+
import { C as CompilePolicy, N as NormalizedResponse, A as ApiKeys, P as ProviderOverrides, a as CompiledRequest, b as PromptIR, c as CallOptions, d as CallResult, R as RecordInput, e as RecordOutcomeInput, O as OutcomeResult, f as OracleScore, g as CompileResult, B as BestPracticeAdvisory, h as Provider, i as ChainEntry, G as Grounding } from './ir-Wr5lc8Mi.js';
|
|
2
|
+
export { j as CallAttempt, k as CallError, l as ChainWithGrounding, m as Constraints, F as FallbackReason, H as HistoryCachePolicy, I as IntentDeclaration, M as Message, n as MutationApplied, o as NormalizedTokens, p as OutcomeKind, q as PromptSection, T as ToolCall, r as ToolDefinition } from './ir-Wr5lc8Mi.js';
|
|
3
3
|
import { ModelProfile } from './profiles.js';
|
|
4
4
|
export { ALIASES, CacheStrategy, CliffRule, LoweringSpec, RecoveryRule, StructuredOutputCapability, SystemPromptMode, allProfiles, getProfile, profilesByProvider, tryGetProfile } from './profiles.js';
|
|
5
5
|
import { IntentArchetypeName } from './dialect.js';
|
|
@@ -326,14 +326,47 @@ declare function countTokens(text: string): number;
|
|
|
326
326
|
|
|
327
327
|
/** Subset of CompileResult fields the advisor needs. */
|
|
328
328
|
type AdvisorContext = Pick<CompileResult, 'target' | 'provider' | 'tokensIn' | 'diagnostics'>;
|
|
329
|
+
/**
|
|
330
|
+
* Optional Phase 2 (alpha.22) context — fallback chain + a profile resolver
|
|
331
|
+
* for cross-model comparison. Three new rules
|
|
332
|
+
* (`cost-mismatched-archetype`, `model-stale-evidence`, `tier-down`) consume
|
|
333
|
+
* this to surface measurement-substrate signals (alpha.20 clean-attribution +
|
|
334
|
+
* alpha.21 grounding labels) as actionable consumer guidance.
|
|
335
|
+
*
|
|
336
|
+
* When `fallbackChain` is empty, rules 1 + 3 stay silent (nothing to
|
|
337
|
+
* compare against). When `profileResolver` is omitted, the rules degrade
|
|
338
|
+
* gracefully — they can still inspect the chosen profile but not chain
|
|
339
|
+
* alternatives. Rule 2 (`model-stale-evidence`) is independent of chain
|
|
340
|
+
* shape and works on the chosen model alone.
|
|
341
|
+
*/
|
|
342
|
+
interface RunAdvisorPhase2Context {
|
|
343
|
+
fallbackChain: string[];
|
|
344
|
+
profileResolver?: (id: string) => ModelProfile | undefined;
|
|
345
|
+
}
|
|
329
346
|
/**
|
|
330
347
|
* Run all phased rules and return collected advisories. Order is fixed so
|
|
331
348
|
* output is stable across runs. The `policy` argument is alpha.9 — the
|
|
332
349
|
* `single-model-array` rule needs to know whether the consumer explicitly
|
|
333
350
|
* declared `posture: 'locked'` (in which case single-model is intentional
|
|
334
351
|
* and shouldn't warn).
|
|
352
|
+
*
|
|
353
|
+
* `phase2` is alpha.22 — gives the advisor access to the fallback chain +
|
|
354
|
+
* a profile resolver so the three new compile-time recommendation rules
|
|
355
|
+
* (`cost-mismatched-archetype`, `model-stale-evidence`, `tier-down`) can
|
|
356
|
+
* compare the chosen model against in-chain alternatives. Optional for
|
|
357
|
+
* backward compatibility with consumers calling `runAdvisor()` directly.
|
|
358
|
+
*/
|
|
359
|
+
declare function runAdvisor(ir: PromptIR, result: AdvisorContext, profile: ModelProfile, policy?: CompilePolicy, phase2?: RunAdvisorPhase2Context): BestPracticeAdvisory[];
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* alpha.22 — sync introspection: is brain-query mode active for a given
|
|
363
|
+
* table? Used by the advisor (`model-stale-evidence` rule) to decide
|
|
364
|
+
* whether a `judgment`-grounded chosen model is a measurement gap worth
|
|
365
|
+
* surfacing. Returns false on cold start, when configureBrain() was never
|
|
366
|
+
* called, or when the consumer explicitly opted the table out via
|
|
367
|
+
* `BrainConfig.brainQuery.<table> = false`.
|
|
335
368
|
*/
|
|
336
|
-
declare function
|
|
369
|
+
declare function isBrainQueryActiveFor(table: string): boolean;
|
|
337
370
|
|
|
338
371
|
/**
|
|
339
372
|
* env.ts — provider env-key resolution + reachability predicates.
|
|
@@ -516,6 +549,17 @@ interface GetDefaultFallbackChainOpts {
|
|
|
516
549
|
*/
|
|
517
550
|
toolOrchestration?: 'parallel' | 'sequential' | 'either';
|
|
518
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
* Returns the fallback chain for an archetype as a plain `string[]` of
|
|
554
|
+
* model ids.
|
|
555
|
+
*
|
|
556
|
+
* @deprecated since alpha.21 — prefer
|
|
557
|
+
* {@link getDefaultFallbackChainWithGrounding}, which returns the same chain
|
|
558
|
+
* shape with a `grounding` label on every entry (measured / capability-fact /
|
|
559
|
+
* judgment). The string[] return is preserved indefinitely for back-compat —
|
|
560
|
+
* no functional change in alpha.21. Existing callers don't need to migrate
|
|
561
|
+
* unless they want to surface the grounding gap to users.
|
|
562
|
+
*/
|
|
519
563
|
declare function getDefaultFallbackChain(opts: GetDefaultFallbackChainOpts): string[];
|
|
520
564
|
/**
|
|
521
565
|
* Returns a shallow copy of the hand-curated starter chain for an archetype.
|
|
@@ -527,6 +571,50 @@ declare function getStarterChain(archetype: IntentArchetypeName): string[];
|
|
|
527
571
|
* Useful for the `digest.mjs` readout and consumer audits.
|
|
528
572
|
*/
|
|
529
573
|
declare function getAllStarterChains(): Record<IntentArchetypeName, string[]>;
|
|
574
|
+
/**
|
|
575
|
+
* alpha.20 E3 introspection — returns the sequential-mode overlay for an
|
|
576
|
+
* archetype, or `undefined` when no overlay is registered (the archetype
|
|
577
|
+
* is mode-agnostic and reuses `STARTER_CHAINS[archetype]`).
|
|
578
|
+
*
|
|
579
|
+
* Useful for tests + the `scripts/digest.mjs` operator readout to surface
|
|
580
|
+
* the mode-aware chains.
|
|
581
|
+
*/
|
|
582
|
+
declare function getSequentialStarterChain(archetype: IntentArchetypeName): string[] | undefined;
|
|
583
|
+
/**
|
|
584
|
+
* alpha.21 (s78 Entry 1) — returns the fallback chain as `ChainEntry[]`,
|
|
585
|
+
* with a `grounding` label on every position.
|
|
586
|
+
*
|
|
587
|
+
* Same selection logic as {@link getDefaultFallbackChain} (primary anchoring,
|
|
588
|
+
* blockedModels filter, dedupe, reachability filter, maxDepth cap) — the
|
|
589
|
+
* only difference is the return shape: each position is a `ChainEntry`
|
|
590
|
+
* carrying `{ id, grounding, reason?, n? }` instead of a bare string.
|
|
591
|
+
*
|
|
592
|
+
* Use this when surfacing the chain to consumers who care WHY each entry
|
|
593
|
+
* sits where it sits — Glass-Box panels, operator dashboards, eval
|
|
594
|
+
* scaffolding deciding which entries deserve measurement priority.
|
|
595
|
+
*
|
|
596
|
+
* Returns `[]` when filtering empties the chain (same semantics as the
|
|
597
|
+
* string variant) — consumer decides what to do.
|
|
598
|
+
*/
|
|
599
|
+
declare function getDefaultFallbackChainWithGrounding(opts: GetDefaultFallbackChainOpts): ChainEntry[];
|
|
600
|
+
/**
|
|
601
|
+
* alpha.21 introspection — returns the grounded starter chain for an
|
|
602
|
+
* archetype (no primary anchoring, no policy filtering, no maxDepth cap).
|
|
603
|
+
* Use this when you want the raw, hand-curated grounded chain — every
|
|
604
|
+
* entry carries a `grounding` label and optional reason/n.
|
|
605
|
+
*/
|
|
606
|
+
declare function getStarterChainWithGrounding(archetype: IntentArchetypeName): ChainEntry[];
|
|
607
|
+
/**
|
|
608
|
+
* alpha.21 introspection — all grounded starter chains keyed by archetype.
|
|
609
|
+
* Useful for the `digest.mjs` readout and consumer audits that want to
|
|
610
|
+
* surface the grounding gap across the entire chain table.
|
|
611
|
+
*/
|
|
612
|
+
declare function getAllStarterChainsWithGrounding(): Record<IntentArchetypeName, ChainEntry[]>;
|
|
613
|
+
/**
|
|
614
|
+
* alpha.21 introspection — sequential-mode overlay with grounding labels,
|
|
615
|
+
* or `undefined` when no overlay is registered for the archetype.
|
|
616
|
+
*/
|
|
617
|
+
declare function getSequentialStarterChainWithGrounding(archetype: IntentArchetypeName): ChainEntry[] | undefined;
|
|
530
618
|
|
|
531
619
|
/**
|
|
532
620
|
* chains-brain — alpha.11 KG-11 adapter.
|
|
@@ -563,6 +651,13 @@ declare const loadChainsFromBrain: () => Record<"ask" | "hunt" | "classify" | "s
|
|
|
563
651
|
*/
|
|
564
652
|
|
|
565
653
|
type ArchetypePerfMap = Map<string, Partial<Record<IntentArchetypeName, number>>>;
|
|
654
|
+
/**
|
|
655
|
+
* alpha.21: per-(model, archetype) row count map. Same shape as
|
|
656
|
+
* ArchetypePerfMap but stores brain row counts when the brain backs a
|
|
657
|
+
* placement. Undefined entries → no row count seen → score is the
|
|
658
|
+
* hand-curated cold-start prior (grounding='judgment').
|
|
659
|
+
*/
|
|
660
|
+
type ArchetypePerfNMap = Map<string, Partial<Record<IntentArchetypeName, number>>>;
|
|
566
661
|
/**
|
|
567
662
|
* Sync reader for the brain-driven archetypePerf map. Returns bundled
|
|
568
663
|
* profile.archetypePerf data when brain-query is disabled, cold, or
|
|
@@ -570,11 +665,61 @@ type ArchetypePerfMap = Map<string, Partial<Record<IntentArchetypeName, number>>
|
|
|
570
665
|
*/
|
|
571
666
|
declare const loadArchetypePerfFromBrain: () => ArchetypePerfMap;
|
|
572
667
|
/**
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
668
|
+
* alpha.21 — sync reader for the brain row-count map paired with
|
|
669
|
+
* archetype-perf. Returns empty map (no measured backing) on cold start /
|
|
670
|
+
* brain-down / unreachable — all `getArchetypePerfScore` calls then
|
|
671
|
+
* resolve to `grounding: 'judgment'`. When the brain table includes an
|
|
672
|
+
* `n` column on each row, this map mirrors those counts so consumers can
|
|
673
|
+
* see how many measurements back each score.
|
|
674
|
+
*/
|
|
675
|
+
declare const loadArchetypePerfNFromBrain: () => ArchetypePerfNMap;
|
|
676
|
+
/**
|
|
677
|
+
* Threshold above which a brain row count counts as 'measured' grounding.
|
|
678
|
+
* Below this, the score is treated as 'judgment' (cold-start prior or
|
|
679
|
+
* not-yet-enough-evidence). Mirrors the alpha.20 `getCleanPerfScore`
|
|
680
|
+
* `minRows` default — same rule for consistency.
|
|
681
|
+
*/
|
|
682
|
+
declare const MEASURED_GROUNDING_MIN_N = 10;
|
|
683
|
+
/**
|
|
684
|
+
* alpha.21 — return shape for the extended {@link getArchetypePerfScore}.
|
|
685
|
+
* Wraps the existing 0..10 score with:
|
|
686
|
+
*
|
|
687
|
+
* - `n`: brain row count backing this score (0 when no measurement).
|
|
688
|
+
* - `grounding`: derived label — 'measured' when n >= 10, else 'judgment'.
|
|
689
|
+
*
|
|
690
|
+
* The score itself is unchanged from pre-alpha.21 (numeric, 5 = neutral
|
|
691
|
+
* default). 'capability-fact' is NOT a perf-score grounding — capability
|
|
692
|
+
* decisions live on chain entries, not on perf scores.
|
|
693
|
+
*/
|
|
694
|
+
interface ArchetypePerfScoreResult {
|
|
695
|
+
/** 0..10 perf score. 5 = neutral default when no entry exists. */
|
|
696
|
+
score: number;
|
|
697
|
+
/**
|
|
698
|
+
* Brain row count backing this score. 0 when bundled (cold-start prior)
|
|
699
|
+
* or when the brain row didn't carry an `n` column.
|
|
700
|
+
*/
|
|
701
|
+
n: number;
|
|
702
|
+
/**
|
|
703
|
+
* Provenance — 'measured' when `n >= 10`, else 'judgment'.
|
|
704
|
+
* Never 'capability-fact' (that label is reserved for chain-entry
|
|
705
|
+
* inclusion/exclusion decisions).
|
|
706
|
+
*/
|
|
707
|
+
grounding: Grounding;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Per-model accessor with grounding (alpha.21). Returns 5 (neutral) when no
|
|
711
|
+
* entry is found — consistent with the master plan §3.3 "missing archetypes
|
|
712
|
+
* default to 5" convention documented in profiles.ts
|
|
713
|
+
* ModelProfile.archetypePerf.
|
|
714
|
+
*
|
|
715
|
+
* Backwards-compat note: pre-alpha.21 callers expected `number` here. The
|
|
716
|
+
* new return shape `{ score, n, grounding }` is a breaking shape change at
|
|
717
|
+
* the type level, but `.score` carries the legacy value. Callers reading
|
|
718
|
+
* `.score` field-by-field continue working; callers using the bare number
|
|
719
|
+
* arithmetically need to switch to `.score`. The migration is single-line
|
|
720
|
+
* (`const x = getArchetypePerfScore(...)` → `const x = getArchetypePerfScore(...).score`).
|
|
576
721
|
*/
|
|
577
|
-
declare function getArchetypePerfScore(modelId: string, archetype: IntentArchetypeName):
|
|
722
|
+
declare function getArchetypePerfScore(modelId: string, archetype: IntentArchetypeName): ArchetypePerfScoreResult;
|
|
578
723
|
|
|
579
724
|
/**
|
|
580
725
|
* pricing-brain — alpha.11 KG-13 adapter.
|
|
@@ -758,4 +903,4 @@ declare const loadAliasesFromBrain: () => Record<string, string>;
|
|
|
758
903
|
*/
|
|
759
904
|
declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
|
|
760
905
|
|
|
761
|
-
export { ApiKeys, type AppOracle, type ArchetypePerfMap, BestPracticeAdvisory, type BrainConfig, type BrainQueryConfig, CallOptions, CallResult, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, type GetDefaultFallbackChainOpts, IntentArchetypeName, type LLMJudgeOptions, type ModelBrainRow, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, PROVIDER_ENV_KEYS, type PricingRow, type ProfileToRowOptions, PromptIR, Provider, ProviderOverrides, type ProviderReachability, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type SupportedProvider, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getAllStarterChains, getArchetypePerfScore, getDefaultFallbackChain, getReachabilityDiagnostic, getStarterChain, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, profileToRow, record, recordOutcome, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|
|
906
|
+
export { ApiKeys, type AppOracle, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, BestPracticeAdvisory, type BrainConfig, type BrainQueryConfig, CallOptions, CallResult, ChainEntry, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, type GetDefaultFallbackChainOpts, Grounding, IntentArchetypeName, type LLMJudgeOptions, MEASURED_GROUNDING_MIN_N, type ModelBrainRow, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, PROVIDER_ENV_KEYS, type PricingRow, type ProfileToRowOptions, PromptIR, Provider, ProviderOverrides, type ProviderReachability, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, type SupportedProvider, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getAllStarterChains, getAllStarterChainsWithGrounding, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getReachabilityDiagnostic, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStarterChain, getStarterChainWithGrounding, isBrainQueryActiveFor, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, profileToRow, record, recordOutcome, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|