Skip to content

「WIP」Enhance WebMCP tool metadata, RPC reliability and add thread status services#4748

Open
lulusir wants to merge 157 commits into
mainfrom
feat/acp-v2
Open

「WIP」Enhance WebMCP tool metadata, RPC reliability and add thread status services#4748
lulusir wants to merge 157 commits into
mainfrom
feat/acp-v2

Conversation

@lulusir
Copy link
Copy Markdown
Contributor

@lulusir lulusir commented May 27, 2026

Types

  • 🎉 New Features
  • 🐛 Bug Fixes
  • 📚 Documentation Changes
  • 💄 Code Style Changes
  • 💄 Style Changes
  • 🪚 Refactors
  • 🚀 Performance Improvements
  • 🏗️ Build System
  • ⏱ Tests
  • 🧹 Chores
  • Other Changes

Background or solution

Changelog

Summary by CodeRabbit

发行说明

  • 新功能

    • 会话绑定权限对话框:权限请求现已关联到特定会话,多会话场景下避免弹窗丢失
    • 待处理权限提示:显示后台会话的权限待处理状态,支持任务切换后查看
    • WebMCP 工具组:新增文件、终端和编辑器操作工具集,扩展 IDE 能力
  • 改进

    • 线程状态可视化:聊天历史显示代理工作状态
    • 权限管理优化:移除超时自动过期,支持显式决策
  • 文档

    • 新增开发循环和场景验证规范文档

Review Change Stack

lulusir and others added 30 commits May 19, 2026 20:44
Extract hardcoded placeholder string in ACP chat view to use localize()
with i18n key, and update Chinese translation to be more concise.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Integrate ClientSideConnection from the official ACP SDK instead of
building a custom JSON-RPC transport layer. The SDK provides complete
JSON-RPC 2.0 implementation, NDJSON parsing, request queuing, error
handling, and type validation.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Plan for replacing custom JSON-RPC transport with
@agentclientprotocol/sdk's ClientSideConnection in the Node layer.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Fix 10 issues found during plan review:
- Runtime bugs: releaseTerminal operator precedence, ndJsonStream called
  before SDK loaded, uninitialized exitResolve variable
- Interface mismatches: setSessionMode return type, sendMessage missing
  config parameter, authenticate method missing
- Behavioral gaps: handler rewrite now notes workspace sandboxing
  preservation, permission options from agent request not hardcoded
- Add test plan with unit and integration test scenarios
- Add 3 new risk items to mitigation table

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… not per-connection

Replace "per WebSocket connection via childInjector" with accurate model:
single WS connection with RPC multiplexing, DI singleton services managing
one Agent process per workspace, AcpThread scoped per Agent session.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Complete IAcpThread interface with all lifecycle methods shown in architecture diagram
- Add AcpThreadFactory (useFactory pattern) to auto-inject dependencies
- Update AcpAgentService.createThread to use factory instead of manual new
- Renumber all tasks (1-7) and steps to match new task structure
- Fix subsection numbering consistency throughout

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…nection, and entry management

Implements the core Thread AI entity encapsulating agent process spawning,
@agentclientprotocol/sdk connection via dynamic ESM import (Node 16 compat),
entries state management, Client interface delegation, notification dispatch,
tool call state machine, and permission request forwarding.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Fixes 9 spec compliance deviations in AcpThread:

1. Entry data contracts use SDK types (ContentBlock, ToolCall, Plan)
   with data wrapper pattern instead of flattened primitives
2. Event model: replaced bulk entries_changed with granular
   entry_added/entry_updated events
3. markAssistantComplete(): no params — finds last assistant entry
   automatically, transitions status to awaiting_prompt
4. respondToToolCall(toolCallId, allowed: boolean): updates
   ToolCallEntry.status (completed/rejected), fires entry_updated
5. reset(): preserves _initialized flag for thread pool reuse
6. initialize(): accepts AgentProcessConfig parameter
7. sessionId: non-nullable string (empty when unbound)
8. Added setError(error): sets status to errored, fires events
9. handleNotification: made public per IAcpThread interface

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… instances

Add AcpThreadFactoryToken, AcpThreadFactory type, AcpThreadRuntimeConfig,
and AcpThreadFactoryProvider using OpenSumi DI useFactory pattern with
Injector-based dependency resolution. The factory accepts sessionId and
runtime config (command, args, cwd, env) at call time while injecting
file system handler, terminal handler, and permission caller via DI.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…tor plan

- Rewrite file-system handler: replace generic FileSystemRequest/Response
  with typed ReadTextFileRequest/Response and WriteTextFileRequest/Response,
  remove permissionCallback, getFileMeta, listDirectory, createDirectory
- Rewrite terminal handler: change method signatures to accept individual
  parameters (terminalId, sessionId) instead of request objects for
  getTerminalOutput, waitForTerminalExit, killTerminal, releaseTerminal
- Remove @Injectable decorator and permissionCallback from both handlers
- Update AcpThread Client and AcpAgentRequestHandler to call handlers
  with new signatures
- Fix pre-existing PlanEntry export error in index.ts
- Update tests to match new interfaces, remove obsolete test cases

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…support

Refactor the permission caller from a per-clientId static singleton pattern
(AcpPermissionCallerManager) to a proper DI singleton service
(AcpPermissionCallerService) that extends RPCService. Add a new
PermissionRoutingService to route permission requests from multiple ACP
sessions independently, with session registration, active session fallback,
and concurrent request support. Pass sessionId through the entire chain
from Node caller to browser dialog for multi-dialog tracking.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Replace the single-process model (AcpCliClientService + CliAgentProcessManager)
with a multi-thread pool architecture using AcpThread instances. Key changes:

- Thread pool management with sessions Map + threadPool array (max 10)
- findOrCreateThread with idle thread reuse logic
- createSession using Deferred pattern (no setTimeout polling)
- sendMessage with streaming via SumiReadableStream + thread.onEvent
- disposeSession with default (return to pool) and force (full dispose) modes
- stopAgent disposes all threads and clears pool
- AgentUpdate mapping from SDK sessionNotification events

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The AcpPermissionCallerService.requestPermission() signature now requires
sessionId as a second parameter. Update all call sites in
agent-request.handler.ts and corresponding test assertions.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… update DI bindings

- Replace AcpPermissionCallerManager with PermissionRoutingService in
  AcpThreadFactoryProvider so permission requests go through the routing layer
- Update AcpThreadOptions.permissionCaller to permissionRouting
- Update backServices to bind AcpPermissionServicePath to
  AcpPermissionCallerServiceToken instead of deprecated alias
- Update acp-thread.test.ts mock to match new permissionRouting interface

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…teSession

Previously createSession generated a fake uuid and passed it to
loadSessionOrNew, which failed and fell back to newSession. The real
sessionId from the agent CLI was stored in the thread but not used for
the sessions map or return value.

The new flow:
1. Find or create an idle thread without sessionId binding
2. Call thread.newSession() to get the real sessionId from the agent CLI
3. Register the thread with the real sessionId
4. Return the real sessionId to callers

Also adds error-handling cleanup in loadSession to prevent thread leaks
when initialization or loadSession fails on a newly created thread.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add setSessionMode, setSessionConfigOption, and unstable session
operations (fork, resume, close, setSessionModel) to IAcpThread
and AcpThread class. Also add 12 SDK type re-exports to acp-types.ts.

Unify cancel() to use ensureInitialized() for consistent error
behavior across all methods — previously it silently returned.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…nager, update AcpAgentService

Removes the deprecated CLI client and process manager classes that have
been superseded by the thread pool pattern. Cleans up DI bindings,
barrel exports, and associated test files. Updates AcpAgentService,
AcpChatAgent, and agent-types to align with the new architecture.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…pAgentService to AcpThread

AcpThread owns SDK notification format knowledge, so translating
SessionNotification into the legacy AgentUpdate stream format belongs
there. AcpAgentService now delegates to thread.toAgentUpdate() instead
of parsing SDK internals itself.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wrap thread.setSessionMode() in try/catch with warn logging, consistent
with cancelRequest pattern. Re-throw error so caller is notified of failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Track whether thread was newly created or reused. On failure:
- New thread: remove from pool and dispose
- Reused thread: reset to clean state
- Add error logging consistent with loadSession pattern

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wrap thread.setSessionConfigOption() in try/catch with warn logging,
consistent with setSessionMode pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…AcpThread

Expose four unstable_* methods from AcpThread through IAcpAgentService
without the unstable_ prefix, enabling session lifecycle management
(fork, resume, close) and model switching from the service layer.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Wrap fork/resume/close/setSessionModel delegations in try/catch with
warn logging, consistent with setSessionMode/setSessionConfigOption pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…erations

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…licate

Previously listSessions only read from the pool's this.sessions Map, which
could drift from the agent's actual state. Now it delegates to each active
thread's listSessions() method, merges results with Set deduplication, and
catches per-thread errors with warn logging.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ionInfo type

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@lulusir
Copy link
Copy Markdown
Contributor Author

lulusir commented Jun 4, 2026

/next

@opensumi
Copy link
Copy Markdown
Contributor

opensumi Bot commented Jun 4, 2026

🎉 PR Next publish successful!

3.9.1-next-1780542952.0

lulusir and others added 17 commits June 4, 2026 14:21
Remove unnecessary timeout/retry logic from ACP initialization. The fallback
mechanism (ready() polling capped at 10s + catch block falling back to
fallbackToLocal()) already guarantees initialization never hangs forever,
making the 30s timeout and retry button dead weight.

Changes:
- Remove timedOut state, retryKey state, and timeoutTimer
- Remove handleRetry function and retry button from loading UI
- Change useEffect dependency from [retryKey] to [] (mount once)
- Keep cancelledRef for unmount cleanup
These classes were used only by the retry UI removed from
AcpChatViewWrapper.tsx. Grep confirmed no other component
references timeout_hint or retry_button in the ai-native package.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Evidence artifacts (screenshots, JSON dumps, issue reports) were mixed
with scenario definitions in test/bdd/. Move them to test/bdd/evidence/
and add a local .gitignore so future /bdd-run outputs stay untracked.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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