mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-29 23:56:43 +01:00
fix: explain detached dev servers on persistent computers
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
d91b4fef7b
commit
66028796f3
2 files changed
+34
-3
No files matched your search
@@ -2158,6 +2158,32 @@ it.each(["installed", "explicit"] as const)("records the selected %s Codex comma
|
||||
}
|
||||
});
|
||||
|
||||
it.each([false, true])("binds detached-process guidance only for a trusted persistent computer (%s)", async (computer) => {
|
||||
const root = await mkdtemp(join(tmpdir(), "paperclip-computer-process-guidance-"));
|
||||
const runnerBinary = join(root, "runnerd");
|
||||
await writeFile(runnerBinary, "unexecuted fixture artifact", { mode: 0o700 });
|
||||
let instructions = "";
|
||||
const { transport } = createCapabilityRunnerdCodexTransport({
|
||||
provider: "codex", runnerBinary, stateDirectory: root, sourceCodexHome: "",
|
||||
codexCommand: "/qualified/codex", persistentAgentHome: computer ? "/agent/home" : undefined,
|
||||
controlPlaneRegistration: async (authority) => {
|
||||
instructions = String((authority.store.state.runAttachTemplate!.provider as { instructions: string }).instructions);
|
||||
throw new Error("fixture_stop_before_runner_launch");
|
||||
},
|
||||
runnerProcessLauncher: () => { throw new Error("must not launch"); },
|
||||
});
|
||||
try {
|
||||
await expect(transport.request("thread/start", { cwd: root, model: "gpt-6.1-sol", dynamicTools: [],
|
||||
developerInstructions: "Preserve the task instructions." })).rejects.toThrow("fixture_stop_before_runner_launch");
|
||||
expect(instructions).toContain("Preserve the task instructions.");
|
||||
expect(instructions.includes("nohup setsid")).toBe(computer);
|
||||
if (computer) {
|
||||
expect(instructions).toContain("stop when its warm timeout expires");
|
||||
expect(instructions).toContain("Do not create services or change runner ownership");
|
||||
}
|
||||
} finally { await transport.close(); await rm(root, { recursive: true, force: true }); }
|
||||
});
|
||||
|
||||
it("rejects remote Codex without a guest executable before resolving controller dependencies", async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), "paperclip-runner-remote-codex-command-"));
|
||||
const runnerBinary = join(root, "runnerd");
|
||||
|
||||
@@ -3443,6 +3443,11 @@ export function trustedRuntimeReadOnlyRoots(
|
||||
return [...roots];
|
||||
}
|
||||
|
||||
function withComputerProcessInstructions(instructions: string, persistentAgentHome?: string): string {
|
||||
if (!persistentAgentHome) return instructions;
|
||||
return `${instructions}\n\nComputer runtime: files in AGENT_HOME persist across turns. A dev server needed between warm turns must survive the shell tool's process-group cleanup: use a detached session, for example \`nohup setsid <command> </dev/null >dev-server.log 2>&1 &\`, and verify its listener from a separate command after the launching command returns. Detached processes still belong to this runner and stop when its warm timeout expires. Do not create services or change runner ownership to keep them alive.`;
|
||||
}
|
||||
|
||||
export function createRunnerdCodexAppServerArgs(input: {
|
||||
environment: NodeJS.ProcessEnv | undefined;
|
||||
codexHome: string;
|
||||
@@ -4826,9 +4831,9 @@ class DurablePrpCodexTransport implements CodexAppServerTransport {
|
||||
const includeCodexCollaborationInstructions =
|
||||
provider === "codex" &&
|
||||
record(params.config).include_collaboration_mode_instructions !== false;
|
||||
const unboundBaseInstructions = String(
|
||||
const unboundBaseInstructions = withComputerProcessInstructions(String(
|
||||
params.developerInstructions ?? params.baseInstructions ?? "You are a Paperclip agent.",
|
||||
);
|
||||
), this.options.persistentAgentHome);
|
||||
const baseInstructions =
|
||||
sourceRuntimeContext && runtimeContext
|
||||
? unboundBaseInstructions.replaceAll(
|
||||
@@ -5445,7 +5450,7 @@ class DurablePrpCodexTransport implements CodexAppServerTransport {
|
||||
runtimeContext,
|
||||
this.options.baseInstructions === undefined
|
||||
? undefined
|
||||
: { text: this.options.baseInstructions, context: sourceRuntimeContext },
|
||||
: { text: withComputerProcessInstructions(this.options.baseInstructions, this.options.persistentAgentHome), context: sourceRuntimeContext },
|
||||
);
|
||||
if (provider === "codex") {
|
||||
// These controller-owned, token-free paths belong to the new run.
|
||||
|
||||
Reference in new issue
Block a user