@warmdrift/kgauto-compiler 2.0.0-alpha.19 → 2.0.0-alpha.21
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 +159 -7
- package/dist/index.d.ts +159 -7
- package/dist/index.js +381 -62
- package/dist/index.mjs +373 -62
- package/dist/{ir-C3P4gDt0.d.mts → ir-CruZBtpK.d.mts} +162 -1
- package/dist/{ir-CFHU3BUT.d.ts → ir-Wr5lc8Mi.d.ts} +162 -1
- package/dist/profiles.d.mts +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{types-xeklorHU.d.ts → types-BiZKJU41.d.ts} +1 -1
- package/dist/{types-DWF6mPGg.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, O as OracleScore,
|
|
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';
|
|
@@ -198,7 +198,30 @@ interface OutcomePayload {
|
|
|
198
198
|
ttft_ms?: number;
|
|
199
199
|
history_cacheable_tokens?: number;
|
|
200
200
|
history_tokens_at_compile?: number;
|
|
201
|
+
/**
|
|
202
|
+
* Mirrors `ir.constraints.toolOrchestration` from compile time. NULL when
|
|
203
|
+
* the consumer hadn't adopted the constraint (pre-alpha.20). Powers
|
|
204
|
+
* per-mode model-perf queries on the brain (the L-040 parallel-tool
|
|
205
|
+
* cliff lumps DeepSeek sequential perf with parallel without this).
|
|
206
|
+
*/
|
|
207
|
+
tool_orchestration?: 'parallel' | 'sequential' | 'either' | null;
|
|
201
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* alpha.20 Entry 4: record a quality outcome for a previously-compiled call.
|
|
211
|
+
*
|
|
212
|
+
* Fires after the consumer's UX surfaces an approve/reject event (e.g., user
|
|
213
|
+
* clicks Approve on a hunt result). Joins to the original `compile_outcomes`
|
|
214
|
+
* row via outcomeId — enables per-(model, archetype) approve-rate measurement
|
|
215
|
+
* once N ≥ 10 outcomes accumulate.
|
|
216
|
+
*
|
|
217
|
+
* Fire-and-forget by default (matches record() semantics). Set BrainConfig.sync
|
|
218
|
+
* = true for runtime contexts that can't tolerate fire-and-forget teardown
|
|
219
|
+
* (Vercel Edge, Cloudflare Workers, AWS Lambda) — see L-086.
|
|
220
|
+
*
|
|
221
|
+
* Returns OutcomeResult with ok: false + stable reason on persistence
|
|
222
|
+
* failure. Never throws.
|
|
223
|
+
*/
|
|
224
|
+
declare function recordOutcome(input: RecordOutcomeInput): Promise<OutcomeResult>;
|
|
202
225
|
|
|
203
226
|
/**
|
|
204
227
|
* Oracle contract — how an app tells the brain whether a response was good.
|
|
@@ -475,7 +498,35 @@ interface GetDefaultFallbackChainOpts {
|
|
|
475
498
|
* legacy unfiltered behavior — preserves alpha.9 callers byte-for-byte.
|
|
476
499
|
*/
|
|
477
500
|
reachability?: ReachabilityOpts;
|
|
501
|
+
/**
|
|
502
|
+
* alpha.20 E3: consumer-declared tool-orchestration shape. Currently
|
|
503
|
+
* only affects `archetype: 'hunt'`, where 'sequential' swaps the
|
|
504
|
+
* parallel-tool-tier-0 chain (Flash → Pro → Sonnet → Haiku) for a
|
|
505
|
+
* DeepSeek-tier-0 chain (V4-Pro → Flash → Sonnet) — DeepSeek's L-040
|
|
506
|
+
* parallel-tool cliff doesn't apply when the consumer commits to
|
|
507
|
+
* single-step orchestration.
|
|
508
|
+
*
|
|
509
|
+
* Other archetypes are NOT mode-aware in this release — they ship the
|
|
510
|
+
* same chain regardless of toolOrchestration. Future versions may
|
|
511
|
+
* extend mode-awareness to ask/generate/etc. when brain evidence
|
|
512
|
+
* supports it.
|
|
513
|
+
*
|
|
514
|
+
* Default (omitted or 'either'): parallel chain. Back-compat with all
|
|
515
|
+
* pre-alpha.20 callers.
|
|
516
|
+
*/
|
|
517
|
+
toolOrchestration?: 'parallel' | 'sequential' | 'either';
|
|
478
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* Returns the fallback chain for an archetype as a plain `string[]` of
|
|
521
|
+
* model ids.
|
|
522
|
+
*
|
|
523
|
+
* @deprecated since alpha.21 — prefer
|
|
524
|
+
* {@link getDefaultFallbackChainWithGrounding}, which returns the same chain
|
|
525
|
+
* shape with a `grounding` label on every entry (measured / capability-fact /
|
|
526
|
+
* judgment). The string[] return is preserved indefinitely for back-compat —
|
|
527
|
+
* no functional change in alpha.21. Existing callers don't need to migrate
|
|
528
|
+
* unless they want to surface the grounding gap to users.
|
|
529
|
+
*/
|
|
479
530
|
declare function getDefaultFallbackChain(opts: GetDefaultFallbackChainOpts): string[];
|
|
480
531
|
/**
|
|
481
532
|
* Returns a shallow copy of the hand-curated starter chain for an archetype.
|
|
@@ -487,6 +538,50 @@ declare function getStarterChain(archetype: IntentArchetypeName): string[];
|
|
|
487
538
|
* Useful for the `digest.mjs` readout and consumer audits.
|
|
488
539
|
*/
|
|
489
540
|
declare function getAllStarterChains(): Record<IntentArchetypeName, string[]>;
|
|
541
|
+
/**
|
|
542
|
+
* alpha.20 E3 introspection — returns the sequential-mode overlay for an
|
|
543
|
+
* archetype, or `undefined` when no overlay is registered (the archetype
|
|
544
|
+
* is mode-agnostic and reuses `STARTER_CHAINS[archetype]`).
|
|
545
|
+
*
|
|
546
|
+
* Useful for tests + the `scripts/digest.mjs` operator readout to surface
|
|
547
|
+
* the mode-aware chains.
|
|
548
|
+
*/
|
|
549
|
+
declare function getSequentialStarterChain(archetype: IntentArchetypeName): string[] | undefined;
|
|
550
|
+
/**
|
|
551
|
+
* alpha.21 (s78 Entry 1) — returns the fallback chain as `ChainEntry[]`,
|
|
552
|
+
* with a `grounding` label on every position.
|
|
553
|
+
*
|
|
554
|
+
* Same selection logic as {@link getDefaultFallbackChain} (primary anchoring,
|
|
555
|
+
* blockedModels filter, dedupe, reachability filter, maxDepth cap) — the
|
|
556
|
+
* only difference is the return shape: each position is a `ChainEntry`
|
|
557
|
+
* carrying `{ id, grounding, reason?, n? }` instead of a bare string.
|
|
558
|
+
*
|
|
559
|
+
* Use this when surfacing the chain to consumers who care WHY each entry
|
|
560
|
+
* sits where it sits — Glass-Box panels, operator dashboards, eval
|
|
561
|
+
* scaffolding deciding which entries deserve measurement priority.
|
|
562
|
+
*
|
|
563
|
+
* Returns `[]` when filtering empties the chain (same semantics as the
|
|
564
|
+
* string variant) — consumer decides what to do.
|
|
565
|
+
*/
|
|
566
|
+
declare function getDefaultFallbackChainWithGrounding(opts: GetDefaultFallbackChainOpts): ChainEntry[];
|
|
567
|
+
/**
|
|
568
|
+
* alpha.21 introspection — returns the grounded starter chain for an
|
|
569
|
+
* archetype (no primary anchoring, no policy filtering, no maxDepth cap).
|
|
570
|
+
* Use this when you want the raw, hand-curated grounded chain — every
|
|
571
|
+
* entry carries a `grounding` label and optional reason/n.
|
|
572
|
+
*/
|
|
573
|
+
declare function getStarterChainWithGrounding(archetype: IntentArchetypeName): ChainEntry[];
|
|
574
|
+
/**
|
|
575
|
+
* alpha.21 introspection — all grounded starter chains keyed by archetype.
|
|
576
|
+
* Useful for the `digest.mjs` readout and consumer audits that want to
|
|
577
|
+
* surface the grounding gap across the entire chain table.
|
|
578
|
+
*/
|
|
579
|
+
declare function getAllStarterChainsWithGrounding(): Record<IntentArchetypeName, ChainEntry[]>;
|
|
580
|
+
/**
|
|
581
|
+
* alpha.21 introspection — sequential-mode overlay with grounding labels,
|
|
582
|
+
* or `undefined` when no overlay is registered for the archetype.
|
|
583
|
+
*/
|
|
584
|
+
declare function getSequentialStarterChainWithGrounding(archetype: IntentArchetypeName): ChainEntry[] | undefined;
|
|
490
585
|
|
|
491
586
|
/**
|
|
492
587
|
* chains-brain — alpha.11 KG-11 adapter.
|
|
@@ -523,6 +618,13 @@ declare const loadChainsFromBrain: () => Record<"ask" | "hunt" | "classify" | "s
|
|
|
523
618
|
*/
|
|
524
619
|
|
|
525
620
|
type ArchetypePerfMap = Map<string, Partial<Record<IntentArchetypeName, number>>>;
|
|
621
|
+
/**
|
|
622
|
+
* alpha.21: per-(model, archetype) row count map. Same shape as
|
|
623
|
+
* ArchetypePerfMap but stores brain row counts when the brain backs a
|
|
624
|
+
* placement. Undefined entries → no row count seen → score is the
|
|
625
|
+
* hand-curated cold-start prior (grounding='judgment').
|
|
626
|
+
*/
|
|
627
|
+
type ArchetypePerfNMap = Map<string, Partial<Record<IntentArchetypeName, number>>>;
|
|
526
628
|
/**
|
|
527
629
|
* Sync reader for the brain-driven archetypePerf map. Returns bundled
|
|
528
630
|
* profile.archetypePerf data when brain-query is disabled, cold, or
|
|
@@ -530,11 +632,61 @@ type ArchetypePerfMap = Map<string, Partial<Record<IntentArchetypeName, number>>
|
|
|
530
632
|
*/
|
|
531
633
|
declare const loadArchetypePerfFromBrain: () => ArchetypePerfMap;
|
|
532
634
|
/**
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
635
|
+
* alpha.21 — sync reader for the brain row-count map paired with
|
|
636
|
+
* archetype-perf. Returns empty map (no measured backing) on cold start /
|
|
637
|
+
* brain-down / unreachable — all `getArchetypePerfScore` calls then
|
|
638
|
+
* resolve to `grounding: 'judgment'`. When the brain table includes an
|
|
639
|
+
* `n` column on each row, this map mirrors those counts so consumers can
|
|
640
|
+
* see how many measurements back each score.
|
|
641
|
+
*/
|
|
642
|
+
declare const loadArchetypePerfNFromBrain: () => ArchetypePerfNMap;
|
|
643
|
+
/**
|
|
644
|
+
* Threshold above which a brain row count counts as 'measured' grounding.
|
|
645
|
+
* Below this, the score is treated as 'judgment' (cold-start prior or
|
|
646
|
+
* not-yet-enough-evidence). Mirrors the alpha.20 `getCleanPerfScore`
|
|
647
|
+
* `minRows` default — same rule for consistency.
|
|
648
|
+
*/
|
|
649
|
+
declare const MEASURED_GROUNDING_MIN_N = 10;
|
|
650
|
+
/**
|
|
651
|
+
* alpha.21 — return shape for the extended {@link getArchetypePerfScore}.
|
|
652
|
+
* Wraps the existing 0..10 score with:
|
|
653
|
+
*
|
|
654
|
+
* - `n`: brain row count backing this score (0 when no measurement).
|
|
655
|
+
* - `grounding`: derived label — 'measured' when n >= 10, else 'judgment'.
|
|
656
|
+
*
|
|
657
|
+
* The score itself is unchanged from pre-alpha.21 (numeric, 5 = neutral
|
|
658
|
+
* default). 'capability-fact' is NOT a perf-score grounding — capability
|
|
659
|
+
* decisions live on chain entries, not on perf scores.
|
|
660
|
+
*/
|
|
661
|
+
interface ArchetypePerfScoreResult {
|
|
662
|
+
/** 0..10 perf score. 5 = neutral default when no entry exists. */
|
|
663
|
+
score: number;
|
|
664
|
+
/**
|
|
665
|
+
* Brain row count backing this score. 0 when bundled (cold-start prior)
|
|
666
|
+
* or when the brain row didn't carry an `n` column.
|
|
667
|
+
*/
|
|
668
|
+
n: number;
|
|
669
|
+
/**
|
|
670
|
+
* Provenance — 'measured' when `n >= 10`, else 'judgment'.
|
|
671
|
+
* Never 'capability-fact' (that label is reserved for chain-entry
|
|
672
|
+
* inclusion/exclusion decisions).
|
|
673
|
+
*/
|
|
674
|
+
grounding: Grounding;
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Per-model accessor with grounding (alpha.21). Returns 5 (neutral) when no
|
|
678
|
+
* entry is found — consistent with the master plan §3.3 "missing archetypes
|
|
679
|
+
* default to 5" convention documented in profiles.ts
|
|
680
|
+
* ModelProfile.archetypePerf.
|
|
681
|
+
*
|
|
682
|
+
* Backwards-compat note: pre-alpha.21 callers expected `number` here. The
|
|
683
|
+
* new return shape `{ score, n, grounding }` is a breaking shape change at
|
|
684
|
+
* the type level, but `.score` carries the legacy value. Callers reading
|
|
685
|
+
* `.score` field-by-field continue working; callers using the bare number
|
|
686
|
+
* arithmetically need to switch to `.score`. The migration is single-line
|
|
687
|
+
* (`const x = getArchetypePerfScore(...)` → `const x = getArchetypePerfScore(...).score`).
|
|
536
688
|
*/
|
|
537
|
-
declare function getArchetypePerfScore(modelId: string, archetype: IntentArchetypeName):
|
|
689
|
+
declare function getArchetypePerfScore(modelId: string, archetype: IntentArchetypeName): ArchetypePerfScoreResult;
|
|
538
690
|
|
|
539
691
|
/**
|
|
540
692
|
* pricing-brain — alpha.11 KG-13 adapter.
|
|
@@ -718,4 +870,4 @@ declare const loadAliasesFromBrain: () => Record<string, string>;
|
|
|
718
870
|
*/
|
|
719
871
|
declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
|
|
720
872
|
|
|
721
|
-
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, PROVIDER_ENV_KEYS, type PricingRow, type ProfileToRowOptions, PromptIR, Provider, ProviderOverrides, type ProviderReachability, type ReachabilityOpts, RecordInput, type SupportedProvider, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getAllStarterChains, getArchetypePerfScore, getDefaultFallbackChain, getReachabilityDiagnostic, getStarterChain, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, profileToRow, record, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|
|
873
|
+
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 SupportedProvider, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getAllStarterChains, getAllStarterChainsWithGrounding, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getReachabilityDiagnostic, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStarterChain, getStarterChainWithGrounding, 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, O as OracleScore,
|
|
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';
|
|
@@ -198,7 +198,30 @@ interface OutcomePayload {
|
|
|
198
198
|
ttft_ms?: number;
|
|
199
199
|
history_cacheable_tokens?: number;
|
|
200
200
|
history_tokens_at_compile?: number;
|
|
201
|
+
/**
|
|
202
|
+
* Mirrors `ir.constraints.toolOrchestration` from compile time. NULL when
|
|
203
|
+
* the consumer hadn't adopted the constraint (pre-alpha.20). Powers
|
|
204
|
+
* per-mode model-perf queries on the brain (the L-040 parallel-tool
|
|
205
|
+
* cliff lumps DeepSeek sequential perf with parallel without this).
|
|
206
|
+
*/
|
|
207
|
+
tool_orchestration?: 'parallel' | 'sequential' | 'either' | null;
|
|
201
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* alpha.20 Entry 4: record a quality outcome for a previously-compiled call.
|
|
211
|
+
*
|
|
212
|
+
* Fires after the consumer's UX surfaces an approve/reject event (e.g., user
|
|
213
|
+
* clicks Approve on a hunt result). Joins to the original `compile_outcomes`
|
|
214
|
+
* row via outcomeId — enables per-(model, archetype) approve-rate measurement
|
|
215
|
+
* once N ≥ 10 outcomes accumulate.
|
|
216
|
+
*
|
|
217
|
+
* Fire-and-forget by default (matches record() semantics). Set BrainConfig.sync
|
|
218
|
+
* = true for runtime contexts that can't tolerate fire-and-forget teardown
|
|
219
|
+
* (Vercel Edge, Cloudflare Workers, AWS Lambda) — see L-086.
|
|
220
|
+
*
|
|
221
|
+
* Returns OutcomeResult with ok: false + stable reason on persistence
|
|
222
|
+
* failure. Never throws.
|
|
223
|
+
*/
|
|
224
|
+
declare function recordOutcome(input: RecordOutcomeInput): Promise<OutcomeResult>;
|
|
202
225
|
|
|
203
226
|
/**
|
|
204
227
|
* Oracle contract — how an app tells the brain whether a response was good.
|
|
@@ -475,7 +498,35 @@ interface GetDefaultFallbackChainOpts {
|
|
|
475
498
|
* legacy unfiltered behavior — preserves alpha.9 callers byte-for-byte.
|
|
476
499
|
*/
|
|
477
500
|
reachability?: ReachabilityOpts;
|
|
501
|
+
/**
|
|
502
|
+
* alpha.20 E3: consumer-declared tool-orchestration shape. Currently
|
|
503
|
+
* only affects `archetype: 'hunt'`, where 'sequential' swaps the
|
|
504
|
+
* parallel-tool-tier-0 chain (Flash → Pro → Sonnet → Haiku) for a
|
|
505
|
+
* DeepSeek-tier-0 chain (V4-Pro → Flash → Sonnet) — DeepSeek's L-040
|
|
506
|
+
* parallel-tool cliff doesn't apply when the consumer commits to
|
|
507
|
+
* single-step orchestration.
|
|
508
|
+
*
|
|
509
|
+
* Other archetypes are NOT mode-aware in this release — they ship the
|
|
510
|
+
* same chain regardless of toolOrchestration. Future versions may
|
|
511
|
+
* extend mode-awareness to ask/generate/etc. when brain evidence
|
|
512
|
+
* supports it.
|
|
513
|
+
*
|
|
514
|
+
* Default (omitted or 'either'): parallel chain. Back-compat with all
|
|
515
|
+
* pre-alpha.20 callers.
|
|
516
|
+
*/
|
|
517
|
+
toolOrchestration?: 'parallel' | 'sequential' | 'either';
|
|
478
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* Returns the fallback chain for an archetype as a plain `string[]` of
|
|
521
|
+
* model ids.
|
|
522
|
+
*
|
|
523
|
+
* @deprecated since alpha.21 — prefer
|
|
524
|
+
* {@link getDefaultFallbackChainWithGrounding}, which returns the same chain
|
|
525
|
+
* shape with a `grounding` label on every entry (measured / capability-fact /
|
|
526
|
+
* judgment). The string[] return is preserved indefinitely for back-compat —
|
|
527
|
+
* no functional change in alpha.21. Existing callers don't need to migrate
|
|
528
|
+
* unless they want to surface the grounding gap to users.
|
|
529
|
+
*/
|
|
479
530
|
declare function getDefaultFallbackChain(opts: GetDefaultFallbackChainOpts): string[];
|
|
480
531
|
/**
|
|
481
532
|
* Returns a shallow copy of the hand-curated starter chain for an archetype.
|
|
@@ -487,6 +538,50 @@ declare function getStarterChain(archetype: IntentArchetypeName): string[];
|
|
|
487
538
|
* Useful for the `digest.mjs` readout and consumer audits.
|
|
488
539
|
*/
|
|
489
540
|
declare function getAllStarterChains(): Record<IntentArchetypeName, string[]>;
|
|
541
|
+
/**
|
|
542
|
+
* alpha.20 E3 introspection — returns the sequential-mode overlay for an
|
|
543
|
+
* archetype, or `undefined` when no overlay is registered (the archetype
|
|
544
|
+
* is mode-agnostic and reuses `STARTER_CHAINS[archetype]`).
|
|
545
|
+
*
|
|
546
|
+
* Useful for tests + the `scripts/digest.mjs` operator readout to surface
|
|
547
|
+
* the mode-aware chains.
|
|
548
|
+
*/
|
|
549
|
+
declare function getSequentialStarterChain(archetype: IntentArchetypeName): string[] | undefined;
|
|
550
|
+
/**
|
|
551
|
+
* alpha.21 (s78 Entry 1) — returns the fallback chain as `ChainEntry[]`,
|
|
552
|
+
* with a `grounding` label on every position.
|
|
553
|
+
*
|
|
554
|
+
* Same selection logic as {@link getDefaultFallbackChain} (primary anchoring,
|
|
555
|
+
* blockedModels filter, dedupe, reachability filter, maxDepth cap) — the
|
|
556
|
+
* only difference is the return shape: each position is a `ChainEntry`
|
|
557
|
+
* carrying `{ id, grounding, reason?, n? }` instead of a bare string.
|
|
558
|
+
*
|
|
559
|
+
* Use this when surfacing the chain to consumers who care WHY each entry
|
|
560
|
+
* sits where it sits — Glass-Box panels, operator dashboards, eval
|
|
561
|
+
* scaffolding deciding which entries deserve measurement priority.
|
|
562
|
+
*
|
|
563
|
+
* Returns `[]` when filtering empties the chain (same semantics as the
|
|
564
|
+
* string variant) — consumer decides what to do.
|
|
565
|
+
*/
|
|
566
|
+
declare function getDefaultFallbackChainWithGrounding(opts: GetDefaultFallbackChainOpts): ChainEntry[];
|
|
567
|
+
/**
|
|
568
|
+
* alpha.21 introspection — returns the grounded starter chain for an
|
|
569
|
+
* archetype (no primary anchoring, no policy filtering, no maxDepth cap).
|
|
570
|
+
* Use this when you want the raw, hand-curated grounded chain — every
|
|
571
|
+
* entry carries a `grounding` label and optional reason/n.
|
|
572
|
+
*/
|
|
573
|
+
declare function getStarterChainWithGrounding(archetype: IntentArchetypeName): ChainEntry[];
|
|
574
|
+
/**
|
|
575
|
+
* alpha.21 introspection — all grounded starter chains keyed by archetype.
|
|
576
|
+
* Useful for the `digest.mjs` readout and consumer audits that want to
|
|
577
|
+
* surface the grounding gap across the entire chain table.
|
|
578
|
+
*/
|
|
579
|
+
declare function getAllStarterChainsWithGrounding(): Record<IntentArchetypeName, ChainEntry[]>;
|
|
580
|
+
/**
|
|
581
|
+
* alpha.21 introspection — sequential-mode overlay with grounding labels,
|
|
582
|
+
* or `undefined` when no overlay is registered for the archetype.
|
|
583
|
+
*/
|
|
584
|
+
declare function getSequentialStarterChainWithGrounding(archetype: IntentArchetypeName): ChainEntry[] | undefined;
|
|
490
585
|
|
|
491
586
|
/**
|
|
492
587
|
* chains-brain — alpha.11 KG-11 adapter.
|
|
@@ -523,6 +618,13 @@ declare const loadChainsFromBrain: () => Record<"ask" | "hunt" | "classify" | "s
|
|
|
523
618
|
*/
|
|
524
619
|
|
|
525
620
|
type ArchetypePerfMap = Map<string, Partial<Record<IntentArchetypeName, number>>>;
|
|
621
|
+
/**
|
|
622
|
+
* alpha.21: per-(model, archetype) row count map. Same shape as
|
|
623
|
+
* ArchetypePerfMap but stores brain row counts when the brain backs a
|
|
624
|
+
* placement. Undefined entries → no row count seen → score is the
|
|
625
|
+
* hand-curated cold-start prior (grounding='judgment').
|
|
626
|
+
*/
|
|
627
|
+
type ArchetypePerfNMap = Map<string, Partial<Record<IntentArchetypeName, number>>>;
|
|
526
628
|
/**
|
|
527
629
|
* Sync reader for the brain-driven archetypePerf map. Returns bundled
|
|
528
630
|
* profile.archetypePerf data when brain-query is disabled, cold, or
|
|
@@ -530,11 +632,61 @@ type ArchetypePerfMap = Map<string, Partial<Record<IntentArchetypeName, number>>
|
|
|
530
632
|
*/
|
|
531
633
|
declare const loadArchetypePerfFromBrain: () => ArchetypePerfMap;
|
|
532
634
|
/**
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
635
|
+
* alpha.21 — sync reader for the brain row-count map paired with
|
|
636
|
+
* archetype-perf. Returns empty map (no measured backing) on cold start /
|
|
637
|
+
* brain-down / unreachable — all `getArchetypePerfScore` calls then
|
|
638
|
+
* resolve to `grounding: 'judgment'`. When the brain table includes an
|
|
639
|
+
* `n` column on each row, this map mirrors those counts so consumers can
|
|
640
|
+
* see how many measurements back each score.
|
|
641
|
+
*/
|
|
642
|
+
declare const loadArchetypePerfNFromBrain: () => ArchetypePerfNMap;
|
|
643
|
+
/**
|
|
644
|
+
* Threshold above which a brain row count counts as 'measured' grounding.
|
|
645
|
+
* Below this, the score is treated as 'judgment' (cold-start prior or
|
|
646
|
+
* not-yet-enough-evidence). Mirrors the alpha.20 `getCleanPerfScore`
|
|
647
|
+
* `minRows` default — same rule for consistency.
|
|
648
|
+
*/
|
|
649
|
+
declare const MEASURED_GROUNDING_MIN_N = 10;
|
|
650
|
+
/**
|
|
651
|
+
* alpha.21 — return shape for the extended {@link getArchetypePerfScore}.
|
|
652
|
+
* Wraps the existing 0..10 score with:
|
|
653
|
+
*
|
|
654
|
+
* - `n`: brain row count backing this score (0 when no measurement).
|
|
655
|
+
* - `grounding`: derived label — 'measured' when n >= 10, else 'judgment'.
|
|
656
|
+
*
|
|
657
|
+
* The score itself is unchanged from pre-alpha.21 (numeric, 5 = neutral
|
|
658
|
+
* default). 'capability-fact' is NOT a perf-score grounding — capability
|
|
659
|
+
* decisions live on chain entries, not on perf scores.
|
|
660
|
+
*/
|
|
661
|
+
interface ArchetypePerfScoreResult {
|
|
662
|
+
/** 0..10 perf score. 5 = neutral default when no entry exists. */
|
|
663
|
+
score: number;
|
|
664
|
+
/**
|
|
665
|
+
* Brain row count backing this score. 0 when bundled (cold-start prior)
|
|
666
|
+
* or when the brain row didn't carry an `n` column.
|
|
667
|
+
*/
|
|
668
|
+
n: number;
|
|
669
|
+
/**
|
|
670
|
+
* Provenance — 'measured' when `n >= 10`, else 'judgment'.
|
|
671
|
+
* Never 'capability-fact' (that label is reserved for chain-entry
|
|
672
|
+
* inclusion/exclusion decisions).
|
|
673
|
+
*/
|
|
674
|
+
grounding: Grounding;
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Per-model accessor with grounding (alpha.21). Returns 5 (neutral) when no
|
|
678
|
+
* entry is found — consistent with the master plan §3.3 "missing archetypes
|
|
679
|
+
* default to 5" convention documented in profiles.ts
|
|
680
|
+
* ModelProfile.archetypePerf.
|
|
681
|
+
*
|
|
682
|
+
* Backwards-compat note: pre-alpha.21 callers expected `number` here. The
|
|
683
|
+
* new return shape `{ score, n, grounding }` is a breaking shape change at
|
|
684
|
+
* the type level, but `.score` carries the legacy value. Callers reading
|
|
685
|
+
* `.score` field-by-field continue working; callers using the bare number
|
|
686
|
+
* arithmetically need to switch to `.score`. The migration is single-line
|
|
687
|
+
* (`const x = getArchetypePerfScore(...)` → `const x = getArchetypePerfScore(...).score`).
|
|
536
688
|
*/
|
|
537
|
-
declare function getArchetypePerfScore(modelId: string, archetype: IntentArchetypeName):
|
|
689
|
+
declare function getArchetypePerfScore(modelId: string, archetype: IntentArchetypeName): ArchetypePerfScoreResult;
|
|
538
690
|
|
|
539
691
|
/**
|
|
540
692
|
* pricing-brain — alpha.11 KG-13 adapter.
|
|
@@ -718,4 +870,4 @@ declare const loadAliasesFromBrain: () => Record<string, string>;
|
|
|
718
870
|
*/
|
|
719
871
|
declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
|
|
720
872
|
|
|
721
|
-
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, PROVIDER_ENV_KEYS, type PricingRow, type ProfileToRowOptions, PromptIR, Provider, ProviderOverrides, type ProviderReachability, type ReachabilityOpts, RecordInput, type SupportedProvider, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getAllStarterChains, getArchetypePerfScore, getDefaultFallbackChain, getReachabilityDiagnostic, getStarterChain, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, profileToRow, record, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|
|
873
|
+
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 SupportedProvider, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getAllStarterChains, getAllStarterChainsWithGrounding, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getReachabilityDiagnostic, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStarterChain, getStarterChainWithGrounding, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, profileToRow, record, recordOutcome, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|