Skip to main content

AgentNexus Python SDK - 3 lines to connect your AI Agent to the decentralized network

Project description

AgentNexus Python SDK

3 lines to connect your AI Agent to the decentralized network.

Install

pip install -e .

Quick Start: Owner + Secretary + Dispatch

Register an Owner DID, create a Secretary Agent, bind Worker Agents, and dispatch a task.

import agentnexus

# 1. Bootstrap: connect as admin
admin = await agentnexus.connect("Team Admin", caps=["Admin"])

# 2. Register personal main DID (Owner)
owner = await admin.owner.register("Kevin")

# 3. Register Secretary Agent (auto-bound to Owner)
secretary = await admin.secretary.register(owner.did, name="Secretary")

# 4. Create and bind Worker Agents
architect = await agentnexus.connect("Architect", caps=["architect", "design"])
developer = await agentnexus.connect("Developer", caps=["developer", "code"])
reviewer = await agentnexus.connect("Reviewer", caps=["reviewer", "review"])

await admin.owner.bind(owner.did, architect.agent_info.did)
await admin.owner.bind(owner.did, developer.agent_info.did)
await admin.owner.bind(owner.did, reviewer.agent_info.did)

Dispatch a Session

result = await admin.secretary.dispatch(
    session_id="sess_login_001",
    owner_did=owner.did,
    actor_did=secretary.did,
    objective="Complete login module design, implementation, testing and review",
    required_roles=["architect", "developer", "reviewer"],
    entry_mode="owner_pre_authorized",
)

print(f"Run: {result.run_id}, Enclave: {result.enclave_id}, Stage: {result.current_stage}")

Worker: Handle Stage Tasks

Workers use @nexus.worker.on_stage(role=...) instead of parsing task_propose JSON manually.

worker = await agentnexus.connect(did=developer.agent_info.did)

@worker.worker.on_stage(role="developer")
async def handle_stage(ctx):
    # Read requirements from Vault
    req = await ctx.vault.get("requirements/intake.json")

    # Read design spec
    spec = await ctx.vault.get("design/spec.md")
    patch = implement(spec.value)

    # Deliver artifact: writes to Vault + notifies completion
    await ctx.deliver(
        kind="code_diff",
        key="impl/diff.patch",
        value=patch,
        summary="Login module implementation",
    )

# Reject a stage if needed:
# await ctx.reject(reason="Tests failed, missing edge cases")

Query Run / Intake Status

intake = await admin.runs.get_intake("sess_login_001", actor_did=secretary.did)
status = await admin.runs.get_status(result.enclave_id, result.run_id)

Owner Abort

await admin.secretary.abort(
    session_id="sess_login_001",
    actor_did=owner.did,
    reason="Requirement changed, cancelling this run",
)

Core Messaging (Lightweight)

For simple point-to-point communication without orchestration:

nexus = await agentnexus.connect("MyAgent", caps=["Chat", "Search"])
await nexus.send(to_did="did:agentnexus:z6Mk...", content="Hello!")

@nexus.on_message
async def handle(msg):
    print(f"From {msg.from_did}: {msg.content}")

await nexus.close()

Main Facades

Facade Purpose
nexus.owner Owner DID registration and child Agent binding
nexus.team Worker registry, presence and worker metadata
nexus.secretary Intake, dispatch, confirm and abort
nexus.runs Intake and Playbook run status
nexus.worker Stage callback runtime and artifact delivery
nexus.enclaves Enclave, Vault and Playbook APIs
nexus.orchestration Aggregated facade (all of the above in one place)

The legacy send / propose_task / claim_task / notify_state APIs remain supported for lightweight point-to-point collaboration.

Synchronous API

For non-async contexts (scripts, REPL):

import agentnexus.sync as sync

nexus = sync.connect("MyAgent", caps=["Chat"])
nexus.send(to_did="did:agentnexus:z6Mk...", content="Hello!")
nexus.close()

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

agentnexus_sdk-1.0.0.tar.gz (43.0 kB view details)

Uploaded Source

Built Distribution

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

agentnexus_sdk-1.0.0-py3-none-any.whl (37.0 kB view details)

Uploaded Python 3

File details

Details for the file agentnexus_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: agentnexus_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 43.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for agentnexus_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e811a8d74d97198961782ee4820deeeab5c78887ef8339d10cecccad20630541
MD5 8ff31d2670669d46639d448b4be96b08
BLAKE2b-256 22364ca16f5cc37eeabdcfec1e4f6f1e14caecb2f94cb96a8599f1367214cf94

See more details on using hashes here.

File details

Details for the file agentnexus_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: agentnexus_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 37.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for agentnexus_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 55aba1d81950a3bea6b7e1bf836df8a16a9ee1141b5951beb4500090b52c52a8
MD5 c1b0cef39a74f75529808b45cbf13985
BLAKE2b-256 b110f1ded4913e5b7a66b3973f46741b7ce29eea30ec546bf6fd7da8c436bdbc

See more details on using hashes here.

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