feat(core): add command, intent, and routing primitives

This commit is contained in:
William Valentin
2026-02-12 22:47:22 -08:00
parent 7ae0fb51c2
commit 6e8984f788
25 changed files with 1469 additions and 0 deletions
+64
View File
@@ -0,0 +1,64 @@
export type RoutingPath = 'fast' | 'llm';
export interface RoutingPolicyConfig {
enabled: boolean;
fastPathThreshold: number;
llmThreshold: number;
defaultPath: RoutingPath;
}
export interface RoutingDecisionInput {
confidence: number | null;
}
export interface RoutingDecision {
path: RoutingPath;
reason: 'disabled' | 'no_match' | 'high_confidence' | 'low_confidence' | 'mid_confidence';
}
export class RoutingPolicy {
private readonly config: RoutingPolicyConfig;
constructor(config: RoutingPolicyConfig) {
this.config = config;
}
isEnabled(): boolean {
return this.config.enabled;
}
decide(input: RoutingDecisionInput): RoutingDecision {
if (!this.config.enabled) {
return {
path: this.config.defaultPath,
reason: 'disabled',
};
}
if (input.confidence === null) {
return {
path: this.config.defaultPath,
reason: 'no_match',
};
}
if (input.confidence >= this.config.fastPathThreshold) {
return {
path: 'fast',
reason: 'high_confidence',
};
}
if (input.confidence <= this.config.llmThreshold) {
return {
path: 'llm',
reason: 'low_confidence',
};
}
return {
path: this.config.defaultPath,
reason: 'mid_confidence',
};
}
}