Files
t3code/apps/server/src/orchestration-v2/ProviderSelectionTransition.ts
T
Julius Marminge c529c610e3 Handle preparing turns across provider orchestration
- Treat preparing as an active turn state in mobile and server flows
- Tighten ACP model option validation and selection reconfiguration
- Add coverage for turn mapping, raw protocol logging, and recovery paths
2026-06-24 16:36:49 -07:00

38 lines
1.3 KiB
TypeScript

import type { ModelSelection, OrchestrationV2ProviderCapabilities } from "@t3tools/contracts";
export interface ProviderSelectionTransitionInput {
readonly current: ModelSelection;
readonly target: ModelSelection;
readonly sessionCapabilities: OrchestrationV2ProviderCapabilities;
}
/**
* Provider-owned classification of how a complete selection can be applied.
* The orchestrator remains responsible for attempts and resource lifecycle.
*/
export type ProviderSelectionTransitionPlan =
| { readonly type: "apply_on_next_turn" }
| { readonly type: "restart_session" }
| { readonly type: "create_with_handoff" }
| { readonly type: "reject"; readonly reason: string };
export function turnScopedSelectionTransition(): ProviderSelectionTransitionPlan {
return { type: "apply_on_next_turn" };
}
/** ACP models require a negotiated model/config mutation capability. */
export function acpSelectionTransition(
input: ProviderSelectionTransitionInput,
): ProviderSelectionTransitionPlan {
if (
input.current.model !== input.target.model &&
!input.sessionCapabilities.sessions.supportsModelSwitchInSession
) {
return {
type: "reject",
reason: "The active ACP session does not expose a model-switch capability.",
};
}
return { type: "apply_on_next_turn" };
}