@buildanagent/protocol 0.0.0-stage → 0.1.0-alpha.29

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 ADDED
@@ -0,0 +1,54 @@
1
+ buildanagent is open source under five licence terms, one for each kind of
2
+ content in the repository.
3
+
4
+ Code: Apache-2.0 OR MIT, at your option
5
+ Scripts (scripts/), our packages (packages/), the verification harnesses and
6
+ their examples (verify/), the book's code and figure generators (apps/manual/),
7
+ the code of the docs app (apps/docs/) and of the website (apps/site/),
8
+ the CI workflows (.github/), the configuration files, and the code blocks in
9
+ the agent skills (.agents/skills/) are licensed under either of
10
+
11
+ * the Apache License, Version 2.0 (LICENSE-APACHE), or
12
+ * the MIT License (LICENSE-MIT).
13
+
14
+ SPDX-License-Identifier: Apache-2.0 OR MIT
15
+
16
+ Code from the garment engineering textbook: Apache-2.0 only
17
+ Some files in apps/manual/ are copied or adapted from the owner's garment
18
+ engineering textbook (tajistudios/garment-engineering-textbook), with the
19
+ owner's permission. Those files are licensed under the Apache License,
20
+ Version 2.0 (LICENSE-APACHE) only, not under the MIT option above. Each one
21
+ opens with a header comment that names its source and this licence, and
22
+ THIRD-PARTY-NOTICES.md lists each file with its source path and commit.
23
+
24
+ SPDX-License-Identifier: Apache-2.0
25
+
26
+ Documentation: CC BY 4.0
27
+ The documents under docs/, the book's prose and figures (apps/manual/), the
28
+ docs pages (apps/docs/src/content/docs/), the website's pages (apps/site/src/pages/),
29
+ the READMEs, the prose of the agent skills (.agents/skills/) and AGENTS.md are
30
+ licensed under the Creative Commons Attribution 4.0 International licence
31
+ (LICENSE-DOCS).
32
+
33
+ SPDX-License-Identifier: CC-BY-4.0
34
+
35
+ The book's fonts: SIL Open Font License 1.1
36
+ The font files under apps/manual/public/fonts/ are subsets of Instrument
37
+ Serif, Literata and Google Sans Code, and are not ours. They stay under the
38
+ SIL Open Font License, Version 1.1, whose text ships as OFL.txt beside each
39
+ family's files. THIRD-PARTY-NOTICES.md lists each family, its source commit
40
+ and how the subsets are named.
41
+
42
+ SPDX-License-Identifier: OFL-1.1
43
+
44
+ Mirrored third-party docs: their own licences
45
+ The upstream documentation mirrored under docs/reference/*/source/ is not ours.
46
+ Each mirror keeps its upstream licence file, and its _manifest.json records
47
+ the source repository and the tag or commit it was copied from.
48
+ THIRD-PARTY-NOTICES.md lists every mirror and its licence.
49
+
50
+ Copyright (c) 2026 The buildanagent contributors (named agent-speak until
51
+ 2026-11-19).
52
+
53
+ Contributions to this repository are accepted under the same terms: code
54
+ under Apache-2.0 OR MIT, documentation under CC BY 4.0.
package/LICENSE-APACHE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The buildanagent contributors (named agent-speak until 2026-11-19)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,86 @@
1
- # Temporary Holding Version
1
+ # @buildanagent/protocol
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The protocol package holds the types that cross a boundary in a buildanagent harness: the entries of a session log, the messages a client and a harness exchange, and the JSONL framing that carries them. Use it to read a session file, or to write a client in TypeScript or another language.
4
+
5
+ The package depends on the gateway and the SDK for their types only, so its JavaScript loads neither. The harness serves these messages; this package only describes and checks them.
6
+
7
+ `parseEntry()` reads one line of a session file and returns a typed `SessionEntry`:
8
+
9
+ ```ts
10
+ import { parseEntry } from "@buildanagent/protocol";
11
+
12
+ const entry = parseEntry(line); // throws a ProtocolError for a line it can't read
13
+ if (entry.type === "session_header") console.log(entry.formatVersion); // 1
14
+ ```
15
+
16
+ ## Install the alpha with `pnpm add @buildanagent/protocol@alpha`
17
+
18
+ The package needs Node 22.19 or later. npm serves every release under the `alpha` dist-tag until the first stable one:
19
+
20
+ ```sh
21
+ pnpm add @buildanagent/protocol@alpha
22
+ ```
23
+
24
+ All six buildanagent packages share one version, and the protocol depends on that exact version of the gateway and the SDK. Name the tag: a plain `pnpm add @buildanagent/protocol` installs `0.0.0-bootstrap.0`, a deprecated placeholder, because `latest` stays on it until the first stable release.
25
+
26
+ ## A session file is a list of entries, one per line
27
+
28
+ Each line of a session file is one `SessionEntry`: six base fields and the fields of its type. The log is an append-only tree, so an entry names the entry it follows. The harness re-exports the types from `@buildanagent/harness/session`.
29
+
30
+ The base fields are `id`, `parentId` (`null` for the first entry), `seq`, `timestamp` (an ISO 8601 date and time with a zone), `type` and `origin`. The origin says who produced the content: `user`, `operator`, `model`, `tool` or `harness`. A message is several `message_block` entries, one per content block, closed by a `message_end`. The [harness README](https://github.com/laudebugs/buildanagent/blob/main/packages/harness/README.md#the-session-log-holds-twenty-one-entry-types) says what each of the twenty-one types records. A `usage` entry accepts a `cost.total` of `null`, for a price that is unknown. A `code_call` entry records a call the host's own code made, with no model step. An `approval_requested` entry holds the SDK's signed request and the input it would run with, and an `approval_resolved` entry holds a person's answer.
31
+
32
+ The stable surface is the base fields, the entry type names and `formatVersion`, and the `@stable` tag marks each of them in the type declarations. Every other field is documented but may change with a `formatVersion` bump, which ships with a migration that writes a new file. `session_header.product` and the `product_record` entry belong to the product that owns the session, so they sit outside the stable surface.
33
+
34
+ ### `parseEntry()` reads a line and refuses a format it does not know
35
+
36
+ `parseEntry(line)` takes a JSON line or a parsed value and returns a `SessionEntry`. It checks what every reader relies on: the value is an object, its base fields are valid, its `type` is in `SESSION_ENTRY_TYPES`, and a `session_header` has `formatVersion: 1`. A header from any other version throws a `ProtocolError` with code `unsupported_format_version`, so a reader never misreads a newer file. Other failures throw `invalid_entry`. It does not check each type's own fields; the JSON Schema does.
37
+
38
+ ### The JSON Schema describes every entry for other languages
39
+
40
+ The [session entry schema](https://github.com/laudebugs/buildanagent/blob/main/packages/protocol/schema/session-entry.schema.json) is a JSON Schema, draft 2020-12, of one entry. It is generated from a zod description that is checked against the TypeScript types, field by field, so the two accept the same values. The package's own code does not import zod.
41
+
42
+ ## The protocol is JSON-RPC 2.0, one message per line
43
+
44
+ Every message is a JSON-RPC 2.0 message and carries `"jsonrpc": "2.0"`. A client sends commands and answers server requests, and the server sends answers, requests and notifications.
45
+
46
+ - **Client methods.** `initialize`, `session/create`, `session/open`, `session/list`, `turn/start`, `turn/steer`, `turn/followUp`, `turn/interrupt` and `approval/list` are requests, and `$/cancelRequest` is a notification that has no response. `session/checkout` and `session/fork` are experimental: a client opts in by listing the method name in the `capabilities` of its `initialize`, and the server answers `NotOptedIn` otherwise. The server's `experimental` list in its `initialize` result names them. A `turn/start` may carry a top-level `trace` member, a trace context. `session/open` may carry `fromSeq`, the first sequence number of the session's log to replay. `$/cancelRequest` names one of the client's own requests by id.
47
+ - **Turns.** `turn/start`, `turn/steer` and `turn/followUp` answer with a `Disposition`, either `{ accepted: true, turn }` or `{ accepted: false, reason }` with a reason of `busy`, `locked` or `invalid`. Every accepted turn ends with a `turn/settled` notification that carries a `TurnResultSummary`.
48
+ - **Server requests.** The server asks for `approval/request`, `clarification/request` and `tool/call`, each with a string id. The client answers with a response of the same id: `{ resolutions }` for the first two and `{ content, isError }` for a tool call. The server withdraws a request it no longer needs with its own `$/cancelRequest` notification, which carries that request's id, so `$/cancelRequest` is both a client method and a server notification.
49
+ - **Events.** `event` notifications carry the session, a sequence number and either an SDK `AgentEvent` or a `HarnessEvent` (`entry_appended`, `budget_warning`, `context_fill`, `completion_check` or `events_dropped`). An `events_dropped` event stands for events the server dropped for a slow client: its `count` says how many, and the notification's `seq` is the last dropped event's.
50
+ - **Errors.** `ErrorCodes` holds the standard JSON-RPC codes and three of ours: `QueueFull` (-32001), `SessionLocked` (-32002) and `NotOptedIn` (-32003).
51
+ - **Envelope check.** `decode()` and `encode()` check the envelope and nothing else, because a method's params are the dispatcher's to check. Each of these throws a `ProtocolError` with code `invalid_request`: a message without `jsonrpc: "2.0"`, a batch, an id that isn't a number or a string, and a response with both or neither of `result` and `error`. Its `rpcCode` and `requestId` say what to answer with. Text that isn't JSON throws `invalid_json`.
52
+
53
+ ### The framer splits on newlines only
54
+
55
+ `JsonlFramer` turns a byte stream into messages. Its `push(chunk)` returns one result for each line the chunk finished, either `{ ok: true, value }` or `{ ok: false, error }`, so one bad line never stops the lines after it:
56
+
57
+ ```ts
58
+ const framer = new JsonlFramer();
59
+ for (const result of framer.push(chunk)) console.log(result.ok ? result.value : result.error.code);
60
+ ```
61
+
62
+ It splits on `\n` and nothing else, and never uses Node's `readline`, which also ends a line at a lone `\r`. Pi's RPC documentation warns that a line reader may split at U+2028 and U+2029 too, characters that may sit inside a JSON string. When checked, Node 22's `readline` did not split at either, but a reader in another language might, so the rule is to split on the newline byte alone. A line is decoded only when it is whole, so a character cut across two chunks is read correctly. The framer drops a trailing `\r`, skips blank lines, and skips a line over `maxLineBytes` (default 8 MiB) after reporting it once. Its `end()` reports a last line that was never finished.
63
+
64
+ ### The protocol schema covers every message
65
+
66
+ The [protocol schema](https://github.com/laudebugs/buildanagent/blob/main/packages/protocol/schema/protocol.schema.json) is a JSON Schema, draft 2020-12, of one message in either direction, generated and checked the same way as the entry schema. Every message kind has a sample message that the compiler checks against its type and the schema validates. The shared shapes under `$defs` are named by a hash of their content, so adding one doesn't rename the others.
67
+
68
+ One part is loose on purpose. An SDK `AgentEvent` in an `event` notification is checked for its `type` and the base fields every event has, because the SDK owns that contract. The schema's list of event types is kept equal to the SDK's.
69
+
70
+ ## Over stdio, each message is one line, and stdout carries nothing else
71
+
72
+ `stdioTransport(dispatcher, io)` from `@buildanagent/harness/server` serves the protocol over a pair of byte streams, and the CLI's `buildanagent rpc` command runs it on its own stdin and stdout. The client writes commands and answers to the server's stdin and reads everything the server sends from its stdout. Each message is one line of UTF-8 JSON ending in `\n`. The server writes it with `encode()` and reads with `JsonlFramer` and `decode()`, so the rules above hold on the wire unchanged. The [harness README](https://github.com/laudebugs/buildanagent/blob/main/packages/harness/README.md#stdiotransport-serves-one-client-over-a-pair-of-byte-streams) says how a host calls it.
73
+
74
+ Five rules govern the stream:
75
+
76
+ - **stdout holds protocol lines only.** The transport writes its own diagnostics, such as a line it refused, to the `log` function the host passes, and the host points it at stderr. A client can therefore treat any stdout line that is not a JSON-RPC message as a broken server.
77
+ - **A bad line gets an error, and the stream goes on.** A line that isn't JSON gets `ParseError` (-32700). A message without a valid envelope, a batch, or a line over the bound (8 MiB by default) gets `InvalidRequest` (-32600). The error carries the request's id when the transport could read it and `null` otherwise, as JSON-RPC 2.0 requires. A malformed response, one that carries `result` or `error`, gets no answer, because JSON-RPC never answers a response; the transport logs it.
78
+ - **Commands run concurrently.** The server may answer commands out of order, as JSON-RPC allows. A client therefore waits for one command's response before it sends a command that depends on it, such as `turn/start` after `session/create`.
79
+ - **A client that stops reading slows the server down.** The transport waits for stdout to drain before it writes the next message, so the backlog stays near the pipe's own buffer. Live events past the queue bound are dropped and replaced by an `events_dropped` marker, as the [harness README](https://github.com/laudebugs/buildanagent/blob/main/packages/harness/README.md#each-connections-queues-are-bounded-at-128-and-only-events-are-dropped) describes, and `session/open` with `fromSeq` returns the dropped entries.
80
+ - **The end of stdin is the client's goodbye.** The server answers every command it has read and writes every line, then closes the connection. After stdin ends, the output must take each line within `writeTimeoutMs` (30 seconds by default in the harness's transport), or the transport stops. A turn still running goes on in the dispatcher, but its events have nowhere to go, so a client that wants `turn/settled` keeps stdin open until it arrives.
81
+
82
+ ### Two outside JSON-RPC libraries read every message the server sends
83
+
84
+ The open question was whether a client we did not write could read our framing. The framing check in [`packages/harness/test/server/framing-interop.test.ts`](https://github.com/laudebugs/buildanagent/blob/main/packages/harness/test/server/framing-interop.test.ts) answers it. It runs a turn that asks for approval through a server in a child process, and two libraries read the stream: `json-rpc-2.0` 1.8.1, a generic JSON-RPC 2.0 peer, and the stdio `ReadBuffer` of `@modelcontextprotocol/client` 2.4.0, which checks each message against MCP's strict schema. Both versions, and what follows about their behaviour, are as of November 2026. Both read every response, error, notification and server request without an adapter, and both answer the server's `approval/request`. Only the error for an unreadable line differs. Its `id` is `null`, as JSON-RPC 2.0 requires, and MCP's schema in 2.4.0 accepts an error with no `id` but refuses a `null` one, so an MCP-based client counts that one response as invalid. The protocol keeps `null`, because the JSON-RPC 2.0 specification asks for it.
85
+
86
+ To see the harness that writes these entries and serves these messages, read the [harness README](https://github.com/laudebugs/buildanagent/blob/main/packages/harness/README.md).