Skip to main content
A connector is your project’s link to one other service, such as a Slack workspace or a GitHub repository. It has a name, unique in the project, and one side or both:
  • The inbound side is a webhook URL, https://webhook.paddock.build/con_.... A function runs on every request to it: it verifies the request, answers a handshake, or accepts it with a list of routes, each a message for one agent’s session. paddock records the request and delivers the routes; you run no server in between.
  • The outbound side lets agents speak. An agent calls the send tool with a key such as slack-acme:C0123ABCD, and the connector’s deliver function posts the message, with credentials the sandbox never sees. See Sending messages.

Create a connector

From a terminal, the CLI does the same, the secret read from standard input so that it never lands in your shell history:
Give the sender the URL and the same secret. The Python SDK takes requests as dictionaries spelled as the API spells them, or as the models in paddockai.types. The URL is unguessable, and only the inbound function decides what a request must prove. A side without a function is inert: the inbound side answers every request 503, and the outbound side refuses every send.

Inbound functions

The inbound function is one file of Node.js or Python, or a preset. It sees each request as the sender sent it, with the connector’s secrets, and answers one of three ways: A thrown error, an answer outside these shapes, or a timeout is 503, so the sender retries. Connector functions has the whole contract, the runtimes, and the limits.

Routes

Each route is one message for one agent: A route with a session key reaches the agent’s active session whose connectorKey metadata equals the key, or creates one with that metadata and the route’s settings. So every event about one pull request lands in one conversation, with the agent’s earlier work in context. Two routes with one key for one agent reach the same session, each with its own message. Find a key’s session with a metadata filter:

Presets

A preset is stock code for one service, in both runtimes. Setting a side’s function from a preset copies its code and default params; you set the secrets it reads and fill its params. While the code is still the preset’s, functionSummary.presetCode is true and the console edits the params as a form; edit the code and it is yours. connectors.functionPresets() returns every preset with its code and the params it declares. Every inbound preset that verifies a signature also accepts a secret named previous, so you can rotate without dropping requests: set the old value as previous, rotate default, and delete previous once the sender has the new one. Routing params of route-all and the signature presets: github: params agent, repository (owner/name; empty, any), reviewEvents (default opened,synchronize,reopened), drafts (default false), and mention. A pull request event with one of those actions goes to the session {repository}#{number}, asking for a review; a new comment on a pull request containing the mention, not written by a bot, goes to the same session, asking for an answer. Any other event, ping among them, is accepted with no route. Set the webhook’s content type to application/json and its events to pull requests and issue comments. slack: params agent, mentions, and threadReplies (both default true). A mention goes to the session of its thread, with the thread as its reply key, so the agent’s send without a key answers in the thread; a thread reply not mentioning the bot reaches only a session that wrote in that thread; a slash command starts a new session that answers in its channel.

Test a function

connector.functions.test runs the saved function, or a draft, on a sample request exactly as a real one runs, and shows the answer a sender would get, the dedupe key, the routes, and what the code logged. It records and delivers nothing.
With the CLI, put the sample request in a JSON file and run paddock connectors fn test github-acme-web --side inbound --request ping.json, adding --file handler.mjs to try a draft. Pass deliveryId instead of event to run a recorded request again, replay: true to run it as a replay would, and draft: { runtime, code, params } to try code before you set it.

Deliveries

Every request to the URL is a delivery, recorded before the sender is answered, with one outcome per route.
What a delivery promises:
  • Exactly once. Each delivered route appends one message, however often an attempt is retried.
  • Deduplication. A request with the dedupe key the function returned, or without one the same body, as a delivery the connector already has is answered 200 with that delivery’s ID and recorded nowhere. A rejected request is never deduplicated against.
  • Retries. A passing failure is retried up to 5 attempts, 30 seconds, 2, 8, and 32 minutes apart; each attempt runs only the routes still pending.
  • Order. Routes for one agent and session key are delivered in the order their requests arrived; a route to a new session never waits.
connector.deliveries.get adds the request as received: its method, URL, headers, and body.

Replay

connector.deliveries.replay(id) runs the current inbound function again on a recorded request, for real, as a new delivery with replayOf set. Deduplication never drops it, and its routes are what the code returns now, so a fixed function can redo what an earlier version got wrong. The function sees ctx.replay = { receivedAt }, the first delivery’s receipt time, and every preset measures a signature’s timestamp against it. A handshake cannot be replayed.

Update and delete

connectors.update(id, { inbound, outbound }) sets which sides exist and the outbound rate limit: a side kept keeps its function and URL, and a side left out is removed with its function. connectors.delete(id) deletes both functions, then the connector: its URL answers 404 at once, its deliveries and outbox messages are removed, and the sessions it created stay. A connector has at most 5 secrets, shared by both sides. Only these operations return a value; nothing else does, logs and errors included.