vibebook.dev 1.6.12 → 1.6.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/cli.mjs +41 -55
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { appendFileSync, chmodSync, closeSync, existsSync, fstatSync, mkdirSync,
|
|
|
7
7
|
import { createServer } from "node:http";
|
|
8
8
|
import { homedir, tmpdir } from "node:os";
|
|
9
9
|
import { basename, dirname, join } from "node:path";
|
|
10
|
-
var VERSION = "1.6.
|
|
10
|
+
var VERSION = "1.6.13";
|
|
11
11
|
var HOME = process.env.VIBEBOOK_HOME || join(homedir(), ".vibebook");
|
|
12
12
|
var SESSION = join(HOME, "session.json");
|
|
13
13
|
var AGENTS = join(HOME, "agents.json");
|
|
@@ -533,60 +533,43 @@ function terminalApp() {
|
|
|
533
533
|
}
|
|
534
534
|
var flog = (m) => process.stdout.write(`${new Date().toLocaleTimeString()} ${m}
|
|
535
535
|
`);
|
|
536
|
-
var firing = new Map;
|
|
537
536
|
async function fireSwitch(room, on, agent, tools) {
|
|
538
|
-
const
|
|
539
|
-
firing.set(room, gen);
|
|
540
|
-
const report = (state, model = "", note = "") => callTool("fire_state", { room_id: room, state, model, note }, agent, tools).catch(() => {});
|
|
537
|
+
const report = (state, note = "") => callTool("fire_state", { room_id: room, state, note }, agent, tools).catch(() => {});
|
|
541
538
|
const map = readJson(HERDR, {});
|
|
542
|
-
const e = map[room]
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
const target = on ? "haiku" : e.fire_prev || "default";
|
|
556
|
-
const busy = !(pane.agent_status === "idle" || pane.agent_status === "done");
|
|
557
|
-
await report("switching", target, busy ? "Teu Claude termina o que está fazendo e troca." : "");
|
|
558
|
-
const since = new Date().toISOString();
|
|
559
|
-
herdr("agent", "prompt", pane.pane_id, `/model ${target}`);
|
|
560
|
-
const until = Date.now() + (busy ? 120000 : 20000);
|
|
561
|
-
while (Date.now() < until) {
|
|
562
|
-
await new Promise((r) => setTimeout(r, 300));
|
|
563
|
-
if (firing.get(room) !== gen)
|
|
564
|
-
return;
|
|
565
|
-
const hit = (transcriptTail(sid, 64 << 10) ?? []).filter((l) => l.includes("Set model to") && (l.match(/"timestamp":"([^"]+)"/)?.[1] ?? "") >= since).map((l) => l.match(/Set model to `([^`]+)`/)?.[1]).pop();
|
|
566
|
-
if (!hit)
|
|
567
|
-
continue;
|
|
568
|
-
try {
|
|
569
|
-
const now = readJson(SETTINGS, {});
|
|
570
|
-
if (now.model !== dflt) {
|
|
571
|
-
if (dflt === undefined)
|
|
572
|
-
delete now.model;
|
|
573
|
-
else
|
|
574
|
-
now.model = dflt;
|
|
575
|
-
writeFileSync(SETTINGS, `${JSON.stringify(now, null, 2)}
|
|
576
|
-
`);
|
|
577
|
-
}
|
|
578
|
-
} catch {}
|
|
579
|
-
if (!on) {
|
|
580
|
-
const m2 = readJson(HERDR, {});
|
|
581
|
-
if (m2[room]) {
|
|
582
|
-
delete m2[room].fire_prev;
|
|
583
|
-
writePrivate(HERDR, m2);
|
|
584
|
-
}
|
|
539
|
+
const e = map[room];
|
|
540
|
+
if (!e?.workspace || !e.folder)
|
|
541
|
+
return report("failed", "Nenhum Claude desta sala aberto no herdr.");
|
|
542
|
+
const tabs = herdr("tab", "list", "--workspace", e.workspace).tabs ?? [];
|
|
543
|
+
const alive = !!e.fire_tab && tabs.some((t) => t.tab_id === e.fire_tab);
|
|
544
|
+
const save = (tab) => {
|
|
545
|
+
const m = readJson(HERDR, {});
|
|
546
|
+
if (m[room]) {
|
|
547
|
+
if (tab)
|
|
548
|
+
m[room].fire_tab = tab;
|
|
549
|
+
else
|
|
550
|
+
delete m[room].fire_tab;
|
|
551
|
+
writePrivate(HERDR, m);
|
|
585
552
|
}
|
|
586
|
-
|
|
587
|
-
|
|
553
|
+
};
|
|
554
|
+
if (!on) {
|
|
555
|
+
if (alive)
|
|
556
|
+
try {
|
|
557
|
+
herdr("tab", "close", e.fire_tab);
|
|
558
|
+
} catch {}
|
|
559
|
+
save();
|
|
560
|
+
flog(`fire off: ${room}`);
|
|
561
|
+
return report("off");
|
|
588
562
|
}
|
|
589
|
-
|
|
563
|
+
if (alive)
|
|
564
|
+
return report("switching", "Teu Haiku já está aberto; esperando ele ouvir.");
|
|
565
|
+
await report("switching", "Abrindo um Claude Haiku só pro Fire…");
|
|
566
|
+
const tab = herdr("tab", "create", "--workspace", e.workspace, "--cwd", e.folder, "--label", "\uD83D\uDD25 fire", "--env", "VIBEBOOK_FIRE=1", ...process.env.VIBEBOOK_HOME ? ["--env", `VIBEBOOK_HOME=${process.env.VIBEBOOK_HOME}`] : [], "--no-focus");
|
|
567
|
+
const tabId = tab.tab?.tab_id, pane = tab.root_pane?.pane_id;
|
|
568
|
+
if (!tabId || !pane)
|
|
569
|
+
return report("failed", "O herdr não abriu a aba do Fire.");
|
|
570
|
+
save(tabId);
|
|
571
|
+
spawn("herdr", ["agent", "start", `vb-fire-${room}`, "--kind", "claude", "--pane", pane, "--", "--model", "haiku", "/vibebook:listen"], { stdio: "ignore", detached: true }).unref();
|
|
572
|
+
flog(`fire on: ${room}, Haiku na aba ${tabId}`);
|
|
590
573
|
}
|
|
591
574
|
function herdrServer(appMode = false, agent = "", tools = []) {
|
|
592
575
|
const allowed = new Set([readJson(SESSION, null)?.origin ?? DEFAULT_ORIGIN, DEFAULT_ORIGIN]);
|
|
@@ -683,7 +666,7 @@ async function herdrSync(agent, tools) {
|
|
|
683
666
|
for (const [room, title] of on) {
|
|
684
667
|
const e = map[room] ??= {};
|
|
685
668
|
if (e.workspace && live.has(e.workspace)) {
|
|
686
|
-
const label = wsList.find((
|
|
669
|
+
const label = wsList.find((w) => w.workspace_id === e.workspace)?.label;
|
|
687
670
|
if (label !== undefined && label !== title.slice(0, 40))
|
|
688
671
|
try {
|
|
689
672
|
herdr("workspace", "rename", e.workspace, title.slice(0, 40));
|
|
@@ -1216,8 +1199,11 @@ async function main() {
|
|
|
1216
1199
|
writeFileSync(lock, String(process.pid));
|
|
1217
1200
|
} catch {}
|
|
1218
1201
|
const tools = await listTools(agent);
|
|
1202
|
+
const FIRE = !!process.env.VIBEBOOK_FIRE;
|
|
1203
|
+
if (FIRE && room)
|
|
1204
|
+
callTool("fire_state", { room_id: room, state: "ready", model: "claude-haiku-5-5" }, agent, tools).catch(() => {});
|
|
1219
1205
|
const check = async (timeout) => {
|
|
1220
|
-
const res = await callTool("wait_for_messages", { timeout_seconds: timeout, ...room ? { room_id: room } : {} }, agent, tools);
|
|
1206
|
+
const res = await callTool("wait_for_messages", { timeout_seconds: timeout, fire: FIRE ? "only" : "skip", ...room ? { room_id: room } : {} }, agent, tools);
|
|
1221
1207
|
const out = JSON.parse(res.content[0]?.text ?? "{}");
|
|
1222
1208
|
if (out.stalled?.length) {
|
|
1223
1209
|
const one = (t) => (t ?? "").replace(/[\p{Cc}"`]/gu, " ").replace(/\s+/g, " ").trim().slice(0, 80);
|
|
@@ -1247,7 +1233,7 @@ async function main() {
|
|
|
1247
1233
|
if (!mine.length)
|
|
1248
1234
|
return false;
|
|
1249
1235
|
const others = (o.messages ?? []).length - mine.length;
|
|
1250
|
-
process.stdout.write(`vibebook: \uD83D\uDD25 Modo Fire em "${name}" room_id=${roomId}.
|
|
1236
|
+
process.stdout.write(`vibebook: \uD83D\uDD25 Modo Fire em "${name}" room_id=${roomId}. Você é o Claude do Modo Fire (Haiku) e teu humano está falando ao vivo: responda já, um post com reply_to e thread de cada fala, sem ack e sem read_room (já li pra você). Card, markdown curto ou HTML ao lado; fire_card reescreve teu card. Trabalho grande (código, deploy): add_task no épico certo e diga que o Claude principal pega quando o Fire acabar. Depois rode listen de novo.
|
|
1251
1237
|
`);
|
|
1252
1238
|
for (const m of mine)
|
|
1253
1239
|
process.stdout.write(`\uD83D\uDD25 #${m.id} thread=${m.thread}${m.viewing ? ` vendo=${m.viewing.name} (file_id ${m.viewing.id})` : ""}: ${(m.text ?? "").slice(0, 2000)}
|
|
@@ -1268,7 +1254,7 @@ async function main() {
|
|
|
1268
1254
|
if (await check(0))
|
|
1269
1255
|
return;
|
|
1270
1256
|
} catch {
|
|
1271
|
-
await new Promise((
|
|
1257
|
+
await new Promise((r) => setTimeout(r, 15000));
|
|
1272
1258
|
}
|
|
1273
1259
|
last = Date.now();
|
|
1274
1260
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vibebook.dev",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.13",
|
|
4
4
|
"description": "vibebook CLI: your vibebook rooms from the terminal, for you and your Claude. One login per machine; room tools discovered at run time.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": { "vibebook": "cli.mjs" },
|