friend-assistant 0.1.42 → 0.1.44
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/README.md +1 -1
- package/dist/BUILD.json +2 -2
- package/dist/chrome-control/dist/index.js +255 -76
- package/dist/friend.mjs +194 -20
- package/dist/web/assets/index-D6qxQkPK.js +4456 -0
- package/dist/web/assets/index-DrNs6WlQ.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-DdfqW6WX.js +0 -4456
- package/dist/web/assets/index-ehxATbhd.css +0 -1
package/dist/friend.mjs
CHANGED
|
@@ -312,6 +312,8 @@ var ServerMsg = z3.discriminatedUnion("type", [
|
|
|
312
312
|
data: z3.string()
|
|
313
313
|
}),
|
|
314
314
|
z3.object({ type: z3.literal("audio.stop") }),
|
|
315
|
+
/** How loud music and video should be while the owner talks or Friend speaks: 1 is as it is, 0.25 a quarter. */
|
|
316
|
+
z3.object({ type: z3.literal("audio.duck"), level: z3.number().min(0).max(1) }),
|
|
315
317
|
/** The owner approved a look through the camera: take one picture and upload it. */
|
|
316
318
|
z3.object({ type: z3.literal("camera.request"), id: z3.string() }),
|
|
317
319
|
/** Stop: the request was answered elsewhere, timed out, or the emergency lock fired. */
|
|
@@ -335,6 +337,8 @@ var ClientMsg = z3.discriminatedUnion("type", [
|
|
|
335
337
|
z3.object({ type: z3.literal("stage.event"), objectId: z3.string(), event: z3.string().max(64) }),
|
|
336
338
|
ApprovalRespond,
|
|
337
339
|
z3.object({ type: z3.literal("voice.interrupt") }),
|
|
340
|
+
/** This screen is listening to the owner, or Friend is speaking on it (true), or neither (false). */
|
|
341
|
+
z3.object({ type: z3.literal("audio.activity"), active: z3.boolean() }),
|
|
338
342
|
z3.object({ type: z3.literal("voice.confirm"), id: z3.string(), pin: z3.string().max(32) }),
|
|
339
343
|
z3.object({ type: z3.literal("voice.cancel"), id: z3.string() }),
|
|
340
344
|
z3.object({ type: z3.literal("camera.denied"), id: z3.string(), reason: z3.enum(["off", "no-camera", "permission", "busy"]) }),
|
|
@@ -3352,12 +3356,16 @@ var DEFAULT_VOICE = {
|
|
|
3352
3356
|
accept: 0.72,
|
|
3353
3357
|
challenge: 0.58,
|
|
3354
3358
|
hindiVoice: DEFAULT_HINDI_VOICE,
|
|
3355
|
-
marathiVoice: DEFAULT_MARATHI_VOICE
|
|
3359
|
+
marathiVoice: DEFAULT_MARATHI_VOICE,
|
|
3360
|
+
duck: true,
|
|
3361
|
+
duckPercent: 25
|
|
3356
3362
|
};
|
|
3357
3363
|
function sanitizeVoice(v) {
|
|
3358
3364
|
const ok = (n) => typeof n === "number" && Number.isFinite(n) && n >= 0 && n <= 1;
|
|
3359
|
-
|
|
3360
|
-
|
|
3365
|
+
const percent2 = typeof v.duckPercent === "number" && Number.isFinite(v.duckPercent) ? Math.max(0, Math.min(100, Math.round(v.duckPercent))) : DEFAULT_VOICE.duckPercent;
|
|
3366
|
+
const base = { ...v, duck: typeof v.duck === "boolean" ? v.duck : DEFAULT_VOICE.duck, duckPercent: percent2 };
|
|
3367
|
+
if (ok(v.accept) && ok(v.challenge) && v.accept > v.challenge) return base;
|
|
3368
|
+
return { ...base, accept: DEFAULT_VOICE.accept, challenge: DEFAULT_VOICE.challenge };
|
|
3361
3369
|
}
|
|
3362
3370
|
var DEFAULT_DESTRUCTIVE_PATTERNS = [
|
|
3363
3371
|
String.raw`\brm\s+(-[a-z]*r|-[a-z]*f)`,
|
|
@@ -4800,6 +4808,53 @@ var ChromePlugin = class {
|
|
|
4800
4808
|
});
|
|
4801
4809
|
return this.serving;
|
|
4802
4810
|
}
|
|
4811
|
+
/** Runs one of Chrome control's own commands that answer with a line of JSON. */
|
|
4812
|
+
async ask(command) {
|
|
4813
|
+
const entry = this.deps.bundled;
|
|
4814
|
+
if (!entry) return null;
|
|
4815
|
+
const r = await this.deps.run(process.execPath, [entry, command]);
|
|
4816
|
+
const line = r.stdout.split(/\r?\n/).reverse().find((l) => l.trim().startsWith("{"));
|
|
4817
|
+
if (!line) return null;
|
|
4818
|
+
try {
|
|
4819
|
+
return JSON.parse(line);
|
|
4820
|
+
} catch {
|
|
4821
|
+
return null;
|
|
4822
|
+
}
|
|
4823
|
+
}
|
|
4824
|
+
/** Whether the open Chrome has the flag that hides the banner, and how many shortcuts do. Changes nothing. */
|
|
4825
|
+
async bannerStatus() {
|
|
4826
|
+
if (!this.deps.bundled) return { supported: false };
|
|
4827
|
+
const s = await this.ask("flag-status").catch(() => null);
|
|
4828
|
+
if (!s || typeof s.running !== "boolean") return { supported: true, error: "Could not read Chrome's state." };
|
|
4829
|
+
const sc = s.shortcuts;
|
|
4830
|
+
return {
|
|
4831
|
+
supported: true,
|
|
4832
|
+
platform: String(s.platform ?? ""),
|
|
4833
|
+
running: s.running,
|
|
4834
|
+
hidden: typeof s.hidden === "boolean" ? s.hidden : null,
|
|
4835
|
+
shortcuts: sc && typeof sc.total === "number" ? { withFlag: sc.withFlag ?? 0, total: sc.total } : null
|
|
4836
|
+
};
|
|
4837
|
+
}
|
|
4838
|
+
/** Adds the flag to the Chrome shortcuts. It takes effect the next time Chrome starts. */
|
|
4839
|
+
async hideBanner() {
|
|
4840
|
+
if (!this.deps.bundled) return { ok: false, message: "This Friend has no copy of Chrome control to do that." };
|
|
4841
|
+
const r = await this.ask("flag").catch(() => null);
|
|
4842
|
+
const c = r?.counts;
|
|
4843
|
+
if (!r || !c) return { ok: false, message: "Could not change the shortcuts." };
|
|
4844
|
+
const patched = c.patched ?? 0;
|
|
4845
|
+
const failed = c.failed ?? 0;
|
|
4846
|
+
const already = c.already ?? 0;
|
|
4847
|
+
if (r.ok !== true) return { ok: false, patched, failed, message: failed ? "Windows would not let Friend change those shortcuts (shared ones may need an administrator)." : "No Chrome shortcut was found to change." };
|
|
4848
|
+
const bits = [patched ? `Added the flag to ${patched} shortcut${patched === 1 ? "" : "s"}.` : "", already ? `${already} already had it.` : "", failed ? `${failed} could not be changed (shared ones may need an administrator).` : ""].filter(Boolean);
|
|
4849
|
+
return { ok: true, patched, failed, message: `${bits.join(" ")} It counts when Chrome starts: if Chrome is open now, restart it.` };
|
|
4850
|
+
}
|
|
4851
|
+
/** Closes Chrome politely and starts it again with the flag and the tabs back. */
|
|
4852
|
+
async restartChrome() {
|
|
4853
|
+
if (!this.deps.bundled) return { ok: false, message: "This Friend has no copy of Chrome control to do that." };
|
|
4854
|
+
const r = await this.ask("chrome-restart").catch(() => null);
|
|
4855
|
+
if (!r || typeof r.ok !== "boolean") return { ok: false, message: "Could not restart Chrome." };
|
|
4856
|
+
return { ok: r.ok, message: String(r.message ?? (r.ok ? "Chrome was restarted." : "Chrome was not restarted.")) };
|
|
4857
|
+
}
|
|
4803
4858
|
/** Switches the connector off but keeps it listed. */
|
|
4804
4859
|
async disconnect() {
|
|
4805
4860
|
if (!this.deps.hub.list().some((c) => c.id === ID)) return;
|
|
@@ -5245,8 +5300,8 @@ var Mpv = class {
|
|
|
5245
5300
|
seek(seconds) {
|
|
5246
5301
|
return this.cmd(["seek", seconds, "absolute"]);
|
|
5247
5302
|
}
|
|
5248
|
-
volume(
|
|
5249
|
-
return this.cmd(["set_property", "volume",
|
|
5303
|
+
volume(percent2) {
|
|
5304
|
+
return this.cmd(["set_property", "volume", percent2]);
|
|
5250
5305
|
}
|
|
5251
5306
|
mute(on) {
|
|
5252
5307
|
return this.cmd(["set_property", "mute", on]);
|
|
@@ -5337,8 +5392,8 @@ var VideoHost = class {
|
|
|
5337
5392
|
seek(seconds) {
|
|
5338
5393
|
return this.mpv.seek(seconds);
|
|
5339
5394
|
}
|
|
5340
|
-
volume(
|
|
5341
|
-
return this.mpv.volume(
|
|
5395
|
+
volume(percent2) {
|
|
5396
|
+
return this.mpv.volume(percent2);
|
|
5342
5397
|
}
|
|
5343
5398
|
stop() {
|
|
5344
5399
|
return this.mpv.stop();
|
|
@@ -5942,10 +5997,10 @@ var Provisioner = class {
|
|
|
5942
5997
|
const list2 = await this.text(plan.sums.url);
|
|
5943
5998
|
const want = checksumFor(list2, plan.sums.name);
|
|
5944
5999
|
if (!want) return fail(`Friend could not check the ${name} download: no published checksum was found for it.`);
|
|
5945
|
-
let got = await this.file(plan.url, part, (
|
|
6000
|
+
let got = await this.file(plan.url, part, (percent2) => this.set(name, { phase: "downloading", percent: percent2 }));
|
|
5946
6001
|
if (got.error === "failed") {
|
|
5947
6002
|
rmSync4(part, { force: true });
|
|
5948
|
-
got = await this.file(plan.url, part, (
|
|
6003
|
+
got = await this.file(plan.url, part, (percent2) => this.set(name, { phase: "downloading", percent: percent2 }));
|
|
5949
6004
|
}
|
|
5950
6005
|
if (got.error) {
|
|
5951
6006
|
this.d.onError?.(name, got.error === "big" ? "too big" : got.why ?? "download failed");
|
|
@@ -6036,10 +6091,10 @@ var Provisioner = class {
|
|
|
6036
6091
|
}
|
|
6037
6092
|
hash.update(value);
|
|
6038
6093
|
if (!out.write(value)) await new Promise((r) => out.once("drain", () => r()));
|
|
6039
|
-
const
|
|
6040
|
-
if (
|
|
6041
|
-
lastPercent =
|
|
6042
|
-
progress(
|
|
6094
|
+
const percent2 = total > 0 ? Math.min(99, Math.floor(received / total * 100)) : null;
|
|
6095
|
+
if (percent2 !== lastPercent) {
|
|
6096
|
+
lastPercent = percent2 ?? -1;
|
|
6097
|
+
progress(percent2);
|
|
6043
6098
|
}
|
|
6044
6099
|
}
|
|
6045
6100
|
await new Promise((resolve13, reject) => {
|
|
@@ -6299,6 +6354,10 @@ var VideoHub = class {
|
|
|
6299
6354
|
tokens = /* @__PURE__ */ new Map();
|
|
6300
6355
|
streams = [];
|
|
6301
6356
|
cached = null;
|
|
6357
|
+
/** The volume the owner chose for the PC's player (mpv keeps it from one video to the next). */
|
|
6358
|
+
hostVolume = 100;
|
|
6359
|
+
/** How loud it is while someone talks: 1 is the owner's volume as it is. */
|
|
6360
|
+
duckLevel = 1;
|
|
6302
6361
|
now = null;
|
|
6303
6362
|
tickets = /* @__PURE__ */ new Map();
|
|
6304
6363
|
clock() {
|
|
@@ -6443,6 +6502,8 @@ var VideoHub = class {
|
|
|
6443
6502
|
const opened = await this.d.host.open(info.webpage || args.url || "", { start: start2, maxHeight: cfg.maxHeight });
|
|
6444
6503
|
if (!opened.ok) return { ok: false, text: opened.error };
|
|
6445
6504
|
this.now = { output, title: info.title, uploader: info.uploader, info, via: "mpv" };
|
|
6505
|
+
if (this.duckLevel < 1) await this.d.host.volume(this.hostLevel()).catch(() => {
|
|
6506
|
+
});
|
|
6446
6507
|
return { ok: true, text: `Playing ${what} in a window on this PC.` };
|
|
6447
6508
|
}
|
|
6448
6509
|
if (browserWindow) {
|
|
@@ -6487,6 +6548,17 @@ var VideoHub = class {
|
|
|
6487
6548
|
});
|
|
6488
6549
|
this.now = null;
|
|
6489
6550
|
}
|
|
6551
|
+
hostLevel() {
|
|
6552
|
+
return Math.round(this.hostVolume * this.duckLevel);
|
|
6553
|
+
}
|
|
6554
|
+
/** Turns the video in the PC's own player down (0.25 is a quarter) while someone talks, and back up (1) after. A video on the screen is turned down by the page. */
|
|
6555
|
+
async duck(level) {
|
|
6556
|
+
this.duckLevel = Math.max(0, Math.min(1, level));
|
|
6557
|
+
const now = this.now;
|
|
6558
|
+
if (now?.output !== "host" || now.via !== "mpv" || !this.d.host) return;
|
|
6559
|
+
await this.d.host.volume(this.hostLevel()).catch(() => {
|
|
6560
|
+
});
|
|
6561
|
+
}
|
|
6490
6562
|
async control(args) {
|
|
6491
6563
|
if (args.action === "stop") {
|
|
6492
6564
|
const wasScreen = this.now?.output === "screen";
|
|
@@ -6502,7 +6574,10 @@ var VideoHub = class {
|
|
|
6502
6574
|
if (args.action === "pause") await host.pause(true);
|
|
6503
6575
|
else if (args.action === "resume") await host.pause(false);
|
|
6504
6576
|
else if (args.action === "seek") await host.seek(Math.max(0, args.seconds ?? 0));
|
|
6505
|
-
else
|
|
6577
|
+
else {
|
|
6578
|
+
this.hostVolume = Math.max(0, Math.min(100, args.level ?? 50));
|
|
6579
|
+
await host.volume(this.hostLevel());
|
|
6580
|
+
}
|
|
6506
6581
|
} catch (e) {
|
|
6507
6582
|
return { ok: false, text: e instanceof Error ? e.message : "The player did not answer." };
|
|
6508
6583
|
}
|
|
@@ -8860,6 +8935,8 @@ var HostPlayer = class {
|
|
|
8860
8935
|
chain = Promise.resolve();
|
|
8861
8936
|
off;
|
|
8862
8937
|
disposed = false;
|
|
8938
|
+
/** How loud it is while someone talks: 1 is the owner's volume as it is. */
|
|
8939
|
+
duckLevel = 1;
|
|
8863
8940
|
now = () => (this.d.clock ?? Date.now)();
|
|
8864
8941
|
available() {
|
|
8865
8942
|
const problem = programProblem(this.d.settings().hostPlayer.trim());
|
|
@@ -9043,14 +9120,24 @@ var HostPlayer = class {
|
|
|
9043
9120
|
if (this.engine === "folder") await this.d.mpv.seek(seconds);
|
|
9044
9121
|
else if (this.engine === "spotify" && this.deviceId) await this.d.spotify.control(this.deviceId, { action: "seek", ms: Math.round(seconds * 1e3) });
|
|
9045
9122
|
}
|
|
9123
|
+
/** The owner's volume, turned down while someone is talking. */
|
|
9124
|
+
level() {
|
|
9125
|
+
return Math.round(this.s.volume * this.duckLevel);
|
|
9126
|
+
}
|
|
9046
9127
|
async applyVolume() {
|
|
9047
9128
|
if (this.engine === "folder") {
|
|
9048
|
-
await this.d.mpv.volume(this.
|
|
9129
|
+
await this.d.mpv.volume(this.level());
|
|
9049
9130
|
await this.d.mpv.mute(this.s.muted);
|
|
9050
9131
|
} else if (this.engine === "spotify" && this.deviceId) {
|
|
9051
|
-
await this.d.spotify.control(this.deviceId, { action: "volume", percent: this.s.muted ? 0 : this.
|
|
9132
|
+
await this.d.spotify.control(this.deviceId, { action: "volume", percent: this.s.muted ? 0 : this.level() });
|
|
9052
9133
|
}
|
|
9053
9134
|
}
|
|
9135
|
+
/** Turns the sound down (0.25 is a quarter) while the owner talks to Friend or Friend speaks, and back up (1) after. The owner's own volume is not changed. */
|
|
9136
|
+
async duck(level) {
|
|
9137
|
+
this.duckLevel = Math.max(0, Math.min(1, level));
|
|
9138
|
+
if (this.disposed || !this.engine) return;
|
|
9139
|
+
await this.run(() => this.applyVolume());
|
|
9140
|
+
}
|
|
9054
9141
|
// ---- what the engines tell us ----
|
|
9055
9142
|
onMpv(e) {
|
|
9056
9143
|
if (this.disposed) return;
|
|
@@ -11545,6 +11632,18 @@ function createGateway(deps) {
|
|
|
11545
11632
|
return pluginError(reply, e, "chrome.remote");
|
|
11546
11633
|
}
|
|
11547
11634
|
});
|
|
11635
|
+
app.get("/api/plugins/chrome/banner", { onRequest: pluginGuard }, async () => chrome.banner());
|
|
11636
|
+
app.post("/api/plugins/chrome/banner/:what", { onRequest: pluginGuard }, async (req, reply) => {
|
|
11637
|
+
const what = z10.enum(["hide", "restart"]).safeParse(req.params.what);
|
|
11638
|
+
const body = z10.object({ pin: z10.string().min(1).max(32) }).safeParse(req.body);
|
|
11639
|
+
if (!what.success) return reply.code(404).send({ error: "Not found" });
|
|
11640
|
+
if (!body.success) return reply.code(400).send({ error: "Enter your PIN" });
|
|
11641
|
+
try {
|
|
11642
|
+
return await chrome.bannerAct(what.data, body.data.pin, req.ip);
|
|
11643
|
+
} catch (e) {
|
|
11644
|
+
return pluginError(reply, e, `chrome.banner_${what.data}`);
|
|
11645
|
+
}
|
|
11646
|
+
});
|
|
11548
11647
|
app.post("/api/plugins/chrome/token", { onRequest: pluginGuard }, async (req, reply) => {
|
|
11549
11648
|
const body = z10.object({ pin: z10.string().min(1).max(32) }).safeParse(req.body);
|
|
11550
11649
|
if (!body.success) return reply.code(400).send({ error: "Enter your PIN" });
|
|
@@ -12897,7 +12996,9 @@ var SettingsPatch = z11.object({
|
|
|
12897
12996
|
/** A Piper voice name; empty makes the main voice read Hindi too. */
|
|
12898
12997
|
hindiVoice: z11.string().trim().max(80).regex(/^[A-Za-z0-9_-]*$/, "A Piper voice name such as hi_IN-priyamvada-medium, or empty"),
|
|
12899
12998
|
marathiVoice: z11.string().trim().max(80).regex(/^[A-Za-z0-9_-]*$/, "A Piper voice name such as mr_IN-google-medium, or empty"),
|
|
12900
|
-
sttModel: z11.string().trim().min(1).max(80).regex(/^[\w./-]+$/)
|
|
12999
|
+
sttModel: z11.string().trim().min(1).max(80).regex(/^[\w./-]+$/),
|
|
13000
|
+
duck: z11.boolean(),
|
|
13001
|
+
duckPercent: z11.number().int().min(0).max(100)
|
|
12901
13002
|
}).partial().strict()
|
|
12902
13003
|
}).partial().strict();
|
|
12903
13004
|
function settingsView(c) {
|
|
@@ -12958,7 +13059,9 @@ function settingsView(c) {
|
|
|
12958
13059
|
ttsVoice: c.voice.ttsVoice,
|
|
12959
13060
|
sttModel: c.voice.sttModel,
|
|
12960
13061
|
hindiVoice: c.voice.hindiVoice,
|
|
12961
|
-
marathiVoice: c.voice.marathiVoice
|
|
13062
|
+
marathiVoice: c.voice.marathiVoice,
|
|
13063
|
+
duck: c.voice.duck,
|
|
13064
|
+
duckPercent: c.voice.duckPercent
|
|
12962
13065
|
}
|
|
12963
13066
|
};
|
|
12964
13067
|
}
|
|
@@ -13550,6 +13653,42 @@ async function ensureTlsCert(dataDir, extraHosts = [], ifaces, now = Date.now) {
|
|
|
13550
13653
|
return { key: pems.private, cert: pems.cert };
|
|
13551
13654
|
}
|
|
13552
13655
|
|
|
13656
|
+
// ../server/src/audio/duck.ts
|
|
13657
|
+
var FALLBACK_PERCENT = 25;
|
|
13658
|
+
var DuckController = class {
|
|
13659
|
+
constructor(d) {
|
|
13660
|
+
this.d = d;
|
|
13661
|
+
}
|
|
13662
|
+
d;
|
|
13663
|
+
active = /* @__PURE__ */ new Set();
|
|
13664
|
+
current = 1;
|
|
13665
|
+
/** How loud things should be now: 1 as normal. */
|
|
13666
|
+
get level() {
|
|
13667
|
+
return this.current;
|
|
13668
|
+
}
|
|
13669
|
+
set(source, active) {
|
|
13670
|
+
if (active) this.active.add(source);
|
|
13671
|
+
else this.active.delete(source);
|
|
13672
|
+
this.update();
|
|
13673
|
+
}
|
|
13674
|
+
/** A screen went away. */
|
|
13675
|
+
drop(source) {
|
|
13676
|
+
if (this.active.delete(source)) this.update();
|
|
13677
|
+
}
|
|
13678
|
+
/** The owner changed the settings. */
|
|
13679
|
+
refresh() {
|
|
13680
|
+
this.update();
|
|
13681
|
+
}
|
|
13682
|
+
update() {
|
|
13683
|
+
const raw = this.d.percent();
|
|
13684
|
+
const percent2 = Number.isFinite(raw) ? Math.max(0, Math.min(100, raw)) : FALLBACK_PERCENT;
|
|
13685
|
+
const next = this.d.enabled() && this.active.size > 0 ? percent2 / 100 : 1;
|
|
13686
|
+
if (next === this.current) return;
|
|
13687
|
+
this.current = next;
|
|
13688
|
+
this.d.apply(next);
|
|
13689
|
+
}
|
|
13690
|
+
};
|
|
13691
|
+
|
|
13553
13692
|
// ../server/src/voice/challenge.ts
|
|
13554
13693
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
13555
13694
|
var Challenges = class {
|
|
@@ -14425,6 +14564,7 @@ async function createApp(opts) {
|
|
|
14425
14564
|
else swap();
|
|
14426
14565
|
}
|
|
14427
14566
|
if (applied.changed.includes("voice.ttsVoice")) void warmVoice(config.voice.ttsVoice, voiceBefore);
|
|
14567
|
+
if (applied.changed.some((k) => k === "voice.duck" || k === "voice.duckPercent")) ducker.refresh();
|
|
14428
14568
|
if (applied.changed.includes("voice.sttModel")) void warmListening(config.voice.sttModel, sttBefore);
|
|
14429
14569
|
if (applied.changed.includes("voice.hindiVoice")) void warmLanguageVoice(config.voice.hindiVoice);
|
|
14430
14570
|
if (applied.changed.includes("voice.marathiVoice")) void warmLanguageVoice(config.voice.marathiVoice);
|
|
@@ -14852,6 +14992,12 @@ async function createApp(opts) {
|
|
|
14852
14992
|
if (enabled) void chromeRemoteApi.ensureServer().catch(() => {
|
|
14853
14993
|
});
|
|
14854
14994
|
},
|
|
14995
|
+
banner: () => chromePlugin.bannerStatus(),
|
|
14996
|
+
bannerAct: async (what, pin, ip) => {
|
|
14997
|
+
await requirePin(pin, ip);
|
|
14998
|
+
audit.log("owner", what === "hide" ? "chrome.banner_hide" : "chrome.banner_restart", { ip });
|
|
14999
|
+
return what === "hide" ? chromePlugin.hideBanner() : chromePlugin.restartChrome();
|
|
15000
|
+
},
|
|
14855
15001
|
revealToken: async (pin, ip) => {
|
|
14856
15002
|
await requirePin(pin, ip);
|
|
14857
15003
|
const key = chromeToken(opts.quick?.home);
|
|
@@ -14860,6 +15006,20 @@ async function createApp(opts) {
|
|
|
14860
15006
|
return key;
|
|
14861
15007
|
}
|
|
14862
15008
|
};
|
|
15009
|
+
const duckIds = /* @__PURE__ */ new WeakMap();
|
|
15010
|
+
let duckSeq = 0;
|
|
15011
|
+
const duckId = (conn) => duckIds.get(conn) ?? (duckIds.set(conn, `screen-${++duckSeq}`), duckIds.get(conn));
|
|
15012
|
+
const ducker = new DuckController({
|
|
15013
|
+
enabled: () => config.voice.duck,
|
|
15014
|
+
percent: () => config.voice.duckPercent,
|
|
15015
|
+
apply: (level) => {
|
|
15016
|
+
broadcast({ type: "audio.duck", level });
|
|
15017
|
+
void hostPlayer.duck(level).catch(() => {
|
|
15018
|
+
});
|
|
15019
|
+
void videoHub.duck(level).catch(() => {
|
|
15020
|
+
});
|
|
15021
|
+
}
|
|
15022
|
+
});
|
|
14863
15023
|
const tls = config.https ? await ensureTlsCert(opts.dataDir, [...config.allowedHosts, ...config.publicUrl ? [new URL(config.publicUrl).hostname] : []]) : void 0;
|
|
14864
15024
|
const gateway = createGateway({
|
|
14865
15025
|
...tls ? { tls } : {},
|
|
@@ -15273,11 +15433,13 @@ ${url}`);
|
|
|
15273
15433
|
conn.send(statusMsg());
|
|
15274
15434
|
conn.send(uiMsg());
|
|
15275
15435
|
conn.send({ type: "music.host", state: hostPlayer.state() });
|
|
15436
|
+
if (ducker.level < 1) conn.send({ type: "audio.duck", level: ducker.level });
|
|
15276
15437
|
const pending = challenges.current();
|
|
15277
15438
|
if (pending) conn.send({ type: "voice.challenge", id: pending.id, text: pending.text });
|
|
15278
15439
|
return () => {
|
|
15279
15440
|
clients.delete(conn);
|
|
15280
15441
|
musicHub.detach(conn);
|
|
15442
|
+
ducker.drop(duckId(conn));
|
|
15281
15443
|
};
|
|
15282
15444
|
},
|
|
15283
15445
|
onClientMessage: (_session, msg, conn) => {
|
|
@@ -15295,6 +15457,9 @@ ${url}`);
|
|
|
15295
15457
|
case "voice.interrupt":
|
|
15296
15458
|
speaker?.interrupt(broadcast);
|
|
15297
15459
|
break;
|
|
15460
|
+
case "audio.activity":
|
|
15461
|
+
ducker.set(duckId(conn), msg.active);
|
|
15462
|
+
break;
|
|
15298
15463
|
case "voice.confirm":
|
|
15299
15464
|
void confirmChallenge(msg.id, msg.pin, conn).catch((e) => audit.log("system", "voice.confirm_error", { message: e.message }));
|
|
15300
15465
|
break;
|
|
@@ -15593,6 +15758,11 @@ var unit2 = (v) => {
|
|
|
15593
15758
|
if (v.trim() === "" || !Number.isFinite(n) || n < 0 || n > 1) throw new Error("Expected a number between 0 and 1");
|
|
15594
15759
|
return n;
|
|
15595
15760
|
};
|
|
15761
|
+
var percent = (v) => {
|
|
15762
|
+
const n = Number(v);
|
|
15763
|
+
if (v.trim() === "" || !Number.isFinite(n) || n < 0 || n > 100) throw new Error("Expected a number between 0 and 100");
|
|
15764
|
+
return Math.round(n);
|
|
15765
|
+
};
|
|
15596
15766
|
var httpUrl = (v) => {
|
|
15597
15767
|
let u;
|
|
15598
15768
|
try {
|
|
@@ -15651,6 +15821,8 @@ var GROUPS = {
|
|
|
15651
15821
|
},
|
|
15652
15822
|
language: (v) => v.trim() === "" ? null : v.trim(),
|
|
15653
15823
|
speakTyped: bool,
|
|
15824
|
+
duck: bool,
|
|
15825
|
+
duckPercent: percent,
|
|
15654
15826
|
accept: unit2,
|
|
15655
15827
|
challenge: unit2
|
|
15656
15828
|
},
|
|
@@ -15715,6 +15887,8 @@ var KEY_HELP = {
|
|
|
15715
15887
|
"voice.hindiVoice": "the voice that reads Hindi (Devanagari) text: hi_IN-priyamvada-medium, hi_IN-pratham-medium or hi_IN-rohan-medium; empty uses the main voice",
|
|
15716
15888
|
"voice.marathiVoice": "the voice that reads Marathi (Devanagari) text: mr_IN-google-medium; empty uses the main voice",
|
|
15717
15889
|
"voice.speakTyped": "true or false: also speak the replies to typed messages",
|
|
15890
|
+
"voice.duck": "true or false: turn music and video down while you talk to Friend and while it speaks",
|
|
15891
|
+
"voice.duckPercent": "0 to 100: how loud music and video are then, as a percent of how loud they were (25 is a quarter)",
|
|
15718
15892
|
"voice.accept": "0 to 1: a voice at or above this match is you",
|
|
15719
15893
|
"voice.challenge": "0 to 1: a voice between this and accept must be confirmed with your PIN",
|
|
15720
15894
|
"ollama.url": "address of the Ollama server, for example http://127.0.0.1:11434",
|
|
@@ -17878,7 +18052,7 @@ async function daemonCommand(args, io2, deps = realDeps) {
|
|
|
17878
18052
|
import crossSpawn5 from "cross-spawn";
|
|
17879
18053
|
var PACKAGE = "friend-assistant";
|
|
17880
18054
|
var real = {
|
|
17881
|
-
current: () => true ? "0.1.
|
|
18055
|
+
current: () => true ? "0.1.44" : "development",
|
|
17882
18056
|
latest: () => new Promise((resolve13) => {
|
|
17883
18057
|
const child = crossSpawn5("npm", ["view", PACKAGE, "version", "--prefer-online"], { stdio: ["ignore", "pipe", "ignore"] });
|
|
17884
18058
|
let out = "";
|
|
@@ -18166,7 +18340,7 @@ async function run(argv, io2) {
|
|
|
18166
18340
|
case "version":
|
|
18167
18341
|
case "--version":
|
|
18168
18342
|
case "-v":
|
|
18169
|
-
io2.out(true ? "0.1.
|
|
18343
|
+
io2.out(true ? "0.1.44" : "development");
|
|
18170
18344
|
return 0;
|
|
18171
18345
|
case "lan":
|
|
18172
18346
|
return await lanCommand(rest, io2);
|