mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 09:41:04 +01:00
## Thinking Path > - Paperclip lets people manage AI agents and their work. > - Legacy adapters launch provider CLIs and expose connected tools. > - Existing defaults did not consistently grant full automatic permission. > - Remote Claude used a fixed tool list that omitted MCP tools and future tools. > - Direct Codex launches and OpenCode configuration also used narrower defaults. > - This change gives all these paths the same full-auto default as native runners. > - Explicit restrictive settings continue to work. ## Linked Issues or Issue Description Refs #13686. This PR is stacked on that native-runner and task-reassignment PR. Merge #13686 first. Related: #831 (constructed Claude agents), #1935 (adapter-switching permission defaults). ## What Changed - Use actual Claude permission bypass for local and remote runs and probes. Remove the fixed tool list so MCP and future provider tools are included. - Identify actual managed sandbox targets to Claude with `IS_SANDBOX=1`. Do not mark ordinary host execution as a sandbox. - Default direct Codex execution to approval and sandbox bypass, matching agent creation. Preserve explicit false, CLI profiles, sandbox modes, approval policy, and network restrictions. - Set OpenCode's full-auto runtime permission to `allow` for every tool and connection. Preserve the existing explicit opt-out. - Default Gemini probes to the same YOLO mode as execution. Make the legacy ACP `default` alias use `approve-all` for fresh and resumed sessions. - Add default, opt-out, remote, probe, connected-tool, and resume regression tests. Update adapter configuration documentation. - Other adapter paths already request full automatic permission or have no provider approval gate. ## Verification - Full workspace `pnpm -r typecheck` and `pnpm build` passed locally after rebasing onto current master. Targeted adapter/server and legacy ACP tests passed, including defaults, explicit opt-outs, remote launches, connected tools, and fresh/resumed sessions. - Greptile reviewed current head `8ca135eaffcf9cfdba6f1368e896a781a0891d50` at **5/5**. The security reviewer acknowledged the documented full-auto requirement. Acknowledged discussions are resolved. - Current head has **54 passing checks**. [PR checks](https://github.com/paperclipai/paperclip/pull/13693/checks). The process-adapter signoff browser shard passed on one retry after its first attempt exceeded a three-second issue-run wait. - **Six native Claude/Codex real-provider cases passed on their first attempt, with cleanup passing**, against the combined branch: plans, reassignment, and backlog creation/status. [Campaign and downloadable evidence](https://github.com/paperclipai/paperclip/actions/runs/35469926548). This does not claim a real-provider run of every legacy adapter. - The live-tested revision is `a37881c824dcd7170380fc4b788732fc743e5da7`. The current head differs only in the corrected heartbeat test expectation; application code is identical. - The campaign result-enforcement job passed. The separate report publisher failed during frozen dependency installation because the trusted workflow's patched-dependency configuration does not match its lockfile. Passing case evidence remains downloadable from the workflow. - Full-suite coverage comes from CI partitions. The separate unsharded local run was stopped after the corresponding CI partitions passed; it is not counted as a completed local run. ## Risks - Missing permission settings now grant all provider operations, including connected tools. OpenCode full-auto also overrides ambient provider permission rules. An explicit Paperclip permission opt-out preserves restrictive behavior. - Claude refuses full bypass as root outside an identified sandbox. Ordinary host deployments must run Claude as a non-root user. Managed sandbox launches include the required marker. - These defaults do not grant additional Paperclip roles, connections, or company access. Existing controller authorization and governance still apply. - This PR depends on #13686. Retarget it to master after that PR merges. ## Model Used OpenAI Codex, based on GPT-6, with code execution and repository tools. The exact deployment model ID and context-window size are not exposed in this session. ## 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>
106 lines
4.2 KiB
TypeScript
106 lines
4.2 KiB
TypeScript
import { asBoolean, asString, asStringArray } from "@paperclipai/adapter-utils/server-utils";
|
|
import {
|
|
CODEX_LOCAL_FAST_MODE_SUPPORTED_MODELS,
|
|
DEFAULT_CODEX_LOCAL_BYPASS_APPROVALS_AND_SANDBOX,
|
|
isCodexLocalFastModeSupported,
|
|
normalizeCodexModel,
|
|
} from "../index.js";
|
|
|
|
const SKIP_GIT_REPO_CHECK_FLAG = "--skip-git-repo-check";
|
|
|
|
export type BuildCodexExecArgsResult = {
|
|
args: string[];
|
|
model: string;
|
|
fastModeRequested: boolean;
|
|
fastModeApplied: boolean;
|
|
fastModeIgnoredReason: string | null;
|
|
};
|
|
|
|
function readExtraArgs(config: unknown): string[] {
|
|
const fromExtraArgs = asStringArray(asRecord(config).extraArgs);
|
|
if (fromExtraArgs.length > 0) return fromExtraArgs;
|
|
return asStringArray(asRecord(config).args);
|
|
}
|
|
|
|
function asRecord(value: unknown): Record<string, unknown> {
|
|
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
? (value as Record<string, unknown>)
|
|
: {};
|
|
}
|
|
|
|
function formatFastModeSupportedModels(): string {
|
|
return `${CODEX_LOCAL_FAST_MODE_SUPPORTED_MODELS.join(", ")} or manually configured model IDs`;
|
|
}
|
|
|
|
export function buildCodexExecArgs(
|
|
config: unknown,
|
|
options: {
|
|
resumeSessionId?: string | null;
|
|
skipGitRepoCheck?: boolean;
|
|
networkAccess?: boolean;
|
|
} = {},
|
|
): BuildCodexExecArgsResult {
|
|
const record = asRecord(config);
|
|
const model = normalizeCodexModel(asString(record.model, ""));
|
|
const modelReasoningEffort = asString(
|
|
record.modelReasoningEffort,
|
|
asString(record.reasoningEffort, ""),
|
|
).trim();
|
|
const search = asBoolean(record.search, false);
|
|
const fastModeRequested = asBoolean(record.fastMode, false);
|
|
const fastModeApplied = fastModeRequested && isCodexLocalFastModeSupported(model);
|
|
const extraArgs = readExtraArgs(record);
|
|
// Explicit CLI modes/profiles remain deliberate overrides. An omitted
|
|
// setting uses the same full-auto default as agent creation and onboarding.
|
|
const explicitSandbox = extraArgs.some((arg) =>
|
|
/^(--sandbox(?:=|$)|-s|--profile(?:=|$)|-p|--full-auto$|--yolo$|--dangerously-bypass-approvals-and-sandbox$)/.test(arg)
|
|
|| /^(?:(?:--config=|-c=?)\s*)?(?:sandbox_mode|profile)\s*=/.test(arg),
|
|
);
|
|
const explicitPermissionRestriction = extraArgs.some((arg) =>
|
|
/^(?:(?:--config=|-c=?)\s*)?(?:approval_policy\s*=|sandbox_workspace_write\.network_access\s*=\s*false)/.test(arg),
|
|
);
|
|
const bypass = asBoolean(
|
|
record.dangerouslyBypassApprovalsAndSandbox,
|
|
asBoolean(record.dangerouslyBypassSandbox, !explicitSandbox && !explicitPermissionRestriction && options.networkAccess !== false && DEFAULT_CODEX_LOCAL_BYPASS_APPROVALS_AND_SANDBOX),
|
|
);
|
|
const args = ["exec", "--json"];
|
|
if (!bypass && !explicitSandbox) {
|
|
args.push("-c", 'sandbox_mode="workspace-write"');
|
|
args.push("-c", `sandbox_workspace_write.network_access=${options.networkAccess !== false}`);
|
|
}
|
|
// Codex rejects a repeated `--skip-git-repo-check` ("cannot be used multiple
|
|
// times"). The adapter injects this flag for sandbox execution, so when an
|
|
// operator's extraArgs already carry it the injection would abort the run
|
|
// with exit code 2. Skip the injection in that case and let the operator's
|
|
// copy stand.
|
|
if (options.skipGitRepoCheck && !extraArgs.includes(SKIP_GIT_REPO_CHECK_FLAG)) {
|
|
args.push(SKIP_GIT_REPO_CHECK_FLAG);
|
|
}
|
|
if (search) args.unshift("--search");
|
|
if (bypass) args.push("--dangerously-bypass-approvals-and-sandbox");
|
|
if (model) args.push("--model", model);
|
|
if (modelReasoningEffort) {
|
|
args.push("-c", `model_reasoning_effort=${JSON.stringify(modelReasoningEffort)}`);
|
|
}
|
|
if (fastModeApplied) {
|
|
args.push("-c", 'service_tier="fast"', "-c", "features.fast_mode=true");
|
|
}
|
|
if (extraArgs.length > 0) args.push(...extraArgs);
|
|
if (!bypass && options.networkAccess === false) {
|
|
args.push("-c", "sandbox_workspace_write.network_access=false");
|
|
}
|
|
if (options.resumeSessionId) args.push("resume", options.resumeSessionId, "-");
|
|
else args.push("-");
|
|
|
|
return {
|
|
args,
|
|
model,
|
|
fastModeRequested,
|
|
fastModeApplied,
|
|
fastModeIgnoredReason:
|
|
fastModeRequested && !fastModeApplied
|
|
? `Configured fast mode is currently only supported on ${formatFastModeSupportedModels()}; Paperclip will ignore it for model ${model || "(default)"}.`
|
|
: null,
|
|
};
|
|
}
|