sec0-sdk:
sec0-sdk/middlewarefor in-process tool enforcementsec0-sdk/instrumentationfor hop decorators and agent-state propagationsec0-sdk/guardfor outbound allow, redact, block, and escalate decisionssec0-sdk/middlewareplussec0-sdk/gatewayfor cross-network tool calls
Prerequisites
- Node.js >= 20
- An Ed25519 signing key
- A local
policy.yaml - Optional: a Sec0 API key when you switch to hosted policy or approvals
1. Install the SDK
2. Generate a Signing Key
3. Create a Minimal policy.yaml
Start with a local, observe-mode policy:
4. Wrap a Tool Server with sec0LocalMiddleware
For a first integration, use the local preset. It keeps policy, runtime decisions, approvals, and audit writes on-device.
sec0HostedMiddleware. See Middleware.
5. Register Hop Metadata in sec0.config.yaml
Instrumentation uses sec0.config.yaml to resolve hop identity, gateway defaults, and local storage:
6. Initialize Decorators and Propagate Agent State
Decorators give you stablenodeId, runId, state propagation, and signed audit envelopes across agent hops:
7. Add Guard Checks for Outbound Messages or API Calls
Usesec0-sdk/guard when the action is not naturally wrapped by the middleware, or when you want a simple allow, redact, block, and escalate API in application code:
8. Route Cross-Network Tool Calls Through the Gateway
Use the bridge helper when tool execution crosses a process or network boundary:9. Switch to Hosted Policy and Approvals When Ready
Replace the local preset with the hosted preset when you want control-plane policy sync, escalation creation, or remote runtime evaluation:enforcement.escalate_on plus security.side_effects.human_escalation and connect the approvals bridge. See Approvals & Escalations.
10. Verify
Use the Verify & Troubleshoot checklist to confirm each layer is working.What’s Next?
Middleware
Wrap tool servers and choose local vs hosted presets
Guard API
Gate outbound messages, tool calls, and APIs
Instrumentation
Register hops, decorators, and propagation
Gateway
Add network-edge enforcement and brokering