@agent-receipts/schema
v0.2.8
Published
Zod schemas and TypeScript types for the Action Receipt Protocol
Maintainers
Readme
@agent-receipts/schema
Zod schemas and TypeScript types for the Action Receipt Protocol.
Install
npm install @agent-receipts/schemaUsage
import { ActionReceipt, validate, CreateReceiptInput } from '@agent-receipts/schema'
// Validate a receipt object
const result = validate(ActionReceipt, someObject)
if (result.success) {
console.log('Valid receipt:', result.data.receipt_id)
} else {
console.log('Invalid:', result.error)
}
// Validate create input
const input = validate(CreateReceiptInput, {
action: 'generate_report',
input_hash: 'sha256:abc123...',
})Schemas
| Schema | Description |
|--------|-------------|
| ActionReceipt | Full receipt with all fields |
| SignablePayload | Deterministic fields used for signing |
| CreateReceiptInput | Input for creating a new receipt |
| CompleteReceiptInput | Input for completing a pending receipt |
| VerifyResponse | Response from verification |
| ListReceiptsQuery | Query parameters for listing receipts |
| PaginationMeta | Pagination metadata |
| ErrorResponse | Structured error response |
| ConstraintDefinition | Constraint rule definition (type, value, message?) |
| SingleConstraintResult | Individual constraint evaluation result |
| ConstraintResult | Aggregate constraint evaluation (passed, results[], evaluated_at) |
| JudgmentRubric | AI Judge rubric with criteria, weights, and thresholds |
| JudgmentResult | AI Judge evaluation result with verdict and criteria scores |
Enums
| Enum | Values |
|------|--------|
| ReceiptStatus | pending, completed, failed, timeout |
| ReceiptType | action, judgment |
| Environment | development, staging, production |
| ErrorCode | VALIDATION_ERROR, NOT_FOUND, VERIFICATION_FAILED, INTERNAL_ERROR |
Utilities
validate(schema, data)— Validate data against any schema, returns{ success, data?, error? }formatZodError(error)— Format a Zod error into a human-readable stringcreateErrorResponse(code, message)— Create a structured error response
JSON Schema
The package includes receipt.schema.json for non-TypeScript consumers. This is auto-generated from the Zod schemas.
License
MIT
