@tensflare/openai
v0.1.0
Published
OpenAI Agents SDK middleware that injects Truss recording into agent handoffs and runs
Readme

@tensflare/openai
OpenAI Agents SDK middleware — wraps agent handoffs and runs to record them as Truss actions.
What is Truss?
Truss is an accountability layer for AI agents — it records every agent action as a cryptographically signed, tamper-evident audit trail. Learn more →
Overview
Wrap OpenAI Agents SDK handoff handlers and run handlers to automatically compute SHA-256 hashes and POST openai_handoff and openai_agent_run action records to the Truss API. Fail-open — operations proceed normally even if recording fails.
Installation
npm install @tensflare/openaiQuick start
import { TrussOpenAIMiddleware } from "@tensflare/openai";
const truss = new TrussOpenAIMiddleware({
apiUrl: "http://localhost:4000",
apiKey: "tr_your_api_key",
mandateId: "mnd_001",
});
// Wrap agent-to-agent handoffs
const wrappedHandoff = truss.wrapHandoff(myHandoffHandler);
// Wrap agent run execution
const wrappedRun = truss.wrapRun(myRunHandler);API
new TrussOpenAIMiddleware(options)
| Option | Type | Description |
|---|---|---|
| apiUrl | string | Truss API base URL |
| apiKey | string | Truss API key |
| mandateId | string | Mandate ID to record actions under |
middleware.wrapHandoff(handoffFn)
Wraps a handoff handler (event: HandoffEvent) => Promise<unknown>. Records openai_handoff actions.
middleware.wrapRun(runFn)
Wraps a run handler (input: AgentRunInput) => Promise<unknown>. Records openai_agent_run actions.
Related packages
| Package | Description | |---|---| | @tensflare/sk | Semantic Kernel middleware (same pattern) | | @tensflare/llamaindex | LlamaIndex middleware (same pattern) | | @tensflare/truss-sdk | TypeScript SDK | | @tensflare/tap | Core Zod schemas |
Development
npm install
npm run build
npm testContributing
Pull requests are welcome. Please see the contribution guidelines.
License
Apache 2.0 — see LICENSE.
