replicas-engine 0.1.1360 → 0.1.1361

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,9 +8,9 @@ import {
8
8
  listRunningCodexModels,
9
9
  restartCodexAspHost,
10
10
  restartCodexAspHostIfRunning
11
- } from "./chunk-R4KV2YTR.js";
11
+ } from "./chunk-ZDKOXODA.js";
12
12
  import "./chunk-YQI4XGIX.js";
13
- import "./chunk-64HL4Y7U.js";
13
+ import "./chunk-JP54MG3X.js";
14
14
  import "./chunk-QCX45VR3.js";
15
15
  import "./chunk-UZSNFLDQ.js";
16
16
  import "./chunk-TQ6XAXNA.js";
@@ -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.1360";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.1361";
244
244
  var INITIALIZE_METHOD = "initialize";
245
245
  var INITIALIZED_NOTIFICATION = "initialized";
246
246
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -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-64HL4Y7U.js";
6
+ } from "./chunk-JP54MG3X.js";
7
7
  import {
8
8
  ASTER_BASE_URL,
9
9
  ASTER_PROVIDER,
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  AppServerProcess,
16
16
  buildCodexAgentEnv
17
- } from "./chunk-64HL4Y7U.js";
17
+ } from "./chunk-JP54MG3X.js";
18
18
  import {
19
19
  SUBPROCESS_MAX_BUFFER,
20
20
  execFileAsync
@@ -319,7 +319,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
319
319
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
320
320
  await this.applyCredentialsResponse(data);
321
321
  setAgentCredentialSnapshot("codex", data);
322
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-V53SLUTD.js");
322
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-OBF4WP6L.js");
323
323
  await restartCodexAspHostIfRunning2();
324
324
  });
325
325
  await this.start(true);
@@ -341,7 +341,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
341
341
  const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
342
342
  await this.applyCredentialsResponse(data);
343
343
  if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
344
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-V53SLUTD.js");
344
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-OBF4WP6L.js");
345
345
  await restartCodexAspHostIfRunning2();
346
346
  }
347
347
  setAgentCredentialSnapshot("codex", data);
@@ -14,11 +14,11 @@ import {
14
14
  recoverCompletedTurn,
15
15
  spawnMuseMsp,
16
16
  startMuseSession
17
- } from "./chunk-CMXQTGY7.js";
17
+ } from "./chunk-NQSMRY4V.js";
18
18
  import {
19
19
  AppServerProcess,
20
20
  buildCodexAgentEnv
21
- } from "./chunk-64HL4Y7U.js";
21
+ } from "./chunk-JP54MG3X.js";
22
22
  import "./chunk-QCX45VR3.js";
23
23
  import {
24
24
  AGENT,
package/dist/src/index.js CHANGED
@@ -65,7 +65,7 @@ import {
65
65
  spawnMuseMsp,
66
66
  startMuseSession,
67
67
  uuidV7
68
- } from "./chunk-CMXQTGY7.js";
68
+ } from "./chunk-NQSMRY4V.js";
69
69
  import {
70
70
  publishedPullRequestUrls
71
71
  } from "./chunk-6FLA4WPX.js";
@@ -143,7 +143,7 @@ import {
143
143
  timestampFromSeconds,
144
144
  upsertCredentialFileLines,
145
145
  writeSecureCredentialFile
146
- } from "./chunk-R4KV2YTR.js";
146
+ } from "./chunk-ZDKOXODA.js";
147
147
  import {
148
148
  ENGINE_ENV,
149
149
  monolithRequest,
@@ -156,7 +156,7 @@ import {
156
156
  } from "./chunk-YQI4XGIX.js";
157
157
  import {
158
158
  getCodexModelProvider
159
- } from "./chunk-64HL4Y7U.js";
159
+ } from "./chunk-JP54MG3X.js";
160
160
  import {
161
161
  SUBPROCESS_MAX_BUFFER,
162
162
  execAsync,
@@ -12857,14 +12857,26 @@ function isClaudeSessionActive(activity) {
12857
12857
  // src/managers/claude-background-tasks.ts
12858
12858
  var ClaudeBackgroundTasks = class {
12859
12859
  active = /* @__PURE__ */ new Set();
12860
- foreground = /* @__PURE__ */ new Set();
12860
+ // The main agent's blocking tasks, by tool_use id; a subagent's own commands are its to wait on.
12861
+ foreground = /* @__PURE__ */ new Map();
12862
+ // A task counts as the main agent's only when its tool call is one the main agent made, so a task
12863
+ // whose owner can't be told apart is left running.
12864
+ mainToolUses = /* @__PURE__ */ new Set();
12861
12865
  reset() {
12862
12866
  this.active.clear();
12863
12867
  this.foreground.clear();
12868
+ this.mainToolUses.clear();
12864
12869
  }
12865
12870
  update(message) {
12871
+ if (message.type === "assistant" && message.parent_tool_use_id === null) {
12872
+ for (const block of message.message.content) if (block.type === "tool_use") this.mainToolUses.add(block.id);
12873
+ }
12874
+ if (message.type === "result") this.mainToolUses.clear();
12866
12875
  if (message.type !== "system") return;
12867
- if (message.subtype === "task_started" && message.is_backgrounded === false) this.foreground.add(message.task_id);
12876
+ const ownedBySubagent = "owned_by_subagent" in message && message.owned_by_subagent === true;
12877
+ if (message.subtype === "task_started" && message.is_backgrounded === false && !message.parent_task_id && !ownedBySubagent && message.tool_use_id && this.mainToolUses.delete(message.tool_use_id)) {
12878
+ this.foreground.set(message.task_id, message.tool_use_id);
12879
+ }
12868
12880
  if (message.subtype === "task_notification") this.foreground.delete(message.task_id);
12869
12881
  if (message.subtype === "task_updated" && (message.patch.is_backgrounded || message.patch.status && message.patch.status !== "running")) {
12870
12882
  this.foreground.delete(message.task_id);
@@ -13219,7 +13231,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13219
13231
  return this.activeQuery !== null && this.backgroundTasks.foreground.size > 0;
13220
13232
  }
13221
13233
  async deliverSteersNow() {
13222
- await this.activeQuery?.backgroundTasks();
13234
+ const query2 = this.activeQuery;
13235
+ if (query2) await Promise.all([...this.backgroundTasks.foreground.values()].map((toolUseId) => query2.backgroundTasks(toolUseId)));
13223
13236
  }
13224
13237
  // Claude Code folds a `next`-priority prompt into the running turn at its next tool boundary.
13225
13238
  async steerRequest(request) {
@@ -13992,6 +14005,14 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13992
14005
  return {};
13993
14006
  }],
13994
14007
  timeout: 30
14008
+ }, {
14009
+ // Only Send now backgrounds commands here, so Claude Code's "manually backgrounded by user" isn't true.
14010
+ matcher: "Bash",
14011
+ hooks: [async (input) => {
14012
+ const response2 = input.hook_event_name === "PostToolUse" ? input.tool_response : void 0;
14013
+ return isRecord(response2) && response2.backgroundedByUser === true ? { hookSpecificOutput: { hookEventName: "PostToolUse", updatedToolOutput: { ...response2, backgroundedByUser: false, backgroundedToDeliverMessage: true } } } : {};
14014
+ }],
14015
+ timeout: 30
13995
14016
  }, {
13996
14017
  matcher: "Workflow",
13997
14018
  hooks: [async (input) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.1360",
3
+ "version": "0.1.1361",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",