mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
28 lines
819 B
TypeScript
28 lines
819 B
TypeScript
import { getRequiredBundlesForTool } from "@snapotter/shared";
|
|||
|
|
|
||
|
|
interface InstalledAiCapabilityGate {
|
||
|
|
installed: boolean;
|
||
|
|
runInstalledContract: boolean;
|
||
|
|
runUnavailableContract: boolean;
|
||
|
|
}
|
||
|
|
|
||
|
|
type ToolCapabilityDetector = (toolId: string) => boolean;
|
||
|
|
|
||
|
|
/** Select complementary integration lanes without hiding required-feature failures. */
|
||
|
|
export function installedAiCapabilityGate(
|
||
|
|
toolId: string,
|
||
|
|
requireAiFeatures: boolean,
|
||
|
|
isInstalled: ToolCapabilityDetector,
|
||
|
|
): InstalledAiCapabilityGate {
|
||
|
|
if (getRequiredBundlesForTool(toolId).length === 0) {
|
||
|
|
throw new Error(`${toolId}: installed AI gate requires a bundle-gated tool`);
|
||
|
|
}
|
||
|
|
|
||
|
|
const installed = isInstalled(toolId);
|
||
|
|
return {
|
||
|
|
installed,
|
||
|
|
runInstalledContract: installed || requireAiFeatures,
|
||
|
|
runUnavailableContract: !installed,
|
||
|
|
};
|
||
|
|
}
|