friend-assistant 0.1.73 → 0.1.74
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 +22 -8
- package/dist/BUILD.json +2 -2
- package/dist/friend.mjs +327 -164
- package/dist/sandbox-child.mjs +318 -0
- package/dist/web/assets/{OrgParts-CKm9GiMe.js → OrgParts-Do6LghTp.js} +1 -1
- package/dist/web/assets/{index-Ds89qbOY.js → index-D-7sGBTA.js} +24 -24
- package/dist/web/assets/{jarvis-ui-P2GxXH_b.js → jarvis-ui-BAYSuxFl.js} +1 -1
- package/dist/web/assets/{jarvisTree-DL1hkJfL.js → jarvisTree-UR7AWNFs.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +4 -1
package/dist/friend.mjs
CHANGED
|
@@ -811,7 +811,7 @@ var TOOL_DEFS = [
|
|
|
811
811
|
},
|
|
812
812
|
{
|
|
813
813
|
name: "code.run",
|
|
814
|
-
description: "Run a program you wrote (python, node or shell)
|
|
814
|
+
description: "Run a program you wrote (python, node or shell) away from the owner's PC and get its output. It runs in a throwaway Docker container when Docker works, otherwise in the sandbox built into Friend (the result says which). Neither has a network or can see the owner's files, and the program is stopped after a time limit (default 10 s, at most 60 s). The built-in sandbox is smaller: python has the standard library only (no numpy or pandas), node is plain JavaScript (no require, no fetch; use readFile and console.log), and shell is an emulated bash with a fixed set of commands (no curl, git or compilers). Use it to calculate, process data you put in the code, test an idea or build a result. The owner approves every run. Print what you want to see to stdout.",
|
|
815
815
|
input: z5.object({
|
|
816
816
|
language: z5.enum(["python", "node", "shell"]),
|
|
817
817
|
code: z5.string().min(1).max(5e4),
|
|
@@ -4489,9 +4489,11 @@ ${r.text}` };
|
|
|
4489
4489
|
if (call.name === "code.run") {
|
|
4490
4490
|
const { language, code, timeoutSec } = args;
|
|
4491
4491
|
const r = await d.code.run({ language, code, timeoutSec });
|
|
4492
|
-
d.audit.log("agent", "tool.call", { tool: call.name, args: { language, chars: code.length }, tier, ok: r.ok });
|
|
4492
|
+
d.audit.log("agent", "tool.call", { tool: call.name, args: { language, chars: code.length }, tier, ok: r.ok, ...r.ok && r.runner ? { runner: r.runner } : {} });
|
|
4493
4493
|
if (!r.ok) return fail3(r.error);
|
|
4494
4494
|
const parts = [r.timedOut ? "Stopped: it ran past the time limit." : `exit code ${r.exitCode}`];
|
|
4495
|
+
if (r.fellBack) parts.push("(Docker was not available, so this ran in Friend's built-in sandbox, which is smaller: no real shell, and Python has the standard library only)");
|
|
4496
|
+
else if (r.runner === "sandbox") parts.push("(ran in Friend's built-in sandbox)");
|
|
4495
4497
|
if (r.stdout) parts.push(`--- stdout ---
|
|
4496
4498
|
${r.stdout}`);
|
|
4497
4499
|
if (r.stderr) parts.push(`--- stderr ---
|
|
@@ -5162,6 +5164,7 @@ function sanitizeChannels(raw) {
|
|
|
5162
5164
|
}
|
|
5163
5165
|
};
|
|
5164
5166
|
}
|
|
5167
|
+
var sanitizeCodeRunner = (v) => v === "sandbox" || v === "docker" ? v : "auto";
|
|
5165
5168
|
var DEFAULT_OPENAI = { url: "http://localhost:20128/v1", model: "auto", apiKey: null, vision: false };
|
|
5166
5169
|
var DEFAULT_CLAUDE_CODE = { model: "sonnet", command: "claude", fallback: "ollama", webSearch: true };
|
|
5167
5170
|
function sanitizeClaudeCode(raw) {
|
|
@@ -5350,6 +5353,7 @@ var defaults = (dataDir) => ({
|
|
|
5350
5353
|
look: { ...DEFAULT_LOOK },
|
|
5351
5354
|
ownerName: "",
|
|
5352
5355
|
approvals: "manual",
|
|
5356
|
+
codeRunner: "auto",
|
|
5353
5357
|
phoneApprovals: sanitizePhoneApprovals(void 0),
|
|
5354
5358
|
audit: sanitizeAudit(void 0),
|
|
5355
5359
|
channels: sanitizeChannels(DEFAULT_CHANNELS),
|
|
@@ -5428,6 +5432,7 @@ function loadConfig(dataDir = defaultDataDir()) {
|
|
|
5428
5432
|
look: sanitizeLook(stored.look),
|
|
5429
5433
|
ownerName: typeof stored.ownerName === "string" ? stored.ownerName.replace(/[\u0000-\u001f\u007f]/g, " ").trim().slice(0, 40) : "",
|
|
5430
5434
|
approvals: stored.approvals === "edits" || stored.approvals === "auto" ? stored.approvals : "manual",
|
|
5435
|
+
codeRunner: sanitizeCodeRunner(stored.codeRunner),
|
|
5431
5436
|
phoneApprovals: sanitizePhoneApprovals(stored.phoneApprovals),
|
|
5432
5437
|
audit: sanitizeAudit(stored.audit),
|
|
5433
5438
|
channels: sanitizeChannels(stored.channels),
|
|
@@ -13839,11 +13844,128 @@ ${url}`);
|
|
|
13839
13844
|
};
|
|
13840
13845
|
|
|
13841
13846
|
// ../server/src/codebox.ts
|
|
13842
|
-
import { spawn as
|
|
13847
|
+
import { spawn as spawn5 } from "node:child_process";
|
|
13843
13848
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
13844
13849
|
import { chmodSync as chmodSync7, mkdtempSync as mkdtempSync2, rmSync as rmSync9, writeFileSync as writeFileSync11 } from "node:fs";
|
|
13845
13850
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
13846
|
-
import { join as
|
|
13851
|
+
import { join as join19 } from "node:path";
|
|
13852
|
+
|
|
13853
|
+
// ../server/src/sandbox/index.ts
|
|
13854
|
+
import { spawn as spawn4 } from "node:child_process";
|
|
13855
|
+
import { existsSync as existsSync16, realpathSync } from "node:fs";
|
|
13856
|
+
import { createRequire } from "node:module";
|
|
13857
|
+
import { dirname as dirname5, join as join18, sep as sep3 } from "node:path";
|
|
13858
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
13859
|
+
|
|
13860
|
+
// ../server/src/sandbox/types.ts
|
|
13861
|
+
var SandboxUnavailable = class extends Error {
|
|
13862
|
+
};
|
|
13863
|
+
var MAX_SANDBOX_OUTPUT = 4e4;
|
|
13864
|
+
var SANDBOX_MEMORY_MB = 512;
|
|
13865
|
+
|
|
13866
|
+
// ../server/src/sandbox/index.ts
|
|
13867
|
+
var RESULT_MARK = "\n@@friend-sandbox-result@@";
|
|
13868
|
+
function childFile() {
|
|
13869
|
+
const here2 = dirname5(fileURLToPath2(import.meta.url));
|
|
13870
|
+
for (const f of [join18(here2, "sandbox-child.mjs"), join18(here2, "..", "..", ".sandbox-dev", "child.mjs")]) if (existsSync16(f)) return f;
|
|
13871
|
+
throw new SandboxUnavailable("The built-in sandbox program is missing. Run `pnpm build` (from the source) or reinstall Friend.");
|
|
13872
|
+
}
|
|
13873
|
+
function engineFolders(child) {
|
|
13874
|
+
const found = /* @__PURE__ */ new Set();
|
|
13875
|
+
for (let dir = dirname5(child); ; dir = dirname5(dir)) {
|
|
13876
|
+
if (existsSync16(join18(dir, "node_modules", "quickjs-emscripten"))) found.add(join18(dir, "node_modules"));
|
|
13877
|
+
if (dirname5(dir) === dir) break;
|
|
13878
|
+
}
|
|
13879
|
+
try {
|
|
13880
|
+
const real3 = realpathSync(createRequire(import.meta.url).resolve("quickjs-emscripten/package.json"));
|
|
13881
|
+
const at = real3.indexOf(`${sep3}node_modules${sep3}`);
|
|
13882
|
+
found.add(at >= 0 ? real3.slice(0, at + `${sep3}node_modules`.length) : dirname5(real3));
|
|
13883
|
+
} catch {
|
|
13884
|
+
}
|
|
13885
|
+
return [...found];
|
|
13886
|
+
}
|
|
13887
|
+
function neutralEnvironment() {
|
|
13888
|
+
if (process.platform !== "win32") return {};
|
|
13889
|
+
const root = process.env.SystemRoot ?? "C:Windows";
|
|
13890
|
+
return {
|
|
13891
|
+
SystemRoot: root,
|
|
13892
|
+
WINDIR: root,
|
|
13893
|
+
PATH: `${root}system32`,
|
|
13894
|
+
SYSTEMDRIVE: "C:",
|
|
13895
|
+
USERPROFILE: "C:sandbox",
|
|
13896
|
+
HOMEDRIVE: "C:",
|
|
13897
|
+
HOMEPATH: "sandbox",
|
|
13898
|
+
USERNAME: "sandbox",
|
|
13899
|
+
USERDOMAIN: "SANDBOX",
|
|
13900
|
+
LOGONSERVER: "\\SANDBOX",
|
|
13901
|
+
COMPUTERNAME: "SANDBOX",
|
|
13902
|
+
TEMP: "C:sandbox mp",
|
|
13903
|
+
TMP: "C:sandbox mp",
|
|
13904
|
+
APPDATA: "C:sandboxappdata",
|
|
13905
|
+
LOCALAPPDATA: "C:sandboxappdata"
|
|
13906
|
+
};
|
|
13907
|
+
}
|
|
13908
|
+
function permissionFlag() {
|
|
13909
|
+
const flags = process.allowedNodeEnvironmentFlags;
|
|
13910
|
+
if (flags.has("--permission")) return "--permission";
|
|
13911
|
+
if (flags.has("--experimental-permission")) return "--experimental-permission";
|
|
13912
|
+
throw new SandboxUnavailable("The built-in sandbox needs Node.js 20 or newer with its permission feature. Update Node.js, or use Docker.");
|
|
13913
|
+
}
|
|
13914
|
+
async function runInSandbox(input) {
|
|
13915
|
+
const child = childFile();
|
|
13916
|
+
const args = [
|
|
13917
|
+
permissionFlag(),
|
|
13918
|
+
`--allow-fs-read=${dirname5(child)}`,
|
|
13919
|
+
...engineFolders(child).map((f) => `--allow-fs-read=${f}`),
|
|
13920
|
+
`--max-old-space-size=${SANDBOX_MEMORY_MB}`,
|
|
13921
|
+
"--no-warnings",
|
|
13922
|
+
child
|
|
13923
|
+
];
|
|
13924
|
+
return new Promise((resolve13, reject) => {
|
|
13925
|
+
let done = false;
|
|
13926
|
+
let out = "";
|
|
13927
|
+
let err = "";
|
|
13928
|
+
let timedOut = false;
|
|
13929
|
+
const p = spawn4(process.execPath, args, { env: neutralEnvironment(), windowsHide: true, stdio: ["pipe", "pipe", "pipe"] });
|
|
13930
|
+
const finish2 = (r) => {
|
|
13931
|
+
if (done) return;
|
|
13932
|
+
done = true;
|
|
13933
|
+
clearTimeout(timer);
|
|
13934
|
+
p.kill("SIGKILL");
|
|
13935
|
+
if (r instanceof Error) reject(r);
|
|
13936
|
+
else resolve13(r);
|
|
13937
|
+
};
|
|
13938
|
+
const timer = setTimeout(() => {
|
|
13939
|
+
timedOut = true;
|
|
13940
|
+
finish2({ code: null, stdout: "", stderr: "", timedOut: true, outOfMemory: false });
|
|
13941
|
+
}, input.timeoutMs + 3e3);
|
|
13942
|
+
const cap = MAX_SANDBOX_OUTPUT * 4;
|
|
13943
|
+
p.stdout.on("data", (d) => void (out.length < cap && (out += d)));
|
|
13944
|
+
p.stderr.on("data", (d) => void (err.length < cap && (err += d)));
|
|
13945
|
+
p.on("error", (e) => finish2(new SandboxUnavailable(`The built-in sandbox could not start: ${e.message}`)));
|
|
13946
|
+
p.on("close", () => {
|
|
13947
|
+
if (timedOut) return;
|
|
13948
|
+
const at = out.lastIndexOf(RESULT_MARK);
|
|
13949
|
+
if (at < 0) {
|
|
13950
|
+
const oom = /heap out of memory|allocation failed|Reached heap limit/i.test(err);
|
|
13951
|
+
finish2({ code: null, stdout: "", stderr: oom ? "" : "The program ended unexpectedly.\n", timedOut: false, outOfMemory: oom });
|
|
13952
|
+
return;
|
|
13953
|
+
}
|
|
13954
|
+
try {
|
|
13955
|
+
const m = JSON.parse(out.slice(at + RESULT_MARK.length));
|
|
13956
|
+
if ("unavailable" in m) finish2(new SandboxUnavailable(m.unavailable));
|
|
13957
|
+
else finish2({ ...m, stdout: String(m.stdout).slice(0, MAX_SANDBOX_OUTPUT), stderr: String(m.stderr).slice(0, MAX_SANDBOX_OUTPUT) });
|
|
13958
|
+
} catch {
|
|
13959
|
+
finish2({ code: null, stdout: "", stderr: "The program ended unexpectedly.\n", timedOut: false, outOfMemory: false });
|
|
13960
|
+
}
|
|
13961
|
+
});
|
|
13962
|
+
p.stdin.on("error", () => {
|
|
13963
|
+
});
|
|
13964
|
+
p.stdin.end(JSON.stringify(input));
|
|
13965
|
+
});
|
|
13966
|
+
}
|
|
13967
|
+
|
|
13968
|
+
// ../server/src/codebox.ts
|
|
13847
13969
|
var MAX_CODE_CHARS = 5e4;
|
|
13848
13970
|
var MAX_OUTPUT_CHARS = 2e4;
|
|
13849
13971
|
var MAX_EXTRA_FILES = 10;
|
|
@@ -13857,7 +13979,7 @@ var SETUP = {
|
|
|
13857
13979
|
};
|
|
13858
13980
|
var spawnDocker = (args, { timeoutMs }) => new Promise((resolve13, reject) => {
|
|
13859
13981
|
const name = args[args.indexOf("--name") + 1];
|
|
13860
|
-
const child =
|
|
13982
|
+
const child = spawn5("docker", args, { windowsHide: true });
|
|
13861
13983
|
const cap = MAX_OUTPUT_CHARS * 2;
|
|
13862
13984
|
let stdout = "";
|
|
13863
13985
|
let stderr = "";
|
|
@@ -13866,7 +13988,7 @@ var spawnDocker = (args, { timeoutMs }) => new Promise((resolve13, reject) => {
|
|
|
13866
13988
|
child.stderr.on("data", (d) => void (stderr.length < cap && (stderr += d)));
|
|
13867
13989
|
const remove = () => new Promise((done) => {
|
|
13868
13990
|
if (!name) return done();
|
|
13869
|
-
const rm =
|
|
13991
|
+
const rm = spawn5("docker", ["rm", "-f", name], { windowsHide: true, stdio: "ignore" });
|
|
13870
13992
|
rm.on("error", () => done());
|
|
13871
13993
|
rm.on("close", () => done());
|
|
13872
13994
|
});
|
|
@@ -13887,11 +14009,15 @@ var spawnDocker = (args, { timeoutMs }) => new Promise((resolve13, reject) => {
|
|
|
13887
14009
|
});
|
|
13888
14010
|
var clip6 = (s) => s.length > MAX_OUTPUT_CHARS ? `${s.slice(0, MAX_OUTPUT_CHARS)}
|
|
13889
14011
|
[output cut]` : s;
|
|
14012
|
+
var DOCKER_RETRY_MS = 6e4;
|
|
13890
14013
|
var CodeBox = class {
|
|
13891
|
-
constructor(docker = spawnDocker) {
|
|
14014
|
+
constructor(docker = spawnDocker, opts = {}) {
|
|
13892
14015
|
this.docker = docker;
|
|
14016
|
+
this.opts = opts;
|
|
13893
14017
|
}
|
|
13894
14018
|
docker;
|
|
14019
|
+
opts;
|
|
14020
|
+
dockerDownUntil = 0;
|
|
13895
14021
|
async run(input) {
|
|
13896
14022
|
if (!input.code.trim()) return { ok: false, error: "There is no code to run." };
|
|
13897
14023
|
if (input.code.length > MAX_CODE_CHARS) return { ok: false, error: `The code is too long (the limit is ${MAX_CODE_CHARS} characters).` };
|
|
@@ -13901,17 +14027,45 @@ var CodeBox = class {
|
|
|
13901
14027
|
return { ok: false, error: "That file name is not allowed in the sandbox." };
|
|
13902
14028
|
}
|
|
13903
14029
|
if (extra.reduce((sum, [, body]) => sum + body.length, 0) > MAX_EXTRA_FILE_CHARS) return { ok: false, error: "The sandbox files are too large." };
|
|
13904
|
-
const setup = SETUP[input.language];
|
|
13905
14030
|
const timeoutMs = input.timeoutSec && input.timeoutSec > 0 ? Math.min(input.timeoutSec * 1e3, MAX_TIMEOUT_MS) : DEFAULT_TIMEOUT_MS;
|
|
13906
|
-
const
|
|
14031
|
+
const mode = this.opts.mode?.() ?? "docker";
|
|
14032
|
+
if (mode === "sandbox") return this.inSandbox(input, timeoutMs);
|
|
14033
|
+
const now = this.opts.now ?? Date.now;
|
|
14034
|
+
if (mode === "auto" && now() < this.dockerDownUntil) return this.fallBack(await this.inSandbox(input, timeoutMs));
|
|
14035
|
+
const viaDocker = await this.inDocker(input, timeoutMs);
|
|
14036
|
+
if (viaDocker.unavailable && mode === "auto") {
|
|
14037
|
+
this.dockerDownUntil = now() + DOCKER_RETRY_MS;
|
|
14038
|
+
return this.fallBack(await this.inSandbox(input, timeoutMs));
|
|
14039
|
+
}
|
|
14040
|
+
return viaDocker.result;
|
|
14041
|
+
}
|
|
14042
|
+
/** Marks a run that went to the built-in sandbox only because Docker would not run it, so the owner and the model are told. */
|
|
14043
|
+
fallBack(r) {
|
|
14044
|
+
return r.ok ? { ...r, fellBack: true } : r;
|
|
14045
|
+
}
|
|
14046
|
+
async inSandbox(input, timeoutMs) {
|
|
14047
|
+
try {
|
|
14048
|
+
const r = await (this.opts.sandbox ?? runInSandbox)({ language: input.language, code: input.code, files: input.files ?? {}, timeoutMs });
|
|
14049
|
+
const memory = "The program ran out of memory (limit 512 MB)." + String.fromCharCode(10);
|
|
14050
|
+
const stderr = r.outOfMemory ? (r.stderr && !r.stderr.endsWith(String.fromCharCode(10)) ? r.stderr + String.fromCharCode(10) : r.stderr) + memory : r.stderr;
|
|
14051
|
+
return { ok: true, runner: "sandbox", exitCode: r.code, stdout: clip6(r.stdout), stderr: clip6(stderr), timedOut: r.timedOut };
|
|
14052
|
+
} catch (e) {
|
|
14053
|
+
if (e instanceof SandboxUnavailable) return { ok: false, error: e.message };
|
|
14054
|
+
return { ok: false, error: "The built-in sandbox could not run this." };
|
|
14055
|
+
}
|
|
14056
|
+
}
|
|
14057
|
+
async inDocker(input, timeoutMs) {
|
|
14058
|
+
const extra = Object.entries(input.files ?? {});
|
|
14059
|
+
const setup = SETUP[input.language];
|
|
14060
|
+
const dir = mkdtempSync2(join19(tmpdir2(), "friend-code-"));
|
|
13907
14061
|
try {
|
|
13908
|
-
const file =
|
|
14062
|
+
const file = join19(dir, setup.file);
|
|
13909
14063
|
writeFileSync11(file, input.code);
|
|
13910
14064
|
chmodSync7(dir, 493);
|
|
13911
14065
|
chmodSync7(file, 420);
|
|
13912
14066
|
for (const [name, body] of extra) {
|
|
13913
|
-
writeFileSync11(
|
|
13914
|
-
chmodSync7(
|
|
14067
|
+
writeFileSync11(join19(dir, name), body);
|
|
14068
|
+
chmodSync7(join19(dir, name), 420);
|
|
13915
14069
|
}
|
|
13916
14070
|
const args = [
|
|
13917
14071
|
"run",
|
|
@@ -13950,15 +14104,15 @@ var CodeBox = class {
|
|
|
13950
14104
|
r = await this.docker(args, { timeoutMs });
|
|
13951
14105
|
} catch (e) {
|
|
13952
14106
|
if (e.code === "ENOENT") {
|
|
13953
|
-
return { ok: false, error: "Docker is not available. Install Docker Desktop and start it to run code safely." };
|
|
14107
|
+
return { result: { ok: false, error: "Docker is not available. Install Docker Desktop and start it to run code safely." }, unavailable: true };
|
|
13954
14108
|
}
|
|
13955
|
-
return { ok: false, error: "Docker could not be started." };
|
|
14109
|
+
return { result: { ok: false, error: "Docker could not be started." }, unavailable: true };
|
|
13956
14110
|
}
|
|
13957
14111
|
if (r.code === 125 && !r.timedOut) {
|
|
13958
|
-
if (/daemon|pipe|socket/i.test(r.stderr)) return { ok: false, error: "Docker is not running. Start Docker Desktop and try again." };
|
|
13959
|
-
return { ok: false, error: "Docker could not start the container. The first run of each language needs an internet connection to download its image." };
|
|
14112
|
+
if (/daemon|pipe|socket/i.test(r.stderr)) return { result: { ok: false, error: "Docker is not running. Start Docker Desktop and try again." }, unavailable: true };
|
|
14113
|
+
return { result: { ok: false, error: "Docker could not start the container. The first run of each language needs an internet connection to download its image." }, unavailable: true };
|
|
13960
14114
|
}
|
|
13961
|
-
return { ok: true, exitCode: r.code, stdout: clip6(r.stdout), stderr: clip6(r.stderr), timedOut: r.timedOut };
|
|
14115
|
+
return { result: { ok: true, runner: "docker", exitCode: r.code, stdout: clip6(r.stdout), stderr: clip6(r.stderr), timedOut: r.timedOut }, unavailable: false };
|
|
13962
14116
|
} finally {
|
|
13963
14117
|
rmSync9(dir, { recursive: true, force: true });
|
|
13964
14118
|
}
|
|
@@ -14055,13 +14209,13 @@ var Memory = class {
|
|
|
14055
14209
|
};
|
|
14056
14210
|
|
|
14057
14211
|
// ../server/src/memory/import.ts
|
|
14058
|
-
import { existsSync as
|
|
14059
|
-
import { join as
|
|
14212
|
+
import { existsSync as existsSync17, writeFileSync as writeFileSync12 } from "node:fs";
|
|
14213
|
+
import { join as join20 } from "node:path";
|
|
14060
14214
|
var MARKER = ".imported-notes";
|
|
14061
14215
|
function importFlatNotes(memory, tree2) {
|
|
14062
14216
|
tree2.ensure();
|
|
14063
|
-
const marker =
|
|
14064
|
-
if (
|
|
14217
|
+
const marker = join20(tree2.root, MARKER);
|
|
14218
|
+
if (existsSync17(marker)) return 0;
|
|
14065
14219
|
let n2 = 0;
|
|
14066
14220
|
for (const m of [...memory.list()].reverse()) {
|
|
14067
14221
|
const name = inboxName(m.text, (x) => tree2.has(`inbox/${x}.md`));
|
|
@@ -14073,8 +14227,8 @@ function importFlatNotes(memory, tree2) {
|
|
|
14073
14227
|
}
|
|
14074
14228
|
|
|
14075
14229
|
// ../server/src/memory/keeper.ts
|
|
14076
|
-
import { existsSync as
|
|
14077
|
-
import { join as
|
|
14230
|
+
import { existsSync as existsSync18, readFileSync as readFileSync11, writeFileSync as writeFileSync13 } from "node:fs";
|
|
14231
|
+
import { join as join21 } from "node:path";
|
|
14078
14232
|
import { z as z11 } from "zod";
|
|
14079
14233
|
var SYSTEM3 = `You keep the long-term memory of a personal assistant for its owner. You are given the memory index, a few existing notes that may be related, and the latest conversation between the owner and the assistant. Decide what, if anything, is worth keeping for months, and return it as JSON.
|
|
14080
14234
|
|
|
@@ -14142,11 +14296,11 @@ var MemoryKeeper = class {
|
|
|
14142
14296
|
this.d.after?.();
|
|
14143
14297
|
}
|
|
14144
14298
|
cursorPath() {
|
|
14145
|
-
return
|
|
14299
|
+
return join21(this.d.tree.root, CURSOR_FILE);
|
|
14146
14300
|
}
|
|
14147
14301
|
readCursor() {
|
|
14148
14302
|
try {
|
|
14149
|
-
if (!
|
|
14303
|
+
if (!existsSync18(this.cursorPath())) return -1;
|
|
14150
14304
|
const n2 = Number(JSON.parse(readFileSync11(this.cursorPath(), "utf8")).lastId);
|
|
14151
14305
|
return Number.isInteger(n2) && n2 >= 0 ? n2 : -1;
|
|
14152
14306
|
} catch {
|
|
@@ -14440,7 +14594,7 @@ ${n2.body.trim().slice(0, NOTE_CHARS)}`).join("\n")}`,
|
|
|
14440
14594
|
};
|
|
14441
14595
|
|
|
14442
14596
|
// ../server/src/proactive/beat.ts
|
|
14443
|
-
import { existsSync as
|
|
14597
|
+
import { existsSync as existsSync19, readFileSync as readFileSync12, writeFileSync as writeFileSync14 } from "node:fs";
|
|
14444
14598
|
var LEVEL2 = { off: 0, low: 1, medium: 2, high: 3 };
|
|
14445
14599
|
var MAX_SAY = 400;
|
|
14446
14600
|
var OVERDUE_AFTER_MS = 2 * 36e5;
|
|
@@ -14483,7 +14637,7 @@ var ProactiveBeat = class {
|
|
|
14483
14637
|
}
|
|
14484
14638
|
load(day2) {
|
|
14485
14639
|
try {
|
|
14486
|
-
if (
|
|
14640
|
+
if (existsSync19(this.d.statePath)) {
|
|
14487
14641
|
const s = JSON.parse(readFileSync12(this.d.statePath, "utf8"));
|
|
14488
14642
|
if (s.day === day2) return { day: day2, sent: s.sent ?? 0, lastAt: s.lastAt ?? 0, fired: s.fired ?? {}, said: s.said ?? [] };
|
|
14489
14643
|
const week = this.now() - 7 * 864e5;
|
|
@@ -14639,13 +14793,13 @@ ${recent}` : "",
|
|
|
14639
14793
|
};
|
|
14640
14794
|
|
|
14641
14795
|
// ../server/src/app.ts
|
|
14642
|
-
import { dirname as
|
|
14643
|
-
import { fileURLToPath as
|
|
14796
|
+
import { dirname as dirname8, extname as extname3, resolve as resolve5 } from "node:path";
|
|
14797
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
14644
14798
|
|
|
14645
14799
|
// ../server/src/office/office.ts
|
|
14646
14800
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
14647
14801
|
import { mkdirSync as mkdirSync12, statSync as statSync3, writeFileSync as writeFileSync15 } from "node:fs";
|
|
14648
|
-
import { join as
|
|
14802
|
+
import { join as join22 } from "node:path";
|
|
14649
14803
|
|
|
14650
14804
|
// ../server/src/provider/claude-code/bridge.ts
|
|
14651
14805
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
@@ -14882,15 +15036,15 @@ function decideAction(call, ctx) {
|
|
|
14882
15036
|
}
|
|
14883
15037
|
|
|
14884
15038
|
// ../server/src/office/runner.ts
|
|
14885
|
-
import
|
|
15039
|
+
import spawn7 from "cross-spawn";
|
|
14886
15040
|
|
|
14887
15041
|
// ../server/src/provider/claude-code/process.ts
|
|
14888
|
-
import
|
|
15042
|
+
import spawn6 from "cross-spawn";
|
|
14889
15043
|
var MAX_STDERR = 8 * 1024;
|
|
14890
15044
|
var ClaudeProc = class {
|
|
14891
15045
|
constructor(opts, emit) {
|
|
14892
15046
|
this.emit = emit;
|
|
14893
|
-
this.child =
|
|
15047
|
+
this.child = spawn6(opts.command, opts.args, { cwd: opts.cwd, env: opts.env, stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
|
|
14894
15048
|
this.exited = new Promise((resolve13) => {
|
|
14895
15049
|
let finished = false;
|
|
14896
15050
|
const finish2 = (code, notInstalled) => {
|
|
@@ -15004,7 +15158,7 @@ var WorkerProc = class {
|
|
|
15004
15158
|
const pid = this.proc.pid;
|
|
15005
15159
|
if (process.platform === "win32" && pid) {
|
|
15006
15160
|
try {
|
|
15007
|
-
|
|
15161
|
+
spawn7.sync("taskkill", ["/pid", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true, timeout: 5e3 });
|
|
15008
15162
|
} catch {
|
|
15009
15163
|
}
|
|
15010
15164
|
}
|
|
@@ -15303,9 +15457,9 @@ var Office = class {
|
|
|
15303
15457
|
const cfg = this.d.config();
|
|
15304
15458
|
await run2.bridge.start();
|
|
15305
15459
|
if (run2.concluded) return;
|
|
15306
|
-
const dir =
|
|
15460
|
+
const dir = join22(this.d.dataDir, "office");
|
|
15307
15461
|
mkdirSync12(dir, { recursive: true });
|
|
15308
|
-
const mcp =
|
|
15462
|
+
const mcp = join22(dir, `${worker.id}.mcp.json`);
|
|
15309
15463
|
writeFileSync15(mcp, JSON.stringify({ mcpServers: { office: { type: "http", url: run2.bridge.url, headers: { Authorization: `Bearer ${run2.bridge.token}` } } } }));
|
|
15310
15464
|
const args = buildWorkerArgs({
|
|
15311
15465
|
model: worker.model.trim() || cfg.claudeCode.model,
|
|
@@ -15695,12 +15849,12 @@ var OfficeStore = class {
|
|
|
15695
15849
|
};
|
|
15696
15850
|
|
|
15697
15851
|
// ../server/src/app.ts
|
|
15698
|
-
import { join as
|
|
15852
|
+
import { join as join27 } from "node:path";
|
|
15699
15853
|
|
|
15700
15854
|
// ../server/src/db.ts
|
|
15701
15855
|
import Database from "better-sqlite3";
|
|
15702
15856
|
import { mkdirSync as mkdirSync13 } from "node:fs";
|
|
15703
|
-
import { join as
|
|
15857
|
+
import { join as join23 } from "node:path";
|
|
15704
15858
|
|
|
15705
15859
|
// ../server/src/migrations.ts
|
|
15706
15860
|
var MIGRATIONS = [
|
|
@@ -15996,7 +16150,7 @@ create trigger audit_no_delete before delete on audit_log begin select raise(abo
|
|
|
15996
16150
|
// ../server/src/db.ts
|
|
15997
16151
|
function openDb(dataDir) {
|
|
15998
16152
|
mkdirSync13(dataDir, { recursive: true });
|
|
15999
|
-
const db = new Database(
|
|
16153
|
+
const db = new Database(join23(dataDir, "friend.db"));
|
|
16000
16154
|
db.pragma("journal_mode = WAL");
|
|
16001
16155
|
db.pragma("foreign_keys = ON");
|
|
16002
16156
|
db.exec("create table if not exists schema_version (id integer primary key, applied_at integer not null)");
|
|
@@ -16821,7 +16975,7 @@ function registerAuditRoutes(d) {
|
|
|
16821
16975
|
// ../server/src/gateway.ts
|
|
16822
16976
|
import fastifyStatic from "@fastify/static";
|
|
16823
16977
|
import Fastify from "fastify";
|
|
16824
|
-
import { createReadStream as createReadStream2, existsSync as
|
|
16978
|
+
import { createReadStream as createReadStream2, existsSync as existsSync20, promises as fsp2 } from "node:fs";
|
|
16825
16979
|
import { isIP as isIP3 } from "node:net";
|
|
16826
16980
|
import { Readable } from "node:stream";
|
|
16827
16981
|
import { WebSocket as WebSocket2, WebSocketServer } from "ws";
|
|
@@ -17954,7 +18108,7 @@ function createGateway(deps) {
|
|
|
17954
18108
|
deps.onLock?.();
|
|
17955
18109
|
return { ok: true };
|
|
17956
18110
|
});
|
|
17957
|
-
if (deps.webDir &&
|
|
18111
|
+
if (deps.webDir && existsSync20(deps.webDir)) {
|
|
17958
18112
|
app.register(fastifyStatic, { root: deps.webDir });
|
|
17959
18113
|
app.setNotFoundHandler((req, reply) => {
|
|
17960
18114
|
if (req.method === "GET" && !req.url.startsWith("/api")) return reply.sendFile("index.html");
|
|
@@ -18108,10 +18262,10 @@ Connection: close\r
|
|
|
18108
18262
|
}
|
|
18109
18263
|
|
|
18110
18264
|
// ../server/src/browser/hub.ts
|
|
18111
|
-
import { spawn as
|
|
18265
|
+
import { spawn as spawn8, spawnSync } from "node:child_process";
|
|
18112
18266
|
import { mkdirSync as mkdirSync14, mkdtempSync as mkdtempSync3, readdirSync as readdirSync6, readFileSync as readFileSync13, rmSync as rmSync10, statSync as statSync5 } from "node:fs";
|
|
18113
18267
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
18114
|
-
import { join as
|
|
18268
|
+
import { join as join24 } from "node:path";
|
|
18115
18269
|
|
|
18116
18270
|
// ../server/src/browser/cdp.ts
|
|
18117
18271
|
import { WebSocket as WebSocket3 } from "ws";
|
|
@@ -18181,11 +18335,11 @@ var Cdp = class _Cdp {
|
|
|
18181
18335
|
};
|
|
18182
18336
|
|
|
18183
18337
|
// ../server/src/browser/chrome.ts
|
|
18184
|
-
import { existsSync as
|
|
18338
|
+
import { existsSync as existsSync21, statSync as statSync4 } from "node:fs";
|
|
18185
18339
|
import { posix as posix3, win32 as win323 } from "node:path";
|
|
18186
18340
|
var fileThere = (p) => {
|
|
18187
18341
|
try {
|
|
18188
|
-
return
|
|
18342
|
+
return existsSync21(p) && statSync4(p).isFile();
|
|
18189
18343
|
} catch {
|
|
18190
18344
|
return false;
|
|
18191
18345
|
}
|
|
@@ -18196,15 +18350,15 @@ function findChrome(override = "", w = {}) {
|
|
|
18196
18350
|
const platform = w.platform ?? process.platform;
|
|
18197
18351
|
const env = w.env ?? process.env;
|
|
18198
18352
|
const isFile = w.isFile ?? fileThere;
|
|
18199
|
-
const
|
|
18353
|
+
const join37 = platform === "win32" ? win323.join : posix3.join;
|
|
18200
18354
|
if (override.trim()) return isFile(override.trim()) ? override.trim() : null;
|
|
18201
18355
|
if (platform === "win32") {
|
|
18202
18356
|
const roots = [env.PROGRAMFILES, env["PROGRAMFILES(X86)"], env.LOCALAPPDATA].filter((r) => !!r);
|
|
18203
|
-
for (const r of roots) for (const rel of ["Google/Chrome/Application/chrome.exe", "Chromium/Application/chrome.exe", "Microsoft/Edge/Application/msedge.exe"]) if (isFile(
|
|
18357
|
+
for (const r of roots) for (const rel of ["Google/Chrome/Application/chrome.exe", "Chromium/Application/chrome.exe", "Microsoft/Edge/Application/msedge.exe"]) if (isFile(join37(r, rel))) return join37(r, rel);
|
|
18204
18358
|
return null;
|
|
18205
18359
|
}
|
|
18206
18360
|
if (platform === "darwin") return MAC_PATHS.find(isFile) ?? null;
|
|
18207
|
-
for (const dir of (env.PATH ?? "").split(":").filter(Boolean)) for (const name of LINUX_NAMES) if (isFile(
|
|
18361
|
+
for (const dir of (env.PATH ?? "").split(":").filter(Boolean)) for (const name of LINUX_NAMES) if (isFile(join37(dir, name))) return join37(dir, name);
|
|
18208
18362
|
return null;
|
|
18209
18363
|
}
|
|
18210
18364
|
|
|
@@ -18231,7 +18385,7 @@ var BrowserHub = class {
|
|
|
18231
18385
|
try {
|
|
18232
18386
|
for (const name of readdirSync6(root)) {
|
|
18233
18387
|
if (!/^friend-browser-/.test(name)) continue;
|
|
18234
|
-
const dir =
|
|
18388
|
+
const dir = join24(root, name);
|
|
18235
18389
|
if (Date.now() - statSync5(dir).mtimeMs > 36e5) rmSync10(dir, { recursive: true, force: true });
|
|
18236
18390
|
}
|
|
18237
18391
|
} catch {
|
|
@@ -18296,8 +18450,8 @@ A picture of the page "${r.value.title || r.value.href}" (${r.value.href}). Text
|
|
|
18296
18450
|
try {
|
|
18297
18451
|
const root = this.o.tmpRoot ?? tmpdir3();
|
|
18298
18452
|
mkdirSync14(root, { recursive: true });
|
|
18299
|
-
profile = mkdtempSync3(
|
|
18300
|
-
child =
|
|
18453
|
+
profile = mkdtempSync3(join24(root, "friend-browser-"));
|
|
18454
|
+
child = spawn8(
|
|
18301
18455
|
chrome,
|
|
18302
18456
|
[
|
|
18303
18457
|
"--headless=new",
|
|
@@ -18410,7 +18564,7 @@ async function endpoint(profile, signal) {
|
|
|
18410
18564
|
for (; ; ) {
|
|
18411
18565
|
signal.throwIfAborted();
|
|
18412
18566
|
try {
|
|
18413
|
-
const [port, path3] = readFileSync13(
|
|
18567
|
+
const [port, path3] = readFileSync13(join24(profile, "DevToolsActivePort"), "utf8").split("\n");
|
|
18414
18568
|
if (port && path3) return `ws://127.0.0.1:${port.trim()}${path3.trim()}`;
|
|
18415
18569
|
} catch {
|
|
18416
18570
|
}
|
|
@@ -18652,8 +18806,8 @@ function startStatsFeed(opts) {
|
|
|
18652
18806
|
|
|
18653
18807
|
// ../server/src/provider/claude-code/provider.ts
|
|
18654
18808
|
import { createHash as createHash12 } from "node:crypto";
|
|
18655
|
-
import { chmodSync as chmodSync8, existsSync as
|
|
18656
|
-
import { join as
|
|
18809
|
+
import { chmodSync as chmodSync8, existsSync as existsSync22, mkdirSync as mkdirSync15, readdirSync as readdirSync7, readFileSync as readFileSync14, rmSync as rmSync11, writeFileSync as writeFileSync16 } from "node:fs";
|
|
18810
|
+
import { join as join25 } from "node:path";
|
|
18657
18811
|
|
|
18658
18812
|
// ../server/src/provider/claude-code/limits.ts
|
|
18659
18813
|
var LIMIT2 = /\b(?:hit|reached)\s+(?:your\s+|the\s+)?(?:[\w-]+\s+)?(?:usage\s+)?limit\b|\busage\s+limit\b|\b(?:\d+-hour|weekly|daily|monthly)\s+limit\s+reached\b|\bhit your (?:weekly|daily|monthly|usage|\d+-hour) limit\b/i;
|
|
@@ -18751,7 +18905,7 @@ var NOT_SIGNED_IN = /not logged in|please run \/login|invalid api key|authentica
|
|
|
18751
18905
|
var ClaudeCodeProvider = class {
|
|
18752
18906
|
constructor(opts) {
|
|
18753
18907
|
this.opts = opts;
|
|
18754
|
-
this.home =
|
|
18908
|
+
this.home = join25(opts.dataDir, "claude");
|
|
18755
18909
|
this.now = opts.now ?? Date.now;
|
|
18756
18910
|
this.bridge = new ToolBridge((call) => this.owner.inbox.push({ kind: "call", call }));
|
|
18757
18911
|
}
|
|
@@ -19007,7 +19161,7 @@ ${item.stderr}`;
|
|
|
19007
19161
|
"local",
|
|
19008
19162
|
"--system-prompt-file",
|
|
19009
19163
|
systemFile,
|
|
19010
|
-
...conv.guest ? ["--no-session-persistence"] : ["--mcp-config",
|
|
19164
|
+
...conv.guest ? ["--no-session-persistence"] : ["--mcp-config", join25(this.home, "mcp.json"), "--allowedTools", [...web ? ["WebSearch"] : [], ...req.tools.map((t) => `mcp__friend__${encodeToolName(t.name)}`)].join(","), ...resume ? ["--resume", resume] : []]
|
|
19011
19165
|
];
|
|
19012
19166
|
const proc = new ClaudeProc(
|
|
19013
19167
|
{
|
|
@@ -19036,11 +19190,11 @@ ${item.stderr}`;
|
|
|
19036
19190
|
if (!this.swept) {
|
|
19037
19191
|
this.swept = true;
|
|
19038
19192
|
try {
|
|
19039
|
-
for (const f of readdirSync7(this.home)) if (/^system-\d+\.txt$/.test(f)) rmSync11(
|
|
19193
|
+
for (const f of readdirSync7(this.home)) if (/^system-\d+\.txt$/.test(f)) rmSync11(join25(this.home, f), { force: true });
|
|
19040
19194
|
} catch {
|
|
19041
19195
|
}
|
|
19042
19196
|
}
|
|
19043
|
-
const file =
|
|
19197
|
+
const file = join25(this.home, `system-${++this.systemCount}.txt`);
|
|
19044
19198
|
writeFileSync16(file, text4);
|
|
19045
19199
|
try {
|
|
19046
19200
|
chmodSync8(file, 384);
|
|
@@ -19057,7 +19211,7 @@ ${item.stderr}`;
|
|
|
19057
19211
|
startBridge() {
|
|
19058
19212
|
this.bridgeReady ??= (async () => {
|
|
19059
19213
|
await this.bridge.start();
|
|
19060
|
-
const file =
|
|
19214
|
+
const file = join25(this.home, "mcp.json");
|
|
19061
19215
|
writeFileSync16(file, JSON.stringify({ mcpServers: { friend: { type: "http", url: this.bridge.url, headers: { Authorization: `Bearer ${this.bridge.token}` } } } }));
|
|
19062
19216
|
try {
|
|
19063
19217
|
chmodSync8(file, 384);
|
|
@@ -19067,10 +19221,10 @@ ${item.stderr}`;
|
|
|
19067
19221
|
return this.bridgeReady;
|
|
19068
19222
|
}
|
|
19069
19223
|
// ---- the session id, kept so a restart of Friend can pick the conversation up again ----
|
|
19070
|
-
sessionFile = () =>
|
|
19224
|
+
sessionFile = () => join25(this.home, "session-id");
|
|
19071
19225
|
readSession() {
|
|
19072
19226
|
try {
|
|
19073
|
-
return
|
|
19227
|
+
return existsSync22(this.sessionFile()) ? readFileSync14(this.sessionFile(), "utf8").trim() || null : null;
|
|
19074
19228
|
} catch {
|
|
19075
19229
|
return null;
|
|
19076
19230
|
}
|
|
@@ -19088,10 +19242,10 @@ ${item.stderr}`;
|
|
|
19088
19242
|
} catch {
|
|
19089
19243
|
}
|
|
19090
19244
|
}
|
|
19091
|
-
freshFile = () =>
|
|
19245
|
+
freshFile = () => join25(this.home, "fresh.json");
|
|
19092
19246
|
readFresh() {
|
|
19093
19247
|
try {
|
|
19094
|
-
if (!
|
|
19248
|
+
if (!existsSync22(this.freshFile())) return null;
|
|
19095
19249
|
const r = JSON.parse(readFileSync14(this.freshFile(), "utf8"));
|
|
19096
19250
|
return { seed: typeof r.seed === "string" && r.seed ? r.seed : null };
|
|
19097
19251
|
} catch {
|
|
@@ -19249,6 +19403,8 @@ var SettingsPatch = z15.object({
|
|
|
19249
19403
|
ownerName: z15.string().trim().max(40),
|
|
19250
19404
|
/** How much Friend asks before acting. Loosening it is a change that needs the PIN. */
|
|
19251
19405
|
approvals: z15.enum(["manual", "edits", "auto"]),
|
|
19406
|
+
/** Where the code the assistant writes runs. Changing it needs the PIN. */
|
|
19407
|
+
codeRunner: z15.enum(["auto", "sandbox", "docker"]),
|
|
19252
19408
|
/** The audit trail. Owner-only. */
|
|
19253
19409
|
audit: z15.object({
|
|
19254
19410
|
keepDays: z15.number().int().min(0).max(3650),
|
|
@@ -19449,6 +19605,7 @@ function settingsView(c) {
|
|
|
19449
19605
|
view: c.view,
|
|
19450
19606
|
ownerName: c.ownerName,
|
|
19451
19607
|
approvals: c.approvals,
|
|
19608
|
+
codeRunner: c.codeRunner,
|
|
19452
19609
|
phoneApprovals: { ...c.phoneApprovals },
|
|
19453
19610
|
audit: { ...c.audit },
|
|
19454
19611
|
channels: {
|
|
@@ -19682,6 +19839,7 @@ function applySettings(config, raw) {
|
|
|
19682
19839
|
if (launcher) config.hud.launcher = sanitizeHud({ launcher }).launcher;
|
|
19683
19840
|
}
|
|
19684
19841
|
if (p.approvals) config.approvals = p.approvals;
|
|
19842
|
+
if (p.codeRunner) config.codeRunner = p.codeRunner;
|
|
19685
19843
|
if (p.phoneApprovals) Object.assign(config.phoneApprovals, p.phoneApprovals);
|
|
19686
19844
|
if (p.audit) Object.assign(config.audit, p.audit);
|
|
19687
19845
|
if (p.channels) {
|
|
@@ -20104,10 +20262,10 @@ function dbWidgetStore(db) {
|
|
|
20104
20262
|
}
|
|
20105
20263
|
|
|
20106
20264
|
// ../server/src/tls.ts
|
|
20107
|
-
import { chmodSync as chmodSync9, existsSync as
|
|
20265
|
+
import { chmodSync as chmodSync9, existsSync as existsSync23, mkdirSync as mkdirSync16, readFileSync as readFileSync15, writeFileSync as writeFileSync17 } from "node:fs";
|
|
20108
20266
|
import { networkInterfaces } from "node:os";
|
|
20109
20267
|
import { isIP as isIP4 } from "node:net";
|
|
20110
|
-
import { join as
|
|
20268
|
+
import { join as join26 } from "node:path";
|
|
20111
20269
|
import { generate } from "selfsigned";
|
|
20112
20270
|
var DAYS = 825;
|
|
20113
20271
|
var RENEW_BEFORE_MS = 30 * 24 * 36e5;
|
|
@@ -20122,12 +20280,12 @@ function tlsHosts(extra = [], ifaces) {
|
|
|
20122
20280
|
return [.../* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", ...lanAddresses(ifaces), ...extra.map((h) => h.toLowerCase()).filter(Boolean)])];
|
|
20123
20281
|
}
|
|
20124
20282
|
async function ensureTlsCert(dataDir, extraHosts = [], ifaces, now = Date.now) {
|
|
20125
|
-
const dir =
|
|
20126
|
-
const keyFile =
|
|
20127
|
-
const certFile =
|
|
20128
|
-
const metaFile =
|
|
20283
|
+
const dir = join26(dataDir, "tls");
|
|
20284
|
+
const keyFile = join26(dir, "key.pem");
|
|
20285
|
+
const certFile = join26(dir, "cert.pem");
|
|
20286
|
+
const metaFile = join26(dir, "meta.json");
|
|
20129
20287
|
const hosts = tlsHosts(extraHosts, ifaces);
|
|
20130
|
-
if (
|
|
20288
|
+
if (existsSync23(keyFile) && existsSync23(certFile) && existsSync23(metaFile)) {
|
|
20131
20289
|
try {
|
|
20132
20290
|
const meta = JSON.parse(readFileSync15(metaFile, "utf8"));
|
|
20133
20291
|
const covered = hosts.every((h) => meta.hosts.includes(h));
|
|
@@ -20197,10 +20355,10 @@ var DuckController = class {
|
|
|
20197
20355
|
};
|
|
20198
20356
|
|
|
20199
20357
|
// ../server/src/system/autostart.ts
|
|
20200
|
-
import { spawn as
|
|
20201
|
-
import { existsSync as
|
|
20358
|
+
import { spawn as spawn9 } from "node:child_process";
|
|
20359
|
+
import { existsSync as existsSync24, mkdirSync as mkdirSync17, readFileSync as readFileSync16, rmSync as rmSync12, writeFileSync as writeFileSync18 } from "node:fs";
|
|
20202
20360
|
import { homedir as homedir4 } from "node:os";
|
|
20203
|
-
import { dirname as
|
|
20361
|
+
import { dirname as dirname6, posix as posix4, win32 as win324 } from "node:path";
|
|
20204
20362
|
var RUN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
|
20205
20363
|
var NAME2 = "Friend";
|
|
20206
20364
|
var LABEL = "com.friend.assistant";
|
|
@@ -20375,7 +20533,7 @@ function realAutostartDeps(dataDir) {
|
|
|
20375
20533
|
uid: typeof process.getuid === "function" ? process.getuid() : 0,
|
|
20376
20534
|
path: process.env.PATH ?? "",
|
|
20377
20535
|
...process.env.XDG_CONFIG_HOME ? { configHome: process.env.XDG_CONFIG_HOME } : {},
|
|
20378
|
-
exists: (p) =>
|
|
20536
|
+
exists: (p) => existsSync24(p),
|
|
20379
20537
|
read: (p) => {
|
|
20380
20538
|
try {
|
|
20381
20539
|
return readFileSync16(p, "utf8");
|
|
@@ -20384,13 +20542,13 @@ function realAutostartDeps(dataDir) {
|
|
|
20384
20542
|
}
|
|
20385
20543
|
},
|
|
20386
20544
|
write: (p, text4) => {
|
|
20387
|
-
mkdirSync17(
|
|
20545
|
+
mkdirSync17(dirname6(p), { recursive: true });
|
|
20388
20546
|
writeFileSync18(p, text4);
|
|
20389
20547
|
},
|
|
20390
20548
|
remove: (p) => rmSync12(p, { force: true }),
|
|
20391
20549
|
run: (cmd, args) => new Promise((resolve13) => {
|
|
20392
20550
|
let out = "";
|
|
20393
|
-
const child =
|
|
20551
|
+
const child = spawn9(cmd, args, { stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
|
|
20394
20552
|
child.stdout?.on("data", (d) => out += d.toString());
|
|
20395
20553
|
child.stderr?.on("data", (d) => out += d.toString());
|
|
20396
20554
|
child.on("error", () => resolve13({ code: 127, stdout: out }));
|
|
@@ -20404,9 +20562,9 @@ function currentSelf() {
|
|
|
20404
20562
|
}
|
|
20405
20563
|
|
|
20406
20564
|
// ../server/src/system/npm.ts
|
|
20407
|
-
import { spawn as
|
|
20565
|
+
import { spawn as spawn10 } from "node:child_process";
|
|
20408
20566
|
var PACKAGE = "friend-assistant";
|
|
20409
|
-
var runningVersion = () => true ? "0.1.
|
|
20567
|
+
var runningVersion = () => true ? "0.1.74" : "development";
|
|
20410
20568
|
async function npmLatest(fetchFn = fetch, timeoutMs = 1e4) {
|
|
20411
20569
|
try {
|
|
20412
20570
|
const res = await fetchFn(`https://registry.npmjs.org/${PACKAGE}/latest`, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(timeoutMs) });
|
|
@@ -20421,7 +20579,7 @@ var ps = (s) => `'${s.replace(/'/g, "''")}'`;
|
|
|
20421
20579
|
function spawnUpgrade(self, platform = process.platform) {
|
|
20422
20580
|
if (!self.node || !self.script) return false;
|
|
20423
20581
|
try {
|
|
20424
|
-
const child = platform === "win32" ?
|
|
20582
|
+
const child = platform === "win32" ? spawn10("powershell.exe", ["-NoProfile", "-NonInteractive", "-WindowStyle", "Hidden", "-Command", `Start-Process -WindowStyle Hidden -FilePath ${ps(self.node)} -ArgumentList ${ps(`"${self.script}"`)},'upgrade','--auto'`], { detached: true, stdio: "ignore", windowsHide: true }) : spawn10(self.node, [self.script, "upgrade", "--auto"], { detached: true, stdio: "ignore" });
|
|
20425
20583
|
child.on("error", () => {
|
|
20426
20584
|
});
|
|
20427
20585
|
child.unref();
|
|
@@ -20619,18 +20777,18 @@ var Challenges = class {
|
|
|
20619
20777
|
|
|
20620
20778
|
// ../server/src/voice/crypto.ts
|
|
20621
20779
|
import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, randomBytes as randomBytes13 } from "node:crypto";
|
|
20622
|
-
import { chmodSync as chmodSync10, existsSync as
|
|
20623
|
-
import { dirname as
|
|
20780
|
+
import { chmodSync as chmodSync10, existsSync as existsSync25, mkdirSync as mkdirSync18, readFileSync as readFileSync17, writeFileSync as writeFileSync19 } from "node:fs";
|
|
20781
|
+
import { dirname as dirname7 } from "node:path";
|
|
20624
20782
|
var KEY_BYTES = 32;
|
|
20625
20783
|
var IV_BYTES = 12;
|
|
20626
20784
|
var TAG_BYTES = 16;
|
|
20627
20785
|
function loadOrCreateKey(path3) {
|
|
20628
|
-
if (
|
|
20786
|
+
if (existsSync25(path3)) {
|
|
20629
20787
|
const key3 = readFileSync17(path3);
|
|
20630
20788
|
if (key3.length !== KEY_BYTES) throw new Error(`invalid voice key file (expected ${KEY_BYTES} bytes): ${path3}`);
|
|
20631
20789
|
return key3;
|
|
20632
20790
|
}
|
|
20633
|
-
mkdirSync18(
|
|
20791
|
+
mkdirSync18(dirname7(path3), { recursive: true });
|
|
20634
20792
|
const key2 = randomBytes13(KEY_BYTES);
|
|
20635
20793
|
writeFileSync19(path3, key2, { mode: 384 });
|
|
20636
20794
|
try {
|
|
@@ -21270,17 +21428,17 @@ async function createApp(opts) {
|
|
|
21270
21428
|
void musicLibrary.scan().catch(() => {
|
|
21271
21429
|
});
|
|
21272
21430
|
const memory = new Memory(db);
|
|
21273
|
-
const memoryTree = new MemoryTree(
|
|
21431
|
+
const memoryTree = new MemoryTree(join27(opts.dataDir, "memory"));
|
|
21274
21432
|
if (config.memory.enabled) {
|
|
21275
21433
|
memoryTree.ensure();
|
|
21276
21434
|
importFlatNotes(memory, memoryTree);
|
|
21277
21435
|
memoryTree.repair();
|
|
21278
21436
|
}
|
|
21279
|
-
const soul = new Soul(memoryTree,
|
|
21437
|
+
const soul = new Soul(memoryTree, join27(opts.dataDir, "soul-history"));
|
|
21280
21438
|
soul.ensure();
|
|
21281
|
-
const browserHub = new BrowserHub({ config: () => config.browser, tmpRoot:
|
|
21439
|
+
const browserHub = new BrowserHub({ config: () => config.browser, tmpRoot: join27(opts.dataDir, "browser-profiles") });
|
|
21282
21440
|
const tasks = new Tasks(db);
|
|
21283
|
-
const plugins = new Plugins(db,
|
|
21441
|
+
const plugins = new Plugins(db, join27(opts.dataDir, "plugins"));
|
|
21284
21442
|
const hub = new McpHub(new ConnectorStore(opts.dataDir));
|
|
21285
21443
|
let listenPort = config.port;
|
|
21286
21444
|
const provisioner = opts.video?.provisioner ?? new Provisioner({ dataDir: opts.dataDir, onError: (name, why) => audit.log("system", "video.provision_failed", { name, why: why.slice(0, 200) }) });
|
|
@@ -21392,13 +21550,13 @@ async function createApp(opts) {
|
|
|
21392
21550
|
if (id2 === "audius") return changeAudiusConfig((s) => changeAudius(s, change));
|
|
21393
21551
|
if (id2 === "browser") {
|
|
21394
21552
|
const err2 = changeBrowserConfig((b) => changeBrowser(b, change, !!browserHub.status().chrome));
|
|
21395
|
-
if (!err2 && "install" in change && listCatalog(catalogDir).some((c) => c.id === BROWSER_SKILL)) plugins.install(
|
|
21553
|
+
if (!err2 && "install" in change && listCatalog(catalogDir).some((c) => c.id === BROWSER_SKILL)) plugins.install(join27(catalogDir, BROWSER_SKILL));
|
|
21396
21554
|
if (!err2 && "remove" in change) plugins.remove(BROWSER_SKILL);
|
|
21397
21555
|
return err2;
|
|
21398
21556
|
}
|
|
21399
21557
|
if (id2 === "tavily") {
|
|
21400
21558
|
const err2 = changeTavilyConfig((t) => changeTavily(t, change, !!config.web.tavilyKey));
|
|
21401
|
-
if (!err2 && "install" in change && listCatalog(catalogDir).some((c) => c.id === TAVILY_SKILL)) plugins.install(
|
|
21559
|
+
if (!err2 && "install" in change && listCatalog(catalogDir).some((c) => c.id === TAVILY_SKILL)) plugins.install(join27(catalogDir, TAVILY_SKILL));
|
|
21402
21560
|
if (!err2 && "remove" in change) plugins.remove(TAVILY_SKILL);
|
|
21403
21561
|
return err2;
|
|
21404
21562
|
}
|
|
@@ -21429,7 +21587,7 @@ async function createApp(opts) {
|
|
|
21429
21587
|
}
|
|
21430
21588
|
if (id2 !== "zerodha") return changeChannels((c) => changeIntegration(c, id2, change));
|
|
21431
21589
|
const err = changeBrokers((b) => changeBroker(b, id2, change, (gone) => brokerHub.forget(gone)));
|
|
21432
|
-
if (!err && "install" in change && listCatalog(catalogDir).some((c) => c.id === PORTFOLIO_SKILL)) plugins.install(
|
|
21590
|
+
if (!err && "install" in change && listCatalog(catalogDir).some((c) => c.id === PORTFOLIO_SKILL)) plugins.install(join27(catalogDir, PORTFOLIO_SKILL));
|
|
21433
21591
|
if (!err && "remove" in change) plugins.remove(PORTFOLIO_SKILL);
|
|
21434
21592
|
return err;
|
|
21435
21593
|
};
|
|
@@ -21445,7 +21603,7 @@ async function createApp(opts) {
|
|
|
21445
21603
|
},
|
|
21446
21604
|
install: (id2) => {
|
|
21447
21605
|
if (!listCatalog(catalogDir).some((c) => c.id === id2)) return { ok: false, error: "That plugin is not in the catalog." };
|
|
21448
|
-
return plugins.install(
|
|
21606
|
+
return plugins.install(join27(catalogDir, id2));
|
|
21449
21607
|
}
|
|
21450
21608
|
},
|
|
21451
21609
|
integrations: {
|
|
@@ -21739,7 +21897,7 @@ First check the work: read the whole report (office.report) and, when it changed
|
|
|
21739
21897
|
tasks,
|
|
21740
21898
|
plugins,
|
|
21741
21899
|
weather: weatherService,
|
|
21742
|
-
code: opts.codeBox ?? new CodeBox(),
|
|
21900
|
+
code: opts.codeBox ?? new CodeBox(void 0, { mode: () => config.codeRunner }),
|
|
21743
21901
|
camera: {
|
|
21744
21902
|
request: (emit, signal) => {
|
|
21745
21903
|
audit.log("agent", "camera.requested", {});
|
|
@@ -21844,7 +22002,7 @@ First check the work: read the whole report (office.report) and, when it changed
|
|
|
21844
22002
|
const voice2 = opts.voice;
|
|
21845
22003
|
const speaker = voice2 ? new Speaker(voice2, audit, () => config.voice.ttsVoice, () => ({ hindi: config.voice.hindiVoice || void 0, marathi: config.voice.marathiVoice || void 0 })) : null;
|
|
21846
22004
|
const voiceAvailable = () => !!voice2 && voice2.available();
|
|
21847
|
-
const voiceKey = voice2 ? loadOrCreateKey(
|
|
22005
|
+
const voiceKey = voice2 ? loadOrCreateKey(join27(opts.dataDir, "voice.key")) : null;
|
|
21848
22006
|
const voiceprint = voiceKey ? new Voiceprint(db, voiceKey) : null;
|
|
21849
22007
|
const enrollment = voiceprint ? new Enrollment(voiceprint, SPEAKER_MODEL) : null;
|
|
21850
22008
|
const household = voiceKey ? new Household(db, voiceKey) : null;
|
|
@@ -21929,7 +22087,7 @@ ${task.title}`) !== null,
|
|
|
21929
22087
|
}
|
|
21930
22088
|
},
|
|
21931
22089
|
audit,
|
|
21932
|
-
statePath:
|
|
22090
|
+
statePath: join27(opts.dataDir, "proactive.json")
|
|
21933
22091
|
});
|
|
21934
22092
|
async function requirePin(pin, ip) {
|
|
21935
22093
|
let ok2 = false;
|
|
@@ -21999,7 +22157,7 @@ ${task.title}`) !== null,
|
|
|
21999
22157
|
broadcast({ type: "voice.heard", text: held.text, trust: "owner" });
|
|
22000
22158
|
await runVoiceTurn(held.text, conn.ip, epoch);
|
|
22001
22159
|
}
|
|
22002
|
-
const here2 =
|
|
22160
|
+
const here2 = dirname8(fileURLToPath3(import.meta.url));
|
|
22003
22161
|
const catalogDir = opts.pluginCatalogDir ?? firstExistingDir([process.env.FRIEND_PLUGIN_CATALOG, resolve5(here2, "plugins"), resolve5(here2, "../../..", "plugins")]) ?? resolve5(here2, "plugins");
|
|
22004
22162
|
const pluginsApi = {
|
|
22005
22163
|
list: () => {
|
|
@@ -22020,7 +22178,7 @@ ${task.title}`) !== null,
|
|
|
22020
22178
|
if (!isPluginId(id2)) throw new HttpError(400, "That is not a plugin name.");
|
|
22021
22179
|
if (!listCatalog(catalogDir).some((c) => c.id === id2)) throw new HttpError(404, "That plugin is not in the catalog.");
|
|
22022
22180
|
await requirePin(pin, ip);
|
|
22023
|
-
const r = plugins.install(
|
|
22181
|
+
const r = plugins.install(join27(catalogDir, id2));
|
|
22024
22182
|
if (!r.ok) throw new HttpError(400, `That plugin cannot be installed: ${r.error}`);
|
|
22025
22183
|
audit.log("owner", "plugin.installed", { id: r.id, upgraded: r.upgraded, ip });
|
|
22026
22184
|
return { id: r.id, upgraded: r.upgraded };
|
|
@@ -22830,7 +22988,7 @@ ${url}`);
|
|
|
22830
22988
|
}
|
|
22831
22989
|
const prune = () => {
|
|
22832
22990
|
try {
|
|
22833
|
-
const r = pruneAudit(db, { keepDays: config.audit.keepDays, archive: config.audit.archive, dir:
|
|
22991
|
+
const r = pruneAudit(db, { keepDays: config.audit.keepDays, archive: config.audit.archive, dir: join27(opts.dataDir, "audit-archive"), now: Date.now() });
|
|
22834
22992
|
if (r.removed) audit.log("system", "audit.pruned", { removed: r.removed, archive: r.archivePath });
|
|
22835
22993
|
} catch (e) {
|
|
22836
22994
|
audit.log("system", "audit.prune_failed", { message: e.message.slice(0, 200) });
|
|
@@ -22924,7 +23082,7 @@ ${url}`);
|
|
|
22924
23082
|
}
|
|
22925
23083
|
|
|
22926
23084
|
// ../server/src/voice/sidecar.ts
|
|
22927
|
-
import { spawn as
|
|
23085
|
+
import { spawn as spawn11 } from "node:child_process";
|
|
22928
23086
|
import { createInterface } from "node:readline";
|
|
22929
23087
|
var SidecarProcess = class {
|
|
22930
23088
|
constructor(opts) {
|
|
@@ -22961,7 +23119,7 @@ var SidecarProcess = class {
|
|
|
22961
23119
|
settled = true;
|
|
22962
23120
|
reject(new Error(message));
|
|
22963
23121
|
};
|
|
22964
|
-
const child =
|
|
23122
|
+
const child = spawn11(this.opts.command, this.opts.args, {
|
|
22965
23123
|
cwd: this.opts.cwd,
|
|
22966
23124
|
env: { ...this.opts.env ?? process.env, FRIEND_VOICE_TOKEN: this.opts.token },
|
|
22967
23125
|
windowsHide: true,
|
|
@@ -23093,6 +23251,10 @@ var PARSERS = {
|
|
|
23093
23251
|
if (v !== "manual" && v !== "edits" && v !== "auto") throw new Error("approvals must be manual, edits or auto");
|
|
23094
23252
|
return v;
|
|
23095
23253
|
},
|
|
23254
|
+
codeRunner: (v) => {
|
|
23255
|
+
if (v !== "auto" && v !== "sandbox" && v !== "docker") throw new Error("codeRunner must be auto, sandbox or docker");
|
|
23256
|
+
return v;
|
|
23257
|
+
},
|
|
23096
23258
|
https: bool,
|
|
23097
23259
|
port: (v) => {
|
|
23098
23260
|
const n2 = Number(v);
|
|
@@ -23244,6 +23406,7 @@ var KEY_HELP = {
|
|
|
23244
23406
|
port: "the web port (easier: friend lan port N)",
|
|
23245
23407
|
https: "true serves a secure https:// address (Friend makes its own certificate), so a phone may use the microphone (easier: friend lan https on)",
|
|
23246
23408
|
publicUrl: "the address people use when Friend is behind your own domain, or empty",
|
|
23409
|
+
codeRunner: "where code the assistant writes runs: auto (Docker if it works, otherwise the built-in sandbox), sandbox (always the built-in one, nothing to install) or docker (always Docker)",
|
|
23247
23410
|
approvals: "how much Friend asks before acting: manual (asks every time), edits (file work and sandboxed code go ahead) or auto (everything goes ahead except risky commands, the camera and changes to connectors/plugins). Easier: Esc \u2192 Settings \u2192 Approvals",
|
|
23248
23411
|
ownerName: "your name, shown on the profile badge (the shield) in the corner of the screen; empty shows Owner",
|
|
23249
23412
|
roots: "folders Friend may read and write freely, separated by commas",
|
|
@@ -23337,11 +23500,11 @@ import { WebSocket as WebSocket4 } from "ws";
|
|
|
23337
23500
|
|
|
23338
23501
|
// ../agent-cli/src/tools/fs.ts
|
|
23339
23502
|
import { closeSync, mkdirSync as mkdirSync19, openSync, readSync, readdirSync as readdirSync8, statSync as statSync7, writeFileSync as writeFileSync20 } from "node:fs";
|
|
23340
|
-
import { dirname as
|
|
23503
|
+
import { dirname as dirname10, join as join28 } from "node:path";
|
|
23341
23504
|
|
|
23342
23505
|
// ../agent-cli/src/tools/roots.ts
|
|
23343
|
-
import { lstatSync as lstatSync3, realpathSync } from "node:fs";
|
|
23344
|
-
import { dirname as
|
|
23506
|
+
import { lstatSync as lstatSync3, realpathSync as realpathSync2 } from "node:fs";
|
|
23507
|
+
import { dirname as dirname9, isAbsolute as isAbsolute2, relative as relative3, resolve as resolve6, sep as sep4 } from "node:path";
|
|
23345
23508
|
var isWin = process.platform === "win32";
|
|
23346
23509
|
var norm = (p) => isWin ? p.toLowerCase() : p;
|
|
23347
23510
|
var exists = (p) => {
|
|
@@ -23357,14 +23520,14 @@ function realish(abs) {
|
|
|
23357
23520
|
let cur = abs;
|
|
23358
23521
|
const tail2 = [];
|
|
23359
23522
|
while (!exists(cur)) {
|
|
23360
|
-
const parent =
|
|
23523
|
+
const parent = dirname9(cur);
|
|
23361
23524
|
if (parent === cur) return abs;
|
|
23362
23525
|
tail2.unshift(cur.slice(parent.length).replace(/^[\\/]+/, ""));
|
|
23363
23526
|
cur = parent;
|
|
23364
23527
|
}
|
|
23365
23528
|
let real3;
|
|
23366
23529
|
try {
|
|
23367
|
-
real3 =
|
|
23530
|
+
real3 = realpathSync2.native(cur);
|
|
23368
23531
|
} catch {
|
|
23369
23532
|
return UNRESOLVABLE + abs;
|
|
23370
23533
|
}
|
|
@@ -23373,7 +23536,7 @@ function realish(abs) {
|
|
|
23373
23536
|
function within2(root, target) {
|
|
23374
23537
|
if (target.startsWith(UNRESOLVABLE)) return false;
|
|
23375
23538
|
const rel = relative3(norm(root), norm(target));
|
|
23376
|
-
return rel === "" || !rel.startsWith("..") && !isAbsolute2(rel) && !rel.split(
|
|
23539
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute2(rel) && !rel.split(sep4).includes("..");
|
|
23377
23540
|
}
|
|
23378
23541
|
function resolveInRoots(p, roots) {
|
|
23379
23542
|
const base = roots[0] ?? process.cwd();
|
|
@@ -23399,7 +23562,7 @@ function fsList(args, ctx) {
|
|
|
23399
23562
|
if (e.isDirectory()) return `[dir] ${e.name}`;
|
|
23400
23563
|
let size = 0;
|
|
23401
23564
|
try {
|
|
23402
|
-
size = statSync7(
|
|
23565
|
+
size = statSync7(join28(g.abs, e.name)).size;
|
|
23403
23566
|
} catch {
|
|
23404
23567
|
}
|
|
23405
23568
|
return `[file] ${e.name} (${size} bytes)`;
|
|
@@ -23440,7 +23603,7 @@ function fsWrite(args, ctx) {
|
|
|
23440
23603
|
if ("error" in g) return { ok: false, error: g.error };
|
|
23441
23604
|
if (Buffer.byteLength(args.content) > MAX_WRITE) return { ok: false, error: "Content too large (5 MB limit)" };
|
|
23442
23605
|
try {
|
|
23443
|
-
mkdirSync19(
|
|
23606
|
+
mkdirSync19(dirname10(g.abs), { recursive: true });
|
|
23444
23607
|
writeFileSync20(g.abs, args.content);
|
|
23445
23608
|
return { ok: true, output: `Wrote ${Buffer.byteLength(args.content)} bytes to ${g.abs}`, truncated: false };
|
|
23446
23609
|
} catch (e) {
|
|
@@ -23449,7 +23612,7 @@ function fsWrite(args, ctx) {
|
|
|
23449
23612
|
}
|
|
23450
23613
|
|
|
23451
23614
|
// ../agent-cli/src/tools/shell.ts
|
|
23452
|
-
import { spawn as
|
|
23615
|
+
import { spawn as spawn12, spawnSync as spawnSync2 } from "node:child_process";
|
|
23453
23616
|
function killTree2(child) {
|
|
23454
23617
|
if (!child.pid) return;
|
|
23455
23618
|
if (process.platform === "win32") {
|
|
@@ -23475,7 +23638,7 @@ function runCommand2(command, cwdArg, ctx, argv) {
|
|
|
23475
23638
|
const file = argv?.file ?? (win ? "powershell.exe" : "sh");
|
|
23476
23639
|
const args = argv?.args ?? (win ? ["-NoProfile", "-NonInteractive", "-Command", command] : ["-c", command]);
|
|
23477
23640
|
return new Promise((resolve13) => {
|
|
23478
|
-
const child =
|
|
23641
|
+
const child = spawn12(file, args, { cwd, windowsHide: true, detached: !win, stdio: ["ignore", "pipe", "pipe"] });
|
|
23479
23642
|
let out = "";
|
|
23480
23643
|
let truncated = false;
|
|
23481
23644
|
let timedOut = false;
|
|
@@ -23677,9 +23840,9 @@ function startDeviceNode(opts) {
|
|
|
23677
23840
|
|
|
23678
23841
|
// ../agent-cli/src/commands/start.ts
|
|
23679
23842
|
import { randomBytes as randomBytes14 } from "node:crypto";
|
|
23680
|
-
import { existsSync as
|
|
23681
|
-
import { dirname as
|
|
23682
|
-
import { fileURLToPath as
|
|
23843
|
+
import { existsSync as existsSync27, readFileSync as readFileSync19, writeFileSync as writeFileSync22 } from "node:fs";
|
|
23844
|
+
import { dirname as dirname12, join as join30, resolve as resolve8 } from "node:path";
|
|
23845
|
+
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
23683
23846
|
|
|
23684
23847
|
// ../agent-cli/src/commands/lan.ts
|
|
23685
23848
|
import { networkInterfaces as networkInterfaces2 } from "node:os";
|
|
@@ -23783,19 +23946,19 @@ async function lanCommand(args, io2, ifaces = networkInterfaces2) {
|
|
|
23783
23946
|
}
|
|
23784
23947
|
|
|
23785
23948
|
// ../agent-cli/src/commands/voice.ts
|
|
23786
|
-
import { spawn as
|
|
23787
|
-
import { existsSync as
|
|
23788
|
-
import { dirname as
|
|
23789
|
-
import { fileURLToPath as
|
|
23949
|
+
import { spawn as spawn13 } from "node:child_process";
|
|
23950
|
+
import { existsSync as existsSync26, mkdirSync as mkdirSync20, readFileSync as readFileSync18, writeFileSync as writeFileSync21 } from "node:fs";
|
|
23951
|
+
import { dirname as dirname11, join as join29, resolve as resolve7 } from "node:path";
|
|
23952
|
+
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
23790
23953
|
function voicePaths(dataDir) {
|
|
23791
|
-
const home =
|
|
23792
|
-
const venv =
|
|
23954
|
+
const home = join29(dataDir, "voice");
|
|
23955
|
+
const venv = join29(home, "venv");
|
|
23793
23956
|
return {
|
|
23794
23957
|
home,
|
|
23795
23958
|
venv,
|
|
23796
|
-
python: process.platform === "win32" ?
|
|
23797
|
-
models:
|
|
23798
|
-
marker:
|
|
23959
|
+
python: process.platform === "win32" ? join29(venv, "Scripts", "python.exe") : join29(venv, "bin", "python"),
|
|
23960
|
+
models: join29(home, "models"),
|
|
23961
|
+
marker: join29(home, "installed.json")
|
|
23799
23962
|
};
|
|
23800
23963
|
}
|
|
23801
23964
|
function readMarker(dataDir) {
|
|
@@ -23806,13 +23969,13 @@ function readMarker(dataDir) {
|
|
|
23806
23969
|
}
|
|
23807
23970
|
}
|
|
23808
23971
|
function findVoiceDir() {
|
|
23809
|
-
const here2 =
|
|
23972
|
+
const here2 = dirname11(fileURLToPath4(import.meta.url));
|
|
23810
23973
|
return firstExistingDir([process.env.FRIEND_VOICE_DIR, resolve7(here2, "voice"), resolve7(here2, "../../../voice")], "friend_voice") ?? resolve7(here2, "voice");
|
|
23811
23974
|
}
|
|
23812
23975
|
var QUIET_ENV = { ...process.env, HF_HUB_DISABLE_SYMLINKS_WARNING: "1", PYTHONUTF8: "1" };
|
|
23813
23976
|
var defaultRunner = (cmd, args, opts) => new Promise((res) => {
|
|
23814
23977
|
let stdout = "";
|
|
23815
|
-
const child =
|
|
23978
|
+
const child = spawn13(cmd, args, { cwd: opts?.cwd, env: QUIET_ENV, windowsHide: true, stdio: ["ignore", "pipe", "pipe"] });
|
|
23816
23979
|
const feed = (d) => {
|
|
23817
23980
|
const s = d.toString();
|
|
23818
23981
|
stdout += s;
|
|
@@ -23898,7 +24061,7 @@ async function voiceSetupCommand(io2, deps = {}, args = []) {
|
|
|
23898
24061
|
return 1;
|
|
23899
24062
|
}
|
|
23900
24063
|
mkdirSync20(p.home, { recursive: true });
|
|
23901
|
-
if (!
|
|
24064
|
+
if (!existsSync26(p.python)) {
|
|
23902
24065
|
io2.out("1/3 Creating a private Python environment\u2026");
|
|
23903
24066
|
const r = await run2(py.cmd, [...py.args, "-m", "venv", p.venv], { onLine });
|
|
23904
24067
|
if (r.code !== 0) {
|
|
@@ -23948,7 +24111,7 @@ async function voiceStatusCommand(io2) {
|
|
|
23948
24111
|
io2.out("Voice engine: not installed. Run: friend voice setup");
|
|
23949
24112
|
return 0;
|
|
23950
24113
|
}
|
|
23951
|
-
if (!
|
|
24114
|
+
if (!existsSync26(marker.python)) {
|
|
23952
24115
|
io2.out("Voice engine: installed, but its Python is missing. Run: friend voice setup");
|
|
23953
24116
|
return 0;
|
|
23954
24117
|
}
|
|
@@ -24019,9 +24182,9 @@ async function voiceCommand(args, io2) {
|
|
|
24019
24182
|
|
|
24020
24183
|
// ../agent-cli/src/commands/start.ts
|
|
24021
24184
|
function findWebDir(explicit) {
|
|
24022
|
-
const here2 =
|
|
24185
|
+
const here2 = dirname12(fileURLToPath5(import.meta.url));
|
|
24023
24186
|
const candidates = [explicit, process.env.FRIEND_WEB_DIR, resolve8(here2, "../../../web/dist"), resolve8(here2, "web")];
|
|
24024
|
-
return candidates.find((c) => !!c &&
|
|
24187
|
+
return candidates.find((c) => !!c && existsSync27(join30(c, "index.html")));
|
|
24025
24188
|
}
|
|
24026
24189
|
async function startFriend(opts) {
|
|
24027
24190
|
const stored = loadConfig(opts.dataDir);
|
|
@@ -24057,8 +24220,8 @@ async function startFriend(opts) {
|
|
|
24057
24220
|
}
|
|
24058
24221
|
});
|
|
24059
24222
|
const { port } = await app.start();
|
|
24060
|
-
const tokenFile =
|
|
24061
|
-
let token =
|
|
24223
|
+
const tokenFile = join30(opts.dataDir, "local-device.token");
|
|
24224
|
+
let token = existsSync27(tokenFile) ? readFileSync19(tokenFile, "utf8").trim() : "";
|
|
24062
24225
|
if (!token || !app.auth.resolveDevice(token)) {
|
|
24063
24226
|
token = app.auth.redeemPairCode(app.auth.createPairCode(), "this-pc");
|
|
24064
24227
|
writeFileSync22(tokenFile, token, { mode: 384 });
|
|
@@ -24067,7 +24230,7 @@ async function startFriend(opts) {
|
|
|
24067
24230
|
url: `${app.config.https ? "wss" : "ws"}://127.0.0.1:${port}/device`,
|
|
24068
24231
|
token,
|
|
24069
24232
|
roots: app.config.roots,
|
|
24070
|
-
...app.config.https ? { ca: readFileSync19(
|
|
24233
|
+
...app.config.https ? { ca: readFileSync19(join30(opts.dataDir, "tls", "cert.pem"), "utf8") } : {}
|
|
24071
24234
|
// this PC trusts only its own Friend's certificate
|
|
24072
24235
|
});
|
|
24073
24236
|
const urls = urlsFor(app.config.bind, port, void 0, app.config.https);
|
|
@@ -24237,8 +24400,8 @@ async function devicesCommand(args, io2) {
|
|
|
24237
24400
|
}
|
|
24238
24401
|
|
|
24239
24402
|
// ../agent-cli/src/commands/memory.ts
|
|
24240
|
-
import { existsSync as
|
|
24241
|
-
import { join as
|
|
24403
|
+
import { existsSync as existsSync28 } from "node:fs";
|
|
24404
|
+
import { join as join31 } from "node:path";
|
|
24242
24405
|
var USAGE = "Usage: friend memory list | friend memory show <path> | friend memory forget <path or number> | friend memory clear";
|
|
24243
24406
|
async function memoryCommand(args, io2) {
|
|
24244
24407
|
const [sub, arg] = args;
|
|
@@ -24250,7 +24413,7 @@ async function memoryCommand(args, io2) {
|
|
|
24250
24413
|
try {
|
|
24251
24414
|
const memory = new Memory(db);
|
|
24252
24415
|
const audit = new Audit(db);
|
|
24253
|
-
const tree2 =
|
|
24416
|
+
const tree2 = existsSync28(join31(io2.dataDir, "memory", "INDEX.md")) ? new MemoryTree(join31(io2.dataDir, "memory")) : null;
|
|
24254
24417
|
if (sub === "show") {
|
|
24255
24418
|
if (!tree2 || !arg) {
|
|
24256
24419
|
io2.err(tree2 ? USAGE : "There is no memory tree yet.");
|
|
@@ -24329,12 +24492,12 @@ async function memoryCommand(args, io2) {
|
|
|
24329
24492
|
}
|
|
24330
24493
|
|
|
24331
24494
|
// ../agent-cli/src/commands/plugin.ts
|
|
24332
|
-
import { existsSync as
|
|
24333
|
-
import { dirname as
|
|
24334
|
-
import { fileURLToPath as
|
|
24495
|
+
import { existsSync as existsSync29, readdirSync as readdirSync9, statSync as statSync8 } from "node:fs";
|
|
24496
|
+
import { dirname as dirname13, join as join32, resolve as resolve10 } from "node:path";
|
|
24497
|
+
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
24335
24498
|
var USAGE2 = "Usage: friend plugin catalog | list | install <name|folder> [--yes] | enable <id> | disable <id> | remove <id>";
|
|
24336
24499
|
function defaultCatalog() {
|
|
24337
|
-
const here2 =
|
|
24500
|
+
const here2 = dirname13(fileURLToPath6(import.meta.url));
|
|
24338
24501
|
return firstExistingDir([process.env.FRIEND_PLUGIN_CATALOG, resolve10(here2, "plugins"), resolve10(here2, "../../../../plugins")]) ?? resolve10(here2, "plugins");
|
|
24339
24502
|
}
|
|
24340
24503
|
var count2 = (n2, word2) => `${n2} ${word2}${n2 === 1 ? "" : "s"}`;
|
|
@@ -24344,10 +24507,10 @@ async function pluginCommand(args, io2, deps = {}) {
|
|
|
24344
24507
|
const flags = rest.filter((a) => a.startsWith("--"));
|
|
24345
24508
|
const arg = rest.find((a) => !a.startsWith("--"));
|
|
24346
24509
|
if (sub === "catalog") {
|
|
24347
|
-
const dirs =
|
|
24510
|
+
const dirs = existsSync29(catalogDir) ? readdirSync9(catalogDir).filter((d) => statSync8(join32(catalogDir, d)).isDirectory()) : [];
|
|
24348
24511
|
if (dirs.length === 0) io2.out("The catalog is empty.");
|
|
24349
24512
|
for (const d of dirs.sort()) {
|
|
24350
|
-
const r = inspectPlugin(
|
|
24513
|
+
const r = inspectPlugin(join32(catalogDir, d));
|
|
24351
24514
|
if (!r.ok) {
|
|
24352
24515
|
io2.out(`${d} (invalid: ${r.error})`);
|
|
24353
24516
|
continue;
|
|
@@ -24363,7 +24526,7 @@ async function pluginCommand(args, io2, deps = {}) {
|
|
|
24363
24526
|
}
|
|
24364
24527
|
const db = openDb(io2.dataDir);
|
|
24365
24528
|
try {
|
|
24366
|
-
const plugins = new Plugins(db,
|
|
24529
|
+
const plugins = new Plugins(db, join32(io2.dataDir, "plugins"));
|
|
24367
24530
|
if (sub === "list") {
|
|
24368
24531
|
const all = plugins.list();
|
|
24369
24532
|
if (all.length === 0) io2.out("No plugins installed. See: friend plugin catalog");
|
|
@@ -24377,8 +24540,8 @@ async function pluginCommand(args, io2, deps = {}) {
|
|
|
24377
24540
|
io2.err(USAGE2);
|
|
24378
24541
|
return 1;
|
|
24379
24542
|
}
|
|
24380
|
-
const inCatalog = !/[\\/]/.test(arg) &&
|
|
24381
|
-
const source = inCatalog ?
|
|
24543
|
+
const inCatalog = !/[\\/]/.test(arg) && existsSync29(join32(catalogDir, arg));
|
|
24544
|
+
const source = inCatalog ? join32(catalogDir, arg) : existsSync29(resolve10(arg)) ? resolve10(arg) : null;
|
|
24382
24545
|
if (!source) {
|
|
24383
24546
|
io2.err(`"${arg}" is not in the catalog and there is no such folder. See: friend plugin catalog`);
|
|
24384
24547
|
return 1;
|
|
@@ -24395,7 +24558,7 @@ async function pluginCommand(args, io2, deps = {}) {
|
|
|
24395
24558
|
if (m.skills.length) io2.out(`Skills (${m.skills.length}): ${m.skills.map((s) => s.name).join(", ")}`);
|
|
24396
24559
|
if (m.tools.length) {
|
|
24397
24560
|
io2.out(`Tools (${m.tools.length}): ${m.tools.map((t) => t.name).join(", ")}`);
|
|
24398
|
-
io2.out(" Tools run in a Docker
|
|
24561
|
+
io2.out(" Tools run in a sandbox (Docker if you have it, otherwise the one built into Friend) with no network and no access to your files, and ask for your approval every time.");
|
|
24399
24562
|
}
|
|
24400
24563
|
io2.out(`Files: ${r.files}, ${Math.max(1, Math.round(r.bytes / 1024))} KB`);
|
|
24401
24564
|
if (!flags.includes("--yes")) {
|
|
@@ -24667,7 +24830,7 @@ async function checkPython(d) {
|
|
|
24667
24830
|
return { ...base, ok: true, detail: first2(v.stdout) || "Python 3.10 or newer" };
|
|
24668
24831
|
}
|
|
24669
24832
|
async function checkDocker(d) {
|
|
24670
|
-
const base = { id: "docker", label: "Docker", need: "optional", unlocks: "
|
|
24833
|
+
const base = { id: "docker", label: "Docker", need: "optional", unlocks: "a real container for scripts the built-in sandbox cannot run (the built-in sandbox needs nothing installed)" };
|
|
24671
24834
|
const v = await d.run("docker", ["--version"]);
|
|
24672
24835
|
if (v.code !== 0) return { ...base, ok: false, detail: "not installed" };
|
|
24673
24836
|
const info = await d.run("docker", ["info", "--format", "{{.ServerVersion}}"]);
|
|
@@ -24756,14 +24919,14 @@ function installPlan(id2, platform, have) {
|
|
|
24756
24919
|
}
|
|
24757
24920
|
|
|
24758
24921
|
// ../agent-cli/src/commands/onboard/state.ts
|
|
24759
|
-
import { existsSync as
|
|
24760
|
-
import { dirname as
|
|
24922
|
+
import { existsSync as existsSync30, mkdirSync as mkdirSync21, readFileSync as readFileSync20, renameSync as renameSync5, rmSync as rmSync13, writeFileSync as writeFileSync23 } from "node:fs";
|
|
24923
|
+
import { dirname as dirname14, join as join33 } from "node:path";
|
|
24761
24924
|
var FEATURES = ["claude-code", "claude-api", "ollama", "voice", "sandbox"];
|
|
24762
24925
|
var emptyState = () => ({ version: 1, done: {}, features: [], restart: [] });
|
|
24763
|
-
var statePath = (dataDir) =>
|
|
24926
|
+
var statePath = (dataDir) => join33(dataDir, "onboarding.json");
|
|
24764
24927
|
function loadState(dataDir) {
|
|
24765
24928
|
const f = statePath(dataDir);
|
|
24766
|
-
if (!
|
|
24929
|
+
if (!existsSync30(f)) return emptyState();
|
|
24767
24930
|
try {
|
|
24768
24931
|
const raw = JSON.parse(readFileSync20(f, "utf8"));
|
|
24769
24932
|
const done = raw.done && typeof raw.done === "object" ? Object.fromEntries(Object.entries(raw.done).filter(([, v]) => typeof v === "string")) : {};
|
|
@@ -24776,7 +24939,7 @@ function loadState(dataDir) {
|
|
|
24776
24939
|
}
|
|
24777
24940
|
function saveState(dataDir, state) {
|
|
24778
24941
|
const f = statePath(dataDir);
|
|
24779
|
-
mkdirSync21(
|
|
24942
|
+
mkdirSync21(dirname14(f), { recursive: true });
|
|
24780
24943
|
const tmp = `${f}.tmp`;
|
|
24781
24944
|
writeFileSync23(tmp, JSON.stringify(state, null, 2));
|
|
24782
24945
|
renameSync5(tmp, f);
|
|
@@ -24876,7 +25039,7 @@ function defaultOnboardDeps() {
|
|
|
24876
25039
|
ollamaSetup: (io2, args) => ollamaCommand(args, io2, { run: capture })
|
|
24877
25040
|
};
|
|
24878
25041
|
}
|
|
24879
|
-
var FEATURE_PREREQ = { "claude-code": "claude", ollama: "ollama", voice: "python"
|
|
25042
|
+
var FEATURE_PREREQ = { "claude-code": "claude", ollama: "ollama", voice: "python" };
|
|
24880
25043
|
var has = (c, f) => c.state.features.includes(f);
|
|
24881
25044
|
var save = (c) => saveState(c.io.dataDir, c.state);
|
|
24882
25045
|
async function welcome(c) {
|
|
@@ -24903,7 +25066,7 @@ async function features(c) {
|
|
|
24903
25066
|
{ key: "claude-api", label: "Claude, with an API key", hint: "pay per use" },
|
|
24904
25067
|
{ key: "ollama", label: "A model on this PC with Ollama", hint: "free and private, but slower" },
|
|
24905
25068
|
{ key: "voice", label: "Voice: talk to Friend and hear it", hint: "needs Python, about 250 MB" },
|
|
24906
|
-
{ key: "sandbox", label: "Safe code running and plugin tools", hint: "
|
|
25069
|
+
{ key: "sandbox", label: "Safe code running and plugin tools", hint: "built in, nothing to install (Docker is optional)" }
|
|
24907
25070
|
],
|
|
24908
25071
|
["claude-code", "voice"]
|
|
24909
25072
|
);
|
|
@@ -25389,7 +25552,7 @@ async function usageCommand(args, io2, log) {
|
|
|
25389
25552
|
|
|
25390
25553
|
// ../agent-cli/src/commands/audit.ts
|
|
25391
25554
|
import { writeFileSync as writeFileSync24 } from "node:fs";
|
|
25392
|
-
import { join as
|
|
25555
|
+
import { join as join34 } from "node:path";
|
|
25393
25556
|
var USAGE5 = [
|
|
25394
25557
|
"Usage: friend audit list [--since 2h|1d|7d] [--who owner|assistant|worker|system|outsider|<worker name>] [--group approvals|tools|workers|logins|messages|settings|system] [--result refused|failed|done] [--q text] [--limit N]",
|
|
25395
25558
|
" friend audit show <request-id>",
|
|
@@ -25494,7 +25657,7 @@ async function auditCommand(args, io2, deps = {}) {
|
|
|
25494
25657
|
afterwards = async (res2) => {
|
|
25495
25658
|
const raw = /filename="([^"]+)"/.exec(res2.headers.get("content-disposition") ?? "")?.[1] ?? `friend-audit.${f.query.format}`;
|
|
25496
25659
|
const name = (raw.split(/[\\/]/).pop() ?? "friend-audit").replace(/[^A-Za-z0-9._-]/g, "_") || "friend-audit";
|
|
25497
|
-
(deps.write ?? ((n2, b) => writeFileSync24(
|
|
25660
|
+
(deps.write ?? ((n2, b) => writeFileSync24(join34(process.cwd(), n2), b)))(name, await res2.text());
|
|
25498
25661
|
io2.out(`Saved ${name} in this folder. It contains private content: keep it safe.`);
|
|
25499
25662
|
return 0;
|
|
25500
25663
|
};
|
|
@@ -25521,10 +25684,10 @@ async function auditCommand(args, io2, deps = {}) {
|
|
|
25521
25684
|
}
|
|
25522
25685
|
|
|
25523
25686
|
// ../agent-cli/src/commands/daemon.ts
|
|
25524
|
-
import { spawn as
|
|
25525
|
-
import { closeSync as closeSync2, existsSync as
|
|
25687
|
+
import { spawn as spawn14, spawnSync as spawnSync3 } from "node:child_process";
|
|
25688
|
+
import { closeSync as closeSync2, existsSync as existsSync31, mkdirSync as mkdirSync23, openSync as openSync2, readFileSync as readFileSync21, renameSync as renameSync6, rmSync as rmSync14, statSync as statSync9, writeFileSync as writeFileSync25 } from "node:fs";
|
|
25526
25689
|
import { connect } from "node:net";
|
|
25527
|
-
import { join as
|
|
25690
|
+
import { join as join35 } from "node:path";
|
|
25528
25691
|
var USAGE6 = "Usage: friend daemon start | stop | restart | status";
|
|
25529
25692
|
var MAX_LOG_BYTES = 5 * 1024 * 1024;
|
|
25530
25693
|
var sleep2 = (ms2) => new Promise((r) => setTimeout(r, ms2));
|
|
@@ -25532,7 +25695,7 @@ var realDeps = {
|
|
|
25532
25695
|
launch(logFile) {
|
|
25533
25696
|
const fd = openSync2(logFile, "a");
|
|
25534
25697
|
try {
|
|
25535
|
-
const child =
|
|
25698
|
+
const child = spawn14(process.execPath, [process.argv[1], "start"], { detached: true, stdio: ["ignore", fd, fd], windowsHide: true, env: { ...process.env, FRIEND_DAEMON: "1" } });
|
|
25536
25699
|
child.unref();
|
|
25537
25700
|
return child.pid;
|
|
25538
25701
|
} finally {
|
|
@@ -25580,8 +25743,8 @@ var realDeps = {
|
|
|
25580
25743
|
},
|
|
25581
25744
|
now: Date.now
|
|
25582
25745
|
};
|
|
25583
|
-
var pidFile = (dataDir) =>
|
|
25584
|
-
var logFileOf = (dataDir) =>
|
|
25746
|
+
var pidFile = (dataDir) => join35(dataDir, "friend.pid");
|
|
25747
|
+
var logFileOf = (dataDir) => join35(dataDir, "friend.log");
|
|
25585
25748
|
function readPid(dataDir) {
|
|
25586
25749
|
try {
|
|
25587
25750
|
const r = JSON.parse(readFileSync21(pidFile(dataDir), "utf8"));
|
|
@@ -25618,7 +25781,7 @@ async function start(io2, deps) {
|
|
|
25618
25781
|
mkdirSync23(io2.dataDir, { recursive: true });
|
|
25619
25782
|
const log = logFileOf(io2.dataDir);
|
|
25620
25783
|
try {
|
|
25621
|
-
if (
|
|
25784
|
+
if (existsSync31(log) && statSync9(log).size > MAX_LOG_BYTES) renameSync6(log, `${log}.old`);
|
|
25622
25785
|
} catch {
|
|
25623
25786
|
}
|
|
25624
25787
|
const pid = deps.launch(log);
|
|
@@ -25692,10 +25855,10 @@ async function daemonCommand(args, io2, deps = realDeps) {
|
|
|
25692
25855
|
// ../agent-cli/src/commands/upgrade.ts
|
|
25693
25856
|
import crossSpawn5 from "cross-spawn";
|
|
25694
25857
|
import { appendFileSync } from "node:fs";
|
|
25695
|
-
import { join as
|
|
25858
|
+
import { join as join36 } from "node:path";
|
|
25696
25859
|
var PACKAGE2 = "friend-assistant";
|
|
25697
25860
|
var real2 = {
|
|
25698
|
-
current: () => true ? "0.1.
|
|
25861
|
+
current: () => true ? "0.1.74" : "development",
|
|
25699
25862
|
latest: () => new Promise((resolve13) => {
|
|
25700
25863
|
const child = crossSpawn5("npm", ["view", PACKAGE2, "version", "--prefer-online"], { stdio: ["ignore", "pipe", "ignore"] });
|
|
25701
25864
|
let out = "";
|
|
@@ -25733,7 +25896,7 @@ async function upgradeCommand(args, io0, deps = real2) {
|
|
|
25733
25896
|
io0.err("Usage: friend upgrade [--force] [--auto]");
|
|
25734
25897
|
return 1;
|
|
25735
25898
|
}
|
|
25736
|
-
const log = deps.log ?? ((line2) => appendFileSync(
|
|
25899
|
+
const log = deps.log ?? ((line2) => appendFileSync(join36(io0.dataDir, "update.log"), `${(/* @__PURE__ */ new Date()).toISOString()} ${line2}
|
|
25737
25900
|
`));
|
|
25738
25901
|
const io2 = auto ? {
|
|
25739
25902
|
...io0,
|
|
@@ -26013,7 +26176,7 @@ async function run(argv, io2) {
|
|
|
26013
26176
|
case "version":
|
|
26014
26177
|
case "--version":
|
|
26015
26178
|
case "-v":
|
|
26016
|
-
io2.out(true ? "0.1.
|
|
26179
|
+
io2.out(true ? "0.1.74" : "development");
|
|
26017
26180
|
return 0;
|
|
26018
26181
|
case "lan":
|
|
26019
26182
|
return await lanCommand(rest, io2);
|