Skip to main content

Python SDK for Rare Identity agent flows

Project description

rare-agent-sdk-python

Python SDK and CLI for Agent identity flows on Rare.

当前 SDK 的本地 Python 依赖只包含 rare-identity-protocol,不再依赖整个 rare-identity-core 服务包。

Features

  • Self register (hosted-signer or self-hosted)
  • Set name (signed)
  • Refresh public attestation
  • Full attestation issue for registered platform
  • Human-in-the-loop upgrades (L1 email magic link, L2 social connect)
  • Challenge login via third-party platform
  • Delegation/session/action signing via hosted Rare signer or local self-hosted key
  • Self-hosted private key stored in separate key file (~/.config/rare/keys/<agent_id>.key, mode 0600)
  • Optional local signer daemon (rare-signer) so SDK process signs via IPC without loading private key

Install

pip install rare-agent-sdk

如果你要接入 Rare 托管服务,默认 Rare API URL 可配置为:

https://api.rareid.cc

可复现依赖安装(本仓开发):

pip install -r requirements-test.lock
pip install -e .[test] --no-deps

本地开发时可额外安装协议包:

(cd ../rare-identity-protocol-python && pip install -e .)
pip install -e .[test]

Configuration

  • CLI / SDK 连接公开 Rare 服务:
rare show-state --rare-url https://api.rareid.cc
  • 本地联调时,你也可以把 --rare-url 指向自建 Rare Core API,例如:
http://127.0.0.1:8000

CLI 默认 --rare-url 不需要额外加 /rare 前缀。

CLI

# terminal A: start local signer
rare-signer

# terminal B: self-hosted register/login via signer IPC
rare register --name alice
rare register --name alice --key-mode self-hosted
rare request-upgrade --level L1 --email alice@example.com
# resend magic link if needed
rare send-l1-link --request-id <request_id>
rare upgrade-status --request-id <request_id>
rare recovery-factors
rare recover-hosted-token-email
rare recover-hosted-token-email-verify --token <token>
rare recover-hosted-token-social-start --provider github
rare show-state --paths
rare request-upgrade --level L2
rare start-social --request-id <request_id> --provider github
rare issue-full-attestation --aud platform
rare login --aud platform --platform-url http://127.0.0.1:8000/platform
rare login --aud platform --public-only
rare set-name --name alice-v2
rare refresh-attestation
rare show-state

SDK

from rare_agent_sdk import AgentClient, AgentState

state = AgentState()
client = AgentClient(state=state)
client.register(name="agent-1")
upg = client.request_upgrade_l1(email="owner@example.com")
sent = client.send_l1_upgrade_magic_link(request_id=upg["upgrade_request_id"])  # optional resend
client.verify_l1_upgrade_magic_link(token=sent["token"])
client.get_hosted_management_recovery_factors()
recovery = client.send_hosted_management_recovery_email_link()
client.verify_hosted_management_recovery_email(token=recovery["token"])
client.login(aud="platform")
signed = client.sign_platform_action(action="post", action_payload={"content": "hello"})

Test

pytest -q

Related Docs

  • 协议与 RIP 文档:Rare-ID/rare-protocol-py
  • 平台接入 SDK:Rare-ID/rare-platform-ts

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rare_agent_sdk-0.2.0.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rare_agent_sdk-0.2.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file rare_agent_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: rare_agent_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rare_agent_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 da0cd25ce3e4c96ad2021b7482c4b0d257326227b6023916f68dde2e20c8e125
MD5 0122cb52056a731ef5d65853f3ebb745
BLAKE2b-256 86e9d7438faa3e4b4d07464c6de1227cdd40209865cdb5786a871bde35198f6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rare_agent_sdk-0.2.0.tar.gz:

Publisher: publish.yml on Rare-ID/rare-agent-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rare_agent_sdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: rare_agent_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rare_agent_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 74b5f05f9a40ef8b881915797ee26e581d04a56886e5b3ea1f5c2c369a06e4dc
MD5 e53e1abb70ff728adf6701a7a887c813
BLAKE2b-256 c7d35f6f0846354678b83c5257a1e187b475720962a5964f9fdd57fc922f32c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for rare_agent_sdk-0.2.0-py3-none-any.whl:

Publisher: publish.yml on Rare-ID/rare-agent-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page