fix(usage): preserve platform test contracts

This commit is contained in:
Mohamed Boudra
2026-09-26 23:15:22 +02:00
parent ef90b8e313
commit fa90f6726c
5 changed files with 21 additions and 12 deletions
@@ -242,13 +242,18 @@ test("named profile ignores agent override and uses existing XDG profile data",
);
profileDb.close();
expect(
resolveOmpUsageReference("session-1", "openai-codex", {
OMP_PROFILE: "work",
PI_PROFILE: "other",
PI_CODING_AGENT_DIR: f.agentDir,
PI_CONFIG_DIR: join(root, "config"),
XDG_DATA_HOME: join(root, "xdg"),
}),
resolveOmpUsageReference(
"session-1",
"openai-codex",
{
OMP_PROFILE: "work",
PI_PROFILE: "other",
PI_CODING_AGENT_DIR: f.agentDir,
PI_CONFIG_DIR: join(root, "config"),
XDG_DATA_HOME: join(root, "xdg"),
},
"linux",
),
).toEqual({ source: "codex", input: { accessToken: "profile-token" } });
});
@@ -129,6 +129,7 @@ export function resolveOmpUsageReference(
sessionId: string,
provider: string,
env: NodeJS.ProcessEnv,
platform: NodeJS.Platform = process.platform,
): UsageReference | null {
let source: string;
if (provider === "openai-codex") source = "codex";
@@ -136,7 +137,7 @@ export function resolveOmpUsageReference(
else return null;
if (!sessionId) return null;
// Upstream: packages/utils/src/dirs.ts:82-94,330-343,583-585 (profile, override, agent dir).
const paths = resolveOmpDiagnosticPaths(env);
const paths = resolveOmpDiagnosticPaths(env, undefined, platform);
if (hasKeyOverride(provider, env, paths.agentDir)) return null;
let db: UsageDb;
try {
@@ -29,7 +29,7 @@ async function checkInternalPluginBoundary(directory: string): Promise<void> {
if (hostModules.has(specifier) || isBuiltin(specifier)) continue;
const resolved = reader.resolve(specifier, file, dependency.kind);
const relative = resolved && path.relative(directory, resolved);
const owned = relative && /^(server|shared)\//.test(relative);
const owned = relative && /^(server|shared)[\\/]/.test(relative);
if (!specifier.startsWith(".") || !owned) {
throw new Error(`Internal plugin import boundary: ${file} imports ${specifier}`);
}