codex-blocker 0.0.7 → 0.0.8
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/bin.js +1 -1
- package/dist/{chunk-APDAIY47.js → chunk-2Q6Z6NQH.js} +54 -16
- package/dist/server.js +1 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -222,6 +222,8 @@ function parseCodexLine(line, sessionId) {
|
|
|
222
222
|
|
|
223
223
|
// src/codex.ts
|
|
224
224
|
var DEFAULT_CODEX_HOME = join(homedir(), ".codex");
|
|
225
|
+
var TAIL_MAX_BYTES = 64 * 1024;
|
|
226
|
+
var TAIL_MAX_LINES = 200;
|
|
225
227
|
async function listRolloutFiles(root) {
|
|
226
228
|
const files = [];
|
|
227
229
|
const entries = await fs.readdir(root, { withFileTypes: true });
|
|
@@ -235,6 +237,30 @@ async function listRolloutFiles(root) {
|
|
|
235
237
|
}
|
|
236
238
|
return files;
|
|
237
239
|
}
|
|
240
|
+
async function readTailLines(filePath, fileSize, maxBytes, maxLines) {
|
|
241
|
+
if (fileSize === 0) return [];
|
|
242
|
+
const start = Math.max(0, fileSize - maxBytes);
|
|
243
|
+
const end = Math.max(fileSize - 1, start);
|
|
244
|
+
const chunks = [];
|
|
245
|
+
await new Promise((resolve, reject) => {
|
|
246
|
+
const stream = createReadStream(filePath, { start, end });
|
|
247
|
+
stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
|
|
248
|
+
stream.on("error", reject);
|
|
249
|
+
stream.on("end", resolve);
|
|
250
|
+
});
|
|
251
|
+
let content = Buffer.concat(chunks).toString("utf-8");
|
|
252
|
+
let lines = content.split("\n");
|
|
253
|
+
if (start > 0 && content[0] !== "\n") {
|
|
254
|
+
lines = lines.slice(1);
|
|
255
|
+
}
|
|
256
|
+
if (lines.length > 0 && lines[lines.length - 1]?.trim() === "") {
|
|
257
|
+
lines.pop();
|
|
258
|
+
}
|
|
259
|
+
if (lines.length > maxLines) {
|
|
260
|
+
lines = lines.slice(-maxLines);
|
|
261
|
+
}
|
|
262
|
+
return lines.filter((line) => line.trim().length > 0);
|
|
263
|
+
}
|
|
238
264
|
async function readNewLines(filePath, fileState) {
|
|
239
265
|
const stat = await fs.stat(filePath);
|
|
240
266
|
if (stat.size < fileState.position) {
|
|
@@ -306,6 +332,15 @@ var CodexSessionWatcher = class {
|
|
|
306
332
|
try {
|
|
307
333
|
const stat = await fs.stat(filePath);
|
|
308
334
|
fileState.position = stat.size;
|
|
335
|
+
const tailLines = await readTailLines(
|
|
336
|
+
filePath,
|
|
337
|
+
stat.size,
|
|
338
|
+
TAIL_MAX_BYTES,
|
|
339
|
+
TAIL_MAX_LINES
|
|
340
|
+
);
|
|
341
|
+
if (tailLines.length > 0) {
|
|
342
|
+
this.processLines(tailLines, fileState);
|
|
343
|
+
}
|
|
309
344
|
} catch {
|
|
310
345
|
continue;
|
|
311
346
|
}
|
|
@@ -318,22 +353,25 @@ var CodexSessionWatcher = class {
|
|
|
318
353
|
continue;
|
|
319
354
|
}
|
|
320
355
|
if (newLines.length === 0) continue;
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
356
|
+
this.processLines(newLines, fileState);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
processLines(lines, fileState) {
|
|
360
|
+
for (const line of lines) {
|
|
361
|
+
const parsed = parseCodexLine(line, fileState.sessionId);
|
|
362
|
+
fileState.sessionId = parsed.sessionId;
|
|
363
|
+
if (parsed.previousSessionId) {
|
|
364
|
+
this.state.removeSession(parsed.previousSessionId);
|
|
365
|
+
}
|
|
366
|
+
this.state.markCodexSessionSeen(parsed.sessionId, parsed.cwd);
|
|
367
|
+
if (parsed.markWorking) {
|
|
368
|
+
this.state.handleCodexActivity({
|
|
369
|
+
sessionId: parsed.sessionId,
|
|
370
|
+
cwd: parsed.cwd
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
if (parsed.markIdle) {
|
|
374
|
+
this.state.setCodexIdle(parsed.sessionId, parsed.cwd);
|
|
337
375
|
}
|
|
338
376
|
}
|
|
339
377
|
}
|
package/dist/server.js
CHANGED
package/package.json
CHANGED