Skip to main content

TypeScript SDK Parity

The Pavri TypeScript SDK (@pavri/sdk) is at capability parity with the Python SDK for all P0 and P1 features as of P2-S6.

Current Status: Signed Off (P2-S6)

All required capabilities have been implemented, tested, and signed off. See the full parity matrix at docs/phase2/typescript-sdk-parity-matrix.md.

Capability Summary

#CapabilityStatusLocation
1Config / BootstrapCompletesrc/config.ts
2Agent RegistrationCompletesrc/identity.ts
3Telemetry / Event ExportCompletesrc/telemetry.ts
4Policy Fetch & CacheCompletesrc/policy.ts
5Runtime Log ForwardingCompletesrc/models.ts (RuntimeLogRecord)
6Trace Link CaptureCompletesrc/models.ts (ProviderTraceLink)
7Policy EnforcementCompletesrc/policy.ts + src/errors.ts
8Execution Governance HooksCompletesrc/models.ts (GovernanceMetadata)
9Threat Detection (Local)Out of scopePython-only; TS uses backend API
10Framework PluginsCompletesrc/plugins/generic.ts
11TransportCompletesrc/transport.ts + src/client.ts
12Identity / FingerprintingCompletesrc/identity.ts

Quick Start (Node.js)

import { secure, createConfig } from "@pavri/sdk";

const config = createConfig({
endpoint: "http://localhost:50051",
agentName: "my-node-agent",
framework: "generic",
team: "platform",
environment: "production",
});

const runtime = await secure(config);

Policy Enforcement

The TypeScript SDK enforces policies and throws PolicyDeniedError for denied actions:

import { PolicyDeniedError } from "@pavri/sdk";

try {
await runtime.enforce({ action: "tool_call", target: "exec_shell" });
} catch (err) {
if (err instanceof PolicyDeniedError) {
console.log("Denied by policy:", err.policyId, err.ruleId);
}
}

Governance Metadata

Governance metadata is emitted alongside telemetry:

import { GovernanceMetadata } from "@pavri/sdk";
// GovernanceMetadata is automatically attached to telemetry events
// by the PavriRuntime when enforcement runs

Differences from Python SDK

AreaPython SDKTypeScript SDK
Local threat detectionBuilt-in heuristics + ML baselineNot available (backend detection only)
MCP scannerCLI preflight toolNot available
Framework plugins7 (LangGraph, CrewAI, OpenAI, Claude, ADK, AutoGen, Generic)1 (GenericAdapter + plugin registry)
Behavioral baseliningAvailable (core/behavioral_baseline.py)Not available

These differences are intentional. TS agents rely on the Pavri backend for detection and scoring.

Contract Verification

Cross-SDK contract tests are at:

  • sdk/typescript/tests/unit/models.test.ts — model structural parity
  • sdk/typescript/tests/unit/enums.test.ts — enum value parity
  • sdk/typescript/tests/unit/audit-contract.test.ts — audit event contracts
  • sdk/typescript/tests/unit/discovery-contract.test.ts — discovery contracts
  • sdk/typescript/tests/unit/rbac-contract.test.ts — RBAC contracts