MCPcopy Create free account
hub / github.com/tiann/hapi / processTranscriptPath

Function processTranscriptPath

cli/src/codex/codexLocalLauncher.ts:71–117  ·  view source on GitHub ↗
(transcriptPath: string)

Source from the content-addressed store, hash-verified

69 };
70
71 const processTranscriptPath = async (transcriptPath: string): Promise<void> => {
72 hookReady = true;
73 if (shuttingDown) {
74 return;
75 }
76 if (primaryTranscriptPath && transcriptPath !== primaryTranscriptPath) {
77 logger.debug(`[codex-local]: Ignoring non-primary transcript path ${transcriptPath}; primary is ${primaryTranscriptPath}`);
78 return;
79 }
80 if (scanner) {
81 await scanner.setTranscriptPath(transcriptPath);
82 return;
83 }
84 const createdScanner = await createCodexSessionScanner({
85 transcriptPath,
86 // 中文注释:导入模式下允许 scanner 首次回放 transcript 全量内容,补齐 Codex 客户端里已有但 Hapi 还未看到的消息。
87 replayExistingHistory: session.replayTranscriptHistoryOnStart,
88 onSessionId: (sessionId) => {
89 if (!isPrimarySessionId(sessionId)) {
90 logger.debug(`[codex-local]: Ignoring transcript session id ${sessionId}; primary is ${primarySessionId}`);
91 return;
92 }
93 session.onSessionFound(sessionId);
94 },
95 onEvent: (event) => {
96 const converted = convertCodexEvent(event);
97 if (converted?.sessionId) {
98 if (!isPrimarySessionId(converted.sessionId)) {
99 logger.debug(`[codex-local]: Ignoring converted session id ${converted.sessionId}; primary is ${primarySessionId}`);
100 return;
101 }
102 session.onSessionFound(converted.sessionId);
103 }
104 if (converted?.userMessage) {
105 session.sendUserMessage(converted.userMessage);
106 }
107 if (converted?.message) {
108 session.sendAgentMessage(converted.message);
109 }
110 }
111 });
112 if (shuttingDown) {
113 await createdScanner.cleanup();
114 return;
115 }
116 scanner = createdScanner;
117 };
118
119 const handleTranscriptPath = (transcriptPath: string): Promise<void> => {
120 const setupTask = (pendingScannerSetup ?? Promise.resolve()).then(() => processTranscriptPath(transcriptPath));

Callers 1

handleTranscriptPathFunction · 0.85

Calls 8

convertCodexEventFunction · 0.90
isPrimarySessionIdFunction · 0.85
debugMethod · 0.80
sendUserMessageMethod · 0.80
sendAgentMessageMethod · 0.80
setTranscriptPathMethod · 0.45
cleanupMethod · 0.45

Tested by

no test coverage detected