Yolk SDK
API reference

Emulator APIs

Experimental service emulators, HttpClient routing to them, and a loopback server.

Experimental. @yolk-sdk/emulators may change in any canary release. It is new after 0.1.0-canary.95; keep it on the same lockstep version as the other public packages.

@yolk-sdk/emulators runs stand-ins for outside services in tests and local development, and routes an Effect HttpClient to them instead of the real service. The email and R2 emulators are port-level fakes instead: plain-JSON backends for EmailClient and for R2Presigner and R2ObjectClient. Emulators never import other @yolk-sdk/* code: their wire shapes follow the conformance fixtures (verified recordings for the Gateway, synthetic placeholders elsewhere), and each emulated route names the conformance cases it follows. The package depends on effect; the Node-only fortnox, microsoft, dropbox, notion, todoist, telegram, github, google, linkedin-search, mcp, and kie subpaths also depend on the upstream @emulators/core runtime (Apache-2.0, pinned to exactly 0.12.0).

There is no root export. Import an explicit subpath.

Router

@yolk-sdk/emulators/router

ExportPurpose
EmulatorRoute{ origin, target }; EmulatorRoute.url(origin, baseUrl) and EmulatorRoute.handler(origin, fetch) build one
EmulatedHttpClient.layer(routes)Rewrites each routed origin to a loopback base URL (path and query kept) over the HttpClient already in context
InProcessHttpClient.layer(routes)Calls the route's fetch handler directly with a web Request; returns HttpClientResponse.fromWeb
EmulatorRouteInvalidBuild error: malformed or duplicate origin, wrong target kind, or a base URL that is not http(s) on loopback
EmulatorEnvironmentRefusedBuild error: NODE_ENV is production or cannot be read (a missing NODE_ENV is allowed)

Pick the transport by swapping layers; the code under test keeps calling the real origin:

TransportLayer
ReplayReplayHttpClient.layer from @yolk-sdk/conformance/replay
InProcessInProcessHttpClient.layer
EmulatedEmulatedHttpClient.layer over your HttpClient
Liveyour own HttpClient

Both layers fail closed: a request to an origin without a route fails with an HttpClientError whose message names only the origin (never the path, query, headers, or body). Emulated base URLs must be http(s) on 127.0.0.0/8, ::1, or localhost (IPv4-mapped forms such as [::ffff:127.0.0.1] are rejected). The in-process client sends Empty, Uint8Array, and string Raw bodies; other body kinds fail with an EncodeError.

EmulatedHttpClient routes at the send step, so redirect follow-ups (HttpClient.followRedirects on top) and URLs changed by your HttpClient.mapRequest are routed or fail closed too. Over FetchHttpClient, routed requests use redirect: 'manual', so a 3xx reaches the caller as a 3xx; other RequestInit defaults are kept when provided around the whole client stack. Put HttpClient.followRedirects on top of EmulatedHttpClient, never underneath it. Any other underlying client must not follow redirects by itself.

import { Layer } from 'effect'
import { makeGatewayEmulator } from '@yolk-sdk/emulators/gateway'
import { EmulatorRoute, InProcessHttpClient } from '@yolk-sdk/emulators/router'

const gateway = makeGatewayEmulator()

const httpLayer = InProcessHttpClient.layer([
  EmulatorRoute.handler('https://ai-gateway.vercel.sh', gateway.fetch)
])

Provide httpLayer below the code under test, for example a Gateway provider layer.

Gateway emulator

@yolk-sdk/emulators/gateway

ExportPurpose
makeGatewayEmulator(options?){ fetch, ledger, reset, faults, script, coverage } for POST /v1/chat/completions
gatewayEmulatorRoutesRoute evidence manifest: method, path, kind, write, caseIds, evidence, observedAt
gatewayEvaluateEmulatorRoutesManifest of the fixture-only classifier route POST /v1/evaluate (unverified)
GatewayEvaluateFault, GatewayEvaluateEmulatorClassifier-route fault schema and its emulator API (emulator.evaluate)
GatewayFault, GatewayScriptedTurnSchemas and types for wire faults and scripted turns
GatewayLedgerEntry, GatewayCoverageLedger entry and coverage report types
gatewayEmulatorDefaultModelsSynthetic-safe default model ids (includes openai/gpt-4.1-nano and the DeepSeek ids)
gatewayEmulatorDefaultReasoningModelsdeepseek/deepseek-v3.2 and deepseek/deepseek-v4.1-flash
gatewayEmulatorDefaultEventsPerChunk2: SSE events per network chunk by default
emulatorEvidenceHeaderx-emulator-evidence, set to unverified on every response from an unverified route
GatewayEmulatorInputInvalidThrown by faults.add / script.enqueue for invalid input, and for an invalid eventsPerChunk

The Gateway route is verified: its wire shapes follow the verified live recordings of 2026-09-30 in @yolk-sdk/agent/providers/vercel/conformance, with synthetic ids, costs, and routing metadata. Without a script, a known model gets synthetic output. stream: true streams chat.completion.chunk events as recorded: a { role: 'assistant' } opening delta, several text deltas, then one finish event whose delta carries provider_metadata and which carries usage (when stream_options.include_usage is set), system_fingerprint, service_tier (openai/* models only), and generationId, followed only by data: [DONE]. Events are packed eventsPerChunk per network chunk (option, default 2; counted from the end, so the finish event and data: [DONE] share the last chunk). stream: false returns one JSON completion (not covered by a recording). Reasoning models asked for reasoning (reasoning_effort, or thinking enabled) stream delta.reasoning with delta.reasoning_details first. A request with tools gets one tool call whose arguments are synthesized from the tool's JSON Schema and streamed in several fragments, finishing with tool_calls; a tool_choice naming an offered function picks that tool (otherwise the first), and tool_choice: 'none' answers with text. Unknown models get the recorded 404 envelope { error: { message, type: 'model_not_found', param: { modelId } } } (no code), a missing bearer credential gets 401, and unknown routes get a 404 JSON error. The credential is never checked or stored.

script.enqueue(turn) queues a completion (text, reasoning, reasoningField, order, toolCalls, usage, finishReason; usage: null drops usage, reasoningField defaults to reasoning) or an error ({ error: { status, body, headers? } }) for the next request. faults.add injects status (for example 429 with retry-after), error-after-chunks, or truncate-after-chunks, each with an optional match: { path?, model? } and count; chunk faults count network chunks, each packing up to eventsPerChunk events. Emulators never redirect and always send a body: fault and scripted-error statuses exclude 1xx, 204, 205, and every 3xx (including 304), header names and values must be valid, and a location header is rejected.

The same fetch handler answers the classifier route POST /v1/evaluate (AI Gateway calls classification "evaluation"), fixture-only: a request matching one of the four synthetic classifier recordings in @yolk-sdk/agent/providers/vercel/conformance (the model and question type exact, any other string, the recorded question ids, option keys, and level count) gets the recorded answer; anything else answers 400 not-emulated. It has its own unverified manifest (gatewayEvaluateEmulatorRoutes), ledger, faults (statuses 400-599), scripted errors, and coverage (emulator.evaluate, control plane /_emulate/evaluate/*); reset() resets both routes.

The ledger records every emulated API request (control-plane requests are not recorded): method, path, parsed body, model, stream, the max_tokens limit (maxCompletionTokens, never validated), reasoning_effort, thinking, tool names, the applied fault, the evidence tag, the status actually sent, and body chunks sent; never credential headers. When a planned response cannot be built, the emulator answers an evidence-tagged 500, records it with responseError, and does not use up the fault. The same fetch handler serves the control plane:

RouteMethods
/_emulate/ledgerGET, DELETE
/_emulate/faultsGET, POST, DELETE
/_emulate/scriptPOST
/_emulate/resetPOST
/_emulate/stateGET
/_emulate/coverageGET

OpenAI emulator

@yolk-sdk/emulators/openai

ExportPurpose
makeOpenAiEmulator(options?){ fetch, ledger, reset, faults, script, coverage } for POST /v1/chat/completions
openAiEmulatorRoutesRoute evidence manifest linked to the OpenAI chat conformance cases
OpenAiFault, OpenAiScriptedTurnSchemas and types for wire faults and scripted turns (no reasoning text fields)
OpenAiLedgerEntry, OpenAiCoverageLedger entry and coverage report types
openAiEmulatorDefaultModelsSynthetic-safe default model ids (gpt-4.1-nano, gpt-4.1-mini, gpt-6-luna)
openAiEmulatorDefaultReasoningModelsDefault reasoning model ids (gpt-6-luna)
OpenAiEmulatorInputInvalidThrown by faults.add / script.enqueue for invalid input

It stands in for OpenAI Chat Completions at https://api.openai.com and shares the Gateway emulator's Chat Completions core, so JSON mode, tool-call fragments, scripted turns, faults, the ledger, and the control plane behave the same. Streaming uses the plain OpenAI framing (one event per network chunk, usage in a trailing chunk, none of the Gateway's metadata fields). Errors use the OpenAI envelope { error: { message, type, param, code } }: an unknown model gets 404 model_not_found, and a missing bearer credential gets 401 invalid_api_key (the credential is never checked or stored). The ledger records max_completion_tokens as maxCompletionTokens.

Reasoning models (reasoningModels, default openAiEmulatorDefaultReasoningModels) follow the three synthetic OpenAI reasoning conformance fixtures: they take reasoning_effort and max_completion_tokens, send no reasoning text, and report it only as usage.completion_tokens_details.reasoning_tokens, counted in completion_tokens. A non-null max_tokens gets the fixture's 400 { error: { message, type: 'invalid_request_error', param: 'max_tokens', code: 'unsupported_parameter' } } (after model validation, never for a scripted turn; the ledger's unsupportedParameter). Scripted turns reject reasoning text fields; script reasoning as usage.reasoningTokens. Not emulated until a fixture backs them: sampling parameter rules, reasoning_effort on a model that does not reason (recorded and ignored), and per-model effort values. reasoning_effort: 'none' reporting 0 reasoning tokens is synthetic.

Anthropic emulator

@yolk-sdk/emulators/anthropic

ExportPurpose
makeAnthropicEmulator(options?){ fetch, ledger, reset, faults, script, coverage } for POST /v1/messages
anthropicEmulatorRoutesRoute evidence manifest linked to the Anthropic Messages conformance cases
AnthropicFault, AnthropicScriptedTurnSchemas and types for wire faults (including a mid-stream error event) and turns
AnthropicLedgerEntry, AnthropicCoverageLedger entry and coverage report types
anthropicEmulatorDefaultModelsSynthetic-safe default model ids (claude-haiku-4-5, claude-sonnet-4-5)
AnthropicEmulatorInputInvalidThrown by faults.add / script.enqueue for invalid input

It stands in for Anthropic Messages at https://api.anthropic.com. stream: true streams the events in the order the API sends them: message_start (input usage), then per content block content_block_start, its deltas, and content_block_stop (a ping follows the first block start), then message_delta (stop_reason, and usage with input and cache counts next to output_tokens, as the unverified fixtures record it) and message_stop; stream: false returns one message JSON body. A request with thinking enabled (enabled or adaptive) gets a thinking block (thinking_delta events, then a signature_delta) before the text. A request with tools gets one tool_use block whose input is synthesized from the tool's input_schema and streamed as input_json_delta fragments, stopping with tool_use; tool_choice: { type: 'tool', name } picks that tool and tool_choice: { type: 'none' } answers with text. An answer that would not fit max_tokens is cut and stops with max_tokens.

Errors use the Anthropic envelope { type: 'error', error: { type, message } }: an unknown model gets 404 not_found_error; a missing or unsupported anthropic-version (only 2023-06-01, the value the SDK providers send), a missing or non-positive max_tokens, or thinking with a forced tool_choice (tool or any) gets 400 invalid_request_error; and a request with neither a non-empty x-api-key (native API keys) nor an Authorization: Bearer credential (Claude OAuth) gets 401 authentication_error. Neither credential is checked or stored; the ledger records which header carried it (credentialHeader), anthropic-version, anthropic-beta, max_tokens (maxTokens), thinking, tool_choice, and tool names. The OAuth anthropic-beta header and budget_tokens limits are not enforced.

Scripted turns are messages (thinking, text, toolUses with inputFragments, order, usage, stopReason; usage: null drops usage, order: 'text-first' sends thinking after the text) or errors. Faults are status (the default body is the envelope for the status, for example rate_limit_error for 429 and overloaded_error for 529), error-after-chunks, truncate-after-chunks (for example before message_stop), and error-event-after-chunks (N events, then an event: error with overloaded_error by default; streamed responses only, and only before message_stop). Faults, the ledger, and the control plane are shared with the Chat Completions emulators.

Responses emulators

@yolk-sdk/emulators/codex and @yolk-sdk/emulators/xai

ExportPurpose
makeCodexEmulator(options?){ fetch, ledger, reset, faults, script, coverage } for POST /backend-api/codex/responses
makeXAiGrokEmulator(options?)The same for POST /v1/responses on the Grok CLI proxy
codexEmulatorRoutes, xAiGrokEmulatorRoutesRoute evidence manifests linked to the Codex and Grok Responses conformance cases
CodexFault, CodexScriptedTurn, XAiGrok*Schemas and types for wire faults (including mid-stream error events) and turns
CodexLedgerEntry, XAiGrokLedgerEntryLedger entry types
codexEmulatorDefaultModels, xAiGrokEmulatorDefaultModelsSynthetic-safe default model ids
CodexEmulatorInputInvalid, XAiGrokEmulatorInputInvalidThrown by faults.add / script.enqueue for invalid input

They stand in for the ChatGPT Codex endpoint at https://chatgpt.com and the xAI Grok CLI proxy at https://cli-chat-proxy.grok.com, on one shared OpenAI Responses core. stream: true streams server-sent events with typed event: names and a sequence_number, in the API's order: response.created, response.in_progress, then per output item response.output_item.added, its parts and deltas, and response.output_item.done, then response.completed with the full response and usage; stream: false returns one completed response JSON body. A request whose reasoning asks for a summary gets a reasoning item (summary part and response.reasoning_summary_text.delta events) first; answers are a message item (response.output_text.delta); a request with function tools gets one function_call item whose arguments are synthesized from the tool's JSON Schema and streamed as response.function_call_arguments.delta fragments.

Errors use { error: { message, type, param, code } }: an unknown model gets 400 model_not_found, and a request without a non-empty Authorization: Bearer credential gets 401 invalid_api_key (never checked or stored). /codex answers max_output_tokens with 400 unsupported_parameter (the endpoint takes no output limit) and records originator. /xai requires, in order, X-XAI-Token-Auth (401), x-grok-client-version (426), and x-grok-model-override (400); it records the client version and model override (never the token-auth value) and records max_output_tokens as maxOutputTokens.

Scripted turns are responses (reasoning, text, functionCalls with argumentFragments, order, usage, and format: 'json' for a JSON body even on stream: true) or errors. Faults are status (for example 429 with retry-after), error-after-chunks, truncate-after-chunks (for example before response.completed), and error-event-after-chunks (N events, then an error event, or a response.failed event with event: 'response.failed'; streamed responses only, and only before response.completed).

Fixture-only routes

The OpenCode Go routes and the Claude, Codex, and Grok subscription-usage routes are fixture-only; the earlier model routes above keep their behaviour. A request matching a recorded request's shape gets that fixture's recorded response (same status, headers, and bytes). Everything else answers one 400 not-emulated, written to the ledger and using up no fault or turn: { error: { type: 'not_emulated', message } }. That covers unknown routes and methods, missing or invalid credentials, missing or other headers and query parameters, unknown models, non-streamed modes, tools, reasoning, and extra fields. No provider status or error envelope is guessed.

Accepted request-shape latitude: any credential value; extra headers; key order; any string value except model, role, type, and phase; any positive integer where the recording has a number (the output-token limit); an anthropic-beta list that includes oauth-2025-04-20; any non-empty Grok x-userid and x-grok-client-version; and content-type parameters. The query string must match byte for byte (a bare ? counts as no query), and Grok's X-XAI-Token-Auth (xai-grok-cli) and x-grok-client-mode (headless) must be the SDK's fixed values. Test controls are the shared faults, scripted error turns, and, on usage routes, a scripted { usage } body or subscriptionUsage option with the recorded JSON shape; fault and scripted-error statuses are 400-599 only. All of these routes are unverified (synthetic fixtures).

OpenCode Go emulator

@yolk-sdk/emulators/opencode

ExportPurpose
makeOpenCodeGoEmulator(options?){ fetch, reset, coverage, chat, messages, responses, usage } for https://opencode.ai/inference/go/v1
openCodeGoEmulatorRoutesRoute evidence manifest (four routes) linked to the OpenCode Go conformance cases
openCodeGoUsageDefaultThe recorded usage body (usage.rolling, .weekly, .monthly as { percent, resetsAt })
openCodeGoEmulatorDefaultModelsThe recorded model ids (one per protocol); no other model is emulated
OpenCodeGoEmulatorInputInvalidThrown by a part's faults.add / script.enqueue, or for a differently shaped subscriptionUsage

One fetch handler serves the four routes the OpenCode Go provider and usage fetcher call, each answering its Go fixture: POST /inference/go/v1/chat/completions (Bearer; streamed plain text with usage), POST /inference/go/v1/messages (x-api-key, anthropic-version: 2023-06-01; streamed plain text), POST /inference/go/v1/responses (Bearer; streamed plain text, or a text answer to a replayed tool turn with commentary-tagged text), and GET /inference/go/v1/usage (Bearer). Each part (emulator.chat, .messages, .responses, .usage) is a full emulator API with its own ledger, faults, and turns, and its control plane over HTTP is /_emulate/<part>/*; coverage() / GET /_emulate/coverage combine every route, and reset() / POST /_emulate/reset reset every part. Requests on no route answer 400 not-emulated, ledgered by the chat part.

Subscription-usage routes

The Anthropic, Codex, and Grok emulators also answer their provider's subscription-usage endpoint on the same origin, with their own manifest, ledger, faults, turns, and coverage (emulator.usage, control plane /_emulate/usage/*). The model route's manifest and coverage are unchanged; the emulator types gain usage and a subscriptionUsage option.

EmulatorRouteHeaders the fetcher sends (all required)Manifest
/anthropicGET /api/oauth/usageBearer, anthropic-beta listing oauth-2025-04-20anthropicSubscriptionUsageEmulatorRoutes
/codexGET /backend-api/wham/usageBearer, ChatGPT-Account-IdcodexSubscriptionUsageEmulatorRoutes
/xaiGET /v1/billing?format=creditsBearer, X-XAI-Token-Auth, x-userid, x-grok-client-version, x-grok-client-modexAiGrokSubscriptionUsageEmulatorRoutes

Each answers its recorded synthetic snapshot body (*SubscriptionUsageDefault) for a request with those headers, accept: application/json, and exactly the recorded query; anything else is 400 not-emulated. Credential and account values are never recorded, and are not checked except Grok's fixed X-XAI-Token-Auth: xai-grok-cli.

Email emulator

@yolk-sdk/emulators/email

ExportPurpose
makeEmailEmulator({ seed? }){ call, state, seed, ledger, reset, faults, coverage }: a fixture-driven fake EmailClient backend
emailEmulatorRoutesRoute evidence manifest: one PORT EmailClient.<method> route per emulated method, linked to email cases
emailEmulatorPort, emailEmulatorRouteMethodHelpers: EmailClient and PORT, the port name and pseudo method of the manifest routes
EmailEmulatorSpecialUse, EmailEmulatorFolder, EmailEmulatorMessageSeed schemas: SPECIAL-USE attributes, folders, and messages
emailEmulatorDefaultSeed, EmailEmulatorSeedThe synthetic practice mailbox the fixtures describe (folders, SPECIAL-USE attributes, messages)
EmailEmulatorFault, EmailEmulatorLedgerEntry, EmailEmulatorReply, EmailEmulatorCoverageFault schema, ledger entry, reply, and coverage types
emailEmulatorFixturesThe email conformance PortFixtures, copied as data
EmailEmulatorInputInvalidThrown for an invalid seed or fault

Yolk never speaks IMAP, POP3, or SMTP, and neither does this emulator: no socket, TLS, MIME, or mail library, no Node builtin, and no SDK import. call(method, request) takes one EmailClient call as plain JSON (without credential fields) and answers { response }, { failure }, or { notEmulated: { reason } }. emailClientLayerFromBackend(emulator) from @yolk-sdk/connectors/email/conformance turns it into the EmailClient layer.

Responses come only from the email conformance fixtures. The in-memory mailbox only selects the first matching fixture consistent with it (preferring fixtures unused since the last reset) and records what that fixture says happened (flags set, a draft appended, a message moved to the destination id the fixture names, a message deleted, a Sent copy saved); it never invents an id, flag, or response.

  • Request-shape latitude: credential fields are never compared or recorded, and connection.host is not compared. Every other connection field (protocol, port, security) and everything else must equal a fixture request.

Anything else fails closed with a ledgered notEmulated answer, the port analogue of HTTP 400: unknown-method, invalid-request, no-matching-fixture, or state-conflict. Faults ({ kind: 'failure', method, match?, count?, failure }, match a deep subset of the request) change no state. reset() restores the seed and clears the ledger, faults, and fixture use.

R2 emulator

@yolk-sdk/emulators/r2

ExportPurpose
makeR2Emulator({ seed? }){ call, state, seed, ledger, reset, faults, coverage }: a fixture-driven fake R2 port backend
r2EmulatorRoutesRoute evidence manifest: one PORT <Port>.<method> route per emulated method, linked to R2 cases
r2EmulatorPresignerPort, r2EmulatorObjectClientPort, r2EmulatorRouteMethodHelpers: R2Presigner, R2ObjectClient, and PORT, the port names and pseudo method of the routes
R2EmulatorObject, R2EmulatorBucket, r2EmulatorDefaultSeed, R2EmulatorSeedSeed schemas and the synthetic practice bucket the fixtures describe (the object the get fixtures read)
R2EmulatorFault, R2EmulatorLedgerEntry, R2EmulatorReply, R2EmulatorCoverageFault schema, ledger entry, reply, and coverage types
r2EmulatorFixturesThe R2 conformance PortFixtures, copied as data
r2EmulatorRedacted, r2EmulatorUnrecognisedThe constant request (<redacted>) and port and method (<unrecognised>) of refusals that record nothing
R2EmulatorInputInvalidThrown for an invalid seed or fault

The R2 connector never talks to R2 itself, and neither does this emulator: no SigV4 signer, S3 client, socket, Node builtin, or SDK import. call(port, method, request) takes one R2Presigner or R2ObjectClient call as plain JSON (without credential fields; bytes as base64) and answers { response }, { failure }, or { notEmulated: { reason } }. r2PortsLayerFromBackend(emulator) from @yolk-sdk/connectors/r2-storage/conformance turns it into both port layers.

Responses come only from the R2 conformance fixtures. The in-memory bucket only selects the first matching fixture consistent with it (preferring fixtures unused since the last reset) and records what that fixture says happened (an object created absent-only or replaced under its current etag, with the etag the fixture names); it never invents an etag, a byte, or a failure, and presigning writes nothing. The connector cannot delete R2 objects, so objects the write cases create stay, and running the write cases again on the same emulator fails them without writing.

Credentials never reach the ledger or any other output. Every credential field (credential(s), accessKeyId, secretAccessKey, sessionToken, token, and the other names the shared port scan classifies as credentials) is dropped at any depth before anything is compared or recorded. Every refusal is ledgered with constant text only (request <redacted>), uses no fault, and changes no state; only a request equal to a fixture request is recorded, with every bodyBase64 as <redacted> plus its decoded length (bodyBytes). Every bodyBase64 (put bytes) must be canonical standard base64 of UTF-8 text (else uncheckable-body), and its decoded text is checked like the rest of the request. A request is refused as credential-in-request when any key, string value, number (as printed or as its digit string), or decoded body repeats a value found under a credential field (any non-empty key, string, or number, with no minimum length), or holds, outside the exact canonical synthetic placeholders, X-Amz-Credential, X-Amz-Signature, X-Amz-Security-Token, a credential query parameter, or a token the shared scan flags (a bearer token, a common API-key prefix, a JSON Web Token, a PEM private key). Each text is checked raw, within three rounds of percent-decoding and three of escape-decoding (\uXXXX, \xXX, and numeric HTML references, as the R2 conformance guard decodes), and through any depth of percent-encoding and JSON escaping, failing closed past a work cap. A request with an own __proto__ key at any depth is refused as invalid-request, and one the checks cannot walk (cyclic, or nested too deeply) as uncheckable-request: call never throws. The copied key, parameter, and token lists have one test sample each, counted against the list and checked against the shared scan.

  • Request-shape latitude: credential fields are never compared or recorded, and JSON key order is not compared. Everything else (the endpoint, bucket, key, content type, maxBytes, expectedEtag, the put condition, bodyBase64, and maxUploadBytes) must equal a fixture request exactly, so only the fixtures' run-synthetic run id is emulated. A bodyBase64 must be canonical standard base64 of UTF-8 text (else uncheckable-body); it is compared as sent but recorded only as its decoded length. No object may have an own __proto__ key (else invalid-request), and no key or value, the decoded body included, may carry a credential or repeat a dropped credential value of any length (else credential-in-request). Every refusal is ledgered with constant text only (request <redacted>).

Anything else fails closed with a ledgered notEmulated answer, the port analogue of HTTP 400, with constant text only (request <redacted>): unknown-method and uncheckable-request (ledgered as <unrecognised>), invalid-request, uncheckable-body, credential-in-request, no-matching-fixture, or state-conflict; none uses a fault or changes the bucket. Faults ({ kind: 'failure', port, method, match?, count?, failure }, match a deep subset of the request) apply only to a call a fixture would answer and change no state. reset() restores the seed and clears the ledger, faults, and fixture use.

Fortnox emulator

@yolk-sdk/emulators/fortnox

Experimental, Node only. A stateful stand-in for the Fortnox /3 API, built on the @emulators/core custom runtime (loaded lazily when you create an emulator).

ExportPurpose
makeFortnoxEmulator(options?)Promise of { fetch, baseUrl, ledger, faults, reset, seed, snapshot, coverage, close }
fortnoxEmulatorRoutesRoute evidence manifest (54 routes, every one unverified; four are connector write routes)
fortnoxEmulatorQuirksThe observed quirks it implements, each with its conformance case id and drill knob
FortnoxEmulatorSeed, FortnoxEmulatorProfileTyped seed schema (profile, entities, read-only resources) and account-variance profiles
FortnoxFault{ kind: 'status', status, headers?, body?, match?: { method?, path? }, count? }
fortnoxEmulatorErrorCodesErrorInformation codes (customer-not-found codes from the fixtures; 2999xxx codes synthetic)
FortnoxEmulatorInputInvalidInvalid seed, fault, or option passed to the JS API

It serves GET /3/companyinformation, GET /3/customers, GET/PUT /3/customers/{CustomerNumber}, GET/POST /3/invoices, GET/PUT /3/invoices/{DocumentNumber}, GET /3/invoices/{DocumentNumber}/preview (a small synthetic PDF), and GET /3/invoices/{DocumentNumber}/email (marks the invoice sent and records an outbox entry in state; nothing is ever delivered). Requests need Authorization: Bearer <non-empty>; the token is never stored or ledgered. Anything else fails closed with a 404 ErrorInformation, and unsupported query parameters or fields get a 400 instead of being ignored.

It also serves the reads of the connector's newer Fortnox actions, GET only: articles, price lists, prices (/3/prices/sublist/{PriceList}/{ArticleNumber} and /3/prices/{PriceList}/{ArticleNumber}/{FromQuantity}), cost centers, customer and supplier invoice payments, offers and their preview PDF, print templates, the inbox (folder JSON; a file id answers the file bytes), company settings, the locked period, predefined accounts, labels, the modes and terms of payment, terms and ways of delivery, and units registers, and /3/me, plus the bookkeeping reads: financial years, accounts per financial year, voucher series, vouchers (and the series sublist), voucher file connections, and SIE file bytes (/3/sie/{Type}). These 44 routes, GET /3/companyinformation, and GET /3/customers cite the Fortnox read conformance cases, whose synthetic fixtures are the source of these answers (bodies shaped from the Fortnox OpenAPI spec and its archived examples; a test requires every read fixture request to get the fixture's body byte for byte, so the emulator cannot drift from them). They are unverified, use minimal synthetic shapes named after the fields the connector reads, and answer requests no fixture records (other pages, filters, searches, ids) from the state. Their writes (and side-effecting reads such as /3/offers/{DocumentNumber}/email, voucher and voucher file connection creates) are not emulated and fail closed with the 404; a key the state does not hold answers 404 code 2999011; lastmodified gets a 400 on every list.

The default seed holds the synthetic fixture entities with the same numbers as fortnoxConformanceFixtureSeeds, so the Fortnox conformance cases run unmodified against it, plus small synthetic read-only data (Example AB, example.test) consistent with them. Each read-only resource has its own seed key (articles, priceLists, prices, costCenters, invoicePayments, supplierInvoicePayments, offers, printTemplates, inboxFolders, inboxFiles, companySettings, lockedPeriod, predefinedAccounts, labels, modesOfPayment, termsOfPayment, termsOfDelivery, waysOfDelivery, units, me, financialYears, accounts, voucherSeries, vouchers, voucherFileConnections, sieFiles) that replaces the profile's part; a seed with a duplicate key or a dangling reference (an offer naming a missing customer, a payment naming a missing invoice, ...) is rejected. Replacing customers or invoices without seeding offers or invoicePayments starts those empty. Profiles: default, empty-company (no business data; settings, registers, and inbox folders stay), no-booked-invoices (no invoice payments either). reset() restores the seed; seed() replaces it.

It implements the quirks the Fortnox cases claim: an omitted row Discount stays on positional row updates (Discount: 0 clears; RowIds regenerate; totals are recomputed); an empty customer string keeps the stored value; unpaid/unpaidoverdue/fullypaid skip unbooked invoices (unpaidoverdue uses the injectable now clock); rejected writes answer 400 ErrorInformation; customer Country is read-only.

The quirks option (stickyRowDiscount: false, emptyStringClears: true, paymentFiltersIncludeUnbooked: true) is a test-only drill knob: it flips one quirk to prove that the matching conformance case fails.

Fortnox faults are status faults only ({ kind: 'status', status, headers?, body?, match?: { method?, path? }, count? }). A fault answers only a request the route would answer successfully, and nothing is written: the route checks the request against the state first, so a request it refuses (a 404 for an unknown id, or a 400 for an invalid state or a query key, field, or value it does not emulate) uses up no fault. They follow the Gateway emulator's rules: statuses without a body (1xx, 204, 205) and redirects (3xx) are rejected, as are invalid header names or values, a location header, and framing headers, both in faults.add and in POST /_emulate/faults. A fault is used up only after its response is built; a response that cannot be built answers an evidence-tagged 500 ErrorInformation recorded in the ledger with responseError. The control plane serves /_emulate/ledger, faults, reset, state, seed, and coverage; unlike the Gateway, it has no scripted turns and no chunk faults, and reset/seed also restore or replace the Fortnox state.

import { makeFortnoxEmulator } from '@yolk-sdk/emulators/fortnox'
import { EmulatorRoute, InProcessHttpClient } from '@yolk-sdk/emulators/router'

const fortnox = await makeFortnoxEmulator({ seed: { profile: 'default' } })

const httpLayer = InProcessHttpClient.layer([
  EmulatorRoute.handler('https://api.fortnox.se', fortnox.fetch)
])

Microsoft Graph emulator

@yolk-sdk/emulators/microsoft

Experimental, Node only. A stateful stand-in for the Microsoft Graph v1.0 routes the Microsoft conformance cases use (calendar, Outlook mail, OneDrive, SharePoint sites, Teams) plus the OneDrive copy monitor URL, built on the same @emulators/core runtime (loaded lazily when you create an emulator).

ExportPurpose
makeMicrosoftEmulator(options?)Promise of { fetch, baseUrl, sharePointOrigin, ledger, faults, monitors, reset, seed, snapshot, coverage, close }
microsoftEmulatorRoutesRoute evidence manifest (35 routes, all unverified; twelve are connector write routes)
MicrosoftEmulatorSeed, MicrosoftEmulatorProfileTyped seed schema (profile, user, mailFolders, messages, attachments, calendars, events, drive, driveItems)
MicrosoftFault{ kind: 'status', status, headers?, body?, match?: { method?, path? }, count? }
microsoftEmulatorErrorCodesGraph error codes, in three groups (below)
MicrosoftEmulatorInputInvalidInvalid seed, fault, or option passed to the JS API
microsoftEmulatorDefaultOrigin, microsoftEmulatorDefaultSharePointOriginhttps://graph.microsoft.com and https://synthetic-my.sharepoint.com (the copy monitor host)

Route both origins to the same fetch handler (the paths never overlap, so one loopback server serves both):

import { makeMicrosoftEmulator } from '@yolk-sdk/emulators/microsoft'
import { EmulatorRoute, InProcessHttpClient } from '@yolk-sdk/emulators/router'

const microsoft = await makeMicrosoftEmulator()

const httpLayer = InProcessHttpClient.layer([
  EmulatorRoute.handler('https://graph.microsoft.com', microsoft.fetch),
  EmulatorRoute.handler(microsoft.sharePointOrigin, microsoft.fetch)
])

It serves, under /v1.0: calendarView (events overlapping [startDateTime, endDateTime)), event create, get, update, delete, and cancel (202; the event is removed, so later reads and deletes are 404); folder message listing (by folder id) with $top/$skip and an opaque @odata.nextLink; draft create, update, and move to Deleted Items; attachment listing (inline included, never contentId) and retrieval (with contentId); $batch with draft permanentDelete subrequests only; and OneDrive item read, children listing, folder create, delete, and file copy (202 with one monitor Location). Folder message listings, calendar views, and children listings need $top, at most the largest value a fixture sends (2, 50, and 200); calendar views and children listings answer one page. The monitor URL needs no credential; its first poll answers completed with a resourceId, as the copy fixture records (copyInProgressPolls, default 0, adds inProgress answers first). Graph routes need Authorization: Bearer <non-empty>; the token is never stored or ledgered, and credential-named keys in ledgered bodies and queries are redacted. Responses carry the fixtures' @odata.context envelopes.

Behaviour comes only from the conformance fixtures. Everything they do not show fails closed with the Graph error envelope { error: { code, message, innerError } }: /me paths other than the Teams ones below and other unknown routes get 404; query keys, $select fields, body properties (including unknown nested keys), and values the emulator does not emulate get a 400 before anything is written. That includes Outlook requests without Prefer: IdType="ImmutableId" and calendar requests without Prefer: outlook.timezone="UTC" (every fixture of theirs sends it), writes to messages that are not drafts, moves to any destination but deleteditems, folder listings by well-known name, If-Match, conflict behaviors other than fail, name conflicts, folder or renamed copies, and failed copies. A route handler that throws answers a 500 envelope recorded in the ledger. The few behaviours the cases need without a fixture (the concurrency window, advancing id counters, removal on delete, synthesized seed values), the request-shape latitude it accepts (for example optional $select, smaller $top, user aliases, subsets of the fixture body keys), and the opt-in in-progress copy polls are listed in the package README under "Emulator extrapolations (no fixture)".

microsoftEmulatorErrorCodes groups:

  • From the fixtures: ErrorItemNotFound, itemNotFound, ErrorIrresolvableConflict.
  • Documented Graph codes (no fixture): InvalidAuthenticationToken (missing bearer), ErrorInvalidUser (a user other than the seeded mailbox), TooManyRequests (the default 429 fault body).
  • Synthetic emulator codes: SyntheticRouteNotEmulated, SyntheticQueryNotEmulated, SyntheticValueNotEmulated, SyntheticInvalidRequest, SyntheticInvalidBody, SyntheticUpstreamError.

Messages keep their immutable id across moves. Event times are UTC with seven fractional digits. For concurrent writes, the first committed write holds the message for conflictWindowMs (default 25; a refused or faulted write holds nothing); an overlapping write gets 409 ErrorIrresolvableConflict; non-overlapping writes both apply (an emulator extrapolation). The default seed is the synthetic fixture entities with the same ids as microsoftConformanceFixtureSeeds; profiles default and empty. Faults, the ledger (which also records the Prefer header), and the /_emulate/* control plane behave as in the Fortnox emulator: a refusal (a 404 for an unknown id, a 400 not emulated, or a 409 conflict) uses up no fault, and a faulted request writes nothing, creates no copy monitor, and holds no message. reset and seed also clear copy monitors. The drills option (calendarRangeEmpty, createOmitsId, timestampPrecisionDigits, omitNextLink, and one per SharePoint site and Teams case: siteSearchEmpty, siteDrivesNoLibrary, chatsOmitMembers, chatMessagesOmitNextLink, joinedTeamsEmpty, repliesOmitReplyToId, transcriptsOtherMeeting, chatSendUnescaped) is a test-only drill knob that makes the matching conformance case fail.

The SharePoint site and Teams routes are fixture-only, without exceptions: site search (GET /sites?search=) and site drives; chats (GET /me/chats, GET /chats/{chatId}), chat messages (two recorded pages, the second through an @odata.nextLink naming the chat id unencoded) and one message; joined teams, a team, its channels, and one channel; a channel's top-level posts, one post, and its replies; the meeting found by its join link (GET /me/onlineMeetings?$filter=) and its transcripts; and the chat send (POST /chats/{chatId}/messages). They answer only the recorded exchanges of the eight microsoft.sharepoint.* and microsoft.teams.* fixtures (synthetic, shaped from the Microsoft Graph v1.0 docs examples), byte for byte, for a request whose raw path and query parameters (decoded, in any order) equal a recorded one, and only under the default profile: under empty every one of them answers the 400 not emulated, since no fixture records an empty listing. Anything else answers 400 before anything is written or a fault is used. The send answers only the recorded send chat (a dedicated chat, never the paging chat) and the recorded text with any run id: the recorded 201 under a minted message id from a counter that only advances. A send cannot be undone on Graph, so the emulator keeps it in the state (chatMessagesSent, never seeded): a read of the sent message answers the recorded readback, and a listing of a chat holding a sent message is not emulated.

Dropbox emulator

@yolk-sdk/emulators/dropbox

Experimental, Node only. A stateful stand-in for the Dropbox /2 RPC and upload routes the Dropbox conformance cases use, built on the same @emulators/core runtime (loaded lazily when you create an emulator). It is fixture-only, without exceptions: it answers only what the conformance fixtures show.

ExportPurpose
makeDropboxEmulator(options?)Promise of { fetch, fetchOn, ledger, faults, cursors, reset, seed, snapshot, coverage, close }
dropboxEmulatorRoutesRoute evidence manifest (10 routes, all unverified; five are connector write routes)
DropboxEmulatorSeed, DropboxEmulatorProfileTyped seed schema (profile, entries by display path, deleted)
DropboxFault{ kind: 'status', status (400-599), headers?, body?, match?: { method?, path?, route? }, count? }
dropboxEmulatorErrorBodiesThe fixtures' 409 error_summary envelopes, byte for byte (notFound, folderConflict, uploadConflict)
DropboxEmulatorInputInvalidInvalid seed, fault, or option passed to the JS API
dropboxEmulatorApiOrigin, dropboxEmulatorContentOriginhttps://api.dropboxapi.com (RPC) and https://content.dropboxapi.com (upload)

In a fault's match, method is the HTTP method, path the raw request path (a trailing * makes it a prefix), and route a route template of the manifest; a route that names no manifest row is rejected when the fault is added. The Notion, GitHub, Google, LinkedIn search, and MCP faults take the same match.

Each route answers only on the origin its fixtures record. fetch reads the origin from the request URL (in-process routing keeps it); behind a loopback rewrite, serve fetchOn(origin) for each origin on its own server:

import { makeDropboxEmulator } from '@yolk-sdk/emulators/dropbox'
import { EmulatorRoute, InProcessHttpClient } from '@yolk-sdk/emulators/router'

const dropbox = await makeDropboxEmulator()

const httpLayer = InProcessHttpClient.layer([
  EmulatorRoute.handler('https://api.dropboxapi.com', dropbox.fetch),
  EmulatorRoute.handler('https://content.dropboxapi.com', dropbox.fetch)
])

It serves, as POST under /2/files: list_folder and list_folder/continue (cursor paging; every page carries a cursor), get_metadata (case-insensitive lookups; path_display keeps the stored casing of the last component only; include_deleted: true answers deleted metadata after an empty folder's delete), search_v2 and search/continue_v2 (file name matches in the nested metadata envelope; a cursor only with has_more), create_folder_v2 (metadata without .tag; an existing folder in any casing is a 409 path/conflict/folder), delete_v2 (by path or id:; folders and their content), copy_v2 (a new file with the source's size and content hash) and move_v2 (the same id), and upload on the content host (add never overwrites; update by id: needs the current rev; both conflicts are 409 path/conflict/file). Route errors are the fixtures' HTTP 409 error_summary envelopes. Every route needs Authorization: Bearer <non-empty>; the token is never stored or ledgered.

Every answer value comes from a fixture, or is a value the emulator mints (created ids and revs from counters that start above the seeded ones, content hashes derived from revs, upload timestamps from the injectable now clock, and cursors). Folders a fixture never shows (the parents of the seeded paths) are implied: never rendered. A cursor is accepted only when this emulator issued it since the last reset and its listing or search renders exactly as when it was issued. Anything else answers one ledgered 400 not-emulated ({ error: { type: 'not_emulated', message } }), writes nothing, and uses up no fault: each route's pure, state-reading eligibility check runs before a fault is decided. That includes a listing of an empty folder and a search without matches (no fixture records either), so findDropboxConformanceLeftovers fails against the default seed's empty work folder with DropboxConformanceActionFailed (HTTP 400), which the live runner reports as its lookup-failed WARN.

  • Request-shape latitude (/dropbox, the only accepted deviations): any bearer value (never checked or stored); extra request headers; JSON key order; content-type media-type parameters; any path and search query (looked up in the state); any list_folder limit from 1 to 2000 and any search_v2 options.max_results from 1 to 1000; and any upload body bytes. Everything else (other keys, booleans, modes, query parameters, another origin, ids or revs where the fixtures send paths, the root folder, and cursors not issued since the last reset or whose listing changed) is not emulated.

The default seed is the synthetic fixture entries at the paths of dropboxConformanceFixtureSeeds; profiles default and empty. Faults (statuses 400-599, default body { error: { type: 'emulator_fault', message } }), the ledger (which records the Dropbox-API-Arg header and any JSON-looking query value with credential-named keys redacted, and an upload's length, never its bytes), and the /_emulate/* control plane behave as in the Microsoft Graph emulator; reset and seed also clear cursors. The drills option (eight booleans, one per Dropbox case) is a test-only drill knob that makes exactly the matching conformance case fail. The package README lists the routes, wire behaviour, minted values, and refusals in full.

Notion emulator

@yolk-sdk/emulators/notion

Experimental, Node only. A stateful stand-in for the Notion /v1 routes the Notion conformance cases use at API version 2025-09-03, built on the same @emulators/core runtime (loaded lazily when you create an emulator). It is fixture-only, without exceptions: it answers only what the conformance fixtures show.

ExportPurpose
makeNotionEmulator(options?)Promise of { fetch, fetchOn, ledger, faults, reset, seed, snapshot, coverage, close }
notionEmulatorRoutesRoute evidence manifest (10 routes, all unverified; two are connector write routes)
NotionEmulatorSeed, NotionEmulatorProfileTyped seed schema (profile, botUser, pages, impliedPages, blocks, propertyItems, databases, dataSources)
NotionFault{ kind: 'status', status (400-599), headers?, body?, match?: { method?, path?, route? }, count? }
NotionEmulatorInputInvalidInvalid seed, fault, or option passed to the JS API
notionEmulatorOrigin, notionEmulatorVersionhttps://api.notion.com and 2025-09-03
import { makeNotionEmulator } from '@yolk-sdk/emulators/notion'
import { EmulatorRoute, InProcessHttpClient } from '@yolk-sdk/emulators/router'

const notion = await makeNotionEmulator()

const httpLayer = InProcessHttpClient.layer([
  EmulatorRoute.handler('https://api.notion.com', notion.fetch)
])

It serves, under /v1: POST /search (pages by title, filter object: page only), GET /users/me (the bot user), GET /pages/{id} (trashed pages too; 404 object_not_found and 400 validation_error envelopes as the fixtures record them), POST /pages (the recorded create: a child of a page titled yolk-conformance page: safe to delete), PATCH /pages/{id} with { archived: true } (the page with archived and in_trash true; it still reads back), GET /blocks/{id}/children, GET /pages/{id}/properties/{propertyId} (the property id decoded once, so the connector's second percent-encoding names it), and the database / data source split: GET /databases/{id} lists its data_sources, GET /data_sources/{id} holds the schema and names its database, and POST /data_sources/{id}/query with page_size: 1 answers the recorded first row, whose parent is the data source, and the next row's id as its cursor. Lists page with has_more and next_cursor, and the last page carries next_cursor: null. Every route needs Authorization: Bearer <non-empty> (never stored or ledgered) and Notion-Version: 2025-09-03, and answers only on the recorded origin https://api.notion.com (notionEmulatorOrigin): fetch reads the origin from the request URL; behind a loopback rewrite, serve fetchOn(notionEmulatorOrigin).

Every answer value comes from a fixture, or is a value the emulator mints (created page ids from a counter that starts above the seeded ones, their timestamps from the injectable now clock, request ids, and cursors). Pages a fixture only names by id (the blocks page, the parent pages, the next query row) are implied: their ids resolve where a fixture names them, but they are never rendered, and search considers only the pages whose content the state holds, so an implied page never matches. A cursor is accepted only when this emulator issued it for the same list since the last reset or seed and the list renders exactly as when it was issued. No cursor value crosses a reset or seed: property cursors come from a counter that never resets, and search and block cursors are the next result's id (the fixture's value) only in the generation that first issued that id for that list, <id>.g<generation> afterwards, so a pre-reset cursor stays refused even after the same first-page request. Anything else answers one ledgered 400 not-emulated, writes nothing, and uses up no fault: unknown routes and methods, another origin, other Notion-Version values, query parameters a route does not take, a missing page_size, other search filters, a search without matches or whose matches include a trashed page or a page shown only as a query row, children of a page without recorded child blocks, sorts and query filters, a query page that would show an unrecorded row, creates with children, under a database, or with another title, page updates other than { archived: true }, and archiving a missing or already trashed page. So findNotionConformanceLeftovers fails against a clean workspace or after the write case (no match, or a trashed match) with NotionConformanceActionFailed (HTTP 400), which the live runner reports as its lookup-failed WARN.

  • Request-shape latitude (/notion, the only accepted deviations): any bearer value (never checked or stored); extra request headers; JSON key order; content-type media-type parameters; the order of query parameters; Notion ids with or without dashes, in any case; any search query (looked up in the state); and any page_size from 1 to 100 whose page shows only recorded results (the data source query: 1). Notion-Version must be 2025-09-03. Everything else (other keys, filters, booleans, sorts, query parameters, another origin, titles, repeated or missing page_size, and cursors not issued for the same list since the last reset or whose list changed) is not emulated.

The default seed is the synthetic fixture entities with the same ids as notionConformanceFixtureSeeds; profiles default and empty; an archived page stays in the state, in the trash. Faults, the ledger (which records the Notion-Version header), and the control plane behave as in the Dropbox emulator. The drills option (eight booleans, one per Notion case) is a test-only drill knob that makes exactly the matching conformance case fail.

Todoist emulator

@yolk-sdk/emulators/todoist

Experimental, Node only. A stateful, fixture-only stand-in for the Todoist API v1 routes the Todoist conformance cases use, built on the same @emulators/core runtime (loaded lazily when you create an emulator).

ExportPurpose
makeTodoistEmulator(options?)Promise of { fetch, ledger, faults, cursors, reset, seed, snapshot, coverage, close }
todoistEmulatorRoutesRoute evidence manifest (ten routes, all unverified; five are connector write routes)
TodoistEmulatorSeed, TodoistEmulatorProfileTyped seed schema (profile, userId, projects, tasks, labels); profiles default and empty
TodoistFault{ kind: 'status', status (400-599), headers?, body?, match?: { method?, path?, route? }, count? }
TodoistEmulatorInputInvalidInvalid seed or fault passed to the JS API
todoistEmulatorDefaultOriginhttps://api.todoist.com
import { makeTodoistEmulator } from '@yolk-sdk/emulators/todoist'
import { EmulatorRoute, InProcessHttpClient } from '@yolk-sdk/emulators/router'

const todoist = await makeTodoistEmulator()

const httpLayer = InProcessHttpClient.layer([
  EmulatorRoute.handler('https://api.todoist.com', todoist.fetch)
])

It serves, under /api/v1 with Authorization: Bearer <token> (at least 8 characters; never stored or ledgered, and refused when the path, query, or body repeats it): GET /tasks (active tasks of a project, REST v1 cursor paging with next_cursor), task create, read, update, and close, GET /labels, GET /projects (every project, REST v1 cursor paging), and project create, read, and delete (which removes the project's task). Case projects are named yolk-conformance-<runId>-<case> with any run- run id, so a live runner's run-<hex> ids work. Bodies, 404 envelopes ({ error, error_code, error_extra, error_tag, http_code }), cursors, and due objects follow the synthetic fixtures; created ids (reserved prefix 6XEmu, which seeds may not use) and event_ids come from counters that only advance, timestamps from the injectable now clock, and cursors are valid only as issued since the last reset or seed (a project cursor also only while the project listing is unchanged); the cursor counters never reset, so no cursor value crosses a reset or seed.

It is fixture-only, with no synthesised answers: anything the fixtures do not record answers one ledgered 400 { error: { type: 'not_emulated', message } } before anything is written and before any fault is chosen, for example other routes, body fields such as labels or due_string, other due values, task listings other than the paging project with limit=2 or a case project created here without limit, unpaged label listings larger than limit, a project listing without limit or without projects, a closed task, reading a seeded project alone (only the project listing fixture records its object), writes to seeded items (only items created through the recorded create flow are updated, closed, or deleted), and a second task in a case project or a second sub-project (the fixtures record child_order: 1 only). The project listing (GET /projects) of the read-only leftover lookup findTodoistConformanceLeftovers is the one the project paging case (todoist.projects.list-cursor-paging) records, so the lookup runs against the emulator: it finds nothing on the default seed and lists every yolk-conformance-run-* project the state holds.

Unrecognised requests (no emulated route under that HTTP method, or raw id segments that are not Todoist ids) are ledgered and answered with constant text only: the path /<unrecognised>, a standard method or <other>, no query or body, and a constant reason. So is a request whose Authorization header is present but is not one recognisable bearer, whatever its route: its credential cannot be extracted and scrubbed.

Run write cases sequentially on one emulator, or reset() between cases: a seeded parent takes one case project at a time (the fixtures record child_order: 1 only), so concurrent write cases, or a case that failed before its cleanup, make later project creates answer not-emulated (a definitive rejection: nothing is created).

Accepted request-shape latitude: any credential value of at least 8 characters that occurs nowhere else in the request (its path, query, or body; never checked against anything, stored, or ledgered); extra request headers; content-type parameters; query parameters in any order; any Todoist id (1-64 of [A-Za-z0-9_-]) of an existing item where a fixture has an id (reads: seeded or created tasks and created projects; task listings: the paging project with limit=2 and case projects created here without limit; writes: only items created through the recorded create flow; a new project's parent_id: a seeded project); any run- run id (at most 40 characters) in a case project name; any non-empty task content; a task update sending content, due_datetime, or both; a label listing limit of 1 to 200 that covers every label; a project listing limit of 1 to 200, its pages chained through cursors this emulator issued for the same limit and unchanged listing. The drills option (cursorRestarts, notFoundWithoutError, taskLabelsAsIds, projectCursorRestarts, listIncludesClosed, ignoreDue, createOmitsParent, deleteKeepsTasks) is a test-only knob that makes exactly one Todoist case fail.

Telegram emulator

@yolk-sdk/emulators/telegram

Experimental, Node only. A stateful, fixture-only stand-in for the Telegram Bot API routes the Telegram conformance cases use, built on the same @emulators/core runtime (loaded lazily when you create an emulator).

ExportPurpose
makeTelegramEmulator(options?)Promise of { fetch, ledger, faults, reset, seed, snapshot, coverage, close }
telegramEmulatorRoutesRoute evidence manifest (four routes, all unverified; sendMessage is a connector write route)
TelegramEmulatorSeed, TelegramEmulatorProfileTyped seed schema (profile, bot, chats, files, nextMessageId); profiles default, empty
TelegramFault{ kind: 'status', status (400-599), headers?, body?, match?: { method?, path?, route? }, count? }
TelegramEmulatorInputInvalidInvalid seed or fault passed to the JS API
telegramEmulatorDefaultOriginhttps://api.telegram.org

It serves POST /bot<token>/getChat (a member chat, or the recorded 400 chat not found), GET /bot<token>/getFile?file_id=..., the hosted file download GET /file/bot<token>/<file_path>, and POST /bot<token>/sendMessage. The bot token is required but never stored, forwarded, ledgered, or echoed. The emulator fails closed: only a request whose raw path is exactly one of these route shapes (the strict token on the raw segment, an emulated method, no other path text) is recognised, and its token is taken from that exact segment. Every other request is ledgered and answered with constant text only (the path /<unrecognised>, a standard method or <other>, no query or body, a constant reason), so an encoded separator, a malformed token, or extra segments carry nothing into the ledger. For a recognised request, the token and its secret part are scrubbed from the ledgered method, path (/bot<redacted>/...), query keys and values, and every not-emulated message, and a query, remaining path, or body that repeats them (raw, percent-decoded, or in any parsed JSON key, string value, or number) is refused with constant text. A token whose bot id is 0 names no bot (getChat answers the recorded 401). A send is irreversible on the real service; the emulator records it in its state (sentMessages) and never delivers anything.

It is fixture-only, like the Todoist emulator: anything else answers the ledgered 400 not-emulated. Accepted request-shape latitude: any credential value of at least 8 characters that occurs nowhere else in the request (its path, query, or body; never checked against anything, stored, or ledgered); extra request headers; content-type parameters; a well-formed <digits>:<secret> bot token with a secret of at least 8 characters (the bot id 0 names no bot); any well-formed chat_id string (an integer or a public @username; one the bot is not in answers the recorded 400 on getChat); any non-empty message text. The drills option (getChatOkFalse, errorsAs200, fileSizeOffByOne, sendOkFalse) makes exactly one Telegram case fail.

Both emulators share faults (status only, 400-599, chosen only after the request passed every check, including the route's eligibility check against the state, and answered before the commit, so a refused request never uses one and nothing is written; the check, the fault decision, and the commit run together, so concurrent requests never interleave; a match.route naming no manifest route is rejected when the fault is added; a 429 reaches the connector as todoist_rate_limited / telegram_rate_limited), the ledger (credential-named query and body keys redacted, guarded credential values scrubbed), clock-free recovery (a handler that throws answers an evidence-tagged 500 emulator_error recorded with responseError; a closed emulator answers 503), and the /_emulate/* control plane (ledger, faults, reset, state, seed, coverage).

GitHub emulator

@yolk-sdk/emulators/github

Experimental, Node only. A stateful, fixture-only stand-in for exactly the GitHub REST routes the GitHub conformance cases use, built on the same @emulators/core runtime (loaded lazily when you create an emulator).

ExportPurpose
makeGithubEmulator(options?)Promise of { fetch, fetchOn, ledger, faults, reset, seed, snapshot, coverage, close }
githubEmulatorRoutesRoute evidence manifest (12 routes, all unverified; six are connector write routes)
GithubEmulatorSeed, GithubEmulatorProfileTyped seed schema (profile, viewer, repository, labels, issues, files, impliedIssues, counters); profiles default, empty
GithubFault{ kind: 'status', status (400-599), headers?, body?, match?: { method?, path?, route? }, count? }
GithubEmulatorInputInvalidInvalid seed, fault, or option passed to the JS API
githubEmulatorOriginhttps://api.github.com
githubEmulatorErrorBodiesThe fixtures' not-found, label, and validation error bodies, byte for byte
githubEmulatorAccept, githubEmulatorApiVersionapplication/vnd.github+json and 2026-03-10, the header values every request needs
import { makeGithubEmulator } from '@yolk-sdk/emulators/github'
import { EmulatorRoute, InProcessHttpClient } from '@yolk-sdk/emulators/router'

const github = await makeGithubEmulator()

const httpLayer = InProcessHttpClient.layer([
  EmulatorRoute.handler('https://api.github.com', github.fetch)
])

It serves, on the seeded repository: GET /repos/{owner}/{repo}/labels (per_page, page, with the paging fixture's Link header minted in its exact form; a listing that fits one page carries none), GET /repos/{owner}/{repo}/issues (state=open, per_page, page=1: the open issues, newest first, on one page), GET .../issues/{number} (the recorded 404 for a number the repository has not reached), GET /search/issues (the recorded 422 for a repository-scoped query longer than 256 characters), GET .../contents/{path} (base64 folded every 60 characters), comment create, listing (per_page=100 with since, or page=1), and delete (204, then the recorded 404), issue label add and remove (the recorded 404 for a repository label not on the issue; removing an issue's last label is not emulated), and issue create, rename, and close as completed. Every route needs exactly Authorization: Bearer <token> (a recognisable bearer, as below; never compared against anything, stored, or ledgered), Accept: application/vnd.github+json (githubEmulatorAccept), and X-GitHub-Api-Version: 2026-03-10 (githubEmulatorApiVersion), and answers only on the recorded origin https://api.github.com (githubEmulatorOrigin): fetch reads the origin from the request URL; behind a loopback rewrite, serve fetchOn(githubEmulatorOrigin).

Every answer value comes from a fixture, or is a value the emulator mints: created issue numbers and comment ids from counters that only advance (the default seed starts at the fixtures' issue 42 and comment 9000000001, a seed's counters lie above its seeded numbers, no seeded node id may use a minted form at or above its counter, and a create past the last addressable number or id is refused), the issue and comment ids derived from them in the fixtures' form, and timestamps from the injectable now clock. Issue numbers below the counter that the state does not hold are implied, never rendered; the open-issue listing answers only while the seed's impliedIssues is closed (the default seed's, as the open-listing fixture records) or no number is implied; a seed that replaces repository or issues or sets nextIssueNumber gets unknown unless it names impliedIssues: 'closed'. Label pages are page numbers, not cursors, and the label list never changes within a seed (no route writes labels). A deleted comment's id and a closed issue stay in the state (GitHub keeps both), so a write case ends at the seed except those and the counters.

It fails closed: only a request whose raw path is exactly an emulated route shape under that route's method, with no Authorization header or exactly Bearer <token>, is recognised. Every other request is ledgered and answered with constant text only (the path /<unrecognised>, a standard method or <other>, no query or body, a constant reason). A recognised bearer must match the RFC 6750 b64token syntax exactly (^[A-Za-z0-9\-._~+/]+=*$, at least 8 characters), start with a character in [G-Zg-z\-._~+/] other than n, r, t, u, and hold at least one character outside the JSON-number alphabet [0-9.eE+-] (every GitHub and Google token form does: ghp_…, github_pat_…, gho_…, ya29.…). So no number's text can contain it; it holds no escape introducer (%, \, "), so no escape starts inside it; and its first character is no hex digit and no JSON escape letter, so no stray %, \, or partial escape to its left can complete with it, and its characters always decode in place. An Authorization header with any other value is unrecognisable. A recognised request that repeats the bearer value in its raw path, any path segment, the raw query or any query key or value, any recorded header, or its body is refused and ledgered with constant text only: a standard method, the path /<unrecognised>, its route template, an empty query, no headers or body, and a constant reason (the query repeats the credential, for example). Each part is checked through the closure of two total, lexical transforms that cannot fail: a tolerant percent-decode (every %XX below %80 becomes its ASCII character; any other % sequence is left as it is) and a tolerant JSON-unescape (in any text, whether or not it parses as JSON, \uXXXX below \u0080 and \", \\, \/, \b, \f, \n, \r, \t become their characters). Starting from each part's raw text, either transform is applied to every text of the previous step, deduplicated, until no new text appears (a fixpoint), and every text is checked for the bearer as a substring; both transforms never lengthen a text and shorten it whenever they change it. So any depth of percent-encoding or JSON escaping, in any order, is seen through in every part: the raw path and each raw path segment, the raw query and each query key and value (already decoded once by URLSearchParams), each recorded header, and the raw body. The work is capped at 64 rounds, 1024 distinct texts, or 8 Mi characters read by the transforms, whichever comes first; a part whose closure hits a cap before its fixpoint counts as repeating the credential and is refused with the same constant entry (uncertainty refuses, it never admits; so any part over 4 Mi characters is always refused). Any other recognised request has the bearer value scrubbed from its ledgered fields and every not-emulated reason (plan-time reasons included); its recorded query is keyed by recorded key; a key recorded more than once lists its values in order (as a JSON array); and recorded headers and query keys and values that start like JSON ({, [, ") are recorded parsed with credential-named keys redacted at any depth, or as <redacted> when they do not parse, whatever the header's declared format. Also, refusals never echo a request's own query or body keys; empty query components are refused. It is fixture-only: anything else answers the ledgered 400 not-emulated before anything is written and before any fault is chosen, for example other routes, issue creates with labels or assignees, updates other than the two recorded ones (so the lifecycle case's failure-path restore, which closes as not_planned, is not emulated), adding a label the repository lacks (it would create it), a comment listing of more than one comment, rendering an issue that holds comments (every fixture answers comments: 0), issue paging, and writes to closed or implied issues. The reads of the read-only leftover lookup findGithubConformanceLeftovers (the open-issue listing, the work issue's first comment page, and the work issue) are the ones the open-listing case (github.issues.open-listing) records, so the lookup runs against the emulator: it finds nothing on the default seed and lists an open yolk-conformance run-* issue the state holds.

  • Request-shape latitude (/github, the only accepted deviations): any bearer value in the RFC 6750 b64token syntax ([A-Za-z0-9\-._~+/]+=*) of at least 8 characters, starting with a character in [G-Zg-z\-._~+/] other than n, r, t, u (so a legacy all-hex token is refused), with at least one outside [0-9.eE+-], that occurs nowhere else in the request (never compared against anything, stored, or ledgered); extra request headers; JSON key order; content-type media-type parameters; the order of query parameters; any non-empty issue title and comment body, and any issue body text; any comment listing since of the form YYYY-MM-DDTHH:MM:SSZ (or, instead of since, page=1); any label listing per_page from 1 to 100, with no page or a page from 2 to one past the last page; any open-issue listing (state=open, page=1) per_page from 1 to 100; any issue search q that starts with the seeded repo:<owner>/<repo> qualifier and whose query after it is longer than 256 characters (answered the recorded 422); any issue number the repository has not reached (answered the recorded 404); and any issue, comment, repository label, or file the state holds where a fixture has one, under the per-route state rules. Authorization must be exactly Bearer <token> (that spelling, one space), Accept application/vnd.github+json, and X-GitHub-Api-Version 2026-03-10. Everything else (other keys and values, query parameters, empty query components such as a bare ? or a stray &, another origin or repository, a repeated query key, an explicit page=1 on the label listing, and a comment listing per_page other than 100) is not emulated.

Faults, the ledger (which records the Accept and X-GitHub-Api-Version headers), clock-free recovery, and the control plane behave as in the Dropbox emulator; a 429 fault reaches the connector as github_rate_limited. The drills option (eight booleans, one per GitHub case) is a test-only knob that makes exactly the matching conformance case fail.

Google emulator

@yolk-sdk/emulators/google

Experimental, Node only. A stateful, fixture-only stand-in for the Gmail, Calendar, and Drive routes the Google conformance cases use, built on the same @emulators/core runtime (loaded lazily when you create an emulator).

ExportPurpose
makeGoogleEmulator(options?)Promise of { fetch, fetchOn, ledger, faults, reset, seed, snapshot, coverage, close }
googleEmulatorRoutesRoute evidence manifest (27 routes, all unverified; 15 are connector write routes)
GoogleEmulatorSeed, GoogleEmulatorProfileTyped seed schema (messages, implied entities, attachments, calendars, events, Drive files)
GoogleFault{ kind: 'status', status (400-599), headers?, body?, match?: { method?, path?, route? }, count? }
GoogleEmulatorInputInvalidInvalid seed, fault, or option passed to the JS API
googleEmulatorGmailOrigin, googleEmulatorApisOriginhttps://gmail.googleapis.com and https://www.googleapis.com
import {
  googleEmulatorApisOrigin,
  googleEmulatorGmailOrigin,
  makeGoogleEmulator
} from '@yolk-sdk/emulators/google'
import { EmulatorRoute, InProcessHttpClient } from '@yolk-sdk/emulators/router'

const google = await makeGoogleEmulator()

const httpLayer = InProcessHttpClient.layer([
  EmulatorRoute.handler(googleEmulatorGmailOrigin, google.fetch),
  EmulatorRoute.handler(googleEmulatorApisOrigin, google.fetch)
])

It serves the Gmail routes the cases use (label listings of messages and of threads with page tokens, message reads in the format renderings a fixture records, with an optional metadataHeaders selection, attachments, the label listing and lifecycle, adding a created label, trash and untrash, the draft search, the draft lifecycle and its thread, and the multipart practice send), the Calendar event routes (time-range listings with page tokens, the free-text query, and a run event created, read, renamed by PATCH, deleted to cancelled, and answered the recorded 410 when deleted again), and the Drive file routes (folder listings with page tokens, with or without trashed items, reads with the connector fields selection, and a run folder created, trashed, and deleted, then the recorded 404). Every route needs Authorization: Bearer <token> (a recognisable bearer) and answers only on its recorded origin: fetch reads the origin from the request URL; behind a loopback rewrite, serve fetchOn(origin) for each origin on its own server.

The leftover lookup's reads. findGoogleConformanceLeftovers reads what four read cases record: the label listing (google.gmail.label-listing: the seeded system and paging labels as recorded, then the labels created here), the draft search (google.gmail.draft-search), the free-text event query (google.calendar.free-text-query), and the folder listing with trashed items (google.drive.list-includes-trashed). So the lookup runs against the default seed and lists a run label or a run folder (in Trash too) the state holds. The draft search and the event query are recorded only empty, and stay fixture-only: the draft search answers only while the state holds no draft and no message labelled DRAFT (Gmail's search syntax is not emulated), and the event query only while no event of the calendar, cancelled or not, holds yolk or conformance in any case in its summary or description, nor, while the calendar holds events, its id or summary (the organizer) or the practice address (the creator): Google's free-text matching cannot be emulated honestly. Otherwise they answer the ledgered 400 not-emulated, so after the event cases, whose cancelled run events stay in the state, the lookup fails closed and a runner prints its lookup-failed WARN.

Draft attachments are not emulated. gmail.draft_compose, gmail.draft_update, and gmail.draft_reply with attachments write through the draft media upload (POST /upload/gmail/v1/users/me/drafts?uploadType=multipart, or PUT .../drafts/{id}?uploadType=multipart), which no fixture records, so it answers the constant unrecognised 400 until a draft-attachment conformance case is recorded live. Drafts without attachments are unaffected.

The practice send is recorded, never delivered. It is irreversible on Gmail; the emulator accepts only the recorded 7-bit message whose sole recipient header is To: <the seeded practiceAddress>, records it in its state (it reads back with the recorded headers, its Date from the injectable now clock), and delivers nothing anywhere. A seed may set another practiceAddress, but then every send is refused: the recorded sizeEstimate of the sent message covers its address, as it covers the draft and send subjects (which therefore take only a run id of the fixtures' length, 13 characters).

Fail closed: the shared rule. Google follows the same fail-closed rule as the GitHub emulator above: every route parameter has a raw pattern matched in full, so a request is recognised only when its raw path is exactly an emulated route shape and any Authorization header is exactly Bearer <token> with a recognisable bearer (Google's ya29.… tokens qualify); every other request is ledgered and answered with constant text only (the path /<unrecognised>, a standard method or <other>, no query or body, a constant reason). The bearer value is never stored or ledgered: a recognised request that repeats it in its path, query, recorded content-type header, or raw body (the multipart send body included) or, on the draft routes, in the base64url-decoded MIME of message.raw, through any depth of percent-encoding or JSON escaping, is ledgered as the constant credential-repeat entry, and any other recognised request has it scrubbed from everything the ledger keeps and every not-emulated message. A message.raw the route would refuse (anything but canonical unpadded base64url of exactly the recorded draft MIME, the run id aside) makes the view throw a DecodedViewRefusal with one of the route's declared constant reasons (viewRefusalReasons: the canonical-base64url reason, the other-than-the-recorded-run-draft reason, the 13-character run-id reason, the extra-key reason), which the wrapper ledgers in the constant entry before anything is recorded (or the request body repeats the credential when the raw decodes cleanly to text holding the bearer), so a refused message.raw never reaches the ledger. Refusals never echo a request's own query or body keys.

Every answer value comes from a fixture, or is a value the emulator mints: created label ids above every seeded label number, draft, message, event, and folder ids in forms seeds may not use, page tokens (the fixtures' values on first issuance, <token>.g<generation> after a reset or seed, and a distinct <token>.v<k> for another list or page size or a changed list: token values are globally unique and never rebound), and timestamps from the now clock. Entities a fixture only names (the paging label, the messages its listing names, their threads (named by the thread listing), the practice Drive folder) are implied: references resolve through them, but no answer renders them. A page token is accepted only when this emulator issued it for the same list since the last reset or seed and the list renders exactly as when it was issued. Anything else answers one ledgered 400 not-emulated, writes nothing, and uses up no fault, including an empty listing and every read of findGoogleConformanceLeftovers (its label listing, draft search, free-text event query, and trashed-included Drive listing have no fixture): the lookup fails with GoogleConformanceActionFailed (gmail_list_labels_failed, HTTP 400), which the live runner reports as its lookup-failed WARN.

  • Request-shape latitude (/google, the only accepted deviations): any bearer value in the RFC 6750 b64token syntax ([A-Za-z0-9\-._~+/]+=*) of at least 8 characters, starting with a character in [G-Zg-z\-._~+/] other than n, r, t, u, with at least one outside [0-9.eE+-] (Google's ya29.… access tokens qualify), that occurs nowhere else in the request (never compared against anything, stored, or ledgered); extra request headers (except X-Goog-Drive-Resource-Keys, which no fixture sends); JSON key order; content-type media-type parameters on JSON requests; query parameters in any order; any run- run id (at most 40 characters) in a run-scoped label name, event summary, or folder name; in a draft subject (compose and update) and the sent subject, only a run id of exactly 13 characters, the length of the fixtures' run-synthetic, because the recorded sizeEstimate of the draft and sent messages (answered by their message reads and the draft thread) covers the subject; on the practice send, a content-type of exactly multipart/related; boundary=<b> with any one unquoted boundary of 1 to 70 [A-Za-z0-9_] characters and no other parameter; a gmail.list, gmail.list_threads, or gmail.list_drafts (the recorded q only) maxResults from 1 to 500, a calendar.list_events maxResults from 1 to 2500 (a range, or the recorded q), and a drive.list_files pageSize from 1 to 1000 (with or without and trashed = false); any timeMin before timeMax (RFC 3339 instants with a real calendar date, hour 0 to 23, minute and second 0 to 59, and a Z or in-range numeric offset); any id of an item the state holds where a fixture has an id (writes: only items created here, plus label changes, trash, and untrash of a stored non-draft message); and, for an id the state does not hold, only the recorded not-found answers (a format=minimal read of a 16-hex-digit message id, a read of a Label_<1 to 999999999> label, a delete of an r-<digits> draft, and a Drive file read); on a format=metadata message read, and on a format=metadata read of a thread of stored non-draft messages (a thread read in that format takes a selection), a metadataHeaders selection, repeated in any order, of 1 to 50 distinct header names each spelled exactly as a header of the recorded metadata rendering, answered as that rendering with only the selected headers, in recorded order. A seed may set another practiceAddress, but then every send is refused, since the recorded sizeEstimate of the sent message also covers the address: the send answers only while the seeded address is the recorded practice@example.test. On the draft compose and update routes, message.raw must be canonical unpadded base64url of exactly the recorded draft MIME of that route, the run id aside; any other message.raw (line-wrapped, the standard alphabet, padded, with a stray character, or with MIME-level encodings such as RFC 2047 encoded-words, quoted-printable other than the recorded parts, or UTF-16) is refused before anything is recorded or a fault is decided, as a constant entry with the route's own declared reason (message.raw must be canonical base64url UTF-8 MIME, a draft compose other than the recorded run draft is not emulated or its update form, the 13-character run-id reason, or message has a key this route does not take), or the request body repeats the credential when that raw decodes cleanly to text holding the bearer, so a refused message.raw never reaches the ledger and an admitted one is the recorded text. Authorization must be exactly Bearer <token> (that spelling, one space). Everything else (other keys, values, formats, query parameters, empty query components such as a bare ? or a stray &, recorded headers such as Drive's accept: application/json missing, another origin, repeated query parameters, any recipient but the seeded practice address, a draft or send run id of another length, a bearer repeated anywhere in the request, including base64url-encoded inside a draft's message.raw, and page tokens not issued for the same list since the last reset or seed, or whose list changed) is not emulated.

The default seed is the synthetic fixture entities with the ids of googleConformanceFixtureSeeds; profiles default and empty. A reversible case ends at the seed except the counters and, for the event cases, its own event, which stays readable as cancelled; the send leaves its sent message. Faults, the ledger, clock-free recovery, and the control plane behave as in the Dropbox emulator; a 429 fault with retry-after reaches the connector as google_rate_limited. The drills option (nineteen booleans, one per Google case) is a test-only knob that makes exactly the matching conformance case fail.

LinkedIn search emulator

@yolk-sdk/emulators/linkedin-search

Experimental, Node only. A stateful, fixture-only stand-in for the Exa and Enrich Layer routes the LinkedIn search conformance cases use, built on the same @emulators/core runtime (loaded lazily when you create an emulator).

ExportPurpose
makeLinkedInSearchEmulator(options?)Promise of { fetch, fetchOn, ledger, faults, reset, seed, snapshot, coverage, close }
linkedInSearchEmulatorRoutesRoute evidence manifest (3 routes, all unverified reads)
LinkedInSearchEmulatorSeedTyped seed schema (searches, profiles, absent profile URLs, rejected keys per origin)
LinkedInSearchFault{ kind: 'status', status (400-599), headers?, body?, match?: { method?, path?, route? }, count? }
LinkedInSearchEmulatorInputInvalidInvalid seed, fault, or option passed to the JS API
linkedInSearchEmulatorExaOrigin, linkedInSearchEmulatorEnrichLayerOriginhttps://api.exa.ai and https://enrichlayer.com
linkedInSearchEmulatorErrorBodiesThe fixtures' 401 and 404 bodies, byte for byte
import {
  linkedInSearchEmulatorEnrichLayerOrigin,
  linkedInSearchEmulatorExaOrigin,
  makeLinkedInSearchEmulator
} from '@yolk-sdk/emulators/linkedin-search'
import { EmulatorRoute, InProcessHttpClient } from '@yolk-sdk/emulators/router'

const linkedIn = await makeLinkedInSearchEmulator()

const httpLayer = InProcessHttpClient.layer([
  EmulatorRoute.handler(linkedInSearchEmulatorExaOrigin, linkedIn.fetch),
  EmulatorRoute.handler(linkedInSearchEmulatorEnrichLayerOrigin, linkedIn.fetch)
])

It serves three reads: the Exa people search (POST /search on https://api.exa.ai) and the Enrich Layer profile and email lookups (GET /api/v2/profile and GET /api/v2/profile/email on https://enrichlayer.com, with linkedin_profile_url). Every route needs Authorization: Bearer <key> (a recognisable bearer; each provider takes its own key) and answers only on its recorded origin: fetch reads the origin from the request URL; behind a loopback rewrite, serve fetchOn(origin) for each origin on its own server.

Every answer comes from a fixture, byte for byte, through the seed, and nothing is written or minted: a search answers only the results the state holds for exactly its query and numResults (the default seed holds the fixtures' three answers for the seeded query, numResults 10, 3, and 2); a profile lookup answers a held profile or, for a seeded absent profile, the recorded 404; an email lookup answers a held profile's recorded email. A key the seed marks as rejected on an origin answers that origin's recorded 401 (the default seed rejects the synthetic invalid keys the two unauthorized cases send; a key rejected on one origin is accepted on the other). Anything else answers one ledgered 400 not-emulated and uses up no fault, and every case ends exactly at its seed.

Fail closed: the shared rule, and keys kept only as digests. LinkedIn search follows the same fail-closed rule as the GitHub emulator above: a request is recognised only when its raw path is exactly an emulated route path and any Authorization header is exactly Bearer <key> with a recognisable bearer (a UUID-form key starts with a hex digit and is unrecognisable, so use a synthetic key); every other request is ledgered with constant text only. A recognised request that repeats its bearer in its path, query, recorded content-type header, or body, through any depth of percent-encoding or JSON escaping, is ledgered as the constant credential-repeat entry, and any other has it scrubbed from everything the ledger keeps. The bearer is never stored or ledgered: through the shared wrapper's opt-in per-origin bearer digest, routes see only SHA-256 of the origin, a space, and the key, which they compare with the digests of the seed's rejected keys for that origin. The state holds only those digests, so a key a request carries as its bearer, a rejected one included, never reaches the state, a snapshot, or /_emulate/* (a key sent as data elsewhere in a request is ledgered like any other text), and no seed error quotes one: seed errors are constant text, a category and a field path. This guarding covers the emulated provider API calls only: /_emulate/* is the host's trusted control plane, and the seed and fault data a host gives it is stored and returned as given.

  • Request-shape latitude (/linkedin-search, the only accepted deviations): any bearer value in the RFC 6750 b64token syntax ([A-Za-z0-9\-._~+/]+=*) of at least 8 characters, starting with a character in [G-Zg-z\-._~+/] other than n, r, t, u, with at least one outside [0-9.eE+-], that occurs nowhere else in the request (never stored or ledgered; only its per-origin digest is compared, with the digests of the keys the seed marks as rejected on that origin); extra request headers; JSON key order; content-type media-type parameters on the search; any percent-encoding of the linkedin_profile_url value that decodes once to the same profile URL; and, with a key the seed marks as rejected on the request's origin, any search query (one trimmed line of at most 500 characters) with any integer numResults from 1 to 100, and any profile URL of the form https://<host>/in/<slug>, each answered the origin's recorded 401. Authorization must be exactly Bearer <token> (that spelling, one space). Everything else (other body keys or values, a category other than people, a type other than auto, contents other than { "text": true }, a search the state holds no answer for (another query, or a numResults no seeded search of that query records), a profile URL the state holds neither as a profile nor as absent, an email lookup of an absent profile, any query parameter on the search, other, missing, or repeated query parameters on a lookup, a query parameter name in any but its plain form (such as %6cinkedin_profile_url), empty query components such as a bare ? or a stray &, a body on a lookup, another origin, and a bearer repeated anywhere in the request) is not emulated.

Seed with seed: { searches?, profiles?, absentProfileUrls?, exaRejectedKeys?, enrichLayerRejectedKeys? } (each list replaces the default's). Faults, the ledger, recovery, and the control plane behave as in the Dropbox emulator; the connector maps every non-2xx answer to its action's failure code, so a 429 fault reaches it as linkedin_search_failed with status 429. The drills option (seven booleans, one per LinkedIn search case) is a test-only knob that makes exactly the matching conformance case fail.

MCP emulator

@yolk-sdk/emulators/mcp

Experimental, Node only. A stateful, fixture-only stand-in for the two synthetic MCP servers of the @yolk-sdk/mcp/conformance fixtures, for the Afloat MCP endpoint of the @yolk-sdk/connectors/afloat/conformance fixtures, and for the Figma MCP endpoint of the @yolk-sdk/connectors/figma/conformance fixtures, built on the same @emulators/core runtime (loaded lazily when you create an emulator).

ExportPurpose
makeMcpEmulator(options?)Promise of { fetch, fetchOn, ledger, faults, reset, seed, snapshot, coverage, close }
mcpEmulatorRoutesRoute evidence manifest (21 rows: one RPC <origin><path>#<method> per method, plus GET and DELETE)
McpEmulatorSeedTyped seed schema (modernListing, legacyInitialize; sessions are never seeded)
McpFaultA status fault (400-599) or { kind: 'truncate-after-chunks', chunks, match?, count? }
McpEmulatorInputInvalidInvalid seed, fault, or option passed to the JS API
mcpEmulatorOriginhttps://mcp.example.test (paths /modern/mcp and /legacy/mcp)
mcpEmulatorReservedInvalidCredentialyolk-conformance-invalid-credential-0000, answered the recorded 401 on the era probe
mcpEmulatorFixturesThe sixteen synthetic MCP fixtures, copied as data
mcpEmulatorServerPingFixturesThe opt-in server ping's synthetic legacy fixture, copied as data
mcpEmulatorAfloatOriginhttps://useafloat.com: the origin of the afloat profile
mcpEmulatorAfloatPath/mcp: the path of the afloat profile (https://useafloat.com/mcp)
mcpEmulatorAfloatKeyPrefixafloat_: the public key prefix; the remainder after it is the guarded secret
mcpEmulatorAfloatReservedInvalidCredentialafloat_yolkconformanceinvalid0000, answered the recorded 401 on the Afloat era probe
mcpEmulatorAfloatFixturesThe eight derived Afloat MCP fixtures, copied as data
mcpEmulatorFigmaOriginhttps://mcp.figma.com: the origin of the figma profile
mcpEmulatorFigmaPath/mcp: the path of the figma profile (https://mcp.figma.com/mcp)
mcpEmulatorFigmaFixturesThe eight synthetic Figma MCP fixtures, copied as data

Setup fragment (not a runnable example): it builds the emulator and the HttpClient layer to provide to the code under test, which then targets https://mcp.example.test/{modern,legacy}/mcp with a synthetic Authorization: Bearer header; await mcp.close() when done.

import { makeMcpEmulator, mcpEmulatorOrigin } from '@yolk-sdk/emulators/mcp'
import { EmulatorRoute, InProcessHttpClient } from '@yolk-sdk/emulators/router'

const mcp = await makeMcpEmulator()

const httpLayer = InProcessHttpClient.layer([EmulatorRoute.handler(mcpEmulatorOrigin, mcp.fetch)])

It serves profile synthetic-modern on https://mcp.example.test/modern/mcp (stateless 2026-07-28: server/discover, tools/list, and tools/call, JSON answers) and profile synthetic-legacy on https://mcp.example.test/legacy/mcp (the era probe's recorded 400 fallback, initialize, notifications/initialized, the standing GET answered 405, tools/list, tools/call, SSE answers, and the DELETE that ends a session, answered 200), so @yolk-sdk/mcp/client and the MCP conformance cases run unchanged against it. Every request needs Authorization: Bearer <token> (a recognisable bearer); behind a loopback rewrite, serve fetchOn(mcpEmulatorOrigin).

It also serves profile afloat on the provider endpoint https://useafloat.com/mcp (stateless 2026-07-28, JSON answers, no session, one listing page): the published nine-tool subset, the list-invoices read call, its VALIDATION_ERROR tool error, the absent tool's JSON-RPC error (HTTP 200), and the 401, all from the derived Afloat fixtures (from the provider's source, not recorded live; unverified). Answering the two derived tools/call fixtures, rather than only recorded calls, is in scope by the owner's decision; they stay unverified until a live call is recorded. Its credential rule: an Afloat key is afloat_ and a remainder, and a is a hex digit, so on https://useafloat.com a bearer is recognised only as afloat_<remainder> whose remainder is a recognisable bearer, and the remainder is the guarded secret (repeat checks, output guard, digest), never stored, ledgered, or echoed. Use a synthetic key such as afloat_synthetic-key-0001; a real-format key whose remainder starts with a hex digit, a bearer without afloat_ there, and an afloat_ key on the synthetic origin are not emulated. Behind a loopback rewrite, serve fetchOn(mcpEmulatorAfloatOrigin).

It also serves profile figma on the provider endpoint https://mcp.figma.com/mcp, in the legacy era exactly as synthetic-legacy (the session-less era probe answered 400, initialize minting a session over SSE, notifications/initialized 202, the standing GET 405, the closing DELETE 200, one listing page of six known Figma tool names with synthetic schemas, the get_metadata read call, its tool error, the absent tool's SSE JSON-RPC error, and the 401), all from the synthetic Figma fixtures (placeholders, not recorded live; unverified). Every legacy session is bound to the profile that minted it, and a legacy profile answers only its own sessions. Its bearer follows the plain recognisable-bearer rule (use a synthetic token such as synthetic-figma-token-0001), and the public reserved invalid credential answers the Figma 401 on its era probe. Behind a loopback rewrite, serve fetchOn(mcpEmulatorFigmaOrigin).

The opt-in mcp.legacy.server-ping case of @yolk-sdk/mcp/conformance runs against synthetic-legacy seeded with { legacyInitialize: 'server-ping' } (default plain): initialize then answers that case's fixture, whose SSE answer sends a ping request before its response, and the session awaits the client's answer to that ping, which the response:ping row (https://mcp.example.test/legacy/mcp#response:ping) accepts once with the recorded 202, in either phase. The Figma profile records no ping and ignores the seed. Under that seed every applicable legacy case passes too: the call gate understands a plain ping whose answer the server accepted with 202 and no body, so the calling cases forward their tools/call; with the pingAnswerRejected drill the gate refuses them (#382).

Every answer is a fixture's, byte for byte, with only the request id substituted at the recorded place (the top-level id of a JSON answer, or of the SSE response event's payload; notification events and SSE id: lines stay byte for byte), the minted session id in the recorded mcp-session-id header, and the cursor of the current generation. initialize mints yolk-emu-session-<n> from a counter that never resets (a form no seed holds); at most 256 sessions are held, and another initialize is refused before any fault; the DELETE the client sends as it closes a legacy operation (MCP 2025-11-25 basic/transports, "Session Management" item 5) answers the recorded 200 on a ready session and ends it, so later requests on it are refused; reset and seed clear the sessions. With seed: { modernListing: 'two-pages' }, tools/list answers the recorded paged listing, whose first page issues synthetic-cursor-0001 in the generation that first issues it and <cursor>.g<generation> after a reset or seed; the second page answers only the cursor issued in the current generation. The bearer is never stored, ledgered, or echoed: routes see only its digest, compared only with the digest of the public reserved invalid credential (on the Afloat profile, of the remainder of afloat_yolkconformanceinvalid0000) to answer its recorded 401. Scope: the bearer is never copied from the request into a response, the state, or /_emulate/*; the output guard also refuses a prepared fixture answer, minted session id, or cursor that happens to contain it, but the emulator's other constants (state values such as initializing, wrapper headers such as x-emulator-evidence) and host-configured control-plane data (a fault body) may coincidentally equal a bearer and are not checked. A request that repeats the bearer in any header name or value (not only the recorded headers), its path, query, or body, and a request whose prepared answer or minted session id or cursor would repeat it (a bearer such as yolk-emu-session-1, or synthetic-mcp, inside the recorded yolk-synthetic-mcp), is refused before any fault is decided or anything is written. Every refusal, by shape or by state, is one 400 not-emulated ledgered with constant text only (/<unrecognised>, no query, headers, or body), and it writes nothing and uses up no fault.

  • Request-shape latitude (/mcp, the only accepted deviations): any bearer value in the RFC 6750 b64token syntax ([A-Za-z0-9\-._~+/]+=*) of at least 8 characters, starting with a character in [G-Zg-z\-._~+/] other than n, r, t, u, with at least one outside [0-9.eE+-] (on the Afloat profile, afloat_ followed by such a value: an Afloat key starts with the hex digit a, so its remainder after afloat_ is the value checked, guarded, and digested), that occurs nowhere else in the request (any header name or value included) and in no answer or value the request would store (never stored or ledgered; only its digest is compared, with the digest of the public reserved invalid credential yolk-conformance-invalid-credential-0000, or on the Afloat profile of the remainder of afloat_yolkconformanceinvalid0000, each answering the recorded 401 on its profile's era probe); extra request headers, except mcp-* headers other than mcp-method, mcp-name, mcp-protocol-version, and mcp-session-id; a recorded header value sent as several headers that the HTTP layer joins into the recorded value; JSON key order; any JSON-RPC request id that is an integer from 0 to 2^53 - 1 or 1 to 64 printable ASCII characters where the recording has an id; any non-empty name and version (and no other key) in the _meta client info (io.modelcontextprotocol/clientInfo) of a modern request; a session id this emulator minted on the same profile since the last reset or seed, and that no DELETE has ended, where the recording sends mcp-session-id (initializing for notifications/initialized, either phase for the answer to the server ping, ready otherwise); on the DELETE that ends a session, an accept of any media type (the Fetch default an HTTP layer adds where the recording sends none); and, with the seed's two-pages listing, the cursor this emulator issued in the current generation on the second page. Authorization must be exactly Bearer <token> (that spelling, one space). Everything else (another origin or path, any query, other HTTP methods, a GET or DELETE on the modern or Afloat profile, a bearer without afloat_ on the Afloat profile or with it on the synthetic profiles, an Afloat key whose remainder fails the rule above (such as one starting with a hex digit), JSON-RPC methods no fixture of the profile records such as ping, resources/*, or prompts/*, batches, client-sent responses other than the answer to the recorded server ping (exactly as recorded, the server's ping id included, on a session awaiting it), other members, a JSON body repeating a key (compared after unescaping), a null, negative, or fractional id, other params (other tools, arguments, protocol versions, or capabilities, extra client-info keys, a cursor on the Afloat listing, and a legacy initialize client info other than the recorded one), the MCP headers accept, content-type, mcp-method, mcp-protocol-version, mcp-name, and last-event-id other than the recorded values or present where none is recorded, any other mcp-* header (such as mcp-param-*), mcp-session-id missing where recorded or present where not, an unknown session or one in the wrong phase, a cursor not issued in the current generation, a reserved invalid credential on anything but its profile's era probe, a bearer repeated anywhere in the request, and a bearer an answer or a minted session id or cursor would repeat) is not emulated.

Not emulated: the client's own ping, resources/*, prompts/*, logging/*, completion/*, tasks/* (@yolk-sdk/mcp/client sends none of them), JSON-RPC batches, client-sent responses other than the answer to the recorded server ping, a JSON body repeating a key, mcp-* headers no recording carries (such as mcp-param-*), cursors the emulator did not issue, any other tool or arguments, and a missing Authorization. Status and truncate-after-chunks faults apply only after a request is admitted and planned, and a faulted request writes nothing: a truncation sends the prepared answer cut short and never runs its commit (a truncated initialize mints no session; a truncated first page issues no cursor; a faulted DELETE ends nothing). Truncating a legacy SSE answer after its first chunk ends the stream before the response, so the client fails as an McpError at its timeout instead of hanging. In match, method is the HTTP method and route one manifest row; a route naming no row is rejected when the fault is added. makeMcpEmulator throws when a copied recording is not canonical JSON. The ledger, recovery, and the control plane behave as in the Dropbox emulator. The drills option (eleven booleans: one per MCP case, the opt-in server ping included, and sessionEndRejected, a second mcp.legacy.session knob that answers the DELETE 500) is a test-only knob that makes exactly the matching conformance case fail, on every profile whose answers it changes (the Afloat profile included, except the legacy-only session knob; pingAnswerRejected changes nothing without the server-ping seed).

Kie emulator

@yolk-sdk/emulators/kie

Experimental, Node only. A stateful, fixture-only stand-in for the Kie Market API task read and create routes the Kie conformance cases use, built on the same @emulators/core runtime (loaded lazily when you create an emulator).

ExportPurpose
makeKieEmulator(options?)Promise of { fetch, fetchOn, ledger, faults, reset, seed, snapshot, coverage, close }
kieEmulatorRoutesRoute evidence manifest (2 routes, unverified; POST /api/v1/jobs/createTask is a write)
KieEmulatorSeedTyped seed schema (finished tasks, absent task ids, rejected keys)
KieFault{ kind: 'status', status (400-599), headers?, body?, match?: { method?, path?, route? }, count? }
KieEmulatorInputInvalidInvalid seed, fault, or option passed to the JS API
kieEmulatorOriginhttps://api.kie.ai
kieEmulatorErrorBodiesThe fixtures' not-found (code 422) and 401 bodies, byte for byte
kieEmulatorCreatedId(counter)The minted created-task id form (yolk_synthetic_task_created_0001)
import { kieEmulatorOrigin, makeKieEmulator } from '@yolk-sdk/emulators/kie'
import { EmulatorRoute, InProcessHttpClient } from '@yolk-sdk/emulators/router'

const kie = await makeKieEmulator()

const httpLayer = InProcessHttpClient.layer([EmulatorRoute.handler(kieEmulatorOrigin, kie.fetch)])

It emulates only GET /api/v1/jobs/recordInfo and POST /api/v1/jobs/createTask, so the Kie connector actions and the Kie conformance cases run unchanged against it. recordInfo answers a held finished task's record (the default seed: the fixtures' success and fail tasks), the recorded not-found envelope (code 422 at HTTP 200) for a seeded absent task id, and, for a key the seed marks as rejected (kept only as its digest), the recorded 401 for any well-formed task id. createTask accepts only the two recorded create flows (GPT Image 2 text-to-image, square at 1K; Wan 2.7 image-to-video, 720p for 5 seconds) and answers envelope code 200 with a minted yolk_synthetic_task_created_<n> task id (in suite order on a fresh emulator, the fixtures' ids). A create is irreversible on Kie, so the emulator records each created task in the state, never readable; a faulted create records nothing. The create route is a connector write: its evidence stays pending until an owner-approved live run of the two create cases. Every request needs Authorization: Bearer <key> (a recognisable bearer) and Accept: application/json; anything else answers a ledgered 400 not-emulated.

  • Request-shape latitude (/kie, the only accepted deviations): any bearer value in the RFC 6750 b64token syntax ([A-Za-z0-9\-._~+/]+=*) of at least 8 characters, starting with a character in [G-Zg-z\-._~+/] other than n, r, t, u, with at least one outside [0-9.eE+-], that occurs nowhere else in the request (never stored or ledgered; only its digest is compared, with the digests of the keys the seed marks as rejected); extra request headers; JSON key order; content-type media-type parameters on the create; with a key the seed marks as rejected, any recordInfo task id of 1 to 128 letters, digits, underscores, or hyphens, answered the recorded 401; any non-empty prompt within the connector's limit (20000 characters for GPT Image 2, 5000 for Wan 2.7); and any absolute https first_frame_url without credentials or whitespace of at most 2048 characters. Authorization must be exactly Bearer <token> (that spelling, one space), and Accept application/json. Everything else (a request without Authorization, other body keys or values, a callBackUrl, another model, aspect ratio, resolution, or duration, input_urls, a task id the state holds neither as a finished task nor as absent, a created task's recordInfo, a create with a rejected key, any query parameter on the create, other, missing, or repeated query parameters on recordInfo, a query parameter name in any but its plain form, empty query components such as a bare ? or a stray &, another origin, and a bearer repeated anywhere in the request) is not emulated.

Node server

@yolk-sdk/emulators/node

ExportPurpose
serveFetchHandler(handler, { port? })Scoped Effect resource { url, close } serving on 127.0.0.1 (port 0 default)
startFetchHandlerServer(handler, opts?)The same server as a Promise { url, close }, for non-Effect test runners
EmulatorServeErrorRefused host, invalid port, or listen failure

Only 127.0.0.1 is accepted as a host. Streamed bodies are written chunk by chunk, so progressive delivery survives the socket; a body stream error drops the connection.

Evidence

Emulated routes carry evidence: verified routes follow a live observation dated by observedAt; unverified routes follow synthetic placeholders. Fetch-handler emulators tag every response from an unverified route with x-emulator-evidence: unverified; the email and R2 emulators' plain-JSON replies carry no header, so they record the evidence on each ledger entry instead. The Gateway route is verified (observedAt: '2026-09-30'): the emulator follows the verified live Gateway recordings, and the Yolk repository checks its response shapes against each recording. The OpenAI, Anthropic, Codex, Grok, OpenCode Go, subscription-usage, email, R2, Fortnox, Microsoft, Dropbox, Notion, Todoist, Telegram, GitHub, Google, LinkedIn search, and MCP routes are unverified, like the synthetic fixtures they follow (the LinkedIn search routes and the MCP rows are reads, so none is held in the pending list). The email write routes are connector writes: until an owner-approved live run against a practice mailbox, through a host EmailClient implementation, verifies them, the repository lists them in a time-bounded allowlist (scripts/emulator-evidence-pending.json), and the evidence check reports them as PENDING warnings until each entry's expiry date and fails again after it. The R2 R2ObjectClient.put route is held in the same list until a live run against a practice bucket, through a host R2ObjectClient implementation, verifies it. The four Fortnox write routes, the twelve Microsoft write routes, the five Dropbox write routes, the two Notion write routes, the five Todoist write routes, the Telegram sendMessage route, the six GitHub write routes, and the fifteen Google write routes are held in the same pending list until a live run against a Fortnox test company, a Microsoft practice tenant, a Dropbox practice account, a Notion practice workspace, a Todoist practice account, a practice bot, a GitHub practice repository, or a practice Google account verifies them.

On this page