Skip to main content
The adapter is the only code every connector must write. It implements two methods and does nothing else — no lifecycle, no connection, no stream management.

Validate

Rejects inputs the tool cannot possibly run, before any container or network resource is spent.
  • Runs before execution. Keep it cheap — no network calls, no process spawns.
  • Return an error to block the run; return nil to allow it.
  • Upstream validation against the connector’s inputsSchema already runs in the worker, so this is a second line of defense for anything the schema cannot express.

Execute

Runs the tool and streams findings to out.
Rules:
  • Stream, do not buffer. Send each finding to out as it is produced. A long scan should return results before it finishes.
  • Honor cancellation. Stop when ctx.Done() is closed — the runtime may cancel a run mid-flight. select on ctx.Done() when sending.
  • Never close out. The runtime owns the channel.
  • Keep tool-specific code in this package and nowhere else.

Error convention

The worker uses an error’s prefix to decide whether to retry. Apply the prefix to every error you return. The SDK applies the prefix to errors it raises itself. An error with no prefix is treated as retryable.

Wrapping the adapter

connector.New wraps your adapter so the runtime can drive it. You do not call Validate or Execute yourself.

Design notes

  • Prefer in-process embedding over a CLI wrapper where the tool offers a library — no subprocess lifecycle, no output-format drift, cancellation propagates naturally.
  • Remote-API tools ship no bundled binary. The adapter is the client; credentials belong in configSchema, never in code or the image.
  • Map severities explicitly with a lookup table, not string guessing. See Finding.
  • Never leak secrets into findings or logs. Findings are persisted and displayed; config values are not.