@kokorolx/ai-sandbox-wrapper 3.4.0 → 3.4.1
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/bin/ai-run +11 -2
- package/lib/playwright-mcp-config.sh +12 -7
- package/package.json +1 -1
package/bin/ai-run
CHANGED
|
@@ -823,8 +823,17 @@ if [[ "$TOOL" == "opencode" ]] && command -v jq &>/dev/null && [[ -f "$AI_SANDBO
|
|
|
823
823
|
# Deterministic port per container name
|
|
824
824
|
CONTAINER_HASH=$(echo "$CONTAINER_NAME_VALUE" | md5sum | cut -c1-4)
|
|
825
825
|
HOST_CHROME_CDP_PORT=$((19222 + 0x$CONTAINER_HASH % 100))
|
|
826
|
-
|
|
827
|
-
|
|
826
|
+
|
|
827
|
+
# Only register entries for MCP binaries actually present in the image
|
|
828
|
+
# (tracked in $AI_SANDBOX_CONFIG by setup.sh). Otherwise opencode would
|
|
829
|
+
# try to spawn a missing binary and fail. (is_mcp_installed is defined
|
|
830
|
+
# later in the file, so use jq inline here.)
|
|
831
|
+
if jq -e '.mcp.installed // [] | index("playwright") != null' "$AI_SANDBOX_CONFIG" &>/dev/null; then
|
|
832
|
+
PLAYWRIGHT_MCP_NAME="playwright_port_${HOST_CHROME_CDP_PORT}"
|
|
833
|
+
fi
|
|
834
|
+
if jq -e '.mcp.installed // [] | index("chrome-devtools") != null' "$AI_SANDBOX_CONFIG" &>/dev/null; then
|
|
835
|
+
CHROME_DEVTOOLS_MCP_NAME="chrome-devtools_port_${HOST_CHROME_CDP_PORT}"
|
|
836
|
+
fi
|
|
828
837
|
|
|
829
838
|
# Reuse-if-alive: probe before launching
|
|
830
839
|
if pmcp::probe_chrome "$HOST_CHROME_CDP_PORT"; then
|
|
@@ -88,20 +88,25 @@ pmcp::register() {
|
|
|
88
88
|
echo " ➕ pmcp: registered $key"
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
# Register
|
|
91
|
+
# Register playwright-mcp and/or chrome-devtools-mcp for a host Chrome on
|
|
92
92
|
# a given CDP port. Sweeps dead entries of both prefixes first, then writes
|
|
93
|
-
# the
|
|
94
|
-
#
|
|
93
|
+
# the requested entries. Pass empty string for a key to skip that one.
|
|
94
|
+
# MUST be called inside a flock.
|
|
95
|
+
# Args: $1 = cfg, $2 = port, $3 = playwright key (or ""), $4 = chrome-devtools key (or "")
|
|
95
96
|
pmcp::register_host_chrome() {
|
|
96
97
|
local cfg="$1" port="$2" pw_key="$3" cd_key="$4"
|
|
97
98
|
local url="http://$PMCP_DOCKER_HOST_IP:$port"
|
|
98
99
|
|
|
99
100
|
pmcp::sweep_dead "$cfg" "playwright_"
|
|
100
101
|
pmcp::sweep_dead "$cfg" "chrome-devtools_"
|
|
101
|
-
|
|
102
|
-
"
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
if [[ -n "$pw_key" ]]; then
|
|
103
|
+
pmcp::register "$cfg" "$pw_key" \
|
|
104
|
+
"[\"playwright-mcp\",\"--cdp-endpoint\",\"$url\"]"
|
|
105
|
+
fi
|
|
106
|
+
if [[ -n "$cd_key" ]]; then
|
|
107
|
+
pmcp::register "$cfg" "$cd_key" \
|
|
108
|
+
"[\"chrome-devtools-mcp\",\"--browserUrl\",\"$url\"]"
|
|
109
|
+
fi
|
|
105
110
|
}
|
|
106
111
|
|
|
107
112
|
# Sweep dead playwright_* entries and append a new one. MUST be called inside
|
package/package.json
CHANGED