replicas-engine 0.1.876 → 0.1.877

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.
@@ -5,11 +5,11 @@ import {
5
5
  getCodexAspHost,
6
6
  restartCodexAspHost,
7
7
  restartCodexAspHostIfRunning
8
- } from "./chunk-QUDJR3YI.js";
9
- import "./chunk-VONPE7H2.js";
10
- import "./chunk-LDEEMUMD.js";
8
+ } from "./chunk-DFXUDZW3.js";
9
+ import "./chunk-MOJN6DR4.js";
10
+ import "./chunk-VJQGQEZV.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-DFV4EYJI.js";
12
+ import "./chunk-NTUXPZOE.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
  export {
15
15
  getCodexAspHost,
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  shouldRefreshPullRequests
6
- } from "./chunk-DFV4EYJI.js";
6
+ } from "./chunk-NTUXPZOE.js";
7
7
 
8
8
  // src/services/post-tool-pr-notifier.ts
9
9
  async function notifyPostToolUse(toolName, toolInput) {
@@ -5,13 +5,13 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  setAgentCredentialSnapshot
8
- } from "./chunk-VONPE7H2.js";
8
+ } from "./chunk-MOJN6DR4.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  SUBPROCESS_MAX_BUFFER,
12
12
  buildCodexAgentEnv,
13
13
  execFileAsync
14
- } from "./chunk-LDEEMUMD.js";
14
+ } from "./chunk-VJQGQEZV.js";
15
15
  import {
16
16
  isRecord
17
17
  } from "./chunk-UZSNFLDQ.js";
@@ -25,7 +25,7 @@ import {
25
25
  listOpenAICompatibleModels,
26
26
  readOllamaAuthEnv,
27
27
  resolveOpenAICompatibleModelsUrl
28
- } from "./chunk-DFV4EYJI.js";
28
+ } from "./chunk-NTUXPZOE.js";
29
29
 
30
30
  // src/managers/codex-token-manager.ts
31
31
  import { promises as fs } from "fs";
@@ -246,7 +246,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
246
246
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
247
247
  await this.applyCredentialsResponse(data);
248
248
  if (data.scope) setAgentCredentialSnapshot("codex", { method: data.type, scope: data.scope, revision: data.revision });
249
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-7QXMUTSZ.js");
249
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-SQK3BF6S.js");
250
250
  await restartCodexAspHostIfRunning2();
251
251
  });
252
252
  await this.start(true);
@@ -266,7 +266,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
266
266
  await this.applyCredentialUpdate(generation, async () => {
267
267
  await this.applyCredentialsResponse(data);
268
268
  if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
269
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-7QXMUTSZ.js");
269
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-SQK3BF6S.js");
270
270
  await restartCodexAspHostIfRunning2();
271
271
  }
272
272
  if (data.scope) {
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  monolithRequest
6
- } from "./chunk-VONPE7H2.js";
6
+ } from "./chunk-MOJN6DR4.js";
7
7
  import {
8
8
  extractCommandProtectionCommandText,
9
9
  findGitCommitSignals,
10
10
  findPrMergeSignals
11
- } from "./chunk-DFV4EYJI.js";
11
+ } from "./chunk-NTUXPZOE.js";
12
12
 
13
13
  // src/services/command-protection-service.ts
14
14
  var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
@@ -15,7 +15,7 @@ import {
15
15
  isValidRelayBaseProvider,
16
16
  parsePosixEnvFile,
17
17
  readReplicasRuntimeEnv
18
- } from "./chunk-DFV4EYJI.js";
18
+ } from "./chunk-NTUXPZOE.js";
19
19
 
20
20
  // src/engine-env.ts
21
21
  import { readFileSync as readFileSync2 } from "fs";
@@ -3998,6 +3998,15 @@ function removeReplicasInstructions(text) {
3998
3998
  return removeTag(text, REPLICAS_INSTRUCTIONS_TAG);
3999
3999
  }
4000
4000
 
4001
+ // ../shared/src/user-message-matching.ts
4002
+ function parseTimestampMs(timestamp) {
4003
+ const value = typeof timestamp === "number" ? timestamp : Date.parse(timestamp);
4004
+ return Number.isFinite(value) ? value : 0;
4005
+ }
4006
+ function areUserMessagesWithinMatchWindow(a, b) {
4007
+ return a.content === b.content && Math.abs(parseTimestampMs(a.timestamp) - parseTimestampMs(b.timestamp)) <= USER_MESSAGE_MATCH_GRACE_PERIOD_MS;
4008
+ }
4009
+
4001
4010
  // ../shared/src/display-message/parsers/codex-asp-parser.ts
4002
4011
  function collectCodexTurns(events) {
4003
4012
  const turns = /* @__PURE__ */ new Map();
@@ -4265,6 +4274,25 @@ function parsePatch(input) {
4265
4274
  }
4266
4275
  return operations;
4267
4276
  }
4277
+ function takeRecordedPrompt(prompts, echo, turnIndex) {
4278
+ const timestampMs = parseTimestampMs(echo.timestamp);
4279
+ let closestIndex = -1;
4280
+ let closestDistance = Infinity;
4281
+ for (let i = prompts.length - 1; i >= 0; i--) {
4282
+ const candidate = prompts[i];
4283
+ const distance = Math.abs(candidate.timestampMs - timestampMs);
4284
+ if (distance > closestDistance) continue;
4285
+ if (candidate.index >= turnIndex && !areUserMessagesWithinMatchWindow(
4286
+ { content: candidate.message.content, timestamp: candidate.timestampMs },
4287
+ { content: echo.content, timestamp: timestampMs }
4288
+ )) continue;
4289
+ const images = candidate.message.images;
4290
+ if (images && echo.images && (images.length !== echo.images.length || images.some((image, index) => image.mediaType !== echo.images?.[index].mediaType || image.data !== echo.images?.[index].data))) continue;
4291
+ closestIndex = i;
4292
+ closestDistance = distance;
4293
+ }
4294
+ return closestIndex === -1 ? void 0 : prompts.splice(closestIndex, 1)[0].message;
4295
+ }
4268
4296
  function parseCodexEvents(events) {
4269
4297
  const messages = [];
4270
4298
  const turns = collectCodexTurns(events);
@@ -4448,26 +4476,35 @@ function parseCodexEvents(events) {
4448
4476
  }
4449
4477
  }
4450
4478
  });
4479
+ const recordedPrompts = /* @__PURE__ */ new Map();
4480
+ messages.forEach((message, index) => {
4481
+ if (message.type !== "user") return;
4482
+ const prompts = recordedPrompts.get(message.content) ?? [];
4483
+ prompts.push({ message, index, timestampMs: parseTimestampMs(message.timestamp) });
4484
+ recordedPrompts.set(message.content, prompts);
4485
+ });
4451
4486
  const claimedPrompts = /* @__PURE__ */ new Set();
4452
4487
  for (const { index, turnId } of turnInsertions.reverse()) {
4453
4488
  const turn = turns.get(turnId);
4454
4489
  if (!turn) continue;
4455
4490
  const kept = [];
4456
4491
  for (const message of messagesForCodexTurn(turn)) {
4457
- const recordedIndex = message.type === "user" ? messages.findLastIndex((candidate, candidateIndex) => candidateIndex < index && candidate.type === "user" && candidate.content === message.content && !claimedPrompts.has(candidateIndex)) : -1;
4458
- if (recordedIndex === -1) {
4492
+ if (message.type !== "user") {
4459
4493
  kept.push(message);
4460
4494
  continue;
4461
4495
  }
4462
- claimedPrompts.add(recordedIndex);
4463
- const recorded = messages[recordedIndex];
4464
- if (recorded.type === "user" && message.type === "user" && !recorded.images && message.images) {
4465
- messages[recordedIndex] = { ...recorded, images: message.images };
4496
+ const prompts = recordedPrompts.get(message.content);
4497
+ const recorded = prompts && takeRecordedPrompt(prompts, message, index);
4498
+ if (!recorded) {
4499
+ kept.push(message);
4500
+ continue;
4466
4501
  }
4502
+ claimedPrompts.add(recorded);
4503
+ kept.push({ ...recorded, images: recorded.images ?? message.images });
4467
4504
  }
4468
4505
  messages.splice(index, 0, ...kept);
4469
4506
  }
4470
- return messages;
4507
+ return messages.filter((message) => !claimedPrompts.has(message));
4471
4508
  }
4472
4509
 
4473
4510
  // ../shared/src/display-message/parsers/cursor-parser.ts
@@ -5484,15 +5521,6 @@ function parseMcpToolName(name) {
5484
5521
  return { server, tool };
5485
5522
  }
5486
5523
 
5487
- // ../shared/src/user-message-matching.ts
5488
- function parseTimestampMs(timestamp) {
5489
- const value = Date.parse(timestamp);
5490
- return Number.isFinite(value) ? value : 0;
5491
- }
5492
- function areUserMessagesWithinMatchWindow(a, b) {
5493
- return a.content === b.content && Math.abs(parseTimestampMs(a.timestamp) - parseTimestampMs(b.timestamp)) <= USER_MESSAGE_MATCH_GRACE_PERIOD_MS;
5494
- }
5495
-
5496
5524
  // ../shared/src/display-message/parsers/claude-parser.ts
5497
5525
  var ABORTED_TERMINAL_REASONS = /* @__PURE__ */ new Set(["aborted_streaming", "aborted_tools"]);
5498
5526
  function createSubagentMessage(messageIndex, timestamp, fields) {
@@ -8152,13 +8180,13 @@ export {
8152
8180
  MEMORY_ROOT,
8153
8181
  MEMORY_INDEX_FILENAME,
8154
8182
  MEMORY_MARKER_GUIDANCE,
8183
+ areUserMessagesWithinMatchWindow,
8155
8184
  extractErrorText,
8156
8185
  isTransientErrorText,
8157
8186
  extractToolResultText,
8158
8187
  normalizeContentBlocks,
8159
8188
  TaskAccumulator,
8160
8189
  parseMcpToolName,
8161
- areUserMessagesWithinMatchWindow,
8162
8190
  coerceClaudeResultPayload,
8163
8191
  stripAgentDiagnosticErrors,
8164
8192
  isClaudeResultError,
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  HOOK_EXEC_MAX_BUFFER_BYTES,
6
6
  isVersionBelow
7
- } from "./chunk-DFV4EYJI.js";
7
+ } from "./chunk-NTUXPZOE.js";
8
8
 
9
9
  // src/utils/codex-agent-env.ts
10
10
  function buildCodexAgentEnv(source = process.env) {
@@ -245,7 +245,7 @@ function getCodexModelProvider(method) {
245
245
  if (method === "foundry") return "azure";
246
246
  return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
247
247
  }
248
- var ENGINE_PACKAGE_VERSION = "0.1.876";
248
+ var ENGINE_PACKAGE_VERSION = "0.1.877";
249
249
  var INITIALIZE_METHOD = "initialize";
250
250
  var INITIALIZED_NOTIFICATION = "initialized";
251
251
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  evaluateCommandProtection
6
- } from "./chunk-7S5PY3WN.js";
7
- import "./chunk-VONPE7H2.js";
6
+ } from "./chunk-DOC4BA3P.js";
7
+ import "./chunk-MOJN6DR4.js";
8
8
  import {
9
9
  isRecord
10
10
  } from "./chunk-UZSNFLDQ.js";
11
- import "./chunk-DFV4EYJI.js";
11
+ import "./chunk-NTUXPZOE.js";
12
12
  import "./chunk-VEQXQN22.js";
13
13
 
14
14
  // src/command-protection-hook.ts
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  evaluateCommandProtection
6
- } from "./chunk-7S5PY3WN.js";
6
+ } from "./chunk-DOC4BA3P.js";
7
7
  import {
8
8
  notifyPostToolUse
9
- } from "./chunk-UCOIF2JZ.js";
10
- import "./chunk-VONPE7H2.js";
9
+ } from "./chunk-37NX5RE5.js";
10
+ import "./chunk-MOJN6DR4.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-DFV4EYJI.js";
12
+ import "./chunk-NTUXPZOE.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/deepseek-command-protection-plugin.ts
@@ -8,12 +8,12 @@ import {
8
8
  import {
9
9
  AppServerProcess,
10
10
  buildCodexAgentEnv
11
- } from "./chunk-LDEEMUMD.js";
11
+ } from "./chunk-VJQGQEZV.js";
12
12
  import {
13
13
  AGENT,
14
14
  getMemoryOutputSafetyViolation,
15
15
  headlessAgentRequestSchema
16
- } from "./chunk-DFV4EYJI.js";
16
+ } from "./chunk-NTUXPZOE.js";
17
17
  import "./chunk-VEQXQN22.js";
18
18
 
19
19
  // src/headless-agent.ts
package/dist/src/index.js CHANGED
@@ -91,7 +91,7 @@ import {
91
91
  evaluateCommandProtection,
92
92
  extractToolCommand,
93
93
  reportCommandProtectionBlock
94
- } from "./chunk-7S5PY3WN.js";
94
+ } from "./chunk-DOC4BA3P.js";
95
95
  import {
96
96
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
97
97
  AGENT_MESSAGE_DELTA_METHOD,
@@ -132,21 +132,21 @@ import {
132
132
  recordCredentialFallback,
133
133
  recordExhaustedCredential,
134
134
  restartCodexAspHost
135
- } from "./chunk-QUDJR3YI.js";
135
+ } from "./chunk-DFXUDZW3.js";
136
136
  import {
137
137
  ENGINE_ENV,
138
138
  IS_WARMING_MODE,
139
139
  monolithRequest,
140
140
  monolithService,
141
141
  setAgentCredentialSnapshot
142
- } from "./chunk-VONPE7H2.js";
142
+ } from "./chunk-MOJN6DR4.js";
143
143
  import {
144
144
  AspClient,
145
145
  SUBPROCESS_MAX_BUFFER,
146
146
  execAsync,
147
147
  execFileAsync,
148
148
  getCodexModelProvider
149
- } from "./chunk-LDEEMUMD.js";
149
+ } from "./chunk-VJQGQEZV.js";
150
150
  import {
151
151
  isRecord as isRecord2
152
152
  } from "./chunk-UZSNFLDQ.js";
@@ -361,7 +361,7 @@ import {
361
361
  waitRelaySubagentRequestSchema,
362
362
  withTimeout,
363
363
  workspaceCredentialProviderSchema
364
- } from "./chunk-DFV4EYJI.js";
364
+ } from "./chunk-NTUXPZOE.js";
365
365
  import {
366
366
  __commonJS,
367
367
  __export,
@@ -3,11 +3,11 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  notifyPostToolUse
6
- } from "./chunk-UCOIF2JZ.js";
6
+ } from "./chunk-37NX5RE5.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
- import "./chunk-DFV4EYJI.js";
10
+ import "./chunk-NTUXPZOE.js";
11
11
  import "./chunk-VEQXQN22.js";
12
12
 
13
13
  // src/post-tool-pr-hook.ts
@@ -11,7 +11,7 @@ import {
11
11
  relaySubagentResponseSchema,
12
12
  spawnRelaySubagentRequestSchema,
13
13
  waitRelaySubagentRequestSchema
14
- } from "./chunk-DFV4EYJI.js";
14
+ } from "./chunk-NTUXPZOE.js";
15
15
  import "./chunk-VEQXQN22.js";
16
16
 
17
17
  // src/relay-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.876",
3
+ "version": "0.1.877",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",