feat: Add CapiscIO.connect() for Let's Encrypt-style agent setup#26
feat: Add CapiscIO.connect() for Let's Encrypt-style agent setup#26
Conversation
- Add connect.py with CapiscIO.connect() and CapiscIO.from_env() - Add events.py with EventEmitter for agent observability - AgentIdentity dataclass with emit(), get_badge(), status() methods - Auto-discover agent, generate keys via gRPC, register DID - Update quickstart docs with new one-liner setup - Regenerate proto bindings with Init RPC support
|
✅ Documentation validation passed!
|
There was a problem hiding this comment.
Pull request overview
This PR implements a "Let's Encrypt" style one-liner agent setup for the CapiscIO Python SDK, significantly simplifying the onboarding process. The new CapiscIO.connect() method automates key generation, DID derivation, server registration, and badge setup. Additionally, it introduces event emission capabilities for observability.
Changes:
- Added
CapiscIO.connect()andCapiscIO.from_env()for simplified agent identity setup - Added
EventEmitterclass with batching for efficient event emission to the registry - Regenerated proto bindings to support the new Init RPC in SimpleGuardService
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 26 comments.
Show a summary per file
| File | Description |
|---|---|
capiscio_sdk/connect.py |
New module implementing "Let's Encrypt" style agent setup with CapiscIO.connect() and AgentIdentity dataclass |
capiscio_sdk/events.py |
New module providing event emission to registry with batching and standard event types |
capiscio_sdk/_rpc/client.py |
Added init() method to SimpleGuardClient for one-call identity initialization |
capiscio_sdk/_rpc/gen/capiscio/v1/*.py |
Regenerated proto bindings with Init RPC support and updated protobuf version (6.33.4→6.33.5) |
capiscio_sdk/__init__.py |
Exported new CapiscIO, connect, from_env, AgentIdentity, and EventEmitter APIs |
docs/getting-started/quickstart.md |
Updated quickstart with CapiscIO.connect() as Step 1, showing one-line setup |
pyproject.toml |
Added base58>=2.1.0 dev dependency for DID verification tests |
|
✅ Documentation validation passed!
|
- Fix BadgeKeeper.get_badge() -> get_current_badge() (2 places) - Fix proto import paths: from capiscio.v1 -> from capiscio_sdk._rpc.gen.capiscio.v1 - Remove unused json imports from connect.py and events.py
|
✅ Documentation validation passed!
|
|
✅ All checks passed! Ready for review. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
✅ Integration tests passed! Server validation, BadgeKeeper, and gRPC tests all working. |
- Add 32 tests for connect.py (AgentIdentity, CapiscIO.connect, from_env, _Connector) - Add 28 tests for events.py (EventEmitter, global functions) - Improve patch coverage for new Let's Encrypt-style setup feature
|
✅ Documentation validation passed!
|
|
✅ Integration tests passed! Server validation, BadgeKeeper, and gRPC tests all working. |
|
✅ Documentation validation passed!
|
|
✅ All checks passed! Ready for review. |
|
✅ Integration tests passed! Server validation, BadgeKeeper, and gRPC tests all working. |
- Add tests for full connect() flow with/without badge - Add tests for _ensure_agent error paths - Add tests for _create_agent edge cases - Add tests for _init_identity with RPC and existing files - Add tests for _setup_badge success and failure - Coverage improved from 63% to 99% for connect.py
|
✅ Documentation validation passed!
|
|
✅ Integration tests passed! Server validation, BadgeKeeper, and gRPC tests all working. |
…leanup - connect.py: Add AgentIdentity.close() for resource cleanup - connect.py: Add finally block in connect() to close httpx/gRPC clients - connect.py: Sanitize error messages to not expose internal RPC details - connect.py: Fix badge_expires_at attribute access with hasattr - events.py: Add threading.Lock for thread-safe batch operations - events.py: Wrap emit() and flush() batch access with _batch_lock - test_connect.py: Remove unused PropertyMock import - test_events.py: Remove unused imports (time, datetime, timezone, _global_emitter)
|
✅ Documentation validation passed!
|
|
✅ Integration tests passed! Server validation, BadgeKeeper, and gRPC tests all working. |
Directly set _rpc_client on connector instead of patching, avoids naming conflict between capiscio_sdk.connect module and CapiscIO.connect method
|
✅ Documentation validation passed!
|
|
✅ All checks passed! Ready for review. |
|
✅ Integration tests passed! Server validation, BadgeKeeper, and gRPC tests all working. |
Summary
Implements a "Let's Encrypt" style one-liner setup for Python SDK.
CapiscIO.connect()handles everything automatically: key generation, DID derivation, server registration, and badge setup.Usage
Or from environment variables:
Changes
New Modules
connect.py(~395 lines)CapiscIO.connect()- Main entry pointCapiscIO.from_env()- Environment variable configurationAgentIdentitydataclass with methods:emit()- Emit events to registryget_badge()- Get current badge (auto-renewed)status()- Get agent status dictevents.py(~319 lines)EventEmitterclass with batching for efficient event emissionagent_started,task_started,task_completed, etc.Proto Updates
Documentation
CapiscIO.connect()as Step 1Two Setup Paths
CapiscIO.connect(api_key="...")CapiscIO.connect(api_key="...", agent_id="agt_123")Dependencies
Added
base58>=2.1.0to dev dependencies for DID verification tests.Related PRs
capiscio initcommand