Skip to content

feat(daemon): wire ACP host callbacks in bypass mode - #2786

Merged
lsm merged 2 commits into
devfrom
space/acp-split-8c-bypass-callbacks
Aug 23, 2026
Merged

lsm merged 2 commits into
devfrom
space/acp-split-8c-bypass-callbacks

Conversation

@lsm

@lsm lsm commented Aug 23, 2026 •

Copy link
Copy Markdown
Owner

Extracted from #2711 (ACP split 8/10).

What this adds

  • Terminal callbacks: when the session has a workspace, query startup constructs an AcpTerminalManager (allowlisted env via buildAcpSafeEnv, workspace as default cwd, process-tree owner) and wires terminal/create|output|wait_for_exit|kill|release. Commands are parsed/normalized, cwd/env overrides on terminal creation are rejected, and terminals are not created after the query aborts. Manager disposal runs on both the error path (early) and in finally.
  • Safe-filesystem callbacks: fs/read_text_file / fs/write_text_file route through the workspace-confined safe-fs layer with a 4 MiB read cap, line/limit ranges, realpath-aware boundary checks, and abort-aware writes. Workspace-less sessions register no host callbacks and fall back to process.cwd() for the agent cwd.
  • Bypass permissions: session/request_permission from the agent is auto-allowed (first allow_* option) — the same trust model the Claude SDK path runs under. The AskUserQuestion-based ACP approval gate that was on dev is removed; the unified approval/permission UX for both providers is deferred design work tracked in ACP security hardening (approval gating + command redaction) — built, intentionally not shipping yet #2782.
  • 7 new/ported tests: workspace-escape rejection, read ranges + write containment, workspace-less sessions, terminal env allowlist, override rejection, post-abort cancellation, auto-allowed permissions.

Deliberately not here

Extracted from #2711.

Verification

  • bun test tests/unit/lib/acp/acp-query-runner.test.ts — 54/54 (includes real-subprocess terminal test at a 20s budget)
  • oxlint, tsc --build --noEmit, knip, pinned-biome format — clean
  • Full tests/unit/lib/acp/ sandbox run matches the pre-existing environmental baseline (AcpClient/mock-server noise) except the real-subprocess allowlist test, which passes in isolation and hangs only in the sandbox's polluted full-dir run; CI shard boundaries differ and ran this suite green on the source branch

Open in Devin Review

Wire the ACP terminal manager and safe-filesystem host callbacks into
query startup when the session has a workspace: terminals run with an
allowlisted environment and inherit the process-tree owner, filesystem
reads and writes are confined to the workspace with size and range
limits, and cwd or env overrides on terminal creation are rejected.
Permission requests from the agent are auto-allowed, matching the
bypass-permissions trust model the SDK path already uses; the
AskUserQuestion approval plumbing for ACP moves to the deferred unified
permission UX (#2782).

Extracted from #2711 (ACP split 8/10).
@lsm

lsm commented Aug 23, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e043635fdc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

this.ctx.trackAgentProcess(proc as unknown as TrackedAgentProcess),
onStderr: (data) => logger.warn(`ACP agent stderr: ${data.trimEnd()}`),
onPermissionRequest: (params) => handleAcpPermissionRequest(params, canUseTool),
onPermissionRequest: allowAcpPermissionRequest,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Respect non-bypass permission modes

When the session or global permission mode is acceptEdits, dontAsk, or plan, QueryOptionsBuilder preserves that value in queryOptions.permissionMode, but this unconditional handler still selects an allow option for every ACP permission request. Consequently, an ACP agent can receive approval for terminal execution or filesystem writes despite the user's restrictive setting; only auto-allow when the effective mode is bypassPermissions, and retain approval/denial behavior for other modes.

Useful? React with 👍 / 👎.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

…not load

The safe-fs FFI backend fails to load inside some CI shard processes
where a native-library sibling test poisons the dynamic loader; the
backend itself stays covered by its dedicated suite. Probe the backend
before the two wiring tests instead of failing the shard, and apply
canonical import formatting.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@lsm

lsm commented Aug 23, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@lsm
lsm merged commit b565076 into dev Aug 23, 2026
51 checks passed
@lsm
lsm deleted the space/acp-split-8c-bypass-callbacks branch August 23, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant