@ramarivera/coding-agent-langfuse 0.1.21 → 0.1.22

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 +19 -2
  2. package/package.json +1 -1
package/dist/backfill.js CHANGED
@@ -688,7 +688,10 @@ function opencodeEvents(homeDir, options = {}) {
688
688
  "json_extract(data, '$.mode') as mode",
689
689
  "json_extract(data, '$.error') as error",
690
690
  ].join(", "), timeWhere, options.rowLimit, 5_000);
691
- parts = sqliteJsonByRowid(db, "part", [
691
+ const messageIds = messages
692
+ .map((message) => asString(message.id))
693
+ .filter((id) => Boolean(id));
694
+ parts = sqliteJsonForIds(db, "part", "message_id", messageIds, [
692
695
  "id",
693
696
  "message_id",
694
697
  "session_id",
@@ -696,7 +699,7 @@ function opencodeEvents(homeDir, options = {}) {
696
699
  "time_updated",
697
700
  "json_extract(data, '$.type') as type",
698
701
  "json_extract(data, '$') as data",
699
- ].join(", "), timeWhere, options.rowLimit, 5_000);
702
+ ].join(", "), 500);
700
703
  }
701
704
  catch (error) {
702
705
  console.error(`Skipping OpenCode history from ${db}: ${error instanceof Error ? error.message : String(error)}`);
@@ -823,6 +826,20 @@ function sqliteTimeWhere(sinceMs, untilMs) {
823
826
  ].filter((condition) => Boolean(condition));
824
827
  return conditions.length > 0 ? conditions.join(" and ") : undefined;
825
828
  }
829
+ function sqliteJsonForIds(db, table, idColumn, ids, columns, pageSize) {
830
+ const rows = [];
831
+ for (let index = 0; index < ids.length; index += pageSize) {
832
+ const pageIds = ids.slice(index, index + pageSize);
833
+ if (pageIds.length === 0)
834
+ continue;
835
+ const quotedIds = pageIds.map(sqliteQuote).join(", ");
836
+ rows.push(...sqliteJson(db, `select ${columns} from ${table} where ${idColumn} in (${quotedIds}) order by rowid;`));
837
+ }
838
+ return rows;
839
+ }
840
+ function sqliteQuote(value) {
841
+ return `'${value.replaceAll("'", "''")}'`;
842
+ }
826
843
  function opencodeTextFromParts(parts) {
827
844
  const text = parts
828
845
  .map((part) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramarivera/coding-agent-langfuse",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "Universal coding-agent Langfuse backfiller and live OTLP helpers",
5
5
  "type": "module",
6
6
  "license": "MIT",