codiedev 0.9.43 → 0.9.44

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.
Files changed (2) hide show
  1. package/dist/codie.js +47 -26
  2. package/package.json +1 -1
package/dist/codie.js CHANGED
@@ -176,39 +176,52 @@ async function runNonInteractive(runtime, runtimeArgs, env) {
176
176
  });
177
177
  return await new Promise((resolve, reject) => {
178
178
  let blockReason;
179
- let pendingStdout = [];
180
- let flushTimer;
179
+ let stdoutTail = Buffer.alloc(0);
180
+ let possibleOpenCodeError;
181
+ const errorPrefixes = [Buffer.from("\x1b[91m\x1b[1mError:"), Buffer.from("Error: {")];
182
+ const retainedPrefixBytes = Math.max(...errorPrefixes.map((prefix) => prefix.length)) - 1;
181
183
  // OpenCode reports a plugin rejection through two different pipes: the
182
184
  // adapter's private reason on stderr, then its generic UnknownError on
183
- // stdout. Hold stdout very briefly so the reason can win that race. Normal
184
- // run output remains streaming with only an imperceptible delay.
185
- const flushStdout = () => {
186
- flushTimer = undefined;
187
- if (!blockReason) {
188
- for (const chunk of pendingStdout)
189
- process.stdout.write(chunk);
185
+ // stdout. Pipe ordering is nondeterministic, so retain only a possible
186
+ // terminal error block until the marker arrives. Ordinary run output keeps
187
+ // streaming immediately (apart from the few bytes needed to match a prefix).
188
+ const writeStdout = (chunk) => {
189
+ if (blockReason) {
190
+ if (possibleOpenCodeError)
191
+ possibleOpenCodeError.push(Buffer.from(chunk));
192
+ return;
190
193
  }
191
- pendingStdout = [];
192
- };
193
- const scheduleStdoutFlush = () => {
194
- if (!flushTimer)
195
- flushTimer = setTimeout(flushStdout, 75);
194
+ if (possibleOpenCodeError) {
195
+ possibleOpenCodeError.push(Buffer.from(chunk));
196
+ return;
197
+ }
198
+ const combined = Buffer.concat([stdoutTail, chunk]);
199
+ let errorStart = -1;
200
+ for (const prefix of errorPrefixes) {
201
+ const index = combined.indexOf(prefix);
202
+ if (index >= 0 && (errorStart < 0 || index < errorStart))
203
+ errorStart = index;
204
+ }
205
+ if (errorStart >= 0) {
206
+ if (errorStart > 0)
207
+ process.stdout.write(combined.subarray(0, errorStart));
208
+ possibleOpenCodeError = [combined.subarray(errorStart)];
209
+ stdoutTail = Buffer.alloc(0);
210
+ return;
211
+ }
212
+ const flushBytes = Math.max(0, combined.length - retainedPrefixBytes);
213
+ if (flushBytes > 0)
214
+ process.stdout.write(combined.subarray(0, flushBytes));
215
+ stdoutTail = combined.subarray(flushBytes);
196
216
  };
197
217
  child.stdout?.on("data", (chunk) => {
198
- if (blockReason)
199
- return;
200
- pendingStdout.push(Buffer.from(chunk));
201
- scheduleStdoutFlush();
218
+ writeStdout(Buffer.from(chunk));
202
219
  });
203
220
  child.stderr?.on("data", (chunk) => {
204
221
  const text = chunk.toString();
205
222
  const reason = (0, codieLauncher_1.extractCodieSecurityBlock)(text);
206
223
  if (reason) {
207
224
  blockReason = reason;
208
- pendingStdout = [];
209
- if (flushTimer)
210
- clearTimeout(flushTimer);
211
- flushTimer = undefined;
212
225
  return;
213
226
  }
214
227
  if (!blockReason)
@@ -216,14 +229,22 @@ async function runNonInteractive(runtime, runtimeArgs, env) {
216
229
  });
217
230
  child.once("error", reject);
218
231
  child.once("close", (status) => {
219
- if (flushTimer)
220
- clearTimeout(flushTimer);
221
232
  if (blockReason) {
222
- pendingStdout = [];
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
+ }
223
241
  console.error(`Codie Security blocked this action:\n${blockReason}`);
224
242
  }
225
243
  else {
226
- flushStdout();
244
+ if (stdoutTail.length > 0)
245
+ process.stdout.write(stdoutTail);
246
+ if (possibleOpenCodeError)
247
+ process.stdout.write(Buffer.concat(possibleOpenCodeError));
227
248
  }
228
249
  resolve(status);
229
250
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codiedev",
3
- "version": "0.9.43",
3
+ "version": "0.9.44",
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",