Skip to content

feat(opencode): emit permission_asked events in --format json headless mode - #39460

Open
baizhu945 wants to merge 1 commit into
anomalyco:devfrom
baizhu945:json-permission-events
Open

feat(opencode): emit permission_asked events in --format json headless mode#39460
baizhu945 wants to merge 1 commit into
anomalyco:devfrom
baizhu945:json-permission-events

Conversation

@baizhu945

Copy link
Copy Markdown

Issue for this PR

Closes #39459

Type of change

  • New feature

What does this PR do?

When OpenCode runs in --format json non-interactive headless mode, it auto-rejects all permission requests without emitting them to stdout. External tools like cc-connect cannot relay permission verification cards to users.

This PR enables permission_asked NDJSON events in --format json mode:

  • Skips reading the prompt from stdin (passed as positional arg instead), keeping stdin free for permission replies
  • Emits permission_asked JSON event with full permission details (id, permission name, patterns, metadata)
  • Reads JSON permission reply from stdin with 120s timeout (defaults to reject)

How did you verify your code works?

Tested end-to-end with a patched cc-connect + Telegram bot. In non-yolo --format json mode, OpenCode now emits permission_asked events, waits for stdin replies, and correctly resumes tool execution after receiving allow/deny responses. Non-JSON-format mode behavior is unchanged.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…s mode

When OpenCode runs in --format json non-interactive mode, emit
permission_asked NDJSON events to stdout and accept permission
replies via stdin instead of auto-rejecting all permission
requests. This enables external tools (e.g. cc-connect) to relay
permission verification cards to messaging platforms.

Closes anomalyco#39459
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.

[FEATURE]: --format json mode should emit permission_asked events for headless integrations

1 participant