feat(ssh): use the agent AI account in new environments (#21248)

Use the agent-selected AI account for new SSH environments. Preserve
remote-machine authentication for existing environments and expose it as
an advanced option. Keep managed credentials private while preserving
supported conversation state and credential refreshes across turns.

Validated with focused route, adapter, lifecycle, and real-process tests;
final CI passed on d634944df1.
Greptile Apex reviewed that revision at 5/5 with no unresolved threads.
External neutral security reports remain documented in the pull request.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Devin FoleyandPaperclip authored and GitHub committed 2026-11-13 13:20:13 -08:00
1 parent 2a8b485140
commit 12aa08721c
77 files changed
+6115 -3898

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"