Open Source · MIT · TypeScript

Your AI agent acts.
Now you can see why.

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
The Problem

Capability without authority

Your agent has tool access. But there's no governance between "it can" and "it should."

NO AUDIT

No trail

Which tools got called and why? You're reconstructing from logs after the damage.

NO SCOPE

No purpose binding

Same permissions for "summarize this file" and "push to main." Every task gets the master key.

NO STOP

No escalation

Agent exceeds scope? It just executes. No circuit breaker, no human in the loop, no signal.

Live Demo

Same AI. Now governed.

Governance events stream alongside the AI response. Your frontend renders them in real time.

SSE Event Stream — weops-proxy:3001
The Protocol

7 event types. One stream.

Every AI agent action decomposes into these governance primitives.

01
WorkOrder
Purpose + role + lifecycle
02
Policy
Permit / deny + reason
03
Escalation
7-rung ladder trigger
04
Evidence
Immutable bundles
05
TextDelta
AI response chunks
06
ToolCall
Invocation + result
07
Source
Citations + refs
types.ts
integrate.ts
render.tsx
// @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>
  )
}
Architecture

Zero changes to your backend

WeOps sits between your client and your AI backend as streaming middleware.

01

Your Client

Sends requests to the governance proxy instead of directly to the AI.

02

WeOps Proxy

Evaluates tool calls against purpose-scoped policies. Injects governance events.

03

AI Backend

Anthropic, OpenAI, local models — unchanged. The proxy reads and annotates the stream.

04

Evidence Ledger

Every decision produces an immutable evidence bundle. Audit-ready by construction.

Ecosystem

One protocol, many domains

@weops/stream-types is the governance layer. Domain assemblies add context-specific policies.

loveflow.dev

LoveFlow Commerce

Multi-vendor coordination with atomicity guarantees. Compensation architecture for when things go wrong.

In development
cognifiq.ai

Cognifiq Enterprise

Governed cross-team reasoning and institutional decision support. When departments disagree, the system helps.

Coming soon
middlecare.com

MiddleCare

HIPAA-compliant AI governance. Purpose-bound PHI access, equity envelopes, clinical escalation.

Coming soon
caregraph.io

CareGraph

The patient as durable object. Care continuity as an architectural property, not a messaging problem.

Research paper

The agent proposes.
The policy engine disposes.

Structured observability for AI agent tool use. Open source. Ship in 10 minutes.

Get Started Read the Docs