opencara 0.100.1 → 0.100.3
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/dist/bin.js +7 -17
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -5,16 +5,14 @@ import {
|
|
|
5
5
|
arch,
|
|
6
6
|
cpus,
|
|
7
7
|
freemem,
|
|
8
|
-
hostname,
|
|
8
|
+
hostname as hostname2,
|
|
9
9
|
networkInterfaces,
|
|
10
10
|
platform,
|
|
11
11
|
release,
|
|
12
12
|
totalmem,
|
|
13
13
|
uptime
|
|
14
14
|
} from "node:os";
|
|
15
|
-
import {
|
|
16
|
-
import { dirname, join as join2 } from "node:path";
|
|
17
|
-
import { fileURLToPath } from "node:url";
|
|
15
|
+
import { statfsSync } from "node:fs";
|
|
18
16
|
|
|
19
17
|
// src/config/store.ts
|
|
20
18
|
import { readFileSync, writeFileSync, mkdirSync, existsSync, unlinkSync } from "node:fs";
|
|
@@ -56,6 +54,7 @@ function defaultOrchestratorUrl() {
|
|
|
56
54
|
// src/commands/register.ts
|
|
57
55
|
import { createHash, randomBytes } from "node:crypto";
|
|
58
56
|
import { spawn } from "node:child_process";
|
|
57
|
+
import { hostname } from "node:os";
|
|
59
58
|
|
|
60
59
|
// ../shared/dist/events.js
|
|
61
60
|
import { z as z2 } from "zod";
|
|
@@ -219,7 +218,7 @@ async function register(opts = {}) {
|
|
|
219
218
|
throw new Error(`pairing create failed: ${createRes.status} ${await createRes.text()}`);
|
|
220
219
|
}
|
|
221
220
|
const { code, expires_at } = PairingCreateResponseSchema.parse(await createRes.json());
|
|
222
|
-
const pairUrl = `${orchestratorUrl}/devices/pair?code=${encodeURIComponent(code)}`;
|
|
221
|
+
const pairUrl = `${orchestratorUrl}/devices/pair?code=${encodeURIComponent(code)}&hostname=${encodeURIComponent(hostname())}`;
|
|
223
222
|
console.log(`
|
|
224
223
|
Pairing code: ${code}`);
|
|
225
224
|
console.log(` Open ${pairUrl} in your browser to confirm.`);
|
|
@@ -368,8 +367,7 @@ function runJob(spec, stdinJson, handlers) {
|
|
|
368
367
|
}
|
|
369
368
|
|
|
370
369
|
// src/commands/run.ts
|
|
371
|
-
var
|
|
372
|
-
var PKG_VERSION = readPkgVersion();
|
|
370
|
+
var PKG_VERSION = "0.100.3";
|
|
373
371
|
var LOG_FLUSH_MS = 800;
|
|
374
372
|
var MAX_CHUNK_SIZE = 4 * 1024;
|
|
375
373
|
async function run(opts = {}) {
|
|
@@ -398,7 +396,7 @@ async function run(opts = {}) {
|
|
|
398
396
|
console.log(`[opencara] disconnected (code=${code} reason="${reason}")`);
|
|
399
397
|
}
|
|
400
398
|
});
|
|
401
|
-
console.log(`[opencara] starting as ${cfg.deviceName} (${
|
|
399
|
+
console.log(`[opencara] starting as ${cfg.deviceName} (${hostname2()})`);
|
|
402
400
|
client.start();
|
|
403
401
|
}
|
|
404
402
|
function handleServerMessage(msg, client, _cfg) {
|
|
@@ -457,14 +455,6 @@ async function executeJob(job, client) {
|
|
|
457
455
|
console.error(`[opencara] job ${runId.slice(-8)} failed`, message);
|
|
458
456
|
}
|
|
459
457
|
}
|
|
460
|
-
function readPkgVersion() {
|
|
461
|
-
try {
|
|
462
|
-
const raw = readFileSync2(join2(__dirname, "..", "..", "package.json"), "utf8");
|
|
463
|
-
return JSON.parse(raw).version ?? "0.0.0";
|
|
464
|
-
} catch {
|
|
465
|
-
return "0.0.0";
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
458
|
function collectSystemInfo() {
|
|
469
459
|
try {
|
|
470
460
|
const cpuList = cpus();
|
|
@@ -492,7 +482,7 @@ function collectSystemInfo() {
|
|
|
492
482
|
os: platform(),
|
|
493
483
|
release: release(),
|
|
494
484
|
arch: arch(),
|
|
495
|
-
hostname:
|
|
485
|
+
hostname: hostname2(),
|
|
496
486
|
cpu: {
|
|
497
487
|
model: head?.model.trim() ?? "unknown",
|
|
498
488
|
cores: cpuList.length,
|