@warmdrift/kgauto-compiler 2.0.0-alpha.67 → 2.0.0-alpha.68
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-DTFQIURE.mjs → chunk-2ZHYFV7G.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 +4 -0
- package/dist/glassbox-routes/index.mjs +4 -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 +43 -3
- package/dist/index.d.ts +43 -3
- package/dist/index.js +78 -12
- package/dist/index.mjs +78 -12
- package/dist/{ir-BTvyl8-w.d.mts → ir-Ct_YDN7y.d.mts} +44 -1
- package/dist/{ir-Qnw6L265.d.ts → ir-Pv19aEBR.d.ts} +44 -1
- 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-Cya0jPAF.d.mts → types-B3IKyBcW.d.mts} +1 -1
- package/dist/{types-BdYlJz0Z.d.ts → types-Bdc3zbrq.d.ts} +1 -1
- package/dist/{types-DxYXuFxj.d.ts → types-DN4kZwXN.d.ts} +1 -1
- package/dist/{types-8pWRDbUg.d.mts → types-DWEB5jet.d.mts} +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
2
|
-
export { A as AdvisoryFiredData, C as CompileDoneData, a as CompileStartData, E as ExecuteAttemptData, b as ExecuteSuccessData, F as FallbackWalkedData, c as GLASSBOX_STREAM_TTL_MS, d as GlassboxEventKind, e as GlassboxPubSub } from '../types-
|
|
3
|
-
import '../ir-
|
|
1
|
+
import { G as GlassboxEvent } from '../types-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';
|
|
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-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';
|
|
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-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';
|
|
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-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';
|
|
5
5
|
import '../dialect.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -2228,6 +2228,7 @@ var SECTION_KINDS = /* @__PURE__ */ new Set([
|
|
|
2228
2228
|
"role_intro",
|
|
2229
2229
|
"tool_call_contract",
|
|
2230
2230
|
"narration_contract",
|
|
2231
|
+
"discipline_contract",
|
|
2231
2232
|
"user_turn",
|
|
2232
2233
|
"reference",
|
|
2233
2234
|
"arbitrary"
|
|
@@ -2242,6 +2243,9 @@ function summarizeSectionRewrite(kind, rule) {
|
|
|
2242
2243
|
if (kind === "narration_contract" && rule === "narration-thinking-leak-deepseek") {
|
|
2243
2244
|
return "Thinking-block suppression applied (DeepSeek V4 internal reasoning kept off-wire).";
|
|
2244
2245
|
}
|
|
2246
|
+
if (kind === "discipline_contract" && rule === "discipline-gates-v1") {
|
|
2247
|
+
return "Discipline gates applied (surface-scaffolding: evidence-before-reasoning, one-extra-signal, source-labeling).";
|
|
2248
|
+
}
|
|
2245
2249
|
return `Translator applied rule "${rule}" to ${kind} section.`;
|
|
2246
2250
|
}
|
|
2247
2251
|
function rowToSectionRewrite(raw) {
|
|
@@ -287,6 +287,7 @@ var SECTION_KINDS = /* @__PURE__ */ new Set([
|
|
|
287
287
|
"role_intro",
|
|
288
288
|
"tool_call_contract",
|
|
289
289
|
"narration_contract",
|
|
290
|
+
"discipline_contract",
|
|
290
291
|
"user_turn",
|
|
291
292
|
"reference",
|
|
292
293
|
"arbitrary"
|
|
@@ -301,6 +302,9 @@ function summarizeSectionRewrite(kind, rule) {
|
|
|
301
302
|
if (kind === "narration_contract" && rule === "narration-thinking-leak-deepseek") {
|
|
302
303
|
return "Thinking-block suppression applied (DeepSeek V4 internal reasoning kept off-wire).";
|
|
303
304
|
}
|
|
305
|
+
if (kind === "discipline_contract" && rule === "discipline-gates-v1") {
|
|
306
|
+
return "Discipline gates applied (surface-scaffolding: evidence-before-reasoning, one-extra-signal, source-labeling).";
|
|
307
|
+
}
|
|
304
308
|
return `Translator applied rule "${rule}" to ${kind} section.`;
|
|
305
309
|
}
|
|
306
310
|
function rowToSectionRewrite(raw) {
|
|
@@ -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-B3IKyBcW.mjs';
|
|
3
|
+
import '../../ir-Ct_YDN7y.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-DN4kZwXN.js';
|
|
3
|
+
import '../../ir-Pv19aEBR.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, 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-
|
|
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';
|
|
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';
|
|
@@ -38,6 +38,15 @@ interface CompileOptions {
|
|
|
38
38
|
* ceiling, boosts preferred. See CompilePolicy in ir.ts.
|
|
39
39
|
*/
|
|
40
40
|
policy?: CompilePolicy;
|
|
41
|
+
/**
|
|
42
|
+
* alpha.68 / Release A (delegation-fanout-accelerator §5.0, R0 linkage) —
|
|
43
|
+
* transport for the fan-out parent handle. Threaded from
|
|
44
|
+
* `CallOptions.parentHandle` on the call() path (and settable directly on the
|
|
45
|
+
* public compile() path). Release A does NOT route on it — it only labels the
|
|
46
|
+
* outcome row (fanout_role / trace_id / parent_handle) at record-registration
|
|
47
|
+
* time. `registerCompile` reads it to derive the linkage. Absent ⇒ root call.
|
|
48
|
+
*/
|
|
49
|
+
parentHandle?: string;
|
|
41
50
|
}
|
|
42
51
|
|
|
43
52
|
/**
|
|
@@ -623,6 +632,28 @@ interface OutcomePayload {
|
|
|
623
632
|
* downstream outcome quality lifted by M points").
|
|
624
633
|
*/
|
|
625
634
|
section_rewrites_applied?: SectionRewrite[] | null;
|
|
635
|
+
/**
|
|
636
|
+
* R0 linkage (§5.0). Parent call's handle when this row is a fan-out branch;
|
|
637
|
+
* key OMITTED (undefined → dropped by JSON.stringify → stored NULL) for a
|
|
638
|
+
* root, safe against pre-042 brains.
|
|
639
|
+
*/
|
|
640
|
+
parent_handle?: string;
|
|
641
|
+
/**
|
|
642
|
+
* R0 linkage (§5.0). Root handle of the fan-out trace (= parent_handle when a
|
|
643
|
+
* branch, else this row's own handle). Emitted for every registered compile.
|
|
644
|
+
*/
|
|
645
|
+
trace_id?: string;
|
|
646
|
+
/**
|
|
647
|
+
* R0 linkage (§5.0). root | branch | composer. Emitted for every registered
|
|
648
|
+
* compile; surface baselines filter to root/NULL so branch traffic never
|
|
649
|
+
* contaminates a promotion/eval baseline. Release A emits only root/branch.
|
|
650
|
+
*/
|
|
651
|
+
fanout_role?: 'root' | 'branch' | 'composer';
|
|
652
|
+
/**
|
|
653
|
+
* RD discipline gate-token accounting (§5.D). Measured token tax of the
|
|
654
|
+
* discipline_contract gate block; 0 when the gate didn't fire.
|
|
655
|
+
*/
|
|
656
|
+
discipline_gate_tokens?: number;
|
|
626
657
|
}
|
|
627
658
|
/**
|
|
628
659
|
* alpha.20 Entry 4: record a quality outcome for a previously-compiled call.
|
|
@@ -942,7 +973,7 @@ declare function runGoldenEval(opts: GoldenEvalOptions): Promise<GoldenEvalRunRe
|
|
|
942
973
|
* guard in `tests/version.test.ts` fails the suite (and therefore
|
|
943
974
|
* `prepublishOnly`) when they diverge — a stale constant cannot reach npm.
|
|
944
975
|
*/
|
|
945
|
-
declare const LIBRARY_VERSION = "2.0.0-alpha.
|
|
976
|
+
declare const LIBRARY_VERSION = "2.0.0-alpha.68";
|
|
946
977
|
|
|
947
978
|
/**
|
|
948
979
|
* Oracle contract — how an app tells the brain whether a response was good.
|
|
@@ -1280,6 +1311,15 @@ interface ApplySectionRewritesArgs {
|
|
|
1280
1311
|
ir: PromptIR;
|
|
1281
1312
|
profile: ModelProfile;
|
|
1282
1313
|
archetype: IntentArchetypeName;
|
|
1314
|
+
/**
|
|
1315
|
+
* alpha.68 / Release A — resolved output shape for Factor C (§5.D). `'json'`
|
|
1316
|
+
* ⇒ structured surface (the discipline gate MUST NOT fire — gates 5+6 are
|
|
1317
|
+
* shape-altering and would break the consumer's parser). `'text'` ⇒ free-form
|
|
1318
|
+
* surface (the gate may fire). Optional: when omitted, derived from
|
|
1319
|
+
* `ir.constraints?.structuredOutput` (true ⇒ 'json', else 'text') so callers
|
|
1320
|
+
* / tests need not pass it. compile() passes it explicitly.
|
|
1321
|
+
*/
|
|
1322
|
+
outputMode?: 'text' | 'json';
|
|
1283
1323
|
}
|
|
1284
1324
|
interface ApplySectionRewritesResult {
|
|
1285
1325
|
/**
|
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, 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-
|
|
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';
|
|
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';
|
|
@@ -38,6 +38,15 @@ interface CompileOptions {
|
|
|
38
38
|
* ceiling, boosts preferred. See CompilePolicy in ir.ts.
|
|
39
39
|
*/
|
|
40
40
|
policy?: CompilePolicy;
|
|
41
|
+
/**
|
|
42
|
+
* alpha.68 / Release A (delegation-fanout-accelerator §5.0, R0 linkage) —
|
|
43
|
+
* transport for the fan-out parent handle. Threaded from
|
|
44
|
+
* `CallOptions.parentHandle` on the call() path (and settable directly on the
|
|
45
|
+
* public compile() path). Release A does NOT route on it — it only labels the
|
|
46
|
+
* outcome row (fanout_role / trace_id / parent_handle) at record-registration
|
|
47
|
+
* time. `registerCompile` reads it to derive the linkage. Absent ⇒ root call.
|
|
48
|
+
*/
|
|
49
|
+
parentHandle?: string;
|
|
41
50
|
}
|
|
42
51
|
|
|
43
52
|
/**
|
|
@@ -623,6 +632,28 @@ interface OutcomePayload {
|
|
|
623
632
|
* downstream outcome quality lifted by M points").
|
|
624
633
|
*/
|
|
625
634
|
section_rewrites_applied?: SectionRewrite[] | null;
|
|
635
|
+
/**
|
|
636
|
+
* R0 linkage (§5.0). Parent call's handle when this row is a fan-out branch;
|
|
637
|
+
* key OMITTED (undefined → dropped by JSON.stringify → stored NULL) for a
|
|
638
|
+
* root, safe against pre-042 brains.
|
|
639
|
+
*/
|
|
640
|
+
parent_handle?: string;
|
|
641
|
+
/**
|
|
642
|
+
* R0 linkage (§5.0). Root handle of the fan-out trace (= parent_handle when a
|
|
643
|
+
* branch, else this row's own handle). Emitted for every registered compile.
|
|
644
|
+
*/
|
|
645
|
+
trace_id?: string;
|
|
646
|
+
/**
|
|
647
|
+
* R0 linkage (§5.0). root | branch | composer. Emitted for every registered
|
|
648
|
+
* compile; surface baselines filter to root/NULL so branch traffic never
|
|
649
|
+
* contaminates a promotion/eval baseline. Release A emits only root/branch.
|
|
650
|
+
*/
|
|
651
|
+
fanout_role?: 'root' | 'branch' | 'composer';
|
|
652
|
+
/**
|
|
653
|
+
* RD discipline gate-token accounting (§5.D). Measured token tax of the
|
|
654
|
+
* discipline_contract gate block; 0 when the gate didn't fire.
|
|
655
|
+
*/
|
|
656
|
+
discipline_gate_tokens?: number;
|
|
626
657
|
}
|
|
627
658
|
/**
|
|
628
659
|
* alpha.20 Entry 4: record a quality outcome for a previously-compiled call.
|
|
@@ -942,7 +973,7 @@ declare function runGoldenEval(opts: GoldenEvalOptions): Promise<GoldenEvalRunRe
|
|
|
942
973
|
* guard in `tests/version.test.ts` fails the suite (and therefore
|
|
943
974
|
* `prepublishOnly`) when they diverge — a stale constant cannot reach npm.
|
|
944
975
|
*/
|
|
945
|
-
declare const LIBRARY_VERSION = "2.0.0-alpha.
|
|
976
|
+
declare const LIBRARY_VERSION = "2.0.0-alpha.68";
|
|
946
977
|
|
|
947
978
|
/**
|
|
948
979
|
* Oracle contract — how an app tells the brain whether a response was good.
|
|
@@ -1280,6 +1311,15 @@ interface ApplySectionRewritesArgs {
|
|
|
1280
1311
|
ir: PromptIR;
|
|
1281
1312
|
profile: ModelProfile;
|
|
1282
1313
|
archetype: IntentArchetypeName;
|
|
1314
|
+
/**
|
|
1315
|
+
* alpha.68 / Release A — resolved output shape for Factor C (§5.D). `'json'`
|
|
1316
|
+
* ⇒ structured surface (the discipline gate MUST NOT fire — gates 5+6 are
|
|
1317
|
+
* shape-altering and would break the consumer's parser). `'text'` ⇒ free-form
|
|
1318
|
+
* surface (the gate may fire). Optional: when omitted, derived from
|
|
1319
|
+
* `ir.constraints?.structuredOutput` (true ⇒ 'json', else 'text') so callers
|
|
1320
|
+
* / tests need not pass it. compile() passes it explicitly.
|
|
1321
|
+
*/
|
|
1322
|
+
outputMode?: 'text' | 'json';
|
|
1283
1323
|
}
|
|
1284
1324
|
interface ApplySectionRewritesResult {
|
|
1285
1325
|
/**
|
package/dist/index.js
CHANGED
|
@@ -4308,7 +4308,36 @@ var RULE_NARRATION_THINKING_LEAK_DEEPSEEK = "narration-thinking-leak-deepseek";
|
|
|
4308
4308
|
var SEQUENTIAL_TOOL_PREAMBLE = "IMPORTANT: Use one tool call per response. Wait for the tool result before deciding the next tool. Do NOT batch tool calls in parallel.";
|
|
4309
4309
|
var NARRATION_DRIFT_ANTHROPIC_PREAMBLE = "Output ONLY the requested content. Do not narrate your thought process. Each line \u2264 12 words.";
|
|
4310
4310
|
var NARRATION_THINKING_LEAK_DEEPSEEK_PREAMBLE = "Reasoning is internal. Output ONLY the requested content; do not emit <thinking> blocks or internal monologue as user-facing text.";
|
|
4311
|
-
|
|
4311
|
+
var RULE_DISCIPLINE_GATES_V1 = "discipline-gates-v1";
|
|
4312
|
+
var DISCIPLINE_GATES_V1_WITH_TOOLS = `Work through these gates at every judgment point, explicitly:
|
|
4313
|
+
1. Evidence before reasoning: cite what you observed before concluding from it.
|
|
4314
|
+
2. One extra signal: when a finding feels conclusive, check one more adjacent signal before stating it.
|
|
4315
|
+
3. Expand, don't guess: resolve a compressed or referenced item by looking it up rather than inferring its contents.
|
|
4316
|
+
4. Innocent explanation first: state the most plausible benign reading before alleging the alarming one.
|
|
4317
|
+
5. Label each claim: mark it observed, inferred, or assumed.
|
|
4318
|
+
6. A surfaced gap beats a guessed answer: flag what you cannot determine rather than fabricating past it.`;
|
|
4319
|
+
var DISCIPLINE_GATES_V1_NO_TOOLS = `Work through these gates at every judgment point, explicitly:
|
|
4320
|
+
1. Evidence before reasoning: cite what you observed before concluding from it.
|
|
4321
|
+
2. One extra signal: when a finding feels conclusive, check one more adjacent signal before stating it.
|
|
4322
|
+
3. Innocent explanation first: state the most plausible benign reading before alleging the alarming one.
|
|
4323
|
+
4. Label each claim: mark it observed, inferred, or assumed.
|
|
4324
|
+
5. A surfaced gap beats a guessed answer: flag what you cannot determine rather than fabricating past it.`;
|
|
4325
|
+
var DISCIPLINE_ELIGIBLE_ARCHETYPES = /* @__PURE__ */ new Set([
|
|
4326
|
+
"hunt",
|
|
4327
|
+
"summarize",
|
|
4328
|
+
"plan",
|
|
4329
|
+
"critique",
|
|
4330
|
+
"judge"
|
|
4331
|
+
]);
|
|
4332
|
+
function matchRule(kind, profile, archetype, ctx) {
|
|
4333
|
+
if (kind === "discipline_contract") {
|
|
4334
|
+
if (!DISCIPLINE_ELIGIBLE_ARCHETYPES.has(archetype)) return null;
|
|
4335
|
+
if (ctx.outputMode !== "text") return null;
|
|
4336
|
+
return {
|
|
4337
|
+
id: RULE_DISCIPLINE_GATES_V1,
|
|
4338
|
+
preamble: ctx.hasTools ? DISCIPLINE_GATES_V1_WITH_TOOLS : DISCIPLINE_GATES_V1_NO_TOOLS
|
|
4339
|
+
};
|
|
4340
|
+
}
|
|
4312
4341
|
if (kind === "tool_call_contract") {
|
|
4313
4342
|
if (!profile.archetypePerf) return null;
|
|
4314
4343
|
const archetypeScore = profile.archetypePerf[archetype];
|
|
@@ -4343,10 +4372,13 @@ function applySectionRewrites(args) {
|
|
|
4343
4372
|
if (!Array.isArray(ir.sections) || ir.sections.length === 0) {
|
|
4344
4373
|
return { rewrittenIR: ir, rewrites: [] };
|
|
4345
4374
|
}
|
|
4375
|
+
const outputMode = args.outputMode ?? (ir.constraints?.structuredOutput === true ? "json" : "text");
|
|
4376
|
+
const hasTools = (ir.tools?.length ?? 0) > 0;
|
|
4377
|
+
const ctx = { outputMode, hasTools };
|
|
4346
4378
|
const rewrites = [];
|
|
4347
4379
|
const newSections = ir.sections.map((section) => {
|
|
4348
4380
|
if (!section.kind || section.kind === "arbitrary") return section;
|
|
4349
|
-
const rule = matchRule(section.kind, profile, archetype);
|
|
4381
|
+
const rule = matchRule(section.kind, profile, archetype, ctx);
|
|
4350
4382
|
if (!rule) return section;
|
|
4351
4383
|
const originalText = section.text;
|
|
4352
4384
|
const transformedText = `${rule.preamble}
|
|
@@ -4551,13 +4583,24 @@ function compile(ir, opts = {}) {
|
|
|
4551
4583
|
const conventions = passApplyConventions(workingIR, profile);
|
|
4552
4584
|
workingIR = conventions.value.ir;
|
|
4553
4585
|
accumulatedMutations.push(...conventions.mutations);
|
|
4586
|
+
const outputMode = ir.constraints?.structuredOutput === true ? "json" : "text";
|
|
4554
4587
|
const translated = applySectionRewrites({
|
|
4555
4588
|
ir: workingIR,
|
|
4556
4589
|
profile,
|
|
4557
|
-
archetype: ir.intent.archetype
|
|
4590
|
+
archetype: ir.intent.archetype,
|
|
4591
|
+
outputMode
|
|
4558
4592
|
});
|
|
4559
4593
|
workingIR = translated.rewrittenIR;
|
|
4560
4594
|
const sectionRewritesApplied = translated.rewrites;
|
|
4595
|
+
const disciplineRewrite = sectionRewritesApplied.find(
|
|
4596
|
+
(rw) => rw.kind === "discipline_contract"
|
|
4597
|
+
);
|
|
4598
|
+
const disciplineGateTokens = disciplineRewrite ? countTokens(
|
|
4599
|
+
disciplineRewrite.transformedText.slice(
|
|
4600
|
+
0,
|
|
4601
|
+
disciplineRewrite.transformedText.length - disciplineRewrite.originalText.length
|
|
4602
|
+
)
|
|
4603
|
+
) : 0;
|
|
4561
4604
|
let wireOverrides;
|
|
4562
4605
|
for (const rw of sectionRewritesApplied) {
|
|
4563
4606
|
if (!rw.wireOverrides) continue;
|
|
@@ -4610,7 +4653,10 @@ function compile(ir, opts = {}) {
|
|
|
4610
4653
|
cliffWarnings: [
|
|
4611
4654
|
...cliffs.value.loweringHints.qualityWarning ?? [],
|
|
4612
4655
|
...conventions.value.cliffWarnings
|
|
4613
|
-
]
|
|
4656
|
+
],
|
|
4657
|
+
// alpha.68 / Release A — measured discipline gate-token tax (§5.D). 0 when
|
|
4658
|
+
// the gate didn't fire.
|
|
4659
|
+
disciplineGateTokens
|
|
4614
4660
|
};
|
|
4615
4661
|
if (ir.intent.archetype === "hunt" && ir.constraints?.toolOrchestration === "sequential") {
|
|
4616
4662
|
accumulatedMutations.push({
|
|
@@ -5014,7 +5060,7 @@ async function flushBrainDeadLetter() {
|
|
|
5014
5060
|
}
|
|
5015
5061
|
var compileRegistry = /* @__PURE__ */ new Map();
|
|
5016
5062
|
var REGISTRY_MAX_ENTRIES = 1e4;
|
|
5017
|
-
function registerCompile(appId, archetype, ir, result) {
|
|
5063
|
+
function registerCompile(appId, archetype, ir, result, parentHandle) {
|
|
5018
5064
|
if (compileRegistry.size >= REGISTRY_MAX_ENTRIES) {
|
|
5019
5065
|
const cutoff = Math.floor(REGISTRY_MAX_ENTRIES * 0.25);
|
|
5020
5066
|
let evicted = 0;
|
|
@@ -5066,7 +5112,15 @@ function registerCompile(appId, archetype, ir, result) {
|
|
|
5066
5112
|
// outcome quality lifted to M."
|
|
5067
5113
|
sectionRewritesApplied: result.sectionRewritesApplied,
|
|
5068
5114
|
// alpha.57: cache the declared effort tier for record()'s auto-enrich.
|
|
5069
|
-
effortFromCompile: ir.constraints?.effort
|
|
5115
|
+
effortFromCompile: ir.constraints?.effort,
|
|
5116
|
+
// alpha.68 / Release A (§5.0, R0 linkage) — derive + cache the fan-out
|
|
5117
|
+
// linkage. Release A is 1-level: a branch's trace_id is its parent handle
|
|
5118
|
+
// (the root); deeper trees await the delegate primitive (Release D).
|
|
5119
|
+
parentHandle,
|
|
5120
|
+
traceId: parentHandle ?? result.handle,
|
|
5121
|
+
fanoutRole: parentHandle ? "branch" : "root",
|
|
5122
|
+
// alpha.68 / Release A (§5.D) — measured gate-token tax from diagnostics.
|
|
5123
|
+
disciplineGateTokens: result.diagnostics.disciplineGateTokens
|
|
5070
5124
|
});
|
|
5071
5125
|
}
|
|
5072
5126
|
function estimateSystemPromptChars(sections) {
|
|
@@ -5257,7 +5311,17 @@ function buildPayload(input, reg) {
|
|
|
5257
5311
|
// alpha.29 — translator activity (migration 019). Send NULL when no
|
|
5258
5312
|
// rewrites fired so the brain's "did the translator do anything?"
|
|
5259
5313
|
// queries can use `IS NOT NULL` cleanly.
|
|
5260
|
-
section_rewrites_applied: reg?.sectionRewritesApplied && reg.sectionRewritesApplied.length > 0 ? reg.sectionRewritesApplied : null
|
|
5314
|
+
section_rewrites_applied: reg?.sectionRewritesApplied && reg.sectionRewritesApplied.length > 0 ? reg.sectionRewritesApplied : null,
|
|
5315
|
+
// alpha.68 / Release A (§5.0 + §5.D, migration 042) — auto-enrich the
|
|
5316
|
+
// fan-out linkage + discipline gate tax from the registered compile.
|
|
5317
|
+
// Omit-when-undefined (JSON.stringify drops undefined keys), same posture as
|
|
5318
|
+
// `effort` / `retried_same_model` → safe against pre-042 brains. A registered
|
|
5319
|
+
// compile always carries trace_id + fanout_role + discipline_gate_tokens
|
|
5320
|
+
// (root/0 for ordinary traffic); parent_handle is present only for branches.
|
|
5321
|
+
parent_handle: reg?.parentHandle,
|
|
5322
|
+
trace_id: reg?.traceId,
|
|
5323
|
+
fanout_role: reg?.fanoutRole,
|
|
5324
|
+
discipline_gate_tokens: reg?.disciplineGateTokens
|
|
5261
5325
|
};
|
|
5262
5326
|
}
|
|
5263
5327
|
function computeCostUsd(modelId, tokensIn, tokensOut) {
|
|
@@ -7187,9 +7251,11 @@ function compileAndRegister(ir, opts) {
|
|
|
7187
7251
|
const result = compile(ir, {
|
|
7188
7252
|
policy: opts.policy,
|
|
7189
7253
|
toolRelevanceThreshold: opts.toolRelevanceThreshold,
|
|
7190
|
-
compressHistoryAfter: opts.compressHistoryAfter
|
|
7254
|
+
compressHistoryAfter: opts.compressHistoryAfter,
|
|
7255
|
+
// alpha.68 / Release A — carry the fan-out parent handle through to compile.
|
|
7256
|
+
parentHandle: opts.parentHandle
|
|
7191
7257
|
});
|
|
7192
|
-
registerCompile(ir.appId, ir.intent.archetype, ir, result);
|
|
7258
|
+
registerCompile(ir.appId, ir.intent.archetype, ir, result, opts.parentHandle);
|
|
7193
7259
|
return result;
|
|
7194
7260
|
}
|
|
7195
7261
|
function extractPromptPreview(ir) {
|
|
@@ -7540,7 +7606,7 @@ function attachCacheControlToStreamTextInput(result, convertedMessages) {
|
|
|
7540
7606
|
// src/compile-aisdk.ts
|
|
7541
7607
|
function compileForAISDKv6(ir, opts) {
|
|
7542
7608
|
const result = compile(ir, opts);
|
|
7543
|
-
registerCompile(ir.appId, ir.intent.archetype, ir, result);
|
|
7609
|
+
registerCompile(ir.appId, ir.intent.archetype, ir, result, opts?.parentHandle);
|
|
7544
7610
|
armCompileConsumeTracking(result.handle);
|
|
7545
7611
|
const systemMessages = result.systemMessages;
|
|
7546
7612
|
const hasStructuredSystemCacheControl = result.provider === "anthropic" && systemMessages.some(
|
|
@@ -8293,7 +8359,7 @@ function createBrainForwardRoutes(config) {
|
|
|
8293
8359
|
}
|
|
8294
8360
|
|
|
8295
8361
|
// src/version.ts
|
|
8296
|
-
var LIBRARY_VERSION = "2.0.0-alpha.
|
|
8362
|
+
var LIBRARY_VERSION = "2.0.0-alpha.68";
|
|
8297
8363
|
|
|
8298
8364
|
// src/key-health.ts
|
|
8299
8365
|
var JSON_HEADERS2 = { "Content-Type": "application/json" };
|
|
@@ -8914,7 +8980,7 @@ async function markExclusionFindingHandled(opts) {
|
|
|
8914
8980
|
// src/index.ts
|
|
8915
8981
|
function compile2(ir, opts) {
|
|
8916
8982
|
const result = compile(ir, opts);
|
|
8917
|
-
registerCompile(ir.appId, ir.intent.archetype, ir, result);
|
|
8983
|
+
registerCompile(ir.appId, ir.intent.archetype, ir, result, opts?.parentHandle);
|
|
8918
8984
|
return result;
|
|
8919
8985
|
}
|
|
8920
8986
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
LIBRARY_VERSION,
|
|
17
17
|
createKeyHealthRoute
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-2ZHYFV7G.mjs";
|
|
19
19
|
import {
|
|
20
20
|
ABSOLUTE_FLOOR,
|
|
21
21
|
ARCHETYPE_FLOOR_DEFAULT,
|
|
@@ -2289,7 +2289,36 @@ var RULE_NARRATION_THINKING_LEAK_DEEPSEEK = "narration-thinking-leak-deepseek";
|
|
|
2289
2289
|
var SEQUENTIAL_TOOL_PREAMBLE = "IMPORTANT: Use one tool call per response. Wait for the tool result before deciding the next tool. Do NOT batch tool calls in parallel.";
|
|
2290
2290
|
var NARRATION_DRIFT_ANTHROPIC_PREAMBLE = "Output ONLY the requested content. Do not narrate your thought process. Each line \u2264 12 words.";
|
|
2291
2291
|
var NARRATION_THINKING_LEAK_DEEPSEEK_PREAMBLE = "Reasoning is internal. Output ONLY the requested content; do not emit <thinking> blocks or internal monologue as user-facing text.";
|
|
2292
|
-
|
|
2292
|
+
var RULE_DISCIPLINE_GATES_V1 = "discipline-gates-v1";
|
|
2293
|
+
var DISCIPLINE_GATES_V1_WITH_TOOLS = `Work through these gates at every judgment point, explicitly:
|
|
2294
|
+
1. Evidence before reasoning: cite what you observed before concluding from it.
|
|
2295
|
+
2. One extra signal: when a finding feels conclusive, check one more adjacent signal before stating it.
|
|
2296
|
+
3. Expand, don't guess: resolve a compressed or referenced item by looking it up rather than inferring its contents.
|
|
2297
|
+
4. Innocent explanation first: state the most plausible benign reading before alleging the alarming one.
|
|
2298
|
+
5. Label each claim: mark it observed, inferred, or assumed.
|
|
2299
|
+
6. A surfaced gap beats a guessed answer: flag what you cannot determine rather than fabricating past it.`;
|
|
2300
|
+
var DISCIPLINE_GATES_V1_NO_TOOLS = `Work through these gates at every judgment point, explicitly:
|
|
2301
|
+
1. Evidence before reasoning: cite what you observed before concluding from it.
|
|
2302
|
+
2. One extra signal: when a finding feels conclusive, check one more adjacent signal before stating it.
|
|
2303
|
+
3. Innocent explanation first: state the most plausible benign reading before alleging the alarming one.
|
|
2304
|
+
4. Label each claim: mark it observed, inferred, or assumed.
|
|
2305
|
+
5. A surfaced gap beats a guessed answer: flag what you cannot determine rather than fabricating past it.`;
|
|
2306
|
+
var DISCIPLINE_ELIGIBLE_ARCHETYPES = /* @__PURE__ */ new Set([
|
|
2307
|
+
"hunt",
|
|
2308
|
+
"summarize",
|
|
2309
|
+
"plan",
|
|
2310
|
+
"critique",
|
|
2311
|
+
"judge"
|
|
2312
|
+
]);
|
|
2313
|
+
function matchRule(kind, profile, archetype, ctx) {
|
|
2314
|
+
if (kind === "discipline_contract") {
|
|
2315
|
+
if (!DISCIPLINE_ELIGIBLE_ARCHETYPES.has(archetype)) return null;
|
|
2316
|
+
if (ctx.outputMode !== "text") return null;
|
|
2317
|
+
return {
|
|
2318
|
+
id: RULE_DISCIPLINE_GATES_V1,
|
|
2319
|
+
preamble: ctx.hasTools ? DISCIPLINE_GATES_V1_WITH_TOOLS : DISCIPLINE_GATES_V1_NO_TOOLS
|
|
2320
|
+
};
|
|
2321
|
+
}
|
|
2293
2322
|
if (kind === "tool_call_contract") {
|
|
2294
2323
|
if (!profile.archetypePerf) return null;
|
|
2295
2324
|
const archetypeScore = profile.archetypePerf[archetype];
|
|
@@ -2324,10 +2353,13 @@ function applySectionRewrites(args) {
|
|
|
2324
2353
|
if (!Array.isArray(ir.sections) || ir.sections.length === 0) {
|
|
2325
2354
|
return { rewrittenIR: ir, rewrites: [] };
|
|
2326
2355
|
}
|
|
2356
|
+
const outputMode = args.outputMode ?? (ir.constraints?.structuredOutput === true ? "json" : "text");
|
|
2357
|
+
const hasTools = (ir.tools?.length ?? 0) > 0;
|
|
2358
|
+
const ctx = { outputMode, hasTools };
|
|
2327
2359
|
const rewrites = [];
|
|
2328
2360
|
const newSections = ir.sections.map((section) => {
|
|
2329
2361
|
if (!section.kind || section.kind === "arbitrary") return section;
|
|
2330
|
-
const rule = matchRule(section.kind, profile, archetype);
|
|
2362
|
+
const rule = matchRule(section.kind, profile, archetype, ctx);
|
|
2331
2363
|
if (!rule) return section;
|
|
2332
2364
|
const originalText = section.text;
|
|
2333
2365
|
const transformedText = `${rule.preamble}
|
|
@@ -2532,13 +2564,24 @@ function compile(ir, opts = {}) {
|
|
|
2532
2564
|
const conventions = passApplyConventions(workingIR, profile);
|
|
2533
2565
|
workingIR = conventions.value.ir;
|
|
2534
2566
|
accumulatedMutations.push(...conventions.mutations);
|
|
2567
|
+
const outputMode = ir.constraints?.structuredOutput === true ? "json" : "text";
|
|
2535
2568
|
const translated = applySectionRewrites({
|
|
2536
2569
|
ir: workingIR,
|
|
2537
2570
|
profile,
|
|
2538
|
-
archetype: ir.intent.archetype
|
|
2571
|
+
archetype: ir.intent.archetype,
|
|
2572
|
+
outputMode
|
|
2539
2573
|
});
|
|
2540
2574
|
workingIR = translated.rewrittenIR;
|
|
2541
2575
|
const sectionRewritesApplied = translated.rewrites;
|
|
2576
|
+
const disciplineRewrite = sectionRewritesApplied.find(
|
|
2577
|
+
(rw) => rw.kind === "discipline_contract"
|
|
2578
|
+
);
|
|
2579
|
+
const disciplineGateTokens = disciplineRewrite ? countTokens(
|
|
2580
|
+
disciplineRewrite.transformedText.slice(
|
|
2581
|
+
0,
|
|
2582
|
+
disciplineRewrite.transformedText.length - disciplineRewrite.originalText.length
|
|
2583
|
+
)
|
|
2584
|
+
) : 0;
|
|
2542
2585
|
let wireOverrides;
|
|
2543
2586
|
for (const rw of sectionRewritesApplied) {
|
|
2544
2587
|
if (!rw.wireOverrides) continue;
|
|
@@ -2591,7 +2634,10 @@ function compile(ir, opts = {}) {
|
|
|
2591
2634
|
cliffWarnings: [
|
|
2592
2635
|
...cliffs.value.loweringHints.qualityWarning ?? [],
|
|
2593
2636
|
...conventions.value.cliffWarnings
|
|
2594
|
-
]
|
|
2637
|
+
],
|
|
2638
|
+
// alpha.68 / Release A — measured discipline gate-token tax (§5.D). 0 when
|
|
2639
|
+
// the gate didn't fire.
|
|
2640
|
+
disciplineGateTokens
|
|
2595
2641
|
};
|
|
2596
2642
|
if (ir.intent.archetype === "hunt" && ir.constraints?.toolOrchestration === "sequential") {
|
|
2597
2643
|
accumulatedMutations.push({
|
|
@@ -2995,7 +3041,7 @@ async function flushBrainDeadLetter() {
|
|
|
2995
3041
|
}
|
|
2996
3042
|
var compileRegistry = /* @__PURE__ */ new Map();
|
|
2997
3043
|
var REGISTRY_MAX_ENTRIES = 1e4;
|
|
2998
|
-
function registerCompile(appId, archetype, ir, result) {
|
|
3044
|
+
function registerCompile(appId, archetype, ir, result, parentHandle) {
|
|
2999
3045
|
if (compileRegistry.size >= REGISTRY_MAX_ENTRIES) {
|
|
3000
3046
|
const cutoff = Math.floor(REGISTRY_MAX_ENTRIES * 0.25);
|
|
3001
3047
|
let evicted = 0;
|
|
@@ -3047,7 +3093,15 @@ function registerCompile(appId, archetype, ir, result) {
|
|
|
3047
3093
|
// outcome quality lifted to M."
|
|
3048
3094
|
sectionRewritesApplied: result.sectionRewritesApplied,
|
|
3049
3095
|
// alpha.57: cache the declared effort tier for record()'s auto-enrich.
|
|
3050
|
-
effortFromCompile: ir.constraints?.effort
|
|
3096
|
+
effortFromCompile: ir.constraints?.effort,
|
|
3097
|
+
// alpha.68 / Release A (§5.0, R0 linkage) — derive + cache the fan-out
|
|
3098
|
+
// linkage. Release A is 1-level: a branch's trace_id is its parent handle
|
|
3099
|
+
// (the root); deeper trees await the delegate primitive (Release D).
|
|
3100
|
+
parentHandle,
|
|
3101
|
+
traceId: parentHandle ?? result.handle,
|
|
3102
|
+
fanoutRole: parentHandle ? "branch" : "root",
|
|
3103
|
+
// alpha.68 / Release A (§5.D) — measured gate-token tax from diagnostics.
|
|
3104
|
+
disciplineGateTokens: result.diagnostics.disciplineGateTokens
|
|
3051
3105
|
});
|
|
3052
3106
|
}
|
|
3053
3107
|
function estimateSystemPromptChars(sections) {
|
|
@@ -3238,7 +3292,17 @@ function buildPayload(input, reg) {
|
|
|
3238
3292
|
// alpha.29 — translator activity (migration 019). Send NULL when no
|
|
3239
3293
|
// rewrites fired so the brain's "did the translator do anything?"
|
|
3240
3294
|
// queries can use `IS NOT NULL` cleanly.
|
|
3241
|
-
section_rewrites_applied: reg?.sectionRewritesApplied && reg.sectionRewritesApplied.length > 0 ? reg.sectionRewritesApplied : null
|
|
3295
|
+
section_rewrites_applied: reg?.sectionRewritesApplied && reg.sectionRewritesApplied.length > 0 ? reg.sectionRewritesApplied : null,
|
|
3296
|
+
// alpha.68 / Release A (§5.0 + §5.D, migration 042) — auto-enrich the
|
|
3297
|
+
// fan-out linkage + discipline gate tax from the registered compile.
|
|
3298
|
+
// Omit-when-undefined (JSON.stringify drops undefined keys), same posture as
|
|
3299
|
+
// `effort` / `retried_same_model` → safe against pre-042 brains. A registered
|
|
3300
|
+
// compile always carries trace_id + fanout_role + discipline_gate_tokens
|
|
3301
|
+
// (root/0 for ordinary traffic); parent_handle is present only for branches.
|
|
3302
|
+
parent_handle: reg?.parentHandle,
|
|
3303
|
+
trace_id: reg?.traceId,
|
|
3304
|
+
fanout_role: reg?.fanoutRole,
|
|
3305
|
+
discipline_gate_tokens: reg?.disciplineGateTokens
|
|
3242
3306
|
};
|
|
3243
3307
|
}
|
|
3244
3308
|
function computeCostUsd(modelId, tokensIn, tokensOut) {
|
|
@@ -4429,9 +4493,11 @@ function compileAndRegister(ir, opts) {
|
|
|
4429
4493
|
const result = compile(ir, {
|
|
4430
4494
|
policy: opts.policy,
|
|
4431
4495
|
toolRelevanceThreshold: opts.toolRelevanceThreshold,
|
|
4432
|
-
compressHistoryAfter: opts.compressHistoryAfter
|
|
4496
|
+
compressHistoryAfter: opts.compressHistoryAfter,
|
|
4497
|
+
// alpha.68 / Release A — carry the fan-out parent handle through to compile.
|
|
4498
|
+
parentHandle: opts.parentHandle
|
|
4433
4499
|
});
|
|
4434
|
-
registerCompile(ir.appId, ir.intent.archetype, ir, result);
|
|
4500
|
+
registerCompile(ir.appId, ir.intent.archetype, ir, result, opts.parentHandle);
|
|
4435
4501
|
return result;
|
|
4436
4502
|
}
|
|
4437
4503
|
function extractPromptPreview(ir) {
|
|
@@ -4782,7 +4848,7 @@ function attachCacheControlToStreamTextInput(result, convertedMessages) {
|
|
|
4782
4848
|
// src/compile-aisdk.ts
|
|
4783
4849
|
function compileForAISDKv6(ir, opts) {
|
|
4784
4850
|
const result = compile(ir, opts);
|
|
4785
|
-
registerCompile(ir.appId, ir.intent.archetype, ir, result);
|
|
4851
|
+
registerCompile(ir.appId, ir.intent.archetype, ir, result, opts?.parentHandle);
|
|
4786
4852
|
armCompileConsumeTracking(result.handle);
|
|
4787
4853
|
const systemMessages = result.systemMessages;
|
|
4788
4854
|
const hasStructuredSystemCacheControl = result.provider === "anthropic" && systemMessages.some(
|
|
@@ -5791,7 +5857,7 @@ async function markExclusionFindingHandled(opts) {
|
|
|
5791
5857
|
// src/index.ts
|
|
5792
5858
|
function compile2(ir, opts) {
|
|
5793
5859
|
const result = compile(ir, opts);
|
|
5794
|
-
registerCompile(ir.appId, ir.intent.archetype, ir, result);
|
|
5860
|
+
registerCompile(ir.appId, ir.intent.archetype, ir, result, opts?.parentHandle);
|
|
5795
5861
|
return result;
|
|
5796
5862
|
}
|
|
5797
5863
|
export {
|
|
@@ -125,12 +125,21 @@ interface PromptSection {
|
|
|
125
125
|
* sequential-tool cliff on the active archetype
|
|
126
126
|
* - `narration_contract` — output-format rules ("don't narrate your steps");
|
|
127
127
|
* alpha.30+ candidate
|
|
128
|
+
* - `discipline_contract`— alpha.68 / Release A (delegation-fanout-accelerator
|
|
129
|
+
* §5.D): surface-scaffolding gate block. When declared
|
|
130
|
+
* on a role/system section, the translator prepends the
|
|
131
|
+
* frozen `discipline-gates-v1` preamble subject to a
|
|
132
|
+
* two-factor eligibility screen — Factor A (archetype:
|
|
133
|
+
* hunt/summarize/plan/critique/judge) AND Factor C
|
|
134
|
+
* (output-shape: text only, never json/tool_call).
|
|
135
|
+
* Clears no cliff, emits no wireOverrides ⇒ no advisor
|
|
136
|
+
* suppression. See `translator.ts`.
|
|
128
137
|
* - `user_turn` — when sections carry user content rather than
|
|
129
138
|
* system context (rare)
|
|
130
139
|
* - `reference` — supporting reference data the model may consult
|
|
131
140
|
* - `arbitrary` — explicit pass-through (default when unset)
|
|
132
141
|
*/
|
|
133
|
-
type SectionKind = 'role_intro' | 'tool_call_contract' | 'narration_contract' | 'user_turn' | 'reference' | 'arbitrary';
|
|
142
|
+
type SectionKind = 'role_intro' | 'tool_call_contract' | 'narration_contract' | 'discipline_contract' | 'user_turn' | 'reference' | 'arbitrary';
|
|
134
143
|
interface ToolDefinition {
|
|
135
144
|
name: string;
|
|
136
145
|
description?: string;
|
|
@@ -289,6 +298,18 @@ interface CompilePolicy {
|
|
|
289
298
|
* on high-volume routes.
|
|
290
299
|
*/
|
|
291
300
|
maxCostPerCallUsd?: number;
|
|
301
|
+
/**
|
|
302
|
+
* alpha.68 / Release A (delegation-fanout-accelerator §5.1) — trace-level
|
|
303
|
+
* cost ceiling (USD) across a fan-out `trace_id`'s cumulative spend.
|
|
304
|
+
*
|
|
305
|
+
* RECORDED / INERT in Release A: nothing fans out yet, so this field is
|
|
306
|
+
* accepted and carried but the compiler enforces NOTHING from it. It is
|
|
307
|
+
* enforced by the `delegate` primitive against the running trace spend in
|
|
308
|
+
* Release D. Kept distinct from `maxCostPerCallUsd` because that per-call
|
|
309
|
+
* ceiling is trivially evadable N times under fan-out — a fan-out budget
|
|
310
|
+
* has to be trace-scoped, not per-call.
|
|
311
|
+
*/
|
|
312
|
+
maxCostPerTraceUsd?: number;
|
|
292
313
|
/**
|
|
293
314
|
* Model IDs the consumer prefers. When multiple models fit, preferred
|
|
294
315
|
* models get a rank boost (large enough to overcome small quality
|
|
@@ -800,6 +821,16 @@ interface CompileResult {
|
|
|
800
821
|
* advisory text. Both can fire on the same call.
|
|
801
822
|
*/
|
|
802
823
|
cliffWarnings: string[];
|
|
824
|
+
/**
|
|
825
|
+
* alpha.68 / Release A (delegation-fanout-accelerator §5.D) — tokens added
|
|
826
|
+
* by the `discipline_contract` gate block on this call; 0 when the gate
|
|
827
|
+
* didn't fire (no eligible `discipline_contract` section, or Factor A /
|
|
828
|
+
* Factor C screened it out). Measured, never assumed: counted from the
|
|
829
|
+
* exact frozen preamble the translator prepended. Persisted to
|
|
830
|
+
* `compile_outcomes.discipline_gate_tokens` (migration 042) so the tax is a
|
|
831
|
+
* number the cost-watcher can weigh against the lift.
|
|
832
|
+
*/
|
|
833
|
+
disciplineGateTokens: number;
|
|
803
834
|
};
|
|
804
835
|
/**
|
|
805
836
|
* alpha.33. Structured `system` for AI-SDK `streamText({ system })`
|
|
@@ -987,6 +1018,18 @@ interface ShadowProbeConfig {
|
|
|
987
1018
|
interface CallOptions {
|
|
988
1019
|
/** Forwarded to compile(). */
|
|
989
1020
|
policy?: CompilePolicy;
|
|
1021
|
+
/**
|
|
1022
|
+
* alpha.68 / Release A (delegation-fanout-accelerator §5.0, R0 linkage).
|
|
1023
|
+
* When set, this call is a fan-out BRANCH of the parent trace: the outcome
|
|
1024
|
+
* row records `fanout_role='branch'`, `parent_handle=<this value>`, and
|
|
1025
|
+
* `trace_id` inherits the parent handle (the trace root). Absent ⇒ this is a
|
|
1026
|
+
* root (user-facing) call: `fanout_role='root'`, `trace_id=<own handle>`.
|
|
1027
|
+
* Pass the parent's `CallResult.handle` / `CompileResult.handle`.
|
|
1028
|
+
*
|
|
1029
|
+
* Release A supports 1-level linkage (root → branch); deeper trees await the
|
|
1030
|
+
* `delegate` primitive in Release D. Labelling only — NOT a routing change.
|
|
1031
|
+
*/
|
|
1032
|
+
parentHandle?: string;
|
|
990
1033
|
/**
|
|
991
1034
|
* alpha (s51 Phase 1) — full-IR inline shadow-probe. When set, kgauto
|
|
992
1035
|
* measures the candidate(s) on the same IR after serving the primary,
|
|
@@ -125,12 +125,21 @@ interface PromptSection {
|
|
|
125
125
|
* sequential-tool cliff on the active archetype
|
|
126
126
|
* - `narration_contract` — output-format rules ("don't narrate your steps");
|
|
127
127
|
* alpha.30+ candidate
|
|
128
|
+
* - `discipline_contract`— alpha.68 / Release A (delegation-fanout-accelerator
|
|
129
|
+
* §5.D): surface-scaffolding gate block. When declared
|
|
130
|
+
* on a role/system section, the translator prepends the
|
|
131
|
+
* frozen `discipline-gates-v1` preamble subject to a
|
|
132
|
+
* two-factor eligibility screen — Factor A (archetype:
|
|
133
|
+
* hunt/summarize/plan/critique/judge) AND Factor C
|
|
134
|
+
* (output-shape: text only, never json/tool_call).
|
|
135
|
+
* Clears no cliff, emits no wireOverrides ⇒ no advisor
|
|
136
|
+
* suppression. See `translator.ts`.
|
|
128
137
|
* - `user_turn` — when sections carry user content rather than
|
|
129
138
|
* system context (rare)
|
|
130
139
|
* - `reference` — supporting reference data the model may consult
|
|
131
140
|
* - `arbitrary` — explicit pass-through (default when unset)
|
|
132
141
|
*/
|
|
133
|
-
type SectionKind = 'role_intro' | 'tool_call_contract' | 'narration_contract' | 'user_turn' | 'reference' | 'arbitrary';
|
|
142
|
+
type SectionKind = 'role_intro' | 'tool_call_contract' | 'narration_contract' | 'discipline_contract' | 'user_turn' | 'reference' | 'arbitrary';
|
|
134
143
|
interface ToolDefinition {
|
|
135
144
|
name: string;
|
|
136
145
|
description?: string;
|
|
@@ -289,6 +298,18 @@ interface CompilePolicy {
|
|
|
289
298
|
* on high-volume routes.
|
|
290
299
|
*/
|
|
291
300
|
maxCostPerCallUsd?: number;
|
|
301
|
+
/**
|
|
302
|
+
* alpha.68 / Release A (delegation-fanout-accelerator §5.1) — trace-level
|
|
303
|
+
* cost ceiling (USD) across a fan-out `trace_id`'s cumulative spend.
|
|
304
|
+
*
|
|
305
|
+
* RECORDED / INERT in Release A: nothing fans out yet, so this field is
|
|
306
|
+
* accepted and carried but the compiler enforces NOTHING from it. It is
|
|
307
|
+
* enforced by the `delegate` primitive against the running trace spend in
|
|
308
|
+
* Release D. Kept distinct from `maxCostPerCallUsd` because that per-call
|
|
309
|
+
* ceiling is trivially evadable N times under fan-out — a fan-out budget
|
|
310
|
+
* has to be trace-scoped, not per-call.
|
|
311
|
+
*/
|
|
312
|
+
maxCostPerTraceUsd?: number;
|
|
292
313
|
/**
|
|
293
314
|
* Model IDs the consumer prefers. When multiple models fit, preferred
|
|
294
315
|
* models get a rank boost (large enough to overcome small quality
|
|
@@ -800,6 +821,16 @@ interface CompileResult {
|
|
|
800
821
|
* advisory text. Both can fire on the same call.
|
|
801
822
|
*/
|
|
802
823
|
cliffWarnings: string[];
|
|
824
|
+
/**
|
|
825
|
+
* alpha.68 / Release A (delegation-fanout-accelerator §5.D) — tokens added
|
|
826
|
+
* by the `discipline_contract` gate block on this call; 0 when the gate
|
|
827
|
+
* didn't fire (no eligible `discipline_contract` section, or Factor A /
|
|
828
|
+
* Factor C screened it out). Measured, never assumed: counted from the
|
|
829
|
+
* exact frozen preamble the translator prepended. Persisted to
|
|
830
|
+
* `compile_outcomes.discipline_gate_tokens` (migration 042) so the tax is a
|
|
831
|
+
* number the cost-watcher can weigh against the lift.
|
|
832
|
+
*/
|
|
833
|
+
disciplineGateTokens: number;
|
|
803
834
|
};
|
|
804
835
|
/**
|
|
805
836
|
* alpha.33. Structured `system` for AI-SDK `streamText({ system })`
|
|
@@ -987,6 +1018,18 @@ interface ShadowProbeConfig {
|
|
|
987
1018
|
interface CallOptions {
|
|
988
1019
|
/** Forwarded to compile(). */
|
|
989
1020
|
policy?: CompilePolicy;
|
|
1021
|
+
/**
|
|
1022
|
+
* alpha.68 / Release A (delegation-fanout-accelerator §5.0, R0 linkage).
|
|
1023
|
+
* When set, this call is a fan-out BRANCH of the parent trace: the outcome
|
|
1024
|
+
* row records `fanout_role='branch'`, `parent_handle=<this value>`, and
|
|
1025
|
+
* `trace_id` inherits the parent handle (the trace root). Absent ⇒ this is a
|
|
1026
|
+
* root (user-facing) call: `fanout_role='root'`, `trace_id=<own handle>`.
|
|
1027
|
+
* Pass the parent's `CallResult.handle` / `CompileResult.handle`.
|
|
1028
|
+
*
|
|
1029
|
+
* Release A supports 1-level linkage (root → branch); deeper trees await the
|
|
1030
|
+
* `delegate` primitive in Release D. Labelling only — NOT a routing change.
|
|
1031
|
+
*/
|
|
1032
|
+
parentHandle?: string;
|
|
990
1033
|
/**
|
|
991
1034
|
* alpha (s51 Phase 1) — full-IR inline shadow-probe. When set, kgauto
|
|
992
1035
|
* measures the candidate(s) on the same IR after serving the primary,
|
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.68";
|
|
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,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-Pv19aEBR.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-Ct_YDN7y.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.
|
|
3
|
+
"version": "2.0.0-alpha.68",
|
|
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",
|