@ramarivera/coding-agent-langfuse 0.1.20 → 0.1.21

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.
@@ -62,7 +62,11 @@ declare function codexEvents(homeDir: string): BackfillEvent[];
62
62
  declare function claudeEvents(homeDir: string): BackfillEvent[];
63
63
  declare function piEvents(homeDir: string): BackfillEvent[];
64
64
  declare function grokEvents(homeDir: string): BackfillEvent[];
65
- declare function opencodeEvents(homeDir: string, rowLimit?: number): BackfillEvent[];
65
+ declare function opencodeEvents(homeDir: string, options?: {
66
+ rowLimit?: number;
67
+ sinceMs?: number;
68
+ untilMs?: number;
69
+ }): BackfillEvent[];
66
70
  declare function fingerprint(event: BackfillEvent): string;
67
71
  declare function toOtlp(events: BackfillEvent[]): Record<string, unknown>;
68
72
  declare function discoverEvents(options: BackfillOptions): BackfillEvent[];
package/dist/backfill.js CHANGED
@@ -659,15 +659,16 @@ function grokEvents(homeDir) {
659
659
  const files = listFiles(join(homeDir, ".grok/sessions"), (path) => path.endsWith("chat_history.jsonl"));
660
660
  return genericJsonlEvents("grok", files, "grok session");
661
661
  }
662
- function opencodeEvents(homeDir, rowLimit) {
662
+ function opencodeEvents(homeDir, options = {}) {
663
663
  const db = join(homeDir, ".local/share/opencode/opencode.db");
664
664
  if (!existsSync(db))
665
665
  return [];
666
+ const timeWhere = sqliteTimeWhere(options.sinceMs, options.untilMs);
666
667
  let sessions = [];
667
668
  let messages = [];
668
669
  let parts = [];
669
670
  try {
670
- sessions = sqliteJsonByRowid(db, "session", "id, directory, time_created, time_updated, title, version, slug, project_id", undefined, rowLimit, 5_000);
671
+ sessions = sqliteJsonByRowid(db, "session", "id, directory, time_created, time_updated, title, version, slug, project_id", undefined, options.rowLimit, 5_000);
671
672
  messages = sqliteJsonByRowid(db, "message", [
672
673
  "id",
673
674
  "session_id",
@@ -686,7 +687,7 @@ function opencodeEvents(homeDir, rowLimit) {
686
687
  "json_extract(data, '$.agent') as agent",
687
688
  "json_extract(data, '$.mode') as mode",
688
689
  "json_extract(data, '$.error') as error",
689
- ].join(", "), undefined, rowLimit, 5_000);
690
+ ].join(", "), timeWhere, options.rowLimit, 5_000);
690
691
  parts = sqliteJsonByRowid(db, "part", [
691
692
  "id",
692
693
  "message_id",
@@ -695,7 +696,7 @@ function opencodeEvents(homeDir, rowLimit) {
695
696
  "time_updated",
696
697
  "json_extract(data, '$.type') as type",
697
698
  "json_extract(data, '$') as data",
698
- ].join(", "), undefined, rowLimit, 5_000);
699
+ ].join(", "), timeWhere, options.rowLimit, 5_000);
699
700
  }
700
701
  catch (error) {
701
702
  console.error(`Skipping OpenCode history from ${db}: ${error instanceof Error ? error.message : String(error)}`);
@@ -815,6 +816,13 @@ function opencodeEvents(homeDir, rowLimit) {
815
816
  }
816
817
  return events;
817
818
  }
819
+ function sqliteTimeWhere(sinceMs, untilMs) {
820
+ const conditions = [
821
+ sinceMs === undefined ? undefined : `time_created >= ${Math.trunc(sinceMs)}`,
822
+ untilMs === undefined ? undefined : `time_created <= ${Math.trunc(untilMs)}`,
823
+ ].filter((condition) => Boolean(condition));
824
+ return conditions.length > 0 ? conditions.join(" and ") : undefined;
825
+ }
818
826
  function opencodeTextFromParts(parts) {
819
827
  const text = parts
820
828
  .map((part) => {
@@ -1247,7 +1255,11 @@ function discoverEvents(options) {
1247
1255
  claude: (inner) => claudeEvents(inner.homeDir),
1248
1256
  codex: (inner) => codexEvents(inner.homeDir),
1249
1257
  grok: (inner) => grokEvents(inner.homeDir),
1250
- opencode: (inner) => opencodeEvents(inner.homeDir, inner.limit),
1258
+ opencode: (inner) => opencodeEvents(inner.homeDir, {
1259
+ rowLimit: inner.limit,
1260
+ sinceMs: inner.sinceMs,
1261
+ untilMs: inner.untilMs,
1262
+ }),
1251
1263
  pi: (inner) => piEvents(inner.homeDir),
1252
1264
  };
1253
1265
  return allAgents
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramarivera/coding-agent-langfuse",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "Universal coding-agent Langfuse backfiller and live OTLP helpers",
5
5
  "type": "module",
6
6
  "license": "MIT",