replicas-engine 0.1.38 → 0.1.39

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/src/index.js +17 -33
  2. package/package.json +1 -1
package/dist/src/index.js CHANGED
@@ -2452,35 +2452,30 @@ var CodexManager = class extends CodingAgentManager {
2452
2452
  };
2453
2453
  }
2454
2454
  let active = true;
2455
- let offset = 0;
2456
- let remainder = "";
2457
- try {
2458
- const fileStats = await stat3(sessionFile);
2459
- offset = fileStats.size;
2460
- } catch {
2461
- offset = 0;
2462
- }
2455
+ const seenLines = /* @__PURE__ */ new Set();
2456
+ const seedSeenLines = async () => {
2457
+ try {
2458
+ const content = await readFile5(sessionFile, "utf-8");
2459
+ const lines = content.split("\n").map((line) => line.trim()).filter(Boolean);
2460
+ for (const line of lines) {
2461
+ seenLines.add(line);
2462
+ }
2463
+ } catch {
2464
+ }
2465
+ };
2466
+ await seedSeenLines();
2463
2467
  const pump = async () => {
2464
2468
  let emitted = 0;
2465
2469
  try {
2466
2470
  const content = await readFile5(sessionFile, "utf-8");
2467
- if (content.length < offset) {
2468
- offset = 0;
2469
- remainder = "";
2470
- }
2471
- const chunk = content.slice(offset);
2472
- offset = content.length;
2473
- if (!chunk) {
2474
- return 0;
2475
- }
2476
- const buffered = `${remainder}${chunk}`;
2477
- const lines = buffered.split("\n");
2478
- remainder = lines.pop() ?? "";
2479
- for (const line of lines) {
2471
+ const lines = content.split("\n");
2472
+ const completeLines = content.endsWith("\n") ? lines : lines.slice(0, -1);
2473
+ for (const line of completeLines) {
2480
2474
  const trimmed = line.trim();
2481
- if (!trimmed) {
2475
+ if (!trimmed || seenLines.has(trimmed)) {
2482
2476
  continue;
2483
2477
  }
2478
+ seenLines.add(trimmed);
2484
2479
  try {
2485
2480
  const parsed = JSON.parse(trimmed);
2486
2481
  if (isJsonlEvent2(parsed)) {
@@ -2512,17 +2507,6 @@ var CodexManager = class extends CodingAgentManager {
2512
2507
  }
2513
2508
  await sleep(100);
2514
2509
  }
2515
- const tail = remainder.trim();
2516
- if (!tail) {
2517
- return;
2518
- }
2519
- try {
2520
- const parsed = JSON.parse(tail);
2521
- if (isJsonlEvent2(parsed)) {
2522
- onEvent(parsed);
2523
- }
2524
- } catch {
2525
- }
2526
2510
  };
2527
2511
  }
2528
2512
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.38",
3
+ "version": "0.1.39",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",