codiedev 0.9.43 → 0.9.45
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/dist/codie.js +56 -33
- package/package.json +1 -1
package/dist/codie.js
CHANGED
|
@@ -176,55 +176,78 @@ async function runNonInteractive(runtime, runtimeArgs, env) {
|
|
|
176
176
|
});
|
|
177
177
|
return await new Promise((resolve, reject) => {
|
|
178
178
|
let blockReason;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
// OpenCode
|
|
182
|
-
//
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
179
|
+
const errorPrefixes = [Buffer.from("\x1b[91m\x1b[1mError:"), Buffer.from("Error: {")];
|
|
180
|
+
const retainedPrefixBytes = Math.max(...errorPrefixes.map((prefix) => prefix.length)) - 1;
|
|
181
|
+
// OpenCode's generic UnknownError and the adapter's private reason can be
|
|
182
|
+
// delivered in either order — and the generic block can arrive on stdout
|
|
183
|
+
// or stderr. Gate both streams by content, retaining only a possible final
|
|
184
|
+
// error block. Ordinary output stays streaming apart from the few bytes
|
|
185
|
+
// needed to recognize a split prefix.
|
|
186
|
+
const createOutputGate = (write) => {
|
|
187
|
+
let tail = Buffer.alloc(0);
|
|
188
|
+
let possibleError;
|
|
189
|
+
return {
|
|
190
|
+
push(chunk, blocked) {
|
|
191
|
+
if (blocked) {
|
|
192
|
+
if (possibleError)
|
|
193
|
+
possibleError.push(Buffer.from(chunk));
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (possibleError) {
|
|
197
|
+
possibleError.push(Buffer.from(chunk));
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const combined = Buffer.concat([tail, chunk]);
|
|
201
|
+
let errorStart = -1;
|
|
202
|
+
for (const prefix of errorPrefixes) {
|
|
203
|
+
const index = combined.indexOf(prefix);
|
|
204
|
+
if (index >= 0 && (errorStart < 0 || index < errorStart))
|
|
205
|
+
errorStart = index;
|
|
206
|
+
}
|
|
207
|
+
if (errorStart >= 0) {
|
|
208
|
+
if (errorStart > 0)
|
|
209
|
+
write(combined.subarray(0, errorStart));
|
|
210
|
+
possibleError = [combined.subarray(errorStart)];
|
|
211
|
+
tail = Buffer.alloc(0);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const flushBytes = Math.max(0, combined.length - retainedPrefixBytes);
|
|
215
|
+
if (flushBytes > 0)
|
|
216
|
+
write(combined.subarray(0, flushBytes));
|
|
217
|
+
tail = combined.subarray(flushBytes);
|
|
218
|
+
},
|
|
219
|
+
finish(blocked) {
|
|
220
|
+
if (tail.length > 0)
|
|
221
|
+
write(tail);
|
|
222
|
+
const heldError = possibleError ? Buffer.concat(possibleError).toString() : "";
|
|
223
|
+
const genericBlockError = heldError.includes("UnknownError") &&
|
|
224
|
+
heldError.includes("Unexpected server error");
|
|
225
|
+
if (heldError && (!blocked || !genericBlockError))
|
|
226
|
+
write(heldError);
|
|
227
|
+
},
|
|
228
|
+
};
|
|
196
229
|
};
|
|
230
|
+
const stdoutGate = createOutputGate((chunk) => process.stdout.write(chunk));
|
|
231
|
+
const stderrGate = createOutputGate((chunk) => process.stderr.write(chunk));
|
|
197
232
|
child.stdout?.on("data", (chunk) => {
|
|
198
|
-
|
|
199
|
-
return;
|
|
200
|
-
pendingStdout.push(Buffer.from(chunk));
|
|
201
|
-
scheduleStdoutFlush();
|
|
233
|
+
stdoutGate.push(Buffer.from(chunk), Boolean(blockReason));
|
|
202
234
|
});
|
|
203
235
|
child.stderr?.on("data", (chunk) => {
|
|
204
236
|
const text = chunk.toString();
|
|
205
237
|
const reason = (0, codieLauncher_1.extractCodieSecurityBlock)(text);
|
|
206
238
|
if (reason) {
|
|
207
239
|
blockReason = reason;
|
|
208
|
-
pendingStdout = [];
|
|
209
|
-
if (flushTimer)
|
|
210
|
-
clearTimeout(flushTimer);
|
|
211
|
-
flushTimer = undefined;
|
|
212
240
|
return;
|
|
213
241
|
}
|
|
214
|
-
|
|
215
|
-
process.stderr.write(chunk);
|
|
242
|
+
stderrGate.push(Buffer.from(chunk), Boolean(blockReason));
|
|
216
243
|
});
|
|
217
244
|
child.once("error", reject);
|
|
218
245
|
child.once("close", (status) => {
|
|
219
|
-
|
|
220
|
-
|
|
246
|
+
stdoutGate.finish(Boolean(blockReason));
|
|
247
|
+
stderrGate.finish(Boolean(blockReason));
|
|
221
248
|
if (blockReason) {
|
|
222
|
-
pendingStdout = [];
|
|
223
249
|
console.error(`Codie Security blocked this action:\n${blockReason}`);
|
|
224
250
|
}
|
|
225
|
-
else {
|
|
226
|
-
flushStdout();
|
|
227
|
-
}
|
|
228
251
|
resolve(status);
|
|
229
252
|
});
|
|
230
253
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codiedev",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.45",
|
|
4
4
|
"description": "Connect Claude Code, Codex, Cursor, OpenCode, or VS Code Copilot to Codiedev for team session capture and artifact collaboration — and run the governed Codie harness",
|
|
5
5
|
"bin": {
|
|
6
6
|
"codiedev": "dist/cli.js",
|