mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-03 01:27:09 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Agents use installed skills and exact version pins during execution. > - Managed skills still depended on mutable directories on the web server. > - A replacement server could lose acknowledged edits or remove an unassigned skill whose directory was absent. > - This pull request makes immutable versions the authority for managed content and installed repository reads. > - The server can rebuild delivery files from durable content after replacement. > - This establishes skills readiness for ephemeral web servers. General server draining and workspace recovery remain separate work. ## Linked Issues or Issue Description **Subsystem affected** Skills services, shared contracts, database receipts, Skill Studio, and runtime delivery. **Problem or motivation** A fresh web server must discover, read, edit, and deliver protected installed skills using the same database, object storage, secrets, and supported application artifacts. It must not need its predecessor's files or process memory. **Proposed solution** Use `managed` ownership with a null source locator. Read installed content by immutable version. Prepare packages before a short publication transaction. Persist execution selections before materialization. Recover exact pinned runtime assets and reject deletion while active or recovering pins exist. **Alternatives considered** Reconstructing a mutable installed directory preserves the old source-of-truth ambiguity. Permanent dual writes create two competing authorities. This change uses one managed model after a bounded legacy conversion. **Roadmap alignment** This improves the existing Skills Manager, Studio, version history, and Cloud execution capabilities. The maintainer supplied the implementation contract. This does not add a separate skills product or deploy fleet changes. Related work: #18082 supplies immutable package storage. #17273 addresses edits outside the API for linked local skills; this PR keeps that source category separate. #2648 is a closed earlier ephemeral-filesystem proposal. ## What Changed - Add managed ownership and focused content publication and execution materialization modules. Keep the archive format and package storage tables. - Publish managed create, save, delete, fork, rename, restore, and catalog content with version checks. Add durable create receipts. Preserve file-save receipt responses. - Return file version identities. Keep Studio drafts after a conflict and provide an explicit reload action. A delayed reload cannot overwrite newer typing or navigation. - Persist exact runtime selections, including empty selections. Rebuild pinned assets and verify their admitted digests on a replacement server. - Preserve source access on forks and disconnected copies. Keep the existing workspace policy category for managed skills. - Add bounded conversion, eligibility, and independent verification phases. Load persisted Cloud configuration in the standalone CLI without seeding or changing it. Reject partial current versions against installed inventories; recover only complete saved content or the exact source. Document storage migration blockers and the compatible rollback floor. - Add separate-process PostgreSQL/S3 qualification and update domain, retention, policy, and UI regressions. - Pass the plugin worker manager into Studio execution, admit restricted `skill_test` mode through native Runner contracts, and preserve admitted scope across native and REST tools. Native tests cannot create ordinary tasks, browse company data, or use external tools. - Select the exact durable Studio revision even when unassigned or Beta skills is off. Persist Studio output and audit atomically with native task completion, preserving the result on replay. ## Verification - Final revision `13e8af480b88ba6fea5737bac4bd81104d604792` passed full CI: all 49 workflow jobs completed successfully ([run 41127396098](https://github.com/paperclipai/paperclip/actions/runs/41127396098)). This includes typecheck, test suites, Runner checks, browser checks and build. Greptile review 15 is 5/5 on that same revision, with zero unresolved threads. The PR is ready for review. - Local workspace typecheck and build passed after integrating master. Focused checks passed: 33 execution/completion cases, 52 Runner HTTP cases, 16 managed-content cases, 17 Studio cases, the new real-process CLI regression, map checks and UI token gates. The CLI regression proves inspection does not seed missing Cloud configuration. Server typecheck passed after that fix. - The independent-process PostgreSQL/S3 matrix passed through normal HTTP skill routes. It covers A → B → C replacement, lost commit responses, upload crashes, concurrent saves, binary contents and executable delivery. Metadata listing and warm selected delivery retain zero object downloads. Local timing measurements are recorded; they do not establish hosted latency. - Hosted A → B → C passed on the owned disposable test tenant with external Postgres, S3 and a real remote Paperclip Computer. Predecessor temporary homes were absent. C read and executed B's acknowledged managed save. New runs used repository v1 while v2 was installed. Hashes matched an independently checked exact upstream commit. - Compatible image rollback to `6518b323` passed. Studio retained the unassigned fork's C save. A fresh remote run executed the newer managed content and historical repository pin. The actual shell event confirmed expected hashes, stdout, exit 0 and mode 0555. - Runtime candidate `9200e3fcb4` deployed successfully ([Cloud run 41124147876](https://github.com/paperclipai/paperclip-cloud/actions/runs/41124147876)). The final Studio test delivered only the unassigned fork's exact v3, executed its script and persisted a successful output snapshot. Independent command-event inspection confirmed all three hashes, stdout, exit 0 and mode 0555. All 14 installations were version-backed. Independent verification checked all 25 versions: 23 remote objects, two bundled database snapshots, zero blockers. - The deployed image is `9200e3fcb4`. Later master integration, the client-only delayed-reload draft guard and the CLI bootstrap have separate automated proof. The CLI bootstrap was also exercised against the tenant's stored configuration and storage through the same read-only services. This PR does not claim that the deployed image is the final PR revision. - Live Studio checks exposed worker wiring, admission, access scope, exact selection and completion-publication gaps. They are fixed. Failed attempts remain in the evidence. The full local suite exceeded 80 minutes under host contention and was stopped. Later combined/isolated local attempts also timed out; they are not counted as passes. Full CI covers the integrated suites. Earlier CI found an obsolete restart-scope fixture, which was corrected and passed all 52 HTTP cases. - Reproduction and migration: [`doc/skill-ephemeral-web-servers.md`](doc/skill-ephemeral-web-servers.md). Source revisions, deployments, versions, run IDs, hashes and failure history: [`doc/plans/2026-10-30-ephemeral-web-skills.md`](doc/plans/2026-10-30-ephemeral-web-skills.md). ## Risks - Legacy conversion requires stopped admission and retired filesystem-authoritative writers. Pre-conversion binaries are not supported rollback targets afterward. - Cloud readiness requires remote object storage. Local provider receipts and provider mismatches remain blockers until objects are copied and verified. - Linked local sources retain filesystem semantics and are outside the cloud guarantee. - Cold reads still fetch the existing archive format. Warm runtime preparation retains the verified-cache path. - Bundled reconciliation preserves an installed head. Existing release snapshots remain selectable. An older server must not replace a newer head with its shipped files. - No production volumes, fleet defaults, or general deployment coordination change in this PR. ## Model Used OpenAI Codex, GPT-6 family, with reasoning, repository tools, code execution, and browser use. The exact backend model ID and context-window size are not exposed in this session. No subagents were used. ## 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 - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [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>
195 lines
17 KiB
TypeScript
195 lines
17 KiB
TypeScript
import { createHash, randomUUID } from "node:crypto";
|
|
import fs from "node:fs/promises";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { and, eq } from "drizzle-orm";
|
|
import { agents, companies, companySkills, createDb, environments, pluginCompanySettings, plugins, resourceLifecycleEvents, type Db } from "@paperclipai/db";
|
|
import type { PaperclipPluginManifestV1 } from "@paperclipai/shared";
|
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { getEmbeddedPostgresTestSupport, startEmbeddedPostgresTestDatabase } from "./helpers/embedded-postgres.js";
|
|
import { environmentSkillConfig } from "../services/environment-skills.js";
|
|
import { pluginAgentRuntimeState } from "../services/plugin-agent-runtime-state.js";
|
|
import { companySkillService } from "../services/company-skills.js";
|
|
import { instanceSettingsService } from "../services/instance-settings.js";
|
|
import { withSkillActor } from "../services/skill-access.js";
|
|
import { buildNativeRuntimeContext } from "../services/native-runtime/runtime-context.js";
|
|
|
|
const support = await getEmbeddedPostgresTestSupport();
|
|
const describeDatabase = support.supported ? describe : describe.skip;
|
|
describeDatabase("environment managed skills", () => {
|
|
let database: Awaited<ReturnType<typeof startEmbeddedPostgresTestDatabase>>;
|
|
let db: Db;
|
|
let home: string;
|
|
let companyId: string;
|
|
let pluginId: string;
|
|
let manifest: PaperclipPluginManifestV1;
|
|
let environment: { driver: string; config: Record<string, unknown> };
|
|
beforeAll(async () => {
|
|
database = await startEmbeddedPostgresTestDatabase("paperclip-environment-skills-"); db = createDb(database.connectionString);
|
|
home = await fs.mkdtemp(path.join(os.tmpdir(), "paperclip-environment-skills-"));
|
|
}, 90_000);
|
|
afterAll(async () => { await database?.cleanup(); if (home) {
|
|
const release = async (directory: string): Promise<void> => {
|
|
await fs.chmod(directory, 0o700);
|
|
for (const entry of await fs.readdir(directory, { withFileTypes: true })) if (entry.isDirectory()) await release(path.join(directory, entry.name));
|
|
};
|
|
await release(home); await fs.rm(home, { recursive: true, force: true });
|
|
} });
|
|
afterEach(() => vi.unstubAllEnvs());
|
|
beforeEach(async () => {
|
|
vi.stubEnv("PAPERCLIP_HOME", home);
|
|
companyId = randomUUID(); pluginId = randomUUID();
|
|
manifest = { id: `fixture.${pluginId}`, apiVersion: 1, version: "1.0.0", displayName: "Desktop", description: "Fixture", author: "Tests", categories: ["automation"],
|
|
capabilities: ["environment.drivers.register", "skills.managed", "agents.lifecycle.manage", "events.subscribe"],
|
|
resourceLifecycle: ["agent_runtime"], entrypoints: { worker: "worker.js" },
|
|
environmentDrivers: [{ driverKey: "desktop", displayName: "Desktop", skillKeys: ["computer-use"], configSchema: {} }],
|
|
skills: [{ skillKey: "computer-use", displayName: "Computer use", slug: "computer-use",
|
|
markdown: "---\nname: computer-use\ndescription: Use the installed desktop tools.\n---\n\nRead references/linux.md.",
|
|
files: [{ path: "references/linux.md", content: "Use the installed cua-driver." }] }] };
|
|
await db.insert(companies).values({ id: companyId, name: "Environment skills", issuePrefix: `E${companyId.slice(0, 6)}` });
|
|
await db.insert(plugins).values({ id: pluginId, pluginKey: manifest.id, packageName: "fixture", version: "1.0.0", status: "ready", manifestJson: manifest });
|
|
environment = { driver: "plugin", config: { pluginKey: manifest.id, driverKey: "desktop", driverConfig: {} } };
|
|
});
|
|
it("installs the company skill and delivers its versioned files through runtime sync and the native snapshot", async () => {
|
|
const config = { paperclipSkillSync: { desiredSkills: [] } };
|
|
const [selection, concurrent] = await Promise.all([environmentSkillConfig(db, companyId, environment, config), environmentSkillConfig(db, companyId, environment, config)]);
|
|
expect(concurrent).toEqual(selection);
|
|
const selected = selection.config;
|
|
const [skill] = await db.select().from(companySkills).where(and(eq(companySkills.companyId, companyId), eq(companySkills.key, `plugin/fixture-${pluginId}/computer-use`)));
|
|
expect(selected).toMatchObject({ paperclipSkillSync: { desiredSkills: [skill.key] } });
|
|
expect(config.paperclipSkillSync.desiredSkills).toEqual([]);
|
|
const [env] = await db.insert(environments).values({ name: "Desktop", ...environment }).returning();
|
|
const [agent] = await db.insert(agents).values({ companyId, name: "Worker", adapterType: "paperclip_runner", defaultEnvironmentId: env.id,
|
|
lifecycleRequiredPluginIds: [pluginId], adapterConfig: config }).returning();
|
|
const state = await pluginAgentRuntimeState(db, pluginId, companyId, agent.id);
|
|
expect(state!.skills).toEqual([expect.objectContaining({ key: skill.key, runtimeName: expect.stringMatching(/^plugin-.*-computer-use--/), versionId: expect.any(String) })]);
|
|
await withSkillActor({ type: "agent", agentId: agent.id, companyId, source: "agent_key" }, async () => {
|
|
await companySkillService(db).withRuntimeSkillEntries(companyId, { selectionConfig: selected, snapshotLatest: true }, async entries => {
|
|
const context = await buildNativeRuntimeContext({ db, agent, runId: randomUUID(), runtimeConfig: selected, runtimeSkillEntries: entries });
|
|
expect(context.skills).toEqual([expect.objectContaining({ key: skill.key, runtimeName: state!.skills[0].runtimeName, versionId: state!.skills[0].versionId })]);
|
|
expect(await fs.readFile(path.join(context.skills[0].bundle.rootPath, "references/linux.md"), "utf8")).toContain("cua-driver");
|
|
});
|
|
});
|
|
await db.update(agents).set({ defaultEnvironmentId: null }).where(eq(agents.id, agent.id));
|
|
await instanceSettingsService(db).update({ defaultEnvironmentId: env.id });
|
|
expect((await pluginAgentRuntimeState(db, pluginId, companyId, agent.id))!.skills).toEqual(state!.skills);
|
|
await instanceSettingsService(db).update({ defaultEnvironmentId: null });
|
|
expect((await pluginAgentRuntimeState(db, pluginId, companyId, agent.id))!.skills).toEqual([]);
|
|
expect((await pluginAgentRuntimeState(db, pluginId, companyId, agent.id, env.id))!.skills).toEqual(state!.skills);
|
|
await expect(pluginAgentRuntimeState(db, pluginId, companyId, agent.id, randomUUID())).rejects.toMatchObject({ status: 422 });
|
|
const invalidSkill = { skillKey: "new-invalid", displayName: "New invalid skill", markdown: "---\nname: new-invalid\nmetadata:\n sources:\n - kind: github-dir\n repo: fixture/skills\n---\nUnpinned." };
|
|
const changedManifest = { ...manifest, skills: [...manifest.skills!, invalidSkill], environmentDrivers: manifest.environmentDrivers!.map(driver => ({ ...driver, skillKeys: [...driver.skillKeys!, "new-invalid"] })) };
|
|
await db.update(plugins).set({ manifestJson: changedManifest }).where(eq(plugins.id, pluginId));
|
|
expect((await pluginAgentRuntimeState(db, pluginId, companyId, agent.id, env.id))!.skills).toEqual(state!.skills);
|
|
await expect(environmentSkillConfig(db, companyId, environment, config)).rejects.toThrow(/pinned Git commit/);
|
|
await db.update(plugins).set({ manifestJson: manifest }).where(eq(plugins.id, pluginId));
|
|
const pinned = { paperclipSkillSync: { desiredSkills: [{ key: skill.key, versionId: state!.skills[0].versionId }] } };
|
|
expect((await environmentSkillConfig(db, companyId, environment, pinned)).config).toEqual(pinned);
|
|
await db.update(companySkills).set({ markdown: "Agent customization" }).where(eq(companySkills.id, skill.id));
|
|
await environmentSkillConfig(db, companyId, environment, config);
|
|
expect((await db.select().from(companySkills).where(eq(companySkills.id, skill.id)))[0].markdown).toBe("Agent customization");
|
|
});
|
|
it("installs and refreshes environment skills through lifecycle reconciliation before any run", async () => {
|
|
const [env] = await db.insert(environments).values({ name: randomUUID(), ...environment }).returning();
|
|
const [agent] = await db.insert(agents).values({ companyId, name: "Background worker", adapterType: "paperclip_runner", defaultEnvironmentId: env.id,
|
|
lifecycleRequiredPluginIds: [pluginId], adapterConfig: { paperclipSkillSync: { desiredSkills: [] } } }).returning();
|
|
expect((await pluginAgentRuntimeState(db, pluginId, companyId, agent.id))!.skills).toEqual([]);
|
|
const states = await Promise.all([1, 2].map(() => pluginAgentRuntimeState(db, pluginId, companyId, agent.id, undefined, true)));
|
|
expect(states[0]!.skills).toEqual(states[1]!.skills);
|
|
const [skill] = await db.select().from(companySkills).where(and(eq(companySkills.companyId, companyId), eq(companySkills.key, `plugin/fixture-${pluginId}/computer-use`)));
|
|
expect(skill.slug).toMatch(/^plugin-.*-computer-use$/);
|
|
const runtime = states[0]!.skills[0];
|
|
expect(await fs.readFile(path.join(runtime.source, "SKILL.md"), "utf8")).toContain(`name: "${skill.slug}"`);
|
|
const events = () => db.select().from(resourceLifecycleEvents).where(and(eq(resourceLifecycleEvents.companyId, companyId), eq(resourceLifecycleEvents.resourceType, "agent_runtime")));
|
|
const before = (await events()).length;
|
|
const edited = skill.markdown + "\nCompany edit.";
|
|
await companySkillService(db).updateFile(companyId, skill.id, "SKILL.md", edited);
|
|
expect((await events()).slice(before).map(event => event.resourceId)).toEqual([agent.id]);
|
|
const refreshed = (await pluginAgentRuntimeState(db, pluginId, companyId, agent.id, undefined, true))!.skills[0];
|
|
expect(refreshed.versionId).not.toBe(runtime.versionId);
|
|
expect(await fs.readFile(path.join(refreshed.source, "SKILL.md"), "utf8")).toContain("Company edit.");
|
|
const settled = (await events()).length;
|
|
await pluginAgentRuntimeState(db, pluginId, companyId, agent.id, undefined, true);
|
|
expect(await events()).toHaveLength(settled);
|
|
const changedManifest = { ...manifest, skills: [...manifest.skills!, { skillKey: "extra", displayName: "Extra" }],
|
|
environmentDrivers: manifest.environmentDrivers!.map(driver => ({ ...driver, skillKeys: [...driver.skillKeys!, "extra"] })) };
|
|
await db.update(plugins).set({ manifestJson: changedManifest }).where(eq(plugins.id, pluginId));
|
|
expect((await events()).slice(settled).map(event => event.resourceId)).toEqual([agent.id]);
|
|
expect((await pluginAgentRuntimeState(db, pluginId, companyId, agent.id, undefined, true))!.skills).toHaveLength(2);
|
|
const saved = await db.select().from(agents).where(eq(agents.id, agent.id));
|
|
expect(saved[0].adapterConfig).toEqual(agent.adapterConfig);
|
|
await db.delete(companySkills).where(eq(companySkills.id, skill.id));
|
|
expect((await pluginAgentRuntimeState(db, pluginId, companyId, agent.id, undefined, true))!.skills).toHaveLength(2);
|
|
});
|
|
it("queues background delivery for inherited defaults and changed environment requirements", async () => {
|
|
const [env] = await db.insert(environments).values({ name: randomUUID(), ...environment }).returning();
|
|
const [agent] = await db.insert(agents).values({ companyId, name: "Inherited worker", adapterType: "paperclip_runner", lifecycleRequiredPluginIds: [pluginId] }).returning();
|
|
const events = () => db.select().from(resourceLifecycleEvents).where(and(eq(resourceLifecycleEvents.companyId, companyId), eq(resourceLifecycleEvents.resourceType, "agent_runtime")));
|
|
let before = (await events()).length;
|
|
await instanceSettingsService(db).update({ defaultEnvironmentId: env.id });
|
|
expect((await events()).slice(before).map(event => event.resourceId)).toEqual([agent.id]);
|
|
await pluginAgentRuntimeState(db, pluginId, companyId, agent.id, undefined, true);
|
|
before = (await events()).length;
|
|
const [settings] = await db.insert(pluginCompanySettings).values({ companyId, pluginId, enabled: true }).returning();
|
|
for (let change = 0; change < 3; change++) {
|
|
await db.update(pluginCompanySettings).set({ settingsJson: { localFolders: { path: `fixture-${change}` } } }).where(eq(pluginCompanySettings.id, settings.id));
|
|
}
|
|
expect(await events()).toHaveLength(before);
|
|
await db.update(pluginCompanySettings).set({ enabled: false }).where(eq(pluginCompanySettings.id, settings.id));
|
|
expect((await events()).slice(before).map(event => event.resourceId)).toEqual([agent.id]);
|
|
await db.update(pluginCompanySettings).set({ enabled: true }).where(eq(pluginCompanySettings.id, settings.id));
|
|
expect((await events()).slice(before).map(event => event.resourceId)).toEqual([agent.id, agent.id]);
|
|
before = (await events()).length;
|
|
await db.delete(pluginCompanySettings).where(eq(pluginCompanySettings.id, settings.id));
|
|
expect(await events()).toHaveLength(before);
|
|
await expect(db.transaction(async tx => {
|
|
await tx.update(environments).set({ config: { ...environment.config, driverKey: "unrelated" } }).where(eq(environments.id, env.id));
|
|
throw new Error("rollback");
|
|
})).rejects.toThrow("rollback");
|
|
expect(await events()).toHaveLength(before);
|
|
await db.update(environments).set({ config: { ...environment.config, driverKey: "unrelated" } }).where(eq(environments.id, env.id));
|
|
expect((await events()).slice(before).map(event => event.resourceId)).toEqual([agent.id]);
|
|
expect((await pluginAgentRuntimeState(db, pluginId, companyId, agent.id, undefined, true))!.skills).toEqual([]);
|
|
before = (await events()).length;
|
|
await instanceSettingsService(db).update({ defaultEnvironmentId: null });
|
|
expect((await events()).slice(before).map(event => event.resourceId)).toEqual([agent.id]);
|
|
});
|
|
it("delivers the required plugin skill and reports a same-name company assignment as shadowed", async () => {
|
|
const name = `plugin-${pluginId}-computer-use`;
|
|
const original = await companySkillService(db).createLocalSkill(companyId, { name, markdown: `---\nname: ${name}\n---\nCompany instructions.\n` });
|
|
const config = { paperclipSkillSync: { desiredSkills: [original.key] } };
|
|
const [env] = await db.insert(environments).values({ name: randomUUID(), ...environment }).returning();
|
|
const [agent] = await db.insert(agents).values({ companyId, name: "Conflicting worker", adapterType: "paperclip_runner", defaultEnvironmentId: env.id,
|
|
lifecycleRequiredPluginIds: [pluginId], adapterConfig: config }).returning();
|
|
const state = await pluginAgentRuntimeState(db, pluginId, companyId, agent.id, undefined, true);
|
|
const key = `plugin/fixture-${pluginId}/computer-use`;
|
|
expect(state!.skills.map(skill => skill.key)).toEqual([key]);
|
|
expect(state!.shadowedSkills).toEqual([{ key: original.key, shadowedBy: key }]);
|
|
for (const reference of [name, original.key.toUpperCase(), `${name}--${createHash("sha256").update(original.key).digest("hex").slice(0, 10)}`]) {
|
|
const aliased = await environmentSkillConfig(db, companyId, environment, { paperclipSkillSync: { desiredSkills: [reference] } });
|
|
expect(aliased.config).toMatchObject({ paperclipSkillSync: { desiredSkills: [key] } });
|
|
expect(aliased.shadowedSkills).toEqual(state!.shadowedSkills);
|
|
}
|
|
expect((await db.select().from(companySkills).where(eq(companySkills.id, original.id)))[0]).toMatchObject({ markdown: original.markdown, slug: original.slug });
|
|
expect((await db.select().from(agents).where(eq(agents.id, agent.id)))[0].adapterConfig).toEqual(config);
|
|
await db.update(agents).set({ defaultEnvironmentId: null }).where(eq(agents.id, agent.id));
|
|
const restored = await pluginAgentRuntimeState(db, pluginId, companyId, agent.id, undefined, true);
|
|
expect(restored!.skills.map(skill => skill.key)).toEqual([original.key]);
|
|
expect(restored!.shadowedSkills).toBeUndefined();
|
|
});
|
|
it("keeps installations company-scoped and rejects disabled providers", async () => {
|
|
const peerId = randomUUID();
|
|
await db.insert(companies).values({ id: peerId, name: "Peer", issuePrefix: `P${peerId.slice(0, 6)}` });
|
|
await environmentSkillConfig(db, companyId, environment, {});
|
|
await environmentSkillConfig(db, peerId, environment, {});
|
|
const peerSkills = await db.select().from(companySkills).where(and(eq(companySkills.companyId, peerId), eq(companySkills.key, `plugin/fixture-${pluginId}/computer-use`)));
|
|
expect(peerSkills).toHaveLength(1);
|
|
const skills = await db.select().from(companySkills).where(and(eq(companySkills.companyId, companyId), eq(companySkills.key, `plugin/fixture-${pluginId}/computer-use`)));
|
|
expect(peerSkills[0].id).not.toBe(skills[0].id);
|
|
await db.insert(pluginCompanySettings).values({ companyId, pluginId, enabled: false });
|
|
await expect(environmentSkillConfig(db, companyId, environment, {})).rejects.toMatchObject({ status: 422 });
|
|
expect(await environmentSkillConfig(db, companyId, { driver: "local", config: null }, {})).toEqual({ config: {}, skillKeys: [] });
|
|
expect(await environmentSkillConfig(db, companyId, { ...environment, config: { ...environment.config, driverKey: "unrelated" } }, {})).toEqual({ config: {}, skillKeys: [] });
|
|
});
|
|
});
|