Typed governance events that stream alongside AI responses. Purpose binding, policy checks, evidence trails — in real time.
npm install @weops/stream-types
click to copy
Your agent has tool access. But there's no governance between "it can" and "it should."
Which tools got called and why? You're reconstructing from logs after the damage.
Same permissions for "summarize this file" and "push to main." Every task gets the master key.
Agent exceeds scope? It just executes. No circuit breaker, no human in the loop, no signal.
Governance events stream alongside the AI response. Your frontend renders them in real time.
Every AI agent action decomposes into these governance primitives.
// @weops/stream-types — core governance event types import type { GovernanceEvent } from '@weops/stream-types' interface WorkOrderEvent { type: 'data-workorder' id: string // wo_8f3a... purpose: string // "FileSystem.Read" role: string // "DEVELOPER" status: 'DRAFT' | 'APPROVED' | 'RUNNING' | 'COMPLETED' | 'FAILED' } interface PolicyEvent { type: 'data-governance' decision: 'PERMIT' | 'DENY' reason: string // human-readable obligations?: string[] // post-conditions } interface EscalationEvent { type: 'data-escalation' rung: number // 1-7 severity trigger: string // "SCOPE_EXCEEDED" action: string // required resolution } type GovernanceEvent = | WorkOrderEvent | PolicyEvent | EscalationEvent | EvidenceEvent | TextDeltaEvent | ToolCallEvent | SourceEvent
// Wrap any AI backend with governance streaming import { createGovernanceProxy } from '@weops/stream-types/proxy' const proxy = createGovernanceProxy({ upstream: 'https://api.anthropic.com/v1/messages', policies: './policies.yaml', }) // Your existing SSE stream passes through unchanged. // Governance events are injected alongside AI responses. proxy.on('tool_call', (call) => { // Every tool invocation is evaluated against purpose scope // BEFORE execution — not after. const decision = proxy.evaluate({ tool: call.name, purpose: call.workOrder.purpose, role: call.workOrder.role, }) if (decision.action === 'DENY') { proxy.escalate(call, decision.reason) return // tool never executes } proxy.permit(call, decision.obligations) }) // Start on port 3001. That's it. proxy.listen(3001)
// React component — render governance inline import { useGovernanceStream } from '@weops/stream-types/react' export function GovernedChat() { const { events, text, status } = useGovernanceStream('/api/chat') return ( <div> {events.map(event => ( <GovernanceEvent key={event.id} event={event} {/* Renders: work order badge, permit/deny pill, escalation alert, evidence link — based on type */ /> ))} <div className="response">{text}</div> {status === 'escalated' && ( <EscalationBanner onApprove={() => events.resolve('approve')} onDeny={() => events.resolve('deny')} /> )} </div> ) }
WeOps sits between your client and your AI backend as streaming middleware.
Sends requests to the governance proxy instead of directly to the AI.
Evaluates tool calls against purpose-scoped policies. Injects governance events.
Anthropic, OpenAI, local models — unchanged. The proxy reads and annotates the stream.
Every decision produces an immutable evidence bundle. Audit-ready by construction.
@weops/stream-types is the governance layer. Domain assemblies add context-specific policies.
Multi-vendor coordination with atomicity guarantees. Compensation architecture for when things go wrong.
Governed cross-team reasoning and institutional decision support. When departments disagree, the system helps.
HIPAA-compliant AI governance. Purpose-bound PHI access, equity envelopes, clinical escalation.
The patient as durable object. Care continuity as an architectural property, not a messaging problem.
Structured observability for AI agent tool use. Open source. Ship in 10 minutes.