@kvali/cli 0.7.7 → 0.7.9
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kvali",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.9",
|
|
4
4
|
"description": "Live progress for Claude Code: plan progress, the current step and the time left, what the agent is doing right now, tokens and your plan limits, in a pane beside the chat.",
|
|
5
5
|
"author": { "name": "Giorgi Khiladze" },
|
|
6
6
|
"homepage": "https://github.com/webGrandpa/kvali",
|
package/dist/kvali.mjs
CHANGED
|
@@ -89,6 +89,16 @@ function restOfPlan(typical, spent, left) {
|
|
|
89
89
|
function fmtClock(ms) {
|
|
90
90
|
return new Date(ms).toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
|
|
91
91
|
}
|
|
92
|
+
function limitStopText(stop, now) {
|
|
93
|
+
const what = `Stopped at the ${stop.limit}`;
|
|
94
|
+
if (stop.resetsAt === void 0) return what;
|
|
95
|
+
const when = fmtWhen(stop.resetsAt, now);
|
|
96
|
+
return stop.resetsAt > now ? `${what} \xB7 resets at ${when}` : `${what} \xB7 it reset at ${when}`;
|
|
97
|
+
}
|
|
98
|
+
function fmtWhen(ms, now) {
|
|
99
|
+
if (Math.abs(ms - now) < 20 * 36e5) return fmtClock(ms);
|
|
100
|
+
return `${new Date(ms).toLocaleDateString(void 0, { weekday: "short", day: "numeric", month: "short" })} ${fmtClock(ms)}`;
|
|
101
|
+
}
|
|
92
102
|
function fmtAbout(ms) {
|
|
93
103
|
const m = Math.max(1, Math.round(ms / 6e4));
|
|
94
104
|
return m < 60 ? `~${m}m` : `~${Math.floor(m / 60)}h ${String(m % 60).padStart(2, "0")}m`;
|
|
@@ -1646,6 +1656,106 @@ function loopKey(a) {
|
|
|
1646
1656
|
return a.kind === "command" ? `command:${a.detail ?? a.label}` : `${a.label}:${a.detail ?? ""}`;
|
|
1647
1657
|
}
|
|
1648
1658
|
|
|
1659
|
+
// ../core/src/util/limit-stop.ts
|
|
1660
|
+
var LIMIT_TEXT = /^(?:You've hit your|You've reached your|You're out of usage credits|Claude AI usage limit reached)/i;
|
|
1661
|
+
var LIMIT_NAMES = {
|
|
1662
|
+
five_hour: "5-hour limit",
|
|
1663
|
+
seven_day: "weekly limit",
|
|
1664
|
+
seven_day_opus: "Opus limit",
|
|
1665
|
+
seven_day_sonnet: "Sonnet limit",
|
|
1666
|
+
seven_day_overage_included: "Fable limit",
|
|
1667
|
+
overage: "usage credit limit"
|
|
1668
|
+
};
|
|
1669
|
+
var toMs = (v) => v < 1e12 ? v * 1e3 : v;
|
|
1670
|
+
function limitStopOf(record, text, at) {
|
|
1671
|
+
const t = text.trim();
|
|
1672
|
+
const isLimit = record.apiError === "usage_limit_reached" || LIMIT_TEXT.test(t) || record.error === "rate_limit" && /\blimit\b/i.test(t) && !/rate limited/i.test(t);
|
|
1673
|
+
if (!isLimit) return void 0;
|
|
1674
|
+
const info = record.apiErrorParams?.rate_limit_info;
|
|
1675
|
+
let resetsAt = typeof info?.resetsAt === "number" && info.resetsAt > 0 ? toMs(info.resetsAt) : void 0;
|
|
1676
|
+
resetsAt ??= parseResetsAt(t, at);
|
|
1677
|
+
const named = typeof info?.rateLimitType === "string" ? LIMIT_NAMES[info.rateLimitType] : void 0;
|
|
1678
|
+
const said = /^You've (?:hit|reached) your (.+?)(?:\s+·|\.|$)/i.exec(t)?.[1]?.trim();
|
|
1679
|
+
return { at, limit: named ?? (said && said.length <= 40 ? said : "usage limit"), resetsAt };
|
|
1680
|
+
}
|
|
1681
|
+
var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
|
|
1682
|
+
var DAYS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
|
1683
|
+
function validZone(tz) {
|
|
1684
|
+
if (!tz) return void 0;
|
|
1685
|
+
try {
|
|
1686
|
+
new Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
1687
|
+
return tz;
|
|
1688
|
+
} catch {
|
|
1689
|
+
return void 0;
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
function wall(t, tz) {
|
|
1693
|
+
const parts = new Intl.DateTimeFormat("en-US", {
|
|
1694
|
+
timeZone: tz,
|
|
1695
|
+
hourCycle: "h23",
|
|
1696
|
+
year: "numeric",
|
|
1697
|
+
month: "numeric",
|
|
1698
|
+
day: "numeric",
|
|
1699
|
+
hour: "numeric",
|
|
1700
|
+
minute: "numeric",
|
|
1701
|
+
weekday: "short"
|
|
1702
|
+
}).formatToParts(new Date(t));
|
|
1703
|
+
const get = (type) => parts.find((p2) => p2.type === type)?.value ?? "";
|
|
1704
|
+
return {
|
|
1705
|
+
y: Number(get("year")),
|
|
1706
|
+
mo: Number(get("month")) - 1,
|
|
1707
|
+
d: Number(get("day")),
|
|
1708
|
+
h: Number(get("hour")) % 24,
|
|
1709
|
+
mi: Number(get("minute")),
|
|
1710
|
+
wd: DAYS.indexOf(get("weekday").slice(0, 3).toLowerCase())
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
function instant(y, mo, d, h, mi, tz) {
|
|
1714
|
+
const want = Date.UTC(y, mo, d, h, mi);
|
|
1715
|
+
let t = want;
|
|
1716
|
+
for (let i = 0; i < 3; i += 1) {
|
|
1717
|
+
const w = wall(t, tz);
|
|
1718
|
+
const diff = want - Date.UTC(w.y, w.mo, w.d, w.h, w.mi);
|
|
1719
|
+
if (diff === 0) break;
|
|
1720
|
+
t += diff;
|
|
1721
|
+
}
|
|
1722
|
+
return t;
|
|
1723
|
+
}
|
|
1724
|
+
function parseResetsAt(text, at) {
|
|
1725
|
+
const legacy = /usage limit reached\|(\d{10,13})/i.exec(text);
|
|
1726
|
+
if (legacy) return toMs(Number(legacy[1]));
|
|
1727
|
+
const rel2 = /\bresets?\s+in\s+(?:(\d+)\s*d(?:ays?)?\s*)?(?:(\d+)\s*h(?:ours?|rs?)?\s*)?(?:(\d+)\s*m(?:in(?:ute)?s?)?)?/i.exec(text);
|
|
1728
|
+
if (rel2 && (rel2[1] || rel2[2] || rel2[3])) return at + ((Number(rel2[1] ?? 0) * 24 + Number(rel2[2] ?? 0)) * 60 + Number(rel2[3] ?? 0)) * 6e4;
|
|
1729
|
+
const m = /\bresets?\s+(?:on\s+)?(?:(sun|mon|tue|wed|thu|fri|sat)[a-z]*,?\s+)?(?:(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\.?\s+(\d{1,2})(?:st|nd|rd|th)?,?\s+)?(?:at\s+)?(\d{1,2})(?::(\d{2}))?\s*(am|pm)?(?:\s*\(([^)]+)\))?/i.exec(
|
|
1730
|
+
text
|
|
1731
|
+
);
|
|
1732
|
+
if (!m) return void 0;
|
|
1733
|
+
let h = Number(m[4]);
|
|
1734
|
+
const mi = Number(m[5] ?? 0);
|
|
1735
|
+
const ampm = m[6]?.toLowerCase();
|
|
1736
|
+
if (ampm) {
|
|
1737
|
+
if (h < 1 || h > 12) return void 0;
|
|
1738
|
+
h = h % 12 + (ampm === "pm" ? 12 : 0);
|
|
1739
|
+
} else if (!m[5] || h > 23) {
|
|
1740
|
+
return void 0;
|
|
1741
|
+
}
|
|
1742
|
+
if (mi > 59) return void 0;
|
|
1743
|
+
const tz = validZone(m[7]?.trim()) ?? Intl.DateTimeFormat().resolvedOptions().timeZone ?? "UTC";
|
|
1744
|
+
const now = wall(at, tz);
|
|
1745
|
+
if (m[2]) {
|
|
1746
|
+
const mo = MONTHS.indexOf(m[2].toLowerCase());
|
|
1747
|
+
const d = Number(m[3]);
|
|
1748
|
+
let t2 = instant(now.y, mo, d, h, mi, tz);
|
|
1749
|
+
if (t2 < at - 864e5) t2 = instant(now.y + 1, mo, d, h, mi, tz);
|
|
1750
|
+
return t2;
|
|
1751
|
+
}
|
|
1752
|
+
let days = 0;
|
|
1753
|
+
if (m[1]) days = (DAYS.indexOf(m[1].toLowerCase()) - now.wd + 7) % 7;
|
|
1754
|
+
let t = instant(now.y, now.mo, now.d + days, h, mi, tz);
|
|
1755
|
+
if (t <= at) t = instant(now.y, now.mo, now.d + days + (m[1] ? 7 : 1), h, mi, tz);
|
|
1756
|
+
return t;
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1649
1759
|
// ../core/src/adapters/claude-code.ts
|
|
1650
1760
|
var PULSE_FRESH_MS = 3e4;
|
|
1651
1761
|
var PULSE_ACTIVE = /* @__PURE__ */ new Set(["requesting", "thinking", "writing", "tool-input", "running", "needs-you", "stalled"]);
|
|
@@ -1892,7 +2002,10 @@ var ClaudeCodeAdapter = class {
|
|
|
1892
2002
|
if (st.lastRecordAt === void 0 || ts > st.lastRecordAt) st.lastRecordAt = ts;
|
|
1893
2003
|
}
|
|
1894
2004
|
if (typeof o.version === "string") st.version = o.version;
|
|
1895
|
-
if (typeof o.entrypoint === "string")
|
|
2005
|
+
if (typeof o.entrypoint === "string") {
|
|
2006
|
+
st.entrypoint = o.entrypoint;
|
|
2007
|
+
if (o.entrypoint !== "cli" && /vscode|jetbrains|ide/.test(o.entrypoint)) st.ranInEditor = true;
|
|
2008
|
+
}
|
|
1896
2009
|
if (typeof o.cwd === "string" && o.cwd) {
|
|
1897
2010
|
st.cwd = o.cwd;
|
|
1898
2011
|
st.launchCwd ??= o.cwd;
|
|
@@ -2000,8 +2113,20 @@ var ClaudeCodeAdapter = class {
|
|
|
2000
2113
|
if (typeof m.model === "string" && m.model !== "<synthetic>") st.model = m.model;
|
|
2001
2114
|
st.lastModelAt = ts;
|
|
2002
2115
|
this.countUsage(st, o, ts, ctx, true);
|
|
2003
|
-
if (m.model !== "<synthetic>")
|
|
2116
|
+
if (m.model !== "<synthetic>") {
|
|
2117
|
+
st.trouble = void 0;
|
|
2118
|
+
st.limitStop = void 0;
|
|
2119
|
+
}
|
|
2004
2120
|
if (o.isApiErrorMessage || o.error && m.model === "<synthetic>") {
|
|
2121
|
+
const limit = limitStopOf(o, contentText(m.content), ts);
|
|
2122
|
+
if (limit) {
|
|
2123
|
+
st.limitStop = limit;
|
|
2124
|
+
st.phase = "idle";
|
|
2125
|
+
st.phaseAt = ts;
|
|
2126
|
+
st.open.clear();
|
|
2127
|
+
this.endTurn(st, ts, void 0);
|
|
2128
|
+
return;
|
|
2129
|
+
}
|
|
2005
2130
|
st.phase = "error";
|
|
2006
2131
|
st.phaseAt = ts;
|
|
2007
2132
|
st.errorText = firstLine(contentText(m.content) || "API error", 120);
|
|
@@ -2154,6 +2279,7 @@ var ClaudeCodeAdapter = class {
|
|
|
2154
2279
|
st.turnOpen = true;
|
|
2155
2280
|
st.turnEndedBy = void 0;
|
|
2156
2281
|
st.loops.reset();
|
|
2282
|
+
st.limitStop = void 0;
|
|
2157
2283
|
}
|
|
2158
2284
|
if (!isCommand) {
|
|
2159
2285
|
st.phase = "working";
|
|
@@ -2359,6 +2485,10 @@ var ClaudeCodeAdapter = class {
|
|
|
2359
2485
|
if (beat.phase === "interrupted") detail = "Interrupted";
|
|
2360
2486
|
else if (beat.phase === "error") detail = st.errorText ?? "Stopped with an error";
|
|
2361
2487
|
}
|
|
2488
|
+
if (st.limitStop && status !== "working" && status !== "waiting" && status !== "stale") {
|
|
2489
|
+
status = "idle";
|
|
2490
|
+
detail = limitStopText(st.limitStop, now);
|
|
2491
|
+
}
|
|
2362
2492
|
if (status === "working") {
|
|
2363
2493
|
const stale = staleness(lastSignal, ctx);
|
|
2364
2494
|
if (stale) {
|
|
@@ -2385,8 +2515,10 @@ var ClaudeCodeAdapter = class {
|
|
|
2385
2515
|
model: st.model,
|
|
2386
2516
|
agentVersion: st.version,
|
|
2387
2517
|
host: st.entrypoint === void 0 ? void 0 : st.entrypoint === "cli" ? "terminal" : /vscode|jetbrains|ide/.test(st.entrypoint) ? "editor" : "app",
|
|
2518
|
+
ranInEditor: st.ranInEditor || void 0,
|
|
2388
2519
|
status,
|
|
2389
2520
|
statusDetail: detail,
|
|
2521
|
+
limitStop: st.limitStop && status === "idle" ? { ...st.limitStop } : void 0,
|
|
2390
2522
|
startedAt: st.startedAt,
|
|
2391
2523
|
updatedAt: Math.max(st.updatedAt, live?.at ?? 0),
|
|
2392
2524
|
tasks,
|
|
@@ -3383,8 +3515,9 @@ function parseArgs(raw) {
|
|
|
3383
3515
|
return {};
|
|
3384
3516
|
}
|
|
3385
3517
|
}
|
|
3518
|
+
var SHELL_TOOLS = /^(?:shell|shell_command|exec_command|exec|unified_exec|container\.exec|local_shell)$/;
|
|
3386
3519
|
function describeCodexCall(name, args, at) {
|
|
3387
|
-
if (
|
|
3520
|
+
if (SHELL_TOOLS.test(name)) {
|
|
3388
3521
|
return { kind: "command", label: "Shell", detail: summarizeCommand(args.command ?? args.cmd), startedAt: at };
|
|
3389
3522
|
}
|
|
3390
3523
|
if (name === "apply_patch") return { kind: "tool", label: "Editing files", startedAt: at };
|
|
@@ -3396,9 +3529,14 @@ function describeCodexCall(name, args, at) {
|
|
|
3396
3529
|
}
|
|
3397
3530
|
return { kind: "tool", label: name, startedAt: at };
|
|
3398
3531
|
}
|
|
3532
|
+
var RESUMED_DAYS = 90;
|
|
3533
|
+
var RESUMED_SCAN_MS = 6e4;
|
|
3399
3534
|
var CodexAdapter = class extends JsonlSessionAdapter {
|
|
3400
3535
|
/** The account's plan windows, from every session's readings. */
|
|
3401
3536
|
limitBook = new LimitBook();
|
|
3537
|
+
/** Rollouts in older day folders that were written lately: sessions resumed since they began. */
|
|
3538
|
+
resumed = [];
|
|
3539
|
+
resumedAt = -Infinity;
|
|
3402
3540
|
limits(ctx) {
|
|
3403
3541
|
const windows = this.limitBook.windows(ctx.now());
|
|
3404
3542
|
return windows.length ? { agent: this.id, agentLabel: this.label, windows } : void 0;
|
|
@@ -3418,18 +3556,48 @@ var CodexAdapter = class extends JsonlSessionAdapter {
|
|
|
3418
3556
|
dirs.add(path7.join(root, String(d.getUTCFullYear()), pad(d.getUTCMonth() + 1), pad(d.getUTCDate())));
|
|
3419
3557
|
}
|
|
3420
3558
|
const out = [];
|
|
3559
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3421
3560
|
for (const dir of dirs) {
|
|
3422
3561
|
for (const f of await listDir(dir)) {
|
|
3423
3562
|
if (!f.isFile() || !f.name.startsWith("rollout-") || !f.name.endsWith(".jsonl")) continue;
|
|
3424
3563
|
const file = path7.join(dir, f.name);
|
|
3425
3564
|
const st = await statSafe(file);
|
|
3426
|
-
if (st)
|
|
3565
|
+
if (st) {
|
|
3566
|
+
out.push({ path: file, mtimeMs: st.mtimeMs });
|
|
3567
|
+
seen.add(file);
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
if (now - this.resumedAt >= RESUMED_SCAN_MS) {
|
|
3572
|
+
this.resumedAt = now;
|
|
3573
|
+
const found = [];
|
|
3574
|
+
for (let i = days + 1; i <= RESUMED_DAYS; i += 1) {
|
|
3575
|
+
const d = new Date(now - i * 864e5);
|
|
3576
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
3577
|
+
for (const dir of /* @__PURE__ */ new Set([
|
|
3578
|
+
path7.join(root, String(d.getFullYear()), pad(d.getMonth() + 1), pad(d.getDate())),
|
|
3579
|
+
path7.join(root, String(d.getUTCFullYear()), pad(d.getUTCMonth() + 1), pad(d.getUTCDate()))
|
|
3580
|
+
])) {
|
|
3581
|
+
if (dirs.has(dir)) continue;
|
|
3582
|
+
for (const f of await listDir(dir)) {
|
|
3583
|
+
if (!f.isFile() || !f.name.startsWith("rollout-") || !f.name.endsWith(".jsonl")) continue;
|
|
3584
|
+
const file = path7.join(dir, f.name);
|
|
3585
|
+
const st = await statSafe(file);
|
|
3586
|
+
if (st && now - st.mtimeMs < ctx.activeWindowMs) found.push(file);
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3427
3589
|
}
|
|
3590
|
+
this.resumed = found;
|
|
3591
|
+
}
|
|
3592
|
+
for (const file of this.resumed) {
|
|
3593
|
+
if (seen.has(file)) continue;
|
|
3594
|
+
const st = await statSafe(file);
|
|
3595
|
+
if (st) out.push({ path: file, mtimeMs: st.mtimeMs });
|
|
3428
3596
|
}
|
|
3429
3597
|
return out;
|
|
3430
3598
|
}
|
|
3431
3599
|
createState(file) {
|
|
3432
|
-
const m = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})
|
|
3600
|
+
const m = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})?\.jsonl$/i.exec(file);
|
|
3433
3601
|
const daily = {};
|
|
3434
3602
|
return {
|
|
3435
3603
|
file,
|
|
@@ -3441,6 +3609,7 @@ var CodexAdapter = class extends JsonlSessionAdapter {
|
|
|
3441
3609
|
daily,
|
|
3442
3610
|
tasks: [],
|
|
3443
3611
|
open: /* @__PURE__ */ new Map(),
|
|
3612
|
+
callKeys: /* @__PURE__ */ new Map(),
|
|
3444
3613
|
phase: "idle",
|
|
3445
3614
|
phaseAt: 0,
|
|
3446
3615
|
turns: 0,
|
|
@@ -3473,6 +3642,7 @@ var CodexAdapter = class extends JsonlSessionAdapter {
|
|
|
3473
3642
|
if (typeof p2.originator === "string") st.originator = p2.originator;
|
|
3474
3643
|
else if (typeof p2.source === "string") st.originator = p2.source;
|
|
3475
3644
|
if (p2.parent_thread_id || p2.agent_role || p2.agent_nickname) st.isSubagent = true;
|
|
3645
|
+
if (p2.source && typeof p2.source === "object" && "subagent" in p2.source) st.isSubagent = true;
|
|
3476
3646
|
const started = parseTime(p2.timestamp);
|
|
3477
3647
|
if (started) st.startedAt = Math.min(st.startedAt ?? started, started);
|
|
3478
3648
|
return;
|
|
@@ -3507,11 +3677,13 @@ var CodexAdapter = class extends JsonlSessionAdapter {
|
|
|
3507
3677
|
st.phase = "idle";
|
|
3508
3678
|
st.phaseAt = ts;
|
|
3509
3679
|
st.open.clear();
|
|
3680
|
+
st.callKeys.clear();
|
|
3510
3681
|
return;
|
|
3511
3682
|
case "turn_aborted":
|
|
3512
3683
|
st.phase = "interrupted";
|
|
3513
3684
|
st.phaseAt = ts;
|
|
3514
3685
|
st.open.clear();
|
|
3686
|
+
st.callKeys.clear();
|
|
3515
3687
|
st.loops.reset();
|
|
3516
3688
|
return;
|
|
3517
3689
|
case "error":
|
|
@@ -3521,7 +3693,8 @@ var CodexAdapter = class extends JsonlSessionAdapter {
|
|
|
3521
3693
|
return;
|
|
3522
3694
|
case "user_message":
|
|
3523
3695
|
if (typeof p2.message === "string" && p2.message.trim()) {
|
|
3524
|
-
|
|
3696
|
+
const said = codexPrompt(p2.message);
|
|
3697
|
+
if (said) st.title ??= firstLine(said, 100);
|
|
3525
3698
|
st.loops.reset();
|
|
3526
3699
|
if (st.phase !== "working") {
|
|
3527
3700
|
st.phase = "working";
|
|
@@ -3621,10 +3794,20 @@ var CodexAdapter = class extends JsonlSessionAdapter {
|
|
|
3621
3794
|
return;
|
|
3622
3795
|
}
|
|
3623
3796
|
case "custom_tool_call": {
|
|
3624
|
-
const
|
|
3625
|
-
|
|
3797
|
+
const name = String(p2.name ?? "tool");
|
|
3798
|
+
const input = typeof p2.input === "string" ? p2.input : void 0;
|
|
3799
|
+
const act = describeCodexCall(name, input !== void 0 ? { command: input } : {}, ts);
|
|
3800
|
+
if (typeof p2.call_id === "string") {
|
|
3801
|
+
st.open.set(p2.call_id, act);
|
|
3802
|
+
if (input) st.callKeys.set(p2.call_id, `${act.kind === "command" ? "command" : name}:${input.slice(0, 2e3)}`);
|
|
3803
|
+
}
|
|
3626
3804
|
st.activity = act;
|
|
3627
3805
|
st.turnSteps += 1;
|
|
3806
|
+
if (name !== "update_plan") {
|
|
3807
|
+
st.recent.unshift(act);
|
|
3808
|
+
if (st.recent.length > 6) st.recent.length = 6;
|
|
3809
|
+
st.timer.step();
|
|
3810
|
+
}
|
|
3628
3811
|
return;
|
|
3629
3812
|
}
|
|
3630
3813
|
case "local_shell_call": {
|
|
@@ -3639,9 +3822,13 @@ var CodexAdapter = class extends JsonlSessionAdapter {
|
|
|
3639
3822
|
const done = typeof p2.call_id === "string" ? st.open.get(p2.call_id) : void 0;
|
|
3640
3823
|
if (done) {
|
|
3641
3824
|
done.endedAt = ts;
|
|
3642
|
-
st.
|
|
3825
|
+
const key = st.callKeys.get(p2.call_id) ?? loopKey(done);
|
|
3826
|
+
st.loops.observe(key, done, codexFailure(p2.output), ts, st.tokens ? totalTokens(st.tokens) : void 0);
|
|
3827
|
+
}
|
|
3828
|
+
if (typeof p2.call_id === "string") {
|
|
3829
|
+
st.open.delete(p2.call_id);
|
|
3830
|
+
st.callKeys.delete(p2.call_id);
|
|
3643
3831
|
}
|
|
3644
|
-
if (typeof p2.call_id === "string") st.open.delete(p2.call_id);
|
|
3645
3832
|
st.activity = { kind: "thinking", label: "Thinking", startedAt: ts };
|
|
3646
3833
|
return;
|
|
3647
3834
|
}
|
|
@@ -3652,6 +3839,14 @@ var CodexAdapter = class extends JsonlSessionAdapter {
|
|
|
3652
3839
|
st.activity = { kind: "thinking", label: "Thinking", startedAt: ts };
|
|
3653
3840
|
return;
|
|
3654
3841
|
case "message":
|
|
3842
|
+
if (p2.role === "user") {
|
|
3843
|
+
const said = codexPrompt(contentText(p2.content));
|
|
3844
|
+
if (said) {
|
|
3845
|
+
st.promptTitle ??= firstLine(said, 100);
|
|
3846
|
+
st.loops.reset();
|
|
3847
|
+
}
|
|
3848
|
+
return;
|
|
3849
|
+
}
|
|
3655
3850
|
if (p2.role === "assistant" && contentText(p2.content).trim()) {
|
|
3656
3851
|
st.activity = { kind: "message", label: "Writing a reply", startedAt: ts };
|
|
3657
3852
|
}
|
|
@@ -3693,13 +3888,13 @@ var CodexAdapter = class extends JsonlSessionAdapter {
|
|
|
3693
3888
|
agent: "codex",
|
|
3694
3889
|
agentLabel: this.label,
|
|
3695
3890
|
id: st.id,
|
|
3696
|
-
title: st.title ?? "Untitled session",
|
|
3697
|
-
titleFromPrompt: st.title !== void 0 ? true : void 0,
|
|
3891
|
+
title: st.title ?? st.promptTitle ?? "Untitled session",
|
|
3892
|
+
titleFromPrompt: (st.title ?? st.promptTitle) !== void 0 ? true : void 0,
|
|
3698
3893
|
projectPath: st.cwd ? findGitRoot(st.cwd) ?? st.cwd : void 0,
|
|
3699
3894
|
cwd: st.cwd,
|
|
3700
3895
|
model: st.model,
|
|
3701
3896
|
agentVersion: st.version,
|
|
3702
|
-
host:
|
|
3897
|
+
host: codexHost(st.originator),
|
|
3703
3898
|
status,
|
|
3704
3899
|
statusDetail: detail,
|
|
3705
3900
|
startedAt: st.startedAt,
|
|
@@ -3720,6 +3915,21 @@ var CodexAdapter = class extends JsonlSessionAdapter {
|
|
|
3720
3915
|
};
|
|
3721
3916
|
}
|
|
3722
3917
|
};
|
|
3918
|
+
function codexPrompt(text) {
|
|
3919
|
+
let t = text.trim();
|
|
3920
|
+
const req = /^#{1,3}\s*My request for Codex:?[ \t]*$/im.exec(t);
|
|
3921
|
+
if (req) t = t.slice(req.index + req[0].length).trim();
|
|
3922
|
+
else if (/^#\s*Context from my IDE setup/i.test(t)) return void 0;
|
|
3923
|
+
if (!t || t.startsWith("<") || /^#\s*AGENTS\.md\b/i.test(t)) return void 0;
|
|
3924
|
+
return t;
|
|
3925
|
+
}
|
|
3926
|
+
function codexHost(originator) {
|
|
3927
|
+
if (originator === void 0) return void 0;
|
|
3928
|
+
if (/desktop/i.test(originator)) return "app";
|
|
3929
|
+
if (/vscode|ide/.test(originator)) return "editor";
|
|
3930
|
+
if (/exec|mcp|sdk/.test(originator)) return "app";
|
|
3931
|
+
return "terminal";
|
|
3932
|
+
}
|
|
3723
3933
|
function loopOf(st, status, now) {
|
|
3724
3934
|
const l = status === "working" || status === "stale" ? st.loops.current(now) : void 0;
|
|
3725
3935
|
if (!l) return void 0;
|
|
@@ -4623,9 +4833,9 @@ function todosOf(list) {
|
|
|
4623
4833
|
if (!Array.isArray(list)) return void 0;
|
|
4624
4834
|
return list.filter((t) => t && typeof t.content === "string" && t.content.trim()).map((t, i) => ({ id: typeof t.id === "string" ? t.id : String(i + 1), title: t.content.trim(), status: todoStatus3(t.status) }));
|
|
4625
4835
|
}
|
|
4626
|
-
var
|
|
4836
|
+
var SHELL_TOOLS2 = /* @__PURE__ */ new Set(["shell", "bash"]);
|
|
4627
4837
|
function toolAct(name, input, at) {
|
|
4628
|
-
if (
|
|
4838
|
+
if (SHELL_TOOLS2.has(name)) return { kind: "command", label: "Shell", detail: summarizeCommand(input.command), startedAt: at };
|
|
4629
4839
|
const file = typeof input.filePath === "string" ? input.filePath : typeof input.path === "string" ? input.path : void 0;
|
|
4630
4840
|
const short = (p2) => p2 ? truncate(p2, 80) : void 0;
|
|
4631
4841
|
switch (name) {
|
|
@@ -4664,7 +4874,7 @@ function failureOf(name, state, contentText2) {
|
|
|
4664
4874
|
const e = state.error;
|
|
4665
4875
|
return typeof e === "string" ? e : typeof e?.message === "string" ? e.message : "Tool error";
|
|
4666
4876
|
}
|
|
4667
|
-
if (state.status !== "completed" || !
|
|
4877
|
+
if (state.status !== "completed" || !SHELL_TOOLS2.has(name)) return void 0;
|
|
4668
4878
|
const m = state.metadata ?? {};
|
|
4669
4879
|
if (m.timeout === true) return `Timed out
|
|
4670
4880
|
${contentText2()}`;
|
|
@@ -8819,7 +9029,7 @@ function qrTerminal(text, color = true) {
|
|
|
8819
9029
|
}
|
|
8820
9030
|
|
|
8821
9031
|
// src/index.ts
|
|
8822
|
-
var VERSION = "0.7.
|
|
9032
|
+
var VERSION = "0.7.9";
|
|
8823
9033
|
function parse(argv) {
|
|
8824
9034
|
const opts = {
|
|
8825
9035
|
json: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kvali/cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.9",
|
|
4
4
|
"description": "Live progress, time left, tokens, plan limits and phone alerts for AI coding agents (Claude Code, Codex, Gemini CLI, Antigravity, Copilot, Cline, Roo Code, Kilo Code, OpenCode), in your terminal.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Giorgi Khiladze (https://github.com/webGrandpa)",
|