replicas-engine 0.1.209 → 0.1.211
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 +54 -4
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -397,7 +397,7 @@ function parseReplicasConfigString(content, filename) {
|
|
|
397
397
|
}
|
|
398
398
|
|
|
399
399
|
// ../shared/src/engine/environment.ts
|
|
400
|
-
var DAYTONA_SNAPSHOT_ID = "
|
|
400
|
+
var DAYTONA_SNAPSHOT_ID = "25-05-2026-royal-york-v2";
|
|
401
401
|
|
|
402
402
|
// ../shared/src/engine/types.ts
|
|
403
403
|
var DEFAULT_CHAT_TITLES = {
|
|
@@ -2939,7 +2939,7 @@ var COMPACT_SUMMARY_PROMPT = [
|
|
|
2939
2939
|
"4. Open questions, blockers, and pending follow-ups.",
|
|
2940
2940
|
"5. Any environment details, credentials, or external systems already configured.",
|
|
2941
2941
|
"",
|
|
2942
|
-
"Format the response as Markdown with clear headings. The session will be reset after your reply
|
|
2942
|
+
"Format the response as Markdown with clear headings. The session will be reset after your reply and your summary re-injected as the prelude to the next user turn; write it so a future agent can resume using only that prelude."
|
|
2943
2943
|
].join("\n");
|
|
2944
2944
|
var MAX_INTERRUPT_QUEUE_ITEMS = 1e3;
|
|
2945
2945
|
var MAX_INTERRUPT_QUEUE_CHARS = 2e5;
|
|
@@ -2952,6 +2952,8 @@ var CodingAgentManager = class {
|
|
|
2952
2952
|
onEvent;
|
|
2953
2953
|
hostOnTurnComplete;
|
|
2954
2954
|
compactionInFlight = false;
|
|
2955
|
+
compactionBuffer = "";
|
|
2956
|
+
pendingSessionPrelude = null;
|
|
2955
2957
|
constructor(options) {
|
|
2956
2958
|
this.workingDirectory = options.workingDirectory ?? ENGINE_ENV.WORKSPACE_ROOT;
|
|
2957
2959
|
this.initialSessionId = options.initialSessionId;
|
|
@@ -2962,6 +2964,9 @@ var CodingAgentManager = class {
|
|
|
2962
2964
|
onTurnComplete = async () => {
|
|
2963
2965
|
if (this.compactionInFlight) {
|
|
2964
2966
|
this.compactionInFlight = false;
|
|
2967
|
+
const summary = this.compactionBuffer.trim();
|
|
2968
|
+
this.compactionBuffer = "";
|
|
2969
|
+
this.pendingSessionPrelude = summary.length > 0 ? summary : null;
|
|
2965
2970
|
this.emitCompactionStatus("completed");
|
|
2966
2971
|
try {
|
|
2967
2972
|
await this.clearSessionState();
|
|
@@ -2974,6 +2979,24 @@ var CodingAgentManager = class {
|
|
|
2974
2979
|
isCompacting() {
|
|
2975
2980
|
return this.compactionInFlight;
|
|
2976
2981
|
}
|
|
2982
|
+
captureCompactionText(text) {
|
|
2983
|
+
if (!this.compactionInFlight) return;
|
|
2984
|
+
const trimmed = text.trim();
|
|
2985
|
+
if (!trimmed) return;
|
|
2986
|
+
this.compactionBuffer = this.compactionBuffer.length > 0 ? `${this.compactionBuffer}
|
|
2987
|
+
|
|
2988
|
+
${trimmed}` : trimmed;
|
|
2989
|
+
}
|
|
2990
|
+
consumePendingPrelude(message) {
|
|
2991
|
+
if (!this.pendingSessionPrelude) return message;
|
|
2992
|
+
const prelude = this.pendingSessionPrelude;
|
|
2993
|
+
this.pendingSessionPrelude = null;
|
|
2994
|
+
return `<prior-session-summary>
|
|
2995
|
+
${prelude}
|
|
2996
|
+
</prior-session-summary>
|
|
2997
|
+
|
|
2998
|
+
${message}`;
|
|
2999
|
+
}
|
|
2977
3000
|
emitCompactionStatus(state) {
|
|
2978
3001
|
this.onEvent({
|
|
2979
3002
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2985,10 +3008,17 @@ var CodingAgentManager = class {
|
|
|
2985
3008
|
const wrappedProcessMessage = async (request) => {
|
|
2986
3009
|
if (request.message.startsWith(COMPACT_TURN_MARKER)) {
|
|
2987
3010
|
this.compactionInFlight = true;
|
|
3011
|
+
this.compactionBuffer = "";
|
|
2988
3012
|
this.emitCompactionStatus("in_progress");
|
|
2989
|
-
|
|
3013
|
+
const summaryPrompt = this.consumePendingPrelude(
|
|
3014
|
+
request.message.slice(COMPACT_TURN_MARKER.length)
|
|
3015
|
+
);
|
|
3016
|
+
return processMessage({ ...request, message: summaryPrompt });
|
|
2990
3017
|
}
|
|
2991
|
-
return processMessage(
|
|
3018
|
+
return processMessage({
|
|
3019
|
+
...request,
|
|
3020
|
+
message: this.consumePendingPrelude(request.message)
|
|
3021
|
+
});
|
|
2992
3022
|
};
|
|
2993
3023
|
this.messageQueue = new MessageQueueService(wrappedProcessMessage);
|
|
2994
3024
|
this.initialized = this.initialize();
|
|
@@ -3713,6 +3743,13 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
3713
3743
|
console.log(`[ClaudeManager] Captured and persisted session ID: ${this.sessionId}`);
|
|
3714
3744
|
}
|
|
3715
3745
|
await this.checkForAuthFailure(message);
|
|
3746
|
+
if (this.isCompacting() && message.type === "assistant") {
|
|
3747
|
+
for (const block of message.message.content) {
|
|
3748
|
+
if (block.type === "text") {
|
|
3749
|
+
this.captureCompactionText(block.text);
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3716
3753
|
await this.recordEvent(message);
|
|
3717
3754
|
}
|
|
3718
3755
|
async recordEvent(event) {
|
|
@@ -4156,6 +4193,18 @@ var CodexManager = class _CodexManager extends CodingAgentManager {
|
|
|
4156
4193
|
}
|
|
4157
4194
|
return null;
|
|
4158
4195
|
}
|
|
4196
|
+
bufferCompactionFromEvent(event) {
|
|
4197
|
+
if (!this.isCompacting()) return;
|
|
4198
|
+
if (event.type !== "response_item") return;
|
|
4199
|
+
const payload = event.payload;
|
|
4200
|
+
if (payload?.type !== "message" || payload?.role !== "assistant") return;
|
|
4201
|
+
const blocks = Array.isArray(payload.content) ? payload.content : [];
|
|
4202
|
+
for (const block of blocks) {
|
|
4203
|
+
if (block.type === "output_text" && typeof block.text === "string") {
|
|
4204
|
+
this.captureCompactionText(block.text);
|
|
4205
|
+
}
|
|
4206
|
+
}
|
|
4207
|
+
}
|
|
4159
4208
|
async startSessionTail(threadId) {
|
|
4160
4209
|
const sessionFile = await this.waitForSessionFile(threadId);
|
|
4161
4210
|
if (!sessionFile) {
|
|
@@ -4206,6 +4255,7 @@ var CodexManager = class _CodexManager extends CodingAgentManager {
|
|
|
4206
4255
|
this.emitQuotaStatus(snapshot);
|
|
4207
4256
|
}
|
|
4208
4257
|
if (isJsonlEvent2(parsed)) {
|
|
4258
|
+
this.bufferCompactionFromEvent(parsed);
|
|
4209
4259
|
this.onEvent(parsed);
|
|
4210
4260
|
emitted += 1;
|
|
4211
4261
|
}
|