openclaw-abacusai-auth 1.2.6 → 1.2.7

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/index.ts +23 -17
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -814,7 +814,7 @@ function buildModelDefinition(modelId: string) {
814
814
  * but the config still stores the port from when `openclaw models auth login`
815
815
  * was first run.
816
816
  */
817
- function updateBaseUrlInConfig(): void {
817
+ function updateBaseUrlInConfig(pluginApi: any): void {
818
818
  if (!proxyPort) return;
819
819
  const newBaseUrl = `http://${PROXY_HOST}:${proxyPort}`;
820
820
  try {
@@ -823,24 +823,30 @@ function updateBaseUrlInConfig(): void {
823
823
  process.env.CLAWDBOT_STATE_DIR ||
824
824
  join(homedir(), ".openclaw");
825
825
  const configPath = join(stateDir, "openclaw.json");
826
- if (!existsSync(configPath)) return;
827
826
 
828
- let raw = readFileSync(configPath, "utf-8");
829
- // Strip UTF-8 BOM if present
830
- if (raw.charCodeAt(0) === 0xFEFF) raw = raw.slice(1);
831
- const config = JSON.parse(raw);
832
- const currentUrl = config?.models?.providers?.abacusai?.baseUrl;
833
-
834
- if (currentUrl === newBaseUrl) {
835
- // Already up to date
836
- return;
827
+ // 1. Update in-memory OpenClaw config if available (so it works immediately and saves correctly)
828
+ let inMemoryUpdated = false;
829
+ if (pluginApi?.config?.models?.providers?.abacusai) {
830
+ if (pluginApi.config.models.providers.abacusai.baseUrl !== newBaseUrl) {
831
+ pluginApi.config.models.providers.abacusai.baseUrl = newBaseUrl;
832
+ inMemoryUpdated = true;
833
+ }
837
834
  }
838
835
 
839
- // Update the baseUrl
840
- if (config.models?.providers?.abacusai) {
841
- config.models.providers.abacusai.baseUrl = newBaseUrl;
842
- writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
843
- console.log(`[abacusai] Updated config baseUrl: ${currentUrl} → ${newBaseUrl}`);
836
+ // 2. Fallback to writing the disk file directly if needed
837
+ if (existsSync(configPath)) {
838
+ let raw = readFileSync(configPath, "utf-8");
839
+ if (raw.charCodeAt(0) === 0xFEFF) raw = raw.slice(1);
840
+ const config = JSON.parse(raw);
841
+ const currentUrl = config?.models?.providers?.abacusai?.baseUrl;
842
+
843
+ if (currentUrl !== newBaseUrl && config.models?.providers?.abacusai) {
844
+ config.models.providers.abacusai.baseUrl = newBaseUrl;
845
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
846
+ console.log(`[abacusai] Updated config baseUrl on disk: ${currentUrl} → ${newBaseUrl}`);
847
+ } else if (inMemoryUpdated) {
848
+ console.log(`[abacusai] Updated in-memory baseUrl to ${newBaseUrl}`);
849
+ }
844
850
  }
845
851
  } catch (err) {
846
852
  console.error("[abacusai] Failed to update baseUrl in config:", err);
@@ -913,7 +919,7 @@ const abacusaiPlugin = {
913
919
  // Update baseUrl in config to match the new proxy port
914
920
  // (The proxy gets a new random port each time the gateway starts,
915
921
  // but the config still has the port from when auth was first run)
916
- updateBaseUrlInConfig();
922
+ updateBaseUrlInConfig(pluginApi);
917
923
  })
918
924
  .catch((err) => {
919
925
  console.error("[abacusai] Failed to auto-start proxy:", err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-abacusai-auth",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "OpenClaw AbacusAI provider plugin - Third-party plugin for AbacusAI RouteLLM integration",
5
5
  "type": "module",
6
6
  "main": "index.ts",