@mindexec/cli 0.2.478 → 0.2.479

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 (146) hide show
  1. package/README.md +323 -323
  2. package/codex-model-catalog.js +202 -202
  3. package/codex-runtime.js +1608 -1608
  4. package/desktop-workspace-state.cjs +120 -120
  5. package/electron/main.cjs +517 -517
  6. package/electron/preload.cjs +17 -17
  7. package/electron/recurring-update-owner-smoke.mjs +55 -55
  8. package/electron/recurring-update-owner.cjs +97 -97
  9. package/electron/source-smoke.mjs +108 -108
  10. package/electron/update-feed-resolver.cjs +79 -79
  11. package/electron/update-feed.json +10 -10
  12. package/electron/update-manager-smoke.mjs +146 -146
  13. package/electron/update-manager.cjs +297 -297
  14. package/electron/windows-package-smoke.mjs +156 -156
  15. package/launch-bridge.cjs +236 -236
  16. package/lzo1x.js +110 -110
  17. package/mode4-atlas-worker.js +440 -440
  18. package/mode4-atlas.js +130 -130
  19. package/package.json +1 -1
  20. package/port-guard.cjs +285 -285
  21. package/remote-fast/osx-arm64/MacScreenCaptureKitH264.swift +339 -339
  22. package/remote-fast/osx-arm64/MacSystemAudioCapture.swift +214 -214
  23. package/remote-fast/osx-arm64/UnixRawCaptureHelper.mjs +80 -80
  24. package/remote-fast/osx-arm64/livedesk-raw-capture-resampler.mjs +73 -73
  25. package/remote-fast/osx-arm64/mindexec-remote-fast.dll +0 -0
  26. package/remote-fast/osx-x64/MacScreenCaptureKitH264.swift +339 -339
  27. package/remote-fast/osx-x64/MacSystemAudioCapture.swift +214 -214
  28. package/remote-fast/osx-x64/UnixRawCaptureHelper.mjs +80 -80
  29. package/remote-fast/osx-x64/livedesk-raw-capture-resampler.mjs +73 -73
  30. package/remote-fast/osx-x64/mindexec-remote-fast.dll +0 -0
  31. package/remote-fast/win-x64/mindexec-remote-fast.dll +0 -0
  32. package/remote-hub.js +3698 -3698
  33. package/scripts/auth-session-smoke.mjs +262 -262
  34. package/scripts/board-render-ownership-smoke.mjs +85 -85
  35. package/scripts/codex-model-catalog-smoke.mjs +150 -150
  36. package/scripts/codex-runtime-home-smoke.mjs +58 -58
  37. package/scripts/codex-sdk-image-live-smoke.mjs +43 -43
  38. package/scripts/codex-sdk-image-runtime-smoke.mjs +122 -122
  39. package/scripts/codex-sdk-runtime-smoke.mjs +89 -89
  40. package/scripts/desktop-update-publisher-smoke.mjs +89 -89
  41. package/scripts/desktop-update-worker-smoke.mjs +72 -72
  42. package/scripts/desktop-workspace-state-smoke.mjs +81 -81
  43. package/scripts/drive-installed-update-smoke.mjs +67 -67
  44. package/scripts/npm-fresh-install-smoke.mjs +216 -216
  45. package/scripts/publish-mindexec-desktop-updates.mjs +224 -224
  46. package/scripts/remote-agent-managed-smoke.mjs +318 -318
  47. package/scripts/remote-agent-package-smoke.mjs +64 -64
  48. package/scripts/remote-agent-ws-smoke.mjs +269 -269
  49. package/scripts/remote-fast-live-rate-smoke.mjs +343 -343
  50. package/scripts/remote-fast-mdm-browser-smoke.mjs +453 -453
  51. package/scripts/remote-fleet-render-smoke.mjs +1350 -1350
  52. package/scripts/remote-frame-ws-smoke.mjs +234 -234
  53. package/scripts/remote-http-smoke.mjs +592 -592
  54. package/scripts/remote-hub-identity-smoke.mjs +146 -146
  55. package/scripts/remote-hub-scale-smoke.mjs +124 -124
  56. package/scripts/remote-hub-smoke.mjs +699 -699
  57. package/scripts/remote-input-ws-smoke.mjs +263 -263
  58. package/scripts/remote-registry-follower-smoke.mjs +815 -815
  59. package/scripts/setup-tree-sitter-grammars.mjs +59 -59
  60. package/server.js +7510 -7510
  61. package/start-bridge.bat +32 -32
  62. package/start-bridge.sh +81 -81
  63. package/tree-sitter-grammars/README.md +18 -0
  64. package/tree-sitter-grammars/tree-sitter-c_sharp.wasm +0 -0
  65. package/tree-sitter-grammars/tree-sitter-go.wasm +0 -0
  66. package/tree-sitter-grammars/tree-sitter-java.wasm +0 -0
  67. package/tree-sitter-grammars/tree-sitter-javascript.wasm +0 -0
  68. package/tree-sitter-grammars/tree-sitter-python.wasm +0 -0
  69. package/tree-sitter-grammars/tree-sitter-rust.wasm +0 -0
  70. package/tree-sitter-grammars/tree-sitter-tsx.wasm +0 -0
  71. package/tree-sitter-grammars/tree-sitter-typescript.wasm +0 -0
  72. package/wwwroot/_content/MindExecution.Plugins.Admin/css/admin-dashboard.css +546 -546
  73. package/wwwroot/_content/MindExecution.Plugins.Directory/background.png +0 -0
  74. package/wwwroot/_content/MindExecution.Plugins.YouTube/css/youtube-search.css +251 -251
  75. package/wwwroot/_content/MindExecution.Shared/css/mind-map-overrides.css +3789 -3789
  76. package/wwwroot/_content/MindExecution.Shared/fonts/NotoSansKR-Bold.ttf +0 -0
  77. package/wwwroot/_content/MindExecution.Shared/fonts/NotoSansKR-Regular.ttf +0 -0
  78. package/wwwroot/_content/MindExecution.Shared/js/agent-visualization.js +27 -27
  79. package/wwwroot/_content/MindExecution.Shared/js/background-themes.js +1449 -1449
  80. package/wwwroot/_content/MindExecution.Shared/js/code-master.js +8316 -8316
  81. package/wwwroot/_content/MindExecution.Shared/js/file-system-helper.js +338 -338
  82. package/wwwroot/_content/MindExecution.Shared/js/marked.min.js +69 -69
  83. package/wwwroot/_content/MindExecution.Shared/js/mind-map-animated-image-preview.js +270 -270
  84. package/wwwroot/_content/MindExecution.Shared/js/mind-map-automation-edge-motion.js +170 -170
  85. package/wwwroot/_content/MindExecution.Shared/js/mind-map-board-render-ownership.js +81 -81
  86. package/wwwroot/_content/MindExecution.Shared/js/mind-map-core.js +10506 -10506
  87. package/wwwroot/_content/MindExecution.Shared/js/mind-map-core.js.backup +1059 -0
  88. package/wwwroot/_content/MindExecution.Shared/js/mind-map-css3d-hotpath.js +902 -902
  89. package/wwwroot/_content/MindExecution.Shared/js/mind-map-css3d-manager.js +24637 -24637
  90. package/wwwroot/_content/MindExecution.Shared/js/mind-map-dev-guards.js +325 -325
  91. package/wwwroot/_content/MindExecution.Shared/js/mind-map-dnd.js +1491 -1491
  92. package/wwwroot/_content/MindExecution.Shared/js/mind-map-dnd.js.bak +434 -0
  93. package/wwwroot/_content/MindExecution.Shared/js/mind-map-glow-shader.js +70 -70
  94. package/wwwroot/_content/MindExecution.Shared/js/mind-map-image-policy.js +218 -218
  95. package/wwwroot/_content/MindExecution.Shared/js/mind-map-interactions.js +7078 -7078
  96. package/wwwroot/_content/MindExecution.Shared/js/mind-map-lod-plan-worker.js +160 -160
  97. package/wwwroot/_content/MindExecution.Shared/js/mind-map-lod-renderer.js +9958 -9958
  98. package/wwwroot/_content/MindExecution.Shared/js/mind-map-lod-video-placeholder.js +107 -107
  99. package/wwwroot/_content/MindExecution.Shared/js/mind-map-logic-workers.js +1004 -1004
  100. package/wwwroot/_content/MindExecution.Shared/js/mind-map-menu-manager.js +1351 -1351
  101. package/wwwroot/_content/MindExecution.Shared/js/mind-map-multi-select.js +865 -865
  102. package/wwwroot/_content/MindExecution.Shared/js/mind-map-node-search-worker.js +554 -554
  103. package/wwwroot/_content/MindExecution.Shared/js/mind-map-nodes.js +4744 -4744
  104. package/wwwroot/_content/MindExecution.Shared/js/mind-map-normal-boundary-optimizer.js +624 -624
  105. package/wwwroot/_content/MindExecution.Shared/js/mind-map-object-manager.js +241 -241
  106. package/wwwroot/_content/MindExecution.Shared/js/mind-map-object-manager.js.backup +372 -0
  107. package/wwwroot/_content/MindExecution.Shared/js/mind-map-pipeline.js +2290 -2290
  108. package/wwwroot/_content/MindExecution.Shared/js/mind-map-remote-codecs.js +202 -202
  109. package/wwwroot/_content/MindExecution.Shared/js/mind-map-render-plan.js +1971 -1971
  110. package/wwwroot/_content/MindExecution.Shared/js/mind-map-text-lod-system.js +93 -93
  111. package/wwwroot/_content/MindExecution.Shared/js/mind-map-texture-factory.js +2391 -2391
  112. package/wwwroot/_content/MindExecution.Shared/js/mind-map-texture-factory.js.backup +1258 -0
  113. package/wwwroot/_content/MindExecution.Shared/js/mind-map-video-playback-controls.js +95 -95
  114. package/wwwroot/_content/MindExecution.Shared/js/mind-map-visibility-worker.js +895 -895
  115. package/wwwroot/_content/MindExecution.Shared/js/mindmap-toolbar.js +636 -636
  116. package/wwwroot/_content/MindExecution.Shared/js/native-drop-handler.js +45 -45
  117. package/wwwroot/_content/MindExecution.Shared/js/plan-master.js +117 -117
  118. package/wwwroot/_content/MindExecution.Shared/js/renderers/CSS3DRenderer.js +114 -114
  119. package/wwwroot/_content/MindExecution.Shared/js/texture-worker-manager.js +10 -10
  120. package/wwwroot/_content/MindExecution.Shared/js/three.min.js +6 -6
  121. package/wwwroot/_content/MindExecution.Shared/js/token-manager.js +7 -7
  122. package/wwwroot/_content/MindExecution.Shared/js/troika-bundle.js +6 -6
  123. package/wwwroot/_content/MindExecution.Shared/js/troika-bundle.js.map +2 -2
  124. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/css/all.min.css +8 -8
  125. package/wwwroot/_content/MindExecution.Shared/models/vocab.txt +30522 -30522
  126. package/wwwroot/_framework/{Google.Protobuf.33g2gb5is0.dll → Google.Protobuf.9h59ukbel7.dll} +0 -0
  127. package/wwwroot/_framework/{MindExecution.Core.z100xo4mg0.dll → MindExecution.Core.xxsj2s456b.dll} +0 -0
  128. package/wwwroot/_framework/{MindExecution.Kernel.i9cldrx8yc.dll → MindExecution.Kernel.5jofnc0wrd.dll} +0 -0
  129. package/wwwroot/_framework/{MindExecution.Plugins.Admin.48lzqddb0a.dll → MindExecution.Plugins.Admin.t7m4jnqjg3.dll} +0 -0
  130. package/wwwroot/_framework/{MindExecution.Plugins.Business.7m8u1q142p.dll → MindExecution.Plugins.Business.6yjlhhavap.dll} +0 -0
  131. package/wwwroot/_framework/{MindExecution.Plugins.Concept.cl5wmr53od.dll → MindExecution.Plugins.Concept.iikqq5zxu0.dll} +0 -0
  132. package/wwwroot/_framework/{MindExecution.Plugins.Directory.slipi39041.dll → MindExecution.Plugins.Directory.c5ribyne4m.dll} +0 -0
  133. package/wwwroot/_framework/{MindExecution.Plugins.PlanMaster.qfge05l671.dll → MindExecution.Plugins.PlanMaster.365bbuifr9.dll} +0 -0
  134. package/wwwroot/_framework/{MindExecution.Plugins.YouTube.tn7v29ut77.dll → MindExecution.Plugins.YouTube.ax415cilpk.dll} +0 -0
  135. package/wwwroot/_framework/MindExecution.Shared.21e2nvf86u.dll +0 -0
  136. package/wwwroot/_framework/{MindExecution.Web.rwawrxxk38.dll → MindExecution.Web.ppgm8rey59.dll} +0 -0
  137. package/wwwroot/_framework/{System.Collections.23yxgetbju.dll → System.Collections.zyvbaq6mpd.dll} +0 -0
  138. package/wwwroot/_framework/blazor.boot.json +25 -25
  139. package/wwwroot/_headers +40 -40
  140. package/wwwroot/_redirects +1 -1
  141. package/wwwroot/index.html +772 -772
  142. package/wwwroot/js/marketing-tool.js +180 -180
  143. package/wwwroot/manifest.webmanifest +23 -23
  144. package/wwwroot/service-worker-assets.js +109 -81
  145. package/wwwroot/service-worker.js +33 -33
  146. package/wwwroot/_framework/MindExecution.Shared.rjqlf0umjn.dll +0 -0
@@ -1,592 +1,592 @@
1
- #!/usr/bin/env node
2
-
3
- import assert from 'node:assert/strict';
4
- import net from 'node:net';
5
- import { spawn } from 'node:child_process';
6
- import path from 'node:path';
7
- import { fileURLToPath } from 'node:url';
8
- import { readFileSync } from 'node:fs';
9
-
10
- const BRIDGE_TOKEN = 'remote-http-smoke-token';
11
- const PAIR_TOKEN = 'remote-http-pair-token';
12
- const SYNTHETIC_COUNT = Number(process.env.REMOTE_HTTP_SMOKE_COUNT || 500);
13
- const LOCAL_BRIDGE_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
14
- const LOCAL_BRIDGE_PACKAGE = JSON.parse(readFileSync(path.join(LOCAL_BRIDGE_DIR, 'package.json'), 'utf8'));
15
-
16
- function wait(ms) {
17
- return new Promise(resolve => setTimeout(resolve, ms));
18
- }
19
-
20
- async function findFreePort() {
21
- return await new Promise((resolve, reject) => {
22
- const server = net.createServer();
23
- server.unref();
24
- server.once('error', reject);
25
- server.listen(0, '127.0.0.1', () => {
26
- const address = server.address();
27
- const port = typeof address === 'object' && address ? address.port : 0;
28
- server.close(() => resolve(port));
29
- });
30
- });
31
- }
32
-
33
- async function fetchJson(url, options = {}) {
34
- const response = await fetch(url, {
35
- ...options,
36
- headers: {
37
- ...(options.body ? { 'Content-Type': 'application/json' } : {}),
38
- ...(options.token ? { 'X-Bridge-Token': options.token } : {}),
39
- ...(options.headers || {})
40
- }
41
- });
42
-
43
- let payload = null;
44
- try {
45
- payload = await response.json();
46
- } catch {
47
- // Some failure responses may be empty.
48
- }
49
-
50
- return {
51
- status: response.status,
52
- ok: response.ok,
53
- payload
54
- };
55
- }
56
-
57
- async function fetchBinary(url, options = {}) {
58
- const response = await fetch(url, {
59
- ...options,
60
- headers: {
61
- Accept: 'image/png,image/jpeg,image/webp,image/*',
62
- ...(options.token ? { 'X-Bridge-Token': options.token } : {}),
63
- ...(options.headers || {})
64
- }
65
- });
66
-
67
- return {
68
- status: response.status,
69
- ok: response.ok,
70
- contentType: response.headers.get('content-type') || '',
71
- frameSeq: response.headers.get('x-mindexec-remote-frame-seq') || '',
72
- streamId: response.headers.get('x-mindexec-remote-stream-id') || '',
73
- payload: Buffer.from(await response.arrayBuffer())
74
- };
75
- }
76
-
77
- async function waitForBridge(baseUrl, getFailureDetails, bridgeToken = BRIDGE_TOKEN) {
78
- const startedAt = Date.now();
79
- while (Date.now() - startedAt < 30000) {
80
- try {
81
- const result = await fetchJson(`${baseUrl}/api/remote/status`, { token: bridgeToken });
82
- if (result.ok && result.payload?.started === true) {
83
- return result.payload;
84
- }
85
- } catch {
86
- // Server is still starting.
87
- }
88
- await wait(100);
89
- }
90
-
91
- throw new Error(`Timed out waiting for LocalBridge RemoteHub HTTP API.\n${getFailureDetails()}`);
92
- }
93
-
94
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
95
- const bridgeRoot = path.resolve(__dirname, '..');
96
-
97
- function spawnBridge({
98
- bridgePort,
99
- remoteHubPort,
100
- bridgeToken = BRIDGE_TOKEN,
101
- pairToken = PAIR_TOKEN,
102
- syntheticFleetEnabled = false
103
- }) {
104
- const env = {
105
- ...process.env,
106
- BRIDGE_PORT: String(bridgePort),
107
- BRIDGE_TOKEN: bridgeToken,
108
- BRIDGE_REQUIRE_TOKEN: '1',
109
- MINDEXEC_REMOTE_HUB: '1',
110
- REMOTE_HUB_HOST: '127.0.0.1',
111
- REMOTE_HUB_PORT: String(remoteHubPort),
112
- REMOTE_HUB_PAIR_TOKEN: pairToken,
113
- NO_COLOR: '1'
114
- };
115
-
116
- delete env.MINDEXEC_REMOTE_SYNTHETIC_FLEET;
117
- delete env.REMOTE_HUB_SYNTHETIC_FLEET;
118
- if (syntheticFleetEnabled) {
119
- env.MINDEXEC_REMOTE_SYNTHETIC_FLEET = '1';
120
- }
121
-
122
- const child = spawn(process.execPath, ['server.js'], {
123
- cwd: bridgeRoot,
124
- stdio: ['ignore', 'pipe', 'pipe'],
125
- windowsHide: true,
126
- env
127
- });
128
-
129
- let stdout = '';
130
- let stderr = '';
131
- child.stdout.on('data', chunk => {
132
- stdout += chunk.toString();
133
- });
134
- child.stderr.on('data', chunk => {
135
- stderr += chunk.toString();
136
- });
137
-
138
- const exitPromise = new Promise(resolve => child.once('exit', resolve));
139
- const details = () => `stdout=${stdout}\nstderr=${stderr}`;
140
- const stop = async () => {
141
- if (child.exitCode === null && !child.killed) {
142
- child.kill('SIGTERM');
143
- await Promise.race([
144
- exitPromise,
145
- wait(5000)
146
- ]);
147
- if (child.exitCode === null && !child.killed) {
148
- child.kill('SIGKILL');
149
- }
150
- }
151
- };
152
-
153
- return {
154
- baseUrl: `http://127.0.0.1:${bridgePort}`,
155
- bridgePort,
156
- remoteHubPort,
157
- bridgeToken,
158
- pairToken,
159
- child,
160
- details,
161
- stop
162
- };
163
- }
164
-
165
- async function runSyntheticEnabledSmoke() {
166
- const bridgePort = await findFreePort();
167
- const remoteHubPort = await findFreePort();
168
- const bridge = spawnBridge({
169
- bridgePort,
170
- remoteHubPort,
171
- syntheticFleetEnabled: true
172
- });
173
- const { baseUrl } = bridge;
174
- const details = bridge.details;
175
-
176
- try {
177
- const status = await waitForBridge(baseUrl, details, bridge.bridgeToken);
178
- assert.equal(status.started, true);
179
- assert.equal(status.port, remoteHubPort);
180
- assert.equal(status.managerPackage, '@mindexec/cli');
181
- assert.equal(status.managerVersion, LOCAL_BRIDGE_PACKAGE.version);
182
- assert.equal(status.agentPackage, '@mindexec/remote');
183
- assert.equal(status.canvasPagination, 'none');
184
- assert.equal(status.canvasDeviceListMode, 'all-devices');
185
- assert.equal(status.hostTargetActive, false);
186
- assert.equal(status.pairToken, PAIR_TOKEN);
187
-
188
- const unauthorizedStatus = await fetchJson(`${baseUrl}/api/remote/status`);
189
- assert.equal(unauthorizedStatus.status, 401);
190
- assert.equal(unauthorizedStatus.payload?.header, 'X-Bridge-Token');
191
-
192
- const unauthorizedDelete = await fetchJson(`${baseUrl}/api/remote/synthetic`, {
193
- method: 'DELETE'
194
- });
195
- assert.equal(unauthorizedDelete.status, 401);
196
-
197
- const unauthorizedHost = await fetchJson(`${baseUrl}/api/remote/host-target`, {
198
- method: 'POST',
199
- body: JSON.stringify({
200
- nodeId: 'remote-fleet-host-unauthorized',
201
- enabled: true
202
- })
203
- });
204
- assert.equal(unauthorizedHost.status, 401);
205
-
206
- const setHost = await fetchJson(`${baseUrl}/api/remote/host-target`, {
207
- method: 'POST',
208
- token: BRIDGE_TOKEN,
209
- body: JSON.stringify({
210
- nodeId: 'remote-fleet-monitor-a',
211
- enabled: true,
212
- leaseMs: 30000
213
- })
214
- });
215
- assert.equal(setHost.ok, true, JSON.stringify(setHost.payload));
216
- assert.equal(setHost.payload?.ok, true);
217
- assert.equal(setHost.payload?.active, true);
218
- assert.equal(setHost.payload?.hostTarget?.nodeId, 'remote-fleet-monitor-a');
219
- assert.equal(setHost.payload?.hostTarget?.endpoint, `127.0.0.1:${remoteHubPort}`);
220
- assert.deepEqual(setHost.payload?.hostTarget?.endpointCandidates, [`127.0.0.1:${remoteHubPort}`]);
221
-
222
- const hostStatus = await fetchJson(`${baseUrl}/api/remote/status`, { token: BRIDGE_TOKEN });
223
- assert.equal(hostStatus.ok, true, JSON.stringify(hostStatus.payload));
224
- assert.equal(hostStatus.payload?.hostTargetActive, true);
225
- assert.equal(hostStatus.payload?.hostTargetNodeId, 'remote-fleet-monitor-a');
226
- assert.equal(hostStatus.payload?.hostTargetEndpoint, `127.0.0.1:${remoteHubPort}`);
227
- assert.deepEqual(hostStatus.payload?.hostTargetEndpointCandidates, [`127.0.0.1:${remoteHubPort}`]);
228
-
229
- const clearHostMismatch = await fetchJson(`${baseUrl}/api/remote/host-target`, {
230
- method: 'DELETE',
231
- token: BRIDGE_TOKEN,
232
- body: JSON.stringify({
233
- nodeId: 'remote-fleet-monitor-b'
234
- })
235
- });
236
- assert.equal(clearHostMismatch.ok, true, JSON.stringify(clearHostMismatch.payload));
237
- assert.equal(clearHostMismatch.payload?.ok, false);
238
- assert.equal(clearHostMismatch.payload?.error, 'host-target-node-mismatch');
239
-
240
- const clearHost = await fetchJson(`${baseUrl}/api/remote/host-target`, {
241
- method: 'DELETE',
242
- token: BRIDGE_TOKEN,
243
- body: JSON.stringify({
244
- nodeId: 'remote-fleet-monitor-a'
245
- })
246
- });
247
- assert.equal(clearHost.ok, true, JSON.stringify(clearHost.payload));
248
- assert.equal(clearHost.payload?.ok, true);
249
- assert.equal(clearHost.payload?.active, false);
250
-
251
- const seed = await fetchJson(`${baseUrl}/api/remote/synthetic/seed`, {
252
- method: 'POST',
253
- token: BRIDGE_TOKEN,
254
- body: JSON.stringify({
255
- count: SYNTHETIC_COUNT,
256
- connectedRatio: 0.84,
257
- thumbnailRatio: 0.72,
258
- aiAssistRatio: 0.42,
259
- liveCount: 8,
260
- replace: true
261
- })
262
- });
263
- assert.equal(seed.ok, true, JSON.stringify(seed.payload));
264
- assert.equal(seed.payload?.ok, true);
265
- assert.equal(seed.payload?.seeded, SYNTHETIC_COUNT);
266
-
267
- const devicesResult = await fetchJson(`${baseUrl}/api/remote/devices`, { token: BRIDGE_TOKEN });
268
- assert.equal(devicesResult.ok, true, JSON.stringify(devicesResult.payload));
269
- assert.equal(devicesResult.payload?.total, SYNTHETIC_COUNT);
270
- assert.equal(devicesResult.payload?.pagination, 'none');
271
- assert.equal(devicesResult.payload?.canvasDeviceListMode, 'all-devices');
272
- assert.equal(devicesResult.payload?.devices?.length, SYNTHETIC_COUNT);
273
- assert.equal(devicesResult.payload.devices.some(device => device.connected === false), true);
274
-
275
- const noControlTarget = devicesResult.payload.devices.find(device => device.connected);
276
- assert.ok(noControlTarget);
277
- const inputUnavailable = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(noControlTarget.deviceId)}/input`, {
278
- method: 'POST',
279
- token: BRIDGE_TOKEN,
280
- body: JSON.stringify({
281
- type: 'noop'
282
- })
283
- });
284
- assert.equal(inputUnavailable.ok, true, JSON.stringify(inputUnavailable.payload));
285
- assert.equal(inputUnavailable.payload?.ok, false);
286
- assert.equal(inputUnavailable.payload?.error, 'device-input-control-unavailable');
287
-
288
- const connectedTargets = devicesResult.payload.devices
289
- .filter(device => device.connected && device.capabilities?.taskDispatch)
290
- .slice(0, 500)
291
- .map(device => device.deviceId);
292
- assert.ok(connectedTargets.length >= 400);
293
-
294
- const batch = await fetchJson(`${baseUrl}/api/remote/tasks`, {
295
- method: 'POST',
296
- token: BRIDGE_TOKEN,
297
- body: JSON.stringify({
298
- deviceIds: connectedTargets,
299
- allConnected: false,
300
- title: 'HTTP smoke task batch',
301
- instruction: 'HTTP smoke batch: report current status to the manager.',
302
- approvalLevel: 'task-only'
303
- })
304
- });
305
- assert.equal(batch.ok, true, JSON.stringify(batch.payload));
306
- assert.equal(batch.payload?.ok, true);
307
- assert.equal(batch.payload?.total, connectedTargets.length);
308
- assert.equal(batch.payload?.queued, connectedTargets.length);
309
- assert.equal(batch.payload?.batch?.completed, connectedTargets.length);
310
- assert.equal(batch.payload?.batch?.failed, 0);
311
- assert.equal(batch.payload?.batch?.status, 'completed');
312
-
313
- const aiTargets = devicesResult.payload.devices
314
- .filter(device => device.connected && device.capabilities?.taskDispatch && device.capabilities?.aiAssist)
315
- .map(device => device.deviceId);
316
- assert.ok(aiTargets.length >= 200);
317
- const allAiBatch = await fetchJson(`${baseUrl}/api/remote/tasks`, {
318
- method: 'POST',
319
- token: BRIDGE_TOKEN,
320
- body: JSON.stringify({
321
- allConnected: true,
322
- title: 'HTTP smoke all AI task batch',
323
- instruction: 'HTTP smoke AI batch: summarize fleet condition only on AI-capable agents.',
324
- approvalLevel: 'ai-assist'
325
- })
326
- });
327
- assert.equal(allAiBatch.ok, true, JSON.stringify(allAiBatch.payload));
328
- assert.equal(allAiBatch.payload?.ok, true);
329
- assert.equal(allAiBatch.payload?.approvalLevel, 'ai-assist');
330
- assert.equal(allAiBatch.payload?.total, aiTargets.length);
331
- assert.equal(allAiBatch.payload?.queued, aiTargets.length);
332
- assert.equal(allAiBatch.payload?.batch?.completed, aiTargets.length);
333
- assert.equal(allAiBatch.payload?.batch?.failed, 0);
334
- assert.equal(allAiBatch.payload?.batch?.status, 'completed');
335
- assert.deepEqual(
336
- [...(allAiBatch.payload?.results || []).map(result => result.deviceId)].sort(),
337
- [...aiTargets].sort());
338
-
339
- const aiTarget = devicesResult.payload.devices.find(device =>
340
- device.connected && device.capabilities?.taskDispatch && device.capabilities?.aiAssist);
341
- assert.ok(aiTarget);
342
- const aiTask = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(aiTarget.deviceId)}/tasks`, {
343
- method: 'POST',
344
- token: BRIDGE_TOKEN,
345
- body: JSON.stringify({
346
- title: 'HTTP smoke AI task',
347
- instruction: 'HTTP smoke AI assist: summarize fleet condition.',
348
- approvalLevel: 'ai-assist'
349
- })
350
- });
351
- assert.equal(aiTask.ok, true, JSON.stringify(aiTask.payload));
352
- assert.equal(aiTask.payload?.ok, true);
353
- assert.equal(aiTask.payload?.approvalLevel, 'ai-assist');
354
-
355
- const thumbnailTarget = devicesResult.payload.devices.find(device =>
356
- device.connected && device.capabilities?.thumbnail);
357
- assert.ok(thumbnailTarget);
358
- const thumbnailRequest = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(thumbnailTarget.deviceId)}/thumbnail/request`, {
359
- method: 'POST',
360
- token: BRIDGE_TOKEN,
361
- body: JSON.stringify({
362
- streamId: 'http-smoke-thumb',
363
- maxWidth: 360,
364
- maxHeight: 220,
365
- quality: 50
366
- })
367
- });
368
- assert.equal(thumbnailRequest.ok, true, JSON.stringify(thumbnailRequest.payload));
369
- assert.equal(thumbnailRequest.payload?.ok, true);
370
-
371
- const thumbnail = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(thumbnailTarget.deviceId)}/thumbnail`, {
372
- token: BRIDGE_TOKEN
373
- });
374
- assert.equal(thumbnail.ok, true, JSON.stringify(thumbnail.payload));
375
- assert.equal(thumbnail.payload?.thumbnail?.streamId, 'http-smoke-thumb');
376
- assert.ok(!('dataUrl' in thumbnail.payload.thumbnail));
377
- assert.ok(String(thumbnail.payload?.thumbnail?.framePath || '').includes(`/api/remote/devices/${encodeURIComponent(thumbnailTarget.deviceId)}/thumbnail?`));
378
- assert.equal(thumbnail.payload?.thumbnail?.frameUrl, thumbnail.payload?.thumbnail?.framePath);
379
-
380
- const thumbnailWithData = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(thumbnailTarget.deviceId)}/thumbnail?includeDataUrl=true`, {
381
- token: BRIDGE_TOKEN
382
- });
383
- assert.equal(thumbnailWithData.ok, true, JSON.stringify(thumbnailWithData.payload));
384
- assert.ok(String(thumbnailWithData.payload?.thumbnail?.dataUrl || '').startsWith('data:image/png;base64,'));
385
-
386
- const thumbnailBinary = await fetchBinary(`${baseUrl}${thumbnail.payload.thumbnail.framePath}`);
387
- assert.equal(thumbnailBinary.ok, true, `${thumbnailBinary.status} ${thumbnailBinary.contentType}`);
388
- assert.equal(thumbnailBinary.contentType, 'image/png');
389
- assert.equal(thumbnailBinary.streamId, 'http-smoke-thumb');
390
- assert.ok(thumbnailBinary.payload.length > 0);
391
-
392
- const badThumbnailBinary = await fetchBinary(`${baseUrl}${thumbnail.payload.thumbnail.framePath.replace(/token=[^&]+/, 'token=wrong-token')}`);
393
- assert.equal(badThumbnailBinary.status, 401);
394
-
395
- const devicesUrlOnlyResult = await fetchJson(`${baseUrl}/api/remote/devices?frameData=url`, { token: BRIDGE_TOKEN });
396
- assert.equal(devicesUrlOnlyResult.ok, true, JSON.stringify(devicesUrlOnlyResult.payload));
397
- const urlOnlyThumbnailDevice = devicesUrlOnlyResult.payload?.devices?.find(device => device.deviceId === thumbnailTarget.deviceId);
398
- assert.ok(urlOnlyThumbnailDevice?.latestThumbnail?.framePath);
399
- assert.ok(!('dataUrl' in urlOnlyThumbnailDevice.latestThumbnail));
400
-
401
- const thumbnailFramesOnly = await fetchJson(`${baseUrl}/api/remote/frames`, {
402
- method: 'POST',
403
- token: BRIDGE_TOKEN,
404
- body: JSON.stringify({
405
- deviceIds: [thumbnailTarget.deviceId],
406
- includeThumbnail: true,
407
- includeLive: true
408
- })
409
- });
410
- assert.equal(thumbnailFramesOnly.ok, true, JSON.stringify(thumbnailFramesOnly.payload));
411
- assert.equal(thumbnailFramesOnly.payload?.ok, true);
412
- assert.equal(thumbnailFramesOnly.payload?.frames?.length, 1);
413
- assert.equal(thumbnailFramesOnly.payload.frames[0].deviceId, thumbnailTarget.deviceId);
414
- assert.equal(thumbnailFramesOnly.payload.frames[0].thumbnailEnabled, true);
415
- assert.ok(String(thumbnailFramesOnly.payload.frames[0].thumbnail?.framePath || '').includes(`/api/remote/devices/${encodeURIComponent(thumbnailTarget.deviceId)}/thumbnail?`));
416
- assert.ok(!('dataUrl' in thumbnailFramesOnly.payload.frames[0].thumbnail));
417
-
418
- const liveTarget = devicesResult.payload.devices.find(device =>
419
- device.connected && device.capabilities?.liveStream);
420
- assert.ok(liveTarget);
421
- const liveStart = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(liveTarget.deviceId)}/live/start`, {
422
- method: 'POST',
423
- token: BRIDGE_TOKEN,
424
- body: JSON.stringify({
425
- streamId: 'http-smoke-live',
426
- fps: 20,
427
- maxWidth: 960,
428
- maxHeight: 540,
429
- quality: 60
430
- })
431
- });
432
- assert.equal(liveStart.ok, true, JSON.stringify(liveStart.payload));
433
- assert.equal(liveStart.payload?.ok, true);
434
-
435
- const liveFrame = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(liveTarget.deviceId)}/live/frame`, {
436
- token: BRIDGE_TOKEN
437
- });
438
- assert.equal(liveFrame.ok, true, JSON.stringify(liveFrame.payload));
439
- assert.equal(liveFrame.payload?.frame?.streamId, 'http-smoke-live');
440
- assert.equal(liveFrame.payload?.frame?.mode, 'remote-fast');
441
- assert.equal(liveFrame.payload?.frame?.fps, 20);
442
- assert.ok(!('dataUrl' in liveFrame.payload.frame));
443
- assert.ok(String(liveFrame.payload?.frame?.framePath || '').includes(`/api/remote/devices/${encodeURIComponent(liveTarget.deviceId)}/live/frame?`));
444
-
445
- const liveFrameWithData = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(liveTarget.deviceId)}/live/frame?includeDataUrl=true`, {
446
- token: BRIDGE_TOKEN
447
- });
448
- assert.equal(liveFrameWithData.ok, true, JSON.stringify(liveFrameWithData.payload));
449
- assert.ok(String(liveFrameWithData.payload?.frame?.dataUrl || '').startsWith('data:image/png;base64,'));
450
-
451
- const liveBinary = await fetchBinary(`${baseUrl}${liveFrame.payload.frame.framePath}`);
452
- assert.equal(liveBinary.ok, true, `${liveBinary.status} ${liveBinary.contentType}`);
453
- assert.equal(liveBinary.contentType, 'image/png');
454
- assert.equal(liveBinary.streamId, 'http-smoke-live');
455
- assert.ok(liveBinary.payload.length > 0);
456
-
457
- const liveBinaryWithBridgeToken = await fetchBinary(
458
- `${baseUrl}/api/remote/devices/${encodeURIComponent(liveTarget.deviceId)}/live/frame?format=binary`,
459
- { token: BRIDGE_TOKEN });
460
- assert.equal(liveBinaryWithBridgeToken.ok, true, `${liveBinaryWithBridgeToken.status} ${liveBinaryWithBridgeToken.contentType}`);
461
- assert.equal(liveBinaryWithBridgeToken.contentType, 'image/png');
462
-
463
- const badLiveSeq = await fetchBinary(`${baseUrl}${liveFrame.payload.frame.framePath.replace(/seq=\d+/, 'seq=999999')}`);
464
- assert.equal(badLiveSeq.status, 401);
465
-
466
- const liveFramesOnly = await fetchJson(`${baseUrl}/api/remote/frames`, {
467
- method: 'POST',
468
- token: BRIDGE_TOKEN,
469
- body: JSON.stringify({
470
- deviceIds: [liveTarget.deviceId],
471
- includeThumbnail: true,
472
- includeLive: true
473
- })
474
- });
475
- assert.equal(liveFramesOnly.ok, true, JSON.stringify(liveFramesOnly.payload));
476
- assert.equal(liveFramesOnly.payload?.ok, true);
477
- assert.equal(liveFramesOnly.payload?.frames?.length, 1);
478
- assert.equal(liveFramesOnly.payload.frames[0].deviceId, liveTarget.deviceId);
479
- assert.equal(liveFramesOnly.payload.frames[0].liveStreamActive, true);
480
- assert.ok(String(liveFramesOnly.payload.frames[0].live?.framePath || '').includes(`/api/remote/devices/${encodeURIComponent(liveTarget.deviceId)}/live/frame?`));
481
- assert.ok(!('dataUrl' in liveFramesOnly.payload.frames[0].live));
482
-
483
- const liveStop = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(liveTarget.deviceId)}/live/stop`, {
484
- method: 'POST',
485
- token: BRIDGE_TOKEN,
486
- body: JSON.stringify({
487
- streamId: 'http-smoke-live'
488
- })
489
- });
490
- assert.equal(liveStop.ok, true, JSON.stringify(liveStop.payload));
491
- assert.equal(liveStop.payload?.ok, true);
492
-
493
- const clear = await fetchJson(`${baseUrl}/api/remote/synthetic`, {
494
- method: 'DELETE',
495
- token: BRIDGE_TOKEN
496
- });
497
- assert.equal(clear.ok, true, JSON.stringify(clear.payload));
498
- assert.equal(clear.payload?.ok, true);
499
- assert.equal(clear.payload?.removed, SYNTHETIC_COUNT);
500
-
501
- console.log(`RemoteHub HTTP smoke OK (${SYNTHETIC_COUNT} synthetic devices, bridge ${bridgePort}, remote ${remoteHubPort})`);
502
- } finally {
503
- await bridge.stop();
504
- }
505
- }
506
-
507
- async function runSyntheticDisabledSmoke() {
508
- const bridgePort = await findFreePort();
509
- const remoteHubPort = await findFreePort();
510
- const bridgeToken = `${BRIDGE_TOKEN}-disabled`;
511
- const pairToken = `${PAIR_TOKEN}-disabled`;
512
- const bridge = spawnBridge({
513
- bridgePort,
514
- remoteHubPort,
515
- bridgeToken,
516
- pairToken,
517
- syntheticFleetEnabled: false
518
- });
519
- const { baseUrl } = bridge;
520
-
521
- try {
522
- const status = await waitForBridge(baseUrl, bridge.details, bridge.bridgeToken);
523
- assert.equal(status.started, true);
524
- assert.equal(status.port, remoteHubPort);
525
- assert.equal(status.pairToken, pairToken);
526
- assert.equal(status.canvasPagination, 'none');
527
- assert.equal(status.canvasDeviceListMode, 'all-devices');
528
- assert.equal(status.hostTargetActive, false);
529
-
530
- const seedDenied = await fetchJson(`${baseUrl}/api/remote/synthetic/seed`, {
531
- method: 'POST',
532
- token: bridge.bridgeToken,
533
- body: JSON.stringify({
534
- count: 3,
535
- replace: true
536
- })
537
- });
538
- assert.equal(seedDenied.status, 403);
539
- assert.equal(seedDenied.payload?.ok, false);
540
- assert.equal(seedDenied.payload?.error, 'synthetic-fleet-disabled');
541
-
542
- const clearDenied = await fetchJson(`${baseUrl}/api/remote/synthetic`, {
543
- method: 'DELETE',
544
- token: bridge.bridgeToken
545
- });
546
- assert.equal(clearDenied.status, 403);
547
- assert.equal(clearDenied.payload?.ok, false);
548
- assert.equal(clearDenied.payload?.error, 'synthetic-fleet-disabled');
549
-
550
- const devicesResult = await fetchJson(`${baseUrl}/api/remote/devices`, { token: bridge.bridgeToken });
551
- assert.equal(devicesResult.ok, true, JSON.stringify(devicesResult.payload));
552
- assert.equal(devicesResult.payload?.total, 0);
553
- assert.equal(devicesResult.payload?.pagination, 'none');
554
- assert.equal(devicesResult.payload?.canvasDeviceListMode, 'all-devices');
555
- assert.equal(devicesResult.payload?.devices?.length, 0);
556
-
557
- const emptyBatch = await fetchJson(`${baseUrl}/api/remote/tasks`, {
558
- method: 'POST',
559
- token: bridge.bridgeToken,
560
- body: JSON.stringify({
561
- allConnected: true,
562
- title: 'HTTP smoke no target batch',
563
- instruction: 'This should not queue because no remote devices are connected.',
564
- approvalLevel: 'task-only'
565
- })
566
- });
567
- assert.equal(emptyBatch.ok, true, JSON.stringify(emptyBatch.payload));
568
- assert.equal(emptyBatch.payload?.ok, false);
569
- assert.equal(emptyBatch.payload?.total, 0);
570
- assert.equal(emptyBatch.payload?.queued, 0);
571
- assert.equal(emptyBatch.payload?.error, 'no-target-devices');
572
-
573
- const hostTarget = await fetchJson(`${baseUrl}/api/remote/host-target`, {
574
- method: 'POST',
575
- token: bridge.bridgeToken,
576
- body: JSON.stringify({
577
- nodeId: 'disabled-synthetic-host',
578
- enabled: true
579
- })
580
- });
581
- assert.equal(hostTarget.ok, true, JSON.stringify(hostTarget.payload));
582
- assert.equal(hostTarget.payload?.ok, true);
583
- assert.equal(hostTarget.payload?.active, true);
584
-
585
- console.log(`RemoteHub HTTP safety smoke OK (synthetic disabled, bridge ${bridgePort}, remote ${remoteHubPort})`);
586
- } finally {
587
- await bridge.stop();
588
- }
589
- }
590
-
591
- await runSyntheticEnabledSmoke();
592
- await runSyntheticDisabledSmoke();
1
+ #!/usr/bin/env node
2
+
3
+ import assert from 'node:assert/strict';
4
+ import net from 'node:net';
5
+ import { spawn } from 'node:child_process';
6
+ import path from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { readFileSync } from 'node:fs';
9
+
10
+ const BRIDGE_TOKEN = 'remote-http-smoke-token';
11
+ const PAIR_TOKEN = 'remote-http-pair-token';
12
+ const SYNTHETIC_COUNT = Number(process.env.REMOTE_HTTP_SMOKE_COUNT || 500);
13
+ const LOCAL_BRIDGE_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
14
+ const LOCAL_BRIDGE_PACKAGE = JSON.parse(readFileSync(path.join(LOCAL_BRIDGE_DIR, 'package.json'), 'utf8'));
15
+
16
+ function wait(ms) {
17
+ return new Promise(resolve => setTimeout(resolve, ms));
18
+ }
19
+
20
+ async function findFreePort() {
21
+ return await new Promise((resolve, reject) => {
22
+ const server = net.createServer();
23
+ server.unref();
24
+ server.once('error', reject);
25
+ server.listen(0, '127.0.0.1', () => {
26
+ const address = server.address();
27
+ const port = typeof address === 'object' && address ? address.port : 0;
28
+ server.close(() => resolve(port));
29
+ });
30
+ });
31
+ }
32
+
33
+ async function fetchJson(url, options = {}) {
34
+ const response = await fetch(url, {
35
+ ...options,
36
+ headers: {
37
+ ...(options.body ? { 'Content-Type': 'application/json' } : {}),
38
+ ...(options.token ? { 'X-Bridge-Token': options.token } : {}),
39
+ ...(options.headers || {})
40
+ }
41
+ });
42
+
43
+ let payload = null;
44
+ try {
45
+ payload = await response.json();
46
+ } catch {
47
+ // Some failure responses may be empty.
48
+ }
49
+
50
+ return {
51
+ status: response.status,
52
+ ok: response.ok,
53
+ payload
54
+ };
55
+ }
56
+
57
+ async function fetchBinary(url, options = {}) {
58
+ const response = await fetch(url, {
59
+ ...options,
60
+ headers: {
61
+ Accept: 'image/png,image/jpeg,image/webp,image/*',
62
+ ...(options.token ? { 'X-Bridge-Token': options.token } : {}),
63
+ ...(options.headers || {})
64
+ }
65
+ });
66
+
67
+ return {
68
+ status: response.status,
69
+ ok: response.ok,
70
+ contentType: response.headers.get('content-type') || '',
71
+ frameSeq: response.headers.get('x-mindexec-remote-frame-seq') || '',
72
+ streamId: response.headers.get('x-mindexec-remote-stream-id') || '',
73
+ payload: Buffer.from(await response.arrayBuffer())
74
+ };
75
+ }
76
+
77
+ async function waitForBridge(baseUrl, getFailureDetails, bridgeToken = BRIDGE_TOKEN) {
78
+ const startedAt = Date.now();
79
+ while (Date.now() - startedAt < 30000) {
80
+ try {
81
+ const result = await fetchJson(`${baseUrl}/api/remote/status`, { token: bridgeToken });
82
+ if (result.ok && result.payload?.started === true) {
83
+ return result.payload;
84
+ }
85
+ } catch {
86
+ // Server is still starting.
87
+ }
88
+ await wait(100);
89
+ }
90
+
91
+ throw new Error(`Timed out waiting for LocalBridge RemoteHub HTTP API.\n${getFailureDetails()}`);
92
+ }
93
+
94
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
95
+ const bridgeRoot = path.resolve(__dirname, '..');
96
+
97
+ function spawnBridge({
98
+ bridgePort,
99
+ remoteHubPort,
100
+ bridgeToken = BRIDGE_TOKEN,
101
+ pairToken = PAIR_TOKEN,
102
+ syntheticFleetEnabled = false
103
+ }) {
104
+ const env = {
105
+ ...process.env,
106
+ BRIDGE_PORT: String(bridgePort),
107
+ BRIDGE_TOKEN: bridgeToken,
108
+ BRIDGE_REQUIRE_TOKEN: '1',
109
+ MINDEXEC_REMOTE_HUB: '1',
110
+ REMOTE_HUB_HOST: '127.0.0.1',
111
+ REMOTE_HUB_PORT: String(remoteHubPort),
112
+ REMOTE_HUB_PAIR_TOKEN: pairToken,
113
+ NO_COLOR: '1'
114
+ };
115
+
116
+ delete env.MINDEXEC_REMOTE_SYNTHETIC_FLEET;
117
+ delete env.REMOTE_HUB_SYNTHETIC_FLEET;
118
+ if (syntheticFleetEnabled) {
119
+ env.MINDEXEC_REMOTE_SYNTHETIC_FLEET = '1';
120
+ }
121
+
122
+ const child = spawn(process.execPath, ['server.js'], {
123
+ cwd: bridgeRoot,
124
+ stdio: ['ignore', 'pipe', 'pipe'],
125
+ windowsHide: true,
126
+ env
127
+ });
128
+
129
+ let stdout = '';
130
+ let stderr = '';
131
+ child.stdout.on('data', chunk => {
132
+ stdout += chunk.toString();
133
+ });
134
+ child.stderr.on('data', chunk => {
135
+ stderr += chunk.toString();
136
+ });
137
+
138
+ const exitPromise = new Promise(resolve => child.once('exit', resolve));
139
+ const details = () => `stdout=${stdout}\nstderr=${stderr}`;
140
+ const stop = async () => {
141
+ if (child.exitCode === null && !child.killed) {
142
+ child.kill('SIGTERM');
143
+ await Promise.race([
144
+ exitPromise,
145
+ wait(5000)
146
+ ]);
147
+ if (child.exitCode === null && !child.killed) {
148
+ child.kill('SIGKILL');
149
+ }
150
+ }
151
+ };
152
+
153
+ return {
154
+ baseUrl: `http://127.0.0.1:${bridgePort}`,
155
+ bridgePort,
156
+ remoteHubPort,
157
+ bridgeToken,
158
+ pairToken,
159
+ child,
160
+ details,
161
+ stop
162
+ };
163
+ }
164
+
165
+ async function runSyntheticEnabledSmoke() {
166
+ const bridgePort = await findFreePort();
167
+ const remoteHubPort = await findFreePort();
168
+ const bridge = spawnBridge({
169
+ bridgePort,
170
+ remoteHubPort,
171
+ syntheticFleetEnabled: true
172
+ });
173
+ const { baseUrl } = bridge;
174
+ const details = bridge.details;
175
+
176
+ try {
177
+ const status = await waitForBridge(baseUrl, details, bridge.bridgeToken);
178
+ assert.equal(status.started, true);
179
+ assert.equal(status.port, remoteHubPort);
180
+ assert.equal(status.managerPackage, '@mindexec/cli');
181
+ assert.equal(status.managerVersion, LOCAL_BRIDGE_PACKAGE.version);
182
+ assert.equal(status.agentPackage, '@mindexec/remote');
183
+ assert.equal(status.canvasPagination, 'none');
184
+ assert.equal(status.canvasDeviceListMode, 'all-devices');
185
+ assert.equal(status.hostTargetActive, false);
186
+ assert.equal(status.pairToken, PAIR_TOKEN);
187
+
188
+ const unauthorizedStatus = await fetchJson(`${baseUrl}/api/remote/status`);
189
+ assert.equal(unauthorizedStatus.status, 401);
190
+ assert.equal(unauthorizedStatus.payload?.header, 'X-Bridge-Token');
191
+
192
+ const unauthorizedDelete = await fetchJson(`${baseUrl}/api/remote/synthetic`, {
193
+ method: 'DELETE'
194
+ });
195
+ assert.equal(unauthorizedDelete.status, 401);
196
+
197
+ const unauthorizedHost = await fetchJson(`${baseUrl}/api/remote/host-target`, {
198
+ method: 'POST',
199
+ body: JSON.stringify({
200
+ nodeId: 'remote-fleet-host-unauthorized',
201
+ enabled: true
202
+ })
203
+ });
204
+ assert.equal(unauthorizedHost.status, 401);
205
+
206
+ const setHost = await fetchJson(`${baseUrl}/api/remote/host-target`, {
207
+ method: 'POST',
208
+ token: BRIDGE_TOKEN,
209
+ body: JSON.stringify({
210
+ nodeId: 'remote-fleet-monitor-a',
211
+ enabled: true,
212
+ leaseMs: 30000
213
+ })
214
+ });
215
+ assert.equal(setHost.ok, true, JSON.stringify(setHost.payload));
216
+ assert.equal(setHost.payload?.ok, true);
217
+ assert.equal(setHost.payload?.active, true);
218
+ assert.equal(setHost.payload?.hostTarget?.nodeId, 'remote-fleet-monitor-a');
219
+ assert.equal(setHost.payload?.hostTarget?.endpoint, `127.0.0.1:${remoteHubPort}`);
220
+ assert.deepEqual(setHost.payload?.hostTarget?.endpointCandidates, [`127.0.0.1:${remoteHubPort}`]);
221
+
222
+ const hostStatus = await fetchJson(`${baseUrl}/api/remote/status`, { token: BRIDGE_TOKEN });
223
+ assert.equal(hostStatus.ok, true, JSON.stringify(hostStatus.payload));
224
+ assert.equal(hostStatus.payload?.hostTargetActive, true);
225
+ assert.equal(hostStatus.payload?.hostTargetNodeId, 'remote-fleet-monitor-a');
226
+ assert.equal(hostStatus.payload?.hostTargetEndpoint, `127.0.0.1:${remoteHubPort}`);
227
+ assert.deepEqual(hostStatus.payload?.hostTargetEndpointCandidates, [`127.0.0.1:${remoteHubPort}`]);
228
+
229
+ const clearHostMismatch = await fetchJson(`${baseUrl}/api/remote/host-target`, {
230
+ method: 'DELETE',
231
+ token: BRIDGE_TOKEN,
232
+ body: JSON.stringify({
233
+ nodeId: 'remote-fleet-monitor-b'
234
+ })
235
+ });
236
+ assert.equal(clearHostMismatch.ok, true, JSON.stringify(clearHostMismatch.payload));
237
+ assert.equal(clearHostMismatch.payload?.ok, false);
238
+ assert.equal(clearHostMismatch.payload?.error, 'host-target-node-mismatch');
239
+
240
+ const clearHost = await fetchJson(`${baseUrl}/api/remote/host-target`, {
241
+ method: 'DELETE',
242
+ token: BRIDGE_TOKEN,
243
+ body: JSON.stringify({
244
+ nodeId: 'remote-fleet-monitor-a'
245
+ })
246
+ });
247
+ assert.equal(clearHost.ok, true, JSON.stringify(clearHost.payload));
248
+ assert.equal(clearHost.payload?.ok, true);
249
+ assert.equal(clearHost.payload?.active, false);
250
+
251
+ const seed = await fetchJson(`${baseUrl}/api/remote/synthetic/seed`, {
252
+ method: 'POST',
253
+ token: BRIDGE_TOKEN,
254
+ body: JSON.stringify({
255
+ count: SYNTHETIC_COUNT,
256
+ connectedRatio: 0.84,
257
+ thumbnailRatio: 0.72,
258
+ aiAssistRatio: 0.42,
259
+ liveCount: 8,
260
+ replace: true
261
+ })
262
+ });
263
+ assert.equal(seed.ok, true, JSON.stringify(seed.payload));
264
+ assert.equal(seed.payload?.ok, true);
265
+ assert.equal(seed.payload?.seeded, SYNTHETIC_COUNT);
266
+
267
+ const devicesResult = await fetchJson(`${baseUrl}/api/remote/devices`, { token: BRIDGE_TOKEN });
268
+ assert.equal(devicesResult.ok, true, JSON.stringify(devicesResult.payload));
269
+ assert.equal(devicesResult.payload?.total, SYNTHETIC_COUNT);
270
+ assert.equal(devicesResult.payload?.pagination, 'none');
271
+ assert.equal(devicesResult.payload?.canvasDeviceListMode, 'all-devices');
272
+ assert.equal(devicesResult.payload?.devices?.length, SYNTHETIC_COUNT);
273
+ assert.equal(devicesResult.payload.devices.some(device => device.connected === false), true);
274
+
275
+ const noControlTarget = devicesResult.payload.devices.find(device => device.connected);
276
+ assert.ok(noControlTarget);
277
+ const inputUnavailable = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(noControlTarget.deviceId)}/input`, {
278
+ method: 'POST',
279
+ token: BRIDGE_TOKEN,
280
+ body: JSON.stringify({
281
+ type: 'noop'
282
+ })
283
+ });
284
+ assert.equal(inputUnavailable.ok, true, JSON.stringify(inputUnavailable.payload));
285
+ assert.equal(inputUnavailable.payload?.ok, false);
286
+ assert.equal(inputUnavailable.payload?.error, 'device-input-control-unavailable');
287
+
288
+ const connectedTargets = devicesResult.payload.devices
289
+ .filter(device => device.connected && device.capabilities?.taskDispatch)
290
+ .slice(0, 500)
291
+ .map(device => device.deviceId);
292
+ assert.ok(connectedTargets.length >= 400);
293
+
294
+ const batch = await fetchJson(`${baseUrl}/api/remote/tasks`, {
295
+ method: 'POST',
296
+ token: BRIDGE_TOKEN,
297
+ body: JSON.stringify({
298
+ deviceIds: connectedTargets,
299
+ allConnected: false,
300
+ title: 'HTTP smoke task batch',
301
+ instruction: 'HTTP smoke batch: report current status to the manager.',
302
+ approvalLevel: 'task-only'
303
+ })
304
+ });
305
+ assert.equal(batch.ok, true, JSON.stringify(batch.payload));
306
+ assert.equal(batch.payload?.ok, true);
307
+ assert.equal(batch.payload?.total, connectedTargets.length);
308
+ assert.equal(batch.payload?.queued, connectedTargets.length);
309
+ assert.equal(batch.payload?.batch?.completed, connectedTargets.length);
310
+ assert.equal(batch.payload?.batch?.failed, 0);
311
+ assert.equal(batch.payload?.batch?.status, 'completed');
312
+
313
+ const aiTargets = devicesResult.payload.devices
314
+ .filter(device => device.connected && device.capabilities?.taskDispatch && device.capabilities?.aiAssist)
315
+ .map(device => device.deviceId);
316
+ assert.ok(aiTargets.length >= 200);
317
+ const allAiBatch = await fetchJson(`${baseUrl}/api/remote/tasks`, {
318
+ method: 'POST',
319
+ token: BRIDGE_TOKEN,
320
+ body: JSON.stringify({
321
+ allConnected: true,
322
+ title: 'HTTP smoke all AI task batch',
323
+ instruction: 'HTTP smoke AI batch: summarize fleet condition only on AI-capable agents.',
324
+ approvalLevel: 'ai-assist'
325
+ })
326
+ });
327
+ assert.equal(allAiBatch.ok, true, JSON.stringify(allAiBatch.payload));
328
+ assert.equal(allAiBatch.payload?.ok, true);
329
+ assert.equal(allAiBatch.payload?.approvalLevel, 'ai-assist');
330
+ assert.equal(allAiBatch.payload?.total, aiTargets.length);
331
+ assert.equal(allAiBatch.payload?.queued, aiTargets.length);
332
+ assert.equal(allAiBatch.payload?.batch?.completed, aiTargets.length);
333
+ assert.equal(allAiBatch.payload?.batch?.failed, 0);
334
+ assert.equal(allAiBatch.payload?.batch?.status, 'completed');
335
+ assert.deepEqual(
336
+ [...(allAiBatch.payload?.results || []).map(result => result.deviceId)].sort(),
337
+ [...aiTargets].sort());
338
+
339
+ const aiTarget = devicesResult.payload.devices.find(device =>
340
+ device.connected && device.capabilities?.taskDispatch && device.capabilities?.aiAssist);
341
+ assert.ok(aiTarget);
342
+ const aiTask = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(aiTarget.deviceId)}/tasks`, {
343
+ method: 'POST',
344
+ token: BRIDGE_TOKEN,
345
+ body: JSON.stringify({
346
+ title: 'HTTP smoke AI task',
347
+ instruction: 'HTTP smoke AI assist: summarize fleet condition.',
348
+ approvalLevel: 'ai-assist'
349
+ })
350
+ });
351
+ assert.equal(aiTask.ok, true, JSON.stringify(aiTask.payload));
352
+ assert.equal(aiTask.payload?.ok, true);
353
+ assert.equal(aiTask.payload?.approvalLevel, 'ai-assist');
354
+
355
+ const thumbnailTarget = devicesResult.payload.devices.find(device =>
356
+ device.connected && device.capabilities?.thumbnail);
357
+ assert.ok(thumbnailTarget);
358
+ const thumbnailRequest = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(thumbnailTarget.deviceId)}/thumbnail/request`, {
359
+ method: 'POST',
360
+ token: BRIDGE_TOKEN,
361
+ body: JSON.stringify({
362
+ streamId: 'http-smoke-thumb',
363
+ maxWidth: 360,
364
+ maxHeight: 220,
365
+ quality: 50
366
+ })
367
+ });
368
+ assert.equal(thumbnailRequest.ok, true, JSON.stringify(thumbnailRequest.payload));
369
+ assert.equal(thumbnailRequest.payload?.ok, true);
370
+
371
+ const thumbnail = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(thumbnailTarget.deviceId)}/thumbnail`, {
372
+ token: BRIDGE_TOKEN
373
+ });
374
+ assert.equal(thumbnail.ok, true, JSON.stringify(thumbnail.payload));
375
+ assert.equal(thumbnail.payload?.thumbnail?.streamId, 'http-smoke-thumb');
376
+ assert.ok(!('dataUrl' in thumbnail.payload.thumbnail));
377
+ assert.ok(String(thumbnail.payload?.thumbnail?.framePath || '').includes(`/api/remote/devices/${encodeURIComponent(thumbnailTarget.deviceId)}/thumbnail?`));
378
+ assert.equal(thumbnail.payload?.thumbnail?.frameUrl, thumbnail.payload?.thumbnail?.framePath);
379
+
380
+ const thumbnailWithData = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(thumbnailTarget.deviceId)}/thumbnail?includeDataUrl=true`, {
381
+ token: BRIDGE_TOKEN
382
+ });
383
+ assert.equal(thumbnailWithData.ok, true, JSON.stringify(thumbnailWithData.payload));
384
+ assert.ok(String(thumbnailWithData.payload?.thumbnail?.dataUrl || '').startsWith('data:image/png;base64,'));
385
+
386
+ const thumbnailBinary = await fetchBinary(`${baseUrl}${thumbnail.payload.thumbnail.framePath}`);
387
+ assert.equal(thumbnailBinary.ok, true, `${thumbnailBinary.status} ${thumbnailBinary.contentType}`);
388
+ assert.equal(thumbnailBinary.contentType, 'image/png');
389
+ assert.equal(thumbnailBinary.streamId, 'http-smoke-thumb');
390
+ assert.ok(thumbnailBinary.payload.length > 0);
391
+
392
+ const badThumbnailBinary = await fetchBinary(`${baseUrl}${thumbnail.payload.thumbnail.framePath.replace(/token=[^&]+/, 'token=wrong-token')}`);
393
+ assert.equal(badThumbnailBinary.status, 401);
394
+
395
+ const devicesUrlOnlyResult = await fetchJson(`${baseUrl}/api/remote/devices?frameData=url`, { token: BRIDGE_TOKEN });
396
+ assert.equal(devicesUrlOnlyResult.ok, true, JSON.stringify(devicesUrlOnlyResult.payload));
397
+ const urlOnlyThumbnailDevice = devicesUrlOnlyResult.payload?.devices?.find(device => device.deviceId === thumbnailTarget.deviceId);
398
+ assert.ok(urlOnlyThumbnailDevice?.latestThumbnail?.framePath);
399
+ assert.ok(!('dataUrl' in urlOnlyThumbnailDevice.latestThumbnail));
400
+
401
+ const thumbnailFramesOnly = await fetchJson(`${baseUrl}/api/remote/frames`, {
402
+ method: 'POST',
403
+ token: BRIDGE_TOKEN,
404
+ body: JSON.stringify({
405
+ deviceIds: [thumbnailTarget.deviceId],
406
+ includeThumbnail: true,
407
+ includeLive: true
408
+ })
409
+ });
410
+ assert.equal(thumbnailFramesOnly.ok, true, JSON.stringify(thumbnailFramesOnly.payload));
411
+ assert.equal(thumbnailFramesOnly.payload?.ok, true);
412
+ assert.equal(thumbnailFramesOnly.payload?.frames?.length, 1);
413
+ assert.equal(thumbnailFramesOnly.payload.frames[0].deviceId, thumbnailTarget.deviceId);
414
+ assert.equal(thumbnailFramesOnly.payload.frames[0].thumbnailEnabled, true);
415
+ assert.ok(String(thumbnailFramesOnly.payload.frames[0].thumbnail?.framePath || '').includes(`/api/remote/devices/${encodeURIComponent(thumbnailTarget.deviceId)}/thumbnail?`));
416
+ assert.ok(!('dataUrl' in thumbnailFramesOnly.payload.frames[0].thumbnail));
417
+
418
+ const liveTarget = devicesResult.payload.devices.find(device =>
419
+ device.connected && device.capabilities?.liveStream);
420
+ assert.ok(liveTarget);
421
+ const liveStart = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(liveTarget.deviceId)}/live/start`, {
422
+ method: 'POST',
423
+ token: BRIDGE_TOKEN,
424
+ body: JSON.stringify({
425
+ streamId: 'http-smoke-live',
426
+ fps: 20,
427
+ maxWidth: 960,
428
+ maxHeight: 540,
429
+ quality: 60
430
+ })
431
+ });
432
+ assert.equal(liveStart.ok, true, JSON.stringify(liveStart.payload));
433
+ assert.equal(liveStart.payload?.ok, true);
434
+
435
+ const liveFrame = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(liveTarget.deviceId)}/live/frame`, {
436
+ token: BRIDGE_TOKEN
437
+ });
438
+ assert.equal(liveFrame.ok, true, JSON.stringify(liveFrame.payload));
439
+ assert.equal(liveFrame.payload?.frame?.streamId, 'http-smoke-live');
440
+ assert.equal(liveFrame.payload?.frame?.mode, 'remote-fast');
441
+ assert.equal(liveFrame.payload?.frame?.fps, 20);
442
+ assert.ok(!('dataUrl' in liveFrame.payload.frame));
443
+ assert.ok(String(liveFrame.payload?.frame?.framePath || '').includes(`/api/remote/devices/${encodeURIComponent(liveTarget.deviceId)}/live/frame?`));
444
+
445
+ const liveFrameWithData = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(liveTarget.deviceId)}/live/frame?includeDataUrl=true`, {
446
+ token: BRIDGE_TOKEN
447
+ });
448
+ assert.equal(liveFrameWithData.ok, true, JSON.stringify(liveFrameWithData.payload));
449
+ assert.ok(String(liveFrameWithData.payload?.frame?.dataUrl || '').startsWith('data:image/png;base64,'));
450
+
451
+ const liveBinary = await fetchBinary(`${baseUrl}${liveFrame.payload.frame.framePath}`);
452
+ assert.equal(liveBinary.ok, true, `${liveBinary.status} ${liveBinary.contentType}`);
453
+ assert.equal(liveBinary.contentType, 'image/png');
454
+ assert.equal(liveBinary.streamId, 'http-smoke-live');
455
+ assert.ok(liveBinary.payload.length > 0);
456
+
457
+ const liveBinaryWithBridgeToken = await fetchBinary(
458
+ `${baseUrl}/api/remote/devices/${encodeURIComponent(liveTarget.deviceId)}/live/frame?format=binary`,
459
+ { token: BRIDGE_TOKEN });
460
+ assert.equal(liveBinaryWithBridgeToken.ok, true, `${liveBinaryWithBridgeToken.status} ${liveBinaryWithBridgeToken.contentType}`);
461
+ assert.equal(liveBinaryWithBridgeToken.contentType, 'image/png');
462
+
463
+ const badLiveSeq = await fetchBinary(`${baseUrl}${liveFrame.payload.frame.framePath.replace(/seq=\d+/, 'seq=999999')}`);
464
+ assert.equal(badLiveSeq.status, 401);
465
+
466
+ const liveFramesOnly = await fetchJson(`${baseUrl}/api/remote/frames`, {
467
+ method: 'POST',
468
+ token: BRIDGE_TOKEN,
469
+ body: JSON.stringify({
470
+ deviceIds: [liveTarget.deviceId],
471
+ includeThumbnail: true,
472
+ includeLive: true
473
+ })
474
+ });
475
+ assert.equal(liveFramesOnly.ok, true, JSON.stringify(liveFramesOnly.payload));
476
+ assert.equal(liveFramesOnly.payload?.ok, true);
477
+ assert.equal(liveFramesOnly.payload?.frames?.length, 1);
478
+ assert.equal(liveFramesOnly.payload.frames[0].deviceId, liveTarget.deviceId);
479
+ assert.equal(liveFramesOnly.payload.frames[0].liveStreamActive, true);
480
+ assert.ok(String(liveFramesOnly.payload.frames[0].live?.framePath || '').includes(`/api/remote/devices/${encodeURIComponent(liveTarget.deviceId)}/live/frame?`));
481
+ assert.ok(!('dataUrl' in liveFramesOnly.payload.frames[0].live));
482
+
483
+ const liveStop = await fetchJson(`${baseUrl}/api/remote/devices/${encodeURIComponent(liveTarget.deviceId)}/live/stop`, {
484
+ method: 'POST',
485
+ token: BRIDGE_TOKEN,
486
+ body: JSON.stringify({
487
+ streamId: 'http-smoke-live'
488
+ })
489
+ });
490
+ assert.equal(liveStop.ok, true, JSON.stringify(liveStop.payload));
491
+ assert.equal(liveStop.payload?.ok, true);
492
+
493
+ const clear = await fetchJson(`${baseUrl}/api/remote/synthetic`, {
494
+ method: 'DELETE',
495
+ token: BRIDGE_TOKEN
496
+ });
497
+ assert.equal(clear.ok, true, JSON.stringify(clear.payload));
498
+ assert.equal(clear.payload?.ok, true);
499
+ assert.equal(clear.payload?.removed, SYNTHETIC_COUNT);
500
+
501
+ console.log(`RemoteHub HTTP smoke OK (${SYNTHETIC_COUNT} synthetic devices, bridge ${bridgePort}, remote ${remoteHubPort})`);
502
+ } finally {
503
+ await bridge.stop();
504
+ }
505
+ }
506
+
507
+ async function runSyntheticDisabledSmoke() {
508
+ const bridgePort = await findFreePort();
509
+ const remoteHubPort = await findFreePort();
510
+ const bridgeToken = `${BRIDGE_TOKEN}-disabled`;
511
+ const pairToken = `${PAIR_TOKEN}-disabled`;
512
+ const bridge = spawnBridge({
513
+ bridgePort,
514
+ remoteHubPort,
515
+ bridgeToken,
516
+ pairToken,
517
+ syntheticFleetEnabled: false
518
+ });
519
+ const { baseUrl } = bridge;
520
+
521
+ try {
522
+ const status = await waitForBridge(baseUrl, bridge.details, bridge.bridgeToken);
523
+ assert.equal(status.started, true);
524
+ assert.equal(status.port, remoteHubPort);
525
+ assert.equal(status.pairToken, pairToken);
526
+ assert.equal(status.canvasPagination, 'none');
527
+ assert.equal(status.canvasDeviceListMode, 'all-devices');
528
+ assert.equal(status.hostTargetActive, false);
529
+
530
+ const seedDenied = await fetchJson(`${baseUrl}/api/remote/synthetic/seed`, {
531
+ method: 'POST',
532
+ token: bridge.bridgeToken,
533
+ body: JSON.stringify({
534
+ count: 3,
535
+ replace: true
536
+ })
537
+ });
538
+ assert.equal(seedDenied.status, 403);
539
+ assert.equal(seedDenied.payload?.ok, false);
540
+ assert.equal(seedDenied.payload?.error, 'synthetic-fleet-disabled');
541
+
542
+ const clearDenied = await fetchJson(`${baseUrl}/api/remote/synthetic`, {
543
+ method: 'DELETE',
544
+ token: bridge.bridgeToken
545
+ });
546
+ assert.equal(clearDenied.status, 403);
547
+ assert.equal(clearDenied.payload?.ok, false);
548
+ assert.equal(clearDenied.payload?.error, 'synthetic-fleet-disabled');
549
+
550
+ const devicesResult = await fetchJson(`${baseUrl}/api/remote/devices`, { token: bridge.bridgeToken });
551
+ assert.equal(devicesResult.ok, true, JSON.stringify(devicesResult.payload));
552
+ assert.equal(devicesResult.payload?.total, 0);
553
+ assert.equal(devicesResult.payload?.pagination, 'none');
554
+ assert.equal(devicesResult.payload?.canvasDeviceListMode, 'all-devices');
555
+ assert.equal(devicesResult.payload?.devices?.length, 0);
556
+
557
+ const emptyBatch = await fetchJson(`${baseUrl}/api/remote/tasks`, {
558
+ method: 'POST',
559
+ token: bridge.bridgeToken,
560
+ body: JSON.stringify({
561
+ allConnected: true,
562
+ title: 'HTTP smoke no target batch',
563
+ instruction: 'This should not queue because no remote devices are connected.',
564
+ approvalLevel: 'task-only'
565
+ })
566
+ });
567
+ assert.equal(emptyBatch.ok, true, JSON.stringify(emptyBatch.payload));
568
+ assert.equal(emptyBatch.payload?.ok, false);
569
+ assert.equal(emptyBatch.payload?.total, 0);
570
+ assert.equal(emptyBatch.payload?.queued, 0);
571
+ assert.equal(emptyBatch.payload?.error, 'no-target-devices');
572
+
573
+ const hostTarget = await fetchJson(`${baseUrl}/api/remote/host-target`, {
574
+ method: 'POST',
575
+ token: bridge.bridgeToken,
576
+ body: JSON.stringify({
577
+ nodeId: 'disabled-synthetic-host',
578
+ enabled: true
579
+ })
580
+ });
581
+ assert.equal(hostTarget.ok, true, JSON.stringify(hostTarget.payload));
582
+ assert.equal(hostTarget.payload?.ok, true);
583
+ assert.equal(hostTarget.payload?.active, true);
584
+
585
+ console.log(`RemoteHub HTTP safety smoke OK (synthetic disabled, bridge ${bridgePort}, remote ${remoteHubPort})`);
586
+ } finally {
587
+ await bridge.stop();
588
+ }
589
+ }
590
+
591
+ await runSyntheticEnabledSmoke();
592
+ await runSyntheticDisabledSmoke();