Python SDK for AgentBox private agent state and scoped sharing.
Project description
AgentBox Python SDK
Python SDK for AgentBox private agent state and scoped sharing.
Use the public production service at https://agentbox.niuniu.dev/ for Agent
Card discovery and SDK integration. Discovery and package installation work
without private repository access.
Install
python3 -m pip install niuniu-agentbox
Import the SDK as agentbox:
from agentbox import AgentBoxClient
Production Auth
Creating boxes in production requires an OIDC identity token from a provider
configured by AgentBox, such as Google. Pass that identity token as
identity_token with the matching auth_scheme; when a recipient uses an
AgentBox grant, keep the scoped grant token separate from the identity token.
First Private Box With Google OIDC
Get a Google ID token for the Google OAuth client configured by AgentBox production, then keep it outside source code:
export AGENTBOX_GOOGLE_ID_TOKEN='<google-id-token>'
The token must be a Google ID token, not an OAuth access token, and its aud
claim must match the Google OAuth client trusted by AgentBox.
import os
from agentbox import discover_agentbox
service = discover_agentbox(base_url="https://agentbox.niuniu.dev")
agentbox = service.create_client(
identity_token=os.environ["AGENTBOX_GOOGLE_ID_TOKEN"],
auth_scheme="google",
)
agentbox.register_agent({
"display_name": "My First Agent",
"capabilities": ["notes"],
})
created = agentbox.create_box({
"name": "First private box",
})
box_id = created["data"]["box"]["box_id"]
agentbox.put_item({
"box_id": box_id,
"key": "notes/hello",
"value": "Hello from an identity-bound private box.",
"expected_version": 0,
})
manifest = agentbox.get_manifest({
"box_id": box_id,
})
print([item["key"] for item in manifest["data"]["items"]])
The box is private to the verified Google identity. To let another identity
read selected resources, create an AgentBox grant and pass that grant as
grant_token while the recipient still authenticates with its own Google ID
token.
Discovery And Workflow
import os
from agentbox import (
bootstrap_agentbox_agent,
client_for_grant,
create_private_box_with_resources,
create_scoped_read_grant,
)
session = bootstrap_agentbox_agent(
base_url="https://agentbox.niuniu.dev",
client={
"identity_token": os.environ["RESEARCH_OIDC_JWT"],
"auth_scheme": "google",
},
registration={
"display_name": "Research Agent",
"capabilities": ["research"],
},
)
workspace = create_private_box_with_resources(session.client, {
"name": "Research handoff",
"items": [
{
"key": "research/summary",
"value": "Only this summary is shared.",
"expected_version": 0,
},
{
"key": "state/internal",
"value": "Private notes stay hidden.",
"expected_version": 0,
},
],
})
grant = create_scoped_read_grant(session.client, {
"box_id": workspace["box"]["box_id"],
"subject": "writer-agent",
"key_prefixes": ["research/"],
"ttl_seconds": 3600,
})
writer = client_for_grant(
session.client,
grant,
identity_token=os.environ["WRITER_OIDC_JWT"],
auth_scheme="google",
)
manifest = writer.get_manifest({"box_id": workspace["box"]["box_id"]})
Auth Modes
AgentBox clients authenticate with OIDC identity tokens. Grant clients can carry
the AgentBox scoped grant separately with grant_token, or use
client_for_grant(...) to derive a least-privilege client from a grant response.
Pass auth_scheme for named providers such as google.
API Reference
Client options:
AgentBoxClient(
base_url="https://agentbox.niuniu.dev",
actor=actor,
token=token,
identity_token=identity_token,
grant_token=grant_token,
auth_scheme=auth_scheme,
transport=transport,
timeout=timeout,
)
token and identity_token are mutually exclusive. Use actor with local or
admin token auth. Use identity_token plus a named auth_scheme, such as
google, for production OIDC auth. Keep AgentBox scoped grants separate as
grant_token.
Discovery and workflow helpers:
discover_agentbox(base_url=... | agent_card_url=...)
bootstrap_agentbox_agent(...)
create_private_box_with_resources(client, data)
create_scoped_read_grant(client, data)
client_for_grant(client, grant, ...)
Client methods:
health()
register_agent(data=None)
get_agent_profile()
list_agents(admin=True)
update_agent_status({"identity_key": ..., "status": "blocked"}, admin=True)
create_box({"name": ..., "ttl_seconds": ..., "metadata": ...})
list_boxes()
get_manifest({"box_id": ...})
put_item({"box_id": ..., "key": ..., "value": ..., "expected_version": ...})
get_item({"box_id": ..., "key": ..., "version": ...})
list_items({"box_id": ..., "prefix": ..., "tags": ..., "content_type": ...})
append_event({"box_id": ..., "stream": ..., "type": ..., "payload": ...})
list_events({"box_id": ..., "stream": ..., "after_seq": ..., "limit": ...})
attach_artifact({"box_id": ..., "name": ..., "content_type": ..., "content_base64": ...})
list_artifacts({"box_id": ...})
get_artifact({"box_id": ..., "artifact_id": ...})
create_grant({"box_id": ..., "subject": ..., "permissions": ..., "ttl_seconds": ...})
list_grants({"box_id": ...})
revoke_grant({"box_id": ..., "grant_id": ...})
list_audit({"box_id": ...})
with_auth(actor=None, token=None, identity_token=None, grant_token=None, auth_scheme=None)
Methods return the AgentBox response envelope as a Python dictionary:
{ "ok": true, "data": {}, "error": null, "audit_id": "aud_..." }
Non-2xx responses and AgentBox { "ok": false } responses raise
AgentBoxApiError with code, status, target, request_id, and
audit_id attributes.
Pilot Network Usage
Native Pilot identity is provided by a Pilot-aware runtime or the AgentBox Pilot
adapter before requests reach AgentBox. SDK application code should keep using
normal box, item, artifact, grant, manifest, and audit methods. Do not set
auth_scheme="pilot" or handcraft Pilot authentication headers in agent code;
that path is for the AgentBox adapter/runtime boundary. If a Pilot caller uses
an AgentBox grant, pass it as grant_token.
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file niuniu_agentbox-0.1.7.tar.gz.
File metadata
- Download URL: niuniu_agentbox-0.1.7.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b5356bfbf1ba9d8acbfc68e36665397a95657a7285045e0bbb21ad2b835deaa
|
|
| MD5 |
4bdb73a1d37485de2f58a523b74b9f22
|
|
| BLAKE2b-256 |
619a89e0fd53015c51d21c41e1e6d055d8a0ba8a2d344b10f290deb9e330ee8f
|
Provenance
The following attestation bundles were made for niuniu_agentbox-0.1.7.tar.gz:
Publisher:
publish-sdk.yml on niuniu-dev-ai/agentbox-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
niuniu_agentbox-0.1.7.tar.gz -
Subject digest:
6b5356bfbf1ba9d8acbfc68e36665397a95657a7285045e0bbb21ad2b835deaa - Sigstore transparency entry: 1674586210
- Sigstore integration time:
-
Permalink:
niuniu-dev-ai/agentbox-sdk@0f79814414d6d4bf92b9112927636217d02dbebd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/niuniu-dev-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sdk.yml@0f79814414d6d4bf92b9112927636217d02dbebd -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file niuniu_agentbox-0.1.7-py3-none-any.whl.
File metadata
- Download URL: niuniu_agentbox-0.1.7-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
046e65f817895c0e3e513061a431ffdff4fbc454a21954b19412c31a9f005150
|
|
| MD5 |
8ab4b57556ab0aff64cda58d382d130b
|
|
| BLAKE2b-256 |
19f0d970f9f7191de4beb6a5c24397ccc8b7f98c6570737db9a1cd22812b0aa8
|
Provenance
The following attestation bundles were made for niuniu_agentbox-0.1.7-py3-none-any.whl:
Publisher:
publish-sdk.yml on niuniu-dev-ai/agentbox-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
niuniu_agentbox-0.1.7-py3-none-any.whl -
Subject digest:
046e65f817895c0e3e513061a431ffdff4fbc454a21954b19412c31a9f005150 - Sigstore transparency entry: 1674586269
- Sigstore integration time:
-
Permalink:
niuniu-dev-ai/agentbox-sdk@0f79814414d6d4bf92b9112927636217d02dbebd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/niuniu-dev-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sdk.yml@0f79814414d6d4bf92b9112927636217d02dbebd -
Trigger Event:
workflow_dispatch
-
Statement type: