fix(grok): improve skills, plans, usage, and turn reliability (#8358)

Co-authored-by: Dara Adedeji <[email protected]>
Co-authored-by: Ahmed Besic <[email protected]>
Co-authored-by: Michael Brown <[email protected]>
Co-authored-by: Lars Nieuwenhuis <[email protected]>
Co-authored-by: Guilherme Barros <[email protected]>
Co-authored-by: PC <pc@localhost>
Co-authored-by: 1xpixi <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-08-26 23:57:46 -07:00
1 parent d3c24a14b9
commit ead4ce52a1
33 files changed
+3860 -146

No files matched your search

+18 -1
View File
@@ -22,6 +22,7 @@ import {
mightCarryUsage,
parseClaudeLine,
parseCodexLine,
parseGrokLine,
type UsageRecord,
} from "./usageTranscripts.ts";
@@ -37,12 +38,18 @@ export interface TranscriptFile {
* Errors on individual entries are swallowed: session files rotate and get
* removed while the walk is in flight, and a partial listing is far better than
* failing the page.
*
* `fileName` restricts the walk to a single basename (Grok's `updates.jsonl`).
* Grok sessions also ship multi-megabyte `chat_history` and `events` logs that
* never carry usage, so the basename filter keeps a cold scan off those files.
*/
export async function listTranscriptFiles(
root: string,
sinceMs: number,
options?: { readonly fileName?: string },
): Promise<readonly TranscriptFile[]> {
const found: TranscriptFile[] = [];
const fileName = options?.fileName;
const walk = async (dir: string): Promise<void> => {
let entries;
@@ -57,7 +64,11 @@ export async function listTranscriptFiles(
await walk(child);
continue;
}
if (!entry.name.endsWith(".jsonl")) continue;
if (fileName !== undefined) {
if (entry.name !== fileName) continue;
} else if (!entry.name.endsWith(".jsonl")) {
continue;
}
try {
const stats = await NodeFSP.stat(child);
if (stats.mtimeMs >= sinceMs) {
@@ -129,6 +140,12 @@ export async function readTranscriptRecords(
continue;
}
if (provider === "grok") {
if (!mightCarryUsage(line, provider)) continue;
for (const grokRecord of parseGrokLine(line)) records.push(grokRecord);
continue;
}
if (!mightCarryUsage(line, provider)) continue;
const record = parseClaudeLine(line);
if (record !== null) records.push(record);