MCPcopy Create free account
hub / github.com/HELPMEEADICE/doge-code / getAgentTranscript

Function getAgentTranscript

src/utils/sessionStorage.ts:4236–4282  ·  view source on GitHub ↗
(agentId: AgentId)

Source from the content-addressed store, hash-verified

4234 * or null if not found
4235 */
4236export async function getAgentTranscript(agentId: AgentId): Promise<{
4237 messages: Message[]
4238 contentReplacements: ContentReplacementRecord[]
4239} | null> {
4240 const agentFile = await resolveAgentTranscriptPath(agentId)
4241
4242 try {
4243 const { messages, agentContentReplacements } =
4244 await loadTranscriptFile(agentFile)
4245
4246 // Find messages with matching agentId
4247 const agentMessages = Array.from(messages.values()).filter(
4248 msg => msg.agentId === agentId && msg.isSidechain,
4249 )
4250
4251 if (agentMessages.length === 0) {
4252 return null
4253 }
4254
4255 // Find the most recent leaf message with this agentId
4256 const parentUuids = new Set(agentMessages.map(msg => msg.parentUuid))
4257 const leafMessage = findLatestMessage(
4258 agentMessages,
4259 msg => !parentUuids.has(msg.uuid),
4260 )
4261
4262 if (!leafMessage) {
4263 return null
4264 }
4265
4266 // Build the conversation chain
4267 const transcript = buildConversationChain(messages, leafMessage)
4268
4269 // Filter to only include messages with this agentId
4270 const agentTranscript = transcript.filter(msg => msg.agentId === agentId)
4271
4272 return {
4273 // Convert TranscriptMessage[] to Message[]
4274 messages: agentTranscript.map(
4275 ({ isSidechain, parentUuid, ...msg }) => msg,
4276 ),
4277 contentReplacements: agentContentReplacements.get(agentId) ?? [],
4278 }
4279 } catch {
4280 return null
4281 }
4282}
4283
4284/**
4285 * Extract agent IDs from progress messages in the conversation.

Callers 4

resumeAgentBackgroundFunction · 0.85
loadSubagentTranscriptsFunction · 0.85
REPLFunction · 0.85
runSummaryFunction · 0.85

Calls 6

loadTranscriptFileFunction · 0.85
findLatestMessageFunction · 0.85
buildConversationChainFunction · 0.85
getMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected