mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-08 01:57:31 +01:00
## Thinking Path > - Paperclip manages AI agents and their execution environments. > - Managed installations supply a default sandbox through managed configuration. > - Most selectors show the configured environment name. > - A fallback label, two errors, and examples still use Paperclip Computer. > - This pull request changes that stock copy to Paperclip Sandbox. > - Existing and custom environment names continue to come from the stored row. ## Linked Issues or Issue Description **What existing behavior does this improve?** The managed environment label in agent settings and the errors shown when the managed sandbox is unavailable. **Subsystem affected** The agent configuration UI, runner selection, and environment reconciliation tests. **Current behavior** Fallback copy and current examples call the managed sandbox Paperclip Computer. The actual environment name is already configurable. **Proposed behavior** Use Paperclip Sandbox for stock copy and current examples. Keep configured names unchanged in selectors, including legacy names and custom names. **Reason and benefit** The name identifies this environment as a managed sandbox and removes ambiguity. **Breaking changes** The displayed fallback and error text change. Error codes, execution behavior, and environment identity remain the same. No migration is needed. **Additional context** No duplicate rename issue or pull request was found. This is a copy update, with no new roadmap feature. ## What Changed - Update the managed fallback label and two unavailable-sandbox error messages. - Update current test and Storybook fixtures without changing story IDs or behavior. - Test configured names, fallback copy, and the unavailable-sandbox message. - Add a PostgreSQL regression test for a rename that retains the environment ID, instance default, agent binding, environment variables, and lease. ## Verification - `pnpm -r typecheck` passed. - `pnpm build` passed. - Focused coverage: 956 cases across nine changed suites. The new fixture initially tried to insert an existing singleton; its corrected upsert passed with all 52 environment-service cases. The updated runner suite also passed all 243 cases. - The two UI suites passed all 189 cases, including configured legacy/custom names and the missing-default fallback. - `pnpm check:token-gates` passed. - `node scripts/storybook-catalog.mjs --check` passed. The catalog is structural evidence only. - `node --test scripts/check-maps.test.mjs scripts/storybook-catalog.test.mjs scripts/storybook-feature-index.test.mjs` passed. - Full `pnpm test:run` is in progress. No live provider or browser journey is claimed by these tests. - CI passed on the current head after one server-shard rerun. The first attempt hit a 10 ms deadline assertion in the unchanged status-card timing test; its isolated local run and the complete rerun shard passed. The original failure and rerun are retained in the PR comment. - Reviewed the diff for secrets, personal data, and run artifacts. ## Risks Low risk: runtime edits change three display strings. Managed reconciliation is unchanged. The regression test exercises the existing rename against PostgreSQL. The configured name still controls normal display, so this code change alone does not rename existing database rows. A managed configuration update uses the existing reconciliation path. Roll back the copy by reverting this commit. ## Model Used OpenAI GPT-6.1 Sol (`gpt-6.1-sol`) through Codex in T3 Code, xhigh reasoning, with repository tools and code execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used, version, and capabilities - [x] I have checked ROADMAP.md; this copy update does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs - [x] I have described the issue in the PR with the enhancement template fields - [x] No internal or instance-local issue references - [x] The branch name describes the change and contains no internal ticket ID - [x] Focused tests pass locally - [x] Relevant tests were added or updated - [x] Relevant copy and examples were updated; no API or schema documentation changed - [x] Risks are documented - [x] All CI gates passed on the current head, including the server 11/12 rerun and aggregate verify - [ ] Full local test suite completed (still running; six chat shards passed) - [x] Greptile is 5/5 on the current head with no unresolved findings - [x] I will address all reviewer comments before requesting merge Co-authored-by: Paperclip <noreply@paperclip.ing>
145 lines
11 KiB
TypeScript
145 lines
11 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import * as executionTargets from "@paperclipai/adapter-utils/execution-target";
|
|
import type { AdapterEnvironmentTestContext } from "@paperclipai/adapter-utils";
|
|
import type { AdapterEnvironmentTestResult } from "@paperclipai/shared";
|
|
import type { Db } from "@paperclipai/db";
|
|
|
|
const { runtimeProbe, claudeProbe, verifyKey, markAuthFailed } = vi.hoisted(() => ({
|
|
runtimeProbe: vi.fn(), claudeProbe: vi.fn(), verifyKey: vi.fn(), markAuthFailed: vi.fn(),
|
|
}));
|
|
vi.mock("../adapters/index.js", () => ({ requireServerAdapter: (type: string) => ({ testEnvironment: type === "paperclip_runner" ? runtimeProbe : claudeProbe }) }));
|
|
vi.mock("./ai-api-key-test.js", () => ({ validateAiApiKey: verifyKey }));
|
|
vi.mock("./ai-connections.js", async original => ({ ...await original<typeof import("./ai-connections.js")>(), aiConnectionService: () => ({ markAuthenticationFailed: markAuthFailed }) }));
|
|
import { agentEnvironmentTestService } from "./agent-environment-test.js";
|
|
|
|
const checkedAt = new Date(0).toISOString();
|
|
function readiness(): AdapterEnvironmentTestResult {
|
|
return { adapterType: "paperclip_runner", status: "warn", testedAt: checkedAt, checks: [{
|
|
code: "acpx_remote_runtime_unverified", level: "warn", message: "The remote platform is supported. Runtime package integrity and readiness must still be verified by the remote runner before launch.",
|
|
}] };
|
|
}
|
|
const context: AdapterEnvironmentTestContext = { companyId: "company-1", adapterType: "paperclip_runner", environmentName: "Paperclip Sandbox",
|
|
config: { provider: "acpx", acpxAgent: "claude", model: "claude-opus-5-5", env: { CLAUDE_CODE_OAUTH_TOKEN: "fixture-token" }, managedAiConnection: { method: "subscription" } },
|
|
executionTarget: { kind: "remote" as const, transport: "sandbox" as const, providerKey: "daytona", leaseId: "lease-1", remoteCwd: "/workspace", runner: { execute: vi.fn().mockResolvedValue({ exitCode: 0, timedOut: false, stdout: "", stderr: "", signal: null }) } },
|
|
};
|
|
async function testConnection(overrides: Partial<AdapterEnvironmentTestContext> = {}) {
|
|
const service = agentEnvironmentTestService({} as Db);
|
|
return service.testManagedEnvironment("paperclip_runner", { ...context, ...overrides },
|
|
{ provider: "anthropic", method: "subscription", mode: "responsible_user" },
|
|
{ identity: "fixture-identity", attribution: { provider: "anthropic", connectionId: "connection-1", grantId: "grant-1" } } as Parameters<typeof service.testManagedEnvironment>[3]);
|
|
}
|
|
afterEach(() => { vi.unstubAllEnvs(); vi.clearAllMocks(); vi.restoreAllMocks(); });
|
|
function verifiedClaude() {
|
|
runtimeProbe.mockResolvedValue(readiness());
|
|
claudeProbe.mockResolvedValue({ adapterType: "claude_local", status: "pass", testedAt: checkedAt,
|
|
checks: [{ code: "claude_hello_probe_passed", level: "info", message: "Claude hello probe succeeded." }] });
|
|
}
|
|
|
|
describe("managed Runner connection test status", () => {
|
|
it("projects the selected Google home for background verification and rejects a conflicting explicit home", async () => {
|
|
const service = agentEnvironmentTestService({} as Db);
|
|
const input = { companyId: "company-1", adapterType: "paperclip_runner", executionTarget: null,
|
|
config: { provider: "acpx", acpxAgent: "antigravity", model: "exact-google-model", env: {}, managedAiConnection: { method: "subscription" } } };
|
|
const binding = { provider: "google", method: "subscription", mode: "responsible_user" } as const;
|
|
const managed = { home: "/private/selected-google", identity: "fixture-identity",
|
|
attribution: { provider: "google", connectionId: "connection-1", grantId: "grant-1" } } as Parameters<typeof service.testManagedEnvironment>[3];
|
|
runtimeProbe.mockResolvedValue({ adapterType: "paperclip_runner", status: "pass", testedAt: checkedAt,
|
|
checks: [{ code: "antigravity_metadata_verified", level: "info", message: "Native account and model accepted." }] });
|
|
expect((await service.testManagedEnvironment("paperclip_runner", input, binding, managed)).status).toBe("pass");
|
|
expect(runtimeProbe).toHaveBeenCalledExactlyOnceWith(expect.objectContaining({ managedAiCredentialHome: "/private/selected-google/provider" }));
|
|
runtimeProbe.mockClear();
|
|
await expect(service.testManagedEnvironment("paperclip_runner", { ...input, managedAiCredentialHome: "/private/other-google/provider" }, binding, managed))
|
|
.rejects.toThrow("does not match the selected managed account");
|
|
expect(runtimeProbe).not.toHaveBeenCalled();
|
|
expect(claudeProbe).not.toHaveBeenCalled();
|
|
});
|
|
it("accepts only the Antigravity native admission receipt without invoking another provider", async () => {
|
|
const service = agentEnvironmentTestService({} as Db);
|
|
const input = { companyId: "company-1", adapterType: "paperclip_runner", executionTarget: null,
|
|
config: { provider: "acpx", acpxAgent: "antigravity", model: "exact-google-model", env: {}, managedAiConnection: { method: "subscription" } } };
|
|
const binding = { provider: "google", method: "subscription", mode: "responsible_user" } as const;
|
|
const managed = { identity: "fixture-identity", attribution: { provider: "google", connectionId: "connection-1", grantId: "grant-1" } } as Parameters<typeof service.testManagedEnvironment>[3];
|
|
runtimeProbe.mockResolvedValue({ adapterType: "paperclip_runner", status: "pass", testedAt: checkedAt,
|
|
checks: [{ code: "antigravity_metadata_verified", level: "info", message: "Native account and model accepted." }] });
|
|
expect((await service.testManagedEnvironment("paperclip_runner", input, binding, managed)).status).toBe("pass");
|
|
expect(claudeProbe).not.toHaveBeenCalled();
|
|
expect(verifyKey).not.toHaveBeenCalled();
|
|
runtimeProbe.mockResolvedValue({ adapterType: "paperclip_runner", status: "pass", testedAt: checkedAt, checks: [] });
|
|
const missing = await service.testManagedEnvironment("paperclip_runner", input, binding, managed);
|
|
expect(missing.status).toBe("fail");
|
|
expect(missing.checks).toContainEqual(expect.objectContaining({ code: "ai_connection_validation_incomplete" }));
|
|
expect(claudeProbe).not.toHaveBeenCalled();
|
|
});
|
|
it("passes a healthy Cloud Claude connection without asking the user to verify launch-time runtime preparation", async () => {
|
|
vi.stubEnv("PAPERCLIP_CLOUD_TENANT_SERVER_TOKEN", "managed-fixture");
|
|
verifiedClaude();
|
|
const result = await testConnection();
|
|
expect(result.status).toBe("pass");
|
|
expect(result.checks).toContainEqual(expect.objectContaining({ code: "claude_hello_probe_passed" }));
|
|
expect(result.checks).toContainEqual(expect.objectContaining({ code: "acpx_remote_runtime_managed", level: "info" }));
|
|
expect(claudeProbe).toHaveBeenCalledWith(expect.objectContaining({ executionTarget: context.executionTarget, config: expect.objectContaining({ engine: "cli" }) }));
|
|
});
|
|
it("keeps remote runtime readiness warnings for self-hosted connections", async () => {
|
|
vi.stubEnv("PAPERCLIP_CLOUD_TENANT_SERVER_TOKEN", ""); vi.stubEnv("PAPERCLIP_MANAGED_CONFIG", undefined);
|
|
verifiedClaude();
|
|
const result = await testConnection();
|
|
expect(result.status).toBe("warn");
|
|
expect(result.checks).toContainEqual(expect.objectContaining({ code: "acpx_remote_runtime_unverified", level: "warn" }));
|
|
});
|
|
it("does not turn a failed hello into a successful Cloud connection", async () => {
|
|
vi.stubEnv("PAPERCLIP_CLOUD_TENANT_SERVER_TOKEN", "managed-fixture"); verifiedClaude();
|
|
claudeProbe.mockResolvedValue({ adapterType: "claude_local", status: "fail", testedAt: checkedAt,
|
|
checks: [{ code: "claude_hello_probe_auth_required", level: "error", message: "Authentication required" }] });
|
|
expect((await testConnection()).status).toBe("fail");
|
|
expect(markAuthFailed).toHaveBeenCalledTimes(1);
|
|
});
|
|
it("does not promote a runtime error before the provider probe", async () => {
|
|
vi.stubEnv("PAPERCLIP_CLOUD_TENANT_SERVER_TOKEN", "managed-fixture"); verifiedClaude();
|
|
runtimeProbe.mockResolvedValue({ adapterType: "paperclip_runner", status: "fail", testedAt: checkedAt,
|
|
checks: [{ code: "acpx_runtime_package_missing", level: "error", message: "Runtime missing" }] });
|
|
expect((await testConnection()).status).toBe("fail");
|
|
expect(claudeProbe).not.toHaveBeenCalled();
|
|
});
|
|
it("does not promote a missing hello receipt", async () => {
|
|
vi.stubEnv("PAPERCLIP_CLOUD_TENANT_SERVER_TOKEN", "managed-fixture"); verifiedClaude();
|
|
claudeProbe.mockResolvedValue({ adapterType: "claude_local", status: "pass", testedAt: checkedAt, checks: [] });
|
|
const result = await testConnection();
|
|
expect(result.status).toBe("fail");
|
|
expect(result.checks).toContainEqual(expect.objectContaining({ code: "ai_connection_validation_incomplete" }));
|
|
});
|
|
it("passes a managed API-key connection only after provider re-verification", async () => {
|
|
vi.stubEnv("PAPERCLIP_CLOUD_TENANT_SERVER_TOKEN", "managed-fixture"); verifiedClaude();
|
|
const result = await testConnection({ config: { ...context.config, env: { ANTHROPIC_API_KEY: "fixture-key" }, managedAiConnection: { method: "api_key" } } });
|
|
expect(result.status).toBe("pass");
|
|
expect(verifyKey).toHaveBeenCalledExactlyOnceWith("anthropic", "fixture-key");
|
|
expect(claudeProbe).not.toHaveBeenCalled();
|
|
});
|
|
it("keeps a rejected API key failed", async () => {
|
|
vi.stubEnv("PAPERCLIP_CLOUD_TENANT_SERVER_TOKEN", "managed-fixture"); verifiedClaude();
|
|
verifyKey.mockRejectedValueOnce(new Error("Rejected key"));
|
|
expect((await testConnection({ config: { ...context.config, env: { ANTHROPIC_API_KEY: "fixture-key" }, managedAiConnection: { method: "api_key" } } })).status).toBe("fail");
|
|
});
|
|
it("keeps SSH runtime warnings even on a Cloud instance", async () => {
|
|
vi.stubEnv("PAPERCLIP_CLOUD_TENANT_SERVER_TOKEN", "managed-fixture"); verifiedClaude();
|
|
vi.spyOn(executionTargets, "runAdapterExecutionTargetProcess").mockResolvedValue({ exitCode: 0, signal: null, timedOut: false, stdout: "", stderr: "", pid: null, startedAt: null });
|
|
const result = await testConnection({ executionTarget: { kind: "remote", transport: "ssh", remoteCwd: "/workspace", spec: { host: "example.test", port: 22, username: "test", remoteCwd: "/workspace", remoteWorkspacePath: "/workspace", privateKey: null, knownHosts: null, strictHostKeyChecking: true } } });
|
|
expect(result.status).toBe("warn");
|
|
});
|
|
it("never promotes an unexplained warning without the exact deferred check", async () => {
|
|
vi.stubEnv("PAPERCLIP_CLOUD_TENANT_SERVER_TOKEN", "managed-fixture"); verifiedClaude();
|
|
runtimeProbe.mockResolvedValue({ adapterType: "paperclip_runner", status: "warn", testedAt: checkedAt, checks: [] });
|
|
expect((await testConnection()).status).toBe("warn");
|
|
});
|
|
it("preserves an unexplained provider warning even with a hello receipt", async () => {
|
|
vi.stubEnv("PAPERCLIP_CLOUD_TENANT_SERVER_TOKEN", "managed-fixture"); verifiedClaude();
|
|
claudeProbe.mockResolvedValue({ adapterType: "claude_local", status: "warn", testedAt: checkedAt,
|
|
checks: [{ code: "claude_hello_probe_passed", level: "info", message: "Hello completed with an unresolved warning." }] });
|
|
expect((await testConnection()).status).toBe("warn");
|
|
});
|
|
it("keeps actionable warnings after a successful hello", async () => {
|
|
vi.stubEnv("PAPERCLIP_CLOUD_TENANT_SERVER_TOKEN", "managed-fixture"); verifiedClaude();
|
|
const result = readiness(); result.checks.push({ code: "provider_configuration_warning", level: "warn", message: "Check the selected provider configuration." }); runtimeProbe.mockResolvedValue(result);
|
|
expect((await testConnection()).status).toBe("warn");
|
|
});
|
|
});
|