@livedesk/client 0.1.18 → 0.1.20
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/bin/livedesk-client-node.js +18 -4
- package/bin/livedesk-client.js +57 -26
- package/fast/linux-x64/mindexec-remote-fast +0 -0
- package/fast/linux-x64/mindexec-remote-fast.deps.json +24 -0
- package/fast/linux-x64/mindexec-remote-fast.dll +0 -0
- package/fast/linux-x64/mindexec-remote-fast.pdb +0 -0
- package/fast/linux-x64/mindexec-remote-fast.runtimeconfig.json +13 -0
- package/fast/osx-arm64/mindexec-remote-fast.dll +0 -0
- package/fast/osx-arm64/mindexec-remote-fast.pdb +0 -0
- package/fast/osx-x64/mindexec-remote-fast.dll +0 -0
- package/fast/osx-x64/mindexec-remote-fast.pdb +0 -0
- package/fast/win-x64/mindexec-remote-fast.dll +0 -0
- package/fast/win-x64/mindexec-remote-fast.pdb +0 -0
- package/package.json +1 -1
|
@@ -6,9 +6,11 @@ import path from 'path';
|
|
|
6
6
|
import crypto from 'crypto';
|
|
7
7
|
import { promises as fs, statfsSync } from 'fs';
|
|
8
8
|
|
|
9
|
-
const AGENT_VERSION = '0.1.
|
|
9
|
+
const AGENT_VERSION = '0.1.20-livedesk.1';
|
|
10
10
|
const DEFAULT_MANAGER = '127.0.0.1:5197';
|
|
11
11
|
const DEFAULT_HEARTBEAT_MS = 5000;
|
|
12
|
+
const DEFAULT_RECONNECT_MS = 5000;
|
|
13
|
+
const EXIT_INVALID_PAIR_TOKEN = 23;
|
|
12
14
|
const DEFAULT_AI_MODEL = 'gpt-5.4-mini';
|
|
13
15
|
const DEFAULT_LIVE_FPS = 20;
|
|
14
16
|
const MAX_LIVE_FPS = 24;
|
|
@@ -44,6 +46,7 @@ Options:
|
|
|
44
46
|
--fake-ai Use deterministic AI assist responses for smoke tests.
|
|
45
47
|
--fake-thumbnail Use generated thumbnail frames for smoke tests.
|
|
46
48
|
--exit-on-disconnect Exit after manager disconnect. Useful for tests.
|
|
49
|
+
--exit-on-invalid-pair Exit when the manager rejects the pair token.
|
|
47
50
|
--once Connect, send one status packet, and exit after welcome.
|
|
48
51
|
--version Show the agent version.
|
|
49
52
|
--help Show this help.
|
|
@@ -90,6 +93,7 @@ function parseArgs(argv) {
|
|
|
90
93
|
fakeAi: isTruthy(process.env.LIVEDESK_CLIENT_FAKE_AI || process.env.MINDEXEC_REMOTE_FAKE_AI),
|
|
91
94
|
fakeThumbnail: isTruthy(process.env.LIVEDESK_CLIENT_FAKE_THUMBNAIL || process.env.MINDEXEC_REMOTE_FAKE_THUMBNAIL),
|
|
92
95
|
exitOnDisconnect: false,
|
|
96
|
+
exitOnInvalidPair: false,
|
|
93
97
|
once: false,
|
|
94
98
|
version: false,
|
|
95
99
|
help: false
|
|
@@ -164,6 +168,9 @@ function parseArgs(argv) {
|
|
|
164
168
|
case '--exit-on-disconnect':
|
|
165
169
|
result.exitOnDisconnect = true;
|
|
166
170
|
break;
|
|
171
|
+
case '--exit-on-invalid-pair':
|
|
172
|
+
result.exitOnInvalidPair = true;
|
|
173
|
+
break;
|
|
167
174
|
case '--once':
|
|
168
175
|
result.once = true;
|
|
169
176
|
break;
|
|
@@ -1106,7 +1113,11 @@ function connectOnce(options, deviceId) {
|
|
|
1106
1113
|
finish();
|
|
1107
1114
|
return;
|
|
1108
1115
|
} else if (message.type === 'error') {
|
|
1109
|
-
|
|
1116
|
+
const remoteError = new Error(message.error || 'RemoteHub rejected the connection.');
|
|
1117
|
+
if (message.error === 'invalid-pair-token' && options.exitOnInvalidPair) {
|
|
1118
|
+
remoteError.exitCode = EXIT_INVALID_PAIR_TOKEN;
|
|
1119
|
+
}
|
|
1120
|
+
finish(remoteError);
|
|
1110
1121
|
return;
|
|
1111
1122
|
}
|
|
1112
1123
|
}
|
|
@@ -1143,7 +1154,10 @@ async function connectWithRetry(options) {
|
|
|
1143
1154
|
attempt = 0;
|
|
1144
1155
|
} catch (err) {
|
|
1145
1156
|
attempt += 1;
|
|
1146
|
-
|
|
1157
|
+
if (err?.exitCode === EXIT_INVALID_PAIR_TOKEN) {
|
|
1158
|
+
throw err;
|
|
1159
|
+
}
|
|
1160
|
+
const delayMs = DEFAULT_RECONNECT_MS;
|
|
1147
1161
|
console.error(`RemoteHub connection failed: ${err?.message || err}. Retrying in ${delayMs}ms.`);
|
|
1148
1162
|
await wait(delayMs);
|
|
1149
1163
|
}
|
|
@@ -1171,5 +1185,5 @@ async function main() {
|
|
|
1171
1185
|
|
|
1172
1186
|
main().catch(err => {
|
|
1173
1187
|
console.error(err?.message || err);
|
|
1174
|
-
process.exit(1);
|
|
1188
|
+
process.exit(Number.isInteger(err?.exitCode) ? err.exitCode : 1);
|
|
1175
1189
|
});
|
package/bin/livedesk-client.js
CHANGED
|
@@ -15,6 +15,8 @@ const FAST_PREFLIGHT_TIMEOUT_MS = 5000;
|
|
|
15
15
|
const DEFAULT_MANAGER = '127.0.0.1:5197';
|
|
16
16
|
const DEFAULT_AUTH_CALLBACK_HOST = '127.0.0.1';
|
|
17
17
|
const DEFAULT_AUTH_CALLBACK_PORT = 5198;
|
|
18
|
+
const DISCOVERY_RETRY_MS = 5000;
|
|
19
|
+
const EXIT_INVALID_PAIR_TOKEN = 23;
|
|
18
20
|
const SUPABASE_URL = process.env.LIVEDESK_SUPABASE_URL || 'https://otbyfkjxrkngvjziawki.supabase.co';
|
|
19
21
|
const SUPABASE_PUBLISHABLE_KEY = process.env.LIVEDESK_SUPABASE_PUBLISHABLE_KEY || 'sb_publishable_NpUs0RDJH2YnllsqTKO6TQ_1jTdSsNQ';
|
|
20
22
|
const CLIENT_STATE_DIR = join(os.homedir(), '.livedesk-client');
|
|
@@ -233,6 +235,13 @@ function upsertForwardedOption(args, flag, value) {
|
|
|
233
235
|
return next;
|
|
234
236
|
}
|
|
235
237
|
|
|
238
|
+
function appendForwardedFlag(args, flag) {
|
|
239
|
+
if (args.includes(flag)) {
|
|
240
|
+
return args;
|
|
241
|
+
}
|
|
242
|
+
return [...args, flag];
|
|
243
|
+
}
|
|
244
|
+
|
|
236
245
|
function createFileStorage(filePath) {
|
|
237
246
|
function readState() {
|
|
238
247
|
try {
|
|
@@ -611,12 +620,16 @@ async function prepareLoginConnection(parsed) {
|
|
|
611
620
|
if (slot) {
|
|
612
621
|
forwarded = upsertForwardedOption(forwarded, '--slot', slot);
|
|
613
622
|
}
|
|
623
|
+
if (shouldLogin) {
|
|
624
|
+
forwarded = appendForwardedFlag(forwarded, '--exit-on-invalid-pair');
|
|
625
|
+
}
|
|
614
626
|
return {
|
|
615
627
|
...parsed,
|
|
616
628
|
manager,
|
|
617
629
|
pair,
|
|
618
630
|
slot,
|
|
619
|
-
forwarded
|
|
631
|
+
forwarded,
|
|
632
|
+
rediscoverOnInvalidPair: shouldLogin
|
|
620
633
|
};
|
|
621
634
|
}
|
|
622
635
|
|
|
@@ -644,6 +657,13 @@ function getFastRuntime() {
|
|
|
644
657
|
dll: join(packageRoot, 'fast', 'osx-x64', 'mindexec-remote-fast.dll')
|
|
645
658
|
};
|
|
646
659
|
}
|
|
660
|
+
if (platform === 'linux' && arch === 'x64') {
|
|
661
|
+
return {
|
|
662
|
+
rid: 'linux-x64',
|
|
663
|
+
executable: join(packageRoot, 'fast', 'linux-x64', 'mindexec-remote-fast'),
|
|
664
|
+
dll: join(packageRoot, 'fast', 'linux-x64', 'mindexec-remote-fast.dll')
|
|
665
|
+
};
|
|
666
|
+
}
|
|
647
667
|
|
|
648
668
|
return null;
|
|
649
669
|
}
|
|
@@ -792,16 +812,14 @@ function spawnAgent(command, args) {
|
|
|
792
812
|
windowsHide: true
|
|
793
813
|
});
|
|
794
814
|
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
}
|
|
804
|
-
process.exit(code ?? 0);
|
|
815
|
+
return new Promise(resolve => {
|
|
816
|
+
child.once('error', error => {
|
|
817
|
+
console.error(`Failed to launch ${command}: ${error.message}`);
|
|
818
|
+
resolve({ code: 1, signal: null });
|
|
819
|
+
});
|
|
820
|
+
child.once('exit', (code, signal) => {
|
|
821
|
+
resolve({ code: code ?? 0, signal });
|
|
822
|
+
});
|
|
805
823
|
});
|
|
806
824
|
}
|
|
807
825
|
|
|
@@ -833,23 +851,36 @@ async function main() {
|
|
|
833
851
|
return;
|
|
834
852
|
}
|
|
835
853
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
854
|
+
while (true) {
|
|
855
|
+
const prepared = await prepareLoginConnection(parsed);
|
|
856
|
+
const fastRuntime = getFastRuntime();
|
|
857
|
+
const useFast = shouldTryFast(prepared, fastRuntime);
|
|
858
|
+
let result;
|
|
859
|
+
if (useFast) {
|
|
860
|
+
const fastArgs = buildFastArgs(prepared.forwarded, prepared.fakeThumbnail);
|
|
861
|
+
const fastLaunch = resolveFastLaunch(fastRuntime);
|
|
862
|
+
if (fastLaunch.ok) {
|
|
863
|
+
result = await spawnAgent(fastLaunch.command, [...fastLaunch.argsPrefix, ...fastArgs]);
|
|
864
|
+
} else if (prepared.engine === 'fast') {
|
|
865
|
+
console.error(`C# RemoteFast is unavailable: ${fastLaunch.reason}. Use --engine node to run the legacy Node agent.`);
|
|
866
|
+
process.exit(2);
|
|
867
|
+
} else {
|
|
868
|
+
console.warn(`C# RemoteFast is unavailable (${fastLaunch.reason}). Falling back to the Node remote agent.`);
|
|
869
|
+
result = await spawnAgent(process.execPath, [nodeAgentPath, ...prepared.forwarded]);
|
|
870
|
+
}
|
|
847
871
|
} else {
|
|
848
|
-
|
|
849
|
-
|
|
872
|
+
result = await spawnAgent(process.execPath, [nodeAgentPath, ...prepared.forwarded]);
|
|
873
|
+
}
|
|
874
|
+
if (result?.signal) {
|
|
875
|
+
process.kill(process.pid, result.signal);
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
if (prepared.rediscoverOnInvalidPair && result?.code === EXIT_INVALID_PAIR_TOKEN) {
|
|
879
|
+
console.error(`LiveDesk manager pair token changed. Refreshing manager discovery in ${DISCOVERY_RETRY_MS}ms.`);
|
|
880
|
+
await sleep(DISCOVERY_RETRY_MS);
|
|
881
|
+
continue;
|
|
850
882
|
}
|
|
851
|
-
|
|
852
|
-
spawnAgent(process.execPath, [nodeAgentPath, ...prepared.forwarded]);
|
|
883
|
+
process.exit(result?.code ?? 0);
|
|
853
884
|
}
|
|
854
885
|
}
|
|
855
886
|
|
|
Binary file
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"runtimeTarget": {
|
|
3
|
+
"name": ".NETCoreApp,Version=v9.0/linux-x64",
|
|
4
|
+
"signature": ""
|
|
5
|
+
},
|
|
6
|
+
"compilationOptions": {},
|
|
7
|
+
"targets": {
|
|
8
|
+
".NETCoreApp,Version=v9.0": {},
|
|
9
|
+
".NETCoreApp,Version=v9.0/linux-x64": {
|
|
10
|
+
"mindexec-remote-fast/1.0.0": {
|
|
11
|
+
"runtime": {
|
|
12
|
+
"mindexec-remote-fast.dll": {}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"libraries": {
|
|
18
|
+
"mindexec-remote-fast/1.0.0": {
|
|
19
|
+
"type": "project",
|
|
20
|
+
"serviceable": false,
|
|
21
|
+
"sha512": ""
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"runtimeOptions": {
|
|
3
|
+
"tfm": "net9.0",
|
|
4
|
+
"framework": {
|
|
5
|
+
"name": "Microsoft.NETCore.App",
|
|
6
|
+
"version": "9.0.0"
|
|
7
|
+
},
|
|
8
|
+
"configProperties": {
|
|
9
|
+
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
|
|
10
|
+
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|