mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat(codex): use hook to obtain the session id and transcript path
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user