Skip to content

feat(sdk/rust): add ContactsApi for the DM permission graph#208

Merged
sanil-23 merged 1 commit into
tinyhumansai:mainfrom
sanil-23:feat/rust-sdk-contacts
Jul 2, 2026
Merged

feat(sdk/rust): add ContactsApi for the DM permission graph#208
sanil-23 merged 1 commit into
tinyhumansai:mainfrom
sanil-23:feat/rust-sdk-contacts

Conversation

@sanil-23

@sanil-23 sanil-23 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

What

Adds ContactsApi to the Rust SDK, exposed as client.contacts. Ports the contact graph from the TypeScript SDK (sdk/typescript/src/api/contacts.ts): request, accept, remove, block, status, list, requests.

Why

An accepted contact relationship is the prerequisite for direct messaging — the relay rejects a DM between non-contacts with not_a_contact. The Rust SDK had no contacts surface at all, so a Rust client (e.g. the OpenHuman core) could resolve a recipient's key and encrypt a message but could never establish the contact edge required to send it. This closes that gap so the Rust SDK reaches parity with the TS SDK for the send bootstrap:

client.contacts.request("@peer").await?;      // initiator
client.contacts.accept("@initiator").await?;  // peer (or auto-accept on reverse-pending)
client.messages.send(envelope).await?;         // now permitted

How

  • New sdk/rust/src/api/contacts.rs mirroring contacts.ts (agent-authenticated; contacts keyed by cryptoId). Responses are returned as serde_json::Value (callers don't need the typed record yet).
  • Wired pub contacts: ContactsApi into TinyPlaceClient (client.rs) and pub mod contacts; (api/mod.rs).

Testing

  • cargo check (standalone, toolchain 1.93) is green.
  • Verified end-to-end against staging: a Rust client (OpenHuman) sent a contact request via client.contacts.request(...) (status: pending), a plugin peer accepted it, and client.contacts.list() then reported the edge as accepted.

Ports the contact graph from the TS SDK (sdk/typescript/src/api/contacts.ts):
request / accept / remove / block / status / list / requests, wired as
client.contacts on TinyPlaceClient.

An accepted contact relationship is the prerequisite for direct messaging
(the relay rejects a DM between non-contacts with not_a_contact), and the
Rust SDK had no way to establish one — so a Rust client could resolve keys
and encrypt but could never send a DM.
@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

@sanil-23 is attempting to deploy a commit to the Vezures Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6bab079a-acd8-4181-b328-7b4e63aec2a0

📥 Commits

Reviewing files that changed from the base of the PR and between d641e1b and dd4755b.

📒 Files selected for processing (3)
  • sdk/rust/src/api/contacts.rs
  • sdk/rust/src/api/mod.rs
  • sdk/rust/src/client.rs
👮 Files not reviewed due to content moderation or server errors (3)
  • sdk/rust/src/api/contacts.rs
  • sdk/rust/src/client.rs
  • sdk/rust/src/api/mod.rs

📝 Walkthrough

[!WARNING]

Walkthrough skipped

File diffs could not be summarized.


Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dd4755b9dd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

}

/// Block `agent_id`, suppressing the relationship and refusing new requests.
pub async fn block(&self, agent_id: &str) -> Result<serde_json::Value> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add the unblock wrapper alongside block

When a Rust client uses this new block() method, the SDK has no corresponding wrapper for POST /contacts/{id}/unblock, even though the mirrored TypeScript API exposes unblock() at sdk/typescript/src/api/contacts.ts:71. In the blocked-contact scenario, Rust callers cannot restore the relationship through client.contacts and must drop to raw client.http(), making this newly added contact graph surface one-way for users who need to resume messaging.

Useful? React with 👍 / 👎.

@sanil-23 sanil-23 merged commit 3553014 into tinyhumansai:main Jul 2, 2026
9 of 10 checks passed
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