@warmdrift/kgauto-compiler 2.0.0-alpha.76 → 2.0.0-alpha.77
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-WZZCW6NA.mjs → chunk-GB7VJQ6C.mjs} +1 -1
- package/dist/glassbox/index.d.mts +3 -3
- package/dist/glassbox/index.d.ts +3 -3
- package/dist/glassbox-routes/format.d.mts +2 -2
- package/dist/glassbox-routes/format.d.ts +2 -2
- package/dist/glassbox-routes/index.d.mts +4 -4
- package/dist/glassbox-routes/index.d.ts +4 -4
- package/dist/glassbox-routes/index.js +1 -0
- package/dist/glassbox-routes/index.mjs +1 -0
- package/dist/glassbox-routes/react/index.d.mts +2 -2
- package/dist/glassbox-routes/react/index.d.ts +2 -2
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +43 -8
- package/dist/index.mjs +43 -8
- package/dist/{ir-B0v2f9NY.d.ts → ir-C02EIElQ.d.ts} +16 -6
- package/dist/{ir-CZukZvDn.d.mts → ir-CRV1_taF.d.mts} +16 -6
- package/dist/key-health.js +1 -1
- package/dist/key-health.mjs +1 -1
- package/dist/profiles.d.mts +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{types-Ba68lIs1.d.ts → types-3WdGMqin.d.mts} +2 -9
- package/dist/{types-D-PuKCWk.d.ts → types-C5BX9bzi.d.ts} +1 -1
- package/dist/{types-BgJ5iQB_.d.mts → types-Caq-hOIj.d.mts} +1 -1
- package/dist/{types-BOTLfJOp.d.mts → types-CkRvjxrI.d.ts} +2 -9
- 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-Caq-hOIj.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-Caq-hOIj.mjs';
|
|
3
|
+
import '../ir-CRV1_taF.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-C5BX9bzi.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-C5BX9bzi.js';
|
|
3
|
+
import '../ir-C02EIElQ.js';
|
|
4
4
|
import '../dialect.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
2
|
-
import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-
|
|
3
|
-
export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-
|
|
4
|
-
import '../ir-
|
|
1
|
+
import { G as GlassboxEvent } from '../types-Caq-hOIj.mjs';
|
|
2
|
+
import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-3WdGMqin.mjs';
|
|
3
|
+
export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-3WdGMqin.mjs';
|
|
4
|
+
import '../ir-CRV1_taF.mjs';
|
|
5
5
|
import '../dialect.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
2
|
-
import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-
|
|
3
|
-
export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-
|
|
4
|
-
import '../ir-
|
|
1
|
+
import { G as GlassboxEvent } from '../types-C5BX9bzi.js';
|
|
2
|
+
import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-CkRvjxrI.js';
|
|
3
|
+
export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-CkRvjxrI.js';
|
|
4
|
+
import '../ir-C02EIElQ.js';
|
|
5
5
|
import '../dialect.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { a as TraceDetail } from '../../types-
|
|
3
|
-
import '../../ir-
|
|
2
|
+
import { a as TraceDetail } from '../../types-3WdGMqin.mjs';
|
|
3
|
+
import '../../ir-CRV1_taF.mjs';
|
|
4
4
|
import '../../dialect.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { a as TraceDetail } from '../../types-
|
|
3
|
-
import '../../ir-
|
|
2
|
+
import { a as TraceDetail } from '../../types-CkRvjxrI.js';
|
|
3
|
+
import '../../ir-C02EIElQ.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, S as SystemModelMessage, e as CompileResult, B as BestPracticeAdvisory, f as SectionRewrite, R as RecordInput, g as RecordOutcomeInput, O as OutcomeResult, h as OracleScore, i as Adapter, j as PerAxisMetrics, k as Provider, l as ChainEntry, G as Grounding } from './ir-
|
|
2
|
-
export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel,
|
|
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, S as SystemModelMessage, e as CompileResult, B as BestPracticeAdvisory, F as FallbackReason, f as SectionRewrite, R as RecordInput, g as RecordOutcomeInput, O as OutcomeResult, h as OracleScore, i as Adapter, j as PerAxisMetrics, k as Provider, l as ChainEntry, G as Grounding } from './ir-CRV1_taF.mjs';
|
|
2
|
+
export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel, r as GoldenCaptureOptions, H as HistoryCachePolicy, I as IntentDeclaration, M as Message, s as MutationApplied, t as NormalizedTokens, u as OutcomeKind, v as PerAxisMetricsByModel, w as PromptSection, x as SectionKind, y as ShadowProbeConfig, T as ToolCall, z as ToolDefinition, D as captureGoldenIr, J as parseGoldenCaptureRate, K as resolveGoldenCaptureRate, L as shouldCaptureGolden } from './ir-CRV1_taF.mjs';
|
|
3
3
|
import { ModelProfile, ArchetypeConvention } from './profiles.mjs';
|
|
4
4
|
export { ALIASES, CacheStrategy, CliffRule, LATENCY_TIER_MS, LatencyTier, LoweringSpec, RecoveryRule, StructuredOutputCapability, SystemPromptMode, allProfiles, getProfile, latencyTierOf, profilesByProvider, tryGetProfile } from './profiles.mjs';
|
|
5
5
|
export { BrainForwardConfig, BrainForwardRoutes, createBrainForwardRoutes } from './brain-proxy.mjs';
|
|
@@ -656,7 +656,7 @@ interface OutcomePayload {
|
|
|
656
656
|
history_depth?: number;
|
|
657
657
|
system_prompt_chars?: number;
|
|
658
658
|
fell_over_from?: string;
|
|
659
|
-
fallback_reason?:
|
|
659
|
+
fallback_reason?: FallbackReason;
|
|
660
660
|
/**
|
|
661
661
|
* alpha.71 (migration 044) — the precise `errorCode` behind
|
|
662
662
|
* `fallback_reason`. Key OMITTED when no fallback fired, so brains that
|
|
@@ -1119,7 +1119,7 @@ declare function runStrategyEvalWithAttribution(opts: Omit<GoldenEvalOptions, 'a
|
|
|
1119
1119
|
* guard in `tests/version.test.ts` fails the suite (and therefore
|
|
1120
1120
|
* `prepublishOnly`) when they diverge — a stale constant cannot reach npm.
|
|
1121
1121
|
*/
|
|
1122
|
-
declare const LIBRARY_VERSION = "2.0.0-alpha.
|
|
1122
|
+
declare const LIBRARY_VERSION = "2.0.0-alpha.77";
|
|
1123
1123
|
|
|
1124
1124
|
/**
|
|
1125
1125
|
* Oracle contract — how an app tells the brain whether a response was good.
|
|
@@ -3404,4 +3404,4 @@ declare function planDecomposition(args: PlanDecompositionArgs): DecompositionPl
|
|
|
3404
3404
|
*/
|
|
3405
3405
|
declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
|
|
3406
3406
|
|
|
3407
|
-
export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ARCHETYPE_FAMILY_FITS, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, ArchetypeConvention, type ArchetypeFamilyFit, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, type AttachCacheControlResult, BestPracticeAdvisory, type BrainConfig, type BrainDeadLetterEntry, type BrainHealthSnapshot, type BrainQueryConfig, type BrainReadEnv, COACH_CFG, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, DECOMPOSITION_TEMPLATES, DECOMPOSITION_TEMPLATES_VERSION, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_MEASURED_FAILURE_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, DISCIPLINE_GATES_V1_ALT_HEADER, type DecompositionPlan, type DecompositionStep, type DecompositionTemplate, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type ExecutorCandidate, type FallbackPosture, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetMeasuredFailureOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalAxis, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenEvalStrategyId, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_FAILURE_CFG, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type MeasuredFailureRuntime, type MeasuredFailureVerdict, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, OutputMode, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PlannedStep, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_DISCIPLINE_GATES_V1, RULE_DISCIPLINE_GATES_V1_STRUCTURED, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, STRATEGY_AUTHORSHIP_LIMITATION, SectionRewrite, type ShadowProbeRecordInput, type StrategyAttribution, type StrategyAttributionResult, type StrategyOutcome, type SupportedProvider, type SurfaceFailureRow, type SurfaceStats, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, altGatesBlockFor, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, awaitMeasuredFailureReady, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, classifyStrategyOutcome, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, deriveFamilyFromModelId, deriveOwnership, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isExclusionFindingsBrainActive, isMeasuredFailureBrainActive, isMeasuredFailureGateEnabledFromEnv, isModelReachable, isPromotionsBrainActive, isProviderReachable, judgeMeasuredFailure, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, planDecomposition, prefetchMeasuredFailure, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, runStrategyEvalWithAttribution, setTokenizer, wilsonLowerBound, withAltDisciplineContract, withDisciplineContract };
|
|
3407
|
+
export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ARCHETYPE_FAMILY_FITS, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, ArchetypeConvention, type ArchetypeFamilyFit, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, type AttachCacheControlResult, BestPracticeAdvisory, type BrainConfig, type BrainDeadLetterEntry, type BrainHealthSnapshot, type BrainQueryConfig, type BrainReadEnv, COACH_CFG, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, DECOMPOSITION_TEMPLATES, DECOMPOSITION_TEMPLATES_VERSION, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_MEASURED_FAILURE_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, DISCIPLINE_GATES_V1_ALT_HEADER, type DecompositionPlan, type DecompositionStep, type DecompositionTemplate, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type ExecutorCandidate, type FallbackPosture, FallbackReason, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetMeasuredFailureOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalAxis, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenEvalStrategyId, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_FAILURE_CFG, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type MeasuredFailureRuntime, type MeasuredFailureVerdict, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, OutputMode, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PlannedStep, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_DISCIPLINE_GATES_V1, RULE_DISCIPLINE_GATES_V1_STRUCTURED, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, STRATEGY_AUTHORSHIP_LIMITATION, SectionRewrite, type ShadowProbeRecordInput, type StrategyAttribution, type StrategyAttributionResult, type StrategyOutcome, type SupportedProvider, type SurfaceFailureRow, type SurfaceStats, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, altGatesBlockFor, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, awaitMeasuredFailureReady, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, classifyStrategyOutcome, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, deriveFamilyFromModelId, deriveOwnership, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isExclusionFindingsBrainActive, isMeasuredFailureBrainActive, isMeasuredFailureGateEnabledFromEnv, isModelReachable, isPromotionsBrainActive, isProviderReachable, judgeMeasuredFailure, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, planDecomposition, prefetchMeasuredFailure, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, runStrategyEvalWithAttribution, setTokenizer, wilsonLowerBound, withAltDisciplineContract, withDisciplineContract };
|
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, S as SystemModelMessage, e as CompileResult, B as BestPracticeAdvisory, f as SectionRewrite, R as RecordInput, g as RecordOutcomeInput, O as OutcomeResult, h as OracleScore, i as Adapter, j as PerAxisMetrics, k as Provider, l as ChainEntry, G as Grounding } from './ir-
|
|
2
|
-
export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel,
|
|
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, S as SystemModelMessage, e as CompileResult, B as BestPracticeAdvisory, F as FallbackReason, f as SectionRewrite, R as RecordInput, g as RecordOutcomeInput, O as OutcomeResult, h as OracleScore, i as Adapter, j as PerAxisMetrics, k as Provider, l as ChainEntry, G as Grounding } from './ir-C02EIElQ.js';
|
|
2
|
+
export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel, r as GoldenCaptureOptions, H as HistoryCachePolicy, I as IntentDeclaration, M as Message, s as MutationApplied, t as NormalizedTokens, u as OutcomeKind, v as PerAxisMetricsByModel, w as PromptSection, x as SectionKind, y as ShadowProbeConfig, T as ToolCall, z as ToolDefinition, D as captureGoldenIr, J as parseGoldenCaptureRate, K as resolveGoldenCaptureRate, L as shouldCaptureGolden } from './ir-C02EIElQ.js';
|
|
3
3
|
import { ModelProfile, ArchetypeConvention } from './profiles.js';
|
|
4
4
|
export { ALIASES, CacheStrategy, CliffRule, LATENCY_TIER_MS, LatencyTier, LoweringSpec, RecoveryRule, StructuredOutputCapability, SystemPromptMode, allProfiles, getProfile, latencyTierOf, profilesByProvider, tryGetProfile } from './profiles.js';
|
|
5
5
|
export { BrainForwardConfig, BrainForwardRoutes, createBrainForwardRoutes } from './brain-proxy.js';
|
|
@@ -656,7 +656,7 @@ interface OutcomePayload {
|
|
|
656
656
|
history_depth?: number;
|
|
657
657
|
system_prompt_chars?: number;
|
|
658
658
|
fell_over_from?: string;
|
|
659
|
-
fallback_reason?:
|
|
659
|
+
fallback_reason?: FallbackReason;
|
|
660
660
|
/**
|
|
661
661
|
* alpha.71 (migration 044) — the precise `errorCode` behind
|
|
662
662
|
* `fallback_reason`. Key OMITTED when no fallback fired, so brains that
|
|
@@ -1119,7 +1119,7 @@ declare function runStrategyEvalWithAttribution(opts: Omit<GoldenEvalOptions, 'a
|
|
|
1119
1119
|
* guard in `tests/version.test.ts` fails the suite (and therefore
|
|
1120
1120
|
* `prepublishOnly`) when they diverge — a stale constant cannot reach npm.
|
|
1121
1121
|
*/
|
|
1122
|
-
declare const LIBRARY_VERSION = "2.0.0-alpha.
|
|
1122
|
+
declare const LIBRARY_VERSION = "2.0.0-alpha.77";
|
|
1123
1123
|
|
|
1124
1124
|
/**
|
|
1125
1125
|
* Oracle contract — how an app tells the brain whether a response was good.
|
|
@@ -3404,4 +3404,4 @@ declare function planDecomposition(args: PlanDecompositionArgs): DecompositionPl
|
|
|
3404
3404
|
*/
|
|
3405
3405
|
declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
|
|
3406
3406
|
|
|
3407
|
-
export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ARCHETYPE_FAMILY_FITS, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, ArchetypeConvention, type ArchetypeFamilyFit, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, type AttachCacheControlResult, BestPracticeAdvisory, type BrainConfig, type BrainDeadLetterEntry, type BrainHealthSnapshot, type BrainQueryConfig, type BrainReadEnv, COACH_CFG, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, DECOMPOSITION_TEMPLATES, DECOMPOSITION_TEMPLATES_VERSION, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_MEASURED_FAILURE_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, DISCIPLINE_GATES_V1_ALT_HEADER, type DecompositionPlan, type DecompositionStep, type DecompositionTemplate, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type ExecutorCandidate, type FallbackPosture, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetMeasuredFailureOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalAxis, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenEvalStrategyId, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_FAILURE_CFG, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type MeasuredFailureRuntime, type MeasuredFailureVerdict, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, OutputMode, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PlannedStep, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_DISCIPLINE_GATES_V1, RULE_DISCIPLINE_GATES_V1_STRUCTURED, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, STRATEGY_AUTHORSHIP_LIMITATION, SectionRewrite, type ShadowProbeRecordInput, type StrategyAttribution, type StrategyAttributionResult, type StrategyOutcome, type SupportedProvider, type SurfaceFailureRow, type SurfaceStats, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, altGatesBlockFor, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, awaitMeasuredFailureReady, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, classifyStrategyOutcome, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, deriveFamilyFromModelId, deriveOwnership, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isExclusionFindingsBrainActive, isMeasuredFailureBrainActive, isMeasuredFailureGateEnabledFromEnv, isModelReachable, isPromotionsBrainActive, isProviderReachable, judgeMeasuredFailure, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, planDecomposition, prefetchMeasuredFailure, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, runStrategyEvalWithAttribution, setTokenizer, wilsonLowerBound, withAltDisciplineContract, withDisciplineContract };
|
|
3407
|
+
export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ARCHETYPE_FAMILY_FITS, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, ArchetypeConvention, type ArchetypeFamilyFit, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, type AttachCacheControlResult, BestPracticeAdvisory, type BrainConfig, type BrainDeadLetterEntry, type BrainHealthSnapshot, type BrainQueryConfig, type BrainReadEnv, COACH_CFG, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, DECOMPOSITION_TEMPLATES, DECOMPOSITION_TEMPLATES_VERSION, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_MEASURED_FAILURE_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, DISCIPLINE_GATES_V1_ALT_HEADER, type DecompositionPlan, type DecompositionStep, type DecompositionTemplate, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type ExecutorCandidate, type FallbackPosture, FallbackReason, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetMeasuredFailureOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalAxis, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenEvalStrategyId, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_FAILURE_CFG, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type MeasuredFailureRuntime, type MeasuredFailureVerdict, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, OutputMode, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PlannedStep, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_DISCIPLINE_GATES_V1, RULE_DISCIPLINE_GATES_V1_STRUCTURED, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, STRATEGY_AUTHORSHIP_LIMITATION, SectionRewrite, type ShadowProbeRecordInput, type StrategyAttribution, type StrategyAttributionResult, type StrategyOutcome, type SupportedProvider, type SurfaceFailureRow, type SurfaceStats, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, altGatesBlockFor, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, awaitMeasuredFailureReady, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, classifyStrategyOutcome, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, deriveFamilyFromModelId, deriveOwnership, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isExclusionFindingsBrainActive, isMeasuredFailureBrainActive, isMeasuredFailureGateEnabledFromEnv, isModelReachable, isPromotionsBrainActive, isProviderReachable, judgeMeasuredFailure, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, planDecomposition, prefetchMeasuredFailure, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, runStrategyEvalWithAttribution, setTokenizer, wilsonLowerBound, withAltDisciplineContract, withDisciplineContract };
|
package/dist/index.js
CHANGED
|
@@ -6426,8 +6426,33 @@ function isAuthSignatureBody(body, message) {
|
|
|
6426
6426
|
const m = message.toLowerCase();
|
|
6427
6427
|
return m.includes("api key not valid") || m.includes("invalid api key") || m.includes("invalid x-api-key") || m.includes("incorrect api key");
|
|
6428
6428
|
}
|
|
6429
|
+
function isBillingExhaustedBody(status, body, message) {
|
|
6430
|
+
if (status === 402) return true;
|
|
6431
|
+
const m = message.toLowerCase();
|
|
6432
|
+
if (m.includes("free_tier") || m.includes("free tier")) return false;
|
|
6433
|
+
if (m.includes("credit balance is too low")) return true;
|
|
6434
|
+
if (m.includes("insufficient balance")) return true;
|
|
6435
|
+
if (m.includes("billingnotenabled") || m.includes("billing not enabled")) return true;
|
|
6436
|
+
if (body && typeof body === "object") {
|
|
6437
|
+
const err = body.error;
|
|
6438
|
+
if (err && typeof err === "object") {
|
|
6439
|
+
const e = err;
|
|
6440
|
+
if (e.code === "insufficient_quota" || e.type === "insufficient_quota") return true;
|
|
6441
|
+
if (Array.isArray(e.details)) {
|
|
6442
|
+
for (const d of e.details) {
|
|
6443
|
+
if (d && typeof d === "object" && d.reason === "BILLING_DISABLED") {
|
|
6444
|
+
return true;
|
|
6445
|
+
}
|
|
6446
|
+
}
|
|
6447
|
+
}
|
|
6448
|
+
}
|
|
6449
|
+
}
|
|
6450
|
+
return false;
|
|
6451
|
+
}
|
|
6429
6452
|
function classifyHttpError(status, body) {
|
|
6430
6453
|
const message = extractErrorMessage(body) ?? `HTTP ${status}`;
|
|
6454
|
+
if (isBillingExhaustedBody(status, body, message))
|
|
6455
|
+
return { ok: false, status, errorType: "terminal", errorCode: "billing_exhausted", message, raw: body };
|
|
6431
6456
|
if (status === 429)
|
|
6432
6457
|
return { ok: false, status, errorType: "retryable", errorCode: "rate_limit", message, raw: body };
|
|
6433
6458
|
if (status === 408)
|
|
@@ -6691,6 +6716,9 @@ function applyOverrides(request, overrides) {
|
|
|
6691
6716
|
}
|
|
6692
6717
|
function classifyHttpError2(status, body) {
|
|
6693
6718
|
const message = extractErrorMessage2(body) ?? `HTTP ${status}`;
|
|
6719
|
+
if (isBillingExhaustedBody(status, body, message)) {
|
|
6720
|
+
return { ok: false, status, errorType: "terminal", errorCode: "billing_exhausted", message, raw: body };
|
|
6721
|
+
}
|
|
6694
6722
|
if (status === 429) {
|
|
6695
6723
|
return { ok: false, status, errorType: "retryable", errorCode: "rate_limit", message, raw: body };
|
|
6696
6724
|
}
|
|
@@ -7533,18 +7561,19 @@ async function call(ir, opts = {}) {
|
|
|
7533
7561
|
}
|
|
7534
7562
|
let activeCompile = initial;
|
|
7535
7563
|
let lastErr;
|
|
7536
|
-
const failedProviders = /* @__PURE__ */ new
|
|
7564
|
+
const failedProviders = /* @__PURE__ */ new Map();
|
|
7537
7565
|
const sameModelRetryEnabled = opts.sameModelRetry ?? isSameModelRetryEnabledFromEnv();
|
|
7538
7566
|
let retriedSameModel = false;
|
|
7539
7567
|
for (let i = 0; i < targetsToTry.length; i++) {
|
|
7540
7568
|
const targetModel = targetsToTry[i];
|
|
7541
7569
|
const targetProfile = tryGetProfile(targetModel);
|
|
7542
|
-
|
|
7570
|
+
const providerFailReason = targetProfile ? failedProviders.get(targetProfile.provider) : void 0;
|
|
7571
|
+
if (targetProfile && providerFailReason && !opts.noFallback) {
|
|
7543
7572
|
attempts.push({
|
|
7544
7573
|
model: targetModel,
|
|
7545
7574
|
status: "terminal",
|
|
7546
|
-
errorCode:
|
|
7547
|
-
message: `Skipped \u2014 provider ${targetProfile.provider} returned 401/403 earlier in this call; same key inferred to fail`
|
|
7575
|
+
errorCode: `${providerFailReason}_inferred`,
|
|
7576
|
+
message: providerFailReason === "billing_exhausted" ? `Skipped \u2014 provider ${targetProfile.provider} is out of credits (seen earlier in this call); a billing failure is account-wide, so this attempt cannot succeed until a human funds the account` : `Skipped \u2014 provider ${targetProfile.provider} returned 401/403 earlier in this call; same key inferred to fail`
|
|
7548
7577
|
});
|
|
7549
7578
|
continue;
|
|
7550
7579
|
}
|
|
@@ -7726,15 +7755,18 @@ async function call(ir, opts = {}) {
|
|
|
7726
7755
|
});
|
|
7727
7756
|
lastErr = validated;
|
|
7728
7757
|
if (validated.errorType === "terminal" || opts.noFallback) {
|
|
7729
|
-
if (validated.errorCode === "auth" && !opts.noFallback && activeCompile.provider) {
|
|
7730
|
-
failedProviders.
|
|
7758
|
+
if ((validated.errorCode === "auth" || validated.errorCode === "billing_exhausted") && !opts.noFallback && activeCompile.provider) {
|
|
7759
|
+
failedProviders.set(
|
|
7760
|
+
activeCompile.provider,
|
|
7761
|
+
validated.errorCode === "billing_exhausted" ? "billing_exhausted" : "auth"
|
|
7762
|
+
);
|
|
7731
7763
|
continue;
|
|
7732
7764
|
}
|
|
7733
7765
|
break;
|
|
7734
7766
|
}
|
|
7735
7767
|
}
|
|
7736
7768
|
const lastAttempted = [...attempts].reverse().find(
|
|
7737
|
-
(a) => a.status !== "success" && a.errorCode !== "auth_inferred" && a.errorCode !== "compile_error"
|
|
7769
|
+
(a) => a.status !== "success" && a.errorCode !== "auth_inferred" && a.errorCode !== "billing_exhausted_inferred" && a.errorCode !== "compile_error"
|
|
7738
7770
|
);
|
|
7739
7771
|
const latencyMs = Date.now() - start;
|
|
7740
7772
|
await record({
|
|
@@ -8056,6 +8088,9 @@ function normalizeFallbackReason(attempts) {
|
|
|
8056
8088
|
}
|
|
8057
8089
|
if (code === "cost_cap_exceeded") return "cost_cap";
|
|
8058
8090
|
if (code === "auth" || code === "auth_inferred") return "provider_auth_failed";
|
|
8091
|
+
if (code === "billing_exhausted" || code === "billing_exhausted_inferred") {
|
|
8092
|
+
return "provider_billing_exhausted";
|
|
8093
|
+
}
|
|
8059
8094
|
return "provider_error";
|
|
8060
8095
|
}
|
|
8061
8096
|
function generateTraceId() {
|
|
@@ -9043,7 +9078,7 @@ function createBrainForwardRoutes(config) {
|
|
|
9043
9078
|
}
|
|
9044
9079
|
|
|
9045
9080
|
// src/version.ts
|
|
9046
|
-
var LIBRARY_VERSION = "2.0.0-alpha.
|
|
9081
|
+
var LIBRARY_VERSION = "2.0.0-alpha.77";
|
|
9047
9082
|
|
|
9048
9083
|
// src/key-health.ts
|
|
9049
9084
|
var JSON_HEADERS2 = { "Content-Type": "application/json" };
|
package/dist/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
LIBRARY_VERSION,
|
|
18
18
|
createKeyHealthRoute
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-GB7VJQ6C.mjs";
|
|
20
20
|
import {
|
|
21
21
|
ABSOLUTE_FLOOR,
|
|
22
22
|
ARCHETYPE_FLOOR_DEFAULT,
|
|
@@ -4222,8 +4222,33 @@ function isAuthSignatureBody(body, message) {
|
|
|
4222
4222
|
const m = message.toLowerCase();
|
|
4223
4223
|
return m.includes("api key not valid") || m.includes("invalid api key") || m.includes("invalid x-api-key") || m.includes("incorrect api key");
|
|
4224
4224
|
}
|
|
4225
|
+
function isBillingExhaustedBody(status, body, message) {
|
|
4226
|
+
if (status === 402) return true;
|
|
4227
|
+
const m = message.toLowerCase();
|
|
4228
|
+
if (m.includes("free_tier") || m.includes("free tier")) return false;
|
|
4229
|
+
if (m.includes("credit balance is too low")) return true;
|
|
4230
|
+
if (m.includes("insufficient balance")) return true;
|
|
4231
|
+
if (m.includes("billingnotenabled") || m.includes("billing not enabled")) return true;
|
|
4232
|
+
if (body && typeof body === "object") {
|
|
4233
|
+
const err = body.error;
|
|
4234
|
+
if (err && typeof err === "object") {
|
|
4235
|
+
const e = err;
|
|
4236
|
+
if (e.code === "insufficient_quota" || e.type === "insufficient_quota") return true;
|
|
4237
|
+
if (Array.isArray(e.details)) {
|
|
4238
|
+
for (const d of e.details) {
|
|
4239
|
+
if (d && typeof d === "object" && d.reason === "BILLING_DISABLED") {
|
|
4240
|
+
return true;
|
|
4241
|
+
}
|
|
4242
|
+
}
|
|
4243
|
+
}
|
|
4244
|
+
}
|
|
4245
|
+
}
|
|
4246
|
+
return false;
|
|
4247
|
+
}
|
|
4225
4248
|
function classifyHttpError(status, body) {
|
|
4226
4249
|
const message = extractErrorMessage(body) ?? `HTTP ${status}`;
|
|
4250
|
+
if (isBillingExhaustedBody(status, body, message))
|
|
4251
|
+
return { ok: false, status, errorType: "terminal", errorCode: "billing_exhausted", message, raw: body };
|
|
4227
4252
|
if (status === 429)
|
|
4228
4253
|
return { ok: false, status, errorType: "retryable", errorCode: "rate_limit", message, raw: body };
|
|
4229
4254
|
if (status === 408)
|
|
@@ -4487,6 +4512,9 @@ function applyOverrides(request, overrides) {
|
|
|
4487
4512
|
}
|
|
4488
4513
|
function classifyHttpError2(status, body) {
|
|
4489
4514
|
const message = extractErrorMessage2(body) ?? `HTTP ${status}`;
|
|
4515
|
+
if (isBillingExhaustedBody(status, body, message)) {
|
|
4516
|
+
return { ok: false, status, errorType: "terminal", errorCode: "billing_exhausted", message, raw: body };
|
|
4517
|
+
}
|
|
4490
4518
|
if (status === 429) {
|
|
4491
4519
|
return { ok: false, status, errorType: "retryable", errorCode: "rate_limit", message, raw: body };
|
|
4492
4520
|
}
|
|
@@ -4675,18 +4703,19 @@ async function call(ir, opts = {}) {
|
|
|
4675
4703
|
}
|
|
4676
4704
|
let activeCompile = initial;
|
|
4677
4705
|
let lastErr;
|
|
4678
|
-
const failedProviders = /* @__PURE__ */ new
|
|
4706
|
+
const failedProviders = /* @__PURE__ */ new Map();
|
|
4679
4707
|
const sameModelRetryEnabled = opts.sameModelRetry ?? isSameModelRetryEnabledFromEnv();
|
|
4680
4708
|
let retriedSameModel = false;
|
|
4681
4709
|
for (let i = 0; i < targetsToTry.length; i++) {
|
|
4682
4710
|
const targetModel = targetsToTry[i];
|
|
4683
4711
|
const targetProfile = tryGetProfile(targetModel);
|
|
4684
|
-
|
|
4712
|
+
const providerFailReason = targetProfile ? failedProviders.get(targetProfile.provider) : void 0;
|
|
4713
|
+
if (targetProfile && providerFailReason && !opts.noFallback) {
|
|
4685
4714
|
attempts.push({
|
|
4686
4715
|
model: targetModel,
|
|
4687
4716
|
status: "terminal",
|
|
4688
|
-
errorCode:
|
|
4689
|
-
message: `Skipped \u2014 provider ${targetProfile.provider} returned 401/403 earlier in this call; same key inferred to fail`
|
|
4717
|
+
errorCode: `${providerFailReason}_inferred`,
|
|
4718
|
+
message: providerFailReason === "billing_exhausted" ? `Skipped \u2014 provider ${targetProfile.provider} is out of credits (seen earlier in this call); a billing failure is account-wide, so this attempt cannot succeed until a human funds the account` : `Skipped \u2014 provider ${targetProfile.provider} returned 401/403 earlier in this call; same key inferred to fail`
|
|
4690
4719
|
});
|
|
4691
4720
|
continue;
|
|
4692
4721
|
}
|
|
@@ -4868,15 +4897,18 @@ async function call(ir, opts = {}) {
|
|
|
4868
4897
|
});
|
|
4869
4898
|
lastErr = validated;
|
|
4870
4899
|
if (validated.errorType === "terminal" || opts.noFallback) {
|
|
4871
|
-
if (validated.errorCode === "auth" && !opts.noFallback && activeCompile.provider) {
|
|
4872
|
-
failedProviders.
|
|
4900
|
+
if ((validated.errorCode === "auth" || validated.errorCode === "billing_exhausted") && !opts.noFallback && activeCompile.provider) {
|
|
4901
|
+
failedProviders.set(
|
|
4902
|
+
activeCompile.provider,
|
|
4903
|
+
validated.errorCode === "billing_exhausted" ? "billing_exhausted" : "auth"
|
|
4904
|
+
);
|
|
4873
4905
|
continue;
|
|
4874
4906
|
}
|
|
4875
4907
|
break;
|
|
4876
4908
|
}
|
|
4877
4909
|
}
|
|
4878
4910
|
const lastAttempted = [...attempts].reverse().find(
|
|
4879
|
-
(a) => a.status !== "success" && a.errorCode !== "auth_inferred" && a.errorCode !== "compile_error"
|
|
4911
|
+
(a) => a.status !== "success" && a.errorCode !== "auth_inferred" && a.errorCode !== "billing_exhausted_inferred" && a.errorCode !== "compile_error"
|
|
4880
4912
|
);
|
|
4881
4913
|
const latencyMs = Date.now() - start;
|
|
4882
4914
|
await record({
|
|
@@ -5198,6 +5230,9 @@ function normalizeFallbackReason(attempts) {
|
|
|
5198
5230
|
}
|
|
5199
5231
|
if (code === "cost_cap_exceeded") return "cost_cap";
|
|
5200
5232
|
if (code === "auth" || code === "auth_inferred") return "provider_auth_failed";
|
|
5233
|
+
if (code === "billing_exhausted" || code === "billing_exhausted_inferred") {
|
|
5234
|
+
return "provider_billing_exhausted";
|
|
5235
|
+
}
|
|
5201
5236
|
return "provider_error";
|
|
5202
5237
|
}
|
|
5203
5238
|
function generateTraceId() {
|
|
@@ -1209,12 +1209,21 @@ interface CallAttempt {
|
|
|
1209
1209
|
* for alpha.10+ — e.g. mid-stream policy rejects)
|
|
1210
1210
|
* - `provider_auth_failed` alpha.14 — initial provider returned 401/403
|
|
1211
1211
|
* (upstream key revocation, malformed-but-truthy
|
|
1212
|
-
* key
|
|
1213
|
-
*
|
|
1212
|
+
* key). The chain walks to the next
|
|
1213
|
+
* non-same-provider target instead of
|
|
1214
1214
|
* short-circuiting; same-provider remaining
|
|
1215
1215
|
* entries skip with errorCode='auth_inferred'.
|
|
1216
|
+
* - `provider_billing_exhausted` alpha.77 — the provider's ACCOUNT is out
|
|
1217
|
+
* of credits (Anthropic "credit balance is too
|
|
1218
|
+
* low" 400, OpenAI insufficient_quota 429,
|
|
1219
|
+
* Google billing-disabled, DeepSeek 402). Walks
|
|
1220
|
+
* like auth and skips same-provider siblings
|
|
1221
|
+
* (errorCode='billing_exhausted_inferred').
|
|
1222
|
+
* Distinct from auth AND from rate_limit because
|
|
1223
|
+
* its disposition is distinct: it never clears
|
|
1224
|
+
* on its own — a human funds the account.
|
|
1216
1225
|
*/
|
|
1217
|
-
type FallbackReason = 'rate_limit' | 'provider_error' | 'cost_cap' | 'cliff' | 'contract_violation' | 'provider_auth_failed';
|
|
1226
|
+
type FallbackReason = 'rate_limit' | 'provider_error' | 'cost_cap' | 'cliff' | 'contract_violation' | 'provider_auth_failed' | 'provider_billing_exhausted';
|
|
1218
1227
|
interface CallResult {
|
|
1219
1228
|
/** Compile handle (still valid for record() if consumer wants to add oracle scores later). */
|
|
1220
1229
|
handle: string;
|
|
@@ -1470,10 +1479,11 @@ interface RecordInput {
|
|
|
1470
1479
|
/** Model originally targeted when a fallback fired. */
|
|
1471
1480
|
fellOverFrom?: string;
|
|
1472
1481
|
/**
|
|
1473
|
-
* Why the fallback fired
|
|
1474
|
-
*
|
|
1482
|
+
* Why the fallback fired — the SAME closed set as CallResult.fallbackReason
|
|
1483
|
+
* (one derivation; the alpha.77 DTS break caught this field's inline copy
|
|
1484
|
+
* drifting when the canonical union grew a member).
|
|
1475
1485
|
*/
|
|
1476
|
-
fallbackReason?:
|
|
1486
|
+
fallbackReason?: FallbackReason;
|
|
1477
1487
|
/**
|
|
1478
1488
|
* alpha.66 — true when the one-shot same-model retry fired during this
|
|
1479
1489
|
* call (migration 039 `retried_same_model`). Powers the offline rollup:
|
|
@@ -1209,12 +1209,21 @@ interface CallAttempt {
|
|
|
1209
1209
|
* for alpha.10+ — e.g. mid-stream policy rejects)
|
|
1210
1210
|
* - `provider_auth_failed` alpha.14 — initial provider returned 401/403
|
|
1211
1211
|
* (upstream key revocation, malformed-but-truthy
|
|
1212
|
-
* key
|
|
1213
|
-
*
|
|
1212
|
+
* key). The chain walks to the next
|
|
1213
|
+
* non-same-provider target instead of
|
|
1214
1214
|
* short-circuiting; same-provider remaining
|
|
1215
1215
|
* entries skip with errorCode='auth_inferred'.
|
|
1216
|
+
* - `provider_billing_exhausted` alpha.77 — the provider's ACCOUNT is out
|
|
1217
|
+
* of credits (Anthropic "credit balance is too
|
|
1218
|
+
* low" 400, OpenAI insufficient_quota 429,
|
|
1219
|
+
* Google billing-disabled, DeepSeek 402). Walks
|
|
1220
|
+
* like auth and skips same-provider siblings
|
|
1221
|
+
* (errorCode='billing_exhausted_inferred').
|
|
1222
|
+
* Distinct from auth AND from rate_limit because
|
|
1223
|
+
* its disposition is distinct: it never clears
|
|
1224
|
+
* on its own — a human funds the account.
|
|
1216
1225
|
*/
|
|
1217
|
-
type FallbackReason = 'rate_limit' | 'provider_error' | 'cost_cap' | 'cliff' | 'contract_violation' | 'provider_auth_failed';
|
|
1226
|
+
type FallbackReason = 'rate_limit' | 'provider_error' | 'cost_cap' | 'cliff' | 'contract_violation' | 'provider_auth_failed' | 'provider_billing_exhausted';
|
|
1218
1227
|
interface CallResult {
|
|
1219
1228
|
/** Compile handle (still valid for record() if consumer wants to add oracle scores later). */
|
|
1220
1229
|
handle: string;
|
|
@@ -1470,10 +1479,11 @@ interface RecordInput {
|
|
|
1470
1479
|
/** Model originally targeted when a fallback fired. */
|
|
1471
1480
|
fellOverFrom?: string;
|
|
1472
1481
|
/**
|
|
1473
|
-
* Why the fallback fired
|
|
1474
|
-
*
|
|
1482
|
+
* Why the fallback fired — the SAME closed set as CallResult.fallbackReason
|
|
1483
|
+
* (one derivation; the alpha.77 DTS break caught this field's inline copy
|
|
1484
|
+
* drifting when the canonical union grew a member).
|
|
1475
1485
|
*/
|
|
1476
|
-
fallbackReason?:
|
|
1486
|
+
fallbackReason?: FallbackReason;
|
|
1477
1487
|
/**
|
|
1478
1488
|
* alpha.66 — true when the one-shot same-model retry fired during this
|
|
1479
1489
|
* call (migration 039 `retried_same_model`). Powers the offline rollup:
|
package/dist/key-health.js
CHANGED
|
@@ -25,7 +25,7 @@ __export(key_health_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(key_health_exports);
|
|
26
26
|
|
|
27
27
|
// src/version.ts
|
|
28
|
-
var LIBRARY_VERSION = "2.0.0-alpha.
|
|
28
|
+
var LIBRARY_VERSION = "2.0.0-alpha.77";
|
|
29
29
|
|
|
30
30
|
// src/key-health.ts
|
|
31
31
|
var JSON_HEADERS = { "Content-Type": "application/json" };
|
package/dist/key-health.mjs
CHANGED
package/dist/profiles.d.mts
CHANGED
package/dist/profiles.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import { i as Adapter, x as SectionKind } from './ir-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Internal config + hook types for createGlassboxRoutes().
|
|
5
|
-
*
|
|
6
|
-
* The public contract lives on `GlassboxRoutesConfig` in ./index.ts; these
|
|
7
|
-
* are the narrower per-handler shapes consumed by proxy.ts and stream.ts.
|
|
8
|
-
*/
|
|
1
|
+
import { i as Adapter, F as FallbackReason, x as SectionKind } from './ir-CRV1_taF.mjs';
|
|
9
2
|
|
|
10
3
|
/**
|
|
11
4
|
* Wire contract for the Glass-Box Chrome extension's brain-poll endpoint.
|
|
@@ -131,7 +124,7 @@ interface TraceDetail extends TraceSummary {
|
|
|
131
124
|
/** Derived: cacheReadInputTokens / max(tokensIn, 1). 0-1. */
|
|
132
125
|
inputCacheHitRatio: number;
|
|
133
126
|
fellOverFrom?: string;
|
|
134
|
-
fallbackReason?:
|
|
127
|
+
fallbackReason?: FallbackReason;
|
|
135
128
|
/** Up to 2 alternatives. Empty array (not undefined) when none qualify. */
|
|
136
129
|
counterfactuals?: TraceCounterfactual[];
|
|
137
130
|
/** Undefined when 7d volume < 5/day (insufficient data). */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-
|
|
1
|
+
import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-C02EIElQ.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Glass-Box observability types (alpha.17).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-
|
|
1
|
+
import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-CRV1_taF.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Glass-Box observability types (alpha.17).
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import { i as Adapter, x as SectionKind } from './ir-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Internal config + hook types for createGlassboxRoutes().
|
|
5
|
-
*
|
|
6
|
-
* The public contract lives on `GlassboxRoutesConfig` in ./index.ts; these
|
|
7
|
-
* are the narrower per-handler shapes consumed by proxy.ts and stream.ts.
|
|
8
|
-
*/
|
|
1
|
+
import { i as Adapter, F as FallbackReason, x as SectionKind } from './ir-C02EIElQ.js';
|
|
9
2
|
|
|
10
3
|
/**
|
|
11
4
|
* Wire contract for the Glass-Box Chrome extension's brain-poll endpoint.
|
|
@@ -131,7 +124,7 @@ interface TraceDetail extends TraceSummary {
|
|
|
131
124
|
/** Derived: cacheReadInputTokens / max(tokensIn, 1). 0-1. */
|
|
132
125
|
inputCacheHitRatio: number;
|
|
133
126
|
fellOverFrom?: string;
|
|
134
|
-
fallbackReason?:
|
|
127
|
+
fallbackReason?: FallbackReason;
|
|
135
128
|
/** Up to 2 alternatives. Empty array (not undefined) when none qualify. */
|
|
136
129
|
counterfactuals?: TraceCounterfactual[];
|
|
137
130
|
/** Undefined when 7d volume < 5/day (insufficient data). */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warmdrift/kgauto-compiler",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.77",
|
|
4
4
|
"description": "Prompt compiler with executable provider knowledge for multi-model AI apps: normalized multi-provider transport with fallback chains, compile-time cliff guards, a curated model registry, and a telemetry flight recorder. Swap models without rewriting prompts.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|