mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-29 15:52:36 +01:00
feat(skills): add beta releases for the core Paperclip skill (#10228)
## Thinking Path > - Paperclip is the open source control plane people use to organize and operate AI-agent companies. > - Agent behavior depends partly on the bundled Paperclip core skill synchronized into each runtime. > - The existing database and runtime plumbing already supports immutable skill-version snapshots and per-agent version selections, but no product workflow exposed that capability. > - Replacing the live bundled skill globally would make champion adoption risky and difficult to compare across agents. > - This pull request adds an experimental, instance-level beta-skills gate plus a repository release registry, immutable seeded releases, enforcement, and a per-agent release picker. > - The benefit is controlled per-agent evaluation of frozen core-skill releases while the default-off path remains behaviorally unchanged. ## Linked Issues or Issue Description ### Subsystem affected Cross-cutting: `server/`, `ui/`, `packages/db`, and `packages/shared`. ### Problem or motivation Paperclip needs a safe way to evaluate improved versions of its core operating skill without globally replacing the live default. Today the version-snapshot and per-agent pin plumbing exists, but operators cannot use it. A global replacement would make regressions difficult to contain and would prevent controlled comparisons across agents. ### Proposed solution Add a default-off instance experiment that exposes immutable, named core-skill releases. When enabled, operators can pin each agent to a seeded release; when disabled, every agent resolves the live default while saved pins remain intact. Validate pinned writes at the API boundary, gate reads at runtime, and expose the selection in the agent Skills tab. ### Alternatives considered - **Replace the bundled core skill globally:** rejected because it changes every agent at once and provides no rollback/isolation boundary. - **Ship releases as separate skills:** rejected because releases are versions of one core capability, not independently enabled skills. - **Store release snapshots only outside the repository:** rejected because repository provenance and hashes make builds reproducible and reviewable. ### Roadmap alignment This extends the Skills Manager / Skill Studio direction in `ROADMAP.md` by making core-skill versions operable per agent. It does not duplicate another open implementation PR; GitHub searches found no related `enableBetaSkills` change. ### Additional context The feature remains experimental and default off. The V7 champion was selected through a multi-model evaluation process, and the frozen release contents are verified by SHA-256 below. ## What Changed - Added the default-off instance-level `enableBetaSkills` experimental flag. - Added `skills-releases/paperclip/` with the ordered release registry and frozen `v0` plus `v7-roster` snapshots. - Added release metadata to `company_skill_versions` and idempotent release seeding. The migration was planned as `0191`, then renumbered to `0192` because current `master` claimed `0191` before final rebase. - Added read-time gating and write-time validation so disabled instances always resolve the live default and reject pinned-version writes. - Added the per-agent Release picker in the agent Skills tab, including responsive layout and beta-pin state. - Kept `EDITS.md` out of the release registry and PR diff. ### V7 Adoption Evidence - Paid roster: 6 models, 94-case suite. - Result: 553/564 pass-within-2, mean 92.17/94, versus the P2 baseline of 544/564. - Reference model improved 84→91; maximin improved 84→90. - Final report: https://pages.paperclip.ing/skills/optimization/paperclip/pap-14624-p3-final-20260721/ ### Provenance - `v7-roster` is the Phase 1 champion plus additions-only edits E107–E112. Per-edit rationale remains in the evals repository at `source/v7-roster/EDITS.md` and is deliberately excluded from this PR. - `v0` is the `skills/paperclip` tree from commit `ea66ea81`. - Champion selection was accepted on July 21, 2026 via board card `9c304fc2` (PAP-14624 G3). - This delivery mechanism was accepted on July 24, 2026 via plan revision `2367abd2` (PAP-14858). ### QA Evidence - P4 QA matrix comment `b7f40522-4e9b-4a3a-9821-28e86fe1a987`: all 6 acceptance criteria passed. - Automated QA matrix: 166 tests passed with 0 failures, including real filesystem materialization and full SHA-256 assertions. - UI QA exercised the real agent Skills tab at desktop and mobile widths with the experimental flag both on and off. ## Verification - `pnpm check:token-gates` - Focused beta-release matrix: 169 tests passed across shared validators, server services/routes/heartbeat behavior, instance settings UI, and release picker UI. - `pnpm -r typecheck` - `pnpm build` - `pnpm test:run`: server and UI partitions passed; one CLI doctor test inherited temporary AWS credentials from the agent heartbeat and expected no static credentials. The isolated rerun with `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` unset passed 8/8. - V7 SHA-256: - `SKILL.md`: `53ab290489684cbf116fdd1406a95f6b6f53c9c36358b1bf8bfeae481e253575` - `references/cases.md`: `3b821f59064a7761091020a14819a8d787131f24029748563d6c0e1be7e6eaec` - `references/workflows.md`: `69747bd6e05f7e3673d1e67b07ff295df1869c05e1fd029804d5fa9177db92cd` - Confirmed 49 changed files, no `pnpm-lock.yaml`, no workflow changes, and no `EDITS.md`. ## Risks - **Migration:** low-to-moderate risk. Three nullable columns and one partial unique index are added idempotently; existing rows remain valid. - **Behavior:** low risk while the flag is off because read-time resolution forces the live default and saved pins are preserved but inactive. - **Frozen content:** release snapshots intentionally diverge from future live skill edits; provenance and hashes make that divergence explicit and reproducible. - **UI:** low risk. The picker only renders for the bundled core skill when the experimental flag is enabled and seeded releases exist. > This extends the existing Skills Manager / Skill Studio direction described in `ROADMAP.md`; it does not duplicate another open implementation PR. The GitHub PR search found no related `enableBetaSkills` change. ## Model Used - OpenAI Codex using `gpt-5.5` with reasoning and terminal/code-execution tools; context-window size is not exposed by this runtime. Earlier implementation commits also record Claude Opus 4.8 assistance where applicable. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [ ] I have not referenced internal/instance-local Paperclip issues or links (required governance identifiers are included above; no internal URL is included) - [ ] My branch name describes the change and contains no internal Paperclip ticket id (the approved delivery plan mandated this shared branch name) - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
030dd9d15c
commit
c3bd0c5d50
49 files changed
+7394
-33
No files matched your search
@@ -48,6 +48,10 @@ const mockCompanySkillService = vi.hoisted(() => ({
|
||||
resolveRequestedSkillKeys: vi.fn(),
|
||||
}));
|
||||
|
||||
const mockInstanceSettingsService = vi.hoisted(() => ({
|
||||
getExperimental: vi.fn(),
|
||||
}));
|
||||
|
||||
const mockSecretService = vi.hoisted(() => ({
|
||||
resolveAdapterConfigForRuntime: vi.fn(),
|
||||
normalizeAdapterConfigForPersistence: vi.fn(async (_companyId: string, config: Record<string, unknown>) => config),
|
||||
@@ -102,6 +106,11 @@ vi.mock("../services/secrets.js", () => ({
|
||||
secretService: () => mockSecretService,
|
||||
}));
|
||||
|
||||
vi.mock("../services/instance-settings.js", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("../services/instance-settings.js")>()),
|
||||
instanceSettingsService: () => mockInstanceSettingsService,
|
||||
}));
|
||||
|
||||
vi.mock("../adapters/index.js", () => ({
|
||||
findServerAdapter: vi.fn(() => mockAdapter),
|
||||
findActiveServerAdapter: vi.fn(() => mockAdapter),
|
||||
@@ -140,6 +149,11 @@ function registerModuleMocks() {
|
||||
secretService: () => mockSecretService,
|
||||
}));
|
||||
|
||||
vi.doMock("../services/instance-settings.js", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("../services/instance-settings.js")>()),
|
||||
instanceSettingsService: () => mockInstanceSettingsService,
|
||||
}));
|
||||
|
||||
vi.doMock("../adapters/index.js", () => ({
|
||||
findServerAdapter: vi.fn(() => mockAdapter),
|
||||
findActiveServerAdapter: vi.fn(() => mockAdapter),
|
||||
@@ -245,6 +259,7 @@ describe.sequential("agent skill routes", () => {
|
||||
for (const mock of Object.values(mockIssueApprovalService)) mock.mockReset();
|
||||
for (const mock of Object.values(mockAgentInstructionsService)) mock.mockReset();
|
||||
for (const mock of Object.values(mockCompanySkillService)) mock.mockReset();
|
||||
for (const mock of Object.values(mockInstanceSettingsService)) mock.mockReset();
|
||||
for (const mock of Object.values(mockSecretService)) mock.mockReset();
|
||||
mockLogActivity.mockReset();
|
||||
mockTrackAgentCreated.mockReset();
|
||||
@@ -260,6 +275,7 @@ describe.sequential("agent skill routes", () => {
|
||||
agent: makeAgent("claude_local"),
|
||||
});
|
||||
mockSecretService.resolveAdapterConfigForRuntime.mockResolvedValue({ config: { env: {} } });
|
||||
mockInstanceSettingsService.getExperimental.mockResolvedValue({ enableBetaSkills: false });
|
||||
mockSecretService.syncEnvBindingsForTarget.mockResolvedValue(undefined);
|
||||
mockCompanySkillService.listRuntimeSkillEntries.mockResolvedValue([
|
||||
{
|
||||
@@ -599,6 +615,48 @@ describe.sequential("agent skill routes", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects version pins while beta skills are disabled", async () => {
|
||||
mockAgentService.getById.mockResolvedValue(makeAgent("claude_local"));
|
||||
|
||||
const res = await requestApp(await createApp(), (baseUrl) => request(baseUrl)
|
||||
.post("/api/agents/11111111-1111-4111-8111-111111111111/skills/sync?companyId=company-1")
|
||||
.send({
|
||||
desiredSkills: [{
|
||||
key: "paperclipai/paperclip/paperclip",
|
||||
versionId: "22222222-2222-4222-8222-222222222222",
|
||||
}],
|
||||
}));
|
||||
|
||||
expect(res.status, JSON.stringify(res.body)).toBe(400);
|
||||
expect(res.body.error).toContain("Beta skills experimental setting");
|
||||
expect(mockAgentService.update).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("accepts version pins while beta skills are enabled", async () => {
|
||||
mockInstanceSettingsService.getExperimental.mockResolvedValue({ enableBetaSkills: true });
|
||||
mockAgentService.getById.mockResolvedValue(makeAgent("claude_local"));
|
||||
const versionId = "22222222-2222-4222-8222-222222222222";
|
||||
|
||||
const res = await requestApp(await createApp(), (baseUrl) => request(baseUrl)
|
||||
.post("/api/agents/11111111-1111-4111-8111-111111111111/skills/sync?companyId=company-1")
|
||||
.send({
|
||||
desiredSkills: [{ key: "paperclipai/paperclip/paperclip", versionId }],
|
||||
}));
|
||||
|
||||
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
||||
expect(mockAgentService.update).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
expect.objectContaining({
|
||||
adapterConfig: expect.objectContaining({
|
||||
paperclipSkillSync: expect.objectContaining({
|
||||
desiredSkills: [{ key: "paperclipai/paperclip/paperclip", versionId }],
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
expect.any(Object),
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves stale desired keys instead of 422-ing when syncing (PAP-13222)", async () => {
|
||||
mockAgentService.getById.mockResolvedValue(makeAgent("acpx_local"));
|
||||
// The agent already carries a stale desired key that no longer resolves to a
|
||||
@@ -806,6 +864,25 @@ describe.sequential("agent skill routes", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects version pins when creating an agent while beta skills are disabled", async () => {
|
||||
const res = await requestApp(await createApp(), (baseUrl) => request(baseUrl)
|
||||
.post("/api/companies/company-1/agents")
|
||||
.send({
|
||||
name: "QA Agent",
|
||||
role: "engineer",
|
||||
adapterType: "claude_local",
|
||||
desiredSkills: [{
|
||||
key: "paperclipai/paperclip/paperclip",
|
||||
versionId: "22222222-2222-4222-8222-222222222222",
|
||||
}],
|
||||
adapterConfig: {},
|
||||
}));
|
||||
|
||||
expect(res.status, JSON.stringify(res.body)).toBe(400);
|
||||
expect(res.body.error).toContain("Beta skills experimental setting");
|
||||
expect(mockAgentService.create).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("accepts the security role on direct agent creation and preserves it in telemetry", async () => {
|
||||
const res = await requestApp(await createApp(), (baseUrl) => request(baseUrl)
|
||||
.post("/api/companies/company-1/agents")
|
||||
@@ -995,6 +1072,26 @@ describe.sequential("agent skill routes", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects version pins in agent hires while beta skills are disabled", async () => {
|
||||
const res = await request(await createApp(createDb(true)))
|
||||
.post("/api/companies/company-1/agent-hires")
|
||||
.send({
|
||||
name: "QA Agent",
|
||||
role: "engineer",
|
||||
adapterType: "claude_local",
|
||||
desiredSkills: [{
|
||||
key: "paperclipai/paperclip/paperclip",
|
||||
versionId: "22222222-2222-4222-8222-222222222222",
|
||||
}],
|
||||
adapterConfig: {},
|
||||
});
|
||||
|
||||
expect(res.status, JSON.stringify(res.body)).toBe(400);
|
||||
expect(res.body.error).toContain("Beta skills experimental setting");
|
||||
expect(mockAgentService.create).not.toHaveBeenCalled();
|
||||
expect(mockApprovalService.create).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("preserves hire source issues, icons, desired skills, and approval payload details", async () => {
|
||||
const db = createDb(true);
|
||||
const sourceIssueId = "22222222-2222-4222-8222-222222222222";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { createHash, randomUUID } from "node:crypto";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { promises as fs } from "node:fs";
|
||||
@@ -333,6 +333,73 @@ describeEmbeddedPostgres("companySkillService.list", () => {
|
||||
expect(refreshedSkill?.updatedAt.toISOString()).toBe(preservedUpdatedAt.toISOString());
|
||||
});
|
||||
|
||||
it("seeds bundled skill releases idempotently and materializes the frozen champion snapshot", async () => {
|
||||
const companyId = randomUUID();
|
||||
await db.insert(companies).values({
|
||||
id: companyId,
|
||||
name: "Paperclip",
|
||||
issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
|
||||
requireBoardApprovalForNewAgents: false,
|
||||
});
|
||||
|
||||
const initialList = await svc.list(companyId);
|
||||
await svc.list(companyId);
|
||||
const paperclipSkill = initialList.find((skill) => skill.key === "paperclipai/paperclip/paperclip");
|
||||
expect(paperclipSkill).toBeDefined();
|
||||
if (!paperclipSkill) throw new Error("Expected bundled Paperclip skill");
|
||||
|
||||
const versions = await svc.listVersions(companyId, paperclipSkill.id);
|
||||
expect(versions.map((version) => version.releaseId).sort()).toEqual(["v0", "v7-roster"]);
|
||||
expect(versions).toHaveLength(2);
|
||||
const storedSkill = await db
|
||||
.select({ currentVersionId: companySkills.currentVersionId })
|
||||
.from(companySkills)
|
||||
.where(eq(companySkills.id, paperclipSkill.id))
|
||||
.then((rows) => rows[0]);
|
||||
expect(storedSkill?.currentVersionId).toBeNull();
|
||||
|
||||
const champion = versions.find((version) => version.releaseId === "v7-roster");
|
||||
expect(champion).toMatchObject({
|
||||
releaseName: "V7 — Roster champion",
|
||||
releasedAt: new Date("2026-07-21T00:00:00.000Z"),
|
||||
});
|
||||
if (!champion) throw new Error("Expected seeded v7-roster release");
|
||||
const championHashes = Object.fromEntries(champion.fileInventory.map((entry) => [
|
||||
entry.path,
|
||||
createHash("sha256").update(entry.content).digest("hex"),
|
||||
]));
|
||||
expect(championHashes).toMatchObject({
|
||||
"SKILL.md": "53ab290489684cbf116fdd1406a95f6b6f53c9c36358b1bf8bfeae481e253575",
|
||||
"references/cases.md": "3b821f59064a7761091020a14819a8d787131f24029748563d6c0e1be7e6eaec",
|
||||
"references/workflows.md": "69747bd6e05f7e3673d1e67b07ff295df1869c05e1fd029804d5fa9177db92cd",
|
||||
});
|
||||
expect(championHashes).not.toHaveProperty("EDITS.md");
|
||||
|
||||
const runtimeEntries = await svc.listRuntimeSkillEntries(companyId, {
|
||||
versionSelections: new Map([[paperclipSkill.key, champion.id]]),
|
||||
});
|
||||
const materialized = runtimeEntries.find((entry) => entry.key === paperclipSkill.key);
|
||||
expect(materialized).toMatchObject({ versionId: champion.id, sourceStatus: "available" });
|
||||
if (!materialized) throw new Error("Expected materialized release entry");
|
||||
const materializedHashes: Record<string, string> = {};
|
||||
async function walk(root: string, current = root): Promise<void> {
|
||||
for (const entry of await fs.readdir(current, { withFileTypes: true })) {
|
||||
const absolutePath = path.join(current, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
await walk(root, absolutePath);
|
||||
continue;
|
||||
}
|
||||
const relativePath = path.relative(root, absolutePath).split(path.sep).join("/");
|
||||
materializedHashes[relativePath] = createHash("sha256")
|
||||
.update(await fs.readFile(absolutePath))
|
||||
.digest("hex");
|
||||
}
|
||||
}
|
||||
await walk(materialized.source);
|
||||
expect(materializedHashes).toEqual(championHashes);
|
||||
expect(materializedHashes).not.toHaveProperty("EDITS.md");
|
||||
});
|
||||
|
||||
it("repairs a squatted bundled root during bundled-skill list refresh", async () => {
|
||||
const companyId = randomUUID();
|
||||
await db.insert(companies).values({
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
} from "./helpers/embedded-postgres.js";
|
||||
import { companySkillService } from "../services/company-skills.ts";
|
||||
import { heartbeatService } from "../services/heartbeat.ts";
|
||||
import { instanceSettingsService } from "../services/instance-settings.ts";
|
||||
import { registerServerAdapter, unregisterServerAdapter } from "../adapters/index.ts";
|
||||
|
||||
const embeddedPostgresSupport = await getEmbeddedPostgresTestSupport();
|
||||
@@ -110,6 +111,7 @@ describeEmbeddedPostgres("heartbeat runtime skill version pins", () => {
|
||||
|
||||
afterEach(async () => {
|
||||
capturedRuns.length = 0;
|
||||
await instanceSettingsService(db).updateExperimental({ enableBetaSkills: false });
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
await db.execute(sql.raw(`
|
||||
TRUNCATE TABLE
|
||||
@@ -228,6 +230,9 @@ describeEmbeddedPostgres("heartbeat runtime skill version pins", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
const settings = instanceSettingsService(db);
|
||||
await settings.updateExperimental({ enableBetaSkills: true });
|
||||
|
||||
const heartbeat = heartbeatService(db);
|
||||
const firstRun = await heartbeat.invoke(firstAgentId, "on_demand", {}, "manual");
|
||||
expect(firstRun).not.toBeNull();
|
||||
@@ -276,6 +281,49 @@ describeEmbeddedPostgres("heartbeat runtime skill version pins", () => {
|
||||
sourceStatus: "available",
|
||||
});
|
||||
expect((await fs.stat(firstSkillFile)).mtime.toISOString()).toBe(oldMtime.toISOString());
|
||||
|
||||
await settings.updateExperimental({ enableBetaSkills: false });
|
||||
const defaultRun = await heartbeat.invoke(firstAgentId, "on_demand", {}, "manual");
|
||||
expect(defaultRun).not.toBeNull();
|
||||
expect((await waitForRunToFinish(heartbeat, defaultRun!.id))?.status).toBe("succeeded");
|
||||
const defaultSkill = capturedRuns
|
||||
.filter((run) => run.agentId === firstAgentId)
|
||||
.at(-1)
|
||||
?.skills.find((entry) => entry.key === skillKey);
|
||||
expect(defaultSkill).toMatchObject({
|
||||
key: skillKey,
|
||||
versionId: null,
|
||||
currentVersionId: versionTwo.id,
|
||||
sourceStatus: "available",
|
||||
});
|
||||
await expect(fs.readFile(path.join(defaultSkill!.source, "SKILL.md"), "utf8"))
|
||||
.resolves.toContain("Version two.");
|
||||
const storedPreference = await db
|
||||
.select({ adapterConfig: agents.adapterConfig })
|
||||
.from(agents)
|
||||
.where(eq(agents.id, firstAgentId))
|
||||
.then((rows) => rows[0]?.adapterConfig);
|
||||
expect(storedPreference).toMatchObject({
|
||||
paperclipSkillSync: {
|
||||
desiredSkills: [{ key: skillKey, versionId: versionOne.id }],
|
||||
},
|
||||
});
|
||||
|
||||
await settings.updateExperimental({ enableBetaSkills: true });
|
||||
const restoredRun = await heartbeat.invoke(firstAgentId, "on_demand", {}, "manual");
|
||||
expect(restoredRun).not.toBeNull();
|
||||
expect((await waitForRunToFinish(heartbeat, restoredRun!.id))?.status).toBe("succeeded");
|
||||
const restoredSkill = capturedRuns
|
||||
.filter((run) => run.agentId === firstAgentId)
|
||||
.at(-1)
|
||||
?.skills.find((entry) => entry.key === skillKey);
|
||||
expect(restoredSkill).toMatchObject({
|
||||
versionId: versionOne.id,
|
||||
currentVersionId: versionTwo.id,
|
||||
sourceStatus: "available",
|
||||
});
|
||||
await expect(fs.readFile(path.join(restoredSkill!.source, "SKILL.md"), "utf8"))
|
||||
.resolves.toContain("Version one.");
|
||||
});
|
||||
|
||||
it("delivers installed connections without exposing gateway bearers in adapter config or logs", async () => {
|
||||
|
||||
@@ -83,6 +83,7 @@ describe("instance settings routes", () => {
|
||||
enableCloudSync: false,
|
||||
enableExternalObjects: false,
|
||||
enableBuiltInAgents: false,
|
||||
enableBetaSkills: false,
|
||||
enableGoalsSidebarLink: false,
|
||||
enableServerInfoDebugView: false,
|
||||
autoRestartDevServerWhenIdle: false,
|
||||
@@ -111,6 +112,7 @@ describe("instance settings routes", () => {
|
||||
enableCloudSync: false,
|
||||
enableExternalObjects: false,
|
||||
enableBuiltInAgents: false,
|
||||
enableBetaSkills: false,
|
||||
enableGoalsSidebarLink: false,
|
||||
enableServerInfoDebugView: false,
|
||||
autoRestartDevServerWhenIdle: false,
|
||||
@@ -138,6 +140,7 @@ describe("instance settings routes", () => {
|
||||
enableCloudSync: true,
|
||||
enableExternalObjects: false,
|
||||
enableBuiltInAgents: false,
|
||||
enableBetaSkills: false,
|
||||
enableGoalsSidebarLink: false,
|
||||
enableServerInfoDebugView: false,
|
||||
autoRestartDevServerWhenIdle: false,
|
||||
@@ -232,6 +235,7 @@ describe("instance settings routes", () => {
|
||||
enableCloudSync: false,
|
||||
enableExternalObjects: false,
|
||||
enableBuiltInAgents: false,
|
||||
enableBetaSkills: false,
|
||||
enableGoalsSidebarLink: false,
|
||||
enableServerInfoDebugView: false,
|
||||
autoRestartDevServerWhenIdle: false,
|
||||
|
||||
@@ -39,6 +39,7 @@ describe("instance settings service", () => {
|
||||
enableTaskWatchdogs: true,
|
||||
enableCloudSync: true,
|
||||
enableBuiltInAgents: true,
|
||||
enableBetaSkills: false,
|
||||
enableSummaries: false,
|
||||
enableStatusCards: false,
|
||||
enableDecisions: false,
|
||||
@@ -150,6 +151,12 @@ describe("instance settings service", () => {
|
||||
expect(normalizeExperimentalSettings({ enableExternalObjects: true }).enableBuiltInAgents).toBe(false);
|
||||
});
|
||||
|
||||
it("preserves enableBetaSkills and defaults it off for legacy stored settings", () => {
|
||||
expect(normalizeExperimentalSettings(undefined).enableBetaSkills).toBe(false);
|
||||
expect(normalizeExperimentalSettings({}).enableBetaSkills).toBe(false);
|
||||
expect(normalizeExperimentalSettings({ enableBetaSkills: true }).enableBetaSkills).toBe(true);
|
||||
});
|
||||
|
||||
it("sets worktree run execution activation fields on a false to true transition", () => {
|
||||
const activatedAt = new Date("2026-07-10T12:00:00.000Z");
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ import {
|
||||
syncInstructionsBundleConfigFromFilePath,
|
||||
workspaceOperationService,
|
||||
} from "../services/index.js";
|
||||
import { conflict, forbidden, HttpError, notFound, unprocessable } from "../errors.js";
|
||||
import { badRequest, conflict, forbidden, HttpError, notFound, unprocessable } from "../errors.js";
|
||||
import { assertBoard, assertCompanyAccess, assertInstanceAdmin, buildActorSecretContext, getAccessibleResource, getActorInfo, hasCompanyAccess } from "./authz.js";
|
||||
import {
|
||||
assertNoAgentHostWorkspaceCommandMutation,
|
||||
@@ -1602,10 +1602,13 @@ export function agentRoutes(
|
||||
} = {},
|
||||
) {
|
||||
const preference = readPaperclipSkillSyncPreference(config);
|
||||
const betaSkillsEnabled = (await instanceSettings.getExperimental()).enableBetaSkills === true;
|
||||
const runtimeSkillEntries = await companySkills.listRuntimeSkillEntries(companyId, {
|
||||
materializeMissing: options.materializeMissing
|
||||
?? shouldMaterializeRuntimeSkillsForAdapter(adapterType),
|
||||
versionSelections: skillVersionSelectionMap(preference.desiredSkillEntries),
|
||||
versionSelections: skillVersionSelectionMap(preference.desiredSkillEntries, {
|
||||
versionPinsEnabled: betaSkillsEnabled,
|
||||
}),
|
||||
});
|
||||
return {
|
||||
...config,
|
||||
@@ -1629,6 +1632,13 @@ export function agentRoutes(
|
||||
};
|
||||
}
|
||||
|
||||
if (requestedDesiredSkills.some((entry) => entry.versionId !== null)) {
|
||||
const betaSkillsEnabled = (await instanceSettings.getExperimental()).enableBetaSkills === true;
|
||||
if (!betaSkillsEnabled) {
|
||||
throw badRequest("Beta skill version pins require the Beta skills experimental setting to be enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
const { resolved: resolvedRequestedSkillEntries, unresolved: unresolvedDesiredSkillKeys } =
|
||||
await companySkills.resolveRequestedSkillEntries(companyId, requestedDesiredSkills, {
|
||||
tolerateUnknownReferences: options.tolerateUnknownDesiredSkills,
|
||||
|
||||
@@ -366,6 +366,22 @@ type SkillActor = {
|
||||
userId?: string | null;
|
||||
};
|
||||
|
||||
type BundledSkillReleaseManifestEntry = {
|
||||
id: string;
|
||||
releaseName: string;
|
||||
releasedAt: string;
|
||||
notes: string;
|
||||
dir: string;
|
||||
};
|
||||
|
||||
type CreateVersionOptions = {
|
||||
fileInventory?: CompanySkillVersionFileInventoryEntry[];
|
||||
release?: { id: string; name: string; releasedAt: Date };
|
||||
updateCurrentVersion?: boolean;
|
||||
skipInventoryRefresh?: boolean;
|
||||
skill?: CompanySkill;
|
||||
};
|
||||
|
||||
type PlannedSkillReassignment = {
|
||||
agentId: string;
|
||||
reassignment: CompanySkillForkReassignment;
|
||||
@@ -886,6 +902,15 @@ function resolveBundledSkillsRoot() {
|
||||
];
|
||||
}
|
||||
|
||||
function resolveBundledSkillReleasesRoot() {
|
||||
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
||||
return [
|
||||
path.resolve(moduleDir, "../../skills-releases/paperclip"),
|
||||
path.resolve(process.cwd(), "skills-releases/paperclip"),
|
||||
path.resolve(moduleDir, "../../../skills-releases/paperclip"),
|
||||
];
|
||||
}
|
||||
|
||||
function matchesRequestedSkill(relativeSkillPath: string, requestedSkillSlug: string | null) {
|
||||
if (!requestedSkillSlug) return true;
|
||||
const skillDir = path.posix.dirname(relativeSkillPath);
|
||||
@@ -1783,6 +1808,9 @@ function toCompanySkillVersion(row: CompanySkillVersionRow): CompanySkillVersion
|
||||
return {
|
||||
...row,
|
||||
label: row.label ?? null,
|
||||
releaseId: row.releaseId ?? null,
|
||||
releaseName: row.releaseName ?? null,
|
||||
releasedAt: row.releasedAt ?? null,
|
||||
fileInventory: Array.isArray(row.fileInventory)
|
||||
? row.fileInventory.flatMap((entry) => {
|
||||
if (!isPlainRecord(entry)) return [];
|
||||
@@ -2828,6 +2856,89 @@ export function companySkillService(db: Db) {
|
||||
return [];
|
||||
}
|
||||
|
||||
async function readBundledSkillReleaseRegistry() {
|
||||
for (const registryRoot of resolveBundledSkillReleasesRoot()) {
|
||||
const manifestPath = path.join(registryRoot, "releases.json");
|
||||
const manifestText = await fs.readFile(manifestPath, "utf8").catch(() => null);
|
||||
if (!manifestText) continue;
|
||||
const parsed = JSON.parse(manifestText) as unknown;
|
||||
if (!Array.isArray(parsed)) throw new Error(`Invalid bundled skill release manifest: ${manifestPath}`);
|
||||
return parsed.map((entry): BundledSkillReleaseManifestEntry & { releaseDir: string } => {
|
||||
if (!isPlainRecord(entry)) throw new Error(`Invalid bundled skill release entry: ${manifestPath}`);
|
||||
const id = asString(entry.id);
|
||||
const releaseName = asString(entry.releaseName);
|
||||
const releasedAt = asString(entry.releasedAt);
|
||||
const notes = asString(entry.notes);
|
||||
const dir = asString(entry.dir);
|
||||
if (!id || !releaseName || !releasedAt || !notes || !dir) {
|
||||
throw new Error(`Incomplete bundled skill release entry: ${manifestPath}`);
|
||||
}
|
||||
const releaseDir = path.resolve(registryRoot, dir);
|
||||
const relativeReleaseDir = path.relative(registryRoot, releaseDir);
|
||||
if (relativeReleaseDir.startsWith("..") || path.isAbsolute(relativeReleaseDir)) {
|
||||
throw new Error(`Bundled skill release directory escapes registry root: ${dir}`);
|
||||
}
|
||||
return { id, releaseName, releasedAt, notes, dir, releaseDir };
|
||||
});
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
async function collectVersionFileInventoryFromDirectory(
|
||||
skillDir: string,
|
||||
): Promise<CompanySkillVersionFileInventoryEntry[]> {
|
||||
const inventory = await collectLocalSkillInventory(skillDir);
|
||||
return Promise.all(inventory.map(async (entry) => ({
|
||||
...entry,
|
||||
content: await fs.readFile(path.join(skillDir, entry.path), "utf8"),
|
||||
})));
|
||||
}
|
||||
|
||||
async function ensureBundledSkillReleases(companyId: string, bundledSkills: CompanySkill[]) {
|
||||
const paperclipSkill = bundledSkills.find((skill) => skill.key === "paperclipai/paperclip/paperclip");
|
||||
if (!paperclipSkill) return;
|
||||
for (const release of await readBundledSkillReleaseRegistry()) {
|
||||
const fileInventory = serializeVersionFileInventory(
|
||||
await collectVersionFileInventoryFromDirectory(release.releaseDir),
|
||||
);
|
||||
const existing = await db
|
||||
.select()
|
||||
.from(companySkillVersions)
|
||||
.where(and(
|
||||
eq(companySkillVersions.companyId, companyId),
|
||||
eq(companySkillVersions.companySkillId, paperclipSkill.id),
|
||||
eq(companySkillVersions.releaseId, release.id),
|
||||
))
|
||||
.then((rows) => rows[0] ?? null);
|
||||
if (existing) {
|
||||
const existingInventory = toCompanySkillVersion(existing).fileInventory;
|
||||
const existingHash = buildInventoryContentHash(existingInventory.map((entry) => ({
|
||||
path: entry.path,
|
||||
sha256: sha256Buffer(entry.content),
|
||||
})));
|
||||
const registryHash = buildInventoryContentHash(fileInventory.map((entry) => ({
|
||||
path: entry.path,
|
||||
sha256: sha256Buffer(entry.content),
|
||||
})));
|
||||
if (existingHash !== registryHash) {
|
||||
throw new Error(`Bundled skill release ${release.id} does not match its seeded snapshot.`);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const releasedAt = new Date(release.releasedAt);
|
||||
if (Number.isNaN(releasedAt.getTime())) {
|
||||
throw new Error(`Invalid bundled skill release date: ${release.releasedAt}`);
|
||||
}
|
||||
await createVersion(companyId, paperclipSkill.id, { label: release.releaseName }, null, {
|
||||
fileInventory,
|
||||
release: { id: release.id, name: release.releaseName, releasedAt },
|
||||
updateCurrentVersion: false,
|
||||
skipInventoryRefresh: true,
|
||||
skill: paperclipSkill,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function reconcilePaperclipSkillFolders(companyId: string) {
|
||||
const shippedSkills = await db
|
||||
.select({
|
||||
@@ -2951,7 +3062,8 @@ export function companySkillService(db: Db) {
|
||||
if (!companyExists) {
|
||||
throw notFound("Company not found");
|
||||
}
|
||||
await ensureBundledSkills(companyId);
|
||||
const bundledSkills = await ensureBundledSkills(companyId);
|
||||
await ensureBundledSkillReleases(companyId, bundledSkills);
|
||||
await reconcilePaperclipSkillFolders(companyId);
|
||||
await reconcileLocalPathSkillSources(companyId);
|
||||
})();
|
||||
@@ -3343,11 +3455,14 @@ export function companySkillService(db: Db) {
|
||||
skillId: string,
|
||||
input: CompanySkillVersionCreateRequest = {},
|
||||
actor: SkillActor | null = null,
|
||||
options: CreateVersionOptions = {},
|
||||
): Promise<CompanySkillVersion> {
|
||||
await ensureSkillInventoryCurrent(companyId);
|
||||
const skill = await getById(companyId, skillId);
|
||||
if (!options.skipInventoryRefresh) await ensureSkillInventoryCurrent(companyId);
|
||||
const skill = options.skill ?? await getById(companyId, skillId);
|
||||
if (!skill) throw notFound("Skill not found");
|
||||
const fileInventory = serializeVersionFileInventory(await collectVersionFileInventory(companyId, skill));
|
||||
const fileInventory = serializeVersionFileInventory(
|
||||
options.fileInventory ?? await collectVersionFileInventory(companyId, skill),
|
||||
);
|
||||
const versionRow = await db.transaction(async (tx) => {
|
||||
await tx.execute(sql`
|
||||
select ${companySkills.id}
|
||||
@@ -3369,6 +3484,9 @@ export function companySkillService(db: Db) {
|
||||
companySkillId: skillId,
|
||||
revisionNumber: Number(nextRevision ?? 1),
|
||||
label: input.label?.trim() || null,
|
||||
releaseId: options.release?.id ?? null,
|
||||
releaseName: options.release?.name ?? null,
|
||||
releasedAt: options.release?.releasedAt ?? null,
|
||||
fileInventory,
|
||||
authorAgentId: actor?.type === "agent" ? actor.agentId ?? null : null,
|
||||
authorUserId: actor?.type === "user" ? actor.userId ?? null : null,
|
||||
@@ -3376,10 +3494,12 @@ export function companySkillService(db: Db) {
|
||||
.returning()
|
||||
.then((rows) => rows[0] ?? null);
|
||||
if (!row) return null;
|
||||
await tx
|
||||
.update(companySkills)
|
||||
.set({ currentVersionId: row.id, updatedAt: new Date() })
|
||||
.where(and(eq(companySkills.id, skillId), eq(companySkills.companyId, companyId)));
|
||||
if (options.updateCurrentVersion !== false) {
|
||||
await tx
|
||||
.update(companySkills)
|
||||
.set({ currentVersionId: row.id, updatedAt: new Date() })
|
||||
.where(and(eq(companySkills.id, skillId), eq(companySkills.companyId, companyId)));
|
||||
}
|
||||
return row;
|
||||
});
|
||||
if (!versionRow) throw notFound("Failed to persist skill version");
|
||||
|
||||
@@ -12417,7 +12417,9 @@ export function heartbeatService(db: Db, options: HeartbeatServiceOptions = {})
|
||||
);
|
||||
const runtimeSkillPreference = readPaperclipSkillSyncPreference(effectiveResolvedConfig);
|
||||
const runtimeSkillEntries = await companySkills.listRuntimeSkillEntries(agent.companyId, {
|
||||
versionSelections: skillVersionSelectionMap(runtimeSkillPreference.desiredSkillEntries),
|
||||
versionSelections: skillVersionSelectionMap(runtimeSkillPreference.desiredSkillEntries, {
|
||||
versionPinsEnabled: resolvedInstanceSettings.experimental.enableBetaSkills === true,
|
||||
}),
|
||||
});
|
||||
let runtimeConfig: Record<string, unknown> = {
|
||||
...effectiveResolvedConfig,
|
||||
|
||||
@@ -221,6 +221,7 @@ export function normalizeExperimentalSettings(raw: unknown): InstanceExperimenta
|
||||
enableExternalObjects: parsed.data.enableExternalObjects ?? false,
|
||||
enableSmokeLab: parsed.data.enableSmokeLab ?? false,
|
||||
enableBuiltInAgents: parsed.data.enableBuiltInAgents ?? false,
|
||||
enableBetaSkills: parsed.data.enableBetaSkills ?? false,
|
||||
enableSummaries: parsed.data.enableSummaries ?? false,
|
||||
enableStatusCards: parsed.data.enableStatusCards ?? false,
|
||||
enableDecisions: parsed.data.enableDecisions ?? false,
|
||||
@@ -254,6 +255,7 @@ export function normalizeExperimentalSettings(raw: unknown): InstanceExperimenta
|
||||
enableExternalObjects: false,
|
||||
enableSmokeLab: false,
|
||||
enableBuiltInAgents: false,
|
||||
enableBetaSkills: false,
|
||||
enableSummaries: false,
|
||||
enableStatusCards: false,
|
||||
enableDecisions: false,
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
export function skillVersionSelectionMap(entries: Array<{ key: string; versionId: string | null }>) {
|
||||
return new Map(entries.map((entry) => [entry.key, entry.versionId] as const));
|
||||
export function skillVersionSelectionMap(
|
||||
entries: Array<{ key: string; versionId: string | null }>,
|
||||
options: { versionPinsEnabled?: boolean } = {},
|
||||
) {
|
||||
const versionPinsEnabled = options.versionPinsEnabled ?? true;
|
||||
return new Map(entries.map((entry) => [entry.key, versionPinsEnabled ? entry.versionId : null] as const));
|
||||
}
|
||||
Reference in new issue
Block a user