replicas-engine 0.1.971 → 0.1.973

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-2OEKOWPM.js";
9
- import "./chunk-JH2UMGOT.js";
10
- import "./chunk-UVAFYGNC.js";
11
- import "./chunk-EUMRQH4J.js";
8
+ } from "./chunk-NHD7MMAW.js";
9
+ import "./chunk-3VGFM7ME.js";
10
+ import "./chunk-4P4NVCXW.js";
11
+ import "./chunk-F4ZGMCND.js";
12
12
  import "./chunk-UZSNFLDQ.js";
13
- import "./chunk-4KMPRAV6.js";
13
+ import "./chunk-RMH6PDA7.js";
14
14
  import "./chunk-VEQXQN22.js";
15
15
  export {
16
16
  getCodexAspHost,
@@ -14,7 +14,7 @@ import {
14
14
  isValidAgentProvider,
15
15
  parsePosixEnvFile,
16
16
  readReplicasRuntimeEnv
17
- } from "./chunk-4KMPRAV6.js";
17
+ } from "./chunk-RMH6PDA7.js";
18
18
 
19
19
  // src/runtime-env-loader.ts
20
20
  import { readFileSync } from "fs";
@@ -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-EUMRQH4J.js";
6
+ } from "./chunk-F4ZGMCND.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-4KMPRAV6.js";
9
+ } from "./chunk-RMH6PDA7.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.971";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.973";
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
  HOOK_EXEC_MAX_BUFFER_BYTES
6
- } from "./chunk-4KMPRAV6.js";
6
+ } from "./chunk-RMH6PDA7.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-JH2UMGOT.js";
8
+ } from "./chunk-3VGFM7ME.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  buildCodexAgentEnv
12
- } from "./chunk-UVAFYGNC.js";
12
+ } from "./chunk-4P4NVCXW.js";
13
13
  import {
14
14
  SUBPROCESS_MAX_BUFFER,
15
15
  execFileAsync
16
- } from "./chunk-EUMRQH4J.js";
16
+ } from "./chunk-F4ZGMCND.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-4KMPRAV6.js";
30
+ } from "./chunk-RMH6PDA7.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-77MZZGH6.js");
263
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-DSLWM2EA.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-77MZZGH6.js");
283
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-DSLWM2EA.js");
284
284
  await restartCodexAspHostIfRunning2();
285
285
  }
286
286
  setAgentCredentialSnapshot("codex", data);
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-4KMPRAV6.js";
8
+ } from "./chunk-RMH6PDA7.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -20,6 +20,7 @@ var ACCOUNT_RATE_LIMITS_UPDATED_METHOD = "account/rateLimits/updated";
20
20
  var THREAD_TOKEN_USAGE_UPDATED_METHOD = "thread/tokenUsage/updated";
21
21
  var THREAD_COMPACTED_METHOD = "thread/compacted";
22
22
  var MODEL_REROUTED_METHOD = "model/rerouted";
23
+ var THREAD_STATUS_CHANGED_METHOD = "thread/status/changed";
23
24
  function dispatchAspNotification(notification, handlers) {
24
25
  const handler = handlers[notification.method];
25
26
  if (!handler) return;
@@ -58,6 +59,7 @@ export {
58
59
  THREAD_TOKEN_USAGE_UPDATED_METHOD,
59
60
  THREAD_COMPACTED_METHOD,
60
61
  MODEL_REROUTED_METHOD,
62
+ THREAD_STATUS_CHANGED_METHOD,
61
63
  dispatchAspNotification,
62
64
  recoverCompletedTurn
63
65
  };
@@ -8935,6 +8935,7 @@ export {
8935
8935
  REMOVED_MESSAGE_IDS_PAYLOAD_KEY,
8936
8936
  USER_MESSAGE_ID_PAYLOAD_KEY,
8937
8937
  CODEX_ASP_ITEM_ID_PAYLOAD_KEY,
8938
+ CODEX_ITEM_EVENT_TYPE,
8938
8939
  CODEX_HISTORY_FORMAT_EVENT_TYPE,
8939
8940
  getEventStreamId,
8940
8941
  CODEX_QUOTA_STATUS_EVENT_TYPE,
@@ -8965,6 +8966,7 @@ export {
8965
8966
  createAcceptedUserMessageEvent,
8966
8967
  codexItemEvent,
8967
8968
  codexTurnEvent,
8969
+ codexItemFromEvent,
8968
8970
  codexTurnFromEvent,
8969
8971
  codexTranscriptToEvents,
8970
8972
  isLatestChatHistoryPage,
@@ -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-JH2UMGOT.js";
6
+ } from "./chunk-3VGFM7ME.js";
7
7
  import {
8
8
  SUBPROCESS_MAX_BUFFER,
9
9
  execFileAsync
10
- } from "./chunk-EUMRQH4J.js";
10
+ } from "./chunk-F4ZGMCND.js";
11
11
  import {
12
12
  extractCommandProtectionCommandText,
13
13
  findCommandProtectionGitLookups,
14
14
  findGitCommitSignals,
15
15
  findPrMergeSignals,
16
16
  parseCommandProtectionRequest
17
- } from "./chunk-4KMPRAV6.js";
17
+ } from "./chunk-RMH6PDA7.js";
18
18
 
19
19
  // src/services/command-protection-service.ts
20
20
  import { readFile, stat } from "fs/promises";
@@ -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-ZRCBGXER.js";
7
- import "./chunk-JH2UMGOT.js";
8
- import "./chunk-EUMRQH4J.js";
6
+ } from "./chunk-T65P3LSH.js";
7
+ import "./chunk-3VGFM7ME.js";
8
+ import "./chunk-F4ZGMCND.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-4KMPRAV6.js";
12
+ import "./chunk-RMH6PDA7.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/command-protection-hook.ts
@@ -3,16 +3,16 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  recoverCompletedTurn
6
- } from "./chunk-UPCC4BX5.js";
6
+ } from "./chunk-P73LGPQO.js";
7
7
  import {
8
8
  AppServerProcess,
9
9
  buildCodexAgentEnv
10
- } from "./chunk-UVAFYGNC.js";
11
- import "./chunk-EUMRQH4J.js";
10
+ } from "./chunk-4P4NVCXW.js";
11
+ import "./chunk-F4ZGMCND.js";
12
12
  import {
13
13
  AGENT,
14
14
  headlessAgentRequestSchema
15
- } from "./chunk-4KMPRAV6.js";
15
+ } from "./chunk-RMH6PDA7.js";
16
16
  import "./chunk-VEQXQN22.js";
17
17
 
18
18
  // 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-ZRCBGXER.js";
35
+ } from "./chunk-T65P3LSH.js";
36
36
  import {
37
37
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
38
38
  AGENT_MESSAGE_DELTA_METHOD,
@@ -47,16 +47,17 @@ import {
47
47
  THREAD_COMPACTED_METHOD,
48
48
  THREAD_GOAL_CLEARED_METHOD,
49
49
  THREAD_GOAL_UPDATED_METHOD,
50
+ THREAD_STATUS_CHANGED_METHOD,
50
51
  THREAD_TOKEN_USAGE_UPDATED_METHOD,
51
52
  TURN_COMPLETED_METHOD,
52
53
  TURN_PLAN_UPDATED_METHOD,
53
54
  TURN_STARTED_METHOD,
54
55
  dispatchAspNotification,
55
56
  recoverCompletedTurn
56
- } from "./chunk-UPCC4BX5.js";
57
+ } from "./chunk-P73LGPQO.js";
57
58
  import {
58
59
  publishedPullRequestUrls
59
- } from "./chunk-MHGSYSA2.js";
60
+ } from "./chunk-OKFWM3XR.js";
60
61
  import {
61
62
  BaseRefreshManager,
62
63
  CodexAspAuthMethodChangedError,
@@ -71,7 +72,7 @@ import {
71
72
  refreshDelayMs,
72
73
  restartCodexAspHost,
73
74
  routineRefreshExclusions
74
- } from "./chunk-2OEKOWPM.js";
75
+ } from "./chunk-NHD7MMAW.js";
75
76
  import {
76
77
  ENGINE_ENV,
77
78
  monolithRequest,
@@ -79,16 +80,16 @@ import {
79
80
  readRuntimeEnvFile,
80
81
  reloadEngineEnv,
81
82
  setAgentCredentialSnapshot
82
- } from "./chunk-JH2UMGOT.js";
83
+ } from "./chunk-3VGFM7ME.js";
83
84
  import {
84
85
  AspClient,
85
86
  getCodexModelProvider
86
- } from "./chunk-UVAFYGNC.js";
87
+ } from "./chunk-4P4NVCXW.js";
87
88
  import {
88
89
  SUBPROCESS_MAX_BUFFER,
89
90
  execAsync,
90
91
  execFileAsync
91
- } from "./chunk-EUMRQH4J.js";
92
+ } from "./chunk-F4ZGMCND.js";
92
93
  import {
93
94
  isRecord as isRecord2
94
95
  } from "./chunk-UZSNFLDQ.js";
@@ -116,6 +117,7 @@ import {
116
117
  CLAUDE_SONNET_5_BEDROCK_MODEL,
117
118
  CODEX_ASP_ITEM_ID_PAYLOAD_KEY,
118
119
  CODEX_HISTORY_FORMAT_EVENT_TYPE,
120
+ CODEX_ITEM_EVENT_TYPE,
119
121
  CODEX_QUOTA_STATUS_EVENT_TYPE,
120
122
  COMPACTION_STATUS_EVENT_TYPE,
121
123
  CONTEXT_USAGE_EVENT_TYPE,
@@ -192,6 +194,7 @@ import {
192
194
  claudeAuthEnvFromResponse,
193
195
  codexHistoryFormatEvent,
194
196
  codexItemEvent,
197
+ codexItemFromEvent,
195
198
  codexReasoningEffortForThinkingLevel,
196
199
  codexTranscriptToEvents,
197
200
  codexTurnEvent,
@@ -307,7 +310,7 @@ import {
307
310
  workspaceCredentialProviderSchema,
308
311
  workspaceTokenRequestSchema,
309
312
  workspaceTokenResponseSchema
310
- } from "./chunk-4KMPRAV6.js";
313
+ } from "./chunk-RMH6PDA7.js";
311
314
  import {
312
315
  cloneMcpConfig,
313
316
  ensureCompatibilityImports,
@@ -12941,6 +12944,20 @@ var CodexHistoryFile = class {
12941
12944
  }
12942
12945
  return found;
12943
12946
  }
12947
+ async findSubagentItems() {
12948
+ const found = /* @__PURE__ */ new Map();
12949
+ try {
12950
+ for await (const line of createInterface({ input: createReadStream(this.filePath), crlfDelay: Infinity })) {
12951
+ if (!line.includes('"subagent"')) continue;
12952
+ const event = parseAgentEventJsonlLine(line);
12953
+ const payload = event?.type === CODEX_ITEM_EVENT_TYPE ? codexItemFromEvent(event) : null;
12954
+ if (payload?.item.type === "subagent") found.set(payload.item.id, { turnId: payload.turnId, item: payload.item });
12955
+ }
12956
+ } catch (error) {
12957
+ if (!isMissingFile(error)) throw error;
12958
+ }
12959
+ return found;
12960
+ }
12944
12961
  async loadAll() {
12945
12962
  const folder = new CodexHistoryEventFolder();
12946
12963
  try {
@@ -15255,6 +15272,7 @@ var CodexAspManager = class extends CodingAgentManager {
15255
15272
  attachedDeveloperInstructions = null;
15256
15273
  historyFile;
15257
15274
  liveTurn = null;
15275
+ codexSubagents = /* @__PURE__ */ new Map();
15258
15276
  quotaStatus = new CodexQuotaStatusTracker();
15259
15277
  currentGoal = null;
15260
15278
  goalHistoryKnown = false;
@@ -15292,6 +15310,9 @@ var CodexAspManager = class extends CodingAgentManager {
15292
15310
  this.currentGoal = coerceChatGoalPayload(goalEvent.payload);
15293
15311
  this.goalHistoryKnown = true;
15294
15312
  }
15313
+ for (const { turnId, item } of (await this.historyFile?.findSubagentItems())?.values() ?? []) {
15314
+ if (item.status === "in_progress") this.updateCodexSubagent({ turnId, item, active: /* @__PURE__ */ new Set(), failed: false });
15315
+ }
15295
15316
  }
15296
15317
  getHistorySink() {
15297
15318
  return {
@@ -15634,6 +15655,9 @@ var CodexAspManager = class extends CodingAgentManager {
15634
15655
  if (this.attachedClient !== host.client) {
15635
15656
  this.skillRegistriesApplied = false;
15636
15657
  this.modelServiceTierCache = null;
15658
+ this.closeCodexSubagents();
15659
+ host.client.off("notification", this.onSubagentThreadStatus);
15660
+ host.client.on("notification", this.onSubagentThreadStatus);
15637
15661
  }
15638
15662
  await this.applySkillRegistries(host);
15639
15663
  const existingThreadId = this.currentThreadId;
@@ -16161,10 +16185,41 @@ ${text.slice(-24e3)}`
16161
16185
  const live = turn.items.get(item.id);
16162
16186
  turn.items.delete(item.id);
16163
16187
  turn.persistedItemIds.add(item.id);
16164
- const event = codexItemEvent(turnId, live ? { ...item, timestamp: live.timestamp } : item);
16188
+ const timestamp = live?.timestamp ?? item.timestamp;
16189
+ const persisted = item.type === "subagent" && item.status === "completed" ? { ...item, timestamp, status: "in_progress" } : { ...item, timestamp };
16190
+ if (persisted.type === "subagent" && persisted.status === "in_progress") {
16191
+ const subagent = { turnId, item: persisted, active: new Set(persisted.receiverThreadIds), failed: false };
16192
+ for (const threadId of subagent.active) this.codexSubagents.set(threadId, subagent);
16193
+ }
16194
+ const event = codexItemEvent(turnId, persisted);
16195
+ this.historyFile?.append(event);
16196
+ this.onEvent(event);
16197
+ }
16198
+ updateCodexSubagent(subagent) {
16199
+ const status = normalizeCodexAspTranscriptStatus(subagent.active.size > 0 ? "inProgress" : "completed", subagent.failed);
16200
+ if (subagent.item.status === status) return;
16201
+ subagent.item = { ...subagent.item, status };
16202
+ const event = codexItemEvent(subagent.turnId, subagent.item);
16165
16203
  this.historyFile?.append(event);
16166
16204
  this.onEvent(event);
16167
16205
  }
16206
+ closeCodexSubagents() {
16207
+ for (const subagent of new Set(this.codexSubagents.values())) {
16208
+ subagent.active.clear();
16209
+ this.updateCodexSubagent(subagent);
16210
+ }
16211
+ this.codexSubagents.clear();
16212
+ }
16213
+ onSubagentThreadStatus = (notification) => {
16214
+ if (notification.method !== THREAD_STATUS_CHANGED_METHOD) return;
16215
+ const { threadId, status: { type } } = notification.params;
16216
+ const subagent = this.codexSubagents.get(threadId);
16217
+ if (!subagent) return;
16218
+ if (type === "active") subagent.active.add(threadId);
16219
+ else subagent.active.delete(threadId);
16220
+ subagent.failed ||= type === "systemError";
16221
+ this.updateCodexSubagent(subagent);
16222
+ };
16168
16223
  completeTurn(turn) {
16169
16224
  const live = this.ensureLiveTurn(turn.id);
16170
16225
  const completedAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -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-MHGSYSA2.js";
6
+ } from "./chunk-OKFWM3XR.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-4KMPRAV6.js";
12
+ } from "./chunk-RMH6PDA7.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-4KMPRAV6.js";
12
+ } from "./chunk-RMH6PDA7.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.971",
3
+ "version": "0.1.973",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",