replicas-engine 0.1.975 → 0.1.977

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-DQFGKWE5.js";
9
- import "./chunk-TCG5OMQH.js";
10
- import "./chunk-ZOOJP2HJ.js";
11
- import "./chunk-X5MYHFWW.js";
8
+ } from "./chunk-7PG7CEM5.js";
9
+ import "./chunk-RCD357QL.js";
10
+ import "./chunk-56WQAG5I.js";
11
+ import "./chunk-TMQGB4OW.js";
12
12
  import "./chunk-UZSNFLDQ.js";
13
- import "./chunk-NTM575B4.js";
13
+ import "./chunk-LGWE7MSQ.js";
14
14
  import "./chunk-VEQXQN22.js";
15
15
  export {
16
16
  getCodexAspHost,
@@ -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-X5MYHFWW.js";
6
+ } from "./chunk-TMQGB4OW.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-NTM575B4.js";
9
+ } from "./chunk-LGWE7MSQ.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.975";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.977";
244
244
  var INITIALIZE_METHOD = "initialize";
245
245
  var INITIALIZED_NOTIFICATION = "initialized";
246
246
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -5,15 +5,15 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  setAgentCredentialSnapshot
8
- } from "./chunk-TCG5OMQH.js";
8
+ } from "./chunk-RCD357QL.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  buildCodexAgentEnv
12
- } from "./chunk-ZOOJP2HJ.js";
12
+ } from "./chunk-56WQAG5I.js";
13
13
  import {
14
14
  SUBPROCESS_MAX_BUFFER,
15
15
  execFileAsync
16
- } from "./chunk-X5MYHFWW.js";
16
+ } from "./chunk-TMQGB4OW.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-NTM575B4.js";
30
+ } from "./chunk-LGWE7MSQ.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-SJQEEEQS.js");
263
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-N276J7RL.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-SJQEEEQS.js");
283
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-N276J7RL.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-NTM575B4.js";
8
+ } from "./chunk-LGWE7MSQ.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -823,6 +823,19 @@ var CREDENTIAL_TYPE = {
823
823
  MUSE_OAUTH: "muse_oauth",
824
824
  MUSE_API_KEY: "muse_api_key"
825
825
  };
826
+ var ENVIRONMENT_AUTH_REQUIRED_KEYS = {
827
+ [AGENT.CLAUDE]: [
828
+ [CREDENTIAL_METHOD.BEDROCK, ["CLAUDE_CODE_USE_BEDROCK", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"]],
829
+ [CREDENTIAL_METHOD.API_KEY, ["ANTHROPIC_API_KEY"]]
830
+ ],
831
+ [AGENT.CODEX]: [[CREDENTIAL_METHOD.API_KEY, ["OPENAI_API_KEY"]]]
832
+ };
833
+ function isEnvironmentKeySet(env, key) {
834
+ return !!env[key]?.trim();
835
+ }
836
+ function detectEnvironmentAuthMethod(agent, env) {
837
+ return ENVIRONMENT_AUTH_REQUIRED_KEYS[agent].find(([, keys]) => keys.every((key) => isEnvironmentKeySet(env, key)))?.[0];
838
+ }
826
839
  var INFERENCE_PROVIDER_LABELS = {
827
840
  [CREDENTIAL_METHOD.OLLAMA]: "Ollama",
828
841
  [CREDENTIAL_METHOD.OPENCODE_GO]: "OpenCode Go",
@@ -8866,6 +8879,7 @@ function normalizeChatTranscriptMetadata(value) {
8866
8879
  relayBaseProvider,
8867
8880
  credential,
8868
8881
  credentialSource,
8882
+ environmentAuthMethod,
8869
8883
  model,
8870
8884
  title,
8871
8885
  displayName,
@@ -8886,6 +8900,8 @@ function normalizeChatTranscriptMetadata(value) {
8886
8900
  const parsedCredential = agentCredentialSnapshotSchema.safeParse(credential);
8887
8901
  if (parsedCredential.success) metadata.credential = parsedCredential.data;
8888
8902
  if (credentialSource === "stored" || credentialSource === "environment") metadata.credentialSource = credentialSource;
8903
+ const authMethod = Object.values(CREDENTIAL_METHOD).find((method) => method === environmentAuthMethod);
8904
+ if (authMethod) metadata.environmentAuthMethod = authMethod;
8889
8905
  if (typeof model === "string") metadata.model = model;
8890
8906
  if (typeof title === "string") metadata.title = title;
8891
8907
  if (typeof displayName === "string") metadata.displayName = displayName;
@@ -8975,6 +8991,7 @@ export {
8975
8991
  getDefaultOllamaModel,
8976
8992
  listOllamaModels,
8977
8993
  CREDENTIAL_METHOD,
8994
+ detectEnvironmentAuthMethod,
8978
8995
  AGENT_CREDENTIAL_METHODS_IN_ORDER,
8979
8996
  describeCredential,
8980
8997
  agentCredentialSnapshotSchema,
@@ -9172,6 +9189,7 @@ export {
9172
9189
  formatChatForkHandoffMessage,
9173
9190
  formatSideChatUpdateMessage,
9174
9191
  readJsonlPage,
9192
+ normalizeChatTranscriptMetadata,
9175
9193
  parseChatTranscriptArtifact,
9176
9194
  readSseStream,
9177
9195
  parseFrontmatter,
@@ -14,7 +14,7 @@ import {
14
14
  isValidAgentProvider,
15
15
  parsePosixEnvFile,
16
16
  readReplicasRuntimeEnv
17
- } from "./chunk-NTM575B4.js";
17
+ } from "./chunk-LGWE7MSQ.js";
18
18
 
19
19
  // src/runtime-env-loader.ts
20
20
  import { readFileSync } 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
  HOOK_EXEC_MAX_BUFFER_BYTES
6
- } from "./chunk-NTM575B4.js";
6
+ } from "./chunk-LGWE7MSQ.js";
7
7
 
8
8
  // src/utils/exec.ts
9
9
  import { exec, execFile } from "child_process";
@@ -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-TCG5OMQH.js";
6
+ } from "./chunk-RCD357QL.js";
7
7
  import {
8
8
  SUBPROCESS_MAX_BUFFER,
9
9
  execFileAsync
10
- } from "./chunk-X5MYHFWW.js";
10
+ } from "./chunk-TMQGB4OW.js";
11
11
  import {
12
12
  extractCommandProtectionCommandText,
13
13
  findCommandProtectionGitLookups,
14
14
  findGitCommitSignals,
15
15
  findPrMergeSignals,
16
16
  parseCommandProtectionRequest
17
- } from "./chunk-NTM575B4.js";
17
+ } from "./chunk-LGWE7MSQ.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-OXFR4PCR.js";
7
- import "./chunk-TCG5OMQH.js";
8
- import "./chunk-X5MYHFWW.js";
6
+ } from "./chunk-ZAPWSOKN.js";
7
+ import "./chunk-RCD357QL.js";
8
+ import "./chunk-TMQGB4OW.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-NTM575B4.js";
12
+ import "./chunk-LGWE7MSQ.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/command-protection-hook.ts
@@ -7,12 +7,12 @@ import {
7
7
  import {
8
8
  AppServerProcess,
9
9
  buildCodexAgentEnv
10
- } from "./chunk-ZOOJP2HJ.js";
11
- import "./chunk-X5MYHFWW.js";
10
+ } from "./chunk-56WQAG5I.js";
11
+ import "./chunk-TMQGB4OW.js";
12
12
  import {
13
13
  AGENT,
14
14
  headlessAgentRequestSchema
15
- } from "./chunk-NTM575B4.js";
15
+ } from "./chunk-LGWE7MSQ.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-OXFR4PCR.js";
35
+ } from "./chunk-ZAPWSOKN.js";
36
36
  import {
37
37
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
38
38
  AGENT_MESSAGE_DELTA_METHOD,
@@ -57,7 +57,7 @@ import {
57
57
  } from "./chunk-P73LGPQO.js";
58
58
  import {
59
59
  publishedPullRequestUrls
60
- } from "./chunk-DTKUVZ6U.js";
60
+ } from "./chunk-K2WA7ZYZ.js";
61
61
  import {
62
62
  BaseRefreshManager,
63
63
  CodexAspAuthMethodChangedError,
@@ -72,7 +72,7 @@ import {
72
72
  refreshDelayMs,
73
73
  restartCodexAspHost,
74
74
  routineRefreshExclusions
75
- } from "./chunk-DQFGKWE5.js";
75
+ } from "./chunk-7PG7CEM5.js";
76
76
  import {
77
77
  ENGINE_ENV,
78
78
  monolithRequest,
@@ -80,16 +80,16 @@ import {
80
80
  readRuntimeEnvFile,
81
81
  reloadEngineEnv,
82
82
  setAgentCredentialSnapshot
83
- } from "./chunk-TCG5OMQH.js";
83
+ } from "./chunk-RCD357QL.js";
84
84
  import {
85
85
  AspClient,
86
86
  getCodexModelProvider
87
- } from "./chunk-ZOOJP2HJ.js";
87
+ } from "./chunk-56WQAG5I.js";
88
88
  import {
89
89
  SUBPROCESS_MAX_BUFFER,
90
90
  execAsync,
91
91
  execFileAsync
92
- } from "./chunk-X5MYHFWW.js";
92
+ } from "./chunk-TMQGB4OW.js";
93
93
  import {
94
94
  isRecord as isRecord2
95
95
  } from "./chunk-UZSNFLDQ.js";
@@ -215,6 +215,7 @@ import {
215
215
  describeCredential,
216
216
  describeQuotaLimit,
217
217
  detectAgentQuotaLimit,
218
+ detectEnvironmentAuthMethod,
218
219
  detectLanguageByPath,
219
220
  excludeQueuedAcceptedEvents,
220
221
  extractErrorText,
@@ -271,6 +272,7 @@ import {
271
272
  mergeSlashCommands,
272
273
  messageSubagentRequestSchema,
273
274
  normalizeAutoCompactThreshold,
275
+ normalizeChatTranscriptMetadata,
274
276
  normalizeClaudeModel,
275
277
  normalizeCodexAspTranscriptStatus,
276
278
  normalizeContentBlocks,
@@ -310,7 +312,7 @@ import {
310
312
  workspaceCredentialProviderSchema,
311
313
  workspaceTokenRequestSchema,
312
314
  workspaceTokenResponseSchema
313
- } from "./chunk-NTM575B4.js";
315
+ } from "./chunk-LGWE7MSQ.js";
314
316
  import {
315
317
  cloneMcpConfig,
316
318
  ensureCompatibilityImports,
@@ -10004,7 +10006,7 @@ var MUSE_AUTH_PATH = join5(homedir3(), ".config", "muse", "auth.json");
10004
10006
 
10005
10007
  // src/managers/codex-auth.ts
10006
10008
  function detectCodexAuthMethod() {
10007
- return ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD ?? (ENGINE_ENV.OPENAI_API_KEY ? "api_key" : "none");
10009
+ return ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD ?? detectEnvironmentAuthMethod(AGENT.CODEX, process.env) ?? "none";
10008
10010
  }
10009
10011
 
10010
10012
  // src/managers/agent-auth-detection.ts
@@ -10017,13 +10019,7 @@ function detectClaudeAuthMethod() {
10017
10019
  if (ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD === "foundry") {
10018
10020
  return "foundry";
10019
10021
  }
10020
- if (ENGINE_ENV.CLAUDE_CODE_USE_BEDROCK && ENGINE_ENV.AWS_ACCESS_KEY_ID && ENGINE_ENV.AWS_SECRET_ACCESS_KEY) {
10021
- return "bedrock";
10022
- }
10023
- if (ENGINE_ENV.ANTHROPIC_API_KEY) {
10024
- return "api_key";
10025
- }
10026
- return "none";
10022
+ return detectEnvironmentAuthMethod(AGENT.CLAUDE, process.env) ?? "none";
10027
10023
  }
10028
10024
  function detectAgentAuthMethod(provider) {
10029
10025
  if (OLLAMA_AGENTS.some((agent) => agent === provider && readOllamaAuthEnv(agent, process.env))) return "ollama";
@@ -60211,6 +60207,17 @@ var ALWAYS_UPLOAD_HISTORY_DIRS = /* @__PURE__ */ new Set([
60211
60207
  HISTORY_DIR_BY_PROVIDER.claude,
60212
60208
  HISTORY_DIR_BY_PROVIDER.codex
60213
60209
  ]);
60210
+ function currentTranscriptAuth(provider) {
60211
+ const credential = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS[provider];
60212
+ if (credential) return { credential, credentialSource: "stored" };
60213
+ const method = detectAgentAuthMethod(provider);
60214
+ return method === "none" ? {} : { credentialSource: "environment", environmentAuthMethod: method };
60215
+ }
60216
+ function normalizeTranscriptAuth(value) {
60217
+ if (!isRecord(value)) return void 0;
60218
+ const { credential, credentialSource, environmentAuthMethod } = normalizeChatTranscriptMetadata(value);
60219
+ return { credential, credentialSource, environmentAuthMethod };
60220
+ }
60214
60221
  function shouldFlushChatTranscript(historyDir, chat, chatsById) {
60215
60222
  return ALWAYS_UPLOAD_HISTORY_DIRS.has(historyDir) || Boolean(chat?.parentChatId && chatsById.has(chat.parentChatId));
60216
60223
  }
@@ -60259,12 +60266,10 @@ function uploadChatTranscript(chatId, filePath, chat, capture) {
60259
60266
  async function uploadChatTranscriptNow(chatId, filePath, chat, capture) {
60260
60267
  const { size } = await stat5(filePath);
60261
60268
  if (size === 0) return null;
60262
- const credential = chat && ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS[chat.provider];
60263
60269
  const metadata = chat ? {
60264
60270
  provider: chat.provider,
60265
- credential,
60266
- // Without a stored credential the agent can only have run on environment-variable auth.
60267
- credentialSource: credential ? "stored" : detectAgentAuthMethod(chat.provider) === "none" ? void 0 : "environment",
60271
+ // Chats with no turn since this engine version fall back to the auth live at upload.
60272
+ ...chat.transcriptAuth ?? currentTranscriptAuth(chat.provider),
60268
60273
  model: chat.model,
60269
60274
  title: chat.title,
60270
60275
  displayName: chat.displayName,
@@ -60627,6 +60632,7 @@ function normalizePersistedChat(chat) {
60627
60632
  fork: coerceChatForkInfo(chat.fork),
60628
60633
  pendingForkHandoff: chat.pendingForkHandoff === true,
60629
60634
  ...chat.chatCredential === "workspace" || agentCredentialSnapshotSchema.safeParse(chat.chatCredential).success ? { chatCredential: chat.chatCredential } : {},
60635
+ transcriptAuth: normalizeTranscriptAuth(chat.transcriptAuth),
60630
60636
  removedMessageIds: Array.isArray(chat.removedMessageIds) ? chat.removedMessageIds.filter((id) => typeof id === "string").slice(-MAX_REMOVED_MESSAGE_IDS) : [],
60631
60637
  acceptedSendResponses: isRecord2(chat.acceptedSendResponses) ? Object.fromEntries(Object.entries(chat.acceptedSendResponses).filter((entry) => {
60632
60638
  const response = entry[1];
@@ -61471,7 +61477,7 @@ var ChatService = class {
61471
61477
  return count;
61472
61478
  }
61473
61479
  toTranscriptSource(chat) {
61474
- return { ...this.toSummary(chat), removedMessageIds: chat.persisted.removedMessageIds };
61480
+ return { ...this.toSummary(chat), removedMessageIds: chat.persisted.removedMessageIds, transcriptAuth: chat.persisted.transcriptAuth };
61475
61481
  }
61476
61482
  uploadChatTranscript(chat) {
61477
61483
  const chatId = chat.persisted.id;
@@ -61703,6 +61709,11 @@ var ChatService = class {
61703
61709
  );
61704
61710
  chat.acceptedUserEvents.set(message.id, acceptedEvent);
61705
61711
  this.activateTurn(chat, message.id);
61712
+ const transcriptAuth = currentTranscriptAuth(chat.persisted.provider);
61713
+ if (JSON.stringify(chat.persisted.transcriptAuth) !== JSON.stringify(transcriptAuth)) {
61714
+ chat.persisted.transcriptAuth = transcriptAuth;
61715
+ await this.persistAllChats();
61716
+ }
61706
61717
  await this.publish({
61707
61718
  type: "chat.turn.started",
61708
61719
  payload: {
@@ -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-DTKUVZ6U.js";
6
+ } from "./chunk-K2WA7ZYZ.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-NTM575B4.js";
12
+ } from "./chunk-LGWE7MSQ.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-NTM575B4.js";
12
+ } from "./chunk-LGWE7MSQ.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.975",
3
+ "version": "0.1.977",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",