mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 09:39:53 +01:00
Preserve native provider compatibility and clean partial SSH uploads
Apply preconfigured SSH homes only to supported native providers and permission modes. Preserve isolated mode for OpenCode, Copilot, and restricted Claude while retaining admitted recovery input. Stage host-auth Codex runtime files in private SSH directories so existing cleanup owns partial uploads. Read the selected remote profile before creating its tracing overlay. Eight new regressions first failed. Verified 21 focused cases and 229 tests across six broader adapter, runtime, configuration, and provider suites. Adapter-utils, Claude, Codex, and server typechecks pass. SDK source, whitespace, and secret scans pass. Fresh CI and Apex review remain required. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
1865127a38
commit
a38694571e
10 files changed
+120
-23
No files matched your search
@@ -389,6 +389,21 @@ describePostgres("heartbeat execution configuration through adapter dispatch", (
|
||||
}
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ provider: "opencode", model: "openai/gpt-5" },
|
||||
{ provider: "acpx", acpxAgent: "copilot", model: "gpt-5.6-luna" },
|
||||
{ provider: "acpx", acpxAgent: "claude", model: "claude-sonnet-4-6", acpxPermissionMode: "approve-reads" },
|
||||
])("keeps native SSH provider home support during preparation: $provider $acpxAgent", async config => {
|
||||
const f = await seed();
|
||||
const environment = { ...await environmentService(db).ensureLocalEnvironment(), driver: "ssh", config: {
|
||||
host: "fixture.invalid", username: "fixture", remoteWorkspacePath: "/workspace",
|
||||
} } as Environment;
|
||||
const opening = await configuration(f, config, {}, "paperclip_runner", false, "shared_workspace", environment);
|
||||
const result = await opening.prepare();
|
||||
if (!result.prepared) throw new Error("SSH preparation failed");
|
||||
expect(result.runtimeConfig.homeMode).toBe("isolated");
|
||||
});
|
||||
|
||||
it("requires an agent AI account for a new SSH environment when remote authentication is off", async () => {
|
||||
const f = await seed();
|
||||
const environment = { ...await environmentService(db).ensureLocalEnvironment(), driver: "ssh", config: { useHostAuth: false } } as Environment;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { supportsPaperclipRunnerPreconfiguredHome } from "../native-runtime/provider-profile.js";
|
||||
import { agentHarnessType } from "@paperclipai/shared";
|
||||
import { observabilitySecretValues } from "@paperclipai/adapter-utils/agent-observability";
|
||||
import { agentObservabilityService, unavailableAgentObservability, type ResolvedAgentObservability } from "../agent-observability.js";
|
||||
@@ -119,9 +120,13 @@ export async function prepareHeartbeatExecutionConfiguration(db: Db, input: Hear
|
||||
const { issueId, context, responsibleUserId, acceptedPlanContinuationWake, acceptedPlanWakeRoutingDecision, taskProjectContext, routineEnvContext, pinnedSkillTest } = input.task;
|
||||
const { selectedEnvironmentId, selectedEnvironmentForConfig, resolvedInstanceSettings, persistedNativeExecutionInput } = input.environment;
|
||||
const useSshHostAuth = selectedEnvironmentForConfig?.driver === "ssh" && selectedEnvironmentForConfig.config.useHostAuth !== false && !persistedNativeExecutionInput;
|
||||
let sshRunnerHomeMode: "isolated" | "preconfigured" | undefined;
|
||||
if (agent.adapterType === "paperclip_runner" && selectedEnvironmentForConfig?.driver === "ssh" && !persistedNativeExecutionInput) {
|
||||
sshRunnerHomeMode = useSshHostAuth && supportsPaperclipRunnerPreconfiguredHome(agent.adapterConfig, { companyId: agent.companyId }) ? "preconfigured" : "isolated";
|
||||
}
|
||||
const sourceWorkspaceConfig = agent.adapterType === "paperclip_runner"
|
||||
? { ...input.config.sourceWorkspaceConfig,
|
||||
homeMode: bindHeartbeatRunnerHomeMode({ ...parseObject(agent.adapterConfig), ...(selectedEnvironmentForConfig?.driver === "ssh" && !persistedNativeExecutionInput ? { homeMode: useSshHostAuth ? "preconfigured" : "isolated" } : {}) }, persistedNativeExecutionInput).homeMode }
|
||||
homeMode: bindHeartbeatRunnerHomeMode({ ...parseObject(agent.adapterConfig), ...(sshRunnerHomeMode ? { homeMode: sshRunnerHomeMode } : {}) }, persistedNativeExecutionInput).homeMode }
|
||||
: input.config.sourceWorkspaceConfig;
|
||||
const preconfiguredHome = agent.adapterType === "paperclip_runner" && sourceWorkspaceConfig.homeMode === "preconfigured";
|
||||
if (preconfiguredHome && pinnedSkillTest) {
|
||||
|
||||
@@ -198,6 +198,27 @@ describe.skipIf(!support.supported)("heartbeat runtime selection boundary", () =
|
||||
expect((await read(f.run.id)).runnerProfileJson).toEqual(saved.runnerProfileJson);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ provider: "opencode", model: "openai/gpt-5" },
|
||||
{ provider: "acpx", acpxAgent: "copilot", model: "gpt-5.6-luna" },
|
||||
{ provider: "acpx", acpxAgent: "claude", model: "claude-sonnet-4-6", acpxPermissionMode: "approve-reads" },
|
||||
])("retains supported isolated native selection for SSH host auth: $provider $acpxAgent", async adapterConfig => {
|
||||
const f = await fixture();
|
||||
f.input.agent = { ...f.agent, adapterConfig };
|
||||
await db.update(agents).set({ adapterConfig }).where(eq(agents.id, f.agent.id));
|
||||
f.input.workspace.executionTarget = { kind: "remote", transport: "ssh", remoteCwd: "/workspace", spec: {
|
||||
host: "fixture.invalid", port: 22, username: "fixture", remoteWorkspacePath: "/workspace", remoteCwd: "/workspace",
|
||||
useHostAuth: true, privateKey: null, knownHosts: null, strictHostKeyChecking: true,
|
||||
} };
|
||||
f.input.nativeRuntimeResolution = resolveHeartbeatNativeRuntimeMode({ persisted: f.run, enabled: true, runtimeConfig: {},
|
||||
adapterConfig, agent: f.input.agent, issue: f.issue, target: f.input.workspace.executionTarget, workspaceId: null });
|
||||
f.input.config.runtimeConfig.homeMode = "preconfigured";
|
||||
const selected = await selectHeartbeatRuntime(db, f.input);
|
||||
if (!selected.selected || !selected.nativeExecution) throw new Error("Expected native selection");
|
||||
expect("homeMode" in selected.nativeExecution ? selected.nativeExecution.homeMode : "isolated").toBe("isolated");
|
||||
expect(selected.nativeExecution.provider.kind).toBe(adapterConfig.provider === "acpx" ? "acpx" : "opencode");
|
||||
});
|
||||
|
||||
it("preserves immutable native recovery when current local Runner configuration is invalid", async () => {
|
||||
const f = await fixture();
|
||||
const selected = await selectHeartbeatRuntime(db, f.input);
|
||||
|
||||
@@ -67,6 +67,7 @@ import {
|
||||
assertManagedProfileRecoveryBinding,
|
||||
projectPaperclipRunnerTaskConfig,
|
||||
resolvePaperclipRunnerNativeProviderInput,
|
||||
supportsPaperclipRunnerPreconfiguredHome,
|
||||
} from "../native-runtime/provider-profile.js";
|
||||
import { readRemoteCodexModelCliVersion } from "../native-runtime/codex-model-fallback.js";
|
||||
import {
|
||||
@@ -784,8 +785,11 @@ export async function selectHeartbeatRuntime(db: Db, input: HeartbeatRuntimeSele
|
||||
managedAiRuntime ? readNonEmptyString(resolvedConfig.model) ?? undefined : undefined,
|
||||
)
|
||||
: agent.adapterConfig;
|
||||
const nativeProviderConfig = agent.adapterType === "paperclip_runner" && runtimeConfig.homeMode !== undefined
|
||||
? { ...parseObject(projectedNativeProviderConfig), homeMode: runtimeConfig.homeMode }
|
||||
const runnerHomeMode = runtimeConfig.homeMode === "preconfigured" && executionTarget?.kind === "remote" && executionTarget.transport === "ssh"
|
||||
&& !supportsPaperclipRunnerPreconfiguredHome(projectedNativeProviderConfig, { companyId: agent.companyId })
|
||||
? "isolated" : runtimeConfig.homeMode;
|
||||
const nativeProviderConfig = agent.adapterType === "paperclip_runner" && runnerHomeMode !== undefined
|
||||
? { ...parseObject(projectedNativeProviderConfig), homeMode: runnerHomeMode }
|
||||
: projectedNativeProviderConfig;
|
||||
const requestedNativeProvider = resolvePaperclipRunnerNativeProviderInput({
|
||||
companyId: agent.companyId,
|
||||
|
||||
@@ -658,6 +658,13 @@ export function resolvePaperclipRunnerProviderProfile(
|
||||
};
|
||||
}
|
||||
|
||||
export function supportsPaperclipRunnerPreconfiguredHome(adapterConfig: unknown, options: { companyId?: string } = {}): boolean {
|
||||
const config = asRecord(adapterConfig);
|
||||
const profile = resolvePaperclipRunnerProviderProfile(config, options);
|
||||
return profile.provider === "codex" || (profile.provider === "acpx" && profile.acpxAgent === "claude"
|
||||
&& (config.acpxPermissionMode === undefined || config.acpxPermissionMode === "approve-all"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Project the operator-owned adapter configuration and a qualified stored
|
||||
* profile into the closed native execution descriptor. Editable adapter
|
||||
|
||||
Reference in new issue
Block a user