You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
transport: split into client/ and server/ subdirectories
Move client-only and server-only transport files into dedicated
subdirectories to make navigability clearer for people finding
their way around the codebase. Split types.ts into shared (root),
client/types.ts, and server/types.ts. Mirror the same structure
in test/core/transport/.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/internals/client-transport.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Client transport
2
2
3
-
The client transport (`src/core/transport/client-transport.ts`) manages the full client-side conversation lifecycle over a single Ably channel. It composes a [stream router](transport-components.md#streamrouter), [conversation tree](conversation-tree.md), and codec [decoder](decoder.md)/[accumulator](codec-interface.md#accumulator) to handle sending messages, receiving streamed responses, managing conversation state, and supporting branching operations (edit, regenerate).
3
+
The client transport (`src/core/transport/client/client-transport.ts`) manages the full client-side conversation lifecycle over a single Ably channel. It composes a [stream router](transport-components.md#streamrouter), [conversation tree](conversation-tree.md), and codec [decoder](decoder.md)/[accumulator](codec-interface.md#accumulator) to handle sending messages, receiving streamed responses, managing conversation state, and supporting branching operations (edit, regenerate).
4
4
5
5
The client never publishes domain messages directly to the channel. Instead, it sends them to the server via HTTP POST. The server publishes user messages and [turn lifecycle events](wire-protocol.md#lifecycle-events) on behalf of the client. The channel subscription is the sole source of truth for conversation state.
Copy file name to clipboardExpand all lines: docs/internals/conversation-tree.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Conversation tree
2
2
3
-
The conversation tree (`src/core/transport/conversation-tree.ts`) materializes a branching conversation from a flat stream of Ably messages. It handles message ordering, sibling grouping for edit/regenerate forks, and branch selection - producing a linear message list via `flatten()` that represents the currently selected conversation path.
3
+
The conversation tree (`src/core/transport/client/conversation-tree.ts`) materializes a branching conversation from a flat stream of Ably messages. It handles message ordering, sibling grouping for edit/regenerate forks, and branch selection - producing a linear message list via `flatten()` that represents the currently selected conversation path.
4
4
5
5
The tree is the single source of truth for conversation state. The transport's `getMessages()` delegates directly to `tree.flatten()`.
Copy file name to clipboardExpand all lines: docs/internals/glossary.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ Every Ably message has an `extras` field that can carry metadata. The AI Transpo
45
45
46
46
The SDK has two layers with a strict boundary:
47
47
48
-
-**Transport layer** - generic machinery shared by all codecs. Handles turn lifecycle, stream routing, optimistic reconciliation, cancel signals, and conversation tree management. Uses `x-ably-*` headers. Lives in `src/core/transport/`.
48
+
-**Transport layer** - generic machinery shared by all codecs. Handles turn lifecycle, stream routing, optimistic reconciliation, cancel signals, and conversation tree management. Uses `x-ably-*` headers. Lives in `src/core/transport/` (with client-side components in `src/core/transport/client/` and server-side components in `src/core/transport/server/`).
49
49
-**Domain layer** - framework-specific encoding/decoding. Maps between domain events (e.g. Vercel's `UIMessageChunk`) and Ably messages. Uses `x-domain-*` headers. Lives in codec implementations (e.g. `src/vercel/codec/`).
50
50
51
51
The [codec interface](codec-interface.md) is the boundary between these layers.
Copy file name to clipboardExpand all lines: docs/internals/history.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# History hydration
2
2
3
-
`decodeHistory` (`src/core/transport/decode-history.ts`) loads conversation history from an Ably channel's history API and returns decoded domain messages. It handles the mismatch between Ably's newest-first history pagination and the decoder's requirement for chronological input.
3
+
`decodeHistory` (`src/core/transport/client/decode-history.ts`) loads conversation history from an Ably channel's history API and returns decoded domain messages. It handles the mismatch between Ably's newest-first history pagination and the decoder's requirement for chronological input.
Copy file name to clipboardExpand all lines: docs/internals/server-transport.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Server transport
2
2
3
-
The server transport (`src/core/transport/server-transport.ts`) handles the server-side turn lifecycle over an Ably channel. It composes a [TurnManager](transport-components.md#turnmanager) for turn state and lifecycle event publishing, and delegates stream piping to [pipeStream](transport-components.md#pipestream).
3
+
The server transport (`src/core/transport/server/server-transport.ts`) handles the server-side turn lifecycle over an Ably channel. It composes a [TurnManager](transport-components.md#turnmanager) for turn state and lifecycle event publishing, and delegates stream piping to [pipeStream](transport-components.md#pipestream).
4
4
5
5
The transport exposes a single factory method - `newTurn()` - which returns a `Turn` object with explicit lifecycle methods: `start()`, `addMessages()`, `streamResponse()`, and `end()`.
The stream router maps decoded events to per-turn `ReadableStream` instances for [own turns](glossary.md#own-turn-vs-observer-turn) - turns this client initiated via `send()`, `regenerate()`, or `edit()`. When the client starts a turn, the router creates a new stream. As decoded events arrive from the channel subscription, the transport routes them through the router to the correct stream.
10
10
@@ -31,7 +31,7 @@ The router accepts an [`isTerminal`](codec-interface.md#the-codec-interface) pre
The turn manager tracks active turns and publishes [turn lifecycle events](wire-protocol.md#lifecycle-events) (`x-ably-turn-start`, `x-ably-turn-end`) on the Ably channel.
37
37
@@ -55,7 +55,7 @@ The turn manager publishes `x-ably-turn-end` **before** deleting local state. If
A pure function that reads events from a `ReadableStream`, writes them through a [streaming encoder](codec-interface.md#encoder-architecture), and handles abort/error. No dependencies on turn state or transport internals.
61
61
@@ -90,7 +90,7 @@ Returns `{ reason }` where reason is `'complete'`, `'cancelled'`, or `'error'`.
90
90
91
91
## Cancel routing (server transport)
92
92
93
-
Cancel routing lives in the server transport (`src/core/transport/server-transport.ts`), not in a separate component.
93
+
Cancel routing lives in the server transport (`src/core/transport/server/server-transport.ts`), not in a separate component.
94
94
95
95
The server transport subscribes to [`x-ably-cancel`](wire-protocol.md#lifecycle-events) events on channel construction. When a cancel message arrives, it:
0 commit comments