tirtc-devtools-cli 0.0.1
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 +52 -0
- package/USAGE.md +417 -0
- package/bin/tirtc-devtool.js +2 -0
- package/dist/app-server/protocol-client/index.d.ts +25 -0
- package/dist/app-server/protocol-client/index.js +114 -0
- package/dist/devtools/cli/src/config.d.ts +46 -0
- package/dist/devtools/cli/src/config.js +98 -0
- package/dist/devtools/cli/src/dummy.d.ts +0 -0
- package/dist/devtools/cli/src/dummy.js +1 -0
- package/dist/devtools/cli/src/embedded_paths.d.ts +7 -0
- package/dist/devtools/cli/src/embedded_paths.js +85 -0
- package/dist/devtools/cli/src/facade.d.ts +723 -0
- package/dist/devtools/cli/src/facade.js +194 -0
- package/dist/devtools/cli/src/ffmpeg_tool.d.ts +6 -0
- package/dist/devtools/cli/src/ffmpeg_tool.js +146 -0
- package/dist/devtools/cli/src/guide.d.ts +1 -0
- package/dist/devtools/cli/src/guide.js +49 -0
- package/dist/devtools/cli/src/index.d.ts +1 -0
- package/dist/devtools/cli/src/index.js +753 -0
- package/dist/devtools/cli/src/media_assets.d.ts +25 -0
- package/dist/devtools/cli/src/media_assets.js +121 -0
- package/dist/devtools/cli/src/session_manager.d.ts +25 -0
- package/dist/devtools/cli/src/session_manager.js +393 -0
- package/dist/devtools/cli/src/token_tool.d.ts +33 -0
- package/dist/devtools/cli/src/token_tool.js +217 -0
- package/dist/devtools/cli/src/transport.d.ts +30 -0
- package/dist/devtools/cli/src/transport.js +84 -0
- package/dist/dummy.d.ts +0 -0
- package/dist/dummy.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +48 -0
- package/package.json +54 -0
- package/script/ensure_ffmpeg.sh +22 -0
- package/vendor/app-server/bin/native/macos-arm64/credential_napi.node +0 -0
- package/vendor/app-server/bin/native/macos-arm64/libcrypto.dylib +0 -0
- package/vendor/app-server/bin/native/macos-arm64/libssl.dylib +0 -0
- package/vendor/app-server/bin/native/macos-arm64/libtgrtc.dylib +0 -0
- package/vendor/app-server/bin/native/macos-arm64/runtime_host_napi.node +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_codec.h +23 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_frame.h +36 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io.h +56 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_android.h +19 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_apple.h +19 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_harmony.h +19 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_windows.h +19 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_processing.h +56 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_sample_rate.h +18 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/error.h +20 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/logging.h +53 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_codec.h +21 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_downlink.h +89 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_uplink.h +115 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/runtime.h +236 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_codec.h +57 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_frame.h +55 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io.h +46 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_android.h +32 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_apple.h +34 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_harmony.h +32 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_windows.h +26 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_processing.h +34 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_audio.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_facade.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_logging.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_media.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_video.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libwebrtc_apm.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libxlog.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/manifest.txt +34 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio.h +398 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_codec.h +23 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_frame.h +36 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io.h +56 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_android.h +19 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_apple.h +19 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_harmony.h +19 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_windows.h +19 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_processing.h +56 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_sample_rate.h +18 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/av.h +452 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/credential.h +34 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/error.h +30 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/foundation/build_info.h +27 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/http.h +57 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/logging.h +55 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_codec.h +21 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_downlink.h +95 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_av_sync.h +61 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_source.h +77 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_live_source.h +71 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_uplink.h +116 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/transport.h +481 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/trp.h +541 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_codec.h +58 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_frame.h +55 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io.h +46 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_android.h +32 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_apple.h +47 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_harmony.h +32 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_windows.h +26 -0
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_processing.h +34 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libcrypto.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libcrypto.dylib +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_audio.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_credential.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_http.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_logging.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libssl.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libssl.dylib +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libwebrtc_apm.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libxlog.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/manifest.txt +50 -0
- package/vendor/app-server/bin/tirtc-devtool-host.js +2 -0
- package/vendor/app-server/dist/host/ArtifactManager.d.ts +18 -0
- package/vendor/app-server/dist/host/ArtifactManager.js +83 -0
- package/vendor/app-server/dist/host/HostProtocol.d.ts +107 -0
- package/vendor/app-server/dist/host/HostProtocol.js +256 -0
- package/vendor/app-server/dist/host/HostServer.d.ts +49 -0
- package/vendor/app-server/dist/host/HostServer.js +635 -0
- package/vendor/app-server/dist/host/HostState.d.ts +60 -0
- package/vendor/app-server/dist/host/HostState.js +19 -0
- package/vendor/app-server/dist/host/RuntimeAdapter.d.ts +81 -0
- package/vendor/app-server/dist/host/RuntimeAdapter.js +559 -0
- package/vendor/app-server/dist/host/RuntimeCredentialTokenIssuer.d.ts +30 -0
- package/vendor/app-server/dist/host/RuntimeCredentialTokenIssuer.js +224 -0
- package/vendor/app-server/dist/host/RuntimeReceiveWorker.d.ts +37 -0
- package/vendor/app-server/dist/host/RuntimeReceiveWorker.js +186 -0
- package/vendor/app-server/dist/host/RuntimeSendWorker.d.ts +42 -0
- package/vendor/app-server/dist/host/RuntimeSendWorker.js +274 -0
- package/vendor/app-server/dist/host/TokenTool.d.ts +15 -0
- package/vendor/app-server/dist/host/TokenTool.js +84 -0
- package/vendor/app-server/dist/host/WebPreviewGateway.d.ts +28 -0
- package/vendor/app-server/dist/host/WebPreviewGateway.js +815 -0
- package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.d.ts +26 -0
- package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.js +118 -0
- package/vendor/app-server/dist/host/native/RuntimeHostBridge.d.ts +19 -0
- package/vendor/app-server/dist/host/native/RuntimeHostBridge.js +141 -0
- package/vendor/app-server/dist/host/runtime_backed_preflight.d.ts +10 -0
- package/vendor/app-server/dist/host/runtime_backed_preflight.js +78 -0
- package/vendor/app-server/dist/host/tests/helpers/host_socket_client.d.ts +28 -0
- package/vendor/app-server/dist/host/tests/helpers/host_socket_client.js +85 -0
- package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.d.ts +10 -0
- package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.js +41 -0
- package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.d.ts +11 -0
- package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.js +32 -0
- package/vendor/app-server/dist/protocol/contract.d.ts +983 -0
- package/vendor/app-server/dist/protocol/contract.js +198 -0
- package/vendor/app-server/dist/protocol-client/index.d.ts +25 -0
- package/vendor/app-server/dist/protocol-client/index.js +114 -0
- package/vendor/app-server/dist/src/index.d.ts +1 -0
- package/vendor/app-server/dist/src/index.js +294 -0
- package/vendor/runtime/script/prepare_runtime_media_dataset.sh +427 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HostProtocolError = void 0;
|
|
4
|
+
exports.parseRequest = parseRequest;
|
|
5
|
+
exports.toParamsRecord = toParamsRecord;
|
|
6
|
+
exports.parseServiceStartParams = parseServiceStartParams;
|
|
7
|
+
exports.parseConnectionConnectParams = parseConnectionConnectParams;
|
|
8
|
+
exports.parseStreamSendStartParams = parseStreamSendStartParams;
|
|
9
|
+
exports.parseStreamStopParams = parseStreamStopParams;
|
|
10
|
+
exports.parseStreamReceiveStartParams = parseStreamReceiveStartParams;
|
|
11
|
+
exports.parseOutputAttachParams = parseOutputAttachParams;
|
|
12
|
+
exports.parseOutputDetachParams = parseOutputDetachParams;
|
|
13
|
+
exports.parseCommandSendParams = parseCommandSendParams;
|
|
14
|
+
exports.parseEventsSubscribeParams = parseEventsSubscribeParams;
|
|
15
|
+
exports.parseArtifactExportParams = parseArtifactExportParams;
|
|
16
|
+
exports.parseStreamRequestPolicySetParams = parseStreamRequestPolicySetParams;
|
|
17
|
+
exports.parseDebugTokenQrcodeParams = parseDebugTokenQrcodeParams;
|
|
18
|
+
exports.normalizeError = normalizeError;
|
|
19
|
+
class HostProtocolError extends Error {
|
|
20
|
+
reasonCode;
|
|
21
|
+
retryable;
|
|
22
|
+
constructor(reasonCode, message, retryable) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.name = 'HostProtocolError';
|
|
25
|
+
this.reasonCode = reasonCode;
|
|
26
|
+
this.retryable = retryable;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.HostProtocolError = HostProtocolError;
|
|
30
|
+
function isRecord(value) {
|
|
31
|
+
return typeof value === 'object' && value !== null;
|
|
32
|
+
}
|
|
33
|
+
function parseRequest(message) {
|
|
34
|
+
const parsed = JSON.parse(message);
|
|
35
|
+
if (!isRecord(parsed) || typeof parsed.method !== 'string') {
|
|
36
|
+
throw new HostProtocolError('invalid_request', 'Invalid request envelope', false);
|
|
37
|
+
}
|
|
38
|
+
const id = parsed.id;
|
|
39
|
+
if (id !== undefined && typeof id !== 'string' && typeof id !== 'number') {
|
|
40
|
+
throw new HostProtocolError('invalid_request', 'Invalid request id', false);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
id,
|
|
44
|
+
method: parsed.method,
|
|
45
|
+
params: parsed.params,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function toParamsRecord(params) {
|
|
49
|
+
if (params === undefined) {
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
if (!isRecord(params)) {
|
|
53
|
+
throw new HostProtocolError('invalid_request', 'Params must be an object', false);
|
|
54
|
+
}
|
|
55
|
+
return params;
|
|
56
|
+
}
|
|
57
|
+
function getString(params, key) {
|
|
58
|
+
const value = params[key];
|
|
59
|
+
if (typeof value !== 'string') {
|
|
60
|
+
throw new HostProtocolError('invalid_request', `Invalid ${key}`, false);
|
|
61
|
+
}
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
function getOptionalString(params, key) {
|
|
65
|
+
const value = params[key];
|
|
66
|
+
if (value === undefined) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
if (typeof value !== 'string') {
|
|
70
|
+
throw new HostProtocolError('invalid_request', `Invalid ${key}`, false);
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
function getNumber(params, key) {
|
|
75
|
+
const value = params[key];
|
|
76
|
+
if (typeof value !== 'number' || Number.isNaN(value)) {
|
|
77
|
+
throw new HostProtocolError('invalid_request', `Invalid ${key}`, false);
|
|
78
|
+
}
|
|
79
|
+
return value;
|
|
80
|
+
}
|
|
81
|
+
function getOptionalNumber(params, key) {
|
|
82
|
+
const value = params[key];
|
|
83
|
+
if (value === undefined) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
if (typeof value !== 'number' || Number.isNaN(value)) {
|
|
87
|
+
throw new HostProtocolError('invalid_request', `Invalid ${key}`, false);
|
|
88
|
+
}
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
function getOptionalBoolean(params, key) {
|
|
92
|
+
const value = params[key];
|
|
93
|
+
if (value === undefined) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
if (typeof value !== 'boolean') {
|
|
97
|
+
throw new HostProtocolError('invalid_request', `Invalid ${key}`, false);
|
|
98
|
+
}
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
function getRecord(params, key) {
|
|
102
|
+
const value = params[key];
|
|
103
|
+
if (!isRecord(value)) {
|
|
104
|
+
throw new HostProtocolError('invalid_request', `Invalid ${key}`, false);
|
|
105
|
+
}
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
function parseStreamSource(source) {
|
|
109
|
+
if (!isRecord(source)) {
|
|
110
|
+
throw new HostProtocolError('invalid_request', 'Invalid source', false);
|
|
111
|
+
}
|
|
112
|
+
const mode = getString(source, 'mode');
|
|
113
|
+
if (mode !== 'local_assets') {
|
|
114
|
+
throw new HostProtocolError('invalid_request', 'Invalid source.mode', false);
|
|
115
|
+
}
|
|
116
|
+
const localAssets = getRecord(source, 'local_assets');
|
|
117
|
+
return {
|
|
118
|
+
mode: 'local_assets',
|
|
119
|
+
local_assets: {
|
|
120
|
+
assets_dir: getString(localAssets, 'assets_dir'),
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function parseServiceStartParams(params) {
|
|
125
|
+
return {
|
|
126
|
+
serviceEntry: getOptionalString(params, 'serviceEntry'),
|
|
127
|
+
license: getString(params, 'license'),
|
|
128
|
+
timeoutMs: getNumber(params, 'timeoutMs'),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function parseConnectionConnectParams(params) {
|
|
132
|
+
const token = getOptionalString(params, 'token');
|
|
133
|
+
const rawTokenMode = getOptionalString(params, 'tokenMode');
|
|
134
|
+
const tokenMode = rawTokenMode === undefined ? undefined : (() => {
|
|
135
|
+
if (rawTokenMode !== 'manual' && rawTokenMode !== 'auto') {
|
|
136
|
+
throw new HostProtocolError('invalid_request', 'Invalid tokenMode', false);
|
|
137
|
+
}
|
|
138
|
+
return rawTokenMode;
|
|
139
|
+
})();
|
|
140
|
+
const autoTokenRaw = params.autoToken;
|
|
141
|
+
let autoToken;
|
|
142
|
+
if (autoTokenRaw !== undefined) {
|
|
143
|
+
if (!isRecord(autoTokenRaw)) {
|
|
144
|
+
throw new HostProtocolError('invalid_request', 'Invalid autoToken', false);
|
|
145
|
+
}
|
|
146
|
+
autoToken = {
|
|
147
|
+
openapiEntry: getOptionalString(autoTokenRaw, 'openapiEntry'),
|
|
148
|
+
accessId: getString(autoTokenRaw, 'accessId'),
|
|
149
|
+
secretKey: getString(autoTokenRaw, 'secretKey'),
|
|
150
|
+
localId: getOptionalString(autoTokenRaw, 'localId'),
|
|
151
|
+
userTtlSeconds: getOptionalNumber(autoTokenRaw, 'userTtlSeconds'),
|
|
152
|
+
channelTtlSeconds: getOptionalNumber(autoTokenRaw, 'channelTtlSeconds'),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (!token && !autoToken) {
|
|
156
|
+
throw new HostProtocolError('invalid_request', 'connection/connect requires token or autoToken', false);
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
serviceEntry: getOptionalString(params, 'serviceEntry'),
|
|
160
|
+
peerId: getString(params, 'peerId'),
|
|
161
|
+
token,
|
|
162
|
+
tokenMode,
|
|
163
|
+
autoToken,
|
|
164
|
+
timeoutMs: getNumber(params, 'timeoutMs'),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function parseStreamSendStartParams(params) {
|
|
168
|
+
const media = getString(params, 'media');
|
|
169
|
+
if (media !== 'audio' && media !== 'video') {
|
|
170
|
+
throw new HostProtocolError('invalid_request', 'Invalid media', false);
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
streamId: getNumber(params, 'streamId'),
|
|
174
|
+
media,
|
|
175
|
+
source: parseStreamSource(params.source),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function parseStreamStopParams(params) {
|
|
179
|
+
return { streamId: getNumber(params, 'streamId') };
|
|
180
|
+
}
|
|
181
|
+
function parseStreamReceiveStartParams(params) {
|
|
182
|
+
const media = getString(params, 'media');
|
|
183
|
+
if (media !== 'audio' && media !== 'video') {
|
|
184
|
+
throw new HostProtocolError('invalid_request', 'Invalid media', false);
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
streamId: getNumber(params, 'streamId'),
|
|
188
|
+
media,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function parseOutputAttachParams(params) {
|
|
192
|
+
return {
|
|
193
|
+
streamId: getNumber(params, 'streamId'),
|
|
194
|
+
consumer: getString(params, 'consumer'),
|
|
195
|
+
mediaView: getString(params, 'mediaView'),
|
|
196
|
+
format: getString(params, 'format'),
|
|
197
|
+
delivery: getString(params, 'delivery'),
|
|
198
|
+
targetPath: getOptionalString(params, 'targetPath'),
|
|
199
|
+
maxFiles: getOptionalNumber(params, 'maxFiles'),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function parseOutputDetachParams(params) {
|
|
203
|
+
return {
|
|
204
|
+
outputId: getString(params, 'outputId'),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function parseCommandSendParams(params) {
|
|
208
|
+
return {
|
|
209
|
+
commandId: getNumber(params, 'commandId'),
|
|
210
|
+
kind: getString(params, 'kind'),
|
|
211
|
+
payloadEncoding: getString(params, 'payloadEncoding'),
|
|
212
|
+
payload: getString(params, 'payload'),
|
|
213
|
+
replyToSequenceNumber: getOptionalNumber(params, 'replyToSequenceNumber'),
|
|
214
|
+
awaitResponse: getOptionalBoolean(params, 'awaitResponse'),
|
|
215
|
+
timeoutMs: getOptionalNumber(params, 'timeoutMs'),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function parseEventsSubscribeParams(params) {
|
|
219
|
+
const families = params.families;
|
|
220
|
+
if (families === undefined) {
|
|
221
|
+
return {};
|
|
222
|
+
}
|
|
223
|
+
if (!Array.isArray(families) || families.some((f) => typeof f !== 'string')) {
|
|
224
|
+
throw new HostProtocolError('invalid_request', 'Invalid families', false);
|
|
225
|
+
}
|
|
226
|
+
return { families };
|
|
227
|
+
}
|
|
228
|
+
function parseArtifactExportParams(params) {
|
|
229
|
+
return {
|
|
230
|
+
outputPath: getString(params, 'outputPath'),
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function parseStreamRequestPolicySetParams(params) {
|
|
234
|
+
const mode = getString(params, 'mode');
|
|
235
|
+
if (mode !== 'manual' && mode !== 'auto-if-bound') {
|
|
236
|
+
throw new HostProtocolError('invalid_request', 'Invalid mode', false);
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
mode,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
function parseDebugTokenQrcodeParams(params) {
|
|
243
|
+
return {
|
|
244
|
+
payload: getString(params, 'payload'),
|
|
245
|
+
outputStem: getOptionalString(params, 'outputStem'),
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function normalizeError(error) {
|
|
249
|
+
if (error instanceof HostProtocolError) {
|
|
250
|
+
return error;
|
|
251
|
+
}
|
|
252
|
+
if (error instanceof Error) {
|
|
253
|
+
return new HostProtocolError('internal_error', error.message, false);
|
|
254
|
+
}
|
|
255
|
+
return new HostProtocolError('internal_error', 'Internal error', false);
|
|
256
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ArtifactManager } from './ArtifactManager';
|
|
2
|
+
import { RuntimeAdapter } from './RuntimeAdapter';
|
|
3
|
+
export declare class HostServer {
|
|
4
|
+
private state;
|
|
5
|
+
private artifactManager;
|
|
6
|
+
private runtimeAdapter;
|
|
7
|
+
private isInitialized;
|
|
8
|
+
private eventCounter;
|
|
9
|
+
private commandSequence;
|
|
10
|
+
private tokenTool;
|
|
11
|
+
private runtimeCredentialTokenIssuer;
|
|
12
|
+
private eventSinks;
|
|
13
|
+
constructor(artifactManager: ArtifactManager, runtimeAdapter: RuntimeAdapter, hostEndpoint?: string);
|
|
14
|
+
handleMessage(message: string): Promise<string | undefined>;
|
|
15
|
+
private writeEvent;
|
|
16
|
+
private pushEvent;
|
|
17
|
+
addEventSink(sink: (event: Record<string, unknown>) => void): void;
|
|
18
|
+
removeEventSink(sink: (event: Record<string, unknown>) => void): void;
|
|
19
|
+
appendHostLog(line: string): void;
|
|
20
|
+
private handleRuntimeEvent;
|
|
21
|
+
private maybeAutoStartStreamFromRemoteDemand;
|
|
22
|
+
private dispatch;
|
|
23
|
+
private handleInitialize;
|
|
24
|
+
private handleHostStatus;
|
|
25
|
+
private handleHostShutdown;
|
|
26
|
+
private handleServiceStart;
|
|
27
|
+
private handleServiceStop;
|
|
28
|
+
private handleConnectionGet;
|
|
29
|
+
private resolveConnectionToken;
|
|
30
|
+
private handleConnectionConnect;
|
|
31
|
+
private startDeferredSendStreamsOnConnected;
|
|
32
|
+
private activatePendingStreamsOnConnected;
|
|
33
|
+
private handleConnectionDisconnect;
|
|
34
|
+
private handleStreamList;
|
|
35
|
+
private handleStreamSendStart;
|
|
36
|
+
private handleStreamSendStop;
|
|
37
|
+
private handleStreamReceiveStart;
|
|
38
|
+
private handleStreamReceiveStop;
|
|
39
|
+
private handleStreamRequestPolicyGet;
|
|
40
|
+
private handleStreamRequestPolicySet;
|
|
41
|
+
private handleOutputAttach;
|
|
42
|
+
private handleOutputDetach;
|
|
43
|
+
private handleCommandSend;
|
|
44
|
+
private handleEventsSubscribe;
|
|
45
|
+
private handleArtifactReadReport;
|
|
46
|
+
private handleArtifactExportLogs;
|
|
47
|
+
private handleArtifactExportReport;
|
|
48
|
+
private handleDebugTokenQrcode;
|
|
49
|
+
}
|