@warmdrift/kgauto-compiler 2.0.0-alpha.26 → 2.0.0-alpha.28
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-7MTHFSNY.mjs → chunk-JQGRWJZO.mjs} +181 -48
- package/dist/chunk-WXCFWUCN.mjs +678 -0
- package/dist/glassbox/index.d.mts +3 -3
- package/dist/glassbox/index.d.ts +3 -3
- package/dist/glassbox-routes/index.d.mts +88 -6
- package/dist/glassbox-routes/index.d.ts +88 -6
- package/dist/glassbox-routes/index.js +1820 -8
- package/dist/glassbox-routes/index.mjs +320 -8
- package/dist/index.d.mts +184 -3
- package/dist/index.d.ts +184 -3
- package/dist/index.js +342 -53
- package/dist/index.mjs +108 -581
- package/dist/{ir-B_XX2LAO.d.ts → ir-5W0efxt9.d.ts} +86 -1
- package/dist/{ir-B9zqlwjH.d.mts → ir-MXCJA8L7.d.mts} +86 -1
- package/dist/profiles.d.mts +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/profiles.js +181 -48
- package/dist/profiles.mjs +1 -1
- package/dist/{types-bt0aVJb8.d.ts → types-CiZ9HLIU.d.ts} +1 -1
- package/dist/{types-o9etg93a.d.mts → types-sDZQzPM6.d.mts} +1 -1
- package/package.json +1 -1
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, R as RecordInput, e as RecordOutcomeInput, O as OutcomeResult, f as OracleScore, g as CompileResult, B as BestPracticeAdvisory, h as
|
|
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, R as RecordInput, e as RecordOutcomeInput, O as OutcomeResult, f as OracleScore, g as CompileResult, B as BestPracticeAdvisory, h as Adapter, i as PerAxisMetrics, j as Provider, k as ChainEntry, G as Grounding } from './ir-5W0efxt9.js';
|
|
2
|
+
export { l as CallAttempt, m as CallError, n as ChainWithGrounding, o as Constraints, F as FallbackReason, H as HistoryCachePolicy, I as IntentDeclaration, M as Message, p as MutationApplied, q as NormalizedTokens, r as OutcomeKind, s as PerAxisMetricsByModel, t as PromptSection, T as ToolCall, u as ToolDefinition } from './ir-5W0efxt9.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';
|
|
@@ -205,6 +205,13 @@ interface OutcomePayload {
|
|
|
205
205
|
* cliff lumps DeepSeek sequential perf with parallel without this).
|
|
206
206
|
*/
|
|
207
207
|
tool_orchestration?: 'parallel' | 'sequential' | 'either' | null;
|
|
208
|
+
finish_reason?: string;
|
|
209
|
+
total_ms?: number;
|
|
210
|
+
tools_count?: number;
|
|
211
|
+
history_depth?: number;
|
|
212
|
+
system_prompt_chars?: number;
|
|
213
|
+
fell_over_from?: string;
|
|
214
|
+
fallback_reason?: 'rate_limit' | 'provider_auth_failed' | 'provider_error' | 'cliff' | 'cost_cap' | 'contract_violation';
|
|
208
215
|
}
|
|
209
216
|
/**
|
|
210
217
|
* alpha.20 Entry 4: record a quality outcome for a previously-compiled call.
|
|
@@ -358,6 +365,180 @@ interface RunAdvisorPhase2Context {
|
|
|
358
365
|
*/
|
|
359
366
|
declare function runAdvisor(ir: PromptIR, result: AdvisorContext, profile: ModelProfile, policy?: CompilePolicy, phase2?: RunAdvisorPhase2Context): BestPracticeAdvisory[];
|
|
360
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Archetype-cliff compatibility — alpha.28 (tt-intel-Cairn ratified).
|
|
370
|
+
*
|
|
371
|
+
* One question, one answer: *given this model and this intent, can it work
|
|
372
|
+
* — and if not, what adapter (if any) would make it work?*
|
|
373
|
+
*
|
|
374
|
+
* Replaces the silent-archetype-cliff failure mode where a consumer picks a
|
|
375
|
+
* model that's structurally wrong for the intent and kgauto compiles cleanly
|
|
376
|
+
* without surfacing the gap. The triggering incident: tt-intel shipped
|
|
377
|
+
* `deepseek-v4-pro` as the hunt default per a local spec; the kgauto coord
|
|
378
|
+
* doc said L-040 — V4 is structurally wrong for hunt (sequential tools).
|
|
379
|
+
* `archetypePerf.hunt = 4` was already in the profile data. The compiler
|
|
380
|
+
* stayed silent. This API + the matching advisor rule surfaces it.
|
|
381
|
+
*
|
|
382
|
+
* Pure function. No network. No brain query. No side effects. ~1ms.
|
|
383
|
+
*
|
|
384
|
+
* Consultation doc:
|
|
385
|
+
* command-center/advisory/kgauto/2026-05-21_archetype-cliff-advisor.md
|
|
386
|
+
*
|
|
387
|
+
* Refinements applied per tt-intel-Cairn ratification (2026-05-21):
|
|
388
|
+
* R1: every variant carries `archetypePerf: number` (raw score) — and
|
|
389
|
+
* `requires-adapter` adds `archetypePerfWithAdapter: number` so
|
|
390
|
+
* consumer policy can be expressed as "accept adapter only when score
|
|
391
|
+
* crosses some threshold WITH the adapter on."
|
|
392
|
+
* R2: every variant carries a plain-English `reason: string`. No internal
|
|
393
|
+
* jargon ("L-040", "archetypePerf=4") — the consumer chooses whether
|
|
394
|
+
* to render it as UI hint or operator-tooling tooltip.
|
|
395
|
+
* R3: `Adapter` is a CLOSED discriminated union, not `| string`. alpha.28
|
|
396
|
+
* ships ONE variant (`toolOrchestration: 'sequential'`). Future
|
|
397
|
+
* adapter parameters extend the union explicitly in named releases.
|
|
398
|
+
* NO escape hatch — the whole point is catching "I added a new
|
|
399
|
+
* adapter and forgot to update consumer policy" at compile time.
|
|
400
|
+
*/
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Minimum `archetypePerf[archetype]` score to count as `compatible` under
|
|
404
|
+
* Option A (default policy). Below this, a documented adapter is needed
|
|
405
|
+
* to lift the model above the floor; if no adapter exists, the model is
|
|
406
|
+
* rejected.
|
|
407
|
+
*
|
|
408
|
+
* Matches `QUALITY_FLOOR_FOR_RECOMMENDATION` in `advisor.ts` — kgauto's
|
|
409
|
+
* library-wide convention for "below this score, swap recommendations stop."
|
|
410
|
+
*/
|
|
411
|
+
declare const ARCHETYPE_FLOOR_DEFAULT = 6;
|
|
412
|
+
/**
|
|
413
|
+
* Absolute floor — below this, the cliff is too steep for ANY adapter to
|
|
414
|
+
* lift cleanly. Reserved under Option A (unused today; every below-floor
|
|
415
|
+
* case is gated by adapter availability). Would gate `reject` vs
|
|
416
|
+
* `requires-adapter` under a future Option B per consultation doc Q1.
|
|
417
|
+
*
|
|
418
|
+
* Exported so consumer-side policy can read it (e.g. "accept adapter only
|
|
419
|
+
* when archetypePerf >= ABSOLUTE_FLOOR + 1"). Not used internally by
|
|
420
|
+
* `getModelCompatibility` today — the gate is "does an adapter exist for
|
|
421
|
+
* this cliff?", not score-based.
|
|
422
|
+
*/
|
|
423
|
+
declare const ABSOLUTE_FLOOR = 4;
|
|
424
|
+
/**
|
|
425
|
+
* The intent the call is expressing — archetype + optional orchestration
|
|
426
|
+
* mode. Same shape as `ir.intent.archetype` + `ir.constraints.toolOrchestration`
|
|
427
|
+
* so a consumer can pass `{ archetype: ir.intent.archetype,
|
|
428
|
+
* toolOrchestration: ir.constraints?.toolOrchestration }` directly.
|
|
429
|
+
*/
|
|
430
|
+
interface CompatibilityIntent {
|
|
431
|
+
archetype: IntentArchetypeName;
|
|
432
|
+
toolOrchestration?: 'parallel' | 'sequential' | 'either';
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* `Adapter` — re-exported above. Canonical definition lives in `ir.ts` to
|
|
436
|
+
* avoid an import cycle (compatibility.ts → profiles.ts → ir.ts).
|
|
437
|
+
*
|
|
438
|
+
* **CLOSED discriminated union per R3.** Future adapter parameters extend
|
|
439
|
+
* the union explicitly in named alpha releases. No `| string` escape hatch
|
|
440
|
+
* — consumer policy code SHOULD write exhaustive `switch (adapter.parameter)`
|
|
441
|
+
* and rely on the compiler to flag "I added a new adapter parameter and
|
|
442
|
+
* forgot to update the consumer's policy."
|
|
443
|
+
*
|
|
444
|
+
* alpha.28 variants:
|
|
445
|
+
* - `{ parameter: 'toolOrchestration'; value: 'sequential'; consequence }`
|
|
446
|
+
* Lifts DeepSeek V4-family on `hunt` from sequential-tool cliff (L-040).
|
|
447
|
+
* The "consequence" plain-English-ifies the trade-off:
|
|
448
|
+
* "Tool calls run one at a time — slower but reliable."
|
|
449
|
+
*
|
|
450
|
+
* alpha.29+ likely additions (per tt-intel-Cairn priority list):
|
|
451
|
+
* - `{ parameter: 'parallelToolCalls'; value: false; consequence }`
|
|
452
|
+
* - `{ parameter: 'maxTools'; value: number; consequence }`
|
|
453
|
+
* - `{ parameter: 'thinkingBudget'; value: 0; consequence }`
|
|
454
|
+
*
|
|
455
|
+
* Each new variant lands in its own named release with the union extended
|
|
456
|
+
* in `ir.ts`. Consumers see the change at compile time.
|
|
457
|
+
*/
|
|
458
|
+
/**
|
|
459
|
+
* The compatibility verdict for a (model, intent) pair. Discriminated union
|
|
460
|
+
* on `status` — `compatible` | `requires-adapter` | `reject`.
|
|
461
|
+
*
|
|
462
|
+
* **Every variant carries `archetypePerf` (R1) + `reason` (R2):**
|
|
463
|
+
* - `archetypePerf` — the raw 0-10 score for (model, archetype). Lets
|
|
464
|
+
* consumers build their own thresholds without re-importing the profile
|
|
465
|
+
* registry.
|
|
466
|
+
* - `reason` — plain-English, consumer-renderable. NOT internal jargon
|
|
467
|
+
* like "L-040 cliff" or "archetypePerf=4". Examples in R2 ratification:
|
|
468
|
+
* - compatible: "Suited for hunt-style parallel discovery."
|
|
469
|
+
* - requires-adapter: "Best with sequential tool calls for hunt — slower but works."
|
|
470
|
+
* - reject: "Not suited for hunt — would underperform significantly."
|
|
471
|
+
*
|
|
472
|
+
* `requires-adapter` additionally carries:
|
|
473
|
+
* - `archetypePerfWithAdapter` — estimated post-adapter score. May be an
|
|
474
|
+
* estimate (we don't measure post-adapter scores yet); kgauto's prior is
|
|
475
|
+
* "adapter lifts to ARCHETYPE_FLOOR_DEFAULT + 1" unless brain-evidenced.
|
|
476
|
+
* - `adapter` — the closed-union variant describing the structural change.
|
|
477
|
+
*
|
|
478
|
+
* Backward-compat: an unknown model returns `reject` with a "model not
|
|
479
|
+
* registered" reason; callers never throw. Unknown archetype is impossible
|
|
480
|
+
* at the type level (`IntentArchetypeName` is a closed union).
|
|
481
|
+
*/
|
|
482
|
+
type ModelCompatibility = {
|
|
483
|
+
status: 'compatible';
|
|
484
|
+
reason: string;
|
|
485
|
+
archetypePerf: number;
|
|
486
|
+
} | {
|
|
487
|
+
status: 'requires-adapter';
|
|
488
|
+
reason: string;
|
|
489
|
+
archetypePerf: number;
|
|
490
|
+
archetypePerfWithAdapter: number;
|
|
491
|
+
adapter: Adapter;
|
|
492
|
+
} | {
|
|
493
|
+
status: 'reject';
|
|
494
|
+
reason: string;
|
|
495
|
+
archetypePerf: number;
|
|
496
|
+
};
|
|
497
|
+
/**
|
|
498
|
+
* Compatibility query — *does this model fit this intent, and if not,
|
|
499
|
+
* what would?*
|
|
500
|
+
*
|
|
501
|
+
* **Rules (Option A from consultation doc Q1):**
|
|
502
|
+
* 1. If model is unregistered → `reject` with "model not registered" reason.
|
|
503
|
+
* 2. If intent provides `toolOrchestration: 'sequential'` AND that adapter
|
|
504
|
+
* silences the cliff (because the cliff IS the sequential-tool one)
|
|
505
|
+
* → return `compatible` with raw score (NOT the post-adapter estimate
|
|
506
|
+
* — caller already paid the adapter, score reflects reality).
|
|
507
|
+
* 3. If raw `archetypePerf[archetype] >= ARCHETYPE_FLOOR_DEFAULT`
|
|
508
|
+
* → `compatible`.
|
|
509
|
+
* 4. If below floor BUT a documented adapter exists that lifts to floor
|
|
510
|
+
* → `requires-adapter` with adapter + estimated post-adapter score.
|
|
511
|
+
* 5. If below floor AND no adapter exists → `reject`.
|
|
512
|
+
*
|
|
513
|
+
* **Pure function.** Deterministic for `(modelId, intent)`. No I/O.
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
* ```ts
|
|
517
|
+
* import { getModelCompatibility } from '@warmdrift/kgauto-compiler';
|
|
518
|
+
*
|
|
519
|
+
* const c = getModelCompatibility('deepseek-v4-pro', { archetype: 'hunt' });
|
|
520
|
+
* // → { status: 'requires-adapter',
|
|
521
|
+
* // reason: 'Best with sequential tool calls for hunt — slower but works.',
|
|
522
|
+
* // archetypePerf: 4,
|
|
523
|
+
* // archetypePerfWithAdapter: 7,
|
|
524
|
+
* // adapter: {
|
|
525
|
+
* // parameter: 'toolOrchestration',
|
|
526
|
+
* // value: 'sequential',
|
|
527
|
+
* // consequence: 'Tool calls run one at a time...'
|
|
528
|
+
* // } }
|
|
529
|
+
*
|
|
530
|
+
* // With the adapter already declared:
|
|
531
|
+
* const c2 = getModelCompatibility('deepseek-v4-pro', {
|
|
532
|
+
* archetype: 'hunt',
|
|
533
|
+
* toolOrchestration: 'sequential',
|
|
534
|
+
* });
|
|
535
|
+
* // → { status: 'compatible',
|
|
536
|
+
* // reason: 'Suited for hunt with sequential tool calls.',
|
|
537
|
+
* // archetypePerf: 4 }
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
declare function getModelCompatibility(modelId: string, intent: CompatibilityIntent): ModelCompatibility;
|
|
541
|
+
|
|
361
542
|
/**
|
|
362
543
|
* alpha.22 — sync introspection: is brain-query mode active for a given
|
|
363
544
|
* table? Used by the advisor (`model-stale-evidence` rule) to decide
|
|
@@ -943,4 +1124,4 @@ declare const loadAliasesFromBrain: () => Record<string, string>;
|
|
|
943
1124
|
*/
|
|
944
1125
|
declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
|
|
945
1126
|
|
|
946
|
-
export { ApiKeys, type AppOracle, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, BestPracticeAdvisory, type BrainConfig, type BrainQueryConfig, CallOptions, CallResult, ChainEntry, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, type GetDefaultFallbackChainOpts, type GetPerAxisMetricsOpts, Grounding, IntentArchetypeName, type LLMJudgeOptions, MEASURED_GROUNDING_MIN_N, type ModelBrainRow, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, PROVIDER_ENV_KEYS, PerAxisMetrics, type PricingRow, type ProfileToRowOptions, PromptIR, Provider, ProviderOverrides, type ProviderReachability, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, type SupportedProvider, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getAllStarterChains, getAllStarterChainsWithGrounding, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getPerAxisMetrics, getReachabilityDiagnostic, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStarterChain, getStarterChainWithGrounding, isBrainQueryActiveFor, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, profileToRow, record, recordOutcome, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|
|
1127
|
+
export { ABSOLUTE_FLOOR, ARCHETYPE_FLOOR_DEFAULT, Adapter, ApiKeys, type AppOracle, 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 GetDefaultFallbackChainOpts, type GetPerAxisMetricsOpts, Grounding, IntentArchetypeName, type LLMJudgeOptions, MEASURED_GROUNDING_MIN_N, 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, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, type SupportedProvider, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getAllStarterChains, getAllStarterChainsWithGrounding, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStarterChain, getStarterChainWithGrounding, isBrainQueryActiveFor, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, profileToRow, record, recordOutcome, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|