feat(plugins): support agentless harness sign-in (#23392)

## Thinking Path

> - Paperclip manages agents and the AI accounts they use.
> - A company can connect an account before creating its first agent.
> - Some plugin drivers can run sign-in in a dedicated sandbox.
> - Core currently selects a saved agent for every plugin login.
> - This change lets each driver declare that it can sign in without an
agent.

## Linked Issues or Issue Description

**Subsystem affected**

Environment drivers, managed AI connections, and the agent setup UI.

**Current behavior**

A company with zero agents cannot start a provider login on a plugin
environment, even when that driver can provision a temporary
environment.

**Proposed behavior**

A driver can declare `supportsAgentlessLogin`. Core uses this capability
when it selects a login target and acquires the lease. Drivers that omit
it retain the existing agent selection.

**Reason and benefit**

Operators can finish connecting the account before they configure its
first agent.

**Additional context**

The driver capability follows the per-driver adapter declaration in
#22827. The onboarding flow keeps the agent readiness check from #23383.

## What Changed

- Added the optional capability to the manifest, capabilities response,
and login UI.
- Kept company and driver validation at sign-in and lease acquisition.
- Applied the plugin device-login deadline to sessions with no agent.
Ordinary task provisioning keeps its existing contract.

## Verification

- 122 tests passed across shared capabilities, environment target
resolution, lease construction, device-login HTTP routes, and session
lifecycle.
- The server typecheck passed.
- The SDK input registry matches the source revision. `pnpm verify`
requests broader CI coverage for that registry.
- After merging the current base, 82 focused tests passed, including the
onboarding tests. The UI typecheck passed. All required GitHub checks
passed.

## Risks

Drivers must advertise this capability only when they can run and clean
up a login without an agent. Existing manifests retain their previous
behavior. No database migration is required.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

OpenAI Codex, GPT-6, with local code inspection and test execution.

## 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>
This commit is contained in:
Nicky LeachandPaperclip authored and GitHub committed 2026-12-01 10:22:32 -08:00
1 parent ce2e6ccc00
commit 07af22c57f
18 files changed
+88 -32

No files matched your search

+2 -1
View File
@@ -215,6 +215,7 @@ export interface LoginSessionActivityEvent {
export type LoginSessionActivityRecorder = (event: LoginSessionActivityEvent) => void;
export interface StartDeviceLoginInput {
environmentDriver?: string;
agentId?: string;
managementContext?: ConnectionManagementContext;
aiConnection?: import("@paperclipai/shared").AiConnectionLoginIntent;
@@ -939,7 +940,7 @@ export function createDeviceLoginService(deps: DeviceLoginServiceDeps) {
const publicSessionId = randomUUID();
const startedAt = now();
const requestedTtlSeconds = input.ttlSeconds ?? resolveProfile(input.adapterType).timeoutMs / 1000;
const ttlSeconds = input.agentId ? Math.min(requestedTtlSeconds, DEVICE_LOGIN_TIMEOUT_MS / 1000) : requestedTtlSeconds;
const ttlSeconds = input.environmentDriver === "plugin" || input.agentId ? Math.min(requestedTtlSeconds, DEVICE_LOGIN_TIMEOUT_MS / 1000) : requestedTtlSeconds;
const expiresAt = new Date(startedAt.getTime() + ttlSeconds * 1000);
const base = {
sessionId,
@@ -8,9 +8,23 @@ const fixtures = vi.hoisted(() => ({ environment: { id: "environment", driver: "
vi.mock("./environments.js", () => ({ environmentService: () => ({ getById: async () => fixtures.environment, listBoundCompanyIds: async () => fixtures.companies }) }));
vi.mock("./instance-settings.js", () => ({ instanceSettingsService: () => ({ get: async () => ({ defaultEnvironmentId: fixtures.instanceDefault }) }) }));
vi.mock("./environment-selection.js", () => ({ assertEnvironmentSelectionForCompany: vi.fn(async () => {}) }));
const { getByKey } = vi.hoisted(() => ({ getByKey: vi.fn() }));
vi.mock("./plugin-registry.js", () => ({ pluginRegistryService: () => ({ getByKey }) }));
const db = { select: () => ({ from: () => ({ where: () => ({ limit: async () => fixtures.agent ? [fixtures.agent] : [] }) }) }) } as unknown as Db;
beforeEach(() => { fixtures.instanceDefault = "environment"; fixtures.environment = { id: "environment", driver: "plugin" }; fixtures.companies = ["company"]; fixtures.agent = { id: "agent", companyId: "company", adapterType: "paperclip_runner", lifecycleState: "verifying", defaultEnvironmentId: "environment" }; });
describe("login environment transport target", () => {
it("acquires an opted-in plugin login without selecting an agent", async () => {
Object.assign(fixtures.environment, { config: { pluginKey: "computers", driverKey: "temporary" } });
getByKey.mockResolvedValue({ status: "ready", manifestJson: { environmentDrivers: [
{ kind: "environment_driver", driverKey: "temporary", supportsLoginPty: true, supportsAgentlessLogin: true },
] } });
fixtures.agent = undefined;
const input = { companyId: "company", environmentId: "environment", adapterType: "codex_local" };
await expect(resolveLoginEnvironmentTarget(db, { ...input, selectComputer: true })).resolves.toEqual({ environment: fixtures.environment, agentId: undefined });
await expect(assertLoginEnvironmentTarget(db, input)).resolves.toEqual(fixtures.environment);
Object.assign(fixtures.environment, { config: { pluginKey: "computers", driverKey: "persistent" } });
await expect(assertLoginEnvironmentTarget(db, input)).rejects.toMatchObject({ status: 400 });
});
it("permits a verifying saved agent on its own computer", async () => { await expect(assertLoginEnvironmentTarget(db, { companyId: "company", environmentId: "environment", agentId: "agent" })).resolves.toEqual(fixtures.environment); });
it("leaves which adapters a computer signs in to its driver's declared support", async () => { await expect(assertLoginEnvironmentTarget(db, { companyId: "company", environmentId: "environment", agentId: "agent", adapterType: "grok_local" })).resolves.toEqual(fixtures.environment); });
it("rejects an adapter that has no Paperclip sign-in", async () => { await expect(assertLoginEnvironmentTarget(db, { companyId: "company", environmentId: "environment", agentId: "agent", adapterType: "copilot_runtime" })).rejects.toMatchObject({ status: 400 }); });
+11 -2
View File
@@ -1,9 +1,10 @@
import { agents, environmentLeases, type Db } from "@paperclipai/db";
import { adapterLoginCommandKey, environmentLoginRequiresAgent } from "@paperclipai/shared";
import { adapterLoginCommandKey } from "@paperclipai/shared";
import { and, asc, eq, isNull, notExists, notInArray, or, sql } from "drizzle-orm";
import { badRequest, forbidden, notFound } from "../errors.js";
import { assertEnvironmentSelectionForCompany } from "./environment-selection.js";
import { environmentService } from "./environments.js";
import { pluginRegistryService } from "./plugin-registry.js";
import { instanceSettingsService } from "./instance-settings.js";
type LoginEnvironmentTarget = { companyId: string; environmentId: string; agentId?: string; adapterType?: string };
@@ -25,12 +26,20 @@ export async function resolveLoginEnvironmentTarget(
if (!environment) throw notFound("Environment not found");
const companies = await environments.listBoundCompanyIds(environment.id);
if (companies.length && !companies.includes(input.companyId)) throw forbidden("The selected environment belongs to another company.", { code: "environment_company_mismatch" });
if (!environmentLoginRequiresAgent(environment)) {
if (environment.driver !== "plugin") {
if (input.agentId) throw badRequest("A temporary sandbox login does not take an agent computer target.");
return { environment, agentId: undefined };
}
if (input.adapterType && !adapterLoginCommandKey(input.adapterType)) throw badRequest("This provider login is not supported on agent computers.", { code: "login_adapter_unsupported" });
if (!input.agentId) {
const config = environment.config;
if (typeof config?.pluginKey === "string" && typeof config.driverKey === "string") {
const plugin = await pluginRegistryService(db).getByKey(config.pluginKey);
const driver = plugin?.manifestJson.environmentDrivers?.find(item => item.driverKey === config.driverKey);
if (plugin?.status === "ready" && driver?.kind !== "sandbox_provider" && driver?.supportsLoginPty && driver.supportsAgentlessLogin) {
return { environment, agentId: undefined };
}
}
if (!input.selectComputer) throw badRequest("Select an agent computer for sign-in.", { code: "login_agent_required" });
const settings = await instanceSettingsService(db).get();
const matchesEnvironment = eq(agents.defaultEnvironmentId, environment.id);
@@ -211,6 +211,7 @@ export interface ReadyPluginEnvironmentDriver {
reusableLeaseMethodsVerified: boolean;
supportedAdapters?: string[];
loginAdapters: string[];
supportsAgentlessLogin?: boolean;
supportsInteractiveSetup?: PluginEnvironmentDriverDeclaration["supportsInteractiveSetup"];
interactiveSetupConnectionTypes?: PluginEnvironmentDriverDeclaration["interactiveSetupConnectionTypes"];
supportsTemplateCapture?: PluginEnvironmentDriverDeclaration["supportsTemplateCapture"];
@@ -471,6 +472,7 @@ export async function listReadyPluginEnvironmentDrivers(input: {
templateConfigBinding: driver.templateConfigBinding,
supportsTemplateDelete: driver.supportsTemplateDelete,
supportsLoginPty: driver.kind === "environment_driver" ? pluginSupportsLoginPty(driver, [...workerMethods]) : sandboxProviderSupportsLoginPty(driver),
...(driver.supportsAgentlessLogin ? { supportsAgentlessLogin: true } : {}),
...supportedAdapterFields(plugin.pluginKey, driver, [...workerMethods]),
})),
);