diff --git a/doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md b/doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md index f8cee7970c0..eed8fd66287 100644 --- a/doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md +++ b/doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md @@ -638,6 +638,12 @@ that harness as unavailable there. A driver without `supportedAdapters` keeps the earlier behavior: every Runner harness, Claude sign-in, and Codex sign-in when the worker reads credentials back. +An environment driver that can allocate a dedicated sign-in sandbox may also +declare `supportsAgentlessLogin: true`. Core can then acquire a +`purpose: "login"` lease without an agent ID, including for a company's first +connection. The driver scopes the login and its cleanup to that allocation. +`requiresAgent` continues to govern ordinary agent provisioning. + ## Login allocations on an existing computer A login-capable environment driver can host authorization on a saved agent's diff --git a/packages/shared/src/environment-support.test.ts b/packages/shared/src/environment-support.test.ts index 91a7aacce30..eed931ef753 100644 --- a/packages/shared/src/environment-support.test.ts +++ b/packages/shared/src/environment-support.test.ts @@ -1,6 +1,8 @@ import { describe, expect, it } from "vitest"; import { adapterSupportsRemoteManagedEnvironments, + environmentLoginRequiresAgent, + environmentSupportsLoginPty, getEnvironmentCapabilities, isSandboxProviderSupportedForAdapter, supportedEnvironmentDriversForAdapter, @@ -119,3 +121,14 @@ describe("environment login PTY support", () => { expect(environmentSupportsLoginPty(computer, none, "claude_local")).toBe(false); }); }); + +it("offers the declared adapters for a plugin login that needs no agent", () => { + const environment = { driver: "plugin", config: { pluginKey: "test", driverKey: "temporary" } }; + const capabilities = { ...getEnvironmentCapabilities(["codex_local"]), loginPtyDrivers: { + "test:temporary": { supportsLoginPty: true, loginAdapters: ["codex_local"], supportsAgentlessLogin: true }, + } }; + expect(environmentLoginRequiresAgent(environment, capabilities)).toBe(false); + expect(environmentLoginRequiresAgent(environment)).toBe(true); + expect(environmentSupportsLoginPty(environment, capabilities, "codex_local")).toBe(true); + expect(environmentSupportsLoginPty(environment, capabilities, "claude_local")).toBe(false); +}); diff --git a/packages/shared/src/environment-support.ts b/packages/shared/src/environment-support.ts index 261c02dccfb..6bef8200e29 100644 --- a/packages/shared/src/environment-support.ts +++ b/packages/shared/src/environment-support.ts @@ -60,7 +60,7 @@ export interface EnvironmentProviderCapability { export interface EnvironmentCapabilities { /** Namespaced plugin driver keys that can host a login on a saved agent. */ - loginPtyDrivers?: Record; + loginPtyDrivers?: Record; adapters: AdapterEnvironmentSupport[]; drivers: Record; sandboxProviders: Record; @@ -203,15 +203,17 @@ export function getEnvironmentCapabilities( }; } -export function environmentLoginRequiresAgent(environment: { driver: string } | null | undefined): boolean { - return environment?.driver === "plugin"; +export function environmentLoginRequiresAgent(environment: { driver: string; config?: Record | null } | null | undefined, capabilities?: EnvironmentCapabilities | null): boolean { + if (environment?.driver !== "plugin") return false; + const config = environment.config; + return capabilities?.loginPtyDrivers?.[`${config?.pluginKey}:${config?.driverKey}`]?.supportsAgentlessLogin !== true; } /** Shared presentation rule for both temporary sandboxes and existing computers. */ export function environmentSupportsLoginPty(environment: { driver: string; config: Record } | null | undefined, capabilities: EnvironmentCapabilities | null | undefined, adapterType?: string): boolean { if (!environment || !capabilities) return false; if (environment.driver === "sandbox") return typeof environment.config.provider === "string" && capabilities.sandboxProviders[environment.config.provider]?.supportsLoginPty === true; - if (environmentLoginRequiresAgent(environment)) { + if (environment.driver === "plugin") { const driver = capabilities.loginPtyDrivers?.[`${environment.config.pluginKey}:${environment.config.driverKey}`]; return driver?.supportsLoginPty === true && (adapterType === undefined ? driver.loginAdapters.length > 0 : driver.loginAdapters.includes(adapterType)); diff --git a/packages/shared/src/types/plugin.ts b/packages/shared/src/types/plugin.ts index 99567f30af5..ec78e2ec76b 100644 --- a/packages/shared/src/types/plugin.ts +++ b/packages/shared/src/types/plugin.ts @@ -267,6 +267,8 @@ export interface PluginEnvironmentDriverDeclaration { * never starts a login. */ supportsLoginPty?: boolean; + /** Browser login can acquire a dedicated environment lease before any agent exists. */ + supportsAgentlessLogin?: boolean; /** * Deprecated alias for `supportsLoginPty`. It exists only so an external * plugin manifest that declares the old name still loads. The manifest diff --git a/packages/shared/src/validators/plugin.ts b/packages/shared/src/validators/plugin.ts index 072f0e6e3b7..424177f7a17 100644 --- a/packages/shared/src/validators/plugin.ts +++ b/packages/shared/src/validators/plugin.ts @@ -195,6 +195,7 @@ export const pluginEnvironmentDriverDeclarationSchema = z.object({ // The neutral transport capability: does the provider host an interactive // login on a real pseudo-terminal? Validate a literal boolean only. supportsLoginPty: z.boolean().optional(), + supportsAgentlessLogin: z.boolean().optional(), // Deprecated alias for `supportsLoginPty`. It exists only so an external // plugin manifest that declares the old name still loads. Validate a literal // boolean only. The transform below canonicalizes it onto `supportsLoginPty` diff --git a/server/src/__tests__/device-login-service.test.ts b/server/src/__tests__/device-login-service.test.ts index 18d46cbc92f..5164c294084 100644 --- a/server/src/__tests__/device-login-service.test.ts +++ b/server/src/__tests__/device-login-service.test.ts @@ -1285,7 +1285,8 @@ describe("device login service", () => { } }); - it("holds the session active until exactly five minutes, then times out and deletes", async () => { + it.each([{}, { environmentDriver: "plugin", ttlSeconds: 3_600 }])( + "holds the session until five minutes and bounds agentless plugin leases %j", async options => { vi.useFakeTimers(); try { const store = createMemoryStore(); @@ -1293,6 +1294,7 @@ describe("device login service", () => { const service = makeService({ store, runtime }); const companyId = randomUUID(); const { session, completed } = await service.start({ + ...options, companyId, environmentId: randomUUID(), adapterType: ADAPTER_TYPE, diff --git a/server/src/routes/adapter-login-route-spine.ts b/server/src/routes/adapter-login-route-spine.ts index 16e0cea73ec..35653083a59 100644 --- a/server/src/routes/adapter-login-route-spine.ts +++ b/server/src/routes/adapter-login-route-spine.ts @@ -1,6 +1,8 @@ import type { Request, Response } from "express"; import type { z } from "zod"; +type LoginTarget = { agentId: string | undefined; environment: { driver: string } }; + /** * The result of the shared adapter login start-route spine. The spine returns it * when every guard passes. `ownerUserId` is the immutable session owner from the @@ -9,7 +11,7 @@ import type { z } from "zod"; export interface AdapterLoginStartResolution { ownerUserId: string; data: TData; - targetAgentId: string | undefined; + target: LoginTarget; } /** @@ -57,7 +59,7 @@ export interface AdapterLoginStartSpineInput Promise; + resolveTarget: (data: TData) => Promise; } /** @@ -102,6 +104,6 @@ export async function runAdapterLoginStartSpine { + ) { const target = await resolveLoginEnvironmentTarget(db, { companyId, environmentId, ...options }); // Gate the Claude setup-token login on the provider capability. Only a // sandbox provider that advertises the setup-token login capability @@ -1593,7 +1593,7 @@ export function agentRoutes( if (options.requireSetupTokenLoginProvider) { await assertSetupTokenLoginProviderCapability(environmentId); } - return target.agentId; + return target; } /** @@ -1612,7 +1612,7 @@ export function agentRoutes( environment?.config && typeof environment.config === "object" ? (environment.config as Record) : {}; - if (environmentLoginRequiresAgent(environment)) { + if (environment?.driver === "plugin") { if (!options.pluginWorkerManager || typeof config.pluginKey !== "string" || typeof config.driverKey !== "string") return false; try { const resolved = await resolvePluginEnvironmentDriver({ db, workerManager: options.pluginWorkerManager, config: config as unknown as import("@paperclipai/shared").PluginEnvironmentConfig }); @@ -3816,21 +3816,21 @@ export function agentRoutes( requestSchema: startAdapterAuthSessionRequestSchema, invalidRequestError: "The device login start request is invalid.", requestOverrides: { adapterType: type }, - resolveTargetAgentId: async (data) => { + resolveTarget: async (data) => { // The device login runs on a real pseudo-terminal, so it needs a // provider that advertises the login pseudo-terminal capability. Gate // the route on the current provider capability before any session or // lease state. The lease-acquisition path re-checks it from current // runtime state before the provider lease. - const targetAgentId = await resolveSandboxLoginTarget(companyId, data.environmentId, { + const target = await resolveSandboxLoginTarget(companyId, data.environmentId, { agentId: data.agentId, adapterType: data.adapterType, selectComputer: Boolean(data.aiConnection), }); await assertDeviceLoginProviderCapability(data.environmentId, data.adapterType); - return targetAgentId; + return target; }, }); if (!resolved) return; - const { ownerUserId: startedByUserId, data, targetAgentId } = resolved; + const { ownerUserId: startedByUserId, data, target } = resolved; if (req.actor.type === "agent" && !data.aiConnection) throw forbidden("Agent logins must save a managed AI account"); if (data.aiConnection) { @@ -3843,7 +3843,8 @@ export function agentRoutes( result = await adapterLoginService.start({ companyId, environmentId: data.environmentId, - agentId: targetAgentId, + agentId: target.agentId, + environmentDriver: target.environment.driver, adapterType: type, startedByUserId, ttlSeconds: data.ttlSeconds, @@ -7052,7 +7053,7 @@ export function agentRoutes( } return false; }, - resolveTargetAgentId: (data) => + resolveTarget: (data) => resolveSandboxLoginTarget(companyId, data.environmentId, { requireSetupTokenLoginProvider: true, agentId: data.agentId, @@ -7061,7 +7062,7 @@ export function agentRoutes( }), }); if (!resolved) return; - const { ownerUserId, data, targetAgentId } = resolved; + const { ownerUserId, data, target } = resolved; const { environmentId, adapterType } = data; if (req.actor.type === "agent" && !data.aiConnection) throw forbidden("Agent logins must save a managed AI account"); if (data.aiConnection) { @@ -7075,7 +7076,7 @@ export function agentRoutes( ownerUserId, adapterType, environmentId, - agentId: targetAgentId, + agentId: target.agentId, confirmedOverwrite, aiConnection: data.aiConnection, managementContext: continuingConnectionManagement(connectionRequestContext(req)), diff --git a/server/src/routes/environments.ts b/server/src/routes/environments.ts index 7f6239f5bba..d49b4ea9875 100644 --- a/server/src/routes/environments.ts +++ b/server/src/routes/environments.ts @@ -824,6 +824,7 @@ export function environmentRoutes( `${driver.pluginKey}:${driver.driverKey}`, { supportsLoginPty: driver.supportsLoginPty === true, loginAdapters: driver.loginAdapters, + ...(driver.supportsAgentlessLogin ? { supportsAgentlessLogin: true } : {}), }, ])) }); }); diff --git a/server/src/services/device-login-service.ts b/server/src/services/device-login-service.ts index 3c37ec802ea..471a9067cb3 100644 --- a/server/src/services/device-login-service.ts +++ b/server/src/services/device-login-service.ts @@ -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, diff --git a/server/src/services/login-environment.test.ts b/server/src/services/login-environment.test.ts index a06b9642ca0..8ebb4468fe7 100644 --- a/server/src/services/login-environment.test.ts +++ b/server/src/services/login-environment.test.ts @@ -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 }); }); diff --git a/server/src/services/login-environment.ts b/server/src/services/login-environment.ts index adca2145812..e5707435630 100644 --- a/server/src/services/login-environment.ts +++ b/server/src/services/login-environment.ts @@ -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); diff --git a/server/src/services/plugin-environment-driver.ts b/server/src/services/plugin-environment-driver.ts index 644437bde3d..f8cf61befd0 100644 --- a/server/src/services/plugin-environment-driver.ts +++ b/server/src/services/plugin-environment-driver.ts @@ -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]), })), ); diff --git a/tests/runner-e2e/source-sdk-public-inputs.json b/tests/runner-e2e/source-sdk-public-inputs.json index ca9e06e485d..2064eef04ce 100644 --- a/tests/runner-e2e/source-sdk-public-inputs.json +++ b/tests/runner-e2e/source-sdk-public-inputs.json @@ -253,8 +253,8 @@ "packages/shared/src/env-file.ts": "ee15f8dfa6610d3fd1eea3ca0846cc2c583f9070", "packages/shared/src/environment-custom-images.test.ts": "80d00f3581f13a782480700296b1295d8159ddae", "packages/shared/src/environment-custom-images.ts": "a81814b7f99e5c8871f50ffcf9dd93dc435dee27", - "packages/shared/src/environment-support.test.ts": "91a7aacce30fb6fcf6782045a5a5e1281448cdf4", - "packages/shared/src/environment-support.ts": "261c02dccfb7d8396687739ccc1b03bb59067a6b", + "packages/shared/src/environment-support.test.ts": "eed931ef7535cd4aae1dc12d640149976634b057", + "packages/shared/src/environment-support.ts": "6bef8200e293fa734e7779456bde5774bab4bdf0", "packages/shared/src/execution-workspace-guards.ts": "5428546ab16ef5cb4d23edd914d0a15a83a94668", "packages/shared/src/external-agent-guidance.ts": "d815fc60b170717f0fdcff61bc30c8a1289f7fcc", "packages/shared/src/external-objects-server.ts": "f323ba3e5e0b1a2ad415bdb5e0ca99bf9d449821", @@ -465,7 +465,7 @@ "packages/shared/src/types/issue.ts": "1a01870cfda97510486c20425fabe7ac553460ac", "packages/shared/src/types/live.ts": "b90e55e4de8600c6fc17d7fa8d89079d4ae655ec", "packages/shared/src/types/native-finalization.ts": "c026a73003ae232fea4f7624d561493b383df358", - "packages/shared/src/types/plugin.ts": "99567f30af5165880d67519c1d9e71855600d4f9", + "packages/shared/src/types/plugin.ts": "ec78e2ec76b61eca20f7250237042c9ac70d5376", "packages/shared/src/types/project.ts": "50b9d9c51cb38d5862e287c1a47726716603f21c", "packages/shared/src/types/quota.ts": "a0686a9afb3111a4de093f66200dc0c9152e883e", "packages/shared/src/types/resource-memberships.ts": "9eab6fad50facf3e489f8c40e5bedd92e1d1faf8", @@ -552,7 +552,7 @@ "packages/shared/src/validators/onboarding-seed.ts": "de302a8400d4199053f379d9ed853522a3ac6d32", "packages/shared/src/validators/partial.ts": "fa60ec7481fc14175365e9e500c814b159f1ab53", "packages/shared/src/validators/plugin.test.ts": "0a028e978f6706b3b23039e30ea04d7d8bccb1e2", - "packages/shared/src/validators/plugin.ts": "072f0e6e3b7618b1d3a7c85dc1cc5074c86bd2b0", + "packages/shared/src/validators/plugin.ts": "424177f7a174e00622acfc0abe1726a7a0768bbb", "packages/shared/src/validators/project.ts": "6ea168f5faf3161e6004ea47274f60634c77b219", "packages/shared/src/validators/provider-trace.ts": "b38b6200a2e51513f5dca0f8b008f2fe68175e82", "packages/shared/src/validators/resource-memberships.ts": "b124ac8a8f24b4dbb03ae82bcc87541f6b4ecdfd", diff --git a/ui/src/components/AgentConfigForm.tsx b/ui/src/components/AgentConfigForm.tsx index 10f75b0109f..1687352fc81 100644 --- a/ui/src/components/AgentConfigForm.tsx +++ b/ui/src/components/AgentConfigForm.tsx @@ -1519,7 +1519,7 @@ export function AgentConfigForm(props: AgentConfigFormProps) { // effective environment provider. The form reads the adapter login capability, // not the adapter name: every adapter login gates on this provider capability. const providerSupportsLoginPty = environmentSupportsLoginPty(effectiveLoginEnvironment, environmentCapabilities, isRunnerHarness ? harnessType : adapterType); - const loginRequiresAgent = environmentLoginRequiresAgent(effectiveLoginEnvironment); + const loginRequiresAgent = environmentLoginRequiresAgent(effectiveLoginEnvironment, environmentCapabilities); const showAdapterLogin = (isCreate || !currentAiConnection) && adapterSupportsSandboxLogin && diff --git a/ui/src/components/OnboardingWizard.tsx b/ui/src/components/OnboardingWizard.tsx index 64c020e1530..324e6c2481a 100644 --- a/ui/src/components/OnboardingWizard.tsx +++ b/ui/src/components/OnboardingWizard.tsx @@ -1165,7 +1165,7 @@ function OnboardingWizardInner({ createdCompanyId && loginProviderSupportsPty, ); - const loginRequiresAgent = canShowAdapterLogin && environmentLoginRequiresAgent(resolvedLoginEnvironment); + const loginRequiresAgent = canShowAdapterLogin && environmentLoginRequiresAgent(resolvedLoginEnvironment, loginEnvironmentCapabilities); const agentSettledOnChoice = (agent: Pick) => agentHarnessType(agent.adapterType, agent.adapterConfig) === adapterType && (!model.trim() || agent.adapterConfig?.model === model.trim()); diff --git a/ui/src/components/ai-connections/AiConnectionCredentialStep.tsx b/ui/src/components/ai-connections/AiConnectionCredentialStep.tsx index 49eb39188a5..fd5a7a2ea8d 100644 --- a/ui/src/components/ai-connections/AiConnectionCredentialStep.tsx +++ b/ui/src/components/ai-connections/AiConnectionCredentialStep.tsx @@ -113,7 +113,7 @@ function SubscriptionConnectionStep({ defaultAccountDialog, onOtherModels, advan adapterType={provider === "google" ? "antigravity_runtime" : provider === "anthropic" ? "claude_local" : provider === "xai" ? "grok_local" : "codex_local"} environmentId={environmentId} canLogin={!loading && canLogin} - requiresAgent={environmentLoginRequiresAgent(environment)} + requiresAgent={environmentLoginRequiresAgent(environment, caps.data)} agentId={environmentId === (suppliedEnvironmentId ?? settings.data?.defaultEnvironmentId) ? loginAgentId : undefined} localEnvironment={!loading && environment?.driver === "local"} onBack={onCancel} diff --git a/ui/src/components/new-agent/NewAgentSetup.tsx b/ui/src/components/new-agent/NewAgentSetup.tsx index 1922b39ea84..949bc13982a 100644 --- a/ui/src/components/new-agent/NewAgentSetup.tsx +++ b/ui/src/components/new-agent/NewAgentSetup.tsx @@ -371,7 +371,7 @@ function Setup({ && transition.environmentId === environmentId && transition.runner === defaultRunner) return; resetTest(); }, [companyId, environmentId, runner === "auto" ? defaultRunner : undefined]); - const loginOnComputer = environmentLoginRequiresAgent(environment); + const loginOnComputer = environmentLoginRequiresAgent(environment, caps.data); const canLogin = environmentSupportsLoginPty(environment, caps.data, connectionAdapter ?? adapterType); const loginComputer = useAgentComputerLogin({ required: loginOnComputer,