Skip to content
Source
Sign inSign up
Open History to see the last commit

selectionTransition.ts

32 lines1.1 KB

1import type { ModelSelection, OrchestrationV2ProviderCapabilities } from "@t3tools/contracts";
2​
3export interface ProviderSelectionTransitionInput {
4 readonly current: ModelSelection;
5 readonly target: ModelSelection;
6 readonly sessionCapabilities: OrchestrationV2ProviderCapabilities;
7}
8​
9export type ProviderSelectionTransitionPlan =
10 | { readonly type: "apply_on_next_turn" }
11 | { readonly type: "restart_session" }
12 | { readonly type: "create_with_handoff" }
13 | { readonly type: "reject"; readonly reason: string };
14​
15export function turnScopedSelectionTransition(): ProviderSelectionTransitionPlan {
16 return { type: "apply_on_next_turn" };
18​
19export function acpSelectionTransition(
20 input: ProviderSelectionTransitionInput,
21): ProviderSelectionTransitionPlan {
22 if (
23 input.current.model !== input.target.model &&
24 !input.sessionCapabilities.sessions.supportsModelSwitchInSession
25 ) {
26 return {
27 type: "reject",
28 reason: "The active ACP session does not expose a model-switch capability.",
29 };
30 }
31 return { type: "apply_on_next_turn" };