Skip to content
Developer Preview

FoldExtension

The one fold extension hook: a neutral, method-name-keyed registration consulted for BOTH connection-level state and the per-session fold.

An extension runs INSIDE the single apply path — never a second pump — so gap buffering, twin-claiming and resume behave exactly as today. The hook names no experimental feature: it matches on the method string, and the extension keeps its own state in its own instance.

A throw never escapes: both loops catch an extension’s throw and report it to that extension’s onError (the ApprovalFailure “reported, not thrown” rule — the call site is a notification pump with nothing to catch it). Without an onError the failure is swallowed, deliberately: one bad add-on must not drop every session. An onError that itself throws is swallowed too, for the same reason the approval observer’s is.

Property Type Stability Presence Description
method string required The exact notification method this extension handles.
onError (error: unknown) => void optional Receives this extension’s throws; absent means swallow.
Method Signature Stability Description
apply apply(params: unknown): void Fold one frame’s params. Called in registration order with the other extensions for the same method, before the fold’s own arm for that method runs.
Source

clients/sdk-ts/src/fold/extension.ts:19

{
"kind": "Interface",
"canonicalPath": "FoldExtension"
}