MCPcopy Create free account
hub / github.com/RioArisk/claudecode_api_RemoteControl / resolveHookTranscript

Function resolveHookTranscript

lib/transcript.js:128–146  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

126// Hook Session Resolution
127// ============================================================
128function resolveHookTranscript(data) {
129 if (!data || typeof data !== 'object') return null;
130 const hookCwd = data.cwd ? path.resolve(String(data.cwd)) : '';
131 if (hookCwd && normalizeFsPath(hookCwd) !== normalizeFsPath(state.CWD)) return null;
132 const sessionId = data.session_id ? String(data.session_id) : '';
133 const expectedDir = projectTranscriptDir();
134 const transcriptPath = data.transcript_path ? path.resolve(String(data.transcript_path)) : '';
135 if (transcriptPath) {
136 const transcriptDir = path.dirname(transcriptPath);
137 const transcriptSessionId = path.basename(transcriptPath, '.jsonl');
138 const dirMatches = normalizeFsPath(transcriptDir) === normalizeFsPath(expectedDir);
139 const idMatches = !sessionId || transcriptSessionId === sessionId;
140 if (dirMatches && idMatches) {
141 return { full: transcriptPath, sessionId: transcriptSessionId };
142 }
143 }
144 if (!sessionId) return null;
145 return { full: path.join(expectedDir, `${sessionId}.jsonl`), sessionId };
146}
147
148function maybeAttachHookSession(data, source) {
149 const target = resolveHookTranscript(data);

Callers 1

maybeAttachHookSessionFunction · 0.85

Calls 2

normalizeFsPathFunction · 0.85
projectTranscriptDirFunction · 0.85

Tested by

no test coverage detected