Apache-2.0v0.1zero dependenciesNode · Workers · browser

The Constitution Kernel.

Model-layer alignment stops at the model. The action layer — where a tool call actually executes — needs its own gate. This is that gate: a tiny, dependency-free library that enforces a machine-readable Constitution before an agent acts. It's the exact policy logic FlowDesk runs server-side, extracted so any MCP server, agent runtime, or API gateway can drop it in.

Install

One file, no build step. Vendor it, or load it directly:

// Node / bundler const { enforce } = require('./flowdesk-constitution-kernel.js'); // Browser / Worker <script src="https://flowdesk-landing-2yz.pages.dev/kernel/flowdesk-constitution-kernel.js"></script> // → window.FlowDeskConstitution.enforce(...)

⬇ flowdesk-constitution-kernel.js · the rule schema is documented in the Constitution spec v0.1.

Enforce before you execute

const rules = { // the workspace Constitution max_priority: 'high', forbidden_terms: ['wire transfer', 'delete production'], quiet_hours_utc: { start: 22, end: 6 }, require_approval_below_confidence: 0.8 }; function beforeToolCall(action, confidence) { const v = enforce(rules, action, { confidence }); if (!v.allow && v.requiresApproval) return stageForHumanApproval(action); // confidence gate if (!v.allow) return deny(v.violation); // { rule, message } — audit it return execute(action); // allowed }

enforce() returns { allow, violation, requiresApproval }. Deny → return the rule to the agent and log it. requiresApproval → route to a human queue. allow → run the tool call. Per-agent rules merge on top of the workspace's via mergeRules(ws, key) — union the forbidden lists, tighten the caps.

Try it — runs in your browser

The same kernel that's loaded on this page, evaluating live:

// click a button — verdicts computed by the kernel, not a server

Why a kernel, not an API

This is a reference implementation, not a sandbox. The kernel decides allow/deny; your runtime still has to actually stop on a deny, write the audit row, and wire the kill-switch. FlowDesk provides those rails server-side — see the showcase.