Files
openclaw/extensions/codex/src/app-server/local-runtime-attribution.ts
Peter Steinberger 26210c1600 refactor: remove browser and codex dead exports (#105867)
* refactor(browser): collapse Playwright export paths

* refactor(browser): remove dead plugin exports

* refactor(codex): remove dead app-server exports

* refactor(codex): remove remaining dead exports

* test(codex): use canonical private-type owners

* test(browser): isolate proxy startup state

* test(browser): remove stale chrome imports

* refactor(codex): privatize remaining helpers

* chore(deadcode): refresh export baseline after rebase

* refactor(browser): finish canonical helper ownership

* refactor: fix dead-export cleanup gates

* refactor(codex): keep runtime facades LOC-neutral

* chore(ci): refresh TypeScript LOC baseline

* chore(deadcode): refresh ratchets after rebase

* chore(ci): refresh LOC baseline after main advance

* chore(deadcode): align ratchets with latest main
2026-07-12 22:23:11 -07:00

45 lines
1.4 KiB
TypeScript

/**
* Resolves the provider/api attribution used when a local Codex runtime is
* backed by OpenAI auth but should still report Codex Responses semantics.
*/
import type { EmbeddedRunAttemptParams } from "openclaw/plugin-sdk/agent-harness-runtime";
const OPENAI_PROVIDER_ID = "openai";
const OPENAI_RESPONSES_API = "openai-responses";
const OPENAI_CODEX_RESPONSES_API = "openai-chatgpt-responses";
/** Provider identity that downstream telemetry should attribute to the local Codex turn. */
type CodexLocalRuntimeAttribution = {
provider: string;
api?: string;
};
function normalizeRuntimeId(value: string | undefined): string {
return value?.trim().toLowerCase() ?? "";
}
/** Maps local Codex runtime plans onto the provider/api pair exposed to event projection. */
export function resolveCodexLocalRuntimeAttribution(
params: EmbeddedRunAttemptParams,
): CodexLocalRuntimeAttribution {
const authProfileProvider = normalizeRuntimeId(
params.runtimePlan?.auth?.authProfileProviderForAuth,
);
if (
normalizeRuntimeId(params.runtimePlan?.observability.harnessId) === "codex" &&
authProfileProvider !== OPENAI_PROVIDER_ID &&
normalizeRuntimeId(params.model.provider) === OPENAI_PROVIDER_ID &&
normalizeRuntimeId(params.model.api) === OPENAI_RESPONSES_API
) {
return {
provider: OPENAI_PROVIDER_ID,
api: OPENAI_CODEX_RESPONSES_API,
};
}
return {
provider: params.provider,
api: params.model.api,
};
}