@nyte-ai/protocol 0.0.29-nightly.20261120.113 → 0.3.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.
Files changed (61) hide show
  1. package/README.md +1 -1
  2. package/THIRD-PARTY-NOTICES.md +61 -3
  3. package/dist/chunks/{client-ha6yznqf.js → index-0q4bw06r.js} +12 -5
  4. package/dist/chunks/{client-wn6q96dq.js → index-1gda64ex.js} +27 -9
  5. package/dist/chunks/{client-4fq758q8.js → index-362qtcjf.js} +43 -20
  6. package/dist/chunks/index-7v2tp03w.js +224 -0
  7. package/dist/chunks/{client-wqkvb55q.js → index-gw4eefqr.js} +72 -37
  8. package/dist/chunks/{client-3sbyne3r.js → index-h14s9gt3.js} +1 -1
  9. package/dist/chunks/{client-eggvt9rc.js → index-ht11mtxs.js} +1 -1
  10. package/dist/chunks/{client-sw8vswjs.js → index-k7th682a.js} +53 -15
  11. package/dist/chunks/{client-xscg1xbf.js → index-kr00kac7.js} +1 -1
  12. package/dist/chunks/{client-j4157t87.js → index-q0t950kb.js} +10 -4
  13. package/dist/chunks/{client-101w6sd1.js → index-ra9p4jfx.js} +1 -1
  14. package/dist/chunks/{client-b8brz84x.js → index-rzv8zrzf.js} +3 -1
  15. package/dist/chunks/index-t6hyhcet.js +36 -0
  16. package/dist/chunks/{client-kqr7p5nh.js → index-vbt1c8yx.js} +3 -2
  17. package/dist/src/client/directory-store.d.ts +24 -0
  18. package/dist/src/{directory-store.js → client/directory-store.js} +1 -1
  19. package/dist/src/{session-store.d.ts → client/session-store.d.ts} +3 -1
  20. package/dist/src/{session-store.js → client/session-store.js} +1 -1
  21. package/dist/src/{socket-client.d.ts → client/socket-client.d.ts} +5 -0
  22. package/dist/src/client/socket-client.js +9 -0
  23. package/dist/src/client/stream-client.d.ts +11 -0
  24. package/dist/src/client/stream-client.js +14 -0
  25. package/dist/src/{client.d.ts → client/transport.d.ts} +2 -3
  26. package/dist/src/client/transport.js +11 -0
  27. package/dist/src/index.d.ts +13 -13
  28. package/dist/src/index.js +20 -16
  29. package/dist/src/{codec.js → operations/codec.js} +3 -2
  30. package/dist/src/operations/declarations.js +1 -0
  31. package/dist/src/{digest.js → operations/digest.js} +1 -1
  32. package/dist/src/{raw-parts.js → operations/raw-parts.js} +1 -1
  33. package/dist/src/wire/frame-checks.d.ts +247 -0
  34. package/dist/src/{frame-checks.js → wire/frame-checks.js} +1 -1
  35. package/dist/src/wire/json.d.ts +6 -0
  36. package/dist/src/wire/json.js +10 -0
  37. package/dist/src/{stream-buffer.js → wire/stream-buffer.js} +1 -1
  38. package/dist/src/{stream-channel.js → wire/stream-channel.js} +1 -1
  39. package/dist/src/{streams.js → wire/streams.js} +1 -1
  40. package/dist/src/{wire.d.ts → wire/wire.d.ts} +2 -1
  41. package/dist/src/{wire.js → wire/wire.js} +2 -2
  42. package/package.json +9 -9
  43. package/dist/chunks/client-6vn29412.js +0 -138
  44. package/dist/chunks/client-rk08pxm6.js +0 -12
  45. package/dist/src/client.js +0 -11
  46. package/dist/src/declarations.js +0 -1
  47. package/dist/src/directory-store.d.ts +0 -16
  48. package/dist/src/frame-checks.d.ts +0 -246
  49. package/dist/src/json.d.ts +0 -2
  50. package/dist/src/json.js +0 -6
  51. package/dist/src/socket-client.js +0 -9
  52. package/dist/src/stream-client.d.ts +0 -7
  53. package/dist/src/stream-client.js +0 -10
  54. /package/dist/chunks/{client-x7k53ygp.js → index-r3zsnw1t.js} +0 -0
  55. /package/dist/src/{codec.d.ts → operations/codec.d.ts} +0 -0
  56. /package/dist/src/{declarations.d.ts → operations/declarations.d.ts} +0 -0
  57. /package/dist/src/{digest.d.ts → operations/digest.d.ts} +0 -0
  58. /package/dist/src/{raw-parts.d.ts → operations/raw-parts.d.ts} +0 -0
  59. /package/dist/src/{stream-buffer.d.ts → wire/stream-buffer.d.ts} +0 -0
  60. /package/dist/src/{stream-channel.d.ts → wire/stream-channel.d.ts} +0 -0
  61. /package/dist/src/{streams.d.ts → wire/streams.d.ts} +0 -0
package/dist/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
- parseJson2
3
- } from "../chunks/client-rk08pxm6.js";
2
+ parseJson2,
3
+ readJson2
4
+ } from "../chunks/index-t6hyhcet.js";
4
5
  import {
5
6
  errorStatus2,
6
7
  INPUT_HEADER2,
@@ -17,7 +18,7 @@ import {
17
18
  withInputHeader2,
18
19
  readInputHeader2,
19
20
  asSdkError2
20
- } from "../chunks/client-4fq758q8.js";
21
+ } from "../chunks/index-362qtcjf.js";
21
22
  import {
22
23
  CHANNEL_PATH2,
23
24
  CANCEL_PATH2,
@@ -25,17 +26,18 @@ import {
25
26
  STREAM_HEADER2,
26
27
  DEFLATE_REQUEST2,
27
28
  readStreamFrame2
28
- } from "../chunks/client-3sbyne3r.js";
29
+ } from "../chunks/index-h14s9gt3.js";
29
30
  import {
30
31
  streamBuffer2
31
- } from "../chunks/client-b8brz84x.js";
32
+ } from "../chunks/index-rzv8zrzf.js";
32
33
  import {
34
+ linkLost2,
33
35
  createStreamClient2
34
- } from "../chunks/client-wn6q96dq.js";
36
+ } from "../chunks/index-1gda64ex.js";
35
37
  import {
36
38
  createTransport2
37
- } from "../chunks/client-sw8vswjs.js";
38
- import"../chunks/client-eggvt9rc.js";
39
+ } from "../chunks/index-k7th682a.js";
40
+ import"../chunks/index-ht11mtxs.js";
39
41
  import {
40
42
  namesOperation2,
41
43
  answersOnce2,
@@ -44,25 +46,25 @@ import {
44
46
  encodeInput2,
45
47
  encodeOutput2,
46
48
  decodeOutput2
47
- } from "../chunks/client-wqkvb55q.js";
48
- import"../chunks/client-x7k53ygp.js";
49
+ } from "../chunks/index-gw4eefqr.js";
50
+ import"../chunks/index-r3zsnw1t.js";
49
51
  import {
50
52
  openSessionStore2
51
- } from "../chunks/client-j4157t87.js";
53
+ } from "../chunks/index-q0t950kb.js";
52
54
  import {
53
55
  openDirectoryStore2
54
- } from "../chunks/client-ha6yznqf.js";
55
- import"../chunks/client-kqr7p5nh.js";
56
+ } from "../chunks/index-0q4bw06r.js";
57
+ import"../chunks/index-vbt1c8yx.js";
56
58
  import {
57
59
  openHostSocket2
58
- } from "../chunks/client-6vn29412.js";
60
+ } from "../chunks/index-7v2tp03w.js";
59
61
  import {
60
62
  mapped2,
61
63
  abortable2
62
- } from "../chunks/client-xscg1xbf.js";
64
+ } from "../chunks/index-kr00kac7.js";
63
65
  import {
64
66
  operationsDigest2
65
- } from "../chunks/client-101w6sd1.js";
67
+ } from "../chunks/index-ra9p4jfx.js";
66
68
  export {
67
69
  CANCEL_PATH2 as CANCEL_PATH,
68
70
  CHANNEL_HEADER2 as CHANNEL_HEADER,
@@ -85,6 +87,7 @@ export {
85
87
  encodeInput2 as encodeInput,
86
88
  encodeOutput2 as encodeOutput,
87
89
  errorStatus2 as errorStatus,
90
+ linkLost2 as linkLost,
88
91
  mapped2 as mapped,
89
92
  namesOperation2 as namesOperation,
90
93
  octetStream2 as octetStream,
@@ -97,6 +100,7 @@ export {
97
100
  parseOutputFrames2 as parseOutputFrames,
98
101
  parseSse2 as parseSse,
99
102
  readInputHeader2 as readInputHeader,
103
+ readJson2 as readJson,
100
104
  readStreamFrame2 as readStreamFrame,
101
105
  sseFrames2 as sseFrames,
102
106
  statusCode2 as statusCode,
@@ -6,8 +6,9 @@ import {
6
6
  encodeInput2,
7
7
  encodeOutput2,
8
8
  decodeOutput2
9
- } from "../chunks/client-wqkvb55q.js";
10
- import"../chunks/client-eggvt9rc.js";
9
+ } from "../../chunks/index-gw4eefqr.js";
10
+ import"../../chunks/index-ht11mtxs.js";
11
+ import"../../chunks/index-t6hyhcet.js";
11
12
  export {
12
13
  answersBytes2 as answersBytes,
13
14
  answersOnce2 as answersOnce,
@@ -0,0 +1 @@
1
+ import"../../chunks/index-r3zsnw1t.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  operationsDigest2
3
- } from "../chunks/client-101w6sd1.js";
3
+ } from "../../chunks/index-ra9p4jfx.js";
4
4
  export {
5
5
  operationsDigest2 as operationsDigest
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  rawPart2
3
- } from "../chunks/client-eggvt9rc.js";
3
+ } from "../../chunks/index-ht11mtxs.js";
4
4
  export {
5
5
  rawPart2 as rawPart
6
6
  };
@@ -0,0 +1,247 @@
1
+ import type { Json } from "@nyte-ai/schema";
2
+ import { Type } from "typebox";
3
+ export declare const welcomes: Pick<import("typebox/compile").Validator<{}, Type.TCyclic<{
4
+ Json: Type.TUnion<[Type.TNull, Type.TBoolean, Type.TNumber, Type.TString, Type.TArray<Type.TRef<"Json">>, Type.TRecord<"^.*$", Type.TRef<"Json">>]>;
5
+ } & {
6
+ Root: Type.TObject<{
7
+ c: Type.TLiteral<"e">;
8
+ type: Type.TLiteral<"welcome">;
9
+ api_revision: Type.TInteger;
10
+ api_min_revision: Type.TInteger;
11
+ api_server_revision: Type.TInteger;
12
+ host_id: Type.TUnsafe<import("@nyte-ai/schema").Id<"host">>;
13
+ client_id: Type.TUnsafe<import("@nyte-ai/schema").Id<"client">>;
14
+ limits: Type.TObject<{
15
+ backlogBytes: Type.TInteger;
16
+ maxFrameBytes: Type.TInteger;
17
+ }>;
18
+ }>;
19
+ }, "Root">, {
20
+ c: "e";
21
+ type: "welcome";
22
+ api_revision: number;
23
+ api_min_revision: number;
24
+ api_server_revision: number;
25
+ host_id: import("@nyte-ai/schema").Id<"host">;
26
+ client_id: import("@nyte-ai/schema").Id<"client">;
27
+ limits: {
28
+ backlogBytes: number;
29
+ maxFrameBytes: number;
30
+ };
31
+ }, {
32
+ c: "e";
33
+ type: "welcome";
34
+ api_revision: number;
35
+ api_min_revision: number;
36
+ api_server_revision: number;
37
+ host_id: import("@nyte-ai/schema").Id<"host">;
38
+ client_id: import("@nyte-ai/schema").Id<"client">;
39
+ limits: {
40
+ backlogBytes: number;
41
+ maxFrameBytes: number;
42
+ };
43
+ }>, "Check">;
44
+ export declare const results: Pick<import("typebox/compile").Validator<{}, Type.TObject<{
45
+ c: Type.TLiteral<"e">;
46
+ type: Type.TLiteral<"result">;
47
+ id: Type.TString;
48
+ output: Type.TUnsafe<Json>;
49
+ }>, {
50
+ c: "e";
51
+ type: "result";
52
+ id: string;
53
+ output: Json;
54
+ }, {
55
+ c: "e";
56
+ type: "result";
57
+ id: string;
58
+ output: Json;
59
+ }>, "Check">;
60
+ export declare const errors: Pick<import("typebox/compile").Validator<{}, Type.TCyclic<{
61
+ Json: Type.TUnion<[Type.TNull, Type.TBoolean, Type.TNumber, Type.TString, Type.TArray<Type.TRef<"Json">>, Type.TRecord<"^.*$", Type.TRef<"Json">>]>;
62
+ } & {
63
+ Root: Type.TObject<{
64
+ c: Type.TLiteral<"e">;
65
+ type: Type.TLiteral<"error">;
66
+ id: Type.TString;
67
+ error: Type.TObject<{
68
+ code: Type.TEnum<["unauthenticated", "denied", "unknown", "invalid", "stale", "unavailable", "internal", "not_supported", "timeout"]>;
69
+ message: Type.TString;
70
+ hostId: Type.TUnion<[Type.TUnsafe<import("@nyte-ai/schema").Id<"host">>, Type.TNull]>;
71
+ issues: Type.TArray<Type.TObject<{
72
+ severity: Type.TEnum<["error", "warning"]>;
73
+ path: Type.TArray<Type.TUnion<[Type.TString, Type.TNumber]>>;
74
+ message: Type.TString;
75
+ source: Type.TOptional<Type.TObject<{
76
+ plugin: Type.TString;
77
+ file: Type.TOptional<Type.TString>;
78
+ line: Type.TOptional<Type.TNumber>;
79
+ }>>;
80
+ }>>;
81
+ correlation: Type.TUnion<[Type.TString, Type.TNull]>;
82
+ retry: Type.TOptional<Type.TBoolean>;
83
+ }>;
84
+ }>;
85
+ }, "Root">, {
86
+ c: "e";
87
+ type: "error";
88
+ id: string;
89
+ error: {
90
+ code: "denied" | "internal" | "invalid" | "not_supported" | "stale" | "timeout" | "unauthenticated" | "unavailable" | "unknown";
91
+ message: string;
92
+ hostId: import("@nyte-ai/schema").Id<"host"> | null;
93
+ issues: {
94
+ severity: "error" | "warning";
95
+ path: (string | number)[];
96
+ message: string;
97
+ source?: {
98
+ plugin: string;
99
+ file?: string | undefined;
100
+ line?: number | undefined;
101
+ } | undefined;
102
+ }[];
103
+ correlation: string | null;
104
+ retry?: boolean | undefined;
105
+ };
106
+ }, {
107
+ c: "e";
108
+ type: "error";
109
+ id: string;
110
+ error: {
111
+ code: "denied" | "internal" | "invalid" | "not_supported" | "stale" | "timeout" | "unauthenticated" | "unavailable" | "unknown";
112
+ message: string;
113
+ hostId: import("@nyte-ai/schema").Id<"host"> | null;
114
+ issues: {
115
+ severity: "error" | "warning";
116
+ path: (string | number)[];
117
+ message: string;
118
+ source?: {
119
+ plugin: string;
120
+ file?: string | undefined;
121
+ line?: number | undefined;
122
+ } | undefined;
123
+ }[];
124
+ correlation: string | null;
125
+ retry?: boolean | undefined;
126
+ };
127
+ }>, "Check">;
128
+ export declare const events: Pick<import("typebox/compile").Validator<{}, Type.TCyclic<{
129
+ Json: Type.TUnion<[Type.TNull, Type.TBoolean, Type.TNumber, Type.TString, Type.TArray<Type.TRef<"Json">>, Type.TRecord<"^.*$", Type.TRef<"Json">>]>;
130
+ } & {
131
+ Root: Type.TObject<{
132
+ c: Type.TLiteral<"e">;
133
+ type: Type.TLiteral<"event">;
134
+ scope: Type.TString;
135
+ seq: Type.TUnion<[Type.TInteger, Type.TNull]>;
136
+ kind: Type.TString;
137
+ }>;
138
+ }, "Root">, {
139
+ c: "e";
140
+ type: "event";
141
+ scope: string;
142
+ seq: number | null;
143
+ kind: string;
144
+ }, {
145
+ c: "e";
146
+ type: "event";
147
+ scope: string;
148
+ seq: number | null;
149
+ kind: string;
150
+ }>, "Check">;
151
+ export declare const texts: Pick<import("typebox/compile").Validator<{}, Type.TCyclic<{
152
+ Json: Type.TUnion<[Type.TNull, Type.TBoolean, Type.TNumber, Type.TString, Type.TArray<Type.TRef<"Json">>, Type.TRecord<"^.*$", Type.TRef<"Json">>]>;
153
+ } & {
154
+ Root: Type.TUnion<[Type.TObject<{
155
+ c: Type.TLiteral<"t">;
156
+ part: Type.TUnsafe<import("@nyte-ai/schema").Id<"part">>;
157
+ run: Type.TUnion<[Type.TUnsafe<import("@nyte-ai/schema").Id<"run">>, Type.TNull]>;
158
+ version: Type.TNumber;
159
+ text: Type.TString;
160
+ }>, Type.TObject<{
161
+ c: Type.TLiteral<"t">;
162
+ part: Type.TUnsafe<import("@nyte-ai/schema").Id<"part">>;
163
+ run: Type.TUnion<[Type.TUnsafe<import("@nyte-ai/schema").Id<"run">>, Type.TNull]>;
164
+ version: Type.TNumber;
165
+ append: Type.TString;
166
+ }>, Type.TObject<{
167
+ c: Type.TLiteral<"t">;
168
+ part: Type.TUnsafe<import("@nyte-ai/schema").Id<"part">>;
169
+ run: Type.TUnion<[Type.TUnsafe<import("@nyte-ai/schema").Id<"run">>, Type.TNull]>;
170
+ progress: Type.TObject<{
171
+ text: Type.TOptional<Type.TString>;
172
+ fraction: Type.TOptional<Type.TNumber>;
173
+ detail: Type.TOptional<Type.TUnsafe<Json>>;
174
+ }>;
175
+ }>, Type.TObject<{
176
+ c: Type.TLiteral<"t">;
177
+ type: Type.TLiteral<"closed">;
178
+ }>]>;
179
+ }, "Root">, {
180
+ c: "t";
181
+ part: import("@nyte-ai/schema").Id<"part">;
182
+ run: import("@nyte-ai/schema").Id<"run"> | null;
183
+ version: number;
184
+ text: string;
185
+ } | {
186
+ c: "t";
187
+ part: import("@nyte-ai/schema").Id<"part">;
188
+ run: import("@nyte-ai/schema").Id<"run"> | null;
189
+ version: number;
190
+ append: string;
191
+ } | {
192
+ c: "t";
193
+ part: import("@nyte-ai/schema").Id<"part">;
194
+ run: import("@nyte-ai/schema").Id<"run"> | null;
195
+ progress: {
196
+ text?: string | undefined;
197
+ fraction?: number | undefined;
198
+ detail?: Json | undefined;
199
+ };
200
+ } | {
201
+ c: "t";
202
+ type: "closed";
203
+ }, {
204
+ c: "t";
205
+ part: import("@nyte-ai/schema").Id<"part">;
206
+ run: import("@nyte-ai/schema").Id<"run"> | null;
207
+ version: number;
208
+ text: string;
209
+ } | {
210
+ c: "t";
211
+ part: import("@nyte-ai/schema").Id<"part">;
212
+ run: import("@nyte-ai/schema").Id<"run"> | null;
213
+ version: number;
214
+ append: string;
215
+ } | {
216
+ c: "t";
217
+ part: import("@nyte-ai/schema").Id<"part">;
218
+ run: import("@nyte-ai/schema").Id<"run"> | null;
219
+ progress: {
220
+ text?: string | undefined;
221
+ fraction?: number | undefined;
222
+ detail?: Json | undefined;
223
+ };
224
+ } | {
225
+ c: "t";
226
+ type: "closed";
227
+ }>, "Check">;
228
+ export declare const fragments: Pick<import("typebox/compile").Validator<{}, Type.TCyclic<{
229
+ Json: Type.TUnion<[Type.TNull, Type.TBoolean, Type.TNumber, Type.TString, Type.TArray<Type.TRef<"Json">>, Type.TRecord<"^.*$", Type.TRef<"Json">>]>;
230
+ } & {
231
+ Root: Type.TObject<{
232
+ c: Type.TLiteral<"e">;
233
+ type: Type.TLiteral<"fragment">;
234
+ text: Type.TString;
235
+ last: Type.TBoolean;
236
+ }>;
237
+ }, "Root">, {
238
+ c: "e";
239
+ type: "fragment";
240
+ text: string;
241
+ last: boolean;
242
+ }, {
243
+ c: "e";
244
+ type: "fragment";
245
+ text: string;
246
+ last: boolean;
247
+ }>, "Check">;
@@ -5,7 +5,7 @@ import {
5
5
  events2,
6
6
  texts2,
7
7
  fragments2
8
- } from "../chunks/client-kqr7p5nh.js";
8
+ } from "../../chunks/index-vbt1c8yx.js";
9
9
  export {
10
10
  errors2 as errors,
11
11
  events2 as events,
@@ -0,0 +1,6 @@
1
+ import { Type } from "typebox";
2
+ import type { Json } from "@nyte-ai/schema";
3
+ export declare const unchecked: import("typebox/compile").Validator<{}, Type.TUnsafe<Json>, Json, Json>;
4
+ export declare function parseJson(text: string): Json;
5
+ /** `JSON.parse` without a reviver returns only null, booleans, strings, finite numbers, arrays and plain objects, except that it reads a number too large for a double as an infinity; so only the numbers are checked. */
6
+ export declare function readJson(text: string): Json | undefined;
@@ -0,0 +1,10 @@
1
+ import {
2
+ unchecked2,
3
+ parseJson2,
4
+ readJson2
5
+ } from "../../chunks/index-t6hyhcet.js";
6
+ export {
7
+ parseJson2 as parseJson,
8
+ readJson2 as readJson,
9
+ unchecked2 as unchecked
10
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  streamBuffer2
3
- } from "../chunks/client-b8brz84x.js";
3
+ } from "../../chunks/index-rzv8zrzf.js";
4
4
  export {
5
5
  streamBuffer2 as streamBuffer
6
6
  };
@@ -5,7 +5,7 @@ import {
5
5
  STREAM_HEADER2,
6
6
  DEFLATE_REQUEST2,
7
7
  readStreamFrame2
8
- } from "../chunks/client-3sbyne3r.js";
8
+ } from "../../chunks/index-h14s9gt3.js";
9
9
  export {
10
10
  CANCEL_PATH2 as CANCEL_PATH,
11
11
  CHANNEL_HEADER2 as CHANNEL_HEADER,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  mapped2,
3
3
  abortable2
4
- } from "../chunks/client-xscg1xbf.js";
4
+ } from "../../chunks/index-kr00kac7.js";
5
5
  export {
6
6
  abortable2 as abortable,
7
7
  mapped2 as mapped
@@ -15,6 +15,7 @@ export declare const INPUT_HEADER = "X-Nyte-Input";
15
15
  /** Names the response header carrying the id of the host that answered, `X-Nyte-Host: <hostId>`, on every response a listener sends, so a client compares it with `expect.hostId` on its first answer (§43a, §43j). */
16
16
  export declare const HOST_HEADER = "X-Nyte-Host";
17
17
  export declare const OPERATIONS_HEADER = "X-Nyte-Operations";
18
+ /** Returns the wire form of an error; `retry` is sent only when true, so a final error's frame is the one a host before it sent. */
18
19
  export declare function encodeError(error: SdkError): SdkErrorWire;
19
20
  /** Rebuilds the `SdkError` a wire error carries; a body that is not a wire error is the code `statusCode` gives the response's status, `internal` without one. */
20
21
  export declare function decodeError(value: Json, status?: number): SdkError;
@@ -24,7 +25,7 @@ export declare function statusCode(status: number): SdkErrorCode;
24
25
  export declare function sseFrames(source: AsyncIterable<Json>, options?: {
25
26
  readonly heartbeatMs?: number;
26
27
  }): ReadableStream<Uint8Array>;
27
- /** Parses a server-sent event stream into each frame's JSON data; comments and any other field are skipped, and an `error` event throws the `SdkError` it carries. Returning early cancels the stream. */
28
+ /** Parses a server-sent event stream into each frame's JSON data; comments and any other field are skipped, and an `error` event throws the `SdkError` it carries. Returning early cancels the stream. Each chunk is read once: a `\n` that starts a chunk ends the `\r` that ended the last one, and a lone line break that ends a chunk waits for the next, so a line break or blank line split between two chunks reads as it would whole. */
28
29
  export declare function parseSse(stream: ReadableStream<Uint8Array>): AsyncGenerator<Json>;
29
30
  /** Returns an `application/octet-stream` response over a byte reader: its mime in `X-Nyte-Mime`, its size as `Content-Length` when known (§40w), plus `headers`. The reader closes once, when the body ends, is cancelled, or `signal` aborts; an abort also errors the body. */
30
31
  export declare function octetStream(body: {
@@ -14,8 +14,8 @@ import {
14
14
  withInputHeader2,
15
15
  readInputHeader2,
16
16
  asSdkError2
17
- } from "../chunks/client-4fq758q8.js";
18
- import"../chunks/client-rk08pxm6.js";
17
+ } from "../../chunks/index-362qtcjf.js";
18
+ import"../../chunks/index-t6hyhcet.js";
19
19
  export {
20
20
  HOST_HEADER2 as HOST_HEADER,
21
21
  INPUT_HEADER2 as INPUT_HEADER,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nyte-ai/protocol",
3
- "version": "0.0.29-nightly.20261120.113",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -20,8 +20,8 @@
20
20
  "import": "./dist/src/index.js"
21
21
  },
22
22
  "./frame-checks": {
23
- "types": "./dist/src/frame-checks.d.ts",
24
- "import": "./dist/src/frame-checks.js"
23
+ "types": "./dist/src/wire/frame-checks.d.ts",
24
+ "import": "./dist/src/wire/frame-checks.js"
25
25
  }
26
26
  },
27
27
  "publishConfig": {
@@ -29,15 +29,15 @@
29
29
  "provenance": true
30
30
  },
31
31
  "dependencies": {
32
- "@nyte-ai/core": "0.0.29-nightly.20261120.113",
33
- "@nyte-ai/schema": "0.0.29-nightly.20261120.113",
32
+ "@nyte-ai/core": "0.3.0",
33
+ "@nyte-ai/schema": "0.3.0",
34
34
  "fflate": "^0.8.3",
35
- "typebox": "^1.4.6"
35
+ "typebox": "^1.4.7"
36
36
  },
37
37
  "devDependencies": {
38
- "@nyte-ai/ai": "0.0.29-nightly.20261120.113",
39
- "@types/node": "^26.6.5",
40
- "vitest": "^5.0.5"
38
+ "@nyte-ai/ai": "0.3.0",
39
+ "@types/node": "^26.6.6",
40
+ "vitest": "^5.1.0"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=26.4.0"
@@ -1,138 +0,0 @@
1
- import {
2
- welcomes2,
3
- results2,
4
- errors2,
5
- events2,
6
- texts2,
7
- fragments2
8
- } from "./client-kqr7p5nh.js";
9
- import {
10
- decodeError2
11
- } from "./client-4fq758q8.js";
12
-
13
- // src/socket-client.ts
14
- import {
15
- API_MIN_REVISION,
16
- API_REVISION,
17
- isJson,
18
- isJsonObject,
19
- SdkError,
20
- SOCKET_LIMITS
21
- } from "@nyte-ai/schema";
22
- async function openHostSocket2(input) {
23
- const socket = input.socket;
24
- const waiting = new Map;
25
- const eventListeners = new Set;
26
- const textListeners = new Set;
27
- const greeted = Promise.withResolvers();
28
- const ended = Promise.withResolvers();
29
- const pieces = [];
30
- let held = 0;
31
- let calls = 0;
32
- greeted.promise.catch(() => {
33
- return;
34
- });
35
- const read = (value) => {
36
- if (welcomes2.Check(value))
37
- greeted.resolve(value);
38
- else if (results2.Check(value))
39
- settle(value.id, value.output, null);
40
- else if (errors2.Check(value))
41
- settle(value.id, null, decodeError2(value.error));
42
- else if (isJsonObject(value) && events2.Check(value))
43
- for (const listener of eventListeners)
44
- listener(value);
45
- else if (texts2.Check(value))
46
- for (const listener of textListeners)
47
- listener(value);
48
- };
49
- socket.addEventListener("message", (message) => {
50
- const value = typeof message.data === "string" ? readJson(message.data) : undefined;
51
- if (!fragments2.Check(value)) {
52
- read(value);
53
- return;
54
- }
55
- held += value.text.length;
56
- if (held > SOCKET_LIMITS.backlogBytes) {
57
- pieces.length = 0;
58
- socket.close(1000, "Fragments passed the backlog limit.");
59
- return;
60
- }
61
- pieces.push(value.text);
62
- if (!value.last)
63
- return;
64
- const joined = readJson(pieces.join(""));
65
- pieces.length = 0;
66
- held = 0;
67
- if (joined === undefined) {
68
- socket.close(1000, "Fragments joined to no frame.");
69
- return;
70
- }
71
- read(joined);
72
- });
73
- socket.addEventListener("close", (event) => {
74
- const closed = { code: event.code, reason: event.reason };
75
- const failure = new SdkError("unavailable", closed.reason === "" ? `The host closed the socket (${closed.code}).` : closed.reason);
76
- greeted.reject(failure);
77
- for (const entry of waiting.values())
78
- entry.reject(failure);
79
- waiting.clear();
80
- ended.resolve(closed);
81
- });
82
- const settle = (id, output, failure) => {
83
- const entry = waiting.get(id);
84
- if (entry === undefined)
85
- return;
86
- waiting.delete(id);
87
- if (failure === null)
88
- entry.resolve(output);
89
- else
90
- entry.reject(failure);
91
- };
92
- await new Promise((opened, failed) => {
93
- socket.addEventListener("open", () => opened());
94
- socket.addEventListener("error", () => failed(new SdkError("unavailable", "Couldn't open the host's socket.")));
95
- });
96
- socket.send(JSON.stringify({
97
- c: "e",
98
- type: "hello",
99
- api_min_revision: input.apiMinRevision ?? API_MIN_REVISION,
100
- api_revision: API_REVISION,
101
- client: input.client
102
- }));
103
- return {
104
- welcome: greeted.promise,
105
- closed: ended.promise,
106
- call(op, value) {
107
- calls += 1;
108
- const id = String(calls);
109
- return new Promise((resolve, reject) => {
110
- waiting.set(id, { resolve, reject });
111
- socket.send(JSON.stringify({ c: "e", type: "call", id, op, input: value }));
112
- });
113
- },
114
- onEvent(listener) {
115
- eventListeners.add(listener);
116
- return () => {
117
- eventListeners.delete(listener);
118
- };
119
- },
120
- onText(listener) {
121
- textListeners.add(listener);
122
- return () => {
123
- textListeners.delete(listener);
124
- };
125
- },
126
- close: () => socket.close(1000, "done")
127
- };
128
- }
129
- function readJson(text) {
130
- try {
131
- const value = JSON.parse(text);
132
- return isJson(value) ? value : undefined;
133
- } catch {
134
- return;
135
- }
136
- }
137
-
138
- export { openHostSocket2 };
@@ -1,12 +0,0 @@
1
- // src/json.ts
2
- import { isJson, SdkError } from "@nyte-ai/schema";
3
- function parseJson2(text) {
4
- try {
5
- const value = JSON.parse(text);
6
- if (isJson(value))
7
- return value;
8
- } catch {}
9
- throw new SdkError("invalid", "The body is not JSON.");
10
- }
11
-
12
- export { parseJson2 };
@@ -1,11 +0,0 @@
1
- import {
2
- createTransport2
3
- } from "../chunks/client-sw8vswjs.js";
4
- import"../chunks/client-wn6q96dq.js";
5
- import"../chunks/client-b8brz84x.js";
6
- import"../chunks/client-3sbyne3r.js";
7
- import"../chunks/client-4fq758q8.js";
8
- import"../chunks/client-rk08pxm6.js";
9
- export {
10
- createTransport2 as createTransport
11
- };
@@ -1 +0,0 @@
1
- import"../chunks/client-x7k53ygp.js";