Files
PaperClipAI/ui/src/lib/cloud-harness-policy.ts
T
Devin FoleyandPaperclip ae2afd525b Make harness choices deployment-configurable
Managed deployments need to control harness availability without changing Core policy. Add a generic environment contract and apply it across harness and model selectors, preserving saved supported profiles and validating import, team, and invite selections. Document deployment ownership in agent guidance.

Validation: focused local tests and typechecks passed; all applicable CI checks passed on the reviewed head. Greptile scored 5/5 with no unresolved comments.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-11-20 15:45:36 -08:00

22 lines
1.2 KiB
TypeScript

import { agentRuntimeSettingsHarness } from "@paperclipai/shared";
import { PAPERCLIP_RUNNER_ACPX_PROFILES } from "@paperclipai/adapter-utils";
/** Deployment policy only restricts choices; adapter availability and qualification still apply. */
export function createCloudHarnessPolicy(availableHarnesses?: readonly string[]) {
const allowed = availableHarnesses === undefined ? undefined : new Set(availableHarnesses);
function isCloudHarnessAllowed(type: string, config: Record<string, unknown> = {}): boolean {
return allowed === undefined || allowed.has(agentRuntimeSettingsHarness(type, config));
}
function isCloudRunnerProviderAllowed(provider: string, acpxAgent?: string): boolean {
const profile = PAPERCLIP_RUNNER_ACPX_PROFILES.find(entry => entry.value === provider);
return isCloudHarnessAllowed("paperclip_runner", {
provider: profile ? "acpx" : provider,
acpxAgent: acpxAgent ?? profile?.value ?? (provider === "acpx" ? "claude" : provider),
});
}
return { availableHarnesses, restricted: allowed !== undefined, isCloudHarnessAllowed, isCloudRunnerProviderAllowed };
}
export type CloudHarnessPolicy = ReturnType<typeof createCloudHarnessPolicy>;
export const unrestrictedCloudHarnessPolicy = createCloudHarnessPolicy();