npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@consensus-tools/schemas

v0.10.0

Published

Shared types and Zod schemas for consensus-tools

Readme

@consensus-tools/schemas

Shared Zod schemas and TypeScript types for the consensus-tools monorepo. This package is the contract layer -- every other package depends on it and it has zero internal dependencies.

Install

pnpm add @consensus-tools/schemas

Basic Usage

Validate untrusted data at runtime using any exported Zod schema:

import { jobSchema, type Job } from "@consensus-tools/schemas";

const job: Job = jobSchema.parse(untrustedPayload); // throws ZodError on invalid data

Use the TypeScript types alone (zero runtime cost) for typed function signatures:

import type { GuardDecision, JobStatus, HitlMode } from "@consensus-tools/schemas";

function handleDecision(d: GuardDecision): void {
  if (d === "BLOCK") { /* ... */ }
}

Validate API Inputs

Each API endpoint has a matching input schema:

import { jobPostInputSchema, voteInputSchema } from "@consensus-tools/schemas";

const body = jobPostInputSchema.parse(req.body); // safe to use
const vote = voteInputSchema.parse(req.body);

Policy Configuration

import { consensusPolicyConfigSchema, type ConsensusPolicyConfig } from "@consensus-tools/schemas";

const policy: ConsensusPolicyConfig = consensusPolicyConfigSchema.parse({
  type: "APPROVAL_VOTE",
  quorum: 3,
  minMargin: 0.6,
  approvalVote: { weightMode: "reputation", settlement: "staked" },
});

Available policy types: FIRST_SUBMISSION_WINS, HIGHEST_CONFIDENCE_SINGLE, APPROVAL_VOTE, OWNER_PICK, TOP_K_SPLIT, MAJORITY_VOTE, WEIGHTED_VOTE_SIMPLE, WEIGHTED_REPUTATION, TRUSTED_ARBITER.

Guard Schemas

import { guardEvaluateInputSchema, guardResultSchema, type GuardResult } from "@consensus-tools/schemas";
import { parseHumanApprovalYesNo } from "@consensus-tools/schemas";

const input = guardEvaluateInputSchema.parse(raw);
const approved = parseHumanApprovalYesNo("yes"); // true

Exports Reference

| Domain | Schemas | Types | |---|---|---| | Policy | consensusPolicyTypeSchema, approvalVoteConfigSchema, consensusPolicyConfigSchema, slashingPolicySchema | ConsensusPolicyType, ApprovalVoteConfig, ConsensusPolicyConfig, SlashingPolicy | | Job | jobModeSchema, jobStatusSchema, jobConstraintsSchema, escrowPolicySchema, jobSchema | JobMode, JobStatus, JobConstraints, EscrowPolicy, Job | | Submission | submissionStatusSchema, submissionSchema | SubmissionStatus, Submission | | Vote | voteTargetTypeSchema, voteSchema | VoteTargetType, Vote | | Resolution | resolutionSchema | Resolution | | Ledger | ledgerEntryTypeSchema, ledgerEntrySchema | LedgerEntryType, LedgerEntry | | Guard | guardTypeSchema, guardDecisionSchema, guardVoteValueSchema, guardVoteSchema, weightedGuardVoteSchema, guardPolicySchema, guardEvaluateInputSchema, guardEvaluateRequestSchema, guardResultSchema, weightingModeSchema, humanApprovalRequestSchema, parseHumanApprovalYesNo (function) | Matching types + VoteTally | | Agent | agentKindSchema, agentStatusSchema, agentSchema, agentConfigSchema | AgentKind, AgentStatus, Agent, AgentConfig | | Participant | participantSubjectTypeSchema, participantStatusSchema, participantSchema | ParticipantSubjectType, ParticipantStatus, Participant | | Workflow | workflowStatusSchema, workflowSchema, workflowRunSchema, cronScheduleSchema | WorkflowStatus, Workflow, WorkflowRun, CronSchedule | | HITL | hitlModeSchema, hitlStatusSchema, hitlApprovalSchema, humanDecisionSchema | HitlMode, HitlStatus, HitlApproval, HumanDecision | | Telemetry | telemetryEventTypeSchema, telemetryEventSchema, traceSpanSchema | TelemetryEventType, TelemetryEvent, TraceSpan | | Config | consensusToolsConfigSchema | ConsensusToolsConfig | | Storage | storageStateSchema | StorageState | | Common | claimStatusSchema, bidSchema, assignmentSchema, auditEventSchema, diagnosticEntrySchema | ClaimStatus, Bid, Assignment, AuditEvent, DiagnosticEntry | | Inputs | jobPostInputSchema, claimInputSchema, submitInputSchema, voteInputSchema, resolveInputSchema, workflowCreateInputSchema, cronRegisterInputSchema, participantCreateInputSchema, consensusVoteInputSchema | Matching types | | Policy Assignment | policyAssignmentSchema, consensusVoteSchema | PolicyAssignment, ConsensusVote | | Resolver | -- | ConsensusInput, ConsensusResult, PolicyResolver | | Guard Constants | BUILT_IN_GUARD_DOMAINS, GUARD_DOMAIN_DESCRIPTIONS, DEFAULT_GUARD_POLICY | GuardType (re-exported) |

Guard Constants

Canonical source of truth for guard domain definitions, shared across all adapter packages:

import {
  BUILT_IN_GUARD_DOMAINS,
  GUARD_DOMAIN_DESCRIPTIONS,
  DEFAULT_GUARD_POLICY,
} from "@consensus-tools/schemas";

BUILT_IN_GUARD_DOMAINS;
// => ["send_email", "code_merge", "publish", "support_reply", "agent_action", "deployment", "permission_escalation"]

GUARD_DOMAIN_DESCRIPTIONS["agent_action"];
// => "Evaluate autonomous agent action — blocks irreversible actions, flags external side effects"

DEFAULT_GUARD_POLICY;
// => { policyId: "default-guard", version: "v1", quorum: 0.7, riskThreshold: 0.7, hitlRequiredAboveRisk: 0.7, options: {} }

Links

consensus-tools on GitHub