agent-insights 0.0.18 → 0.0.19

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/dist/cli.js CHANGED
@@ -817,6 +817,7 @@ function asString(v) {
817
817
  }
818
818
 
819
819
  // src/adapters/codex.ts
820
+ import { readdirSync } from "fs";
820
821
  import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
821
822
  import { homedir as homedir3 } from "os";
822
823
  import { dirname as dirname3, join as join3 } from "path";
@@ -841,7 +842,7 @@ var codexAdapter = {
841
842
  const data = payload.data ?? {};
842
843
  const sessionId = asString2(data["session_id"]) ?? asString2(data["sessionId"]);
843
844
  const toolName = asString2(data["tool_name"]) ?? asString2(data["toolName"]) ?? asString2(data["tool"]?.["name"]);
844
- const transcriptPath = asString2(data["transcript_path"]) ?? asString2(data["transcriptPath"]);
845
+ const transcriptPath = asString2(data["transcript_path"]) ?? asString2(data["transcriptPath"]) ?? (type === "session.end" && sessionId ? findCodexTranscript(sessionId, defaultSessionsRoot()) : void 0);
845
846
  return {
846
847
  type,
847
848
  ...sessionId !== void 0 ? { sessionId } : {},
@@ -966,6 +967,49 @@ async function readJson2(path) {
966
967
  function asString2(v) {
967
968
  return typeof v === "string" && v.length > 0 ? v : void 0;
968
969
  }
970
+ function defaultSessionsRoot() {
971
+ return join3(homedir3(), ".codex", "sessions");
972
+ }
973
+ function findCodexTranscript(sessionId, root) {
974
+ const suffix = `-${sessionId}.jsonl`;
975
+ const MAX_DAYS = 7;
976
+ let scanned = 0;
977
+ let years;
978
+ try {
979
+ years = readdirSync(root).filter((s) => /^\d{4}$/.test(s)).sort().reverse();
980
+ } catch {
981
+ return void 0;
982
+ }
983
+ for (const y of years) {
984
+ let months;
985
+ try {
986
+ months = readdirSync(join3(root, y)).filter((s) => /^\d{2}$/.test(s)).sort().reverse();
987
+ } catch {
988
+ continue;
989
+ }
990
+ for (const m of months) {
991
+ let days;
992
+ try {
993
+ days = readdirSync(join3(root, y, m)).filter((s) => /^\d{2}$/.test(s)).sort().reverse();
994
+ } catch {
995
+ continue;
996
+ }
997
+ for (const d of days) {
998
+ if (++scanned > MAX_DAYS) return void 0;
999
+ const dir = join3(root, y, m, d);
1000
+ let files;
1001
+ try {
1002
+ files = readdirSync(dir);
1003
+ } catch {
1004
+ continue;
1005
+ }
1006
+ const match = files.find((f) => f.endsWith(suffix));
1007
+ if (match) return join3(dir, match);
1008
+ }
1009
+ }
1010
+ }
1011
+ return void 0;
1012
+ }
969
1013
 
970
1014
  // src/adapters/cursor.ts
971
1015
  import { mkdir as mkdir4, readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
@@ -1953,7 +1997,7 @@ function yn(v) {
1953
1997
  var program = new Command();
1954
1998
  program.name("agent-insights").description(
1955
1999
  "Internal CLI for AI coding agent observability (Claude Code, Cursor)."
1956
- ).version("0.0.18");
2000
+ ).version("0.0.19");
1957
2001
  program.command("login").description("Authenticate with Vercel (Sign in with Vercel).").action(async () => {
1958
2002
  await runLogin();
1959
2003
  });