@ramarivera/coding-agent-langfuse 0.1.13 → 0.1.15

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 +11 -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,13 @@ 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
+ model: asString(info.model) ?? currentModel,
426
+ usage,
427
+ });
428
+ if (seenTokenCounts.has(tokenKey))
429
+ continue;
430
+ seenTokenCounts.add(tokenKey);
423
431
  events.push({
424
432
  agent: "codex",
425
433
  sourcePath: path,
@@ -740,10 +748,10 @@ function stableId(input) {
740
748
  return createHash("sha256").update(input).digest("hex").slice(0, 32);
741
749
  }
742
750
  function fingerprint(event) {
743
- return `${importIdentityVersion}:${event.agent}:${event.sourcePath}:${event.sessionId}:${event.recordId}`;
751
+ return `${importIdentityVersion}:${event.agent}:${event.sessionId}:${event.recordId}`;
744
752
  }
745
753
  function traceFingerprint(event) {
746
- return `${importIdentityVersion}:${event.agent}:${event.sourcePath}:${event.sessionId}`;
754
+ return `${importIdentityVersion}:${event.agent}:${event.sessionId}`;
747
755
  }
748
756
  function traceId(event) {
749
757
  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.15",
4
4
  "description": "Universal coding-agent Langfuse backfiller and live OTLP helpers",
5
5
  "type": "module",
6
6
  "license": "MIT",