replicas-engine 0.1.881 → 0.1.883

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-VLMY3PUD.js";
9
- import "./chunk-4CF465DO.js";
10
- import "./chunk-AKHJBXSS.js";
8
+ } from "./chunk-EW3NFV6B.js";
9
+ import "./chunk-M3A4WF5K.js";
10
+ import "./chunk-USCNKCYW.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-PYQVWR2X.js";
12
+ import "./chunk-2HBZMD3O.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
  export {
15
15
  getCodexAspHost,
@@ -1161,6 +1161,24 @@ var relaySubagentResponseSchema = z3.object({
1161
1161
  response: z3.string().optional(),
1162
1162
  timedOut: z3.literal(true).optional()
1163
1163
  });
1164
+ var integrationErrorNotificationTargetSchema = z3.discriminatedUnion("type", [
1165
+ z3.object({
1166
+ type: z3.literal("slack"),
1167
+ conversation: z3.object({
1168
+ channelId: z3.string().min(1),
1169
+ threadTs: z3.string().min(1)
1170
+ }).optional()
1171
+ }),
1172
+ z3.object({ type: z3.literal("linear"), sessionId: z3.string().min(1) }),
1173
+ z3.object({
1174
+ type: z3.literal("code_host"),
1175
+ provider: z3.enum(["github", "gitlab"]),
1176
+ resource: z3.enum(["issue", "pull_request"]),
1177
+ repositoryId: z3.string().min(1),
1178
+ resourceNumber: z3.number().int().positive()
1179
+ }),
1180
+ z3.object({ type: z3.literal("automation"), executionId: z3.string().min(1) })
1181
+ ]);
1164
1182
  var sendChatMessageRequestSchema = z3.object({
1165
1183
  messageId: z3.string().min(1).optional(),
1166
1184
  submittedAt: z3.string().datetime().optional(),
@@ -1190,18 +1208,8 @@ var sendChatMessageRequestSchema = z3.object({
1190
1208
  senderEmail: z3.string().optional(),
1191
1209
  senderDisplayName: z3.string().optional(),
1192
1210
  senderAvatarUrl: z3.string().optional(),
1193
- errorNotificationTarget: z3.discriminatedUnion("type", [
1194
- z3.object({ type: z3.literal("slack") }),
1195
- z3.object({ type: z3.literal("linear"), sessionId: z3.string().min(1) }),
1196
- z3.object({
1197
- type: z3.literal("code_host"),
1198
- provider: z3.enum(["github", "gitlab"]),
1199
- resource: z3.enum(["issue", "pull_request"]),
1200
- repositoryId: z3.string().min(1),
1201
- resourceNumber: z3.number().int().positive()
1202
- }),
1203
- z3.object({ type: z3.literal("automation"), executionId: z3.string().min(1) })
1204
- ]).optional()
1211
+ errorNotificationTarget: integrationErrorNotificationTargetSchema.optional(),
1212
+ errorNotificationTargets: z3.array(integrationErrorNotificationTargetSchema).optional()
1205
1213
  }).passthrough();
1206
1214
  function isChatMessageSender(value) {
1207
1215
  return isRecord(value) && (value.messageId === void 0 || typeof value.messageId === "string") && typeof value.senderUserId === "string" && typeof value.senderEmail === "string" && typeof value.recordedAt === "string";
@@ -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-4CF465DO.js";
6
+ } from "./chunk-M3A4WF5K.js";
7
7
  import {
8
8
  extractCommandProtectionCommandText,
9
9
  findGitCommitSignals,
10
10
  findPrMergeSignals
11
- } from "./chunk-PYQVWR2X.js";
11
+ } from "./chunk-2HBZMD3O.js";
12
12
 
13
13
  // src/services/command-protection-service.ts
14
14
  var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
@@ -5,13 +5,13 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  setAgentCredentialSnapshot
8
- } from "./chunk-4CF465DO.js";
8
+ } from "./chunk-M3A4WF5K.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  SUBPROCESS_MAX_BUFFER,
12
12
  buildCodexAgentEnv,
13
13
  execFileAsync
14
- } from "./chunk-AKHJBXSS.js";
14
+ } from "./chunk-USCNKCYW.js";
15
15
  import {
16
16
  isRecord
17
17
  } from "./chunk-UZSNFLDQ.js";
@@ -25,7 +25,7 @@ import {
25
25
  listOpenAICompatibleModels,
26
26
  readOllamaAuthEnv,
27
27
  resolveOpenAICompatibleModelsUrl
28
- } from "./chunk-PYQVWR2X.js";
28
+ } from "./chunk-2HBZMD3O.js";
29
29
 
30
30
  // src/managers/codex-token-manager.ts
31
31
  import { promises as fs } from "fs";
@@ -68,6 +68,11 @@ function listCredentialFallbacks() {
68
68
  function listExhaustedCredentials(provider) {
69
69
  return [...exhaustedByAgent.get(provider)?.values() ?? []];
70
70
  }
71
+ function routineRefreshExclusions(provider) {
72
+ const live = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS[provider];
73
+ const excludeCredentials = listExhaustedCredentials(provider).filter((spent) => spent.method !== live?.method || spent.scope !== live?.scope);
74
+ return excludeCredentials.length > 0 ? { excludeCredentials } : {};
75
+ }
71
76
  function recordExhaustedCredential(provider, credential) {
72
77
  const spent = exhaustedByAgent.get(provider) ?? /* @__PURE__ */ new Map();
73
78
  spent.set(`${credential.method}|${credential.scope}`, credential);
@@ -240,13 +245,13 @@ var CodexTokenManager = class extends BaseRefreshManager {
240
245
  return null;
241
246
  }
242
247
  async doRefresh(_config) {
243
- await this.refreshWithRequest(void 0, true);
248
+ await this.refreshWithRequest(routineRefreshExclusions("codex"), true);
244
249
  }
245
250
  async switchCredentials(data) {
246
251
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
247
252
  await this.applyCredentialsResponse(data);
248
253
  if (data.scope) setAgentCredentialSnapshot("codex", { method: data.type, scope: data.scope, revision: data.revision });
249
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-ITDUH7G3.js");
254
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-UHA7DQNH.js");
250
255
  await restartCodexAspHostIfRunning2();
251
256
  });
252
257
  await this.start(true);
@@ -266,7 +271,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
266
271
  await this.applyCredentialUpdate(generation, async () => {
267
272
  await this.applyCredentialsResponse(data);
268
273
  if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
269
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-ITDUH7G3.js");
274
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-UHA7DQNH.js");
270
275
  await restartCodexAspHostIfRunning2();
271
276
  }
272
277
  if (data.scope) {
@@ -505,6 +510,7 @@ export {
505
510
  clearCredentialFallbacks,
506
511
  recordCredentialFallback,
507
512
  listCredentialFallbacks,
513
+ routineRefreshExclusions,
508
514
  recordExhaustedCredential,
509
515
  BaseRefreshManager,
510
516
  applyAuthEnvTransition,
@@ -15,7 +15,7 @@ import {
15
15
  isValidRelayBaseProvider,
16
16
  parsePosixEnvFile,
17
17
  readReplicasRuntimeEnv
18
- } from "./chunk-PYQVWR2X.js";
18
+ } from "./chunk-2HBZMD3O.js";
19
19
 
20
20
  // src/engine-env.ts
21
21
  import { readFileSync as readFileSync2 } from "fs";
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  shouldRefreshPullRequests
6
- } from "./chunk-PYQVWR2X.js";
6
+ } from "./chunk-2HBZMD3O.js";
7
7
 
8
8
  // src/services/post-tool-pr-notifier.ts
9
9
  async function notifyPostToolUse(toolName, toolInput) {
@@ -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-PYQVWR2X.js";
7
+ } from "./chunk-2HBZMD3O.js";
8
8
 
9
9
  // src/utils/codex-agent-env.ts
10
10
  function buildCodexAgentEnv(source = process.env) {
@@ -245,7 +245,7 @@ function getCodexModelProvider(method) {
245
245
  if (method === "foundry") return "azure";
246
246
  return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
247
247
  }
248
- var ENGINE_PACKAGE_VERSION = "0.1.881";
248
+ var ENGINE_PACKAGE_VERSION = "0.1.883";
249
249
  var INITIALIZE_METHOD = "initialize";
250
250
  var INITIALIZED_NOTIFICATION = "initialized";
251
251
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -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-OMPZUIYA.js";
7
- import "./chunk-4CF465DO.js";
6
+ } from "./chunk-BDG6FRDO.js";
7
+ import "./chunk-M3A4WF5K.js";
8
8
  import {
9
9
  isRecord
10
10
  } from "./chunk-UZSNFLDQ.js";
11
- import "./chunk-PYQVWR2X.js";
11
+ import "./chunk-2HBZMD3O.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-OMPZUIYA.js";
6
+ } from "./chunk-BDG6FRDO.js";
7
7
  import {
8
8
  notifyPostToolUse
9
- } from "./chunk-BYRW3S7A.js";
10
- import "./chunk-4CF465DO.js";
9
+ } from "./chunk-Q3M3WO7E.js";
10
+ import "./chunk-M3A4WF5K.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-PYQVWR2X.js";
12
+ import "./chunk-2HBZMD3O.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-AKHJBXSS.js";
11
+ } from "./chunk-USCNKCYW.js";
12
12
  import {
13
13
  AGENT,
14
14
  getMemoryOutputSafetyViolation,
15
15
  headlessAgentRequestSchema
16
- } from "./chunk-PYQVWR2X.js";
16
+ } from "./chunk-2HBZMD3O.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-OMPZUIYA.js";
94
+ } from "./chunk-BDG6FRDO.js";
95
95
  import {
96
96
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
97
97
  AGENT_MESSAGE_DELTA_METHOD,
@@ -131,22 +131,23 @@ import {
131
131
  listCredentialFallbacks,
132
132
  recordCredentialFallback,
133
133
  recordExhaustedCredential,
134
- restartCodexAspHost
135
- } from "./chunk-VLMY3PUD.js";
134
+ restartCodexAspHost,
135
+ routineRefreshExclusions
136
+ } from "./chunk-EW3NFV6B.js";
136
137
  import {
137
138
  ENGINE_ENV,
138
139
  IS_WARMING_MODE,
139
140
  monolithRequest,
140
141
  monolithService,
141
142
  setAgentCredentialSnapshot
142
- } from "./chunk-4CF465DO.js";
143
+ } from "./chunk-M3A4WF5K.js";
143
144
  import {
144
145
  AspClient,
145
146
  SUBPROCESS_MAX_BUFFER,
146
147
  execAsync,
147
148
  execFileAsync,
148
149
  getCodexModelProvider
149
- } from "./chunk-AKHJBXSS.js";
150
+ } from "./chunk-USCNKCYW.js";
150
151
  import {
151
152
  isRecord as isRecord2
152
153
  } from "./chunk-UZSNFLDQ.js";
@@ -361,7 +362,7 @@ import {
361
362
  waitRelaySubagentRequestSchema,
362
363
  withTimeout,
363
364
  workspaceCredentialProviderSchema
364
- } from "./chunk-PYQVWR2X.js";
365
+ } from "./chunk-2HBZMD3O.js";
365
366
  import {
366
367
  __commonJS,
367
368
  __export,
@@ -9431,7 +9432,7 @@ var ClaudeTokenManager = class extends BaseRefreshManager {
9431
9432
  return null;
9432
9433
  }
9433
9434
  async doRefresh(_config) {
9434
- await this.refreshWithRequest();
9435
+ await this.refreshWithRequest(routineRefreshExclusions("claude"));
9435
9436
  }
9436
9437
  async switchCredentials(data) {
9437
9438
  await this.applyCredentialUpdate(++this.credentialGeneration, () => this.applyCredentialsResponse(data));
@@ -61648,8 +61649,16 @@ var ChatService = class {
61648
61649
  }
61649
61650
  chat.lastSendRequest = request;
61650
61651
  this.agentChatActivityTrackerService.noteMessageAccepted(result.messageId, request);
61651
- if (request.errorNotificationTarget) {
61652
- chat.errorNotificationTargets.set(result.messageId, request.errorNotificationTarget);
61652
+ const notificationTargets = [
61653
+ ...request.errorNotificationTargets ?? [],
61654
+ ...request.errorNotificationTarget ? [request.errorNotificationTarget] : []
61655
+ ];
61656
+ if (notificationTargets.length > 0) {
61657
+ const existingTargets = chat.errorNotificationTargets.get(result.messageId) ?? [];
61658
+ chat.errorNotificationTargets.set(result.messageId, [
61659
+ ...existingTargets,
61660
+ ...notificationTargets.filter((target) => !existingTargets.some((existing) => JSON.stringify(existing) === JSON.stringify(target)))
61661
+ ]);
61653
61662
  }
61654
61663
  if (recordedSender) {
61655
61664
  await this.appendSender(chatId, recordedSender);
@@ -61987,7 +61996,7 @@ var ChatService = class {
61987
61996
  });
61988
61997
  return formatChatForkHandoffMessage({ ...handoff, ...options });
61989
61998
  }
61990
- async runFork(targetId, request, errorNotificationTarget) {
61999
+ async runFork(targetId, request, errorNotificationTargets) {
61991
62000
  const target = this.chats.get(targetId);
61992
62001
  const fork = target?.persisted.fork;
61993
62002
  if (!target || !fork) return false;
@@ -62009,7 +62018,7 @@ var ChatService = class {
62009
62018
  senderEmail: request.senderEmail,
62010
62019
  senderDisplayName: request.senderDisplayName,
62011
62020
  senderAvatarUrl: request.senderAvatarUrl,
62012
- errorNotificationTarget,
62021
+ errorNotificationTargets,
62013
62022
  idempotencyKey: `chat-fork:${targetId}`
62014
62023
  });
62015
62024
  } catch (error) {
@@ -62061,10 +62070,10 @@ var ChatService = class {
62061
62070
  senderAvatarUrl: last?.senderAvatarUrl
62062
62071
  };
62063
62072
  const fallback = await this.createForkTarget(chat.persisted.id, request, "auto", exhaustion.reason);
62064
- const accepted = await this.runFork(fallback.id, request, chat.activeErrorNotificationTarget ?? void 0);
62073
+ const accepted = await this.runFork(fallback.id, request, chat.activeErrorNotificationTargets);
62065
62074
  if (!accepted) return false;
62066
62075
  chat.lastTurnErrors = null;
62067
- chat.activeErrorNotificationTarget = null;
62076
+ chat.activeErrorNotificationTargets = [];
62068
62077
  return true;
62069
62078
  }
62070
62079
  async getChatHistory(chatId, page2 = {}) {
@@ -62273,7 +62282,7 @@ var ChatService = class {
62273
62282
  observedBranchesByRepo: /* @__PURE__ */ new Map(),
62274
62283
  lastTurnErrors: null,
62275
62284
  errorNotificationTargets: /* @__PURE__ */ new Map(),
62276
- activeErrorNotificationTarget: null,
62285
+ activeErrorNotificationTargets: [],
62277
62286
  quotaExhaustion: null,
62278
62287
  lastSendRequest: null
62279
62288
  };
@@ -62322,7 +62331,7 @@ var ChatService = class {
62322
62331
  getChatExecutionProvider(chat.persisted)
62323
62332
  );
62324
62333
  this.agentTokenUsageTracker.startTurn(context);
62325
- chat.activeErrorNotificationTarget = chat.errorNotificationTargets.get(messageId) ?? null;
62334
+ chat.activeErrorNotificationTargets = chat.errorNotificationTargets.get(messageId) ?? [];
62326
62335
  chat.errorNotificationTargets.delete(messageId);
62327
62336
  }
62328
62337
  async handleTurnStarted(chatId, message) {
@@ -62590,8 +62599,8 @@ var ChatService = class {
62590
62599
  const linearSessionId = ENGINE_ENV.REPLICAS_LINEAR_SESSION_ID;
62591
62600
  const errors = chat.persisted.parentChatId === null ? chat.lastTurnErrors : null;
62592
62601
  chat.lastTurnErrors = null;
62593
- const errorNotificationTarget = chat.activeErrorNotificationTarget;
62594
- chat.activeErrorNotificationTarget = null;
62602
+ const errorNotificationTargets = chat.activeErrorNotificationTargets;
62603
+ chat.activeErrorNotificationTargets = [];
62595
62604
  const repoStatuses = await this.refreshTurnRepos(chat);
62596
62605
  if (chat.persisted.parentChatId) return;
62597
62606
  try {
@@ -62601,7 +62610,7 @@ var ChatService = class {
62601
62610
  processing,
62602
62611
  repoStatuses,
62603
62612
  ...errors?.length ? { errors } : {},
62604
- ...errors?.length && errorNotificationTarget ? { errorNotificationTarget } : {}
62613
+ ...errors?.length && errorNotificationTargets.length > 0 ? { errorNotificationTargets } : {}
62605
62614
  };
62606
62615
  await monolithService.sendEvent({ type: "agent_turn_complete", payload });
62607
62616
  } catch (error) {
@@ -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-BYRW3S7A.js";
6
+ } from "./chunk-Q3M3WO7E.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
- import "./chunk-PYQVWR2X.js";
10
+ import "./chunk-2HBZMD3O.js";
11
11
  import "./chunk-VEQXQN22.js";
12
12
 
13
13
  // src/post-tool-pr-hook.ts
@@ -11,7 +11,7 @@ import {
11
11
  relaySubagentResponseSchema,
12
12
  spawnRelaySubagentRequestSchema,
13
13
  waitRelaySubagentRequestSchema
14
- } from "./chunk-PYQVWR2X.js";
14
+ } from "./chunk-2HBZMD3O.js";
15
15
  import "./chunk-VEQXQN22.js";
16
16
 
17
17
  // src/relay-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.881",
3
+ "version": "0.1.883",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",