replicas-engine 0.1.226 → 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.
- package/dist/src/index.js +150 -14
- 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-
|
|
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 = {
|
|
@@ -5425,6 +5425,23 @@ var AspClient = class {
|
|
|
5425
5425
|
console.warn(`[AspClient] Failed to send response ${String(id)}:`, error);
|
|
5426
5426
|
}
|
|
5427
5427
|
}
|
|
5428
|
+
reject(id, code, message, data) {
|
|
5429
|
+
if (this.disposed) {
|
|
5430
|
+
return;
|
|
5431
|
+
}
|
|
5432
|
+
try {
|
|
5433
|
+
this.write({
|
|
5434
|
+
id,
|
|
5435
|
+
error: {
|
|
5436
|
+
code,
|
|
5437
|
+
message,
|
|
5438
|
+
...data !== void 0 ? { data } : {}
|
|
5439
|
+
}
|
|
5440
|
+
});
|
|
5441
|
+
} catch (error) {
|
|
5442
|
+
console.warn(`[AspClient] Failed to send error response ${String(id)}:`, error);
|
|
5443
|
+
}
|
|
5444
|
+
}
|
|
5428
5445
|
dispose(reason = new Error("ASP client disposed")) {
|
|
5429
5446
|
if (this.disposed) {
|
|
5430
5447
|
return;
|
|
@@ -6098,7 +6115,7 @@ function dedupeTranscriptItems(items) {
|
|
|
6098
6115
|
deduped.push(item);
|
|
6099
6116
|
continue;
|
|
6100
6117
|
}
|
|
6101
|
-
deduped[existingIndex] =
|
|
6118
|
+
deduped[existingIndex] = mergeCodexAspTranscriptItem(deduped[existingIndex], item);
|
|
6102
6119
|
}
|
|
6103
6120
|
return deduped;
|
|
6104
6121
|
}
|
|
@@ -6253,14 +6270,71 @@ var FILE_CHANGE_OUTPUT_DELTA_METHOD = "item/fileChange/outputDelta";
|
|
|
6253
6270
|
var ACCOUNT_RATE_LIMITS_UPDATED_METHOD = "account/rateLimits/updated";
|
|
6254
6271
|
var THREAD_TOKEN_USAGE_UPDATED_METHOD = "thread/tokenUsage/updated";
|
|
6255
6272
|
var THREAD_COMPACTED_METHOD = "thread/compacted";
|
|
6256
|
-
var COMMAND_APPROVAL_METHOD = "item/commandExecution/requestApproval";
|
|
6257
|
-
var FILE_CHANGE_APPROVAL_METHOD = "item/fileChange/requestApproval";
|
|
6258
6273
|
function dispatchAspNotification(notification, handlers) {
|
|
6259
6274
|
const handler = handlers[notification.method];
|
|
6260
6275
|
if (!handler) return;
|
|
6261
6276
|
handler(notification);
|
|
6262
6277
|
}
|
|
6263
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
|
+
|
|
6264
6338
|
// src/managers/codex-asp/codex-asp-manager.ts
|
|
6265
6339
|
var CodexAspManager = class extends CodingAgentManager {
|
|
6266
6340
|
currentThreadId = null;
|
|
@@ -6271,6 +6345,9 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
6271
6345
|
codexAspSequence = 0;
|
|
6272
6346
|
quotaStatus = new CodexQuotaStatusTracker();
|
|
6273
6347
|
currentGoal = null;
|
|
6348
|
+
transcriptUpdateCoalescer = new TranscriptUpdateCoalescer((threadId) => {
|
|
6349
|
+
this.flushTranscriptUpdated(threadId);
|
|
6350
|
+
});
|
|
6274
6351
|
constructor(options) {
|
|
6275
6352
|
super(options);
|
|
6276
6353
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
@@ -6397,6 +6474,8 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
6397
6474
|
}
|
|
6398
6475
|
throw error;
|
|
6399
6476
|
} finally {
|
|
6477
|
+
this.transcriptUpdateCoalescer.flushPending();
|
|
6478
|
+
this.transcriptUpdateCoalescer.dispose();
|
|
6400
6479
|
this.activeTurnId = null;
|
|
6401
6480
|
await this.onTurnComplete();
|
|
6402
6481
|
}
|
|
@@ -6534,7 +6613,7 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
6534
6613
|
observedTurnId = notification.params.turn.id;
|
|
6535
6614
|
this.activeTurnId = notification.params.turn.id;
|
|
6536
6615
|
this.mergeTranscriptTurn(notification.params.threadId, notification.params.turn);
|
|
6537
|
-
this.emitTranscriptUpdated(notification.params.threadId);
|
|
6616
|
+
this.emitTranscriptUpdated(notification.params.threadId, { immediate: true });
|
|
6538
6617
|
linearForwarder.sendEvent(convertCodexAspNotification(notification, linearSessionId ?? ""));
|
|
6539
6618
|
},
|
|
6540
6619
|
[TURN_PLAN_UPDATED_METHOD]: (notification) => {
|
|
@@ -6555,7 +6634,7 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
6555
6634
|
"in_progress",
|
|
6556
6635
|
"started"
|
|
6557
6636
|
);
|
|
6558
|
-
this.emitTranscriptUpdated(notification.params.threadId);
|
|
6637
|
+
this.emitTranscriptUpdated(notification.params.threadId, { immediate: true });
|
|
6559
6638
|
linearForwarder.sendEvent(convertCodexAspNotification(notification, linearSessionId ?? ""));
|
|
6560
6639
|
},
|
|
6561
6640
|
[ITEM_COMPLETED_METHOD]: (notification) => {
|
|
@@ -6573,7 +6652,7 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
6573
6652
|
itemFailed ? "failed" : "completed",
|
|
6574
6653
|
"completed"
|
|
6575
6654
|
);
|
|
6576
|
-
this.emitTranscriptUpdated(notification.params.threadId);
|
|
6655
|
+
this.emitTranscriptUpdated(notification.params.threadId, { immediate: true });
|
|
6577
6656
|
linearForwarder.sendEvent(convertCodexAspNotification(notification, linearSessionId ?? ""));
|
|
6578
6657
|
},
|
|
6579
6658
|
[AGENT_MESSAGE_DELTA_METHOD]: (notification) => {
|
|
@@ -6623,7 +6702,7 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
6623
6702
|
}
|
|
6624
6703
|
const completedTurn = items.length > 0 ? { ...turn, items, itemsView: "full" } : turn;
|
|
6625
6704
|
this.mergeTranscriptTurn(notification.params.threadId, completedTurn);
|
|
6626
|
-
this.emitTranscriptUpdated(notification.params.threadId);
|
|
6705
|
+
this.emitTranscriptUpdated(notification.params.threadId, { immediate: true });
|
|
6627
6706
|
resolveCompleted(completedTurn);
|
|
6628
6707
|
}
|
|
6629
6708
|
};
|
|
@@ -6631,11 +6710,10 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
6631
6710
|
dispatchAspNotification(notification, handlers);
|
|
6632
6711
|
};
|
|
6633
6712
|
const onServerRequest = (serverRequest) => {
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
host.client.respond(serverRequest.id, { decision: "accept" });
|
|
6713
|
+
void this.respondToServerRequest(host, serverRequest).catch((error) => {
|
|
6714
|
+
console.warn(`[CodexAspManager] Failed to handle ASP server request ${serverRequest.method}:`, error);
|
|
6715
|
+
host.client.reject(serverRequest.id, -32603, `Failed to handle ${serverRequest.method}`);
|
|
6716
|
+
});
|
|
6639
6717
|
};
|
|
6640
6718
|
const onDispose = (reason) => {
|
|
6641
6719
|
this.threadAttached = false;
|
|
@@ -6660,12 +6738,67 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
6660
6738
|
host.client.off("notification", onNotification);
|
|
6661
6739
|
host.client.off("serverRequest", onServerRequest);
|
|
6662
6740
|
host.client.off("dispose", onDispose);
|
|
6741
|
+
this.transcriptUpdateCoalescer.flushPending();
|
|
6663
6742
|
await removeTempImageFiles(tempImagePaths);
|
|
6664
6743
|
if (host.client.isDisposed) {
|
|
6665
6744
|
this.threadAttached = false;
|
|
6666
6745
|
}
|
|
6667
6746
|
}
|
|
6668
6747
|
}
|
|
6748
|
+
async respondToServerRequest(host, serverRequest) {
|
|
6749
|
+
const requestId = serverRequest.id;
|
|
6750
|
+
const method = serverRequest.method;
|
|
6751
|
+
switch (serverRequest.method) {
|
|
6752
|
+
case "item/commandExecution/requestApproval":
|
|
6753
|
+
case "item/fileChange/requestApproval":
|
|
6754
|
+
console.warn("[CodexAspManager] approval requested while sandbox is danger-full-access");
|
|
6755
|
+
host.client.respond(requestId, { decision: "accept" });
|
|
6756
|
+
return;
|
|
6757
|
+
case "execCommandApproval":
|
|
6758
|
+
case "applyPatchApproval":
|
|
6759
|
+
console.warn("[CodexAspManager] legacy approval requested while sandbox is danger-full-access");
|
|
6760
|
+
host.client.respond(requestId, { decision: "approved" });
|
|
6761
|
+
return;
|
|
6762
|
+
case "item/permissions/requestApproval": {
|
|
6763
|
+
const requested = serverRequest.params.permissions;
|
|
6764
|
+
const permissions = {};
|
|
6765
|
+
if (requested.network) permissions.network = requested.network;
|
|
6766
|
+
if (requested.fileSystem) permissions.fileSystem = requested.fileSystem;
|
|
6767
|
+
const response = {
|
|
6768
|
+
permissions,
|
|
6769
|
+
scope: "turn"
|
|
6770
|
+
};
|
|
6771
|
+
host.client.respond(requestId, response);
|
|
6772
|
+
return;
|
|
6773
|
+
}
|
|
6774
|
+
case "item/tool/call": {
|
|
6775
|
+
const response = {
|
|
6776
|
+
success: false,
|
|
6777
|
+
contentItems: [{
|
|
6778
|
+
type: "inputText",
|
|
6779
|
+
text: `Replicas does not support Codex dynamic tool calls yet: ${serverRequest.params.namespace ? `${serverRequest.params.namespace}.` : ""}${serverRequest.params.tool}`
|
|
6780
|
+
}]
|
|
6781
|
+
};
|
|
6782
|
+
host.client.respond(requestId, response);
|
|
6783
|
+
return;
|
|
6784
|
+
}
|
|
6785
|
+
case "mcpServer/elicitation/request": {
|
|
6786
|
+
const response = {
|
|
6787
|
+
action: "cancel",
|
|
6788
|
+
content: null,
|
|
6789
|
+
_meta: null
|
|
6790
|
+
};
|
|
6791
|
+
host.client.respond(requestId, response);
|
|
6792
|
+
return;
|
|
6793
|
+
}
|
|
6794
|
+
case "item/tool/requestUserInput":
|
|
6795
|
+
case "account/chatgptAuthTokens/refresh":
|
|
6796
|
+
case "attestation/generate":
|
|
6797
|
+
host.client.reject(requestId, -32601, `Replicas does not support ASP server request ${method}`);
|
|
6798
|
+
return;
|
|
6799
|
+
}
|
|
6800
|
+
host.client.reject(requestId, -32601, `Replicas does not support ASP server request ${method}`);
|
|
6801
|
+
}
|
|
6669
6802
|
nextTranscriptSequence() {
|
|
6670
6803
|
return this.codexAspSequence++;
|
|
6671
6804
|
}
|
|
@@ -6856,7 +6989,10 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
6856
6989
|
this.historyEvents.push(event);
|
|
6857
6990
|
return event;
|
|
6858
6991
|
}
|
|
6859
|
-
emitTranscriptUpdated(threadId) {
|
|
6992
|
+
emitTranscriptUpdated(threadId, options = {}) {
|
|
6993
|
+
this.transcriptUpdateCoalescer.schedule(threadId, options);
|
|
6994
|
+
}
|
|
6995
|
+
flushTranscriptUpdated(threadId) {
|
|
6860
6996
|
const updatedAt = this.codexAspTranscript?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
6861
6997
|
const transcript = this.codexAspTranscript ? structuredClone(this.codexAspTranscript) : null;
|
|
6862
6998
|
const updatePayload = {
|