Setup
Declare alive block on your integration entry:
Egress validation
The harness enforces your definition’segress allowlist in live mode. A browser request to an undeclared origin throws EgressDeniedError (from @ekanos/sdk/context, code: 'EGRESS_DENIED'):
redirect: 'error', so a redirect to another origin fails rather than being followed.
This is a harness convenience, not a preview of production enforcement: production runs no egress check on the client path today. Flipping to live mode is still a real test of the declaration under review, not of a second list kept beside it.
Local packages register under a namespace, like the host does
The host registers a partner package under a token,<namespace>__<slug> (for example acme__news), while your code keeps sending its bare SLUG (news). The harness now does the same, so a bug that only shows up in that gap shows up locally first.
- The namespace is the
namespacein your repo’s rootekanos.json, elselocal. A package that setsavailability.mode: "global"stays under its bare slug, as on the host. - Your code does not change. A bare slug sent to
/api/integrations/<slug>/…is resolved to the token with the same function the host runs. A token from another namespace reaches nothing and answersunknown_integration. - Keys use the token.
.ekanos/local-secrets.jsonholds one block per token (local__news), and the live context and stored OAuth tokens are keyed by it too. A file written before this, with blocks under the bare slug (news) or the display name an experience used (acme/news), is read merged and moved under the token the next time the harness writes it; the fixtures pin and Connect-as switches in.ekanos/local-state.jsonmove the same way. There is nothing to do by hand. Savinglocal-secrets.jsonmid sign-in no longer drops the sign-in. - The redirect URI names no integration, as the host’s does:
http://localhost:<port>/api/integrations/oauth/callback. The integration’s token travels in the OAuthstate. Register the one the Local OAuth panel shows; if you registered a per-integration URL for your local app, add this one beside it. - The console names a package
acme/news, never the token. The token appears only in URLs and keys. ctx.integration.slugis the token too, in every context the harness builds (actions, webhooks, schedules,onActivateand tools, in fixtures and live mode). The host’sbuildIntegrationContextis handed the token, so code that builds a URL or a key fromctx.integration.slug(acme__news) behaves the same locally as in production; a global package sees its bare slug. Theslugin your definition stays bare. Fixtures files need no change, since nothing in them names the slug. In fixtures mode the Triggers and Activation pages ask the harness server for the token before they build their context, and a failed lookup shows as a failed run, never as the bare slug.
Credential storage
Live mode reads credentials (the OAuth client id and secret, signed webhooks’ secrets, API keys, and the fields of an activation form) from.ekanos/local-secrets.json in your project root. In a repo, each integration package has its own. The file is gitignored, never packed by ekanos publish, written with mode 0600, and read on every request. The harness generates it on first use.
OAuth tokens are stored in the same file once a Connect completes, and replayed through your onTokens handler when the harness starts, so a restart does not ask you to authorize again. They are not replayed if the OAuth app’s client id changed.
On the integration’s Connect tab, or on the Preview tab’s Activation or Triggers section:
- Find the Local OAuth panel (shown for integrations that declare
oauth, in either mode) - Follow the checklist to create a developer app at your vendor’s console
- Paste the client id, secret, and any webhook signing secrets into the form (one field per secret name your definition declares)
- Click Save credentials
.ekanos/local-secrets.json and never echoes values back. A saved key shows as filled beside an empty field; a blank field keeps what is saved. Saving, or editing a value in the file, rebuilds the live context and forgets any current connection.
Credentials last until you Disconnect. They survive a harness restart, a
browser reload and the regeneration of
.ekanos/harness. An integration whose
credentials are the fields of its activation form stores its string fields
from the Connect tab, and saving again replaces them. Activation data you
submit through the plain activation form on the Preview tab is a different
thing: it is held in memory only, never written to localStorage, a fixture
or the registry, and is cleared on reload and on Disconnect.Live or fixtures per integration
In repo mode the global Data selector is gone. Each integration answers from Live or Fixtures on its own terms:
Pin to fixtures (the button on an integration’s chip, and Unpin to undo it) keeps an integration on fixtures even when it is connected. The pin is saved in the integration package’s
.ekanos/local-state.json as { "pinnedFixtures": { "<slug>": true } }. The file is gitignored, separate from credentials, and survives a restart and the regeneration of .ekanos/harness. Disconnect does not clear a pin.
An integration with No connection needed (its contract’s auth is none and it declares no keys) reads that everywhere in the harness, starts on Live, and has nothing to connect. If it has settings, its Connect tab says “Settings below are optional.” Live reads of a connected integration run with its stored credentials; a widget or page write runs on your click, and a workflow write waits for your approval first.
See Repo mode for the whole picture.
Opting in
An integration with nolive block is fixtures-only; the toolbar control is disabled for it and says why. The harness also forces fixtures mode while a live.egress is wider than the definition’s egress.
One WITH a live block opens in fixtures mode by default. To use live mode:
- Select Live API in the toolbar’s Data dropdown (single-integration project), or
- Declare
live: { default: 'live' }— for integrations whose widgets never call the vendor from the browser (every vendor call is server-side behindctx.fetch)
live.default and is saved in localStorage, so it survives reloads.
Keys that stay mocked (seeds)
live.seeds lists the react-query keys that stay mocked in live mode — Ekanos-side state your widgets read before they can call anything (a saved setting, an account preference). Everything not listed runs its real query function:
- Mocked: Ekanos-side state
- Live: your vendor
OAuth loop on localhost
For an integration withoauth declared:
1
Switch to Live API (the entry needs a
live block).2
On the integration’s Connect tab (or the Preview tab’s Activation or Triggers
section), find the Local OAuth panel.
3
Follow the checklist to set up a developer app at your vendor’s console. It is derived from your declaration: the redirect URI
http://localhost:<port>/api/integrations/oauth/callback (<port> is 3100 unless you passed --port; Copy button), the declared scopes, and the code grant (with PKCE when declared). Add oauth.setup to the entry for the console link and key names it cannot know.4
Paste the client id, secret, and any webhook signing secrets into the form and
click Save credentials.
5
Click Connect (on the Connect tab or in the activation dialog). The
shell’s
oauth/connect route builds the authorize URL (PKCE when declared)
and sends the browser to your vendor.6
Your vendor redirects back to
oauth/callback, which verifies the single-use
state, exchanges the code through ctx.fetch (an undeclared token-endpoint
origin fails with EgressDeniedError), and awaits your onTokens handler on
the live context.7
oauth/status then answers connected, the SDK’s OAuthActivationForm
auto-activates, and onActivate runs on the same context.8
Your widgets read what the handlers wrote through
fetchIntegrationStorage(), unchanged. An empty read runs your declared schedules once first, as the host does..ekanos/local-secrets.json and replayed on the next start, so the connection lasts until you Disconnect. Changing the OAuth app’s client id discards them.
The API routes refuse any request whose Host is not loopback unless EKANOS_HARNESS_EXPOSED=1; ekanos dev --host sets that after printing a warning.
API routes available
The shell’s API route (createHarnessApiHandlers from @ekanos/harness/api) serves these under /api/integrations/<slug>/:
In live mode the browser passes the active integration’s requests to these routes.
local-setup and actions/<actionName> are reached in both modes. The routes run against one server-held context per integration, whose ctx.fetch reaches your vendor under the declared egress.
Widget data fetching
UseuseIntegrationFetch() from @ekanos/sdk/hooks. The harness mounts IntegrationFetchProvider and IntegrationActivationDataProvider unconditionally, so the hook returns a fetch already gated for whichever mode the toolbar is in, and useActivationData() returns what was last submitted to the activation form (null before any submission or after Disconnect):
fetch is answered from your fixtures. In live mode, it reaches your real API.
Taking an
IntegrationFetch as an argument lets the same query function serve
ctx.fetch on the server and this hook’s fetch on the client. In the harness
the client fetch is gated by the harness’s own check; in production today it
is a plain, unmediated browser fetch.live.FetchProvider field is deprecated. It still works and receives fetch, mode, and activationData as props; use it only to compose an authenticated fetch once at a single seam.
Knowing which mode is active
CalluseHarnessDataMode() from @ekanos/harness/hooks. It has no SDK equivalent, so call it only from code that runs nowhere but the harness:
live block or a live.egress/definition mismatch (both force fixtures regardless of the toolbar).
Troubleshooting
EgressDeniedError in live mode
The origin is not in your definition’segress. Add it or fix a typo in your URL.
NoRecordedResponseError in live mode
The request was a same-origin/api/… request outside the active integration’s own /api/integrations/<slug>/… routes. Those are answered from fixtures in both modes; record a fixture for it, or call your vendor with an absolute URL.
Can’t find where credentials were saved
Check.ekanos/local-secrets.json in your project root (in a repo, in the integration package’s own folder). The file is gitignored and never committed.
Changing credentials
To change credentials, save new values in the Local OAuth panel or the Connect tab, or edit.ekanos/local-secrets.json; either rebuilds the live context and forgets the current connection. Disconnect on the Connect tab removes the integration’s stored fields and keys and keeps the OAuth app’s own keys.