@warmdrift/kgauto-compiler 2.0.0-alpha.32 → 2.0.0-alpha.34
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-WXCFWUCN.mjs → chunk-XJZRDGHF.mjs} +11 -6
- package/dist/glassbox/index.d.mts +3 -3
- package/dist/glassbox/index.d.ts +3 -3
- package/dist/glassbox-routes/index.d.mts +2 -2
- package/dist/glassbox-routes/index.d.ts +2 -2
- package/dist/glassbox-routes/index.js +11 -6
- package/dist/glassbox-routes/index.mjs +1 -1
- package/dist/index.d.mts +95 -3
- package/dist/index.d.ts +95 -3
- package/dist/index.js +410 -25
- package/dist/index.mjs +399 -20
- package/dist/{ir-De2AQtlr.d.mts → ir-BAAHLfFL.d.mts} +118 -1
- package/dist/{ir-BIAT9gJk.d.ts → ir-B_ygNURd.d.ts} +118 -1
- package/dist/profiles.d.mts +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{types-BjrIFPGe.d.mts → types-BoqPXoUb.d.mts} +1 -1
- package/dist/{types-D_JAhCv4.d.ts → types-CXyKj6-K.d.ts} +1 -1
- package/package.json +1 -1
|
@@ -328,7 +328,8 @@ var STARTER_CHAINS_GROUNDED = {
|
|
|
328
328
|
{ id: "claude-sonnet-4-6", grounding: "judgment", reason: "Reasoning + cost balance \u2014 engineer pick" },
|
|
329
329
|
{ id: "claude-opus-4-7", grounding: "judgment", reason: 'Same-provider walk-UP on 429 (rare exception to "always cheaper")' },
|
|
330
330
|
{ id: "gemini-2.5-pro", grounding: "judgment", reason: "Cross-provider anchor" },
|
|
331
|
-
{ id: "deepseek-v4-pro", grounding: "judgment", reason: "Tier 3 cost floor \u2014 no brain evidence yet" }
|
|
331
|
+
{ id: "deepseek-v4-pro", grounding: "judgment", reason: "Tier 3 cost floor \u2014 no brain evidence yet" },
|
|
332
|
+
{ id: "gpt-5.4", grounding: "judgment", reason: "alpha.33: third-provider tail (archetypePerf=7) \u2014 closes openai-in-default-fallback-chains" }
|
|
332
333
|
],
|
|
333
334
|
// Quality + cost match.
|
|
334
335
|
generate: [
|
|
@@ -359,7 +360,8 @@ var STARTER_CHAINS_GROUNDED = {
|
|
|
359
360
|
{ id: "claude-sonnet-4-6", grounding: "judgment", reason: "Quality anchor \u2014 engineer pick" },
|
|
360
361
|
{ id: "claude-haiku-4-5", grounding: "judgment", reason: "Same-provider step-down" },
|
|
361
362
|
{ id: "gemini-2.5-pro", grounding: "judgment", reason: "Cross-provider anchor" },
|
|
362
|
-
{ id: "gemini-2.5-flash", grounding: "judgment", reason: "Cost floor \u2014 forgiving archetype tolerates Flash" }
|
|
363
|
+
{ id: "gemini-2.5-flash", grounding: "judgment", reason: "Cost floor \u2014 forgiving archetype tolerates Flash" },
|
|
364
|
+
{ id: "gpt-5.4-mini", grounding: "judgment", reason: "alpha.33: third-provider tail (archetypePerf=7) \u2014 closes openai-in-default-fallback-chains" }
|
|
363
365
|
],
|
|
364
366
|
// Parallel-tool throughput champion — Flash leads on the L-040 cliff
|
|
365
367
|
// (capability-fact: Flash 15-75 parallel calls/step vs DeepSeek 7-8).
|
|
@@ -367,21 +369,24 @@ var STARTER_CHAINS_GROUNDED = {
|
|
|
367
369
|
{ id: "gemini-2.5-flash", grounding: "capability-fact", reason: "L-040 parallel-tool throughput champion (15-75 calls/step)" },
|
|
368
370
|
{ id: "gemini-2.5-pro", grounding: "capability-fact", reason: "Cross-provider tier 1 with strong parallel-tool support" },
|
|
369
371
|
{ id: "claude-sonnet-4-6", grounding: "judgment", reason: "Quality safety net for blocked-Flash case" },
|
|
370
|
-
{ id: "claude-haiku-4-5", grounding: "judgment", reason: "Reduced tool budget \u2014 cliff at 16 fires" }
|
|
372
|
+
{ id: "claude-haiku-4-5", grounding: "judgment", reason: "Reduced tool budget \u2014 cliff at 16 fires" },
|
|
373
|
+
{ id: "gpt-5.4-mini", grounding: "judgment", reason: "alpha.33: third-provider tail \u2014 OpenAI parallel-tool capable archetype" }
|
|
371
374
|
],
|
|
372
375
|
// Cost-sensitive + tolerant. DeepSeek brain-evidence tier 1.
|
|
373
376
|
summarize: [
|
|
374
377
|
{ id: "gemini-2.5-flash", grounding: "judgment", reason: "Cost-sensitive primary \u2014 engineer pick" },
|
|
375
378
|
{ id: "deepseek-v4-flash", grounding: "measured", reason: "Brain-validated tier 1 for cost-sensitive summarize workloads", n: 169 },
|
|
376
379
|
{ id: "claude-haiku-4-5", grounding: "judgment", reason: "Quality safety net" },
|
|
377
|
-
{ id: "gemini-2.5-flash-lite", grounding: "judgment", reason: "Emergency floor \u2014 onboarded s22, no brain evidence yet" }
|
|
380
|
+
{ id: "gemini-2.5-flash-lite", grounding: "judgment", reason: "Emergency floor \u2014 onboarded s22, no brain evidence yet" },
|
|
381
|
+
{ id: "gpt-5.4-nano", grounding: "judgment", reason: "alpha.33: third-provider tail (archetypePerf=6) \u2014 cheapest OpenAI, matches summarize cost-band" }
|
|
378
382
|
],
|
|
379
383
|
// Brain-validated DeepSeek tier 1 (169 rows, 0% empty rate).
|
|
380
384
|
classify: [
|
|
381
385
|
{ id: "gemini-2.5-flash", grounding: "judgment", reason: "Cost-sensitive primary \u2014 engineer pick" },
|
|
382
386
|
{ id: "deepseek-v4-flash", grounding: "measured", reason: "Brain-validated tier 1 (169 rows, 0% empty rate)", n: 169 },
|
|
383
387
|
{ id: "claude-haiku-4-5", grounding: "judgment", reason: "Quality safety net" },
|
|
384
|
-
{ id: "gemini-2.5-flash-lite", grounding: "judgment", reason: "Cache-discount 10\xD7 floor for repeat-prompt workloads" }
|
|
388
|
+
{ id: "gemini-2.5-flash-lite", grounding: "judgment", reason: "Cache-discount 10\xD7 floor for repeat-prompt workloads" },
|
|
389
|
+
{ id: "gpt-5.4-nano", grounding: "judgment", reason: "alpha.33: third-provider tail (archetypePerf=6) \u2014 cheapest OpenAI for classify" }
|
|
385
390
|
]
|
|
386
391
|
};
|
|
387
392
|
var STARTER_CHAINS = (() => {
|
|
@@ -436,7 +441,7 @@ function resolveStarterForMode(archetype, toolOrchestration, allChains) {
|
|
|
436
441
|
return allChains[archetype];
|
|
437
442
|
}
|
|
438
443
|
function getDefaultFallbackChain(opts) {
|
|
439
|
-
const { archetype, primary, maxDepth =
|
|
444
|
+
const { archetype, primary, maxDepth = 4, policy, reachability, toolOrchestration } = opts;
|
|
440
445
|
if (maxDepth < 1) {
|
|
441
446
|
throw new Error(
|
|
442
447
|
`getDefaultFallbackChain: maxDepth must be >= 1, got ${maxDepth}`
|
|
@@ -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-BoqPXoUb.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-BoqPXoUb.mjs';
|
|
3
|
+
import '../ir-BAAHLfFL.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-CXyKj6-K.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-CXyKj6-K.js';
|
|
3
|
+
import '../ir-B_ygNURd.js';
|
|
4
4
|
import '../dialect.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
2
|
-
import {
|
|
1
|
+
import { G as GlassboxEvent } from '../types-BoqPXoUb.mjs';
|
|
2
|
+
import { i as Adapter, v as SectionKind } from '../ir-BAAHLfFL.mjs';
|
|
3
3
|
import '../dialect.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
2
|
-
import {
|
|
1
|
+
import { G as GlassboxEvent } from '../types-CXyKj6-K.js';
|
|
2
|
+
import { i as Adapter, v as SectionKind } from '../ir-B_ygNURd.js';
|
|
3
3
|
import '../dialect.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1414,7 +1414,8 @@ var STARTER_CHAINS_GROUNDED = {
|
|
|
1414
1414
|
{ id: "claude-sonnet-4-6", grounding: "judgment", reason: "Reasoning + cost balance \u2014 engineer pick" },
|
|
1415
1415
|
{ id: "claude-opus-4-7", grounding: "judgment", reason: 'Same-provider walk-UP on 429 (rare exception to "always cheaper")' },
|
|
1416
1416
|
{ id: "gemini-2.5-pro", grounding: "judgment", reason: "Cross-provider anchor" },
|
|
1417
|
-
{ id: "deepseek-v4-pro", grounding: "judgment", reason: "Tier 3 cost floor \u2014 no brain evidence yet" }
|
|
1417
|
+
{ id: "deepseek-v4-pro", grounding: "judgment", reason: "Tier 3 cost floor \u2014 no brain evidence yet" },
|
|
1418
|
+
{ id: "gpt-5.4", grounding: "judgment", reason: "alpha.33: third-provider tail (archetypePerf=7) \u2014 closes openai-in-default-fallback-chains" }
|
|
1418
1419
|
],
|
|
1419
1420
|
// Quality + cost match.
|
|
1420
1421
|
generate: [
|
|
@@ -1445,7 +1446,8 @@ var STARTER_CHAINS_GROUNDED = {
|
|
|
1445
1446
|
{ id: "claude-sonnet-4-6", grounding: "judgment", reason: "Quality anchor \u2014 engineer pick" },
|
|
1446
1447
|
{ id: "claude-haiku-4-5", grounding: "judgment", reason: "Same-provider step-down" },
|
|
1447
1448
|
{ id: "gemini-2.5-pro", grounding: "judgment", reason: "Cross-provider anchor" },
|
|
1448
|
-
{ id: "gemini-2.5-flash", grounding: "judgment", reason: "Cost floor \u2014 forgiving archetype tolerates Flash" }
|
|
1449
|
+
{ id: "gemini-2.5-flash", grounding: "judgment", reason: "Cost floor \u2014 forgiving archetype tolerates Flash" },
|
|
1450
|
+
{ id: "gpt-5.4-mini", grounding: "judgment", reason: "alpha.33: third-provider tail (archetypePerf=7) \u2014 closes openai-in-default-fallback-chains" }
|
|
1449
1451
|
],
|
|
1450
1452
|
// Parallel-tool throughput champion — Flash leads on the L-040 cliff
|
|
1451
1453
|
// (capability-fact: Flash 15-75 parallel calls/step vs DeepSeek 7-8).
|
|
@@ -1453,21 +1455,24 @@ var STARTER_CHAINS_GROUNDED = {
|
|
|
1453
1455
|
{ id: "gemini-2.5-flash", grounding: "capability-fact", reason: "L-040 parallel-tool throughput champion (15-75 calls/step)" },
|
|
1454
1456
|
{ id: "gemini-2.5-pro", grounding: "capability-fact", reason: "Cross-provider tier 1 with strong parallel-tool support" },
|
|
1455
1457
|
{ id: "claude-sonnet-4-6", grounding: "judgment", reason: "Quality safety net for blocked-Flash case" },
|
|
1456
|
-
{ id: "claude-haiku-4-5", grounding: "judgment", reason: "Reduced tool budget \u2014 cliff at 16 fires" }
|
|
1458
|
+
{ id: "claude-haiku-4-5", grounding: "judgment", reason: "Reduced tool budget \u2014 cliff at 16 fires" },
|
|
1459
|
+
{ id: "gpt-5.4-mini", grounding: "judgment", reason: "alpha.33: third-provider tail \u2014 OpenAI parallel-tool capable archetype" }
|
|
1457
1460
|
],
|
|
1458
1461
|
// Cost-sensitive + tolerant. DeepSeek brain-evidence tier 1.
|
|
1459
1462
|
summarize: [
|
|
1460
1463
|
{ id: "gemini-2.5-flash", grounding: "judgment", reason: "Cost-sensitive primary \u2014 engineer pick" },
|
|
1461
1464
|
{ id: "deepseek-v4-flash", grounding: "measured", reason: "Brain-validated tier 1 for cost-sensitive summarize workloads", n: 169 },
|
|
1462
1465
|
{ id: "claude-haiku-4-5", grounding: "judgment", reason: "Quality safety net" },
|
|
1463
|
-
{ id: "gemini-2.5-flash-lite", grounding: "judgment", reason: "Emergency floor \u2014 onboarded s22, no brain evidence yet" }
|
|
1466
|
+
{ id: "gemini-2.5-flash-lite", grounding: "judgment", reason: "Emergency floor \u2014 onboarded s22, no brain evidence yet" },
|
|
1467
|
+
{ id: "gpt-5.4-nano", grounding: "judgment", reason: "alpha.33: third-provider tail (archetypePerf=6) \u2014 cheapest OpenAI, matches summarize cost-band" }
|
|
1464
1468
|
],
|
|
1465
1469
|
// Brain-validated DeepSeek tier 1 (169 rows, 0% empty rate).
|
|
1466
1470
|
classify: [
|
|
1467
1471
|
{ id: "gemini-2.5-flash", grounding: "judgment", reason: "Cost-sensitive primary \u2014 engineer pick" },
|
|
1468
1472
|
{ id: "deepseek-v4-flash", grounding: "measured", reason: "Brain-validated tier 1 (169 rows, 0% empty rate)", n: 169 },
|
|
1469
1473
|
{ id: "claude-haiku-4-5", grounding: "judgment", reason: "Quality safety net" },
|
|
1470
|
-
{ id: "gemini-2.5-flash-lite", grounding: "judgment", reason: "Cache-discount 10\xD7 floor for repeat-prompt workloads" }
|
|
1474
|
+
{ id: "gemini-2.5-flash-lite", grounding: "judgment", reason: "Cache-discount 10\xD7 floor for repeat-prompt workloads" },
|
|
1475
|
+
{ id: "gpt-5.4-nano", grounding: "judgment", reason: "alpha.33: third-provider tail (archetypePerf=6) \u2014 cheapest OpenAI for classify" }
|
|
1471
1476
|
]
|
|
1472
1477
|
};
|
|
1473
1478
|
var STARTER_CHAINS = (() => {
|
|
@@ -1522,7 +1527,7 @@ function resolveStarterForMode(archetype, toolOrchestration, allChains) {
|
|
|
1522
1527
|
return allChains[archetype];
|
|
1523
1528
|
}
|
|
1524
1529
|
function getDefaultFallbackChain(opts) {
|
|
1525
|
-
const { archetype, primary, maxDepth =
|
|
1530
|
+
const { archetype, primary, maxDepth = 4, policy, reachability, toolOrchestration } = opts;
|
|
1526
1531
|
if (maxDepth < 1) {
|
|
1527
1532
|
throw new Error(
|
|
1528
1533
|
`getDefaultFallbackChain: maxDepth must be >= 1, got ${maxDepth}`
|
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 SectionRewrite, R as RecordInput,
|
|
2
|
-
export {
|
|
1
|
+
import { C as CompilePolicy, N as NormalizedResponse, A as ApiKeys, P as ProviderOverrides, a as CompiledRequest, b as PromptIR, c as CallOptions, d as CallResult, S as SystemModelMessage, e as CompileResult, f as SectionRewrite, R as RecordInput, g as RecordOutcomeInput, O as OutcomeResult, h as OracleScore, B as BestPracticeAdvisory, i as Adapter, j as PerAxisMetrics, k as Provider, l as ChainEntry, G as Grounding } from './ir-BAAHLfFL.mjs';
|
|
2
|
+
export { m as CallAttempt, n as CallError, o as ChainWithGrounding, p as Constraints, F as FallbackReason, H as HistoryCachePolicy, I as IntentDeclaration, M as Message, q as MutationApplied, r as NormalizedTokens, s as OutcomeKind, t as PerAxisMetricsByModel, u as PromptSection, v as SectionKind, T as ToolCall, w as ToolDefinition } from './ir-BAAHLfFL.mjs';
|
|
3
3
|
import { ModelProfile } from './profiles.mjs';
|
|
4
4
|
export { ALIASES, CacheStrategy, CliffRule, LoweringSpec, RecoveryRule, StructuredOutputCapability, SystemPromptMode, allProfiles, getProfile, profilesByProvider, tryGetProfile } from './profiles.mjs';
|
|
5
5
|
import { IntentArchetypeName } from './dialect.mjs';
|
|
@@ -54,6 +54,15 @@ interface ExecuteOptions {
|
|
|
54
54
|
apiKeys?: ApiKeys;
|
|
55
55
|
fetchImpl?: typeof fetch;
|
|
56
56
|
providerOverrides?: ProviderOverrides;
|
|
57
|
+
/**
|
|
58
|
+
* alpha.34. When supplied AND the chosen provider supports streaming, the
|
|
59
|
+
* execute() per-provider branch switches to SSE wire format and invokes
|
|
60
|
+
* `onChunk(delta)` once per text-delta event. Single-shot behavior
|
|
61
|
+
* preserved when omitted (current consumers unaffected). Wired from
|
|
62
|
+
* `CallOptions.onChunk` by `call()` after gating on `profile.streaming`
|
|
63
|
+
* and `!opts.noStream`.
|
|
64
|
+
*/
|
|
65
|
+
onChunk?: (chunk: string) => void;
|
|
57
66
|
}
|
|
58
67
|
interface ExecuteOk {
|
|
59
68
|
ok: true;
|
|
@@ -94,6 +103,89 @@ declare function execute(request: CompiledRequest, opts?: ExecuteOptions): Promi
|
|
|
94
103
|
*/
|
|
95
104
|
declare function call(ir: PromptIR, opts?: CallOptions): Promise<CallResult>;
|
|
96
105
|
|
|
106
|
+
/**
|
|
107
|
+
* alpha.33 — AI-SDK streamText helpers.
|
|
108
|
+
*
|
|
109
|
+
* The cross-consumer pattern surfaced 2026-05-20 (`streamText-cache-marker-
|
|
110
|
+
* propagation-gap` on `command-center/interfaces/kgauto.md ## Requested`):
|
|
111
|
+
* AI-SDK consumers using `streamText({ system: <string>, messages:
|
|
112
|
+
* convertToModelMessages(messages), model })` silently drop the Anthropic
|
|
113
|
+
* `cache_control` markers the compiler emits on `result.request.messages`.
|
|
114
|
+
* Two losses on that line:
|
|
115
|
+
* (a) `convertToModelMessages()` reads raw inputs not the lowered output,
|
|
116
|
+
* dropping per-message providerOptions; and
|
|
117
|
+
* (b) `streamText({ system: '<string>' })` strips any providerOptions
|
|
118
|
+
* on the system prefix.
|
|
119
|
+
*
|
|
120
|
+
* Net effect prior to this surface: `cache_read_input_tokens = 0` across
|
|
121
|
+
* every measured production call by IC + tt-intel even though both
|
|
122
|
+
* consumers had `historyCachePolicy: { strategy: 'all-but-latest' }` wired
|
|
123
|
+
* since alpha.5. The compiler did the right thing; the consumer integration
|
|
124
|
+
* pattern lost the markers at the wire boundary.
|
|
125
|
+
*
|
|
126
|
+
* This helper closes the gap. Pass the consumer's already-converted messages
|
|
127
|
+
* + the kgauto CompileResult and get back a `{ system, messages }` pair
|
|
128
|
+
* with cacheControl re-attached at the deterministic indices the compiler
|
|
129
|
+
* computed (`diagnostics.historyCacheMarkIndex` + `systemMessages` with
|
|
130
|
+
* its own cacheControl markers).
|
|
131
|
+
*
|
|
132
|
+
* No I/O. Pure transform. Idempotent — calling twice with the same inputs
|
|
133
|
+
* produces structurally-identical output.
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* AI-SDK-shaped converted-message structure. Matches what
|
|
138
|
+
* `convertToModelMessages()` returns at the wire layer. We don't import
|
|
139
|
+
* the AI-SDK type to avoid pulling that dep into the kgauto-compiler
|
|
140
|
+
* package — consumers pass their own already-converted messages.
|
|
141
|
+
*/
|
|
142
|
+
interface AISDKConvertedMessage {
|
|
143
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
144
|
+
content: unknown;
|
|
145
|
+
providerOptions?: {
|
|
146
|
+
anthropic?: {
|
|
147
|
+
cacheControl?: {
|
|
148
|
+
type: 'ephemeral';
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Result of `attachCacheControlToStreamTextInput()` — ready to spread into
|
|
155
|
+
* `streamText(...)` directly.
|
|
156
|
+
*
|
|
157
|
+
* The `system` field is either the structured `SystemModelMessage[]` form
|
|
158
|
+
* (when the compiler computed at least one cacheable section + chose
|
|
159
|
+
* Anthropic) or the flat-string concatenation (when no cacheable sections
|
|
160
|
+
* exist OR the provider isn't Anthropic). Consumers can pass either form
|
|
161
|
+
* to `streamText({ system })` — the AI-SDK accepts both.
|
|
162
|
+
*/
|
|
163
|
+
interface AttachCacheControlResult {
|
|
164
|
+
system: string | SystemModelMessage[];
|
|
165
|
+
messages: AISDKConvertedMessage[];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Attach Anthropic cache_control markers to a streamText input that the
|
|
169
|
+
* consumer has already prepared via `convertToModelMessages()`. Reads
|
|
170
|
+
* `result.diagnostics.historyCacheMarkIndex` for the position-on-history
|
|
171
|
+
* marker and `result.systemMessages` for the per-section system markers.
|
|
172
|
+
*
|
|
173
|
+
* The flat-string `system` form is returned when:
|
|
174
|
+
* - the compiler produced no `systemMessages` (e.g., zero sections kept), or
|
|
175
|
+
* - the chosen provider is not Anthropic, so cacheControl wouldn't
|
|
176
|
+
* achieve anything at the wire layer (other providers cache implicitly
|
|
177
|
+
* based on prefix shape, no marker needed).
|
|
178
|
+
*
|
|
179
|
+
* Otherwise the structured `SystemModelMessage[]` form is returned —
|
|
180
|
+
* preserves the per-section cacheControl markers across `streamText`.
|
|
181
|
+
*
|
|
182
|
+
* @param result - kgauto CompileResult from `compile(ir, opts)`
|
|
183
|
+
* @param convertedMessages - the consumer's already-converted messages
|
|
184
|
+
* (from `convertToModelMessages(rawMessages)` in their AI-SDK call site)
|
|
185
|
+
* @returns `{ system, messages }` ready to spread into `streamText(...)`
|
|
186
|
+
*/
|
|
187
|
+
declare function attachCacheControlToStreamTextInput(result: CompileResult, convertedMessages: AISDKConvertedMessage[]): AttachCacheControlResult;
|
|
188
|
+
|
|
97
189
|
/**
|
|
98
190
|
* alpha.11 — opt-in nested config for brain-query mode (chains / archetype
|
|
99
191
|
* perf / pricing / models registry). Enabled by default when endpoint is
|
|
@@ -1419,4 +1511,4 @@ declare const loadAliasesFromBrain: () => Record<string, string>;
|
|
|
1419
1511
|
*/
|
|
1420
1512
|
declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
|
|
1421
1513
|
|
|
1422
|
-
export { ABSOLUTE_FLOOR, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, BestPracticeAdvisory, type BrainConfig, type BrainQueryConfig, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, type GetActionableAdvisoriesOptions, type GetDefaultFallbackChainOpts, type GetPerAxisMetricsOpts, Grounding, IntentArchetypeName, type LLMJudgeOptions, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, PROVIDER_ENV_KEYS, PerAxisMetrics, type PricingRow, type ProfileToRowOptions, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, SectionRewrite, type SupportedProvider, TRANSLATOR_FLOOR, applySectionRewrites, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStarterChain, getStarterChainWithGrounding, isBrainQueryActiveFor, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, profileToRow, record, recordOutcome, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|
|
1514
|
+
export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, type AttachCacheControlResult, BestPracticeAdvisory, type BrainConfig, type BrainQueryConfig, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, type GetActionableAdvisoriesOptions, type GetDefaultFallbackChainOpts, type GetPerAxisMetricsOpts, Grounding, IntentArchetypeName, type LLMJudgeOptions, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, PROVIDER_ENV_KEYS, PerAxisMetrics, type PricingRow, type ProfileToRowOptions, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, SectionRewrite, type SupportedProvider, SystemModelMessage, TRANSLATOR_FLOOR, applySectionRewrites, attachCacheControlToStreamTextInput, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStarterChain, getStarterChainWithGrounding, isBrainQueryActiveFor, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, profileToRow, record, recordOutcome, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CompilePolicy, N as NormalizedResponse, A as ApiKeys, P as ProviderOverrides, a as CompiledRequest, b as PromptIR, c as CallOptions, d as CallResult, S as SectionRewrite, R as RecordInput,
|
|
2
|
-
export {
|
|
1
|
+
import { C as CompilePolicy, N as NormalizedResponse, A as ApiKeys, P as ProviderOverrides, a as CompiledRequest, b as PromptIR, c as CallOptions, d as CallResult, S as SystemModelMessage, e as CompileResult, f as SectionRewrite, R as RecordInput, g as RecordOutcomeInput, O as OutcomeResult, h as OracleScore, B as BestPracticeAdvisory, i as Adapter, j as PerAxisMetrics, k as Provider, l as ChainEntry, G as Grounding } from './ir-B_ygNURd.js';
|
|
2
|
+
export { m as CallAttempt, n as CallError, o as ChainWithGrounding, p as Constraints, F as FallbackReason, H as HistoryCachePolicy, I as IntentDeclaration, M as Message, q as MutationApplied, r as NormalizedTokens, s as OutcomeKind, t as PerAxisMetricsByModel, u as PromptSection, v as SectionKind, T as ToolCall, w as ToolDefinition } from './ir-B_ygNURd.js';
|
|
3
3
|
import { ModelProfile } from './profiles.js';
|
|
4
4
|
export { ALIASES, CacheStrategy, CliffRule, LoweringSpec, RecoveryRule, StructuredOutputCapability, SystemPromptMode, allProfiles, getProfile, profilesByProvider, tryGetProfile } from './profiles.js';
|
|
5
5
|
import { IntentArchetypeName } from './dialect.js';
|
|
@@ -54,6 +54,15 @@ interface ExecuteOptions {
|
|
|
54
54
|
apiKeys?: ApiKeys;
|
|
55
55
|
fetchImpl?: typeof fetch;
|
|
56
56
|
providerOverrides?: ProviderOverrides;
|
|
57
|
+
/**
|
|
58
|
+
* alpha.34. When supplied AND the chosen provider supports streaming, the
|
|
59
|
+
* execute() per-provider branch switches to SSE wire format and invokes
|
|
60
|
+
* `onChunk(delta)` once per text-delta event. Single-shot behavior
|
|
61
|
+
* preserved when omitted (current consumers unaffected). Wired from
|
|
62
|
+
* `CallOptions.onChunk` by `call()` after gating on `profile.streaming`
|
|
63
|
+
* and `!opts.noStream`.
|
|
64
|
+
*/
|
|
65
|
+
onChunk?: (chunk: string) => void;
|
|
57
66
|
}
|
|
58
67
|
interface ExecuteOk {
|
|
59
68
|
ok: true;
|
|
@@ -94,6 +103,89 @@ declare function execute(request: CompiledRequest, opts?: ExecuteOptions): Promi
|
|
|
94
103
|
*/
|
|
95
104
|
declare function call(ir: PromptIR, opts?: CallOptions): Promise<CallResult>;
|
|
96
105
|
|
|
106
|
+
/**
|
|
107
|
+
* alpha.33 — AI-SDK streamText helpers.
|
|
108
|
+
*
|
|
109
|
+
* The cross-consumer pattern surfaced 2026-05-20 (`streamText-cache-marker-
|
|
110
|
+
* propagation-gap` on `command-center/interfaces/kgauto.md ## Requested`):
|
|
111
|
+
* AI-SDK consumers using `streamText({ system: <string>, messages:
|
|
112
|
+
* convertToModelMessages(messages), model })` silently drop the Anthropic
|
|
113
|
+
* `cache_control` markers the compiler emits on `result.request.messages`.
|
|
114
|
+
* Two losses on that line:
|
|
115
|
+
* (a) `convertToModelMessages()` reads raw inputs not the lowered output,
|
|
116
|
+
* dropping per-message providerOptions; and
|
|
117
|
+
* (b) `streamText({ system: '<string>' })` strips any providerOptions
|
|
118
|
+
* on the system prefix.
|
|
119
|
+
*
|
|
120
|
+
* Net effect prior to this surface: `cache_read_input_tokens = 0` across
|
|
121
|
+
* every measured production call by IC + tt-intel even though both
|
|
122
|
+
* consumers had `historyCachePolicy: { strategy: 'all-but-latest' }` wired
|
|
123
|
+
* since alpha.5. The compiler did the right thing; the consumer integration
|
|
124
|
+
* pattern lost the markers at the wire boundary.
|
|
125
|
+
*
|
|
126
|
+
* This helper closes the gap. Pass the consumer's already-converted messages
|
|
127
|
+
* + the kgauto CompileResult and get back a `{ system, messages }` pair
|
|
128
|
+
* with cacheControl re-attached at the deterministic indices the compiler
|
|
129
|
+
* computed (`diagnostics.historyCacheMarkIndex` + `systemMessages` with
|
|
130
|
+
* its own cacheControl markers).
|
|
131
|
+
*
|
|
132
|
+
* No I/O. Pure transform. Idempotent — calling twice with the same inputs
|
|
133
|
+
* produces structurally-identical output.
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* AI-SDK-shaped converted-message structure. Matches what
|
|
138
|
+
* `convertToModelMessages()` returns at the wire layer. We don't import
|
|
139
|
+
* the AI-SDK type to avoid pulling that dep into the kgauto-compiler
|
|
140
|
+
* package — consumers pass their own already-converted messages.
|
|
141
|
+
*/
|
|
142
|
+
interface AISDKConvertedMessage {
|
|
143
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
144
|
+
content: unknown;
|
|
145
|
+
providerOptions?: {
|
|
146
|
+
anthropic?: {
|
|
147
|
+
cacheControl?: {
|
|
148
|
+
type: 'ephemeral';
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Result of `attachCacheControlToStreamTextInput()` — ready to spread into
|
|
155
|
+
* `streamText(...)` directly.
|
|
156
|
+
*
|
|
157
|
+
* The `system` field is either the structured `SystemModelMessage[]` form
|
|
158
|
+
* (when the compiler computed at least one cacheable section + chose
|
|
159
|
+
* Anthropic) or the flat-string concatenation (when no cacheable sections
|
|
160
|
+
* exist OR the provider isn't Anthropic). Consumers can pass either form
|
|
161
|
+
* to `streamText({ system })` — the AI-SDK accepts both.
|
|
162
|
+
*/
|
|
163
|
+
interface AttachCacheControlResult {
|
|
164
|
+
system: string | SystemModelMessage[];
|
|
165
|
+
messages: AISDKConvertedMessage[];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Attach Anthropic cache_control markers to a streamText input that the
|
|
169
|
+
* consumer has already prepared via `convertToModelMessages()`. Reads
|
|
170
|
+
* `result.diagnostics.historyCacheMarkIndex` for the position-on-history
|
|
171
|
+
* marker and `result.systemMessages` for the per-section system markers.
|
|
172
|
+
*
|
|
173
|
+
* The flat-string `system` form is returned when:
|
|
174
|
+
* - the compiler produced no `systemMessages` (e.g., zero sections kept), or
|
|
175
|
+
* - the chosen provider is not Anthropic, so cacheControl wouldn't
|
|
176
|
+
* achieve anything at the wire layer (other providers cache implicitly
|
|
177
|
+
* based on prefix shape, no marker needed).
|
|
178
|
+
*
|
|
179
|
+
* Otherwise the structured `SystemModelMessage[]` form is returned —
|
|
180
|
+
* preserves the per-section cacheControl markers across `streamText`.
|
|
181
|
+
*
|
|
182
|
+
* @param result - kgauto CompileResult from `compile(ir, opts)`
|
|
183
|
+
* @param convertedMessages - the consumer's already-converted messages
|
|
184
|
+
* (from `convertToModelMessages(rawMessages)` in their AI-SDK call site)
|
|
185
|
+
* @returns `{ system, messages }` ready to spread into `streamText(...)`
|
|
186
|
+
*/
|
|
187
|
+
declare function attachCacheControlToStreamTextInput(result: CompileResult, convertedMessages: AISDKConvertedMessage[]): AttachCacheControlResult;
|
|
188
|
+
|
|
97
189
|
/**
|
|
98
190
|
* alpha.11 — opt-in nested config for brain-query mode (chains / archetype
|
|
99
191
|
* perf / pricing / models registry). Enabled by default when endpoint is
|
|
@@ -1419,4 +1511,4 @@ declare const loadAliasesFromBrain: () => Record<string, string>;
|
|
|
1419
1511
|
*/
|
|
1420
1512
|
declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
|
|
1421
1513
|
|
|
1422
|
-
export { ABSOLUTE_FLOOR, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, BestPracticeAdvisory, type BrainConfig, type BrainQueryConfig, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, type GetActionableAdvisoriesOptions, type GetDefaultFallbackChainOpts, type GetPerAxisMetricsOpts, Grounding, IntentArchetypeName, type LLMJudgeOptions, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, PROVIDER_ENV_KEYS, PerAxisMetrics, type PricingRow, type ProfileToRowOptions, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, SectionRewrite, type SupportedProvider, TRANSLATOR_FLOOR, applySectionRewrites, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStarterChain, getStarterChainWithGrounding, isBrainQueryActiveFor, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, profileToRow, record, recordOutcome, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|
|
1514
|
+
export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, type AttachCacheControlResult, BestPracticeAdvisory, type BrainConfig, type BrainQueryConfig, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, type GetActionableAdvisoriesOptions, type GetDefaultFallbackChainOpts, type GetPerAxisMetricsOpts, Grounding, IntentArchetypeName, type LLMJudgeOptions, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, PROVIDER_ENV_KEYS, PerAxisMetrics, type PricingRow, type ProfileToRowOptions, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, SectionRewrite, type SupportedProvider, SystemModelMessage, TRANSLATOR_FLOOR, applySectionRewrites, attachCacheControlToStreamTextInput, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStarterChain, getStarterChainWithGrounding, isBrainQueryActiveFor, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, profileToRow, record, recordOutcome, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|