replicas-engine 0.1.303 → 0.1.305
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 +130 -5
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -41,6 +41,7 @@ function codexReasoningEffortForThinkingLevel(thinkingLevel) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// ../shared/src/event.ts
|
|
44
|
+
var CLAUDE_PARTIAL_MESSAGE_EVENT_TYPE = "claude-partial-message";
|
|
44
45
|
var ACCEPTED_USER_MESSAGE_SOURCE = "replicas-chat-turn-accepted";
|
|
45
46
|
var USER_MESSAGE_ID_PAYLOAD_KEY = "replicasMessageId";
|
|
46
47
|
var CODEX_ASP_ITEM_ID_PAYLOAD_KEY = "codexAspItemId";
|
|
@@ -301,7 +302,7 @@ var WORKSPACE_SIZES = ["small", "large"];
|
|
|
301
302
|
var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
|
|
302
303
|
|
|
303
304
|
// ../shared/src/e2b.ts
|
|
304
|
-
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-06-
|
|
305
|
+
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-06-13-v1";
|
|
305
306
|
|
|
306
307
|
// ../shared/src/runtime-env.ts
|
|
307
308
|
function parsePosixEnvFile(content) {
|
|
@@ -5394,6 +5395,11 @@ var MessageQueueService = class {
|
|
|
5394
5395
|
this.queue.splice(index, 1);
|
|
5395
5396
|
return true;
|
|
5396
5397
|
}
|
|
5398
|
+
clearQueue() {
|
|
5399
|
+
if (this.queue.length === 0) return false;
|
|
5400
|
+
this.queue = [];
|
|
5401
|
+
return true;
|
|
5402
|
+
}
|
|
5397
5403
|
/**
|
|
5398
5404
|
* Move a message to a new position in the queue
|
|
5399
5405
|
* @returns true if the message was found and moved
|
|
@@ -5490,6 +5496,9 @@ var CodingAgentManager = class {
|
|
|
5490
5496
|
removeFromQueue(messageId) {
|
|
5491
5497
|
return this.messageQueue.removeFromQueue(messageId);
|
|
5492
5498
|
}
|
|
5499
|
+
clearQueue() {
|
|
5500
|
+
return this.messageQueue.clearQueue();
|
|
5501
|
+
}
|
|
5493
5502
|
reorderQueue(messageId, newPosition) {
|
|
5494
5503
|
return this.messageQueue.reorderQueue(messageId, newPosition);
|
|
5495
5504
|
}
|
|
@@ -5825,6 +5834,11 @@ var COMMAND_PROTECTION_SAFE_TOOLS = /* @__PURE__ */ new Set([
|
|
|
5825
5834
|
"WebFetch",
|
|
5826
5835
|
"LS"
|
|
5827
5836
|
]);
|
|
5837
|
+
var CLAUDE_PARTIAL_MESSAGE_FLUSH_MS = 500;
|
|
5838
|
+
function supportsClaudeThinkingDisplay(model) {
|
|
5839
|
+
const normalized = model.toLowerCase();
|
|
5840
|
+
return AGENT_MODELS.claude.includes(normalized) || normalized === "opus" || /^claude-(?:opus|sonnet|haiku)-4/.test(normalized);
|
|
5841
|
+
}
|
|
5828
5842
|
var TOOL_INPUT_HANDLERS = {
|
|
5829
5843
|
ExitPlanMode: {
|
|
5830
5844
|
getRequest: () => ({
|
|
@@ -5919,6 +5933,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
5919
5933
|
pendingTurn = null;
|
|
5920
5934
|
pendingInterrupt = false;
|
|
5921
5935
|
activeBackgroundTasks = /* @__PURE__ */ new Set();
|
|
5936
|
+
partialMessageStreams = /* @__PURE__ */ new Map();
|
|
5937
|
+
partialMessageFlushTimers = /* @__PURE__ */ new Map();
|
|
5922
5938
|
systemPromptOverride;
|
|
5923
5939
|
toolsOverride;
|
|
5924
5940
|
mcpServersConfig;
|
|
@@ -6300,6 +6316,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
6300
6316
|
...this.mcpServersConfig ? { mcpServers: this.mcpServersConfig } : {},
|
|
6301
6317
|
env: queryEnv,
|
|
6302
6318
|
model: resolvedModel,
|
|
6319
|
+
includePartialMessages: true,
|
|
6320
|
+
...supportsClaudeThinkingDisplay(resolvedModel) ? { thinking: { type: "adaptive", display: "summarized" } } : {},
|
|
6303
6321
|
...thinkingLevel ? { effort: thinkingLevel } : {},
|
|
6304
6322
|
canUseTool: this.buildCanUseTool(),
|
|
6305
6323
|
...ENGINE_ENV.REPLICAS_DISABLE_GH_PR_MERGE ? {
|
|
@@ -6372,6 +6390,11 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
6372
6390
|
this.sessionLinearForwarder = null;
|
|
6373
6391
|
this.sessionLoop = null;
|
|
6374
6392
|
this.activeBackgroundTasks.clear();
|
|
6393
|
+
for (const timer of this.partialMessageFlushTimers.values()) {
|
|
6394
|
+
clearTimeout(timer);
|
|
6395
|
+
}
|
|
6396
|
+
this.partialMessageFlushTimers.clear();
|
|
6397
|
+
this.partialMessageStreams.clear();
|
|
6375
6398
|
}
|
|
6376
6399
|
resolvePendingTurn() {
|
|
6377
6400
|
const pending = this.pendingTurn;
|
|
@@ -6498,6 +6521,80 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
6498
6521
|
events
|
|
6499
6522
|
};
|
|
6500
6523
|
}
|
|
6524
|
+
partialMessageStreamKey(message) {
|
|
6525
|
+
return `${message.session_id}:${message.parent_tool_use_id ?? "root"}`;
|
|
6526
|
+
}
|
|
6527
|
+
clearPartialMessageFlush(key) {
|
|
6528
|
+
const timer = this.partialMessageFlushTimers.get(key);
|
|
6529
|
+
if (!timer) return;
|
|
6530
|
+
clearTimeout(timer);
|
|
6531
|
+
this.partialMessageFlushTimers.delete(key);
|
|
6532
|
+
}
|
|
6533
|
+
flushPartialMessageStream(key, status = "in_progress") {
|
|
6534
|
+
this.clearPartialMessageFlush(key);
|
|
6535
|
+
const stream = this.partialMessageStreams.get(key);
|
|
6536
|
+
if (!stream || !stream.text && !stream.thinking) return;
|
|
6537
|
+
this.onEvent({
|
|
6538
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6539
|
+
type: CLAUDE_PARTIAL_MESSAGE_EVENT_TYPE,
|
|
6540
|
+
payload: {
|
|
6541
|
+
streamId: stream.streamId,
|
|
6542
|
+
parent_tool_use_id: stream.parent_tool_use_id,
|
|
6543
|
+
...stream.text ? { text: stream.text } : {},
|
|
6544
|
+
...stream.thinking ? { thinking: stream.thinking } : {},
|
|
6545
|
+
status
|
|
6546
|
+
}
|
|
6547
|
+
});
|
|
6548
|
+
}
|
|
6549
|
+
schedulePartialMessageFlush(key) {
|
|
6550
|
+
if (this.partialMessageFlushTimers.has(key)) return;
|
|
6551
|
+
this.partialMessageFlushTimers.set(key, setTimeout(() => {
|
|
6552
|
+
this.partialMessageFlushTimers.delete(key);
|
|
6553
|
+
this.flushPartialMessageStream(key);
|
|
6554
|
+
}, CLAUDE_PARTIAL_MESSAGE_FLUSH_MS));
|
|
6555
|
+
}
|
|
6556
|
+
handlePartialAssistantMessage(message) {
|
|
6557
|
+
const key = this.partialMessageStreamKey(message);
|
|
6558
|
+
const streamEvent = message.event;
|
|
6559
|
+
if (streamEvent.type === "message_start") {
|
|
6560
|
+
this.clearPartialMessageFlush(key);
|
|
6561
|
+
this.partialMessageStreams.set(key, {
|
|
6562
|
+
streamId: streamEvent.message.id || key,
|
|
6563
|
+
parent_tool_use_id: message.parent_tool_use_id,
|
|
6564
|
+
text: "",
|
|
6565
|
+
thinking: ""
|
|
6566
|
+
});
|
|
6567
|
+
return;
|
|
6568
|
+
}
|
|
6569
|
+
const stream = this.partialMessageStreams.get(key);
|
|
6570
|
+
if (!stream) return;
|
|
6571
|
+
if (streamEvent.type === "content_block_start") {
|
|
6572
|
+
const block = streamEvent.content_block;
|
|
6573
|
+
if (block.type === "text" && block.text) {
|
|
6574
|
+
stream.text += block.text;
|
|
6575
|
+
this.schedulePartialMessageFlush(key);
|
|
6576
|
+
} else if (block.type === "thinking" && block.thinking) {
|
|
6577
|
+
stream.thinking += block.thinking;
|
|
6578
|
+
this.schedulePartialMessageFlush(key);
|
|
6579
|
+
}
|
|
6580
|
+
return;
|
|
6581
|
+
}
|
|
6582
|
+
if (streamEvent.type === "content_block_delta") {
|
|
6583
|
+
const delta = streamEvent.delta;
|
|
6584
|
+
if (delta.type === "text_delta") {
|
|
6585
|
+
stream.text += delta.text;
|
|
6586
|
+
this.schedulePartialMessageFlush(key);
|
|
6587
|
+
} else if (delta.type === "thinking_delta") {
|
|
6588
|
+
stream.thinking += delta.thinking;
|
|
6589
|
+
this.schedulePartialMessageFlush(key);
|
|
6590
|
+
}
|
|
6591
|
+
return;
|
|
6592
|
+
}
|
|
6593
|
+
if (streamEvent.type === "message_stop") {
|
|
6594
|
+
this.flushPartialMessageStream(key, "completed");
|
|
6595
|
+
this.partialMessageStreams.delete(key);
|
|
6596
|
+
}
|
|
6597
|
+
}
|
|
6501
6598
|
async initialize() {
|
|
6502
6599
|
const historyDir = join13(homedir11(), ".replicas", "claude");
|
|
6503
6600
|
await mkdir10(historyDir, { recursive: true });
|
|
@@ -6512,6 +6609,10 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
6512
6609
|
await this.onSaveSessionId(this.sessionId);
|
|
6513
6610
|
console.log(`[ClaudeManager] Captured and persisted session ID: ${this.sessionId}`);
|
|
6514
6611
|
}
|
|
6612
|
+
if (message.type === "stream_event") {
|
|
6613
|
+
this.handlePartialAssistantMessage(message);
|
|
6614
|
+
return;
|
|
6615
|
+
}
|
|
6515
6616
|
this.trackNativeCompaction(message);
|
|
6516
6617
|
await this.recordEvent(message);
|
|
6517
6618
|
}
|
|
@@ -6734,7 +6835,7 @@ var AspClient = class {
|
|
|
6734
6835
|
// src/managers/codex-asp/app-server-process.ts
|
|
6735
6836
|
var DEFAULT_CODEX_BINARY = "codex";
|
|
6736
6837
|
var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
|
|
6737
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
6838
|
+
var ENGINE_PACKAGE_VERSION = "0.1.305";
|
|
6738
6839
|
var INITIALIZE_METHOD = "initialize";
|
|
6739
6840
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
6740
6841
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -8991,6 +9092,9 @@ var RelayManager = class {
|
|
|
8991
9092
|
removeFromQueue(messageId) {
|
|
8992
9093
|
return this.inner.removeFromQueue(messageId);
|
|
8993
9094
|
}
|
|
9095
|
+
clearQueue() {
|
|
9096
|
+
return this.inner.clearQueue();
|
|
9097
|
+
}
|
|
8994
9098
|
reorderQueue(messageId, newPosition) {
|
|
8995
9099
|
return this.inner.reorderQueue(messageId, newPosition);
|
|
8996
9100
|
}
|
|
@@ -9436,6 +9540,14 @@ var ChatService = class {
|
|
|
9436
9540
|
queue: chat.provider.getQueue()
|
|
9437
9541
|
};
|
|
9438
9542
|
}
|
|
9543
|
+
clearQueue(chatId) {
|
|
9544
|
+
const chat = this.requireChat(chatId);
|
|
9545
|
+
const success = chat.provider.clearQueue();
|
|
9546
|
+
return {
|
|
9547
|
+
success,
|
|
9548
|
+
queue: chat.provider.getQueue()
|
|
9549
|
+
};
|
|
9550
|
+
}
|
|
9439
9551
|
reorderQueue(chatId, messageId, position) {
|
|
9440
9552
|
const chat = this.requireChat(chatId);
|
|
9441
9553
|
const success = chat.provider.reorderQueue(messageId, position);
|
|
@@ -9660,9 +9772,11 @@ var ChatService = class {
|
|
|
9660
9772
|
}
|
|
9661
9773
|
}
|
|
9662
9774
|
}
|
|
9663
|
-
|
|
9664
|
-
|
|
9665
|
-
|
|
9775
|
+
if (event.type !== CLAUDE_PARTIAL_MESSAGE_EVENT_TYPE) {
|
|
9776
|
+
this.touch(chat);
|
|
9777
|
+
this.observeCurrentBranches(chat).catch(() => {
|
|
9778
|
+
});
|
|
9779
|
+
}
|
|
9666
9780
|
this.publish({
|
|
9667
9781
|
type: "chat.turn.delta",
|
|
9668
9782
|
payload: {
|
|
@@ -10793,6 +10907,17 @@ function createV1Routes(deps) {
|
|
|
10793
10907
|
return c.json(jsonError("Failed to get queue", error instanceof Error ? error.message : "Unknown error"), 500);
|
|
10794
10908
|
}
|
|
10795
10909
|
});
|
|
10910
|
+
app2.delete("/chats/:chatId/queue", (c) => {
|
|
10911
|
+
try {
|
|
10912
|
+
const result = deps.chatService.clearQueue(c.req.param("chatId"));
|
|
10913
|
+
return c.json(result);
|
|
10914
|
+
} catch (error) {
|
|
10915
|
+
if (error instanceof ChatNotFoundError) {
|
|
10916
|
+
return c.json(jsonError("Chat not found", error.message), 404);
|
|
10917
|
+
}
|
|
10918
|
+
return c.json(jsonError("Failed to clear queue", error instanceof Error ? error.message : "Unknown error"), 500);
|
|
10919
|
+
}
|
|
10920
|
+
});
|
|
10796
10921
|
app2.delete("/chats/:chatId/queue/:messageId", (c) => {
|
|
10797
10922
|
try {
|
|
10798
10923
|
const result = deps.chatService.removeFromQueue(c.req.param("chatId"), c.req.param("messageId"));
|