@terra-protocol/oamp-sdk
v1.0.0
Published
Open Agent Mandate Protocol (OAMP v1.0) — Cryptographic Agent Identity, Multi-Hop Delegation, Section 8.14 Contagion Clause, and MCP/x402/LangChain/CrewAI Middleware SDK
Maintainers
Readme
@terra-protocol/oamp-sdk — Open Agent Mandate Protocol (OAMP v1.0)
The Cryptographic Birth Certificate, Multi-Hop Delegation, and Liability Attribution SDK for Autonomous AI Agents.
Built by TERRA (EyeTea Solutions ApS / TERRA ApS) — The Global Agent Trust, Liability, State Verification, and Physical Reality Layer for Autonomous AI.
Features
- Zero External Dependencies (
< 2msp99 Sign + Verify,< 0.02msCached Verify): Built on native Ed25519 (RFC 8032), W3Cdid:key(0xed01Base58BTC) &did:ion, Canonical JSON-LD (RFC 8785), and Jacobian ECDSAsecp256k1. - Multi-Hop Sub-Agent Delegation: Cryptographic inheritance chains (
Primary Agent -> Sub-Agent -> Worker) enforcing cumulative spend decay (authorityDecayFactor), tool scope subsetting, and maximum cascade depth (Rule B). - Mandatory 7-Header TERRA Protocol & Section 8.14 ("The Contagion Clause") Suite:
X-Terra-Mandate: Ed25519-signed JSON-LD capability & budget mandateX-Terra-Principal: Root legal entitydid:keyURIX-Terra-Prompt-Hash: Immutable SHA-256 digest of{ baseModelId, systemPrompt, activeTools, triggeringContext }(Rule A Hash Drift protection)X-Terra-Liability-Proof: Base64 MGA insurance policy & escrow reservation proofX-TERRA-OAMP-MANDATE-ID: UUIDv4 Mandate IdentifierX-TERRA-OAMP-PROOF-HASH: Ed25519 signature bindingmandateId:promptHashX-TERRA-OAMP-ESCROW-SIG: ECDSAsecp256k1signature bindingmandateId:escrowReservationId:maxPerCallUsd
- Drop-In Framework Middleware:
- Model Context Protocol (MCP):
wrapMcpToolCall,verifyMcpToolCall - HTTP x402 Payment Rail (15 bps MGA Micro-Policy):
createX402PaymentHeaders,verifyX402PaymentHeaders - LangChain (LCEL):
withTerraLcelRunnable - CrewAI:
executeCrewAiGuardedTask
- Model Context Protocol (MCP):
Quick Start
npm install @terra-protocol/oamp-sdkimport {
generateEd25519KeyPair,
generateSecp256k1KeyPair,
createMandate,
buildTerraHeaders,
verifyTerraHeaders,
} from "@terra-protocol/oamp-sdk";
const principal = generateEd25519KeyPair();
const agent = generateEd25519KeyPair();
const escrow = generateSecp256k1KeyPair();
const mandate = createMandate({
principalDid: principal.didKey,
agentDid: agent.didKey,
signerPrivateKeyHex: principal.privateKeyHex,
jurisdiction: "EU-DK",
allowedTools: ["stripe.create_payment", "logistics.book_freight"],
maxPerCallUsd: 25_000,
dailyCapUsd: 100_000,
});
const headers = buildTerraHeaders({
mandate,
agentPrivateKeyHex: agent.privateKeyHex,
promptContext: {
baseModelId: "gemini-4-argon-high",
systemPrompt: "Insured enterprise procurement agent.",
activeTools: mandate.allowedTools,
triggeringContext: "Book container #881 for $12,000",
},
escrowPrivateKeyPem: escrow.privateKeyPem,
escrowPublicKeyPem: escrow.publicKeyPem,
});
const verified = verifyTerraHeaders(headers, {
requestedTool: "logistics.book_freight",
requestedSpendUsd: 12_000,
});
console.log(verified.valid); // trueLicense
Apache-2.0 — Copyright (c) 2026 EyeTea Solutions ApS (binavn: TERRA ApS).
