@warmdrift/kgauto-compiler 2.0.0-alpha.68 → 2.0.0-alpha.69

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.
@@ -56,6 +56,11 @@ var ALL_ARCHETYPES = Object.keys(INTENT_ARCHETYPES);
56
56
  function isArchetype(name) {
57
57
  return name in INTENT_ARCHETYPES;
58
58
  }
59
+ function resolveOutputMode(args) {
60
+ if (args.declared) return args.declared;
61
+ if (args.structuredOutput === true) return "json";
62
+ return args.toolCount > 0 ? "tool_call" : "text";
63
+ }
59
64
  function bucketContext(tokens) {
60
65
  if (tokens < 1e3) return "tiny";
61
66
  if (tokens < 4e3) return "small";
@@ -92,6 +97,7 @@ export {
92
97
  INTENT_ARCHETYPES,
93
98
  ALL_ARCHETYPES,
94
99
  isArchetype,
100
+ resolveOutputMode,
95
101
  bucketContext,
96
102
  bucketToolCount,
97
103
  bucketHistory,
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var LIBRARY_VERSION = "2.0.0-alpha.68";
2
+ var LIBRARY_VERSION = "2.0.0-alpha.69";
3
3
 
4
4
  // src/key-health.ts
5
5
  var JSON_HEADERS = { "Content-Type": "application/json" };
@@ -94,6 +94,32 @@ interface ShapeSignature {
94
94
  /** Whether the prompt includes few-shot examples. */
95
95
  hasExamples: boolean;
96
96
  }
97
+ /**
98
+ * SINGLE source of truth for a call's output shape.
99
+ *
100
+ * Two independent expressions of this concept used to exist — `computeShape`
101
+ * (three-valued, feeding `compile_outcomes.shape_key`) and compile()'s Factor C
102
+ * screen (two-valued). They disagreed on exactly one case: tools present with
103
+ * no `structuredOutput`, which the shape signature calls `tool_call` and the
104
+ * screen called `text`. That gap let alpha.68's shape-altering discipline gates
105
+ * fire on tool-call surfaces — the surface class the design contract names as
106
+ * forbidden, because labelling claims inside a tool-call envelope manufactures
107
+ * the structured-output violations alpha.66 ships a retry for.
108
+ *
109
+ * A consumer `declared` value WINS over inference. The inference cannot see
110
+ * that an agentic surface carrying tools ultimately emits prose, so it is
111
+ * deliberately conservative — wrongly firing a shape-altering rule breaks a
112
+ * parser, wrongly withholding one only forgoes a lift. `constraints.outputMode`
113
+ * is the escape hatch for surfaces that know better.
114
+ *
115
+ * Takes the facts rather than a `PromptIR` so `dialect.ts` stays
116
+ * dependency-free (`ir.ts` imports THIS module, not the reverse).
117
+ */
118
+ declare function resolveOutputMode(args: {
119
+ declared?: OutputMode;
120
+ structuredOutput?: boolean;
121
+ toolCount: number;
122
+ }): OutputMode;
97
123
  declare function bucketContext(tokens: number): ContextBucket;
98
124
  declare function bucketToolCount(count: number): ToolCountBucket;
99
125
  declare function bucketHistory(turnCount: number): HistoryDepth;
@@ -108,4 +134,4 @@ declare function hashShape(s: ShapeSignature): string;
108
134
  */
109
135
  declare function learningKey(archetype: IntentArchetypeName, model: string, shape: ShapeSignature): string;
110
136
 
111
- export { ALL_ARCHETYPES, type ContextBucket, DIALECT_VERSION, type HistoryDepth, INTENT_ARCHETYPES, type IntentArchetypeName, type OutputMode, type ShapeSignature, type ToolCountBucket, bucketContext, bucketHistory, bucketToolCount, hashShape, isArchetype, learningKey };
137
+ export { ALL_ARCHETYPES, type ContextBucket, DIALECT_VERSION, type HistoryDepth, INTENT_ARCHETYPES, type IntentArchetypeName, type OutputMode, type ShapeSignature, type ToolCountBucket, bucketContext, bucketHistory, bucketToolCount, hashShape, isArchetype, learningKey, resolveOutputMode };
package/dist/dialect.d.ts CHANGED
@@ -94,6 +94,32 @@ interface ShapeSignature {
94
94
  /** Whether the prompt includes few-shot examples. */
95
95
  hasExamples: boolean;
96
96
  }
97
+ /**
98
+ * SINGLE source of truth for a call's output shape.
99
+ *
100
+ * Two independent expressions of this concept used to exist — `computeShape`
101
+ * (three-valued, feeding `compile_outcomes.shape_key`) and compile()'s Factor C
102
+ * screen (two-valued). They disagreed on exactly one case: tools present with
103
+ * no `structuredOutput`, which the shape signature calls `tool_call` and the
104
+ * screen called `text`. That gap let alpha.68's shape-altering discipline gates
105
+ * fire on tool-call surfaces — the surface class the design contract names as
106
+ * forbidden, because labelling claims inside a tool-call envelope manufactures
107
+ * the structured-output violations alpha.66 ships a retry for.
108
+ *
109
+ * A consumer `declared` value WINS over inference. The inference cannot see
110
+ * that an agentic surface carrying tools ultimately emits prose, so it is
111
+ * deliberately conservative — wrongly firing a shape-altering rule breaks a
112
+ * parser, wrongly withholding one only forgoes a lift. `constraints.outputMode`
113
+ * is the escape hatch for surfaces that know better.
114
+ *
115
+ * Takes the facts rather than a `PromptIR` so `dialect.ts` stays
116
+ * dependency-free (`ir.ts` imports THIS module, not the reverse).
117
+ */
118
+ declare function resolveOutputMode(args: {
119
+ declared?: OutputMode;
120
+ structuredOutput?: boolean;
121
+ toolCount: number;
122
+ }): OutputMode;
97
123
  declare function bucketContext(tokens: number): ContextBucket;
98
124
  declare function bucketToolCount(count: number): ToolCountBucket;
99
125
  declare function bucketHistory(turnCount: number): HistoryDepth;
@@ -108,4 +134,4 @@ declare function hashShape(s: ShapeSignature): string;
108
134
  */
109
135
  declare function learningKey(archetype: IntentArchetypeName, model: string, shape: ShapeSignature): string;
110
136
 
111
- export { ALL_ARCHETYPES, type ContextBucket, DIALECT_VERSION, type HistoryDepth, INTENT_ARCHETYPES, type IntentArchetypeName, type OutputMode, type ShapeSignature, type ToolCountBucket, bucketContext, bucketHistory, bucketToolCount, hashShape, isArchetype, learningKey };
137
+ export { ALL_ARCHETYPES, type ContextBucket, DIALECT_VERSION, type HistoryDepth, INTENT_ARCHETYPES, type IntentArchetypeName, type OutputMode, type ShapeSignature, type ToolCountBucket, bucketContext, bucketHistory, bucketToolCount, hashShape, isArchetype, learningKey, resolveOutputMode };
package/dist/dialect.js CHANGED
@@ -28,7 +28,8 @@ __export(dialect_exports, {
28
28
  bucketToolCount: () => bucketToolCount,
29
29
  hashShape: () => hashShape,
30
30
  isArchetype: () => isArchetype,
31
- learningKey: () => learningKey
31
+ learningKey: () => learningKey,
32
+ resolveOutputMode: () => resolveOutputMode
32
33
  });
33
34
  module.exports = __toCommonJS(dialect_exports);
34
35
  var DIALECT_VERSION = "v1";
@@ -88,6 +89,11 @@ var ALL_ARCHETYPES = Object.keys(INTENT_ARCHETYPES);
88
89
  function isArchetype(name) {
89
90
  return name in INTENT_ARCHETYPES;
90
91
  }
92
+ function resolveOutputMode(args) {
93
+ if (args.declared) return args.declared;
94
+ if (args.structuredOutput === true) return "json";
95
+ return args.toolCount > 0 ? "tool_call" : "text";
96
+ }
91
97
  function bucketContext(tokens) {
92
98
  if (tokens < 1e3) return "tiny";
93
99
  if (tokens < 4e3) return "small";
@@ -128,5 +134,6 @@ function learningKey(archetype, model, shape) {
128
134
  bucketToolCount,
129
135
  hashShape,
130
136
  isArchetype,
131
- learningKey
137
+ learningKey,
138
+ resolveOutputMode
132
139
  });
package/dist/dialect.mjs CHANGED
@@ -7,8 +7,9 @@ import {
7
7
  bucketToolCount,
8
8
  hashShape,
9
9
  isArchetype,
10
- learningKey
11
- } from "./chunk-3KQAID63.mjs";
10
+ learningKey,
11
+ resolveOutputMode
12
+ } from "./chunk-BVEXV5KC.mjs";
12
13
  export {
13
14
  ALL_ARCHETYPES,
14
15
  DIALECT_VERSION,
@@ -18,5 +19,6 @@ export {
18
19
  bucketToolCount,
19
20
  hashShape,
20
21
  isArchetype,
21
- learningKey
22
+ learningKey,
23
+ resolveOutputMode
22
24
  };
@@ -1,6 +1,6 @@
1
- import { G as GlassboxEvent } from '../types-DWEB5jet.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-DWEB5jet.mjs';
3
- import '../ir-Ct_YDN7y.mjs';
1
+ import { G as GlassboxEvent } from '../types-DsEq35WY.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-DsEq35WY.mjs';
3
+ import '../ir-Bqn1RVdV.mjs';
4
4
  import '../dialect.mjs';
5
5
 
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { G as GlassboxEvent } from '../types-Bdc3zbrq.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-Bdc3zbrq.js';
3
- import '../ir-Pv19aEBR.js';
1
+ import { G as GlassboxEvent } from '../types-Bon96eyc.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-Bon96eyc.js';
3
+ import '../ir-Bvlkw5ja.js';
4
4
  import '../dialect.js';
5
5
 
6
6
  /**
@@ -1,5 +1,5 @@
1
- import { T as TraceHealth } from '../types-B3IKyBcW.mjs';
2
- import '../ir-Ct_YDN7y.mjs';
1
+ import { T as TraceHealth } from '../types-CwGhacGT.mjs';
2
+ import '../ir-Bqn1RVdV.mjs';
3
3
  import '../dialect.mjs';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { T as TraceHealth } from '../types-DN4kZwXN.js';
2
- import '../ir-Pv19aEBR.js';
1
+ import { T as TraceHealth } from '../types-DIxRZ3Dj.js';
2
+ import '../ir-Bvlkw5ja.js';
3
3
  import '../dialect.js';
4
4
 
5
5
  /**
@@ -1,7 +1,7 @@
1
- import { G as GlassboxEvent } from '../types-DWEB5jet.mjs';
2
- import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-B3IKyBcW.mjs';
3
- export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-B3IKyBcW.mjs';
4
- import '../ir-Ct_YDN7y.mjs';
1
+ import { G as GlassboxEvent } from '../types-DsEq35WY.mjs';
2
+ import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-CwGhacGT.mjs';
3
+ export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-CwGhacGT.mjs';
4
+ import '../ir-Bqn1RVdV.mjs';
5
5
  import '../dialect.mjs';
6
6
 
7
7
  /**
@@ -1,7 +1,7 @@
1
- import { G as GlassboxEvent } from '../types-Bdc3zbrq.js';
2
- import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-DN4kZwXN.js';
3
- export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-DN4kZwXN.js';
4
- import '../ir-Pv19aEBR.js';
1
+ import { G as GlassboxEvent } from '../types-Bon96eyc.js';
2
+ import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-DIxRZ3Dj.js';
3
+ export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-DIxRZ3Dj.js';
4
+ import '../ir-Bvlkw5ja.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-B3IKyBcW.mjs';
3
- import '../../ir-Ct_YDN7y.mjs';
2
+ import { a as TraceDetail } from '../../types-CwGhacGT.mjs';
3
+ import '../../ir-Bqn1RVdV.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-DN4kZwXN.js';
3
- import '../../ir-Pv19aEBR.js';
2
+ import { a as TraceDetail } from '../../types-DIxRZ3Dj.js';
3
+ import '../../ir-Bvlkw5ja.js';
4
4
  import '../../dialect.js';
5
5
 
6
6
  /**
package/dist/index.d.mts CHANGED
@@ -1,11 +1,11 @@
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-Ct_YDN7y.mjs';
2
- export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel, F as FallbackReason, 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-Ct_YDN7y.mjs';
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-Bqn1RVdV.mjs';
2
+ export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel, F as FallbackReason, 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-Bqn1RVdV.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';
6
6
  export { KeyHealthConfig, KeyHealthProvider, KeyHealthResponseBody, KeyHealthResult, KeyHealthRoute, createKeyHealthRoute } from './key-health.mjs';
7
- import { IntentArchetypeName } from './dialect.mjs';
8
- export { ALL_ARCHETYPES, ContextBucket, DIALECT_VERSION, HistoryDepth, INTENT_ARCHETYPES, OutputMode, ShapeSignature, ToolCountBucket, bucketContext, bucketHistory, bucketToolCount, hashShape, isArchetype, learningKey } from './dialect.mjs';
7
+ import { IntentArchetypeName, OutputMode } from './dialect.mjs';
8
+ export { ALL_ARCHETYPES, ContextBucket, DIALECT_VERSION, HistoryDepth, INTENT_ARCHETYPES, ShapeSignature, ToolCountBucket, bucketContext, bucketHistory, bucketToolCount, hashShape, isArchetype, learningKey } from './dialect.mjs';
9
9
 
10
10
  /**
11
11
  * compile() — the main orchestrator.
@@ -973,7 +973,7 @@ declare function runGoldenEval(opts: GoldenEvalOptions): Promise<GoldenEvalRunRe
973
973
  * guard in `tests/version.test.ts` fails the suite (and therefore
974
974
  * `prepublishOnly`) when they diverge — a stale constant cannot reach npm.
975
975
  */
976
- declare const LIBRARY_VERSION = "2.0.0-alpha.68";
976
+ declare const LIBRARY_VERSION = "2.0.0-alpha.69";
977
977
 
978
978
  /**
979
979
  * Oracle contract — how an app tells the brain whether a response was good.
@@ -1319,7 +1319,7 @@ interface ApplySectionRewritesArgs {
1319
1319
  * `ir.constraints?.structuredOutput` (true ⇒ 'json', else 'text') so callers
1320
1320
  * / tests need not pass it. compile() passes it explicitly.
1321
1321
  */
1322
- outputMode?: 'text' | 'json';
1322
+ outputMode?: OutputMode;
1323
1323
  }
1324
1324
  interface ApplySectionRewritesResult {
1325
1325
  /**
@@ -2879,4 +2879,4 @@ declare function _testWaitForPromotionsRefresh(): Promise<void>;
2879
2879
  */
2880
2880
  declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
2881
2881
 
2882
- 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, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, SectionRewrite, type ShadowProbeRecordInput, type SupportedProvider, SystemModelMessage, TRANSLATOR_FLOOR, _testResetPromotions, _testWaitForPromotionsRefresh, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configurePromotionsBrain, countTokens, deriveFamilyFromModelId, deriveOwnership, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isExclusionFindingsBrainActive, isModelReachable, isPromotionsBrainActive, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, setTokenizer };
2882
+ 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, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, OutputMode, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, SectionRewrite, type ShadowProbeRecordInput, type SupportedProvider, SystemModelMessage, TRANSLATOR_FLOOR, _testResetPromotions, _testWaitForPromotionsRefresh, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configurePromotionsBrain, countTokens, deriveFamilyFromModelId, deriveOwnership, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isExclusionFindingsBrainActive, isModelReachable, isPromotionsBrainActive, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, setTokenizer };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
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-Pv19aEBR.js';
2
- export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel, F as FallbackReason, 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-Pv19aEBR.js';
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-Bvlkw5ja.js';
2
+ export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel, F as FallbackReason, 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-Bvlkw5ja.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';
6
6
  export { KeyHealthConfig, KeyHealthProvider, KeyHealthResponseBody, KeyHealthResult, KeyHealthRoute, createKeyHealthRoute } from './key-health.js';
7
- import { IntentArchetypeName } from './dialect.js';
8
- export { ALL_ARCHETYPES, ContextBucket, DIALECT_VERSION, HistoryDepth, INTENT_ARCHETYPES, OutputMode, ShapeSignature, ToolCountBucket, bucketContext, bucketHistory, bucketToolCount, hashShape, isArchetype, learningKey } from './dialect.js';
7
+ import { IntentArchetypeName, OutputMode } from './dialect.js';
8
+ export { ALL_ARCHETYPES, ContextBucket, DIALECT_VERSION, HistoryDepth, INTENT_ARCHETYPES, ShapeSignature, ToolCountBucket, bucketContext, bucketHistory, bucketToolCount, hashShape, isArchetype, learningKey } from './dialect.js';
9
9
 
10
10
  /**
11
11
  * compile() — the main orchestrator.
@@ -973,7 +973,7 @@ declare function runGoldenEval(opts: GoldenEvalOptions): Promise<GoldenEvalRunRe
973
973
  * guard in `tests/version.test.ts` fails the suite (and therefore
974
974
  * `prepublishOnly`) when they diverge — a stale constant cannot reach npm.
975
975
  */
976
- declare const LIBRARY_VERSION = "2.0.0-alpha.68";
976
+ declare const LIBRARY_VERSION = "2.0.0-alpha.69";
977
977
 
978
978
  /**
979
979
  * Oracle contract — how an app tells the brain whether a response was good.
@@ -1319,7 +1319,7 @@ interface ApplySectionRewritesArgs {
1319
1319
  * `ir.constraints?.structuredOutput` (true ⇒ 'json', else 'text') so callers
1320
1320
  * / tests need not pass it. compile() passes it explicitly.
1321
1321
  */
1322
- outputMode?: 'text' | 'json';
1322
+ outputMode?: OutputMode;
1323
1323
  }
1324
1324
  interface ApplySectionRewritesResult {
1325
1325
  /**
@@ -2879,4 +2879,4 @@ declare function _testWaitForPromotionsRefresh(): Promise<void>;
2879
2879
  */
2880
2880
  declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
2881
2881
 
2882
- 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, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, SectionRewrite, type ShadowProbeRecordInput, type SupportedProvider, SystemModelMessage, TRANSLATOR_FLOOR, _testResetPromotions, _testWaitForPromotionsRefresh, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configurePromotionsBrain, countTokens, deriveFamilyFromModelId, deriveOwnership, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isExclusionFindingsBrainActive, isModelReachable, isPromotionsBrainActive, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, setTokenizer };
2882
+ 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, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, OutputMode, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, SectionRewrite, type ShadowProbeRecordInput, type SupportedProvider, SystemModelMessage, TRANSLATOR_FLOOR, _testResetPromotions, _testWaitForPromotionsRefresh, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configurePromotionsBrain, countTokens, deriveFamilyFromModelId, deriveOwnership, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isExclusionFindingsBrainActive, isModelReachable, isPromotionsBrainActive, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, setTokenizer };
package/dist/index.js CHANGED
@@ -2476,6 +2476,11 @@ var ALL_ARCHETYPES = Object.keys(INTENT_ARCHETYPES);
2476
2476
  function isArchetype(name) {
2477
2477
  return name in INTENT_ARCHETYPES;
2478
2478
  }
2479
+ function resolveOutputMode(args) {
2480
+ if (args.declared) return args.declared;
2481
+ if (args.structuredOutput === true) return "json";
2482
+ return args.toolCount > 0 ? "tool_call" : "text";
2483
+ }
2479
2484
  function bucketContext(tokens) {
2480
2485
  if (tokens < 1e3) return "tiny";
2481
2486
  if (tokens < 4e3) return "small";
@@ -2923,7 +2928,11 @@ function computeShape(ir, estimatedInputTokens) {
2923
2928
  contextBucket: bucketContext(estimatedInputTokens),
2924
2929
  toolCountBucket: bucketToolCount(ir.tools?.length ?? 0),
2925
2930
  historyDepth: bucketHistory(ir.history?.length ?? 0),
2926
- outputMode: ir.constraints?.structuredOutput ? "json" : ir.tools?.length ? "tool_call" : "text",
2931
+ outputMode: resolveOutputMode({
2932
+ declared: ir.constraints?.outputMode,
2933
+ structuredOutput: ir.constraints?.structuredOutput,
2934
+ toolCount: ir.tools?.length ?? 0
2935
+ }),
2927
2936
  hasExamples: ir.sections.some((s) => /\bexample\b/i.test(s.id))
2928
2937
  };
2929
2938
  }
@@ -4372,7 +4381,11 @@ function applySectionRewrites(args) {
4372
4381
  if (!Array.isArray(ir.sections) || ir.sections.length === 0) {
4373
4382
  return { rewrittenIR: ir, rewrites: [] };
4374
4383
  }
4375
- const outputMode = args.outputMode ?? (ir.constraints?.structuredOutput === true ? "json" : "text");
4384
+ const outputMode = args.outputMode ?? resolveOutputMode({
4385
+ declared: ir.constraints?.outputMode,
4386
+ structuredOutput: ir.constraints?.structuredOutput,
4387
+ toolCount: ir.tools?.length ?? 0
4388
+ });
4376
4389
  const hasTools = (ir.tools?.length ?? 0) > 0;
4377
4390
  const ctx = { outputMode, hasTools };
4378
4391
  const rewrites = [];
@@ -4583,7 +4596,11 @@ function compile(ir, opts = {}) {
4583
4596
  const conventions = passApplyConventions(workingIR, profile);
4584
4597
  workingIR = conventions.value.ir;
4585
4598
  accumulatedMutations.push(...conventions.mutations);
4586
- const outputMode = ir.constraints?.structuredOutput === true ? "json" : "text";
4599
+ const outputMode = resolveOutputMode({
4600
+ declared: ir.constraints?.outputMode,
4601
+ structuredOutput: ir.constraints?.structuredOutput,
4602
+ toolCount: ir.tools?.length ?? 0
4603
+ });
4587
4604
  const translated = applySectionRewrites({
4588
4605
  ir: workingIR,
4589
4606
  profile,
@@ -8359,7 +8376,7 @@ function createBrainForwardRoutes(config) {
8359
8376
  }
8360
8377
 
8361
8378
  // src/version.ts
8362
- var LIBRARY_VERSION = "2.0.0-alpha.68";
8379
+ var LIBRARY_VERSION = "2.0.0-alpha.69";
8363
8380
 
8364
8381
  // src/key-health.ts
8365
8382
  var JSON_HEADERS2 = { "Content-Type": "application/json" };
package/dist/index.mjs CHANGED
@@ -10,12 +10,13 @@ import {
10
10
  bucketToolCount,
11
11
  hashShape,
12
12
  isArchetype,
13
- learningKey
14
- } from "./chunk-3KQAID63.mjs";
13
+ learningKey,
14
+ resolveOutputMode
15
+ } from "./chunk-BVEXV5KC.mjs";
15
16
  import {
16
17
  LIBRARY_VERSION,
17
18
  createKeyHealthRoute
18
- } from "./chunk-2ZHYFV7G.mjs";
19
+ } from "./chunk-EZXVJUK7.mjs";
19
20
  import {
20
21
  ABSOLUTE_FLOOR,
21
22
  ARCHETYPE_FLOOR_DEFAULT,
@@ -904,7 +905,11 @@ function computeShape(ir, estimatedInputTokens) {
904
905
  contextBucket: bucketContext(estimatedInputTokens),
905
906
  toolCountBucket: bucketToolCount(ir.tools?.length ?? 0),
906
907
  historyDepth: bucketHistory(ir.history?.length ?? 0),
907
- outputMode: ir.constraints?.structuredOutput ? "json" : ir.tools?.length ? "tool_call" : "text",
908
+ outputMode: resolveOutputMode({
909
+ declared: ir.constraints?.outputMode,
910
+ structuredOutput: ir.constraints?.structuredOutput,
911
+ toolCount: ir.tools?.length ?? 0
912
+ }),
908
913
  hasExamples: ir.sections.some((s) => /\bexample\b/i.test(s.id))
909
914
  };
910
915
  }
@@ -2353,7 +2358,11 @@ function applySectionRewrites(args) {
2353
2358
  if (!Array.isArray(ir.sections) || ir.sections.length === 0) {
2354
2359
  return { rewrittenIR: ir, rewrites: [] };
2355
2360
  }
2356
- const outputMode = args.outputMode ?? (ir.constraints?.structuredOutput === true ? "json" : "text");
2361
+ const outputMode = args.outputMode ?? resolveOutputMode({
2362
+ declared: ir.constraints?.outputMode,
2363
+ structuredOutput: ir.constraints?.structuredOutput,
2364
+ toolCount: ir.tools?.length ?? 0
2365
+ });
2357
2366
  const hasTools = (ir.tools?.length ?? 0) > 0;
2358
2367
  const ctx = { outputMode, hasTools };
2359
2368
  const rewrites = [];
@@ -2564,7 +2573,11 @@ function compile(ir, opts = {}) {
2564
2573
  const conventions = passApplyConventions(workingIR, profile);
2565
2574
  workingIR = conventions.value.ir;
2566
2575
  accumulatedMutations.push(...conventions.mutations);
2567
- const outputMode = ir.constraints?.structuredOutput === true ? "json" : "text";
2576
+ const outputMode = resolveOutputMode({
2577
+ declared: ir.constraints?.outputMode,
2578
+ structuredOutput: ir.constraints?.structuredOutput,
2579
+ toolCount: ir.tools?.length ?? 0
2580
+ });
2568
2581
  const translated = applySectionRewrites({
2569
2582
  ir: workingIR,
2570
2583
  profile,
@@ -1,4 +1,4 @@
1
- import { IntentArchetypeName } from './dialect.js';
1
+ import { IntentArchetypeName, OutputMode } from './dialect.mjs';
2
2
 
3
3
  /**
4
4
  * Golden-set capture (alpha.62, eval spine — design brief 2026-07-17).
@@ -206,6 +206,21 @@ interface Constraints {
206
206
  effort?: EffortLevel;
207
207
  /** Caller wants structured (JSON) output. */
208
208
  structuredOutput?: boolean;
209
+ /**
210
+ * alpha.69 — consumer-declared output shape. Overrides the inference in
211
+ * `resolveOutputMode` (structuredOutput ⇒ json · tools ⇒ tool_call · else
212
+ * text), which is deliberately conservative: it cannot see that an agentic
213
+ * surface carrying tools ultimately emits prose to the user.
214
+ *
215
+ * Declaring `'text'` on a tool-carrying surface is what re-opens the
216
+ * alpha.68 discipline gates for it (Factor C is a hard screen on inferred
217
+ * `tool_call`, because wrongly firing breaks a parser while wrongly
218
+ * withholding only forgoes a lift). Declare it truthfully — it is
219
+ * consumer-reported ground truth about what the model emits, and it feeds
220
+ * `shape_key`, so a false declaration fragments the learning key AND lets
221
+ * shape-altering rules fire on a structured surface.
222
+ */
223
+ outputMode?: OutputMode;
209
224
  /** Hint: caller expects a short response (used to disable thinking on Gemini). */
210
225
  expectedShortOutput?: boolean;
211
226
  /** Hint: max response words. */
@@ -1,4 +1,4 @@
1
- import { IntentArchetypeName } from './dialect.mjs';
1
+ import { IntentArchetypeName, OutputMode } from './dialect.js';
2
2
 
3
3
  /**
4
4
  * Golden-set capture (alpha.62, eval spine — design brief 2026-07-17).
@@ -206,6 +206,21 @@ interface Constraints {
206
206
  effort?: EffortLevel;
207
207
  /** Caller wants structured (JSON) output. */
208
208
  structuredOutput?: boolean;
209
+ /**
210
+ * alpha.69 — consumer-declared output shape. Overrides the inference in
211
+ * `resolveOutputMode` (structuredOutput ⇒ json · tools ⇒ tool_call · else
212
+ * text), which is deliberately conservative: it cannot see that an agentic
213
+ * surface carrying tools ultimately emits prose to the user.
214
+ *
215
+ * Declaring `'text'` on a tool-carrying surface is what re-opens the
216
+ * alpha.68 discipline gates for it (Factor C is a hard screen on inferred
217
+ * `tool_call`, because wrongly firing breaks a parser while wrongly
218
+ * withholding only forgoes a lift). Declare it truthfully — it is
219
+ * consumer-reported ground truth about what the model emits, and it feeds
220
+ * `shape_key`, so a false declaration fragments the learning key AND lets
221
+ * shape-altering rules fire on a structured surface.
222
+ */
223
+ outputMode?: OutputMode;
209
224
  /** Hint: caller expects a short response (used to disable thinking on Gemini). */
210
225
  expectedShortOutput?: boolean;
211
226
  /** Hint: max response words. */
@@ -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.68";
28
+ var LIBRARY_VERSION = "2.0.0-alpha.69";
29
29
 
30
30
  // src/key-health.ts
31
31
  var JSON_HEADERS = { "Content-Type": "application/json" };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createKeyHealthRoute
3
- } from "./chunk-2ZHYFV7G.mjs";
3
+ } from "./chunk-EZXVJUK7.mjs";
4
4
  export {
5
5
  createKeyHealthRoute
6
6
  };
@@ -1,4 +1,4 @@
1
- import { k as Provider } from './ir-Ct_YDN7y.mjs';
1
+ import { k as Provider } from './ir-Bqn1RVdV.mjs';
2
2
  import { IntentArchetypeName } from './dialect.mjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { k as Provider } from './ir-Pv19aEBR.js';
1
+ import { k as Provider } from './ir-Bvlkw5ja.js';
2
2
  import { IntentArchetypeName } from './dialect.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-Pv19aEBR.js';
1
+ import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-Bvlkw5ja.js';
2
2
 
3
3
  /**
4
4
  * Glass-Box observability types (alpha.17).
@@ -1,4 +1,4 @@
1
- import { i as Adapter, x as SectionKind } from './ir-Ct_YDN7y.mjs';
1
+ import { i as Adapter, x as SectionKind } from './ir-Bqn1RVdV.mjs';
2
2
 
3
3
  /**
4
4
  * Internal config + hook types for createGlassboxRoutes().
@@ -1,4 +1,4 @@
1
- import { i as Adapter, x as SectionKind } from './ir-Pv19aEBR.js';
1
+ import { i as Adapter, x as SectionKind } from './ir-Bvlkw5ja.js';
2
2
 
3
3
  /**
4
4
  * Internal config + hook types for createGlassboxRoutes().
@@ -1,4 +1,4 @@
1
- import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-Ct_YDN7y.mjs';
1
+ import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-Bqn1RVdV.mjs';
2
2
 
3
3
  /**
4
4
  * Glass-Box observability types (alpha.17).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warmdrift/kgauto-compiler",
3
- "version": "2.0.0-alpha.68",
3
+ "version": "2.0.0-alpha.69",
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",