@ramarivera/coding-agent-langfuse 0.1.40 → 0.1.41

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.
@@ -63,7 +63,9 @@ type FollowSummary = RunSummary & {
63
63
  declare const allAgents: AgentName[];
64
64
  declare const defaultEndpoint = "https://langfuse.ai.roxasroot.net/otel/v1/traces";
65
65
  declare function parseArgs(argv: string[]): BackfillOptions;
66
- declare function codexEvents(homeDir: string): BackfillEvent[];
66
+ declare function codexEvents(homeDir: string, options?: {
67
+ sinceMs?: number;
68
+ }): BackfillEvent[];
67
69
  declare function claudeEvents(homeDir: string): BackfillEvent[];
68
70
  declare function piEvents(homeDir: string): BackfillEvent[];
69
71
  declare function grokEvents(homeDir: string): BackfillEvent[];
package/dist/backfill.js CHANGED
@@ -235,7 +235,7 @@ function listFiles(root, predicate) {
235
235
  }
236
236
  if (stat.isDirectory())
237
237
  stack.push(path);
238
- else if (stat.isFile() && predicate(path))
238
+ else if (stat.isFile() && predicate(path, stat))
239
239
  out.push(path);
240
240
  }
241
241
  }
@@ -378,8 +378,28 @@ function isGenerationEvent(event) {
378
378
  return event.usage !== undefined && event.role !== "user" &&
379
379
  event.role !== "developer" && event.role !== "system";
380
380
  }
381
- function codexEvents(homeDir) {
382
- const files = listFiles(join(homeDir, ".codex/sessions"), (path) => path.endsWith(".jsonl"));
381
+ function codexSessionPathTimeMs(path) {
382
+ const rolloutMatch = path.match(/rollout-(\d{4})-(\d{2})-(\d{2})T(\d{2})-(\d{2})-(\d{2})/);
383
+ if (rolloutMatch) {
384
+ const [, year, month, day, hour, minute, second] = rolloutMatch;
385
+ return Date.UTC(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute), Number(second));
386
+ }
387
+ const folderMatch = path.match(/[\\/]sessions[\\/](\d{4})[\\/](\d{2})[\\/](\d{2})[\\/]/);
388
+ if (!folderMatch)
389
+ return undefined;
390
+ const [, year, month, day] = folderMatch;
391
+ return Date.UTC(Number(year), Number(month) - 1, Number(day));
392
+ }
393
+ function fileMayContainCodexWindow(path, stat, options) {
394
+ if (options.sinceMs === undefined)
395
+ return true;
396
+ if (stat.mtimeMs >= options.sinceMs)
397
+ return true;
398
+ const pathTimeMs = codexSessionPathTimeMs(path);
399
+ return pathTimeMs === undefined || pathTimeMs >= options.sinceMs;
400
+ }
401
+ function codexEvents(homeDir, options = {}) {
402
+ const files = listFiles(join(homeDir, ".codex/sessions"), (path, stat) => path.endsWith(".jsonl") && fileMayContainCodexWindow(path, stat, options));
383
403
  const seenTokenCounts = new Set();
384
404
  return files.flatMap((path) => {
385
405
  const rows = parseJsonl(path).map(asRecord);
@@ -1388,7 +1408,7 @@ function describeError(error) {
1388
1408
  function discoverEvents(options) {
1389
1409
  const providers = {
1390
1410
  claude: (inner) => claudeEvents(inner.homeDir),
1391
- codex: (inner) => codexEvents(inner.homeDir),
1411
+ codex: (inner) => codexEvents(inner.homeDir, { sinceMs: inner.sinceMs }),
1392
1412
  grok: (inner) => grokEvents(inner.homeDir),
1393
1413
  opencode: (inner) => opencodeEvents(inner.homeDir, {
1394
1414
  rowLimit: inner.limit,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramarivera/coding-agent-langfuse",
3
- "version": "0.1.40",
3
+ "version": "0.1.41",
4
4
  "description": "Universal coding-agent Langfuse backfiller and live OTLP helpers",
5
5
  "type": "module",
6
6
  "license": "MIT",