Skip to content

Integrations

Build a Provider Driver

Build, test, package, install, trust, and enable a provider driver that does not ship with Octant, starting from the example loopback driver.

  • 13 min read
  • 11 sections

Build a Provider Driver ​

An outside provider driver lets Octant use a model service that has no driver bundled with Octant. You write it as a small JavaScript package; a person reviews it, installs it, trusts it, and switches it on, each as a separate step, and then adds a provider from it under Providers and models.

A driver only translates. Octant sends it a conversation, and the driver turns it into the requests its model service understands and the service's answers back into text and tool calls. Octant does everything else: the agent loop, tools and approvals, retries, the transcript, and checking whether a model can use Octant's tools (Verify tools). Nothing a driver claims raises what Octant lets it do.

What a driver can reach ​

A driver runs in its own process, one per provider, confined by the operating system:

  • No network. The driver asks Octant to make each request for it, and Octant sends it only to the address the person entered when they added the provider (HTTPS, or HTTP on this computer). Redirects are not followed.
  • No key. If the service needs a key, Octant adds it to each request itself, in the header the person chose. The driver never sees it.
  • No files beyond its own package, and a temporary folder removed when it stops. It cannot start programs.
  • Its text goes nowhere. Failures reach people in Octant's own words, and what the driver writes to stderr is kept bounded and never shown.

A Mac runs an outside driver confined. Linux runs one without confinement, and its provider row says so; under Strict, Linux runs none. Windows never starts one.

Optional provider cloud jobs ​

The public SDK exposes CloudSessionDriver separately from local session acquisition. Its first supported protocol is openai-agents-v1; another protocol is unsupported in this release. Use @octant/provider-sdk/openai-cloud-session-protocol to encode the same closed create/read/cancel operations as the bundled adapter. A third-party driver has no broader HTTP plan or private first-party shortcut.

For an outside driver, expose cloudSessions.protocol = "openai-agents-v1" and create, read, cancel methods through serveOutsideDriver, and return claims.cloudSessions: "supported" from probe. Each method receives its own scoped host HTTP port. Create receives the reviewed job ID, model and text; read receives the owned remote ID; cancel receives the remote and local job IDs. Return the normalized observation or cancellation result defined by @octant/contracts/provider-cloud-sessions. Do not interpret cancel requested as a completed turn.

The host requires the exact official API endpoint and bearer-key profile, enabled/trusted activation, observed capability, independent endpoint opt-in, current Code authority and exact per-job consent. The scoped port seals the method/path/body, reviewed text/model, disabled network and empty tools/files/ environment. It refuses another job ID, changed input, broader configuration or duplicate create. The host adds the credential and records the actual created ID before forwarding the bounded response. An ambiguous create must not be retried. The ordinary outside-driver HTTP port cannot create/read/cancel Agents API jobs without this owned operation.

Run runCloudSessionConformance from @octant/provider-sdk/cloud-session-conformance against your adapter with synthetic HTTP. Also exercise the ordinary outside-driver conformance kit. These checks establish local protocol behavior, not real account eligibility, provider confinement or billing. The Code workflow describes the current text-only input, cancellation, cost and retention limits.

Start from the example ​

The Octant repository holds an example driver package at packages/provider-sdk/examples/loopback-chat-driver. It speaks the OpenAI-compatible chat completions protocol of a model server running on your Mac, such as llama.cpp's llama-server, LM Studio, vLLM, or Ollama's /v1 address:

text
loopback-chat-driver/
├── octant-provider-driver.json   the driver's description
├── driver.mjs                    the entry Octant runs
└── lib/
    ├── loopback-chat.mjs         the translation
    └── outside-driver-serve.mjs  the serve helper, copied from the provider SDK

To try it, start your model server, then add the folder as described in Install, trust, and switch it on. For the provider, enter the server's address (for example http://127.0.0.1:8080/v1), choose No key (this computer only), and list the model IDs the server serves.

Package rules ​

A driver package is a folder whose root holds octant-provider-driver.json:

json
{
  "driverKind": "outside-harness-endpoint",
  "protocolVersions": ["harness-endpoint/1"],
  "manifest": {
    "manifestVersion": 1,
    "slug": "loopback-chat-example",
    "displayName": "Loopback chat (example)",
    "version": "0.1.0",
    "provenance": { "publisher": "Example", "canonicalUrl": "https://example.com/driver" },
    "license": { "kind": "spdx", "identifier": "MIT" },
    "compatibility": {
      "platforms": ["macos"],
      "modes": ["chat", "work", "code"],
      "providerFamilies": []
    },
    "declaredCapabilities": [],
    "primaryComponentId": "driver",
    "components": [
      {
        "id": "driver",
        "kind": "provider-driver",
        "displayName": "Loopback chat (example)",
        "declaredCapabilities": [],
        "entryPoint": "driver.mjs"
      }
    ]
  }
}

Octant refuses a package, before installing it, when:

  • its entry is not a .mjs file inside the package. The entry is plain JavaScript in an ES module; Octant runs it on its own runtime, which is Electron's Node in the app, and .mjs is the one suffix every runtime loads that way. TypeScript must be compiled to JavaScript first;
  • it holds any file with an execute permission, native code (a .node, .dylib, .so, .dll, or .exe, or a compiled program under any name), or an install script (a binding.gyp, or an install step in any package.json). Octant runs no install step, so ship every module your driver imports inside the package;
  • it declares capabilities or contributions, holds more than the one provider-driver component, or uses a bundled driver's name as its slug;
  • it speaks no protocol version Octant speaks (harness-endpoint/1, or image-generation/1 for an image driver, video-generation/1 for a video driver);
  • the description states the package's own identity, source, digest, or review (extensionId, packageId, source, digest, reviewed, or reviewedAt). Octant sets those itself.

Write the driver ​

Octant and the driver exchange one JSON-RPC 2.0 message per line on the driver's stdin and stdout. The serve helper speaks that protocol for you: copy packages/provider-sdk/src/outsideDriverServe.mjs from the Octant repository into your package (it is not published to npm yet) and import it from your entry:

js
import { OutsideDriverFailure, serveOutsideDriver } from "./lib/outside-driver-serve.mjs";

let baseUrl = "";

serveOutsideDriver({
  // The address and model IDs the person entered when they added the provider.
  initialize(configuration) {
    // Ends in "/" so `new URL("models", baseUrl)` keeps a path such as `/v1`.
    baseUrl = configuration.baseUrl.replace(/\/?$/, "/");
  },
  // The models the service can serve; Octant offers only the ones the person listed.
  async probe(host) {
    const response = await host.http({ url: new URL("models", baseUrl).href, method: "GET" });
    if (!response.ok) throw new OutsideDriverFailure("unavailable");
    const body = await response.json();
    return { models: body.data.map((model) => ({ id: model.id })) };
  },
  // One model request: stream what arrives, then settle with the whole answer.
  async send({ request }, turn) {
    const response = await turn.host.http({
      url: new URL("chat", baseUrl).href,
      method: "POST",
      headers: [["content-type", "application/json"]],
      // Your translation of Octant's request into the service's own.
      body: JSON.stringify(serviceRequest(request)),
    });
    if (response.status === 429) throw new OutsideDriverFailure("rate-limited");
    let text = "";
    for await (const piece of response.chunks()) {
      if (turn.signal.aborted) throw new OutsideDriverFailure("interrupted");
      // A piece can end anywhere, even mid-line: a service that streams lines
      // or events needs them buffered and parsed only once whole.
      text += piece;
      turn.emit({ kind: "text-delta", text: piece });
    }
    return { text, toolCalls: [] };
  },
});

What Octant holds a driver to:

  • Write only what the protocol names. Octant reads every message strictly and stops the driver at the first one it cannot read: a field the protocol does not have, a model name longer than 256 characters, more than 256 models, or a line that is not a protocol message. Nothing but protocol messages may go to stdout; the serve helper sends console output to stderr for you.
  • Fail with a category. Throw OutsideDriverFailure with one of unavailable, unauthenticated, unauthorized, rate-limited, unsupported, incompatible, invalid-configuration, protocol, interrupted, or provider-failed. Add retryAfterMs to a rate limit, and contextOverflow: { contextWindowTokens } when the request outgrew the model's window, so Octant can shorten the next one. Any other error becomes provider-failed; your message text is never shown.
  • Ask for the key where the service reads it. A request that needs the key names the header with auth, for example auth: { header: "authorization", scheme: "Bearer" }, which matches Bearer token in the provider's setup, or auth: { header: "x-api-key" } for A header of its own. Tell people which one your driver uses: Octant refuses a request that asks for the key anywhere else, or for a provider added with No key. A driver never sets authorization, cookie, host, or proxy-authorization itself.
  • Leave retries, tools, and images to Octant. Octant retries a failed request itself, decides which models may use its tools, and does not send a driver the files a person attaches.

Test it in your CI ​

The conformance kit plays Octant's part against your driver's process, using a fake model service you write, and fails the run at the first message Octant would refuse. It lives in the provider SDK in the Octant repository (@octant/provider-sdk/outside-driver-conformance):

ts
import { spawn } from "node:child_process";
import { createInterface } from "node:readline";
import { runOutsideDriverConformance } from "@octant/provider-sdk/outside-driver-conformance";

const child = spawn("node", ["driver.mjs"], { stdio: ["pipe", "pipe", "inherit"] });
const lines = createInterface({ input: child.stdout });

await runOutsideDriverConformance({
  channel: {
    write: (line) => child.stdin.write(`${line}\n`),
    onLine: (listener) => lines.on("line", listener),
  },
  configuration: { baseUrl: "http://127.0.0.1:8080/v1/", modelIds: ["local-model"] },
  // How a provider for your service sends its key; leave it out for none.
  key: undefined,
  // Your fake model service; the kit makes the driver's requests through it.
  fetch: fakeModelService,
  request: {
    sessionId: "00000000-0000-4000-8000-000000000001",
    modelId: "local-model",
    history: [{ role: "user", text: "Say hello" }],
    tools: [],
  },
});

The kit checks the handshake, the probe, a streamed answer, that the driver keeps answering after a cancel (even one that lands while it is reading an answer) and after a session ends, that its failures carry a category, and that every request it asks for stays on the configured address and asks for the key only where the provider sends it. It hands the driver response bodies in small pieces, as Octant does. Passing the kit installs, trusts, and switches on nothing: Octant checks every message again when it runs the driver, and runs Verify tools itself.

An image generation driver ​

A driver can generate images instead of chatting. Its description names the image family and protocol, and its one component declares the models it offers with the price per image its service publishes, in whole micro-dollars (40000 is 4 cents). A model with no usdMicrosPerImage has no published price, and Octant refuses it while a spend limit is set.

json
{
  "driverKind": "outside-image",
  "protocolVersions": ["image-generation/1"],
  "manifest": {
    "primaryComponentId": "images",
    "components": [
      {
        "id": "images",
        "kind": "provider-driver",
        "displayName": "Example images",
        "declaredCapabilities": [],
        "entryPoint": "images.mjs",
        "mediaGeneration": {
          "media": "image",
          "models": [
            { "modelId": "example-image-1", "usdMicrosPerImage": 40000 },
            { "modelId": "example-image-draft" }
          ]
        }
      }
    ]
  }
}

The rest of the manifest is as for any driver. Octant refuses the package when its kind, protocol versions, and mediaGeneration do not agree, when a price is not a positive whole number up to 100 dollars, or when a model is listed twice.

After initialize, Octant sends image/generate with the model, the prompt, the number of images it wants, any reference images as base64 bytes (up to 2.5 MiB combined), and the options the person chose. The driver makes its requests with http/request, naming the image/generate call it serves, and answers with { "status": "completed", "images": [...] }, each image either { "mediaType": "image/png", "data": "<base64>" }, { "mediaType": "image/png", "chunked": true } (after streaming its base64 bytes via image/chunk notifications), or { "url": "..." }, or with { "status": "refused" } when the service declines the prompt. If the person stops the job, Octant sends image/cancel and closes the job's requests.

Octant checks the answer itself:

  • No more images than it asked for, or the job fails and keeps none.
  • It reads each image's bytes to tell its type; a type the bytes don't bear out fails the job.
  • It fetches an image given as a url itself, without the key, only when that exact address appeared in a response it relayed for this job.
  • The price is the one in your package, never anything the driver says while it runs; Octant releases its spend reservation when a job fails (though a provider that already answered may still bill your account).

A video generation driver ​

A driver can make video clips. Its description names the video family and protocol, and its one component declares each model in full: what it can make, what it costs, and whether a clip can be stopped or removed. Octant builds the card, the price, and the limits from this, and never from the running driver.

json
{
  "driverKind": "outside-video",
  "protocolVersions": ["video-generation/1"],
  "manifest": {
    "primaryComponentId": "video",
    "components": [
      {
        "id": "video",
        "kind": "provider-driver",
        "displayName": "Example video",
        "declaredCapabilities": [],
        "entryPoint": "video.mjs",
        "mediaGeneration": {
          "media": "video",
          "models": [
            {
              "modelId": "example-video-1",
              "displayName": "Example Video",
              "durations": { "kind": "range", "min": 2, "max": 10 },
              "resolutions": ["720p"],
              "aspectRatios": [{ "ratio": "16:9" }],
              "audio": "none",
              "inputs": {
                "firstFrame": true,
                "lastFrame": false,
                "maxReferenceImages": 0
              },
              "price": {
                "kind": "per-second",
                "rates": [{ "resolution": "720p", "usdMicrosPerSecond": 50000 }]
              },
              "job": {
                "cancel": "running",
                "removal": { "kind": "delete" },
                "resumeWindowHours": 24
              }
            }
          ]
        }
      }
    ]
  }
}

A price is per-second, per-clip, per-token, or unpublished, which Octant refuses while a spend limit is set. Rates are whole micro-dollars above zero: at most 100 dollars a second or a clip, or 10,000 dollars a million tokens. A clip can be at most 600 seconds, and a resume window or a provider's copy at most a year. Octant refuses the package otherwise.

The serveOutsideDriver helper speaks the harness protocol only. A video driver reads and writes the messages itself, one JSON object a line, as an image driver does. After initialize, Octant sends:

  • video/start with the model, the prompt, the chosen options, and any images as base64 bytes (up to 2.5 MiB combined). Answer { "status": "started", "remoteId": "..." }, or { "status": "refused" } when the service declines the prompt.
  • video/poll with that remoteId. Answer running, { "status": "completed", "url": "..." }, refused, cancelled, or { "status": "failed", "category": "provider-failed" }. Add "billed": true when the service charged for a refusal or a failure, and usage with billedSeconds, inputTokens, or outputTokens when it reports a count above zero; leave a zero out, because a zero count stops the driver. Never send an amount or any text.
  • video/cancel, only if the model declares "cancel": "running", answered like a poll.
  • video/forget, only if the model declares "removal": { "kind": "delete" }. Answer { "status": "removed" }.

Every http/request must name the call it serves. Besides GET:

CallMay send
video/startone POST, and another only after the service refused the first outright
video/pollnothing
video/cancelone PUT or DELETE
video/forgetone DELETE

A start is refused outright by a 4xx other than 408, or by a 521, 523, 525, or 526 that carries cf-error-type: 52x and a cf-error-origin. After any other answer a second POST stops the driver, and so does any request the table does not allow. If your service stops a clip only by POST, declare "cancel": "none".

Octant fetches the clip itself, without the key, only over HTTPS or your service's own address, and only when that exact address appeared in a response it relayed for the same check. It decides what a clip may have cost from the requests it saw leave and the answers that came back: a start that fails after your service may have accepted it is counted at the estimate, whatever the driver says. A clip that did start settles by its checks. Usage you report for a completed, cancelled, or billed failed clip can settle it lower, never above the estimate. A refusal with "billed": true counts the whole estimate. A failure or refusal without it is not charged.

Install, trust, and switch it on ​

On a Mac, in the Octant desktop app:

  1. Plugins → Marketplace → Import local Agent Plugin…, and pick the driver's folder.
  2. Review before installing shows the package's name, version, digest, and that it holds a provider driver. Confirm install stores it held: untrusted, switched off, and with no process.
  3. Under Installed, Trust source. Trust holds for the exact contents you reviewed.
  4. Switch the plugin on, and its driver component.
  5. In Settings → Providers & Models → Provider catalog, the driver is listed under Outside drivers. Its setup adds a provider: a name, the service's address, how the key is sent, the key, and the model IDs to offer (for an image or video driver, which of its declared models to offer). The provider is added off.
  6. Turn it on. For a chat driver, use Check connection, which starts the driver for the first time, then use Verify tools on a model before relying on it for Octant's tools. An image or video driver starts at the first image or clip and does not use Verify tools.

These steps are available only in a window on the Mac itself; a paired device, an agent, or a mention cannot install, trust, switch on, or add one.

When you change the driver, import the folder again and install the new version. It arrives held and untrusted, and providers added from the earlier version are blocked, with their history and key. Trusting the new version moves them to it: their next check starts the new version, and their models need Verify tools again.

Signing ​

A driver added from a local folder may be unsigned developer input, and its review says so; trust is bound to the exact contents you reviewed. A publisher can also sign the package, and drivers from a marketplace source must be signed. Local folders and signed npm packages are accepted; see Publishing to npm.

To sign, make an Ed25519 key once and keep it private:

sh
openssl genpkey -algorithm ed25519 -out driver-signing-key.pem

Then sign the folder after its last change, with the signing tool from the author kit (plain JavaScript; it runs on Node or Bun):

sh
node outsideDriverSign.mjs ./my-driver --key-file driver-signing-key.pem
# or read the key from standard input
node outsideDriverSign.mjs ./my-driver --key-stdin < driver-signing-key.pem

It writes octant-signature.json beside octant-provider-driver.json and prints the key's fingerprint (ed25519:…); it never writes or prints the private key. The file lists the SHA-256 of every other file in the folder and signs them with the driver's name (its slug), version, and protocol versions. Octant hashes every file again itself, so changing, adding, or removing a file after signing makes the signature invalid, and the folder is refused.

The first time you trust a signed driver, Octant pins its publisher key for that name and source, and keeps the pin even if you uninstall it. A later version, or a reinstall, signed by another key is held: under Plugins, its card shows the pinned key and the new one side by side. Trust new publisher replaces the pin and clears what its providers verified, and you then trust the version as usual; Forget publisher drops the pin.

Publishing to npm ​

A person installs your driver with octant plugin install npm:@scope/name or from Marketplace. Octant downloads the one tarball, checks it against the integrity the registry published, verifies your signature, and runs no install script. A driver from npm must be signed, and the signature must name the npm package:

sh
node outsideDriverSign.mjs ./my-driver --key-file driver-signing-key.pem --name @scope/name

Sign the exact files the tarball will hold: run npm pack, unpack it, sign the unpacked folder, and publish from that folder. A file that npm pack adds after signing makes the signature invalid. The version in octant-provider-driver.json must equal the version in package.json, the package must have no preinstall, install, postinstall, or prepare script, and it must hold no native code or executable file.

Octant documentation · local-first by design