mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-10 03:08:10 +02:00
Decode current Runner profiles from the release manifest
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
0432d80cfd
commit
15af2eefbc
2 files changed
+21
-6
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { QUALIFIED_ACPX_PROFILE_DATA } from "./generated-profiles.js";
|
||||
import { isSupportedAcpxProfileVersion } from "./profile-compatibility.js";
|
||||
|
||||
describe("historical ACPX profile decoding", () => {
|
||||
@@ -6,16 +7,23 @@ describe("historical ACPX profile decoding", () => {
|
||||
expect(isSupportedAcpxProfileVersion("cursor", 15)).toBe(true);
|
||||
for (const agent of ["pi", "copilot"]) {
|
||||
expect(isSupportedAcpxProfileVersion(agent, 16)).toBe(true);
|
||||
expect(isSupportedAcpxProfileVersion(agent, 17)).toBe(false);
|
||||
const current = QUALIFIED_ACPX_PROFILE_DATA[agent as "pi" | "copilot"].agentProfileVersion;
|
||||
expect(isSupportedAcpxProfileVersion(agent, current)).toBe(true);
|
||||
expect(isSupportedAcpxProfileVersion(agent, Math.max(16, current) + 1)).toBe(false);
|
||||
}
|
||||
for (const agent of ["claude", "codex", "grok"]) {
|
||||
expect(isSupportedAcpxProfileVersion(agent, 5)).toBe(true);
|
||||
expect(isSupportedAcpxProfileVersion(agent, 6)).toBe(false);
|
||||
}
|
||||
});
|
||||
it.each([0, 16, 1.5, "11", null, undefined, NaN])("rejects invalid revisions: %s", version => {
|
||||
it.each([0, 1.5, "11", null, undefined, NaN])("rejects invalid revisions: %s", version => {
|
||||
expect(isSupportedAcpxProfileVersion("cursor", version)).toBe(false);
|
||||
});
|
||||
it("decodes every current release while retaining exact launch admission separately", () => {
|
||||
for (const [agent, current] of Object.entries(QUALIFIED_ACPX_PROFILE_DATA)) {
|
||||
expect(isSupportedAcpxProfileVersion(agent, current.agentProfileVersion)).toBe(true);
|
||||
}
|
||||
});
|
||||
it.each(["unknown", "toString", "__proto__"])("rejects unregistered providers: %s", agent => {
|
||||
expect(isSupportedAcpxProfileVersion(agent, 1)).toBe(false);
|
||||
});
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
import { QUALIFIED_ACPX_PROFILE_DATA } from "./generated-profiles.js";
|
||||
|
||||
/** Decodable historical profile revisions, not permission to launch them.
|
||||
* Exact current profile/package/digest admission is checked separately. */
|
||||
export type AcpxProfileVersion = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16;
|
||||
const historicalVersions: Readonly<Record<string, readonly AcpxProfileVersion[]>> = {
|
||||
type HistoricalAcpxProfileVersion = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16;
|
||||
type CurrentAcpxProfileVersion = typeof QUALIFIED_ACPX_PROFILE_DATA[keyof typeof QUALIFIED_ACPX_PROFILE_DATA]["agentProfileVersion"];
|
||||
export type AcpxProfileVersion = HistoricalAcpxProfileVersion | CurrentAcpxProfileVersion;
|
||||
|
||||
const historicalVersions: Readonly<Record<string, readonly HistoricalAcpxProfileVersion[]>> = {
|
||||
pi: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], claude: [1, 2, 3, 4, 5], codex: [1, 2, 3, 4, 5],
|
||||
grok: [1, 2, 3, 4, 5], copilot: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
|
||||
cursor: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
||||
};
|
||||
|
||||
export function isSupportedAcpxProfileVersion(agent: string, value: unknown): value is AcpxProfileVersion {
|
||||
return Object.hasOwn(historicalVersions, agent)
|
||||
&& historicalVersions[agent]!.includes(value as AcpxProfileVersion);
|
||||
if (!Object.hasOwn(QUALIFIED_ACPX_PROFILE_DATA, agent)) return false;
|
||||
const current = QUALIFIED_ACPX_PROFILE_DATA[agent as keyof typeof QUALIFIED_ACPX_PROFILE_DATA];
|
||||
return value === current.agentProfileVersion
|
||||
|| historicalVersions[agent]?.includes(value as HistoricalAcpxProfileVersion) === true;
|
||||
}
|
||||
Reference in new issue
Block a user