@warmdrift/kgauto-compiler 2.0.0-alpha.11 → 2.0.0-alpha.12
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/index.d.mts +61 -1
- package/dist/index.d.ts +61 -1
- package/dist/index.js +35 -0
- package/dist/index.mjs +34 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -596,6 +596,66 @@ declare function resolvePricingAt(modelId: string, at?: Date): PricingRow | unde
|
|
|
596
596
|
* status. Deprecation (`active=false`) affects chain composition only.
|
|
597
597
|
*/
|
|
598
598
|
|
|
599
|
+
/**
|
|
600
|
+
* Exported brain-row shape for `kgauto_models`. Mirrors the SQL table
|
|
601
|
+
* (`v2/brain/migrations/010_kgauto_models_and_aliases.sql`) — column names
|
|
602
|
+
* are snake_case to match PostgREST. Used by operator scripts that write
|
|
603
|
+
* to brain (auto-onboard, promote-model) — see `profileToRow()`.
|
|
604
|
+
*
|
|
605
|
+
* Read path stays internal via `RawModelRow` to keep `rowToProfile()`'s
|
|
606
|
+
* tolerance contract from leaking into write callers.
|
|
607
|
+
*/
|
|
608
|
+
interface ModelBrainRow {
|
|
609
|
+
model_id: string;
|
|
610
|
+
provider: string;
|
|
611
|
+
status?: string;
|
|
612
|
+
max_context_tokens?: number;
|
|
613
|
+
max_output_tokens?: number;
|
|
614
|
+
max_tools?: number;
|
|
615
|
+
parallel_tool_calls?: boolean;
|
|
616
|
+
structured_output?: string;
|
|
617
|
+
system_prompt_mode?: string;
|
|
618
|
+
streaming?: boolean;
|
|
619
|
+
cliffs?: unknown;
|
|
620
|
+
lowering?: unknown;
|
|
621
|
+
recovery?: unknown;
|
|
622
|
+
strengths?: string[] | null;
|
|
623
|
+
weaknesses?: string[] | null;
|
|
624
|
+
cost_input_per_1m?: number;
|
|
625
|
+
cost_output_per_1m?: number;
|
|
626
|
+
notes?: string | null;
|
|
627
|
+
verified_against_docs?: string | null;
|
|
628
|
+
archetype_perf?: Record<string, number> | null;
|
|
629
|
+
version_added?: string;
|
|
630
|
+
version_removed?: string | null;
|
|
631
|
+
active?: boolean;
|
|
632
|
+
}
|
|
633
|
+
interface ProfileToRowOptions {
|
|
634
|
+
/** e.g. `'2.0.0-alpha.12'` — leave undefined to omit from row. */
|
|
635
|
+
versionAdded?: string;
|
|
636
|
+
/** Pass `null` to clear; omit to leave field unset. */
|
|
637
|
+
versionRemoved?: string | null;
|
|
638
|
+
/** Defaults to true if omitted. */
|
|
639
|
+
active?: boolean;
|
|
640
|
+
/**
|
|
641
|
+
* Override verifiedAgainstDocs (e.g. set to `null` for auto-onboard).
|
|
642
|
+
* When omitted, the profile's own value is used. Pass `null` explicitly
|
|
643
|
+
* to write a SQL NULL (e.g. unverified auto-onboard rows).
|
|
644
|
+
*/
|
|
645
|
+
verifiedAgainstDocs?: string | null;
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Inverse of `rowToProfile` — serialize a `ModelProfile` to a `kgauto_models`
|
|
649
|
+
* row payload for INSERT/UPSERT. Used by operator scripts that write to
|
|
650
|
+
* brain (auto-onboard pipeline, promote-model verification CLI).
|
|
651
|
+
*
|
|
652
|
+
* Row-level fields (`version_added`, `version_removed`, `active`) are
|
|
653
|
+
* operator-controlled and pass through `opts`. `verifiedAgainstDocs` can
|
|
654
|
+
* also be overridden via `opts` — auto-onboard explicitly passes `null` to
|
|
655
|
+
* mark unverified rows (the column is DATE, doesn't accept the
|
|
656
|
+
* `'UNVERIFIED-AUTO-ONBOARD'` sentinel used in PROFILES_RAW).
|
|
657
|
+
*/
|
|
658
|
+
declare function profileToRow(profile: ModelProfile, opts?: ProfileToRowOptions): ModelBrainRow;
|
|
599
659
|
/**
|
|
600
660
|
* Sync reader for the brain-driven model registry. Returns bundled
|
|
601
661
|
* PROFILES_RAW when brain-query is disabled, cold, or unreachable.
|
|
@@ -656,4 +716,4 @@ declare const loadAliasesFromBrain: () => Record<string, string>;
|
|
|
656
716
|
*/
|
|
657
717
|
declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
|
|
658
718
|
|
|
659
|
-
export { ApiKeys, type AppOracle, type ArchetypePerfMap, BestPracticeAdvisory, type BrainConfig, type BrainQueryConfig, CallOptions, CallResult, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, type GetDefaultFallbackChainOpts, IntentArchetypeName, type LLMJudgeOptions, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, PROVIDER_ENV_KEYS, type PricingRow, PromptIR, Provider, ProviderOverrides, type ProviderReachability, type ReachabilityOpts, RecordInput, type SupportedProvider, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getAllStarterChains, getArchetypePerfScore, getDefaultFallbackChain, getReachabilityDiagnostic, getStarterChain, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, record, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|
|
719
|
+
export { ApiKeys, type AppOracle, type ArchetypePerfMap, BestPracticeAdvisory, type BrainConfig, type BrainQueryConfig, CallOptions, CallResult, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, type GetDefaultFallbackChainOpts, IntentArchetypeName, type LLMJudgeOptions, type ModelBrainRow, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, PROVIDER_ENV_KEYS, type PricingRow, type ProfileToRowOptions, PromptIR, Provider, ProviderOverrides, type ProviderReachability, type ReachabilityOpts, RecordInput, type SupportedProvider, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getAllStarterChains, getArchetypePerfScore, getDefaultFallbackChain, getReachabilityDiagnostic, getStarterChain, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, profileToRow, record, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|
package/dist/index.d.ts
CHANGED
|
@@ -596,6 +596,66 @@ declare function resolvePricingAt(modelId: string, at?: Date): PricingRow | unde
|
|
|
596
596
|
* status. Deprecation (`active=false`) affects chain composition only.
|
|
597
597
|
*/
|
|
598
598
|
|
|
599
|
+
/**
|
|
600
|
+
* Exported brain-row shape for `kgauto_models`. Mirrors the SQL table
|
|
601
|
+
* (`v2/brain/migrations/010_kgauto_models_and_aliases.sql`) — column names
|
|
602
|
+
* are snake_case to match PostgREST. Used by operator scripts that write
|
|
603
|
+
* to brain (auto-onboard, promote-model) — see `profileToRow()`.
|
|
604
|
+
*
|
|
605
|
+
* Read path stays internal via `RawModelRow` to keep `rowToProfile()`'s
|
|
606
|
+
* tolerance contract from leaking into write callers.
|
|
607
|
+
*/
|
|
608
|
+
interface ModelBrainRow {
|
|
609
|
+
model_id: string;
|
|
610
|
+
provider: string;
|
|
611
|
+
status?: string;
|
|
612
|
+
max_context_tokens?: number;
|
|
613
|
+
max_output_tokens?: number;
|
|
614
|
+
max_tools?: number;
|
|
615
|
+
parallel_tool_calls?: boolean;
|
|
616
|
+
structured_output?: string;
|
|
617
|
+
system_prompt_mode?: string;
|
|
618
|
+
streaming?: boolean;
|
|
619
|
+
cliffs?: unknown;
|
|
620
|
+
lowering?: unknown;
|
|
621
|
+
recovery?: unknown;
|
|
622
|
+
strengths?: string[] | null;
|
|
623
|
+
weaknesses?: string[] | null;
|
|
624
|
+
cost_input_per_1m?: number;
|
|
625
|
+
cost_output_per_1m?: number;
|
|
626
|
+
notes?: string | null;
|
|
627
|
+
verified_against_docs?: string | null;
|
|
628
|
+
archetype_perf?: Record<string, number> | null;
|
|
629
|
+
version_added?: string;
|
|
630
|
+
version_removed?: string | null;
|
|
631
|
+
active?: boolean;
|
|
632
|
+
}
|
|
633
|
+
interface ProfileToRowOptions {
|
|
634
|
+
/** e.g. `'2.0.0-alpha.12'` — leave undefined to omit from row. */
|
|
635
|
+
versionAdded?: string;
|
|
636
|
+
/** Pass `null` to clear; omit to leave field unset. */
|
|
637
|
+
versionRemoved?: string | null;
|
|
638
|
+
/** Defaults to true if omitted. */
|
|
639
|
+
active?: boolean;
|
|
640
|
+
/**
|
|
641
|
+
* Override verifiedAgainstDocs (e.g. set to `null` for auto-onboard).
|
|
642
|
+
* When omitted, the profile's own value is used. Pass `null` explicitly
|
|
643
|
+
* to write a SQL NULL (e.g. unverified auto-onboard rows).
|
|
644
|
+
*/
|
|
645
|
+
verifiedAgainstDocs?: string | null;
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Inverse of `rowToProfile` — serialize a `ModelProfile` to a `kgauto_models`
|
|
649
|
+
* row payload for INSERT/UPSERT. Used by operator scripts that write to
|
|
650
|
+
* brain (auto-onboard pipeline, promote-model verification CLI).
|
|
651
|
+
*
|
|
652
|
+
* Row-level fields (`version_added`, `version_removed`, `active`) are
|
|
653
|
+
* operator-controlled and pass through `opts`. `verifiedAgainstDocs` can
|
|
654
|
+
* also be overridden via `opts` — auto-onboard explicitly passes `null` to
|
|
655
|
+
* mark unverified rows (the column is DATE, doesn't accept the
|
|
656
|
+
* `'UNVERIFIED-AUTO-ONBOARD'` sentinel used in PROFILES_RAW).
|
|
657
|
+
*/
|
|
658
|
+
declare function profileToRow(profile: ModelProfile, opts?: ProfileToRowOptions): ModelBrainRow;
|
|
599
659
|
/**
|
|
600
660
|
* Sync reader for the brain-driven model registry. Returns bundled
|
|
601
661
|
* PROFILES_RAW when brain-query is disabled, cold, or unreachable.
|
|
@@ -656,4 +716,4 @@ declare const loadAliasesFromBrain: () => Record<string, string>;
|
|
|
656
716
|
*/
|
|
657
717
|
declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
|
|
658
718
|
|
|
659
|
-
export { ApiKeys, type AppOracle, type ArchetypePerfMap, BestPracticeAdvisory, type BrainConfig, type BrainQueryConfig, CallOptions, CallResult, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, type GetDefaultFallbackChainOpts, IntentArchetypeName, type LLMJudgeOptions, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, PROVIDER_ENV_KEYS, type PricingRow, PromptIR, Provider, ProviderOverrides, type ProviderReachability, type ReachabilityOpts, RecordInput, type SupportedProvider, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getAllStarterChains, getArchetypePerfScore, getDefaultFallbackChain, getReachabilityDiagnostic, getStarterChain, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, record, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|
|
719
|
+
export { ApiKeys, type AppOracle, type ArchetypePerfMap, BestPracticeAdvisory, type BrainConfig, type BrainQueryConfig, CallOptions, CallResult, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, type GetDefaultFallbackChainOpts, IntentArchetypeName, type LLMJudgeOptions, type ModelBrainRow, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, PROVIDER_ENV_KEYS, type PricingRow, type ProfileToRowOptions, PromptIR, Provider, ProviderOverrides, type ProviderReachability, type ReachabilityOpts, RecordInput, type SupportedProvider, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, execute, getAllStarterChains, getArchetypePerfScore, getDefaultFallbackChain, getReachabilityDiagnostic, getStarterChain, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, profileToRow, record, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
|
package/dist/index.js
CHANGED
|
@@ -53,6 +53,7 @@ __export(index_exports, {
|
|
|
53
53
|
loadChainsFromBrain: () => loadChainsFromBrain,
|
|
54
54
|
loadModelsFromBrain: () => loadModelsFromBrain,
|
|
55
55
|
loadPricingFromBrain: () => loadPricingFromBrain,
|
|
56
|
+
profileToRow: () => profileToRow,
|
|
56
57
|
profilesByProvider: () => profilesByProvider,
|
|
57
58
|
record: () => record,
|
|
58
59
|
resetTokenizer: () => resetTokenizer,
|
|
@@ -2805,6 +2806,39 @@ function rowToProfile(row) {
|
|
|
2805
2806
|
return null;
|
|
2806
2807
|
}
|
|
2807
2808
|
}
|
|
2809
|
+
function profileToRow(profile, opts = {}) {
|
|
2810
|
+
const row = {
|
|
2811
|
+
model_id: profile.id,
|
|
2812
|
+
provider: profile.provider,
|
|
2813
|
+
status: profile.status,
|
|
2814
|
+
max_context_tokens: profile.maxContextTokens,
|
|
2815
|
+
max_output_tokens: profile.maxOutputTokens,
|
|
2816
|
+
max_tools: profile.maxTools,
|
|
2817
|
+
parallel_tool_calls: profile.parallelToolCalls,
|
|
2818
|
+
structured_output: profile.structuredOutput,
|
|
2819
|
+
system_prompt_mode: profile.systemPromptMode,
|
|
2820
|
+
streaming: profile.streaming,
|
|
2821
|
+
cliffs: profile.cliffs,
|
|
2822
|
+
cost_input_per_1m: profile.costInputPer1m,
|
|
2823
|
+
cost_output_per_1m: profile.costOutputPer1m,
|
|
2824
|
+
lowering: profile.lowering,
|
|
2825
|
+
recovery: profile.recovery,
|
|
2826
|
+
strengths: profile.strengths,
|
|
2827
|
+
weaknesses: profile.weaknesses,
|
|
2828
|
+
notes: profile.notes ?? null,
|
|
2829
|
+
archetype_perf: profile.archetypePerf ?? null,
|
|
2830
|
+
active: opts.active ?? true
|
|
2831
|
+
};
|
|
2832
|
+
if (opts.verifiedAgainstDocs !== void 0) {
|
|
2833
|
+
row.verified_against_docs = opts.verifiedAgainstDocs;
|
|
2834
|
+
} else if (profile.verifiedAgainstDocs !== void 0) {
|
|
2835
|
+
const v = profile.verifiedAgainstDocs;
|
|
2836
|
+
row.verified_against_docs = /^\d{4}-\d{2}-\d{2}/.test(v) ? v : null;
|
|
2837
|
+
}
|
|
2838
|
+
if (opts.versionAdded !== void 0) row.version_added = opts.versionAdded;
|
|
2839
|
+
if (opts.versionRemoved !== void 0) row.version_removed = opts.versionRemoved;
|
|
2840
|
+
return row;
|
|
2841
|
+
}
|
|
2808
2842
|
function mapRowsToModels(rows) {
|
|
2809
2843
|
const out = /* @__PURE__ */ new Map();
|
|
2810
2844
|
for (const row of rows) {
|
|
@@ -2884,6 +2918,7 @@ function compile2(ir, opts) {
|
|
|
2884
2918
|
loadChainsFromBrain,
|
|
2885
2919
|
loadModelsFromBrain,
|
|
2886
2920
|
loadPricingFromBrain,
|
|
2921
|
+
profileToRow,
|
|
2887
2922
|
profilesByProvider,
|
|
2888
2923
|
record,
|
|
2889
2924
|
resetTokenizer,
|
package/dist/index.mjs
CHANGED
|
@@ -2016,6 +2016,39 @@ function rowToProfile(row) {
|
|
|
2016
2016
|
return null;
|
|
2017
2017
|
}
|
|
2018
2018
|
}
|
|
2019
|
+
function profileToRow(profile, opts = {}) {
|
|
2020
|
+
const row = {
|
|
2021
|
+
model_id: profile.id,
|
|
2022
|
+
provider: profile.provider,
|
|
2023
|
+
status: profile.status,
|
|
2024
|
+
max_context_tokens: profile.maxContextTokens,
|
|
2025
|
+
max_output_tokens: profile.maxOutputTokens,
|
|
2026
|
+
max_tools: profile.maxTools,
|
|
2027
|
+
parallel_tool_calls: profile.parallelToolCalls,
|
|
2028
|
+
structured_output: profile.structuredOutput,
|
|
2029
|
+
system_prompt_mode: profile.systemPromptMode,
|
|
2030
|
+
streaming: profile.streaming,
|
|
2031
|
+
cliffs: profile.cliffs,
|
|
2032
|
+
cost_input_per_1m: profile.costInputPer1m,
|
|
2033
|
+
cost_output_per_1m: profile.costOutputPer1m,
|
|
2034
|
+
lowering: profile.lowering,
|
|
2035
|
+
recovery: profile.recovery,
|
|
2036
|
+
strengths: profile.strengths,
|
|
2037
|
+
weaknesses: profile.weaknesses,
|
|
2038
|
+
notes: profile.notes ?? null,
|
|
2039
|
+
archetype_perf: profile.archetypePerf ?? null,
|
|
2040
|
+
active: opts.active ?? true
|
|
2041
|
+
};
|
|
2042
|
+
if (opts.verifiedAgainstDocs !== void 0) {
|
|
2043
|
+
row.verified_against_docs = opts.verifiedAgainstDocs;
|
|
2044
|
+
} else if (profile.verifiedAgainstDocs !== void 0) {
|
|
2045
|
+
const v = profile.verifiedAgainstDocs;
|
|
2046
|
+
row.verified_against_docs = /^\d{4}-\d{2}-\d{2}/.test(v) ? v : null;
|
|
2047
|
+
}
|
|
2048
|
+
if (opts.versionAdded !== void 0) row.version_added = opts.versionAdded;
|
|
2049
|
+
if (opts.versionRemoved !== void 0) row.version_removed = opts.versionRemoved;
|
|
2050
|
+
return row;
|
|
2051
|
+
}
|
|
2019
2052
|
function mapRowsToModels(rows) {
|
|
2020
2053
|
const out = /* @__PURE__ */ new Map();
|
|
2021
2054
|
for (const row of rows) {
|
|
@@ -2094,6 +2127,7 @@ export {
|
|
|
2094
2127
|
loadChainsFromBrain,
|
|
2095
2128
|
loadModelsFromBrain,
|
|
2096
2129
|
loadPricingFromBrain,
|
|
2130
|
+
profileToRow,
|
|
2097
2131
|
profilesByProvider,
|
|
2098
2132
|
record,
|
|
2099
2133
|
resetTokenizer,
|
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.12",
|
|
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",
|