@harapter/transport-jsonl-process 0.1.1
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 +201 -0
- package/README.md +112 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +538 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Harapter contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# `@harapter/transport-jsonl-process`
|
|
2
|
+
|
|
3
|
+
`@harapter/transport-jsonl-process` is a bounded strict-JSONL transport for
|
|
4
|
+
Provider Adapters that communicate with a host-supplied harness process.
|
|
5
|
+
|
|
6
|
+
The package owns UTF-8 framing, ordered inbound delivery, serialized writes,
|
|
7
|
+
backpressure, local write waits, connection disposal, and explicit resource
|
|
8
|
+
limits. It does not spawn or discover executables, correlate protocol requests,
|
|
9
|
+
interpret Provider messages, or assign Harapter Session, Run, Event, error, or
|
|
10
|
+
cancellation semantics.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @harapter/transport-jsonl-process@next
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Public entrypoints
|
|
19
|
+
|
|
20
|
+
- `JsonlProcessTransport` sends JSON objects and exposes received objects as one
|
|
21
|
+
ordered async iterable.
|
|
22
|
+
- `JsonlMessage` is the untyped JSON object boundary that a consuming Provider
|
|
23
|
+
must validate before interpreting or exposing it.
|
|
24
|
+
- `JsonlSendOptions` controls only the local wait for a complete write through
|
|
25
|
+
an optional timeout or `AbortSignal`.
|
|
26
|
+
- `JsonlTransportError` provides stable, content-free failure codes for Provider
|
|
27
|
+
error mapping.
|
|
28
|
+
|
|
29
|
+
## Framing and limits
|
|
30
|
+
|
|
31
|
+
Each message is one UTF-8 JSON object followed by LF (`\n`). Inbound CRLF is
|
|
32
|
+
accepted by stripping one trailing delimiter CR. Other Unicode separators,
|
|
33
|
+
including U+2028 and U+2029 inside JSON strings, are data and never delimit
|
|
34
|
+
records. Empty records, arrays, primitives, invalid UTF-8, malformed JSON, and
|
|
35
|
+
truncated final records fail the connection.
|
|
36
|
+
|
|
37
|
+
Defaults are finite:
|
|
38
|
+
|
|
39
|
+
- `maxMessageBytes`: 1 MiB per encoded message, excluding LF and an optional
|
|
40
|
+
delimiter CR;
|
|
41
|
+
- `maxBufferedMessages`: 128 unread inbound messages;
|
|
42
|
+
- `maxPendingWrites`: 128 active or queued outbound writes;
|
|
43
|
+
- `writeTimeoutMs`: 30 seconds for the caller's local write wait.
|
|
44
|
+
|
|
45
|
+
Every limit must be a positive safe integer. Timeouts cannot exceed
|
|
46
|
+
2,147,483,647 milliseconds, the maximum delay Node timers preserve without
|
|
47
|
+
overflow.
|
|
48
|
+
|
|
49
|
+
## Lifecycle
|
|
50
|
+
|
|
51
|
+
The caller supplies and owns the readable and writable streams. The transport
|
|
52
|
+
does not end or destroy them. An optional `cleanup` callback lets the Provider
|
|
53
|
+
Connection stop or detach its surrounding process policy; it runs at most once
|
|
54
|
+
after explicit close, malformed input, stream failure, premature EOF, or another
|
|
55
|
+
terminal transport failure.
|
|
56
|
+
|
|
57
|
+
Exactly one consumer may claim `incoming()`. Returning from that consumer closes
|
|
58
|
+
the logical transport because unread Provider output would otherwise have no
|
|
59
|
+
owner. Explicit close completes a waiting iterator normally. After an unexpected
|
|
60
|
+
stream or protocol boundary, complete records already received remain ordered
|
|
61
|
+
and observable before iteration rejects with a safe transport error.
|
|
62
|
+
|
|
63
|
+
Writes are serialized until each Node write callback settles. A local abort or
|
|
64
|
+
timeout skips a queued frame only when writing has not started. Once a write has
|
|
65
|
+
started, the Provider may receive it even if the local wait ends. The transport
|
|
66
|
+
does not emit an abort message and supplies no evidence of native Run
|
|
67
|
+
cancellation. Close retains one bounded terminal error guard until cleanup and
|
|
68
|
+
every already-started write callback settle.
|
|
69
|
+
|
|
70
|
+
## Errors and sensitive data
|
|
71
|
+
|
|
72
|
+
Transport errors contain fixed messages and never retain a frame, stream error,
|
|
73
|
+
identifier, or Provider payload. Received objects remain untrusted and may
|
|
74
|
+
contain sensitive data. The consuming Provider Adapter must validate and redact
|
|
75
|
+
them before producing Harapter events, errors, diagnostics, logs, fixtures, or
|
|
76
|
+
raw-channel observations.
|
|
77
|
+
|
|
78
|
+
## Example
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { JsonlProcessTransport } from '@harapter/transport-jsonl-process';
|
|
82
|
+
|
|
83
|
+
const transport = new JsonlProcessTransport({
|
|
84
|
+
readable: controlledProcess.stdout,
|
|
85
|
+
writable: controlledProcess.stdin,
|
|
86
|
+
cleanup: () => stopControlledProcess(controlledProcess),
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const inbound = (async () => {
|
|
90
|
+
for await (const message of transport.incoming()) {
|
|
91
|
+
await validateAndMapProviderMessage(message);
|
|
92
|
+
}
|
|
93
|
+
})();
|
|
94
|
+
|
|
95
|
+
await transport.send({ id: 'request-1', type: 'prompt', message: 'Hello' });
|
|
96
|
+
await transport.close();
|
|
97
|
+
await inbound;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Process creation, request correlation, startup negotiation, Session ownership,
|
|
101
|
+
Run terminality, Provider-native cancellation, redaction, compatibility, and
|
|
102
|
+
capabilities belong to the consuming Provider Adapter.
|
|
103
|
+
|
|
104
|
+
## Limitations
|
|
105
|
+
|
|
106
|
+
- This is not a process manager, request/response protocol, Provider Adapter,
|
|
107
|
+
retry layer, logger, or agent loop.
|
|
108
|
+
- Exactly one inbound consumer is supported.
|
|
109
|
+
- Messages must be JSON objects that fit on one LF-delimited record.
|
|
110
|
+
- A successful `send()` proves only that Node completed the local write
|
|
111
|
+
callback; it does not prove Provider acceptance or execution.
|
|
112
|
+
- No Provider support claim follows from this package alone.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { Readable, Writable } from 'node:stream';
|
|
2
|
+
import { inspect } from 'node:util';
|
|
3
|
+
/** One provider-owned JSON object carried by the transport. */
|
|
4
|
+
export type JsonlMessage = Readonly<Record<string, unknown>>;
|
|
5
|
+
/** Stable transport failure categories for Provider error mapping. */
|
|
6
|
+
export type JsonlTransportErrorCode = 'capacity_exceeded' | 'cleanup_failed' | 'consumer_conflict' | 'invalid_configuration' | 'invalid_outbound_message' | 'malformed_message' | 'message_too_large' | 'stream_ended' | 'stream_failed' | 'transport_closed' | 'truncated_message' | 'write_aborted' | 'write_failed' | 'write_timeout';
|
|
7
|
+
/** Safe transport failure that never includes a frame or stream error body. */
|
|
8
|
+
export declare class JsonlTransportError extends Error {
|
|
9
|
+
readonly code: JsonlTransportErrorCode;
|
|
10
|
+
constructor(code: JsonlTransportErrorCode, message: string);
|
|
11
|
+
/** Keep generic JSON error logging bounded and content-free. */
|
|
12
|
+
toJSON(): Readonly<{
|
|
13
|
+
code: JsonlTransportErrorCode;
|
|
14
|
+
message: string;
|
|
15
|
+
name: string;
|
|
16
|
+
}>;
|
|
17
|
+
/** Keep Node inspection bounded and content-free. */
|
|
18
|
+
[inspect.custom](): string;
|
|
19
|
+
}
|
|
20
|
+
/** Local controls for waiting until one complete frame is written. */
|
|
21
|
+
export interface JsonlSendOptions {
|
|
22
|
+
readonly signal?: AbortSignal;
|
|
23
|
+
readonly timeoutMs?: number;
|
|
24
|
+
}
|
|
25
|
+
/** Explicit stream, lifecycle, and resource limits for one connection. */
|
|
26
|
+
export interface JsonlProcessTransportOptions {
|
|
27
|
+
readonly readable: Readable;
|
|
28
|
+
readonly writable: Writable;
|
|
29
|
+
readonly cleanup?: () => Promise<void> | void;
|
|
30
|
+
readonly maxMessageBytes?: number;
|
|
31
|
+
readonly maxBufferedMessages?: number;
|
|
32
|
+
readonly maxPendingWrites?: number;
|
|
33
|
+
readonly writeTimeoutMs?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Bounded strict-JSONL transport over caller-owned process streams.
|
|
37
|
+
* Provider Adapters own every message envelope and lifecycle interpretation.
|
|
38
|
+
*/
|
|
39
|
+
export declare class JsonlProcessTransport {
|
|
40
|
+
private readonly readable;
|
|
41
|
+
private readonly writable;
|
|
42
|
+
private readonly cleanup;
|
|
43
|
+
private readonly maxMessageBytes;
|
|
44
|
+
private readonly maxPendingWrites;
|
|
45
|
+
private readonly writeTimeoutMs;
|
|
46
|
+
private readonly inboundQueue;
|
|
47
|
+
private readonly pendingWriteWaits;
|
|
48
|
+
private readonly activeWriteRejectors;
|
|
49
|
+
private readonly terminalGuardStreams;
|
|
50
|
+
private lineChunks;
|
|
51
|
+
private lineBytes;
|
|
52
|
+
private pendingWrites;
|
|
53
|
+
private incomingClaimed;
|
|
54
|
+
private open;
|
|
55
|
+
private terminalError;
|
|
56
|
+
private cleanupFailure;
|
|
57
|
+
private cleanupPromise;
|
|
58
|
+
private cleanupSettled;
|
|
59
|
+
private activePhysicalWrites;
|
|
60
|
+
private terminalGuardReleaseScheduled;
|
|
61
|
+
private resolveTerminalGuardRelease;
|
|
62
|
+
private writeTail;
|
|
63
|
+
private writableCallbackFailed;
|
|
64
|
+
private readonly handleReadableData;
|
|
65
|
+
private readonly handleReadableEnd;
|
|
66
|
+
private readonly handleStreamError;
|
|
67
|
+
private readonly handleWritableError;
|
|
68
|
+
private readonly handleStreamClose;
|
|
69
|
+
constructor(options: JsonlProcessTransportOptions);
|
|
70
|
+
/** Send one JSON object and wait until its complete frame is flushed. */
|
|
71
|
+
send(message: JsonlMessage, options?: JsonlSendOptions): Promise<void>;
|
|
72
|
+
/** Iterate provider-owned JSON objects in wire order. */
|
|
73
|
+
incoming(): AsyncIterableIterator<JsonlMessage>;
|
|
74
|
+
/** Whether the logical transport can still accept operations. */
|
|
75
|
+
isOpen(): boolean;
|
|
76
|
+
/** Close the logical transport and run caller-provided cleanup once. */
|
|
77
|
+
close(): Promise<void>;
|
|
78
|
+
private iterateIncoming;
|
|
79
|
+
private encode;
|
|
80
|
+
private enqueueWrite;
|
|
81
|
+
private writeFrame;
|
|
82
|
+
private resolveWriteWait;
|
|
83
|
+
private rejectWriteWait;
|
|
84
|
+
private finishWriteWait;
|
|
85
|
+
private consumeChunk;
|
|
86
|
+
private appendLineSegment;
|
|
87
|
+
private consumeLine;
|
|
88
|
+
private assertOpen;
|
|
89
|
+
private fail;
|
|
90
|
+
private terminate;
|
|
91
|
+
private detachStreams;
|
|
92
|
+
private startCleanup;
|
|
93
|
+
private armTerminalErrorGuards;
|
|
94
|
+
private releaseTerminalErrorGuards;
|
|
95
|
+
private maybeReleaseTerminalErrorGuards;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,+DAA+D;AAC/D,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE7D,sEAAsE;AACtE,MAAM,MAAM,uBAAuB,GAC/B,mBAAmB,GACnB,gBAAgB,GAChB,mBAAmB,GACnB,uBAAuB,GACvB,0BAA0B,GAC1B,mBAAmB,GACnB,mBAAmB,GACnB,cAAc,GACd,eAAe,GACf,kBAAkB,GAClB,mBAAmB,GACnB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;IAY9B,OAAO,CAAC,MAAM;IA+Bd,OAAO,CAAC,YAAY;IAgEpB,OAAO,CAAC,UAAU;IA6ClB,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,iBAAiB;IAmBzB,OAAO,CAAC,WAAW;IA8CnB,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,IAAI;IAKZ,OAAO,CAAC,SAAS;IAqBjB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,YAAY;IAqBpB,OAAO,CAAC,sBAAsB;IAQ9B,OAAO,CAAC,0BAA0B;IAOlC,OAAO,CAAC,+BAA+B;CAexC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
import { setImmediate as scheduleImmediate } from 'node:timers';
|
|
2
|
+
import { inspect } from 'node:util';
|
|
3
|
+
const defaultMaxMessageBytes = 1024 * 1024;
|
|
4
|
+
const defaultMaxBufferedMessages = 128;
|
|
5
|
+
const defaultMaxPendingWrites = 128;
|
|
6
|
+
const defaultWriteTimeoutMs = 30_000;
|
|
7
|
+
const maximumTimerMilliseconds = 2_147_483_647;
|
|
8
|
+
/** Safe transport failure that never includes a frame or stream error body. */
|
|
9
|
+
export class JsonlTransportError extends Error {
|
|
10
|
+
code;
|
|
11
|
+
constructor(code, message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = 'JsonlTransportError';
|
|
14
|
+
this.code = code;
|
|
15
|
+
}
|
|
16
|
+
/** Keep generic JSON error logging bounded and content-free. */
|
|
17
|
+
toJSON() {
|
|
18
|
+
return { code: this.code, message: this.message, name: this.name };
|
|
19
|
+
}
|
|
20
|
+
/** Keep Node inspection bounded and content-free. */
|
|
21
|
+
[inspect.custom]() {
|
|
22
|
+
return `${this.name} [${this.code}]: ${this.message}`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
class InboundQueue {
|
|
26
|
+
capacity;
|
|
27
|
+
values = [];
|
|
28
|
+
waiter;
|
|
29
|
+
failure;
|
|
30
|
+
closed = false;
|
|
31
|
+
constructor(capacity) {
|
|
32
|
+
this.capacity = capacity;
|
|
33
|
+
}
|
|
34
|
+
push(value) {
|
|
35
|
+
if (this.closed)
|
|
36
|
+
return false;
|
|
37
|
+
if (this.waiter) {
|
|
38
|
+
const waiter = this.waiter;
|
|
39
|
+
this.waiter = undefined;
|
|
40
|
+
waiter.resolve({ done: false, value });
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
if (this.values.length >= this.capacity)
|
|
44
|
+
return false;
|
|
45
|
+
this.values.push(value);
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
next() {
|
|
49
|
+
const value = this.values.shift();
|
|
50
|
+
if (value)
|
|
51
|
+
return Promise.resolve({ done: false, value });
|
|
52
|
+
if (this.failure)
|
|
53
|
+
return Promise.reject(this.failure);
|
|
54
|
+
if (this.closed)
|
|
55
|
+
return Promise.resolve({ done: true, value: undefined });
|
|
56
|
+
if (this.waiter) {
|
|
57
|
+
return Promise.reject(transportError('consumer_conflict', 'Only one inbound read may be pending at a time.'));
|
|
58
|
+
}
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
this.waiter = { resolve, reject };
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
close(failure) {
|
|
64
|
+
if (this.closed)
|
|
65
|
+
return;
|
|
66
|
+
this.closed = true;
|
|
67
|
+
this.failure = failure;
|
|
68
|
+
if (!failure)
|
|
69
|
+
this.values.length = 0;
|
|
70
|
+
if (!this.waiter)
|
|
71
|
+
return;
|
|
72
|
+
const waiter = this.waiter;
|
|
73
|
+
this.waiter = undefined;
|
|
74
|
+
if (failure)
|
|
75
|
+
waiter.reject(failure);
|
|
76
|
+
else
|
|
77
|
+
waiter.resolve({ done: true, value: undefined });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Bounded strict-JSONL transport over caller-owned process streams.
|
|
82
|
+
* Provider Adapters own every message envelope and lifecycle interpretation.
|
|
83
|
+
*/
|
|
84
|
+
export class JsonlProcessTransport {
|
|
85
|
+
readable;
|
|
86
|
+
writable;
|
|
87
|
+
cleanup;
|
|
88
|
+
maxMessageBytes;
|
|
89
|
+
maxPendingWrites;
|
|
90
|
+
writeTimeoutMs;
|
|
91
|
+
inboundQueue;
|
|
92
|
+
pendingWriteWaits = new Set();
|
|
93
|
+
activeWriteRejectors = new Set();
|
|
94
|
+
terminalGuardStreams = new Set();
|
|
95
|
+
lineChunks = [];
|
|
96
|
+
lineBytes = 0;
|
|
97
|
+
pendingWrites = 0;
|
|
98
|
+
incomingClaimed = false;
|
|
99
|
+
open = true;
|
|
100
|
+
terminalError;
|
|
101
|
+
cleanupFailure;
|
|
102
|
+
cleanupPromise;
|
|
103
|
+
cleanupSettled = false;
|
|
104
|
+
activePhysicalWrites = 0;
|
|
105
|
+
terminalGuardReleaseScheduled = false;
|
|
106
|
+
resolveTerminalGuardRelease;
|
|
107
|
+
writeTail = Promise.resolve();
|
|
108
|
+
writableCallbackFailed = false;
|
|
109
|
+
handleReadableData = (chunk) => {
|
|
110
|
+
if (!this.open)
|
|
111
|
+
return;
|
|
112
|
+
if (typeof chunk !== 'string' &&
|
|
113
|
+
!Buffer.isBuffer(chunk) &&
|
|
114
|
+
!(chunk instanceof Uint8Array)) {
|
|
115
|
+
this.fail(transportError('stream_failed', 'The readable stream emitted an unsupported chunk.'));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this.consumeChunk(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
119
|
+
};
|
|
120
|
+
handleReadableEnd = () => {
|
|
121
|
+
if (!this.open)
|
|
122
|
+
return;
|
|
123
|
+
this.fail(this.lineBytes > 0
|
|
124
|
+
? transportError('truncated_message', 'The readable stream ended with an incomplete JSONL frame.')
|
|
125
|
+
: transportError('stream_ended', 'The readable stream ended before the transport was closed.'));
|
|
126
|
+
};
|
|
127
|
+
handleStreamError = (_error) => {
|
|
128
|
+
this.fail(transportError('stream_failed', 'A transport stream reported a failure.'));
|
|
129
|
+
};
|
|
130
|
+
handleWritableError = (_error) => {
|
|
131
|
+
this.fail(this.writableCallbackFailed
|
|
132
|
+
? transportError('write_failed', 'The transport could not write a JSONL frame.')
|
|
133
|
+
: transportError('stream_failed', 'A transport stream reported a failure.'));
|
|
134
|
+
};
|
|
135
|
+
handleStreamClose = () => {
|
|
136
|
+
if (!this.open)
|
|
137
|
+
return;
|
|
138
|
+
this.fail(transportError('stream_ended', 'A transport stream closed before the transport was closed.'));
|
|
139
|
+
};
|
|
140
|
+
constructor(options) {
|
|
141
|
+
this.maxMessageBytes = positiveInteger(options.maxMessageBytes ?? defaultMaxMessageBytes);
|
|
142
|
+
const maxBufferedMessages = positiveInteger(options.maxBufferedMessages ?? defaultMaxBufferedMessages);
|
|
143
|
+
this.maxPendingWrites = positiveInteger(options.maxPendingWrites ?? defaultMaxPendingWrites);
|
|
144
|
+
this.writeTimeoutMs = timerMilliseconds(options.writeTimeoutMs ?? defaultWriteTimeoutMs);
|
|
145
|
+
this.readable = options.readable;
|
|
146
|
+
this.writable = options.writable;
|
|
147
|
+
this.cleanup = options.cleanup;
|
|
148
|
+
this.inboundQueue = new InboundQueue(maxBufferedMessages);
|
|
149
|
+
this.readable.on('data', this.handleReadableData);
|
|
150
|
+
this.readable.once('end', this.handleReadableEnd);
|
|
151
|
+
this.readable.once('error', this.handleStreamError);
|
|
152
|
+
this.readable.once('close', this.handleStreamClose);
|
|
153
|
+
this.writable.once('error', this.handleWritableError);
|
|
154
|
+
this.writable.once('close', this.handleStreamClose);
|
|
155
|
+
if (this.readable.readableEnded)
|
|
156
|
+
this.handleReadableEnd();
|
|
157
|
+
else if (this.readable.destroyed ||
|
|
158
|
+
this.readable.closed ||
|
|
159
|
+
this.writable.destroyed ||
|
|
160
|
+
this.writable.closed) {
|
|
161
|
+
this.handleStreamClose();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/** Send one JSON object and wait until its complete frame is flushed. */
|
|
165
|
+
send(message, options = {}) {
|
|
166
|
+
try {
|
|
167
|
+
this.assertOpen();
|
|
168
|
+
if (options.signal?.aborted) {
|
|
169
|
+
throw transportError('write_aborted', 'The local write wait was aborted before the frame was sent.');
|
|
170
|
+
}
|
|
171
|
+
if (this.pendingWrites >= this.maxPendingWrites) {
|
|
172
|
+
throw transportError('capacity_exceeded', 'The pending transport write limit was reached.');
|
|
173
|
+
}
|
|
174
|
+
const timeoutMs = timerMilliseconds(options.timeoutMs ?? this.writeTimeoutMs);
|
|
175
|
+
const frame = this.encode(message);
|
|
176
|
+
this.assertOpen();
|
|
177
|
+
return this.enqueueWrite(frame, options.signal, timeoutMs);
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
return Promise.reject(asTransportError(error));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/** Iterate provider-owned JSON objects in wire order. */
|
|
184
|
+
incoming() {
|
|
185
|
+
if (this.incomingClaimed) {
|
|
186
|
+
throw transportError('consumer_conflict', 'The inbound message stream already has a consumer.');
|
|
187
|
+
}
|
|
188
|
+
this.incomingClaimed = true;
|
|
189
|
+
const source = this.iterateIncoming();
|
|
190
|
+
return {
|
|
191
|
+
[Symbol.asyncIterator]() {
|
|
192
|
+
return this;
|
|
193
|
+
},
|
|
194
|
+
next: () => source.next(),
|
|
195
|
+
return: async () => {
|
|
196
|
+
await this.close();
|
|
197
|
+
return source.return(undefined);
|
|
198
|
+
},
|
|
199
|
+
throw: async (error) => {
|
|
200
|
+
await this.close();
|
|
201
|
+
return source.throw(error);
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/** Whether the logical transport can still accept operations. */
|
|
206
|
+
isOpen() {
|
|
207
|
+
return this.open;
|
|
208
|
+
}
|
|
209
|
+
/** Close the logical transport and run caller-provided cleanup once. */
|
|
210
|
+
async close() {
|
|
211
|
+
if (this.open) {
|
|
212
|
+
this.terminate(undefined, transportError('transport_closed', 'The transport was closed.'));
|
|
213
|
+
}
|
|
214
|
+
await this.cleanupPromise;
|
|
215
|
+
if (this.cleanupFailure)
|
|
216
|
+
throw this.cleanupFailure;
|
|
217
|
+
}
|
|
218
|
+
async *iterateIncoming() {
|
|
219
|
+
try {
|
|
220
|
+
for (;;) {
|
|
221
|
+
const next = await this.inboundQueue.next();
|
|
222
|
+
if (next.done)
|
|
223
|
+
return;
|
|
224
|
+
yield next.value;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
finally {
|
|
228
|
+
if (this.open)
|
|
229
|
+
await this.close();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
encode(message) {
|
|
233
|
+
if (!isRecord(message)) {
|
|
234
|
+
throw transportError('invalid_outbound_message', 'The outbound JSONL message must be a JSON object.');
|
|
235
|
+
}
|
|
236
|
+
let encoded;
|
|
237
|
+
try {
|
|
238
|
+
encoded = JSON.stringify(message);
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
throw transportError('invalid_outbound_message', 'The outbound JSONL message is not JSON serializable.');
|
|
242
|
+
}
|
|
243
|
+
if (!encoded || !isSerializedRecord(encoded)) {
|
|
244
|
+
throw transportError('invalid_outbound_message', 'The outbound JSONL message must serialize to a JSON object.');
|
|
245
|
+
}
|
|
246
|
+
if (Buffer.byteLength(encoded) > this.maxMessageBytes) {
|
|
247
|
+
throw transportError('message_too_large', 'The outbound JSONL message exceeds the configured limit.');
|
|
248
|
+
}
|
|
249
|
+
return `${encoded}\n`;
|
|
250
|
+
}
|
|
251
|
+
enqueueWrite(frame, signal, timeoutMs) {
|
|
252
|
+
this.pendingWrites += 1;
|
|
253
|
+
let state;
|
|
254
|
+
const wait = new Promise((resolve, reject) => {
|
|
255
|
+
const abortListener = signal
|
|
256
|
+
? () => {
|
|
257
|
+
this.rejectWriteWait(state, transportError('write_aborted', 'The local write wait was aborted.'));
|
|
258
|
+
}
|
|
259
|
+
: undefined;
|
|
260
|
+
const timer = setTimeout(() => {
|
|
261
|
+
this.rejectWriteWait(state, transportError('write_timeout', 'The JSONL write wait timed out.'));
|
|
262
|
+
}, timeoutMs);
|
|
263
|
+
timer.unref();
|
|
264
|
+
state = {
|
|
265
|
+
abortListener,
|
|
266
|
+
reject,
|
|
267
|
+
resolve,
|
|
268
|
+
signal,
|
|
269
|
+
started: false,
|
|
270
|
+
settled: false,
|
|
271
|
+
timer,
|
|
272
|
+
};
|
|
273
|
+
this.pendingWriteWaits.add(state);
|
|
274
|
+
if (abortListener) {
|
|
275
|
+
signal?.addEventListener('abort', abortListener, { once: true });
|
|
276
|
+
if (signal?.aborted)
|
|
277
|
+
abortListener();
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
const operation = this.writeTail.then(async () => {
|
|
281
|
+
this.assertOpen();
|
|
282
|
+
if (state.settled)
|
|
283
|
+
return;
|
|
284
|
+
state.started = true;
|
|
285
|
+
await this.writeFrame(frame);
|
|
286
|
+
});
|
|
287
|
+
const tracked = operation
|
|
288
|
+
.then(() => {
|
|
289
|
+
this.resolveWriteWait(state);
|
|
290
|
+
}, (error) => {
|
|
291
|
+
this.rejectWriteWait(state, asTransportError(error));
|
|
292
|
+
})
|
|
293
|
+
.finally(() => {
|
|
294
|
+
this.pendingWrites -= 1;
|
|
295
|
+
});
|
|
296
|
+
this.writeTail = tracked.catch(() => undefined);
|
|
297
|
+
return wait;
|
|
298
|
+
}
|
|
299
|
+
writeFrame(frame) {
|
|
300
|
+
return new Promise((resolve, reject) => {
|
|
301
|
+
let settled = false;
|
|
302
|
+
const rejectWrite = (error) => {
|
|
303
|
+
if (settled)
|
|
304
|
+
return;
|
|
305
|
+
settled = true;
|
|
306
|
+
this.activeWriteRejectors.delete(rejectWrite);
|
|
307
|
+
reject(error);
|
|
308
|
+
};
|
|
309
|
+
const resolveWrite = () => {
|
|
310
|
+
if (settled)
|
|
311
|
+
return;
|
|
312
|
+
settled = true;
|
|
313
|
+
this.activeWriteRejectors.delete(rejectWrite);
|
|
314
|
+
resolve();
|
|
315
|
+
};
|
|
316
|
+
this.activeWriteRejectors.add(rejectWrite);
|
|
317
|
+
this.activePhysicalWrites += 1;
|
|
318
|
+
let physicalWriteSettled = false;
|
|
319
|
+
const settlePhysicalWrite = () => {
|
|
320
|
+
if (physicalWriteSettled)
|
|
321
|
+
return;
|
|
322
|
+
physicalWriteSettled = true;
|
|
323
|
+
this.activePhysicalWrites -= 1;
|
|
324
|
+
this.maybeReleaseTerminalErrorGuards();
|
|
325
|
+
};
|
|
326
|
+
try {
|
|
327
|
+
this.writable.write(frame, (error) => {
|
|
328
|
+
if (error) {
|
|
329
|
+
this.writableCallbackFailed = true;
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
resolveWrite();
|
|
333
|
+
}
|
|
334
|
+
settlePhysicalWrite();
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
settlePhysicalWrite();
|
|
339
|
+
this.fail(transportError('write_failed', 'The transport could not write a JSONL frame.'));
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
resolveWriteWait(state) {
|
|
344
|
+
if (state.settled)
|
|
345
|
+
return;
|
|
346
|
+
this.finishWriteWait(state);
|
|
347
|
+
state.resolve();
|
|
348
|
+
}
|
|
349
|
+
rejectWriteWait(state, error) {
|
|
350
|
+
if (state.settled)
|
|
351
|
+
return;
|
|
352
|
+
this.finishWriteWait(state);
|
|
353
|
+
state.reject(error);
|
|
354
|
+
}
|
|
355
|
+
finishWriteWait(state) {
|
|
356
|
+
state.settled = true;
|
|
357
|
+
clearTimeout(state.timer);
|
|
358
|
+
if (state.abortListener) {
|
|
359
|
+
state.signal?.removeEventListener('abort', state.abortListener);
|
|
360
|
+
}
|
|
361
|
+
this.pendingWriteWaits.delete(state);
|
|
362
|
+
}
|
|
363
|
+
consumeChunk(chunk) {
|
|
364
|
+
let segmentStart = 0;
|
|
365
|
+
for (let index = 0; index < chunk.length && this.open; index += 1) {
|
|
366
|
+
if (chunk[index] !== 0x0a)
|
|
367
|
+
continue;
|
|
368
|
+
if (!this.appendLineSegment(chunk.subarray(segmentStart, index)))
|
|
369
|
+
return;
|
|
370
|
+
this.consumeLine();
|
|
371
|
+
segmentStart = index + 1;
|
|
372
|
+
}
|
|
373
|
+
if (this.open && segmentStart < chunk.length) {
|
|
374
|
+
this.appendLineSegment(chunk.subarray(segmentStart));
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
appendLineSegment(segment) {
|
|
378
|
+
if (segment.length === 0)
|
|
379
|
+
return true;
|
|
380
|
+
const nextLineBytes = this.lineBytes + segment.length;
|
|
381
|
+
const hasOptionalDelimiterCr = nextLineBytes === this.maxMessageBytes + 1 && segment.at(-1) === 0x0d;
|
|
382
|
+
if (nextLineBytes > this.maxMessageBytes && !hasOptionalDelimiterCr) {
|
|
383
|
+
this.fail(transportError('message_too_large', 'An inbound JSONL frame exceeds the configured limit.'));
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
this.lineChunks.push(Buffer.from(segment));
|
|
387
|
+
this.lineBytes += segment.length;
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
consumeLine() {
|
|
391
|
+
let line = Buffer.concat(this.lineChunks, this.lineBytes);
|
|
392
|
+
this.lineChunks = [];
|
|
393
|
+
this.lineBytes = 0;
|
|
394
|
+
if (line.at(-1) === 0x0d)
|
|
395
|
+
line = line.subarray(0, -1);
|
|
396
|
+
let decoded;
|
|
397
|
+
try {
|
|
398
|
+
decoded = new TextDecoder('utf-8', { fatal: true }).decode(line);
|
|
399
|
+
}
|
|
400
|
+
catch {
|
|
401
|
+
this.fail(transportError('malformed_message', 'An inbound frame is not UTF-8.'));
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
let value;
|
|
405
|
+
try {
|
|
406
|
+
value = JSON.parse(decoded);
|
|
407
|
+
}
|
|
408
|
+
catch {
|
|
409
|
+
this.fail(transportError('malformed_message', 'An inbound frame is not valid JSON.'));
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
if (!isRecord(value)) {
|
|
413
|
+
this.fail(transportError('malformed_message', 'An inbound JSONL message must be a JSON object.'));
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
if (this.inboundQueue.push(value))
|
|
417
|
+
return;
|
|
418
|
+
this.fail(transportError('capacity_exceeded', 'The buffered inbound message limit was reached.'));
|
|
419
|
+
}
|
|
420
|
+
assertOpen() {
|
|
421
|
+
if (!this.open) {
|
|
422
|
+
throw (this.terminalError ??
|
|
423
|
+
transportError('transport_closed', 'The transport is closed.'));
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
fail(error) {
|
|
427
|
+
if (!this.open)
|
|
428
|
+
return;
|
|
429
|
+
this.terminate(error, error);
|
|
430
|
+
}
|
|
431
|
+
terminate(inboundFailure, operationFailure) {
|
|
432
|
+
if (!this.open)
|
|
433
|
+
return;
|
|
434
|
+
this.open = false;
|
|
435
|
+
this.terminalError = operationFailure;
|
|
436
|
+
this.armTerminalErrorGuards();
|
|
437
|
+
this.detachStreams();
|
|
438
|
+
this.lineChunks = [];
|
|
439
|
+
this.lineBytes = 0;
|
|
440
|
+
for (const state of [...this.pendingWriteWaits]) {
|
|
441
|
+
this.rejectWriteWait(state, operationFailure);
|
|
442
|
+
}
|
|
443
|
+
for (const rejectWrite of [...this.activeWriteRejectors]) {
|
|
444
|
+
rejectWrite(operationFailure);
|
|
445
|
+
}
|
|
446
|
+
this.inboundQueue.close(inboundFailure);
|
|
447
|
+
this.startCleanup();
|
|
448
|
+
}
|
|
449
|
+
detachStreams() {
|
|
450
|
+
this.readable.off('data', this.handleReadableData);
|
|
451
|
+
this.readable.off('end', this.handleReadableEnd);
|
|
452
|
+
this.readable.off('error', this.handleStreamError);
|
|
453
|
+
this.readable.off('close', this.handleStreamClose);
|
|
454
|
+
this.writable.off('error', this.handleWritableError);
|
|
455
|
+
this.writable.off('close', this.handleStreamClose);
|
|
456
|
+
}
|
|
457
|
+
startCleanup() {
|
|
458
|
+
if (this.cleanupPromise)
|
|
459
|
+
return;
|
|
460
|
+
const terminalGuardRelease = new Promise((resolve) => {
|
|
461
|
+
this.resolveTerminalGuardRelease = resolve;
|
|
462
|
+
});
|
|
463
|
+
this.cleanupPromise = Promise.resolve()
|
|
464
|
+
.then(() => this.cleanup?.())
|
|
465
|
+
.then(() => undefined)
|
|
466
|
+
.catch(() => {
|
|
467
|
+
this.cleanupFailure = transportError('cleanup_failed', 'Transport cleanup failed.');
|
|
468
|
+
})
|
|
469
|
+
.then(() => {
|
|
470
|
+
this.cleanupSettled = true;
|
|
471
|
+
this.maybeReleaseTerminalErrorGuards();
|
|
472
|
+
return terminalGuardRelease;
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
armTerminalErrorGuards() {
|
|
476
|
+
this.terminalGuardStreams.add(this.readable);
|
|
477
|
+
this.terminalGuardStreams.add(this.writable);
|
|
478
|
+
for (const stream of this.terminalGuardStreams) {
|
|
479
|
+
stream.on('error', ignoreTerminalStreamError);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
releaseTerminalErrorGuards() {
|
|
483
|
+
for (const stream of this.terminalGuardStreams) {
|
|
484
|
+
stream.off('error', ignoreTerminalStreamError);
|
|
485
|
+
}
|
|
486
|
+
this.terminalGuardStreams.clear();
|
|
487
|
+
}
|
|
488
|
+
maybeReleaseTerminalErrorGuards() {
|
|
489
|
+
if (!this.cleanupSettled ||
|
|
490
|
+
this.activePhysicalWrites > 0 ||
|
|
491
|
+
this.terminalGuardReleaseScheduled) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
this.terminalGuardReleaseScheduled = true;
|
|
495
|
+
scheduleImmediate(() => {
|
|
496
|
+
this.releaseTerminalErrorGuards();
|
|
497
|
+
this.resolveTerminalGuardRelease?.();
|
|
498
|
+
this.resolveTerminalGuardRelease = undefined;
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
function transportError(code, message) {
|
|
503
|
+
return new JsonlTransportError(code, message);
|
|
504
|
+
}
|
|
505
|
+
function asTransportError(error) {
|
|
506
|
+
return error instanceof JsonlTransportError
|
|
507
|
+
? error
|
|
508
|
+
: transportError('invalid_outbound_message', 'The outbound JSONL operation is invalid.');
|
|
509
|
+
}
|
|
510
|
+
function positiveInteger(value) {
|
|
511
|
+
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
512
|
+
throw transportError('invalid_configuration', 'Transport limits and timeouts must be positive safe integers.');
|
|
513
|
+
}
|
|
514
|
+
return value;
|
|
515
|
+
}
|
|
516
|
+
function timerMilliseconds(value) {
|
|
517
|
+
const timeout = positiveInteger(value);
|
|
518
|
+
if (timeout > maximumTimerMilliseconds) {
|
|
519
|
+
throw transportError('invalid_configuration', `Transport timeouts cannot exceed ${String(maximumTimerMilliseconds)} milliseconds.`);
|
|
520
|
+
}
|
|
521
|
+
return timeout;
|
|
522
|
+
}
|
|
523
|
+
function isRecord(value) {
|
|
524
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
525
|
+
}
|
|
526
|
+
function isSerializedRecord(encoded) {
|
|
527
|
+
try {
|
|
528
|
+
const value = JSON.parse(encoded);
|
|
529
|
+
return isRecord(value);
|
|
530
|
+
}
|
|
531
|
+
catch {
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
function ignoreTerminalStreamError() {
|
|
536
|
+
// A short-lived guard contains errors racing with terminal cleanup.
|
|
537
|
+
}
|
|
538
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MA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SAAS,kBAAkB,CAAC,OAAe;IACzC,IAAI,CAAC;QACH,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3C,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,yBAAyB;IAChC,oEAAoE;AACtE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@harapter/transport-jsonl-process",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Bounded strict JSONL transport for Harapter process providers.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agent",
|
|
7
|
+
"jsonl",
|
|
8
|
+
"process",
|
|
9
|
+
"transport"
|
|
10
|
+
],
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/yunfeizhu/harapter.git",
|
|
15
|
+
"directory": "packages/transport-jsonl-process"
|
|
16
|
+
},
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/yunfeizhu/harapter/issues"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/yunfeizhu/harapter#readme",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=24"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"provenance": true,
|
|
40
|
+
"registry": "https://registry.npmjs.org/",
|
|
41
|
+
"tag": "next"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc --project tsconfig.build.json"
|
|
45
|
+
}
|
|
46
|
+
}
|