@conveno/cli 0.2.0-rc.11 → 0.2.0-rc.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/README.md +1 -1
- package/dist/{acp-BOSDOzU7.js → acp-Bs6XS61j.js} +3 -3
- package/dist/{agy-relay-BUo9uRng.js → agy-relay-BJLRYbFp.js} +3 -2
- package/dist/{args-C1eX8Ixk.js → args-C4rVCVXx.js} +3 -1
- package/dist/bin.js +16 -2
- package/dist/daemon.js +339 -18
- package/dist/{daemonError-DraepwsB.js → daemonError-CjxG2yUl.js} +1 -1
- package/dist/{dist-Y0JDSJP_.js → dist-B14ldKRS.js} +50 -8
- package/dist/{dist-Rdj5ogAX.js → dist-BkhKEexU.js} +90 -21
- package/dist/{dist-DEjU_KXC.js → dist-C9Z1EMlM.js} +39 -19
- package/dist/{dist-n6XMTlyN.js → dist-Ca3P7aN-.js} +10 -1
- package/dist/{dist-Dg2IY9OA.js → dist-CoRBNycn.js} +1 -1
- package/dist/{dist-KWlFKO7H.js → dist-D4sb5RQD.js} +56 -13
- package/dist/{dist-qONHJRJk.js → dist-DnNuDzEA.js} +286 -36
- package/dist/{hook-CDF1A8AY.js → hook-C60hXJdg.js} +101 -7
- package/dist/{hook-entry-BYvXWDJv.js → hook-entry-WlJSM5aD.js} +101 -78
- package/dist/hook-entry-jOfjq-0A.js +1 -0
- package/dist/{main-EqfI0btx.js → main-I2RMN7XN.js} +54 -15
- package/dist/{pick-B-axJvgf.js → pick-Colav8Wm.js} +1 -1
- package/dist/{run-CtGfzzwB.js → run-BuDbmxx_.js} +223 -74
- package/dist/{runtime-BDNmkbsS.js → runtime-CPmrhPFJ.js} +118 -90
- package/dist/{uninstall-Blt-KHI5.js → uninstall-812XZDTG.js} +259 -43
- package/dist/{watch-CuZ7jPVd.js → watch-DXbOOc20.js} +29 -7
- package/package.json +13 -13
- package/dist/hook-entry-D2CAJsq-.js +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Box, Text, render, useApp, useInput, useStdin, useStdout } from "ink";
|
|
2
2
|
import { n as connectOpts, t as adapterEnv } from "./ctx-tYftvhz_.js";
|
|
3
|
-
import { t as
|
|
3
|
+
import { D as stopDaemonIfRunning, N as showCode$1, S as PAIR_TIMEOUT_MS, T as replaceStaleDaemon, _ as saveChoice, a as applyOptions, b as unifiedDiff, c as collectPlans, d as refreshManifest, f as renewedApprovals, g as connectedTools, h as chosenTools, k as openInBrowser, l as detectAll, n as inspect, o as approvalWrites, r as partState, s as approvedBySetup, t as runUninstall, u as pendingOptions, v as StaleError, x as warmAcpAdapters, y as applyChanges } from "./uninstall-812XZDTG.js";
|
|
4
|
+
import { t as daemonProblem } from "./daemonError-CjxG2yUl.js";
|
|
4
5
|
import { a as fail, n as cmd, s as plainError, u as tilde } from "./fmt-C2SsP5Y0.js";
|
|
5
6
|
import { createContext, useContext, useEffect, useImperativeHandle, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
|
|
6
|
-
import {
|
|
7
|
-
import { C as openInBrowser, D as showCode$1, S as stopDaemonIfRunning, _ as unifiedDiff, a as applyOptions, c as collectPlans, d as refreshManifest, f as renewedApprovals, g as applyChanges, h as StaleError, l as detectAll, n as inspect, o as approvalWrites, r as partState, s as approvedBySetup, t as runUninstall, u as pendingOptions, v as PAIR_TIMEOUT_MS } from "./uninstall-Blt-KHI5.js";
|
|
7
|
+
import { Ht as readSettings, Kt as requestDeviceCode, Lt as readAccountTokens, N as compatStatus, Nt as planSpawn, P as completeLogin, Pt as pollDeviceCode, Ut as readSpawnRecord, V as defaultProcessIo, Vt as readProcessList, Wt as realSpawnDeps, X as findOnPath, Y as fetchAccountStatus, gn as writeSettings, gt as logoutAccount, jn as SESSION_NAME_PATTERN, nn as spawnRecordPath, r as AccountError, rn as spawnSession, z as dataPaths } from "./dist-DnNuDzEA.js";
|
|
8
8
|
import { i as tokens, n as detectColorLevel, r as detectUnicode } from "./dist-BRjg9CLd.js";
|
|
9
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { readFileSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -12,7 +12,7 @@ import { Readable } from "node:stream";
|
|
|
12
12
|
import { basename, posix, win32 } from "node:path";
|
|
13
13
|
import { spawn } from "node:child_process";
|
|
14
14
|
import { homedir } from "node:os";
|
|
15
|
-
import { r as stopRequestPath, t as killProcessTree } from "./dist-
|
|
15
|
+
import { r as stopRequestPath, t as killProcessTree } from "./dist-BkhKEexU.js";
|
|
16
16
|
// src/tui/home/deps.ts
|
|
17
17
|
/**
|
|
18
18
|
* What home does outside the store: sign in and out, and take Conveno away. Real in the app, fake
|
|
@@ -570,14 +570,10 @@ function Choices({ items, multi = false, value, onChange, onSubmit, focusIndex,
|
|
|
570
570
|
else if (input === " ") toggle(focus);
|
|
571
571
|
else if (key.return) submit(focus);
|
|
572
572
|
}, { isActive });
|
|
573
|
-
const mark = multi ?
|
|
573
|
+
const mark = multi ? {
|
|
574
574
|
on: "[x]",
|
|
575
575
|
off: "[ ]",
|
|
576
576
|
no: "[-]"
|
|
577
|
-
} : {
|
|
578
|
-
on: "●",
|
|
579
|
-
off: "○",
|
|
580
|
-
no: "–"
|
|
581
577
|
} : void 0;
|
|
582
578
|
const pointer = k.ascii ? ">" : "›";
|
|
583
579
|
const labelW = Math.max(0, ...items.map((i) => [...i.label].length));
|
|
@@ -587,7 +583,7 @@ function Choices({ items, multi = false, value, onChange, onSubmit, focusIndex,
|
|
|
587
583
|
const focused = i === focus && !item.disabled;
|
|
588
584
|
const picked = value.includes(item.id);
|
|
589
585
|
const lead = focused ? pointer : " ";
|
|
590
|
-
const room = Math.max(0, full - 2 - (mark ?
|
|
586
|
+
const room = Math.max(0, full - 2 - (mark ? 4 : 0));
|
|
591
587
|
const label = cut(item.label, Math.min(labelW, room), k.ascii);
|
|
592
588
|
const hintRoom = room - [...label].length - 2;
|
|
593
589
|
const labelProps = item.disabled ? tint(k.c.quiet) : focused ? {
|
|
@@ -612,7 +608,10 @@ function Choices({ items, multi = false, value, onChange, onSubmit, focusIndex,
|
|
|
612
608
|
children: `${lead} `
|
|
613
609
|
}),
|
|
614
610
|
mark ? /* @__PURE__ */ jsx(Text, {
|
|
615
|
-
...item.disabled ? k.quiet : picked ?
|
|
611
|
+
...item.disabled ? k.quiet : picked ? {
|
|
612
|
+
...tint(k.c.entry),
|
|
613
|
+
...strong(k)
|
|
614
|
+
} : k.quiet,
|
|
616
615
|
children: `${item.disabled ? mark.no : picked ? mark.on : mark.off} `
|
|
617
616
|
}) : null,
|
|
618
617
|
/* @__PURE__ */ jsx(Text, {
|
|
@@ -1159,6 +1158,8 @@ const TOOL_NAMES$1 = {
|
|
|
1159
1158
|
};
|
|
1160
1159
|
/** "Claude Code" for `claude`. An unknown id shows as it is. */
|
|
1161
1160
|
const toolName$1 = (cli) => TOOL_NAMES$1[cli] ?? cli;
|
|
1161
|
+
/** The tool a session runs in: "Antigravity app" for the desktop app, else `toolName`. */
|
|
1162
|
+
const sessionTool = (s) => s.variant === "app" && s.cli === "antigravity" ? "Antigravity app" : toolName$1(s.cli);
|
|
1162
1163
|
/** The session's own name without the computer it runs on (`laptop:api-fix` is `api-fix`). */
|
|
1163
1164
|
function shortName(name) {
|
|
1164
1165
|
const i = name.indexOf(":");
|
|
@@ -1169,7 +1170,7 @@ function shortName(name) {
|
|
|
1169
1170
|
* the same tool (`Codex (api-fix)`).
|
|
1170
1171
|
*/
|
|
1171
1172
|
function sessionLabel(s, all) {
|
|
1172
|
-
const tool =
|
|
1173
|
+
const tool = sessionTool(s);
|
|
1173
1174
|
return all.some((o) => o.id !== s.id && o.cli === s.cli) ? `${tool} (${shortName(s.name)})` : tool;
|
|
1174
1175
|
}
|
|
1175
1176
|
// src/tui/home/hooks.ts
|
|
@@ -1188,11 +1189,16 @@ function reasonOf(e, fallback = "That did not work.") {
|
|
|
1188
1189
|
const line = (e instanceof Error ? e.message : typeof e === "string" ? e : "").split("\n")[0]?.trim();
|
|
1189
1190
|
return line ? line : fallback;
|
|
1190
1191
|
}
|
|
1191
|
-
/**
|
|
1192
|
+
/**
|
|
1193
|
+
* The state of a session in one or two words: working, idle, waking up, on next prompt, waiting for
|
|
1194
|
+
* you. A message waits for "waking up" only when something can wake the session; one that cannot
|
|
1195
|
+
* (`wakeable` false, such as a window nothing listens in yet) gets it at its next prompt.
|
|
1196
|
+
*/
|
|
1192
1197
|
function stateWord(s) {
|
|
1193
1198
|
if (s.status === "busy") return "working";
|
|
1194
1199
|
if (s.status === "waiting_on_question") return "waiting for you";
|
|
1195
|
-
|
|
1200
|
+
if ((s.unreadCount ?? 0) === 0) return "idle";
|
|
1201
|
+
return s.wakeable === false ? "on next prompt" : "waking up";
|
|
1196
1202
|
}
|
|
1197
1203
|
/** What a card says on its last line: the state, and the computer for a remote session. */
|
|
1198
1204
|
function stateLine(s) {
|
|
@@ -1217,6 +1223,7 @@ function problemsOf(setup) {
|
|
|
1217
1223
|
if (!h.fixId) continue;
|
|
1218
1224
|
const cli = h.fixId.split(":")[1] ?? "";
|
|
1219
1225
|
const check = setup.clis.find((c) => c.cli === cli);
|
|
1226
|
+
if (check?.chosen === false) continue;
|
|
1220
1227
|
out.push({
|
|
1221
1228
|
fixId: h.fixId,
|
|
1222
1229
|
label: check?.label ?? toolName$1(cli)
|
|
@@ -1549,7 +1556,7 @@ function Card({ session, lead, selected, width, onSelect }) {
|
|
|
1549
1556
|
}) : /* @__PURE__ */ jsx(Text, { children: " " }), /* @__PURE__ */ jsx(Text, {
|
|
1550
1557
|
...strong(k),
|
|
1551
1558
|
...k.ink,
|
|
1552
|
-
children: cut(
|
|
1559
|
+
children: cut(sessionTool(session), inner - 2, k.ascii)
|
|
1553
1560
|
})]
|
|
1554
1561
|
}),
|
|
1555
1562
|
/* @__PURE__ */ jsx(Text, {
|
|
@@ -2115,6 +2122,10 @@ const MENU_ITEMS = [
|
|
|
2115
2122
|
id: "rename",
|
|
2116
2123
|
label: "Rename"
|
|
2117
2124
|
},
|
|
2125
|
+
{
|
|
2126
|
+
id: "remove",
|
|
2127
|
+
label: "Remove this session"
|
|
2128
|
+
},
|
|
2118
2129
|
{
|
|
2119
2130
|
id: "setup",
|
|
2120
2131
|
label: "Set up tools"
|
|
@@ -2251,6 +2262,7 @@ function Help({ onClose }) {
|
|
|
2251
2262
|
["m or enter", "send a message to the one you picked"],
|
|
2252
2263
|
["l", "put it in charge"],
|
|
2253
2264
|
["r", "rename it"],
|
|
2265
|
+
["x", "take it off the list"],
|
|
2254
2266
|
["f", "fix a tool that needs it"],
|
|
2255
2267
|
["ctrl+p or /", "the menu"],
|
|
2256
2268
|
["?", "this list"],
|
|
@@ -2486,6 +2498,26 @@ function Home({ store, deps, size, onSetup, onQuit }) {
|
|
|
2486
2498
|
say(reasonOf(e), "error");
|
|
2487
2499
|
}
|
|
2488
2500
|
};
|
|
2501
|
+
const startRemove = () => {
|
|
2502
|
+
const who = target();
|
|
2503
|
+
if (!who) return;
|
|
2504
|
+
if (who.remote) {
|
|
2505
|
+
say("That one's on another computer. Remove it there.", "warn");
|
|
2506
|
+
return;
|
|
2507
|
+
}
|
|
2508
|
+
setMode("remove");
|
|
2509
|
+
};
|
|
2510
|
+
const remove = async () => {
|
|
2511
|
+
const who = sel;
|
|
2512
|
+
setMode("board");
|
|
2513
|
+
if (!who) return;
|
|
2514
|
+
try {
|
|
2515
|
+
await actions.remove(who.id);
|
|
2516
|
+
say(`Removed ${who.name}.`);
|
|
2517
|
+
} catch (e) {
|
|
2518
|
+
say(reasonOf(e, "That did not work."), "error");
|
|
2519
|
+
}
|
|
2520
|
+
};
|
|
2489
2521
|
const startFix = () => {
|
|
2490
2522
|
if (problems.length === 0) {
|
|
2491
2523
|
say("Everything is in order.", "info");
|
|
@@ -2499,6 +2531,7 @@ function Home({ store, deps, size, onSetup, onQuit }) {
|
|
|
2499
2531
|
if (id === "send") startMessage();
|
|
2500
2532
|
else if (id === "lead") makeLead();
|
|
2501
2533
|
else if (id === "rename") startRename();
|
|
2534
|
+
else if (id === "remove") startRemove();
|
|
2502
2535
|
else if (id === "setup") onSetup();
|
|
2503
2536
|
else if (id === "computers" || id === "account" || id === "uninstall") setMode(id);
|
|
2504
2537
|
else if (id === "quit") onQuit();
|
|
@@ -2526,11 +2559,16 @@ function Home({ store, deps, size, onSetup, onQuit }) {
|
|
|
2526
2559
|
if (key.return || input === "m") return startMessage();
|
|
2527
2560
|
if (input === "l") return void makeLead();
|
|
2528
2561
|
if (input === "r") return startRename();
|
|
2562
|
+
if (input === "x") return startRemove();
|
|
2529
2563
|
if (input === "f") return startFix();
|
|
2530
2564
|
if (input === "/") return setMode("menu");
|
|
2531
2565
|
if (input === "?") return setMode("help");
|
|
2532
2566
|
if (input === "q") return onQuit();
|
|
2533
2567
|
}, { isActive: mode === "board" });
|
|
2568
|
+
useInput((input, key) => {
|
|
2569
|
+
if (input === "y" || input === "Y") remove();
|
|
2570
|
+
else if (input === "n" || input === "N" || key.escape || key.return) setMode("board");
|
|
2571
|
+
}, { isActive: mode === "remove" });
|
|
2534
2572
|
useWheel(boardRef, (d) => move(selIdx + d), { isActive: mode === "board" });
|
|
2535
2573
|
const back = () => setMode("board");
|
|
2536
2574
|
if (mode === "menu") return /* @__PURE__ */ jsx(Menu, {
|
|
@@ -2573,7 +2611,8 @@ function Home({ store, deps, size, onSetup, onQuit }) {
|
|
|
2573
2611
|
const hint = !lead && !empty;
|
|
2574
2612
|
const entries = state.activity;
|
|
2575
2613
|
let act = Math.min(ACTIVITY_LINES, Math.max(1, entries.length));
|
|
2576
|
-
const
|
|
2614
|
+
const asking = mode === "remove";
|
|
2615
|
+
const fixed = 2 + (problems.length > 0 ? 2 : 0) + 1 + (typing || asking ? 1 : 0) + 1 + 1 + (hint ? 1 : 0);
|
|
2577
2616
|
const need = lead && modeFor(columns) === "compact" ? 11 : 5;
|
|
2578
2617
|
while (act > 1 && rows - fixed - act < need) act -= 1;
|
|
2579
2618
|
const budget = Math.max(5, rows - fixed - act);
|
|
@@ -2718,6 +2757,11 @@ function Home({ store, deps, size, onSetup, onQuit }) {
|
|
|
2718
2757
|
})
|
|
2719
2758
|
]
|
|
2720
2759
|
}),
|
|
2760
|
+
mode === "remove" && sel ? /* @__PURE__ */ jsx(Text, {
|
|
2761
|
+
wrap: "truncate",
|
|
2762
|
+
...tint(k.c.warn),
|
|
2763
|
+
children: cut(`Remove ${sel.name} from the list? Its unread messages go too. y/n`, width, k.ascii)
|
|
2764
|
+
}) : null,
|
|
2721
2765
|
typing && sel ? /* @__PURE__ */ jsxs(Box, { children: [
|
|
2722
2766
|
/* @__PURE__ */ jsx(Text, {
|
|
2723
2767
|
wrap: "truncate",
|
|
@@ -3219,26 +3263,11 @@ function installPlan(cli, platform) {
|
|
|
3219
3263
|
}
|
|
3220
3264
|
}
|
|
3221
3265
|
/**
|
|
3222
|
-
* Update route
|
|
3223
|
-
*
|
|
3224
|
-
* unreadable version gets no update.
|
|
3266
|
+
* Update route. No tool needs one now: any OpenCode 1.x or 2.x works, so nothing is offered. Kept
|
|
3267
|
+
* as the one place to add a route again if a tool ever gets a floor.
|
|
3225
3268
|
*/
|
|
3226
|
-
function updatePlan(
|
|
3227
|
-
|
|
3228
|
-
const m = /^v?(\d+)\.(\d+)/.exec(installedVersion.trim());
|
|
3229
|
-
if (!m) return { available: false };
|
|
3230
|
-
const major = Number(m[1]);
|
|
3231
|
-
const minor = Number(m[2]);
|
|
3232
|
-
if (major > 2 || major === 2 && minor >= 4) return { available: false };
|
|
3233
|
-
const args = major < 2 ? ["upgrade", "--major"] : ["upgrade"];
|
|
3234
|
-
return {
|
|
3235
|
-
available: true,
|
|
3236
|
-
steps: [{
|
|
3237
|
-
file: "opencode",
|
|
3238
|
-
args,
|
|
3239
|
-
display: `opencode ${args.join(" ")}`
|
|
3240
|
-
}]
|
|
3241
|
-
};
|
|
3269
|
+
function updatePlan(_cli, _installedVersion) {
|
|
3270
|
+
return { available: false };
|
|
3242
3271
|
}
|
|
3243
3272
|
/** Real process I/O. */
|
|
3244
3273
|
function realInstallDeps() {
|
|
@@ -3548,9 +3577,13 @@ function healthFrom(input) {
|
|
|
3548
3577
|
level: "error",
|
|
3549
3578
|
text: "Conveno can't be reached"
|
|
3550
3579
|
});
|
|
3551
|
-
const
|
|
3552
|
-
const
|
|
3553
|
-
|
|
3580
|
+
const mine = input.clis.filter((c) => c.chosen !== false);
|
|
3581
|
+
const installed = mine.filter((c) => c.status !== "not-installed" || c.connected);
|
|
3582
|
+
const good = installed.filter((c) => c.status === "ready" || c.status === "not-installed").length;
|
|
3583
|
+
out.push(mine.length === 0 ? {
|
|
3584
|
+
level: "warn",
|
|
3585
|
+
text: "No AI tools chosen yet"
|
|
3586
|
+
} : installed.length === 0 ? {
|
|
3554
3587
|
level: "warn",
|
|
3555
3588
|
text: "No supported CLI found on this machine"
|
|
3556
3589
|
} : {
|
|
@@ -3592,7 +3625,18 @@ function healthFrom(input) {
|
|
|
3592
3625
|
}
|
|
3593
3626
|
/** The same facts as `conveno doctor`, as friendly rows. Never throws. */
|
|
3594
3627
|
async function loadSetup(ctx) {
|
|
3595
|
-
const
|
|
3628
|
+
const rows = await Promise.all(ctx.adapters.map((a) => inspect(ctx, a)));
|
|
3629
|
+
const chosen = new Set(await chosenTools(ctx));
|
|
3630
|
+
const connected = new Set(await connectedTools(ctx));
|
|
3631
|
+
const clis = rows.map((r) => {
|
|
3632
|
+
const check = checkFromRow(r, ctx.compat);
|
|
3633
|
+
return {
|
|
3634
|
+
...check,
|
|
3635
|
+
chosen: chosen.has(r.adapter.cli),
|
|
3636
|
+
...connected.has(r.adapter.cli) ? { connected: true } : {},
|
|
3637
|
+
...check.status === "not-installed" && connected.has(r.adapter.cli) ? { note: "connected, but the program is not on this computer" } : {}
|
|
3638
|
+
};
|
|
3639
|
+
});
|
|
3596
3640
|
let daemon = "stopped";
|
|
3597
3641
|
let sync;
|
|
3598
3642
|
try {
|
|
@@ -3655,7 +3699,7 @@ async function planFor(ctx, fixId) {
|
|
|
3655
3699
|
installed: false,
|
|
3656
3700
|
configPaths: []
|
|
3657
3701
|
}));
|
|
3658
|
-
if (detection.installed) found.push({
|
|
3702
|
+
if (detection.installed || parsed.kind === "uninstall") found.push({
|
|
3659
3703
|
adapter,
|
|
3660
3704
|
detection
|
|
3661
3705
|
});
|
|
@@ -3806,8 +3850,7 @@ async function detectTools(ctx) {
|
|
|
3806
3850
|
...o.defaultYes ? { defaultYes: true } : {}
|
|
3807
3851
|
});
|
|
3808
3852
|
}
|
|
3809
|
-
|
|
3810
|
-
if (detection.installed) connected = await adapter.plan(env, {}).then((p) => p.length === 0).catch(() => false);
|
|
3853
|
+
const connected = await adapter.plan(env, {}).then((p) => p.length === 0).catch(() => false);
|
|
3811
3854
|
const major = Number.parseInt((detection.version ?? "").replace(/^v/i, ""), 10) < 2;
|
|
3812
3855
|
return {
|
|
3813
3856
|
cli,
|
|
@@ -3876,6 +3919,7 @@ async function changeTool(ctx, cli, fixId, failed, io) {
|
|
|
3876
3919
|
for (const p of done.problems) io.line(p);
|
|
3877
3920
|
return {
|
|
3878
3921
|
ok: true,
|
|
3922
|
+
changed: files.length > 0,
|
|
3879
3923
|
...files.length === 0 ? { note: "already connected" } : {},
|
|
3880
3924
|
...done.approved === void 0 ? {} : { approved: done.approved }
|
|
3881
3925
|
};
|
|
@@ -3900,23 +3944,56 @@ const PROCESS_NAMES = {
|
|
|
3900
3944
|
antigravity: "agy",
|
|
3901
3945
|
grok: "grok"
|
|
3902
3946
|
};
|
|
3903
|
-
/**
|
|
3904
|
-
|
|
3947
|
+
/** Words in a command line that mark a background server, helper or protocol process, not a window. */
|
|
3948
|
+
const SERVER_ARGS = /(?:^|\s)(?:app-server|serve|daemon|mcp|acp|--managed-daemon|--service)(?=\s|$)/i;
|
|
3949
|
+
/**
|
|
3950
|
+
* The program name and the rest of a command line: `"C:\Program Files\x\codex.exe" app-server`
|
|
3951
|
+
* gives { name: "codex", args: "app-server" }. Lowercase, without folders or `.exe`.
|
|
3952
|
+
*/
|
|
3953
|
+
function splitCommand(command) {
|
|
3954
|
+
const line = command.trim();
|
|
3955
|
+
let exe;
|
|
3956
|
+
let rest;
|
|
3957
|
+
const quoted = /^"([^"]*)"\s*(.*)$/.exec(line);
|
|
3958
|
+
if (quoted) {
|
|
3959
|
+
exe = quoted[1] ?? "";
|
|
3960
|
+
rest = quoted[2] ?? "";
|
|
3961
|
+
} else {
|
|
3962
|
+
const m = /^(.*?\.exe)(?:\s+(.*))?$/i.exec(line) ?? /^(\S+)(?:\s+(.*))?$/.exec(line);
|
|
3963
|
+
exe = m?.[1] ?? "";
|
|
3964
|
+
rest = m?.[2] ?? "";
|
|
3965
|
+
}
|
|
3966
|
+
const name = basename(exe.replaceAll("\\", "/")).replace(/\.exe$/i, "").toLowerCase();
|
|
3967
|
+
return name === "" ? void 0 : {
|
|
3968
|
+
name,
|
|
3969
|
+
args: rest
|
|
3970
|
+
};
|
|
3971
|
+
}
|
|
3972
|
+
/**
|
|
3973
|
+
* Which of `clis` have a window-like process running: a process of that name whose command line
|
|
3974
|
+
* is not a server, daemon, helper or protocol process (`codex app-server --managed-daemon`,
|
|
3975
|
+
* `opencode serve --service`). Those outlive every window, so they say nothing about whether the
|
|
3976
|
+
* tool is open.
|
|
3977
|
+
*/
|
|
3978
|
+
function openTools(processes, clis) {
|
|
3979
|
+
const open = /* @__PURE__ */ new Set();
|
|
3980
|
+
for (const p of processes) {
|
|
3981
|
+
if (p.command === void 0) continue;
|
|
3982
|
+
const parts = splitCommand(p.command);
|
|
3983
|
+
if (parts && !SERVER_ARGS.test(parts.args)) open.add(parts.name);
|
|
3984
|
+
}
|
|
3985
|
+
return clis.filter((c) => open.has(PROCESS_NAMES[c]));
|
|
3986
|
+
}
|
|
3987
|
+
async function runningTools(ctx, clis) {
|
|
3905
3988
|
try {
|
|
3906
|
-
const
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
"-A",
|
|
3913
|
-
"-o",
|
|
3914
|
-
"comm="
|
|
3915
|
-
]));
|
|
3916
|
-
if (r.code !== 0) return /* @__PURE__ */ new Set();
|
|
3917
|
-
return new Set(r.stdout.split(/\r?\n/).map((l) => win ? (l.split("\",\"")[0] ?? "").replace(/^"/, "") : l.trim()).filter(Boolean).map((n) => basename(n.replaceAll("\\", "/")).replace(/\.exe$/i, "").toLowerCase()));
|
|
3989
|
+
const io = ctx.processIo ?? {
|
|
3990
|
+
...defaultProcessIo,
|
|
3991
|
+
platform: ctx.platform
|
|
3992
|
+
};
|
|
3993
|
+
const list = await readProcessList(io);
|
|
3994
|
+
return list ? openTools(list, clis) : [];
|
|
3918
3995
|
} catch {
|
|
3919
|
-
return
|
|
3996
|
+
return [];
|
|
3920
3997
|
}
|
|
3921
3998
|
}
|
|
3922
3999
|
const SIGN_IN_FAILED = "Couldn't sign you in. You can try again any time with conveno login.";
|
|
@@ -3928,8 +4005,9 @@ function createOnboardingDeps(ctx) {
|
|
|
3928
4005
|
update: (cli, io) => updateTool(ctx, cli, io),
|
|
3929
4006
|
connect: (cli, accept, io) => changeTool(ctx, cli, fixIdWith(cli, accept), "connect", io),
|
|
3930
4007
|
disconnect: (cli, io) => changeTool(ctx, cli, `uninstall:${cli}`, "remove Conveno from", io),
|
|
3931
|
-
|
|
3932
|
-
|
|
4008
|
+
chosen: () => chosenTools(ctx),
|
|
4009
|
+
saveChoice: async (tools, lead) => {
|
|
4010
|
+
saveChoice(ctx, tools, lead);
|
|
3933
4011
|
},
|
|
3934
4012
|
signedIn: async () => await readAccountTokens(tokenFile(ctx)).catch(() => null) !== null,
|
|
3935
4013
|
signIn: async ({ signal, onCode }) => {
|
|
@@ -3963,8 +4041,13 @@ function createOnboardingDeps(ctx) {
|
|
|
3963
4041
|
}
|
|
3964
4042
|
},
|
|
3965
4043
|
running: async (clis) => {
|
|
3966
|
-
|
|
3967
|
-
|
|
4044
|
+
return runningTools(ctx, clis);
|
|
4045
|
+
},
|
|
4046
|
+
prepareWorkers: async (clis, io) => {
|
|
4047
|
+
return (await warmAcpAdapters(ctx, clis, {
|
|
4048
|
+
onStart: io.start,
|
|
4049
|
+
onLine: io.line
|
|
4050
|
+
}).catch(() => void 0))?.status === "ready";
|
|
3968
4051
|
}
|
|
3969
4052
|
};
|
|
3970
4053
|
}
|
|
@@ -4140,14 +4223,12 @@ const pushLog = (r, lines) => ({
|
|
|
4140
4223
|
function reduce(s, a) {
|
|
4141
4224
|
switch (a.type) {
|
|
4142
4225
|
case "loaded": {
|
|
4143
|
-
const
|
|
4144
|
-
const connected = a.tools.filter((t) => t.connected);
|
|
4145
|
-
const initial = s.start === "tools" && connected.length > 0 ? connected : installed;
|
|
4226
|
+
const known = new Set(a.tools.map((t) => t.cli));
|
|
4146
4227
|
return {
|
|
4147
4228
|
...s,
|
|
4148
4229
|
tools: a.tools,
|
|
4149
4230
|
signedIn: a.signedIn,
|
|
4150
|
-
picked:
|
|
4231
|
+
picked: a.chosen.filter((c) => known.has(c))
|
|
4151
4232
|
};
|
|
4152
4233
|
}
|
|
4153
4234
|
case "begin": return s.step === "welcome" && s.tools ? {
|
|
@@ -4273,6 +4354,7 @@ function reduce(s, a) {
|
|
|
4273
4354
|
return {
|
|
4274
4355
|
...rest,
|
|
4275
4356
|
...a.result.approved === void 0 ? {} : { approved: a.result.approved },
|
|
4357
|
+
...a.result.changed === void 0 ? {} : { changed: a.result.changed },
|
|
4276
4358
|
state: "done",
|
|
4277
4359
|
note: a.result.note ?? (r.kind === "remove" ? "removed" : r.installedNow ? "installed and connected" : "connected")
|
|
4278
4360
|
};
|
|
@@ -4359,6 +4441,27 @@ function reduce(s, a) {
|
|
|
4359
4441
|
...s,
|
|
4360
4442
|
runningTools: a.clis
|
|
4361
4443
|
};
|
|
4444
|
+
case "workersStart": return {
|
|
4445
|
+
...s,
|
|
4446
|
+
workers: {
|
|
4447
|
+
state: "working",
|
|
4448
|
+
log: []
|
|
4449
|
+
}
|
|
4450
|
+
};
|
|
4451
|
+
case "workersLine": return s.workers ? {
|
|
4452
|
+
...s,
|
|
4453
|
+
workers: {
|
|
4454
|
+
...s.workers,
|
|
4455
|
+
log: [...s.workers.log, a.line]
|
|
4456
|
+
}
|
|
4457
|
+
} : s;
|
|
4458
|
+
case "workersDone": return s.workers ? {
|
|
4459
|
+
...s,
|
|
4460
|
+
workers: {
|
|
4461
|
+
...s.workers,
|
|
4462
|
+
state: a.ready ? "done" : "skipped"
|
|
4463
|
+
}
|
|
4464
|
+
} : s;
|
|
4362
4465
|
}
|
|
4363
4466
|
}
|
|
4364
4467
|
/** Show question `index` again, forgetting the answers from there on. */
|
|
@@ -4424,7 +4527,8 @@ function Line({ tone, children }) {
|
|
|
4424
4527
|
const list = (names) => names.length <= 1 ? names[0] ?? "" : `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
|
|
4425
4528
|
function toolHint(t) {
|
|
4426
4529
|
const parts = [];
|
|
4427
|
-
if (!t.installed) parts.push(
|
|
4530
|
+
if (!t.installed && t.connected) parts.push("already connected · not on this computer");
|
|
4531
|
+
else if (!t.installed) parts.push(t.installable ? "not installed · I can install it" : "not installed");
|
|
4428
4532
|
else if (t.connected) parts.push("already connected");
|
|
4429
4533
|
else parts.push("on this computer");
|
|
4430
4534
|
if (t.installed && t.update) parts.push("needs an update");
|
|
@@ -4627,10 +4731,12 @@ function detailLines(rows, width, ascii) {
|
|
|
4627
4731
|
}
|
|
4628
4732
|
return out;
|
|
4629
4733
|
}
|
|
4630
|
-
function DetailsPanel({ rows }) {
|
|
4734
|
+
function DetailsPanel({ rows, workers }) {
|
|
4631
4735
|
const { ascii, c } = useTheme();
|
|
4632
4736
|
const width = useFrameWidth();
|
|
4633
|
-
const
|
|
4737
|
+
const inner = Math.max(10, width - 4);
|
|
4738
|
+
const lines = detailLines(rows, inner, ascii);
|
|
4739
|
+
if (workers.length > 0) lines.push("Getting workers ready", ...workers.map((l) => ` ${cut(l, inner - 2, ascii)}`));
|
|
4634
4740
|
return /* @__PURE__ */ jsx(Panel, {
|
|
4635
4741
|
title: "Details",
|
|
4636
4742
|
width,
|
|
@@ -4675,11 +4781,20 @@ function WorkingStep({ s }) {
|
|
|
4675
4781
|
state: r.state,
|
|
4676
4782
|
...r.note ? { note: w(r.note) } : {}
|
|
4677
4783
|
})) }),
|
|
4784
|
+
s.workers ? /* @__PURE__ */ jsx(Steps, { rows: [{
|
|
4785
|
+
id: "workers",
|
|
4786
|
+
label: "Getting workers ready",
|
|
4787
|
+
state: s.workers.state,
|
|
4788
|
+
...s.workers.state === "done" ? { note: "ready" } : s.workers.state === "skipped" ? { note: "they will download on first use" } : {}
|
|
4789
|
+
}] }) : null,
|
|
4678
4790
|
failed.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Gap, {}), failed.map((r) => /* @__PURE__ */ jsx(Line, {
|
|
4679
4791
|
tone: "error",
|
|
4680
4792
|
children: r.reason ?? "Something went wrong."
|
|
4681
4793
|
}, r.cli))] }) : null,
|
|
4682
|
-
s.showDetails ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Gap, {}), /* @__PURE__ */ jsx(DetailsPanel, {
|
|
4794
|
+
s.showDetails ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Gap, {}), /* @__PURE__ */ jsx(DetailsPanel, {
|
|
4795
|
+
rows: s.rows,
|
|
4796
|
+
workers: s.workers?.log ?? []
|
|
4797
|
+
})] }) : null
|
|
4683
4798
|
]
|
|
4684
4799
|
});
|
|
4685
4800
|
}
|
|
@@ -4746,7 +4861,7 @@ function firstRunApprovals(s) {
|
|
|
4746
4861
|
});
|
|
4747
4862
|
}
|
|
4748
4863
|
function FinishStep({ s }) {
|
|
4749
|
-
const open = connectedRows(s).filter((r) => s.runningTools.includes(r.cli));
|
|
4864
|
+
const open = connectedRows(s).filter((r) => r.changed !== false && s.runningTools.includes(r.cli));
|
|
4750
4865
|
const any = connectedRows(s).length > 0;
|
|
4751
4866
|
const approvals = firstRunApprovals(s);
|
|
4752
4867
|
return /* @__PURE__ */ jsxs(Frame, {
|
|
@@ -4800,18 +4915,27 @@ function Onboarding({ deps, start, onDone }) {
|
|
|
4800
4915
|
}, []);
|
|
4801
4916
|
useEffect(() => {
|
|
4802
4917
|
const d = depsRef.current;
|
|
4803
|
-
Promise.all([
|
|
4918
|
+
Promise.all([
|
|
4919
|
+
d.detect(),
|
|
4920
|
+
d.signedIn().catch(() => false),
|
|
4921
|
+
d.chosen().catch(() => [])
|
|
4922
|
+
]).then(([tools, signedIn, chosen]) => {
|
|
4804
4923
|
if (live.current) dispatch({
|
|
4805
4924
|
type: "loaded",
|
|
4806
4925
|
tools,
|
|
4807
|
-
signedIn
|
|
4926
|
+
signedIn,
|
|
4927
|
+
chosen
|
|
4808
4928
|
});
|
|
4809
4929
|
});
|
|
4810
4930
|
}, []);
|
|
4811
4931
|
useEffect(() => {
|
|
4812
|
-
if (s.step !== "
|
|
4932
|
+
if (s.step !== "account" && s.step !== "finish") return;
|
|
4933
|
+
if (led.current) return;
|
|
4813
4934
|
led.current = true;
|
|
4814
|
-
|
|
4935
|
+
const tools = connectedRows(s).map((r) => r.cli);
|
|
4936
|
+
if (tools.length === 0) return;
|
|
4937
|
+
const lead = s.lead && tools.includes(s.lead) ? s.lead : void 0;
|
|
4938
|
+
depsRef.current.saveChoice(tools, lead).catch(() => {});
|
|
4815
4939
|
}, [s]);
|
|
4816
4940
|
useEffect(() => {
|
|
4817
4941
|
if (s.step !== "working") return;
|
|
@@ -4884,6 +5008,25 @@ function Onboarding({ deps, start, onDone }) {
|
|
|
4884
5008
|
}
|
|
4885
5009
|
})();
|
|
4886
5010
|
}, [s.step, s.rows]);
|
|
5011
|
+
const warmed = useRef(false);
|
|
5012
|
+
useEffect(() => {
|
|
5013
|
+
if (s.step !== "working" || warmed.current) return;
|
|
5014
|
+
warmed.current = true;
|
|
5015
|
+
const clis = s.rows.filter((r) => r.kind === "setup" && r.state !== "skipped").map((r) => r.cli);
|
|
5016
|
+
if (clis.length === 0) return;
|
|
5017
|
+
depsRef.current.prepareWorkers(clis, {
|
|
5018
|
+
start: () => live.current && dispatch({ type: "workersStart" }),
|
|
5019
|
+
line: (line) => live.current && dispatch({
|
|
5020
|
+
type: "workersLine",
|
|
5021
|
+
line
|
|
5022
|
+
})
|
|
5023
|
+
}).catch(() => false).then((ready) => {
|
|
5024
|
+
if (live.current) dispatch({
|
|
5025
|
+
type: "workersDone",
|
|
5026
|
+
ready
|
|
5027
|
+
});
|
|
5028
|
+
});
|
|
5029
|
+
}, [s.step, s.rows]);
|
|
4887
5030
|
useEffect(() => {
|
|
4888
5031
|
if (s.step !== "finish") return;
|
|
4889
5032
|
const clis = connectedRows(s).map((r) => r.cli);
|
|
@@ -5410,6 +5553,10 @@ async function createStore(ctx, opts = {}) {
|
|
|
5410
5553
|
});
|
|
5411
5554
|
set({ sessions: upsert(state.sessions, res.session) });
|
|
5412
5555
|
},
|
|
5556
|
+
async remove(sessionId) {
|
|
5557
|
+
await live()["session.remove"]({ sessionId });
|
|
5558
|
+
set({ sessions: state.sessions.filter((s) => s.id !== sessionId) });
|
|
5559
|
+
},
|
|
5413
5560
|
async spawn(p) {
|
|
5414
5561
|
const c = live();
|
|
5415
5562
|
const runner = ctx.spawnRunner ?? [process.execPath, process.argv[1] ?? "conveno"];
|
|
@@ -5513,6 +5660,7 @@ async function createStore(ctx, opts = {}) {
|
|
|
5513
5660
|
/** `start: "setup"` opens the onboarding at the tool list; otherwise it picks onboarding or home. */
|
|
5514
5661
|
async function runTui(ctx, opts = {}) {
|
|
5515
5662
|
let first;
|
|
5663
|
+
const restarted = await replaceStaleDaemon(ctx);
|
|
5516
5664
|
try {
|
|
5517
5665
|
first = await ctx.connect(connectOpts(ctx, true));
|
|
5518
5666
|
} catch (e) {
|
|
@@ -5563,6 +5711,7 @@ async function runTui(ctx, opts = {}) {
|
|
|
5563
5711
|
input.dispose();
|
|
5564
5712
|
await store.close();
|
|
5565
5713
|
if (farewell) ctx.out(`${farewell}\n`);
|
|
5714
|
+
if (restarted) ctx.out(`${restarted}\n`);
|
|
5566
5715
|
}
|
|
5567
5716
|
}
|
|
5568
5717
|
export { runTui };
|