@ausca/sdk
v0.2.0
Published
Typed client for Ausca metered agent infrastructure services: catalog-bound invocations paid per call under a hard USD cap, through pluggable payment authorities (x402 v2 today), with receipt-backed results.
Downloads
117
Maintainers
Readme
@ausca/sdk
The typed engine behind the ausca front door: catalog-bound invocations of Ausca metered agent infrastructure services, paid per call under a hard USD cap, with receipt-backed results.
Most consumers want the ausca package, which re-exports this entire
surface and adds the CLI and local MCP server. Depend on @ausca/sdk
directly when you only need the library.
Client
import { AuscaClient } from "@ausca/sdk";
const client = AuscaClient.withLocalKey({
privateKey: process.env.AUSCA_PRIVATE_KEY,
maxPaymentUsd: 0.5,
});
const offer = await client.offer("document.ocr");
const price = await client.price("document.ocr");
const outcome = await client.invoke("document.ocr", { artifact });
const state = await client.invocation("inv_...");The envelope carries the offer's immutable revision and schema digests
exactly as the catalog declares. Each invoke starts with a
fresh idempotency key. For recovery after an uncertain response, retry with
the same caller-owned idempotencyKey; use a new key for a new intentional
purchase, even when the input is identical.
Payment authorities
The client pays through a PaymentAuthority, a small port any rail can
implement: wrap a fetch so 402 challenges are paid within policy, and decode
settlement evidence from the response. Built in:
localKeyAuthority({ privateKey, maxPaymentUsd, network? }): x402 v2 with a local signing key via the official@x402/*libraries.x402Authority(config): the official x402 client configuration passed through verbatim, so any registered scheme client works.inertAuthority(): pays nothing; reads and price discovery.
Caps are enforced inside the authority before anything is signed.
Artifact store
Artifact-backed offers take an immutable input commitment.
client.commit(bytes, mediaType) uses Ausca's keyless temporary ingress and
creates a fresh temporary commitment on every call. Pass
{ idempotencyKey: "..." } only to recover the same uncertain upload. The
client verifies the returned digest-backed evidence and returns the commitment
the invocation input carries. No account or API token is needed.
ArtifactStore remains the narrow port for a custom storage policy.
Successful paid state includes receipt_ref.public_url, an immutable
hash-only proof of the Ausca service, public price, completion time, and
receipt digest. It contains no request or result bytes, content digests, or
access capabilities. Anyone holding the unguessable URL can read it.
A result larger than the offer's inline bound arrives as output_artifact
instead of output. client.artifactAccess(artifactRef) mints a 60-second
download URL for it; verify the bytes against contentDigest. A failed
invocation carries failure.code and failure.message.
Testkit
@ausca/sdk/testkit ships an in-process x402 v2 resource and an
Ausca-shaped service fixture (catalog, schema, payable route, invocation
read) for offline test suites. No chain is involved.
License
MIT
