@graphrefly/ts 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/adapters/index.cjs +9015 -0
- package/dist/adapters/index.cjs.map +1 -0
- package/dist/adapters/index.d.cts +678 -0
- package/dist/adapters/index.d.ts +678 -0
- package/dist/adapters/index.js +2894 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/observe-storage.cjs +260 -0
- package/dist/adapters/observe-storage.cjs.map +1 -0
- package/dist/adapters/observe-storage.d.cts +77 -0
- package/dist/adapters/observe-storage.d.ts +77 -0
- package/dist/adapters/observe-storage.js +161 -0
- package/dist/adapters/observe-storage.js.map +1 -0
- package/dist/append-log-DisvEReb.d.cts +189 -0
- package/dist/append-log-DzKMmjxx.d.ts +189 -0
- package/dist/chunk-2ILL7HQI.js +1189 -0
- package/dist/chunk-2ILL7HQI.js.map +1 -0
- package/dist/chunk-4VLAQHZI.js +330 -0
- package/dist/chunk-4VLAQHZI.js.map +1 -0
- package/dist/chunk-6PHB5CJS.js +229 -0
- package/dist/chunk-6PHB5CJS.js.map +1 -0
- package/dist/chunk-COHO25CZ.js +2449 -0
- package/dist/chunk-COHO25CZ.js.map +1 -0
- package/dist/chunk-D6BG7U6A.js +161 -0
- package/dist/chunk-D6BG7U6A.js.map +1 -0
- package/dist/chunk-DJC4CHLQ.js +818 -0
- package/dist/chunk-DJC4CHLQ.js.map +1 -0
- package/dist/chunk-DK554R7P.js +67 -0
- package/dist/chunk-DK554R7P.js.map +1 -0
- package/dist/chunk-DKP56CSW.js +322 -0
- package/dist/chunk-DKP56CSW.js.map +1 -0
- package/dist/chunk-G4M3NHRJ.js +688 -0
- package/dist/chunk-G4M3NHRJ.js.map +1 -0
- package/dist/chunk-GAJW5I5P.js +1 -0
- package/dist/chunk-GAJW5I5P.js.map +1 -0
- package/dist/chunk-GDL26N2T.js +282 -0
- package/dist/chunk-GDL26N2T.js.map +1 -0
- package/dist/chunk-GTPCOEOZ.js +741 -0
- package/dist/chunk-GTPCOEOZ.js.map +1 -0
- package/dist/chunk-H2HTHFVN.js +1 -0
- package/dist/chunk-H2HTHFVN.js.map +1 -0
- package/dist/chunk-HDRL4VQQ.js +218 -0
- package/dist/chunk-HDRL4VQQ.js.map +1 -0
- package/dist/chunk-I3IHOHCJ.js +2267 -0
- package/dist/chunk-I3IHOHCJ.js.map +1 -0
- package/dist/chunk-JIMUDQN3.js +965 -0
- package/dist/chunk-JIMUDQN3.js.map +1 -0
- package/dist/chunk-JR4IKCR2.js +462 -0
- package/dist/chunk-JR4IKCR2.js.map +1 -0
- package/dist/chunk-K3FXTC3I.js +165 -0
- package/dist/chunk-K3FXTC3I.js.map +1 -0
- package/dist/chunk-OOEN33FB.js +65 -0
- package/dist/chunk-OOEN33FB.js.map +1 -0
- package/dist/chunk-PKVBHGBM.js +554 -0
- package/dist/chunk-PKVBHGBM.js.map +1 -0
- package/dist/chunk-RIIOUTGM.js +1857 -0
- package/dist/chunk-RIIOUTGM.js.map +1 -0
- package/dist/chunk-SCRFRCGR.js +33 -0
- package/dist/chunk-SCRFRCGR.js.map +1 -0
- package/dist/chunk-SWTLEQL6.js +53 -0
- package/dist/chunk-SWTLEQL6.js.map +1 -0
- package/dist/chunk-SZAETNNA.js +1 -0
- package/dist/chunk-SZAETNNA.js.map +1 -0
- package/dist/chunk-TEW47IVR.js +49 -0
- package/dist/chunk-TEW47IVR.js.map +1 -0
- package/dist/chunk-Y3ZLRGHC.js +1482 -0
- package/dist/chunk-Y3ZLRGHC.js.map +1 -0
- package/dist/chunk-Z2ANQ6JW.js +149 -0
- package/dist/chunk-Z2ANQ6JW.js.map +1 -0
- package/dist/codec-BB7p8fJc.d.cts +38 -0
- package/dist/codec-BB7p8fJc.d.ts +38 -0
- package/dist/composition/index.cjs +2505 -0
- package/dist/composition/index.cjs.map +1 -0
- package/dist/composition/index.d.cts +95 -0
- package/dist/composition/index.d.ts +95 -0
- package/dist/composition/index.js +19 -0
- package/dist/composition/index.js.map +1 -0
- package/dist/core/index.cjs +2475 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +25 -0
- package/dist/core/index.d.ts +25 -0
- package/dist/core/index.js +74 -0
- package/dist/core/index.js.map +1 -0
- package/dist/cqrs/index.cjs +595 -0
- package/dist/cqrs/index.cjs.map +1 -0
- package/dist/cqrs/index.d.cts +200 -0
- package/dist/cqrs/index.d.ts +200 -0
- package/dist/cqrs/index.js +557 -0
- package/dist/cqrs/index.js.map +1 -0
- package/dist/data-structures/index.cjs +4277 -0
- package/dist/data-structures/index.cjs.map +1 -0
- package/dist/data-structures/index.d.cts +22 -0
- package/dist/data-structures/index.d.ts +22 -0
- package/dist/data-structures/index.js +31 -0
- package/dist/data-structures/index.js.map +1 -0
- package/dist/describe-BZb7AS2y.d.ts +57 -0
- package/dist/describe-Ciu8SUnN.d.cts +57 -0
- package/dist/graph/index.cjs +7832 -0
- package/dist/graph/index.cjs.map +1 -0
- package/dist/graph/index.d.cts +251 -0
- package/dist/graph/index.d.ts +251 -0
- package/dist/graph/index.js +131 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph-DfdF9zy4.d.ts +666 -0
- package/dist/graph-s23RbbFO.d.cts +666 -0
- package/dist/index-CAEmLCYF.d.cts +166 -0
- package/dist/index-SnzZu3x7.d.ts +166 -0
- package/dist/index.cjs +15409 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +582 -0
- package/dist/index.js.map +1 -0
- package/dist/messages-BZqrGGm1.d.cts +55 -0
- package/dist/messages-BZqrGGm1.d.ts +55 -0
- package/dist/messaging/index.cjs +818 -0
- package/dist/messaging/index.cjs.map +1 -0
- package/dist/messaging/index.d.cts +235 -0
- package/dist/messaging/index.d.ts +235 -0
- package/dist/messaging/index.js +767 -0
- package/dist/messaging/index.js.map +1 -0
- package/dist/observe-event-log-0SVsx7JG.d.cts +88 -0
- package/dist/observe-event-log-Dnm76owp.d.ts +88 -0
- package/dist/operators/index.cjs +3774 -0
- package/dist/operators/index.cjs.map +1 -0
- package/dist/operators/index.d.cts +308 -0
- package/dist/operators/index.d.ts +308 -0
- package/dist/operators/index.js +112 -0
- package/dist/operators/index.js.map +1 -0
- package/dist/orchestration/index.cjs +3541 -0
- package/dist/orchestration/index.cjs.map +1 -0
- package/dist/orchestration/index.d.cts +302 -0
- package/dist/orchestration/index.d.ts +302 -0
- package/dist/orchestration/index.js +1004 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/patterns/index.cjs +1045 -0
- package/dist/patterns/index.cjs.map +1 -0
- package/dist/patterns/index.d.cts +39 -0
- package/dist/patterns/index.d.ts +39 -0
- package/dist/patterns/index.js +33 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/reactive-collection-BxBqtIOE.d.cts +344 -0
- package/dist/reactive-collection-Cb1II1Fi.d.ts +344 -0
- package/dist/reactive-collection-storage-BNiEc-Gd.d.ts +217 -0
- package/dist/reactive-collection-storage-D-KmjE0J.d.cts +217 -0
- package/dist/reactive-map-BcB4KsQR.d.ts +256 -0
- package/dist/reactive-map-D-g3dv8I.d.cts +256 -0
- package/dist/read-through-B1CYPfq_.d.cts +82 -0
- package/dist/read-through-DwyJhGs1.d.ts +82 -0
- package/dist/render/index.cjs +250 -0
- package/dist/render/index.cjs.map +1 -0
- package/dist/render/index.d.cts +58 -0
- package/dist/render/index.d.ts +58 -0
- package/dist/render/index.js +20 -0
- package/dist/render/index.js.map +1 -0
- package/dist/resilience-Dig3Q7n0.d.cts +45 -0
- package/dist/resilience-Dig3Q7n0.d.ts +45 -0
- package/dist/semantic-memory-graph-BYoIlP35.d.cts +356 -0
- package/dist/semantic-memory-graph-CxyXLms3.d.ts +356 -0
- package/dist/solutions/index.cjs +3249 -0
- package/dist/solutions/index.cjs.map +1 -0
- package/dist/solutions/index.d.cts +520 -0
- package/dist/solutions/index.d.ts +520 -0
- package/dist/solutions/index.js +31 -0
- package/dist/solutions/index.js.map +1 -0
- package/dist/sources/browser.cjs +3095 -0
- package/dist/sources/browser.cjs.map +1 -0
- package/dist/sources/browser.d.cts +39 -0
- package/dist/sources/browser.d.ts +39 -0
- package/dist/sources/browser.js +137 -0
- package/dist/sources/browser.js.map +1 -0
- package/dist/sources/index.cjs +3021 -0
- package/dist/sources/index.cjs.map +1 -0
- package/dist/sources/index.d.cts +7 -0
- package/dist/sources/index.d.ts +7 -0
- package/dist/sources/index.js +63 -0
- package/dist/sources/index.js.map +1 -0
- package/dist/sources/node.cjs +675 -0
- package/dist/sources/node.cjs.map +1 -0
- package/dist/sources/node.d.cts +109 -0
- package/dist/sources/node.d.ts +109 -0
- package/dist/sources/node.js +639 -0
- package/dist/sources/node.js.map +1 -0
- package/dist/storage/browser.cjs +777 -0
- package/dist/storage/browser.cjs.map +1 -0
- package/dist/storage/browser.d.cts +40 -0
- package/dist/storage/browser.d.ts +40 -0
- package/dist/storage/browser.js +275 -0
- package/dist/storage/browser.js.map +1 -0
- package/dist/storage/index.cjs +1989 -0
- package/dist/storage/index.cjs.map +1 -0
- package/dist/storage/index.d.cts +92 -0
- package/dist/storage/index.d.ts +92 -0
- package/dist/storage/index.js +161 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/node.cjs +898 -0
- package/dist/storage/node.cjs.map +1 -0
- package/dist/storage/node.d.cts +66 -0
- package/dist/storage/node.d.ts +66 -0
- package/dist/storage/node.js +402 -0
- package/dist/storage/node.js.map +1 -0
- package/dist/testing/index.cjs +95 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +20 -0
- package/dist/testing/index.d.ts +20 -0
- package/dist/testing/index.js +8 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/types-bNMSWKqF.d.cts +732 -0
- package/dist/types-h12mNYbq.d.ts +732 -0
- package/package.json +250 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/bridge.ts","../../src/adapters/environment.ts","../../src/adapters/nestjs.ts","../../src/adapters/store.ts"],"sourcesContent":["/**\n * Graph-visible wire bridge envelope helpers (D134).\n *\n * This first slice is transport-free: commands become outbound envelope facts,\n * remote receipts enter only through the inbound fact node, and retry/ack timeout\n * state is surfaced through graph-visible attempts/status/errors nodes.\n */\n\nimport { type Ctx, depBatch } from \"../ctx/types.js\";\nimport type { Graph } from \"../graph/graph.js\";\nimport {\n\tnextRetryDelayMs,\n\ttype RetryPolicy,\n\tretryPolicy,\n\tshouldRetry,\n} from \"../graph/resilience.js\";\nimport type { Node } from \"../node/node.js\";\nimport { errorPayload, type Wave } from \"../protocol/messages.js\";\n\nexport type WireBridgeEnvelopeType =\n\t| \"start\"\n\t| \"data\"\n\t| \"ack\"\n\t| \"nack\"\n\t| \"status\"\n\t| \"error\"\n\t| \"close\";\n\nexport interface WireBridgeMetadata {\n\t/** Monotonic envelope sequence within the bridge session. */\n\treadonly seq: number;\n\t/** Monotonic accepted inbound cursor observed by the sending side. */\n\treadonly cursor: number;\n\t/** D151: correlation/idempotency metadata, not an authoritative duplicate lookup key. */\n\treadonly idempotencyKey: string;\n\treadonly attempt: number;\n\treadonly maxAttempts: number;\n\treadonly timestampMs?: number;\n\t/** D151 ack/nack correlation target; receipt duplicate recognition still uses seq/cursor. */\n\treadonly ackForSeq?: number;\n\treadonly requestId?: string;\n}\n\nexport type WireBridgePayload<TData = unknown> =\n\t| { readonly kind: \"data\"; readonly value: TData }\n\t| { readonly kind: \"error\"; readonly error: unknown }\n\t| { readonly kind: \"status\"; readonly status: unknown }\n\t| { readonly kind: \"close\"; readonly reason?: unknown };\n\nexport interface WireBridgeEnvelope<TData = unknown> {\n\treadonly sessionId: string;\n\treadonly type: WireBridgeEnvelopeType;\n\treadonly payload?: WireBridgePayload<TData>;\n\treadonly metadata: WireBridgeMetadata;\n}\n\nexport type WireBridgeCommand<TData = unknown> =\n\t| { readonly kind: \"start\"; readonly idempotencyKey?: string; readonly requestId?: string }\n\t| {\n\t\t\treadonly kind: \"send\";\n\t\t\treadonly payload: TData;\n\t\t\treadonly idempotencyKey?: string;\n\t\t\treadonly requestId?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"ack\";\n\t\t\treadonly ackForSeq: number;\n\t\t\treadonly idempotencyKey?: string;\n\t\t\treadonly requestId?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"nack\";\n\t\t\treadonly ackForSeq: number;\n\t\t\treadonly error: unknown;\n\t\t\treadonly idempotencyKey?: string;\n\t\t\treadonly requestId?: string;\n\t }\n\t| { readonly kind: \"close\"; readonly reason?: unknown; readonly idempotencyKey?: string };\n\nexport type WireBridgeEvent<TOutbound = unknown, TInbound = unknown> =\n\t| {\n\t\t\treadonly kind: \"outbound\";\n\t\t\treadonly envelope: WireBridgeEnvelope<TOutbound>;\n\t }\n\t| {\n\t\t\treadonly kind: \"inbound\";\n\t\t\treadonly envelope: WireBridgeEnvelope<TInbound>;\n\t }\n\t| {\n\t\t\treadonly kind: \"ack\";\n\t\t\treadonly ackForSeq: number;\n\t\t\treadonly envelope: WireBridgeEnvelope<TInbound>;\n\t\t\treadonly outbound: WireBridgeEnvelope<TOutbound>;\n\t }\n\t| {\n\t\t\treadonly kind: \"nack\";\n\t\t\treadonly ackForSeq: number;\n\t\t\treadonly envelope: WireBridgeEnvelope<TInbound>;\n\t\t\treadonly outbound: WireBridgeEnvelope<TOutbound>;\n\t\t\treadonly error: unknown;\n\t }\n\t| { readonly kind: \"timeout\"; readonly seq: number; readonly attempt: number }\n\t| {\n\t\t\treadonly kind: \"retry\";\n\t\t\treadonly seq: number;\n\t\t\treadonly attempt: number;\n\t\t\treadonly delayMs: number;\n\t\t\treadonly error: unknown;\n\t }\n\t| {\n\t\t\treadonly kind: \"exhausted\";\n\t\t\treadonly seq: number;\n\t\t\treadonly attempt: number;\n\t\t\treadonly error: unknown;\n\t }\n\t| { readonly kind: \"cursor\"; readonly cursor: number }\n\t| { readonly kind: \"duplicate\"; readonly seq: number; readonly cursor: number }\n\t| { readonly kind: \"out-of-order\"; readonly seq: number; readonly expected: number }\n\t| { readonly kind: \"session-mismatch\"; readonly expected: string; readonly actual: string }\n\t| { readonly kind: \"late-receipt\"; readonly receipt: \"ack\" | \"nack\"; readonly ackForSeq: number }\n\t| { readonly kind: \"invalid\"; readonly error: string };\n\nexport interface WireBridgeAck {\n\treadonly ackForSeq: number;\n\treadonly envelope: WireBridgeEnvelope;\n}\n\nexport interface WireBridgeNack {\n\treadonly ackForSeq: number;\n\treadonly envelope: WireBridgeEnvelope;\n\treadonly error: unknown;\n}\n\nexport interface WireBridgeAttempt {\n\treadonly seq: number;\n\treadonly attempt: number;\n\treadonly maxAttempts: number;\n}\n\nexport interface WireBridgeStatus {\n\treadonly sessionId: string;\n\treadonly state: \"idle\" | \"started\" | \"open\" | \"waiting\" | \"closed\" | \"errored\" | \"exhausted\";\n\treadonly cursor: number;\n\treadonly nextSeq: number;\n\treadonly pending: number;\n\treadonly attempts: number;\n\treadonly acked: number;\n\treadonly nacked: number;\n\treadonly errors: number;\n\treadonly lastSeq?: number;\n\treadonly lastDelayMs?: number;\n}\n\nexport interface WireBridgeOptions {\n\treadonly name?: string;\n\treadonly sessionId: string;\n\treadonly retry?: RetryPolicy;\n\t/** Finite D134 ack timeout. Defaults to 30s so pending ack tracking is bounded. */\n\treadonly ackTimeoutMs?: number;\n\treadonly now?: () => number;\n}\n\nexport interface WireBridgeBundle<TOutbound = unknown, TInbound = unknown> {\n\treadonly sessionId: string;\n\treadonly command: Node<WireBridgeCommand<TOutbound>>;\n\treadonly outbound: Node<WireBridgeEnvelope<TOutbound>>;\n\treadonly inbound: Node<WireBridgeEnvelope<TInbound>>;\n\treadonly events: Node<WireBridgeEvent<TOutbound, TInbound>>;\n\treadonly acks: Node<WireBridgeAck>;\n\treadonly nacks: Node<WireBridgeNack>;\n\treadonly status: Node<WireBridgeStatus>;\n\treadonly errors: Node<unknown>;\n\treadonly cursor: Node<number>;\n\treadonly attempts: Node<WireBridgeAttempt>;\n\tstart(): void;\n\tsend(payload: TOutbound, opts?: { idempotencyKey?: string; requestId?: string }): void;\n\tack(ackForSeq: number, opts?: { idempotencyKey?: string; requestId?: string }): void;\n\tnack(\n\t\tackForSeq: number,\n\t\terror: unknown,\n\t\topts?: { idempotencyKey?: string; requestId?: string },\n\t): void;\n\tclose(reason?: unknown, opts?: { idempotencyKey?: string }): void;\n}\n\nexport interface RemoteCallRequest<T = unknown> {\n\treadonly operation: string;\n\treadonly requestId: string;\n\treadonly payload: T;\n}\n\nexport type RemoteCallResponse<T = unknown> =\n\t| {\n\t\t\treadonly kind: \"result\";\n\t\t\treadonly operation: string;\n\t\t\treadonly requestId: string;\n\t\t\treadonly payload: T;\n\t }\n\t| {\n\t\t\treadonly kind: \"error\";\n\t\t\treadonly operation: string;\n\t\t\treadonly requestId: string;\n\t\t\treadonly error: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"status\";\n\t\t\treadonly operation: string;\n\t\t\treadonly requestId: string;\n\t\t\treadonly status: string;\n\t };\n\nexport interface RemoteCallResult<T = unknown> {\n\treadonly operation: string;\n\treadonly requestId: string;\n\treadonly payload: T;\n}\n\nexport type RemoteCallStatusState =\n\t| \"idle\"\n\t| \"requested\"\n\t| \"responded\"\n\t| \"errored\"\n\t| \"timed-out\"\n\t| \"bridge-errored\";\n\nexport interface RemoteCallStatus {\n\treadonly state: RemoteCallStatusState;\n\treadonly operation?: string;\n\treadonly requestId?: string;\n\treadonly pending: number;\n\treadonly completed: number;\n\treadonly errors: number;\n\treadonly timeouts: number;\n}\n\nexport interface RemoteCallError {\n\treadonly operation?: string;\n\treadonly requestId?: string;\n\treadonly error: string;\n}\n\nexport interface RemoteCallTimeout {\n\treadonly operation?: string;\n\treadonly requestId: string;\n\treadonly error: string;\n}\n\nexport interface RemoteCallOptions {\n\treadonly name?: string;\n}\n\nexport interface RemoteCallBundle<TRequest = unknown, TResponse = unknown> {\n\treadonly responses: Node<RemoteCallResponse<TResponse>>;\n\treadonly results: Node<RemoteCallResult<TResponse>>;\n\treadonly status: Node<RemoteCallStatus>;\n\treadonly errors: Node<RemoteCallError>;\n\treadonly timeouts: Node<RemoteCallTimeout>;\n\tcall(\n\t\toperation: string,\n\t\trequestId: string,\n\t\tpayload: TRequest,\n\t\topts?: { readonly idempotencyKey?: string },\n\t): RemoteCallRequest<TRequest>;\n\ttimeout(requestId: string, operation: string | undefined, error: string): RemoteCallTimeout;\n}\n\nexport type RemoteResponderHandler<TRequest = unknown, TResponse = unknown> = (\n\trequest: RemoteCallRequest<TRequest>,\n) => TResponse;\n\nexport interface RemoteResponderHandlerDefinition<TRequest = unknown, TResponse = unknown> {\n\treadonly operation: string;\n\treadonly handle: RemoteResponderHandler<TRequest, TResponse>;\n}\n\nexport type RemoteResponderEvent<TRequest = unknown, TResponse = unknown> =\n\t| {\n\t\t\treadonly kind: \"request\";\n\t\t\treadonly request: RemoteCallRequest<TRequest>;\n\t\t\treadonly seq: number;\n\t }\n\t| {\n\t\t\treadonly kind: \"response\";\n\t\t\treadonly requestId: string;\n\t\t\treadonly operation: string;\n\t\t\treadonly command: WireBridgeCommand<RemoteCallResponse<TResponse>>;\n\t }\n\t| {\n\t\t\treadonly kind: \"rejected\";\n\t\t\treadonly requestId?: string;\n\t\t\treadonly operation?: string;\n\t\t\treadonly error: string;\n\t\t\treadonly command?: WireBridgeCommand<RemoteCallResponse<TResponse>>;\n\t }\n\t| { readonly kind: \"invalid\"; readonly error: string };\n\nexport type RemoteResponderStatusState = \"idle\" | \"responded\" | \"rejected\" | \"errored\";\n\nexport interface RemoteResponderStatus {\n\treadonly state: RemoteResponderStatusState;\n\treadonly operation?: string;\n\treadonly requestId?: string;\n\treadonly handled: number;\n\treadonly rejected: number;\n\treadonly errors: number;\n}\n\nexport interface RemoteResponderOptions<TRequest = unknown, TResponse = unknown> {\n\treadonly name?: string;\n\treadonly handlers?: readonly RemoteResponderHandlerDefinition<TRequest, TResponse>[];\n\t/** Default false: non-owned operations are ignored so multiple responders may share one bridge. */\n\treadonly rejectUnknown?: boolean;\n}\n\nexport interface RemoteResponderBundle<TRequest = unknown, TResponse = unknown> {\n\treadonly events: Node<RemoteResponderEvent<TRequest, TResponse>>;\n\treadonly responseCommands: Node<WireBridgeCommand<RemoteCallResponse<TResponse>>>;\n\treadonly requests: Node<RemoteCallRequest<TRequest>>;\n\treadonly status: Node<RemoteResponderStatus>;\n\treadonly errors: Node<RemoteCallError>;\n\trelease(): void;\n}\n\ninterface PendingEnvelope<TData> {\n\tenvelope: WireBridgeEnvelope<TData>;\n\ttimer?: ReturnType<typeof setTimeout>;\n}\n\ninterface BridgeState<TData> {\n\tactive: boolean;\n\tcleanupInstalled: boolean;\n\tnextSeq: number;\n\tcursor: number;\n\tremoteCursor: number;\n\tterminalReported: boolean;\n\tpending: Map<number, PendingEnvelope<TData>>;\n}\n\ninterface AttachedCommandSources<TOutbound> {\n\tsources: Node<WireBridgeCommand<TOutbound>>[];\n}\n\ninterface WireBridgeInvalidIngress {\n\treadonly __wireBridgeInvalidIngress: true;\n\treadonly error: string;\n}\n\nconst envelopeTypes = new Set<WireBridgeEnvelopeType>([\n\t\"start\",\n\t\"data\",\n\t\"ack\",\n\t\"nack\",\n\t\"status\",\n\t\"error\",\n\t\"close\",\n]);\n\nconst defaultAckTimeoutMs = 30_000;\nconst bridgeCommandSources = new WeakMap<\n\tWireBridgeBundle<unknown, unknown>,\n\tAttachedCommandSources<unknown>\n>();\nconst bridgeInboundTargets = new WeakMap<\n\tWireBridgeBundle<unknown, unknown>,\n\tNode<WireBridgeEnvelope<unknown> | WireBridgeInvalidIngress>\n>();\n\n/** Stable D134 idempotency key helper scoped to one bridge session and sequence. */\nexport function wireBridgeIdempotencyKey(sessionId: string, seq: number): string {\n\treturn `${sessionId}:${seq}`;\n}\n\n/** Create a D134 wire bridge envelope with ordered metadata. */\nexport function wireBridgeEnvelope<TData = unknown>(input: {\n\treadonly sessionId: string;\n\treadonly type: WireBridgeEnvelopeType;\n\treadonly seq: number;\n\treadonly cursor?: number;\n\treadonly payload?: WireBridgePayload<TData>;\n\treadonly idempotencyKey?: string;\n\treadonly attempt?: number;\n\treadonly maxAttempts?: number;\n\treadonly timestampMs?: number;\n\treadonly ackForSeq?: number;\n\treadonly requestId?: string;\n}): WireBridgeEnvelope<TData> {\n\tif (typeof input.sessionId !== \"string\" || input.sessionId.length === 0) {\n\t\tthrow new RangeError(\"wireBridgeEnvelope: sessionId must be a non-empty string\");\n\t}\n\tif (!envelopeTypes.has(input.type)) {\n\t\tthrow new RangeError(\"wireBridgeEnvelope: type is not recognized\");\n\t}\n\tif (!isSafePositiveInteger(input.seq)) {\n\t\tthrow new RangeError(\"wireBridgeEnvelope: seq must be a positive integer\");\n\t}\n\tconst cursor = input.cursor ?? 0;\n\tif (!isSafeNonNegativeInteger(cursor)) {\n\t\tthrow new RangeError(\"wireBridgeEnvelope: cursor must be a non-negative integer\");\n\t}\n\tconst attempt = input.attempt ?? 1;\n\tif (!isSafePositiveInteger(attempt)) {\n\t\tthrow new RangeError(\"wireBridgeEnvelope: attempt must be a positive integer\");\n\t}\n\tconst maxAttempts = input.maxAttempts ?? attempt;\n\tif (!isSafePositiveInteger(maxAttempts) || maxAttempts < attempt) {\n\t\tthrow new RangeError(\"wireBridgeEnvelope: maxAttempts must be >= attempt\");\n\t}\n\tif (input.ackForSeq !== undefined && !isSafePositiveInteger(input.ackForSeq)) {\n\t\tthrow new RangeError(\"wireBridgeEnvelope: ackForSeq must be a positive integer\");\n\t}\n\tif ((input.type === \"ack\" || input.type === \"nack\") && input.ackForSeq === undefined) {\n\t\tthrow new RangeError(`wireBridgeEnvelope: ${input.type} envelope requires ackForSeq`);\n\t}\n\tif (input.idempotencyKey !== undefined && input.idempotencyKey.length === 0) {\n\t\tthrow new RangeError(\"wireBridgeEnvelope: idempotencyKey must be a non-empty string\");\n\t}\n\tconst payloadError = validatePayloadForType(input.type, input.payload, \"wireBridgeEnvelope\");\n\tif (payloadError !== undefined) {\n\t\tthrow new RangeError(payloadError);\n\t}\n\treturn {\n\t\tsessionId: input.sessionId,\n\t\ttype: input.type,\n\t\tpayload: input.payload,\n\t\tmetadata: {\n\t\t\tseq: input.seq,\n\t\t\tcursor,\n\t\t\tidempotencyKey: input.idempotencyKey ?? wireBridgeIdempotencyKey(input.sessionId, input.seq),\n\t\t\tattempt,\n\t\t\tmaxAttempts,\n\t\t\ttimestampMs: input.timestampMs,\n\t\t\tackForSeq: input.ackForSeq,\n\t\t\trequestId: input.requestId,\n\t\t},\n\t};\n}\n\nexport function wireBridge<TOutbound = unknown, TInbound = unknown>(\n\tgraph: Graph,\n\topts: WireBridgeOptions,\n): WireBridgeBundle<TOutbound, TInbound> {\n\tconst name = opts.name ?? \"wireBridge\";\n\tconst policy = opts.retry ?? retryPolicy();\n\tconst command = graph.node<WireBridgeCommand<TOutbound>>([], null, {\n\t\tname: `${name}/command`,\n\t\tfactory: \"wireBridgeCommand\",\n\t});\n\tconst inboundCore = graph.node<WireBridgeEnvelope<TInbound> | WireBridgeInvalidIngress>(\n\t\t[],\n\t\tnull,\n\t\t{\n\t\t\tname: `${name}/inbound`,\n\t\t\tfactory: \"wireBridgeInbound\",\n\t\t},\n\t);\n\tconst inbound = guardedInboundNode(inboundCore, opts.sessionId);\n\tconst events = wireBridgeEventsNode<TOutbound, TInbound>(\n\t\tgraph,\n\t\tcommand,\n\t\tinboundCore,\n\t\tname,\n\t\topts,\n\t\tpolicy,\n\t);\n\tconst outbound = projectOutbound(graph, events, name);\n\tconst acks = projectAcks(graph, events, name);\n\tconst nacks = projectNacks(graph, events, name);\n\tconst status = projectStatus(graph, events, name, opts.sessionId);\n\tconst errors = projectErrors(graph, events, name);\n\tconst cursor = projectCursor(graph, events, name);\n\tconst attempts = projectAttempts(graph, events, name);\n\tconst bundle: WireBridgeBundle<TOutbound, TInbound> = {\n\t\tsessionId: opts.sessionId,\n\t\tcommand,\n\t\toutbound,\n\t\tinbound,\n\t\tevents,\n\t\tacks,\n\t\tnacks,\n\t\tstatus,\n\t\terrors,\n\t\tcursor,\n\t\tattempts,\n\t\tstart: () => command.down([[\"DATA\", { kind: \"start\" }]]),\n\t\tsend: (payload, sendOpts) =>\n\t\t\tcommand.down([\n\t\t\t\t[\n\t\t\t\t\t\"DATA\",\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: \"send\",\n\t\t\t\t\t\tpayload,\n\t\t\t\t\t\tidempotencyKey: sendOpts?.idempotencyKey,\n\t\t\t\t\t\trequestId: sendOpts?.requestId,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t]),\n\t\tack: (ackForSeq, ackOpts) =>\n\t\t\tcommand.down([\n\t\t\t\t[\n\t\t\t\t\t\"DATA\",\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: \"ack\",\n\t\t\t\t\t\tackForSeq,\n\t\t\t\t\t\tidempotencyKey: ackOpts?.idempotencyKey,\n\t\t\t\t\t\trequestId: ackOpts?.requestId,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t]),\n\t\tnack: (ackForSeq, error, nackOpts) =>\n\t\t\tcommand.down([\n\t\t\t\t[\n\t\t\t\t\t\"DATA\",\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: \"nack\",\n\t\t\t\t\t\tackForSeq,\n\t\t\t\t\t\terror,\n\t\t\t\t\t\tidempotencyKey: nackOpts?.idempotencyKey,\n\t\t\t\t\t\trequestId: nackOpts?.requestId,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t]),\n\t\tclose: (reason, closeOpts) =>\n\t\t\tcommand.down([\n\t\t\t\t[\"DATA\", { kind: \"close\", reason, idempotencyKey: closeOpts?.idempotencyKey }],\n\t\t\t]),\n\t};\n\tbridgeCommandSources.set(bundle as WireBridgeBundle<unknown, unknown>, { sources: [] });\n\tbridgeInboundTargets.set(bundle as WireBridgeBundle<unknown, unknown>, inboundCore);\n\treturn bundle;\n}\n\n/** D147 remote dispatcher call helper over explicit wireBridge request/response facts. */\nexport function remoteCall<TRequest = unknown, TResponse = unknown>(\n\tgraph: Graph,\n\tbridge: WireBridgeBundle<RemoteCallRequest<TRequest>, RemoteCallResponse<TResponse>>,\n\topts: RemoteCallOptions = {},\n): RemoteCallBundle<TRequest, TResponse> {\n\tconst name = opts.name ?? \"remoteCall\";\n\tconst timeouts = graph.node<RemoteCallTimeout>([], null, {\n\t\tname: `${name}/timeouts`,\n\t\tfactory: \"remoteCallTimeouts\",\n\t\tcompleteWhenDepsComplete: false,\n\t\terrorWhenDepsError: false,\n\t});\n\tconst responses = remoteCallResponsesNode(graph, bridge.events, timeouts, name);\n\tconst results = remoteCallResultsNode(graph, responses, name);\n\tconst status = remoteCallStatusNode(graph, bridge.events, responses, timeouts, name);\n\tconst errors = remoteCallErrorsNode(graph, responses, timeouts, bridge.events, name);\n\treturn {\n\t\tresponses,\n\t\tresults,\n\t\tstatus,\n\t\terrors,\n\t\ttimeouts,\n\t\tcall(operation, requestId, payload, callOpts) {\n\t\t\tconst request = remoteCallRequest(operation, requestId, payload);\n\t\t\tbridge.command.down([\n\t\t\t\t[\n\t\t\t\t\t\"DATA\",\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: \"send\",\n\t\t\t\t\t\tpayload: request,\n\t\t\t\t\t\tidempotencyKey: callOpts?.idempotencyKey,\n\t\t\t\t\t\trequestId,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t]);\n\t\t\treturn request;\n\t\t},\n\t\ttimeout(requestId, operation, error) {\n\t\t\tconst timeout = remoteCallTimeout(requestId, operation, error);\n\t\t\ttimeouts.down([[\"DATA\", timeout]]);\n\t\t\treturn timeout;\n\t\t},\n\t};\n}\n\nexport function remoteResponderHandler<TRequest = unknown, TResponse = unknown>(\n\toperation: string,\n\thandle: RemoteResponderHandler<TRequest, TResponse>,\n): RemoteResponderHandlerDefinition<TRequest, TResponse> {\n\tif (operation.length === 0) {\n\t\tthrow new RangeError(\"remoteResponderHandler: operation must be non-empty\");\n\t}\n\tif (typeof handle !== \"function\") {\n\t\tthrow new TypeError(\"remoteResponderHandler: handle must be a function\");\n\t}\n\treturn { operation, handle };\n}\n\n/** D147 remote responder over inbound wireBridge request facts and outbound command facts. */\nexport function remoteResponder<TRequest = unknown, TResponse = unknown>(\n\tgraph: Graph,\n\tbridge: WireBridgeBundle<RemoteCallResponse<TResponse>, RemoteCallRequest<TRequest>>,\n\topts: RemoteResponderOptions<TRequest, TResponse> = {},\n): RemoteResponderBundle<TRequest, TResponse> {\n\tconst name = opts.name ?? \"remoteResponder\";\n\tconst handlers = normalizeRemoteHandlers(opts.handlers ?? []);\n\tconst topology = graph.topologyGroup({ name: `${name}.remoteResponder` });\n\tconst events = topology.add(\n\t\tremoteResponderEventsNode(\n\t\t\tgraph,\n\t\t\twireBridgeInboundTarget(bridge),\n\t\t\tname,\n\t\t\tbridge.sessionId,\n\t\t\thandlers,\n\t\t\topts.rejectUnknown === true,\n\t\t),\n\t);\n\tconst responseCommands = topology.add(remoteResponderResponseCommandsNode(graph, events, name));\n\tconst requests = topology.add(remoteResponderRequestsNode(graph, events, name));\n\tconst status = topology.add(remoteResponderStatusNode(graph, events, name));\n\tconst errors = topology.add(remoteResponderErrorsNode(graph, events, name));\n\ttry {\n\t\tattachWireBridgeCommandSource(bridge, responseCommands);\n\t} catch (error) {\n\t\ttopology.release({ reason: `${name}.remoteResponder.failedAttach` });\n\t\tthrow error;\n\t}\n\tlet released = false;\n\treturn {\n\t\tevents,\n\t\tresponseCommands,\n\t\trequests,\n\t\tstatus,\n\t\terrors,\n\t\trelease() {\n\t\t\tif (released) return;\n\t\t\tdetachWireBridgeCommandSource(bridge, responseCommands);\n\t\t\ttry {\n\t\t\t\ttopology.release({ reason: `${name}.remoteResponder.release` });\n\t\t\t\treleased = true;\n\t\t\t} catch (error) {\n\t\t\t\tattachWireBridgeCommandSource(bridge, responseCommands);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction wireBridgeEventsNode<TOutbound, TInbound>(\n\tgraph: Graph,\n\tcommand: Node<WireBridgeCommand<TOutbound>>,\n\tinbound: Node<WireBridgeEnvelope<TInbound> | WireBridgeInvalidIngress>,\n\tname: string,\n\topts: WireBridgeOptions,\n\tpolicy: RetryPolicy,\n): Node<WireBridgeEvent<TOutbound, TInbound>> {\n\tconst now = opts.now ?? Date.now;\n\treturn graph.node<WireBridgeEvent<TOutbound, TInbound>>(\n\t\t[command, inbound],\n\t\t(ctx) => {\n\t\t\tconst state = initBridgeState<TOutbound>(ctx);\n\n\t\t\tconst emitOutbound = (\n\t\t\t\ttype: WireBridgeEnvelopeType,\n\t\t\t\tpayload: WireBridgePayload<TOutbound> | undefined,\n\t\t\t\tcommandOpts: { idempotencyKey?: string; requestId?: string; ackForSeq?: number } = {},\n\t\t\t\tbeforeEmit?: () => void,\n\t\t\t) => {\n\t\t\t\tif (!isSafePositiveInteger(state.nextSeq)) {\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"invalid\",\n\t\t\t\t\t\t\t\terror: `${opts.sessionId}: next outbound seq exceeded Number.MAX_SAFE_INTEGER`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst seq = state.nextSeq;\n\t\t\t\tlet envelope: WireBridgeEnvelope<TOutbound>;\n\t\t\t\ttry {\n\t\t\t\t\tenvelope = wireBridgeEnvelope<TOutbound>({\n\t\t\t\t\t\tsessionId: opts.sessionId,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tseq,\n\t\t\t\t\t\tcursor: state.cursor,\n\t\t\t\t\t\tpayload,\n\t\t\t\t\t\tidempotencyKey: commandOpts.idempotencyKey,\n\t\t\t\t\t\tattempt: 1,\n\t\t\t\t\t\tmaxAttempts: policy.maxAttempts,\n\t\t\t\t\t\ttimestampMs: now(),\n\t\t\t\t\t\tackForSeq: commandOpts.ackForSeq,\n\t\t\t\t\t\trequestId: commandOpts.requestId,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"invalid\",\n\t\t\t\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tstate.nextSeq++;\n\t\t\t\tbeforeEmit?.();\n\t\t\t\tctx.down([[\"DATA\", { kind: \"outbound\", envelope }]]);\n\t\t\t\tif (shouldTrackAck(type)) armAckTimeout(ctx, state, envelope, opts, policy, now);\n\t\t\t};\n\n\t\t\tfor (const raw of depBatch(ctx, 1) ?? []) {\n\t\t\t\tprocessInbound(ctx, state, raw, opts.sessionId);\n\t\t\t}\n\t\t\tconst inboundTerminal = ctx.terminal[1];\n\t\t\tif (inboundTerminal !== false && inboundTerminal !== undefined && !state.terminalReported) {\n\t\t\t\tstate.terminalReported = true;\n\t\t\t\tconst error =\n\t\t\t\t\tinboundTerminal === true\n\t\t\t\t\t\t? `${opts.sessionId}: inbound protocol COMPLETE is local misuse; remote completion must arrive as a DATA envelope fact`\n\t\t\t\t\t\t: `${opts.sessionId}: inbound protocol ERROR ${String(\n\t\t\t\t\t\t\t\terrorPayload(inboundTerminal),\n\t\t\t\t\t\t\t)} is local misuse; remote errors must arrive as DATA envelope facts`;\n\t\t\t\tctx.down([[\"DATA\", { kind: \"invalid\", error }]]);\n\t\t\t}\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst invalid = validateCommand(raw);\n\t\t\t\tif (invalid !== undefined) {\n\t\t\t\t\tctx.down([[\"DATA\", { kind: \"invalid\", error: invalid }]]);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst commandValue = raw as WireBridgeCommand<TOutbound>;\n\t\t\t\tswitch (commandValue.kind) {\n\t\t\t\t\tcase \"start\":\n\t\t\t\t\t\temitOutbound(\"start\", undefined, commandValue);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"send\":\n\t\t\t\t\t\temitOutbound(\"data\", { kind: \"data\", value: commandValue.payload }, commandValue);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"ack\":\n\t\t\t\t\t\temitOutbound(\"ack\", undefined, {\n\t\t\t\t\t\t\tidempotencyKey: commandValue.idempotencyKey,\n\t\t\t\t\t\t\trequestId: commandValue.requestId,\n\t\t\t\t\t\t\tackForSeq: commandValue.ackForSeq,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"nack\":\n\t\t\t\t\t\temitOutbound(\n\t\t\t\t\t\t\t\"nack\",\n\t\t\t\t\t\t\t{ kind: \"error\", error: errorPayload(commandValue.error) },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tidempotencyKey: commandValue.idempotencyKey,\n\t\t\t\t\t\t\t\trequestId: commandValue.requestId,\n\t\t\t\t\t\t\t\tackForSeq: commandValue.ackForSeq,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"close\":\n\t\t\t\t\t\temitOutbound(\n\t\t\t\t\t\t\t\"close\",\n\t\t\t\t\t\t\t{ kind: \"close\", reason: commandValue.reason },\n\t\t\t\t\t\t\tcommandValue,\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\tfor (const pending of state.pending.values()) {\n\t\t\t\t\t\t\t\t\tif (pending.timer !== undefined) clearTimeout(pending.timer);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tstate.pending.clear();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/events`,\n\t\t\tfactory: \"wireBridgeEvents\",\n\t\t\tpartial: true,\n\t\t\terrorWhenDepsError: false,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\tterminalAsRealInput: true,\n\t\t},\n\t);\n}\n\nfunction initBridgeState<TPayload>(ctx: Ctx): BridgeState<TPayload> {\n\tlet state = ctx.state.get<BridgeState<TPayload>>();\n\tif (state === undefined) {\n\t\tstate = {\n\t\t\tactive: true,\n\t\t\tcleanupInstalled: false,\n\t\t\tnextSeq: 1,\n\t\t\tcursor: 0,\n\t\t\tremoteCursor: 0,\n\t\t\tterminalReported: false,\n\t\t\tpending: new Map(),\n\t\t};\n\t\tctx.state.set(state);\n\t}\n\tstate.active = true;\n\tif (!state.cleanupInstalled) {\n\t\tstate.cleanupInstalled = true;\n\t\tctx.onDeactivation(() => {\n\t\t\tstate.active = false;\n\t\t\tstate.cleanupInstalled = false;\n\t\t\tfor (const pending of state.pending.values()) {\n\t\t\t\tif (pending.timer !== undefined) clearTimeout(pending.timer);\n\t\t\t}\n\t\t\tstate.pending.clear();\n\t\t});\n\t}\n\treturn state;\n}\n\nfunction attachWireBridgeCommandSource<TOutbound, TInbound>(\n\tbridge: WireBridgeBundle<TOutbound, TInbound>,\n\tsource: Node<WireBridgeCommand<TOutbound>>,\n): void {\n\tconst attached = bridgeCommandSources.get(bridge as WireBridgeBundle<unknown, unknown>);\n\tif (attached === undefined) {\n\t\tthrow new Error(\"remoteResponder: bridge command source registry missing\");\n\t}\n\tconst sources = attached.sources as Node<WireBridgeCommand<TOutbound>>[];\n\tconst previousSources = [...sources];\n\tif (!sources.includes(source)) sources.push(source);\n\ttry {\n\t\tbridge.command.replaceDeps([...sources], wireBridgeCommandSourceFn(sources.length));\n\t} catch (error) {\n\t\tsources.splice(0, sources.length, ...previousSources);\n\t\tbridge.command.replaceDeps(\n\t\t\t[...previousSources],\n\t\t\twireBridgeCommandSourceFn(previousSources.length),\n\t\t);\n\t\tthrow error;\n\t}\n}\n\nfunction detachWireBridgeCommandSource<TOutbound, TInbound>(\n\tbridge: WireBridgeBundle<TOutbound, TInbound>,\n\tsource: Node<WireBridgeCommand<TOutbound>>,\n): void {\n\tconst attached = bridgeCommandSources.get(bridge as WireBridgeBundle<unknown, unknown>);\n\tif (attached === undefined) {\n\t\tthrow new Error(\"remoteResponder: bridge command source registry missing\");\n\t}\n\tconst sources = attached.sources as Node<WireBridgeCommand<TOutbound>>[];\n\tif (!sources.includes(source)) return;\n\tconst previousSources = [...sources];\n\tconst nextSources = sources.filter((candidate) => candidate !== source);\n\tsources.splice(0, sources.length, ...nextSources);\n\ttry {\n\t\tbridge.command.replaceDeps([...nextSources], wireBridgeCommandSourceFn(nextSources.length));\n\t} catch (error) {\n\t\tsources.splice(0, sources.length, ...previousSources);\n\t\tbridge.command.replaceDeps(\n\t\t\t[...previousSources],\n\t\t\twireBridgeCommandSourceFn(previousSources.length),\n\t\t);\n\t\tthrow error;\n\t}\n}\n\nfunction wireBridgeInboundTarget<TInbound>(\n\tbridge: WireBridgeBundle<unknown, TInbound>,\n): Node<WireBridgeEnvelope<TInbound> | WireBridgeInvalidIngress> {\n\tconst target = bridgeInboundTargets.get(bridge as WireBridgeBundle<unknown, unknown>);\n\tif (target === undefined) {\n\t\tthrow new Error(\"remoteResponder: bridge inbound target registry missing\");\n\t}\n\treturn target as Node<WireBridgeEnvelope<TInbound> | WireBridgeInvalidIngress>;\n}\n\nfunction wireBridgeCommandSourceFn<TOutbound>(sourceCount: number): (ctx: Ctx) => void {\n\treturn (ctx) => {\n\t\tfor (let i = 0; i < sourceCount; i += 1) {\n\t\t\tfor (const command of depBatch(ctx, i) ?? []) {\n\t\t\t\tctx.down([[\"DATA\", command as WireBridgeCommand<TOutbound>]]);\n\t\t\t}\n\t\t}\n\t};\n}\n\nfunction remoteCallRequest<TRequest>(\n\toperation: string,\n\trequestId: string,\n\tpayload: TRequest,\n): RemoteCallRequest<TRequest> {\n\tif (operation.length === 0) throw new RangeError(\"remoteCall: operation must be non-empty\");\n\tif (requestId.length === 0) throw new RangeError(\"remoteCall: requestId must be non-empty\");\n\treturn { operation, requestId, payload };\n}\n\nfunction remoteCallTimeout(\n\trequestId: string,\n\toperation: string | undefined,\n\terror: string,\n): RemoteCallTimeout {\n\tif (requestId.length === 0)\n\t\tthrow new RangeError(\"remoteCall: timeout requestId must be non-empty\");\n\tif (error.length === 0) throw new RangeError(\"remoteCall: timeout error must be non-empty\");\n\treturn { ...(operation === undefined ? {} : { operation }), requestId, error };\n}\n\ninterface RemotePendingRequest {\n\toperation: string;\n\trequestId: string;\n\tseq: number;\n}\n\ninterface RemotePendingState {\n\trequestIds: Set<string>;\n\tbySeq: Map<number, RemotePendingRequest>;\n}\n\nfunction remotePendingState(): RemotePendingState {\n\treturn { requestIds: new Set(), bySeq: new Map() };\n}\n\nfunction remotePendingContains(state: RemotePendingState, requestId: string): boolean {\n\treturn state.requestIds.has(requestId);\n}\n\nfunction remotePendingDuplicate(state: RemotePendingState, request: RemotePendingRequest): boolean {\n\tconst current = remotePendingTakeBySeqPreview(state, request.seq);\n\treturn current?.requestId !== request.requestId && state.requestIds.has(request.requestId);\n}\n\nfunction remotePendingTakeBySeqPreview(\n\tstate: RemotePendingState,\n\tseq: number,\n): RemotePendingRequest | undefined {\n\treturn state.bySeq.get(seq);\n}\n\nfunction remotePendingInsert(state: RemotePendingState, request: RemotePendingRequest): void {\n\tconst existingBySeq = state.bySeq.get(request.seq);\n\tif (existingBySeq !== undefined) {\n\t\tstate.requestIds.delete(existingBySeq.requestId);\n\t}\n\tfor (const [seq, pending] of state.bySeq) {\n\t\tif (pending.requestId === request.requestId && seq !== request.seq) {\n\t\t\tstate.bySeq.delete(seq);\n\t\t\tbreak;\n\t\t}\n\t}\n\tstate.requestIds.add(request.requestId);\n\tstate.bySeq.set(request.seq, request);\n}\n\nfunction remotePendingTakeByRequestId(\n\tstate: RemotePendingState,\n\trequestId: string,\n): RemotePendingRequest | undefined {\n\tif (!state.requestIds.delete(requestId)) return undefined;\n\tlet seq: number | undefined;\n\tlet found: RemotePendingRequest | undefined;\n\tfor (const [candidateSeq, request] of state.bySeq) {\n\t\tif (request.requestId === requestId) {\n\t\t\tseq = candidateSeq;\n\t\t\tfound = request;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (seq !== undefined) state.bySeq.delete(seq);\n\treturn found;\n}\n\nfunction remotePendingTakeBySeq(\n\tstate: RemotePendingState,\n\tseq: number,\n): RemotePendingRequest | undefined {\n\tconst request = state.bySeq.get(seq);\n\tif (request === undefined) return undefined;\n\tstate.bySeq.delete(seq);\n\tstate.requestIds.delete(request.requestId);\n\treturn request;\n}\n\nfunction remotePendingFromReceipt<T>(\n\tstate: RemotePendingState,\n\tenvelope: WireBridgeEnvelope<RemoteCallRequest<T>>,\n): RemotePendingRequest | undefined {\n\tconst bySeq = remotePendingTakeBySeq(state, envelope.metadata.seq);\n\tif (bySeq !== undefined) return bySeq;\n\tconst fallback = pendingRequestFromEnvelope(envelope);\n\tif (fallback === undefined || remotePendingContains(state, fallback.requestId)) {\n\t\treturn undefined;\n\t}\n\treturn fallback;\n}\n\nfunction pendingRequestFromEnvelope<T>(\n\tenvelope: WireBridgeEnvelope<RemoteCallRequest<T>>,\n): RemotePendingRequest | undefined {\n\tif (envelope.payload?.kind !== \"data\") return undefined;\n\tconst request = validateRemoteCallRequest(envelope.payload.value);\n\tif (request === undefined) return undefined;\n\treturn {\n\t\toperation: request.operation,\n\t\trequestId: request.requestId,\n\t\tseq: envelope.metadata.seq,\n\t};\n}\n\nfunction validateRemoteCallRequest<T>(value: unknown): RemoteCallRequest<T> | undefined {\n\tif (!isRecord(value)) return undefined;\n\tif (typeof value.operation !== \"string\" || value.operation.length === 0) return undefined;\n\tif (typeof value.requestId !== \"string\" || value.requestId.length === 0) return undefined;\n\tif (!(\"payload\" in value)) return undefined;\n\treturn {\n\t\toperation: value.operation,\n\t\trequestId: value.requestId,\n\t\tpayload: value.payload as T,\n\t};\n}\n\nfunction validateRemoteCallResponse<T>(value: unknown): RemoteCallResponse<T> | undefined {\n\tif (!isRecord(value)) return undefined;\n\tif (typeof value.operation !== \"string\" || value.operation.length === 0) return undefined;\n\tif (typeof value.requestId !== \"string\" || value.requestId.length === 0) return undefined;\n\tif (value.kind === \"result\" && \"payload\" in value) {\n\t\treturn {\n\t\t\tkind: \"result\",\n\t\t\toperation: value.operation,\n\t\t\trequestId: value.requestId,\n\t\t\tpayload: value.payload as T,\n\t\t};\n\t}\n\tif (value.kind === \"error\" && typeof value.error === \"string\" && value.error.length > 0) {\n\t\treturn {\n\t\t\tkind: \"error\",\n\t\t\toperation: value.operation,\n\t\t\trequestId: value.requestId,\n\t\t\terror: value.error,\n\t\t};\n\t}\n\tif (value.kind === \"status\" && typeof value.status === \"string\" && value.status.length > 0) {\n\t\treturn {\n\t\t\tkind: \"status\",\n\t\t\toperation: value.operation,\n\t\t\trequestId: value.requestId,\n\t\t\tstatus: value.status,\n\t\t};\n\t}\n\treturn undefined;\n}\n\nfunction remoteMalformedResponseRequestId(value: unknown): string | undefined {\n\tif (!isRecord(value)) return undefined;\n\treturn typeof value.requestId === \"string\" && value.requestId.length > 0\n\t\t? value.requestId\n\t\t: undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction isThenable(value: unknown): boolean {\n\treturn isRecord(value) && typeof value.then === \"function\";\n}\n\nfunction remoteCallResponseRequestId<T>(response: RemoteCallResponse<T>): string {\n\treturn response.requestId;\n}\n\nfunction remoteCallResponseIsTerminal<T>(response: RemoteCallResponse<T>): boolean {\n\treturn response.kind === \"result\" || response.kind === \"error\";\n}\n\nfunction remoteCallResponsesNode<TRequest, TResponse>(\n\tgraph: Graph,\n\tevents: Node<WireBridgeEvent<RemoteCallRequest<TRequest>, RemoteCallResponse<TResponse>>>,\n\ttimeouts: Node<RemoteCallTimeout>,\n\tname: string,\n): Node<RemoteCallResponse<TResponse>> {\n\treturn graph.node<RemoteCallResponse<TResponse>>(\n\t\t[events, timeouts],\n\t\t(ctx) => {\n\t\t\ttype State = {\n\t\t\t\tpending: RemotePendingState;\n\t\t\t};\n\t\t\tconst state = ctx.state.get<State>() ?? {\n\t\t\t\tpending: remotePendingState(),\n\t\t\t};\n\t\t\tconst ready: RemoteCallResponse<TResponse>[] = [];\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as WireBridgeEvent<\n\t\t\t\t\tRemoteCallRequest<TRequest>,\n\t\t\t\t\tRemoteCallResponse<TResponse>\n\t\t\t\t>;\n\t\t\t\tif (event.kind === \"outbound\") {\n\t\t\t\t\tconst request = pendingRequestFromEnvelope(event.envelope);\n\t\t\t\t\tif (request === undefined) continue;\n\t\t\t\t\tif (remotePendingDuplicate(state.pending, request)) continue;\n\t\t\t\t\tremotePendingInsert(state.pending, request);\n\t\t\t\t} else if (event.kind === \"inbound\" && event.envelope.payload?.kind === \"data\") {\n\t\t\t\t\tconst response = validateRemoteCallResponse<TResponse>(event.envelope.payload.value);\n\t\t\t\t\tif (response === undefined) {\n\t\t\t\t\t\tconst requestId = remoteMalformedResponseRequestId(event.envelope.payload.value);\n\t\t\t\t\t\tif (requestId !== undefined && remotePendingContains(state.pending, requestId)) {\n\t\t\t\t\t\t\tremotePendingTakeByRequestId(state.pending, requestId);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst requestId = remoteCallResponseRequestId(response);\n\t\t\t\t\tif (remotePendingContains(state.pending, requestId)) {\n\t\t\t\t\t\tif (remoteCallResponseIsTerminal(response)) {\n\t\t\t\t\t\t\tremotePendingTakeByRequestId(state.pending, requestId);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tready.push(response);\n\t\t\t\t\t}\n\t\t\t\t} else if (event.kind === \"nack\") {\n\t\t\t\t\tremotePendingFromReceipt(state.pending, event.outbound);\n\t\t\t\t} else if (event.kind === \"exhausted\") {\n\t\t\t\t\tremotePendingTakeBySeq(state.pending, event.seq);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const raw of depBatch(ctx, 1) ?? []) {\n\t\t\t\tconst timeout = raw as RemoteCallTimeout;\n\t\t\t\tremotePendingTakeByRequestId(state.pending, timeout.requestId);\n\t\t\t}\n\t\t\tctx.state.set(state);\n\t\t\tfor (const response of ready) ctx.down([[\"DATA\", response]]);\n\t\t},\n\t\t{\n\t\t\tname: `${name}/responses`,\n\t\t\tfactory: \"remoteCallResponses\",\n\t\t\tpartial: true,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n}\n\nfunction remoteCallResultsNode<TResponse>(\n\tgraph: Graph,\n\tresponses: Node<RemoteCallResponse<TResponse>>,\n\tname: string,\n): Node<RemoteCallResult<TResponse>> {\n\treturn graph.node<RemoteCallResult<TResponse>>(\n\t\t[responses],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst response = raw as RemoteCallResponse<TResponse>;\n\t\t\t\tif (response.kind === \"result\") {\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\toperation: response.operation,\n\t\t\t\t\t\t\t\trequestId: response.requestId,\n\t\t\t\t\t\t\t\tpayload: response.payload,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/results`, factory: \"remoteCallResults\", completeWhenDepsComplete: false },\n\t);\n}\n\nfunction remoteCallStatusNode<TRequest, TResponse>(\n\tgraph: Graph,\n\tevents: Node<WireBridgeEvent<RemoteCallRequest<TRequest>, RemoteCallResponse<TResponse>>>,\n\tresponses: Node<RemoteCallResponse<TResponse>>,\n\ttimeouts: Node<RemoteCallTimeout>,\n\tname: string,\n): Node<RemoteCallStatus> {\n\treturn graph.node<RemoteCallStatus>(\n\t\t[events, responses, timeouts],\n\t\t(ctx) => {\n\t\t\ttype State = { status: RemoteCallStatus; pending: RemotePendingState };\n\t\t\tconst state =\n\t\t\t\tctx.state.get<State>() ??\n\t\t\t\t({\n\t\t\t\t\tstatus: { state: \"idle\", pending: 0, completed: 0, errors: 0, timeouts: 0 },\n\t\t\t\t\tpending: remotePendingState(),\n\t\t\t\t} satisfies State);\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as WireBridgeEvent<\n\t\t\t\t\tRemoteCallRequest<TRequest>,\n\t\t\t\t\tRemoteCallResponse<TResponse>\n\t\t\t\t>;\n\t\t\t\tif (event.kind === \"outbound\") {\n\t\t\t\t\tconst request = pendingRequestFromEnvelope(event.envelope);\n\t\t\t\t\tif (request !== undefined) {\n\t\t\t\t\t\tif (remotePendingDuplicate(state.pending, request)) {\n\t\t\t\t\t\t\tstate.status = {\n\t\t\t\t\t\t\t\t...state.status,\n\t\t\t\t\t\t\t\tstate: \"errored\",\n\t\t\t\t\t\t\t\toperation: request.operation,\n\t\t\t\t\t\t\t\trequestId: request.requestId,\n\t\t\t\t\t\t\t\terrors: state.status.errors + 1,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tremotePendingInsert(state.pending, request);\n\t\t\t\t\t\tstate.status = {\n\t\t\t\t\t\t\t...state.status,\n\t\t\t\t\t\t\tstate: \"requested\",\n\t\t\t\t\t\t\toperation: request.operation,\n\t\t\t\t\t\t\trequestId: request.requestId,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t} else if (\n\t\t\t\t\tevent.kind === \"invalid\" ||\n\t\t\t\t\tevent.kind === \"session-mismatch\" ||\n\t\t\t\t\tevent.kind === \"out-of-order\" ||\n\t\t\t\t\tevent.kind === \"late-receipt\"\n\t\t\t\t) {\n\t\t\t\t\tstate.status = {\n\t\t\t\t\t\t...state.status,\n\t\t\t\t\t\tstate: \"bridge-errored\",\n\t\t\t\t\t\terrors: state.status.errors + 1,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"nack\") {\n\t\t\t\t\tconst request = remotePendingFromReceipt(state.pending, event.outbound);\n\t\t\t\t\tstate.status = {\n\t\t\t\t\t\t...state.status,\n\t\t\t\t\t\tstate: \"bridge-errored\",\n\t\t\t\t\t\t...(request === undefined\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: { operation: request.operation, requestId: request.requestId }),\n\t\t\t\t\t\terrors: state.status.errors + 1,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"exhausted\") {\n\t\t\t\t\tconst request = remotePendingTakeBySeq(state.pending, event.seq);\n\t\t\t\t\tstate.status = {\n\t\t\t\t\t\t...state.status,\n\t\t\t\t\t\tstate: \"bridge-errored\",\n\t\t\t\t\t\t...(request === undefined\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: { operation: request.operation, requestId: request.requestId }),\n\t\t\t\t\t\terrors: state.status.errors + 1,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"inbound\" && event.envelope.payload?.kind === \"data\") {\n\t\t\t\t\tconst response = validateRemoteCallResponse<TResponse>(event.envelope.payload.value);\n\t\t\t\t\tif (response === undefined) {\n\t\t\t\t\t\tconst requestId = remoteMalformedResponseRequestId(event.envelope.payload.value);\n\t\t\t\t\t\tif (requestId !== undefined) {\n\t\t\t\t\t\t\tconst request = remotePendingTakeByRequestId(state.pending, requestId);\n\t\t\t\t\t\t\tif (request !== undefined) {\n\t\t\t\t\t\t\t\tstate.status = {\n\t\t\t\t\t\t\t\t\t...state.status,\n\t\t\t\t\t\t\t\t\tstate: \"errored\",\n\t\t\t\t\t\t\t\t\toperation: request.operation,\n\t\t\t\t\t\t\t\t\trequestId,\n\t\t\t\t\t\t\t\t\terrors: state.status.errors + 1,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const raw of depBatch(ctx, 1) ?? []) {\n\t\t\t\tconst response = raw as RemoteCallResponse<TResponse>;\n\t\t\t\tif (response.kind === \"result\") {\n\t\t\t\t\tremotePendingTakeByRequestId(state.pending, response.requestId);\n\t\t\t\t\tstate.status = {\n\t\t\t\t\t\t...state.status,\n\t\t\t\t\t\tstate: \"responded\",\n\t\t\t\t\t\toperation: response.operation,\n\t\t\t\t\t\trequestId: response.requestId,\n\t\t\t\t\t\tcompleted: state.status.completed + 1,\n\t\t\t\t\t};\n\t\t\t\t} else if (response.kind === \"error\") {\n\t\t\t\t\tremotePendingTakeByRequestId(state.pending, response.requestId);\n\t\t\t\t\tstate.status = {\n\t\t\t\t\t\t...state.status,\n\t\t\t\t\t\tstate: \"errored\",\n\t\t\t\t\t\toperation: response.operation,\n\t\t\t\t\t\trequestId: response.requestId,\n\t\t\t\t\t\terrors: state.status.errors + 1,\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\tstate.status = {\n\t\t\t\t\t\t...state.status,\n\t\t\t\t\t\toperation: response.operation,\n\t\t\t\t\t\trequestId: response.requestId,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const raw of depBatch(ctx, 2) ?? []) {\n\t\t\t\tconst timeout = raw as RemoteCallTimeout;\n\t\t\t\tremotePendingTakeByRequestId(state.pending, timeout.requestId);\n\t\t\t\tstate.status = {\n\t\t\t\t\t...state.status,\n\t\t\t\t\tstate: \"timed-out\",\n\t\t\t\t\toperation: timeout.operation,\n\t\t\t\t\trequestId: timeout.requestId,\n\t\t\t\t\terrors: state.status.errors + 1,\n\t\t\t\t\ttimeouts: state.status.timeouts + 1,\n\t\t\t\t};\n\t\t\t}\n\t\t\tstate.status = { ...state.status, pending: state.pending.requestIds.size };\n\t\t\tctx.state.set(state);\n\t\t\tctx.down([[\"DATA\", state.status]]);\n\t\t},\n\t\t{\n\t\t\tname: `${name}/status`,\n\t\t\tfactory: \"remoteCallStatus\",\n\t\t\tpartial: true,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n}\n\nfunction remoteCallErrorsNode<TRequest, TResponse>(\n\tgraph: Graph,\n\tresponses: Node<RemoteCallResponse<TResponse>>,\n\ttimeouts: Node<RemoteCallTimeout>,\n\tevents: Node<WireBridgeEvent<RemoteCallRequest<TRequest>, RemoteCallResponse<TResponse>>>,\n\tname: string,\n): Node<RemoteCallError> {\n\treturn graph.node<RemoteCallError>(\n\t\t[responses, timeouts, events],\n\t\t(ctx) => {\n\t\t\tconst pending = ctx.state.get<RemotePendingState>() ?? remotePendingState();\n\t\t\tfor (const raw of depBatch(ctx, 2) ?? []) {\n\t\t\t\tconst event = raw as WireBridgeEvent<\n\t\t\t\t\tRemoteCallRequest<TRequest>,\n\t\t\t\t\tRemoteCallResponse<TResponse>\n\t\t\t\t>;\n\t\t\t\tif (event.kind === \"outbound\") {\n\t\t\t\t\tconst request = pendingRequestFromEnvelope(event.envelope);\n\t\t\t\t\tif (request !== undefined) {\n\t\t\t\t\t\tif (remotePendingDuplicate(pending, request)) {\n\t\t\t\t\t\t\tctx.down([\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\toperation: request.operation,\n\t\t\t\t\t\t\t\t\t\trequestId: request.requestId,\n\t\t\t\t\t\t\t\t\t\terror: `remoteCall: duplicate in-flight requestId '${request.requestId}'`,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tremotePendingInsert(pending, request);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst response = raw as RemoteCallResponse<TResponse>;\n\t\t\t\tif (response.kind === \"error\") {\n\t\t\t\t\tremotePendingTakeByRequestId(pending, response.requestId);\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\toperation: response.operation,\n\t\t\t\t\t\t\t\trequestId: response.requestId,\n\t\t\t\t\t\t\t\terror: response.error,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t} else if (response.kind === \"result\") {\n\t\t\t\t\tremotePendingTakeByRequestId(pending, response.requestId);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const raw of depBatch(ctx, 1) ?? []) {\n\t\t\t\tconst timeout = raw as RemoteCallTimeout;\n\t\t\t\tremotePendingTakeByRequestId(pending, timeout.requestId);\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t{ operation: timeout.operation, requestId: timeout.requestId, error: timeout.error },\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t}\n\t\t\tfor (const raw of depBatch(ctx, 2) ?? []) {\n\t\t\t\tconst event = raw as WireBridgeEvent<\n\t\t\t\t\tRemoteCallRequest<TRequest>,\n\t\t\t\t\tRemoteCallResponse<TResponse>\n\t\t\t\t>;\n\t\t\t\tif (event.kind === \"inbound\" && event.envelope.payload?.kind === \"data\") {\n\t\t\t\t\tconst response = validateRemoteCallResponse<TResponse>(event.envelope.payload.value);\n\t\t\t\t\tif (response === undefined) {\n\t\t\t\t\t\tconst requestId = remoteMalformedResponseRequestId(event.envelope.payload.value);\n\t\t\t\t\t\tconst request =\n\t\t\t\t\t\t\trequestId === undefined\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: remotePendingTakeByRequestId(pending, requestId);\n\t\t\t\t\t\tif (request === undefined) continue;\n\t\t\t\t\t\tctx.down([\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\toperation: request.operation,\n\t\t\t\t\t\t\t\t\trequestId: request.requestId,\n\t\t\t\t\t\t\t\t\terror: \"remoteCall: response payload is malformed\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t]);\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (event.kind === \"nack\") {\n\t\t\t\t\tconst request = remotePendingFromReceipt(pending, event.outbound);\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\toperation: request?.operation,\n\t\t\t\t\t\t\t\trequestId: request?.requestId,\n\t\t\t\t\t\t\t\terror: String(event.error),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t} else if (event.kind === \"exhausted\") {\n\t\t\t\t\tconst request = remotePendingTakeBySeq(pending, event.seq);\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\toperation: request?.operation,\n\t\t\t\t\t\t\t\trequestId: request?.requestId,\n\t\t\t\t\t\t\t\terror: String(event.error),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t} else if (event.kind === \"invalid\") {\n\t\t\t\t\tctx.down([[\"DATA\", { error: event.error }]]);\n\t\t\t\t} else if (\n\t\t\t\t\tevent.kind === \"session-mismatch\" ||\n\t\t\t\t\tevent.kind === \"out-of-order\" ||\n\t\t\t\t\tevent.kind === \"late-receipt\"\n\t\t\t\t) {\n\t\t\t\t\tctx.down([[\"DATA\", { error: remoteCallBridgeErrorMessage(event) }]]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.state.set(pending);\n\t\t},\n\t\t{\n\t\t\tname: `${name}/errors`,\n\t\t\tfactory: \"remoteCallErrors\",\n\t\t\tpartial: true,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n}\n\nfunction remoteCallBridgeErrorMessage<TRequest, TResponse>(\n\tevent: WireBridgeEvent<RemoteCallRequest<TRequest>, RemoteCallResponse<TResponse>>,\n): string {\n\tif (event.kind === \"session-mismatch\") {\n\t\treturn `remoteCall: inbound session ${event.actual} did not match expected ${event.expected}`;\n\t}\n\tif (event.kind === \"out-of-order\") {\n\t\treturn `remoteCall: inbound seq ${event.seq} arrived before expected seq ${event.expected}`;\n\t}\n\tif (event.kind === \"late-receipt\") {\n\t\treturn `remoteCall: late ${event.receipt} for unknown or completed ackForSeq ${event.ackForSeq}`;\n\t}\n\treturn \"remoteCall: bridge error\";\n}\n\nfunction normalizeRemoteHandlers<TRequest, TResponse>(\n\thandlers: readonly RemoteResponderHandlerDefinition<TRequest, TResponse>[],\n): Map<string, RemoteResponderHandler<TRequest, TResponse>> {\n\tconst out = new Map<string, RemoteResponderHandler<TRequest, TResponse>>();\n\tfor (const handler of handlers) {\n\t\tif (handler.operation.length === 0) {\n\t\t\tthrow new RangeError(\"remoteResponder: operation must be non-empty\");\n\t\t}\n\t\tif (out.has(handler.operation)) {\n\t\t\tthrow new RangeError(`remoteResponder: duplicate operation '${handler.operation}'`);\n\t\t}\n\t\tout.set(handler.operation, handler.handle);\n\t}\n\treturn out;\n}\n\ninterface RemoteResponderCursor {\n\tcursor: number;\n\tremoteCursor: number;\n}\n\ntype RemoteResponderInbound<T> =\n\t| { readonly kind: \"request\"; readonly request: RemoteCallRequest<T>; readonly seq: number }\n\t| { readonly kind: \"consumed\" }\n\t| { readonly kind: \"invalid\"; readonly error: string };\n\nfunction reduceRemoteResponderInbound<T>(\n\tcursor: RemoteResponderCursor,\n\tenvelope: WireBridgeEnvelope<RemoteCallRequest<T>>,\n\texpectedSessionId: string,\n): RemoteResponderInbound<T> {\n\tconst envelopeError = validateInboundEnvelope(envelope);\n\tif (envelopeError !== undefined) {\n\t\treturn { kind: \"invalid\", error: envelopeError };\n\t}\n\tif (envelope.sessionId !== expectedSessionId) {\n\t\treturn {\n\t\t\tkind: \"invalid\",\n\t\t\terror: `remoteResponder: inbound session ${envelope.sessionId} did not match expected ${expectedSessionId}`,\n\t\t};\n\t}\n\tconst seq = envelope.metadata.seq;\n\tconst expected = cursor.cursor + 1;\n\tif (seq <= cursor.cursor) {\n\t\treturn {\n\t\t\tkind: \"invalid\",\n\t\t\terror: `remoteResponder: duplicate request seq ${seq} at cursor ${cursor.cursor}`,\n\t\t};\n\t}\n\tif (seq > expected) {\n\t\treturn {\n\t\t\tkind: \"invalid\",\n\t\t\terror: `remoteResponder: out-of-order request seq ${seq}, expected ${expected}`,\n\t\t};\n\t}\n\tif (envelope.metadata.cursor < cursor.remoteCursor) {\n\t\treturn {\n\t\t\tkind: \"invalid\",\n\t\t\terror: `${envelope.sessionId}: remoteResponder inbound cursor ${envelope.metadata.cursor} regressed below ${cursor.remoteCursor}`,\n\t\t};\n\t}\n\tcursor.cursor = seq;\n\tcursor.remoteCursor = envelope.metadata.cursor;\n\tif (envelope.type !== \"data\") return { kind: \"consumed\" };\n\tif (envelope.payload?.kind !== \"data\") {\n\t\treturn { kind: \"invalid\", error: \"remoteResponder: request envelope must carry request DATA\" };\n\t}\n\tconst request = validateRemoteCallRequest<T>(envelope.payload.value);\n\tif (request === undefined) {\n\t\treturn { kind: \"invalid\", error: \"remoteResponder: request payload is malformed\" };\n\t}\n\treturn { kind: \"request\", request, seq };\n}\n\nfunction remoteResponderEventsNode<TRequest, TResponse>(\n\tgraph: Graph,\n\tinbound: Node<WireBridgeEnvelope<RemoteCallRequest<TRequest>> | WireBridgeInvalidIngress>,\n\tname: string,\n\texpectedSessionId: string,\n\thandlers: Map<string, RemoteResponderHandler<TRequest, TResponse>>,\n\trejectUnknown: boolean,\n): Node<RemoteResponderEvent<TRequest, TResponse>> {\n\treturn graph.node<RemoteResponderEvent<TRequest, TResponse>>(\n\t\t[inbound],\n\t\t(ctx) => {\n\t\t\tconst cursor = ctx.state.get<RemoteResponderCursor>() ?? { cursor: 0, remoteCursor: 0 };\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst envelope = raw as WireBridgeEnvelope<RemoteCallRequest<TRequest>>;\n\t\t\t\tconst received = reduceRemoteResponderInbound(cursor, envelope, expectedSessionId);\n\t\t\t\tif (received.kind === \"consumed\") continue;\n\t\t\t\tif (received.kind === \"invalid\") {\n\t\t\t\t\tctx.down([[\"DATA\", { kind: \"invalid\", error: received.error }]]);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst { request, seq } = received;\n\t\t\t\tctx.down([[\"DATA\", { kind: \"request\", request, seq }]]);\n\t\t\t\tconst handler = handlers.get(request.operation);\n\t\t\t\tif (handler === undefined) {\n\t\t\t\t\tif (!rejectUnknown) continue;\n\t\t\t\t\tconst error = `remoteResponder: unknown operation '${request.operation}'`;\n\t\t\t\t\tconst response = remoteCallErrorResponse(request, error);\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"rejected\",\n\t\t\t\t\t\t\t\trequestId: request.requestId,\n\t\t\t\t\t\t\t\toperation: request.operation,\n\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t\tcommand: { kind: \"send\", payload: response, requestId: request.requestId },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst payload = handler(request);\n\t\t\t\t\tif (isThenable(payload)) {\n\t\t\t\t\t\tthrow new Error(\"remoteResponder: async handler results require a later adapter shape\");\n\t\t\t\t\t}\n\t\t\t\t\tconst response = {\n\t\t\t\t\t\tkind: \"result\",\n\t\t\t\t\t\toperation: request.operation,\n\t\t\t\t\t\trequestId: request.requestId,\n\t\t\t\t\t\tpayload,\n\t\t\t\t\t} satisfies RemoteCallResponse<TResponse>;\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"response\",\n\t\t\t\t\t\t\t\trequestId: request.requestId,\n\t\t\t\t\t\t\t\toperation: request.operation,\n\t\t\t\t\t\t\t\tcommand: { kind: \"send\", payload: response, requestId: request.requestId },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t} catch (error) {\n\t\t\t\t\trethrowGraphRuntimeInvariant(error);\n\t\t\t\t\tconst message = errorMessage(error);\n\t\t\t\t\tconst response = remoteCallErrorResponse(request, message);\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"rejected\",\n\t\t\t\t\t\t\t\trequestId: request.requestId,\n\t\t\t\t\t\t\t\toperation: request.operation,\n\t\t\t\t\t\t\t\terror: message,\n\t\t\t\t\t\t\t\tcommand: { kind: \"send\", payload: response, requestId: request.requestId },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.state.set(cursor);\n\t\t},\n\t\t{\n\t\t\tname: `${name}/events`,\n\t\t\tfactory: \"remoteResponderEvents\",\n\t\t\tpartial: true,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n}\n\nfunction remoteCallErrorResponse<TRequest, TResponse>(\n\trequest: RemoteCallRequest<TRequest>,\n\terror: string,\n): RemoteCallResponse<TResponse> {\n\treturn {\n\t\tkind: \"error\",\n\t\toperation: request.operation,\n\t\trequestId: request.requestId,\n\t\terror,\n\t};\n}\n\nfunction remoteResponderResponseCommandsNode<TRequest, TResponse>(\n\tgraph: Graph,\n\tevents: Node<RemoteResponderEvent<TRequest, TResponse>>,\n\tname: string,\n): Node<WireBridgeCommand<RemoteCallResponse<TResponse>>> {\n\treturn graph.node<WireBridgeCommand<RemoteCallResponse<TResponse>>>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as RemoteResponderEvent<TRequest, TResponse>;\n\t\t\t\tif (\n\t\t\t\t\t(event.kind === \"response\" || event.kind === \"rejected\") &&\n\t\t\t\t\tevent.command !== undefined\n\t\t\t\t) {\n\t\t\t\t\tctx.down([[\"DATA\", event.command]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/responseCommands`,\n\t\t\tfactory: \"remoteResponderResponseCommands\",\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n}\n\nfunction remoteResponderRequestsNode<TRequest, TResponse>(\n\tgraph: Graph,\n\tevents: Node<RemoteResponderEvent<TRequest, TResponse>>,\n\tname: string,\n): Node<RemoteCallRequest<TRequest>> {\n\treturn graph.node<RemoteCallRequest<TRequest>>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as RemoteResponderEvent<TRequest, TResponse>;\n\t\t\t\tif (event.kind === \"request\") ctx.down([[\"DATA\", event.request]]);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/requests`,\n\t\t\tfactory: \"remoteResponderRequests\",\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t},\n\t);\n}\n\nfunction remoteResponderStatusNode<TRequest, TResponse>(\n\tgraph: Graph,\n\tevents: Node<RemoteResponderEvent<TRequest, TResponse>>,\n\tname: string,\n): Node<RemoteResponderStatus> {\n\treturn graph.node<RemoteResponderStatus>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tlet status =\n\t\t\t\tctx.state.get<RemoteResponderStatus>() ??\n\t\t\t\t({ state: \"idle\", handled: 0, rejected: 0, errors: 0 } satisfies RemoteResponderStatus);\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as RemoteResponderEvent<TRequest, TResponse>;\n\t\t\t\tif (event.kind === \"response\") {\n\t\t\t\t\tstatus = {\n\t\t\t\t\t\t...status,\n\t\t\t\t\t\tstate: \"responded\",\n\t\t\t\t\t\toperation: event.operation,\n\t\t\t\t\t\trequestId: event.requestId,\n\t\t\t\t\t\thandled: status.handled + 1,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"rejected\") {\n\t\t\t\t\tstatus = {\n\t\t\t\t\t\t...status,\n\t\t\t\t\t\tstate: \"rejected\",\n\t\t\t\t\t\toperation: event.operation,\n\t\t\t\t\t\trequestId: event.requestId,\n\t\t\t\t\t\trejected: status.rejected + 1,\n\t\t\t\t\t\terrors: status.errors + 1,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"invalid\") {\n\t\t\t\t\tstatus = { ...status, state: \"errored\", errors: status.errors + 1 };\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.state.set(status);\n\t\t\tctx.down([[\"DATA\", status]]);\n\t\t},\n\t\t{\n\t\t\tname: `${name}/status`,\n\t\t\tfactory: \"remoteResponderStatus\",\n\t\t\tpartial: true,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n}\n\nfunction remoteResponderErrorsNode<TRequest, TResponse>(\n\tgraph: Graph,\n\tevents: Node<RemoteResponderEvent<TRequest, TResponse>>,\n\tname: string,\n): Node<RemoteCallError> {\n\treturn graph.node<RemoteCallError>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as RemoteResponderEvent<TRequest, TResponse>;\n\t\t\t\tif (event.kind === \"rejected\") {\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{ operation: event.operation, requestId: event.requestId, error: event.error },\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t} else if (event.kind === \"invalid\") {\n\t\t\t\t\tctx.down([[\"DATA\", { error: event.error }]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/errors`, factory: \"remoteResponderErrors\", completeWhenDepsComplete: false },\n\t);\n}\n\nfunction armAckTimeout<TPayload>(\n\tctx: Ctx,\n\tstate: BridgeState<TPayload>,\n\tenvelope: WireBridgeEnvelope<TPayload>,\n\topts: WireBridgeOptions,\n\tpolicy: RetryPolicy,\n\tnow: () => number,\n): void {\n\tconst timeoutMs = opts.ackTimeoutMs ?? defaultAckTimeoutMs;\n\tif (!Number.isFinite(timeoutMs) || timeoutMs < 0) {\n\t\tthrow new RangeError(\"wireBridge: ackTimeoutMs must be a non-negative finite number\");\n\t}\n\tconst pending: PendingEnvelope<TPayload> = { envelope };\n\tconst schedule = (current: WireBridgeEnvelope<TPayload>) => {\n\t\tpending.timer = setTimeout(() => {\n\t\t\tpending.timer = undefined;\n\t\t\tif (!state.active || !state.pending.has(current.metadata.seq)) return;\n\t\t\tctx.down([\n\t\t\t\t[\n\t\t\t\t\t\"DATA\",\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: \"timeout\",\n\t\t\t\t\t\tseq: current.metadata.seq,\n\t\t\t\t\t\tattempt: current.metadata.attempt,\n\t\t\t\t\t} satisfies WireBridgeEvent<TPayload, unknown>,\n\t\t\t\t],\n\t\t\t]);\n\t\t\tif (!shouldRetry(policy, current.metadata.attempt)) {\n\t\t\t\tconst error = `${opts.sessionId}: ack timeout for seq ${current.metadata.seq}`;\n\t\t\t\tstate.pending.delete(current.metadata.seq);\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"exhausted\",\n\t\t\t\t\t\t\tseq: current.metadata.seq,\n\t\t\t\t\t\t\tattempt: current.metadata.attempt,\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t} satisfies WireBridgeEvent<TPayload, unknown>,\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst attempt = current.metadata.attempt + 1;\n\t\t\tconst delayMs = nextRetryDelayMs(policy, attempt) ?? 0;\n\t\t\tctx.down([\n\t\t\t\t[\n\t\t\t\t\t\"DATA\",\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: \"retry\",\n\t\t\t\t\t\tseq: current.metadata.seq,\n\t\t\t\t\t\tattempt,\n\t\t\t\t\t\tdelayMs,\n\t\t\t\t\t\terror: `${opts.sessionId}: ack timeout for seq ${current.metadata.seq}`,\n\t\t\t\t\t} satisfies WireBridgeEvent<TPayload, unknown>,\n\t\t\t\t],\n\t\t\t]);\n\t\t\tconst retry = wireBridgeEnvelope<TPayload>({\n\t\t\t\tsessionId: current.sessionId,\n\t\t\t\ttype: current.type,\n\t\t\t\tseq: current.metadata.seq,\n\t\t\t\tcursor: state.cursor,\n\t\t\t\tpayload: current.payload,\n\t\t\t\tidempotencyKey: current.metadata.idempotencyKey,\n\t\t\t\tattempt,\n\t\t\t\tmaxAttempts: policy.maxAttempts,\n\t\t\t\ttimestampMs: now(),\n\t\t\t\trequestId: current.metadata.requestId,\n\t\t\t});\n\t\t\tpending.timer = setTimeout(() => {\n\t\t\t\tpending.timer = undefined;\n\t\t\t\tif (!state.active || !state.pending.has(current.metadata.seq)) return;\n\t\t\t\tpending.envelope = retry;\n\t\t\t\tctx.down([[\"DATA\", { kind: \"outbound\", envelope: retry }]]);\n\t\t\t\tschedule(retry);\n\t\t\t}, delayMs);\n\t\t}, timeoutMs);\n\t};\n\tstate.pending.set(envelope.metadata.seq, pending);\n\tschedule(envelope);\n}\n\nfunction processInbound<TOutbound, TInbound>(\n\tctx: Ctx,\n\tstate: BridgeState<TOutbound>,\n\tinput: unknown,\n\tsessionId: string,\n): void {\n\tif (isInvalidIngress(input)) {\n\t\tctx.down([[\"DATA\", { kind: \"invalid\", error: input.error }]]);\n\t\treturn;\n\t}\n\tconst invalid = validateInboundEnvelope(input);\n\tif (invalid !== undefined) {\n\t\tctx.down([[\"DATA\", { kind: \"invalid\", error: invalid }]]);\n\t\treturn;\n\t}\n\tconst envelope = input as WireBridgeEnvelope<TInbound>;\n\tif (envelope.sessionId !== sessionId) {\n\t\tctx.down([\n\t\t\t[\n\t\t\t\t\"DATA\",\n\t\t\t\t{\n\t\t\t\t\tkind: \"session-mismatch\",\n\t\t\t\t\texpected: sessionId,\n\t\t\t\t\tactual: envelope.sessionId,\n\t\t\t\t} satisfies WireBridgeEvent<TOutbound, TInbound>,\n\t\t\t],\n\t\t]);\n\t\treturn;\n\t}\n\tconst seq = envelope.metadata.seq;\n\tconst expected = state.cursor + 1;\n\tif (seq <= state.cursor) {\n\t\tctx.down([[\"DATA\", { kind: \"duplicate\", seq, cursor: state.cursor }]]);\n\t\treturn;\n\t}\n\tif (seq > expected) {\n\t\tctx.down([[\"DATA\", { kind: \"out-of-order\", seq, expected }]]);\n\t\treturn;\n\t}\n\tif (envelope.metadata.cursor < state.remoteCursor) {\n\t\tctx.down([\n\t\t\t[\n\t\t\t\t\"DATA\",\n\t\t\t\t{\n\t\t\t\t\tkind: \"invalid\",\n\t\t\t\t\terror: `${sessionId}: inbound cursor ${envelope.metadata.cursor} regressed below ${state.remoteCursor}`,\n\t\t\t\t},\n\t\t\t],\n\t\t]);\n\t\treturn;\n\t}\n\tstate.remoteCursor = envelope.metadata.cursor;\n\tstate.cursor = seq;\n\tctx.down([[\"DATA\", { kind: \"cursor\", cursor: state.cursor }]]);\n\tctx.down([[\"DATA\", { kind: \"inbound\", envelope }]]);\n\tif (envelope.type === \"ack\" && envelope.metadata.ackForSeq !== undefined) {\n\t\tconst pending = state.pending.get(envelope.metadata.ackForSeq);\n\t\tif (pending === undefined) {\n\t\t\tctx.down([\n\t\t\t\t[\"DATA\", { kind: \"late-receipt\", receipt: \"ack\", ackForSeq: envelope.metadata.ackForSeq }],\n\t\t\t]);\n\t\t\treturn;\n\t\t}\n\t\tif (pending?.timer !== undefined) clearTimeout(pending.timer);\n\t\tstate.pending.delete(envelope.metadata.ackForSeq);\n\t\tctx.down([\n\t\t\t[\n\t\t\t\t\"DATA\",\n\t\t\t\t{\n\t\t\t\t\tkind: \"ack\",\n\t\t\t\t\tackForSeq: envelope.metadata.ackForSeq,\n\t\t\t\t\tenvelope,\n\t\t\t\t\toutbound: pending.envelope,\n\t\t\t\t} satisfies WireBridgeEvent<TOutbound, TInbound>,\n\t\t\t],\n\t\t]);\n\t} else if (envelope.type === \"nack\" && envelope.metadata.ackForSeq !== undefined) {\n\t\tconst pending = state.pending.get(envelope.metadata.ackForSeq);\n\t\tif (pending === undefined) {\n\t\t\tctx.down([\n\t\t\t\t[\"DATA\", { kind: \"late-receipt\", receipt: \"nack\", ackForSeq: envelope.metadata.ackForSeq }],\n\t\t\t]);\n\t\t\treturn;\n\t\t}\n\t\tif (pending?.timer !== undefined) clearTimeout(pending.timer);\n\t\tstate.pending.delete(envelope.metadata.ackForSeq);\n\t\tctx.down([\n\t\t\t[\n\t\t\t\t\"DATA\",\n\t\t\t\t{\n\t\t\t\t\tkind: \"nack\",\n\t\t\t\t\tackForSeq: envelope.metadata.ackForSeq,\n\t\t\t\t\tenvelope,\n\t\t\t\t\toutbound: pending.envelope,\n\t\t\t\t\terror: bridgePayloadError(envelope.payload, \"remote nack\"),\n\t\t\t\t} satisfies WireBridgeEvent<TOutbound, TInbound>,\n\t\t\t],\n\t\t]);\n\t}\n}\n\nfunction validateInboundEnvelope(envelope: unknown): string | undefined {\n\tif (typeof envelope !== \"object\" || envelope === null) {\n\t\treturn \"wireBridge: inbound envelope must be an object\";\n\t}\n\tconst candidate = envelope as Partial<WireBridgeEnvelope<unknown>>;\n\tif (typeof candidate.sessionId !== \"string\" || candidate.sessionId.length === 0) {\n\t\treturn \"wireBridge: inbound envelope sessionId must be a non-empty string\";\n\t}\n\tif (\n\t\ttypeof candidate.type !== \"string\" ||\n\t\t!envelopeTypes.has(candidate.type as WireBridgeEnvelopeType)\n\t) {\n\t\treturn \"wireBridge: inbound envelope type is not recognized\";\n\t}\n\tconst metadata = candidate.metadata as Partial<WireBridgeMetadata> | undefined;\n\tif (typeof metadata !== \"object\" || metadata === null) {\n\t\treturn \"wireBridge: inbound envelope metadata must be an object\";\n\t}\n\tif (!isSafePositiveInteger(metadata.seq)) {\n\t\treturn \"wireBridge: inbound envelope seq must be a positive integer\";\n\t}\n\tif (!isSafeNonNegativeInteger(metadata.cursor)) {\n\t\treturn \"wireBridge: inbound envelope cursor must be a non-negative integer\";\n\t}\n\tif (\n\t\ttypeof metadata.idempotencyKey !== \"string\" ||\n\t\t(metadata.idempotencyKey as string).length === 0\n\t) {\n\t\treturn \"wireBridge: inbound envelope idempotencyKey must be a non-empty string\";\n\t}\n\tif (!isSafePositiveInteger(metadata.attempt)) {\n\t\treturn \"wireBridge: inbound envelope attempt must be a positive integer\";\n\t}\n\tif (\n\t\t!isSafePositiveInteger(metadata.maxAttempts) ||\n\t\t(metadata.maxAttempts as number) < (metadata.attempt as number)\n\t) {\n\t\treturn \"wireBridge: inbound envelope maxAttempts must be >= attempt\";\n\t}\n\tif (metadata.ackForSeq !== undefined && !isSafePositiveInteger(metadata.ackForSeq)) {\n\t\treturn \"wireBridge: inbound envelope ackForSeq must be a positive integer\";\n\t}\n\tif ((candidate.type === \"ack\" || candidate.type === \"nack\") && metadata.ackForSeq === undefined) {\n\t\treturn `wireBridge: inbound ${candidate.type} envelope requires ackForSeq`;\n\t}\n\tconst payloadError = validatePayloadForType(\n\t\tcandidate.type as WireBridgeEnvelopeType,\n\t\tcandidate.payload,\n\t\t\"wireBridge: inbound envelope\",\n\t);\n\tif (payloadError !== undefined) return payloadError;\n\treturn undefined;\n}\n\nfunction validateCommand(value: unknown): string | undefined {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn \"wireBridge: command fact must be an object\";\n\t}\n\tconst kind = (value as { readonly kind?: unknown }).kind;\n\tif (\n\t\tkind !== \"start\" &&\n\t\tkind !== \"send\" &&\n\t\tkind !== \"ack\" &&\n\t\tkind !== \"nack\" &&\n\t\tkind !== \"close\"\n\t) {\n\t\treturn \"wireBridge: command kind is not recognized\";\n\t}\n\tif (\n\t\t(kind === \"ack\" || kind === \"nack\") &&\n\t\t!isSafePositiveInteger((value as { readonly ackForSeq?: unknown }).ackForSeq)\n\t) {\n\t\treturn `wireBridge: ${kind} command ackForSeq must be a positive integer`;\n\t}\n\treturn undefined;\n}\n\nfunction projectOutbound<TOutbound, TInbound>(\n\tgraph: Graph,\n\tevents: Node<WireBridgeEvent<TOutbound, TInbound>>,\n\tname: string,\n): Node<WireBridgeEnvelope<TOutbound>> {\n\treturn graph.node<WireBridgeEnvelope<TOutbound>>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as WireBridgeEvent<TOutbound, TInbound>;\n\t\t\t\tif (event.kind === \"outbound\") ctx.down([[\"DATA\", event.envelope]]);\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/outbound`, factory: \"wireBridgeOutbound\" },\n\t);\n}\n\nfunction projectAcks<TOutbound, TInbound>(\n\tgraph: Graph,\n\tevents: Node<WireBridgeEvent<TOutbound, TInbound>>,\n\tname: string,\n): Node<WireBridgeAck> {\n\treturn graph.node<WireBridgeAck>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as WireBridgeEvent<TOutbound, TInbound>;\n\t\t\t\tif (event.kind === \"ack\") {\n\t\t\t\t\tctx.down([[\"DATA\", { ackForSeq: event.ackForSeq, envelope: event.envelope }]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/acks`, factory: \"wireBridgeAcks\" },\n\t);\n}\n\nfunction projectNacks<TOutbound, TInbound>(\n\tgraph: Graph,\n\tevents: Node<WireBridgeEvent<TOutbound, TInbound>>,\n\tname: string,\n): Node<WireBridgeNack> {\n\treturn graph.node<WireBridgeNack>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as WireBridgeEvent<TOutbound, TInbound>;\n\t\t\t\tif (event.kind === \"nack\") {\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\"DATA\", { ackForSeq: event.ackForSeq, envelope: event.envelope, error: event.error }],\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/nacks`, factory: \"wireBridgeNacks\" },\n\t);\n}\n\nfunction projectStatus<TOutbound, TInbound>(\n\tgraph: Graph,\n\tevents: Node<WireBridgeEvent<TOutbound, TInbound>>,\n\tname: string,\n\tsessionId: string,\n): Node<WireBridgeStatus> {\n\treturn graph.node<WireBridgeStatus>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tlet next =\n\t\t\t\tctx.state.get<WireBridgeStatus>() ??\n\t\t\t\t({\n\t\t\t\t\tsessionId,\n\t\t\t\t\tstate: \"idle\",\n\t\t\t\t\tcursor: 0,\n\t\t\t\t\tnextSeq: 1,\n\t\t\t\t\tpending: 0,\n\t\t\t\t\tattempts: 0,\n\t\t\t\t\tacked: 0,\n\t\t\t\t\tnacked: 0,\n\t\t\t\t\terrors: 0,\n\t\t\t\t} satisfies WireBridgeStatus);\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as WireBridgeEvent<TOutbound, TInbound>;\n\t\t\t\tif (event.kind === \"outbound\") {\n\t\t\t\t\tconst { seq, attempt } = event.envelope.metadata;\n\t\t\t\t\tconst trackAck = shouldTrackAck(event.envelope.type);\n\t\t\t\t\tnext = {\n\t\t\t\t\t\t...next,\n\t\t\t\t\t\tstate:\n\t\t\t\t\t\t\tevent.envelope.type === \"start\"\n\t\t\t\t\t\t\t\t? \"started\"\n\t\t\t\t\t\t\t\t: event.envelope.type === \"close\"\n\t\t\t\t\t\t\t\t\t? \"closed\"\n\t\t\t\t\t\t\t\t\t: \"open\",\n\t\t\t\t\t\tnextSeq: Math.max(next.nextSeq, seq + 1),\n\t\t\t\t\t\tpending:\n\t\t\t\t\t\t\tevent.envelope.type === \"close\"\n\t\t\t\t\t\t\t\t? 1\n\t\t\t\t\t\t\t\t: trackAck && attempt === 1\n\t\t\t\t\t\t\t\t\t? next.pending + 1\n\t\t\t\t\t\t\t\t\t: next.pending,\n\t\t\t\t\t\tattempts: trackAck ? next.attempts + 1 : next.attempts,\n\t\t\t\t\t\tlastSeq: seq,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"ack\") {\n\t\t\t\t\tnext = {\n\t\t\t\t\t\t...next,\n\t\t\t\t\t\tstate: event.outbound.type === \"close\" ? \"closed\" : \"open\",\n\t\t\t\t\t\tpending: Math.max(0, next.pending - 1),\n\t\t\t\t\t\tacked: next.acked + 1,\n\t\t\t\t\t\tlastSeq: event.envelope.metadata.seq,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"nack\") {\n\t\t\t\t\tnext = {\n\t\t\t\t\t\t...next,\n\t\t\t\t\t\tstate: \"errored\",\n\t\t\t\t\t\tpending: Math.max(0, next.pending - 1),\n\t\t\t\t\t\tnacked: next.nacked + 1,\n\t\t\t\t\t\terrors: next.errors + 1,\n\t\t\t\t\t\tlastSeq: event.envelope.metadata.seq,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"retry\") {\n\t\t\t\t\tnext = {\n\t\t\t\t\t\t...next,\n\t\t\t\t\t\tstate: \"waiting\",\n\t\t\t\t\t\tlastSeq: event.seq,\n\t\t\t\t\t\tlastDelayMs: event.delayMs,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"exhausted\") {\n\t\t\t\t\tnext = {\n\t\t\t\t\t\t...next,\n\t\t\t\t\t\tstate: \"exhausted\",\n\t\t\t\t\t\tpending: Math.max(0, next.pending - 1),\n\t\t\t\t\t\terrors: next.errors + 1,\n\t\t\t\t\t\tlastSeq: event.seq,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"cursor\") {\n\t\t\t\t\tnext = { ...next, cursor: event.cursor };\n\t\t\t\t} else if (event.kind === \"out-of-order\") {\n\t\t\t\t\tnext = { ...next, state: \"errored\", errors: next.errors + 1, lastSeq: event.seq };\n\t\t\t\t} else if (event.kind === \"session-mismatch\") {\n\t\t\t\t\tnext = { ...next, state: \"errored\", errors: next.errors + 1 };\n\t\t\t\t} else if (event.kind === \"late-receipt\" || event.kind === \"invalid\") {\n\t\t\t\t\tnext = { ...next, state: \"errored\", errors: next.errors + 1 };\n\t\t\t\t} else if (event.kind === \"inbound\" && event.envelope.type === \"error\") {\n\t\t\t\t\tnext = {\n\t\t\t\t\t\t...next,\n\t\t\t\t\t\tstate: \"errored\",\n\t\t\t\t\t\terrors: next.errors + 1,\n\t\t\t\t\t\tlastSeq: event.envelope.metadata.seq,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"inbound\" && event.envelope.type === \"close\") {\n\t\t\t\t\tnext = { ...next, state: \"closed\", lastSeq: event.envelope.metadata.seq };\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.state.set(next);\n\t\t\tctx.down([[\"DATA\", next]]);\n\t\t},\n\t\t{ name: `${name}/status`, factory: \"wireBridgeStatus\" },\n\t);\n}\n\nfunction projectErrors<TOutbound, TInbound>(\n\tgraph: Graph,\n\tevents: Node<WireBridgeEvent<TOutbound, TInbound>>,\n\tname: string,\n): Node<unknown> {\n\treturn graph.node<unknown>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as WireBridgeEvent<TOutbound, TInbound>;\n\t\t\t\tif (event.kind === \"nack\") ctx.down([[\"DATA\", event.error]]);\n\t\t\t\telse if (event.kind === \"exhausted\") ctx.down([[\"DATA\", event.error]]);\n\t\t\t\telse if (event.kind === \"out-of-order\") {\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t`${name}: inbound seq ${event.seq} arrived before expected seq ${event.expected}`,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t} else if (event.kind === \"inbound\" && event.envelope.type === \"error\") {\n\t\t\t\t\tctx.down([[\"DATA\", bridgePayloadError(event.envelope.payload, \"remote error envelope\")]]);\n\t\t\t\t} else if (event.kind === \"session-mismatch\") {\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t`${name}: inbound session ${event.actual} did not match expected ${event.expected}`,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t} else if (event.kind === \"late-receipt\") {\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t`${name}: late ${event.receipt} for unknown or completed ackForSeq ${event.ackForSeq}`,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t} else if (event.kind === \"invalid\") {\n\t\t\t\t\tctx.down([[\"DATA\", event.error]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/errors`, factory: \"wireBridgeErrors\" },\n\t);\n}\n\nfunction projectCursor<TOutbound, TInbound>(\n\tgraph: Graph,\n\tevents: Node<WireBridgeEvent<TOutbound, TInbound>>,\n\tname: string,\n): Node<number> {\n\treturn graph.node<number>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as WireBridgeEvent<TOutbound, TInbound>;\n\t\t\t\tif (event.kind === \"cursor\") ctx.down([[\"DATA\", event.cursor]]);\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/cursor`, factory: \"wireBridgeCursor\" },\n\t);\n}\n\nfunction projectAttempts<TOutbound, TInbound>(\n\tgraph: Graph,\n\tevents: Node<WireBridgeEvent<TOutbound, TInbound>>,\n\tname: string,\n): Node<WireBridgeAttempt> {\n\treturn graph.node<WireBridgeAttempt>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as WireBridgeEvent<TOutbound, TInbound>;\n\t\t\t\tif (event.kind === \"outbound\" && shouldTrackAck(event.envelope.type)) {\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tseq: event.envelope.metadata.seq,\n\t\t\t\t\t\t\t\tattempt: event.envelope.metadata.attempt,\n\t\t\t\t\t\t\t\tmaxAttempts: event.envelope.metadata.maxAttempts,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/attempts`, factory: \"wireBridgeAttempts\" },\n\t);\n}\n\nfunction guardedInboundNode<TInbound>(\n\tnode: Node<WireBridgeEnvelope<TInbound> | WireBridgeInvalidIngress>,\n\tsessionId: string,\n): Node<WireBridgeEnvelope<TInbound>> {\n\treturn new Proxy(node, {\n\t\tget(target, property) {\n\t\t\tif (property === \"down\") {\n\t\t\t\treturn (msgs: Wave) => target.down(guardInboundWave(msgs, sessionId));\n\t\t\t}\n\t\t\tconst value = Reflect.get(target, property, target);\n\t\t\treturn typeof value === \"function\" ? value.bind(target) : value;\n\t\t},\n\t}) as Node<WireBridgeEnvelope<TInbound>>;\n}\n\nfunction guardInboundWave(msgs: Wave, sessionId: string): Wave {\n\treturn msgs.map((msg) => {\n\t\tif (msg[0] === \"DATA\") return msg;\n\t\tif (msg[0] === \"ERROR\") {\n\t\t\treturn [\n\t\t\t\t\"DATA\",\n\t\t\t\tinvalidIngress(\n\t\t\t\t\t`${sessionId}: inbound protocol ERROR ${String(\n\t\t\t\t\t\terrorPayload(msg[1]),\n\t\t\t\t\t)} is local misuse; remote errors must arrive as DATA envelope facts`,\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\t\tif (msg[0] === \"COMPLETE\") {\n\t\t\treturn [\n\t\t\t\t\"DATA\",\n\t\t\t\tinvalidIngress(\n\t\t\t\t\t`${sessionId}: inbound protocol COMPLETE is local misuse; remote completion must arrive as a DATA envelope fact`,\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\t\treturn [\n\t\t\t\"DATA\",\n\t\t\tinvalidIngress(\n\t\t\t\t`${sessionId}: inbound port accepts DATA envelope facts only; ${msg[0]} is local protocol traffic`,\n\t\t\t),\n\t\t];\n\t});\n}\n\nfunction invalidIngress(error: string): WireBridgeInvalidIngress {\n\treturn { __wireBridgeInvalidIngress: true, error };\n}\n\nfunction isInvalidIngress(value: unknown): value is WireBridgeInvalidIngress {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t(value as WireBridgeInvalidIngress).__wireBridgeInvalidIngress === true &&\n\t\ttypeof (value as WireBridgeInvalidIngress).error === \"string\"\n\t);\n}\n\nfunction shouldTrackAck(type: WireBridgeEnvelopeType): boolean {\n\treturn type === \"start\" || type === \"data\" || type === \"close\";\n}\n\nfunction isSafePositiveInteger(value: unknown): value is number {\n\treturn Number.isSafeInteger(value) && (value as number) > 0;\n}\n\nfunction isSafeNonNegativeInteger(value: unknown): value is number {\n\treturn Number.isSafeInteger(value) && (value as number) >= 0;\n}\n\nfunction validatePayloadForType(\n\ttype: WireBridgeEnvelopeType,\n\tpayload: unknown,\n\tprefix: string,\n): string | undefined {\n\tconst kind =\n\t\ttypeof payload === \"object\" && payload !== null\n\t\t\t? (payload as { readonly kind?: unknown }).kind\n\t\t\t: undefined;\n\tswitch (type) {\n\t\tcase \"data\":\n\t\t\treturn kind === \"data\" && (payload as { readonly value?: unknown }).value !== undefined\n\t\t\t\t? undefined\n\t\t\t\t: `${prefix}: data envelope requires data payload`;\n\t\tcase \"nack\":\n\t\tcase \"error\":\n\t\t\treturn kind === \"error\" && (payload as { readonly error?: unknown }).error !== undefined\n\t\t\t\t? undefined\n\t\t\t\t: `${prefix}: ${type} envelope requires error payload`;\n\t\tcase \"status\":\n\t\t\treturn kind === \"status\" && (payload as { readonly status?: unknown }).status !== undefined\n\t\t\t\t? undefined\n\t\t\t\t: `${prefix}: status envelope requires status payload`;\n\t\tcase \"close\":\n\t\t\treturn kind === \"close\" ? undefined : `${prefix}: close envelope requires close payload`;\n\t\tcase \"start\":\n\t\tcase \"ack\":\n\t\t\treturn payload === undefined\n\t\t\t\t? undefined\n\t\t\t\t: `${prefix}: ${type} envelope must not carry a payload`;\n\t}\n}\n\nfunction bridgePayloadError(payload: unknown, fallback: unknown): unknown {\n\tif (\n\t\ttypeof payload === \"object\" &&\n\t\tpayload !== null &&\n\t\t(payload as { readonly kind?: unknown }).kind === \"error\"\n\t) {\n\t\treturn (payload as { readonly error?: unknown }).error;\n\t}\n\treturn fallback;\n}\n\nfunction rethrowGraphRuntimeInvariant(error: unknown): void {\n\tconst message = errorMessage(error);\n\tif (\n\t\tmessage.includes(\"R-reentrancy\") ||\n\t\tmessage.includes(\"R-rewire\") ||\n\t\tmessage.includes(\"R-graph-domain\") ||\n\t\tmessage.includes(\"D37\") ||\n\t\tmessage.includes(\"D22\") ||\n\t\tmessage.includes(\"different graph\") ||\n\t\tmessage.includes(\"cross-graph\") ||\n\t\tmessage.includes(\"wire bridge\") ||\n\t\tmessage.includes(\"mid-fn topology mutation\") ||\n\t\tmessage.includes(\"reentrant dep mutation\") ||\n\t\tmessage.includes(\"feedback cycle\")\n\t) {\n\t\tthrow error;\n\t}\n}\n\nfunction errorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n","/**\n * Graph-visible outbound environment adapters (D130/D132).\n *\n * Async transport work is confined to graph-local EnvironmentDrivers. Each\n * helper returns declared nodes for events/status/attempts/errors instead of a\n * hidden sink side channel.\n */\n\nimport { type Ctx, depBatch } from \"../ctx/types.js\";\nimport type {\n\tDriverCancel,\n\tHttpRequest,\n\tHttpResponse,\n\tProcessCommand,\n\tProcessResult,\n\tWebSocketRequest,\n\tWebSocketSend,\n\tWebSocketSendResult,\n\tWebSocketSessionHandle,\n} from \"../graph/environment.js\";\nimport type { Graph } from \"../graph/graph.js\";\nimport {\n\tnextRetryDelayMs,\n\ttype RetryPolicy,\n\tretryPolicy,\n\tshouldRetry,\n} from \"../graph/resilience.js\";\nimport type { Node } from \"../node/node.js\";\nimport { errorPayload } from \"../protocol/messages.js\";\n\nexport type OutboundEvent<TValue, TResult> =\n\t| { readonly kind: \"attempt\"; readonly value: TValue; readonly attempt: number }\n\t| {\n\t\t\treadonly kind: \"retry\";\n\t\t\treadonly value: TValue;\n\t\t\treadonly attempt: number;\n\t\t\treadonly delayMs: number;\n\t\t\treadonly error: unknown;\n\t }\n\t| {\n\t\t\treadonly kind: \"sent\";\n\t\t\treadonly value: TValue;\n\t\t\treadonly attempt: number;\n\t\t\treadonly result: TResult;\n\t }\n\t| {\n\t\t\treadonly kind: \"failed\";\n\t\t\treadonly value: TValue;\n\t\t\treadonly attempt: number;\n\t\t\treadonly error: unknown;\n\t }\n\t| {\n\t\t\treadonly kind: \"exhausted\";\n\t\t\treadonly value: TValue;\n\t\t\treadonly attempt: number;\n\t\t\treadonly error: unknown;\n\t }\n\t| { readonly kind: \"upstream-complete\" }\n\t| { readonly kind: \"upstream-error\"; readonly error: unknown };\n\nexport interface OutboundStatus {\n\treadonly state:\n\t\t| \"idle\"\n\t\t| \"running\"\n\t\t| \"waiting\"\n\t\t| \"succeeded\"\n\t\t| \"failed\"\n\t\t| \"exhausted\"\n\t\t| \"completed\";\n\treadonly inFlight: number;\n\treadonly attempt: number;\n\treadonly sent: number;\n\treadonly failed: number;\n\treadonly lastDelayMs?: number;\n}\n\nexport interface OutboundBundle<TValue, TResult> {\n\treadonly events: Node<OutboundEvent<TValue, TResult>>;\n\treadonly status: Node<OutboundStatus>;\n\treadonly attempts: Node<number>;\n\treadonly errors: Node<unknown>;\n}\n\nexport interface OutboundAdapterOptions {\n\treadonly name?: string;\n\treadonly retry?: RetryPolicy;\n}\n\nexport type HttpRequestOf<T> = (value: T) => HttpRequest;\nexport type ProcessCommandOf<T> = (value: T) => ProcessCommand;\nexport type WebSocketSendOf<T> = (value: T) => WebSocketSend;\n\n/** D133 command facts for a graph-visible WebSocket SessionBundle. */\nexport type WebSocketSessionCommand =\n\t| { readonly kind: \"start\" }\n\t| { readonly kind: \"send\"; readonly message: WebSocketSend }\n\t| { readonly kind: \"close\"; readonly code?: number; readonly reason?: string };\n\n/** Inbound facts emitted by the live WebSocket session connection. */\nexport type WebSocketSessionInbound =\n\t| { readonly kind: \"text\"; readonly data: string }\n\t| { readonly kind: \"binary\"; readonly data: Uint8Array };\n\n/** Observable lifecycle facts for bounded D133 reconnect/session progress. */\nexport type WebSocketSessionLifecycle =\n\t| { readonly kind: \"starting\"; readonly attempt: number; readonly maxAttempts: number }\n\t| { readonly kind: \"open\"; readonly attempt: number }\n\t| { readonly kind: \"sent\"; readonly message: WebSocketSend }\n\t| { readonly kind: \"closing\"; readonly code?: number; readonly reason?: string }\n\t| { readonly kind: \"closed\"; readonly code?: number; readonly reason?: string }\n\t| {\n\t\t\treadonly kind: \"retrying\";\n\t\t\treadonly attempt: number;\n\t\t\treadonly nextAttempt: number;\n\t\t\treadonly delayMs: number;\n\t\t\treadonly error: unknown;\n\t }\n\t| { readonly kind: \"exhausted\"; readonly attempt: number; readonly error: unknown };\n\n/** D175 graph-visible outbound disposition for a WebSocket SessionBundle send. */\nexport type WebSocketSessionOutbound =\n\t| { readonly kind: \"queued\"; readonly seq: number; readonly message: WebSocketSend }\n\t| { readonly kind: \"sending\"; readonly seq: number; readonly message: WebSocketSend }\n\t| { readonly kind: \"sent\"; readonly seq: number; readonly message: WebSocketSend }\n\t| {\n\t\t\treadonly kind: \"rejected\";\n\t\t\treadonly seq: number;\n\t\t\treadonly message: WebSocketSend;\n\t\t\treadonly error: unknown;\n\t }\n\t| {\n\t\t\treadonly kind: \"canceled\";\n\t\t\treadonly seq: number;\n\t\t\treadonly message: WebSocketSend;\n\t\t\treadonly reason: unknown;\n\t };\n\n/** Current graph-visible WebSocket session status projection. */\nexport interface WebSocketSessionStatus {\n\treadonly state:\n\t\t| \"idle\"\n\t\t| \"connecting\"\n\t\t| \"open\"\n\t\t| \"closing\"\n\t\t| \"closed\"\n\t\t| \"waiting\"\n\t\t| \"exhausted\"\n\t\t| \"errored\";\n\treadonly attempt: number;\n\treadonly maxAttempts: number;\n\treadonly sent: number;\n\treadonly received: number;\n\treadonly errors: number;\n\treadonly lastDelayMs?: number;\n}\n\n/** D133 SessionBundle: all session commands, inbound data, attempts, status, and errors are nodes. */\nexport interface WebSocketSessionBundle {\n\treadonly command: Node<WebSocketSessionCommand>;\n\treadonly inbound: Node<WebSocketSessionInbound>;\n\treadonly lifecycle: Node<WebSocketSessionLifecycle>;\n\treadonly outbound: Node<WebSocketSessionOutbound>;\n\treadonly status: Node<WebSocketSessionStatus>;\n\treadonly errors: Node<unknown>;\n\treadonly attempts: Node<number>;\n\tstart(): void;\n\tsend(message: WebSocketSend | string | Uint8Array): void;\n\tclose(code?: number, reason?: string): void;\n}\n\nexport type WebSocketSessionSendPolicy =\n\t| { readonly kind?: \"reject\" }\n\t| { readonly kind: \"buffer\"; readonly maxPending: number };\n\n/** Options for the D133 WebSocket SessionBundle; retry is bounded unless configured otherwise. */\nexport interface WebSocketSessionOptions {\n\treadonly name?: string;\n\treadonly retry?: RetryPolicy;\n\treadonly sendPolicy?: WebSocketSessionSendPolicy;\n}\n\ntype WebSocketSessionEvent =\n\t| { readonly kind: \"attempt\"; readonly attempt: number; readonly maxAttempts: number }\n\t| { readonly kind: \"open\"; readonly attempt: number }\n\t| { readonly kind: \"message\"; readonly message: WebSocketSessionInbound }\n\t| { readonly kind: \"sent\"; readonly message: WebSocketSend }\n\t| { readonly kind: \"closing\"; readonly code?: number; readonly reason?: string }\n\t| { readonly kind: \"closed\"; readonly code?: number; readonly reason?: string }\n\t| {\n\t\t\treadonly kind: \"retry\";\n\t\t\treadonly attempt: number;\n\t\t\treadonly nextAttempt: number;\n\t\t\treadonly delayMs: number;\n\t\t\treadonly error: unknown;\n\t }\n\t| { readonly kind: \"outbound\"; readonly fact: WebSocketSessionOutbound }\n\t| { readonly kind: \"error\"; readonly error: unknown; readonly attempt?: number }\n\t| { readonly kind: \"exhausted\"; readonly attempt: number; readonly error: unknown };\n\ninterface SendState {\n\tseq: number;\n\tcancels: Map<number, DriverCancel>;\n\ttimers: Map<number, ReturnType<typeof setTimeout>>;\n\tactive: boolean;\n\tcleanupInstalled: boolean;\n}\n\nfunction assertSourceLocal<T>(source: Node<T>): Node<T> {\n\treturn source;\n}\n\nfunction initSendState(ctx: Ctx): SendState {\n\tlet state = ctx.state.get<SendState>();\n\tif (state === undefined) {\n\t\tstate = {\n\t\t\tseq: 0,\n\t\t\tcancels: new Map(),\n\t\t\ttimers: new Map(),\n\t\t\tactive: true,\n\t\t\tcleanupInstalled: false,\n\t\t};\n\t\tctx.state.set(state);\n\t}\n\tstate.active = true;\n\tif (!state.cleanupInstalled) {\n\t\tstate.cleanupInstalled = true;\n\t\tctx.onDeactivation(() => {\n\t\t\tstate.active = false;\n\t\t\tstate.cleanupInstalled = false;\n\t\t\tfor (const cancel of state.cancels.values()) runCancel(cancel);\n\t\t\tfor (const timer of state.timers.values()) clearTimeout(timer);\n\t\t\tstate.cancels.clear();\n\t\t\tstate.timers.clear();\n\t\t});\n\t}\n\treturn state;\n}\n\nfunction runCancel(cancel: DriverCancel): void {\n\ttry {\n\t\tcancel();\n\t} catch {\n\t\t// Driver cancellation is best-effort and must not hide graph-visible outcomes.\n\t}\n}\n\nfunction outboundNodes<TValue, TResult>(\n\tgraph: Graph,\n\tevents: Node<OutboundEvent<TValue, TResult>>,\n\tname: string,\n): OutboundBundle<TValue, TResult> {\n\tconst status = graph.node<OutboundStatus>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tconst current =\n\t\t\t\tctx.state.get<OutboundStatus>() ??\n\t\t\t\t({ state: \"idle\", inFlight: 0, attempt: 0, sent: 0, failed: 0 } satisfies OutboundStatus);\n\t\t\tlet next = current;\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tnext = reduceStatus(next, event as OutboundEvent<TValue, TResult>);\n\t\t\t}\n\t\t\tctx.state.set(next);\n\t\t\tctx.down([[\"DATA\", next]]);\n\t\t},\n\t\t{ name: `${name}/status`, factory: \"outboundStatus\" },\n\t);\n\tconst attempts = graph.node<number>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = event as OutboundEvent<TValue, TResult>;\n\t\t\t\tif (\"attempt\" in typed) ctx.down([[\"DATA\", typed.attempt]]);\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/attempts`, factory: \"outboundAttempts\" },\n\t);\n\tconst errors = graph.node<unknown>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = event as OutboundEvent<TValue, TResult>;\n\t\t\t\tif (\"error\" in typed) ctx.down([[\"DATA\", typed.error]]);\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/errors`, factory: \"outboundErrors\" },\n\t);\n\treturn { events, status, attempts, errors };\n}\n\nfunction reduceStatus<TValue, TResult>(\n\tcurrent: OutboundStatus,\n\tevent: OutboundEvent<TValue, TResult>,\n): OutboundStatus {\n\tswitch (event.kind) {\n\t\tcase \"attempt\":\n\t\t\treturn {\n\t\t\t\t...current,\n\t\t\t\tstate: \"running\",\n\t\t\t\tinFlight: current.inFlight + 1,\n\t\t\t\tattempt: event.attempt,\n\t\t\t};\n\t\tcase \"retry\":\n\t\t\treturn {\n\t\t\t\t...current,\n\t\t\t\tstate: \"waiting\",\n\t\t\t\tinFlight: Math.max(0, current.inFlight - 1),\n\t\t\t\tattempt: event.attempt,\n\t\t\t\tlastDelayMs: event.delayMs,\n\t\t\t};\n\t\tcase \"sent\":\n\t\t\treturn {\n\t\t\t\t...current,\n\t\t\t\tstate: \"succeeded\",\n\t\t\t\tinFlight: Math.max(0, current.inFlight - 1),\n\t\t\t\tattempt: event.attempt,\n\t\t\t\tsent: current.sent + 1,\n\t\t\t\tlastDelayMs: undefined,\n\t\t\t};\n\t\tcase \"failed\":\n\t\t\treturn {\n\t\t\t\t...current,\n\t\t\t\tstate: \"failed\",\n\t\t\t\tinFlight: Math.max(0, current.inFlight - 1),\n\t\t\t\tattempt: event.attempt,\n\t\t\t\tfailed: current.failed + 1,\n\t\t\t};\n\t\tcase \"exhausted\":\n\t\t\treturn {\n\t\t\t\t...current,\n\t\t\t\tstate: \"exhausted\",\n\t\t\t\tinFlight: Math.max(0, current.inFlight - 1),\n\t\t\t\tattempt: event.attempt,\n\t\t\t\tfailed: current.failed + 1,\n\t\t\t};\n\t\tcase \"upstream-complete\":\n\t\t\treturn { ...current, state: \"completed\" };\n\t\tcase \"upstream-error\":\n\t\t\treturn { ...current, state: \"failed\", failed: current.failed + 1 };\n\t}\n}\n\ninterface WebSocketSessionState {\n\tactive: boolean;\n\tconnected: boolean;\n\tcleanupInstalled: boolean;\n\tcurrentAttempt: number;\n\tcurrentSession: WebSocketSessionHandle | undefined;\n\tsendCancels: Map<number, DriverCancel>;\n\tliveSends: Map<number, PendingWebSocketOutbound>;\n\tpendingOutbound: PendingWebSocketOutbound[];\n\ttimers: Map<number, ReturnType<typeof setTimeout>>;\n\tseq: number;\n\toutboundSeq: number;\n}\n\ninterface PendingWebSocketOutbound {\n\treadonly seq: number;\n\treadonly message: WebSocketSend;\n}\n\nfunction initWebSocketSessionState(ctx: Ctx): WebSocketSessionState {\n\tlet state = ctx.state.get<WebSocketSessionState>();\n\tif (state === undefined) {\n\t\tstate = {\n\t\t\tactive: true,\n\t\t\tconnected: false,\n\t\t\tcleanupInstalled: false,\n\t\t\tcurrentAttempt: 0,\n\t\t\tcurrentSession: undefined,\n\t\t\tsendCancels: new Map(),\n\t\t\tliveSends: new Map(),\n\t\t\tpendingOutbound: [],\n\t\t\ttimers: new Map(),\n\t\t\tseq: 0,\n\t\t\toutboundSeq: 0,\n\t\t};\n\t\tctx.state.set(state);\n\t}\n\tstate.active = true;\n\tif (!state.cleanupInstalled) {\n\t\tstate.cleanupInstalled = true;\n\t\tctx.onDeactivation(() => {\n\t\t\tconst sendCancels = [...state.sendCancels.values()];\n\t\t\tconst timers = [...state.timers.values()];\n\t\t\tconst session = state.currentSession;\n\t\t\tstate.active = false;\n\t\t\tstate.cleanupInstalled = false;\n\t\t\tstate.connected = false;\n\t\t\tstate.currentAttempt = 0;\n\t\t\tstate.currentSession = undefined;\n\t\t\tstate.sendCancels.clear();\n\t\t\tstate.liveSends.clear();\n\t\t\tstate.pendingOutbound = [];\n\t\t\tstate.timers.clear();\n\t\t\tfor (const cancel of sendCancels) runCancel(cancel);\n\t\t\tfor (const timer of timers) clearTimeout(timer);\n\t\t\tsession?.cancel();\n\t\t});\n\t}\n\treturn state;\n}\n\nfunction closeWebSocketSessionState(\n\tstate: WebSocketSessionState,\n\tdriverAction: \"cancel\" | \"none\" = \"cancel\",\n): {\n\treadonly canceled: PendingWebSocketOutbound[];\n\treadonly session: WebSocketSessionHandle | undefined;\n} {\n\tconst session = state.currentSession;\n\tconst timers = [...state.timers.values()];\n\tconst sendCancels = [...state.sendCancels.values()];\n\tconst canceled = [...state.pendingOutbound, ...state.liveSends.values()];\n\tstate.connected = false;\n\tstate.currentAttempt = 0;\n\tstate.currentSession = undefined;\n\tstate.timers.clear();\n\tstate.sendCancels.clear();\n\tstate.pendingOutbound = [];\n\tstate.liveSends.clear();\n\tfor (const timer of timers) clearTimeout(timer);\n\tfor (const cancelSend of sendCancels) runCancel(cancelSend);\n\tif (driverAction === \"cancel\") session?.cancel();\n\treturn { canceled, session };\n}\n\nfunction cancelRetryTimers(state: WebSocketSessionState): void {\n\tfor (const timer of state.timers.values()) clearTimeout(timer);\n\tstate.timers.clear();\n}\n\nfunction cleanupWebSocketConnection(\n\tstate: WebSocketSessionState,\n\tdriverAction: \"cancel\" | \"none\" = \"cancel\",\n): PendingWebSocketOutbound[] {\n\tconst session = state.currentSession;\n\tconst sendCancels = [...state.sendCancels.values()];\n\tconst canceled = [...state.liveSends.values()];\n\tstate.connected = false;\n\tstate.currentAttempt = 0;\n\tstate.currentSession = undefined;\n\tstate.sendCancels.clear();\n\tstate.liveSends.clear();\n\tfor (const cancelSend of sendCancels) runCancel(cancelSend);\n\tif (driverAction === \"cancel\") session?.cancel();\n\treturn canceled;\n}\n\nfunction normalizeWebSocketSessionSendPolicy(\n\tpolicy: WebSocketSessionSendPolicy | undefined,\n): { readonly kind: \"reject\" } | { readonly kind: \"buffer\"; readonly maxPending: number } {\n\tif (policy?.kind !== \"buffer\") return { kind: \"reject\" };\n\tif (!Number.isFinite(policy.maxPending) || policy.maxPending < 1) {\n\t\tthrow new Error(\"webSocketSession: buffer sendPolicy requires finite maxPending >= 1\");\n\t}\n\treturn { kind: \"buffer\", maxPending: Math.floor(policy.maxPending) };\n}\n\nfunction webSocketSessionEventNode(\n\tgraph: Graph,\n\tcommand: Node<WebSocketSessionCommand>,\n\trequest: WebSocketRequest,\n\tname: string,\n\tpolicy: RetryPolicy,\n\tsendPolicy: ReturnType<typeof normalizeWebSocketSessionSendPolicy>,\n): Node<WebSocketSessionEvent> {\n\treturn graph.node<WebSocketSessionEvent>(\n\t\t[command],\n\t\t(ctx) => {\n\t\t\tconst state = initWebSocketSessionState(ctx);\n\n\t\t\tconst emitOutbound = (fact: WebSocketSessionOutbound) => {\n\t\t\t\tctx.down([[\"DATA\", { kind: \"outbound\", fact } satisfies WebSocketSessionEvent]]);\n\t\t\t};\n\n\t\t\tconst emitOutboundCanceled = (\n\t\t\t\titems: readonly PendingWebSocketOutbound[],\n\t\t\t\treason: unknown,\n\t\t\t) => {\n\t\t\t\tfor (const item of items) {\n\t\t\t\t\temitOutbound({\n\t\t\t\t\t\tkind: \"canceled\",\n\t\t\t\t\t\tseq: item.seq,\n\t\t\t\t\t\tmessage: item.message,\n\t\t\t\t\t\treason,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst emitOutboundRejected = (items: readonly PendingWebSocketOutbound[], error: unknown) => {\n\t\t\t\tconst payload = errorPayload(error);\n\t\t\t\tfor (const item of items) {\n\t\t\t\t\temitOutbound({\n\t\t\t\t\t\tkind: \"rejected\",\n\t\t\t\t\t\tseq: item.seq,\n\t\t\t\t\t\tmessage: item.message,\n\t\t\t\t\t\terror: payload,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst retryOrExhaust = (attempt: number, error: unknown) => {\n\t\t\t\tconst payload = errorPayload(error);\n\t\t\t\tconst canceled = cleanupWebSocketConnection(state);\n\t\t\t\temitOutboundCanceled(canceled, `${name}: connection cleanup`);\n\t\t\t\tif (shouldRetry(policy, attempt)) {\n\t\t\t\t\tconst nextAttempt = attempt + 1;\n\t\t\t\t\tconst delayMs = nextRetryDelayMs(policy, nextAttempt) ?? 0;\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"retry\",\n\t\t\t\t\t\t\t\tattempt,\n\t\t\t\t\t\t\t\tnextAttempt,\n\t\t\t\t\t\t\t\tdelayMs,\n\t\t\t\t\t\t\t\terror: payload,\n\t\t\t\t\t\t\t} satisfies WebSocketSessionEvent,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t\tconst timerId = state.seq++;\n\t\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\t\tstate.timers.delete(timerId);\n\t\t\t\t\t\tif (!state.active) return;\n\t\t\t\t\t\tstart(nextAttempt);\n\t\t\t\t\t}, delayMs);\n\t\t\t\t\tstate.timers.set(timerId, timer);\n\t\t\t\t} else {\n\t\t\t\t\temitOutboundRejected(state.pendingOutbound, payload);\n\t\t\t\t\tstate.pendingOutbound = [];\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{ kind: \"exhausted\", attempt, error: payload } satisfies WebSocketSessionEvent,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst start = (attempt: number) => {\n\t\t\t\tif (\n\t\t\t\t\t!state.active ||\n\t\t\t\t\tstate.connected ||\n\t\t\t\t\tstate.currentAttempt !== 0 ||\n\t\t\t\t\tstate.timers.size > 0\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst driver = ctx.environment().webSocketDriver();\n\t\t\t\tstate.currentAttempt = attempt;\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"attempt\",\n\t\t\t\t\t\t\tattempt,\n\t\t\t\t\t\t\tmaxAttempts: policy.maxAttempts,\n\t\t\t\t\t\t} satisfies WebSocketSessionEvent,\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t\tconst connectSession = driver?.connectSession;\n\t\t\t\tif (connectSession === undefined) {\n\t\t\t\t\tretryOrExhaust(attempt, `${name}: missing WebSocket session capability`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet session: WebSocketSessionHandle | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tsession = connectSession.call(driver, request, (event) => {\n\t\t\t\t\t\tif (!state.active || state.currentAttempt !== attempt) return;\n\t\t\t\t\t\tif (event.kind === \"event\") {\n\t\t\t\t\t\t\tconst ws = event.event;\n\t\t\t\t\t\t\tif (ws.kind === \"open\") {\n\t\t\t\t\t\t\t\tstate.connected = true;\n\t\t\t\t\t\t\t\tctx.down([[\"DATA\", { kind: \"open\", attempt } satisfies WebSocketSessionEvent]]);\n\t\t\t\t\t\t\t\tflushPending();\n\t\t\t\t\t\t\t} else if (ws.kind === \"text\" || ws.kind === \"binary\") {\n\t\t\t\t\t\t\t\tctx.down([\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tkind: \"message\",\n\t\t\t\t\t\t\t\t\t\t\tmessage: ws satisfies WebSocketSessionInbound,\n\t\t\t\t\t\t\t\t\t\t} satisfies WebSocketSessionEvent,\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\t} else if (ws.kind === \"close\") {\n\t\t\t\t\t\t\t\tconst normalClose = ws.code === 1000;\n\t\t\t\t\t\t\t\tconst canceled = cleanupWebSocketConnection(state);\n\t\t\t\t\t\t\t\temitOutboundCanceled(canceled, `${name}: session closed`);\n\t\t\t\t\t\t\t\tctx.down([\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tkind: \"closed\",\n\t\t\t\t\t\t\t\t\t\t\tcode: ws.code,\n\t\t\t\t\t\t\t\t\t\t\treason: ws.reason,\n\t\t\t\t\t\t\t\t\t\t} satisfies WebSocketSessionEvent,\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\t\tif (!normalClose) {\n\t\t\t\t\t\t\t\t\tretryOrExhaust(attempt, {\n\t\t\t\t\t\t\t\t\t\tkind: \"close\",\n\t\t\t\t\t\t\t\t\t\tcode: ws.code,\n\t\t\t\t\t\t\t\t\t\treason: ws.reason,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (event.kind === \"error\") {\n\t\t\t\t\t\t\tretryOrExhaust(attempt, event.error);\n\t\t\t\t\t\t} else if (event.kind === \"complete\") {\n\t\t\t\t\t\t\tretryOrExhaust(attempt, `${name}: connection completed`);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tretryOrExhaust(attempt, error);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (session === undefined) {\n\t\t\t\t\tretryOrExhaust(attempt, `${name}: missing WebSocket session capability`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (state.active && state.currentAttempt === attempt) {\n\t\t\t\t\tstate.currentSession = session;\n\t\t\t\t} else {\n\t\t\t\t\tsession.cancel();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tfunction sendNow(item: PendingWebSocketOutbound): void {\n\t\t\t\tif (!state.connected) {\n\t\t\t\t\temitOutbound({\n\t\t\t\t\t\tkind: \"rejected\",\n\t\t\t\t\t\tseq: item.seq,\n\t\t\t\t\t\tmessage: item.message,\n\t\t\t\t\t\terror: `${name}: session is not open`,\n\t\t\t\t\t});\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"error\",\n\t\t\t\t\t\t\t\terror: `${name}: session is not open`,\n\t\t\t\t\t\t\t} satisfies WebSocketSessionEvent,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst session = state.currentSession;\n\t\t\t\tif (session === undefined) {\n\t\t\t\t\temitOutbound({\n\t\t\t\t\t\tkind: \"rejected\",\n\t\t\t\t\t\tseq: item.seq,\n\t\t\t\t\t\tmessage: item.message,\n\t\t\t\t\t\terror: `${name}: missing WebSocket session capability`,\n\t\t\t\t\t});\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"error\",\n\t\t\t\t\t\t\t\terror: `${name}: missing WebSocket session capability`,\n\t\t\t\t\t\t\t} satisfies WebSocketSessionEvent,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst sendId = state.seq++;\n\t\t\t\tstate.liveSends.set(sendId, item);\n\t\t\t\temitOutbound({ kind: \"sending\", seq: item.seq, message: item.message });\n\t\t\t\tlet done = false;\n\t\t\t\tlet cancel: DriverCancel | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tcancel = session.send(item.message, (result) => {\n\t\t\t\t\t\tif (done || !state.active || !state.liveSends.has(sendId)) return;\n\t\t\t\t\t\tdone = true;\n\t\t\t\t\t\tstate.liveSends.delete(sendId);\n\t\t\t\t\t\tstate.sendCancels.delete(sendId);\n\t\t\t\t\t\tif (result.ok) {\n\t\t\t\t\t\t\temitOutbound({ kind: \"sent\", seq: item.seq, message: item.message });\n\t\t\t\t\t\t\tctx.down([\n\t\t\t\t\t\t\t\t[\"DATA\", { kind: \"sent\", message: item.message } satisfies WebSocketSessionEvent],\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst payload = errorPayload(result.error);\n\t\t\t\t\t\t\temitOutbound({\n\t\t\t\t\t\t\t\tkind: \"rejected\",\n\t\t\t\t\t\t\t\tseq: item.seq,\n\t\t\t\t\t\t\t\tmessage: item.message,\n\t\t\t\t\t\t\t\terror: payload,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tctx.down([\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tkind: \"error\",\n\t\t\t\t\t\t\t\t\t\terror: payload,\n\t\t\t\t\t\t\t\t\t} satisfies WebSocketSessionEvent,\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstate.liveSends.delete(sendId);\n\t\t\t\t\tconst payload = errorPayload(error);\n\t\t\t\t\temitOutbound({\n\t\t\t\t\t\tkind: \"rejected\",\n\t\t\t\t\t\tseq: item.seq,\n\t\t\t\t\t\tmessage: item.message,\n\t\t\t\t\t\terror: payload,\n\t\t\t\t\t});\n\t\t\t\t\tctx.down([[\"DATA\", { kind: \"error\", error: payload } satisfies WebSocketSessionEvent]]);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (cancel !== undefined && !done && state.active && state.liveSends.has(sendId)) {\n\t\t\t\t\tstate.sendCancels.set(sendId, cancel);\n\t\t\t\t} else if (cancel !== undefined && !state.active) runCancel(cancel);\n\t\t\t}\n\n\t\t\tfunction flushPending(): void {\n\t\t\t\tconst pending = state.pendingOutbound;\n\t\t\t\tstate.pendingOutbound = [];\n\t\t\t\tfor (let index = 0; index < pending.length; index++) {\n\t\t\t\t\tconst item = pending[index];\n\t\t\t\t\tif (!state.connected || state.currentSession === undefined) {\n\t\t\t\t\t\temitOutboundCanceled(pending.slice(index), `${name}: session closed`);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsendNow(item);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst send = (message: WebSocketSend) => {\n\t\t\t\tconst item = { seq: state.outboundSeq++, message } satisfies PendingWebSocketOutbound;\n\t\t\t\tif (state.connected) {\n\t\t\t\t\tsendNow(item);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (sendPolicy.kind === \"buffer\") {\n\t\t\t\t\tif (state.pendingOutbound.length >= sendPolicy.maxPending) {\n\t\t\t\t\t\temitOutbound({\n\t\t\t\t\t\t\tkind: \"rejected\",\n\t\t\t\t\t\t\tseq: item.seq,\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\terror: `${name}: outbound buffer full`,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tctx.down([\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tkind: \"error\",\n\t\t\t\t\t\t\t\t\terror: `${name}: outbound buffer full`,\n\t\t\t\t\t\t\t\t} satisfies WebSocketSessionEvent,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t]);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tstate.pendingOutbound.push(item);\n\t\t\t\t\temitOutbound({ kind: \"queued\", seq: item.seq, message });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\temitOutbound({\n\t\t\t\t\tkind: \"rejected\",\n\t\t\t\t\tseq: item.seq,\n\t\t\t\t\tmessage,\n\t\t\t\t\terror: `${name}: session is not open`,\n\t\t\t\t});\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"error\",\n\t\t\t\t\t\t\terror: `${name}: session is not open`,\n\t\t\t\t\t\t} satisfies WebSocketSessionEvent,\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t};\n\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst commandValue = raw as WebSocketSessionCommand;\n\t\t\t\tif (commandValue.kind === \"start\") start(1);\n\t\t\t\telse if (commandValue.kind === \"send\") send(commandValue.message);\n\t\t\t\telse {\n\t\t\t\t\tcancelRetryTimers(state);\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"closing\",\n\t\t\t\t\t\t\t\tcode: commandValue.code,\n\t\t\t\t\t\t\t\treason: commandValue.reason,\n\t\t\t\t\t\t\t} satisfies WebSocketSessionEvent,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t\tconst { canceled, session } = closeWebSocketSessionState(state, \"none\");\n\t\t\t\t\temitOutboundCanceled(canceled, `${name}: session closed`);\n\t\t\t\t\tsession?.close(commandValue.code, commandValue.reason);\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"closed\",\n\t\t\t\t\t\t\t\tcode: commandValue.code,\n\t\t\t\t\t\t\t\treason: commandValue.reason,\n\t\t\t\t\t\t\t} satisfies WebSocketSessionEvent,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/events`, factory: \"webSocketSessionEvents\" },\n\t);\n}\n\nfunction webSocketSessionNodes(\n\tgraph: Graph,\n\tcommand: Node<WebSocketSessionCommand>,\n\tevents: Node<WebSocketSessionEvent>,\n\tname: string,\n\tpolicy: RetryPolicy,\n): WebSocketSessionBundle {\n\tconst inbound = graph.node<WebSocketSessionInbound>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as WebSocketSessionEvent;\n\t\t\t\tif (event.kind === \"message\") ctx.down([[\"DATA\", event.message]]);\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/inbound`, factory: \"webSocketSessionInbound\" },\n\t);\n\tconst lifecycle = graph.node<WebSocketSessionLifecycle>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as WebSocketSessionEvent;\n\t\t\t\tif (event.kind === \"attempt\") {\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"starting\",\n\t\t\t\t\t\t\t\tattempt: event.attempt,\n\t\t\t\t\t\t\t\tmaxAttempts: event.maxAttempts,\n\t\t\t\t\t\t\t} satisfies WebSocketSessionLifecycle,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t} else if (event.kind === \"open\") {\n\t\t\t\t\tctx.down([[\"DATA\", { kind: \"open\", attempt: event.attempt }]]);\n\t\t\t\t} else if (event.kind === \"sent\") {\n\t\t\t\t\tctx.down([[\"DATA\", { kind: \"sent\", message: event.message }]]);\n\t\t\t\t} else if (event.kind === \"closing\" || event.kind === \"closed\") {\n\t\t\t\t\tctx.down([[\"DATA\", event]]);\n\t\t\t\t} else if (event.kind === \"retry\") {\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"retrying\",\n\t\t\t\t\t\t\t\tattempt: event.attempt,\n\t\t\t\t\t\t\t\tnextAttempt: event.nextAttempt,\n\t\t\t\t\t\t\t\tdelayMs: event.delayMs,\n\t\t\t\t\t\t\t\terror: event.error,\n\t\t\t\t\t\t\t} satisfies WebSocketSessionLifecycle,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t} else if (event.kind === \"exhausted\") {\n\t\t\t\t\tctx.down([[\"DATA\", event]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/lifecycle`, factory: \"webSocketSessionLifecycle\" },\n\t);\n\tconst outbound = graph.node<WebSocketSessionOutbound>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as WebSocketSessionEvent;\n\t\t\t\tif (event.kind === \"outbound\") ctx.down([[\"DATA\", event.fact]]);\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/outbound`, factory: \"webSocketSessionOutbound\" },\n\t);\n\tconst status = graph.node<WebSocketSessionStatus>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tlet next =\n\t\t\t\tctx.state.get<WebSocketSessionStatus>() ??\n\t\t\t\t({\n\t\t\t\t\tstate: \"idle\",\n\t\t\t\t\tattempt: 0,\n\t\t\t\t\tmaxAttempts: policy.maxAttempts,\n\t\t\t\t\tsent: 0,\n\t\t\t\t\treceived: 0,\n\t\t\t\t\terrors: 0,\n\t\t\t\t} satisfies WebSocketSessionStatus);\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as WebSocketSessionEvent;\n\t\t\t\tif (event.kind === \"attempt\") {\n\t\t\t\t\tnext = {\n\t\t\t\t\t\t...next,\n\t\t\t\t\t\tstate: \"connecting\",\n\t\t\t\t\t\tattempt: event.attempt,\n\t\t\t\t\t\tmaxAttempts: event.maxAttempts,\n\t\t\t\t\t\tlastDelayMs: undefined,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"open\") {\n\t\t\t\t\tnext = { ...next, state: \"open\", attempt: event.attempt, lastDelayMs: undefined };\n\t\t\t\t} else if (event.kind === \"message\") {\n\t\t\t\t\tnext = { ...next, received: next.received + 1 };\n\t\t\t\t} else if (event.kind === \"sent\") {\n\t\t\t\t\tnext = { ...next, sent: next.sent + 1 };\n\t\t\t\t} else if (event.kind === \"closing\") {\n\t\t\t\t\tnext = { ...next, state: \"closing\" };\n\t\t\t\t} else if (event.kind === \"closed\") {\n\t\t\t\t\tnext = { ...next, state: \"closed\" };\n\t\t\t\t} else if (event.kind === \"retry\") {\n\t\t\t\t\tnext = {\n\t\t\t\t\t\t...next,\n\t\t\t\t\t\tstate: \"waiting\",\n\t\t\t\t\t\tattempt: event.attempt,\n\t\t\t\t\t\terrors: next.errors + 1,\n\t\t\t\t\t\tlastDelayMs: event.delayMs,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"error\") {\n\t\t\t\t\tnext = {\n\t\t\t\t\t\t...next,\n\t\t\t\t\t\tstate: \"errored\",\n\t\t\t\t\t\tattempt: event.attempt ?? next.attempt,\n\t\t\t\t\t\terrors: next.errors + 1,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"exhausted\") {\n\t\t\t\t\tnext = {\n\t\t\t\t\t\t...next,\n\t\t\t\t\t\tstate: \"exhausted\",\n\t\t\t\t\t\tattempt: event.attempt,\n\t\t\t\t\t\terrors: next.errors + 1,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.state.set(next);\n\t\t\tctx.down([[\"DATA\", next]]);\n\t\t},\n\t\t{ name: `${name}/status`, factory: \"webSocketSessionStatus\" },\n\t);\n\tconst errors = graph.node<unknown>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as WebSocketSessionEvent;\n\t\t\t\tif (\"error\" in event) ctx.down([[\"DATA\", event.error]]);\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/errors`, factory: \"webSocketSessionErrors\" },\n\t);\n\tconst attempts = graph.node<number>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as WebSocketSessionEvent;\n\t\t\t\tif (event.kind === \"attempt\") ctx.down([[\"DATA\", event.attempt]]);\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/attempts`, factory: \"webSocketSessionAttempts\" },\n\t);\n\treturn {\n\t\tcommand,\n\t\tinbound,\n\t\tlifecycle,\n\t\toutbound,\n\t\tstatus,\n\t\terrors,\n\t\tattempts,\n\t\tstart: () => command.down([[\"DATA\", { kind: \"start\" }]]),\n\t\tsend: (message) =>\n\t\t\tcommand.down([\n\t\t\t\t[\n\t\t\t\t\t\"DATA\",\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: \"send\",\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\ttypeof message === \"string\" || message instanceof Uint8Array\n\t\t\t\t\t\t\t\t? { data: message }\n\t\t\t\t\t\t\t\t: message,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t]),\n\t\tclose: (code, reason) => command.down([[\"DATA\", { kind: \"close\", code, reason }]]),\n\t};\n}\n\n/**\n * Create a graph-visible D133 WebSocket SessionBundle.\n *\n * The convenience start/send/close methods publish command facts only; hidden\n * session state is driven by the command node and graph-local EnvironmentDrivers.\n */\nexport function webSocketSession(\n\tgraph: Graph,\n\trequest: WebSocketRequest,\n\topts: WebSocketSessionOptions = {},\n): WebSocketSessionBundle {\n\tconst name = opts.name ?? \"webSocketSession\";\n\tconst policy = opts.retry ?? retryPolicy();\n\tconst sendPolicy = normalizeWebSocketSessionSendPolicy(opts.sendPolicy);\n\tconst command = graph.node<WebSocketSessionCommand>([], null, {\n\t\tname: `${name}/command`,\n\t\tfactory: \"webSocketSessionCommand\",\n\t});\n\tconst events = webSocketSessionEventNode(graph, command, request, name, policy, sendPolicy);\n\treturn webSocketSessionNodes(graph, command, events, name, policy);\n}\n\nfunction outboundNode<TValue, TResult>(\n\tgraph: Graph,\n\tsource: Node<TValue>,\n\tname: string,\n\tsend: (\n\t\tctx: Ctx,\n\t\tvalue: TValue,\n\t\tcallback: (result: { ok: true; value: TResult } | { ok: false; error: unknown }) => void,\n\t) => DriverCancel | undefined,\n\topts: OutboundAdapterOptions,\n): Node<OutboundEvent<TValue, TResult>> {\n\tconst policy = opts.retry ?? retryPolicy();\n\treturn graph.node<OutboundEvent<TValue, TResult>>(\n\t\t[assertSourceLocal(source)],\n\t\t(ctx) => {\n\t\t\tconst state = initSendState(ctx);\n\t\t\tconst start = (value: TValue, attempt: number) => {\n\t\t\t\tif (!state.active) return;\n\t\t\t\tconst id = state.seq++;\n\t\t\t\tctx.down([\n\t\t\t\t\t[\"DATA\", { kind: \"attempt\", value, attempt } satisfies OutboundEvent<TValue, TResult>],\n\t\t\t\t]);\n\t\t\t\tconst failTerminal = (error: unknown) => {\n\t\t\t\t\tconst payload = errorPayload(error);\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{ kind: \"exhausted\", value, attempt, error: payload } satisfies OutboundEvent<\n\t\t\t\t\t\t\t\tTValue,\n\t\t\t\t\t\t\t\tTResult\n\t\t\t\t\t\t\t>,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t\tctx.down([[\"ERROR\", payload]]);\n\t\t\t\t};\n\t\t\t\tlet cancel: DriverCancel | undefined;\n\t\t\t\tlet done = false;\n\t\t\t\ttry {\n\t\t\t\t\tcancel = send(ctx, value, (result) => {\n\t\t\t\t\t\tif (done || !state.active) return;\n\t\t\t\t\t\tdone = true;\n\t\t\t\t\t\tstate.cancels.delete(id);\n\t\t\t\t\t\tif (result.ok) {\n\t\t\t\t\t\t\tctx.down([\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t\t\t{ kind: \"sent\", value, attempt, result: result.value } satisfies OutboundEvent<\n\t\t\t\t\t\t\t\t\t\tTValue,\n\t\t\t\t\t\t\t\t\t\tTResult\n\t\t\t\t\t\t\t\t\t>,\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (shouldRetry(policy, attempt)) {\n\t\t\t\t\t\t\tconst nextAttempt = attempt + 1;\n\t\t\t\t\t\t\tconst delayMs = nextRetryDelayMs(policy, nextAttempt) ?? 0;\n\t\t\t\t\t\t\tctx.down([\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tkind: \"retry\",\n\t\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t\tattempt,\n\t\t\t\t\t\t\t\t\t\tdelayMs,\n\t\t\t\t\t\t\t\t\t\terror: errorPayload(result.error),\n\t\t\t\t\t\t\t\t\t} satisfies OutboundEvent<TValue, TResult>,\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\t\t\t\tstate.timers.delete(id);\n\t\t\t\t\t\t\t\tif (!state.active) return;\n\t\t\t\t\t\t\t\tstart(value, nextAttempt);\n\t\t\t\t\t\t\t}, delayMs);\n\t\t\t\t\t\t\tstate.timers.set(id, timer);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tctx.down([\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tkind: \"exhausted\",\n\t\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t\tattempt,\n\t\t\t\t\t\t\t\t\t\terror: errorPayload(result.error),\n\t\t\t\t\t\t\t\t\t} satisfies OutboundEvent<TValue, TResult>,\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!done) {\n\t\t\t\t\t\tdone = true;\n\t\t\t\t\t\tstate.cancels.delete(id);\n\t\t\t\t\t\tfailTerminal(error);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (cancel === undefined) {\n\t\t\t\t\tif (!done) {\n\t\t\t\t\t\tdone = true;\n\t\t\t\t\t\tfailTerminal(`${name}: missing environment driver capability`);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!done && state.active) {\n\t\t\t\t\tstate.cancels.set(id, cancel);\n\t\t\t\t} else if (!state.active) {\n\t\t\t\t\trunCancel(cancel);\n\t\t\t\t}\n\t\t\t};\n\t\t\tfor (const value of depBatch(ctx, 0) ?? []) start(value as TValue, 1);\n\t\t\tconst terminal = ctx.terminal[0];\n\t\t\tif (terminal === true) {\n\t\t\t\tctx.down([\n\t\t\t\t\t[\"DATA\", { kind: \"upstream-complete\" } satisfies OutboundEvent<TValue, TResult>],\n\t\t\t\t]);\n\t\t\t} else if (terminal !== false && terminal !== undefined) {\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t{ kind: \"upstream-error\", error: terminal } satisfies OutboundEvent<TValue, TResult>,\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t}\n\t\t},\n\t\t{ name, factory: name },\n\t);\n}\n\nexport function toHttp<T>(\n\tgraph: Graph,\n\tsource: Node<T>,\n\trequestOf: HttpRequestOf<T>,\n\topts: OutboundAdapterOptions = {},\n): OutboundBundle<T, HttpResponse> {\n\tconst name = opts.name ?? \"toHttp\";\n\tconst events = outboundNode<T, HttpResponse>(\n\t\tgraph,\n\t\tsource,\n\t\tname,\n\t\t(ctx, value, callback) => {\n\t\t\tconst request = requestOf(value);\n\t\t\treturn ctx.environment().httpDriver()?.request(request, callback);\n\t\t},\n\t\topts,\n\t);\n\treturn outboundNodes(graph, events, name);\n}\n\nexport function toProcess<T>(\n\tgraph: Graph,\n\tsource: Node<T>,\n\tcommandOf: ProcessCommandOf<T>,\n\topts: OutboundAdapterOptions = {},\n): OutboundBundle<T, ProcessResult> {\n\tconst name = opts.name ?? \"toProcess\";\n\tconst events = outboundNode<T, ProcessResult>(\n\t\tgraph,\n\t\tsource,\n\t\tname,\n\t\t(ctx, value, callback) => {\n\t\t\tconst command = commandOf(value);\n\t\t\treturn ctx.environment().processDriver()?.run(command, callback);\n\t\t},\n\t\topts,\n\t);\n\treturn outboundNodes(graph, events, name);\n}\n\nexport function toWebSocket<T>(\n\tgraph: Graph,\n\tsource: Node<T>,\n\trequest: WebSocketRequest,\n\tsendOf: WebSocketSendOf<T>,\n\topts: OutboundAdapterOptions = {},\n): OutboundBundle<T, WebSocketSendResult> {\n\tconst name = opts.name ?? \"toWebSocket\";\n\tconst events = outboundNode<T, WebSocketSendResult>(\n\t\tgraph,\n\t\tsource,\n\t\tname,\n\t\t(ctx, value, callback) => {\n\t\t\tconst driver = ctx.environment().webSocketDriver();\n\t\t\treturn driver?.send?.(request, sendOf(value), callback);\n\t\t},\n\t\topts,\n\t);\n\treturn outboundNodes(graph, events, name);\n}\n","/**\n * Dependency-free NestJS adapter tokens and method metadata.\n *\n * The old compat layer imported `@nestjs/common` for DI decorators. Clean-slate keeps the\n * retainable token/metadata vocabulary here and leaves actual `Inject(...)` composition to\n * user-land NestJS code, so @graphrefly/ts keeps zero framework dependencies (D125/B61).\n */\n\n/** Injection token for a root graph singleton. */\nexport const GRAPHREFLY_ROOT_GRAPH = Symbol.for(\"graphrefly:root-graph\");\n\n/** Injection token for adapter module options. */\nexport const GRAPHREFLY_MODULE_OPTIONS = Symbol.for(\"graphrefly:module-options\");\n\n/** Injection token for a request-scoped graph. */\nexport const GRAPHREFLY_REQUEST_GRAPH = Symbol.for(\"graphrefly:request-graph\");\n\nexport type DecoratorHostConstructor = abstract new (...args: unknown[]) => unknown;\nexport type DecoratorBoundMethod = (...args: unknown[]) => unknown;\n\nexport interface OnGraphEventMeta {\n\tnodeName: string;\n\tmethodKey: string | symbol;\n}\n\nexport interface GraphIntervalMeta {\n\tms: number;\n\tmethodKey: string | symbol;\n}\n\nexport interface GraphCronMeta {\n\texpr: string;\n\tmethodKey: string | symbol;\n}\n\nexport const EVENT_HANDLERS = new Map<DecoratorHostConstructor, OnGraphEventMeta[]>();\nexport const INTERVAL_HANDLERS = new Map<DecoratorHostConstructor, GraphIntervalMeta[]>();\nexport const CRON_HANDLERS = new Map<DecoratorHostConstructor, GraphCronMeta[]>();\n\nexport type GraphMethodDecorator = MethodDecorator &\n\t((value: DecoratorBoundMethod, context: ClassMethodDecoratorContext) => void);\n\n/** Get the injection token for a named feature graph. */\nexport function getGraphToken(name: string): symbol {\n\treturn Symbol.for(`graphrefly:graph:${name}`);\n}\n\n/** Get the injection token for a node at a qualified path. */\nexport function getNodeToken(path: string): symbol {\n\treturn Symbol.for(`graphrefly:node:${path}`);\n}\n\nfunction sameMeta<T>(a: T, b: T): boolean {\n\tconst left = a as Record<string | symbol, unknown>;\n\tconst right = b as Record<string | symbol, unknown>;\n\tconst keys = Reflect.ownKeys(left);\n\tif (keys.length !== Reflect.ownKeys(right).length) return false;\n\tfor (const key of keys) {\n\t\tif (!Object.is(left[key], right[key])) return false;\n\t}\n\treturn true;\n}\n\nfunction pushUniqueMeta<T>(\n\tregistry: Map<DecoratorHostConstructor, T[]>,\n\tctor: DecoratorHostConstructor,\n\titem: T,\n): void {\n\tconst existing = registry.get(ctor) ?? [];\n\tif (existing.some((current) => sameMeta(current, item))) return;\n\tregistry.set(ctor, [...existing, item]);\n}\n\nfunction registerMeta<T>(\n\tregistry: Map<DecoratorHostConstructor, T[]>,\n\tmeta: (methodKey: string | symbol) => T,\n): GraphMethodDecorator {\n\treturn ((targetOrValue: object, contextOrKey: ClassMethodDecoratorContext | string | symbol) => {\n\t\tif (typeof contextOrKey === \"object\" && contextOrKey !== null) {\n\t\t\tconst methodKey = contextOrKey.name;\n\t\t\tcontextOrKey.addInitializer(function (this: unknown) {\n\t\t\t\tconst ctor = (this as { constructor: DecoratorHostConstructor }).constructor;\n\t\t\t\tpushUniqueMeta(registry, ctor, meta(methodKey));\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst ctor = (targetOrValue as { constructor: DecoratorHostConstructor }).constructor;\n\t\tpushUniqueMeta(registry, ctor, meta(contextOrKey));\n\t}) as GraphMethodDecorator;\n}\n\n/** Register a method as a DATA-event handler for a graph observe path. */\nexport function OnGraphEvent(nodeName: string): GraphMethodDecorator {\n\treturn registerMeta(EVENT_HANDLERS, (methodKey) => ({ nodeName, methodKey }));\n}\n\n/** Register fixed-interval metadata for a user-land NestJS scheduler bridge. */\nexport function GraphInterval(ms: number): GraphMethodDecorator {\n\treturn registerMeta(INTERVAL_HANDLERS, (methodKey) => ({ ms, methodKey }));\n}\n\n/** Register cron metadata for a user-land NestJS scheduler bridge. */\nexport function GraphCron(expr: string): GraphMethodDecorator {\n\treturn registerMeta(CRON_HANDLERS, (methodKey) => ({ expr, methodKey }));\n}\n","/**\n * Framework-neutral store adapters.\n *\n * React/Vue/Solid/Svelte/Zustand/Jotai/Nanostores bindings can build on this\n * tiny Node-facing layer without importing framework packages or reviving the\n * old `compat` namespace (D125/B61).\n */\n\nimport type { DeliveryMeta, Sink } from \"../ctx/types.js\";\nimport type { Node } from \"../node/node.js\";\n\n/** A minimal readable store contract shared by Svelte/Nanostores-style adapters. */\nexport interface ReadableStore<T> {\n\tget(): T | undefined;\n\tsubscribe(run: (value: T | undefined) => void): () => void;\n}\n\n/** A minimal writable store contract over a clean-slate writable node. */\nexport interface WritableStore<T> extends ReadableStore<T> {\n\tset(value: T): void;\n\tupdate(fn: (value: T | undefined) => T): void;\n}\n\n/** React `useSyncExternalStore`-compatible shape, without importing React. */\nexport interface ExternalStore<T> {\n\tgetSnapshot(): T | undefined;\n\tgetServerSnapshot(): T | undefined;\n\tsubscribe(onStoreChange: () => void): () => void;\n}\n\n/** Object-of-nodes factory used by record subscription adapters. */\nexport type NodeRecordFactory<K extends string, R extends Record<string, unknown>> = (key: K) => {\n\t[P in keyof R]: Node<R[P]>;\n};\n\n/** Zustand-compatible store API over a caller-owned clean-slate state node. */\nexport interface ZustandStoreApi<T extends object> {\n\tgetState(): T;\n\tsetState(partial: T | Partial<T> | ((state: T) => T | Partial<T>), replace?: boolean): void;\n\tgetInitialState(): T;\n\tsubscribe(listener: (state: T, prevState: T) => void): () => void;\n\tdestroy(): void;\n}\n\n/** Jotai-style atom facade over a caller-owned node. */\nexport interface JotaiAtom<T> {\n\tget(): T | undefined;\n\tsubscribe(callback: (value: T | undefined) => void): () => void;\n\treadonly _node: Node<T>;\n}\n\n/** Writable Jotai-style atom facade over a caller-owned writable node. */\nexport interface WritableJotaiAtom<T> extends JotaiAtom<T> {\n\tset(value: T): void;\n\tupdate(fn: (value: T | undefined) => T): void;\n}\n\n/** Nanostores-style atom facade over a caller-owned node. */\nexport interface NanoAtom<T> {\n\tget(): T | undefined;\n\tsubscribe(callback: (value: T | undefined) => void): () => void;\n\tlisten(callback: (value: T | undefined) => void): () => void;\n\treadonly _node: Node<T>;\n}\n\n/** Writable Nanostores-style atom facade over a caller-owned writable node. */\nexport interface WritableNanoAtom<T> extends NanoAtom<T> {\n\tset(value: T): void;\n\tupdate(fn: (value: T | undefined) => T): void;\n}\n\n/** TC39-Signals-style facade over a caller-owned node. */\nexport interface SignalLike<T> {\n\tget(): T | undefined;\n\tsubscribe(callback: (value: T | undefined) => void): () => void;\n\treadonly _node: Node<T>;\n}\n\n/** Writable TC39-Signals-style facade over a caller-owned writable node. */\nexport interface WritableSignalLike<T> extends SignalLike<T> {\n\tset(value: T): void;\n\tupdate(fn: (value: T | undefined) => T): void;\n}\n\nexport interface SubscribeValuesOptions<T> {\n\t/** Emit the current cache snapshot immediately. `undefined` means SENTINEL/no DATA. */\n\timmediate?: boolean;\n\t/** Suppress synchronous push-on-subscribe/replay DATA. Useful for change-only store listeners. */\n\tchangesOnly?: boolean;\n\tonError?: (error: unknown) => void;\n\tonComplete?: () => void;\n\t/** Custom cache reader for wrappers that keep their own snapshot object. */\n\tgetSnapshot?: () => T | undefined;\n}\n\nexport interface WritableNode<T> extends Node<T> {\n\tset(value: T): void;\n}\n\nexport interface WritableStoreOptions<T> extends SubscribeValuesOptions<T> {\n\t/** Override writes for adapters that need a framework-owned reducer. */\n\twrite?: (node: WritableNode<T>, value: T) => void;\n}\n\n/** Read a node cache without activating it. */\nexport function nodeSnapshot<T>(node: Node<T>): T | undefined {\n\treturn node.cache as T | undefined;\n}\n\n/**\n * Subscribe to DATA values from a Node. Protocol internals stay below the adapter boundary:\n * DATA drives value listeners, ERROR/COMPLETE route to optional lifecycle callbacks.\n */\nexport function subscribeNodeValues<T>(\n\tnode: Node<T>,\n\trun: (value: T | undefined) => void,\n\topts: SubscribeValuesOptions<T> = {},\n): () => void {\n\tconst read = opts.getSnapshot ?? (() => nodeSnapshot(node));\n\tif (opts.immediate) run(read());\n\n\tlet subscribing = true;\n\tconst skipSynchronousHandshakeData = opts.changesOnly || opts.immediate;\n\tconst sink: Sink = (msg, delivery?: DeliveryMeta) => {\n\t\tswitch (msg[0]) {\n\t\t\tcase \"DATA\":\n\t\t\t\tif (skipSynchronousHandshakeData && subscribing && delivery === undefined) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\trun(msg[1] as T);\n\t\t\t\treturn;\n\t\t\tcase \"ERROR\":\n\t\t\t\topts.onError?.(msg[1]);\n\t\t\t\treturn;\n\t\t\tcase \"COMPLETE\":\n\t\t\t\topts.onComplete?.();\n\t\t\t\treturn;\n\t\t}\n\t};\n\tconst unsubscribe = node.subscribe(sink);\n\tsubscribing = false;\n\treturn unsubscribe;\n}\n\n/** Build a Svelte/Nanostores-style readable store from a clean-slate Node. */\nexport function readableStore<T>(\n\tnode: Node<T>,\n\topts: SubscribeValuesOptions<T> = {},\n): ReadableStore<T> {\n\treturn {\n\t\tget: () => (opts.getSnapshot ?? (() => nodeSnapshot(node)))(),\n\t\tsubscribe: (run) => subscribeNodeValues(node, run, { immediate: true, ...opts }),\n\t};\n}\n\nfunction hasWritableSet<T>(node: Node<T>): node is WritableNode<T> {\n\treturn typeof (node as { set?: unknown }).set === \"function\";\n}\n\nfunction defaultWrite<T>(node: WritableNode<T>, value: T): void {\n\tnode.set(value);\n}\n\n/** Build a writable store over a StateNode or compatible clean-slate writable Node. */\nexport function writableStore<T>(\n\tnode: WritableNode<T>,\n\topts?: WritableStoreOptions<T>,\n): WritableStore<T>;\nexport function writableStore<T>(\n\tnode: Node<T>,\n\topts: WritableStoreOptions<T> & { write: (node: WritableNode<T>, value: T) => void },\n): WritableStore<T>;\nexport function writableStore<T>(\n\tnode: Node<T>,\n\topts: WritableStoreOptions<T> = {},\n): WritableStore<T> {\n\tconst read = opts.getSnapshot ?? (() => nodeSnapshot(node));\n\tconst write = opts.write ?? (hasWritableSet(node) ? defaultWrite : undefined);\n\tif (!write) {\n\t\tthrow new TypeError(\"writableStore: node must expose set(value) or opts.write\");\n\t}\n\tconst writable = node as WritableNode<T>;\n\treturn {\n\t\tget: read,\n\t\tsubscribe: (run) => subscribeNodeValues(node, run, { immediate: true, ...opts }),\n\t\tset: (value) => write(writable, value),\n\t\tupdate: (fn) => write(writable, fn(read())),\n\t};\n}\n\n/** Build the tiny shape React's `useSyncExternalStore` expects, without importing React. */\nexport function externalStore<T>(\n\tnode: Node<T>,\n\topts: Pick<SubscribeValuesOptions<T>, \"getSnapshot\" | \"onError\" | \"onComplete\"> = {},\n): ExternalStore<T> {\n\tconst read = opts.getSnapshot ?? (() => nodeSnapshot(node));\n\treturn {\n\t\tgetSnapshot: read,\n\t\tgetServerSnapshot: read,\n\t\tsubscribe: (onStoreChange) =>\n\t\t\tsubscribeNodeValues(node, () => onStoreChange(), {\n\t\t\t\tchangesOnly: true,\n\t\t\t\tonError: opts.onError,\n\t\t\t\tonComplete: opts.onComplete,\n\t\t\t}),\n\t};\n}\n\n/** Alias for React-facing bindings; dependency-free so React stays a peer of user code. */\nexport const reactExternalStore = externalStore;\n\n/** Alias for Svelte-style readable stores. */\nexport const svelteReadableStore = readableStore;\n\n/** Alias for Svelte-style writable stores. */\nexport const svelteWritableStore = writableStore;\n\n/** Build a framework-neutral keyed record store (the core of old useSubscribeRecord helpers). */\nexport function recordReadableStore<K extends string, R extends Record<string, unknown>>(\n\tkeysNode: Node<readonly K[]>,\n\tfactory: NodeRecordFactory<K, R>,\n\topts: SubscribeValuesOptions<Record<K, R>> = {},\n): ReadableStore<Record<K, R>> {\n\tconst read = () => {\n\t\tconst keys = keysNode.cache ?? [];\n\t\tconst out = {} as Record<K, R>;\n\t\tfor (const key of keys) {\n\t\t\tconst nodes = factory(key);\n\t\t\tconst values = {} as R;\n\t\t\tfor (const field of Object.keys(nodes) as Array<keyof R>) {\n\t\t\t\tvalues[field] = nodes[field].cache as R[keyof R];\n\t\t\t}\n\t\t\tout[key] = values;\n\t\t}\n\t\treturn out;\n\t};\n\n\treturn {\n\t\tget: read,\n\t\tsubscribe(run) {\n\t\t\tconst entryUnsubs: Array<() => void> = [];\n\t\t\tconst cleanupEntries = () => {\n\t\t\t\tfor (const unsub of entryUnsubs.splice(0)) unsub();\n\t\t\t};\n\t\t\tconst sync = () => {\n\t\t\t\tcleanupEntries();\n\t\t\t\tfor (const key of keysNode.cache ?? []) {\n\t\t\t\t\tconst nodes = factory(key);\n\t\t\t\t\tfor (const field of Object.keys(nodes) as Array<keyof R>) {\n\t\t\t\t\t\tentryUnsubs.push(\n\t\t\t\t\t\t\tsubscribeNodeValues(nodes[field], () => run(read()), {\n\t\t\t\t\t\t\t\tchangesOnly: true,\n\t\t\t\t\t\t\t\tonError: opts.onError,\n\t\t\t\t\t\t\t\tonComplete: opts.onComplete,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\trun(read());\n\t\t\t};\n\t\t\tconst keysUnsub = subscribeNodeValues(keysNode, sync, {\n\t\t\t\tchangesOnly: true,\n\t\t\t\tonError: opts.onError,\n\t\t\t\tonComplete: opts.onComplete,\n\t\t\t});\n\t\t\tsync();\n\t\t\treturn () => {\n\t\t\t\tkeysUnsub();\n\t\t\t\tcleanupEntries();\n\t\t\t};\n\t\t},\n\t};\n}\n\n/** Build a Zustand-compatible StoreApi over a caller-owned clean-slate state node. */\nexport function zustandStore<T extends object>(\n\tnode: WritableNode<T>,\n\tinitialState?: T,\n\topts?: WritableStoreOptions<T>,\n): ZustandStoreApi<T>;\nexport function zustandStore<T extends object>(\n\tnode: Node<T>,\n\tinitialState: T | undefined,\n\topts: WritableStoreOptions<T> & { write: (node: WritableNode<T>, value: T) => void },\n): ZustandStoreApi<T>;\nexport function zustandStore<T extends object>(\n\tnode: Node<T>,\n\tinitialState: T = nodeSnapshot(node) as T,\n\topts: WritableStoreOptions<T> = {},\n): ZustandStoreApi<T> {\n\tconst listeners = new Set<() => void>();\n\tconst read = opts.getSnapshot ?? (() => nodeSnapshot(node));\n\tconst write = opts.write ?? (hasWritableSet(node) ? defaultWrite : undefined);\n\tif (!write) {\n\t\tthrow new TypeError(\"zustandStore: node must expose set(value) or opts.write\");\n\t}\n\tconst writable = node as WritableNode<T>;\n\tconst api: ZustandStoreApi<T> = {\n\t\tgetState: () => read() as T,\n\t\tsetState(partial, replace) {\n\t\t\tconst prev = api.getState();\n\t\t\tconst next = typeof partial === \"function\" ? partial(prev) : partial;\n\t\t\twrite(writable, replace ? (next as T) : ({ ...prev, ...next } as T));\n\t\t},\n\t\tgetInitialState: () => initialState,\n\t\tsubscribe(listener) {\n\t\t\tlet prev = api.getState();\n\t\t\tconst unsub = subscribeNodeValues(\n\t\t\t\tnode,\n\t\t\t\t(value) => {\n\t\t\t\t\tconst next = value as T;\n\t\t\t\t\tlistener(next, prev);\n\t\t\t\t\tprev = next;\n\t\t\t\t},\n\t\t\t\t{ changesOnly: true, onError: opts.onError, onComplete: opts.onComplete },\n\t\t\t);\n\t\t\tlisteners.add(unsub);\n\t\t\treturn () => {\n\t\t\t\tif (!listeners.delete(unsub)) return;\n\t\t\t\tunsub();\n\t\t\t};\n\t\t},\n\t\tdestroy() {\n\t\t\tfor (const unsub of [...listeners]) {\n\t\t\t\tlisteners.delete(unsub);\n\t\t\t\tunsub();\n\t\t\t}\n\t\t},\n\t};\n\treturn api;\n}\n\n/** Build a Jotai-style atom facade over a caller-owned node. */\nexport function jotaiAtom<T>(\n\tnode: WritableNode<T>,\n\topts?: WritableStoreOptions<T>,\n): WritableJotaiAtom<T>;\nexport function jotaiAtom<T>(node: Node<T>, opts?: SubscribeValuesOptions<T>): JotaiAtom<T>;\nexport function jotaiAtom<T>(\n\tnode: Node<T> | WritableNode<T>,\n\topts: SubscribeValuesOptions<T> | WritableStoreOptions<T> = {},\n): JotaiAtom<T> | WritableJotaiAtom<T> {\n\tconst base: JotaiAtom<T> = {\n\t\tget: () => (opts.getSnapshot ?? (() => nodeSnapshot(node)))(),\n\t\tsubscribe: (callback) => subscribeNodeValues(node, callback, { changesOnly: true, ...opts }),\n\t\t_node: node,\n\t};\n\tif (hasWritableSet(node) || typeof (opts as WritableStoreOptions<T>).write === \"function\") {\n\t\tconst writable = writableStore(\n\t\t\tnode,\n\t\t\topts as WritableStoreOptions<T> & {\n\t\t\t\twrite: (node: WritableNode<T>, value: T) => void;\n\t\t\t},\n\t\t);\n\t\treturn { ...base, set: writable.set, update: writable.update };\n\t}\n\treturn base;\n}\n\n/** Build a Nanostores-style atom facade over a caller-owned node. */\nexport function nanoAtom<T>(\n\tnode: WritableNode<T>,\n\topts?: WritableStoreOptions<T>,\n): WritableNanoAtom<T>;\nexport function nanoAtom<T>(node: Node<T>, opts?: SubscribeValuesOptions<T>): NanoAtom<T>;\nexport function nanoAtom<T>(\n\tnode: Node<T> | WritableNode<T>,\n\topts: SubscribeValuesOptions<T> | WritableStoreOptions<T> = {},\n): NanoAtom<T> | WritableNanoAtom<T> {\n\tconst base: NanoAtom<T> = {\n\t\tget: () => (opts.getSnapshot ?? (() => nodeSnapshot(node)))(),\n\t\tsubscribe: (callback) => subscribeNodeValues(node, callback, { immediate: true, ...opts }),\n\t\tlisten: (callback) => subscribeNodeValues(node, callback, { changesOnly: true, ...opts }),\n\t\t_node: node,\n\t};\n\tif (hasWritableSet(node) || typeof (opts as WritableStoreOptions<T>).write === \"function\") {\n\t\tconst writable = writableStore(\n\t\t\tnode,\n\t\t\topts as WritableStoreOptions<T> & {\n\t\t\t\twrite: (node: WritableNode<T>, value: T) => void;\n\t\t\t},\n\t\t);\n\t\treturn { ...base, set: writable.set, update: writable.update };\n\t}\n\treturn base;\n}\n\n/** Build a TC39-Signals-style facade over a caller-owned node. */\nexport function signalFromNode<T>(\n\tnode: WritableNode<T>,\n\topts?: WritableStoreOptions<T>,\n): WritableSignalLike<T>;\nexport function signalFromNode<T>(node: Node<T>, opts?: SubscribeValuesOptions<T>): SignalLike<T>;\nexport function signalFromNode<T>(\n\tnode: Node<T> | WritableNode<T>,\n\topts: SubscribeValuesOptions<T> | WritableStoreOptions<T> = {},\n): SignalLike<T> | WritableSignalLike<T> {\n\tconst base: SignalLike<T> = {\n\t\tget: () => (opts.getSnapshot ?? (() => nodeSnapshot(node)))(),\n\t\tsubscribe: (callback) => subscribeNodeValues(node, callback, { changesOnly: true, ...opts }),\n\t\t_node: node,\n\t};\n\tif (hasWritableSet(node) || typeof (opts as WritableStoreOptions<T>).write === \"function\") {\n\t\tconst writable = writableStore(\n\t\t\tnode,\n\t\t\topts as WritableStoreOptions<T> & {\n\t\t\t\twrite: (node: WritableNode<T>, value: T) => void;\n\t\t\t},\n\t\t);\n\t\treturn { ...base, set: writable.set, update: writable.update };\n\t}\n\treturn base;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2VA,IAAM,gBAAgB,oBAAI,IAA4B;AAAA,EACrD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC;AAED,IAAM,sBAAsB;AAC5B,IAAM,uBAAuB,oBAAI,QAG/B;AACF,IAAM,uBAAuB,oBAAI,QAG/B;AAGK,SAAS,yBAAyB,WAAmB,KAAqB;AAChF,SAAO,GAAG,SAAS,IAAI,GAAG;AAC3B;AAGO,SAAS,mBAAoC,OAYtB;AAC7B,MAAI,OAAO,MAAM,cAAc,YAAY,MAAM,UAAU,WAAW,GAAG;AACxE,UAAM,IAAI,WAAW,0DAA0D;AAAA,EAChF;AACA,MAAI,CAAC,cAAc,IAAI,MAAM,IAAI,GAAG;AACnC,UAAM,IAAI,WAAW,4CAA4C;AAAA,EAClE;AACA,MAAI,CAAC,sBAAsB,MAAM,GAAG,GAAG;AACtC,UAAM,IAAI,WAAW,oDAAoD;AAAA,EAC1E;AACA,QAAM,SAAS,MAAM,UAAU;AAC/B,MAAI,CAAC,yBAAyB,MAAM,GAAG;AACtC,UA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