Repository navigation
0.3.0
Breaking
emithands events to a background thread and returns at once. Delivery happens everyflush_intervalseconds (default 1), when a batch is full, onflush(), onclose()and at interpreter exit. Callflush(timeout=…)before a short-lived process or serverless handler returns.flush(timeout=None, *, replay_spool=True)returns{"drained": bool}.- x402 events without a network or token address raise inside the mapper and are reported as
invalid_event, instead of being recorded with a guessed testnet, zero address,USDCor 6 decimals. - A source key that is not an Ed25519 private JWK with a
kid, or an API key that is nothk_test_…/hk_live_…, disables the client with oneconfigerror at construction. validate_eventrejectsnullanywhere in an event, as APE v0.1 does.
Fixed
- Retries with backoff (
retry_delays, default 1, 2, 4, 8, 16, 32 s) on network errors, 408, 425, 429 and 5xx. 5xx and network failures no longer count asrejected. - Permanent errors (400, 401, 403, 404, 405, 409, 410, 415, 422) are not retried; the batch goes to
<spool_dir>/dead/and is reported once withserverCode,detailsandrequestId. - A batch that is too large (413) is split; a single oversized event is dropped and reported.
- x402:
payment.requestedhaspayment_idx402:<network>:requested:<event id>; authorization, settlement and failure sharex402:<network>:<nonce>and never use the transaction hash;payment.authorizedlinks to its challenge withrelated.previous_event_id; a failed settlement has notx_hashand afailure_reasonof at most 128 characters; the payer wallet is the instrument. Output matches the Node.js SDK for the same headers. - x402 events keep the full agent and owner from
agent_context. - An event-level
instructionreplaces the context one, and only APE instruction fields are kept. - Card numbers are redacted in
payee.website,payee.resource_url, label keys and JSON evidence (the evidence hash is recomputed), and rejected there by validation. - JCS: strings with a lone UTF-16 surrogate are written as
\udXXX, like the Node.js SDK, instead of raising. stats()returns a copy, and counters are exact under concurrentemitcalls.
Added
- Disk spool (
spool_dir,spool_max_bytesdefault 50 MB,spool_max_agedefault 7 days): undeliverable batches are kept and replayed by the nextflushor process; the oldest files are evicted first and reported. close(timeout), context manager support, and anatexitflush (exit_hook=True, 2 s).stats()hasdropped,retries,spooledandreplayed.- x402:
HalvorX402TransportandAsyncHalvorX402Transport(see every request, includingstream()),wrap_httpx_async, and every HTTP method on the wrappers. - Tests run the ape-schema conformance cases (40 events, JCS vectors).
Changed
emitvalidates every event against APE v0.1 before signing; an invalid event is dropped, counted instats().dropped_invalidand reported throughon_errorwithinvalid_event.- The default endpoint follows the key:
hk_test_keys (andenvironment="test"with no key) go to the sandbox,hk_live_keys to production. endpointis a base URL, as in the Node.js SDK; a full/v1/eventsURL still works.HALVOR_ENDPOINTsets it from the environment.HalvorClient()readsHALVOR_API_KEYandHALVOR_SOURCE_KEYfrom the environment.- Delivery counts each event by the status the API returned:
accepted,duplicatesandrejected. transportaccepts anhttpxtransport, for tests.- The SDK version in
source.sdkcomes from the installed package metadata.
Full Changelog: v0.2.0...v0.3.0