replicas-engine 0.1.782 → 0.1.784

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-CG6LJND6.js";
9
- import "./chunk-D3WNK45A.js";
10
- import "./chunk-MCPX7RQG.js";
8
+ } from "./chunk-4C6X7DTG.js";
9
+ import "./chunk-YRK3AKS5.js";
10
+ import "./chunk-ASPROGDI.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-LYIXF36I.js";
12
+ import "./chunk-YSUQDUHX.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
  export {
15
15
  getCodexAspHost,
@@ -5,18 +5,18 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  setAgentCredentialSnapshot
8
- } from "./chunk-D3WNK45A.js";
8
+ } from "./chunk-YRK3AKS5.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  buildCodexAgentEnv
12
- } from "./chunk-MCPX7RQG.js";
12
+ } from "./chunk-ASPROGDI.js";
13
13
  import {
14
14
  CODEX_AUTH_ENV_KEYS,
15
15
  CODEX_AUTH_ENV_KEYS_BY_METHOD,
16
16
  codexAuthEnvFromResponse,
17
17
  createErrorResult,
18
18
  createSuccessResult
19
- } from "./chunk-LYIXF36I.js";
19
+ } from "./chunk-YSUQDUHX.js";
20
20
 
21
21
  // src/managers/codex-token-manager.ts
22
22
  import { promises as fs } from "fs";
@@ -232,7 +232,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
232
232
  const data = await response.json();
233
233
  await this.applyCredentialsResponse(data);
234
234
  if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
235
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-AYGDQXIX.js");
235
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-SNPWGUDH.js");
236
236
  await restartCodexAspHostIfRunning2();
237
237
  }
238
238
  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-D3WNK45A.js";
6
+ } from "./chunk-YRK3AKS5.js";
7
7
  import {
8
8
  extractCommandProtectionCommandText,
9
9
  findGitCommitSignals,
10
10
  findPrMergeSignals
11
- } from "./chunk-LYIXF36I.js";
11
+ } from "./chunk-YSUQDUHX.js";
12
12
 
13
13
  // src/services/command-protection-service.ts
14
14
  var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
@@ -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-LYIXF36I.js";
7
+ } from "./chunk-YSUQDUHX.js";
8
8
 
9
9
  // src/utils/codex-agent-env.ts
10
10
  function buildCodexAgentEnv(source = process.env) {
@@ -241,7 +241,7 @@ var DEFAULT_CODEX_ARGS = [
241
241
  var MIN_CODEX_CLI_VERSION = "0.153.3";
242
242
  var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
243
243
  var codexCliVersionEnsured = null;
244
- var ENGINE_PACKAGE_VERSION = "0.1.782";
244
+ var ENGINE_PACKAGE_VERSION = "0.1.784";
245
245
  var INITIALIZE_METHOD = "initialize";
246
246
  var INITIALIZED_NOTIFICATION = "initialized";
247
247
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  findCodeHostPullRequestUrls,
6
6
  mayCreatePullRequest
7
- } from "./chunk-LYIXF36I.js";
7
+ } from "./chunk-YSUQDUHX.js";
8
8
 
9
9
  // src/services/post-tool-pr-notifier.ts
10
10
  async function notifyPostToolUse(toolName, toolInput, toolResult) {
@@ -15,7 +15,7 @@ import {
15
15
  isValidRelayBaseProvider,
16
16
  parsePosixEnvFile,
17
17
  readReplicasRuntimeEnv
18
- } from "./chunk-LYIXF36I.js";
18
+ } from "./chunk-YSUQDUHX.js";
19
19
 
20
20
  // src/engine-env.ts
21
21
  import { readFileSync as readFileSync2 } from "fs";
@@ -885,41 +885,36 @@ function applyCodexAspTranscriptDelta(current, delta) {
885
885
  updatedAt: delta.updatedAt,
886
886
  turns: []
887
887
  });
888
- const turns = base.turns.map((turn) => ({
889
- ...turn,
890
- items: [...turn.items]
891
- }));
888
+ const turns = base.turns.map((turn) => delta.reset ? { ...turn, items: [...turn.items] } : turn);
889
+ const changedTurns = new Set(delta.reset ? turns : []);
890
+ const turnIndexes = new Map(turns.map((turn, index) => [turn.id, index]));
892
891
  for (const turnDelta of delta.turns) {
893
- let turn = turns.find((candidate) => candidate.id === turnDelta.id);
894
- if (!turn) {
895
- turn = {
896
- id: turnDelta.id,
897
- status: turnDelta.status,
898
- startedAt: turnDelta.startedAt,
899
- completedAt: turnDelta.completedAt,
900
- items: []
901
- };
902
- turns.push(turn);
903
- } else {
904
- turn.status = turnDelta.status;
905
- turn.startedAt = turnDelta.startedAt;
906
- turn.completedAt = turnDelta.completedAt;
907
- }
892
+ const turnIndex = turnIndexes.get(turnDelta.id) ?? turns.length;
893
+ const previousTurn = turns[turnIndex];
894
+ const turn = {
895
+ ...previousTurn,
896
+ id: turnDelta.id,
897
+ status: turnDelta.status,
898
+ startedAt: turnDelta.startedAt,
899
+ completedAt: turnDelta.completedAt,
900
+ items: [...previousTurn?.items ?? []]
901
+ };
902
+ turnIndexes.set(turn.id, turnIndex);
903
+ turns[turnIndex] = turn;
904
+ const itemIndexes = new Map(turn.items.map((item, index) => [item.id, index]));
908
905
  for (const itemDelta of turnDelta.items) {
909
- const itemIndex = turn.items.findIndex((item) => item.id === itemDelta.id);
906
+ const itemIndex = itemIndexes.get(itemDelta.id) ?? turn.items.length;
910
907
  const patched = patchCodexAspTranscriptItem(turn.items[itemIndex], itemDelta);
911
908
  if (!patched) continue;
912
- if (itemIndex === -1) {
913
- turn.items.push(patched);
914
- } else {
915
- turn.items[itemIndex] = patched;
916
- }
909
+ itemIndexes.set(itemDelta.id, itemIndex);
910
+ turn.items[itemIndex] = patched;
917
911
  }
912
+ changedTurns.add(turn);
918
913
  }
919
- turns.sort((a, b) => Date.parse(a.startedAt) - Date.parse(b.startedAt));
920
- for (const turn of turns) {
914
+ for (const turn of changedTurns) {
921
915
  turn.items.sort((a, b) => (a.sequence ?? Number.MAX_SAFE_INTEGER) - (b.sequence ?? Number.MAX_SAFE_INTEGER) || Date.parse(a.timestamp) - Date.parse(b.timestamp));
922
916
  }
917
+ turns.sort((a, b) => Date.parse(a.startedAt) - Date.parse(b.startedAt));
923
918
  return {
924
919
  threadId: delta.threadId,
925
920
  updatedAt: delta.updatedAt,
@@ -6240,6 +6235,7 @@ var PLANS = {
6240
6235
  "Unlimited automations",
6241
6236
  "Warm pools and warm hooks",
6242
6237
  "Higher API rate limits",
6238
+ "Mobile app",
6243
6239
  "Access to a static egress IP",
6244
6240
  "Auto-upgraded sandbox resources (4 vCPU, 32 GB disk, 16 GB memory)",
6245
6241
  "Shared Slack support channel"
@@ -6256,6 +6252,7 @@ var PLANS = {
6256
6252
  "Unlimited automations",
6257
6253
  "Custom warm hooks and pools",
6258
6254
  "Custom API rates",
6255
+ "Mobile app",
6259
6256
  "Custom rate limits",
6260
6257
  "Shared Slack support channel",
6261
6258
  "SOC 2",
@@ -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-YZTSUH4U.js";
7
- import "./chunk-D3WNK45A.js";
6
+ } from "./chunk-65OJBHL5.js";
7
+ import "./chunk-YRK3AKS5.js";
8
8
  import {
9
9
  isRecord
10
10
  } from "./chunk-UZSNFLDQ.js";
11
- import "./chunk-LYIXF36I.js";
11
+ import "./chunk-YSUQDUHX.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-YZTSUH4U.js";
6
+ } from "./chunk-65OJBHL5.js";
7
7
  import {
8
8
  notifyPostToolUse
9
- } from "./chunk-JXXGULZ6.js";
10
- import "./chunk-D3WNK45A.js";
9
+ } from "./chunk-F7EM7PIH.js";
10
+ import "./chunk-YRK3AKS5.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-LYIXF36I.js";
12
+ import "./chunk-YSUQDUHX.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-MCPX7RQG.js";
11
+ } from "./chunk-ASPROGDI.js";
12
12
  import {
13
13
  AGENT,
14
14
  getMemoryOutputSafetyViolation,
15
15
  headlessAgentRequestSchema
16
- } from "./chunk-LYIXF36I.js";
16
+ } from "./chunk-YSUQDUHX.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-YZTSUH4U.js";
94
+ } from "./chunk-65OJBHL5.js";
95
95
  import {
96
96
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
97
97
  AGENT_MESSAGE_DELTA_METHOD,
@@ -124,20 +124,20 @@ import {
124
124
  recordCredentialFallback,
125
125
  recordExhaustedCredential,
126
126
  restartCodexAspHost
127
- } from "./chunk-CG6LJND6.js";
127
+ } from "./chunk-4C6X7DTG.js";
128
128
  import {
129
129
  ENGINE_ENV,
130
130
  IS_WARMING_MODE,
131
131
  monolithRequest,
132
132
  monolithService,
133
133
  setAgentCredentialSnapshot
134
- } from "./chunk-D3WNK45A.js";
134
+ } from "./chunk-YRK3AKS5.js";
135
135
  import {
136
136
  AspClient,
137
137
  SUBPROCESS_MAX_BUFFER,
138
138
  execAsync,
139
139
  execFileAsync
140
- } from "./chunk-MCPX7RQG.js";
140
+ } from "./chunk-ASPROGDI.js";
141
141
  import {
142
142
  isRecord as isRecord2
143
143
  } from "./chunk-UZSNFLDQ.js";
@@ -338,7 +338,7 @@ import {
338
338
  spawnRelaySubagentRequestSchema,
339
339
  stripAgentDiagnosticErrors,
340
340
  withTimeout
341
- } from "./chunk-LYIXF36I.js";
341
+ } from "./chunk-YSUQDUHX.js";
342
342
  import {
343
343
  __commonJS,
344
344
  __export,
@@ -14698,7 +14698,8 @@ var CodexAspManager = class extends CodingAgentManager {
14698
14698
  attachedDeveloperInstructions = null;
14699
14699
  historyFile;
14700
14700
  codexAspTranscript = null;
14701
- lastEmittedTranscripts = /* @__PURE__ */ new Map();
14701
+ lastEmittedTranscript = null;
14702
+ dirtyTranscriptTurns = /* @__PURE__ */ new Map();
14702
14703
  codexAspSequence = 0;
14703
14704
  quotaStatus = new CodexQuotaStatusTracker();
14704
14705
  currentGoal = null;
@@ -15648,9 +15649,13 @@ var CodexAspManager = class extends CodingAgentManager {
15648
15649
  }
15649
15650
  mergeTranscriptSnapshot(snapshot) {
15650
15651
  if (snapshot?.threadId && this.codexAspTranscript?.threadId !== snapshot.threadId) {
15651
- this.lastEmittedTranscripts.clear();
15652
+ this.lastEmittedTranscript = null;
15653
+ this.dirtyTranscriptTurns.clear();
15652
15654
  }
15653
15655
  this.codexAspTranscript = mergeCodexAspTranscripts(this.codexAspTranscript, snapshot);
15656
+ for (const turn of this.codexAspTranscript?.turns ?? []) {
15657
+ this.dirtyTranscriptTurns.set(turn.id, turn);
15658
+ }
15654
15659
  this.syncTranscriptSequence(this.codexAspTranscript);
15655
15660
  return this.codexAspTranscript;
15656
15661
  }
@@ -15658,7 +15663,8 @@ var CodexAspManager = class extends CodingAgentManager {
15658
15663
  if (this.codexAspTranscript?.threadId === threadId) {
15659
15664
  return this.codexAspTranscript;
15660
15665
  }
15661
- this.lastEmittedTranscripts.clear();
15666
+ this.lastEmittedTranscript = null;
15667
+ this.dirtyTranscriptTurns.clear();
15662
15668
  this.codexAspTranscript = {
15663
15669
  threadId,
15664
15670
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -15680,8 +15686,8 @@ var CodexAspManager = class extends CodingAgentManager {
15680
15686
  };
15681
15687
  transcript.turns.push(turn);
15682
15688
  transcript.turns.sort((a, b) => Date.parse(a.startedAt) - Date.parse(b.startedAt));
15683
- return turn;
15684
15689
  }
15690
+ this.dirtyTranscriptTurns.set(turnId, turn);
15685
15691
  if (Date.parse(startedAt) < Date.parse(turn.startedAt)) {
15686
15692
  turn.startedAt = startedAt;
15687
15693
  }
@@ -15836,6 +15842,7 @@ var CodexAspManager = class extends CodingAgentManager {
15836
15842
  if (itemIndex === -1) return;
15837
15843
  const item = turn.items[itemIndex];
15838
15844
  if (item.type !== "commandExecution" && item.type !== "fileChange") return;
15845
+ this.dirtyTranscriptTurns.set(turnId, turn);
15839
15846
  turn.items[itemIndex] = {
15840
15847
  ...item,
15841
15848
  output: appendCodexAspTranscriptOutput(item.output, delta),
@@ -15887,6 +15894,7 @@ var CodexAspManager = class extends CodingAgentManager {
15887
15894
  this.transcriptUpdateCoalescer.schedule(threadId, options);
15888
15895
  }
15889
15896
  buildTranscriptItemDelta(previous, current) {
15897
+ if (previous === current) return null;
15890
15898
  if (!previous || previous.type !== current.type) {
15891
15899
  return { id: current.id, item: structuredClone(current) };
15892
15900
  }
@@ -15914,9 +15922,9 @@ var CodexAspManager = class extends CodingAgentManager {
15914
15922
  return { id: current.id, item: structuredClone(current) };
15915
15923
  }
15916
15924
  buildTranscriptDelta(threadId, current) {
15917
- const previous = this.lastEmittedTranscripts.get(threadId);
15925
+ const previous = this.lastEmittedTranscript;
15918
15926
  const updatedAt = current?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString();
15919
- if (!current || previous === void 0 || previous?.threadId !== current.threadId) {
15927
+ if (!current || !previous || previous.threadId !== current.threadId) {
15920
15928
  return {
15921
15929
  threadId,
15922
15930
  updatedAt,
@@ -15925,8 +15933,8 @@ var CodexAspManager = class extends CodingAgentManager {
15925
15933
  };
15926
15934
  }
15927
15935
  const turnDeltas = [];
15928
- for (const currentTurn of current.turns) {
15929
- const previousTurn = previous.turns.find((turn) => turn.id === currentTurn.id);
15936
+ for (const currentTurn of this.dirtyTranscriptTurns.values()) {
15937
+ const previousTurn = previous.turns.get(currentTurn.id);
15930
15938
  if (!previousTurn) {
15931
15939
  turnDeltas.push({
15932
15940
  id: currentTurn.id,
@@ -15937,8 +15945,9 @@ var CodexAspManager = class extends CodingAgentManager {
15937
15945
  });
15938
15946
  continue;
15939
15947
  }
15948
+ const previousItems = new Map(previousTurn.items.map((item) => [item.id, item]));
15940
15949
  const itemDeltas = currentTurn.items.map((item) => this.buildTranscriptItemDelta(
15941
- previousTurn.items.find((candidate) => candidate.id === item.id),
15950
+ previousItems.get(item.id),
15942
15951
  item
15943
15952
  )).filter((item) => item !== null);
15944
15953
  if (itemDeltas.length > 0 || currentTurn.status !== previousTurn.status || currentTurn.startedAt !== previousTurn.startedAt || currentTurn.completedAt !== previousTurn.completedAt) {
@@ -15966,15 +15975,16 @@ var CodexAspManager = class extends CodingAgentManager {
15966
15975
  transcript: transcriptDelta.reset ?? null,
15967
15976
  transcriptDelta
15968
15977
  };
15969
- this.lastEmittedTranscripts.set(
15970
- threadId,
15971
- this.codexAspTranscript ? structuredClone(this.codexAspTranscript) : null
15972
- );
15973
- for (const emittedThreadId of this.lastEmittedTranscripts.keys()) {
15974
- if (emittedThreadId !== threadId) {
15975
- this.lastEmittedTranscripts.delete(emittedThreadId);
15978
+ if (this.codexAspTranscript) {
15979
+ const snapshot = this.lastEmittedTranscript ?? { threadId, turns: /* @__PURE__ */ new Map() };
15980
+ for (const turn of this.dirtyTranscriptTurns.values()) {
15981
+ snapshot.turns.set(turn.id, { ...turn, items: [...turn.items] });
15976
15982
  }
15983
+ this.lastEmittedTranscript = snapshot;
15984
+ } else {
15985
+ this.lastEmittedTranscript = null;
15977
15986
  }
15987
+ this.dirtyTranscriptTurns.clear();
15978
15988
  const event = {
15979
15989
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
15980
15990
  type: CODEX_ASP_TRANSCRIPT_UPDATED_EVENT_TYPE,
@@ -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-JXXGULZ6.js";
6
+ } from "./chunk-F7EM7PIH.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
- import "./chunk-LYIXF36I.js";
10
+ import "./chunk-YSUQDUHX.js";
11
11
  import "./chunk-VEQXQN22.js";
12
12
 
13
13
  // src/post-tool-pr-hook.ts
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  messageRelaySubagentRequestSchema,
6
6
  spawnRelaySubagentRequestSchema
7
- } from "./chunk-LYIXF36I.js";
7
+ } from "./chunk-YSUQDUHX.js";
8
8
  import "./chunk-VEQXQN22.js";
9
9
 
10
10
  // src/relay-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.782",
3
+ "version": "0.1.784",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",