mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-29 15:46:21 +01:00
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>
40 lines
2.5 KiB
TypeScript
40 lines
2.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { Agent } from "@paperclipai/shared";
|
|
import { createCloudHarnessPolicy } from "./cloud-harness-policy";
|
|
import { sampleHarnesses } from "@/test-support/harness-availability";
|
|
import { bulkAgentDisabledReason, mapBulkAgents, sameBinding } from "./bulk-agent-settings";
|
|
|
|
it("withholds Cloud bulk model edits for unsupported saved native profiles", () => {
|
|
const agent = { adapterType: "paperclip_runner", adapterConfig: { provider: "acpx", acpxAgent: "antigravity" }, runtimeConfig: {}, status: "idle" } as unknown as Agent;
|
|
expect(bulkAgentDisabledReason(agent)).toBeUndefined();
|
|
expect(bulkAgentDisabledReason(agent, true, createCloudHarnessPolicy(sampleHarnesses))).toContain("not available on Paperclip Cloud");
|
|
expect(bulkAgentDisabledReason({ ...agent, adapterConfig: { provider: "acpx", acpxAgent: "copilot" } }, true, createCloudHarnessPolicy(sampleHarnesses))).toBeUndefined();
|
|
});
|
|
|
|
describe("bulk agent writes", () => {
|
|
it("allows Antigravity connection/model edits while preserving router-only editing", () => {
|
|
const agent = { adapterType: "paperclip_runner", adapterConfig: { provider: "acpx", acpxAgent: "antigravity" }, runtimeConfig: {}, status: "active" } as unknown as Agent;
|
|
expect(bulkAgentDisabledReason(agent)).toBeUndefined();
|
|
expect(bulkAgentDisabledReason({ ...agent, status: "terminated" })).toContain("not available");
|
|
expect(bulkAgentDisabledReason({ ...agent, runtimeConfig: { aiConnection: { mode: "router", connectionId: "11111111-1111-4111-8111-111111111111" } } })).toContain("pool members");
|
|
});
|
|
it("bounds concurrent requests and retains each success and failure in input order", async () => {
|
|
let active = 0;
|
|
let peak = 0;
|
|
const results = await mapBulkAgents([0, 1, 2, 3, 4, 5, 6], async id => {
|
|
active++;
|
|
peak = Math.max(peak, active);
|
|
await new Promise(resolve => setTimeout(resolve, id === 0 ? 15 : 1));
|
|
active--;
|
|
if (id === 2) throw new Error("Unavailable");
|
|
return id;
|
|
});
|
|
expect(peak).toBe(4);
|
|
expect(results.map(r => r.status === "fulfilled" ? r.value : "failed")).toEqual([0, 1, "failed", 3, 4, 5, 6]);
|
|
});
|
|
it("compares binding identity independently of JSON field order", () => {
|
|
expect(sameBinding({ provider: "openai", method: "api_key", mode: "responsible_user" }, { mode: "responsible_user", method: "api_key", provider: "openai" })).toBe(true);
|
|
expect(sameBinding(undefined, { mode: "responsible_user", method: "api_key", provider: "openai" })).toBe(false);
|
|
});
|
|
});
|