demobites 1.20.0 → 1.21.1
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/launcher/index.mjs +39 -7
- package/package.json +1 -1
package/launcher/index.mjs
CHANGED
|
@@ -113,12 +113,16 @@ if (arg === "logs") {
|
|
|
113
113
|
let text = ""; try { text = fs.readFileSync(LOG, "utf8"); } catch { /* none */ }
|
|
114
114
|
const lines = text.trimEnd().split("\n"); console.log(lines.slice(-n).join("\n") || " (no log yet)"); process.exit(0);
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
// The login service, removed: the file, the registration, and (unless we ARE the service) the listener.
|
|
117
|
+
const removeService = () => {
|
|
117
118
|
const def = serviceDef();
|
|
119
|
+
fs.rmSync(def.file, { force: true });
|
|
118
120
|
if (process.platform === "darwin") spawnSync("launchctl", ["bootout", `gui/${process.getuid()}/${SERVICE_LABEL}`], { stdio: "ignore" });
|
|
119
121
|
else if (process.platform === "linux") spawnSync("systemctl", ["--user", "disable", "--now", SERVICE_UNIT], { stdio: "ignore" });
|
|
120
122
|
else spawnSync("reg", ["delete", "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", "/v", RUN_NAME, "/f"], { stdio: "ignore" });
|
|
121
|
-
|
|
123
|
+
};
|
|
124
|
+
if (arg === "off") {
|
|
125
|
+
removeService();
|
|
122
126
|
const pid = killListener();
|
|
123
127
|
// the browsers of an interrupted take go with it
|
|
124
128
|
for (const c of readJson(CHILDREN) ?? []) { try { process.kill(process.platform === "win32" ? c : -c, "SIGTERM"); } catch { /* gone */ } }
|
|
@@ -280,9 +284,15 @@ if (arg === "on") {
|
|
|
280
284
|
const cfgAt = () => readJson(path.join(cwd, ".recorder", "config.json"));
|
|
281
285
|
const base = (flag("--base") || cfgAt()?.base || "https://app.demobites.com").replace(/\/+$/, "");
|
|
282
286
|
const code = flag("--connect");
|
|
283
|
-
|
|
287
|
+
// No key and no code: the one door is the line in the app (1.21.1, after a pairing page opened in the
|
|
288
|
+
// wrong browser on 2026-10-16). Nothing here ever opens a browser on its own; `demobite login` is explicit.
|
|
289
|
+
if (!code && (!cfgAt()?.api_key || (flag("--base") && cfgAt()?.base && cfgAt().base.replace(/\/+$/, "") !== base))) {
|
|
290
|
+
warn("Not connected. In the app, open Create → Agentic Capture and run the line in the banner on this machine.");
|
|
291
|
+
process.exit(1);
|
|
292
|
+
}
|
|
293
|
+
if (code) {
|
|
284
294
|
console.log("");
|
|
285
|
-
const r = spawnSync(process.execPath, [path.join(dest, "scripts", "login.mjs"), base,
|
|
295
|
+
const r = spawnSync(process.execPath, [path.join(dest, "scripts", "login.mjs"), base, "--connect", code], { stdio: "inherit", cwd });
|
|
286
296
|
if (r.status !== 0) process.exit(r.status ?? 1);
|
|
287
297
|
}
|
|
288
298
|
if (!cfgAt()?.api_key) { warn("Not connected. Run the line from the app again."); process.exit(1); }
|
|
@@ -389,9 +399,14 @@ if (arg === "listen") {
|
|
|
389
399
|
// --connect <code>: the line the Agentic Capture chat gave — already approved
|
|
390
400
|
// for the signed-in person; connects this machine without a page or a click.
|
|
391
401
|
const connectCode = argvRest.includes("--connect") ? (argvRest[argvRest.indexOf("--connect") + 1] || "") : "";
|
|
392
|
-
if (connectCode
|
|
393
|
-
|
|
394
|
-
|
|
402
|
+
if (!connectCode && (!cfg?.api_key || (argvRest.includes("--base") && cfg?.base && cfg.base.replace(/\/+$/, "") !== base))) {
|
|
403
|
+
// Never a browser of its own (1.21.1): the line in the app, or `demobite login` by hand.
|
|
404
|
+
warn("Not connected. In the app, open Create → Agentic Capture and run the line in the banner on this machine, or run: demobite login");
|
|
405
|
+
process.exit(1);
|
|
406
|
+
}
|
|
407
|
+
if (connectCode) {
|
|
408
|
+
console.log(`\n Connecting this machine to your DemoBites account first…\n`);
|
|
409
|
+
const r = spawnSync(process.execPath, [path.join(dest, "scripts", "login.mjs"), base, "--connect", connectCode], { stdio: "inherit", cwd: process.cwd() });
|
|
395
410
|
if (r.status !== 0) process.exit(r.status ?? 1);
|
|
396
411
|
cfg = readCfg();
|
|
397
412
|
}
|
|
@@ -600,8 +615,25 @@ if (arg === "listen") {
|
|
|
600
615
|
waitOn();
|
|
601
616
|
};
|
|
602
617
|
|
|
618
|
+
// DISCONNECT FROM THE APP (1.21.0, founder 2026-10-16: "go back to the connected machine via my browser
|
|
619
|
+
// and disconnect"): the app's order, taken at check-in. Says so to the app first (the key is needed for
|
|
620
|
+
// that), then the sign-ins, the ledger and the key go from this machine, the login service is removed,
|
|
621
|
+
// and the process ends. `demobite on` with a new line from the app connects it again.
|
|
622
|
+
const runOff = async (job) => {
|
|
623
|
+
console.log(`\n ⏏ Disconnecting this machine, on your word from the app.`);
|
|
624
|
+
noteState({ busy: true, job: job.id });
|
|
625
|
+
await event(job.id, "started", { machine: name });
|
|
626
|
+
await event(job.id, "ready", { disconnected: true, machine: name });
|
|
627
|
+
const rec = path.join(process.cwd(), ".recorder");
|
|
628
|
+
for (const f of ["profile", "signins.json", "config.json", "listen.json"]) fs.rmSync(path.join(rec, f), { recursive: true, force: true });
|
|
629
|
+
noteState({ busy: false, job: null, last_error: null, disconnected: true });
|
|
630
|
+
console.log(` ○ Disconnected. The sign-ins and the key are gone from this machine; the login service is removed.`);
|
|
631
|
+
if (SERVICE) removeService(); // bootout ends this process; the handlers below clear the lock
|
|
632
|
+
bye("OFF");
|
|
633
|
+
};
|
|
603
634
|
const runJob = async (job) => {
|
|
604
635
|
waitOff();
|
|
636
|
+
if (job.kind === "off") return runOff(job);
|
|
605
637
|
if (job.kind === "look" || job.kind === "signin" || job.kind === "signout") return runLookOrSignin(job);
|
|
606
638
|
const model = typeof job.model === "string" && job.model ? job.model : JOB_MODEL;
|
|
607
639
|
// Alive while filming (1.13.1): a heartbeat every 5 s so the rail never shows this machine
|
package/package.json
CHANGED