From 8ef77d96ef6accb3eea00c0806ca1cc6587ad939 Mon Sep 17 00:00:00 2001 From: Benjamin McCormick Date: Fri, 6 Feb 2026 14:31:03 -0500 Subject: [PATCH] chore: review nits --- sdks/python/src/honcho/aio.py | 16 ++++++++++++++-- sdks/python/src/honcho/peer.py | 1 - sdks/typescript/src/peer.ts | 4 +++- sdks/typescript/src/validation.ts | 5 +++++ tests/crud/test_peer_card.py | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/sdks/python/src/honcho/aio.py b/sdks/python/src/honcho/aio.py index 75a09bdc..aa851889 100644 --- a/sdks/python/src/honcho/aio.py +++ b/sdks/python/src/honcho/aio.py @@ -605,7 +605,6 @@ class PeerAio(AsyncMetadataConfigMixin): response = PeerCardResponse.model_validate(data) return response.peer_card - @validate_call(config=ConfigDict(arbitrary_types_allowed=True)) async def card( self, target: str | PeerBase | None = None, @@ -625,7 +624,20 @@ class PeerAio(AsyncMetadataConfigMixin): peer_card: list[str], target: str | PeerBase | None = None, ) -> list[str] | None: - """Set the peer card asynchronously.""" + """ + Set the peer card for this peer. + + Makes an API call to set the peer card. If a target is provided, sets this + peer's local card of the target peer. + + Args: + peer_card: A list of strings to set as the peer card. + target: Optional target peer for local card. If provided, sets this + peer's card of the target peer. Can be a Peer object or peer ID string. + + Returns: + A list of strings representing the updated peer card, or None if none is available + """ await self._peer._honcho._ensure_workspace_async() target_id = resolve_id(target) diff --git a/sdks/python/src/honcho/peer.py b/sdks/python/src/honcho/peer.py index c58eabc2..5984737b 100644 --- a/sdks/python/src/honcho/peer.py +++ b/sdks/python/src/honcho/peer.py @@ -477,7 +477,6 @@ class Peer(PeerBase, MetadataConfigMixin): return response.peer_card - @validate_call(config=ConfigDict(arbitrary_types_allowed=True)) def card( self, target: str | PeerBase | None = None, diff --git a/sdks/typescript/src/peer.ts b/sdks/typescript/src/peer.ts index 0fb4dfa6..65567ad5 100644 --- a/sdks/typescript/src/peer.ts +++ b/sdks/typescript/src/peer.ts @@ -28,6 +28,7 @@ import { MessageConfigurationSchema, MessageContentSchema, MessageMetadataSchema, + PeerCardContentSchema, type PeerConfig, PeerConfigSchema, PeerGetRepresentationParamsSchema, @@ -697,9 +698,10 @@ export class Peer { peerCard: string[], target?: string | Peer ): Promise { + const validatedPeerCard = PeerCardContentSchema.parse(peerCard) const validatedTarget = CardTargetSchema.parse(target) const response = await this._setCard({ - peer_card: peerCard, + peer_card: validatedPeerCard, target: validatedTarget, }) return response.peer_card diff --git a/sdks/typescript/src/validation.ts b/sdks/typescript/src/validation.ts index 3a5e8584..829699ca 100644 --- a/sdks/typescript/src/validation.ts +++ b/sdks/typescript/src/validation.ts @@ -376,6 +376,11 @@ export const CardTargetSchema = z val ? (typeof val === 'string' ? val : val.id) : undefined ) +/** + * Schema for peer card content (array of strings). + */ +export const PeerCardContentSchema = z.array(z.string()) + /** * Schema for peer addition to session. */ diff --git a/tests/crud/test_peer_card.py b/tests/crud/test_peer_card.py index ae3e954e..2b00d56e 100644 --- a/tests/crud/test_peer_card.py +++ b/tests/crud/test_peer_card.py @@ -53,7 +53,7 @@ async def test_peer_card_get_set_roundtrip( async def test_get_peer_card_missing_peer_returns_none( db_session: AsyncSession, sample_data: tuple[models.Workspace, models.Peer] ): - """Getting a peer card for a non-existent peer should return None.""" + """Getting a peer card for a non-existent peer should return None while creating the peer.""" workspace, _existing_peer = sample_data result = await get_peer_card( db_session,