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.
The package registry instructions use VeriProof's public GitLab feeds. Installs require no GitLab account or package credential. See SDK access for workstation and CI guidance.
VeriProof packages used here: @veriproof/sdk-core, @veriproof/sdk-adapter-openai-agents.
Store the API 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.
A review_context_required result means policy asked for human review, but the call didn’t include review options, so no review was opened. VeriProof recorded the attempt. Add review options with an active review profile and run the action again.
Report token usage
Declare the model call with executionDescriptor, then report the counts the provider returned from inside the action. VeriProof prices the call from those counts and the call’s model.
const result = await veriproof.govern(
'support.reply',
request,
async ({ input, reportTokenUsage, signal }) => {
const response = await provider.complete(input, { signal });
reportTokenUsage({
inputTokens: response.usage.inputTokens,
outputTokens: response.usage.outputTokens,
});
return { text: response.text };
},
{
model: { id: 'gpt-4.1-mini', provider: 'openai' },
executionDescriptor: { kind: 'model_invocation', operation: 'chat' },
},
);The counts are metadata, so VeriProof records them even when content capture is off. The last report wins. VeriProof records the model call when the action returns, so a call that throws has no counts. reportTokenUsage throws a TypeError and records nothing for a count that isn’t an integer from 0 to 2147483647, or when the call declared no model invocation. tryReportTokenUsage takes the same argument and returns false instead of throwing. A review checkpoint keeps the declaration for resume.
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 Edge API endpoint of your VeriProof Agent Gateway 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.
| Framework | Package | Checks | Not covered |
|---|---|---|---|
| Anthropic SDK | @veriproof/sdk-adapter-anthropic | One non-streaming Messages request and selected text result | Streaming, provider-hosted tools, and direct client calls. |
| Express | @veriproof/sdk-adapter-express | The supplied JSON route execute function | Work outside the supplied handler and request cancellation without a host signal. |
| Fastify | @veriproof/sdk-adapter-fastify | The supplied JSON route execute function | Work outside the supplied handler and request cancellation without a host signal. |
| Genkit | @veriproof/sdk-adapter-genkit | Owned generate, flow, and local tool calls | GenerateStream, provider-hosted tools, and custom tool loops. |
| Google GenAI | @veriproof/sdk-adapter-google-ai | One non-streaming generateContent request and selected text result | Streaming, automatic function calling, and direct client calls. |
| LangChain.js | @veriproof/sdk-adapter-langchainjs | LangChain v1 middleware model calls, including calls that offer tools, and selected local tool calls | Provider-hosted tools, custom runtimes that bypass middleware, and stream chunks. |
| LlamaIndexTS | @veriproof/sdk-adapter-llamaindex | Owned agent workflow runs and selected or wrapped local tool calls | Raw streaming, local tools left out of the tools selection, and custom workflows outside the adapter. |
| Mastra | @veriproof/sdk-adapter-mastra | Buffered Agent.generate runs and selected local tool calls | Streaming, local tools left out of the tools selection, and durable agents and networks. |
| Next.js | @veriproof/sdk-adapter-nextjs | App Router JSON handlers | Pages Router, Server Actions, and streaming responses. |
| OpenAI Agents | @veriproof/sdk-adapter-openai-agents | Model calls and local tool calls | Streaming 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-sdk | Owned generateText runs and selected local tool calls | StreamText and UI streams, provider-hosted tools, local tools left out of the tools selection, and direct ToolLoopAgent and model calls. |
See the package catalog and TypeScript release notes.