@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
|
@@ -564,6 +564,86 @@ interface CompileResult {
|
|
|
564
564
|
* treat as 'parallel' equivalent for back-compat.
|
|
565
565
|
*/
|
|
566
566
|
toolOrchestration?: 'parallel' | 'sequential' | 'either';
|
|
567
|
+
/**
|
|
568
|
+
* alpha.33. Zero-based index into the resolved (post-compression) history
|
|
569
|
+
* array at which Anthropic prompt-cache marker should land — i.e., the
|
|
570
|
+
* last message that belongs to the stable cacheable prefix. Consumers
|
|
571
|
+
* using AI-SDK's `streamText({ messages: convertToModelMessages(...) })`
|
|
572
|
+
* lose the per-message `providerOptions.anthropic.cacheControl` markers
|
|
573
|
+
* the compiler emits on `result.request.messages`, because
|
|
574
|
+
* `convertToModelMessages` reads raw input not the lowered output.
|
|
575
|
+
* This index gives the consumer a single deterministic position to
|
|
576
|
+
* attach `cacheControl: { type: 'ephemeral' }` after their own conversion.
|
|
577
|
+
*
|
|
578
|
+
* Computation:
|
|
579
|
+
* - `historyCachePolicy.strategy === 'all-but-latest'`: history.length - 1
|
|
580
|
+
* (or undefined if history is empty)
|
|
581
|
+
* - `historyCachePolicy.strategy === 'fixed-suffix'` with `suffix: N`:
|
|
582
|
+
* history.length - 1 - N (undefined if N exceeds history length)
|
|
583
|
+
* - `historyCachePolicy.strategy === 'none'` or omitted: undefined
|
|
584
|
+
*
|
|
585
|
+
* The companion helper `attachCacheControlToStreamTextInput()` reads
|
|
586
|
+
* this field + the consumer's converted messages to perform the per-
|
|
587
|
+
* attempt mutation correctly. Filed by IC + tt-intel cross-consumer
|
|
588
|
+
* pattern 2026-05-20 (`streamText-cache-marker-propagation-gap`).
|
|
589
|
+
*/
|
|
590
|
+
historyCacheMarkIndex?: number;
|
|
591
|
+
/**
|
|
592
|
+
* alpha.33. Zero-based index into the structured `systemMessages` array
|
|
593
|
+
* (see top-level `systemMessages` field) at which the cacheable system
|
|
594
|
+
* prefix ends. Useful when the consumer is building a multi-block
|
|
595
|
+
* system parameter for Anthropic streamText — they can attach
|
|
596
|
+
* `providerOptions.anthropic.cacheControl` to `systemMessages[index]`.
|
|
597
|
+
*
|
|
598
|
+
* Undefined when no section had `cacheable: true` OR `systemMessages` is
|
|
599
|
+
* empty. Matches `historyCacheMarkIndex` semantics on the history axis.
|
|
600
|
+
*/
|
|
601
|
+
systemCacheMarkIndex?: number;
|
|
602
|
+
};
|
|
603
|
+
/**
|
|
604
|
+
* alpha.33. Structured `system` for AI-SDK `streamText({ system })`
|
|
605
|
+
* consumers. When the consumer's lowered request has cacheable section
|
|
606
|
+
* markers, the flat `system: string` form loses the marker assignment
|
|
607
|
+
* (every `streamText({ system: '<string>' })` call silently strips
|
|
608
|
+
* providerOptions). Pass `systemMessages` instead to `streamText({
|
|
609
|
+
* system: result.systemMessages })` so the cacheable prefix is structurally
|
|
610
|
+
* preserved.
|
|
611
|
+
*
|
|
612
|
+
* Each entry is a `SystemModelMessage`-shaped object:
|
|
613
|
+
* { role: 'system', content: string, providerOptions?: { anthropic?:
|
|
614
|
+
* { cacheControl: { type: 'ephemeral' } } } }
|
|
615
|
+
*
|
|
616
|
+
* Provider-agnostic on emit: only Anthropic actually consumes the
|
|
617
|
+
* cacheControl block; Gemini / OpenAI / DeepSeek receive the same
|
|
618
|
+
* shape but ignore the marker (matching their implicit-caching semantics).
|
|
619
|
+
*
|
|
620
|
+
* Empty array when the IR carried zero sections (rare; usually means the
|
|
621
|
+
* compiler dropped everything for the chosen intent). Consumers can fall
|
|
622
|
+
* back to `result.systemMessages.length === 0 ? '' : result.systemMessages`
|
|
623
|
+
* or use the helper `attachCacheControlToStreamTextInput()` which handles
|
|
624
|
+
* both shapes.
|
|
625
|
+
*/
|
|
626
|
+
systemMessages: SystemModelMessage[];
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* alpha.33. AI-SDK-compatible system-message shape carried on
|
|
630
|
+
* `CompileResult.systemMessages`. Matches the AI-SDK `streamText({ system })`
|
|
631
|
+
* structured form — consumers can pass these directly without conversion.
|
|
632
|
+
*
|
|
633
|
+
* The `providerOptions` field is set ONLY for entries that came from a
|
|
634
|
+
* section with `cacheable: true` AND the chosen provider is Anthropic AND
|
|
635
|
+
* the compiler computed a non-zero `cacheableTokens`. Other providers see
|
|
636
|
+
* `providerOptions: undefined` (or omitted entirely).
|
|
637
|
+
*/
|
|
638
|
+
interface SystemModelMessage {
|
|
639
|
+
role: 'system';
|
|
640
|
+
content: string;
|
|
641
|
+
providerOptions?: {
|
|
642
|
+
anthropic?: {
|
|
643
|
+
cacheControl: {
|
|
644
|
+
type: 'ephemeral';
|
|
645
|
+
};
|
|
646
|
+
};
|
|
567
647
|
};
|
|
568
648
|
}
|
|
569
649
|
/**
|
|
@@ -653,6 +733,43 @@ interface CallOptions {
|
|
|
653
733
|
* for hermetic test runs.
|
|
654
734
|
*/
|
|
655
735
|
noAutoFilter?: boolean;
|
|
736
|
+
/**
|
|
737
|
+
* alpha.34. When provided AND the chosen provider supports streaming
|
|
738
|
+
* (`profile.streaming === true`) AND `noStream` is not set, kgauto
|
|
739
|
+
* enables provider-native SSE streaming at the wire layer and invokes
|
|
740
|
+
* `onChunk(delta)` once per provider stream event. `delta` is the text
|
|
741
|
+
* since the previous `onChunk` call (NOT cumulative) — provider
|
|
742
|
+
* stream-shape headache normalized in kgauto's lowering layer.
|
|
743
|
+
*
|
|
744
|
+
* `CallResult.response.text` is still populated with the full assembled
|
|
745
|
+
* response — kgauto buffers internally regardless of the callback.
|
|
746
|
+
* Consumers can use either the streaming side-effect OR the final
|
|
747
|
+
* `response.text`, doesn't matter.
|
|
748
|
+
*
|
|
749
|
+
* Tool calls + finish reason + usage are collected from stream events
|
|
750
|
+
* and returned in the final `CallResult` exactly as the non-streaming
|
|
751
|
+
* path would shape them. Brain telemetry latency = time-to-stream-end.
|
|
752
|
+
*
|
|
753
|
+
* Chain-walk semantics: if the streaming target fails mid-stream
|
|
754
|
+
* (network error, retryable provider error), kgauto walks to the next
|
|
755
|
+
* fallback target and restarts streaming from its first chunk —
|
|
756
|
+
* `onChunk` fires fresh from the new target. Consumer detects via the
|
|
757
|
+
* post-call `CallResult.fellOverFrom`. To opt out of fallback for
|
|
758
|
+
* streaming, set `noFallback: true` alongside `onChunk`.
|
|
759
|
+
*
|
|
760
|
+
* Filed by playbacksam s42 (2026-05-22) as `streaming-output-callback-
|
|
761
|
+
* on-callresult` for ComposeDrawer SSE; perceived-latency UX win
|
|
762
|
+
* during 10-30s draft assembly.
|
|
763
|
+
*/
|
|
764
|
+
onChunk?: (chunk: string) => void;
|
|
765
|
+
/**
|
|
766
|
+
* alpha.34. Explicit opt-out of streaming even when `onChunk` is
|
|
767
|
+
* provided. Default: false (streaming enabled when `onChunk` is set).
|
|
768
|
+
* Use when the consumer wants to pass `onChunk` conditionally without
|
|
769
|
+
* branching the call site (e.g., capture chunks for instrumentation
|
|
770
|
+
* without engaging streaming wire format).
|
|
771
|
+
*/
|
|
772
|
+
noStream?: boolean;
|
|
656
773
|
}
|
|
657
774
|
interface CallAttempt {
|
|
658
775
|
model: string;
|
|
@@ -1028,4 +1145,4 @@ interface PerAxisMetrics {
|
|
|
1028
1145
|
/** Per-axis metrics keyed by model — used for chain-comparison views. */
|
|
1029
1146
|
type PerAxisMetricsByModel = Record<string, PerAxisMetrics>;
|
|
1030
1147
|
|
|
1031
|
-
export { type ApiKeys as A, type BestPracticeAdvisory as B, type CompilePolicy as C, type FallbackReason as F, type Grounding as G, type HistoryCachePolicy as H, type IntentDeclaration as I, type Message as M, type NormalizedResponse as N, type OutcomeResult as O, type ProviderOverrides as P, type RecordInput as R, type
|
|
1148
|
+
export { type ApiKeys as A, type BestPracticeAdvisory as B, type CompilePolicy as C, type FallbackReason as F, type Grounding as G, type HistoryCachePolicy as H, type IntentDeclaration as I, type Message as M, type NormalizedResponse as N, type OutcomeResult as O, type ProviderOverrides as P, type RecordInput as R, type SystemModelMessage as S, type ToolCall as T, type CompiledRequest as a, type PromptIR as b, type CallOptions as c, type CallResult as d, type CompileResult as e, type SectionRewrite as f, type RecordOutcomeInput as g, type OracleScore as h, type Adapter as i, type PerAxisMetrics as j, type Provider as k, type ChainEntry as l, type CallAttempt as m, CallError as n, type ChainWithGrounding as o, type Constraints as p, type MutationApplied as q, type NormalizedTokens as r, type OutcomeKind as s, type PerAxisMetricsByModel as t, type PromptSection as u, type SectionKind as v, type ToolDefinition as w };
|
|
@@ -564,6 +564,86 @@ interface CompileResult {
|
|
|
564
564
|
* treat as 'parallel' equivalent for back-compat.
|
|
565
565
|
*/
|
|
566
566
|
toolOrchestration?: 'parallel' | 'sequential' | 'either';
|
|
567
|
+
/**
|
|
568
|
+
* alpha.33. Zero-based index into the resolved (post-compression) history
|
|
569
|
+
* array at which Anthropic prompt-cache marker should land — i.e., the
|
|
570
|
+
* last message that belongs to the stable cacheable prefix. Consumers
|
|
571
|
+
* using AI-SDK's `streamText({ messages: convertToModelMessages(...) })`
|
|
572
|
+
* lose the per-message `providerOptions.anthropic.cacheControl` markers
|
|
573
|
+
* the compiler emits on `result.request.messages`, because
|
|
574
|
+
* `convertToModelMessages` reads raw input not the lowered output.
|
|
575
|
+
* This index gives the consumer a single deterministic position to
|
|
576
|
+
* attach `cacheControl: { type: 'ephemeral' }` after their own conversion.
|
|
577
|
+
*
|
|
578
|
+
* Computation:
|
|
579
|
+
* - `historyCachePolicy.strategy === 'all-but-latest'`: history.length - 1
|
|
580
|
+
* (or undefined if history is empty)
|
|
581
|
+
* - `historyCachePolicy.strategy === 'fixed-suffix'` with `suffix: N`:
|
|
582
|
+
* history.length - 1 - N (undefined if N exceeds history length)
|
|
583
|
+
* - `historyCachePolicy.strategy === 'none'` or omitted: undefined
|
|
584
|
+
*
|
|
585
|
+
* The companion helper `attachCacheControlToStreamTextInput()` reads
|
|
586
|
+
* this field + the consumer's converted messages to perform the per-
|
|
587
|
+
* attempt mutation correctly. Filed by IC + tt-intel cross-consumer
|
|
588
|
+
* pattern 2026-05-20 (`streamText-cache-marker-propagation-gap`).
|
|
589
|
+
*/
|
|
590
|
+
historyCacheMarkIndex?: number;
|
|
591
|
+
/**
|
|
592
|
+
* alpha.33. Zero-based index into the structured `systemMessages` array
|
|
593
|
+
* (see top-level `systemMessages` field) at which the cacheable system
|
|
594
|
+
* prefix ends. Useful when the consumer is building a multi-block
|
|
595
|
+
* system parameter for Anthropic streamText — they can attach
|
|
596
|
+
* `providerOptions.anthropic.cacheControl` to `systemMessages[index]`.
|
|
597
|
+
*
|
|
598
|
+
* Undefined when no section had `cacheable: true` OR `systemMessages` is
|
|
599
|
+
* empty. Matches `historyCacheMarkIndex` semantics on the history axis.
|
|
600
|
+
*/
|
|
601
|
+
systemCacheMarkIndex?: number;
|
|
602
|
+
};
|
|
603
|
+
/**
|
|
604
|
+
* alpha.33. Structured `system` for AI-SDK `streamText({ system })`
|
|
605
|
+
* consumers. When the consumer's lowered request has cacheable section
|
|
606
|
+
* markers, the flat `system: string` form loses the marker assignment
|
|
607
|
+
* (every `streamText({ system: '<string>' })` call silently strips
|
|
608
|
+
* providerOptions). Pass `systemMessages` instead to `streamText({
|
|
609
|
+
* system: result.systemMessages })` so the cacheable prefix is structurally
|
|
610
|
+
* preserved.
|
|
611
|
+
*
|
|
612
|
+
* Each entry is a `SystemModelMessage`-shaped object:
|
|
613
|
+
* { role: 'system', content: string, providerOptions?: { anthropic?:
|
|
614
|
+
* { cacheControl: { type: 'ephemeral' } } } }
|
|
615
|
+
*
|
|
616
|
+
* Provider-agnostic on emit: only Anthropic actually consumes the
|
|
617
|
+
* cacheControl block; Gemini / OpenAI / DeepSeek receive the same
|
|
618
|
+
* shape but ignore the marker (matching their implicit-caching semantics).
|
|
619
|
+
*
|
|
620
|
+
* Empty array when the IR carried zero sections (rare; usually means the
|
|
621
|
+
* compiler dropped everything for the chosen intent). Consumers can fall
|
|
622
|
+
* back to `result.systemMessages.length === 0 ? '' : result.systemMessages`
|
|
623
|
+
* or use the helper `attachCacheControlToStreamTextInput()` which handles
|
|
624
|
+
* both shapes.
|
|
625
|
+
*/
|
|
626
|
+
systemMessages: SystemModelMessage[];
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* alpha.33. AI-SDK-compatible system-message shape carried on
|
|
630
|
+
* `CompileResult.systemMessages`. Matches the AI-SDK `streamText({ system })`
|
|
631
|
+
* structured form — consumers can pass these directly without conversion.
|
|
632
|
+
*
|
|
633
|
+
* The `providerOptions` field is set ONLY for entries that came from a
|
|
634
|
+
* section with `cacheable: true` AND the chosen provider is Anthropic AND
|
|
635
|
+
* the compiler computed a non-zero `cacheableTokens`. Other providers see
|
|
636
|
+
* `providerOptions: undefined` (or omitted entirely).
|
|
637
|
+
*/
|
|
638
|
+
interface SystemModelMessage {
|
|
639
|
+
role: 'system';
|
|
640
|
+
content: string;
|
|
641
|
+
providerOptions?: {
|
|
642
|
+
anthropic?: {
|
|
643
|
+
cacheControl: {
|
|
644
|
+
type: 'ephemeral';
|
|
645
|
+
};
|
|
646
|
+
};
|
|
567
647
|
};
|
|
568
648
|
}
|
|
569
649
|
/**
|
|
@@ -653,6 +733,43 @@ interface CallOptions {
|
|
|
653
733
|
* for hermetic test runs.
|
|
654
734
|
*/
|
|
655
735
|
noAutoFilter?: boolean;
|
|
736
|
+
/**
|
|
737
|
+
* alpha.34. When provided AND the chosen provider supports streaming
|
|
738
|
+
* (`profile.streaming === true`) AND `noStream` is not set, kgauto
|
|
739
|
+
* enables provider-native SSE streaming at the wire layer and invokes
|
|
740
|
+
* `onChunk(delta)` once per provider stream event. `delta` is the text
|
|
741
|
+
* since the previous `onChunk` call (NOT cumulative) — provider
|
|
742
|
+
* stream-shape headache normalized in kgauto's lowering layer.
|
|
743
|
+
*
|
|
744
|
+
* `CallResult.response.text` is still populated with the full assembled
|
|
745
|
+
* response — kgauto buffers internally regardless of the callback.
|
|
746
|
+
* Consumers can use either the streaming side-effect OR the final
|
|
747
|
+
* `response.text`, doesn't matter.
|
|
748
|
+
*
|
|
749
|
+
* Tool calls + finish reason + usage are collected from stream events
|
|
750
|
+
* and returned in the final `CallResult` exactly as the non-streaming
|
|
751
|
+
* path would shape them. Brain telemetry latency = time-to-stream-end.
|
|
752
|
+
*
|
|
753
|
+
* Chain-walk semantics: if the streaming target fails mid-stream
|
|
754
|
+
* (network error, retryable provider error), kgauto walks to the next
|
|
755
|
+
* fallback target and restarts streaming from its first chunk —
|
|
756
|
+
* `onChunk` fires fresh from the new target. Consumer detects via the
|
|
757
|
+
* post-call `CallResult.fellOverFrom`. To opt out of fallback for
|
|
758
|
+
* streaming, set `noFallback: true` alongside `onChunk`.
|
|
759
|
+
*
|
|
760
|
+
* Filed by playbacksam s42 (2026-05-22) as `streaming-output-callback-
|
|
761
|
+
* on-callresult` for ComposeDrawer SSE; perceived-latency UX win
|
|
762
|
+
* during 10-30s draft assembly.
|
|
763
|
+
*/
|
|
764
|
+
onChunk?: (chunk: string) => void;
|
|
765
|
+
/**
|
|
766
|
+
* alpha.34. Explicit opt-out of streaming even when `onChunk` is
|
|
767
|
+
* provided. Default: false (streaming enabled when `onChunk` is set).
|
|
768
|
+
* Use when the consumer wants to pass `onChunk` conditionally without
|
|
769
|
+
* branching the call site (e.g., capture chunks for instrumentation
|
|
770
|
+
* without engaging streaming wire format).
|
|
771
|
+
*/
|
|
772
|
+
noStream?: boolean;
|
|
656
773
|
}
|
|
657
774
|
interface CallAttempt {
|
|
658
775
|
model: string;
|
|
@@ -1028,4 +1145,4 @@ interface PerAxisMetrics {
|
|
|
1028
1145
|
/** Per-axis metrics keyed by model — used for chain-comparison views. */
|
|
1029
1146
|
type PerAxisMetricsByModel = Record<string, PerAxisMetrics>;
|
|
1030
1147
|
|
|
1031
|
-
export { type ApiKeys as A, type BestPracticeAdvisory as B, type CompilePolicy as C, type FallbackReason as F, type Grounding as G, type HistoryCachePolicy as H, type IntentDeclaration as I, type Message as M, type NormalizedResponse as N, type OutcomeResult as O, type ProviderOverrides as P, type RecordInput as R, type
|
|
1148
|
+
export { type ApiKeys as A, type BestPracticeAdvisory as B, type CompilePolicy as C, type FallbackReason as F, type Grounding as G, type HistoryCachePolicy as H, type IntentDeclaration as I, type Message as M, type NormalizedResponse as N, type OutcomeResult as O, type ProviderOverrides as P, type RecordInput as R, type SystemModelMessage as S, type ToolCall as T, type CompiledRequest as a, type PromptIR as b, type CallOptions as c, type CallResult as d, type CompileResult as e, type SectionRewrite as f, type RecordOutcomeInput as g, type OracleScore as h, type Adapter as i, type PerAxisMetrics as j, type Provider as k, type ChainEntry as l, type CallAttempt as m, CallError as n, type ChainWithGrounding as o, type Constraints as p, type MutationApplied as q, type NormalizedTokens as r, type OutcomeKind as s, type PerAxisMetricsByModel as t, type PromptSection as u, type SectionKind as v, type ToolDefinition as w };
|
package/dist/profiles.d.mts
CHANGED
package/dist/profiles.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-BAAHLfFL.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Glass-Box observability types (alpha.17).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-B_ygNURd.js';
|
|
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.34",
|
|
4
4
|
"description": "Prompt compiler + central learning brain for multi-model AI apps. Swap models without rewriting prompts.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|