@elvatis_com/openclaw-cli-bridge-elvatis 1.3.1 → 1.3.3
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.
- package/index.ts +29 -19
- package/openclaw.plugin.json +1 -1
- package/package.json +2 -2
package/index.ts
CHANGED
|
@@ -322,12 +322,32 @@ async function cleanupBrowsers(log: (msg: string) => void): Promise<void> {
|
|
|
322
322
|
log("[cli-bridge] browser resources cleaned up");
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
+
/**
|
|
326
|
+
* Singleton guard for ensureAllProviderContexts — prevents concurrent spawns.
|
|
327
|
+
* If a run is already in progress, callers await the same promise instead of
|
|
328
|
+
* spawning a new Chromium each time.
|
|
329
|
+
*/
|
|
330
|
+
let _ensureAllRunning: Promise<void> | null = null;
|
|
331
|
+
|
|
325
332
|
/**
|
|
326
333
|
* Ensure all browser provider contexts are connected.
|
|
327
334
|
* 1. Try the shared OpenClaw browser (CDP 18800)
|
|
328
335
|
* 2. Fallback: launch a persistent headless Chromium per provider (saved profile with cookies)
|
|
336
|
+
*
|
|
337
|
+
* SAFETY: Only one concurrent run allowed. Extra callers await the existing run.
|
|
329
338
|
*/
|
|
330
339
|
async function ensureAllProviderContexts(log: (msg: string) => void): Promise<void> {
|
|
340
|
+
if (_ensureAllRunning) {
|
|
341
|
+
log("[cli-bridge] ensureAllProviderContexts already running — awaiting existing run");
|
|
342
|
+
return _ensureAllRunning;
|
|
343
|
+
}
|
|
344
|
+
_ensureAllRunning = _doEnsureAllProviderContexts(log).finally(() => {
|
|
345
|
+
_ensureAllRunning = null;
|
|
346
|
+
});
|
|
347
|
+
return _ensureAllRunning;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
async function _doEnsureAllProviderContexts(log: (msg: string) => void): Promise<void> {
|
|
331
351
|
const { chromium } = await import("playwright");
|
|
332
352
|
|
|
333
353
|
// Try CDP first (OpenClaw browser)
|
|
@@ -726,14 +746,10 @@ const plugin = {
|
|
|
726
746
|
const codexAuthPath = cfg.codexAuthPath ?? DEFAULT_CODEX_AUTH_PATH;
|
|
727
747
|
const grokSessionPath = cfg.grokSessionPath ?? DEFAULT_SESSION_PATH;
|
|
728
748
|
|
|
729
|
-
//
|
|
730
|
-
void tryRestoreGrokSession(grokSessionPath, (msg) => api.logger.info(msg));
|
|
749
|
+
// Grok session restore on startup REMOVED — on-demand only via /grok-login.
|
|
731
750
|
|
|
732
|
-
//
|
|
733
|
-
|
|
734
|
-
await new Promise(r => setTimeout(r, 3000)); // wait for proxy to start
|
|
735
|
-
await ensureAllProviderContexts((msg) => api.logger.info(msg));
|
|
736
|
-
})();
|
|
751
|
+
// Auto-connect on startup REMOVED — browsers are launched on-demand via /xxx-login only.
|
|
752
|
+
// Spawning 4 persistent Chromium contexts at startup caused OOM under load.
|
|
737
753
|
|
|
738
754
|
// ── Phase 1: openai-codex auth bridge ─────────────────────────────────────
|
|
739
755
|
if (enableCodex) {
|
|
@@ -848,8 +864,7 @@ const plugin = {
|
|
|
848
864
|
const editor = await page.locator(".ProseMirror").isVisible().catch(() => false);
|
|
849
865
|
if (editor) { claudeContext = ctx; return ctx; }
|
|
850
866
|
}
|
|
851
|
-
//
|
|
852
|
-
await ensureAllProviderContexts((msg) => api.logger.info(msg));
|
|
867
|
+
// No fallback spawn — return existing context or null to avoid Chromium leak
|
|
853
868
|
return claudeContext;
|
|
854
869
|
},
|
|
855
870
|
getGeminiContext: () => geminiContext,
|
|
@@ -861,8 +876,7 @@ const plugin = {
|
|
|
861
876
|
const editor = await page.locator(".ql-editor").isVisible().catch(() => false);
|
|
862
877
|
if (editor) { geminiContext = ctx; return ctx; }
|
|
863
878
|
}
|
|
864
|
-
//
|
|
865
|
-
await ensureAllProviderContexts((msg) => api.logger.info(msg));
|
|
879
|
+
// No fallback spawn — return existing context or null to avoid Chromium leak
|
|
866
880
|
return geminiContext;
|
|
867
881
|
},
|
|
868
882
|
getChatGPTContext: () => chatgptContext,
|
|
@@ -874,8 +888,7 @@ const plugin = {
|
|
|
874
888
|
const editor = await page.locator("#prompt-textarea").isVisible().catch(() => false);
|
|
875
889
|
if (editor) { chatgptContext = ctx; return ctx; }
|
|
876
890
|
}
|
|
877
|
-
//
|
|
878
|
-
await ensureAllProviderContexts((msg) => api.logger.info(msg));
|
|
891
|
+
// No fallback spawn — return existing context or null to avoid Chromium leak
|
|
879
892
|
return chatgptContext;
|
|
880
893
|
},
|
|
881
894
|
});
|
|
@@ -919,8 +932,7 @@ const plugin = {
|
|
|
919
932
|
const editor = await page.locator(".ProseMirror").isVisible().catch(() => false);
|
|
920
933
|
if (editor) { claudeContext = ctx; return ctx; }
|
|
921
934
|
}
|
|
922
|
-
//
|
|
923
|
-
await ensureAllProviderContexts((msg) => api.logger.info(msg));
|
|
935
|
+
// No fallback spawn — return existing context or null to avoid Chromium leak
|
|
924
936
|
return claudeContext;
|
|
925
937
|
},
|
|
926
938
|
getGeminiContext: () => geminiContext,
|
|
@@ -932,8 +944,7 @@ const plugin = {
|
|
|
932
944
|
const editor = await page.locator(".ql-editor").isVisible().catch(() => false);
|
|
933
945
|
if (editor) { geminiContext = ctx; return ctx; }
|
|
934
946
|
}
|
|
935
|
-
//
|
|
936
|
-
await ensureAllProviderContexts((msg) => api.logger.info(msg));
|
|
947
|
+
// No fallback spawn — return existing context or null to avoid Chromium leak
|
|
937
948
|
return geminiContext;
|
|
938
949
|
},
|
|
939
950
|
getChatGPTContext: () => chatgptContext,
|
|
@@ -945,8 +956,7 @@ const plugin = {
|
|
|
945
956
|
const editor = await page.locator("#prompt-textarea").isVisible().catch(() => false);
|
|
946
957
|
if (editor) { chatgptContext = ctx; return ctx; }
|
|
947
958
|
}
|
|
948
|
-
//
|
|
949
|
-
await ensureAllProviderContexts((msg) => api.logger.info(msg));
|
|
959
|
+
// No fallback spawn — return existing context or null to avoid Chromium leak
|
|
950
960
|
return chatgptContext;
|
|
951
961
|
},
|
|
952
962
|
});
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "openclaw-cli-bridge-elvatis",
|
|
3
3
|
"name": "OpenClaw CLI Bridge",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.3",
|
|
5
5
|
"description": "Phase 1: openai-codex auth bridge. Phase 2: local HTTP proxy routing model calls through gemini/claude CLIs (vllm provider).",
|
|
6
6
|
"providers": [
|
|
7
7
|
"openai-codex"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elvatis_com/openclaw-cli-bridge-elvatis",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Bridges gemini, claude, and codex CLI tools as OpenClaw model providers. Reads existing CLI auth without re-login.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"openclaw": {
|
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"playwright": "^1.58.2"
|
|
24
24
|
}
|
|
25
|
-
}
|
|
25
|
+
}
|