replicas-engine 0.1.572 → 0.1.574
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 +48 -4
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -3438,6 +3438,13 @@ function findPrMergeSignals(request) {
|
|
|
3438
3438
|
];
|
|
3439
3439
|
return checks.flatMap(([name, pattern]) => pattern.test(combined) ? [name] : []);
|
|
3440
3440
|
}
|
|
3441
|
+
function findGitCommitCommands(command) {
|
|
3442
|
+
return [...command.matchAll(/\bgit(?:\s+-[^\s;&|]+(?:\s+(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|[^\s;&|]+))?)*\s+commit\b(?:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\\\r?\n|[^;&|\r\n])*)/g)].map((match) => match[0]);
|
|
3443
|
+
}
|
|
3444
|
+
function findGitCommitSignals(request) {
|
|
3445
|
+
const command = extractCommandProtectionCommandText(request, { stringifyFallback: true }) ?? "";
|
|
3446
|
+
return findGitCommitCommands(command).length > 0 ? ["git-commit"] : [];
|
|
3447
|
+
}
|
|
3441
3448
|
|
|
3442
3449
|
// ../shared/src/routes/client-state.ts
|
|
3443
3450
|
var MAX_CLIENT_STATE_REQUEST_BYTES = 5 * 1024 * 1024;
|
|
@@ -5338,12 +5345,48 @@ function mergeCodexAspDisplayMessages(primary, supplemental) {
|
|
|
5338
5345
|
}
|
|
5339
5346
|
function parseCodexAspTranscript(transcript) {
|
|
5340
5347
|
const messages = [];
|
|
5341
|
-
const orderedItems = transcript.turns.map((turn, turnIndex) => ({ turn, turnIndex })).flatMap(({ turn, turnIndex }) => turn.items.map((item, itemIndex) => ({ item, turnIndex, itemIndex }))).sort((a, b) => {
|
|
5348
|
+
const orderedItems = transcript.turns.map((turn, turnIndex) => ({ turn, turnIndex })).flatMap(({ turn, turnIndex }) => turn.items.map((item, itemIndex) => ({ item, turn, turnIndex, itemIndex }))).sort((a, b) => {
|
|
5342
5349
|
const aSequence = a.item.sequence ?? Number.MAX_SAFE_INTEGER;
|
|
5343
5350
|
const bSequence = b.item.sequence ?? Number.MAX_SAFE_INTEGER;
|
|
5344
5351
|
return aSequence - bSequence || parseTimestampMs(a.item.timestamp) - parseTimestampMs(b.item.timestamp) || a.turnIndex - b.turnIndex || a.itemIndex - b.itemIndex;
|
|
5345
5352
|
});
|
|
5346
|
-
|
|
5353
|
+
const reasoningByTurnId = /* @__PURE__ */ new Map();
|
|
5354
|
+
for (const { item, turn } of orderedItems) {
|
|
5355
|
+
if (item.type !== "reasoning" || !item.text.trim()) continue;
|
|
5356
|
+
const reasoning = reasoningByTurnId.get(turn.id) ?? [];
|
|
5357
|
+
reasoning.push(item);
|
|
5358
|
+
reasoningByTurnId.set(turn.id, reasoning);
|
|
5359
|
+
}
|
|
5360
|
+
const emittedReasoningTurnIds = /* @__PURE__ */ new Set();
|
|
5361
|
+
const coalescedItems = orderedItems.flatMap((entry) => {
|
|
5362
|
+
if (entry.item.type !== "reasoning") return [entry];
|
|
5363
|
+
const reasoning = reasoningByTurnId.get(entry.turn.id);
|
|
5364
|
+
if (!reasoning || emittedReasoningTurnIds.has(entry.turn.id)) return [];
|
|
5365
|
+
emittedReasoningTurnIds.add(entry.turn.id);
|
|
5366
|
+
return [{
|
|
5367
|
+
...entry,
|
|
5368
|
+
item: {
|
|
5369
|
+
type: "reasoning",
|
|
5370
|
+
id: entry.turn.id,
|
|
5371
|
+
text: reasoning.map(({ text }) => text.trim()).join("\n\n"),
|
|
5372
|
+
timestamp: entry.turn.startedAt,
|
|
5373
|
+
status: reasoning.at(-1)?.status ?? "completed",
|
|
5374
|
+
sequence: entry.item.sequence
|
|
5375
|
+
}
|
|
5376
|
+
}];
|
|
5377
|
+
});
|
|
5378
|
+
for (const turn of transcript.turns) {
|
|
5379
|
+
const reasoningIndex = coalescedItems.findIndex(({ item, turn: itemTurn }) => itemTurn.id === turn.id && item.type === "reasoning");
|
|
5380
|
+
if (reasoningIndex === -1) continue;
|
|
5381
|
+
let finalAnswerIndex = coalescedItems.findIndex(({ item, turn: itemTurn }) => itemTurn.id === turn.id && item.type === "agentMessage" && item.phase === "final_answer");
|
|
5382
|
+
if (finalAnswerIndex === -1 && normalizeCodexAspTranscriptStatus(turn.status) !== "in_progress") {
|
|
5383
|
+
finalAnswerIndex = coalescedItems.findLastIndex(({ item, turn: itemTurn }) => itemTurn.id === turn.id && item.type === "agentMessage");
|
|
5384
|
+
}
|
|
5385
|
+
if (finalAnswerIndex === -1 || reasoningIndex < finalAnswerIndex) continue;
|
|
5386
|
+
const [reasoning] = coalescedItems.splice(reasoningIndex, 1);
|
|
5387
|
+
coalescedItems.splice(finalAnswerIndex, 0, reasoning);
|
|
5388
|
+
}
|
|
5389
|
+
for (const { item } of coalescedItems) {
|
|
5347
5390
|
const message = messageForItem(item);
|
|
5348
5391
|
if (message) {
|
|
5349
5392
|
messages.push(message);
|
|
@@ -9012,7 +9055,7 @@ function failClosed(reason, matchedSignals) {
|
|
|
9012
9055
|
};
|
|
9013
9056
|
}
|
|
9014
9057
|
async function evaluateCommandProtection(request, signal) {
|
|
9015
|
-
const matchedSignals = findPrMergeSignals(request);
|
|
9058
|
+
const matchedSignals = [...findGitCommitSignals(request), ...findPrMergeSignals(request)];
|
|
9016
9059
|
if (matchedSignals.length === 0) {
|
|
9017
9060
|
return { allowed: true, enabled: true };
|
|
9018
9061
|
}
|
|
@@ -10780,7 +10823,7 @@ var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
|
|
|
10780
10823
|
var MIN_CODEX_CLI_VERSION = "0.144.6";
|
|
10781
10824
|
var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
|
|
10782
10825
|
var codexCliVersionEnsured = null;
|
|
10783
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
10826
|
+
var ENGINE_PACKAGE_VERSION = "0.1.574";
|
|
10784
10827
|
var INITIALIZE_METHOD = "initialize";
|
|
10785
10828
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
10786
10829
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -11215,6 +11258,7 @@ function itemToTranscriptItem(item, timestamp, status) {
|
|
|
11215
11258
|
type: "agentMessage",
|
|
11216
11259
|
id: item.id,
|
|
11217
11260
|
text: item.text,
|
|
11261
|
+
phase: item.phase,
|
|
11218
11262
|
timestamp
|
|
11219
11263
|
};
|
|
11220
11264
|
}
|