@integrity-labs/agt-cli 0.28.192 → 0.28.194

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.
@@ -3,7 +3,7 @@ import {
3
3
  formatMissingVar,
4
4
  isClaudeFastMode,
5
5
  probeMcpEnvSubstitution
6
- } from "./chunk-C7VSGFDC.js";
6
+ } from "./chunk-4D2OW6W6.js";
7
7
  import {
8
8
  reapOrphanChannelMcps
9
9
  } from "./chunk-XWVM4KPK.js";
@@ -519,6 +519,7 @@ function creditWatchdogGiveUpCount(codeName, count) {
519
519
  }
520
520
 
521
521
  // src/lib/persistent-session.ts
522
+ var OPENROUTER_ANTHROPIC_BASE_URL = "https://openrouter.ai/api";
522
523
  function syncClaudeCredsToRoot() {
523
524
  if (platform() !== "linux") return true;
524
525
  if (typeof process.getuid !== "function" || process.getuid() !== 0) return true;
@@ -658,7 +659,7 @@ function restartEgressSidecar(codeName) {
658
659
  }
659
660
  }
660
661
  function buildDockerRunCommand(args) {
661
- const { codeName, agentId, wrapperPath, projectDir, homeDir, runId, passApiKey, egress } = args;
662
+ const { codeName, agentId, wrapperPath, projectDir, homeDir, runId, passApiKey, passOpenRouter, egress } = args;
662
663
  const q = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
663
664
  const agentDir = join2(homeDir, ".augmented", codeName);
664
665
  const agentIdDir = join2(homeDir, ".augmented", agentId);
@@ -679,6 +680,12 @@ function buildDockerRunCommand(args) {
679
680
  const envArgs = [`-e ${q(`HOME=${homeDir}`)}`];
680
681
  envArgs.push(`-e ${q(`npm_config_cache=${join2(agentDir, ".npm-cache")}`)}`);
681
682
  if (passApiKey) envArgs.push("-e ANTHROPIC_API_KEY");
683
+ if (passOpenRouter) {
684
+ envArgs.push("-e ANTHROPIC_BASE_URL");
685
+ envArgs.push("-e ANTHROPIC_AUTH_TOKEN");
686
+ envArgs.push("-e ANTHROPIC_MODEL");
687
+ envArgs.push("-e ANTHROPIC_SMALL_FAST_MODEL");
688
+ }
682
689
  if (runId) envArgs.push(`-e ${q(`AGT_RUN_ID=${runId}`)}`);
683
690
  envArgs.push("-e AGT_API_KEY");
684
691
  envArgs.push("-e AGT_HOST");
@@ -905,15 +912,18 @@ function startPersistentSession(config) {
905
912
  function spawnSession(config, session) {
906
913
  const { codeName, projectDir, mcpConfigPath, claudeMdPath, channels, devChannels, apiHost, log } = config;
907
914
  const claudeAuthMode = config.claudeAuthMode ?? "subscription";
915
+ const openRouterMode = !!config.openRouter;
908
916
  const tmuxSession = `agt-${codeName}`;
909
- log(`[persistent-session] Starting tmux session '${tmuxSession}' for '${codeName}' (auth=${claudeAuthMode})`);
917
+ log(
918
+ `[persistent-session] Starting tmux session '${tmuxSession}' for '${codeName}' (auth=${openRouterMode ? "openrouter" : claudeAuthMode})`
919
+ );
910
920
  try {
911
921
  sanitizeMcpJson(mcpConfigPath, apiHost);
912
922
  try {
913
923
  execSync(`tmux kill-session -t ${tmuxSession} 2>/dev/null`, { stdio: "ignore" });
914
924
  } catch {
915
925
  }
916
- if (claudeAuthMode === "subscription") {
926
+ if (claudeAuthMode === "subscription" && !openRouterMode) {
917
927
  const credsSynced = syncClaudeCredsToRoot();
918
928
  if (!credsSynced && platform() === "linux" && typeof process.getuid === "function" && process.getuid() === 0) {
919
929
  log(`[persistent-session] No Claude Code credentials found under /root/.claude or /home/*. Pair via browser from the host page, or run 'claude /login' on the host.`);
@@ -930,7 +940,9 @@ function spawnSession(config, session) {
930
940
  }
931
941
  }
932
942
  }
933
- if (!config.anthropicApiKey) {
943
+ if (openRouterMode) {
944
+ log(`[persistent-session] OpenRouter mode for '${codeName}' \u2014 model=${config.openRouter.model} (OAuth creds purged; using ANTHROPIC_BASE_URL override)`);
945
+ } else if (!config.anthropicApiKey) {
934
946
  log(`[persistent-session] api_key mode but no anthropicApiKey passed. Session will fail auth.`);
935
947
  }
936
948
  }
@@ -968,8 +980,10 @@ function spawnSession(config, session) {
968
980
  if (devChannels.length > 0) args.push("--dangerously-load-development-channels", ...devChannels);
969
981
  args.push("--mcp-config", mcpConfigPath);
970
982
  if (existsSync2(claudeMdPath)) args.push("--system-prompt-file", claudeMdPath);
971
- const modelAlias = claudeModelAlias(config.primaryModel);
972
- if (modelAlias) args.push("--model", modelAlias);
983
+ if (!openRouterMode) {
984
+ const modelAlias = claudeModelAlias(config.primaryModel);
985
+ if (modelAlias) args.push("--model", modelAlias);
986
+ }
973
987
  args.push("--allow-dangerously-skip-permissions");
974
988
  args.push("--dangerously-skip-permissions");
975
989
  args.push("--strict-mcp-config");
@@ -986,7 +1000,15 @@ function spawnSession(config, session) {
986
1000
  claudeArgsJoined
987
1001
  });
988
1002
  const tmuxSessionEnvArgs = [];
989
- if (claudeAuthMode === "api_key" && config.anthropicApiKey) {
1003
+ if (openRouterMode) {
1004
+ const or = config.openRouter;
1005
+ tmuxSessionEnvArgs.push("-e", `ANTHROPIC_BASE_URL=${OPENROUTER_ANTHROPIC_BASE_URL}`);
1006
+ tmuxSessionEnvArgs.push("-e", `ANTHROPIC_AUTH_TOKEN=${or.authToken}`);
1007
+ tmuxSessionEnvArgs.push("-e", `ANTHROPIC_MODEL=${or.model}`);
1008
+ if (or.smallFastModel) {
1009
+ tmuxSessionEnvArgs.push("-e", `ANTHROPIC_SMALL_FAST_MODEL=${or.smallFastModel}`);
1010
+ }
1011
+ } else if (claudeAuthMode === "api_key" && config.anthropicApiKey) {
990
1012
  tmuxSessionEnvArgs.push("-e", `ANTHROPIC_API_KEY=${config.anthropicApiKey}`);
991
1013
  }
992
1014
  const sessionHomeDir = process.env.HOME?.trim() || homedir2();
@@ -1004,7 +1026,10 @@ function spawnSession(config, session) {
1004
1026
  projectDir,
1005
1027
  homeDir: sessionHomeDir,
1006
1028
  runId: config.runId ?? void 0,
1007
- passApiKey: claudeAuthMode === "api_key" && !!config.anthropicApiKey,
1029
+ passApiKey: !openRouterMode && claudeAuthMode === "api_key" && !!config.anthropicApiKey,
1030
+ // ENG-7152: forward the OpenRouter ANTHROPIC_* vars (by name) from the
1031
+ // session-shell env into the container, same posture as passApiKey.
1032
+ passOpenRouter: openRouterMode,
1008
1033
  egress
1009
1034
  }) : JSON.stringify(wrapperPath);
1010
1035
  const tmuxEnv = {
@@ -1018,15 +1043,22 @@ function spawnSession(config, session) {
1018
1043
  if (config.runId) {
1019
1044
  tmuxEnv["AGT_RUN_ID"] = config.runId;
1020
1045
  }
1021
- const apiKeyEnv = claudeAuthMode === "api_key" && config.anthropicApiKey ? { ANTHROPIC_API_KEY: config.anthropicApiKey } : {};
1046
+ const apiKeyEnv = !openRouterMode && claudeAuthMode === "api_key" && config.anthropicApiKey ? { ANTHROPIC_API_KEY: config.anthropicApiKey } : {};
1047
+ const openRouterEnv = openRouterMode ? {
1048
+ ANTHROPIC_BASE_URL: OPENROUTER_ANTHROPIC_BASE_URL,
1049
+ ANTHROPIC_AUTH_TOKEN: config.openRouter.authToken,
1050
+ ANTHROPIC_MODEL: config.openRouter.model,
1051
+ ...config.openRouter.smallFastModel ? { ANTHROPIC_SMALL_FAST_MODEL: config.openRouter.smallFastModel } : {}
1052
+ } : {};
1022
1053
  const probeBaseEnv = isolationMode(codeName) === "docker" ? {
1023
1054
  HOME: tmuxEnv["HOME"],
1024
1055
  ...apiKeyEnv,
1056
+ ...openRouterEnv,
1025
1057
  ...config.runId ? { AGT_RUN_ID: config.runId } : {},
1026
1058
  AGT_API_KEY: tmuxEnv["AGT_API_KEY"],
1027
1059
  AGT_HOST: tmuxEnv["AGT_HOST"],
1028
1060
  AGT_AGENT_ID: config.agentId
1029
- } : { ...tmuxEnv, ...apiKeyEnv };
1061
+ } : { ...tmuxEnv, ...apiKeyEnv, ...openRouterEnv };
1030
1062
  for (const f of probeMcpEnvSubstitution({
1031
1063
  mcpConfigPath,
1032
1064
  envIntegrationsPath: join2(projectDir, ".env.integrations"),
@@ -1588,4 +1620,4 @@ export {
1588
1620
  stopAllSessionsAndWait,
1589
1621
  getProjectDir
1590
1622
  };
1591
- //# sourceMappingURL=chunk-SJ3TWGEN.js.map
1623
+ //# sourceMappingURL=chunk-AABQHAHG.js.map