Releases

Migrating from 0.7.x to 0.8.0

What changed between Routecraft 0.7 and 0.8, and how to update.

0.8.0 is the plugin release. Every feature Routecraft ships beyond the route grammar is now a plugin built on the same sockets a third party uses: direct endpoints, retries, caching, authentication and deferral included. Routes built from the DSL are unchanged. What follows is every change that can break a 0.7 project, in the order most projects meet them.

  1. Plugins are descriptors. CraftPlugin, apply(ctx) and teardown(ctx, info) are removed; a plugin is definePlugin({ id, bind, start, stop, ... }) and never receives the CraftContext. Section 1.

  2. ex.principal is ex.auth.principal. Section 2.

  3. craft.config.ts default-exports defineProject(...). A plain config is refused; see section 19. Section 3.

  4. registerDsl is removed. Route methods come from a plugin's steps. Section 4.

  5. Store keys that crossed plugins are ports. Section 5.

  6. A custom DeferralStore fences its claims. renewClaim is new, and markExpired and markDenied take the claim id. The shipped SQLite and memory stores migrate themselves. Section 6.

  7. An editor turn's body is the prompt text. An agent's own user that read ex.body.message on an ACP turn reads ex.body. Section 7.

  8. A route proxies a remote MCP server. mcpPlugin({ proxy }) and its guard are removed; a route with .from(mcp({ proxy: 'server:*' })) re-exposes a client's tools. Section 8.

  9. A mail message's flags are an array. MailMessage.flags is string[] and the routecraft.mail.flags header is readonly string[], so a mail exchange can be deferred. Section 9.

  10. The correlation id is engine-owned, and event() continues the causing journey. .header() refuses routecraft.correlation_id; .correlate() re-stamps it. Section 10.

  11. agentBrowser() is removed from @routecraft/os. Section 11.

  12. craft run logs to stderr, and RUNNER_ARGV is RUNNER_INVOCATION. Section 12.

  13. Three optional peers need a newer major. mailauth is ^8.0.6, @ai-sdk/openai-compatible is ^2.0.0 and @huggingface/transformers is ^4.3.1. Section 13.

  14. An MCP tool call's arguments ride in _snapshot. A subscriber to plugin:mcp:tool:called reads details._snapshot?.args, and asks for snapshots. Section 14.

  15. A remote MCP server is reached over https. A client on plain http to a host that is not loopback sets allowHttp: true. Section 15.

  16. Parked deferrals are re-asked once. The continuation digest changed format and covers more, so a deferral parked on 0.7 is refused with RC5048 on its first resume, and a custom WrapperStep implements wrapperKind and identityOptions(). Section 16.

  17. .log() takes a level and a message, and the logger export is gone. log(), debug() and .debug() are removed; defineProject({ logger }) sets the logger; craft.log.* reads only level, file and redact. Section 17.

  18. A resume payload is input, and deferring is declared. .defer({ schema }) is .defer({ input }), a resume request is { token, input }, and ex.deferral.result is ex.deferral.input. A step or adapter that defers declares DEFERS and is handed ctx.defer; DeferSignal, markDeferCapable, getExchangeContext and getExchangeRoute leave the entry. Section 18.

  19. The command line reads a project, and only a project. craft.config.ts default-exports defineProject({ ... }); defineConfig, a plain default-exported object and the craftConfig named export are refused with RC1120. telemetry() is the telemetry key or telemetryPlugin(). Section 19.

  20. Events carry ids, and bodies only on request. details.exchange is gone from every event: read details.exchangeId, and subscribe with { snapshots: true } to read details._snapshot. Section 20.

  21. agent() and mcp() need their plugin. An inline agent({ ... }) needs agent: {}, and a call to a remote tool by URL needs mcp: {}. A block resolver's second argument is a BlockContext. Section 21.

  22. A failed split child fails the aggregate. A child that fails with no handler deciding otherwise no longer drops out of the join silently. Section 22.

  23. A model call that was cut off before it produced anything fails. llm() and agent() fail with AI1020 where they returned an empty answer, the default output cap is lifted when reasoning is set, and llm() sends an empty user: as it is. Section 23.

  24. craft exec exits 2 for a payload the route refused. A refused payload was exit 1, and a caller a validate hook refused is exit 4. Section 24.

  25. Option and filesystem errors carry a code. An invalid mcpPlugin() or llmPlugin() option is RC5003 where it was a TypeError, and a missing or unreadable path is RC5014 or RC5015. Section 25.

Projects that write no plugin of their own typically need sections 2, 17 and 19 and nothing else, section 6 if they supply their own DeferralStore, section 7 if an agent declares its own user for editor turns, section 8 if they call or proxy an MCP client, section 9 if they read IMAP flags, section 10 if they set the correlation id themselves or group event() routes' work by it, section 11 if they import agentBrowser(), section 12 if they read craft run's stdout or RUNNER_ARGV, section 13 if they install mailauth or @ai-sdk/openai-compatible, section 14 if they subscribe to plugin:mcp:tool:called and read details.args, section 15 if an MCP client is reached over plain http, section 16 if an approval can be parked across the upgrade, section 18 if a route defers or resumes, section 20 if a subscriber reads details.exchange or details._snapshot, section 21 if a route dispatches an inline agent or calls a remote MCP tool by URL, section 22 if a route splits and aggregates, section 23 if a route calls a model, section 24 if a script reads craft exec's exit code, and section 25 if code catches a TypeError from mcpPlugin() or llmPlugin() or matches a filesystem adapter's error message. Section 26 lists what is new, for context.


1. Plugins

A plugin is a plain descriptor built with definePlugin(). It declares a dotted id, and its lifecycle functions receive a PluginContext: ports, events, its own routes and a small set of execution verbs. A plugin still shaped with apply is refused at install with RC1117 naming the change.

import { type CraftPlugin } from '@routecraft/routecraft'

export const audit: CraftPlugin = {
  apply(ctx) {
    ctx.on('route:exchange:failed', ({ details }) => {
      ctx.logger.warn({ route: details.routeId }, 'exchange failed')
    })
  },
}
import { definePlugin } from '@routecraft/routecraft'

export const audit = definePlugin({
  id: 'acme.audit',
  bind(c) {
    c.observe('route:exchange:failed', ({ details }) => {
      c.logger.warn({ route: details.routeId }, 'exchange failed')
    })
  },
})
0.70.8
CraftPluginPlugin, declared with definePlugin()
name (optional)id (required, dotted, unique per application)
apply(ctx)bind(c)
teardown(ctx, info)stop(c, info); or register releases with c.onDispose(fn)
TeardownInfoStopInfo
ctx.registerHandler(handler) and the handlers config key (#818)a hook in the error slot: hooks: { error: { id, phase: 'mutate', run } }, with mayDefer: true when it may park (section 26)
route:error-handler:* events with scope: "context" and handlerIndexscope: "slot" and hook (the pluginId/hookId), recoveryStrategy: "error-slot-hook"
ctx.on(event, handler)c.observe(event, handler)
ctx.emit(event, details)c.emit(event, details)
ctx.setStore / ctx.getStore to share state with an adapter or another plugina port: provides + c.provide(), requires + c.require() (section 5)
ctx.registerRoutes(...)c.routes.register(...), in bind only
ctx.stop() from a lifecycle functionc.execution.requestStop()
ctx.whenStarted()c.execution.whenStarted()
plugin:applying / plugin:appliedplugin:binding / plugin:bound

bind runs at the same point apply did: while the application is installed, before routes are registered. Plugins now bind in dependency order rather than strictly in list order: a plugin that requires a port binds after the plugin that provides it. The default plugins (routecraft.direct, routecraft.resilience, routecraft.cache, routecraft.principals, routecraft.auth, routecraft.credentials) install ahead of the application's own, so a lifecycle event's pluginIndex counts them.

Two new families of fault name the plugin responsible: RC1101 to RC1117 for install, resolution, ordering and compile faults, RC1118 when a plugin's bind or start hook waits on c.execution.whenStarted(), RC1119 when a replaces names another version of an installed port, and RC5068 when a validate hook refuses an exchange. See the errors reference.

2. ex.principal is ex.auth.principal

The authenticated principal is now the auth plugin's facet. In a route callable, read ex.auth.principal. Code that holds a plain Exchange (an adapter, a hook, a helper) reads principalOf(exchange). The header it derives from, routecraft.auth.principal, is unchanged.

craft()
  .id('whoami')
  .from(direct())
  .authenticate(() => ({ scheme: 'test', subject: 'ada' }))
  .transform((_body, ex) => ex.auth.principal?.subject)
  .to(noop())

ex.deferral is unchanged in route callables; outside them, read deferralOf(exchange). The principal authority (mint, brand, isAuthentic, restore, isRestored, read) is the AUTHORITY port the default routecraft.principals plugin provides. Brand and check through authorityOf(exchangeOrContext) instead of markAuthentic, isAuthentic, markRestored and isRestored, which are no longer exported; the default authority is exported as defaultAuthority for a replacement that decorates it, and the restrict-principal-minting lint rule flags its mint() and brand() too. delegate() takes the authority as its fourth argument: delegate(subject, actor, options, authorityOf(exchange)).

3. defineProject

A project declares its plugins and configuration with defineProject(), and craft.config.ts default-exports the result:

// craft.config.ts
import { defineProject } from '@routecraft/routecraft'

export default defineProject({
  plugins: [],
  deferral: {},
})

defineProject returns { craft, config, plugins }. Its craft() is typed by exactly the installed plugins, so a route can use a plugin's steps and facet. The command line reads a project and nothing else: section 19. See Plugins.

4. Route methods come from steps

registerDsl and augmenting StepBuilderBase are removed. A plugin's steps become builder methods, typed by step<In, Out>():

import { definePlugin, step } from '@routecraft/routecraft'

export const shout = definePlugin({
  id: 'acme.shout',
  steps: {
    shout: () => step<string, string>((exchange) => exchange.body.toUpperCase()),
  },
})

Build routes that use it with the project's craft(). A method generic at the call site declares its type by merging into StepMethods. See Steps.

5. Store keys that crossed plugins are ports

State one plugin hands another, or hands an adapter, is a port: a typed token declared once with port<T>("owner.capability@1"). These store keys are removed:

0.7 store key0.8 port
ADAPTER_DIRECT_STORE, ADAPTER_DIRECT_OPTIONSDIRECT; list capabilities with ctx.capabilities()
OPS_HEALTH_STATE, OPS_RESOURCESOPS
DEFERRAL_RUNTIMECONTINUATIONS
CARDDAV_CLIENT_MANAGERCARDDAV
ADAPTER_AGENT_REGISTRY, ADAPTER_FN_REGISTRY, ADAPTER_AGENT_DEFAULT_OPTIONS and the MCP keysports of @routecraft/ai

A custom adapter that read context-wide defaults from a store key reads them from a port its companion plugin provides: context.lookup(MY_DEFAULTS). See Merged Options. An adapter's own per-context state may stay in the store.

CraftConfig.plugins is a readonly array.

A plugin that is not repeatable is installed once per application. A second llmPlugin(), embeddingPlugin() or shellPlugin() used to replace the first silently; it is now RC1101. Merge the options into one install.

The internal RouteDefinition fields preParseFilters, postParseFilters and postFromFilters are gone: a route definition carries its chain as configuration, and the chain is built when the route compiles.

6. A custom DeferralStore fences its claims

A store supplied through deferral: { store } implements a claim with an identity, so a claimant that outlived its lease cannot renew or finalize the claim that replaced it. The shipped backends migrate themselves (the SQLite file moves to schema version 4 on open); a store of your own changes five members:

0.70.8
Deferral.claimedAt?: DateDeferral.claim?: DeferralClaim, which is { id, at, renewedAt }: id is a DeferralClaimId minted by the store (randomUUID() as DeferralClaimId) and distinct for every claim taken on a record, at never moves, and renewedAt is what releaseClaims compares
claimExpiry(id, at): DeferralCasResultclaimExpiry(id, at): DeferralClaimResult, which carries the claim the caller now holds when it won; claimResultOf(result) builds it from the compare-and-swap result
(absent)Deferral.format: number, the record format the kernel wrote: persist it as given and return it unchanged. A record your store wrote before it kept one reads back as 0
(absent)renewClaim(id, claimId, at): moves renewedAt to at, and wins only while claimId names the live claim on a waiting record
markExpired(id) and markDenied(id, reason?)markExpired(id, claimId) and markDenied(id, claimId, reason?): settle only while claimId names the live claim, so a stale holder loses

The fenced methods compare the claim's identity and nothing else. Compare renewedAt too and the holder's own second renewal loses, because its copy of the claim went stale at the first. The exported claimedBy(record, claimId) predicate is that compare; resumable and claimed read claim in place of claimedAt. The kernel renews a claim three times per expiryLease while a re-ask runs, so a slow .error() handler no longer needs a lease longer than itself.

A configured store missing any of these members is refused when the application starts, with RC5066 naming the first one, rather than starting clean and losing its first delivery claim to a renewal that throws.

Do not run 0.7 and 0.8 against one SQLite file, including for the length of a rolling deploy: 0.7 does not honour the fence, so it can settle a delivery a 0.8 process is still making. Stop every 0.7 process before the first 0.8 one opens the file. A claim a 0.7 process writes after the migration anyway carries no identity; 0.8 reads it back as claimed under one no holder can present, and the lease releases it from its claim time, so the record is redelivered rather than stranded.

7. An editor turn's body is the prompt text

An ACP turn used to reach the agent's route as a { session, message } body, so an agent with no user of its own, as every agent loaded from agents/*.md is, handed the model that envelope as JSON. The body is now the prompt text. An agent that declared its own user for editor turns reads the text directly:

0.70.8
user: (ex) => ex.body.messageuser: (ex) => ex.body, or no user at all
ex.body.session(ex.headers[AGENT_SURFACE_HEADER] as AgentSurfaceRef | undefined)?.session, the editor surface every turn carries, both exported from @routecraft/ai

A conversation recorded under 0.7 keeps its earlier prompts as they were stored, so loading one in the editor replays those as the envelope; turns taken under 0.8 replay as text.

8. A route proxies a remote MCP server

mcpPlugin({ proxy }) and its per-entry guard are gone. A client's tools are re-exposed by a route, so the chain and the steps every route has are the policy on them, for an external client and for your own agent alike:

0.70.8
mcpPlugin({ clients, proxy: ['docs:*'] })craft().id('docs').from(mcp({ proxy: 'docs:*' })).to(mcp('docs:*'))
proxy: [{ ref: 'docs:get_document', name: 'fetch_doc', guard }]craft().id('fetch').authorize(...).from(mcp({ proxy: 'docs:get_document', name: 'fetch_doc' })).to(mcp('docs:get_document')), with the guard's check as .authorize() or a .process() that throws
A proxied tool exposed under the remote's name (get_document)Exposed as <client>_<tool> (docs_get_document); prefix: '' on a star route keeps the bare names, name on an exact route renames one
An agent's MCP(docs:get_document) reaches the client directlyIt runs through the route that proxies the tool when one exists. The call carries the agent's principal, so the route's .authorize() judges the agent too, unless the route replaces the identity with .authenticate(). A tool that a star route excludes, or whose proxy route is not live, is not offered to the agent. A tool that no proxy route covers or declares reaches the client directly, as before
McpProxyToolConfigMcpProxyRegistration, what the source registers with the MCP service
One HTTP endpoint, /mcp, with every tool/mcp is unchanged; /mcp/<client> serves one client's proxied tools under their remote names, and /mcp/<server name> the application's own tools (mounts). Over HTTP a client id equal to the server name, or a name or client id that is not one path segment, now fails the bind with RC5003

The mcp() client changed with it. tool is required: the exchange.body.tool fallback is gone, and '*' forwards the tool named on McpHeadersKeys.TOOL when McpHeadersKeys.CLIENT names the same client, which only a proxy route over that client sets. A result the remote flagged isError now throws AI2003 instead of arriving as content, on the enricher and on an agent's MCP(...) tool alike; the remote's text is read with remoteErrorTextOf(error) and is not in the message. The MCP caller of a proxy route still receives the text, since they addressed the remote. A call that fails on the wire is no longer RC5003: a timeout, HTTP 408 and HTTP 504 are RC5011, a refused or dropped connection and any other HTTP 5xx are RC5010, HTTP 429 is RC5013, and 401, 403 and 404 are RC5012, RC5015 and RC5014. The first three are retryable, so a .retry() around mcp() now re-attempts them with the default retryOn and a .circuitBreaker() counts them; drop a retryOn: () => true written to get that. An .error() handler that matched RC5003 for an unreachable server matches the new codes instead. A server that is not registered is still RC5003, and so are a JSON-RPC error from the remote, any other HTTP 4xx and a result the client itself refused: the default retryOn retries none of them, so a tool the remote already ran is not run again unless a custom retryOn says so. A remote structuredContent is the body when present, where it was discarded before. The call's metadata (toolName, transport, serverId or url) is no longer written into an object result; getMetadata() still reads it. auth beside a serverId, which was silently ignored in favour of the client's registered auth, is refused with RC5003 when mcp() is called: set the credential on the client in mcpPlugin({ clients }), or call an inline mcp({ url, tool, auth }).

9. A mail message's flags are an array

MailMessage.flags was a Set<string> and the routecraft.mail.flags header a ReadonlySet<string>, which the deferral store cannot persist, so a route sourced from mail() could never defer (RC5042). They are now string[] and readonly string[], matching the flags: string | string[] the mail operations take.

0.70.8
message.flags.has('\\Seen')message.flags.includes('\\Seen')
ex.headers[MailHeaders.FLAGS]?.has('\\Flagged')ex.headers[MailHeaders.FLAGS]?.includes('\\Flagged')

An attachment's content stays a Buffer. The deferral store persists it as base64 and hands it back as a Buffer on resume, so a message with attachments defers too; a route that holds large attachments for days and does not need them afterwards drops body.attachments before .defer().

10. The correlation id is engine-owned, and event() continues the causing journey

Every exchange now records the exchange that caused it (routecraft.causation_id) beside the journey it belongs to (routecraft.correlation_id), and the engine keeps the two in step with the logger, the lifecycle events and the event() guard. That changes two things a 0.7 route could depend on.

0.70.8
.header(HeadersKeys.CORRELATION_ID, (ex) => upstreamId(ex)).correlate((ex) => ({ correlationId: upstreamId(ex) })); .header() on routecraft.correlation_id or routecraft.causation_id fails the build with RC5003, and a plugin's mutate hook writing either is refused with RC1115
A source or CraftClient.sendDirect passing any string as the correlation idThe same, but the id must be 1 to 128 characters from [A-Za-z0-9._~:-], the alphabet W3C tracestate allows; another value is refused with RC5003. Hash a longer key first
Each event() delivery starts a new chain under a fresh correlation idA delivery carries the correlation id of the exchange that caused the event, and names it as the cause. A consumer that grouped work by correlation id and counted each event() route's work as its own journey now sees it inside the causing journey; group by routeId as well, or start a new journey with .correlate()
Each http(), ops dispatch or MCP request starts a new correlation idAn authenticated caller's traceparent and tracestate set it (the rc member's correlation id, else the trace id as a UUID), so separate requests from one upstream trace share it. Set traceContext: "never" on httpPlugin, the mount, opsPlugin or mcpPlugin to keep a fresh id per request
splitChild(body, { [HeadersKeys.CORRELATION_ID]: id }) sets a child's correlation idThe envelope's correlation and causation ids are ignored, as its routecraft.id already was: a child keeps the parent's journey and names the parent as its cause

Outbound calls changed too: the http() client, the remotes channel and the MCP client now send the exchange's W3C trace context (traceparent, tracestate; in _meta for MCP) by default. A server that does not take part ignores the headers. An upstream that rejects unknown headers takes traceContext: false on the client. An application that must not send journey ids to third parties sets traceContext: { outbound: false } once and opts trusted calls back in.

11. agentBrowser() is removed

@routecraft/os no longer exports agentBrowser() and no longer lists agent-browser as a peer. The adapter wrapped the JavaScript library of agent-browser 0.17, which that project dropped in 0.20 for a Rust binary, so it was pinned to an unmaintained release whose dependency chain carried high-severity advisories with no fixed version. shell() is unchanged.

A route that drove a browser calls a browser MCP server's tools instead. Register the server under mcp.clients (for example as browser) and call its tools as mcp('browser:navigate'), as Call an MCP shows; the browser session lives in that server, not in the route. @routecraft/os no longer needs agent-browser, so drop it from the project's dependencies unless something else in the project runs it.

12. craft run logs to stderr, and RUNNER_ARGV is RUNNER_INVOCATION

craft run prints a route's result on stdout through the new argv() source, so its logs go to stderr unless LOG_STREAM or CRAFT_LOG_STREAM names a stream, or a log file is set. A script that captured craft run's logs from stdout reads stderr, or sets LOG_STREAM=stdout. A stdio MCP server run with craft run no longer needs --log-file to keep its protocol stream clean.

The RUNNER_ARGV store key is removed. No adapter read it; a runner of your own sets RUNNER_INVOCATION to a RunnerInvocation (the id of the route to run, the arguments, a stdin reader and a settle callback) instead, and craft start sets nothing, which is what keeps argv() inert there.

13. Three optional peers need a newer major

Each range dropped majors whose releases carry a high-severity advisory in a pinned dependency, so the vulnerable versions no longer satisfy the peer:

  • mailauth, used by the mail adapter's verify: 'strict', is ^8.0.6. Run bun add mailauth@^8.0.6.
  • @ai-sdk/openai-compatible, used by LM Studio and other OpenAI-compatible providers, is ^2.0.0, the line that matches ai 6. Run bun add @ai-sdk/openai-compatible@^2.
  • @huggingface/transformers, used by Hugging Face embeddings, is ^4.3.1. Run bun add @huggingface/transformers@^4.3.1, then check that sharp resolves to 0.35.5 or later (bun update sharp if the lockfile holds 0.35.4).

None changes how the adapter or the provider behaves.

Four peers keep their major and need a newer release of it: @modelcontextprotocol/client and @modelcontextprotocol/server are ^2.3.0, @modelcontextprotocol/node is ^2.1.1, @agentclientprotocol/sdk is ^1.7.0 and imapflow is ^1.0.77. Three take a new major beside the old one, so nothing changes for a project that stays: croner 10 or 11, imapflow 1 or 2, and execa 9 or 10.

14. An MCP tool call's arguments ride in _snapshot

plugin:mcp:tool:called carried the call's arguments as args, a plain field of the event details. The telemetry plugin writes event details to its store and holds back only the _snapshot envelope, so a project that had left captureSnapshots off was storing every tool call's arguments regardless. The arguments are now _snapshot: { args }, the envelope an agent tool's input already uses: a subscription receives them only when made with { snapshots: true } (section 20), and the telemetry store keeps them only when captureSnapshots is on.

// Before
ctx.on('plugin:mcp:tool:called', ({ details }) => record(details.tool, details.args))

// After
ctx.on(
  'plugin:mcp:tool:called',
  ({ details }) => record(details.tool, details._snapshot?.args),
  { snapshots: true },
)

The ops event tail omits _snapshot payloads, so it no longer shows a call's arguments either. The debug log line that printed the same arguments (MCP tool call exchange body) is removed. Rows the telemetry store wrote before the upgrade keep the arguments they were written with; prune them if they should not be retained.

15. A remote MCP server is reached over https

The client's credential and every call's arguments travel in the request to a remote MCP server, so the URL is https unless the request never leaves the machine.

0.70.8
A client or inline url over plain http to any hosthttps, or http to a loopback host (localhost, an address in 127.0.0.0/8, [::1]). Any other host over http fails with RC5003, a registered client when the plugin binds and an inline url on its first call, until the client or the call sets allowHttp: true

16. Parked deferrals are re-asked once, and a custom wrapper states its identity

The digest that refuses a resume after the route changed now covers what it used to miss: an edit inside a .choice() branch or a .multicast() path, a .dispatch() strategy, a wrapper such as .retry() and its options, a header's literal value, a schema in the tail. It no longer reads Routecraft's own source, so later upgrades stop moving it.

  • Every deferral parked on 0.7 is refused once. Its stored digest is in the old format and cannot be compared, so the first resume raises RC5048 into the deferred route's .error(), the path that already re-asks after an edit. A route with no handler there fails the resume: drain approvals before the upgrade, or add the handler. Default .cache() keys change the same way, which costs one cold cache.
  • A custom WrapperStep implements two members in place of describeOptions(): protected readonly wrapperKind, a stable dotted name, and protected identityOptions(), returning { options } (and version when its behaviour changes).
  • NestedSteps.predicate is selector, for a raw step that reports its own branches.
  • A route that defers or caches may warn at start with RC5071 when a step the digest covers holds a value it cannot see. See step identity.

17. Logging

A log line is now a step in the flow, and the logger is something a project is given rather than something the package builds when it is imported.

0.70.8
.log(), .tap(log()), .to(log()).log('info', 'Message', (ex) => ({ ... }))
.log((ex) => value), .tap(log((ex) => value)).log('info', 'Message', (ex) => ({ value }))
.debug(), .tap(debug()), log(fn, { level: 'debug' }).log('debug', 'Message', ...)
log(fn, { level: 'error' })no step equivalent: a failure is logged once, at the boundary. Add context in .error()
import { logger } from '@routecraft/routecraft'ex.logger, context.logger or a plugin's c.logger; defaultLogger() where there is no context
LogOptions, LogDestinationAdapterLogger
a pino options object in craft.log.jslevel, file and redact only; anything else through defineProject({ logger })
  • A .log() line is ordered and attributed. It used to run as a detached tap on a copy of the exchange with an id of its own. It now runs in the flow on the exchange itself, so it carries that exchange's exchangeId and lands where it is written. The old default line, LogAdapter output with the whole exchange, is gone: a line says what its message says and carries the fields its bindings return.
  • A line cannot fail or change the exchange. The level and bindings functions see the exchange read-only, and a throw from either becomes one warn, Log line could not be built.
  • The logger is built on first use. Importing the package no longer opens LOG_FILE or reads craft.log.*; the first defaultLogger() call does, and a context built with logger never makes that call.
  • Credential headers are redacted by default. A line that logs headers shows [Redacted] for authorization, cookie, set-cookie and proxy-authorization, under createLogger() and the default logger alike.
  • The default logger writes synchronously, so a line is not lost to a process that exits right after it.
  • @routecraft/testing no longer patches a global. testContext() gives each context its own spy logger, so contexts alive at once never see each other's lines. t.logger and t.contextLogger read as before; a test that passes its own logger in .with({ logger }) gets that one and leaves the spies empty.

See .log() and logging configuration.

18. The defer contract

One word names a resume payload everywhere, and only the kernel parks or revives an exchange. A route that uses the shipped .defer() and .resume() renames three things:

0.70.8
.defer({ schema }), and schema on .error(handler, { ... }).defer({ input }), .error(handler, { input })
A resume mapper returning { token, result }, and an unmapped .resume() body of { token, result }{ token, input }
ex.deferral.resultex.deferral.input
schema on the Deferred acknowledgmentinput

A schema left on .defer(), .error(), ctx.defer() or DeferError is refused with RC5003, and on an error hook with RC1115, rather than dropped: dropped, the site would park with no contract and the resume door would validate nothing.

A caller that posts to a resume door sends input too, so update whatever builds the approval link or form. The header routecraft.deferral.result is routecraft.deferral.input. A .resume() mapper, like a plugin step's ctx.resume, no longer names resumedBy: the kernel records the principal the route verified, and a request that names one is refused (RC5003).

A step that defers declares it. Throwing DeferSignal, returning a step result with kind: 'defer' built by hand, and markDeferCapable are removed. The step declares defers (or [DEFERS]() on a raw step or an adapter) and calls the handle the kernel gives it:

0.70.8
markDeferCapable(adapter)[DEFERS]: () => ({ revival: 'this-step' }) on the adapter
throw new DeferSignal({ ... })return ctx.defer({ ttl, meta, stepState, input, notify })
peekResumeStepState(exchange)ctx.defer.revived, which is { deferralId, stepState, input } on a revival
deferAside(...)ctx.defer.aside({ stepState, announce })
reviveDeferral(context, request) from a doorctx.resume({ token, input }) on a step that declares resumes
reviveDeferral(...) outside a requestc.continuations in a plugin (resume, sweep, mintToken, get, list, eventScope), which hands back decoded records

A step result that names a deferral the kernel did not issue is refused with RC5032. See steps that defer or resume. A plugin written against an 0.8 canary moves c.execution.resume() and c.execution.sweep() to c.continuations, and reads records through it in place of deferralScope, decodePersistable and decodeOutcome.

An adapter does not read the context off the exchange. getExchangeContext and getExchangeRoute leave the entry. What an adapter used them for has a narrower replacement:

0.70.8
getExchangeContext(ex).lookup(PORT)lookupOf(exchange, PORT)
getExchangeContext(ex).getStore(KEY) for a plugin's own stateapplicationState<T>(): state.set(c.application, value) in bind, state.of(exchange) in the adapter (merged options)
getExchangeContext(ex).loggerexchange.logger
getExchangeContext(ex) to read a parked record or verify a tokencontinuationsOf(exchange)
getExchangeContext(ex) to decide whether to send trace headerssendsTraceContextFor(exchange, ...settings)
getExchangeRoute(ex)?.trackTask(p) from a pluginc.execution.trackTask(p, { route })
getExchangeRoute(ex)?.signal and .definition.id in an adaptercontext.route.signal and context.route.id on the step context

A custom DeferralStore stores what it is given. The kernel encodes stepState, meta and the settled outcome before the store sees them and decodes them after, so a store persists those fields as the JSON they arrive as and never encodes or decodes them itself. Run the shared suite against it:

import { afterEach, describe, expect, test } from 'bun:test'
import { deferralStoreConformance } from '@routecraft/testing'

deferralStoreConformance('my store', () => openMyStore(), {
  describe,
  test,
  afterEach,
  expect,
})

The rest:

  • The CONTINUATIONS port is routecraft.continuations@2. A plugin that provides it under the @1 name declares the port again from the exported token. Its signer is typed ResumeTokenSigning.
  • A parked exchange finds its defer site by what follows it. A step added or removed ahead of a .defer() no longer refuses the exchanges parked there. Two sites of one kind followed by identical steps (a .defer() in each of two sibling branches, say) that both moved are refused with RC5048 as ambiguous. A .defer() and a step that defers itself are never confused: the digest carries which of the two parked.
  • A record carries its format, and a resume reads only its own. Every deferral is written with an integer format. A record in any other format, older or newer, is refused with RC5048 and re-asked, so a rolled-back deployment does not resume what a newer release parked. A record parked by a 0.8 canary is refused once for this reason.
  • A deferral parks the exchange it was raised for, once. A step that keeps the signal ctx.defer() rejected with and throws it on another exchange, or a second time, is RC5032.
  • restrict-continuation-minting is an error in both lint presets. It flags continuations.mintToken(), resume() and rewriteStepState(); see linting.
  • Six more names leave the entry, none of which a route needs: ResolvedSampleOptions, ResolvedDedupeOptions, ResolvedThrottleOptions, ResolvedCircuitBreakerOptions, RouteEnablement and hashExchangeBody.
  • The names only @routecraft/* packages used leave the entry too. They sit on @routecraft/routecraft/internal, which carries no compatibility promise and is unsupported outside the @routecraft scope: the adapter-override hooks behind @routecraft/testing (RC_ADAPTER_OVERRIDES, SOURCE_FIXTURE, isSourceFixture and the types AdapterOverride, AdapterSendCall, AdapterSourceCall, SendOverrideHandler, SourceOverrideBehavior, SourceFixture, SourceMessage), the runtime-version helpers (RuntimeVersion, parseRuntimeVersion, compareRuntimeVersion, isDevelopmentRuntime) and rejectStaleOptions. Override an adapter through @routecraft/testing; nothing else here has a public replacement because nothing outside the framework had a use for it.

19. The command line reads a project, and only a project

craft start, craft exec, craft connect and every other command that loads craft.config.ts read its default export, and it must be a defineProject(...). Anything else is refused with RC1120, and the message says how to rewrite the shape it found. defineConfig is removed; defineProject takes the same keys.

0.70.8
export const craftConfig = defineConfig({ ... })export default defineProject({ ... })
export const craftConfig: CraftConfig = { ... }export default defineProject({ ... })
export default { ... }export default defineProject({ ... })
export const craftConfig = ... in a file run with craft runexport const project = defineProject({ ... }) in that file, or nothing: craft run finds the project's craft.config
export { craftConfig } from '../craft.config' in a capabilitydelete the line
plugins: [telemetry({ ... })]telemetry: { ... }, or plugins: [telemetryPlugin({ ... })]

defineProject resolves the plugin list where it is called, so a config key with options its plugin refuses fails at the declaration instead of at start. A misspelled key is a compile error at the top level and inside each config block. Deeper than that it is not: defineConfig checked every depth, so a typo inside one named server or one mail account compiled as an error in 0.7 and does not in 0.8.

craft run <file> no longer takes its configuration from the file's craftConfig export. It picks the project its routes run in, first match wins:

  1. --config <path>: the project that file default-exports.
  2. The file's own export const project = defineProject({ ... }).
  3. The craft.config beside the nearest package.json at or above the file, when it installs every plugin the routes were built with. One that does not, or that fails to load while the routes carry a project of their own, is ignored with a warning saying why; --no-config skips this step.
  4. The project the routes were built with: the one whose craft() started them.
  5. The defaults, for routes built with the root craft().

Code that builds a context itself is unchanged: new CraftContext(config), ContextBuilder.with(config) and testContext().with(config) take a plain CraftConfig, and project.config is one.

The telemetry plugin's internals left the entry with the factory's old name: SqliteConnection, the SQLite span processor and event writer, ATTR and SPAN_KIND are no longer exported. Configure the sink through the telemetry key.

20. Events carry ids, and bodies only on request

Every event that named an exchange handed each subscriber the exchange itself, headers included, so a subscriber that only counted failures also held the caller's Authorization header. No event carries an exchange now.

0.70.8
details.exchange on route:exchange:completed, :failed, :droppeddetails._snapshot?.exchange, for a subscription made with { snapshots: true }
details.exchange on context:error, route:error, route:error:caught, route:step:errordetails.exchangeId and details.correlationId; the copy is details._snapshot?.exchange under the same option
details.exchange on route:stopping, route:stoppedremoved; it was never set
details._snapshot on the agent tool and block events and on plugin:mcp:tool:called, always presentpresent only for a subscription made with { snapshots: true }, so the type is optional
principalOf(details.exchange)details.principal on the lifecycle events (started, completed, failed, dropped, deferred): { subject, issuer?, clientId?, actorSubject? }
// Before
ctx.on('route:exchange:failed', ({ details }) => report(details.exchange?.body, details.error))

// After
ctx.on(
  'route:exchange:failed',
  ({ details }) => report(details._snapshot?.exchange.body, details.error),
  { snapshots: true },
)

The copy is frozen and leaves out Authorization, Cookie, Set-Cookie, Proxy-Authorization, X-Api-Key and every header a plugin lists in secretHeaders, at every depth of a header, so the wire headers the HTTP door keeps under routecraft.http.rawHeaders lose theirs too. The principal in it is the reference, without claims or scopes. A subscriber that reads only ids, durations and errors changes nothing. A handler that passed details.exchange to isDropped() or another exchange helper has no exchange to pass: the event's name already says how the exchange ended. See snapshots.

Two more places stop holding a credential:

  • An API key the HTTP mount verified is not on the exchange. With auth: apiKey(...), the key is left out of routecraft.http.rawHeaders, or out of routecraft.http.query and routecraft.http.url for in: 'query'. A route that read the key to work out who called returns that from apiKey({ verify }) as the principal instead.
  • A parked exchange is stored without its credential headers. The same names the snapshot leaves out are left out of the record a .defer() writes, at every depth, so a bearer token or a session cookie does not sit in the deferral store for as long as the approval takes. Steps after a resume run as the principal the route verified and do not see those headers.

A telemetry store written by 0.7 with captureSnapshots on holds the headers as they were then, credentials included, in exchange_snapshots and in the details of its error events. Delete the store, or those rows, if it should not keep them. From 0.8 the exchange is stored once, in exchange_snapshots, and no event row repeats it.

21. agent() and mcp() need their plugin

In 0.7 an inline agent({ ... }) and an mcp({ url, tool }) call ran in an application that installed neither plugin, on state they created on first use. Both steps now read the application through their plugin, and refuse with RC5003 when it is absent. A project that registers agents, serves tools or names MCP clients already has the key and changes nothing.

0.70.8
.to(agent({ model, system })) with no agent keyadd agent: {} to defineProject({ ... }), or agentPlugin() to the plugins of a context built by hand
.to(mcp({ url, tool })) with no mcp keyadd mcp: {}, or mcpPlugin(). It starts no server until transport is set or a route is exposed with .from(mcp())
agent({ session }) with no sessions plugin, on a session store resolved at the first turnthe agent plugin brings the sessions plugin, which resolves the same store when the application binds
a block resolver (exchange, context) => ... reading the CraftContextcontext is a BlockContext: context.lookup(PORT) and context.logger
mcp: { clients } with no tool route starting a stdio serverno server starts; set transport: 'stdio' to keep one
export default defineProject({
  llm: { providers: { anthropic: { apiKey: process.env.ANTHROPIC_API_KEY! } } },
  agent: {},
})

A test that dispatches an inline agent adds the plugin the same way: testContext().with({ plugins: [agentPlugin(), llmPlugin({ ... })] }).

An adapter of your own that read the route off the exchange for its id or its stop signal reads them from the step context it is handed: context.route.id and context.route.signal, which fires when the route abandons its in-flight work.

22. A failed split child fails the aggregate

In 0.7 a child of .split() that failed was left out and .aggregate() joined whoever was left, so a route that priced five items and lost two returned three with nothing to say so. The aggregate now does not run when a child failed and no handler decided what to do about it: the siblings finish their own steps, then the parent exchange fails with RC5001, the first child's error as its cause.

0.70.8
a child fails, nothing handles it: the aggregate joins the restthe aggregate does not run and the parent fails. route:exchange:failed lists the failed children in failedChildren
a child fails and the route's .error() handler recovers or drops itunchanged: the handler decided for that child, and the aggregate joins the rest
a child is dropped by .filter()unchanged: it is left out and the aggregate joins the rest
the route's .error() handler saw only child failuresit is also asked about the parent's failure, which failedChildrenOf(error) tells apart

To keep the 0.7 result, say so on the route: drop a failed child, and the aggregate joins the rest.

import { craft, direct, recovery } from '@routecraft/routecraft'

export default craft()
  .id('price-order')
  .error(() => recovery.drop('price check failed'))
  .from(direct())
  .split()
  .to(direct('price-check'))
  .aggregate()

A handler that should answer for the whole order instead reads the parent's failure with failedChildrenOf, shown under Children that do not arrive.

23. A model call cut off with nothing fails

In 0.7 a call that ran into its output cap before the model wrote anything came back as a success with an empty text, and the route carried the empty string on. The usual cause was the framework's own default: maxTokens was 1024 on every call, and a model asked to think spends that on thinking. Both ends changed.

0.70.8
llm() or agent() ends on length or content-filter with no text, no structured output and no tool call in its last step: an empty resultthe step fails with AI1020. It is not retryable: the same call hits the same cap
a call cut off part way through its answerunchanged: the partial text is returned. finishReason says so, and an agent result now carries it too
maxTokens defaults to 1024 on every callit defaults to 1024 only when reasoning is unset or 'none'. A call that sets reasoning sends no cap, and the provider's own maximum applies
llm({ user }) that resolved to an empty string or an empty parts array sent the exchange bodyit sends the empty prompt. The body stands in only when user is absent, which is what agent() already did for a string

A model that thinks without being asked to still runs under the 1024 default, since the framework cannot tell. Set maxTokens on that call, or set reasoning, when it fails with AI1020. A route that preferred the empty answer says so:

import {
  craft,
  direct,
  isRoutecraftError,
  recovery,
} from '@routecraft/routecraft'
import { llm } from '@routecraft/ai'

export default craft()
  .id('summarise')
  .error((error) =>
    isRoutecraftError(error) && error.rc === 'AI1020'
      ? { text: '' }
      : recovery.rethrow(),
  )
  .from(direct())
  .enrich(llm('anthropic:claude-opus-4-7', { maxTokens: 4096 }))

With the cap lifted, a provider that has no maximum of its own (a local ollama or lmstudio model) is bounded only by the model's context, so set maxTokens there when the output must be bounded. The output cap has the detail.

24. craft exec exits 2 for a refused payload

craft exec reported a payload the route refused as exit 1, the code for a route that failed, while craft run reported the same refusal as 2. The two commands now agree, so a script can tell "fix the command line" from "the route failed".

The dispatched route0.70.8
refused the payload at its own .input() schema, or a validate hook found it invalid12
had a validate hook or a .validate() step refuse the caller as a conflict24
had a validate hook or a .validate() step refuse the caller as gone, rate limited or unavailable14
failed, including on a refusal raised by a route it calls1unchanged

A script that treated exit 1 as covering a rejected payload or a refused caller handles 2 and 4 as well. The exit code table has every code.

Nothing else in this change needs a migration: auth:rejected gains two optional fields, code and claim, that say why a token was refused. Events lists their values.

25. Option and filesystem errors carry a code

Two kinds of failure were thrown as bare errors, so the only way to recognise one was its English sentence.

What fails0.70.8
mcpPlugin() or llmPlugin() is given an invalid optionTypeError, in three places a plain ErrorRC5003
file(), jsonl(), csv() or directory() is pointed at a path that does not exist, or writes below a directory that does not existplain ErrorRC5014, with the errno error as cause
the same adapters may not read, write or delete the pathplain ErrorRC5015, with the errno error as cause

The messages are the ones 0.7 wrote, so log lines do not change. The thrown object does:

// Before
try {
  mcpPlugin(options)
} catch (err) {
  if (err instanceof TypeError) report(err.message)
}

// After
try {
  mcpPlugin(options)
} catch (err) {
  if (isRoutecraftError(err) && err.rc === 'RC5003') report(err.message)
}

A route that treats a missing file as empty tests the code where it matched the sentence:

// Before
.error((error) => {
  if (/file not found/.test((error as Error).message)) return []
  throw error
})

// After
.error((error) => {
  if (isRoutecraftError(error) && error.rc === 'RC5014') return []
  throw error
})

A path below a regular file, which the system reports as ENOTDIR, counts as missing. Any other read failure is still a plain error, and now carries the errno error as cause.

26. What is new in 0.8.0

  • Ports. Plugins share anything through port<T>(), with requires, optional, provides and replaces.

  • Replaceable positions. .authorize() and the resilience operations are unchanged on the builder, and the default plugins fill them through ENFORCEMENT and RESILIENCE. A plugin may replace one, and the replacement fills the same methods placed after .from() too. Both ports are provisional in 0.8: they are due to be reshaped, so a replacement pins the minor it was written against.

  • A replaceable cache store. .cache() keeps its policy and reads its entries from the CACHE_STORE port, a CacheProvider. A plugin that provides and replaces it moves every cache site that names no provider of its own, and cacheProviderConformance from @routecraft/testing is the suite its store runs against itself.

  • Port versions are contracts. The value read under name@1 keeps its shape while that name exists; a change ships as name@2.

  • isTransient(error). The rule .retry() and .circuitBreaker() apply by default, exported so a custom retryOn extends it. route:retry:stopped carries reason (exhausted, not-retryable or aborted) and the error's code, so a retry that never re-attempted is visible.

  • Hooks. Plugins add hooks to the slots of the chain (beforeAuth, afterAuth, admitted, perAttempt, exit, error) in the observe, mutate and validate phases. Every hook declares an id; hooks.order and hooks.disable in config address it as pluginId/id and settle conflicts. A validate hook's refuse(reason, { kind }) is answered at the door the caller came through with the status its kind maps to.

  • The error slot. A plugin hook can recover, drop or park (recovery.defer()) a failure the route's own .error() did not settle.

  • Error-path parks are validated. .error(handler, { input }) and an error hook's input declare what a resume payload must satisfy when the handler parks; the resume door validates it (RC5049) and refuses a resume whose schema changed (RC5048).

  • Facets. A plugin's facet is readable as ex.<namespace>.

  • Journeys. routecraft.causation_id on every exchange a hand-off produces (a chain root has none), causationId on every route:exchange:* event of such an exchange and in the logger's bindings, W3C trace context across the http(), ops and MCP doors (adopted from an authenticated caller by default, traceContext on each door and client), .correlate() for a channel that carries none, and telemetry spans parented to the exchange that caused them. See journeys.

  • Exchange source. sourceOf(exchange) (the engine-owned routecraft.source header) names the source adapter that admitted an exchange, route:exchange:started carries it as source, and a plugin hook takes sources: [...] to run only for those sources: a beforeAuth hook can supply a principal for argv() without opening the route's direct() or mcp() door. See Hooks.

  • argv(). craft run <file> --field=value (or JSON on stdin) reaches the route as one exchange, with the craft exec flag grammar and exit codes, and --help from the .input() schema. A file with several argv() routes takes the route's id first. The exchange carries no principal. See argv.

  • A record of every call to a remote MCP tool. plugin:mcp:remote:requested and plugin:mcp:remote:settled name the client, the tool, the caller and the outcome for a call from the door, from an agent and from a route's hop, and say whether a proxy route judged it. mcpPlugin also logs at start whether each client is proxied. See remote call events.

  • Pinned MCP tools. pins on an MCP client holds it to the tool definitions in mcp.lock, which craft mcp pin writes and a commit approves. A new or changed tool is withheld or served as the pins say, a withheld tool is unknown to an MCP caller and refused to a hop or an agent (AI2004), and each tool carries a class on routecraft.mcp.class: the approved one when the tool is served on its approved definition, destructive otherwise. A star proxy's exclude also takes a function of the tool. See pinning a server's tools.

  • MCP clients behind a login. auth: connect({ clientId, scopes }) on a named MCP client, craft connect to log in from a machine with a browser, and a credential store that refreshes and writes rotated tokens back with compare-and-swap writes. A server imports a sealed seed from craft connect --export. See servers behind a login.

  • Plugin tooling. A plugin's descriptor declares tooling: { commands, logins }: craft <namespace> <command> runs a command, and craft connect runs a login, both read from the project's plugin list without starting it. A command is handed the credentials its own plugin's logins declare and no others. craft mcp pin and the MCP logins are declared this way. See tooling.

  • craft run --config <path> and --no-config. A route file run on its own runs in the project it was built with, or in the craft.config that extends it.

The Plugins guide explains each part with a worked example, and the Plugins reference lists every field.

Previous
Changelog