replicas-engine 0.1.941 → 0.1.943

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,12 +5,12 @@ import {
5
5
  getCodexAspHost,
6
6
  restartCodexAspHost,
7
7
  restartCodexAspHostIfRunning
8
- } from "./chunk-DFSIJZRP.js";
9
- import "./chunk-VXCEH64K.js";
10
- import "./chunk-P7EUB7A7.js";
11
- import "./chunk-PYS6OODD.js";
8
+ } from "./chunk-KB2IJ7Q3.js";
9
+ import "./chunk-2GKG7HNY.js";
10
+ import "./chunk-NUHC2G2R.js";
11
+ import "./chunk-CBG53K5N.js";
12
12
  import "./chunk-UZSNFLDQ.js";
13
- import "./chunk-UOTSKL34.js";
13
+ import "./chunk-KZVXTHPA.js";
14
14
  import "./chunk-VEQXQN22.js";
15
15
  export {
16
16
  getCodexAspHost,
@@ -15,7 +15,7 @@ import {
15
15
  isValidRelayBaseProvider,
16
16
  parsePosixEnvFile,
17
17
  readReplicasRuntimeEnv
18
- } from "./chunk-UOTSKL34.js";
18
+ } from "./chunk-KZVXTHPA.js";
19
19
 
20
20
  // src/runtime-env-loader.ts
21
21
  import { readFileSync } from "fs";
@@ -3,18 +3,18 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  monolithRequest
6
- } from "./chunk-VXCEH64K.js";
6
+ } from "./chunk-2GKG7HNY.js";
7
7
  import {
8
8
  SUBPROCESS_MAX_BUFFER,
9
9
  execFileAsync
10
- } from "./chunk-PYS6OODD.js";
10
+ } from "./chunk-CBG53K5N.js";
11
11
  import {
12
12
  extractCommandProtectionCommandText,
13
13
  findCommandProtectionGitLookups,
14
14
  findGitCommitSignals,
15
15
  findPrMergeSignals,
16
16
  parseCommandProtectionRequest
17
- } from "./chunk-UOTSKL34.js";
17
+ } from "./chunk-KZVXTHPA.js";
18
18
 
19
19
  // src/services/command-protection-service.ts
20
20
  import { readFile, stat } from "fs/promises";
@@ -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-UOTSKL34.js";
6
+ } from "./chunk-KZVXTHPA.js";
7
7
 
8
8
  // src/utils/exec.ts
9
9
  import { exec, execFile } from "child_process";
@@ -5,15 +5,15 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  setAgentCredentialSnapshot
8
- } from "./chunk-VXCEH64K.js";
8
+ } from "./chunk-2GKG7HNY.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  buildCodexAgentEnv
12
- } from "./chunk-P7EUB7A7.js";
12
+ } from "./chunk-NUHC2G2R.js";
13
13
  import {
14
14
  SUBPROCESS_MAX_BUFFER,
15
15
  execFileAsync
16
- } from "./chunk-PYS6OODD.js";
16
+ } from "./chunk-CBG53K5N.js";
17
17
  import {
18
18
  isRecord
19
19
  } from "./chunk-UZSNFLDQ.js";
@@ -27,7 +27,7 @@ import {
27
27
  listOpenAICompatibleModels,
28
28
  readOllamaAuthEnv,
29
29
  resolveOpenAICompatibleModelsUrl
30
- } from "./chunk-UOTSKL34.js";
30
+ } from "./chunk-KZVXTHPA.js";
31
31
 
32
32
  // src/managers/codex-token-manager.ts
33
33
  import { promises as fs } from "fs";
@@ -260,7 +260,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
260
260
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
261
261
  await this.applyCredentialsResponse(data);
262
262
  setAgentCredentialSnapshot("codex", data);
263
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-HEE4G4VF.js");
263
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-4HL3QSHC.js");
264
264
  await restartCodexAspHostIfRunning2();
265
265
  });
266
266
  await this.start(true);
@@ -280,7 +280,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
280
280
  await this.applyCredentialUpdate(generation, async () => {
281
281
  await this.applyCredentialsResponse(data);
282
282
  if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
283
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-HEE4G4VF.js");
283
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-4HL3QSHC.js");
284
284
  await restartCodexAspHostIfRunning2();
285
285
  }
286
286
  setAgentCredentialSnapshot("codex", data);
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  RELAY_MCP_TOOL_NAMES
6
- } from "./chunk-UOTSKL34.js";
6
+ } from "./chunk-KZVXTHPA.js";
7
7
 
8
8
  // src/managers/relay-mcp-config.ts
9
9
  import { existsSync } from "fs";
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-UOTSKL34.js";
8
+ } from "./chunk-KZVXTHPA.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -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-PYS6OODD.js";
6
+ } from "./chunk-CBG53K5N.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-UOTSKL34.js";
9
+ } from "./chunk-KZVXTHPA.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.941";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.943";
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-WD7GUVFF.js";
7
- import "./chunk-VXCEH64K.js";
8
- import "./chunk-PYS6OODD.js";
6
+ } from "./chunk-BJT6MJOM.js";
7
+ import "./chunk-2GKG7HNY.js";
8
+ import "./chunk-CBG53K5N.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-UOTSKL34.js";
12
+ import "./chunk-KZVXTHPA.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/command-protection-hook.ts
@@ -8,13 +8,13 @@ import {
8
8
  import {
9
9
  AppServerProcess,
10
10
  buildCodexAgentEnv
11
- } from "./chunk-P7EUB7A7.js";
12
- import "./chunk-PYS6OODD.js";
11
+ } from "./chunk-NUHC2G2R.js";
12
+ import "./chunk-CBG53K5N.js";
13
13
  import {
14
14
  AGENT,
15
15
  getMemoryOutputSafetyViolation,
16
16
  headlessAgentRequestSchema
17
- } from "./chunk-UOTSKL34.js";
17
+ } from "./chunk-KZVXTHPA.js";
18
18
  import "./chunk-VEQXQN22.js";
19
19
 
20
20
  // src/headless-agent.ts
package/dist/src/index.js CHANGED
@@ -32,7 +32,7 @@ import {
32
32
  reportCommandProtectionBlock,
33
33
  resolveDiffBase,
34
34
  runGitCommand
35
- } from "./chunk-WD7GUVFF.js";
35
+ } from "./chunk-BJT6MJOM.js";
36
36
  import {
37
37
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
38
38
  AGENT_MESSAGE_DELTA_METHOD,
@@ -57,12 +57,12 @@ import {
57
57
  } from "./chunk-FLDA7BX3.js";
58
58
  import {
59
59
  publishedPullRequestUrls
60
- } from "./chunk-ZGP5X4RU.js";
60
+ } from "./chunk-NOB6RRL2.js";
61
61
  import {
62
62
  RELAY_MCP_TOOL_TIMEOUT_MS,
63
63
  relayCodexMcpConfig,
64
64
  relayMcpProcessConfig
65
- } from "./chunk-YJ7ESUFG.js";
65
+ } from "./chunk-LURTYTNW.js";
66
66
  import {
67
67
  BaseRefreshManager,
68
68
  CodexAspAuthMethodChangedError,
@@ -77,7 +77,7 @@ import {
77
77
  refreshDelayMs,
78
78
  restartCodexAspHost,
79
79
  routineRefreshExclusions
80
- } from "./chunk-DFSIJZRP.js";
80
+ } from "./chunk-KB2IJ7Q3.js";
81
81
  import {
82
82
  ENGINE_ENV,
83
83
  monolithRequest,
@@ -85,16 +85,16 @@ import {
85
85
  readRuntimeEnvFile,
86
86
  reloadEngineEnv,
87
87
  setAgentCredentialSnapshot
88
- } from "./chunk-VXCEH64K.js";
88
+ } from "./chunk-2GKG7HNY.js";
89
89
  import {
90
90
  AspClient,
91
91
  getCodexModelProvider
92
- } from "./chunk-P7EUB7A7.js";
92
+ } from "./chunk-NUHC2G2R.js";
93
93
  import {
94
94
  SUBPROCESS_MAX_BUFFER,
95
95
  execAsync,
96
96
  execFileAsync
97
- } from "./chunk-PYS6OODD.js";
97
+ } from "./chunk-CBG53K5N.js";
98
98
  import {
99
99
  isRecord as isRecord2
100
100
  } from "./chunk-UZSNFLDQ.js";
@@ -326,7 +326,7 @@ import {
326
326
  workspaceCredentialProviderSchema,
327
327
  workspaceTokenRequestSchema,
328
328
  workspaceTokenResponseSchema
329
- } from "./chunk-UOTSKL34.js";
329
+ } from "./chunk-KZVXTHPA.js";
330
330
  import {
331
331
  cloneMcpConfig,
332
332
  ensureCompatibilityImports,
@@ -13263,6 +13263,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13263
13263
  // Set when background tasks outlive a turn; cleared once their completion
13264
13264
  // has been reported through onTurnComplete.
13265
13265
  pendingBackgroundCompletion = false;
13266
+ backgroundCompletionsInFlight = 0;
13266
13267
  partialMessageStreams = /* @__PURE__ */ new Map();
13267
13268
  partialMessageFlushTimers = /* @__PURE__ */ new Map();
13268
13269
  /** Active tool-input requests keyed by requestId; resolved when the user selects an option. */
@@ -13279,7 +13280,14 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13279
13280
  chatCredentials = null;
13280
13281
  turnCredentials = null;
13281
13282
  constructor(options) {
13282
- super({ ...options, provider: AGENT.CLAUDE });
13283
+ super({
13284
+ ...options,
13285
+ provider: AGENT.CLAUDE,
13286
+ onProcessingChanged: (processing) => {
13287
+ if (!processing) this.maybeCompleteBackgroundTurn();
13288
+ options.onProcessingChanged?.(processing);
13289
+ }
13290
+ });
13283
13291
  this.chatId = options.chatId;
13284
13292
  this.onChatCredential = options.onChatCredential ?? (() => {
13285
13293
  });
@@ -13332,7 +13340,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13332
13340
  return this.authRetrying;
13333
13341
  }
13334
13342
  isProcessing() {
13335
- return super.isProcessing() || isClaudeSessionActive(this.sessionActivity) || this.hasActiveBackgroundTasks();
13343
+ return super.isProcessing() || isClaudeSessionActive(this.sessionActivity) || this.pendingBackgroundCompletion || this.backgroundCompletionsInFlight > 0 || this.hasActiveBackgroundTasks();
13336
13344
  }
13337
13345
  getGoal() {
13338
13346
  return this.currentGoal;
@@ -14048,6 +14056,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14048
14056
  }
14049
14057
  return;
14050
14058
  }
14059
+ const wasProcessing = this.isProcessing();
14051
14060
  this.setAuthRetrying(false);
14052
14061
  if (this.pendingTurn && _ClaudeManager.isTurnActivity(msg)) {
14053
14062
  this.pendingTurn.sawActivity = true;
@@ -14084,6 +14093,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14084
14093
  }
14085
14094
  }
14086
14095
  this.maybeCompleteBackgroundTurn();
14096
+ if (wasProcessing && !this.isProcessing()) this.onProcessingChanged(false);
14087
14097
  }
14088
14098
  } catch (error) {
14089
14099
  loopError = error;
@@ -14153,9 +14163,14 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14153
14163
  this.backgroundWatchdogTriggered = false;
14154
14164
  this.notifyBackgroundTurnComplete();
14155
14165
  }
14156
- notifyBackgroundTurnComplete() {
14157
- void this.historyFile.flush().then(() => this.onTurnComplete()).catch((error) => {
14166
+ notifyBackgroundTurnComplete(after) {
14167
+ this.backgroundCompletionsInFlight += 1;
14168
+ void Promise.resolve(after).catch(() => {
14169
+ }).then(() => this.historyFile.flush()).then(() => this.onTurnComplete()).catch((error) => {
14158
14170
  console.error("[ClaudeManager] Background turn completion failed:", error);
14171
+ }).finally(() => {
14172
+ this.backgroundCompletionsInFlight -= 1;
14173
+ if (!this.isProcessing()) this.onProcessingChanged(false);
14159
14174
  });
14160
14175
  }
14161
14176
  failPendingTurn(err) {
@@ -14286,6 +14301,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14286
14301
  const stream = this.activePromptStream;
14287
14302
  const loop = this.sessionLoop;
14288
14303
  const notifyCompletion = this.pendingBackgroundCompletion && !this.messageQueue.isProcessing();
14304
+ if (notifyCompletion) this.notifyBackgroundTurnComplete(loop);
14289
14305
  this.settleBackgroundTasks();
14290
14306
  if (interrupted) this.resolvePendingTurn();
14291
14307
  else this.failPendingTurn(new Error("Claude session torn down"));
@@ -14304,7 +14320,6 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14304
14320
  } catch {
14305
14321
  }
14306
14322
  }
14307
- if (notifyCompletion) this.notifyBackgroundTurnComplete();
14308
14323
  }
14309
14324
  settleBackgroundTasks(error) {
14310
14325
  for (const taskId of this.backgroundTasks.active.keys()) {
@@ -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-ZGP5X4RU.js";
6
+ } from "./chunk-NOB6RRL2.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-UOTSKL34.js";
12
+ } from "./chunk-KZVXTHPA.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/services/post-tool-pr-notifier.ts
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
- import "./chunk-YJ7ESUFG.js";
4
+ import "./chunk-LURTYTNW.js";
5
5
  import {
6
6
  RELAY_MCP_SERVER_NAME,
7
7
  RELAY_MCP_TOOLS,
@@ -10,7 +10,7 @@ import {
10
10
  relaySubagentResponseSchema,
11
11
  spawnRelaySubagentRequestSchema,
12
12
  waitRelaySubagentRequestSchema
13
- } from "./chunk-UOTSKL34.js";
13
+ } from "./chunk-KZVXTHPA.js";
14
14
  import "./chunk-VEQXQN22.js";
15
15
 
16
16
  // src/relay-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.941",
3
+ "version": "0.1.943",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",