API Reference
Receipts
Section titled “Receipts”import { createReceipt, signReceipt, verifyReceipt, generateKeyPair, hashReceipt, verifyChain,} from "@agnt-rcpt/sdk-ts";Functions
Section titled “Functions”createReceipt
Section titled “createReceipt”function createReceipt(input: CreateReceiptInput): UnsignedAgentReceiptBuild an unsigned receipt. Auto-generates an ID (urn:uuid:...), action ID, issuance date, and action timestamp.
signReceipt
Section titled “signReceipt”function signReceipt( unsigned: UnsignedAgentReceipt, privateKey: string, verificationMethod: string,): AgentReceiptSign an unsigned receipt with an Ed25519 private key (PEM-encoded). Returns a signed AgentReceipt with an Ed25519Signature2020 proof.
verifyReceipt
Section titled “verifyReceipt”function verifyReceipt(receipt: AgentReceipt, publicKey: string): booleanVerify the Ed25519 signature on a signed receipt.
generateKeyPair
Section titled “generateKeyPair”function generateKeyPair(): KeyPairGenerate an Ed25519 key pair in PEM format.
hashReceipt
Section titled “hashReceipt”function hashReceipt(receipt: AgentReceipt): stringCompute the SHA-256 hash of a receipt (excluding proof) using canonical JSON. Returns sha256:<hex>.
verifyChain
Section titled “verifyChain”function verifyChain(receipts: AgentReceipt[], publicKey: string): ChainVerificationVerify an entire receipt chain: signatures, hash linkage, and sequence numbers.
canonicalize
Section titled “canonicalize”function canonicalize(value: unknown): stringRFC 8785 canonical JSON serialization.
sha256
Section titled “sha256”function sha256(data: string): stringCompute a SHA-256 hash, returned as hex.
CreateReceiptInput
Section titled “CreateReceiptInput”interface CreateReceiptInput { issuer: Issuer; principal: Principal; action: Omit<Action, "id" | "timestamp">; outcome: Outcome; chain: Chain; intent?: Intent; authorization?: Authorization; actionTimestamp?: string;}AgentReceipt
Section titled “AgentReceipt”interface AgentReceipt { "@context": readonly string[]; id: string; type: readonly string[]; version: string; issuer: Issuer; issuanceDate: string; credentialSubject: CredentialSubject; proof: Proof;}
type UnsignedAgentReceipt = Omit<AgentReceipt, "proof">KeyPair
Section titled “KeyPair”interface KeyPair { publicKey: string; privateKey: string;}Issuer
Section titled “Issuer”interface Issuer { id: string; type?: string; name?: string; operator?: Operator; model?: string; session_id?: string;}
interface Operator { id: string; name: string;}Principal
Section titled “Principal”interface Principal { id: string; type?: string;}Action
Section titled “Action”interface Action { id: string; type: string; risk_level: RiskLevel; target?: ActionTarget; parameters_hash?: string; timestamp: string; trusted_timestamp?: string | null;}
interface ActionTarget { system: string; resource?: string;}Outcome
Section titled “Outcome”interface Outcome { status: OutcomeStatus; error?: string | null; reversible?: boolean; reversal_method?: string; reversal_window_seconds?: number; state_change?: StateChange;}
interface StateChange { before_hash: string; after_hash: string;}interface Chain { sequence: number; previous_receipt_hash: string | null; chain_id: string;}ChainVerification
Section titled “ChainVerification”type ChainVerification = { valid: boolean; length: number; receipts: ReceiptVerification[]; brokenAt: number;}
type ReceiptVerification = { index: number; receiptId: string; signatureValid: boolean; hashLinkValid: boolean; sequenceValid: boolean;}Intent / Authorization / Proof
Section titled “Intent / Authorization / Proof”interface Intent { conversation_hash?: string; prompt_preview?: string; prompt_preview_truncated?: boolean; reasoning_hash?: string;}
interface Authorization { scopes: string[]; granted_at: string; expires_at?: string; grant_ref?: string | null;}
interface Proof { type: string; created?: string; verificationMethod?: string; proofPurpose?: string; proofValue: string;}Constants
Section titled “Constants”type RiskLevel = "low" | "medium" | "high" | "critical"type OutcomeStatus = "success" | "failure" | "pending"
const CONTEXT: readonly ["https://www.w3.org/ns/credentials/v2", "https://agentreceipts.ai/context/v1"]const CREDENTIAL_TYPE: readonly ["VerifiableCredential", "AgentReceipt"]const RECEIPT_VERSION: "0.1.0"const VERSION: "0.1.0"import { ReceiptStore, openStore, verifyStoredChain } from "@agnt-rcpt/sdk-ts";SQLite-backed receipt persistence and querying.
openStore
Section titled “openStore”function openStore(dbPath: string): ReceiptStoreOpen or create a SQLite receipt store. Pass ":memory:" for an in-memory store.
verifyStoredChain
Section titled “verifyStoredChain”function verifyStoredChain( store: ReceiptStore, chainId: string, publicKey: string,): ChainVerificationLoad a chain from the store and verify its integrity.
ReceiptStore
Section titled “ReceiptStore”class ReceiptStore { constructor(dbPath: string); insert(receipt: AgentReceipt, receiptHash: string): void; getById(id: string): AgentReceipt | undefined; getChain(chainId: string): AgentReceipt[]; query(filters: ReceiptQuery): AgentReceipt[]; stats(): StoreStats; close(): void;}ReceiptQuery
Section titled “ReceiptQuery”interface ReceiptQuery { chainId?: string; actionType?: string; riskLevel?: RiskLevel; status?: OutcomeStatus; after?: string; before?: string; limit?: number;}StoreStats
Section titled “StoreStats”interface StoreStats { total: number; chains: number; byRisk: { risk_level: string; count: number }[]; byStatus: { status: string; count: number }[]; byAction: { action_type: string; count: number }[];}Taxonomy
Section titled “Taxonomy”import { classifyToolCall, getActionType, resolveActionType, loadTaxonomyConfig, ALL_ACTIONS,} from "@agnt-rcpt/sdk-ts";Action type registry and tool call classification.
classifyToolCall
Section titled “classifyToolCall”function classifyToolCall( toolName: string, mappings?: TaxonomyMapping[],): ClassificationResultClassify a tool call to an action type and risk level using the provided mappings.
getActionType
Section titled “getActionType”function getActionType(type: string): ActionTypeEntry | undefinedLook up an action type by name. Returns undefined if not found.
resolveActionType
Section titled “resolveActionType”function resolveActionType(type: string): ActionTypeEntryLike getActionType but returns an “unknown” fallback instead of undefined.
loadTaxonomyConfig
Section titled “loadTaxonomyConfig”function loadTaxonomyConfig(filePath: string): TaxonomyMapping[]Load taxonomy mappings from a JSON file.
interface ActionTypeEntry { type: string; description: string; risk_level: RiskLevel;}
interface TaxonomyMapping { tool_name: string; action_type: string;}
interface ClassificationResult { action_type: string; risk_level: RiskLevel;}Built-in action registries
Section titled “Built-in action registries”const FILESYSTEM_ACTIONS: readonly ActionTypeEntry[] // 7 typesconst SYSTEM_ACTIONS: readonly ActionTypeEntry[] // 8 typesconst ALL_ACTIONS: readonly ActionTypeEntry[] // all + unknownconst UNKNOWN_ACTION: ActionTypeEntry