MCPcopy Create free account
hub / github.com/github/gh-aw / convertToLogEntries

Function convertToLogEntries

actions/setup/js/parse_codex_log.cjs:166–274  ·  view source on GitHub ↗

* Convert parsed Codex data to logEntries format for plain text rendering * @param {Array<{type: string, content?: string, toolName?: string, params?: string, response?: string, statusIcon?: string}>} parsedData - Parsed Codex log data * @returns {Array} logEntries array in the format expected by

(parsedData)

Source from the content-addressed store, hash-verified

164 * @returns {Array} logEntries array in the format expected by generatePlainTextSummary
165 */
166function convertToLogEntries(parsedData) {
167 const logEntries = [];
168
169 for (const item of parsedData) {
170 if (item.type === "thinking") {
171 // Add thinking as assistant reasoning content (distinct from regular text)
172 logEntries.push({
173 type: "assistant",
174 message: {
175 content: [
176 {
177 type: "thinking",
178 thinking: item.content,
179 },
180 ],
181 },
182 });
183 } else if (item.type === "text") {
184 // Add a plain agent message as assistant text content
185 logEntries.push({
186 type: "assistant",
187 message: {
188 content: [
189 {
190 type: "text",
191 text: item.content,
192 },
193 ],
194 },
195 });
196 } else if (item.type === "tool") {
197 // Add tool use as assistant content
198 const toolUseId = `tool_${logEntries.length}`;
199
200 // Parse params - it might be a plain JSON string or need parsing
201 let inputObj = {};
202 if (item.params) {
203 try {
204 inputObj = JSON.parse(item.params);
205 } catch (e) {
206 // If parsing fails, wrap it as a string
207 inputObj = { params: item.params };
208 }
209 }
210
211 logEntries.push({
212 type: "assistant",
213 message: {
214 content: [
215 {
216 type: "tool_use",
217 id: toolUseId,
218 name: item.toolName, // Already in server__method format
219 input: inputObj,
220 },
221 ],
222 },
223 });

Callers 2

parseCodexJsonlFunction · 0.85
parseCodexLogFunction · 0.85

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected