tesseract-agent 0.11.19 → 0.11.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/dist-bundle/cli.js +289 -184
- package/dist-bundle/mesh-core/package.json +1 -1
- package/package.json +1 -1
package/dist-bundle/cli.js
CHANGED
|
@@ -39665,7 +39665,6 @@ import { tmpdir as tmpdir3, homedir as homedir3, userInfo } from "node:os";
|
|
|
39665
39665
|
import { join as join19, dirname as dirname9 } from "node:path";
|
|
39666
39666
|
import { existsSync as existsSync6, readFileSync as readFileSync13, readdirSync as readdirSync4, openSync as openSync5, readSync as readSync4, closeSync as closeSync5, statSync as statSync7, writeFileSync as writeFileSync8, mkdirSync as mkdirSync11, copyFileSync, renameSync as renameSync5, realpathSync as realpathSync2 } from "node:fs";
|
|
39667
39667
|
import { fileURLToPath } from "node:url";
|
|
39668
|
-
import { createRequire } from "node:module";
|
|
39669
39668
|
import { createServer } from "node:net";
|
|
39670
39669
|
import { spawn as spawn2, execSync, execFileSync } from "node:child_process";
|
|
39671
39670
|
function setBrowserExtensionProbe(fn) {
|
|
@@ -39723,17 +39722,6 @@ function resolveClaudeCodeExecutable() {
|
|
|
39723
39722
|
const user = findUserInstalledClaude(binName);
|
|
39724
39723
|
if (user)
|
|
39725
39724
|
return cachedClaudeExe = user;
|
|
39726
|
-
const require2 = createRequire(import.meta.url);
|
|
39727
|
-
const keys = process.platform === "linux" ? [`linux-${process.arch}`, `linux-${process.arch}-musl`] : [`${process.platform}-${process.arch}`];
|
|
39728
|
-
for (const key2 of keys) {
|
|
39729
|
-
try {
|
|
39730
|
-
const pkgJson = require2.resolve(`@anthropic-ai/claude-agent-sdk-${key2}/package.json`);
|
|
39731
|
-
const bin = join19(dirname9(pkgJson), binName);
|
|
39732
|
-
if (existsSync6(bin))
|
|
39733
|
-
return cachedClaudeExe = bin;
|
|
39734
|
-
} catch {
|
|
39735
|
-
}
|
|
39736
|
-
}
|
|
39737
39725
|
const resourcesPath = process.resourcesPath;
|
|
39738
39726
|
if (resourcesPath) {
|
|
39739
39727
|
const platKey = process.platform === "darwin" ? "mac" : process.platform === "win32" ? "win" : "linux";
|
|
@@ -47717,7 +47705,7 @@ var init_managed_spawn = __esm({
|
|
|
47717
47705
|
|
|
47718
47706
|
// ../../packages/host-core/dist/runners/proxy-router.js
|
|
47719
47707
|
import { execFile as execFile4, execSync as execSync2 } from "node:child_process";
|
|
47720
|
-
import { createRequire
|
|
47708
|
+
import { createRequire } from "node:module";
|
|
47721
47709
|
import { randomUUID as randomUUID6, createHash as createHash2 } from "node:crypto";
|
|
47722
47710
|
import { existsSync as existsSync9, mkdirSync as mkdirSync13, writeFileSync as writeFileSync11 } from "node:fs";
|
|
47723
47711
|
import { join as join24, dirname as dirname11, sep as sep3 } from "node:path";
|
|
@@ -47912,7 +47900,7 @@ var init_proxy_router = __esm({
|
|
|
47912
47900
|
init_base_paths();
|
|
47913
47901
|
init_managed_spawn();
|
|
47914
47902
|
init_dist2();
|
|
47915
|
-
requireFromHere =
|
|
47903
|
+
requireFromHere = createRequire(import.meta.url);
|
|
47916
47904
|
ROUTER_PORT = 8787;
|
|
47917
47905
|
BIND_HOST = "127.0.0.1";
|
|
47918
47906
|
ROUTER_TOKEN = randomUUID6();
|
|
@@ -84283,8 +84271,8 @@ var mesh_ca_exports = {};
|
|
|
84283
84271
|
__export(mesh_ca_exports, {
|
|
84284
84272
|
netCaCommand: () => netCaCommand
|
|
84285
84273
|
});
|
|
84286
|
-
import { chmodSync as chmodSync9, existsSync as
|
|
84287
|
-
import { join as
|
|
84274
|
+
import { chmodSync as chmodSync9, existsSync as existsSync60, mkdirSync as mkdirSync52, readFileSync as readFileSync68, writeFileSync as writeFileSync51 } from "node:fs";
|
|
84275
|
+
import { join as join102, resolve as resolve13 } from "node:path";
|
|
84288
84276
|
import { createInterface as createInterface2 } from "node:readline";
|
|
84289
84277
|
function die(msg) {
|
|
84290
84278
|
console.error(msg);
|
|
@@ -84315,28 +84303,28 @@ async function readPassphrase(prompt2) {
|
|
|
84315
84303
|
}
|
|
84316
84304
|
}
|
|
84317
84305
|
function writeSecretFile(p, bytes3) {
|
|
84318
|
-
|
|
84306
|
+
writeFileSync51(p, bytes3, { mode: 384 });
|
|
84319
84307
|
try {
|
|
84320
84308
|
chmodSync9(p, 384);
|
|
84321
84309
|
} catch {
|
|
84322
84310
|
}
|
|
84323
84311
|
}
|
|
84324
84312
|
function ensureDir(p) {
|
|
84325
|
-
|
|
84313
|
+
mkdirSync52(p, { recursive: true, mode: 448 });
|
|
84326
84314
|
try {
|
|
84327
84315
|
chmodSync9(p, 448);
|
|
84328
84316
|
} catch {
|
|
84329
84317
|
}
|
|
84330
84318
|
}
|
|
84331
84319
|
async function openCa(dir2) {
|
|
84332
|
-
const gPath =
|
|
84333
|
-
const sPath =
|
|
84334
|
-
if (!
|
|
84320
|
+
const gPath = join102(dir2, "genesis.bin");
|
|
84321
|
+
const sPath = join102(dir2, "ca.sealed");
|
|
84322
|
+
if (!existsSync60(gPath) || !existsSync60(sPath)) {
|
|
84335
84323
|
die(`No mesh CA in ${dir2}. Run: tesseract-agent mesh init --org NAME --ca-dir ${dir2}`);
|
|
84336
84324
|
}
|
|
84337
|
-
const genesisBytes = new Uint8Array(
|
|
84325
|
+
const genesisBytes = new Uint8Array(readFileSync68(gPath));
|
|
84338
84326
|
const genesis = decodeGenesis(genesisBytes);
|
|
84339
|
-
const sealed = decodeRecoveryBundle(new Uint8Array(
|
|
84327
|
+
const sealed = decodeRecoveryBundle(new Uint8Array(readFileSync68(sPath)));
|
|
84340
84328
|
const pass = await readPassphrase("CA passphrase: ");
|
|
84341
84329
|
let seed;
|
|
84342
84330
|
try {
|
|
@@ -84352,7 +84340,7 @@ async function netCaCommand(rest, flags) {
|
|
|
84352
84340
|
if (sub === "init") {
|
|
84353
84341
|
const org = typeof flags.org === "string" ? flags.org.trim() : "";
|
|
84354
84342
|
if (!org) die("Usage: tesseract-agent mesh init --org NAME [--ca-dir DIR]");
|
|
84355
|
-
if (
|
|
84343
|
+
if (existsSync60(join102(caDir, "ca.sealed"))) {
|
|
84356
84344
|
die(`A mesh CA already exists in ${caDir}. Refusing to overwrite it.`);
|
|
84357
84345
|
}
|
|
84358
84346
|
const pass = await readPassphrase("New CA passphrase: ");
|
|
@@ -84374,9 +84362,9 @@ async function netCaCommand(rest, flags) {
|
|
|
84374
84362
|
const genesisBytes = encodeGenesis(genesis);
|
|
84375
84363
|
const fp = await genesisFingerprint(genesis);
|
|
84376
84364
|
ensureDir(caDir);
|
|
84377
|
-
|
|
84378
|
-
writeSecretFile(
|
|
84379
|
-
writeSecretFile(
|
|
84365
|
+
writeFileSync51(join102(caDir, "genesis.bin"), genesisBytes);
|
|
84366
|
+
writeSecretFile(join102(caDir, "ca.sealed"), encodeRecoveryBundle(await sealCaKey(seed, pass, `${org} mesh CA`)));
|
|
84367
|
+
writeSecretFile(join102(caDir, "disablement.secret"), hex3(disable.secret));
|
|
84380
84368
|
console.log(`
|
|
84381
84369
|
Mesh created for "${org}".`);
|
|
84382
84370
|
console.log(` fingerprint: ${hex3(fp)}`);
|
|
@@ -84391,7 +84379,7 @@ Mesh created for "${org}".`);
|
|
|
84391
84379
|
console.log(` ${hex3(disable.secret)}`);
|
|
84392
84380
|
console.log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
84393
84381
|
console.log(`
|
|
84394
|
-
A copy of the disablement secret is in ${
|
|
84382
|
+
A copy of the disablement secret is in ${join102(caDir, "disablement.secret")}.`);
|
|
84395
84383
|
console.log("Move it somewhere the CA directory is not \u2014 holding both in one place");
|
|
84396
84384
|
console.log("defeats the point of having two.");
|
|
84397
84385
|
const caFlag = caDir === resolve13("./mesh-ca") ? "" : ` --ca-dir ${caDir}`;
|
|
@@ -84444,14 +84432,14 @@ Next, issue an identity for a machine (pick a free address in ${formatPrefix(gen
|
|
|
84444
84432
|
[{ keyIndex: 0, privateKey: ca.privateKey }]
|
|
84445
84433
|
);
|
|
84446
84434
|
ensureDir(outDir);
|
|
84447
|
-
|
|
84448
|
-
|
|
84449
|
-
writeSecretFile(
|
|
84435
|
+
writeFileSync51(join102(outDir, "genesis.bin"), genesisBytes);
|
|
84436
|
+
writeFileSync51(join102(outDir, "node.cert"), encodeCert(cert));
|
|
84437
|
+
writeSecretFile(join102(outDir, "node.key"), await exportStaticPrivate(nodeKey));
|
|
84450
84438
|
console.log(`Minted "${name}" at ${ip4}.`);
|
|
84451
84439
|
console.log(` ${outDir}`);
|
|
84452
84440
|
console.log("\nCopy that directory to the node and run there:");
|
|
84453
|
-
console.log(` tesseract-agent mesh enroll --genesis ${
|
|
84454
|
-
console.log(` --cert ${
|
|
84441
|
+
console.log(` tesseract-agent mesh enroll --genesis ${join102(outDir, "genesis.bin")} \\`);
|
|
84442
|
+
console.log(` --cert ${join102(outDir, "node.cert")} --key ${join102(outDir, "node.key")}`);
|
|
84455
84443
|
console.log("\nnode.key is the node's identity \u2014 send it over a channel you trust, and");
|
|
84456
84444
|
console.log("delete this copy once the node has it.");
|
|
84457
84445
|
return;
|
|
@@ -84487,8 +84475,8 @@ Next, issue an identity for a machine (pick a free address in ${formatPrefix(gen
|
|
|
84487
84475
|
ip4Exceptions: []
|
|
84488
84476
|
};
|
|
84489
84477
|
const signed = await signBundle(bundle, [{ keyIndex: 0, privateKey: ca.privateKey }]);
|
|
84490
|
-
const out = resolve13(typeof flags.out === "string" ? flags.out :
|
|
84491
|
-
|
|
84478
|
+
const out = resolve13(typeof flags.out === "string" ? flags.out : join102(caDir, "bundle.bin"));
|
|
84479
|
+
writeFileSync51(out, encodeSignedBundle(signed));
|
|
84492
84480
|
console.log(`Signed policy bundle (epoch ${epoch2}) \u2192 ${out}`);
|
|
84493
84481
|
console.log("Every node must receive it; the relay distributes it, or copy it to");
|
|
84494
84482
|
console.log(`each node's mesh directory as bundle.bin.`);
|
|
@@ -84510,12 +84498,12 @@ var init_mesh_ca = __esm({
|
|
|
84510
84498
|
|
|
84511
84499
|
// src/cli.ts
|
|
84512
84500
|
init_base_paths();
|
|
84513
|
-
import { existsSync as
|
|
84501
|
+
import { existsSync as existsSync61, mkdtempSync as mkdtempSync4, readFileSync as readFileSync70, rmSync as rmSync14 } from "node:fs";
|
|
84514
84502
|
import { createHash as createHash12 } from "node:crypto";
|
|
84515
|
-
import { execFileSync as
|
|
84503
|
+
import { execFileSync as execFileSync9, spawn as spawn14 } from "node:child_process";
|
|
84516
84504
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
84517
84505
|
import { tmpdir as tmpdir8 } from "node:os";
|
|
84518
|
-
import { dirname as
|
|
84506
|
+
import { dirname as dirname46, join as join103, resolve as resolve15 } from "node:path";
|
|
84519
84507
|
import { createInterface as createInterface3 } from "node:readline/promises";
|
|
84520
84508
|
|
|
84521
84509
|
// ../../packages/host-core/dist/control-link.js
|
|
@@ -100456,8 +100444,8 @@ import { randomUUID as randomUUID23 } from "node:crypto";
|
|
|
100456
100444
|
import { existsSync as existsSync21 } from "node:fs";
|
|
100457
100445
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
100458
100446
|
import { sep as sep6, join as join46, dirname as dirname19 } from "node:path";
|
|
100459
|
-
import { createRequire as
|
|
100460
|
-
var require_ =
|
|
100447
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
100448
|
+
var require_ = createRequire2(import.meta.url);
|
|
100461
100449
|
var unpacked = (p) => p.replace(`app.asar${sep6}`, `app.asar.unpacked${sep6}`);
|
|
100462
100450
|
function exportedPath(name) {
|
|
100463
100451
|
try {
|
|
@@ -101164,8 +101152,8 @@ async function falTopazEnhance(path6, spec, opts) {
|
|
|
101164
101152
|
const dir2 = opts.outDir ?? workDir();
|
|
101165
101153
|
mkdirSync24(dir2, { recursive: true });
|
|
101166
101154
|
const outPath = join48(dir2, "enhanced.mp4");
|
|
101167
|
-
const { writeFileSync:
|
|
101168
|
-
|
|
101155
|
+
const { writeFileSync: writeFileSync52 } = await import("node:fs");
|
|
101156
|
+
writeFileSync52(outPath, Buffer.from(await dl.arrayBuffer()));
|
|
101169
101157
|
const out = await probeMedia(outPath).catch(() => null);
|
|
101170
101158
|
opts.onProgress?.(100, "Enhance complete");
|
|
101171
101159
|
return { path: outPath, mime: MIME, width: out?.width ?? null, height: out?.height ?? null, durationSec: out?.durationSec ?? p.durationSec, summary: `fal Topaz ${spec.model ?? "Proteus"} \xD7${spec.upscaleFactor ?? 2}` };
|
|
@@ -107237,9 +107225,9 @@ var NodeFsHandler = class {
|
|
|
107237
107225
|
if (this.fsw.closed) {
|
|
107238
107226
|
return;
|
|
107239
107227
|
}
|
|
107240
|
-
const
|
|
107228
|
+
const dirname47 = sysPath.dirname(file2);
|
|
107241
107229
|
const basename17 = sysPath.basename(file2);
|
|
107242
|
-
const parent = this.fsw._getWatchedDir(
|
|
107230
|
+
const parent = this.fsw._getWatchedDir(dirname47);
|
|
107243
107231
|
let prevStats = stats;
|
|
107244
107232
|
if (parent.has(basename17))
|
|
107245
107233
|
return;
|
|
@@ -107266,7 +107254,7 @@ var NodeFsHandler = class {
|
|
|
107266
107254
|
prevStats = newStats2;
|
|
107267
107255
|
}
|
|
107268
107256
|
} catch (error51) {
|
|
107269
|
-
this.fsw._remove(
|
|
107257
|
+
this.fsw._remove(dirname47, basename17);
|
|
107270
107258
|
}
|
|
107271
107259
|
} else if (parent.has(basename17)) {
|
|
107272
107260
|
const at = newStats.atimeMs;
|
|
@@ -116137,9 +116125,9 @@ async function startLocalServer(opts) {
|
|
|
116137
116125
|
|
|
116138
116126
|
// ../../packages/host-core/dist/daemon-runtime.js
|
|
116139
116127
|
init_base_paths();
|
|
116140
|
-
import { readFileSync as
|
|
116141
|
-
import { execFileSync as
|
|
116142
|
-
import { join as
|
|
116128
|
+
import { readFileSync as readFileSync60, writeFileSync as writeFileSync45, existsSync as existsSync50, mkdirSync as mkdirSync48, unlinkSync as unlinkSync8, chmodSync as chmodSync8, statSync as statSync21 } from "node:fs";
|
|
116129
|
+
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
116130
|
+
import { join as join92 } from "node:path";
|
|
116143
116131
|
import { randomBytes as randomBytes11 } from "node:crypto";
|
|
116144
116132
|
import { hostname as hostname6 } from "node:os";
|
|
116145
116133
|
|
|
@@ -116548,7 +116536,7 @@ async function getPeerIdentityPub(opts) {
|
|
|
116548
116536
|
|
|
116549
116537
|
// ../../packages/host-core/dist/mesh/node.js
|
|
116550
116538
|
import { createSocket } from "node:dgram";
|
|
116551
|
-
import { createRequire as
|
|
116539
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
116552
116540
|
init_credentials();
|
|
116553
116541
|
|
|
116554
116542
|
// ../../packages/host-core/dist/mesh/bundle-gossip.js
|
|
@@ -117448,7 +117436,7 @@ function isAdvertisableEndpoint(ip, overlays) {
|
|
|
117448
117436
|
// ../../packages/host-core/dist/mesh/node.js
|
|
117449
117437
|
init_dist6();
|
|
117450
117438
|
var _a3;
|
|
117451
|
-
var requireCjs =
|
|
117439
|
+
var requireCjs = createRequire3(import.meta.url);
|
|
117452
117440
|
function joinedOverlayRanges() {
|
|
117453
117441
|
const out = [];
|
|
117454
117442
|
try {
|
|
@@ -121869,33 +121857,150 @@ init_credentials();
|
|
|
121869
121857
|
|
|
121870
121858
|
// ../../packages/shared/dist/identity.js
|
|
121871
121859
|
init_base_paths();
|
|
121860
|
+
import { existsSync as existsSync49, mkdirSync as mkdirSync47, readFileSync as readFileSync59, writeFileSync as writeFileSync44 } from "node:fs";
|
|
121861
|
+
import { dirname as dirname40, join as join91 } from "node:path";
|
|
121862
|
+
import { randomUUID as randomUUID31 } from "node:crypto";
|
|
121863
|
+
|
|
121864
|
+
// ../../packages/shared/dist/device-id-mirror.js
|
|
121865
|
+
init_base_paths();
|
|
121866
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
121872
121867
|
import { existsSync as existsSync48, mkdirSync as mkdirSync46, readFileSync as readFileSync58, writeFileSync as writeFileSync43 } from "node:fs";
|
|
121868
|
+
import { homedir as homedir16 } from "node:os";
|
|
121873
121869
|
import { dirname as dirname39, join as join90 } from "node:path";
|
|
121874
|
-
|
|
121870
|
+
var SERVICE = "dev.tesseract.device-id";
|
|
121871
|
+
var ACCOUNT = "device-id";
|
|
121872
|
+
var TOOL_TIMEOUT_MS = 4e3;
|
|
121873
|
+
function machineGlobalAllowed() {
|
|
121874
|
+
try {
|
|
121875
|
+
return !isAlternateHome();
|
|
121876
|
+
} catch {
|
|
121877
|
+
return false;
|
|
121878
|
+
}
|
|
121879
|
+
}
|
|
121880
|
+
function appSupportDir(env = process.env, platform8 = process.platform) {
|
|
121881
|
+
const home = homedir16();
|
|
121882
|
+
if (platform8 === "darwin")
|
|
121883
|
+
return join90(home, "Library", "Application Support", "Tesseract");
|
|
121884
|
+
if (platform8 === "win32")
|
|
121885
|
+
return join90(env.APPDATA ?? join90(home, "AppData", "Roaming"), "Tesseract");
|
|
121886
|
+
return join90(env.XDG_CONFIG_HOME ?? join90(home, ".config"), "Tesseract");
|
|
121887
|
+
}
|
|
121888
|
+
function mirrorFile() {
|
|
121889
|
+
return join90(appSupportDir(), "device-id.json");
|
|
121890
|
+
}
|
|
121891
|
+
function readJsonId(file2) {
|
|
121892
|
+
try {
|
|
121893
|
+
const raw = JSON.parse(readFileSync58(file2, "utf-8"));
|
|
121894
|
+
return typeof raw.deviceId === "string" && raw.deviceId ? raw.deviceId : null;
|
|
121895
|
+
} catch {
|
|
121896
|
+
return null;
|
|
121897
|
+
}
|
|
121898
|
+
}
|
|
121899
|
+
function writeJsonId(file2, deviceId3) {
|
|
121900
|
+
try {
|
|
121901
|
+
const dir2 = dirname39(file2);
|
|
121902
|
+
if (!existsSync48(dir2))
|
|
121903
|
+
mkdirSync46(dir2, { recursive: true });
|
|
121904
|
+
writeFileSync43(file2, JSON.stringify({ deviceId: deviceId3 }), { mode: 384 });
|
|
121905
|
+
} catch {
|
|
121906
|
+
}
|
|
121907
|
+
}
|
|
121908
|
+
function haveTool(bin) {
|
|
121909
|
+
try {
|
|
121910
|
+
execFileSync6(process.platform === "win32" ? "where" : "which", [bin], { timeout: TOOL_TIMEOUT_MS, stdio: "pipe" });
|
|
121911
|
+
return true;
|
|
121912
|
+
} catch {
|
|
121913
|
+
return false;
|
|
121914
|
+
}
|
|
121915
|
+
}
|
|
121916
|
+
function readFromCredentialStore() {
|
|
121917
|
+
try {
|
|
121918
|
+
if (process.platform === "darwin") {
|
|
121919
|
+
const out = execFileSync6("security", ["find-generic-password", "-s", SERVICE, "-a", ACCOUNT, "-w"], {
|
|
121920
|
+
encoding: "utf-8",
|
|
121921
|
+
timeout: TOOL_TIMEOUT_MS,
|
|
121922
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
121923
|
+
}).trim();
|
|
121924
|
+
return out || null;
|
|
121925
|
+
}
|
|
121926
|
+
if (process.platform === "linux" && haveTool("secret-tool")) {
|
|
121927
|
+
const out = execFileSync6("secret-tool", ["lookup", "service", SERVICE, "account", ACCOUNT], {
|
|
121928
|
+
encoding: "utf-8",
|
|
121929
|
+
timeout: TOOL_TIMEOUT_MS,
|
|
121930
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
121931
|
+
}).trim();
|
|
121932
|
+
return out || null;
|
|
121933
|
+
}
|
|
121934
|
+
} catch {
|
|
121935
|
+
}
|
|
121936
|
+
return null;
|
|
121937
|
+
}
|
|
121938
|
+
function writeToCredentialStore(deviceId3) {
|
|
121939
|
+
try {
|
|
121940
|
+
if (process.platform === "darwin") {
|
|
121941
|
+
execFileSync6("security", ["add-generic-password", "-s", SERVICE, "-a", ACCOUNT, "-w", deviceId3, "-U"], {
|
|
121942
|
+
timeout: TOOL_TIMEOUT_MS,
|
|
121943
|
+
stdio: "ignore"
|
|
121944
|
+
});
|
|
121945
|
+
return;
|
|
121946
|
+
}
|
|
121947
|
+
if (process.platform === "linux" && haveTool("secret-tool")) {
|
|
121948
|
+
execFileSync6("secret-tool", ["store", "--label=Tesseract device id", "service", SERVICE, "account", ACCOUNT], {
|
|
121949
|
+
input: deviceId3,
|
|
121950
|
+
timeout: TOOL_TIMEOUT_MS,
|
|
121951
|
+
stdio: ["pipe", "ignore", "ignore"]
|
|
121952
|
+
});
|
|
121953
|
+
}
|
|
121954
|
+
} catch {
|
|
121955
|
+
}
|
|
121956
|
+
}
|
|
121957
|
+
function recoverDeviceId() {
|
|
121958
|
+
if (!machineGlobalAllowed())
|
|
121959
|
+
return null;
|
|
121960
|
+
return readJsonId(mirrorFile()) ?? readFromCredentialStore();
|
|
121961
|
+
}
|
|
121962
|
+
function ensureMirrors(deviceId3) {
|
|
121963
|
+
if (!machineGlobalAllowed())
|
|
121964
|
+
return;
|
|
121965
|
+
const file2 = mirrorFile();
|
|
121966
|
+
if (readJsonId(file2) === deviceId3)
|
|
121967
|
+
return;
|
|
121968
|
+
writeJsonId(file2, deviceId3);
|
|
121969
|
+
writeToCredentialStore(deviceId3);
|
|
121970
|
+
}
|
|
121971
|
+
|
|
121972
|
+
// ../../packages/shared/dist/identity.js
|
|
121875
121973
|
function deviceIdFile() {
|
|
121876
|
-
return
|
|
121974
|
+
return join91(tesseractHome(), "device-id.json");
|
|
121877
121975
|
}
|
|
121878
121976
|
function readPersistedDeviceId() {
|
|
121879
121977
|
try {
|
|
121880
|
-
const raw = JSON.parse(
|
|
121978
|
+
const raw = JSON.parse(readFileSync59(deviceIdFile(), "utf-8"));
|
|
121881
121979
|
return typeof raw.deviceId === "string" && raw.deviceId ? raw.deviceId : null;
|
|
121882
121980
|
} catch {
|
|
121883
121981
|
return null;
|
|
121884
121982
|
}
|
|
121885
121983
|
}
|
|
121984
|
+
function mintDeviceId() {
|
|
121985
|
+
return randomUUID31().replace(/-/g, "");
|
|
121986
|
+
}
|
|
121886
121987
|
function persistentDeviceId() {
|
|
121887
121988
|
const cur = readPersistedDeviceId();
|
|
121888
|
-
if (cur)
|
|
121989
|
+
if (cur) {
|
|
121990
|
+
ensureMirrors(cur);
|
|
121889
121991
|
return cur;
|
|
121890
|
-
|
|
121992
|
+
}
|
|
121993
|
+
const recovered = recoverDeviceId();
|
|
121994
|
+
const id = recovered ?? mintDeviceId();
|
|
121891
121995
|
try {
|
|
121892
121996
|
const f = deviceIdFile();
|
|
121893
|
-
const dir2 =
|
|
121894
|
-
if (!
|
|
121895
|
-
|
|
121896
|
-
|
|
121997
|
+
const dir2 = dirname40(f);
|
|
121998
|
+
if (!existsSync49(dir2))
|
|
121999
|
+
mkdirSync47(dir2, { recursive: true });
|
|
122000
|
+
writeFileSync44(f, JSON.stringify({ deviceId: id }));
|
|
121897
122001
|
} catch {
|
|
121898
122002
|
}
|
|
122003
|
+
ensureMirrors(id);
|
|
121899
122004
|
return id;
|
|
121900
122005
|
}
|
|
121901
122006
|
|
|
@@ -122052,8 +122157,8 @@ async function runDaemon(opts = {}) {
|
|
|
122052
122157
|
log10("paths", JSON.stringify(sealBasePaths()));
|
|
122053
122158
|
const OUR_STARTED_AT = procStartedAt(process.pid);
|
|
122054
122159
|
let ownsMachine = false;
|
|
122055
|
-
const pidfile2 = () =>
|
|
122056
|
-
const statusFile2 = () =>
|
|
122160
|
+
const pidfile2 = () => join92(daemonDir2(), "daemon.lock");
|
|
122161
|
+
const statusFile2 = () => join92(daemonDir2(), "status.json");
|
|
122057
122162
|
const isAlive2 = (pid) => {
|
|
122058
122163
|
if (!Number.isFinite(pid) || pid <= 0)
|
|
122059
122164
|
return false;
|
|
@@ -122066,7 +122171,7 @@ async function runDaemon(opts = {}) {
|
|
|
122066
122171
|
};
|
|
122067
122172
|
const lockHeldByAnother = () => {
|
|
122068
122173
|
try {
|
|
122069
|
-
const pid = Number(
|
|
122174
|
+
const pid = Number(readFileSync60(pidfile2(), "utf-8").trim());
|
|
122070
122175
|
return Number.isFinite(pid) && pid > 0 && pid !== process.pid && isAlive2(pid);
|
|
122071
122176
|
} catch {
|
|
122072
122177
|
return false;
|
|
@@ -122074,7 +122179,7 @@ async function runDaemon(opts = {}) {
|
|
|
122074
122179
|
};
|
|
122075
122180
|
const lockHeldByYieldingSubset = () => {
|
|
122076
122181
|
try {
|
|
122077
|
-
const pid = Number(
|
|
122182
|
+
const pid = Number(readFileSync60(pidfile2(), "utf-8").trim());
|
|
122078
122183
|
if (!Number.isFinite(pid) || pid <= 0 || pid === process.pid || !isAlive2(pid))
|
|
122079
122184
|
return false;
|
|
122080
122185
|
return liveDaemons().some((d) => d.pid === pid && d.rdeskOnly === true);
|
|
@@ -122085,17 +122190,17 @@ async function runDaemon(opts = {}) {
|
|
|
122085
122190
|
function acquireLock2() {
|
|
122086
122191
|
const f = pidfile2();
|
|
122087
122192
|
try {
|
|
122088
|
-
if (!
|
|
122089
|
-
|
|
122193
|
+
if (!existsSync50(daemonDir2()))
|
|
122194
|
+
mkdirSync48(daemonDir2(), { recursive: true, mode: 448 });
|
|
122090
122195
|
} catch {
|
|
122091
122196
|
}
|
|
122092
122197
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
122093
122198
|
try {
|
|
122094
|
-
|
|
122199
|
+
writeFileSync45(f, String(process.pid), { flag: "wx" });
|
|
122095
122200
|
return true;
|
|
122096
122201
|
} catch {
|
|
122097
122202
|
try {
|
|
122098
|
-
const prev = Number(
|
|
122203
|
+
const prev = Number(readFileSync60(f, "utf-8").trim());
|
|
122099
122204
|
if (!prev)
|
|
122100
122205
|
return false;
|
|
122101
122206
|
if (prev !== process.pid && isAlive2(prev))
|
|
@@ -122111,7 +122216,7 @@ async function runDaemon(opts = {}) {
|
|
|
122111
122216
|
function releaseLock() {
|
|
122112
122217
|
try {
|
|
122113
122218
|
const f = pidfile2();
|
|
122114
|
-
if (
|
|
122219
|
+
if (existsSync50(f) && Number(readFileSync60(f, "utf-8").trim()) === process.pid)
|
|
122115
122220
|
unlinkSync8(f);
|
|
122116
122221
|
} catch {
|
|
122117
122222
|
}
|
|
@@ -122121,7 +122226,7 @@ async function runDaemon(opts = {}) {
|
|
|
122121
122226
|
if (!ownsMachine)
|
|
122122
122227
|
return;
|
|
122123
122228
|
try {
|
|
122124
|
-
|
|
122229
|
+
writeFileSync45(statusFile2(), JSON.stringify({ pid: process.pid, startedAt: OUR_STARTED_AT, role: process.env.CCB_RDESK_ROLE ?? "host", kind: KIND, version: VERSION2, execPath: process.env.CCB_DAEMON_EXECPATH ?? process.execPath, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), gui: daemonGuiTrayActive(), ...localInfo ?? {}, ...s }));
|
|
122125
122230
|
chmodSync8(statusFile2(), 384);
|
|
122126
122231
|
} catch {
|
|
122127
122232
|
}
|
|
@@ -122241,7 +122346,7 @@ async function runDaemon(opts = {}) {
|
|
|
122241
122346
|
}
|
|
122242
122347
|
const snapshotProcs = (tag) => {
|
|
122243
122348
|
try {
|
|
122244
|
-
const raw =
|
|
122349
|
+
const raw = execFileSync7("ps", ["-axww", "-o", "pid=,ppid=,pcpu=,etime=,command="], { encoding: "utf8", timeout: 3e3 });
|
|
122245
122350
|
const rows = raw.split("\n").filter((l) => /[Tt]esseract|host-daemon/.test(l) && !/\bgrep\b|ps -axww/.test(l));
|
|
122246
122351
|
log10(`PROC-SNAPSHOT [${tag}] me=${process.pid} ppid=${process.ppid} \u2014 ${rows.length} tesseract proc(s):`);
|
|
122247
122352
|
for (const r of rows.slice(0, 40))
|
|
@@ -122684,7 +122789,7 @@ async function runDaemon(opts = {}) {
|
|
|
122684
122789
|
if (r.status === 401) {
|
|
122685
122790
|
log10("device token no longer valid \u2014 dropping to local-only on restart");
|
|
122686
122791
|
try {
|
|
122687
|
-
unlinkSync8(
|
|
122792
|
+
unlinkSync8(join92(daemonDir2(), "credentials.json"));
|
|
122688
122793
|
} catch {
|
|
122689
122794
|
}
|
|
122690
122795
|
shutdown(0, "token-revoked-401");
|
|
@@ -123004,7 +123109,7 @@ async function runDaemon(opts = {}) {
|
|
|
123004
123109
|
let freeTicks = 0;
|
|
123005
123110
|
const lockHolder = () => {
|
|
123006
123111
|
try {
|
|
123007
|
-
return Number(
|
|
123112
|
+
return Number(readFileSync60(pidfile2(), "utf-8").trim()) || 0;
|
|
123008
123113
|
} catch {
|
|
123009
123114
|
return 0;
|
|
123010
123115
|
}
|
|
@@ -123174,7 +123279,7 @@ async function runDaemon(opts = {}) {
|
|
|
123174
123279
|
onDeviceRevoked: () => {
|
|
123175
123280
|
log10("this machine was removed from the account \u2014 dropping its credentials; it speaks for itself again");
|
|
123176
123281
|
try {
|
|
123177
|
-
unlinkSync8(
|
|
123282
|
+
unlinkSync8(join92(daemonDir2(), "credentials.json"));
|
|
123178
123283
|
} catch {
|
|
123179
123284
|
}
|
|
123180
123285
|
void reloadIdentity();
|
|
@@ -123227,7 +123332,7 @@ async function runDaemon(opts = {}) {
|
|
|
123227
123332
|
if (appPid > 0 && appPid !== process.pid) {
|
|
123228
123333
|
const quitMarker = () => {
|
|
123229
123334
|
try {
|
|
123230
|
-
return Number(
|
|
123335
|
+
return Number(readFileSync60(join92(daemonDir2(), "app-quit.marker"), "utf-8").trim()) || 0;
|
|
123231
123336
|
} catch {
|
|
123232
123337
|
return 0;
|
|
123233
123338
|
}
|
|
@@ -123252,7 +123357,7 @@ async function runDaemon(opts = {}) {
|
|
|
123252
123357
|
log10(`desktop app (pid ${appPid}) is gone with NO clean-quit marker \u2014 reporting`);
|
|
123253
123358
|
const tail3 = (name) => {
|
|
123254
123359
|
try {
|
|
123255
|
-
const buf =
|
|
123360
|
+
const buf = readFileSync60(join92(daemonDir2(), name), "utf-8");
|
|
123256
123361
|
return buf.length > 4096 ? buf.slice(-4096) : buf;
|
|
123257
123362
|
} catch {
|
|
123258
123363
|
return void 0;
|
|
@@ -123283,14 +123388,14 @@ async function runDaemon(opts = {}) {
|
|
|
123283
123388
|
}
|
|
123284
123389
|
try {
|
|
123285
123390
|
const DAEMON_LOG_CAP = 2 * 1024 * 1024;
|
|
123286
|
-
const daemonLogFile =
|
|
123391
|
+
const daemonLogFile = join92(daemonDir2(), "daemon.log");
|
|
123287
123392
|
const capTimer = setInterval(() => {
|
|
123288
123393
|
try {
|
|
123289
|
-
if (
|
|
123290
|
-
const buf =
|
|
123394
|
+
if (existsSync50(daemonLogFile) && statSync21(daemonLogFile).size > DAEMON_LOG_CAP) {
|
|
123395
|
+
const buf = readFileSync60(daemonLogFile, "utf-8");
|
|
123291
123396
|
const kept = `\u2026[daemon.log capped at ${(/* @__PURE__ */ new Date()).toISOString()}]\u2026
|
|
123292
123397
|
` + buf.slice(-DAEMON_LOG_CAP / 2);
|
|
123293
|
-
|
|
123398
|
+
writeFileSync45(daemonLogFile, kept);
|
|
123294
123399
|
}
|
|
123295
123400
|
} catch {
|
|
123296
123401
|
}
|
|
@@ -123396,15 +123501,15 @@ init_credentials();
|
|
|
123396
123501
|
|
|
123397
123502
|
// ../../packages/host-core/dist/net-service/ensure-installed.js
|
|
123398
123503
|
import { execFile as execFile16 } from "node:child_process";
|
|
123399
|
-
import { existsSync as
|
|
123400
|
-
import { dirname as
|
|
123504
|
+
import { existsSync as existsSync54, readFileSync as readFileSync63, statSync as statSync22 } from "node:fs";
|
|
123505
|
+
import { dirname as dirname42, join as join96 } from "node:path";
|
|
123401
123506
|
import { promisify as promisify12 } from "node:util";
|
|
123402
123507
|
|
|
123403
123508
|
// ../../packages/host-core/dist/net-service/launchd-system.js
|
|
123404
123509
|
import { spawn as spawn9 } from "node:child_process";
|
|
123405
|
-
import { existsSync as
|
|
123510
|
+
import { existsSync as existsSync52, mkdtempSync as mkdtempSync2, writeFileSync as writeFileSync46, rmSync as rmSync11, readFileSync as readFileSync61 } from "node:fs";
|
|
123406
123511
|
import { tmpdir as tmpdir6 } from "node:os";
|
|
123407
|
-
import { join as
|
|
123512
|
+
import { join as join94 } from "node:path";
|
|
123408
123513
|
|
|
123409
123514
|
// ../../packages/host-core/dist/net-service/owner-uid.js
|
|
123410
123515
|
function installOwnerUid(env = process.env, self2 = typeof process.getuid === "function" ? process.getuid() : 0) {
|
|
@@ -123449,14 +123554,14 @@ async function alreadyElevated() {
|
|
|
123449
123554
|
}
|
|
123450
123555
|
|
|
123451
123556
|
// ../../packages/host-core/dist/net-service/app-bundle.js
|
|
123452
|
-
import { execFileSync as
|
|
123453
|
-
import { existsSync as
|
|
123454
|
-
import { dirname as
|
|
123557
|
+
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
123558
|
+
import { existsSync as existsSync51 } from "node:fs";
|
|
123559
|
+
import { dirname as dirname41, basename as basename16, join as join93 } from "node:path";
|
|
123455
123560
|
function appBundleFor(exec2) {
|
|
123456
123561
|
let found;
|
|
123457
|
-
let dir2 =
|
|
123458
|
-
for (let prev = ""; dir2 !== prev; prev = dir2, dir2 =
|
|
123459
|
-
if (basename16(dir2).endsWith(".app") &&
|
|
123562
|
+
let dir2 = dirname41(exec2);
|
|
123563
|
+
for (let prev = ""; dir2 !== prev; prev = dir2, dir2 = dirname41(dir2)) {
|
|
123564
|
+
if (basename16(dir2).endsWith(".app") && existsSync51(join93(dir2, "Contents", "Info.plist"))) {
|
|
123460
123565
|
found = dir2;
|
|
123461
123566
|
}
|
|
123462
123567
|
}
|
|
@@ -123472,7 +123577,7 @@ function bundleIdForExec(exec2) {
|
|
|
123472
123577
|
if (!bundle)
|
|
123473
123578
|
return void 0;
|
|
123474
123579
|
try {
|
|
123475
|
-
const id =
|
|
123580
|
+
const id = execFileSync8("/usr/bin/plutil", ["-extract", "CFBundleIdentifier", "raw", "-o", "-", join93(bundle, "Contents", "Info.plist")], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
123476
123581
|
return looksLikeBundleId(id) ? id : void 0;
|
|
123477
123582
|
} catch {
|
|
123478
123583
|
return void 0;
|
|
@@ -123571,10 +123676,10 @@ function runForCode(cmd, args) {
|
|
|
123571
123676
|
});
|
|
123572
123677
|
}
|
|
123573
123678
|
async function elevate(script) {
|
|
123574
|
-
const dir2 = mkdtempSync2(
|
|
123575
|
-
const path6 =
|
|
123679
|
+
const dir2 = mkdtempSync2(join94(tmpdir6(), "tesseract-netd-"));
|
|
123680
|
+
const path6 = join94(dir2, "install.sh");
|
|
123576
123681
|
try {
|
|
123577
|
-
|
|
123682
|
+
writeFileSync46(path6, script, { mode: 384 });
|
|
123578
123683
|
if (await alreadyElevated()) {
|
|
123579
123684
|
return { code: await runForCode("/bin/sh", [path6]), declined: false };
|
|
123580
123685
|
}
|
|
@@ -123644,9 +123749,9 @@ ${plist}TESSERACT_PLIST_EOF`,
|
|
|
123644
123749
|
};
|
|
123645
123750
|
},
|
|
123646
123751
|
async state() {
|
|
123647
|
-
if (!
|
|
123752
|
+
if (!existsSync52(PLIST))
|
|
123648
123753
|
return { installed: false, running: false };
|
|
123649
|
-
const text13 =
|
|
123754
|
+
const text13 = readFileSync61(PLIST, "utf8");
|
|
123650
123755
|
const owner = parseOwnerUid(text13);
|
|
123651
123756
|
const assoc = parseAssociatedBundleId(text13);
|
|
123652
123757
|
const running2 = await netdAvailable();
|
|
@@ -123667,7 +123772,7 @@ ${plist}TESSERACT_PLIST_EOF`,
|
|
|
123667
123772
|
|
|
123668
123773
|
// ../../packages/host-core/dist/net-service/systemd-system.js
|
|
123669
123774
|
import { spawn as spawn11 } from "node:child_process";
|
|
123670
|
-
import { existsSync as
|
|
123775
|
+
import { existsSync as existsSync53, readFileSync as readFileSync62 } from "node:fs";
|
|
123671
123776
|
|
|
123672
123777
|
// ../../packages/host-core/dist/service/exec.js
|
|
123673
123778
|
import { execFile as execFile13, spawn as spawn10 } from "node:child_process";
|
|
@@ -123844,9 +123949,9 @@ function makeSystemdSystem() {
|
|
|
123844
123949
|
return code === 0 ? { ok: true } : { ok: false, detail: `removing the helper failed (exit ${code})` };
|
|
123845
123950
|
},
|
|
123846
123951
|
async state() {
|
|
123847
|
-
if (!
|
|
123952
|
+
if (!existsSync53(UNIT_PATH))
|
|
123848
123953
|
return { installed: false, running: false };
|
|
123849
|
-
const owner = parseOwnerUid(
|
|
123954
|
+
const owner = parseOwnerUid(readFileSync62(UNIT_PATH, "utf8"));
|
|
123850
123955
|
const active2 = await tryRun("systemctl", ["is-active", UNIT]);
|
|
123851
123956
|
const running2 = active2.stdout.trim() === "active";
|
|
123852
123957
|
const own2 = owner === void 0 ? {} : { ownerUid: owner };
|
|
@@ -123871,12 +123976,12 @@ function sh2(s) {
|
|
|
123871
123976
|
|
|
123872
123977
|
// ../../packages/host-core/dist/net-service/windows-service.js
|
|
123873
123978
|
import { execFile as execFile14, spawn as spawn12 } from "node:child_process";
|
|
123874
|
-
import { mkdtempSync as mkdtempSync3, writeFileSync as
|
|
123979
|
+
import { mkdtempSync as mkdtempSync3, writeFileSync as writeFileSync47, rmSync as rmSync12 } from "node:fs";
|
|
123875
123980
|
import { tmpdir as tmpdir7 } from "node:os";
|
|
123876
|
-
import { join as
|
|
123981
|
+
import { join as join95, win32 } from "node:path";
|
|
123877
123982
|
import { promisify as promisify10 } from "node:util";
|
|
123878
123983
|
var run7 = promisify10(execFile14);
|
|
123879
|
-
var
|
|
123984
|
+
var SERVICE2 = "TesseractNetd";
|
|
123880
123985
|
var DISPLAY = "Tesseract network helper";
|
|
123881
123986
|
function windowsHelperDir() {
|
|
123882
123987
|
const root = process.env.ProgramW6432 || process.env.ProgramFiles || "C:\\Program Files";
|
|
@@ -123908,9 +124013,9 @@ function buildBinaryPath(spec) {
|
|
|
123908
124013
|
return parts.map((p) => `"${p}"`).join(" ");
|
|
123909
124014
|
}
|
|
123910
124015
|
async function elevatePowerShell(script) {
|
|
123911
|
-
const dir2 = mkdtempSync3(
|
|
123912
|
-
const inner =
|
|
123913
|
-
|
|
124016
|
+
const dir2 = mkdtempSync3(join95(tmpdir7(), "tesseract-netd-"));
|
|
124017
|
+
const inner = join95(dir2, "install.ps1");
|
|
124018
|
+
writeFileSync47(inner, script, { encoding: "utf8" });
|
|
123914
124019
|
if (await alreadyElevated()) {
|
|
123915
124020
|
return new Promise((resolve16) => {
|
|
123916
124021
|
const p = spawn12("powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", inner], { stdio: "inherit" });
|
|
@@ -123925,8 +124030,8 @@ async function elevatePowerShell(script) {
|
|
|
123925
124030
|
p.on("close", (code) => finish2(code ?? 1));
|
|
123926
124031
|
});
|
|
123927
124032
|
}
|
|
123928
|
-
const outer =
|
|
123929
|
-
|
|
124033
|
+
const outer = join95(dir2, "elevate.ps1");
|
|
124034
|
+
writeFileSync47(outer, [
|
|
123930
124035
|
'$ErrorActionPreference = "Stop"',
|
|
123931
124036
|
"try {",
|
|
123932
124037
|
` $p = Start-Process -FilePath "powershell.exe" -ArgumentList @("-NoProfile","-ExecutionPolicy","Bypass","-File",${ps(inner)}) -Verb RunAs -Wait -PassThru`,
|
|
@@ -123960,10 +124065,10 @@ function buildInstallScript2(spec) {
|
|
|
123960
124065
|
// Stopping first is ALSO what makes the copy below possible: Windows locks a running
|
|
123961
124066
|
// executable, so overwriting `tesseract-netd.exe` while the old service holds it fails
|
|
123962
124067
|
// with "being used by another process" — on exactly the upgrade this exists to perform.
|
|
123963
|
-
`$existing = Get-Service -Name ${ps(
|
|
124068
|
+
`$existing = Get-Service -Name ${ps(SERVICE2)} -ErrorAction SilentlyContinue`,
|
|
123964
124069
|
"if ($existing) {",
|
|
123965
|
-
` Stop-Service -Name ${ps(
|
|
123966
|
-
` & sc.exe delete ${
|
|
124070
|
+
` Stop-Service -Name ${ps(SERVICE2)} -Force -ErrorAction SilentlyContinue`,
|
|
124071
|
+
` & sc.exe delete ${SERVICE2} | Out-Null`,
|
|
123967
124072
|
" Start-Sleep -Milliseconds 500",
|
|
123968
124073
|
"}",
|
|
123969
124074
|
// The whole shipped directory, not just the exe: tun-rs `LoadLibrary`s `wintun.dll` from
|
|
@@ -123975,7 +124080,7 @@ function buildInstallScript2(spec) {
|
|
|
123975
124080
|
`if (-not (Test-Path -LiteralPath ${ps(windowsHelperExec())})) { exit 2 }`,
|
|
123976
124081
|
// Checked ELEVATED, on the admin-owned copy: the source directory is user-writable.
|
|
123977
124082
|
...spec.execSha256 ? [`if ((Get-FileHash -Algorithm SHA256 -LiteralPath ${ps(windowsHelperExec())}).Hash.ToLower() -ne ${ps(spec.execSha256)}) { Remove-Item -LiteralPath ${ps(windowsHelperExec())} -Force; exit 3 }`] : [],
|
|
123978
|
-
`New-Service -Name ${ps(
|
|
124083
|
+
`New-Service -Name ${ps(SERVICE2)} -BinaryPathName ${ps(bin)} -DisplayName ${ps(DISPLAY)} -Description ${ps("Programs the routes for Tesseract private networks and owns the tunnel device.")} -StartupType Automatic | Out-Null`,
|
|
123979
124084
|
// RESTART FOR AS LONG AS THE MACHINE IS ON, which is the same contract systemd
|
|
123980
124085
|
// (`Restart=on-failure`, no `StartLimitBurst`) and launchd (`KeepAlive`/`SuccessfulExit`)
|
|
123981
124086
|
// give on the other two platforms. A private network that stops coming back after three
|
|
@@ -123993,15 +124098,15 @@ function buildInstallScript2(spec) {
|
|
|
123993
124098
|
// `reset= 86400` still applies: a day without a failure clears the count. The delays rise
|
|
123994
124099
|
// 5s → 10s → 60s, and Windows repeats the LAST action for every subsequent failure, so a
|
|
123995
124100
|
// genuinely unfixable crash costs one attempt a minute rather than a spin.
|
|
123996
|
-
`& sc.exe failure ${
|
|
123997
|
-
`Start-Service -Name ${ps(
|
|
124101
|
+
`& sc.exe failure ${SERVICE2} reset= 86400 actions= restart/5000/restart/10000/restart/60000 | Out-Null`,
|
|
124102
|
+
`Start-Service -Name ${ps(SERVICE2)}`,
|
|
123998
124103
|
"exit 0"
|
|
123999
124104
|
].join("\n");
|
|
124000
124105
|
}
|
|
124001
124106
|
function buildUninstallScript() {
|
|
124002
124107
|
return [
|
|
124003
|
-
`Stop-Service -Name ${ps(
|
|
124004
|
-
`& sc.exe delete ${
|
|
124108
|
+
`Stop-Service -Name ${ps(SERVICE2)} -Force -ErrorAction SilentlyContinue`,
|
|
124109
|
+
`& sc.exe delete ${SERVICE2} | Out-Null`,
|
|
124005
124110
|
// The copy goes too. Leaving an admin-owned helper behind after an uninstall is litter at
|
|
124006
124111
|
// best; the pause lets the stopped process release its file lock first.
|
|
124007
124112
|
"Start-Sleep -Milliseconds 500",
|
|
@@ -124033,7 +124138,7 @@ function makeWindowsService() {
|
|
|
124033
124138
|
},
|
|
124034
124139
|
async state() {
|
|
124035
124140
|
try {
|
|
124036
|
-
const { stdout } = await run7("sc.exe", ["query",
|
|
124141
|
+
const { stdout } = await run7("sc.exe", ["query", SERVICE2]);
|
|
124037
124142
|
const out = String(stdout);
|
|
124038
124143
|
const running2 = /STATE\s*:\s*4\b/.test(out);
|
|
124039
124144
|
if (running2)
|
|
@@ -124185,16 +124290,16 @@ function installedHelperPath(platform8) {
|
|
|
124185
124290
|
function helperDiffers(shipped, installed) {
|
|
124186
124291
|
if (!shipped || !installed)
|
|
124187
124292
|
return false;
|
|
124188
|
-
if (!
|
|
124293
|
+
if (!existsSync54(shipped))
|
|
124189
124294
|
return false;
|
|
124190
|
-
if (!
|
|
124295
|
+
if (!existsSync54(installed))
|
|
124191
124296
|
return true;
|
|
124192
124297
|
try {
|
|
124193
124298
|
const a = statSync22(shipped);
|
|
124194
124299
|
const b = statSync22(installed);
|
|
124195
124300
|
if (a.size !== b.size)
|
|
124196
124301
|
return true;
|
|
124197
|
-
return !
|
|
124302
|
+
return !readFileSync63(shipped).equals(readFileSync63(installed));
|
|
124198
124303
|
} catch {
|
|
124199
124304
|
return false;
|
|
124200
124305
|
}
|
|
@@ -124223,7 +124328,7 @@ async function ensureNetHelperInstalled() {
|
|
|
124223
124328
|
return { ok: false, reason: "failed", detail: u.detail };
|
|
124224
124329
|
}
|
|
124225
124330
|
const exec2 = netdBinaryPath();
|
|
124226
|
-
if (exec2 && process.platform === "win32" && !
|
|
124331
|
+
if (exec2 && process.platform === "win32" && !existsSync54(join96(dirname42(exec2), "wintun.dll"))) {
|
|
124227
124332
|
return {
|
|
124228
124333
|
ok: false,
|
|
124229
124334
|
reason: "no-binary",
|
|
@@ -124280,9 +124385,9 @@ import { platform as platform6 } from "node:os";
|
|
|
124280
124385
|
|
|
124281
124386
|
// ../../packages/host-core/dist/service/launchd.js
|
|
124282
124387
|
init_credentials();
|
|
124283
|
-
import { writeFileSync as
|
|
124284
|
-
import { dirname as
|
|
124285
|
-
import { homedir as
|
|
124388
|
+
import { writeFileSync as writeFileSync48, existsSync as existsSync55, mkdirSync as mkdirSync49, unlinkSync as unlinkSync9, readFileSync as readFileSync64 } from "node:fs";
|
|
124389
|
+
import { dirname as dirname43, join as join97 } from "node:path";
|
|
124390
|
+
import { homedir as homedir17, userInfo as userInfo2 } from "node:os";
|
|
124286
124391
|
|
|
124287
124392
|
// ../../packages/host-core/dist/service/legacy-label.js
|
|
124288
124393
|
function definitionIsCli(text13) {
|
|
@@ -124298,18 +124403,18 @@ function xml2(s) {
|
|
|
124298
124403
|
function makeLaunchd(instanceId) {
|
|
124299
124404
|
const suffix = instanceSuffix(instanceId);
|
|
124300
124405
|
const label = SERVICE_LABEL_BASE + (suffix ? `.${suffix}` : "");
|
|
124301
|
-
const plistPath = () =>
|
|
124406
|
+
const plistPath = () => join97(homedir17(), "Library", "LaunchAgents", `${label}.plist`);
|
|
124302
124407
|
const domainTarget = () => `gui/${userInfo2().uid}`;
|
|
124303
124408
|
const serviceTarget = () => `${domainTarget()}/${label}`;
|
|
124304
|
-
const logFile = () =>
|
|
124409
|
+
const logFile = () => join97(daemonDir2(), "daemon.log");
|
|
124305
124410
|
const legacyLabel = LEGACY_SERVICE_LABEL_BASE + (suffix ? `.${suffix}` : "");
|
|
124306
|
-
const legacyPlistPath = () =>
|
|
124411
|
+
const legacyPlistPath = () => join97(homedir17(), "Library", "LaunchAgents", `${legacyLabel}.plist`);
|
|
124307
124412
|
async function removeLegacySharedJob() {
|
|
124308
124413
|
try {
|
|
124309
124414
|
const p = legacyPlistPath();
|
|
124310
|
-
if (!
|
|
124415
|
+
if (!existsSync55(p))
|
|
124311
124416
|
return;
|
|
124312
|
-
if (!definitionIsCli(
|
|
124417
|
+
if (!definitionIsCli(readFileSync64(p, "utf-8")))
|
|
124313
124418
|
return;
|
|
124314
124419
|
await run6("launchctl", ["bootout", `${domainTarget()}/${legacyLabel}`]).catch(() => {
|
|
124315
124420
|
});
|
|
@@ -124392,10 +124497,10 @@ ${env}
|
|
|
124392
124497
|
return {
|
|
124393
124498
|
async install(spec) {
|
|
124394
124499
|
await removeLegacySharedJob();
|
|
124395
|
-
|
|
124396
|
-
|
|
124397
|
-
|
|
124398
|
-
|
|
124500
|
+
mkdirSync49(workDirOf(spec), { recursive: true });
|
|
124501
|
+
mkdirSync49(dirname43(plistPath()), { recursive: true });
|
|
124502
|
+
mkdirSync49(dirname43(spec.logPath), { recursive: true });
|
|
124503
|
+
writeFileSync48(plistPath(), buildPlist2(spec));
|
|
124399
124504
|
await run6("launchctl", ["bootout", serviceTarget()]).catch(() => {
|
|
124400
124505
|
});
|
|
124401
124506
|
await untilGone();
|
|
@@ -124411,7 +124516,7 @@ ${env}
|
|
|
124411
124516
|
async uninstall() {
|
|
124412
124517
|
await run6("launchctl", ["bootout", serviceTarget()]).catch(() => {
|
|
124413
124518
|
});
|
|
124414
|
-
if (
|
|
124519
|
+
if (existsSync55(plistPath())) {
|
|
124415
124520
|
try {
|
|
124416
124521
|
unlinkSync9(plistPath());
|
|
124417
124522
|
} catch {
|
|
@@ -124422,7 +124527,7 @@ ${env}
|
|
|
124422
124527
|
await this.install(spec);
|
|
124423
124528
|
},
|
|
124424
124529
|
async isInstalled() {
|
|
124425
|
-
return
|
|
124530
|
+
return existsSync55(plistPath());
|
|
124426
124531
|
},
|
|
124427
124532
|
async start() {
|
|
124428
124533
|
await run6("launchctl", ["bootstrap", domainTarget(), plistPath()]).catch(() => {
|
|
@@ -124439,7 +124544,7 @@ ${env}
|
|
|
124439
124544
|
},
|
|
124440
124545
|
async logs(follow) {
|
|
124441
124546
|
const f = logFile();
|
|
124442
|
-
if (!
|
|
124547
|
+
if (!existsSync55(f)) {
|
|
124443
124548
|
console.log(`No log yet at ${f} \u2014 has the service started?`);
|
|
124444
124549
|
return;
|
|
124445
124550
|
}
|
|
@@ -124450,9 +124555,9 @@ ${env}
|
|
|
124450
124555
|
|
|
124451
124556
|
// ../../packages/host-core/dist/service/systemd.js
|
|
124452
124557
|
init_credentials();
|
|
124453
|
-
import { writeFileSync as
|
|
124454
|
-
import { dirname as
|
|
124455
|
-
import { homedir as
|
|
124558
|
+
import { writeFileSync as writeFileSync49, existsSync as existsSync56, mkdirSync as mkdirSync50, unlinkSync as unlinkSync10, readFileSync as readFileSync65 } from "node:fs";
|
|
124559
|
+
import { dirname as dirname44, join as join98 } from "node:path";
|
|
124560
|
+
import { homedir as homedir18, userInfo as userInfo3 } from "node:os";
|
|
124456
124561
|
function unitVal2(v) {
|
|
124457
124562
|
return v.replace(/%/g, "%%");
|
|
124458
124563
|
}
|
|
@@ -124464,16 +124569,16 @@ function makeSystemd(instanceId) {
|
|
|
124464
124569
|
const unit = `tesseract-agent${suffix ? `-${suffix}` : ""}.service`;
|
|
124465
124570
|
const legacyUnit = `tesseract-host${suffix ? `-${suffix}` : ""}.service`;
|
|
124466
124571
|
const unitPath = () => {
|
|
124467
|
-
const base = process.env.XDG_CONFIG_HOME ||
|
|
124468
|
-
return
|
|
124572
|
+
const base = process.env.XDG_CONFIG_HOME || join98(homedir18(), ".config");
|
|
124573
|
+
return join98(base, "systemd", "user", unit);
|
|
124469
124574
|
};
|
|
124470
124575
|
async function removeLegacySharedUnit() {
|
|
124471
124576
|
try {
|
|
124472
|
-
const base = process.env.XDG_CONFIG_HOME ||
|
|
124473
|
-
const p =
|
|
124474
|
-
if (!
|
|
124577
|
+
const base = process.env.XDG_CONFIG_HOME || join98(homedir18(), ".config");
|
|
124578
|
+
const p = join98(base, "systemd", "user", legacyUnit);
|
|
124579
|
+
if (!existsSync56(p))
|
|
124475
124580
|
return;
|
|
124476
|
-
if (!definitionIsCli(
|
|
124581
|
+
if (!definitionIsCli(readFileSync65(p, "utf-8")))
|
|
124477
124582
|
return;
|
|
124478
124583
|
await run6("systemctl", ["--user", "disable", "--now", legacyUnit]).catch(() => {
|
|
124479
124584
|
});
|
|
@@ -124509,10 +124614,10 @@ WantedBy=default.target
|
|
|
124509
124614
|
return {
|
|
124510
124615
|
async install(spec) {
|
|
124511
124616
|
await removeLegacySharedUnit();
|
|
124512
|
-
|
|
124513
|
-
|
|
124514
|
-
|
|
124515
|
-
|
|
124617
|
+
mkdirSync50(workDirOf(spec), { recursive: true });
|
|
124618
|
+
mkdirSync50(dirname44(unitPath()), { recursive: true });
|
|
124619
|
+
mkdirSync50(dirname44(spec.logPath), { recursive: true });
|
|
124620
|
+
writeFileSync49(unitPath(), buildUnit2(spec));
|
|
124516
124621
|
await run6("loginctl", ["enable-linger", userInfo3().username]).catch(() => {
|
|
124517
124622
|
});
|
|
124518
124623
|
await run6("systemctl", ["--user", "daemon-reload"]).catch(() => {
|
|
@@ -124524,7 +124629,7 @@ WantedBy=default.target
|
|
|
124524
124629
|
async uninstall() {
|
|
124525
124630
|
await run6("systemctl", ["--user", "disable", "--now", unit]).catch(() => {
|
|
124526
124631
|
});
|
|
124527
|
-
if (
|
|
124632
|
+
if (existsSync56(unitPath())) {
|
|
124528
124633
|
try {
|
|
124529
124634
|
unlinkSync10(unitPath());
|
|
124530
124635
|
} catch {
|
|
@@ -124537,7 +124642,7 @@ WantedBy=default.target
|
|
|
124537
124642
|
await this.install(spec);
|
|
124538
124643
|
},
|
|
124539
124644
|
async isInstalled() {
|
|
124540
|
-
return
|
|
124645
|
+
return existsSync56(unitPath());
|
|
124541
124646
|
},
|
|
124542
124647
|
async start() {
|
|
124543
124648
|
await run6("systemctl", ["--user", "start", unit]);
|
|
@@ -124549,8 +124654,8 @@ WantedBy=default.target
|
|
|
124549
124654
|
await runInherit("systemctl", ["--user", "status", unit, "--no-pager"]);
|
|
124550
124655
|
},
|
|
124551
124656
|
async logs(follow) {
|
|
124552
|
-
const f =
|
|
124553
|
-
if (
|
|
124657
|
+
const f = join98(daemonDir2(), "daemon.log");
|
|
124658
|
+
if (existsSync56(f)) {
|
|
124554
124659
|
await runInherit("tail", follow ? ["-f", f] : ["-n", "200", f]);
|
|
124555
124660
|
return;
|
|
124556
124661
|
}
|
|
@@ -124562,12 +124667,12 @@ WantedBy=default.target
|
|
|
124562
124667
|
|
|
124563
124668
|
// ../../packages/host-core/dist/service/windows.js
|
|
124564
124669
|
init_credentials();
|
|
124565
|
-
import { writeFileSync as
|
|
124566
|
-
import { dirname as
|
|
124670
|
+
import { writeFileSync as writeFileSync50, existsSync as existsSync57, mkdirSync as mkdirSync51, unlinkSync as unlinkSync11, readFileSync as readFileSync66 } from "node:fs";
|
|
124671
|
+
import { dirname as dirname45, join as join99 } from "node:path";
|
|
124567
124672
|
function publishedDaemonPid(dir2) {
|
|
124568
124673
|
for (const f of ["status.json", "daemon.lock"]) {
|
|
124569
124674
|
try {
|
|
124570
|
-
const raw =
|
|
124675
|
+
const raw = readFileSync66(join99(dir2, f), "utf-8");
|
|
124571
124676
|
const pid = f === "status.json" ? Number(JSON.parse(raw).pid) : Number(raw.trim());
|
|
124572
124677
|
if (Number.isInteger(pid) && pid > 0)
|
|
124573
124678
|
return pid;
|
|
@@ -124580,15 +124685,15 @@ function makeWindowsTask(instanceId) {
|
|
|
124580
124685
|
const suffix = instanceSuffix(instanceId);
|
|
124581
124686
|
const task = `Fineguide\\TesseractAgent${suffix ? `-${suffix}` : ""}`;
|
|
124582
124687
|
const legacyTask = `Fineguide\\TesseractHost${suffix ? `-${suffix}` : ""}`;
|
|
124583
|
-
const wrapperPath = () =>
|
|
124584
|
-
const legacyWrapperPath = () =>
|
|
124585
|
-
const logFile = () =>
|
|
124688
|
+
const wrapperPath = () => join99(daemonDir2(), `run-agent${suffix ? `-${suffix}` : ""}.cmd`);
|
|
124689
|
+
const legacyWrapperPath = () => join99(daemonDir2(), `run-host${suffix ? `-${suffix}` : ""}.cmd`);
|
|
124690
|
+
const logFile = () => join99(daemonDir2(), "daemon.log");
|
|
124586
124691
|
async function removeLegacySharedTask() {
|
|
124587
124692
|
try {
|
|
124588
124693
|
const w = legacyWrapperPath();
|
|
124589
|
-
if (!
|
|
124694
|
+
if (!existsSync57(w))
|
|
124590
124695
|
return;
|
|
124591
|
-
if (!definitionIsCli(
|
|
124696
|
+
if (!definitionIsCli(readFileSync66(w, "utf-8")))
|
|
124592
124697
|
return;
|
|
124593
124698
|
await run6("schtasks", ["/End", "/TN", legacyTask]).catch(() => {
|
|
124594
124699
|
});
|
|
@@ -124614,10 +124719,10 @@ start "" /b ${cmd} >> "${oneLine3(spec.logPath).replace(/"/g, "")}" 2>&1\r
|
|
|
124614
124719
|
return {
|
|
124615
124720
|
async install(spec) {
|
|
124616
124721
|
await removeLegacySharedTask();
|
|
124617
|
-
|
|
124618
|
-
|
|
124619
|
-
|
|
124620
|
-
|
|
124722
|
+
mkdirSync51(spec.workingDirectory ?? daemonDir2(), { recursive: true });
|
|
124723
|
+
mkdirSync51(dirname45(spec.logPath), { recursive: true });
|
|
124724
|
+
mkdirSync51(dirname45(wrapperPath()), { recursive: true });
|
|
124725
|
+
writeFileSync50(wrapperPath(), buildWrapper(spec));
|
|
124621
124726
|
await run6("schtasks", ["/Create", "/TN", task, "/SC", "ONLOGON", "/RL", "LIMITED", "/F", "/TR", `"${wrapperPath()}"`]);
|
|
124622
124727
|
await run6("schtasks", ["/Run", "/TN", task]).catch(() => {
|
|
124623
124728
|
});
|
|
@@ -124625,7 +124730,7 @@ start "" /b ${cmd} >> "${oneLine3(spec.logPath).replace(/"/g, "")}" 2>&1\r
|
|
|
124625
124730
|
async uninstall() {
|
|
124626
124731
|
await run6("schtasks", ["/Delete", "/TN", task, "/F"]).catch(() => {
|
|
124627
124732
|
});
|
|
124628
|
-
if (
|
|
124733
|
+
if (existsSync57(wrapperPath())) {
|
|
124629
124734
|
try {
|
|
124630
124735
|
unlinkSync11(wrapperPath());
|
|
124631
124736
|
} catch {
|
|
@@ -124699,7 +124804,7 @@ start "" /b ${cmd} >> "${oneLine3(spec.logPath).replace(/"/g, "")}" 2>&1\r
|
|
|
124699
124804
|
},
|
|
124700
124805
|
async logs(follow) {
|
|
124701
124806
|
const f = logFile();
|
|
124702
|
-
if (!
|
|
124807
|
+
if (!existsSync57(f)) {
|
|
124703
124808
|
console.log(`No log yet at ${f} \u2014 has the task run?`);
|
|
124704
124809
|
return;
|
|
124705
124810
|
}
|
|
@@ -124835,8 +124940,8 @@ init_safe_kill();
|
|
|
124835
124940
|
|
|
124836
124941
|
// src/auth.ts
|
|
124837
124942
|
var import_qrcode_terminal = __toESM(require_main(), 1);
|
|
124838
|
-
import { existsSync as
|
|
124839
|
-
import { join as
|
|
124943
|
+
import { existsSync as existsSync58, rmSync as rmSync13 } from "node:fs";
|
|
124944
|
+
import { join as join100 } from "node:path";
|
|
124840
124945
|
|
|
124841
124946
|
// src/config.ts
|
|
124842
124947
|
import { hostname as hostname7 } from "node:os";
|
|
@@ -125037,8 +125142,8 @@ async function logout() {
|
|
|
125037
125142
|
}
|
|
125038
125143
|
for (const f of ["credentials.json", "status.json", "daemon.lock"]) {
|
|
125039
125144
|
try {
|
|
125040
|
-
const p =
|
|
125041
|
-
if (
|
|
125145
|
+
const p = join100(daemonDir2(), f);
|
|
125146
|
+
if (existsSync58(p)) rmSync13(p);
|
|
125042
125147
|
} catch {
|
|
125043
125148
|
}
|
|
125044
125149
|
}
|
|
@@ -125196,9 +125301,9 @@ function startSelfUpdater(current) {
|
|
|
125196
125301
|
}
|
|
125197
125302
|
|
|
125198
125303
|
// src/service.ts
|
|
125199
|
-
import { join as
|
|
125304
|
+
import { join as join101 } from "node:path";
|
|
125200
125305
|
import { platform as platform7 } from "node:os";
|
|
125201
|
-
import { existsSync as
|
|
125306
|
+
import { existsSync as existsSync59, readFileSync as readFileSync67 } from "node:fs";
|
|
125202
125307
|
function controller(instanceId) {
|
|
125203
125308
|
const c = getServiceController(instanceId);
|
|
125204
125309
|
if (!c) {
|
|
@@ -125211,7 +125316,7 @@ function buildSpec(cliEntry) {
|
|
|
125211
125316
|
exec: process.execPath,
|
|
125212
125317
|
args: [cliEntry, "run"],
|
|
125213
125318
|
env: { CCB_DAEMON_DIR: daemonDir2() },
|
|
125214
|
-
logPath:
|
|
125319
|
+
logPath: join101(daemonDir2(), "daemon.log")
|
|
125215
125320
|
};
|
|
125216
125321
|
}
|
|
125217
125322
|
var isAlive = (pid) => {
|
|
@@ -125223,10 +125328,10 @@ var isAlive = (pid) => {
|
|
|
125223
125328
|
}
|
|
125224
125329
|
};
|
|
125225
125330
|
function runningDaemonInfo() {
|
|
125226
|
-
const lock =
|
|
125331
|
+
const lock = join101(daemonDir2(), "daemon.lock");
|
|
125227
125332
|
try {
|
|
125228
|
-
if (!
|
|
125229
|
-
const pid = Number(
|
|
125333
|
+
if (!existsSync59(lock)) return null;
|
|
125334
|
+
const pid = Number(readFileSync67(lock, "utf-8").trim());
|
|
125230
125335
|
if (!pid || !isAlive(pid)) return null;
|
|
125231
125336
|
return { pid, device: readCredentials()?.deviceId };
|
|
125232
125337
|
} catch {
|
|
@@ -125260,7 +125365,7 @@ async function logs(instanceId, follow) {
|
|
|
125260
125365
|
}
|
|
125261
125366
|
|
|
125262
125367
|
// src/net.ts
|
|
125263
|
-
import { readFileSync as
|
|
125368
|
+
import { readFileSync as readFileSync69 } from "node:fs";
|
|
125264
125369
|
import { randomBytes as randomBytes12 } from "node:crypto";
|
|
125265
125370
|
import { hostname as hostname8 } from "node:os";
|
|
125266
125371
|
import { resolve as resolve14 } from "node:path";
|
|
@@ -125343,7 +125448,7 @@ function readOrDie(label, p) {
|
|
|
125343
125448
|
process.exit(1);
|
|
125344
125449
|
}
|
|
125345
125450
|
try {
|
|
125346
|
-
return new Uint8Array(
|
|
125451
|
+
return new Uint8Array(readFileSync69(resolve14(p)));
|
|
125347
125452
|
} catch (e) {
|
|
125348
125453
|
console.error(`net enroll: could not read --${label} ${p}: ${e instanceof Error ? e.message : e}`);
|
|
125349
125454
|
process.exit(1);
|
|
@@ -126111,8 +126216,8 @@ async function meshCommand(rest, flags) {
|
|
|
126111
126216
|
// src/cli.ts
|
|
126112
126217
|
function pkgVersion() {
|
|
126113
126218
|
try {
|
|
126114
|
-
const p =
|
|
126115
|
-
return JSON.parse(
|
|
126219
|
+
const p = join103(dirname46(fileURLToPath8(import.meta.url)), "..", "package.json");
|
|
126220
|
+
return JSON.parse(readFileSync70(p, "utf8")).version ?? "0.0.0";
|
|
126116
126221
|
} catch {
|
|
126117
126222
|
return "0.0.0";
|
|
126118
126223
|
}
|
|
@@ -126340,7 +126445,7 @@ async function linkCommand(rest, flags) {
|
|
|
126340
126445
|
process.exit(1);
|
|
126341
126446
|
}
|
|
126342
126447
|
async function captureClaudeSubscription(flags) {
|
|
126343
|
-
const home = mkdtempSync4(
|
|
126448
|
+
const home = mkdtempSync4(join103(tmpdir8(), "tesseract-claude-login-"));
|
|
126344
126449
|
const binary = typeof flags["claude-path"] === "string" ? flags["claude-path"] : process.env.CCB_ENGINE_PATH_CLAUDE_CODE || "claude";
|
|
126345
126450
|
const args = ["auth", "login", "--claudeai"];
|
|
126346
126451
|
if (typeof flags.email === "string") args.push("--email", flags.email);
|
|
@@ -126357,10 +126462,10 @@ async function captureClaudeSubscription(flags) {
|
|
|
126357
126462
|
child.once("close", (exitCode, signal2) => resolveCode(signal2 ? 1 : exitCode ?? 1));
|
|
126358
126463
|
});
|
|
126359
126464
|
if (code !== 0) throw new Error(`Claude sign-in did not complete (exit ${code}).`);
|
|
126360
|
-
const file2 =
|
|
126361
|
-
if (
|
|
126465
|
+
const file2 = join103(home, ".credentials.json");
|
|
126466
|
+
if (existsSync61(file2)) return readFileSync70(file2, "utf8");
|
|
126362
126467
|
if (process.platform === "darwin") {
|
|
126363
|
-
const value =
|
|
126468
|
+
const value = execFileSync9("security", [
|
|
126364
126469
|
"find-generic-password",
|
|
126365
126470
|
"-s",
|
|
126366
126471
|
"Claude Code-credentials",
|
|
@@ -126440,7 +126545,7 @@ async function runnerCommand(rest, flags) {
|
|
|
126440
126545
|
process.exit(1);
|
|
126441
126546
|
}
|
|
126442
126547
|
const oauthFilePath = typeof flags["oauth-file"] === "string" ? resolve15(flags["oauth-file"]) : void 0;
|
|
126443
|
-
const oauthAuthFile = oauthFilePath ?
|
|
126548
|
+
const oauthAuthFile = oauthFilePath ? readFileSync70(oauthFilePath, "utf8") : void 0;
|
|
126444
126549
|
if (oauthAuthFile) {
|
|
126445
126550
|
try {
|
|
126446
126551
|
JSON.parse(oauthAuthFile);
|