friend-assistant 0.1.111 → 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 +1 -0
- package/dist/BUILD.json +2 -2
- package/dist/friend.mjs +161 -11
- package/dist/pc-agent/agent.js +41 -9
- package/dist/pc-agent/agent.js.sha256 +1 -1
- package/package.json +1 -1
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
package/dist/friend.mjs
CHANGED
|
@@ -22092,7 +22092,11 @@ Move-Item -Force $part $agent
|
|
|
22092
22092
|
|
|
22093
22093
|
# 3. start at every logon, and every five minutes if it is not running (after a crash or an update; while it runs the task ignores the trigger)
|
|
22094
22094
|
$who = $env:USERDOMAIN + '\\' + $env:USERNAME
|
|
22095
|
-
|
|
22095
|
+
# node.exe is a console program and would open a terminal window at every logon: Windows Script Host starts it with no window at all
|
|
22096
|
+
$vbs = Join-Path $dir 'run.vbs'
|
|
22097
|
+
$vbsLines = @('Set s = CreateObject(' + $q + 'WScript.Shell' + $q + ')', ('s.CurrentDirectory = ' + $q + $dir + $q), ('rc = s.Run(' + $q + $q + $q + $nodeExe + $q + $q + ' ' + $q + $q + $agent + $q + $q + $q + ', 0, True)'), 'WScript.Quit rc')
|
|
22098
|
+
[IO.File]::WriteAllText($vbs, (($vbsLines -join [Environment]::NewLine) + [Environment]::NewLine), [Text.Encoding]::Default)
|
|
22099
|
+
$action = New-ScheduledTaskAction -Execute 'wscript.exe' -Argument ('//B //Nologo ' + $q + $vbs + $q) -WorkingDirectory $dir
|
|
22096
22100
|
$trigger = @((New-ScheduledTaskTrigger -AtLogOn -User $who), (New-ScheduledTaskTrigger -Once -At ((Get-Date).AddMinutes(2)) -RepetitionInterval (New-TimeSpan -Minutes 5) -RepetitionDuration (New-TimeSpan -Days 3650)))
|
|
22097
22101
|
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -RestartCount 999 -RestartInterval (New-TimeSpan -Minutes 1) -ExecutionTimeLimit ([TimeSpan]::Zero) -MultipleInstances IgnoreNew
|
|
22098
22102
|
$principal = New-ScheduledTaskPrincipal -UserId $who -LogonType Interactive -RunLevel Limited
|
|
@@ -24367,7 +24371,49 @@ var FOCUS_CHAT = `(() => { ${HELPERS}
|
|
|
24367
24371
|
return new Promise((done) => setTimeout(() => { b = box(); if (!b) return done(false); b.focus(); done(true); }, 700));
|
|
24368
24372
|
})()`;
|
|
24369
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; })()`;
|
|
24370
24412
|
var TEAMS = {
|
|
24413
|
+
readChat: READ_CHAT,
|
|
24414
|
+
people: PEOPLE,
|
|
24415
|
+
shareSteps: [CLICK_SHARE, CLICK_SCREEN],
|
|
24416
|
+
stopShare: STOP_SHARE,
|
|
24371
24417
|
advance: ADVANCE,
|
|
24372
24418
|
captions: CAPTIONS,
|
|
24373
24419
|
captionSteps: [OPEN_MORE, CLICK_CAPTIONS_ITEM, CLICK_LANGUAGE, CLICK_CAPTIONS, CLICK_CONFIRM],
|
|
@@ -24814,11 +24860,14 @@ var MeetingSession = class {
|
|
|
24814
24860
|
const d = this.d;
|
|
24815
24861
|
if (this.status !== "live") return { ok: false, message: "It is not in the meeting." };
|
|
24816
24862
|
if (!d.speech || !d.page.speak || !d.page.mic) return { ok: false, message: "Speaking aloud is not switched on here." };
|
|
24817
|
-
if (this.now() - this.lastSpoke <
|
|
24863
|
+
if (this.now() - this.lastSpoke < 6e3) return { ok: false, message: "It spoke a moment ago: wait a few seconds between spoken answers." };
|
|
24818
24864
|
this.lastSpoke = this.now();
|
|
24865
|
+
const t02 = Date.now();
|
|
24819
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);
|
|
24820
24868
|
for (let w = 0; quietFor() < (this.audioMode ? 500 : 1500) && w < 40; w++) await this.sleep(150);
|
|
24821
|
-
const wav = await
|
|
24869
|
+
const wav = await making;
|
|
24870
|
+
d.events.timing?.("speak.prepare", Date.now() - t02);
|
|
24822
24871
|
if (!wav) return { ok: false, message: "This PC has no voice to speak with." };
|
|
24823
24872
|
if (!await d.page.mic(true).catch(() => false)) return { ok: false, message: "It could not switch the microphone on in the meeting." };
|
|
24824
24873
|
let ok4 = false;
|
|
@@ -24878,6 +24927,10 @@ var MeetingSession = class {
|
|
|
24878
24927
|
await d.page.camera?.(true).catch(() => false);
|
|
24879
24928
|
}
|
|
24880
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
|
+
});
|
|
24881
24934
|
} else if (this.now() - began > 12e4 && !inSince) {
|
|
24882
24935
|
reason = s.detail || "It could not join the meeting.";
|
|
24883
24936
|
d.events.problem(reason);
|
|
@@ -24940,9 +24993,70 @@ var MeetingSession = class {
|
|
|
24940
24993
|
}
|
|
24941
24994
|
const pcm = await d.page.audio?.().catch(() => null);
|
|
24942
24995
|
if (pcm && this.now() >= this.deafUntil) d.hearing?.push(pcm);
|
|
24943
|
-
const lines = d.hearing?.take() ?? [];
|
|
24996
|
+
const lines = (d.hearing?.take() ?? []).map((l) => l.verified ? l : { ...l, speaker: this.who(l.speaker) });
|
|
24944
24997
|
if (lines.length) this.take(lines);
|
|
24945
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
|
+
}
|
|
24946
25060
|
take(lines) {
|
|
24947
25061
|
const d = this.d;
|
|
24948
25062
|
this.lastHeard = this.now();
|
|
@@ -25327,7 +25441,7 @@ var AudioHearing = class {
|
|
|
25327
25441
|
ready = [];
|
|
25328
25442
|
o;
|
|
25329
25443
|
constructor(o) {
|
|
25330
|
-
this.o = { speaker: "Someone", silence: 0.012, minSeconds:
|
|
25444
|
+
this.o = { speaker: "Someone", silence: 0.012, minSeconds: 0.9, maxSeconds: 10, ...o };
|
|
25331
25445
|
}
|
|
25332
25446
|
/** When someone was last heard talking (milliseconds, Date.now): it never starts to speak over them. */
|
|
25333
25447
|
lastVoiceAt = 0;
|
|
@@ -28033,7 +28147,10 @@ var ImapSmtpProvider = class {
|
|
|
28033
28147
|
usable = false;
|
|
28034
28148
|
makeImap() {
|
|
28035
28149
|
if (this.deps.imap) return this.deps.imap();
|
|
28036
|
-
|
|
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;
|
|
28037
28154
|
}
|
|
28038
28155
|
wrap(e, host3) {
|
|
28039
28156
|
if (e instanceof MailAuthError || e instanceof MailNetworkError) return e;
|
|
@@ -29518,7 +29635,7 @@ function currentSelf() {
|
|
|
29518
29635
|
// ../server/src/system/npm.ts
|
|
29519
29636
|
import { spawn as spawn11 } from "node:child_process";
|
|
29520
29637
|
var PACKAGE = "friend-assistant";
|
|
29521
|
-
var runningVersion = () => true ? "0.1.
|
|
29638
|
+
var runningVersion = () => true ? "0.1.113" : "development";
|
|
29522
29639
|
async function npmLatest(fetchFn = fetch, timeoutMs = 1e4) {
|
|
29523
29640
|
try {
|
|
29524
29641
|
const res = await fetchFn(`https://registry.npmjs.org/${PACKAGE}/latest`, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(timeoutMs) });
|
|
@@ -33491,6 +33608,7 @@ function startDeviceNode(opts) {
|
|
|
33491
33608
|
}
|
|
33492
33609
|
|
|
33493
33610
|
// ../agent-cli/src/commands/start.ts
|
|
33611
|
+
import { spawn as spawn15 } from "node:child_process";
|
|
33494
33612
|
import { randomBytes as randomBytes20 } from "node:crypto";
|
|
33495
33613
|
import { existsSync as existsSync33, readFileSync as readFileSync26, writeFileSync as writeFileSync27 } from "node:fs";
|
|
33496
33614
|
import { dirname as dirname12, join as join38, resolve as resolve8 } from "node:path";
|
|
@@ -33926,7 +34044,39 @@ function waitForSignal() {
|
|
|
33926
34044
|
process.once("SIGTERM", res);
|
|
33927
34045
|
});
|
|
33928
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
|
+
}
|
|
33929
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);
|
|
33930
34080
|
const f = await startFriend({ dataDir: io2.dataDir, out: io2.out });
|
|
33931
34081
|
await (io2.waitForExit ?? waitForSignal)();
|
|
33932
34082
|
io2.out("Stopping\u2026");
|
|
@@ -35336,7 +35486,7 @@ async function auditCommand(args, io2, deps = {}) {
|
|
|
35336
35486
|
}
|
|
35337
35487
|
|
|
35338
35488
|
// ../agent-cli/src/commands/daemon.ts
|
|
35339
|
-
import { spawn as
|
|
35489
|
+
import { spawn as spawn16, spawnSync as spawnSync3 } from "node:child_process";
|
|
35340
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";
|
|
35341
35491
|
import { connect as connect2 } from "node:net";
|
|
35342
35492
|
import { join as join43 } from "node:path";
|
|
@@ -35347,7 +35497,7 @@ var realDeps = {
|
|
|
35347
35497
|
launch(logFile) {
|
|
35348
35498
|
const fd = openSync2(logFile, "a");
|
|
35349
35499
|
try {
|
|
35350
|
-
const child =
|
|
35500
|
+
const child = spawn16(process.execPath, [process.argv[1], "start"], { detached: true, stdio: ["ignore", fd, fd], windowsHide: true, env: { ...process.env, FRIEND_DAEMON: "1" } });
|
|
35351
35501
|
child.unref();
|
|
35352
35502
|
return child.pid;
|
|
35353
35503
|
} finally {
|
|
@@ -35510,7 +35660,7 @@ import { appendFileSync } from "node:fs";
|
|
|
35510
35660
|
import { join as join44 } from "node:path";
|
|
35511
35661
|
var PACKAGE2 = "friend-assistant";
|
|
35512
35662
|
var real2 = {
|
|
35513
|
-
current: () => true ? "0.1.
|
|
35663
|
+
current: () => true ? "0.1.113" : "development",
|
|
35514
35664
|
latest: () => new Promise((resolve13) => {
|
|
35515
35665
|
const child = crossSpawn5("npm", ["view", PACKAGE2, "version", "--prefer-online"], { stdio: ["ignore", "pipe", "ignore"] });
|
|
35516
35666
|
let out = "";
|
|
@@ -35828,7 +35978,7 @@ async function run2(argv, io2) {
|
|
|
35828
35978
|
case "version":
|
|
35829
35979
|
case "--version":
|
|
35830
35980
|
case "-v":
|
|
35831
|
-
io2.out(true ? "0.1.
|
|
35981
|
+
io2.out(true ? "0.1.113" : "development");
|
|
35832
35982
|
return 0;
|
|
35833
35983
|
case "lan":
|
|
35834
35984
|
return await lanCommand(rest, io2);
|
package/dist/pc-agent/agent.js
CHANGED
|
@@ -30977,6 +30977,16 @@ async function takeLock(dir, log, waitMs = 8e3) {
|
|
|
30977
30977
|
});
|
|
30978
30978
|
return true;
|
|
30979
30979
|
}
|
|
30980
|
+
function launcherVbs(dir, nodeExe, agentFile) {
|
|
30981
|
+
const q = (s) => s.replace(/"/g, '""');
|
|
30982
|
+
return [
|
|
30983
|
+
'Set s = CreateObject("WScript.Shell")',
|
|
30984
|
+
`s.CurrentDirectory = "${q(dir)}"`,
|
|
30985
|
+
`rc = s.Run("""${q(nodeExe)}"" ""${q(agentFile)}""", 0, True)`,
|
|
30986
|
+
"WScript.Quit rc",
|
|
30987
|
+
""
|
|
30988
|
+
].join("\r\n");
|
|
30989
|
+
}
|
|
30980
30990
|
var POWERSHELL = ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command"];
|
|
30981
30991
|
function restartSoon(dir, log) {
|
|
30982
30992
|
if (process.platform !== "win32" || process.env.FRIEND_PC_NO_TASK) return;
|
|
@@ -30986,28 +30996,50 @@ function restartSoon(dir, log) {
|
|
|
30986
30996
|
log(`could not ask for a restart: ${e.message}`);
|
|
30987
30997
|
}
|
|
30988
30998
|
}
|
|
30989
|
-
async function ensureWatchdog(log) {
|
|
30999
|
+
async function ensureWatchdog(dir, nodeExe, agentFile, log) {
|
|
30990
31000
|
if (process.platform !== "win32" || process.env.FRIEND_PC_NO_TASK) return;
|
|
31001
|
+
const vbs = (0, import_node_path4.join)(dir, "run.vbs");
|
|
31002
|
+
try {
|
|
31003
|
+
(0, import_node_fs4.writeFileSync)(vbs, launcherVbs(dir, nodeExe, agentFile));
|
|
31004
|
+
} catch (e) {
|
|
31005
|
+
log(`could not write the launcher: ${e.message}`);
|
|
31006
|
+
return;
|
|
31007
|
+
}
|
|
31008
|
+
const q = (s) => `'${s.replace(/'/g, "''")}'`;
|
|
30991
31009
|
const script = `$ErrorActionPreference = 'Stop'
|
|
30992
31010
|
$task = '${TASK}'
|
|
31011
|
+
$vbs = ${q(vbs)}
|
|
31012
|
+
$dir = ${q(dir)}
|
|
30993
31013
|
$t = Get-ScheduledTask -TaskName $task -ErrorAction SilentlyContinue
|
|
30994
31014
|
if (-not $t) { Write-Output 'no task'; exit 0 }
|
|
30995
|
-
|
|
30996
|
-
$
|
|
30997
|
-
|
|
30998
|
-
|
|
30999
|
-
|
|
31015
|
+
$did = @()
|
|
31016
|
+
$exe = ''
|
|
31017
|
+
if ($t.Actions.Count -gt 0) { $exe = [string]$t.Actions[0].Execute }
|
|
31018
|
+
if ($exe -notmatch 'wscript') {
|
|
31019
|
+
$action = New-ScheduledTaskAction -Execute 'wscript.exe' -Argument ('//B //Nologo ' + [char]34 + $vbs + [char]34) -WorkingDirectory $dir
|
|
31020
|
+
Set-ScheduledTask -TaskName $task -Action $action | Out-Null
|
|
31021
|
+
$did += 'hidden'
|
|
31022
|
+
}
|
|
31023
|
+
$has = $false
|
|
31024
|
+
foreach ($x in $t.Triggers) { if ($x.Repetition -and $x.Repetition.Interval) { $has = $true } }
|
|
31025
|
+
if (-not $has) {
|
|
31026
|
+
$who = $env:USERDOMAIN + '\\' + $env:USERNAME
|
|
31027
|
+
$triggers = @((New-ScheduledTaskTrigger -AtLogOn -User $who), (New-ScheduledTaskTrigger -Once -At ((Get-Date).AddMinutes(2)) -RepetitionInterval (New-TimeSpan -Minutes 5) -RepetitionDuration (New-TimeSpan -Days 3650)))
|
|
31028
|
+
Set-ScheduledTask -TaskName $task -Trigger $triggers | Out-Null
|
|
31029
|
+
$did += 'watchdog'
|
|
31030
|
+
}
|
|
31031
|
+
Write-Output ('changed: ' + ($did -join ','))`;
|
|
31000
31032
|
await new Promise((resolve) => {
|
|
31001
31033
|
(0, import_node_child_process3.execFile)("powershell.exe", [...POWERSHELL, script], { windowsHide: true, timeout: 3e4 }, (e, out) => {
|
|
31002
31034
|
if (e) log(`could not check the restart task: ${e.message.split("\n")[0]}`);
|
|
31003
|
-
else if (/
|
|
31035
|
+
else if (/changed: \S/.test(out)) log(`the logon task was updated (${out.replace(/^[\s\S]*changed:\s*/, "").trim()}): it starts the agent without a window, and again every five minutes if it is not running`);
|
|
31004
31036
|
resolve();
|
|
31005
31037
|
});
|
|
31006
31038
|
});
|
|
31007
31039
|
}
|
|
31008
31040
|
|
|
31009
31041
|
// ../pc-agent/src/main.ts
|
|
31010
|
-
var VERSION = "0.1.
|
|
31042
|
+
var VERSION = "0.1.113";
|
|
31011
31043
|
var TASK2 = "Friend PC Agent";
|
|
31012
31044
|
function parse3(argv) {
|
|
31013
31045
|
const out = {};
|
|
@@ -31105,7 +31137,7 @@ Friend PC Agent
|
|
|
31105
31137
|
}
|
|
31106
31138
|
});
|
|
31107
31139
|
holder.agent = agent;
|
|
31108
|
-
void ensureWatchdog(log);
|
|
31140
|
+
void ensureWatchdog(dir, process.execPath, self, log);
|
|
31109
31141
|
const stop = () => void agent.stop().finally(() => process.exit(0));
|
|
31110
31142
|
process.on("SIGINT", stop);
|
|
31111
31143
|
process.on("SIGTERM", stop);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
2495b4715f314428bfbcaf7c208cd9d2b6a8729b5deaf68c22cfba2c560d1dc1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "friend-assistant",
|
|
3
|
-
"version": "0.1.
|
|
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",
|