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.
-
Plugins are descriptors.
CraftPlugin,apply(ctx)andteardown(ctx, info)are removed; a plugin isdefinePlugin({ id, bind, start, stop, ... })and never receives theCraftContext. Section 1. -
ex.principalisex.auth.principal. Section 2. -
craft.config.tsdefault-exportsdefineProject(...). A plain config is refused; see section 19. Section 3. -
registerDslis removed. Route methods come from a plugin'ssteps. Section 4. -
Store keys that crossed plugins are ports. Section 5.
-
A custom
DeferralStorefences its claims.renewClaimis new, andmarkExpiredandmarkDeniedtake the claim id. The shipped SQLite and memory stores migrate themselves. Section 6. -
An editor turn's body is the prompt text. An agent's own
userthat readex.body.messageon an ACP turn readsex.body. Section 7. -
A route proxies a remote MCP server.
mcpPlugin({ proxy })and itsguardare removed; a route with.from(mcp({ proxy: 'server:*' }))re-exposes a client's tools. Section 8. -
A mail message's flags are an array.
MailMessage.flagsisstring[]and theroutecraft.mail.flagsheader isreadonly string[], so a mail exchange can be deferred. Section 9. -
The correlation id is engine-owned, and
event()continues the causing journey..header()refusesroutecraft.correlation_id;.correlate()re-stamps it. Section 10. -
agentBrowser()is removed from@routecraft/os. Section 11. -
craft runlogs to stderr, andRUNNER_ARGVisRUNNER_INVOCATION. Section 12. -
Three optional peers need a newer major.
mailauthis^8.0.6,@ai-sdk/openai-compatibleis^2.0.0and@huggingface/transformersis^4.3.1. Section 13. -
An MCP tool call's arguments ride in
_snapshot. A subscriber toplugin:mcp:tool:calledreadsdetails._snapshot?.args, and asks for snapshots. Section 14. -
A remote MCP server is reached over
https. A client on plainhttpto a host that is not loopback setsallowHttp: true. Section 15. -
Parked deferrals are re-asked once. The continuation digest changed format and covers more, so a deferral parked on 0.7 is refused with
RC5048on its first resume, and a customWrapperStepimplementswrapperKindandidentityOptions(). Section 16. -
.log()takes a level and a message, and theloggerexport is gone.log(),debug()and.debug()are removed;defineProject({ logger })sets the logger;craft.log.*reads onlylevel,fileandredact. Section 17. -
A resume payload is
input, and deferring is declared..defer({ schema })is.defer({ input }), a resume request is{ token, input }, andex.deferral.resultisex.deferral.input. A step or adapter that defers declaresDEFERSand is handedctx.defer;DeferSignal,markDeferCapable,getExchangeContextandgetExchangeRouteleave the entry. Section 18. -
The command line reads a project, and only a project.
craft.config.tsdefault-exportsdefineProject({ ... });defineConfig, a plain default-exported object and thecraftConfignamed export are refused withRC1120.telemetry()is thetelemetrykey ortelemetryPlugin(). Section 19. -
Events carry ids, and bodies only on request.
details.exchangeis gone from every event: readdetails.exchangeId, and subscribe with{ snapshots: true }to readdetails._snapshot. Section 20. -
agent()andmcp()need their plugin. An inlineagent({ ... })needsagent: {}, and a call to a remote tool by URL needsmcp: {}. A block resolver's second argument is aBlockContext. Section 21. -
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.
-
A model call that was cut off before it produced anything fails.
llm()andagent()fail withAI1020where they returned an empty answer, the default output cap is lifted whenreasoningis set, andllm()sends an emptyuser:as it is. Section 23. -
craft execexits2for a payload the route refused. A refused payload was exit1, and a caller a validate hook refused is exit4. Section 24. -
Option and filesystem errors carry a code. An invalid
mcpPlugin()orllmPlugin()option isRC5003where it was aTypeError, and a missing or unreadable path isRC5014orRC5015. 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')
})
},
})
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:
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:
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:
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:
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.
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.
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'sverify: 'strict', is^8.0.6. Runbun 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 matchesai6. Runbun add @ai-sdk/openai-compatible@^2.@huggingface/transformers, used by Hugging Face embeddings, is^4.3.1. Runbun add @huggingface/transformers@^4.3.1, then check thatsharpresolves to 0.35.5 or later (bun update sharpif 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.
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
RC5048into 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
WrapperStepimplements two members in place ofdescribeOptions():protected readonly wrapperKind, a stable dotted name, andprotected identityOptions(), returning{ options }(andversionwhen its behaviour changes). NestedSteps.predicateisselector, for a raw step that reports its own branches.- A route that defers or caches may warn at start with
RC5071when 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.
- 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'sexchangeIdand lands where it is written. The old default line,LogAdapter outputwith 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_FILEor readscraft.log.*; the firstdefaultLogger()call does, and a context built withloggernever makes that call. - Credential headers are redacted by default. A line that logs
headersshows[Redacted]forauthorization,cookie,set-cookieandproxy-authorization, undercreateLogger()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/testingno longer patches a global.testContext()gives each context its own spy logger, so contexts alive at once never see each other's lines.t.loggerandt.contextLoggerread as before; a test that passes its ownloggerin.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:
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:
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:
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
CONTINUATIONSport isroutecraft.continuations@2. A plugin that provides it under the@1name declares the port again from the exported token. Itssigneris typedResumeTokenSigning. - 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 withRC5048as 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 withRC5048and 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, isRC5032. restrict-continuation-mintingis an error in both lint presets. It flagscontinuations.mintToken(),resume()andrewriteStepState(); see linting.- Six more names leave the entry, none of which a route needs:
ResolvedSampleOptions,ResolvedDedupeOptions,ResolvedThrottleOptions,ResolvedCircuitBreakerOptions,RouteEnablementandhashExchangeBody. - 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@routecraftscope: the adapter-override hooks behind@routecraft/testing(RC_ADAPTER_OVERRIDES,SOURCE_FIXTURE,isSourceFixtureand the typesAdapterOverride,AdapterSendCall,AdapterSourceCall,SendOverrideHandler,SourceOverrideBehavior,SourceFixture,SourceMessage), the runtime-version helpers (RuntimeVersion,parseRuntimeVersion,compareRuntimeVersion,isDevelopmentRuntime) andrejectStaleOptions. 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.
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:
--config <path>: the project that file default-exports.- The file's own
export const project = defineProject({ ... }). - The
craft.configbeside the nearestpackage.jsonat 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-configskips this step. - The project the routes were built with: the one whose
craft()started them. - 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.
// 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 ofroutecraft.http.rawHeaders, or out ofroutecraft.http.queryandroutecraft.http.urlforin: 'query'. A route that read the key to work out who called returns that fromapiKey({ 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.
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.
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.
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".
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.
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>(), withrequires,optional,providesandreplaces. -
Replaceable positions.
.authorize()and the resilience operations are unchanged on the builder, and the default plugins fill them throughENFORCEMENTandRESILIENCE. 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 theCACHE_STOREport, aCacheProvider. A plugin that provides and replaces it moves every cache site that names noproviderof its own, andcacheProviderConformancefrom@routecraft/testingis the suite its store runs against itself. -
Port versions are contracts. The value read under
name@1keeps its shape while that name exists; a change ships asname@2. -
isTransient(error). The rule.retry()and.circuitBreaker()apply by default, exported so a customretryOnextends it.route:retry:stoppedcarriesreason(exhausted,not-retryableoraborted) and the error'scode, 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 theobserve,mutateandvalidatephases. Every hook declares anid;hooks.orderandhooks.disablein config address it aspluginId/idand settle conflicts. A validate hook'srefuse(reason, { kind })is answered at the door the caller came through with the status its kind maps to. -
The
errorslot. 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'sinputdeclare 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_idon every exchange a hand-off produces (a chain root has none),causationIdon everyroute:exchange:*event of such an exchange and in the logger's bindings, W3C trace context across thehttp(), ops and MCP doors (adopted from an authenticated caller by default,traceContexton 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-ownedroutecraft.sourceheader) names the source adapter that admitted an exchange,route:exchange:startedcarries it assource, and a plugin hook takessources: [...]to run only for those sources: abeforeAuthhook can supply a principal forargv()without opening the route'sdirect()ormcp()door. See Hooks. -
argv().craft run <file> --field=value(or JSON on stdin) reaches the route as one exchange, with thecraft execflag grammar and exit codes, and--helpfrom the.input()schema. A file with severalargv()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:requestedandplugin:mcp:remote:settledname 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.mcpPluginalso logs at start whether each client is proxied. See remote call events. -
Pinned MCP tools.
pinson an MCP client holds it to the tool definitions inmcp.lock, whichcraft mcp pinwrites 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 aclassonroutecraft.mcp.class: the approved one when the tool is served on its approved definition,destructiveotherwise. A star proxy'sexcludealso 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 connectto 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 fromcraft connect --export. See servers behind a login. -
Plugin tooling. A plugin's descriptor declares
tooling: { commands, logins }:craft <namespace> <command>runs a command, andcraft connectruns 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 pinand 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 thecraft.configthat extends it.
The Plugins guide explains each part with a worked example, and the Plugins reference lists every field.