@sealant/runtime-client-next 0.0.0-next.0 → 0.20.0-next.142
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 +202 -0
- package/dist/channel.d.ts +84 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/channel.js +166 -0
- package/dist/channel.js.map +1 -0
- package/dist/client.d.ts +204 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +516 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/package.json +28 -9
package/LICENSE
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.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { StreamEnd, StreamWindowUpdate } from "@sealant/runtime-protocol";
|
|
2
|
+
/** How a `Channel` writes a frame back to the daemon over the shared connection. The client wires
|
|
3
|
+
* this to its framed-socket writer; the channel never touches the socket directly. */
|
|
4
|
+
export interface ChannelTransport {
|
|
5
|
+
/** Send a `StreamFrame::Data` for this channel. */
|
|
6
|
+
sendData(channelId: string, data: Uint8Array): void;
|
|
7
|
+
/** Send a `StreamFrame::WindowUpdate` (flow-control credits) for this channel. */
|
|
8
|
+
sendWindowUpdate(channelId: string, credits: bigint): void;
|
|
9
|
+
/** Send a `StreamFrame::End` for this channel (half-close from the client side). */
|
|
10
|
+
sendEnd(channelId: string, end?: StreamEnd): void;
|
|
11
|
+
/** Detach this channel from the client's demux table once it is fully closed. */
|
|
12
|
+
release(channelId: string): void;
|
|
13
|
+
}
|
|
14
|
+
/** Why a channel fully closed: a daemon `StreamEnd`, a local `destroy()` teardown, or the
|
|
15
|
+
* connection dying. Note that a half-close via `end()` does NOT resolve `closed` — only the *full*
|
|
16
|
+
* close does, and for a well-behaved peer that arrives as `remote` (the daemon's `StreamEnd`). */
|
|
17
|
+
export type ChannelClose = {
|
|
18
|
+
kind: "remote";
|
|
19
|
+
end: StreamEnd;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "local";
|
|
22
|
+
} | {
|
|
23
|
+
kind: "error";
|
|
24
|
+
error: Error;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* One demultiplexed byte channel. It is an async-iterable of inbound `Uint8Array` chunks (the bytes
|
|
28
|
+
* the daemon wrote on this `channelId`) and exposes `write`/`windowUpdate`/`end` for outbound bytes.
|
|
29
|
+
*
|
|
30
|
+
* Backpressure-friendly: inbound chunks queue until consumed; `closed` resolves with the close cause.
|
|
31
|
+
*/
|
|
32
|
+
export declare class Channel implements AsyncIterable<Uint8Array> {
|
|
33
|
+
#private;
|
|
34
|
+
/** The daemon-assigned channel id this conduit is bound to. */
|
|
35
|
+
readonly channelId: string;
|
|
36
|
+
/** Resolves with the cause when the channel is *fully* closed (remote End, local `destroy()`, or
|
|
37
|
+
* error). A half-close via `end()` does NOT resolve this — inbound keeps flowing until the remote
|
|
38
|
+
* `StreamEnd`, at which point it resolves as `remote`. */
|
|
39
|
+
readonly closed: Promise<ChannelClose>;
|
|
40
|
+
constructor(channelId: string, transport: ChannelTransport);
|
|
41
|
+
/** True once the channel has been *fully* closed (both halves done). */
|
|
42
|
+
get isClosed(): boolean;
|
|
43
|
+
/** True once the outbound half has been closed via `end()` (or a full close). Inbound may still
|
|
44
|
+
* be flowing while this is true. */
|
|
45
|
+
get isOutboundClosed(): boolean;
|
|
46
|
+
/** The close cause, if the channel is closed; otherwise `undefined`. */
|
|
47
|
+
get closeCause(): ChannelClose | undefined;
|
|
48
|
+
/** Route an inbound `StreamFrame::Data` payload into this channel's byte stream. */
|
|
49
|
+
pushData(data: Uint8Array): void;
|
|
50
|
+
/** Route an inbound `StreamFrame::WindowUpdate`: release outbound writers waiting on credits. */
|
|
51
|
+
pushWindowUpdate(update: StreamWindowUpdate): void;
|
|
52
|
+
/** Route an inbound `StreamFrame::End`: drain queued bytes, then close the iterator. */
|
|
53
|
+
pushEnd(end: StreamEnd): void;
|
|
54
|
+
/** The connection died under us; fail the channel. */
|
|
55
|
+
fail(error: Error): void;
|
|
56
|
+
/** Write bytes to the daemon as a `StreamFrame::Data` on this channel. Throws once the outbound
|
|
57
|
+
* half has been closed (via `end()`/`destroy()`) or the channel is fully closed. */
|
|
58
|
+
write(data: Uint8Array): void;
|
|
59
|
+
/** Grant the daemon `credits` more bytes of send window (`StreamFrame::WindowUpdate`). Throws once
|
|
60
|
+
* the outbound half is closed. (Credits flow with outbound frames; once we have half-closed we no
|
|
61
|
+
* longer issue them.) */
|
|
62
|
+
windowUpdate(credits: bigint): void;
|
|
63
|
+
/** Await the next inbound `WindowUpdate`'s credit count (for outbound flow control). */
|
|
64
|
+
awaitWindow(): Promise<bigint>;
|
|
65
|
+
/**
|
|
66
|
+
* Half-close the outbound direction: send a `StreamFrame::End` to the daemon (our EOF) and reject
|
|
67
|
+
* further `write`/`windowUpdate`. Crucially this does NOT tear down inbound — the channel keeps
|
|
68
|
+
* delivering the daemon's output and stays open until the remote `StreamEnd` arrives (which then
|
|
69
|
+
* resolves `closed` as `remote`). This is the SSH semantics `ssh host cmd` relies on: stdin can
|
|
70
|
+
* hit EOF immediately while stdout/stderr and the exit status are still in flight.
|
|
71
|
+
*
|
|
72
|
+
* Idempotent; a no-op if the outbound half is already closed or the channel is fully closed.
|
|
73
|
+
*/
|
|
74
|
+
end(end?: StreamEnd): void;
|
|
75
|
+
/**
|
|
76
|
+
* Full local teardown: half-close the outbound direction if it is still open, then close inbound
|
|
77
|
+
* too and resolve `closed` as `local`. Use this for a real abort/teardown where you do not intend
|
|
78
|
+
* to keep reading the daemon's remaining output. For normal completion prefer `end()` and let the
|
|
79
|
+
* remote `StreamEnd` close the channel.
|
|
80
|
+
*/
|
|
81
|
+
destroy(end?: StreamEnd): void;
|
|
82
|
+
[Symbol.asyncIterator](): AsyncIterator<Uint8Array>;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/E;sFACsF;AACtF,MAAM,WAAW,gBAAgB;IAC/B,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IACpD,kFAAkF;IAClF,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3D,oFAAoF;IACpF,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAClD,iFAAiF;IACjF,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED;;kGAEkG;AAClG,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,SAAS,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEpC;;;;;GAKG;AACH,qBAAa,OAAQ,YAAW,aAAa,CAAC,UAAU,CAAC;;IACvD,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAc3B;;8DAE0D;IAC1D,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;gBAE3B,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB;IAQ1D,wEAAwE;IACxE,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED;wCACoC;IACpC,IAAI,gBAAgB,IAAI,OAAO,CAE9B;IAED,wEAAwE;IACxE,IAAI,UAAU,IAAI,YAAY,GAAG,SAAS,CAEzC;IAID,oFAAoF;IACpF,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAUhC,iGAAiG;IACjG,gBAAgB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI;IAKlD,wFAAwF;IACxF,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI;IAI7B,sDAAsD;IACtD,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAMxB;wFACoF;IACpF,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAK7B;;6BAEyB;IACzB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKnC,wFAAwF;IACxF,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAI9B;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,CAAC,EAAE,SAAS,GAAG,IAAI;IAM1B;;;;;OAKG;IACH,OAAO,CAAC,GAAG,CAAC,EAAE,SAAS,GAAG,IAAI;IAW9B,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,UAAU,CAAC;CA+BpD"}
|
package/dist/channel.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// @sealant/runtime-client — channel multiplexing.
|
|
2
|
+
//
|
|
3
|
+
// A `Channel` is one logical byte conduit inside the single length-prefixed control connection
|
|
4
|
+
// (ADR-0012). The daemon addresses frames by `channelId`; the client demuxes inbound
|
|
5
|
+
// `ServerMessage::Stream` frames into the matching `Channel` and the `Channel` muxes outbound bytes
|
|
6
|
+
// back out as `ClientMessage::Stream` frames. This is the substrate the gateway builds SSH channels
|
|
7
|
+
// (session attach, direct-tcpip forwards, SFTP subsystem) on top of.
|
|
8
|
+
/**
|
|
9
|
+
* One demultiplexed byte channel. It is an async-iterable of inbound `Uint8Array` chunks (the bytes
|
|
10
|
+
* the daemon wrote on this `channelId`) and exposes `write`/`windowUpdate`/`end` for outbound bytes.
|
|
11
|
+
*
|
|
12
|
+
* Backpressure-friendly: inbound chunks queue until consumed; `closed` resolves with the close cause.
|
|
13
|
+
*/
|
|
14
|
+
export class Channel {
|
|
15
|
+
/** The daemon-assigned channel id this conduit is bound to. */
|
|
16
|
+
channelId;
|
|
17
|
+
#transport;
|
|
18
|
+
#inbound = [];
|
|
19
|
+
#waiters = [];
|
|
20
|
+
#windowWaiters = [];
|
|
21
|
+
/** Outbound half-closed: we have sent our `StreamEnd`; `write`/`windowUpdate` are now rejected.
|
|
22
|
+
* Inbound delivery is unaffected — this is the SSH-style half-close. */
|
|
23
|
+
#outboundClosed = false;
|
|
24
|
+
/** Fully closed: both halves are done. Inbound iterator completes and `closed` resolves. */
|
|
25
|
+
#closed = false;
|
|
26
|
+
#close;
|
|
27
|
+
#resolveClosed;
|
|
28
|
+
/** Resolves with the cause when the channel is *fully* closed (remote End, local `destroy()`, or
|
|
29
|
+
* error). A half-close via `end()` does NOT resolve this — inbound keeps flowing until the remote
|
|
30
|
+
* `StreamEnd`, at which point it resolves as `remote`. */
|
|
31
|
+
closed;
|
|
32
|
+
constructor(channelId, transport) {
|
|
33
|
+
this.channelId = channelId;
|
|
34
|
+
this.#transport = transport;
|
|
35
|
+
this.closed = new Promise((resolve) => {
|
|
36
|
+
this.#resolveClosed = resolve;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** True once the channel has been *fully* closed (both halves done). */
|
|
40
|
+
get isClosed() {
|
|
41
|
+
return this.#closed;
|
|
42
|
+
}
|
|
43
|
+
/** True once the outbound half has been closed via `end()` (or a full close). Inbound may still
|
|
44
|
+
* be flowing while this is true. */
|
|
45
|
+
get isOutboundClosed() {
|
|
46
|
+
return this.#outboundClosed;
|
|
47
|
+
}
|
|
48
|
+
/** The close cause, if the channel is closed; otherwise `undefined`. */
|
|
49
|
+
get closeCause() {
|
|
50
|
+
return this.#close;
|
|
51
|
+
}
|
|
52
|
+
// --- inbound (demux target; called by the client) -------------------------------------------
|
|
53
|
+
/** Route an inbound `StreamFrame::Data` payload into this channel's byte stream. */
|
|
54
|
+
pushData(data) {
|
|
55
|
+
if (this.#closed)
|
|
56
|
+
return;
|
|
57
|
+
const waiter = this.#waiters.shift();
|
|
58
|
+
if (waiter) {
|
|
59
|
+
waiter({ value: data, done: false });
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.#inbound.push(data);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Route an inbound `StreamFrame::WindowUpdate`: release outbound writers waiting on credits. */
|
|
66
|
+
pushWindowUpdate(update) {
|
|
67
|
+
if (this.#closed)
|
|
68
|
+
return;
|
|
69
|
+
for (const w of this.#windowWaiters.splice(0))
|
|
70
|
+
w(update.credits);
|
|
71
|
+
}
|
|
72
|
+
/** Route an inbound `StreamFrame::End`: drain queued bytes, then close the iterator. */
|
|
73
|
+
pushEnd(end) {
|
|
74
|
+
this.#finish({ kind: "remote", end });
|
|
75
|
+
}
|
|
76
|
+
/** The connection died under us; fail the channel. */
|
|
77
|
+
fail(error) {
|
|
78
|
+
this.#finish({ kind: "error", error });
|
|
79
|
+
}
|
|
80
|
+
// --- outbound (mux source; called by the consumer) ------------------------------------------
|
|
81
|
+
/** Write bytes to the daemon as a `StreamFrame::Data` on this channel. Throws once the outbound
|
|
82
|
+
* half has been closed (via `end()`/`destroy()`) or the channel is fully closed. */
|
|
83
|
+
write(data) {
|
|
84
|
+
if (this.#outboundClosed)
|
|
85
|
+
throw new Error(`channel ${this.channelId} outbound is closed`);
|
|
86
|
+
this.#transport.sendData(this.channelId, data);
|
|
87
|
+
}
|
|
88
|
+
/** Grant the daemon `credits` more bytes of send window (`StreamFrame::WindowUpdate`). Throws once
|
|
89
|
+
* the outbound half is closed. (Credits flow with outbound frames; once we have half-closed we no
|
|
90
|
+
* longer issue them.) */
|
|
91
|
+
windowUpdate(credits) {
|
|
92
|
+
if (this.#outboundClosed)
|
|
93
|
+
throw new Error(`channel ${this.channelId} outbound is closed`);
|
|
94
|
+
this.#transport.sendWindowUpdate(this.channelId, credits);
|
|
95
|
+
}
|
|
96
|
+
/** Await the next inbound `WindowUpdate`'s credit count (for outbound flow control). */
|
|
97
|
+
awaitWindow() {
|
|
98
|
+
return new Promise((resolve) => this.#windowWaiters.push(resolve));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Half-close the outbound direction: send a `StreamFrame::End` to the daemon (our EOF) and reject
|
|
102
|
+
* further `write`/`windowUpdate`. Crucially this does NOT tear down inbound — the channel keeps
|
|
103
|
+
* delivering the daemon's output and stays open until the remote `StreamEnd` arrives (which then
|
|
104
|
+
* resolves `closed` as `remote`). This is the SSH semantics `ssh host cmd` relies on: stdin can
|
|
105
|
+
* hit EOF immediately while stdout/stderr and the exit status are still in flight.
|
|
106
|
+
*
|
|
107
|
+
* Idempotent; a no-op if the outbound half is already closed or the channel is fully closed.
|
|
108
|
+
*/
|
|
109
|
+
end(end) {
|
|
110
|
+
if (this.#outboundClosed || this.#closed)
|
|
111
|
+
return;
|
|
112
|
+
this.#outboundClosed = true;
|
|
113
|
+
this.#transport.sendEnd(this.channelId, end);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Full local teardown: half-close the outbound direction if it is still open, then close inbound
|
|
117
|
+
* too and resolve `closed` as `local`. Use this for a real abort/teardown where you do not intend
|
|
118
|
+
* to keep reading the daemon's remaining output. For normal completion prefer `end()` and let the
|
|
119
|
+
* remote `StreamEnd` close the channel.
|
|
120
|
+
*/
|
|
121
|
+
destroy(end) {
|
|
122
|
+
if (this.#closed)
|
|
123
|
+
return;
|
|
124
|
+
if (!this.#outboundClosed) {
|
|
125
|
+
this.#outboundClosed = true;
|
|
126
|
+
this.#transport.sendEnd(this.channelId, end);
|
|
127
|
+
}
|
|
128
|
+
this.#finish({ kind: "local" });
|
|
129
|
+
}
|
|
130
|
+
// --- async iteration --------------------------------------------------------------------------
|
|
131
|
+
[Symbol.asyncIterator]() {
|
|
132
|
+
return {
|
|
133
|
+
next: () => {
|
|
134
|
+
const queued = this.#inbound.shift();
|
|
135
|
+
if (queued !== undefined)
|
|
136
|
+
return Promise.resolve({ value: queued, done: false });
|
|
137
|
+
if (this.#closed)
|
|
138
|
+
return Promise.resolve({ value: undefined, done: true });
|
|
139
|
+
return new Promise((resolve) => this.#waiters.push(resolve));
|
|
140
|
+
},
|
|
141
|
+
// The consumer stopped iterating (e.g. `break`): they will read no more inbound bytes, so this
|
|
142
|
+
// is a real teardown, not a half-close. Destroy fully.
|
|
143
|
+
return: () => {
|
|
144
|
+
this.destroy();
|
|
145
|
+
return Promise.resolve({ value: undefined, done: true });
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/** Internal: mark closed once, drain waiters, resolve `closed`, and detach from the demux table. */
|
|
150
|
+
#finish(cause) {
|
|
151
|
+
if (this.#closed)
|
|
152
|
+
return;
|
|
153
|
+
this.#closed = true;
|
|
154
|
+
// A full close implies the outbound half is closed too (block any late writes).
|
|
155
|
+
this.#outboundClosed = true;
|
|
156
|
+
this.#close = cause;
|
|
157
|
+
for (const waiter of this.#waiters.splice(0)) {
|
|
158
|
+
waiter({ value: undefined, done: true });
|
|
159
|
+
}
|
|
160
|
+
for (const w of this.#windowWaiters.splice(0))
|
|
161
|
+
w(0n);
|
|
162
|
+
this.#transport.release(this.channelId);
|
|
163
|
+
this.#resolveClosed(cause);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":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AuD;YACvD,MAAM,EAAE,GAAwC,EAAE;gBAChD,IAAI,CAAC,OAAO,EAAE,CAAC;gBACf,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3D,CAAC;SACF,CAAC;IACJ,CAAC;IAED,oGAAoG;IACpG,OAAO,CAAC,KAAmB;QACzB,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,gFAAgF;QAChF,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7C,MAAM,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3C,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;YAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACrD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { ChildProcess } from "node:child_process";
|
|
2
|
+
import type { Duplex } from "node:stream";
|
|
3
|
+
import type { MessageInitShape } from "@bufbuild/protobuf";
|
|
4
|
+
import { CommandSchema, ControlErrorCode, AttachMode, SessionMode, type Capabilities, type ControlError, type ControlResponse, type EventEnvelope, type ExecAccepted, type ForwardOpened, type HealthReport, type ProcessAttached, type ProcessList, type RuntimeMetrics, type SessionList, type SessionOpened, type SessionOutput, type SftpOpened, type Signal, type StreamAttached } from "@sealant/runtime-protocol";
|
|
5
|
+
import { Channel } from "./channel.js";
|
|
6
|
+
export { Channel } from "./channel.js";
|
|
7
|
+
export type { ChannelTransport, ChannelClose } from "./channel.js";
|
|
8
|
+
/** Error raised when the daemon returns a typed control error. */
|
|
9
|
+
export declare class SealantError extends Error {
|
|
10
|
+
/** Stable error code (e.g. `ControlErrorCode.PROCESS_START_FAILED`). */
|
|
11
|
+
readonly code: ControlErrorCode;
|
|
12
|
+
/** Optional machine-readable detail JSON. */
|
|
13
|
+
readonly detailJson?: string;
|
|
14
|
+
constructor(error: ControlError);
|
|
15
|
+
}
|
|
16
|
+
/** The init shape of the `Command` oneof (what callers pass to {@link SealantClient.request}). */
|
|
17
|
+
type CommandInit = MessageInitShape<typeof CommandSchema>["command"];
|
|
18
|
+
/** Options for {@link SealantClient.openSession} (a subset of the wire `OpenSessionArgs`). */
|
|
19
|
+
export interface OpenSessionOptions {
|
|
20
|
+
/** Shell/command to run; defaults to the daemon's configured default shell. */
|
|
21
|
+
shell?: string;
|
|
22
|
+
/** Arguments to the shell/command. */
|
|
23
|
+
args?: string[];
|
|
24
|
+
/** Working directory (defaults to the workspace root). */
|
|
25
|
+
cwd?: string;
|
|
26
|
+
/** Environment overlay entries. */
|
|
27
|
+
env?: Array<{
|
|
28
|
+
key: string;
|
|
29
|
+
value: string;
|
|
30
|
+
}>;
|
|
31
|
+
/** Initial terminal columns. */
|
|
32
|
+
cols: number;
|
|
33
|
+
/** Initial terminal rows. */
|
|
34
|
+
rows: number;
|
|
35
|
+
/** `TERM` to advertise (defaults daemon-side). */
|
|
36
|
+
term?: string;
|
|
37
|
+
/** Execution to associate the session with. */
|
|
38
|
+
executionId?: string;
|
|
39
|
+
/**
|
|
40
|
+
* How the leader is wired. `PTY` (default) allocates a pseudoterminal — interactive shells and
|
|
41
|
+
* TUIs. `PIPE` gives the leader plain stdio pipes and no tty — the shape for processes that
|
|
42
|
+
* speak a byte protocol over stdin/stdout (JSON-RPC / NDJSON servers): stdout is the journaled,
|
|
43
|
+
* attachable output, stderr is recorded as telemetry only, `writeSessionInput` feeds stdin, and
|
|
44
|
+
* `resizePty` is rejected. `cols`/`rows` are ignored in pipe mode.
|
|
45
|
+
*/
|
|
46
|
+
mode?: SessionMode;
|
|
47
|
+
}
|
|
48
|
+
/** Options for {@link SealantClient.attachSession}. */
|
|
49
|
+
export interface AttachSessionOptions {
|
|
50
|
+
/** Consumption mode (interactive by default). */
|
|
51
|
+
mode?: AttachMode;
|
|
52
|
+
/**
|
|
53
|
+
* Replay the durable output journal from this sequence (0 = full retained scrollback) before
|
|
54
|
+
* live frames; data-frame `seq` values are journal sequences. Omit for a live tail only.
|
|
55
|
+
*/
|
|
56
|
+
fromSequence?: number | bigint;
|
|
57
|
+
}
|
|
58
|
+
/** Options for {@link SealantClient.exec} (a subset of the wire `ExecArgs`). */
|
|
59
|
+
export interface ExecOptions {
|
|
60
|
+
executable: string;
|
|
61
|
+
args?: string[];
|
|
62
|
+
executionId?: string;
|
|
63
|
+
sessionId?: string;
|
|
64
|
+
cwd?: string;
|
|
65
|
+
stdin?: boolean;
|
|
66
|
+
timeoutMillis?: number;
|
|
67
|
+
background?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/** A connected, typed control client for one sealantd instance. */
|
|
70
|
+
export declare class SealantClient {
|
|
71
|
+
#private;
|
|
72
|
+
constructor(stream: Duplex);
|
|
73
|
+
/**
|
|
74
|
+
* Build a client over an arbitrary Node Duplex — e.g. a `docker exec -i` stdio pipe bridged to the
|
|
75
|
+
* daemon's Unix socket. The framing/protocol is transport-agnostic, so this drives the same
|
|
76
|
+
* request/response/event machinery as {@link SealantClient.connect}.
|
|
77
|
+
*/
|
|
78
|
+
static fromStream(stream: Duplex): SealantClient;
|
|
79
|
+
static connect(socketPath: string, options?: {
|
|
80
|
+
retries?: number;
|
|
81
|
+
delayMs?: number;
|
|
82
|
+
}): Promise<SealantClient>;
|
|
83
|
+
static spawn(options: {
|
|
84
|
+
binPath: string;
|
|
85
|
+
socketPath: string;
|
|
86
|
+
workspace?: string;
|
|
87
|
+
workspaceId?: string;
|
|
88
|
+
executionId?: string;
|
|
89
|
+
spoolDir?: string;
|
|
90
|
+
watchFilesystem?: boolean;
|
|
91
|
+
networkProxy?: boolean;
|
|
92
|
+
logLevel?: string;
|
|
93
|
+
}): Promise<{
|
|
94
|
+
client: SealantClient;
|
|
95
|
+
child: ChildProcess;
|
|
96
|
+
}>;
|
|
97
|
+
/** Send a command oneof case and await its single (typed) response. */
|
|
98
|
+
request(command: CommandInit): Promise<ControlResponse>;
|
|
99
|
+
/**
|
|
100
|
+
* Register a {@link Channel} for `channelId` so inbound `ServerMessage::Stream` frames demux into
|
|
101
|
+
* it and writes mux back out. Low-level: the high-level openers ({@link SealantClient.attachSession},
|
|
102
|
+
* {@link SealantClient.openForward}, {@link SealantClient.openSftp}, {@link SealantClient.execAttached})
|
|
103
|
+
* call this with the daemon-allocated id from their result. A multiplexing consumer (the gateway)
|
|
104
|
+
* can also call it directly when it already holds a channel id.
|
|
105
|
+
*/
|
|
106
|
+
openChannel(channelId: string): Channel;
|
|
107
|
+
health(): Promise<HealthReport>;
|
|
108
|
+
getCapabilities(): Promise<Capabilities>;
|
|
109
|
+
getMetrics(): Promise<RuntimeMetrics>;
|
|
110
|
+
listProcesses(executionId?: string): Promise<ProcessList>;
|
|
111
|
+
exec(options: ExecOptions): Promise<ExecAccepted>;
|
|
112
|
+
/**
|
|
113
|
+
* Write input bytes to a process's stdin or an interactive PTY session's input.
|
|
114
|
+
*
|
|
115
|
+
* The daemon's `WriteStdinArgs` carries an exclusive choice of `processId` (non-PTY stdin) OR
|
|
116
|
+
* `sessionId` (PTY input); it routes by whichever is set (see runtime dispatch). The gateway needs
|
|
117
|
+
* the `sessionId` path to deliver SSH PTY keystrokes to a live session.
|
|
118
|
+
*
|
|
119
|
+
* Backward compatible: a bare string `target` is treated as a `processId` (the original signature).
|
|
120
|
+
* Pass `{ sessionId }` to target a session, or `{ processId }` to be explicit.
|
|
121
|
+
*/
|
|
122
|
+
writeStdin(target: string | {
|
|
123
|
+
processId: string;
|
|
124
|
+
} | {
|
|
125
|
+
sessionId: string;
|
|
126
|
+
}, data: Uint8Array): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Convenience for the gateway's interactive path: deliver `data` to a PTY session's input by
|
|
129
|
+
* `sessionId`. Equivalent to `writeStdin({ sessionId }, data)`.
|
|
130
|
+
*/
|
|
131
|
+
writeSessionInput(sessionId: string, data: Uint8Array): Promise<void>;
|
|
132
|
+
signalProcess(processId: string, signal: number): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Point a bindable mount's path at a subdirectory of its root (ADR-0014): `/workspace/repo` at
|
|
135
|
+
* `wt-<id>`, or `/workspace/repos/<name>` at a sibling repository's worktree. An empty subpath
|
|
136
|
+
* unbinds. The daemon records the bind and re-applies it when it restarts in the same container.
|
|
137
|
+
*/
|
|
138
|
+
bindMount(mountPath: string, subpath: string): Promise<void>;
|
|
139
|
+
shutdown(graceMillis?: number): Promise<void>;
|
|
140
|
+
/** Open an interactive PTY session (arbitrary command or the default shell). */
|
|
141
|
+
openSession(options: OpenSessionOptions): Promise<SessionOpened>;
|
|
142
|
+
/**
|
|
143
|
+
* Close a session: hang up a running session's terminal (SIGHUP), or drop an exited session's
|
|
144
|
+
* retained tombstone (and its journal).
|
|
145
|
+
*/
|
|
146
|
+
closeSession(sessionId: string): Promise<void>;
|
|
147
|
+
/** Resize a running session's PTY. */
|
|
148
|
+
resizePty(sessionId: string, cols: number, rows: number): Promise<void>;
|
|
149
|
+
/** List sessions: running first, then retained exited tombstones (state + exit code). */
|
|
150
|
+
listSessions(): Promise<SessionList>;
|
|
151
|
+
/** Deliver a signal (e.g. SIGINT/SIGTERM) to a running session's process group. */
|
|
152
|
+
signalSession(sessionId: string, signal: Signal): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* One-shot batch read of a session's durable output journal from `fromSequence` (clamped to the
|
|
155
|
+
* first retained record). Works for running and exited sessions; the result carries the cursors
|
|
156
|
+
* (`nextSequence`, `firstAvailableSequence`) and lifecycle state.
|
|
157
|
+
*/
|
|
158
|
+
readSessionOutput(sessionId: string, fromSequence: number | bigint, maxBytes?: number | bigint): Promise<SessionOutput>;
|
|
159
|
+
/**
|
|
160
|
+
* Attach to an existing PTY session as a multiplexed channel (interactive by default). Pass
|
|
161
|
+
* `{ fromSequence }` to replay the durable journal (scrollback) before live output — data-frame
|
|
162
|
+
* `seq` values are then journal sequences, resumable across disconnects.
|
|
163
|
+
*/
|
|
164
|
+
attachSession(sessionId: string, modeOrOptions?: AttachMode | AttachSessionOptions): Promise<{
|
|
165
|
+
result: StreamAttached;
|
|
166
|
+
channel: Channel;
|
|
167
|
+
}>;
|
|
168
|
+
/** Detach a previously attached session channel and tear down its local {@link Channel}. */
|
|
169
|
+
detachSession(channelId: string): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Open a direct forward to `host:port` as a multiplexed channel. TCP (the
|
|
172
|
+
* default) is a byte stream; `protocol: "udp"` opens a connected UDP socket
|
|
173
|
+
* where one channel frame is exactly one datagram, both directions.
|
|
174
|
+
*/
|
|
175
|
+
openForward(host: string, port: number, executionId?: string, protocol?: "tcp" | "udp"): Promise<{
|
|
176
|
+
result: ForwardOpened;
|
|
177
|
+
channel: Channel;
|
|
178
|
+
}>;
|
|
179
|
+
/** Close a forward channel and tear down its local {@link Channel}. */
|
|
180
|
+
closeForward(channelId: string): Promise<void>;
|
|
181
|
+
/** Open an SFTP subsystem channel as a multiplexed byte channel. */
|
|
182
|
+
openSftp(options?: {
|
|
183
|
+
executionId?: string;
|
|
184
|
+
cwd?: string;
|
|
185
|
+
}): Promise<{
|
|
186
|
+
result: SftpOpened;
|
|
187
|
+
channel: Channel;
|
|
188
|
+
}>;
|
|
189
|
+
/** Close an SFTP channel and tear down its local {@link Channel}. */
|
|
190
|
+
closeSftp(channelId: string): Promise<void>;
|
|
191
|
+
/**
|
|
192
|
+
* Exec with `attach=true`: the daemon allocates a byte channel bound to the process's stdio and
|
|
193
|
+
* returns {@link ProcessAttached} with its `channelId`. Returns the typed result plus the open
|
|
194
|
+
* {@link Channel} (stdout/stderr ride inbound frames; stdin rides outbound `write`).
|
|
195
|
+
*/
|
|
196
|
+
execAttached(options: ExecOptions): Promise<{
|
|
197
|
+
result: ProcessAttached;
|
|
198
|
+
channel: Channel;
|
|
199
|
+
}>;
|
|
200
|
+
/** Async iterator over telemetry events (typed `EventEnvelope`; `payload` is a discriminated union). */
|
|
201
|
+
events(): AsyncIterableIterator<EventEnvelope>;
|
|
202
|
+
close(): void;
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAOL,aAAa,EAEb,gBAAgB,EAChB,UAAU,EACV,WAAW,EAEX,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,cAAc,EAEnB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,cAAc,EAEpB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAyB,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,cAAc,CA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time-client
|
|
2
|
+
//
|
|
3
|
+
// Ergonomic, typed TypeScript client for sealantd over the Protobuf wire (ADR-0012). Uses IPC (a Unix
|
|
4
|
+
// domain socket) as the language boundary — never in-process FFI (plan §19). Built on the
|
|
5
|
+
// Buf-generated protobuf-es types from @sealant/runtime-protocol, so commands, responses, and events
|
|
6
|
+
// are fully typed (discriminated unions + TS enums).
|
|
7
|
+
var _a;
|
|
8
|
+
import net from "node:net";
|
|
9
|
+
import { spawn } from "node:child_process";
|
|
10
|
+
import { Buffer } from "node:buffer";
|
|
11
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
12
|
+
import { create, encodeClient, encodeFrame, FrameDecoder, SCHEMA_VERSION, ClientMessageSchema, CommandSchema, StreamFrameSchema, ControlErrorCode, AttachMode, SessionMode, } from "@sealant/runtime-protocol";
|
|
13
|
+
import { Channel } from "./channel.js";
|
|
14
|
+
export { Channel } from "./channel.js";
|
|
15
|
+
/** Error raised when the daemon returns a typed control error. */
|
|
16
|
+
export class SealantError extends Error {
|
|
17
|
+
/** Stable error code (e.g. `ControlErrorCode.PROCESS_START_FAILED`). */
|
|
18
|
+
code;
|
|
19
|
+
/** Optional machine-readable detail JSON. */
|
|
20
|
+
detailJson;
|
|
21
|
+
constructor(error) {
|
|
22
|
+
super(error.message || "control error");
|
|
23
|
+
this.name = "SealantError";
|
|
24
|
+
this.code = error.code;
|
|
25
|
+
this.detailJson = error.detailJson;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Throw on an error outcome; otherwise return the `CommandResult`. */
|
|
29
|
+
function okResult(response) {
|
|
30
|
+
// ControlResponse.outcome is a ResponseOutcome message whose `outcome` oneof is ok | error.
|
|
31
|
+
const outcome = response.outcome?.outcome;
|
|
32
|
+
if (outcome?.case === "error") {
|
|
33
|
+
throw new SealantError(outcome.value);
|
|
34
|
+
}
|
|
35
|
+
if (outcome?.case === "ok") {
|
|
36
|
+
return outcome.value;
|
|
37
|
+
}
|
|
38
|
+
throw new Error("response had no outcome");
|
|
39
|
+
}
|
|
40
|
+
/** Assert the `CommandResult` is a specific result case and return its (untyped) value. The caller
|
|
41
|
+
* casts to the exact result type — the public method signatures are the typed contract. */
|
|
42
|
+
function resultValue(result, kase) {
|
|
43
|
+
if (result.result.case !== kase) {
|
|
44
|
+
throw new Error(`expected result ${kase}, got ${String(result.result.case)}`);
|
|
45
|
+
}
|
|
46
|
+
return result.result.value;
|
|
47
|
+
}
|
|
48
|
+
/** A connected, typed control client for one sealantd instance. */
|
|
49
|
+
export class SealantClient {
|
|
50
|
+
#stream;
|
|
51
|
+
#decoder = new FrameDecoder();
|
|
52
|
+
#pending = new Map();
|
|
53
|
+
#counter = 0;
|
|
54
|
+
#closed = false;
|
|
55
|
+
#eventQueue = [];
|
|
56
|
+
#eventWaiters = [];
|
|
57
|
+
/** Demux table: channel_id → open `Channel`. Inbound `ServerMessage::Stream` frames route here. */
|
|
58
|
+
#channels = new Map();
|
|
59
|
+
/**
|
|
60
|
+
* Frames that arrived for a channel the caller has not registered yet. The daemon may write
|
|
61
|
+
* channel frames BEFORE the response that carries the channel id reaches the caller (journal
|
|
62
|
+
* replay on `attachSession({fromSequence})` does this by design; a fast exec-attach can too), so
|
|
63
|
+
* they are buffered here and flushed by {@link SealantClient.openChannel}. Bounded per channel;
|
|
64
|
+
* cleared on connection close.
|
|
65
|
+
*/
|
|
66
|
+
#pendingFrames = new Map();
|
|
67
|
+
#transport;
|
|
68
|
+
constructor(stream) {
|
|
69
|
+
this.#stream = stream;
|
|
70
|
+
// The transport every Channel uses to mux outbound frames back over this one connection.
|
|
71
|
+
this.#transport = {
|
|
72
|
+
sendData: (channelId, data) => this.#sendStream(channelId, { case: "data", value: data }),
|
|
73
|
+
sendWindowUpdate: (channelId, credits) => this.#sendStream(channelId, { case: "windowUpdate", value: { credits } }),
|
|
74
|
+
sendEnd: (channelId, end) => this.#sendStream(channelId, { case: "end", value: end ?? {} }),
|
|
75
|
+
release: (channelId) => this.#channels.delete(channelId),
|
|
76
|
+
};
|
|
77
|
+
this.#attach(stream);
|
|
78
|
+
}
|
|
79
|
+
/** Wire a transport stream's data/close/end/error events into the client. */
|
|
80
|
+
#attach(stream) {
|
|
81
|
+
stream.on("data", (chunk) => this.#onData(chunk));
|
|
82
|
+
stream.on("close", () => this.#onClose());
|
|
83
|
+
// A `docker exec -i` stdio Duplex emits "end" (not always "close"); #onClose is idempotent.
|
|
84
|
+
stream.on("end", () => this.#onClose());
|
|
85
|
+
stream.on("error", () => { });
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Build a client over an arbitrary Node Duplex — e.g. a `docker exec -i` stdio pipe bridged to the
|
|
89
|
+
* daemon's Unix socket. The framing/protocol is transport-agnostic, so this drives the same
|
|
90
|
+
* request/response/event machinery as {@link SealantClient.connect}.
|
|
91
|
+
*/
|
|
92
|
+
static fromStream(stream) {
|
|
93
|
+
return new _a(stream);
|
|
94
|
+
}
|
|
95
|
+
static async connect(socketPath, options = {}) {
|
|
96
|
+
const retries = options.retries ?? 100;
|
|
97
|
+
const delayMs = options.delayMs ?? 20;
|
|
98
|
+
let lastError;
|
|
99
|
+
for (let attempt = 0; attempt < retries; attempt++) {
|
|
100
|
+
try {
|
|
101
|
+
return new _a(await connectOnce(socketPath));
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
lastError = error;
|
|
105
|
+
await delay(delayMs);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
throw lastError instanceof Error ? lastError : new Error("connection failed");
|
|
109
|
+
}
|
|
110
|
+
static async spawn(options) {
|
|
111
|
+
const args = ["--socket", options.socketPath, "--log-level", options.logLevel ?? "off"];
|
|
112
|
+
if (options.workspace)
|
|
113
|
+
args.push("--workspace", options.workspace);
|
|
114
|
+
if (options.workspaceId)
|
|
115
|
+
args.push("--workspace-id", options.workspaceId);
|
|
116
|
+
if (options.executionId)
|
|
117
|
+
args.push("--execution-id", options.executionId);
|
|
118
|
+
if (options.spoolDir)
|
|
119
|
+
args.push("--spool-dir", options.spoolDir);
|
|
120
|
+
if (options.watchFilesystem)
|
|
121
|
+
args.push("--watch-filesystem");
|
|
122
|
+
if (options.networkProxy)
|
|
123
|
+
args.push("--network-proxy");
|
|
124
|
+
const child = spawn(options.binPath, args, { stdio: ["ignore", "ignore", "inherit"] });
|
|
125
|
+
try {
|
|
126
|
+
return { client: await _a.connect(options.socketPath), child };
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
child.kill("SIGKILL");
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** Send a command oneof case and await its single (typed) response. */
|
|
134
|
+
request(command) {
|
|
135
|
+
if (this.#closed) {
|
|
136
|
+
return Promise.reject(new Error("client is closed"));
|
|
137
|
+
}
|
|
138
|
+
const requestId = `req_client_${++this.#counter}`;
|
|
139
|
+
const message = create(ClientMessageSchema, {
|
|
140
|
+
message: {
|
|
141
|
+
case: "request",
|
|
142
|
+
value: { schemaVersion: SCHEMA_VERSION, requestId, command: { command } },
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
const body = encodeClient(message);
|
|
146
|
+
return new Promise((resolve, reject) => {
|
|
147
|
+
this.#pending.set(requestId, { resolve, reject });
|
|
148
|
+
this.#stream.write(encodeFrame(body), (error) => {
|
|
149
|
+
if (error) {
|
|
150
|
+
this.#pending.delete(requestId);
|
|
151
|
+
reject(error);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/** Mux one outbound `ClientMessage::Stream` frame onto the shared connection. */
|
|
157
|
+
#sendStream(channelId, payload) {
|
|
158
|
+
if (this.#closed)
|
|
159
|
+
throw new Error("client is closed");
|
|
160
|
+
const message = create(ClientMessageSchema, {
|
|
161
|
+
message: { case: "stream", value: { channelId, seq: 0n, payload } },
|
|
162
|
+
});
|
|
163
|
+
this.#stream.write(encodeFrame(encodeClient(message)));
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Register a {@link Channel} for `channelId` so inbound `ServerMessage::Stream` frames demux into
|
|
167
|
+
* it and writes mux back out. Low-level: the high-level openers ({@link SealantClient.attachSession},
|
|
168
|
+
* {@link SealantClient.openForward}, {@link SealantClient.openSftp}, {@link SealantClient.execAttached})
|
|
169
|
+
* call this with the daemon-allocated id from their result. A multiplexing consumer (the gateway)
|
|
170
|
+
* can also call it directly when it already holds a channel id.
|
|
171
|
+
*/
|
|
172
|
+
openChannel(channelId) {
|
|
173
|
+
const existing = this.#channels.get(channelId);
|
|
174
|
+
if (existing)
|
|
175
|
+
return existing;
|
|
176
|
+
const channel = new Channel(channelId, this.#transport);
|
|
177
|
+
this.#channels.set(channelId, channel);
|
|
178
|
+
// Flush any frames that raced ahead of the response carrying this channel id.
|
|
179
|
+
const pending = this.#pendingFrames.get(channelId);
|
|
180
|
+
if (pending) {
|
|
181
|
+
this.#pendingFrames.delete(channelId);
|
|
182
|
+
for (const frame of pending)
|
|
183
|
+
this.#deliverFrame(channel, frame);
|
|
184
|
+
}
|
|
185
|
+
return channel;
|
|
186
|
+
}
|
|
187
|
+
async health() {
|
|
188
|
+
return resultValue(okResult(await this.request({ case: "runtimeHealth", value: {} })), "health");
|
|
189
|
+
}
|
|
190
|
+
async getCapabilities() {
|
|
191
|
+
return resultValue(okResult(await this.request({ case: "runtimeGetCapabilities", value: {} })), "capabilities");
|
|
192
|
+
}
|
|
193
|
+
async getMetrics() {
|
|
194
|
+
return resultValue(okResult(await this.request({ case: "getRuntimeMetrics", value: {} })), "metrics");
|
|
195
|
+
}
|
|
196
|
+
async listProcesses(executionId) {
|
|
197
|
+
const value = executionId === undefined ? {} : { executionId };
|
|
198
|
+
return resultValue(okResult(await this.request({ case: "listProcesses", value })), "processList");
|
|
199
|
+
}
|
|
200
|
+
async exec(options) {
|
|
201
|
+
const result = okResult(await this.request({
|
|
202
|
+
case: "exec",
|
|
203
|
+
value: {
|
|
204
|
+
executable: options.executable,
|
|
205
|
+
args: options.args ?? [],
|
|
206
|
+
executionId: options.executionId,
|
|
207
|
+
sessionId: options.sessionId,
|
|
208
|
+
cwd: options.cwd,
|
|
209
|
+
stdin: options.stdin ?? false,
|
|
210
|
+
// 64-bit wire fields are bigint in protobuf-es.
|
|
211
|
+
timeoutMillis: options.timeoutMillis === undefined ? undefined : BigInt(options.timeoutMillis),
|
|
212
|
+
background: options.background ?? false,
|
|
213
|
+
},
|
|
214
|
+
}));
|
|
215
|
+
return resultValue(result, "execAccepted");
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Write input bytes to a process's stdin or an interactive PTY session's input.
|
|
219
|
+
*
|
|
220
|
+
* The daemon's `WriteStdinArgs` carries an exclusive choice of `processId` (non-PTY stdin) OR
|
|
221
|
+
* `sessionId` (PTY input); it routes by whichever is set (see runtime dispatch). The gateway needs
|
|
222
|
+
* the `sessionId` path to deliver SSH PTY keystrokes to a live session.
|
|
223
|
+
*
|
|
224
|
+
* Backward compatible: a bare string `target` is treated as a `processId` (the original signature).
|
|
225
|
+
* Pass `{ sessionId }` to target a session, or `{ processId }` to be explicit.
|
|
226
|
+
*/
|
|
227
|
+
async writeStdin(target, data) {
|
|
228
|
+
const value = typeof target === "string"
|
|
229
|
+
? { processId: target, data }
|
|
230
|
+
: "sessionId" in target
|
|
231
|
+
? { sessionId: target.sessionId, data }
|
|
232
|
+
: { processId: target.processId, data };
|
|
233
|
+
okResult(await this.request({ case: "writeStdin", value }));
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Convenience for the gateway's interactive path: deliver `data` to a PTY session's input by
|
|
237
|
+
* `sessionId`. Equivalent to `writeStdin({ sessionId }, data)`.
|
|
238
|
+
*/
|
|
239
|
+
async writeSessionInput(sessionId, data) {
|
|
240
|
+
okResult(await this.request({ case: "writeStdin", value: { sessionId, data } }));
|
|
241
|
+
}
|
|
242
|
+
async signalProcess(processId, signal) {
|
|
243
|
+
okResult(await this.request({ case: "signalProcess", value: { processId, signal } }));
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Point a bindable mount's path at a subdirectory of its root (ADR-0014): `/workspace/repo` at
|
|
247
|
+
* `wt-<id>`, or `/workspace/repos/<name>` at a sibling repository's worktree. An empty subpath
|
|
248
|
+
* unbinds. The daemon records the bind and re-applies it when it restarts in the same container.
|
|
249
|
+
*/
|
|
250
|
+
async bindMount(mountPath, subpath) {
|
|
251
|
+
okResult(await this.request({ case: "bindMount", value: { mountPath, subpath } }));
|
|
252
|
+
}
|
|
253
|
+
async shutdown(graceMillis) {
|
|
254
|
+
const value = graceMillis === undefined ? {} : { graceMillis: BigInt(graceMillis) };
|
|
255
|
+
okResult(await this.request({ case: "runtimeGracefulShutdown", value }));
|
|
256
|
+
}
|
|
257
|
+
// ===================== channel multiplexing =====================
|
|
258
|
+
//
|
|
259
|
+
// Each opener sends its command, reads the daemon-allocated channel_id out of the typed result, and
|
|
260
|
+
// returns an open {@link Channel} already wired into the demux table — an async-iterable of that
|
|
261
|
+
// channel's inbound bytes plus `write`/`windowUpdate`/`end` for outbound bytes.
|
|
262
|
+
// ===================== interactive sessions =====================
|
|
263
|
+
/** Open an interactive PTY session (arbitrary command or the default shell). */
|
|
264
|
+
async openSession(options) {
|
|
265
|
+
return resultValue(okResult(await this.request({
|
|
266
|
+
case: "openSession",
|
|
267
|
+
value: {
|
|
268
|
+
shell: options.shell,
|
|
269
|
+
args: options.args ?? [],
|
|
270
|
+
cwd: options.cwd,
|
|
271
|
+
env: options.env ?? [],
|
|
272
|
+
cols: options.cols,
|
|
273
|
+
rows: options.rows,
|
|
274
|
+
term: options.term,
|
|
275
|
+
executionId: options.executionId,
|
|
276
|
+
mode: options.mode ?? SessionMode.PTY,
|
|
277
|
+
},
|
|
278
|
+
})), "sessionOpened");
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Close a session: hang up a running session's terminal (SIGHUP), or drop an exited session's
|
|
282
|
+
* retained tombstone (and its journal).
|
|
283
|
+
*/
|
|
284
|
+
async closeSession(sessionId) {
|
|
285
|
+
okResult(await this.request({ case: "closeSession", value: { sessionId } }));
|
|
286
|
+
}
|
|
287
|
+
/** Resize a running session's PTY. */
|
|
288
|
+
async resizePty(sessionId, cols, rows) {
|
|
289
|
+
okResult(await this.request({ case: "resizePty", value: { sessionId, cols, rows } }));
|
|
290
|
+
}
|
|
291
|
+
/** List sessions: running first, then retained exited tombstones (state + exit code). */
|
|
292
|
+
async listSessions() {
|
|
293
|
+
return resultValue(okResult(await this.request({ case: "listSessions", value: {} })), "sessionList");
|
|
294
|
+
}
|
|
295
|
+
/** Deliver a signal (e.g. SIGINT/SIGTERM) to a running session's process group. */
|
|
296
|
+
async signalSession(sessionId, signal) {
|
|
297
|
+
okResult(await this.request({ case: "signalSession", value: { sessionId, signal } }));
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* One-shot batch read of a session's durable output journal from `fromSequence` (clamped to the
|
|
301
|
+
* first retained record). Works for running and exited sessions; the result carries the cursors
|
|
302
|
+
* (`nextSequence`, `firstAvailableSequence`) and lifecycle state.
|
|
303
|
+
*/
|
|
304
|
+
async readSessionOutput(sessionId, fromSequence, maxBytes) {
|
|
305
|
+
return resultValue(okResult(await this.request({
|
|
306
|
+
case: "readSessionOutput",
|
|
307
|
+
value: {
|
|
308
|
+
sessionId,
|
|
309
|
+
fromSequence: BigInt(fromSequence),
|
|
310
|
+
maxBytes: maxBytes === undefined ? undefined : BigInt(maxBytes),
|
|
311
|
+
},
|
|
312
|
+
})), "sessionOutput");
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Attach to an existing PTY session as a multiplexed channel (interactive by default). Pass
|
|
316
|
+
* `{ fromSequence }` to replay the durable journal (scrollback) before live output — data-frame
|
|
317
|
+
* `seq` values are then journal sequences, resumable across disconnects.
|
|
318
|
+
*/
|
|
319
|
+
async attachSession(sessionId, modeOrOptions = AttachMode.INTERACTIVE) {
|
|
320
|
+
const options = typeof modeOrOptions === "object" ? modeOrOptions : { mode: modeOrOptions };
|
|
321
|
+
const result = resultValue(okResult(await this.request({
|
|
322
|
+
case: "attachSession",
|
|
323
|
+
value: {
|
|
324
|
+
sessionId,
|
|
325
|
+
mode: options.mode ?? AttachMode.INTERACTIVE,
|
|
326
|
+
fromSequence: options.fromSequence === undefined ? undefined : BigInt(options.fromSequence),
|
|
327
|
+
},
|
|
328
|
+
})), "streamAttached");
|
|
329
|
+
return { result, channel: this.openChannel(result.channelId) };
|
|
330
|
+
}
|
|
331
|
+
/** Detach a previously attached session channel and tear down its local {@link Channel}. */
|
|
332
|
+
async detachSession(channelId) {
|
|
333
|
+
okResult(await this.request({ case: "detachSession", value: { channelId } }));
|
|
334
|
+
// Explicit teardown command: fully close the local channel, don't leave inbound half-open.
|
|
335
|
+
this.#channels.get(channelId)?.destroy();
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Open a direct forward to `host:port` as a multiplexed channel. TCP (the
|
|
339
|
+
* default) is a byte stream; `protocol: "udp"` opens a connected UDP socket
|
|
340
|
+
* where one channel frame is exactly one datagram, both directions.
|
|
341
|
+
*/
|
|
342
|
+
async openForward(host, port, executionId, protocol) {
|
|
343
|
+
const result = resultValue(okResult(await this.request({
|
|
344
|
+
case: "openForward",
|
|
345
|
+
// Omit tcp on the wire — the field's absence is the old default.
|
|
346
|
+
value: { host, port, executionId, protocol: protocol === "udp" ? "udp" : undefined },
|
|
347
|
+
})), "forwardOpened");
|
|
348
|
+
return { result, channel: this.openChannel(result.channelId) };
|
|
349
|
+
}
|
|
350
|
+
/** Close a forward channel and tear down its local {@link Channel}. */
|
|
351
|
+
async closeForward(channelId) {
|
|
352
|
+
okResult(await this.request({ case: "closeForward", value: { channelId } }));
|
|
353
|
+
// Explicit teardown command: fully close the local channel, don't leave inbound half-open.
|
|
354
|
+
this.#channels.get(channelId)?.destroy();
|
|
355
|
+
}
|
|
356
|
+
/** Open an SFTP subsystem channel as a multiplexed byte channel. */
|
|
357
|
+
async openSftp(options = {}) {
|
|
358
|
+
const result = resultValue(okResult(await this.request({
|
|
359
|
+
case: "openSftp",
|
|
360
|
+
value: { executionId: options.executionId, cwd: options.cwd },
|
|
361
|
+
})), "sftpOpened");
|
|
362
|
+
return { result, channel: this.openChannel(result.channelId) };
|
|
363
|
+
}
|
|
364
|
+
/** Close an SFTP channel and tear down its local {@link Channel}. */
|
|
365
|
+
async closeSftp(channelId) {
|
|
366
|
+
okResult(await this.request({ case: "closeSftp", value: { channelId } }));
|
|
367
|
+
// Explicit teardown command: fully close the local channel, don't leave inbound half-open.
|
|
368
|
+
this.#channels.get(channelId)?.destroy();
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Exec with `attach=true`: the daemon allocates a byte channel bound to the process's stdio and
|
|
372
|
+
* returns {@link ProcessAttached} with its `channelId`. Returns the typed result plus the open
|
|
373
|
+
* {@link Channel} (stdout/stderr ride inbound frames; stdin rides outbound `write`).
|
|
374
|
+
*/
|
|
375
|
+
async execAttached(options) {
|
|
376
|
+
const result = resultValue(okResult(await this.request({
|
|
377
|
+
case: "exec",
|
|
378
|
+
value: {
|
|
379
|
+
executable: options.executable,
|
|
380
|
+
args: options.args ?? [],
|
|
381
|
+
executionId: options.executionId,
|
|
382
|
+
sessionId: options.sessionId,
|
|
383
|
+
cwd: options.cwd,
|
|
384
|
+
stdin: options.stdin ?? false,
|
|
385
|
+
timeoutMillis: options.timeoutMillis === undefined ? undefined : BigInt(options.timeoutMillis),
|
|
386
|
+
background: options.background ?? false,
|
|
387
|
+
attach: true,
|
|
388
|
+
},
|
|
389
|
+
})), "processAttached");
|
|
390
|
+
return { result, channel: this.openChannel(result.channelId) };
|
|
391
|
+
}
|
|
392
|
+
/** Async iterator over telemetry events (typed `EventEnvelope`; `payload` is a discriminated union). */
|
|
393
|
+
events() {
|
|
394
|
+
const self = this;
|
|
395
|
+
return {
|
|
396
|
+
[Symbol.asyncIterator]() {
|
|
397
|
+
return this;
|
|
398
|
+
},
|
|
399
|
+
next() {
|
|
400
|
+
const queued = self.#eventQueue.shift();
|
|
401
|
+
if (queued !== undefined) {
|
|
402
|
+
return Promise.resolve({ value: queued, done: false });
|
|
403
|
+
}
|
|
404
|
+
if (self.#closed) {
|
|
405
|
+
return Promise.resolve({ value: undefined, done: true });
|
|
406
|
+
}
|
|
407
|
+
return new Promise((resolve) => self.#eventWaiters.push(resolve));
|
|
408
|
+
},
|
|
409
|
+
return() {
|
|
410
|
+
return Promise.resolve({ value: undefined, done: true });
|
|
411
|
+
},
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
close() {
|
|
415
|
+
this.#stream.end();
|
|
416
|
+
}
|
|
417
|
+
#onData(chunk) {
|
|
418
|
+
let messages;
|
|
419
|
+
try {
|
|
420
|
+
messages = this.#decoder.push(chunk);
|
|
421
|
+
}
|
|
422
|
+
catch (error) {
|
|
423
|
+
this.#stream.destroy(error instanceof Error ? error : new Error(String(error)));
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
for (const message of messages) {
|
|
427
|
+
if (message.message.case === "response") {
|
|
428
|
+
const response = message.message.value;
|
|
429
|
+
const pending = this.#pending.get(response.requestId);
|
|
430
|
+
if (pending) {
|
|
431
|
+
this.#pending.delete(response.requestId);
|
|
432
|
+
pending.resolve(response);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
else if (message.message.case === "event") {
|
|
436
|
+
this.#emitEvent(message.message.value);
|
|
437
|
+
}
|
|
438
|
+
else if (message.message.case === "stream") {
|
|
439
|
+
this.#routeStream(message.message.value);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
/** Frames buffered per not-yet-registered channel (a full session journal replay fits). */
|
|
444
|
+
static #MAX_PENDING_FRAMES = 65536;
|
|
445
|
+
/** Demultiplex one inbound `ServerMessage::Stream` frame into its `Channel` by `channelId`. */
|
|
446
|
+
#routeStream(frame) {
|
|
447
|
+
const channel = this.#channels.get(frame.channelId);
|
|
448
|
+
if (!channel) {
|
|
449
|
+
// The channel id is not registered (yet): buffer bounded, flushed by openChannel. Frames
|
|
450
|
+
// beyond the bound (or for channels that are never opened) are dropped on close.
|
|
451
|
+
const pending = this.#pendingFrames.get(frame.channelId) ?? [];
|
|
452
|
+
if (pending.length < _a.#MAX_PENDING_FRAMES) {
|
|
453
|
+
pending.push(frame);
|
|
454
|
+
this.#pendingFrames.set(frame.channelId, pending);
|
|
455
|
+
}
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
this.#deliverFrame(channel, frame);
|
|
459
|
+
}
|
|
460
|
+
#deliverFrame(channel, frame) {
|
|
461
|
+
switch (frame.payload.case) {
|
|
462
|
+
case "data":
|
|
463
|
+
channel.pushData(frame.payload.value);
|
|
464
|
+
break;
|
|
465
|
+
case "windowUpdate":
|
|
466
|
+
channel.pushWindowUpdate(frame.payload.value);
|
|
467
|
+
break;
|
|
468
|
+
case "end":
|
|
469
|
+
channel.pushEnd(frame.payload.value);
|
|
470
|
+
break;
|
|
471
|
+
default:
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
#emitEvent(event) {
|
|
476
|
+
const waiter = this.#eventWaiters.shift();
|
|
477
|
+
if (waiter) {
|
|
478
|
+
waiter({ value: event, done: false });
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
this.#eventQueue.push(event);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
#onClose() {
|
|
485
|
+
this.#closed = true;
|
|
486
|
+
for (const waiter of this.#eventWaiters.splice(0)) {
|
|
487
|
+
waiter({ value: undefined, done: true });
|
|
488
|
+
}
|
|
489
|
+
for (const pending of this.#pending.values()) {
|
|
490
|
+
pending.reject(new Error("connection closed"));
|
|
491
|
+
}
|
|
492
|
+
this.#pending.clear();
|
|
493
|
+
// Fail every open channel so consumers iterating their bytes/`closed` promise unblock.
|
|
494
|
+
for (const channel of [...this.#channels.values()]) {
|
|
495
|
+
channel.fail(new Error("connection closed"));
|
|
496
|
+
}
|
|
497
|
+
this.#channels.clear();
|
|
498
|
+
this.#pendingFrames.clear();
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
_a = SealantClient;
|
|
502
|
+
function connectOnce(socketPath) {
|
|
503
|
+
return new Promise((resolve, reject) => {
|
|
504
|
+
const socket = net.createConnection(socketPath);
|
|
505
|
+
const onError = (error) => {
|
|
506
|
+
socket.destroy();
|
|
507
|
+
reject(error);
|
|
508
|
+
};
|
|
509
|
+
socket.once("error", onError);
|
|
510
|
+
socket.once("connect", () => {
|
|
511
|
+
socket.removeListener("error", onError);
|
|
512
|
+
resolve(socket);
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,EAAE;AACF,sGAAsG;AACtG,0FAA0F;AAC1F,qGAAqG;AACrG,qDAAqD;;AAErD,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAI3D,OAAO,EACL,MAAM,EACN,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,WAAW,GAoBZ,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAyB,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,kEAAkE;AAClE,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,wEAAwE;IAC/D,IAAI,CAAmB;IAChC,6CAA6C;IACpC,UAAU,CAAU;I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|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealant/runtime-client-next",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
|
-
"keywords": [],
|
|
10
|
-
"author": "",
|
|
3
|
+
"version": "0.20.0-next.142",
|
|
4
|
+
"description": "Ergonomic, typed TypeScript client for the sealantd runtime daemon.",
|
|
11
5
|
"license": "Apache-2.0",
|
|
12
|
-
"
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/sealant-sh/sealantd.git",
|
|
9
|
+
"directory": "packages/runtime-client"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=20"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@bufbuild/protobuf": "^2.12.0",
|
|
26
|
+
"@sealant/runtime-protocol": "npm:@sealant/runtime-protocol-next@0.20.0-next.142"
|
|
27
|
+
},
|
|
28
|
+
"gitHead": "07ada506afa745c9165d31f4eff705d13d0e1a43",
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
}
|
|
13
32
|
}
|