Skip to content

cleanup component trait, access connection_cx explicitly#30

Merged
nikomatsakis merged 3 commits intoagentclientprotocol:mainfrom
nikomatsakis:main
Nov 12, 2025
Merged

cleanup component trait, access connection_cx explicitly#30
nikomatsakis merged 3 commits intoagentclientprotocol:mainfrom
nikomatsakis:main

Conversation

@nikomatsakis
Copy link
Contributor

No description provided.

nikomatsakis and others added 3 commits November 12, 2025 05:44
- Rename Channels → Channel (singular) to represent one endpoint
- Add Channel::duplex() to create connected channel pairs
- Make both rx and tx use Result<Message, Error> for consistency
- Add Component::serve(client) method for composing components
- Add Component::into_server() to convert component to channel + future
- Update connect_to() to use into_server() avoiding extra channel copies
- Update all Component implementations across workspace
- Update all tests to use new API

This refactoring eliminates unnecessary channel copying when components
are connected together, improving performance and API clarity.

Co-authored-by: Claude <claude@anthropic.com>
Add comprehensive documentation covering three common usage patterns:
1. Defining reusable components with Component trait
2. Creating custom message handlers with JrMessageHandler
3. Connecting as a client with with_client

Also document JrRequestCx capabilities and the importance of avoiding
blocking in message handlers.

Co-authored-by: Claude <claude@anthropic.com>
This change requires users to explicitly call connection_cx() when they
want to perform connection-level operations (send_request, send_notification,
spawn) from within a request handler. This makes the API more explicit and
helps users understand when they're performing connection operations versus
request-specific operations.

Updated all call sites across the codebase:
- sacp/src/jsonrpc.rs: Removed Deref impl and updated doc examples
- sacp-proxy: Updated mcp_server.rs and to_from_successor.rs
- sacp-conductor: Updated conductor.rs and initialization_sequence test
- elizacp: Updated lib.rs

All tests pass after this change.

Co-authored-by: Claude <claude@anthropic.com>
@nikomatsakis nikomatsakis merged commit c4030d0 into agentclientprotocol:main Nov 12, 2025
1 check passed
@nikomatsakis nikomatsakis mentioned this pull request Nov 12, 2025
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