createTrustProofAgentHook(...) provides SDK-agnostic hook handlers for agent lifecycle events.
For each completed action/tool event, it:
Implementation:
pnpm --filter @trustproof/sdk example:openai-agents
Example script:
import { createTrustProofAgentHook } from "@trustproof/sdk";
const hook = createTrustProofAgentHook({
privateKeyPem,
subject: { type: "agent", id: "agent_demo_1" },
policy: { policy_v: "v0", scopes: ["tools:invoke"], constraints: {} },
chain: { enabled: true }
});
const { proof_jwt } = await hook.onToolEnd({
tool_name: "payout.initiate",
input,
output,
action_name: "agent.tool.payout.initiate"
});
Keep the adapter thin:
action_name, tool_name, input, output, resource, timestamp, jti)onToolEnd(...) / onActionEnd(...) at completion pointsgetChain().proofs externally if you need cross-process continuityAvoid deep coupling to transient SDK types; keep mapping logic isolated.