Skip to Content

gateway

A gateway block runs a managed subprocess that bridges Squadron to an external system — a Discord channel, a Slack workspace, a Microsoft Teams chat, a custom web dashboard, anything you build against the Gateway SDK.

The gateway subscribes to live human_input_requested / human_input_resolved events from Squadron and surfaces them in its target system; user actions in that system flow back to Squadron through the same record store. From the agent’s perspective, an answer in Discord is indistinguishable from one typed into the Command Center Inbox.

Squadron supports at most one gateway block per instance.

Minimal Example — Discord

variable "discord_bot_token" { secret = true } variable "discord_channel_id" {} gateway "discord" { source = "github.com/mlund01/squadron-gateway-discord" version = "v0.0.1" settings = { bot_token = vars.discord_bot_token channel_id = vars.discord_channel_id checkpoint_path = "${path.cwd}/.squadron/discord-gateway.json" } }

Restart Squadron and the next builtins.human.ask call will appear in the configured Discord channel as a message with quick-reply buttons (or a multi-select dropdown when multi_select = true on the tool call).

Fields

FieldTypeRequiredDescription
name (label)stringyesUsed in logs and the install path (.squadron/gateways/<platform>/<name>/<version>/gateway).
sourcestringyes (unless version = "local")GitHub source path. Squadron downloads the matching release archive on first load.
versionstringyesRelease tag (e.g. v0.0.1) or local to use a developer-built binary.
settingsmapnoFree-form key/value map passed to the gateway’s Configure. Each gateway documents its own keys.

Lifecycle

  • squadron verify pre-flights the install (download + checksum verify) and exits non-zero if the gateway can’t be installed — same fail-loudly behavior as plugins.
  • squadron engage re-runs the install pre-flight before the daemon signals ready, so a broken gateway fails the engage command instead of leaving you with a half-running daemon.
  • Once installed, Squadron launches the gateway as a managed subprocess at startup (same install model as native plugins).
  • A watchdog polls the subprocess and automatically restarts on crash with exponential backoff (capped at 30s).
  • The SDK includes orphan prevention — if the parent Squadron process dies, the gateway exits on the next watchdog tick rather than lingering.
  • On reconnect, the gateway uses a checkpoint (timestamp of the last event it processed) to catch up via ListHumanInputs(Since=…) so no questions are dropped during a transient disconnect.

Local Development

Use version = "local" to skip the GitHub download and use a binary you’ve placed at the cache path:

gateway "discord" { version = "local" settings = { ... } }

Build and install:

go build -o gateway . mkdir -p ~/.squadron/gateways/darwin-arm64/discord/local mv gateway ~/.squadron/gateways/darwin-arm64/discord/local/gateway

Adjust the platform path to match runtime.GOOS-runtime.GOARCH.

Available Gateways

Building Your Own

Gateways are Go programs built against squadron-gateway-sdk. See the SDK README for the Gateway interface, hello-world template, catch-up patterns, and the release-archive shape Squadron expects when distributing your gateway.

Last updated on