replicas-engine 0.1.119 → 0.1.120

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.
Files changed (2) hide show
  1. package/dist/src/index.js +60 -7
  2. package/package.json +1 -1
package/dist/src/index.js CHANGED
@@ -42,6 +42,18 @@ function requireValidURL(value, name) {
42
42
  throw new Error(`Invalid engine environment: ${name} must be a valid URL`);
43
43
  }
44
44
  }
45
+ function parseClaudeAuthMethod(value) {
46
+ if (value === "oauth" || value === "api_key" || value === "bedrock") {
47
+ return value;
48
+ }
49
+ return void 0;
50
+ }
51
+ function parseCodexAuthMethod(value) {
52
+ if (value === "oauth" || value === "api_key") {
53
+ return value;
54
+ }
55
+ return void 0;
56
+ }
45
57
  var IS_WARMING_MODE = process.argv.includes("--warming");
46
58
  function loadEngineEnv() {
47
59
  const HOME_DIR = homedir();
@@ -66,7 +78,9 @@ function loadEngineEnv() {
66
78
  CLAUDE_CODE_USE_BEDROCK: readEnv("CLAUDE_CODE_USE_BEDROCK"),
67
79
  AWS_ACCESS_KEY_ID: readEnv("AWS_ACCESS_KEY_ID"),
68
80
  AWS_SECRET_ACCESS_KEY: readEnv("AWS_SECRET_ACCESS_KEY"),
69
- AWS_REGION: readEnv("AWS_REGION")
81
+ AWS_REGION: readEnv("AWS_REGION"),
82
+ REPLICAS_CLAUDE_AUTH_METHOD: parseClaudeAuthMethod(readEnv("REPLICAS_CLAUDE_AUTH_METHOD")),
83
+ REPLICAS_CODEX_AUTH_METHOD: parseCodexAuthMethod(readEnv("REPLICAS_CODEX_AUTH_METHOD"))
70
84
  };
71
85
  if (!IS_WARMING_MODE && !env.WORKSPACE_ID) {
72
86
  console.error("WORKSPACE_ID is not set \u2014 this is required in normal (non-warming) mode");
@@ -1137,7 +1151,7 @@ function parseReplicasConfigString(content, filename) {
1137
1151
  }
1138
1152
 
1139
1153
  // ../shared/src/engine/environment.ts
1140
- var DAYTONA_SNAPSHOT_ID = "22-04-2026-islington-v2";
1154
+ var DAYTONA_SNAPSHOT_ID = "23-04-2026-islington-v1";
1141
1155
 
1142
1156
  // ../shared/src/engine/types.ts
1143
1157
  var DEFAULT_CHAT_TITLES = {
@@ -2447,6 +2461,43 @@ var CodingAgentManager = class {
2447
2461
  }
2448
2462
  };
2449
2463
 
2464
+ // src/utils/agent-env.ts
2465
+ function buildClaudeAgentEnv(overrides) {
2466
+ const env = { ...process.env };
2467
+ if (overrides) {
2468
+ Object.assign(env, overrides);
2469
+ }
2470
+ if (shouldStripAnthropicApiKey()) {
2471
+ env.ANTHROPIC_API_KEY = void 0;
2472
+ }
2473
+ return env;
2474
+ }
2475
+ function buildCodexAgentEnv() {
2476
+ const env = {};
2477
+ for (const [key, value] of Object.entries(process.env)) {
2478
+ if (typeof value === "string") {
2479
+ env[key] = value;
2480
+ }
2481
+ }
2482
+ if (shouldStripOpenAIApiKey()) {
2483
+ delete env.OPENAI_API_KEY;
2484
+ }
2485
+ return env;
2486
+ }
2487
+ function resolveCodexApiKey() {
2488
+ if (shouldStripOpenAIApiKey()) {
2489
+ return void 0;
2490
+ }
2491
+ return ENGINE_ENV.OPENAI_API_KEY;
2492
+ }
2493
+ function shouldStripAnthropicApiKey() {
2494
+ const method = ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD;
2495
+ return method === "oauth" || method === "bedrock";
2496
+ }
2497
+ function shouldStripOpenAIApiKey() {
2498
+ return ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD === "oauth";
2499
+ }
2500
+
2450
2501
  // src/managers/claude-manager.ts
2451
2502
  var PromptStream = class {
2452
2503
  queue = [];
@@ -2592,7 +2643,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
2592
2643
  preset: "claude_code",
2593
2644
  append: combinedInstructions
2594
2645
  };
2595
- const queryEnv = this.envOverrides ? { ...process.env, ...this.envOverrides } : process.env;
2646
+ const queryEnv = buildClaudeAgentEnv(this.envOverrides);
2596
2647
  const response = query({
2597
2648
  prompt: promptStream,
2598
2649
  options: {
@@ -2764,9 +2815,11 @@ var CodexManager = class extends CodingAgentManager {
2764
2815
  activeAbortController = null;
2765
2816
  constructor(options) {
2766
2817
  super(options);
2767
- this.codex = new Codex(
2768
- ENGINE_ENV.OPENAI_API_KEY ? { apiKey: ENGINE_ENV.OPENAI_API_KEY } : void 0
2769
- );
2818
+ const codexApiKey = resolveCodexApiKey();
2819
+ this.codex = new Codex({
2820
+ env: buildCodexAgentEnv(),
2821
+ ...codexApiKey ? { apiKey: codexApiKey } : {}
2822
+ });
2770
2823
  this.tempImageDir = join11(homedir8(), ".replicas", "codex", "temp-images");
2771
2824
  this.initializeManager(this.processMessageInternal.bind(this));
2772
2825
  }
@@ -3530,7 +3583,7 @@ function getEnvironmentSection() {
3530
3583
  `Platform: ${process.platform}`,
3531
3584
  getShellInfoLine(),
3532
3585
  `OS Version: ${unameSR}`,
3533
- `The most recent Claude model family is Claude 4.5/4.6. Model IDs \u2014 Opus 4.6: 'claude-opus-4-6', Sonnet 4.6: 'claude-sonnet-4-6', Haiku 4.5: 'claude-haiku-4-5-20251001'. When building AI applications, default to the latest and most capable Claude models.`
3586
+ `The most recent Claude model family is Claude 4.5/4.6/4.7. Model IDs \u2014 Opus 4.7: 'claude-opus-4-7', Sonnet 4.6: 'claude-sonnet-4-6', Haiku 4.5: 'claude-haiku-4-5-20251001'. When building AI applications, default to the latest and most capable Claude models.`
3534
3587
  ];
3535
3588
  return [
3536
3589
  `# Environment`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.119",
3
+ "version": "0.1.120",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",