replicas-engine 0.1.227 → 0.1.228

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 +74 -6
  2. package/package.json +1 -1
package/dist/src/index.js CHANGED
@@ -1773,7 +1773,7 @@ function isClaudeAuthErrorText(text) {
1773
1773
  }
1774
1774
 
1775
1775
  // ../shared/src/engine/environment.ts
1776
- var DAYTONA_SNAPSHOT_ID = "28-05-2026-royal-york-v4";
1776
+ var DAYTONA_SNAPSHOT_ID = "28-05-2026-royal-york-v5";
1777
1777
 
1778
1778
  // ../shared/src/engine/types.ts
1779
1779
  var DEFAULT_CHAT_TITLES = {
@@ -6276,6 +6276,65 @@ function dispatchAspNotification(notification, handlers) {
6276
6276
  handler(notification);
6277
6277
  }
6278
6278
 
6279
+ // src/managers/codex-asp/transcript-update-coalescer.ts
6280
+ var TRANSCRIPT_UPDATE_COALESCE_MS = 1e3;
6281
+ var TranscriptUpdateCoalescer = class {
6282
+ constructor(flush, intervalMs = TRANSCRIPT_UPDATE_COALESCE_MS) {
6283
+ this.flush = flush;
6284
+ this.intervalMs = intervalMs;
6285
+ }
6286
+ flush;
6287
+ intervalMs;
6288
+ timer = null;
6289
+ pendingThreadId = null;
6290
+ lastFlushAt = 0;
6291
+ schedule(threadId, options = {}) {
6292
+ this.pendingThreadId = threadId;
6293
+ if (options.immediate) {
6294
+ this.flushNow(threadId);
6295
+ return;
6296
+ }
6297
+ const now = Date.now();
6298
+ const elapsed = now - this.lastFlushAt;
6299
+ if (elapsed >= this.intervalMs) {
6300
+ this.flushNow(threadId);
6301
+ return;
6302
+ }
6303
+ if (this.timer) {
6304
+ return;
6305
+ }
6306
+ this.timer = setTimeout(() => {
6307
+ const pendingThreadId = this.pendingThreadId;
6308
+ if (pendingThreadId) {
6309
+ this.flushNow(pendingThreadId);
6310
+ }
6311
+ }, this.intervalMs - elapsed);
6312
+ }
6313
+ flushPending() {
6314
+ const pendingThreadId = this.pendingThreadId;
6315
+ if (pendingThreadId) {
6316
+ this.flushNow(pendingThreadId);
6317
+ return;
6318
+ }
6319
+ this.clearTimer();
6320
+ }
6321
+ dispose() {
6322
+ this.pendingThreadId = null;
6323
+ this.clearTimer();
6324
+ }
6325
+ flushNow(threadId) {
6326
+ this.clearTimer();
6327
+ this.pendingThreadId = null;
6328
+ this.lastFlushAt = Date.now();
6329
+ this.flush(threadId);
6330
+ }
6331
+ clearTimer() {
6332
+ if (!this.timer) return;
6333
+ clearTimeout(this.timer);
6334
+ this.timer = null;
6335
+ }
6336
+ };
6337
+
6279
6338
  // src/managers/codex-asp/codex-asp-manager.ts
6280
6339
  var CodexAspManager = class extends CodingAgentManager {
6281
6340
  currentThreadId = null;
@@ -6286,6 +6345,9 @@ var CodexAspManager = class extends CodingAgentManager {
6286
6345
  codexAspSequence = 0;
6287
6346
  quotaStatus = new CodexQuotaStatusTracker();
6288
6347
  currentGoal = null;
6348
+ transcriptUpdateCoalescer = new TranscriptUpdateCoalescer((threadId) => {
6349
+ this.flushTranscriptUpdated(threadId);
6350
+ });
6289
6351
  constructor(options) {
6290
6352
  super(options);
6291
6353
  this.initializeManager(this.processMessageInternal.bind(this));
@@ -6412,6 +6474,8 @@ var CodexAspManager = class extends CodingAgentManager {
6412
6474
  }
6413
6475
  throw error;
6414
6476
  } finally {
6477
+ this.transcriptUpdateCoalescer.flushPending();
6478
+ this.transcriptUpdateCoalescer.dispose();
6415
6479
  this.activeTurnId = null;
6416
6480
  await this.onTurnComplete();
6417
6481
  }
@@ -6549,7 +6613,7 @@ var CodexAspManager = class extends CodingAgentManager {
6549
6613
  observedTurnId = notification.params.turn.id;
6550
6614
  this.activeTurnId = notification.params.turn.id;
6551
6615
  this.mergeTranscriptTurn(notification.params.threadId, notification.params.turn);
6552
- this.emitTranscriptUpdated(notification.params.threadId);
6616
+ this.emitTranscriptUpdated(notification.params.threadId, { immediate: true });
6553
6617
  linearForwarder.sendEvent(convertCodexAspNotification(notification, linearSessionId ?? ""));
6554
6618
  },
6555
6619
  [TURN_PLAN_UPDATED_METHOD]: (notification) => {
@@ -6570,7 +6634,7 @@ var CodexAspManager = class extends CodingAgentManager {
6570
6634
  "in_progress",
6571
6635
  "started"
6572
6636
  );
6573
- this.emitTranscriptUpdated(notification.params.threadId);
6637
+ this.emitTranscriptUpdated(notification.params.threadId, { immediate: true });
6574
6638
  linearForwarder.sendEvent(convertCodexAspNotification(notification, linearSessionId ?? ""));
6575
6639
  },
6576
6640
  [ITEM_COMPLETED_METHOD]: (notification) => {
@@ -6588,7 +6652,7 @@ var CodexAspManager = class extends CodingAgentManager {
6588
6652
  itemFailed ? "failed" : "completed",
6589
6653
  "completed"
6590
6654
  );
6591
- this.emitTranscriptUpdated(notification.params.threadId);
6655
+ this.emitTranscriptUpdated(notification.params.threadId, { immediate: true });
6592
6656
  linearForwarder.sendEvent(convertCodexAspNotification(notification, linearSessionId ?? ""));
6593
6657
  },
6594
6658
  [AGENT_MESSAGE_DELTA_METHOD]: (notification) => {
@@ -6638,7 +6702,7 @@ var CodexAspManager = class extends CodingAgentManager {
6638
6702
  }
6639
6703
  const completedTurn = items.length > 0 ? { ...turn, items, itemsView: "full" } : turn;
6640
6704
  this.mergeTranscriptTurn(notification.params.threadId, completedTurn);
6641
- this.emitTranscriptUpdated(notification.params.threadId);
6705
+ this.emitTranscriptUpdated(notification.params.threadId, { immediate: true });
6642
6706
  resolveCompleted(completedTurn);
6643
6707
  }
6644
6708
  };
@@ -6674,6 +6738,7 @@ var CodexAspManager = class extends CodingAgentManager {
6674
6738
  host.client.off("notification", onNotification);
6675
6739
  host.client.off("serverRequest", onServerRequest);
6676
6740
  host.client.off("dispose", onDispose);
6741
+ this.transcriptUpdateCoalescer.flushPending();
6677
6742
  await removeTempImageFiles(tempImagePaths);
6678
6743
  if (host.client.isDisposed) {
6679
6744
  this.threadAttached = false;
@@ -6924,7 +6989,10 @@ var CodexAspManager = class extends CodingAgentManager {
6924
6989
  this.historyEvents.push(event);
6925
6990
  return event;
6926
6991
  }
6927
- emitTranscriptUpdated(threadId) {
6992
+ emitTranscriptUpdated(threadId, options = {}) {
6993
+ this.transcriptUpdateCoalescer.schedule(threadId, options);
6994
+ }
6995
+ flushTranscriptUpdated(threadId) {
6928
6996
  const updatedAt = this.codexAspTranscript?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString();
6929
6997
  const transcript = this.codexAspTranscript ? structuredClone(this.codexAspTranscript) : null;
6930
6998
  const updatePayload = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.227",
3
+ "version": "0.1.228",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",