codiedev 0.9.44 → 0.9.46
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 +55 -52
- package/package.json +1 -1
package/dist/codie.js
CHANGED
|
@@ -176,76 +176,79 @@ async function runNonInteractive(runtime, runtimeArgs, env) {
|
|
|
176
176
|
});
|
|
177
177
|
return await new Promise((resolve, reject) => {
|
|
178
178
|
let blockReason;
|
|
179
|
-
let stdoutTail = Buffer.alloc(0);
|
|
180
|
-
let possibleOpenCodeError;
|
|
181
179
|
const errorPrefixes = [Buffer.from("\x1b[91m\x1b[1mError:"), Buffer.from("Error: {")];
|
|
182
180
|
const retainedPrefixBytes = Math.max(...errorPrefixes.map((prefix) => prefix.length)) - 1;
|
|
183
|
-
// OpenCode
|
|
184
|
-
//
|
|
185
|
-
//
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
errorStart =
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
+
};
|
|
216
229
|
};
|
|
230
|
+
const stdoutGate = createOutputGate((chunk) => process.stdout.write(chunk));
|
|
231
|
+
const stderrGate = createOutputGate((chunk) => process.stderr.write(chunk));
|
|
217
232
|
child.stdout?.on("data", (chunk) => {
|
|
218
|
-
|
|
233
|
+
stdoutGate.push(Buffer.from(chunk), Boolean(blockReason));
|
|
219
234
|
});
|
|
220
235
|
child.stderr?.on("data", (chunk) => {
|
|
221
236
|
const text = chunk.toString();
|
|
222
237
|
const reason = (0, codieLauncher_1.extractCodieSecurityBlock)(text);
|
|
223
238
|
if (reason) {
|
|
224
239
|
blockReason = reason;
|
|
240
|
+
child.kill("SIGTERM");
|
|
225
241
|
return;
|
|
226
242
|
}
|
|
227
|
-
|
|
228
|
-
process.stderr.write(chunk);
|
|
243
|
+
stderrGate.push(Buffer.from(chunk), Boolean(blockReason));
|
|
229
244
|
});
|
|
230
245
|
child.once("error", reject);
|
|
231
246
|
child.once("close", (status) => {
|
|
247
|
+
stdoutGate.finish(Boolean(blockReason));
|
|
248
|
+
stderrGate.finish(Boolean(blockReason));
|
|
232
249
|
if (blockReason) {
|
|
233
|
-
if (stdoutTail.length > 0)
|
|
234
|
-
process.stdout.write(stdoutTail);
|
|
235
|
-
const heldError = possibleOpenCodeError
|
|
236
|
-
? Buffer.concat(possibleOpenCodeError).toString()
|
|
237
|
-
: "";
|
|
238
|
-
if (heldError && !(heldError.includes("UnknownError") && heldError.includes("Unexpected server error"))) {
|
|
239
|
-
process.stdout.write(heldError);
|
|
240
|
-
}
|
|
241
250
|
console.error(`Codie Security blocked this action:\n${blockReason}`);
|
|
242
251
|
}
|
|
243
|
-
else {
|
|
244
|
-
if (stdoutTail.length > 0)
|
|
245
|
-
process.stdout.write(stdoutTail);
|
|
246
|
-
if (possibleOpenCodeError)
|
|
247
|
-
process.stdout.write(Buffer.concat(possibleOpenCodeError));
|
|
248
|
-
}
|
|
249
252
|
resolve(status);
|
|
250
253
|
});
|
|
251
254
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codiedev",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.46",
|
|
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",
|