polydev-ai 1.8.28 → 1.8.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mcp/stdio-wrapper.js +22 -15
- package/package.json +1 -1
package/mcp/stdio-wrapper.js
CHANGED
|
@@ -105,7 +105,7 @@ if (writableTmp) {
|
|
|
105
105
|
* Strips: provider info, approval, sandbox, reasoning, session id, MCP errors, etc.
|
|
106
106
|
*
|
|
107
107
|
* Codex CLI output structure:
|
|
108
|
-
* [metadata] → user → [echoed prompt] → thinking → [status] → codex → [RESPONSE]
|
|
108
|
+
* [metadata] → user → [echoed prompt] → thinking → [status] → codex → [RESPONSE] → tokens used → [count]
|
|
109
109
|
*
|
|
110
110
|
* Claude Code output structure:
|
|
111
111
|
* [may include JSON or plain text response]
|
|
@@ -119,7 +119,7 @@ function cleanCliResponse(content) {
|
|
|
119
119
|
const cleanedLines = [];
|
|
120
120
|
|
|
121
121
|
// State machine for Codex CLI output parsing
|
|
122
|
-
// States: 'metadata' | 'user_section' | 'thinking_section' | 'response'
|
|
122
|
+
// States: 'metadata' | 'user_section' | 'thinking_section' | 'response' | 'footer'
|
|
123
123
|
let state = 'metadata';
|
|
124
124
|
let foundCodexMarker = false;
|
|
125
125
|
|
|
@@ -127,11 +127,16 @@ function cleanCliResponse(content) {
|
|
|
127
127
|
const line = lines[i];
|
|
128
128
|
const trimmed = line.trim();
|
|
129
129
|
|
|
130
|
-
// Always skip
|
|
130
|
+
// Always skip these patterns anywhere in the output
|
|
131
131
|
if (trimmed.startsWith('ERROR: MCP client for')) continue;
|
|
132
132
|
if (trimmed.includes('failed to start') && trimmed.includes('MCP')) continue;
|
|
133
133
|
if (trimmed.includes('handshake') && trimmed.includes('failed')) continue;
|
|
134
134
|
if (trimmed.includes('connection closed')) continue;
|
|
135
|
+
if (trimmed.startsWith('mcp:')) continue; // MCP startup logs
|
|
136
|
+
if (trimmed.startsWith('mcp startup:')) continue; // MCP startup summary
|
|
137
|
+
if (trimmed.includes('rmcp::transport')) continue; // RMCP transport errors
|
|
138
|
+
if (trimmed.includes('ERROR rmcp')) continue;
|
|
139
|
+
if (trimmed.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)) continue; // Timestamp logs
|
|
135
140
|
|
|
136
141
|
// State: metadata - skip until we hit a section marker
|
|
137
142
|
if (state === 'metadata') {
|
|
@@ -186,13 +191,7 @@ function cleanCliResponse(content) {
|
|
|
186
191
|
foundCodexMarker = true;
|
|
187
192
|
continue;
|
|
188
193
|
}
|
|
189
|
-
// Skip
|
|
190
|
-
if (trimmed.startsWith('mcp:')) continue;
|
|
191
|
-
if (trimmed.startsWith('mcp startup:')) continue;
|
|
192
|
-
// Skip RMCP transport errors
|
|
193
|
-
if (trimmed.includes('rmcp::transport')) continue;
|
|
194
|
-
if (trimmed.includes('ERROR rmcp')) continue;
|
|
195
|
-
// Skip everything in user section (echoed prompt, errors)
|
|
194
|
+
// Skip everything in user section (echoed prompt)
|
|
196
195
|
continue;
|
|
197
196
|
}
|
|
198
197
|
|
|
@@ -209,16 +208,24 @@ function cleanCliResponse(content) {
|
|
|
209
208
|
|
|
210
209
|
// State: response - keep actual response content
|
|
211
210
|
if (state === 'response') {
|
|
212
|
-
//
|
|
213
|
-
if (trimmed === 'tokens used')
|
|
214
|
-
|
|
211
|
+
// Transition to footer when we see "tokens used"
|
|
212
|
+
if (trimmed === 'tokens used') {
|
|
213
|
+
state = 'footer';
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
215
216
|
|
|
216
|
-
// Skip any
|
|
217
|
+
// Skip any bold status markers like **Processing...**
|
|
217
218
|
if (trimmed.match(/^\*\*.*\*\*$/)) continue;
|
|
218
219
|
|
|
219
|
-
// Keep this line
|
|
220
|
+
// Keep this line - it's the actual response
|
|
220
221
|
cleanedLines.push(line);
|
|
221
222
|
}
|
|
223
|
+
|
|
224
|
+
// State: footer - skip token count and anything after
|
|
225
|
+
if (state === 'footer') {
|
|
226
|
+
// Skip everything in footer (token counts, etc.)
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
222
229
|
}
|
|
223
230
|
|
|
224
231
|
// Trim leading/trailing empty lines
|
package/package.json
CHANGED