fix(omp): support Windows session paths (#2092)

This commit is contained in:
Wiedzmin
2026-07-30 21:44:25 +03:00
committed by GitHub
parent ac47b9e679
commit a07871a55e
3 changed files with 22 additions and 4 deletions
@@ -227,6 +227,17 @@ for (const integration of integrations) {
});
}
test("OMP accepts POSIX and Windows session paths", async () => {
const { isAbsoluteSessionPath } = await importFresh("./omp/herdr-agent-state.ts");
expect(isAbsoluteSessionPath("/tmp/omp-session.jsonl")).toBe(true);
expect(isAbsoluteSessionPath("C:\\Users\\User\\.omp\\agent\\sessions\\omp-session.jsonl")).toBe(
true,
);
expect(isAbsoluteSessionPath("C:/Users/User/.omp/agent/sessions/omp-session.jsonl")).toBe(true);
expect(isAbsoluteSessionPath("relative/omp-session.jsonl")).toBe(false);
});
test("Pi reports idle only after the agent settles", async () => {
const requests = await startRecordingServer("pi-settled");
const { handlers, pi } = createExtensionHarness();
@@ -2,10 +2,11 @@
// managed by herdr; reinstalling or updating the integration overwrites this file.
// add custom hooks/plugins beside this file instead of editing it.
// HERDR_INTEGRATION_ID=omp
// HERDR_INTEGRATION_VERSION=7
// HERDR_INTEGRATION_VERSION=8
// @ts-nocheck
import net from "node:net";
import path from "node:path";
const HERDR_ENV = process.env.HERDR_ENV;
const socketPath = process.env.HERDR_SOCKET_PATH;
@@ -84,11 +85,17 @@ function nextReportSeq(): number {
return reportSeq;
}
export function isAbsoluteSessionPath(file: unknown): file is string {
return (
typeof file === "string" &&
(path.posix.isAbsolute(file) || path.win32.isAbsolute(file))
);
}
function updateSessionRef(ctx: any): void {
try {
const file = ctx?.sessionManager?.getSessionFile?.();
currentAgentSessionPath =
typeof file === "string" && file.startsWith("/") ? file : undefined;
currentAgentSessionPath = isAbsoluteSessionPath(file) ? file : undefined;
} catch {
currentAgentSessionPath = undefined;
}
+1 -1
View File
@@ -25,7 +25,7 @@ const PI_EXTENSION_ASSET: &str = include_str!("assets/pi/herdr-agent-state.ts");
const PI_INTEGRATION_VERSION: u32 = 7;
const OMP_EXTENSION_INSTALL_NAME: &str = "herdr-omp-agent-state.ts";
const OMP_EXTENSION_ASSET: &str = include_str!("assets/omp/herdr-agent-state.ts");
const OMP_INTEGRATION_VERSION: u32 = 7;
const OMP_INTEGRATION_VERSION: u32 = 8;
const CLAUDE_HOOK_INSTALL_NAME: &str = if cfg!(windows) {
"herdr-agent-state.ps1"
} else {