Skip to content

feat(acp): Gateway-backed ACP server implementation#122

Closed
visionik wants to merge 23 commits intoopenclaw:mainfrom
visionik:main
Closed

feat(acp): Gateway-backed ACP server implementation#122
visionik wants to merge 23 commits intoopenclaw:mainfrom
visionik:main

Conversation

@visionik
Copy link
Copy Markdown
Contributor

@visionik visionik commented Jan 3, 2026

Summary

Implements a complete ACP (Agent Client Protocol) server that delegates to the Clawdis Gateway.

Features

  • ACP lifecycle (initialize, newSession, authenticate)
  • Prompt/response with streaming text deltas
  • Tool call event streaming (tool_call, tool_call_update)
  • Image attachment support
  • Session persistence to disk
  • Auto-reconnect on Gateway disconnect (5 attempts, exponential backoff)
  • Session isolation via acp: namespace prefix

Files

  • src/acp/ - Server, translator, session manager, types
  • docs/acp.md - Full documentation

Tests

  • 65 tests for acp module
  • 81% line coverage
  • Unit tests for session and translator
  • Integration tests with real Gateway

Binaries

  • clawdis-acp - Main binary
  • pnpm acp - Dev script

- Add src/acp/ module with ClawdisAgent, AcpSessionAdapter, and stdio server
- Plug into getReplyFromConfig() like Discord/Telegram/WhatsApp connectors
- Add clawd-acp binary entry point for IDE integration
- Include 8 unit tests for agent lifecycle methods
- Uses @agentclientprotocol/sdk for JSON-RPC transport

See: https://agentclientprotocol.com
- Add clawd-acp-client binary for testing without an IDE
- Spawns clawd-acp, initializes, creates session, interactive prompt loop
- Auto-approves permission requests for testing
- Supports --cwd, --agent, --verbose flags

See: https://agentclientprotocol.com
- Add acp-gw module: thin ACP server that delegates to Gateway via WebSocket
- Fix ACP session blocking: use sessionKey as lane for parallel execution
- Add --trace-sessions flag for debugging session/lane routing
- Document architecture and concurrency fix in docs/acp-gw.md

The key fix: ACP sessions now use their own lane (e.g., acp:sessionId) instead
of the global 'main' lane, allowing them to run concurrently with the main
conversation session.
- Track cumulative text to only send new characters (not full text each time)
- Detect and skip duplicate text when Gateway sends response twice
- Fixes double-printing in ACP client output
- Extract image content blocks from ACP prompts
- Pass as attachments to Gateway chat.send
- Images use base64 data with mimeType
- Add runId -> sessionId reverse lookup for agent event correlation
- Handle tool stream events (phase: start/result)
- Send tool_call and tool_call_update session updates
- Reject all pending prompts when Gateway disconnects
- Clean up session state on disconnect
- Log disconnect reason
- Retry connection up to 5 times with exponential backoff
- Update Gateway client reference on reconnect
- Reset attempt counter on successful connection
- Session manager tests (create, get, delete, active runs)
- Translator tests (initialize, newSession, auth, disconnect/reconnect)
- 21 tests total, all passing
- Document streaming (text, tools, delta diffing)
- Document attachments, reconnection, abort
- Add Limitations section (MCP servers, session persistence)
- Add CLI options reference
- Update file listing with tests
- Sessions persist to ~/.clawdis/acp-gw-sessions.json by default
- Add --session-store and --no-session-store CLI options
- Sessions survive acp-gw restart (Gateway keeps conversation history)
- Add persistence tests (4 new tests, 27 total)
- Test gateway connection
- Test session creation (single and multiple)
- Test disconnect handling with callback wiring
- Test authentication
- 5 integration tests, 32 total acp-gw tests
- Add tests for setSessionMode, prompt, cancel
- Add tests for handleGatewayEvent (tool start/result/error)
- Add tests for handleChatEvent (delta, final, aborted)
- Add tests for text deduplication, image extraction
- Add verbose logging test
- Coverage: translator.ts 15% → 88%, overall 30% → 66%
- 52 tests total (was 32)
- Add full lifecycle integration tests
- Add setSessionMode, cancel, reconnection tests
- Add error handling tests (unknown session, loadSession)
- Add verbose mode test
- Add server module test
- 62 tests total, 78.78% line coverage (target: 75%)
- Test prompt/response with streaming
- Test tool use events (tool_call, tool_call_update)
- Test prompt cancellation
- Handle various model responses (end_turn, refusal)
- 65 tests total, 80.8% line coverage
Users can now run:
- pnpm acp-gw (local dev)
- clawd-acp-gw (when installed globally)
- Remove src/acp/ (non-gateway ACP implementation)
- Point clawd-acp binary to acp-gw/server.js
- Single ACP implementation via Gateway
- src/acp-gw → src/acp
- docs/acp-gw.md → docs/acp.md
- Update all internal references
- Add module-level documentation with architecture overview
- Document all public functions with @param, @returns, @example
- Add inline comments explaining key logic
- Update agent name to clawdis-acp in types and tests
- Show tool name with full args in Toad (e.g., 'bash: command: ls')
- Skip duplicate Gateway tool start events (second event lacks args)
- Wait for both job:done AND state=final before resolving prompts
- Use startedAt timestamp to correctly match job events across prompts
- Disable keepalive dots (tool updates provide sufficient activity)
- Add detailed logging for tool events

Note: Code may be messy due to extensive debugging of Gateway event
timing corner cases. Will be cleaned up tomorrow.
- Add resolvedSessionKeys Set to ignore events after session resolution
- Clear resolved marker when new prompt starts on same session
- Improve delta dedup logging for debugging
- Fixes issue where subsequent prompts on same session were blocked
@steipete
Copy link
Copy Markdown
Contributor

Haven't forgotten about this, just too many fires!

@steipete
Copy link
Copy Markdown
Contributor

Took me longer than I wanted, but finally landed - thank you!

@steipete
Copy link
Copy Markdown
Contributor

Thanks @visionik! We already landed ACP support in main. Implemented across:

  • de3b687 feat(acp): add experimental ACP support
  • 9809b47 feat(acp): add interactive client harness
  • 65bed81 fix: resolve ci failures
  • 9241e21 fix: address acp client typing
  • b739a38 fix: stabilize acp streams and tests

Closing this PR as already implemented. Appreciate the work!

@steipete steipete closed this Jan 18, 2026
@visionik
Copy link
Copy Markdown
Contributor Author

Outstanding. Thank you @steipete and Clawd!

dgarson referenced this pull request in dgarson/clawdbot Feb 7, 2026
voice-call: use fromNumber for Twilio webhook sync
dgarson referenced this pull request in dgarson/clawdbot Feb 22, 2026
- WebhookPlayground: webhook test/replay tool (Reed agent)
  - Endpoint config, request body editor, response viewer, delivery history with 6+ entries
- SLAManager: SLA compliance tracking (Quinn agent)
  - 4 tabs: Overview/Definitions/Compliance Report/Incidents
  - 6 SLAs with compliance bars, monthly breach tracking
- DocumentationViewer: 3-column docs browser (Wes agent)
  - Nav tree, content area with headings/code blocks/callouts, TOC, search
github-actions bot pushed a commit to Piboonsak/openclaw_github that referenced this pull request Mar 11, 2026
Piboonsak added a commit to Piboonsak/openclaw_github that referenced this pull request Mar 12, 2026
- Add safeBinProfiles.gh and .git to config/openclaw.prod.json5 (WS-B)
  * Fixes config drift that blocked exec path and forced approval fallback
  * Profiles allow git clone/pull, gh issue/pr operations
  * Reduces outbound message bursts that trigger LINE rate limits

- Add exponential backoff + jitter retry to LINE exec-approvals (WS-D)
  * Retries template send with 3 attempts, baseDelay 300ms, max 5s
  * Retries fallback text with 2 attempts, baseDelay 500ms, max 3s
  * Only retries on transient errors (429, 5xx, network timeouts)
  * Spreads requests over time to avoid burst rate limits

- Add backoff retry to heartbeat runner (WS-D)
  * Wraps deliverOutboundPayloads calls with retry logic
  * 2 attempts, baseDelay 500ms, max 5s for heartbeat pings
  * Handles transient rate limiting gracefully

Fixes openclaw#122 (LINE 429 bursts)
Addresses openclaw#97 #101 (exec allow list reliability)
zhyongrui added a commit to zhyongrui/openclaw that referenced this pull request Mar 20, 2026
0x666c6f added a commit to 0x666c6f/openclaw that referenced this pull request Mar 26, 2026
…#122)

* fix(slack:PLA-950): guard numeric summary totals

* fix(slack:PLA-950): validate final replies against evidence

* fix(slack:PLA-950): address PR review findings

* fix(slack:PLA-950): harden evidence reply validation

* fix(slack:PLA-950): tighten evidence provenance guards

* fix(slack:PLA-950): bound evidence fact parsing

* fix(slack:PLA-950): tighten evidence-backed total reconciliation

* fix(slack:PLA-950): harden summary evidence parsing

* build(ui): bump vite to fix prod audit

* fix(slack): harden numeric token parsing
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.

2 participants