@ramarivera/coding-agent-langfuse 0.1.22 → 0.1.23

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 +35 -4
  2. package/package.json +1 -1
package/dist/backfill.js CHANGED
@@ -698,7 +698,17 @@ function opencodeEvents(homeDir, options = {}) {
698
698
  "time_created",
699
699
  "time_updated",
700
700
  "json_extract(data, '$.type') as type",
701
- "json_extract(data, '$') as data",
701
+ "substr(json_extract(data, '$.text'), 1, 8000) as text",
702
+ "json_extract(data, '$.tool') as tool",
703
+ "json_extract(data, '$.callID') as call_id_upper",
704
+ "json_extract(data, '$.call_id') as call_id",
705
+ "substr(json_extract(data, '$.state.input'), 1, 8000) as state_input",
706
+ "substr(json_extract(data, '$.state.output'), 1, 8000) as state_output",
707
+ "json_extract(data, '$.state.status') as state_status",
708
+ "json_extract(data, '$.state.title') as state_title",
709
+ "json_type(data, '$.metadata.openai.reasoningEncryptedContent') is not null as has_encrypted_content",
710
+ "json_extract(data, '$.filename') as filename",
711
+ "json_extract(data, '$.url') as url",
702
712
  ].join(", "), 500);
703
713
  }
704
714
  catch (error) {
@@ -765,7 +775,7 @@ function opencodeEvents(homeDir, options = {}) {
765
775
  metadata: pick(message, ["agent", "mode", "error"]),
766
776
  });
767
777
  for (const part of messageParts) {
768
- const data = asRecord(parseMaybeJson(part.data));
778
+ const data = opencodePartData(part);
769
779
  const type = asString(part.type) ?? asString(data.type);
770
780
  const partId = asString(part.id) ?? stableId(JSON.stringify(part));
771
781
  const partStartMs = getTimestampMs(part.time_created, getTimestampMs(message.time_created));
@@ -786,7 +796,7 @@ function opencodeEvents(homeDir, options = {}) {
786
796
  parentRecordId: messageId,
787
797
  output: extractText(data.text),
788
798
  metadata: {
789
- has_encrypted_content: getPath(data, ["metadata", "openai", "reasoningEncryptedContent"]) !== undefined,
799
+ has_encrypted_content: Boolean(data.has_encrypted_content),
790
800
  },
791
801
  });
792
802
  }
@@ -843,7 +853,7 @@ function sqliteQuote(value) {
843
853
  function opencodeTextFromParts(parts) {
844
854
  const text = parts
845
855
  .map((part) => {
846
- const data = asRecord(parseMaybeJson(part.data));
856
+ const data = opencodePartData(part);
847
857
  const type = asString(part.type) ?? asString(data.type);
848
858
  if (type === "text")
849
859
  return extractText(data.text, 8000);
@@ -860,6 +870,27 @@ function opencodeTextFromParts(parts) {
860
870
  .join("\n");
861
871
  return text ? text.slice(0, 8000) : undefined;
862
872
  }
873
+ function opencodePartData(part) {
874
+ const data = asRecord(parseMaybeJson(part.data));
875
+ if (Object.keys(data).length > 0)
876
+ return data;
877
+ return {
878
+ type: part.type,
879
+ text: part.text,
880
+ tool: part.tool,
881
+ callID: part.call_id_upper,
882
+ call_id: part.call_id,
883
+ state: {
884
+ input: parseMaybeJson(part.state_input),
885
+ output: parseMaybeJson(part.state_output),
886
+ status: part.state_status,
887
+ title: part.state_title,
888
+ },
889
+ has_encrypted_content: Boolean(part.has_encrypted_content),
890
+ filename: part.filename,
891
+ url: part.url,
892
+ };
893
+ }
863
894
  function sqliteJson(db, sql) {
864
895
  const output = execFileSync("sqlite3", ["-readonly", "-json", db, sql], {
865
896
  encoding: "utf8",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramarivera/coding-agent-langfuse",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "Universal coding-agent Langfuse backfiller and live OTLP helpers",
5
5
  "type": "module",
6
6
  "license": "MIT",