pi-langfuse 1.5.9 → 1.5.10

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.
package/index.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  import { basename } from "node:path";
11
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
11
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
12
12
 
13
13
  import { state, resetRunState, runWithSession, setCurrentSession } from "./src/state.js";
14
14
  import { ensureConfig, promptForConfig, loadConfig } from "./src/config.js";
@@ -74,10 +74,18 @@ export default async function (pi: ExtensionAPI) {
74
74
  },
75
75
  });
76
76
 
77
- const getSessionId = (ctx?: any) => {
77
+ const getSessionId = (ctx?: unknown): string | undefined => {
78
78
  try {
79
- const sessionFile = ctx?.sessionManager?.getSessionFile?.();
80
- return sessionFile ? basename(sessionFile, ".jsonl") : undefined;
79
+ const sessionManager = (ctx as ExtensionContext | undefined)?.sessionManager;
80
+ const sessionId = sessionManager?.getSessionId?.();
81
+ if (typeof sessionId === "string" && sessionId) {
82
+ return sessionId;
83
+ }
84
+
85
+ const sessionFile = sessionManager?.getSessionFile?.();
86
+ return typeof sessionFile === "string" && sessionFile
87
+ ? basename(sessionFile, ".jsonl")
88
+ : undefined;
81
89
  } catch {
82
90
  return undefined;
83
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-langfuse",
3
- "version": "1.5.9",
3
+ "version": "1.5.10",
4
4
  "description": "Langfuse extension for Pi coding agent",
5
5
  "repository": {
6
6
  "type": "git",
package/src/langfuse.ts CHANGED
@@ -219,6 +219,9 @@ async function flushPendingScores(rt: LangfuseRuntime, signal: AbortSignal): Pro
219
219
 
220
220
  while (pendingScores.length > 0) {
221
221
  const scores = pendingScores.slice(0, MAX_SCORE_BATCH_SIZE);
222
+ for (const score of scores) {
223
+ score.id ??= randomUUID();
224
+ }
222
225
  try {
223
226
  const errors = await ingestBatch(
224
227
  rt,
package/src/types.ts CHANGED
@@ -60,6 +60,7 @@ export interface LangfuseScoreClient {
60
60
  }
61
61
 
62
62
  export interface PendingScore {
63
+ id?: string;
63
64
  traceId?: string;
64
65
  sessionId?: string;
65
66
  observationId?: string;
@@ -1,4 +1,11 @@
1
1
  declare module "@earendil-works/pi-coding-agent" {
2
+ export interface ExtensionContext {
3
+ sessionManager?: {
4
+ getSessionId?: () => unknown;
5
+ getSessionFile?: () => unknown;
6
+ };
7
+ }
8
+
2
9
  export interface ExtensionAPI {
3
10
  on(event: string, handler: (event: any, ctx: any) => unknown): void;
4
11
  registerCommand(