Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions LifeOS/install/LIFEOS/PULSE/manage-deriver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ fi

OS=$(uname -s)

# Linux/systemd analog is intentionally not implemented — the deriver is a
# nice-to-have on Linux and can be wired by hand via systemd timers if
# needed. Pulse menu bar is already macOS-only; same scope.
# Linux: the same nightly job runs as a systemd --user timer via
# LIFEOS/TOOLS/InstallDeriverSystemd.ts (daily 03:00). macOS keeps launchd below.
if [ "$OS" != "Darwin" ]; then
case "${1:-}" in
install|uninstall|status)
exec "$BUN_PATH" "$HOME/.claude/LIFEOS/TOOLS/InstallDeriverSystemd.ts" "$1" ;;
esac
fi

case "${1:-}" in
install)
Expand Down
40 changes: 40 additions & 0 deletions LifeOS/install/LIFEOS/TOOLS/InstallDeriverSystemd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bun
/**
* InstallDeriverSystemd.ts — Linux (systemd --user) install for the nightly Pulse deriver.
*
* Same job as com.lifeos.deriver.plist (macOS): daily 03:00,
* bun run LIFEOS/TOOLS/LearningPatternSynthesis.ts --hypothesize
* manage-deriver.sh delegates here on non-Darwin hosts.
*
* bun InstallDeriverSystemd.ts # install (also: install)
* bun InstallDeriverSystemd.ts uninstall # remove
* bun InstallDeriverSystemd.ts status # check
*/

import { getClaudeDir, lifeosPath } from "./Paths";
import * as systemd from "./lib/SystemdUser";

const LABEL = "com.lifeos.deriver";
const log = (m: string) => console.log(`[InstallDeriverSystemd] ${m}`);

async function main(): Promise<void> {
const verb = (process.argv[2] ?? "install").replace(/^--/, "");
const bunPath = await systemd.which("bun");
if (!bunPath) throw new Error("bun not found in PATH - install bun first");

const spec: systemd.UnitSpec = {
label: LABEL,
description: "LifeOS proactive deriver (nightly hypotheses)",
exec: [bunPath, "run", lifeosPath("TOOLS", "LearningPatternSynthesis.ts"), "--hypothesize"],
logPath: lifeosPath("MEMORY", "OBSERVABILITY", "deriver.log"),
workingDirectory: getClaudeDir(),
schedule: { kind: "calendar", hour: 3, minute: 0 },
};

if (verb === "uninstall") { await systemd.uninstall(spec, log); return; }
if (verb === "status") { if (!(await systemd.status(spec, log))) process.exit(1); return; }
if (verb !== "install") throw new Error(`unknown verb: ${verb}`);
if (!(await systemd.install(spec, log))) process.exit(1);
}

main().catch((err) => { console.error(`[InstallDeriverSystemd] Fatal: ${err}`); process.exit(1); });
30 changes: 29 additions & 1 deletion LifeOS/install/LIFEOS/TOOLS/InstallModelSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
import { homedir } from "node:os";
import { dirname, join } from "node:path";
import { lifeosPath } from "./Paths"; // public issue #1974 @sabo961, PR #1918 @PigLardLord
import { getClaudeDir, lifeosPath } from "./Paths"; // public issue #1974 @sabo961, PR #1918 @PigLardLord
import { installVerb } from "./lib/InstallVerb";
import * as systemd from "./lib/SystemdUser";

const HOME = homedir();
const LABEL = "com.lifeos.modelsync";
Expand All @@ -28,7 +29,34 @@ async function sh(cmd: string[]): Promise<{ exit: number; out: string }> {
const uid = (await sh(["id", "-u"])).out.trim();
const domain = `gui/${uid}`;

/* ── systemd --user backend (Linux only) ────────────────────────────────────
* Same shape as InstallHealthSync's Linux branch. On darwin nothing here runs.
* Schedule matches the launchd plist: daily 05:10.
* ------------------------------------------------------------------------- */
async function linuxMain(arg: string | undefined): Promise<void> {
const log = (m: string) => console.log(`[InstallModelSync] ${m}`);
const bunPath = await systemd.which("bun");
if (!bunPath) throw new Error("bun not found in PATH - install bun first");
const spec: systemd.UnitSpec = {
label: LABEL,
description: "LifeOS model sync (lineup + prices)",
exec: [bunPath, lifeosPath("TOOLS", "ModelSync.ts"), "--daily"],
logPath: lifeosPath("MEMORY", "OBSERVABILITY", "model-sync-launchd.log"),
workingDirectory: getClaudeDir(),
schedule: { kind: "calendar", hour: 5, minute: 10 },
};
if (arg === "--uninstall") { await systemd.uninstall(spec, log); return; }
if (arg === "--status") { if (!(await systemd.status(spec, log))) process.exit(1); return; }
if (!(await systemd.install(spec, log))) process.exit(1);
const first = await sh([bunPath, lifeosPath("TOOLS", "ModelSync.ts"), "--sync"]);
console.log(first.exit === 0 ? "First sync: done" : `First sync skipped (${first.out.trim().split("\n").pop()}) — the daily job will retry`);
}

installVerb(process.argv, "InstallModelSync");
if (systemd.isLinux()) {
await linuxMain(process.argv.find((a) => a.startsWith("--")));
process.exit(0);
}
if (process.argv.includes("--status")) {
const listed = await sh(["launchctl", "print", `${domain}/${LABEL}`]);
console.log(existsSync(TARGET) ? `plist: ${TARGET}` : "plist: not installed");
Expand Down