Use agent AI accounts in SSH environments

Stage the selected agent account in a private remote home and restore refreshed credentials before cleanup. Preserve remote authentication for existing SSH environments and expose it as an advanced option.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Devin FoleyandPaperclip committed 2026-11-12 17:08:59 -08:00
1 parent 2dcfdabc79
commit 8490bf9df2
41 files changed
+4471 -3774

No files matched your search

+26
View File
@@ -696,6 +696,32 @@ describe("CompanyEnvironments — test provider button", () => {
expect(buttons[1].disabled).toBe(true);
});
it("defaults new SSH environments to the agent's Paperclip account", async () => {
root = createRoot(container);
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
await act(async () => { root!.render(renderCompanyEnvironments(queryClient, `${ENVIRONMENTS_PATH}/new`)); });
await waitForAssertion(() => {
const toggle = getEnvironmentFormPage()?.querySelector('[aria-label="Use authentication configured on the remote machine"]');
expect(toggle?.getAttribute("aria-checked")).toBe("false");
expect(toggle?.closest("details")?.open).toBe(false);
});
});
it.each([undefined, true, false])("preserves the remote-auth option when editing an existing SSH environment (saved=%s)", async useHostAuth => {
mockEnvironmentsApi.list.mockResolvedValue([{ id: "env-existing-ssh", name: "Existing SSH", driver: "ssh", description: null, envVars: {},
config: { ...(useHostAuth !== undefined ? { useHostAuth } : {}), host: "ssh.example.test", username: "developer", port: 22, remoteWorkspacePath: "/workspace", strictHostKeyChecking: true } }]);
root = createRoot(container);
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
await act(async () => { root!.render(renderCompanyEnvironments(queryClient, `${ENVIRONMENTS_PATH}/env-existing-ssh/edit`)); });
await waitForAssertion(() => {
expect(getEnvironmentFormPage()?.querySelector('[aria-label="Use authentication configured on the remote machine"]')?.getAttribute("aria-checked")).toBe(String(useHostAuth !== false));
});
await act(async () => { click(findButton(getEnvironmentFormPage()!, "Save environment")); });
await waitForAssertion(() => {
expect(mockEnvironmentsApi.update).toHaveBeenCalledWith("env-existing-ssh", expect.objectContaining({ config: expect.objectContaining({ useHostAuth: useHostAuth !== false }) }), "company-1");
});
});
it("opens the add-environment form on a standalone page and closes it on cancel", async () => {
root = createRoot(container);
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
+16
View File
@@ -70,6 +70,7 @@ type EnvironmentFormState = {
name: string;
description: string;
driver: "local" | "ssh" | "sandbox";
sshUseHostAuth: boolean;
sshHost: string;
sshPort: string;
sshUsername: string;
@@ -126,6 +127,7 @@ function buildEnvironmentPayload(form: EnvironmentFormState) {
config:
form.driver === "ssh"
? {
useHostAuth: form.sshUseHostAuth,
host: form.sshHost.trim(),
port: Number.parseInt(form.sshPort || "22", 10) || 22,
username: form.sshUsername.trim(),
@@ -152,6 +154,7 @@ function createEmptyEnvironmentForm(): EnvironmentFormState {
name: "",
description: "",
driver: "ssh",
sshUseHostAuth: false,
sshHost: "",
sshPort: "22",
sshUsername: "",
@@ -182,6 +185,7 @@ function normalizeNonLocalEnvironmentId(
function readSshConfig(environment: Environment) {
const config = environment.config ?? {};
return {
useHostAuth: config.useHostAuth !== false,
host: typeof config.host === "string" ? config.host : "",
port:
typeof config.port === "number"
@@ -227,6 +231,7 @@ function createEnvironmentFormFromEnvironment(environment: Environment): Environ
name: environment.name,
description: environment.description ?? "",
driver: "ssh",
sshUseHostAuth: ssh.useHostAuth,
sshHost: ssh.host,
sshPort: ssh.port,
sshUsername: ssh.username,
@@ -2378,6 +2383,17 @@ export function CompanyEnvironments({ mode = "list" }: CompanyEnvironmentsProps)
onChange={(e) => setEnvironmentForm((current) => ({ ...current, sshKnownHosts: e.target.value }))}
/>
</Field>
<details className="md:col-span-2">
<summary className="cursor-pointer text-sm font-medium">Advanced</summary>
<div className="pt-3">
<ToggleField
label="Use authentication configured on the remote machine"
hint="Use the remote user's provider login instead of the agent's Paperclip AI account."
checked={environmentForm.sshUseHostAuth}
onChange={(checked) => setEnvironmentForm((current) => ({ ...current, sshUseHostAuth: checked }))}
/>
</div>
</details>
<div className="md:col-span-2">
<ToggleField
label="Strict host key checking"