Agent-runtime library for bnbagent-studio: wallet, ERC-8004, ERC-8183, x402 over bnbagent-sdk.
Project description
bnbagent-studio-core
The agent-runtime library for
bnbagent-studio — the code a
deployed BNB Chain seller agent imports and runs. It wraps the bnbagent
protocol SDK with studio's configuration, workflow, and safety layer so an
agent can sign quotes, run ERC-8183 jobs, pay over x402, and read chain state
without re-implementing any of it.
Highlights
- Wraps the
bnbagentSDK (wallet / ERC-8004 / ERC-8183 / x402) with studio's opinions —studio.tomlconfig, multi-step workflows, signing policy, and an audit log — while leaving the SDK protocol layer untouched. - Lean runtime deps —
bnbagent,web3,eth-account,httpx,tomlkit,python-dotenv. No agent framework, no web server in the base install. - Framework- and runtime-agnostic — does NOT import ADK, LangChain, or bedrock-agentcore. Those couplings live in the CLI's emitted recipes, not here, so you can drop this into any runtime.
- FastAPI is opt-in. The ERC-8183 seller-hosting helpers are the only code
that touches FastAPI, and they
importit lazily — install the[serve]extra only when you host an 8183 endpoint yourself. - What a deployed agent imports. This is the library a scaffolded agent declares as its runtime dependency; signing, settlement, and chain reads all flow through it.
⚠️ This project is under active development and may introduce breaking changes between releases. It manages wallet keys and on-chain funds: start on testnet, and use it at your own risk.
⚠️ Deploying provisions AWS resources in your own account, under IAM policies you review and apply yourself. The published policy documents (least-privilege guide, policy JSON) are reference configurations provided AS IS — you remain responsible for scoping, costs, and security. Full terms: DISCLAIMER.md (also shipped in this package as
bnbagent_studio_core/DISCLAIMER.md).
Distribution & import names
- Distribution:
bnbagent-studio-core - Import package:
bnbagent_studio_core
from bnbagent_studio_core import get_wallet, get_policy
from bnbagent_studio_core.erc8183 import submit_workflow, settle_workflow
Where it sits
You normally don't install this directly. It's the library half of a two-distribution split:
bnbagent-studio-core(this package, importbnbagent_studio_core) — the runtime library.bnbagent-studio(importbag) — the CLI: scaffolding, recipes, and a read-only MCP server. It depends on this package.
Its three consumers:
- A deployed Agent (Layer A, on AWS Bedrock AgentCore) imports it at
runtime to sign quotes, submit/settle ERC-8183 jobs, auto-renew LLM credit,
and read chain state. Emitted agent code does
from bnbagent_studio_core import .... - The
bagCLI and its read-only MCP server — shipped as the separatebnbagent-studiodistribution — also import it. - Rarely standalone — only when building or vendoring an agent runtime by hand.
The keyless Layer-B Service depends on neither package — it inlines its own ~10-LOC config loader.
Install
# Usual path: install the CLI, which pulls this in automatically
pip install bnbagent-studio
Install it standalone only when building or vendoring an agent runtime by hand:
pip install bnbagent-studio-core
The [serve] extra
FastAPI/uvicorn are an optional [serve] extra. Only the seller-hosting path
(bnbagent_studio_core.erc8183.seller, reached via serve_8183 /
build_erc8183_app) imports them, and it does so lazily — the agent runtime
never touches FastAPI. Install the extra only to host an ERC-8183 endpoint
yourself:
pip install "bnbagent-studio-core[serve]"
What's inside
Modules live under bnbagent_studio_core/. The convenience surface that
agent code imports is re-exported from the package root
(get_wallet, get_policy, Policy, load_studio_toml,
find_project_root, emit); lower-level surfaces stay reachable via their
submodules.
- wallet — keystore-backed signing.
get_wallet()returns abnbagentWalletProvider(anEVMWalletProviderthat enforces aSigningPolicyon every sign);ensure_keystore_materialized()writes the injected keystore to disk when the code mount is read-only. Local Keystore V3 today (KMS / remote signing deferred to v2). - config —
studio.tomlloading and project discovery:load_studio_toml(),find_project_root(),find_workspace_root(),load_env(). - networks — BSC testnet/mainnet registry and the U stablecoin (United
Stables, 18 decimals) token info;
get_network(), plusto_raw/from_rawamount converters. - policy —
get_policy()/Policy(budget caps: per-call and daily spend limits read fromstudio.toml). - erc8004 — identity:
register,resolve,resolve_service,update_endpoint,update_service_endpoint,show(withAgentRecord/ResolvedServiceresult types). - erc8183 — commerce: a pre-configured client (
get_8183_client), multi-step workflows (buy_workflow/submit_workflow/fetch_workflow/settle_workflow, plusget_job_summary), quote verification (verify_signed_job/recover_quote_signer→Verdict), off-chain negotiation, and seller-hosting starters (serve_8183/build_erc8183_app). Typed errors (JobNotFoundError,JobStateError,BudgetCapExceededError, …) are exported alongside. - x402 — x402 micropayment buyer kernel over the SDK's hardened
X402Signer(fetch_with_payment,quote_url,pay_challenge,FetchResult) gated by anX402BuyerPolicy/BudgetTracker. - pieverse — Pieverse LLM credit layer:
PieverseCreditEnsurer(budget-gated auto-renew),BudgetPolicy/PieversePolicy, key management (create_key,inspect_key,allocate,get_account_usage), SIWE login (siwe_login), and x402 top-up (topup_x402). - tools.chain_readonly — 15 read-only on-chain query functions
(
wallet_info,balance_native,balance_u,agent_info,job_status,job_list,tx_status,block_info,network_info, …). Also surfaced as the CLI's MCP tools; framework-neutral. - audit —
.studio/audit-log.jsonlemission protocol for on-chain money ops: redaction (validate_no_secrets), schema (Event,SCHEMA_VERSION), and a writer (record,record_chain_op,audited_op,tail). - storage — deliverable storage selection (local file / IPFS) via
storage_provider_from_config(). - llm — framework-neutral LLM-config resolution
(
_resolve_provider_config()→ProviderConfig) used by emitted provider shells. Studio constructs no model object itself.
Usage
The smallest meaningful snippets — read config and a wallet, verify a signed quote. See the reference doc for the full API.
from bnbagent_studio_core import get_wallet, get_policy, load_studio_toml
cfg = load_studio_toml() # parsed studio.toml (project root auto-discovered)
wallet = get_wallet() # keystore-backed WalletProvider (policy enforced)
policy = get_policy() # budget caps from [policy] in studio.toml
# Verify a counterparty's signed ERC-8183 quote before acting on it.
from bnbagent_studio_core.erc8183 import verify_signed_job
verdict = verify_signed_job(signed_job)
if verdict.ok:
... # safe to submit / settle
# Read-only chain query (no signing, no key needed).
from bnbagent_studio_core.tools.chain_readonly import balance_u
print(balance_u(network="bsc-testnet"))
Dependencies & boundaries
Runtime dependencies (lean by design):
bnbagent,web3,eth-account,httpx,tomlkit,python-dotenv(andtomlion Python < 3.11).
Boundaries:
- FastAPI/uvicorn are
[serve]-only. The agent runtime never imports them; the seller-hosting helpers import FastAPI lazily. - Framework- and runtime-agnostic. This library does NOT import ADK, LangChain, or bedrock-agentcore — those couplings live in the CLI's emitted recipes, not here.
- The SDK protocol layer stays pure. Studio's opinions wrap
bnbagent; they never pollute it.
Python ≥ 3.10.
Further reading
- Main repository — overview,
guides, and the
bagCLI. - Architecture — the layered design and two-layer deploy model.
- Reference — CLI / recipe / MCP-tool / library reference.
- User Guide
— the install → skills → Claude Code →
bag devpath (for CLI end-users).
License
Apache-2.0.
Project details
Release history Release notifications | RSS feed
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 bnbagent_studio_core-0.0.1.tar.gz.
File metadata
- Download URL: bnbagent_studio_core-0.0.1.tar.gz
- Upload date:
- Size: 78.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
717dd29e116c2759a851fc7bd669a8d803e64fea61b8b309421894c3cdadbf68
|
|
| MD5 |
1ce6dcc7878df0b1e9fd801279ac277c
|
|
| BLAKE2b-256 |
b3504b7c36d6af2e3c25938aa9e602591481fff1561b553db9d02af44a19cbfc
|
File details
Details for the file bnbagent_studio_core-0.0.1-py3-none-any.whl.
File metadata
- Download URL: bnbagent_studio_core-0.0.1-py3-none-any.whl
- Upload date:
- Size: 100.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc2c1a44018804175e2342ecc3c20f240d01009c818e8a7383a961102c34f4ae
|
|
| MD5 |
1954812ea105faee43e34b0300f4851f
|
|
| BLAKE2b-256 |
64c0c69e64dfb61769662874c6bdc21cd1146ec81e6e84d99fc3e82bafcd8e68
|