Skip to main content
This quickstart uses the current developer entrypoints in sec0-sdk:
  • sec0-sdk/middleware for in-process tool enforcement
  • sec0-sdk/instrumentation for hop decorators and agent-state propagation
  • sec0-sdk/guard for outbound allow, redact, block, and escalate decisions
  • sec0-sdk/middleware plus sec0-sdk/gateway for 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

Store your signing key securely. If you keep the key outside default safe directories (.sec0/keys, keys, config/keys, .sec0/secrets, secrets), set SEC0_SIGNER_KEY_DIRS.

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.
When you need hosted policy, approvals, or remote runtime evaluation, switch the same server to 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 stable nodeId, runId, state propagation, and signed audit envelopes across agent hops:

7. Add Guard Checks for Outbound Messages or API Calls

Use sec0-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:
See Guard API for dashboard and hybrid modes, redaction, and approvals transport wiring.

8. Route Cross-Network Tool Calls Through the Gateway

Use the bridge helper when tool execution crosses a process or network boundary:
Use Gateway Bridge for client options and Network Gateway to deploy the server side.

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:
Then configure 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