feat(codex): use hook to obtain the session id and transcript path

This commit is contained in:
weishu
2026-04-24 10:52:38 +08:00
parent 82703b85fb
commit 8e54bbeb53
8 changed files with 610 additions and 762 deletions
+28
View File
@@ -12,12 +12,15 @@ type LocalLaunchFailure = {
};
export class CodexSession extends AgentSessionBase<EnhancedMode> {
transcriptPath: string | null = null;
readonly codexArgs?: string[];
readonly codexCliOverrides?: CodexCliOverrides;
readonly startedBy: 'runner' | 'terminal';
readonly startingMode: 'local' | 'remote';
localLaunchFailure: LocalLaunchFailure | null = null;
private transcriptPathCallbacks: Array<(path: string) => void> = [];
constructor(opts: {
api: ApiClient;
client: ApiSessionClient;
@@ -67,6 +70,31 @@ export class CodexSession extends AgentSessionBase<EnhancedMode> {
this.collaborationMode = opts.collaborationMode;
}
onTranscriptPathFound(path: string): void {
if (this.transcriptPath === path) {
return;
}
this.transcriptPath = path;
for (const callback of this.transcriptPathCallbacks) {
callback(path);
}
}
addTranscriptPathCallback(cb: (path: string) => void): void {
this.transcriptPathCallbacks.push(cb);
}
removeTranscriptPathCallback(cb: (path: string) => void): void {
const index = this.transcriptPathCallbacks.indexOf(cb);
if (index !== -1) {
this.transcriptPathCallbacks.splice(index, 1);
}
}
resetTranscriptPath(): void {
this.transcriptPath = null;
}
setPermissionMode = (mode: PermissionMode): void => {
this.permissionMode = mode;
};