@ramarivera/coding-agent-langfuse 0.1.13 → 0.1.14

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.
Files changed (2) hide show
  1. package/dist/backfill.js +12 -3
  2. package/package.json +1 -1
package/dist/backfill.js CHANGED
@@ -5,7 +5,7 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSy
5
5
  import { homedir } from "node:os";
6
6
  import { dirname, join } from "node:path";
7
7
  const allAgents = ["claude", "codex", "grok", "opencode", "pi"];
8
- const importIdentityVersion = "v6-session-traces-with-generations-and-costs";
8
+ const importIdentityVersion = "v7-host-independent-session-traces";
9
9
  const defaultEndpoint = "https://langfuse.ai.roxasroot.net/otel/v1/traces";
10
10
  const deadRemoteEndpoint = "http://langfuse.ai.roxasroot.net:14318/v1/traces";
11
11
  const defaultStatePath = join(homedir(), ".local/state/coding-agent-langfuse/backfill-v6.json");
@@ -345,6 +345,7 @@ function codexEvents(homeDir) {
345
345
  asString(getPath(payload, ["model"]));
346
346
  let currentModel = model;
347
347
  let currentCwd = cwd;
348
+ const seenTokenCounts = new Set();
348
349
  const events = [
349
350
  {
350
351
  agent: "codex",
@@ -420,6 +421,14 @@ function codexEvents(homeDir) {
420
421
  const info = asRecord(rowPayload.info);
421
422
  const usage = normalizeUsage(asRecord(info.last_token_usage)) ??
422
423
  normalizeUsage(asRecord(info.total_token_usage));
424
+ const tokenKey = JSON.stringify({
425
+ timestamp,
426
+ model: asString(info.model) ?? currentModel,
427
+ usage,
428
+ });
429
+ if (seenTokenCounts.has(tokenKey))
430
+ continue;
431
+ seenTokenCounts.add(tokenKey);
423
432
  events.push({
424
433
  agent: "codex",
425
434
  sourcePath: path,
@@ -740,10 +749,10 @@ function stableId(input) {
740
749
  return createHash("sha256").update(input).digest("hex").slice(0, 32);
741
750
  }
742
751
  function fingerprint(event) {
743
- return `${importIdentityVersion}:${event.agent}:${event.sourcePath}:${event.sessionId}:${event.recordId}`;
752
+ return `${importIdentityVersion}:${event.agent}:${event.sessionId}:${event.recordId}`;
744
753
  }
745
754
  function traceFingerprint(event) {
746
- return `${importIdentityVersion}:${event.agent}:${event.sourcePath}:${event.sessionId}`;
755
+ return `${importIdentityVersion}:${event.agent}:${event.sessionId}`;
747
756
  }
748
757
  function traceId(event) {
749
758
  return stableId(traceFingerprint(event));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramarivera/coding-agent-langfuse",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Universal coding-agent Langfuse backfiller and live OTLP helpers",
5
5
  "type": "module",
6
6
  "license": "MIT",