MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / appendEntryMessage

Function appendEntryMessage

shared/thread-history.ts:39–84  ·  view source on GitHub ↗
(messages: AgentMessage[], entry: SessionPathEntry)

Source from the content-addressed store, hash-verified

37}
38
39function appendEntryMessage(messages: AgentMessage[], entry: SessionPathEntry) {
40 switch (entry.type) {
41 case 'message':
42 if (entry.message) {
43 messages.push(entry.message)
44 }
45 return
46 case 'custom_message':
47 if (entry.display === false) {
48 return
49 }
50
51 messages.push({
52 role: 'custom',
53 customType: entry.customType ?? 'custom',
54 content: entry.content ?? '',
55 timestamp: entry.timestamp ?? Date.now(),
56 } as unknown as AgentMessage)
57 return
58 case 'branch_summary':
59 if (!entry.summary?.trim()) {
60 return
61 }
62
63 messages.push({
64 role: 'branchSummary',
65 summary: entry.summary,
66 timestamp: entry.timestamp ?? Date.now(),
67 } as unknown as AgentMessage)
68 return
69 case 'compaction':
70 if (!entry.summary?.trim()) {
71 return
72 }
73
74 messages.push({
75 role: 'compactionSummary',
76 summary: entry.summary,
77 tokensBefore: entry.tokensBefore ?? 0,
78 timestamp: entry.timestamp ?? Date.now(),
79 } as unknown as AgentMessage)
80 return
81 default:
82 return
83 }
84}
85
86export function buildSourceMessagesFromPathEntries(pathEntries: SessionPathEntry[]) {
87 const messages: AgentMessage[] = []

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected