fix: narrow legacy codex context cleanup

This commit is contained in:
Alex Newman
2026-05-06 14:39:42 -07:00
parent a64d60b9cb
commit 8d65b95a59
3 changed files with 26 additions and 5 deletions
+24 -1
View File
@@ -182,6 +182,29 @@ function isCodexTranscriptWatch(watch: Record<string, unknown>): boolean {
return watch.name === 'codex' || watch.schema === 'codex';
}
function expandHome(inputPath: string): string {
if (inputPath === '~') return homedir();
if (inputPath.startsWith('~/') || inputPath.startsWith('~\\')) {
return path.join(homedir(), inputPath.slice(2));
}
return inputPath;
}
function isLegacyCodexAgentsContext(context: Record<string, unknown>): boolean {
if (context.mode !== 'agents') return false;
const updateOn = context.updateOn;
const hasLegacyUpdateOn = Array.isArray(updateOn)
&& updateOn.length === 2
&& updateOn.includes('session_start')
&& updateOn.includes('session_end');
if (!hasLegacyUpdateOn) return false;
if (context.path === undefined) return true;
return typeof context.path === 'string'
&& path.resolve(expandHome(context.path)) === CODEX_AGENTS_MD_PATH;
}
function disableCodexTranscriptAgentsContext(): boolean {
if (!existsSync(CODEX_TRANSCRIPT_WATCH_CONFIG_PATH)) return true;
@@ -192,7 +215,7 @@ function disableCodexTranscriptAgentsContext(): boolean {
let changed = false;
for (const watch of parsed.watches) {
if (!isRecord(watch) || !isCodexTranscriptWatch(watch)) continue;
if (!isRecord(watch.context) || watch.context.mode !== 'agents') continue;
if (!isRecord(watch.context) || !isLegacyCodexAgentsContext(watch.context)) continue;
delete watch.context;
changed = true;
}
+1 -2
View File
@@ -54,8 +54,7 @@ const CODEX_SAMPLE_SCHEMA: TranscriptSchema = {
toolName: {
coalesce: [
'payload.name',
'payload.type',
{ value: 'web_search' }
'payload.type'
]
},
toolInput: {
+1 -2
View File
@@ -48,8 +48,7 @@
"toolName": {
"coalesce": [
"payload.name",
"payload.type",
{ "value": "web_search" }
"payload.type"
]
},
"toolInput": {