reactor-effect-client 0.0.0-reserved.0 → 0.2.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 (267) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +29 -0
  3. package/README.md +124 -2
  4. package/dist/FetchHttp.d.ts +9 -0
  5. package/dist/FetchHttp.d.ts.map +1 -0
  6. package/dist/FetchHttp.js +63 -0
  7. package/dist/FetchHttp.js.map +1 -0
  8. package/dist/PeerFactory.d.ts +15 -0
  9. package/dist/PeerFactory.d.ts.map +1 -0
  10. package/dist/PeerFactory.js +4 -0
  11. package/dist/PeerFactory.js.map +1 -0
  12. package/dist/PeerTypes.d.ts +64 -0
  13. package/dist/PeerTypes.d.ts.map +1 -0
  14. package/dist/PeerTypes.js +2 -0
  15. package/dist/PeerTypes.js.map +1 -0
  16. package/dist/Sequence.d.ts +81 -0
  17. package/dist/Sequence.d.ts.map +1 -0
  18. package/dist/Sequence.js +215 -0
  19. package/dist/Sequence.js.map +1 -0
  20. package/dist/SessionTypes.d.ts +164 -0
  21. package/dist/SessionTypes.d.ts.map +1 -0
  22. package/dist/SessionTypes.js +2 -0
  23. package/dist/SessionTypes.js.map +1 -0
  24. package/dist/Submission.d.ts +42 -0
  25. package/dist/Submission.d.ts.map +1 -0
  26. package/dist/Submission.js +52 -0
  27. package/dist/Submission.js.map +1 -0
  28. package/dist/bytes.d.ts +6 -0
  29. package/dist/bytes.d.ts.map +1 -0
  30. package/dist/bytes.js +32 -0
  31. package/dist/bytes.js.map +1 -0
  32. package/dist/contract.d.ts +58 -0
  33. package/dist/contract.d.ts.map +1 -0
  34. package/dist/contract.js +87 -0
  35. package/dist/contract.js.map +1 -0
  36. package/dist/coordinator/_internal/client.d.ts +127 -0
  37. package/dist/coordinator/_internal/client.d.ts.map +1 -0
  38. package/dist/coordinator/_internal/client.js +450 -0
  39. package/dist/coordinator/_internal/client.js.map +1 -0
  40. package/dist/coordinator/_internal/response.d.ts +15 -0
  41. package/dist/coordinator/_internal/response.d.ts.map +1 -0
  42. package/dist/coordinator/_internal/response.js +57 -0
  43. package/dist/coordinator/_internal/response.js.map +1 -0
  44. package/dist/coordinator/_internal/schemas.d.ts +51 -0
  45. package/dist/coordinator/_internal/schemas.d.ts.map +1 -0
  46. package/dist/coordinator/_internal/schemas.js +170 -0
  47. package/dist/coordinator/_internal/schemas.js.map +1 -0
  48. package/dist/coordinator/index.d.ts +28 -0
  49. package/dist/coordinator/index.d.ts.map +1 -0
  50. package/dist/coordinator/index.js +25 -0
  51. package/dist/coordinator/index.js.map +1 -0
  52. package/dist/correlation.d.ts +32 -0
  53. package/dist/correlation.d.ts.map +1 -0
  54. package/dist/correlation.js +113 -0
  55. package/dist/correlation.js.map +1 -0
  56. package/dist/errors.d.ts +88 -0
  57. package/dist/errors.d.ts.map +1 -0
  58. package/dist/errors.js +93 -0
  59. package/dist/errors.js.map +1 -0
  60. package/dist/h3/_internal/client.d.ts +9 -0
  61. package/dist/h3/_internal/client.d.ts.map +1 -0
  62. package/dist/h3/_internal/client.js +510 -0
  63. package/dist/h3/_internal/client.js.map +1 -0
  64. package/dist/h3/_internal/contracts.d.ts +123 -0
  65. package/dist/h3/_internal/contracts.d.ts.map +1 -0
  66. package/dist/h3/_internal/contracts.js +113 -0
  67. package/dist/h3/_internal/contracts.js.map +1 -0
  68. package/dist/h3/_internal/deployment.d.ts +8 -0
  69. package/dist/h3/_internal/deployment.d.ts.map +1 -0
  70. package/dist/h3/_internal/deployment.js +132 -0
  71. package/dist/h3/_internal/deployment.js.map +1 -0
  72. package/dist/h3/_internal/evidence.d.ts +17 -0
  73. package/dist/h3/_internal/evidence.d.ts.map +1 -0
  74. package/dist/h3/_internal/evidence.js +48 -0
  75. package/dist/h3/_internal/evidence.js.map +1 -0
  76. package/dist/h3/_internal/references.d.ts +18 -0
  77. package/dist/h3/_internal/references.d.ts.map +1 -0
  78. package/dist/h3/_internal/references.js +186 -0
  79. package/dist/h3/_internal/references.js.map +1 -0
  80. package/dist/h3/_internal/request.d.ts +16 -0
  81. package/dist/h3/_internal/request.d.ts.map +1 -0
  82. package/dist/h3/_internal/request.js +79 -0
  83. package/dist/h3/_internal/request.js.map +1 -0
  84. package/dist/h3/_internal/state.d.ts +30 -0
  85. package/dist/h3/_internal/state.d.ts.map +1 -0
  86. package/dist/h3/_internal/state.js +243 -0
  87. package/dist/h3/_internal/state.js.map +1 -0
  88. package/dist/h3/index.d.ts +10 -0
  89. package/dist/h3/index.d.ts.map +1 -0
  90. package/dist/h3/index.js +7 -0
  91. package/dist/h3/index.js.map +1 -0
  92. package/dist/h3/messages.d.ts +310 -0
  93. package/dist/h3/messages.d.ts.map +1 -0
  94. package/dist/h3/messages.js +114 -0
  95. package/dist/h3/messages.js.map +1 -0
  96. package/dist/h3/profile.d.ts +109 -0
  97. package/dist/h3/profile.d.ts.map +1 -0
  98. package/dist/h3/profile.js +70 -0
  99. package/dist/h3/profile.js.map +1 -0
  100. package/dist/h3/types.d.ts +173 -0
  101. package/dist/h3/types.d.ts.map +1 -0
  102. package/dist/h3/types.js +2 -0
  103. package/dist/h3/types.js.map +1 -0
  104. package/dist/host.d.ts +25 -0
  105. package/dist/host.d.ts.map +1 -0
  106. package/dist/host.js +20 -0
  107. package/dist/host.js.map +1 -0
  108. package/dist/index.d.ts +17 -0
  109. package/dist/index.d.ts.map +1 -0
  110. package/dist/index.js +8 -0
  111. package/dist/index.js.map +1 -0
  112. package/dist/json.d.ts +18 -0
  113. package/dist/json.d.ts.map +1 -0
  114. package/dist/json.js +123 -0
  115. package/dist/json.js.map +1 -0
  116. package/dist/media-stream.d.ts +10 -0
  117. package/dist/media-stream.d.ts.map +1 -0
  118. package/dist/media-stream.js +20 -0
  119. package/dist/media-stream.js.map +1 -0
  120. package/dist/observation.d.ts +26 -0
  121. package/dist/observation.d.ts.map +1 -0
  122. package/dist/observation.js +106 -0
  123. package/dist/observation.js.map +1 -0
  124. package/dist/orchestration/h3-source.d.ts +30 -0
  125. package/dist/orchestration/h3-source.d.ts.map +1 -0
  126. package/dist/orchestration/h3-source.js +303 -0
  127. package/dist/orchestration/h3-source.js.map +1 -0
  128. package/dist/orchestration/index.d.ts +12 -0
  129. package/dist/orchestration/index.d.ts.map +1 -0
  130. package/dist/orchestration/index.js +9 -0
  131. package/dist/orchestration/index.js.map +1 -0
  132. package/dist/orchestration/media-buffer.d.ts +23 -0
  133. package/dist/orchestration/media-buffer.d.ts.map +1 -0
  134. package/dist/orchestration/media-buffer.js +73 -0
  135. package/dist/orchestration/media-buffer.js.map +1 -0
  136. package/dist/orchestration/queries.d.ts +10 -0
  137. package/dist/orchestration/queries.d.ts.map +1 -0
  138. package/dist/orchestration/queries.js +40 -0
  139. package/dist/orchestration/queries.js.map +1 -0
  140. package/dist/orchestration/references.d.ts +16 -0
  141. package/dist/orchestration/references.d.ts.map +1 -0
  142. package/dist/orchestration/references.js +76 -0
  143. package/dist/orchestration/references.js.map +1 -0
  144. package/dist/orchestration/renewal-state.d.ts +58 -0
  145. package/dist/orchestration/renewal-state.d.ts.map +1 -0
  146. package/dist/orchestration/renewal-state.js +60 -0
  147. package/dist/orchestration/renewal-state.js.map +1 -0
  148. package/dist/orchestration/renewal.d.ts +76 -0
  149. package/dist/orchestration/renewal.d.ts.map +1 -0
  150. package/dist/orchestration/renewal.js +633 -0
  151. package/dist/orchestration/renewal.js.map +1 -0
  152. package/dist/orchestration/request.d.ts +53 -0
  153. package/dist/orchestration/request.d.ts.map +1 -0
  154. package/dist/orchestration/request.js +122 -0
  155. package/dist/orchestration/request.js.map +1 -0
  156. package/dist/orchestration/routing.d.ts +21 -0
  157. package/dist/orchestration/routing.d.ts.map +1 -0
  158. package/dist/orchestration/routing.js +90 -0
  159. package/dist/orchestration/routing.js.map +1 -0
  160. package/dist/orchestration/source-slot.d.ts +99 -0
  161. package/dist/orchestration/source-slot.d.ts.map +1 -0
  162. package/dist/orchestration/source-slot.js +206 -0
  163. package/dist/orchestration/source-slot.js.map +1 -0
  164. package/dist/orchestration/types.d.ts +334 -0
  165. package/dist/orchestration/types.d.ts.map +1 -0
  166. package/dist/orchestration/types.js +11 -0
  167. package/dist/orchestration/types.js.map +1 -0
  168. package/dist/protobuf.d.ts +63 -0
  169. package/dist/protobuf.d.ts.map +1 -0
  170. package/dist/protobuf.js +252 -0
  171. package/dist/protobuf.js.map +1 -0
  172. package/dist/session/_internal/acquire.d.ts +23 -0
  173. package/dist/session/_internal/acquire.d.ts.map +1 -0
  174. package/dist/session/_internal/acquire.js +167 -0
  175. package/dist/session/_internal/acquire.js.map +1 -0
  176. package/dist/session/_internal/cleanup.d.ts +18 -0
  177. package/dist/session/_internal/cleanup.d.ts.map +1 -0
  178. package/dist/session/_internal/cleanup.js +94 -0
  179. package/dist/session/_internal/cleanup.js.map +1 -0
  180. package/dist/session/_internal/lifecycle.d.ts +62 -0
  181. package/dist/session/_internal/lifecycle.d.ts.map +1 -0
  182. package/dist/session/_internal/lifecycle.js +132 -0
  183. package/dist/session/_internal/lifecycle.js.map +1 -0
  184. package/dist/session/_internal/remote.d.ts +28 -0
  185. package/dist/session/_internal/remote.d.ts.map +1 -0
  186. package/dist/session/_internal/remote.js +61 -0
  187. package/dist/session/_internal/remote.js.map +1 -0
  188. package/dist/session/_internal/uploads.d.ts +4 -0
  189. package/dist/session/_internal/uploads.d.ts.map +1 -0
  190. package/dist/session/_internal/uploads.js +33 -0
  191. package/dist/session/_internal/uploads.js.map +1 -0
  192. package/dist/session/commands.d.ts +22 -0
  193. package/dist/session/commands.d.ts.map +1 -0
  194. package/dist/session/commands.js +13 -0
  195. package/dist/session/commands.js.map +1 -0
  196. package/dist/session/files.d.ts +15 -0
  197. package/dist/session/files.d.ts.map +1 -0
  198. package/dist/session/files.js +54 -0
  199. package/dist/session/files.js.map +1 -0
  200. package/dist/session/index.d.ts +76 -0
  201. package/dist/session/index.d.ts.map +1 -0
  202. package/dist/session/index.js +16 -0
  203. package/dist/session/index.js.map +1 -0
  204. package/dist/session/media.d.ts +67 -0
  205. package/dist/session/media.d.ts.map +1 -0
  206. package/dist/session/media.js +2 -0
  207. package/dist/session/media.js.map +1 -0
  208. package/dist/session.d.ts +104 -0
  209. package/dist/session.d.ts.map +1 -0
  210. package/dist/session.js +872 -0
  211. package/dist/session.js.map +1 -0
  212. package/dist/simulation/_internal/source.d.ts +12 -0
  213. package/dist/simulation/_internal/source.d.ts.map +1 -0
  214. package/dist/simulation/_internal/source.js +477 -0
  215. package/dist/simulation/_internal/source.js.map +1 -0
  216. package/dist/simulation/index.d.ts +14 -0
  217. package/dist/simulation/index.d.ts.map +1 -0
  218. package/dist/simulation/index.js +13 -0
  219. package/dist/simulation/index.js.map +1 -0
  220. package/dist/simulation/types.d.ts +29 -0
  221. package/dist/simulation/types.d.ts.map +1 -0
  222. package/dist/simulation/types.js +2 -0
  223. package/dist/simulation/types.js.map +1 -0
  224. package/dist/stats.d.ts +33 -0
  225. package/dist/stats.d.ts.map +1 -0
  226. package/dist/stats.js +134 -0
  227. package/dist/stats.js.map +1 -0
  228. package/dist/testing/Faults.d.ts +4 -0
  229. package/dist/testing/Faults.d.ts.map +1 -0
  230. package/dist/testing/Faults.js +7 -0
  231. package/dist/testing/Faults.js.map +1 -0
  232. package/dist/testing/Png.d.ts +3 -0
  233. package/dist/testing/Png.d.ts.map +1 -0
  234. package/dist/testing/Png.js +68 -0
  235. package/dist/testing/Png.js.map +1 -0
  236. package/dist/testing/index.d.ts +3 -0
  237. package/dist/testing/index.d.ts.map +1 -0
  238. package/dist/testing/index.js +3 -0
  239. package/dist/testing/index.js.map +1 -0
  240. package/dist/wire.d.ts +7 -0
  241. package/dist/wire.d.ts.map +1 -0
  242. package/dist/wire.generated.d.ts +305 -0
  243. package/dist/wire.generated.d.ts.map +1 -0
  244. package/dist/wire.generated.js +1257 -0
  245. package/dist/wire.generated.js.map +1 -0
  246. package/dist/wire.js +5 -0
  247. package/dist/wire.js.map +1 -0
  248. package/notices/effect-LICENSE +21 -0
  249. package/notices/google-protobuf-LICENSE +32 -0
  250. package/notices/owned-webrtc/Effect-MIT.txt +21 -0
  251. package/notices/owned-webrtc/IETF.txt +43 -0
  252. package/notices/owned-webrtc/LICENSE +21 -0
  253. package/notices/owned-webrtc/UPSTREAM.md +20 -0
  254. package/notices/owned-webrtc/VP8-ADAPTATION.md +32 -0
  255. package/notices/owned-webrtc/VP8-AUTHORS.txt +42 -0
  256. package/notices/owned-webrtc/VP8-LICENSE.txt +25 -0
  257. package/notices/owned-webrtc/VP8-PATENTS.txt +21 -0
  258. package/notices/owned-webrtc/Werift-MIT.txt +21 -0
  259. package/notices/owned-webrtc/libvpx-v1.12.0-LICENSE.txt +28 -0
  260. package/notices/owned-webrtc/libvpx-v1.12.0-PATENTS.txt +22 -0
  261. package/notices/owned-webrtc/rfc3711.txt +3139 -0
  262. package/notices/owned-webrtc/str0m-MIT.txt +7 -0
  263. package/notices/owned-webrtc-LICENSE +21 -0
  264. package/notices/reactor-runtime-LICENSE +201 -0
  265. package/notices/reactor-runtime-NOTICE +5 -0
  266. package/notices/reactor-sdk-LICENSE +201 -0
  267. package/package.json +62 -4
@@ -0,0 +1,170 @@
1
+ import { Clock, Effect, Redacted, Schema } from "effect";
2
+ import { positiveLimit, ReactorError } from "../../errors.js";
3
+ const failure = (operation, message, cause) => new ReactorError("Protocol", message, {
4
+ operation,
5
+ outcome: "replied",
6
+ ...(cause === undefined ? {} : { detail: cause }),
7
+ });
8
+ const PositiveInteger = Schema.Number.check(Schema.isFinite(), Schema.isInt(), Schema.isGreaterThan(0));
9
+ const Pricing = Schema.Struct({
10
+ settings: Schema.Struct({
11
+ currency_code: Schema.Literal("USD"),
12
+ credits_per_dollar: PositiveInteger,
13
+ }),
14
+ models: Schema.Array(Schema.Struct({
15
+ name: Schema.String,
16
+ rate: Schema.Struct({
17
+ amount_per_sec: Schema.Number,
18
+ unit: Schema.String,
19
+ denomination: Schema.String,
20
+ }),
21
+ })),
22
+ });
23
+ /** Preserve the integer ratio; callers decide whether the returned price fits their budget. */
24
+ export const modelRate = (value, model) => Effect.try({
25
+ try: () => {
26
+ const decoded = Schema.decodeUnknownSync(Pricing)(value);
27
+ const matches = decoded.models.filter((entry) => entry.name === model);
28
+ const rate = matches[0]?.rate;
29
+ if (matches.length !== 1 ||
30
+ rate?.unit !== "credits" ||
31
+ rate.denomination !== "second" ||
32
+ !Number.isSafeInteger(rate.amount_per_sec) ||
33
+ rate.amount_per_sec <= 0 ||
34
+ !Number.isSafeInteger(decoded.settings.credits_per_dollar))
35
+ throw failure("pricing", "Reactor pricing has an unknown model, currency or rate unit");
36
+ return {
37
+ creditsPerDollar: decoded.settings.credits_per_dollar,
38
+ creditsPerSecond: rate.amount_per_sec,
39
+ };
40
+ },
41
+ catch: (cause) => cause instanceof ReactorError
42
+ ? cause
43
+ : failure("pricing", "Reactor pricing has an unknown model, currency or rate unit", cause),
44
+ });
45
+ export const validateTokenOptions = (input) => Effect.try({
46
+ try: () => {
47
+ const options = {
48
+ apiKey: input.apiKey,
49
+ modelName: input.modelName,
50
+ maxSessionDurationSeconds: input.maxSessionDurationSeconds,
51
+ expiresAfterSeconds: input.expiresAfterSeconds,
52
+ };
53
+ if (!Redacted.isRedacted(options.apiKey) ||
54
+ Redacted.value(options.apiKey).length === 0 ||
55
+ typeof options.modelName !== "string" ||
56
+ options.modelName.length === 0 ||
57
+ options.expiresAfterSeconds <= options.maxSessionDurationSeconds + 30)
58
+ throw new Error("Invalid bounded grant input");
59
+ positiveLimit(options.maxSessionDurationSeconds, "session duration", 86_400);
60
+ positiveLimit(options.expiresAfterSeconds, "token expiry", Number.MAX_SAFE_INTEGER);
61
+ return Object.freeze(options);
62
+ },
63
+ catch: () => new ReactorError("InvalidInput", "A bounded session needs a model, redacted key, positive duration, and token expiry allowing cleanup", { operation: "token", outcome: "not-submitted" }),
64
+ });
65
+ const Token = Schema.Struct({
66
+ jwt: Schema.NonEmptyString,
67
+ expires_at: Schema.Number.check(Schema.isFinite()),
68
+ });
69
+ const TokenClaims = Schema.StringFromBase64Url.pipe(Schema.decodeTo(Schema.fromJsonString(Schema.Struct({ authorization_details: Schema.Unknown }))));
70
+ const SessionAuthorization = Schema.Tuple([
71
+ Schema.Struct({
72
+ type: Schema.Literal("session"),
73
+ resources: Schema.Struct({
74
+ models: Schema.Struct({ match: Schema.Tuple([Schema.NonEmptyString]) }),
75
+ }),
76
+ constraints: Schema.Struct({
77
+ max_sessions: Schema.Literal(1),
78
+ max_session_duration_seconds: PositiveInteger,
79
+ }),
80
+ }),
81
+ ]);
82
+ export const decodeToken = (raw) => Schema.decodeUnknownEffect(Token)(raw).pipe(Effect.mapError((cause) => failure("token", "Reactor returned an invalid token response", cause)));
83
+ /** Validate the issuer's returned authority; token expiry alone never caps a remote session. */
84
+ export const grantedLimits = (jwt, options) => Effect.gen(function* () {
85
+ const payload = /^[A-Za-z0-9_-]+\.([A-Za-z0-9_-]+)\.[A-Za-z0-9_-]+$/.exec(jwt)?.[1];
86
+ const claims = yield* Schema.decodeUnknownEffect(TokenClaims)(payload);
87
+ const [authorization] = yield* Schema.decodeUnknownEffect(SessionAuthorization, {
88
+ onExcessProperty: "error",
89
+ })(claims.authorization_details);
90
+ const seconds = authorization.constraints.max_session_duration_seconds;
91
+ if (authorization.resources.models.match[0] !== options.modelName ||
92
+ seconds > options.maxSessionDurationSeconds)
93
+ return yield* Effect.fail(failure("token", "Reactor returned a token outside the requested session grant"));
94
+ return { maxSessions: authorization.constraints.max_sessions, maxSessionSeconds: seconds };
95
+ }).pipe(Effect.mapError(() => failure("token", "Reactor returned an invalid or unbounded session grant")));
96
+ const Transport = Schema.Struct({
97
+ protocol: Schema.NonEmptyString,
98
+ version: Schema.NonEmptyString,
99
+ });
100
+ export const Inspection = Schema.Struct({
101
+ observedAt: Schema.Number,
102
+ state: Schema.String,
103
+ hasCapabilities: Schema.Boolean,
104
+ selectedTransport: Schema.NullOr(Transport),
105
+ cluster: Schema.NullOr(Schema.String),
106
+ zone: Schema.NullOr(Schema.String),
107
+ serverVersion: Schema.NullOr(Schema.String),
108
+ additional: Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.Number, Schema.Boolean, Schema.Null])),
109
+ });
110
+ const OptionalText = Schema.optionalKey(Schema.NullOr(Schema.String));
111
+ const modeledFields = new Set([
112
+ "session_id",
113
+ "state",
114
+ "capabilities",
115
+ "selected_transport",
116
+ "cluster",
117
+ "zone",
118
+ "server_info",
119
+ ]);
120
+ const sensitiveField = /secret|token|credential|password|key|jwt|url|auth/i;
121
+ const additionalFacts = (raw) => {
122
+ const facts = [];
123
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw))
124
+ return {};
125
+ for (const [key, value] of Object.entries(raw).slice(0, 64)) {
126
+ if (modeledFields.has(key) || sensitiveField.test(key))
127
+ continue;
128
+ if (value === null || typeof value === "number" || typeof value === "boolean")
129
+ facts.push([key, value]);
130
+ else if (typeof value === "string")
131
+ facts.push([key, value.slice(0, 200)]);
132
+ }
133
+ return Object.fromEntries(facts);
134
+ };
135
+ // Inspection needs coordinator facts, even when connection capabilities are
136
+ // only partially published. Allocation/readiness uses the stricter Descriptor.
137
+ const SessionDescription = Schema.Struct({
138
+ session_id: Schema.NonEmptyString,
139
+ state: Schema.NonEmptyString,
140
+ capabilities: Schema.optionalKey(Schema.NullOr(Schema.JsonObject)),
141
+ selected_transport: Schema.optionalKey(Schema.NullOr(Transport)),
142
+ cluster: OptionalText,
143
+ zone: OptionalText,
144
+ server_info: Schema.optionalKey(Schema.NullOr(Schema.Struct({ server_version: Schema.String }))),
145
+ });
146
+ export const decodeInspection = (raw, sessionId) => Effect.gen(function* () {
147
+ const value = yield* Schema.decodeUnknownEffect(SessionDescription)(raw).pipe(Effect.mapError((cause) => failure("inspect", "Reactor returned an invalid session description", cause)));
148
+ if (value.session_id !== sessionId)
149
+ return yield* Effect.fail(failure("inspect", "Reactor returned a different session identity"));
150
+ return {
151
+ observedAt: yield* Clock.currentTimeMillis,
152
+ state: value.state,
153
+ hasCapabilities: value.capabilities != null,
154
+ selectedTransport: value.selected_transport ?? null,
155
+ cluster: value.cluster ?? null,
156
+ zone: value.zone ?? null,
157
+ serverVersion: value.server_info?.server_version ?? null,
158
+ additional: additionalFacts(raw),
159
+ };
160
+ });
161
+ // A termination probe promises state, not a complete connectable descriptor.
162
+ // When it includes identity, that identity must match the requested session.
163
+ const TerminalState = Schema.Struct({
164
+ session_id: Schema.optionalKey(Schema.NonEmptyString),
165
+ state: Schema.NonEmptyString,
166
+ });
167
+ export const decodeTermination = (raw, sessionId) => Schema.decodeUnknownEffect(TerminalState)(raw).pipe(Effect.mapError((cause) => failure("terminate", "Reactor returned an invalid termination description", cause)), Effect.flatMap((value) => value.session_id !== undefined && value.session_id !== sessionId
168
+ ? Effect.fail(failure("terminate", "Reactor returned a different session identity"))
169
+ : Effect.succeed(value)));
170
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/coordinator/_internal/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE9D,MAAM,OAAO,GAAG,CAAC,SAAiB,EAAE,OAAe,EAAE,KAAe,EAAE,EAAE,CACtE,IAAI,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE;IACpC,SAAS;IACT,OAAO,EAAE,SAAS;IAClB,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;CAClD,CAAC,CAAC;AACL,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CACzC,MAAM,CAAC,QAAQ,EAAE,EACjB,MAAM,CAAC,KAAK,EAAE,EACd,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CACxB,CAAC;AACF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AAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CACxB,OAAO,CAAC,WAAW,EAAE,qDAAqD,EAAE,KAAK,CAAC,CACnF,EACD,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CACvB,KAAK,CAAC,UAAU,KAAK,SAAS,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS;IAC9D,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,+CAA+C,CAAC,CAAC;IACpF,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAC1B,CACF,CAAC"}
@@ -0,0 +1,28 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Redacted from "effect/Redacted";
3
+ import * as Http from "effect/unstable/http/HttpClient";
4
+ import { ReactorError } from "../errors.js";
5
+ import type { Json } from "../json.js";
6
+ import type { HttpOptions, Termination } from "./_internal/client.js";
7
+ import type { Inspection, TokenGrant, TokenOptions } from "./_internal/schemas.js";
8
+ export { Inspection, modelRate } from "./_internal/schemas.js";
9
+ export type { TokenGrant, TokenOptions } from "./_internal/schemas.js";
10
+ export type { Termination, Poll } from "./_internal/client.js";
11
+ export type { Capabilities, Descriptor, Track, Mapping, IceCandidate, IceServer, } from "../contract.js";
12
+ export interface Configuration extends Omit<HttpOptions, "apiUrl" | "credential"> {
13
+ readonly apiUrl?: string;
14
+ /** Evaluated for each authenticated request, including a supervisor's confirmation GET. */
15
+ readonly credential?: Effect.Effect<Redacted.Redacted<string>, ReactorError>;
16
+ }
17
+ /** Coordinator operations share configuration and the supplied Effect HTTP client. */
18
+ export interface Client {
19
+ readonly apiUrl: string;
20
+ readonly pricing: () => Effect.Effect<Json, ReactorError>;
21
+ readonly mintToken: (options: TokenOptions) => Effect.Effect<TokenGrant, ReactorError>;
22
+ readonly inspect: (sessionId: string) => Effect.Effect<Inspection, ReactorError>;
23
+ /** Uncertainty is retained in the report; supervisors choose their own failure policy. */
24
+ readonly terminate: (sessionId: string) => Effect.Effect<Termination>;
25
+ }
26
+ /** No network request or remote allocation occurs while constructing a coordinator client. */
27
+ export declare const make: (configuration?: Configuration) => Effect.Effect<Client, ReactorError, Http.HttpClient>;
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/coordinator/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,iCAAiC,CAAC;AACxD,OAAO,EAAW,YAAY,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACvE,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC/D,YAAY,EACV,YAAY,EACZ,UAAU,EACV,KAAK,EACL,OAAO,EACP,YAAY,EACZ,SAAS,GACV,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,YAAY,CAAC;IAC/E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,2FAA2F;IAC3F,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC;CAC9E;AAED,sFAAsF;AACtF,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC1D,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACvF,QAAQ,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACjF,0FAA0F;IAC1F,QAAQ,CAAC,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;CACvE;AAED,8FAA8F;AAC9F,eAAO,MAAM,IAAI,mBACA,aAAa,KAC3B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,CAAC,UAAU,CAgCnD,CAAC"}
@@ -0,0 +1,25 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Redacted from "effect/Redacted";
3
+ import * as Http from "effect/unstable/http/HttpClient";
4
+ import { errorOf, ReactorError } from "../errors.js";
5
+ import { CoordinatorClient } from "./_internal/client.js";
6
+ export { Inspection, modelRate } from "./_internal/schemas.js";
7
+ /** No network request or remote allocation occurs while constructing a coordinator client. */
8
+ export const make = (configuration = {}) => Effect.flatMap(Http.HttpClient, (http) => Effect.try({
9
+ try: () => new CoordinatorClient({
10
+ ...configuration,
11
+ apiUrl: configuration.apiUrl ?? "https://api.reactor.inc",
12
+ credential: configuration.credential === undefined
13
+ ? Effect.succeed(undefined)
14
+ : configuration.credential.pipe(Effect.flatMap((credential) => Effect.try({
15
+ try: () => {
16
+ if (!Redacted.isRedacted(credential))
17
+ throw new ReactorError("InvalidInput", "Coordinator credential must be Redacted", { outcome: "not-submitted" });
18
+ return Redacted.value(credential);
19
+ },
20
+ catch: errorOf,
21
+ }))),
22
+ }, http),
23
+ catch: errorOf,
24
+ }));
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/coordinator/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,iCAAiC,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI1D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AA4B/D,8FAA8F;AAC9F,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,aAAa,GAAkB,EAAE,EACqB,EAAE,CACxD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CACvC,MAAM,CAAC,GAAG,CAAC;IACT,GAAG,EAAE,GAAG,EAAE,CACR,IAAI,iBAAiB,CACnB;QACE,GAAG,aAAa;QAChB,MAAM,EAAE,aAAa,CAAC,MAAM,IAAI,yBAAyB;QACzD,UAAU,EACR,aAAa,CAAC,UAAU,KAAK,SAAS;YACpC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;YAC3B,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,CAC3B,MAAM,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAC5B,MAAM,CAAC,GAAG,CAAC;gBACT,GAAG,EAAE,GAAG,EAAE;oBACR,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC;wBAClC,MAAM,IAAI,YAAY,CACpB,cAAc,EACd,yCAAyC,EACzC,EAAE,OAAO,EAAE,eAAe,EAAE,CAC7B,CAAC;oBACJ,OAAO,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBACpC,CAAC;gBACD,KAAK,EAAE,OAAO;aACf,CAAC,CACH,CACF;KACR,EACD,IAAI,CACL;IACH,KAAK,EAAE,OAAO;CACf,CAAC,CACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Deferred from "effect/Deferred";
3
+ import { ReactorError } from "./errors.js";
4
+ export interface Pending<A> {
5
+ readonly id: string;
6
+ readonly generation: bigint;
7
+ readonly operation: string;
8
+ readonly deferred: Deferred.Deferred<A, ReactorError>;
9
+ submitted: boolean;
10
+ waiting: boolean;
11
+ }
12
+ export type Correlation = "matched" | "late" | "duplicate" | "unsolicited" | "late-or-unknown" | "stale-generation";
13
+ /** Synchronous register-before-send, separate from bounded best-effort observations. */
14
+ export declare class Correlator<A> {
15
+ readonly prefix: "data" | "ctrl";
16
+ readonly limit: number;
17
+ readonly namespace: string;
18
+ private counter;
19
+ private readonly pending;
20
+ private readonly recent;
21
+ constructor(prefix: "data" | "ctrl", limit?: number, namespace?: string);
22
+ get size(): number;
23
+ has(pending: Pending<A>): boolean;
24
+ register(generation: bigint, operation: string): Pending<A>;
25
+ private remember;
26
+ settle(id: string, generation: bigint, result: Effect.Effect<A, ReactorError>): Correlation;
27
+ /** Resolve attribution before publishing a result or waking its caller. */
28
+ settleWith(id: string, generation: bigint, result: (correlation: Correlation) => Effect.Effect<A, ReactorError>, stage?: "acknowledged" | "replied"): Correlation;
29
+ cancel(pending: Pending<A>): boolean;
30
+ failGeneration(generation: bigint, failure: ReactorError): void;
31
+ }
32
+ //# sourceMappingURL=correlation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correlation.d.ts","sourceRoot":"","sources":["../src/correlation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAiB,Y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ACV,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,EACpE,KAAK,GAAE,cAAc,GAAG,SAAqB,GAC5C,WAAW,CAgCb;IACD,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAKnC;IACD,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAkB9D;CACF"}
@@ -0,0 +1,113 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Deferred from "effect/Deferred";
3
+ import { positiveLimit, ReactorError } from "./errors.js";
4
+ /** Synchronous register-before-send, separate from bounded best-effort observations. */
5
+ export class Correlator {
6
+ prefix;
7
+ limit;
8
+ namespace;
9
+ counter = 0n;
10
+ pending = new Map();
11
+ recent = new Map();
12
+ constructor(prefix, limit = 128, namespace = "") {
13
+ this.prefix = prefix;
14
+ this.limit = limit;
15
+ this.namespace = namespace;
16
+ positiveLimit(limit, "pending request limit", 4096);
17
+ }
18
+ get size() {
19
+ return this.pending.size;
20
+ }
21
+ has(pending) {
22
+ return this.pending.get(pending.id) === pending;
23
+ }
24
+ register(generation, operation) {
25
+ if (this.pending.size >= this.limit)
26
+ throw new ReactorError("Overflow", "pending request bound reached", {
27
+ operation,
28
+ outcome: "not-submitted",
29
+ });
30
+ if (this.counter === 0xffffffffffffffffn)
31
+ throw new ReactorError("Overflow", "request identity space exhausted");
32
+ const id = `${this.prefix}_${this.namespace ? `${this.namespace}_` : ""}${++this.counter}`;
33
+ const pending = {
34
+ id,
35
+ generation,
36
+ operation,
37
+ deferred: Deferred.makeUnsafe(),
38
+ submitted: false,
39
+ waiting: true,
40
+ };
41
+ this.pending.set(id, pending);
42
+ return pending;
43
+ }
44
+ remember(id, generation, completion) {
45
+ this.recent.set(id, { generation, completion });
46
+ if (this.recent.size > 256) {
47
+ const first = this.recent.keys().next();
48
+ if (!first.done)
49
+ this.recent.delete(first.value);
50
+ }
51
+ }
52
+ settle(id, generation, result) {
53
+ return this.settleWith(id, generation, () => result);
54
+ }
55
+ /** Resolve attribution before publishing a result or waking its caller. */
56
+ settleWith(id, generation, result, stage = "replied") {
57
+ const pending = this.pending.get(id);
58
+ const recent = this.recent.get(id);
59
+ const correlation = id === ""
60
+ ? "unsolicited"
61
+ : pending !== undefined
62
+ ? pending.generation !== generation
63
+ ? "stale-generation"
64
+ : pending.waiting
65
+ ? "matched"
66
+ : "late"
67
+ : recent === undefined
68
+ ? "late-or-unknown"
69
+ : recent.generation !== generation
70
+ ? "stale-generation"
71
+ : recent.completion === "acknowledged" && stage === "replied"
72
+ ? "late"
73
+ : recent.completion === "cancelled"
74
+ ? "late-or-unknown"
75
+ : "duplicate";
76
+ const matched = pending !== undefined && (correlation === "matched" || correlation === "late");
77
+ if (matched) {
78
+ this.pending.delete(id);
79
+ this.remember(id, generation, stage);
80
+ }
81
+ else if (correlation === "late" && recent?.completion === "acknowledged") {
82
+ // A transport ACK and a later model payload are two different facts.
83
+ this.remember(id, generation, "replied");
84
+ }
85
+ const completion = result(correlation);
86
+ if (matched)
87
+ Deferred.doneUnsafe(pending.deferred, completion);
88
+ return correlation;
89
+ }
90
+ cancel(pending) {
91
+ if (this.pending.get(pending.id) !== pending)
92
+ return false;
93
+ this.pending.delete(pending.id);
94
+ this.remember(pending.id, pending.generation, "cancelled");
95
+ return true;
96
+ }
97
+ failGeneration(generation, failure) {
98
+ for (const pending of this.pending.values()) {
99
+ if (pending.generation !== generation)
100
+ continue;
101
+ this.pending.delete(pending.id);
102
+ this.remember(pending.id, generation, "cancelled");
103
+ Deferred.doneUnsafe(pending.deferred, Effect.fail(new ReactorError(failure.code, failure.message, {
104
+ ...failure.context,
105
+ operation: pending.operation,
106
+ requestId: pending.id,
107
+ generation,
108
+ outcome: pending.submitted ? "unknown" : "not-submitted",
109
+ })));
110
+ }
111
+ }
112
+ }
113
+ //# sourceMappingUR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AAM,CAAC,OAAmB;QACxB,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,OAAO;YAAE,OAAO,KAAK,CAAC;QAC3D,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAChC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IACD,cAAc,CAAC,UAAkB,EAAE,OAAqB;QACtD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YAC5C,IAAI,OAAO,CAAC,UAAU,KAAK,UAAU;gBAAE,SAAS;YAChD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAChC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;YACnD,QAAQ,CAAC,UAAU,CACjB,OAAO,CAAC,QAAQ,EAChB,MAAM,CAAC,IAAI,CACT,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE;gBAC9C,GAAG,OAAO,CAAC,OAAO;gBAClB,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,SAAS,EAAE,OAAO,CAAC,EAAE;gBACrB,UAAU;gBACV,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe;aACzD,CAAC,CACH,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,88 @@
1
+ import * as Schema from "effect/Schema";
2
+ export declare const ErrorCode: Schema.Literals<readonly ["InvalidInput", "Protocol", "Http", "VersionMismatch", "UnsupportedHost", "UnsupportedCapability", "InvalidState", "TerminalSession", "Timeout", "Disconnected", "Aborted", "Overflow", "Remote", "UnexpectedReply", "Upload", "RecorderDisabled", "Native", "Closed", "AlreadyReading", "Shutdown"]>;
3
+ export type ErrorCode = typeof ErrorCode.Type;
4
+ export type RemoteOutcome = "not-submitted" | "unknown" | "replied";
5
+ export declare const ProviderFailure: Schema.Struct<{
6
+ readonly code: Schema.String;
7
+ readonly message: Schema.String;
8
+ readonly recoverable: Schema.Boolean;
9
+ readonly operation: Schema.optionalKey<Schema.String>;
10
+ readonly status: Schema.optionalKey<Schema.Number>;
11
+ readonly retryAfterMs: Schema.optionalKey<Schema.Number>;
12
+ }>;
13
+ export type ProviderFailure = typeof ProviderFailure.Type;
14
+ export declare const ErrorContext: Schema.Struct<{
15
+ readonly operation: Schema.optionalKey<Schema.String>;
16
+ readonly requestId: Schema.optionalKey<Schema.String>;
17
+ readonly sessionId: Schema.optionalKey<Schema.String>;
18
+ readonly generation: Schema.optionalKey<Schema.BigInt>;
19
+ readonly outcome: Schema.optionalKey<Schema.Literals<readonly ["not-submitted", "unknown", "replied"]>>;
20
+ readonly status: Schema.optionalKey<Schema.Number>;
21
+ readonly retryAfterMs: Schema.optionalKey<Schema.Number>;
22
+ readonly remoteCode: Schema.optionalKey<Schema.String>;
23
+ /** Explicit inspection only. Diagnostic serialization excludes response bodies and causes. */
24
+ readonly body: Schema.optionalKey<Schema.String>;
25
+ readonly detail: Schema.optionalKey<Schema.Unknown>;
26
+ }>;
27
+ export type ErrorContext = typeof ErrorContext.Type;
28
+ interface Fields {
29
+ readonly code: ErrorCode;
30
+ readonly message: string;
31
+ readonly context?: ErrorContext;
32
+ readonly nativeError?: ProviderFailure;
33
+ }
34
+ declare const ReactorError_base: Schema.Class<ReactorError, Schema.TaggedStruct<"ReactorError", {
35
+ readonly code: Schema.Literals<readonly ["InvalidInput", "Protocol", "Http", "VersionMismatch", "UnsupportedHost", "UnsupportedCapability", "InvalidState", "TerminalSession", "Timeout", "Disconnected", "Aborted", "Overflow", "Remote", "UnexpectedReply", "Upload", "RecorderDisabled", "Native", "Closed", "AlreadyReading", "Shutdown"]>;
36
+ readonly message: Schema.String;
37
+ readonly context: Schema.Struct<{
38
+ readonly operation: Schema.optionalKey<Schema.String>;
39
+ readonly requestId: Schema.optionalKey<Schema.String>;
40
+ readonly sessionId: Schema.optionalKey<Schema.String>;
41
+ readonly generation: Schema.optionalKey<Schema.BigInt>;
42
+ readonly outcome: Schema.optionalKey<Schema.Literals<readonly ["not-submitted", "unknown", "replied"]>>;
43
+ readonly status: Schema.optionalKey<Schema.Number>;
44
+ readonly retryAfterMs: Schema.optionalKey<Schema.Number>;
45
+ readonly remoteCode: Schema.optionalKey<Schema.String>;
46
+ /** Explicit inspection only. Diagnostic serialization excludes response bodies and causes. */
47
+ readonly body: Schema.optionalKey<Schema.String>;
48
+ readonly detail: Schema.optionalKey<Schema.Unknown>;
49
+ }>;
50
+ readonly nativeError: Schema.optionalKey<Schema.Struct<{
51
+ readonly code: Schema.String;
52
+ readonly message: Schema.String;
53
+ readonly recoverable: Schema.Boolean;
54
+ readonly operation: Schema.optionalKey<Schema.String>;
55
+ readonly status: Schema.optionalKey<Schema.Number>;
56
+ readonly retryAfterMs: Schema.optionalKey<Schema.Number>;
57
+ }>>;
58
+ }>, import("effect/Cause").YieldableError>;
59
+ /** A failure category never implies a mutation was rolled back. Inspect context.outcome. */
60
+ export declare class ReactorError extends ReactorError_base {
61
+ constructor(fields: Fields);
62
+ constructor(code: ErrorCode, message: string, context?: ErrorContext);
63
+ toJSON(): {
64
+ _tag: "ReactorError";
65
+ code: "Aborted" | "AlreadyReading" | "Closed" | "Disconnected" | "Http" | "InvalidInput" | "InvalidState" | "Native" | "Overflow" | "Protocol" | "RecorderDisabled" | "Remote" | "Shutdown" | "TerminalSession" | "Timeout" | "UnexpectedReply" | "UnsupportedCapability" | "UnsupportedHost" | "Upload" | "VersionMismatch";
66
+ message: string;
67
+ context: {
68
+ operation?: string;
69
+ requestId?: string;
70
+ sessionId?: string;
71
+ outcome?: "not-submitted" | "replied" | "unknown";
72
+ status?: number;
73
+ retryAfterMs?: number;
74
+ remoteCode?: string;
75
+ generation?: string;
76
+ };
77
+ provider?: {
78
+ code: string;
79
+ operation: string | undefined;
80
+ status: number | undefined;
81
+ };
82
+ };
83
+ }
84
+ /** Keep the original cause for deliberate inspection without including it in the message. */
85
+ export declare const errorOf: (cause: unknown, code?: ErrorCode, operation?: string) => ReactorError;
86
+ export declare const positiveLimit: (value: number, name: string, maximum?: number) => number;
87
+ export {};
88
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,eAAO,MAAM,SAAS,iUAqBpB,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC;AAC9C,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,SAAS,GAAG,SAAS,CAAC;AAEpE,eAAO,MAAM,eAAe;;;;;;;EAO1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC;AAE1D,eAAO,MAAM,YAAY;;;;;;;;;IASvB,8FAA8F;;;EAG9F,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC;AAEpD,UAAU,MAAM;IACd,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC;CACxC;;;;;;;;;;;;;QAXC,8FAA8F;;;;;;;;;;;;;AAahG,4FAA4F;AAC5F,qBAAa,YAAa,SAAQ,iBAOhC;IACA,YAAY,MAAM,EAAE,MAAM,EAAE;IAC5B,YAAY,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE;IAM7D,MAAM;;;;;;;;;;;;;;;YAcH,IAAI;YACJ,SAAS;YACT,MAAM;;MAIjB;CACF;AAED,6FAA6F;AAC7F,eAAO,MAAM,OAAO,UACX,OAAO,SACR,SAAS,cACH,MAAM,KACjB,YAMK,CAAC;AAET,eAAO,MAAM,aAAa,UAAW,MAAM,QAAQ,MAAM,uBAAyB,MAOjF,CAAC"}
package/dist/errors.js ADDED
@@ -0,0 +1,93 @@
1
+ import * as Schema from "effect/Schema";
2
+ export const ErrorCode = Schema.Literals([
3
+ "InvalidInput",
4
+ "Protocol",
5
+ "Http",
6
+ "VersionMismatch",
7
+ "UnsupportedHost",
8
+ "UnsupportedCapability",
9
+ "InvalidState",
10
+ "TerminalSession",
11
+ "Timeout",
12
+ "Disconnected",
13
+ "Aborted",
14
+ "Overflow",
15
+ "Remote",
16
+ "UnexpectedReply",
17
+ "Upload",
18
+ "RecorderDisabled",
19
+ "Native",
20
+ "Closed",
21
+ "AlreadyReading",
22
+ "Shutdown",
23
+ ]);
24
+ export const ProviderFailure = Schema.Struct({
25
+ code: Schema.String,
26
+ message: Schema.String,
27
+ recoverable: Schema.Boolean,
28
+ operation: Schema.optionalKey(Schema.String),
29
+ status: Schema.optionalKey(Schema.Number),
30
+ retryAfterMs: Schema.optionalKey(Schema.Number),
31
+ });
32
+ export const ErrorContext = Schema.Struct({
33
+ operation: Schema.optionalKey(Schema.String),
34
+ requestId: Schema.optionalKey(Schema.String),
35
+ sessionId: Schema.optionalKey(Schema.String),
36
+ generation: Schema.optionalKey(Schema.BigInt),
37
+ outcome: Schema.optionalKey(Schema.Literals(["not-submitted", "unknown", "replied"])),
38
+ status: Schema.optionalKey(Schema.Number),
39
+ retryAfterMs: Schema.optionalKey(Schema.Number),
40
+ remoteCode: Schema.optionalKey(Schema.String),
41
+ /** Explicit inspection only. Diagnostic serialization excludes response bodies and causes. */
42
+ body: Schema.optionalKey(Schema.String),
43
+ detail: Schema.optionalKey(Schema.Unknown),
44
+ });
45
+ /** A failure category never implies a mutation was rolled back. Inspect context.outcome. */
46
+ export class ReactorError extends Schema.TaggedError("reactor-effect-client/ReactorError")("ReactorError", {
47
+ code: ErrorCode,
48
+ message: Schema.String,
49
+ context: ErrorContext,
50
+ nativeError: Schema.optionalKey(ProviderFailure),
51
+ }) {
52
+ constructor(code, message, context = {}) {
53
+ const fields = typeof code === "string" ? { code, message: message ?? code, context } : code;
54
+ super({ ...fields, context: fields.context ?? {} });
55
+ }
56
+ toJSON() {
57
+ const { body: _body, detail: _detail, generation, ...context } = this.context;
58
+ return {
59
+ _tag: this._tag,
60
+ code: this.code,
61
+ message: this.message,
62
+ context: {
63
+ ...context,
64
+ ...(generation === undefined ? {} : { generation: String(generation) }),
65
+ },
66
+ ...(this.nativeError === undefined
67
+ ? {}
68
+ : {
69
+ provider: {
70
+ code: this.nativeError.code,
71
+ operation: this.nativeError.operation,
72
+ status: this.nativeError.status,
73
+ },
74
+ }),
75
+ };
76
+ }
77
+ }
78
+ /** Keep the original cause for deliberate inspection without including it in the message. */
79
+ export const errorOf = (cause, code = "Protocol", operation) => cause instanceof ReactorError
80
+ ? cause
81
+ : new ReactorError(code, operation === undefined ? code : `${operation} failed`, {
82
+ ...(operation === undefined ? {} : { operation }),
83
+ detail: cause,
84
+ });
85
+ export const positiveLimit = (value, name, maximum = 0x7fffffff) => {
86
+ if (!Number.isSafeInteger(value) || value < 1 || value > maximum) {
87
+ throw new ReactorError("InvalidInput", `${name} must be an integer in 1..${maximum}`, {
88
+ outcome: "not-submitted",
89
+ });
90
+ }
91
+ return value;
92
+ };
93
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,C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
+ import * as Scope from "effect/Scope";
4
+ import { ReactorError } from "../../errors.js";
5
+ import type { Session } from "../../session/index.js";
6
+ import type { Options, Provider } from "../types.js";
7
+ /** Failed acquisition closes its local observation scope immediately. */
8
+ export declare const make: (session: Session, options?: Options) => Effect.Effect<Provider, ReactorError, Crypto.Crypto | Scope.Scope>;
9
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/h3/_internal/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,EAA0B,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGvE,OAAO,KAAK,EAAgB,OAAO,EAAgB,MAAM,wBAAwB,CAAC;AAMlF,OAAO,KAAK,EAGV,OAAO,EAEP,QAAQ,EAGT,MAAM,aAAa,CAAC;AA6uBrB,yEAAyE;AACzE,eAAO,MAAM,IAAI,YACN,OAAO,YACP,OAAO,KACf,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAOhE,CAAC"}