Skip to Content
SDK referenceTypeScriptveriproof-sdk-core

TypeScript SDK

Use @veriproof/sdk-core for application-owned actions. Add the Enforce adapter for each framework your application uses.

Try it without an account

import { VeriproofTestHarness } from '@veriproof/sdk-core/testing'; const local = new VeriproofTestHarness().respondWith({ verdict: 'allow' }); const result = await local.veriproof.govern( 'payments.submit', payment, submitPayment, );

The harness performs no network requests. It can queue policy outcomes, directives, timeouts, transport failures, and signed review deliveries.

Govern one action

In the customer portal, open Tools and SDKs. Select your language and adapters, then follow the installation instructions shown there.

VeriProof SDKs are distributed through customer-gated GitLab packages, not public registries. See SDK access for workstation and CI guidance.

VeriProof packages used here: @veriproof/sdk-core, @veriproof/sdk-adapter-openai-agents.

Store the application SDK key as VERIPROOF_API_KEY, then create one client:

import { Veriproof } from '@veriproof/sdk-core'; const veriproof = Veriproof.fromEnv(); const result = await veriproof.govern( 'payments.submit', payment, ({ input, invocationId, signal }) => provider.submit(input, { idempotencyKey: invocationId, signal }), { facts: { payment_amount: payment.amount }, }, );

The core SDK checks the input before it calls provider.submit. It checks output before release through the typed result.value boundary.

Only completed, completed_with_warning, and transformed can contain a released value. Reconcile completion_unknown before retrying an external side effect. Never release a value from a blocked result, which the portal shows as Stopped by policy. Use the typed status, safe message, reason code, and evidence reference to handle results without a value.

Handle a stop

Pass signal to cancellable child work. Call throwIfStopped() immediately before a protected side effect that cannot accept an AbortSignal.

A live Stop directive applies only to its matching run or application. The SDK signals the action before it acknowledges the directive. It does not terminate the Node.js process. Reconcile the side effect when the result reports completion_unknown.

Add industry values

import { Industry } from '@veriproof/sdk-core'; import { ClaimStatus, ClaimStatusMeta } from '@veriproof/sdk-core/industries/insurance'; const industry = Industry.fact( ClaimStatusMeta, ClaimStatus.PendingPaymentAuthorization, );

Use facts for application-specific rule data. The active field contract checks required fields, types, and allowed values before protected work begins.

Derive facts once

If every call carries the same kind of facts, register one factExtractor on the client instead of building facts at each call site. It receives the action name, input, session and invocation IDs, the adapter name, the tool name when an adapter governs a tool call, and any runMetadata:

import { Veriproof } from '@veriproof/sdk-core'; const veriproof = Veriproof.fromEnv(process.env, { factExtractor: ({ toolName, input }) => toolName === 'claims_pay' ? { claim: input } : undefined, });

Facts you pass in governOptions.facts win over extracted facts with the same name. Extracted facts go through the same sanitization and field-contract checks as facts you pass yourself, and they’re saved in review checkpoints. A resumed review uses those saved facts and doesn’t call the extractor again.

If the extractor throws or returns something other than a plain JSON object, the call ends with failed and reason code fact_extraction_failed, and the action doesn’t run. runMetadata only reaches the extractor; the SDK never sends it to VeriProof.

Continue after human review

Save every review_required checkpoint in a protected workflow store. Pass the exact callback bytes and all signature headers to the review runtime before parsing the body. A worker can then call reviews.resume with the saved checkpoint and an idempotent protected callback.

The runtime checks each callback against the signing keys VeriProof publishes at your endpoint. If your host can’t reach VeriProof, pass webhookKeys: new PinnedWebhookKeySet(keySetJson). To check review event webhooks, use verifyWebhook with the key set, your whsec_ subscription secret, or both.

Core Human Review uses a 12-field bounded brief and a response and resume-mode matrix. route_to_revision starts application-owned revision work and never runs the superseded payload. Private-note content remains in VeriProof and is excluded from the callback.

Do not retry a checkpoint with uncertain execution until the application reconciles its durable side effect.

The hosted Server Ingest path is the default. Configure the licensed Edge Gateway endpoint when the application needs local policy latency and outage continuity.

See Core Human Review for the lifecycle contract and the runnable TypeScript receiver guide for callback hosting.

Framework adapters

Add the Enforce adapter for each framework your application uses. Checks names the operation the adapter controls. Put the core SDK’s governed action around anything under Not covered.

FrameworkPackageChecksNot covered
Anthropic SDK@veriproof/sdk-adapter-anthropicOne non-streaming Messages request and selected text resultStreaming, provider-hosted tools, and direct client calls.
Express@veriproof/sdk-adapter-expressThe supplied JSON route execute functionWork outside the supplied handler and request cancellation without a host signal.
Fastify@veriproof/sdk-adapter-fastifyThe supplied JSON route execute functionWork outside the supplied handler and request cancellation without a host signal.
Genkit@veriproof/sdk-adapter-genkitOwned generate, flow, and local tool callsGenerateStream, provider-hosted tools, and custom tool loops.
Google GenAI@veriproof/sdk-adapter-google-aiOne non-streaming generateContent request and selected text resultStreaming, automatic function calling, and direct client calls.
LangChain.js@veriproof/sdk-adapter-langchainjsLangChain v1 middleware model and local tool callsProvider-hosted tools, custom runtimes that bypass middleware, and stream chunks.
LlamaIndexTS@veriproof/sdk-adapter-llamaindexOwned workflow and local FunctionTool callsRaw streaming, unwrapped tools, and custom workflows outside the adapter.
Mastra@veriproof/sdk-adapter-mastraComplete agent run boundaryPer-tool policy, streaming, and durable agents and networks.
Next.js@veriproof/sdk-adapter-nextjsApp Router JSON handlersPages Router, Server Actions, and streaming responses.
OpenAI Agents@veriproof/sdk-adapter-openai-agentsModel calls and local tool callsStreaming is not covered until the adapter can withhold every emitted item through a bounded buffer. Framework handoffs outside the controlled run function are not covered.
Vercel AI SDK@veriproof/sdk-ai-sdkOwned generateText and local tool callsStreamText and UI streams, provider-hosted tools, and direct model calls.

See the package catalog and TypeScript release notes.

Last updated on