friend-assistant 0.1.112 → 0.1.113

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 CHANGED
@@ -174,6 +174,7 @@ Example: `friend config set voice.speakTyped false` keeps typed messages silent.
174
174
  |---|---|
175
175
  | `FRIEND_HOME` | The folder where Friend keeps its data (default: `.friend` in your home folder). Use another folder to keep a separate test copy. |
176
176
  | `FRIEND_DAEMON` | Set to `1` by `friend daemon start` for the Friend it starts in the background. Only a background Friend may restart itself to install an update; one running in a terminal never does. You do not set it yourself. |
177
+ | `FRIEND_CHILD` | Set to `1` by the watcher of a background Friend for the Friend it keeps running; if that one ever ends by itself, the watcher starts it again after a short wait. You do not set it yourself. |
177
178
  | `FRIEND_SECRET_KEY` | A passphrase to lock the saved keys, tokens and passwords with, instead of the `secret.key` file Friend makes in its data folder. Keys in `config.json` are always stored encrypted (on every system); with this set, the unlocking key is not on the disk at all. Set the same value on every start; if it is lost, those keys must be entered again. |
178
179
  | `FRIEND_ANTHROPIC_KEY` | An API key to use when none is saved. |
179
180
  | `FRIEND_PC_DIR` | On a Windows PC: the folder where the PC agent keeps its data and its log (default `%LOCALAPPDATA%\Friend\pc-agent`). |
package/dist/BUILD.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "friend-assistant",
3
- "version": "0.1.112",
4
- "builtAt": "2026-11-27T18:06:56.316Z"
3
+ "version": "0.1.113",
4
+ "builtAt": "2026-11-28T10:25:34.695Z"
5
5
  }
package/dist/friend.mjs CHANGED
@@ -24371,7 +24371,49 @@ var FOCUS_CHAT = `(() => { ${HELPERS}
24371
24371
  return new Promise((done) => setTimeout(() => { b = box(); if (!b) return done(false); b.focus(); done(true); }, 700));
24372
24372
  })()`;
24373
24373
  var HANG_UP = `(() => { ${HELPERS} const b = document.querySelector('[data-tid="hangup-button"], #hangup-button') || byText(/^\\s*(leave|hang up)\\b/i, "button, [role=button]"); if (!b) return false; b.click(); return true; })()`;
24374
+ var READ_CHAT = `(() => { ${HELPERS}
24375
+ const ITEM = '[data-tid="chat-pane-item"], [data-tid="chat-pane-message"], [data-tid="message-pane-body"] [role="listitem"], [data-tid="chat-message-list"] [role="listitem"], [data-tid="message-pane-list-viewport"] [role="listitem"], [data-tid="message-pane-list-viewport"] [role="group"]';
24376
+ const pane = document.querySelector('[data-tid="message-pane-list-viewport"], [data-tid="chat-pane"], [data-tid="meeting-chat-pane"], [data-tid="chat-message-list"]');
24377
+ if (!pane) { const open = document.querySelector('[data-tid="chat-button"], #chat-button') || byText(/^\\s*chat\\b/i, "button, [role=button]"); if (open) open.click(); return null; }
24378
+ const seen = new Set();
24379
+ const out = [];
24380
+ let prev = "";
24381
+ for (const el of Array.from(document.querySelectorAll(ITEM))) {
24382
+ if (seen.has(el) || Array.from(seen).some((s) => s.contains(el))) continue;
24383
+ seen.add(el);
24384
+ const a = el.querySelector('[data-tid="message-author-name"], [data-tid*="author"]');
24385
+ const b = el.querySelector('[data-tid="chat-pane-message"], [data-tid="message-body-content"], [id^="content-"], [data-tid="message-body"]');
24386
+ let sender = a ? txt(a) : "";
24387
+ if (sender) prev = sender; else sender = prev;
24388
+ let text = b ? txt(b) : txt(el);
24389
+ if (!b && a) text = text.replace(txt(a), "").trim();
24390
+ if (text && sender) out.push({ sender, text: text.slice(0, 600) });
24391
+ }
24392
+ return out;
24393
+ })()`;
24394
+ var PEOPLE = `(() => { ${HELPERS}
24395
+ const TILE = '[data-tid*="video-tile"], [data-tid*="participant-tile"], [data-tid="calling-participant-stream"], [data-tid*="stream-container"], [data-cid*="tile"], [role="listitem"][aria-label]';
24396
+ const names = [];
24397
+ const speaking = [];
24398
+ for (const el of all(TILE)) {
24399
+ const n = el.querySelector('[data-tid*="display-name"], [data-tid*="participant-name"], [data-tid*="name"]');
24400
+ let name = n ? txt(n) : (el.getAttribute("aria-label") || "").split(",")[0].trim();
24401
+ name = name.replace(/\\s*\\((guest|external|unverified)[^)]*\\)/i, "").trim();
24402
+ if (!name || name.length > 60) continue;
24403
+ if (!names.includes(name)) names.push(name);
24404
+ const ring = el.querySelector('[data-tid*="voice-level"], [data-tid*="speaking"], [class*="speaking" i], [class*="voice-level" i]');
24405
+ if (ring || /speaking/i.test(el.getAttribute("aria-label") || "")) speaking.push(name);
24406
+ }
24407
+ return { names, speaking };
24408
+ })()`;
24409
+ var CLICK_SHARE = `(() => { ${HELPERS} const b = document.querySelector('[data-tid="share-button"], #share-button') || byText(/^\\s*(share|present)\\b/i, "button, [role=button]"); if (!b) return false; const r = b.getBoundingClientRect(); return { x: r.x + r.width / 2, y: r.y + r.height / 2 }; })()`;
24410
+ var CLICK_SCREEN = `(() => { ${HELPERS} const b = byText(/^\\s*(screen|entire screen|share (the )?screen|present (the )?screen)\\b/i, "button, [role=button], [role=menuitem], [role=option], [data-tid*="screen"]") || document.querySelector('[data-tid*="share-screen"], [data-tid*="screen-share"]'); if (!b) return false; const r = b.getBoundingClientRect(); return { x: r.x + r.width / 2, y: r.y + r.height / 2 }; })()`;
24411
+ var STOP_SHARE = `(() => { ${HELPERS} const b = document.querySelector('[data-tid="stop-sharing-button"], [data-tid="unshare-button"]') || byText(/stop (presenting|sharing)/i, "button, [role=button]"); if (!b) return false; b.click(); return true; })()`;
24374
24412
  var TEAMS = {
24413
+ readChat: READ_CHAT,
24414
+ people: PEOPLE,
24415
+ shareSteps: [CLICK_SHARE, CLICK_SCREEN],
24416
+ stopShare: STOP_SHARE,
24375
24417
  advance: ADVANCE,
24376
24418
  captions: CAPTIONS,
24377
24419
  captionSteps: [OPEN_MORE, CLICK_CAPTIONS_ITEM, CLICK_LANGUAGE, CLICK_CAPTIONS, CLICK_CONFIRM],
@@ -24818,11 +24860,14 @@ var MeetingSession = class {
24818
24860
  const d = this.d;
24819
24861
  if (this.status !== "live") return { ok: false, message: "It is not in the meeting." };
24820
24862
  if (!d.speech || !d.page.speak || !d.page.mic) return { ok: false, message: "Speaking aloud is not switched on here." };
24821
- if (this.now() - this.lastSpoke < 2e4) return { ok: false, message: "It spoke a moment ago: wait twenty seconds between spoken answers." };
24863
+ if (this.now() - this.lastSpoke < 6e3) return { ok: false, message: "It spoke a moment ago: wait a few seconds between spoken answers." };
24822
24864
  this.lastSpoke = this.now();
24865
+ const t02 = Date.now();
24823
24866
  const quietFor = () => d.hearing && this.audioMode ? Date.now() - d.hearing.lastVoiceAt : this.now() - this.lastHeard;
24867
+ const making = d.speech(text5.slice(0, 400)).catch(() => null);
24824
24868
  for (let w = 0; quietFor() < (this.audioMode ? 500 : 1500) && w < 40; w++) await this.sleep(150);
24825
- const wav = await d.speech(text5.slice(0, 400)).catch(() => null);
24869
+ const wav = await making;
24870
+ d.events.timing?.("speak.prepare", Date.now() - t02);
24826
24871
  if (!wav) return { ok: false, message: "This PC has no voice to speak with." };
24827
24872
  if (!await d.page.mic(true).catch(() => false)) return { ok: false, message: "It could not switch the microphone on in the meeting." };
24828
24873
  let ok4 = false;
@@ -24882,6 +24927,10 @@ var MeetingSession = class {
24882
24927
  await d.page.camera?.(true).catch(() => false);
24883
24928
  }
24884
24929
  await this.listen(captionsTried, noCaptions, warned).then((r) => ({ captionsTried, noCaptions, warned } = r));
24930
+ await this.watchPeople().catch(() => {
24931
+ });
24932
+ await this.watchChat().catch(() => {
24933
+ });
24885
24934
  } else if (this.now() - began > 12e4 && !inSince) {
24886
24935
  reason = s.detail || "It could not join the meeting.";
24887
24936
  d.events.problem(reason);
@@ -24944,9 +24993,70 @@ var MeetingSession = class {
24944
24993
  }
24945
24994
  const pcm = await d.page.audio?.().catch(() => null);
24946
24995
  if (pcm && this.now() >= this.deafUntil) d.hearing?.push(pcm);
24947
- const lines = d.hearing?.take() ?? [];
24996
+ const lines = (d.hearing?.take() ?? []).map((l) => l.verified ? l : { ...l, speaker: this.who(l.speaker) });
24948
24997
  if (lines.length) this.take(lines);
24949
24998
  }
24999
+ /** People in the meeting, as the page last showed them, and who was seen speaking just now. */
25000
+ roster = [];
25001
+ seenSpeaking = [];
25002
+ lastPeople = 0;
25003
+ lastChatRead = 0;
25004
+ chatSeen = /* @__PURE__ */ new Set();
25005
+ chatReady = false;
25006
+ isSelf(name) {
25007
+ const n2 = name.trim().toLowerCase();
25008
+ return !n2 || n2 === this.d.selfName.trim().toLowerCase() || n2 === "you" || n2.startsWith(`${this.d.selfName.trim().toLowerCase()} (`);
25009
+ }
25010
+ async watchPeople() {
25011
+ if (!this.d.page.people || this.now() - this.lastPeople < 1200) return;
25012
+ this.lastPeople = this.now();
25013
+ const p = await this.d.page.people();
25014
+ if (!p) return;
25015
+ this.roster = p.names.filter((n2) => !this.isSelf(n2));
25016
+ for (const n2 of p.speaking) if (!this.isSelf(n2)) this.seenSpeaking.push({ name: n2, at: this.now() });
25017
+ this.seenSpeaking = this.seenSpeaking.filter((s) => this.now() - s.at < 12e3);
25018
+ }
25019
+ /** A line from "Someone" gets the name the meeting shows: whoever was seen speaking just now, or the one other person who is there. */
25020
+ who(speaker) {
25021
+ if (speaker.trim().toLowerCase() !== "someone") return speaker;
25022
+ const recent = [...new Set(this.seenSpeaking.filter((s) => this.now() - s.at < 8e3).map((s) => s.name))];
25023
+ if (recent.length === 1) return recent[0];
25024
+ const owners = this.d.prefs().ownerNames.map((n2) => n2.toLowerCase());
25025
+ const others = this.roster.filter((n2) => !owners.some((o) => n2.toLowerCase().includes(o)));
25026
+ return others.length === 1 ? others[0] : speaker;
25027
+ }
25028
+ /** What people write in the chat is read like what they say: it is kept, and it can be addressed to the assistant. */
25029
+ async watchChat() {
25030
+ if (!this.d.page.readChat || this.now() - this.lastChatRead < 3e3) return;
25031
+ this.lastChatRead = this.now();
25032
+ const msgs = await this.d.page.readChat();
25033
+ if (!msgs) return;
25034
+ const fresh2 = [];
25035
+ const counts = /* @__PURE__ */ new Map();
25036
+ for (const m of msgs) {
25037
+ const base = `${m.sender}\0${m.text}`;
25038
+ const n2 = (counts.get(base) ?? 0) + 1;
25039
+ counts.set(base, n2);
25040
+ const key2 = `${base}\0${n2}`;
25041
+ if (this.chatSeen.has(key2)) continue;
25042
+ this.chatSeen.add(key2);
25043
+ if (this.chatReady && !this.isSelf(m.sender) && m.text.trim()) fresh2.push({ speaker: m.sender, text: `(in the chat) ${m.text.trim()}` });
25044
+ }
25045
+ this.chatReady = true;
25046
+ if (fresh2.length) this.take(fresh2);
25047
+ }
25048
+ /** Shows something to the meeting by sharing its screen. */
25049
+ async present(c) {
25050
+ if (this.status !== "live") return { ok: false, message: "It is not in the meeting." };
25051
+ if (!this.d.page.present) return { ok: false, message: "This meeting page cannot share a screen." };
25052
+ return this.d.page.present(c);
25053
+ }
25054
+ async flip(by) {
25055
+ return await this.d.page.flip?.(by).catch(() => false) === true;
25056
+ }
25057
+ async stopPresenting() {
25058
+ return await this.d.page.stopPresenting?.().catch(() => false) === true;
25059
+ }
24950
25060
  take(lines) {
24951
25061
  const d = this.d;
24952
25062
  this.lastHeard = this.now();
@@ -25331,7 +25441,7 @@ var AudioHearing = class {
25331
25441
  ready = [];
25332
25442
  o;
25333
25443
  constructor(o) {
25334
- this.o = { speaker: "Someone", silence: 0.012, minSeconds: 1.2, maxSeconds: 10, ...o };
25444
+ this.o = { speaker: "Someone", silence: 0.012, minSeconds: 0.9, maxSeconds: 10, ...o };
25335
25445
  }
25336
25446
  /** When someone was last heard talking (milliseconds, Date.now): it never starts to speak over them. */
25337
25447
  lastVoiceAt = 0;
@@ -28037,7 +28147,10 @@ var ImapSmtpProvider = class {
28037
28147
  usable = false;
28038
28148
  makeImap() {
28039
28149
  if (this.deps.imap) return this.deps.imap();
28040
- return new ImapFlow({ host: this.s.imap.host, port: this.s.imap.port, secure: this.s.imap.tls, auth: { user: this.s.username, pass: this.s.password }, logger: false });
28150
+ const c = new ImapFlow({ host: this.s.imap.host, port: this.s.imap.port, secure: this.s.imap.tls, auth: { user: this.s.username, pass: this.s.password }, logger: false });
28151
+ c.on("error", () => {
28152
+ });
28153
+ return c;
28041
28154
  }
28042
28155
  wrap(e, host3) {
28043
28156
  if (e instanceof MailAuthError || e instanceof MailNetworkError) return e;
@@ -29522,7 +29635,7 @@ function currentSelf() {
29522
29635
  // ../server/src/system/npm.ts
29523
29636
  import { spawn as spawn11 } from "node:child_process";
29524
29637
  var PACKAGE = "friend-assistant";
29525
- var runningVersion = () => true ? "0.1.112" : "development";
29638
+ var runningVersion = () => true ? "0.1.113" : "development";
29526
29639
  async function npmLatest(fetchFn = fetch, timeoutMs = 1e4) {
29527
29640
  try {
29528
29641
  const res = await fetchFn(`https://registry.npmjs.org/${PACKAGE}/latest`, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(timeoutMs) });
@@ -33495,6 +33608,7 @@ function startDeviceNode(opts) {
33495
33608
  }
33496
33609
 
33497
33610
  // ../agent-cli/src/commands/start.ts
33611
+ import { spawn as spawn15 } from "node:child_process";
33498
33612
  import { randomBytes as randomBytes20 } from "node:crypto";
33499
33613
  import { existsSync as existsSync33, readFileSync as readFileSync26, writeFileSync as writeFileSync27 } from "node:fs";
33500
33614
  import { dirname as dirname12, join as join38, resolve as resolve8 } from "node:path";
@@ -33930,7 +34044,39 @@ function waitForSignal() {
33930
34044
  process.once("SIGTERM", res);
33931
34045
  });
33932
34046
  }
34047
+ async function superviseFriend(io2, sleep4 = (ms2) => new Promise((r) => setTimeout(r, ms2))) {
34048
+ let asked = false;
34049
+ let child = null;
34050
+ const stop2 = () => {
34051
+ asked = true;
34052
+ child?.kill();
34053
+ };
34054
+ process.once("SIGTERM", stop2);
34055
+ process.once("SIGINT", stop2);
34056
+ let quick = 0;
34057
+ while (!asked) {
34058
+ const began = Date.now();
34059
+ const code = await new Promise((done) => {
34060
+ child = spawn15(process.execPath, [process.argv[1], "start"], { stdio: "inherit", windowsHide: true, env: { ...process.env, FRIEND_CHILD: "1" } });
34061
+ child.on("error", () => done(1));
34062
+ child.on("exit", (c) => done(c));
34063
+ });
34064
+ if (asked || code === 0) return 0;
34065
+ quick = Date.now() - began < 6e4 ? quick + 1 : 0;
34066
+ const wait = Math.min(3e4, 2e3 * 2 ** Math.min(quick, 4));
34067
+ io2.out(`Friend stopped unexpectedly (code ${code ?? "none"}). Starting it again in ${Math.round(wait / 1e3)} seconds.`);
34068
+ await sleep4(wait);
34069
+ }
34070
+ return 0;
34071
+ }
34072
+ function surviveErrors(io2) {
34073
+ const note = (kind, e) => io2.out(`${kind}: ${e instanceof Error ? e.stack ?? e.message : String(e)}`);
34074
+ process.on("uncaughtException", (e) => note("An error was caught and ignored", e));
34075
+ process.on("unhandledRejection", (e) => note("A failed task was caught and ignored", e));
34076
+ }
33933
34077
  async function startCommand(io2) {
34078
+ if (process.env.FRIEND_DAEMON === "1" && process.env.FRIEND_CHILD !== "1" && !io2.waitForExit) return superviseFriend(io2);
34079
+ if (!io2.waitForExit) surviveErrors(io2);
33934
34080
  const f = await startFriend({ dataDir: io2.dataDir, out: io2.out });
33935
34081
  await (io2.waitForExit ?? waitForSignal)();
33936
34082
  io2.out("Stopping\u2026");
@@ -35340,7 +35486,7 @@ async function auditCommand(args, io2, deps = {}) {
35340
35486
  }
35341
35487
 
35342
35488
  // ../agent-cli/src/commands/daemon.ts
35343
- import { spawn as spawn15, spawnSync as spawnSync3 } from "node:child_process";
35489
+ import { spawn as spawn16, spawnSync as spawnSync3 } from "node:child_process";
35344
35490
  import { closeSync as closeSync2, existsSync as existsSync37, mkdirSync as mkdirSync28, openSync as openSync2, readFileSync as readFileSync28, renameSync as renameSync7, rmSync as rmSync17, statSync as statSync12, writeFileSync as writeFileSync30 } from "node:fs";
35345
35491
  import { connect as connect2 } from "node:net";
35346
35492
  import { join as join43 } from "node:path";
@@ -35351,7 +35497,7 @@ var realDeps = {
35351
35497
  launch(logFile) {
35352
35498
  const fd = openSync2(logFile, "a");
35353
35499
  try {
35354
- const child = spawn15(process.execPath, [process.argv[1], "start"], { detached: true, stdio: ["ignore", fd, fd], windowsHide: true, env: { ...process.env, FRIEND_DAEMON: "1" } });
35500
+ const child = spawn16(process.execPath, [process.argv[1], "start"], { detached: true, stdio: ["ignore", fd, fd], windowsHide: true, env: { ...process.env, FRIEND_DAEMON: "1" } });
35355
35501
  child.unref();
35356
35502
  return child.pid;
35357
35503
  } finally {
@@ -35514,7 +35660,7 @@ import { appendFileSync } from "node:fs";
35514
35660
  import { join as join44 } from "node:path";
35515
35661
  var PACKAGE2 = "friend-assistant";
35516
35662
  var real2 = {
35517
- current: () => true ? "0.1.112" : "development",
35663
+ current: () => true ? "0.1.113" : "development",
35518
35664
  latest: () => new Promise((resolve13) => {
35519
35665
  const child = crossSpawn5("npm", ["view", PACKAGE2, "version", "--prefer-online"], { stdio: ["ignore", "pipe", "ignore"] });
35520
35666
  let out = "";
@@ -35832,7 +35978,7 @@ async function run2(argv, io2) {
35832
35978
  case "version":
35833
35979
  case "--version":
35834
35980
  case "-v":
35835
- io2.out(true ? "0.1.112" : "development");
35981
+ io2.out(true ? "0.1.113" : "development");
35836
35982
  return 0;
35837
35983
  case "lan":
35838
35984
  return await lanCommand(rest, io2);
@@ -31039,7 +31039,7 @@ Write-Output ('changed: ' + ($did -join ','))`;
31039
31039
  }
31040
31040
 
31041
31041
  // ../pc-agent/src/main.ts
31042
- var VERSION = "0.1.112";
31042
+ var VERSION = "0.1.113";
31043
31043
  var TASK2 = "Friend PC Agent";
31044
31044
  function parse3(argv) {
31045
31045
  const out = {};
@@ -1 +1 @@
1
- 5896d75c965a48307ff135ba9d476e23848f2a02aaafef6d741d74b00bde7477
1
+ 2495b4715f314428bfbcaf7c208cd9d2b6a8729b5deaf68c22cfba2c560d1dc1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "friend-assistant",
3
- "version": "0.1.112",
3
+ "version": "0.1.113",
4
4
  "description": "A self-hosted personal AI assistant for your own PC: a full-screen stage, voice, tools with your approval, and your Claude subscription or a local model.",
5
5
  "keywords": ["ai", "assistant", "jarvis", "voice", "claude", "ollama", "mcp", "self-hosted"],
6
6
  "license": "UNLICENSED",