replicas-engine 0.1.302 → 0.1.304
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 +102 -14
- 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-12-
|
|
305
|
+
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-06-12-v7";
|
|
305
306
|
|
|
306
307
|
// ../shared/src/runtime-env.ts
|
|
307
308
|
function parsePosixEnvFile(content) {
|
|
@@ -2075,7 +2076,7 @@ function normalizeClaudeModel(model) {
|
|
|
2075
2076
|
}
|
|
2076
2077
|
var AGENT_MODELS = {
|
|
2077
2078
|
claude: [CLAUDE_OPUS_1M_MODEL, CLAUDE_FABLE_5_MODEL, "sonnet", "haiku"],
|
|
2078
|
-
codex: [DEFAULT_CODEX_MODEL, "gpt-5.4", "gpt-5.4-mini", "gpt-5.3-codex", "gpt-5.
|
|
2079
|
+
codex: [DEFAULT_CODEX_MODEL, "gpt-5.4", "gpt-5.4-mini", "gpt-5.3-codex", "gpt-5.2"],
|
|
2079
2080
|
relay: [CLAUDE_OPUS_1M_MODEL, CLAUDE_FABLE_5_MODEL, "sonnet"]
|
|
2080
2081
|
};
|
|
2081
2082
|
var MODEL_LABELS = {
|
|
@@ -2089,14 +2090,7 @@ var MODEL_LABELS = {
|
|
|
2089
2090
|
"gpt-5.4": "GPT-5.4",
|
|
2090
2091
|
"gpt-5.4-mini": "GPT-5.4 Mini",
|
|
2091
2092
|
"gpt-5.3-codex": "GPT-5.3 Codex",
|
|
2092
|
-
"gpt-5.
|
|
2093
|
-
"gpt-5.2-codex": "GPT-5.2 Codex",
|
|
2094
|
-
"gpt-5.2": "GPT-5.2",
|
|
2095
|
-
"gpt-5.1-codex-max": "GPT-5.1 Codex Max",
|
|
2096
|
-
"gpt-5.1-codex": "GPT-5.1 Codex",
|
|
2097
|
-
"gpt-5.1": "GPT-5.1",
|
|
2098
|
-
"gpt-5-codex": "GPT-5 Codex",
|
|
2099
|
-
"gpt-5": "GPT-5"
|
|
2093
|
+
"gpt-5.2": "GPT-5.2"
|
|
2100
2094
|
};
|
|
2101
2095
|
var IMAGE_MEDIA_TYPES = ["image/png", "image/jpeg", "image/gif", "image/webp"];
|
|
2102
2096
|
var CANVAS_KIND_BY_EXTENSION = {
|
|
@@ -5832,6 +5826,11 @@ var COMMAND_PROTECTION_SAFE_TOOLS = /* @__PURE__ */ new Set([
|
|
|
5832
5826
|
"WebFetch",
|
|
5833
5827
|
"LS"
|
|
5834
5828
|
]);
|
|
5829
|
+
var CLAUDE_PARTIAL_MESSAGE_FLUSH_MS = 500;
|
|
5830
|
+
function supportsClaudeThinkingDisplay(model) {
|
|
5831
|
+
const normalized = model.toLowerCase();
|
|
5832
|
+
return AGENT_MODELS.claude.includes(normalized) || normalized === "opus" || /^claude-(?:opus|sonnet|haiku)-4/.test(normalized);
|
|
5833
|
+
}
|
|
5835
5834
|
var TOOL_INPUT_HANDLERS = {
|
|
5836
5835
|
ExitPlanMode: {
|
|
5837
5836
|
getRequest: () => ({
|
|
@@ -5926,6 +5925,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
5926
5925
|
pendingTurn = null;
|
|
5927
5926
|
pendingInterrupt = false;
|
|
5928
5927
|
activeBackgroundTasks = /* @__PURE__ */ new Set();
|
|
5928
|
+
partialMessageStreams = /* @__PURE__ */ new Map();
|
|
5929
|
+
partialMessageFlushTimers = /* @__PURE__ */ new Map();
|
|
5929
5930
|
systemPromptOverride;
|
|
5930
5931
|
toolsOverride;
|
|
5931
5932
|
mcpServersConfig;
|
|
@@ -6307,6 +6308,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
6307
6308
|
...this.mcpServersConfig ? { mcpServers: this.mcpServersConfig } : {},
|
|
6308
6309
|
env: queryEnv,
|
|
6309
6310
|
model: resolvedModel,
|
|
6311
|
+
includePartialMessages: true,
|
|
6312
|
+
...supportsClaudeThinkingDisplay(resolvedModel) ? { thinking: { type: "adaptive", display: "summarized" } } : {},
|
|
6310
6313
|
...thinkingLevel ? { effort: thinkingLevel } : {},
|
|
6311
6314
|
canUseTool: this.buildCanUseTool(),
|
|
6312
6315
|
...ENGINE_ENV.REPLICAS_DISABLE_GH_PR_MERGE ? {
|
|
@@ -6379,6 +6382,11 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
6379
6382
|
this.sessionLinearForwarder = null;
|
|
6380
6383
|
this.sessionLoop = null;
|
|
6381
6384
|
this.activeBackgroundTasks.clear();
|
|
6385
|
+
for (const timer of this.partialMessageFlushTimers.values()) {
|
|
6386
|
+
clearTimeout(timer);
|
|
6387
|
+
}
|
|
6388
|
+
this.partialMessageFlushTimers.clear();
|
|
6389
|
+
this.partialMessageStreams.clear();
|
|
6382
6390
|
}
|
|
6383
6391
|
resolvePendingTurn() {
|
|
6384
6392
|
const pending = this.pendingTurn;
|
|
@@ -6505,6 +6513,80 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
6505
6513
|
events
|
|
6506
6514
|
};
|
|
6507
6515
|
}
|
|
6516
|
+
partialMessageStreamKey(message) {
|
|
6517
|
+
return `${message.session_id}:${message.parent_tool_use_id ?? "root"}`;
|
|
6518
|
+
}
|
|
6519
|
+
clearPartialMessageFlush(key) {
|
|
6520
|
+
const timer = this.partialMessageFlushTimers.get(key);
|
|
6521
|
+
if (!timer) return;
|
|
6522
|
+
clearTimeout(timer);
|
|
6523
|
+
this.partialMessageFlushTimers.delete(key);
|
|
6524
|
+
}
|
|
6525
|
+
flushPartialMessageStream(key, status = "in_progress") {
|
|
6526
|
+
this.clearPartialMessageFlush(key);
|
|
6527
|
+
const stream = this.partialMessageStreams.get(key);
|
|
6528
|
+
if (!stream || !stream.text && !stream.thinking) return;
|
|
6529
|
+
this.onEvent({
|
|
6530
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6531
|
+
type: CLAUDE_PARTIAL_MESSAGE_EVENT_TYPE,
|
|
6532
|
+
payload: {
|
|
6533
|
+
streamId: stream.streamId,
|
|
6534
|
+
parent_tool_use_id: stream.parent_tool_use_id,
|
|
6535
|
+
...stream.text ? { text: stream.text } : {},
|
|
6536
|
+
...stream.thinking ? { thinking: stream.thinking } : {},
|
|
6537
|
+
status
|
|
6538
|
+
}
|
|
6539
|
+
});
|
|
6540
|
+
}
|
|
6541
|
+
schedulePartialMessageFlush(key) {
|
|
6542
|
+
if (this.partialMessageFlushTimers.has(key)) return;
|
|
6543
|
+
this.partialMessageFlushTimers.set(key, setTimeout(() => {
|
|
6544
|
+
this.partialMessageFlushTimers.delete(key);
|
|
6545
|
+
this.flushPartialMessageStream(key);
|
|
6546
|
+
}, CLAUDE_PARTIAL_MESSAGE_FLUSH_MS));
|
|
6547
|
+
}
|
|
6548
|
+
handlePartialAssistantMessage(message) {
|
|
6549
|
+
const key = this.partialMessageStreamKey(message);
|
|
6550
|
+
const streamEvent = message.event;
|
|
6551
|
+
if (streamEvent.type === "message_start") {
|
|
6552
|
+
this.clearPartialMessageFlush(key);
|
|
6553
|
+
this.partialMessageStreams.set(key, {
|
|
6554
|
+
streamId: streamEvent.message.id || key,
|
|
6555
|
+
parent_tool_use_id: message.parent_tool_use_id,
|
|
6556
|
+
text: "",
|
|
6557
|
+
thinking: ""
|
|
6558
|
+
});
|
|
6559
|
+
return;
|
|
6560
|
+
}
|
|
6561
|
+
const stream = this.partialMessageStreams.get(key);
|
|
6562
|
+
if (!stream) return;
|
|
6563
|
+
if (streamEvent.type === "content_block_start") {
|
|
6564
|
+
const block = streamEvent.content_block;
|
|
6565
|
+
if (block.type === "text" && block.text) {
|
|
6566
|
+
stream.text += block.text;
|
|
6567
|
+
this.schedulePartialMessageFlush(key);
|
|
6568
|
+
} else if (block.type === "thinking" && block.thinking) {
|
|
6569
|
+
stream.thinking += block.thinking;
|
|
6570
|
+
this.schedulePartialMessageFlush(key);
|
|
6571
|
+
}
|
|
6572
|
+
return;
|
|
6573
|
+
}
|
|
6574
|
+
if (streamEvent.type === "content_block_delta") {
|
|
6575
|
+
const delta = streamEvent.delta;
|
|
6576
|
+
if (delta.type === "text_delta") {
|
|
6577
|
+
stream.text += delta.text;
|
|
6578
|
+
this.schedulePartialMessageFlush(key);
|
|
6579
|
+
} else if (delta.type === "thinking_delta") {
|
|
6580
|
+
stream.thinking += delta.thinking;
|
|
6581
|
+
this.schedulePartialMessageFlush(key);
|
|
6582
|
+
}
|
|
6583
|
+
return;
|
|
6584
|
+
}
|
|
6585
|
+
if (streamEvent.type === "message_stop") {
|
|
6586
|
+
this.flushPartialMessageStream(key, "completed");
|
|
6587
|
+
this.partialMessageStreams.delete(key);
|
|
6588
|
+
}
|
|
6589
|
+
}
|
|
6508
6590
|
async initialize() {
|
|
6509
6591
|
const historyDir = join13(homedir11(), ".replicas", "claude");
|
|
6510
6592
|
await mkdir10(historyDir, { recursive: true });
|
|
@@ -6519,6 +6601,10 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
6519
6601
|
await this.onSaveSessionId(this.sessionId);
|
|
6520
6602
|
console.log(`[ClaudeManager] Captured and persisted session ID: ${this.sessionId}`);
|
|
6521
6603
|
}
|
|
6604
|
+
if (message.type === "stream_event") {
|
|
6605
|
+
this.handlePartialAssistantMessage(message);
|
|
6606
|
+
return;
|
|
6607
|
+
}
|
|
6522
6608
|
this.trackNativeCompaction(message);
|
|
6523
6609
|
await this.recordEvent(message);
|
|
6524
6610
|
}
|
|
@@ -6741,7 +6827,7 @@ var AspClient = class {
|
|
|
6741
6827
|
// src/managers/codex-asp/app-server-process.ts
|
|
6742
6828
|
var DEFAULT_CODEX_BINARY = "codex";
|
|
6743
6829
|
var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
|
|
6744
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
6830
|
+
var ENGINE_PACKAGE_VERSION = "0.1.304";
|
|
6745
6831
|
var INITIALIZE_METHOD = "initialize";
|
|
6746
6832
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
6747
6833
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -9667,9 +9753,11 @@ var ChatService = class {
|
|
|
9667
9753
|
}
|
|
9668
9754
|
}
|
|
9669
9755
|
}
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
|
|
9756
|
+
if (event.type !== CLAUDE_PARTIAL_MESSAGE_EVENT_TYPE) {
|
|
9757
|
+
this.touch(chat);
|
|
9758
|
+
this.observeCurrentBranches(chat).catch(() => {
|
|
9759
|
+
});
|
|
9760
|
+
}
|
|
9673
9761
|
this.publish({
|
|
9674
9762
|
type: "chat.turn.delta",
|
|
9675
9763
|
payload: {
|