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 +12 -4
- package/package.json +1 -1
- package/src/langfuse.ts +3 -0
- package/src/types.ts +1 -0
- package/types/pi-coding-agent.d.ts +7 -0
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?:
|
|
77
|
+
const getSessionId = (ctx?: unknown): string | undefined => {
|
|
78
78
|
try {
|
|
79
|
-
const
|
|
80
|
-
|
|
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
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
|
@@ -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(
|