@miao-ai/protocol 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/LICENSE-APACHE +201 -0
- package/dist/LICENSE-MIT +21 -0
- package/dist/codec.d.ts +30 -0
- package/dist/codec.d.ts.map +1 -0
- package/dist/codec.js +296 -0
- package/dist/codec.js.map +1 -0
- package/dist/generated/fixture.d.ts +336 -0
- package/dist/generated/fixture.d.ts.map +1 -0
- package/dist/generated/fixture.js +351 -0
- package/dist/generated/fixture.js.map +1 -0
- package/dist/generated/protocol.d.ts +110 -0
- package/dist/generated/protocol.d.ts.map +1 -0
- package/dist/generated/protocol.js +50 -0
- package/dist/generated/protocol.js.map +1 -0
- package/dist/generated/schema.d.ts +357 -0
- package/dist/generated/schema.d.ts.map +1 -0
- package/dist/generated/schema.js +511 -0
- package/dist/generated/schema.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/fixtures/runtime-v1.fixture.json +349 -0
- package/package.json +49 -0
- package/schemas/runtime-v1.schema.json +508 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# `@miao-ai/protocol`
|
|
2
|
+
|
|
3
|
+
Generated TypeScript contracts, JSON Schema, fixtures, and bounded frame codecs
|
|
4
|
+
for `miao.runtime/v1`.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @miao-ai/protocol@0.1.0
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Use this package when implementing a custom transport or validating protocol
|
|
11
|
+
fixtures. Most application developers should install `@miao-ai/node`, which
|
|
12
|
+
re-exports the public protocol and client API.
|
|
13
|
+
|
|
14
|
+
The generated declarations and schemas come from the Rust protocol source of
|
|
15
|
+
truth. Do not copy or hand-edit them downstream.
|
|
16
|
+
|
|
17
|
+
Runtime and SDK versions are independent. P11 pairs SDK `0.1.0` with
|
|
18
|
+
Runtime `0.22.0`; compatibility is based on protocol, schema, operations, and
|
|
19
|
+
features rather than equal SemVer values.
|
|
20
|
+
|
|
21
|
+
Licensed under MIT OR Apache-2.0.
|
|
@@ -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 Miao 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/dist/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Miao Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/codec.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type CancellationFrame, type HeartbeatFrame, type HostCallRequest, type HostCallResponse, type RuntimeDescriptor, type RuntimeEventFrame, type RuntimeFrame, type RuntimeOperation, type RuntimeRequest, type RuntimeResponse } from "./generated/protocol.js";
|
|
2
|
+
export declare class ProtocolValidationError extends Error {
|
|
3
|
+
readonly code: "invalid_json" | "invalid_frame" | "unsupported_protocol" | "line_too_long";
|
|
4
|
+
constructor(code: ProtocolValidationError["code"], message: string, options?: ErrorOptions);
|
|
5
|
+
}
|
|
6
|
+
export declare function isRuntimeOperation(value: unknown): value is RuntimeOperation;
|
|
7
|
+
export declare function parseRuntimeFrame(value: unknown): RuntimeFrame;
|
|
8
|
+
export declare function decodeRuntimeFrame(input: string): RuntimeFrame;
|
|
9
|
+
export declare function encodeRuntimeFrame(frame: RuntimeFrame): string;
|
|
10
|
+
export declare function encodeRuntimeFrameLine(frame: RuntimeFrame): string;
|
|
11
|
+
export declare function isRuntimeFrame(value: unknown): value is RuntimeFrame;
|
|
12
|
+
export declare function isRuntimeRequest(value: unknown): value is RuntimeRequest;
|
|
13
|
+
export declare function isRuntimeResponse(value: unknown): value is RuntimeResponse;
|
|
14
|
+
export declare function isRuntimeEventFrame(value: unknown): value is RuntimeEventFrame;
|
|
15
|
+
export declare function isHostCallRequest(value: unknown): value is HostCallRequest;
|
|
16
|
+
export declare function isHostCallResponse(value: unknown): value is HostCallResponse;
|
|
17
|
+
export declare function isCancellationFrame(value: unknown): value is CancellationFrame;
|
|
18
|
+
export declare function isHeartbeatFrame(value: unknown): value is HeartbeatFrame;
|
|
19
|
+
export declare function isRuntimeDescriptor(value: unknown): value is RuntimeDescriptor;
|
|
20
|
+
export interface NdjsonFrameDecoderOptions {
|
|
21
|
+
maxLineLength?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare class NdjsonFrameDecoder {
|
|
24
|
+
#private;
|
|
25
|
+
constructor(options?: NdjsonFrameDecoderOptions);
|
|
26
|
+
push(chunk: string | Uint8Array): RuntimeFrame[];
|
|
27
|
+
finish(): RuntimeFrame[];
|
|
28
|
+
reset(): void;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EAEtB,KAAK,cAAc,EAEnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAGtB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAEjB,KAAK,gBAAgB,EAErB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AAKjC,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,eAAe,GAAG,sBAAsB,GAAG,eAAe,CAAC;gBAGzF,IAAI,EAAE,uBAAuB,CAAC,MAAM,CAAC,EACrC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY;CAMzB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAE5E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CA+B9D;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAQ9D;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAE9D;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAElE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAOpE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAE9E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAE5E;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAE9E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAa9E;AAED,MAAM,WAAW,yBAAyB;IACxC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,kBAAkB;;gBAKjB,OAAO,GAAE,yBAA8B;IAQnD,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,EAAE;IAKhD,MAAM,IAAI,YAAY,EAAE;IAKxB,KAAK,IAAI,IAAI;CA6Bd"}
|
package/dist/codec.js
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { RUNTIME_OPERATIONS, RUNTIME_PROTOCOL_VERSION, } from "./generated/protocol.js";
|
|
2
|
+
const operationSet = new Set(RUNTIME_OPERATIONS);
|
|
3
|
+
const frameTypes = new Set(["request", "response", "event", "host_call", "host_result", "cancel", "ping", "pong"]);
|
|
4
|
+
export class ProtocolValidationError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
constructor(code, message, options) {
|
|
7
|
+
super(message, options);
|
|
8
|
+
this.name = "ProtocolValidationError";
|
|
9
|
+
this.code = code;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function isRuntimeOperation(value) {
|
|
13
|
+
return typeof value === "string" && operationSet.has(value);
|
|
14
|
+
}
|
|
15
|
+
export function parseRuntimeFrame(value) {
|
|
16
|
+
if (!isRecord(value))
|
|
17
|
+
fail("frame must be a JSON object");
|
|
18
|
+
requireProtocol(value);
|
|
19
|
+
const type = requireString(value, "type");
|
|
20
|
+
if (!frameTypes.has(type))
|
|
21
|
+
fail(`unsupported frame type: ${type}`);
|
|
22
|
+
switch (type) {
|
|
23
|
+
case "request":
|
|
24
|
+
validateRequest(value);
|
|
25
|
+
break;
|
|
26
|
+
case "response":
|
|
27
|
+
validateResponse(value);
|
|
28
|
+
break;
|
|
29
|
+
case "event":
|
|
30
|
+
validateEventFrame(value);
|
|
31
|
+
break;
|
|
32
|
+
case "host_call":
|
|
33
|
+
validateHostCall(value);
|
|
34
|
+
break;
|
|
35
|
+
case "host_result":
|
|
36
|
+
validateHostResult(value);
|
|
37
|
+
break;
|
|
38
|
+
case "cancel":
|
|
39
|
+
validateCancellation(value);
|
|
40
|
+
break;
|
|
41
|
+
case "ping":
|
|
42
|
+
case "pong":
|
|
43
|
+
requireNonEmptyString(value, "nonce");
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
export function decodeRuntimeFrame(input) {
|
|
49
|
+
let value;
|
|
50
|
+
try {
|
|
51
|
+
value = JSON.parse(input);
|
|
52
|
+
}
|
|
53
|
+
catch (cause) {
|
|
54
|
+
throw new ProtocolValidationError("invalid_json", "Runtime frame is not valid JSON", { cause });
|
|
55
|
+
}
|
|
56
|
+
return parseRuntimeFrame(value);
|
|
57
|
+
}
|
|
58
|
+
export function encodeRuntimeFrame(frame) {
|
|
59
|
+
return JSON.stringify(parseRuntimeFrame(frame));
|
|
60
|
+
}
|
|
61
|
+
export function encodeRuntimeFrameLine(frame) {
|
|
62
|
+
return `${encodeRuntimeFrame(frame)}\n`;
|
|
63
|
+
}
|
|
64
|
+
export function isRuntimeFrame(value) {
|
|
65
|
+
try {
|
|
66
|
+
parseRuntimeFrame(value);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export function isRuntimeRequest(value) {
|
|
74
|
+
return isFrameType(value, "request");
|
|
75
|
+
}
|
|
76
|
+
export function isRuntimeResponse(value) {
|
|
77
|
+
return isFrameType(value, "response");
|
|
78
|
+
}
|
|
79
|
+
export function isRuntimeEventFrame(value) {
|
|
80
|
+
return isFrameType(value, "event");
|
|
81
|
+
}
|
|
82
|
+
export function isHostCallRequest(value) {
|
|
83
|
+
return isFrameType(value, "host_call");
|
|
84
|
+
}
|
|
85
|
+
export function isHostCallResponse(value) {
|
|
86
|
+
return isFrameType(value, "host_result");
|
|
87
|
+
}
|
|
88
|
+
export function isCancellationFrame(value) {
|
|
89
|
+
return isFrameType(value, "cancel");
|
|
90
|
+
}
|
|
91
|
+
export function isHeartbeatFrame(value) {
|
|
92
|
+
return isRuntimeFrame(value) && (value.type === "ping" || value.type === "pong");
|
|
93
|
+
}
|
|
94
|
+
export function isRuntimeDescriptor(value) {
|
|
95
|
+
if (!isRecord(value))
|
|
96
|
+
return false;
|
|
97
|
+
try {
|
|
98
|
+
if (value.protocolVersion !== RUNTIME_PROTOCOL_VERSION)
|
|
99
|
+
return false;
|
|
100
|
+
requireNonEmptyString(value, "platformVersion");
|
|
101
|
+
if (!isRuntimeMode(value.mode) || !isRuntimeProfile(value.profile))
|
|
102
|
+
return false;
|
|
103
|
+
if (!Array.isArray(value.operations) || !value.operations.every(isRuntimeOperation))
|
|
104
|
+
return false;
|
|
105
|
+
if (!Array.isArray(value.features) || !value.features.every((item) => typeof item === "string"))
|
|
106
|
+
return false;
|
|
107
|
+
if (!Array.isArray(value.transports) || !value.transports.every((item) => typeof item === "string"))
|
|
108
|
+
return false;
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export class NdjsonFrameDecoder {
|
|
116
|
+
#decoder = new TextDecoder();
|
|
117
|
+
#maxLineLength;
|
|
118
|
+
#buffer = "";
|
|
119
|
+
constructor(options = {}) {
|
|
120
|
+
const maxLineLength = options.maxLineLength ?? 1024 * 1024;
|
|
121
|
+
if (!Number.isSafeInteger(maxLineLength) || maxLineLength < 1) {
|
|
122
|
+
throw new RangeError("maxLineLength must be a positive safe integer");
|
|
123
|
+
}
|
|
124
|
+
this.#maxLineLength = maxLineLength;
|
|
125
|
+
}
|
|
126
|
+
push(chunk) {
|
|
127
|
+
this.#buffer += typeof chunk === "string" ? chunk : this.#decoder.decode(chunk, { stream: true });
|
|
128
|
+
return this.#drain(false);
|
|
129
|
+
}
|
|
130
|
+
finish() {
|
|
131
|
+
this.#buffer += this.#decoder.decode();
|
|
132
|
+
return this.#drain(true);
|
|
133
|
+
}
|
|
134
|
+
reset() {
|
|
135
|
+
this.#buffer = "";
|
|
136
|
+
this.#decoder.decode();
|
|
137
|
+
}
|
|
138
|
+
#drain(final) {
|
|
139
|
+
const frames = [];
|
|
140
|
+
let newline = this.#buffer.indexOf("\n");
|
|
141
|
+
while (newline >= 0) {
|
|
142
|
+
this.#assertLength(newline);
|
|
143
|
+
const line = stripCarriageReturn(this.#buffer.slice(0, newline));
|
|
144
|
+
this.#buffer = this.#buffer.slice(newline + 1);
|
|
145
|
+
if (line.trim().length > 0)
|
|
146
|
+
frames.push(decodeRuntimeFrame(line));
|
|
147
|
+
newline = this.#buffer.indexOf("\n");
|
|
148
|
+
}
|
|
149
|
+
this.#assertLength(this.#buffer.length);
|
|
150
|
+
if (final && this.#buffer.length > 0) {
|
|
151
|
+
const line = stripCarriageReturn(this.#buffer);
|
|
152
|
+
this.#buffer = "";
|
|
153
|
+
if (line.trim().length > 0)
|
|
154
|
+
frames.push(decodeRuntimeFrame(line));
|
|
155
|
+
}
|
|
156
|
+
return frames;
|
|
157
|
+
}
|
|
158
|
+
#assertLength(length) {
|
|
159
|
+
if (length > this.#maxLineLength) {
|
|
160
|
+
throw new ProtocolValidationError("line_too_long", `Runtime frame exceeds ${this.#maxLineLength} characters`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function isFrameType(value, type) {
|
|
165
|
+
return isRuntimeFrame(value) && value.type === type;
|
|
166
|
+
}
|
|
167
|
+
function validateRequest(value) {
|
|
168
|
+
requireNonEmptyString(value, "requestId");
|
|
169
|
+
if (!isRuntimeOperation(value.operation))
|
|
170
|
+
fail(`unsupported operation: ${String(value.operation)}`);
|
|
171
|
+
requireOwn(value, "payload");
|
|
172
|
+
}
|
|
173
|
+
function validateResponse(value) {
|
|
174
|
+
requireNonEmptyString(value, "requestId");
|
|
175
|
+
const status = requireString(value, "status");
|
|
176
|
+
if (status === "success")
|
|
177
|
+
requireOwn(value, "result");
|
|
178
|
+
else if (status === "error")
|
|
179
|
+
validateRuntimeError(requireRecord(value, "error"));
|
|
180
|
+
else
|
|
181
|
+
fail(`unsupported response status: ${status}`);
|
|
182
|
+
}
|
|
183
|
+
function validateEventFrame(value) {
|
|
184
|
+
requireNonEmptyString(value, "subscriptionId");
|
|
185
|
+
const sequence = value.sequence;
|
|
186
|
+
if (!Number.isSafeInteger(sequence) || sequence < 0)
|
|
187
|
+
fail("sequence must be a non-negative safe integer");
|
|
188
|
+
validateRuntimeEvent(requireRecord(value, "event"));
|
|
189
|
+
}
|
|
190
|
+
function validateHostCall(value) {
|
|
191
|
+
requireNonEmptyString(value, "callId");
|
|
192
|
+
requireNonEmptyString(value, "capability");
|
|
193
|
+
requireOwn(value, "input");
|
|
194
|
+
if (!Number.isSafeInteger(value.deadlineMs) || value.deadlineMs < 1)
|
|
195
|
+
fail("deadlineMs must be a positive safe integer");
|
|
196
|
+
validateHostCallContext(requireRecord(value, "context"));
|
|
197
|
+
}
|
|
198
|
+
function validateHostResult(value) {
|
|
199
|
+
requireNonEmptyString(value, "callId");
|
|
200
|
+
const status = requireString(value, "status");
|
|
201
|
+
if (status === "success")
|
|
202
|
+
requireOwn(value, "output");
|
|
203
|
+
else if (status === "error")
|
|
204
|
+
validateRuntimeError(requireRecord(value, "error"));
|
|
205
|
+
else if (status === "cancelled")
|
|
206
|
+
requireString(value, "reason");
|
|
207
|
+
else
|
|
208
|
+
fail(`unsupported Host Call status: ${status}`);
|
|
209
|
+
}
|
|
210
|
+
function validateCancellation(value) {
|
|
211
|
+
validateCancellationTarget(requireRecord(value, "target"));
|
|
212
|
+
if (hasOwn(value, "reason") && typeof value.reason !== "string")
|
|
213
|
+
fail("reason must be a string");
|
|
214
|
+
}
|
|
215
|
+
function validateRuntimeError(value) {
|
|
216
|
+
requireNonEmptyString(value, "code");
|
|
217
|
+
requireString(value, "message");
|
|
218
|
+
if (typeof value.retryable !== "boolean")
|
|
219
|
+
fail("retryable must be a boolean");
|
|
220
|
+
optionalNonEmptyString(value, "runId");
|
|
221
|
+
}
|
|
222
|
+
function validateRuntimeEvent(value) {
|
|
223
|
+
requireNonEmptyString(value, "type");
|
|
224
|
+
optionalNonEmptyString(value, "runId");
|
|
225
|
+
requireOwn(value, "payload");
|
|
226
|
+
}
|
|
227
|
+
function validateHostCallContext(value) {
|
|
228
|
+
requireNonEmptyString(value, "runId");
|
|
229
|
+
requireNonEmptyString(value, "principal");
|
|
230
|
+
requireNonEmptyString(value, "namespace");
|
|
231
|
+
optionalNonEmptyString(value, "traceId");
|
|
232
|
+
}
|
|
233
|
+
function validateCancellationTarget(value) {
|
|
234
|
+
const kind = requireString(value, "kind");
|
|
235
|
+
if (kind === "request")
|
|
236
|
+
requireNonEmptyString(value, "requestId");
|
|
237
|
+
else if (kind === "run")
|
|
238
|
+
requireNonEmptyString(value, "runId");
|
|
239
|
+
else if (kind === "host_call")
|
|
240
|
+
requireNonEmptyString(value, "callId");
|
|
241
|
+
else if (kind === "subscription")
|
|
242
|
+
requireNonEmptyString(value, "subscriptionId");
|
|
243
|
+
else
|
|
244
|
+
fail(`unsupported cancellation target: ${kind}`);
|
|
245
|
+
}
|
|
246
|
+
function requireProtocol(value) {
|
|
247
|
+
const protocol = requireString(value, "protocol");
|
|
248
|
+
if (protocol !== RUNTIME_PROTOCOL_VERSION) {
|
|
249
|
+
throw new ProtocolValidationError("unsupported_protocol", `Unsupported Runtime Protocol version: ${protocol}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function isRuntimeMode(value) {
|
|
253
|
+
return value === "embedded" || value === "process" || value === "server";
|
|
254
|
+
}
|
|
255
|
+
function isRuntimeProfile(value) {
|
|
256
|
+
return value === "minimal" || value === "stable" || value === "full";
|
|
257
|
+
}
|
|
258
|
+
function isRecord(value) {
|
|
259
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
260
|
+
}
|
|
261
|
+
function requireRecord(value, key) {
|
|
262
|
+
const result = value[key];
|
|
263
|
+
if (!isRecord(result))
|
|
264
|
+
fail(`${key} must be an object`);
|
|
265
|
+
return result;
|
|
266
|
+
}
|
|
267
|
+
function requireOwn(value, key) {
|
|
268
|
+
if (!hasOwn(value, key))
|
|
269
|
+
fail(`${key} is required`);
|
|
270
|
+
}
|
|
271
|
+
function requireString(value, key) {
|
|
272
|
+
const result = value[key];
|
|
273
|
+
if (typeof result !== "string")
|
|
274
|
+
fail(`${key} must be a string`);
|
|
275
|
+
return result;
|
|
276
|
+
}
|
|
277
|
+
function requireNonEmptyString(value, key) {
|
|
278
|
+
const result = requireString(value, key);
|
|
279
|
+
if (result.trim().length === 0)
|
|
280
|
+
fail(`${key} must not be empty`);
|
|
281
|
+
return result;
|
|
282
|
+
}
|
|
283
|
+
function optionalNonEmptyString(value, key) {
|
|
284
|
+
if (hasOwn(value, key))
|
|
285
|
+
requireNonEmptyString(value, key);
|
|
286
|
+
}
|
|
287
|
+
function hasOwn(value, key) {
|
|
288
|
+
return Object.prototype.hasOwnProperty.call(value, key);
|
|
289
|
+
}
|
|
290
|
+
function stripCarriageReturn(line) {
|
|
291
|
+
return line.endsWith("\r") ? line.slice(0, -1) : line;
|
|
292
|
+
}
|
|
293
|
+
function fail(message) {
|
|
294
|
+
throw new ProtocolValidationError("invalid_frame", message);
|
|
295
|
+
}
|
|
296
|
+
//# sourceMappingURL=codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GAiBzB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC,kBAAkB,CAAC,CAAC;AACtE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEnH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACvC,IAAI,CAA8E;IAE3F,YACE,IAAqC,EACrC,OAAe,EACf,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,IAAI,CAAC,6BAA6B,CAAC,CAAC;IAC1D,eAAe,CAAC,KAAK,CAAC,CAAC;IACvB,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,EAAE,MAAM,CA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