reactor-effect-client 0.2.0 → 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.
- package/README.md +66 -6
- package/dist/FetchHttp.js +1 -1
- package/dist/FetchHttp.js.map +1 -1
- package/dist/PeerFactory.d.ts +13 -2
- package/dist/PeerFactory.d.ts.map +1 -1
- package/dist/PeerFactory.js.map +1 -1
- package/dist/PeerTypes.d.ts +2 -2
- package/dist/PeerTypes.d.ts.map +1 -1
- package/dist/Sequence.d.ts +18 -14
- package/dist/Sequence.d.ts.map +1 -1
- package/dist/Sequence.js +117 -122
- package/dist/Sequence.js.map +1 -1
- package/dist/SessionTypes.d.ts +172 -15
- package/dist/SessionTypes.d.ts.map +1 -1
- package/dist/SessionTypes.js +18 -1
- package/dist/SessionTypes.js.map +1 -1
- package/dist/bytes.js +3 -3
- package/dist/bytes.js.map +1 -1
- package/dist/contract.d.ts +120 -29
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +105 -73
- package/dist/contract.js.map +1 -1
- package/dist/coordinator/_internal/client.d.ts +111 -17
- package/dist/coordinator/_internal/client.d.ts.map +1 -1
- package/dist/coordinator/_internal/client.js +187 -74
- package/dist/coordinator/_internal/client.js.map +1 -1
- package/dist/coordinator/_internal/recording.d.ts +33 -0
- package/dist/coordinator/_internal/recording.d.ts.map +1 -0
- package/dist/coordinator/_internal/recording.js +123 -0
- package/dist/coordinator/_internal/recording.js.map +1 -0
- package/dist/coordinator/_internal/response.d.ts.map +1 -1
- package/dist/coordinator/_internal/response.js +5 -7
- package/dist/coordinator/_internal/response.js.map +1 -1
- package/dist/coordinator/_internal/schemas.d.ts +40 -6
- package/dist/coordinator/_internal/schemas.d.ts.map +1 -1
- package/dist/coordinator/_internal/schemas.js +94 -64
- package/dist/coordinator/_internal/schemas.js.map +1 -1
- package/dist/coordinator/index.d.ts +14 -2
- package/dist/coordinator/index.d.ts.map +1 -1
- package/dist/coordinator/index.js +14 -18
- package/dist/coordinator/index.js.map +1 -1
- package/dist/correlation.d.ts +15 -0
- package/dist/correlation.d.ts.map +1 -1
- package/dist/correlation.js +26 -8
- package/dist/correlation.js.map +1 -1
- package/dist/duration.d.ts +25 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/duration.js +47 -0
- package/dist/duration.js.map +1 -0
- package/dist/errors.d.ts +1264 -49
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +698 -46
- package/dist/errors.js.map +1 -1
- package/dist/h3/_internal/client.d.ts +2 -2
- package/dist/h3/_internal/client.d.ts.map +1 -1
- package/dist/h3/_internal/client.js +280 -146
- package/dist/h3/_internal/client.js.map +1 -1
- package/dist/h3/_internal/contracts.d.ts.map +1 -1
- package/dist/h3/_internal/contracts.js +2 -2
- package/dist/h3/_internal/contracts.js.map +1 -1
- package/dist/h3/_internal/deployment.d.ts.map +1 -1
- package/dist/h3/_internal/deployment.js +5 -4
- package/dist/h3/_internal/deployment.js.map +1 -1
- package/dist/h3/_internal/evidence.js +1 -1
- package/dist/h3/_internal/evidence.js.map +1 -1
- package/dist/h3/_internal/operations.d.ts +58 -0
- package/dist/h3/_internal/operations.d.ts.map +1 -0
- package/dist/h3/_internal/operations.js +268 -0
- package/dist/h3/_internal/operations.js.map +1 -0
- package/dist/h3/_internal/references.d.ts.map +1 -1
- package/dist/h3/_internal/references.js +3 -8
- package/dist/h3/_internal/references.js.map +1 -1
- package/dist/h3/_internal/request.js +1 -1
- package/dist/h3/_internal/request.js.map +1 -1
- package/dist/h3/_internal/retained.d.ts +22 -0
- package/dist/h3/_internal/retained.d.ts.map +1 -0
- package/dist/h3/_internal/retained.js +89 -0
- package/dist/h3/_internal/retained.js.map +1 -0
- package/dist/h3/_internal/state.d.ts +15 -1
- package/dist/h3/_internal/state.d.ts.map +1 -1
- package/dist/h3/_internal/state.js +69 -29
- package/dist/h3/_internal/state.js.map +1 -1
- package/dist/h3/index.d.ts +1 -1
- package/dist/h3/index.d.ts.map +1 -1
- package/dist/h3/messages.d.ts +118 -109
- package/dist/h3/messages.d.ts.map +1 -1
- package/dist/h3/messages.js +73 -51
- package/dist/h3/messages.js.map +1 -1
- package/dist/h3/types.d.ts +109 -13
- package/dist/h3/types.d.ts.map +1 -1
- package/dist/host.d.ts +6 -6
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +4 -5
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +11 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/json.d.ts +13 -6
- package/dist/json.d.ts.map +1 -1
- package/dist/json.js +34 -14
- package/dist/json.js.map +1 -1
- package/dist/media-stream.d.ts.map +1 -1
- package/dist/media-stream.js +9 -11
- package/dist/media-stream.js.map +1 -1
- package/dist/observation.d.ts +9 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +20 -18
- package/dist/observation.js.map +1 -1
- package/dist/orchestration/h3-source.d.ts +32 -4
- package/dist/orchestration/h3-source.d.ts.map +1 -1
- package/dist/orchestration/h3-source.js +47 -14
- package/dist/orchestration/h3-source.js.map +1 -1
- package/dist/orchestration/index.d.ts +9 -6
- package/dist/orchestration/index.d.ts.map +1 -1
- package/dist/orchestration/index.js +5 -3
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/media-buffer.d.ts +12 -4
- package/dist/orchestration/media-buffer.d.ts.map +1 -1
- package/dist/orchestration/media-buffer.js +31 -11
- package/dist/orchestration/media-buffer.js.map +1 -1
- package/dist/orchestration/open-h3.d.ts +65 -0
- package/dist/orchestration/open-h3.d.ts.map +1 -0
- package/dist/orchestration/open-h3.js +65 -0
- package/dist/orchestration/open-h3.js.map +1 -0
- package/dist/orchestration/references.d.ts +5 -1
- package/dist/orchestration/references.d.ts.map +1 -1
- package/dist/orchestration/references.js +37 -34
- package/dist/orchestration/references.js.map +1 -1
- package/dist/orchestration/renewal-state.js +1 -1
- package/dist/orchestration/renewal-state.js.map +1 -1
- package/dist/orchestration/renewal.d.ts +64 -64
- package/dist/orchestration/renewal.d.ts.map +1 -1
- package/dist/orchestration/renewal.js +149 -88
- package/dist/orchestration/renewal.js.map +1 -1
- package/dist/orchestration/request.d.ts +11 -12
- package/dist/orchestration/request.d.ts.map +1 -1
- package/dist/orchestration/request.js +63 -66
- package/dist/orchestration/request.js.map +1 -1
- package/dist/orchestration/routing.d.ts.map +1 -1
- package/dist/orchestration/routing.js +17 -14
- package/dist/orchestration/routing.js.map +1 -1
- package/dist/orchestration/source-slot.d.ts +15 -5
- package/dist/orchestration/source-slot.d.ts.map +1 -1
- package/dist/orchestration/source-slot.js +40 -21
- package/dist/orchestration/source-slot.js.map +1 -1
- package/dist/orchestration/types.d.ts +594 -39
- package/dist/orchestration/types.d.ts.map +1 -1
- package/dist/orchestration/types.js +20 -0
- package/dist/orchestration/types.js.map +1 -1
- package/dist/protobuf.js +2 -2
- package/dist/protobuf.js.map +1 -1
- package/dist/session/_internal/acquire.d.ts +4 -6
- package/dist/session/_internal/acquire.d.ts.map +1 -1
- package/dist/session/_internal/acquire.js +40 -50
- package/dist/session/_internal/acquire.js.map +1 -1
- package/dist/session/_internal/cleanup.d.ts +2 -1
- package/dist/session/_internal/cleanup.d.ts.map +1 -1
- package/dist/session/_internal/cleanup.js +23 -15
- package/dist/session/_internal/cleanup.js.map +1 -1
- package/dist/session/_internal/lifecycle.d.ts +5 -0
- package/dist/session/_internal/lifecycle.d.ts.map +1 -1
- package/dist/session/_internal/lifecycle.js +16 -6
- package/dist/session/_internal/lifecycle.js.map +1 -1
- package/dist/session/_internal/remote.d.ts.map +1 -1
- package/dist/session/_internal/remote.js +16 -7
- package/dist/session/_internal/remote.js.map +1 -1
- package/dist/session/_internal/uploads.d.ts +4 -1
- package/dist/session/_internal/uploads.d.ts.map +1 -1
- package/dist/session/_internal/uploads.js +25 -27
- package/dist/session/_internal/uploads.js.map +1 -1
- package/dist/session/commands.d.ts +1 -21
- package/dist/session/commands.d.ts.map +1 -1
- package/dist/session/commands.js +1 -12
- package/dist/session/commands.js.map +1 -1
- package/dist/session/files.d.ts +10 -2
- package/dist/session/files.d.ts.map +1 -1
- package/dist/session/files.js +11 -16
- package/dist/session/files.js.map +1 -1
- package/dist/session/index.d.ts +6 -6
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js.map +1 -1
- package/dist/session/media.d.ts +53 -6
- package/dist/session/media.d.ts.map +1 -1
- package/dist/session/recorder.d.ts +24 -0
- package/dist/session/recorder.d.ts.map +1 -0
- package/dist/session/recorder.js +19 -0
- package/dist/session/recorder.js.map +1 -0
- package/dist/session.d.ts +5 -4
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +213 -110
- package/dist/session.js.map +1 -1
- package/dist/simulation/_internal/source.d.ts.map +1 -1
- package/dist/simulation/_internal/source.js +57 -48
- package/dist/simulation/_internal/source.js.map +1 -1
- package/dist/simulation/index.d.ts +4 -5
- package/dist/simulation/index.d.ts.map +1 -1
- package/dist/simulation/index.js +3 -4
- package/dist/simulation/index.js.map +1 -1
- package/dist/simulation/types.d.ts +16 -2
- package/dist/simulation/types.d.ts.map +1 -1
- package/dist/stats.d.ts +19 -0
- package/dist/stats.d.ts.map +1 -1
- package/dist/stats.js +79 -8
- package/dist/stats.js.map +1 -1
- package/package.json +5 -4
- package/notices/owned-webrtc/Effect-MIT.txt +0 -21
- package/notices/owned-webrtc/IETF.txt +0 -43
- package/notices/owned-webrtc/LICENSE +0 -21
- package/notices/owned-webrtc/UPSTREAM.md +0 -20
- package/notices/owned-webrtc/VP8-ADAPTATION.md +0 -32
- package/notices/owned-webrtc/VP8-AUTHORS.txt +0 -42
- package/notices/owned-webrtc/VP8-LICENSE.txt +0 -25
- package/notices/owned-webrtc/VP8-PATENTS.txt +0 -21
- package/notices/owned-webrtc/Werift-MIT.txt +0 -21
- package/notices/owned-webrtc/libvpx-v1.12.0-LICENSE.txt +0 -28
- package/notices/owned-webrtc/libvpx-v1.12.0-PATENTS.txt +0 -22
- package/notices/owned-webrtc/rfc3711.txt +0 -3139
- package/notices/owned-webrtc/str0m-MIT.txt +0 -7
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { terminal } from "../../contract.js";
|
|
3
|
+
import { duration } from "../../duration.js";
|
|
4
|
+
import { ReactorError, parsed, positiveLimit } from "../../errors.js";
|
|
5
|
+
import { retryAfterMs } from "./response.js";
|
|
6
|
+
const pure = (body) => parsed(body);
|
|
7
|
+
export const parsePlaylist = (text, baseUrl, maxSegments = 1024) => {
|
|
8
|
+
positiveLimit(maxSegments, "clip segments", 16_384);
|
|
9
|
+
if (text.trimStart().split(/\r?\n/, 1)[0]?.trim() !== "#EXTM3U")
|
|
10
|
+
throw ReactorError.fromCode("Protocol", "not an HLS playlist");
|
|
11
|
+
let init;
|
|
12
|
+
const media = [];
|
|
13
|
+
for (const line of text
|
|
14
|
+
.split(/\r?\n/)
|
|
15
|
+
.map((s) => s.trim())
|
|
16
|
+
.filter(Boolean)) {
|
|
17
|
+
if (/^#EXT-X-(STREAM-INF|I-FRAME-STREAM-INF|BYTERANGE|DISCONTINUITY|PART|PRELOAD-HINT|SKIP|GAP|SESSION-KEY|DEFINE)(:|$)/.test(line))
|
|
18
|
+
throw ReactorError.fromCode("UnsupportedCapability", "master, byte-range, discontinuous, encrypted, gap, variable, or low-latency playlists require an HLS player, not byte concatenation");
|
|
19
|
+
if (line.startsWith("#EXT-X-KEY:") && !/(?:^|,)METHOD=NONE(?:,|$)/.test(line.slice(11)))
|
|
20
|
+
throw ReactorError.fromCode("UnsupportedCapability", "encrypted clips are not assembled by this client");
|
|
21
|
+
if (line.startsWith("#EXT-X-MAP:")) {
|
|
22
|
+
if (line.includes("BYTERANGE="))
|
|
23
|
+
throw ReactorError.fromCode("UnsupportedCapability", "byte-range init segments unsupported");
|
|
24
|
+
const match = /(?:^|,)URI="([^"]+)"/.exec(line.slice(11)), uri = match?.[1];
|
|
25
|
+
if (uri === undefined || (init !== undefined && init !== uri))
|
|
26
|
+
throw ReactorError.fromCode("Protocol", "missing or changing HLS init URI");
|
|
27
|
+
init = uri;
|
|
28
|
+
}
|
|
29
|
+
else if (!line.startsWith("#")) {
|
|
30
|
+
if (media.length >= maxSegments)
|
|
31
|
+
throw ReactorError.fromCode("Overflow", "clip segment count bound exceeded");
|
|
32
|
+
media.push(line);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (media.length === 0)
|
|
36
|
+
throw ReactorError.fromCode("Protocol", "empty clip playlist");
|
|
37
|
+
// The URL constructor rejects a malformed playlist URI with a TypeError.
|
|
38
|
+
const parseUrl = (uri) => {
|
|
39
|
+
try {
|
|
40
|
+
return new URL(uri, baseUrl);
|
|
41
|
+
}
|
|
42
|
+
catch (cause) {
|
|
43
|
+
throw ReactorError.fromCode("Protocol", "invalid clip URL", { detail: cause });
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const resolve = (uri) => {
|
|
47
|
+
const url = parseUrl(uri);
|
|
48
|
+
if (!(url.protocol === "http:" || url.protocol === "https:") || url.username || url.password)
|
|
49
|
+
throw ReactorError.fromCode("Protocol", "clip URL must use http(s) with no embedded credentials");
|
|
50
|
+
return url.href;
|
|
51
|
+
};
|
|
52
|
+
if (init === undefined &&
|
|
53
|
+
media.some((uri) => /\.(?:m4s|mp4|m4a|m4v)$/i.test(parseUrl(uri).pathname)))
|
|
54
|
+
throw ReactorError.fromCode("Protocol", "fragmented MP4 playlist lacks EXT-X-MAP init segment");
|
|
55
|
+
const segments = init === undefined ? [] : [{ kind: "init", url: resolve(init) }];
|
|
56
|
+
for (const uri of media)
|
|
57
|
+
segments.push({ kind: "media", url: resolve(uri) });
|
|
58
|
+
return Object.freeze(segments.map((s) => Object.freeze(s)));
|
|
59
|
+
};
|
|
60
|
+
/** Bounded transport of a prepared recording. Does not decode, play, or assert further generation.
|
|
61
|
+
* This API intentionally uses a caller wall deadline, not an unbounded wait based on a prediction. */
|
|
62
|
+
export const downloadClip = (http, clip, options = {}) => Effect.suspend(() => {
|
|
63
|
+
const action = Effect.gen(function* () {
|
|
64
|
+
const bounds = yield* pure(() => ({
|
|
65
|
+
timeout: duration(options.downloadTimeout ?? "60 seconds", "clip download timeout", {
|
|
66
|
+
maximum: "10 minutes",
|
|
67
|
+
}),
|
|
68
|
+
manifest: positiveLimit(options.maxManifestBytes ?? 262_144, "manifest bytes", 2_097_152),
|
|
69
|
+
segment: positiveLimit(options.maxSegmentBytes ?? 16_777_216, "segment bytes", 64 * 1024 * 1024),
|
|
70
|
+
total: positiveLimit(options.maxTotalBytes ?? 64 * 1024 * 1024, "clip bytes", 64 * 1024 * 1024),
|
|
71
|
+
count: positiveLimit(options.maxSegments ?? 1024, "clip segments", 16_384),
|
|
72
|
+
}));
|
|
73
|
+
const fetchAndAssemble = Effect.gen(function* () {
|
|
74
|
+
let segments;
|
|
75
|
+
while (true) {
|
|
76
|
+
const response = yield* http.request({
|
|
77
|
+
operation: "clip playlist",
|
|
78
|
+
url: clip.playlist_url,
|
|
79
|
+
auth: "same-origin",
|
|
80
|
+
maxBytes: bounds.manifest,
|
|
81
|
+
});
|
|
82
|
+
if (response.status !== 202) {
|
|
83
|
+
segments = yield* pure(() => parsePlaylist(new TextDecoder("utf-8", { fatal: true }).decode(response.bytes), clip.playlist_url, bounds.count));
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
// A local peer disconnection does not prove stopped inference. Query the remote descriptor.
|
|
87
|
+
const descriptor = yield* http.read(clip.session_id);
|
|
88
|
+
if (terminal(descriptor.state))
|
|
89
|
+
return yield* ReactorError.fromCode("TerminalSession", "session terminated before playlist became available");
|
|
90
|
+
yield* Effect.sleep(Math.max(200, Math.min(retryAfterMs(response.headers) ?? 2000, 2000)));
|
|
91
|
+
}
|
|
92
|
+
let size = 0;
|
|
93
|
+
const chunks = [];
|
|
94
|
+
for (const segment of segments) {
|
|
95
|
+
const response = yield* http.request({
|
|
96
|
+
operation: "clip segment",
|
|
97
|
+
url: segment.url,
|
|
98
|
+
auth: "same-origin",
|
|
99
|
+
maxBytes: Math.min(bounds.segment, bounds.total - size || 1),
|
|
100
|
+
});
|
|
101
|
+
if (response.status === 202)
|
|
102
|
+
return yield* ReactorError.fromCode("Protocol", "playlist referenced a segment that is not ready");
|
|
103
|
+
size += response.bytes.length;
|
|
104
|
+
if (size > bounds.total)
|
|
105
|
+
return yield* ReactorError.fromCode("Overflow", "assembled clip byte bound exceeded");
|
|
106
|
+
chunks.push(response.bytes);
|
|
107
|
+
}
|
|
108
|
+
const bytes = new Uint8Array(size);
|
|
109
|
+
let at = 0;
|
|
110
|
+
for (const chunk of chunks) {
|
|
111
|
+
bytes.set(chunk, at);
|
|
112
|
+
at += chunk.length;
|
|
113
|
+
}
|
|
114
|
+
return { bytes, segments };
|
|
115
|
+
});
|
|
116
|
+
return yield* fetchAndAssemble.pipe(Effect.timeoutOrElse({
|
|
117
|
+
duration: bounds.timeout,
|
|
118
|
+
orElse: () => Effect.fail(ReactorError.fromCode("Timeout", "clip download deadline; remote generation outcome unchanged")),
|
|
119
|
+
}));
|
|
120
|
+
});
|
|
121
|
+
return action;
|
|
122
|
+
});
|
|
123
|
+
//# sourceMappingURL=recording.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recording.js","sourceRoot":"","sources":["../../../src/coordinator/_internal/recording.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGtE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAwB7C,MAAM,IAAI,GAAG,CAAI,IAAa,EAAkC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAChF,MAAM,CAAC,MAAM,aAAa,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MAAM,EAAE,CAAC;gBAC3B,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACrB,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC;YACrB,CAAC;YACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,OAAO,KAAK,CAAC,CAAC,gBAAgB,CAAC,IAAI,CACjC,MAAM,CAAC,aAAa,CAAC;YACnB,QAAQ,EAAE,MAAM,CAAC,OAAO;YACxB,MAAM,EAAE,GAAG,EAAE,CACX,MAAM,CAAC,IAAI,CACT,YAAY,CAAC,QAAQ,CACnB,SAAS,EACT,6DAA6D,CAC9D,CACF;SACJ,CAAC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../src/coordinator/_internal/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,eAAe,MAAM,sCAAsC,CAAC;AACxE,OAAO,KAAK,KAAK,kBAAkB,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;CACzC;AAED,uFAAuF;AACvF,eAAO,MAAM,QAAQ,aACT,kBAAkB,CAAC,kBAAkB,aACpC,MAAM,YACP,MAAM,aACL,MAAM,
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../src/coordinator/_internal/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,eAAe,MAAM,sCAAsC,CAAC;AACxE,OAAO,KAAK,KAAK,kBAAkB,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;CACzC;AAED,uFAAuF;AACvF,eAAO,MAAM,QAAQ,aACT,kBAAkB,CAAC,kBAAkB,aACpC,MAAM,YACP,MAAM,aACL,MAAM,kGAoCf,CAAC;AAEL,iFAAiF;AACjF,eAAO,MAAM,eAAe,UAAW,SAAS,cAAc,MAAM,KAAG,OAoBtE,CAAC;AAEF,eAAO,MAAM,YAAY,YAAa,OAAO,KAAG,MAAM,GAAG,SAOxD,CAAC"}
|
|
@@ -11,15 +11,13 @@ export const readBody = (response, operation, maxBytes, maxChunks) => Effect.gen
|
|
|
11
11
|
size += chunk.byteLength;
|
|
12
12
|
count++;
|
|
13
13
|
if (size > maxBytes || count > maxChunks)
|
|
14
|
-
return yield*
|
|
14
|
+
return yield* ReactorError.fromCode("Overflow", `${operation} response exceeds its ${maxBytes} byte/${maxChunks} chunk bound`, { operation, outcome: "replied", detail: { status: response.status } });
|
|
15
15
|
// A supplied HTTP implementation may reuse its transport buffer.
|
|
16
16
|
if (chunk.byteLength !== 0)
|
|
17
17
|
chunks.push(new Uint8Array(chunk));
|
|
18
|
-
})), Effect.
|
|
18
|
+
})), Effect.catchIf((error) => count === 0 &&
|
|
19
19
|
HttpClientError.isHttpClientError(error) &&
|
|
20
|
-
error.reason._tag === "EmptyBodyError"
|
|
21
|
-
? Effect.void
|
|
22
|
-
: Effect.fail(error)));
|
|
20
|
+
error.reason._tag === "EmptyBodyError", () => Effect.void));
|
|
23
21
|
const bytes = new Uint8Array(size);
|
|
24
22
|
let offset = 0;
|
|
25
23
|
for (const chunk of chunks) {
|
|
@@ -35,10 +33,10 @@ export const decodeJsonReply = (reply, operation) => {
|
|
|
35
33
|
return result;
|
|
36
34
|
}
|
|
37
35
|
catch (cause) {
|
|
38
|
-
|
|
36
|
+
// The SyntaxError quotes the body, so it stays in the inspection-only detail.
|
|
37
|
+
throw ReactorError.fromCode("Protocol", operation === undefined
|
|
39
38
|
? "invalid UTF-8/JSON HTTP response"
|
|
40
39
|
: `Reactor ${operation} request or response failed`, {
|
|
41
|
-
status: reply.status,
|
|
42
40
|
...(operation === undefined ? {} : { operation }),
|
|
43
41
|
outcome: "replied",
|
|
44
42
|
detail: cause,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../src/coordinator/_internal/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,eAAe,MAAM,sCAAsC,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQ/C,uFAAuF;AACvF,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,QAA+C,EAC/C,SAAiB,EACjB,QAAgB,EAChB,SAAiB,EACjB,EAAE,CACF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,MAAM,GAA8B,EAAE,CAAC;IAC7C,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CACzB,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,EAAE,CAC1B,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClB,IAAI,IAAI,KAAK,CAAC,UAAU,CAAC;QACzB,KAAK,EAAE,CAAC;QACR,IAAI,IAAI,GAAG,QAA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,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAgB,EAAsB,EAAE;IACnE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACvC,IAAI,GAAG,KAAK,IAAI,IAAI,CAAC,iCAAiC,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IACnF,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;QAChF,CAAC,CAAC,OAAO,GAAG,IAAI;QAChB,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -1,11 +1,45 @@
|
|
|
1
|
-
import { Effect, Redacted, Schema } from "effect";
|
|
1
|
+
import { Duration, Effect, Redacted, Schema } from "effect";
|
|
2
2
|
import { ReactorError } from "../../errors.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* The rate of `model`, given by its connect slug (or its bare name), in
|
|
5
|
+
* credits per second: exactly as stated for a per-second rate, and a
|
|
6
|
+
* per-minute rate divided by 60. Callers decide whether the price fits their
|
|
7
|
+
* budget, and how the time they are billed rounds: Reactor's documentation
|
|
8
|
+
* bills by the session-minute.
|
|
9
|
+
*/
|
|
4
10
|
export declare const modelRate: (value: unknown, model: string) => Effect.Effect<{
|
|
5
11
|
creditsPerDollar: number;
|
|
6
12
|
creditsPerSecond: number;
|
|
7
13
|
}, ReactorError, never>;
|
|
8
14
|
export interface TokenOptions {
|
|
15
|
+
readonly apiKey: Redacted.Redacted<string>;
|
|
16
|
+
readonly modelName: string;
|
|
17
|
+
/**
|
|
18
|
+
* The longest session the token may start, a whole number of seconds up to
|
|
19
|
+
* one day. A bare number is milliseconds.
|
|
20
|
+
*/
|
|
21
|
+
readonly maxSessionDuration: Duration.Input;
|
|
22
|
+
/**
|
|
23
|
+
* How long the token stays valid, a whole number of seconds more than 30
|
|
24
|
+
* seconds past `maxSessionDuration`, so cleanup still holds a valid token. A
|
|
25
|
+
* bare number is milliseconds.
|
|
26
|
+
*/
|
|
27
|
+
readonly expiresAfter: Duration.Input;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Removed in 0.3.0: use `maxSessionDuration` (a bare number is
|
|
30
|
+
* milliseconds, so `maxSessionDurationSeconds: 60` becomes
|
|
31
|
+
* `maxSessionDuration: "60 seconds"`).
|
|
32
|
+
*/
|
|
33
|
+
readonly maxSessionDurationSeconds?: never;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Removed in 0.3.0: use `expiresAfter` (a bare number is
|
|
36
|
+
* milliseconds, so `expiresAfterSeconds: 300` becomes
|
|
37
|
+
* `expiresAfter: "300 seconds"`).
|
|
38
|
+
*/
|
|
39
|
+
readonly expiresAfterSeconds?: never;
|
|
40
|
+
}
|
|
41
|
+
/** Token options after validation, in the wire's whole seconds. */
|
|
42
|
+
export interface TokenRequest {
|
|
9
43
|
readonly apiKey: Redacted.Redacted<string>;
|
|
10
44
|
readonly modelName: string;
|
|
11
45
|
readonly maxSessionDurationSeconds: number;
|
|
@@ -19,18 +53,18 @@ export interface TokenGrant {
|
|
|
19
53
|
readonly maxSessionSeconds: number;
|
|
20
54
|
};
|
|
21
55
|
}
|
|
22
|
-
export declare const validateTokenOptions: (input: TokenOptions) => Effect.Effect<
|
|
56
|
+
export declare const validateTokenOptions: (input: TokenOptions) => Effect.Effect<TokenRequest, ReactorError>;
|
|
23
57
|
export declare const decodeToken: (raw: unknown) => Effect.Effect<{
|
|
24
58
|
readonly jwt: string;
|
|
25
59
|
readonly expires_at: number;
|
|
26
60
|
}, ReactorError, never>;
|
|
27
61
|
/** Validate the issuer's returned authority; token expiry alone never caps a remote session. */
|
|
28
|
-
export declare const grantedLimits: (jwt: string, options:
|
|
62
|
+
export declare const grantedLimits: (jwt: string, options: TokenRequest) => Effect.Effect<{
|
|
29
63
|
maxSessions: 1;
|
|
30
64
|
maxSessionSeconds: number;
|
|
31
65
|
}, ReactorError, never>;
|
|
32
66
|
export declare const Inspection: Schema.Struct<{
|
|
33
|
-
readonly observedAt: Schema.
|
|
67
|
+
readonly observedAt: Schema.Finite;
|
|
34
68
|
readonly state: Schema.String;
|
|
35
69
|
readonly hasCapabilities: Schema.Boolean;
|
|
36
70
|
readonly selectedTransport: Schema.NullOr<Schema.Struct<{
|
|
@@ -40,7 +74,7 @@ export declare const Inspection: Schema.Struct<{
|
|
|
40
74
|
readonly cluster: Schema.NullOr<Schema.String>;
|
|
41
75
|
readonly zone: Schema.NullOr<Schema.String>;
|
|
42
76
|
readonly serverVersion: Schema.NullOr<Schema.String>;
|
|
43
|
-
readonly additional: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.
|
|
77
|
+
readonly additional: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.Null]>>;
|
|
44
78
|
}>;
|
|
45
79
|
export type Inspection = typeof Inspection.Type;
|
|
46
80
|
export declare const decodeInspection: (raw: unknown, sessionId: string) => Effect.Effect<Inspection, ReactorError>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/coordinator/_internal/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/coordinator/_internal/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE3E,OAAO,EAAsB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAoDnE;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,UAAW,OAAO,SAAS,MAAM;;;uBAiBpD,CAAC;AAEJ,MA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;;;;EAYrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC;AAqChD,eAAO,MAAM,gBAAgB,QACtB,OAAO,aACD,MAAM,KAChB,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,CAmBrC,CAAC;AAQL,eAAO,MAAM,iBAAiB,QAAS,OAAO,aAAa,MAAM;;;uBAS9D,CAAC"}
|
|
@@ -1,70 +1,102 @@
|
|
|
1
|
-
import { Clock, Effect, Redacted, Schema } from "effect";
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { Clock, Duration, Effect, Redacted, Result, Schema } from "effect";
|
|
2
|
+
import { duration } from "../../duration.js";
|
|
3
|
+
import { parse, parsedInput, ReactorError } from "../../errors.js";
|
|
4
|
+
const failure = (operation, message, cause) => ReactorError.fromCode("Protocol", message, {
|
|
4
5
|
operation,
|
|
5
6
|
outcome: "replied",
|
|
6
7
|
...(cause === undefined ? {} : { detail: cause }),
|
|
7
8
|
});
|
|
8
|
-
const PositiveInteger = Schema.
|
|
9
|
+
const PositiveInteger = Schema.Int.check(Schema.isGreaterThan(0));
|
|
10
|
+
/**
|
|
11
|
+
* Only the settings are read strictly. The catalog is shared by every model,
|
|
12
|
+
* so an entry in a shape this client does not price never stops it pricing
|
|
13
|
+
* the model it was asked for; an absent catalog is empty, as Reactor's
|
|
14
|
+
* pricing documentation says. Credits are sold per US dollar, so a stated
|
|
15
|
+
* currency must be that one.
|
|
16
|
+
*/
|
|
9
17
|
const Pricing = Schema.Struct({
|
|
10
18
|
settings: Schema.Struct({
|
|
11
|
-
currency_code: Schema.Literal("USD"),
|
|
19
|
+
currency_code: Schema.optional(Schema.Literal("USD")),
|
|
12
20
|
credits_per_dollar: PositiveInteger,
|
|
13
21
|
}),
|
|
14
|
-
models: Schema.Array(Schema.
|
|
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" }),
|
|
22
|
+
models: Schema.optional(Schema.Array(Schema.Unknown)),
|
|
64
23
|
});
|
|
24
|
+
const isEntry = Schema.is(Schema.Struct({ name: Schema.String, rate: Schema.Unknown }));
|
|
25
|
+
const unknownRate = (cause) => failure("pricing", "Reactor pricing has an unknown model, currency or rate unit", cause);
|
|
26
|
+
/**
|
|
27
|
+
* The rates this client prices: whole credits per second, as the live pricing
|
|
28
|
+
* document states them, or per minute, as its documentation does.
|
|
29
|
+
*/
|
|
30
|
+
const CreditsRate = Schema.Union([
|
|
31
|
+
Schema.Struct({
|
|
32
|
+
amount_per_sec: PositiveInteger,
|
|
33
|
+
unit: Schema.Literal("credits"),
|
|
34
|
+
denomination: Schema.Literal("second"),
|
|
35
|
+
}),
|
|
36
|
+
Schema.Struct({
|
|
37
|
+
amount_per_min: PositiveInteger,
|
|
38
|
+
unit: Schema.Literal("credits"),
|
|
39
|
+
denomination: Schema.Literal("minute"),
|
|
40
|
+
}),
|
|
41
|
+
]);
|
|
42
|
+
/**
|
|
43
|
+
* Pricing lists a model by its bare name, `h3-reference-to-video-turbo-realtime`,
|
|
44
|
+
* where sessions and tokens take its connect slug,
|
|
45
|
+
* `reactor/h3-reference-to-video-turbo-realtime`: the name after the owner.
|
|
46
|
+
*/
|
|
47
|
+
const pricedAs = (model) => model.slice(model.lastIndexOf("/") + 1);
|
|
48
|
+
/**
|
|
49
|
+
* The rate of `model`, given by its connect slug (or its bare name), in
|
|
50
|
+
* credits per second: exactly as stated for a per-second rate, and a
|
|
51
|
+
* per-minute rate divided by 60. Callers decide whether the price fits their
|
|
52
|
+
* budget, and how the time they are billed rounds: Reactor's documentation
|
|
53
|
+
* bills by the session-minute.
|
|
54
|
+
*/
|
|
55
|
+
export const modelRate = (value, model) => Schema.decodeUnknownEffect(Pricing)(value).pipe(Effect.flatMap((decoded) => {
|
|
56
|
+
const matches = (decoded.models ?? [])
|
|
57
|
+
.filter(isEntry)
|
|
58
|
+
.filter((entry) => entry.name === model || entry.name === pricedAs(model));
|
|
59
|
+
return Schema.decodeUnknownEffect(CreditsRate)(matches.length === 1 ? matches[0].rate : undefined).pipe(Effect.map((rate) => ({
|
|
60
|
+
creditsPerDollar: decoded.settings.credits_per_dollar,
|
|
61
|
+
creditsPerSecond: "amount_per_sec" in rate ? rate.amount_per_sec : rate.amount_per_min / 60,
|
|
62
|
+
})));
|
|
63
|
+
}), Effect.mapError(unknownRate));
|
|
64
|
+
const wholeSeconds = (value) => Math.round(Duration.toSeconds(value));
|
|
65
|
+
export const validateTokenOptions = (input) => parsedInput(() => {
|
|
66
|
+
const reject = () => {
|
|
67
|
+
throw ReactorError.fromCode("InvalidInput", "A bounded session needs a model, redacted key, positive duration, and token expiry allowing cleanup", { operation: "token", outcome: "not-submitted" });
|
|
68
|
+
};
|
|
69
|
+
if (input === null || typeof input !== "object")
|
|
70
|
+
return reject();
|
|
71
|
+
const bounded = parse(() => ({
|
|
72
|
+
maxSessionDurationSeconds: wholeSeconds(duration(input.maxSessionDuration, "session duration", {
|
|
73
|
+
maximum: "1 day",
|
|
74
|
+
wholeSeconds: true,
|
|
75
|
+
})),
|
|
76
|
+
// Whole milliseconds stay exact up to this bound, so the seconds do too.
|
|
77
|
+
expiresAfterSeconds: wholeSeconds(duration(input.expiresAfter, "token expiry", {
|
|
78
|
+
maximum: Duration.millis(Number.MAX_SAFE_INTEGER),
|
|
79
|
+
wholeSeconds: true,
|
|
80
|
+
})),
|
|
81
|
+
}));
|
|
82
|
+
if (Result.isFailure(bounded))
|
|
83
|
+
return reject();
|
|
84
|
+
const options = {
|
|
85
|
+
apiKey: input.apiKey,
|
|
86
|
+
modelName: input.modelName,
|
|
87
|
+
...bounded.success,
|
|
88
|
+
};
|
|
89
|
+
if (!Redacted.isRedacted(options.apiKey) ||
|
|
90
|
+
Redacted.value(options.apiKey).length === 0 ||
|
|
91
|
+
typeof options.modelName !== "string" ||
|
|
92
|
+
options.modelName.length === 0 ||
|
|
93
|
+
options.expiresAfterSeconds <= options.maxSessionDurationSeconds + 30)
|
|
94
|
+
return reject();
|
|
95
|
+
return Object.freeze(options);
|
|
96
|
+
}, "token");
|
|
65
97
|
const Token = Schema.Struct({
|
|
66
98
|
jwt: Schema.NonEmptyString,
|
|
67
|
-
expires_at: Schema.
|
|
99
|
+
expires_at: Schema.Finite,
|
|
68
100
|
});
|
|
69
101
|
const TokenClaims = Schema.StringFromBase64Url.pipe(Schema.decodeTo(Schema.fromJsonString(Schema.Struct({ authorization_details: Schema.Unknown }))));
|
|
70
102
|
const SessionAuthorization = Schema.Tuple([
|
|
@@ -90,22 +122,22 @@ export const grantedLimits = (jwt, options) => Effect.gen(function* () {
|
|
|
90
122
|
const seconds = authorization.constraints.max_session_duration_seconds;
|
|
91
123
|
if (authorization.resources.models.match[0] !== options.modelName ||
|
|
92
124
|
seconds > options.maxSessionDurationSeconds)
|
|
93
|
-
return yield*
|
|
125
|
+
return yield* failure("token", "Reactor returned a token outside the requested session grant");
|
|
94
126
|
return { maxSessions: authorization.constraints.max_sessions, maxSessionSeconds: seconds };
|
|
95
|
-
}).pipe(Effect.mapError(() => failure("token", "Reactor returned an invalid or unbounded session grant")));
|
|
127
|
+
}).pipe(Effect.mapError((cause) => failure("token", "Reactor returned an invalid or unbounded session grant", cause)));
|
|
96
128
|
const Transport = Schema.Struct({
|
|
97
129
|
protocol: Schema.NonEmptyString,
|
|
98
130
|
version: Schema.NonEmptyString,
|
|
99
131
|
});
|
|
100
132
|
export const Inspection = Schema.Struct({
|
|
101
|
-
observedAt: Schema.
|
|
133
|
+
observedAt: Schema.Finite,
|
|
102
134
|
state: Schema.String,
|
|
103
135
|
hasCapabilities: Schema.Boolean,
|
|
104
136
|
selectedTransport: Schema.NullOr(Transport),
|
|
105
137
|
cluster: Schema.NullOr(Schema.String),
|
|
106
138
|
zone: Schema.NullOr(Schema.String),
|
|
107
139
|
serverVersion: Schema.NullOr(Schema.String),
|
|
108
|
-
additional: Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.
|
|
140
|
+
additional: Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.Finite, Schema.Boolean, Schema.Null])),
|
|
109
141
|
});
|
|
110
142
|
const OptionalText = Schema.optionalKey(Schema.NullOr(Schema.String));
|
|
111
143
|
const modeledFields = new Set([
|
|
@@ -146,7 +178,7 @@ const SessionDescription = Schema.Struct({
|
|
|
146
178
|
export const decodeInspection = (raw, sessionId) => Effect.gen(function* () {
|
|
147
179
|
const value = yield* Schema.decodeUnknownEffect(SessionDescription)(raw).pipe(Effect.mapError((cause) => failure("inspect", "Reactor returned an invalid session description", cause)));
|
|
148
180
|
if (value.session_id !== sessionId)
|
|
149
|
-
return yield*
|
|
181
|
+
return yield* failure("inspect", "Reactor returned a different session identity");
|
|
150
182
|
return {
|
|
151
183
|
observedAt: yield* Clock.currentTimeMillis,
|
|
152
184
|
state: value.state,
|
|
@@ -164,7 +196,5 @@ const TerminalState = Schema.Struct({
|
|
|
164
196
|
session_id: Schema.optionalKey(Schema.NonEmptyString),
|
|
165
197
|
state: Schema.NonEmptyString,
|
|
166
198
|
});
|
|
167
|
-
export const decodeTermination = (raw, sessionId) => Schema.decodeUnknownEffect(TerminalState)(raw).pipe(Effect.mapError((cause) => failure("terminate", "Reactor returned an invalid termination description", cause)), Effect.
|
|
168
|
-
? Effect.fail(failure("terminate", "Reactor returned a different session identity"))
|
|
169
|
-
: Effect.succeed(value)));
|
|
199
|
+
export const decodeTermination = (raw, sessionId) => Schema.decodeUnknownEffect(TerminalState)(raw).pipe(Effect.mapError((cause) => failure("terminate", "Reactor returned an invalid termination description", cause)), Effect.filterOrFail((value) => value.session_id === undefined || value.session_id === sessionId, () => failure("terminate", "Reactor returned a different session identity")));
|
|
170
200
|
//# sourceMappingURL=schemas.js.map
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/coordinator/_internal/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEnE,MAAM,OAAO,GAAG,CAAC,SAAiB,EAAE,OAAe,EAAE,KAAe,EAAE,EAAE,CACtE,YAAY,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,EAAE;IACzC,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,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE;;;;;;GAMG;AACH,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC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,CACF,CAAC"}
|
|
@@ -5,9 +5,14 @@ import { ReactorError } from "../errors.js";
|
|
|
5
5
|
import type { Json } from "../json.js";
|
|
6
6
|
import type { HttpOptions, Termination } from "./_internal/client.js";
|
|
7
7
|
import type { Inspection, TokenGrant, TokenOptions } from "./_internal/schemas.js";
|
|
8
|
+
import type { DownloadedClip, DownloadOptions } from "./_internal/recording.js";
|
|
9
|
+
import type { ClipReady } from "../wire.generated.js";
|
|
8
10
|
export { Inspection, modelRate } from "./_internal/schemas.js";
|
|
9
11
|
export type { TokenGrant, TokenOptions } from "./_internal/schemas.js";
|
|
10
|
-
export
|
|
12
|
+
export { Termination } from "./_internal/client.js";
|
|
13
|
+
export type { Poll } from "./_internal/client.js";
|
|
14
|
+
export { parsePlaylist } from "./_internal/recording.js";
|
|
15
|
+
export type { DownloadedClip, DownloadOptions, Segment } from "./_internal/recording.js";
|
|
11
16
|
export type { Capabilities, Descriptor, Track, Mapping, IceCandidate, IceServer, } from "../contract.js";
|
|
12
17
|
export interface Configuration extends Omit<HttpOptions, "apiUrl" | "credential"> {
|
|
13
18
|
readonly apiUrl?: string;
|
|
@@ -17,11 +22,18 @@ export interface Configuration extends Omit<HttpOptions, "apiUrl" | "credential"
|
|
|
17
22
|
/** Coordinator operations share configuration and the supplied Effect HTTP client. */
|
|
18
23
|
export interface Client {
|
|
19
24
|
readonly apiUrl: string;
|
|
20
|
-
readonly pricing:
|
|
25
|
+
readonly pricing: Effect.Effect<Json, ReactorError>;
|
|
21
26
|
readonly mintToken: (options: TokenOptions) => Effect.Effect<TokenGrant, ReactorError>;
|
|
22
27
|
readonly inspect: (sessionId: string) => Effect.Effect<Inspection, ReactorError>;
|
|
23
28
|
/** Uncertainty is retained in the report; supervisors choose their own failure policy. */
|
|
24
29
|
readonly terminate: (sessionId: string) => Effect.Effect<Termination>;
|
|
30
|
+
/**
|
|
31
|
+
* Bounded transport of a prepared recording (`clip_ready`): polls its HLS
|
|
32
|
+
* playlist, then fetches and concatenates its segments within a caller wall
|
|
33
|
+
* deadline. It does not decode or play the clip, and a deadline does not
|
|
34
|
+
* change the remote generation outcome.
|
|
35
|
+
*/
|
|
36
|
+
readonly downloadClip: (clip: ClipReady, options?: DownloadOptions) => Effect.Effect<DownloadedClip, ReactorError>;
|
|
25
37
|
}
|
|
26
38
|
/** No network request or remote allocation occurs while constructing a coordinator client. */
|
|
27
39
|
export declare const make: (configuration?: Configuration) => Effect.Effect<Client, ReactorError, Http.HttpClient>;
|
|
@@ -1 +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,
|
|
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,EAAU,YAAY,EAAE,MAAM,cAAc,CAAC;AACpD,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;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EAAE,UAAU,EAAE,YA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AAO,CAAC,EAAE,eAAe,KACtB,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;CAClD;AAED,8FAA8F;AAC9F,eAAO,MAAM,IAAI,mBACA,aAAa,KAC3B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,CAAC,UAAU,CA4BnD,CAAC"}
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as Redacted from "effect/Redacted";
|
|
3
3
|
import * as Http from "effect/unstable/http/HttpClient";
|
|
4
|
-
import {
|
|
4
|
+
import { parsed, ReactorError } from "../errors.js";
|
|
5
5
|
import { CoordinatorClient } from "./_internal/client.js";
|
|
6
6
|
export { Inspection, modelRate } from "./_internal/schemas.js";
|
|
7
|
+
export { Termination } from "./_internal/client.js";
|
|
8
|
+
export { parsePlaylist } from "./_internal/recording.js";
|
|
7
9
|
/** No network request or remote allocation occurs while constructing a coordinator client. */
|
|
8
|
-
export const make = (configuration = {}) => Effect.flatMap(Http.HttpClient, (http) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
catch: errorOf,
|
|
21
|
-
}))),
|
|
22
|
-
}, http),
|
|
23
|
-
catch: errorOf,
|
|
24
|
-
}));
|
|
10
|
+
export const make = (configuration = {}) => Effect.flatMap(Http.HttpClient, (http) => parsed(() => new CoordinatorClient({
|
|
11
|
+
...configuration,
|
|
12
|
+
apiUrl: configuration.apiUrl ?? "https://api.reactor.inc",
|
|
13
|
+
credential: configuration.credential === undefined
|
|
14
|
+
? Effect.undefined
|
|
15
|
+
: configuration.credential.pipe(Effect.flatMap((credential) => parsed(() => {
|
|
16
|
+
if (!Redacted.isRedacted(credential))
|
|
17
|
+
throw ReactorError.fromCode("InvalidInput", "Coordinator credential must be Redacted", { outcome: "not-submitted" });
|
|
18
|
+
return Redacted.value(credential);
|
|
19
|
+
}))),
|
|
20
|
+
}, http)));
|
|
25
21
|
//# sourceMappingURL=index.js.map
|