amalgm 0.1.56 → 0.1.57
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/lib/cli.js +30 -0
- package/lib/paths.js +3 -1
- package/lib/tunnel-chat.js +7 -1
- package/lib/tunnel-events.js +10 -1
- package/package.json +1 -1
package/lib/cli.js
CHANGED
|
@@ -12,6 +12,7 @@ const { spawn, spawnSync } = require('child_process');
|
|
|
12
12
|
const {
|
|
13
13
|
AMALGM_DIR,
|
|
14
14
|
AMALGM_BRANCH,
|
|
15
|
+
AMALGM_HOME,
|
|
15
16
|
DEFAULT_APP_URL,
|
|
16
17
|
DEVICE_FILE,
|
|
17
18
|
LOG_DIR,
|
|
@@ -271,6 +272,27 @@ async function ensureDevice() {
|
|
|
271
272
|
return existing;
|
|
272
273
|
}
|
|
273
274
|
|
|
275
|
+
const candidates = [
|
|
276
|
+
path.join(AMALGM_HOME, 'device.json'),
|
|
277
|
+
path.join(AMALGM_DIR, 'device.json'),
|
|
278
|
+
path.join(AMALGM_HOME, 'computer.json'),
|
|
279
|
+
path.join(AMALGM_DIR, 'computer.json'),
|
|
280
|
+
];
|
|
281
|
+
for (const candidate of candidates) {
|
|
282
|
+
if (path.resolve(candidate) === path.resolve(DEVICE_FILE)) continue;
|
|
283
|
+
const found = readJson(candidate, null);
|
|
284
|
+
if (found && typeof found.device_id === 'string' && found.device_id.length >= 8) {
|
|
285
|
+
const migrated = {
|
|
286
|
+
device_id: found.device_id,
|
|
287
|
+
created_at: typeof found.created_at === 'string' ? found.created_at : new Date().toISOString(),
|
|
288
|
+
migrated_from: candidate,
|
|
289
|
+
migrated_at: new Date().toISOString(),
|
|
290
|
+
};
|
|
291
|
+
writeJsonSecret(DEVICE_FILE, migrated);
|
|
292
|
+
return migrated;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
274
296
|
const device = {
|
|
275
297
|
device_id: `npm-${crypto.randomUUID()}`,
|
|
276
298
|
created_at: new Date().toISOString(),
|
|
@@ -515,6 +537,8 @@ async function registerComputer(appUrl, registrationToken, device, name) {
|
|
|
515
537
|
name,
|
|
516
538
|
platform: platformName(),
|
|
517
539
|
app_version: PACKAGE_VERSION,
|
|
540
|
+
runtime_label: AMALGM_RUNTIME_LABEL,
|
|
541
|
+
branch: AMALGM_BRANCH,
|
|
518
542
|
}),
|
|
519
543
|
});
|
|
520
544
|
|
|
@@ -578,6 +602,8 @@ async function loginWithSetupCode(appUrl, setupCode, device, name) {
|
|
|
578
602
|
name,
|
|
579
603
|
platform: platformName(),
|
|
580
604
|
app_version: PACKAGE_VERSION,
|
|
605
|
+
runtime_label: AMALGM_RUNTIME_LABEL,
|
|
606
|
+
branch: AMALGM_BRANCH,
|
|
581
607
|
}),
|
|
582
608
|
});
|
|
583
609
|
|
|
@@ -629,6 +655,8 @@ async function startCliLogin(appUrl, device, name, options) {
|
|
|
629
655
|
name,
|
|
630
656
|
platform: platformName(),
|
|
631
657
|
app_version: PACKAGE_VERSION,
|
|
658
|
+
runtime_label: AMALGM_RUNTIME_LABEL,
|
|
659
|
+
branch: AMALGM_BRANCH,
|
|
632
660
|
}),
|
|
633
661
|
});
|
|
634
662
|
|
|
@@ -677,6 +705,8 @@ async function startCliLogin(appUrl, device, name, options) {
|
|
|
677
705
|
name,
|
|
678
706
|
platform: platformName(),
|
|
679
707
|
app_version: PACKAGE_VERSION,
|
|
708
|
+
runtime_label: AMALGM_RUNTIME_LABEL,
|
|
709
|
+
branch: AMALGM_BRANCH,
|
|
680
710
|
}),
|
|
681
711
|
});
|
|
682
712
|
} catch (error) {
|
package/lib/paths.js
CHANGED
|
@@ -28,7 +28,9 @@ const AMALGM_DIR = process.env.AMALGM_DIR
|
|
|
28
28
|
: scopedAmalgmDir(AMALGM_HOME, AMALGM_RUNTIME_USER_SCOPE, AMALGM_RUNTIME_LABEL);
|
|
29
29
|
const AMALGM_RUNTIME_INSTANCE_ID = process.env.AMALGM_RUNTIME_INSTANCE_ID
|
|
30
30
|
|| runtimeInstanceIdForDir(AMALGM_DIR);
|
|
31
|
-
|
|
31
|
+
// Physical machine identity is intentionally shared across runtime labels.
|
|
32
|
+
// Runtime credentials/state below remain scoped by user + label.
|
|
33
|
+
const DEVICE_FILE = path.join(AMALGM_HOME, 'device.json');
|
|
32
34
|
const COMPUTER_FILE = path.join(AMALGM_DIR, 'computer.json');
|
|
33
35
|
const AUTH_FILE = path.join(AMALGM_DIR, 'auth.json');
|
|
34
36
|
const RUNTIME_TOKEN_FILE = path.join(AMALGM_DIR, 'runtime-token.json');
|
package/lib/tunnel-chat.js
CHANGED
|
@@ -4,7 +4,11 @@ const http = require('http');
|
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const os = require('os');
|
|
6
6
|
const { WebSocket } = require('ws');
|
|
7
|
-
const {
|
|
7
|
+
const {
|
|
8
|
+
AMALGM_BRANCH,
|
|
9
|
+
AMALGM_RUNTIME_LABEL,
|
|
10
|
+
RUNTIME_STATE_FILE,
|
|
11
|
+
} = require('./paths');
|
|
8
12
|
const { runtimePort, runtimeServiceByName } = require('./runtime-manifest');
|
|
9
13
|
|
|
10
14
|
const DEFAULT_TARGET_PORT = runtimeServiceByName('chat-server').defaultPort;
|
|
@@ -157,6 +161,8 @@ function createChatTunnel({ record, foreground = false }) {
|
|
|
157
161
|
send({
|
|
158
162
|
type: 'hello',
|
|
159
163
|
app_version: require('../package.json').version,
|
|
164
|
+
runtime_label: record.runtime_label || AMALGM_RUNTIME_LABEL,
|
|
165
|
+
branch: record.branch || AMALGM_BRANCH,
|
|
160
166
|
runtime_gateway_port: runtimeGatewayPort(),
|
|
161
167
|
});
|
|
162
168
|
|
package/lib/tunnel-events.js
CHANGED
|
@@ -6,7 +6,12 @@ const os = require('os');
|
|
|
6
6
|
const path = require('path');
|
|
7
7
|
const { WebSocket } = require('ws');
|
|
8
8
|
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
AMALGM_BRANCH,
|
|
11
|
+
AMALGM_DIR,
|
|
12
|
+
AMALGM_RUNTIME_LABEL,
|
|
13
|
+
RUNTIME_STATE_FILE,
|
|
14
|
+
} = require('./paths');
|
|
10
15
|
const { runtimePort, runtimeServiceByName } = require('./runtime-manifest');
|
|
11
16
|
|
|
12
17
|
const DEFAULT_TARGET_PORT = runtimeServiceByName('amalgm-mcp').defaultPort;
|
|
@@ -66,6 +71,8 @@ async function postPresence(record, online) {
|
|
|
66
71
|
body: JSON.stringify({
|
|
67
72
|
computer_id: record.computer_id,
|
|
68
73
|
device_id: record.device_id || '',
|
|
74
|
+
runtime_label: record.runtime_label || AMALGM_RUNTIME_LABEL,
|
|
75
|
+
branch: record.branch || AMALGM_BRANCH,
|
|
69
76
|
online,
|
|
70
77
|
}),
|
|
71
78
|
});
|
|
@@ -275,6 +282,8 @@ function createEventTunnel({ record, foreground = false }) {
|
|
|
275
282
|
send({
|
|
276
283
|
type: 'hello',
|
|
277
284
|
app_version: require('../package.json').version,
|
|
285
|
+
runtime_label: record.runtime_label || AMALGM_RUNTIME_LABEL,
|
|
286
|
+
branch: record.branch || AMALGM_BRANCH,
|
|
278
287
|
runtime_gateway_port: runtimeGatewayPort(),
|
|
279
288
|
app_routes: appRoutes,
|
|
280
289
|
artifact_routes: legacyArtifactRoutes(appRoutes),
|