MCPcopy Create free account
hub / github.com/MarsWang42/Awel / formatConsoleContext

Function formatConsoleContext

packages/cli/src/agent.ts:64–90  ·  view source on GitHub ↗

* Formats console entries into a context block for the LLM prompt.

(entries: ConsoleEntryInput[])

Source from the content-addressed store, hash-verified

62 * Formats console entries into a context block for the LLM prompt.
63 */
64function formatConsoleContext(entries: ConsoleEntryInput[]): string | null {
65 if (entries.length === 0) return null;
66
67 const parts = entries.map(entry => {
68 const lines = [`[${entry.level}] ${entry.message}`];
69 if (entry.sourceTrace && entry.sourceTrace.length > 0) {
70 lines.push('Trace:');
71 for (const f of entry.sourceTrace) {
72 lines.push(` ${f.source}${f.line ? `:${f.line}` : ''}`);
73 }
74 } else if (entry.source) {
75 let loc = entry.source;
76 if (entry.line) loc += `:${entry.line}`;
77 if (entry.column) loc += `:${entry.column}`;
78 lines.push(`Source: ${loc}`);
79 }
80 if (entry.stack) {
81 lines.push(`Stack: ${entry.stack}`);
82 }
83 if (entry.count > 1) {
84 lines.push(`Occurred ${entry.count} times`);
85 }
86 return lines.join('\n');
87 });
88
89 return '[Browser Console Errors]\n\n' + parts.join('\n\n') + '\n\n';
90}
91
92/**
93 * Formats page context into a context block for the LLM prompt.

Callers 1

createAgentRouteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected