@tpsdev-ai/flair 0.4.11 → 0.4.13
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/dist/cli.js +76 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -377,6 +377,80 @@ program
|
|
|
377
377
|
console.log("Waiting for Harper health check...");
|
|
378
378
|
await waitForHealth(httpPort, adminUser, adminPass, STARTUP_TIMEOUT_MS);
|
|
379
379
|
console.log("Harper is healthy ✓");
|
|
380
|
+
// Register launchd service on macOS so Harper survives reboots
|
|
381
|
+
// and `flair restart` / `flair stop` work via launchctl.
|
|
382
|
+
if (process.platform === "darwin") {
|
|
383
|
+
const harperBinPath = harperBin();
|
|
384
|
+
if (harperBinPath) {
|
|
385
|
+
const label = "ai.tpsdev.flair";
|
|
386
|
+
const plistDir = join(homedir(), "Library", "LaunchAgents");
|
|
387
|
+
mkdirSync(plistDir, { recursive: true });
|
|
388
|
+
const plistPath = join(plistDir, `${label}.plist`);
|
|
389
|
+
const opsSocket = join(dataDir, "operations-server");
|
|
390
|
+
const setConfig = JSON.stringify({
|
|
391
|
+
rootPath: dataDir,
|
|
392
|
+
http: { port: httpPort, cors: true, corsAccessList: [`http://127.0.0.1:${httpPort}`, `http://localhost:${httpPort}`] },
|
|
393
|
+
operationsApi: { network: { port: opsPort, cors: true }, domainSocket: opsSocket },
|
|
394
|
+
mqtt: { network: { port: null }, webSocket: false },
|
|
395
|
+
localStudio: { enabled: false },
|
|
396
|
+
authentication: { authorizeLocal: true, enableSessions: true },
|
|
397
|
+
});
|
|
398
|
+
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
399
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
400
|
+
<plist version="1.0">
|
|
401
|
+
<dict>
|
|
402
|
+
<key>Label</key><string>${label}</string>
|
|
403
|
+
<key>ProgramArguments</key>
|
|
404
|
+
<array>
|
|
405
|
+
<string>${process.execPath}</string>
|
|
406
|
+
<string>${harperBinPath}</string>
|
|
407
|
+
<string>run</string>
|
|
408
|
+
<string>.</string>
|
|
409
|
+
</array>
|
|
410
|
+
<key>WorkingDirectory</key><string>${flairPackageDir()}</string>
|
|
411
|
+
<key>EnvironmentVariables</key>
|
|
412
|
+
<dict>
|
|
413
|
+
<key>ROOTPATH</key><string>${dataDir}</string>
|
|
414
|
+
<key>HARPER_SET_CONFIG</key><string>${setConfig.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """)}</string>
|
|
415
|
+
<key>DEFAULTS_MODE</key><string>dev</string>
|
|
416
|
+
<key>HDB_ADMIN_USERNAME</key><string>${adminUser}</string>
|
|
417
|
+
<key>HDB_ADMIN_PASSWORD</key><string>${adminPass}</string>
|
|
418
|
+
<key>THREADS_COUNT</key><string>1</string>
|
|
419
|
+
<key>NODE_HOSTNAME</key><string>localhost</string>
|
|
420
|
+
<key>HTTP_PORT</key><string>${httpPort}</string>
|
|
421
|
+
<key>OPERATIONSAPI_NETWORK_PORT</key><string>${opsPort}</string>
|
|
422
|
+
<key>LOCAL_STUDIO</key><string>false</string>
|
|
423
|
+
</dict>
|
|
424
|
+
<key>RunAtLoad</key><true/>
|
|
425
|
+
<key>KeepAlive</key><true/>
|
|
426
|
+
<key>StandardOutPath</key><string>${join(dataDir, "log", "launchd-stdout.log")}</string>
|
|
427
|
+
<key>StandardErrorPath</key><string>${join(dataDir, "log", "launchd-stderr.log")}</string>
|
|
428
|
+
</dict>
|
|
429
|
+
</plist>`;
|
|
430
|
+
writeFileSync(plistPath, plist);
|
|
431
|
+
try {
|
|
432
|
+
const { execSync } = await import("node:child_process");
|
|
433
|
+
// Stop the detached process — launchd will manage it from here
|
|
434
|
+
try {
|
|
435
|
+
const lsof = execSync(`lsof -ti :${httpPort}`, { encoding: "utf-8" }).trim();
|
|
436
|
+
if (lsof)
|
|
437
|
+
for (const pid of lsof.split("\n"))
|
|
438
|
+
try {
|
|
439
|
+
process.kill(Number(pid.trim()), "SIGTERM");
|
|
440
|
+
}
|
|
441
|
+
catch { }
|
|
442
|
+
await new Promise(r => setTimeout(r, 1000));
|
|
443
|
+
}
|
|
444
|
+
catch { }
|
|
445
|
+
execSync(`launchctl load "${plistPath}"`, { stdio: "pipe" });
|
|
446
|
+
await waitForHealth(httpPort, adminUser, adminPass, STARTUP_TIMEOUT_MS);
|
|
447
|
+
console.log("Launchd service registered ✓");
|
|
448
|
+
}
|
|
449
|
+
catch (err) {
|
|
450
|
+
console.log(`Note: launchd registration failed (${err.message}) — Harper is running but won't auto-start on reboot`);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
380
454
|
}
|
|
381
455
|
// Persist port to config so other commands can find this instance
|
|
382
456
|
writeConfig(httpPort);
|
|
@@ -1086,6 +1160,8 @@ program
|
|
|
1086
1160
|
}
|
|
1087
1161
|
catch { }
|
|
1088
1162
|
}
|
|
1163
|
+
// Wait for process to release file handles (RocksDB)
|
|
1164
|
+
await new Promise(r => setTimeout(r, 2000));
|
|
1089
1165
|
console.log("✅ Flair process stopped");
|
|
1090
1166
|
}
|
|
1091
1167
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tpsdev-ai/flair",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.13",
|
|
4
4
|
"description": "Identity, memory, and soul for AI agents. Cryptographic identity (Ed25519), semantic memory with local embeddings, and persistent personality — all in a single process.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|