tereno-client
v0.3.0
Published
x402 client for Tereno execution intelligence, reusable web evidence and agent demand signals
Readme
tereno-client
Pre-sign Base transaction and contract-change intelligence with no API key or account. The wallet signing the x402 payment is the consumer identity.
Direct client
import { privateKeyToAccount } from "viem/accounts";
import { createTerenoClient } from "tereno-client";
const client = createTerenoClient({
baseUrl: "https://tereno.xyz",
account: privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`),
network: "eip155:8453",
maxPriceUsd: 0.02,
builderCode: "my_agent_service", // optional client/service (`s`) attribution
evidenceInstallationId: process.env.TERENO_INSTALLATION_ID, // stable random id, never a wallet
});
const guarded = await client.invokeCapability({
capabilityId: "transaction.intent.guard",
from: client.address,
to: unsignedTx.to,
data: unsignedTx.data,
value: unsignedTx.value.toString(),
});
if (guarded.data.verdict === "block") throw new Error("Tereno blocked signing");
const changed = await client.invokeCapability({
capabilityId: "contract.change",
address: unsignedTx.to,
});
const page = await client.compileWebPage("https://example.com/article");
// Another agent can hand you `changed.data.evidenceReference.artifactId`.
// This read is free and independent from Bazaar/x402 payment.
const reference = await client.evidenceReference(changed.data.evidenceReference.artifactId);
// Older wallet-intelligence APIs remain available during migration.
const quote = await client.lookup("wallet_reputation", subject);
const quoted = await client.get("wallet_reputation", subject);
const direct = await client.getDirect("wallet_reputation", subject);
await client.feedback(quoted.data.discoveryId, true);invokeCapability() obtains a wallet-bound quote, follows its GET or POST contract, completes x402 and returns data plus the settlement receipt. The canonical transaction guard costs $0.005 and contract.change costs $0.001 by default. tx.preflight remains an accepted deprecated alias.
lookup() signs an EIP-712 agent action and returns the legacy discovery quote without paying. That signature is what unlocks wallet-specific standing and reserved credit; the later x402 payer must match. buy(buyUrl) pays a single-use quoted URL. get() performs both steps and returns data plus the settlement transaction.
getDirect() buys at public list price from the Bazaar-enabled route without a prior lookup. feedback() is signed and is accepted once, only from a settled purchaser. Pass builderCode to attribute client-driven Base settlements as an ERC-8021 service code.
AgentKit users can import terenoActionProvider from
tereno-client/agentkit. It exposes a free quote action and a budget-limited
direct x402 purchase action for Base and Base Sepolia wallets.
import { terenoActionProvider } from "tereno-client/agentkit";
const provider = terenoActionProvider({
baseUrl: "https://tereno.xyz",
maxPriceUsd: 0.02,
builderCode: "my_agent_service",
});
// Include `provider` in the AgentKit actionProviders array.The provider exports these primary semantic actions:
tereno_buy_transaction_intent_guard: pre-sign intent, simulation, gas, supported balance/allowance deltas and target-state risks.tereno_buy_aerodrome_swap_guard: private pre-sign simulation and encoded limit check for prepared Aerodrome Classic or Slipstream swaps on Base.tereno_check_contract_change: bytecode, implementation, admin and pause changes.tereno_quote_contract_guardandtereno_buy_contract_guard: bounded reusable contract check.tereno_list_capabilities: machine-readable prices and contracts.tereno_compile_web_page: bounded public URL → Markdown, citations and a reusable content-addressed artifact ($0.005 fresh / $0.001 reused).
The legacy wallet-intelligence actions remain available during migration:
tereno_lookup_wallet_intelligence: free economics/availability lookup.tereno_buy_wallet_intelligence: direct Bazaar-compatible x402 purchase.
