replicas-engine 0.1.1185 → 0.1.1186

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.
@@ -8,12 +8,12 @@ import {
8
8
  listRunningCodexModels,
9
9
  restartCodexAspHost,
10
10
  restartCodexAspHostIfRunning
11
- } from "./chunk-4ZGWVW57.js";
12
- import "./chunk-5LUEYBGK.js";
13
- import "./chunk-BWK6AIHV.js";
14
- import "./chunk-DK47O5WV.js";
11
+ } from "./chunk-KLHDCQAK.js";
12
+ import "./chunk-VXPWAQR2.js";
13
+ import "./chunk-WIEXE5ZC.js";
14
+ import "./chunk-R6I3LT27.js";
15
15
  import "./chunk-UZSNFLDQ.js";
16
- import "./chunk-MRLYA3JT.js";
16
+ import "./chunk-4T2K6OBK.js";
17
17
  import "./chunk-VEQXQN22.js";
18
18
  export {
19
19
  CODEX_ULTRAFAST_SERVICE_TIER,
@@ -5586,6 +5586,7 @@ var DEFAULT_USER_PREFERENCES = {
5586
5586
  memory_enabled: null,
5587
5587
  subagent_mcp_enabled: null,
5588
5588
  default_fast_mode: false,
5589
+ auto_compact_tokens: null,
5589
5590
  agent_defaults: { ...EMPTY_AGENT_DEFAULT_SETTINGS },
5590
5591
  fallback_chains: null
5591
5592
  };
@@ -8065,6 +8066,7 @@ function buildCodexTokenUsageContextUsagePayload(usage) {
8065
8066
  rawMaxTokens: maxTokens,
8066
8067
  percentage: percentage(totalTokens, maxTokens),
8067
8068
  compactsAutomatically: true,
8069
+ ...autoCompactThresholdField(usage.autoCompactTokens && maxTokens && usage.autoCompactTokens < maxTokens ? percentage(usage.autoCompactTokens, maxTokens) : null),
8068
8070
  categories: compactCategories([
8069
8071
  {
8070
8072
  name: "Input context",
@@ -8080,16 +8082,6 @@ function buildCodexTokenUsageContextUsagePayload(usage) {
8080
8082
  updatedAt: usage.updatedAt
8081
8083
  };
8082
8084
  }
8083
- function resolveClaudeContextWindow(provider2, model2, reportedMaxTokens) {
8084
- if (provider2 !== "claude") {
8085
- return { maxTokens: reportedMaxTokens, usedKnownWindow: false };
8086
- }
8087
- const knownWindow = getClaudeModelContextWindow(model2);
8088
- return {
8089
- maxTokens: knownWindow ?? reportedMaxTokens,
8090
- usedKnownWindow: knownWindow !== null
8091
- };
8092
- }
8093
8085
  function coerceContextUsagePayload(payload, timestamp) {
8094
8086
  const provider2 = payload.provider;
8095
8087
  if (typeof provider2 !== "string" || !isValidAgentProvider(provider2)) return null;
@@ -8099,9 +8091,8 @@ function coerceContextUsagePayload(payload, timestamp) {
8099
8091
  return null;
8100
8092
  }
8101
8093
  const model2 = typeof payload.model === "string" ? payload.model : null;
8102
- const reportedMaxTokens = numberOrNull(payload.maxTokens);
8103
- const { maxTokens, usedKnownWindow } = resolveClaudeContextWindow(provider2, model2, reportedMaxTokens);
8104
- const rawMaxTokens = usedKnownWindow ? maxTokens : numberOrNull(payload.rawMaxTokens);
8094
+ const maxTokens = numberOrNull(payload.maxTokens);
8095
+ const rawMaxTokens = numberOrNull(payload.rawMaxTokens);
8105
8096
  const totalTokens = clampTokensToWindow(rawTotalTokens, maxTokens);
8106
8097
  const source = payload.source === "codex_token_count" || payload.source === "claude_usage" || payload.source === "provider_usage" ? payload.source : "claude_context";
8107
8098
  const categories = Array.isArray(payload.categories) ? compactCategories(payload.categories.map((item) => {
@@ -8114,7 +8105,7 @@ function coerceContextUsagePayload(payload, timestamp) {
8114
8105
  return {
8115
8106
  name,
8116
8107
  tokens,
8117
- percentage: usedKnownWindow ? percentage(tokens, maxTokens) : categoryPercentage
8108
+ percentage: categoryPercentage
8118
8109
  };
8119
8110
  })) : [];
8120
8111
  const compactsAutomatically = typeof payload.compactsAutomatically === "boolean" ? payload.compactsAutomatically : void 0;
@@ -8126,7 +8117,7 @@ function coerceContextUsagePayload(payload, timestamp) {
8126
8117
  totalTokens,
8127
8118
  maxTokens,
8128
8119
  rawMaxTokens,
8129
- percentage: usedKnownWindow ? percentage(totalTokens, maxTokens) : clampPercentage(percentageValue),
8120
+ percentage: clampPercentage(percentageValue),
8130
8121
  ...compactsAutomatically !== void 0 ? { compactsAutomatically } : {},
8131
8122
  ...autoCompactThreshold !== null ? { autoCompactThreshold } : {},
8132
8123
  categories,
@@ -8150,6 +8141,7 @@ function codexTokenCountToContextUsage(event) {
8150
8141
  totalTokens: numberOrNull(lastUsage.total_tokens) ?? inputTokens + outputTokens
8151
8142
  },
8152
8143
  modelContextWindow: maxTokens,
8144
+ autoCompactTokens: null,
8153
8145
  updatedAt: event.timestamp
8154
8146
  });
8155
8147
  }
@@ -10,15 +10,15 @@ import {
10
10
  resolveDiffBase,
11
11
  runGitCommand,
12
12
  setAgentCredentialSnapshot
13
- } from "./chunk-5LUEYBGK.js";
13
+ } from "./chunk-VXPWAQR2.js";
14
14
  import {
15
15
  AppServerProcess,
16
16
  buildCodexAgentEnv
17
- } from "./chunk-BWK6AIHV.js";
17
+ } from "./chunk-WIEXE5ZC.js";
18
18
  import {
19
19
  SUBPROCESS_MAX_BUFFER,
20
20
  execFileAsync
21
- } from "./chunk-DK47O5WV.js";
21
+ } from "./chunk-R6I3LT27.js";
22
22
  import {
23
23
  isRecord
24
24
  } from "./chunk-UZSNFLDQ.js";
@@ -55,7 +55,7 @@ import {
55
55
  resolveOpenAICompatibleModelsUrl,
56
56
  splitMothershipInstructions,
57
57
  withTimeout
58
- } from "./chunk-MRLYA3JT.js";
58
+ } from "./chunk-4T2K6OBK.js";
59
59
 
60
60
  // src/managers/codex-token-manager.ts
61
61
  import { promises as fs } from "fs";
@@ -291,7 +291,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
291
291
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
292
292
  await this.applyCredentialsResponse(data);
293
293
  setAgentCredentialSnapshot("codex", data);
294
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-ZLG2O2IB.js");
294
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-J4AUGWDZ.js");
295
295
  await restartCodexAspHostIfRunning2();
296
296
  });
297
297
  await this.start(true);
@@ -313,7 +313,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
313
313
  const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
314
314
  await this.applyCredentialsResponse(data);
315
315
  if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
316
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-ZLG2O2IB.js");
316
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-J4AUGWDZ.js");
317
317
  await restartCodexAspHostIfRunning2();
318
318
  }
319
319
  setAgentCredentialSnapshot("codex", data);
@@ -1771,7 +1771,7 @@ function turnsToAspTranscript(threadId, updatedAt, sourceTurns) {
1771
1771
  });
1772
1772
  return { threadId, updatedAt, turns };
1773
1773
  }
1774
- async function buildThreadStartParams(workingDirectory, request, developerInstructions, serviceTier, subagentMcpParentChatId) {
1774
+ async function buildThreadStartParams(workingDirectory, request, developerInstructions, serviceTier, subagentMcpParentChatId, autoCompactTokens = null) {
1775
1775
  const additionalDirectories = await getAgentAdditionalDirectories();
1776
1776
  return {
1777
1777
  model: request.model ?? DEFAULT_MODEL,
@@ -1784,6 +1784,7 @@ async function buildThreadStartParams(workingDirectory, request, developerInstru
1784
1784
  config: {
1785
1785
  web_search: ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD === "ollama" ? "disabled" : "live",
1786
1786
  model_reasoning_summary: "auto",
1787
+ ...autoCompactTokens ? { model_auto_compact_token_limit: autoCompactTokens } : {},
1787
1788
  ...subagentMcpParentChatId ? {
1788
1789
  // Codex gates its native collaboration tools on `agents.enabled`; `features.multi_agent` is now a no-op.
1789
1790
  "agents.enabled": false,
@@ -1793,7 +1794,7 @@ async function buildThreadStartParams(workingDirectory, request, developerInstru
1793
1794
  experimentalRawEvents: false
1794
1795
  };
1795
1796
  }
1796
- async function buildThreadResumeParams(workingDirectory, threadId, request, developerInstructions, serviceTier, subagentMcpParentChatId) {
1797
+ async function buildThreadResumeParams(workingDirectory, threadId, request, developerInstructions, serviceTier, subagentMcpParentChatId, autoCompactTokens = null) {
1797
1798
  const additionalDirectories = await getAgentAdditionalDirectories();
1798
1799
  return {
1799
1800
  threadId,
@@ -1807,6 +1808,7 @@ async function buildThreadResumeParams(workingDirectory, threadId, request, deve
1807
1808
  config: {
1808
1809
  web_search: ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD === "ollama" ? "disabled" : "live",
1809
1810
  model_reasoning_summary: "auto",
1811
+ ...autoCompactTokens ? { model_auto_compact_token_limit: autoCompactTokens } : {},
1810
1812
  ...subagentMcpParentChatId ? {
1811
1813
  // Codex gates its native collaboration tools on `agents.enabled`; `features.multi_agent` is now a no-op.
1812
1814
  "agents.enabled": false,
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-MRLYA3JT.js";
8
+ } from "./chunk-4T2K6OBK.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  AspClient
6
- } from "./chunk-BWK6AIHV.js";
6
+ } from "./chunk-WIEXE5ZC.js";
7
7
  import {
8
8
  ASTER_BASE_URL,
9
9
  ASTER_PROVIDER,
@@ -11,7 +11,7 @@ import {
11
11
  codexReasoningEffortForThinkingLevel,
12
12
  isRecord,
13
13
  readOllamaAuthEnv
14
- } from "./chunk-MRLYA3JT.js";
14
+ } from "./chunk-4T2K6OBK.js";
15
15
 
16
16
  // src/managers/codex-asp/notification-dispatch.ts
17
17
  var TURN_STARTED_METHOD = "turn/started";
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  HOOK_EXEC_MAX_BUFFER_BYTES
6
- } from "./chunk-MRLYA3JT.js";
6
+ } from "./chunk-4T2K6OBK.js";
7
7
 
8
8
  // src/utils/exec.ts
9
9
  import { exec, execFile } from "child_process";
@@ -5,14 +5,14 @@ import {
5
5
  getOriginDefaultBranch,
6
6
  monolithRequest,
7
7
  runGitCommand
8
- } from "./chunk-5LUEYBGK.js";
8
+ } from "./chunk-VXPWAQR2.js";
9
9
  import {
10
10
  extractCommandProtectionCommandText,
11
11
  findCommandProtectionGitLookups,
12
12
  findGitCommitSignals,
13
13
  findPrMergeSignals,
14
14
  parseCommandProtectionRequest
15
- } from "./chunk-MRLYA3JT.js";
15
+ } from "./chunk-4T2K6OBK.js";
16
16
 
17
17
  // src/services/command-protection-service.ts
18
18
  import { readFile, stat } from "fs/promises";
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  SUBPROCESS_MAX_BUFFER,
6
6
  execFileAsync
7
- } from "./chunk-DK47O5WV.js";
7
+ } from "./chunk-R6I3LT27.js";
8
8
  import {
9
9
  isRecord as isRecord2
10
10
  } from "./chunk-UZSNFLDQ.js";
@@ -18,7 +18,7 @@ import {
18
18
  isValidAgentProvider,
19
19
  parsePosixEnvFile,
20
20
  readReplicasRuntimeEnv
21
- } from "./chunk-MRLYA3JT.js";
21
+ } from "./chunk-4T2K6OBK.js";
22
22
 
23
23
  // src/runtime-env-loader.ts
24
24
  import { readFileSync } from "fs";
@@ -274,29 +274,22 @@ async function monolithRequest(path, init = {}) {
274
274
  });
275
275
  }
276
276
  var MonolithService = class {
277
- async getSubagentMcpConfig() {
277
+ async getJson(path, parse, signal) {
278
278
  try {
279
- const response = await monolithRequest("/v1/engine/subagent-mcp", { method: "GET", signal: AbortSignal.timeout(1e4) });
280
- if (!response.ok) {
281
- return null;
282
- }
283
- const body = await response.json();
284
- return isRecord(body) && typeof body.enabled === "boolean" && Array.isArray(body.providers) && body.providers.every((provider) => typeof provider === "string" && isValidAgentProvider(provider)) ? { enabled: body.enabled, providers: body.providers } : null;
279
+ const response = await monolithRequest(path, { method: "GET", signal });
280
+ return response.ok ? parse(await response.json()) : null;
285
281
  } catch {
286
282
  return null;
287
283
  }
288
284
  }
289
- async getOpenRouterModels() {
290
- try {
291
- const response = await monolithRequest("/v1/engine/openrouter-models", { method: "GET" });
292
- if (!response.ok) {
293
- return null;
294
- }
295
- const body = await response.json();
296
- return isRecord(body) && Array.isArray(body.models) && body.models.every((model) => typeof model === "string") ? body.models : null;
297
- } catch {
298
- return null;
299
- }
285
+ getSubagentMcpConfig() {
286
+ return this.getJson("/v1/engine/subagent-mcp", (body) => isRecord(body) && typeof body.enabled === "boolean" && Array.isArray(body.providers) && body.providers.every((provider) => typeof provider === "string" && isValidAgentProvider(provider)) ? { enabled: body.enabled, providers: body.providers } : null, AbortSignal.timeout(1e4));
287
+ }
288
+ getAutoCompactConfig() {
289
+ return this.getJson("/v1/engine/auto-compact", (body) => isRecord(body) && (body.tokens === null || typeof body.tokens === "number") ? { tokens: body.tokens } : null, AbortSignal.timeout(1e4));
290
+ }
291
+ getOpenRouterModels() {
292
+ return this.getJson("/v1/engine/openrouter-models", (body) => isRecord(body) && Array.isArray(body.models) && body.models.every((model) => typeof model === "string") ? body.models : null);
300
293
  }
301
294
  /** `unsupported` means an older monolith; `unavailable` means this one could not be read. */
302
295
  async getFallbackPlan(params) {
@@ -3,10 +3,10 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  execFileAsync
6
- } from "./chunk-DK47O5WV.js";
6
+ } from "./chunk-R6I3LT27.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-MRLYA3JT.js";
9
+ } from "./chunk-4T2K6OBK.js";
10
10
 
11
11
  // src/utils/codex-agent-env.ts
12
12
  function buildCodexAgentEnv(source = process.env) {
@@ -240,7 +240,7 @@ function getCodexModelProvider(method) {
240
240
  if (method === "foundry") return "azure";
241
241
  return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
242
242
  }
243
- var ENGINE_PACKAGE_VERSION = "0.1.1185";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.1186";
244
244
  var INITIALIZE_METHOD = "initialize";
245
245
  var INITIALIZED_NOTIFICATION = "initialized";
246
246
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -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-3MSUW7UR.js";
7
- import "./chunk-5LUEYBGK.js";
8
- import "./chunk-DK47O5WV.js";
6
+ } from "./chunk-TUZLVYYH.js";
7
+ import "./chunk-VXPWAQR2.js";
8
+ import "./chunk-R6I3LT27.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-MRLYA3JT.js";
12
+ import "./chunk-4T2K6OBK.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/command-protection-hook.ts
@@ -13,12 +13,12 @@ import {
13
13
  recoverCompletedTurn,
14
14
  spawnMuseMsp,
15
15
  startMuseSession
16
- } from "./chunk-HI2JQFS4.js";
16
+ } from "./chunk-NQOV2YOZ.js";
17
17
  import {
18
18
  AppServerProcess,
19
19
  buildCodexAgentEnv
20
- } from "./chunk-BWK6AIHV.js";
21
- import "./chunk-DK47O5WV.js";
20
+ } from "./chunk-WIEXE5ZC.js";
21
+ import "./chunk-R6I3LT27.js";
22
22
  import {
23
23
  AGENT,
24
24
  OPENCODE_GO_PROVIDER,
@@ -28,7 +28,7 @@ import {
28
28
  headlessAgentUsagePath,
29
29
  isRecord,
30
30
  withTimeout
31
- } from "./chunk-MRLYA3JT.js";
31
+ } from "./chunk-4T2K6OBK.js";
32
32
  import "./chunk-VEQXQN22.js";
33
33
 
34
34
  // src/headless-agent.ts
package/dist/src/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  evaluateCommandProtection,
28
28
  extractToolCommand,
29
29
  reportCommandProtectionBlock
30
- } from "./chunk-3MSUW7UR.js";
30
+ } from "./chunk-TUZLVYYH.js";
31
31
  import {
32
32
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
33
33
  AGENT_MESSAGE_DELTA_METHOD,
@@ -64,10 +64,10 @@ import {
64
64
  spawnMuseMsp,
65
65
  startMuseSession,
66
66
  uuidV7
67
- } from "./chunk-HI2JQFS4.js";
67
+ } from "./chunk-NQOV2YOZ.js";
68
68
  import {
69
69
  publishedPullRequestUrls
70
- } from "./chunk-DVPKDEWH.js";
70
+ } from "./chunk-NIT22CZW.js";
71
71
  import {
72
72
  ACCOUNT_RATE_LIMITS_READ_METHOD,
73
73
  AsyncLock,
@@ -139,7 +139,7 @@ import {
139
139
  timestampFromSeconds,
140
140
  upsertCredentialFileLines,
141
141
  writeSecureCredentialFile
142
- } from "./chunk-4ZGWVW57.js";
142
+ } from "./chunk-KLHDCQAK.js";
143
143
  import {
144
144
  ENGINE_ENV,
145
145
  monolithRequest,
@@ -148,15 +148,15 @@ import {
148
148
  reloadEngineEnv,
149
149
  resolveDiffBase,
150
150
  setAgentCredentialSnapshot
151
- } from "./chunk-5LUEYBGK.js";
151
+ } from "./chunk-VXPWAQR2.js";
152
152
  import {
153
153
  getCodexModelProvider
154
- } from "./chunk-BWK6AIHV.js";
154
+ } from "./chunk-WIEXE5ZC.js";
155
155
  import {
156
156
  SUBPROCESS_MAX_BUFFER,
157
157
  execAsync,
158
158
  execFileAsync
159
- } from "./chunk-DK47O5WV.js";
159
+ } from "./chunk-R6I3LT27.js";
160
160
  import {
161
161
  isRecord as isRecord2
162
162
  } from "./chunk-UZSNFLDQ.js";
@@ -383,7 +383,7 @@ import {
383
383
  workspaceTokenRequestSchema,
384
384
  workspaceTokenResponseSchema,
385
385
  wrapInTag
386
- } from "./chunk-MRLYA3JT.js";
386
+ } from "./chunk-4T2K6OBK.js";
387
387
  import {
388
388
  cloneMcpConfig,
389
389
  ensureCompatibilityImports,
@@ -11396,6 +11396,8 @@ var CodingAgentManager = class {
11396
11396
  authFallback;
11397
11397
  subagentMcpChatId;
11398
11398
  subagentMcpEnabledForTurn = false;
11399
+ usesAutoCompactTokens;
11400
+ autoCompactTokens = null;
11399
11401
  unreadSteers = /* @__PURE__ */ new Map();
11400
11402
  lastSenderKey;
11401
11403
  onLastSenderKeyChanged;
@@ -11410,6 +11412,7 @@ var CodingAgentManager = class {
11410
11412
  this.onUsageUpdate = options.onUsageUpdate ?? (() => {
11411
11413
  });
11412
11414
  this.subagentMcpChatId = options.parentChatId === null && options.provider && SUBAGENT_MCP_HARNESSES.includes(options.provider) ? options.chatId : void 0;
11415
+ this.usesAutoCompactTokens = options.provider === "claude" || options.provider === "codex";
11413
11416
  this.linearSessionId = options.linearSessionId;
11414
11417
  this.chatId = options.chatId;
11415
11418
  this.hostOnTurnComplete = options.onTurnComplete;
@@ -11485,7 +11488,7 @@ var CodingAgentManager = class {
11485
11488
  initializeManager(processMessage) {
11486
11489
  this.messageQueue = new MessageQueueService(
11487
11490
  async (request, signal) => {
11488
- await this.refreshSubagentMcp();
11491
+ await Promise.all([this.refreshSubagentMcp(), this.refreshAutoCompactTokens()]);
11489
11492
  if (signal.aborted) return;
11490
11493
  const { request: delivered, senderKey } = this.withSenderLine(request);
11491
11494
  await this.saveLastSenderKey(senderKey);
@@ -11523,6 +11526,11 @@ ${request.message}` }, senderKey };
11523
11526
  const config = await subagentMcpConfigRequest;
11524
11527
  if (config) this.subagentMcpEnabledForTurn = await this.subagentMcpForTurn(config.enabled);
11525
11528
  }
11529
+ async refreshAutoCompactTokens() {
11530
+ if (!this.usesAutoCompactTokens) return;
11531
+ const config = await monolithService.getAutoCompactConfig();
11532
+ if (config) this.autoCompactTokens = config.tokens;
11533
+ }
11526
11534
  /** Harnesses that fix their tool set per session override this to keep a session's original mode. */
11527
11535
  async subagentMcpForTurn(enabled) {
11528
11536
  return enabled;
@@ -13206,6 +13214,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13206
13214
  thinkingLevel,
13207
13215
  enableInteractiveTools: Boolean(enableInteractiveTools),
13208
13216
  fastMode: resolvedFastMode,
13217
+ autoCompactTokens: this.autoCompactTokens,
13209
13218
  permissionMode: resolvedPermissionMode,
13210
13219
  subagentMcpParentChatId: this.subagentMcpParentChatId()
13211
13220
  };
@@ -13307,7 +13316,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13307
13316
  });
13308
13317
  }
13309
13318
  sessionSignaturesMatch(a, b) {
13310
- return a.combinedInstructions === b.combinedInstructions && a.credential === b.credential && a.thinkingLevel === b.thinkingLevel && a.enableInteractiveTools === b.enableInteractiveTools && a.fastMode === b.fastMode && a.permissionMode === b.permissionMode && a.subagentMcpParentChatId === b.subagentMcpParentChatId;
13319
+ return a.combinedInstructions === b.combinedInstructions && a.credential === b.credential && a.thinkingLevel === b.thinkingLevel && a.enableInteractiveTools === b.enableInteractiveTools && a.fastMode === b.fastMode && a.autoCompactTokens === b.autoCompactTokens && a.permissionMode === b.permissionMode && a.subagentMcpParentChatId === b.subagentMcpParentChatId;
13311
13320
  }
13312
13321
  /** Query inputs shared by real sessions and slash-command discovery. */
13313
13322
  async buildSharedQueryOptions() {
@@ -13381,6 +13390,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13381
13390
  model: claudeCodeModel,
13382
13391
  settings: {
13383
13392
  fastMode: signature.fastMode,
13393
+ ...signature.autoCompactTokens ? { autoCompactWindow: signature.autoCompactTokens } : {},
13384
13394
  ...ultracode ? { enableWorkflows: true, ultracode: true } : {}
13385
13395
  },
13386
13396
  includePartialMessages: true,
@@ -14071,6 +14081,7 @@ var CodexAspManager = class extends CodingAgentManager {
14071
14081
  attachedClient = null;
14072
14082
  attachedModel = null;
14073
14083
  attachedDeveloperInstructions = null;
14084
+ attachedAutoCompactTokens = null;
14074
14085
  historyFile;
14075
14086
  liveTurn = null;
14076
14087
  codexSubagents = /* @__PURE__ */ new Map();
@@ -14479,16 +14490,18 @@ var CodexAspManager = class extends CodingAgentManager {
14479
14490
  if (existingThreadId) {
14480
14491
  if (this.attachedClient !== host.client || requestedModel !== this.attachedModel || (developerInstructions ?? null) !== this.attachedDeveloperInstructions) {
14481
14492
  const serviceTier2 = await this.resolveRequestedServiceTier(host, request);
14482
- const previous = this.attachedClient !== host.client ? await host.client.request(THREAD_READ_METHOD, { threadId: existingThreadId, includeTurns: true }).catch(() => null) : null;
14493
+ const coldResume = this.attachedClient !== host.client;
14494
+ const previous = coldResume ? await host.client.request(THREAD_READ_METHOD, { threadId: existingThreadId, includeTurns: true }).catch(() => null) : null;
14483
14495
  const response = previous?.thread.modelProvider && previous.thread.modelProvider !== getCodexModelProvider(ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD) ? await this.continueWithNewProvider(host, previous.thread, request, developerInstructions, serviceTier2) : await host.client.request(
14484
14496
  THREAD_RESUME_METHOD,
14485
- await buildThreadResumeParams(this.workingDirectory, existingThreadId, request, developerInstructions, serviceTier2, subagentMcpParentChatId)
14497
+ await buildThreadResumeParams(this.workingDirectory, existingThreadId, request, developerInstructions, serviceTier2, subagentMcpParentChatId, this.autoCompactTokens)
14486
14498
  );
14487
14499
  this.currentThreadId = response.thread.id;
14488
14500
  this.activeServiceTier = response.serviceTier;
14489
14501
  this.attachedClient = host.client;
14490
14502
  this.attachedModel = requestedModel;
14491
14503
  this.attachedDeveloperInstructions = developerInstructions ?? null;
14504
+ if (coldResume) this.attachedAutoCompactTokens = this.autoCompactTokens;
14492
14505
  await this.onSaveSessionId(this.currentThreadId);
14493
14506
  }
14494
14507
  return this.currentThreadId ?? existingThreadId;
@@ -14496,7 +14509,7 @@ var CodexAspManager = class extends CodingAgentManager {
14496
14509
  const serviceTier = await this.resolveRequestedServiceTier(host, request);
14497
14510
  const threadStartResponse = await host.client.request(
14498
14511
  THREAD_START_METHOD,
14499
- await buildThreadStartParams(this.workingDirectory, request, developerInstructions, serviceTier, subagentMcpParentChatId)
14512
+ await buildThreadStartParams(this.workingDirectory, request, developerInstructions, serviceTier, subagentMcpParentChatId, this.autoCompactTokens)
14500
14513
  );
14501
14514
  const threadId = threadStartResponse.thread.id;
14502
14515
  this.currentThreadId = threadId;
@@ -14504,6 +14517,7 @@ var CodexAspManager = class extends CodingAgentManager {
14504
14517
  this.attachedClient = host.client;
14505
14518
  this.attachedModel = requestedModel;
14506
14519
  this.attachedDeveloperInstructions = developerInstructions ?? null;
14520
+ this.attachedAutoCompactTokens = this.autoCompactTokens;
14507
14521
  if (subagentMcpParentChatId) await markSubagentMcpThread(threadId);
14508
14522
  await this.onSaveSessionId(this.currentThreadId);
14509
14523
  return threadId;
@@ -14517,7 +14531,7 @@ var CodexAspManager = class extends CodingAgentManager {
14517
14531
  await writeFile4(transcriptPath, text, "utf8");
14518
14532
  const response = await host.client.request(
14519
14533
  THREAD_START_METHOD,
14520
- await buildThreadStartParams(this.workingDirectory, request, developerInstructions, serviceTier, this.subagentMcpParentChatId())
14534
+ await buildThreadStartParams(this.workingDirectory, request, developerInstructions, serviceTier, this.subagentMcpParentChatId(), this.autoCompactTokens)
14521
14535
  );
14522
14536
  await host.client.request(THREAD_INJECT_ITEMS_METHOD, {
14523
14537
  threadId: response.thread.id,
@@ -15160,6 +15174,7 @@ ${text.slice(-24e3)}`
15160
15174
  const payload = buildCodexTokenUsageContextUsagePayload({
15161
15175
  model,
15162
15176
  modelContextWindow: tokenUsage.modelContextWindow,
15177
+ autoCompactTokens: this.attachedAutoCompactTokens,
15163
15178
  last: {
15164
15179
  inputTokens: tokenUsage.last.inputTokens,
15165
15180
  outputTokens: tokenUsage.last.outputTokens,
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  publishedPullRequestUrls
6
- } from "./chunk-DVPKDEWH.js";
6
+ } from "./chunk-NIT22CZW.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-MRLYA3JT.js";
12
+ } from "./chunk-4T2K6OBK.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/services/post-tool-pr-notifier.ts
@@ -9,7 +9,7 @@ import {
9
9
  spawnSubagentRequestSchema,
10
10
  subagentResponseSchema,
11
11
  waitSubagentRequestSchema
12
- } from "./chunk-MRLYA3JT.js";
12
+ } from "./chunk-4T2K6OBK.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/subagent-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.1185",
3
+ "version": "0.1.1186",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",