mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-02 19:08:33 +01:00
785 lines
30 KiB
TypeScript
785 lines
30 KiB
TypeScript
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../components/ui/select";
|
||
import { AdapterMark } from "../../components/AdapterMark";
|
||
import { configFieldsForSection } from "../config-sections";
|
||
import type { AdapterConfigFieldsProps } from "../types";
|
||
import {
|
||
Field,
|
||
ToggleField,
|
||
DraftInput,
|
||
DraftNumberInput,
|
||
help,
|
||
} from "../../components/agent-config-primitives";
|
||
import { ChoosePathButton } from "../../components/PathInstructionsModal";
|
||
import { LocalWorkspaceRuntimeFields } from "../local-workspace-runtime-fields";
|
||
import {
|
||
DEFAULT_CODEX_LOCAL_MODEL,
|
||
CODEX_LOCAL_FAST_MODE_SUPPORTED_MODELS,
|
||
isCodexLocalFastModeSupported,
|
||
isCodexLocalManualModel,
|
||
} from "@paperclipai/adapter-codex-local";
|
||
import {
|
||
PAPERCLIP_RUNNER_IDLE_TIMEOUT_DEFAULT_MS,
|
||
PAPERCLIP_RUNNER_IDLE_TIMEOUT_MAX_MS,
|
||
PAPERCLIP_RUNNER_PERMISSION_CAPABILITIES,
|
||
PAPERCLIP_RUNNER_ACPX_PROFILES,
|
||
isPaperclipRunnerProvider,
|
||
resolvePaperclipRunnerIdleTimeoutMs,
|
||
resolvePaperclipRunnerPermissionMode,
|
||
type PaperclipRunnerPermissionMode,
|
||
type PaperclipRunnerProvider,
|
||
} from "@paperclipai/adapter-utils";
|
||
|
||
const inputClass =
|
||
"w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40";
|
||
const instructionsFileHint =
|
||
"Absolute path to a markdown file (e.g. AGENTS.md) that defines this agent's behavior. Injected into the system prompt at runtime. Note: Codex may still auto-apply repo-scoped AGENTS.md files from the workspace.";
|
||
const defaultOpenCodeRunnerModel = "openrouter/deepseek/deepseek-v4-flash-0731";
|
||
const defaultAcpxClaudeModel = "claude-sonnet-5";
|
||
const defaultClaudeManagedModel = "claude-sonnet-5";
|
||
const defaultAwsAgentCoreModel = "global.anthropic.claude-sonnet-4-6";
|
||
const runnerHarnessOptions = [
|
||
{ value: "codex", label: "Codex", adapter: "codex_local" },
|
||
{ value: "opencode", label: "OpenCode 1.18.34", adapter: "opencode_local" },
|
||
{ value: "claude_managed", label: "Claude Managed", adapter: "claude_local" },
|
||
{ value: "aws_agentcore", label: "AWS AgentCore", adapter: "aws_agentcore" },
|
||
{ value: "acpx", label: "ACP agents", adapter: "acpx_local" },
|
||
{ value: "grok", label: "Grok Build", adapter: "grok_local" },
|
||
];
|
||
|
||
export function CodexLocalConfigFields({
|
||
section,
|
||
mode,
|
||
isCreate,
|
||
adapterType,
|
||
values,
|
||
set,
|
||
config,
|
||
eff,
|
||
mark,
|
||
models,
|
||
hideInstructionsFile,
|
||
managedSandboxOnly,
|
||
}: AdapterConfigFieldsProps) {
|
||
const runnerManaged = adapterType === "paperclip_runner";
|
||
// The execution engine picks which binary runs on the execution host, and the
|
||
// ACP sub-fields below name host paths. The platform-managed environment owns
|
||
// both, so the managed-sandbox-only policy hides them the same way
|
||
// `runnerManaged` already does for the Paperclip Runner.
|
||
const hideEngineChoice = runnerManaged || managedSandboxOnly === true;
|
||
const configuredRunnerProvider = runnerManaged
|
||
? isCreate
|
||
? values!.adapterSchemaValues?.provider
|
||
: eff("adapterConfig", "provider", config.provider === "acpx" && config.acpxAgent === "codex" ? "codex" : config.provider ?? "codex")
|
||
: "codex";
|
||
const runnerProvider: PaperclipRunnerProvider = isPaperclipRunnerProvider(
|
||
configuredRunnerProvider,
|
||
)
|
||
? configuredRunnerProvider
|
||
: "codex";
|
||
const runnerPermissionCapability =
|
||
PAPERCLIP_RUNNER_PERMISSION_CAPABILITIES[runnerProvider];
|
||
const configuredRunnerPermissionMode =
|
||
runnerManaged && runnerPermissionCapability.configurable
|
||
? isCreate
|
||
? (values!.adapterSchemaValues?.[
|
||
runnerPermissionCapability.configKey
|
||
] ??
|
||
(runnerProvider === "codex"
|
||
? values!.codexPermissionMode
|
||
: undefined))
|
||
: eff(
|
||
"adapterConfig",
|
||
runnerPermissionCapability.configKey,
|
||
config[runnerPermissionCapability.configKey],
|
||
)
|
||
: undefined;
|
||
const runnerPermissionModeUnsupported =
|
||
runnerManaged &&
|
||
runnerPermissionCapability.configurable &&
|
||
configuredRunnerPermissionMode !== undefined &&
|
||
!runnerPermissionCapability.options.some(
|
||
(option) => option.value === configuredRunnerPermissionMode,
|
||
);
|
||
const runnerPermissionMode =
|
||
runnerManaged && runnerPermissionCapability.configurable
|
||
? resolvePaperclipRunnerPermissionMode(
|
||
runnerProvider,
|
||
configuredRunnerPermissionMode,
|
||
)
|
||
: runnerPermissionCapability.defaultMode;
|
||
const runnerSchemaValue = (key: string, fallback: unknown): unknown =>
|
||
isCreate
|
||
? (values!.adapterSchemaValues?.[key] ?? fallback)
|
||
: eff("adapterConfig", key, config[key] ?? fallback);
|
||
const updateRunnerSchemaValue = (key: string, value: unknown): void => {
|
||
if (isCreate) {
|
||
set!({
|
||
adapterSchemaValues: {
|
||
...values!.adapterSchemaValues,
|
||
[key]: value,
|
||
},
|
||
});
|
||
} else {
|
||
mark("adapterConfig", key, value);
|
||
}
|
||
};
|
||
const runnerLifecycleMode = runnerManaged
|
||
? isCreate
|
||
? (values!.paperclipRunnerLifecycleMode ?? "per_turn")
|
||
: eff(
|
||
"adapterConfig",
|
||
"lifecycleMode",
|
||
config.lifecycleMode === "warm" ? "warm" : "per_turn",
|
||
)
|
||
: "per_turn";
|
||
const runnerIdleTimeoutMs = runnerManaged
|
||
? resolvePaperclipRunnerIdleTimeoutMs(
|
||
isCreate
|
||
? values!.paperclipRunnerIdleTimeoutMs
|
||
: eff("adapterConfig", "idleTimeoutMs", config.idleTimeoutMs),
|
||
)
|
||
: PAPERCLIP_RUNNER_IDLE_TIMEOUT_DEFAULT_MS;
|
||
const rawEngine = runnerManaged
|
||
? "cli"
|
||
: isCreate
|
||
? (values!.codexEngine ?? "auto")
|
||
: eff("adapterConfig", "engine", String(config.engine ?? "auto"));
|
||
const engine =
|
||
rawEngine === "acp" || rawEngine === "cli" ? rawEngine : "auto";
|
||
const acpSelected = engine === "acp";
|
||
const bypassEnabled =
|
||
config.dangerouslyBypassApprovalsAndSandbox === true ||
|
||
config.dangerouslyBypassSandbox === true;
|
||
const fastModeEnabled = isCreate
|
||
? Boolean(values!.fastMode)
|
||
: eff("adapterConfig", "fastMode", Boolean(config.fastMode));
|
||
const currentModel = isCreate
|
||
? String(values!.model ?? "")
|
||
: eff("adapterConfig", "model", String(config.model ?? ""));
|
||
const fastModeManualModel = isCodexLocalManualModel(currentModel);
|
||
const fastModeSupported = isCodexLocalFastModeSupported(currentModel);
|
||
const supportedModelsLabel =
|
||
CODEX_LOCAL_FAST_MODE_SUPPORTED_MODELS.join(", ");
|
||
const fastModeMessage = fastModeManualModel
|
||
? "Fast mode will be passed through for this manual model. If Codex rejects it, turn the toggle off."
|
||
: fastModeSupported
|
||
? "Fast mode consumes credits/tokens much faster than standard Codex runs."
|
||
: `Fast mode currently only works on ${supportedModelsLabel} or manual model IDs. Paperclip will ignore this toggle until the model is switched.`;
|
||
|
||
return configFieldsForSection(section, (
|
||
<>
|
||
{!hideEngineChoice && (
|
||
<Field
|
||
label="Execution engine"
|
||
hint="Default uses ACP. If ACP is unavailable, the run fails with a setup error. Choose CLI explicitly to use it."
|
||
>
|
||
<select
|
||
className={inputClass}
|
||
value={engine}
|
||
onChange={(e) => {
|
||
const value =
|
||
e.target.value === "acp"
|
||
? "acp"
|
||
: e.target.value === "cli"
|
||
? "cli"
|
||
: "auto";
|
||
isCreate
|
||
? set!({ codexEngine: value })
|
||
: mark(
|
||
"adapterConfig",
|
||
"engine",
|
||
value === "auto" ? undefined : value,
|
||
);
|
||
}}
|
||
>
|
||
<option value="auto">Default (ACP)</option>
|
||
<option value="cli">Codex CLI</option>
|
||
<option value="acp">ACP</option>
|
||
</select>
|
||
</Field>
|
||
)}
|
||
{runnerManaged && (
|
||
<Field configSection="adapter"
|
||
label="Harness"
|
||
hint="Choose the agent harness that runs your tasks."
|
||
>
|
||
<Select
|
||
value={runnerProvider === "acpx" && runnerSchemaValue("acpxAgent", "claude") === "grok" ? "grok" : runnerProvider}
|
||
onValueChange={(value) => {
|
||
const grok = value === "grok";
|
||
const provider = grok ? "acpx" : isPaperclipRunnerProvider(value)
|
||
? value
|
||
: "codex";
|
||
const model =
|
||
provider === "opencode"
|
||
? defaultOpenCodeRunnerModel
|
||
: provider === "claude_managed"
|
||
? defaultClaudeManagedModel
|
||
: provider === "aws_agentcore"
|
||
? defaultAwsAgentCoreModel
|
||
: provider === "acpx"
|
||
? grok ? "grok-4.7" : defaultAcpxClaudeModel
|
||
: DEFAULT_CODEX_LOCAL_MODEL;
|
||
if (isCreate) {
|
||
set!({
|
||
model,
|
||
adapterSchemaValues: {
|
||
...values!.adapterSchemaValues,
|
||
provider,
|
||
acpxSessionMode: undefined,
|
||
...(provider === "acpx" ? { acpxAgent: grok ? "grok" : "claude" } : {}),
|
||
},
|
||
});
|
||
} else {
|
||
mark("adapterConfig", "provider", provider);
|
||
mark("adapterConfig", "acpxSessionMode", undefined);
|
||
mark("adapterConfig", "model", model);
|
||
if (provider === "acpx") {
|
||
mark("adapterConfig", "acpxAgent", grok ? "grok" : "claude");
|
||
}
|
||
}
|
||
}}
|
||
>
|
||
<SelectTrigger className="w-full" aria-label="Harness"><SelectValue /></SelectTrigger>
|
||
<SelectContent>
|
||
{runnerHarnessOptions.map((option) => (
|
||
<SelectItem key={option.value} value={option.value}>
|
||
<AdapterMark type={option.adapter} className="size-4" />
|
||
{option.label}
|
||
</SelectItem>
|
||
))}
|
||
</SelectContent>
|
||
</Select>
|
||
</Field>
|
||
)}
|
||
{runnerManaged && runnerProvider === "acpx" && runnerSchemaValue("acpxAgent", "claude") !== "grok" && (
|
||
<Field configSection="adapter" label="ACP agent" hint="Cursor uses Paperclip questions; per-run cost is unavailable. GitHub Copilot, Pi and Hermes await qualification.">
|
||
<Select
|
||
value={String(isCreate ? values!.adapterSchemaValues?.acpxAgent ?? "claude" : eff("adapterConfig", "acpxAgent", config.acpxAgent ?? "claude"))}
|
||
onValueChange={(value) => {
|
||
const profile = PAPERCLIP_RUNNER_ACPX_PROFILES.find(entry => entry.value === value);
|
||
const acpxSessionMode = profile?.value === "cursor" ? "agent" : undefined;
|
||
if (!profile?.qualified) return;
|
||
if (isCreate) set!({ model: profile.value === "claude" ? defaultAcpxClaudeModel : "",
|
||
adapterSchemaValues: { ...values!.adapterSchemaValues, acpxAgent: profile.value, acpxSessionMode } });
|
||
else { mark("adapterConfig", "acpxAgent", profile.value); mark("adapterConfig", "acpxSessionMode", acpxSessionMode); mark("adapterConfig", "model", profile.value === "claude" ? defaultAcpxClaudeModel : ""); }
|
||
}}>
|
||
<SelectTrigger className="w-full" aria-label="ACP agent"><SelectValue /></SelectTrigger>
|
||
<SelectContent>
|
||
{PAPERCLIP_RUNNER_ACPX_PROFILES.map(profile => (
|
||
<SelectItem key={profile.value} value={profile.value} disabled={!profile.qualified}>
|
||
<AdapterMark type={profile.value === "cursor" ? "cursor" : `${profile.value}_local`} className="size-4" />
|
||
{profile.label}{profile.qualified ? "" : " — qualification pending"}
|
||
</SelectItem>
|
||
))}
|
||
</SelectContent>
|
||
</Select>
|
||
</Field>
|
||
)}
|
||
{runnerManaged && runnerProvider === "acpx" && runnerSchemaValue("acpxAgent", "claude") === "cursor" && (
|
||
<Field configSection="adapter" label="Cursor mode" hint="Select Cursor's session mode. Permissions and company approval rules still apply.">
|
||
<select className={inputClass} aria-label="Cursor mode"
|
||
value={String(runnerSchemaValue("acpxSessionMode", "agent"))}
|
||
onChange={(event) => updateRunnerSchemaValue("acpxSessionMode", event.target.value)}>
|
||
{!["agent", "plan", "ask"].includes(String(runnerSchemaValue("acpxSessionMode", "agent"))) && (
|
||
<option value={String(runnerSchemaValue("acpxSessionMode", "agent"))} disabled>Unsupported saved mode — select Agent, Plan, or Ask</option>
|
||
)}
|
||
<option value="agent">Agent</option>
|
||
<option value="plan">Plan</option>
|
||
<option value="ask">Ask</option>
|
||
</select>
|
||
</Field>
|
||
)}
|
||
{runnerManaged && runnerProvider === "claude_managed" && (
|
||
<>
|
||
<Field
|
||
label="Managed Agent profile"
|
||
hint="Company-scoped qualified profile ID or key. Remote resource identity is loaded from the stored profile, not this agent config."
|
||
>
|
||
<DraftInput
|
||
value={String(runnerSchemaValue("managedProfileId", ""))}
|
||
onCommit={(value) =>
|
||
updateRunnerSchemaValue("managedProfileId", value.trim())
|
||
}
|
||
immediate
|
||
className={inputClass}
|
||
placeholder="managed-primary"
|
||
/>
|
||
</Field>
|
||
<Field
|
||
label="Session spend ceiling (USD)"
|
||
hint="Optional per-agent hard ceiling. Leave 1.00 to use a conservative default."
|
||
>
|
||
<DraftNumberInput
|
||
value={Number(runnerSchemaValue("maxSessionListCostUsd", 1))}
|
||
min={0.01}
|
||
onCommit={(value) =>
|
||
updateRunnerSchemaValue("maxSessionListCostUsd", value)
|
||
}
|
||
immediate
|
||
className={inputClass}
|
||
/>
|
||
</Field>
|
||
<ToggleField
|
||
label="Acknowledge managed retention"
|
||
hint="Claude Managed is a stateful beta service and is not eligible for ZDR or HIPAA modes."
|
||
checked={
|
||
runnerSchemaValue("managedAgentsRetentionAcknowledged", false) ===
|
||
true
|
||
}
|
||
onChange={(value) =>
|
||
updateRunnerSchemaValue(
|
||
"managedAgentsRetentionAcknowledged",
|
||
value,
|
||
)
|
||
}
|
||
/>
|
||
</>
|
||
)}
|
||
{runnerManaged && runnerProvider === "aws_agentcore" && (
|
||
<>
|
||
<Field
|
||
label="AgentCore profile"
|
||
hint="Company-scoped qualified profile ID or key. Harness, Memory, IAM, and context-store identity come from the stored profile."
|
||
>
|
||
<DraftInput
|
||
value={String(runnerSchemaValue("agentCoreProfileId", ""))}
|
||
onCommit={(value) =>
|
||
updateRunnerSchemaValue("agentCoreProfileId", value.trim())
|
||
}
|
||
immediate
|
||
className={inputClass}
|
||
placeholder="agentcore-primary"
|
||
/>
|
||
</Field>
|
||
<Field
|
||
label="Estimated session ceiling (USD)"
|
||
hint="Paperclip estimate; AWS does not provide a per-session currency hard stop."
|
||
>
|
||
<DraftNumberInput
|
||
value={Number(runnerSchemaValue("maxEstimatedSessionCostUsd", 1))}
|
||
min={0.01}
|
||
onCommit={(value) =>
|
||
updateRunnerSchemaValue("maxEstimatedSessionCostUsd", value)
|
||
}
|
||
immediate
|
||
className={inputClass}
|
||
/>
|
||
</Field>
|
||
<Field
|
||
label="Maximum iterations"
|
||
hint="Qualified range is 1–8. Invalid values fail closed to 8."
|
||
>
|
||
<DraftNumberInput
|
||
value={Number(runnerSchemaValue("maxIterations", 8))}
|
||
min={1}
|
||
max={8}
|
||
onCommit={(value) =>
|
||
updateRunnerSchemaValue("maxIterations", value)
|
||
}
|
||
immediate
|
||
className={inputClass}
|
||
/>
|
||
</Field>
|
||
<Field
|
||
label="Maximum output tokens"
|
||
hint="Qualified range is 1–4096."
|
||
>
|
||
<DraftNumberInput
|
||
value={Number(runnerSchemaValue("maxOutputTokens", 4_096))}
|
||
min={1}
|
||
max={4_096}
|
||
onCommit={(value) =>
|
||
updateRunnerSchemaValue("maxOutputTokens", value)
|
||
}
|
||
immediate
|
||
className={inputClass}
|
||
/>
|
||
</Field>
|
||
<Field configSection="runPolicy"
|
||
label="Invocation timeout (seconds)"
|
||
hint="Qualified range is 1–300 seconds."
|
||
>
|
||
<DraftNumberInput
|
||
value={Number(runnerSchemaValue("timeoutSeconds", 300))}
|
||
min={1}
|
||
max={300}
|
||
onCommit={(value) =>
|
||
updateRunnerSchemaValue("timeoutSeconds", value)
|
||
}
|
||
immediate
|
||
className={inputClass}
|
||
/>
|
||
</Field>
|
||
<ToggleField
|
||
label="Acknowledge 90-day Memory retention"
|
||
hint="The qualified AgentCore profile retains short-term Memory events for exactly 90 days."
|
||
checked={
|
||
runnerSchemaValue("agentCoreRetentionAcknowledged", false) ===
|
||
true
|
||
}
|
||
onChange={(value) =>
|
||
updateRunnerSchemaValue("agentCoreRetentionAcknowledged", value)
|
||
}
|
||
/>
|
||
</>
|
||
)}
|
||
{runnerManaged && runnerPermissionCapability.configurable && (runnerPermissionCapability.options.length > 1 || runnerPermissionModeUnsupported) && (
|
||
<Field
|
||
label="Permission mode"
|
||
hint={`${runnerPermissionCapability.description} The selected mode does not widen Paperclip's workspace, network, credential, or planning boundaries.`}
|
||
>
|
||
<Select
|
||
value={
|
||
runnerPermissionModeUnsupported
|
||
? "__unsupported__"
|
||
: runnerPermissionMode
|
||
}
|
||
onValueChange={(selectedMode) => {
|
||
const value = resolvePaperclipRunnerPermissionMode(
|
||
runnerProvider,
|
||
selectedMode,
|
||
) as PaperclipRunnerPermissionMode;
|
||
if (isCreate) {
|
||
set!({
|
||
adapterSchemaValues: {
|
||
...values!.adapterSchemaValues,
|
||
[runnerPermissionCapability.configKey]: value,
|
||
},
|
||
});
|
||
} else {
|
||
mark(
|
||
"adapterConfig",
|
||
runnerPermissionCapability.configKey,
|
||
value,
|
||
);
|
||
}
|
||
}}
|
||
>
|
||
<SelectTrigger aria-label="Permission mode" className="w-full font-sans">
|
||
<SelectValue>
|
||
{runnerPermissionModeUnsupported
|
||
? "Unsupported saved mode — select a qualified mode"
|
||
: runnerPermissionCapability.options.find((option) => option.value === runnerPermissionMode)?.label}
|
||
</SelectValue>
|
||
</SelectTrigger>
|
||
<SelectContent>
|
||
{runnerPermissionModeUnsupported && (
|
||
<SelectItem value="__unsupported__" disabled>
|
||
Unsupported saved mode — select a qualified mode
|
||
</SelectItem>
|
||
)}
|
||
{runnerPermissionCapability.options.map((option) => (
|
||
<SelectItem key={option.value} value={option.value}>
|
||
{option.label}
|
||
</SelectItem>
|
||
))}
|
||
</SelectContent>
|
||
</Select>
|
||
{runnerPermissionModeUnsupported && runnerProvider === "codex" && (
|
||
<p className="mt-1 text-xs text-destructive" role="alert">
|
||
This saved Codex mode cannot start or recover a Paperclip Runner
|
||
run. Select Automatic (isolated) to remediate it.
|
||
</p>
|
||
)}
|
||
</Field>
|
||
)}
|
||
{runnerManaged && (
|
||
<Field configSection="runPolicy"
|
||
label="Runner lifecycle"
|
||
hint="Turn by turn suspends after each run. Warm keeps the same provider process available between governed runs."
|
||
>
|
||
<select
|
||
className={inputClass}
|
||
value={runnerLifecycleMode}
|
||
onChange={(event) => {
|
||
const value = event.target.value === "warm" ? "warm" : "per_turn";
|
||
isCreate
|
||
? set!({ paperclipRunnerLifecycleMode: value })
|
||
: mark("adapterConfig", "lifecycleMode", value);
|
||
}}
|
||
>
|
||
<option value="per_turn">Turn by turn</option>
|
||
<option value="warm">Warm session</option>
|
||
</select>
|
||
</Field>
|
||
)}
|
||
{runnerManaged && runnerLifecycleMode === "warm" && (
|
||
<Field configSection="runPolicy"
|
||
label="Warm idle timeout (ms)"
|
||
hint="After this much inactivity, runnerd checkpoints and suspends the provider session. The maximum is 24 hours."
|
||
>
|
||
{isCreate ? (
|
||
<input
|
||
type="number"
|
||
min={1}
|
||
max={PAPERCLIP_RUNNER_IDLE_TIMEOUT_MAX_MS}
|
||
className={inputClass}
|
||
value={runnerIdleTimeoutMs}
|
||
onChange={(event) =>
|
||
set!({
|
||
paperclipRunnerIdleTimeoutMs:
|
||
resolvePaperclipRunnerIdleTimeoutMs(
|
||
Number(event.target.value),
|
||
),
|
||
})
|
||
}
|
||
/>
|
||
) : (
|
||
<DraftNumberInput
|
||
value={runnerIdleTimeoutMs}
|
||
min={1}
|
||
max={PAPERCLIP_RUNNER_IDLE_TIMEOUT_MAX_MS}
|
||
onCommit={(value) =>
|
||
mark(
|
||
"adapterConfig",
|
||
"idleTimeoutMs",
|
||
resolvePaperclipRunnerIdleTimeoutMs(value),
|
||
)
|
||
}
|
||
immediate
|
||
className={inputClass}
|
||
/>
|
||
)}
|
||
</Field>
|
||
)}
|
||
{acpSelected && (
|
||
<>
|
||
{!managedSandboxOnly && (
|
||
<Field configSection="advanced"
|
||
label="ACP server command"
|
||
hint="Optional override for the Codex ACP server command. Defaults to the package-local codex-acp binary."
|
||
>
|
||
<DraftInput
|
||
value={
|
||
isCreate
|
||
? (values!.codexAcpAgentCommand ?? "")
|
||
: eff(
|
||
"adapterConfig",
|
||
"agentCommand",
|
||
String(config.agentCommand ?? ""),
|
||
)
|
||
}
|
||
onCommit={(v) =>
|
||
isCreate
|
||
? set!({ codexAcpAgentCommand: v })
|
||
: mark("adapterConfig", "agentCommand", v || undefined)
|
||
}
|
||
immediate
|
||
className={inputClass}
|
||
placeholder="codex-acp"
|
||
/>
|
||
</Field>
|
||
)}
|
||
<Field configSection="runPolicy"
|
||
label="ACP session mode"
|
||
hint="Persistent keeps ACP session state between runs. One-shot starts fresh each run."
|
||
>
|
||
<select
|
||
className={inputClass}
|
||
value={
|
||
isCreate
|
||
? (values!.codexAcpMode ?? "persistent")
|
||
: eff(
|
||
"adapterConfig",
|
||
"mode",
|
||
String(config.mode ?? "persistent"),
|
||
)
|
||
}
|
||
onChange={(e) => {
|
||
const value =
|
||
e.target.value === "oneshot" ? "oneshot" : "persistent";
|
||
isCreate
|
||
? set!({ codexAcpMode: value })
|
||
: mark("adapterConfig", "mode", value);
|
||
}}
|
||
>
|
||
<option value="persistent">Persistent</option>
|
||
<option value="oneshot">One-shot</option>
|
||
</select>
|
||
</Field>
|
||
<Field
|
||
label="ACP non-interactive permissions"
|
||
hint="Fallback if the ACP agent asks for input outside an interactive session."
|
||
>
|
||
<select
|
||
className={inputClass}
|
||
value={
|
||
isCreate
|
||
? (values!.codexAcpNonInteractivePermissions ?? "deny")
|
||
: eff(
|
||
"adapterConfig",
|
||
"nonInteractivePermissions",
|
||
String(config.nonInteractivePermissions ?? "deny"),
|
||
)
|
||
}
|
||
onChange={(e) => {
|
||
const value = e.target.value === "fail" ? "fail" : "deny";
|
||
isCreate
|
||
? set!({ codexAcpNonInteractivePermissions: value })
|
||
: mark("adapterConfig", "nonInteractivePermissions", value);
|
||
}}
|
||
>
|
||
<option value="deny">Deny</option>
|
||
<option value="fail">Fail</option>
|
||
</select>
|
||
</Field>
|
||
{!managedSandboxOnly && (
|
||
<Field
|
||
label="ACP state directory"
|
||
hint="Optional ACP session state directory. Defaults to Paperclip-managed organization/agent scoped storage."
|
||
>
|
||
<div className="flex items-center gap-2">
|
||
<DraftInput
|
||
value={
|
||
isCreate
|
||
? (values!.codexAcpStateDir ?? "")
|
||
: eff(
|
||
"adapterConfig",
|
||
"stateDir",
|
||
String(config.stateDir ?? ""),
|
||
)
|
||
}
|
||
onCommit={(v) =>
|
||
isCreate
|
||
? set!({ codexAcpStateDir: v })
|
||
: mark("adapterConfig", "stateDir", v || undefined)
|
||
}
|
||
immediate
|
||
className={inputClass}
|
||
placeholder="/path/to/acp-state"
|
||
/>
|
||
<ChoosePathButton />
|
||
</div>
|
||
</Field>
|
||
)}
|
||
<Field configSection="runPolicy"
|
||
label="ACP warm process idle ms"
|
||
hint="Defaults to 0, which closes the ACP process after each run while retaining persistent session state."
|
||
>
|
||
{isCreate ? (
|
||
<input
|
||
type="number"
|
||
className={inputClass}
|
||
value={values!.codexAcpWarmHandleIdleMs ?? 0}
|
||
onChange={(e) =>
|
||
set!({ codexAcpWarmHandleIdleMs: Number(e.target.value) })
|
||
}
|
||
/>
|
||
) : (
|
||
<DraftNumberInput
|
||
value={eff(
|
||
"adapterConfig",
|
||
"warmHandleIdleMs",
|
||
Number(config.warmHandleIdleMs ?? 0),
|
||
)}
|
||
onCommit={(v) =>
|
||
mark("adapterConfig", "warmHandleIdleMs", v || 0)
|
||
}
|
||
immediate
|
||
className={inputClass}
|
||
/>
|
||
)}
|
||
</Field>
|
||
</>
|
||
)}
|
||
{!runnerManaged && !hideInstructionsFile && (
|
||
<Field label="Agent instructions file" hint={instructionsFileHint}>
|
||
<div className="flex items-center gap-2">
|
||
<DraftInput
|
||
value={
|
||
isCreate
|
||
? (values!.instructionsFilePath ?? "")
|
||
: eff(
|
||
"adapterConfig",
|
||
"instructionsFilePath",
|
||
String(config.instructionsFilePath ?? ""),
|
||
)
|
||
}
|
||
onCommit={(v) =>
|
||
isCreate
|
||
? set!({ instructionsFilePath: v })
|
||
: mark(
|
||
"adapterConfig",
|
||
"instructionsFilePath",
|
||
v || undefined,
|
||
)
|
||
}
|
||
immediate
|
||
className={inputClass}
|
||
placeholder="/absolute/path/to/AGENTS.md"
|
||
/>
|
||
<ChoosePathButton />
|
||
</div>
|
||
</Field>
|
||
)}
|
||
{!runnerManaged && (
|
||
<>
|
||
<ToggleField
|
||
label="Bypass sandbox"
|
||
hint={help.dangerouslyBypassSandbox}
|
||
checked={
|
||
isCreate
|
||
? values!.dangerouslyBypassSandbox
|
||
: eff(
|
||
"adapterConfig",
|
||
"dangerouslyBypassApprovalsAndSandbox",
|
||
bypassEnabled,
|
||
)
|
||
}
|
||
onChange={(v) =>
|
||
isCreate
|
||
? set!({ dangerouslyBypassSandbox: v })
|
||
: mark(
|
||
"adapterConfig",
|
||
"dangerouslyBypassApprovalsAndSandbox",
|
||
v,
|
||
)
|
||
}
|
||
/>
|
||
<ToggleField
|
||
label="Enable search"
|
||
hint={help.search}
|
||
checked={
|
||
isCreate
|
||
? values!.search
|
||
: eff("adapterConfig", "search", !!config.search)
|
||
}
|
||
onChange={(v) =>
|
||
isCreate
|
||
? set!({ search: v })
|
||
: mark("adapterConfig", "search", v)
|
||
}
|
||
/>
|
||
<ToggleField
|
||
label="Fast mode"
|
||
hint={help.fastMode}
|
||
checked={fastModeEnabled}
|
||
onChange={(v) =>
|
||
isCreate
|
||
? set!({ fastMode: v })
|
||
: mark("adapterConfig", "fastMode", v)
|
||
}
|
||
/>
|
||
{fastModeEnabled && (
|
||
<div className="rounded-md border border-amber-300/70 bg-amber-50/80 px-3 py-2 text-sm text-amber-900 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-100">
|
||
{fastModeMessage}
|
||
</div>
|
||
)}
|
||
</>
|
||
)}
|
||
<LocalWorkspaceRuntimeFields
|
||
isCreate={isCreate}
|
||
values={values}
|
||
set={set}
|
||
config={config}
|
||
mark={mark}
|
||
eff={eff}
|
||
mode={mode}
|
||
adapterType={adapterType}
|
||
models={models}
|
||
/>
|
||
</>
|
||
));
|
||
}
|