TrustProof-Protocol

LangChain Integration

What It Does

wrapToolWithTrustProof(...) wraps a LangChain tool call and emits a TrustProof JWT per invocation.

For each call, it:

Implementation:

Run the Example

pnpm --filter @trustproof/sdk example:langchain

Example script:

Minimal Usage

import { wrapToolWithTrustProof } from "@trustproof/sdk";

const wrapped = wrapToolWithTrustProof(tool, {
  privateKeyPem,
  subject: { type: "agent", id: "agent_demo_1" },
  action: "agent.tool.payout.quote",
  resource: { type: "tool", id: "payout.quote" },
  policy: { policy_v: "v0", scopes: ["tools:invoke"], constraints: {} }
});

const { output, proof_jwt } = await wrapped.invoke(input);

Naming Convention

Use stable, parseable action names: