tesseract-agent 0.11.5 → 0.11.7
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 +398 -330
- package/dist-bundle/mesh-core/package.json +1 -1
- package/package.json +1 -1
package/dist-bundle/cli.js
CHANGED
|
@@ -4269,7 +4269,7 @@ function isPidAlive(pid) {
|
|
|
4269
4269
|
function createSchedulerLock(lockDir, ownerId, now2 = () => Date.now()) {
|
|
4270
4270
|
const lockFile = join5(lockDir, "scheduled_tasks.lock");
|
|
4271
4271
|
let held = false;
|
|
4272
|
-
const
|
|
4272
|
+
const read = () => {
|
|
4273
4273
|
try {
|
|
4274
4274
|
const rec = JSON.parse(readFileSync4(lockFile, "utf-8"));
|
|
4275
4275
|
if (rec && typeof rec.ownerId === "string" && typeof rec.pid === "number" && typeof rec.refreshedAt === "number")
|
|
@@ -4294,13 +4294,13 @@ function createSchedulerLock(lockDir, ownerId, now2 = () => Date.now()) {
|
|
|
4294
4294
|
held = false;
|
|
4295
4295
|
return false;
|
|
4296
4296
|
}
|
|
4297
|
-
const after =
|
|
4297
|
+
const after = read();
|
|
4298
4298
|
held = !!after && after.nonce === nonce2;
|
|
4299
4299
|
return held;
|
|
4300
4300
|
};
|
|
4301
4301
|
return {
|
|
4302
4302
|
isOwner() {
|
|
4303
|
-
const existing =
|
|
4303
|
+
const existing = read();
|
|
4304
4304
|
if (!existing) {
|
|
4305
4305
|
try {
|
|
4306
4306
|
const fd = openSync(lockFile, "wx");
|
|
@@ -4312,7 +4312,7 @@ function createSchedulerLock(lockDir, ownerId, now2 = () => Date.now()) {
|
|
|
4312
4312
|
held = true;
|
|
4313
4313
|
return true;
|
|
4314
4314
|
} catch {
|
|
4315
|
-
const r =
|
|
4315
|
+
const r = read();
|
|
4316
4316
|
if (r && r.ownerId === ownerId)
|
|
4317
4317
|
return writeLease();
|
|
4318
4318
|
return false;
|
|
@@ -4329,7 +4329,7 @@ function createSchedulerLock(lockDir, ownerId, now2 = () => Date.now()) {
|
|
|
4329
4329
|
release() {
|
|
4330
4330
|
if (!held)
|
|
4331
4331
|
return;
|
|
4332
|
-
const r =
|
|
4332
|
+
const r = read();
|
|
4333
4333
|
if (r && r.ownerId === ownerId) {
|
|
4334
4334
|
try {
|
|
4335
4335
|
unlinkSync(lockFile);
|
|
@@ -27550,6 +27550,32 @@ var init_mesh_node_name = __esm({
|
|
|
27550
27550
|
}
|
|
27551
27551
|
});
|
|
27552
27552
|
|
|
27553
|
+
// ../../packages/shared/dist/host-id.js
|
|
27554
|
+
function parseHostId(hostId) {
|
|
27555
|
+
if (!hostId)
|
|
27556
|
+
return null;
|
|
27557
|
+
const i = hostId.indexOf(":");
|
|
27558
|
+
if (i < 0 || hostId.slice(0, i) !== "electron")
|
|
27559
|
+
return null;
|
|
27560
|
+
const rest = hostId.slice(i + 1);
|
|
27561
|
+
const j = rest.indexOf(":");
|
|
27562
|
+
if (j < 0)
|
|
27563
|
+
return null;
|
|
27564
|
+
const owner = rest.slice(0, j);
|
|
27565
|
+
const deviceId3 = rest.slice(j + 1);
|
|
27566
|
+
if (!owner || !deviceId3)
|
|
27567
|
+
return null;
|
|
27568
|
+
return { kind: "electron", owner, deviceId: deviceId3 };
|
|
27569
|
+
}
|
|
27570
|
+
function hostDeviceId(hostId) {
|
|
27571
|
+
return parseHostId(hostId)?.deviceId ?? null;
|
|
27572
|
+
}
|
|
27573
|
+
var init_host_id = __esm({
|
|
27574
|
+
"../../packages/shared/dist/host-id.js"() {
|
|
27575
|
+
"use strict";
|
|
27576
|
+
}
|
|
27577
|
+
});
|
|
27578
|
+
|
|
27553
27579
|
// ../../packages/shared/dist/index.js
|
|
27554
27580
|
var init_dist2 = __esm({
|
|
27555
27581
|
"../../packages/shared/dist/index.js"() {
|
|
@@ -27610,6 +27636,7 @@ var init_dist2 = __esm({
|
|
|
27610
27636
|
init_user_dialog();
|
|
27611
27637
|
init_session_ops();
|
|
27612
27638
|
init_mesh_node_name();
|
|
27639
|
+
init_host_id();
|
|
27613
27640
|
}
|
|
27614
27641
|
});
|
|
27615
27642
|
|
|
@@ -30878,8 +30905,8 @@ ${err2 instanceof Error ? err2.message : String(err2)}
|
|
|
30878
30905
|
const fd = openSync2(job.logPath, "r");
|
|
30879
30906
|
try {
|
|
30880
30907
|
const buf = Buffer.allocUnsafe(want);
|
|
30881
|
-
const
|
|
30882
|
-
return buf.subarray(0,
|
|
30908
|
+
const read = readSync(fd, buf, 0, want, size - want);
|
|
30909
|
+
return buf.subarray(0, read).toString("utf8");
|
|
30883
30910
|
} finally {
|
|
30884
30911
|
closeSync2(fd);
|
|
30885
30912
|
}
|
|
@@ -31271,10 +31298,10 @@ function wrapAsyncTool(def, opts) {
|
|
|
31271
31298
|
return text9(raced.err instanceof Error ? raced.err.message : String(raced.err), true);
|
|
31272
31299
|
}
|
|
31273
31300
|
opts.learnedSlow?.add(t.name);
|
|
31274
|
-
const job = opts.registry.start(t.name, describeArgs(t.name, args), async (
|
|
31301
|
+
const job = opts.registry.start(t.name, describeArgs(t.name, args), async (write2) => {
|
|
31275
31302
|
try {
|
|
31276
31303
|
const out = await work;
|
|
31277
|
-
|
|
31304
|
+
write2(out);
|
|
31278
31305
|
} catch (err2) {
|
|
31279
31306
|
throw err2 instanceof Error ? err2 : new Error(String(err2));
|
|
31280
31307
|
}
|
|
@@ -43883,8 +43910,8 @@ ${lines.join("\n")}
|
|
|
43883
43910
|
const fd = openSync5(path6, "r");
|
|
43884
43911
|
try {
|
|
43885
43912
|
const buf = Buffer.allocUnsafe(want);
|
|
43886
|
-
const
|
|
43887
|
-
return buf.subarray(0,
|
|
43913
|
+
const read = readSync4(fd, buf, 0, want, Math.max(0, size - want));
|
|
43914
|
+
return buf.subarray(0, read).toString("utf8").slice(-maxChars);
|
|
43888
43915
|
} finally {
|
|
43889
43916
|
closeSync5(fd);
|
|
43890
43917
|
}
|
|
@@ -46357,9 +46384,9 @@ function wrapHostedAsyncTool(t, opts) {
|
|
|
46357
46384
|
return text11(raced.err instanceof Error ? raced.err.message : String(raced.err), true);
|
|
46358
46385
|
opts.learnedSlow?.add(t.name);
|
|
46359
46386
|
const sessionId = ctx2?.sessionId;
|
|
46360
|
-
const job = opts.registry.start(t.name, describeArgs2(t.name, args), async (
|
|
46387
|
+
const job = opts.registry.start(t.name, describeArgs2(t.name, args), async (write2) => {
|
|
46361
46388
|
try {
|
|
46362
|
-
|
|
46389
|
+
write2(await work);
|
|
46363
46390
|
} catch (err2) {
|
|
46364
46391
|
throw err2 instanceof Error ? err2 : new Error(String(err2));
|
|
46365
46392
|
}
|
|
@@ -79687,7 +79714,7 @@ function alphabet(letters) {
|
|
|
79687
79714
|
};
|
|
79688
79715
|
}
|
|
79689
79716
|
// @__NO_SIDE_EFFECTS__
|
|
79690
|
-
function
|
|
79717
|
+
function join67(separator = "") {
|
|
79691
79718
|
astr("join", separator);
|
|
79692
79719
|
return {
|
|
79693
79720
|
encode: (from) => {
|
|
@@ -79892,7 +79919,7 @@ var init_esm = __esm({
|
|
|
79892
79919
|
convertRadix2,
|
|
79893
79920
|
radix,
|
|
79894
79921
|
radix2,
|
|
79895
|
-
join:
|
|
79922
|
+
join: join67,
|
|
79896
79923
|
padding
|
|
79897
79924
|
};
|
|
79898
79925
|
}
|
|
@@ -81454,9 +81481,9 @@ async function readPassphrase(prompt2) {
|
|
|
81454
81481
|
}
|
|
81455
81482
|
const rl = createInterface2({ input: process.stdin, output: process.stdout, terminal: true });
|
|
81456
81483
|
const out = process.stdout;
|
|
81457
|
-
const
|
|
81484
|
+
const write2 = out.write.bind(out);
|
|
81458
81485
|
let muted = false;
|
|
81459
|
-
out.write = (chunk) => muted ? true :
|
|
81486
|
+
out.write = (chunk) => muted ? true : write2(chunk);
|
|
81460
81487
|
process.stdout.write(prompt2);
|
|
81461
81488
|
muted = true;
|
|
81462
81489
|
try {
|
|
@@ -81466,7 +81493,7 @@ async function readPassphrase(prompt2) {
|
|
|
81466
81493
|
}));
|
|
81467
81494
|
} finally {
|
|
81468
81495
|
muted = false;
|
|
81469
|
-
out.write =
|
|
81496
|
+
out.write = write2;
|
|
81470
81497
|
process.stdout.write("\n");
|
|
81471
81498
|
}
|
|
81472
81499
|
}
|
|
@@ -81725,9 +81752,9 @@ function toRewindOutcome(res, noHistory) {
|
|
|
81725
81752
|
}
|
|
81726
81753
|
|
|
81727
81754
|
// ../../packages/host-core/dist/control-link.js
|
|
81728
|
-
import { join as
|
|
81729
|
-
import { randomUUID as
|
|
81730
|
-
import { mkdirSync as
|
|
81755
|
+
import { join as join60, basename as basename11 } from "node:path";
|
|
81756
|
+
import { randomUUID as randomUUID24 } from "node:crypto";
|
|
81757
|
+
import { mkdirSync as mkdirSync29 } from "node:fs";
|
|
81731
81758
|
|
|
81732
81759
|
// ../../node_modules/ws/wrapper.mjs
|
|
81733
81760
|
var import_stream = __toESM(require_stream(), 1);
|
|
@@ -89219,8 +89246,8 @@ ${text12}`;
|
|
|
89219
89246
|
const t = await conn(threadCwd.get(sessionId) ?? spawnedCwd ?? projectDir ?? void 0);
|
|
89220
89247
|
if (!t)
|
|
89221
89248
|
return { ok: false, reason: `${label} is not reachable for this.` };
|
|
89222
|
-
const
|
|
89223
|
-
const turns2 = (
|
|
89249
|
+
const read = await t.request("thread/read", { threadId: sessionId, includeTurns: true }).catch(() => null);
|
|
89250
|
+
const turns2 = (read?.thread ?? {}).turns ?? [];
|
|
89224
89251
|
const at = turns2.findIndex((tn) => (tn.items ?? []).some((it) => it.id === uuid3));
|
|
89225
89252
|
if (at < 0)
|
|
89226
89253
|
return { ok: false, reason: `${label} no longer has that message.` };
|
|
@@ -99315,9 +99342,9 @@ async function startOutboundTransfer(msg, controllerClientId, ownHostId2, hostRo
|
|
|
99315
99342
|
break;
|
|
99316
99343
|
const len = Math.min(CHUNK2, f.size - offset);
|
|
99317
99344
|
const buf = Buffer.alloc(len);
|
|
99318
|
-
const
|
|
99319
|
-
send4({ type: "fs:transferChunk", transferId, toHost, fileIx, rel: f.rel, mode: f.mode, kind: "file", offset, base64: buf.subarray(0,
|
|
99320
|
-
state3.sentBytes +=
|
|
99345
|
+
const read = readSync7(fd, buf, 0, len, offset);
|
|
99346
|
+
send4({ type: "fs:transferChunk", transferId, toHost, fileIx, rel: f.rel, mode: f.mode, kind: "file", offset, base64: buf.subarray(0, read).toString("base64"), eof: offset + len >= f.size }, { hostId: toHost });
|
|
99347
|
+
state3.sentBytes += read;
|
|
99321
99348
|
}
|
|
99322
99349
|
}
|
|
99323
99350
|
} catch (e) {
|
|
@@ -100126,70 +100153,22 @@ init_credentials();
|
|
|
100126
100153
|
// ../../packages/host-core/dist/rdesk/machine-identity.js
|
|
100127
100154
|
init_credentials();
|
|
100128
100155
|
import { hostname as hostname3, platform } from "node:os";
|
|
100129
|
-
import { randomUUID as randomUUID24 } from "node:crypto";
|
|
100130
|
-
import { chmodSync as chmodSync3, existsSync as existsSync24, mkdirSync as mkdirSync27, readFileSync as readFileSync37, statSync as statSync14, unlinkSync as unlinkSync3, writeFileSync as writeFileSync25 } from "node:fs";
|
|
100131
|
-
import { join as join54 } from "node:path";
|
|
100132
|
-
|
|
100133
|
-
// ../../packages/host-core/dist/device-id.js
|
|
100134
|
-
init_base_paths();
|
|
100135
|
-
import { existsSync as existsSync23, mkdirSync as mkdirSync26, readFileSync as readFileSync36, writeFileSync as writeFileSync24 } from "node:fs";
|
|
100136
|
-
import { dirname as dirname24, join as join53 } from "node:path";
|
|
100137
100156
|
import { randomUUID as randomUUID23 } from "node:crypto";
|
|
100138
|
-
|
|
100139
|
-
|
|
100140
|
-
|
|
100141
|
-
function read() {
|
|
100142
|
-
try {
|
|
100143
|
-
const raw = JSON.parse(readFileSync36(deviceIdFile(), "utf-8"));
|
|
100144
|
-
const deviceId3 = typeof raw.deviceId === "string" && raw.deviceId ? raw.deviceId : null;
|
|
100145
|
-
const aliases = Array.isArray(raw.aliases) ? raw.aliases.filter((a) => typeof a === "string" && !!a) : [];
|
|
100146
|
-
return { deviceId: deviceId3, aliases };
|
|
100147
|
-
} catch {
|
|
100148
|
-
return { deviceId: null, aliases: [] };
|
|
100149
|
-
}
|
|
100150
|
-
}
|
|
100151
|
-
function write(deviceId3, aliases) {
|
|
100152
|
-
try {
|
|
100153
|
-
const f = deviceIdFile();
|
|
100154
|
-
const dir2 = dirname24(f);
|
|
100155
|
-
if (!existsSync23(dir2))
|
|
100156
|
-
mkdirSync26(dir2, { recursive: true });
|
|
100157
|
-
writeFileSync24(f, JSON.stringify(aliases.length ? { deviceId: deviceId3, aliases } : { deviceId: deviceId3 }));
|
|
100158
|
-
} catch {
|
|
100159
|
-
}
|
|
100160
|
-
}
|
|
100161
|
-
function persistentDeviceId() {
|
|
100162
|
-
const cur = read();
|
|
100163
|
-
if (cur.deviceId)
|
|
100164
|
-
return cur.deviceId;
|
|
100165
|
-
const id = randomUUID23().slice(0, 8);
|
|
100166
|
-
write(id, cur.aliases);
|
|
100167
|
-
return id;
|
|
100168
|
-
}
|
|
100169
|
-
function addDeviceIdAlias(old) {
|
|
100170
|
-
if (!old)
|
|
100171
|
-
return;
|
|
100172
|
-
const cur = read();
|
|
100173
|
-
const deviceId3 = cur.deviceId ?? persistentDeviceId();
|
|
100174
|
-
if (old === deviceId3 || cur.aliases.includes(old))
|
|
100175
|
-
return;
|
|
100176
|
-
write(deviceId3, [...cur.aliases, old]);
|
|
100177
|
-
}
|
|
100178
|
-
|
|
100179
|
-
// ../../packages/host-core/dist/rdesk/machine-identity.js
|
|
100180
|
-
var FILE = () => join54(daemonDir2(), "machine-identity.json");
|
|
100157
|
+
import { chmodSync as chmodSync3, existsSync as existsSync23, mkdirSync as mkdirSync26, readFileSync as readFileSync36, statSync as statSync14, unlinkSync as unlinkSync3, writeFileSync as writeFileSync24 } from "node:fs";
|
|
100158
|
+
import { join as join53 } from "node:path";
|
|
100159
|
+
var FILE = () => join53(daemonDir2(), "machine-identity.json");
|
|
100181
100160
|
function readMachineIdentity() {
|
|
100182
100161
|
try {
|
|
100183
|
-
const m = JSON.parse(
|
|
100162
|
+
const m = JSON.parse(readFileSync36(FILE(), "utf-8"));
|
|
100184
100163
|
return m?.deviceToken && m?.publicId ? m : null;
|
|
100185
100164
|
} catch {
|
|
100186
100165
|
return null;
|
|
100187
100166
|
}
|
|
100188
100167
|
}
|
|
100189
|
-
function
|
|
100168
|
+
function write(m) {
|
|
100190
100169
|
try {
|
|
100191
|
-
|
|
100192
|
-
|
|
100170
|
+
mkdirSync26(daemonDir2(), { recursive: true, mode: 448 });
|
|
100171
|
+
writeFileSync24(FILE(), JSON.stringify(m, null, 2), { mode: 384 });
|
|
100193
100172
|
chmodSync3(FILE(), 384);
|
|
100194
100173
|
} catch {
|
|
100195
100174
|
}
|
|
@@ -100224,14 +100203,14 @@ async function ensureMachineIdentity(opts) {
|
|
|
100224
100203
|
});
|
|
100225
100204
|
return inflight;
|
|
100226
100205
|
}
|
|
100227
|
-
var LOCK = () =>
|
|
100206
|
+
var LOCK = () => join53(daemonDir2(), "machine-identity.lock");
|
|
100228
100207
|
var LOCK_STALE_MS = 3e4;
|
|
100229
100208
|
function tryRegistrationLock() {
|
|
100230
100209
|
const f = LOCK();
|
|
100231
100210
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
100232
100211
|
try {
|
|
100233
|
-
|
|
100234
|
-
|
|
100212
|
+
mkdirSync26(daemonDir2(), { recursive: true, mode: 448 });
|
|
100213
|
+
writeFileSync24(f, String(process.pid), { flag: "wx" });
|
|
100235
100214
|
return true;
|
|
100236
100215
|
} catch {
|
|
100237
100216
|
try {
|
|
@@ -100268,15 +100247,8 @@ async function ensureMachineIdentityOnce(opts) {
|
|
|
100268
100247
|
return null;
|
|
100269
100248
|
}
|
|
100270
100249
|
let m = readMachineIdentity();
|
|
100271
|
-
if (m && opts.deviceId
|
|
100272
|
-
|
|
100273
|
-
m = { ...m, deviceId: opts.deviceId };
|
|
100274
|
-
delete m.accessToken;
|
|
100275
|
-
delete m.expiresAt;
|
|
100276
|
-
write2(m);
|
|
100277
|
-
addDeviceIdAlias(old);
|
|
100278
|
-
log9?.(`machine identity: device id ${old} \u2192 ${opts.deviceId} (the id this computer uses whether signed in or not; ${old} kept as an alias)`);
|
|
100279
|
-
}
|
|
100250
|
+
if (m && opts.deviceId)
|
|
100251
|
+
m = adoptPersistentDeviceId(opts.deviceId, log9).identity ?? m;
|
|
100280
100252
|
try {
|
|
100281
100253
|
if (!m) {
|
|
100282
100254
|
if (!tryRegistrationLock()) {
|
|
@@ -100293,11 +100265,11 @@ async function ensureMachineIdentityOnce(opts) {
|
|
|
100293
100265
|
m = {
|
|
100294
100266
|
deviceToken: reg.token,
|
|
100295
100267
|
publicId: reg.publicId,
|
|
100296
|
-
deviceId: opts.deviceId ??
|
|
100268
|
+
deviceId: opts.deviceId ?? randomUUID23().slice(0, 8),
|
|
100297
100269
|
apiOrigin: apiOrigin2,
|
|
100298
100270
|
backendOrigin: backendOrigin2
|
|
100299
100271
|
};
|
|
100300
|
-
|
|
100272
|
+
write(m);
|
|
100301
100273
|
log9?.(`machine identity: registered \u2014 this machine can be reached as ${reg.publicId}`);
|
|
100302
100274
|
}
|
|
100303
100275
|
} finally {
|
|
@@ -100308,7 +100280,7 @@ async function ensureMachineIdentityOnce(opts) {
|
|
|
100308
100280
|
if (!tokenUsable(m)) {
|
|
100309
100281
|
const t = await postJson(`${apiOrigin2}/auth/device/relay-token`, { deviceToken: m.deviceToken, deviceId: m.deviceId });
|
|
100310
100282
|
m = { ...m, accessToken: t.accessToken, expiresAt: t.expiresAt, publicId: t.publicId, apiOrigin: apiOrigin2, backendOrigin: backendOrigin2 };
|
|
100311
|
-
|
|
100283
|
+
write(m);
|
|
100312
100284
|
log9?.("machine identity: relay token minted");
|
|
100313
100285
|
}
|
|
100314
100286
|
return m;
|
|
@@ -100317,6 +100289,18 @@ async function ensureMachineIdentityOnce(opts) {
|
|
|
100317
100289
|
return m && tokenUsable(m) ? m : null;
|
|
100318
100290
|
}
|
|
100319
100291
|
}
|
|
100292
|
+
function adoptPersistentDeviceId(deviceId3, log9) {
|
|
100293
|
+
const m = readMachineIdentity();
|
|
100294
|
+
if (!m || !deviceId3 || m.deviceId === deviceId3)
|
|
100295
|
+
return { identity: m, migratedFrom: null };
|
|
100296
|
+
const old = m.deviceId;
|
|
100297
|
+
const next = { ...m, deviceId: deviceId3 };
|
|
100298
|
+
delete next.accessToken;
|
|
100299
|
+
delete next.expiresAt;
|
|
100300
|
+
write(next);
|
|
100301
|
+
log9?.(`machine identity: device id ${old} \u2192 ${deviceId3} (the id this computer has whether signed in or not)`);
|
|
100302
|
+
return { identity: next, migratedFrom: old };
|
|
100303
|
+
}
|
|
100320
100304
|
|
|
100321
100305
|
// ../../packages/host-core/dist/rdesk/server-auth.js
|
|
100322
100306
|
var DEFAULT_API = (process.env.CCB_TESSERACT_API ?? "https://app.tesseract.dev").replace(/\/$/, "");
|
|
@@ -100354,14 +100338,14 @@ function getMachinePublicId() {
|
|
|
100354
100338
|
|
|
100355
100339
|
// ../../packages/host-core/dist/active-link/engine.js
|
|
100356
100340
|
import { lstat as lstat7, readlink as readlink4, rm as rm4, mkdir as mkdir13, symlink as symlink2, rename as rename3, utimes as utimes2, writeFile as writeFile12 } from "node:fs/promises";
|
|
100357
|
-
import { existsSync as
|
|
100358
|
-
import { dirname as
|
|
100341
|
+
import { existsSync as existsSync25 } from "node:fs";
|
|
100342
|
+
import { dirname as dirname27, join as join58, resolve as resolve11 } from "node:path";
|
|
100359
100343
|
|
|
100360
100344
|
// ../../packages/host-core/dist/active-link/blocks.js
|
|
100361
100345
|
import { createHash as createHash5 } from "node:crypto";
|
|
100362
100346
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
100363
100347
|
import { open as open4, mkdir as mkdir12, rename as rename2, chmod as chmod2, utimes, unlink } from "node:fs/promises";
|
|
100364
|
-
import { dirname as
|
|
100348
|
+
import { dirname as dirname24 } from "node:path";
|
|
100365
100349
|
var CHUNK3 = 1024 * 1024;
|
|
100366
100350
|
var MAX_INFLIGHT2 = 8 * CHUNK3;
|
|
100367
100351
|
var IDLE_MS2 = 6e4;
|
|
@@ -100489,7 +100473,7 @@ var StagingWriter = class {
|
|
|
100489
100473
|
}
|
|
100490
100474
|
async ensureOpen() {
|
|
100491
100475
|
if (!this.fh) {
|
|
100492
|
-
await mkdir12(
|
|
100476
|
+
await mkdir12(dirname24(this.stagingPath), { recursive: true });
|
|
100493
100477
|
this.fh = await open4(this.stagingPath, "w");
|
|
100494
100478
|
}
|
|
100495
100479
|
return this.fh;
|
|
@@ -100519,7 +100503,7 @@ var StagingWriter = class {
|
|
|
100519
100503
|
});
|
|
100520
100504
|
await fh.close();
|
|
100521
100505
|
this.fh = null;
|
|
100522
|
-
await mkdir12(
|
|
100506
|
+
await mkdir12(dirname24(dest), { recursive: true });
|
|
100523
100507
|
await chmod2(this.stagingPath, mode & 511).catch(() => {
|
|
100524
100508
|
});
|
|
100525
100509
|
const secs = mtimeMs / 1e3;
|
|
@@ -100552,7 +100536,7 @@ var BlockAssembler = class {
|
|
|
100552
100536
|
this.stagingPath = stagingPath;
|
|
100553
100537
|
}
|
|
100554
100538
|
async open() {
|
|
100555
|
-
await mkdir12(
|
|
100539
|
+
await mkdir12(dirname24(this.stagingPath), { recursive: true });
|
|
100556
100540
|
this.fh = await open4(this.stagingPath, "w");
|
|
100557
100541
|
}
|
|
100558
100542
|
/** Write a received block at its byte offset (index * CHUNK). */
|
|
@@ -100596,7 +100580,7 @@ var BlockAssembler = class {
|
|
|
100596
100580
|
});
|
|
100597
100581
|
return false;
|
|
100598
100582
|
}
|
|
100599
|
-
await mkdir12(
|
|
100583
|
+
await mkdir12(dirname24(dest), { recursive: true });
|
|
100600
100584
|
await chmod2(this.stagingPath, mode & 511).catch(() => {
|
|
100601
100585
|
});
|
|
100602
100586
|
const secs = mtimeMs / 1e3;
|
|
@@ -100619,8 +100603,8 @@ var BlockAssembler = class {
|
|
|
100619
100603
|
};
|
|
100620
100604
|
|
|
100621
100605
|
// ../../packages/host-core/dist/active-link/manifest.js
|
|
100622
|
-
import { readFileSync as
|
|
100623
|
-
import { join as
|
|
100606
|
+
import { readFileSync as readFileSync37, writeFileSync as writeFileSync25, mkdirSync as mkdirSync27, existsSync as existsSync24, renameSync as renameSync8 } from "node:fs";
|
|
100607
|
+
import { join as join54 } from "node:path";
|
|
100624
100608
|
|
|
100625
100609
|
// ../../packages/host-core/dist/active-link/reconcile.js
|
|
100626
100610
|
var ABSENT = { kind: "absent", t: -Infinity, hash: "" };
|
|
@@ -100656,11 +100640,11 @@ var LinkManifest = class {
|
|
|
100656
100640
|
this.dir = dir2;
|
|
100657
100641
|
}
|
|
100658
100642
|
file() {
|
|
100659
|
-
return
|
|
100643
|
+
return join54(this.dir, "manifest.json");
|
|
100660
100644
|
}
|
|
100661
100645
|
load() {
|
|
100662
100646
|
try {
|
|
100663
|
-
const raw = JSON.parse(
|
|
100647
|
+
const raw = JSON.parse(readFileSync37(this.file(), "utf-8"));
|
|
100664
100648
|
this.records = new Map(Object.entries(raw.records ?? {}));
|
|
100665
100649
|
this.tombstones = new Map(Object.entries(raw.tombstones ?? {}));
|
|
100666
100650
|
} catch {
|
|
@@ -100741,14 +100725,14 @@ var LinkManifest = class {
|
|
|
100741
100725
|
if (!this.dirty)
|
|
100742
100726
|
return;
|
|
100743
100727
|
try {
|
|
100744
|
-
if (!
|
|
100745
|
-
|
|
100728
|
+
if (!existsSync24(this.dir))
|
|
100729
|
+
mkdirSync27(this.dir, { recursive: true });
|
|
100746
100730
|
const json3 = {
|
|
100747
100731
|
records: Object.fromEntries(this.records),
|
|
100748
100732
|
tombstones: Object.fromEntries(this.tombstones)
|
|
100749
100733
|
};
|
|
100750
100734
|
const tmp = `${this.file()}.tmp`;
|
|
100751
|
-
|
|
100735
|
+
writeFileSync25(tmp, JSON.stringify(json3));
|
|
100752
100736
|
renameSync8(tmp, this.file());
|
|
100753
100737
|
this.dirty = false;
|
|
100754
100738
|
} catch {
|
|
@@ -100758,7 +100742,7 @@ var LinkManifest = class {
|
|
|
100758
100742
|
|
|
100759
100743
|
// ../../packages/host-core/dist/active-link/scanner.js
|
|
100760
100744
|
import { readdir as readdir7, lstat as lstat3, readlink as readlink2 } from "node:fs/promises";
|
|
100761
|
-
import { join as
|
|
100745
|
+
import { join as join55, sep as sep10 } from "node:path";
|
|
100762
100746
|
async function walkRels(root, extraIgnore) {
|
|
100763
100747
|
const out = [];
|
|
100764
100748
|
async function rec(dir2) {
|
|
@@ -100773,7 +100757,7 @@ async function walkRels(root, extraIgnore) {
|
|
|
100773
100757
|
continue;
|
|
100774
100758
|
if (e.isDirectory() && HEAVY_DIRS.has(e.name))
|
|
100775
100759
|
continue;
|
|
100776
|
-
const abs =
|
|
100760
|
+
const abs = join55(dir2, e.name);
|
|
100777
100761
|
if (extraIgnore?.(abs))
|
|
100778
100762
|
continue;
|
|
100779
100763
|
if (e.isDirectory())
|
|
@@ -100812,7 +100796,7 @@ async function scanTree(root, prior, allow, extraIgnore) {
|
|
|
100812
100796
|
return { records };
|
|
100813
100797
|
}
|
|
100814
100798
|
function absOf(root, rel) {
|
|
100815
|
-
return
|
|
100799
|
+
return join55(root, rel.split("/").join(sep10));
|
|
100816
100800
|
}
|
|
100817
100801
|
|
|
100818
100802
|
// ../../packages/host-core/dist/active-link/gitignore.js
|
|
@@ -102837,7 +102821,7 @@ var ActiveLinkEngine = class {
|
|
|
102837
102821
|
}
|
|
102838
102822
|
async start() {
|
|
102839
102823
|
this.emit({ type: "status", linkId: this.opts.linkId, state: "scanning" });
|
|
102840
|
-
await rm4(
|
|
102824
|
+
await rm4(join58(this.stateDir, ".staging"), { recursive: true, force: true }).catch(() => {
|
|
102841
102825
|
});
|
|
102842
102826
|
this.manifest.load();
|
|
102843
102827
|
await this.reconcileScan();
|
|
@@ -103232,13 +103216,13 @@ var ActiveLinkEngine = class {
|
|
|
103232
103216
|
* file so the path still exists — recorded as a FILE matching disk so the local
|
|
103233
103217
|
* watcher doesn't churn. The target is containment-checked, never dereferenced. */
|
|
103234
103218
|
async applySymlink(rel, dest, target, mtimeMs, mode) {
|
|
103235
|
-
const resolved = resolve11(
|
|
103219
|
+
const resolved = resolve11(dirname27(dest), target);
|
|
103236
103220
|
if (!isInsideRoot(resolved, this.opts.localRoot))
|
|
103237
103221
|
return;
|
|
103238
103222
|
const hash2 = hashString(target);
|
|
103239
103223
|
const secs = mtimeMs / 1e3;
|
|
103240
103224
|
try {
|
|
103241
|
-
await mkdir13(
|
|
103225
|
+
await mkdir13(dirname27(dest), { recursive: true });
|
|
103242
103226
|
await rm4(dest, { force: true, recursive: true });
|
|
103243
103227
|
try {
|
|
103244
103228
|
await symlink2(target, dest);
|
|
@@ -103290,7 +103274,7 @@ var ActiveLinkEngine = class {
|
|
|
103290
103274
|
return;
|
|
103291
103275
|
if (fromRec && fromRec.kind === "file") {
|
|
103292
103276
|
try {
|
|
103293
|
-
await mkdir13(
|
|
103277
|
+
await mkdir13(dirname27(toAbs2), { recursive: true });
|
|
103294
103278
|
await rename3(fromAbs, toAbs2);
|
|
103295
103279
|
const secs = mtimeMs / 1e3;
|
|
103296
103280
|
await utimes2(toAbs2, secs, secs).catch(() => {
|
|
@@ -103315,7 +103299,7 @@ var ActiveLinkEngine = class {
|
|
|
103315
103299
|
await this.maybeRefreshAllow(rels);
|
|
103316
103300
|
const state3 = /* @__PURE__ */ new Map();
|
|
103317
103301
|
for (const rel of rels) {
|
|
103318
|
-
if (
|
|
103302
|
+
if (existsSync25(absOf(this.opts.localRoot, rel)) && !this.isSynced(rel)) {
|
|
103319
103303
|
this.manifest.dropRecord(rel);
|
|
103320
103304
|
continue;
|
|
103321
103305
|
}
|
|
@@ -103419,7 +103403,7 @@ var ActiveLinkEngine = class {
|
|
|
103419
103403
|
for (const rel of this.manifest.recordRels()) {
|
|
103420
103404
|
if (records.has(rel))
|
|
103421
103405
|
continue;
|
|
103422
|
-
if (
|
|
103406
|
+
if (existsSync25(absOf(this.opts.localRoot, rel)))
|
|
103423
103407
|
this.manifest.dropRecord(rel);
|
|
103424
103408
|
else
|
|
103425
103409
|
this.manifest.setTombstone(rel, now2);
|
|
@@ -103465,7 +103449,7 @@ var ActiveLinkEngine = class {
|
|
|
103465
103449
|
this.inboundWatchdog.clear();
|
|
103466
103450
|
}
|
|
103467
103451
|
stagingPath(rel, tag) {
|
|
103468
|
-
return
|
|
103452
|
+
return join58(this.stateDir, ".staging", `${hashString(rel)}.${tag}`);
|
|
103469
103453
|
}
|
|
103470
103454
|
pruneSuppress() {
|
|
103471
103455
|
const now2 = this.now();
|
|
@@ -103490,14 +103474,14 @@ var ActiveLinkEngine = class {
|
|
|
103490
103474
|
};
|
|
103491
103475
|
|
|
103492
103476
|
// ../../packages/host-core/dist/active-link/config.js
|
|
103493
|
-
import { readFileSync as
|
|
103494
|
-
import { join as
|
|
103477
|
+
import { readFileSync as readFileSync38, writeFileSync as writeFileSync26, mkdirSync as mkdirSync28, existsSync as existsSync26, renameSync as renameSync9, watch as watch3 } from "node:fs";
|
|
103478
|
+
import { join as join59 } from "node:path";
|
|
103495
103479
|
function configPath2() {
|
|
103496
|
-
return
|
|
103480
|
+
return join59(activeLinkRoot(), "links.json");
|
|
103497
103481
|
}
|
|
103498
103482
|
function loadLinkConfigs() {
|
|
103499
103483
|
try {
|
|
103500
|
-
const raw = JSON.parse(
|
|
103484
|
+
const raw = JSON.parse(readFileSync38(configPath2(), "utf-8"));
|
|
103501
103485
|
if (!Array.isArray(raw.links))
|
|
103502
103486
|
return [];
|
|
103503
103487
|
return raw.links.filter((c) => c && c.linkId && c.localRoot && c.peerHostId);
|
|
@@ -103508,10 +103492,10 @@ function loadLinkConfigs() {
|
|
|
103508
103492
|
function writeAll(links) {
|
|
103509
103493
|
try {
|
|
103510
103494
|
const dir2 = activeLinkRoot();
|
|
103511
|
-
if (!
|
|
103512
|
-
|
|
103495
|
+
if (!existsSync26(dir2))
|
|
103496
|
+
mkdirSync28(dir2, { recursive: true });
|
|
103513
103497
|
const tmp = `${configPath2()}.tmp`;
|
|
103514
|
-
|
|
103498
|
+
writeFileSync26(tmp, JSON.stringify({ links }, null, 2));
|
|
103515
103499
|
renameSync9(tmp, configPath2());
|
|
103516
103500
|
} catch {
|
|
103517
103501
|
}
|
|
@@ -103530,11 +103514,11 @@ function saveLinkConfig(cfg2) {
|
|
|
103530
103514
|
writeAll(links);
|
|
103531
103515
|
}
|
|
103532
103516
|
function pendingPath() {
|
|
103533
|
-
return
|
|
103517
|
+
return join59(activeLinkRoot(), "pending-deprovisions.json");
|
|
103534
103518
|
}
|
|
103535
103519
|
function loadPendingDeprovisions() {
|
|
103536
103520
|
try {
|
|
103537
|
-
const raw = JSON.parse(
|
|
103521
|
+
const raw = JSON.parse(readFileSync38(pendingPath(), "utf-8"));
|
|
103538
103522
|
return Array.isArray(raw.pending) ? raw.pending.filter((p) => p && p.linkId && p.peerHostId) : [];
|
|
103539
103523
|
} catch {
|
|
103540
103524
|
return [];
|
|
@@ -103543,10 +103527,10 @@ function loadPendingDeprovisions() {
|
|
|
103543
103527
|
function writePending(pending2) {
|
|
103544
103528
|
try {
|
|
103545
103529
|
const dir2 = activeLinkRoot();
|
|
103546
|
-
if (!
|
|
103547
|
-
|
|
103530
|
+
if (!existsSync26(dir2))
|
|
103531
|
+
mkdirSync28(dir2, { recursive: true });
|
|
103548
103532
|
const tmp = `${pendingPath()}.tmp`;
|
|
103549
|
-
|
|
103533
|
+
writeFileSync26(tmp, JSON.stringify({ pending: pending2 }, null, 2));
|
|
103550
103534
|
renameSync9(tmp, pendingPath());
|
|
103551
103535
|
} catch {
|
|
103552
103536
|
}
|
|
@@ -103559,8 +103543,8 @@ function removeLinkConfig(linkId) {
|
|
|
103559
103543
|
}
|
|
103560
103544
|
function watchLinkConfigs(onChange) {
|
|
103561
103545
|
const dir2 = activeLinkRoot();
|
|
103562
|
-
if (!
|
|
103563
|
-
|
|
103546
|
+
if (!existsSync26(dir2))
|
|
103547
|
+
mkdirSync28(dir2, { recursive: true });
|
|
103564
103548
|
let timer2 = null;
|
|
103565
103549
|
let watcher = null;
|
|
103566
103550
|
try {
|
|
@@ -103705,7 +103689,7 @@ function routeInboundLinkFrame(frame) {
|
|
|
103705
103689
|
init_dist5();
|
|
103706
103690
|
|
|
103707
103691
|
// ../../packages/host-core/dist/pty-manager.js
|
|
103708
|
-
import { existsSync as
|
|
103692
|
+
import { existsSync as existsSync27 } from "node:fs";
|
|
103709
103693
|
import { homedir as homedir9 } from "node:os";
|
|
103710
103694
|
init_safe_kill();
|
|
103711
103695
|
var ptyPromise = null;
|
|
@@ -103860,7 +103844,7 @@ function listUnix() {
|
|
|
103860
103844
|
const seen = /* @__PURE__ */ new Set();
|
|
103861
103845
|
const loginShell = process.env.SHELL || "";
|
|
103862
103846
|
const add2 = (id, path6) => {
|
|
103863
|
-
if (!path6 || seen.has(path6) || !
|
|
103847
|
+
if (!path6 || seen.has(path6) || !existsSync27(path6))
|
|
103864
103848
|
return;
|
|
103865
103849
|
seen.add(path6);
|
|
103866
103850
|
out.push(mk(id, path6, path6 === loginShell));
|
|
@@ -103892,7 +103876,7 @@ function listWindows() {
|
|
|
103892
103876
|
const gitBash = `${pf}\\Git\\bin\\bash.exe`;
|
|
103893
103877
|
const pwsh7 = `${pf}\\PowerShell\\7\\pwsh.exe`;
|
|
103894
103878
|
const add2 = (id, path6, label, isDefault = false) => {
|
|
103895
|
-
if (path6 &&
|
|
103879
|
+
if (path6 && existsSync27(path6))
|
|
103896
103880
|
out.push(mk(id, path6, isDefault, label));
|
|
103897
103881
|
};
|
|
103898
103882
|
add2("powershell", winPwsh, "Windows PowerShell", true);
|
|
@@ -103951,7 +103935,7 @@ function resolveCwd(cwd, hostRoot) {
|
|
|
103951
103935
|
const fallback = hostRoot || homedir9();
|
|
103952
103936
|
if (!cwd)
|
|
103953
103937
|
return fallback;
|
|
103954
|
-
if (!
|
|
103938
|
+
if (!existsSync27(cwd))
|
|
103955
103939
|
return fallback;
|
|
103956
103940
|
if (hostRoot && !isInsideRoot(cwd, hostRoot))
|
|
103957
103941
|
return hostRoot;
|
|
@@ -104145,7 +104129,7 @@ async function ensureP2pReady() {
|
|
|
104145
104129
|
}
|
|
104146
104130
|
}
|
|
104147
104131
|
function ownHostId() {
|
|
104148
|
-
const mine = serverHosts.find((h) => h.
|
|
104132
|
+
const mine = serverHosts.find((h) => h.deviceId === deviceId);
|
|
104149
104133
|
return mine?.hostId ?? "local";
|
|
104150
104134
|
}
|
|
104151
104135
|
var lastOwnHostLog = null;
|
|
@@ -104159,9 +104143,10 @@ function logOwnHostVerdict() {
|
|
|
104159
104143
|
}
|
|
104160
104144
|
function presentedHosts() {
|
|
104161
104145
|
const out = serverHosts.slice();
|
|
104162
|
-
if (!out.some((h) => h.
|
|
104146
|
+
if (!out.some((h) => h.deviceId === deviceId)) {
|
|
104163
104147
|
out.unshift({
|
|
104164
104148
|
hostId: "local",
|
|
104149
|
+
deviceId,
|
|
104165
104150
|
name: hostname4(),
|
|
104166
104151
|
kind: "electron",
|
|
104167
104152
|
platform: process.platform,
|
|
@@ -104176,7 +104161,7 @@ function presentedHosts() {
|
|
|
104176
104161
|
}
|
|
104177
104162
|
function connectedFsHosts() {
|
|
104178
104163
|
const mine = ownHostId();
|
|
104179
|
-
return serverHosts.filter((h) => h.online && h.hostId !== mine &&
|
|
104164
|
+
return serverHosts.filter((h) => h.online && h.hostId !== mine && h.deviceId !== deviceId).filter((h) => h.kind === "electron" || h.kind === "cloud").filter((h) => !h.caps || h.caps.includes("fs")).map((h) => ({ hostId: h.hostId, label: h.name || (h.kind === "cloud" ? "Cloud agent" : "Remote machine") }));
|
|
104180
104165
|
}
|
|
104181
104166
|
function listHosts() {
|
|
104182
104167
|
return presentedHosts();
|
|
@@ -104184,16 +104169,6 @@ function listHosts() {
|
|
|
104184
104169
|
function ownHost() {
|
|
104185
104170
|
return ownHostId();
|
|
104186
104171
|
}
|
|
104187
|
-
function setControlLinkDeviceId(id) {
|
|
104188
|
-
if (!id || id === deviceId)
|
|
104189
|
-
return;
|
|
104190
|
-
deviceId = id;
|
|
104191
|
-
if (cfg)
|
|
104192
|
-
cfg = { ...cfg, deviceId: id };
|
|
104193
|
-
lastOwnHostLog = null;
|
|
104194
|
-
hooks?.ownHostResolved(ownHostId());
|
|
104195
|
-
hooks?.pushHosts(presentedHosts());
|
|
104196
|
-
}
|
|
104197
104172
|
function assertServerSelection() {
|
|
104198
104173
|
if (!socket || socket.readyState !== 1)
|
|
104199
104174
|
return;
|
|
@@ -104367,7 +104342,12 @@ function resumeActiveLinks() {
|
|
|
104367
104342
|
for (const { linkId } of listActiveLinks())
|
|
104368
104343
|
if (!configured.has(linkId))
|
|
104369
104344
|
void disconnectActiveLink(linkId);
|
|
104370
|
-
for (const
|
|
104345
|
+
for (const stored of configs) {
|
|
104346
|
+
const peerDevice = hostDeviceId(stored.peerHostId);
|
|
104347
|
+
const live = peerDevice ? serverHosts.find((h) => h.deviceId === peerDevice) : void 0;
|
|
104348
|
+
const cfg2 = live && live.hostId !== stored.peerHostId ? { ...stored, peerHostId: live.hostId } : stored;
|
|
104349
|
+
if (cfg2 !== stored)
|
|
104350
|
+
saveLinkConfig(cfg2);
|
|
104371
104351
|
connectActiveLink({
|
|
104372
104352
|
linkId: cfg2.linkId,
|
|
104373
104353
|
localRoot: cfg2.localRoot,
|
|
@@ -104420,9 +104400,9 @@ function provisionActiveLinkMirror(payload) {
|
|
|
104420
104400
|
const remoteSubfolder = typeof payload.remoteSubfolder === "string" ? payload.remoteSubfolder : void 0;
|
|
104421
104401
|
let localRoot;
|
|
104422
104402
|
if (remoteParent && remoteSubfolder) {
|
|
104423
|
-
localRoot =
|
|
104403
|
+
localRoot = join60(remoteParent, safeFolderName(remoteSubfolder));
|
|
104424
104404
|
} else {
|
|
104425
|
-
localRoot =
|
|
104405
|
+
localRoot = join60(HOST_ROOT, "Tesseract Mirrors", safeFolderName(projectName));
|
|
104426
104406
|
}
|
|
104427
104407
|
if (loadLinkConfigs().some((c) => c.localRoot === localRoot && c.linkId !== linkId)) {
|
|
104428
104408
|
localRoot = `${localRoot}-${linkId.slice(0, 6)}`;
|
|
@@ -104430,7 +104410,7 @@ function provisionActiveLinkMirror(payload) {
|
|
|
104430
104410
|
if (!isInsideRoot(localRoot, HOST_ROOT))
|
|
104431
104411
|
return;
|
|
104432
104412
|
try {
|
|
104433
|
-
|
|
104413
|
+
mkdirSync29(localRoot, { recursive: true });
|
|
104434
104414
|
} catch {
|
|
104435
104415
|
}
|
|
104436
104416
|
saveLinkConfig({
|
|
@@ -104738,7 +104718,7 @@ async function handleInboundAgent(msg, driverClientId) {
|
|
|
104738
104718
|
send3("agent", {
|
|
104739
104719
|
type: "agent:notice",
|
|
104740
104720
|
sessionId: msg.sessionId,
|
|
104741
|
-
noticeId:
|
|
104721
|
+
noticeId: randomUUID24(),
|
|
104742
104722
|
category: "model",
|
|
104743
104723
|
level: "warning",
|
|
104744
104724
|
title: "That model is not available on this device",
|
|
@@ -104967,10 +104947,19 @@ function handleHostChannel(payload) {
|
|
|
104967
104947
|
return;
|
|
104968
104948
|
}
|
|
104969
104949
|
if (payload.type === "host:register:denied") {
|
|
104950
|
+
const d = payload;
|
|
104951
|
+
if (d.reason === "revoked") {
|
|
104952
|
+
stopHeartbeat();
|
|
104953
|
+
teardownHostRole();
|
|
104954
|
+
const message2 = typeof payload.message === "string" ? payload.message : "This computer was removed from the account.";
|
|
104955
|
+
console.log(`[control-link] host:register DENIED reason=revoked \u2014 ${message2}`);
|
|
104956
|
+
hooks?.notify({ type: "notify", level: "warning", message: message2 });
|
|
104957
|
+
hooks?.onDeviceRevoked?.();
|
|
104958
|
+
return;
|
|
104959
|
+
}
|
|
104970
104960
|
entitlementDenied = true;
|
|
104971
104961
|
stopHeartbeat();
|
|
104972
104962
|
const message = typeof payload.message === "string" ? payload.message : "Running agents on your own machines requires a paid plan.";
|
|
104973
|
-
const d = payload;
|
|
104974
104963
|
console.log(`[control-link] host:register DENIED reason=${String(d.reason ?? "?")} feature=${String(d.feature ?? "?")} limit=${String(d.limit ?? "?")} \u2014 ${message}`);
|
|
104975
104964
|
hooks?.notify({ type: "notify", level: "warning", message });
|
|
104976
104965
|
scheduleEntitlementRetry();
|
|
@@ -105506,6 +105495,8 @@ function refreshControlLink() {
|
|
|
105506
105495
|
if (accountChanged) {
|
|
105507
105496
|
serverHosts = [];
|
|
105508
105497
|
serverSelected = false;
|
|
105498
|
+
entitlementDenied = false;
|
|
105499
|
+
cancelEntitlementRetry();
|
|
105509
105500
|
teardownHostRole();
|
|
105510
105501
|
hooks.pushHosts(presentedHosts());
|
|
105511
105502
|
hooks.ownHostResolved(ownHostId());
|
|
@@ -105537,9 +105528,9 @@ init_gateway_plan2();
|
|
|
105537
105528
|
init_base_paths();
|
|
105538
105529
|
init_credentials();
|
|
105539
105530
|
init_dist5();
|
|
105540
|
-
import { mkdirSync as
|
|
105541
|
-
import { randomUUID as
|
|
105542
|
-
import { dirname as
|
|
105531
|
+
import { mkdirSync as mkdirSync30, readFileSync as readFileSync39, writeFileSync as writeFileSync27 } from "node:fs";
|
|
105532
|
+
import { randomUUID as randomUUID25 } from "node:crypto";
|
|
105533
|
+
import { dirname as dirname28 } from "node:path";
|
|
105543
105534
|
var REFRESH_MS = 24 * 60 * 60 * 1e3;
|
|
105544
105535
|
var TIMEOUT_MS2 = 1e4;
|
|
105545
105536
|
var CACHE = () => tessPath("bundled-model.json");
|
|
@@ -105549,22 +105540,22 @@ function deviceId2() {
|
|
|
105549
105540
|
if (fromCredentials)
|
|
105550
105541
|
return fromCredentials;
|
|
105551
105542
|
try {
|
|
105552
|
-
const raw = JSON.parse(
|
|
105543
|
+
const raw = JSON.parse(readFileSync39(DEVICE_ID(), "utf8"));
|
|
105553
105544
|
if (typeof raw?.deviceId === "string" && raw.deviceId)
|
|
105554
105545
|
return raw.deviceId;
|
|
105555
105546
|
} catch {
|
|
105556
105547
|
}
|
|
105557
|
-
const fresh =
|
|
105548
|
+
const fresh = randomUUID25().slice(0, 8);
|
|
105558
105549
|
try {
|
|
105559
|
-
|
|
105560
|
-
|
|
105550
|
+
mkdirSync30(dirname28(DEVICE_ID()), { recursive: true });
|
|
105551
|
+
writeFileSync27(DEVICE_ID(), JSON.stringify({ deviceId: fresh }), { mode: 384 });
|
|
105561
105552
|
} catch {
|
|
105562
105553
|
}
|
|
105563
105554
|
return fresh;
|
|
105564
105555
|
}
|
|
105565
105556
|
function readCache() {
|
|
105566
105557
|
try {
|
|
105567
|
-
const raw = JSON.parse(
|
|
105558
|
+
const raw = JSON.parse(readFileSync39(CACHE(), "utf8"));
|
|
105568
105559
|
if (typeof raw?.apiKey === "string" && typeof raw.baseUrl === "string" && raw.models?.low && raw.models.high) {
|
|
105569
105560
|
return { ...raw, fetchedAt: raw.fetchedAt ?? 0 };
|
|
105570
105561
|
}
|
|
@@ -105574,8 +105565,8 @@ function readCache() {
|
|
|
105574
105565
|
}
|
|
105575
105566
|
function writeCache(key2) {
|
|
105576
105567
|
try {
|
|
105577
|
-
|
|
105578
|
-
|
|
105568
|
+
mkdirSync30(dirname28(CACHE()), { recursive: true });
|
|
105569
|
+
writeFileSync27(CACHE(), JSON.stringify({ ...key2, fetchedAt: Date.now() }, null, 2), { mode: 384 });
|
|
105579
105570
|
} catch (e) {
|
|
105580
105571
|
log(`gateway key: could not cache (${e.message})`);
|
|
105581
105572
|
}
|
|
@@ -106156,7 +106147,7 @@ Open System Settings \u2192 Privacy & Security \u2192 Screen Recording and switc
|
|
|
106156
106147
|
}
|
|
106157
106148
|
|
|
106158
106149
|
// ../../packages/host-core/dist/rdesk/publisher-window.js
|
|
106159
|
-
import { join as
|
|
106150
|
+
import { join as join61 } from "node:path";
|
|
106160
106151
|
var windows = /* @__PURE__ */ new Map();
|
|
106161
106152
|
var ipcInstalled = false;
|
|
106162
106153
|
function ensureIpc() {
|
|
@@ -106311,7 +106302,7 @@ var PublisherWindow = class {
|
|
|
106311
106302
|
win3.setContentProtection(true);
|
|
106312
106303
|
} catch {
|
|
106313
106304
|
}
|
|
106314
|
-
await win3.loadFile(
|
|
106305
|
+
await win3.loadFile(join61(daemonUiDir(), "publisher.html"));
|
|
106315
106306
|
this.send("rdesk:pub:start", {
|
|
106316
106307
|
sessionId: this.sessionId,
|
|
106317
106308
|
sourceId,
|
|
@@ -106356,7 +106347,7 @@ var PublisherWindow = class {
|
|
|
106356
106347
|
win3.setContentProtection(true);
|
|
106357
106348
|
} catch {
|
|
106358
106349
|
}
|
|
106359
|
-
await win3.loadFile(
|
|
106350
|
+
await win3.loadFile(join61(daemonUiDir(), "publisher.html"));
|
|
106360
106351
|
this.send("rdesk:pub:start", {
|
|
106361
106352
|
sessionId: this.sessionId,
|
|
106362
106353
|
mode: "canvas",
|
|
@@ -106956,10 +106947,10 @@ function setInProcConnector(fn) {
|
|
|
106956
106947
|
|
|
106957
106948
|
// ../../packages/host-core/dist/rdesk/server-prefs.js
|
|
106958
106949
|
init_credentials();
|
|
106959
|
-
import { readFileSync as
|
|
106960
|
-
import { join as
|
|
106950
|
+
import { readFileSync as readFileSync40, writeFileSync as writeFileSync28 } from "node:fs";
|
|
106951
|
+
import { join as join62 } from "node:path";
|
|
106961
106952
|
function rdeskServerPrefsPath() {
|
|
106962
|
-
return
|
|
106953
|
+
return join62(daemonDir2(), "rdesk-server.json");
|
|
106963
106954
|
}
|
|
106964
106955
|
var DEFAULTS2 = {
|
|
106965
106956
|
enabled: true,
|
|
@@ -106971,7 +106962,7 @@ var DEFAULTS2 = {
|
|
|
106971
106962
|
};
|
|
106972
106963
|
function readRdeskServerPrefs() {
|
|
106973
106964
|
try {
|
|
106974
|
-
const p = JSON.parse(
|
|
106965
|
+
const p = JSON.parse(readFileSync40(rdeskServerPrefsPath(), "utf8"));
|
|
106975
106966
|
return {
|
|
106976
106967
|
// `!== false` (not `?? true`): only an explicit opt-out disables sharing, so a
|
|
106977
106968
|
// partially-written or older prefs file never silently turns the machine off.
|
|
@@ -106989,7 +106980,7 @@ function readRdeskServerPrefs() {
|
|
|
106989
106980
|
function writeRdeskServerPrefs(patch) {
|
|
106990
106981
|
try {
|
|
106991
106982
|
const next = { ...readRdeskServerPrefs(), ...patch };
|
|
106992
|
-
|
|
106983
|
+
writeFileSync28(rdeskServerPrefsPath(), JSON.stringify(next), { mode: 384 });
|
|
106993
106984
|
} catch {
|
|
106994
106985
|
}
|
|
106995
106986
|
}
|
|
@@ -107004,13 +106995,13 @@ function rdeskSharingEnabled() {
|
|
|
107004
106995
|
// ../../packages/host-core/dist/rdesk/password.js
|
|
107005
106996
|
init_credentials();
|
|
107006
106997
|
import { scryptSync, randomBytes as randomBytes5, timingSafeEqual as timingSafeEqual4, randomInt } from "node:crypto";
|
|
107007
|
-
import { readFileSync as
|
|
107008
|
-
import { join as
|
|
106998
|
+
import { readFileSync as readFileSync41, writeFileSync as writeFileSync29, existsSync as existsSync28, unlinkSync as unlinkSync4 } from "node:fs";
|
|
106999
|
+
import { join as join63 } from "node:path";
|
|
107009
107000
|
function pwFile() {
|
|
107010
|
-
return
|
|
107001
|
+
return join63(daemonDir2(), "rdesk-password.json");
|
|
107011
107002
|
}
|
|
107012
107003
|
function pwPlainFile() {
|
|
107013
|
-
return
|
|
107004
|
+
return join63(daemonDir2(), "rdesk-password.enc");
|
|
107014
107005
|
}
|
|
107015
107006
|
var PW_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789";
|
|
107016
107007
|
var PW_LENGTH = 16;
|
|
@@ -107025,14 +107016,14 @@ function writePlain(password) {
|
|
|
107025
107016
|
const safe2 = electronModule()?.safeStorage;
|
|
107026
107017
|
if (!safe2?.isEncryptionAvailable())
|
|
107027
107018
|
return;
|
|
107028
|
-
|
|
107019
|
+
writeFileSync29(pwPlainFile(), safe2.encryptString(password), { mode: 384 });
|
|
107029
107020
|
} catch {
|
|
107030
107021
|
}
|
|
107031
107022
|
}
|
|
107032
107023
|
function canRevealRdeskPassword() {
|
|
107033
107024
|
try {
|
|
107034
107025
|
const safe2 = electronModule()?.safeStorage;
|
|
107035
|
-
return !!safe2?.isEncryptionAvailable() &&
|
|
107026
|
+
return !!safe2?.isEncryptionAvailable() && existsSync28(pwPlainFile());
|
|
107036
107027
|
} catch {
|
|
107037
107028
|
return false;
|
|
107038
107029
|
}
|
|
@@ -107042,7 +107033,7 @@ function readRdeskPasswordPlain() {
|
|
|
107042
107033
|
const safe2 = electronModule()?.safeStorage;
|
|
107043
107034
|
if (!safe2?.isEncryptionAvailable())
|
|
107044
107035
|
return null;
|
|
107045
|
-
return safe2.decryptString(
|
|
107036
|
+
return safe2.decryptString(readFileSync41(pwPlainFile()));
|
|
107046
107037
|
} catch {
|
|
107047
107038
|
return null;
|
|
107048
107039
|
}
|
|
@@ -107061,7 +107052,7 @@ function setRdeskPassword(password) {
|
|
|
107061
107052
|
}
|
|
107062
107053
|
const salt = randomBytes5(16);
|
|
107063
107054
|
const hash2 = scryptSync(password, salt, 32);
|
|
107064
|
-
|
|
107055
|
+
writeFileSync29(pwFile(), JSON.stringify({ salt: salt.toString("hex"), hash: hash2.toString("hex") }), { mode: 384 });
|
|
107065
107056
|
writePlain(password);
|
|
107066
107057
|
}
|
|
107067
107058
|
function regenerateRdeskPassword() {
|
|
@@ -107075,7 +107066,7 @@ function ensureRdeskPassword() {
|
|
|
107075
107066
|
return regenerateRdeskPassword();
|
|
107076
107067
|
}
|
|
107077
107068
|
function hasRdeskPassword() {
|
|
107078
|
-
return !!process.env.CCB_RDESK_PASSWORD ||
|
|
107069
|
+
return !!process.env.CCB_RDESK_PASSWORD || existsSync28(pwFile());
|
|
107079
107070
|
}
|
|
107080
107071
|
function verifyRdeskPassword(password) {
|
|
107081
107072
|
if (!password)
|
|
@@ -107084,7 +107075,7 @@ function verifyRdeskPassword(password) {
|
|
|
107084
107075
|
if (override3)
|
|
107085
107076
|
return password.length === override3.length && timingSafeEqual4(Buffer.from(password), Buffer.from(override3));
|
|
107086
107077
|
try {
|
|
107087
|
-
const { salt, hash: hash2 } = JSON.parse(
|
|
107078
|
+
const { salt, hash: hash2 } = JSON.parse(readFileSync41(pwFile(), "utf8"));
|
|
107088
107079
|
const got = scryptSync(password, Buffer.from(salt, "hex"), 32);
|
|
107089
107080
|
const want = Buffer.from(hash2, "hex");
|
|
107090
107081
|
return got.length === want.length && timingSafeEqual4(got, want);
|
|
@@ -107562,7 +107553,7 @@ function stopSystemEvents() {
|
|
|
107562
107553
|
}
|
|
107563
107554
|
|
|
107564
107555
|
// ../../packages/host-core/dist/local-server.js
|
|
107565
|
-
import { randomUUID as
|
|
107556
|
+
import { randomUUID as randomUUID27 } from "node:crypto";
|
|
107566
107557
|
init_daemon_settings();
|
|
107567
107558
|
|
|
107568
107559
|
// ../../packages/host-core/dist/vault/manager.js
|
|
@@ -107650,8 +107641,8 @@ function createPasskeyRegistration(rpId) {
|
|
|
107650
107641
|
|
|
107651
107642
|
// ../../packages/host-core/dist/vault/manager.js
|
|
107652
107643
|
init_base_paths();
|
|
107653
|
-
import { mkdirSync as
|
|
107654
|
-
import { dirname as
|
|
107644
|
+
import { mkdirSync as mkdirSync33, readFileSync as readFileSync44, writeFileSync as writeFileSync32 } from "node:fs";
|
|
107645
|
+
import { dirname as dirname30 } from "node:path";
|
|
107655
107646
|
|
|
107656
107647
|
// ../../packages/vault-core/dist/crypto.js
|
|
107657
107648
|
init_argon2();
|
|
@@ -108158,7 +108149,7 @@ var XJSON_AAD = utf8("tesseract-vault-encrypted-json-v1");
|
|
|
108158
108149
|
init_credentials();
|
|
108159
108150
|
|
|
108160
108151
|
// ../../packages/host-core/dist/vault/store.js
|
|
108161
|
-
import { randomUUID as
|
|
108152
|
+
import { randomUUID as randomUUID26 } from "node:crypto";
|
|
108162
108153
|
var b64 = (u) => Buffer.from(u).toString("base64");
|
|
108163
108154
|
var u82 = (s) => new Uint8Array(Buffer.from(s, "base64"));
|
|
108164
108155
|
var isServerRecoverableMeta = (m) => !m.wrappedVaultKey;
|
|
@@ -108460,7 +108451,7 @@ var VaultStore = class {
|
|
|
108460
108451
|
const existing = input.id ? items.get(input.id) : void 0;
|
|
108461
108452
|
const { id: _drop, name, folderId, favorite, reprompt, notes, tags, ...content } = input;
|
|
108462
108453
|
const item = {
|
|
108463
|
-
id: input.id ??
|
|
108454
|
+
id: input.id ?? randomUUID26(),
|
|
108464
108455
|
name,
|
|
108465
108456
|
folderId,
|
|
108466
108457
|
favorite,
|
|
@@ -108489,7 +108480,7 @@ var VaultStore = class {
|
|
|
108489
108480
|
const now2 = this.now();
|
|
108490
108481
|
for (const d of drafts) {
|
|
108491
108482
|
const { name, notes, favorite, tags, ...content } = d;
|
|
108492
|
-
const item = { id:
|
|
108483
|
+
const item = { id: randomUUID26(), name, notes, favorite, tags, createdAt: now2, updatedAt: now2, ...content };
|
|
108493
108484
|
items.set(item.id, item);
|
|
108494
108485
|
this.enc.set(item.id, await encryptItem(key2, item));
|
|
108495
108486
|
this.dirty.add(item.id);
|
|
@@ -108675,8 +108666,8 @@ function makeDaemonVaultApi(getOrigin, getToken2) {
|
|
|
108675
108666
|
|
|
108676
108667
|
// ../../packages/host-core/dist/vault/persistence.js
|
|
108677
108668
|
init_base_paths();
|
|
108678
|
-
import { existsSync as
|
|
108679
|
-
import { dirname as
|
|
108669
|
+
import { existsSync as existsSync29, mkdirSync as mkdirSync31, readFileSync as readFileSync42, writeFileSync as writeFileSync30, unlinkSync as unlinkSync5 } from "node:fs";
|
|
108670
|
+
import { dirname as dirname29 } from "node:path";
|
|
108680
108671
|
function vaultStoreFile() {
|
|
108681
108672
|
return homePath(".tesseract", "vault", "vault.json");
|
|
108682
108673
|
}
|
|
@@ -108687,9 +108678,9 @@ function makeVaultPersistence(file2 = vaultStoreFile, deviceKeyFile = vaultDevic
|
|
|
108687
108678
|
return {
|
|
108688
108679
|
load() {
|
|
108689
108680
|
try {
|
|
108690
|
-
if (!
|
|
108681
|
+
if (!existsSync29(file2()))
|
|
108691
108682
|
return null;
|
|
108692
|
-
const parsed = JSON.parse(
|
|
108683
|
+
const parsed = JSON.parse(readFileSync42(file2(), "utf8"));
|
|
108693
108684
|
if (!parsed || typeof parsed !== "object")
|
|
108694
108685
|
return null;
|
|
108695
108686
|
return { meta: parsed.meta ?? null, items: Array.isArray(parsed.items) ? parsed.items : [] };
|
|
@@ -108699,28 +108690,28 @@ function makeVaultPersistence(file2 = vaultStoreFile, deviceKeyFile = vaultDevic
|
|
|
108699
108690
|
},
|
|
108700
108691
|
save(state3) {
|
|
108701
108692
|
try {
|
|
108702
|
-
|
|
108703
|
-
|
|
108693
|
+
mkdirSync31(dirname29(file2()), { recursive: true, mode: 448 });
|
|
108694
|
+
writeFileSync30(file2(), JSON.stringify(state3), { mode: 384 });
|
|
108704
108695
|
} catch {
|
|
108705
108696
|
}
|
|
108706
108697
|
},
|
|
108707
108698
|
loadDeviceKey() {
|
|
108708
108699
|
try {
|
|
108709
|
-
return
|
|
108700
|
+
return existsSync29(deviceKeyFile()) ? readFileSync42(deviceKeyFile(), "utf8").trim() || null : null;
|
|
108710
108701
|
} catch {
|
|
108711
108702
|
return null;
|
|
108712
108703
|
}
|
|
108713
108704
|
},
|
|
108714
108705
|
saveDeviceKey(base64Key) {
|
|
108715
108706
|
try {
|
|
108716
|
-
|
|
108717
|
-
|
|
108707
|
+
mkdirSync31(dirname29(deviceKeyFile()), { recursive: true, mode: 448 });
|
|
108708
|
+
writeFileSync30(deviceKeyFile(), base64Key, { mode: 384 });
|
|
108718
108709
|
} catch {
|
|
108719
108710
|
}
|
|
108720
108711
|
},
|
|
108721
108712
|
clearDeviceKey() {
|
|
108722
108713
|
try {
|
|
108723
|
-
if (
|
|
108714
|
+
if (existsSync29(deviceKeyFile()))
|
|
108724
108715
|
unlinkSync5(deviceKeyFile());
|
|
108725
108716
|
} catch {
|
|
108726
108717
|
}
|
|
@@ -108730,8 +108721,8 @@ function makeVaultPersistence(file2 = vaultStoreFile, deviceKeyFile = vaultDevic
|
|
|
108730
108721
|
|
|
108731
108722
|
// ../../packages/host-core/dist/vault/biometric.js
|
|
108732
108723
|
init_base_paths();
|
|
108733
|
-
import { existsSync as
|
|
108734
|
-
import { join as
|
|
108724
|
+
import { existsSync as existsSync30, mkdirSync as mkdirSync32, readFileSync as readFileSync43, rmSync as rmSync6, writeFileSync as writeFileSync31 } from "node:fs";
|
|
108725
|
+
import { join as join64 } from "node:path";
|
|
108735
108726
|
async function electronBio() {
|
|
108736
108727
|
if (!electronModule())
|
|
108737
108728
|
return null;
|
|
@@ -108748,11 +108739,11 @@ async function electronBio() {
|
|
|
108748
108739
|
}
|
|
108749
108740
|
function bioDir() {
|
|
108750
108741
|
const d = homePath(".tesseract", "vault-bio");
|
|
108751
|
-
|
|
108742
|
+
mkdirSync32(d, { recursive: true, mode: 448 });
|
|
108752
108743
|
return d;
|
|
108753
108744
|
}
|
|
108754
108745
|
function bioFile(id) {
|
|
108755
|
-
return
|
|
108746
|
+
return join64(bioDir(), `${String(id).replace(/[^a-zA-Z0-9_-]/g, "").slice(0, 64)}.enc`);
|
|
108756
108747
|
}
|
|
108757
108748
|
async function biometricAvailable() {
|
|
108758
108749
|
if (process.platform !== "darwin")
|
|
@@ -108767,24 +108758,24 @@ async function biometricAvailable() {
|
|
|
108767
108758
|
}
|
|
108768
108759
|
}
|
|
108769
108760
|
function biometricEnrolled(id) {
|
|
108770
|
-
return
|
|
108761
|
+
return existsSync30(bioFile(id));
|
|
108771
108762
|
}
|
|
108772
108763
|
async function biometricEnroll(id, base64Key) {
|
|
108773
108764
|
const bio = await electronBio();
|
|
108774
108765
|
if (!bio)
|
|
108775
108766
|
throw new Error("Touch ID is not available on this device.");
|
|
108776
108767
|
await bio.systemPreferences.promptTouchID("enable Touch ID for your vault");
|
|
108777
|
-
|
|
108768
|
+
writeFileSync31(bioFile(id), bio.safeStorage.encryptString(base64Key), { mode: 384 });
|
|
108778
108769
|
}
|
|
108779
108770
|
async function biometricUnlock(id) {
|
|
108780
108771
|
const f = bioFile(id);
|
|
108781
|
-
if (!
|
|
108772
|
+
if (!existsSync30(f))
|
|
108782
108773
|
throw new Error("Touch ID is not set up for this vault.");
|
|
108783
108774
|
const bio = await electronBio();
|
|
108784
108775
|
if (!bio)
|
|
108785
108776
|
throw new Error("Touch ID is not available on this device.");
|
|
108786
108777
|
await bio.systemPreferences.promptTouchID("unlock your vault");
|
|
108787
|
-
return bio.safeStorage.decryptString(
|
|
108778
|
+
return bio.safeStorage.decryptString(readFileSync43(f));
|
|
108788
108779
|
}
|
|
108789
108780
|
function biometricDisable(id) {
|
|
108790
108781
|
try {
|
|
@@ -108814,7 +108805,7 @@ var VaultManager = class {
|
|
|
108814
108805
|
// ── auto-lock ────────────────────────────────────────────────────────────────────
|
|
108815
108806
|
loadAutoLock() {
|
|
108816
108807
|
try {
|
|
108817
|
-
const raw = JSON.parse(
|
|
108808
|
+
const raw = JSON.parse(readFileSync44(settingsFile(), "utf8"));
|
|
108818
108809
|
return Number.isFinite(raw.autoLockMinutes) ? Math.max(0, raw.autoLockMinutes) : 0;
|
|
108819
108810
|
} catch {
|
|
108820
108811
|
return 0;
|
|
@@ -108822,8 +108813,8 @@ var VaultManager = class {
|
|
|
108822
108813
|
}
|
|
108823
108814
|
saveAutoLock() {
|
|
108824
108815
|
try {
|
|
108825
|
-
|
|
108826
|
-
|
|
108816
|
+
mkdirSync33(dirname30(settingsFile()), { recursive: true, mode: 448 });
|
|
108817
|
+
writeFileSync32(settingsFile(), JSON.stringify({ autoLockMinutes: this.autoLockMinutes }), { mode: 384 });
|
|
108827
108818
|
} catch {
|
|
108828
108819
|
}
|
|
108829
108820
|
}
|
|
@@ -109520,7 +109511,7 @@ async function startLocalServer(opts) {
|
|
|
109520
109511
|
send4("agent", {
|
|
109521
109512
|
type: "agent:notice",
|
|
109522
109513
|
sessionId: msg.sessionId,
|
|
109523
|
-
noticeId:
|
|
109514
|
+
noticeId: randomUUID27(),
|
|
109524
109515
|
category: "model",
|
|
109525
109516
|
level: "warning",
|
|
109526
109517
|
title: "That model is not available on this device",
|
|
@@ -109907,13 +109898,13 @@ import { hostname as hostname5 } from "node:os";
|
|
|
109907
109898
|
// ../../packages/shared/dist/daemon-registry.js
|
|
109908
109899
|
init_base_paths();
|
|
109909
109900
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
109910
|
-
import { existsSync as
|
|
109911
|
-
import { join as
|
|
109901
|
+
import { existsSync as existsSync31, mkdirSync as mkdirSync34, readdirSync as readdirSync11, readFileSync as readFileSync45, readlinkSync, unlinkSync as unlinkSync6, writeFileSync as writeFileSync33 } from "node:fs";
|
|
109902
|
+
import { join as join65 } from "node:path";
|
|
109912
109903
|
var SUPERVISOR_PID = Number(process.env.CCB_DAEMON_SUPERVISOR_PID ?? 0) || 0;
|
|
109913
109904
|
delete process.env.CCB_DAEMON_SUPERVISOR_PID;
|
|
109914
109905
|
var PS_ENV = { ...process.env, LC_ALL: "C", LANG: "C" };
|
|
109915
|
-
var registryDir = () =>
|
|
109916
|
-
var recordPath = (pid) =>
|
|
109906
|
+
var registryDir = () => join65(daemonDir(), "daemons");
|
|
109907
|
+
var recordPath = (pid) => join65(registryDir(), `${pid}.json`);
|
|
109917
109908
|
function isPidAlive2(pid) {
|
|
109918
109909
|
try {
|
|
109919
109910
|
process.kill(pid, 0);
|
|
@@ -109965,7 +109956,7 @@ function pidStillMatches(pid, rec) {
|
|
|
109965
109956
|
}
|
|
109966
109957
|
function registerSelfAsDaemon(version2) {
|
|
109967
109958
|
try {
|
|
109968
|
-
|
|
109959
|
+
mkdirSync34(registryDir(), { recursive: true, mode: 448 });
|
|
109969
109960
|
const rec = {
|
|
109970
109961
|
pid: process.pid,
|
|
109971
109962
|
startedAt: procStartedAt(process.pid),
|
|
@@ -109977,7 +109968,7 @@ function registerSelfAsDaemon(version2) {
|
|
|
109977
109968
|
...process.env.CCB_RDESK_ONLY === "1" || process.env.CCB_MESH_ONLY === "1" ? { rdeskOnly: true } : {},
|
|
109978
109969
|
...SUPERVISOR_PID ? { supervisorPid: SUPERVISOR_PID, supervisorStartedAt: procStartedAt(SUPERVISOR_PID) } : {}
|
|
109979
109970
|
};
|
|
109980
|
-
|
|
109971
|
+
writeFileSync33(recordPath(process.pid), JSON.stringify(rec), { mode: 384 });
|
|
109981
109972
|
invalidateSupervisorCache();
|
|
109982
109973
|
try {
|
|
109983
109974
|
registeredDaemons(process.pid);
|
|
@@ -109998,7 +109989,7 @@ function unregisterSelfAsDaemon() {
|
|
|
109998
109989
|
}
|
|
109999
109990
|
function readRecord(pid) {
|
|
110000
109991
|
try {
|
|
110001
|
-
return JSON.parse(
|
|
109992
|
+
return JSON.parse(readFileSync45(recordPath(pid), "utf-8"));
|
|
110002
109993
|
} catch {
|
|
110003
109994
|
return null;
|
|
110004
109995
|
}
|
|
@@ -110012,7 +110003,7 @@ function allRegisteredPids() {
|
|
|
110012
110003
|
}
|
|
110013
110004
|
function registeredDaemons(selfPid) {
|
|
110014
110005
|
const out = [];
|
|
110015
|
-
if (!
|
|
110006
|
+
if (!existsSync31(registryDir()))
|
|
110016
110007
|
return out;
|
|
110017
110008
|
for (const pid of allRegisteredPids()) {
|
|
110018
110009
|
if (pid === selfPid)
|
|
@@ -110041,18 +110032,18 @@ function liveDaemons() {
|
|
|
110041
110032
|
}
|
|
110042
110033
|
|
|
110043
110034
|
// ../../packages/host-core/dist/device-identity.js
|
|
110044
|
-
import { join as
|
|
110045
|
-
import { readFileSync as
|
|
110035
|
+
import { join as join66 } from "node:path";
|
|
110036
|
+
import { readFileSync as readFileSync46, writeFileSync as writeFileSync34, existsSync as existsSync32, mkdirSync as mkdirSync35, renameSync as renameSync10, chmodSync as chmodSync4 } from "node:fs";
|
|
110046
110037
|
init_credentials();
|
|
110047
110038
|
var cached3 = null;
|
|
110048
110039
|
function identityPath() {
|
|
110049
|
-
return
|
|
110040
|
+
return join66(daemonDir2(), "identity.json");
|
|
110050
110041
|
}
|
|
110051
110042
|
async function loadOrCreateDeviceIdentity() {
|
|
110052
110043
|
if (cached3)
|
|
110053
110044
|
return cached3;
|
|
110054
110045
|
try {
|
|
110055
|
-
const stored = JSON.parse(
|
|
110046
|
+
const stored = JSON.parse(readFileSync46(identityPath(), "utf-8"));
|
|
110056
110047
|
if (stored?.privateJwk) {
|
|
110057
110048
|
cached3 = await importIdentity(stored.privateJwk);
|
|
110058
110049
|
return cached3;
|
|
@@ -110062,10 +110053,10 @@ async function loadOrCreateDeviceIdentity() {
|
|
|
110062
110053
|
const kp = await generateIdentityKeyPair(true);
|
|
110063
110054
|
const { privateJwk, publicRaw } = await exportIdentity(kp);
|
|
110064
110055
|
const dir2 = daemonDir2();
|
|
110065
|
-
if (!
|
|
110066
|
-
|
|
110056
|
+
if (!existsSync32(dir2))
|
|
110057
|
+
mkdirSync35(dir2, { recursive: true, mode: 448 });
|
|
110067
110058
|
const tmp = `${identityPath()}.tmp`;
|
|
110068
|
-
|
|
110059
|
+
writeFileSync34(tmp, JSON.stringify({ privateJwk, publicRaw, alg: "P256-ECDSA" }, null, 2), { mode: 384 });
|
|
110069
110060
|
renameSync10(tmp, identityPath());
|
|
110070
110061
|
try {
|
|
110071
110062
|
chmodSync4(identityPath(), 384);
|
|
@@ -110076,7 +110067,7 @@ async function loadOrCreateDeviceIdentity() {
|
|
|
110076
110067
|
}
|
|
110077
110068
|
var sealingCached = null;
|
|
110078
110069
|
function sealingPath() {
|
|
110079
|
-
return
|
|
110070
|
+
return join66(daemonDir2(), "sealing.json");
|
|
110080
110071
|
}
|
|
110081
110072
|
var EC_DH = { name: "ECDH", namedCurve: "P-256" };
|
|
110082
110073
|
async function loadOrCreateSealingKey() {
|
|
@@ -110084,7 +110075,7 @@ async function loadOrCreateSealingKey() {
|
|
|
110084
110075
|
return sealingCached;
|
|
110085
110076
|
const { subtle: subtle5 } = globalThis.crypto;
|
|
110086
110077
|
try {
|
|
110087
|
-
const stored = JSON.parse(
|
|
110078
|
+
const stored = JSON.parse(readFileSync46(sealingPath(), "utf-8"));
|
|
110088
110079
|
if (stored?.privateJwk && stored.publicRaw) {
|
|
110089
110080
|
const privateKey = await subtle5.importKey("jwk", stored.privateJwk, EC_DH, true, ["deriveBits"]);
|
|
110090
110081
|
sealingCached = { privateKey, publicRaw: unb64u(stored.publicRaw) };
|
|
@@ -110096,10 +110087,10 @@ async function loadOrCreateSealingKey() {
|
|
|
110096
110087
|
const publicRaw = new Uint8Array(await subtle5.exportKey("raw", kp.publicKey));
|
|
110097
110088
|
const privateJwk = await subtle5.exportKey("jwk", kp.privateKey);
|
|
110098
110089
|
const dir2 = daemonDir2();
|
|
110099
|
-
if (!
|
|
110100
|
-
|
|
110090
|
+
if (!existsSync32(dir2))
|
|
110091
|
+
mkdirSync35(dir2, { recursive: true, mode: 448 });
|
|
110101
110092
|
const tmp = `${sealingPath()}.tmp`;
|
|
110102
|
-
|
|
110093
|
+
writeFileSync34(tmp, JSON.stringify({ privateJwk, publicRaw: b64u(publicRaw), alg: "P256-ECDH" }, null, 2), { mode: 384 });
|
|
110103
110094
|
renameSync10(tmp, sealingPath());
|
|
110104
110095
|
try {
|
|
110105
110096
|
chmodSync4(sealingPath(), 384);
|
|
@@ -110196,7 +110187,7 @@ var BundleOfferLedger = class {
|
|
|
110196
110187
|
init_dist6();
|
|
110197
110188
|
|
|
110198
110189
|
// ../../packages/host-core/dist/mesh/netd-client.js
|
|
110199
|
-
import { existsSync as
|
|
110190
|
+
import { existsSync as existsSync33, readdirSync as readdirSync12 } from "node:fs";
|
|
110200
110191
|
import { connect as connect2 } from "node:net";
|
|
110201
110192
|
import { platform as platform3 } from "node:process";
|
|
110202
110193
|
var NETD_WIRE_VERSION = 2;
|
|
@@ -110212,7 +110203,7 @@ function netdEndpoint() {
|
|
|
110212
110203
|
function netdListening() {
|
|
110213
110204
|
const ep = endpointOverride() ?? netdEndpoint();
|
|
110214
110205
|
if (process.platform !== "win32")
|
|
110215
|
-
return
|
|
110206
|
+
return existsSync33(ep);
|
|
110216
110207
|
try {
|
|
110217
110208
|
const name = ep.replace(/^\\\\\.\\pipe\\/, "");
|
|
110218
110209
|
return readdirSync12("\\\\.\\pipe\\").includes(name);
|
|
@@ -110617,13 +110608,13 @@ ${ts}`);
|
|
|
110617
110608
|
|
|
110618
110609
|
// ../../packages/host-core/dist/mesh/config.js
|
|
110619
110610
|
init_credentials();
|
|
110620
|
-
import { chmodSync as chmodSync5, existsSync as
|
|
110621
|
-
import { dirname as
|
|
110611
|
+
import { chmodSync as chmodSync5, existsSync as existsSync34, mkdirSync as mkdirSync36, readdirSync as readdirSync13, readFileSync as readFileSync47, renameSync as renameSync11, rmSync as rmSync7, writeFileSync as writeFileSync35 } from "node:fs";
|
|
110612
|
+
import { dirname as dirname31, join as join68 } from "node:path";
|
|
110622
110613
|
function meshDir() {
|
|
110623
|
-
return
|
|
110614
|
+
return join68(daemonDir2(), "mesh");
|
|
110624
110615
|
}
|
|
110625
110616
|
function meshesDir() {
|
|
110626
|
-
return
|
|
110617
|
+
return join68(meshDir(), "meshes");
|
|
110627
110618
|
}
|
|
110628
110619
|
var MESH_DIR_NAME_BYTES = 8;
|
|
110629
110620
|
function meshDirName(genesisFp) {
|
|
@@ -110641,7 +110632,7 @@ function oneMeshDir(meshId) {
|
|
|
110641
110632
|
if (!isMeshId(meshId)) {
|
|
110642
110633
|
throw new Error(`not a mesh id: ${JSON.stringify(meshId.slice(0, 64))}`);
|
|
110643
110634
|
}
|
|
110644
|
-
return
|
|
110635
|
+
return join68(meshesDir(), meshId);
|
|
110645
110636
|
}
|
|
110646
110637
|
var LEGACY_MESH_ID = "legacy";
|
|
110647
110638
|
var CERT_GENESIS_FP_OFFSET = 19;
|
|
@@ -110659,29 +110650,29 @@ var FILES = {
|
|
|
110659
110650
|
local: "local.json"
|
|
110660
110651
|
};
|
|
110661
110652
|
function readIfPresent(name, dir2 = meshDir()) {
|
|
110662
|
-
const p =
|
|
110653
|
+
const p = join68(dir2, name);
|
|
110663
110654
|
try {
|
|
110664
|
-
return
|
|
110655
|
+
return existsSync34(p) ? new Uint8Array(readFileSync47(p)) : void 0;
|
|
110665
110656
|
} catch {
|
|
110666
110657
|
return void 0;
|
|
110667
110658
|
}
|
|
110668
110659
|
}
|
|
110669
110660
|
function migrateSingleMesh() {
|
|
110670
|
-
const legacyGenesis =
|
|
110671
|
-
if (!
|
|
110661
|
+
const legacyGenesis = join68(meshDir(), FILES.genesis);
|
|
110662
|
+
if (!existsSync34(legacyGenesis))
|
|
110672
110663
|
return null;
|
|
110673
110664
|
const id = meshIdFromCert(readIfPresent(FILES.cert)) ?? LEGACY_MESH_ID;
|
|
110674
110665
|
const dest = oneMeshDir(id);
|
|
110675
110666
|
try {
|
|
110676
|
-
|
|
110667
|
+
mkdirSync36(dest, { recursive: true, mode: 448 });
|
|
110677
110668
|
chmodSync5(dest, 448);
|
|
110678
110669
|
for (const f of Object.values(FILES)) {
|
|
110679
|
-
const from =
|
|
110680
|
-
if (
|
|
110681
|
-
renameSync11(from,
|
|
110670
|
+
const from = join68(meshDir(), f);
|
|
110671
|
+
if (existsSync34(from))
|
|
110672
|
+
renameSync11(from, join68(dest, f));
|
|
110682
110673
|
}
|
|
110683
|
-
const key2 =
|
|
110684
|
-
if (
|
|
110674
|
+
const key2 = join68(dest, FILES.key);
|
|
110675
|
+
if (existsSync34(key2))
|
|
110685
110676
|
chmodSync5(key2, 384);
|
|
110686
110677
|
} catch {
|
|
110687
110678
|
return null;
|
|
@@ -110704,15 +110695,15 @@ function listMeshIds() {
|
|
|
110704
110695
|
}
|
|
110705
110696
|
function readLocal(meshId) {
|
|
110706
110697
|
try {
|
|
110707
|
-
return JSON.parse(
|
|
110698
|
+
return JSON.parse(readFileSync47(join68(oneMeshDir(meshId), FILES.local), "utf8"));
|
|
110708
110699
|
} catch {
|
|
110709
110700
|
return null;
|
|
110710
110701
|
}
|
|
110711
110702
|
}
|
|
110712
110703
|
function writeLocal(meshId, state3) {
|
|
110713
110704
|
try {
|
|
110714
|
-
|
|
110715
|
-
|
|
110705
|
+
mkdirSync36(oneMeshDir(meshId), { recursive: true, mode: 448 });
|
|
110706
|
+
writeFileSync35(join68(oneMeshDir(meshId), FILES.local), JSON.stringify(state3, null, 2), { mode: 384 });
|
|
110716
110707
|
} catch {
|
|
110717
110708
|
}
|
|
110718
110709
|
}
|
|
@@ -110745,8 +110736,8 @@ function loadMeshIdentity() {
|
|
|
110745
110736
|
return first === void 0 ? null : loadMesh(first);
|
|
110746
110737
|
}
|
|
110747
110738
|
function writeSecret(name, bytes2, dir2 = meshDir()) {
|
|
110748
|
-
const p =
|
|
110749
|
-
|
|
110739
|
+
const p = join68(dir2, name);
|
|
110740
|
+
writeFileSync35(p, bytes2, { mode: 384 });
|
|
110750
110741
|
try {
|
|
110751
110742
|
chmodSync5(p, 384);
|
|
110752
110743
|
} catch {
|
|
@@ -110758,20 +110749,20 @@ function saveMeshIdentity(id) {
|
|
|
110758
110749
|
saveMesh(meshId, id);
|
|
110759
110750
|
return;
|
|
110760
110751
|
}
|
|
110761
|
-
|
|
110752
|
+
mkdirSync36(meshDir(), { recursive: true, mode: 448 });
|
|
110762
110753
|
try {
|
|
110763
110754
|
chmodSync5(meshDir(), 448);
|
|
110764
110755
|
} catch {
|
|
110765
110756
|
}
|
|
110766
|
-
|
|
110767
|
-
|
|
110757
|
+
writeFileSync35(join68(meshDir(), FILES.genesis), id.genesis);
|
|
110758
|
+
writeFileSync35(join68(meshDir(), FILES.cert), id.cert);
|
|
110768
110759
|
writeSecret(FILES.key, id.staticPrivate);
|
|
110769
110760
|
if (id.bundle)
|
|
110770
|
-
|
|
110761
|
+
writeFileSync35(join68(meshDir(), FILES.bundle), id.bundle);
|
|
110771
110762
|
}
|
|
110772
110763
|
function saveMesh(meshId, id) {
|
|
110773
110764
|
const dir2 = oneMeshDir(meshId);
|
|
110774
|
-
|
|
110765
|
+
mkdirSync36(dir2, { recursive: true, mode: 448 });
|
|
110775
110766
|
try {
|
|
110776
110767
|
chmodSync5(meshDir(), 448);
|
|
110777
110768
|
} catch {
|
|
@@ -110784,13 +110775,13 @@ function saveMesh(meshId, id) {
|
|
|
110784
110775
|
chmodSync5(dir2, 448);
|
|
110785
110776
|
} catch {
|
|
110786
110777
|
}
|
|
110787
|
-
|
|
110788
|
-
|
|
110778
|
+
writeFileSync35(join68(dir2, FILES.genesis), id.genesis);
|
|
110779
|
+
writeFileSync35(join68(dir2, FILES.cert), id.cert);
|
|
110789
110780
|
writeSecret(FILES.key, id.staticPrivate, dir2);
|
|
110790
110781
|
if (id.sigPrivate)
|
|
110791
110782
|
writeSecret(FILES.sigKey, id.sigPrivate, dir2);
|
|
110792
110783
|
if (id.bundle)
|
|
110793
|
-
|
|
110784
|
+
writeFileSync35(join68(dir2, FILES.bundle), id.bundle);
|
|
110794
110785
|
if (readLocal(meshId) === null)
|
|
110795
110786
|
writeLocal(meshId, { joinedAt: Date.now() });
|
|
110796
110787
|
}
|
|
@@ -110800,13 +110791,13 @@ function removeMesh(meshId) {
|
|
|
110800
110791
|
var STATUS_REFRESH_MS = 5e3;
|
|
110801
110792
|
var STATUS_STALE_MS = 2e4;
|
|
110802
110793
|
function statusPath(meshId) {
|
|
110803
|
-
return meshId === void 0 ?
|
|
110794
|
+
return meshId === void 0 ? join68(meshDir(), "status.json") : join68(oneMeshDir(meshId), "status.json");
|
|
110804
110795
|
}
|
|
110805
110796
|
function writeStatus(status2, meshId) {
|
|
110806
110797
|
try {
|
|
110807
110798
|
const p = statusPath(meshId);
|
|
110808
|
-
|
|
110809
|
-
|
|
110799
|
+
mkdirSync36(dirname31(p), { recursive: true, mode: 448 });
|
|
110800
|
+
writeFileSync35(p, JSON.stringify({ ...status2, at: Date.now() }, null, 2));
|
|
110810
110801
|
} catch {
|
|
110811
110802
|
}
|
|
110812
110803
|
}
|
|
@@ -110818,7 +110809,7 @@ function clearStatus(meshId) {
|
|
|
110818
110809
|
}
|
|
110819
110810
|
function readStatus(meshId) {
|
|
110820
110811
|
try {
|
|
110821
|
-
const raw = JSON.parse(
|
|
110812
|
+
const raw = JSON.parse(readFileSync47(statusPath(meshId), "utf8"));
|
|
110822
110813
|
if (typeof raw.at !== "number")
|
|
110823
110814
|
return null;
|
|
110824
110815
|
return { ...raw, at: raw.at, stale: Date.now() - raw.at > STATUS_STALE_MS };
|
|
@@ -110830,8 +110821,8 @@ function cacheBundle(bundle, meshId) {
|
|
|
110830
110821
|
try {
|
|
110831
110822
|
const id = meshId ?? listMeshIds()[0];
|
|
110832
110823
|
const dir2 = id === void 0 ? meshDir() : oneMeshDir(id);
|
|
110833
|
-
|
|
110834
|
-
|
|
110824
|
+
mkdirSync36(dir2, { recursive: true, mode: 448 });
|
|
110825
|
+
writeFileSync35(join68(dir2, FILES.bundle), bundle);
|
|
110835
110826
|
} catch {
|
|
110836
110827
|
}
|
|
110837
110828
|
}
|
|
@@ -111960,20 +111951,38 @@ function startNodes(log9) {
|
|
|
111960
111951
|
return [];
|
|
111961
111952
|
}
|
|
111962
111953
|
const started2 = meshNode().start();
|
|
111963
|
-
|
|
111964
|
-
|
|
111954
|
+
if (started2.ok) {
|
|
111955
|
+
log9("mesh: node up");
|
|
111956
|
+
return only !== void 0 ? [only] : [];
|
|
111957
|
+
}
|
|
111958
|
+
const refusal = { running: false, enrolled: true, lastError: started2.reason };
|
|
111959
|
+
if (only !== void 0)
|
|
111960
|
+
writeStatus(refusal, only);
|
|
111961
|
+
writeStatus(refusal);
|
|
111962
|
+
log9(`mesh: not started \u2014 ${started2.reason}`);
|
|
111963
|
+
return [];
|
|
111965
111964
|
}
|
|
111966
111965
|
const running2 = [];
|
|
111966
|
+
let failedPrimary = null;
|
|
111967
111967
|
for (const r of meshManager().startAll()) {
|
|
111968
|
-
|
|
111969
|
-
|
|
111968
|
+
if (r.ok) {
|
|
111969
|
+
log9(`mesh ${r.meshId}: up`);
|
|
111970
111970
|
running2.push(r.meshId);
|
|
111971
|
+
continue;
|
|
111972
|
+
}
|
|
111973
|
+
writeStatus({ running: false, enrolled: true, lastError: r.reason }, r.meshId);
|
|
111974
|
+
if (failedPrimary === null)
|
|
111975
|
+
failedPrimary = r.reason ?? "the node did not start";
|
|
111976
|
+
log9(`mesh ${r.meshId}: not started \u2014 ${r.reason}`);
|
|
111977
|
+
}
|
|
111978
|
+
if (running2.length === 0 && failedPrimary !== null) {
|
|
111979
|
+
writeStatus({ running: false, enrolled: true, lastError: failedPrimary });
|
|
111971
111980
|
}
|
|
111972
111981
|
return running2;
|
|
111973
111982
|
}
|
|
111974
111983
|
|
|
111975
111984
|
// ../../packages/host-core/dist/drops/receive-ui.js
|
|
111976
|
-
import { basename as basename12, dirname as
|
|
111985
|
+
import { basename as basename12, dirname as dirname32 } from "node:path";
|
|
111977
111986
|
var log5 = (...a) => console.log("[drops]", ...a);
|
|
111978
111987
|
function formatBytes(n) {
|
|
111979
111988
|
if (!Number.isFinite(n) || n <= 0)
|
|
@@ -112067,7 +112076,7 @@ import { basename as basename13 } from "node:path";
|
|
|
112067
112076
|
// ../../packages/host-core/dist/drops/paths.js
|
|
112068
112077
|
init_base_paths();
|
|
112069
112078
|
import { mkdir as mkdir14 } from "node:fs/promises";
|
|
112070
|
-
import { join as
|
|
112079
|
+
import { join as join69 } from "node:path";
|
|
112071
112080
|
|
|
112072
112081
|
// ../../packages/host-core/dist/drops/names.js
|
|
112073
112082
|
var WINDOWS_RESERVED = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i;
|
|
@@ -112156,7 +112165,7 @@ function basenameOf(p) {
|
|
|
112156
112165
|
function resolveDropsRoot() {
|
|
112157
112166
|
const root = resolveHostRoot();
|
|
112158
112167
|
const preferred = dropsDir();
|
|
112159
|
-
return isInsideRoot(preferred, root) ? preferred :
|
|
112168
|
+
return isInsideRoot(preferred, root) ? preferred : join69(root, "Drops");
|
|
112160
112169
|
}
|
|
112161
112170
|
async function ensureDropsRoot() {
|
|
112162
112171
|
const dir2 = resolveDropsRoot();
|
|
@@ -112172,7 +112181,7 @@ async function ensureDropDir(opts) {
|
|
|
112172
112181
|
parts.push(sanitizeDropName(opts.sender, "Unknown sender"));
|
|
112173
112182
|
if (!opts.singleItem && opts.label)
|
|
112174
112183
|
parts.push(sanitizeDropName(opts.label, "Files"));
|
|
112175
|
-
const dir2 =
|
|
112184
|
+
const dir2 = join69(...parts);
|
|
112176
112185
|
await mkdir14(dir2, { recursive: true });
|
|
112177
112186
|
return dir2;
|
|
112178
112187
|
}
|
|
@@ -112315,7 +112324,7 @@ function createDropHandler(deps) {
|
|
|
112315
112324
|
// ../../packages/host-core/dist/drops/blob-fetch.js
|
|
112316
112325
|
import { createWriteStream as createWriteStream2 } from "node:fs";
|
|
112317
112326
|
import { mkdir as mkdir15, rm as rm5, chmod as chmod3 } from "node:fs/promises";
|
|
112318
|
-
import { dirname as
|
|
112327
|
+
import { dirname as dirname33, join as join70 } from "node:path";
|
|
112319
112328
|
import { Readable as Readable2 } from "node:stream";
|
|
112320
112329
|
import { pipeline } from "node:stream/promises";
|
|
112321
112330
|
|
|
@@ -112487,7 +112496,7 @@ async function fetchBlobDrop(opts) {
|
|
|
112487
112496
|
log7(`drop ${opts.dropId}: refusing directory "${item.rel}"`);
|
|
112488
112497
|
continue;
|
|
112489
112498
|
}
|
|
112490
|
-
const abs =
|
|
112499
|
+
const abs = join70(opts.destDir, rel);
|
|
112491
112500
|
if (!isInsideRoot(abs, opts.destDir)) {
|
|
112492
112501
|
log7(`drop ${opts.dropId}: refusing directory outside the destination`);
|
|
112493
112502
|
continue;
|
|
@@ -112508,12 +112517,12 @@ async function fetchBlobDrop(opts) {
|
|
|
112508
112517
|
log7(`drop ${opts.dropId}: refusing "${item.rel}"`);
|
|
112509
112518
|
continue;
|
|
112510
112519
|
}
|
|
112511
|
-
let abs =
|
|
112520
|
+
let abs = join70(opts.destDir, rel);
|
|
112512
112521
|
if (!isInsideRoot(abs, opts.destDir)) {
|
|
112513
112522
|
log7(`drop ${opts.dropId}: refusing a path outside the destination`);
|
|
112514
112523
|
continue;
|
|
112515
112524
|
}
|
|
112516
|
-
await mkdir15(
|
|
112525
|
+
await mkdir15(dirname33(abs), { recursive: true });
|
|
112517
112526
|
abs = await uniqueDropPath(abs);
|
|
112518
112527
|
const res = await fetchFn(new URL(item.url, opts.apiOrigin).toString(), { signal: opts.signal });
|
|
112519
112528
|
if (!res.ok || !res.body)
|
|
@@ -112545,7 +112554,7 @@ async function fetchBlobDrop(opts) {
|
|
|
112545
112554
|
}
|
|
112546
112555
|
|
|
112547
112556
|
// ../../packages/host-core/dist/chat-agent.js
|
|
112548
|
-
import { randomUUID as
|
|
112557
|
+
import { randomUUID as randomUUID28 } from "node:crypto";
|
|
112549
112558
|
init_prompts();
|
|
112550
112559
|
var TURN_TIMEOUT_MS = 4 * 6e4;
|
|
112551
112560
|
var PARTIAL_INTERVAL_MS = 700;
|
|
@@ -112574,7 +112583,7 @@ function createChatAgentRunner(deps) {
|
|
|
112574
112583
|
}
|
|
112575
112584
|
async function runTurn(prompt2, onPartial) {
|
|
112576
112585
|
const backend2 = await getSharedBackend();
|
|
112577
|
-
const clientRequestId = `chat-agent-${
|
|
112586
|
+
const clientRequestId = `chat-agent-${randomUUID28()}`;
|
|
112578
112587
|
return new Promise((resolve16, reject) => {
|
|
112579
112588
|
let text12 = "";
|
|
112580
112589
|
let settled = false;
|
|
@@ -112783,13 +112792,13 @@ var RdeskServerChannel = class {
|
|
|
112783
112792
|
};
|
|
112784
112793
|
|
|
112785
112794
|
// ../../packages/host-core/dist/rdesk/channel-client.js
|
|
112786
|
-
import { readFileSync as
|
|
112787
|
-
import { join as
|
|
112795
|
+
import { readFileSync as readFileSync48 } from "node:fs";
|
|
112796
|
+
import { join as join71 } from "node:path";
|
|
112788
112797
|
var RECONNECT_MS = 2e3;
|
|
112789
112798
|
var CLAIM_RETRY_MS = 5e3;
|
|
112790
112799
|
function readEndpoint(dir2, selfPid) {
|
|
112791
112800
|
try {
|
|
112792
|
-
const s = JSON.parse(
|
|
112801
|
+
const s = JSON.parse(readFileSync48(join71(dir2, "status.json"), "utf8"));
|
|
112793
112802
|
if (selfPid && s.pid === selfPid)
|
|
112794
112803
|
return null;
|
|
112795
112804
|
return s.localPort && s.localToken ? `ws://127.0.0.1:${s.localPort}/?token=${s.localToken}` : null;
|
|
@@ -113234,10 +113243,10 @@ function registerRdpEngine() {
|
|
|
113234
113243
|
// ../../packages/host-core/dist/rdesk/audit.js
|
|
113235
113244
|
init_credentials();
|
|
113236
113245
|
import { appendFile, stat as stat9, rename as rename4 } from "node:fs/promises";
|
|
113237
|
-
import { join as
|
|
113246
|
+
import { join as join72 } from "node:path";
|
|
113238
113247
|
var MAX_BYTES2 = 2 * 1024 * 1024;
|
|
113239
113248
|
function rdeskAuditPath() {
|
|
113240
|
-
return
|
|
113249
|
+
return join72(daemonDir2(), "rdesk-audit.jsonl");
|
|
113241
113250
|
}
|
|
113242
113251
|
var queue = [];
|
|
113243
113252
|
var draining = false;
|
|
@@ -113279,13 +113288,13 @@ function appendRdeskAudit(e) {
|
|
|
113279
113288
|
|
|
113280
113289
|
// ../../packages/host-core/dist/fileprovider-bridge.js
|
|
113281
113290
|
init_managed_spawn();
|
|
113282
|
-
import { writeFileSync as
|
|
113291
|
+
import { writeFileSync as writeFileSync36, mkdirSync as mkdirSync37, rmSync as rmSync8, existsSync as existsSync35 } from "node:fs";
|
|
113283
113292
|
import { homedir as homedir10 } from "node:os";
|
|
113284
|
-
import { join as
|
|
113293
|
+
import { join as join73 } from "node:path";
|
|
113285
113294
|
init_safe_kill();
|
|
113286
113295
|
var APPEX_BUNDLE_ID = "dev.tesseract.FileProvider";
|
|
113287
113296
|
function appexBridgeInfoPath() {
|
|
113288
|
-
return
|
|
113297
|
+
return join73(homedir10(), "Library", "Containers", APPEX_BUNDLE_ID, "Data", "Library", "Application Support", "tesseract-bridge.json");
|
|
113289
113298
|
}
|
|
113290
113299
|
function clearBridgeInfo() {
|
|
113291
113300
|
if (process.platform !== "darwin")
|
|
@@ -113450,9 +113459,9 @@ function stopFileProviderBridge() {
|
|
|
113450
113459
|
|
|
113451
113460
|
// ../../packages/host-core/dist/vault/autofill-bridge.js
|
|
113452
113461
|
import { randomBytes as randomBytes9 } from "node:crypto";
|
|
113453
|
-
import { existsSync as
|
|
113462
|
+
import { existsSync as existsSync36, mkdirSync as mkdirSync38, writeFileSync as writeFileSync37, rmSync as rmSync9 } from "node:fs";
|
|
113454
113463
|
import { homedir as homedir11 } from "node:os";
|
|
113455
|
-
import { join as
|
|
113464
|
+
import { join as join74 } from "node:path";
|
|
113456
113465
|
|
|
113457
113466
|
// ../../packages/host-core/dist/vault/peer-verify.js
|
|
113458
113467
|
import { execFile as execFile9 } from "node:child_process";
|
|
@@ -113514,10 +113523,10 @@ async function isTrustedAutofillPeer(remotePort) {
|
|
|
113514
113523
|
var APPEX_BUNDLE_ID2 = "dev.tesseract.AutoFill";
|
|
113515
113524
|
var BRIDGE_PORTS2 = [17872, 17873, 17874, 17875];
|
|
113516
113525
|
function appexContainerData() {
|
|
113517
|
-
return
|
|
113526
|
+
return join74(homedir11(), "Library", "Containers", APPEX_BUNDLE_ID2, "Data");
|
|
113518
113527
|
}
|
|
113519
113528
|
function bridgeInfoPath() {
|
|
113520
|
-
return
|
|
113529
|
+
return join74(appexContainerData(), "Library", "Application Support", "tesseract-autofill-bridge.json");
|
|
113521
113530
|
}
|
|
113522
113531
|
var infoLoggedOnce = false;
|
|
113523
113532
|
function writeBridgeInfo(port, token3, log9) {
|
|
@@ -113525,16 +113534,16 @@ function writeBridgeInfo(port, token3, log9) {
|
|
|
113525
113534
|
return;
|
|
113526
113535
|
const containerData = appexContainerData();
|
|
113527
113536
|
try {
|
|
113528
|
-
if (!
|
|
113537
|
+
if (!existsSync36(containerData)) {
|
|
113529
113538
|
if (!infoLoggedOnce) {
|
|
113530
113539
|
infoLoggedOnce = true;
|
|
113531
113540
|
log9("autofill bridge-info SKIP: no appex container yet at", containerData);
|
|
113532
113541
|
}
|
|
113533
113542
|
return;
|
|
113534
113543
|
}
|
|
113535
|
-
const dir2 =
|
|
113536
|
-
|
|
113537
|
-
|
|
113544
|
+
const dir2 = join74(containerData, "Library", "Application Support");
|
|
113545
|
+
mkdirSync38(dir2, { recursive: true });
|
|
113546
|
+
writeFileSync37(bridgeInfoPath(), JSON.stringify({ port, token: token3, pid: process.pid, ts: Date.now() }), { mode: 384 });
|
|
113538
113547
|
if (!infoLoggedOnce) {
|
|
113539
113548
|
infoLoggedOnce = true;
|
|
113540
113549
|
log9("autofill bridge-info WROTE", port, "\u2192", dir2);
|
|
@@ -113774,9 +113783,9 @@ function createNodePowerController() {
|
|
|
113774
113783
|
|
|
113775
113784
|
// ../../packages/host-core/dist/native-host.js
|
|
113776
113785
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
113777
|
-
import { chmodSync as chmodSync6, existsSync as
|
|
113786
|
+
import { chmodSync as chmodSync6, existsSync as existsSync37, mkdirSync as mkdirSync39, writeFileSync as writeFileSync38 } from "node:fs";
|
|
113778
113787
|
import { homedir as homedir12, platform as platform5 } from "node:os";
|
|
113779
|
-
import { dirname as
|
|
113788
|
+
import { dirname as dirname34, join as join75, resolve as resolve12 } from "node:path";
|
|
113780
113789
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
113781
113790
|
var HOST_NAME = "com.tesseract.companion";
|
|
113782
113791
|
var EXTENSION_IDS = ["icpnghhpcmaonjckkpilpajblfehpplo", "giolfpookdhjfafcchaflhmigghaeffn"];
|
|
@@ -113785,41 +113794,41 @@ function browserProfileDirs() {
|
|
|
113785
113794
|
const home = homedir12();
|
|
113786
113795
|
const p = platform5();
|
|
113787
113796
|
if (p === "darwin") {
|
|
113788
|
-
const base =
|
|
113789
|
-
return ["Google/Chrome", "Google/Chrome Beta", "Google/Chrome Dev", "Google/Chrome Canary", "Chromium", "Microsoft Edge", "BraveSoftware/Brave-Browser", "Vivaldi", "Arc"].map((b) =>
|
|
113797
|
+
const base = join75(home, "Library/Application Support");
|
|
113798
|
+
return ["Google/Chrome", "Google/Chrome Beta", "Google/Chrome Dev", "Google/Chrome Canary", "Chromium", "Microsoft Edge", "BraveSoftware/Brave-Browser", "Vivaldi", "Arc"].map((b) => join75(base, b));
|
|
113790
113799
|
}
|
|
113791
113800
|
if (p === "win32")
|
|
113792
113801
|
return [];
|
|
113793
|
-
const cfg2 =
|
|
113794
|
-
return ["google-chrome", "google-chrome-beta", "chromium", "microsoft-edge", "BraveSoftware/Brave-Browser", "vivaldi"].map((b) =>
|
|
113802
|
+
const cfg2 = join75(home, ".config");
|
|
113803
|
+
return ["google-chrome", "google-chrome-beta", "chromium", "microsoft-edge", "BraveSoftware/Brave-Browser", "vivaldi"].map((b) => join75(cfg2, b));
|
|
113795
113804
|
}
|
|
113796
113805
|
function resolveBridge(log9) {
|
|
113797
113806
|
const candidates = [
|
|
113798
113807
|
process.env.CCB_COMPANION_HOST_JS,
|
|
113799
|
-
process.resourcesPath ?
|
|
113808
|
+
process.resourcesPath ? join75(process.resourcesPath, "companion-host", BRIDGE_BASENAME) : void 0
|
|
113800
113809
|
];
|
|
113801
113810
|
try {
|
|
113802
|
-
const here =
|
|
113811
|
+
const here = dirname34(fileURLToPath6(import.meta.url));
|
|
113803
113812
|
candidates.push(resolve12(here, "../../../apps/companion-host/dist", BRIDGE_BASENAME));
|
|
113804
113813
|
candidates.push(resolve12(here, "../../apps/companion-host/dist", BRIDGE_BASENAME));
|
|
113805
113814
|
} catch {
|
|
113806
113815
|
}
|
|
113807
113816
|
for (const c of candidates)
|
|
113808
|
-
if (c &&
|
|
113817
|
+
if (c && existsSync37(c))
|
|
113809
113818
|
return c;
|
|
113810
113819
|
log9("companion native-host: bridge not found; skipping registration (looked in", candidates.filter(Boolean).join(" , "), ")");
|
|
113811
113820
|
return null;
|
|
113812
113821
|
}
|
|
113813
113822
|
function writeLauncher(daemonDir3, bridge, runtime) {
|
|
113814
113823
|
const isWin = platform5() === "win32";
|
|
113815
|
-
const launcher =
|
|
113824
|
+
const launcher = join75(daemonDir3, isWin ? "companion-host.cmd" : "companion-host.sh");
|
|
113816
113825
|
if (isWin) {
|
|
113817
|
-
|
|
113826
|
+
writeFileSync38(launcher, `@echo off\r
|
|
113818
113827
|
set ELECTRON_RUN_AS_NODE=1\r
|
|
113819
113828
|
"${runtime}" "${bridge}" %*\r
|
|
113820
113829
|
`);
|
|
113821
113830
|
} else {
|
|
113822
|
-
|
|
113831
|
+
writeFileSync38(launcher, `#!/bin/sh
|
|
113823
113832
|
# Tesseract Companion native-messaging launcher (auto-written by the daemon).
|
|
113824
113833
|
ELECTRON_RUN_AS_NODE=1 exec "${runtime}" "${bridge}" "$@"
|
|
113825
113834
|
`);
|
|
@@ -113834,7 +113843,7 @@ function registerNativeHost(opts) {
|
|
|
113834
113843
|
if (!bridge)
|
|
113835
113844
|
return;
|
|
113836
113845
|
const runtime = opts.runtime ?? process.execPath;
|
|
113837
|
-
|
|
113846
|
+
mkdirSync39(opts.daemonDir, { recursive: true });
|
|
113838
113847
|
const launcher = writeLauncher(opts.daemonDir, bridge, runtime);
|
|
113839
113848
|
const manifestJson = JSON.stringify({
|
|
113840
113849
|
name: HOST_NAME,
|
|
@@ -113847,12 +113856,12 @@ function registerNativeHost(opts) {
|
|
|
113847
113856
|
return registerWindows(opts.daemonDir, manifestJson, log9);
|
|
113848
113857
|
let wrote = 0;
|
|
113849
113858
|
for (const profile of browserProfileDirs()) {
|
|
113850
|
-
if (!
|
|
113859
|
+
if (!existsSync37(profile))
|
|
113851
113860
|
continue;
|
|
113852
113861
|
try {
|
|
113853
|
-
const dir2 =
|
|
113854
|
-
|
|
113855
|
-
|
|
113862
|
+
const dir2 = join75(profile, "NativeMessagingHosts");
|
|
113863
|
+
mkdirSync39(dir2, { recursive: true });
|
|
113864
|
+
writeFileSync38(join75(dir2, `${HOST_NAME}.json`), manifestJson);
|
|
113856
113865
|
wrote++;
|
|
113857
113866
|
} catch {
|
|
113858
113867
|
}
|
|
@@ -113864,8 +113873,8 @@ function registerNativeHost(opts) {
|
|
|
113864
113873
|
}
|
|
113865
113874
|
function registerWindows(daemonDir3, manifestJson, log9) {
|
|
113866
113875
|
try {
|
|
113867
|
-
const manifestPath =
|
|
113868
|
-
|
|
113876
|
+
const manifestPath = join75(daemonDir3, `${HOST_NAME}.json`);
|
|
113877
|
+
writeFileSync38(manifestPath, manifestJson);
|
|
113869
113878
|
for (const root of ["Software\\Google\\Chrome", "Software\\Microsoft\\Edge", "Software\\BraveSoftware\\Brave-Browser"]) {
|
|
113870
113879
|
try {
|
|
113871
113880
|
execFileSync4("reg", ["add", `HKCU\\${root}\\NativeMessagingHosts\\${HOST_NAME}`, "/ve", "/t", "REG_SZ", "/d", manifestPath, "/f"], { stdio: "ignore" });
|
|
@@ -113883,10 +113892,10 @@ init_daemon_settings();
|
|
|
113883
113892
|
|
|
113884
113893
|
// ../../packages/host-core/dist/activity/activity-tracker.js
|
|
113885
113894
|
init_credentials();
|
|
113886
|
-
import { promises as fsp, writeFileSync as
|
|
113887
|
-
import { join as
|
|
113895
|
+
import { promises as fsp, writeFileSync as writeFileSync39, mkdirSync as mkdirSync40, existsSync as existsSync38 } from "node:fs";
|
|
113896
|
+
import { join as join76 } from "node:path";
|
|
113888
113897
|
function activityProfilePath() {
|
|
113889
|
-
return
|
|
113898
|
+
return join76(daemonDir2(), "activity-profile.json");
|
|
113890
113899
|
}
|
|
113891
113900
|
var MAX_APPS = 300;
|
|
113892
113901
|
var MAX_AGE_DAYS = 120;
|
|
@@ -113961,7 +113970,7 @@ function createActivityTracker(opts = {}) {
|
|
|
113961
113970
|
return;
|
|
113962
113971
|
const key2 = front.bundleId || front.name;
|
|
113963
113972
|
await ensureLoaded();
|
|
113964
|
-
if (profile && Object.keys(profile.apps).length && !
|
|
113973
|
+
if (profile && Object.keys(profile.apps).length && !existsSync38(activityProfilePath())) {
|
|
113965
113974
|
log9("activity profile cleared externally \u2014 resetting in-memory");
|
|
113966
113975
|
profile = { version: 1, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), apps: {} };
|
|
113967
113976
|
}
|
|
@@ -113997,8 +114006,8 @@ function createActivityTracker(opts = {}) {
|
|
|
113997
114006
|
if (profile) {
|
|
113998
114007
|
pruneProfile(profile);
|
|
113999
114008
|
profile.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
114000
|
-
|
|
114001
|
-
|
|
114009
|
+
mkdirSync40(daemonDir2(), { recursive: true, mode: 448 });
|
|
114010
|
+
writeFileSync39(activityProfilePath(), JSON.stringify(profile), { mode: 384 });
|
|
114002
114011
|
dirty = 0;
|
|
114003
114012
|
}
|
|
114004
114013
|
} catch (e) {
|
|
@@ -114050,6 +114059,38 @@ function closeRdeskCallWindow() {
|
|
|
114050
114059
|
// ../../packages/host-core/dist/daemon-runtime.js
|
|
114051
114060
|
init_credentials();
|
|
114052
114061
|
|
|
114062
|
+
// ../../packages/shared/dist/identity.js
|
|
114063
|
+
init_base_paths();
|
|
114064
|
+
import { existsSync as existsSync39, mkdirSync as mkdirSync41, readFileSync as readFileSync49, writeFileSync as writeFileSync40 } from "node:fs";
|
|
114065
|
+
import { dirname as dirname35, join as join77 } from "node:path";
|
|
114066
|
+
import { randomUUID as randomUUID29 } from "node:crypto";
|
|
114067
|
+
function deviceIdFile() {
|
|
114068
|
+
return join77(tesseractHome(), "device-id.json");
|
|
114069
|
+
}
|
|
114070
|
+
function readPersistedDeviceId() {
|
|
114071
|
+
try {
|
|
114072
|
+
const raw = JSON.parse(readFileSync49(deviceIdFile(), "utf-8"));
|
|
114073
|
+
return typeof raw.deviceId === "string" && raw.deviceId ? raw.deviceId : null;
|
|
114074
|
+
} catch {
|
|
114075
|
+
return null;
|
|
114076
|
+
}
|
|
114077
|
+
}
|
|
114078
|
+
function persistentDeviceId() {
|
|
114079
|
+
const cur = readPersistedDeviceId();
|
|
114080
|
+
if (cur)
|
|
114081
|
+
return cur;
|
|
114082
|
+
const id = randomUUID29().slice(0, 8);
|
|
114083
|
+
try {
|
|
114084
|
+
const f = deviceIdFile();
|
|
114085
|
+
const dir2 = dirname35(f);
|
|
114086
|
+
if (!existsSync39(dir2))
|
|
114087
|
+
mkdirSync41(dir2, { recursive: true });
|
|
114088
|
+
writeFileSync40(f, JSON.stringify({ deviceId: id }));
|
|
114089
|
+
} catch {
|
|
114090
|
+
}
|
|
114091
|
+
return id;
|
|
114092
|
+
}
|
|
114093
|
+
|
|
114053
114094
|
// ../../packages/host-core/dist/error-report.js
|
|
114054
114095
|
init_dist2();
|
|
114055
114096
|
init_credentials();
|
|
@@ -114318,6 +114359,19 @@ async function runDaemon(opts = {}) {
|
|
|
114318
114359
|
const activityTracker = createActivityTracker({ log: log9 });
|
|
114319
114360
|
let activityTimer = null;
|
|
114320
114361
|
let creds3 = readCredentials();
|
|
114362
|
+
try {
|
|
114363
|
+
const ownId = persistentDeviceId();
|
|
114364
|
+
const { migratedFrom } = adoptPersistentDeviceId(ownId, (m) => log9(m));
|
|
114365
|
+
if (migratedFrom) {
|
|
114366
|
+
try {
|
|
114367
|
+
opts.onDeviceIdMigrated?.(migratedFrom, ownId);
|
|
114368
|
+
} catch (e) {
|
|
114369
|
+
log9("device id migration hook failed", e.message);
|
|
114370
|
+
}
|
|
114371
|
+
}
|
|
114372
|
+
} catch (e) {
|
|
114373
|
+
log9("device id reconcile skipped", e.message);
|
|
114374
|
+
}
|
|
114321
114375
|
let machine = null;
|
|
114322
114376
|
const acquireIdentity = async () => {
|
|
114323
114377
|
const signedIn = readCredentials();
|
|
@@ -114827,7 +114881,7 @@ async function runDaemon(opts = {}) {
|
|
|
114827
114881
|
scheduleRefreshRetry("the api was unreachable");
|
|
114828
114882
|
}
|
|
114829
114883
|
}
|
|
114830
|
-
|
|
114884
|
+
const reloadIdentity = async () => {
|
|
114831
114885
|
const fresh = readCredentials();
|
|
114832
114886
|
const next = nextDaemonIdentity(fresh, { accessToken, userId: c.userId });
|
|
114833
114887
|
if (next.kind === "unchanged")
|
|
@@ -114837,7 +114891,6 @@ async function runDaemon(opts = {}) {
|
|
|
114837
114891
|
c = fresh;
|
|
114838
114892
|
accessToken = fresh.accessToken;
|
|
114839
114893
|
log9(`signed in as ${fresh.userId} \u2014 re-homing the control link to the account`);
|
|
114840
|
-
setControlLinkDeviceId(fresh.deviceId);
|
|
114841
114894
|
refreshControlLink();
|
|
114842
114895
|
return;
|
|
114843
114896
|
}
|
|
@@ -114856,9 +114909,9 @@ async function runDaemon(opts = {}) {
|
|
|
114856
114909
|
c = { ...c, accessToken: m.accessToken, refreshSecret: "", dtid: "", userId: "", deviceId: m.deviceId, publicId: m.publicId, expiresAt: m.expiresAt ?? c.expiresAt };
|
|
114857
114910
|
accessToken = m.accessToken;
|
|
114858
114911
|
log9("signed out \u2014 this machine speaks for itself again");
|
|
114859
|
-
setControlLinkDeviceId(m.deviceId);
|
|
114860
114912
|
refreshControlLink();
|
|
114861
|
-
}
|
|
114913
|
+
};
|
|
114914
|
+
setDaemonIdentityReload(reloadIdentity);
|
|
114862
114915
|
registerTesseractEngine({ getIceServers: () => fetchIceServers() });
|
|
114863
114916
|
registerVncEngine();
|
|
114864
114917
|
registerRdpEngine();
|
|
@@ -115270,6 +115323,18 @@ async function runDaemon(opts = {}) {
|
|
|
115270
115323
|
deliverRdeskSignal: (payload, hostId, sessionId) => {
|
|
115271
115324
|
getRdeskClientWebContents()?.send("rdesk:signal", { payload, hostId, sessionId });
|
|
115272
115325
|
},
|
|
115326
|
+
// The account removed this machine (Remove in My Computers on another device, CLI logout).
|
|
115327
|
+
// Drop the account credentials and speak for the machine itself again — the same switch a
|
|
115328
|
+
// sign-out makes. The host app's own hook additionally turns sharing off, so it does not
|
|
115329
|
+
// simply provision a new token and come straight back.
|
|
115330
|
+
onDeviceRevoked: () => {
|
|
115331
|
+
log9("this machine was removed from the account \u2014 dropping its credentials; it speaks for itself again");
|
|
115332
|
+
try {
|
|
115333
|
+
unlinkSync7(join78(daemonDir2(), "credentials.json"));
|
|
115334
|
+
} catch {
|
|
115335
|
+
}
|
|
115336
|
+
void reloadIdentity();
|
|
115337
|
+
},
|
|
115273
115338
|
// Universal clipboard sync: a copy (or fetch/chunk control frame) from another of the account's
|
|
115274
115339
|
// devices → hand it to the daemon's clipboard-sync (created in onOwned).
|
|
115275
115340
|
onClipboard: (entry, fromClientId) => daemonClipboardSync?.onRemote(entry, fromClientId),
|
|
@@ -116822,7 +116887,6 @@ init_safe_kill();
|
|
|
116822
116887
|
|
|
116823
116888
|
// src/auth.ts
|
|
116824
116889
|
var import_qrcode_terminal = __toESM(require_main(), 1);
|
|
116825
|
-
import { randomUUID as randomUUID31 } from "node:crypto";
|
|
116826
116890
|
import { existsSync as existsSync48, rmSync as rmSync12 } from "node:fs";
|
|
116827
116891
|
import { join as join86 } from "node:path";
|
|
116828
116892
|
|
|
@@ -116964,7 +117028,7 @@ async function login(opts) {
|
|
|
116964
117028
|
process.exit(1);
|
|
116965
117029
|
}
|
|
116966
117030
|
}
|
|
116967
|
-
const deviceId3 = readCredentials()?.deviceId ?? process.env.CCB_DEVICE_ID ??
|
|
117031
|
+
const deviceId3 = readCredentials()?.deviceId ?? process.env.CCB_DEVICE_ID ?? persistentDeviceId();
|
|
116968
117032
|
const label = opts.name ?? defaultLabel();
|
|
116969
117033
|
if (opts.token) {
|
|
116970
117034
|
const dt = await fetchJson(`${api}/auth/device-token`, {
|
|
@@ -117380,6 +117444,10 @@ async function netCommand(rest, flags) {
|
|
|
117380
117444
|
return;
|
|
117381
117445
|
}
|
|
117382
117446
|
console.log("mesh engine: ok");
|
|
117447
|
+
if (s.running === false) {
|
|
117448
|
+
console.log(`node: NOT RUNNING \u2014 ${s.lastError ?? "no reason was recorded"}`);
|
|
117449
|
+
return;
|
|
117450
|
+
}
|
|
117383
117451
|
console.log(`node: running on UDP port ${s.port ?? "?"}`);
|
|
117384
117452
|
console.log(`node: LAN discovery ${s.lan ? "on" : "off (no multicast on this network)"}`);
|
|
117385
117453
|
const established = s.established ?? [];
|